#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure do_dialogue;
procedure cabbot01;
procedure cabbot02;
procedure cabbot04;
procedure cabbot05;
procedure cabbot05a;
procedure cabbot06;
procedure cabbot07;
procedure cabbot09;
procedure cabbot10;
procedure cabbot12;
procedure cabbot16;
procedure cabbot17;
procedure cabbot18;
procedure cabbot19;
procedure cabbot20;
procedure cabbot21;
procedure cabbot21_1;
procedure cabbot22;
procedure cabbot23;
procedure cabbot24;
procedure cabbot25;
procedure cabbot27;
procedure cabbot28;
procedure cabbot31;
procedure cabbot32;
procedure cabbot33;
procedure cabbot34;
procedure cabbot35;
procedure cabbot36;
procedure cabbot37;
procedure cabbot38;
procedure cabbot39;
procedure cabbot40;
procedure cabbot41;
procedure cabbot42;
procedure cabbot43;
procedure cabbot44;
procedure cabbot45;
procedure cabbot46;
procedure cabbot47;
procedure cabbot48;
procedure cabbot06a;
procedure cabbot07a;
procedure cabbot16a;
procedure cabbot19a;
procedure cabbot23a;
procedure cabbot33a;
procedure cabbotx;
procedure cabbotx1;
procedure cabbotx3;
procedure cabbotx6;
procedure cabbotx7;
procedure cabbotx8;
procedure cabbot35a;
procedure cabbot49;
procedure cabbot50;
procedure cabbot51;
procedure cabbot52;
procedure cabbot53;
procedure cabbot54;
procedure cabbot55;
procedure cabbot56;
procedure cabbot57;
procedure cabbot58;
procedure cabbot59;
procedure cabbot60;
procedure cabbot61;
procedure cabbot62;
procedure cabbot63;
procedure cabbot64;
procedure cabbot65;
procedure cabbot66;
procedure cabbot67;
procedure cabbot68;
procedure cabbot69;
procedure cabbotend;
procedure cabbotopen;
procedure combat;
procedure damage_p_proc;
procedure critter_p_proc;
procedure pickup_p_proc;
procedure talk_p_proc;
procedure destroy_p_proc;
procedure look_at_p_proc;
procedure time_p_proc;

import variable Door_ptr;
import variable Cabbot_Ptr;

variable VATS;
variable MALE;
variable SEXY;
variable HOSTILE;
variable ILLEGAL;
variable Only_Once := 1;
variable awardex;
variable temp;

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 (Only_Once) then begin
    Only_Once := 0;
    Cabbot_Ptr := self_obj;
    critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_TEAM_NUM, 44);
    critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_AI_PACKET, AI_BROTHERHOOD_KNIGHT);
  end
  if (script_action == look_at_proc) then begin
    call look_at_p_proc;
  end
  else begin
    if (script_action == damage_proc) then begin
      call damage_p_proc;
    end
    else begin
      if (script_action == pickup_proc) then begin
        call pickup_p_proc;
      end
      else begin
        if (script_action == timed_event_proc) then begin
          call time_p_proc;
        end
        else begin
          if (script_action == talk_proc) then begin
            call talk_p_proc;
          end
          else begin
            if (script_action == critter_proc) then begin
              call critter_p_proc;
            end
            else begin
              if (script_action == destroy_proc) then begin
                call destroy_p_proc;
              end
            end
          end
        end
      end
    end
  end
end

procedure do_dialogue
begin
  call Get_Reaction;
  start_gdialog(SCRIPT_CABBOT, self_obj, 4, HEAD_CABBOT, BACKGROUND_BROTHERHOOD);
  gsay_start;
  if (local_var(4) == 1) then begin
    if (global_var(GVAR_BECOME_AN_INITIATE) == 1) then begin
      call cabbot24;
    end
    else begin
      if (global_var(GVAR_BECOME_AN_INITIATE) == 2) then begin
        call cabbot36;
      end
      else begin
        if (global_var(GVAR_WITH_CARAVAN == 1)) then begin
          call cabbot33;
        end
        else begin
          if (local_var(0) >= 50) then begin
            call cabbot19;
          end
          else begin
            call cabbot21;
          end
        end
      end
    end
  end
  else begin
    call cabbot01;
  end
  gsay_end;
  end_dialogue;
  if (awardex) then begin
    awardex := 0;
    display_msg(message_str(SCRIPT_CABBOT, 232));
    set_global_var(GVAR_PLAYER_REPUTATION, global_var(GVAR_PLAYER_REPUTATION) + 1);
    give_exp_points(2000);
  end
end

procedure cabbot01
begin
  set_local_var(4, 1);
  gsay_reply(SCRIPT_CABBOT, 101);
  giq_option(4, SCRIPT_CABBOT, 103, cabbot17, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 105, cabbot04, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 106, cabbot12, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 107, cabbot10, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 102, cabbot02, NEUTRAL_REACTION);
  giq_option(-3, SCRIPT_CABBOT, 104, cabbot46, NEUTRAL_REACTION);
end

procedure cabbot02
begin
  gsay_reply(SCRIPT_CABBOT, 108);
  giq_option(5, SCRIPT_CABBOT, 109, cabbot17, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 110, cabbot16, NEUTRAL_REACTION);
  giq_option(5, SCRIPT_CABBOT, 111, cabbot04, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 112, cabbot12, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 113, cabbot10, NEUTRAL_REACTION);
end

procedure cabbot04
begin
  gsay_message(SCRIPT_CABBOT, 114, NEUTRAL_REACTION);
  set_local_var(6, 1);
  gfade_out(600);
  game_time_advance(game_ticks(600));
  gfade_in(600);
  call cabbot05;
end

procedure cabbot05
begin
  gsay_reply(SCRIPT_CABBOT, 115);
  giq_option(4, SCRIPT_CABBOT, 116, cabbot06, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 117, cabbot10, NEUTRAL_REACTION);
  giq_option(6, SCRIPT_CABBOT, 118, cabbot05a, NEUTRAL_REACTION);
end

procedure cabbot05a
begin
  gsay_reply(SCRIPT_CABBOT, 119);
  giq_option(4, SCRIPT_CABBOT, 120, cabbot06, NEUTRAL_REACTION);
  giq_option(6, SCRIPT_CABBOT, 121, cabbot17, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 122, cabbot10, NEUTRAL_REACTION);
end

procedure cabbot06
begin
  gsay_reply(SCRIPT_CABBOT, 123);
  if (not(global_var(GVAR_THE_GLOW))) then begin
    set_global_var(GVAR_THE_GLOW, 1);
  end
  giq_option(7, SCRIPT_CABBOT, 124, cabbot07, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 125, cabbot09, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 126, cabbot06a, BAD_REACTION);
end

procedure cabbot07
begin
  gsay_reply(SCRIPT_CABBOT, 127);
  giq_option(4, SCRIPT_CABBOT, 128, cabbot09, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 129, cabbot07a, BAD_REACTION);
end

procedure cabbot09
begin
  gsay_message(SCRIPT_CABBOT, 130, GOOD_REACTION);
  set_global_var(GVAR_BECOME_AN_INITIATE, 1);
  call Up_React_Level;
  call cabbotx;
end

procedure cabbot10
begin
  gsay_message(SCRIPT_CABBOT, 131, NEUTRAL_REACTION);
end

procedure cabbot12
begin
  gsay_reply(SCRIPT_CABBOT, 132);
  giq_option(5, SCRIPT_CABBOT, 133, cabbot04, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 134, cabbot10, NEUTRAL_REACTION);
  giq_option(5, SCRIPT_CABBOT, 135, cabbot17, NEUTRAL_REACTION);
end

procedure cabbot16
begin
  gsay_reply(SCRIPT_CABBOT, 136);
  giq_option(5, SCRIPT_CABBOT, 137, cabbot17, NEUTRAL_REACTION);
  giq_option(5, SCRIPT_CABBOT, 138, cabbot04, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 139, cabbot16a, BAD_REACTION);
  giq_option(4, SCRIPT_CABBOT, 140, cabbot10, NEUTRAL_REACTION);
end

procedure cabbot17
begin
  gsay_message(SCRIPT_CABBOT, 141, BAD_REACTION);
  call cabbotx;
end

procedure cabbot18
begin
  gsay_message(SCRIPT_CABBOT, 142, BAD_REACTION);
  call cabbotx;
end

procedure cabbot19
begin
  if (local_var(1) >= 3) then begin
    gsay_reply(SCRIPT_CABBOT, 143);
  end
  else begin
    gsay_reply(SCRIPT_CABBOT, 144);
  end
  giq_option(5, SCRIPT_CABBOT, 145, cabbot05, NEUTRAL_REACTION);
  giq_option(5, SCRIPT_CABBOT, 146, cabbot17, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 147, cabbot19a, BAD_REACTION);
  giq_option(-3, SCRIPT_CABBOT, 104, cabbot46, NEUTRAL_REACTION);
end

procedure cabbot20
begin
  gsay_message(SCRIPT_CABBOT, 148, NEUTRAL_REACTION);
  call cabbotx;
end

procedure cabbot21
begin
  gsay_reply(SCRIPT_CABBOT, 149);
  giq_option(5, SCRIPT_CABBOT, 150, cabbot21_1, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 151, cabbotx, NEUTRAL_REACTION);
end

procedure cabbot21_1
begin
  if (dude_is_male) then begin
    if (is_success(roll_vs_skill(dude_obj, 14, 0))) then begin
      call cabbot23;
    end
    else begin
      call cabbot22;
    end
  end
  else begin
    call cabbot23;
  end
end

procedure cabbot22
begin
  gsay_message(SCRIPT_CABBOT, 152, NEUTRAL_REACTION);
  call cabbotx;
end

procedure cabbot23
begin
  if (local_var(1) < 2) then begin
    set_local_var(1, 2);
    call Level_To_React;
  end
  gsay_reply(SCRIPT_CABBOT, 153);
  giq_option(5, SCRIPT_CABBOT, 154, cabbot05, NEUTRAL_REACTION);
  giq_option(5, SCRIPT_CABBOT, 155, cabbot17, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 156, cabbot23a, BAD_REACTION);
end

procedure cabbot24
begin
  gsay_reply(SCRIPT_CABBOT, 157);
  giq_option(4, SCRIPT_CABBOT, 158, cabbot25, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 159, cabbot32, NEUTRAL_REACTION);
end

procedure cabbot25
begin
  gsay_reply(SCRIPT_CABBOT, 160);
  giq_option(4, SCRIPT_CABBOT, 161, cabbotx3, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 162, cabbot32, NEUTRAL_REACTION);
end

procedure cabbot27
begin
  gsay_reply(SCRIPT_CABBOT, 163);
  giq_option(4, SCRIPT_CABBOT, 164, cabbotopen, NEUTRAL_REACTION);
end

procedure cabbot28
begin
  gsay_reply(SCRIPT_CABBOT, 165);
  giq_option(4, SCRIPT_CABBOT, 166, cabbot31, NEUTRAL_REACTION);
end

procedure cabbot31
begin
  gsay_message(SCRIPT_CABBOT, 168, NEUTRAL_REACTION);
  call cabbotx;
end

procedure cabbot32
begin
  gsay_message(SCRIPT_CABBOT, 169, NEUTRAL_REACTION);
  call cabbotx;
end

procedure cabbot33
begin
  if (local_var(1) >= 3) then begin
    gsay_reply(SCRIPT_CABBOT, 170);
  end
  else begin
    if (local_var(1) <= 1) then begin
      gsay_reply(SCRIPT_CABBOT, 171);
    end
    else begin
      gsay_reply(SCRIPT_CABBOT, 172);
    end
  end
  giq_option(4, SCRIPT_CABBOT, 173, cabbot34, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 174, cabbot33a, BAD_REACTION);
end

procedure cabbot34
begin
  if (local_var(1) >= 3) then begin
    gsay_message(SCRIPT_CABBOT, 175, GOOD_REACTION);
  end
  else begin
    if (local_var(1) <= 1) then begin
      gsay_message(SCRIPT_CABBOT, 176, BAD_REACTION);
    end
    else begin
      gsay_message(SCRIPT_CABBOT, 177, NEUTRAL_REACTION);
    end
  end
  call cabbotx6;
end

procedure cabbot35
begin
  giq_option(5, SCRIPT_CABBOT, 178, cabbot38, NEUTRAL_REACTION);
  giq_option(5, SCRIPT_CABBOT, 179, cabbot42, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 180, cabbot37, NEUTRAL_REACTION);
end

procedure cabbot36
begin
  if (local_var(1) >= 3) then begin
    gsay_reply(SCRIPT_CABBOT, 182);
  end
  else begin
    if (local_var(1) <= 1) then begin
      gsay_reply(SCRIPT_CABBOT, 183);
    end
    else begin
      gsay_reply(SCRIPT_CABBOT, 184);
    end
  end
  giq_option(5, SCRIPT_CABBOT, 185, cabbot35a, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 186, cabbot37, NEUTRAL_REACTION);
end

procedure cabbot37
begin
  gsay_message(SCRIPT_CABBOT, 187, NEUTRAL_REACTION);
  call cabbotx7;
end

procedure cabbot38
begin
  gsay_reply(SCRIPT_CABBOT, 188);
  giq_option(5, SCRIPT_CABBOT, 189, cabbot39, NEUTRAL_REACTION);
  giq_option(5, SCRIPT_CABBOT, 190, cabbot40, NEUTRAL_REACTION);
end

procedure cabbot39
begin
  gsay_reply(SCRIPT_CABBOT, 191);
  giq_option(5, SCRIPT_CABBOT, 192, cabbot35a, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 193, cabbot37, NEUTRAL_REACTION);
end

procedure cabbot40
begin
  gsay_reply(SCRIPT_CABBOT, 194);
  giq_option(6, SCRIPT_CABBOT, 195, cabbot41, NEUTRAL_REACTION);
  giq_option(5, SCRIPT_CABBOT, 196, cabbot35a, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 197, cabbot37, NEUTRAL_REACTION);
end

procedure cabbot41
begin
  gsay_reply(SCRIPT_CABBOT, 198);
  giq_option(4, SCRIPT_CABBOT, 199, cabbot35a, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 200, cabbot37, NEUTRAL_REACTION);
end

procedure cabbot42
begin
  gsay_reply(SCRIPT_CABBOT, 201);
  giq_option(4, SCRIPT_CABBOT, 202, cabbot39, NEUTRAL_REACTION);
  giq_option(5, SCRIPT_CABBOT, 203, cabbot35a, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_CABBOT, 204, cabbot37, NEUTRAL_REACTION);
end

procedure cabbot43
begin
  call Down_React_Level;
  ILLEGAL := 1;
  float_msg(self_obj, message_str(SCRIPT_CABBOT, 205), FLOAT_MSG_RED);
end

procedure cabbot44
begin
  call Down_React_Level;
  ILLEGAL := 1;
  float_msg(self_obj, message_str(SCRIPT_CABBOT, 206), FLOAT_MSG_RED);
  call cabbotx8;
end

procedure cabbot45
begin
  call Down_React_Level;
  ILLEGAL := 1;
  float_msg(self_obj, message_str(SCRIPT_CABBOT, 207), FLOAT_MSG_RED);
end

procedure cabbot46
begin
  gsay_message(SCRIPT_CABBOT, 208, NEUTRAL_REACTION);
  call cabbotx;
end

procedure cabbot47
begin
  gsay_message(SCRIPT_CABBOT, 209, NEUTRAL_REACTION);
end

procedure cabbot48
begin
  gsay_message(SCRIPT_CABBOT, 210, NEUTRAL_REACTION);
end

procedure cabbot06a
begin
  call Down_React_Level;
  call cabbot10;
end

procedure cabbot07a
begin
  call Down_React_Level;
  call Level_To_React;
  call cabbot10;
end

procedure cabbot16a
begin
  call Bottom_React;
  call cabbot18;
end

procedure cabbot19a
begin
  call Down_React_Level;
  call Level_To_React;
  call cabbot20;
end

procedure cabbot23a
begin
  call Down_React_Level;
  call cabbot20;
end

procedure cabbot33a
begin
  call Down_React_Level;
  call cabbot34;
end

procedure cabbotx
begin
end

procedure cabbotx1
begin
  call cabbot05;
end

procedure cabbotx3
begin
  variable LVar0 := 0;
  if (obj_is_carrying_obj_pid(dude_obj, 164)) then begin
    awardex := 1;
    LVar0 := obj_carrying_pid_obj(dude_obj, 164);
    set_global_var(GVAR_BECOME_AN_INITIATE, 2);
    call Top_React;
    rm_obj_from_inven(dude_obj, LVar0);
    call cabbot27;
  end
  else begin
    call cabbot31;
  end
end

procedure cabbotx6
begin
end

procedure cabbotx7
begin
end

procedure cabbotx8
begin
end

procedure cabbot35a
begin
  gsay_message(SCRIPT_CABBOT, 181, NEUTRAL_REACTION);
  call cabbot35;
end

procedure cabbot49
begin
  gsay_message(SCRIPT_CABBOT, 211, NEUTRAL_REACTION);
end

procedure cabbot50
begin
  gsay_message(SCRIPT_CABBOT, 212, NEUTRAL_REACTION);
end

procedure cabbot51
begin
  gsay_message(SCRIPT_CABBOT, 213, NEUTRAL_REACTION);
end

procedure cabbot52
begin
  gsay_message(SCRIPT_CABBOT, 214, NEUTRAL_REACTION);
end

procedure cabbot53
begin
  gsay_message(SCRIPT_CABBOT, 215, NEUTRAL_REACTION);
end

procedure cabbot54
begin
  gsay_message(SCRIPT_CABBOT, 216, NEUTRAL_REACTION);
end

procedure cabbot55
begin
  gsay_message(SCRIPT_CABBOT, 217, NEUTRAL_REACTION);
end

procedure cabbot56
begin
  gsay_message(SCRIPT_CABBOT, 218, NEUTRAL_REACTION);
end

procedure cabbot57
begin
  gsay_message(SCRIPT_CABBOT, 219, NEUTRAL_REACTION);
end

procedure cabbot58
begin
  gsay_message(SCRIPT_CABBOT, 220, NEUTRAL_REACTION);
end

procedure cabbot59
begin
  gsay_message(SCRIPT_CABBOT, 221, NEUTRAL_REACTION);
end

procedure cabbot60
begin
  gsay_message(SCRIPT_CABBOT, 222, NEUTRAL_REACTION);
end

procedure cabbot61
begin
  gsay_message(SCRIPT_CABBOT, 223, NEUTRAL_REACTION);
end

procedure cabbot62
begin
  gsay_message(SCRIPT_CABBOT, 224, NEUTRAL_REACTION);
end

procedure cabbot63
begin
  gsay_message(SCRIPT_CABBOT, 225, NEUTRAL_REACTION);
end

procedure cabbot64
begin
  gsay_message(SCRIPT_CABBOT, 226, NEUTRAL_REACTION);
end

procedure cabbot65
begin
  gsay_message(SCRIPT_CABBOT, 227, NEUTRAL_REACTION);
end

procedure cabbot66
begin
  gsay_message(SCRIPT_CABBOT, 228, NEUTRAL_REACTION);
end

procedure cabbot67
begin
  gsay_message(SCRIPT_CABBOT, 229, NEUTRAL_REACTION);
end

procedure cabbot68
begin
  gsay_message(SCRIPT_CABBOT, 230, NEUTRAL_REACTION);
end

procedure cabbot69
begin
  gsay_message(SCRIPT_CABBOT, 231, NEUTRAL_REACTION);
end

procedure cabbotend
begin
end

procedure cabbotopen
begin
end

procedure combat
begin
  HOSTILE := 1;
end

procedure damage_p_proc
begin
  set_global_var(GVAR_ENEMY_BROTHERHOOD, 1);
end

procedure critter_p_proc
begin
  if (global_var(GVAR_ENEMY_BROTHERHOOD)) then begin
    HOSTILE := 1;
  end
  if (tile_distance_objs(self_obj, dude_obj) > 12) then begin
    HOSTILE := 0;
  end
  if (HOSTILE) then begin
    set_global_var(GVAR_ENEMY_BROTHERHOOD, 1);
    HOSTILE := 0;
    attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
  end
  else begin
    if (local_var(5) == 0) then begin
      if (global_var(GVAR_BECOME_AN_INITIATE) == 2) then begin
        add_timer_event(self_obj, game_ticks(1), 1);
      end
    end
    else begin
      if (local_var(5) == 1) then begin
        if (tile_num(self_obj) == 20906) then begin
          set_local_var(5, 2);
        end
        else begin
          animate_move_obj_to_tile(self_obj, 20906, ANIMATE_WALK);
        end
      end
    end
  end
end

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

procedure talk_p_proc
begin
  if (global_var(GVAR_BECOME_AN_INITIATE) == 5) then begin
    float_msg(self_obj, message_str(SCRIPT_CABBOT, 233), FLOAT_MSG_RED);
  end
  else begin
    call do_dialogue;
  end
end

procedure destroy_p_proc
begin
  set_global_var(GVAR_ENEMY_BROTHERHOOD, 1);
  rm_timer_event(self_obj);
  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 look_at_p_proc
begin
  script_overrides;
  display_msg(message_str(SCRIPT_CABBOT, 100));
end

procedure time_p_proc
begin
  set_local_var(5, 1);
  use_obj(Door_ptr);
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
