procedure critter_p_proc
begin
if (get_critter_stat(self_obj, 35) < get_critter_stat(self_obj, 7)) then begin
if (not(local_var(7))) then begin
set_local_var(7, 1);
end
if ((not(obj_on_screen(self_obj))) or (tile_distance_objs(dude_obj, self_obj) > 30)) then begin
set_global_var(399, global_var(399) bwor 64);
destroy_object(self_obj);
end
else begin
if (tile_distance_objs(dude_obj, self_obj) < 15) then begin
if (anim_busy(self_obj) == 0) then begin
global_temp := rotation_to_tile(tile_num(dude_obj), tile_num(self_obj));
animate_move_obj_to_tile(self_obj, tile_num_in_direction(tile_num(self_obj), global_temp, random(30, 40)), 1);
global_temp := (global_temp + 1) % 6;
while((anim_busy(self_obj) == 0) and (global_temp != rotation_to_tile(tile_num(dude_obj), tile_num(self_obj)))) do begin
debug_msg("flee loop: rot == " + global_temp);
animate_move_obj_to_tile(self_obj, tile_num_in_direction(tile_num(self_obj), global_temp, random(30, 40)), 1);
global_temp := (global_temp + 1) % 6;
end
end
end
else begin
if (not(anim_busy(self_obj))) then begin
animate_move_obj_to_tile(self_obj, tile_num_in_direction(tile_num(self_obj), rotation_to_tile(tile_num(dude_obj), tile_num(self_obj)), 30), 1);
end
end
end
end
else begin
if (not(combat_is_initialized) and (local_var(5) == 2) and obj_can_see_obj(self_obj, dude_obj)) then begin
attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
end
end
end