#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 damage_p_proc;
procedure Demetre00;
procedure Demetre01;
procedure Demetre02;
procedure Demetre03;
procedure Demetre04;
procedure Demetre05;
procedure Demetre06;
procedure Demetre07;
procedure Demetre08;
procedure Demetre09;
procedure Demetre10;
procedure Demetre11;
procedure Demetre12;
procedure Demetre13;
procedure Demetre14;
procedure Demetre15;
procedure Demetre16;
procedure Demetre17;
procedure Demetre17a;
procedure Demetre17b;
procedure Demetre18;
procedure Demetre19;
procedure Demetre20;
procedure Demetre20a;
procedure Demetre21;
procedure Demetre22;
procedure Demetre23;
procedure Demetre24;
procedure Demetre25;
procedure Demetre26;
procedure Demetre27;
procedure Demetre28;
procedure Demetre29;
procedure Demetre30;
procedure Demetre31;
procedure Demetre31a;
procedure Demetre31b;
procedure Demetre31c;
procedure Demetre32;
procedure Demetre33;
procedure Demetre33a;
procedure Demetre34;
procedure Demetre35;
procedure Demetre35a;
procedure Demetre36;
procedure Demetre37;
procedure Demetre38;
procedure Demetre39;
procedure Demetre40;
procedure Demetre41;
procedure Demetre42;
procedure Demetre43;
procedure DemetreEnd;

variable hostile1;
variable Only_Once := 1;

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, 36);
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_AI_PACKET, AI_BERZERKER);
	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;
	set_map_var(24, 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
	if (source_obj == dude_obj) then begin
		hostile1 := 1;
	end
end

procedure talk_p_proc
begin
	call Get_Reaction;
	if (map_var(24) == 1) then begin
		call Demetre10;
	end
	else begin
		if (map_var(25) == 1) then begin
			if (local_var(5) == 0) then begin
				start_gdialog(SCRIPT_DEMETRE, self_obj, 4, -1, -1);
				gsay_start;
				call Demetre20;
				gsay_end;
				end_dialogue;
			end
			else begin
				call Demetre20;
			end
		end
		else begin
			if (global_var(GVAR_CC_JOB) == 3) then begin
				call Demetre30;
			end
			else begin
				if (local_var(4) == 0) then begin
					start_gdialog(SCRIPT_DEMETRE, self_obj, 4, -1, -1);
					gsay_start;
					call Demetre00;
					gsay_end;
					end_dialogue;
				end
				else begin
					if (map_var(26) == 0) then begin
						start_gdialog(SCRIPT_DEMETRE, self_obj, 4, -1, -1);
						gsay_start;
						call Demetre27;
						gsay_end;
						end_dialogue;
					end
					else begin
						if ((map_var(26) == 1) and (global_var(GVAR_CC_JOB) != 4)) then begin
							start_gdialog(SCRIPT_DEMETRE, self_obj, 4, -1, -1);
							gsay_start;
							call Demetre40;
							gsay_end;
							end_dialogue;
						end
						else begin
							if ((map_var(26) == 1) and (global_var(GVAR_CC_JOB) == 4)) then begin
								start_gdialog(SCRIPT_DEMETRE, self_obj, 4, -1, -1);
								gsay_start;
								call Demetre28;
								gsay_end;
								end_dialogue;
							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
	set_map_var(28, 1);
end

procedure look_at_p_proc
begin
	script_overrides;
	display_msg(message_str(SCRIPT_DEMETRE, 100));
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 Demetre00
begin
	variable LVar0 := 0;
	LVar0 := get_critter_stat(dude_obj, 0);
	if (LVar0 < 4) then begin
		gsay_reply(SCRIPT_DEMETRE, message_str(SCRIPT_DEMETRE, 101) + " " + message_str(SCRIPT_DEMETRE, 102));
	end
	else begin
		if ((LVar0 >= 4) and (LVar0 < 6)) then begin
			gsay_reply(SCRIPT_DEMETRE, message_str(SCRIPT_DEMETRE, 101) + " " + message_str(SCRIPT_DEMETRE, 103));
		end
		else begin
			if ((LVar0 >= 6) and (LVar0 < 8)) then begin
				gsay_reply(SCRIPT_DEMETRE, message_str(SCRIPT_DEMETRE, 101) + " " + message_str(SCRIPT_DEMETRE, 104));
			end
			else begin
				if ((LVar0 >= 8) and (LVar0 < 10)) then begin
					gsay_reply(SCRIPT_DEMETRE, message_str(SCRIPT_DEMETRE, 101) + " " + message_str(SCRIPT_DEMETRE, 105));
				end
				else begin
					gsay_reply(SCRIPT_DEMETRE, message_str(SCRIPT_DEMETRE, 101) + " " + message_str(SCRIPT_DEMETRE, 106));
				end
			end
		end
	end
	giq_option(4, SCRIPT_DEMETRE, 107, Demetre01, GOOD_REACTION);
	giq_option(4, SCRIPT_DEMETRE, 108, Demetre01, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_DEMETRE, 109, Demetre01, NEUTRAL_REACTION);
end

procedure Demetre01
begin
	gsay_reply(SCRIPT_DEMETRE, 110);
	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
		giq_option(4, SCRIPT_DEMETRE, 112, Demetre13, NEUTRAL_REACTION);
	end
	else begin
		giq_option(4, SCRIPT_DEMETRE, 111, Demetre02, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_DEMETRE, 113, Demetre12, NEUTRAL_REACTION);
	if (local_var(7) == 0) then begin
		giq_option(4, SCRIPT_DEMETRE, 114, Demetre31a, NEUTRAL_REACTION);
	end
	if (global_var(GVAR_MISSING_CARAVAN) == 1) then begin
		giq_option(4, SCRIPT_DEMETRE, 115, Demetre15, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_DEMETRE, 116, DemetreEnd, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_DEMETRE, 117, Demetre21, NEUTRAL_REACTION);
end

procedure Demetre02
begin
	gsay_reply(SCRIPT_DEMETRE, 118);
	giq_option(4, SCRIPT_DEMETRE, 119, Demetre03, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_DEMETRE, 120, Demetre05, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_DEMETRE, 121, Demetre09, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_DEMETRE, 122, Demetre04, NEUTRAL_REACTION);
end

procedure Demetre03
begin
	set_map_var(26, 1);
	gsay_message(SCRIPT_DEMETRE, 123, NEUTRAL_REACTION);
end

procedure Demetre04
begin
	gsay_message(SCRIPT_DEMETRE, 124, NEUTRAL_REACTION);
end

procedure Demetre05
begin
	gsay_reply(SCRIPT_DEMETRE, 125);
	giq_option(4, SCRIPT_DEMETRE, 126, Demetre08, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_DEMETRE, 127, Demetre07, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_DEMETRE, 128, Demetre06, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_DEMETRE, 129, Demetre07, NEUTRAL_REACTION);
end

procedure Demetre06
begin
	set_map_var(26, 1);
	gsay_message(SCRIPT_DEMETRE, 130, NEUTRAL_REACTION);
end

procedure Demetre07
begin
	set_map_var(26, 1);
	gsay_message(SCRIPT_DEMETRE, 131, NEUTRAL_REACTION);
end

procedure Demetre08
begin
	gsay_message(SCRIPT_DEMETRE, 132, NEUTRAL_REACTION);
end

procedure Demetre09
begin
	gsay_reply(SCRIPT_DEMETRE, 133);
	giq_option(4, SCRIPT_DEMETRE, 134, DemetreEnd, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_DEMETRE, 135, Demetre11, NEUTRAL_REACTION);
end

procedure Demetre10
begin
	float_msg(self_obj, message_str(SCRIPT_DEMETRE, random(136, 138)), FLOAT_MSG_RED);
end

procedure Demetre11
begin
	set_map_var(26, 1);
	gsay_message(SCRIPT_DEMETRE, 139, NEUTRAL_REACTION);
end

procedure Demetre12
begin
	gsay_message(SCRIPT_DEMETRE, 140, NEUTRAL_REACTION);
end

procedure Demetre13
begin
	set_map_var(26, 1);
	gsay_message(SCRIPT_DEMETRE, 141, NEUTRAL_REACTION);
end

procedure Demetre14
begin
	gsay_reply(SCRIPT_DEMETRE, 142);
	giq_option(4, SCRIPT_DEMETRE, 143, Demetre02, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_DEMETRE, 144, Demetre12, NEUTRAL_REACTION);
end

procedure Demetre15
begin
	gsay_reply(SCRIPT_DEMETRE, 145);
	giq_option(5, SCRIPT_DEMETRE, 146, Demetre16, NEUTRAL_REACTION);
	if ((map_var(4) == 1) and (global_var(GVAR_MISSING_CARAVAN) == 1)) then begin
		giq_option(4, SCRIPT_DEMETRE, 147, Demetre17, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_DEMETRE, 148, DemetreEnd, NEUTRAL_REACTION);
end

procedure Demetre16
begin
	gsay_reply(SCRIPT_DEMETRE, 149);
	giq_option(4, SCRIPT_DEMETRE, 150, Demetre02, NEUTRAL_REACTION);
	if ((map_var(4) == 1) and (global_var(GVAR_MISSING_CARAVAN) == 1)) then begin
		giq_option(4, SCRIPT_DEMETRE, 151, Demetre17, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_DEMETRE, 152, DemetreEnd, NEUTRAL_REACTION);
end

procedure Demetre17
begin
	gsay_reply(SCRIPT_DEMETRE, 153);
	giq_option(7, SCRIPT_DEMETRE, 154, Demetre18, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_DEMETRE, 155, Demetre17a, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_DEMETRE, 156, Demetre17b, BAD_REACTION);
end

procedure Demetre17a
begin
	if (global_var(GVAR_KILL_DEATHCLAW) == 2) then begin
		call DemetreEnd;
	end
	else begin
		call Demetre19;
	end
end

procedure Demetre17b
begin
	call Big_Down_React;
	call DemetreEnd;
end

procedure Demetre18
begin
	gsay_reply(SCRIPT_DEMETRE, 157);
	giq_option(4, SCRIPT_DEMETRE, 158, Demetre17a, NEUTRAL_REACTION);
end

procedure Demetre19
begin
	gsay_message(SCRIPT_DEMETRE, 159, NEUTRAL_REACTION);
end

procedure Demetre20
begin
	if (local_var(5) == 0) then begin
		set_local_var(5, 1);
		gsay_reply(SCRIPT_DEMETRE, 160);
		giq_option(4, SCRIPT_DEMETRE, 161, DemetreEnd, BAD_REACTION);
		giq_option(4, SCRIPT_DEMETRE, 162, Demetre25, BAD_REACTION);
		giq_option(4, SCRIPT_DEMETRE, 163, Demetre20a, BAD_REACTION);
		giq_option(-3, SCRIPT_DEMETRE, 164, Demetre22, BAD_REACTION);
	end
	else begin
		if (local_var(5) <= 5) then begin
			float_msg(self_obj, message_str(SCRIPT_DEMETRE, 164 + local_var(5)), FLOAT_MSG_RED);
			set_local_var(5, local_var(5) + 1);
		end
		else begin
			display_msg(message_str(SCRIPT_DEMETRE, 170));
		end
	end
end

procedure Demetre20a
begin
	if (is_success(do_check(dude_obj, 3, -5))) then begin
		call Demetre24;
	end
	else begin
		call Demetre23;
	end
end

procedure Demetre21
begin
	gsay_reply(SCRIPT_DEMETRE, 171);
	giq_option(-3, SCRIPT_DEMETRE, 172, DemetreEnd, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_DEMETRE, 173, DemetreEnd, NEUTRAL_REACTION);
end

procedure Demetre22
begin
	gsay_message(SCRIPT_DEMETRE, 174, BAD_REACTION);
end

procedure Demetre23
begin
	gsay_message(SCRIPT_DEMETRE, 175, BAD_REACTION);
end

procedure Demetre24
begin
	gsay_message(SCRIPT_DEMETRE, 176, NEUTRAL_REACTION);
end

procedure Demetre25
begin
	gsay_message(SCRIPT_DEMETRE, 177, BAD_REACTION);
end

procedure Demetre26
begin
end

procedure Demetre27
begin
	gsay_reply(SCRIPT_DEMETRE, 184);
	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
		giq_option(4, SCRIPT_DEMETRE, 186, Demetre13, NEUTRAL_REACTION);
	end
	else begin
		giq_option(4, SCRIPT_DEMETRE, 185, Demetre02, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_DEMETRE, 187, Demetre12, NEUTRAL_REACTION);
	if (local_var(7) == 0) then begin
		giq_option(4, SCRIPT_DEMETRE, 188, Demetre31a, NEUTRAL_REACTION);
	end
	if (global_var(GVAR_MISSING_CARAVAN) == 1) then begin
		giq_option(4, SCRIPT_DEMETRE, 189, Demetre15, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_DEMETRE, 190, DemetreEnd, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_DEMETRE, 191, Demetre21, NEUTRAL_REACTION);
end

procedure Demetre28
begin
	gsay_reply(SCRIPT_DEMETRE, 192);
	giq_option(4, SCRIPT_DEMETRE, 193, Demetre33, NEUTRAL_REACTION);
	if (local_var(7) == 0) then begin
		giq_option(4, SCRIPT_DEMETRE, 194, Demetre31a, NEUTRAL_REACTION);
	end
	if (global_var(GVAR_MISSING_CARAVAN) == 1) then begin
		giq_option(4, SCRIPT_DEMETRE, 195, Demetre15, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_DEMETRE, 196, Demetre39, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_DEMETRE, 197, DemetreEnd, NEUTRAL_REACTION);
end

procedure Demetre29
begin
	float_msg(self_obj, message_str(SCRIPT_DEMETRE, 198), FLOAT_MSG_RED);
	set_map_var(25, 1);
end

procedure Demetre30
begin
	float_msg(self_obj, message_str(SCRIPT_DEMETRE, 199), FLOAT_MSG_RED);
	set_map_var(25, 1);
end

procedure Demetre31
begin
	if (local_var(1) == 1) then begin
		float_msg(self_obj, message_str(SCRIPT_DEMETRE, 201), FLOAT_MSG_RED);
	end
	else begin
		gsay_reply(SCRIPT_DEMETRE, 200);
		if (local_var(7) == 0) then begin
			giq_option(4, SCRIPT_DEMETRE, 202, Demetre31a, NEUTRAL_REACTION);
		end
		if (global_var(GVAR_MISSING_CARAVAN) == 1) then begin
			giq_option(4, SCRIPT_DEMETRE, 203, Demetre15, NEUTRAL_REACTION);
		end
		if (local_var(8) == 0) then begin
			giq_option(4, SCRIPT_DEMETRE, 204, Demetre31b, BAD_REACTION);
		end
		else begin
			giq_option(4, SCRIPT_DEMETRE, 205, Demetre31c, BAD_REACTION);
		end
		giq_option(4, SCRIPT_DEMETRE, 206, DemetreEnd, NEUTRAL_REACTION);
		giq_option(-3, SCRIPT_DEMETRE, 207, Demetre21, NEUTRAL_REACTION);
	end
end

procedure Demetre31a
begin
	set_local_var(7, 1);
	call Demetre14;
end

procedure Demetre31b
begin
	set_local_var(8, 1);
	call Down_React;
	call Demetre32;
end

procedure Demetre31c
begin
	set_map_var(25, 1);
	call DemetreEnd;
end

procedure Demetre32
begin
	gsay_message(SCRIPT_DEMETRE, 208, BAD_REACTION);
end

procedure Demetre33
begin
	if (local_var(9) == 0) then begin
		set_local_var(9, 1);
		gsay_reply(SCRIPT_DEMETRE, 209);
		giq_option(4, SCRIPT_DEMETRE, 211, Demetre34, NEUTRAL_REACTION);
		giq_option(4, SCRIPT_DEMETRE, 212, Demetre33a, BAD_REACTION);
		giq_option(4, SCRIPT_DEMETRE, 213, DemetreEnd, NEUTRAL_REACTION);
	end
	else begin
		gsay_message(SCRIPT_DEMETRE, 210, NEUTRAL_REACTION);
	end
end

procedure Demetre33a
begin
	set_map_var(25, 1);
	set_map_var(24, 1);
	call Demetre35;
end

procedure Demetre34
begin
	gsay_reply(SCRIPT_DEMETRE, 214);
	giq_option(4, SCRIPT_DEMETRE, 215, Demetre37, BAD_REACTION);
	giq_option(4, SCRIPT_DEMETRE, 216, DemetreEnd, NEUTRAL_REACTION);
end

procedure Demetre35
begin
	gsay_reply(SCRIPT_DEMETRE, 217);
	giq_option(4, SCRIPT_DEMETRE, 218, Demetre36, BAD_REACTION);
	giq_option(4, SCRIPT_DEMETRE, 219, Demetre35a, BAD_REACTION);
end

procedure Demetre35a
begin
	set_map_var(24, 1);
	call combat;
end

procedure Demetre36
begin
	set_map_var(25, 1);
	gsay_message(SCRIPT_DEMETRE, 220, BAD_REACTION);
end

procedure Demetre37
begin
	gsay_reply(SCRIPT_DEMETRE, 221);
	giq_option(4, SCRIPT_DEMETRE, 222, combat, BAD_REACTION);
	giq_option(4, SCRIPT_DEMETRE, 223, Demetre38, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_DEMETRE, 224, DemetreEnd, NEUTRAL_REACTION);
end

procedure Demetre38
begin
	gsay_reply(SCRIPT_DEMETRE, 225);
	giq_option(4, SCRIPT_DEMETRE, 226, DemetreEnd, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_DEMETRE, 227, combat, BAD_REACTION);
end

procedure Demetre39
begin
	gsay_message(SCRIPT_DEMETRE, 228, NEUTRAL_REACTION);
end

procedure Demetre40
begin
	gsay_reply(SCRIPT_DEMETRE, 229);
	giq_option(4, SCRIPT_DEMETRE, 230, Demetre41, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_DEMETRE, 231, Demetre43, NEUTRAL_REACTION);
	if (local_var(7) == 0) then begin
		giq_option(4, SCRIPT_DEMETRE, 232, Demetre31a, NEUTRAL_REACTION);
	end
	if (global_var(GVAR_MISSING_CARAVAN) == 1) then begin
		giq_option(4, SCRIPT_DEMETRE, 233, Demetre15, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_DEMETRE, 234, DemetreEnd, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_DEMETRE, 235, Demetre21, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_DEMETRE, 236, Demetre42, NEUTRAL_REACTION);
end

procedure Demetre41
begin
	variable LVar0 := 0;
	if (local_var(10) == 0) then begin
		LVar0 := create_object_sid(25, 0, 0, -1);
		add_obj_to_inven(dude_obj, LVar0);
		set_local_var(10, 1);
		gsay_message(SCRIPT_DEMETRE, 237, NEUTRAL_REACTION);
	end
	else begin
		gsay_message(SCRIPT_DEMETRE, 238, NEUTRAL_REACTION);
	end
end

procedure Demetre42
begin
	gsay_message(SCRIPT_DEMETRE, 239, NEUTRAL_REACTION);
end

procedure Demetre43
begin
	gsay_message(SCRIPT_DEMETRE, 240, NEUTRAL_REACTION);
end

procedure DemetreEnd
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