From af43673e24fc975cac3981fd2e8e3ca7c9b3f27e Mon Sep 17 00:00:00 2001 From: Cuyler36 Date: Sun, 9 Feb 2025 03:50:15 -0500 Subject: [PATCH] Implement & link ac_npc_sleep_obaba --- configure.py | 2 +- include/ac_npc_sleep_obaba.h | 12 +- src/actor/npc/ac_npc_sleep_obaba.c | 87 ++++++++++++++ src/actor/npc/ac_npc_sleep_obaba_act.c_inc | 113 ++++++++++++++++++ .../npc/ac_npc_sleep_obaba_animation.c_inc | 5 + 5 files changed, 217 insertions(+), 2 deletions(-) create mode 100644 src/actor/npc/ac_npc_sleep_obaba.c create mode 100644 src/actor/npc/ac_npc_sleep_obaba_act.c_inc create mode 100644 src/actor/npc/ac_npc_sleep_obaba_animation.c_inc diff --git a/configure.py b/configure.py index 27bb6398..baa1c0db 100644 --- a/configure.py +++ b/configure.py @@ -1138,7 +1138,7 @@ config.libs = [ Object(NonMatching, "actor/npc/ac_npc_shasho.c"), Object(Matching, "actor/npc/ac_npc_shop_master.c"), Object(Matching, "actor/npc/ac_npc_shop_mastersp.c"), - Object(NonMatching, "actor/npc/ac_npc_sleep_obaba.c"), + Object(Matching, "actor/npc/ac_npc_sleep_obaba.c"), Object(NonMatching, "actor/npc/ac_npc_soncho.c"), Object(NonMatching, "actor/npc/ac_npc_station_master.c"), Object(Matching, "actor/npc/ac_npc_super_master.c"), diff --git a/include/ac_npc_sleep_obaba.h b/include/ac_npc_sleep_obaba.h index 602c0acb..70a7a5f1 100644 --- a/include/ac_npc_sleep_obaba.h +++ b/include/ac_npc_sleep_obaba.h @@ -3,11 +3,22 @@ #include "types.h" #include "m_actor.h" +#include "ac_npc.h" #ifdef __cplusplus extern "C" { #endif +typedef struct npc_sleep_obaba_actor_s NPC_SLEEP_OBABA_ACTOR; + +typedef void (*aNSO_ACT_PROC)(NPC_SLEEP_OBABA_ACTOR* actor); + +struct npc_sleep_obaba_actor_s { + NPC_ACTOR npc_class; + int action; + aNSO_ACT_PROC act_proc; +}; + extern ACTOR_PROFILE Npc_Sleep_Obaba_Profile; #ifdef __cplusplus @@ -15,4 +26,3 @@ extern ACTOR_PROFILE Npc_Sleep_Obaba_Profile; #endif #endif - diff --git a/src/actor/npc/ac_npc_sleep_obaba.c b/src/actor/npc/ac_npc_sleep_obaba.c new file mode 100644 index 00000000..61b20912 --- /dev/null +++ b/src/actor/npc/ac_npc_sleep_obaba.c @@ -0,0 +1,87 @@ +#include "ac_npc_sleep_obaba.h" + +#include "m_common_data.h" + +enum { + aNSO_ACT_SLEEP, + aNSO_ACT_CRAMP, + + aNSO_ACT_NUM +}; + +static void aNSO_actor_ct(ACTOR* actorx, GAME* game); +static void aNSO_actor_dt(ACTOR* actorx, GAME* game); +static void aNSO_actor_move(ACTOR* actorx, GAME* game); +static void aNSO_actor_draw(ACTOR* actorx, GAME* game); +static void aNSO_actor_save(ACTOR* actorx, GAME* game); +static void aNSO_actor_init(ACTOR* actorx, GAME* game); + +// clang-format off +ACTOR_PROFILE Npc_Sleep_Obaba_Profile = { + mAc_PROFILE_NPC_SLEEP_OBABA, + ACTOR_PART_NPC, + ACTOR_STATE_NONE, + SP_NPC_SLEEP_OBABA, + ACTOR_OBJ_BANK_KEEP, + sizeof(NPC_SLEEP_OBABA_ACTOR), + aNSO_actor_ct, + aNSO_actor_dt, + aNSO_actor_init, + mActor_NONE_PROC1, + aNSO_actor_save, +}; +// clang-format on + +static void aNSO_schedule_proc(NPC_ACTOR* nactorx, GAME_PLAY* play, int proc_type); +static void aNSO_setupAction(NPC_SLEEP_OBABA_ACTOR* actor, int action); + +static void aNSO_actor_ct(ACTOR* actorx, GAME* game) { + NPC_SLEEP_OBABA_ACTOR* actor = (NPC_SLEEP_OBABA_ACTOR*)actorx; + static aNPC_ct_data_c ct_data = { + aNSO_actor_move, + aNSO_actor_draw, + aNPC_CT_SCHED_TYPE_SPECIAL, + (aNPC_TALK_REQUEST_PROC)none_proc1, + (aNPC_TALK_INIT_PROC)none_proc1, + (aNPC_TALK_END_CHECK_PROC)none_proc1, + 1, + }; + + if (CLIP(npc_clip)->birth_check_proc(actorx, game) == TRUE) { + NPC_SLEEP_OBABA_ACTOR* actor = (NPC_SLEEP_OBABA_ACTOR*)actorx; + + actor->npc_class.schedule.schedule_proc = aNSO_schedule_proc; + CLIP(npc_clip)->ct_proc(actorx, game, &ct_data); + actorx->world.position.x -= 6.0f; + actorx->world.position.z -= 24.0f; + } +} + +static void aNSO_actor_save(ACTOR* actorx, GAME* game) { + CLIP(npc_clip)->save_proc(actorx, game); +} + +static void aNSO_actor_dt(ACTOR* actorx, GAME* game) { + CLIP(npc_clip)->dt_proc(actorx, game); +} + +static void aNSO_actor_init(ACTOR* actorx, GAME* game) { + CLIP(npc_clip)->init_proc(actorx, game); +} + +static void aNSO_actor_move(ACTOR* actorx, GAME* game) { + NPC_SLEEP_OBABA_ACTOR* actor = (NPC_SLEEP_OBABA_ACTOR*)actorx; + + actor->npc_class.condition_info.demo_flg = + aNPC_COND_DEMO_SKIP_ENTRANCE_CHECK | aNPC_COND_DEMO_SKIP_HEAD_LOOKAT | aNPC_COND_DEMO_SKIP_TALK_CHECK | + aNPC_COND_DEMO_SKIP_FORWARD_CHECK | aNPC_COND_DEMO_SKIP_BGCHECK | aNPC_COND_DEMO_SKIP_OBJ_COL_CHECK | + aNPC_COND_DEMO_SKIP_MOVE_Y | aNPC_COND_DEMO_SKIP_MOVE_CIRCLE_REV | aNPC_COND_DEMO_SKIP_MOVE_RANGE_CHECK; + CLIP(npc_clip)->move_proc(actorx, game); +} + +static void aNSO_actor_draw(ACTOR* actorx, GAME* game) { + CLIP(npc_clip)->draw_proc(actorx, game); +} + +#include "../src/actor/npc/ac_npc_sleep_obaba_animation.c_inc" +#include "../src/actor/npc/ac_npc_sleep_obaba_act.c_inc" diff --git a/src/actor/npc/ac_npc_sleep_obaba_act.c_inc b/src/actor/npc/ac_npc_sleep_obaba_act.c_inc new file mode 100644 index 00000000..32399de1 --- /dev/null +++ b/src/actor/npc/ac_npc_sleep_obaba_act.c_inc @@ -0,0 +1,113 @@ +static void aNSO_set_request_act(NPC_SLEEP_OBABA_ACTOR* actor) { + actor->npc_class.request.act_priority = 4; + actor->npc_class.request.act_idx = aNPC_ACT_CLAP; + actor->npc_class.request.act_type = aNPC_ACT_TYPE_SEARCH; +} + +static void aNSO_sleep(NPC_SLEEP_OBABA_ACTOR* actor) { + if (actor->npc_class.draw.main_animation_state == cKF_STATE_CONTINUE) { + if (actor->npc_class.draw.loop_flag == 0) { + actor->npc_class.action.step = aNPC_ACTION_END_STEP; + } else { + actor->npc_class.draw.loop_flag--; + } + } +} + +static void aNSO_cramp(NPC_SLEEP_OBABA_ACTOR* actor) { + if (actor->npc_class.draw.main_animation_state == cKF_STATE_STOPPED) { + actor->npc_class.action.step = aNPC_ACTION_END_STEP; + } +} + +static void aNSO_setupAction(NPC_SLEEP_OBABA_ACTOR* actor, int action) { + static aNSO_ACT_PROC process[] = { + aNSO_sleep, + aNSO_cramp, + }; + + actor->npc_class.action.step = 0; + actor->action = action; + actor->act_proc = process[action]; + actor->npc_class.draw.loop_flag = 2 + RANDOM(3); + aNSO_set_animation(actor, action); +} + +static void aNSO_act_chg_data_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) { + nactorx->action.act_obj = aNPC_ACT_OBJ_PLAYER; +} + +static void aNSO_act_init_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) { + NPC_SLEEP_OBABA_ACTOR* actor = (NPC_SLEEP_OBABA_ACTOR*)nactorx; + + aNSO_setupAction(actor, aNSO_ACT_SLEEP); +} + +static void aNSO_act_main_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) { + NPC_SLEEP_OBABA_ACTOR* actor = (NPC_SLEEP_OBABA_ACTOR*)nactorx; + + (*actor->act_proc)(actor); +} + +static void aNSO_act_proc(NPC_ACTOR* nactorx, GAME_PLAY* play, int proc_type) { + static aNPC_SUB_PROC act_proc[] = { + aNSO_act_init_proc, + aNSO_act_chg_data_proc, + aNSO_act_main_proc, + }; + + (*act_proc[proc_type])(nactorx, play); +} + +static void aNSO_think_main_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) { + static int action[] = { aNSO_ACT_SLEEP, aNSO_ACT_CRAMP }; + NPC_SLEEP_OBABA_ACTOR* actor = (NPC_SLEEP_OBABA_ACTOR*)nactorx; + + if (actor->npc_class.action.step == aNPC_ACTION_END_STEP) { + if (actor->npc_class.action.idx == aNPC_ACT_CLAP) { + int idx = RANDOM(ARRAY_COUNT(action)); + + aNSO_setupAction(actor, action[idx]); + } + + aNSO_set_request_act(actor); + } +} + +static void aNSO_think_init_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) { + NPC_SLEEP_OBABA_ACTOR* actor = (NPC_SLEEP_OBABA_ACTOR*)nactorx; + + nactorx->think.interrupt_flags = 0; + nactorx->action.act_proc = aNSO_act_proc; + aNSO_set_request_act(actor); +} + +static void aNSO_think_proc(NPC_ACTOR* nactorx, GAME_PLAY* play, int proc_type) { + static aNPC_SUB_PROC think_proc[] = { + aNSO_think_init_proc, + aNSO_think_main_proc, + }; + + (*think_proc[proc_type])(nactorx, play); +} + +static void aNSO_schedule_init_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) { + nactorx->think.think_proc = aNSO_think_proc; + nactorx->condition_info.hide_request = FALSE; + CLIP(npc_clip)->think_proc(nactorx, play, aNPC_THINK_IN_BLOCK, aNPC_THINK_TYPE_INIT); +} + +static void aNSO_schedule_main_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) { + if (CLIP(npc_clip)->think_proc(nactorx, play, -1, aNPC_THINK_TYPE_CHK_INTERRUPT) == 0) { + CLIP(npc_clip)->think_proc(nactorx, play, -1, aNPC_THINK_TYPE_MAIN); + } +} + +static void aNSO_schedule_proc(NPC_ACTOR* nactorx, GAME_PLAY* play, int proc_type) { + static aNPC_SUB_PROC sche_proc[] = { + aNSO_schedule_init_proc, + aNSO_schedule_main_proc, + }; + + (*sche_proc[proc_type])(nactorx, play); +} diff --git a/src/actor/npc/ac_npc_sleep_obaba_animation.c_inc b/src/actor/npc/ac_npc_sleep_obaba_animation.c_inc new file mode 100644 index 00000000..31e00fb2 --- /dev/null +++ b/src/actor/npc/ac_npc_sleep_obaba_animation.c_inc @@ -0,0 +1,5 @@ +static void aNSO_set_animation(NPC_SLEEP_OBABA_ACTOR* actor, int action) { + static int animeSeqNo[] = { aNPC_ANIM_KOKKURI_D1, aNPC_ANIM_KOKKURI_D2 }; + + CLIP(npc_clip)->animation_init_proc((ACTOR*)actor, animeSeqNo[action], FALSE); +}