diff --git a/configure.py b/configure.py index d7f30ba5..e49fa087 100644 --- a/configure.py +++ b/configure.py @@ -1119,7 +1119,7 @@ config.libs = [ Object(NonMatching, "actor/npc/ac_npc_hem.c"), Object(Matching, "actor/npc/ac_npc_majin.c"), Object(Matching, "actor/npc/ac_npc_majin2.c"), - Object(NonMatching, "actor/npc/ac_npc_majin3.c"), + Object(Matching, "actor/npc/ac_npc_majin3.c"), Object(NonMatching, "actor/npc/ac_npc_majin4.c"), Object(Matching, "actor/npc/ac_npc_majin5.c"), Object(Matching, "actor/npc/ac_npc_mamedanuki.c"), diff --git a/include/ac_npc_majin3.h b/include/ac_npc_majin3.h index 38aef6e6..3d9d7ff4 100644 --- a/include/ac_npc_majin3.h +++ b/include/ac_npc_majin3.h @@ -3,11 +3,29 @@ #include "types.h" #include "m_actor.h" +#include "ac_npc.h" +#include "m_string.h" #ifdef __cplusplus extern "C" { #endif +typedef struct npc_majin3_actor_s NPC_MAJIN3_ACTOR; + +typedef void (*aMJN3_THINK_PROC)(NPC_MAJIN3_ACTOR* actor, GAME_PLAY* play); +typedef void (*aMJN3_TALK_PROC)(NPC_MAJIN3_ACTOR* actor, GAME_PLAY* play); + +struct npc_majin3_actor_s { + NPC_ACTOR npc_class; + int think_idx; + int next_think_idx; + aMJN3_THINK_PROC think_proc; + int talk_idx; + aMJN3_TALK_PROC talk_proc; + u8 reply[mString_DEFAULT_STR_SIZE]; + u8 reply_idx; +}; + extern ACTOR_PROFILE Npc_Majin3_Profile; #ifdef __cplusplus @@ -15,4 +33,3 @@ extern ACTOR_PROFILE Npc_Majin3_Profile; #endif #endif - diff --git a/include/m_string_data.h b/include/m_string_data.h index 7094a53f..9b31b146 100644 --- a/include/m_string_data.h +++ b/include/m_string_data.h @@ -10,6 +10,10 @@ extern "C" { #define mString_AM 0x001 #define mString_PM 0x002 #define mString_WEEKDAY_START 0x009 +#define mString_RESETTI_GOOD_WORD_START 0x484 +#define mString_RESETTI_GOOD_WORD_END 0x493 +#define mString_RESETTI_NG_WORD_START 0x4C0 +#define mString_RESETTI_NG_WORD_END 0x4DF #define mString_DAY_START 0x64E #define mString_MONTH_START 0x66D #define mString_SONCHO_EVENT_NAME_START 0x6F8 @@ -20,6 +24,8 @@ extern "C" { #define mString_HANIWA_MSG3 0x76D #define mString_MIKANBOX_START 0x77B #define mString_MIKANBOX_END 0x7FE + +// TODO: these should be in m_msg_data.h #define mString_CARPETPEDDLER_START 0x48a #define mString_TOTAKEKE_START 0x1b93 #define mString_SPEECH_SONCHO_START 0x3db5 diff --git a/src/actor/npc/ac_npc_majin3.c b/src/actor/npc/ac_npc_majin3.c new file mode 100644 index 00000000..cc6a9b14 --- /dev/null +++ b/src/actor/npc/ac_npc_majin3.c @@ -0,0 +1,130 @@ +#include "ac_npc_majin3.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" +#include "m_ledit_ovl.h" + +enum { + aMJN3_THINK_START_WAIT, + aMJN3_THINK_START_WAIT_ST, + aMJN3_THINK_START_WAIT_ST2, + aMJN3_THINK_CALL, + aMJN3_THINK_EXIT, + + aMJN3_THINK_NUM +}; + +enum { + aMJN3_TALK_MSG_WIN_CLOSE_WAIT, + aMJN3_TALK_MENU_OPEN_WAIT, + aMJN3_TALK_MENU_CLOSE_WAIT, + aMJN3_TALK_MSG_WIN_OPEN_WAIT, + aMJN3_TALK_END_WAIT, + + aMJN3_TALK_NUM +}; + +enum { + aMJN3_WORD_GOOD, // user input the correct phrase + aMJN3_WORD_NG, // user input a 'ng' word, special response + aMJN3_WORD_WRONG, // user input the wrong phrase + + aMJN3_WORD_NUM +}; + +static void aMJN3_actor_ct(ACTOR* actorx, GAME* game); +static void aMJN3_actor_dt(ACTOR* actorx, GAME* game); +static void aMJN3_actor_move(ACTOR* actorx, GAME* game); +static void aMJN3_actor_draw(ACTOR* actorx, GAME* game); +static void aMJN3_actor_save(ACTOR* actorx, GAME* game); +static void aMJN3_actor_init(ACTOR* actorx, GAME* game); + +// clang-format off +ACTOR_PROFILE Npc_Majin3_Profile = { + mAc_PROFILE_NPC_MAJIN3, + ACTOR_PART_NPC, + ACTOR_STATE_NO_MOVE_WHILE_CULLED | ACTOR_STATE_NO_DRAW_WHILE_CULLED, + SP_NPC_MAJIN3, + ACTOR_OBJ_BANK_KEEP, + sizeof(NPC_MAJIN3_ACTOR), + aMJN3_actor_ct, + aMJN3_actor_dt, + aMJN3_actor_init, + mActor_NONE_PROC1, + aMJN3_actor_save, +}; +// clang-format on + +static void aMJN3_force_talk_request(ACTOR* actorx, GAME* game); +static void aMJN3_norm_talk_request(ACTOR* actorx, GAME* game); +static int aMJN3_talk_init(ACTOR* actorx, GAME* game); +static int aMJN3_talk_end_chk(ACTOR* actorx, GAME* game); + +static void aMJN3_schedule_proc(NPC_ACTOR* nactorx, GAME_PLAY* play, int type); +static void aMJN3_setup_think_proc(NPC_MAJIN3_ACTOR* actor, GAME_PLAY* play, int think_idx); +static void aMJN3_change_talk_proc(NPC_MAJIN3_ACTOR* actor, int talk_idx); + +static void aMJN3_actor_ct(ACTOR* actorx, GAME* game) { + static aNPC_ct_data_c ct_data = { + aMJN3_actor_move, + aMJN3_actor_draw, + aNPC_CT_SCHED_TYPE_SPECIAL, + (aNPC_TALK_REQUEST_PROC)none_proc1, + aMJN3_talk_init, + aMJN3_talk_end_chk, + 0, + }; + + if (NPC_CLIP->birth_check_proc(actorx, game) == TRUE) { + NPC_MAJIN3_ACTOR* actor = (NPC_MAJIN3_ACTOR*)actorx; + + actor->npc_class.schedule.schedule_proc = aMJN3_schedule_proc; + NPC_CLIP->ct_proc(actorx, game, &ct_data); + } +} + +static void aMJN3_actor_save(ACTOR* actorx, GAME* game) { + NPC_CLIP->save_proc(actorx, game); +} + +static void aMJN3_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 aMJN3_actor_init(ACTOR* actorx, GAME* game) { + NPC_CLIP->init_proc(actorx, game); +} + +static void aMJN3_actor_move(ACTOR* actorx, GAME* game) { + NPC_CLIP->move_proc(actorx, game); + actorx->shape_info.draw_shadow = FALSE; +} + +static void aMJN3_set_animation(NPC_MAJIN3_ACTOR* actor, int think_idx) { + static s16 animeSeqNo[] = { aNPC_ANIM_WAIT1, aNPC_ANIM_WAIT1, aNPC_ANIM_WAIT1, aNPC_ANIM_APPEAR1, aNPC_ANIM_GO_UG1 }; + + NPC_CLIP->animation_init_proc((ACTOR*)actor, animeSeqNo[think_idx], FALSE); +} + +static void aMJN3_actor_draw(ACTOR* actorx, GAME* game) { + NPC_CLIP->draw_proc(actorx, game); +} + +#include "../src/actor/npc/ac_npc_majin3_talk.c_inc" +#include "../src/actor/npc/ac_npc_majin3_schedule.c_inc" diff --git a/src/actor/npc/ac_npc_majin3_schedule.c_inc b/src/actor/npc/ac_npc_majin3_schedule.c_inc new file mode 100644 index 00000000..08602eee --- /dev/null +++ b/src/actor/npc/ac_npc_majin3_schedule.c_inc @@ -0,0 +1,178 @@ +static void aMJN3_set_request_act(NPC_MAJIN3_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 aMJN3_act_init_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) { + nactorx->action.step = 0; +} + +static void aMJN3_act_proc(NPC_ACTOR* nactorx, GAME_PLAY* play, int type) { + static aNPC_SUB_PROC act_proc[] = { aMJN3_act_init_proc, (aNPC_SUB_PROC)none_proc1, (aNPC_SUB_PROC)none_proc1 }; + + (*act_proc[type])(nactorx, play); +} + +static void aMJN3_start_wait(NPC_MAJIN3_ACTOR* actor, GAME_PLAY* play) { + int reset_type = Common_Get(reset_type); + + if (reset_type == 0) { + if (actor->npc_class.actor_class.player_distance_xz >= 120.0f) { + reset_type = 2; + } + } + + if (reset_type != 0) { + actor->npc_class.actor_class.shape_info.rotation.y = actor->npc_class.actor_class.player_angle_y; + aMJN3_setup_think_proc(actor, play, aMJN3_THINK_CALL); + Common_Set(reset_type, 0); + } +} + +static void aMJN3_start_wait_st(NPC_MAJIN3_ACTOR* actor, GAME_PLAY* play) { + ACTOR* playerx = GET_PLAYER_ACTOR_ACTOR(play); + + if (playerx != NULL && playerx->world.position.z > 970.0f) { + aMJN3_setup_think_proc(actor, play, aMJN3_THINK_START_WAIT_ST2); + } +} + +static void aMJN3_start_wait_st2(NPC_MAJIN3_ACTOR* actor, GAME_PLAY* play) { + int reset_type = Common_Get(reset_type); + + if (reset_type == 0) { + ACTOR* playerx = GET_PLAYER_ACTOR_ACTOR(play); + + if (actor->npc_class.actor_class.player_distance_xz > 120.0f) { + reset_type = 2; + } + + if (playerx != NULL) { + if (playerx->world.position.x >= 2280.0f && playerx->world.position.x < 2360.0f && playerx->world.position.z <= 970.0f) { + reset_type = 2; + } + } + } + + if (reset_type != 0) { + actor->npc_class.actor_class.shape_info.rotation.y = actor->npc_class.actor_class.player_angle_y; + aMJN3_setup_think_proc(actor, play, aMJN3_THINK_CALL); + Common_Set(reset_type, 0); + } +} + +static void aMJN3_exit(NPC_MAJIN3_ACTOR* actor, GAME_PLAY* play) { + if (actor->npc_class.draw.main_animation_state == cKF_STATE_STOPPED) { + Actor_delete((ACTOR*)actor); + } +} + +static void aMJN3_think_main_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) { + NPC_MAJIN3_ACTOR* actor = (NPC_MAJIN3_ACTOR*)nactorx; + + if (nactorx->action.idx == aNPC_ACT_SPECIAL) { + actor->think_proc(actor, play); + } else if (nactorx->action.step == aNPC_ACTION_END_STEP) { + aMJN3_set_request_act(actor); + } +} + +static void aMJN3_think_init_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) { + static f32 def_posX[] = { 2180.0f, 2300.0f, 2180.0f, 2300.0f, 2300.0f }; + static f32 def_posZ[] = { 1460.0f, 1460.0f, 1740.0f, 1740.0f, 1020.0f }; + static s16 def_angl[] = { 0, 0, 0, 0, 0x8000 }; + static int def_think_idx[] = { aMJN3_THINK_START_WAIT, aMJN3_THINK_START_WAIT, aMJN3_THINK_START_WAIT, aMJN3_THINK_START_WAIT, aMJN3_THINK_START_WAIT_ST }; + NPC_MAJIN3_ACTOR* actor = (NPC_MAJIN3_ACTOR*)nactorx; + ACTOR* actorx = (ACTOR*)nactorx; + int pos_idx; + + actor->npc_class.action.act_proc = aMJN3_act_proc; + aMJN3_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); + aMJN3_setup_think_proc(actor, play, def_think_idx[pos_idx]); +} + +static void aMJN3_call_init(NPC_MAJIN3_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; + + eEC_CLIP->effect_make_proc(eEC_EFFECT_RESET_HOLE, ((ACTOR*)actor)->world.position, 3, ((ACTOR*)actor)->shape_info.rotation.y, (GAME*)play, RSV_NO, 0, 0); + 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; + } + } +} + +typedef void (*aMJN3_THINK_INIT_PROC)(NPC_MAJIN3_ACTOR* actor, GAME_PLAY* play); + +typedef struct { + aMJN3_THINK_PROC think_proc; + aMJN3_THINK_INIT_PROC think_init_proc; + aNPC_TALK_REQUEST_PROC talk_request_proc; + u8 talk_idx; + u8 think_idx_when_talk_done; +} aMJN3_think_data_c; + +static void aMJN3_setup_think_proc(NPC_MAJIN3_ACTOR* actor, GAME_PLAY* play, int think_idx) { + // clang-format off + static aMJN3_think_data_c dt_tbl[] = { + {aMJN3_start_wait, (aMJN3_THINK_INIT_PROC)none_proc1, (aNPC_TALK_REQUEST_PROC)none_proc1, 0, aMJN3_THINK_START_WAIT}, + {aMJN3_start_wait_st, (aMJN3_THINK_INIT_PROC)none_proc1, (aNPC_TALK_REQUEST_PROC)none_proc1, 0, aMJN3_THINK_START_WAIT_ST}, + {aMJN3_start_wait_st2, (aMJN3_THINK_INIT_PROC)none_proc1, (aNPC_TALK_REQUEST_PROC)none_proc1, 0, aMJN3_THINK_START_WAIT_ST2}, + {(aMJN3_THINK_PROC)none_proc1, aMJN3_call_init, aMJN3_force_talk_request, 0, aMJN3_THINK_EXIT}, + {aMJN3_exit, (aMJN3_THINK_INIT_PROC)none_proc1, (aNPC_TALK_REQUEST_PROC)none_proc1, 0, aMJN3_THINK_EXIT}, + }; + // clang-format on + + aMJN3_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; + aMJN3_set_animation(actor, think_idx); + (*data_p->think_init_proc)(actor, play); +} + +static void aMJN3_think_proc(NPC_ACTOR* nactorx, GAME_PLAY* play, int type) { + static aNPC_SUB_PROC think_proc[] = { aMJN3_think_init_proc, aMJN3_think_main_proc }; + + (*think_proc[type])(nactorx, play); +} + +static void aMJN3_schedule_init_proc(NPC_ACTOR* nactorx, GAME_PLAY* play) { + nactorx->think.think_proc = aMJN3_think_proc; + NPC_CLIP->think_proc(nactorx, play, aNPC_THINK_SPECIAL, aNPC_THINK_TYPE_INIT); +} + +static void aMJN3_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 aMJN3_schedule_proc(NPC_ACTOR* nactorx, GAME_PLAY* play, int type) { + static aNPC_SUB_PROC sche_proc[] = { aMJN3_schedule_init_proc, aMJN3_schedule_main_proc }; + + (*sche_proc[type])(nactorx, play); +} diff --git a/src/actor/npc/ac_npc_majin3_talk.c_inc b/src/actor/npc/ac_npc_majin3_talk.c_inc new file mode 100644 index 00000000..bfc0666b --- /dev/null +++ b/src/actor/npc/ac_npc_majin3_talk.c_inc @@ -0,0 +1,175 @@ +static int aMJN3_check_good_word(NPC_MAJIN3_ACTOR* actor) { + u8 word[mString_DEFAULT_STR_SIZE]; + int ret = FALSE; + + mString_Load_StringFromRom(word, sizeof(word), mString_RESETTI_GOOD_WORD_START + actor->reply_idx); + if (mem_cmp(actor->reply, word, sizeof(word)) == TRUE) { + ret = TRUE; + } + + return ret; +} + +static int aMJN3_check_ng_word(NPC_MAJIN3_ACTOR* actor) { + static int chg_length[] = { 1, 2, 4, 8, 10, 17, 24, 28, -1 }; + u8 word[mString_DEFAULT_STR_SIZE]; + u32 len = 2; + u8* reply_p; + int* chg_length_p = chg_length; + int i; + int j; + int ng_word_idx = mString_RESETTI_NG_WORD_START; + + // Loop through every "ng" (no good?) word + for (i = 0; i < (mString_RESETTI_NG_WORD_END - mString_RESETTI_NG_WORD_START) + 1; i++) { + // check if this index crosses the boundary into the next length of ng strings + // ng strings are grouped in data by length + if (i == *chg_length_p) { + len++; + chg_length_p++; + } + + mString_Load_StringFromRom(word, sizeof(word), ng_word_idx); + reply_p = actor->reply; + // check the entire reply string for occurrences of the ng string + for (j = (mString_DEFAULT_STR_SIZE + 1) - len; j != 0; j--) { + if (mem_cmp(reply_p, word, len) == TRUE) { + return TRUE; + } + + reply_p++; + } + + ng_word_idx++; + } + + return FALSE; +} + +static int aMJN3_check_word(NPC_MAJIN3_ACTOR* actor) { + int ret = aMJN3_WORD_WRONG; + + if (aMJN3_check_good_word(actor) == TRUE) { + ret = aMJN3_WORD_GOOD; + } else if (aMJN3_check_ng_word(actor) == TRUE) { + ret = aMJN3_WORD_NG; + } + + return ret; +} + +static void aMJN3_msg_win_close_wait_talk_proc(NPC_MAJIN3_ACTOR* actor, GAME_PLAY* play) { + int order = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); + + if (order != 0) { + mMsg_REQUEST_MAIN_DISAPPEAR_WAIT_TYPE1(); + aMJN3_change_talk_proc(actor, aMJN3_TALK_MENU_OPEN_WAIT); + } +} + +static void aMJN3_menu_open_wait_talk_proc(NPC_MAJIN3_ACTOR* actor, GAME_PLAY* play) { + if (mMsg_CHECK_MAIN_WAIT() == TRUE) { + Submenu* submenu = &play->submenu; + + submenu->start_refuse = FALSE; + mSM_open_submenu_new(submenu, mSM_OVL_LEDIT, mLE_TYPE_RESET, 0, actor->reply); + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + aMJN3_change_talk_proc(actor, aMJN3_TALK_MENU_CLOSE_WAIT); + } +} + +static void aMJN3_menu_close_wait_talk_proc(NPC_MAJIN3_ACTOR* actor, GAME_PLAY* play) { + Submenu* submenu = &play->submenu; + + if (!submenu->open_flag) { + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + + submenu->start_refuse = TRUE; + mMsg_request_main_appear_wait_type1(msg_p); + aMJN3_change_talk_proc(actor, aMJN3_TALK_MSG_WIN_OPEN_WAIT); + } +} + +static void aMJN3_msg_win_open_wait_talk_proc(NPC_MAJIN3_ACTOR* actor, GAME_PLAY* play) { + static int msg_no[] = { 0x23EC, 0x23EF, 0x23EE }; + static int next_talk_idx[] = { aMJN3_TALK_END_WAIT, aMJN3_TALK_MSG_WIN_CLOSE_WAIT, aMJN3_TALK_MSG_WIN_CLOSE_WAIT }; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + + if (mMsg_Check_not_series_main_wait(msg_p) == TRUE) { + int idx = aMJN3_check_word(actor); + + mMsg_ChangeMsgData(msg_p, msg_no[idx]); + aMJN3_change_talk_proc(actor, next_talk_idx[idx]); + } +} + +static void aMJN3_change_talk_proc(NPC_MAJIN3_ACTOR* actor, int talk_idx) { + // clang-format off + static aMJN3_TALK_PROC talk_proc[] = { + aMJN3_msg_win_close_wait_talk_proc, + aMJN3_menu_open_wait_talk_proc, + aMJN3_menu_close_wait_talk_proc, + aMJN3_msg_win_open_wait_talk_proc, + (aMJN3_TALK_PROC)none_proc1, + }; + // clang-format on + + actor->talk_proc = talk_proc[talk_idx]; +} + +typedef struct { + int msg_no; + aMJN3_TALK_PROC talk_proc; +} aMJN3_talk_data_c; + +static void aMJN3_set_force_talk_info(ACTOR* actorx) { + static aMJN3_talk_data_c dt_tbl[] = { + { 0x23E6, aMJN3_msg_win_close_wait_talk_proc }, + }; + NPC_MAJIN3_ACTOR* actor = (NPC_MAJIN3_ACTOR*)actorx; + aMJN3_talk_data_c* data_p = &dt_tbl[actor->talk_idx]; + + mDemo_Set_msg_num(data_p->msg_no); + mDemo_Set_talk_turn(TRUE); + actor->talk_proc = data_p->talk_proc; + mPlib_Set_able_hand_all_item_in_demo(TRUE); + mBGMPsComp_make_ps_quiet(0); +} + +static void aMJN3_force_talk_request(ACTOR* actorx, GAME* game) { + mDemo_Request(mDemo_TYPE_SPEAK, actorx, aMJN3_set_force_talk_info); +} + +static int aMJN3_talk_init(ACTOR* actorx, GAME* game) { + NPC_MAJIN3_ACTOR* actor = (NPC_MAJIN3_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) { + u8 str[mString_DEFAULT_STR_SIZE]; + + actor->npc_class.talk_info.default_turn_animation = aNPC_ANIM_WAIT_R1; + actor->npc_class.talk_info.default_animation = aNPC_ANIM_WAIT_R1; + actor->reply_idx = RANDOM((mString_RESETTI_GOOD_WORD_END - mString_RESETTI_GOOD_WORD_START) + 1); + mString_Load_StringFromRom(str, sizeof(str), mString_RESETTI_GOOD_WORD_START + actor->reply_idx); + mMsg_SET_ITEM_STR(mMsg_FREE_STR0, str, sizeof(str)); + actor->npc_class.talk_info.talk_request_proc = (aNPC_TALK_REQUEST_PROC)none_proc1; + mDemo_Set_ListenAble(); + ret = TRUE; + } + + return ret; +} + +static int aMJN3_talk_end_chk(ACTOR* actorx, GAME* game) { + NPC_MAJIN3_ACTOR* actor = (NPC_MAJIN3_ACTOR*)actorx; + GAME_PLAY* play = (GAME_PLAY*)game; + int ret = FALSE; + + actor->talk_proc(actor, play); + if (!mDemo_Check(mDemo_TYPE_SPEAK, actorx)) { + aMJN3_setup_think_proc(actor, play, actor->next_think_idx); + ret = TRUE; + } + + return ret; +}