Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Mon Dec 18, 2017 2:55 pm

All times are UTC




Post new topic  Reply to topic  [ 16 posts ] 
Author Message
PostPosted: Wed Nov 29, 2017 6:10 pm 
Online
Tycoon
Tycoon
User avatar

Joined: Wed May 16, 2007 4:59 pm
Posts: 2790
So I'm back (for now) and looking at town houses in NML...

A few little questions to get started, I'll give some code snippets if more info is needed:

1. Random colours in houses.
The NML specs say there is a house property "random colours" which takes an array of four recolours, eg. [COLOUR_DARK_BLUE, COLOUR_DARK_GREEN, COLOUR_BLUE, COLOUR_WHITE]. I tried this with dummy house sprites that are entirely company colour, but it didn't seem to do anything... Always appeared blue. Am I using the right table of recolours?

2. Preferred method for road-facing houses.
I can get a switch detecting nearby roads, and pick appropriate sprites or return an appropriate value, but what's the best way to then handle this data? Directly using the switch to pick sprites works, but allows the building to rotate when you change the neighbouring roads, and the redrawing isn't clean. Using four animation frames and setting the animation frame via anim_control works, but it takes a tile loop to set the house to its correct orientation and is still sensitive to changes to the neighbouring roads. I thought setting the animation frame on changes to construction state via construction_anim might avoid this, by triggering only on construction state changes, but this didn't seem to work.

3. Town index
I'd like to use the town index for some pseudo-random town to town variation. It's listed as a variable for a NFO varaction2, but not as an nml switch variable. Can I access that variable via NML? On a related note, is the coordinates of the town centre accessible via NML or NFO? I thought it was, but can't find it documented...

_________________
GRVTS/eGRVTS --- Generic Tram Set --- UK Town Set --- zBase ---RichardWheeler.net


Top
   
PostPosted: Thu Nov 30, 2017 12:53 am 
Offline
Tycoon
Tycoon

Joined: Wed Jan 17, 2007 12:14 am
Posts: 6940
2) i'm not entirely sure, but there should be a way to "stop" the animation after it ran once, so you shouldn't have to worry about later changes. possibly you need a fifth (or zeroth) animation frame "undecided"

3) unknown variables can be accessed with "var[num, shift, mask]", but you should open a feature request about it.

_________________
You might not exactly be interested in Ferion, but if you are, have fun :)


Top
   
PostPosted: Thu Nov 30, 2017 6:45 am 
Offline
Tycoon
Tycoon

Joined: Wed Apr 27, 2005 7:09 am
Posts: 5112
1) You can´t use CC blue for house recolouring. IIRC, you need to use brownish 0x46 .. 0x4F.

2) Take a look into the code for Swedish houses. It is mis-using animation for road-facing.

regards
Michael

_________________
Image


Top
   
PostPosted: Fri Dec 01, 2017 8:46 am 
Online
Tycoon
Tycoon
User avatar

Joined: Wed May 16, 2007 4:59 pm
Posts: 2790
Thanks! Swedish towns was very informative. When the animation frame is zero (ie. new buildings) it picks an animation frame (1 and higher) based on neighbouring roads. When the animation frame is more than zero it stops the animation. I'm guessing it also sets the animation speed to high to quickly change house orientation...

_________________
GRVTS/eGRVTS --- Generic Tram Set --- UK Town Set --- zBase ---RichardWheeler.net


Top
   
PostPosted: Fri Dec 01, 2017 10:07 am 
Offline
Tycoon
Tycoon

Joined: Wed Apr 27, 2005 7:09 am
Posts: 5112
Zephyris wrote:
I'm guessing it also sets the animation speed to high to quickly change house orientation...

That´s not needed, since the default is already fastest (108 msec). And in fact, it won´t be needed since "speed" is defined as amount of time between switching frames. And house orientation should be set exclusively when building, shouldn´t it?

regards
Michael

_________________
Image


Top
   
PostPosted: Fri Dec 01, 2017 12:42 pm 
Online
Tycoon
Tycoon
User avatar

Joined: Wed May 16, 2007 4:59 pm
Posts: 2790
The issue I'm seeing is that the house is initially built facing in the default direction (ie. whatever is shown for animation frame 0). It seems the animation frame is then updated on the next tile loop (is that when the next animation frame is triggered?); this setting the building to the correct orientation (ie. animation frame 1 to 4). Adding the animation stop prevents the house from re-orienting when you demolish/add neighboring roads (ie. they are fixed in animation frame 1 to 4). It doesn't help with that initial default orientation (which is always frame 0).

Looking in more detail I think the way Swedish houses handles this is by using two switches: For frame 0 have a direct switch in orientation based on neighbouring roads then 'lock' the orientation using frame 1 to 4 use the orientation based on that animation frame. It just seems a bit inelegant. Or perhaps I've just missed how it works...

I'm wondering if callback triggers other than anim_control (callback 1A) might work better. anim_next_frame and construction_anim (callback 1B and 1C) never seem to trigger though.

_________________
GRVTS/eGRVTS --- Generic Tram Set --- UK Town Set --- zBase ---RichardWheeler.net


Top
   
PostPosted: Fri Dec 01, 2017 1:10 pm 
Online
Tycoon
Tycoon
User avatar

Joined: Wed May 16, 2007 4:59 pm
Posts: 2790
I think I've solved the random colour problem.

In NFO:
https://newgrf-specs.tt-wiki.net/wiki/A ... ng_sprites

House action2/sprite layout, under sprite definition for ground and building sprites, says:
...
Bits 14-15: 0: draw sprite normally, 1: draw sprite in transparent mode, 2: recolor sprite
Bits 16-29: Colour translation special sprite number
...

If bits 16-29 are set then it just uses that recolouring. If they are not set then, if house callback 1E is returns a value, that palette/colour translation will be used. Otherwise if colours are specified in house action0 property 17 then they will be used.

In NML:
https://newgrf-specs.tt-wiki.net/wiki/N ... ecolouring
Setting a recolour_mode in a spritelayout is presumably equivalent to action2/sprite layout bits 14-15. Similarly setting the palette in a spritelayout is presumably setting bits 16-29.

Not setting a palette (i.e. ommitting the line) is not allowed:
"nmlc ERROR: 'palette' must be set when 'recolour_mode' is not set to RECOLOUR_NONE"
However, setting palette to 0 (i.e. trying to imitate setting bits 16-29 to zero) works.

It looks like an over-stringency in nmlc; if recolour_mode is not set to RECOLOUR_NONE then palette should probably default to zero.

_________________
GRVTS/eGRVTS --- Generic Tram Set --- UK Town Set --- zBase ---RichardWheeler.net


Top
   
PostPosted: Tue Dec 05, 2017 9:44 pm 
Online
Tycoon
Tycoon
User avatar

Joined: Wed May 16, 2007 4:59 pm
Posts: 2790
Another question:
Is there a way to get the coordinates of the town for a grf? I'd like to effectively add another town zone right at the town centre. That should be easily possible with a construction callback checking town zone and distance from town centre, assuming town centre coordinates are accessible.

_________________
GRVTS/eGRVTS --- Generic Tram Set --- UK Town Set --- zBase ---RichardWheeler.net


Top
   
PostPosted: Wed Dec 06, 2017 2:30 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9025
Location: Sol d
Zephyris wrote:
Another question:
Is there a way to get the coordinates of the town for a grf? I'd like to effectively add another town zone right at the town centre. That should be easily possible with a construction callback checking town zone and distance from town centre, assuming town centre coordinates are accessible.


I was about to answer "yes, sure". But seems that houses don't have that information available - opposed to industries which can query their distance from the closest town.

_________________
Image
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML


Top
   
PostPosted: Fri Dec 08, 2017 1:24 pm 
Online
Tycoon
Tycoon
User avatar

Joined: Wed May 16, 2007 4:59 pm
Posts: 2790
The house coordinates themselves are accessible right? If the town is accessible too then I could use the difference between the two, but I couldn't work out if town coordinates are accessible as one of the undocumented features...

_________________
GRVTS/eGRVTS --- Generic Tram Set --- UK Town Set --- zBase ---RichardWheeler.net


Top
   
PostPosted: Fri Dec 08, 2017 7:57 pm 
Offline
Tycoon
Tycoon

Joined: Wed Apr 27, 2005 7:09 am
Posts: 5112
Zephyris wrote:
I couldn't work out if town coordinates are accessible as one of the undocumented features...

Since m4nfo includes a function townlocation() (accessing town var 0x80), I think it should work. At least it did in TTDPatch, never tried it for OTTD.

regards
Michael

_________________
Image


Top
   
PostPosted: Fri Dec 08, 2017 9:17 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sun Oct 09, 2011 1:51 pm
Posts: 1446
Location: The Netherlands
michael blunck wrote:
Zephyris wrote:
I couldn't work out if town coordinates are accessible as one of the undocumented features...

Since m4nfo includes a function townlocation() (accessing town var 0x80), I think it should work. At least it did in TTDPatch, never tried it for OTTD.

regards
Michael


A bit offtopic, but related:
Is it also possible to extract that information? For example to a .txt?

_________________
Projects: viewtopic.php?f=26&t=57266
Screenshots: viewtopic.php?f=47&t=56959

Winner of the following screenshot competitions:
sep 2012, jan 2013, apr 2013, aug 2013, mar 2014, mar 2016
All my work is released under GPL-license (either V2 or V3), if not clearly stated otherwise.


Top
   
PostPosted: Sat Dec 09, 2017 11:26 am 
Offline
Tycoon
Tycoon

Joined: Wed Apr 27, 2005 7:09 am
Posts: 5112
Quast65 wrote:
Is it also possible to extract that information? For example to a .txt?

You´re asking about extracting town coordinates from a game? Probably by using a script.

regards
Michael

_________________
Image


Top
   
PostPosted: Sun Dec 10, 2017 7:16 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Nov 27, 2004 3:05 pm
Posts: 5013
Location: Canada
Quote:
On a related note, is the coordinates of the town centre accessible via NML or NFO? I thought it was, but can't find it documented...

Town co-ordinates ... Sounds like a GPS question.
Opening a town's window and clicking on the Location button centers the map precisely on that location.
Similarly with clicking on a town's name in the Town List menu, which should have those names and co-ordinates all in one convenient [src], no?
I'm not at all a dev or a patch level coder, but I suspect a poke about the appropriate [src] would give up a variable name or an array co-ordinate containing the sought after values.

_________________
wallyweb on tt-forums: Screenshots - Projects - Releases
wallyweb on Simuscape: Projects - Releases
Other Stuff: TTDPatch 2.6 "Nightly" download - cirdan's OpenTTD branch (New Map Features)
Screenshot Of The Month Contest Winner: August 2015 - Tied May 2016


Top
   
PostPosted: Sun Dec 10, 2017 1:47 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sun Oct 09, 2011 1:51 pm
Posts: 1446
Location: The Netherlands
Quote:
You´re asking about extracting town coordinates from a game?

Yes
Quote:
Probably by using a script.

Quote:
but I suspect a poke about the appropriate [src] would give up a variable name or an array co-ordinate containing the sought after values.

Well, the first person who figures that out, gets a virtual beer from me (and I tell ya, those will be worth more than Bitcoin!! :mrgreen: )

_________________
Projects: viewtopic.php?f=26&t=57266
Screenshots: viewtopic.php?f=47&t=56959

Winner of the following screenshot competitions:
sep 2012, jan 2013, apr 2013, aug 2013, mar 2014, mar 2016
All my work is released under GPL-license (either V2 or V3), if not clearly stated otherwise.


Top
   
PostPosted: Mon Dec 18, 2017 2:52 pm 
Online
Tycoon
Tycoon
User avatar

Joined: Wed May 16, 2007 4:59 pm
Posts: 2790
I'll take a look at accessing those variables, sounds promising.

New question: Is it intentional behaviour to be able to block removal of buildings by setting the local authority rating impact to greater than 1000? I'm not complaining (it would be very useful for landmark-type buildings) but I found it a little surprising.

_________________
GRVTS/eGRVTS --- Generic Tram Set --- UK Town Set --- zBase ---RichardWheeler.net


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 16 posts ] 

All times are UTC


Who is online

Users browsing this forum: Zephyris and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2017 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2017.
Hosted by Zernebok Hosting.