#include <define.h>

//#define NAME                    SCRIPT_

#include <command.h>
//#include <ModReact.h>



procedure start;
#include <push.h>
procedure do_dialogue;
procedure setend;
procedure setcbt;
procedure settime;
procedure set00;
procedure set00_2;
procedure set01;
procedure set01a;
procedure set02;
procedure set03;
procedure set05;
procedure set06;
procedure set07;
procedure set08;
procedure set09_2;
procedure set09;
procedure set10;
procedure set10a;
procedure set11;
procedure set12;
procedure set12_2;
procedure set13;
procedure set13_2;
procedure set14;
procedure set15;
procedure set16;
procedure set17;
procedure set17_2;
procedure set18;
procedure set19_2;
procedure set19;
procedure set20;
procedure set21;
procedure set21a;
procedure set22;
procedure set23;
procedure set24;
procedure set25;
procedure set25_2;
procedure set26;
procedure set27;
procedure set28;
procedure set29;
procedure set30;
procedure set31;
procedure set32;
procedure set33;
procedure set34;
procedure set34_2;
procedure set35;
procedure set36;
procedure set38;
procedure set39;
procedure set40;
procedure set40_2;
procedure set41;
procedure set42;
procedure set43;
procedure set44;
procedure set42_2;
procedure set45;
procedure set45a;
procedure set46;
procedure set47;
procedure set48;
procedure set49;
procedure set50;
procedure set51;
procedure set52;
procedure set52a;
procedure set53;
procedure set54;
procedure set55;
procedure set56;
procedure set57;
procedure set57_2;
procedure set58;
procedure set59;
procedure set60;
procedure set61;
procedure set62;
procedure set63;
procedure set64;
procedure set65;
procedure set00a;
procedure set00b;
procedure set02a;
procedure set04;
procedure set09a;
procedure set18a;
procedure set200;
procedure set201;
procedure set202;
procedure set203;
procedure set204;
procedure set205;
procedure set206;
procedure set207;
procedure set208;
procedure set209;
procedure set300;
procedure set301;
procedure set302;
procedure set303;
procedure set304;
procedure set305;
procedure set306;
procedure set307;
procedure set308;
procedure set309;
procedure set310;
procedure set311;
procedure pickup_p_proc;
procedure travel;

variable Hostile;
variable initialized1;
variable chip;
variable setgone;

procedure Get_Reaction;
procedure React_To_Level;
procedure Level_To_React;
procedure Up_React;
procedure Down_React;
procedure Bottom_React;
procedure Top_React;
procedure Big_Up_React;
procedure Big_Down_React;
procedure Up_React_Level;
procedure Down_React_Level;
procedure Goodbyes;

variable exit_line;


procedure start
begin
if (not(initialized1)) then begin
    critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_TEAM_NUM, 30);
    critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_AI_PACKET, AI_GHOUL_NASTY);
    initialized1 := 1;
  end
  else begin
    if (script_action == timed_event_proc) then begin
      if (fixed_param == 1) then begin
        set_local_var(9, 1);
      end
    end
    else begin
      if (script_action == damage_proc) then begin
        Hostile := 1;
      end
      else begin
        if (script_action == talk_proc) then begin
          call do_dialogue;
        end
        else begin
          if (script_action == pickup_proc) then begin
            call pickup_p_proc;
          end
          else begin
            if (script_action == critter_proc) then begin
              if (global_var(GVAR_ENEMY_NECROPOLIS) and obj_can_see_obj(self_obj, dude_obj)) then begin
                if (local_var(6) == 0) then begin
                  dialogue_system_enter;
                end
              end
              if (Hostile) then begin
                Hostile := 0;
                set_global_var(GVAR_ENEMY_NECROPOLIS, 1);
                attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
              end
              else begin
                if (local_var(4) == 0) then begin
                  if (obj_can_see_obj(self_obj, dude_obj) and (tile_distance_objs(self_obj, dude_obj) < 6)) then begin
                    dialogue_system_enter;
                  end
                end
                else begin
                  if ((global_var(GVAR_NECROP_WATER_CHIP_TAKEN) == 1) and (global_var(GVAR_NECROP_WATER_PUMP_FIXED) != 2)) then begin
                    if (obj_can_see_obj(self_obj, dude_obj) and (tile_distance_objs(self_obj, dude_obj) < 6)) then begin
                      dialogue_system_enter;
                    end
                  end
                end
              end
            end
            else begin
              if ((script_action == look_at_proc) or (script_action == description_proc)) then begin
                script_overrides;
                display_msg(message_str(SCRIPT_SET, 100));
              end
              else begin
                if (script_action == destroy_proc) then begin
                  set_global_var(GVAR_SET_DEAD, 1);
                  if (source_obj == dude_obj) then begin
                    if (((global_var(GVAR_BAD_MONSTER) + global_var(GVAR_GOOD_MONSTER)) >= 25) and ((global_var(GVAR_GOOD_MONSTER) > (2 * global_var(GVAR_BAD_MONSTER))) or (global_var(GVAR_BERSERKER_REPUTATION) == 1))) then begin
                      set_global_var(GVAR_BERSERKER_REPUTATION, 1);
                      set_global_var(GVAR_CHAMPION_REPUTATION, 0);
                    end
                    if (((global_var(GVAR_BAD_MONSTER) + global_var(GVAR_GOOD_MONSTER)) >= 25) and ((global_var(GVAR_BAD_MONSTER) > (3 * global_var(GVAR_GOOD_MONSTER))) or (global_var(GVAR_CHAMPION_REPUTATION) == 1))) then begin
                      set_global_var(GVAR_CHAMPION_REPUTATION, 1);
                      set_global_var(GVAR_BERSERKER_REPUTATION, 0);
                    end
                    set_global_var(GVAR_BAD_MONSTER, global_var(GVAR_BAD_MONSTER) + 1);
                    if ((global_var(GVAR_BAD_MONSTER) % 6) == 0) then begin
                      set_global_var(GVAR_PLAYER_REPUTATION, global_var(GVAR_PLAYER_REPUTATION) + 1);
                    end
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end

procedure do_dialogue
begin
  call Get_Reaction;
  start_gdialog(SCRIPT_SET, self_obj, 4, HEAD_SET, BACKGROUND_NECROPOLIS);
  gsay_start;
  if (global_var(GVAR_ENEMY_NECROPOLIS)) then begin
    Hostile := 1;
  end
  if (Hostile) then begin
    call set49;
  end
  else begin
    if (local_var(4)) then begin
      if ((global_var(GVAR_NECROP_WATER_CHIP_TAKEN) == 1) and (global_var(GVAR_NECROP_WATER_PUMP_FIXED) != 2)) then begin
        call set57;
      end
      else begin
        if (global_var(GVAR_MASTER_BLOWN) and (local_var(7) == 0)) then begin
          call set52;
        end
        else begin
          if ((game_time_hour >= 700) and (game_time_hour < 1800)) then begin
            call set207;
          end
          else begin
            if (global_var(GVAR_NECROP_MUTANTS_KILLED) >= 1) then begin
              if (local_var(5) == 1) then begin
                call set50;
              end
              if (global_var(GVAR_SIGNAL_REWARD) bwand 1) then begin
                call set42;
              end
              else begin
                if (global_var(GVAR_PLAYER_CAPTURED) == 1) then begin
                  call set29;
                end
                else begin
                  if ((global_var(GVAR_NECROP_MUTANTS_KILLED) == 2) or (global_var(GVAR_DESTROY_MASTER_2) != 0)) then begin
                    call set18;
                  end
                  else begin
                    if (local_var(9)) then begin
                      call set25;
                    end
                    else begin
                      call set51;
                    end
                  end
                end
              end
            end
            else begin
              call set51;
            end
          end
        end
      end
    end
    else begin
      add_timer_event(self_obj, game_ticks(600), 1);
      set_local_var(4, 1);
      if ((global_var(GVAR_NECROP_WATER_CHIP_TAKEN) == 1) and (global_var(GVAR_NECROP_WATER_PUMP_FIXED) != 2)) then begin
        call set57;
      end
      else begin
        if (global_var(GVAR_MASTER_BLOWN) and (local_var(7) == 0)) then begin
          call set52;
        end
        else begin
          if ((global_var(GVAR_NECROP_MUTANTS_KILLED) == 2) or (global_var(GVAR_DESTROY_MASTER_2) != 0)) then begin
            call set30;
          end
          else begin
            if (global_var(GVAR_VATS_BLOWN) != 2) then begin
              if (global_var(GVAR_PLAYER_CAPTURED) == 1) then begin
                call set16;
              end
              else begin
                call set00;
              end
            end
          end
        end
      end
    end
  end
  gsay_end;
  end_dialogue;
end

procedure setend
begin
end

procedure setcbt
begin
  Hostile := 1;
end

procedure settime
begin
  call setcbt;
end

procedure set00
begin
  gsay_reply(SCRIPT_SET, 101);
  giq_option(5, SCRIPT_SET, 102, set00_2, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 103, set00a, BAD_REACTION);
  giq_option(4, SCRIPT_SET, 104, set00b, BAD_REACTION);
  giq_option(-3, SCRIPT_SET, 105, set05, NEUTRAL_REACTION);
end

procedure set00_2
begin
  if (is_success(roll_vs_skill(dude_obj, 14, -10))) then begin
    call Up_React;
    call set01;
  end
  else begin
    call Big_Down_React;
    call set02;
  end
end

procedure set01
begin
  gsay_reply(SCRIPT_SET, 106);
  giq_option(7, SCRIPT_SET, 107, set09, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 108, set01a, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 109, set14, NEUTRAL_REACTION);
end

procedure set01a
begin
  gsay_reply(SCRIPT_SET, 110);
  giq_option(0, SCRIPT_SET, 111, set12, NEUTRAL_REACTION);
end

procedure set02
begin
  gsay_reply(SCRIPT_SET, 112);
  giq_option(5, SCRIPT_SET, 113, set03, BAD_REACTION);
  giq_option(5, SCRIPT_SET, 114, set02a, GOOD_REACTION);
  giq_option(0, SCRIPT_SET, 115, set01, NEUTRAL_REACTION);
end

procedure set03
begin
  gsay_message(SCRIPT_SET, 116, BAD_REACTION);
  call setcbt;
end

procedure set05
begin
  gsay_reply(SCRIPT_SET, 121);
  giq_option(-3, SCRIPT_SET, 122, set06, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_SET, 123, set08, NEUTRAL_REACTION);
end

procedure set06
begin
  set_global_var(GVAR_NECROP_MUTANTS_KILLED, 1);
  gsay_reply(SCRIPT_SET, 124);
  giq_option(4, SCRIPT_SET, 125, setend, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 126, set07, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_SET, 127, setend, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_SET, 128, set07, NEUTRAL_REACTION);
end

procedure set07
begin
  gsay_message(SCRIPT_SET, 129, NEUTRAL_REACTION);
  call setend;
end

procedure set08
begin
  gsay_message(SCRIPT_SET, 130, NEUTRAL_REACTION);
  call settime;
end

procedure set09_2
begin
  if (is_success(roll_vs_skill(dude_obj, 14, -10))) then begin
    call set10;
  end
  else begin
    if (dude_is_male) then begin
      call set03;
    end
    else begin
      call set04;
    end
  end
end

procedure set09
begin
  gsay_reply(SCRIPT_SET, 131);
  giq_option(6, SCRIPT_SET, 132, set09_2, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 133, set09a, BAD_REACTION);
  giq_option(5, SCRIPT_SET, 134, set15, NEUTRAL_REACTION);
end

procedure set10
begin
  gsay_reply(SCRIPT_SET, 135);
  giq_option(6, SCRIPT_SET, 136, set10a, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 137, setcbt, BAD_REACTION);
end

procedure set10a
begin
  gsay_reply(SCRIPT_SET, 138);
  giq_option(6, SCRIPT_SET, 139, set11, NEUTRAL_REACTION);
end

procedure set11
begin
  gsay_reply(SCRIPT_SET, 140);
  giq_option(5, SCRIPT_SET, 141, set12, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 142, set08, NEUTRAL_REACTION);
end

procedure set12
begin
  gsay_reply(SCRIPT_SET, 143);
  giq_option(4, SCRIPT_SET, 144, set06, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 145, set12_2, BAD_REACTION);
end

procedure set12_2
begin
  if (is_success(roll_vs_skill(dude_obj, 14, 0))) then begin
    call set08;
  end
  else begin
    call set03;
  end
end

procedure set13
begin
  gsay_reply(SCRIPT_SET, 146);
  giq_option(4, SCRIPT_SET, 147, set06, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 148, set13_2, BAD_REACTION);
end

procedure set13_2
begin
  if (is_success(roll_vs_skill(dude_obj, 14, -20))) then begin
    call set08;
  end
  else begin
    call set03;
  end
end

procedure set14
begin
  gsay_reply(SCRIPT_SET, 149);
  giq_option(4, SCRIPT_SET, 150, set12, NEUTRAL_REACTION);
  giq_option(5, SCRIPT_SET, 151, set15, NEUTRAL_REACTION);
end

procedure set15
begin
  gsay_reply(SCRIPT_SET, 152);
  giq_option(4, SCRIPT_SET, 153, set12, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 154, set12_2, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 155, set09a, BAD_REACTION);
end

procedure set16
begin
  gsay_reply(SCRIPT_SET, 156);
  giq_option(4, SCRIPT_SET, 157, set17, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 158, set03, BAD_REACTION);
  giq_option(-3, SCRIPT_SET, 159, set17, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_SET, 160, set03, BAD_REACTION);
end

procedure set17
begin
  gsay_reply(SCRIPT_SET, 161);
  giq_option(7, SCRIPT_SET, 162, set17_2, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 163, set06, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 164, set03, BAD_REACTION);
  giq_option(-3, SCRIPT_SET, 159, set06, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_SET, 160, set03, BAD_REACTION);
end

procedure set17_2
begin
  if (is_success(roll_vs_skill(dude_obj, 14, -10))) then begin
    call set09;
  end
  else begin
    call set03;
  end
end

procedure set18
begin
  set_global_var(GVAR_SIGNAL_REWARD, global_var(GVAR_SIGNAL_REWARD) bwor 1);
  gsay_reply(SCRIPT_SET, 165);
  giq_option(4, SCRIPT_SET, 166, setend, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 167, set18a, BAD_REACTION);
  giq_option(-3, SCRIPT_SET, 168, setend, NEUTRAL_REACTION);
end

procedure set19_2
begin
  if (is_success(roll_vs_skill(dude_obj, 14, 0))) then begin
    call set20;
  end
  else begin
    call set23;
  end
end

procedure set19
begin
  gsay_reply(SCRIPT_SET, 169);
  giq_option(5, SCRIPT_SET, 170, set19_2, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 171, setend, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 172, set24, NEUTRAL_REACTION);
end

procedure set20
begin
  gsay_reply(SCRIPT_SET, 173);
  giq_option(4, SCRIPT_SET, 174, set21, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 175, setend, NEUTRAL_REACTION);
end

procedure set21
begin
  gsay_reply(SCRIPT_SET, 176);
  giq_option(4, SCRIPT_SET, 177, set22, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 178, set21a, NEUTRAL_REACTION);
end

procedure set21a
begin
  gsay_message(SCRIPT_SET, 179, NEUTRAL_REACTION);
  call setend;
end

procedure set22
begin
  gsay_reply(SCRIPT_SET, 180);
  giq_option(5, SCRIPT_SET, 181, setend, NEUTRAL_REACTION);
end

procedure set23
begin
  gsay_reply(SCRIPT_SET, 182);
  giq_option(4, SCRIPT_SET, 183, setend, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 184, setcbt, BAD_REACTION);
end

procedure set24
begin
  gsay_reply(SCRIPT_SET, 185);
  giq_option(4, SCRIPT_SET, 186, setend, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 187, setcbt, BAD_REACTION);
end

procedure set25
begin
  gsay_reply(SCRIPT_SET, 188);
  giq_option(5, SCRIPT_SET, 189, set25_2, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 190, set28, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_SET, 191, set28, NEUTRAL_REACTION);
end

procedure set25_2
begin
  if (is_success(roll_vs_skill(dude_obj, 14, -20))) then begin
    call set26;
  end
  else begin
    call set27;
  end
end

procedure set26
begin
  set_local_var(5, 1);
  gsay_message(SCRIPT_SET, 192, NEUTRAL_REACTION);
  set_global_var(GVAR_SIGNAL_REWARD, global_var(GVAR_SIGNAL_REWARD) bwor 1);
  call setend;
end

procedure set27
begin
  gsay_message(SCRIPT_SET, 193, BAD_REACTION);
  call setcbt;
end

procedure set28
begin
  gsay_message(SCRIPT_SET, 194, NEUTRAL_REACTION);
  call setend;
end

procedure set29
begin
  gsay_message(SCRIPT_SET, 195, NEUTRAL_REACTION);
  call setcbt;
end

procedure set30
begin
  gsay_reply(SCRIPT_SET, 196);
  giq_option(5, SCRIPT_SET, 197, set31, NEUTRAL_REACTION);
  giq_option(5, SCRIPT_SET, 198, set34, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 199, set38, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 200, set40, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_SET, 201, set41, NEUTRAL_REACTION);
end

procedure set31
begin
  gsay_reply(SCRIPT_SET, 202);
  giq_option(5, SCRIPT_SET, 203, set32, NEUTRAL_REACTION);
  giq_option(5, SCRIPT_SET, 204, setcbt, BAD_REACTION);
end

procedure set32
begin
  gsay_reply(SCRIPT_SET, 205);
  giq_option(4, SCRIPT_SET, 206, setcbt, BAD_REACTION);
  giq_option(4, SCRIPT_SET, 207, set33, NEUTRAL_REACTION);
end

procedure set33
begin
  set_global_var(GVAR_SIGNAL_REWARD, global_var(GVAR_SIGNAL_REWARD) bwor 1);
  gsay_reply(SCRIPT_SET, 208);
  call setend;
end

procedure set34
begin
  gsay_reply(SCRIPT_SET, 209);
  giq_option(5, SCRIPT_SET, 210, set18, NEUTRAL_REACTION);
  giq_option(5, SCRIPT_SET, 211, set34_2, NEUTRAL_REACTION);
end

procedure set34_2
begin
  if (is_success(roll_vs_skill(dude_obj, 14, -10))) then begin
    call set35;
  end
  else begin
    call set36;
  end
end

procedure set35
begin
  gsay_message(SCRIPT_SET, 212, NEUTRAL_REACTION);
  call setend;
end

procedure set36
begin
  set_global_var(GVAR_SIGNAL_REWARD, global_var(GVAR_SIGNAL_REWARD) bwor 1);
  gsay_message(SCRIPT_SET, 213, NEUTRAL_REACTION);
  call setend;
end

procedure set38
begin
  gsay_reply(SCRIPT_SET, 214);
  giq_option(4, SCRIPT_SET, 215, set39, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 216, setend, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 217, setcbt, BAD_REACTION);
end

procedure set39
begin
  set_global_var(GVAR_SIGNAL_REWARD, global_var(GVAR_SIGNAL_REWARD) bwor 1);
  gsay_message(SCRIPT_SET, 218, NEUTRAL_REACTION);
  call setend;
end

procedure set40
begin
  gsay_reply(SCRIPT_SET, 219);
  giq_option(4, SCRIPT_SET, 220, set40_2, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 221, setcbt, BAD_REACTION);
end

procedure set40_2
begin
  if (is_success(roll_vs_skill(dude_obj, 14, -10))) then begin
    call set34;
  end
  else begin
    call set48;
  end
end

procedure set41
begin
  gsay_reply(SCRIPT_SET, 222);
  giq_option(-3, SCRIPT_SET, 223, set08, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_SET, 224, setcbt, BAD_REACTION);
end

procedure set42
begin
  gsay_reply(SCRIPT_SET, 225);
  giq_option(4, SCRIPT_SET, 226, set42_2, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 227, setcbt, BAD_REACTION);
  giq_option(4, SCRIPT_SET, 228, setend, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_SET, 229, setend, NEUTRAL_REACTION);
end

procedure set43
begin
  gsay_reply(SCRIPT_SET, 230);
  giq_option(7, SCRIPT_SET, 231, set44, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 232, set47, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 233, set48, BAD_REACTION);
end

procedure set44
begin
  gsay_reply(SCRIPT_SET, 234);
  if (is_success(do_check(dude_obj, 4, 0))) then begin
    giq_option(13, SCRIPT_SET, 235, set46, NEUTRAL_REACTION);
  end
  giq_option(4, SCRIPT_SET, 236, setend, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 237, set45, NEUTRAL_REACTION);
end

procedure set42_2
begin
  if (is_success(roll_vs_skill(dude_obj, 14, -10))) then begin
    call set43;
  end
  else begin
    call set48;
  end
end

procedure set45
begin
  gsay_reply(SCRIPT_SET, 238);
  giq_option(4, SCRIPT_SET, 239, setcbt, BAD_REACTION);
  giq_option(4, SCRIPT_SET, 240, setend, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 241, set45a, BAD_REACTION);
end

procedure set45a
begin
  gsay_message(SCRIPT_SET, 242, BAD_REACTION);
  call setcbt;
end

procedure set46
begin
  gsay_reply(SCRIPT_SET, 243);
  giq_option(4, SCRIPT_SET, 244, setend, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 245, setcbt, BAD_REACTION);
end

procedure set47
begin
  gsay_message(SCRIPT_SET, 246, NEUTRAL_REACTION);
  call setend;
end

procedure set48
begin
  gsay_message(SCRIPT_SET, 247, BAD_REACTION);
  call setcbt;
end

procedure set49
begin
  if (local_var(6) != 1) then begin
    set_local_var(6, 1);
    gsay_message(SCRIPT_SET, 248, BAD_REACTION);
  end
  call setcbt;
end

procedure set50
begin
  set_local_var(5, 2);
  gsay_reply(SCRIPT_SET, 249);
  giq_option(5, SCRIPT_SET, 250, setend, NEUTRAL_REACTION);
  giq_option(5, SCRIPT_SET, 251, setcbt, BAD_REACTION);
end

procedure set51
begin
  gsay_message(SCRIPT_SET, 252, NEUTRAL_REACTION);
  call setend;
end

procedure set52
begin
  set_local_var(7, 1);
  gsay_reply(SCRIPT_SET, 253);
  giq_option(4, SCRIPT_SET, 254, set53, GOOD_REACTION);
  giq_option(4, SCRIPT_SET, 255, set03, BAD_REACTION);
  giq_option(-3, SCRIPT_SET, 256, set52a, GOOD_REACTION);
end

procedure set52a
begin
  gsay_reply(SCRIPT_SET, 257);
  giq_option(-3, SCRIPT_SET, 258, set53, GOOD_REACTION);
end

procedure set53
begin
  gsay_reply(SCRIPT_SET, 259);
  giq_option(5, SCRIPT_SET, 260, set54, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 261, set56, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 262, setend, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_SET, 263, set56, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_SET, 264, setend, NEUTRAL_REACTION);
end

procedure set54
begin
  gsay_reply(SCRIPT_SET, 265);
  giq_option(4, SCRIPT_SET, 266, set55, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 267, set56, NEUTRAL_REACTION);
end

procedure set55
begin
  setgone := 1;
  gsay_message(SCRIPT_SET, 268, NEUTRAL_REACTION);
  call setend;
end

procedure set56
begin
  set_global_var(GVAR_SIGNAL_REWARD, global_var(GVAR_SIGNAL_REWARD) bwor 2);
  gsay_message(SCRIPT_SET, 269, NEUTRAL_REACTION);
  call setend;
end

procedure set57
begin
  gsay_reply(SCRIPT_SET, 270);
  if (obj_is_carrying_obj_pid(dude_obj, 98)) then begin
    giq_option(6, SCRIPT_SET, 271, set57_2, NEUTRAL_REACTION);
  end
  giq_option(4, SCRIPT_SET, 272, set63, BAD_REACTION);
  giq_option(4, SCRIPT_SET, 273, setcbt, BAD_REACTION);
  giq_option(4, SCRIPT_SET, 274, set64, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_SET, 275, set63, NEUTRAL_REACTION);
end

procedure set57_2
begin
  if (is_success(roll_vs_skill(dude_obj, 14, -20))) then begin
    call set58;
  end
  else begin
    call set62;
  end
end

procedure set58
begin
  gsay_reply(SCRIPT_SET, 276);
  giq_option(5, SCRIPT_SET, 277, set59, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 278, set60, BAD_REACTION);
end

procedure set59
begin
  set_global_var(GVAR_NECROP_WATER_PUMP_FIXED, 1);
  set_global_var(GVAR_HUB_FILLER_30, 1);
  gsay_reply(SCRIPT_SET, 279);
  giq_option(4, SCRIPT_SET, 280, travel, NEUTRAL_REACTION);
end

procedure set60
begin
  gsay_reply(SCRIPT_SET, 281);
  giq_option(4, SCRIPT_SET, 282, set06, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 283, setcbt, BAD_REACTION);
end

procedure set61
begin
  gsay_message(SCRIPT_SET, 284, BAD_REACTION);
  call setcbt;
end

procedure set62
begin
  gsay_reply(SCRIPT_SET, 285);
  giq_option(4, SCRIPT_SET, 286, setcbt, BAD_REACTION);
end

procedure set63
begin
  gsay_reply(SCRIPT_SET, 287);
  giq_option(4, SCRIPT_SET, 288, setcbt, BAD_REACTION);
  giq_option(-3, SCRIPT_SET, 289, setcbt, BAD_REACTION);
end

procedure set64
begin
  gsay_reply(SCRIPT_SET, 290);
  giq_option(4, SCRIPT_SET, 291, set63, BAD_REACTION);
  giq_option(4, SCRIPT_SET, 292, set65, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_SET, 293, setcbt, BAD_REACTION);
end

procedure set65
begin
  chip := obj_carrying_pid_obj(dude_obj, 55);
  if (chip != 0) then begin
    rm_obj_from_inven(dude_obj, chip);
    set_global_var(GVAR_NECROP_WATER_CHIP_TAKEN, 0);
  end
  gsay_message(SCRIPT_SET, 294, BAD_REACTION);
  call Big_Down_React;
end

procedure set00a
begin
  if (dude_is_male) then begin
    call set03;
  end
  else begin
    call set04;
  end
end

procedure set00b
begin
  call Big_Down_React;
  call set02;
end

procedure set02a
begin
  call Up_React;
  call set01;
end

procedure set04
begin
  gsay_reply(SCRIPT_SET, 117);
  giq_option(4, SCRIPT_SET, 118, setcbt, BAD_REACTION);
  giq_option(4, SCRIPT_SET, 119, setcbt, BAD_REACTION);
  giq_option(-3, SCRIPT_SET, 120, setcbt, BAD_REACTION);
end

procedure set09a
begin
  if (dude_is_male) then begin
    call set03;
  end
  else begin
    call set04;
  end
end

procedure set18a
begin
  call Big_Down_React;
  call set19;
end

procedure set200
begin
  gsay_message(SCRIPT_SET, 295, NEUTRAL_REACTION);
end

procedure set201
begin
  gsay_message(SCRIPT_SET, 296, NEUTRAL_REACTION);
end

procedure set202
begin
  gsay_message(SCRIPT_SET, 297, NEUTRAL_REACTION);
end

procedure set203
begin
  gsay_message(SCRIPT_SET, 298, NEUTRAL_REACTION);
end

procedure set204
begin
  gsay_message(SCRIPT_SET, 299, NEUTRAL_REACTION);
end

procedure set205
begin
  gsay_message(SCRIPT_SET, 300, NEUTRAL_REACTION);
end

procedure set206
begin
  gsay_message(SCRIPT_SET, 301, NEUTRAL_REACTION);
end

procedure set207
begin
  gsay_message(SCRIPT_SET, 302, NEUTRAL_REACTION);
end

procedure set208
begin
  gsay_message(SCRIPT_SET, 303, NEUTRAL_REACTION);
end

procedure set209
begin
  gsay_message(SCRIPT_SET, 304, NEUTRAL_REACTION);
end

procedure set300
begin
  gsay_message(SCRIPT_SET, 305, NEUTRAL_REACTION);
end

procedure set301
begin
  gsay_message(SCRIPT_SET, 306, NEUTRAL_REACTION);
end

procedure set302
begin
  gsay_message(SCRIPT_SET, 307, NEUTRAL_REACTION);
end

procedure set303
begin
  gsay_message(SCRIPT_SET, 308, NEUTRAL_REACTION);
end

procedure set304
begin
  gsay_message(SCRIPT_SET, 309, NEUTRAL_REACTION);
end

procedure set305
begin
  gsay_message(SCRIPT_SET, 310, NEUTRAL_REACTION);
end

procedure set306
begin
  gsay_message(SCRIPT_SET, 311, NEUTRAL_REACTION);
end

procedure set307
begin
  gsay_message(SCRIPT_SET, 312, NEUTRAL_REACTION);
end

procedure set308
begin
  gsay_message(SCRIPT_SET, 313, NEUTRAL_REACTION);
end

procedure set309
begin
  gsay_message(SCRIPT_SET, 314, NEUTRAL_REACTION);
end

procedure set310
begin
  gsay_message(SCRIPT_SET, 315, NEUTRAL_REACTION);
end

procedure set311
begin
  gsay_message(SCRIPT_SET, 316, NEUTRAL_REACTION);
end

procedure pickup_p_proc
begin
  if (source_obj == dude_obj) then begin
    Hostile := 1;
  end
end

procedure travel
begin
  load_map(5, 1);
end

procedure Get_Reaction
begin
  if (local_var(2) == 0) then begin
    set_local_var(0, 50);
    set_local_var(1, 2);
    set_local_var(2, 1);
    set_local_var(0, local_var(0) + (5 * get_critter_stat(dude_obj, 3)) - 25);
    set_local_var(0, local_var(0) + (10 * has_trait(0, dude_obj, 10)));
    if (has_trait(0, dude_obj, 39)) then begin
      if (global_var(GVAR_PLAYER_REPUTATION) > 0) then begin
        set_local_var(0, local_var(0) + global_var(GVAR_PLAYER_REPUTATION));
      end
      else begin
        set_local_var(0, local_var(0) - global_var(GVAR_PLAYER_REPUTATION));
      end
    end
    else begin
      if (local_var(3) == 1) then begin
        set_local_var(0, local_var(0) - global_var(GVAR_PLAYER_REPUTATION));
      end
      else begin
        set_local_var(0, local_var(0) + global_var(GVAR_PLAYER_REPUTATION));
      end
    end
    if (global_var(GVAR_CHILDKILLER_REPUTATION) > 2) then begin
      set_local_var(0, local_var(0) - 30);
    end
    if (((global_var(GVAR_BAD_MONSTER) + global_var(GVAR_GOOD_MONSTER)) >= 25) and ((global_var(GVAR_BAD_MONSTER) > (3 * global_var(GVAR_GOOD_MONSTER))) or (global_var(GVAR_CHAMPION_REPUTATION) == 1))) then begin
      set_local_var(0, local_var(0) + 20);
    end
    if (((global_var(GVAR_BAD_MONSTER) + global_var(GVAR_GOOD_MONSTER)) >= 25) and ((global_var(GVAR_GOOD_MONSTER) > (2 * global_var(GVAR_BAD_MONSTER))) or (global_var(GVAR_BERSERKER_REPUTATION) == 1))) then begin
      set_local_var(0, local_var(0) - 20);
    end
    call React_To_Level;
  end
end

procedure React_To_Level
begin
  if (local_var(0) <= 25) then begin
    set_local_var(1, 1);
  end
  else begin
    if (local_var(0) <= 75) then begin
      set_local_var(1, 2);
    end
    else begin
      set_local_var(1, 3);
    end
  end
end

procedure Level_To_React
begin
  if (local_var(1) == 1) then begin
    set_local_var(0, random(1, 25));
  end
  else begin
    if (local_var(1) == 2) then begin
      set_local_var(0, random(26, 75));
    end
    else begin
      set_local_var(0, random(76, 100));
    end
  end
end

procedure Up_React
begin
  set_local_var(0, local_var(0) + 10);
  call React_To_Level;
end

procedure Down_React
begin
  set_local_var(0, local_var(0) - 10);
  call React_To_Level;
end

procedure Bottom_React
begin
  set_local_var(1, 1);
  set_local_var(0, 1);
end

procedure Top_React
begin
  set_local_var(0, 100);
  set_local_var(1, 3);
end

procedure Big_Up_React
begin
  set_local_var(0, local_var(0) + 25);
  call React_To_Level;
end

procedure Big_Down_React
begin
  set_local_var(0, local_var(0) - 25);
  call React_To_Level;
end

procedure Up_React_Level
begin
  set_local_var(1, local_var(1) + 1);
  if (local_var(1) > 3) then begin
    set_local_var(1, 3);
  end
  call Level_To_React;
end

procedure Down_React_Level
begin
  set_local_var(1, local_var(1) - 1);
  if (local_var(1) < 1) then begin
    set_local_var(1, 1);
  end
  call Level_To_React;
end

procedure Goodbyes
begin
  exit_line := message_str(SCRIPT_MODREACT, random(100, 105));
end
