{$I HKS_SaveCData.script}

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

{$I HKS_Functions.script}

var EVENT_TakeOverTheVillage : KD_Event;

procedure TakeOverTheVillage;
var I : Integer;
begin
	ChangeHousesOwner(S.PlayerGetAllHouses(2), PLAYER, true, true);
	for I := 0 to 4 do
		A.GiveUnit(PLAYER, 0, 43,104, 4);
	for I := 0 to 2 do
		A.GiveUnit(PLAYER, 9, 43, 106, 4);
end;

procedure OnTick;
begin
      If States.GameTime = 10 then
begin
     Actions.OverlayTextSetFormatted(-1, '1', []);
     Actions.OverlayTextAppendFormatted(-1, '<$1>', []);
     A.PlayOgg(0, '01', 1);
end;
     If States.GameTime = 3000 then
begin
   Actions.OverlayTextSetFormatted(-1, '2', []);
   Actions.OverlayTextAppendFormatted(-1, '<$2>', []);
   A.PlayOgg(0, '02', 1);
end;
	
	If GT mod 10 <> 0 then 
		Exit;
	If EVENT_TakeOverTheVillage.Finished then 
		Exit;
	
	If S.StatArmyCount(2) = 0 then 
		FinEv(EVENT_TakeOverTheVillage);
end;
	
	
procedure OnMissionStart;
begin
	EvCreate(EVENT_TakeOverTheVillage, 'Take over', '<$3>');
	EVENT_TakeOverTheVillage.DoAtEnd := @TakeOverTheVillage;
end;