Skip to content

Commit

Permalink
repair discount (#2875)
Browse files Browse the repository at this point in the history
* repair discount

make repair cost 75% of the price of the unit

* check if repairing or building

apply 25% repair reduction only when unit is finished

* improve repair code
  • Loading branch information
shalkya authored and JaggedAppliance committed Nov 11, 2019
1 parent 500f3d7 commit 0f43e48
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lua/sim/Unit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,7 @@ Unit = Class(moho.unit_methods) {
local energy = 0
local targetData
local baseData
local repairRatio = 0.75

if focus then -- Always inherit work status of focus
self:InheritWork(focus)
Expand Down Expand Up @@ -1000,6 +1001,10 @@ Unit = Class(moho.unit_methods) {
mass = (mass / siloBuildRate) * (self:GetBuildRate() or 1)
else
time, energy, mass = self:GetBuildCosts(focus:GetBlueprint())
if self:IsUnitState('Repairing') and focus.isFinishedUnit then
energy = energy * repairRatio
mass = mass * repairRatio
end
end
end

Expand Down Expand Up @@ -2077,6 +2082,7 @@ Unit = Class(moho.unit_methods) {
end

local bp = self:GetBlueprint()
self.isFinishedUnit = true

-- Set up Veterancy tracking here. Avoids needing to check completion later.
-- Do all this here so we only have to do for things which get completed
Expand Down

0 comments on commit 0f43e48

Please sign in to comment.