#include <define.h>

//#define NAME                    SCRIPT_

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


variable GVar0;
variable GVar1;
variable GVar2;
variable GVar3;
variable GVar4;
variable GVar5;
variable GVar6;
variable GVar7;
variable GVar8;
variable GVar9;
variable GVar10;
variable GVar11;
variable GVar12;

procedure start;
#include <push.h>
procedure combat_p_proc;
procedure critter_p_proc;
procedure description_p_proc;
procedure destroy_p_proc;
procedure look_at_p_proc;
procedure map_enter_p_proc;
procedure map_update_p_proc;
procedure talk_p_proc;
procedure timed_event_p_proc;
procedure damage_p_proc;
procedure Saul06;
procedure Saul07;
procedure Saul08;
procedure Saul09;
procedure Saul10;
procedure Saul11;
procedure Saul12;
procedure Saul13;
procedure Saul14;
procedure Saul15;
procedure Saul16;
procedure Saul17;
procedure Saul18;
procedure Saul18a;
procedure Saul19;
procedure Saul20;
procedure Saul21;
procedure Saul22;
procedure Saul23;
procedure Saul24;
procedure SaulBoxing;
procedure SaulCombat;
procedure SaulEnd;
procedure create_challenger;
procedure sleeping;

import variable challenger_ptr;
import variable fight;
import variable Saul_loses;
import variable Saul_wins;

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;


procedure start
begin
	if (script_action == combat_proc) then begin
		call combat_p_proc;
	end
	else begin
		if (script_action == critter_proc) then begin
			call critter_p_proc;
		end
		else begin
			if (script_action == description_proc) then begin
				call description_p_proc;
			end
			else begin
				if (script_action == destroy_proc) then begin
					call destroy_p_proc;
				end
				else begin
					if (script_action == look_at_proc) then begin
						call look_at_p_proc;
					end
					else begin
						if (script_action == map_enter_proc) then begin
							call map_enter_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 == timed_event_proc) then begin
										call timed_event_p_proc;
									end
								end
							end
						end
					end
				end
			end
		end
	end
end

procedure combat_p_proc
begin
	if ((fixed_param == 4) and obj_can_see_obj(self_obj, dude_obj)) then begin
		GVar7 := GVar7 + 1;
	end
	if (GVar7 > 3) then begin
		if (global_var(GVAR_ENEMY_JUNKTOWN) == 0) then begin
			set_global_var(GVAR_ENEMY_JUNKTOWN, 1);
			set_global_var(GVAR_PLAYER_REPUTATION, global_var(GVAR_PLAYER_REPUTATION) - 5);
		end
	end
end

procedure critter_p_proc
begin
	if (GVar5) then begin
		GVar5 := 0;
		attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
	end
	else begin
		if (cur_map_index == MAP_JUNKCSNO) then begin
			if (fight) then begin
				fight := 0;
				GVar10 := 0;
				GVar9 := 0;
				anim(self_obj, 1000, 1);
				if (obj_can_see_obj(dude_obj, self_obj)) then begin
					gfade_out(600);
					call create_challenger;
					gfade_in(600);
				end
				else begin
					call create_challenger;
				end
				add_timer_event(self_obj, game_ticks(1), 1);
			end
		end
		if (GVar8 == 0) then begin
			call sleeping;
		end
	end
	if (global_var(GVAR_ENEMY_JUNKTOWN) == 1) then begin
		if (obj_can_see_obj(self_obj, dude_obj)) then begin
			attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
		end
	end
end

procedure description_p_proc
begin
	if (is_success(do_check(dude_obj, 1, has_trait(0, dude_obj, 0)))) then begin
		display_msg(message_str(SCRIPT_SAUL, 102));
	end
end

procedure destroy_p_proc
begin
	if (source_obj == dude_obj) then begin
		set_global_var(GVAR_ENEMY_JUNKTOWN, 1);
		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
	set_global_var(GVAR_SAUL_STATUS, 3);
end

procedure look_at_p_proc
begin
	script_overrides;
	if (not(global_var(GVAR_SAUL_STATUS))) then begin
		display_msg(message_str(SCRIPT_SAUL, 101));
	end
	else begin
		display_msg(message_str(SCRIPT_SAUL, 100));
	end
end

procedure map_enter_p_proc
begin
	variable LVar0 := 0;
	if (global_var(GVAR_JUNKTOWN_INVADED) == 1) then begin
		LVar0 := create_object_sid(234, 0, 0, -1);
		add_obj_to_inven(self_obj, LVar0);
		kill_critter(self_obj, 48);
	end
	GVar8 := 0;
	GVar2 := 2000;
	GVar1 := 700;
	if (cur_map_index == MAP_JUNKCSNO) then begin
		GVar4 := 7000;
		if ((game_time / (10 * 60 * 60 * 24) % 3) == 0) then begin
			GVar3 := 15094;
		end
		else begin
			GVar3 := 16892;
		end
	end
	if (global_var(GVAR_SAUL_STATUS) == 3) then begin
		destroy_object(self_obj);
	end
	move_to(self_obj, GVar3, 0);
end

procedure map_update_p_proc
begin
	if (not(combat_is_initialized)) then begin
		if ((game_time / (10 * 60 * 60 * 24) % 3) == 0) then begin
			GVar3 := 15094;
		end
		else begin
			GVar3 := 16892;
		end
		move_to(self_obj, GVar3, 0);
		if (local_var(8) == 1) then begin
			set_local_var(8, 0);
			reg_anim_animate(self_obj, 0, 0);
		end
		call sleeping;
	end
end

procedure talk_p_proc
begin
	call Get_Reaction;
	if (local_var(4)) then begin
		float_msg(self_obj, message_str(SCRIPT_GENVAULT, 166), FLOAT_MSG_NORMAL);
	end
	else begin
		if (critter_state(self_obj) bwand 1) then begin
			display_msg(message_str(SCRIPT_SAUL, 115));
		end
		else begin
			if (global_var(GVAR_ENEMY_JUNKTOWN)) then begin
				float_msg(self_obj, message_str(SCRIPT_ENEMY, 104), FLOAT_MSG_RED);
			end
			else begin
				if ((obj_item_subtype(critter_inven_obj(dude_obj, 1)) == 3) or (obj_item_subtype(critter_inven_obj(dude_obj, 2)) == 3)) then begin
					call Saul06;
				end
				else begin
					start_gdialog(SCRIPT_SAUL, self_obj, 4, -1, -1);
					gsay_start;
					if (global_var(GVAR_SAUL_STATUS)) then begin
						call Saul23;
					end
					else begin
						call Saul07;
					end
					gsay_end;
					end_dialogue;
				end
			end
		end
	end
	if (not(global_var(GVAR_TRISH_STATUS) bwand 16) and (global_var(GVAR_TRISH_STATUS) bwand 8)) then begin
		set_global_var(GVAR_TRISH_STATUS, global_var(GVAR_TRISH_STATUS) + 16);
		display_msg(message_str(SCRIPT_TRISH, 173));
		give_exp_points(250);
	end
end

procedure timed_event_p_proc
begin
	if (fixed_param == 1) then begin
		if (obj_pid(challenger_ptr) == 16777227) then begin
			if (random(0, 4) == 0) then begin
				GVar11 := 1;
			end
			else begin
				GVar11 := 0;
			end
		end
		else begin
			if (random(0, 2)) then begin
				GVar11 := 1;
			end
			else begin
				GVar11 := 0;
			end
		end
		call SaulBoxing;
	end
	else begin
		if (fixed_param == 2) then begin
			Saul_wins := 1;
		end
		else begin
			if (fixed_param == 3) then begin
				Saul_loses := 1;
				set_local_var(8, 1);
			end
		end
	end
end

procedure damage_p_proc
begin
	if (source_obj == dude_obj) then begin
		set_global_var(GVAR_ENEMY_JUNKTOWN, 1);
	end
end

procedure Saul06
begin
	float_msg(self_obj, message_str(SCRIPT_SAUL, 104), FLOAT_MSG_RED);
end

procedure Saul07
begin
	if (local_var(1) == 1) then begin
		gsay_reply(SCRIPT_SAUL, 105);
	end
	else begin
		gsay_reply(SCRIPT_SAUL, 106);
	end
	giq_option(4, SCRIPT_SAUL, 107, Saul08, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_SAUL, 108, Saul09, BAD_REACTION);
	giq_option(4, SCRIPT_SAUL, message_str(SCRIPT_SAUL, 109) + proto_data(obj_pid(dude_obj), 1) + message_str(SCRIPT_SAUL, 110), Saul09, NEUTRAL_REACTION);
end

procedure Saul08
begin
	gsay_reply(SCRIPT_SAUL, 111);
	giq_option(4, SCRIPT_SAUL, 112, Saul09, BAD_REACTION);
	giq_option(4, SCRIPT_SAUL, 113, Saul11, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_SAUL, 103, SaulEnd, NEUTRAL_REACTION);
end

procedure Saul09
begin
	if (local_var(1) == 1) then begin
		gsay_reply(SCRIPT_SAUL, 128);
	end
	else begin
		gsay_reply(SCRIPT_SAUL, 129);
	end
	if (local_var(1) == 1) then begin
		giq_option(4, SCRIPT_SAUL, 130, Saul10, NEUTRAL_REACTION);
		giq_option(4, SCRIPT_SAUL, 188, SaulCombat, BAD_REACTION);
	end
	giq_option(4, SCRIPT_SAUL, 131, Saul10, NEUTRAL_REACTION);
	if (local_var(1) == 3) then begin
		giq_option(4, SCRIPT_SAUL, 135, Saul11, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_SAUL, 132, SaulEnd, NEUTRAL_REACTION);
end

procedure Saul10
begin
	if (local_var(1) == 1) then begin
		gsay_reply(SCRIPT_SAUL, 133);
	end
	else begin
		gsay_reply(SCRIPT_SAUL, 134);
	end
	giq_option(4, SCRIPT_SAUL, 135, Saul11, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_SAUL, 136, Saul12, GOOD_REACTION);
	giq_option(4, SCRIPT_SAUL, 132, SaulEnd, NEUTRAL_REACTION);
end

procedure Saul11
begin
	gsay_reply(SCRIPT_SAUL, 137);
	giq_option(4, SCRIPT_SAUL, 136, Saul12, GOOD_REACTION);
	if (not(local_var(5))) then begin
		giq_option(4, SCRIPT_SAUL, 138, Saul13, NEUTRAL_REACTION);
	end
	if (not(local_var(6))) then begin
		giq_option(4, SCRIPT_SAUL, 139, Saul14, NEUTRAL_REACTION);
	end
	call Goodbyes;
	giq_option(4, SCRIPT_SAUL, GVar12, SaulEnd, NEUTRAL_REACTION);
end

procedure Saul12
begin
	call Up_React;
	if (local_var(1) == 1) then begin
		gsay_reply(SCRIPT_SAUL, 140);
	end
	else begin
		gsay_reply(SCRIPT_SAUL, 141);
		giq_option(5, SCRIPT_SAUL, 142, Saul15, GOOD_REACTION);
	end
	giq_option(4, SCRIPT_SAUL, 143, Saul13, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_SAUL, 144, Saul14, NEUTRAL_REACTION);
	call Goodbyes;
	giq_option(4, SCRIPT_SAUL, GVar12, SaulEnd, NEUTRAL_REACTION);
end

procedure Saul13
begin
	set_local_var(5, 1);
	gsay_reply(SCRIPT_SAUL, 145);
	giq_option(4, SCRIPT_SAUL, 146, Saul19, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_SAUL, 147, Saul14, NEUTRAL_REACTION);
	call Goodbyes;
	giq_option(4, SCRIPT_SAUL, GVar12, SaulEnd, NEUTRAL_REACTION);
end

procedure Saul14
begin
	set_local_var(6, 1);
	gsay_reply(SCRIPT_SAUL, 148);
	if (not(local_var(5))) then begin
		giq_option(4, SCRIPT_SAUL, 149, Saul13, NEUTRAL_REACTION);
	end
	call Goodbyes;
	giq_option(4, SCRIPT_SAUL, GVar12, SaulEnd, NEUTRAL_REACTION);
end

procedure Saul15
begin
	set_local_var(7, 1);
	gsay_reply(SCRIPT_SAUL, 150);
	giq_option(4, SCRIPT_SAUL, 151, Saul17, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_SAUL, 152, Saul18, NEUTRAL_REACTION);
	if (get_critter_stat(dude_obj, 4) >= 6) then begin
		giq_option(6, SCRIPT_SAUL, 153, Saul16, GOOD_REACTION);
	end
	else begin
		call Goodbyes;
		giq_option(4, SCRIPT_SAUL, GVar12, SaulEnd, NEUTRAL_REACTION);
	end
	giq_option(6, SCRIPT_SAUL, 154, Saul24, NEUTRAL_REACTION);
end

procedure Saul16
begin
	call Up_React;
	gsay_reply(SCRIPT_SAUL, 155);
	giq_option(4, SCRIPT_SAUL, 156, Saul18, NEUTRAL_REACTION);
	call Goodbyes;
	giq_option(4, SCRIPT_SAUL, GVar12, SaulEnd, NEUTRAL_REACTION);
end

procedure Saul17
begin
	gsay_reply(SCRIPT_SAUL, 157);
	giq_option(4, SCRIPT_SAUL, 158, Saul18, NEUTRAL_REACTION);
	if ((global_var(GVAR_TRISH_STATUS) bwand 1) or (global_var(GVAR_TRISH_STATUS) bwand 4)) then begin
		giq_option(5, SCRIPT_SAUL, 159, Saul20, NEUTRAL_REACTION);
	end
	call Goodbyes;
	giq_option(4, SCRIPT_SAUL, GVar12, SaulEnd, NEUTRAL_REACTION);
end

procedure Saul18
begin
	if (local_var(1) < 2) then begin
		gsay_reply(SCRIPT_SAUL, 160);
	end
	else begin
		gsay_reply(SCRIPT_SAUL, 161);
	end
	if (not(local_var(5))) then begin
		giq_option(4, SCRIPT_SAUL, 162, Saul13, NEUTRAL_REACTION);
	end
	if (not(local_var(6))) then begin
		giq_option(4, SCRIPT_SAUL, 163, Saul14, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_SAUL, 164, Saul18a, BAD_REACTION);
	giq_option(4, SCRIPT_SAUL, 165, SaulEnd, NEUTRAL_REACTION);
end

procedure Saul18a
begin
	set_local_var(1, 1);
	call Level_To_React;
	call Saul09;
end

procedure Saul19
begin
	gsay_reply(SCRIPT_SAUL, 166);
	giq_option(4, SCRIPT_SAUL, 168, Saul18, NEUTRAL_REACTION);
	if (get_critter_stat(dude_obj, 4) >= 6) then begin
		giq_option(6, SCRIPT_SAUL, 167, Up_React, GOOD_REACTION);
	end
	else begin
		call Goodbyes;
		giq_option(4, SCRIPT_SAUL, 169, SaulEnd, NEUTRAL_REACTION);
	end
end

procedure Saul20
begin
	if (local_var(1) == 1) then begin
		gsay_reply(SCRIPT_SAUL, 169);
	end
	else begin
		if (is_success(roll_vs_skill(dude_obj, 14, 0))) then begin
			gsay_reply(SCRIPT_SAUL, message_str(SCRIPT_SAUL, 170) + message_str(SCRIPT_SAUL, 171));
			if (get_critter_stat(dude_obj, 4) >= 6) then begin
				giq_option(6, SCRIPT_SAUL, 172, Saul21, GOOD_REACTION);
			end
			else begin
				giq_option(4, SCRIPT_SAUL, 173, Saul22, NEUTRAL_REACTION);
			end
		end
		else begin
			gsay_reply(SCRIPT_SAUL, message_str(SCRIPT_SAUL, 170));
		end
	end
	giq_option(4, SCRIPT_SAUL, 174, Saul18, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_SAUL, 175, SaulEnd, NEUTRAL_REACTION);
end

procedure Saul21
begin
	call Up_React;
	set_global_var(GVAR_TRISH_STATUS, global_var(GVAR_TRISH_STATUS) + 8);
	gsay_message(SCRIPT_SAUL, 176, GOOD_REACTION);
end

procedure Saul22
begin
	if (is_success(roll_vs_skill(dude_obj, 14, 0))) then begin
		call Saul21;
	end
	else begin
		gsay_reply(SCRIPT_SAUL, 177);
		giq_option(4, SCRIPT_SAUL, 178, Saul18, NEUTRAL_REACTION);
		giq_option(4, SCRIPT_SAUL, 179, SaulEnd, NEUTRAL_REACTION);
	end
end

procedure Saul23
begin
	if (local_var(1) < 2) then begin
		gsay_reply(SCRIPT_SAUL, 180);
	end
	else begin
		gsay_reply(SCRIPT_SAUL, 181);
	end
	giq_option(4, SCRIPT_SAUL, 182, Saul09, BAD_REACTION);
	if ((global_var(GVAR_TRISH_STATUS) bwand 1) or (global_var(GVAR_TRISH_STATUS) bwand 4) and not(global_var(GVAR_TRISH_STATUS) bwand 8)) then begin
		giq_option(4, SCRIPT_SAUL, 183, Saul20, NEUTRAL_REACTION);
	end
	if (not(local_var(5))) then begin
		giq_option(4, SCRIPT_SAUL, 184, Saul13, NEUTRAL_REACTION);
	end
	call Goodbyes;
	giq_option(4, SCRIPT_SAUL, GVar12, SaulEnd, NEUTRAL_REACTION);
end

procedure Saul24
begin
	gsay_reply(SCRIPT_SAUL, 185);
	giq_option(4, SCRIPT_SAUL, 186, SaulEnd, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_SAUL, 187, Saul18, NEUTRAL_REACTION);
end

procedure SaulBoxing
begin
	reg_anim_func(2, self_obj);
	reg_anim_func(2, challenger_ptr);
	if (GVar11 == 1) then begin
		reg_anim_func(1, 1);
		reg_anim_animate(self_obj, 16, -1);
		if (is_success(roll_vs_skill(self_obj, 3, 0))) then begin
			if (GVar9 >= (get_critter_stat(challenger_ptr, 2) * 2)) then begin
				reg_anim_animate(challenger_ptr, 20, 4);
				reg_anim_animate(challenger_ptr, 48, -1);
				add_timer_event(self_obj, game_ticks(2), 2);
			end
			else begin
				reg_anim_animate(challenger_ptr, 14, 4);
				GVar9 := GVar9 + 1;
				add_timer_event(self_obj, game_ticks(random(1, 2)), 1);
			end
		end
		else begin
			reg_anim_animate(challenger_ptr, 13, 4);
			add_timer_event(self_obj, game_ticks(random(1, 2)), 1);
		end
		reg_anim_func(3, 0);
	end
	else begin
		reg_anim_func(1, 1);
		reg_anim_animate(challenger_ptr, 16, -1);
		if (is_success(roll_vs_skill(challenger_ptr, 3, 0))) then begin
			if (GVar10 >= (get_critter_stat(self_obj, 2) * 2)) then begin
				reg_anim_animate(self_obj, 20, 4);
				reg_anim_animate(self_obj, 48, -1);
				add_timer_event(self_obj, game_ticks(2), 3);
			end
			else begin
				reg_anim_animate(self_obj, 14, 4);
				GVar10 := GVar10 + 1;
				add_timer_event(self_obj, game_ticks(random(1, 2)), 1);
			end
		end
		else begin
			reg_anim_animate(self_obj, 13, 4);
			add_timer_event(self_obj, game_ticks(random(1, 2)), 1);
		end
		reg_anim_func(3, 0);
	end
end

procedure SaulCombat
begin
	GVar5 := 1;
end

procedure SaulEnd
begin
end

procedure create_challenger
begin
	challenger_ptr := random(0, 4);
	if (challenger_ptr == 4) then begin
		challenger_ptr := create_object_sid(16777226, 0, 0, 25);
	end
	else begin
		if (challenger_ptr == 3) then begin
			challenger_ptr := create_object_sid(16777227, 0, 0, 25);
		end
		else begin
			if (challenger_ptr == 2) then begin
				challenger_ptr := create_object_sid(16777238, 0, 0, 25);
			end
			else begin
				if (challenger_ptr == 1) then begin
					challenger_ptr := create_object_sid(16777218, 0, 0, 25);
				end
				else begin
					if (challenger_ptr == 0) then begin
						challenger_ptr := create_object_sid(16777243, 0, 0, 25);
					end
				end
			end
		end
	end
	critter_attempt_placement(challenger_ptr, tile_num_in_direction(tile_num(self_obj), 1, 1), 0);
	anim(challenger_ptr, 1000, 4);
end

procedure sleeping
begin
	if (local_var(4) == 1) then begin
		if (not(GVar0) and (game_time_hour >= GVar1) and (game_time_hour < GVar2) or (GVar0 and ((game_time_hour >= GVar1) or (game_time_hour < GVar2)))) then begin
			if (((game_time_hour - GVar1) < 10) and ((game_time_hour - GVar1) > 0)) then begin
				if (tile_num(self_obj) != GVar3) then begin
					animate_move_obj_to_tile(self_obj, GVar3, ANIMATE_WALK);
				end
				else begin
					set_local_var(4, 0);
				end
			end
			else begin
				move_to(self_obj, GVar3, elevation(self_obj));
				if (tile_num(self_obj) == GVar3) then begin
					set_local_var(4, 0);
				end
			end
		end
	end
	else begin
		if (GVar0 and (game_time_hour >= GVar2) and (game_time_hour < GVar1) or (not(GVar0) and ((game_time_hour >= GVar2) or (game_time_hour < GVar1)))) then begin
			if (((game_time_hour - GVar2) < 10) and ((game_time_hour - GVar2) > 0)) then begin
				if (tile_num(self_obj) != GVar4) then begin
					animate_move_obj_to_tile(self_obj, self_obj, ANIMATE_WALK);
				end
				else begin
					set_local_var(4, 1);
				end
			end
			else begin
				if (tile_num(self_obj) != GVar4) then begin
					move_to(self_obj, GVar4, elevation(self_obj));
				end
				else begin
					set_local_var(4, 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
	GVar12 := message_str(SCRIPT_MODREACT, random(100, 105));
end