From ce4f8c6e1234e28b41162c723a65b8980f5a6c1d Mon Sep 17 00:00:00 2001 From: Cuyler36 Date: Sun, 15 Jun 2025 21:25:05 -0400 Subject: [PATCH] Implement & link ac_tokyoso_npc1 --- configure.py | 2 +- include/ac_tokyoso_control.h | 44 ++- include/ac_tokyoso_npc1.h | 20 +- include/audio_defs.h | 1 + src/actor/ac_tokyoso_clip.c_inc | 16 +- src/actor/ac_tokyoso_control.c | 26 +- src/actor/npc/ac_tokyoso_npc1.c | 168 ++++++++ src/actor/npc/ac_tokyoso_npc1_schedule.c_inc | 391 +++++++++++++++++++ src/actor/npc/ac_tokyoso_npc1_talk.c_inc | 75 ++++ 9 files changed, 702 insertions(+), 41 deletions(-) create mode 100644 src/actor/npc/ac_tokyoso_npc1.c create mode 100644 src/actor/npc/ac_tokyoso_npc1_schedule.c_inc create mode 100644 src/actor/npc/ac_tokyoso_npc1_talk.c_inc diff --git a/configure.py b/configure.py index 141930ab..6569014e 100644 --- a/configure.py +++ b/configure.py @@ -1150,7 +1150,7 @@ config.libs = [ Object(Matching, "actor/npc/ac_tamaire_npc0.c"), Object(Matching, "actor/npc/ac_tamaire_npc1.c"), Object(NonMatching, "actor/npc/ac_tokyoso_npc0.c"), - Object(NonMatching, "actor/npc/ac_tokyoso_npc1.c"), + Object(Matching, "actor/npc/ac_tokyoso_npc1.c"), Object(Matching, "actor/npc/ac_tukimi_npc0.c"), Object(Matching, "actor/npc/ac_tukimi_npc1.c"), Object(NonMatching, "actor/npc/ac_tunahiki_npc0.c"), diff --git a/include/ac_tokyoso_control.h b/include/ac_tokyoso_control.h index 6f01e6ef..d233fa5e 100644 --- a/include/ac_tokyoso_control.h +++ b/include/ac_tokyoso_control.h @@ -14,19 +14,43 @@ extern "C" { #define aTKC_ANGLE_FOR_LAP_COMPLETION 4000 // approximately 22 degrees -#define aTKC_FLAG_5 (1 << 5) -#define aTKC_FLAG_6 (1 << 6) -#define aTKC_FLAG_7 (1 << 7) -#define aTKC_FLAG_8 (1 << 8) -#define aTKC_FLAG_9 (1 << 9) +#define aTKC_FLAG_DELETE_NPC0 (1 << 0) +#define aTKC_FLAG_DELETE_NPC1 (1 << 1) +#define aTKC_FLAG_DELETE_NPC2 (1 << 2) +#define aTKC_FLAG_DELETE_NPC3 (1 << 3) +#define aTKC_FLAG_DELETE_NPC4 (1 << 4) +#define aTKC_FLAG_STRETCH_TEAM0 (1 << 5) +#define aTKC_FLAG_STRETCH_TEAM1 (1 << 6) +#define aTKC_FLAG_READY_TEAM0 (1 << 7) +#define aTKC_FLAG_READY_TEAM1 (1 << 8) +#define aTKC_FLAG_READY_SHOOTER (1 << 9) #define aTKC_FLAG_RACE_ACTIVE (1 << 10) -#define aTKC_FLAG_11 (1 << 11) -#define aTKC_FLAG_12 (1 << 12) -#define aTKC_FLAG_13 (1 << 13) -#define aTKC_FLAG_14 (1 << 14) +#define aTKC_FLAG_KANSEN_TEAM0 (1 << 11) +#define aTKC_FLAG_KANSEN_TEAM1 (1 << 12) +#define aTKC_FLAG_GOAL_TEAM0 (1 << 13) +#define aTKC_FLAG_GOAL_TEAM1 (1 << 14) #define aTKC_FLAG_15 (1 << 15) -#define aTKC_MASK_13_14 (aTKC_FLAG_13 | aTKC_FLAG_14) +#define aTKC_STRETCH_ALL (aTKC_FLAG_STRETCH_TEAM0 | aTKC_FLAG_STRETCH_TEAM1) +#define aTKC_STRETCH_MASK aTKC_STRETCH_ALL + +#define aTKC_READY_ALL (aTKC_FLAG_READY_TEAM0 | aTKC_FLAG_READY_TEAM1 | aTKC_FLAG_READY_SHOOTER) +#define aTKC_READY_MASK aTKC_READY_ALL + +#define aTKC_KANSEN_ALL (aTKC_FLAG_KANSEN_TEAM0 | aTKC_FLAG_KANSEN_TEAM1) +#define aTKC_KANSEN_MASK aTKC_KANSEN_ALL + +#define aTKC_GOAL_ALL (aTKC_FLAG_GOAL_TEAM0 | aTKC_FLAG_GOAL_TEAM1) +#define aTKC_GOAL_MASK aTKC_GOAL_ALL + +#define aTKC_NPCID2IDX(id) ((id - SP_NPC_EV_TOKYOSO_0)) +#define aTKC_NPCID2TEAM(id) (aTKC_NPCID2IDX(id) & 1) // 0 = team 0, 1 = team 1 +#define aTKC_NPCID2ROLE(id) (aTKC_NPCID2IDX(id) & 2) // 0 = runner, 2 = spectator +#define aTKC_NPCIDX2DELETEFLG(n) (aTKC_FLAG_DELETE_NPC0 << aTKC_NPCID2IDX(n)) +#define aTKC_NPCIDX2STRETCHFLG(n) (aTKC_FLAG_STRETCH_TEAM0 << aTKC_NPCID2TEAM(n)) +#define aTKC_NPCIDX2READYLFG(n) (aTKC_FLAG_READY_TEAM0 << aTKC_NPCID2TEAM(n)) +#define aTKC_NPCIDX2KANSENFLG(n) (aTKC_FLAG_KANSEN_TEAM0 << aTKC_NPCID2TEAM(n)) +#define aTKC_NPCIDX2GOALFLG(n) (aTKC_FLAG_GOAL_TEAM0 << aTKC_NPCID2TEAM(n)) enum { aTKC_GOAL_NONE, diff --git a/include/ac_tokyoso_npc1.h b/include/ac_tokyoso_npc1.h index ab5705ae..5c897f10 100644 --- a/include/ac_tokyoso_npc1.h +++ b/include/ac_tokyoso_npc1.h @@ -12,20 +12,22 @@ extern "C" { typedef struct tokyoso_npc1_actor_s TOKYOSO_NPC1_ACTOR; -// TODO: finish this +typedef void (*aTKN1_THINK_PROC)(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play); + struct tokyoso_npc1_actor_s { NPC_ACTOR npc_class; - void* think_proc; - int msg_start_no; + aTKN1_THINK_PROC think_proc; + int base_msg; f32 speed; - s16 _9A0; - s16 start_pos[2]; s16 timer; - u8 _9A8; - u8 _9A9; - u8 _9AA; + s16 start_pos[2]; + s16 run_timer; + u8 think_idx; + u8 next_think_idx; + u8 move_think_idx; u8 talk_idx; - u8 _9AC; + u8 change_flag; + u8 flags; }; extern ACTOR_PROFILE Tokyoso_Npc1_Profile; diff --git a/include/audio_defs.h b/include/audio_defs.h index 09e1a9c0..544af565 100644 --- a/include/audio_defs.h +++ b/include/audio_defs.h @@ -211,6 +211,7 @@ typedef enum audio_sound_effects { NA_SE_TUMBLE_WAVE, NA_SE_ARAIIKI_BOY = 0x158, + NA_SE_ARAIIKI_OTHER = 0x159, NA_SE_ARAIIKI_GIRL = 0x15A, NA_SE_AMI_HIT_WATER = 0x15C, diff --git a/src/actor/ac_tokyoso_clip.c_inc b/src/actor/ac_tokyoso_clip.c_inc index ca739132..a42a7185 100644 --- a/src/actor/ac_tokyoso_clip.c_inc +++ b/src/actor/ac_tokyoso_clip.c_inc @@ -69,8 +69,8 @@ static void aTKN1_warmup_init(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play) { aEv_tokyoso_c* tokyoso = (aEv_tokyoso_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_FOOT_RACE, 8); NPC_CLIP->animation_init_proc((ACTOR*)actor, aNPC_ANIM_WARMUP1, FALSE); - tokyoso->flags &= ~(aTKC_FLAG_5 << ((actor->npc_class.actor_class.npc_id - SP_NPC_EV_TOKYOSO_0) & 1)); - actor->_9A0 = 240; + tokyoso->flags &= ~aTKC_NPCIDX2STRETCHFLG(actor->npc_class.actor_class.npc_id); + actor->timer = 240; } static void aTKN1_ready_init(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play) { @@ -148,7 +148,7 @@ static void aTKN1_lookl_init(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play) { aEv_tokyoso_c* tokyoso = (aEv_tokyoso_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_FOOT_RACE, 8); aTKN1_turn_l_init(actor, play); - tokyoso->flags &= ~(aTKC_FLAG_11 << ((actorx->npc_id - SP_NPC_EV_TOKYOSO_0) & 1)); + tokyoso->flags &= ~aTKC_NPCIDX2KANSENFLG(actorx->npc_id); } typedef void (*aTKN1_THINK_INIT_PROC)(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play); @@ -207,7 +207,7 @@ static void aTKC_clip_next_run(ACTOR* actorx) { actor->start_pos[1] = (tokyoso->yasiro_pos[1] - 130.0f) + idx * 60.0f + (RANDOM_F(10.0f) - 5.0f); } - actor->timer = 300; + actor->run_timer = 300; } static s16 aTKC_clip_get_angle(ACTOR* actorx) { @@ -237,9 +237,9 @@ static s16 aTKC_clip_run_check(ACTOR* actorx) { aEv_tokyoso_c* tokyoso = (aEv_tokyoso_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_FOOT_RACE, 8); TOKYOSO_NPC1_ACTOR* actor = (TOKYOSO_NPC1_ACTOR*)actorx; - if (actor->timer > 0) { - actor->timer--; - if (actor->timer == 0) { + if (actor->run_timer > 0) { + actor->run_timer--; + if (actor->run_timer == 0) { return TRUE; } } @@ -342,7 +342,7 @@ static void aTKC_clip_set_talk_request(ACTOR* actorx) { TOKYOSO_NPC1_ACTOR* actor = (TOKYOSO_NPC1_ACTOR*)actorx; aTCK_npc1_talk_data_c* data_p = &dt_tbl[actor->talk_idx]; - mDemo_Set_msg_num(actor->msg_start_no + data_p->msg_no + RANDOM(2)); + mDemo_Set_msg_num(actor->base_msg + data_p->msg_no + RANDOM(2)); mDemo_Set_talk_turn(data_p->turn_flag); mDemo_Set_camera(data_p->camera_type); } diff --git a/src/actor/ac_tokyoso_control.c b/src/actor/ac_tokyoso_control.c index 926c5922..849309d7 100644 --- a/src/actor/ac_tokyoso_control.c +++ b/src/actor/ac_tokyoso_control.c @@ -99,7 +99,7 @@ static void aTKC_actor_move(ACTOR* actorx, GAME* game) { static void aTKC_irekae_2(TOKYOSO_CONTROL_ACTOR* actor, GAME_PLAY* play) { aEv_tokyoso_c* tokyoso = (aEv_tokyoso_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_FOOT_RACE, 8); - if ((tokyoso->flags & aTKC_FLAG_11) == 0) { + if ((tokyoso->flags & aTKC_FLAG_KANSEN_TEAM0) == 0) { aTKC_setupAction(actor, aTKC_ACT_STRECH); actor->timer = 600; } @@ -108,25 +108,25 @@ static void aTKC_irekae_2(TOKYOSO_CONTROL_ACTOR* actor, GAME_PLAY* play) { static void aTKC_irekae_1(TOKYOSO_CONTROL_ACTOR* actor, GAME_PLAY* play) { aEv_tokyoso_c* tokyoso = (aEv_tokyoso_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_FOOT_RACE, 8); - if ((tokyoso->flags & aTKC_FLAG_12) == 0) { + if ((tokyoso->flags & aTKC_FLAG_KANSEN_TEAM1) == 0) { aTKC_setupAction(actor, aTKC_ACT_IREKAE_2); - tokyoso->flags |= aTKC_FLAG_5; - tokyoso->flags |= aTKC_FLAG_11; + tokyoso->flags |= aTKC_FLAG_STRETCH_TEAM0; + tokyoso->flags |= aTKC_FLAG_KANSEN_TEAM0; } } static void aTKC_goal(TOKYOSO_CONTROL_ACTOR* actor, GAME_PLAY* play) { aEv_tokyoso_c* tokyoso = (aEv_tokyoso_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_FOOT_RACE, 8); - if ((tokyoso->flags & aTKC_MASK_13_14) == aTKC_MASK_13_14) { + if ((tokyoso->flags & aTKC_GOAL_MASK) == aTKC_GOAL_ALL) { if (actor->timer > 0) { actor->timer--; } else { aTKC_setupAction(actor, aTKC_ACT_IREKAE_1); - tokyoso->flags |= aTKC_FLAG_6; - tokyoso->flags |= aTKC_FLAG_12; + tokyoso->flags |= aTKC_FLAG_STRETCH_TEAM1; + tokyoso->flags |= aTKC_FLAG_KANSEN_TEAM1; tokyoso->flags &= ~aTKC_FLAG_RACE_ACTIVE; - tokyoso->flags &= ~aTKC_MASK_13_14; + tokyoso->flags &= ~aTKC_GOAL_MASK; } } } @@ -161,7 +161,7 @@ static void aTKC_go(TOKYOSO_CONTROL_ACTOR* actor, GAME_PLAY* play) { static void aTKC_set(TOKYOSO_CONTROL_ACTOR* actor, GAME_PLAY* play) { aEv_tokyoso_c* tokyoso = (aEv_tokyoso_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_FOOT_RACE, 8); - if ((tokyoso->flags & (aTKC_FLAG_7 | aTKC_FLAG_8 | aTKC_FLAG_9)) == 0) { + if ((tokyoso->flags & aTKC_READY_ALL) == 0) { aTKC_setupAction(actor, aTKC_ACT_GO); // @BUG - this is called twice tokyoso->flags |= aTKC_FLAG_RACE_ACTIVE; tokyoso->lap[0] = tokyoso->lap[1] = 0; @@ -173,12 +173,12 @@ static void aTKC_set(TOKYOSO_CONTROL_ACTOR* actor, GAME_PLAY* play) { static void aTKC_ready(TOKYOSO_CONTROL_ACTOR* actor, GAME_PLAY* play) { aEv_tokyoso_c* tokyoso = (aEv_tokyoso_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_FOOT_RACE, 8); - if ((tokyoso->flags & (aTKC_FLAG_7 | aTKC_FLAG_8 | aTKC_FLAG_9)) == 0) { + if ((tokyoso->flags & aTKC_READY_ALL) == 0) { if (actor->timer > 0) { actor->timer--; } else { aTKC_setupAction(actor, aTKC_ACT_SET); - tokyoso->flags |= (aTKC_FLAG_7 | aTKC_FLAG_8 | aTKC_FLAG_9); + tokyoso->flags |= aTKC_READY_ALL; } } } @@ -186,13 +186,13 @@ static void aTKC_ready(TOKYOSO_CONTROL_ACTOR* actor, GAME_PLAY* play) { static void aTKC_strech(TOKYOSO_CONTROL_ACTOR* actor, GAME_PLAY* play) { aEv_tokyoso_c* tokyoso = (aEv_tokyoso_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_FOOT_RACE, 8); - if ((tokyoso->flags & (aTKC_FLAG_5 | aTKC_FLAG_6)) == 0) { + if ((tokyoso->flags & aTKC_STRETCH_MASK) == 0) { if (actor->timer > 0) { actor->timer--; } else { actor->timer = 120; aTKC_setupAction(actor, aTKC_ACT_READY); - tokyoso->flags |= (aTKC_FLAG_7 | aTKC_FLAG_8 | aTKC_FLAG_9); + tokyoso->flags |= aTKC_READY_ALL; } } } diff --git a/src/actor/npc/ac_tokyoso_npc1.c b/src/actor/npc/ac_tokyoso_npc1.c new file mode 100644 index 00000000..36cf43c9 --- /dev/null +++ b/src/actor/npc/ac_tokyoso_npc1.c @@ -0,0 +1,168 @@ +#include "ac_tokyoso_npc1.h" + +#include "ac_tokyoso_control.h" +#include "m_common_data.h" +#include "m_player_lib.h" +#include "m_font.h" +#include "m_msg.h" +#include "m_soncho.h" +#include "libultra/libultra.h" + +// TODO: coordinate enum types with ac_tokyoso_control + +// enum { +// aTKN1_THINK_BIRTH, +// aTKN1_THINK_KYORO_MAE, +// aTKN1_THINK_KYORO, +// aTKN1_THINK_WALK_TURN, +// aTKN1_THINK_WALK, +// aTKN1_THINK_HIROU_MAE, +// aTKN1_THINK_HIROU, +// aTKN1_THINK_HIROU_SP, +// aTKN1_THINK_HIROU_END, +// aTKN1_THINK_NAGERU, +// aTKN1_THINK_NAGERU_END, + +// aTKN1_THINK_NUM +// }; + +// enum { +// aTKN1_THINK_PROC_NONE, +// aTKN1_THINK_PROC_TIMER_NEXT, +// aTKN1_THINK_PROC_BIRTH, +// aTKN1_THINK_PROC_TURN_NEXT, +// aTKN1_THINK_PROC_WALK, +// aTKN1_THINK_PROC_HIROU, +// aTKN1_THINK_PROC_HIROU_SP, +// aTKN1_THINK_PROC_ANIME_NEXT, +// aTKN1_THINK_PROC_NAGERU, +// aTKN1_THINK_PROC_NAGERU_END, + +// aTKN1_THINK_PROC_NUM +// }; + +// enum { +// aTKN1_THINK_INIT_PROC_NONE, +// aTKN1_THINK_INIT_PROC_NORMAL_WAIT, +// aTKN1_THINK_INIT_PROC_MOVE, +// aTKN1_THINK_INIT_PROC_KYORO_MAE, +// aTKN1_THINK_INIT_PROC_KYORO, +// aTKN1_THINK_INIT_PROC_WALK_TURN, +// aTKN1_THINK_INIT_PROC_HIROU_MAE, +// aTKN1_THINK_INIT_PROC_HIROU, +// aTKN1_THINK_INIT_PROC_HIROU_SP, +// aTKN1_THINK_INIT_PROC_HIROU_END, +// aTKN1_THINK_INIT_PROC_NAGERU, +// aTKN1_THINK_INIT_PROC_NAGERU_END, + +// aTKN1_THINK_INIT_PROC_NUM +// }; + +static void aTKN1_actor_ct(ACTOR* actorx, GAME* game); +static void aTKN1_actor_dt(ACTOR* actorx, GAME* game); +static void aTKN1_actor_move(ACTOR* actorx, GAME* game); +static void aTKN1_actor_draw(ACTOR* actorx, GAME* game); +static void aTKN1_actor_save(ACTOR* actorx, GAME* game); +static void aTKN1_actor_init(ACTOR* actorx, GAME* game); + +// clang-format off +ACTOR_PROFILE Tokyoso_Npc1_Profile = { + mAc_PROFILE_TOKYOSO_NPC1, + ACTOR_PART_NPC, + ACTOR_STATE_NONE, + SP_NPC_EV_TOKYOSO_1, + ACTOR_OBJ_BANK_KEEP, + sizeof(TOKYOSO_NPC1_ACTOR), + aTKN1_actor_ct, + aTKN1_actor_dt, + aTKN1_actor_init, + mActor_NONE_PROC1, + aTKN1_actor_save, +}; +// clang-format on + +static void aTKN1_talk_request(ACTOR* actorx, GAME* game); +static int aTKN1_talk_init(ACTOR* actorx, GAME* game); +static int aTKN1_talk_end_chk(ACTOR* actorx, GAME* game); + +static void aTKN1_schedule_proc(NPC_ACTOR* nactorx, GAME_PLAY* play, int type); +static void aTKN1_setup_think_proc(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play, u8 think_idx); + +static void aTKN1_actor_ct(ACTOR* actorx, GAME* game) { + static aNPC_ct_data_c ct_data = { + aTKN1_actor_move, + aTKN1_actor_draw, + aNPC_CT_SCHED_TYPE_SPECIAL, + (aNPC_TALK_REQUEST_PROC)none_proc1, + aTKN1_talk_init, + aTKN1_talk_end_chk, + 0, + }; + TOKYOSO_NPC1_ACTOR* actor = (TOKYOSO_NPC1_ACTOR*)actorx; + + if (NPC_CLIP->birth_check_proc(actorx, game) == TRUE) { + static int base_msg_table[] = { 0x19DD, 0x19ED, 0x19CD, 0x19FD, 0x1A0D, 0x1A1D }; + + actor->npc_class.schedule.schedule_proc = aTKN1_schedule_proc; + NPC_CLIP->ct_proc(actorx, game, &ct_data); + + actor->npc_class.palActorIgnoreTimer = -1; + actor->base_msg = base_msg_table[mNpc_GetNpcLooks(actorx)]; + actor->change_flag = FALSE; + actor->flags = 0; + actor->npc_class.head.lock_flag = TRUE; + } +} + +static void aTKN1_actor_save(ACTOR* actorx, GAME* game) { + mNpc_RenewalSetNpc(actorx); +} + +static void aTKN1_actor_dt(ACTOR* actorx, GAME* game) { + NPC_CLIP->dt_proc(actorx, game); +} + +static void aTKN1_actor_init(ACTOR* actorx, GAME* game) { + NPC_CLIP->init_proc(actorx, game); +} + +static int aTKN1_set_request_act(TOKYOSO_NPC1_ACTOR* actor, u8 prio, u8 idx, u8 type, u16 obj, s16 move_x, s16 move_z) { + int res = FALSE; + + if (prio >= actor->npc_class.request.act_priority) { + u16 args[6]; + + bzero(args, sizeof(args)); + args[0] = obj; + args[2] = move_x; + args[3] = move_z; + actor->npc_class.request.act_priority = prio; + actor->npc_class.request.act_idx = idx; + actor->npc_class.request.act_type = type; + mem_copy((u8*)actor->npc_class.request.act_args, (u8*)args, sizeof(args)); + res = TRUE; + } + + return res; +} + +static void aTKN1_actor_move(ACTOR* actorx, GAME* game) { + aEv_tokyoso_c* tokyoso = (aEv_tokyoso_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_FOOT_RACE, 8); + + NPC_CLIP->move_proc(actorx, game); + if (tokyoso != NULL) { + if (tokyoso->_00 == 3) { + if ((tokyoso->flags & aTKC_NPCIDX2DELETEFLG(actorx->npc_id)) == 0) { + tokyoso->flags |= aTKC_NPCIDX2DELETEFLG(actorx->npc_id); + Actor_delete(actorx); + } + } + } +} + +#include "../src/actor/npc/ac_tokyoso_npc1_talk.c_inc" +#include "../src/actor/npc/ac_tokyoso_npc1_schedule.c_inc" + +static void aTKN1_actor_draw(ACTOR* actorx, GAME* game) { + NPC_CLIP->draw_proc(actorx, game); +} diff --git a/src/actor/npc/ac_tokyoso_npc1_schedule.c_inc b/src/actor/npc/ac_tokyoso_npc1_schedule.c_inc new file mode 100644 index 00000000..63daf5ee --- /dev/null +++ b/src/actor/npc/ac_tokyoso_npc1_schedule.c_inc @@ -0,0 +1,391 @@ +static void aTKN1_local_to_goal(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play, s16 goal) { + aEv_tokyoso_c* tokyoso = (aEv_tokyoso_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_FOOT_RACE, 8); + + actor->npc_class.actor_class.speed = 0.0f; + aTKN1_setup_think_proc(actor, play, 13 + goal); + actor->flags &= ~0x1; + tokyoso->flags |= aTKC_NPCIDX2GOALFLG(actor->npc_class.actor_class.npc_id); +} + +static int aTKN1_local_redy_check(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play) { + aEv_tokyoso_c* tokyoso = (aEv_tokyoso_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_FOOT_RACE, 8); + + if (tokyoso->flags & aTKC_NPCIDX2READYLFG(actor->npc_class.actor_class.npc_id)) { + actor->move_think_idx = 8; + CLIP(tokyoso_clip)->next_pos_proc((ACTOR*)actor, aTKC_NPCID2TEAM(actor->npc_class.actor_class.npc_id)); + aTKN1_setup_think_proc(actor, play, 1); + tokyoso->flags &= ~aTKC_NPCIDX2READYLFG(actor->npc_class.actor_class.npc_id); + tokyoso->_01 &= ~(u8)(1 << (aTKC_NPCID2IDX(actor->npc_class.actor_class.npc_id) & 3)); + return TRUE; + } + + return FALSE; +} + +static void aTKN1_birth(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play) { + aEv_tokyoso_c* tokyoso = (aEv_tokyoso_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_FOOT_RACE, 8); + + if (tokyoso != NULL && tokyoso->_00 == 2) { + actor->npc_class.actor_class.state_bitfield |= ACTOR_STATE_NO_MOVE_WHILE_CULLED; + + if (aTKC_NPCID2ROLE(actor->npc_class.actor_class.npc_id - 1) == 0) { + aTKN1_setup_think_proc(actor, play, 6); + } else { + aTKN1_setup_think_proc(actor, play, 18); + } + } +} + +static void aTKN1_warmup(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play) { + if (!aTKN1_local_redy_check(actor, play)) { + if (actor->timer > 0) { + actor->timer--; + } else { + actor->move_think_idx = 7; + actor->timer = (1.0f + RANDOM_F(1.0f)) * 60.0f; + CLIP(tokyoso_clip)->next_warmup_proc((ACTOR*)actor); + aTKN1_setup_think_proc(actor, play, 3); + } + } +} + +static void aTKN1_warmup3(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play) { + if (!aTKN1_local_redy_check(actor, play)) { + if (actor->timer > 0) { + actor->timer--; + } else { + actor->move_think_idx = 5; + CLIP(tokyoso_clip)->next_warmup_proc((ACTOR*)actor); + aTKN1_setup_think_proc(actor, play, 3); + } + } +} + +static void aTKN1_turn_next(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play) { + if (actor->npc_class.action.idx == aNPC_ACT_TURN) { + aTKN1_setup_think_proc(actor, play, (u8)++actor->think_idx); + } +} + +static void aTKN1_ready(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play) { + aEv_tokyoso_c* tokyoso = (aEv_tokyoso_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_FOOT_RACE, 8); + + if ((tokyoso->flags & aTKC_NPCIDX2READYLFG(actor->npc_class.actor_class.npc_id)) != 0 && (tokyoso->flags & aTKC_FLAG_READY_SHOOTER) == 0) { + CLIP(tokyoso_clip)->next_run_proc((ACTOR*)actor); + aTKN1_setup_think_proc(actor, play, 11); + tokyoso->flags &= ~aTKC_NPCIDX2READYLFG(actor->npc_class.actor_class.npc_id); + actor->flags |= 0x1; + } +} + +static void aTKN1_run(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play) { + s16 goal; + ACTOR* actorx = (ACTOR*)actor; + + if ((actor->npc_class.action.idx == aNPC_ACT_RUN && actor->npc_class.action.step == aNPC_ACTION_END_STEP) || CLIP(tokyoso_clip)->run_check_proc(actorx)) { + goal = CLIP(tokyoso_clip)->goal_check_proc(actorx); + + if (goal == 0) { + CLIP(tokyoso_clip)->next_run_proc(actorx); + if (CLIP(tokyoso_clip)->top_check_proc(actorx) && RANDOM_F(1.0f) < 0.1f) { + aTKN1_setup_think_proc(actor,play, 12); + } else { + aTKN1_setup_think_proc(actor,play, 11); + } + } else { + aTKN1_local_to_goal(actor, play, goal); + } + } else if ((s16)actor->npc_class.movement.dst_pos_x != actor->start_pos[0] || (s16)actor->npc_class.movement.dst_pos_z != actor->start_pos[1]) { + CLIP(tokyoso_clip)->next_run_proc(actorx); + aTKN1_setup_think_proc(actor, play, 11); + } +} + +static void aTKN1_kokeru(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play) { + ACTOR* actorx = (ACTOR*)actor; + + if (cKF_FrameControl_passCheck_now(&actor->npc_class.draw.main_animation.keyframe.frame_control, 8.0f)) { + eEC_CLIP->effect_make_proc(eEC_EFFECT_TUMBLE, actorx->world.position, 1, actorx->world.angle.y, (GAME*)play, actorx->npc_id, actorx->bg_collision_check.result.unit_attribute, 1); + } + + if (cKF_FrameControl_stop_proc(&actor->npc_class.draw.main_animation.keyframe.frame_control) == TRUE && actorx->speed == 0.0f) { + aTKN1_setup_think_proc(actor, play, 13); + } +} + +static void aTKN1_getup(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play) { + s16 goal; + ACTOR* actorx = (ACTOR*)actor; + + if (cKF_FrameControl_stop_proc(&actor->npc_class.draw.main_animation.keyframe.frame_control) == TRUE) { + goal = CLIP(tokyoso_clip)->goal_check_proc(actorx); + + if (goal == 0) { + aTKN1_setup_think_proc(actor,play, 10); + } else { + aTKN1_local_to_goal(actor, play, goal); + } + } +} + +static void aTKN1_kansen_bf(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play) { + aEv_tokyoso_c* tokyoso = (aEv_tokyoso_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_FOOT_RACE, 8); + + if ((tokyoso->flags & aTKC_FLAG_RACE_ACTIVE) != 0 || (tokyoso->_01 & (u8)(1 << (aTKC_NPCID2IDX(actor->npc_class.actor_class.npc_id) & 3))) != 0) { + aTKN1_setup_think_proc(actor, play, 20); + } +} + +static void aTKN1_kansen(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play) { + int idx = aTKC_NPCID2TEAM(actor->npc_class.actor_class.npc_id); + aEv_tokyoso_c* tokyoso = (aEv_tokyoso_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_FOOT_RACE, 8); + + actor->npc_class.condition_info.demo_flg |= aNPC_COND_DEMO_SKIP_FOOTSTEPS; + if (tokyoso->goal[0] != 0 || tokyoso->goal[1] != 0 || (tokyoso->_01 & (u8)(1 << (aTKC_NPCID2IDX(actor->npc_class.actor_class.npc_id) & 3))) != 0) { + aTKN1_setup_think_proc(actor, play, 21); + actor->npc_class.condition_info.demo_flg &= ~aNPC_COND_DEMO_SKIP_FOOTSTEPS; + } else { + aTKN1_set_request_act(actor, 4, aNPC_ACT_TURN2, aNPC_ACT_TYPE_TO_POINT, aNPC_ACT_OBJ_DEFAULT, tokyoso->pos_0A[idx][0], tokyoso->pos_0A[idx][1]); + } +} + +static void aTKN1_goal1(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play) { + if (actor->npc_class.action.idx == aNPC_ACT_TURN) { + aTKN1_setup_think_proc(actor, play, 17); + } +} + +static void aTKN1_omedeto(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play) { + ACTOR* actorx = (ACTOR*)actor; + aEv_tokyoso_c* tokyoso = (aEv_tokyoso_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_FOOT_RACE, 8); + + if ((tokyoso->flags & aTKC_NPCIDX2STRETCHFLG(actorx->npc_id)) != 0) { + actor->move_think_idx = 5; + CLIP(tokyoso_clip)->next_pos_proc(actorx, aTKC_NPCID2TEAM(actorx->npc_id)); + aTKN1_setup_think_proc(actor, play, 1); + } else if ((tokyoso->flags & aTKC_STRETCH_MASK) != 0) { + aTKN1_setup_think_proc(actor, play, 22); + } + + if (aTKC_NPCID2TEAM(actorx->npc_id) != 0) { + sAdo_OngenPos((u32)actorx, 0x2F, &actorx->world.position); + } else { + sAdo_OngenPos((u32)actorx, 0x31, &actorx->world.position); + } +} + +static void aTKN1_omedeto_af(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play) { + ACTOR* actorx = (ACTOR*)actor; + aEv_tokyoso_c* tokyoso = (aEv_tokyoso_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_FOOT_RACE, 8); + + if ((tokyoso->flags & aTKC_NPCIDX2STRETCHFLG(actorx->npc_id)) != 0) { + actor->move_think_idx = 5; + CLIP(tokyoso_clip)->next_pos_proc(actorx, aTKC_NPCID2TEAM(actorx->npc_id)); + aTKN1_setup_think_proc(actor, play, 1); + } +} + +static void aTKN1_move(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play) { + if (actor->npc_class.action.idx == aNPC_ACT_WALK) { + aTKN1_setup_think_proc(actor, play, actor->move_think_idx); + } else if ((s16)actor->npc_class.movement.dst_pos_x != actor->start_pos[0] || (s16)actor->npc_class.movement.dst_pos_z != actor->start_pos[1]) { + aTKN1_setup_think_proc(actor, play, 1); + } +} + +static void aTKN1_move_wm(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play) { + if (!aTKN1_local_redy_check(actor, play)) { + if (actor->npc_class.action.idx == aNPC_ACT_WALK) { + aTKN1_setup_think_proc(actor, play, actor->move_think_idx); + } else if ((s16)actor->npc_class.movement.dst_pos_x != actor->start_pos[0] || (s16)actor->npc_class.movement.dst_pos_z != actor->start_pos[1]) { + aTKN1_setup_think_proc(actor, play, actor->move_think_idx); + } + } +} + +static void aTKN1_goal_af(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play) { + ACTOR* actorx = (ACTOR*)actor; + aEv_tokyoso_c* tokyoso = (aEv_tokyoso_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_FOOT_RACE, 8); + + if ((tokyoso->flags & aTKC_NPCIDX2KANSENFLG(actorx->npc_id)) != 0) { + actor->move_think_idx = 18; + CLIP(tokyoso_clip)->next_pos_proc(actorx, 2 + aTKC_NPCID2TEAM(actorx->npc_id)); + aTKN1_setup_think_proc(actor, play, 1); + } + + if (actor->think_idx == 16 && cKF_FrameControl_passCheck_now(&actor->npc_class.draw.main_animation.keyframe.frame_control, 9.0f)) { + switch (mNpc_GetNpcSoundSpec(actorx)) { + case 3: + sAdo_OngenTrgStart(NA_SE_ARAIIKI_OTHER, &actorx->world.position); + break; + case 4: + sAdo_OngenTrgStart(NA_SE_ARAIIKI_GIRL, &actorx->world.position); + break; + default: + sAdo_OngenTrgStart(NA_SE_ARAIIKI_BOY, &actorx->world.position); + break; + + } + } +} + +static void aTKN1_think_main_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) { + TOKYOSO_NPC1_ACTOR* actor = (TOKYOSO_NPC1_ACTOR*)nactorx; + ACTOR* actorx = (ACTOR*)nactorx; + + if (mDemo_Check(mDemo_TYPE_TALK, actorx) == TRUE) { + return; + } + + if (actor->npc_class.action.step == aNPC_ACTION_END_STEP) { + actor->npc_class.condition_info.demo_flg |= aNPC_COND_DEMO_SKIP_MOVE_CIRCLE_REV | aNPC_COND_DEMO_SKIP_MOVE_RANGE_CHECK; + } + + if (actor->think_idx == 11) { + actor->npc_class.movement.speed.max_speed = actor->speed; + actor->think_proc(actor, play); + } else if (actor->npc_class.action.step == aNPC_ACTION_END_STEP) { + actor->think_proc(actor, play); + } else if (actor->think_idx == 12 || actor->think_idx == 13) { + actor->think_proc(actor, play); + } + + if (actor->think_idx == 11) { + if (RANDOM_F(1.0f) < 0.1f) { + eEC_CLIP->effect_make_proc(eEC_EFFECT_DASH_ASIMOTO, actorx->world.position, 1, actorx->shape_info.rotation.y, (GAME*)play, actorx->npc_id, actorx->bg_collision_check.result.unit_attribute, 0); + } + } + + if ((actor->flags & 0x1) != 0 && CLIP(tokyoso_clip) != NULL) { + CLIP(tokyoso_clip)->run_proc(actorx); + } +} + +static void aTKN1_think_init_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) { + TOKYOSO_NPC1_ACTOR* actor = (TOKYOSO_NPC1_ACTOR*)nactorx; + + nactorx->actor_class.status_data.weight = MASSTYPE_HEAVY; + nactorx->condition_info.hide_request = FALSE; + aTKN1_setup_think_proc(actor, play, 0); + nactorx->think.interrupt_flags = 0; + nactorx->condition_info.demo_flg = aNPC_COND_DEMO_SKIP_MOVE_CIRCLE_REV | aNPC_COND_DEMO_SKIP_MOVE_RANGE_CHECK; + nactorx->movement.mv_add_angl = DEG2SHORT_ANGLE2(11.25f); +} + +enum { + aTKN1_TALK_REQUEST_NONE, + aTKN1_TALK_REQUEST_NORM, + + aTKN1_TALK_REQUEST_NUM +}; + +typedef struct { + u8 think_proc_idx; + u8 think_init_idx; + u8 talk_request_idx; + u8 talk_idx; + u8 think_idx_after_talk; +} aTKN1_think_data_c; + +// TODO: enums for these +static aTKN1_think_data_c dt_tbl[] = { + {0x01, 0x01, 0x00, 0x00, 0x00}, + {0x02, 0x07, 0x00, 0x00, 0x01}, + {0x0D, 0x10, 0x00, 0x00, 0x02}, + {0x02, 0x07, 0x00, 0x00, 0x03}, + {0x0F, 0x10, 0x01, 0x00, 0x04}, + {0x02, 0x06, 0x00, 0x00, 0x05}, + {0x05, 0x08, 0x01, 0x01, 0x05}, + {0x06, 0x02, 0x01, 0x02, 0x07}, + {0x02, 0x04, 0x00, 0x00, 0x08}, + {0x03, 0x09, 0x01, 0x03, 0x09}, + {0x02, 0x12, 0x00, 0x00, 0x0A}, + {0x04, 0x03, 0x01, 0x04, 0x0A}, + {0x07, 0x0A, 0x01, 0x05, 0x0A}, + {0x08, 0x0B, 0x01, 0x06, 0x0A}, + {0x0B, 0x0C, 0x00, 0x00, 0x0E}, + {0x02, 0x0C, 0x00, 0x00, 0x0F}, + {0x0E, 0x0E, 0x01, 0x07, 0x10}, + {0x0E, 0x0D, 0x01, 0x08, 0x11}, + {0x02, 0x11, 0x00, 0x00, 0x12}, + {0x09, 0x13, 0x01, 0x09, 0x12}, + {0x0A, 0x13, 0x01, 0x0A, 0x14}, + {0x0C, 0x0F, 0x01, 0x0B, 0x15}, + {0x10, 0x14, 0x01, 0x0C, 0x16}, +}; + +static aTKN1_THINK_PROC proc_table[] = { + (aTKN1_THINK_PROC)none_proc1, + aTKN1_birth, + aTKN1_turn_next, + aTKN1_ready, + aTKN1_run, + aTKN1_warmup, + aTKN1_warmup3, + aTKN1_kokeru, + aTKN1_getup, + aTKN1_kansen_bf, + aTKN1_kansen, + aTKN1_goal1, + aTKN1_omedeto, + aTKN1_move, + aTKN1_goal_af, + aTKN1_move_wm, + aTKN1_omedeto_af, +}; + +static void aTKN1_setup_think_proc(TOKYOSO_NPC1_ACTOR* actor, GAME_PLAY* play, u8 think_idx) { + static aNPC_TALK_REQUEST_PROC talk_request_table[] = { (aNPC_TALK_REQUEST_PROC)none_proc1, aTKN1_norm_talk_request, (aNPC_TALK_REQUEST_PROC)none_proc1 }; + aTKN1_think_data_c* dt; + + dt = &dt_tbl[think_idx]; + actor->think_idx = think_idx; + actor->think_proc = proc_table[dt->think_proc_idx]; + actor->npc_class.talk_info.talk_request_proc = talk_request_table[dt->talk_request_idx]; + actor->talk_idx = dt->talk_idx; + actor->next_think_idx = dt->think_idx_after_talk; + + if (CLIP(tokyoso_clip) != NULL) { + CLIP(tokyoso_clip)->npc1_think_init_proc((ACTOR*)actor, play, dt->think_init_idx); + } + + actor->change_flag = TRUE; +} + +static void aTKN1_think_proc(NPC_ACTOR* nactorx, GAME_PLAY* play, int type) { + switch (type) { + case aNPC_THINK_PROC_INIT: + aTKN1_think_init_proc(nactorx, play); + break; + case aNPC_THINK_PROC_MAIN: + aTKN1_think_main_proc(nactorx, play); + break; + } +} + +static void aTKN1_schedule_init_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) { + nactorx->think.think_proc = aTKN1_think_proc; + NPC_CLIP->think_proc(nactorx, play, aNPC_THINK_SPECIAL, aNPC_THINK_TYPE_INIT); +} + +static void aTKN1_schedule_main_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) { + TOKYOSO_NPC1_ACTOR* actor = (TOKYOSO_NPC1_ACTOR*)nactorx; + + if (!NPC_CLIP->think_proc(nactorx, play, -1, aNPC_THINK_TYPE_CHK_INTERRUPT)) { + NPC_CLIP->think_proc(nactorx, play, -1, aNPC_THINK_TYPE_MAIN); + } else if (nactorx->collision.turn_flag == TRUE && actor->think_idx == 11) { + CLIP(tokyoso_clip)->next_run_proc((ACTOR*)nactorx); + aTKN1_setup_think_proc(actor, play, 11); + } +} + +static void aTKN1_schedule_proc(NPC_ACTOR* nactorx, GAME_PLAY* play, int type) { + switch (type) { + case aNPC_SCHEDULE_PROC_INIT: + aTKN1_schedule_init_proc(nactorx, play); + break; + case aNPC_SCHEDULE_PROC_MAIN: + aTKN1_schedule_main_proc(nactorx, play); + break; + } +} diff --git a/src/actor/npc/ac_tokyoso_npc1_talk.c_inc b/src/actor/npc/ac_tokyoso_npc1_talk.c_inc new file mode 100644 index 00000000..a276b042 --- /dev/null +++ b/src/actor/npc/ac_tokyoso_npc1_talk.c_inc @@ -0,0 +1,75 @@ +enum { + aTKN1_TALK_END_WAIT, + + aTKN1_TALK_NUM +}; + +typedef struct { + u8 msg_idx; + u8 turn; + u8 camera; +} aTKN1_talk_data_c; + +static void aTKN1_set_norm_talk_info(ACTOR* actorx) { + CLIP(tokyoso_clip)->set_talk_request_proc(actorx); +} + +static void aTKN1_norm_talk_request(ACTOR* actorx, GAME* game) { + TOKYOSO_NPC1_ACTOR* actor = (TOKYOSO_NPC1_ACTOR*)actorx; + + if (!actor->change_flag) { + mDemo_Request(mDemo_TYPE_TALK, actorx, aTKN1_set_norm_talk_info); + } else { + actor->change_flag = FALSE; + } +} + +static int aTKN1_talk_init(ACTOR* actorx, GAME* game) { + TOKYOSO_NPC1_ACTOR* actor = (TOKYOSO_NPC1_ACTOR*)actorx; + + actor->npc_class.talk_info.talk_request_proc = (aNPC_TALK_REQUEST_PROC)none_proc1; + mDemo_Set_ListenAble(); + mDemo_Start(actorx); + return TRUE; +} + +static int aTKN1_talk_end_chk(ACTOR* actorx, GAME* game) { + TOKYOSO_NPC1_ACTOR* actor = (TOKYOSO_NPC1_ACTOR*)actorx; + GAME_PLAY* play = (GAME_PLAY*)game; + int ret = FALSE; + + if (mDemo_CAN_ACTOR_TALK(actorx)) { + aTKN1_setup_think_proc(actor, play, actor->next_think_idx); + ret = TRUE; + } + + if (cKF_FrameControl_stop_proc(&actor->npc_class.draw.main_animation.keyframe.frame_control) == TRUE && + actor->npc_class.draw.animation_id == actor->npc_class.talk_info.default_animation) { + int anime_id; + int fc_mode = cKF_FRAMECONTROL_STOP; + + switch (actor->npc_class.talk_info.default_animation) { + case aNPC_ANIM_KOKERU_GETUP1: + anime_id = aNPC_ANIM_ASIHUMI1; + fc_mode = cKF_FRAMECONTROL_REPEAT; + actor->npc_class.movement.mv_add_angl = DEG2SHORT_ANGLE2(11.25f); + actor->npc_class.movement.mv_angl = actorx->player_angle_y; + break; + case aNPC_ANIM_KOKERU1: + anime_id = aNPC_ANIM_KOKERU_GETUP1; + fc_mode = cKF_FRAMECONTROL_STOP; + break; + default: + anime_id = aNPC_ANIM_NUM; + break; + } + + if (anime_id != aNPC_ANIM_NUM) { + actor->npc_class.talk_info.default_animation = anime_id; + NPC_CLIP->animation_init_proc(actorx, anime_id, TRUE); + actor->npc_class.draw.main_animation.keyframe.frame_control.mode = fc_mode; + } + } + + return ret; +}