function switch_slot_22() /* entry=467 class_id=0x0A15 slot=0x22 */
{
  set_info(0x0207, *(arg_06));
  local_01 = MainActor.hasKeycard(Item.getQLo(arg_06));
  if (Item.getFrame(arg_06) == 4) {
    spawn FREE.slot_21(pid, 0x00AD, 0x00000000);
    suspend;
    spawn TRIGGER.slot_20(pid, 0, *(arg_06), arg_06);
    suspend;
    spawn FREE.slot_3B(pid, 1, 0x00000000);
    suspend;
    return;
  }
  else if (!World.getAlertActive()) {
    spawn FREE.slot_21(pid, 0x0181, 0x00000000);
    suspend;
    if (UCMachine.rndRange(100, 0) <= 50) {
      spawn FREE.slot_21(pid, 0x018D, 0x00000000);
      suspend;
    }
    else {
      spawn FREE.slot_21(pid, 0x018B, 0x00000000);
      suspend;
    }
    return;
  }
  else if (!local_01) {
    spawn FREE.slot_21(pid, 0x0183, 0x00000000);
    suspend;
    spawn FREE.slot_3B(pid, 1, 0x00000000);
    suspend;
    spawn TRIGGER.slot_20(pid, 0, *(arg_06), arg_06);
    suspend;
    return;
  }
  else {
    spawn FREE.slot_21(pid, 0x0181, 0x00000000);
    suspend;
    spawn FREE.slot_21(pid, 0x018F, 0x00000000);
    suspend;
    spawn FREE.slot_3B(pid, 1, 0x00000000);
    suspend;
    spawn TRIGGER.slot_20(pid, 1, *(arg_06), arg_06);
    suspend;
  }
  return;
}
