#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 look_at_p_proc;
procedure pickup_p_proc;
procedure talk_p_proc;
procedure uthern0;
procedure uthern1;
procedure uthern2;
procedure uthern3;
procedure uthern4;
procedure uthern5;
procedure uthern6;
procedure uthern7;
procedure uthern8;
procedure uthern9;
procedure uthern10;
procedure uthern11;
procedure uthern12;
procedure uthern13;
procedure uthern14;
procedure uthernend;
procedure combat;

variable hostile1;
variable initialized1;


procedure start
begin
	if (not(initialized1)) then begin
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_TEAM_NUM, 34);
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_AI_PACKET, AI_SUPER_MUTANT_SGT);
		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 == 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
					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
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_BAD_MONSTER, global_var(GVAR_BAD_MONSTER) + 1);
		if ((global_var(GVAR_BAD_MONSTER) % 6) == 0) then begin
			set_global_var(GVAR_PLAYER_REPUTATION, global_var(GVAR_PLAYER_REPUTATION) + 1);
		end
	end
end

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

procedure pickup_p_proc
begin
	hostile1 := 1;
end

procedure talk_p_proc
begin
	script_overrides;
	if (local_var(0)) then begin
		call uthern14;
	end
	else begin
		set_local_var(0, 1);
		start_gdialog(SCRIPT_UTHERN, self_obj, 4, -1, -1);
		gsay_start;
		call uthern0;
		gsay_end;
		end_dialogue;
	end
end

procedure uthern0
begin
	gsay_reply(SCRIPT_UTHERN, 101);
	giq_option(-3, SCRIPT_UTHERN, 102, uthern1, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_UTHERN, 103, uthern2, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_UTHERN, 104, combat, NEUTRAL_REACTION);
	giq_option(5, SCRIPT_UTHERN, 105, uthern7, NEUTRAL_REACTION);
	giq_option(8, SCRIPT_UTHERN, 106, uthern13, NEUTRAL_REACTION);
end

procedure uthern1
begin
	gsay_message(SCRIPT_UTHERN, 107, NEUTRAL_REACTION);
	call combat;
end

procedure uthern2
begin
	gsay_reply(SCRIPT_UTHERN, 108);
	giq_option(4, SCRIPT_UTHERN, 109, uthern3, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_UTHERN, 110, combat, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_UTHERN, 111, uthern4, NEUTRAL_REACTION);
end

procedure uthern3
begin
	gsay_message(SCRIPT_UTHERN, 112, NEUTRAL_REACTION);
	call combat;
end

procedure uthern4
begin
	gsay_reply(SCRIPT_UTHERN, 113);
	giq_option(6, SCRIPT_UTHERN, 114, uthern5, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_UTHERN, 115, uthern6, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_UTHERN, 116, combat, NEUTRAL_REACTION);
end

procedure uthern5
begin
	gsay_message(SCRIPT_UTHERN, 117, NEUTRAL_REACTION);
	call combat;
end

procedure uthern6
begin
	gsay_message(SCRIPT_UTHERN, 118, NEUTRAL_REACTION);
	call combat;
end

procedure uthern7
begin
	gsay_reply(SCRIPT_UTHERN, 119);
	giq_option(5, SCRIPT_UTHERN, 120, uthern8, NEUTRAL_REACTION);
	giq_option(5, SCRIPT_UTHERN, 121, uthern12, NEUTRAL_REACTION);
	giq_option(5, SCRIPT_UTHERN, 122, combat, NEUTRAL_REACTION);
end

procedure uthern8
begin
	gsay_reply(SCRIPT_UTHERN, 123);
	giq_option(5, SCRIPT_UTHERN, 124, uthern9, NEUTRAL_REACTION);
	giq_option(5, SCRIPT_UTHERN, 125, uthern10, NEUTRAL_REACTION);
	giq_option(5, SCRIPT_UTHERN, 126, uthern11, NEUTRAL_REACTION);
	giq_option(5, SCRIPT_UTHERN, 127, combat, NEUTRAL_REACTION);
end

procedure uthern9
begin
	gsay_message(SCRIPT_UTHERN, 128, NEUTRAL_REACTION);
	call combat;
end

procedure uthern10
begin
	gsay_message(SCRIPT_UTHERN, 129, NEUTRAL_REACTION);
	call combat;
end

procedure uthern11
begin
	gsay_message(SCRIPT_UTHERN, 130, NEUTRAL_REACTION);
	call combat;
end

procedure uthern12
begin
	gsay_reply(SCRIPT_UTHERN, 131);
	giq_option(5, SCRIPT_UTHERN, 132, combat, NEUTRAL_REACTION);
	giq_option(5, SCRIPT_UTHERN, 133, combat, NEUTRAL_REACTION);
	giq_option(5, SCRIPT_UTHERN, 134, combat, NEUTRAL_REACTION);
end

procedure uthern13
begin
	gsay_message(SCRIPT_UTHERN, 135, NEUTRAL_REACTION);
	call combat;
end

procedure uthern14
begin
	float_msg(self_obj, message_str(SCRIPT_UTHERN, 136), FLOAT_MSG_NORMAL);
	call combat;
end

procedure uthernend
begin
end

procedure combat
begin
	hostile1 := 1;
end