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

Move vetDamage total inside instigator check #6110

Open
wants to merge 9 commits into
base: deploy/fafdevelop
Choose a base branch
from
4 changes: 4 additions & 0 deletions changelog/snippets/fix.6110.md
@@ -0,0 +1,4 @@
- (#6110) Veterancy Fixes and Features
- Volatile units (example: Paragon being killed by Mavor) will now give full veterancy credit on death, where before their own death weapon would "steal" some of the credit
- Adds a new stat--'VetMassKillCredit`--which records the total mass killed by a unit without respect to the "one vet level per kill" guardrail
- Condenses VetDamage and VetInstigators into one table to save memory
15 changes: 12 additions & 3 deletions lua/defaultcomponents.lua
Expand Up @@ -596,7 +596,8 @@ local VeterancyRegenBuffs = {
---@field VetDamageTaken number
---@field VetInstigators table<EntityId, Unit>
---@field VetExperience? number
---@field VetLevel? number
---@field VetLevel? number
---@field VetMassKillCredit? number -- bookkeeping number available to the player via stat
VeterancyComponent = ClassSimple {

---@param self VeterancyComponent | Unit
Expand All @@ -610,10 +611,12 @@ VeterancyComponent = ClassSimple {

-- optionally, these fields are defined too to inform UI of our veterancy status
if blueprint.VetEnabled then
self:UpdateStat('VetLevel', 0)
self:UpdateStat('VetExperience', 0)
self:UpdateStat('VetLevel', 0)
self:UpdateStat('VetMassKillCredit', 0)
self.VetExperience = 0
self.VetLevel = 0
self.VetMassKillCredit = 0
end
end,

Expand All @@ -624,12 +627,12 @@ VeterancyComponent = ClassSimple {
---@param damageType DamageType unused
DoTakeDamage = function(self, instigator, amount, vector, damageType)
amount = MathMin(amount, self:GetMaxHealth())
self.VetDamageTaken = self.VetDamageTaken + amount
if instigator and
instigator.IsUnit and
(not IsDestroyed(instigator)) and
IsEnemy(self.Army, instigator.Army)
then
self.VetDamageTaken = self.VetDamageTaken + amount
local entityId = instigator.EntityId
local vetInstigators = self.VetInstigators
local vetDamage = self.VetDamage
Expand Down Expand Up @@ -665,6 +668,12 @@ VeterancyComponent = ClassSimple {
return
end

-- VetMassKillCredit is not otherwise used by the vet system, but
-- is available for players as a bookkeeping item for total mass
-- killed without the level gain limitations on VetExperience
self.VetMassKillCredit = self.VetMassKillCredit + experience
self:UpdateStat('VetMassKillCredit', self.VetMassKillCredit)

local currExperience = self.VetExperience
local currLevel = self.VetLevel

Expand Down