#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure critter_p_proc;
procedure talk_p_proc;
procedure pickup_p_proc;
procedure look_at_p_proc;
procedure destroy_p_proc;

variable hostile1;
variable Only_Once := 1;


procedure start
begin
	if (Only_Once) then begin
		Only_Once := 0;
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_TEAM_NUM, 44);
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_AI_PACKET, AI_BOS_ELDERS);
	end
	if (script_action == talk_proc) then begin
		call talk_p_proc;
	end
	else begin
		if (script_action == critter_proc) then begin
			call critter_p_proc;
		end
		else begin
			if (script_action == pickup_proc) then begin
				call pickup_p_proc;
			end
			else begin
				if (script_action == look_at_proc) then begin
					call look_at_p_proc;
				end
				else begin
					if (script_action == destroy_proc) then begin
						call destroy_p_proc;
					end
				end
			end
		end
	end
end

procedure critter_p_proc
begin
	if (global_var(GVAR_ENEMY_BROTHERHOOD)) then begin
		hostile1 := 1;
	end
	if (tile_distance_objs(self_obj, dude_obj) > 12) then begin
		hostile1 := 0;
	end
	if (hostile1) then begin
		set_global_var(GVAR_ENEMY_BROTHERHOOD, 1);
		hostile1 := 0;
		attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
	end
end

procedure talk_p_proc
begin
	float_msg(self_obj, message_str(SCRIPT_BROELD, random(101, 105)), FLOAT_MSG_RED);
end

procedure pickup_p_proc
begin
	hostile1 := 1;
end

procedure look_at_p_proc
begin
	display_msg(message_str(SCRIPT_BROELD, 100));
end

procedure destroy_p_proc
begin
	set_global_var(GVAR_ENEMY_BROTHERHOOD, 1);
end