#include <define.h>
//#include <updatmap.h>

//#define NAME                    SCRIPT_

#include <command.h>

procedure start;
#include <push.h>
procedure stranger;
procedure Lighting;
procedure choose_start;
procedure North_table;
procedure South_table;
procedure Shady_table;
procedure Raider_table;
procedure Junk_table;
procedure Hub_table;
procedure Necrop_table;
procedure Steel_table;
procedure Vats_table;
procedure Glow_table;
procedure Bone_table;
procedure Death_table;
procedure North1;
procedure North2;
procedure North3;
procedure North4;
procedure North5;
procedure North6;
procedure South1;
procedure South2;
procedure South3;
procedure South4;
procedure South5;
procedure South6;
procedure Shady1;
procedure Shady2;
procedure Shady3;
procedure Shady4;
procedure Shady5;
procedure Shady6;
procedure Raider1;
procedure Raider2;
procedure Raider3;
procedure Raider4;
procedure Raider5;
procedure Raider6;
procedure Junk1;
procedure Junk2;
procedure Junk3;
procedure Junk4;
procedure Junk5;
procedure Junk6;
procedure Hub1;
procedure Hub2;
procedure Hub3;
procedure Hub4;
procedure Hub5;
procedure Hub6;
procedure Necrop1;
procedure Necrop2;
procedure Necrop3;
procedure Necrop4;
procedure Necrop5;
procedure Necrop6;
procedure Steel1;
procedure Steel2;
procedure Steel3;
procedure Steel4;
procedure Steel5;
procedure Steel6;
procedure Vats1;
procedure Vats2;
procedure Vats3;
procedure Vats4;
procedure Vats5;
procedure Vats6;
procedure Glow1;
procedure Glow2;
procedure Glow3;
procedure Glow4;
procedure Glow5;
procedure Glow6;
procedure Death1;
procedure Death2;
procedure Death3;
procedure Death4;
procedure Death5;
procedure Death6;
procedure Bone1;
procedure Bone2;
procedure Bone3;
procedure Bone4;
procedure Bone5;
procedure Bone6;
procedure Scenes;
procedure Place_critter;
procedure hunters;
procedure add_party;
procedure update_party;
procedure remove_party;

variable party_elevation := 0;
variable dude_start_hex := 0;

export variable Ian_ptr := 0;
export variable Dog_ptr := 0;
export variable Tycho_ptr := 0;
export variable Katja_ptr := 0;
export variable Tandi_ptr := 0;

variable Dude_tile := 0;
variable Place_Holder := 0;
variable Encounter_Num := 0;
variable Tot_Critter_A := 0;
variable Tot_Critter_B := 0;
variable Scorpions_Killed := 0;
variable Skill_roll := 0;
variable Item := 0;
variable money := 0;
variable Ranger_rerolls := 0;
variable victim := 0;
variable Critter := 0;
variable Inner_ring := 0;
variable Outer_ring := 0;
variable Critter_direction := 0;
variable Critter_tile := 0;
variable Critter_type := 0;
variable Critter_script := 4294967295;
variable dude_pos := 0;
variable dude_rot := 0;
variable group_angle := 0;
variable Range := 0;

export variable random_seed_1 := 0;
export variable random_seed_2 := 0;
export variable random_seed_3 := 0;

procedure Darkness;
procedure Invasion;

procedure start
begin
  if (script_action == map_enter_proc) then
  begin
    dude_rot := random(0, 5);
    set_global_var(GVAR_SAVE_TANDI_6, 0);
    if ((global_var(GVAR_LOAD_MAP_INDEX) != 1) and metarule(14, 0)) then
    begin
      Ranger_rerolls := has_trait(0, dude_obj, 47);
      set_global_var(GVAR_SAVE_TANDI_5, 0);
      while (Encounter_Num == 0) do
      begin
        Encounter_Num := random(1, 6) + random(1, 6) + random(1, 6);
        if (get_critter_stat(dude_obj, 6) > 8) then
          Encounter_Num := Encounter_Num + 2;
        else if (get_critter_stat(dude_obj, 6) > 6) then
          Encounter_Num := Encounter_Num + 1;
        else if (get_critter_stat(dude_obj, 6) < 3) then
          Encounter_Num := Encounter_Num - 1;
        if ((global_var(GVAR_HUNTER_STATUS) != 3) and (global_var(GVAR_CHILDKILLER_REPUTATION) > 2) and random(0, 1)) then
          Encounter_Num := 7;
        else if (Encounter_Num <= 3) then
          Encounter_Num := 1;
        else if (Encounter_Num <= 5) then
          Encounter_Num := 2;
        else if (Encounter_Num <= 8) then
          Encounter_Num := 3;
        else if (Encounter_Num <= 12) then
          Encounter_Num := 4;
        else if (Encounter_Num <= 15) then
          Encounter_Num := 5;
        else
          Encounter_Num := 6;
        if (global_var(GVAR_WORLD_TERRAIN) == 0) then
          call North_table;
        else if (global_var(GVAR_WORLD_TERRAIN) == 1) then
          call South_table;
        else if (global_var(GVAR_WORLD_TERRAIN) == 5) then
          call Shady_table;
        else if (global_var(GVAR_WORLD_TERRAIN) == 6) then
          call Raider_table;
        else if (global_var(GVAR_WORLD_TERRAIN) == 7) then
          call Junk_table;
        else if (global_var(GVAR_WORLD_TERRAIN) == 8) then
          call Hub_table;
        else if (global_var(GVAR_WORLD_TERRAIN) == 9) then
          call Necrop_table;
        else if (global_var(GVAR_WORLD_TERRAIN) == 10) then
          call Steel_table;
        else if (global_var(GVAR_WORLD_TERRAIN) == 11) then
          call Vats_table;
        else if (global_var(GVAR_WORLD_TERRAIN) == 12) then
          call Glow_table;
        else if (global_var(GVAR_WORLD_TERRAIN) == 14) then
          call Death_table;
        else if (global_var(GVAR_WORLD_TERRAIN) == 13) then
          call Bone_table;
        else if (random(0, 1)) then
          call North_table;
        else
          call South_table;
      end
    end
    else if (metarule(14, 0)) then
    begin
      dude_pos := random(0, 3);
      Dude_tile := tile_num(dude_obj);
      call Scenes;
      if (dude_pos == 0) then
        override_map_start(109, 72, 0, dude_rot);
      else if (dude_pos == 1) then
        override_map_start(131, 102, 0, dude_rot);
      else if (dude_pos == 2) then
        override_map_start(90, 112, 0, dude_rot);
      else
        override_map_start(80, 86, 0, dude_rot);
    end
    call Lighting;
  end
  else if (script_action == map_update_proc) then
    call Lighting;
  else if (script_action == map_exit_proc) then
  begin
    Skill_roll := roll_vs_skill(dude_obj, 17, 0);
    if (Scorpions_Killed == 1) then
    begin
      if (is_success(Skill_roll)) then
      begin
        if (is_critical(Skill_roll)) then
          display_msg(message_str(SCRIPT_RNDDESRT, 100));
        else
          display_msg(message_str(SCRIPT_RNDDESRT, 101));
      end
      else if (is_critical(Skill_roll)) then
        display_msg(message_str(SCRIPT_RNDDESRT, 102));
      else
        display_msg(message_str(SCRIPT_RNDDESRT, 103));
    end
  end
end

procedure stranger
begin
  variable LVar1 := 1;

  if (has_trait(0, dude_obj, 46) and (global_var(GVAR_STRANGER_STATUS) == 0) and random(0, 1)) then
  begin
    Critter_type := 16777520;
    Critter_script := 856;
    Critter_direction := random(0, 5);
    Outer_ring := 7;
    Inner_ring := 4;
    call Place_critter;
    Critter_direction := dude_rot + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    anim(Critter, 1000, Critter_direction);
    Item := create_object_sid(7, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Item := create_object_sid(40, 0, 0, -1);
    add_mult_objs_to_inven(Critter, Item, 2);
    Item := item_caps_adjust(Critter, random(7, 30) * ((2 * has_trait(0, dude_obj, 20)) + 1));
    LVar1 := global_var(GVAR_WATER_THIEF_1);
    if (LVar1 == 1) then
      set_global_var(GVAR_WATER_THIEF_1, 10);
    else if (LVar1 == 2) then
      set_global_var(GVAR_WATER_THIEF_1, 9);
    else
      set_global_var(GVAR_WATER_THIEF_1, 15);
  end
end

procedure Lighting
begin
  variable LVar1 := 0;

  LVar1 := game_time_hour;
  if ((LVar1 >= 600) and (LVar1 < 700)) then
    set_light_level(LVar1 - 600 + 40);
  else if ((LVar1 >= 700) and (LVar1 < 1800)) then
    set_light_level(100);
  else if ((LVar1 >= 1800) and (LVar1 < 1900)) then
    set_light_level(100 - (LVar1 - 1800));
  else
    set_light_level(40);
end

procedure choose_start
begin
  dude_pos := random(0, 3);
  if (global_var(GVAR_WORLD_TERRAIN) == 1) then
  begin
    if (Encounter_Num == 1) then
      override_map_start(93, 91, 0, 1);
    else if (dude_pos == 0) then
      override_map_start(109, 72, 0, dude_rot);
    else if (dude_pos == 1) then
      override_map_start(131, 102, 0, dude_rot);
    else if (dude_pos == 2) then
      override_map_start(90, 112, 0, dude_rot);
    else
      override_map_start(80, 86, 0, dude_rot);
  end
  else if (global_var(GVAR_WORLD_TERRAIN) == 10) then
  begin
    if ((Encounter_Num == 1) or (Encounter_Num == 5) or (Encounter_Num == 6)) then
      override_map_start(100, 100, 0, dude_rot);
    else if (dude_pos == 0) then
      override_map_start(109, 72, 0, dude_rot);
    else if (dude_pos == 1) then
      override_map_start(131, 102, 0, dude_rot);
    else if (dude_pos == 2) then
      override_map_start(90, 112, 0, dude_rot);
    else
      override_map_start(80, 86, 0, dude_rot);
  end
  else if (dude_pos == 0) then
    override_map_start(109, 72, 0, dude_rot);
  else if (dude_pos == 1) then
    override_map_start(131, 102, 0, dude_rot);
  else if (dude_pos == 2) then
    override_map_start(90, 112, 0, dude_rot);
  else
    override_map_start(80, 86, 0, dude_rot);
  Dude_tile := tile_num(dude_obj);
  call Scenes;
end

procedure North_table
begin
  if (Ranger_rerolls) then
  begin
    Ranger_rerolls := Ranger_rerolls - 1;
    if ((Encounter_Num == 1) or (Encounter_Num == 2) or (Encounter_Num == 3) or (Encounter_Num == 4) or (Encounter_Num == 7)) then
      Encounter_Num := 0;
  end
  if (global_var(GVAR_WATER_THIEF_8)) then
  begin
    Encounter_Num := global_var(GVAR_WATER_THIEF_8);
    set_global_var(GVAR_WATER_THIEF_8, 0);
    debug_msg("Northern Desert encounter type: " + Encounter_Num);
  end
  if (Encounter_Num) then
  begin
    call choose_start;
    if (Encounter_Num == 1) then
      call North1;
    else if (Encounter_Num == 2) then
      call North2;
    else if (Encounter_Num == 3) then
      call North3;
    else if (Encounter_Num == 4) then
      call North4;
    else if (Encounter_Num == 5) then
      call North5;
    else if (Encounter_Num == 6) then
      call North6;
    else
      call hunters;
  end
end

procedure South_table
begin
  if (Ranger_rerolls) then
  begin
    Ranger_rerolls := Ranger_rerolls - 1;
    if ((Encounter_Num == 2) or (Encounter_Num == 4) or (Encounter_Num == 5) or (Encounter_Num == 6) or (Encounter_Num == 7)) then
      Encounter_Num := 0;
  end
  if (global_var(GVAR_WATER_THIEF_8)) then
  begin
    Encounter_Num := global_var(GVAR_WATER_THIEF_8);
    set_global_var(GVAR_WATER_THIEF_8, 0);
    debug_msg("Southern Desert encounter type: " + Encounter_Num);
  end
  if (Encounter_Num) then
  begin
    call choose_start;
    if (Encounter_Num == 1) then
      call South1;
    else if (Encounter_Num == 2) then
      call South2;
    else if (Encounter_Num == 3) then
      call South3;
    else if (Encounter_Num == 4) then
      call South4;
    else if (Encounter_Num == 5) then
      call South5;
    else if (Encounter_Num == 6) then
      call South6;
    else
      call hunters;
  end
end

procedure Shady_table
begin
  if (Ranger_rerolls) then
  begin
    Ranger_rerolls := Ranger_rerolls - 1;
    if ((Encounter_Num == 1) or (Encounter_Num == 3) or (Encounter_Num == 7)) then
      Encounter_Num := 0;
  end
  if (global_var(GVAR_WATER_THIEF_8)) then
  begin
    Encounter_Num := global_var(GVAR_WATER_THIEF_8);
    set_global_var(GVAR_WATER_THIEF_8, 0);
    debug_msg("Shady Sands Desert encounter type: " + Encounter_Num);
  end
  if (Encounter_Num) then
  begin
    call choose_start;
    if (Encounter_Num == 1) then
      call Shady1;
    else if (Encounter_Num == 2) then
      call Shady2;
    else if (Encounter_Num == 3) then
      call Shady3;
    else if (Encounter_Num == 4) then
      call Shady4;
    else if (Encounter_Num == 5) then
      call Shady5;
    else if (Encounter_Num == 6) then
      call Shady6;
    else
      call hunters;
  end
end

procedure Raider_table
begin
  if (Ranger_rerolls) then
  begin
    Ranger_rerolls := Ranger_rerolls - 1;
    if ((Encounter_Num == 1) or (Encounter_Num == 3) or (Encounter_Num == 4) or (Encounter_Num == 7)) then
      Encounter_Num := 0;
  end
  if (global_var(GVAR_WATER_THIEF_8)) then
  begin
    Encounter_Num := global_var(GVAR_WATER_THIEF_8);
    set_global_var(GVAR_WATER_THIEF_8, 0);
    debug_msg("Raiders Desert encounter type: " + Encounter_Num);
  end
  if (Encounter_Num) then
  begin
    call choose_start;
    if (Encounter_Num == 1) then
      call Raider1;
    else if (Encounter_Num == 2) then
      call Raider2;
    else if (Encounter_Num == 3) then
      call Raider3;
    else if (Encounter_Num == 4) then
      call Raider4;
    else if (Encounter_Num == 5) then
      call Raider5;
    else if (Encounter_Num == 6) then
      call Raider6;
    else
      call hunters;
  end
end

procedure Junk_table
begin
  if (Ranger_rerolls) then
  begin
    Ranger_rerolls := Ranger_rerolls - 1;
    if ((Encounter_Num == 1) or (Encounter_Num == 2) or (Encounter_Num == 3) or (Encounter_Num == 4) or (Encounter_Num == 7)) then
      Encounter_Num := 0;
  end
  if (global_var(GVAR_WATER_THIEF_8)) then
  begin
    Encounter_Num := global_var(GVAR_WATER_THIEF_8);
    set_global_var(GVAR_WATER_THIEF_8, 0);
    debug_msg("Junk Town Desert encounter type: " + Encounter_Num);
  end
  if (Encounter_Num) then
  begin
    call choose_start;
    if (Encounter_Num == 1) then
      call Junk1;
    else if (Encounter_Num == 2) then
      call Junk2;
    else if (Encounter_Num == 3) then
      call Junk3;
    else if (Encounter_Num == 4) then
      call Junk4;
    else if (Encounter_Num == 5) then
      call Junk5;
    else if (Encounter_Num == 6) then
      call Junk6;
    else
      call hunters;
  end
end

procedure Hub_table
begin
  if (Ranger_rerolls) then
  begin
    Ranger_rerolls := Ranger_rerolls - 1;
    if ((Encounter_Num == 2) or (Encounter_Num == 3) or (Encounter_Num == 4) or (Encounter_Num == 7)) then
      Encounter_Num := 0;
  end
  if (global_var(GVAR_WATER_THIEF_8)) then
  begin
    Encounter_Num := global_var(GVAR_WATER_THIEF_8);
    set_global_var(GVAR_WATER_THIEF_8, 0);
    debug_msg("Hub Desert encounter type: " + Encounter_Num);
  end
  if (Encounter_Num) then
  begin
    call choose_start;
    if (Encounter_Num == 1) then
      call Hub1;
    else if (Encounter_Num == 2) then
      call Hub2;
    else if (Encounter_Num == 3) then
      call Hub3;
    else if (Encounter_Num == 4) then
      call Hub4;
    else if (Encounter_Num == 5) then
      call Hub5;
    else if (Encounter_Num == 6) then
      call Hub6;
    else
      call hunters;
  end
end

procedure Necrop_table
begin
  if (Ranger_rerolls) then
  begin
    Ranger_rerolls := Ranger_rerolls - 1;
    if ((Encounter_Num == 2) or (Encounter_Num == 3) or (Encounter_Num == 5) or (Encounter_Num == 7)) then
      Encounter_Num := 0;
  end
  if (global_var(GVAR_WATER_THIEF_8)) then
  begin
    Encounter_Num := global_var(GVAR_WATER_THIEF_8);
    set_global_var(GVAR_WATER_THIEF_8, 0);
    debug_msg("Necropolis Desert encounter type: " + Encounter_Num);
  end
  if (Encounter_Num) then
  begin
    call choose_start;
    if (Encounter_Num == 1) then
      call Necrop1;
    else if (Encounter_Num == 2) then
      call Necrop2;
    else if (Encounter_Num == 3) then
      call Necrop3;
    else if (Encounter_Num == 4) then
      call Necrop4;
    else if (Encounter_Num == 5) then
      call Necrop5;
    else if (Encounter_Num == 6) then
      call Necrop6;
    else
      call hunters;
  end
end

procedure Steel_table
begin
  if (Ranger_rerolls) then
  begin
    Ranger_rerolls := Ranger_rerolls - 1;
    if ((Encounter_Num == 1) or (Encounter_Num == 2) or (Encounter_Num == 4) or (Encounter_Num == 7)) then
      Encounter_Num := 0;
  end
  if (global_var(GVAR_WATER_THIEF_8)) then
  begin
    Encounter_Num := global_var(GVAR_WATER_THIEF_8);
    set_global_var(GVAR_WATER_THIEF_8, 0);
    debug_msg("Brotherhood of Steel Desert encounter type: " + Encounter_Num);
  end
  if (Encounter_Num) then
  begin
    call choose_start;
    if (Encounter_Num == 1) then
      call Steel1;
    else if (Encounter_Num == 2) then
      call Steel2;
    else if (Encounter_Num == 3) then
      call Steel3;
    else if (Encounter_Num == 4) then
      call Steel4;
    else if (Encounter_Num == 5) then
      call Steel5;
    else if (Encounter_Num == 6) then
      call Steel6;
    else
      call hunters;
  end
end

procedure Vats_table
begin
  if (Ranger_rerolls) then
  begin
    Ranger_rerolls := Ranger_rerolls - 1;
    if ((Encounter_Num == 1) or (Encounter_Num == 2) or (Encounter_Num == 3) or (Encounter_Num == 4) or (Encounter_Num == 7)) then
      Encounter_Num := 0;
  end
  if (global_var(GVAR_WATER_THIEF_8)) then
  begin
    Encounter_Num := global_var(GVAR_WATER_THIEF_8);
    set_global_var(GVAR_WATER_THIEF_8, 0);
    debug_msg("Vats Desert encounter type: " + Encounter_Num);
  end
  if (Encounter_Num) then
  begin
    call choose_start;
    if (Encounter_Num == 1) then
      call Vats1;
    else if (Encounter_Num == 2) then
      call Vats2;
    else if (Encounter_Num == 3) then
      call Vats3;
    else if (Encounter_Num == 4) then
      call Vats4;
    else if (Encounter_Num == 5) then
      call Vats5;
    else if (Encounter_Num == 6) then
      call Vats6;
    else
      call hunters;
  end
end

procedure Glow_table
begin
  if (Ranger_rerolls) then
  begin
    Ranger_rerolls := Ranger_rerolls - 1;
    if ((Encounter_Num == 1) or (Encounter_Num == 3) or (Encounter_Num == 4) or (Encounter_Num == 5) or (Encounter_Num == 7)) then
      Encounter_Num := 0;
  end
  if (global_var(GVAR_WATER_THIEF_8)) then
  begin
    Encounter_Num := global_var(GVAR_WATER_THIEF_8);
    set_global_var(GVAR_WATER_THIEF_8, 0);
    debug_msg("Glow Desert encounter type: " + Encounter_Num);
  end
  if (Encounter_Num) then
  begin
    call choose_start;
    if (Encounter_Num == 1) then
      call Glow1;
    else if (Encounter_Num == 2) then
      call Glow2;
    else if (Encounter_Num == 3) then
      call Glow3;
    else if (Encounter_Num == 4) then
      call Glow4;
    else if (Encounter_Num == 5) then
      call Glow5;
    else if (Encounter_Num == 6) then
      call Glow6;
    else
      call hunters;
  end
end

procedure Bone_table
begin
  if (Ranger_rerolls) then
  begin
    Ranger_rerolls := Ranger_rerolls - 1;
    if ((Encounter_Num == 1) or (Encounter_Num == 3) or (Encounter_Num == 5) or (Encounter_Num == 7)) then
      Encounter_Num := 0;
  end
  if (global_var(GVAR_WATER_THIEF_8)) then
  begin
    Encounter_Num := global_var(GVAR_WATER_THIEF_8);
    set_global_var(GVAR_WATER_THIEF_8, 0);
    debug_msg("Bone Desert encounter type: " + Encounter_Num);
  end
  if (Encounter_Num) then
  begin
    call choose_start;
    if (Encounter_Num == 1) then
      call Bone1;
    else if (Encounter_Num == 2) then
      call Bone2;
    else if (Encounter_Num == 3) then
      call Bone3;
    else if (Encounter_Num == 4) then
      call Bone4;
    else if (Encounter_Num == 5) then
      call Bone5;
    else if (Encounter_Num == 6) then
      call Bone6;
    else
      call hunters;
  end
end

procedure Death_table
begin
  if (Ranger_rerolls) then
  begin
    Ranger_rerolls := Ranger_rerolls - 1;
    if ((Encounter_Num == 1) or (Encounter_Num == 2) or (Encounter_Num == 4) or (Encounter_Num == 6) or (Encounter_Num == 7)) then
      Encounter_Num := 0;
  end
  if (global_var(GVAR_WATER_THIEF_8)) then
  begin
    Encounter_Num := global_var(GVAR_WATER_THIEF_8);
    set_global_var(GVAR_WATER_THIEF_8, 0);
    debug_msg("Death Claw encounter type: " + Encounter_Num);
  end
  if (Encounter_Num) then
  begin
    call choose_start;
    if (Encounter_Num == 1) then
      call Death1;
    else if (Encounter_Num == 2) then
      call Death2;
    else if (Encounter_Num == 3) then
      call Death3;
    else if (Encounter_Num == 4) then
      call Death4;
    else if (Encounter_Num == 5) then
      call Death5;
    else if (Encounter_Num == 6) then
      call Death6;
    else
      call hunters;
  end
end

procedure North1
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 104));
  Tot_Critter_A := random(3, 6);
  Tot_Critter_B := random(4, 8);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 4;
  group_angle := random(0, 5);
  Critter_type := 16777227;
  Critter_script := 12;
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (group_angle == 0) then
      Critter_direction := 3;
    else if (group_angle == 1) then
      Critter_direction := 4;
    else if (group_angle == 2) then
      Critter_direction := 5;
    else if (group_angle == 3) then
      Critter_direction := 0;
    else if (group_angle == 4) then
      Critter_direction := 1;
    else if (group_angle == 5) then
      Critter_direction := 2;
    if (random(0, 2) == 0) then
    begin
      Critter_direction := Critter_direction + (random(0, 2) - 1);
      while (Critter_direction < 0) do
        Critter_direction := Critter_direction + 6;
      if (Critter_direction > 5) then
        Critter_direction := Critter_direction % 6;
    end
    anim(Critter, 1000, Critter_direction);
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  victim := Critter;
  Critter_script := 222;
  if (group_angle == 0) then
    group_angle := 3;
  else if (group_angle == 1) then
    group_angle := 4;
  else if (group_angle == 2) then
    group_angle := 5;
  else if (group_angle == 3) then
    group_angle := 0;
  else if (group_angle == 4) then
    group_angle := 1;
  else if (group_angle == 5) then
    group_angle := 2;
  while (Tot_Critter_B) do
  begin
    if (random(0, 3) == 3) then
      Critter_type := 16777226;
    else
      Critter_type := 16777378;
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (group_angle == 0) then
      Critter_direction := 3;
    else if (group_angle == 1) then
      Critter_direction := 4;
    else if (group_angle == 2) then
      Critter_direction := 5;
    else if (group_angle == 3) then
      Critter_direction := 0;
    else if (group_angle == 4) then
      Critter_direction := 1;
    else if (group_angle == 5) then
      Critter_direction := 2;
    if (random(0, 2) == 0) then
    begin
      Critter_direction := Critter_direction + (random(0, 2) - 1);
      while (Critter_direction < 0) do
        Critter_direction := Critter_direction + 6;
      if (Critter_direction > 5) then
        Critter_direction := Critter_direction % 6;
    end
    anim(Critter, 1000, Critter_direction);
    Tot_Critter_B := Tot_Critter_B - 1;
  end
  attack_setup(dude_obj, victim);
  attack_setup(dude_obj, Critter);
  attack_setup(Critter, victim);
  set_global_var(GVAR_WATER_THIEF_1, 1);
  call stranger;
end

procedure North2
begin
  variable LVar1 := 0;

  Tot_Critter_A := random(1, 2);
  Tot_Critter_B := random(3, 5);
  group_angle := random(0, 5);
  if (is_success(do_check(dude_obj, 1, -2)) or has_trait(0, dude_obj, 0)) then
  begin
    display_msg(message_str(SCRIPT_RNDDESRT, 197));
    Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 7;
    Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 5;
  end
  else
  begin
    display_msg(message_str(SCRIPT_RNDDESRT, 105));
    LVar1 := 1;
    Outer_ring := 5;
    Inner_ring := 2;
  end
  Critter_type := 16777419;
  Critter_script := 749;
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (LVar1) then
      anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    else
      anim(Critter, 1000, random(0, 5));
    if (random(0, 1)) then
    begin
      if (random(0, 1)) then
        Item := create_object_sid(18, 0, 0, -1);
      else
        Item := create_object_sid(8, 0, 0, -1);
    end
    else
      Item := create_object_sid(4, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Item := item_caps_adjust(Critter, (random(1, 20) * has_trait(0, dude_obj, 20)) + 1);
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  Outer_ring := Outer_ring + 2;
  Inner_ring := Inner_ring + 2;
  while (Tot_Critter_B) do
  begin
    if (random(0, 1)) then
      Critter_type := 16777449;
    else
      Critter_type := 16777432;
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (LVar1) then
      anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    else
      anim(Critter, 1000, random(0, 5));
    if (random(0, 1)) then
    begin
      if (random(0, 1)) then
        Item := create_object_sid(18, 0, 0, -1);
      else
        Item := create_object_sid(8, 0, 0, -1);
    end
    else
      Item := create_object_sid(4, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Item := item_caps_adjust(Critter, random(1, 25) * (has_trait(0, dude_obj, 20) + 1));
    Tot_Critter_B := Tot_Critter_B - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 1);
  call stranger;
end

procedure North3
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 106));
  Tot_Critter_A := random(4, 6);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 5;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 3;
  Critter_type := 16777227;
  Critter_script := 12;
  group_angle := random(0, 5);
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle;
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  Critter_type := 16777229;
  Critter_direction := random(0, 5);
  Outer_ring := 4;
  Inner_ring := 2;
  call Place_critter;
  anim(Critter, 1000, random(0, 5));
  Item := item_caps_adjust(Critter, random(40, 100) * (has_trait(0, dude_obj, 20) + 1));
  if (random(0, 1)) then
  begin
    Item := create_object_sid(40, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
  end
  kill_critter(Critter, 61);
  set_global_var(GVAR_WATER_THIEF_1, 1);
  call stranger;
end

procedure North4
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 107));
  Tot_Critter_A := random(2, 4);
  group_angle := random(0, 5);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 3;
  Inner_ring := get_critter_stat(dude_obj, 1) / 2;
  Critter_type := 16777227;
  Critter_script := 12;
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle + (random(0, 3 * 2) - 3);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 1);
  call stranger;
end

procedure North5
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 108));
  Tot_Critter_A := random(2, 6);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 8;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 4;
  Critter_script := 222;
  while (Tot_Critter_A) do
  begin
    if (random(0, 3) == 3) then
      Critter_type := 16777226;
    else
      Critter_type := 16777378;
    Critter_direction := random(0, 2);
    call Place_critter;
    anim(Critter, 1000, random(0, 5));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 1);
  call stranger;
end

procedure North6
begin
  variable LVar1 := 0;
  variable LVar2 := 0;

  LVar1 := random(1, 6);
  if (obj_is_carrying_obj_pid(dude_obj, 126)) then
  begin
    display_msg(message_str(SCRIPT_RNDDESRT, 125));
    destroy_object(obj_carrying_pid_obj(dude_obj, 126));
  end
  else
  begin
    Skill_roll := roll_vs_skill(dude_obj, 17, 20 * has_trait(0, dude_obj, 16));
    if (is_success(Skill_roll)) then
    begin
      if (LVar1 == 1) then
        display_msg(message_str(SCRIPT_RNDDESRT, 109));
      else
        display_msg(message_str(SCRIPT_RNDDESRT, 110) + LVar1 + message_str(SCRIPT_RNDDESRT, 111));
    end
    else if (is_critical(Skill_roll)) then
    begin
      LVar2 := random(2, 4);
      if (LVar1 == 1) then
        display_msg(message_str(SCRIPT_RNDDESRT, 112) + LVar2 + message_str(SCRIPT_RNDDESRT, 113));
      else
        display_msg(message_str(SCRIPT_RNDDESRT, 114) + LVar1 + message_str(SCRIPT_RNDDESRT, 115) + LVar2 + message_str(SCRIPT_RNDDESRT, 116));
      critter_injure(dude_obj, 2);
    end
    else
    begin
      LVar2 := random(1, 2);
      if (LVar1 == 1) then
      begin
        if (LVar2 == 1) then
          display_msg(message_str(SCRIPT_RNDDESRT, 117));
        else
          display_msg(message_str(SCRIPT_RNDDESRT, 118) + LVar2 + message_str(SCRIPT_RNDDESRT, 119));
      end
      else if (LVar2 == 1) then
        display_msg(message_str(SCRIPT_RNDDESRT, 120) + LVar1 + message_str(SCRIPT_RNDDESRT, 121));
      else
        display_msg(message_str(SCRIPT_RNDDESRT, 122) + LVar1 + message_str(SCRIPT_RNDDESRT, 123) + LVar2 + message_str(SCRIPT_RNDDESRT, 124));
      critter_injure(dude_obj, 2);
    end
    critter_dmg(dude_obj, LVar2, 0);
    LVar1 := LVar1 * 3600;
    game_time_advance(game_ticks(LVar1));
  end
end

procedure South1
begin
  variable LVar1 := 0;

  display_msg(message_str(SCRIPT_RNDDESRT, 131));
  Tot_Critter_A := random(6, 10);
  Outer_ring := 7;
  Inner_ring := 10;
  Critter_type := 16777244;
  Critter_script := 941;
  while (Tot_Critter_A) do
  begin
    Critter_direction := 1;
    call Place_critter;
    anim(Critter, 1000, 4);
    Tot_Critter_A := Tot_Critter_A - 1;
  end
end

procedure South2
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 132));
  Tot_Critter_A := random(4, 6);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 5;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 2;
  Critter_type := 16777227;
  Critter_script := 12;
  group_angle := random(0, 5);
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle + (random(0, 2 * 2) - 2);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 2);
  call stranger;
end

procedure South3
begin
  variable LVar1 := 0;
  variable LVar2 := 0;

  LVar1 := random(1, 6);
  Skill_roll := roll_vs_skill(dude_obj, 17, 20 * has_trait(0, dude_obj, 16));
  if (obj_is_carrying_obj_pid(dude_obj, 126)) then
  begin
    display_msg(message_str(SCRIPT_RNDDESRT, 125));
    destroy_object(obj_carrying_pid_obj(dude_obj, 126));
  end
  else
  begin
    if (is_success(Skill_roll)) then
    begin
      if (LVar1 == 1) then
        display_msg(message_str(SCRIPT_RNDDESRT, 109));
      else
        display_msg(message_str(SCRIPT_RNDDESRT, 110) + LVar1 + message_str(SCRIPT_RNDDESRT, 111));
    end
    else if (is_critical(Skill_roll)) then
    begin
      LVar2 := random(2, 4);
      if (LVar1 == 1) then
        display_msg(message_str(SCRIPT_RNDDESRT, 112) + LVar2 + message_str(SCRIPT_RNDDESRT, 113));
      else
        display_msg(message_str(SCRIPT_RNDDESRT, 114) + LVar1 + message_str(SCRIPT_RNDDESRT, 115) + LVar2 + message_str(SCRIPT_RNDDESRT, 116));
      critter_injure(dude_obj, 2);
    end
    else
    begin
      LVar2 := random(1, 2);
      if (LVar1 == 1) then
      begin
        if (LVar2 == 1) then
          display_msg(message_str(SCRIPT_RNDDESRT, 117));
        else
          display_msg(message_str(SCRIPT_RNDDESRT, 118) + LVar2 + message_str(SCRIPT_RNDDESRT, 119));
      end
      else if (LVar2 == 1) then
        display_msg(message_str(SCRIPT_RNDDESRT, 120) + LVar1 + message_str(SCRIPT_RNDDESRT, 121));
      else
        display_msg(message_str(SCRIPT_RNDDESRT, 122) + LVar1 + message_str(SCRIPT_RNDDESRT, 123) + LVar2 + message_str(SCRIPT_RNDDESRT, 124));
      critter_injure(dude_obj, 2);
    end
    critter_dmg(dude_obj, LVar2, 0);
    LVar1 := LVar1 * 3600;
    game_time_advance(game_ticks(LVar1));
  end
end

procedure South4
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 143));
  Tot_Critter_A := random(2, 5);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 5;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 2;
  Critter_script := 749;
  group_angle := random(0, 5);
  while (Tot_Critter_A) do
  begin
    if (random(0, 1)) then
      Critter_type := 16777449;
    else
      Critter_type := 16777432;
    Critter_direction := group_angle + (random(0, 1 * 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    if (random(0, 1)) then
    begin
      if (random(0, 1)) then
      begin
        Item := create_object_sid(34, 0, 0, -1);
        add_obj_to_inven(Critter, Item);
        if (has_trait(0, dude_obj, 40)) then
        begin
          Item := create_object_sid(34, 0, 0, -1);
          add_obj_to_inven(Critter, Item);
        end
        Item := create_object_sid(10, 0, 0, -1);
      end
      else
      begin
        Item := create_object_sid(29, 0, 0, -1);
        add_mult_objs_to_inven(Critter, Item, has_trait(0, dude_obj, 40) + 1);
        Item := create_object_sid(8, 0, 0, -1);
      end
    end
    else
      Item := create_object_sid(7, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Item := item_caps_adjust(Critter, random(10, 30) * (has_trait(0, dude_obj, 20) + 1));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 2);
  call stranger;
end

procedure South5
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 144));
  Tot_Critter_A := random(4, 8);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 7;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 5;
  Critter_script := 943;
  group_angle := random(0, 5);
  while (Tot_Critter_A) do
  begin
    if (random(0, 4) == 4) then
      Critter_type := 16777226;
    else
      Critter_type := 16777378;
    Critter_direction := group_angle + (random(0, 2 * 2) - 2);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    anim(Critter, 1000, random(0, 5));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 2);
  call stranger;
end

procedure South6
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 145));
  Tot_Critter_A := random(3, 6);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 5;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 3;
  group_angle := random(0, 5);
  Critter_type := 16777227;
  Critter_script := 12;
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle + (random(0, 2 * 2) - 2);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 2);
  call stranger;
end

procedure Shady1
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 146));
  Tot_Critter_A := 2;
  Tot_Critter_B := random(2, 3);
  set_global_var(GVAR_WATER_THIEF_3, 0);
  set_global_var(GVAR_WATER_THIEF_4, 0);
  set_global_var(GVAR_WATER_THIEF_5, 0);
  set_global_var(GVAR_WATER_THIEF_2, Tot_Critter_B);
  set_global_var(GVAR_WATER_THIEF_1, 6);
  group_angle := random(0, 5);
  Outer_ring := 11;
  Inner_ring := 8;
  Critter_type := 16777255;
  Critter_script := 713;
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (group_angle == 0) then
      Critter_direction := 3;
    else if (group_angle == 1) then
      Critter_direction := 4;
    else if (group_angle == 2) then
      Critter_direction := 5;
    else if (group_angle == 3) then
      Critter_direction := 0;
    else if (group_angle == 4) then
      Critter_direction := 1;
    else if (group_angle == 5) then
      Critter_direction := 2;
    if (random(0, 2) == 0) then
    begin
      Critter_direction := Critter_direction + (random(0, 2) - 1);
      while (Critter_direction < 0) do
        Critter_direction := Critter_direction + 6;
      if (Critter_direction > 5) then
        Critter_direction := Critter_direction % 6;
    end
    anim(Critter, 1000, Critter_direction);
    Item := item_caps_adjust(Critter, (random(1, 12) * has_trait(0, dude_obj, 20)) + 1);
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  victim := Critter;
  Critter_type := 16777449;
  Critter_script := 749;
  if (group_angle == 0) then
    group_angle := 3;
  else if (group_angle == 1) then
    group_angle := 4;
  else if (group_angle == 2) then
    group_angle := 5;
  else if (group_angle == 3) then
    group_angle := 0;
  else if (group_angle == 4) then
    group_angle := 1;
  else if (group_angle == 5) then
    group_angle := 2;
  while (Tot_Critter_B) do
  begin
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (group_angle == 0) then
      Critter_direction := 3;
    else if (group_angle == 1) then
      Critter_direction := 4;
    else if (group_angle == 2) then
      Critter_direction := 5;
    else if (group_angle == 3) then
      Critter_direction := 0;
    else if (group_angle == 4) then
      Critter_direction := 1;
    else if (group_angle == 5) then
      Critter_direction := 2;
    if (random(0, 2) == 0) then
    begin
      Critter_direction := Critter_direction + (random(0, 2) - 1);
      while (Critter_direction < 0) do
        Critter_direction := Critter_direction + 6;
      if (Critter_direction > 5) then
        Critter_direction := Critter_direction % 6;
    end
    anim(Critter, 1000, Critter_direction);
    Item := create_object_sid(7, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Item := item_caps_adjust(Critter, (random(1, 13) * has_trait(0, dude_obj, 20)) + 1);
    Tot_Critter_B := Tot_Critter_B - 1;
  end
  attack_setup(Critter, victim);
  set_global_var(GVAR_WATER_THIEF_1, 1);
  call stranger;
end

procedure Shady2
begin
  variable LVar1 := 0;
  variable LVar2 := 0;

  LVar1 := random(1, 6);
  Skill_roll := roll_vs_skill(dude_obj, 17, 20 * has_trait(0, dude_obj, 16));
  if (obj_is_carrying_obj_pid(dude_obj, 126)) then
  begin
    display_msg(message_str(SCRIPT_RNDDESRT, 125));
    destroy_object(obj_carrying_pid_obj(dude_obj, 126));
  end
  else
  begin
    if (is_success(Skill_roll)) then
    begin
      if (LVar1 == 1) then
        display_msg(message_str(SCRIPT_RNDDESRT, 109));
      else
        display_msg(message_str(SCRIPT_RNDDESRT, 110) + LVar1 + message_str(SCRIPT_RNDDESRT, 111));
    end
    else if (is_critical(Skill_roll)) then
    begin
      LVar2 := random(2, 4);
      if (LVar1 == 1) then
        display_msg(message_str(SCRIPT_RNDDESRT, 112) + LVar2 + message_str(SCRIPT_RNDDESRT, 113));
      else
        display_msg(message_str(SCRIPT_RNDDESRT, 114) + LVar1 + message_str(SCRIPT_RNDDESRT, 115) + LVar2 + message_str(SCRIPT_RNDDESRT, 116));
      critter_injure(dude_obj, 2);
    end
    else
    begin
      LVar2 := random(1, 2);
      if (LVar1 == 1) then
      begin
        if (LVar2 == 1) then
          display_msg(message_str(SCRIPT_RNDDESRT, 117));
        else
          display_msg(message_str(SCRIPT_RNDDESRT, 118) + LVar2 + message_str(SCRIPT_RNDDESRT, 119));
        critter_injure(dude_obj, 2);
      end
      else
      begin
        if (LVar2 == 1) then
          display_msg(message_str(SCRIPT_RNDDESRT, 120) + LVar1 + message_str(SCRIPT_RNDDESRT, 121));
        else
          display_msg(message_str(SCRIPT_RNDDESRT, 122) + LVar1 + message_str(SCRIPT_RNDDESRT, 123) + LVar2 + message_str(SCRIPT_RNDDESRT, 124));
        critter_injure(dude_obj, 2);
      end
    end
    critter_dmg(dude_obj, LVar2, 0);
    LVar1 := LVar1 * 3600;
    game_time_advance(game_ticks(LVar1));
  end
end

procedure Shady3
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 169));
  Scorpions_Killed := 1;
  Tot_Critter_A := random(1, 3);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 3;
  Critter_type := 16777227;
  Critter_script := 12;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(0, 4);
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 1);
  call stranger;
end

procedure Shady4
begin
  if (not global_var(GVAR_SAVE_TANDI_2)) then
    display_msg(message_str(SCRIPT_RNDDESRT, 170));
  else
    display_msg(message_str(SCRIPT_RNDDESRT, 305));
  Tot_Critter_B := random(4, 6);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 7;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 3;
  group_angle := dude_rot;
  set_global_var(GVAR_WATER_THIEF_2, 0);
  if (not global_var(GVAR_SAVE_TANDI_2)) then
  begin
    Critter_type := 16777246;
    Critter_script := 243;
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Item := create_object_sid(71, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Item := create_object_sid(29, 0, 0, -1);
    add_mult_objs_to_inven(Critter, Item, 2 * (has_trait(0, dude_obj, 40) + 1));
    Item := create_object_sid(30, 0, 0, -1);
    add_mult_objs_to_inven(Critter, Item, 1 * (has_trait(0, dude_obj, 40) + 1));
    Item := create_object_sid(34, 0, 0, -1);
    add_mult_objs_to_inven(Critter, Item, 2 * (has_trait(0, dude_obj, 40) + 1));
    Item := create_object_sid(40, 0, 0, -1);
    add_mult_objs_to_inven(Critter, Item, random(0, 4));
    Item := create_object_sid(47, 0, 0, -1);
    add_mult_objs_to_inven(Critter, Item, random(0, 1));
    Item := create_object_sid(81, 0, 0, -1);
    add_mult_objs_to_inven(Critter, Item, random(0, 3));
    Item := item_caps_adjust(Critter, random(25, 100) * (has_trait(0, dude_obj, 20) + 1));
    victim := Critter;
  end
  else
    set_global_var(GVAR_WATER_THIEF_2, 1);
  Critter_type := 16777218;
  Critter_script := 757;
  while (Tot_Critter_B) do
  begin
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (not global_var(GVAR_SAVE_TANDI_2)) then
    begin
      if (random(0, 1)) then
      begin
        Critter_direction := group_angle + (random(0, 4) - 2);
        while (Critter_direction < 0) do
          Critter_direction := Critter_direction + 6;
        if (Critter_direction > 5) then
          Critter_direction := Critter_direction % 6;
        anim(Critter, 1000, Critter_direction);
      end
      else
        anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(victim)));
    end
    else
      anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Item := create_object_sid(10, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Item := create_object_sid(34, 0, 0, -1);
    add_mult_objs_to_inven(Critter, Item, has_trait(0, dude_obj, 40) + 1);
    Item := item_caps_adjust(Critter, random(1, 6) * (has_trait(0, dude_obj, 20) + 1));
    Tot_Critter_B := Tot_Critter_B - 1;
  end
end

procedure Shady5
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 171));
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 4;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 3;
  Critter_direction := dude_rot;
  Critter_type := 16777246;
  if (random(0, 1)) then
  begin
    Critter_type := 16777246;
    Critter_script := 699;
  end
  else
  begin
    Critter_type := 16777218;
    Critter_script := 749;
  end
  Critter_script := -1;
  call Place_critter;
  anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
  Item := create_object_sid(8, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Item := create_object_sid(29, 0, 0, -1);
  add_mult_objs_to_inven(Critter, Item, 1 + has_trait(0, dude_obj, 40));
  Item := create_object_sid(7, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Item := create_object_sid(81, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Item := item_caps_adjust(Critter, random(8, 44) * (has_trait(0, dude_obj, 20) + 1));
  kill_critter(Critter, 61);
  Tot_Critter_A := random(4, 6);
  if ((game_time_hour >= 700) and (game_time_hour < 1800)) then
  begin
    Outer_ring := 6;
    Inner_ring := 4;
  end
  else
  begin
    Outer_ring := 4;
    Inner_ring := 3;
  end
  Critter_type := 16777284;
  Critter_script := 735;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(0, 5);
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 1);
  call stranger;
end

procedure Shady6
begin
  variable LVar1 := 2;

  display_msg(message_str(SCRIPT_RNDDESRT, 172));
  Critter_direction := random(0, 5);
  money := create_object_sid(41, 0, 0, -1);
  Critter_tile := tile_num_in_direction(Dude_tile, Critter_direction, 4);
  Item := create_object_sid(71, 0, 0, -1);
  critter_attempt_placement(Item, Critter_tile, 0);
  if (get_critter_stat(dude_obj, 6) == 8) then
  begin
    money := 0;
    Item := create_object_sid(71, 0, 0, -1);
    critter_attempt_placement(Item, Critter_tile, 0);
    Item := create_object_sid(29, 0, 0, -1);
    critter_attempt_placement(Item, Critter_tile, 0);
    if (has_trait(0, dude_obj, 40)) then
    begin
      Item := create_object_sid(29, 0, 0, -1);
      critter_attempt_placement(Item, Critter_tile, 0);
    end
    Item := create_object_sid(46, 0, 0, -1);
    critter_attempt_placement(Item, Critter_tile, 0);
    add_mult_objs_to_inven(Item, money, 6 * (has_trait(0, dude_obj, 20) + 1));
  end
  else if (get_critter_stat(dude_obj, 6) > 8) then
  begin
    Item := create_object_sid(71, 0, 0, -1);
    critter_attempt_placement(Item, Critter_tile, 0);
    if (has_trait(0, dude_obj, 40)) then
      LVar1 := 4;
    while (LVar1) do
    begin
      Item := create_object_sid(29, 0, 0, -1);
      critter_attempt_placement(Item, Critter_tile, 0);
      LVar1 := LVar1 - 1;
    end
    Item := create_object_sid(46, 0, 0, -1);
    add_mult_objs_to_inven(Item, money, 122 * (has_trait(0, dude_obj, 20) + 1));
    critter_attempt_placement(Item, Critter_tile, 0);
    Item := create_object_sid(8, 0, 0, -1);
    critter_attempt_placement(Item, Critter_tile, 0);
  end
  else
  begin
    Item := create_object_sid(71, 0, 0, -1);
    critter_attempt_placement(Item, Critter_tile, 0);
    Item := create_object_sid(46, 0, 0, -1);
    add_mult_objs_to_inven(Item, money, 4 * (has_trait(0, dude_obj, 20) + 1));
    critter_attempt_placement(Item, Critter_tile, 0);
  end
end

procedure Raider1
begin
  variable LVar1 := 0;

  display_msg(message_str(SCRIPT_RNDDESRT, 173));
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 4;
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Tot_Critter_A := random(5, 7);
  Tot_Critter_B := random(2, 3);
  group_angle := random(0, 5);
  random_seed_1 := Tot_Critter_A;
  random_seed_2 := 0;
  random_seed_3 := 0;
  LVar1 := tile_num_in_direction(Dude_tile + random(0, 8) - 4, random(0, 5), random(7, 12));
  Item := create_object_sid(33554959, LVar1, 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 0), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 1), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 2), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 3), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 4), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 5), 0, -1);
  if ((game_time_hour >= 1900) or (game_time_hour < 600)) then
  begin
    Critter := create_object_sid(33554433, 0, 0, -1);
    Critter_tile := tile_num_in_direction(Dude_tile, group_angle, 5);
    critter_attempt_placement(Critter, Critter_tile, 0);
  end
  Critter_type := 16777244;
  Critter_script := -1;
  Critter_direction := random(0, 5);
  call Place_critter;
  anim(Critter, 1000, random(0, 5));
  kill_critter(Critter, 61);
  Critter_type := 16777244;
  Critter_script := -1;
  Critter_direction := random(0, 5);
  call Place_critter;
  anim(Critter, 1000, random(0, 5));
  kill_critter(Critter, 61);
  Critter_script := 750;
  while (Tot_Critter_A) do
  begin
    if (random(0, 1)) then
      Critter_type := 16777449;
    else
      Critter_type := 16777432;
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (group_angle == 0) then
      Critter_direction := 3;
    else if (group_angle == 1) then
      Critter_direction := 4;
    else if (group_angle == 2) then
      Critter_direction := 5;
    else if (group_angle == 3) then
      Critter_direction := 0;
    else if (group_angle == 4) then
      Critter_direction := 1;
    else if (group_angle == 5) then
      Critter_direction := 2;
    if (random(0, 2) == 0) then
    begin
      Critter_direction := Critter_direction + (random(0, 2) - 1);
      while (Critter_direction < 0) do
        Critter_direction := Critter_direction + 6;
      if (Critter_direction > 5) then
        Critter_direction := Critter_direction % 6;
    end
    anim(Critter, 1000, Critter_direction);
    Item := create_object_sid(4, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    if (random(0, 1)) then
    begin
      if (random(0, 1)) then
      begin
        Item := create_object_sid(34, 0, 0, -1);
        add_mult_objs_to_inven(Critter, Item, has_trait(0, dude_obj, 40) + 1);
        Item := create_object_sid(10, 0, 0, -1);
      end
      else
      begin
        Item := create_object_sid(29, 0, 0, -1);
        add_mult_objs_to_inven(Critter, Item, has_trait(0, dude_obj, 40) + 1);
        Item := create_object_sid(8, 0, 0, -1);
      end
    end
    else
      Item := create_object_sid(7, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  victim := Critter;
  if (random(0, 1)) then
    Critter_type := 16777449;
  else
    Critter_type := 16777432;
  Critter_script := -1;
  Critter_direction := group_angle + (random(0, 2) - 1);
  while (Critter_direction < 0) do
    Critter_direction := Critter_direction + 6;
  if (Critter_direction > 5) then
    Critter_direction := Critter_direction % 6;
  call Place_critter;
  if (group_angle == 0) then
    Critter_direction := 3;
  else if (group_angle == 1) then
    Critter_direction := 4;
  else if (group_angle == 2) then
    Critter_direction := 5;
  else if (group_angle == 3) then
    Critter_direction := 0;
  else if (group_angle == 4) then
    Critter_direction := 1;
  else if (group_angle == 5) then
    Critter_direction := 2;
  if (random(0, 2) == 0) then
  begin
    Critter_direction := Critter_direction + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
  end
  anim(Critter, 1000, Critter_direction);
  Item := create_object_sid(1, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Item := create_object_sid(4, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  kill_critter(Critter, 61);
  Critter_type := 16777219;
  Critter_script := 755;
  if (group_angle == 0) then
    group_angle := 3;
  else if (group_angle == 1) then
    group_angle := 4;
  else if (group_angle == 2) then
    group_angle := 5;
  else if (group_angle == 3) then
    group_angle := 0;
  else if (group_angle == 4) then
    group_angle := 1;
  else if (group_angle == 5) then
    group_angle := 2;
  while (Tot_Critter_B) do
  begin
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (group_angle == 0) then
      Critter_direction := 3;
    else if (group_angle == 1) then
      Critter_direction := 4;
    else if (group_angle == 2) then
      Critter_direction := 5;
    else if (group_angle == 3) then
      Critter_direction := 0;
    else if (group_angle == 4) then
      Critter_direction := 1;
    else if (group_angle == 5) then
      Critter_direction := 2;
    if (random(0, 2) == 0) then
    begin
      Critter_direction := Critter_direction + (random(0, 2) - 1);
      while (Critter_direction < 0) do
        Critter_direction := Critter_direction + 6;
      if (Critter_direction > 5) then
        Critter_direction := Critter_direction % 6;
    end
    anim(Critter, 1000, Critter_direction);
    Item := create_object_sid(10, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Item := create_object_sid(34, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    if (has_trait(0, dude_obj, 40)) then
    begin
      Item := create_object_sid(34, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
    end
    Tot_Critter_B := Tot_Critter_B - 1;
  end
  attack_setup(victim, Critter);
  Critter_type := 16777219;
  Critter_script := -1;
  Critter_direction := group_angle + (random(0, 2) - 1);
  while (Critter_direction < 0) do
    Critter_direction := Critter_direction + 6;
  if (Critter_direction > 5) then
    Critter_direction := Critter_direction % 6;
  call Place_critter;
  if (group_angle == 0) then
    Critter_direction := 3;
  else if (group_angle == 1) then
    Critter_direction := 4;
  else if (group_angle == 2) then
    Critter_direction := 5;
  else if (group_angle == 3) then
    Critter_direction := 0;
  else if (group_angle == 4) then
    Critter_direction := 1;
  else if (group_angle == 5) then
    Critter_direction := 2;
  if (random(0, 2) == 0) then
  begin
    Critter_direction := Critter_direction + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
  end
  anim(Critter, 1000, Critter_direction);
  Item := create_object_sid(2, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Item := create_object_sid(10, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Item := create_object_sid(34, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  kill_critter(Critter, 61);
  Critter_type := 16777229;
  Critter_script := 753;
  Critter_direction := random(0, 5);
  call Place_critter;
  critter_dmg(Critter, 5, 0);
  Item := item_caps_adjust(Critter, random(100, 300) * (has_trait(0, dude_obj, 20) + 1));
  if (random(1, 10) > 6) then
  begin
    Item := create_object_sid(47, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
  end
  if (random(1, 10) > 6) then
  begin
    Item := create_object_sid(40, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
  end
  if (random(1, 10) > 6) then
  begin
    Item := create_object_sid(78, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
  end
  if (random(1, 10) > 6) then
  begin
    Item := create_object_sid(84, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
  end
  set_global_var(GVAR_WATER_THIEF_1, 1);
  call stranger;
end

procedure Raider2
begin
  variable LVar1 := 0;
  variable LVar2 := 0;

  LVar1 := random(1, 6);
  if (obj_is_carrying_obj_pid(dude_obj, 126)) then
  begin
    display_msg(message_str(SCRIPT_RNDDESRT, 125));
    destroy_object(obj_carrying_pid_obj(dude_obj, 126));
  end
  else
  begin
    Skill_roll := roll_vs_skill(dude_obj, 17, 20 * has_trait(0, dude_obj, 16));
    if (is_success(Skill_roll)) then
    begin
      if (LVar1 == 1) then
        display_msg(message_str(SCRIPT_RNDDESRT, 109));
      else
        display_msg(message_str(SCRIPT_RNDDESRT, 110) + LVar1 + message_str(SCRIPT_RNDDESRT, 111));
    end
    else if (is_critical(Skill_roll)) then
    begin
      LVar2 := random(2, 4);
      if (LVar1 == 1) then
        display_msg(message_str(SCRIPT_RNDDESRT, 112) + LVar2 + message_str(SCRIPT_RNDDESRT, 113));
      else
        display_msg(message_str(SCRIPT_RNDDESRT, 114) + LVar1 + message_str(SCRIPT_RNDDESRT, 115) + LVar2 + message_str(SCRIPT_RNDDESRT, 116));
      critter_injure(dude_obj, 2);
    end
    else
    begin
      LVar2 := random(1, 2);
      if (LVar1 == 1) then
      begin
        if (LVar2 == 1) then
          display_msg(message_str(SCRIPT_RNDDESRT, 117));
        else
          display_msg(message_str(SCRIPT_RNDDESRT, 118) + LVar2 + message_str(SCRIPT_RNDDESRT, 119));
        critter_injure(dude_obj, 2);
      end
      else
      begin
        if (LVar2 == 1) then
          display_msg(message_str(SCRIPT_RNDDESRT, 120) + LVar1 + message_str(SCRIPT_RNDDESRT, 121));
        else
          display_msg(message_str(SCRIPT_RNDDESRT, 122) + LVar1 + message_str(SCRIPT_RNDDESRT, 123) + LVar2 + message_str(SCRIPT_RNDDESRT, 124));
        critter_injure(dude_obj, 2);
      end
    end
    critter_dmg(dude_obj, LVar2, 0);
    LVar1 := LVar1 * 3600;
    game_time_advance(game_ticks(LVar1));
  end
end

procedure Raider3
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 196));
  Tot_Critter_A := random(3, 4);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 2;
  Critter_type := 16777227;
  Critter_script := 12;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(4, 5);
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 1);
  call stranger;
end

procedure Raider4
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 197));
  Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 3;
  Tot_Critter_A := random(4, 6);
  group_angle := random(0, 5);
  Critter_script := 749;
  while (Tot_Critter_A) do
  begin
    if (random(0, 1)) then
    begin
      if (random(0, 1)) then
        Critter_type := 16777449;
      else
        Critter_type := 16777432;
    end
    else
      Critter_type := 16777319;
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (group_angle == 0) then
      Critter_direction := 3;
    else if (group_angle == 1) then
      Critter_direction := 4;
    else if (group_angle == 2) then
      Critter_direction := 5;
    else if (group_angle == 3) then
      Critter_direction := 0;
    else if (group_angle == 4) then
      Critter_direction := 1;
    else if (group_angle == 5) then
      Critter_direction := 2;
    if (random(0, 2) == 0) then
    begin
      Critter_direction := Critter_direction + (random(0, 2) - 1);
      while (Critter_direction < 0) do
        Critter_direction := Critter_direction + 6;
      if (Critter_direction > 5) then
        Critter_direction := Critter_direction % 6;
    end
    anim(Critter, 1000, Critter_direction);
    Item := create_object_sid(4, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    if (random(0, 1)) then
    begin
      if (random(0, 1)) then
        Item := create_object_sid(10, 0, 0, -1);
      else
        Item := create_object_sid(18, 0, 0, -1);
    end
    else
      Item := create_object_sid(8, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    if (random(0, 1)) then
    begin
      Item := create_object_sid(124, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
    end
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 1);
  call stranger;
end

procedure Raider5
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 198));
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 5;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 2;
  Critter_direction := dude_rot;
  Critter_type := 16777254;
  Critter_script := 700;
  call Place_critter;
  anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
  Item := create_object_sid(4, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  if (random(0, 1)) then
  begin
    if (random(0, 1)) then
      Item := create_object_sid(10, 0, 0, -1);
    else
      Item := create_object_sid(18, 0, 0, -1);
  end
  else
    Item := create_object_sid(8, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  if (random(0, 1)) then
    Item := item_caps_adjust(Critter, random(5, 10) * (has_trait(0, dude_obj, 20) + 1));
end

procedure Raider6
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 199));
  Tot_Critter_A := random(3, 5);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 4;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 2;
  Critter_script := -1;
  while (Tot_Critter_A) do
  begin
    if (random(0, 1)) then
    begin
      if (random(0, 1)) then
        Critter_type := 16777449;
      else
        Critter_type := 16777432;
    end
    else
      Critter_type := 16777319;
    Critter_direction := random(0, 5);
    call Place_critter;
    anim(Critter, 1000, random(0, 5));
    kill_critter(Critter, 61);
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  Critter_type := 16777252;
  Critter_direction := random(0, 5);
  call Place_critter;
  anim(Critter, 1000, random(0, 5));
  kill_critter(Critter, 61);
end

procedure Junk1
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 200));
  Tot_Critter_A := random(3, 4);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 2;
  Critter_type := 16777227;
  Critter_script := 12;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(0, 4);
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 1);
  call stranger;
end

procedure Junk2
begin
  variable LVar1 := 0;
  variable LVar2 := 0;

  LVar1 := random(1, 6);
  if (obj_is_carrying_obj_pid(dude_obj, 126)) then
  begin
    display_msg(message_str(SCRIPT_RNDDESRT, 125));
    destroy_object(obj_carrying_pid_obj(dude_obj, 126));
  end
  else
  begin
    Skill_roll := roll_vs_skill(dude_obj, 17, 20 * has_trait(0, dude_obj, 16));
    if (is_success(Skill_roll)) then
    begin
      if (LVar1 == 1) then
        display_msg(message_str(SCRIPT_RNDDESRT, 109));
      else
        display_msg(message_str(SCRIPT_RNDDESRT, 110) + LVar1 + message_str(SCRIPT_RNDDESRT, 111));
    end
    else if (is_critical(Skill_roll)) then
    begin
      LVar2 := random(2, 4);
      if (LVar1 == 1) then
        display_msg(message_str(SCRIPT_RNDDESRT, 112) + LVar2 + message_str(SCRIPT_RNDDESRT, 113));
      else
        display_msg(message_str(SCRIPT_RNDDESRT, 114) + LVar1 + message_str(SCRIPT_RNDDESRT, 115) + LVar2 + message_str(SCRIPT_RNDDESRT, 116));
      critter_injure(dude_obj, 2);
    end
    else
    begin
      LVar2 := random(1, 2);
      if (LVar1 == 1) then
      begin
        if (LVar2 == 1) then
          display_msg(message_str(SCRIPT_RNDDESRT, 117));
        else
          display_msg(message_str(SCRIPT_RNDDESRT, 118) + LVar2 + message_str(SCRIPT_RNDDESRT, 119));
        critter_injure(dude_obj, 2);
      end
      else
      begin
        if (LVar2 == 1) then
          display_msg(message_str(SCRIPT_RNDDESRT, 120) + LVar1 + message_str(SCRIPT_RNDDESRT, 121));
        else
          display_msg(message_str(SCRIPT_RNDDESRT, 122) + LVar1 + message_str(SCRIPT_RNDDESRT, 123) + LVar2 + message_str(SCRIPT_RNDDESRT, 124));
        critter_injure(dude_obj, 2);
      end
    end
    critter_dmg(dude_obj, LVar2, 0);
    LVar1 := LVar1 * 3600;
    game_time_advance(game_ticks(LVar1));
  end
end

procedure Junk3
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 223));
  Tot_Critter_A := random(4, 6);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 2;
  group_angle := random(0, 5);
  Critter_type := 16777379;
  Critter_script := 693;
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    anim(Critter, 1000, random(0, 5));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 1);
  call stranger;
end

procedure Junk4
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 224));
  Tot_Critter_A := random(2, 4);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 5;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 2;
  Critter_type := 16777452;
  Critter_script := 437;
  group_angle := random(0, 5);
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (random(1, 3) == 1) then
      anim(Critter, 1000, random(0, 5));
    else
      anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Item := create_object_sid(4, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    if (random(0, 1)) then
    begin
      Item := create_object_sid(10, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
      Item := create_object_sid(34, 0, 0, -1);
      add_mult_objs_to_inven(Critter, Item, has_trait(0, dude_obj, 40) + 1);
    end
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  Item := create_object_sid(100, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
end

procedure Junk5
begin
  variable LVar1 := 0;

  display_msg(message_str(SCRIPT_RNDDESRT, 225));
  Tot_Critter_A := random(1, 3);
  Tot_Critter_B := random(2, 12);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 2;
  group_angle := random(0, 5);
  LVar1 := tile_num_in_direction(Dude_tile + random(0, 8) - 4, random(0, 5), random(7, 12));
  Item := create_object_sid(33554959, LVar1, 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 0), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 1), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 2), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 3), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 4), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 5), 0, -1);
  LVar1 := tile_num_in_direction(Dude_tile + random(0, 8) - 4, random(0, 5), random(7, 12));
  Item := create_object_sid(33554960, LVar1, 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 0), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 1), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 2), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 3), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 4), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 5), 0, -1);
  Critter_type := 16777245;
  Critter_script := 752;
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    anim(Critter, 1000, random(0, 5));
    Item := item_caps_adjust(Critter, random(50, 150) * (has_trait(0, dude_obj, 20) + 1));
    Item := create_object_sid(30, 0, 0, -1);
    add_mult_objs_to_inven(Critter, Item, random(1, 4));
    Item := create_object_sid(29, 0, 0, -1);
    add_mult_objs_to_inven(Critter, Item, random(1, 4));
    Item := create_object_sid(4, 0, 0, -1);
    add_mult_objs_to_inven(Critter, Item, random(1, 4));
    Item := create_object_sid(71, 0, 0, -1);
    add_mult_objs_to_inven(Critter, Item, random(4, 8));
    Item := create_object_sid(127, 0, 0, -1);
    add_mult_objs_to_inven(Critter, Item, random(0, 2));
    Item := create_object_sid(93, 0, 0, -1);
    add_mult_objs_to_inven(Critter, Item, random(0, 2));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  Critter_type := 16777243;
  Critter_script := 755;
  while (Tot_Critter_B) do
  begin
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    anim(Critter, 1000, random(0, 5));
    Item := create_object_sid(4, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    if (random(0, 1)) then
    begin
      Item := create_object_sid(18, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
      Item := create_object_sid(31, 0, 0, -1);
      add_mult_objs_to_inven(Critter, Item, has_trait(0, dude_obj, 40) + 1);
    end
    else
    begin
      Item := create_object_sid(10, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
      Item := create_object_sid(34, 0, 0, -1);
      add_mult_objs_to_inven(Critter, Item, has_trait(0, dude_obj, 40) + 1);
    end
    Tot_Critter_B := Tot_Critter_B - 1;
  end
end

procedure Junk6
begin
  variable LVar1 := 2;
  variable LVar2 := 0;

  display_msg(message_str(SCRIPT_RNDDESRT, 172));
  LVar2 := create_object_sid(41, 0, 0, -1);
  Critter_direction := random(0, 5);
  Critter_tile := tile_num_in_direction(Dude_tile, Critter_direction, 4);
  if (get_critter_stat(dude_obj, 6) < 3) then
  begin
    Item := create_object_sid(71, 0, 0, -1);
    critter_attempt_placement(Item, Critter_tile, 0);
  end
  else if (get_critter_stat(dude_obj, 6) == 8) then
  begin
    Item := create_object_sid(71, 0, 0, -1);
    critter_attempt_placement(Item, Critter_tile, 0);
    Item := create_object_sid(29, 0, 0, -1);
    critter_attempt_placement(Item, Critter_tile, 0);
    if (has_trait(0, dude_obj, 40)) then
    begin
      Item := create_object_sid(29, 0, 0, -1);
      critter_attempt_placement(Item, Critter_tile, 0);
    end
    Item := create_object_sid(46, 0, 0, -1);
    critter_attempt_placement(Item, Critter_tile, 0);
    add_mult_objs_to_inven(Item, LVar2, 6 * (has_trait(0, dude_obj, 20) + 1));
  end
  else if (get_critter_stat(dude_obj, 6) > 8) then
  begin
    Item := create_object_sid(71, 0, 0, -1);
    critter_attempt_placement(Item, Critter_tile, 0);
    if (has_trait(0, dude_obj, 40)) then
      LVar1 := 4;
    while (LVar1) do
    begin
      Item := create_object_sid(29, 0, 0, -1);
      critter_attempt_placement(Item, Critter_tile, 0);
      LVar1 := LVar1 - 1;
    end
    Item := create_object_sid(46, 0, 0, -1);
    add_mult_objs_to_inven(Item, LVar2, 122 * (has_trait(0, dude_obj, 20) + 1));
    critter_attempt_placement(Item, Critter_tile, 0);
    Item := create_object_sid(8, 0, 0, -1);
    critter_attempt_placement(Item, Critter_tile, 0);
  end
  else
  begin
    Item := create_object_sid(71, 0, 0, -1);
    critter_attempt_placement(Item, Critter_tile, 0);
    Item := create_object_sid(46, 0, 0, -1);
    add_mult_objs_to_inven(Item, LVar2, 4 * (has_trait(0, dude_obj, 20) + 1));
    critter_attempt_placement(Item, Critter_tile, 0);
  end
end

procedure Hub1
begin
  variable LVar1 := 0;
  variable LVar2 := 0;

  LVar1 := random(1, 6) + 2;
  if (obj_is_carrying_obj_pid(dude_obj, 126)) then
  begin
    display_msg(message_str(SCRIPT_RNDDESRT, 125));
    destroy_object(obj_carrying_pid_obj(dude_obj, 126));
  end
  else
  begin
    Skill_roll := roll_vs_skill(dude_obj, 17, 20 * has_trait(0, dude_obj, 16));
    if (is_success(Skill_roll)) then
      display_msg(message_str(SCRIPT_RNDDESRT, 110) + LVar1 + message_str(SCRIPT_RNDDESRT, 111));
    else
    begin
      if (is_critical(Skill_roll)) then
        LVar2 := random(2, 4);
      else
        LVar2 := random(2, 3);
      display_msg(message_str(SCRIPT_RNDDESRT, 114) + LVar1 + message_str(SCRIPT_RNDDESRT, 115) + LVar2 + message_str(SCRIPT_RNDDESRT, 116));
      critter_injure(dude_obj, 2);
    end
    critter_dmg(dude_obj, LVar2, 0);
    LVar1 := LVar1 * 3600;
    game_time_advance(game_ticks(LVar1));
  end
end

procedure Hub2
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 133));
  Tot_Critter_A := random(3, 6);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 2;
  Critter_script := 749;
  while (Tot_Critter_A) do
  begin
    if (random(0, 1)) then
    begin
      if (random(0, 1)) then
        Critter_type := 16777254;
      else
        Critter_type := 16777235;
    end
    else
      Critter_type := 16777243;
    Critter_direction := random(3, 5);
    call Place_critter;
    anim(Critter, 1000, random(0, 2));
    Item := create_object_sid(4, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    if (random(0, 1)) then
    begin
      if (random(0, 1)) then
        Item := create_object_sid(9, 0, 0, -1);
      else
        Item := create_object_sid(10, 0, 0, -1);
    end
    else
      Item := create_object_sid(8, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Item := item_caps_adjust(Critter, random(10, 30) * (has_trait(0, dude_obj, 20) + 1));
    if (random(0, 3) == 3) then
    begin
      Item := create_object_sid(40, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
    end
    if (random(0, 3) == 3) then
    begin
      Item := create_object_sid(87, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
    end
    if (random(0, 3) == 3) then
    begin
      Item := create_object_sid(81, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
    end
    if (random(0, 3) == 3) then
    begin
      Item := create_object_sid(103, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
    end
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 2);
  call stranger;
end

procedure Hub3
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 134));
  Tot_Critter_A := random(2, 3);
  Tot_Critter_B := random(1, 2);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 2;
  Critter_type := 16777227;
  Critter_script := 12;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(0, 4);
    call Place_critter;
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  Critter_type := 16777382;
  while (Tot_Critter_B) do
  begin
    Critter_direction := random(0, 4);
    call Place_critter;
    Tot_Critter_B := Tot_Critter_B - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 2);
  call stranger;
end

procedure Hub4
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 135));
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 5;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 3;
  Tot_Critter_A := random(4, 6);
  Critter_script := 573;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(0, 2);
    if (random(0, 1)) then
      Critter_type := 16777243;
    else
      Critter_type := 16777253;
    call Place_critter;
    anim(Critter, 1000, random(3, 5));
    Item := item_caps_adjust(Critter, random(20, 50) * (has_trait(0, dude_obj, 20) + 1));
    if (random(0, 1)) then
      Item := create_object_sid(9, 0, 0, -1);
    else
      Item := create_object_sid(18, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Tot_Critter_A := Tot_Critter_A - 1;
  end
end

procedure Hub5
begin
  variable LVar1 := 0;

  display_msg(message_str(SCRIPT_RNDDESRT, 136));
  LVar1 := tile_num_in_direction(Dude_tile + random(0, 8) - 4, random(0, 5), random(7, 9));
  Item := create_object_sid(33554959, LVar1, 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 0), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 1), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 2), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 3), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 4), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 5), 0, -1);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 5;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 3;
  Tot_Critter_A := random(5, 8);
  Critter_script := 755;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(0, 2);
    if (random(0, 1)) then
      Critter_type := 16777243;
    else
      Critter_type := 16777253;
    call Place_critter;
    anim(Critter, 1000, random(3, 5));
    Item := item_caps_adjust(Critter, random(20, 50) * (has_trait(0, dude_obj, 20) + 1));
    if (random(0, 1)) then
      Item := create_object_sid(9, 0, 0, -1);
    else
      Item := create_object_sid(18, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 4;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 2;
  Critter_type := 16777229;
  Critter_script := 752;
  call Place_critter;
  Item := item_caps_adjust(Critter, random(100, 300) * (has_trait(0, dude_obj, 20) + 1));
  Item := create_object_sid(71, 0, 0, -1);
  add_mult_objs_to_inven(Critter, Item, random(0, 4));
  Item := create_object_sid(81, 0, 0, -1);
  add_mult_objs_to_inven(Critter, Item, random(0, 4));
  Item := create_object_sid(40, 0, 0, -1);
  add_mult_objs_to_inven(Critter, Item, random(0, 2));
  Item := create_object_sid(47, 0, 0, -1);
  add_mult_objs_to_inven(Critter, Item, random(0, 1));
  Item := create_object_sid(29, 0, 0, -1);
  add_mult_objs_to_inven(Critter, Item, random(0, 3));
  Item := create_object_sid(30, 0, 0, -1);
  add_mult_objs_to_inven(Critter, Item, random(0, 3));
  Item := create_object_sid(35, 0, 0, -1);
  add_mult_objs_to_inven(Critter, Item, random(0, 2));
  Item := create_object_sid(36, 0, 0, -1);
  add_mult_objs_to_inven(Critter, Item, random(0, 2));
end

procedure Hub6
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 137));
  Tot_Critter_A := random(2, 4);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 3;
  Critter_type := 16777244;
  Critter_script := 34;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(0, 5);
    call Place_critter;
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  Critter_type := 16777386;
  Critter_script := -1;
  call Place_critter;
end

procedure Necrop1
begin
  variable LVar1 := 0;
  variable LVar2 := 0;

  LVar1 := random(1, 6);
  if (obj_is_carrying_obj_pid(dude_obj, 126)) then
  begin
    display_msg(message_str(SCRIPT_RNDDESRT, 125));
    destroy_object(obj_carrying_pid_obj(dude_obj, 126));
  end
  else
  begin
    Skill_roll := roll_vs_skill(dude_obj, 17, 20 * has_trait(0, dude_obj, 16));
    if (is_success(Skill_roll)) then
    begin
      if (LVar1 == 1) then
        display_msg(message_str(SCRIPT_RNDDESRT, 109));
      else
        display_msg(message_str(SCRIPT_RNDDESRT, 110) + LVar1 + message_str(SCRIPT_RNDDESRT, 111));
    end
    else if (is_critical(Skill_roll)) then
    begin
      LVar2 := random(2, 4);
      if (LVar1 == 1) then
        display_msg(message_str(SCRIPT_RNDDESRT, 112) + LVar2 + message_str(SCRIPT_RNDDESRT, 113));
      else
        display_msg(message_str(SCRIPT_RNDDESRT, 114) + LVar1 + message_str(SCRIPT_RNDDESRT, 115) + LVar2 + message_str(SCRIPT_RNDDESRT, 116));
      critter_injure(dude_obj, 2);
    end
    else
    begin
      LVar2 := random(1, 2);
      if (LVar1 == 1) then
      begin
        if (LVar2 == 1) then
          display_msg(message_str(SCRIPT_RNDDESRT, 117));
        else
          display_msg(message_str(SCRIPT_RNDDESRT, 118) + LVar2 + message_str(SCRIPT_RNDDESRT, 119));
        critter_injure(dude_obj, 2);
      end
      else
      begin
        if (LVar2 == 1) then
          display_msg(message_str(SCRIPT_RNDDESRT, 120) + LVar1 + message_str(SCRIPT_RNDDESRT, 121));
        else
          display_msg(message_str(SCRIPT_RNDDESRT, 122) + LVar1 + message_str(SCRIPT_RNDDESRT, 123) + LVar2 + message_str(SCRIPT_RNDDESRT, 124));
        critter_injure(dude_obj, 2);
      end
    end
    critter_dmg(dude_obj, LVar2, 0);
    LVar1 := LVar1 * 3600;
    game_time_advance(game_ticks(LVar1));
  end
end

procedure Necrop2
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 126));
  Tot_Critter_A := random(2, 4);
  Tot_Critter_B := random(2, 4);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 3;
  group_angle := random(0, 5);
  Critter_script := 12;
  Dude_tile := Dude_tile + (200 * (random(0, 4) - 2));
  while (Tot_Critter_A) do
  begin
    if (random(0, 3) == 3) then
      Critter_type := 16777382;
    else
      Critter_type := 16777227;
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (group_angle == 0) then
      Critter_direction := 3;
    else if (group_angle == 1) then
      Critter_direction := 4;
    else if (group_angle == 2) then
      Critter_direction := 5;
    else if (group_angle == 3) then
      Critter_direction := 0;
    else if (group_angle == 4) then
      Critter_direction := 1;
    else if (group_angle == 5) then
      Critter_direction := 2;
    if (random(0, 2) == 0) then
    begin
      Critter_direction := Critter_direction + (random(0, 2) - 1);
      while (Critter_direction < 0) do
        Critter_direction := Critter_direction + 6;
      if (Critter_direction > 5) then
        Critter_direction := Critter_direction % 6;
    end
    anim(Critter, 1000, Critter_direction);
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  victim := Critter;
  Critter_script := 222;
  if (group_angle == 0) then
    group_angle := 3;
  else if (group_angle == 1) then
    group_angle := 4;
  else if (group_angle == 2) then
    group_angle := 5;
  else if (group_angle == 3) then
    group_angle := 0;
  else if (group_angle == 4) then
    group_angle := 1;
  else if (group_angle == 5) then
    group_angle := 2;
  while (Tot_Critter_B) do
  begin
    if (random(0, 2) == 2) then
      Critter_type := 16777226;
    else
      Critter_type := 16777378;
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (group_angle == 0) then
      Critter_direction := 3;
    else if (group_angle == 1) then
      Critter_direction := 4;
    else if (group_angle == 2) then
      Critter_direction := 5;
    else if (group_angle == 3) then
      Critter_direction := 0;
    else if (group_angle == 4) then
      Critter_direction := 1;
    else if (group_angle == 5) then
      Critter_direction := 2;
    if (random(0, 2) == 0) then
    begin
      Critter_direction := Critter_direction + (random(0, 2) - 1);
      while (Critter_direction < 0) do
        Critter_direction := Critter_direction + 6;
      if (Critter_direction > 5) then
        Critter_direction := Critter_direction % 6;
    end
    anim(Critter, 1000, Critter_direction);
    Tot_Critter_B := Tot_Critter_B - 1;
  end
  attack_setup(Critter, victim);
  set_global_var(GVAR_WATER_THIEF_1, 1);
  call stranger;
end

procedure Necrop3
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 127));
  Tot_Critter_A := random(2, 4);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 4;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 2;
  group_angle := random(0, 5);
  Critter_type := 16777230;
  Critter_script := 953;
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 1);
  call stranger;
end

procedure Necrop4
begin
  variable LVar1 := 0;
  variable LVar2 := 0;
  variable LVar3 := 0;

  display_msg(message_str(SCRIPT_RNDDESRT, 128));
  Item := create_object_sid(33554653, tile_num_in_direction(Dude_tile + random(0, 8) - 4, random(0, 5), random(5, 8)), 0, -1);
  Item := create_object_sid(33554654, tile_num_in_direction(Dude_tile + random(0, 8) - 4, random(0, 5), random(5, 8)), 0, -1);
  Item := create_object_sid(33554747, tile_num_in_direction(Dude_tile + random(0, 8) - 4, random(0, 5), random(5, 8)), 0, -1);
  if (random(0, 3) == 3) then
  begin
    LVar2 := tile_num_in_direction(tile_num(dude_obj), random(0, 5), random(0, 5));
    LVar3 := random(0, 4);
    if (LVar3 == 0) then
      LVar1 := create_object_sid(29, LVar2, 0, -1);
    else if (LVar3 == 1) then
      LVar1 := create_object_sid(30, LVar2, 0, -1);
    else if (LVar3 == 2) then
      LVar1 := create_object_sid(34, LVar2, 0, -1);
    else if (LVar3 == 3) then
      LVar1 := create_object_sid(31, LVar2, 0, -1);
    else if (LVar3 == 4) then
      LVar1 := create_object_sid(111, LVar2, 0, -1);
  end
  LVar2 := tile_num_in_direction(tile_num(dude_obj), random(0, 5), random(3, 5));
  LVar1 := create_object_sid(33554541, LVar2, 0, -1);
  LVar2 := tile_num_in_direction(tile_num(dude_obj), random(0, 5), random(3, 5));
  LVar1 := create_object_sid(33554437, LVar2, 0, -1);
  LVar2 := tile_num_in_direction(tile_num(dude_obj), random(0, 5), random(3, 5));
  LVar1 := create_object_sid(33554524, LVar2, 0, -1);
end

procedure Necrop5
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 127));
  Tot_Critter_A := random(1, 3);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 4;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 2;
  group_angle := random(0, 5);
  Critter_type := 16777230;
  Critter_script := 953;
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 1);
  call stranger;
end

procedure Necrop6
begin
  variable LVar1 := 0;
  variable LVar2 := 0;

  display_msg(message_str(SCRIPT_RNDDESRT, 130));
  Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 4;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 2;
  if (random(0, 1)) then
    Critter_type := 16777254;
  else
    Critter_type := 16777253;
  Critter_script := -1;
  Critter_direction := random(0, 5);
  call Place_critter;
  anim(Critter, 1000, random(0, 5));
  if (random(0, 3) == 3) then
  begin
    LVar2 := create_object_sid(40, 0, 0, -1);
    add_obj_to_inven(LVar1, LVar2);
  end
  if (random(0, 3) == 3) then
    LVar2 := item_caps_adjust(LVar1, random(50, 100) * (has_trait(0, dude_obj, 20) + 1));
  if (random(0, 3) == 3) then
  begin
    LVar2 := create_object_sid(90, 0, 0, -1);
    add_obj_to_inven(LVar1, LVar2);
  end
  if (random(0, 3) == 3) then
  begin
    LVar2 := create_object_sid(10, 0, 0, -1);
    add_obj_to_inven(LVar1, LVar2);
  end
  if (random(0, 3) == 3) then
  begin
    LVar2 := create_object_sid(8, 0, 0, -1);
    add_obj_to_inven(LVar1, LVar2);
  end
  if (random(0, 3) == 3) then
  begin
    LVar2 := create_object_sid(1, 0, 0, -1);
    add_obj_to_inven(LVar1, LVar2);
  end
  if (random(0, 3) == 3) then
  begin
    LVar2 := create_object_sid(127, 0, 0, -1);
    add_obj_to_inven(LVar1, LVar2);
  end
  if (random(0, 3) == 3) then
  begin
    LVar2 := create_object_sid(51, 0, 0, -1);
    add_obj_to_inven(LVar1, LVar2);
  end
  LVar2 := create_object_sid(106, 0, 0, -1);
  add_obj_to_inven(LVar1, LVar2);
  LVar2 := item_caps_adjust(LVar1, random(3, 9) * (has_trait(0, dude_obj, 20) + 1));
  kill_critter(Critter, 61);
end

procedure Steel1
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 226));
  Tot_Critter_A := 2;
  Tot_Critter_B := 6;
  Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 8;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 4;
  group_angle := random(0, 5);
  random_seed_1 := 0;
  Critter_script := 759;
  if (random(0, 1)) then
    Critter_type := 16777491;
  else
    Critter_type := 16777494;
  Critter_direction := group_angle + (random(0, 2) - 1);
  while (Critter_direction < 0) do
    Critter_direction := Critter_direction + 6;
  if (Critter_direction > 5) then
    Critter_direction := Critter_direction % 6;
  call Place_critter;
  if (group_angle == 0) then
    Critter_direction := 3;
  else if (group_angle == 1) then
    Critter_direction := 4;
  else if (group_angle == 2) then
    Critter_direction := 5;
  else if (group_angle == 3) then
    Critter_direction := 0;
  else if (group_angle == 4) then
    Critter_direction := 1;
  else if (group_angle == 5) then
    Critter_direction := 2;
  if (random(0, 2) == 0) then
  begin
    Critter_direction := Critter_direction + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
  end
  anim(Critter, 1000, Critter_direction);
  Item := create_object_sid(28, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  victim := Critter;
  Critter_script := 758;
  while (Tot_Critter_A) do
  begin
    if (random(0, 1)) then
      Critter_type := 16777490;
    else
      Critter_type := 16777493;
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (group_angle == 0) then
      Critter_direction := 3;
    else if (group_angle == 1) then
      Critter_direction := 4;
    else if (group_angle == 2) then
      Critter_direction := 5;
    else if (group_angle == 3) then
      Critter_direction := 0;
    else if (group_angle == 4) then
      Critter_direction := 1;
    else if (group_angle == 5) then
      Critter_direction := 2;
    if (random(0, 2) == 0) then
    begin
      Critter_direction := Critter_direction + (random(0, 2) - 1);
      while (Critter_direction < 0) do
        Critter_direction := Critter_direction + 6;
      if (Critter_direction > 5) then
        Critter_direction := Critter_direction % 6;
    end
    anim(Critter, 1000, Critter_direction);
    Item := create_object_sid(12, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    if (random(1, 3) == 1) then
    begin
      Item := create_object_sid(13, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
      Item := create_object_sid(37, 0, 0, -1);
      add_mult_objs_to_inven(Critter, Item, random(1, 3));
    end
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  Critter_type := 16777403;
  Critter_script := 850;
  if (group_angle == 0) then
    group_angle := 3;
  else if (group_angle == 1) then
    group_angle := 4;
  else if (group_angle == 2) then
    group_angle := 5;
  else if (group_angle == 3) then
    group_angle := 0;
  else if (group_angle == 4) then
    group_angle := 1;
  else if (group_angle == 5) then
    group_angle := 2;
  while (Tot_Critter_B) do
  begin
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (group_angle == 0) then
      Critter_direction := 3;
    else if (group_angle == 1) then
      Critter_direction := 4;
    else if (group_angle == 2) then
      Critter_direction := 5;
    else if (group_angle == 3) then
      Critter_direction := 0;
    else if (group_angle == 4) then
      Critter_direction := 1;
    else if (group_angle == 5) then
      Critter_direction := 2;
    if (random(0, 2) == 0) then
    begin
      Critter_direction := Critter_direction + (random(0, 2) - 1);
      while (Critter_direction < 0) do
        Critter_direction := Critter_direction + 6;
      if (Critter_direction > 5) then
        Critter_direction := Critter_direction % 6;
    end
    anim(Critter, 1000, Critter_direction);
    if (random(1, 3) == 1) then
      Item := create_object_sid(11, 0, 0, -1);
    else
      Item := create_object_sid(12, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    if (random(1, 2) == 1) then
    begin
      Item := create_object_sid(13, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
      Item := create_object_sid(37, 0, 0, -1);
      add_mult_objs_to_inven(Critter, Item, random(1, 3));
    end
    Tot_Critter_B := Tot_Critter_B - 1;
  end
  attack_setup(victim, Critter);
  set_global_var(GVAR_WATER_THIEF_1, 3);
  call stranger;
end

procedure Steel2
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 227));
  Tot_Critter_A := random(6, 10);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 7;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 3;
  Critter_type := 16777227;
  Critter_script := 12;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(3, 5);
    call Place_critter;
    if (random(1, 3) == 1) then
      anim(Critter, 1000, random(0, 5));
    else
      anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 3);
  call stranger;
end

procedure Steel3
begin
  variable LVar1 := 0;
  variable LVar2 := 0;

  LVar1 := random(1, 6);
  if (obj_is_carrying_obj_pid(dude_obj, 126)) then
  begin
    display_msg(message_str(SCRIPT_RNDDESRT, 125));
    destroy_object(obj_carrying_pid_obj(dude_obj, 126));
  end
  else
  begin
    Skill_roll := roll_vs_skill(dude_obj, 17, 20 * has_trait(0, dude_obj, 16));
    if (is_success(Skill_roll)) then
    begin
      if (LVar1 == 1) then
        display_msg(message_str(SCRIPT_RNDDESRT, 109));
      else
        display_msg(message_str(SCRIPT_RNDDESRT, 110) + LVar1 + message_str(SCRIPT_RNDDESRT, 111));
    end
    else if (is_critical(Skill_roll)) then
    begin
      LVar2 := random(2, 4);
      if (LVar1 == 1) then
        display_msg(message_str(SCRIPT_RNDDESRT, 112) + LVar2 + message_str(SCRIPT_RNDDESRT, 113));
      else
        display_msg(message_str(SCRIPT_RNDDESRT, 114) + LVar1 + message_str(SCRIPT_RNDDESRT, 115) + LVar2 + message_str(SCRIPT_RNDDESRT, 116));
      critter_injure(dude_obj, 2);
    end
    else
    begin
      LVar2 := random(1, 2);
      if (LVar1 == 1) then
      begin
        if (LVar2 == 1) then
          display_msg(message_str(SCRIPT_RNDDESRT, 117));
        else
          display_msg(message_str(SCRIPT_RNDDESRT, 118) + LVar2 + message_str(SCRIPT_RNDDESRT, 119));
      end
      else
      begin
        if (LVar2 == 1) then
          display_msg(message_str(SCRIPT_RNDDESRT, 120) + LVar1 + message_str(SCRIPT_RNDDESRT, 121));
        else
          display_msg(message_str(SCRIPT_RNDDESRT, 122) + LVar1 + message_str(SCRIPT_RNDDESRT, 123) + LVar2 + message_str(SCRIPT_RNDDESRT, 124));
        critter_injure(dude_obj, 2);
      end
    end
    critter_dmg(dude_obj, LVar2, 0);
    LVar1 := LVar1 * 3600;
    game_time_advance(game_ticks(LVar1));
  end
end

procedure Steel4
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 250));
  Tot_Critter_A := random(5, 7);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 4;
  group_angle := dude_rot;
  random_seed_1 := 0;
  if (random(0, 1)) then
    Critter_type := 16777491;
  else
    Critter_type := 16777494;
  Critter_script := 759;
  Critter_direction := group_angle + (random(0, 2) - 1);
  while (Critter_direction < 0) do
    Critter_direction := Critter_direction + 6;
  if (Critter_direction > 5) then
    Critter_direction := Critter_direction % 6;
  call Place_critter;
  if (group_angle == 0) then
    Critter_direction := 3;
  else if (group_angle == 1) then
    Critter_direction := 4;
  else if (group_angle == 2) then
    Critter_direction := 5;
  else if (group_angle == 3) then
    Critter_direction := 0;
  else if (group_angle == 4) then
    Critter_direction := 1;
  else if (group_angle == 5) then
    Critter_direction := 2;
  if (random(0, 2) == 0) then
  begin
    Critter_direction := Critter_direction + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
  end
  anim(Critter, 1000, Critter_direction);
  Item := create_object_sid(28, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Critter_script := 758;
  while (Tot_Critter_A) do
  begin
    if (random(0, 1)) then
      Critter_type := 16777490;
    else
      Critter_type := 16777493;
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (group_angle == 0) then
      Critter_direction := 3;
    else if (group_angle == 1) then
      Critter_direction := 4;
    else if (group_angle == 2) then
      Critter_direction := 5;
    else if (group_angle == 3) then
      Critter_direction := 0;
    else if (group_angle == 4) then
      Critter_direction := 1;
    else if (group_angle == 5) then
      Critter_direction := 2;
    if (random(0, 2) == 0) then
    begin
      Critter_direction := Critter_direction + (random(0, 2) - 1);
      while (Critter_direction < 0) do
        Critter_direction := Critter_direction + 6;
      if (Critter_direction > 5) then
        Critter_direction := Critter_direction % 6;
    end
    anim(Critter, 1000, Critter_direction);
    if (random(1, 3) == 1) then
    begin
      Item := create_object_sid(32, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
    end
    Item := create_object_sid(12, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Tot_Critter_A := Tot_Critter_A - 1;
  end
end

procedure Steel5
begin
  variable LVar1 := 0;

  display_msg(message_str(SCRIPT_RNDDESRT, 251));
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 3;
  LVar1 := tile_num_in_direction(Dude_tile + random(0, 8) - 4, random(0, 5), random(7, 12));
  Item := create_object_sid(33554959, LVar1, 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 0), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 1), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 2), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 3), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 4), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 5), 0, -1);
  LVar1 := tile_num_in_direction(Dude_tile + random(0, 8) - 4, random(0, 5), random(7, 12));
  Item := create_object_sid(33554960, LVar1, 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 0), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 1), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 2), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 3), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 4), 0, -1);
  Item := create_object_sid(33554499, tile_num_in_direction(LVar1, 1, 5), 0, -1);
  if ((game_time_hour >= 1900) or (game_time_hour < 600)) then
  begin
    Critter := create_object_sid(33554433, 0, 0, -1);
    Critter_tile := tile_num_in_direction(Dude_tile, random(0, 5), 5);
    critter_attempt_placement(Critter, Critter_tile, 0);
    Critter := create_object_sid(33554433, 0, 0, -1);
    Critter_tile := tile_num_in_direction(Dude_tile, random(0, 5), 5);
    critter_attempt_placement(Critter, Critter_tile, 0);
  end
  Tot_Critter_A := random(1, 2);
  while (Tot_Critter_A) do
  begin
    Critter_type := 16777244;
    Critter_script := 34;
    Critter_direction := random(0, 5);
    call Place_critter;
    anim(Critter, 1000, random(0, 5));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  Tot_Critter_A := random(2, 4);
  Critter_type := 16777245;
  Critter_script := 752;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(0, 5);
    call Place_critter;
    anim(Critter, 1000, random(0, 5));
    if (random(0, 1)) then
    begin
      Item := create_object_sid(71, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
    end
    if (random(0, 1)) then
    begin
      Item := create_object_sid(29, 0, 0, -1);
      add_mult_objs_to_inven(Critter, Item, 2 * (has_trait(0, dude_obj, 40) + 1));
    end
    if (random(0, 1)) then
    begin
      Item := create_object_sid(30, 0, 0, -1);
      add_mult_objs_to_inven(Critter, Item, 1 * (has_trait(0, dude_obj, 40) + 1));
    end
    if (random(0, 1)) then
    begin
      Item := create_object_sid(34, 0, 0, -1);
      add_mult_objs_to_inven(Critter, Item, 2 * (has_trait(0, dude_obj, 40) + 1));
    end
    if (random(0, 1)) then
    begin
      Item := create_object_sid(40, 0, 0, -1);
      add_mult_objs_to_inven(Critter, Item, random(0, 4));
    end
    if (random(0, 1)) then
    begin
      Item := create_object_sid(47, 0, 0, -1);
      add_mult_objs_to_inven(Critter, Item, random(0, 1));
    end
    if (random(0, 1)) then
    begin
      Item := create_object_sid(81, 0, 0, -1);
      add_mult_objs_to_inven(Critter, Item, random(0, 3));
    end
    Item := item_caps_adjust(Critter, random(12, 32) * (has_trait(0, dude_obj, 20) + 1));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  Tot_Critter_B := random(6, 8);
  Critter_script := 755;
  while (Tot_Critter_B) do
  begin
    Critter_direction := random(0, 5);
    if (random(0, 1)) then
      Critter_type := 16777243;
    else
      Critter_type := 16777238;
    call Place_critter;
    anim(Critter, 1000, random(0, 5));
    Item := item_caps_adjust(Critter, random(1, 15) * (has_trait(0, dude_obj, 20) + 1));
    if (random(0, 1)) then
    begin
      Item := create_object_sid(95, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
      if (has_trait(0, dude_obj, 40)) then
      begin
        Item := create_object_sid(95, 0, 0, -1);
        add_obj_to_inven(Critter, Item);
      end
      Item := create_object_sid(94, 0, 0, -1);
    end
    else
    begin
      Item := create_object_sid(34, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
      if (has_trait(0, dude_obj, 40)) then
      begin
        Item := create_object_sid(34, 0, 0, -1);
        add_obj_to_inven(Critter, Item);
      end
      Item := create_object_sid(10, 0, 0, -1);
    end
    add_obj_to_inven(Critter, Item);
    if (random(0, 1)) then
    begin
      if (random(0, 2) == 0) then
        Item := create_object_sid(125, 0, 0, -1);
      else
        Item := create_object_sid(124, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
    end
    Tot_Critter_B := Tot_Critter_B - 1;
  end
end

procedure Steel6
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 252));
  Tot_Critter_A := random(3, 4);
  Tot_Critter_B := random(12, 15);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 7;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 4;
  group_angle := random(0, 5);
  random_seed_1 := 0;
  Critter_script := 759;
  if (random(0, 1)) then
    Critter_type := 16777491;
  else
    Critter_type := 16777494;
  Critter_direction := group_angle + (random(0, 2) - 1);
  while (Critter_direction < 0) do
    Critter_direction := Critter_direction + 6;
  if (Critter_direction > 5) then
    Critter_direction := Critter_direction % 6;
  call Place_critter;
  if (group_angle == 0) then
    Critter_direction := 3;
  else if (group_angle == 1) then
    Critter_direction := 4;
  else if (group_angle == 2) then
    Critter_direction := 5;
  else if (group_angle == 3) then
    Critter_direction := 0;
  else if (group_angle == 4) then
    Critter_direction := 1;
  else if (group_angle == 5) then
    Critter_direction := 2;
  if (random(0, 2) == 0) then
  begin
    Critter_direction := Critter_direction + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
  end
  anim(Critter, 1000, Critter_direction);
  Item := create_object_sid(28, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Critter_script := 758;
  while (Tot_Critter_A) do
  begin
    if (random(0, 1)) then
      Critter_type := 16777490;
    else
      Critter_type := 16777493;
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (group_angle == 0) then
      Critter_direction := 3;
    else if (group_angle == 1) then
      Critter_direction := 4;
    else if (group_angle == 2) then
      Critter_direction := 5;
    else if (group_angle == 3) then
      Critter_direction := 0;
    else if (group_angle == 4) then
      Critter_direction := 1;
    else if (group_angle == 5) then
      Critter_direction := 2;
    if (random(0, 2) == 0) then
    begin
      Critter_direction := Critter_direction + (random(0, 2) - 1);
      while (Critter_direction < 0) do
        Critter_direction := Critter_direction + 6;
      if (Critter_direction > 5) then
        Critter_direction := Critter_direction % 6;
    end
    anim(Critter, 1000, Critter_direction);
    if (random(0, 3) == 1) then
    begin
      Item := create_object_sid(13, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
      Item := create_object_sid(37, 0, 0, -1);
      add_mult_objs_to_inven(Critter, Item, random(1, 3));
    end
    else
    begin
      Item := create_object_sid(12, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
    end
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  victim := Critter;
  Critter_type := 16777254;
  Critter_script := 749;
  if (group_angle == 0) then
    group_angle := 3;
  else if (group_angle == 1) then
    group_angle := 4;
  else if (group_angle == 2) then
    group_angle := 5;
  else if (group_angle == 3) then
    group_angle := 0;
  else if (group_angle == 4) then
    group_angle := 1;
  else if (group_angle == 5) then
    group_angle := 2;
  while (Tot_Critter_B) do
  begin
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (group_angle == 0) then
      Critter_direction := 3;
    else if (group_angle == 1) then
      Critter_direction := 4;
    else if (group_angle == 2) then
      Critter_direction := 5;
    else if (group_angle == 3) then
      Critter_direction := 0;
    else if (group_angle == 4) then
      Critter_direction := 1;
    else if (group_angle == 5) then
      Critter_direction := 2;
    if (random(0, 2) == 0) then
    begin
      Critter_direction := Critter_direction + (random(0, 2) - 1);
      while (Critter_direction < 0) do
        Critter_direction := Critter_direction + 6;
      if (Critter_direction > 5) then
        Critter_direction := Critter_direction % 6;
    end
    anim(Critter, 1000, Critter_direction);
    Item := create_object_sid(7, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    if (random(0, 2)) then
    begin
      Item := create_object_sid(30, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
      if (has_trait(0, dude_obj, 40)) then
      begin
        Item := create_object_sid(30, 0, 0, -1);
        add_obj_to_inven(Critter, Item);
      end
      Item := create_object_sid(8, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
    end
    if (random(0, 1)) then
    begin
      Item := create_object_sid(40, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
    end
    Tot_Critter_B := Tot_Critter_B - 1;
  end
  attack_setup(Critter, victim);
  set_global_var(GVAR_WATER_THIEF_1, 3);
  call stranger;
end

procedure Vats1
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 253));
  radiation_inc(dude_obj, random(15, 30));
  Tot_Critter_A := random(3, 4);
  Tot_Critter_B := 1;
  Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 3;
  Critter_type := 16777403;
  Critter_script := 850;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(0, 2);
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    if (random(0, 1) == 1) then
    begin
      if (random(0, 3) == 0) then
        Item := create_object_sid(11, 0, 0, -1);
      else
        Item := create_object_sid(12, 0, 0, -1);
    end
    else
      Item := create_object_sid(234, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  Critter_type := 16777241;
  Critter_script := 854;
  while (Tot_Critter_B) do
  begin
    Critter_direction := random(0, 2);
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Item := create_object_sid(12, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Item := create_object_sid(35, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Tot_Critter_B := Tot_Critter_B - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 3);
  call stranger;
end

procedure Vats2
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 254));
  if (random(0, 1)) then
  begin
    Critter_type := 16777259;
    Critter_script := 953;
  end
  else
  begin
    Critter_type := 16777261;
    Critter_script := 953;
  end
  Tot_Critter_A := random(3, 5);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 5;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 2;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(0, 2);
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 3);
  call stranger;
end

procedure Vats3
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 306));
  Tot_Critter_A := random(1, 2);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 4;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 2;
  Critter_type := 16777261;
  Critter_script := 953;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(0, 2);
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  Critter_type := 16777259;
  Critter_script := 953;
  Tot_Critter_A := 1;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(0, 2);
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 3;
  Tot_Critter_A := random(2, 3);
  Critter_type := 16777403;
  Critter_script := 850;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(0, 2);
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  Critter_type := 16777241;
  Critter_script := 854;
  Critter_direction := random(0, 2);
  call Place_critter;
  anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
  Item := create_object_sid(118, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Item := create_object_sid(38, 0, 0, -1);
  add_mult_objs_to_inven(Critter, Item, has_trait(0, dude_obj, 40) + 2);
  if (not obj_is_carrying_obj_pid(dude_obj, 100)) then
  begin
    Item := create_object_sid(100, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
  end
  set_global_var(GVAR_WATER_THIEF_1, 3);
  call stranger;
end

procedure Vats4
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 256));
  Tot_Critter_A := random(3, 4);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 7;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Critter_type := 16777403;
  Critter_script := 850;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(0, 2);
    call Place_critter;
    anim(Critter, 1000, random(3, 4));
    if (random(0, 1) == 1) then
    begin
      if (random(0, 1) == 1) then
        Item := create_object_sid(11, 0, 0, -1);
      else
        Item := create_object_sid(12, 0, 0, -1);
    end
    else
      Item := create_object_sid(234, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  Critter_type := 16777241;
  Critter_script := 854;
  Tot_Critter_B := 1;
  while (Tot_Critter_B) do
  begin
    Critter_direction := random(0, 2);
    call Place_critter;
    anim(Critter, 1000, random(3, 4));
    Item := create_object_sid(12, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Item := create_object_sid(35, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Tot_Critter_B := Tot_Critter_B - 1;
  end
  Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 5;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 3;
  Critter_type := 16777261;
  Critter_script := 953;
  Critter_direction := random(0, 2);
  call Place_critter;
  anim(Critter, 1000, random(3, 4));
  set_global_var(GVAR_WATER_THIEF_1, 3);
  call stranger;
end

procedure Vats5
begin
  variable LVar1 := 0;
  variable LVar2 := 0;

  LVar1 := random(1, 6);
  Skill_roll := roll_vs_skill(dude_obj, 17, 20 * has_trait(0, dude_obj, 16));
  if (is_success(Skill_roll)) then
  begin
    if (LVar1 == 1) then
      display_msg(message_str(SCRIPT_RNDDESRT, 109));
    else
      display_msg(message_str(SCRIPT_RNDDESRT, 110) + LVar1 + message_str(SCRIPT_RNDDESRT, 111));
  end
  else if (is_critical(Skill_roll)) then
  begin
    LVar2 := random(2, 4);
    if (LVar1 == 1) then
      display_msg(message_str(SCRIPT_RNDDESRT, 112) + LVar2 + message_str(SCRIPT_RNDDESRT, 113));
    else
      display_msg(message_str(SCRIPT_RNDDESRT, 114) + LVar1 + message_str(SCRIPT_RNDDESRT, 115) + LVar2 + message_str(SCRIPT_RNDDESRT, 116));
    critter_injure(dude_obj, 2);
  end
  else
  begin
    LVar2 := random(1, 2);
    if (LVar1 == 1) then
    begin
      if (LVar2 == 1) then
        display_msg(message_str(SCRIPT_RNDDESRT, 117));
      else
        display_msg(message_str(SCRIPT_RNDDESRT, 118) + LVar2 + message_str(SCRIPT_RNDDESRT, 119));
      critter_injure(dude_obj, 2);
    end
    else
    begin
      if (LVar2 == 1) then
        display_msg(message_str(SCRIPT_RNDDESRT, 120) + LVar1 + message_str(SCRIPT_RNDDESRT, 121));
      else
        display_msg(message_str(SCRIPT_RNDDESRT, 122) + LVar1 + message_str(SCRIPT_RNDDESRT, 123) + LVar2 + message_str(SCRIPT_RNDDESRT, 124));
      critter_injure(dude_obj, 2);
    end
  end
  LVar1 := LVar1 * 3600;
  game_time_advance(game_ticks(LVar1));
end

procedure Vats6
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 279));
  Item := create_object_sid(33554804, tile_num_in_direction(Dude_tile + random(0, 8) - 4, random(0, 5), random(8, 10)), 0, -1);
  Item := create_object_sid(33554653, tile_num_in_direction(Dude_tile + random(0, 8) - 4, random(0, 5), random(5, 9)), 0, -1);
  Item := create_object_sid(33554654, tile_num_in_direction(Dude_tile + random(0, 8) - 4, random(0, 5), random(5, 9)), 0, -1);
  Item := create_object_sid(33554747, tile_num_in_direction(Dude_tile + random(0, 8) - 4, random(0, 5), random(5, 9)), 0, -1);
  Item := create_object_sid(33555207, tile_num_in_direction(Dude_tile + random(0, 8) - 4, random(0, 5), random(5, 9)), 0, -1);
  if ((game_time_hour >= 1900) or (game_time_hour < 600)) then
  begin
    Item := create_object_sid(33554433, tile_num_in_direction(Dude_tile + random(0, 8) - 4, random(0, 5), random(8, 10)), 0, -1);
    if (random(0, 1)) then
      Item := create_object_sid(33554433, tile_num_in_direction(Dude_tile + random(0, 8) - 4, random(0, 5), random(8, 10)), 0, -1);
  end
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 3;
  group_angle := random(0, 5);
  Critter_type := 16777403;
  Critter_script := 850;
  Tot_Critter_A := random(2, 3);
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  Critter_type := 16777241;
  Critter_script := 854;
  Critter_direction := random(0, 2);
  Critter_direction := group_angle + (random(0, 2) - 1);
  while (Critter_direction < 0) do
    Critter_direction := Critter_direction + 6;
  if (Critter_direction > 5) then
    Critter_direction := Critter_direction % 6;
  call Place_critter;
  anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
  Item := create_object_sid(12, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Item := create_object_sid(35, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 5;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 3;
  Critter_type := 16777261;
  Critter_script := 953;
  Tot_Critter_A := 2;
  if (group_angle == 0) then
    group_angle := 3;
  else if (group_angle == 1) then
    group_angle := 4;
  else if (group_angle == 2) then
    group_angle := 5;
  else if (group_angle == 3) then
    group_angle := 0;
  else if (group_angle == 4) then
    group_angle := 1;
  else if (group_angle == 5) then
    group_angle := 2;
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 3);
  call stranger;
end

procedure Glow1
begin
  variable LVar1 := 3;

  display_msg(message_str(SCRIPT_RNDDESRT, 280));
  Tot_Critter_A := random(2, 3);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 4;
  Critter_type := 16777403;
  Critter_script := 850;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(0, 5);
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  if (random(0, 1)) then
  begin
    Critter_type := 16777241;
    Critter_script := 854;
    Critter_direction := random(0, 5);
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Item := create_object_sid(118, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    if (has_trait(0, dude_obj, 40)) then
      LVar1 := 5;
    while (LVar1) do
    begin
      Item := create_object_sid(38, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
      LVar1 := LVar1 - 1;
    end
  end
  set_global_var(GVAR_WATER_THIEF_1, 3);
  call stranger;
end

procedure Glow2
begin
  variable LVar1 := 0;

  display_msg(message_str(SCRIPT_RNDDESRT, 281));
  LVar1 := game_time_hour;
  Tot_Critter_A := random(3, 5);
  if ((LVar1 > 600) and (LVar1 < 1900)) then
  begin
    Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 5;
    Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 2;
  end
  else
  begin
    Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 2;
    Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 2;
  end
  Critter_type := 16777261;
  Critter_script := 953;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(0, 5);
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  if (random(0, 1)) then
  begin
    Critter_direction := random(0, 4);
    Critter_type := 16777259;
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
  end
  set_global_var(GVAR_WATER_THIEF_1, 3);
  call stranger;
end

procedure Glow3
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 282));
  Tot_Critter_A := random(4, 8);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 8;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 5;
  Critter_type := 16777227;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(0, 4);
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Item := create_object_sid(92, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 3);
  call stranger;
end

procedure Glow4
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 283));
  Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 4;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 2;
  Critter_type := 16777261;
  Critter_script := 953;
  Tot_Critter_A := 1;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(0, 2);
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  radiation_inc(dude_obj, random(15, 30));
end

procedure Glow5
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 284));
  Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 5;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 3;
  group_angle := random(0, 5);
  Tot_Critter_A := 1 + random(0, 1);
  Critter_type := 16777261;
  Critter_script := 953;
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (group_angle == 0) then
      Critter_direction := 3;
    else if (group_angle == 1) then
      Critter_direction := 4;
    else if (group_angle == 2) then
      Critter_direction := 5;
    else if (group_angle == 3) then
      Critter_direction := 0;
    else if (group_angle == 4) then
      Critter_direction := 1;
    else if (group_angle == 5) then
      Critter_direction := 2;
    if (random(0, 2) == 0) then
    begin
      Critter_direction := Critter_direction + (random(0, 2) - 1);
      while (Critter_direction < 0) do
        Critter_direction := Critter_direction + 6;
      if (Critter_direction > 5) then
        Critter_direction := Critter_direction % 6;
    end
    anim(Critter, 1000, Critter_direction);
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  if (random(0, 1)) then
  begin
    Critter_type := 16777259;
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (group_angle == 0) then
      Critter_direction := 3;
    else if (group_angle == 1) then
      Critter_direction := 4;
    else if (group_angle == 2) then
      Critter_direction := 5;
    else if (group_angle == 3) then
      Critter_direction := 0;
    else if (group_angle == 4) then
      Critter_direction := 1;
    else if (group_angle == 5) then
      Critter_direction := 2;
    if (random(0, 2) == 0) then
    begin
      Critter_direction := Critter_direction + (random(0, 2) - 1);
      while (Critter_direction < 0) do
        Critter_direction := Critter_direction + 6;
      if (Critter_direction > 5) then
        Critter_direction := Critter_direction % 6;
    end
    anim(Critter, 1000, Critter_direction);
  end
end

procedure Glow6
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 285));
  Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 5;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 2;
  Critter_script := 953;
  Critter_type := 16777259;
  Critter_direction := random(2, 5);
  call Place_critter;
  anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
  if (random(0, 1)) then
  begin
    Critter_type := 16777261;
    Critter_direction := random(1, 4);
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
  end
  set_global_var(GVAR_WATER_THIEF_1, 3);
  call stranger;
end

procedure Death1
begin
  Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 8;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 8;
  if (global_var(GVAR_KILL_DEATHCLAW) != 2) then
  begin
    display_msg(message_str(SCRIPT_RNDDESRT, 286));
    Critter_direction := random(0, 5);
    Critter_type := 16777267;
    Critter_script := 642;
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
  end
  else
  begin
    display_msg(message_str(SCRIPT_RNDDESRT, 287));
    Critter_type := 16777227;
    Critter_script := 12;
    Tot_Critter_A := random(3, 5);
    while (Tot_Critter_A) do
    begin
      Critter_direction := random(0, 5);
      call Place_critter;
      anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
      Tot_Critter_A := Tot_Critter_A - 1;
    end
  end
  set_global_var(GVAR_WATER_THIEF_1, 2);
  call stranger;
end

procedure Death2
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 288));
  Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 5;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 3;
  Critter_direction := random(0, 5);
  Critter_type := 16777259;
  call Place_critter;
  anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
  set_global_var(GVAR_WATER_THIEF_1, 2);
  call stranger;
end

procedure Death3
begin
  variable LVar1 := 0;
  variable LVar2 := 0;

  LVar1 := random(1, 6) + 2;
  if (obj_is_carrying_obj_pid(dude_obj, 126)) then
  begin
    display_msg(message_str(SCRIPT_RNDDESRT, 125));
    destroy_object(obj_carrying_pid_obj(dude_obj, 126));
  end
  else
  begin
    Skill_roll := roll_vs_skill(dude_obj, 17, 20 * has_trait(0, dude_obj, 16));
    if (is_success(Skill_roll)) then
      display_msg(message_str(SCRIPT_RNDDESRT, 110) + LVar1 + message_str(SCRIPT_RNDDESRT, 111));
    else
    begin
      if (is_critical(Skill_roll)) then
        LVar2 := random(2, 4);
      else
        LVar2 := random(2, 3);
      display_msg(message_str(SCRIPT_RNDDESRT, 114) + LVar1 + message_str(SCRIPT_RNDDESRT, 115) + LVar2 + message_str(SCRIPT_RNDDESRT, 116));
      critter_injure(dude_obj, 2);
    end
    critter_dmg(dude_obj, LVar2, 0);
    LVar1 := LVar1 * 3600;
    game_time_advance(game_ticks(LVar1));
  end
end

procedure Death4
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 299));
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 2;
  Tot_Critter_A := random(2, 4);
  group_angle := random(0, 5);
  Critter_type := 16777227;
  Critter_script := 12;
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle + (random(0, 4) - 2);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (group_angle == 0) then
      Critter_direction := 3;
    else if (group_angle == 1) then
      Critter_direction := 4;
    else if (group_angle == 2) then
      Critter_direction := 5;
    else if (group_angle == 3) then
      Critter_direction := 0;
    else if (group_angle == 4) then
      Critter_direction := 1;
    else if (group_angle == 5) then
      Critter_direction := 2;
    if (random(0, 2) == 0) then
    begin
      Critter_direction := Critter_direction + (random(0, 2) - 1);
      while (Critter_direction < 0) do
        Critter_direction := Critter_direction + 6;
      if (Critter_direction > 5) then
        Critter_direction := Critter_direction % 6;
    end
    anim(Critter, 1000, Critter_direction);
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 2);
  call stranger;
end

procedure Death5
begin
  Outer_ring := (get_critter_stat(dude_obj, 1) / 3) + 10;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 3) + 10;
  if (1 == 1) then
  begin
    display_msg(message_str(SCRIPT_RNDDESRT, 300));
    Critter_direction := dude_rot + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    Critter_type := 16777254;
    Critter_script := 703;
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Item := create_object_sid(18, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Item := create_object_sid(4, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Item := item_caps_adjust(Critter, (random(20, 60) * has_trait(0, dude_obj, 20)) + 1);
    Item := create_object_sid(40, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Item := create_object_sid(31, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Item := create_object_sid(111, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Item := create_object_sid(9, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Item := create_object_sid(1, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Item := create_object_sid(90, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    Item := create_object_sid(125, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    set_global_var(GVAR_TRENT_STATUS, 1);
  end
  else
  begin
    display_msg(message_str(SCRIPT_RNDDESRT, 301));
    Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 7;
    Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 4;
    Critter_direction := random(0, 5);
    if (random(0, 3) == 3) then
      Critter_type := 16777226;
    else
      Critter_type := 16777378;
    Critter_script := 222;
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
  end
  set_global_var(GVAR_WATER_THIEF_1, 2);
  call stranger;
end

procedure Death6
begin
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 5;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 2;
  if (global_var(GVAR_KILL_DEATHCLAW) != 2) then
  begin
    display_msg(message_str(SCRIPT_RNDDESRT, 302));
    Critter_direction := random(0, 5);
    Critter_type := 16777267;
    Critter_script := 642;
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
  end
  else
  begin
    display_msg(message_str(SCRIPT_RNDDESRT, 303));
    Critter_type := 16777227;
    Critter_script := 12;
    Tot_Critter_A := random(3, 5);
    group_angle := random(0, 5);
    while (Tot_Critter_A) do
    begin
      Critter_direction := group_angle + (random(0, 4) - 2);
      while (Critter_direction < 0) do
        Critter_direction := Critter_direction + 6;
      if (Critter_direction > 5) then
        Critter_direction := Critter_direction % 6;
      call Place_critter;
      anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
      Tot_Critter_A := Tot_Critter_A - 1;
    end
  end
  set_global_var(GVAR_WATER_THIEF_1, 2);
  call stranger;
end

procedure Bone1
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 307));
  Tot_Critter_A := random(2, 3);
  group_angle := random(0, 5);
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 4;
  Critter_type := 16777403;
  Critter_script := 850;
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle + (random(0, 4) - 2);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    if (random(1, 4) == 1) then
      Item := create_object_sid(11, 0, 0, -1);
    else
      Item := create_object_sid(12, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    if (random(1, 5) == 1) then
    begin
      Item := create_object_sid(13, 0, 0, -1);
      add_obj_to_inven(Critter, Item);
    end
    if (random(0, 2) == 0) then
      Item := item_caps_adjust(Critter, random(5, 20) * ((2 * has_trait(0, dude_obj, 20)) + 1));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  if (random(0, 1)) then
  begin
    Critter_type := 16777241;
    Critter_script := 854;
    Critter_direction := group_angle + (random(0, 4) - 2);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Item := create_object_sid(12, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    if (random(0, 2) == 0) then
      Item := item_caps_adjust(Critter, random(5, 20) * ((2 * has_trait(0, dude_obj, 20)) + 1));
  end
  set_global_var(GVAR_WATER_THIEF_1, 3);
  call stranger;
end

procedure Bone2
begin
  variable LVar1 := 0;

  display_msg(message_str(SCRIPT_RNDDESRT, 308));
  group_angle := random(0, 5);
  if ((game_time_hour >= 1900) or (game_time_hour < 600) and random(0, 1)) then
  begin
    Critter := create_object_sid(33555044, 0, 0, -1);
    Critter_tile := tile_num_in_direction(Dude_tile, group_angle, 4);
    critter_attempt_placement(Critter, Critter_tile, 0);
    Critter := create_object_sid(33555044, 0, 0, -1);
    if (group_angle == 0) then
      Item := 3;
    else if (group_angle == 1) then
      Item := 4;
    else if (group_angle == 2) then
      Item := 5;
    else if (group_angle == 3) then
      Item := 0;
    else if (group_angle == 4) then
      Item := 1;
    else if (group_angle == 5) then
      Item := 2;
    Critter_tile := tile_num_in_direction(Dude_tile, Item, 4);
    critter_attempt_placement(Critter, Critter_tile, 0);
  end
  Dude_tile := Dude_tile + (random(0, 4) - 2 + ((random(0, 2) - 1) * 200));
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 4;
  Tot_Critter_A := random(3, 5);
  Tot_Critter_B := random(3, 5);
  Critter_type := 16777419;
  Critter_script := 749;
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (group_angle == 0) then
      Critter_direction := 3;
    else if (group_angle == 1) then
      Critter_direction := 4;
    else if (group_angle == 2) then
      Critter_direction := 5;
    else if (group_angle == 3) then
      Critter_direction := 0;
    else if (group_angle == 4) then
      Critter_direction := 1;
    else if (group_angle == 5) then
      Critter_direction := 2;
    if (random(0, 2) == 0) then
    begin
      Critter_direction := Critter_direction + (random(0, 2) - 1);
      while (Critter_direction < 0) do
        Critter_direction := Critter_direction + 6;
      if (Critter_direction > 5) then
        Critter_direction := Critter_direction % 6;
    end
    anim(Critter, 1000, Critter_direction);
    LVar1 := random(0, 2);
    if (LVar1 == 0) then
      Item := create_object_sid(18, 0, 0, -1);
    else if (LVar1 == 1) then
      Item := create_object_sid(21, 0, 0, -1);
    else
      Item := create_object_sid(8, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    if (random(0, 2) == 0) then
      Item := item_caps_adjust(Critter, random(5, 25) * ((2 * has_trait(0, dude_obj, 20)) + 1));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  victim := Critter;
  Critter_type := 16777472;
  Critter_script := 751;
  if (group_angle == 0) then
    group_angle := 3;
  else if (group_angle == 1) then
    group_angle := 4;
  else if (group_angle == 2) then
    group_angle := 5;
  else if (group_angle == 3) then
    group_angle := 0;
  else if (group_angle == 4) then
    group_angle := 1;
  else if (group_angle == 5) then
    group_angle := 2;
  while (Tot_Critter_B) do
  begin
    Critter_direction := group_angle + (random(0, 2) - 1);
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    if (group_angle == 0) then
      Critter_direction := 3;
    else if (group_angle == 1) then
      Critter_direction := 4;
    else if (group_angle == 2) then
      Critter_direction := 5;
    else if (group_angle == 3) then
      Critter_direction := 0;
    else if (group_angle == 4) then
      Critter_direction := 1;
    else if (group_angle == 5) then
      Critter_direction := 2;
    if (random(0, 2) == 0) then
    begin
      Critter_direction := Critter_direction + (random(0, 2) - 1);
      while (Critter_direction < 0) do
        Critter_direction := Critter_direction + 6;
      if (Critter_direction > 5) then
        Critter_direction := Critter_direction % 6;
    end
    anim(Critter, 1000, Critter_direction);
    if (random(0, 1)) then
      Item := create_object_sid(4, 0, 0, -1);
    else
      Item := create_object_sid(7, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    if (random(0, 2) == 0) then
      Item := item_caps_adjust(Critter, random(4, 25) * ((2 * has_trait(0, dude_obj, 20)) + 1));
    Tot_Critter_B := Tot_Critter_B - 1;
  end
  attack_setup(Critter, victim);
  set_global_var(GVAR_WATER_THIEF_1, 2);
  call stranger;
end

procedure Bone3
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 309));
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 2;
  Tot_Critter_A := random(3, 7);
  group_angle := random(0, 5);
  Critter_type := 16777419;
  Critter_script := 749;
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle + random(0, 2 * 2) - 2;
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    if (random(0, 1)) then
      Item := create_object_sid(8, 0, 0, -1);
    else
      Item := create_object_sid(10, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    if (random(0, 2) == 0) then
      Item := item_caps_adjust(Critter, random(4, 25) * ((2 * has_trait(0, dude_obj, 20)) + 1));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  Critter_type := 16777254;
  Critter_script := 749;
  Critter_direction := group_angle + random(0, 2 * 2) - 2;
  while (Critter_direction < 0) do
    Critter_direction := Critter_direction + 6;
  if (Critter_direction > 5) then
    Critter_direction := Critter_direction % 6;
  call Place_critter;
  anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
  Item := create_object_sid(1, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Item := create_object_sid(47, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Item := item_caps_adjust(Critter, random(25, 100) * ((2 * has_trait(0, dude_obj, 20)) + 1));
  if (random(0, 1)) then
  begin
    Item := create_object_sid(38, 0, 0, -1);
    add_mult_objs_to_inven(Critter, Item, has_trait(0, dude_obj, 40) + 1);
  end
  if (random(0, 1)) then
  begin
    Item := create_object_sid(6, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
  end
  if (random(0, 1)) then
  begin
    Item := create_object_sid(31, 0, 0, -1);
    add_mult_objs_to_inven(Critter, Item, has_trait(0, dude_obj, 40) + 1);
  end
  if (random(0, 1)) then
  begin
    Item := create_object_sid(4, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
  end
  set_global_var(GVAR_WATER_THIEF_1, 1);
  call stranger;
end

procedure Bone4
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 310));
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 2;
  Tot_Critter_A := random(2, 5);
  group_angle := random(0, 5);
  Critter_type := 16777419;
  Critter_script := 749;
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle + random(0, 2 * 2) - 2;
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    if (random(0, 1)) then
      Item := create_object_sid(8, 0, 0, -1);
    else
      Item := create_object_sid(10, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    if (random(0, 2) == 0) then
      Item := item_caps_adjust(Critter, random(4, 25) * ((2 * has_trait(0, dude_obj, 20)) + 1));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  Critter_type := 16777254;
  Critter_script := 749;
  Critter_direction := group_angle + random(0, 2 * 2) - 2;
  while (Critter_direction < 0) do
    Critter_direction := Critter_direction + 6;
  if (Critter_direction > 5) then
    Critter_direction := Critter_direction % 6;
  call Place_critter;
  anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
  Item := create_object_sid(47, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Item := item_caps_adjust(Critter, random(25, 100) * ((2 * has_trait(0, dude_obj, 20)) + 1));
  if (random(0, 1)) then
  begin
    Item := create_object_sid(38, 0, 0, -1);
    add_mult_objs_to_inven(Critter, Item, has_trait(0, dude_obj, 40) + 1);
  end
  if (random(0, 1)) then
  begin
    Item := create_object_sid(6, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
  end
  if (random(0, 1)) then
  begin
    Item := create_object_sid(31, 0, 0, -1);
    add_mult_objs_to_inven(Critter, Item, has_trait(0, dude_obj, 40) + 1);
  end
  if (random(0, 1)) then
  begin
    Item := create_object_sid(4, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
  end
  set_global_var(GVAR_WATER_THIEF_1, 1);
  call stranger;
end

procedure Bone5
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 311));
  Outer_ring := (get_critter_stat(dude_obj, 1) / 2) + 6;
  Inner_ring := (get_critter_stat(dude_obj, 1) / 2) + 2;
  Tot_Critter_A := random(1, 3);
  group_angle := random(0, 5);
  Critter_type := 16777419;
  Critter_script := 749;
  while (Tot_Critter_A) do
  begin
    Critter_direction := group_angle + random(0, 2 * 2) - 2;
    while (Critter_direction < 0) do
      Critter_direction := Critter_direction + 6;
    if (Critter_direction > 5) then
      Critter_direction := Critter_direction % 6;
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    if (random(0, 1)) then
      Item := create_object_sid(8, 0, 0, -1);
    else
      Item := create_object_sid(10, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
    if (random(0, 2) == 0) then
      Item := item_caps_adjust(Critter, random(4, 25) * ((2 * has_trait(0, dude_obj, 20)) + 1));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  Critter_type := 16777254;
  Critter_script := 749;
  Critter_direction := group_angle + random(0, 2 * 2) - 2;
  while (Critter_direction < 0) do
    Critter_direction := Critter_direction + 6;
  if (Critter_direction > 5) then
    Critter_direction := Critter_direction % 6;
  call Place_critter;
  anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
  Item := create_object_sid(1, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Item := create_object_sid(47, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Item := item_caps_adjust(Critter, random(25, 100) * ((2 * has_trait(0, dude_obj, 20)) + 1));
  if (random(0, 1)) then
  begin
    Item := create_object_sid(38, 0, 0, -1);
    add_mult_objs_to_inven(Critter, Item, has_trait(0, dude_obj, 40) + 1);
  end
  if (random(0, 1)) then
  begin
    Item := create_object_sid(6, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
  end
  if (random(0, 1)) then
  begin
    Item := create_object_sid(31, 0, 0, -1);
    add_mult_objs_to_inven(Critter, Item, has_trait(0, dude_obj, 40) + 1);
  end
  if (random(0, 1)) then
  begin
    Item := create_object_sid(4, 0, 0, -1);
    add_obj_to_inven(Critter, Item);
  end
  set_global_var(GVAR_WATER_THIEF_1, 2);
  call stranger;
end

procedure Bone6
begin
  display_msg(message_str(SCRIPT_RNDDESRT, 313));
  Tot_Critter_A := random(4, 6);
  if ((game_time_hour >= 700) and (game_time_hour < 1800)) then
  begin
    Outer_ring := 6;
    Inner_ring := 3;
  end
  else
  begin
    Outer_ring := 4;
    Inner_ring := 3;
  end
  Critter_type := 16777284;
  Critter_script := 735;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(0, 5);
    call Place_critter;
    anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
    Tot_Critter_A := Tot_Critter_A - 1;
  end
  set_global_var(GVAR_WATER_THIEF_1, 1);
  call stranger;
end

procedure Scenes
begin
  variable LVar1 := 0;
  variable LVar2 := 0;
  variable LVar3 := 0;
  variable LVar4 := 0;
  variable LVar5 := 0;

  Tot_Critter_A := random(3, 14);
  LVar5 := -1;
  while (Tot_Critter_A) do
  begin
    Critter_direction := random(0, 5);
    Range := random(4, 28);
    Place_Holder := Range;
    LVar1 := tile_num_in_direction(Dude_tile, Critter_direction, Place_Holder);
    Critter_direction := random(0, 5);
    LVar1 := tile_num_in_direction(Dude_tile, Critter_direction, Place_Holder);
    LVar1 := LVar1 + (random(0, 2) - 1);
    Critter_direction := random(0, 5);
    LVar1 := tile_num_in_direction(Dude_tile, Critter_direction, Place_Holder);
    LVar1 := LVar1 + (random(0, 2) - 1);
    Critter_direction := random(0, 5);
    LVar1 := tile_num_in_direction(Dude_tile, Critter_direction, Place_Holder);
    LVar3 := random(0, 9);
    while (LVar5 == LVar3) do
      LVar3 := random(0, 9);
    debug_msg(message_str(SCRIPT_RNDDESRT, 304) + LVar3 + "");
    if (LVar3 == 0) then
    begin
      LVar4 := random(1, 6);
      if (LVar4 == 1) then
        Item := create_object_sid(33554517, 0, 0, -1);
      else if (LVar4 == 2) then
      begin
        if (random(1, 4) == 1) then
          Item := create_object_sid(33554749, 0, 0, -1);
        else
          Item := create_object_sid(33554496, 0, 0, -1);
      end
      else if (LVar4 == 3) then
        Item := create_object_sid(33554555, 0, 0, -1);
      else if (LVar4 == 4) then
        Item := create_object_sid(33554496, 0, 0, -1);
      else if (LVar4 == 5) then
        Item := create_object_sid(33554497, 0, 0, -1);
      else if (random(1, 3) == 1) then
        Item := create_object_sid(33554498, 0, 0, -1);
      else
        Item := create_object_sid(33554744, 0, 0, -1);
    end
    else if (LVar3 == 1) then
    begin
      LVar4 := random(1, 3);
      if (LVar4 == 1) then
        Item := create_object_sid(33554712, 0, 0, -1);
      else if (LVar4 == 2) then
        Item := create_object_sid(33554711, 0, 0, -1);
      else
        Item := create_object_sid(33554710, 0, 0, -1);
    end
    else if (LVar3 == 2) then
    begin
      LVar4 := random(1, 5);
      if (LVar4 == 1) then
        Item := create_object_sid(33554514, 0, 0, -1);
      else if (LVar4 == 2) then
        Item := create_object_sid(33554515, 0, 0, -1);
      else if (LVar4 == 3) then
        Item := create_object_sid(33554516, 0, 0, -1);
      else if (LVar4 == 4) then
        Item := create_object_sid(33554517, 0, 0, -1);
      else
        Item := create_object_sid(33554518, 0, 0, -1);
    end
    else if (LVar3 == 3) then
      Item := create_object_sid(33554533, 0, 0, -1);
    else if (LVar3 == 4) then
    begin
      LVar4 := random(1, 4);
      if (LVar4 == 1) then
        Item := create_object_sid(33554524, 0, 0, -1);
      else if (LVar4 == 2) then
        Item := create_object_sid(33554525, 0, 0, -1);
      else if (LVar4 == 3) then
        Item := create_object_sid(33554524, 0, 0, -1);
      else
        Item := create_object_sid(33554525, 0, 0, -1);
    end
    else if (LVar3 == 5) then
    begin
      LVar4 := random(1, 4);
      if (LVar4 == 1) then
        Item := create_object_sid(33554534, 0, 0, -1);
      else if (LVar4 == 2) then
        Item := create_object_sid(33554535, 0, 0, -1);
      else if (LVar4 == 3) then
        Item := create_object_sid(33554536, 0, 0, -1);
      else
        Item := create_object_sid(33554534, 0, 0, -1);
    end
    else if (LVar3 == 6) then
    begin
      LVar4 := random(1, 3);
      if (LVar4 == 1) then
        Item := create_object_sid(33554541, 0, 0, -1);
      else if (LVar4 == 2) then
        Item := create_object_sid(33554542, 0, 0, -1);
      else
        Item := create_object_sid(33554540, 0, 0, -1);
    end
    else if (LVar3 == 7) then
    begin
      LVar4 := random(1, 4);
      if (LVar4 == 1) then
        Item := create_object_sid(33554555, 0, 0, -1);
      else if (LVar4 == 2) then
        Item := create_object_sid(33554553, 0, 0, -1);
      else if (LVar4 == 3) then
        Item := create_object_sid(33554556, 0, 0, -1);
      else
        Item := create_object_sid(33554554, 0, 0, -1);
    end
    else if (LVar3 == 8) then
    begin
      LVar4 := random(1, 3);
      if (LVar4 == 1) then
        Item := create_object_sid(33554712, 0, 0, -1);
      else if (LVar4 == 2) then
        Item := create_object_sid(33554711, 0, 0, -1);
      else
        Item := create_object_sid(33554710, 0, 0, -1);
    end
    else
    begin
      LVar4 := random(1, 6);
      if (LVar4 == 1) then
        Item := create_object_sid(33554517, 0, 0, -1);
      else if (LVar4 == 2) then
      begin
        if (random(1, 3) == 1) then
          Item := create_object_sid(33554749, 0, 0, -1);
        else
          Item := create_object_sid(33554496, 0, 0, -1);
      end
      else if (LVar4 == 3) then
        Item := create_object_sid(33554555, 0, 0, -1);
      else if (LVar4 == 4) then
        Item := create_object_sid(33554496, 0, 0, -1);
      else if (LVar4 == 5) then
        Item := create_object_sid(33554497, 0, 0, -1);
      else if (random(1, 3) == 1) then
        Item := create_object_sid(33554498, 0, 0, -1);
      else
        Item := create_object_sid(random(0, 2) + 33554710, 0, 0, -1);
    end
    LVar5 := LVar3;
    critter_attempt_placement(Item, LVar1, 0);
    Tot_Critter_A := Tot_Critter_A - 1;
  end
end

procedure Place_critter
begin
  variable LVar1 := 0;
  variable LVar2 := 0;

  Critter := create_object_sid(Critter_type, 0, 0, Critter_script);
  Range := random(Inner_ring, Outer_ring);
  LVar1 := random(0, 5);
  Critter_tile := tile_num_in_direction(Dude_tile, Critter_direction, Range);
  LVar2 := tile_num_in_direction(Critter_tile, LVar1, Range / 2);
  if ((tile_distance(Dude_tile, LVar2) <= Outer_ring) and (tile_distance(Dude_tile, LVar2) >= Inner_ring)) then
    Critter_tile := tile_num_in_direction(Critter_tile, LVar1, Range / 2);
  critter_attempt_placement(Critter, Critter_tile, 0);
end

procedure hunters
begin
  Inner_ring := 8;
  Outer_ring := 5;
  group_angle := random(0, 5);
  Critter_direction := group_angle + random(0, 3 * 2) - 3;
  while (Critter_direction < 0) do
    Critter_direction := Critter_direction + 6;
  if (Critter_direction > 5) then
    Critter_direction := Critter_direction % 6;
  Critter_type := 16777349;
  Critter_script := 241;
  call Place_critter;
  anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
  Item := create_object_sid(23, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Item := create_object_sid(36, 0, 0, -1);
  add_mult_objs_to_inven(Critter, Item, 4 * (has_trait(0, dude_obj, 40) + 1));
  Item := create_object_sid(17, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Item := item_caps_adjust(Critter, random(5, 30) * ((2 * has_trait(0, dude_obj, 20)) + 1));
  Item := create_object_sid(144, 0, 0, -1);
  add_mult_objs_to_inven(Critter, Item, 2);
  Critter_direction := group_angle + random(0, 3 * 2) - 3;
  while (Critter_direction < 0) do
    Critter_direction := Critter_direction + 6;
  if (Critter_direction > 5) then
    Critter_direction := Critter_direction % 6;
  Critter_type := 16777467;
  Critter_script := 383;
  call Place_critter;
  anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
  Item := create_object_sid(7, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Item := create_object_sid(2, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  if (random(0, 2) == 0) then
    Item := item_caps_adjust(Critter, random(5, 30) * ((2 * has_trait(0, dude_obj, 20)) + 1));
  Critter_direction := group_angle + random(0, 3 * 2) - 3;
  while (Critter_direction < 0) do
    Critter_direction := Critter_direction + 6;
  if (Critter_direction > 5) then
    Critter_direction := Critter_direction % 6;
  Critter_type := 16777472;
  Critter_script := 383;
  call Place_critter;
  anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
  Item := create_object_sid(143, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Item := create_object_sid(34, 0, 0, -1);
  add_mult_objs_to_inven(Critter, Item, 3 * (has_trait(0, dude_obj, 40) + 1));
  Item := create_object_sid(2, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Item := create_object_sid(14, 0, 0, -1);
  add_mult_objs_to_inven(Critter, Item, 2 * (has_trait(0, dude_obj, 40) + 1));
  if (random(0, 2) == 0) then
    Item := item_caps_adjust(Critter, random(5, 40) * ((2 * has_trait(0, dude_obj, 20)) + 1));
  Critter_direction := group_angle + random(0, 3 * 2) - 3;
  while (Critter_direction < 0) do
    Critter_direction := Critter_direction + 6;
  if (Critter_direction > 5) then
    Critter_direction := Critter_direction % 6;
  Critter_type := 16777462;
  Critter_script := 383;
  call Place_critter;
  anim(Critter, 1000, rotation_to_tile(tile_num(Critter), tile_num(dude_obj)));
  Item := create_object_sid(18, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  Item := create_object_sid(31, 0, 0, -1);
  add_mult_objs_to_inven(Critter, Item, 2 * (has_trait(0, dude_obj, 40) + 1));
  Item := create_object_sid(2, 0, 0, -1);
  add_obj_to_inven(Critter, Item);
  if (random(0, 2) == 0) then
    Item := item_caps_adjust(Critter, random(5, 30) * ((2 * has_trait(0, dude_obj, 20)) + 1));
  call stranger;
end

procedure add_party
begin
  variable LVar1 := 0;
  variable LVar2 := 0;

  party_elevation := elevation(dude_obj);
  if (global_var(GVAR_TANDI_STATUS) == 5) then
  begin
    if (Tandi_ptr == 0) then
    begin
    end
    critter_add_trait(Tandi_ptr, 1, 6, 0);
  end
end

procedure update_party
begin
  variable LVar1 := 0;
  variable LVar2 := 0;

  if (elevation(dude_obj) != party_elevation) then
  begin
    party_elevation := elevation(dude_obj);
    if (global_var(GVAR_IAN_STATUS) == 2) then
    begin
      if (Ian_ptr == 0) then
      begin
      end
      else
        move_to(Ian_ptr, tile_num_in_direction(tile_num(dude_obj), 1, 2), elevation(dude_obj));
    end
    if (global_var(GVAR_DOG_EMPATHY)) then
    begin
      if (Dog_ptr == 0) then
      begin
      end
      else
        move_to(Dog_ptr, tile_num_in_direction(tile_num(dude_obj), 2, 1), elevation(dude_obj));
    end
    if (global_var(GVAR_HERNANDEZ_STATUS) == 2) then
    begin
      if (Tycho_ptr == 0) then
      begin
      end
      else
        move_to(Tycho_ptr, tile_num_in_direction(tile_num(dude_obj), 3, 2), elevation(dude_obj));
    end
    if (global_var(GVAR_KATJA_STATUS) == 2) then
    begin
      if (Katja_ptr == 0) then
      begin
      end
      else
        move_to(Katja_ptr, tile_num_in_direction(tile_num(dude_obj), 4, 2), elevation(dude_obj));
    end
    if (global_var(GVAR_TANDI_STATUS) == 5) then
    begin
      if (Tandi_ptr == 0) then
      begin
      end
      else
        move_to(Tandi_ptr, tile_num_in_direction(tile_num(dude_obj), 4, 4), elevation(dude_obj));
    end
  end
end

procedure remove_party
begin
  if (global_var(GVAR_IAN_STATUS) == 2) then
    set_global_var(GVAR_IAN_STATUS, 2);
  if (global_var(GVAR_DOG_EMPATHY)) then
    set_global_var(GVAR_DOG_EMPATHY, 1);
  if (global_var(GVAR_HERNANDEZ_STATUS) == 2) then
    set_global_var(GVAR_HERNANDEZ_STATUS, 2);
  if (global_var(GVAR_KATJA_STATUS) == 2) then
    set_global_var(GVAR_KATJA_STATUS, 2);
  if (global_var(GVAR_TANDI_STATUS) == 5) then
  begin
  end
end

procedure Darkness
begin
  set_light_level(40);
end

procedure Invasion
begin
  if (not(global_var(GVAR_MASTER_BLOWN) == 2)) then
  begin
    if (global_var(GVAR_NECROPOLIS_INVADED_DATE) > (game_time / (10 * 60 * 60 * 24))) then
      set_global_var(GVAR_NECROPOLIS_INVADED, 1);
    if (global_var(GVAR_THE_HUB_INVADED_DATE) > (game_time / (10 * 60 * 60 * 24))) then
      set_global_var(GVAR_HUB_INVADED, 1);
    if (global_var(GVAR_BROTHERHOOD_INVADED_DATE) > (game_time / (10 * 60 * 60 * 24))) then
      set_global_var(GVAR_BROTHERHOOD_INVADED, 1);
    if (global_var(GVAR_JUNKTOWN_INVADED_DATE) > (game_time / (10 * 60 * 60 * 24))) then
      set_global_var(GVAR_JUNKTOWN_INVADED, 1);
    if (global_var(GVAR_SHADY_SANDS_INVADED_DATE) > (game_time / (10 * 60 * 60 * 24))) then
      set_global_var(GVAR_SHADY_SANDS_INVADED, 1);
    if (global_var(GVAR_VAULT_13_INVADED_DATE) <= 0) then
      set_global_var(GVAR_VAULT_INVADED, 1);
    if (global_var(GVAR_FOLLOWERS_INVADED_DATE) > (game_time / (10 * 60 * 60 * 24))) then
      set_global_var(GVAR_FOLLOWERS_INVADED, 1);
  end
end