[OTTD]DWE SET (Station Tiles/NewObjects)

Discuss, get help with, or post new graphics for TTDPatch and OpenTTD, using the NewGRF system, here. Graphics for plain TTD also acceptable here.

Moderator: Graphics Moderators

User avatar
zero.eight
Traffic Manager
Traffic Manager
Posts: 128
Joined: 15 Jun 2007 01:14

Re: [OTTD]DWE - Station/NewObject tiles Set

Post by zero.eight »

A wordy version of Property 09:

OTTD code, might be different in TTDP.

The layout format is as follows:

Code: Select all

09                   // this is property 09
<numLayouts>         // the number of layouts, should be even and at least two (one for each orientation)
// layout 1 
<groundsprite>       // sprite used for ground, will be shown in transparent mode
<overlaysprite>      // sprite drawn over ground (and maybe other overlay sprites)
[<overlaysprite>]    // optional extra overlay sprite(s). Only define if needed.
80                   // end layout definition
// layout 2
<groundsprite>
<overlaysprite> 
[<overlaysprite>] 
80                   // end layout definition
The ground sprite is a full-tile sprite that is always drawn. It can be one of two types of sprite: either a sprite from the base set or an Action 1 sprite. To draw a base set sprite, set the ground sprite to the number of base set which can be found by looking at the sprites in the base set (I think it's either trg1r.grf or openttd.grf). To draw a custom sprite, set bit 31 of the spritenumber and start counting at 0x42D, then add the index (1-based) of the sprite in its set (so first sprite is 0x42D, fourth is 0x430 etc).

The game will automatically change the ground sprite depending on which rail type is being used in order to draw the correct rail sprite for each rail type. However, this happens for any sprite, that is any sprite in the base set or any Action 1 sprite. The rail sprite is number 1012 (decimal) in the / orientation (odd layouts) and 1011 in the \ orientation (even layouts). If this number is used for the ground sprite and a normal or electrified station is built, the game will draw sprite 1012/1011. However, if a monorail or maglev station is built, the game draws sprite 1094/1093 or 1174/1175 respectively. However, if you want the flat grass tile to be drawn, you will get a brown tile for monorail and a coast tile for maglev. This is useful if you actually want the correct rail sprite for all rail types, but not useful if you want something else. For that reason I recommend drawing the base set rail sprite for all layouts and drawing an Action 1 "ground sprite" as an overlay sprite if you want a separate sprite to look like it is the ground sprite. Of course, it will only look right if the overlay sprite covers the whole tile.

To work out which base set sprite will be drawn for monorail, add 82 to it. For maglev, add 164. Action 1 sprites do something similar. Not sure if the numbers are the same.

The overlay sprite works in a similar way, however the game does not change sprites depending on rail type if an Action 1 sprite is drawn. It still does for a base set sprite. Note that the spritenumber does not need bit 31 set if it is an Action 1 sprite, but it must still start at 0x42D. Base set sprites can be used by setting bit 31 and using the sprite number from the base set. Setting bit 15 allows company colour 1 to be used. No 2CC yet. If you really want to use a base set sprite, such as the flat grass one, and want it to be the same for all rail types, you can use more layouts and callbacks. Which is fun.

An overlay sprite is made up of either of the following:

Code: Select all

// sprite with its own bounding box
<xofs> <yofs> <zofs>              // x,y,z offsets from northern corner
<xextent> <yextent> <zextent>     // x,y,z sizes 
<spritenumber>                    // sprite to draw, see above
OR
// sprite sharing bounding box of previous sprite
<xofs> <yofs>  80                 // x,y offsets from northern corner
00 00 00                          // ignored
<spritenumber>                    // sprite to draw, see above
Either format can used. It might be more efficient to put some sprites in shared bounding boxes, such as if the sprite is the same size as or smaller than the previous one. Or it could be a minor annoyance to code. Just use the first one if the second is too much hassle.

Some real code (uses escapes). First draw a rail ground sprite, then an Action 1 sprite (some tiles) with the same bounding box as the ground sprite, then another Action 1 sprite (flowerbed) with its own bounding box.

Code: Select all

  729 * 57	 00 	04 01 01		65
							09 \b2
								\dx000003F4
								00 00 80		00 00 00		\dx0000042D
								00 00 00		0F 0F 11		\dx0000042E		80
								\dx000003F3
								00 00 80		00 00 00		\dx0000042D
								00 00 00		0F 0F 11		\dx0000042E		80
Hope that helps.

-D
OpenTTD: VAST - station tiles and objects | MICS - urban monorail graphical conversion | Universal Rail Type - easier train replacement
Dante123
Chief Executive
Chief Executive
Posts: 671
Joined: 11 Aug 2009 16:10
Location: The Nederlands
Contact:

Re: [OTTD]DWE - Station/NewObject tiles Set

Post by Dante123 »

Bingo have it all working now :D

thanx!!
Dante123
Chief Executive
Chief Executive
Posts: 671
Joined: 11 Aug 2009 16:10
Location: The Nederlands
Contact:

Re: [OTTD]DWE - Station/NewObject tiles Set

Post by Dante123 »

now i have just 1 more little thing.
how to i prevent this from happening:
1.PNG
1.PNG (5.13 KiB) Viewed 5295 times
User avatar
wallyweb
Tycoon
Tycoon
Posts: 6102
Joined: 27 Nov 2004 15:05
Location: Canada

Re: [OTTD]DWE - Station/NewObject tiles Set

Post by wallyweb »

Do you mean bits of the railroad's fence showing through the holes in your fence?
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: [OTTD]DWE - Station/NewObject tiles Set

Post by Kogut »

wallyweb wrote:Do you mean bits of the railroad's fence showing through the holes in your fence?
There are showing on top of fence.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
Lakie
TTDPatch Developer
TTDPatch Developer
Posts: 1799
Joined: 26 May 2004 16:37
Location: Britain
Contact:

Re: [OTTD]DWE - Station/NewObject tiles Set

Post by Lakie »

That looks like bounding box errors, (incorrectly set bounding boxes).
Ideally for such sprites one would split the sprite into whats in-front of the tracks and whats behind.
As such you'd have two sprites in your sprites list each with separate bounding boxes.

~ 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."
Dante123
Chief Executive
Chief Executive
Posts: 671
Joined: 11 Aug 2009 16:10
Location: The Nederlands
Contact:

Re: [OTTD]DWE - Station/NewObject tiles Set

Post by Dante123 »

Lakie wrote:That looks like bounding box errors, (incorrectly set bounding boxes).
Ideally for such sprites one would split the sprite into whats in-front of the tracks and whats behind.
As such you'd have two sprites in your sprites list each with separate bounding boxes.

~ Lakie
mmm ok to a coding newbie as me you would need to explain this a bit more.
i just have a pcx where i have a tile with a gap in it, but i guess this is not enough ?
i need to do it like this: back - default sprite - front ?

i used thic ode now:

Code: Select all

 
       524 * 47    00    04 08 01      32
	   				11 FF # <----- Pylon placement ? 00 = no FF = yes
					14 00 # <----- Overhead wire placement FF = no 00 = yes
					15 00 # <----- Can train enter tile FF = no 00 = yes
					0C FE
					0D FE
                    09 \b2
                       \dx000003F4
                       00 00 80      00 00 00      \dx0000042E      80
                       ##00 00 00      0F 0F 11      \dx0000044D      80
                       \dx000003F3
                       00 00 80      00 00 00      \dx0000042D      80
                       ##00 00 00      0F 0F 11      \dx0000044D      80
as you can see i also use the half tile fences.
but what and how should i put the code than ? for me, it seems like that wiki is alreay way too complex about it :/
User avatar
zero.eight
Traffic Manager
Traffic Manager
Posts: 128
Joined: 15 Jun 2007 01:14

Re: [OTTD]DWE - Station/NewObject tiles Set

Post by zero.eight »

Dante123 wrote:mmm ok to a coding newbie as me you would need to explain this a bit more.
i just have a pcx where i have a tile with a gap in it, but i guess this is not enough ?
You need to split the sprite into two: one is the background (everything behind the rails, drawn behind a train) and one is the foreground (drawn over a train if the foreground is "taller"). Both sprites then need their own bounding boxes and need to be placed at the correct positions on the tile. You can use the sprite aligner to help with this task: http://wiki.openttd.org/NewGRF_Debugging. Ctrl-B draws bounding boxes ingame. Make sure the x,y,z sizes are set properly.
OpenTTD: VAST - station tiles and objects | MICS - urban monorail graphical conversion | Universal Rail Type - easier train replacement
Dante123
Chief Executive
Chief Executive
Posts: 671
Joined: 11 Aug 2009 16:10
Location: The Nederlands
Contact:

Re: [OTTD]DWE - Station/NewObject tiles Set

Post by Dante123 »

zero.eight wrote:
Dante123 wrote:mmm ok to a coding newbie as me you would need to explain this a bit more.
i just have a pcx where i have a tile with a gap in it, but i guess this is not enough ?
You need to split the sprite into two: one is the background (everything behind the rails, drawn behind a train) and one is the foreground (drawn over a train if the foreground is "taller"). Both sprites then need their own bounding boxes and need to be placed at the correct positions on the tile. You can use the sprite aligner to help with this task: http://wiki.openttd.org/NewGRF_Debugging. Ctrl-B draws bounding boxes ingame. Make sure the x,y,z sizes are set properly.

mmmm but im not fully getting it. i really try to understand but somehow im failing.
so when i have this code:

Code: Select all

       524 * 47    00    04 08 01      32
                  11 FF # <----- Pylon placement ? 00 = no FF = yes
               14 00 # <----- Overhead wire placement FF = no 00 = yes
               15 00 # <----- Can train enter tile FF = no 00 = yes
               0C FE
               0D FE
                    09 \b2
                       \dx000003F4
                       00 00 80      00 00 00      \dx0000042E      80
                       ##00 00 00      0F 0F 11      \dx0000044D      80
                       \dx000003F3
                       00 00 80      00 00 00      \dx0000042D      80
                       ##00 00 00      0F 0F 11      \dx0000044D      80
this defines the station number/ID "32"
but how/where do i define the corresponding sprites ??
and in what part i put the back, the middle and the front ?
even with the wiki i just dont get it :/

is there not some nice, very clear nfo example ?
i only have seen decompiled ones that put everything in large lines with no spaces or whatsoever.
User avatar
Lakie
TTDPatch Developer
TTDPatch Developer
Posts: 1799
Joined: 26 May 2004 16:37
Location: Britain
Contact:

Re: [OTTD]DWE - Station/NewObject tiles Set

Post by Lakie »

Code: Select all

    0 * 0      00 04 08 01   32
                 11 FF # <----- Pylon placement ? 00 = no FF = yes
                 14 00 # <----- Overhead wire placement FF = no 00 = yes
                 15 00 # <----- Can train enter tile FF = no 00 = yes
                 0C FE
                 0D FE
                 09 \b2
                   \dx800003F4 # <----- Ground (tracks)
                     00 00 00      01 06 0B      \dx0000042D # Rough guesses based on the sprites above
                     00 0A 00      01 06 0B      \dx0000042D # Probably need to alter the sprite numbers to suit your spritesheets.
                     80
                   \dx800003F3
                     00 00 00      06 01 0B      \dx0000042E
                     0A 00 00      06 01 0B      \dx0000043E
                     80
You would need to split the sprites, in particular, fence (one behind and one infront) as their own individual sprites.
In the example above I have assumed you use a single sprite for both fences in each direction, as I assume they are identical.

Its been a while since I've dealt with station bounding boxes, so these may be incorrect.
Hopefully they should be relatively good starting points. :)

~ Lakie
Attachments
How the sprites in the sprite sheet might appear.
How the sprites in the sprite sheet might appear.
example sprites.png (430 Bytes) Viewed 5185 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."
Dante123
Chief Executive
Chief Executive
Posts: 671
Joined: 11 Aug 2009 16:10
Location: The Nederlands
Contact:

Re: [OTTD]DWE - Station/NewObject tiles Set

Post by Dante123 »

but for all stations i just had to put in the ID (31 / 32 / 33)
and than 42D and 42E
but how do i define some other frome ID 31. is the number relative to 31 ? or to the whole grf ID ?
User avatar
Lakie
TTDPatch Developer
TTDPatch Developer
Posts: 1799
Joined: 26 May 2004 16:37
Location: Britain
Contact:

Re: [OTTD]DWE - Station/NewObject tiles Set

Post by Lakie »

From memory you should be able to use any number between 0 and 254 (FE) for station id, they should be grf specific?
I.e. Generally you should give each station type its own new id.

[edit]
I could be wrong though, it's been a long time since I wrote a station grf.

~ 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."
Dante123
Chief Executive
Chief Executive
Posts: 671
Joined: 11 Aug 2009 16:10
Location: The Nederlands
Contact:

Re: [OTTD]DWE - Station/NewObject tiles Set

Post by Dante123 »

ok checked :)
got it now with the counting part for the sprites.

now, to see how those bounding boxes work with that foreground/background thing
User avatar
Lakie
TTDPatch Developer
TTDPatch Developer
Posts: 1799
Joined: 26 May 2004 16:37
Location: Britain
Contact:

Re: [OTTD]DWE - Station/NewObject tiles Set

Post by Lakie »

They should do, they are used for sprite sorting (what to draw on top). Hit Ctrl-B to view the bounding boxes in OpenTTD iirc.

~ 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."
Dante123
Chief Executive
Chief Executive
Posts: 671
Joined: 11 Aug 2009 16:10
Location: The Nederlands
Contact:

Re: [OTTD]DWE - Station/NewObject tiles Set

Post by Dante123 »

to comment a bit on the previous messages,
the reason why some of them are just a bit outside the box is because when you take two opposites side fences they are in the same place and not 1 pixel moved.

i hope this weekend i will have some time to see how to fix this bounding boxies thing
Dante123
Chief Executive
Chief Executive
Posts: 671
Joined: 11 Aug 2009 16:10
Location: The Nederlands
Contact:

Re: [OTTD]DWE - Station/NewObject tiles Set

Post by Dante123 »

:bow:

seems like i got it now :)
1.PNG
1.PNG (40.69 KiB) Viewed 4973 times

with the code:

Code: Select all


   523 * 12	 00 04 06 01 65 08 "FENC" 0A 00
   524 * 4	 01 04 01 02
   525 C:\TTD\sprites\Fences.pcx 25 650 09 33 64 -31 -2
   526 C:\TTD\sprites\Fences.pcx 175 650 09 33 64 -31 -2
   527 * 7	 02 04 00 00 01 00 00
   528 * 7	 03 04 01 65 00 00 00
   529 * 30	 04 04 9F 01 65 "ÅFence bbbb-bbbb Half B2" 00
   530 * 67    00    04 08 01      65
					11 FF # <----- Pylon placement ? 00 = no FF = yes
					14 00 # <----- Overhead wire placement FF = no 00 = yes
					15 00 # <----- Can train enter tile FF = no 00 = yes
					0C FE
					0D FE
					09 \b2
                       \dx000003F4
                       00 00 80      00 00 00      \dx0000042D
                       00 00 00      0F 0F 11      \dx0000042E      80
                       \dx000003F3
                       00 00 80      00 00 00      \dx0000042D
                       00 00 00      0F 0F 11      \dx0000042E      80

Dante123
Chief Executive
Chief Executive
Posts: 671
Joined: 11 Aug 2009 16:10
Location: The Nederlands
Contact:

Re: [OTTD]DWE - Station/NewObject tiles Set

Post by Dante123 »

DARN!

still a small error.
maybe someone can help me out with what i am doing wrong now.

this is the error:
2.PNG
2.PNG (15.14 KiB) Viewed 4963 times
as you can see 1 side (first of the 2 tiles) went fine. the second one wrong...

here with the boxes:
3.PNG
3.PNG (14.2 KiB) Viewed 4961 times
and this the code for that 2 tiles:

Code: Select all

   523 * 12	 00 04 06 01 65 08 "FENC" 0A 00
   524 * 4	 01 04 01 04
   525 C:\TTD\sprites\Fences.pcx 25 650 09 33 64 -31 -2
   526 C:\TTD\sprites\Fences.pcx 175 650 09 33 64 -31 -2
   527 C:\TTD\sprites\Fences.pcx 100 650 09 33 64 -31 -1
   528 C:\TTD\sprites\Fences.pcx 250 650 09 33 64 -31 -1
   529 * 7	 02 04 00 00 01 00 00
   530 * 7	 03 04 01 65 00 00 00
   531 * 30	 04 04 9F 01 65 "ÅFence bbbb-bbbb Half B2" 00
   532 * 67    00    04 08 01      65
					11 FF # <----- Pylon placement ? 00 = no FF = yes
					14 00 # <----- Overhead wire placement FF = no 00 = yes
					15 00 # <----- Can train enter tile FF = no 00 = yes
					0C FE
					0D FE
					09 \b2
                       \dx000003F4
                       00 00 80      00 00 00      \dx00000430
                       00 00 00      0F 0F 11      \dx0000042F      80
                       \dx000003F3
                       00 00 80      00 00 00      \dx0000042D
                       00 00 00      0F 0F 11      \dx0000042E      80
i already tried switching 42D and 42E but that did not worked,...
so i am out of clues for now.
User avatar
Lakie
TTDPatch Developer
TTDPatch Developer
Posts: 1799
Joined: 26 May 2004 16:37
Location: Britain
Contact:

Re: [OTTD]DWE - Station/NewObject tiles Set

Post by Lakie »

Did the bounding boxes I give not work, they should've been close, (sprite alignment is fixable)?
(The problem with the second one is also due to bounding boxes, and the former case is still likely broken).

~ 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."
Dante123
Chief Executive
Chief Executive
Posts: 671
Joined: 11 Aug 2009 16:10
Location: The Nederlands
Contact:

Re: [OTTD]DWE - Station/NewObject tiles Set

Post by Dante123 »

something super crap i just saw:
1.PNG
1.PNG (88.37 KiB) Viewed 4890 times
when it is normal or electric track all works fine.
upgrading to monorail will get some crapy part of the factory and the maglev some building ground sprite...

this is the code i used for the instances:

Code: Select all

   24 * 18	 00 04 07 01 03 08 "FENA" 11 00 14 FF 15 FF 0A 00
   25 * 4	 01 04 01 02
   26 C:\TTD\sprites\Fences.pcx 2 88 09 33 64 -31 -2
   27 C:\TTD\sprites\Fences.pcx 82 88 09 32 64 -31 -1
   28 * 7	 02 04 00 00 01 00 00
   29 * 7	 03 04 01 03 00 00 00
   30 * 25	 04 04 9F 01 03 "ÅFence MID-T-Wall 1" 00
could anyone help me out in this crappy error ?
maquinista
Tycoon
Tycoon
Posts: 1828
Joined: 10 Jul 2006 00:43
Location: Spain

Re: [OTTD]DWE - Station/NewObject tiles Set

Post by maquinista »

Dante123 wrote:something super crap i just saw:
1.PNG
when it is normal or electric track all works fine.
upgrading to monorail will get some crapy part of the factory and the maglev some building ground sprite...

this is the code i used for the instances:

Code: Select all

   24 * 18	 00 04 07 01 03 08 "FENA" 11 00 14 FF 15 FF 0A 00
   25 * 4	 01 04 01 02
   26 C:\TTD\sprites\Fences.pcx 2 88 09 33 64 -31 -2
   27 C:\TTD\sprites\Fences.pcx 82 88 09 32 64 -31 -1
   28 * 7	 02 04 00 00 01 00 00
   29 * 7	 03 04 01 03 00 00 00
   30 * 25	 04 04 9F 01 03 "ÅFence MID-T-Wall 1" 00
could anyone help me out in this crappy error ?
I get the same error with basic stations file.

My solution was to not use malev or monorail for not track tiles.
Sorry if my english is too poor, I want learn it, but it isn't too easy.[/list][/size]
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: No registered users and 24 guests