#include <define.h>

//#define NAME                    SCRIPT_

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



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

variable initialized1;
variable damage_counter;


procedure start
begin
	if (not(initialized1)) then begin
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_AI_PACKET, AI_COW);
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_TEAM_NUM, 4);
		initialized1 := 1;
	end
	else begin
		if (script_action == critter_proc) then begin
			call critter_p_proc;
		end
		else begin
			if (script_action == damage_proc) then begin
				call damage_p_proc;
			end
		end
	end
end

procedure critter_p_proc
begin
	script_overrides;
	animate_move_obj_to_tile(self_obj, tile_num_in_direction(tile_num(self_obj), 4, 6), ANIMATE_RUN);
	if ((tile_distance_objs(dude_obj, self_obj) <= 1) and (random(1, 3) == 1)) then begin
		critter_dmg(dude_obj, random(1, 6) + 3, 0);
		critter_injure(dude_obj, 2);
	end
end

procedure damage_p_proc
begin
	if (damage_counter > 2) then begin
		attack_complex(self_obj, 0, 1, 0, 0, 30000, 0, 0);
	end
	else begin
		damage_counter := damage_counter + 1;
	end
end