#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure combat_p_proc;
procedure map_update_p_proc;
procedure talk_p_proc;
procedure razlo00;
procedure razlo00a;
procedure razlo01;
procedure razlo02;
procedure razlo03;
procedure razlo04;
procedure razlo05;
procedure razlo06;
procedure razlo06na;
procedure razlo06nb;
procedure razlo07;
procedure razlo08;
procedure razlo09;
procedure razlo10;
procedure razlo11;
procedure razlo12;
procedure razlo14;
procedure razlo15;
procedure Razlo17;
procedure razlo18;
procedure razlo19;
procedure razlo20;
procedure razlo21;
procedure razlo22;
procedure razlo23;
procedure razlo23a;
procedure razlo24;
procedure razlo25;
procedure razlo26;
procedure razlo27;
procedure razlo27a;
procedure razlo28;
procedure razlo29;
procedure razlo30;
procedure razlo31;
procedure razlo00n;
procedure razlo01n;
procedure razlo02n;
procedure razlo03n;
procedure razlo04n;
procedure razlo05n;
procedure razlo06n;
procedure razlo07n;
procedure razlo08n;
procedure razlo09n;
procedure razlo10n;
procedure razlo11n;
procedure razlo14n;
procedure razlo15n;
procedure razlo16n;
procedure razlowmpa;
procedure razlowmpb;
procedure razlofixa;
procedure razlofixb;
procedure razlofixc;
procedure razlox;
procedure razloend;
procedure givestuff;
procedure remove_items;
procedure critter_p_proc;
procedure look_at_p_proc;
procedure destroy_p_proc;
procedure pickup_p_proc;
procedure sleeping;

variable night_person;
variable wake_time;
variable sleep_time;
variable home_tile;
variable sleep_tile;
variable STIM;
variable FRUIT;
variable damage;
variable HOSTILE;
variable heal;
variable COST;
variable BONUS;
variable NIGHT;
variable round_counter;
variable dummyvar;
variable MONEY;
variable MAX_HITS;
variable HITS;
variable initialized1;
variable tail;

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 (script_action == combat_proc) then begin
		call combat_p_proc;
	end
	else begin
		if (script_action == map_update_proc) then begin
			call map_update_p_proc;
		end
		else begin
			if (script_action == talk_proc) then begin
				call talk_p_proc;
			end
			else begin
				if (script_action == pickup_proc) then begin
					call pickup_p_proc;
				end
				else begin
					if (script_action == critter_proc) then begin
						call critter_p_proc;
					end
					else begin
						if (script_action == look_at_proc) then begin
							call look_at_p_proc;
						end
						else begin
							if (script_action == destroy_proc) then begin
								call destroy_p_proc;
							end
						end
					end
				end
			end
		end
	end
end

procedure combat_p_proc
begin
	if (fixed_param == 4) then begin
		round_counter := round_counter + 1;
	end
	if (round_counter > 3) then begin
		if (global_var(GVAR_ENEMY_SHADY_SANDS) == 0) then begin
			set_global_var(GVAR_ENEMY_SHADY_SANDS, 1);
			set_global_var(GVAR_PLAYER_REPUTATION, global_var(GVAR_PLAYER_REPUTATION) - 5);
		end
	end
end

procedure map_update_p_proc
begin
	if (not(initialized1)) then begin
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_TEAM_NUM, 2);
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_AI_PACKET, AI_PEASANT);
		home_tile := 24529;
		sleep_tile := 23133;
		wake_time := 630;
		sleep_time := 2230;
		initialized1 := 0;
	end
end

procedure talk_p_proc
begin
	MAX_HITS := get_critter_stat(dude_obj, 7);
	HITS := get_critter_stat(dude_obj, 35);
	call Get_Reaction;
	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
	if (local_var(9) == 1) then begin
		float_msg(self_obj, message_str(SCRIPT_GENVAULT, 166), FLOAT_MSG_NORMAL);
	end
	else begin
		if ((game_time_hour >= 1900) or (game_time_hour < 600)) then begin
			set_local_var(6, 1);
			start_gdialog(SCRIPT_RAZLO, self_obj, 4, -1, -1);
			gsay_start;
			call razlo00n;
			gsay_end;
			end_dialogue;
		end
		else begin
			if (global_var(GVAR_RADSCORPION_SEED) == 1) then begin
				if ((global_var(GVAR_TANDI_STATUS) == 1) and (local_var(4) == 0) and (global_var(GVAR_TALKED_ABOUT_TANDI) == 1)) then begin
					set_local_var(4, 1);
					start_gdialog(SCRIPT_RAZLO, self_obj, 4, -1, -1);
					gsay_start;
					call razlo01;
					gsay_end;
					end_dialogue;
				end
				else begin
					start_gdialog(SCRIPT_RAZLO, self_obj, 4, -1, -1);
					gsay_start;
					call razlo23;
					gsay_end;
					end_dialogue;
				end
			end
			else begin
				if (obj_is_carrying_obj_pid(dude_obj, 92)) then begin
					start_gdialog(SCRIPT_RAZLO, self_obj, 4, -1, -1);
					gsay_start;
					call razlo23;
					gsay_end;
					end_dialogue;
				end
				else begin
					if ((local_var(6) == 0) and (local_var(1) >= 2)) then begin
						set_local_var(6, 1);
						start_gdialog(SCRIPT_RAZLO, self_obj, 4, -1, -1);
						gsay_start;
						call razlo10;
						gsay_end;
						end_dialogue;
					end
					else begin
						if (local_var(6) == 0) then begin
							set_local_var(6, 1);
							start_gdialog(SCRIPT_RAZLO, self_obj, 4, -1, -1);
							gsay_start;
							call razlo18;
							gsay_end;
							end_dialogue;
						end
						else begin
							if (global_var(GVAR_TANDI_STATUS) == 3) then begin
								call razlo09;
							end
							else begin
								if ((global_var(GVAR_TANDI_STATUS) == 2) and (local_var(5) == 0)) then begin
									set_local_var(5, 1);
									call razlo08;
								end
								else begin
									if ((global_var(GVAR_TANDI_STATUS) == 1) and (local_var(4) == 0) and (global_var(GVAR_TALKED_ABOUT_TANDI) == 1)) then begin
										set_local_var(4, 1);
										start_gdialog(SCRIPT_RAZLO, self_obj, 4, -1, -1);
										gsay_start;
										call razlo01;
										gsay_end;
										end_dialogue;
									end
									else begin
										if ((global_var(GVAR_TANDI_STATUS) == 1) and (global_var(GVAR_TALKED_ABOUT_TANDI) == 1) and (local_var(4) == 1)) then begin
											set_local_var(4, 2);
											call razlo07;
										end
										else 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)) or (global_var(GVAR_CHILDKILLER_REPUTATION) > 2)) then begin
												start_gdialog(SCRIPT_RAZLO, self_obj, 4, -1, -1);
												gsay_start;
												call razlo00;
												gsay_end;
												end_dialogue;
												display_msg(message_str(SCRIPT_RAZLO, 103));
											end
											else begin
												if (local_var(1) >= 2) then begin
													start_gdialog(SCRIPT_RAZLO, self_obj, 4, -1, -1);
													gsay_start;
													call razlo19;
													gsay_end;
													end_dialogue;
												end
												else begin
													start_gdialog(SCRIPT_RAZLO, self_obj, 4, -1, -1);
													gsay_start;
													call razlo21;
													gsay_end;
													end_dialogue;
												end
											end
										end
									end
								end
							end
						end
					end
				end
			end
		end
	end
	call remove_items;
end

procedure razlo00
begin
	gsay_message(SCRIPT_RAZLO, 101, NEUTRAL_REACTION);
end

procedure razlo00a
begin
	display_msg(message_str(SCRIPT_RAZLO, 103));
end

procedure razlo01
begin
	gsay_reply(SCRIPT_RAZLO, 104);
	if ((global_var(GVAR_TANDI_STATUS) == 1) and (global_var(GVAR_TALKED_ABOUT_TANDI) == 1)) then begin
		giq_option(4, SCRIPT_RAZLO, 105, razlo03, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_RAZLO, 143, razlo22, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_RAZLO, 144, razlo23a, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_RAZLO, 106, razlo02, NEUTRAL_REACTION);
end

procedure razlo02
begin
	gsay_message(SCRIPT_RAZLO, 107, NEUTRAL_REACTION);
	set_local_var(4, 1);
end

procedure razlo03
begin
	set_local_var(4, 1);
	gsay_reply(SCRIPT_RAZLO, 108);
	giq_option(5, SCRIPT_RAZLO, 110, razlo04, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_RAZLO, 109, razloend, NEUTRAL_REACTION);
	giq_option(5, SCRIPT_RAZLO, 111, razloend, NEUTRAL_REACTION);
end

procedure razlo04
begin
	gsay_reply(SCRIPT_RAZLO, 112);
	giq_option(4, SCRIPT_RAZLO, 113, razlo05, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_RAZLO, 114, razlo06, NEUTRAL_REACTION);
end

procedure razlo05
begin
	gsay_message(SCRIPT_RAZLO, 115, NEUTRAL_REACTION);
end

procedure razlo06
begin
	gsay_message(SCRIPT_RAZLO, 116, NEUTRAL_REACTION);
	call givestuff;
end

procedure razlo06na
begin
	gsay_message(SCRIPT_RAZLO, 306, NEUTRAL_REACTION);
	call razlo06nb;
end

procedure razlo06nb
begin
	variable LVar0 := 0;
	variable LVar1 := 0;
	gsay_message(SCRIPT_RAZLO, 307, NEUTRAL_REACTION);
	LVar0 := create_object_sid(49, 0, 0, -1);
	add_obj_to_inven(dude_obj, LVar0);
	LVar1 := obj_carrying_pid_obj(dude_obj, 92);
	rm_obj_from_inven(dude_obj, LVar1);
	destroy_object(LVar1);
	if (local_var(7) == 0) then begin
		set_local_var(7, 1);
		give_exp_points(250);
		display_msg(message_str(SCRIPT_RAZLO, 300));
	end
	gfade_out(400);
	gfade_in(400);
	game_time_advance(game_ticks(1200 * damage));
	critter_heal(dude_obj, damage);
end

procedure razlo07
begin
	float_msg(self_obj, message_str(SCRIPT_RAZLO, 117), FLOAT_MSG_RED);
end

procedure razlo08
begin
	float_msg(self_obj, message_str(SCRIPT_RAZLO, 118), FLOAT_MSG_LIGHT_RED);
end

procedure razlo09
begin
	float_msg(self_obj, message_str(SCRIPT_RAZLO, 119), FLOAT_MSG_LIGHT_GREY);
end

procedure razlo10
begin
	gsay_reply(SCRIPT_RAZLO, 120);
	giq_option(4, SCRIPT_RAZLO, 122, razlo14, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_RAZLO, 144, razlo23a, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_RAZLO, 121, razloend, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_RAZLO, 123, razlo11, NEUTRAL_REACTION);
end

procedure razlo11
begin
	gsay_message(SCRIPT_RAZLO, 124, NEUTRAL_REACTION);
	damage := MAX_HITS - HITS;
	if (damage > (MAX_HITS / 4)) then begin
		call razlo14;
	end
	else begin
		call razlo12;
	end
end

procedure razlo12
begin
	gsay_message(SCRIPT_RAZLO, 125, NEUTRAL_REACTION);
end

procedure razlo14
begin
	gsay_message(SCRIPT_RAZLO, 126, NEUTRAL_REACTION);
	damage := MAX_HITS - HITS;
	if (damage < (MAX_HITS / 4)) then begin
		call razlowmpa;
	end
	else begin
		if (damage < (MAX_HITS / 2)) then begin
			call razlofixa;
		end
		else begin
			if (damage < (3 * MAX_HITS / 4)) then begin
				call razlofixb;
			end
			else begin
				call razlofixc;
			end
		end
	end
end

procedure razlo15
begin
	gsay_message(SCRIPT_RAZLO, 127, NEUTRAL_REACTION);
end

procedure Razlo17
begin
	variable LVar0 := 0;
	if (damage < (MAX_HITS / 2)) then begin
		LVar0 := create_object_sid(218, 0, 0, -1);
		add_obj_to_inven(self_obj, LVar0);
	end
	else begin
		if (damage < (3 * MAX_HITS / 4)) then begin
			LVar0 := create_object_sid(219, 0, 0, -1);
			add_obj_to_inven(self_obj, LVar0);
		end
		else begin
			LVar0 := create_object_sid(220, 0, 0, -1);
			add_obj_to_inven(self_obj, LVar0);
		end
	end
	gdialog_mod_barter(0);
	gsay_message(SCRIPT_RAZLO, 126, NEUTRAL_REACTION);
	call razlo08n;
end

procedure razlo18
begin
	gsay_reply(SCRIPT_RAZLO, 128);
	giq_option(4, SCRIPT_RAZLO, 130, razlo14, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_RAZLO, 144, razlo23a, NEUTRAL_REACTION);
	giq_option(5, SCRIPT_RAZLO, 129, razloend, NEUTRAL_REACTION);
end

procedure razlo19
begin
	gsay_reply(SCRIPT_RAZLO, 131);
	giq_option(4, SCRIPT_RAZLO, 132, razlo20, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_RAZLO, 143, razlo22, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_RAZLO, 144, razlo23a, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_RAZLO, 134, razlo11, NEUTRAL_REACTION);
end

procedure razlo20
begin
	gsay_message(SCRIPT_RAZLO, 135, NEUTRAL_REACTION);
end

procedure razlo21
begin
	gsay_reply(SCRIPT_RAZLO, 136);
	giq_option(4, SCRIPT_RAZLO, 138, razlo22, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_RAZLO, 144, razlo23a, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_RAZLO, 139, razlo11, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_RAZLO, 137, razloend, NEUTRAL_REACTION);
end

procedure razlo22
begin
	gsay_message(SCRIPT_RAZLO, 140, NEUTRAL_REACTION);
	call razlo14;
end

procedure razlo23
begin
	gsay_reply(SCRIPT_RAZLO, 141);
	giq_option(4, SCRIPT_RAZLO, 143, razlo22, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_RAZLO, 144, razlo23a, NEUTRAL_REACTION);
	giq_option(5, SCRIPT_RAZLO, 145, razlo27, NEUTRAL_REACTION);
	if (obj_is_carrying_obj_pid(dude_obj, 92)) then begin
		giq_option(4, SCRIPT_RAZLO, 146, razlo30, NEUTRAL_REACTION);
		giq_option(-3, SCRIPT_RAZLO, 303, razlo30, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_RAZLO, 142, razloend, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_RAZLO, 147, razlo11, NEUTRAL_REACTION);
end

procedure razlo23a
begin
	if (local_var(8) == 1) then begin
		call razlo25;
	end
	else begin
		call razlo24;
	end
end

procedure razlo24
begin
	gsay_message(SCRIPT_RAZLO, 148, NEUTRAL_REACTION);
end

procedure razlo25
begin
	gsay_message(SCRIPT_RAZLO, 149, NEUTRAL_REACTION);
	if (get_poison(dude_obj) > 0) then begin
		gsay_message(SCRIPT_RAZLO, 150, NEUTRAL_REACTION);
		poison(dude_obj, -get_poison(dude_obj));
		call razlo26;
	end
	else begin
		gsay_message(SCRIPT_RAZLO, 151, NEUTRAL_REACTION);
	end
	poison(dude_obj, -get_poison(dude_obj));
end

procedure razlo26
begin
	gsay_message(SCRIPT_RAZLO, 152, NEUTRAL_REACTION);
end

procedure razlo27
begin
	gsay_message(SCRIPT_RAZLO, 153, NEUTRAL_REACTION);
	gsay_reply(SCRIPT_RAZLO, 154);
	giq_option(5, SCRIPT_RAZLO, 156, razlo29, NEUTRAL_REACTION);
	giq_option(5, SCRIPT_RAZLO, 157, razlo28, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_RAZLO, 155, razlo27a, GOOD_REACTION);
end

procedure razlo27a
begin
	call Up_React;
end

procedure razlo28
begin
	gsay_reply(SCRIPT_RAZLO, 158);
	giq_option(5, SCRIPT_RAZLO, 159, razloend, NEUTRAL_REACTION);
end

procedure razlo29
begin
	gsay_message(SCRIPT_RAZLO, 160, NEUTRAL_REACTION);
end

procedure razlo30
begin
	gsay_message(SCRIPT_RAZLO, 161, NEUTRAL_REACTION);
	gfade_out(400);
	gfade_in(400);
	game_time_advance(game_ticks(14400));
	set_local_var(8, 1);
	call razlo31;
end

procedure razlo31
begin
	variable LVar0 := 0;
	gsay_message(SCRIPT_RAZLO, 162, NEUTRAL_REACTION);
	LVar0 := create_object_sid(49, 0, 0, -1);
	add_obj_to_inven(dude_obj, LVar0);
	tail := obj_carrying_pid_obj(dude_obj, 92);
	rm_obj_from_inven(dude_obj, tail);
	destroy_object(tail);
	if (local_var(7) == 0) then begin
		set_local_var(7, 1);
		give_exp_points(250);
		display_msg(message_str(SCRIPT_RAZLO, 300));
	end
end

procedure razlo00n
begin
	gsay_reply(SCRIPT_RAZLO, 163);
	giq_option(4, SCRIPT_RAZLO, 164, razlo02n, NEUTRAL_REACTION);
	if (global_var(GVAR_RADSCORPION_SEED) == 1) then begin
		giq_option(5, SCRIPT_RAZLO, 165, razlo09n, NEUTRAL_REACTION);
	end
	if ((global_var(GVAR_TANDI_STATUS) == 1) and (global_var(GVAR_TALKED_ABOUT_TANDI) == 1)) then begin
		giq_option(5, SCRIPT_RAZLO, 166, razlo15n, NEUTRAL_REACTION);
	end
	giq_option(-3, SCRIPT_RAZLO, 167, razlo01n, NEUTRAL_REACTION);
end

procedure razlo01n
begin
	gsay_message(SCRIPT_RAZLO, 168, NEUTRAL_REACTION);
	call Down_React;
end

procedure razlo02n
begin
	gsay_reply(SCRIPT_RAZLO, 169);
	giq_option(4, SCRIPT_RAZLO, 170, razlo04n, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_RAZLO, 171, razlo03n, NEUTRAL_REACTION);
end

procedure razlo03n
begin
	gsay_message(SCRIPT_RAZLO, 172, NEUTRAL_REACTION);
	call Down_React;
end

procedure razlo04n
begin
	gsay_reply(SCRIPT_RAZLO, 173);
	giq_option(4, SCRIPT_RAZLO, 174, razlo05n, NEUTRAL_REACTION);
end

procedure razlo05n
begin
	damage := MAX_HITS - HITS;
	if (damage < (MAX_HITS / 4)) then begin
		call razlowmpb;
	end
	else begin
		if (damage < (MAX_HITS / 2)) then begin
			call razlofixa;
		end
		else begin
			if (damage < (3 * MAX_HITS / 4)) then begin
				call razlofixb;
			end
			else begin
				call razlofixc;
			end
		end
	end
end

procedure razlo06n
begin
	gsay_reply(SCRIPT_RAZLO, 186);
	giq_option(4, SCRIPT_RAZLO, 187, Razlo17, NEUTRAL_REACTION);
	if (obj_is_carrying_obj_pid(dude_obj, 92)) then begin
		giq_option(4, SCRIPT_RAZLO, 305, razlo06na, NEUTRAL_REACTION);
		giq_option(-3, SCRIPT_RAZLO, 303, razlo06na, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_RAZLO, 188, razloend, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_RAZLO, 304, Razlo17, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_RAZLO, 302, razloend, NEUTRAL_REACTION);
end

procedure razlo07n
begin
	gsay_message(SCRIPT_RAZLO, 189, GOOD_REACTION);
end

procedure razlo08n
begin
	if (obj_is_carrying_obj_pid(dude_obj, 218) or obj_is_carrying_obj_pid(dude_obj, 219) or obj_is_carrying_obj_pid(dude_obj, 220)) then begin
		call razlo14n;
	end
	else begin
		if (item_caps_total(dude_obj) >= COST) then begin
			dummyvar := item_caps_adjust(dude_obj, -COST);
			call razlo14n;
		end
		else begin
			call razlo06n;
		end
	end
end

procedure razlo09n
begin
	gsay_reply(SCRIPT_RAZLO, 190);
	giq_option(6, SCRIPT_RAZLO, 191, razlo10n, NEUTRAL_REACTION);
end

procedure razlo10n
begin
	gsay_message(SCRIPT_RAZLO, 192, NEUTRAL_REACTION);
end

procedure razlo11n
begin
	gsay_reply(SCRIPT_RAZLO, 108);
	giq_option(5, SCRIPT_RAZLO, 194, razlo04, NEUTRAL_REACTION);
	giq_option(5, SCRIPT_RAZLO, 195, razloend, NEUTRAL_REACTION);
end

procedure razlo14n
begin
	gsay_message(SCRIPT_RAZLO, 196, NEUTRAL_REACTION);
	gfade_out(400);
	gfade_in(400);
	game_time_advance(game_ticks(1200 * damage));
	critter_heal(dude_obj, damage);
end

procedure razlo15n
begin
	if (local_var(11) == 1) then begin
		call razlo16n;
	end
	else begin
		set_local_var(11, 1);
		call razlo11n;
	end
end

procedure razlo16n
begin
	gsay_message(SCRIPT_RAZLO, 197, NEUTRAL_REACTION);
end

procedure razlowmpa
begin
	gsay_message(SCRIPT_RAZLO, 175, NEUTRAL_REACTION);
end

procedure razlowmpb
begin
	gsay_message(SCRIPT_RAZLO, 176, NEUTRAL_REACTION);
end

procedure razlofixa
begin
	COST := 25;
	gsay_reply(SCRIPT_RAZLO, 177);
	giq_option(4, SCRIPT_RAZLO, 178, razlo08n, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_RAZLO, 179, razlo06n, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_RAZLO, 301, razlo08n, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_RAZLO, 302, razloend, NEUTRAL_REACTION);
end

procedure razlofixb
begin
	COST := 50;
	gsay_reply(SCRIPT_RAZLO, 180);
	giq_option(4, SCRIPT_RAZLO, 181, razlo08n, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_RAZLO, 182, razlo06n, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_RAZLO, 301, razlo08n, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_RAZLO, 302, razloend, NEUTRAL_REACTION);
end

procedure razlofixc
begin
	COST := 100;
	gsay_reply(SCRIPT_RAZLO, 183);
	giq_option(4, SCRIPT_RAZLO, 184, razlo08n, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_RAZLO, 185, razlo06n, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_RAZLO, 301, razlo08n, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_RAZLO, 302, razloend, NEUTRAL_REACTION);
end

procedure razlox
begin
end

procedure razloend
begin
end

procedure givestuff
begin
	variable LVar0 := 0;
	LVar0 := create_object_sid(40, 0, 0, -1);
	add_obj_to_inven(dude_obj, LVar0);
	LVar0 := create_object_sid(40, 0, 0, -1);
	add_obj_to_inven(dude_obj, LVar0);
	LVar0 := create_object_sid(71, 0, 0, -1);
	add_obj_to_inven(dude_obj, LVar0);
	if (local_var(8) == 1) then begin
		LVar0 := create_object_sid(49, 0, 0, -1);
		add_obj_to_inven(dude_obj, LVar0);
	end
end

procedure remove_items
begin
	variable LVar0 := 0;
	if (obj_is_carrying_obj_pid(dude_obj, 218)) then begin
		LVar0 := obj_carrying_pid_obj(dude_obj, 218);
		rm_obj_from_inven(dude_obj, LVar0);
		destroy_object(LVar0);
	end
	if (obj_is_carrying_obj_pid(self_obj, 218)) then begin
		LVar0 := obj_carrying_pid_obj(self_obj, 218);
		rm_obj_from_inven(self_obj, LVar0);
		destroy_object(LVar0);
	end
	if (obj_is_carrying_obj_pid(dude_obj, 219)) then begin
		LVar0 := obj_carrying_pid_obj(dude_obj, 219);
		rm_obj_from_inven(dude_obj, LVar0);
		destroy_object(LVar0);
	end
	if (obj_is_carrying_obj_pid(self_obj, 219)) then begin
		LVar0 := obj_carrying_pid_obj(self_obj, 219);
		rm_obj_from_inven(self_obj, LVar0);
		destroy_object(LVar0);
	end
	if (obj_is_carrying_obj_pid(dude_obj, 220)) then begin
		LVar0 := obj_carrying_pid_obj(dude_obj, 220);
		rm_obj_from_inven(dude_obj, LVar0);
		destroy_object(LVar0);
	end
	if (obj_is_carrying_obj_pid(self_obj, 220)) then begin
		LVar0 := obj_carrying_pid_obj(self_obj, 220);
		rm_obj_from_inven(self_obj, LVar0);
		destroy_object(LVar0);
	end
end

procedure critter_p_proc
begin
	if (map_var(2) == 1) then begin
		set_local_var(10, local_var(10) + 1);
		set_map_var(2, 0);
		if (local_var(10) < 3) then begin
			float_msg(self_obj, message_str(SCRIPT_RAZLO, 308), FLOAT_MSG_RED);
		end
		else begin
			HOSTILE := 1;
		end
	end
	if (obj_can_see_obj(self_obj, dude_obj)) then begin
		if (global_var(GVAR_ENEMY_SHADY_SANDS) == 1) then begin
			HOSTILE := 1;
		end
	end
	if (HOSTILE) then begin
		HOSTILE := 0;
		attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
	end
end

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

procedure destroy_p_proc
begin
	if (source_obj == dude_obj) then begin
		set_global_var(GVAR_ENEMY_SHADY_SANDS, 1);
	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_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 pickup_p_proc
begin
	HOSTILE := 1;
end

procedure sleeping
begin
	if (local_var(9) == 1) then begin
		if (not(night_person) and (game_time_hour >= wake_time) and (game_time_hour < sleep_time) or (night_person and ((game_time_hour >= wake_time) or (game_time_hour < sleep_time)))) then begin
			if (((game_time_hour - wake_time) < 10) and ((game_time_hour - wake_time) > 0)) then begin
				if (tile_num(self_obj) != home_tile) then begin
					animate_move_obj_to_tile(self_obj, home_tile, ANIMATE_WALK);
				end
				else begin
					set_local_var(9, 0);
				end
			end
			else begin
				move_to(self_obj, home_tile, elevation(self_obj));
				if (tile_num(self_obj) == home_tile) then begin
					set_local_var(9, 0);
				end
			end
		end
	end
	else begin
		if (night_person and (game_time_hour >= sleep_time) and (game_time_hour < wake_time) or (not(night_person) and ((game_time_hour >= sleep_time) or (game_time_hour < wake_time)))) then begin
			if (((game_time_hour - sleep_time) < 10) and ((game_time_hour - sleep_time) > 0)) then begin
				if (tile_num(self_obj) != sleep_tile) then begin
					animate_move_obj_to_tile(self_obj, self_obj, ANIMATE_WALK);
				end
				else begin
					set_local_var(9, 1);
				end
			end
			else begin
				if (tile_num(self_obj) != sleep_tile) then begin
					move_to(self_obj, sleep_tile, elevation(self_obj));
				end
				else begin
					set_local_var(9, 1);
				end
			end
		end
	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