Author Topic: Question about "RandomSelection _deathSelector"  (Read 301 times)

0 Members and 1 Guest are viewing this topic.

Offline sym

  • Newb
  • *
  • Posts: 3
Question about "RandomSelection _deathSelector"
« on: December 19, 2016, 04:21:57 PM »
Code: [Select]
RandomSelection _deathSelector
{
float _years = 10;
float _population = 100;
}
from /Game/Profession/Profession.rsc

I'm wondering exactly what these variables represent. I've looked through the resources, but I can't find how they are actually used.

Online Discrepancy

  • Trader
  • ****
  • Posts: 368
Re: Question about "RandomSelection _deathSelector"
« Reply #1 on: December 19, 2016, 06:01:10 PM »
The code is attached to the individual Professions. As far as I know it is controlling the chance/likelihood of a 'work death' for that profession.

If you look throughout the Profession.rsc file, you will see that the Miner has 'float _years = 4;' -- the miner is the most 'dangerous' profession, the likelihood of a death to a miner is higher.
A Buillder, Forester and Hunter I think are next, with 'float _years = 5;'
The lower the number, the more likely a 'work death' will occur. Higher the numbers, the less likely.

The code 'flost _population = 100;' I would guess would be the required population at which a death could occur.

I'm sure @Tom Sawyer or another person from this great community will have more insight into this.

Offline sym

  • Newb
  • *
  • Posts: 3
Re: Question about "RandomSelection _deathSelector"
« Reply #2 on: December 19, 2016, 09:54:25 PM »
Thanks for the reply :)
I just tested this by setting values in the laborer's Profession.rsc to these:
_years = 0.1f
_population = 5

and then started a new game, this was the outcome:
http://i.imgur.com/oymSywY.png
Question about "RandomSelection _deathSelector"


My entire population died off rapidly, even after hitting and going below the threshold of 5, so I don't think that's what _population refers to..

_years is definitely a scale of how likely someone is to die on the job, lower being a higher chance of death.. If you set it to wildly high values you should basically never experience a death.

Offline elemental

  • Trader
  • ****
  • Posts: 243
Re: Question about "RandomSelection _deathSelector"
« Reply #3 on: December 20, 2016, 02:13:22 AM »
You'd think that "years" might refer to time rather than probability. Maybe  _years denotes how often the game rolls the dice to see if someone is going to die, but exactly how the game determines which profession gets hit and what chance they have of dying... who knows. These links might be helpful:

Safer mines and quarries mod:

http://steamcommunity.com/sharedfiles/filedetails/?id=741446941&searchtext=mining

and the source code for that mod:

http://www.nexusmods.com/banished/mods/46/?tab=2&navtag=http%3A%2F%2Fwww.nexusmods.com%2Fbanished%2Fajax%2Fmodfiles%2F%3Fid%3D46&pUp=1

Offline Tom Sawyer

  • Architect
  • *****
  • Posts: 585
Re: Question about "RandomSelection _deathSelector"
« Reply #4 on: December 20, 2016, 02:19:08 AM »
I do not know the exact formula. But I think the values mean that by using a random function about every x years one of y citizens dies if he does this job.

The lower x (_years), the more dead.
The lower y (_population), the more dead.

The deadliest job in vanilla Banished is by far the stonecutter followed by miners. In the North I changed the stonecutter to the better level of the miner and all jobs in the Nordic woods are more dangerous with some new events. ;D

Offline sym

  • Newb
  • *
  • Posts: 3
Re: Question about "RandomSelection _deathSelector"
« Reply #5 on: December 20, 2016, 11:12:20 AM »
@elemental That's actually the original reference I was using when trying to learn how to write a mod. It was pretty helpful for my case, but didn't help really in explaining what the values did. I do think it has something to do with probability.

@Tom Sawyer I think you might be close to it with that. Perhaps it acts as some sort of ratio, as in: if a worker worked without stopping for (_years amount of game years), then you can expect (_population amount of workers) to die? edit: This is definitely not the case.

I'll do some more testing today and report results. I've sent an e-mail to Shining Rock asking for specifics about how the deaths work, hopefully I get a response..
« Last Edit: December 20, 2016, 11:42:16 AM by sym »