#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure do_dialogue;
procedure first;
procedure notfirst;
procedure garl00;
procedure garl01;
procedure garl01a;
procedure garl01b;
procedure garl01c;
procedure garl01d;
procedure garl02;
procedure garl03;
procedure garl03a;
procedure garl04;
procedure garl04a;
procedure garl04b;
procedure garl04c;
procedure garl05;
procedure garl06;
procedure garl06a;
procedure garl07;
procedure garl08;
procedure garl09;
procedure garl10;
procedure garl11;
procedure garl12;
procedure garl12a;
procedure garl12b;
procedure garl15;
procedure garl15a;
procedure garl16;
procedure garl17;
procedure garl17a;
procedure garl18;
procedure garl19;
procedure garl20;
procedure garl21;
procedure garl22;
procedure garl23;
procedure garl24;
procedure garl25;
procedure garl26;
procedure garl27;
procedure garl28;
procedure garl29;
procedure garl30;
procedure garl31;
procedure garl32;
procedure garl33;
procedure garl34;
procedure garl35;
procedure garl36;
procedure garl37;
procedure garl37a;
procedure garl38;
procedure garl38a;
procedure garl39;
procedure garl39a;
procedure garl40;
procedure garl41;
procedure garl42;
procedure garl43;
procedure garlx;
procedure garlend;
procedure freetandi;
procedure garlcbt;
procedure honorcbt;
procedure honorarea;
procedure garlbarter;
procedure return_to_map;
procedure Critter_Action;
procedure damage_p_proc;

import variable women_killed;
import variable signal_women;
import variable killing_women;
import variable Garls_Inven_Ptr;

variable HOSTILE;
variable only_once := 1;
variable temp;
variable tandi_pid_ptr;

import variable Cell_Door_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 (only_once) then begin
		only_once := 0;
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_TEAM_NUM, 6);
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_AI_PACKET, AI_RAIDER_LEADER);
	end
	if (script_action == talk_proc) then begin
		call do_dialogue;
	end
	else begin
		if (script_action == timed_event_proc) then begin
			if (fixed_param == 1) then begin
				if (global_var(GVAR_GARLS_FRIEND) != 1) then begin
					dialogue_system_enter;
				end
			end
			else begin
				if (fixed_param == 2) then begin
					call freetandi;
				end
				else begin
					if (fixed_param == 3) then begin
						call honorarea;
					end
					else begin
						if (fixed_param == 4) then begin
							call return_to_map;
							call freetandi;
						end
					end
				end
			end
		end
		else begin
			if (script_action == look_at_proc) then begin
				script_overrides;
				display_msg(message_str(SCRIPT_GARL, 100));
			end
			else begin
				if (script_action == pickup_proc) then begin
					HOSTILE := 1;
				end
				else begin
					if (script_action == critter_proc) then begin
						call Critter_Action;
						if (HOSTILE) then begin
							HOSTILE := 0;
							attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
						end
					end
					else begin
						if (script_action == damage_proc) then begin
							call damage_p_proc;
						end
						else begin
							if (script_action == destroy_proc) then begin
								if (local_var(7) == 1) then begin
									move_to(dude_obj, local_var(6), 0);
									move_obj_inven_to_obj(Garls_Inven_Ptr, dude_obj);
									set_global_var(GVAR_TANDI_STATUS, 5);
									set_map_var(2, 2);
									obj_unlock(Cell_Door_Ptr);
								end
								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
								if (local_var(7) == 0) then begin
									set_global_var(GVAR_ENEMY_RAIDERS, 1);
									set_global_var(GVAR_GARLS_FRIEND, 0);
								end
								set_global_var(GVAR_GARL_DEAD, 1);
								set_global_var(GVAR_TOTAL_RAIDERS, global_var(GVAR_TOTAL_RAIDERS) - 1);
							end
						end
					end
				end
			end
		end
	end
end

procedure do_dialogue
begin
	if (elevation(self_obj) == 1) then begin
		float_msg(self_obj, message_str(SCRIPT_GARL, 208), FLOAT_MSG_RED);
		add_timer_event(self_obj, 5, 4);
	end
	else begin
		if (killing_women) then begin
			call garl39a;
		end
		else begin
			set_local_var(3, 1);
			call Get_Reaction;
			start_gdialog(SCRIPT_GARL, self_obj, 4, -1, -1);
			gsay_start;
			if (women_killed > 1) then begin
				call garl11;
			end
			else begin
				if (global_var(GVAR_MISTAKEN_ID)) then begin
					call garl01;
				end
				else begin
					if (local_var(4) < 1) then begin
						call first;
						set_local_var(4, 1);
					end
					else begin
						call notfirst;
					end
				end
			end
			gsay_end;
			end_dialogue;
		end
	end
	if (obj_carrying_pid_obj(dude_obj, 212)) then begin
		rm_obj_from_inven(dude_obj, tandi_pid_ptr);
		destroy_object(tandi_pid_ptr);
		set_global_var(GVAR_TANDI_STATUS, 5);
		set_map_var(2, 2);
		obj_unlock(Cell_Door_Ptr);
		add_timer_event(self_obj, 1, 2);
	end
	else begin
		if (obj_carrying_pid_obj(self_obj, 212)) then begin
			rm_obj_from_inven(self_obj, tandi_pid_ptr);
			destroy_object(tandi_pid_ptr);
			call garl20;
		end
	end
end

procedure first
begin
	if (global_var(GVAR_TANDI_STATUS) > 1) then begin
		call garl43;
	end
	else begin
		if (global_var(GVAR_TANDI_STATUS) > 0) then begin
			call garl12;
		end
		else begin
			call garl32;
		end
	end
end

procedure notfirst
begin
	if (global_var(GVAR_TANDI_STATUS) > 1) then begin
		call garl43;
	end
	else begin
		if (global_var(GVAR_TANDI_STATUS) > 0) then begin
			call garl22;
		end
		else begin
			call garl41;
		end
	end
end

procedure garl00
begin
	gsay_message(SCRIPT_GARL, 101, NEUTRAL_REACTION);
	call garlcbt;
end

procedure garl01
begin
	gsay_reply(SCRIPT_GARL, 102);
	giq_option(-3, SCRIPT_GARL, 207, garl09, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_GARL, 103, garl01a, NEUTRAL_REACTION);
	giq_option(5, SCRIPT_GARL, 104, garl01b, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_GARL, 105, garl01c, NEUTRAL_REACTION);
end

procedure garl01a
begin
	call garl02;
end

procedure garl01b
begin
	call garl03;
end

procedure garl01c
begin
	call garl04;
end

procedure garl01d
begin
	gsay_reply(SCRIPT_GARL, 106);
	giq_option(4, SCRIPT_GARL, 107, garl02, NEUTRAL_REACTION);
	giq_option(5, SCRIPT_GARL, 108, garl03, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_GARL, 109, garl04, NEUTRAL_REACTION);
end

procedure garl02
begin
	gsay_message(SCRIPT_GARL, 110, NEUTRAL_REACTION);
	set_global_var(GVAR_MISTAKEN_ID, 0);
	call garlcbt;
end

procedure garl03
begin
	gsay_reply(SCRIPT_GARL, 111);
	giq_option(8, SCRIPT_GARL, 112, garl03a, NEUTRAL_REACTION);
end

procedure garl03a
begin
	set_global_var(GVAR_MISTAKEN_ID, 0);
	call garlcbt;
end

procedure garl04
begin
	gsay_reply(SCRIPT_GARL, 113);
	giq_option(6, SCRIPT_GARL, 114, garl04a, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_GARL, 115, garl04b, NEUTRAL_REACTION);
end

procedure garl04a
begin
	call garl06;
end

procedure garl04b
begin
	call garl05;
end

procedure garl04c
begin
	gsay_reply(SCRIPT_GARL, 116);
	giq_option(6, SCRIPT_GARL, 117, garl06, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_GARL, 118, garl05, NEUTRAL_REACTION);
end

procedure garl05
begin
	gsay_message(SCRIPT_GARL, 119, NEUTRAL_REACTION);
	set_global_var(GVAR_MISTAKEN_ID, 0);
	call garlcbt;
end

procedure garl06
begin
	gsay_reply(SCRIPT_GARL, 120);
	if (global_var(GVAR_TANDI_STATUS) == 1) then begin
		giq_option(6, SCRIPT_GARL, 121, garl06a, NEUTRAL_REACTION);
	end
	giq_option(6, SCRIPT_GARL, 122, garl10, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_GARL, 123, garl10, NEUTRAL_REACTION);
end

procedure garl06a
begin
	if (is_success(do_check(dude_obj, 3, 0)) or is_success(roll_vs_skill(dude_obj, 14, 10))) then begin
		call garl08;
	end
	else begin
		call garl09;
	end
end

procedure garl07
begin
	gsay_message(SCRIPT_GARL, 124, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_GARL, 125, garl08, NEUTRAL_REACTION);
end

procedure garl08
begin
	gsay_message(SCRIPT_GARL, 126, NEUTRAL_REACTION);
	set_global_var(GVAR_MISTAKEN_ID, 0);
	call freetandi;
end

procedure garl09
begin
	gsay_message(SCRIPT_GARL, 127, NEUTRAL_REACTION);
	call garlcbt;
end

procedure garl10
begin
	gsay_message(SCRIPT_GARL, 128, NEUTRAL_REACTION);
	set_global_var(GVAR_MISTAKEN_ID, 0);
	call garlcbt;
end

procedure garl11
begin
	if (women_killed > 1) then begin
		women_killed := 0;
		gsay_message(SCRIPT_GARL, 129, NEUTRAL_REACTION);
		call garlcbt;
	end
end

procedure garl12
begin
	gsay_reply(SCRIPT_GARL, 130);
	if (global_var(GVAR_TALKED_ABOUT_TANDI) == 1) then begin
		giq_option(4, SCRIPT_GARL, 131, garl12b, NEUTRAL_REACTION);
		giq_option(5, SCRIPT_GARL, 133, garl15, NEUTRAL_REACTION);
	end
	else begin
		giq_option(5, SCRIPT_GARL, 200, garl12a, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_GARL, 132, garlcbt, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_GARL, 134, garl17, NEUTRAL_REACTION);
end

procedure garl12a
begin
	gsay_message(SCRIPT_GARL, 201, NEUTRAL_REACTION);
end

procedure garl12b
begin
	if (is_success(roll_vs_skill(dude_obj, 14, 10)) or is_success(do_check(dude_obj, 3, 0))) then begin
		call garl15;
	end
	else begin
		call garl10;
	end
end

procedure garl15
begin
	gsay_reply(SCRIPT_GARL, 140);
	if (has_skill(dude_obj, 14) >= 45) then begin
		giq_option(6, SCRIPT_GARL, 141, garl15a, NEUTRAL_REACTION);
	end
	giq_option(6, SCRIPT_GARL, 142, garl18, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_GARL, 143, garl21, NEUTRAL_REACTION);
	giq_option(5, SCRIPT_GARL, 203, garl28, NEUTRAL_REACTION);
end

procedure garl15a
begin
	if (is_success(roll_vs_skill(dude_obj, 14, 10)) or is_success(do_check(dude_obj, 3, 0))) then begin
		call garl16;
	end
	else begin
		call garl17;
	end
end

procedure garl16
begin
	gsay_message(SCRIPT_GARL, 145, NEUTRAL_REACTION);
	call freetandi;
end

procedure garl17
begin
	gsay_message(SCRIPT_GARL, 146, NEUTRAL_REACTION);
	call garlcbt;
end

procedure garl17a
begin
	gsay_message(SCRIPT_GARL, 204, NEUTRAL_REACTION);
	call garlcbt;
end

procedure garl18
begin
	tandi_pid_ptr := create_object_sid(212, 0, 0, -1);
	add_obj_to_inven(self_obj, tandi_pid_ptr);
	gsay_message(SCRIPT_GARL, 147, NEUTRAL_REACTION);
	call garlbarter;
end

procedure garl19
begin
	float_msg(self_obj, message_str(SCRIPT_GARL, 148), FLOAT_MSG_RED);
	call freetandi;
end

procedure garl20
begin
	if (dude_is_male) then begin
		float_msg(self_obj, message_str(SCRIPT_GARL, 149), FLOAT_MSG_RED);
	end
	else begin
		float_msg(self_obj, message_str(SCRIPT_GARL, 205), FLOAT_MSG_RED);
	end
	call garlcbt;
end

procedure garl21
begin
	gsay_message(SCRIPT_GARL, 150, NEUTRAL_REACTION);
	call garlcbt;
end

procedure garl22
begin
	gsay_reply(SCRIPT_GARL, 151);
	giq_option(4, SCRIPT_GARL, 152, garl23, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_GARL, 153, garl24, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_GARL, 207, garl17, NEUTRAL_REACTION);
end

procedure garl23
begin
	gsay_message(SCRIPT_GARL, 155, NEUTRAL_REACTION);
end

procedure garl24
begin
	gsay_reply(SCRIPT_GARL, 156);
	giq_option(4, SCRIPT_GARL, 157, garl25, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_GARL, 158, garl18, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_GARL, 159, garl15a, NEUTRAL_REACTION);
end

procedure garl25
begin
	gsay_reply(SCRIPT_GARL, 160);
	giq_option(4, SCRIPT_GARL, 161, garl26, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_GARL, 162, garl27, NEUTRAL_REACTION);
end

procedure garl26
begin
	gsay_message(SCRIPT_GARL, 163, NEUTRAL_REACTION);
	call garlcbt;
end

procedure garl27
begin
	gsay_reply(SCRIPT_GARL, 164);
	giq_option(4, SCRIPT_GARL, 165, garl26, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_GARL, 166, garl28, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_GARL, 167, garl29, NEUTRAL_REACTION);
end

procedure garl28
begin
	gsay_reply(SCRIPT_GARL, 168);
	giq_option(4, SCRIPT_GARL, 169, honorcbt, NEUTRAL_REACTION);
end

procedure garl29
begin
	gsay_reply(SCRIPT_GARL, 170);
	giq_option(4, SCRIPT_GARL, 171, garlcbt, NEUTRAL_REACTION);
end

procedure garl30
begin
	gsay_message(SCRIPT_GARL, 172, NEUTRAL_REACTION);
	call freetandi;
end

procedure garl31
begin
	gsay_message(SCRIPT_GARL, 173, NEUTRAL_REACTION);
end

procedure garl32
begin
	gsay_reply(SCRIPT_GARL, 174);
	giq_option(4, SCRIPT_GARL, 175, garl33, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_GARL, 176, garl34, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_GARL, 154, garl23, NEUTRAL_REACTION);
end

procedure garl33
begin
	if (dude_is_male) then begin
		gsay_message(SCRIPT_GARL, 177, NEUTRAL_REACTION);
	end
	else begin
		gsay_message(SCRIPT_GARL, 206, NEUTRAL_REACTION);
	end
	call garlcbt;
end

procedure garl34
begin
	gsay_reply(SCRIPT_GARL, 178);
	giq_option(6, SCRIPT_GARL, 179, garl35, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_GARL, 180, garl33, NEUTRAL_REACTION);
end

procedure garl35
begin
	gsay_reply(SCRIPT_GARL, 181);
	giq_option(4, SCRIPT_GARL, 182, garl37, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_GARL, 183, garl36, NEUTRAL_REACTION);
end

procedure garl36
begin
	gsay_message(SCRIPT_GARL, 184, NEUTRAL_REACTION);
end

procedure garl37
begin
	gsay_reply(SCRIPT_GARL, 185);
	giq_option(4, SCRIPT_GARL, 186, garl38, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_GARL, 187, garl37a, NEUTRAL_REACTION);
end

procedure garl37a
begin
	signal_women := 2;
	killing_women := 1;
	add_timer_event(self_obj, game_ticks(15), 1);
end

procedure garl38
begin
	women_killed := 0;
	if (dude_is_male) then begin
		gsay_message(SCRIPT_GARL, 188, NEUTRAL_REACTION);
	end
	else begin
		gsay_message(SCRIPT_GARL, 189, NEUTRAL_REACTION);
	end
	call garlcbt;
end

procedure garl38a
begin
	women_killed := 0;
	if (dude_is_male) then begin
		float_msg(self_obj, message_str(SCRIPT_GARL, 188), FLOAT_MSG_RED);
	end
	else begin
		float_msg(self_obj, message_str(SCRIPT_GARL, 189), FLOAT_MSG_RED);
	end
	call garlcbt;
end

procedure garl39
begin
	gsay_message(SCRIPT_GARL, 190, NEUTRAL_REACTION);
	call garlcbt;
end

procedure garl39a
begin
	killing_women := 0;
	if (women_killed > 1) then begin
		call garl40;
	end
	else begin
		call garl38a;
	end
end

procedure garl40
begin
	women_killed := 0;
	call Top_React;
	float_msg(self_obj, message_str(SCRIPT_GARL, 191), FLOAT_MSG_RED);
	temp := 500;
	display_msg(message_str(SCRIPT_RAIDMAP, 100) + temp + message_str(SCRIPT_RAIDMAP, 102));
	give_exp_points(temp);
	set_global_var(GVAR_PLAYER_REPUTATION, global_var(GVAR_PLAYER_REPUTATION) + -2);
	set_global_var(GVAR_GARLS_FRIEND, 1);
end

procedure garl41
begin
	gsay_reply(SCRIPT_GARL, 192);
	giq_option(4, SCRIPT_GARL, 193, garl23, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_GARL, 194, garl42, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_GARL, 195, garl23, NEUTRAL_REACTION);
end

procedure garl42
begin
	gsay_message(SCRIPT_GARL, 196, NEUTRAL_REACTION);
end

procedure garl43
begin
	if (dude_is_male) then begin
		gsay_message(SCRIPT_GARL, 197, NEUTRAL_REACTION);
	end
	else begin
		gsay_message(SCRIPT_GARL, 198, NEUTRAL_REACTION);
	end
	call garlcbt;
end

procedure garlx
begin
end

procedure garlend
begin
end

procedure freetandi
begin
	set_global_var(GVAR_TANDI_STATUS, 5);
	set_map_var(2, 2);
	obj_unlock(Cell_Door_Ptr);
end

procedure garlcbt
begin
	HOSTILE := 1;
end

procedure honorcbt
begin
	add_timer_event(self_obj, game_ticks(1), 3);
end

procedure honorarea
begin
	variable LVar0 := 0;
	set_local_var(6, tile_num(dude_obj));
	set_local_var(7, 1);
	move_to(dude_obj, 20102, 1);
	move_to(self_obj, 20301, 1);
	LVar0 := critter_inven_obj(dude_obj, 0);
	rm_obj_from_inven(dude_obj, LVar0);
	move_obj_inven_to_obj(self_obj, Garls_Inven_Ptr);
	move_obj_inven_to_obj(dude_obj, Garls_Inven_Ptr);
	add_obj_to_inven(dude_obj, LVar0);
	wield_obj_critter(dude_obj, LVar0);
	if (party_member_obj(16777292) != 0) then begin
		move_to(party_member_obj(16777292), tile_num_in_direction(tile_num(dude_obj), 0, 10), 1);
	end
	if (party_member_obj(16777518) != 0) then begin
		move_to(party_member_obj(16777518), tile_num_in_direction(tile_num(dude_obj), 1, 10), 1);
	end
	if (party_member_obj(16777426) != 0) then begin
		move_to(party_member_obj(16777426), tile_num_in_direction(tile_num(dude_obj), 2, 10), 1);
	end
	if (party_member_obj(16777338) != 0) then begin
		move_to(party_member_obj(16777338), tile_num_in_direction(tile_num(dude_obj), 4, 10), 1);
	end
	if (party_member_obj(16777279) != 0) then begin
		move_to(party_member_obj(16777279), tile_num_in_direction(tile_num(dude_obj), 5, 10), 1);
	end
	critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_TEAM_NUM, 87);
	critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_AI_PACKET, AI_GARL_HONOR);
	call garlcbt;
end

procedure garlbarter
begin
	gdialog_mod_barter(0);
	gsay_message(SCRIPT_GARL, "", NEUTRAL_REACTION);
end

procedure return_to_map
begin
	move_to(dude_obj, local_var(6), 0);
	move_obj_inven_to_obj(Garls_Inven_Ptr, dude_obj);
	set_global_var(GVAR_TANDI_STATUS, 5);
	set_map_var(2, 2);
	obj_unlock(Cell_Door_Ptr);
end

procedure Critter_Action
begin
	if (global_var(GVAR_TANDI_STATUS) == 2) then begin
		set_global_var(GVAR_ENEMY_RAIDERS, 1);
	end
	else begin
		if (global_var(GVAR_MISTAKEN_ID)) then begin
			set_global_var(GVAR_ENEMY_RAIDERS, 0);
		end
		else begin
			if (global_var(GVAR_TANDI_ESCAPE)) then begin
				set_global_var(GVAR_ENEMY_RAIDERS, 1);
			end
			if (obj_can_see_obj(self_obj, dude_obj)) then begin
				if (global_var(GVAR_RAID_LOOTING)) then begin
					set_global_var(GVAR_ENEMY_RAIDERS, 1);
				end
			end
		end
	end
	if (global_var(GVAR_ENEMY_RAIDERS) and obj_can_see_obj(self_obj, dude_obj)) then begin
		HOSTILE := 1;
	end
	if (tile_distance_objs(self_obj, dude_obj) > 12) then begin
		HOSTILE := 0;
	end
end

procedure damage_p_proc
begin
	if (local_var(7) == 0) then begin
		set_global_var(GVAR_ENEMY_RAIDERS, 1);
	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