#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure combat_p_proc;
procedure critter_p_proc;
procedure damage_p_proc;
procedure look_at_p_proc;
procedure map_enter_p_proc;
procedure pickup_p_proc;
procedure talk_p_proc;
procedure use_skill_on_p_proc;
procedure overend;
procedure overcbt;
procedure over00;
procedure over01;
procedure over01a;
procedure over02;
procedure over03;
procedure over04;
procedure over05;
procedure over06;
procedure over07;
procedure over08;
procedure over09;
procedure over10;
procedure over12;
procedure over13;
procedure over14;
procedure over16;
procedure over19;
procedure over20;
procedure over21;
procedure over22;
procedure over23;
procedure over24;
procedure over25;
procedure over26;
procedure over27;
procedure over28;
procedure over29;
procedure over30;
procedure over31;
procedure over32;
procedure over33;
procedure over34;
procedure over34_1;
procedure over37;
procedure over38;
procedure over38a;
procedure over39;
procedure over40;
procedure over41;
procedure over41a;
procedure over42;
procedure over43;
procedure over44;
procedure over45;
procedure over46;
procedure over47;
procedure over48;
procedure over49;
procedure over50;
procedure over51;
procedure over52;
procedure over53;
procedure over54;
procedure over55;
procedure over58;
procedure over59;
procedure over60;
procedure over61;
procedure over61a;
procedure over62;
procedure over63;
procedure over64;
procedure over66;
procedure over68;
procedure over69;
procedure over70;
procedure over71;
procedure over72;
procedure over73;
procedure over74;
procedure over75;
procedure over76;
procedure over77;
procedure over78;
procedure over79;
procedure over80;
procedure over81;
procedure Over81b;
procedure Over81c;
procedure Over81d;
procedure Over81e;
procedure over100;
procedure over200;
procedure over201;
procedure over202;
procedure over203;
procedure destroy_p_proc;

variable rndx;
variable rndy;
variable rndz;
variable HOSTILE;
variable HEREBEFORE;
variable stealing;
variable SEED;
variable Visits_without_chip := 1;
variable Visits_with_caravans := 1;
variable Visits_master_alive := 1;
variable Visits_with_chip := 1;
variable Visits_vats_blown := 1;
variable initialized1;

import variable Ian_ptr;

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 (script_action == combat_proc) then begin
    call combat_p_proc;
  end
  else begin
    if (script_action == critter_proc) then begin
      call critter_p_proc;
    end
    else begin
      if (script_action == damage_proc) then begin
        call damage_p_proc;
      end
      else begin
        if (script_action == destroy_proc) then begin
          call destroy_p_proc;
        end
        else begin
          if (script_action == look_at_proc) then begin
            call look_at_p_proc;
          end
          else begin
            if (script_action == map_enter_proc) then begin
              call map_enter_p_proc;
            end
            else begin
              if (script_action == pickup_proc) then begin
                call pickup_p_proc;
              end
              else begin
                if (script_action == talk_proc) then begin
                  call talk_p_proc;
                end
                else begin
                  if (script_action == use_skill_on_proc) then begin
                    call use_skill_on_p_proc;
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end

procedure combat_p_proc
begin
  variable LVar0 := 0;
  if (fixed_param == 4) then begin
    if (obj_is_carrying_obj_pid(self_obj, 36) == 0) then begin
      LVar0 := create_object_sid(36, 0, 0, -1);
      add_mult_objs_to_inven(self_obj, LVar0, 2);
    end
  end
end

procedure critter_p_proc
begin
  if (HOSTILE) then begin
    HOSTILE := 0;
    attack_complex(dude_obj, 0, 1, 100, 250, 300, 0, 128);
  end
  else begin
    if ((global_var(GVAR_WATER_CHIP_4) == 1) and (tile_distance_objs(self_obj, dude_obj) < 12)) then begin
      if (local_var(8) == 0) then begin
        dialogue_system_enter;
      end
    end
    else begin
      if (global_var(GVAR_VATS_BLOWN) and global_var(GVAR_MASTER_BLOWN) and (local_var(6) == 0)) then begin
        dialogue_system_enter;
      end
    end
  end
end

procedure damage_p_proc
begin
  script_overrides;
  critter_heal(self_obj, 100);
  if (source_obj == dude_obj) then begin
    set_global_var(GVAR_WATER_CHIP_4, 1);
  end
end

procedure look_at_p_proc
begin
  script_overrides;
  display_msg(message_str(SCRIPT_OVER, 100));
end

procedure map_enter_p_proc
begin
  critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_TEAM_NUM, 1);
end

procedure pickup_p_proc
begin
  stealing := 1;
  dialogue_system_enter;
end

procedure talk_p_proc
begin
  call Get_Reaction;
  start_gdialog(SCRIPT_OVER, self_obj, 4, HEAD_OVERSEER, BACKGROUND_VAULT);
  gsay_start;
  SEED := 0;
  if (global_var(GVAR_VATS_BLOWN) and global_var(GVAR_MASTER_BLOWN)) then begin
    call over81;
  end
  else begin
    if (global_var(GVAR_WATER_CHIP_4)) then begin
      call over72;
    end
    else begin
      if (stealing) then begin
        call over71;
      end
      else begin
        if (global_var(GVAR_FIND_WATER_CHIP) == 0) then begin
          if (obj_is_carrying_obj_pid(dude_obj, 55)) then begin
            call over28;
          end
          else begin
            if (Visits_without_chip == 1) then begin
              call over07;
            end
            else begin
              if (Visits_without_chip == 2) then begin
                call over12;
              end
              else begin
                if (Visits_without_chip > 2) then begin
                  call over19;
                end
              end
            end
            Visits_without_chip := Visits_without_chip + 1;
          end
        end
        else begin
          if (global_var(GVAR_FIND_WATER_CHIP) == 1) then begin
            if (obj_is_carrying_obj_pid(dude_obj, 55)) then begin
              call over28;
            end
            else begin
              if (Visits_with_caravans == 1) then begin
                call over73;
              end
              else begin
                if (Visits_with_caravans > 1) then begin
                  call over80;
                end
              end
            end
            Visits_with_caravans := Visits_with_caravans + 1;
          end
          else begin
            if (not(global_var(GVAR_VATS_BLOWN))) then begin
              if (global_var(GVAR_MASTER_BLOWN)) then begin
                call over54;
              end
              else begin
                if (Visits_master_alive == 1) then begin
                  call over42;
                end
                else begin
                  call over50;
                end
              end
              Visits_master_alive := Visits_master_alive + 1;
            end
            else begin
              if (global_var(GVAR_MASTER_BLOWN)) then begin
                call over81;
              end
              else begin
                if (Visits_vats_blown == 1) then begin
                  call over62;
                end
                else begin
                  call over68;
                end
              end
              Visits_vats_blown := Visits_vats_blown + 1;
            end
          end
        end
      end
    end
  end
  gsay_end;
  end_dialogue;
  if (Ian_ptr != 0) then begin
    if (local_var(7) == 0) then begin
      float_msg(Ian_ptr, message_str(SCRIPT_IAN, 171), FLOAT_MSG_NORMAL);
      set_local_var(7, 1);
    end
  end
  if (local_var(4) == 1) then begin
    gfade_out(600);
    display_msg(message_str(SCRIPT_OVER, 252));
    give_exp_points(7500);
    set_local_var(4, 2);
    move_to(dude_obj, 21135, 2);
    display_msg(message_str(SCRIPT_WTRGRD, 117));
    gfade_in(600);
  end
end

procedure use_skill_on_p_proc
begin
  if (action_being_used == 10) then begin
    script_overrides;
    stealing := 1;
    dialogue_system_enter;
  end
end

procedure overend
begin
end

procedure overcbt
begin
  HOSTILE := 1;
end

procedure over00
begin
  HEREBEFORE := 1;
  gsay_message(SCRIPT_OVER, 101, NEUTRAL_REACTION);
  gsay_message(SCRIPT_OVER, 102, NEUTRAL_REACTION);
  call over01;
end

procedure over01
begin
  gsay_message(SCRIPT_OVER, 103, NEUTRAL_REACTION);
  call over04;
end

procedure over01a
begin
  gsay_message(SCRIPT_OVER, 104, NEUTRAL_REACTION);
end

procedure over02
begin
  gsay_message(SCRIPT_OVER, 105, NEUTRAL_REACTION);
  call over04;
end

procedure over03
begin
  gsay_message(SCRIPT_OVER, 106, NEUTRAL_REACTION);
  call over04;
end

procedure over04
begin
  gsay_message(SCRIPT_OVER, 107, NEUTRAL_REACTION);
  gsay_message(SCRIPT_OVER, 108, NEUTRAL_REACTION);
  call over05;
end

procedure over05
begin
  gsay_message(SCRIPT_OVER, 109, NEUTRAL_REACTION);
  call over06;
end

procedure over06
begin
  set_global_var(GVAR_BURIED_VAULT, 1);
  gsay_message(SCRIPT_OVER, 110, NEUTRAL_REACTION);
end

procedure over07
begin
  gsay_reply(SCRIPT_OVER, 111);
  giq_option(7, SCRIPT_OVER, 112, over10, BAD_REACTION);
  giq_option(6, SCRIPT_OVER, 113, over09, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_OVER, 114, over08, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_OVER, 115, over08, NEUTRAL_REACTION);
end

procedure over08
begin
  gsay_reply(SCRIPT_OVER, 116);
  giq_option(4, SCRIPT_OVER, 260, overend, NEUTRAL_REACTION);
end

procedure over09
begin
  gsay_reply(SCRIPT_OVER, 117);
  giq_option(4, SCRIPT_OVER, 118, over08, NEUTRAL_REACTION);
end

procedure over10
begin
  gsay_reply(SCRIPT_OVER, 119);
  giq_option(4, SCRIPT_OVER, 120, over08, NEUTRAL_REACTION);
end

procedure over12
begin
  gsay_reply(SCRIPT_OVER, 121);
  giq_option(4, SCRIPT_OVER, 122, over13, NEUTRAL_REACTION);
  giq_option(5, SCRIPT_OVER, 123, over14, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_OVER, 124, over16, BAD_REACTION);
  giq_option(-3, SCRIPT_OVER, 125, over16, BAD_REACTION);
end

procedure over13
begin
  gsay_message(SCRIPT_OVER, 126, NEUTRAL_REACTION);
end

procedure over14
begin
  gsay_reply(SCRIPT_OVER, 127);
  giq_option(6, SCRIPT_OVER, 128, overend, NEUTRAL_REACTION);
end

procedure over16
begin
  gsay_message(SCRIPT_OVER, 129, NEUTRAL_REACTION);
end

procedure over19
begin
  gsay_reply(SCRIPT_OVER, 130);
  giq_option(5, SCRIPT_OVER, 131, over21, BAD_REACTION);
  giq_option(6, SCRIPT_OVER, 132, over22, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_OVER, 133, over20, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_OVER, 134, over20, NEUTRAL_REACTION);
end

procedure over20
begin
  gsay_message(SCRIPT_OVER, 135, NEUTRAL_REACTION);
end

procedure over21
begin
  gsay_message(SCRIPT_OVER, 136, BAD_REACTION);
end

procedure over22
begin
  gsay_reply(SCRIPT_OVER, 137);
  giq_option(6, SCRIPT_OVER, 138, over23, NEUTRAL_REACTION);
  if (not(local_var(5))) then begin
    giq_option(6, SCRIPT_OVER, 139, over24, NEUTRAL_REACTION);
  end
  giq_option(6, SCRIPT_OVER, 140, over25, NEUTRAL_REACTION);
end

procedure over23
begin
  gsay_message(SCRIPT_OVER, 141, NEUTRAL_REACTION);
end

procedure over24
begin
  variable LVar0 := 0;
  set_local_var(5, 1);
  LVar0 := create_object_sid(40, 0, 0, -1);
  add_obj_to_inven(dude_obj, LVar0);
  LVar0 := create_object_sid(40, 0, 0, -1);
  add_obj_to_inven(dude_obj, LVar0);
  LVar0 := create_object_sid(29, 0, 0, -1);
  add_obj_to_inven(dude_obj, LVar0);
  LVar0 := create_object_sid(29, 0, 0, -1);
  add_obj_to_inven(dude_obj, LVar0);
  gsay_message(SCRIPT_OVER, 142, NEUTRAL_REACTION);
end

procedure over25
begin
  gsay_reply(SCRIPT_OVER, 143);
  giq_option(5, SCRIPT_OVER, 144, over26, NEUTRAL_REACTION);
  giq_option(5, SCRIPT_OVER, 145, over27, NEUTRAL_REACTION);
end

procedure over26
begin
  gsay_reply(SCRIPT_OVER, 146);
  giq_option(5, SCRIPT_OVER, 147, overend, NEUTRAL_REACTION);
  giq_option(6, SCRIPT_OVER, 148, overend, NEUTRAL_REACTION);
end

procedure over27
begin
  gsay_message(SCRIPT_OVER, 149, NEUTRAL_REACTION);
end

procedure over28
begin
  Visits_with_chip := Visits_with_chip + 1;
  set_global_var(GVAR_FIND_WATER_CHIP, 2);
  if (global_var(GVAR_CALM_REBELS) != 2) then begin
    set_global_var(GVAR_CALM_REBELS, 3);
  end
  if (global_var(GVAR_WATER_THIEF) != 2) then begin
    set_global_var(GVAR_WATER_THIEF, 3);
  end
  set_local_var(4, 1);
  gsay_reply(SCRIPT_OVER, 150);
  giq_option(4, SCRIPT_OVER, 151, over31, NEUTRAL_REACTION);
  giq_option(6, SCRIPT_OVER, 152, over34, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_OVER, 153, over37, NEUTRAL_REACTION);
end

procedure over29
begin
  gsay_message(SCRIPT_OVER, 154, NEUTRAL_REACTION);
  if (obj_is_carrying_obj_pid(dude_obj, 55)) then begin
    call over31;
  end
  else begin
    call over30;
  end
end

procedure over30
begin
  gsay_message(SCRIPT_OVER, 155, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_OVER, 164, over31, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_OVER, 165, over30, NEUTRAL_REACTION);
end

procedure over31
begin
  variable LVar0 := 0;
  LVar0 := obj_carrying_pid_obj(dude_obj, 55);
  destroy_object(LVar0);
  gsay_reply(SCRIPT_OVER, 156);
  giq_option(6, SCRIPT_OVER, 157, over32, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_OVER, 158, over33, NEUTRAL_REACTION);
end

procedure over32
begin
  gsay_reply(SCRIPT_OVER, 159);
  giq_option(4, SCRIPT_OVER, 160, overend, NEUTRAL_REACTION);
end

procedure over33
begin
  gsay_reply(SCRIPT_OVER, 161);
  giq_option(4, SCRIPT_OVER, 162, overend, NEUTRAL_REACTION);
end

procedure over34
begin
  gsay_reply(SCRIPT_OVER, 163);
  giq_option(4, SCRIPT_OVER, 164, over31, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_OVER, 165, over30, NEUTRAL_REACTION);
end

procedure over34_1
begin
end

procedure over37
begin
  gsay_reply(SCRIPT_OVER, 166);
  giq_option(0, SCRIPT_OVER, 196, over38, NEUTRAL_REACTION);
end

procedure over38
begin
  gsay_reply(SCRIPT_OVER, 167);
  giq_option(0, SCRIPT_OVER, 196, over38a, NEUTRAL_REACTION);
end

procedure over38a
begin
  gsay_reply(SCRIPT_OVER, 168);
  giq_option(0, SCRIPT_OVER, 196, over39, NEUTRAL_REACTION);
end

procedure over39
begin
  gsay_reply(SCRIPT_OVER, 169);
  giq_option(0, SCRIPT_OVER, 196, over40, NEUTRAL_REACTION);
end

procedure over40
begin
  variable LVar0 := 0;
  LVar0 := obj_carrying_pid_obj(dude_obj, 55);
  destroy_object(LVar0);
  set_local_var(4, 1);
  gsay_reply(SCRIPT_OVER, 170);
  giq_option(-3, SCRIPT_OVER, 171, over41, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_OVER, 172, over41a, NEUTRAL_REACTION);
end

procedure over41
begin
  gsay_message(SCRIPT_OVER, 173, NEUTRAL_REACTION);
end

procedure over41a
begin
  gsay_message(SCRIPT_OVER, 174, NEUTRAL_REACTION);
end

procedure over42
begin
  set_global_var(GVAR_DESTROY_MASTER_4, 1);
  set_global_var(GVAR_DESTROY_MASTER_5, 1);
  gsay_reply(SCRIPT_OVER, 175);
  giq_option(4, SCRIPT_OVER, 176, over43, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_OVER, 177, over49, NEUTRAL_REACTION);
end

procedure over43
begin
  gsay_reply(SCRIPT_OVER, 178);
  giq_option(4, SCRIPT_OVER, 179, over44, NEUTRAL_REACTION);
end

procedure over44
begin
  gsay_reply(SCRIPT_OVER, 180);
  giq_option(4, SCRIPT_OVER, 181, over45, NEUTRAL_REACTION);
  giq_option(7, SCRIPT_OVER, 182, over46, NEUTRAL_REACTION);
end

procedure over45
begin
  gsay_reply(SCRIPT_OVER, 183);
  giq_option(4, SCRIPT_OVER, 184, over47, NEUTRAL_REACTION);
end

procedure over46
begin
  gsay_reply(SCRIPT_OVER, 185);
  giq_option(6, SCRIPT_OVER, 186, over47, NEUTRAL_REACTION);
end

procedure over47
begin
  gsay_reply(SCRIPT_OVER, 187);
  giq_option(4, SCRIPT_OVER, 188, overend, NEUTRAL_REACTION);
  giq_option(6, SCRIPT_OVER, 189, over48, NEUTRAL_REACTION);
end

procedure over48
begin
  gsay_message(SCRIPT_OVER, 190, NEUTRAL_REACTION);
end

procedure over49
begin
  gsay_message(SCRIPT_OVER, 191, NEUTRAL_REACTION);
end

procedure over50
begin
  gsay_reply(SCRIPT_OVER, 192);
  giq_option(4, SCRIPT_OVER, 193, over51, NEUTRAL_REACTION);
  giq_option(6, SCRIPT_OVER, 194, over52, NEUTRAL_REACTION);
  giq_option(5, SCRIPT_OVER, 195, over53, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_OVER, 196, over51, NEUTRAL_REACTION);
end

procedure over51
begin
  gsay_message(SCRIPT_OVER, 197, NEUTRAL_REACTION);
end

procedure over52
begin
  gsay_message(SCRIPT_OVER, 198, NEUTRAL_REACTION);
end

procedure over53
begin
  gsay_message(SCRIPT_OVER, 199, NEUTRAL_REACTION);
end

procedure over54
begin
  gsay_reply(SCRIPT_OVER, 200);
  giq_option(4, SCRIPT_OVER, 201, over55, NEUTRAL_REACTION);
  giq_option(6, SCRIPT_OVER, 202, over55, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_OVER, 203, over61, NEUTRAL_REACTION);
end

procedure over55
begin
  gsay_reply(SCRIPT_OVER, 204);
  giq_option(4, SCRIPT_OVER, 205, over60, NEUTRAL_REACTION);
end

procedure over58
begin
  gsay_message(SCRIPT_OVER, 207, NEUTRAL_REACTION);
end

procedure over59
begin
  gsay_message(SCRIPT_OVER, 208, NEUTRAL_REACTION);
end

procedure over60
begin
  gsay_message(SCRIPT_OVER, 209, NEUTRAL_REACTION);
end

procedure over61
begin
  gsay_reply(SCRIPT_OVER, 210);
  giq_option(-3, SCRIPT_OVER, 211, over61a, NEUTRAL_REACTION);
end

procedure over61a
begin
  gsay_message(SCRIPT_OVER, 212, NEUTRAL_REACTION);
end

procedure over62
begin
  gsay_reply(SCRIPT_OVER, 213);
  giq_option(4, SCRIPT_OVER, 214, over63, NEUTRAL_REACTION);
  giq_option(6, SCRIPT_OVER, 215, over64, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_OVER, 216, over63, NEUTRAL_REACTION);
end

procedure over63
begin
  gsay_reply(SCRIPT_OVER, 217);
  giq_option(4, SCRIPT_OVER, 218, over64, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_OVER, 219, over64, NEUTRAL_REACTION);
end

procedure over64
begin
  gsay_reply(SCRIPT_OVER, 220);
  giq_option(4, SCRIPT_OVER, 221, over66, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_OVER, 222, over66, NEUTRAL_REACTION);
end

procedure over66
begin
  gsay_message(SCRIPT_OVER, 223, NEUTRAL_REACTION);
end

procedure over68
begin
  gsay_reply(SCRIPT_OVER, 224);
  giq_option(4, SCRIPT_OVER, 225, over69, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_OVER, 226, over70, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_OVER, 227, over69, NEUTRAL_REACTION);
end

procedure over69
begin
  gsay_message(SCRIPT_OVER, 228, NEUTRAL_REACTION);
end

procedure over70
begin
  gsay_message(SCRIPT_OVER, 229, NEUTRAL_REACTION);
end

procedure over71
begin
  stealing := 0;
  gsay_message(SCRIPT_OVER, 230, BAD_REACTION);
end

procedure over72
begin
  gsay_reply(SCRIPT_OVER, 231);
  set_local_var(8, 1);
  giq_option(4, SCRIPT_OVER, 259, overcbt, BAD_REACTION);
end

procedure over73
begin
  gsay_reply(SCRIPT_OVER, 232);
  giq_option(4, SCRIPT_OVER, 233, over75, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_OVER, 234, over74, NEUTRAL_REACTION);
end

procedure over74
begin
  gsay_message(SCRIPT_OVER, 235, NEUTRAL_REACTION);
end

procedure over75
begin
  gsay_reply(SCRIPT_OVER, 236);
  giq_option(4, SCRIPT_OVER, 237, over76, NEUTRAL_REACTION);
  giq_option(6, SCRIPT_OVER, 238, over77, NEUTRAL_REACTION);
end

procedure over76
begin
  gsay_message(SCRIPT_OVER, 239, NEUTRAL_REACTION);
end

procedure over77
begin
  gsay_reply(SCRIPT_OVER, 240);
  giq_option(5, SCRIPT_OVER, 241, over78, NEUTRAL_REACTION);
  giq_option(6, SCRIPT_OVER, 242, over79, NEUTRAL_REACTION);
end

procedure over78
begin
  gsay_message(SCRIPT_OVER, 243, NEUTRAL_REACTION);
end

procedure over79
begin
  gsay_message(SCRIPT_OVER, 244, NEUTRAL_REACTION);
end

procedure over80
begin
  gsay_message(SCRIPT_OVER, 245, NEUTRAL_REACTION);
end

procedure over81
begin
  set_local_var(6, 1);
  set_local_var(8, 1);
  call Top_React;
  gsay_reply(SCRIPT_OVER, 261);
  giq_option(0, SCRIPT_MODREACT, 106, Over81b, GOOD_REACTION);
end

procedure Over81b
begin
  set_local_var(1, 50);
  call Level_To_React;
  gsay_reply(SCRIPT_OVER, 262);
  giq_option(0, SCRIPT_MODREACT, 106, Over81c, BAD_REACTION);
end

procedure Over81c
begin
  call Bottom_React;
  gsay_reply(SCRIPT_OVER, 263);
  giq_option(0, SCRIPT_MODREACT, 106, Over81d, BAD_REACTION);
end

procedure Over81d
begin
  gsay_reply(SCRIPT_OVER, 264);
  giq_option(0, SCRIPT_MODREACT, 106, Over81e, BAD_REACTION);
end

procedure Over81e
begin
  gsay_message(SCRIPT_OVER, 265, BAD_REACTION);
  add_timer_event(dude_obj, 10, 5);
end

procedure over100
begin
  gsay_message(SCRIPT_OVER, 247, NEUTRAL_REACTION);
end

procedure over200
begin
  gsay_message(SCRIPT_OVER, 248, NEUTRAL_REACTION);
end

procedure over201
begin
  gsay_message(SCRIPT_OVER, 249, NEUTRAL_REACTION);
end

procedure over202
begin
  gsay_message(SCRIPT_OVER, 250, NEUTRAL_REACTION);
end

procedure over203
begin
  gsay_message(SCRIPT_OVER, 251, NEUTRAL_REACTION);
end

procedure destroy_p_proc
begin
  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_GOOD_MONSTER, global_var(GVAR_GOOD_MONSTER) + 1);
    if ((global_var(GVAR_GOOD_MONSTER) % 2) == 0) then begin
      set_global_var(GVAR_PLAYER_REPUTATION, global_var(GVAR_PLAYER_REPUTATION) - 1);
    end
  end
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
