#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure combat;
procedure critter_p_proc;
procedure pickup_p_proc;
procedure talk_p_proc;
procedure destroy_p_proc;
procedure look_at_p_proc;
procedure RecalcDate;
procedure RecalcDateString;
procedure damage_p_proc;
procedure FGTDriver00;
procedure FGTDriver01;
procedure FGTDriver02;
procedure FGTDriver03;
procedure FGTDriver04;
procedure FGTDriver04a;
procedure FGTDriver05;
procedure FGTDriver06;
procedure FGTDriver07;
procedure FGTDriver08;
procedure FGTDriver10;
procedure FGTDriver10a;
procedure FGTDriver11;
procedure FGTDriver12;
procedure FGTDriver13;
procedure FGTDriver14;
procedure FGTDriver15;
procedure FGTDriver17;
procedure FGTDriver18;
procedure FGTDriver19;
procedure FGTDriver20;
procedure FGTDriver21a;
procedure FGTDriver21b;
procedure FGTDriver21c;
procedure FGTDriver27;
procedure FGTDriver28;
procedure FGTDriver29;
procedure FGTDriver30;
procedure FGTDriver31;
procedure FGTDriver32;
procedure FGTDriver33;
procedure FGTDriver34;
procedure FGTDriver35;

variable hostile1;
variable Only_Once := 1;
variable DayString := "None";

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, 37);
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_AI_PACKET, AI_MERCHANT);
	end
	if (script_action == look_at_proc) then begin
		call look_at_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 == 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

procedure combat
begin
	hostile1 := 1;
end

procedure critter_p_proc
begin
	if (hostile1) then begin
		hostile1 := 0;
		attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
	end
end

procedure pickup_p_proc
begin
	call FGTDriver10;
end

procedure talk_p_proc
begin
	variable LVar0 := 0;
	call Get_Reaction;
	if (local_var(10) == 1) then begin
		if (local_var(7) < (game_time / (10 * 60 * 60 * 24 * 365))) then begin
			set_local_var(10, 0);
		end
		else begin
			if ((local_var(6) < get_month) or (local_var(6) == 12) and (get_month == 1) and ((local_var(6) != 1) or (get_month != 12))) then begin
				set_local_var(10, 0);
			end
			else begin
				if ((local_var(5) < get_day) and ((local_var(6) != 1) or (get_month != 12))) then begin
					set_local_var(10, 0);
				end
			end
		end
	end
	call RecalcDate;
	LVar0 := local_var(5);
	if (local_var(8) > 0) then begin
		call FGTDriver14;
	end
	else begin
		if (map_var(35) == 1) then begin
			call FGTDriver15;
		end
		else begin
			if (global_var(GVAR_FARGO_JOB) == 3) then begin
				start_gdialog(SCRIPT_FGTCARVN, self_obj, 4, -1, -1);
				gsay_start;
				call FGTDriver19;
				gsay_end;
				end_dialogue;
			end
			else begin
				if (global_var(GVAR_FARGO_JOB) == 4) then begin
					start_gdialog(SCRIPT_FGTCARVN, self_obj, 4, -1, -1);
					gsay_start;
					call FGTDriver27;
					gsay_end;
					end_dialogue;
				end
				else begin
					if (map_var(36) == 0) then begin
						call FGTDriver00;
					end
					else begin
						if ((map_var(36) == 1) and (local_var(10) == 0)) then begin
							start_gdialog(SCRIPT_FGTCARVN, self_obj, 4, -1, -1);
							gsay_start;
							if (local_var(9) == 0) then begin
								call FGTDriver01;
							end
							else begin
								call FGTDriver03;
							end
							gsay_end;
							end_dialogue;
						end
						else begin
							if ((local_var(10) == 1) and (LVar0 == get_day)) then begin
								start_gdialog(SCRIPT_FGTCARVN, self_obj, 4, -1, -1);
								gsay_start;
								call FGTDriver28;
								gsay_end;
								end_dialogue;
							end
							else begin
								if ((local_var(10) == 1) and (LVar0 != get_day)) then begin
									start_gdialog(SCRIPT_FGTCARVN, self_obj, 4, -1, -1);
									gsay_start;
									call FGTDriver29;
									gsay_end;
									end_dialogue;
								end
							end
						end
					end
				end
			end
		end
	end
	set_local_var(4, 1);
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 look_at_p_proc
begin
	script_overrides;
	display_msg(message_str(SCRIPT_FGTCARVN, 100));
end

procedure RecalcDate
begin
	variable LVar0 := 0;
	variable LVar1 := 0;
	variable LVar2 := 0;
	LVar0 := get_day;
	if ((LVar0 >= 1) and (LVar0 <= 8)) then begin
		LVar0 := 8;
		LVar1 := get_month;
		LVar2 := game_time / (10 * 60 * 60 * 24 * 365);
	end
	else begin
		if ((LVar0 > 8) and (LVar0 <= 18)) then begin
			LVar0 := 18;
			LVar1 := get_month;
			LVar2 := game_time / (10 * 60 * 60 * 24 * 365);
		end
		else begin
			if ((LVar0 > 18) and (LVar0 <= 28)) then begin
				LVar0 := 28;
				LVar1 := get_month;
				LVar2 := game_time / (10 * 60 * 60 * 24 * 365);
			end
			else begin
				if (LVar0 > 28) then begin
					LVar0 := 8;
					LVar1 := get_month;
					if (LVar1 == 12) then begin
						LVar1 := 1;
						LVar2 := (game_time / (10 * 60 * 60 * 24 * 365)) + 1;
					end
					else begin
						LVar1 := LVar1 + 1;
						LVar2 := game_time / (10 * 60 * 60 * 24 * 365);
					end
				end
			end
		end
	end
	set_local_var(5, LVar0);
	set_local_var(6, LVar1);
	set_local_var(7, LVar2);
end

procedure RecalcDateString
begin
	variable LVar0 := 0;
	variable LVar1 := 0;
	call RecalcDate;
	LVar0 := local_var(6);
	LVar1 := local_var(5);
	if (LVar0 == 1) then begin
		DayString := message_str(SCRIPT_FGTCARVN, 204);
	end
	else begin
		if (LVar0 == 2) then begin
			DayString := message_str(SCRIPT_FGTCARVN, 205);
		end
		else begin
			if (LVar0 == 3) then begin
				DayString := message_str(SCRIPT_FGTCARVN, 206);
			end
			else begin
				if (LVar0 == 4) then begin
					DayString := message_str(SCRIPT_FGTCARVN, 207);
				end
				else begin
					if (LVar0 == 5) then begin
						DayString := message_str(SCRIPT_FGTCARVN, 208);
					end
					else begin
						if (LVar0 == 6) then begin
							DayString := message_str(SCRIPT_FGTCARVN, 209);
						end
						else begin
							if (LVar0 == 7) then begin
								DayString := message_str(SCRIPT_FGTCARVN, 210);
							end
							else begin
								if (LVar0 == 8) then begin
									DayString := message_str(SCRIPT_FGTCARVN, 211);
								end
								else begin
									if (LVar0 == 9) then begin
										DayString := message_str(SCRIPT_FGTCARVN, 212);
									end
									else begin
										if (LVar0 == 10) then begin
											DayString := message_str(SCRIPT_FGTCARVN, 213);
										end
										else begin
											if (LVar0 == 11) then begin
												DayString := message_str(SCRIPT_FGTCARVN, 214);
											end
											else begin
												if (LVar0 == 12) then begin
													DayString := message_str(SCRIPT_FGTCARVN, 215);
												end
											end
										end
									end
								end
							end
						end
					end
				end
			end
		end
	end
	if (LVar1 == 8) then begin
		DayString := DayString + message_str(SCRIPT_FGTCARVN, 197);
	end
	else begin
		if (LVar1 == 18) then begin
			DayString := DayString + message_str(SCRIPT_FGTCARVN, 198);
		end
		else begin
			if (LVar1 == 28) then begin
				DayString := DayString + message_str(SCRIPT_FGTCARVN, 199);
			end
		end
	end
end

procedure damage_p_proc
begin
	variable LVar0 := 0;
	LVar0 := obj_pid(source_obj);
	if (party_member_obj(LVar0) != 0) then begin
		set_global_var(GVAR_ENEMY_HUB, 1);
	end
end

procedure FGTDriver00
begin
	if (local_var(4) == 0) then begin
		float_msg(self_obj, message_str(SCRIPT_FGTCARVN, 101), FLOAT_MSG_RED);
		set_local_var(4, 1);
	end
	else begin
		float_msg(self_obj, message_str(SCRIPT_FGTCARVN, 102), FLOAT_MSG_RED);
	end
end

procedure FGTDriver01
begin
	if (global_var(GVAR_JUNKTOWN) == 0) then begin
		set_global_var(GVAR_JUNKTOWN, 1);
	end
	if (global_var(GVAR_ANGELS_BONEYARD) == 0) then begin
		set_global_var(GVAR_ANGELS_BONEYARD, 1);
	end
	if (global_var(GVAR_BROTHERHOOD_OF_STEEL) == 0) then begin
		set_global_var(GVAR_BROTHERHOOD_OF_STEEL, 1);
	end
	gsay_reply(SCRIPT_FGTCARVN, 103);
	giq_option(4, SCRIPT_FGTCARVN, 104, FGTDriver02, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_FGTCARVN, 105, FGTDriver02, NEUTRAL_REACTION);
end

procedure FGTDriver02
begin
	variable LVar0 := 0;
	call RecalcDateString;
	LVar0 := local_var(5);
	if (LVar0 == get_day) then begin
		gsay_reply(SCRIPT_FGTCARVN, message_str(SCRIPT_FGTCARVN, 106) + message_str(SCRIPT_FGTCARVN, 107));
	end
	else begin
		gsay_reply(SCRIPT_FGTCARVN, message_str(SCRIPT_FGTCARVN, 106) + message_str(SCRIPT_FGTCARVN, 108) + DayString + message_str(SCRIPT_FGTCARVN, 111));
	end
	call FGTDriver04;
end

procedure FGTDriver03
begin
	variable LVar0 := 0;
	if (local_var(1) != 1) then begin
		call RecalcDateString;
		LVar0 := local_var(5);
		if (LVar0 == get_day) then begin
			gsay_reply(SCRIPT_FGTCARVN, message_str(SCRIPT_FGTCARVN, 107));
		end
		else begin
			gsay_reply(SCRIPT_FGTCARVN, message_str(SCRIPT_FGTCARVN, 108) + DayString + message_str(SCRIPT_FGTCARVN, 111));
		end
		call FGTDriver04;
	end
	else begin
		gsay_reply(SCRIPT_FGTCARVN, 112);
		call FGTDriver04;
	end
end

procedure FGTDriver04
begin
	giq_option(4, SCRIPT_FGTCARVN, 113, FGTDriver04a, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_FGTCARVN, 114, FGTDriver05, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_FGTCARVN, 115, FGTDriver06, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_FGTCARVN, 116, FGTDriver07, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_FGTCARVN, 117, FGTDriver07, NEUTRAL_REACTION);
end

procedure FGTDriver04a
begin
	variable LVar0 := 0;
	set_local_var(10, 1);
	call RecalcDate;
	LVar0 := local_var(5);
	if (LVar0 == get_day) then begin
		call FGTDriver17;
	end
	else begin
		call FGTDriver18;
	end
end

procedure FGTDriver05
begin
	set_local_var(10, 0);
	gsay_message(SCRIPT_FGTCARVN, 118, NEUTRAL_REACTION);
end

procedure FGTDriver06
begin
	set_local_var(10, 0);
	gsay_message(SCRIPT_FGTCARVN, 120, NEUTRAL_REACTION);
end

procedure FGTDriver07
begin
	gsay_message(SCRIPT_FGTCARVN, 121, NEUTRAL_REACTION);
end

procedure FGTDriver08
begin
	gsay_message(SCRIPT_FGTCARVN, 123, NEUTRAL_REACTION);
end

procedure FGTDriver10
begin
	if (local_var(8) == 0) then begin
		set_local_var(8, 1);
		set_map_var(35, 1);
		set_map_var(10, 0);
		gsay_reply(SCRIPT_FGTCARVN, 125);
		giq_option(4, SCRIPT_FGTCARVN, 126, FGTDriver08, NEUTRAL_REACTION);
		giq_option(4, SCRIPT_FGTCARVN, 127, FGTDriver10a, NEUTRAL_REACTION);
		giq_option(4, SCRIPT_FGTCARVN, 128, FGTDriver31, BAD_REACTION);
		giq_option(-3, SCRIPT_FGTCARVN, 130, FGTDriver31, BAD_REACTION);
	end
	else begin
		gsay_message(SCRIPT_FGTCARVN, 131, BAD_REACTION);
		call combat;
	end
end

procedure FGTDriver10a
begin
	if (is_success(roll_vs_skill(dude_obj, 14, 20)) == 1) then begin
		call FGTDriver11;
	end
	else begin
		call FGTDriver12;
	end
end

procedure FGTDriver11
begin
	set_map_var(36, 0);
	set_map_var(35, 1);
	set_map_var(10, 0);
	gsay_message(SCRIPT_FGTCARVN, 132, NEUTRAL_REACTION);
end

procedure FGTDriver12
begin
	gsay_message(SCRIPT_FGTCARVN, 133, BAD_REACTION);
	call combat;
end

procedure FGTDriver13
begin
	float_msg(self_obj, message_str(SCRIPT_FGTCARVN, 137), FLOAT_MSG_RED);
end

procedure FGTDriver14
begin
	if (local_var(8) > 0) then begin
		float_msg(self_obj, message_str(SCRIPT_FGTCARVN, 138), FLOAT_MSG_RED);
	end
	else begin
		float_msg(self_obj, message_str(SCRIPT_FGTCARVN, 139), FLOAT_MSG_RED);
		call FGTDriver31;
	end
end

procedure FGTDriver15
begin
	variable LVar0 := 0;
	LVar0 := random(1, 4);
	if (LVar0 == 1) then begin
		float_msg(self_obj, message_str(SCRIPT_FGTCARVN, 140), FLOAT_MSG_RED);
	end
	else begin
		if (LVar0 == 2) then begin
			float_msg(self_obj, message_str(SCRIPT_FGTCARVN, 141), FLOAT_MSG_RED);
		end
		else begin
			if (LVar0 == 3) then begin
				float_msg(self_obj, message_str(SCRIPT_FGTCARVN, 142), FLOAT_MSG_RED);
			end
			else begin
				if (LVar0 == 4) then begin
					float_msg(self_obj, message_str(SCRIPT_FGTCARVN, 143), FLOAT_MSG_RED);
				end
			end
		end
	end
end

procedure FGTDriver17
begin
	gsay_reply(SCRIPT_FGTCARVN, 145);
	call FGTDriver33;
	call FGTDriver20;
end

procedure FGTDriver18
begin
	call RecalcDateString;
	gsay_reply(SCRIPT_FGTCARVN, message_str(SCRIPT_FGTCARVN, 146) + DayString + message_str(SCRIPT_FGTCARVN, 153));
	giq_option(4, SCRIPT_FGTCARVN, 154, FGTDriver30, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_FGTCARVN, 155, FGTDriver34, NEUTRAL_REACTION);
end

procedure FGTDriver19
begin
	set_map_var(35, 1);
	set_map_var(10, 0);
	set_global_var(GVAR_FARGO_JOB, 0);
	gsay_message(SCRIPT_FGTCARVN, 156, BAD_REACTION);
end

procedure FGTDriver20
begin
	giq_option(4, SCRIPT_FGTCARVN, 157, FGTDriver21a, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_FGTCARVN, 158, FGTDriver21b, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_FGTCARVN, 152, FGTDriver21c, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_FGTCARVN, 159, FGTDriver34, NEUTRAL_REACTION);
end

procedure FGTDriver21a
begin
	variable LVar0 := 0;
	set_global_var(GVAR_FARGO_TRADERS_STATUS, 1);
	LVar0 := random(1, 7);
	if (LVar0 == 1) then begin
		gsay_message(SCRIPT_FGTCARVN, 160, NEUTRAL_REACTION);
	end
	else begin
		if (LVar0 == 2) then begin
			gsay_message(SCRIPT_FGTCARVN, 161, NEUTRAL_REACTION);
		end
		else begin
			if (LVar0 == 3) then begin
				gsay_message(SCRIPT_FGTCARVN, 162, NEUTRAL_REACTION);
			end
			else begin
				if (LVar0 == 4) then begin
					gsay_message(SCRIPT_FGTCARVN, 163, NEUTRAL_REACTION);
				end
				else begin
					if (LVar0 == 5) then begin
						gsay_message(SCRIPT_FGTCARVN, 167, NEUTRAL_REACTION);
					end
					else begin
						if (LVar0 == 6) then begin
							gsay_message(SCRIPT_FGTCARVN, 168, NEUTRAL_REACTION);
						end
						else begin
							if (LVar0 == 7) then begin
								gsay_message(SCRIPT_FGTCARVN, 169, NEUTRAL_REACTION);
							end
						end
					end
				end
			end
		end
	end
	LVar0 := random(1, 4);
	if (LVar0 < 4) then begin
		load_map(58, 3);
	end
	else begin
		load_map(10, 1);
	end
end

procedure FGTDriver21b
begin
	variable LVar0 := 0;
	set_global_var(GVAR_FARGO_TRADERS_STATUS, 1);
	LVar0 := random(1, 7);
	if (LVar0 == 1) then begin
		gsay_message(SCRIPT_FGTCARVN, 160, NEUTRAL_REACTION);
	end
	else begin
		if (LVar0 == 2) then begin
			gsay_message(SCRIPT_FGTCARVN, 161, NEUTRAL_REACTION);
		end
		else begin
			if (LVar0 == 3) then begin
				gsay_message(SCRIPT_FGTCARVN, 162, NEUTRAL_REACTION);
			end
			else begin
				if (LVar0 == 4) then begin
					gsay_message(SCRIPT_FGTCARVN, 163, NEUTRAL_REACTION);
				end
				else begin
					if (LVar0 == 5) then begin
						gsay_message(SCRIPT_FGTCARVN, 164, NEUTRAL_REACTION);
					end
					else begin
						if (LVar0 == 6) then begin
							gsay_message(SCRIPT_FGTCARVN, 165, NEUTRAL_REACTION);
						end
						else begin
							if (LVar0 == 7) then begin
								gsay_message(SCRIPT_FGTCARVN, 166, NEUTRAL_REACTION);
							end
						end
					end
				end
			end
		end
	end
	LVar0 := random(1, 4);
	if (LVar0 < 3) then begin
		load_map(56, 3);
	end
	else begin
		load_map(28, 1);
	end
end

procedure FGTDriver21c
begin
	variable LVar0 := 0;
	set_global_var(GVAR_FARGO_TRADERS_STATUS, 1);
	LVar0 := random(1, 8);
	if (LVar0 == 1) then begin
		gsay_message(SCRIPT_FGTCARVN, 160, NEUTRAL_REACTION);
	end
	else begin
		if (LVar0 == 2) then begin
			gsay_message(SCRIPT_FGTCARVN, 161, NEUTRAL_REACTION);
		end
		else begin
			if (LVar0 == 3) then begin
				gsay_message(SCRIPT_FGTCARVN, 162, NEUTRAL_REACTION);
			end
			else begin
				if (LVar0 == 4) then begin
					gsay_message(SCRIPT_FGTCARVN, 163, NEUTRAL_REACTION);
				end
				else begin
					if (LVar0 == 5) then begin
						gsay_message(SCRIPT_FGTCARVN, 216, NEUTRAL_REACTION);
					end
					else begin
						if (LVar0 == 6) then begin
							gsay_message(SCRIPT_FGTCARVN, 217, NEUTRAL_REACTION);
						end
						else begin
							if (LVar0 == 7) then begin
								gsay_message(SCRIPT_FGTCARVN, 218, NEUTRAL_REACTION);
							end
							else begin
								if (LVar0 == 8) then begin
									gsay_message(SCRIPT_FGTCARVN, 219, NEUTRAL_REACTION);
								end
							end
						end
					end
				end
			end
		end
	end
	LVar0 := random(1, 4);
	if (LVar0 < 4) then begin
		load_map(59, 3);
	end
	else begin
		load_map(13, 1);
	end
end

procedure FGTDriver27
begin
	gsay_reply(SCRIPT_FGTCARVN, 185);
	giq_option(4, SCRIPT_FGTCARVN, 186, FGTDriver04a, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_FGTCARVN, 187, FGTDriver05, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_FGTCARVN, 188, FGTDriver06, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_FGTCARVN, 189, FGTDriver07, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_FGTCARVN, 190, FGTDriver07, NEUTRAL_REACTION);
end

procedure FGTDriver28
begin
	gsay_reply(SCRIPT_FGTCARVN, 191);
	giq_option(4, SCRIPT_FGTCARVN, 192, FGTDriver17, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_FGTCARVN, 193, FGTDriver35, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_FGTCARVN, 194, FGTDriver07, NEUTRAL_REACTION);
end

procedure FGTDriver29
begin
	variable LVar0 := 0;
	call RecalcDateString;
	LVar0 := local_var(5);
	gsay_message(SCRIPT_FGTCARVN, message_str(SCRIPT_FGTCARVN, 196) + DayString + message_str(SCRIPT_FGTCARVN, 203) + message_str(SCRIPT_FGTCARVN, 195), NEUTRAL_REACTION);
end

procedure FGTDriver30
begin
	set_local_var(10, 1);
end

procedure FGTDriver31
begin
	call combat;
end

procedure FGTDriver32
begin
end

procedure FGTDriver33
begin
	variable LVar0 := 0;
	set_local_var(10, 0);
	set_global_var(GVAR_FARGO_JOB, 1);
	LVar0 := local_var(9);
	set_local_var(9, LVar0 + 1);
end

procedure FGTDriver34
begin
	set_local_var(10, 0);
end

procedure FGTDriver35
begin
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