static int Player_actor_request_main_pickup_exchange(GAME* game, const xyz_t* target_pos_p, mActor_name_t item,
                                                     int priority) {
    if (Player_actor_check_request_main_able(game, mPlayer_INDEX_PICKUP_EXCHANGE, priority)) {
        PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game);
        mPlayer_request_pickup_exchange_c* req_pickup_exchange_p = &player->requested_main_index_data.pickup_exchange;

        Player_actor_request_main_index(game, mPlayer_INDEX_PICKUP_EXCHANGE, priority);
        req_pickup_exchange_p->target_pos = *target_pos_p;
        req_pickup_exchange_p->item = item;

        return TRUE;
    }

    return FALSE;
}

static void Player_actor_setup_main_Pickup_exchange(ACTOR* actorx, GAME* game) {
    PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx;
    mPlayer_request_pickup_exchange_c* req_pickup_exchange_p = &player->requested_main_index_data.pickup_exchange;
    mPlayer_main_pickup_exchange_c* main_pickup_exchange_p = &player->main_data.pickup_exchange;
    int anim1_idx;
    int part_table_idx;

    main_pickup_exchange_p->target_pos = req_pickup_exchange_p->target_pos;
    main_pickup_exchange_p->item = req_pickup_exchange_p->item;
    main_pickup_exchange_p->msg_mode = 0;
    main_pickup_exchange_p->submenu_flag = FALSE;

    Player_actor_SetupItem_Base1(actorx, mPlayer_ANIM_PICKUP_WAIT1, -6.0f, &anim1_idx, &part_table_idx);

    if (anim1_idx != mPlayer_ANIM_PICKUP_WAIT1) {
        part_table_idx = mPlayer_PART_TABLE_NET;
    }

    Player_actor_InitAnimation_Base1(actorx, game, mPlayer_ANIM_PICKUP_WAIT1, anim1_idx, 1.0f, 1.0f, 0.5f, -5.0f,
                                     part_table_idx);
    Player_actor_setup_main_Base(actorx, game);
}

static void Player_actor_settle_main_Pickup_exchange(ACTOR* actorx, GAME* game) {
    PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx;
    mPlayer_main_pickup_exchange_c* main_pickup_exchange_p = &player->main_data.pickup_exchange;

    if (main_pickup_exchange_p->submenu_flag == FALSE) {
        mActor_name_t item = main_pickup_exchange_p->item;
        xyz_t* target_pos_p = &main_pickup_exchange_p->target_pos;

        if (item == ITM_SIGNBOARD) {
            aSIGN_set_white_sign(game, target_pos_p);
        } else if (Common_Get(clip).bg_item_clip != NULL &&
                   Common_Get(clip).bg_item_clip->player_drop_entry_proc != NULL) {
            int ut_x;
            int ut_z;

            if (mFI_Wpos2UtNum(&ut_x, &ut_z, *target_pos_p)) {
                Common_Get(clip).bg_item_clip->player_drop_entry_proc(game, item, ut_x, ut_z, mCoBG_LAYER0);
            }
        }
    }
}

static void Player_actor_Movement_Pickup_exchange(ACTOR* actorx) {
    Player_actor_Movement_Base_Braking_common(actorx, 0.23925f);
}

static int Player_actor_CulcAnimation_Pickup_exchange(ACTOR* actorx) {
    f32 dummy;

    return Player_actor_CulcAnimation_Base2(actorx, &dummy);
}

static void Player_actor_ObjCheck_Pickup_exchange(ACTOR* actorx, GAME* game) {
    Player_actor_Excute_Corect_forStand(actorx, game);
}

static void Player_actor_BGcheck_Pickup_exchange(ACTOR* actorx) {
    Player_actor_BGcheck_common_type1(actorx);
}

static void Player_actor_Pickup_exchange_demo_ct(ACTOR* actorx) {
    int msg_no;
    rgba_t window_color;

    if (Common_Get(field_type) == mFI_FIELDTYPE2_FG) {
        msg_no = 0x17B2;
    } else {
        msg_no = 0x17B3;
    }

    mDemo_Set_msg_num(msg_no);
    mDemo_Set_talk_display_name(FALSE);
    mDemo_Set_ListenAble();

    window_color.r = 255;
    window_color.g = 255;
    window_color.b = 20;
    window_color.a = 255;
    mDemo_Set_talk_window_color(&window_color);
    mChoice_CLEAR_CHOSENUM();
}

static int Player_actor_MessageControl_Pickup_exchange(ACTOR* actorx, GAME* game) {
    PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx;
    mPlayer_main_pickup_exchange_c* main_pickup_exchange_p = &player->main_data.pickup_exchange;
    int* msg_mode_p = &main_pickup_exchange_p->msg_mode;

    switch (*msg_mode_p) {
        case 0: {
            if (mDemo_Check(mDemo_TYPE_REPORT, actorx) == FALSE) {
                mDemo_Request(mDemo_TYPE_REPORT, actorx, &Player_actor_Pickup_exchange_demo_ct);
            } else {
                *msg_mode_p = 1;
            }
            return -1;
        }
        case 1: {
            int choice_no = mChoice_GET_CHOSENUM();

            if (choice_no == mChoice_CHOICE0) {
                *msg_mode_p = 2;
                main_pickup_exchange_p->submenu_flag = TRUE;
            } else if (choice_no == mChoice_CHOICE1) {
                *msg_mode_p = 3;
                main_pickup_exchange_p->submenu_flag = FALSE;
            }
            return -1;
        }
        case 2: {

            if (mDemo_Check(mDemo_TYPE_REPORT, actorx) == FALSE) {
                GAME_PLAY* play = (GAME_PLAY*)game;
                Submenu* submenu = &play->submenu;

                mSM_open_submenu_new2(submenu, mSM_OVL_INVENTORY, mSM_IV_OPEN_EXCHANGE, main_pickup_exchange_p->item,
                                      NULL, actorx->shape_info.rotation.y);
            }
            return -1;
        }
        case 3: {
            if (mDemo_Check(mDemo_TYPE_REPORT, actorx) == FALSE) {
                return mPlayer_INDEX_WAIT;
            }
            return -1;
        }
        default: {
            return -1;
        }
    }
}

static void Player_actor_request_proc_index_fromPickup_exchange(GAME* game, int request_main_index) {
    if (request_main_index == mPlayer_INDEX_WAIT) {
        Player_actor_request_main_wait_all(game, -5.0f, 0.0f, 0, mPlayer_REQUEST_PRIORITY_34);
    }
}

static void Player_actor_main_Pickup_exchange(ACTOR* actorx, GAME* game) {
    int request_main_index;

    Player_actor_Movement_Pickup_exchange(actorx);
    Player_actor_CulcAnimation_Pickup_exchange(actorx);
    Player_actor_Reinput_force_position_angle(actorx, game);
    Player_actor_recover_lean_angle(actorx);
    Player_actor_set_tex_anime_pattern(actorx);
    Player_actor_ObjCheck_Pickup_exchange(actorx, game);
    Player_actor_BGcheck_Pickup_exchange(actorx);
    request_main_index = Player_actor_MessageControl_Pickup_exchange(actorx, game);
    Player_actor_Item_main(actorx, game);
    Player_actor_request_proc_index_fromPickup_exchange(game, request_main_index);
}
