Page 1 of 1
[OTTD] Feature request - Ship 'type' action 0 property
Posted: 18 Aug 2010 19:01
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
Re: [OTTD] Feature request - Ship 'type' action 0 property
Posted: 18 Aug 2010 20:44
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
Re: [OTTD] Feature request - Ship 'type' action 0 property
Posted: 19 Aug 2010 01:47
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.
Re: [OTTD] Feature request - Ship 'type' action 0 property
Posted: 19 Aug 2010 13:23
by Hirundo
Since I felt like patching today, here is a patch that adds some new livery types for ships.
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

Re: [OTTD] Feature request - Ship 'type' action 0 property
Posted: 19 Aug 2010 13:50
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.
Re: [OTTD] Feature request - Ship 'type' action 0 property
Posted: 19 Aug 2010 17:40
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.
Re: [OTTD] Feature request - Ship 'type' action 0 property
Posted: 19 Aug 2010 19:55
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".
Re: [OTTD] Feature request - Ship 'type' action 0 property
Posted: 19 Aug 2010 21:19
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.
Re: [OTTD] Feature request - Ship 'type' action 0 property
Posted: 19 Aug 2010 21:51
by andythenorth
Patch works with default ships as advertised, and FISH defaults to diesel.
I'll add some test code to FISH to test steam / sail
Request: 'Passenger Ship' instead of 'Passenger Ferry'.
Re: [OTTD] Feature request - Ship 'type' action 0 property
Posted: 14 Sep 2010 18:24
by Hirundo
New patch version attached. Changes:
- Applies to r20806
- Removal of some useless code, shaving around 2kb off the diff.
Re: [OTTD] Feature request - Ship 'type' action 0 property
Posted: 14 Sep 2010 20:16
by andythenorth
Tested and works with r20806 (and a modified version of FISH making use of prop 1C)
Re: [OTTD] Feature request - Ship 'type' action 0 property
Posted: 02 Jan 2011 00:30
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.
Re: [OTTD] Feature request - Ship 'type' action 0 property
Posted: 02 Jan 2011 00:38
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.