#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure critter_p_proc;
procedure destroy_p_proc;
procedure pickup_p_proc;
procedure talk_p_proc;
procedure Lance00;
procedure Lance00a;
procedure Lance01;
procedure Lance02;
procedure Lance03;
procedure Lance04;
procedure Lance04a;
procedure Lance05;
procedure Lance06;
procedure Lance07;
procedure Lance08;
procedure Lance09;
procedure Lance10;
procedure Lance11;
procedure Lance12;
procedure Lance13;
procedure Lance14;
procedure Lance15;
procedure Lance16;
procedure Lance17;
procedure Lance18;
procedure Lance19;
procedure Lance19a;
procedure Lance20;
procedure Lance21;
procedure Lance22;
procedure Lance23;
procedure Lance24;
procedure Lance25;
procedure Lance26;
procedure Lance27;
procedure Lance28;
procedure Lance29;
procedure Lance30;
procedure Lance31;
procedure Lance31a;
procedure Lance32;
procedure Lance33;
procedure Lance34;
procedure Lance35;
procedure Lance36;
procedure Lance37;
procedure Lance38;
procedure Lance39;
procedure Lance40;
procedure Lance41;
procedure Lance42;
procedure Lance43;
procedure Lance44;
procedure Lance45;
procedure Lance46;
procedure Lance47;
procedure Lance48;
procedure Lance49;
procedure Lance50;
procedure Lance51;
procedure Lance52;
procedure LanceCombat;
procedure LanceEnd;
procedure LanceLoot;

variable hostile1;
variable initialized1;
variable known;
variable go_to_Shady;
variable go_to_Raiders;

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 (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_GUARD);
		hostile1 := global_var(GVAR_SAVE_TANDI_5);
		initialized1 := 1;
	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 == pickup_proc) then begin
					call pickup_p_proc;
				end
				else begin
					if (script_action == talk_proc) then begin
						call talk_p_proc;
					end
				end
			end
		end
	end
end

procedure critter_p_proc
begin
	if (hostile1) then begin
		hostile1 := 0;
		attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
	end
	else begin
		if (known and (tile_num(self_obj) < 20000)) then begin
			animate_move_obj_to_tile(self_obj, tile_num_in_direction(self_obj, 0, 3), ANIMATE_WALK);
		end
	end
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_global_var(GVAR_SAVE_TANDI_3, 1);
end

procedure pickup_p_proc
begin
	hostile1 := 1;
	set_global_var(GVAR_SAVE_TANDI_5, 1);
end

procedure talk_p_proc
begin
	call Get_Reaction;
	if (global_var(GVAR_SHADY_SANDS_INVADED)) then begin
		if (known) then begin
			call Lance52;
		end
		else begin
			start_gdialog(SCRIPT_LANCE, self_obj, 4, -1, -1);
			gsay_start;
			call Lance49;
			gsay_end;
			end_dialogue;
		end
	end
	else begin
		if (known) then begin
			if (local_var(1) == 1) then begin
				call Lance02;
			end
			else begin
				start_gdialog(SCRIPT_LANCE, self_obj, 4, -1, -1);
				gsay_start;
				call Lance03;
				gsay_end;
				end_dialogue;
			end
		end
		else begin
			if (global_var(GVAR_ENEMY_SHADY_SANDS) or (global_var(GVAR_PLAYER_REPUTATION) < -30) or (((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
				if ((global_var(GVAR_RESCUE_TANDI) == 2) and (global_var(GVAR_RADSCORPION_SEED) == 2)) then begin
					start_gdialog(SCRIPT_LANCE, self_obj, 4, -1, -1);
					gsay_start;
					call Lance00;
					gsay_end;
					end_dialogue;
				end
				else begin
					call Lance01;
				end
			end
			else begin
				if (global_var(GVAR_SHADY_SANDS) < 2) then begin
					if (local_var(1) >= 2) then begin
						start_gdialog(SCRIPT_LANCE, self_obj, 4, -1, -1);
						gsay_start;
						call Lance04;
						gsay_end;
						end_dialogue;
					end
					else begin
						call Lance05;
					end
				end
				else begin
					start_gdialog(SCRIPT_LANCE, self_obj, 4, -1, -1);
					gsay_start;
					if (local_var(1) >= 2) then begin
						call Lance07;
					end
					else begin
						call Lance06;
					end
					gsay_end;
					end_dialogue;
				end
			end
		end
	end
	if (go_to_Shady) then begin
		gfade_out(600);
		game_time_advance(game_ticks(86400));
		load_map(26, 0);
	end
	if (go_to_Raiders) then begin
		gfade_out(600);
		game_time_advance(game_ticks(86400));
		load_map(24, 0);
	end
end

procedure Lance00
begin
	call Bottom_React;
	known := 1;
	gsay_reply(SCRIPT_LANCE, 102);
	giq_option(4, SCRIPT_LANCE, 103, Lance00a, BAD_REACTION);
	giq_option(4, SCRIPT_LANCE, 104, Lance10, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 105, Lance11, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 106, Lance12, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_LANCE, 107, Lance13, NEUTRAL_REACTION);
end

procedure Lance00a
begin
	if ((get_critter_stat(dude_obj, 0) > 7) or obj_is_carrying_obj_pid(dude_obj, 15) or obj_is_carrying_obj_pid(dude_obj, 118) or obj_is_carrying_obj_pid(dude_obj, 13) or obj_is_carrying_obj_pid(dude_obj, 12)) then begin
		call Lance08;
	end
	else begin
		call Lance09;
	end
end

procedure Lance01
begin
	call Bottom_React;
	float_msg(self_obj, message_str(SCRIPT_LANCE, 108), FLOAT_MSG_NORMAL);
	hostile1 := 1;
	set_global_var(GVAR_SAVE_TANDI_5, 1);
end

procedure Lance02
begin
	float_msg(self_obj, message_str(SCRIPT_LANCE, 109), FLOAT_MSG_NORMAL);
end

procedure Lance03
begin
	gsay_reply(SCRIPT_LANCE, 110);
	if ((global_var(GVAR_FIND_WATER_CHIP) == 1) and (obj_is_carrying_obj_pid(dude_obj, 55) == 0)) then begin
		giq_option(4, SCRIPT_LANCE, 111, Lance14, NEUTRAL_REACTION);
	end
	if ((global_var(GVAR_TANDI_STATUS) == 1) and (global_var(GVAR_RESCUE_TANDI) == 1)) then begin
		giq_option(4, SCRIPT_LANCE, 112, Lance15, NEUTRAL_REACTION);
	end
	if (global_var(GVAR_RESCUE_TANDI) == 2) then begin
		giq_option(4, SCRIPT_LANCE, 113, Lance16, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LANCE, 114, Lance17, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_LANCE, 115, Lance18, NEUTRAL_REACTION);
end

procedure Lance04
begin
	known := 1;
	gsay_reply(SCRIPT_LANCE, 116);
	if ((global_var(GVAR_FIND_WATER_CHIP) == 1) and (obj_is_carrying_obj_pid(dude_obj, 55) == 0)) then begin
		giq_option(4, SCRIPT_LANCE, 111, Lance14, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LANCE, 118, Lance04a, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 119, Lance22, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 120, Lance23, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_LANCE, 121, Lance24, NEUTRAL_REACTION);
end

procedure Lance04a
begin
	if (is_success(roll_vs_skill(dude_obj, 14, 0))) then begin
		call Lance19;
	end
	else begin
		call Lance20;
	end
end

procedure Lance05
begin
	float_msg(self_obj, message_str(SCRIPT_LANCE, 122), FLOAT_MSG_NORMAL);
end

procedure Lance06
begin
	gsay_reply(SCRIPT_LANCE, message_str(SCRIPT_LANCE, 123) + proto_data(obj_pid(dude_obj), 1) + message_str(SCRIPT_LANCE, 124));
	giq_option(4, SCRIPT_LANCE, 125, Lance25, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 113, Lance16, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 127, Lance26, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 128, Lance28, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 121, Lance18, BAD_REACTION);
end

procedure Lance07
begin
	known := 1;
	gsay_reply(SCRIPT_LANCE, message_str(SCRIPT_LANCE, 123) + proto_data(obj_pid(dude_obj), 1) + message_str(SCRIPT_LANCE, 130));
	giq_option(4, SCRIPT_LANCE, 131, Lance29, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 113, Lance16, NEUTRAL_REACTION);
	if ((global_var(GVAR_FIND_WATER_CHIP) == 1) and (obj_is_carrying_obj_pid(dude_obj, 55) == 0)) then begin
		giq_option(4, SCRIPT_LANCE, 111, Lance14, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LANCE, 132, Lance00a, BAD_REACTION);
	giq_option(4, SCRIPT_LANCE, 133, Lance30, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_LANCE, 121, Lance18, NEUTRAL_REACTION);
end

procedure Lance08
begin
	gsay_reply(SCRIPT_LANCE, 134);
	giq_option(0, SCRIPT_MODREACT, 106, LanceLoot, BAD_REACTION);
end

procedure Lance09
begin
	gsay_message(SCRIPT_LANCE, 135, BAD_REACTION);
	hostile1 := 1;
	set_global_var(GVAR_SAVE_TANDI_5, 1);
end

procedure Lance10
begin
	gsay_reply(SCRIPT_LANCE, 126);
	giq_option(4, SCRIPT_LANCE, 136, Lance00a, BAD_REACTION);
	giq_option(4, SCRIPT_LANCE, 137, Lance31, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 105, Lance11, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 106, Lance12, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 138, LanceCombat, BAD_REACTION);
end

procedure Lance11
begin
	call Bottom_React;
	gsay_message(SCRIPT_LANCE, 139, BAD_REACTION);
end

procedure Lance12
begin
	gsay_message(SCRIPT_LANCE, 140, BAD_REACTION);
end

procedure Lance13
begin
	gsay_message(SCRIPT_LANCE, 141, NEUTRAL_REACTION);
end

procedure Lance14
begin
	gsay_reply(SCRIPT_LANCE, 142);
	giq_option(4, SCRIPT_LANCE, 143, Lance14, NEUTRAL_REACTION);
	if ((global_var(GVAR_RESCUE_TANDI) == 1) and (global_var(GVAR_TANDI_STATUS) == 1)) then begin
		giq_option(4, SCRIPT_LANCE, 112, Lance15, NEUTRAL_REACTION);
	end
	if (global_var(GVAR_RESCUE_TANDI) == 2) then begin
		giq_option(4, SCRIPT_LANCE, 113, Lance16, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LANCE, 114, Lance17, NEUTRAL_REACTION);
	if (global_var(GVAR_RADSCORPION_SEED) == 2) then begin
		giq_option(4, SCRIPT_LANCE, 144, Lance32, NEUTRAL_REACTION);
	end
end

procedure Lance15
begin
	gsay_reply(SCRIPT_LANCE, 145);
	giq_option(4, SCRIPT_LANCE, 146, Lance33, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 147, Lance34, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 148, Lance35, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 149, Lance36, NEUTRAL_REACTION);
end

procedure Lance16
begin
	gsay_reply(SCRIPT_LANCE, 150);
	giq_option(4, SCRIPT_LANCE, 151, Lance37, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 152, Lance38, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 144, Lance32, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 153, Lance39, NEUTRAL_REACTION);
end

procedure Lance17
begin
	gsay_reply(SCRIPT_LANCE, 154);
	if ((global_var(GVAR_FIND_WATER_CHIP) == 1) and (obj_is_carrying_obj_pid(dude_obj, 55) == 0)) then begin
		giq_option(4, SCRIPT_LANCE, 111, Lance14, NEUTRAL_REACTION);
	end
	if ((global_var(GVAR_RESCUE_TANDI) == 1) and (global_var(GVAR_TANDI_STATUS) == 1)) then begin
		giq_option(4, SCRIPT_LANCE, 112, Lance15, NEUTRAL_REACTION);
	end
	if (global_var(GVAR_RESCUE_TANDI) == 2) then begin
		giq_option(4, SCRIPT_LANCE, 113, Lance16, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LANCE, 155, Lance17, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 156, Lance36, NEUTRAL_REACTION);
end

procedure Lance18
begin
	gsay_message(SCRIPT_LANCE, 157, BAD_REACTION);
end

procedure Lance19
begin
	gsay_reply(SCRIPT_LANCE, 158);
	giq_option(4, SCRIPT_LANCE, 159, Lance19a, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 160, Lance42, NEUTRAL_REACTION);
	if ((global_var(GVAR_FIND_WATER_CHIP) == 1) and (obj_is_carrying_obj_pid(dude_obj, 55) == 0)) then begin
		giq_option(4, SCRIPT_LANCE, 161, Lance43, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LANCE, 162, Lance48, NEUTRAL_REACTION);
end

procedure Lance19a
begin
	if (get_critter_stat(dude_obj, 3) > 6) then begin
		call Lance40;
	end
	else begin
		call Lance41;
	end
end

procedure Lance20
begin
	call Bottom_React;
	gsay_message(SCRIPT_LANCE, 163, BAD_REACTION);
end

procedure Lance21
begin
	call Bottom_React;
	gsay_message(SCRIPT_LANCE, 164, BAD_REACTION);
end

procedure Lance22
begin
	if (global_var(GVAR_JUNKTOWN) < 1) then begin
		set_global_var(GVAR_JUNKTOWN, 1);
	end
	gsay_message(SCRIPT_LANCE, 165, NEUTRAL_REACTION);
end

procedure Lance23
begin
	call Bottom_React;
	gsay_message(SCRIPT_LANCE, 166, BAD_REACTION);
end

procedure Lance24
begin
	gsay_message(SCRIPT_LANCE, 167, BAD_REACTION);
end

procedure Lance25
begin
	gsay_reply(SCRIPT_LANCE, 168);
	giq_option(4, SCRIPT_LANCE, 169, Lance44, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 170, LanceCombat, BAD_REACTION);
	giq_option(4, SCRIPT_LANCE, 171, Lance28, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 172, Lance31, NEUTRAL_REACTION);
end

procedure Lance26
begin
	gsay_reply(SCRIPT_LANCE, 173);
	giq_option(4, SCRIPT_LANCE, 169, Lance44, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 170, Lance45, BAD_REACTION);
	giq_option(4, SCRIPT_LANCE, 171, Lance28, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 172, Lance31, NEUTRAL_REACTION);
end

procedure Lance27
begin
	call Bottom_React;
	gsay_reply(SCRIPT_LANCE, 174);
	giq_option(0, SCRIPT_MODREACT, 106, LanceLoot, BAD_REACTION);
end

procedure Lance28
begin
	gsay_message(SCRIPT_LANCE, 175, NEUTRAL_REACTION);
end

procedure Lance29
begin
	gsay_reply(SCRIPT_LANCE, 176);
	giq_option(4, SCRIPT_LANCE, 177, Lance46, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 178, Lance47, NEUTRAL_REACTION);
end

procedure Lance30
begin
	gsay_reply(SCRIPT_LANCE, 179);
	giq_option(0, SCRIPT_MODREACT, 106, Lance29, NEUTRAL_REACTION);
end

procedure Lance31
begin
	gsay_reply(SCRIPT_LANCE, 180);
	giq_option(0, SCRIPT_MODREACT, 106, Lance31a, BAD_REACTION);
end

procedure Lance31a
begin
	gsay_message(SCRIPT_LANCE, 181, NEUTRAL_REACTION);
end

procedure Lance32
begin
	gsay_reply(SCRIPT_LANCE, 182);
	if ((global_var(GVAR_FIND_WATER_CHIP) == 1) and (obj_is_carrying_obj_pid(dude_obj, 55) == 0)) then begin
		giq_option(4, SCRIPT_LANCE, 161, Lance43, NEUTRAL_REACTION);
	end
	if ((global_var(GVAR_RESCUE_TANDI) == 1) and (global_var(GVAR_TANDI_STATUS) == 1)) then begin
		giq_option(4, SCRIPT_LANCE, 112, Lance15, NEUTRAL_REACTION);
	end
	if (global_var(GVAR_RESCUE_TANDI) == 2) then begin
		giq_option(4, SCRIPT_LANCE, 113, Lance16, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_LANCE, 114, Lance17, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 183, Lance36, NEUTRAL_REACTION);
end

procedure Lance33
begin
	gsay_message(SCRIPT_LANCE, 184, NEUTRAL_REACTION);
	go_to_Shady := 1;
end

procedure Lance34
begin
	gsay_message(SCRIPT_LANCE, 185, NEUTRAL_REACTION);
	go_to_Raiders := 1;
end

procedure Lance35
begin
	gsay_message(SCRIPT_LANCE, 186, NEUTRAL_REACTION);
end

procedure Lance36
begin
	gsay_message(SCRIPT_LANCE, 187, NEUTRAL_REACTION);
end

procedure Lance37
begin
	gsay_reply(SCRIPT_LANCE, 188);
	giq_option(0, SCRIPT_MODREACT, 106, LanceLoot, NEUTRAL_REACTION);
end

procedure Lance38
begin
	gsay_message(SCRIPT_LANCE, 189, NEUTRAL_REACTION);
end

procedure Lance39
begin
	gsay_message(SCRIPT_LANCE, 190, GOOD_REACTION);
end

procedure Lance40
begin
	gsay_message(SCRIPT_LANCE, 191, NEUTRAL_REACTION);
	go_to_Shady := 1;
end

procedure Lance41
begin
	gsay_message(SCRIPT_LANCE, 192, NEUTRAL_REACTION);
end

procedure Lance42
begin
	gsay_message(SCRIPT_LANCE, 193, NEUTRAL_REACTION);
end

procedure Lance43
begin
	gsay_reply(SCRIPT_LANCE, 194);
	giq_option(0, SCRIPT_MODREACT, 106, Lance36, NEUTRAL_REACTION);
end

procedure Lance44
begin
	gsay_message(SCRIPT_LANCE, 195, NEUTRAL_REACTION);
end

procedure Lance45
begin
	call Bottom_React;
	gsay_message(SCRIPT_LANCE, 196, BAD_REACTION);
end

procedure Lance46
begin
	gsay_message(SCRIPT_LANCE, 197, NEUTRAL_REACTION);
	go_to_Shady := 1;
end

procedure Lance47
begin
	gsay_message(SCRIPT_LANCE, 198, NEUTRAL_REACTION);
end

procedure Lance48
begin
	gsay_message(SCRIPT_LANCE, 199, NEUTRAL_REACTION);
end

procedure Lance49
begin
	known := 1;
	gsay_reply(SCRIPT_LANCE, 200);
	giq_option(4, SCRIPT_LANCE, 201, Lance50, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 202, Lance51, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 203, Lance50, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_LANCE, 204, Lance51, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_LANCE, 205, Lance51, NEUTRAL_REACTION);
end

procedure Lance50
begin
	gsay_message(SCRIPT_LANCE, 206, NEUTRAL_REACTION);
end

procedure Lance51
begin
	gsay_message(SCRIPT_LANCE, 207, NEUTRAL_REACTION);
end

procedure Lance52
begin
	float_msg(self_obj, message_str(SCRIPT_LANCE, 208), FLOAT_MSG_NORMAL);
end

procedure LanceCombat
begin
	hostile1 := 1;
	set_global_var(GVAR_SAVE_TANDI_5, 1);
end

procedure LanceEnd
begin
end

procedure LanceLoot
begin
	gdialog_mod_barter(0);
	giq_option(4, SCRIPT_MODREACT, 103, LanceEnd, 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