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

{$I HKS_Functions.script}
{$I HKS_SpecialUnits.script}
{$I HKS_SaveCData.script}

//{$I HKS_Feed.script}
//{$I HKS_ResHouses.script}
//{$I HKS_Patrol.script}
//{$I HKS_RaisArmy.script} //
//{$I HKS_Difficulty.script} //need HKS_RaisArmy, mainly difficulty setup

procedure OnUnitWounded(aUnit, aAttacker : Integer);
var UU : KD_UnitStats;
	IsAttacker : Boolean;
begin
	If not SetUnit(aUnit, UU) then 
		If not SetUnit(aAttacker, UU) then 
			Exit
		else
			IsAttacker := true;
		
	If UU.Owner <> PLAYER then 
		Exit;
	If IsAttacker then 
	begin
		If aAttacker <> aHeros[0].ID then 
			If PointNearPoint(UU.aPos, aHeros[0].Pos, 5) then 
				If GChance(50) then 			
					A.UnitHPChange(aUnit, -1);
		Exit;
	end;
	If aUnit <> aHeros[0].ID then 
		If PointNearPoint(UU.aPos, aHeros[0].Pos, 5) then 
			If GChance(50) then 
				A.UnitHPChange(aUnit, 1);
				
		
end;

Procedure OnTick;
begin
	OnTickHero;
  if States.GameTime = 600 then
	Actions.ShowMsg(0, '<$1>');
  if States.GameTime = 30000 then
	Actions.ShowMsg(0, '<$2>');
end;

procedure OnMissionStart;
begin

	AddHero(S.GroupAt(57,58));
	SetHeroStats(15, 45, 216, 8, 4, 0, hcNicholas);
	
	AddGroupAsSpecialUnits(S.GroupAt( 54, 61 ) );
	AddGroupAsSpecialUnits(S.GroupAt( 59, 61 ) );
	AddGroupAsSpecialUnits(S.GroupAt( 63, 56  ) );
end;
