Advertisement
Draco18s

Surviving Mars Nightowl

Mar 24th, 2018
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.22 KB | None | 0 0
  1.     function Workplace:OnChangeWorkshift(old, new)
  2.         if old then
  3.             local martianborn_resilience = self.city:IsTechResearched("MartianbornResilience")
  4.             local dark_penalty = IsDarkHour(self.city.hour - 4) and -g_Consts.WorkDarkHoursSanityDecrease
  5.             local overtime = self.overtime[old]
  6.             local outside_sanity_decrease = -g_Consts.OutsideWorkplaceSanityDecrease
  7.             local is_outside_building = self:IsKindOf("OutsideHumanBuilding")
  8.             for _, worker in ipairs(self.workers[old]) do
  9.                 -- begin modifications
  10.                 local traits = worker.traits
  11.                 if dark_penalty then
  12.                     if traits.Nightowl then
  13.                         dark_penalty = dark_penalty / 4
  14.                     end
  15.                     worker:ChangeSanity(dark_penalty, "work in dark hours")
  16.                 end
  17.                 -- end modifications
  18.                 if overtime and worker:IsWorking() and not traits.Workaholic then
  19.                     worker:ChangeHealth(-g_Consts.WorkOvertimeHealth, "overtime")
  20.                     worker:ChangeSanity(-g_Consts.WorkOvertimeSanityDecrease, "overtime")
  21.                 end
  22.                 if is_outside_building and (not martianborn_resilience or not traits.Martianborn) then
  23.                     worker:ChangeSanity(outside_sanity_decrease, "outside workplace")
  24.                 end
  25.                 worker:InterruptVisit()
  26.             end
  27.         end
  28.         RebuildInfopanel(self)
  29.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement