From 13ab56c394ddbf48ec612b6ec9af7dd896ce726a Mon Sep 17 00:00:00 2001 From: Prakxo Date: Wed, 2 Oct 2024 20:34:40 +0200 Subject: [PATCH] link ac_ride_off_demo --- config/rel_slices.yml | 5 ++ include/ac_ride_off_demo.h | 13 +++ src/ac_ride_off_demo.c | 45 ++++++++++ src/ac_ride_off_demo_move.c_inc | 140 ++++++++++++++++++++++++++++++++ 4 files changed, 203 insertions(+) create mode 100644 src/ac_ride_off_demo.c create mode 100644 src/ac_ride_off_demo_move.c_inc diff --git a/config/rel_slices.yml b/config/rel_slices.yml index 148432a6..bd0ecf11 100644 --- a/config/rel_slices.yml +++ b/config/rel_slices.yml @@ -540,6 +540,11 @@ ac_quest_talk_init.c: .text: [0x80489A34, 0x8048D768] .rodata: [0x80644CA8, 0x80644D10] .data: [0x8068B048, 0x8068B310] +ac_ride_off_demo.c: + .text: [0x80496218, 0x804967A4] + .rodata: [0x80644D90, 0x80644DB0] + .data: [0x8068BB28, 0x8068BB80] + .bss: [0x812FCCD8, 0x812FCCE0] ac_rope.c: .text: [0x804967A4, 0x80496AB8] .rodata: [0x80644DB0, 0x80644DB8] diff --git a/include/ac_ride_off_demo.h b/include/ac_ride_off_demo.h index e8be7827..82b64c15 100644 --- a/include/ac_ride_off_demo.h +++ b/include/ac_ride_off_demo.h @@ -3,11 +3,24 @@ #include "types.h" #include "m_actor.h" +#include "ac_train1.h" #ifdef __cplusplus extern "C" { #endif +typedef void (*aROD_INIT_PROC)(ACTOR*, GAME*); + +typedef struct ride_off_demo_s { + ACTOR actor_class; + int current_action; + int _178; + aROD_INIT_PROC current_proc; + TRAIN1_ACTOR* train_actor; + ACTOR* station_master_actor; + int _188; +} RIDE_OFF_DEMO_ACTOR; + extern ACTOR_PROFILE Ride_Off_Demo_Profile; #ifdef __cplusplus diff --git a/src/ac_ride_off_demo.c b/src/ac_ride_off_demo.c new file mode 100644 index 00000000..bf506be6 --- /dev/null +++ b/src/ac_ride_off_demo.c @@ -0,0 +1,45 @@ +#include "ac_ride_off_demo.h" +#include "libultra/libultra.h" +#include "m_bgm.h" +#include "m_common_data.h" +#include "m_demo.h" +#include "m_player_lib.h" + +static void aROD_actor_ct(ACTOR* actor, GAME* game); +static void aROD_actor_dt(ACTOR* actor, GAME* game); +static void aROD_actor_move(ACTOR* actor, GAME* game); + +mDemo_Clip_c aROD_clip; + +ACTOR_PROFILE Ride_Off_Demo_Profile = { + mAc_PROFILE_RIDE_OFF_DEMO, + ACTOR_PART_CONTROL, + ACTOR_STATE_CAN_MOVE_IN_DEMO_SCENES | ACTOR_STATE_NO_MOVE_WHILE_CULLED, + EMPTY_NO, + ACTOR_OBJ_BANK_KEEP, + sizeof(RIDE_OFF_DEMO_ACTOR), + aROD_actor_ct, + aROD_actor_dt, + aROD_actor_move, + NONE_ACTOR_PROC, + NULL, +}; + +static void aROD_setupAction(ACTOR* actor, GAME* game, int action); + +static void aROD_actor_ct(ACTOR* actor, GAME* game) { + Common_Set(clip.demo_clip, &aROD_clip); + bzero(&aROD_clip, sizeof(mDemo_Clip_c)); + Common_Set(clip.demo_clip->demo_class, actor); + Common_Set(clip.demo_clip->type, mDemo_CLIP_TYPE_RIDE_OFF_DEMO); + + aROD_setupAction(actor, game, 0); +} + +static void aROD_actor_dt(ACTOR* actor, GAME* game) { + if (Common_Get(clip.demo_clip) != NULL) { + Common_Set(clip.demo_clip, NULL); + } +} + +#include "../src/ac_ride_off_demo_move.c_inc" diff --git a/src/ac_ride_off_demo_move.c_inc b/src/ac_ride_off_demo_move.c_inc new file mode 100644 index 00000000..eadce01a --- /dev/null +++ b/src/ac_ride_off_demo_move.c_inc @@ -0,0 +1,140 @@ +#define aROD_OFF_UT_X_POS 2220 +#define aROD_OFF_UT_Z_POS 840 + +#define aROD_PLYR_X_START_POS 1970 +#define aROD_PLYR_Y_START_POS 760 + +static void aROD_change_player_demo_standing_train(GAME* game) { + if (mPlib_get_player_actor_main_index(game) != mPlayer_INDEX_DEMO_STANDING_TRAIN) { + mPlib_request_main_demo_standing_train_type1(game); + } +} + +static void aROD_first_set(ACTOR* actor, GAME* game) { + Common_Set(train_coming_flag, 3); + aROD_change_player_demo_standing_train(game); + aROD_setupAction(actor, game, 1); +} + +static void aROD_train_birth_wait(ACTOR* actor, GAME* game) { + RIDE_OFF_DEMO_ACTOR* ride_off = (RIDE_OFF_DEMO_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY*)game; + TRAIN1_ACTOR* train = (TRAIN1_ACTOR*)Actor_info_fgName_search(&play->actor_info, TRAIN1, ACTOR_PART_ITEM); + + aROD_change_player_demo_standing_train(game); + + if (train != NULL) { + ride_off->train_actor = train; + train->player_pass_exists = TRUE; + aROD_setupAction(actor, game, 2); + } +} + +static void aROD_ride_train(ACTOR* actor, GAME* game) { + RIDE_OFF_DEMO_ACTOR* ride_off = (RIDE_OFF_DEMO_ACTOR*)actor; + TRAIN1_ACTOR* train = ride_off->train_actor; + + aROD_change_player_demo_standing_train(game); + + if (train->tr_action == 5) { + aROD_setupAction(actor, game, 3); + } +} + +static void aROD_ride_off_player(ACTOR* actor, GAME* game) { + RIDE_OFF_DEMO_ACTOR* ride_off = (RIDE_OFF_DEMO_ACTOR*)actor; + ACTOR* station_master = ride_off->station_master_actor; + + if (ride_off->_188 == 0) { + if (mDemo_Check(mDemo_TYPE_SPEAK, station_master) == 1) { + ride_off->_188 = 1; + } + } else if (!mDemo_Check(mDemo_TYPE_SPEAK, station_master)) { + aROD_setupAction(actor, game, 4); + } +} + +static void aROD_walk_one_unit(ACTOR* actor, GAME* game) { + RIDE_OFF_DEMO_ACTOR* ride_off = (RIDE_OFF_DEMO_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY*)game; + PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); + + if (player != NULL) { + if (player->actor_class.world.position.z >= aROD_OFF_UT_Z_POS) { + if (F32_IS_ZERO(ride_off->station_master_actor->speed)) { + mPlib_request_main_wait_type3(game); + Camera2_request_main_normal(play, 0, 9); + Actor_delete(actor); + } + } else { + mPlib_Set_goal_player_demo_walk(aROD_OFF_UT_X_POS, aROD_OFF_UT_Z_POS, 2.5f); + } + } +} + +static void aROD_first_set_init(ACTOR* actor, GAME* game) { + GAME_PLAY* play = (GAME_PLAY*)game; + Actor_data* data = play->player_data; + + mBGMPsComp_make_ps_happening(0x2F, 0x168); + data->position.x = aROD_PLYR_X_START_POS; + data->position.z = aROD_PLYR_Y_START_POS; +} + +static void aROD_train_birth_wait_init(ACTOR* actor, GAME* game) { + GAME_PLAY* play = (GAME_PLAY*)game; + xyz_t pos; + + pos.x = 2180.0f; + pos.z = 820.0f; + + pos.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(pos, -35.0f); + Camera2_request_main_demo_fromNowPos2(play, &pos, 0.0f, 0.0f, 0.0f, 9); +} + +static void aROD_ride_off_player_init(ACTOR* actor, GAME* game) { + static xyz_t enter_pos = {2180.0f, 0.0f, 820.0f}; + + RIDE_OFF_DEMO_ACTOR* ride_off = (RIDE_OFF_DEMO_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY*)game; + TRAIN1_ACTOR* train = ride_off->train_actor; + + ride_off->station_master_actor = Actor_info_fgName_search(&play->actor_info, SP_NPC_STATION_MASTER, ACTOR_PART_NPC); + + train->player_pass_exists = FALSE; + mPlib_request_main_demo_getoff_train_type1(game); + ride_off->_188 = 0; + mCoBG_SetAttribute(enter_pos, mCoBG_ATTRIBUTE_STONE); +} + +static void aROD_walk_one_unit_init(ACTOR* actor, GAME* game) { + mPlib_request_main_demo_walk_type1(game, 2220.0f, 840.0f, 2.5f, 0); +} + +static void aROD_init_proc(ACTOR* actor, GAME* game, int idx) { + static aROD_INIT_PROC init_proc[] = { + aROD_first_set_init, aROD_train_birth_wait_init, (aROD_INIT_PROC)&none_proc1, + aROD_ride_off_player_init, aROD_walk_one_unit_init, + }; + + init_proc[idx](actor, game); +} + +static void aROD_setupAction(ACTOR* actor, GAME* game, int idx) { + static aROD_INIT_PROC process[] = { + aROD_first_set, aROD_train_birth_wait, aROD_ride_train, aROD_ride_off_player, aROD_walk_one_unit, + }; + + RIDE_OFF_DEMO_ACTOR* ride_off = (RIDE_OFF_DEMO_ACTOR*)actor; + + ride_off->current_proc = process[idx]; + ride_off->current_action = idx; + aROD_init_proc(actor, game, idx); +} + +static void aROD_actor_move(ACTOR* actor, GAME* game) { + RIDE_OFF_DEMO_ACTOR* ride_off = (RIDE_OFF_DEMO_ACTOR*)actor; + + ride_off->current_proc(actor, game); +} +