George's new cargos [aborted] Use ECS instead

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

How should the building look it transperent mode

as the ground part with the above part in grey (default behaviour)
14
21%
there should be a text with cargo name over the ground part (English only)
15
22%
there should be an icon of the cargo over the ground part
38
56%
other (specify please)
1
1%
 
Total votes: 68

User avatar
George
Tycoon
Tycoon
Posts: 4363
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

Post by George »

New attempt
Attachments
peter1-3.png
peter1-3.png (14.27 KiB) Viewed 3404 times
Image Image Image Image
User avatar
Aegir
Tycoon
Tycoon
Posts: 2884
Joined: 09 Feb 2004 10:02
Contact:

Post by Aegir »

George wrote:New attempt
Thats quite nice George. Nice statue.
Currently working under the name 'reldred' on Github, and Discord.
NFO/NML coder, part-time patch writer for JGRPP, and all round belligerent.

14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
User avatar
Csaboka
Tycoon
Tycoon
Posts: 1202
Joined: 25 Nov 2002 16:30
Location: Tiszavasvári, Hungary
Contact:

Post by Csaboka »

For industries, callback 28 can be used to get a water industry near the shore or a normal industry near water. Currently you can't have an industry that is partly on land and partly on water. Town buildings don't have any of those possibilities.
Reality is that which, when you stop believing in it, doesn't go away.—Philip K. Dick
User avatar
George
Tycoon
Tycoon
Posts: 4363
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

Post by George »

Csaboka wrote:For industries, callback 28 can be used to get a water industry near the shore or a normal industry near water. Currently you can't have an industry that is partly on land and partly on water. Town buildings don't have any of those possibilities.
Can it be placed on the shore?
Can it prevent removing the nearby land?
Could we have an abstract industry "an old ship", that would have different graphics, name, amount of production?
Can we make the industry to produce N tourists from N accepted tourists M days after a day, when they were accepted?
Image Image Image Image
User avatar
Csaboka
Tycoon
Tycoon
Posts: 1202
Joined: 25 Nov 2002 16:30
Location: Tiszavasvári, Hungary
Contact:

Post by Csaboka »

George wrote:Can it be placed on the shore?
You can have it 1 tile away from water, which is on the shore, effectively.
George wrote:Can it prevent removing the nearby land?
No, it can't do such a thing.
George wrote:Could we have an abstract industry "an old ship", that would have different graphics, name, amount of production?
You can have different graphics via different layouts or random action 2s. Different amounts of production can also be achieved by using the production callback. The name must be the same for every instance of the industry, though.
George wrote:Can we make the industry to produce N tourists from N accepted tourists M days after a day, when they were accepted?
Not really. You can make it "process" the tourists periodically (i.e. x tourists per 3 days), which would result in something similar to that, though.
Reality is that which, when you stop believing in it, doesn't go away.—Philip K. Dick
User avatar
George
Tycoon
Tycoon
Posts: 4363
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

Post by George »

I’ve made my first attempt to code a building (well, it is a statue, but it does not matter). Anyway, I’ve wrote this code

Code: Select all

// - The statue "Bronse Horseman" -
  125 * 36	 00 07 0E 01 01 08 09 03 10 0A 0A FF 0B FF 0C 00 0D 08 0E 00 0F 00 10 FF 7F 11 FF 13 1F F8 14 00
	         18 FF 19 02
  126 * 4	 01 07 01 01
  127 F:\GAMES\TTD-WIN\GRF\pl\SPRITES\NewCargosw01.PCX 242 136 09 50 64 -31 -19
  128 * 17	 02 07 01 00 8C 05 00 00 00 00 00 80 00 00 10 10 00
  129 * 7	 03 07 01 01 00 01 00
  130 * 30	 04 07 1F 01 01 53 74 61 74 75 65 20 22 42 72 6F 6E 7A 65 20 68 6F 72 73 65 6D 61 6E 22 00 
but I have problems with custom name (it is not displayed, the default one is represented instead)

Also I’d like to ask, how I can change this code with the following conditions:
Can not be removed (done?)
If not represented on the map, then it should be built in the random city. The news message should be shown "New statue was build in ... (city name)"
Should not appear in desert (Can be done with var 43?)
Should appear near the water or near the shore (Can we have some nearby tiles check as for canals? May be with vars 80?)
Should appear on the height 1, that means 1 level above the water (Some high check as for canals?)
Would it be possible to make the check of the city name for the part "Peter", "Piter" or "Lenin" and choose that one for building?

I’d like also to ask about the last 5 values of action 2.
newgrf.txt wrote: B xofs x-offset from northern tile corner (must be below 10h)
B yofs y-offset from northern tile corner (must be below 10h)
B xextent size of sprite in x direction
B yextent size of sprite in y direction
B zextent size of sprite in z direction
It works with different values. What do they exactly mean?

And what do that do building flags Bit 6 (This building is a church) and (Bit 7 This building is a stadium) mean, when I specify a new building?

And the final the most important question. How to make it produce and accept tourists?
Image Image Image Image
User avatar
Csaboka
Tycoon
Tycoon
Posts: 1202
Joined: 25 Nov 2002 16:30
Location: Tiszavasvári, Hungary
Contact:

Post by Csaboka »

George wrote:

Code: Select all

08 09 03 10 0A...
Now this doesn't make sense. "08 09" sets the substitute type to the old statue, but houses don't have property 03, so it doesn't make sense from this point.
George wrote: but I have problems with custom name (it is not displayed, the default one is represented instead)
That's because you're setting it incorrectly. The correct way is this:

Code: Select all

04 07 9F 01 01 C9...
since the name of house xx should be modified by changing the generic text C9xxh.
George wrote:Also I’d like to ask, how I can change this code with the following conditions:
Can not be removed (done?)
You can do this by setting bit 1 of property 19. This won't prevent human players from removing it, though, but towns and AI players will leave it alone.
George wrote:If not represented on the map, then it should be built in the random city. The news message should be shown "New statue was build in ... (city name)"
Sorry, but no news messages can be generated for houses.
George wrote: Should not appear in desert (Can be done with var 43?)
Yes, it can be done via var. 43.
George wrote: Should appear near the water or near the shore (Can we have some nearby tiles check as for canals? May be with vars 80?)
With some work, I can give you a variable telling you the distance of the closest water tile, if it's enough for you.
George wrote: Should appear on the height 1, that means 1 level above the water (Some high check as for canals?)
A variable for land height wouldn't be too hard, either.
George wrote: Would it be possible to make the check of the city name for the part "Peter", "Piter" or "Lenin" and choose that one for building?
No. Too much work for too little benefit, if you ask me.
George wrote: I’d like also to ask about the last 5 values of action 2.
...
It works with different values. What do they exactly mean?
These are the coordinates of the bounding box of the building. This information is used by the sprite sorter to find out which sprite covers which. If you get those wrong, the building will still appear OK, but a vehicle passing behind it may be drawn in front of the sprite, or flickering may occur.
George wrote: And what do that do building flags Bit 6 (This building is a church) and (Bit 7 This building is a stadium) mean, when I specify a new building?
TTD allows only one church and one stadium per town. Originally, the IDs of stadiums/churches are hardcoded, but newhouses allows you to add your house to the church/stadium list.
George wrote: And the final the most important question. How to make it produce and accept tourists?
Currently, houses can't produce anyhing other than passengers and mail. They can accept any cargo if you use property 1E.
Reality is that which, when you stop believing in it, doesn't go away.—Philip K. Dick
User avatar
George
Tycoon
Tycoon
Posts: 4363
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

Post by George »

Csaboka wrote:
George wrote:

Code: Select all

08 09 03 10 0A...
Now this doesn't make sense. "08 09" sets the substitute type to the old statue, but houses don't have property 03, so it doesn't make sense from this point.
My fault, it has to be 08 09 09 03 0A
Csaboka wrote:
George wrote:Also I’d like to ask, how I can change this code with the following conditions:
Can not be removed (done?)
You can do this by setting bit 1 of property 19. This won't prevent human players from removing it, though, but towns and AI players will leave it alone.
I did it, but I can't remove them too
Csaboka wrote:
George wrote:If not represented on the map, then it should be built in the random city. The news message should be shown "New statue was build in ... (city name)"
Sorry, but no news messages can be generated for houses.
Would it be hard to do?
Csaboka wrote:
George wrote:Should appear near the water or near the shore (Can we have some nearby tiles check as for canals? May be with vars 80?)
With some work, I can give you a variable telling you the distance of the closest water tile, if it's enough for you.
I wanted water in SE direction. Could you return a SWORD - closest water in NE,SE,SW,NW directions?
Csaboka wrote:
George wrote:Should appear on the height 1, that means 1 level above the water (Some high check as for canals?)
A variable for land height wouldn't be too hard, either.
Ok
Csaboka wrote:
George wrote:I’d like also to ask about the last 5 values of action 2.
It works with different values. What do they exactly mean?
These are the coordinates of the bounding box of the building. This information is used by the sprite sorter to find out which sprite covers which. If you get those wrong, the building will still appear OK, but a vehicle passing behind it may be drawn in front of the sprite, or flickering may occur.
But then why do they can be somethung except 00 00 40 1f xx. And what is Z-coordinate size when the box is 2D. The heigh above the tile+10h?

Csaboka wrote:
George wrote:And what do that do building flags Bit 6 (This building is a church) and (Bit 7 This building is a stadium) mean, when I specify a new building?
TTD allows only one church and one stadium per town. Originally, the IDs of stadiums/churches are hardcoded, but newhouses allows you to add your house to the church/stadium list.
Does it mean that "only one church and this building can be build per town" or "only one building per town"? What will happen, if I'd specify both to 1?
Csaboka wrote:
George wrote:And the final the most important question. How to make it produce and accept tourists?
Currently, houses can't produce anyhing other than passengers and mail. They can accept any cargo if you use property 1E.
How hard would it be to change it. Producing tourists by hotels is the main idea of tourists.
Image Image Image Image
User avatar
George
Tycoon
Tycoon
Posts: 4363
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

Post by George »

I coded it this way

Code: Select all

  125 * 36	 00 07 0E 01 01 08 09 09 03 0A 0A FF 0B FF 0C 00 0D 08 0E 00 0F 00 10 FF 7F 11 FF 13 1F F8 14 01
	         18 FF 19 02
  126 * 4	 01 07 01 01
  127 F:\GAMES\TTD-WIN\GRF\pl\SPRITES\NewCargosw01.PCX 242 136 09 50 64 -31 -19
  128 * 17	 02 07 01 00 8C 05 00 00 00 00 00 80 00 00 10 10 00
  129 * 14	 02 07 10 81 0C 00 FF 01 00 FF 17 17 01 00
  130 * 14	 02 07 11 81 0C 00 FF 01 01 FF 17 17 01 00
  131 * 14	 02 07 12 81 C3 00 FF 01 10 00 01 01 11 00
  132 * 14	 02 07 13 81 C4 00 FF 01 12 00 00 01 10 00
  133 * 14	 02 07 14 81 C4 08 FF 01 13 00 00 0A 10 00
  134 * 7	 03 07 01 01 00 14 00
  135 * 31	 04 07 9F 01 01 C9 53 74 61 74 75 65 20 22 42 72 6F 6E 7A 65 20 68 6F 72 73 65 6D 61 6E 22 00
and got the crash

Code: Select all

TTD V0019E000 Crash Log by TTDPatch 2.0.1 alpha 55 vcs 4 (Windows)

Exception C0000005 at 001B:00619DCC

EAX       EBX       ECX       EDX
000000C4  025D43CC  0000000E  025C6E01

ESI       EDI       ESP       EBP
0000F651  004596D6  0006F5C4  0000004E

DS        ES        FS        GS        SS        Flags
0023      0023      0038      0000      0023      00010282
FFFFFFFF  FFFFFFFF  00000FFF  ########  FFFFFFFF (Segment limits)
00CFF300  00CFF300  0040F300  ########  00CFF300 (Access rights)

Bytes at DS:EIP
8B 04 06 EB 22 0F B6 CA 8A 73 01 F6 C6 E0 8D 5C

Stack Dump:
00619E57  0000004E  025C6EE4  0000F651  00619BA9  00000001  00000017  FFFFFFE9
00624170  00585EE2  00280003  00820081  00890088  00960091  00A8009E  00AD00AC
00B500B1  00BB00B9  00BE00BC  00C000BF  00C800C4  000000CE  00000001  0000001A
00000000  00000000  00000015  00000015  0000000D  0000000D  7A10082A  0685046A

Handler Stack Dump (at 0023:0006F374):
00004002  00000000  4003B000  00000000  00000000  00000038  00000023  00000023
004596D6  0000F651  025D43CC  025C6E01  0000000E  000000C4  0000004E  00619DCC
0000001B  00010282  0006F5C4  00000023  4020027F  05A00000  BF9C2166  00000008
F0041E74  00000023  00001F80  0000FFFF  EF4E58F0  823F4000  0000C9AD  00000000

Patch flags:
FFB8FFFF  FFFFFFFF  FFFFFFFD  00003FFF  00000000  00000000  0005F2BF  A2000000
0000006E  0000002C  00001000  FFFE003C  005007AD  00B40041  016D0041  76260500
13B14EC4  02580320  13880258  05141024  0A28370A  140A1928  1E145014  141E1450
3C1E1E14  003C5A3F  FFFF0314  F0F0F0F0  1EFF0001  005A010A  50040A1E  02010007
010A2357  0301030A  140A0014  FA1E0401  00000000

While processing GRF file: newgrf/NewCargosw.grf; Sprite number: 0085 (hex)
What did I do wrong?
Image Image Image Image
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

George wrote:I wanted water in SE direction. Could you return a SWORD - closest water in NE,SE,SW,NW directions?
So, if the house is at the H, and there are water tiles at 1 and 2, which should be returned as closest SE? The one that's actually SE? The one that's far closer, but not actually SE of the house? Or neither of them, because neither is exactly SE of the house?

Code: Select all

- - - H -
 1 - - - 
- - - 2 -
George wrote:And what is Z-coordinate size when the box is 2D. The heigh above the tile+10h?
Houses are 3D; they have an x-size, a y-size, and a z-size:

Code: Select all

    |z
    |
   / \
 x/   \y
The sprite that represents a house is 2D; it has an x-size and a y-size:

Code: Select all

 |y
 |
 |___
    x
George wrote:
Csaboka wrote:TTD allows only one church and one stadium per town. newhouses allows you to add your house to the church/stadium list.
Does it mean that "only one church and this building can be build per town" or "only one building per town"?
A town with only one building isn't much of a town, is it? (Say what you *mean*!)
It means exactly what it says. "This building is a {church/stadium}."

There may be at most one church and one stadium in each town, and the building in question may be the {church/stadium} for its town.

I assume if you set both bits, then the building can only be built in a town that possesses neither church nor stadium, and that building will serve as both church and stadium for its town.
George wrote:I coded it this way

Code: Select all

  133 * 14	 02 07 14 81 C4
wiki wrote:Variational Action 2 Variables for Houses
80+x None defined, and none ever will because town buildings don't have an internal structure. Trying to access these variables crashes TTD.
NFORenum should have complained. Did you mean "02 07 14 82 C4 ..."?
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
George
Tycoon
Tycoon
Posts: 4363
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

Post by George »

DaleStan wrote:
George wrote:I wanted water in SE direction. Could you return a DWORD - closest water in NE,SE,SW,NW directions?
So, if the house is at the H, and there are water tiles at 1 and 2, which should be returned as closest SE? The one that's actually SE?
I said SE, not S or E. SE is the direction, parallel to the map side, that goes from the north (top) corner to the east (right) corner. So, if a map is a 256x256 matrix, than for element (i, j) we need info about elements (i-1, j), (i, j+1) (i+1, j) (i, j-1)
DaleStan wrote:The one that's far closer, but not actually SE of the house? Or neither of them, because neither is exactly SE of the house?
if we look for the shortest distance to the water in the direction in general, we can take the Manhattan distance to the first square in the sector, like this:

Code: Select all

 ooooooooooooxxxxxxxxxxxx
oooooooooooxxxxxxxxxxxxx
ooooooooooxxxxxxxxxxxxxx
oooooooooxxxxxxxxxxxxxxx
oooooooPxxxxxxxxxxxxxxxx
oooooooooxxxxxxxxxxxxxxx
ooooooooooxxxxxxxxxxxxxx
oooooooooooxxxxxxxxxxxxx
ooooooooooooxxxxxxxxxxxx
oooooooooooooxxxxxxxxxxx
DaleStan wrote:
George wrote:And what is Z-coordinate size when the box is 2D. The heigh above the tile+10h?
Houses are 3D; they have an x-size, a y-size, and a z-size:

Code: Select all

    |z
    |
   / \
 x/   \y
The sprite that represents a house is 2D; it has an x-size and a y-size:

Code: Select all

 |y
 |
 |___
    x
The question is: how to make the image projection. If the sprite is 40h x 1Fh plus я pixels above, what are the 3D box dimensions?
DaleStan wrote:
George wrote:
Csaboka wrote:TTD allows only one church and one stadium per town. newhouses allows you to add your house to the church/stadium list.
Does it mean that "only one church and this building can be build per town" or "only one building per town"?
A town with only one building isn't much of a town, is it? (Say what you *mean*!) It means exactly what it says. "This building is a {church/stadium}."
There may be at most one church and one stadium in each town, and the building in question may be the {church/stadium} for its town.
That means the building can not appear in the town with the church can not appear in the town with this building, right?
DaleStan wrote:
George wrote:I coded it this way

Code: Select all

  133 * 14	 02 07 14 81 C4
wiki wrote:Variational Action 2 Variables for Houses
80+x None defined, and none ever will because town buildings don't have an internal structure. Trying to access these variables crashes TTD.
NFORenum should have complained. Did you mean "02 07 14 82 C4 ..."?
with C4 I try to access var. 44. Do you want to say, that var. 44 is defined for the town, not the building, and I have to check it that way? Then why do I get no error in line 132, where I access the same var. 44, but check the other 8 bits.
I wanted to code whose rules with var. 44: max 2 per town, max 10 on map (as the example)
Image Image Image Image
User avatar
Csaboka
Tycoon
Tycoon
Posts: 1202
Joined: 25 Nov 2002 16:30
Location: Tiszavasvári, Hungary
Contact:

Post by Csaboka »

George wrote:The question is: how to make the image projection. If the sprite is 40h x 1Fh plus я pixels above, what are the 3D box dimensions?
This is the transformation TTD uses to get screen coordinates from game coordinates:

Code: Select all

screen_X = 2*(game_Y - game_X) 
screen_Y = game_Y + game_X - game_Z
This is a lossy transformation, of course, so you can't calculate the game coordinates back from the screen coordinates. You just need to estimate the dimensions of the bounding box yourself. Or, if you're lazy (like me), you can have xoffset/yoffset at 0, xextent/yextent at 16 and zextent as the height of the sprite in pixels. The resulting bounding box will be larger than necessary, but it won't hurt AFAICT.
George wrote:That means the building can not appear in the town with the church can not appear in the town with this building, right?
Yes. If there's a building in the town that has the church-flag set, no other church-flagged buildings are allowed to appear.
George wrote:with C4 I try to access var. 44.
Why did you set bit 7, then? Why didn't you simply write 44 if you meant 44?
Reality is that which, when you stop believing in it, doesn't go away.—Philip K. Dick
User avatar
George
Tycoon
Tycoon
Posts: 4363
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

Post by George »

Csaboka wrote:
George wrote:The question is: how to make the image projection. If the sprite is 40h x 1Fh plus я pixels above, what are the 3D box dimensions?
This is the transformation TTD uses to get screen coordinates from game coordinates:

Code: Select all

screen_X = 2*(game_Y - game_X) 
screen_Y = game_Y + game_X - game_Z
This is a lossy transformation, of course, so you can't calculate the game coordinates back from the screen coordinates. You just need to estimate the dimensions of the bounding box yourself. Or, if you're lazy (like me), you can have xoffset/yoffset at 0, xextent/yextent at 16 and zextent as the height of the sprite in pixels.
Why 16, not 32? The square (image) is 64x31, not 32x32. if I count 16, 16, 35, than I get screen x and y equal to 0 and -3??
Csaboka wrote:The resulting bounding box will be larger than necessary, but it won't hurt AFAICT.
I feel myself stupid :oops:
Csaboka wrote:
George wrote:with C4 I try to access var. 44.
Why did you set bit 7, then? Why didn't you simply write 44 if you meant 44?
This part confused me. I do not know why I understood it this way this time :oops:

Code: Select all

For all features, the 80+x variables are offsets into the corresponding structure in TTD's game data.  The 40+x variables are special variables that are computed on-the-fly, and aren't actually stored anywhere in memory. The 40+x variables are all  doubleword-sized.
Previous time, when I coded trains, I did not do that mistake :(
Now I changed it to 44 and it works.

One more question. I try to make the building to appear only in the main zone of the town (4 if there are 5, 3 if 4, 2 if 3, 1 if 2, disallow otherwise). I code it this way

Code: Select all

  125 * 36	 00 07 0E 01 01 08 09 09 03 0A 0A FF 0B FF 0C 00 0D 08 0E 00 0F 00 10 FF 7F 11 FF 13 1F F8 14 01
	         18 FF 19 02
  126 * 4	 01 07 01 01
  127 F:\GAMES\TTD-WIN\GRF\pl\SPRITES\NewCargosw01.PCX 242 136 09 50 64 -31 -19
  128 * 17	 02 07 01 00 00 00 00 80 00 00 00 80 00 00 10 10 23
  129 * 14	 02 07 10 81 0C 00 FF 01 00 FF 17 17 01 00
  130 * 14	 02 07 11 81 0C 00 FF 01 01 FF 17 17 01 00
  131 * 14	 02 07 12 81 43 00 FF 01 10 00 01 01 11 00
  132 * 14	 02 07 13 81 44 00 FF 01 12 00 00 00 10 00
  133 * 14	 02 07 14 81 44 08 FF 01 13 00 00 FE 10 00
// Z=n and Rn+1>0 => false
  135 * 14	 02 07 22 81 42 00 FF 01 14 00 01 01 10 00
  136 * 14	 02 07 23 82 98 00 FF 01 22 00 00 00 10 00
  137 * 14	 02 07 24 81 42 00 FF 01 14 00 02 02 23 00
  138 * 14	 02 07 25 82 9A 00 FF 01 24 00 00 00 10 00
  139 * 14	 02 07 26 81 42 00 FF 01 14 00 03 03 25 00
  140 * 14	 02 07 27 82 9C 00 FF 01 26 00 00 00 10 00
  141 * 14	 02 07 28 81 42 00 FF 01 14 00 04 04 27 00
  142 * 7	 03 07 01 01 00 28 00
  143 * 31	 04 07 9F 01 01 C9 53 74 61 74 75 65 20 22 42 72 6F 6E 7A 65 20 68 6F 72 73 65 6D 61 6E 22 00
But sometimes the map generator makes confusing results (see the attach) :( What am I doing wrong?
Attachments
SCR27.png
(18.17 KiB) Downloaded 1423 times
Image Image Image Image
User avatar
Csaboka
Tycoon
Tycoon
Posts: 1202
Joined: 25 Nov 2002 16:30
Location: Tiszavasvári, Hungary
Contact:

Post by Csaboka »

George wrote:Why 16, not 32? The square (image) is 64x31, not 32x32.
Let's calculate a little:

Code: Select all

North corner (x:0, y:0, z:0)
screen_X=2*(0-0)=0
screen_Y=0+0-0=0

West corner (x:16, y:0, z:0)
screen_X=2*(0-16)=-32
screen_Y=0+16-0=16

East corner (x:0, y:16, z:0)
screen_X=2*(16-0)=32
screen_Y=16+0-0=16

South corner (x:16, y:16, z:0)
screen_X=2*(16-16)=0
screen_Y=16+16-0=32
The result: You need 64 pixels horizontally (-32..32) and 32 pixels vertically (0..32) to represent a flat tile.
George wrote: if I count 16, 16, 35, than I get screen x and y equal to 0 and -3??
Yes, but there's no problem with that. Screen coordinates can go negative, they're just an offset from the "reference point".
George wrote:One more question. I try to make the building to appear only in the main zone of the town (4 if there are 5, 3 if 4, 2 if 3, 1 if 2, disallow otherwise). I code it this way
(snip)
But sometimes the map generator makes confusing results (see the attach) :( What am I doing wrong?
There is no problem with the coding. I think it's mentioned in the docs somewhere that TTD "cheats" while generating a random town: it increases the number of buildings to get fake town zones. If it didn't do that, newly-generated towns would have zone 1 buildings only, since the house count would start from zero. I think the problem was a result of this; your building was placed correctly according to the fake zones. You can't avoid this kind of error, but it's present at the generation of random maps only. During normal gameplay, zones should be correct.
Reality is that which, when you stop believing in it, doesn't go away.—Philip K. Dick
User avatar
George
Tycoon
Tycoon
Posts: 4363
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

Post by George »

Csaboka wrote:
George wrote:Why 16, not 32? The square (image) is 64x31, not 32x32.
Let's calculate a little:
The result: You need 64 pixels horizontally (-32..32) and 32 pixels vertically (0..32) to represent a flat tile.
I see.
Csaboka wrote:
George wrote:One more question. I try to make the building to appear only in the main zone of the town (4 if there are 5, 3 if 4, 2 if 3, 1 if 2, disallow otherwise).
But sometimes the map generator makes confusing results (see the attach) :( What am I doing wrong?
There is no problem with the coding. I think it's mentioned in the docs somewhere that TTD "cheats" while generating a random town: it increases the number of buildings to get fake town zones. If it didn't do that, newly-generated towns would have zone 1 buildings only, since the house count would start from zero. I think the problem was a result of this; your building was placed correctly according to the fake zones. You can't avoid this kind of error, but it's present at the generation of random maps only. During normal gameplay, zones should be correct.
But what makes town to stop expanding to the planed size. Is there a way to determinate how big do the town plan to be while generation?

What about tourists? Are you working on producing custom cargo by buildings?
Image Image Image Image
User avatar
George
Tycoon
Tycoon
Posts: 4363
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

Post by George »

Csaboka wrote:
George wrote:Could we have an abstract industry "an old ship", that would have different graphics, name, amount of production?
You can have different graphics via different layouts or random action 2s. Different amounts of production can also be achieved by using the production callback. The name must be the same for every instance of the industry, though.
And then, how can I do the following thing: If I have N views for the building, how can I specify, that every view should be represented only once on the map? What will happen, if the some of them will be removed? How can I specify, that the view 1 appears, then 2, then 3 and so on, but when the building with view 1 is removed, the next one should be built with view 1?

And one more question - what var (or how hard would it be to add it) contains the distance between the house and the city centre?
Image Image Image Image
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

George wrote:How can I specify, that the view 1 appears, then 2, then 3 and so on, but when the building with view 1 is removed, the next one should be built with view 1?
Can't be done, AFAICT, and I don't see it happening.
George wrote:And one more question - what var (or how hard would it be to add it) contains the distance between the house and the city centre?
Doesn't exist, but it seems like it shouldn't be too hard to add
George wrote:But what makes town to stop expanding to the planed size. Is there a way to determinate how big do the town plan to be while generation?
I don't think even TTD knows when it's going to stop expanding, until the RNG suddendly turns up "stop expanding".
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
DanMacK
Tycoon
Tycoon
Posts: 3906
Joined: 27 Feb 2004 20:03
Location: Ontario, Canada
Contact:

Post by DanMacK »

Any possibility of using the newcargoes to make more accurate industries for Toyland2Mars?
User avatar
George
Tycoon
Tycoon
Posts: 4363
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

Post by George »

DanMacK wrote:Any possibility of using the newcargoes to make more accurate industries for Toyland2Mars?
Technically yes, but unless the resources of standard landscapes are not used up to 90%, I doubt that anyone will think about spending time on the alternative landscapes. I shall not have enough time to do it. Ask someone else :(
Image Image Image Image
User avatar
Wile E. Coyote
Tycoon
Tycoon
Posts: 8515
Joined: 08 Jul 2004 22:14
Skype: wile.e.coyote2
Location: Belgrade, Serbia
Contact:

Post by Wile E. Coyote »

George, you'll plan petrol as cargo. Would you draw petrol station? I plan to use petrol too in Serbian rail set, so it'd be great if there'll be available petrol station (2x1 tiles).
Serbian rail set with Serbian scenario (ECS, PBI, FIRS and Tourist set compatible) Website | Topic and download | Latest version: 03.06.2015.
Serbian tram set Tracking table | TTD Patch tram set Latest version: 17.06.2015. | Open TTD Remix Latest version: 11.07.2015.
WIN-DOS GRF Converter Topic and download | Version 0.2.1: 09.01.2005.


Runner-up in "Best avatar Forums award" for years 2006 and 2010!
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Semrush [Bot] and 16 guests