Skip to content

Commit

Permalink
Set minimum possible machine strength after repair to 2 (CorsixTH#2727)
Browse files Browse the repository at this point in the history
* Set minimum possible machine strength after repair is 2
  • Loading branch information
ARGAMX authored Nov 28, 2024
1 parent e69e880 commit c79bb6b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions CorsixTH/Lua/entities/machine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,19 @@ end

function Machine:machineRepaired(room)
room.needs_repair = nil
self:reduceStrengthOnRepair(room)
self.times_used = 0
self:setRepairing(nil)
setSmoke(self, false)
local taskIndex = self.hospital:getIndexOfTask(self.tile_x, self.tile_y, "repairing")
self.hospital:removeHandymanTask(taskIndex, "repairing")
end

--! Calculates if machine strength should be reduced as a result of repair
--!param room (object) machine room
function Machine:reduceStrengthOnRepair(room)
local minimum_possible_strength = 2
if self.strength <= minimum_possible_strength then return end

local current_strength = self.strength
local used_out_rate = self.times_used / current_strength
Expand All @@ -298,12 +311,6 @@ function Machine:machineRepaired(room)
if should_reduce_strength then
self.strength = current_strength - 1
end

self.times_used = 0
self:setRepairing(nil)
setSmoke(self, false)
local taskIndex = self.hospital:getIndexOfTask(self.tile_x, self.tile_y, "repairing")
self.hospital:removeHandymanTask(taskIndex, "repairing")
end

--! Tells the machine to start showing the icon that it needs repair.
Expand Down

0 comments on commit c79bb6b

Please sign in to comment.