Skip to content

Commit

Permalink
Fix transferred units receiving full vet (FAForever#4784)
Browse files Browse the repository at this point in the history
  • Loading branch information
Garanas authored Mar 5, 2023
1 parent 356a6b8 commit 55c31fe
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions lua/defaultcomponents.lua
Original file line number Diff line number Diff line change
Expand Up @@ -607,13 +607,13 @@ VeterancyComponent = ClassSimple {
self.VetExperience = currExperience
self:SetStat('VetExperience', currExperience)

while currLevel < 5 and upperThreshold <= experience do
while currLevel < 5 and upperThreshold and upperThreshold <= experience do
self:AddVetLevel()
currLevel = currLevel + 1
lowerThreshold = vetThresholds[currLevel + 1]
upperThreshold = vetThresholds[currLevel + 1]
end

-- case where we do have a limit (usual gameplay approach)
-- case where we do have a limit (usual gameplay approach)
else
if experience > diffThreshold then
experience = diffThreshold
Expand Down Expand Up @@ -688,6 +688,15 @@ VeterancyComponent = ClassSimple {
self:AddVetExperience(self.Blueprint.VetThresholds[MathMin(level, 5)] or 0, true)
end,

---@param self Unit | VeterancyComponent
---@param massKilled number
---@param noLimit boolean
CalculateVeterancyLevelAfterTransfer = function(self, massKilled, noLimit)
self.VetExperience = 0
self.VetLevel = 0
self:AddVetExperience(massKilled, noLimit)
end,

-- kept for backwards compatibility with mods, but should really not be used anymore

---@deprecated
Expand All @@ -714,16 +723,6 @@ VeterancyComponent = ClassSimple {
self:AddVetExperience(massKilled, noLimit)
end,

---@deprecated
---@param self Unit | VeterancyComponent
---@param massKilled number
---@param noLimit boolean
CalculateVeterancyLevelAfterTransfer = function(self, massKilled, noLimit)
self.VetExperience = 0
self.VetLevel = 0
self:AddVetExperience(massKilled, noLimit)
end,

---@see AddVetLevel
---@deprecated
---@param self Unit | VeterancyComponent
Expand Down

0 comments on commit 55c31fe

Please sign in to comment.