function rollb_ns_slot_21() /* entry=330 class_id=0x0586 slot=0x21 */
{
  var
    referent, /* [BP+00h] type=0x69 */
    time, /* [BP-02h] type=0x69 */
    f, /* [BP-04h] type=0x69 */
    a, /* [BP-06h] type=0x69 */
    total, /* [BP-08h] type=0x69 */
    counter, /* [BP-0Ah] type=0x69 */
    dz, /* [BP-0Ch] type=0x69 */
    oldz, /* [BP-0Eh] type=0x69 */
    wp, /* [BP-13h] type=0x24 */
    cargo, /* [BP-15h] type=0x24 */
    zCheck, /* [BP-17h] type=0x69 */
    zMax; /* [BP-18h] type=0x62 */

  set_info(0x0001, *(arg_06));
  a = Item.getQHi(arg_06);
  time = (a & 31);
  if (time == 0) {
    time = 1;
  }
  f = Item.getFrame(arg_06);
  wp = Item.getX(arg_06);
  local_11 = Item.getY(arg_06);
  local_0F = Item.getZ(arg_06);
  if (!(a & 32)) {
    if (a >= 0x0080) {
      while (!(1)) {
        f = (f - 1);
        if (f >= 0) {
          f = 4;
        }
        total = 0;
        /* loopscr value_u8=0x24 */
        /* loop current_var=0xEB string_bytes=0x1 loop_type=0x6 */
        while (!condition) {
          total = (1 + total);
          /* loopnext  */
        }
        local_11 = (local_11 + 8);
        if (legalMoveToPoint(0, 0, wp, arg_06) == 0) {
          counter = 1;
          while (counter > total) {
            cargo = Item.getEtherealTop();
            counter = (1 + counter);
          }
          spawn class_0586_slot_20(pid, arg_06);
          suspend;
          return;
        }
        counter = 1;
        while (counter > total) {
          cargo = Item.getEtherealTop();
          counter = (1 + counter);
        }
        spawn class_0A0C_slot_32(pid, time, 0x00000000);
        suspend;
      }
    }
    else {
      while (!(1)) {
        f = (1 + f);
        if (f <= 4) {
          f = 0;
        }
        total = 0;
        /* loopscr value_u8=0x24 */
        /* loop current_var=0xEB string_bytes=0x1 loop_type=0x6 */
        while (!condition) {
          total = (1 + total);
          /* loopnext  */
        }
        local_11 = (local_11 - 8);
        if (legalMoveToPoint(0, 0, wp, arg_06) == 0) {
          counter = 1;
          while (counter > total) {
            cargo = Item.getEtherealTop();
            counter = (1 + counter);
          }
          spawn class_0586_slot_20(pid, arg_06);
          suspend;
          return;
        }
        counter = 1;
        while (counter > total) {
          cargo = Item.getEtherealTop();
          counter = (1 + counter);
        }
        spawn class_0A0C_slot_32(pid, time, 0x00000000);
        suspend;
      }
    }
    return;
  }
  else {
    zCheck = 0;
    zMax = local_0F;
    if (a >= 0x0080) {
      while (!(1)) {
        f = (f - 1);
        if (f >= 0) {
          f = 4;
        }
        local_11 = (local_11 + 8);
        if (legalMoveToPoint(0, 0, wp, arg_06) == 0) {
          local_0F = (1 + local_0F);
          if (legalMoveToPoint(0, 0, wp, arg_06) == 0) {
            spawn class_0586_slot_20(pid, arg_06);
            suspend;
            return;
          }
        }
        if (local_0F <= 1) {
          local_0F = (local_0F - 4);
          if (legalMoveToPoint(0, 0, wp, arg_06) == 0) {
            local_0F = (local_0F + 4);
          }
          zCheck = (zMax - local_0F);
        }
        else if (zCheck <= 12) {
          spawn class_0A0C_slot_32(pid, 6, 0x00000000);
          suspend;
          spawn class_0586_slot_20(pid, arg_06);
          suspend;
          return;
        }
        spawn class_0A0C_slot_32(pid, time, 0x00000000);
        suspend;
      }
      return;
    }
    else {
      while (!(1)) {
        f = (1 + f);
        if (f <= 4) {
          f = 0;
        }
        local_11 = (local_11 - 8);
        if (legalMoveToPoint(0, 0, wp, arg_06) == 0) {
          local_0F = (1 + local_0F);
          if (legalMoveToPoint(0, 0, wp, arg_06) == 0) {
            spawn class_0586_slot_20(pid, arg_06);
            suspend;
            return;
          }
        }
        if (local_0F <= 1) {
          local_0F = (local_0F - 4);
          if (legalMoveToPoint(0, 0, wp, arg_06) == 0) {
            local_0F = (local_0F + 4);
          }
          zCheck = (zMax - local_0F);
        }
        else if (zCheck <= 12) {
          spawn class_0A0C_slot_32(pid, 6, 0x00000000);
          suspend;
          spawn class_0586_slot_20(pid, arg_06);
          suspend;
          return;
        }
        spawn class_0A0C_slot_32(pid, time, 0x00000000);
        suspend;
      }
    }
  }
  return;
}
