Advertisement
Draco18s

Self Taught

Apr 8th, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 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. local traits = worker.traits
  10. if traits.SelfTaught and self.specialist ~= worker.specialist and self.specialist ~= "none" then
  11. local martianborn_adaptability = self.city:IsTechResearched("MartianbornAdaptability") and TechDef.MartianbornAdaptability.param1
  12. local gain_point = 20
  13. if martianborn_adaptability and worker.traits.Martianborn then
  14. gain_point = gain_point + MulDivRound(martianborn_adaptability, gain_point, 100)
  15. end
  16. --ModLog(" gain_point " .. tostring(gain_point))
  17. gain_point = gain_point + MulDivRound(worker.performance, gain_point, 100)
  18. --ModLog(" gain_point " .. tostring(gain_point))
  19. worker.training_points = worker.training_points or {}
  20. worker.training_points["SelfTaught_" .. self.specialist] = (worker.training_points["SelfTaught_" .. self.specialist] or 0) + MulDivRound(gain_point, 3, g_Consts.WorkingHours)
  21. --ModLog("Senior age: " .. tostring(worker.MinAge_Senior))
  22. --ModLog(" Self training progress: " .. tostring(worker.training_points["SelfTaught_" .. self.specialist]))
  23. if (worker.training_points and worker.training_points["SelfTaught_" .. self.specialist] or 0) >= 100 then
  24. worker.training_points["SelfTaught_" .. self.specialist] = 100
  25. worker:SetSpecialization(self.specialist)
  26. end
  27. end
  28. end
  29. end
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement