diff --git a/rel/ac_douzou.c b/rel/ac_douzou.c index 9e432b5d..aedba775 100644 --- a/rel/ac_douzou.c +++ b/rel/ac_douzou.c @@ -184,7 +184,6 @@ static void aDOU_actor_ct(ACTOR* actor, GAME* game) { cKF_SkeletonInfo_R_play(&douzou->keyframe); aDOU_keep_item(actor); } -#pragma pool_data reset static void aDOU_actor_dt(ACTOR* actor, GAME* game) { STRUCTURE_ACTOR* douzou = (STRUCTURE_ACTOR*)actor; diff --git a/rel/ac_douzou_draw.c_inc b/rel/ac_douzou_draw.c_inc index dc9be74c..5beadaff 100644 --- a/rel/ac_douzou_draw.c_inc +++ b/rel/ac_douzou_draw.c_inc @@ -72,8 +72,6 @@ static int aDOU_actor_draw_before(GAME* game, cKF_SkeletonInfo_R_c* keyframe, in return TRUE; } -#pragma pool_data reset - static void aDOU_actor_draw(ACTOR* actor, GAME* game) { GAME_PLAY* play = (GAME_PLAY*)game; @@ -146,4 +144,3 @@ static void aDOU_actor_draw(ACTOR* actor, GAME* game) { } } } -#pragma pool_data reset diff --git a/rel/ac_douzou_move.c_inc b/rel/ac_douzou_move.c_inc index 42111d4d..b2985ba8 100644 --- a/rel/ac_douzou_move.c_inc +++ b/rel/ac_douzou_move.c_inc @@ -121,7 +121,6 @@ static int aDOU_setEffect_sub(ACTOR* actor, GAME* game, int house_no, int color) return TRUE; } -#pragma pool_data reset static void aDOU_setEffect(ACTOR* actor, GAME* game) { static f32 b_timetbl[mHS_HOUSE_NUM] = { 5.0f, 15.0f, 20.0f, 30.0f }; diff --git a/rel/ac_haniwa.c b/rel/ac_haniwa.c index 94d592d9..3f680c4b 100644 --- a/rel/ac_haniwa.c +++ b/rel/ac_haniwa.c @@ -26,11 +26,10 @@ extern cKF_Animation_R_c cKF_ba_r_hnw_move; extern u8 hnw_tmem_txt[]; extern u8 hnw_face[]; -// #include ac_haniwa_move_procs.c_inc - static void aHNW_actor_ct(ACTOR* actor, GAME* game); static void aHNW_actor_dt(ACTOR* actor, GAME* game); static void aHNW_actor_init(ACTOR* actor, GAME* game); +static void aHNW_actor_draw(ACTOR* actor, GAME* game); ACTOR_PROFILE Haniwa_Profile = { mAc_PROFILE_HANIWA, @@ -95,20 +94,13 @@ static void aHNW_actor_dt(ACTOR* actor, GAME* game) { ClObjPipe_dt(play, &haniwa->col_pipe); } - -static Gfx hnw_tex_model[2]; +#include "../rel/ac_haniwa_move.c_inc" static void aHNW_actor_draw(ACTOR* actor, GAME* game) { - // TODO: this should be fixed when possible. - // we need to add an additional TU for correct ordering - // but PPCdis does not work well with that - - /* static Gfx hnw_tex_model[] = { gsDPLoadTLUT_Dolphin(15, 16, 1, hnw_face), gsSPEndDisplayList(), }; - */ HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; cKF_SkeletonInfo_R_c* keyframe = &haniwa->keyframe; @@ -144,832 +136,3 @@ static void aHNW_actor_draw(ACTOR* actor, GAME* game) { cKF_Si3_draw_R_SV(game, keyframe, m, NULL, NULL, actor); } } - -static void aHNW_setupAction(ACTOR* actor, GAME* game, int action); - -static int aHNW_set_save_permission() { - u32 player_no = Common_Get(player_no); - PersonalID_c* pid; - mHm_hs_c* house; - int res = FALSE; - - if (player_no < PLAYER_NUM) { - int arrange_idx = mHS_get_arrange_idx(player_no); - house = Save_GetPointer(homes[arrange_idx]); - pid = &Save_Get(private[player_no]).player_ID; - - if (mPr_NullCheckPersonalID(pid) != TRUE && - mPr_CheckCmpPersonalID(pid, &house->ownerID) == TRUE - ) { - res = TRUE; - house->flags.has_saved = TRUE; - } - } - - return res; -} - -static void aHNW_search_player(ACTOR* actor) { - chase_angle(&actor->shape_info.rotation.y, actor->player_angle_y, 0x0600); -} - -static void aHNW_search_front(ACTOR* actor, int house_idx) { - s16 target_angle[mHS_HOUSE_NUM] = { 8000, -8000, 8000, -8000 }; - - chase_angle(&actor->shape_info.rotation.y, target_angle[house_idx], 0x0600); -} - -static int aHNW_check_keep_item(ACTOR* actor) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - Haniwa_Item_c* haniwa_item = Save_Get(homes[haniwa->house_idx]).haniwa.items; - int i; - int res = FALSE; - - for (i = 0; i < HANIWA_ITEM_HOLD_NUM; i++) { - if (haniwa_item->item != EMPTY_NO) { - res = TRUE; - break; - } - - haniwa_item++; - } - - return res; -} - -static void aHNW_set_proceeds_str(Haniwa_c* haniwa) { - u8 str[7]; - - mFont_UnintToString(str, 7, haniwa->bells, 6, TRUE, FALSE, TRUE); - mMsg_Set_free_str(mMsg_Get_base_window_p(), 0, str, 7); -} - -static int aHNW_check_handOver_proceeds(Haniwa_c* haniwa) { - int handOver = FALSE; - u32 money = Common_Get(now_private)->inventory.wallet + haniwa->bells; - - if (money < mPr_WALLET_MAX) { - Common_Get(now_private)->inventory.wallet = money; - handOver = TRUE; - } - else { - u32 num_30k_bell_bags = (money - mPr_WALLET_MAX) / 30000 + 1; - - if (mPr_GetPossessionItemSumWithCond(Common_Get(now_private), EMPTY_NO, mPr_ITEM_COND_NORMAL) >= num_30k_bell_bags) { - handOver = TRUE; - - for (num_30k_bell_bags; num_30k_bell_bags != 0; num_30k_bell_bags--) { - mPr_SetFreePossessionItem(Common_Get(now_private), ITM_MONEY_30000, mPr_ITEM_COND_NORMAL); - money -= 30000; - } - - Common_Get(now_private)->inventory.wallet = money; - } - else { - u8 str[5]; - - mFont_UnintToString(str, 5, num_30k_bell_bags, 5, TRUE, FALSE, TRUE); - mMsg_Set_free_str(mMsg_Get_base_window_p(), 1, str, 5); - } - } - - return handOver; -} - -static int aHNW_check_house_door(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - int res = FALSE; - GAME_PLAY* play = (GAME_PLAY*)game; - - if (Common_Get(reset_flag) == TRUE) { - ACTOR* talk_actor = mDemo_Get_talk_actor(); - - if (talk_actor == NULL && chkTrigger(BUTTON_A)) { - PLAYER_ACTOR* player = get_player_actor_withoutCheck(play); - - if (mDemo_Check_DiffAngle_forTalk((actor->player_angle_y - player->actor_class.shape_info.rotation.y) - -0x8000) == TRUE) { - Common_Set(reset_type, 4); - } - } - - res = TRUE; - } - else { - mDemo_Clip_c* demo_clip = Common_Get(clip).demo_clip; - - if (demo_clip != NULL) { - INTRO_DEMO_ACTOR* demo_class = (INTRO_DEMO_ACTOR*)demo_clip->class; - if (demo_class != NULL && demo_clip->type == mDemo_CLIP_TYPE_INTRO_DEMO && - mEv_CheckFirstIntro() && demo_class->player_intro_demo_state != 0) { - res = TRUE; - } - } - } - - return res; -} - -static void aHNW_wait(ACTOR* actor, GAME* game) { - if (actor->player_distance_xz < 80.0f) { - aHNW_setupAction(actor, game, aHNW_ACTION_DANCE); - } -} - -static int aHNW_decide_msg_idx_dance(ACTOR* actor) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - Haniwa_c* house_haniwa; - int house_idx = haniwa->house_idx; - int player_is_owner = Common_Get(player_no) == mHS_get_pl_no(haniwa->house_idx); - int res; - - - if (mPr_NullCheckPersonalID(&Save_Get(homes[house_idx]).ownerID) == TRUE) { - res = aHNW_MSG_NO_OWNER; /* no one owns this house */ - } - else if (player_is_owner == TRUE) { - Haniwa_c* house_haniwa = &Save_Get(homes[house_idx]).haniwa; - int house_arrange_idx = mHS_get_arrange_idx(Common_Get(player_no)); - mHm_hs_c* house = Save_GetPointer(homes[house_arrange_idx]); - if (house->flags.has_saved == FALSE && - mEv_CheckFirstJob() == TRUE && mNpc_GetFriendAnimalNum(&Common_Get(now_private)->player_ID) == 0 - ) { - res = aHNW_MSG_NEED_FRIEND; /* player owns this house, but is in intro and has not spoken to any villagers */ - } - else if (house_haniwa->bells != 0) { - res = aHNW_MSG_PROCEEDS; - } - else { - res = aHNW_MSG_NORMAL; - } - - /* player owns house but gyroid has bells from other players */ - } - else { - res = aHNW_MSG_OTHER_OWNER; /* another player owns house */ - } - - return res; -} - - -static void aHNW_set_talk_info_dance(ACTOR* actor) { - static int msg_no[aHNW_MSG_NUM] = { - 0x0934, /* aHNW_MSG_NO_OWNER */ - 0x0935, /* aHNW_MSG_PROCEEDS */ - 0x0925, /* aHNW_MSG_NORMAL */ - 0x0928, /* aHNW_MSG_OTHER_OWNER */ - 0x092E /* aHNW_MSG_NEED_FRIEND */ - }; - - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - int house_idx = haniwa->house_idx; - Haniwa_c* house_haniwa = &Save_Get(homes[house_idx]).haniwa; - int msg_idx = aHNW_decide_msg_idx_dance(actor); - - switch (msg_idx) { - case aHNW_MSG_PROCEEDS: - { - aHNW_set_proceeds_str(house_haniwa); - break; - } - - case aHNW_MSG_OTHER_OWNER: - { - mMsg_Set_mail_str(mMsg_Get_base_window_p(), 0, house_haniwa->message, HANIWA_MESSAGE_LEN); - break; - } - } - - mDemo_Set_msg_num(msg_no[msg_idx]); -} - -static void aHNW_dance(ACTOR* actor, GAME* game) { - static int next_act_idx[aHNW_MSG_NUM] = { - aHNW_ACTION_TALK_END_WAIT, /* aHNW_MSG_NO_OWNER */ - aHNW_ACTION_CHECK_PROCEEDS, /* aHNW_MSG_PROCEEDS */ - aHNW_ACTION_TALK_WITH_MASTER, /* aHNW_MSG_NORMAL */ - aHNW_ACTION_TALK_WITH_GUEST, /* aHNW_MSG_OTHER_OWNER */ - aHNW_ACTION_TALK_END_WAIT /* aHNW_MSG_NEED_FRIEND */ - }; - - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - - if (actor->player_distance_xz > 90.0f) { - aHNW_setupAction(actor, game, aHNW_ACTION_WAIT); - } - else { - if (mDemo_Check(mDemo_TYPE_TALK, (ACTOR*)haniwa) == TRUE && mDemo_Check_ListenAble() == FALSE) { - int msg_idx = aHNW_decide_msg_idx_dance(actor); - mDemo_Set_ListenAble(); - aHNW_setupAction(actor, game, next_act_idx[msg_idx]); - } - else if (aHNW_check_house_door((ACTOR*)haniwa, game) == FALSE) { - mDemo_Request(mDemo_TYPE_TALK, (ACTOR*)haniwa, &aHNW_set_talk_info_dance); - } - } -} - -static void aHNW_check_proceeds(ACTOR* actor, GAME* game) { - static int msg_no[aHNW_HANDOVER_NUM] = { - 0x0936, /* aHNW_HANDOVER_YES */ - 0x0937 /* aHNW_HANDOVER_NO */ - }; - - static int next_act_idx[aHNW_HANDOVER_NUM] = { - aHNW_ACTION_TALK_WITH_MASTER, /* aHNW_HANDOVER_YES */ - aHNW_ACTION_TALK_END_WAIT /* aHNW_HANDOVER_NO */ - }; - - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - - if (mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9)) { - int house_idx = haniwa->house_idx; - Haniwa_c* house_haniwa = &Save_Get(homes[house_idx]).haniwa; - int handover_state; - - if (aHNW_check_handOver_proceeds(house_haniwa) == TRUE) { - house_haniwa->bells = 0; - handover_state = aHNW_HANDOVER_YES; - } - else { - handover_state = aHNW_HANDOVER_NO; - } - - mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), msg_no[handover_state]); - aHNW_setupAction(actor, game, next_act_idx[handover_state]); - mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); - } -} - -static void aHNW_talk_with_master(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); - - if (mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9) && mMsg_Check_MainNormalContinue(msg_win) == TRUE) { - int action = -1; - - switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { - case mChoice_CHOICE0: - { - action = aHNW_ACTION_SAVE_CHECK; - break; - } - - case mChoice_CHOICE1: - { - action = aHNW_ACTION_MENU_OPEN_WAIT; - haniwa->submenu_type = mSM_OVL_INVENTORY; - break; - } - - case mChoice_CHOICE2: - { - action = aHNW_ACTION_TALK_WITH_MASTER2; - break; - } - - case mChoice_CHOICE3: - { - action = aHNW_ACTION_TALK_END_WAIT; - break; - } - } - - if (action != -1) { - mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); - aHNW_setupAction(actor, game, action); - } - } -} - -static void aHNW_talk_with_master2(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); - - if (mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9) && mMsg_Check_MainNormalContinue(msg_win) == TRUE) { - int action = -1; - - switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { - case mChoice_CHOICE0: - { - action = aHNW_ACTION_ROOF_CHECK; - break; - } - - case mChoice_CHOICE1: - { - action = aHNW_ACTION_MENU_OPEN_WAIT; - haniwa->submenu_type = mSM_OVL_HBOARD; - break; - } - - case mChoice_CHOICE2: - { - action = aHNW_ACTION_TALK_WITH_MASTER; - break; - } - - case mChoice_CHOICE3: - { - action = aHNW_ACTION_TALK_END_WAIT; - break; - } - } - - if (action != -1) { - mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); - aHNW_setupAction(actor, game, action); - } - } -} - -static void aHNW_talk_end_wait(ACTOR* actor, GAME* game) { - if (mDemo_Check(mDemo_TYPE_TALK, actor) == FALSE) { - aHNW_setupAction(actor, game, aHNW_ACTION_DANCE); - } -} - -static void aHNW_menu_open_wait(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - GAME_PLAY* play = (GAME_PLAY*)game; - mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); - - if (mMsg_Check_main_wait(msg_win) == TRUE) { - int submenu_type = haniwa->submenu_type; - Submenu* submenu = &play->submenu; - int arg1 = haniwa->house_idx; - - switch (submenu_type) { - case mSM_OVL_HBOARD: - { - mSM_open_submenu(submenu, mSM_OVL_HBOARD, 0, arg1); - break; - } - - case mSM_OVL_INVENTORY: - { - mSM_open_submenu(submenu, mSM_OVL_INVENTORY, 2, arg1); - break; - } - - case mSM_OVL_NEEDLEWORK: - { - mSM_open_submenu(submenu, mSM_OVL_NEEDLEWORK, 0, arg1); - break; - } - } - - mMsg_ChangeMsgData(msg_win, 0x0927); - mMsg_Set_ForceNext(msg_win); - aHNW_setupAction(actor, game, aHNW_ACTION_MENU_END_WAIT); - } -} - -static void aHNW_menu_end_wait(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - GAME_PLAY* play = (GAME_PLAY*)game; - Submenu* submenu = &play->submenu; - Submenu_Item_c* item; - - if (submenu->flag == FALSE) { - if (mMsg_Check_not_series_main_wait(mMsg_Get_base_window_p()) == TRUE) { - aHNW_setupAction(actor, game, aHNW_ACTION_TALK_WITH_MASTER); - switch (haniwa->submenu_type) { - case mSM_OVL_NEEDLEWORK: - { - Submenu_Item_c* item = submenu->item_p; - if (item->item == RSV_NO) { - Save_Get(homes[haniwa->house_idx]).door_original = mNW_get_image_no(submenu, item->slot_no); - sAdo_SysTrgStart(0x461); - } - - break; - } - } - - haniwa->submenu_type = mSM_OVL_NONE; - } - } -} - -static void aHNW_talk_with_guest(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - - if (mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 0)) { - mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); - if (mMsg_Check_MainNormalContinue(msg_win) == TRUE) { - int action = -1; - - switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { - case mChoice_CHOICE0: - { - if (aHNW_check_keep_item(actor) == FALSE) { - mMsg_Set_continue_msg_num(msg_win, 0x092C); - action = aHNW_ACTION_TALK_END_WAIT; - } - else { - action = aHNW_ACTION_MENU_OPEN_WAIT_FOR_GUEST; - } - break; - } - - case mChoice_CHOICE1: - { - mMsg_Set_continue_msg_num(msg_win, 0x092A); - action = aHNW_ACTION_TALK_END_WAIT; - break; - } - } - - if (action != -1) { - mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0, 0); - aHNW_setupAction(actor, game, action); - } - } - } -} - -static void aHNW_menu_open_wait_for_guest(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - GAME_PLAY* play = (GAME_PLAY*)game; - mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); - - if (mMsg_Check_main_wait(msg_win) == TRUE) { - mSM_open_submenu(&play->submenu, mSM_OVL_INVENTORY, 3, haniwa->house_idx); - mMsg_ChangeMsgData(msg_win, 0x092B); - aHNW_setupAction(actor, game, aHNW_ACTION_MENU_END_WAIT_FOR_GUEST); - } -} - -static void aHNW_menu_end_wait_for_guest(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - GAME_PLAY* play = (GAME_PLAY*)game; - - if (play->submenu.flag == FALSE && mMsg_Check_not_series_main_wait(mMsg_Get_base_window_p()) == TRUE) { - aHNW_setupAction(actor, game, aHNW_ACTION_TALK_END_WAIT); - } -} - -static void aHNW_save_check(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); - int order_value = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); - int action = -1; - - if (order_value && mMsg_Check_MainNormalContinue(msg_win) == TRUE) { - switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { - case mChoice_CHOICE0: - { - action = aHNW_ACTION_SAVE_END_WAIT; - mBGMPsComp_scene_mode(13); - mDemo_Set_talk_return_demo_wait(1); - mPlib_Set_able_force_speak_label(actor); - break; - } - - case mChoice_CHOICE1: - { - action = aHNW_ACTION_TALK_WITH_MASTER; - break; - } - } - - if (action != -1) { - mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); - aHNW_setupAction(actor, game, action); - } - } -} - -static void aHNW_roof_check(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); - int order_value = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); - int action = -1; - - if (order_value && mMsg_Check_MainNormalContinue(msg_win) == TRUE) { - switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { - case mChoice_CHOICE0: - { - action = aHNW_ACTION_MENU_OPEN_WAIT; - haniwa->submenu_type = mSM_OVL_NEEDLEWORK; - break; - } - - case mChoice_CHOICE1: - { - Save_Get(homes[haniwa->house_idx]).door_original = 0xFF; - sAdo_SysTrgStart(0x461); - action = aHNW_ACTION_TALK_WITH_MASTER; - break; - } - - case mChoice_CHOICE2: - { - action = aHNW_ACTION_TALK_WITH_MASTER; - break; - } - } - - if (action != -1) { - mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); - aHNW_setupAction(actor, game, action); - } - } -} - -static void aHNW_save_end_wait(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - - if (haniwa->playing_save_bgm == FALSE && mMsg_Check_MainDisappear(mMsg_Get_base_window_p())) { - haniwa->playing_save_bgm = TRUE; - mBGMPsComp_make_ps_demo(0x41, 0x168); - } - - if (mDemo_Check(mDemo_TYPE_TALK, actor) == FALSE) { - aHNW_setupAction(actor, game, aHNW_ACTION_PL_APPROACH_DOOR); - aHNW_set_save_permission(); - } -} - - -static void aHNW_pl_approach_door(ACTOR* actor, GAME* game) { - static f32 chk_posX[mHS_HOUSE_NUM] = { 2095.0f, 2385.0f, 2095.0f, 2385.0f }; - static f32 chk_val[mHS_HOUSE_NUM] = { 1.0f, -1.0f, 1.0f, -1.0f }; - static xyz_t goal_pos[mHS_HOUSE_NUM][2] = { - { - { 2098.0f, 0.0f, 1540.0f }, - { 2110.0f, 0.0f, 1474.0f } - }, - { - { 2382.0f, 0.0f, 1540.0f }, - { 2369.0f, 0.0f, 1474.0f } - }, - { - { 2098.0f, 0.0f, 1820.0f }, - { 2110.0f, 0.0f, 1755.0f } - }, - { - { 2382.0f, 0.0f, 1820.0f }, - { 2369.0f, 0.0f, 1755.0f } - } - }; - - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - GAME_PLAY* play = (GAME_PLAY*)game; - PLAYER_ACTOR* player = get_player_actor_withoutCheck((GAME_PLAY*)game); - - haniwa->door_approach_frame++; - - if (player != NULL) { - int house_idx = haniwa->house_idx; - int stage = ((chk_posX[house_idx] - player->actor_class.world.position.x) * chk_val[house_idx]) <= 0.0f; - xyz_t* goal = goal_pos[house_idx] + stage; - - if (haniwa->player_approach_door_stage != stage && mPlib_request_main_demo_walk_type1(game, goal->x, goal->z, 3.0f, FALSE)) { - haniwa->player_approach_door_stage = stage; - } - - mPlib_Set_goal_player_demo_walk(goal->x, goal->z, 3.0f); - - if (haniwa->door_approach_frame > 160) { - MY_HOUSE_ACTOR* house_actor = (MY_HOUSE_ACTOR*)Actor_info_fgName_search(&play->actor_info, HOUSE0 + haniwa->house_idx, ACTOR_PART_ITEM); - - if (house_actor != NULL) { - house_actor->actor_class.world.angle.z = 1; - aHNW_setupAction(actor, game, aHNW_ACTION_WAIT); - } - } - else if (stage == 1 && search_position_distanceXZ(goal, &player->actor_class.world.position) < 3.0f) { - aHNW_setupAction(actor, game, aHNW_ACTION_DOOR_OPEN_WAIT); - } - } -} -#pragma pool_data reset - -static void aHNW_door_open_wait(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - GAME_PLAY* play = (GAME_PLAY*)game; - MY_HOUSE_ACTOR* house_actor = (MY_HOUSE_ACTOR*)Actor_info_fgName_search(&play->actor_info, HOUSE0 + haniwa->house_idx, ACTOR_PART_ITEM); - - if (house_actor != NULL) { - house_actor->door_rotation_speed_idx = 6; // TODO: this is probably an enum - if (house_actor != get_player_actor_withoutCheck((GAME_PLAY*)gamePT)->get_door_label_proc(gamePT)) { - aHNW_setupAction(actor, game, aHNW_ACTION_DOOR_OPEN_TIMER); - haniwa->door_approach_frame = 0; - } - else { - aHNW_setupAction(actor, game, aHNW_ACTION_WAIT); - } - } -} - -static void aHNW_door_open_timer(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - GAME_PLAY* play = (GAME_PLAY*)game; - MY_HOUSE_ACTOR* house_actor = (MY_HOUSE_ACTOR*)Actor_info_fgName_search(&play->actor_info, HOUSE0 + haniwa->house_idx, ACTOR_PART_ITEM); - - if (house_actor != NULL) { - if (house_actor == get_player_actor_withoutCheck((GAME_PLAY*)gamePT)->get_door_label_proc(gamePT)) { - aHNW_setupAction(actor, game, aHNW_ACTION_WAIT); - } - else { - haniwa->door_approach_frame++; - if (haniwa->door_approach_frame > 80) { - house_actor->actor_class.world.angle.z = 1; - aHNW_setupAction(actor, game, aHNW_ACTION_WAIT); - } - } - } -} - -static void aHNW_menu_open_wait_init(ACTOR* actor, GAME* game) { - mMsg_request_main_disappear_wait_type1(mMsg_Get_base_window_p()); -} - -static void aHNW_menu_end_wait_init(ACTOR* actor, GAME* game) { - mMsg_request_main_appear_wait_type1(mMsg_Get_base_window_p()); -} - -static void aHNW_talk_with_guest_init(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - - mMsg_Set_free_str(mMsg_Get_base_window_p(), 2, Save_Get(homes[haniwa->house_idx]).ownerID.player_name, PLAYER_NAME_LEN); -} - -static void aHNW_pl_approach_door_init(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - - game->pad_initialized = FALSE; - haniwa->player_approach_door_stage = -1; - haniwa->door_approach_frame = 0; -} - -typedef void (*HANIWA_PROC)(ACTOR*, GAME*); - -static void aHNW_init_proc(ACTOR* actor, GAME* game, int action) { - static HANIWA_PROC init_proc[aHNW_ACTION_NUM] = { - (HANIWA_PROC)&none_proc1, - (HANIWA_PROC)&none_proc1, - (HANIWA_PROC)&none_proc1, - (HANIWA_PROC)&none_proc1, - (HANIWA_PROC)&none_proc1, - (HANIWA_PROC)&none_proc1, - &aHNW_menu_open_wait_init, - &aHNW_menu_end_wait_init, - &aHNW_talk_with_guest_init, - &aHNW_menu_open_wait_init, - &aHNW_menu_end_wait_init, - (HANIWA_PROC)&none_proc1, - (HANIWA_PROC)&none_proc1, - (HANIWA_PROC)&none_proc1, - &aHNW_pl_approach_door_init, - (HANIWA_PROC)&none_proc1, - (HANIWA_PROC)&none_proc1 - }; - - (*init_proc[action])(actor, game); -} - -static void aHNW_setupAction(ACTOR* actor, GAME* game, int action) { - static HANIWA_PROC process[aHNW_ACTION_NUM] = { - &aHNW_wait, - &aHNW_dance, - &aHNW_check_proceeds, - &aHNW_talk_with_master, - &aHNW_talk_with_master2, - &aHNW_talk_end_wait, - &aHNW_menu_open_wait, - &aHNW_menu_end_wait, - &aHNW_talk_with_guest, - &aHNW_menu_open_wait_for_guest, - &aHNW_menu_end_wait_for_guest, - &aHNW_roof_check, - &aHNW_save_check, - &aHNW_save_end_wait, - &aHNW_pl_approach_door, - &aHNW_door_open_wait, - &aHNW_door_open_timer - }; - - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - - int house_idx = haniwa->house_idx; - int animation_state = haniwa->animation_state; - int no_owner = mPr_NullCheckPersonalID(&Save_Get(homes[house_idx]).ownerID); - int owner_is_player = mHS_get_pl_no(house_idx) == Common_Get(player_no); - - haniwa->action = action; - haniwa->action_proc = process[action]; - - if (action >= aHNW_ACTION_CHECK_PROCEEDS) { - haniwa->anim_frame_speed = 0.3f; - } - else { - if (no_owner) { - if (haniwa->anim_frame_speed != 0.0f) { - haniwa->anim_frame_speed = 0.075f; - } - } - else { - if (owner_is_player) { - if (action == aHNW_ACTION_WAIT || action == aHNW_ACTION_DOOR_OPEN_TIMER) { - haniwa->anim_frame_speed = 0.3f; - } - else { - haniwa->anim_frame_speed = 0.45f; - } - } - else { - haniwa->anim_frame_speed = 0.1f; - } - } - } - - if (animation_state == 2) { - cKF_SkeletonInfo_R_init( - &haniwa->keyframe, haniwa->keyframe.skeleton, &cKF_ba_r_hnw_move, - 1.0f, 9.0f, 1.0f, haniwa->anim_frame_speed, 0.0f, - cKF_FRAMECONTROL_REPEAT, - NULL - ); - haniwa->saved_current_frame = haniwa->keyframe.frame_control.current_frame; - } - - haniwa->animation_state = 0; - aHNW_init_proc(actor, game, action); - if (no_owner && action < aHNW_ACTION_CHECK_PROCEEDS) { - haniwa->keyframe.frame_control.mode = cKF_FRAMECONTROL_STOP; - } - else { - haniwa->keyframe.frame_control.mode = cKF_FRAMECONTROL_REPEAT; - } -} - -static void aHNW_common_process(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - cKF_SkeletonInfo_R_c* keyframe = &haniwa->keyframe; - int house_idx = haniwa->house_idx; - int no_owner = mPr_NullCheckPersonalID(&Save_Get(homes[house_idx]).ownerID); - f32 target; - - if (no_owner == FALSE && keyframe->frame_control.mode == cKF_FRAMECONTROL_STOP) { - aHNW_setupAction((ACTOR*)haniwa, game, haniwa->action); - keyframe->frame_control.mode = cKF_FRAMECONTROL_REPEAT; - } - else if (no_owner && haniwa->action < 2 && keyframe->frame_control.speed <= 0.1f) { - keyframe->frame_control.mode = cKF_FRAMECONTROL_STOP; - } - else { - keyframe->frame_control.mode = cKF_FRAMECONTROL_REPEAT; - } - - if (no_owner == FALSE || haniwa->action >= aHNW_ACTION_CHECK_PROCEEDS) { - aHNW_search_player((ACTOR*)haniwa); - } - else { - aHNW_search_front((ACTOR*)haniwa, house_idx); - } - - target = haniwa->anim_frame_speed; - - { - if (target > keyframe->frame_control.speed) { - chase_f(&keyframe->frame_control.speed, target, 0.05f); - } - else { - chase_f(&keyframe->frame_control.speed, target, 0.015f); - } - } -} - -static void aHNW_actor_move(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - GAME_PLAY* play = (GAME_PLAY*)game; - cKF_SkeletonInfo_R_c* keyframe = &haniwa->keyframe; - - haniwa->keyframe_state = cKF_SkeletonInfo_R_play(keyframe); - (*haniwa->action_proc)((ACTOR*)haniwa, game); - aHNW_common_process(actor, game); - CollisionCheck_Uty_ActorWorldPosSetPipeC(actor, &haniwa->col_pipe); - CollisionCheck_setOC(play, &play->collision_check, &haniwa->col_pipe.collision_obj); - Actor_world_to_eye(actor, 50.0f); -} - -static void aHNW_actor_init(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - int house_idx = haniwa->house_idx; - - mFI_SetFG_common((mActor_name_t)(house_idx + DUMMY_HANIWA0), actor->world.position, FALSE); - actor->mv_proc = &aHNW_actor_move; - actor->dw_proc = &aHNW_actor_draw; - aHNW_setupAction((ACTOR*)haniwa, game, aHNW_ACTION_WAIT); // weird that we have to re-cast to ACTOR so fequently for matches - haniwa->keyframe.morph_counter = 0.0f; - aHNW_actor_move(actor, game); -} - -/* TODO: hack */ -static Gfx hnw_tex_model[] = { - gsDPLoadTLUT_Dolphin(15, 16, 1, hnw_face), - gsSPEndDisplayList(), -}; diff --git a/rel/ac_haniwa_move.c_inc b/rel/ac_haniwa_move.c_inc new file mode 100644 index 00000000..0ff90e13 --- /dev/null +++ b/rel/ac_haniwa_move.c_inc @@ -0,0 +1,821 @@ +static void aHNW_setupAction(ACTOR* actor, GAME* game, int action); + +static int aHNW_set_save_permission() { + u32 player_no = Common_Get(player_no); + PersonalID_c* pid; + mHm_hs_c* house; + int res = FALSE; + + if (player_no < PLAYER_NUM) { + int arrange_idx = mHS_get_arrange_idx(player_no); + house = Save_GetPointer(homes[arrange_idx]); + pid = &Save_Get(private[player_no]).player_ID; + + if (mPr_NullCheckPersonalID(pid) != TRUE && + mPr_CheckCmpPersonalID(pid, &house->ownerID) == TRUE + ) { + res = TRUE; + house->flags.has_saved = TRUE; + } + } + + return res; +} + +static void aHNW_search_player(ACTOR* actor) { + chase_angle(&actor->shape_info.rotation.y, actor->player_angle_y, 0x0600); +} + +static void aHNW_search_front(ACTOR* actor, int house_idx) { + s16 target_angle[mHS_HOUSE_NUM] = { 8000, -8000, 8000, -8000 }; + + chase_angle(&actor->shape_info.rotation.y, target_angle[house_idx], 0x0600); +} + +static int aHNW_check_keep_item(ACTOR* actor) { + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + Haniwa_Item_c* haniwa_item = Save_Get(homes[haniwa->house_idx]).haniwa.items; + int i; + int res = FALSE; + + for (i = 0; i < HANIWA_ITEM_HOLD_NUM; i++) { + if (haniwa_item->item != EMPTY_NO) { + res = TRUE; + break; + } + + haniwa_item++; + } + + return res; +} + +static void aHNW_set_proceeds_str(Haniwa_c* haniwa) { + u8 str[7]; + + mFont_UnintToString(str, 7, haniwa->bells, 6, TRUE, FALSE, TRUE); + mMsg_Set_free_str(mMsg_Get_base_window_p(), 0, str, 7); +} + +static int aHNW_check_handOver_proceeds(Haniwa_c* haniwa) { + int handOver = FALSE; + u32 money = Common_Get(now_private)->inventory.wallet + haniwa->bells; + + if (money < mPr_WALLET_MAX) { + Common_Get(now_private)->inventory.wallet = money; + handOver = TRUE; + } + else { + u32 num_30k_bell_bags = (money - mPr_WALLET_MAX) / 30000 + 1; + + if (mPr_GetPossessionItemSumWithCond(Common_Get(now_private), EMPTY_NO, mPr_ITEM_COND_NORMAL) >= num_30k_bell_bags) { + handOver = TRUE; + + for (num_30k_bell_bags; num_30k_bell_bags != 0; num_30k_bell_bags--) { + mPr_SetFreePossessionItem(Common_Get(now_private), ITM_MONEY_30000, mPr_ITEM_COND_NORMAL); + money -= 30000; + } + + Common_Get(now_private)->inventory.wallet = money; + } + else { + u8 str[5]; + + mFont_UnintToString(str, 5, num_30k_bell_bags, 5, TRUE, FALSE, TRUE); + mMsg_Set_free_str(mMsg_Get_base_window_p(), 1, str, 5); + } + } + + return handOver; +} + +static int aHNW_check_house_door(ACTOR* actor, GAME* game) { + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + int res = FALSE; + GAME_PLAY* play = (GAME_PLAY*)game; + + if (Common_Get(reset_flag) == TRUE) { + ACTOR* talk_actor = mDemo_Get_talk_actor(); + + if (talk_actor == NULL && chkTrigger(BUTTON_A)) { + PLAYER_ACTOR* player = get_player_actor_withoutCheck(play); + + if (mDemo_Check_DiffAngle_forTalk((actor->player_angle_y - player->actor_class.shape_info.rotation.y) - -0x8000) == TRUE) { + Common_Set(reset_type, 4); + } + } + + res = TRUE; + } + else { + mDemo_Clip_c* demo_clip = Common_Get(clip).demo_clip; + + if (demo_clip != NULL) { + INTRO_DEMO_ACTOR* demo_class = (INTRO_DEMO_ACTOR*)demo_clip->class; + if (demo_class != NULL && demo_clip->type == mDemo_CLIP_TYPE_INTRO_DEMO && + mEv_CheckFirstIntro() && demo_class->player_intro_demo_state != 0) { + res = TRUE; + } + } + } + + return res; +} + +static void aHNW_wait(ACTOR* actor, GAME* game) { + if (actor->player_distance_xz < 80.0f) { + aHNW_setupAction(actor, game, aHNW_ACTION_DANCE); + } +} + +static int aHNW_decide_msg_idx_dance(ACTOR* actor) { + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + Haniwa_c* house_haniwa; + int house_idx = haniwa->house_idx; + int player_is_owner = Common_Get(player_no) == mHS_get_pl_no(haniwa->house_idx); + int res; + + + if (mPr_NullCheckPersonalID(&Save_Get(homes[house_idx]).ownerID) == TRUE) { + res = aHNW_MSG_NO_OWNER; /* no one owns this house */ + } + else if (player_is_owner == TRUE) { + Haniwa_c* house_haniwa = &Save_Get(homes[house_idx]).haniwa; + int house_arrange_idx = mHS_get_arrange_idx(Common_Get(player_no)); + mHm_hs_c* house = Save_GetPointer(homes[house_arrange_idx]); + if (house->flags.has_saved == FALSE && + mEv_CheckFirstJob() == TRUE && mNpc_GetFriendAnimalNum(&Common_Get(now_private)->player_ID) == 0 + ) { + res = aHNW_MSG_NEED_FRIEND; /* player owns this house, but is in intro and has not spoken to any villagers */ + } + else if (house_haniwa->bells != 0) { + res = aHNW_MSG_PROCEEDS; + } + else { + res = aHNW_MSG_NORMAL; + } + + /* player owns house but gyroid has bells from other players */ + } + else { + res = aHNW_MSG_OTHER_OWNER; /* another player owns house */ + } + + return res; +} + + +static void aHNW_set_talk_info_dance(ACTOR* actor) { + static int msg_no[aHNW_MSG_NUM] = { + 0x0934, /* aHNW_MSG_NO_OWNER */ + 0x0935, /* aHNW_MSG_PROCEEDS */ + 0x0925, /* aHNW_MSG_NORMAL */ + 0x0928, /* aHNW_MSG_OTHER_OWNER */ + 0x092E /* aHNW_MSG_NEED_FRIEND */ + }; + + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + int house_idx = haniwa->house_idx; + Haniwa_c* house_haniwa = &Save_Get(homes[house_idx]).haniwa; + int msg_idx = aHNW_decide_msg_idx_dance(actor); + + switch (msg_idx) { + case aHNW_MSG_PROCEEDS: + { + aHNW_set_proceeds_str(house_haniwa); + break; + } + + case aHNW_MSG_OTHER_OWNER: + { + mMsg_Set_mail_str(mMsg_Get_base_window_p(), 0, house_haniwa->message, HANIWA_MESSAGE_LEN); + break; + } + } + + mDemo_Set_msg_num(msg_no[msg_idx]); +} + +static void aHNW_dance(ACTOR* actor, GAME* game) { + static int next_act_idx[aHNW_MSG_NUM] = { + aHNW_ACTION_TALK_END_WAIT, /* aHNW_MSG_NO_OWNER */ + aHNW_ACTION_CHECK_PROCEEDS, /* aHNW_MSG_PROCEEDS */ + aHNW_ACTION_TALK_WITH_MASTER, /* aHNW_MSG_NORMAL */ + aHNW_ACTION_TALK_WITH_GUEST, /* aHNW_MSG_OTHER_OWNER */ + aHNW_ACTION_TALK_END_WAIT /* aHNW_MSG_NEED_FRIEND */ + }; + + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + + if (actor->player_distance_xz > 90.0f) { + aHNW_setupAction(actor, game, aHNW_ACTION_WAIT); + } + else { + if (mDemo_Check(mDemo_TYPE_TALK, (ACTOR*)haniwa) == TRUE && mDemo_Check_ListenAble() == FALSE) { + int msg_idx = aHNW_decide_msg_idx_dance(actor); + mDemo_Set_ListenAble(); + aHNW_setupAction(actor, game, next_act_idx[msg_idx]); + } + else if (aHNW_check_house_door((ACTOR*)haniwa, game) == FALSE) { + mDemo_Request(mDemo_TYPE_TALK, (ACTOR*)haniwa, &aHNW_set_talk_info_dance); + } + } +} + +static void aHNW_check_proceeds(ACTOR* actor, GAME* game) { + static int msg_no[aHNW_HANDOVER_NUM] = { + 0x0936, /* aHNW_HANDOVER_YES */ + 0x0937 /* aHNW_HANDOVER_NO */ + }; + + static int next_act_idx[aHNW_HANDOVER_NUM] = { + aHNW_ACTION_TALK_WITH_MASTER, /* aHNW_HANDOVER_YES */ + aHNW_ACTION_TALK_END_WAIT /* aHNW_HANDOVER_NO */ + }; + + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + + if (mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9)) { + int house_idx = haniwa->house_idx; + Haniwa_c* house_haniwa = &Save_Get(homes[house_idx]).haniwa; + int handover_state; + + if (aHNW_check_handOver_proceeds(house_haniwa) == TRUE) { + house_haniwa->bells = 0; + handover_state = aHNW_HANDOVER_YES; + } + else { + handover_state = aHNW_HANDOVER_NO; + } + + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), msg_no[handover_state]); + aHNW_setupAction(actor, game, next_act_idx[handover_state]); + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + } +} + +static void aHNW_talk_with_master(ACTOR* actor, GAME* game) { + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); + + if (mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9) && mMsg_Check_MainNormalContinue(msg_win) == TRUE) { + int action = -1; + + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: + { + action = aHNW_ACTION_SAVE_CHECK; + break; + } + + case mChoice_CHOICE1: + { + action = aHNW_ACTION_MENU_OPEN_WAIT; + haniwa->submenu_type = mSM_OVL_INVENTORY; + break; + } + + case mChoice_CHOICE2: + { + action = aHNW_ACTION_TALK_WITH_MASTER2; + break; + } + + case mChoice_CHOICE3: + { + action = aHNW_ACTION_TALK_END_WAIT; + break; + } + } + + if (action != -1) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + aHNW_setupAction(actor, game, action); + } + } +} + +static void aHNW_talk_with_master2(ACTOR* actor, GAME* game) { + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); + + if (mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9) && mMsg_Check_MainNormalContinue(msg_win) == TRUE) { + int action = -1; + + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: + { + action = aHNW_ACTION_ROOF_CHECK; + break; + } + + case mChoice_CHOICE1: + { + action = aHNW_ACTION_MENU_OPEN_WAIT; + haniwa->submenu_type = mSM_OVL_HBOARD; + break; + } + + case mChoice_CHOICE2: + { + action = aHNW_ACTION_TALK_WITH_MASTER; + break; + } + + case mChoice_CHOICE3: + { + action = aHNW_ACTION_TALK_END_WAIT; + break; + } + } + + if (action != -1) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + aHNW_setupAction(actor, game, action); + } + } +} + +static void aHNW_talk_end_wait(ACTOR* actor, GAME* game) { + if (mDemo_Check(mDemo_TYPE_TALK, actor) == FALSE) { + aHNW_setupAction(actor, game, aHNW_ACTION_DANCE); + } +} + +static void aHNW_menu_open_wait(ACTOR* actor, GAME* game) { + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY*)game; + mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); + + if (mMsg_Check_main_wait(msg_win) == TRUE) { + int submenu_type = haniwa->submenu_type; + Submenu* submenu = &play->submenu; + int arg1 = haniwa->house_idx; + + switch (submenu_type) { + case mSM_OVL_HBOARD: + { + mSM_open_submenu(submenu, mSM_OVL_HBOARD, 0, arg1); + break; + } + + case mSM_OVL_INVENTORY: + { + mSM_open_submenu(submenu, mSM_OVL_INVENTORY, 2, arg1); + break; + } + + case mSM_OVL_NEEDLEWORK: + { + mSM_open_submenu(submenu, mSM_OVL_NEEDLEWORK, 0, arg1); + break; + } + } + + mMsg_ChangeMsgData(msg_win, 0x0927); + mMsg_Set_ForceNext(msg_win); + aHNW_setupAction(actor, game, aHNW_ACTION_MENU_END_WAIT); + } +} + +static void aHNW_menu_end_wait(ACTOR* actor, GAME* game) { + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY*)game; + Submenu* submenu = &play->submenu; + Submenu_Item_c* item; + + if (submenu->flag == FALSE) { + if (mMsg_Check_not_series_main_wait(mMsg_Get_base_window_p()) == TRUE) { + aHNW_setupAction(actor, game, aHNW_ACTION_TALK_WITH_MASTER); + switch (haniwa->submenu_type) { + case mSM_OVL_NEEDLEWORK: + { + Submenu_Item_c* item = submenu->item_p; + if (item->item == RSV_NO) { + Save_Get(homes[haniwa->house_idx]).door_original = mNW_get_image_no(submenu, item->slot_no); + sAdo_SysTrgStart(0x461); + } + + break; + } + } + + haniwa->submenu_type = mSM_OVL_NONE; + } + } +} + +static void aHNW_talk_with_guest(ACTOR* actor, GAME* game) { + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + + if (mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 0)) { + mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); + if (mMsg_Check_MainNormalContinue(msg_win) == TRUE) { + int action = -1; + + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: + { + if (aHNW_check_keep_item(actor) == FALSE) { + mMsg_Set_continue_msg_num(msg_win, 0x092C); + action = aHNW_ACTION_TALK_END_WAIT; + } + else { + action = aHNW_ACTION_MENU_OPEN_WAIT_FOR_GUEST; + } + break; + } + + case mChoice_CHOICE1: + { + mMsg_Set_continue_msg_num(msg_win, 0x092A); + action = aHNW_ACTION_TALK_END_WAIT; + break; + } + } + + if (action != -1) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0, 0); + aHNW_setupAction(actor, game, action); + } + } + } +} + +static void aHNW_menu_open_wait_for_guest(ACTOR* actor, GAME* game) { + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY*)game; + mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); + + if (mMsg_Check_main_wait(msg_win) == TRUE) { + mSM_open_submenu(&play->submenu, mSM_OVL_INVENTORY, 3, haniwa->house_idx); + mMsg_ChangeMsgData(msg_win, 0x092B); + aHNW_setupAction(actor, game, aHNW_ACTION_MENU_END_WAIT_FOR_GUEST); + } +} + +static void aHNW_menu_end_wait_for_guest(ACTOR* actor, GAME* game) { + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY*)game; + + if (play->submenu.flag == FALSE && mMsg_Check_not_series_main_wait(mMsg_Get_base_window_p()) == TRUE) { + aHNW_setupAction(actor, game, aHNW_ACTION_TALK_END_WAIT); + } +} + +static void aHNW_save_check(ACTOR* actor, GAME* game) { + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); + int order_value = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); + int action = -1; + + if (order_value && mMsg_Check_MainNormalContinue(msg_win) == TRUE) { + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: + { + action = aHNW_ACTION_SAVE_END_WAIT; + mBGMPsComp_scene_mode(13); + mDemo_Set_talk_return_demo_wait(1); + mPlib_Set_able_force_speak_label(actor); + break; + } + + case mChoice_CHOICE1: + { + action = aHNW_ACTION_TALK_WITH_MASTER; + break; + } + } + + if (action != -1) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + aHNW_setupAction(actor, game, action); + } + } +} + +static void aHNW_roof_check(ACTOR* actor, GAME* game) { + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); + int order_value = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); + int action = -1; + + if (order_value && mMsg_Check_MainNormalContinue(msg_win) == TRUE) { + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: + { + action = aHNW_ACTION_MENU_OPEN_WAIT; + haniwa->submenu_type = mSM_OVL_NEEDLEWORK; + break; + } + + case mChoice_CHOICE1: + { + Save_Get(homes[haniwa->house_idx]).door_original = 0xFF; + sAdo_SysTrgStart(0x461); + action = aHNW_ACTION_TALK_WITH_MASTER; + break; + } + + case mChoice_CHOICE2: + { + action = aHNW_ACTION_TALK_WITH_MASTER; + break; + } + } + + if (action != -1) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + aHNW_setupAction(actor, game, action); + } + } +} + +static void aHNW_save_end_wait(ACTOR* actor, GAME* game) { + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + + if (haniwa->playing_save_bgm == FALSE && mMsg_Check_MainDisappear(mMsg_Get_base_window_p())) { + haniwa->playing_save_bgm = TRUE; + mBGMPsComp_make_ps_demo(0x41, 0x168); + } + + if (mDemo_Check(mDemo_TYPE_TALK, actor) == FALSE) { + aHNW_setupAction(actor, game, aHNW_ACTION_PL_APPROACH_DOOR); + aHNW_set_save_permission(); + } +} + + +static void aHNW_pl_approach_door(ACTOR* actor, GAME* game) { + static f32 chk_posX[mHS_HOUSE_NUM] = { 2095.0f, 2385.0f, 2095.0f, 2385.0f }; + static f32 chk_val[mHS_HOUSE_NUM] = { 1.0f, -1.0f, 1.0f, -1.0f }; + static xyz_t goal_pos[mHS_HOUSE_NUM][2] = { + { + { 2098.0f, 0.0f, 1540.0f }, + { 2110.0f, 0.0f, 1474.0f } + }, + { + { 2382.0f, 0.0f, 1540.0f }, + { 2369.0f, 0.0f, 1474.0f } + }, + { + { 2098.0f, 0.0f, 1820.0f }, + { 2110.0f, 0.0f, 1755.0f } + }, + { + { 2382.0f, 0.0f, 1820.0f }, + { 2369.0f, 0.0f, 1755.0f } + } + }; + + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY*)game; + PLAYER_ACTOR* player = get_player_actor_withoutCheck((GAME_PLAY*)game); + + haniwa->door_approach_frame++; + + if (player != NULL) { + int house_idx = haniwa->house_idx; + int stage = ((chk_posX[house_idx] - player->actor_class.world.position.x) * chk_val[house_idx]) <= 0.0f; + xyz_t* goal = goal_pos[house_idx] + stage; + + if (haniwa->player_approach_door_stage != stage && mPlib_request_main_demo_walk_type1(game, goal->x, goal->z, 3.0f, FALSE)) { + haniwa->player_approach_door_stage = stage; + } + + mPlib_Set_goal_player_demo_walk(goal->x, goal->z, 3.0f); + + if (haniwa->door_approach_frame > 160) { + MY_HOUSE_ACTOR* house_actor = (MY_HOUSE_ACTOR*)Actor_info_fgName_search(&play->actor_info, HOUSE0 + haniwa->house_idx, ACTOR_PART_ITEM); + + if (house_actor != NULL) { + house_actor->actor_class.world.angle.z = 1; + aHNW_setupAction(actor, game, aHNW_ACTION_WAIT); + } + } + else if (stage == 1 && search_position_distanceXZ(goal, &player->actor_class.world.position) < 3.0f) { + aHNW_setupAction(actor, game, aHNW_ACTION_DOOR_OPEN_WAIT); + } + } +} + +static void aHNW_door_open_wait(ACTOR* actor, GAME* game) { + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY*)game; + MY_HOUSE_ACTOR* house_actor = (MY_HOUSE_ACTOR*)Actor_info_fgName_search(&play->actor_info, HOUSE0 + haniwa->house_idx, ACTOR_PART_ITEM); + + if (house_actor != NULL) { + house_actor->door_rotation_speed_idx = 6; // TODO: this is probably an enum + if (house_actor != get_player_actor_withoutCheck((GAME_PLAY*)gamePT)->get_door_label_proc(gamePT)) { + aHNW_setupAction(actor, game, aHNW_ACTION_DOOR_OPEN_TIMER); + haniwa->door_approach_frame = 0; + } + else { + aHNW_setupAction(actor, game, aHNW_ACTION_WAIT); + } + } +} + +static void aHNW_door_open_timer(ACTOR* actor, GAME* game) { + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY*)game; + MY_HOUSE_ACTOR* house_actor = (MY_HOUSE_ACTOR*)Actor_info_fgName_search(&play->actor_info, HOUSE0 + haniwa->house_idx, ACTOR_PART_ITEM); + + if (house_actor != NULL) { + if (house_actor == get_player_actor_withoutCheck((GAME_PLAY*)gamePT)->get_door_label_proc(gamePT)) { + aHNW_setupAction(actor, game, aHNW_ACTION_WAIT); + } + else { + haniwa->door_approach_frame++; + if (haniwa->door_approach_frame > 80) { + house_actor->actor_class.world.angle.z = 1; + aHNW_setupAction(actor, game, aHNW_ACTION_WAIT); + } + } + } +} + +static void aHNW_menu_open_wait_init(ACTOR* actor, GAME* game) { + mMsg_request_main_disappear_wait_type1(mMsg_Get_base_window_p()); +} + +static void aHNW_menu_end_wait_init(ACTOR* actor, GAME* game) { + mMsg_request_main_appear_wait_type1(mMsg_Get_base_window_p()); +} + +static void aHNW_talk_with_guest_init(ACTOR* actor, GAME* game) { + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + + mMsg_Set_free_str(mMsg_Get_base_window_p(), 2, Save_Get(homes[haniwa->house_idx]).ownerID.player_name, PLAYER_NAME_LEN); +} + +static void aHNW_pl_approach_door_init(ACTOR* actor, GAME* game) { + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + + game->pad_initialized = FALSE; + haniwa->player_approach_door_stage = -1; + haniwa->door_approach_frame = 0; +} + +typedef void (*HANIWA_PROC)(ACTOR*, GAME*); + +static void aHNW_init_proc(ACTOR* actor, GAME* game, int action) { + static HANIWA_PROC init_proc[aHNW_ACTION_NUM] = { + (HANIWA_PROC)&none_proc1, + (HANIWA_PROC)&none_proc1, + (HANIWA_PROC)&none_proc1, + (HANIWA_PROC)&none_proc1, + (HANIWA_PROC)&none_proc1, + (HANIWA_PROC)&none_proc1, + &aHNW_menu_open_wait_init, + &aHNW_menu_end_wait_init, + &aHNW_talk_with_guest_init, + &aHNW_menu_open_wait_init, + &aHNW_menu_end_wait_init, + (HANIWA_PROC)&none_proc1, + (HANIWA_PROC)&none_proc1, + (HANIWA_PROC)&none_proc1, + &aHNW_pl_approach_door_init, + (HANIWA_PROC)&none_proc1, + (HANIWA_PROC)&none_proc1 + }; + + (*init_proc[action])(actor, game); +} + +static void aHNW_setupAction(ACTOR* actor, GAME* game, int action) { + static HANIWA_PROC process[aHNW_ACTION_NUM] = { + &aHNW_wait, + &aHNW_dance, + &aHNW_check_proceeds, + &aHNW_talk_with_master, + &aHNW_talk_with_master2, + &aHNW_talk_end_wait, + &aHNW_menu_open_wait, + &aHNW_menu_end_wait, + &aHNW_talk_with_guest, + &aHNW_menu_open_wait_for_guest, + &aHNW_menu_end_wait_for_guest, + &aHNW_roof_check, + &aHNW_save_check, + &aHNW_save_end_wait, + &aHNW_pl_approach_door, + &aHNW_door_open_wait, + &aHNW_door_open_timer + }; + + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + + int house_idx = haniwa->house_idx; + int animation_state = haniwa->animation_state; + int no_owner = mPr_NullCheckPersonalID(&Save_Get(homes[house_idx]).ownerID); + int owner_is_player = mHS_get_pl_no(house_idx) == Common_Get(player_no); + + haniwa->action = action; + haniwa->action_proc = process[action]; + + if (action >= aHNW_ACTION_CHECK_PROCEEDS) { + haniwa->anim_frame_speed = 0.3f; + } + else { + if (no_owner) { + if (haniwa->anim_frame_speed != 0.0f) { + haniwa->anim_frame_speed = 0.075f; + } + } + else { + if (owner_is_player) { + if (action == aHNW_ACTION_WAIT || action == aHNW_ACTION_DOOR_OPEN_TIMER) { + haniwa->anim_frame_speed = 0.3f; + } + else { + haniwa->anim_frame_speed = 0.45f; + } + } + else { + haniwa->anim_frame_speed = 0.1f; + } + } + } + + if (animation_state == 2) { + cKF_SkeletonInfo_R_init( + &haniwa->keyframe, haniwa->keyframe.skeleton, &cKF_ba_r_hnw_move, + 1.0f, 9.0f, 1.0f, haniwa->anim_frame_speed, 0.0f, + cKF_FRAMECONTROL_REPEAT, + NULL + ); + haniwa->saved_current_frame = haniwa->keyframe.frame_control.current_frame; + } + + haniwa->animation_state = 0; + aHNW_init_proc(actor, game, action); + if (no_owner && action < aHNW_ACTION_CHECK_PROCEEDS) { + haniwa->keyframe.frame_control.mode = cKF_FRAMECONTROL_STOP; + } + else { + haniwa->keyframe.frame_control.mode = cKF_FRAMECONTROL_REPEAT; + } +} + +static void aHNW_common_process(ACTOR* actor, GAME* game) { + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + cKF_SkeletonInfo_R_c* keyframe = &haniwa->keyframe; + int house_idx = haniwa->house_idx; + int no_owner = mPr_NullCheckPersonalID(&Save_Get(homes[house_idx]).ownerID); + f32 target; + + if (no_owner == FALSE && keyframe->frame_control.mode == cKF_FRAMECONTROL_STOP) { + aHNW_setupAction((ACTOR*)haniwa, game, haniwa->action); + keyframe->frame_control.mode = cKF_FRAMECONTROL_REPEAT; + } + else if (no_owner && haniwa->action < 2 && keyframe->frame_control.speed <= 0.1f) { + keyframe->frame_control.mode = cKF_FRAMECONTROL_STOP; + } + else { + keyframe->frame_control.mode = cKF_FRAMECONTROL_REPEAT; + } + + if (no_owner == FALSE || haniwa->action >= aHNW_ACTION_CHECK_PROCEEDS) { + aHNW_search_player((ACTOR*)haniwa); + } + else { + aHNW_search_front((ACTOR*)haniwa, house_idx); + } + + target = haniwa->anim_frame_speed; + + { + if (target > keyframe->frame_control.speed) { + chase_f(&keyframe->frame_control.speed, target, 0.05f); + } + else { + chase_f(&keyframe->frame_control.speed, target, 0.015f); + } + } +} + +static void aHNW_actor_move(ACTOR* actor, GAME* game) { + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY*)game; + cKF_SkeletonInfo_R_c* keyframe = &haniwa->keyframe; + + haniwa->keyframe_state = cKF_SkeletonInfo_R_play(keyframe); + (*haniwa->action_proc)((ACTOR*)haniwa, game); + aHNW_common_process(actor, game); + CollisionCheck_Uty_ActorWorldPosSetPipeC(actor, &haniwa->col_pipe); + CollisionCheck_setOC(play, &play->collision_check, &haniwa->col_pipe.collision_obj); + Actor_world_to_eye(actor, 50.0f); +} + +static void aHNW_actor_init(ACTOR* actor, GAME* game) { + HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + int house_idx = haniwa->house_idx; + + mFI_SetFG_common((mActor_name_t)(house_idx + DUMMY_HANIWA0), actor->world.position, FALSE); + actor->mv_proc = &aHNW_actor_move; + actor->dw_proc = &aHNW_actor_draw; + aHNW_setupAction((ACTOR*)haniwa, game, aHNW_ACTION_WAIT); // weird that we have to re-cast to ACTOR so fequently for matches + haniwa->keyframe.morph_counter = 0.0f; + aHNW_actor_move(actor, game); +} diff --git a/rel/ac_radio.c b/rel/ac_radio.c index 80e10ef0..c4a5201c 100644 --- a/rel/ac_radio.c +++ b/rel/ac_radio.c @@ -25,7 +25,7 @@ ACTOR_PROFILE Radio_Profile = { aRAD_actor_init, aRAD_actor_draw, NULL, - }; +}; extern Vtx obj_e_radio_shadow_v[]; extern Gfx obj_e_radio_shadowT_model[]; @@ -39,7 +39,6 @@ bIT_ShadowData_c aRAD_shadow_data = { obj_e_radio_shadowT_model, }; - extern Gfx radio_DL_model[]; static void aRAD_setup_action(RADIO_ACTOR*, int); @@ -53,92 +52,6 @@ static void aRAD_actor_ct(ACTOR* actor, GAME* game){ aRAD_set_bgOffset(radio, 1); } -static void aRAD_set_bgOffset(RADIO_ACTOR* radio, int offs){ - offs = offs == 0 ? 3 : 3; +#include "../rel/ac_radio_move.c_inc" - mCoBG_SetPlussOffset(radio->actor_class.home.position, offs, 100); -} - -static void aRAD_wait(RADIO_ACTOR* radio, GAME_PLAY* play){ - xyz_t def = {2.0f, 0.0f, -10.0f}; - xyz_t newPos; - - if(radio->next_action >= 0x24){ - radio->next_action = 0; - Matrix_push(); - Matrix_translate(radio->actor_class.world.position.x,radio->actor_class.world.position.y, radio->actor_class.world.position.z, 0); - Matrix_Position(&def, &newPos); - Matrix_pull(); - - Common_Get(clip.effect_clip->effect_make_proc)(32, newPos, 1, 0x6000, &play->game, AEROBICS_RADIO, 1,0); - } - - radio->next_action++; -} - -static void aRAD_setup_action(RADIO_ACTOR* radio, int action){ - static RADIO_PROC proc[] = {aRAD_wait}; - - radio->proc = proc[action]; - radio->current_action = action; - -} - -static void aRAD_actor_move(ACTOR* actor, GAME* game){ - GAME_PLAY* play = (GAME_PLAY*)game; - RADIO_ACTOR* radio = (RADIO_ACTOR*)actor; - PLAYER_ACTOR* player; - - int rbx; - int rbz; - int pbx; - int pbz; - - player = GET_PLAYER_ACTOR(play); - mFI_Wpos2BlockNum(&rbx,&rbz, radio->actor_class.world.position); - mFI_Wpos2BlockNum(&pbx,&pbz, player->actor_class.world.position); - - if(!mDemo_Check(mDemo_TYPE_SCROLL, &player->actor_class) && !mDemo_Check(mDemo_TYPE_SCROLL2, &player->actor_class) - && !mDemo_Check(mDemo_TYPE_SCROLL3, &player->actor_class) && ((rbx != pbx) || (rbz != pbz))){ - - Actor_delete(&radio->actor_class); - } - else{ - radio->proc(radio, play); - } -} - -static void aRAD_actor_init(ACTOR* actor, GAME* game){ - RADIO_ACTOR* radio = (RADIO_ACTOR*)actor; - xyz_t pos = radio->actor_class.home.position; - - mFI_SetFG_common(DUMMY_RADIO, pos, 0); - aRAD_actor_move(actor, game); - radio->actor_class.mv_proc = aRAD_actor_move; -} - -static void aRAD_actor_draw(ACTOR* actor, GAME* game){ - RADIO_ACTOR* radio = (RADIO_ACTOR*)actor; - - Mtx* cur; - GRAPH* graph = game->graph; - u16* pal; - Gfx* gfx; - - OPEN_DISP(graph); - pal = Common_Get(clip.structure_clip)->get_pal_segment_proc(aSTR_PAL_RADIO); - - cur = _Matrix_to_Mtx_new(graph); - - if(cur != NULL){ - _texture_z_light_fog_prim_npc(graph); - gfx = NOW_POLY_OPA_DISP; - gSPSegment(gfx++, 0x8, pal); - gSPMatrix(gfx++, cur,G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gfx++,radio_DL_model); - SET_POLY_OPA_DISP(gfx); - Common_Get(clip.bg_item_clip)->draw_shadow_proc(game, &aRAD_shadow_data, 0); - } - - CLOSE_DISP(graph); -} \ No newline at end of file +#include "../rel/ac_radio_draw.c_inc" diff --git a/rel/ac_radio_draw.c_inc b/rel/ac_radio_draw.c_inc new file mode 100644 index 00000000..745a1afa --- /dev/null +++ b/rel/ac_radio_draw.c_inc @@ -0,0 +1,25 @@ +static void aRAD_actor_draw(ACTOR* actor, GAME* game){ + RADIO_ACTOR* radio = (RADIO_ACTOR*)actor; + + Mtx* cur; + GRAPH* graph = game->graph; + u16* pal; + Gfx* gfx; + + OPEN_DISP(graph); + pal = Common_Get(clip.structure_clip)->get_pal_segment_proc(aSTR_PAL_RADIO); + + cur = _Matrix_to_Mtx_new(graph); + + if(cur != NULL){ + _texture_z_light_fog_prim_npc(graph); + gfx = NOW_POLY_OPA_DISP; + gSPSegment(gfx++, 0x8, pal); + gSPMatrix(gfx++, cur,G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++,radio_DL_model); + SET_POLY_OPA_DISP(gfx); + Common_Get(clip.bg_item_clip)->draw_shadow_proc(game, &aRAD_shadow_data, 0); + } + + CLOSE_DISP(graph); +} diff --git a/rel/ac_radio_move.c_inc b/rel/ac_radio_move.c_inc new file mode 100644 index 00000000..9270e19e --- /dev/null +++ b/rel/ac_radio_move.c_inc @@ -0,0 +1,63 @@ +static void aRAD_set_bgOffset(RADIO_ACTOR* radio, int offs){ + offs = offs == 0 ? 3 : 3; + + mCoBG_SetPlussOffset(radio->actor_class.home.position, offs, 100); +} + +static void aRAD_wait(RADIO_ACTOR* radio, GAME_PLAY* play){ + xyz_t def = {2.0f, 0.0f, -10.0f}; + xyz_t newPos; + + if(radio->next_action >= 0x24){ + radio->next_action = 0; + Matrix_push(); + Matrix_translate(radio->actor_class.world.position.x,radio->actor_class.world.position.y, radio->actor_class.world.position.z, 0); + Matrix_Position(&def, &newPos); + Matrix_pull(); + + Common_Get(clip.effect_clip->effect_make_proc)(32, newPos, 1, 0x6000, &play->game, AEROBICS_RADIO, 1,0); + } + + radio->next_action++; +} + +static void aRAD_setup_action(RADIO_ACTOR* radio, int action){ + static RADIO_PROC proc[] = {aRAD_wait}; + + radio->proc = proc[action]; + radio->current_action = action; + +} + +static void aRAD_actor_move(ACTOR* actor, GAME* game){ + GAME_PLAY* play = (GAME_PLAY*)game; + RADIO_ACTOR* radio = (RADIO_ACTOR*)actor; + PLAYER_ACTOR* player; + + int rbx; + int rbz; + int pbx; + int pbz; + + player = GET_PLAYER_ACTOR(play); + mFI_Wpos2BlockNum(&rbx,&rbz, radio->actor_class.world.position); + mFI_Wpos2BlockNum(&pbx,&pbz, player->actor_class.world.position); + + if(!mDemo_Check(mDemo_TYPE_SCROLL, &player->actor_class) && !mDemo_Check(mDemo_TYPE_SCROLL2, &player->actor_class) + && !mDemo_Check(mDemo_TYPE_SCROLL3, &player->actor_class) && ((rbx != pbx) || (rbz != pbz))){ + + Actor_delete(&radio->actor_class); + } + else{ + radio->proc(radio, play); + } +} + +static void aRAD_actor_init(ACTOR* actor, GAME* game){ + RADIO_ACTOR* radio = (RADIO_ACTOR*)actor; + xyz_t pos = radio->actor_class.home.position; + + mFI_SetFG_common(DUMMY_RADIO, pos, 0); + aRAD_actor_move(actor, game); + radio->actor_class.mv_proc = aRAD_actor_move; +} diff --git a/rel/ac_toudai.c b/rel/ac_toudai.c index 885182d9..9aaa3bec 100644 --- a/rel/ac_toudai.c +++ b/rel/ac_toudai.c @@ -123,310 +123,6 @@ static void aTOU_actor_dt(ACTOR* actor, GAME* game){ } -static void aTOU_rewrite_door(ACTOR* actor, GAME_PLAY* play){ - TOUDAI_ACTOR* light = (TOUDAI_ACTOR*)actor; - - xyz_t pos; - Door_data_c* door_data = Common_GetPointer(structure_exit_door_data); +#include "../rel/ac_toudai_move.c_inc" - if(play->fb_wipe_mode == 0){ - door_data->next_scene_id = Save_Get(scene_no); - door_data->exit_orientation = 4; - door_data->exit_type = 0; - door_data->extra_data = 3; - - pos.x = light->actor_class.world.position.x; - pos.z = light->actor_class.world.position.z - 70.0f; - pos.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(pos, 0.0f); - door_data->exit_position.x = pos.x; - door_data->exit_position.y = pos.y; - door_data->exit_position.z = pos.z; - door_data->door_actor_name = light->actor_class.npc_id; - door_data->wipe_type = 1; - mBGMPsComp_make_ps_wipe(0x2168); - } -} - -static int aTOU_check_door_pos(ACTOR* actor, GAME_PLAY* play){ - TOUDAI_ACTOR* light = (TOUDAI_ACTOR*)actor; - - PLAYER_ACTOR* player = get_player_actor_withoutCheck(play); - f32 diff; - - if(player != NULL){ - diff = (player->actor_class.world.position.z - light->actor_class.world.position.z); - if(fabsf(player->actor_class.world.position.x - light->actor_class.world.position.x) < 20.0f && - diff > -65.0f && diff < 0.0f){ - if((player->actor_class.shape_info.rotation.y > -0x2000) && - (player->actor_class.shape_info.rotation.y < 0x2000)){ - return 1; - } - } - } - - return 0; -} - -Door_data_c aTOU_door_data = { - SCENE_LIGHTHOUSE, - 0, - FALSE, - 0, - {120,0,100}, - EMPTY_NO, - 1, - {0,0,0}, -}; - -static void aTOU_set_bgOffset(TOUDAI_ACTOR* light, int idx){ - static mCoBG_OffsetTable_c height_table_ct[] = { { 0x64, 16, 16, 16, 16, 16, 0 }, - { 0x64, 16, 16, 16, 16, 16, 0 }, - { 0x64, 16, 16, 16, 16, 16, 0 }, - { 0x64, 16, 16, 16, 16, 16, 0 } }; - static mCoBG_OffsetTable_c* height_table[] = { height_table_ct, height_table_ct }; - static f32 addX[] = { -40.0f, 0.0f }; - static f32 addZ[] = { -40.0f, 0.0f }; - - mCoBG_OffsetTable_c* offset; - int i; - xyz_t pos; - - offset = height_table[idx]; - - for(i = 0; i < 2; i++){ - pos.z = light->actor_class.home.position.z + addZ[i]; - pos.x = light->actor_class.home.position.x + addX[0]; - mCoBG_SetPluss5PointOffset_file(pos, *offset, "ac_toudai_move.c_inc", 184); - offset++; - pos.x = light->actor_class.home.position.x + addX[1]; - mCoBG_SetPluss5PointOffset_file(pos, *offset, "ac_toudai_move.c_inc", 188); - offset++; - } -} - -static void aTOU_color_ctrl(TOUDAI_ACTOR* light) { - f32 factor; - int timer; - - if (light->ready_flag == 0) { - add_calc(&light->unk2C8, 0.0f, 1.0f - sqrtf(0.7), 50.0f, 0.5f); - add_calc(&light->unk2CC, 0.0f, 1.0f - sqrtf(0.7), 50.0f, 0.5f); - add_calc(&light->unk2D0, 0.0f, 1.0f - sqrtf(0.9), 50.0f, 0.5f); - return; - } - - timer = light->current_frame - 51; - factor = (timer < 0) ? 1.0f : -1.0f; - timer = ABS(timer); - - if (timer == 0) { - light->unk2C8 = 220.0f; - light->unk2CC = 240.0f; - - } else if (timer >= 40) { - add_calc(&light->unk2C8, 0.0f, 1.0f - sqrtf(0.7), 50.0f, 0.5f); - add_calc(&light->unk2CC, 0.0f, 1.0f - sqrtf(0.7), 50.0f, 0.5f); - - } else if (timer < 10) { - light->unk2C8 += (4.5f * factor); - light->unk2CC += (7.0f * factor); - - } else if (timer < 30) { - light->unk2C8 += (1.25f * factor); - light->unk2CC += (2.25f * factor); - - } else { - light->unk2C8 += (4.0f * factor); - light->unk2CC += (0.5f * factor); - } - - add_calc(&light->unk2D0, 255.0f, 1.0f - sqrtf(0.9), 50.0f, 0.5f); -} - -static void aTOU_init(ACTOR* actor, GAME_PLAY* play){ - aTOU_setup_action(actor, 1); -} - -static void aTOU_wait(ACTOR* actor, GAME_PLAY* play){ - TOUDAI_ACTOR* light = (TOUDAI_ACTOR*)actor; - int sec = Common_Get(time.now_sec); - - if(mSC_LightHouse_Switch_Check() != 0 && (sec >= 64800 || sec < 18000)){ - light->keyframe.frame_control.speed = 0.5f; - light->ready_flag = TRUE; - aTOU_setup_action(actor, 2); - } -} - -static void aTOU_lighting(ACTOR* actor, GAME_PLAY* play){ - TOUDAI_ACTOR* light = (TOUDAI_ACTOR*)actor; - int sec = Common_Get(time.now_sec); - - if((mSC_LightHouse_Switch_Check() == 0) || ((sec < 64800) - && (sec >= 18000))){ - aTOU_setup_action(actor, 3); - } -} - -static void aTOU_lightout(ACTOR* actor, GAME_PLAY* play){ - TOUDAI_ACTOR* light = (TOUDAI_ACTOR*)actor; - - if(light->current_frame == 0x33){ - light->keyframe.frame_control.speed = 0.0f; - light->ready_flag = 0; - aTOU_setup_action(actor, 1); - } -} - -extern cKF_Animation_R_c cKF_ba_r_obj_s_toudai; -extern cKF_Animation_R_c cKF_ba_r_obj_w_toudai; - -static void aTOU_setup_action(ACTOR* actor, int action) { - TOUDAI_ACTOR* light = (TOUDAI_ACTOR*)actor; - static cKF_Animation_R_c* ani[] = { &cKF_ba_r_obj_s_toudai, &cKF_ba_r_obj_w_toudai }; - static TOUDAI_PROC process[] = { aTOU_init, aTOU_wait, aTOU_lighting, aTOU_lightout }; - - int type; - - if(action == 0){ - type = light->season == mTM_SEASON_WINTER; - cKF_SkeletonInfo_R_init(&light->keyframe, light->keyframe.skeleton, ani[type], - 1.0f, 100.0f, 51.0f, 0.0f, 0.0f, cKF_FRAMECONTROL_REPEAT, NULL); - } - - light->proc = process[action]; - light->current_proc = action; -} - -static void aTOU_actor_move(ACTOR* actor, GAME* game){ - GAME_PLAY* play = (GAME_PLAY*)game; - TOUDAI_ACTOR* light = (TOUDAI_ACTOR*)actor; - - light->keyframe_state = cKF_SkeletonInfo_R_play(&light->keyframe); - light->current_frame = light->keyframe.frame_control.current_frame; - - if(get_player_actor_withoutCheck((GAME_PLAY*)gamePT)->get_door_label_proc(gamePT) == light){ - aTOU_rewrite_door(&light->actor_class, play); - goto_other_scene(play, &aTOU_door_data, 0); - } - else{ - light->proc(actor,play); - - if((mSC_LightHouse_In_Check() != 0) && (aTOU_check_door_pos(actor,play) != 0)){ - xyz_t pos; - pos.x = light->actor_class.world.position.x; - pos.y = light->actor_class.world.position.y; - pos.z = light->actor_class.world.position.z - 60.0f; - mPlib_request_main_door_type1(play, &pos, 0, 1, light); - } - } - aTOU_color_ctrl(light); -} - -static void aTOU_actor_init(ACTOR* actor, GAME* game){ - TOUDAI_ACTOR* light = (TOUDAI_ACTOR*)actor; - - mFI_SetFG_common(0xF11E, light->actor_class.home.position, 0); - aTOU_actor_move(actor, game); - light->actor_class.mv_proc = aTOU_actor_move; -} - -static int aTOU_actor_draw_before(GAME*,cKF_SkeletonInfo_R_c*, int idx, Gfx** gfxp,u8* dispbuf, void* actor, s_xyz* rotation, xyz_t* translation){ - - if(idx == 4){ - *gfxp = NULL; - } - - return 1; -} - -extern Gfx obj_s_toudai_light_model[]; -extern Gfx obj_w_toudai_light_model[]; - -static int aTOU_actor_draw_after(GAME* game,cKF_SkeletonInfo_R_c* info, int idx, Gfx** gfxp, -u8* dispbuf, void* actor, s_xyz* rotation, xyz_t* translation){ - static Gfx* mdl[] = {obj_s_toudai_light_model, obj_w_toudai_light_model}; - static rgba_t prmcol = {255,255,150,120}; - TOUDAI_ACTOR* light = (TOUDAI_ACTOR*)actor; - - GRAPH* graph = game->graph; - Mtx* work; - u16* pal; - Gfx* gfx; - int type; - - if((idx == 4) && ((int)light->unk2CC != 0)){ - work = _Matrix_to_Mtx_new(graph); - - if(work != NULL){ - type = light->season == mTM_SEASON_WINTER; - pal = Common_Get(clip.structure_clip)->get_pal_segment_proc(aSTR_PAL_TOUDAI); - _texture_z_light_fog_prim_light(graph); - - OPEN_DISP(graph); - - gfx = NOW_LIGHT_DISP; - gSPSegment(gfx++, 0x8, pal); - - prmcol.b = light->unk2C8; - prmcol.a = light->unk2CC; - - if(prmcol.a > (u8)light->unk2D0){ - prmcol.a = light->unk2D0; - } - - gDPPipeSync(gfx++); - gDPSetPrimColor(gfx++, 0, (s8)light->unk2D0, prmcol.r, prmcol.g, prmcol.b, prmcol.a); - gSPMatrix(gfx++, work, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gfx++, mdl[type]); - - SET_LIGHT_DISP(gfx); - CLOSE_DISP(graph); - } - } - - return 1; -} - - -static void aTOU_actor_draw(ACTOR* actor, GAME* game){ - GAME_PLAY* play = (GAME_PLAY*)game; - GRAPH* graph; - - Gfx* gfx; - u16* pal; - cKF_SkeletonInfo_R_c* keyf; - Mtx* mtx; - xyz_t* pos; - TOUDAI_ACTOR* light = (TOUDAI_ACTOR*)actor; - - graph = game->graph; - pos = &light->actor_class.world.position; - keyf = &light->keyframe; - mtx = GRAPH_ALLOC_TYPE(graph, Mtx, keyf->skeleton->num_shown_joints); - - if(mtx != NULL){ - pal = Common_Get(clip.structure_clip)->get_pal_segment_proc(aSTR_PAL_TOUDAI); - - OPEN_DISP(graph); - - _texture_z_light_fog_prim_npc(graph); - - gfx = NOW_POLY_OPA_DISP; - gSPSegment(gfx++, 0x8, pal); - SET_POLY_OPA_DISP(gfx); - - _texture_z_light_fog_prim_xlu(graph); - - gfx = NOW_POLY_XLU_DISP; - gSPSegment(gfx++, 0x8, pal); - SET_POLY_XLU_DISP(gfx); - - Setpos_HiliteReflect_init(pos, play); - Setpos_HiliteReflect_xlu_init(pos, play); - - cKF_Si3_draw_R_SV(game, keyf, mtx, aTOU_actor_draw_before, aTOU_actor_draw_after, light); - (*Common_Get(clip).bg_item_clip->draw_shadow_proc)(game, &aTOU_shadow_data, TRUE); - CLOSE_DISP(graph); - } -} \ No newline at end of file +#include "../rel/ac_toudai_draw.c_inc" diff --git a/rel/ac_toudai_draw.c_inc b/rel/ac_toudai_draw.c_inc new file mode 100644 index 00000000..8dbfba7f --- /dev/null +++ b/rel/ac_toudai_draw.c_inc @@ -0,0 +1,99 @@ +static int aTOU_actor_draw_before(GAME*,cKF_SkeletonInfo_R_c*, int idx, Gfx** gfxp,u8* dispbuf, void* actor, s_xyz* rotation, xyz_t* translation){ + + if(idx == 4){ + *gfxp = NULL; + } + + return 1; +} + +extern Gfx obj_s_toudai_light_model[]; +extern Gfx obj_w_toudai_light_model[]; + +static int aTOU_actor_draw_after(GAME* game,cKF_SkeletonInfo_R_c* info, int idx, Gfx** gfxp, +u8* dispbuf, void* actor, s_xyz* rotation, xyz_t* translation){ + static Gfx* mdl[] = {obj_s_toudai_light_model, obj_w_toudai_light_model}; + static rgba_t prmcol = {255,255,150,120}; + TOUDAI_ACTOR* light = (TOUDAI_ACTOR*)actor; + + GRAPH* graph = game->graph; + Mtx* work; + u16* pal; + Gfx* gfx; + int type; + + if((idx == 4) && ((int)light->unk2CC != 0)){ + work = _Matrix_to_Mtx_new(graph); + + if(work != NULL){ + type = light->season == mTM_SEASON_WINTER; + pal = Common_Get(clip.structure_clip)->get_pal_segment_proc(aSTR_PAL_TOUDAI); + _texture_z_light_fog_prim_light(graph); + + OPEN_DISP(graph); + + gfx = NOW_LIGHT_DISP; + gSPSegment(gfx++, 0x8, pal); + + prmcol.b = light->unk2C8; + prmcol.a = light->unk2CC; + + if(prmcol.a > (u8)light->unk2D0){ + prmcol.a = light->unk2D0; + } + + gDPPipeSync(gfx++); + gDPSetPrimColor(gfx++, 0, (s8)light->unk2D0, prmcol.r, prmcol.g, prmcol.b, prmcol.a); + gSPMatrix(gfx++, work, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, mdl[type]); + + SET_LIGHT_DISP(gfx); + CLOSE_DISP(graph); + } + } + + return 1; +} + + +static void aTOU_actor_draw(ACTOR* actor, GAME* game){ + GAME_PLAY* play = (GAME_PLAY*)game; + GRAPH* graph; + + Gfx* gfx; + u16* pal; + cKF_SkeletonInfo_R_c* keyf; + Mtx* mtx; + xyz_t* pos; + TOUDAI_ACTOR* light = (TOUDAI_ACTOR*)actor; + + graph = game->graph; + pos = &light->actor_class.world.position; + keyf = &light->keyframe; + mtx = GRAPH_ALLOC_TYPE(graph, Mtx, keyf->skeleton->num_shown_joints); + + if(mtx != NULL){ + pal = Common_Get(clip.structure_clip)->get_pal_segment_proc(aSTR_PAL_TOUDAI); + + OPEN_DISP(graph); + + _texture_z_light_fog_prim_npc(graph); + + gfx = NOW_POLY_OPA_DISP; + gSPSegment(gfx++, 0x8, pal); + SET_POLY_OPA_DISP(gfx); + + _texture_z_light_fog_prim_xlu(graph); + + gfx = NOW_POLY_XLU_DISP; + gSPSegment(gfx++, 0x8, pal); + SET_POLY_XLU_DISP(gfx); + + Setpos_HiliteReflect_init(pos, play); + Setpos_HiliteReflect_xlu_init(pos, play); + + cKF_Si3_draw_R_SV(game, keyf, mtx, aTOU_actor_draw_before, aTOU_actor_draw_after, light); + (*Common_Get(clip).bg_item_clip->draw_shadow_proc)(game, &aTOU_shadow_data, TRUE); + CLOSE_DISP(graph); + } +} diff --git a/rel/ac_toudai_move.c_inc b/rel/ac_toudai_move.c_inc new file mode 100644 index 00000000..b774ee31 --- /dev/null +++ b/rel/ac_toudai_move.c_inc @@ -0,0 +1,207 @@ +static void aTOU_rewrite_door(ACTOR* actor, GAME_PLAY* play){ + TOUDAI_ACTOR* light = (TOUDAI_ACTOR*)actor; + + xyz_t pos; + Door_data_c* door_data = Common_GetPointer(structure_exit_door_data); + + if(play->fb_wipe_mode == 0){ + door_data->next_scene_id = Save_Get(scene_no); + door_data->exit_orientation = 4; + door_data->exit_type = 0; + door_data->extra_data = 3; + + pos.x = light->actor_class.world.position.x; + pos.z = light->actor_class.world.position.z - 70.0f; + pos.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(pos, 0.0f); + door_data->exit_position.x = pos.x; + door_data->exit_position.y = pos.y; + door_data->exit_position.z = pos.z; + door_data->door_actor_name = light->actor_class.npc_id; + door_data->wipe_type = 1; + mBGMPsComp_make_ps_wipe(0x2168); + } +} + +static int aTOU_check_door_pos(ACTOR* actor, GAME_PLAY* play){ + TOUDAI_ACTOR* light = (TOUDAI_ACTOR*)actor; + + PLAYER_ACTOR* player = get_player_actor_withoutCheck(play); + f32 diff; + + if(player != NULL){ + diff = (player->actor_class.world.position.z - light->actor_class.world.position.z); + if(fabsf(player->actor_class.world.position.x - light->actor_class.world.position.x) < 20.0f && + diff > -65.0f && diff < 0.0f){ + if((player->actor_class.shape_info.rotation.y > -0x2000) && + (player->actor_class.shape_info.rotation.y < 0x2000)){ + return 1; + } + } + } + + return 0; +} + +Door_data_c aTOU_door_data = { + SCENE_LIGHTHOUSE, + 0, + FALSE, + 0, + {120,0,100}, + EMPTY_NO, + 1, + {0,0,0}, +}; + +static void aTOU_set_bgOffset(TOUDAI_ACTOR* light, int idx){ + static mCoBG_OffsetTable_c height_table_ct[] = { { 0x64, 16, 16, 16, 16, 16, 0 }, + { 0x64, 16, 16, 16, 16, 16, 0 }, + { 0x64, 16, 16, 16, 16, 16, 0 }, + { 0x64, 16, 16, 16, 16, 16, 0 } }; + static mCoBG_OffsetTable_c* height_table[] = { height_table_ct, height_table_ct }; + static f32 addX[] = { -40.0f, 0.0f }; + static f32 addZ[] = { -40.0f, 0.0f }; + + mCoBG_OffsetTable_c* offset; + int i; + xyz_t pos; + + offset = height_table[idx]; + + for(i = 0; i < 2; i++){ + pos.z = light->actor_class.home.position.z + addZ[i]; + pos.x = light->actor_class.home.position.x + addX[0]; + mCoBG_SetPluss5PointOffset_file(pos, *offset, "ac_toudai_move.c_inc", 184); + offset++; + pos.x = light->actor_class.home.position.x + addX[1]; + mCoBG_SetPluss5PointOffset_file(pos, *offset, "ac_toudai_move.c_inc", 188); + offset++; + } +} + +static void aTOU_color_ctrl(TOUDAI_ACTOR* light) { + f32 factor; + int timer; + + if (light->ready_flag == 0) { + add_calc(&light->unk2C8, 0.0f, 1.0f - sqrtf(0.7), 50.0f, 0.5f); + add_calc(&light->unk2CC, 0.0f, 1.0f - sqrtf(0.7), 50.0f, 0.5f); + add_calc(&light->unk2D0, 0.0f, 1.0f - sqrtf(0.9), 50.0f, 0.5f); + return; + } + + timer = light->current_frame - 51; + factor = (timer < 0) ? 1.0f : -1.0f; + timer = ABS(timer); + + if (timer == 0) { + light->unk2C8 = 220.0f; + light->unk2CC = 240.0f; + + } else if (timer >= 40) { + add_calc(&light->unk2C8, 0.0f, 1.0f - sqrtf(0.7), 50.0f, 0.5f); + add_calc(&light->unk2CC, 0.0f, 1.0f - sqrtf(0.7), 50.0f, 0.5f); + + } else if (timer < 10) { + light->unk2C8 += (4.5f * factor); + light->unk2CC += (7.0f * factor); + + } else if (timer < 30) { + light->unk2C8 += (1.25f * factor); + light->unk2CC += (2.25f * factor); + + } else { + light->unk2C8 += (4.0f * factor); + light->unk2CC += (0.5f * factor); + } + + add_calc(&light->unk2D0, 255.0f, 1.0f - sqrtf(0.9), 50.0f, 0.5f); +} + +static void aTOU_init(ACTOR* actor, GAME_PLAY* play){ + aTOU_setup_action(actor, 1); +} + +static void aTOU_wait(ACTOR* actor, GAME_PLAY* play){ + TOUDAI_ACTOR* light = (TOUDAI_ACTOR*)actor; + int sec = Common_Get(time.now_sec); + + if(mSC_LightHouse_Switch_Check() != 0 && (sec >= 64800 || sec < 18000)){ + light->keyframe.frame_control.speed = 0.5f; + light->ready_flag = TRUE; + aTOU_setup_action(actor, 2); + } +} + +static void aTOU_lighting(ACTOR* actor, GAME_PLAY* play){ + TOUDAI_ACTOR* light = (TOUDAI_ACTOR*)actor; + int sec = Common_Get(time.now_sec); + + if((mSC_LightHouse_Switch_Check() == 0) || ((sec < 64800) + && (sec >= 18000))){ + aTOU_setup_action(actor, 3); + } +} + +static void aTOU_lightout(ACTOR* actor, GAME_PLAY* play){ + TOUDAI_ACTOR* light = (TOUDAI_ACTOR*)actor; + + if(light->current_frame == 0x33){ + light->keyframe.frame_control.speed = 0.0f; + light->ready_flag = 0; + aTOU_setup_action(actor, 1); + } +} + +extern cKF_Animation_R_c cKF_ba_r_obj_s_toudai; +extern cKF_Animation_R_c cKF_ba_r_obj_w_toudai; + +static void aTOU_setup_action(ACTOR* actor, int action) { + TOUDAI_ACTOR* light = (TOUDAI_ACTOR*)actor; + static cKF_Animation_R_c* ani[] = { &cKF_ba_r_obj_s_toudai, &cKF_ba_r_obj_w_toudai }; + static TOUDAI_PROC process[] = { aTOU_init, aTOU_wait, aTOU_lighting, aTOU_lightout }; + + int type; + + if(action == 0){ + type = light->season == mTM_SEASON_WINTER; + cKF_SkeletonInfo_R_init(&light->keyframe, light->keyframe.skeleton, ani[type], + 1.0f, 100.0f, 51.0f, 0.0f, 0.0f, cKF_FRAMECONTROL_REPEAT, NULL); + } + + light->proc = process[action]; + light->current_proc = action; +} + +static void aTOU_actor_move(ACTOR* actor, GAME* game){ + GAME_PLAY* play = (GAME_PLAY*)game; + TOUDAI_ACTOR* light = (TOUDAI_ACTOR*)actor; + + light->keyframe_state = cKF_SkeletonInfo_R_play(&light->keyframe); + light->current_frame = light->keyframe.frame_control.current_frame; + + if(get_player_actor_withoutCheck((GAME_PLAY*)gamePT)->get_door_label_proc(gamePT) == light){ + aTOU_rewrite_door(&light->actor_class, play); + goto_other_scene(play, &aTOU_door_data, 0); + } + else{ + light->proc(actor,play); + + if((mSC_LightHouse_In_Check() != 0) && (aTOU_check_door_pos(actor,play) != 0)){ + xyz_t pos; + pos.x = light->actor_class.world.position.x; + pos.y = light->actor_class.world.position.y; + pos.z = light->actor_class.world.position.z - 60.0f; + mPlib_request_main_door_type1(play, &pos, 0, 1, light); + } + } + aTOU_color_ctrl(light); +} + +static void aTOU_actor_init(ACTOR* actor, GAME* game){ + TOUDAI_ACTOR* light = (TOUDAI_ACTOR*)actor; + + mFI_SetFG_common(0xF11E, light->actor_class.home.position, 0); + aTOU_actor_move(actor, game); + light->actor_class.mv_proc = aTOU_actor_move; +} diff --git a/rel/ac_train0.c b/rel/ac_train0.c index 1c571ed9..74950cfb 100644 --- a/rel/ac_train0.c +++ b/rel/ac_train0.c @@ -61,246 +61,6 @@ static void aTR0_actor_dt(ACTOR* actor, GAME* game){ Common_Set(train_exists_flag, 0); } -static void aTR0_ctrl_engineer(ACTOR* actor, GAME* game){ - TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; - GAME_PLAY* play = (GAME_PLAY* )game; +#include "../rel/ac_train0_move.c_inc" - - ACTOR* ac_p; - - ac_p = train0->tr_actor_p; - - if(ac_p == NULL){ - - if((*Common_Get(clip.npc_clip)->setupActor_proc)(play, SP_NPC_ENGINEER, -1,-1,-1,-1,-1,0,0) == 1){ - train0->tr_actor_p = Actor_info_fgName_search(&play->actor_info, SP_NPC_ENGINEER, ACTOR_PART_NPC); - } - } - else{ - ac_p->world.position.x = -40.0f + train0->actor_class.world.position.x; - ac_p->world.position.y = 47.0f + train0->actor_class.world.position.y; - ac_p->world.position.z = 20.0f + train0->actor_class.world.position.z; - } -} - -static void aTR0_set_effect(ACTOR* actor, GAME* game){ - TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; - - int calc; - xyz_t pos; - xyz_t clip_pos; - if(train0->effect_num <= 0){ - if(train0->actor_class.speed >= 1.0f){ - calc = (12.0f/train0->actor_class.speed); - train0->effect_num = calc; - } - else{ - train0->effect_num = 12; - } - xyz_t_move(&pos, &train0->actor_class.world.position); - pos.x += 36.0f; - pos.y += 110.0f; - - if(mEv_CheckTitleDemo() == 0){ - clip_pos = pos; - (*Common_Get(clip.effect_clip)->effect_make_proc)(35, clip_pos, 1,0, game, train0->actor_class.npc_id, 0,0); - } - } - else{ - train0->effect_num--; - } -} - -static void aTR0_steam_work_sub(ACTOR* actor, GAME* game, int x_idx){ - TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; - xyz_t pos; - xyz_t clip_pos; - int unk2c0; - static f32 setX[] = {15.0f, 22.0f}; - static s16 angl[] = {0xd000, 0x0400}; - - pos.x = train0->actor_class.world.position.x + setX[x_idx]; - pos.y = train0->actor_class.world.position.y + 21.0f; - pos.z = train0->actor_class.world.position.z + 42.0f; - unk2c0 = train0->unk2c0; - if(mEv_CheckTitleDemo() == 0){ - clip_pos = pos; - (*Common_Get(clip.effect_clip)->effect_make_proc)(63, clip_pos, 1,angl[x_idx], game, train0->actor_class.npc_id, 0,0); - } - unk2c0++; - train0->unk2c0 = unk2c0 % 4; -} - -static void aTR0_steam_work(ACTOR* actor, GAME* game){ - TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; - - if(train0->steam_available == 1){ - if((train0->steam_timer >= 2) && (train0->steam_timer <= 5)){ - aTR0_steam_work_sub(actor,game,0); - } - if((train0->steam_timer >= 13) && (train0->steam_timer <= 16)){ - aTR0_steam_work_sub(actor,game,1); - } - } -} - -static f32 calc_speed1(ACTOR* actor){ - TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; - - if(fabsf(train0->tr_speed) < 0.008f){ - return 0.8f + train0->actor_class.speed; - } - - if(train0->tr_speed < train0->actor_class.speed){ - return train0->actor_class.speed + (0.5f * - (train0->tr_speed - train0->actor_class.speed)); - } - - return train0->actor_class.speed; -} - -static f32 calc_speed2(ACTOR* actor){ - TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; - int should_stop = fabsf(train0->actor_class.speed) < 0.008f; - - return should_stop == FALSE ? train0->actor_class.speed : -0.23f; -} - -static void aTR0_ctrl_back_car(ACTOR* actor){ - TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; - - f32 tr_back_calc = train0->tr1_pos; - f32 base_x_pos = -125.0f + train0->actor_class.world.position.x; - tr_back_calc += 0.5f * train0->tr_speed; - - if((tr_back_calc - base_x_pos) > 2.0f){ - train0->tr_speed = calc_speed2(actor); - train0->tr1_pos = 2.0f + base_x_pos; - } - else if((tr_back_calc - base_x_pos) <= 0.0f){ - train0->tr_speed = calc_speed1(actor); - train0->tr1_pos = base_x_pos; - } - else{ - chase_f(&train0->tr_speed, 0.0f, 0.0025f); - train0->tr1_pos = tr_back_calc; - } -} - -static void aTR0_animation(ACTOR* actor){ - TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; - - int av = 0; - int cur_frame = train0->keyframe.frame_control.current_frame; - cKF_SkeletonInfo_R_play(&train0->keyframe); - - if( cur_frame!= train0->steam_timer){ - train0->steam_timer = cur_frame; - av = 1; - } - train0->steam_available = av; -} - -static void aTR0_move(ACTOR* actor){ - TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; - xyz_t pos; - - if(train0->tr_action != Common_Get(train_action)){ - train0->tr_action = Common_Get(train_action); - } - pos = Common_Get(train_position); - train0->actor_class.world.position.x = pos.x; - train0->actor_class.world.position.z = pos.z; - train0->actor_class.speed = Common_Get(train_speed); -} - -static void aTR0_delcheck(ACTOR* actor,GAME* game){ - GAME_PLAY* play = (GAME_PLAY* )game; - TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; - - int x; - int z; - int abs_x; - xyz_t pos; - - pos = train0->actor_class.world.position; - - mFI_Wpos2BlockNum(&x,&z,pos); - x -= play->block_table.block_x; - abs_x = x >= 0 ? x: -x; - - if((abs_x >= 2) || (z != play->block_table.block_z) || (train0->tr_action == 0)){ - if((int)train0->tr_actor_p != 0){ - Actor_delete(train0->tr_actor_p); - } - Actor_delete(actor->child_actor); - Actor_delete(actor); - } -} - -static void aTR0_actor_move(ACTOR* actor, GAME* game){ - TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; - GAME_PLAY* play = (GAME_PLAY* )game; - - f32 speed; - aTR0_animation(actor); - aTR0_move(actor); - - if(!(fabsf(train0->actor_class.speed) < 0.008f)){ - aTR0_set_effect(actor,game); - aTR0_steam_work(actor,game); - } - - if(mEv_CheckTitleDemo() == 1){ - train0->tr1_pos = -125.0f + train0->actor_class.world.position.x; - } - else{ - aTR0_ctrl_back_car(actor); - } - - aTR0_ctrl_engineer(actor,game); - - speed = (train0->actor_class.speed / 40.0f) * 10.0f; - - if(speed >= 0.5f){ - speed = 0.5f; - } - - train0->keyframe.frame_control.speed = speed; - aTR0_delcheck(&train0->actor_class, game); -} - -static void aTR0_actor_draw(ACTOR* actor, GAME* game){ - u16* pal = (*Common_Get(clip).structure_clip->get_pal_segment_proc)(0x39); - GRAPH* graph = game->graph; - cKF_SkeletonInfo_R_c* keyf; - TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; - - Mtx* mtx; - Gfx* gfx; - - keyf = &train0->keyframe; - mtx = GRAPH_ALLOC_TYPE(graph, Mtx, keyf->skeleton->num_shown_joints); - - if (mtx != NULL){ - _texture_z_light_fog_prim_npc(graph); - Matrix_push(); - Matrix_translate(train0->tr1_pos, train0->actor_class.world.position.y, - train0->actor_class.world.position.z, 0); - Matrix_scale(train0->actor_class.scale.x, train0->actor_class.scale.y, - train0->actor_class.scale.z, 1); - - OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; - - gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(gfx++, G_MWO_SEGMENT_8, pal); - gDPLoadTLUT_Dolphin(gfx++, 15, 16, 1, pal); - gSPDisplayList(gfx++, obj_train1_2_model); - - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); - - Matrix_pull(); - cKF_Si3_draw_R_SV(game, keyf, mtx, NULL,NULL,train0); - } -} \ No newline at end of file +#include "../rel/ac_train0_draw.c_inc" diff --git a/rel/ac_train0_draw.c_inc b/rel/ac_train0_draw.c_inc new file mode 100644 index 00000000..0d15e7a8 --- /dev/null +++ b/rel/ac_train0_draw.c_inc @@ -0,0 +1,35 @@ +static void aTR0_actor_draw(ACTOR* actor, GAME* game){ + u16* pal = (*Common_Get(clip).structure_clip->get_pal_segment_proc)(0x39); + GRAPH* graph = game->graph; + cKF_SkeletonInfo_R_c* keyf; + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + + Mtx* mtx; + Gfx* gfx; + + keyf = &train0->keyframe; + mtx = GRAPH_ALLOC_TYPE(graph, Mtx, keyf->skeleton->num_shown_joints); + + if (mtx != NULL){ + _texture_z_light_fog_prim_npc(graph); + Matrix_push(); + Matrix_translate(train0->tr1_pos, train0->actor_class.world.position.y, + train0->actor_class.world.position.z, 0); + Matrix_scale(train0->actor_class.scale.x, train0->actor_class.scale.y, + train0->actor_class.scale.z, 1); + + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; + + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(gfx++, G_MWO_SEGMENT_8, pal); + gDPLoadTLUT_Dolphin(gfx++, 15, 16, 1, pal); + gSPDisplayList(gfx++, obj_train1_2_model); + + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); + + Matrix_pull(); + cKF_Si3_draw_R_SV(game, keyf, mtx, NULL,NULL,train0); + } +} diff --git a/rel/ac_train0_move.c_inc b/rel/ac_train0_move.c_inc new file mode 100644 index 00000000..0d415ea0 --- /dev/null +++ b/rel/ac_train0_move.c_inc @@ -0,0 +1,207 @@ +static void aTR0_ctrl_engineer(ACTOR* actor, GAME* game){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY* )game; + + + ACTOR* ac_p; + + ac_p = train0->tr_actor_p; + + if(ac_p == NULL){ + + if((*Common_Get(clip.npc_clip)->setupActor_proc)(play, SP_NPC_ENGINEER, -1,-1,-1,-1,-1,0,0) == 1){ + train0->tr_actor_p = Actor_info_fgName_search(&play->actor_info, SP_NPC_ENGINEER, ACTOR_PART_NPC); + } + } + else{ + ac_p->world.position.x = -40.0f + train0->actor_class.world.position.x; + ac_p->world.position.y = 47.0f + train0->actor_class.world.position.y; + ac_p->world.position.z = 20.0f + train0->actor_class.world.position.z; + } +} + +static void aTR0_set_effect(ACTOR* actor, GAME* game){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + + int calc; + xyz_t pos; + xyz_t clip_pos; + if(train0->effect_num <= 0){ + if(train0->actor_class.speed >= 1.0f){ + calc = (12.0f/train0->actor_class.speed); + train0->effect_num = calc; + } + else{ + train0->effect_num = 12; + } + xyz_t_move(&pos, &train0->actor_class.world.position); + pos.x += 36.0f; + pos.y += 110.0f; + + if(mEv_CheckTitleDemo() == 0){ + clip_pos = pos; + (*Common_Get(clip.effect_clip)->effect_make_proc)(35, clip_pos, 1,0, game, train0->actor_class.npc_id, 0,0); + } + } + else{ + train0->effect_num--; + } +} + +static void aTR0_steam_work_sub(ACTOR* actor, GAME* game, int x_idx){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + xyz_t pos; + xyz_t clip_pos; + int unk2c0; + static f32 setX[] = {15.0f, 22.0f}; + static s16 angl[] = {0xd000, 0x0400}; + + pos.x = train0->actor_class.world.position.x + setX[x_idx]; + pos.y = train0->actor_class.world.position.y + 21.0f; + pos.z = train0->actor_class.world.position.z + 42.0f; + unk2c0 = train0->unk2c0; + if(mEv_CheckTitleDemo() == 0){ + clip_pos = pos; + (*Common_Get(clip.effect_clip)->effect_make_proc)(63, clip_pos, 1,angl[x_idx], game, train0->actor_class.npc_id, 0,0); + } + unk2c0++; + train0->unk2c0 = unk2c0 % 4; +} + +static void aTR0_steam_work(ACTOR* actor, GAME* game){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + + if(train0->steam_available == 1){ + if((train0->steam_timer >= 2) && (train0->steam_timer <= 5)){ + aTR0_steam_work_sub(actor,game,0); + } + if((train0->steam_timer >= 13) && (train0->steam_timer <= 16)){ + aTR0_steam_work_sub(actor,game,1); + } + } +} + +static f32 calc_speed1(ACTOR* actor){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + + if(fabsf(train0->tr_speed) < 0.008f){ + return 0.8f + train0->actor_class.speed; + } + + if(train0->tr_speed < train0->actor_class.speed){ + return train0->actor_class.speed + (0.5f * - (train0->tr_speed - train0->actor_class.speed)); + } + + return train0->actor_class.speed; +} + +static f32 calc_speed2(ACTOR* actor){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + int should_stop = fabsf(train0->actor_class.speed) < 0.008f; + + return should_stop == FALSE ? train0->actor_class.speed : -0.23f; +} + +static void aTR0_ctrl_back_car(ACTOR* actor){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + + f32 tr_back_calc = train0->tr1_pos; + f32 base_x_pos = -125.0f + train0->actor_class.world.position.x; + tr_back_calc += 0.5f * train0->tr_speed; + + if((tr_back_calc - base_x_pos) > 2.0f){ + train0->tr_speed = calc_speed2(actor); + train0->tr1_pos = 2.0f + base_x_pos; + } + else if((tr_back_calc - base_x_pos) <= 0.0f){ + train0->tr_speed = calc_speed1(actor); + train0->tr1_pos = base_x_pos; + } + else{ + chase_f(&train0->tr_speed, 0.0f, 0.0025f); + train0->tr1_pos = tr_back_calc; + } +} + +static void aTR0_animation(ACTOR* actor){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + + int av = 0; + int cur_frame = train0->keyframe.frame_control.current_frame; + cKF_SkeletonInfo_R_play(&train0->keyframe); + + if( cur_frame!= train0->steam_timer){ + train0->steam_timer = cur_frame; + av = 1; + } + train0->steam_available = av; +} + +static void aTR0_move(ACTOR* actor){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + xyz_t pos; + + if(train0->tr_action != Common_Get(train_action)){ + train0->tr_action = Common_Get(train_action); + } + pos = Common_Get(train_position); + train0->actor_class.world.position.x = pos.x; + train0->actor_class.world.position.z = pos.z; + train0->actor_class.speed = Common_Get(train_speed); +} + +static void aTR0_delcheck(ACTOR* actor,GAME* game){ + GAME_PLAY* play = (GAME_PLAY* )game; + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + + int x; + int z; + int abs_x; + xyz_t pos; + + pos = train0->actor_class.world.position; + + mFI_Wpos2BlockNum(&x,&z,pos); + x -= play->block_table.block_x; + abs_x = x >= 0 ? x: -x; + + if((abs_x >= 2) || (z != play->block_table.block_z) || (train0->tr_action == 0)){ + if((int)train0->tr_actor_p != 0){ + Actor_delete(train0->tr_actor_p); + } + Actor_delete(actor->child_actor); + Actor_delete(actor); + } +} + +static void aTR0_actor_move(ACTOR* actor, GAME* game){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY* )game; + + f32 speed; + aTR0_animation(actor); + aTR0_move(actor); + + if(!(fabsf(train0->actor_class.speed) < 0.008f)){ + aTR0_set_effect(actor,game); + aTR0_steam_work(actor,game); + } + + if(mEv_CheckTitleDemo() == 1){ + train0->tr1_pos = -125.0f + train0->actor_class.world.position.x; + } + else{ + aTR0_ctrl_back_car(actor); + } + + aTR0_ctrl_engineer(actor,game); + + speed = (train0->actor_class.speed / 40.0f) * 10.0f; + + if(speed >= 0.5f){ + speed = 0.5f; + } + + train0->keyframe.frame_control.speed = speed; + aTR0_delcheck(&train0->actor_class, game); +} diff --git a/rel/ac_train1.c b/rel/ac_train1.c index c8e309b7..97eadea9 100644 --- a/rel/ac_train1.c +++ b/rel/ac_train1.c @@ -60,181 +60,6 @@ static void aTR1_actor_dt(ACTOR* actor, GAME* game){ cKF_SkeletonInfo_R_dt(&train1->keyframe); } -static void aTR1_OngenTrgStart(ACTOR* actor, u16 id){ - TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; +#include "../rel/ac_train1_move.c_inc" - sAdo_OngenTrgStart(id, &train1->actor_class.world.position); -} - -static f32 calc_speed1(ACTOR* actor0, ACTOR* actor1) { - TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor0; - TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor1; - - if (fabsf(actor1->speed) < 0.008f) { - return 0.8f + train0->tr_speed; - } - - if (actor1->speed < train0->tr_speed){ - return train0->tr_speed + (0.5f * - (actor1->speed - train0->tr_speed)); - } - - return train0->tr_speed; -} - -static f32 calc_speed2(ACTOR* actor){ - TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; - int should_stop = fabsf(train1->tr0_pos) < 0.008f; - - return should_stop == FALSE ? train1->tr0_pos : -0.23f; -} - -static void aTR1_position_move(ACTOR* actor){ - TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; - TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor->parent_actor; - - f32 diff; - f32 tr_back_calc; - f32 base_x_pos; - - tr_back_calc = train1->actor_class.world.position.x; - base_x_pos = -125.0f + train0->tr1_pos; - tr_back_calc += 0.5f * train1->actor_class.speed; - - diff = tr_back_calc - base_x_pos; - if((diff) <= 0.0f){ - train1->actor_class.speed = calc_speed1(actor->parent_actor, actor); - train1->actor_class.world.position.x = base_x_pos; - } - else if((diff) > 2.0f){ - train1->actor_class.speed = calc_speed2(actor->parent_actor); - train1->actor_class.world.position.x = 2.0f + base_x_pos; - } - else{ - chase_f(&train1->actor_class.speed, 0.0f, 0.0025f); - train1->actor_class.world.position.x = tr_back_calc; - } -} - -static void aTR1_chg_station_attr(int station){ - static xyz_t doorway_pos = { 2180.0f, 0.0f, 820.0f }; - xyz_t soil_pos; - xyz_t unk20_pos; - - if(mEv_CheckFirstIntro() == 0){ - if(station == 5){ - soil_pos = doorway_pos; - mCoBG_SetAttribute(&soil_pos, 7); - } - else if(station == 6){ - unk20_pos = doorway_pos; - mCoBG_SetAttribute(&unk20_pos, 0x20); - } - } -} - -static void aTR1_passenger_ctrl(ACTOR* actor){ - TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; - - GAME_PLAY* play = (GAME_PLAY*)gamePT; - xyz_t pos; - s_xyz rot; - - if(train1->player_pass_exists == 1){ - pos.x = train1->actor_class.world.position.x + 60.0f; - pos.y = train1->actor_class.world.position.y + 20.0f; - pos.z = train1->actor_class.world.position.z + 20.0f; - rot.x = ZeroSVec.x; - rot.y = ZeroSVec.y; - rot.z = ZeroSVec.z; - get_player_actor_withoutCheck((GAME_PLAY*)gamePT)->Set_force_position_angle_proc(gamePT, &pos, &rot, mPlayer_FORCE_POSITION_ANGLE_POSX | mPlayer_FORCE_POSITION_ANGLE_POSY | mPlayer_FORCE_POSITION_ANGLE_POSZ | mPlayer_FORCE_POSITION_ANGLE_ROTY); - } - else if(train1->player_pass_leaving == 1){ - pos.x = train1->actor_class.world.position.x + 2.0f; - pos.y = train1->actor_class.world.position.y + 16.0f; - pos.z = train1->actor_class.world.position.z + 20.0f; - get_player_actor_withoutCheck((GAME_PLAY*)gamePT)->Set_force_position_angle_proc(gamePT, &pos, NULL, mPlayer_FORCE_POSITION_ANGLE_POSX | mPlayer_FORCE_POSITION_ANGLE_POSY | mPlayer_FORCE_POSITION_ANGLE_POSZ); - - } -} - - -static void aTR1_setupAction(ACTOR* actor, int action){ - TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; - - static cKF_Animation_R_c* anime_table[] = {&cKF_ba_r_obj_train1_3_open, &cKF_ba_r_obj_train1_3_close}; - static f32 anime_end[] = {24.0f, 32.0f}; - static int animeSeqNoTable[] = {0,0,0,0,0,1,1,0,0}; - static f32 anime_spd[] = {0.0f,0.0f,0.0f,0.0f, 0.5f, 0.0f,0.5f,0.0f,0.0f}; - - cKF_Animation_R_c* anime_pt; - f32 speed; - f32 end; - f32 tr_speed; - int seq_no = animeSeqNoTable[action]; - - anime_pt = anime_table[seq_no]; - speed = anime_spd[action]; - end = anime_end[seq_no]; - - tr_speed = 1.0f; - train1->tr_action = action; - - if((train1->tr_action == 6) || (train1->tr_action == 4)){ - if((mEv_CheckTitleDemo() == 0) && (tr_speed != train1->tr_speed)){ - aTR1_OngenTrgStart(actor, 43); - } - else{ - tr_speed = end; - } - } - cKF_SkeletonInfo_R_init(&train1->keyframe, train1->keyframe.skeleton, anime_pt, - 1.0f, end, tr_speed, speed, 0.0f, 0, NULL ); - aTR1_chg_station_attr(action); -} -#pragma pool_data reset - -static void aTR1_actor_move(ACTOR* actor, GAME* game){ - TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; - TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor->parent_actor; - cKF_SkeletonInfo_R_c* keyframe = &train1->keyframe; - - - train1->anim_state = cKF_SkeletonInfo_R_play(keyframe); - if(mEv_CheckTitleDemo() <= 0){ - aTR1_position_move((ACTOR*)train1); - } - aTR1_passenger_ctrl((ACTOR*)train1); - - if(train0->tr_action != train1->tr_action){ - aTR1_setupAction((ACTOR*)train1, train0->tr_action); - } - - train1->tr_speed = 0.0f; -} - -static void aTR1_actor_draw(ACTOR* actor, GAME* game){ - u16* pal = (*Common_Get(clip).structure_clip->get_pal_segment_proc)(0x3A); - - TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; - - GRAPH* graph = game->graph; - cKF_SkeletonInfo_R_c* keyf; - Mtx* mtx; - Gfx* gfx; - - keyf = &train1->keyframe; - mtx = GRAPH_ALLOC_TYPE(graph, Mtx, keyf->skeleton->num_shown_joints); - - if(mtx != NULL){ - _texture_z_light_fog_prim_npc(graph); - - OPEN_DISP(graph); - - gfx = NOW_POLY_OPA_DISP; - gSPSegment(gfx++, 0x8, pal); - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); - - cKF_Si3_draw_R_SV(game, keyf, mtx, NULL,NULL,train1); - } -} +#include "../rel/ac_train1_draw.c_inc" diff --git a/rel/ac_train1_draw.c_inc b/rel/ac_train1_draw.c_inc new file mode 100644 index 00000000..8db907e8 --- /dev/null +++ b/rel/ac_train1_draw.c_inc @@ -0,0 +1,26 @@ +static void aTR1_actor_draw(ACTOR* actor, GAME* game){ + u16* pal = (*Common_Get(clip).structure_clip->get_pal_segment_proc)(0x3A); + + TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; + + GRAPH* graph = game->graph; + cKF_SkeletonInfo_R_c* keyf; + Mtx* mtx; + Gfx* gfx; + + keyf = &train1->keyframe; + mtx = GRAPH_ALLOC_TYPE(graph, Mtx, keyf->skeleton->num_shown_joints); + + if(mtx != NULL){ + _texture_z_light_fog_prim_npc(graph); + + OPEN_DISP(graph); + + gfx = NOW_POLY_OPA_DISP; + gSPSegment(gfx++, 0x8, pal); + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); + + cKF_Si3_draw_R_SV(game, keyf, mtx, NULL,NULL,train1); + } +} diff --git a/rel/ac_train1_move.c_inc b/rel/ac_train1_move.c_inc new file mode 100644 index 00000000..7b952699 --- /dev/null +++ b/rel/ac_train1_move.c_inc @@ -0,0 +1,150 @@ +static void aTR1_OngenTrgStart(ACTOR* actor, u16 id){ + TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; + + sAdo_OngenTrgStart(id, &train1->actor_class.world.position); +} + +static f32 calc_speed1(ACTOR* actor0, ACTOR* actor1) { + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor0; + TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor1; + + if (fabsf(actor1->speed) < 0.008f) { + return 0.8f + train0->tr_speed; + } + + if (actor1->speed < train0->tr_speed){ + return train0->tr_speed + (0.5f * - (actor1->speed - train0->tr_speed)); + } + + return train0->tr_speed; +} + +static f32 calc_speed2(ACTOR* actor){ + TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; + int should_stop = fabsf(train1->tr0_pos) < 0.008f; + + return should_stop == FALSE ? train1->tr0_pos : -0.23f; +} + +static void aTR1_position_move(ACTOR* actor){ + TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor->parent_actor; + + f32 diff; + f32 tr_back_calc; + f32 base_x_pos; + + tr_back_calc = train1->actor_class.world.position.x; + base_x_pos = -125.0f + train0->tr1_pos; + tr_back_calc += 0.5f * train1->actor_class.speed; + + diff = tr_back_calc - base_x_pos; + if((diff) <= 0.0f){ + train1->actor_class.speed = calc_speed1(actor->parent_actor, actor); + train1->actor_class.world.position.x = base_x_pos; + } + else if((diff) > 2.0f){ + train1->actor_class.speed = calc_speed2(actor->parent_actor); + train1->actor_class.world.position.x = 2.0f + base_x_pos; + } + else{ + chase_f(&train1->actor_class.speed, 0.0f, 0.0025f); + train1->actor_class.world.position.x = tr_back_calc; + } +} + +static void aTR1_chg_station_attr(int station){ + static xyz_t doorway_pos = { 2180.0f, 0.0f, 820.0f }; + xyz_t soil_pos; + xyz_t unk20_pos; + + if(mEv_CheckFirstIntro() == 0){ + if(station == 5){ + soil_pos = doorway_pos; + mCoBG_SetAttribute(&soil_pos, 7); + } + else if(station == 6){ + unk20_pos = doorway_pos; + mCoBG_SetAttribute(&unk20_pos, 0x20); + } + } +} + +static void aTR1_passenger_ctrl(ACTOR* actor){ + TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; + + GAME_PLAY* play = (GAME_PLAY*)gamePT; + xyz_t pos; + s_xyz rot; + + if(train1->player_pass_exists == 1){ + pos.x = train1->actor_class.world.position.x + 60.0f; + pos.y = train1->actor_class.world.position.y + 20.0f; + pos.z = train1->actor_class.world.position.z + 20.0f; + rot.x = ZeroSVec.x; + rot.y = ZeroSVec.y; + rot.z = ZeroSVec.z; + get_player_actor_withoutCheck((GAME_PLAY*)gamePT)->Set_force_position_angle_proc(gamePT, &pos, &rot, mPlayer_FORCE_POSITION_ANGLE_POSX | mPlayer_FORCE_POSITION_ANGLE_POSY | mPlayer_FORCE_POSITION_ANGLE_POSZ | mPlayer_FORCE_POSITION_ANGLE_ROTY); + } + else if(train1->player_pass_leaving == 1){ + pos.x = train1->actor_class.world.position.x + 2.0f; + pos.y = train1->actor_class.world.position.y + 16.0f; + pos.z = train1->actor_class.world.position.z + 20.0f; + get_player_actor_withoutCheck((GAME_PLAY*)gamePT)->Set_force_position_angle_proc(gamePT, &pos, NULL, mPlayer_FORCE_POSITION_ANGLE_POSX | mPlayer_FORCE_POSITION_ANGLE_POSY | mPlayer_FORCE_POSITION_ANGLE_POSZ); + + } +} + + +static void aTR1_setupAction(ACTOR* actor, int action){ + TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; + + static cKF_Animation_R_c* anime_table[] = {&cKF_ba_r_obj_train1_3_open, &cKF_ba_r_obj_train1_3_close}; + static f32 anime_end[] = {24.0f, 32.0f}; + static int animeSeqNoTable[] = {0,0,0,0,0,1,1,0,0}; + static f32 anime_spd[] = {0.0f,0.0f,0.0f,0.0f, 0.5f, 0.0f,0.5f,0.0f,0.0f}; + + cKF_Animation_R_c* anime_pt; + f32 speed; + f32 end; + f32 tr_speed; + int seq_no = animeSeqNoTable[action]; + + anime_pt = anime_table[seq_no]; + speed = anime_spd[action]; + end = anime_end[seq_no]; + + tr_speed = 1.0f; + train1->tr_action = action; + + if((train1->tr_action == 6) || (train1->tr_action == 4)){ + if((mEv_CheckTitleDemo() == 0) && (tr_speed != train1->tr_speed)){ + aTR1_OngenTrgStart(actor, 43); + } + else{ + tr_speed = end; + } + } + cKF_SkeletonInfo_R_init(&train1->keyframe, train1->keyframe.skeleton, anime_pt, + 1.0f, end, tr_speed, speed, 0.0f, 0, NULL ); + aTR1_chg_station_attr(action); +} + +static void aTR1_actor_move(ACTOR* actor, GAME* game){ + TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor->parent_actor; + cKF_SkeletonInfo_R_c* keyframe = &train1->keyframe; + + + train1->anim_state = cKF_SkeletonInfo_R_play(keyframe); + if(mEv_CheckTitleDemo() <= 0){ + aTR1_position_move((ACTOR*)train1); + } + aTR1_passenger_ctrl((ACTOR*)train1); + + if(train0->tr_action != train1->tr_action){ + aTR1_setupAction((ACTOR*)train1, train0->tr_action); + } + + train1->tr_speed = 0.0f; +} diff --git a/rel/irqmgr.c b/rel/irqmgr.c index 200cc361..a88d2ff5 100644 --- a/rel/irqmgr.c +++ b/rel/irqmgr.c @@ -89,7 +89,6 @@ static void irqmgr_HandlePreNMI() { osSetTimer(&this->timer, MSEC(400), 0, &this->_msgQueue, (OSMessage)IRQ_PRENMI450_MSG); irqmgr_JamMesgForClient(&this->msgPreNMI); } -#pragma pool_data reset /** * @brief Handler for pre-NMI message (post 400ms). @@ -132,7 +131,6 @@ static void irqmgr_HandleRetrace() { RetraceCount++; irqmgr_SendMesgForClient(&this->msgRetrace); } -#pragma pool_data reset /** * @brief Main IRQ manager handler. @@ -223,4 +221,3 @@ extern void osViSetEvent(OSMessageQueue* mesgq, OSMessage msg, u32 retcount) { vc_msg = msg; vc_retraceCount = retcount; } -#pragma pool_data reset diff --git a/rel/m_all_grow.c b/rel/m_all_grow.c index ef007cd1..04dc4fcb 100644 --- a/rel/m_all_grow.c +++ b/rel/m_all_grow.c @@ -38,7 +38,6 @@ static void mAGrw_ClearDebugData() { bzero(l_fossil_block, mAGrw_FOSSIL_NUM * sizeof(mAGrw_block_c)); bzero(l_haniwa_block, mAGrw_HANIWA_NUM * sizeof(mAGrw_block_c)); } -#pragma pool_data reset static int mAGrw_CheckRegistedData_debug(mAGrw_block_c* block_info, int num, int block_x, int block_z) { int res = FALSE; @@ -95,7 +94,6 @@ static void mAGrw_SetDebugDataBlock(mActor_name_t* fg_items, u16* deposit, mAGrw } } - static void mAGrw_SetDebugData() { mFM_fg_c* fg_items = Save_Get(fg[0]); u16* deposit = Save_Get(deposit[0]); @@ -112,8 +110,6 @@ static void mAGrw_SetDebugData() { } } } -#pragma pool_data reset - extern void mAGrw_PrintFossilHaniwa_debug(gfxprint_t* gfxprint) { gfxprint_color(gfxprint, 240, 50, 50, 255); @@ -139,7 +135,6 @@ extern void mAGrw_PrintFossilHaniwa_debug(gfxprint_t* gfxprint) { l_haniwa_block[2].block_x, l_haniwa_block[2].block_z ); } -#pragma pool_data reset extern int mAGrw_CheckKabuPeddler() { lbRTC_time_c peddler_spawn_time; diff --git a/rel/m_handbill.c b/rel/m_handbill.c index d13215ce..2d7a3950 100644 --- a/rel/m_handbill.c +++ b/rel/m_handbill.c @@ -33,7 +33,6 @@ extern void mHandbill_aram_init() { mHandbillz_aram_init(); } -#pragma pool_data reset static mHandbill_Data_c mHandbill_data; diff --git a/rel/m_home.c b/rel/m_home.c index e7091365..047af196 100644 --- a/rel/m_home.c +++ b/rel/m_home.c @@ -196,7 +196,6 @@ extern void mHm_ClearHomeInfo(int home_no) { Save_Set(keep_house_size[no], 0); Save_Set(homes[no].door_original, 0xFF); } -#pragma pool_data reset /** * @brief Clears save data for all homes.