#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 ChdScout0;
procedure ChdScout1;
procedure ChdScout2;
procedure ChdScout3;
procedure ChdScout4;
procedure ChdScout5;
procedure ChdScout6;
procedure ChdScout7;
procedure ChdScout8;
procedure ChdScout9;
procedure ChdScout10;
procedure ChdScout11;
procedure ChdScout12;
procedure ChdScout13;
procedure ChdScout14;
procedure ChdScout15;
procedure ChdScout16;
procedure ChdScout17;
procedure ChdScout17a;
procedure ChdScout18;
procedure ChdScout19;
procedure ChdScout20;
procedure ChdScout21;
procedure ChdScout22;
procedure ChdScout23;
procedure ChdScout24;
procedure ChdScout25;
procedure ChdScout26;
procedure ChdScout27;
procedure ChdScout28;
procedure ChdScout29;
procedure ChdScout30;
procedure ChdScout31;
procedure ChdScout32;
procedure ChdScout33;
procedure ChdScout34;
procedure ChdScout35;
procedure ChdScoutend;
procedure combat;

variable hostile1;
variable initialized1;


procedure start
begin
	if (not(initialized1)) then begin
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_TEAM_NUM, 20);
		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 (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_CHDSCOUT, 100));
end

procedure talk_p_proc
begin
	if (local_var(0)) then begin
		call ChdScout35;
	end
	else begin
		set_local_var(0, 1);
		start_gdialog(SCRIPT_CHDSCOUT, self_obj, 4, -1, -1);
		gsay_start;
		call ChdScout0;
		gsay_end;
		end_dialogue;
	end
end

procedure ChdScout0
begin
	gsay_reply(SCRIPT_CHDSCOUT, 101);
	giq_option(-3, SCRIPT_CHDSCOUT, 102, ChdScout1, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_CHDSCOUT, 103, ChdScout13, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_CHDSCOUT, 104, ChdScout25, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_CHDSCOUT, 105, ChdScout26, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_CHDSCOUT, 106, ChdScout27, NEUTRAL_REACTION);
end

procedure ChdScout1
begin
	gsay_reply(SCRIPT_CHDSCOUT, 107);
	giq_option(-3, SCRIPT_CHDSCOUT, 108, ChdScout2, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_CHDSCOUT, 109, combat, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_CHDSCOUT, 110, ChdScout9, NEUTRAL_REACTION);
end

procedure ChdScout2
begin
	gsay_reply(SCRIPT_CHDSCOUT, 111);
	giq_option(-3, SCRIPT_CHDSCOUT, 112, combat, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_CHDSCOUT, 113, ChdScout3, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_CHDSCOUT, 114, ChdScout4, NEUTRAL_REACTION);
end

procedure ChdScout3
begin
	gsay_message(SCRIPT_CHDSCOUT, 115, NEUTRAL_REACTION);
end

procedure ChdScout4
begin
	gsay_reply(SCRIPT_CHDSCOUT, 116);
	giq_option(-3, SCRIPT_CHDSCOUT, 117, ChdScout5, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_CHDSCOUT, 118, combat, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_CHDSCOUT, 119, ChdScout6, NEUTRAL_REACTION);
end

procedure ChdScout5
begin
	gsay_message(SCRIPT_CHDSCOUT, 120, NEUTRAL_REACTION);
end

procedure ChdScout6
begin
	gsay_reply(SCRIPT_CHDSCOUT, 121);
	giq_option(-3, SCRIPT_CHDSCOUT, 122, ChdScout7, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_CHDSCOUT, 123, ChdScout5, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_CHDSCOUT, 124, ChdScout8, NEUTRAL_REACTION);
end

procedure ChdScout7
begin
	gsay_message(SCRIPT_CHDSCOUT, 125, NEUTRAL_REACTION);
end

procedure ChdScout8
begin
	gsay_message(SCRIPT_CHDSCOUT, 126, NEUTRAL_REACTION);
end

procedure ChdScout9
begin
	gsay_reply(SCRIPT_CHDSCOUT, 127);
	giq_option(-3, SCRIPT_CHDSCOUT, 128, ChdScout10, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_CHDSCOUT, 129, ChdScout12, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_CHDSCOUT, 130, ChdScoutend, NEUTRAL_REACTION);
end

procedure ChdScout10
begin
	gsay_reply(SCRIPT_CHDSCOUT, 131);
	giq_option(-3, SCRIPT_CHDSCOUT, 132, ChdScout11, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_CHDSCOUT, 133, ChdScoutend, NEUTRAL_REACTION);
end

procedure ChdScout11
begin
	gsay_message(SCRIPT_CHDSCOUT, 134, NEUTRAL_REACTION);
end

procedure ChdScout12
begin
	gsay_reply(SCRIPT_CHDSCOUT, 135);
	giq_option(-3, SCRIPT_CHDSCOUT, 136, ChdScoutend, NEUTRAL_REACTION);
end

procedure ChdScout13
begin
	gsay_reply(SCRIPT_CHDSCOUT, 137);
	giq_option(4, SCRIPT_CHDSCOUT, 138, ChdScout14, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_CHDSCOUT, 139, ChdScout15, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_CHDSCOUT, message_str(SCRIPT_CHDSCOUT, 140) + proto_data(obj_pid(dude_obj), 1) + message_str(SCRIPT_CHDSCOUT, 141), ChdScout22, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_CHDSCOUT, 142, ChdScout24, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_CHDSCOUT, 143, combat, NEUTRAL_REACTION);
end

procedure ChdScout14
begin
	gsay_message(SCRIPT_CHDSCOUT, 144, NEUTRAL_REACTION);
	call combat;
end

procedure ChdScout15
begin
	gsay_reply(SCRIPT_CHDSCOUT, 145);
	giq_option(4, SCRIPT_CHDSCOUT, 146, ChdScout16, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_CHDSCOUT, 147, ChdScout17, NEUTRAL_REACTION);
end

procedure ChdScout16
begin
	gsay_message(SCRIPT_CHDSCOUT, 148, NEUTRAL_REACTION);
	call combat;
end

procedure ChdScout17
begin
	gsay_reply(SCRIPT_CHDSCOUT, 149);
	giq_option(4, SCRIPT_CHDSCOUT, message_str(SCRIPT_CHDSCOUT, 150) + proto_data(obj_pid(dude_obj), 1) + message_str(SCRIPT_CHDSCOUT, 151), ChdScout17a, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_CHDSCOUT, 152, ChdScout20, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_CHDSCOUT, 153, combat, NEUTRAL_REACTION);
end

procedure ChdScout17a
begin
	if (is_success(roll_vs_skill(dude_obj, 14, 0))) then begin
		call ChdScout18;
	end
	else begin
		call ChdScout19;
	end
end

procedure ChdScout18
begin
	gsay_message(SCRIPT_CHDSCOUT, 154, NEUTRAL_REACTION);
end

procedure ChdScout19
begin
	gsay_message(SCRIPT_CHDSCOUT, 155, NEUTRAL_REACTION);
	call combat;
end

procedure ChdScout20
begin
	gsay_reply(SCRIPT_CHDSCOUT, 156);
	giq_option(4, SCRIPT_CHDSCOUT, message_str(SCRIPT_CHDSCOUT, 157) + proto_data(obj_pid(dude_obj), 1) + message_str(SCRIPT_CHDSCOUT, 158), ChdScout21, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_CHDSCOUT, 159, combat, NEUTRAL_REACTION);
end

procedure ChdScout21
begin
	gsay_message(SCRIPT_CHDSCOUT, 160, NEUTRAL_REACTION);
	call ChdScout17a;
end

procedure ChdScout22
begin
	gsay_reply(SCRIPT_CHDSCOUT, message_str(SCRIPT_CHDSCOUT, 161) + proto_data(obj_pid(dude_obj), 1) + message_str(SCRIPT_CHDSCOUT, 162));
	giq_option(4, SCRIPT_CHDSCOUT, 163, ChdScout23, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_CHDSCOUT, 164, ChdScout23, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_CHDSCOUT, 165, combat, NEUTRAL_REACTION);
end

procedure ChdScout23
begin
	gsay_message(SCRIPT_CHDSCOUT, 166, NEUTRAL_REACTION);
	call combat;
end

procedure ChdScout24
begin
	gsay_message(SCRIPT_CHDSCOUT, 167, NEUTRAL_REACTION);
	call combat;
end

procedure ChdScout25
begin
	gsay_reply(SCRIPT_CHDSCOUT, 168);
	giq_option(4, SCRIPT_CHDSCOUT, 169, ChdScout14, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_CHDSCOUT, 170, ChdScout15, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_CHDSCOUT, message_str(SCRIPT_CHDSCOUT, 171) + proto_data(obj_pid(dude_obj), 1) + message_str(SCRIPT_CHDSCOUT, 172), ChdScout22, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_CHDSCOUT, 173, ChdScout24, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_CHDSCOUT, 174, combat, NEUTRAL_REACTION);
end

procedure ChdScout26
begin
	gsay_message(SCRIPT_CHDSCOUT, 175, NEUTRAL_REACTION);
	call combat;
end

procedure ChdScout27
begin
	gsay_reply(SCRIPT_CHDSCOUT, 176);
	giq_option(6, SCRIPT_CHDSCOUT, 177, ChdScout28, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_CHDSCOUT, 178, ChdScout29, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_CHDSCOUT, 179, ChdScout30, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_CHDSCOUT, 180, ChdScout34, NEUTRAL_REACTION);
end

procedure ChdScout28
begin
	gsay_message(SCRIPT_CHDSCOUT, 181, NEUTRAL_REACTION);
end

procedure ChdScout29
begin
	gsay_message(SCRIPT_CHDSCOUT, 182, NEUTRAL_REACTION);
end

procedure ChdScout30
begin
	gsay_reply(SCRIPT_CHDSCOUT, 183);
	giq_option(6, SCRIPT_CHDSCOUT, 184, ChdScout31, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_CHDSCOUT, 185, ChdScout32, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_CHDSCOUT, 186, combat, NEUTRAL_REACTION);
end

procedure ChdScout31
begin
	gsay_message(SCRIPT_CHDSCOUT, 187, NEUTRAL_REACTION);
	call combat;
end

procedure ChdScout32
begin
	gsay_reply(SCRIPT_CHDSCOUT, 188);
	giq_option(6, SCRIPT_CHDSCOUT, 189, ChdScout33, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_CHDSCOUT, 190, ChdScout33, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_CHDSCOUT, 191, combat, NEUTRAL_REACTION);
end

procedure ChdScout33
begin
	gsay_reply(SCRIPT_CHDSCOUT, 192);
	giq_option(6, SCRIPT_CHDSCOUT, 193, ChdScoutend, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_CHDSCOUT, 194, combat, NEUTRAL_REACTION);
end

procedure ChdScout34
begin
	gsay_message(SCRIPT_CHDSCOUT, 195, NEUTRAL_REACTION);
	call combat;
end

procedure ChdScout35
begin
	gsay_message(SCRIPT_CHDSCOUT, 196, NEUTRAL_REACTION);
	call combat;
end

procedure ChdScoutend
begin
end

procedure combat
begin
	hostile1 := 1;
end