Implement & link ac_npc_sleep_obaba

This commit is contained in:
Cuyler36
2025-02-09 03:50:15 -05:00
parent a1b6ff8feb
commit af43673e24
5 changed files with 217 additions and 2 deletions
+1 -1
View File
@@ -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"),
+11 -1
View File
@@ -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
+87
View File
@@ -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"
+113
View File
@@ -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);
}
@@ -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);
}