#include <define.h>

//#define NAME                    SCRIPT_

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



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

variable Initialize := 1;
variable PsstTime;


procedure Start
begin
	if (Initialize) then begin
		if (obj_is_carrying_obj_pid(self_obj, 41) == 0) then begin
			item_caps_adjust(self_obj, random(1, 10));
		end
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_TEAM_NUM, 6);
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_AI_PACKET, AI_GUARD_HUMOROUS);
		if (local_var(4) == 0) then begin
			set_global_var(GVAR_WATER_CHIP_12, global_var(GVAR_WATER_CHIP_12) + 1);
			set_local_var(4, 1);
		end
		Initialize := 0;
	end
end

procedure talk_p_proc
begin
	float_msg(self_obj, message_str(SCRIPT_IRWIN, random(300, 303)), FLOAT_MSG_NORMAL);
end

procedure critter_p_proc
begin
	if (obj_can_see_obj(self_obj, dude_obj)) then begin
		attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
	end
	if ((((game_time / 10) - PsstTime) >= 30) and (tile_distance_objs(self_obj, dude_obj) <= 4)) then begin
		float_msg(self_obj, message_str(SCRIPT_IRWIN, random(300, 303)), FLOAT_MSG_NORMAL);
		PsstTime := game_time / 10;
	end
end

procedure destroy_p_proc
begin
	set_global_var(GVAR_WATER_CHIP_12, global_var(GVAR_WATER_CHIP_12) - 1);
	if (global_var(GVAR_WATER_CHIP_12) == 0) then begin
		set_global_var(GVAR_DESTROY_MASTER_3, 2);
	end
end