
{$EVENT evtMissionStart : OnMissionStartData}
{$EVENT evtPlayerVictory : OnPlayerVictoryData}
{$EVENT evtWarriorEquipped : OnWarriorEquippedData}
var aMissionID : Integer;

function GetEquippedCountAll : Integer;
var I : integer;
begin
	Result := 0;
	for I := 0 to 20 do 
		Result := Result + CampaignData.aEquippedCount[I];
	
end;
function GetKillCountAll : Integer;
var I : integer;
begin
	Result := 0;
	for I := 0 to 20 do 
		Result := Result + CampaignData.aKillCount[I];
	
end;


function GetKillCount : Integer;
var I : integer;
begin
	Result := 0;
	for I := 0 to 27 do 
		Result := Result + S.StatUnitKilledCount(0, I);
	
end;

function GetLostCountAll : Integer;
var I : integer;
begin
	Result := 0;
	for I := 0 to 20 do 
		Result := Result + CampaignData.aLostCount[I];
	
end;
function GetLostCount : Integer;
var I : integer;
begin
	Result := 0;
	for I := 0 to 27 do 
		Result := Result + S.StatUnitLostCount(0, I);
	
end;


procedure OnWarriorEquippedData(aUnit,aGroup : Integer);
begin
	If S.UnitOwner(aUnit) = 0 then 
		Inc(CampaignData.aEquippedCount[aMissionID]);
end;


Procedure OnMissionStartData;
begin
	aMissionID := S.CampaignMissionID;
	with CampaignData do 
	begin
		aKillCount[aMissionID] := 0;
		aLostCount[aMissionID] := 0;
		aEquippedCount[aMissionID] := 0;
	end;
end;


Procedure OnPlayerVictoryData(aPlayer : Integer); 
begin
	with CampaignData do 
	begin
		aKillCount[aMissionID] := GetKillCount;
		aLostCount[aMissionID] := GetLostCount;
		//aEquippedCount[aMissionID] := 0;
		//A.ShowMSG(0, intTostr(aKillCount[aMissionID]));
	end;
	If aMissionID = 20 then 
	begin
		A.ShowMsg(0, '<$9>' + '|   <$5> : ' + IntToStr(GetKillCountAll) + '|   <$6> : ' + IntToStr(GetLostCountAll) + '|   <$7> : ' + IntToStr(GetEquippedCountAll))//
	end;
end;