mirror of
https://github.com/ACreTeam/ac-decomp
synced 2026-05-23 06:34:18 -04:00
Implement & link ac_tunahiki_npc0
This commit is contained in:
+1
-1
@@ -1153,7 +1153,7 @@ config.libs = [
|
||||
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"),
|
||||
Object(Matching, "actor/npc/ac_tunahiki_npc0.c"),
|
||||
Object(NonMatching, "actor/npc/ac_tunahiki_npc1.c"),
|
||||
Object(Matching, "actor/npc/ac_turi_npc0.c"),
|
||||
],
|
||||
|
||||
@@ -3,11 +3,30 @@
|
||||
|
||||
#include "types.h"
|
||||
#include "m_actor.h"
|
||||
#include "ac_npc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct tunahiki_npc0_actor_s TUNAHIKI_NPC0_ACTOR;
|
||||
|
||||
typedef void (*aTNN0_THINK_PROC)(TUNAHIKI_NPC0_ACTOR* actor, GAME_PLAY* play);
|
||||
typedef void (*aTNN0_TALK_PROC)(TUNAHIKI_NPC0_ACTOR* actor, GAME_PLAY* play);
|
||||
|
||||
struct tunahiki_npc0_actor_s {
|
||||
NPC_ACTOR npc_class;
|
||||
aTNN0_THINK_PROC think_proc;
|
||||
aTNN0_TALK_PROC talk_proc;
|
||||
ACTOR* rope_p;
|
||||
int base_msg;
|
||||
s16 timer;
|
||||
u8 think_idx;
|
||||
u8 next_think_idx;
|
||||
u8 talk_idx;
|
||||
u8 change_flag;
|
||||
};
|
||||
|
||||
extern ACTOR_PROFILE Tunahiki_Npc0_Profile;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -15,4 +34,3 @@ extern ACTOR_PROFILE Tunahiki_Npc0_Profile;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
#include "ac_tunahiki_npc0.h"
|
||||
|
||||
#include "ac_tunahiki_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_tunahiki_control
|
||||
|
||||
// enum {
|
||||
// aTNN0_THINK_BIRTH,
|
||||
// aTNN0_THINK_KYORO_MAE,
|
||||
// aTNN0_THINK_KYORO,
|
||||
// aTNN0_THINK_WALK_TURN,
|
||||
// aTNN0_THINK_WALK,
|
||||
// aTNN0_THINK_HIROU_MAE,
|
||||
// aTNN0_THINK_HIROU,
|
||||
// aTNN0_THINK_HIROU_SP,
|
||||
// aTNN0_THINK_HIROU_END,
|
||||
// aTNN0_THINK_NAGERU,
|
||||
// aTNN0_THINK_NAGERU_END,
|
||||
|
||||
// aTNN0_THINK_NUM
|
||||
// };
|
||||
|
||||
// enum {
|
||||
// aTNN0_THINK_PROC_NONE,
|
||||
// aTNN0_THINK_PROC_TIMER_NEXT,
|
||||
// aTNN0_THINK_PROC_BIRTH,
|
||||
// aTNN0_THINK_PROC_TURN_NEXT,
|
||||
// aTNN0_THINK_PROC_WALK,
|
||||
// aTNN0_THINK_PROC_HIROU,
|
||||
// aTNN0_THINK_PROC_HIROU_SP,
|
||||
// aTNN0_THINK_PROC_ANIME_NEXT,
|
||||
// aTNN0_THINK_PROC_NAGERU,
|
||||
// aTNN0_THINK_PROC_NAGERU_END,
|
||||
|
||||
// aTNN0_THINK_PROC_NUM
|
||||
// };
|
||||
|
||||
// enum {
|
||||
// aTNN0_THINK_INIT_PROC_NONE,
|
||||
// aTNN0_THINK_INIT_PROC_NORMAL_WAIT,
|
||||
// aTNN0_THINK_INIT_PROC_MOVE,
|
||||
// aTNN0_THINK_INIT_PROC_KYORO_MAE,
|
||||
// aTNN0_THINK_INIT_PROC_KYORO,
|
||||
// aTNN0_THINK_INIT_PROC_WALK_TURN,
|
||||
// aTNN0_THINK_INIT_PROC_HIROU_MAE,
|
||||
// aTNN0_THINK_INIT_PROC_HIROU,
|
||||
// aTNN0_THINK_INIT_PROC_HIROU_SP,
|
||||
// aTNN0_THINK_INIT_PROC_HIROU_END,
|
||||
// aTNN0_THINK_INIT_PROC_NAGERU,
|
||||
// aTNN0_THINK_INIT_PROC_NAGERU_END,
|
||||
|
||||
// aTNN0_THINK_INIT_PROC_NUM
|
||||
// };
|
||||
|
||||
static void aTNN0_actor_ct(ACTOR* actorx, GAME* game);
|
||||
static void aTNN0_actor_dt(ACTOR* actorx, GAME* game);
|
||||
static void aTNN0_actor_move(ACTOR* actorx, GAME* game);
|
||||
static void aTNN0_actor_draw(ACTOR* actorx, GAME* game);
|
||||
static void aTNN0_actor_save(ACTOR* actorx, GAME* game);
|
||||
static void aTNN0_actor_init(ACTOR* actorx, GAME* game);
|
||||
|
||||
// clang-format off
|
||||
ACTOR_PROFILE Tunahiki_Npc0_Profile = {
|
||||
mAc_PROFILE_TUNAHIKI_NPC0,
|
||||
ACTOR_PART_NPC,
|
||||
ACTOR_STATE_NONE,
|
||||
SP_NPC_EV_TUNAHIKI_0,
|
||||
ACTOR_OBJ_BANK_KEEP,
|
||||
sizeof(TUNAHIKI_NPC0_ACTOR),
|
||||
aTNN0_actor_ct,
|
||||
aTNN0_actor_dt,
|
||||
aTNN0_actor_init,
|
||||
mActor_NONE_PROC1,
|
||||
aTNN0_actor_save,
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
static int aTNN0_talk_init(ACTOR* actorx, GAME* game);
|
||||
static int aTNN0_talk_end_chk(ACTOR* actorx, GAME* game);
|
||||
|
||||
static void aTNN0_schedule_proc(NPC_ACTOR* nactorx, GAME_PLAY* play, int type);
|
||||
static void aTNN0_setup_think_proc(TUNAHIKI_NPC0_ACTOR* actor, GAME_PLAY* play, u8 think_idx);
|
||||
|
||||
static void aTNN0_actor_ct(ACTOR* actorx, GAME* game) {
|
||||
static aNPC_ct_data_c ct_data = {
|
||||
aTNN0_actor_move,
|
||||
aTNN0_actor_draw,
|
||||
aNPC_CT_SCHED_TYPE_SPECIAL,
|
||||
(aNPC_TALK_REQUEST_PROC)none_proc1,
|
||||
aTNN0_talk_init,
|
||||
aTNN0_talk_end_chk,
|
||||
0,
|
||||
};
|
||||
TUNAHIKI_NPC0_ACTOR* actor = (TUNAHIKI_NPC0_ACTOR*)actorx;
|
||||
|
||||
if (NPC_CLIP->birth_check_proc(actorx, game) == TRUE) {
|
||||
static int base_msg_table[] = { 0x1984, 0x1990, 0x1978, 0x199C, 0x19A8, 0x19B4 };
|
||||
|
||||
actor->npc_class.schedule.schedule_proc = aTNN0_schedule_proc;
|
||||
NPC_CLIP->ct_proc(actorx, game, &ct_data);
|
||||
|
||||
actor->npc_class.palActorIgnoreTimer = -1;
|
||||
actor->change_flag = FALSE;
|
||||
actor->npc_class.head.lock_flag = TRUE;
|
||||
actor->base_msg = base_msg_table[mNpc_GetNpcLooks(actorx)];
|
||||
actor->npc_class.talk_info.turn = aNPC_TALK_TURN_NONE;
|
||||
actor->npc_class.talk_info.default_animation = aNPC_ANIM_HATAFURI1;
|
||||
actorx->talk_distance = 85.0f;
|
||||
actor->npc_class.collision.check_kind = mCoBG_CHECK_TYPE_NORMAL;
|
||||
actorx->world.position.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(actorx->world.position, 0.0f);
|
||||
actorx->position_speed.y = 0.0f;
|
||||
actorx->gravity = 0.0f;
|
||||
actorx->max_velocity_y = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
static void aTNN0_actor_save(ACTOR* actorx, GAME* game) {
|
||||
mNpc_RenewalSetNpc(actorx);
|
||||
}
|
||||
|
||||
static void aTNN0_actor_dt(ACTOR* actorx, GAME* game) {
|
||||
aEv_tunahiki_c* tunahiki = (aEv_tunahiki_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_TUG_OF_WAR, 9);
|
||||
TUNAHIKI_NPC0_ACTOR* actor = (TUNAHIKI_NPC0_ACTOR*)actorx;
|
||||
|
||||
if (tunahiki != NULL) {
|
||||
tunahiki->flag = 0;
|
||||
tunahiki->npc_state = aTNC_NPC_STATE2;
|
||||
}
|
||||
|
||||
if (actor->rope_p != NULL) {
|
||||
Actor_delete(actor->rope_p);
|
||||
}
|
||||
|
||||
NPC_CLIP->dt_proc(actorx, game);
|
||||
}
|
||||
|
||||
static void aTNN0_actor_init(ACTOR* actorx, GAME* game) {
|
||||
NPC_CLIP->init_proc(actorx, game);
|
||||
}
|
||||
|
||||
static int aTNN0_set_request_act(TUNAHIKI_NPC0_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 aTNN0_make_hata(ACTOR* actorx, GAME* game) {
|
||||
TUNAHIKI_NPC0_ACTOR* actor = (TUNAHIKI_NPC0_ACTOR*)actorx;
|
||||
|
||||
if (actor->npc_class.right_hand.item_actor_p == NULL) {
|
||||
ACTOR* flag = CLIP(tools_clip)->aTOL_birth_proc(TOOL_FLAG, aTOL_ACTION_S_TAKEOUT, actorx, game, -1, NULL);
|
||||
|
||||
if (flag != NULL) {
|
||||
actor->npc_class.right_hand.item_actor_p = flag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void aTNN0_actor_move(ACTOR* actorx, GAME* game) {
|
||||
NPC_CLIP->move_proc(actorx, game);
|
||||
aTNN0_make_hata(actorx, game);
|
||||
}
|
||||
|
||||
#include "../src/actor/npc/ac_tunahiki_npc0_talk.c_inc"
|
||||
#include "../src/actor/npc/ac_tunahiki_npc0_schedule.c_inc"
|
||||
|
||||
static void aTNN0_actor_draw(ACTOR* actorx, GAME* game) {
|
||||
NPC_CLIP->draw_proc(actorx, game);
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
static void aTNN0_birth(TUNAHIKI_NPC0_ACTOR* actor, GAME_PLAY* play) {
|
||||
aEv_tunahiki_c* tunahiki = (aEv_tunahiki_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_TUG_OF_WAR, 9);
|
||||
ACTOR* actorx = (ACTOR*)actor;
|
||||
|
||||
if (tunahiki != NULL) {
|
||||
ACTOR* rope_p = Actor_info_make_actor(&play->actor_info, (GAME*)play, mAc_PROFILE_ROPE, actorx->world.position.x + 20.0f, actorx->world.position.y, actorx->world.position.z + 45.0f, 0, 0, 0, -1, -1, -1, EMPTY_NO, -1, -1, -1);
|
||||
actor->rope_p = rope_p;
|
||||
|
||||
if (rope_p != NULL) {
|
||||
((aEv_tunahiki_c*)mEv_get_save_area(mEv_EVENT_SPORTS_FAIR_TUG_OF_WAR, 9))->rope = 0.0f; // this smells like a macro
|
||||
tunahiki->rope_base = 0.0f;
|
||||
tunahiki->flag = 0;
|
||||
tunahiki->npc_state = aTNC_NPC_STATE1;
|
||||
aTNN0_setup_think_proc(actor, play, 0);
|
||||
actorx->world.position.x += 20.0f;
|
||||
actorx->world.position.z -= 30.0f;
|
||||
actor->npc_class.collision.pipe.attribute.pipe.radius = 60;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void aTNN0_think_main_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) {
|
||||
TUNAHIKI_NPC0_ACTOR* actor = (TUNAHIKI_NPC0_ACTOR*)nactorx;
|
||||
|
||||
if (actor->npc_class.action.step == aNPC_ACTION_END_STEP) {
|
||||
actor->npc_class.condition_info.demo_flg = aNPC_COND_DEMO_SKIP_BGCHECK | aNPC_COND_DEMO_SKIP_MOVE_Y;
|
||||
}
|
||||
|
||||
actor->think_proc(actor, play);
|
||||
}
|
||||
|
||||
static void aTNN0_think_init_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) {
|
||||
TUNAHIKI_NPC0_ACTOR* actor = (TUNAHIKI_NPC0_ACTOR*)nactorx;
|
||||
|
||||
nactorx->actor_class.status_data.weight = MASSTYPE_IMMOVABLE;
|
||||
nactorx->condition_info.hide_request = FALSE;
|
||||
aTNN0_setup_think_proc(actor, play, 1);
|
||||
nactorx->condition_info.demo_flg = aNPC_COND_DEMO_SKIP_BGCHECK | aNPC_COND_DEMO_SKIP_MOVE_Y;
|
||||
}
|
||||
|
||||
static void aTNN0_wait_init(TUNAHIKI_NPC0_ACTOR* actor, GAME_PLAY* play) {
|
||||
NPC_CLIP->animation_init_proc((ACTOR*)actor, aNPC_ANIM_HATAFURI1, FALSE);
|
||||
actor->npc_class.action.idx = aNPC_ACT_WAIT;
|
||||
aTNN0_set_request_act(actor, 4, aNPC_ACT_WAIT, aNPC_ACT_TYPE_DEFAULT, aNPC_ACT_OBJ_DEFAULT, 0, 0);
|
||||
}
|
||||
|
||||
enum {
|
||||
aTNN0_TALK_REQUEST_NONE,
|
||||
aTNN0_TALK_REQUEST_NORM,
|
||||
|
||||
aTNN0_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;
|
||||
} aTNN0_think_data_c;
|
||||
|
||||
// TODO: enums for these
|
||||
static aTNN0_think_data_c dt_tbl[] = {
|
||||
{0x00, 0x01, 0x01, 0x00, 0x00},
|
||||
{0x01, 0x00, 0x00, 0x00, 0x01},
|
||||
};
|
||||
|
||||
static aTNN0_THINK_PROC proc_table[] = {
|
||||
(aTNN0_THINK_PROC)none_proc1,
|
||||
aTNN0_birth,
|
||||
};
|
||||
|
||||
typedef void (*aTNN0_THINK_INIT_PROC)(TUNAHIKI_NPC0_ACTOR* actor, GAME_PLAY* play);
|
||||
|
||||
static aTNN0_THINK_INIT_PROC init_table[] = {
|
||||
(aTNN0_THINK_INIT_PROC)none_proc1,
|
||||
aTNN0_wait_init,
|
||||
};
|
||||
|
||||
static void aTNN0_setup_think_proc(TUNAHIKI_NPC0_ACTOR* actor, GAME_PLAY* play, u8 think_idx) {
|
||||
static aNPC_TALK_REQUEST_PROC talk_request_table[] = { (aNPC_TALK_REQUEST_PROC)none_proc1, aTNN0_norm_talk_request, (aNPC_TALK_REQUEST_PROC)none_proc1 };
|
||||
aTNN0_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;
|
||||
(*init_table[dt->think_init_idx])(actor, play);
|
||||
actor->change_flag = TRUE;
|
||||
}
|
||||
|
||||
static void aTNN0_think_proc(NPC_ACTOR* nactorx, GAME_PLAY* play, int type) {
|
||||
switch (type) {
|
||||
case aNPC_THINK_PROC_INIT:
|
||||
aTNN0_think_init_proc(nactorx, play);
|
||||
break;
|
||||
case aNPC_THINK_PROC_MAIN:
|
||||
aTNN0_think_main_proc(nactorx, play);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void aTNN0_schedule_init_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) {
|
||||
nactorx->think.think_proc = aTNN0_think_proc;
|
||||
NPC_CLIP->think_proc(nactorx, play, aNPC_THINK_SPECIAL, aNPC_THINK_TYPE_INIT);
|
||||
}
|
||||
|
||||
static void aTNN0_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 aTNN0_schedule_proc(NPC_ACTOR* nactorx, GAME_PLAY* play, int type) {
|
||||
switch (type) {
|
||||
case aNPC_SCHEDULE_PROC_INIT:
|
||||
aTNN0_schedule_init_proc(nactorx, play);
|
||||
break;
|
||||
case aNPC_SCHEDULE_PROC_MAIN:
|
||||
aTNN0_schedule_main_proc(nactorx, play);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
enum {
|
||||
aTNN0_TALK_END_WAIT,
|
||||
|
||||
aTNN0_TALK_NUM
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int msg_no;
|
||||
u8 turn;
|
||||
u8 camera;
|
||||
} aTNN0_talk_data_c;
|
||||
|
||||
static void aTNN0_set_norm_talk_info(ACTOR* actorx) {
|
||||
static aTNN0_talk_data_c dt_tbl[] = {
|
||||
{0x0000, TRUE, CAMERA2_PROCESS_TALK},
|
||||
};
|
||||
TUNAHIKI_NPC0_ACTOR* actor = (TUNAHIKI_NPC0_ACTOR*)actorx;
|
||||
aTNN0_talk_data_c* data_p = &dt_tbl[actor->talk_idx];
|
||||
|
||||
mDemo_Set_msg_num(actor->base_msg + data_p->msg_no + RANDOM(3));
|
||||
mDemo_Set_talk_turn(data_p->turn);
|
||||
mDemo_Set_camera(data_p->camera);
|
||||
actor->talk_proc = (aTNN0_TALK_PROC)none_proc1;
|
||||
}
|
||||
|
||||
static void aTNN0_norm_talk_request(ACTOR* actorx, GAME* game) {
|
||||
TUNAHIKI_NPC0_ACTOR* actor = (TUNAHIKI_NPC0_ACTOR*)actorx;
|
||||
|
||||
if (!actor->change_flag) {
|
||||
mDemo_Request(mDemo_TYPE_TALK, actorx, aTNN0_set_norm_talk_info);
|
||||
} else {
|
||||
actor->change_flag = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static int aTNN0_talk_init(ACTOR* actorx, GAME* game) {
|
||||
TUNAHIKI_NPC0_ACTOR* actor = (TUNAHIKI_NPC0_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 aTNN0_talk_end_chk(ACTOR* actorx, GAME* game) {
|
||||
TUNAHIKI_NPC0_ACTOR* actor = (TUNAHIKI_NPC0_ACTOR*)actorx;
|
||||
GAME_PLAY* play = (GAME_PLAY*)game;
|
||||
int ret = FALSE;
|
||||
|
||||
actor->talk_proc(actor, play);
|
||||
if (mDemo_CAN_ACTOR_TALK(actorx)) {
|
||||
aTNN0_setup_think_proc(actor, play, actor->next_think_idx);
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
Reference in New Issue
Block a user