#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure do_dialogue;
procedure loxley00a;
procedure loxley01;
procedure loxley02;
procedure loxley02_1;
procedure loxley03;
procedure loxley04;
procedure loxley05;
procedure loxley06;
procedure loxley06b;
procedure loxley07;
procedure loxley08;
procedure loxley09;
procedure loxley10;
procedure loxley11;
procedure loxley12;
procedure loxley12b;
procedure loxley13;
procedure loxley14;
procedure loxley16;
procedure loxley17;
procedure loxley18;
procedure loxley21;
procedure loxley22;
procedure loxley23;
procedure loxley24;
procedure loxley25;
procedure loxley26;
procedure loxley27;
procedure loxley29;
procedure loxley30;
procedure loxley31;
procedure loxley32;
procedure loxley33;
procedure loxley34;
procedure loxley34_1;
procedure loxley34_2;
procedure loxley35;
procedure loxley35_1;
procedure loxley36;
procedure loxley37;
procedure loxley38;
procedure loxley39;
procedure loxley40;
procedure loxley41;
procedure loxley42;
procedure loxley43;
procedure loxley43a;
procedure loxley44;
procedure loxley47;
procedure loxley48;
procedure loxley51;
procedure loxley53;
procedure loxley54;
procedure loxley55;
procedure loxley56;
procedure loxley57;
procedure loxley58;
procedure loxley59;
procedure loxley60;
procedure loxley61;
procedure loxley62;
procedure loxley90;
procedure loxleyx;
procedure loxleyx1;
procedure loxleyx2;
procedure loxleyx3;
procedure loxleyx4;
procedure loxley00aa;
procedure loxley00ab;
procedure loxley00a1;
procedure loxley01a;
procedure loxley01b;
procedure loxley01c;
procedure loxley03a;
procedure loxley04a;
procedure loxley07a;
procedure loxley18a;
procedure loxley23a;
procedure loxley23b;
procedure loxley23c;
procedure loxley24a;
procedure loxley25a;
procedure loxley27a;
procedure loxley44a;
procedure loxley44b;
procedure loxleyend;
procedure loxley63;
procedure loxley64;
procedure loxley65;
procedure loxley66;
procedure loxley67;
procedure loxley68;
procedure loxley69;
procedure loxley70;
procedure loxley71;
procedure loxley72;
procedure loxley73;
procedure loxley74;
procedure loxley75;
procedure loxley76;
procedure loxley77;
procedure loxley78;
procedure loxley79;
procedure loxley80;
procedure loxley81;
procedure loxley82;
procedure loxley83;
procedure loxley84;
procedure loxley85;
procedure loxley86;
procedure loxley87;
procedure loxley88;
procedure loxley89;
procedure loxley91;
procedure combat;

variable rndx;
variable rndy;
variable rndz;
variable MALE;
variable HOSTILE;
variable DESTROYED;
variable KILLEDANY;
variable CAPTURED;
variable ILLEGBEFORE;
variable ILLEGAL;
variable TRESPASS;
variable CRIME;
variable floatReward;

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 loxley00;


procedure start
begin
variable LVar0 := 0;
  if (script_action == talk_proc) then begin
    call do_dialogue;
  end
  else begin
    if ((script_action == look_at_proc) or (script_action == description_proc)) then begin
      script_overrides;
      display_msg(message_str(SCRIPT_LOXLEY, 100));
    end
    else begin
      if (script_action == pickup_proc) then begin
        call combat;
      end
      else begin
        if (script_action == critter_proc) then begin
          if (HOSTILE) then begin
            HOSTILE := 0;
            attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
          end
        end
        else begin
          if (script_action == destroy_proc) then 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
        end
      end
    end
  end
end

procedure do_dialogue
begin
  call Get_Reaction;
  set_global_var(GVAR_Loxley_known, 1);
  MALE := dude_is_male;
  if (ILLEGAL) then begin
    if (ILLEGBEFORE) then begin
      start_gdialog(SCRIPT_LOXLEY, self_obj, 4, HEAD_LOXLEY, BACKGROUND_HUB);
      gsay_start;
      call loxley57;
      gsay_end;
      end_dialogue;
    end
    else begin
      if (CRIME == TRESPASS) then begin
        start_gdialog(SCRIPT_LOXLEY, self_obj, 4, HEAD_LOXLEY, BACKGROUND_HUB);
        gsay_start;
        call loxley59;
        gsay_end;
        end_dialogue;
      end
      if (CRIME > TRESPASS) then begin
        start_gdialog(SCRIPT_LOXLEY, self_obj, 4, HEAD_LOXLEY, BACKGROUND_HUB);
        gsay_start;
        call loxley58;
        gsay_end;
        end_dialogue;
      end
    end
  end
  else begin
    if (local_var(4) == 1) then begin
      if (global_var(GVAR_STEAL_NECKLACE) == 1) then begin
        start_gdialog(SCRIPT_LOXLEY, self_obj, 4, HEAD_LOXLEY, BACKGROUND_HUB);
        gsay_start;
        call loxley27;
        gsay_end;
        end_dialogue;
      end
      else begin
        if (global_var(GVAR_STEAL_NECKLACE) == 0) then begin
          if (local_var(1) > 1) then begin
            start_gdialog(SCRIPT_LOXLEY, self_obj, 4, HEAD_LOXLEY, BACKGROUND_HUB);
            gsay_start;
            call loxley01;
            gsay_end;
            end_dialogue;
          end
          else begin
            start_gdialog(SCRIPT_LOXLEY, self_obj, 4, HEAD_LOXLEY, BACKGROUND_HUB);
            gsay_start;
            call loxley24;
            gsay_end;
            end_dialogue;
          end
        end
        else begin
          display_msg(message_str(SCRIPT_LOXLEY, 267));
        end
      end
    end
    else begin
      set_local_var(4, 1);
      if (local_var(1) > 1) then begin
        start_gdialog(SCRIPT_LOXLEY, self_obj, 4, HEAD_LOXLEY, BACKGROUND_HUB);
        gsay_start;
        call loxley01;
        gsay_end;
        end_dialogue;
      end
      else begin
        start_gdialog(SCRIPT_LOXLEY, self_obj, 4, HEAD_LOXLEY, BACKGROUND_HUB);
        gsay_start;
        call loxley24;
        gsay_end;
        end_dialogue;
      end
    end
  end
  if (floatReward == 1) then begin
    floatReward := 0;
    float_msg(self_obj, message_str(SCRIPT_LOXLEY, 268), FLOAT_MSG_RED);
  end
end

procedure loxley00a
begin
  gsay_reply(SCRIPT_LOXLEY, 104);
  giq_option(4, SCRIPT_LOXLEY, message_str(SCRIPT_LOXLEY, 105) + proto_data(obj_pid(dude_obj), 1) + message_str(SCRIPT_LOXLEY, 106), loxley02, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 107, loxley00a1, BAD_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 108, loxley22, NEUTRAL_REACTION);
end

procedure loxley01
begin
  if (MALE) then begin
    gsay_reply(SCRIPT_LOXLEY, 109);
  end
  else begin
    gsay_reply(SCRIPT_LOXLEY, 110);
  end
  giq_option(4, SCRIPT_LOXLEY, message_str(SCRIPT_LOXLEY, 111) + proto_data(obj_pid(dude_obj), 1) + message_str(SCRIPT_LOXLEY, 112), loxley02, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 113, loxley01a, BAD_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 114, loxley22, NEUTRAL_REACTION);
  giq_option(5, SCRIPT_LOXLEY, 115, loxley01b, GOOD_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 116, loxley01c, BAD_REACTION);
  giq_option(-3, SCRIPT_LOXLEY, 117, loxley90, NEUTRAL_REACTION);
end

procedure loxley02
begin
  gsay_reply(SCRIPT_LOXLEY, 118);
  giq_option(4, SCRIPT_LOXLEY, 119, loxley03, GOOD_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 120, loxley02_1, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 121, loxley18, BAD_REACTION);
end

procedure loxley02_1
begin
  if (local_var(1) > 2) then begin
    call loxley08;
  end
  else begin
    call loxley09;
  end
end

procedure loxley03
begin
  gsay_reply(SCRIPT_LOXLEY, 122);
  giq_option(4, SCRIPT_LOXLEY, 123, loxley04, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 124, loxley03a, BAD_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 125, loxley17, NEUTRAL_REACTION);
end

procedure loxley04
begin
  gsay_reply(SCRIPT_LOXLEY, 126);
  giq_option(4, SCRIPT_LOXLEY, 127, loxley05, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 128, loxley04a, BAD_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 129, loxley10, NEUTRAL_REACTION);
end

procedure loxley05
begin
  gsay_reply(SCRIPT_LOXLEY, 130);
  giq_option(4, SCRIPT_LOXLEY, 131, loxley06, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 132, loxley07, NEUTRAL_REACTION);
end

procedure loxley06
begin
  if (MALE) then begin
    gsay_message(SCRIPT_LOXLEY, 133, NEUTRAL_REACTION);
  end
  else begin
    gsay_message(SCRIPT_LOXLEY, 134, NEUTRAL_REACTION);
  end
  give_exp_points(900);
  display_msg(message_str(SCRIPT_GENCHAT, 103) + 900 + message_str(SCRIPT_GENCHAT, 104));
  set_global_var(GVAR_STEAL_NECKLACE, 1);
  call loxley06b;
end

procedure loxley06b
begin
  gsay_message(SCRIPT_LOXLEY, 135, NEUTRAL_REACTION);
  call loxleyx;
end

procedure loxley07
begin
  gsay_reply(SCRIPT_LOXLEY, 136);
  giq_option(4, SCRIPT_LOXLEY, 137, loxley02_1, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 138, loxley07a, BAD_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 139, loxley03, NEUTRAL_REACTION);
end

procedure loxley08
begin
  gsay_message(SCRIPT_LOXLEY, 140, NEUTRAL_REACTION);
  call loxley34;
end

procedure loxley09
begin
  call Big_Down_React;
  gsay_message(SCRIPT_LOXLEY, 141, BAD_REACTION);
  call loxleyx1;
end

procedure loxley10
begin
  gsay_reply(SCRIPT_LOXLEY, 142);
  giq_option(4, SCRIPT_LOXLEY, 143, loxley11, BAD_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 144, loxley12, GOOD_REACTION);
end

procedure loxley11
begin
  call Big_Down_React;
  gsay_message(SCRIPT_LOXLEY, 145, BAD_REACTION);
  call loxleyx1;
end

procedure loxley12
begin
  gsay_reply(SCRIPT_LOXLEY, 146);
  giq_option(4, SCRIPT_LOXLEY, 147, loxley12b, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 148, loxley13, BAD_REACTION);
end

procedure loxley12b
begin
  gsay_message(SCRIPT_LOXLEY, 149, NEUTRAL_REACTION);
  call loxley06;
end

procedure loxley13
begin
  call Big_Down_React;
  gsay_message(SCRIPT_LOXLEY, 150, NEUTRAL_REACTION);
  call loxleyx1;
end

procedure loxley14
begin
  set_global_var(GVAR_DECKER_KNOWN, 1);
  gsay_reply(SCRIPT_LOXLEY, 151);
  giq_option(4, SCRIPT_LOXLEY, 152, loxley05, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 153, loxley07, BAD_REACTION);
end

procedure loxley16
begin
  call Big_Down_React;
  gsay_message(SCRIPT_LOXLEY, 154, NEUTRAL_REACTION);
  call loxleyx1;
end

procedure loxley17
begin
  gsay_reply(SCRIPT_LOXLEY, 155);
  giq_option(4, SCRIPT_LOXLEY, 156, loxley06, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 157, loxley05, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 158, loxley02_1, NEUTRAL_REACTION);
end

procedure loxley18
begin
  gsay_reply(SCRIPT_LOXLEY, 159);
  giq_option(4, SCRIPT_LOXLEY, 160, loxley18a, BAD_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 161, loxley12, NEUTRAL_REACTION);
end

procedure loxley21
begin
  gsay_reply(SCRIPT_LOXLEY, 162);
  giq_option(4, SCRIPT_LOXLEY, message_str(SCRIPT_LOXLEY, 163) + proto_data(obj_pid(dude_obj), 1) + message_str(SCRIPT_LOXLEY, 164), loxley02, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 165, loxley10, BAD_REACTION);
end

procedure loxley22
begin
  gsay_reply(SCRIPT_LOXLEY, 166);
  giq_option(4, SCRIPT_LOXLEY, 167, loxley04, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 168, loxley02_1, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 169, loxley10, BAD_REACTION);
end

procedure loxley23
begin
  gsay_reply(SCRIPT_LOXLEY, 170);
  giq_option(4, SCRIPT_LOXLEY, message_str(SCRIPT_LOXLEY, 171) + proto_data(obj_pid(dude_obj), 1) + message_str(SCRIPT_LOXLEY, 172), loxley02, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 173, loxley23a, BAD_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 174, loxley22, NEUTRAL_REACTION);
  giq_option(5, SCRIPT_LOXLEY, 175, loxley23b, GOOD_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 176, loxley23c, BAD_REACTION);
end

procedure loxley24
begin
  gsay_reply(SCRIPT_LOXLEY, 177);
  giq_option(4, SCRIPT_LOXLEY, 178, loxley25, BAD_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 179, loxley26, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 180, loxley24a, GOOD_REACTION);
end

procedure loxley25
begin
  gsay_reply(SCRIPT_LOXLEY, 181);
  giq_option(4, SCRIPT_LOXLEY, 182, loxley25a, GOOD_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 183, loxley26, BAD_REACTION);
end

procedure loxley26
begin
  call Big_Down_React;
  gsay_message(SCRIPT_LOXLEY, 184, NEUTRAL_REACTION);
  call loxleyx1;
end

procedure loxley27
begin
  gsay_reply(SCRIPT_LOXLEY, 185);
  giq_option(4, SCRIPT_LOXLEY, 186, loxley32, BAD_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 187, loxley33, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 188, loxley27a, NEUTRAL_REACTION);
end

procedure loxley29
begin
  variable LVar0 := 0;
  LVar0 := obj_carrying_pid_obj(dude_obj, 119);
  call Up_React;
  if (obj_is_carrying_obj_pid(dude_obj, 119)) then begin
    rm_obj_from_inven(dude_obj, LVar0);
    add_obj_to_inven(self_obj, LVar0);
  end
  give_exp_points(500);
  display_msg(message_str(SCRIPT_GENCHAT, 103) + 500 + message_str(SCRIPT_GENCHAT, 104));
  set_global_var(GVAR_STEAL_NECKLACE, 2);
  gsay_message(SCRIPT_LOXLEY, 189, GOOD_REACTION);
  call loxleyx3;
end

procedure loxley30
begin
  gsay_message(SCRIPT_LOXLEY, 190, NEUTRAL_REACTION);
end

procedure loxley31
begin
  gsay_message(SCRIPT_LOXLEY, 191, BAD_REACTION);
  call loxleyx1;
end

procedure loxley32
begin
  gsay_message(SCRIPT_LOXLEY, 192, NEUTRAL_REACTION);
  set_global_var(GVAR_STEAL_NECKLACE, 2);
  call loxleyx1;
end

procedure loxley33
begin
  gsay_message(SCRIPT_LOXLEY, 193, BAD_REACTION);
  call loxleyx4;
end

procedure loxley34
begin
  gsay_reply(0, 0);
  giq_option(4, SCRIPT_LOXLEY, 194, loxley34_1, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 195, loxley43, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 196, loxley51, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 197, loxley34_2, NEUTRAL_REACTION);
  if (global_var(GVAR_MISSING_CARAVAN) == 1) then begin
    giq_option(4, SCRIPT_LOXLEY, 198, loxley55, NEUTRAL_REACTION);
  end
  giq_option(4, SCRIPT_PATRICK, 114, loxleyx1, NEUTRAL_REACTION);
end

procedure loxley34_1
begin
  if (global_var(GVAR_VATS_STATUS) == 1) then begin
    if (local_var(1) > 1) then begin
      call loxley35;
    end
    else begin
      call loxley40;
    end
  end
  else begin
    call loxley42;
  end
end

procedure loxley34_2
begin
  if (local_var(1) > 2) then begin
    call loxley53;
  end
  else begin
    call loxley54;
  end
end

procedure loxley35
begin
  gsay_reply(SCRIPT_LOXLEY, 199);
  giq_option(4, SCRIPT_LOXLEY, 200, loxley36, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 201, loxley35_1, NEUTRAL_REACTION);
end

procedure loxley35_1
begin
  if (local_var(1) > 2) then begin
    call loxley38;
  end
  else begin
    call loxley39;
  end
end

procedure loxley36
begin
  gsay_reply(SCRIPT_LOXLEY, 202);
  giq_option(4, SCRIPT_LOXLEY, 203, loxley37, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 204, loxley35_1, NEUTRAL_REACTION);
end

procedure loxley37
begin
  gsay_reply(SCRIPT_LOXLEY, 205);
  giq_option(4, SCRIPT_LOXLEY, 206, loxley35_1, NEUTRAL_REACTION);
end

procedure loxley38
begin
  set_local_var(6, local_var(6) + 1);
  if (local_var(6) == 1) then begin
    gsay_message(SCRIPT_LOXLEY, 207, NEUTRAL_REACTION);
  end
  if (local_var(6) == 2) then begin
    gsay_message(SCRIPT_LOXLEY, 208, NEUTRAL_REACTION);
  end
  if (local_var(6) > 2) then begin
    gsay_message(SCRIPT_LOXLEY, 209, NEUTRAL_REACTION);
  end
  call loxley34;
end

procedure loxley39
begin
  gsay_message(SCRIPT_LOXLEY, 210, NEUTRAL_REACTION);
  call loxleyend;
end

procedure loxley40
begin
  gsay_reply(SCRIPT_LOXLEY, 211);
  giq_option(4, SCRIPT_LOXLEY, 212, loxley41, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 213, loxley39, NEUTRAL_REACTION);
end

procedure loxley41
begin
  gsay_reply(SCRIPT_LOXLEY, 214);
  giq_option(4, SCRIPT_LOXLEY, 215, loxley39, NEUTRAL_REACTION);
end

procedure loxley42
begin
  set_global_var(GVAR_DECKER_KNOWN, 1);
  gsay_message(SCRIPT_LOXLEY, 216, NEUTRAL_REACTION);
  call loxley34;
end

procedure loxley43
begin
  set_global_var(GVAR_DECKER_KNOWN, 1);
  gsay_reply(SCRIPT_LOXLEY, 217);
  giq_option(4, SCRIPT_LOXLEY, 218, loxley44, NEUTRAL_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 219, loxley43a, NEUTRAL_REACTION);
end

procedure loxley43a
begin
  gsay_message(SCRIPT_LOXLEY, 220, NEUTRAL_REACTION);
  call loxley34;
end

procedure loxley44
begin
  gsay_reply(SCRIPT_LOXLEY, 221);
  giq_option(4, SCRIPT_LOXLEY, 222, loxley44a, BAD_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 223, loxley44b, GOOD_REACTION);
end

procedure loxley47
begin
  gsay_message(SCRIPT_LOXLEY, 224, BAD_REACTION);
  call loxleyx1;
end

procedure loxley48
begin
  gsay_message(SCRIPT_LOXLEY, 225, NEUTRAL_REACTION);
  call loxley34;
end

procedure loxley51
begin
  gsay_message(SCRIPT_LOXLEY, 226, NEUTRAL_REACTION);
  call loxley34;
end

procedure loxley53
begin
  gsay_message(SCRIPT_LOXLEY, 227, NEUTRAL_REACTION);
  call loxley34;
end

procedure loxley54
begin
  gsay_message(SCRIPT_LOXLEY, 228, NEUTRAL_REACTION);
  call loxley34;
end

procedure loxley55
begin
  if (local_var(1) > 1) then begin
    gsay_message(SCRIPT_LOXLEY, 229, NEUTRAL_REACTION);
  end
  else begin
    gsay_message(SCRIPT_LOXLEY, 230, BAD_REACTION);
  end
end

procedure loxley56
begin
  gsay_message(SCRIPT_LOXLEY, 231, NEUTRAL_REACTION);
end

procedure loxley57
begin
  gsay_message(SCRIPT_LOXLEY, 232, NEUTRAL_REACTION);
end

procedure loxley58
begin
  gsay_message(SCRIPT_LOXLEY, 233, NEUTRAL_REACTION);
end

procedure loxley59
begin
  gsay_message(SCRIPT_LOXLEY, 234, NEUTRAL_REACTION);
end

procedure loxley60
begin
  gsay_message(SCRIPT_LOXLEY, 235, NEUTRAL_REACTION);
end

procedure loxley61
begin
  gsay_message(SCRIPT_LOXLEY, 236, NEUTRAL_REACTION);
end

procedure loxley62
begin
  gsay_message(SCRIPT_LOXLEY, 237, NEUTRAL_REACTION);
end

procedure loxley90
begin
  gsay_message(SCRIPT_LOXLEY, 265, NEUTRAL_REACTION);
  call loxleyx1;
end

procedure loxleyx
begin
end

procedure loxleyx1
begin
end

procedure loxleyx2
begin
end

procedure loxleyx3
begin
  set_map_var(3, 1);
  floatReward := 1;
end

procedure loxleyx4
begin
end

procedure loxley00aa
begin
  call Up_React;
  call loxley00a;
end

procedure loxley00ab
begin
  call Big_Down_React;
  call loxley10;
end

procedure loxley00a1
begin
  call Down_React;
  call loxley21;
end

procedure loxley01a
begin
  call Down_React;
  call loxley21;
end

procedure loxley01b
begin
  call Up_React;
  call loxley00;
end

procedure loxley01c
begin
  call Big_Down_React;
  call loxley00;
end

procedure loxley03a
begin
  call Down_React;
  call loxley16;
end

procedure loxley04a
begin
  call Down_React;
  call loxley14;
end

procedure loxley07a
begin
  call Down_React;
  call loxley10;
end

procedure loxley18a
begin
  call Down_React;
  call loxley10;
end

procedure loxley23a
begin
  call Down_React;
  call loxley21;
end

procedure loxley23b
begin
  call Up_React;
  call loxley00;
end

procedure loxley23c
begin
  call Big_Down_React;
  call loxley00;
end

procedure loxley24a
begin
  call Up_React;
  call loxley23;
end

procedure loxley25a
begin
  call Up_React;
  call loxley23;
end

procedure loxley27a
begin
  if (obj_is_carrying_obj_pid(dude_obj, 119)) then begin
    call loxley29;
  end
  else begin
    set_local_var(5, local_var(5) + 1);
    if (local_var(5) == 1) then begin
      call loxley30;
    end
    else begin
      call loxley31;
    end
  end
end

procedure loxley44a
begin
  call Down_React;
  call loxley47;
end

procedure loxley44b
begin
  call Up_React;
  call loxley48;
end

procedure loxleyend
begin
end

procedure loxley63
begin
  gsay_message(SCRIPT_LOXLEY, 238, NEUTRAL_REACTION);
end

procedure loxley64
begin
  gsay_message(SCRIPT_LOXLEY, 239, NEUTRAL_REACTION);
end

procedure loxley65
begin
  gsay_message(SCRIPT_LOXLEY, 240, NEUTRAL_REACTION);
end

procedure loxley66
begin
  gsay_message(SCRIPT_LOXLEY, 241, NEUTRAL_REACTION);
end

procedure loxley67
begin
  gsay_message(SCRIPT_LOXLEY, 242, NEUTRAL_REACTION);
end

procedure loxley68
begin
  gsay_message(SCRIPT_LOXLEY, 243, NEUTRAL_REACTION);
end

procedure loxley69
begin
  gsay_message(SCRIPT_LOXLEY, 244, NEUTRAL_REACTION);
end

procedure loxley70
begin
  gsay_message(SCRIPT_LOXLEY, 245, NEUTRAL_REACTION);
end

procedure loxley71
begin
  gsay_message(SCRIPT_LOXLEY, 246, NEUTRAL_REACTION);
end

procedure loxley72
begin
  gsay_message(SCRIPT_LOXLEY, 247, NEUTRAL_REACTION);
end

procedure loxley73
begin
  gsay_message(SCRIPT_LOXLEY, 248, NEUTRAL_REACTION);
end

procedure loxley74
begin
  gsay_message(SCRIPT_LOXLEY, 249, NEUTRAL_REACTION);
end

procedure loxley75
begin
  gsay_message(SCRIPT_LOXLEY, 250, NEUTRAL_REACTION);
end

procedure loxley76
begin
  gsay_message(SCRIPT_LOXLEY, 251, NEUTRAL_REACTION);
end

procedure loxley77
begin
  gsay_message(SCRIPT_LOXLEY, 252, NEUTRAL_REACTION);
end

procedure loxley78
begin
  gsay_message(SCRIPT_LOXLEY, 253, NEUTRAL_REACTION);
end

procedure loxley79
begin
  gsay_message(SCRIPT_LOXLEY, 254, NEUTRAL_REACTION);
end

procedure loxley80
begin
  gsay_message(SCRIPT_LOXLEY, 255, NEUTRAL_REACTION);
end

procedure loxley81
begin
  gsay_message(SCRIPT_LOXLEY, 256, NEUTRAL_REACTION);
end

procedure loxley82
begin
  gsay_message(SCRIPT_LOXLEY, 257, NEUTRAL_REACTION);
end

procedure loxley83
begin
  gsay_message(SCRIPT_LOXLEY, 258, NEUTRAL_REACTION);
end

procedure loxley84
begin
  gsay_message(SCRIPT_LOXLEY, 259, NEUTRAL_REACTION);
end

procedure loxley85
begin
  gsay_message(SCRIPT_LOXLEY, 260, NEUTRAL_REACTION);
end

procedure loxley86
begin
  gsay_message(SCRIPT_LOXLEY, 261, NEUTRAL_REACTION);
end

procedure loxley87
begin
  gsay_message(SCRIPT_LOXLEY, 262, NEUTRAL_REACTION);
end

procedure loxley88
begin
  gsay_message(SCRIPT_LOXLEY, 263, NEUTRAL_REACTION);
end

procedure loxley89
begin
  gsay_message(SCRIPT_LOXLEY, 264, NEUTRAL_REACTION);
end

procedure loxley91
begin
  gsay_message(SCRIPT_LOXLEY, 266, NEUTRAL_REACTION);
end

procedure combat
begin
  HOSTILE := 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

procedure loxley00
begin
  gsay_reply(SCRIPT_LOXLEY, 101);
  giq_option(4, SCRIPT_LOXLEY, 102, loxley00aa, GOOD_REACTION);
  giq_option(4, SCRIPT_LOXLEY, 103, loxley00ab, BAD_REACTION);
end
