Permalink
Browse files

Merge pull request #1483 from mugmuggy/autospyrediscoverable

[RDY] Autospy can be discovered multiple times - morale related chances
  • Loading branch information...
TheCycoONE committed Oct 16, 2018
2 parents a13522f + 37d5257 commit 157b23cca89b072a8fb45ab83beae742eb68a909
Showing with 16 additions and 9 deletions.
  1. +1 −1 CorsixTH/Lua/app.lua
  2. +5 −1 CorsixTH/Lua/hospital.lua
  3. +10 −7 CorsixTH/Lua/rooms/research.lua
@@ -28,7 +28,7 @@ local runDebugger = corsixth.require("run_debugger")
-- Increment each time a savegame break would occur
-- and add compatibility code in afterLoad functions

local SAVEGAME_VERSION = 130
local SAVEGAME_VERSION = 131

class "App"

@@ -51,7 +51,6 @@ function Hospital:Hospital(world, avail_rooms, name)
self.acc_research_cost = 0
self.acc_overdraft = 0
self.acc_heating = 0
self.discover_autopsy_risk = 10

-- The sum of all material values (tiles, rooms, objects).
-- Initial value: hospital tile count * tile value + 20000
@@ -662,6 +661,11 @@ function Hospital:afterLoad(old, new)
self.ratholes = {}
end

if old < 131 then
self.autopsy_discovered = nil
self.discover_autopsy_risk = nil
end

-- Update other objects in the hospital (added in version 106).
if self.epidemic then self.epidemic.afterLoad(old, new) end
for _, future_epidemic in ipairs(self.future_epidemics_pool) do
@@ -166,15 +166,18 @@ function ResearchRoom:commandEnteringPatient(patient)
local hosp = self.hospital
local patient_room = patient.disease.treatment_rooms[#patient.disease.treatment_rooms]
hosp.research:addResearchPoints("dummy", patient_room)
if not hosp.autopsy_discovered and hosp.discover_autopsy_risk > math.random(1, 100) then
-- Can only be discovered once.
hosp.autopsy_discovered = true
-- average morale of all staff affects chances
local avg_happiness = hosp:getAverageStaffAttribute("happiness", nil)
local autopsy_discovered
-- low morale - more likely to discover
if avg_happiness < 0.25 then
autopsy_discovered = math.random(1,3) ~= 1
else
autopsy_discovered = math.random(1,3) == 1
end
if autopsy_discovered then
hosp:changeReputation("autopsy_discovered")
hosp.world.ui.adviser:say(_A.research.autopsy_discovered_rep_loss)
else
-- The risk increases after each use.
-- TODO: Should it ever become 100%?
self.hospital.discover_autopsy_risk = self.hospital.discover_autopsy_risk + 10
end
if patient.hospital then
hosp:removePatient(patient)

0 comments on commit 157b23c

Please sign in to comment.