FS#5467 - Callback to populate vehicle purchase list

Attached to Project: OpenTTD
Opened by David Dallaston (Pikka) - Saturday, 09 February 2013, 00:19 GMT
Last edited by Alberth (Alberth) - Monday, 11 February 2013, 12:58 GMT
Type Feature Request
Category NewGRF
Status Closed
Assigned To No-one
Operating System All
Severity Medium
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No


It would be nice to have a callback to add/remove vehicles from the purchase list, so that different players could have different vehicles available (similar to the way, at the moment, one player can have access a prototype vehicle that other players do not).

The uses for this callback would include:

a) hiding "confusing" vehicles from an AI player.
b) hiding "AI Only" vehicles from a human player (for example, street traffic cars).
c) giving players exclusive vehicles in multiplayer games (for example, player 1 gets German trains and player 2 gets French trains).
d) enabling vehicles as "rewards", in cooperation with a game script.

Callback returns 0 to allow and 1 to hide vehicle from buy list. Perhaps 2 to display vehicle but not allow construction?

New variables which would be nice, but not essential, for this callback are:

a) availability of other vehicle (x). This would allow, for example, specialist wagons to be hidden before the locomotive which hauls them appears.
b) count of vehicle (this/x) (owned by this player/everyone). This would allow authors to limit the number of a particular vehicle, if they wanted to do that for some reason.
This task depends upon

Closed by  Alberth (Alberth)
Monday, 11 February 2013, 12:58 GMT
Reason for closing:  Won't implement
Additional comments about closing:  Second attempt in  FS#4571 
Comment by Juanjo (juanjo) - Saturday, 09 February 2013, 10:51 GMT
This task is related with  FS#5292  - Add filters to the build vehicle GUI.
The filter for vehicles solve b).
As for c) and d), I don't think a newGRF/GameScript callback is the right solution. It would be better to introduce a new engine/company bit: "Has this company rights to use this engine?". With that you can:
c) At the start of the game, set which set of engines each company will be allowed to use without paying any additional cost.
d) Enable vehicles as rewards controlled by GS.
e) When the company isn't allowed to use an engine, it can pay a (high) amount of money to use it.
Comment by David Dallaston (Pikka) - Saturday, 09 February 2013, 20:41 GMT
I think you've missed the point, Juanjo. "Filters" are all very well, but they require far too much cooperation and knowledge from the player for what I'm trying to achieve here.
Comment by David Dallaston (Pikka) - Monday, 11 February 2013, 08:08 GMT
It additionally occurs to me that, if implented, this callback should also have the ability to auto-reject new vehicle prototypes. Otherwis players will be offered prototypes of vehicles they're not going to be able to build.
Comment by Alberth (Alberth) - Monday, 11 February 2013, 13:01 GMT
And of course that number was wrong, the new bug is FS#5471