#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure critter_p_proc;
procedure timed_event_p_proc;

variable hostile1;
variable initialized1;


procedure start
begin
	if (not(initialized1)) then begin
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_AI_PACKET, AI_MOLE_RATS);
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_TEAM_NUM, 8);
		add_timer_event(self_obj, game_ticks(random(1, 5)), 0);
		initialized1 := 1;
	end
	else begin
		if (script_action == critter_proc) then begin
			call critter_p_proc;
		end
		else begin
			if (script_action == timed_event_proc) then begin
				call timed_event_p_proc;
			end
		end
	end
end

procedure critter_p_proc
begin
	if (hostile1 or (tile_distance_objs(dude_obj, self_obj) <= 2)) then begin
		hostile1 := 0;
		attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
	end
end

procedure timed_event_p_proc
begin
	animate_move_obj_to_tile(self_obj, tile_num_in_direction(tile_num(self_obj), random(0, 5), random(1, 4)), ANIMATE_WALK);
	add_timer_event(self_obj, game_ticks(random(1, 5)), 0);
end