#include <define.h>

//#define NAME                    SCRIPT_

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


variable GVar0;
variable GVar1;
variable GVar2;
variable GVar3 := 29081;

procedure start;
#include <push.h>
procedure do_dialogue;
procedure go_inside;
procedure Lenore00;
procedure Lenore01;
procedure Lenore02;
procedure Lenore03;
procedure Lenore04;

import variable dog_is_angry;
import variable smartass;
import variable smartass2;


procedure start
begin
	if (not(GVar2)) then begin
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_TEAM_NUM, 5);
		GVar2 := 1;
	end
	else begin
		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
					set_global_var(GVAR_GOOD_MONSTER, global_var(GVAR_GOOD_MONSTER) + 1);
					if ((global_var(GVAR_GOOD_MONSTER) % 7) == 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_DEMOPEAS, 100));
				end
				else begin
					if (script_action == pickup_proc) then begin
						attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
					end
					else begin
						if (script_action == critter_proc) then begin
							if (smartass2) then begin
								call Lenore00;
							end
							if (not(dog_is_angry)) then begin
								call go_inside;
							end
						end
						else begin
							if (script_action == use_skill_on_proc) then begin
								if (action_being_used == 14) then begin
									dialogue_system_enter;
								end
							end
						end
					end
				end
			end
		end
	end
end

procedure do_dialogue
begin
	if (global_var(GVAR_DOG_EMPATHY)) then begin
		call Lenore02;
	end
	else begin
		if (not(dog_is_angry)) then begin
			call Lenore04;
		end
		else begin
			if ((obj_item_subtype(critter_inven_obj(dude_obj, 1)) == 3) or (obj_item_subtype(critter_inven_obj(dude_obj, 2)) == 3)) then begin
				call Lenore01;
			end
			else begin
				call Lenore03;
			end
		end
	end
end

procedure go_inside
begin
	animate_move_obj_to_tile(self_obj, GVar3, ANIMATE_WALK);
end

procedure Lenore00
begin
	variable LVar0 := 0;
	variable LVar1 := 0;
	LVar0 := random(1, 3);
	if (LVar0 == 1) then begin
		LVar1 := message_str(SCRIPT_DEMOPEAS, 101);
	end
	else begin
		if (LVar0 == 2) then begin
			LVar1 := message_str(SCRIPT_DEMOPEAS, 102);
		end
		else begin
			set_global_var(GVAR_DOG_2, 1);
			LVar1 := message_str(SCRIPT_DEMOPEAS, 103);
		end
	end
	if (dog_is_angry) then begin
		float_msg(self_obj, LVar1, FLOAT_MSG_NORMAL);
	end
	smartass2 := 0;
end

procedure Lenore01
begin
	if (dog_is_angry) then begin
		float_msg(self_obj, message_str(SCRIPT_DEMOPEAS, 104), FLOAT_MSG_NORMAL);
	end
end

procedure Lenore02
begin
	if (dog_is_angry) then begin
		float_msg(self_obj, message_str(SCRIPT_DEMOPEAS, 105), FLOAT_MSG_NORMAL);
	end
end

procedure Lenore03
begin
	float_msg(self_obj, message_str(SCRIPT_DEMOPEAS, 106), FLOAT_MSG_NORMAL);
	smartass := 1;
end

procedure Lenore04
begin
	float_msg(self_obj, message_str(SCRIPT_DEMOPEAS, 107), FLOAT_MSG_NORMAL);
end