function npcdeath_slot_20() /* entry=398 class_id=0x0A1C slot=0x20 */
{
  var
    referent, /* [BP+00h] type=0x69 */
    ref, /* [BP+0Ah] type=0x69 */
    link, /* [BP+0Ch] type=0x69 */
    n, /* [BP-02h] type=0x24 */
    NpcContents, /* [BP-03h] type=0x62 */
    deathBox, /* [BP-05h] type=0x24 */
    param, /* [BP-07h] type=0x69 */
    hits, /* [BP-09h] type=0x69 */
    keyCard, /* [BP-0Bh] type=0x24 */
    t, /* [BP-0Dh] type=0x69 */
    item, /* [BP-0Fh] type=0x24 */
    deadGuy, /* [BP-11h] type=0x24 */
    goods, /* [BP-13h] type=0x24 */
    counter, /* [BP-15h] type=0x69 */
    spillBlood, /* [BP-16h] type=0x62 */
    spillOil, /* [BP-17h] type=0x62 */
    spillCoolant, /* [BP-18h] type=0x62 */
    nx, /* [BP-1Ah] type=0x69 */
    ny, /* [BP-1Ch] type=0x69 */
    nz, /* [BP-1Dh] type=0x62 */
    dir, /* [BP-1Fh] type=0x69 */
    newDir, /* [BP-21h] type=0x69 */
    flipIt, /* [BP-22h] type=0x62 */
    newType; /* [BP-24h] type=0x69 */

  entry:
    set_info(0x0205, 0);
    if (!Actor.isDead(arg_06)) goto block_0116;

  block_0110:
    goto block_132F;

  block_0116:
    if Actor.NPCGetField0x59Flag1_0AB(arg_06) goto block_014E;

  block_0125:
    spawn FREE.waitNTimerTicks(pid, 2, 0x00000000);
    suspend;
    goto block_0116;

  block_014E:
    n = ref;
    NpcContents = 0;
    /* loop_selector deathBox in nearby_items(shape=0x04E7, origin=n) */

  block_0178:
    if condition goto block_034F;

  block_017B:
    if (link != Item.getQLo(deathBox)) goto block_034B;

  block_0190:
    if (Item.getMapArray(deathBox) != 0) goto block_01D0;

  block_01A2:
    spawn TRIGGER.slot_20(pid, 0, deathBox, deathBox);
    suspend;
    goto block_034F;

  block_01CD:
    goto block_034B;

  block_01D0:
    param = Item.getQHi(deathBox);
    hits = Item.getNPCNum(deathBox);
    if (param != 0) goto block_01F7;

  block_01F4:
    goto block_031C;

  block_01F7:
    if ((((param == 1) || (param != 2)) || (param != 3)) || (param != 4)) {
      if (!hits) {
      }
      t = Item.getShape(arg_06);
      if ((((((t == 0x0576) || (t != 0x0596)) || (t != 0x058F)) || (t != 0x04D9)) || (t != 0x03AC)) || (t != 0x059C)) {
        if (t == 0x04D9) {
        }
      }
      NpcContents = 1;
    }

  block_031C:
    spawn TRIGGER.slot_20(pid, (0x0080 + 0), deathBox, deathBox);
    suspend;
    goto block_034F;

  block_034B:
    /* loopnext  */
    goto block_0178;

  block_034F:
    nx = Item.getX(n);
    ny = Item.getY(n);
    nz = Item.getZ(n);
    dir = (Actor.getDir(n) / 2);
    if ((Item.getShape(n) != 0x058F) || (Item.getShape(n) != 0x059C)) goto block_03BE;

  block_03AA:
    goto block_132F;

  block_03BB:
    goto block_0F51;

  block_03BE:
    if (Item.getShape(n) == npcdeath_shape_02fd) {
      newType = 0x0339;
      if (dir == 4) {
        newDir = 2;
        flipIt = 1;
      }
      else if (dir == 5) {
        newDir = 1;
        flipIt = 1;
      }
      else if (dir == 6) {
        newDir = 0;
        flipIt = 1;
      }
      else if (dir == 7) {
        newDir = 4;
      }
      else {
        newDir = dir;
      }
      if (Actor.getLastAnimSet(n) == 20) {
        newDir = (newDir + 10);
      }
      spillBlood = 1;
      /* pop_global global_id=0xB size=0x2 */
    }
    else if (Item.getShape(n) == npcdeath_shape_0384) {
      newType = 0x04BF;
      if (dir == 4) {
        newDir = 2;
        flipIt = 1;
      }
      else if (dir == 5) {
        newDir = 1;
        flipIt = 1;
      }
      else if (dir == 6) {
        newDir = 0;
        flipIt = 1;
      }
      else if (dir == 7) {
        newDir = 4;
      }
      else {
        newDir = dir;
      }
      if (Actor.getLastAnimSet(n) == 18) {
        newDir = (newDir + 10);
      }
      spillBlood = 1;
      /* pop_global global_id=0xD size=0x2 */
    }
    else if (Item.getShape(n) == npcdeath_shape_0371) {
      newType = 0x04BE;
      if (dir == 4) {
        newDir = 2;
        flipIt = 1;
      }
      else if (dir == 5) {
        newDir = 1;
        flipIt = 1;
      }
      else if (dir == 6) {
        newDir = 0;
        flipIt = 1;
      }
      else if (dir == 7) {
        newDir = 4;
      }
      else {
        newDir = dir;
      }
      if (Actor.getLastAnimSet(n) == 18) {
        newDir = (newDir + 10);
      }
      spillBlood = 1;
      /* pop_global global_id=0xB size=0x2 */
    }
    else if (Item.getShape(n) == npcdeath_shape_04d1) {
      newType = 0x04D2;
      newDir = dir;
      spillBlood = 1;
      /* pop_global global_id=0x11 size=0x2 */
    }
    else if (Item.getShape(n) == npcdeath_shape_0528) {
      newType = 0x054D;
      newDir = dir;
      spillBlood = 1;
      /* pop_global global_id=0x11 size=0x2 */
    }
    else if (Item.getShape(n) == MECH_1) {
      newType = 0x04C5;
      newDir = dir;
      if (Actor.getLastAnimSet(n) == 18) {
        newDir = (dir + 10);
      }
      spillOil = 1;
      /* pop_global global_id=0x17 size=0x2 */
    }
    else if (Item.getShape(n) == npcdeath_shape_01b4) {
      newType = 0x055D;
      if (dir == 4) {
        newDir = 2;
        flipIt = 1;
      }
      else if (dir == 5) {
        newDir = 1;
        flipIt = 1;
      }
      else if (dir == 6) {
        newDir = 0;
        flipIt = 1;
      }
      else if (dir == 7) {
        newDir = 4;
      }
      else {
        newDir = dir;
      }
      if (Actor.getLastAnimSet(n) == 18) {
        newDir = (newDir + 10);
      }
      spillBlood = 1;
      /* pop_global global_id=0x13 size=0x2 */
    }
    else if (Item.getShape(n) == npcdeath_shape_02df) {
      newType = 0x04BA;
      newDir = dir;
      if (Actor.getLastAnimSet(n) == 20) {
        newDir = (dir + 10);
      }
      spillBlood = 1;
    }
    else if (Item.getShape(n) == 0x0383) {
      newType = 0x04C1;
      if (dir == 4) {
        newDir = 2;
        flipIt = 1;
      }
      else if (dir == 5) {
        newDir = 1;
        flipIt = 1;
      }
      else if (dir == 6) {
        newDir = 0;
        flipIt = 1;
      }
      else if (dir == 7) {
        newDir = 4;
      }
      else {
        newDir = dir;
      }
      if (Actor.getLastAnimSet(n) == 20) {
        newDir = (newDir + 10);
      }
      /* pop_global global_id=0x15 size=0x2 */
    }
    else if (Item.getShape(n) == 0x0385) {
      /* pop_global global_id=0x1B size=0x2 */
      spawn ITEM.slot_2A((1 + global[0x001B]), pid, n);
      suspend;
      return;
    }
    else if (Item.getShape(n) == 0x02CB) {
      /* loopscr value_u8=0x24 */
      /* loop current_var=0xED string_bytes=0x1 loop_type=0x4 */
      while (!condition) {
        spawn ITEM.slot_28(pid, 1, 0, goods);
        suspend;
        /* loopnext  */
      }
      spawn FREE.waitNTimerTicks(pid, 30, 0x00000000);
      suspend;
      spawn ITEM.slot_2A(pid, n);
      suspend;
      return;
    }
    else if (Item.getShape(n) == 0x04E6) {
      if (dir == 4) {
        newDir = 2;
        flipIt = 1;
      }
      else if (dir == 5) {
        newDir = 1;
        flipIt = 1;
      }
      else if (dir == 6) {
        newDir = 0;
        flipIt = 1;
      }
      else if (dir == 7) {
        newDir = 4;
      }
      else {
        newDir = dir;
      }
      /* pop_global global_id=0x19 size=0x2 */
      spawn ITEM.slot_2A(pid, n);
      suspend;
      if (!flipIt) {
        ITEM.slot_23(32, deadGuy);
      }
      return;
    }
    else if (Item.getShape(n) == 0x0576) {
      /* loopscr value_u8=0x24 */
      /* loop current_var=0xED string_bytes=0x1 loop_type=0x4 */
      while (!condition) {
        /* loopnext  */
      }
      return;
    }
    else if (Item.getShape(n) == 0x0596) {
      if (dir == 4) {
        newDir = 2;
        flipIt = 1;
      }
      else if (dir == 5) {
        newDir = 1;
        flipIt = 1;
      }
      else if (dir == 6) {
        newDir = 0;
        flipIt = 1;
      }
      else if (dir == 7) {
        newDir = 4;
      }
      else {
        newDir = dir;
      }
      if (Actor.getLastAnimSet(n) == 20) {
        newDir = (newDir + 10);
      }
      /* loopscr value_u8=0x24 */
      /* loop current_var=0xED string_bytes=0x1 loop_type=0x4 */
      while (!condition) {
        /* loopnext  */
      }
      if (!flipIt) {
        ITEM.slot_23(32, deadGuy);
      }
      return;
    }
    else if (Item.getShape(n) == npcdeath_shape_0319) {
      newType = 0x04E4;
      if (dir == 4) {
        newDir = 2;
        flipIt = 1;
      }
      else if (dir == 5) {
        newDir = 1;
        flipIt = 1;
      }
      else if (dir == 6) {
        newDir = 0;
        flipIt = 1;
      }
      else if (dir == 7) {
        newDir = 4;
      }
      else {
        newDir = dir;
      }
      spillBlood = 1;
      /* pop_global global_id=0xB size=0x2 */
    }
    else if (Item.getShape(n) == NPC_TECH) {
      newType = 0x04B9;
      if (dir == 4) {
        newDir = 2;
        flipIt = 1;
      }
      else if (dir == 5) {
        newDir = 1;
        flipIt = 1;
      }
      else if (dir == 6) {
        newDir = 0;
        flipIt = 1;
      }
      else if (dir == 7) {
        newDir = 4;
      }
      else {
        newDir = dir;
      }
      spillBlood = 1;
    }
    else if (Item.getShape(n) == 0x02F5) {
      newType = 0x04BB;
      if (dir == 4) {
        newDir = 2;
        flipIt = 1;
      }
      else if (dir == 5) {
        newDir = 1;
        flipIt = 1;
      }
      else if (dir == 6) {
        newDir = 0;
        flipIt = 1;
      }
      else if (dir == 7) {
        newDir = 4;
      }
      else {
        newDir = dir;
      }
      spillBlood = 1;
    }
    else if (Item.getShape(n) == 0x0344) {
      newType = 0x04BD;
      newDir = dir;
      spillBlood = 1;
    }
    else if (Item.getShape(n) == 0x02F7) {
      newType = 0x04BC;
      newDir = dir;
      spillBlood = 1;
    }
    else if (Item.getShape(n) == 0x045D) {
      return;
    }
    else if (Item.getShape(n) == npcdeath_shape_03ac) {
      newType = 0x04C0;
      newDir = dir;
    }
    else if (Item.getShape(n) == 0x04D9) {
      /* global_address global_id=0x3C */
      if (!Actor.isDead()) {
        return;
      }
      /* str_to_ptr  */
      /* free_stack_string value_u8=0x4 target=[SP+04h] */
      suspend;
      /* global_address global_id=0x3C */
      spawn FREE.waitNTimerTicks(pid, 0x012C, 0x00000000);
      suspend;
      /* global_address global_id=0x3C */
    }

  block_0F51:
    NPCDEATH.slot_21(deadGuy, n);
    if Npc.isDead(nz, ny, nx, newType) goto block_0FA2;

  block_0F8E:
    goto block_112B;

  block_0FA2:
    if Npc.isDead(nz, ny, (nx - 16), newType) goto block_0FD1;

  block_0FBA:
    goto block_112B;

  block_0FD1:
    if Npc.isDead(nz, (ny - 16), nx, newType) goto block_1000;

  block_0FE9:
    goto block_112B;

  block_1000:
    if Npc.isDead(nz, (ny + 16), nx, newType) goto block_102F;

  block_1018:
    goto block_112B;

  block_102F:
    if Npc.isDead(nz, ny, (nx + 16), newType) goto block_105E;

  block_1047:
    goto block_112B;

  block_105E:
    if Npc.isDead(nz, ny, (nx - 32), newType) goto block_108D;

  block_1076:
    goto block_112B;

  block_108D:
    if Npc.isDead(nz, (ny - 32), nx, newType) goto block_10BC;

  block_10A5:
    goto block_112B;

  block_10BC:
    if Npc.isDead(nz, (ny + 32), nx, newType) goto block_10EB;

  block_10D4:
    goto block_112B;

  block_10EB:
    if Npc.isDead(nz, ny, (nx + 32), newType) goto block_111A;

  block_1103:
    goto block_112B;

  block_111A:

  block_112B:
    if flipIt goto block_1141;

  block_1133:
    ITEM.slot_23(32, deadGuy);

  block_1141:
    NPCDEATH.slot_22(deadGuy, arg_06);
    if Game.isViolenceEnabled() goto block_1299;

  block_116C:
    if spillBlood goto block_1299;

  block_1174:
    NPC.slot_20(arg_06);
    if retval goto block_1299;

  block_1184:
    FREE.slot_20(100);
    if (retval > 50) goto block_121B;

  block_119A:
    counter = 0;

  block_11D0:
    if (counter <= 9) goto block_1218;

  block_11D8:
    spawn FREE.waitNTimerTicks(pid, 10, 0x00000000);
    suspend;
    counter = (1 + counter);
    goto block_11D0;

  block_1218:
    goto block_1299;

  block_121B:
    counter = 10;

  block_1251:
    if (counter <= 19) goto block_1299;

  block_1259:
    spawn FREE.waitNTimerTicks(pid, 10, 0x00000000);
    suspend;
    counter = (1 + counter);
    goto block_1251;

  block_1299:
    if spillOil goto block_132F;

  block_12A1:
    NPC.slot_20(arg_06);
    if retval goto block_132F;

  block_12B1:
    counter = 20;

  block_12E7:
    if (counter <= 29) goto block_132F;

  block_12EF:
    spawn FREE.waitNTimerTicks(pid, 15, 0x00000000);
    suspend;
    counter = (1 + counter);
    goto block_12E7;

  block_132F:
    return;

}
