Ok been going around in circles with AddKills.
From what I can see in SimUtils.lua line 105, we have...
unit:AddKills( unitKills )
Then in Unit.lua line 3084, we have
AddKills = function(self, numKills)
#Add the kills, then check veterancy junk.
local unitKills = self:GetStat('KILLS', 0).Value + numKills
self:SetStat('KILLS', unitKills)
local vet = self:GetBlueprint().Veteran or Game.VeteranDefault
local vetLevels = table.getsize(vet)
if self.VeteranLevel == vetLevels then
return
end
local nextLvl = self.VeteranLevel + 1
local nextKills = vet[('Level' .. nextLvl)]
#Since we could potentially be gaining a lot of kills here, check if we gained more than one level
while unitKills >= nextKills and self.VeteranLevel ~= vetLevels do
self:SetVeteranLevel(nextLvl)
nextLvl = self.VeteranLevel + 1
nextKills = vet[('Level' .. nextLvl)]
end
end,
thus it should be just as simple as using within a unit script the following...
myUnit:AddKills( myUnitsKills )
However this is constantly throwing errors such as "attempt to call method `AddKills' (a nil value)". Which makes no sense at all as the script is within the units core lua and is clearly defined. What am i missing here?