Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the internal unit statistics #6129

Draft
wants to merge 2 commits into
base: deploy/fafdevelop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 11 additions & 4 deletions lua/sim/score.lua
Expand Up @@ -325,15 +325,22 @@ local function GameOverScore()
Score.units[categoryName]['built'] = brain:GetBlueprintStat("Units_History", category)
Score.units[categoryName]['lost'] = brain:GetBlueprintStat("Units_Killed", category)
end

Score.blueprints = {}
local allStats = brain:GetUnitStats()
for _, unitId in unitIdsForAchievements do

LOG(index, unitId, brain:GetBlueprintStat("Enemies_Killed", categories[unitId]), '->', allStats[unitId]['kills'])
LOG(index, unitId, brain:GetBlueprintStat("Units_History", categories[unitId]), '->', allStats[unitId]['built'])
LOG(index, unitId, brain:GetBlueprintStat("Units_History", categories[unitId]) - brain:GetBlueprintStat("Units_Active", categories[unitId]), '->', allStats[unitId]['lost'])

local unitStats = allStats[unitId]
if unitStats then
if not unitStats['kills'] then unitStats['kills'] = 0 end
if not unitStats['built'] then unitStats['built'] = 0 end
if not unitStats['lost'] then unitStats['lost'] = 0 end
-- track the statistics for these specific units
unitStats['kills'] = brain:GetBlueprintStat("Enemies_Killed", categories[unitId])
unitStats['built'] = brain:GetBlueprintStat("Units_History", categories[unitId])
unitStats['lost'] = brain:GetBlueprintStat("Units_History", categories[unitId]) - brain:GetBlueprintStat("Units_Active", categories[unitId])

Score.blueprints[unitId] = unitStats
end
end
Expand Down