{$I HKS_SaveCData.script}

{.$DEFINE FEED}
{.$DEFINE RES_HOUSES}
{.$DEFINE PATROL}
{.$DEFINE DIFFICULTY}
{.$DEFINE REBUILD}
{.$DEFINE ANIMATION}
{.$DEFINE HERO}

{$I HKS_Functions.script}
var EVENT_CaveMans : KD_Event;

function CheckUnitAtLocation(aPos : TKMpoint) : Boolean;
begin
	Result := false;
	If S.UnitAt(aPos.X,aPos.Y) > 0 then 
		If S.unitowner(S.UnitAt(aPos.X,aPos.Y)) = PLAYER then
			Result := true;
end;

Procedure OnTick;
begin
	If GT mod 10 <> 0 then 
		Exit;
		
	If EVENT_CaveMans.Finished then 
		Exit;
		
	If CheckUnitAtLocation(U.KMPoint(4, 38)) or CheckUnitAtLocation(U.KMPoint(3, 38)) then 
	begin
		FinEv(EVENT_CaveMans)
		A.GroupOrderWalk(A.GiveGroup(PLAYER, 16, 1, 39, 4, 9, 2), 10, 47, 3);
	end;
end;

procedure OnMissionStart;
begin
	EvCreate(EVENT_CaveMans, 'Cave', '<$1>');
end;