#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 timed_event_p_proc;
procedure SendInsideHouse;
procedure Lorenzo00;
procedure Lorenzo01;
procedure Lorenzo02;
procedure Lorenzo02a;
procedure Lorenzo04;
procedure Lorenzo05;
procedure Lorenzo06;
procedure Lorenzo07;
procedure Lorenzo08;
procedure Lorenzo09;
procedure Lorenzo09a;
procedure Lorenzo12;
procedure Lorenzo13;
procedure Lorenzo14;
procedure Lorenzo15;
procedure Lorenzo15a;
procedure Lorenzo15b;
procedure Lorenzo15c;
procedure Lorenzo15d;
procedure Lorenzo15e;
procedure Lorenzo15f;
procedure Lorenzo16;
procedure Lorenzo16a;
procedure Lorenzo19;
procedure Lorenzo20;
procedure Lorenzo21;
procedure Lorenzo22;
procedure Lorenzo23;
procedure Lorenzo24;
procedure Lorenzo25;
procedure Lorenzo26;
procedure Lorenzo27;
procedure Lorenzo28;
procedure Lorenzo29;
procedure Lorenzo30;
procedure Lorenzo31;
procedure Lorenzo32;
procedure Lorenzo33;
procedure Lorenzo34;
procedure Lorenzo35;
procedure Lorenzo36;
procedure Lorenzo37;
procedure Lorenzo38;
procedure Lorenzo39;
procedure Lorenzo40;
procedure Lorenzo41;

variable hostile1;
variable Only_Once := 1;
variable SetDayNight;
variable Destination;
variable LastMove;
variable VaultCount;

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, 73);
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_AI_PACKET, AI_HUB_UNDERGROUND);
		LastMove := 23309;
	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
					else begin
						if (script_action == timed_event_proc) then begin
							call timed_event_p_proc;
						end
					end
				end
			end
		end
	end
end

procedure combat
begin
	hostile1 := 1;
end

procedure critter_p_proc
begin
	variable LVar0 := 0;
	if (hostile1) then begin
		hostile1 := 0;
		attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
	end
	if (SetDayNight == 0) then begin
		add_timer_event(self_obj, game_ticks(random(5, 20)), 1);
		SetDayNight := 1;
	end
	if (map_var(55) == 2) then begin
		hostile1 := 1;
		float_msg(self_obj, message_str(SCRIPT_LORENZO, 247), FLOAT_MSG_RED);
	end
	else begin
		if (map_var(55) == 1) then begin
			set_map_var(55, 0);
			VaultCount := VaultCount + 1;
			float_msg(self_obj, message_str(SCRIPT_LORENZO, 246), FLOAT_MSG_RED);
			if (VaultCount >= 2) then begin
				hostile1 := 1;
				float_msg(self_obj, message_str(SCRIPT_LORENZO, 247), FLOAT_MSG_RED);
			end
		end
	end
	LVar0 := tile_num(self_obj);
	if ((LVar0 == 22312) or (LVar0 == 23106) or (LVar0 == 24106)) then begin
		if (anim_busy(self_obj) == 0) then begin
			if (has_trait(1, self_obj, 10) != 0) then begin
				anim(self_obj, 1000, 0);
			end
		end
	end
	else begin
		if (LVar0 == 21112) then begin
			if (anim_busy(self_obj) == 0) then begin
				if (has_trait(1, self_obj, 10) != 5) then begin
					anim(self_obj, 1000, 5);
				end
			end
		end
	end
end

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

procedure talk_p_proc
begin
	variable LVar0 := 0;
	if (item_caps_total(dude_obj) < 1000) then begin
		LVar0 := item_caps_adjust(self_obj, 3000);
	end
	else begin
		if (item_caps_total(dude_obj) < 2000) then begin
			LVar0 := item_caps_adjust(self_obj, 2000);
		end
		else begin
			LVar0 := item_caps_adjust(self_obj, 1000);
		end
	end
	call Get_Reaction;
	if (map_var(22) == 1) then begin
		call Lorenzo04;
	end
	else begin
		if ((map_var(22) == 0) and ((map_var(11) == 1) or (map_var(44) == 1))) then begin
			call Lorenzo00;
		end
		else begin
			if ((local_var(6) > 0) and (((game_time / (10 * 60 * 60 * 24)) - local_var(5)) > 10)) then begin
				call Lorenzo01;
			end
			else begin
				if (local_var(6) > 0) then begin
					call Lorenzo02;
				end
				else begin
					call Lorenzo05;
				end
			end
		end
	end
	LVar0 := item_caps_adjust(self_obj, -item_caps_total(self_obj));
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_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
end

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

procedure timed_event_p_proc
begin
	call SendInsideHouse;
end

procedure SendInsideHouse
begin
	variable LVar0 := 0;
	Destination := 0;
	LVar0 := random(10, 30);
	while(Destination == 0) do begin
		Destination := random(1, 5);
		if (Destination == 1) then begin
			Destination := 23309;
		end
		else begin
			if (Destination == 2) then begin
				Destination := 21112;
			end
			else begin
				if (Destination == 3) then begin
					Destination := 22312;
				end
				else begin
					if (Destination == 4) then begin
						Destination := 23106;
					end
					else begin
						if (Destination == 5) then begin
							Destination := 24104;
						end
					end
				end
			end
		end
		if (Destination == LastMove) then begin
			Destination := 0;
		end
	end
	LastMove := Destination;
	reg_anim_func(2, self_obj);
	reg_anim_func(1, 1);
	reg_anim_obj_move_to_tile(self_obj, Destination, -1);
	reg_anim_func(3, 0);
	rm_timer_event(self_obj);
	add_timer_event(self_obj, game_ticks(LVar0), 1);
end

procedure Lorenzo00
begin
	if (dude_is_male) then begin
		float_msg(self_obj, message_str(SCRIPT_LORENZO, 101), FLOAT_MSG_RED);
	end
	else begin
		float_msg(self_obj, message_str(SCRIPT_LORENZO, 102), FLOAT_MSG_RED);
	end
	set_map_var(22, 1);
	set_map_var(18, 1);
end

procedure Lorenzo01
begin
	variable LVar0 := 0;
	start_gdialog(SCRIPT_LORENZO, self_obj, 4, -1, -1);
	gsay_start;
	LVar0 := (local_var(6) / 10 * ((game_time / (10 * 60 * 60 * 24)) - local_var(5))) + local_var(6);
	gsay_reply(SCRIPT_LORENZO, 103);
	giq_option(4, SCRIPT_LORENZO, 104, Lorenzo14, BAD_REACTION);
	giq_option(4, SCRIPT_LORENZO, 105, Lorenzo15, BAD_REACTION);
	if ((local_var(6) > 0) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, message_str(SCRIPT_LORENZO, 106) + LVar0 + message_str(SCRIPT_LORENZO, 107), Lorenzo16, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LORENZO, 108, Lorenzo15, BAD_REACTION);
	gsay_end;
	end_dialogue;
end

procedure Lorenzo02
begin
	variable LVar0 := 0;
	start_gdialog(SCRIPT_LORENZO, self_obj, 4, -1, -1);
	gsay_start;
	LVar0 := (local_var(6) / 10 * ((game_time / (10 * 60 * 60 * 24)) - local_var(5))) + local_var(6);
	gsay_reply(SCRIPT_LORENZO, 109);
	giq_option(4, SCRIPT_LORENZO, 110, Lorenzo02a, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 111, Lorenzo08, NEUTRAL_REACTION);
	if (local_var(6) > 0) then begin
		giq_option(4, SCRIPT_LORENZO, message_str(SCRIPT_LORENZO, 106) + LVar0 + message_str(SCRIPT_LORENZO, 107), Lorenzo09, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LORENZO, 112, Lorenzo12, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_LORENZO, 113, Lorenzo13, NEUTRAL_REACTION);
	gsay_end;
	end_dialogue;
end

procedure Lorenzo02a
begin
	if (is_success(roll_vs_skill(dude_obj, 14, 0))) then begin
		call Lorenzo06;
	end
	else begin
		call Lorenzo07;
	end
end

procedure Lorenzo04
begin
	float_msg(self_obj, message_str(SCRIPT_LORENZO, 114), FLOAT_MSG_RED);
	call combat;
end

procedure Lorenzo05
begin
	start_gdialog(SCRIPT_LORENZO, self_obj, 4, -1, -1);
	gsay_start;
	set_map_var(18, 1);
	gsay_reply(SCRIPT_LORENZO, 115);
	giq_option(4, SCRIPT_LORENZO, 110, Lorenzo02a, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 116, Lorenzo19, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 117, Lorenzo20, BAD_REACTION);
	giq_option(4, SCRIPT_LORENZO, 112, Lorenzo12, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_LORENZO, 113, Lorenzo21, NEUTRAL_REACTION);
	gsay_end;
	end_dialogue;
end

procedure Lorenzo06
begin
	gsay_reply(SCRIPT_LORENZO, 118);
	if (global_var(GVAR_MISSING_CARAVAN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 119, Lorenzo22, NEUTRAL_REACTION);
	end
	if (global_var(GVAR_DECKER_KNOWN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 120, Lorenzo23, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LORENZO, 121, Lorenzo24, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 122, Lorenzo25, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 123, Lorenzo26, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 124, Lorenzo27, NEUTRAL_REACTION);
end

procedure Lorenzo07
begin
	if (map_var(19) == 0) then begin
		gsay_message(SCRIPT_LORENZO, 125, BAD_REACTION);
		set_map_var(19, 1);
	end
	else begin
		set_map_var(22, 1);
		gsay_message(SCRIPT_LORENZO, 126, BAD_REACTION);
	end
end

procedure Lorenzo08
begin
	gsay_message(SCRIPT_LORENZO, 127, NEUTRAL_REACTION);
end

procedure Lorenzo09
begin
	variable LVar0 := 0;
	variable LVar1 := 0;
	LVar0 := (local_var(6) / 10 * ((game_time / (10 * 60 * 60 * 24)) - local_var(5))) + local_var(6);
	if (item_caps_total(dude_obj) >= LVar0) then begin
		LVar1 := item_caps_adjust(dude_obj, -1 * LVar0);
		set_local_var(6, 0);
		set_local_var(5, 0);
		gsay_reply(SCRIPT_LORENZO, 128);
		giq_option(4, SCRIPT_LORENZO, 130, Lorenzo09a, NEUTRAL_REACTION);
		giq_option(4, SCRIPT_LORENZO, 131, Lorenzo19, NEUTRAL_REACTION);
		giq_option(4, SCRIPT_LORENZO, 132, Lorenzo12, NEUTRAL_REACTION);
	end
	else begin
		gsay_reply(SCRIPT_LORENZO, 129);
		giq_option(4, SCRIPT_LORENZO, 130, Lorenzo07, NEUTRAL_REACTION);
		giq_option(4, SCRIPT_LORENZO, 131, Lorenzo08, NEUTRAL_REACTION);
		giq_option(4, SCRIPT_LORENZO, 132, Lorenzo12, NEUTRAL_REACTION);
	end
end

procedure Lorenzo09a
begin
	if (is_success(roll_vs_skill(dude_obj, 14, 20))) then begin
		call Lorenzo06;
	end
	else begin
		call Lorenzo07;
	end
end

procedure Lorenzo12
begin
	gsay_message(SCRIPT_LORENZO, 133, NEUTRAL_REACTION);
end

procedure Lorenzo13
begin
	set_map_var(22, 1);
	gsay_message(SCRIPT_LORENZO, 134, BAD_REACTION);
end

procedure Lorenzo14
begin
	set_map_var(44, 1);
	set_map_var(11, 1);
	if (dude_is_male) then begin
		gsay_message(SCRIPT_LORENZO, 135, BAD_REACTION);
	end
	else begin
		gsay_message(SCRIPT_LORENZO, 136, BAD_REACTION);
	end
	call combat;
end

procedure Lorenzo15
begin
	variable LVar0 := 0;
	LVar0 := (local_var(6) / 10 * ((game_time / (10 * 60 * 60 * 24)) - local_var(5))) + local_var(6);
	gsay_reply(SCRIPT_LORENZO, 248);
	if (item_caps_total(dude_obj) < LVar0) then begin
		giq_option(4, SCRIPT_LORENZO, 249, Lorenzo15a, NEUTRAL_REACTION);
	end
	else begin
		giq_option(4, SCRIPT_LORENZO, 250, Lorenzo15b, NEUTRAL_REACTION);
		giq_option(4, SCRIPT_LORENZO, message_str(SCRIPT_LORENZO, 251) + (LVar0 * 3 / 4) + message_str(SCRIPT_LORENZO, 252), Lorenzo15c, NEUTRAL_REACTION);
		giq_option(4, SCRIPT_LORENZO, message_str(SCRIPT_LORENZO, 251) + (LVar0 / 2) + message_str(SCRIPT_LORENZO, 252), Lorenzo15d, NEUTRAL_REACTION);
		giq_option(4, SCRIPT_LORENZO, message_str(SCRIPT_LORENZO, 251) + (LVar0 / 4) + message_str(SCRIPT_LORENZO, 252), Lorenzo15e, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LORENZO, 253, Lorenzo15f, BAD_REACTION);
end

procedure Lorenzo15a
begin
	variable LVar0 := 0;
	variable LVar1 := 0;
	LVar0 := (local_var(6) / 10 * ((game_time / (10 * 60 * 60 * 24)) - local_var(5))) + local_var(6);
	LVar1 := item_caps_adjust(dude_obj, -item_caps_total(dude_obj));
	set_map_var(22, 1);
	set_local_var(6, 0);
	set_local_var(5, 0);
	gsay_message(SCRIPT_LORENZO, 254, NEUTRAL_REACTION);
	gsay_message(SCRIPT_LORENZO, 259, BAD_REACTION);
end

procedure Lorenzo15b
begin
	variable LVar0 := 0;
	variable LVar1 := 0;
	LVar0 := (local_var(6) / 10 * ((game_time / (10 * 60 * 60 * 24)) - local_var(5))) + local_var(6);
	LVar1 := item_caps_adjust(dude_obj, -1 * LVar0);
	set_map_var(22, 1);
	set_local_var(6, 0);
	set_local_var(5, 0);
	gsay_message(SCRIPT_LORENZO, 260, BAD_REACTION);
end

procedure Lorenzo15c
begin
	variable LVar0 := 0;
	variable LVar1 := 0;
	LVar0 := (local_var(6) / 10 * ((game_time / (10 * 60 * 60 * 24)) - local_var(5))) + local_var(6);
	if (is_success(roll_vs_skill(dude_obj, 14, -20)) or is_success(do_check(dude_obj, 3, -1))) then begin
		LVar1 := item_caps_adjust(dude_obj, -1 * (LVar0 * 3 / 4));
		set_map_var(22, 1);
		set_local_var(6, 0);
		set_local_var(5, 0);
		gsay_message(SCRIPT_LORENZO, message_str(SCRIPT_LORENZO, 255) + (LVar0 * 3 / 4) + message_str(SCRIPT_LORENZO, 256), NEUTRAL_REACTION);
		gsay_message(SCRIPT_LORENZO, 259, BAD_REACTION);
	end
	else begin
		set_map_var(22, 1);
		set_map_var(44, 1);
		set_map_var(11, 1);
		set_local_var(6, 0);
		set_local_var(5, 0);
		gsay_message(SCRIPT_LORENZO, 257, BAD_REACTION);
		call combat;
	end
end

procedure Lorenzo15d
begin
	variable LVar0 := 0;
	variable LVar1 := 0;
	LVar0 := (local_var(6) / 10 * ((game_time / (10 * 60 * 60 * 24)) - local_var(5))) + local_var(6);
	if (is_success(roll_vs_skill(dude_obj, 14, -30)) or is_success(do_check(dude_obj, 3, -2))) then begin
		LVar1 := item_caps_adjust(dude_obj, -1 * (LVar0 / 2));
		set_map_var(22, 1);
		set_local_var(6, 0);
		set_local_var(5, 0);
		gsay_message(SCRIPT_LORENZO, message_str(SCRIPT_LORENZO, 255) + (LVar0 / 2) + message_str(SCRIPT_LORENZO, 256), NEUTRAL_REACTION);
		gsay_message(SCRIPT_LORENZO, 259, BAD_REACTION);
	end
	else begin
		set_map_var(22, 1);
		set_map_var(44, 1);
		set_map_var(11, 1);
		set_local_var(6, 0);
		set_local_var(5, 0);
		gsay_message(SCRIPT_LORENZO, 257, BAD_REACTION);
		call combat;
	end
end

procedure Lorenzo15e
begin
	variable LVar0 := 0;
	variable LVar1 := 0;
	LVar0 := (local_var(6) / 10 * ((game_time / (10 * 60 * 60 * 24)) - local_var(5))) + local_var(6);
	if (is_success(roll_vs_skill(dude_obj, 14, -40)) or is_success(do_check(dude_obj, 3, -3))) then begin
		LVar1 := item_caps_adjust(dude_obj, -1 * (LVar0 / 4));
		set_map_var(22, 1);
		set_local_var(6, 0);
		set_local_var(5, 0);
		gsay_message(SCRIPT_LORENZO, message_str(SCRIPT_LORENZO, 255) + (LVar0 / 4) + message_str(SCRIPT_LORENZO, 256), NEUTRAL_REACTION);
		gsay_message(SCRIPT_LORENZO, 259, BAD_REACTION);
	end
	else begin
		set_map_var(22, 1);
		set_map_var(44, 1);
		set_map_var(11, 1);
		set_local_var(6, 0);
		set_local_var(5, 0);
		gsay_message(SCRIPT_LORENZO, 257, BAD_REACTION);
		call combat;
	end
end

procedure Lorenzo15f
begin
	set_map_var(22, 1);
	set_map_var(44, 1);
	set_map_var(11, 1);
	set_local_var(6, 0);
	set_local_var(5, 0);
	gsay_message(SCRIPT_LORENZO, 258, BAD_REACTION);
	call combat;
end

procedure Lorenzo16
begin
	variable LVar0 := 0;
	variable LVar1 := 0;
	LVar0 := (local_var(6) / 10 * ((game_time / (10 * 60 * 60 * 24)) - local_var(5))) + local_var(6);
	if (item_caps_total(dude_obj) >= LVar0) then begin
		LVar1 := item_caps_adjust(dude_obj, -1 * LVar0);
		set_local_var(6, 0);
		set_local_var(5, 0);
		gsay_reply(SCRIPT_LORENZO, 138);
		giq_option(4, SCRIPT_LORENZO, 139, Lorenzo16a, NEUTRAL_REACTION);
		giq_option(4, SCRIPT_LORENZO, 140, Lorenzo28, NEUTRAL_REACTION);
		giq_option(4, SCRIPT_LORENZO, 141, Lorenzo15, NEUTRAL_REACTION);
	end
	else begin
		gsay_message(SCRIPT_LORENZO, 261, BAD_REACTION);
		call Lorenzo15;
	end
end

procedure Lorenzo16a
begin
	if (is_success(roll_vs_skill(dude_obj, 14, -10))) then begin
		call Lorenzo06;
	end
	else begin
		call Lorenzo07;
	end
end

procedure Lorenzo19
begin
	gsay_reply(SCRIPT_LORENZO, 143);
	if (local_var(7) >= 800) then begin
		giq_option(4, SCRIPT_LORENZO, message_str(SCRIPT_LORENZO, 144) + message_str(SCRIPT_LORENZO, 145) + message_str(SCRIPT_LORENZO, 150), Lorenzo29, NEUTRAL_REACTION);
	end
	if (local_var(7) >= 600) then begin
		giq_option(4, SCRIPT_LORENZO, message_str(SCRIPT_LORENZO, 144) + message_str(SCRIPT_LORENZO, 146) + message_str(SCRIPT_LORENZO, 150), Lorenzo30, NEUTRAL_REACTION);
	end
	if (local_var(7) >= 400) then begin
		giq_option(4, SCRIPT_LORENZO, message_str(SCRIPT_LORENZO, 144) + message_str(SCRIPT_LORENZO, 147) + message_str(SCRIPT_LORENZO, 150), Lorenzo31, NEUTRAL_REACTION);
	end
	if (local_var(7) >= 200) then begin
		giq_option(4, SCRIPT_LORENZO, message_str(SCRIPT_LORENZO, 144) + message_str(SCRIPT_LORENZO, 148) + message_str(SCRIPT_LORENZO, 150), Lorenzo32, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LORENZO, message_str(SCRIPT_LORENZO, 144) + message_str(SCRIPT_LORENZO, 149) + message_str(SCRIPT_LORENZO, 150), Lorenzo33, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 151, Lorenzo34, NEUTRAL_REACTION);
end

procedure Lorenzo20
begin
	set_map_var(44, 1);
	set_map_var(11, 1);
	gsay_message(SCRIPT_LORENZO, 152, BAD_REACTION);
	call combat;
end

procedure Lorenzo21
begin
	set_map_var(22, 1);
	gsay_message(SCRIPT_LORENZO, 153, NEUTRAL_REACTION);
end

procedure Lorenzo22
begin
	gsay_reply(SCRIPT_LORENZO, 154);
	if (global_var(GVAR_MISSING_CARAVAN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 155, Lorenzo35, NEUTRAL_REACTION);
	end
	if (global_var(GVAR_DECKER_KNOWN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 156, Lorenzo23, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LORENZO, 157, Lorenzo24, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 158, Lorenzo25, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 159, Lorenzo26, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 160, Lorenzo27, NEUTRAL_REACTION);
end

procedure Lorenzo23
begin
	set_map_var(21, 1);
	gsay_reply(SCRIPT_LORENZO, 161);
	if (global_var(GVAR_MISSING_CARAVAN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 162, Lorenzo22, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LORENZO, 163, Lorenzo36, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 164, Lorenzo24, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 165, Lorenzo25, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 166, Lorenzo26, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 167, Lorenzo27, NEUTRAL_REACTION);
end

procedure Lorenzo24
begin
	gsay_reply(SCRIPT_LORENZO, 168);
	if (global_var(GVAR_MISSING_CARAVAN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 169, Lorenzo22, NEUTRAL_REACTION);
	end
	if (global_var(GVAR_DECKER_KNOWN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 170, Lorenzo23, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LORENZO, 171, Lorenzo37, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 172, Lorenzo25, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 173, Lorenzo26, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 174, Lorenzo27, NEUTRAL_REACTION);
end

procedure Lorenzo25
begin
	gsay_reply(SCRIPT_LORENZO, 175);
	if (global_var(GVAR_MISSING_CARAVAN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 176, Lorenzo22, NEUTRAL_REACTION);
	end
	if (global_var(GVAR_DECKER_KNOWN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 177, Lorenzo23, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LORENZO, 178, Lorenzo24, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 179, Lorenzo38, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 180, Lorenzo26, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 181, Lorenzo27, NEUTRAL_REACTION);
end

procedure Lorenzo26
begin
	gsay_reply(SCRIPT_LORENZO, 182);
	if (global_var(GVAR_MISSING_CARAVAN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 183, Lorenzo22, NEUTRAL_REACTION);
	end
	if (global_var(GVAR_DECKER_KNOWN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 184, Lorenzo23, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LORENZO, 185, Lorenzo24, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 186, Lorenzo25, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 187, Lorenzo39, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 188, Lorenzo27, NEUTRAL_REACTION);
end

procedure Lorenzo27
begin
	set_global_var(GVAR_DECKER_KNOWN, 1);
	set_map_var(21, 1);
	gsay_reply(SCRIPT_LORENZO, 189);
	if (global_var(GVAR_MISSING_CARAVAN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 190, Lorenzo22, NEUTRAL_REACTION);
	end
	if (global_var(GVAR_DECKER_KNOWN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 191, Lorenzo23, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LORENZO, 192, Lorenzo24, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 193, Lorenzo25, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 194, Lorenzo26, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 195, Lorenzo40, NEUTRAL_REACTION);
end

procedure Lorenzo28
begin
	set_map_var(22, 1);
	gsay_message(SCRIPT_LORENZO, 196, BAD_REACTION);
end

procedure Lorenzo29
begin
	variable LVar0 := 0;
	set_local_var(6, 1000);
	set_local_var(5, game_time / (10 * 60 * 60 * 24));
	LVar0 := item_caps_adjust(dude_obj, 1000);
	if (local_var(7) <= 1000) then begin
		set_local_var(7, 1000);
	end
	gsay_message(SCRIPT_LORENZO, 197, NEUTRAL_REACTION);
end

procedure Lorenzo30
begin
	variable LVar0 := 0;
	set_local_var(6, 800);
	set_local_var(5, game_time / (10 * 60 * 60 * 24));
	LVar0 := item_caps_adjust(dude_obj, 800);
	if (local_var(7) <= 800) then begin
		set_local_var(7, 800);
	end
	gsay_message(SCRIPT_LORENZO, 198, NEUTRAL_REACTION);
end

procedure Lorenzo31
begin
	variable LVar0 := 0;
	set_local_var(6, 600);
	set_local_var(5, game_time / (10 * 60 * 60 * 24));
	LVar0 := item_caps_adjust(dude_obj, 600);
	if (local_var(7) <= 600) then begin
		set_local_var(7, 600);
	end
	gsay_message(SCRIPT_LORENZO, 199, NEUTRAL_REACTION);
end

procedure Lorenzo32
begin
	variable LVar0 := 0;
	set_local_var(6, 400);
	set_local_var(5, game_time / (10 * 60 * 60 * 24));
	LVar0 := item_caps_adjust(dude_obj, 400);
	if (local_var(7) <= 400) then begin
		set_local_var(7, 400);
	end
	gsay_message(SCRIPT_LORENZO, 200, NEUTRAL_REACTION);
end

procedure Lorenzo33
begin
	variable LVar0 := 0;
	set_local_var(6, 200);
	set_local_var(5, game_time / (10 * 60 * 60 * 24));
	LVar0 := item_caps_adjust(dude_obj, 200);
	if (local_var(7) <= 200) then begin
		set_local_var(7, 200);
	end
	gsay_message(SCRIPT_LORENZO, 201, NEUTRAL_REACTION);
end

procedure Lorenzo34
begin
	gsay_message(SCRIPT_LORENZO, 202, NEUTRAL_REACTION);
end

procedure Lorenzo35
begin
	gsay_reply(SCRIPT_LORENZO, 203);
	if (global_var(GVAR_DECKER_KNOWN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 204, Lorenzo23, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LORENZO, 205, Lorenzo24, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 206, Lorenzo25, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 207, Lorenzo26, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 208, Lorenzo27, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 209, Lorenzo41, NEUTRAL_REACTION);
end

procedure Lorenzo36
begin
	gsay_reply(SCRIPT_LORENZO, 210);
	if (global_var(GVAR_MISSING_CARAVAN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 211, Lorenzo22, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LORENZO, 212, Lorenzo24, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 213, Lorenzo25, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 214, Lorenzo26, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 215, Lorenzo27, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 216, Lorenzo41, NEUTRAL_REACTION);
end

procedure Lorenzo37
begin
	set_global_var(GVAR_DECKER_KNOWN, 1);
	gsay_reply(SCRIPT_LORENZO, 217);
	if (global_var(GVAR_MISSING_CARAVAN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 218, Lorenzo22, NEUTRAL_REACTION);
	end
	if (global_var(GVAR_DECKER_KNOWN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 219, Lorenzo23, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LORENZO, 220, Lorenzo25, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 221, Lorenzo26, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 222, Lorenzo27, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 223, Lorenzo41, NEUTRAL_REACTION);
end

procedure Lorenzo38
begin
	set_global_var(GVAR_MORPHEUS_KNOWN, 1);
	if (global_var(GVAR_ANGELS_BONEYARD) == 0) then begin
		set_global_var(GVAR_ANGELS_BONEYARD, 1);
	end
	gsay_reply(SCRIPT_LORENZO, 224);
	if (global_var(GVAR_MISSING_CARAVAN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 225, Lorenzo22, NEUTRAL_REACTION);
	end
	if (global_var(GVAR_DECKER_KNOWN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 226, Lorenzo23, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LORENZO, 227, Lorenzo24, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 228, Lorenzo26, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 229, Lorenzo27, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 230, Lorenzo41, NEUTRAL_REACTION);
end

procedure Lorenzo39
begin
	gsay_reply(SCRIPT_LORENZO, 231);
	if (global_var(GVAR_MISSING_CARAVAN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 232, Lorenzo22, NEUTRAL_REACTION);
	end
	if (global_var(GVAR_DECKER_KNOWN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 233, Lorenzo23, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LORENZO, 234, Lorenzo24, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 235, Lorenzo25, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 236, Lorenzo27, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 237, Lorenzo41, NEUTRAL_REACTION);
end

procedure Lorenzo40
begin
	gsay_reply(SCRIPT_LORENZO, 238);
	if (global_var(GVAR_MISSING_CARAVAN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 239, Lorenzo22, NEUTRAL_REACTION);
	end
	if (global_var(GVAR_DECKER_KNOWN) == 1) then begin
		giq_option(4, SCRIPT_LORENZO, 240, Lorenzo23, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LORENZO, 241, Lorenzo24, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 242, Lorenzo25, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 243, Lorenzo26, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LORENZO, 244, Lorenzo41, NEUTRAL_REACTION);
end

procedure Lorenzo41
begin
	gsay_message(SCRIPT_LORENZO, 245, NEUTRAL_REACTION);
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