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,
#ifdef aNSC_MAMEDANUKI
    aNSC_ACTION_GOODBYE_WAIT2,
#endif
    aNSC_ACTION_SAY_GOODBYE,
    aNSC_ACTION_EXIT_WAIT,
    aNSC_ACTION_NUM
};

static void aNSC_set_animation(NPC_SHOP_COMMON_ACTOR* shop_common, int action) {
    static aNSC_animation_data anime[aNSC_ACTION_NUM] = {
#include aNSC_ANIME_FILE // This is very cursed
    };

    aNSC_animation_data* data = &anime[action];
    CLIP(npc_clip)->animation_init_proc((ACTOR*)shop_common, data->anim, data->talk_flag);
}

static void aNSC_BGcheck(ACTOR* actor) {
    mCoBG_BgCheckControll(NULL, actor, 8.0f, 0.0f, 1, 0, 0);
}

#ifndef aNSC_MAMEDANUKI
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;
}
#endif

static void aNSC_calc_talk_start_tim(NPC_SHOP_COMMON_ACTOR* shop_common) {
    int ivar1 = shop_common->talk_start_tim;
    if (ivar1 <= -1) {
        ivar1 = 180;
    } else if (ivar1 != 0) {
        ivar1 -= 1;
    }
    shop_common->talk_start_tim = 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 == mSP_SHOP_TYPE_DSUPER);

    Camera2_request_BuySikimono_WallPaper(play, &pcenter[i][p2], &peye[i][p2]);
}

static void aNSC_Set_ListenAble(NPC_SHOP_COMMON_ACTOR* shop_common) {
    mMld_ActorMakeMelody((ACTOR*)shop_common);
    mDemo_Set_ListenAble();
}

static void aNSC_set_sell_camera(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    PLAYER_ACTOR* player;
    xyz_t wpos;
    f32 bg_y;

    player = GET_PLAYER_ACTOR(play);
    mFI_UtNum2CenterWpos(&wpos, shop_common->ut_x, shop_common->ut_z);
    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_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    if (shop_common->action >= aNSC_ACTION_SELL_CHECK_BEFORE && shop_common->action <= aNSC_ACTION_CHG_CLOTH_END_WAIT) {
        switch (ITEM_NAME_GET_TYPE(shop_common->sell_item)) {
            case NAME_TYPE_FTR0:
            case NAME_TYPE_FTR1:
                aNSC_set_sell_camera(shop_common, play);
                break;
            case NAME_TYPE_ITEM1:
                switch (ITEM_NAME_GET_CAT(shop_common->sell_item)) {
                    case ITEM1_CAT_CLOTH:
                        break;
                    case ITEM1_CAT_TOOL:
                        if (ITEM_IS_UMBRELLA2(shop_common->sell_item)) {
                            break;
                        }
                        // fall through
                    default:
                        return;
                }
                aNSC_set_sell_camera(shop_common, 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_COMMON_ACTOR* shop_common) {
    shop_common->npc_class.actor_class.speed = 0.0;
    shop_common->npc_class.movement.speed.max_speed = 0.0;
    shop_common->npc_class.movement.speed.acceleration = 0.0;
    shop_common->npc_class.movement.speed.deceleration = 0.0;
}

static void aNSC_set_walk_spd(NPC_SHOP_COMMON_ACTOR* shop_common) {
    shop_common->npc_class.movement.speed.max_speed = 1.0;
    shop_common->npc_class.movement.speed.acceleration = 0.1;
    shop_common->npc_class.movement.speed.deceleration = 0.2;
}

static void aNSC_set_run_spd(NPC_SHOP_COMMON_ACTOR* shop_common) {
    shop_common->npc_class.movement.speed.max_speed = 4.0;
    shop_common->npc_class.movement.speed.acceleration = 0.4;
    shop_common->npc_class.movement.speed.deceleration = 0.8;
}

#ifndef aNSC_MAMEDANUKI
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);
}
#endif

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_COMMON_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_COMMON_ACTOR* shop_common) {
    mMsg_Window_c* msg_win = mMsg_Get_base_window_p();
    mMsg_Set_free_str(msg_win, mMsg_FREE_STR6, shop_common->pw_town_str, aNSC_PW_TOWN_STR_LEN);
    mMsg_Set_free_str(msg_win, mMsg_FREE_STR7, shop_common->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, sizeof(value_str), TRUE, FALSE, TRUE);
    mMsg_Set_free_str(mMsg_Get_base_window_p(), p2, value_str, sizeof(value_str));
}

static void aNSC_set_item_name_str(mActor_name_t itm, u32 p2) {
    u8 buff[mIN_ITEM_NAME_LEN];
    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, mIN_ITEM_NAME_LEN, art);
}

static void aNSC_set_item_str(ACTOR* actorx) {
    NPC_SHOP_COMMON_ACTOR* shop_common = (NPC_SHOP_COMMON_ACTOR*)actorx;
    u16 item = shop_common->sell_item;
    u32 value;

    aNSC_set_item_name_str(item, 0);
    value = mSP_ItemNo2ItemPrice(item);
    aNSC_set_value_str(value, 4);
    shop_common->value = value;
}

static void aNSC_set_pw_password_str(NPC_SHOP_COMMON_ACTOR* shop_common) {
    mMsg_Window_c* msg_win = mMsg_Get_base_window_p();
    u8* msg = shop_common->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_COMMON_ACTOR* shop_common) {
    mMsg_Window_c* msg_win = mMsg_Get_base_window_p();
    mMsg_Set_free_str(msg_win, mMsg_FREE_STR6, shop_common->password.str1, 8);
    mMsg_Set_free_str(msg_win, mMsg_FREE_STR7, shop_common->password.str0, 8);
    aNSC_set_item_name_str(shop_common->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_COMMON_ACTOR* shop_common) {
    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_user, aNSC_pc_check_password_card_e_mini,
    };

    int res = aNSC_PSW_RES_0;
    u8 buff[24];

    if (shop_common->password_str[mMpswd_PASSWORD_STR_LEN - 1] == CHAR_SPACE) {
        res = aNSC_PSW_RES_9;
    } else {
        if (mMpswd_decode_code(buff, shop_common->password_str) == TRUE) {
            mMpswd_password_c* password = &shop_common->password;

            mMpswd_password(buff, password);
            if (mMpswd_password_zuru_check(password) == FALSE && mMpswd_check_present(password) == TRUE) {
                aNSC_set_pw_password_str(shop_common);
                aNSC_set_pw_info_str(shop_common);
                res = pc_check_password_proc[password->type](password);
            }
        }
    }

    return res;
}

static int aNSC_check_possession_item_make_password(NPC_SHOP_COMMON_ACTOR* shop_common) {
    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_common->password_flags = flags;

    return res;
}

static void aNSC_set_buy_sum_str(mActor_name_t item, u32 p2) {
    static int tani_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 + tani_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);
}

#ifndef aNSC_MAMEDANUKI
static int aNSC_decide_next_move_act(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    int res;
    ACTOR* player;
    if (ClObj_DID_COLLIDE(shop_common->npc_class.collision.pipe.collision_obj)) {
        return aNSC_ACTION_WAIT;
    } else {
        player = GET_PLAYER_ACTOR_ACTOR(play);
        if (player == NULL) {
            return shop_common->action;
        }
        if (aNSC_check_safe_zone(shop_common, player) == TRUE) {
            return aNSC_ACTION_WAIT;
        } else {
            if (shop_common->npc_class.actor_class.player_distance_xz < aNSC_PLAYER_DISTANCE ||
                shop_common->talk_start_tim == 0) {
                return aNSC_ACTION_WAIT;
            } else {
                f32 player_distance_xz = shop_common->npc_class.actor_class.player_distance_xz;
                if (shop_common->player_zone != shop_common->zone) {
                    if (shop_common->action != aNSC_ACTION_WALK_PL_OTHER_ZONE &&
                        shop_common->action != aNSC_ACTION_0x41_WALK_PL_OTHER_ZONE) {
                        shop_common->next_zone = aNSC_get_next_zone(shop_common->player_zone, shop_common->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_common->next_zone = shop_common->zone;
                    if (player_distance_xz < 90.0f) {
                        return aNSC_ACTION_0x3e_WAIT;
                    } else {
                        return aNSC_ACTION_0x40_WAIT;
                    }
                }
            }
        }
    }
}
#else
static int aNSC_decide_next_move_act(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    ACTOR* player = GET_PLAYER_ACTOR_ACTOR(play);
    ACTOR* talk_actor = mDemo_Get_talk_actor();
    int res;

    if (player == NULL) {
        res = shop_common->action;
    } else if (ClObj_DID_COLLIDE(shop_common->npc_class.collision.pipe.collision_obj) &&
               shop_common->npc_class.collision.pipe.collision_obj.collided_actor == player) {
        res = aNSC_ACTION_WAIT;
    } else if (talk_actor != NULL && talk_actor != (ACTOR*)shop_common && mDemo_Check_ListenAble() == TRUE &&
               (ClObj_DID_COLLIDE(shop_common->npc_class.collision.pipe.collision_obj) ||
                shop_common->action == aNSC_ACTION_WAIT)) {
        res = aNSC_ACTION_WAIT;
    } else if (player->world.position.z < 120.0f && (shop_common->zone == 2 || shop_common->zone == 3)) {
        res = aNSC_ACTION_WAIT;
    } else {
        f32 dist = shop_common->npc_class.actor_class.player_distance_xz;

        if (dist < 80.0f || shop_common->talk_start_tim == 0) {
            res = aNSC_ACTION_WAIT;
        } else if (shop_common->player_zone != shop_common->zone) {
            if (shop_common->action != aNSC_ACTION_WALK_PL_OTHER_ZONE &&
                shop_common->action != aNSC_ACTION_0x41_WALK_PL_OTHER_ZONE) {
                shop_common->next_zone = aNSC_get_next_zone(shop_common, shop_common->player_zone, shop_common->zone);
            }

            if (dist < 110.0f) {
                res = aNSC_ACTION_WALK_PL_OTHER_ZONE;
            } else {
                res = aNSC_ACTION_0x41_WALK_PL_OTHER_ZONE;
            }
        } else {
            shop_common->next_zone = shop_common->zone;
            if (dist < 110.0f) {
                res = aNSC_ACTION_0x3e_WAIT;
            } else {
                res = aNSC_ACTION_0x40_WAIT;
            }
        }
    }

    return res;
}
#endif

#ifndef aNSC_MAMEDANUKI
static void aNSC_set_zone_data(NPC_SHOP_COMMON_ACTOR* shop_common, ACTOR* a2) {
    ACTOR* actorx = (ACTOR*)shop_common;

    shop_common->zone = aNSC_get_zone(shop_common->npc_class.actor_class.world.position);
    if (a2 != NULL) {
        shop_common->player_zone = aNSC_get_zone(a2->world.position);
    }
}
#else
static void aNSC_set_zone_data(NPC_SHOP_COMMON_ACTOR* shop_common, ACTOR* a2) {
    ACTOR* actorx = (ACTOR*)shop_common;

    shop_common->zone = aNSC_get_zone(shop_common, shop_common->npc_class.actor_class.world.position);
    if (a2 != NULL) {
        shop_common->player_zone = aNSC_get_zone(shop_common, a2->world.position);
    }
}
#endif

static void aNSC_set_player_angl(NPC_SHOP_COMMON_ACTOR* shop_common) {
    shop_common->player_angle = shop_common->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) {
    mActor_name_t* item = Now_Private->inventory.pockets;
    int res = aNSC_CHECK_BUY_NORMAL_SUB;
    int i;

    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_COMMON_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_COMMON_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_COMMON_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) {
#ifndef aNSC_MAMEDANUKI
    if (msg_no < 0) {
        msg_no = 0x082A;
    } else if (msg_no < 100) {
        msg_no += 0x107B;
    } else if (msg_no < 200) {
        msg_no += 0x2BAF;
    } else if (msg_no < 300) {
        msg_no += 0x2DE6;
    } else {
        msg_no += 0x3CD2;
    }

    return msg_no;
#else
    if (msg_no < 0) {
        msg_no = 0x082A;
    } else if (msg_no < 200) {
        msg_no += 0x16FD;
    } else if (msg_no < 300) {
        msg_no += 0x2DE7;
    } else {
        msg_no += 0x3CF0;
    }

    return msg_no;
#endif
}

static void aNSC_Set_continue_msg_num(mMsg_Window_c* msg_p, NPC_SHOP_COMMON_ACTOR* shop_common, int msg_no) {
    mMsg_Set_continue_msg_num(msg_p, msg_no);
    shop_common->msg_no = msg_no;
}

static void aNSC_ChangeMsgData(mMsg_Window_c* msg_p, NPC_SHOP_COMMON_ACTOR* shop_common, int msg_no) {
    mMsg_ChangeMsgData(msg_p, msg_no);
    shop_common->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(ACTOR* actorx) {
    aNSC_set_item_str(actorx);
    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(ACTOR* actorx) {
    aNSC_set_item_str(actorx);
    aNSC_set_player_angle();
    mDemo_Set_camera(CAMERA2_PROCESS_NUM);
#ifndef aNSC_MAMEDANUKI
    mDemo_Set_msg_num(aNSC_get_msg_no(aNSC_MSG_SHOW_CLOTH));
#else
    mDemo_Set_msg_num(aNSC_get_msg_no(aNSC_ACTION_WAIT));
#endif
}

static void aNSC_set_talk_info_sell_item(ACTOR* actorx) {
    NPC_SHOP_COMMON_ACTOR* shop_common = (NPC_SHOP_COMMON_ACTOR*)actorx;
    mActor_name_t item = shop_common->sell_item;
    u8 camera_type;
    int msg_no = aNSC_MSG_BUY_ONE_OFFER;

    aNSC_set_item_str(actorx);
    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(ACTOR* actorx) {
    mDemo_Set_msg_num(aNSC_get_msg_no(aNSC_MSG_INTERACT_START));
}

#ifndef aNSC_MAMEDANUKI

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);
}

#endif

#ifdef aNSC_MAMEDANUKI

static void aNSC_set_talk_info_fukubiki(ACTOR* actorx) {
    mDemo_Set_camera(CAMERA2_PROCESS_NORMAL);
    mDemo_Set_msg_num(0x10E2);
}

static void aNSC_message_ctrl_force_talk_start_normal_day(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mActor_name_t sell_item = shop_common->sell_item;

    if (sell_item != EMPTY_NO) {
        int next_act_idx = aNSC_ACTION_SELL_CHECK_BEFORE;

        if (ITEM_NAME_GET_TYPE(sell_item) == NAME_TYPE_ITEM1) {
            switch (ITEM_NAME_GET_CAT(sell_item)) {
                case ITEM1_CAT_CLOTH:
                case ITEM1_CAT_CARPET:
                case ITEM1_CAT_WALL:
                    next_act_idx = aNSC_ACTION_SHOW_ITEM_CHECK;
                    break;
                default:
                    if (ITEM_IS_PAINT(sell_item) && mLd_PlayerManKindCheck()) {
                        next_act_idx = aNSC_ACTION_REQUEST_Q_END_WAIT;
                    }
                    break;
            }
        }

        aNSC_setupAction(shop_common, play, next_act_idx);
    }
}

static void aNSC_message_ctrl_force_talk_start_fukubiki_day(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    aNSC_setupAction(shop_common, play, aNSC_ACTION_SAY_HELLO_END_WAIT);
}

static void aNSC_message_ctrl_norm_talk_start_normal_day(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    aNSC_setupAction(shop_common, play, aNSC_ACTION_REQUEST_Q_ANSWER_WAIT);
}

static void aNSC_message_ctrl_norm_talk_start_fukubiki_day(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    aNSC_setupAction(shop_common, play, aNSC_ACTION_SAY_HELLO_END_WAIT);
}

static void aNSC_message_ctrl_talk_request_normal_day(NPC_SHOP_COMMON_ACTOR* shop_common, PLAYER_ACTOR* player) {
    shop_common->sell_item = EMPTY_NO;

    if (player->a_btn_pressed == TRUE) {
        mActor_name_t fg_item;
        int ux;
        int uz;

        mFI_Wpos2UtNum(&ux, &uz, player->forward_ut_pos);
        fg_item = CLIP(shop_design_clip)->unitNum2ItemNo_proc(ux, uz);

        if (fg_item != EMPTY_NO && fg_item != RSV_NO) {
            mDemo_REQUEST_PROC req_proc = (mDemo_REQUEST_PROC)none_proc1;

            shop_common->sell_item = fg_item;
            shop_common->ut_x = ux;
            shop_common->ut_z = uz;

            switch (ITEM_NAME_GET_TYPE(fg_item)) {
                case NAME_TYPE_FTR0:
                case NAME_TYPE_FTR1:
                    req_proc = aNSC_set_talk_info_sell_item;
                    break;
                case NAME_TYPE_ITEM1:
                    switch (ITEM_NAME_GET_CAT(fg_item)) {
                        case ITEM1_CAT_CARPET:
                        case ITEM1_CAT_WALL:
                            req_proc = aNSC_set_talk_info_show_item;
                            break;
                        case ITEM1_CAT_CLOTH:
                            req_proc = aNSC_set_talk_info_show_cloth;
                            break;
                        default:
                            req_proc = aNSC_set_talk_info_sell_item;
                            break;
                    }
                    break;
            }

            mDemo_Request(mDemo_TYPE_SPEAK, (ACTOR*)shop_common, req_proc);
            shop_common->talk_start_tim = -1;
        }
    }
}

static void aNSC_message_ctrl_talk_request_fukubiki_day(NPC_SHOP_COMMON_ACTOR* shop_common, PLAYER_ACTOR* player) {
    if (player->a_btn_pressed == TRUE) {
        mActor_name_t fg_item;
        int ux;
        int uz;

        mFI_Wpos2UtNum(&ux, &uz, player->forward_ut_pos);
        fg_item = CLIP(shop_design_clip)->unitNum2ItemNo_proc(ux, uz);

        if (fg_item != EMPTY_NO && fg_item != RSV_NO) {
            mDemo_Request(mDemo_TYPE_SPEAK, (ACTOR*)shop_common, &aNSC_set_talk_info_fukubiki);
            shop_common->talk_start_tim = -1;
        }
    }
}

static int aNSC_message_ctrl_sub(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play, PLAYER_ACTOR* player,
                                 int day_type) {
    static aNSC_TALK_PROC force_talk_start_proc[] = { &aNSC_message_ctrl_force_talk_start_normal_day,
                                                      &aNSC_message_ctrl_force_talk_start_fukubiki_day };
    static aNSC_TALK_PROC norm_talk_start_proc[] = { &aNSC_message_ctrl_norm_talk_start_normal_day,
                                                     &aNSC_message_ctrl_norm_talk_start_fukubiki_day };
    static aNSC_TALK_REQ_PROC request_proc[] = { &aNSC_message_ctrl_talk_request_normal_day,
                                                 &aNSC_message_ctrl_talk_request_fukubiki_day };
    static mDemo_REQUEST_PROC set_talk_info_proc[] = { &aNSC_set_talk_info_message_ctrl, &aNSC_set_talk_info_fukubiki };

    ACTOR* actorx = (ACTOR*)shop_common;
    int ret = FALSE;

    if (mDemo_Check(mDemo_TYPE_SPEAK, actorx) == TRUE) {
        if (!mDemo_Check_ListenAble()) {
            aNSC_calc_talk_start_tim(shop_common);

            if (actorx->player_distance_xz < 85.0f || shop_common->talk_start_tim == 0) {
                if (chase_angle(&actorx->shape_info.rotation.y, shop_common->player_angle, DEG2SHORT_ANGLE2(11.25f)) ==
                    TRUE) {
                    (*force_talk_start_proc[day_type])(shop_common, play);
                    shop_common->talk_start_tim = -1;
                    aNMD_selectIdx = (aNMD_selectIdx + 1) & 1;
                    aNSC_Set_ListenAble(shop_common);
                    ret = TRUE;
                }

                actorx->world.angle.y = actorx->shape_info.rotation.y;
            }
        }
    } else if (mDemo_Check(mDemo_TYPE_TALK, actorx) == TRUE) {
        if (!mDemo_Check_ListenAble()) {
            if (chase_angle(&actorx->shape_info.rotation.y, shop_common->player_angle, DEG2SHORT_ANGLE2(11.25f)) ==
                TRUE) {
                (*norm_talk_start_proc[day_type])(shop_common, play);
                aNSC_Set_ListenAble(shop_common);
                ret = TRUE;
            }

            actorx->world.angle.y = actorx->shape_info.rotation.y;
        }
    } else if (mDemo_Get_talk_actor() == NULL) {
        if (aNMD_selectIdx > 1) {
            aNMD_selectIdx = 0;
        }

        if (actorx == aNMD_actor_p[aNMD_selectIdx]) {
            (*request_proc[day_type])(shop_common, player);
        } else {
            shop_common->talk_start_tim = -1;
        }

        mDemo_Request(mDemo_TYPE_TALK, actorx, set_talk_info_proc[day_type]);
    }

    return ret;
}

static int aNSC_message_ctrl(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    ACTOR* player_actorx = GET_PLAYER_ACTOR_ACTOR(play);
    int ret = FALSE;

    if (player_actorx != NULL && CLIP(shop_design_clip) != NULL) {
        PLAYER_ACTOR* player = (PLAYER_ACTOR*)player_actorx;

        if (player->item_in_front == EXIT_DOOR1) {
            int next_act_idx;

            if ((ACTOR*)shop_common == aNMD_actor_p[aNMD_selectIdx]) {
                next_act_idx = aNSC_ACTION_GOODBYE_WAIT;
            } else {
                next_act_idx = aNSC_ACTION_GOODBYE_WAIT2;
            }

            aNSC_setupAction(shop_common, play, next_act_idx);
            ret = TRUE;
        } else if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_FUKUBIKI) {
            ret = aNSC_message_ctrl_sub(shop_common, play, player, aNSC_DAY_FUKUBIKI);
        } else {
            ret = aNSC_message_ctrl_sub(shop_common, play, player, aNSC_DAY_NORMAL);
        }
    }

    return ret;
}

#else

static int aNSC_message_ctrl(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common, play, aNSC_ACTION_GOODBYE_WAIT);
            res = TRUE;
        } else {
            ACTOR* actorx = (ACTOR*)shop_common;
            int action = 0;
            if (mDemo_Check(mDemo_TYPE_SPEAK, actorx) == TRUE) {
                if (mDemo_Check_ListenAble() == FALSE) {
                    aNSC_calc_talk_start_tim(shop_common);
                    if (shop_common->npc_class.actor_class.player_distance_xz < 80.0f ||
                        shop_common->talk_start_tim == 0) {
                        if (chase_angle(&shop_common->npc_class.actor_class.shape_info.rotation.y,
                                        shop_common->player_angle, DEG2SHORT_ANGLE(11.25f)) == TRUE) {
                            mActor_name_t item = shop_common->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_common, play, action);
                            }
                            aNSC_Set_ListenAble(shop_common);
                            shop_common->talk_start_tim = -1;
                            res = TRUE;
                        }
                        actorx->world.angle.y = actorx->shape_info.rotation.y;
                    }
                }
            } else {
                if (mDemo_Check(mDemo_TYPE_TALK, (ACTOR*)shop_common) == TRUE) {
                    if (!mDemo_Check_ListenAble()) {
                        action = aNSC_ACTION_SELL_CHECK_BEFORE;
                        if (chase_angle(&actorx->shape_info.rotation.y, shop_common->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_common->_9B9 == TRUE) {
                                    action = aNSC_ACTION_REQUEST_Q_END_WAIT;
                                } else {
                                    action = aNSC_ACTION_REQUEST_Q_ANSWER_WAIT;
                                }
                            }
                            aNSC_setupAction(shop_common, play, action);
                            aNSC_Set_ListenAble(shop_common);
                            res = TRUE;
                        }
                        actorx->world.angle.y = actorx->shape_info.rotation.y;
                    }
                } else {
                    void* demo_proc;
                    shop_common->sell_item = EMPTY_NO;

                    if (player->a_btn_pressed == TRUE) {
                        int ut_x, ut_z;
                        u16 item;

                        xyz_t wpos = player->forward_ut_pos;
                        mFI_Wpos2UtNum(&ut_x, &ut_z, wpos);
                        item = CLIP(shop_design_clip)->unitNum2ItemNo_proc(ut_x, ut_z);
                        if (item != EMPTY_NO && item != RSV_NO) {
                            void* sell_proc = none_proc1;
                            shop_common->sell_item = item;
                            shop_common->ut_x = ut_x;
                            shop_common->ut_z = ut_z;

                            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_common->talk_start_tim = -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_common->_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;
}

#endif

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;
}

#ifdef aNSC_MAMEDANUKI

static void aNSC_set_talk_info_start_wait(ACTOR* actorx) {
    int msg_no;

    if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_EVENT) {
        msg_no = 0x1722;
    } else if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_FUKUBIKI) {
        msg_no = 0x10E1;
    } else {
        msg_no = 0x1713;
    }

    mDemo_Set_msg_num(msg_no);
}

static void aNSC_start_wait(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    ACTOR* actorx = (ACTOR*)shop_common;

    if (mDemo_Check(mDemo_TYPE_SPEAK, actorx) == TRUE) {
        if (!mDemo_Check_ListenAble()) {
            aNSC_Set_ListenAble(shop_common);
            aNSC_setupAction(shop_common, play, aNSC_ACTION_SAY_HELLO_APPROACH);
        }
    } else {
        mDemo_Request(mDemo_TYPE_SPEAK, actorx, &aNSC_set_talk_info_start_wait);
    }
}

#else

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_COMMON_ACTOR* shop_common = (NPC_SHOP_COMMON_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_common->next_action = 1;
}

static void aNSC_set_talk_info_start_wait1(ACTOR* actor) {
    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_COMMON_ACTOR* shop_common = (NPC_SHOP_COMMON_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_common->next_action = aNSC_ACTION_PRESENT_BALLOON_START_WAIT;
}

static void aNSC_set_talk_info_start_wait3(ACTOR* actorx) {
    NPC_SHOP_COMMON_ACTOR* shop_common = (NPC_SHOP_COMMON_ACTOR*)actorx;
    int msg_no = aNSC_get_start_call_msg_no(actorx);
    mDemo_Set_msg_num(aNSC_get_msg_no(msg_no));
    shop_common->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_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    ACTOR* actorx = (ACTOR*)shop_common;
    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_common->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_common);
        aNSC_setupAction(shop_common, 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);
}
#endif

#ifdef aNSC_MAMEDANUKI

static void aNSC_say_hello_approach(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    ACTOR* actorx = (ACTOR*)shop_common;

    if (actorx->world.position.z < 160.0f) {
        actorx->world.position.z = 160.0f;
        aNSC_setupAction(shop_common, play, shop_common->action + 1);
    } else if (!mDemo_Check(mDemo_TYPE_SPEAK, actorx) && !mDemo_Check(mDemo_TYPE_TALK, actorx)) {
        aNSC_setupAction(shop_common, play, shop_common->action + 1);
    }
}

#else

static void aNSC_say_hello_approach(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    ACTOR* actorx = (ACTOR*)shop_common;
    f32 z = aNSC_POS_Z_MAX;
    if (actorx->world.position.z > z) {
        actorx->world.position.z = z;
        aNSC_setupAction(shop_common, 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_common, play, aNSC_ACTION_SAY_HELLO_END_WAIT);
    }
}

#endif

static void aNSC_say_hello_end_wait(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    ACTOR* actorx = (ACTOR*)shop_common;
    if (mDemo_Check(mDemo_TYPE_SPEAK, actorx) == FALSE) {
        if (mDemo_Check(mDemo_TYPE_TALK, actorx) == FALSE) {
            shop_common->npc_class.talk_info.melody_inst = 0;
            aNSC_setupAction(shop_common, play, aNSC_ACTION_WAIT);
        }
    }
}

#ifndef aNSC_MAMEDANUKI

static void aNSC_check_col_chg_or_make_basement(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    f32 z = aNSC_POS_Z_MAX;
    if (((ACTOR*)shop_common)->world.position.z > z) {
        ((ACTOR*)shop_common)->world.position.z = z;
        aNSC_set_stop_spd(shop_common);
        CLIP(npc_clip)->animation_init_proc((ACTOR*)shop_common, 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_common, play, action);
    }
}

static void aNSC_check_roof_col_order(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    f32 z = aNSC_POS_Z_MAX;
    int unk = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9);
    if (((ACTOR*)shop_common)->world.position.z > z) {
        ((ACTOR*)shop_common)->world.position.z = z;
        aNSC_set_stop_spd(shop_common);
        CLIP(npc_clip)->animation_init_proc((ACTOR*)shop_common, 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_common, play, action);
        }
    }
}

static void aNSC_check_roof_col_order2(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common, play, action);
    }
}

static void aNSC_present_balloon_start_wait(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    if ((int)mDemo_Get_OrderValue(mDemo_TYPE_4, 0x1) == 2) {
        aNSC_setupAction(shop_common, play, aNSC_ACTION_PRESENT_BALLOON_TRANS_MOVE);
    }
}

static void aNSC_present_balloon_trans_move(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    ACTOR* actorx = (ACTOR*)shop_common;
    if (actorx->world.position.z > aNSC_POS_Z_MAX) {
        actorx->world.position.z = aNSC_POS_Z_MAX;
        aNSC_setupAction(shop_common, play, aNSC_ACTION_PRESENT_BALLOON_TRANS_TAKEOUT);
    }
}

static void aNSC_present_balloon_trans_takeout(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    ACTOR* actorx = (ACTOR*)shop_common;
    ACTOR* res;
    if (shop_common->npc_class.left_hand.item_actor_p == NULL) {
        res = CLIP(handOverItem_clip)
                  ->birth_proc(ITM_BALLOON_START, aHOI_REQUEST_PUTAWAY, aHOI_PRESENT, (ACTOR*)shop_common);
        if (res) {
            CLIP(handOverItem_clip)->chg_request_mode_proc((ACTOR*)shop_common, aHOI_REQUEST_TRANSFER);

            shop_common->npc_class.left_hand.item_actor_p = res;
        }
    }

    if (shop_common->npc_class.draw.main_animation_state == cKF_STATE_STOPPED) {
        if (CLIP(handOverItem_clip)->master_actor == (ACTOR*)shop_common) {
            CLIP(handOverItem_clip)->chg_request_mode_proc((ACTOR*)shop_common, aHOI_REQUEST_TRANS_WAIT);
            aNSC_setupAction(shop_common, play, aNSC_ACTION_PRESENT_BALLOON_TRANS_WAIT);
        }
    }
}

static void aNSC_present_balloon_trans_wait(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    if (CLIP(handOverItem_clip)->master_actor != (ACTOR*)shop_common) {
        aNSC_setupAction(shop_common, play, aNSC_ACTION_PRESENT_BALLOON_END_WAIT);
    }
}

static void aNSC_present_balloon_end_wait(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    if (CLIP(handOverItem_clip)->master_actor == NULL) {
        mMsg_Unset_LockContinue(mMsg_Get_base_window_p());
        aNSC_setupAction(shop_common, play, aNSC_ACTION_SAY_HELLO_END_WAIT);
    }
}

#endif

static void aNSC_set_talk_info_request_Q_start_wait(ACTOR* actor) {
    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_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    ACTOR* actorx = (ACTOR*)shop_common;
    if (mDemo_Check(mDemo_TYPE_TALK, actorx) == TRUE) {
        if (mDemo_Check_ListenAble() == FALSE) {
            aNSC_Set_ListenAble(shop_common);
            aNSC_setupAction(shop_common, 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_COMMON_ACTOR* shop_common, 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_common, aNSC_get_msg_no(msg_no[next]));
            aNSC_setupAction(shop_common, play, next_act_idx[next]);
        }
    }
}

static void aNSC_request_Q_answer_wait2(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common) == 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_common, aNSC_get_msg_no(msg_no[next]));
            aNSC_setupAction(shop_common, play, next_act_idx[next]);
        }
    }
}

static void aNSC_request_Q_end_wait(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    ACTOR* actorx = (ACTOR*)shop_common;
    if (mDemo_Check(mDemo_TYPE_SPEAK, actorx) == FALSE && mDemo_Check(mDemo_TYPE_TALK, actorx) == FALSE) {
        shop_common->sell_item = EMPTY_NO;
        aNSC_setupAction(shop_common, play, aNSC_ACTION_WAIT);
    }
}

static void aNSC_answer_buy_item(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common, play, shop_common->action + 1);
        }
    }
}

static void aNSC_buy_menu_open_wait(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    if (mMsg_Check_main_wait(mMsg_Get_base_window_p()) == TRUE) {
        aNSC_setupAction(shop_common, play, shop_common->action + 1);
    }
}

static void aNSC_buy_menu_close_wait(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    if (play->submenu.open_flag == FALSE) {
        aNSC_setupAction(shop_common, play, shop_common->action + 1);
    }
}

static void aNSC_msg_win_open_wait(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common, submenu);
        }
        if (action == aNSC_CHECK_BUY_OFFER_BUY_ALL) {
#ifdef aNSC_MAMEDANUKI
            msg_no = 0x173D;
#else
            msg_no = 0x108A;
#endif
        } else {
            msg_no = aNSC_get_msg_no(msg_no_table[action]);
        }
        aNSC_Set_continue_msg_num(msg_p, shop_common, msg_no);
        mMsg_Set_ForceNext(msg_p);
        aNSC_setupAction(shop_common, play, next_act_idx[action]);
    }
}

static void aNSC_buy_sum_check(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common->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_common, aNSC_get_msg_no(aNSC_MSG_SELL_OFFER));
            aNSC_setupAction(shop_common, play, aNSC_ACTION_BUY_CHECK);
        }
    }
}

static void aNSC_buy_check(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common->counter;
                    Submenu_Item_c* submenu_item = play->submenu.item_p;
                    bells += shop_common->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_common->money / 2);
                        if (counter == 1) {
                            next = aNSC_buy_item_only_one(&bells, item, (u8*)submenu_item, shop_common->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_common, aNSC_get_msg_no(msg_no[next]));
                aNSC_setupAction(shop_common, play, next_act_idx[next]);
            }
        }
    }
}

static void aNSC_buy_after_service(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common, play, aNSC_ACTION_BUY_CONTINUE_CHECK);
        }
    }
}

static void aNSC_buy_continue_check(NPC_SHOP_COMMON_ACTOR* shop_common, 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:
#ifdef aNSC_MAMEDANUKI
                    aNSC_Set_continue_msg_num(msg_p, shop_common, aNSC_get_msg_no(aNSC_MSG_3C));
#else
                    aNSC_Set_continue_msg_num(msg_p, shop_common, aNSC_get_msg_no(aNSC_MSG_CANCEL));
#endif
                    action = 1;
                    break;
            }
            if (action != -1) {
                aNSC_setupAction(shop_common, play, next_act_idx[action]);
            }
        }
    }
}

static void aNSC_receive_check(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mMsg_Window_c* msg_p = mMsg_Get_base_window_p();
    int no = mMsg_Get_msg_num(msg_p);
    if (shop_common->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_common, play, aNSC_ACTION_REQUEST_Q_ANSWER_WAIT);
        }
    }
}

static void aNSC_msg_win_open_wait2(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common->order_item = item;
        }
        aNSC_ChangeMsgData(msg_p, shop_common, aNSC_get_msg_no(msg_no[action]));
        mMsg_Set_ForceNext(msg_p);
        aNSC_setupAction(shop_common, play, next_act_idx[action]);
    }
}

static void aNSC_order_check(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mMsg_Window_c* msg_p = mMsg_Get_base_window_p();
    if (mMsg_Get_msg_num(msg_p) == shop_common->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_common->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_common);
                        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_common, aNSC_get_msg_no(msg_no));
                aNSC_setupAction(shop_common, play, aNSC_ACTION_REQUEST_Q_ANSWER_WAIT);
            }
        }
    }
}

static void aNSC_sell_check_before(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    if (mDemo_Get_OrderValue(mDemo_TYPE_4, 0x9)) {
        mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0);
        aNSC_setupAction(shop_common, play, aNSC_ACTION_SELL_CHECK);
    }
}

static void aNSC_sell_check(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common->is_selling == TRUE && ITEM_NAME_GET_CAT(shop_common->sell_item) == ITEM1_CAT_CLOTH) {
                shop_common->next_action = action;
                action = aNSC_ACTION_CHG_CLOTH_START_WAIT;
                shop_common->change_cloth = shop_common->player_cloth;
            }
            aNSC_setupAction(shop_common, play, action);
        }
    }
}

static void aNSC_sell_answer0(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common->value) == FALSE) {
                next = 0x3;
            } else {
                mActor_name_t item = shop_common->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_common, aNSC_get_msg_no(msg_no[next]));
            mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0);
            aNSC_setupAction(shop_common, play, next_act_idx[next]);
        }
    }
}

static void aNSC_sell_item_with_ticket(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common, aNSC_get_msg_no(RANDOM(3) + aNSC_MSG_TICKET_1));
            mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0);
            aNSC_setupAction(shop_common, play, aNSC_ACTION_REQUEST_Q_END_WAIT);
        }
    }
}

static void aNSC_show_item_check(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mMsg_Window_c* msg_p = mMsg_Get_base_window_p();
    if (mMsg_Check_MainNormalContinue(msg_p)) {
        mActor_name_t item = shop_common->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_common->ut_x, shop_common->ut_z);
                        action = aNSC_ACTION_CHG_CLOTH_START_WAIT;
#ifndef aNSC_MAMEDANUKI
                        msg_no = aNSC_MSG_CONFIRM_CLOTH;
#else
                        msg_no = aNSC_MSG_3E;
#endif
                        shop_common->next_action = aNSC_ACTION_SELL_CHECK_BEFORE;
                        shop_common->player_cloth = Now_Private->cloth.item;
                        shop_common->change_cloth = shop_common->sell_item;
                        break;
                }
                shop_common->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:
#ifndef aNSC_MAMEDANUKI
                        msg_no = aNSC_MSG_CANCEL_CLOTH;
#else
                        msg_no = aNSC_MSG_3F;
#endif
                        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_common, aNSC_get_msg_no(msg_no));
            mMsg_Set_ForceNext(msg_p);
            aNSC_setupAction(shop_common, play, action);
        }
    }
}

static void aNSC_chg_cloth_start_wait(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    if (mPlib_get_player_actor_main_index((GAME*)play) == mPlayer_INDEX_CHANGE_CLOTH) {
        aNSC_setupAction(shop_common, play, aNSC_ACTION_CHG_CLOTH_END_WAIT);
    } else {
        mActor_name_t item = shop_common->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_COMMON_ACTOR* shop_common, 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_common, play, shop_common->next_action);
    }
}

static void aNSC_pw_entry_send_addr_start_wait(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common, play, aNSC_ACTION_2A_BUY_MENU_OPEN_WAIT);
        }
    }
}

static void aNSC_pw_msg_win_open_wait(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common->pw_town_str, mLd_GetLandName()) == FALSE) {
            next = 1;
        }
        aNSC_ChangeMsgData(msg_p, shop_common, aNSC_get_msg_no(msg_no[next]));
        mMsg_Set_ForceNext(msg_p);
        aNSC_setupAction(shop_common, play, next_act_idx[next]);
    }
}

static void aNSC_pw_send_addr_check(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common, play, next_act_idx[choice]);
            }
        }
    }
}

static void aNSC_pw_sel_item_start_wait(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common, play, aNSC_ACTION_2F_BUY_MENU_OPEN_WAIT);
        }
    }
}

static void aNSC_pw_msg_win_open_wait2(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common->pw_item = item;
            aNSC_set_item_name_str(item, 0x2);
            action = 1;
        }
        aNSC_ChangeMsgData(msg_p, shop_common, aNSC_get_msg_no(msg_no[action]));
        mMsg_Set_ForceNext(msg_p);
        aNSC_setupAction(shop_common, play, next_act_idx[action]);
    }
}

static void aNSC_pw_send_check(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common->password_str, 0x4, 0x1, shop_common->pw_recip_str,
                                         shop_common->pw_town_str, shop_common->pw_item, 0x0, 0x0);
                    aNSC_set_pw_password_str(shop_common);
                    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_common, play, next_act_idx[choice]);
            }
        }
    }
}

static void aNSC_pw_retry_sel_item_check(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common, play, next_act_idx[choice]);
            }
        }
    }
}

static void aNSC_pc_input_pw_start_wait(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common, play, aNSC_ACTION_35_BUY_MENU_OPEN_WAIT);
        }
    }
}

static void aNSC_pc_msg_win_open_wait(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common);
        aNSC_ChangeMsgData(msg_p, shop_common, aNSC_get_msg_no(msg_no[act]));
        mMsg_Set_ForceNext(msg_p);
        aNSC_setupAction(shop_common, play, next_act_idx[act]);
    }
}

static void aNSC_pc_retry_input_pw_check(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common, aNSC_get_msg_no(aNSC_MSG_PSWD_DECLINE));
                    break;
            }
            if (choice != -1) {
                mMsg_Set_ForceNext(msg_p);
                aNSC_setupAction(shop_common, play, next_act_idx[choice]);
            }
        }
    }
}

static void aNSC_pc_present_start_wait(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    int value = mDemo_Get_OrderValue(mDemo_TYPE_4, 0x01);
    if (value == 0x2) {
        aNSC_setupAction(shop_common, play, aNSC_ACTION_PC_PRESENT_TRANS_TAKEOUT);
    }
}

static void aNSC_pc_present_trans_takeout(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    if (shop_common->npc_class.left_hand.item_actor_p == NULL) {
        ACTOR* actor = CLIP(handOverItem_clip)->birth_proc(shop_common->password.item, 0x7, 0x1, (ACTOR*)shop_common);
        if (actor) {
            CLIP(handOverItem_clip)->chg_request_mode_proc((ACTOR*)shop_common, 0x1);
            shop_common->npc_class.left_hand.item_actor_p = actor;
        }
    }
    if (shop_common->npc_class.draw.main_animation_state == cKF_STATE_STOPPED) {
        if (CLIP(handOverItem_clip)->master_actor == (ACTOR*)shop_common) {
            CLIP(handOverItem_clip)->chg_request_mode_proc((ACTOR*)shop_common, aHOI_REQUEST_TRANS_WAIT);
            aNSC_setupAction(shop_common, play, aNSC_ACTION_PC_PRESENT_TRANS_WAIT);
        }
    }
}

static void aNSC_pc_present_trans_wait(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    if (CLIP(handOverItem_clip)->master_actor != (ACTOR*)shop_common) {
        aNSC_setupAction(shop_common, play, aNSC_ACTION_PC_PRESENT_END_WAIT);
    }
}

static void aNSC_pc_present_end_wait(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    if (CLIP(handOverItem_clip)->master_actor == NULL) {
        mMsg_Unset_LockContinue(mMsg_Get_base_window_p());
        aNSC_setupAction(shop_common, play, aNSC_ACTION_REQUEST_Q_END_WAIT);
    }
}

static void aNSC_wait(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    if (aNSC_message_ctrl(shop_common, play) != TRUE) {
        int act = aNSC_decide_next_move_act(shop_common, play);
        if (act != shop_common->action) {
            aNSC_setupAction(shop_common, play, act);
        } else {
            aNSC_search_player(shop_common, play);
        }
    }
}

static void aNSC_walk_pl_other_zone(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    if (aNSC_message_ctrl(shop_common, play) != TRUE) {
        int act = aNSC_decide_next_move_act(shop_common, play);
        if (act != shop_common->action) {
            aNSC_setupAction(shop_common, play, act);
        } else {
            aNSC_search_player2(shop_common, play);
        }
    }
}

static void aNSC_turn(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    ACTOR* actorx = (ACTOR*)shop_common;
    if (aNSC_message_ctrl(shop_common, play) != TRUE) {
        if (GET_PLAYER_ACTOR(play)) {
            s16 player_angle = shop_common->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_common, play, aNSC_ACTION_WAIT);
            }
        }
    }
}

static void aNSC_set_talk_info_goodbye_wait(ACTOR* actor) {
    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_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    ACTOR* actorx = (ACTOR*)shop_common;
    if (mDemo_Check(mDemo_TYPE_SPEAK, (ACTOR*)shop_common) == TRUE) {
        if (mDemo_Check_ListenAble() == FALSE) {
            s16 player_angle = shop_common->player_angle;
            if (chase_angle(&actorx->shape_info.rotation.y, player_angle, DEG2SHORT_ANGLE(11.25f)) == TRUE) {
#ifdef aNSC_MAMEDANUKI
                mBGMForce_room_nonstop_start();
#endif
                aNSC_Set_ListenAble(shop_common);
                aNSC_setupAction(shop_common, play, aNSC_ACTION_SAY_GOODBYE);
            }
        }
    } else {
        mDemo_Request(mDemo_TYPE_SPEAK, actorx, aNSC_set_talk_info_goodbye_wait);
    }
}

#ifdef aNSC_MAMEDANUKI

static void aNSC_goodbye_wait2(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    chase_angle(&shop_common->npc_class.actor_class.shape_info.rotation.y, shop_common->player_angle,
                DEG2SHORT_ANGLE2(11.25f));
}

#endif

static void aNSC_say_goodbye(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common, play, aNSC_ACTION_EXIT_WAIT);
    }
}

static void aNSC_exit_wait(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
#ifdef aNSC_MAMEDANUKI
    // clang-format off
    static Door_data_c stairs = {
        SCENE_DEPART,
        mSc_DIRECT_SOUTH,
        0,
        0,
        { 300, 40, 65 },
        EMPTY_NO,
        2,
        0,
        0
    };
    // clang-format on

    if (mMsg_Check_main_wait(mMsg_Get_base_window_p()) == TRUE) {
        goto_other_scene(play, &stairs, TRUE);
        if (play->fb_wipe_mode == WIPE_MODE_NONE) {
            play->fb_fade_type = FADE_TYPE_OTHER_ROOM;
            mBGMPsComp_volume_talk_end();
            mBGMPsComp_make_ps_wipe(0x195);
        }
    }

#else

    if (mMsg_Check_main_wait(mMsg_Get_base_window_p()) == TRUE) {
        goto_other_scene(play, Common_GetPointer(structure_exit_door_data), TRUE);
        if (play->fb_wipe_mode == WIPE_MODE_NONE) {
            mBGMPsComp_scene_mode(0xe);
            mBGMPsComp_volume_talk_end();
            mBGMPsComp_make_ps_wipe(0x195);
        }
    }
#endif
}

static void aNSC_say_hello_approach_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    aNSC_set_walk_spd(shop_common);
}

static void aNSC_say_hello_end_wait_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    shop_common->next_zone = shop_common->zone;
    aNSC_set_stop_spd(shop_common);
}

#ifndef aNSC_MAMEDANUKI

static void aNSC_check_col_chg_or_make_basement_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    aNSC_set_walk_spd(shop_common);
}

static void aNSC_check_roof_col_order_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0);
    aNSC_set_walk_spd(shop_common);
}

static void aNSC_check_roof_col_order2_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0);
}

static void aNSC_present_balloon_start_wait_init(NPC_SHOP_COMMON_ACTOR* shop_common, 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_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    int rand;
    mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x1, 0x0);
    aNSC_set_walk_spd(shop_common);
    rand = RANDOM(8);
    mPr_SetFreePossessionItem(Now_Private, ITM_BALLOON_START + rand, mPr_ITEM_COND_PRESENT);
    mMsg_Set_LockContinue(mMsg_Get_base_window_p());
    shop_common->npc_class.head.lock_flag = TRUE;
}

static void aNSC_present_balloon_trans_takeout_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    ACTOR* actorx = (ACTOR*)shop_common;
    shop_common->next_zone = shop_common->zone;
    aNSC_set_stop_spd(shop_common);
    sAdo_OngenTrgStart(0x69, &actorx->world.position);
}

static void aNSC_present_balloon_end_wait_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    shop_common->npc_class.left_hand.item_actor_p = NULL;
    shop_common->npc_class.head.lock_flag = FALSE;
}

#endif

static void aNSC_request_Q_answer_wait_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0);
    aNSC_set_stop_spd(shop_common);
}

static void aNSC_request_Q_end_wait_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    aNSC_set_stop_spd(shop_common);
}

static void aNSC_answer_buy_item_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mDemo_Set_OrderValue(mDemo_TYPE_4, 9, 0);
}

static void aNSC_buy_menu_open_wait_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mMsg_request_main_disappear_wait_type1(mMsg_Get_base_window_p());
}

static void aNSC_buy_menu_close_wait_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mSM_open_submenu(&play->submenu, mSM_OVL_INVENTORY, 0x5, 0x0);
    shop_common->next_action = 0x13;
}

static void aNSC_msg_win_open_wait_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mMsg_request_main_appear_wait_type1(mMsg_Get_base_window_p());
}

static void aNSC_buy_sum_check_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0);
}

static void aNSC_buy_check_init(NPC_SHOP_COMMON_ACTOR* shop_common, 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_common->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_common->money = value;
    aNSC_set_value_str(value, 0x2);
}

static void aNSC_buy_after_service_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0);
}

static void aNSC_order_select_menu_close_wait_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mSM_open_submenu(&play->submenu, mSM_OVL_CATALOG, 0x0, 0x0);
    shop_common->next_action = aNSC_ACTION_MSG_WIN_OPEN_WAIT2;
}

static void aNSC_order_check_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    aNSC_set_value_str(mSP_ItemNo2ItemPrice(shop_common->order_item), 0x3);
}

static void aNSC_sell_check_before_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0);
    aNSC_set_stop_spd(shop_common);
}

static void aNSC_sell_answer0_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0);
    if (shop_common->is_selling == TRUE) {
        switch (ITEM_NAME_GET_CAT(shop_common->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_common->is_selling = FALSE;
                }
                break;
            case ITEM1_CAT_CLOTH:
                if (!aNSC_money_check(shop_common->value) || !mPr_GetPossessionItemSum(Now_Private, 0) ||
                    shop_common->action == aNSC_ACTION_21_REQUEST_Q_END_WAIT) {
                    CLIP(shop_manekin_clip)->naked2cloth_proc(shop_common->ut_x, shop_common->ut_z);
                }
                shop_common->is_selling = FALSE;
                break;
        }
    }
}

static void aNSC_sell_answer1_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    aNSC_sell_answer0_init(shop_common, play);
    shop_common->sell_item = EMPTY_NO;
}

static void aNSC_sell_item_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    aNSC_get_sell_price(shop_common->value);
    if (CLIP(shop_design_clip) != NULL) {
        CLIP(shop_design_clip)->reportGoodsSale_proc(shop_common->ut_x, shop_common->ut_z);
    }
    shop_common->sell_item = EMPTY_NO;
}

static void aNSC_sell_item_with_ticket_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0);
    aNSC_sell_item_init(shop_common, play);
}

static void aNSC_sell_refuse0_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    shop_common->sell_item = EMPTY_NO;
}

static void aNSC_show_item_check_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    aNSC_set_stop_spd(shop_common);
}

static void aNSC_chg_cloth_start_wait_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mMsg_Set_LockContinue(mMsg_Get_base_window_p());
}

static void aNSC_pw_entry_send_addr_start_wait_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0);
}

static void aNSC_pw_make_menu_close_wait_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mem_clear(shop_common->pw_town_str, 0x10, 0x20);
    mSM_open_submenu_new(&play->submenu, mSM_OVL_PASSWORDMAKE, 0x0, 0x0, &shop_common->pw_town_str);
    shop_common->next_action = aNSC_ACTION_PW_MSG_WIN_OPEN_WAIT;
}

static void aNSC_pw_send_addr_check_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    aNSC_set_pw_name_str(shop_common);
}

static void aNSC_pw_sel_item_menu_close_wait_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mSM_open_submenu(&play->submenu, mSM_OVL_INVENTORY, 0x10, shop_common->password_flags);
    shop_common->next_action = aNSC_ACTION_PW_MSG_WIN_OPEN_WAIT;
}

static void aNSC_pc_input_pw_start_wait_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mem_clear(shop_common->password_str, sizeof(shop_common->password_str), CHAR_SPACE);
    mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x9, 0x0);
}

static void aNSC_pc_chk_menu_close_wait_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mSM_open_submenu_new(&play->submenu, mSM_OVL_PASSWORDCHK, 0x0, 0x0, shop_common->password_str);
    shop_common->next_action = aNSC_ACTION_PC_MSG_WIN_OPEN_WAIT;
}

static void aNSC_pc_present_trans_takeout_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    ACTOR* actorx = (ACTOR*)shop_common;
    mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0x1, 0x0);
    sAdo_OngenTrgStart(NA_SE_GASAGOSO, &actorx->world.position);
    mPr_SetFreePossessionItem(Now_Private, shop_common->password.item, mPr_ITEM_COND_PRESENT);
    Common_Get(unk_nook_present_count)++;
    mMsg_Set_LockContinue(mMsg_Get_base_window_p());
    shop_common->npc_class.head.lock_flag = TRUE;
}

static void aNSC_pc_present_end_wait_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    shop_common->npc_class.left_hand.item_actor_p = NULL;
    shop_common->npc_class.head.lock_flag = FALSE;
}

static void aNSC_wait_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    aNSC_set_stop_spd(shop_common);
}

static void aNSC_walk_pl_same_zone_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    aNSC_set_walk_spd(shop_common);
}

static void aNSC_run_pl_same_zone_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    aNSC_set_run_spd(shop_common);
}

static void aNSC_goodbye_wait_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    aNSC_set_stop_spd(shop_common);
}

static void aNSC_say_goodbye_init(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
    mMsg_Set_idling_req(mMsg_Get_base_window_p());
}

// clang-format off
static void aNSC_init_proc(NPC_SHOP_COMMON_ACTOR *shop_common, GAME_PLAY* play, int action) {
    static aNSC_INIT_PROC init_proc[aNSC_ACTION_NUM] = {
		(aNSC_INIT_PROC)none_proc1,
		aNSC_say_hello_approach_init,
		aNSC_say_hello_end_wait_init,
		aNSC_say_hello_end_wait_init,
#ifdef aNSC_MAMEDANUKI
        aNSC_say_hello_approach_init,
		aNSC_say_hello_end_wait_init,
        (aNSC_INIT_PROC)none_proc1,
        (aNSC_INIT_PROC)none_proc1,
        (aNSC_INIT_PROC)none_proc1,
        (aNSC_INIT_PROC)none_proc1,
        (aNSC_INIT_PROC)none_proc1,
        (aNSC_INIT_PROC)none_proc1,
#else
		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,
#endif
		(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,
#ifdef aNSC_MAMEDANUKI
        aNSC_goodbye_wait_init,
#endif
		aNSC_say_goodbye_init,
		aNSC_exit_wait
    };
    init_proc[action](shop_common, play);
}

static void aNSC_setupAction(NPC_SHOP_COMMON_ACTOR *shop_common, GAME_PLAY *play, int action) {
    static aNSC_ACTION_PROC process[aNSC_ACTION_NUM] = {
		aNSC_start_wait, // 0x0
		aNSC_say_hello_approach,
		aNSC_say_hello_end_wait,
		aNSC_say_hello_end_wait,
#ifdef aNSC_MAMEDANUKI
        aNSC_say_hello_approach,
		aNSC_say_hello_end_wait,
        (aNSC_ACTION_PROC)none_proc1,
        (aNSC_ACTION_PROC)none_proc1,
        (aNSC_ACTION_PROC)none_proc1,
        (aNSC_ACTION_PROC)none_proc1,
        (aNSC_ACTION_PROC)none_proc1,
        (aNSC_ACTION_PROC)none_proc1,
#else
		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,
#endif
		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,
#ifdef aNSC_MAMEDANUKI
        aNSC_goodbye_wait2,
#endif
		aNSC_say_goodbye,
		aNSC_exit_wait
    };
    shop_common->action = action; 
    shop_common->proc = process[action];
    aNSC_set_animation(shop_common, action);
    aNSC_init_proc(shop_common, play, action);
}
// clang-format off
