Feature: Randomize direction of rail vehicle on build based on probability callback. (#11489)

This allows NewGRF authors to indicate that the game should randomly flip rail vehicles on build, without needing to use random bits nor duplicate sprites to handle it themselves.

To use this functionality, test for callback 162 (CBID_VEHICLE_BUILD_PROBABILITY)  and var10 = 0 (values other than 0 are reserved for future use), and return a value between 0 and 100 inclusive.

The return value is a percentage chance of reversing the vehicle. A value of 0 will always build a forward facing vehicle, and 100 will always build a reverse facing vehicle.
This commit is contained in:
Peter Nelson
2023-11-29 22:40:09 +00:00
committed by GitHub
parent e2c5eb3b65
commit ddd609ce9b
4 changed files with 26 additions and 0 deletions

View File

@@ -103,6 +103,12 @@ bool UsesWagonOverride(const Vehicle *v);
int GetVehicleProperty(const Vehicle *v, PropertyID property, int orig_value, bool is_signed = false);
int GetEngineProperty(EngineID engine, PropertyID property, int orig_value, const Vehicle *v = nullptr, bool is_signed = false);
enum class BuildProbabilityType {
Reversed = 0,
};
bool TestVehicleBuildProbability(Vehicle *v, EngineID engine, BuildProbabilityType type);
enum VehicleTrigger {
VEHICLE_TRIGGER_NEW_CARGO = 0x01,
/* Externally triggered only for the first vehicle in chain */