Implement & link ac_npc_majin

This commit is contained in:
Cuyler36
2025-06-11 02:10:01 -04:00
parent 9302b0441f
commit 9577610833
5 changed files with 425 additions and 2 deletions
+1 -1
View File
@@ -1117,7 +1117,7 @@ config.libs = [
Object(Matching, "actor/npc/ac_npc_guide.c"),
Object(Matching, "actor/npc/ac_npc_guide2.c"),
Object(NonMatching, "actor/npc/ac_npc_hem.c"),
Object(NonMatching, "actor/npc/ac_npc_majin.c"),
Object(Matching, "actor/npc/ac_npc_majin.c"),
Object(NonMatching, "actor/npc/ac_npc_majin2.c"),
Object(NonMatching, "actor/npc/ac_npc_majin3.c"),
Object(NonMatching, "actor/npc/ac_npc_majin4.c"),
+15 -1
View File
@@ -3,11 +3,26 @@
#include "types.h"
#include "m_actor.h"
#include "ac_npc.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct npc_majin_actor_s NPC_MAJIN_ACTOR;
typedef void (*aMJN_THINK_PROC)(NPC_MAJIN_ACTOR* actor, GAME_PLAY* play);
struct npc_majin_actor_s {
NPC_ACTOR npc_class;
int think_idx;
int next_think_idx;
aMJN_THINK_PROC think_proc;
int talk_idx;
int camera_zoomup;
int set_head_request;
};
extern ACTOR_PROFILE Npc_Majin_Profile;
#ifdef __cplusplus
@@ -15,4 +30,3 @@ extern ACTOR_PROFILE Npc_Majin_Profile;
#endif
#endif
+113
View File
@@ -0,0 +1,113 @@
#include "ac_npc_majin.h"
#include "m_common_data.h"
#include "m_player_lib.h"
#include "m_font.h"
#include "m_msg.h"
#include "ac_reset_demo.h"
#include "m_bgm.h"
#include "m_house.h"
enum {
aMJN_THINK_START_WAIT,
aMJN_THINK_START_WAIT_ST,
aMJN_THINK_CALL,
aMJN_THINK_CALL_2,
aMJN_THINK_CALL_3,
aMJN_THINK_CALL_4,
aMJN_THINK_CALL_5,
aMJN_THINK_EXIT,
aMJN_THINK_NUM
};
static void aMJN_actor_ct(ACTOR* actorx, GAME* game);
static void aMJN_actor_dt(ACTOR* actorx, GAME* game);
static void aMJN_actor_move(ACTOR* actorx, GAME* game);
static void aMJN_actor_draw(ACTOR* actorx, GAME* game);
static void aMJN_actor_save(ACTOR* actorx, GAME* game);
static void aMJN_actor_init(ACTOR* actorx, GAME* game);
// clang-format off
ACTOR_PROFILE Npc_Majin_Profile = {
mAc_PROFILE_NPC_MAJIN,
ACTOR_PART_NPC,
ACTOR_STATE_NO_MOVE_WHILE_CULLED | ACTOR_STATE_NO_DRAW_WHILE_CULLED,
SP_NPC_MAJIN,
ACTOR_OBJ_BANK_KEEP,
sizeof(NPC_MAJIN_ACTOR),
aMJN_actor_ct,
aMJN_actor_dt,
aMJN_actor_init,
mActor_NONE_PROC1,
aMJN_actor_save,
};
// clang-format on
static void aMJN_force_talk_request(ACTOR* actorx, GAME* game);
static void aMJN_norm_talk_request(ACTOR* actorx, GAME* game);
static int aMJN_talk_init(ACTOR* actorx, GAME* game);
static int aMJN_talk_end_chk(ACTOR* actorx, GAME* game);
static void aMJN_schedule_proc(NPC_ACTOR* nactorx, GAME_PLAY* play, int type);
static void aMJN_setup_think_proc(NPC_MAJIN_ACTOR* actor, GAME_PLAY* play, int think_idx);
static void aMJN_actor_ct(ACTOR* actorx, GAME* game) {
static aNPC_ct_data_c ct_data = {
aMJN_actor_move,
aMJN_actor_draw,
aNPC_CT_SCHED_TYPE_SPECIAL,
(aNPC_TALK_REQUEST_PROC)none_proc1,
aMJN_talk_init,
aMJN_talk_end_chk,
0,
};
if (NPC_CLIP->birth_check_proc(actorx, game) == TRUE) {
NPC_MAJIN_ACTOR* actor = (NPC_MAJIN_ACTOR*)actorx;
actor->npc_class.schedule.schedule_proc = aMJN_schedule_proc;
NPC_CLIP->ct_proc(actorx, game, &ct_data);
}
}
static void aMJN_actor_save(ACTOR* actorx, GAME* game) {
NPC_CLIP->save_proc(actorx, game);
}
static void aMJN_actor_dt(ACTOR* actorx, GAME* game) {
NPC_CLIP->dt_proc(actorx, game);
eEC_CLIP->effect_kill_proc(eEC_EFFECT_RESET_HOLE, RSV_NO);
if (CLIP(demo_clip2) != NULL && CLIP(demo_clip2)->type == mDemo_CLIP_TYPE_RESET_DEMO) {
ACTOR* demox = (ACTOR*)CLIP(demo_clip2)->demo_class;
if (demox != NULL) {
RESET_DEMO_ACTOR* reset_demo = (RESET_DEMO_ACTOR*)demox;
reset_demo->reset_actor = NULL;
reset_demo->request_light = FALSE;
}
}
}
static void aMJN_actor_init(ACTOR* actorx, GAME* game) {
NPC_CLIP->init_proc(actorx, game);
}
static void aMJN_actor_move(ACTOR* actorx, GAME* game) {
NPC_CLIP->move_proc(actorx, game);
actorx->shape_info.draw_shadow = FALSE;
}
static void aMJN_set_animation(NPC_MAJIN_ACTOR* actor, int think_idx) {
static s16 animeSeqNo[] = { aNPC_ANIM_WAIT1, aNPC_ANIM_WAIT1, aNPC_ANIM_APPEAR1, aNPC_ANIM_APPEAR1, aNPC_ANIM_APPEAR1, aNPC_ANIM_APPEAR1, aNPC_ANIM_APPEAR1, aNPC_ANIM_GO_UG1};
NPC_CLIP->animation_init_proc((ACTOR*)actor, animeSeqNo[think_idx], FALSE);
}
static void aMJN_actor_draw(ACTOR* actorx, GAME* game) {
NPC_CLIP->draw_proc(actorx, game);
}
#include "../src/actor/npc/ac_npc_majin_talk.c_inc"
#include "../src/actor/npc/ac_npc_majin_schedule.c_inc"
+177
View File
@@ -0,0 +1,177 @@
static void aMJN_set_request_act(NPC_MAJIN_ACTOR* actor) {
actor->npc_class.request.act_priority = 1;
actor->npc_class.request.act_idx = aNPC_ACT_SPECIAL;
actor->npc_class.request.act_type = aNPC_ACT_TYPE_SEARCH;
}
static void aMJN_act_init_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) {
nactorx->action.step = 0;
}
static void aMJN_act_proc(NPC_ACTOR* nactorx, GAME_PLAY* play, int type) {
static aNPC_SUB_PROC act_proc[] = { aMJN_act_init_proc, (aNPC_SUB_PROC)none_proc1, (aNPC_SUB_PROC)none_proc1 };
(*act_proc[type])(nactorx, play);
}
static void aMJN_setup_start_think(NPC_MAJIN_ACTOR* actor, GAME_PLAY* play) {
ACTOR* actorx = (ACTOR*)actor;
int think_idx;
s16 arg = 0;
switch (actorx->npc_id) {
case SP_NPC_MAJIN:
think_idx = aMJN_THINK_CALL;
break;
case SP_NPC_MAJIN_D07C:
think_idx = aMJN_THINK_CALL_2;
break;
case SP_NPC_MAJIN_D07D:
think_idx = aMJN_THINK_CALL_3;
break;
case SP_NPC_MAJIN_BROTHER:
arg = 1;
think_idx = aMJN_THINK_CALL_4;
break;
case SP_NPC_MAJIN_D080:
think_idx = aMJN_THINK_CALL_5;
break;
default:
think_idx = aMJN_THINK_CALL_4;
break;
}
eEC_CLIP->effect_make_proc(eEC_EFFECT_RESET_HOLE, actorx->world.position, 3, actorx->shape_info.rotation.y, (GAME*)play, RSV_NO, 0, arg);
if (CLIP(demo_clip2) != NULL && CLIP(demo_clip2)->type == mDemo_CLIP_TYPE_RESET_DEMO) {
ACTOR* demox = (ACTOR*)CLIP(demo_clip2)->demo_class;
if (demox != NULL) {
RESET_DEMO_ACTOR* reset_demo = (RESET_DEMO_ACTOR*)demox;
reset_demo->request_light = TRUE;
}
}
aMJN_setup_think_proc(actor, play, think_idx);
}
static void aMJN_start_wait(NPC_MAJIN_ACTOR* actor, GAME_PLAY* play) {
if (!mPlib_check_player_actor_main_index_OutDoorMove2((GAME*)play)) {
aMJN_setup_start_think(actor, play);
}
}
static void aMJN_start_wait_st(NPC_MAJIN_ACTOR* actor, GAME_PLAY* play) {
ACTOR* playerx = GET_PLAYER_ACTOR_ACTOR(play);
if (playerx != NULL && playerx->world.position.z > 970.0f) {
aMJN_setup_start_think(actor, play);
}
}
static void aMJN_exit(NPC_MAJIN_ACTOR* actor, GAME_PLAY* play) {
if (actor->npc_class.draw.main_animation_state == cKF_STATE_STOPPED) {
Actor_delete((ACTOR*)actor);
}
}
static void aMJN_think_main_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) {
NPC_MAJIN_ACTOR* actor = (NPC_MAJIN_ACTOR*)nactorx;
if (nactorx->action.idx == aNPC_ACT_SPECIAL) {
actor->think_proc(actor, play);
} else if (nactorx->action.step == aNPC_ACTION_END_STEP) {
aMJN_set_request_act(actor);
}
}
static void aMJN_think_init_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) {
static f32 def_posX[] = { 2180.0f, 2300.0f, 2180.0f, 2300.0f, 2220.0f };
static f32 def_posZ[] = { 1460.0f, 1460.0f, 1740.0f, 1740.0f, 1020.0f };
static s16 def_angl[] = { 0xD41D, 0x2BE3, 0xD41D, 0x2BE3, 0x4000 };
static int def_think_idx[] = { aMJN_THINK_START_WAIT, aMJN_THINK_START_WAIT, aMJN_THINK_START_WAIT, aMJN_THINK_START_WAIT, aMJN_THINK_START_WAIT_ST };
NPC_MAJIN_ACTOR* actor = (NPC_MAJIN_ACTOR*)nactorx;
ACTOR* actorx = (ACTOR*)nactorx;
int pos_idx;
actor->npc_class.action.act_proc = aMJN_act_proc;
aMJN_set_request_act(actor);
actorx->status_data.weight = MASSTYPE_HEAVY;
Common_Set(reset_type, 0);
if (play->block_table.block_z == 1) {
pos_idx = 4;
} else {
pos_idx = mHS_get_arrange_idx(Common_Get(player_no));
}
actorx->world.position.x = def_posX[pos_idx];
actorx->world.position.z = def_posZ[pos_idx];
actorx->shape_info.rotation.y = def_angl[pos_idx];
actorx->world.position.y = mCoBG_GetBgY_OnlyCenter_FromWpos(actorx->world.position, 0.0f);
aMJN_setup_think_proc(actor, play, def_think_idx[pos_idx]);
}
static void aMJN_call_init(NPC_MAJIN_ACTOR* actor, GAME_PLAY* play) {
actor->npc_class.condition_info.hide_request = FALSE;
actor->npc_class.talk_info.default_turn_animation = aNPC_ANIM_APPEAR1;
actor->npc_class.talk_info.default_animation = aNPC_ANIM_APPEAR1;
}
typedef void (*aMJN_THINK_INIT_PROC)(NPC_MAJIN_ACTOR* actor, GAME_PLAY* play);
typedef struct {
aMJN_THINK_PROC think_proc;
aMJN_THINK_INIT_PROC think_init_proc;
aNPC_TALK_REQUEST_PROC talk_request_proc;
u8 talk_idx;
u8 think_idx_when_talk_done;
} aMJN_think_data_c;
static void aMJN_setup_think_proc(NPC_MAJIN_ACTOR* actor, GAME_PLAY* play, int think_idx) {
// clang-format off
static aMJN_think_data_c dt_tbl[] = {
{ aMJN_start_wait, (aMJN_THINK_INIT_PROC)none_proc1, (aNPC_TALK_REQUEST_PROC)none_proc1, 0, aMJN_THINK_START_WAIT},
{ aMJN_start_wait_st, (aMJN_THINK_INIT_PROC)none_proc1, (aNPC_TALK_REQUEST_PROC)none_proc1, 0, aMJN_THINK_START_WAIT_ST},
{(aMJN_THINK_PROC)none_proc1, aMJN_call_init, aMJN_force_talk_request, 0, aMJN_THINK_EXIT},
{(aMJN_THINK_PROC)none_proc1, aMJN_call_init, aMJN_force_talk_request, 1, aMJN_THINK_EXIT},
{(aMJN_THINK_PROC)none_proc1, aMJN_call_init, aMJN_force_talk_request, 2, aMJN_THINK_EXIT},
{(aMJN_THINK_PROC)none_proc1, aMJN_call_init, aMJN_force_talk_request, 3, aMJN_THINK_EXIT},
{(aMJN_THINK_PROC)none_proc1, aMJN_call_init, aMJN_force_talk_request, 4, aMJN_THINK_EXIT},
{ aMJN_exit, (aMJN_THINK_INIT_PROC)none_proc1, (aNPC_TALK_REQUEST_PROC)none_proc1, 0, aMJN_THINK_EXIT},
};
// clang-format on
aMJN_think_data_c* data_p = &dt_tbl[think_idx];
actor->think_idx = think_idx;
actor->think_proc = data_p->think_proc;
actor->npc_class.talk_info.talk_request_proc = data_p->talk_request_proc;
actor->talk_idx = data_p->talk_idx;
actor->next_think_idx = data_p->think_idx_when_talk_done;
aMJN_set_animation(actor, think_idx);
(*data_p->think_init_proc)(actor, play);
}
static void aMJN_think_proc(NPC_ACTOR* nactorx, GAME_PLAY* play, int type) {
static aNPC_SUB_PROC think_proc[] = { aMJN_think_init_proc, aMJN_think_main_proc };
(*think_proc[type])(nactorx, play);
}
static void aMJN_schedule_init_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) {
nactorx->think.think_proc = aMJN_think_proc;
NPC_CLIP->think_proc(nactorx, play, aNPC_THINK_SPECIAL, aNPC_THINK_TYPE_INIT);
}
static void aMJN_schedule_main_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) {
if (!NPC_CLIP->think_proc(nactorx, play, -1, aNPC_THINK_TYPE_CHK_INTERRUPT)) {
NPC_CLIP->think_proc(nactorx, play, -1, aNPC_THINK_TYPE_MAIN);
}
}
static void aMJN_schedule_proc(NPC_ACTOR* nactorx, GAME_PLAY* play, int type) {
static aNPC_SUB_PROC sche_proc[] = { aMJN_schedule_init_proc, aMJN_schedule_main_proc };
(*sche_proc[type])(nactorx, play);
}
+119
View File
@@ -0,0 +1,119 @@
static void aMJN_set_zoomup_camera(NPC_MAJIN_ACTOR* actor, GAME_PLAY* play) {
ACTOR* actorx = (ACTOR*)actor;
xyz_t pos;
s_xyz angle;
pos.x = actorx->world.position.x;
pos.y = actorx->world.position.y + actor->npc_class.eye_y - 23.0f;
pos.z = actorx->world.position.z;
angle.x = DEG2SHORT_ANGLE2(-157.5f);
angle.y = actorx->player_angle_y + DEG2SHORT_ANGLE(180.0f);
angle.z = DEG2SHORT_ANGLE2(0.0f);
Camera2_change_priority(play, 0);
Camera2_request_main_demo_fromNowPos(play, &pos, &angle, 182.0f, 28.0f, 10.0f, 10.0f, 9);
}
static void aMJN_set_default_camera(NPC_MAJIN_ACTOR* actor, GAME_PLAY* play) {
ACTOR* playerx;
Camera2_change_priority(play, 0);
playerx = GET_PLAYER_ACTOR_ACTOR(play);
if (playerx != NULL) {
Camera2_request_main_talk(play, playerx, (ACTOR*)actor, 9);
}
}
static void aMJN_chk_talk_demo_code(NPC_MAJIN_ACTOR* actor, GAME_PLAY* play) {
int demo_order3 = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 3);
int demo_order4 = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 4);
switch (demo_order3) {
case 1:
if (!actor->set_head_request) {
actor->set_head_request = TRUE;
}
break;
case 0xFF:
if (actor->set_head_request == TRUE) {
actor->set_head_request = FALSE;
}
break;
default:
if (actor->set_head_request == TRUE) {
xyz_t pos = *Camera2_getEyePos_p();
pos.y += -150.0f;
NPC_CLIP->set_head_request_act_proc((NPC_ACTOR*)actor, 4, aNPC_HEAD_TARGET_POS, NULL, &pos);
actor->npc_class.movement.mv_angl = 0;
actor->npc_class.movement.mv_add_angl = DEG2SHORT_ANGLE2(11.25f);
} else {
actor->npc_class.movement.mv_angl = actor->npc_class.actor_class.player_angle_y;
actor->npc_class.movement.mv_add_angl = DEG2SHORT_ANGLE2(11.25f);
}
break;
}
mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 3, 0);
switch (demo_order4) {
case 1:
if (!actor->camera_zoomup) {
aMJN_set_zoomup_camera(actor, play);
actor->camera_zoomup = TRUE;
}
break;
case 0xFF:
if (actor->camera_zoomup == TRUE) {
aMJN_set_default_camera(actor, play);
actor->camera_zoomup = FALSE;
}
break;
}
mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 4, 0);
}
static void aMJN_set_force_talk_info(ACTOR* actorx) {
static int msg_no[] = { 0x1B3B, 0x3A38, 0x3A42, 0x3A4C, 0x3B05 };
NPC_MAJIN_ACTOR* actor = (NPC_MAJIN_ACTOR*)actorx;
mDemo_Set_msg_num(msg_no[actor->talk_idx]);
mDemo_Set_talk_turn(TRUE);
mPlib_Set_able_hand_all_item_in_demo(TRUE);
mBGMPsComp_make_ps_quiet(0);
}
static void aMJN_force_talk_request(ACTOR* actorx, GAME* game) {
mDemo_Request(mDemo_TYPE_SPEAK, actorx, aMJN_set_force_talk_info);
}
static int aMJN_talk_init(ACTOR* actorx, GAME* game) {
NPC_MAJIN_ACTOR* actor = (NPC_MAJIN_ACTOR*)actorx;
int ret = FALSE;
if (actor->npc_class.draw.animation_id == aNPC_ANIM_APPEAR1 && actor->npc_class.draw.main_animation_state == cKF_STATE_STOPPED) {
actor->npc_class.talk_info.default_turn_animation = aNPC_ANIM_WAIT_R1;
actor->npc_class.talk_info.default_animation = aNPC_ANIM_WAIT_R1;
actor->npc_class.talk_info.talk_request_proc = (aNPC_TALK_REQUEST_PROC)none_proc1;
mDemo_Set_ListenAble();
ret = TRUE;
}
return ret;
}
static int aMJN_talk_end_chk(ACTOR* actorx, GAME* game) {
NPC_MAJIN_ACTOR* actor = (NPC_MAJIN_ACTOR*)actorx;
GAME_PLAY* play = (GAME_PLAY*)game;
int ret = FALSE;
aMJN_chk_talk_demo_code(actor, play);
if (!mDemo_Check(mDemo_TYPE_SPEAK, actorx)) {
aMJN_setup_think_proc(actor, play, actor->next_think_idx);
ret = TRUE;
}
return ret;
}