#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 talk_p_proc;
procedure Amber0;
procedure Amber1;
procedure Amber2;
procedure Amber3;
procedure Amber3a;
procedure Amber4;
procedure Amber5;
procedure Amber6;
procedure Amber7;
procedure Amber8;
procedure Amber9;
procedure Amber10;
procedure Amber11;
procedure Amber12;
procedure Amber13;
procedure Amber14;
procedure Amber15;
procedure Amber16;
procedure Amber17;
procedure Amber18;
procedure AmberEnd;

variable initialized1;


procedure start
begin
	if (not(initialized1)) then begin
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_TEAM_NUM, 46);
		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 == talk_proc) then begin
						call talk_p_proc;
					end
				end
			end
		end
	end
end

procedure critter_p_proc
begin
	if (global_var(GVAR_DESTROY_FOLLOWERS) == 2) then begin
		kill_critter(self_obj, 59);
	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
end

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

procedure talk_p_proc
begin
	script_overrides;
	if (global_var(GVAR_TRAIN_FOLLOWERS) == 1) then begin
		call Amber18;
	end
	else begin
		if ((game_time_hour >= 700) and (game_time_hour < 1800)) then begin
			call Amber0;
		end
		else begin
			set_local_var(0, local_var(0) + 1);
			start_gdialog(SCRIPT_AMBER, self_obj, 4, -1, -1);
			gsay_start;
			call Amber1;
			gsay_end;
			end_dialogue;
		end
	end
end

procedure Amber0
begin
	float_msg(self_obj, message_str(SCRIPT_AMBER, 101), FLOAT_MSG_NORMAL);
end

procedure Amber1
begin
	gsay_reply(SCRIPT_AMBER, 102);
	giq_option(4, SCRIPT_AMBER, 103, Amber2, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_AMBER, 104, Amber3, NEUTRAL_REACTION);
	giq_option(7, SCRIPT_AMBER, 105, Amber17, NEUTRAL_REACTION);
end

procedure Amber2
begin
	gsay_message(SCRIPT_AMBER, 106, NEUTRAL_REACTION);
end

procedure Amber3
begin
	gsay_reply(SCRIPT_AMBER, 107);
	if (not(local_var(1))) then begin
		giq_option(4, SCRIPT_AMBER, 108, Amber4, NEUTRAL_REACTION);
	end
	giq_option(4, SCRIPT_AMBER, 109, AmberEnd, NEUTRAL_REACTION);
	if (local_var(2) == 0) then begin
		giq_option(4, SCRIPT_AMBER, 110, Amber3a, NEUTRAL_REACTION);
	end
	giq_option(5, SCRIPT_AMBER, 111, Amber16, NEUTRAL_REACTION);
end

procedure Amber3a
begin
	if (local_var(0) < 6) then begin
		call Amber9;
	end
	else begin
		if (local_var(0) == 6) then begin
			call Amber10;
		end
		else begin
			call Amber15;
		end
	end
end

procedure Amber4
begin
	gsay_reply(SCRIPT_AMBER, 112);
	giq_option(4, SCRIPT_AMBER, 113, Amber5, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_AMBER, 114, Amber8, NEUTRAL_REACTION);
	giq_option(5, SCRIPT_AMBER, 115, AmberEnd, NEUTRAL_REACTION);
end

procedure Amber5
begin
	gsay_reply(SCRIPT_AMBER, 116);
	giq_option(4, SCRIPT_AMBER, 117, Amber6, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_AMBER, 118, Amber7, NEUTRAL_REACTION);
end

procedure Amber6
begin
	variable LVar0 := 0;
	set_local_var(1, local_var(1) + 1);
	gsay_message(SCRIPT_AMBER, 119, NEUTRAL_REACTION);
	gfade_out(800);
	gfade_in(800);
	LVar0 := 3600 * 9;
	game_time_advance(game_ticks(LVar0));
	critter_mod_skill(dude_obj, 17, 15);
	gsay_message(SCRIPT_AMBER, 120, NEUTRAL_REACTION);
end

procedure Amber7
begin
	gsay_message(SCRIPT_AMBER, 121, NEUTRAL_REACTION);
end

procedure Amber8
begin
	variable LVar0 := 0;
	set_local_var(1, local_var(1) + 1);
	gsay_message(SCRIPT_AMBER, 122, NEUTRAL_REACTION);
	gfade_out(800);
	gfade_in(800);
	LVar0 := 3600 * 7;
	game_time_advance(game_ticks(LVar0));
	critter_mod_skill(dude_obj, 17, 15);
	gsay_message(SCRIPT_AMBER, 123, NEUTRAL_REACTION);
end

procedure Amber9
begin
	gsay_message(SCRIPT_AMBER, 124, NEUTRAL_REACTION);
end

procedure Amber10
begin
	set_local_var(2, local_var(2) + 1);
	gsay_reply(SCRIPT_AMBER, 125);
	giq_option(4, SCRIPT_AMBER, 126, Amber11, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_AMBER, 127, Amber12, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_AMBER, 128, Amber13, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_AMBER, 129, Amber14, NEUTRAL_REACTION);
end

procedure Amber11
begin
	variable LVar0 := 0;
	gsay_message(SCRIPT_AMBER, 130, NEUTRAL_REACTION);
	LVar0 := 3600 * 10;
	gfade_out(800);
	gfade_in(800);
	game_time_advance(game_ticks(LVar0));
	critter_mod_skill(dude_obj, 8, 12);
	critter_mod_skill(dude_obj, 9, 10);
	critter_mod_skill(dude_obj, 10, 8);
	critter_mod_skill(dude_obj, 11, 8);
	gsay_message(SCRIPT_AMBER, 131, NEUTRAL_REACTION);
end

procedure Amber12
begin
	variable LVar0 := 0;
	gsay_message(SCRIPT_AMBER, 132, NEUTRAL_REACTION);
	LVar0 := 3600 * 10;
	gfade_out(800);
	gfade_in(800);
	game_time_advance(game_ticks(LVar0));
	critter_mod_skill(dude_obj, 3, 10);
	critter_mod_skill(dude_obj, 0, 8);
	critter_mod_skill(dude_obj, 5, 8);
	critter_mod_skill(dude_obj, 4, 6);
	gsay_message(SCRIPT_AMBER, 133, NEUTRAL_REACTION);
end

procedure Amber13
begin
	variable LVar0 := 0;
	gsay_message(SCRIPT_AMBER, 134, NEUTRAL_REACTION);
	LVar0 := 3600 * 10;
	gfade_out(800);
	gfade_in(800);
	game_time_advance(game_ticks(LVar0));
	critter_mod_skill(dude_obj, 17, 10);
	critter_mod_skill(dude_obj, 8, 8);
	critter_mod_skill(dude_obj, 5, 8);
	critter_mod_skill(dude_obj, 11, 6);
	gsay_message(SCRIPT_AMBER, 135, NEUTRAL_REACTION);
end

procedure Amber14
begin
	variable LVar0 := 0;
	gsay_message(SCRIPT_AMBER, 136, NEUTRAL_REACTION);
	LVar0 := 3600 * 10;
	gfade_out(800);
	gfade_in(800);
	game_time_advance(game_ticks(LVar0));
	critter_mod_skill(dude_obj, 15, 10);
	critter_mod_skill(dude_obj, 14, 8);
	critter_mod_skill(dude_obj, 16, 8);
	critter_mod_skill(dude_obj, 4, 6);
	gsay_message(SCRIPT_AMBER, 137, NEUTRAL_REACTION);
end

procedure Amber15
begin
	gsay_message(SCRIPT_AMBER, 138, NEUTRAL_REACTION);
end

procedure Amber16
begin
	gsay_message(SCRIPT_AMBER, 139, NEUTRAL_REACTION);
end

procedure Amber17
begin
	gsay_reply(SCRIPT_AMBER, 140);
	if (local_var(2) == 0) then begin
		giq_option(7, SCRIPT_AMBER, 141, Amber10, NEUTRAL_REACTION);
	end
	giq_option(7, SCRIPT_AMBER, 142, AmberEnd, NEUTRAL_REACTION);
	if (not(local_var(1))) then begin
		giq_option(6, SCRIPT_AMBER, 143, Amber4, NEUTRAL_REACTION);
	end
end

procedure Amber18
begin
	float_msg(self_obj, message_str(SCRIPT_AMBER, 144), FLOAT_MSG_NORMAL);
end

procedure AmberEnd
begin
end