[OTTD] Feature request - Ship 'type' action 0 property

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

Moderator: Graphics Moderators

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

[OTTD] Feature request - Ship 'type' action 0 property

Post by andythenorth »

It would be useful if ships had a 'type' property similar to train prop 19

Types would be sail / steam / diesel.

This would be used primarily so players could set the company colours. It would extend the current 'passenger ferry / freight ship' choices in the company colour menu. Steam ships tend to be dark colours, sailing ships vary, and modern ships tend to be brightly painted, and it would be nice for players to be able to set this. More ship sets are appearing, so this would be a nice useful feature.

If type was defined, other features could be added in future - for instance if ships had smoke effects available in game, this could be used to choose which smoke to use (steam / diesel).

cheers,

Andy
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Re: [OTTD] Feature request - Ship 'type' action 0 property

Post by michael blunck »

andythenorth wrote: [...] if ships had smoke effects available in game, this could be used to choose which smoke to use (steam / diesel).
You may already use the motion counter to add smoke effects to ships.

regards
Michael
Image
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: [OTTD] Feature request - Ship 'type' action 0 property

Post by Eddi »

Problem with the approach to include the smoke in the ship drawing is that if the ship turns, the smoke moves as well. with rail engines, the smoke stays where it was emitted, regardless of vehicle movement.
Hirundo
Transport Coordinator
Transport Coordinator
Posts: 298
Joined: 27 Jan 2008 13:02

Re: [OTTD] Feature request - Ship 'type' action 0 property

Post by Hirundo »

Since I felt like patching today, here is a patch that adds some new livery types for ships. :D

The patch is in two parts. The first adds a new action0 property 0x1C for ships. This is a byte-sized property with three possible values
0: steam ship
1: diesel ship
2: sailing ship
Existing ships are all set to class 1 (diesel). Ships that are not based on an existing ship (nfo IDs 0x00 - 0x0A) will have 0, i.e. steam, as their setting. I thought this would not be a problem, since there are (to my knowledge) no major ship sets that make use of the newgrf engine pool, except FISH.

The second part uses this new property to add some additional liveries. The existing 'passenger ferry' and 'freight ship' have been split into three settings each.

The functionality could be extended for visual effects. For flexibility (multiple ship generations in one ID, etc.), I suggest enhancing CB 10, though action0 could be used as well. CB 33 support (sound effects) would be nice as well. This requires some restructuring of the visual effect code to make it work without code duplication, so I've left it out for now.

Attached are diff files for the individual parts and the total patch. Enjoy :P
Attachments
0_prop.diff
(4.05 KiB) Downloaded 143 times
1_livery.diff
(5.77 KiB) Downloaded 146 times
total.diff
(9.82 KiB) Downloaded 147 times
Create your own NewGRF? Check out this tutorial!
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: [OTTD] Feature request - Ship 'type' action 0 property

Post by planetmaker »

Nice thing :-)
Hirundo wrote: Existing ships are all set to class 1 (diesel). Ships that are not based on an existing ship (nfo IDs 0x00 - 0x0A) will have 0, i.e. steam, as their setting.
That sounds IMHO like a bad choice. Make it consistant. If that means that diesel=0 and steam=1 it's not bad; but the defaults being the same for all ships is much easier to work with, resulting in WAY less confusion.
Hirundo
Transport Coordinator
Transport Coordinator
Posts: 298
Joined: 27 Jan 2008 13:02

Re: [OTTD] Feature request - Ship 'type' action 0 property

Post by Hirundo »

It's the same for other vehicles/properties. E.g. if I use the ID of a train engine that happens to be electric, the engine itself will be electric unless I set set the property myself in action0. If I use an ID outside of the normal range, I don't know what I'll get (I'd expect steam, though).
The default ships are all diesels, therefore if you override them you will get diesel ships only by default.

Perhaps I should not have mentioned that the 'default' is steam for IDs > 0x0A, rather it should be considered undefined. There is a reason that newgrfs should specify each and every property for such vehicles. IDs that do not match a TTD vehicle do not actually have any default values (except for RV tractive effort), they are initialized as zeroes. In this case, zero happens to be equal to 'Steam', but that might as well be anything else. It should not documented in the official specification and certainly not relied on.

The reason that steam == 0 and diesel == 1 is because that matches the values used for trains (internally), therefore visual effects will be slightly easier to code.
Create your own NewGRF? Check out this tutorial!
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 991
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: [OTTD] Feature request - Ship 'type' action 0 property

Post by frosch »

All new properties after enginepool got defaults. (though I would not mind if they had sane defaults for all properties, if someone manages to define "sane")
See Engine constructor (base_life for wagons and tractive effort for road vehicles).
If you do not supply defaults you break existing grfs. And in this case "diesel" looks like a sane default. OTOH a default visual effect would be "no effect", which might not be "diesel".
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Hirundo
Transport Coordinator
Transport Coordinator
Posts: 298
Joined: 27 Jan 2008 13:02

Re: [OTTD] Feature request - Ship 'type' action 0 property

Post by Hirundo »

Update:

- Colouring actually works correctly now, it used to fail because of a missing 'break' statement.
- Diesel is now the default for all vehicles.
Attachments
0_shipclass.diff
(4.55 KiB) Downloaded 140 times
1_livery.diff
(5.81 KiB) Downloaded 138 times
total.diff
(10.38 KiB) Downloaded 138 times
Create your own NewGRF? Check out this tutorial!
Hirundo
Transport Coordinator
Transport Coordinator
Posts: 298
Joined: 27 Jan 2008 13:02

Re: [OTTD] Feature request - Ship 'type' action 0 property

Post by Hirundo »

New patch version attached. Changes:

- Applies to r20806
- Removal of some useless code, shaving around 2kb off the diff.
Attachments
0_shipclass.diff
(2.48 KiB) Downloaded 156 times
1_livery.diff
(5.81 KiB) Downloaded 151 times
total.diff
(8.32 KiB) Downloaded 140 times
Create your own NewGRF? Check out this tutorial!
damerell
Traffic Manager
Traffic Manager
Posts: 190
Joined: 22 Feb 2008 23:09

Re: [OTTD] Feature request - Ship 'type' action 0 property

Post by damerell »

andythenorth wrote:It would be useful if ships had a 'type' property similar to train prop 19

Types would be sail / steam / diesel.
How curious. I was just thinking about this, playing a game with the "sailing ships" newgrf.

I definitely agree that there should be a "no effect" type - this would also be useful for horse-drawn canal boats.

But "sail" ships might have more radical effects; suppose the prevailing wind on OTTD maps is Northerly. The patch might be extended so that they travel at different fractions of their rated speeds depending on the direction of travel. This would give a real flavour to sailing ships to make them distinct from other ships.

You don't want to get into changing wind directions. This way, newgrf authors could draw ships close-hauled when travelling NE and NW and reaching or running when travelling in other directions, but wouldn't have to draw any additional graphics; and on the scale of an OTTD game, the prevailing wind is the appropriate concern.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: [OTTD] Feature request - Ship 'type' action 0 property

Post by planetmaker »

damerell wrote: But "sail" ships might have more radical effects; suppose the prevailing wind on OTTD maps is Northerly. The patch might be extended so that they travel at different fractions of their rated speeds depending on the direction of travel. This would give a real flavour to sailing ships to make them distinct from other ships.
You might try something with vehicle variable 80+1F for this endeavor: http://marcin.ttdpatch.net/sv1codec/TTD ... hicleArray and http://wiki.ttdpatch.net/tiki-index.php ... n2Vehicles and callback 0x36 for speed.
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 12 guests