Multi-tile object randomisation
Moderator: Graphics Moderators
-
- Tycoon
- Posts: 5954
- Joined: 27 Apr 2005 07:09
- Contact:
Multi-tile object randomisation
I think it´s not possible to achieve consistent multi-tile object randomisation, simply because "random bits are unique to each tile in the object, and are not shared across the whole object"?
I.e., what I´d like to achieve is to randomise the tiles of an object in a consistent way, say for a two-tile object I want to get randomised sprites A-A, or B-B, C-C, ..., but not A-B, C-B, etc.
Is that possible in some way?
regards
Michael
I.e., what I´d like to achieve is to randomise the tiles of an object in a consistent way, say for a two-tile object I want to get randomised sprites A-A, or B-B, C-C, ..., but not A-B, C-B, etc.
Is that possible in some way?
regards
Michael
- zero.eight
- Traffic Manager
- Posts: 128
- Joined: 15 Jun 2007 01:14
Re: Multi-tile object randomisation
var61 + var40 will get the random bits of some specific tile in the object, so for each tile in a multi-tile object you could make decisions based on the random bits of the northernmost tile, which should be consistent.
OpenTTD: VAST - station tiles and objects | MICS - urban monorail graphical conversion | Universal Rail Type - easier train replacement
Re: Multi-tile object randomisation
There is even an example in the specs for exactly that: http://newgrf-specs.tt-wiki.net/wiki/Va ... andom_bits
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
-
- Tycoon
- Posts: 5954
- Joined: 27 Apr 2005 07:09
- Contact:
Re: Multi-tile object randomisation
Thanks for your reply. Yes, I know that this is the usual approach, and I´ve already used it this way, and hence there seems to be no better method I´ve now implemented it again.zero.eight wrote: var61 (objinfo_randombits) + var40 (position) will get the random bits of some specific tile in the object, so for each tile in a multi-tile object you could make decisions based on the random bits of the northernmost tile, which should be consistent.
However, I still don´t understand why the same result can´t be achieved by a simple use of a randomaction (the code would be very much simpler: 1 line versus n+1 lines). The fact that a simple randomaction does not work for features composed from multiple tiles is nowhere mentioned in the docs. Moreover, how a randomaction works in general is nowhere explained in the docs as well. Please note, question is not about "*re*-randomising" (which is indeed (sparingly) explained) here, since objects have no triggers.
This reminds me of that problem with re-randomisation in callback chains, which was likewise nowhere explained, but uncovered the existence of an undocumented "callback 1" to the audience.
@frosch
Thanks, I know about this example (it´s even implemented as a pre-defined function in m4nfo).
regards
Michael
Re: Multi-tile object randomisation
so what you're proposing is something like random action type 84 also for <whatever>Tiles, not only for trains?
-
- Tycoon
- Posts: 5954
- Joined: 27 Apr 2005 07:09
- Contact:
Re: Multi-tile object randomisation
Well, current behaviour seems to exist because of "historical reasons" (trains were first, multi-tile features were introduced much later).Eddi wrote: so what you're proposing is something like random action type 84 also for <whatever>Tiles, not only for trains?
Even more, since you´ll have to check for that northern tile explicitly, both for x- and y direction.mb wrote: (the code would be very much simpler: 1 line versus n+1 lines)
regards
Michael
Re: Multi-tile object randomisation
From my understanding there are two possible solutions (proposed):
~ Lakie
* If I remember correctly, defined object layouts do not require the north tile, meaning just fetching those bits is undefined in some (rare) cases.
** Objects can have a maximum dimension of 15x15 making negatives infeasible with just a single byte.
- Store 'whole object' random bits which are accessed through 83. *
- Implement 84 for objects taking offset (as a byte) from the north tile and fetch its random bits. **
~ Lakie
* If I remember correctly, defined object layouts do not require the north tile, meaning just fetching those bits is undefined in some (rare) cases.
** Objects can have a maximum dimension of 15x15 making negatives infeasible with just a single byte.
TTDpatch Developer 2005 - 2010 ~ It all started because of shortened vehicle not loading correctly, now look where I've gone with it!
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."
-
- Tycoon
- Posts: 5954
- Joined: 27 Apr 2005 07:09
- Contact:
Re: Multi-tile object randomisation
IMO, supplying random bits for an object as a whole would be the more "conservative" approach, since stations and industry tiles work the same way. Whereas type "84" seems to be especially useful for trains (plus taking into account the limitations you pointed out).Lakie wrote:From my understanding there are two possible solutions (proposed):I haven't looked to see how feasible either solution would be, but both solutions hold their merits [...]
- Store 'whole object' random bits which are accessed through 83. *
- Implement 84 for objects taking offset (as a byte) from the north tile and fetch its random bits. **
feature bits
vehicles 8
stations 16+4
houses 0/8+8*
ind tile 16+8
objects 0+8
*depending on trigger set for periodic tile processing loop
regards
Michael
Re: Multi-tile object randomisation
the difference is that industries have completely separate "industry" (global) and "industry tile" (local) representations ingame, where objects only have the "object tile" representation. there is no "object pool" storing global data about each object. (there's also no reason for that to exist, since objects have no relevant gameplay effect that would require this storage, so introducing it just for the sake of random bits sounds a bit overkill)
Re: Multi-tile object randomisation
Actually, both TTDPatch and OpenTTD keep certain information about the object separate in a small data structure shared by all the tiles of the object, (see objects.inc and object_base.h).
~ Lakie
~ Lakie
TTDpatch Developer 2005 - 2010 ~ It all started because of shortened vehicle not loading correctly, now look where I've gone with it!
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."
-
- Tycoon
- Posts: 5954
- Joined: 27 Apr 2005 07:09
- Contact:
Re: Multi-tile object randomisation
Well, yes. W/r to industry tiles you´re right, but for stations, there are indeed 16 bits for the station as a whole, not for its "related" feature (town).
So, there´s no fixed "scheme" for random bit allocation in existence, defining a clear distinction between bits for feature tiles and bits for its related feature (sorry, there´s really a clash between "object" and object in our terminology).
Hence, I don´t see any fundamental contradiction in adding random bits for an object as a whole. Since"new" objects are built up from more than one tile most of the time, such a feature would come indeed quite handy, and it would outweigh any theoretical concerns.
IMO, it´d be much more straightforward than implementing type "84" for objects.
regards
Michael
So, there´s no fixed "scheme" for random bit allocation in existence, defining a clear distinction between bits for feature tiles and bits for its related feature (sorry, there´s really a clash between "object" and object in our terminology).
Hence, I don´t see any fundamental contradiction in adding random bits for an object as a whole. Since"new" objects are built up from more than one tile most of the time, such a feature would come indeed quite handy, and it would outweigh any theoretical concerns.
IMO, it´d be much more straightforward than implementing type "84" for objects.
regards
Michael
-
- Tycoon
- Posts: 5954
- Joined: 27 Apr 2005 07:09
- Contact:
Re: Multi-tile object randomisation
@Lakie
So, what´s this
regards
Michael
So, what´s this
In addition, there´s a periodic tileloop trigger?26 #define OA_WHOLEOBJECT 0x4 // Every 250? ticks (whole object)
27
28 #define OA_FORALLTILES 0x5 // Used to detect which triggers are for the whole object
regards
Michael
Re: Multi-tile object randomisation
Those are just the bit definitions for property 13, the last is a mask for any of the animation bits triggering the whole object to be updated.
~ Lakie
~ Lakie
TTDpatch Developer 2005 - 2010 ~ It all started because of shortened vehicle not loading correctly, now look where I've gone with it!
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."
-
- Tycoon
- Posts: 5954
- Joined: 27 Apr 2005 07:09
- Contact:
Re: Multi-tile object randomisation
@Lakie
Aha. "OA" means "object animation", so it has nothing to do with randomisation which we´re talking about here.
regards
Michael
Aha. "OA" means "object animation", so it has nothing to do with randomisation which we´re talking about here.
regards
Michael
Re: Multi-tile object randomisation
Yes, apparently object layouts was planned but never implemented. Thus the solution of redirecting type 83 random to use the random bits from the north-tile is currently viable. (Although possibly not future safe).
~ Lakie
~ Lakie
TTDpatch Developer 2005 - 2010 ~ It all started because of shortened vehicle not loading correctly, now look where I've gone with it!
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."
-
- Tycoon
- Posts: 5954
- Joined: 27 Apr 2005 07:09
- Contact:
Re: Multi-tile object randomisation
Speaking about missing features in objects, there´s also that old proposal to allow for shared bits for animation triggers.
regards
Michael
regards
Michael
Re: Multi-tile object randomisation
Well, we're going a little off topic here. At present there are two suggestions for multi-tile object randomization, either shared object random bits or another tile's (in the same object) random bits.
The former could only really be implemented as type 83, whilst the latter could be either type 83 or 84 depending on how flexible the solution should be. Also, a combination of the two might be preferable.
[edit] I've attached my test object source code (NFO) for a comparison of the the NewGRF (NFO) code. I wasn't sure how it was presently done so I took best guess (last object).
~ Lakie
The former could only really be implemented as type 83, whilst the latter could be either type 83 or 84 depending on how flexible the solution should be. Also, a combination of the two might be preferable.
[edit] I've attached my test object source code (NFO) for a comparison of the the NewGRF (NFO) code. I wasn't sure how it was presently done so I took best guess (last object).
~ Lakie
- Attachments
-
- test.nfo
- (8.13 KiB) Downloaded 150 times
TTDpatch Developer 2005 - 2010 ~ It all started because of shortened vehicle not loading correctly, now look where I've gone with it!
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."
Re: Multi-tile object randomisation
For shared random bits within an object I am strongly in favour of using type 83. If there would be triggers at some point, it could work similar to industry tiles.
I see no point in using type 84. Triggers will never work to rerandomize bits of other tiles, and it does not work for vehicles either (actually for vehicles type 83 already fails). Reading of random bits can already be done with the existing variables (object var 61 and vehicle var 61), so actually type 84 is on my list of crap to remove from specs in some unknown future.
I see no point in using type 84. Triggers will never work to rerandomize bits of other tiles, and it does not work for vehicles either (actually for vehicles type 83 already fails). Reading of random bits can already be done with the existing variables (object var 61 and vehicle var 61), so actually type 84 is on my list of crap to remove from specs in some unknown future.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Re: Multi-tile object randomisation
unless you completely remove randomaction2, i don't see how that would work...
(Off-Topic Alert)
(Off-Topic Alert)
Who is online
Users browsing this forum: No registered users and 14 guests