[nfo] Random values in an action 0?

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5658
Joined: 31 Mar 2007 14:23
Location: Lost in Music

[nfo] Random values in an action 0?

Post by andythenorth »

I am trying to find a way to randomise values for properties set by an Action 0.

Looks like Action 6 and Action D would be the best way to do that, but I can't see a way to get a random value for the Action D.

The use case is providing random values for cargo properties 10, 11 and 12. Random cargo rates would avoid the 'oh no, coal again' feeling when starting a game, and might provide a renewed challenge to players.

It's possible these values would be either entirely random, or from a range of pre-defined values to ensure the game is actually playable (in which case Action 7 randomly jumping to one of several labels might be more appropriate).

EDIT (Eddi pointed out that there is a problem maintaining these random rates across save game reloads).

Any ideas for solutions?

cheers,

Andy
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5602
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: [nfo] Random values in an action 0?

Post by PikkaBird »

Perhaps if you ask nicely, you can get the OTTD map seed as an action 7/D variable? :)
dandan
Route Supervisor
Route Supervisor
Posts: 414
Joined: 17 Feb 2008 23:01

Re: [nfo] Random values in an action 0?

Post by dandan »

Interesting idea. As far as I understand it, a callback that would allow changing those properties might be the best solution. You could then also, for example, make cargo payment rates dependent on the year.

And talking about callbacks, couldn't you just use callback 39 (custom profit calculation for cargoes)? I have never coded these things, so I'm not exactly sure how it works.
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: [nfo] Random values in an action 0?

Post by frosch »

Access to map seed should be possible.

However, it would not change if you play e.g. scenarios. Which I would not necessarily consider as "wanted behaviour".
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5658
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: [nfo] Random values in an action 0?

Post by andythenorth »

frosch wrote:Access to map seed should be possible.
However, it would not change if you play e.g. scenarios. Which I would not necessarily consider as "wanted behaviour".
Actually it might be in theory...it would allow scenario designers to tweak a scenario according to payment rates, but I think it would be too random to be useful!

It might be nice to have different payment rates for every map, then again it might not :o

cheers,

Andy
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: [nfo] Random values in an action 0?

Post by frosch »

Well, for a scenario I can only imagine two useful cases:
  • Randomised at game start like engine reliabilities and introduction dates, etc.
  • Set by the scenario designer via grf parameters
The mapseed is otoh only randomised when creating the map resp. the scenario. I.e. it would not really be controllable by the scenario creator like grf parameters, but it would also not get randomised when starting the actual game as it is fixed to the scenario.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5658
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: [nfo] Random values in an action 0?

Post by andythenorth »

frosch wrote:Well, for a scenario I can only imagine two useful cases:
  • Randomised at game start like engine reliabilities and introduction dates, etc.
  • Set by the scenario designer via grf parameters
Thanks for the answers. So I am currently thinking of pre-defined sets of payment rates, the set to be chosen according to a parameter.

Something between 8 and 256 different sets, depending on whether we choose the rates by hand (to ensure they are actually sane), or at random programmatically when the grf is built (which might produce some insane results).

The player would then have to set a parameter to set the rates. 0 would be default and closest to standard TTD. It would however be a nice alternative if it was possible to randomise the chosen set from the map seed, this would seem to also be a conveniently reliable way to preserve the random choice across save games :)
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 4 guests