diff --git a/include/ac_npc.h b/include/ac_npc.h index 58190947..222387bc 100644 --- a/include/ac_npc.h +++ b/include/ac_npc.h @@ -18,6 +18,7 @@ extern "C" { #define aNPC_SPNPC_BIT_CURATOR 0 #define aNPC_SPNPC_BIT_GOHOME_NPC 1 #define aNPC_SPNPC_BIT_MASK_CAT 2 +#define aNPC_SPNPC_BIT_SHOP_MASTER 3 #define aNPC_SPNPC_BIT_DOZAEMON 4 #define aNPC_SPNPC_BIT_EV_SONCHO 5 diff --git a/include/ac_npc_shop_master.h b/include/ac_npc_shop_master.h index 9bdb25f6..9cab4beb 100644 --- a/include/ac_npc_shop_master.h +++ b/include/ac_npc_shop_master.h @@ -3,16 +3,340 @@ #include "types.h" #include "m_actor.h" +#include "ac_npc.h" +#include "m_mail_password_check.h" +#include "m_private.h" + +#define aNSC_MAX_TICKETS 255 + +#define aNSC_PW_TOWN_STR_LEN 8 +#define aNSC_PW_RECIP_STR_LEN 8 + +#define SELL_BUY_RATIO 4 +#define aNSC_LOAN_MEDIUM 148000 +#define aNSC_LOAN_LARGE 398000 +#define aNSC_LOAN_UPPER 798000 +#define aNSC_LOAN_STATUE 0 +#define aNSC_LOAN_BASEMENT 49800 + + +typedef struct npc_shop_master_s NPC_SHOP_MASTER_ACTOR; + +typedef void (*aNSC_PROC)(ACTOR*, GAME*); + +typedef void (*aNSC_INIT_PROC)(NPC_SHOP_MASTER_ACTOR*, GAME_PLAY*); +typedef int (*aNSC_PC_CHECK_PASSWORD_PROC)(mMpswd_password_c*); +typedef void (*aNSC_ITEM_SELL_PROC)(NPC_SHOP_MASTER_ACTOR*, mActor_name_t); +typedef void (*aNSC_ACTION_PROC)(NPC_SHOP_MASTER_ACTOR*, GAME_PLAY*); + +struct npc_shop_master_s { + /* 0x000 */ NPC_ACTOR npc_class; + /* 0x994 */ int action; + /* 0x998 */ int next_action; + /* 0x99C */ aNSC_ACTION_PROC proc; + /* 0x9A0 */ u16 _9A0; + /* 0x9A2 */ u8 zone; + /* 0x9A3 */ u8 next_zone; + /* 0x9A4 */ u8 player_zone; + /* 0x9A6 */ s16 player_angle; + /* 0x9A8 */ u32 money; + /* 0x9AC */ u32 value; + /* 0x9B0 */ u32 counter; + /* 0x9B4 */ mActor_name_t sell_item; + /* 0x9B6 */ u8 ut_x; + /* 0x9B7 */ u8 ut_y; + /* 0x9B8 */ u8 is_selling; + /* 0x9B9 */ u8 _9B9; + /* 0x9BA */ mActor_name_t order_item; + /* 0x9BC */ u16 player_cloth; + /* 0x9BE */ u16 change_cloth; + /* 0x9C0 */ int _9C0; + /* 0x9C4 */ int msg_no; + /* 0x9C8 */ u8 pw_town_str[aNSC_PW_TOWN_STR_LEN]; + /* 0x9D0 */ u8 pw_recip_str[aNSC_PW_RECIP_STR_LEN]; + /* 0x9D8 */ u8 password_str[mMpswd_PASSWORD_STR_LEN]; + /* 0x9F4 */ u16 pw_item; + /* 0x9F6 */ u16 password_flags; + /* 0x9F8 */ mMpswd_password_c password; +}; + +enum aNSC_action { + aNSC_ACTION_EMPTY, + aNSC_ACTION_SAY_HELLO_APPROACH, + aNSC_ACTION_SAY_HELLO_END_WAIT, + aNSC_ACTION_03_SAY_HELLO_END_WAIT, + aNSC_ACTION_CHECK_ROOF_COL_ORDER, + aNSC_ACTION_CHECK_ROOF_COL_ORDER2, + aNSC_ACTION_CHECK_COL_CHG_OR_MAKE_BASEMENT, + aNSC_ACTION_PRESENT_BALLOON_START_WAIT, + aNSC_ACTION_PRESENT_BALLOON_TRANS_MOVE, + aNSC_ACTION_PRESENT_BALLOON_TRANS_TAKEOUT, + aNSC_ACTION_PRESENT_BALLOON_TRANS_WAIT, + aNSC_ACTION_PRESENT_BALLOON_END_WAIT, + aNSC_ACTION_REQUEST_Q_START_WAIT, + aNSC_ACTION_REQUEST_Q_ANSWER_WAIT, + aNSC_ACTION_REQUEST_Q_ANSWER_WAIT2, + aNSC_ACTION_REQUEST_Q_END_WAIT, + aNSC_ACTION_ANSWER_BUY_ITEM, + aNSC_ACTION_BUY_MENU_OPEN_WAIT, + aNSC_ACTION_BUY_MENU_CLOSE_WAIT, + aNSC_ACTION_MSG_WIN_OPEN_WAIT, + aNSC_ACTION_BUY_SUM_CHECK, + aNSC_ACTION_BUY_CHECK, + aNSC_ACTION_BUY_AFTER_SERVICE, + aNSC_ACTION_BUY_CONTINUE_CHECK, + aNSC_ACTION_RECEIVE_CHECK, + aNSC_ACTION_19_ANSWER_BUY_ITEM, + aNSC_ACTION_0x1a_UNUSED, + aNSC_ACTION_0x1b_UNUSED, + aNSC_ACTION_MSG_WIN_OPEN_WAIT2, + aNSC_ACTION_ORDER_CHECK, + aNSC_ACTION_SELL_CHECK_BEFORE, + aNSC_ACTION_SELL_CHECK, + aNSC_ACTION_SELL_ANSWER0, + aNSC_ACTION_21_REQUEST_Q_END_WAIT, + aNSC_ACTION_SELL_ITEM_WITHOUT_TICKET, + aNSC_ACTION_SELL_ITEM_WITH_TICKET, + aNSC_ACTION_SELL_ITEM_POCKETS_FULL, + aNSC_ACTION_SELL_ITEM_INSUFICIENT_FUNDS, + aNSC_ACTION_SHOW_ITEM_CHECK, + aNSC_ACTION_CHG_CLOTH_START_WAIT, + aNSC_ACTION_CHG_CLOTH_END_WAIT, + aNSC_ACTION_PW_ENTRY_SEND_ADDR_START_WAIT, + aNSC_ACTION_2A_BUY_MENU_OPEN_WAIT, + aNSC_ACTION_0x2b_UNUSED, + aNSC_ACTION_PW_MSG_WIN_OPEN_WAIT, + aNSC_ACTION_PW_SEND_ADDR_CHECK, + aNSC_ACTION_PW_SEL_ITEM_START_WAIT, + aNSC_ACTION_2F_BUY_MENU_OPEN_WAIT, + aNSC_ACTION_0x30_UNUSED, + aNSC_ACTION_0x31_UNUSED, + aNSC_ACTION_PW_SEND_CHECK, + aNSC_ACTION_PW_RETRY_SEL_ITEM_CHECK, + aNSC_ACTION_PC_INPUT_PW_START_WAIT, + aNSC_ACTION_35_BUY_MENU_OPEN_WAIT, + aNSC_ACTION_0x36_UNUSED, + aNSC_ACTION_PC_MSG_WIN_OPEN_WAIT, + aNSC_ACTION_PC_RETRY_INPUT_PW_CHECK, + aNSC_ACTION_PC_PRESENT_START_WAIT, + aNSC_ACTION_PC_PRESENT_TRANS_TAKEOUT, + aNSC_ACTION_PC_PRESENT_TRANS_WAIT, + aNSC_ACTION_PC_PRESENT_END_WAIT, + aNSC_ACTION_WAIT, + aNSC_ACTION_0x3e_WAIT, + aNSC_ACTION_WALK_PL_OTHER_ZONE, + aNSC_ACTION_0x40_WAIT, + aNSC_ACTION_0x41_WALK_PL_OTHER_ZONE, + aNSC_ACTION_TURN, + aNSC_ACTION_GOODBYE_WAIT, + aNSC_ACTION_SAY_GOODBYE, + aNSC_ACTION_EXIT_WAIT, + aNSC_ACTION_NUM +}; + +enum aNSC_msg_no { + aNSC_MSG_WAIT = -0x1, + aNSC_MSG_REHOUSE_MEDIUM = 0x0, + aNSC_MSG_REHOUSE_MEDIUM_1, + aNSC_MSG_REHOUSE_MEDIUM_2, + aNSC_MSG_MEDIUM_BUILT, + aNSC_MSG_REHOUSE_2_OFFER, + aNSC_MSG_REHOUSE_2_LARGe, + aNSC_MSG_REHOUSE_2_BASEment, + aNSC_MSG_LARGE_BUILT, + aNSC_MSG_REHOUSE_STATUE, + aNSC_MSG_STATUE_BUILT, + aNSC_MSG_PALLET_SELECTED, + aNSC_MSG_PALLET_SELECT_1, + aNSC_MSG_PALLET_SELECT_2, + aNSC_MSG_PALLET_SELECT_3, + aNSC_MSG_PALLET_SELECT_4, + aNSC_MSG_OFFER_SELL_ALL, + aNSC_MSG_EVENT_DEPART, + aNSC_MSG_GREET_DEPART, + aNSC_MSG_SHOW_CLOTH, + aNSC_MSG_CONFIRM_CLOTH, + aNSC_MSG_CANCEL_CLOTH, + aNSC_MSG_CANCEL, + aNSC_MSG_START_CALL_NORMAL, + aNSC_MSG_INTERACT_START, + aNSC_MSG_INTERACT_CANCEl, + aNSC_MSG_KABU_INFO, + aNSC_MSG_SELL_START, + aNSC_MSG_SELL_OFFER, + aNSC_MSG_SELL_NORMAL, + aNSC_MSG_SELL_CANCEL, + aNSC_MSG_BUY_ONE_OFFER, + aNSC_MSG_BUY_CANCEL, + aNSC_MSG_THANKS, + aNSC_MSG_INSUFFICIENT_FUNDS, + aNSC_MSG_BUY_NORMAL, + aNSC_MSG_SAY_GOODBYE, + aNSC_MSG_KABU_ON_SUNDAY, + aNSC_MSG_EVENT, + aNSC_MSG_BREAK_BAG, + aNSC_MSG_POCKETS_FULL, + aNSC_MSG_SHOW_ITEM, + aNSC_MSG_SHOW_CARPET_OFFER, + aNSC_MSG_SHOW_CARPET_DECLINE, + aNSC_MSG_SHOW_CATALOGUE, + aNSC_MSG_ORDER_OFFER, + aNSC_MSG_ORDER_UNAVAILABLE, + aNSC_MSG_ORDER_CANCEL, + aNSC_MSG_ORDER_CONFIRM, + aNSC_MSG_ORDER_INSUFFICIENT_FUNDS, + aNSC_MSG_ORDER_FULL, + aNSC_MSG_ORDER_FURNITURE_ONLY, + aNSC_MSG_GIVE_TICKET, + aNSC_MSG_MAIL_TICKET, + aNSC_MSG_TICKET_1, + aNSC_MSG_TICKET_2, + aNSC_MSG_TICKET_SELL_REFUSE, + aNSC_MSG_SELL_QUEST, + aNSC_MSG_JUNK_ACCEPT, + aNSC_MSG_JUNK_CANCEL, + aNSC_MSG_SELL_SHOVEL = 0x64, + aNSC_MSG_SELL_NET, + aNSC_MSG_SELL_ROD, + aNSC_MSG_SELL_AXE, + aNSC_MSG_SELL_SIGN, + aNSC_MSG_MONEY_OVERFLOW = 0xc8, + aNSC_MSG_SELL_PAINT = 0xca, + aNSC_MSG_SELL_PAINT_CONFIRM, + aNSC_MSG_BASEMENT_BUILT, + aNSC_MSG_BASEMENT_PAID, + aNSC_MSG_REHOUSE_BASEMENT = 0xd0, + aNSC_MSG_REHOUSE_LARGE, + aNSC_MSG_REHOUSE_UPPER = 0xd4, + aNSC_MSG_UPPER_BUILT, + aNSC_MSG_BUY_MANY_OFFER, + aNSC_MSG_BUY_REFUSE_PLURAL = 0xd8, + aNSC_MSG_BALLOON = 0xda, + aNSC_MSG_BALLOON_DEPART = 0xdc, + aNSC_MSG_SELL_PAPER = 0xde, + aNSC_MSG_SELL_PAINT_FOREIGN, + aNSC_MSG_PSWD_NO_ITEM = 0x12c, + aNSC_MSG_PSWD_INFO = 0x12d, + aNSC_MSG_PSWD_SAME_NAME, + aNSC_MSG_PSWD_CONFIRM, + aNSC_MSG_PSWD_CANCEL = 0x131, + aNSC_MSG_PSWD_CHECK, + aNSC_MSG_OTHER = 0x135, + aNSC_MSG_RETURN, + aNSC_MSG_PSWD_INVENTORY_FULL, + aNSC_MSG_PSWD_SAY, + aNSC_MSG_PSWD_WRONG, + aNSC_MSG_PSWD_DECLINE, + aNSC_MSG_PSWD_GOOD_FAMICON, + aNSC_MSG_PSWD_GOOD_NPC, + aNSC_MSG_PSWD_GOOD_MAGAZINE_1, + aNSC_MSG_PSWD_CARDE, + aNSC_MSG_PSWD_GOOD_USER, + aNSC_MSG_PSWD_GOOD_CARDEM, + aNSC_MSG_PSWD_FOREIGN, + aNSC_MSG_PSWD_GOOD_MAGAZINE_2, + aNSC_MSG_GIFT_OUT, + aNSC_MSG_PSWD_BAD, + aNSC_MSG_TAKE_OFF_HANDS= 0x108a +}; + +enum aNSC_wait_type { + + aNSC_WAIT_TYPE_REHOUSE, + aNSC_WAIT_TYPE_DONE_REHOUSE, + aNSC_WAIT_TYPE_BALLOON, + aNSC_WAIT_TYPE_3, + aNSC_WAIT_TYPE_HRATALK, + + aNSC_WAIT_TYPE_NUM +}; + +enum aNSC_buy_outcome { + aNSC_BUY_OUTCOME_BREAK_BAG, + aNSC_BUY_OUTCOME_NORMAL, + aNSC_BUY_OUTCOME_CANCEL, + aNSC_BUY_OUTCOME_MONEY_OVERFLOW, + aNSC_BUY_OUTCOME_NUM +}; + +enum aNSC_check_buy { + aNSC_CHECK_BUY_NORMAL_SUB, + aNSC_CHECK_BUY_NONE_SELECTED, + aNSC_CHECK_BUY_NO_SUNDAY_TURNIPS, + aNSC_CHECK_BUY_REFUSE_QUEST_COND, + aNSC_CHECK_BUY_TAKE_OFF_HANDS, + aNSC_CHECK_BUY_OFFER_BUY_ALL, + aNSC_CHECK_BUY_PLURAL, + aNSC_CHECK_BUY_NORMAL, + + aNSC_RES_NUM +}; + +enum aNSC_tanni_str { + aNSC_TANNI_STR_00, + aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_03, + aNSC_TANNI_STR_KABU, + aNSC_TANNI_STR_FAUNA, + aNSC_TANNI_STR_SAPPLING, + aNSC_TANNI_STR_DIARY, + aNSC_TANNI_STR_08, + aNSC_TANNI_STR_09, + + aNSC_TANNI_STR_NUM +}; + +enum check_password_result { + aNSC_PSW_RES_0, + aNSC_PSW_GOOD_FAMICON, + aNSC_PSW_GOOD_NPC, + aNSC_PSW_GOOD_MAGAZINE_1, + aNSC_PSW_CARDE = 4, + aNSC_PSW_GOOD_USER, + aNSC_PSW_GOOD_CARDEM, + aNSC_PSW_GOOD_MAGAZINE_2, + aNSC_PSW_BAD = 8, + aNSC_PSW_RES_9 = 9, + + aNSC_PSW_NUM +}; + +enum aNSC_request_show_type { + aNSC_REQUEST_SHOW_TYPE_WALL, + aNSC_REQUEST_SHOW_TYPE_CARPET +}; + +enum aNSC_zone { + aNSC_ZONE_0, + aNSC_ZONE_1, + aNSC_ZONE_2, + aNSC_ZONE_3, + + aNSC_ZONE_NUM +}; + +typedef struct aNSC_animation_data_s { + int anim; + int talk_flag; +} aNSC_animation_data; + +extern ACTOR_PROFILE Npc_Shop_Master_Profile; + +#define aNSC_PLAYER_DISTANCE (f32)60.0 #ifdef __cplusplus extern "C" { #endif -extern ACTOR_PROFILE Npc_Shop_Master_Profile; - #ifdef __cplusplus } #endif +static void aNSC_setupAction(NPC_SHOP_MASTER_ACTOR *shop_master, GAME_PLAY* game, int p3); +static int aNSC_check_buy_item_sub(u32 *p1, mActor_name_t itm_name); +static int aNSC_check_buy_paper(u32 *p1, mActor_name_t itm_name); +static void aNSC_init_proc(NPC_SHOP_MASTER_ACTOR *shop_master, GAME_PLAY * game, int p3); + #endif diff --git a/include/m_home_h.h b/include/m_home_h.h index 4486ec0f..1d089397 100644 --- a/include/m_home_h.h +++ b/include/m_home_h.h @@ -85,7 +85,8 @@ typedef struct home_size_info_s { /* 0x05 */ u8 renew : 1; /* refresh house size & 'outlook' palette */ /* 0x05 */ u8 statue_ordered : 1; /* set when statue is ordered from Nook */ /* 0x05 */ u8 basement_ordered : 1; /* set when basement has been ordered */ - /* 0x05 */ u8 pad : 5; /* unused? */ + /* 0x05 */ u8 pad_1 : 1; /* unused? */ + /* 0x05 */ u8 pad : 4; } mHm_rmsz_c; /* sizeof(Haniwa_Item_c) == 8 */ diff --git a/include/m_name_table.h b/include/m_name_table.h index 9bb5cb9c..65244480 100644 --- a/include/m_name_table.h +++ b/include/m_name_table.h @@ -227,6 +227,7 @@ extern int mNT_check_unknown(mActor_name_t item_no); #define PAPER2TYPE(n) ((n) % PAPER_UNIQUE_NUM) #define PAPER2STACK(n) ((n) / PAPER_UNIQUE_NUM) +#define PAPEROFQUANT(n, q) (ITM_PAPER_START + (q - 1) * PAPER_UNIQUE_NUM + PAPER2TYPE(n)) #define ITEM_IS_FTR(n) \ (ITEM_NAME_GET_TYPE(n) == NAME_TYPE_FTR0 || ITEM_NAME_GET_TYPE(n) == NAME_TYPE_FTR1) diff --git a/src/actor/npc/ac_npc_shop_master.c b/src/actor/npc/ac_npc_shop_master.c new file mode 100644 index 00000000..0317a908 --- /dev/null +++ b/src/actor/npc/ac_npc_shop_master.c @@ -0,0 +1,3016 @@ +#include "ac_npc_shop_master.h" + +#include "m_shop.h" +#include "m_common_data.h" +#include "m_font.h" +#include "m_msg.h" +#include "m_private.h" +#include "m_string.h" +#include "m_actor_type.h" +#include "m_player_lib.h" +#include "m_mail_password_check.h" +#include "m_actor.h" +#include "m_actor_type.h" +#include "m_camera2.h" +#include "m_house.h" +#include "m_melody.h" +#include "m_scene.h" +#include "m_collision_bg.h" +#include "m_demo.h" +#include "m_player.h" +#include "m_bgm.h" +#include "ac_npc.h" +#include "ac_uki.h" +#include "ac_npc_anim_def.h" + +void aNSM_actor_ct(ACTOR* shop_master, GAME* game); +void aNSM_actor_dt(ACTOR* actorx, GAME* game); +void aNSM_actor_move(ACTOR* actorx, GAME* game); +void aNSM_actor_draw(ACTOR* actorx, GAME* game); +void aNSM_actor_init(ACTOR* actorx, GAME* game); +void aNSM_actor_save(ACTOR* actorx, GAME* game); + +static void aNSM_talk_request(ACTOR* actorx, GAME* game); +static int aNSM_talk_init(ACTOR* actorx, GAME* game); +static int aNSM_talk_end_chk(ACTOR* actorx, GAME* game); + +static void aNSC_BGcheck(ACTOR* actorx); +static void aNSC_set_zone_data(NPC_SHOP_MASTER_ACTOR* shop_master, ACTOR* actor); +static void aNSC_set_player_angl(NPC_SHOP_MASTER_ACTOR* shop_master); +static void aNSC_talk_demo_proc(ACTOR* actorx); +static void aNSC_sell_camera(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play); + +// clang-format off +ACTOR_PROFILE Npc_Shop_Master_Profile = { + mAc_PROFILE_NPC_SHOP_MASTER, + ACTOR_PART_NPC, + ACTOR_STATE_NONE, + SP_NPC_SHOP_MASTER, + ACTOR_OBJ_BANK_KEEP, + sizeof(NPC_SHOP_MASTER_ACTOR), +}; +// clang-format on + +void aNSM_actor_ct(ACTOR* actorx, GAME* game) { + static aNPC_ct_data_c ct_data = { &aNSM_actor_move, &aNSM_actor_draw, 0, &aNSM_talk_request, + &aNSM_talk_init, &aNSM_talk_end_chk, TRUE }; + + NPC_SHOP_MASTER_ACTOR* shop_master = (NPC_SHOP_MASTER_ACTOR*)actorx; + int action = 0; + + CLIP(npc_clip)->ct_proc(actorx, game, &ct_data); + + shop_master->npc_class.draw.main_animation.keyframe.morph_counter = 0.0f; + shop_master->sell_item = EMPTY_NO; + shop_master->npc_class.condition_info.hide_flg = FALSE; + shop_master->_9C0 = -1; + actorx->shape_info.draw_shadow = TRUE; + + if (Common_Get(door_data).door_actor_name == RSV_NO) { + shop_master->npc_class.talk_info.melody_inst = 0; + action = aNSC_ACTION_WAIT; + } else { + action = 0; + } + + aNSC_setupAction(shop_master, (GAME_PLAY*)game, action); +} + +void aNSM_actor_save(ACTOR* actorx, GAME* game) { + (CLIP(npc_clip)->save_proc)(actorx, game); +} + +void aNSM_actor_dt(ACTOR* actorx, GAME* game) { + (CLIP(npc_clip)->dt_proc)(actorx, game); +} + +void aNSM_actor_init(ACTOR* actorx, GAME* game) { + (CLIP(npc_clip)->init_proc)(actorx, game); +} + +void aNSM_actor_draw(ACTOR* actorx, GAME* game) { + (CLIP(npc_clip)->draw_proc)(actorx, game); +} + +u8 aNSM_get_zone(xyz_t* wpos) { + if (wpos->x < 120.0f) { + if (wpos->z < 180.0f) { + return aNSC_ZONE_1; + } else { + return aNSC_ZONE_2; + } + } + if (wpos->z < 160.0f) { + return aNSC_ZONE_0; + } else { + return aNSC_ZONE_3; + } +} + +u8 aNSM_get_next_zone(u8 p1, u8 p2) { + static u8 next_zone[16] = { aNSC_ZONE_0, aNSC_ZONE_1, aNSC_ZONE_1, aNSC_ZONE_1, aNSC_ZONE_0, aNSC_ZONE_1, + aNSC_ZONE_2, aNSC_ZONE_2, aNSC_ZONE_1, aNSC_ZONE_1, aNSC_ZONE_2, aNSC_ZONE_3, + aNSC_ZONE_2, aNSC_ZONE_2, aNSC_ZONE_2, aNSC_ZONE_3 }; + int t = p2 * 4; + return next_zone[t + p1]; +} + +void aNSM_search_player(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + ACTOR* actorx = (ACTOR*)shop_master; + PLAYER_ACTOR* player = GET_PLAYER_ACTOR(play); + + if (player != NULL) { + s16 angle = actorx->shape_info.rotation.y - shop_master->player_angle; + if (ABS(angle) > DEG2SHORT_ANGLE(90.0f)) { + aNSC_setupAction(shop_master, play, aNSC_ACTION_TURN); + } else { + chase_angle(&actorx->shape_info.rotation.y, shop_master->player_angle, DEG2SHORT_ANGLE(11.25f)); + actorx->world.angle.y = actorx->shape_info.rotation.y; + } + } +} + +void aNSM_search_player2(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + static f32 posX[4] = { 220.0, 100.0, 100.0, 220.0 }; + static f32 posZ[4] = { 140.0, 140.0, 220.0, 220.0 }; + PLAYER_ACTOR* player = GET_PLAYER_ACTOR(play); + if (player != NULL) { + f32 dz = posX[shop_master->next_zone] - shop_master->npc_class.actor_class.world.position.x; + f32 dx = posZ[shop_master->next_zone] - shop_master->npc_class.actor_class.world.position.z; + + s16 angle = atans_table(dx, dz); + chase_angle(&shop_master->npc_class.actor_class.shape_info.rotation.y, angle, DEG2SHORT_ANGLE(11.25f)); + + shop_master->npc_class.actor_class.world.angle.y = shop_master->npc_class.actor_class.shape_info.rotation.y; + + if (dz * dz + dx * dx < 200.0f) { + shop_master->next_zone = aNSM_get_next_zone(shop_master->player_zone, shop_master->zone); + } + } +} + +int aNSM_check_safe_zone(NPC_SHOP_MASTER_ACTOR* shop_master, PLAYER_ACTOR* player) { + int res = FALSE; + if (player->actor_class.world.position.z > 280.0f && shop_master->zone == 3) { + res = TRUE; + } + return res; +} + +void aNSM_actor_move(ACTOR* actorx, GAME* game) { + NPC_SHOP_MASTER_ACTOR* shop_master = (NPC_SHOP_MASTER_ACTOR*)actorx; + GAME_PLAY* play = (GAME_PLAY*)game; + PLAYER_ACTOR* player = GET_PLAYER_ACTOR(play); + CLIP(npc_clip)->move_before_proc(actorx, game); + aNSC_BGcheck(actorx); + aNSC_set_zone_data(shop_master, (ACTOR*)player); + aNSC_set_player_angl(shop_master); + (shop_master->proc)(shop_master, play); + aNSC_talk_demo_proc(actorx); + CLIP(npc_clip)->move_after_proc(actorx, game); + aNSC_sell_camera(shop_master, play); +} + +static void aNSC_set_animation(NPC_SHOP_MASTER_ACTOR* shop_master, int action) { + static aNSC_animation_data anime[70] = { + { aNPC_ANIM_WAIT1, FALSE }, { aNPC_ANIM_WALK1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, + { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WALK1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, + { aNPC_ANIM_WALK1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WALK1, TRUE }, + { aNPC_ANIM_TRANSFER1, TRUE }, { aNPC_ANIM_TRANS_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, + { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, + { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, + { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, + { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, + { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, + { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, + { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, + { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, + { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, + { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, + { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, + { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, + { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, + { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, + { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, TRUE }, + { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_TRANSFER1, TRUE }, { aNPC_ANIM_TRANS_WAIT1, TRUE }, + { aNPC_ANIM_WAIT1, TRUE }, { aNPC_ANIM_WAIT1, FALSE }, { aNPC_ANIM_WALK1, FALSE }, + { aNPC_ANIM_WALK1, FALSE }, { aNPC_ANIM_RUN1, FALSE }, { aNPC_ANIM_RUN1, FALSE }, + { aNPC_ANIM_WALK1, FALSE }, { aNPC_ANIM_WAIT1, FALSE }, { aNPC_ANIM_WAIT1, TRUE }, + { aNPC_ANIM_WAIT1, FALSE } + }; + + aNSC_animation_data* data = &anime[action]; + CLIP(npc_clip)->animation_init_proc((ACTOR*)shop_master, data->anim, data->talk_flag); +} + +static void aNSC_BGcheck(ACTOR* actor) { + mCoBG_BgCheckControll(NULL, actor, 8.0f, 0.0f, 1, 0, 0); +} + +static int aNSC_check_present_balloon() { + int idx; + int res = 0; + + if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_EVENT && + (Common_Get(spnpc_first_talk_flags) & (1 << aNPC_SPNPC_BIT_SHOP_MASTER)) == 0) { + idx = mPr_GetPossessionItemIdx(Now_Private, EMPTY_NO); + if (idx != -1) { + res = 1; + } + } + + return res; +} + +static void aNSC_calc_talk_start_tim(NPC_SHOP_MASTER_ACTOR* shop_master) { + int ivar1 = shop_master->_9C0; + if (ivar1 <= -1) { + ivar1 = 0xb4; + } else if (ivar1 != 0) { + ivar1 -= 1; + } + shop_master->_9C0 = ivar1; +} + +static u8 aNSC_item1_0_tanni_type[256] = { + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD +}; + +static u8 aNSC_item1_1_tanni_type[4] = { aNSC_TANNI_STR_SAPPLING, aNSC_TANNI_STR_SAPPLING, aNSC_TANNI_STR_SAPPLING, + aNSC_TANNI_STR_SAPPLING }; + +static u8 aNSC_item1_2_tanni_type[92] = { + aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, + aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, + aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, + aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, + aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, + aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, + aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, + aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, + aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, + aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, + aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, + aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, + aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_03, aNSC_TANNI_03, + aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, + aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, aNSC_TANNI_03, + aNSC_TANNI_03, aNSC_TANNI_03 +}; +static u8 aNSC_item1_3_tanni_type[40] = { + aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, + aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, + aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, + aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, + aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, + aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, + aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, + aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA +}; + +static u8 aNSC_item1_4_tanni_type[255] = { + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, + aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH, aNSC_TANNI_STR_CLOTH +}; + +static u8 aNSC_item1_5_tanni_type[49] = { + aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, + aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, + aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, + aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, + aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, + aNSC_TANNI_03, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, + aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, + aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, + aNSC_TANNI_STR_00 +}; + +static u8 aNSC_item1_6_tanni_type[67] = { + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD +}; + +static u8 aNSC_item1_7_tanni_type[67] = { + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD +}; + +static u8 aNSC_item1_8_tanni_type[8] = { aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00, + aNSC_TANNI_STR_00, aNSC_TANNI_03, aNSC_TANNI_STR_00, aNSC_TANNI_STR_00 }; + +static u8 aNSC_item1_9_tanni_type[11] = { aNSC_TANNI_STR_DIARY, aNSC_TANNI_STR_DIARY, aNSC_TANNI_STR_SAPPLING, + aNSC_TANNI_STR_SAPPLING, aNSC_TANNI_STR_SAPPLING, aNSC_TANNI_STR_SAPPLING, + aNSC_TANNI_STR_SAPPLING, aNSC_TANNI_STR_SAPPLING, aNSC_TANNI_STR_SAPPLING, + aNSC_TANNI_STR_SAPPLING, aNSC_TANNI_STR_SAPPLING }; + +static u8 aNSC_item1_A_tanni_type[55] = { + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD +}; + +static u8 aNSC_item1_B_tanni_type[16] = { aNSC_TANNI_STR_09, aNSC_TANNI_STR_09, aNSC_TANNI_STR_09, aNSC_TANNI_STR_09, + aNSC_TANNI_STR_09, aNSC_TANNI_STR_09, aNSC_TANNI_STR_09, aNSC_TANNI_STR_09, + aNSC_TANNI_STR_09, aNSC_TANNI_STR_09, aNSC_TANNI_STR_09, aNSC_TANNI_STR_09, + aNSC_TANNI_STR_09, aNSC_TANNI_STR_09, aNSC_TANNI_STR_09, aNSC_TANNI_STR_09 }; + +static u8 aNSC_item1_C_tanni_type[96] = { + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, aNSC_TANNI_STR_COMMOD, + aNSC_TANNI_STR_COMMOD +}; + +static u8 aNSC_item1_D_tanni_type[45] = { + aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, + aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, + aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, + aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, + aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, + aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, + aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, + aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, + aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA, aNSC_TANNI_STR_FAUNA +}; + +static u8 aNSC_item1_E_tanni_type[2] = { aNSC_TANNI_STR_SAPPLING, aNSC_TANNI_STR_SAPPLING }; + +static u8 aNSC_item1_F_tanni_type[4] = { aNSC_TANNI_STR_KABU, aNSC_TANNI_STR_KABU, aNSC_TANNI_STR_KABU, + aNSC_TANNI_STR_KABU }; + +static u8* aNSC_item_tanni_type[16] = { aNSC_item1_0_tanni_type, aNSC_item1_1_tanni_type, aNSC_item1_2_tanni_type, + aNSC_item1_3_tanni_type, aNSC_item1_4_tanni_type, aNSC_item1_5_tanni_type, + aNSC_item1_6_tanni_type, aNSC_item1_7_tanni_type, aNSC_item1_8_tanni_type, + aNSC_item1_9_tanni_type, aNSC_item1_A_tanni_type, aNSC_item1_B_tanni_type, + aNSC_item1_C_tanni_type, aNSC_item1_D_tanni_type, aNSC_item1_E_tanni_type, + aNSC_item1_F_tanni_type }; + +static void aNSC_request_show_camera(GAME_PLAY* play, int p2) { + static xyz_t pcenter[2][2] = { { { 160.0, 85.0, 180.0 }, { 160.0, 60.0, 285.0 } }, + { { 160.0, 85.0, 260.0 }, { 160.0, 60.0, 365.0 } } }; + static xyz_t peye[2][2] = { { { 160.0, 235.0, 900.0 }, { 160.0, 475.0, 840.0 } }, + { { 160.0, 285.0, 980.0 }, { 160.0, 475.0, 920.0 } } }; + int i; + + int level = mSP_GetShopLevel(); + i = (level == 3); + + Camera2_request_BuySikimono_WallPaper(play, &pcenter[i][p2], &peye[i][p2]); +} + +static void aNSC_Set_ListenAble(NPC_SHOP_MASTER_ACTOR* shop_master) { + mMld_ActorMakeMelody((ACTOR*)shop_master); + mDemo_Set_ListenAble(); +} + +static void aNSC_set_sell_camera(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + PLAYER_ACTOR* player; + xyz_t wpos; + f32 bg_y; + + player = GET_PLAYER_ACTOR(play); + mFI_UtNum2CenterWpos(&wpos, shop_master->ut_x, shop_master->ut_y); + bg_y = mCoBG_GetBgY_OnlyCenter_FromWpos2(wpos, -40.0); + wpos.y = bg_y; + Camera2_request_main_talk_pos(play, (ACTOR*)player, &wpos, 5); +} + +static void aNSC_sell_camera(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (shop_master->action >= aNSC_ACTION_SELL_CHECK_BEFORE && shop_master->action <= aNSC_ACTION_CHG_CLOTH_END_WAIT) { + switch (ITEM_NAME_GET_TYPE(shop_master->sell_item)) { + case NAME_TYPE_FTR0: + case NAME_TYPE_FTR1: + aNSC_set_sell_camera(shop_master, play); + break; + case NAME_TYPE_ITEM1: + switch (ITEM_NAME_GET_CAT(shop_master->sell_item)) { + case ITEM1_CAT_CLOTH: + break; + case ITEM1_CAT_TOOL: + if (ITEM_IS_UMBRELLA2(shop_master->sell_item)) { + break; + } + // fall through + default: + return; + } + aNSC_set_sell_camera(shop_master, play); + break; + } + } +} + +static void aNSC_talk_demo_proc(ACTOR* actorx) { + if (mDemo_Check(mDemo_TYPE_SPEAK, actorx) == TRUE || mDemo_Check(mDemo_TYPE_TALK, actorx) == TRUE) { + CLIP(npc_clip)->talk_demo_proc(actorx); + } +} + +static void aNSC_set_stop_spd(NPC_SHOP_MASTER_ACTOR* shop_master) { + shop_master->npc_class.actor_class.speed = 0.0; + shop_master->npc_class.movement.max_speed = 0.0; + shop_master->npc_class.movement.acceleration = 0.0; + shop_master->npc_class.movement.deceleration = 0.0; +} + +static void aNSC_set_walk_spd(NPC_SHOP_MASTER_ACTOR* shop_master) { + shop_master->npc_class.movement.max_speed = 1.0; + shop_master->npc_class.movement.acceleration = 0.1; + shop_master->npc_class.movement.deceleration = 0.2; +} + +static void aNSC_set_run_spd(NPC_SHOP_MASTER_ACTOR* shop_master) { + shop_master->npc_class.movement.max_speed = 4.0; + shop_master->npc_class.movement.acceleration = 0.4; + shop_master->npc_class.movement.deceleration = 0.8; +} + +static void aNSC_set_rehouse_order_date(mHm_hs_c* home) { + lbRTC_time_c* now = &Common_Get(time).rtc_time; + home->size_info.upgrade_order_date.year = now->year; + home->size_info.upgrade_order_date.month = now->month; + home->size_info.upgrade_order_date.day = now->day; +} + +static void aNSC_set_make_basement_info() { + int arrange_idx = mHS_get_arrange_idx(Common_Get(player_no)); + mHm_hs_c* home = &Save_Get(homes)[arrange_idx]; + home->size_info.basement_ordered = TRUE; + aNSC_set_rehouse_order_date(home); +} + +static mPr_catalog_order_c* aNSC_getP_free_ftr_order() { + int i; + mPr_catalog_order_c* order = Now_Private->catalog_orders; + + for (i = 0; i < 5; i++) { + if (order->item == EMPTY_NO) { + return order; + } + order += sizeof(u8); + } + return NULL; +} + +static void aNSC_set_ftr_order(NPC_SHOP_MASTER_ACTOR* actor) { + mPr_catalog_order_c* order = aNSC_getP_free_ftr_order(); + order->item = actor->order_item; + order->shop_level = Save_Get(shop).shop_info.shop_level; +} + +static void aNSC_set_last_day_str() { + u8 buff[8]; + u16 day = (u16)lbRTC_GetDaysByMonth(Common_Get(time).rtc_time.year, Common_Get(time).rtc_time.month); + + mString_Load_DayStringFromRom(buff, day); + mMsg_Set_free_str(mMsg_Get_base_window_p(), mMsg_FREE_STR5, buff, 4); +} + +static void aNSC_set_pw_name_str(NPC_SHOP_MASTER_ACTOR* shop_master) { + mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); + mMsg_Set_free_str(msg_win, mMsg_FREE_STR6, shop_master->pw_town_str, aNSC_PW_TOWN_STR_LEN); + mMsg_Set_free_str(msg_win, mMsg_FREE_STR7, shop_master->pw_recip_str, aNSC_PW_RECIP_STR_LEN); +} + +static void aNSC_set_value_str(int p1, int p2) { + u8 value_str[16]; + + mFont_UnintToString(value_str, sizeof(value_str), p1, 0x10, TRUE, FALSE, TRUE); + mMsg_Set_free_str(mMsg_Get_base_window_p(), p2, value_str, 0x10); +} + +static void aNSC_set_item_name_str(mActor_name_t itm, u32 p2) { + u8 buff[16]; + u32 art; + mMsg_Window_c* msg_win; + + mIN_copy_name_str(buff, itm); + art = mIN_get_item_article(itm); + mMsg_Set_item_str_art(mMsg_Get_base_window_p(), p2, buff, 0x10, art); +} + +static void aNSC_set_item_str(NPC_SHOP_MASTER_ACTOR* shop_master, mActor_name_t itm) { + u32 value; + u16 item = shop_master->sell_item; + aNSC_set_item_name_str(item, 0); + value = mSP_ItemNo2ItemPrice(item); + aNSC_set_value_str(value, 4); + shop_master->value = value; +} + +static void aNSC_set_pw_password_str(NPC_SHOP_MASTER_ACTOR* shop_master) { + mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); + u8* msg = shop_master->password_str; + mMsg_Set_item_str(msg_win, mMsg_ITEM_STR3, msg, 14); + mMsg_Set_item_str(msg_win, mMsg_ITEM_STR4, &msg[14], 14); +} + +static void aNSC_set_pw_info_str(NPC_SHOP_MASTER_ACTOR* shop_master) { + mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); + mMsg_Set_free_str(msg_win, mMsg_FREE_STR6, shop_master->password.str1, 8); + mMsg_Set_free_str(msg_win, mMsg_FREE_STR7, shop_master->password.str0, 8); + aNSC_set_item_name_str(shop_master->password.item, 2); +} + +static int aNSC_pc_check_password_famicom(mMpswd_password_c* pswd) { + int res = aNSC_PSW_RES_0; + if (pswd->hit_rate_index == 1) { + if (mMpswd_check_name(pswd) == TRUE) { + res = aNSC_PSW_GOOD_FAMICON; + } else { + res = aNSC_PSW_BAD; + } + } + return res; +} + +static int aNSC_pc_check_password_npc(mMpswd_password_c* pswd) { + int res = aNSC_PSW_RES_0; + if (pswd->hit_rate_index == 1 && mMpswd_check_npc_code(pswd) == TRUE) { + if (mMpswd_check_name(pswd) == TRUE) { + res = aNSC_PSW_GOOD_NPC; + } else { + res = aNSC_PSW_BAD; + } + } + return res; +} + +static int aNSC_pc_check_password_card_e(mMpswd_password_c* pswd) { + return aNSC_PSW_CARDE; +} + +static int aNSC_pc_check_password_magazine(mMpswd_password_c* pswd) { + static f32 hit_rate_magazine[5] = { 80.0, 60.0, 30.0, 0.0, 100.0 }; + int res = 0; + + if (pswd->hit_rate_index <= 4) { + if (RANDOM_F(100.0) < hit_rate_magazine[pswd->hit_rate_index]) { + res = aNSC_PSW_GOOD_MAGAZINE_1; + } else { + res = aNSC_PSW_GOOD_MAGAZINE_2; + } + } + return res; +} + +static int aNSC_pc_check_password_card_e_mini(mMpswd_password_c* pswd) { + int res = aNSC_PSW_RES_0; + if (pswd->hit_rate_index == 1) { + res = aNSC_PSW_GOOD_CARDEM; + } + return res; +} + +static int aNSC_pc_check_password_user(mMpswd_password_c* pswd) { + int res = aNSC_PSW_RES_0; + if (pswd->hit_rate_index == 1) { + if (mMpswd_check_name(pswd) == TRUE) { + res = aNSC_PSW_GOOD_USER; + } else { + res = aNSC_PSW_BAD; + } + } + return res; +} + +static int aNSC_pc_check_password(NPC_SHOP_MASTER_ACTOR* shop_master) { + static aNSC_PC_CHECK_PASSWORD_PROC pc_check_password_proc[6] = { + aNSC_pc_check_password_famicom, aNSC_pc_check_password_npc, aNSC_pc_check_password_card_e, + aNSC_pc_check_password_magazine, aNSC_pc_check_password_card_e_mini, aNSC_pc_check_password_user + }; + + int res = aNSC_PSW_RES_0; + u8 buff[24]; + + if (shop_master->password_str[mMpswd_PASSWORD_STR_LEN - 1] == CHAR_SPACE) { + res = aNSC_PSW_RES_9; + } else { + if (mMpswd_decode_code(buff, shop_master->password_str) == TRUE) { + mMpswd_password_c* password = &shop_master->password; + + mMpswd_password(buff, password); + if (mMpswd_password_zuru_check(password) == FALSE && mMpswd_check_present(password) == TRUE) { + aNSC_set_pw_password_str(shop_master); + aNSC_set_pw_info_str(shop_master); + res = pc_check_password_proc[password->type](password); + } + } + } + + return res; +} + +static int aNSC_check_possession_item_make_password(NPC_SHOP_MASTER_ACTOR* shop_master) { + mActor_name_t* item; + int flags; + int i; + int res; + + flags = 0; + res = 0; + + item = Now_Private->inventory.pockets; + for (i = 0; i < 15; i++) { + if ((*item != EMPTY_NO) && (mPr_GET_ITEM_COND(Now_Private->inventory.item_conditions, i) == 0) && + mMpswd_check_present_user(*item) == TRUE) { + res = 1; + flags |= (1 << i); + } + item += 1; + } + shop_master->password_flags = flags; + + return res; +} + +static void aNSC_set_buy_sum_str(mActor_name_t item, u32 p2) { + static int tanni_string_num[10] = { 0x566, 0x575, 0x584, 0x593, 0x5a2, 0x5b1, 0x5c0, 0x5cf, 0x5de, 0x5ed }; + mActor_name_t type; + u8 buff[16]; + u32 str_no; + + aNSC_set_item_name_str(item, mMsg_ITEM_STR2); + aNSC_set_value_str(p2, 7); + + switch (ITEM_NAME_GET_TYPE(item)) { + case NAME_TYPE_ITEM1: + str_no = p2 + tanni_string_num[aNSC_item_tanni_type[ITEM_NAME_GET_CAT((mActor_name_t)item)] + [ITEM_NAME_GET_INDEX(item)]]; + str_no -= 1; + break; + case NAME_TYPE_FTR0: + case NAME_TYPE_FTR1: + str_no = p2 + 0x565; + break; + default: + str_no = p2 + 0x565; + break; + } + + mString_Load_StringFromRom(buff, 0x10, str_no); + mMsg_Set_free_str(mMsg_Get_base_window_p(), 8, buff, 0x10); +} + +static int aNSC_decide_next_move_act(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + int res; + PLAYER_ACTOR* player; + if ((shop_master->npc_class.collision.pipe.collision_obj.collision_flags0 & 0x2) != 0) { + return aNSC_ACTION_WAIT; + } else { + player = GET_PLAYER_ACTOR(play); + if (player == NULL) { + return shop_master->action; + } + if (aNSM_check_safe_zone(shop_master, player) == TRUE) { + return aNSC_ACTION_WAIT; + } else { + if (shop_master->npc_class.actor_class.player_distance_xz < aNSC_PLAYER_DISTANCE || + shop_master->_9C0 == 0) { + return aNSC_ACTION_WAIT; + } else { + f32 player_distance_xz = shop_master->npc_class.actor_class.player_distance_xz; + if (shop_master->player_zone != shop_master->zone) { + if (shop_master->action != 0x3f && shop_master->action != 0x41) { + shop_master->next_zone = aNSM_get_next_zone(shop_master->player_zone, shop_master->zone); + } + if (player_distance_xz < 90.0f) { + return aNSC_ACTION_WALK_PL_OTHER_ZONE; + } else { + return aNSC_ACTION_0x41_WALK_PL_OTHER_ZONE; + } + } else { + shop_master->next_zone = shop_master->zone; + if (player_distance_xz < 90.0f) { + return aNSC_ACTION_0x3e_WAIT; + } else { + return aNSC_ACTION_0x40_WAIT; + } + } + } + } + } +} + +static void aNSC_set_zone_data(NPC_SHOP_MASTER_ACTOR* shop_master, ACTOR* a2) { + ACTOR* actorx = (ACTOR*)shop_master; + xyz_t pos1; + xyz_t pos2; + + pos1 = shop_master->npc_class.actor_class.world.position; + shop_master->zone = aNSM_get_zone(&pos1); + + if (a2 != NULL) { + pos2 = a2->world.position; + shop_master->player_zone = aNSM_get_zone(&pos2); + } +} + +static void aNSC_set_player_angl(NPC_SHOP_MASTER_ACTOR* shop_master) { + shop_master->player_angle = shop_master->npc_class.actor_class.player_angle_y; +} + +static int aNSC_money_check(u32 amount) { + return mSP_money_check(amount); +} + +static void aNSC_get_sell_price(u32 amount) { + mSP_get_sell_price(amount); +} + +static int aNSC_check_money_overflow(u32 p1, u32 counter) { + u32 bags; + int empty_spaces; + int res = FALSE; + + empty_spaces = mPr_GetPossessionItemSum(Now_Private, EMPTY_NO); + bags = 0; + for (; p1 >= mPr_WALLET_MAX; p1 -= 30000) { + bags += 1; + } + + if (bags <= empty_spaces + counter) { + res = TRUE; + } + return res; +} + +static int aNSC_check_buy_item_sub(u32* quant, mActor_name_t itm_name) { + int i; + mActor_name_t* item = Now_Private->inventory.pockets; + int res = aNSC_CHECK_BUY_NORMAL_SUB; + + for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { + if (*item == itm_name) { + if (!((NowPrivate_GetItemCond(i) & mPr_ITEM_COND_QUEST) || + (NowPrivate_GetItemCond(i) & mPr_ITEM_COND_PRESENT))) { + *quant += 1; + } + } + item += 1; + } + if (*quant > 1) { + aNSC_set_buy_sum_str(itm_name, *quant); + res = aNSC_CHECK_BUY_OFFER_BUY_ALL; + } + return res; +} + +static int aNSC_check_buy_paper(u32* quant, mActor_name_t itm_name) { + int i; + int res = 0; + mActor_name_t* pockets = Now_Private->inventory.pockets; + int paper_type = PAPER2TYPE(itm_name - ITM_PAPER_START); + + for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { + mActor_name_t item = *pockets; + if (ITEM_IS_PAPER(item)) { + if (PAPER2TYPE(item - ITM_PAPER_START) == paper_type) { + if (!((NowPrivate_GetItemCond(i) & mPr_ITEM_COND_QUEST) || + (NowPrivate_GetItemCond(i) & mPr_ITEM_COND_PRESENT))) { + *quant += PAPER2STACK(item - ITM_PAPER_START) + 1; + } + } + } + pockets++; + } + if (*quant > 1) { + aNSC_set_buy_sum_str(itm_name, *quant); + res = aNSC_CHECK_BUY_OFFER_BUY_ALL; + } + return res; +} + +static int aNSC_check_buy_item_single(NPC_SHOP_MASTER_ACTOR* nook, Submenu* menu) { + + mActor_name_t item = menu->item_p[0].item; + Submenu_Item_c* item_p = &menu->item_p[0]; + + u32 res = aNSC_CHECK_BUY_NORMAL_SUB; + u32 quant = 0; + + if (NowPrivate_GetItemCond(item_p->slot_no) & mPr_ITEM_COND_QUEST) { + res = aNSC_CHECK_BUY_REFUSE_QUEST_COND; + } else if (ITEM_NAME_GET_TYPE(item) == NAME_TYPE_ITEM1 && ITEM_NAME_GET_CAT(item) == ITEM1_CAT_KABU) { + if (item == ITM_KABU_SPOILED) { + res = aNSC_CHECK_BUY_TAKE_OFF_HANDS; + quant = 1; + } else if (Common_Get(time).rtc_time.weekday == lbRTC_SUNDAY) { + res = aNSC_CHECK_BUY_NO_SUNDAY_TURNIPS; + } else { + res = aNSC_check_buy_item_sub(&quant, item); + } + } else { + if (mSP_ItemNo2ItemPrice(item) / SELL_BUY_RATIO == 0) { + res = aNSC_CHECK_BUY_TAKE_OFF_HANDS; + quant = 1; + } else if (ITEM_IS_PAPER(item)) { + res = aNSC_check_buy_paper(&quant, item); + } else { + res = aNSC_check_buy_item_sub(&quant, item); + } + } + + nook->counter = quant; + return res; +} + +static int aNSC_check_buy_item_plural(NPC_SHOP_MASTER_ACTOR* nook, Submenu* menu) { + Submenu_Item_c* selected = menu->item_p; + + u32 num_selected = menu->selected_item_num; + int res = aNSC_CHECK_BUY_NORMAL; + nook->counter = num_selected; + + while (num_selected) { + if (ITEM_NAME_GET_TYPE(selected->item) == NAME_TYPE_ITEM1) { + if (ITEM_NAME_GET_CAT(selected->item) == ITEM1_CAT_KABU) { + res = aNSC_CHECK_BUY_PLURAL; + break; + } + } + if (mSP_ItemNo2ItemPrice(selected->item) / SELL_BUY_RATIO != 0) { + res = aNSC_CHECK_BUY_PLURAL; + break; + } + + selected += 1; + num_selected -= 1; + } + + return res; +} + +static int aNSC_check_buy_item(NPC_SHOP_MASTER_ACTOR* sm, Submenu* menu) { + if (menu->selected_item_num == 1) { + return aNSC_check_buy_item_single(sm, menu); + } else { + return aNSC_check_buy_item_plural(sm, menu); + } +} + +static int aNSC_check_item_with_ticket(mActor_name_t item) { + int type; + int cat; + int res; + + type = ITEM_NAME_GET_TYPE(item); + res = FALSE; + + switch (ITEM_NAME_GET_TYPE(item)) { + case NAME_TYPE_FTR0: + case NAME_TYPE_FTR1: + return TRUE; + case NAME_TYPE_ITEM1: + switch (ITEM_NAME_GET_CAT(item)) { + case ITEM1_CAT_CLOTH: + case ITEM1_CAT_WALL: + case ITEM1_CAT_CARPET: + res = TRUE; + break; + case ITEM1_CAT_TOOL: + if (item >= ITM_UMBRELLA_START && item <= ITM_UMBRELLA_END - 1) { + res = TRUE; + } + break; + } + } + + return res; +} + +static void aNSC_setup_ticket_remain() { + s32 tickets = Now_Private->inventory.lotto_ticket_mail_storage; + + if (Common_Get(time).rtc_time.month != Now_Private->inventory.lotto_ticket_expiry_month) { + tickets = 0; + Now_Private->inventory.lotto_ticket_expiry_month = Common_Get(time).rtc_time.month; + } + tickets++; + if (tickets > aNSC_MAX_TICKETS) { + tickets = aNSC_MAX_TICKETS; + } + Now_Private->inventory.lotto_ticket_mail_storage = tickets; +} + +static int aNSC_check_same_month_ticket(mActor_name_t ticket) { + int res = FALSE; + + mActor_name_t new_ticket = ticket; + int idx = mPlib_Get_space_putin_item_forTICKET(&new_ticket); + if (idx != -1) { + mPr_SetPossessionItem(Now_Private, idx, new_ticket, mPr_ITEM_COND_NORMAL); + res = TRUE; + } + return res; +} + +static int aNSC_get_msg_no(int msg_no) { + int res = 0x82a; + if (msg_no < 0) { + return res; + } else if (msg_no < 100) { + res = msg_no + 0x107b; + } else if (msg_no < 200) { + res = msg_no + 0x2baf; + } else if (msg_no < 300) { + res = msg_no + 0x2de6; + } else { + res = msg_no + 0x3cd2; + } + return res; +} + +static void aNSC_Set_continue_msg_num(mMsg_Window_c* msg_p, NPC_SHOP_MASTER_ACTOR* shop_master, int msg_no) { + mMsg_Set_continue_msg_num(msg_p, msg_no); + shop_master->msg_no = msg_no; +} + +static void aNSC_ChangeMsgData(mMsg_Window_c* msg_p, NPC_SHOP_MASTER_ACTOR* shop_master, int msg_no) { + mMsg_ChangeMsgData(msg_p, msg_no); + shop_master->msg_no = msg_no; +} + +static void aNSC_set_player_angle() { + PLAYER_ACTOR* player_actor; + s_xyz angle; + xyz_t wpos; + + player_actor = GET_PLAYER_ACTOR_NOW(); + + wpos.x = ((f32)((int)player_actor->forward_ut_pos.x / mFI_UT_WORLDSIZE_X) + 0.5f) * mFI_UT_WORLDSIZE_X_F; + wpos.z = ((f32)((int)player_actor->forward_ut_pos.z / mFI_UT_WORLDSIZE_Z) + 0.5f) * mFI_UT_WORLDSIZE_Z_F; + + angle.y = atans_table(wpos.z - player_actor->actor_class.world.position.z, + wpos.x - player_actor->actor_class.world.position.x); + + GET_PLAYER_ACTOR_NOW()->Set_force_position_angle_proc(gamePT, &player_actor->actor_class.world.position, &angle, + mPlayer_FORCE_POSITION_ANGLE_ROTY); +} + +static void aNSC_set_talk_info_show_item(NPC_SHOP_MASTER_ACTOR* actor, mActor_name_t item) { + aNSC_set_item_str(actor, item); + aNSC_set_player_angle(); + mDemo_Set_camera(CAMERA2_PROCESS_NORMAL); + mDemo_Set_msg_num(aNSC_get_msg_no(aNSC_MSG_SHOW_ITEM)); +} + +static void aNSC_set_talk_info_show_cloth(NPC_SHOP_MASTER_ACTOR* actor, mActor_name_t cloth) { + PositionAngle pa; + aNSC_set_item_str(actor, cloth); + aNSC_set_player_angle(); + mDemo_Set_camera(CAMERA2_PROCESS_NUM); + mDemo_Set_msg_num(aNSC_get_msg_no(aNSC_MSG_SHOW_CLOTH)); +} + +static void aNSC_set_talk_info_sell_item(NPC_SHOP_MASTER_ACTOR* actor, mActor_name_t p2) { + mActor_name_t item = actor->sell_item; + u8 camera_type; + int msg_no = aNSC_MSG_BUY_ONE_OFFER; + + aNSC_set_item_str(actor, p2); + aNSC_set_player_angle(); + + if (ITEM_NAME_GET_TYPE(item) == NAME_TYPE_FTR0 || ITEM_NAME_GET_TYPE(item) == NAME_TYPE_FTR1 || + (ITM_UMBRELLA_START <= item && item <= ITM_UMBRELLA_END - 1)) { + camera_type = mDemo_TYPE_EVENTMSG; + } else { + camera_type = mDemo_TYPE_SCROLL; + } + + if (item >= ITM_RED_PAINT && item <= ITM_BROWN_PAINT) { + if (mLd_PlayerManKindCheck() == FALSE) { + msg_no = aNSC_MSG_SELL_PAINT; + } else { + msg_no = aNSC_MSG_SELL_PAINT_FOREIGN; + } + } else { + if (item >= ITM_PAPER_START && item <= ITM_PAPER_END - 1) { + msg_no = aNSC_MSG_SELL_PAPER; + } + } + + mDemo_Set_camera(camera_type); + mDemo_Set_msg_num(aNSC_get_msg_no(msg_no)); +} + +static void aNSC_set_talk_info_message_ctrl() { + mDemo_Set_msg_num(aNSC_get_msg_no(aNSC_MSG_INTERACT_START)); +} + +static void aNSC_set_talk_info_message_ctrl_aprilfool(ACTOR* actorx, GAME* game) { + int msg_num = Common_Get(clip).aprilfool_control_clip->get_msg_num_proc(SP_NPC_SHOP_MASTER, 0); + mDemo_Set_msg_num(msg_num); +} + +static void aNSC_set_talk_info_message_ctrl_tokubai() { + int msg_num = aNSC_get_msg_no(aNSC_MSG_GREET_DEPART); + mDemo_Set_msg_num(msg_num); +} + +static int aNSC_message_ctrl(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(play); + int res = 0; + + if (player != NULL && CLIP(shop_design_clip) != NULL) { + if (player->item_in_front == EXIT_DOOR1) { + aNSC_setupAction(shop_master, play, aNSC_ACTION_GOODBYE_WAIT); + res = TRUE; + } else { + ACTOR* actorx = (ACTOR*)shop_master; + int action = 0; + if (mDemo_Check(mDemo_TYPE_SPEAK, actorx) == TRUE) { + if (mDemo_Check_ListenAble() == FALSE) { + aNSC_calc_talk_start_tim(shop_master); + if (shop_master->npc_class.actor_class.player_distance_xz < 80.0f || shop_master->_9C0 == 0) { + if (chase_angle(&shop_master->npc_class.actor_class.shape_info.rotation.y, + shop_master->player_angle, DEG2SHORT_ANGLE(11.25f)) == TRUE) { + mActor_name_t item = shop_master->sell_item; + if (item != EMPTY_NO) { + action = aNSC_ACTION_SELL_CHECK_BEFORE; + if (ITEM_NAME_GET_TYPE(item) == NAME_TYPE_ITEM1) { + switch (ITEM_NAME_GET_CAT(item)) { + case ITEM1_CAT_CLOTH: + case ITEM1_CAT_CARPET: + case ITEM1_CAT_WALL: + action = aNSC_ACTION_SHOW_ITEM_CHECK; + break; + default: + if (item >= ITM_RED_PAINT && item <= ITM_BROWN_PAINT) { + if (mLd_PlayerManKindCheck() != FALSE) { + action = aNSC_ACTION_REQUEST_Q_END_WAIT; + } + } + break; + } + } + aNSC_setupAction(shop_master, play, action); + } + aNSC_Set_ListenAble(shop_master); + shop_master->_9C0 = -1; + res = TRUE; + } + actorx->world.angle.y = actorx->shape_info.rotation.y; + } + } + } else { + if (mDemo_Check(mDemo_TYPE_TALK, (ACTOR*)shop_master) == TRUE) { + if (!mDemo_Check_ListenAble()) { + action = aNSC_ACTION_SELL_CHECK_BEFORE; + if (chase_angle(&actorx->shape_info.rotation.y, shop_master->player_angle, + DEG2SHORT_ANGLE(11.25f)) == TRUE) { + if (CLIP(aprilfool_control_clip) != NULL && + CLIP(aprilfool_control_clip)->talk_chk_proc(SP_NPC_SHOP_MASTER) == FALSE) { + action = aNSC_ACTION_REQUEST_Q_END_WAIT; + CLIP(aprilfool_control_clip)->talk_set_proc(SP_NPC_SHOP_MASTER); + } else { + if (shop_master->_9B9 == TRUE) { + action = aNSC_ACTION_REQUEST_Q_END_WAIT; + } else { + action = aNSC_ACTION_REQUEST_Q_ANSWER_WAIT; + } + } + aNSC_setupAction(shop_master, play, action); + aNSC_Set_ListenAble(shop_master); + res = TRUE; + } + actorx->world.angle.y = actorx->shape_info.rotation.y; + } + } else { + void* demo_proc; + shop_master->sell_item = EMPTY_NO; + + if (player->a_btn_pressed == TRUE) { + int ut_x, ut_y; + u16 item; + + xyz_t wpos = player->forward_ut_pos; + mFI_Wpos2UtNum(&ut_x, &ut_y, wpos); + item = CLIP(shop_design_clip)->unitNum2ItemNo_proc(ut_x, ut_y); + if (item != EMPTY_NO && item != RSV_NO) { + void* sell_proc = none_proc1; + shop_master->sell_item = item; + shop_master->ut_x = ut_x; + shop_master->ut_y = ut_y; + + switch (ITEM_NAME_GET_TYPE(item)) { + case NAME_TYPE_FTR0: + case NAME_TYPE_FTR1: + sell_proc = aNSC_set_talk_info_sell_item; + break; + case NAME_TYPE_ITEM1: + switch (ITEM_NAME_GET_CAT(item)) { + case ITEM1_CAT_CARPET: + case ITEM1_CAT_WALL: + sell_proc = aNSC_set_talk_info_show_item; + break; + case ITEM1_CAT_CLOTH: + sell_proc = aNSC_set_talk_info_show_cloth; + break; + default: + sell_proc = aNSC_set_talk_info_sell_item; + break; + } + break; + } + + mDemo_Request(mDemo_TYPE_SPEAK, actorx, sell_proc); + shop_master->_9C0 = -1; + } + } + + if (CLIP(aprilfool_control_clip) != NULL && + CLIP(aprilfool_control_clip)->talk_chk_proc(SP_NPC_SHOP_MASTER) == FALSE) { + demo_proc = aNSC_set_talk_info_message_ctrl_aprilfool; + } else if (shop_master->_9B9 == TRUE) { + demo_proc = aNSC_set_talk_info_message_ctrl_tokubai; + } else { + demo_proc = aNSC_set_talk_info_message_ctrl; + } + mDemo_Request(mDemo_TYPE_TALK, actorx, demo_proc); + } + } + } + } + + return res; +} + +static mActor_name_t aNSC_exchange_itemNo[2] = { ITM_MONEY_30000, EMPTY_NO }; + +static int aNSC_buy_item_single(u32* bells, mActor_name_t item, u32 p2) { + int idx; + Private_c* priv = Now_Private; + int replace_with_bag; + u32 bells_before; + int res = 1; + + for (; p2 != 0; p2--) { + bells_before = *bells; + if (bells_before >= mPr_WALLET_MAX) { + *bells -= 30000; + replace_with_bag = 0; + res = 0; + } else { + replace_with_bag = 1; + } + idx = mPr_GetPossessionItemIdxWithCond(priv, item, mPr_ITEM_COND_NORMAL); + + mPr_SetPossessionItem(Now_Private, idx, aNSC_exchange_itemNo[replace_with_bag], mPr_ITEM_COND_NORMAL); + } + + while (*bells >= mPr_WALLET_MAX) { + *bells -= 30000; + mPr_SetFreePossessionItem(Now_Private, ITM_MONEY_30000, mPr_ITEM_COND_NORMAL); + } + + return res; +} + +static int aNSC_buy_paper(u32* money, mActor_name_t itm, int quant) { + struct private_s* priv = Now_Private; + int paper_type = PAPER2TYPE(itm - ITM_PAPER_START); + int stack_quant = 0; + int place_in_wallet; + + int next = aNSC_BUY_OUTCOME_NORMAL; + // TODO: BUG? doesn't this start with a stack quantity of -1? + mActor_name_t current_item = paper_type + ITM_PAPER_START + (stack_quant - 1) * PAPER_UNIQUE_NUM; + + if (*money >= mPr_WALLET_MAX) { + *money -= 30000; + place_in_wallet = FALSE; + next = aNSC_BUY_OUTCOME_BREAK_BAG; + } else { + place_in_wallet = TRUE; + } + + while (quant != 0) { + u32 idx = mPr_GetPossessionItemIdxWithCond(priv, current_item, mPr_ITEM_COND_NORMAL); + if (idx != -1) { + mPr_SetPossessionItem(Now_Private, idx, aNSC_exchange_itemNo[place_in_wallet], mPr_ITEM_COND_NORMAL); + quant -= stack_quant; + place_in_wallet = TRUE; + } else { + stack_quant += 1; + if (stack_quant > 4) { + break; + } + current_item = ITM_PAPER_START + paper_type + (stack_quant - 1) * PAPER_UNIQUE_NUM; + } + } + + return next; +} + +static int aNSC_buy_item_only_one(u32* bells, mActor_name_t itm, u8* p3, int sell_value) { + int next = aNSC_BUY_OUTCOME_NORMAL; + Private_c* priv; + int quant; + int paper_type; + int item; + int idx; + + if (*bells >= mPr_WALLET_MAX) { + *bells -= 30000; + next = aNSC_BUY_OUTCOME_BREAK_BAG; + } + + if (itm >= ITM_PAPER_START && itm <= ITM_PAPER_END - 1) { + priv = Now_Private; + paper_type = PAPER2TYPE(itm - ITM_PAPER_START); + + for (quant = 1; quant <= 4; quant++) { + item = ITM_PAPER_START + paper_type + (quant - 1) * PAPER_UNIQUE_NUM; + idx = mPr_GetPossessionItemIdx(priv, item); + if (idx != -1) { + if (quant == 1) { + mPr_SetPossessionItem(Now_Private, idx, aNSC_exchange_itemNo[next], mPr_ITEM_COND_NORMAL); + } else if (next == FALSE) { + int empty_idx = mPr_GetPossessionItemIdx(priv, EMPTY_NO); + if (empty_idx != -1) { + item = ITM_PAPER_START + paper_type + (quant - 2) * PAPER_UNIQUE_NUM; + mPr_SetPossessionItem(Now_Private, idx, item, mPr_ITEM_COND_NORMAL); + mPr_SetPossessionItem(Now_Private, empty_idx, ITM_MONEY_30000, mPr_ITEM_COND_NORMAL); + } else { + next = 3; + *bells += 30000; + *bells -= sell_value; + } + } else { + item = ITM_PAPER_START + paper_type + (quant - 2) * PAPER_UNIQUE_NUM; + mPr_SetPossessionItem(Now_Private, idx, item, mPr_ITEM_COND_NORMAL); + } + break; + } + } + } else { + mPr_SetPossessionItem(Now_Private, p3[2], aNSC_exchange_itemNo[next], mPr_ITEM_COND_NORMAL); + } + + while (*bells >= mPr_WALLET_MAX) { + *bells -= 30000; + mPr_SetFreePossessionItem(Now_Private, ITM_MONEY_30000, mPr_ITEM_COND_NORMAL); + } + + return next; +} + +static int aNSC_get_start_call_msg_no(ACTOR* actorx) { + int no; + if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_EVENT) { + if (actorx->npc_id == SP_NPC_DEPART_MASTER) { + no = aNSC_MSG_EVENT_DEPART; + } else { + no = aNSC_MSG_EVENT; + } + } else { + no = aNSC_MSG_START_CALL_NORMAL; + } + return no; +} + +static void aNSC_set_talk_info_start_wait(ACTOR* actorx) { + static u32 rehouse_msg[4] = { aNSC_MSG_MEDIUM_BUILT, aNSC_MSG_LARGE_BUILT, aNSC_MSG_UPPER_BUILT, + aNSC_MSG_STATUE_BUILT }; + static u32 rehouse_loan[4] = { aNSC_LOAN_MEDIUM, aNSC_LOAN_LARGE, aNSC_LOAN_UPPER, aNSC_LOAN_STATUE }; + u8 player_no = Common_Get(player_no); + int idx = mHS_get_arrange_idx(player_no); + Private_c* priv; + struct home_size_info_s* size; + int msg_no; + NPC_SHOP_MASTER_ACTOR* shop_master = (NPC_SHOP_MASTER_ACTOR*)actorx; + + size = &Save_Get(homes)[idx].size_info; + + if (size->renew == TRUE) { + u32 next_loan; + size->pad_1 = 0; + if (size->basement_ordered == TRUE) { + size->basement_ordered = FALSE; + next_loan = aNSC_LOAN_BASEMENT; + size->pad_1 = 1; + msg_no = aNSC_MSG_BASEMENT_BUILT; + } else { + int i = size->size - 1; + msg_no = rehouse_msg[i]; + next_loan = rehouse_loan[i]; + } + + Now_Private->inventory.loan = next_loan; + size->renew = FALSE; + } else { + if (size->statue_ordered == TRUE && size->next_size == mHm_HOMESIZE_STATUE) { + msg_no = aNSC_MSG_STATUE_BUILT; + size->statue_ordered = FALSE; + } else { + if (Now_Private->inventory.loan == 0 && size->size == mHm_HOMESIZE_UPPER && size->size == size->next_size && + size->statue_ordered == FALSE) { + u8 statues_count = Save_Get(num_statues); + mHm_hs_c* home_2; + + player_no = Common_Get(player_no); + idx = mHS_get_arrange_idx(player_no); + home_2 = Save_GetPointer(homes[idx]); + + size->statue_ordered = TRUE; + + size->statue_rank = statues_count; + statues_count += 1; + + if (statues_count >= 4) { + statues_count = 3; + } + Save_Get(num_statues) = statues_count; + aNSC_set_rehouse_order_date(home_2); + msg_no = aNSC_MSG_REHOUSE_STATUE; + } else { + msg_no = aNSC_get_start_call_msg_no(actorx); + } + } + } + mDemo_Set_msg_num(aNSC_get_msg_no(msg_no)); + shop_master->next_action = 1; +} + +static void aNSC_set_talk_info_start_wait1() { + int msg_no = 0; + + u8 player_no = Common_Get(player_no); + int idx = mHS_get_arrange_idx(player_no); + mHm_hs_c* home = &Save_Get(homes)[idx]; + + switch (home->size_info.size) { + case mHm_HOMESIZE_SMALL: + msg_no = aNSC_MSG_REHOUSE_MEDIUM; + break; + case mHm_HOMESIZE_MEDIUM: + if (home->flags.has_basement == FALSE) { + msg_no = aNSC_MSG_REHOUSE_2_OFFER; + } else { + msg_no = aNSC_MSG_BASEMENT_PAID; + } + break; + case mHm_HOMESIZE_LARGE: + if (home->size_info.pad_1 == TRUE) { + msg_no = aNSC_MSG_REHOUSE_UPPER; + break; + } + if (home->flags.has_basement == FALSE) { + msg_no = aNSC_MSG_REHOUSE_BASEMENT; + } else { + msg_no = aNSC_MSG_REHOUSE_LARGE; + } + break; + } + + mDemo_Set_msg_num(aNSC_get_msg_no(msg_no)); +} + +static void aNSC_set_talk_info_start_wait2(ACTOR* actorx) { + NPC_SHOP_MASTER_ACTOR* shop_master = (NPC_SHOP_MASTER_ACTOR*)actorx; + int msg_no = aNSC_MSG_BALLOON; + if (actorx->npc_id == SP_NPC_DEPART_MASTER) { + msg_no = aNSC_MSG_BALLOON_DEPART; + } + mDemo_Set_msg_num(aNSC_get_msg_no(msg_no)); + shop_master->next_action = aNSC_ACTION_PRESENT_BALLOON_START_WAIT; +} + +static void aNSC_set_talk_info_start_wait3(ACTOR* actorx) { + NPC_SHOP_MASTER_ACTOR* shop_master = (NPC_SHOP_MASTER_ACTOR*)actorx; + int msg_no = aNSC_get_start_call_msg_no(actorx); + mDemo_Set_msg_num(aNSC_get_msg_no(msg_no)); + shop_master->next_action = aNSC_ACTION_SAY_HELLO_APPROACH; +} + +static void aNSC_set_talk_info_start_wait4(ACTOR* actorx) { + mDemo_Set_msg_num(aNSC_get_msg_no(-1)); +} + +static void aNSC_start_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + ACTOR* actorx = (ACTOR*)shop_master; + int wait_type = aNSC_WAIT_TYPE_REHOUSE; + int action; + mDemo_REQUEST_PROC proc; + + if (mLd_PlayerManKindCheck() == FALSE) { + if (mEv_CheckEvent(mEv_SAVED_HRATALK_PLR0 + Common_Get(player_no)) == TRUE) { + wait_type = aNSC_WAIT_TYPE_HRATALK; + } else if (aNSC_check_present_balloon() == TRUE) { + wait_type = aNSC_WAIT_TYPE_BALLOON; + } else { + int idx = mHS_get_arrange_idx(Common_Get(player_no)); + mHm_rmsz_c* size = &Save_Get(homes)[idx].size_info; + if (Now_Private->inventory.loan == 0 && size->renew == FALSE && size->size < 3 && + size->size == size->next_size && size->basement_ordered == FALSE) { + wait_type = aNSC_WAIT_TYPE_DONE_REHOUSE; + } + } + } else if (aNSC_check_present_balloon() == TRUE) { + wait_type = aNSC_WAIT_TYPE_BALLOON; + } else { + wait_type = aNSC_WAIT_TYPE_3; + } + + if (mDemo_Check(mDemo_TYPE_SPEAK, actorx) == TRUE && mDemo_Check_ListenAble() == FALSE) { + switch (wait_type) { + case aNSC_WAIT_TYPE_HRATALK: + mEv_EventOFF(mEv_SAVED_HRATALK_PLR0 + Common_Get(player_no)); + action = aNSC_ACTION_SAY_HELLO_APPROACH; + break; + case aNSC_WAIT_TYPE_REHOUSE: + case aNSC_WAIT_TYPE_BALLOON: + case aNSC_WAIT_TYPE_3: + action = shop_master->next_action; + break; + case aNSC_WAIT_TYPE_DONE_REHOUSE: { + int idx = mHS_get_arrange_idx(Common_Get(player_no)); + mHm_hs_c* home = &Save_Get(homes)[idx]; + switch (home->size_info.size) { + case mHm_HOMESIZE_MEDIUM: + if (home->flags.has_basement == FALSE) { + action = aNSC_ACTION_CHECK_COL_CHG_OR_MAKE_BASEMENT; + } else { + action = aNSC_ACTION_CHECK_ROOF_COL_ORDER; + } + break; + case mHm_HOMESIZE_LARGE: + if (home->flags.has_basement == FALSE) { + aNSC_set_make_basement_info(); + action = aNSC_ACTION_SAY_HELLO_APPROACH; + } else { + action = aNSC_ACTION_CHECK_ROOF_COL_ORDER; + } + break; + default: + action = aNSC_ACTION_CHECK_ROOF_COL_ORDER; + break; + } + break; + } break; + } + aNSC_Set_ListenAble(shop_master); + aNSC_setupAction(shop_master, play, action); + return; + } + + proc = (mDemo_REQUEST_PROC)none_proc1; + switch (wait_type) { + case aNSC_WAIT_TYPE_REHOUSE: + proc = aNSC_set_talk_info_start_wait; + break; + case aNSC_WAIT_TYPE_DONE_REHOUSE: + proc = aNSC_set_talk_info_start_wait1; + break; + case aNSC_WAIT_TYPE_BALLOON: + proc = aNSC_set_talk_info_start_wait2; + break; + case aNSC_WAIT_TYPE_3: + proc = aNSC_set_talk_info_start_wait3; + break; + case aNSC_WAIT_TYPE_HRATALK: + proc = aNSC_set_talk_info_start_wait4; + break; + } + mDemo_Request(mDemo_TYPE_SPEAK, actorx, proc); +} + +static void aNSC_say_hello_approach(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + ACTOR* actorx = (ACTOR*)shop_master; + f32 z = 260.0; + if (actorx->world.position.z > z) { + actorx->world.position.z = z; + aNSC_setupAction(shop_master, play, aNSC_ACTION_SAY_HELLO_END_WAIT); + } else if (mDemo_Check(mDemo_TYPE_SPEAK, actorx) == FALSE && mDemo_Check(mDemo_TYPE_TALK, actorx) == FALSE) { + aNSC_setupAction(shop_master, play, aNSC_ACTION_SAY_HELLO_END_WAIT); + } +} + +static void aNSC_say_hello_end_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + ACTOR* actorx = (ACTOR*)shop_master; + if (mDemo_Check(mDemo_TYPE_SPEAK, actorx) == FALSE) { + if (mDemo_Check(mDemo_TYPE_TALK, actorx) == FALSE) { + shop_master->npc_class.talk_info.melody_inst = 0; + aNSC_setupAction(shop_master, play, aNSC_ACTION_WAIT); + } + } +} + +static void aNSC_check_col_chg_or_make_basement(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + f32 z = 260.0; + if (((ACTOR*)shop_master)->world.position.z > z) { + ((ACTOR*)shop_master)->world.position.z = z; + aNSC_set_stop_spd(shop_master); + CLIP(npc_clip)->animation_init_proc((ACTOR*)shop_master, 0x5, 0x1); + } + if (mMsg_Check_MainNormalContinue(mMsg_Get_base_window_p()) == TRUE) { + int action = aNSC_ACTION_CHECK_ROOF_COL_ORDER; + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: + action = aNSC_ACTION_CHECK_ROOF_COL_ORDER; + break; + case mChoice_CHOICE1: + aNSC_set_make_basement_info(); + action = aNSC_ACTION_SAY_HELLO_END_WAIT; + break; + } + aNSC_setupAction(shop_master, play, action); + } +} + +static void aNSC_check_roof_col_order(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + f32 z = 260.0; + int unk = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); + if (((ACTOR*)shop_master)->world.position.z > z) { + ((ACTOR*)shop_master)->world.position.z = z; + aNSC_set_stop_spd(shop_master); + CLIP(npc_clip)->animation_init_proc((ACTOR*)shop_master, 0x5, 0x1); + } + if (unk) { + if (mMsg_Check_MainNormalContinue(mMsg_Get_base_window_p()) == TRUE) { + mHm_hs_c* home = &Save_Get(homes)[mHS_get_arrange_idx(Common_Get(player_no))]; + int action; + int choice = mChoice_Get_ChoseNum(mChoice_Get_base_window_p()); + switch (choice) { + case mChoice_CHOICE0: + case mChoice_CHOICE1: + case mChoice_CHOICE2: + action = aNSC_ACTION_SAY_HELLO_END_WAIT; + home->size_info.next_size += 1; + home->ordered_outlook_pal = choice; + aNSC_set_rehouse_order_date(home); + break; + default: + action = aNSC_ACTION_CHECK_ROOF_COL_ORDER2; + break; + } + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0x0); + aNSC_setupAction(shop_master, play, action); + } + } +} + +static void aNSC_check_roof_col_order2(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (mMsg_Check_MainNormalContinue(mMsg_Get_base_window_p()) == TRUE) { + mHm_hs_c* home = &Save_Get(homes)[mHS_get_arrange_idx(Common_Get(player_no))]; + int choice = mChoice_Get_ChoseNum(mChoice_Get_base_window_p()); + int unk = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); + int action = 0; + switch (choice) { + case mChoice_CHOICE0: + case mChoice_CHOICE1: + case mChoice_CHOICE2: + action = aNSC_ACTION_SAY_HELLO_END_WAIT; + home->size_info.next_size += 1; + home->ordered_outlook_pal = choice + unk * 3; + aNSC_set_rehouse_order_date(home); + break; + default: + action = aNSC_ACTION_CHECK_ROOF_COL_ORDER2; + break; + } + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0x0); + aNSC_setupAction(shop_master, play, action); + } +} + +static void aNSC_present_balloon_start_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if ((int)mDemo_Get_OrderValue(mDemo_TYPE_4, 0x1) == 2) { + aNSC_setupAction(shop_master, play, aNSC_ACTION_PRESENT_BALLOON_TRANS_MOVE); + } +} + +static void aNSC_present_balloon_trans_move(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + ACTOR* actorx = (ACTOR*)shop_master; + if (actorx->world.position.z > 260.0f) { + actorx->world.position.z = 260.0f; + aNSC_setupAction(shop_master, play, aNSC_ACTION_PRESENT_BALLOON_TRANS_TAKEOUT); + } +} + +static void aNSC_present_balloon_trans_takeout(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + ACTOR* actorx = (ACTOR*)shop_master; + ACTOR* res; + if (shop_master->npc_class.left_hand.item_actor_p == NULL) { + res = CLIP(handOverItem_clip) + ->birth_proc(ITM_BALLOON_START, aHOI_REQUEST_PUTAWAY, aHOI_PRESENT, (ACTOR*)shop_master); + if (res) { + CLIP(handOverItem_clip)->chg_request_mode_proc((ACTOR*)shop_master, aHOI_REQUEST_TRANSFER); + + shop_master->npc_class.left_hand.item_actor_p = res; + } + } + + if (shop_master->npc_class.draw.main_animation_state == cKF_STATE_STOPPED) { + if (CLIP(handOverItem_clip)->master_actor == (ACTOR*)shop_master) { + CLIP(handOverItem_clip)->chg_request_mode_proc((ACTOR*)shop_master, aHOI_REQUEST_TRANS_WAIT); + aNSC_setupAction(shop_master, play, aNSC_ACTION_PRESENT_BALLOON_TRANS_WAIT); + } + } +} + +static void aNSC_present_balloon_trans_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (CLIP(handOverItem_clip)->master_actor != (ACTOR*)shop_master) { + aNSC_setupAction(shop_master, play, aNSC_ACTION_PRESENT_BALLOON_END_WAIT); + } +} + +static void aNSC_present_balloon_end_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (CLIP(handOverItem_clip)->master_actor == NULL) { + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + aNSC_setupAction(shop_master, play, aNSC_ACTION_SAY_HELLO_END_WAIT); + } +} + +static void aNSC_set_talk_info_request_Q_start_wait() { + mDemo_Set_msg_num(aNSC_get_msg_no(aNSC_MSG_INTERACT_START)); + mDemo_Set_talk_turn(0x0); +} + +static void aNSC_request_Q_start_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + ACTOR* actorx = (ACTOR*)shop_master; + if (mDemo_Check(mDemo_TYPE_TALK, actorx) == TRUE) { + if (mDemo_Check_ListenAble() == FALSE) { + aNSC_Set_ListenAble(shop_master); + aNSC_setupAction(shop_master, play, aNSC_ACTION_REQUEST_Q_ANSWER_WAIT); + } + } else { + mDemo_Request(mDemo_TYPE_TALK, actorx, aNSC_set_talk_info_request_Q_start_wait); + } +} + +static void aNSC_request_Q_answer_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + static int msg_no[5] = { aNSC_MSG_OTHER, aNSC_MSG_SELL_START, aNSC_MSG_ORDER_FULL, aNSC_MSG_SHOW_CATALOGUE, + aNSC_MSG_INTERACT_CANCEl }; + static int next_act_idx[5] = { aNSC_ACTION_REQUEST_Q_ANSWER_WAIT2, aNSC_ACTION_ANSWER_BUY_ITEM, + aNSC_ACTION_REQUEST_Q_ANSWER_WAIT, aNSC_ACTION_19_ANSWER_BUY_ITEM, + aNSC_ACTION_REQUEST_Q_END_WAIT }; + int res = mDemo_Get_OrderValue(mDemo_TYPE_4, 0x9); + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + if (res != 0) { + if (mMsg_Check_MainNormalContinue(msg_p) == TRUE) { + int next; + mDemo_Set_msg_num(aNSC_get_msg_no(aNSC_MSG_INTERACT_START)); + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: + next = 1; + break; + case mChoice_CHOICE1: + if (aNSC_getP_free_ftr_order() == FALSE) { + next = 0x2; + } else { + next = 0x3; + } + break; + case mChoice_CHOICE2: + next = 0x0; + break; + default: + next = 0x4; + break; + } + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); + aNSC_Set_continue_msg_num(msg_p, shop_master, aNSC_get_msg_no(msg_no[next])); + aNSC_setupAction(shop_master, play, next_act_idx[next]); + } + } +} + +static void aNSC_request_Q_answer_wait2(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + static int msg_no[9] = { aNSC_MSG_KABU_ON_SUNDAY, aNSC_MSG_KABU_INFO, aNSC_MSG_PSWD_INFO, + aNSC_MSG_PSWD_NO_ITEM, aNSC_MSG_GIFT_OUT, aNSC_MSG_PSWD_SAY, + aNSC_MSG_PSWD_INVENTORY_FULL, aNSC_MSG_PSWD_FOREIGN, aNSC_MSG_RETURN }; + static int next_act_idx[9] = { + aNSC_ACTION_REQUEST_Q_END_WAIT, aNSC_ACTION_REQUEST_Q_END_WAIT, aNSC_ACTION_PW_ENTRY_SEND_ADDR_START_WAIT, + aNSC_ACTION_REQUEST_Q_ANSWER_WAIT, aNSC_ACTION_REQUEST_Q_ANSWER_WAIT, aNSC_ACTION_PC_INPUT_PW_START_WAIT, + aNSC_ACTION_REQUEST_Q_ANSWER_WAIT, aNSC_ACTION_REQUEST_Q_ANSWER_WAIT, aNSC_ACTION_REQUEST_Q_ANSWER_WAIT + }; + int res = mDemo_Get_OrderValue(mDemo_TYPE_4, 0x9); + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + if (res != 0) { + if (mMsg_Check_MainNormalContinue(msg_p) == TRUE) { + int next; + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: + if (Common_Get(time).rtc_time.weekday == 0) { + next = 0; + } else { + aNSC_set_value_str(Kabu_get_price(), 0x1); + next = 0x1; + } + break; + case mChoice_CHOICE1: + if (aNSC_check_possession_item_make_password(shop_master) == TRUE) { + next = 0x2; + } else { + next = 0x3; + } + break; + case mChoice_CHOICE2: + if (mLd_PlayerManKindCheck() == FALSE) { + if (Common_Get(unk_nook_present_count) >= 3) { + next = 0x4; + } else if (mPr_GetPossessionItemIdx(Now_Private, EMPTY_NO) != -1) { + next = 0x5; + } else { + next = 0x6; + } + } else { + next = 0x7; + } + break; + default: + next = 0x8; + break; + } + + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); + aNSC_Set_continue_msg_num(msg_p, shop_master, aNSC_get_msg_no(msg_no[next])); + aNSC_setupAction(shop_master, play, next_act_idx[next]); + } + } +} + +static void aNSC_request_Q_end_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + ACTOR* actorx = (ACTOR*)shop_master; + if (mDemo_Check(mDemo_TYPE_SPEAK, actorx) == FALSE && mDemo_Check(mDemo_TYPE_TALK, actorx) == FALSE) { + shop_master->sell_item = EMPTY_NO; + aNSC_setupAction(shop_master, play, aNSC_ACTION_WAIT); + } +} + +static void aNSC_answer_buy_item(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (mDemo_Get_OrderValue(mDemo_TYPE_4, 0x9)) { + if (mMsg_Check_MainNormalContinue(mMsg_Get_base_window_p())) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); + aNSC_setupAction(shop_master, play, shop_master->action + 1); + } + } +} + +static void aNSC_buy_menu_open_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (mMsg_Check_main_wait(mMsg_Get_base_window_p()) == TRUE) { + aNSC_setupAction(shop_master, play, shop_master->action + 1); + } +} + +static void aNSC_buy_menu_close_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (play->submenu.open_flag == FALSE) { + aNSC_setupAction(shop_master, play, shop_master->action + 1); + } +} + +static void aNSC_msg_win_open_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + static int msg_no_table[8] = { aNSC_MSG_SELL_OFFER, aNSC_MSG_SELL_CANCEL, aNSC_MSG_KABU_ON_SUNDAY, + aNSC_MSG_JUNK_ACCEPT, aNSC_MSG_SELL_QUEST, aNSC_MSG_REHOUSE_MEDIUM, + aNSC_MSG_BUY_MANY_OFFER, aNSC_MSG_BUY_REFUSE_PLURAL }; + static int next_act_idx[8] = { aNSC_ACTION_BUY_CHECK, aNSC_ACTION_BUY_CONTINUE_CHECK, + aNSC_ACTION_REQUEST_Q_END_WAIT, aNSC_ACTION_REQUEST_Q_ANSWER_WAIT, + aNSC_ACTION_RECEIVE_CHECK, aNSC_ACTION_BUY_SUM_CHECK, + aNSC_ACTION_BUY_CHECK, aNSC_ACTION_BUY_CHECK }; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + if (mMsg_Check_not_series_main_wait(msg_p) == TRUE) { + int action; + Submenu* submenu = &play->submenu; + mActor_name_t item = submenu->item_p->item; + int msg_no; + if (item == EMPTY_NO) { + action = aNSC_CHECK_BUY_NONE_SELECTED; + } else { + action = aNSC_check_buy_item(shop_master, submenu); + } + if (action == aNSC_CHECK_BUY_OFFER_BUY_ALL) { + msg_no = aNSC_MSG_TAKE_OFF_HANDS; + } else { + msg_no = aNSC_get_msg_no(msg_no_table[action]); + } + aNSC_Set_continue_msg_num(msg_p, shop_master, msg_no); + mMsg_Set_ForceNext(msg_p); + aNSC_setupAction(shop_master, play, next_act_idx[action]); + } +} + +static void aNSC_buy_sum_check(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (mDemo_Get_OrderValue(mDemo_TYPE_4, 0x9)) { + int res = -1; + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: + res = 0; + break; + case mChoice_CHOICE1: + res = 1; + shop_master->counter = 1; + break; + } + if (res != -1) { + mActor_name_t* item = &play->submenu.item_p->item; + if (ITEM_IS_PAPER(*item)) { + *item = PAPEROFQUANT(*item - ITM_PAPER_START, 1); + } + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); + aNSC_Set_continue_msg_num(mMsg_Get_base_window_p(), shop_master, aNSC_get_msg_no(aNSC_MSG_SELL_OFFER)); + aNSC_setupAction(shop_master, play, aNSC_ACTION_BUY_CHECK); + } + } +} + +static void aNSC_buy_check(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + static int msg_no[4] = { aNSC_MSG_BREAK_BAG, aNSC_MSG_SELL_NORMAL, aNSC_MSG_SELL_CANCEL, aNSC_MSG_MONEY_OVERFLOW }; + static int next_act_idx[4] = { aNSC_ACTION_BUY_AFTER_SERVICE, aNSC_ACTION_BUY_CONTINUE_CHECK, + aNSC_ACTION_BUY_CONTINUE_CHECK, aNSC_ACTION_REQUEST_Q_ANSWER_WAIT }; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + int n1 = aNSC_get_msg_no(aNSC_MSG_SELL_OFFER); + int n2 = aNSC_get_msg_no(aNSC_MSG_BUY_MANY_OFFER); + int n3 = aNSC_get_msg_no(aNSC_MSG_BUY_REFUSE_PLURAL); + int num = mMsg_Get_msg_num(msg_p); + int next; + if (num == n1 || num == n2 || num == n3) { + if (mMsg_Check_MainNormalContinue(msg_p)) { + next = -1; + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: { + u32 bells = Now_Private->inventory.wallet; + u32 counter = shop_master->counter; + Submenu_Item_c* submenu_item = play->submenu.item_p; + bells += shop_master->money; + next = 1; + if (!aNSC_check_money_overflow(bells, counter)) { + next = aNSC_BUY_OUTCOME_MONEY_OVERFLOW; + } else { + mActor_name_t item = Now_Private->inventory.pockets[submenu_item->slot_no]; + mSP_PlusSales(shop_master->money / 2); + if (counter == 1) { + next = aNSC_buy_item_only_one(&bells, item, (u8*)submenu_item, shop_master->money); + } else if (play->submenu.selected_item_num > 1) { + int change; + for (; counter > 0; counter--) { + if (bells >= mPr_WALLET_MAX) { + bells -= 30000; + change = 0; + next = aNSC_BUY_OUTCOME_BREAK_BAG; + } else { + change = 1; + } + mPr_SetPossessionItem(Now_Private, submenu_item->slot_no, aNSC_exchange_itemNo[change], + mPr_ITEM_COND_NORMAL); + submenu_item++; + } + + while (bells >= mPr_WALLET_MAX) { + bells -= 30000; + mPr_SetFreePossessionItem(Now_Private, ITM_MONEY_30000, mPr_ITEM_COND_NORMAL); + } + } else if (ITEM_IS_PAPER(item)) { + next = aNSC_buy_paper(&bells, item, counter); + } else { + next = aNSC_buy_item_single(&bells, item, counter); + } + Now_Private->inventory.wallet = bells; + } + } break; + case mChoice_CHOICE1: + next = aNSC_BUY_OUTCOME_CANCEL; + break; + } + if (next != -1) { + int no; + mMsg_Set_ForceNext(msg_p); + aNSC_Set_continue_msg_num(msg_p, shop_master, aNSC_get_msg_no(msg_no[next])); + aNSC_setupAction(shop_master, play, next_act_idx[next]); + } + } + } +} + +static void aNSC_buy_after_service(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + int val = mDemo_Get_OrderValue(mDemo_TYPE_4, 0x9); + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + if (val != 0) { + if (mMsg_Check_MainNormalContinue(msg_p) == TRUE) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); + aNSC_setupAction(shop_master, play, aNSC_ACTION_BUY_CONTINUE_CHECK); + } + } +} + +static void aNSC_buy_continue_check(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + static int next_act_idx[2] = { aNSC_ACTION_BUY_MENU_OPEN_WAIT, aNSC_ACTION_REQUEST_Q_END_WAIT }; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + int n1 = aNSC_get_msg_no(aNSC_MSG_SELL_NORMAL); + int n2 = aNSC_get_msg_no(aNSC_MSG_SELL_CANCEL); + int num = mMsg_Get_msg_num(msg_p); + if (num == n1 || num == n2) { + if (mMsg_Check_MainNormalContinue(msg_p)) { + int action = -1; + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: + action = 0; + break; + case mChoice_CHOICE1: + aNSC_Set_continue_msg_num(msg_p, shop_master, aNSC_get_msg_no(aNSC_MSG_CANCEL)); + action = 1; + break; + } + if (action != -1) { + aNSC_setupAction(shop_master, play, next_act_idx[action]); + } + } + } +} + +static void aNSC_receive_check(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + int no = mMsg_Get_msg_num(msg_p); + if (shop_master->msg_no == no) { + if (mMsg_Check_MainNormalContinue(msg_p)) { + Submenu_Item_c* submenu_item = play->submenu.item_p; + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: + mPr_SetPossessionItem(Now_Private, submenu_item->slot_no, EMPTY_NO, mPr_ITEM_COND_NORMAL); + break; + } + aNSC_setupAction(shop_master, play, aNSC_ACTION_REQUEST_Q_ANSWER_WAIT); + } + } +} + +static void aNSC_msg_win_open_wait2(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + static int msg_no[3] = { aNSC_MSG_ORDER_CANCEL, aNSC_MSG_ORDER_UNAVAILABLE, aNSC_MSG_ORDER_OFFER }; + static int next_act_idx[3] = { aNSC_ACTION_REQUEST_Q_ANSWER_WAIT, aNSC_ACTION_REQUEST_Q_ANSWER_WAIT, + aNSC_ACTION_ORDER_CHECK }; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + if (mMsg_Check_not_series_main_wait(msg_p) == TRUE) { + Submenu_Item_c* submenu_item = play->submenu.item_p; + mActor_name_t item = submenu_item->item; + + int action; + if (item == EMPTY_NO) { + action = 0; + } else { + action = (submenu_item->slot_no != 0 ? 2 : 1); + aNSC_set_item_name_str(item, 0x1); + shop_master->order_item = item; + } + aNSC_ChangeMsgData(msg_p, shop_master, aNSC_get_msg_no(msg_no[action])); + mMsg_Set_ForceNext(msg_p); + aNSC_setupAction(shop_master, play, next_act_idx[action]); + } +} + +static void aNSC_order_check(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + if (mMsg_Get_msg_num(msg_p) == shop_master->msg_no) { + if (mMsg_Check_MainNormalContinue(msg_p)) { + int msg_no = aNSC_MSG_WAIT; + u32 price; + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: + price = mSP_ItemNo2ItemPrice(shop_master->order_item); + if (aNSC_money_check(price) == FALSE) { + msg_no = aNSC_MSG_ORDER_INSUFFICIENT_FUNDS; + } else { + msg_no = aNSC_MSG_ORDER_CONFIRM; + aNSC_set_ftr_order(shop_master); + aNSC_get_sell_price(price); + mSP_PlusSales(price); + } + break; + case mChoice_CHOICE1: + msg_no = aNSC_MSG_ORDER_CANCEL; + break; + } + if (msg_no != aNSC_MSG_WAIT) { + mMsg_Set_ForceNext(msg_p); + aNSC_Set_continue_msg_num(msg_p, shop_master, aNSC_get_msg_no(msg_no)); + aNSC_setupAction(shop_master, play, aNSC_ACTION_REQUEST_Q_ANSWER_WAIT); + } + } + } +} + +static void aNSC_sell_check_before(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (mDemo_Get_OrderValue(mDemo_TYPE_4, 0x9)) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); + aNSC_setupAction(shop_master, play, aNSC_ACTION_SELL_CHECK); + } +} + +static void aNSC_sell_check(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (mMsg_Check_MainNormalContinue(mMsg_Get_base_window_p())) { + int action = -1; + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: + action = aNSC_ACTION_SELL_ANSWER0; + break; + case mChoice_CHOICE1: + action = aNSC_ACTION_21_REQUEST_Q_END_WAIT; + break; + } + if (action != -1) { + if (shop_master->is_selling == TRUE && ITEM_NAME_GET_CAT(shop_master->sell_item) == ITEM1_CAT_CLOTH) { + shop_master->next_action = action; + action = aNSC_ACTION_CHG_CLOTH_START_WAIT; + shop_master->change_cloth = shop_master->player_cloth; + } + aNSC_setupAction(shop_master, play, action); + } + } +} + +static void aNSC_sell_answer0(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + static int next_act_idx[11] = { aNSC_ACTION_SELL_ITEM_WITHOUT_TICKET, aNSC_ACTION_SELL_ITEM_WITH_TICKET, + aNSC_ACTION_SELL_ITEM_WITH_TICKET, aNSC_ACTION_SELL_ITEM_INSUFICIENT_FUNDS, + aNSC_ACTION_SELL_ITEM_POCKETS_FULL, aNSC_ACTION_SELL_ITEM_WITHOUT_TICKET, + aNSC_ACTION_SELL_ITEM_WITHOUT_TICKET, aNSC_ACTION_SELL_ITEM_WITHOUT_TICKET, + aNSC_ACTION_SELL_ITEM_WITHOUT_TICKET, aNSC_ACTION_SELL_ITEM_WITHOUT_TICKET, + aNSC_ACTION_SELL_ITEM_WITHOUT_TICKET }; + static int msg_no[11] = { aNSC_MSG_BUY_NORMAL, aNSC_MSG_GIVE_TICKET, aNSC_MSG_MAIL_TICKET, + aNSC_MSG_INSUFFICIENT_FUNDS, aNSC_MSG_POCKETS_FULL, aNSC_MSG_SELL_NET, + aNSC_MSG_SELL_AXE, aNSC_MSG_SELL_SHOVEL, aNSC_MSG_SELL_ROD, + aNSC_MSG_SELL_PAINT_CONFIRM, aNSC_MSG_SELL_SIGN }; + if (mDemo_Get_OrderValue(mDemo_TYPE_4, 0x9)) { + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + if (mMsg_Check_MainNormal(msg_p) == TRUE) { + int next = 0; + if (aNSC_money_check(shop_master->value) == FALSE) { + next = 0x3; + } else { + mActor_name_t item = shop_master->sell_item; + if (item >= ITM_RED_PAINT && item <= ITM_BROWN_PAINT) { + mHm_hs_c* home = &Save_Get(homes)[mHS_get_arrange_idx(Common_Get(player_no))]; + home->next_outlook_pal = + (item >= ITM_RED_PAINT && item <= ITM_BROWN_PAINT) ? (item - ITM_RED_PAINT) : 0; + next = 0x9; + Now_Private->state_flags |= mPr_FLAG_UPDATE_OUTLOOK_PENDING; + } else { + int idx = mPr_GetPossessionItemIdx(Now_Private, EMPTY_NO); + if (idx == -1) { + next = 0x4; + } else { + mPr_SetPossessionItem(Now_Private, idx, item, mPr_ITEM_COND_NORMAL); + if (aNSC_check_item_with_ticket(item) == TRUE) { + mActor_name_t ticket = (Common_Get(time).rtc_time.month - 1) * 8 + ITM_TICKET_START; + if (aNSC_check_same_month_ticket(ticket) == TRUE) { + next = 0x1; + } else { + aNSC_setup_ticket_remain(); + next = 0x2; + } + } else if (item == ITM_SIGNBOARD) { + next = 0xa; + } else { + switch (item) { + case ITM_NET: + next = 0x5; + break; + case ITM_AXE: + next = 0x6; + break; + case ITM_SHOVEL: + next = 0x7; + break; + case ITM_ROD: + next = 0x8; + break; + } + } + } + } + } + aNSC_Set_continue_msg_num(msg_p, shop_master, aNSC_get_msg_no(msg_no[next])); + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); + aNSC_setupAction(shop_master, play, next_act_idx[next]); + } + } +} + +static void aNSC_sell_item_with_ticket(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + int val = mDemo_Get_OrderValue(mDemo_TYPE_4, 0x9); + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + if (val) { + if (mMsg_Check_MainNormalContinue(msg_p)) { + aNSC_set_last_day_str(); + aNSC_Set_continue_msg_num(msg_p, shop_master, aNSC_get_msg_no(RANDOM(3) + aNSC_MSG_TICKET_1)); + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); + aNSC_setupAction(shop_master, play, aNSC_ACTION_REQUEST_Q_END_WAIT); + } + } +} + +static void aNSC_show_item_check(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + if (mMsg_Check_MainNormalContinue(msg_p)) { + mActor_name_t item = shop_master->sell_item; + int action = aNSC_ACTION_SELL_CHECK_BEFORE; + int msg_no = aNSC_MSG_WAIT; + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: + switch (ITEM_NAME_GET_CAT(item)) { + case ITEM1_CAT_WALL: + CLIP(shop_indoor_clip)->change_wall_proc(item); + msg_no = aNSC_MSG_SHOW_CARPET_OFFER; + aNSC_request_show_camera(play, aNSC_REQUEST_SHOW_TYPE_WALL); + break; + case ITEM1_CAT_CARPET: + CLIP(shop_indoor_clip)->change_carpet_proc(item); + msg_no = aNSC_MSG_SHOW_CARPET_OFFER; + aNSC_request_show_camera(play, aNSC_REQUEST_SHOW_TYPE_CARPET); + break; + default: + CLIP(shop_manekin_clip)->change2naked_manekin_proc(shop_master->ut_x, shop_master->ut_y); + action = aNSC_ACTION_CHG_CLOTH_START_WAIT; + msg_no = aNSC_MSG_CONFIRM_CLOTH; + shop_master->next_action = aNSC_ACTION_SELL_CHECK_BEFORE; + shop_master->player_cloth = Now_Private->cloth.item; + shop_master->change_cloth = shop_master->sell_item; + break; + } + shop_master->is_selling = TRUE; + break; + case mChoice_CHOICE1: + switch (ITEM_NAME_GET_CAT(item)) { + case ITEM1_CAT_CARPET: + case ITEM1_CAT_WALL: + msg_no = aNSC_MSG_SHOW_CARPET_DECLINE; + break; + default: + msg_no = aNSC_MSG_CANCEL_CLOTH; + break; + } + break; + case mChoice_CHOICE2: + action = aNSC_ACTION_21_REQUEST_Q_END_WAIT; + msg_no = aNSC_MSG_BUY_CANCEL; + break; + } + + if (msg_no != -1) { + aNSC_Set_continue_msg_num(msg_p, shop_master, aNSC_get_msg_no(msg_no)); + mMsg_Set_ForceNext(msg_p); + aNSC_setupAction(shop_master, play, action); + } + } +} + +static void aNSC_chg_cloth_start_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (mPlib_get_player_actor_main_index((GAME*)play) == mPlayer_INDEX_CHANGE_CLOTH) { + aNSC_setupAction(shop_master, play, aNSC_ACTION_CHG_CLOTH_END_WAIT); + } else { + mActor_name_t item = shop_master->change_cloth; + if (item != RSV_CLOTH) { + mPlib_request_main_change_cloth_forNPC_type1((GAME*)play, item, + ITEM_IS_CLOTH(item) ? item - ITM_CLOTH_START : FALSE, TRUE); + } else { + mPlib_request_main_change_cloth_forNPC_type1((GAME*)play, 1 - 0x1e1, Now_Private->cloth.idx, TRUE); + } + } +} + +static void aNSC_chg_cloth_end_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (mPlib_get_player_actor_main_index((GAME*)play) != mPlayer_INDEX_CHANGE_CLOTH) { + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + aNSC_setupAction(shop_master, play, shop_master->next_action); + } +} + +static void aNSC_pw_entry_send_addr_start_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (mDemo_Get_OrderValue(mDemo_TYPE_4, 0x9)) { + if (mMsg_Check_MainNormalContinue(mMsg_Get_base_window_p()) == TRUE) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); + aNSC_setupAction(shop_master, play, aNSC_ACTION_2A_BUY_MENU_OPEN_WAIT); + } + } +} + +static void aNSC_pw_msg_win_open_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + static int msg_no[2] = { aNSC_MSG_PSWD_SAME_NAME, aNSC_MSG_PSWD_CONFIRM }; + static int next_act_idx[2] = { aNSC_ACTION_PW_ENTRY_SEND_ADDR_START_WAIT, aNSC_ACTION_PW_SEND_ADDR_CHECK }; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + if (mMsg_Check_not_series_main_wait(msg_p) == TRUE) { + int next = 0; + if (mLd_CheckCmpLandName(shop_master->pw_town_str, mLd_GetLandName()) == FALSE) { + next = 1; + } + aNSC_ChangeMsgData(msg_p, shop_master, aNSC_get_msg_no(msg_no[next])); + mMsg_Set_ForceNext(msg_p); + aNSC_setupAction(shop_master, play, next_act_idx[next]); + } +} + +static void aNSC_pw_send_addr_check(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + static int next_act_idx[3] = { aNSC_ACTION_PW_SEL_ITEM_START_WAIT, aNSC_ACTION_PW_ENTRY_SEND_ADDR_START_WAIT, + aNSC_ACTION_REQUEST_Q_ANSWER_WAIT }; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + if (mMsg_Get_msg_num(msg_p) == aNSC_get_msg_no(aNSC_MSG_PSWD_CONFIRM)) { + if (mMsg_Check_MainNormalContinue(msg_p)) { + int choice = -1; + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: + choice = 0; + break; + case mChoice_CHOICE1: + choice = 1; + break; + case mChoice_CHOICE2: + choice = 2; + break; + } + if (choice != -1) { + mMsg_Set_ForceNext(msg_p); + aNSC_setupAction(shop_master, play, next_act_idx[choice]); + } + } + } +} + +static void aNSC_pw_sel_item_start_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (mDemo_Get_OrderValue(mDemo_TYPE_4, 0x9)) { + if (mMsg_Check_MainNormalContinue(mMsg_Get_base_window_p()) == TRUE) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); + aNSC_setupAction(shop_master, play, aNSC_ACTION_2F_BUY_MENU_OPEN_WAIT); + } + } +} + +static void aNSC_pw_msg_win_open_wait2(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + static int msg_no[2] = { aNSC_MSG_PSWD_CANCEL, aNSC_MSG_PSWD_CHECK }; + static int next_act_idx[2] = { aNSC_ACTION_PW_RETRY_SEL_ITEM_CHECK, aNSC_ACTION_PW_SEND_CHECK }; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + if (mMsg_Check_not_series_main_wait(msg_p) == TRUE) { + int action = 0; + mActor_name_t item = play->submenu.item_p->item; + if (item != EMPTY_NO) { + shop_master->pw_item = item; + aNSC_set_item_name_str(item, 0x2); + action = 1; + } + aNSC_ChangeMsgData(msg_p, shop_master, aNSC_get_msg_no(msg_no[action])); + mMsg_Set_ForceNext(msg_p); + aNSC_setupAction(shop_master, play, next_act_idx[action]); + } +} + +static void aNSC_pw_send_check(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + static int next_act_idx[3] = { aNSC_ACTION_REQUEST_Q_END_WAIT, aNSC_ACTION_PW_ENTRY_SEND_ADDR_START_WAIT, + aNSC_ACTION_REQUEST_Q_ANSWER_WAIT }; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + if (mMsg_Get_msg_num(msg_p) == aNSC_get_msg_no(aNSC_MSG_PSWD_CHECK)) { + if (mMsg_Check_MainNormalContinue(msg_p)) { + int choice = -1; + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: { + Submenu_Item_c* submenu_item = play->submenu.item_p; + mMpswd_make_password(shop_master->password_str, 0x4, 0x1, shop_master->pw_recip_str, + shop_master->pw_town_str, shop_master->pw_item, 0x0, 0x0); + aNSC_set_pw_password_str(shop_master); + mPr_SetPossessionItem(Now_Private, submenu_item->slot_no, EMPTY_NO, mPr_ITEM_COND_NORMAL); + choice = 0; + break; + } + case mChoice_CHOICE1: + choice = 1; + break; + case mChoice_CHOICE2: + choice = 2; + break; + } + if (choice != -1) { + mMsg_Set_ForceNext(msg_p); + aNSC_setupAction(shop_master, play, next_act_idx[choice]); + } + } + } +} + +static void aNSC_pw_retry_sel_item_check(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + static int next_act_idx[2] = { aNSC_ACTION_2F_BUY_MENU_OPEN_WAIT, aNSC_ACTION_REQUEST_Q_ANSWER_WAIT }; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + if (mMsg_Get_msg_num(msg_p) == aNSC_get_msg_no(aNSC_MSG_PSWD_CANCEL)) { + if (mMsg_Check_MainNormalContinue(msg_p)) { + int choice = -1; + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: + choice = 0; + break; + case mChoice_CHOICE1: + choice = 1; + break; + } + if (choice != -1) { + mMsg_Set_ForceNext(msg_p); + aNSC_setupAction(shop_master, play, next_act_idx[choice]); + } + } + } +} + +static void aNSC_pc_input_pw_start_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (mDemo_Get_OrderValue(mDemo_TYPE_4, 0x9)) { + if (mMsg_Check_MainNormalContinue(mMsg_Get_base_window_p()) == TRUE) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); + aNSC_setupAction(shop_master, play, aNSC_ACTION_35_BUY_MENU_OPEN_WAIT); + } + } +} + +static void aNSC_pc_msg_win_open_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + static int msg_no[10] = { aNSC_MSG_PSWD_WRONG, aNSC_MSG_PSWD_GOOD_FAMICON, aNSC_MSG_PSWD_GOOD_NPC, + aNSC_MSG_PSWD_GOOD_MAGAZINE_1, aNSC_MSG_PSWD_CARDE, aNSC_MSG_PSWD_GOOD_USER, + aNSC_MSG_PSWD_GOOD_CARDEM, aNSC_MSG_PSWD_GOOD_MAGAZINE_2, aNSC_MSG_PSWD_BAD, + aNSC_MSG_PSWD_DECLINE }; + static int next_act_idx[10] = { aNSC_ACTION_PC_RETRY_INPUT_PW_CHECK, aNSC_ACTION_PC_PRESENT_START_WAIT, + aNSC_ACTION_PC_PRESENT_START_WAIT, aNSC_ACTION_PC_PRESENT_START_WAIT, + aNSC_ACTION_REQUEST_Q_END_WAIT, aNSC_ACTION_PC_PRESENT_START_WAIT, + aNSC_ACTION_PC_PRESENT_START_WAIT, aNSC_ACTION_REQUEST_Q_END_WAIT, + aNSC_ACTION_PC_RETRY_INPUT_PW_CHECK, aNSC_ACTION_REQUEST_Q_ANSWER_WAIT }; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + if (mMsg_Check_not_series_main_wait(msg_p) == TRUE) { + int act = aNSC_pc_check_password(shop_master); + aNSC_ChangeMsgData(msg_p, shop_master, aNSC_get_msg_no(msg_no[act])); + mMsg_Set_ForceNext(msg_p); + aNSC_setupAction(shop_master, play, next_act_idx[act]); + } +} + +static void aNSC_pc_retry_input_pw_check(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + static int next_act_idx[2] = { aNSC_ACTION_35_BUY_MENU_OPEN_WAIT, aNSC_ACTION_REQUEST_Q_ANSWER_WAIT }; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + int n1 = aNSC_get_msg_no(aNSC_MSG_PSWD_WRONG); + int n2 = aNSC_get_msg_no(aNSC_MSG_PSWD_BAD); + int no = mMsg_Get_msg_num(msg_p); + if (no == n1 || no == n2) { + if (mMsg_Check_MainNormalContinue(msg_p)) { + int choice = -1; + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: + choice = 0; + break; + case mChoice_CHOICE1: + choice = 1; + aNSC_ChangeMsgData(msg_p, shop_master, aNSC_get_msg_no(aNSC_MSG_PSWD_DECLINE)); + break; + } + if (choice != -1) { + mMsg_Set_ForceNext(msg_p); + aNSC_setupAction(shop_master, play, next_act_idx[choice]); + } + } + } +} + +static void aNSC_pc_present_start_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + int value = mDemo_Get_OrderValue(mDemo_TYPE_4, 0x01); + if (value == 0x2) { + aNSC_setupAction(shop_master, play, aNSC_ACTION_PC_PRESENT_TRANS_TAKEOUT); + } +} + +static void aNSC_pc_present_trans_takeout(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (shop_master->npc_class.left_hand.item_actor_p == NULL) { + ACTOR* actor = CLIP(handOverItem_clip)->birth_proc(shop_master->password.item, 0x7, 0x1, (ACTOR*)shop_master); + if (actor) { + CLIP(handOverItem_clip)->chg_request_mode_proc((ACTOR*)shop_master, 0x1); + shop_master->npc_class.left_hand.item_actor_p = actor; + } + } + if (shop_master->npc_class.draw.main_animation_state == cKF_STATE_STOPPED) { + if (CLIP(handOverItem_clip)->master_actor == (ACTOR*)shop_master) { + CLIP(handOverItem_clip)->chg_request_mode_proc((ACTOR*)shop_master, aHOI_REQUEST_TRANS_WAIT); + aNSC_setupAction(shop_master, play, aNSC_ACTION_PC_PRESENT_TRANS_WAIT); + } + } +} + +static void aNSC_pc_present_trans_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (CLIP(handOverItem_clip)->master_actor != (ACTOR*)shop_master) { + aNSC_setupAction(shop_master, play, aNSC_ACTION_PC_PRESENT_END_WAIT); + } +} + +static void aNSC_pc_present_end_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (CLIP(handOverItem_clip)->master_actor == NULL) { + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + aNSC_setupAction(shop_master, play, aNSC_ACTION_REQUEST_Q_END_WAIT); + } +} + +static void aNSC_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (aNSC_message_ctrl(shop_master, play) != TRUE) { + int act = aNSC_decide_next_move_act(shop_master, play); + if (act != shop_master->action) { + aNSC_setupAction(shop_master, play, act); + } else { + aNSM_search_player(shop_master, play); + } + } +} + +static void aNSC_walk_pl_other_zone(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (aNSC_message_ctrl(shop_master, play) != TRUE) { + int act = aNSC_decide_next_move_act(shop_master, play); + if (act != shop_master->action) { + aNSC_setupAction(shop_master, play, act); + } else { + aNSM_search_player2(shop_master, play); + } + } +} + +static void aNSC_turn(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + ACTOR* actorx = (ACTOR*)shop_master; + if (aNSC_message_ctrl(shop_master, play) != TRUE) { + if (GET_PLAYER_ACTOR(play)) { + s16 player_angle = shop_master->player_angle; + chase_angle(&actorx->shape_info.rotation.y, player_angle, DEG2SHORT_ANGLE(11.25f)); + actorx->world.angle.y = actorx->shape_info.rotation.y; + if (ABS(player_angle - actorx->shape_info.rotation.y) <= DEG2SHORT_ANGLE(90.0f)) { + aNSC_setupAction(shop_master, play, aNSC_ACTION_WAIT); + } + } + } +} + +static void aNSC_set_talk_info_goodbye_wait() { + mDemo_Set_msg_num(aNSC_get_msg_no(aNSC_MSG_SAY_GOODBYE)); + mDemo_Set_camera(CAMERA2_PROCESS_NORMAL); +} + +static void aNSC_goodbye_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + ACTOR* actorx = (ACTOR*)shop_master; + if (mDemo_Check(mDemo_TYPE_SPEAK, (ACTOR*)shop_master) == TRUE) { + if (mDemo_Check_ListenAble() == FALSE) { + s16 player_angle = shop_master->player_angle; + if (chase_angle(&actorx->shape_info.rotation.y, player_angle, DEG2SHORT_ANGLE(11.25f)) == TRUE) { + aNSC_Set_ListenAble(shop_master); + aNSC_setupAction(shop_master, play, aNSC_ACTION_SAY_GOODBYE); + } + } + } else { + mDemo_Request(mDemo_TYPE_SPEAK, actorx, aNSC_set_talk_info_goodbye_wait); + } +} + +static void aNSC_say_goodbye(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + if (mMsg_Check_idling_now(msg_p) == TRUE) { + mMsg_request_main_disappear_wait_type1(msg_p); + aNSC_setupAction(shop_master, play, aNSC_ACTION_EXIT_WAIT); + } +} + +static void aNSC_exit_wait(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + if (mMsg_Check_main_wait(mMsg_Get_base_window_p()) == TRUE) { + goto_other_scene(play, &Common_Get(structure_exit_door_data), TRUE); + if (play->fb_wipe_mode == 0) { + mBGMPsComp_scene_mode(0xe); + mBGMPsComp_volume_talk_end(); + mBGMPsComp_make_ps_wipe(0x195); + } + } +} + +static void aNSC_say_hello_approach_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + aNSC_set_walk_spd(shop_master); +} + +static void aNSC_say_hello_end_wait_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + shop_master->next_zone = shop_master->zone; + aNSC_set_stop_spd(shop_master); +} + +static void aNSC_check_col_chg_or_make_basement_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + aNSC_set_walk_spd(shop_master); +} + +static void aNSC_check_roof_col_order_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); + aNSC_set_walk_spd(shop_master); +} + +static void aNSC_check_roof_col_order2_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); +} + +static void aNSC_present_balloon_start_wait_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + Common_Get(spnpc_first_talk_flags) |= (1 << aNPC_SPNPC_BIT_SHOP_MASTER); +} + +static void aNSC_present_balloon_trans_move_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + int rand; + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x1, 0x0); + aNSC_set_walk_spd(shop_master); + rand = RANDOM(8); + mPr_SetFreePossessionItem(Now_Private, ITM_BALLOON_START + rand, mPr_ITEM_COND_PRESENT); + mMsg_Set_LockContinue(mMsg_Get_base_window_p()); + shop_master->npc_class.head.lock_flag = TRUE; +} + +static void aNSC_present_balloon_trans_takeout_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + ACTOR* actorx = (ACTOR*)shop_master; + shop_master->next_zone = shop_master->zone; + aNSC_set_stop_spd(shop_master); + sAdo_OngenTrgStart(0x69, &actorx->world.position); +} + +static void aNSC_present_balloon_end_wait_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + shop_master->npc_class.left_hand.item_actor_p = NULL; + shop_master->npc_class.head.lock_flag = FALSE; +} + +static void aNSC_request_Q_answer_wait_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); + aNSC_set_stop_spd(shop_master); +} + +static void aNSC_request_Q_end_wait_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + aNSC_set_stop_spd(shop_master); +} + +static void aNSC_answer_buy_item_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mDemo_Set_OrderValue(mDemo_TYPE_4, 9, 0); +} + +static void aNSC_buy_menu_open_wait_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mMsg_request_main_disappear_wait_type1(mMsg_Get_base_window_p()); +} + +static void aNSC_buy_menu_close_wait_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mSM_open_submenu(&play->submenu, mSM_OVL_INVENTORY, 0x5, 0x0); + shop_master->next_action = 0x13; +} + +static void aNSC_msg_win_open_wait_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mMsg_request_main_appear_wait_type1(mMsg_Get_base_window_p()); +} + +static void aNSC_buy_sum_check_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); +} + +static void aNSC_buy_check_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + static int kabu_sum[4] = { 10, 50, 100, 0 }; + int value = 0; + Submenu_Item_c* submenu_item = play->submenu.item_p; + int quant = play->submenu.selected_item_num; + u32 counter = shop_master->counter; + + if (quant > 1) { + counter = 1; + } + + while (quant) { + mActor_name_t item = submenu_item->item; + if (ITEM_NAME_GET_TYPE(item) == NAME_TYPE_ITEM1 && ITEM_NAME_GET_CAT(item) == ITEM1_CAT_KABU) { + value += Kabu_get_price() * kabu_sum[item - ITM_KABU_START] * counter; + } else if (ITEM_IS_PAPER(item)) { + value += (mSP_ItemNo2ItemPrice(item) / SELL_BUY_RATIO) * counter; + } else { + value += (mSP_ItemNo2ItemPrice(item) / SELL_BUY_RATIO) * counter; + } + submenu_item++; + quant--; + } + shop_master->money = value; + aNSC_set_value_str(value, 0x2); +} + +static void aNSC_buy_after_service_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); +} + +static void aNSC_order_select_menu_close_wait_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mSM_open_submenu(&play->submenu, mSM_OVL_CATALOG, 0x0, 0x0); + shop_master->next_action = aNSC_ACTION_MSG_WIN_OPEN_WAIT2; +} + +static void aNSC_order_check_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + aNSC_set_value_str(mSP_ItemNo2ItemPrice(shop_master->order_item), 0x3); +} + +static void aNSC_sell_check_before_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); + aNSC_set_stop_spd(shop_master); +} + +static void aNSC_sell_answer0_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); + if (shop_master->is_selling == TRUE) { + switch (ITEM_NAME_GET_CAT(shop_master->sell_item)) { + case ITEM1_CAT_CARPET: + case ITEM1_CAT_WALL: + if (CLIP(shop_indoor_clip) != NULL) { + CLIP(shop_indoor_clip)->change2default_proc(); + Camera2_Inter_set_reverse_mode(play); + shop_master->is_selling = FALSE; + } + break; + case ITEM1_CAT_CLOTH: + if (!aNSC_money_check(shop_master->value) || !mPr_GetPossessionItemSum(Now_Private, 0) || + shop_master->action == aNSC_ACTION_21_REQUEST_Q_END_WAIT) { + CLIP(shop_manekin_clip)->naked2cloth_proc(shop_master->ut_x, shop_master->ut_y); + } + shop_master->is_selling = FALSE; + break; + } + } +} + +static void aNSC_sell_answer1_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + aNSC_sell_answer0_init(shop_master, play); + shop_master->sell_item = EMPTY_NO; +} + +static void aNSC_sell_item_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + aNSC_get_sell_price(shop_master->value); + if (CLIP(shop_design_clip) != NULL) { + CLIP(shop_design_clip)->reportGoodsSale_proc(shop_master->ut_x, shop_master->ut_y); + } + shop_master->sell_item = EMPTY_NO; +} + +static void aNSC_sell_item_with_ticket_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); + aNSC_sell_item_init(shop_master, play); +} + +static void aNSC_sell_refuse0_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + shop_master->sell_item = EMPTY_NO; +} + +static void aNSC_show_item_check_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + aNSC_set_stop_spd(shop_master); +} + +static void aNSC_chg_cloth_start_wait_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mMsg_Set_LockContinue(mMsg_Get_base_window_p()); +} + +static void aNSC_pw_entry_send_addr_start_wait_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); +} + +static void aNSC_pw_make_menu_close_wait_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mem_clear(shop_master->pw_town_str, 0x10, 0x20); + mSM_open_submenu_new(&play->submenu, mSM_OVL_PASSWORDMAKE, 0x0, 0x0, &shop_master->pw_town_str); + shop_master->next_action = aNSC_ACTION_PW_MSG_WIN_OPEN_WAIT; +} + +static void aNSC_pw_send_addr_check_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + aNSC_set_pw_name_str(shop_master); +} + +static void aNSC_pw_sel_item_menu_close_wait_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mSM_open_submenu(&play->submenu, mSM_OVL_INVENTORY, 0x10, shop_master->password_flags); + shop_master->next_action = aNSC_ACTION_PW_MSG_WIN_OPEN_WAIT; +} + +static void aNSC_pc_input_pw_start_wait_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mem_clear(shop_master->password_str, 0x1c, 0x20); + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0); +} + +static void aNSC_pc_chk_menu_close_wait_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mSM_open_submenu_new(&play->submenu, mSM_OVL_PASSWORDCHK, 0x0, 0x0, shop_master->password_str); + shop_master->next_action = aNSC_ACTION_PC_MSG_WIN_OPEN_WAIT; +} + +static void aNSC_pc_present_trans_takeout_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + ACTOR* actorx = (ACTOR*)shop_master; + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x1, 0x0); + sAdo_OngenTrgStart(0x69, &actorx->world.position); + mPr_SetFreePossessionItem(Now_Private, shop_master->password.item, mPr_ITEM_COND_PRESENT); + Common_Get(unk_nook_present_count)++; + mMsg_Set_LockContinue(mMsg_Get_base_window_p()); + shop_master->npc_class.head.lock_flag = TRUE; +} + +static void aNSC_pc_present_end_wait_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + shop_master->npc_class.left_hand.item_actor_p = NULL; + shop_master->npc_class.head.lock_flag = FALSE; +} + +static void aNSC_wait_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + aNSC_set_stop_spd(shop_master); +} + +static void aNSC_walk_pl_same_zone_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + aNSC_set_walk_spd(shop_master); +} + +static void aNSC_run_pl_same_zone_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + aNSC_set_run_spd(shop_master); +} + +static void aNSC_goodbye_wait_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + aNSC_set_stop_spd(shop_master); +} + +static void aNSC_say_goodbye_init(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* play) { + mMsg_Set_idling_req(mMsg_Get_base_window_p()); +} + +// clang-format off +static void aNSC_init_proc(NPC_SHOP_MASTER_ACTOR *shop_master, GAME_PLAY* play, int action) { + static aNSC_INIT_PROC init_proc[70] = { + (aNSC_INIT_PROC)none_proc1, + aNSC_say_hello_approach_init, + aNSC_say_hello_end_wait_init, + aNSC_say_hello_end_wait_init, + aNSC_check_roof_col_order_init, + aNSC_check_roof_col_order2_init, + aNSC_check_col_chg_or_make_basement_init, + aNSC_present_balloon_start_wait_init, + aNSC_present_balloon_trans_move_init, + aNSC_present_balloon_trans_takeout_init, + (aNSC_INIT_PROC)none_proc1, + aNSC_present_balloon_end_wait_init, + (aNSC_INIT_PROC)none_proc1, + aNSC_request_Q_answer_wait_init, + aNSC_request_Q_answer_wait_init, + aNSC_request_Q_end_wait_init, + aNSC_answer_buy_item_init, + aNSC_buy_menu_open_wait_init, + aNSC_buy_menu_close_wait_init, + aNSC_msg_win_open_wait_init, + aNSC_buy_sum_check_init, + aNSC_buy_check_init, + aNSC_buy_after_service_init, + (aNSC_INIT_PROC)none_proc1, + (aNSC_INIT_PROC)none_proc1, + aNSC_buy_after_service_init, + aNSC_buy_menu_open_wait_init, + aNSC_order_select_menu_close_wait_init, + aNSC_msg_win_open_wait_init, + aNSC_order_check_init, + aNSC_sell_check_before_init, + (aNSC_INIT_PROC)none_proc1, + aNSC_sell_answer0_init, + aNSC_sell_answer1_init, + aNSC_sell_item_init, + aNSC_sell_item_with_ticket_init, + aNSC_sell_refuse0_init, + aNSC_sell_refuse0_init, + aNSC_show_item_check_init, + aNSC_chg_cloth_start_wait_init, + (aNSC_INIT_PROC)none_proc1, + aNSC_pw_entry_send_addr_start_wait_init, + aNSC_buy_menu_open_wait_init, + aNSC_pw_make_menu_close_wait_init, + aNSC_msg_win_open_wait_init, + aNSC_pw_send_addr_check_init, + aNSC_pw_entry_send_addr_start_wait_init, + aNSC_buy_menu_open_wait_init, + aNSC_pw_sel_item_menu_close_wait_init, + aNSC_msg_win_open_wait_init, + (aNSC_INIT_PROC)none_proc1, + (aNSC_INIT_PROC)none_proc1, + aNSC_pc_input_pw_start_wait_init, + aNSC_buy_menu_open_wait_init, + aNSC_pc_chk_menu_close_wait_init, + aNSC_msg_win_open_wait_init, + (aNSC_INIT_PROC)none_proc1, + (aNSC_INIT_PROC)none_proc1, + aNSC_pc_present_trans_takeout_init, + (aNSC_INIT_PROC)none_proc1, + aNSC_pc_present_end_wait_init, + aNSC_wait_init, + aNSC_walk_pl_same_zone_init, + aNSC_walk_pl_same_zone_init, + aNSC_run_pl_same_zone_init, + aNSC_run_pl_same_zone_init, + aNSC_wait_init, + aNSC_goodbye_wait_init, + aNSC_say_goodbye_init, + aNSC_exit_wait + }; + init_proc[action](shop_master, play); +} + +static void aNSC_setupAction(NPC_SHOP_MASTER_ACTOR *shop_master, GAME_PLAY *play, int action) { + static aNSC_ACTION_PROC process[70] = { + aNSC_start_wait, // 0x0 + aNSC_say_hello_approach, + aNSC_say_hello_end_wait, + aNSC_say_hello_end_wait, + aNSC_check_roof_col_order, + aNSC_check_roof_col_order2, + aNSC_check_col_chg_or_make_basement, + aNSC_present_balloon_start_wait, + aNSC_present_balloon_trans_move, + aNSC_present_balloon_trans_takeout, + aNSC_present_balloon_trans_wait, + aNSC_present_balloon_end_wait, + aNSC_request_Q_start_wait, + aNSC_request_Q_answer_wait, + aNSC_request_Q_answer_wait2, + aNSC_request_Q_end_wait, + aNSC_answer_buy_item, // 0x10 + aNSC_buy_menu_open_wait, + aNSC_buy_menu_close_wait, + aNSC_msg_win_open_wait, + aNSC_buy_sum_check, + aNSC_buy_check, + aNSC_buy_after_service, + aNSC_buy_continue_check, + aNSC_receive_check, + aNSC_answer_buy_item, + aNSC_buy_menu_open_wait, + aNSC_buy_menu_close_wait, + aNSC_msg_win_open_wait2, + aNSC_order_check, + aNSC_sell_check_before, + aNSC_sell_check, + aNSC_sell_answer0, // 0x20 + aNSC_request_Q_end_wait, + aNSC_request_Q_end_wait, + aNSC_sell_item_with_ticket, + aNSC_request_Q_end_wait, + aNSC_request_Q_end_wait, + aNSC_show_item_check, + aNSC_chg_cloth_start_wait, + aNSC_chg_cloth_end_wait, + aNSC_pw_entry_send_addr_start_wait, + aNSC_buy_menu_open_wait, + aNSC_buy_menu_close_wait, + aNSC_pw_msg_win_open_wait, + aNSC_pw_send_addr_check, + aNSC_pw_sel_item_start_wait, + aNSC_buy_menu_open_wait, + aNSC_buy_menu_close_wait, // 0x30 + aNSC_pw_msg_win_open_wait2, + aNSC_pw_send_check, + aNSC_pw_retry_sel_item_check, + aNSC_pc_input_pw_start_wait, + aNSC_buy_menu_open_wait, + aNSC_buy_menu_close_wait, + aNSC_pc_msg_win_open_wait, + aNSC_pc_retry_input_pw_check, + aNSC_pc_present_start_wait, + aNSC_pc_present_trans_takeout, + aNSC_pc_present_trans_wait, + aNSC_pc_present_end_wait, + aNSC_wait, + aNSC_wait, + aNSC_walk_pl_other_zone, + aNSC_wait, // 0x40 + aNSC_walk_pl_other_zone, + aNSC_turn, + aNSC_goodbye_wait, + aNSC_say_goodbye, + aNSC_exit_wait + }; + shop_master->action = action; + shop_master->proc = process[action]; + aNSC_set_animation(shop_master, action); + aNSC_init_proc(shop_master, play, action); +} +// clang-format off