#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure do_dialogue;
procedure guard00;
procedure first;
procedure notfirst;


procedure start
begin
	variable LVar0 := 0;
	if (script_action == talk_proc) then begin
		call do_dialogue;
	end
	else begin
		if (script_action == destroy_proc) then 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
		end
		else begin
			if ((script_action == look_at_proc) or (script_action == description_proc)) then begin
				script_overrides;
				display_msg(message_str(SCRIPT_JTPEASNT, 100));
			end
		end
	end
end

procedure do_dialogue
begin
	call guard00;
end

procedure guard00
begin
	variable LVar0 := 0;
	if (dude_is_male) then begin
		LVar0 := random(1, 2);
	end
	else begin
		LVar0 := random(1, 3);
	end
	if (LVar0 == 1) then begin
		float_msg(self_obj, message_str(SCRIPT_JTPEASNT, 103), FLOAT_MSG_NORMAL);
	end
	else begin
		if (LVar0 == 2) then begin
			float_msg(self_obj, message_str(SCRIPT_JTPEASNT, 104), FLOAT_MSG_NORMAL);
		end
		else begin
			if (LVar0 == 3) then begin
				float_msg(self_obj, message_str(SCRIPT_JTPEASNT, 105), FLOAT_MSG_NORMAL);
			end
		end
	end
end

procedure first
begin
end

procedure notfirst
begin
end