#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure do_dialogue;
procedure elder01;
procedure elder02;
procedure elder03;
procedure elder04;
procedure elder05;
procedure elder06;
procedure elder07;

variable whim;
variable reaction;
variable in_combat;
variable rndx;
variable rndy;
variable new_obj;
variable new_obj_picked;


procedure start
begin
	variable LVar0 := 0;
	if (script_action == talk_proc) then begin
		call do_dialogue;
	end
	else begin
		if (script_action == look_at_proc) then begin
			script_overrides;
			display_msg(message_str(SCRIPT_ELDER, 100));
		end
		else begin
			if (script_action == destroy_proc) then begin
				set_global_var(GVAR_QUEST_PEOPLE, 1);
			end
		end
	end
end

procedure do_dialogue
begin
	start_gdialog(SCRIPT_ELDER, self_obj, 4, -1, -1);
	gsay_start;
	if ((global_var(GVAR_QUEST_PEOPLE) != 0) or (global_var(GVAR_DOGS_KILLED) != 0)) then begin
		set_global_var(GVAR_CHILD_KILLER_SHADY, 1);
		set_global_var(GVAR_CHILD_KILLER_HUB, 1);
	end
	if (global_var(GVAR_CHILD_KILLER_SHADY)) then begin
		call elder07;
	end
	else begin
		if (global_var(GVAR_CHILD_KILLER_HUB)) then begin
			call elder06;
		end
		else begin
			gsay_reply(SCRIPT_ELDER, 101);
			gsay_option(SCRIPT_ELDER, 102, elder01, NEUTRAL_REACTION);
			gsay_option(SCRIPT_ELDER, 103, elder02, NEUTRAL_REACTION);
		end
	end
	gsay_end;
	end_dialogue;
end

procedure elder01
begin
	dialogue_reaction(-1);
	gsay_reply(SCRIPT_ELDER, 104);
	gsay_option(SCRIPT_ELDER, 105, elder03, NEUTRAL_REACTION);
end

procedure elder02
begin
	dialogue_reaction(1);
	gsay_reply(SCRIPT_ELDER, 106);
	gsay_option(SCRIPT_ELDER, 107, elder03, NEUTRAL_REACTION);
end

procedure elder03
begin
	gsay_reply(SCRIPT_ELDER, 108);
	gsay_option(SCRIPT_ELDER, 109, elder05, NEUTRAL_REACTION);
	gsay_option(SCRIPT_ELDER, 110, elder04, NEUTRAL_REACTION);
end

procedure elder04
begin
	set_global_var(GVAR_CHILD_KILLER_SHADY, 1);
	set_global_var(GVAR_CHILD_KILLER_HUB, 1);
	dialogue_reaction(1);
	gsay_reply(SCRIPT_ELDER, 111);
end

procedure elder05
begin
	variable LVar0 := 0;
	set_global_var(GVAR_CHILD_KILLER_HUB, 1);
	dialogue_reaction(-1);
	gsay_reply(SCRIPT_ELDER, 112);
	LVar0 := create_object_sid(1, 0, 0, -1);
	add_obj_to_inven(dude_obj, LVar0);
	LVar0 := create_object_sid(10, 0, 0, -1);
	add_obj_to_inven(dude_obj, LVar0);
	LVar0 := create_object_sid(34, 0, 0, -1);
	add_obj_to_inven(dude_obj, LVar0);
	LVar0 := create_object_sid(34, 0, 0, -1);
	add_obj_to_inven(dude_obj, LVar0);
end

procedure elder06
begin
	gsay_message(SCRIPT_ELDER, 113, NEUTRAL_REACTION);
end

procedure elder07
begin
	dialogue_reaction(1);
	gsay_message(SCRIPT_ELDER, 114, NEUTRAL_REACTION);
end