• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

RenoMartin

Recruit
Jun 9, 2020
1
0
Trying to mod workers in workshops milestone, because I think sometimes it bugs out. Several times during playthroughs I hit 40%+ and it didn't count.
Wanted to bring it down at 20-25% and see how it goes. My code looks like this:


function Milestone_WorkshopWorkersPercent(city, 25)
local min_interval = const.HourDuration
local max_interval = const.DayDuration
while true do
local current_percent = city and city:GetWorkshopWorkersPercent() or 0
if current_percent >= target_percent then
return true
end
local interval = min_interval + MulDivRound(max_interval - min_interval, target_percent - current_percent, target_percent)
Sleep(interval)
end
end

function OnMsg.ClassesPostprocess()
PlaceObj('Milestone', {
Complete = function (self, city)
return Milestone_WorkshopWorkersPercent(city, 25)
end,
SortKey = 16000,
bonus_score = 3000,
bonus_score_expiration = 300,
display_name = T(590068197487, --[[Milestone Default WorkersInWorkshops display_name]] "25% Workers in Workshops"),
group = "Default",
id = "WorkersInWorkshops",
reward_research = 5000,
trigger_fireworks = true,
})
end


As you can see, I don't really know what I'm doing, best I could come up with after digging in documentation. What am I doing wrong and how it should look like?

P.S. I'd also like to reduce reasearch points reward to ~5k for balance reasons.