OpenTTD AI API
20241117-master-ga6c526cfa0
|
Class that handles all order related functions. More...
Static Public Member Functions | |
static bool | IsValidVehicleOrder (VehicleID vehicle_id, OrderPosition order_position) |
Checks whether the given order id is valid for the given vehicle. More... | |
static bool | IsGotoStationOrder (VehicleID vehicle_id, OrderPosition order_position) |
Checks whether the given order is a goto-station order. More... | |
static bool | IsGotoDepotOrder (VehicleID vehicle_id, OrderPosition order_position) |
Checks whether the given order is a goto-depot order. More... | |
static bool | IsGotoWaypointOrder (VehicleID vehicle_id, OrderPosition order_position) |
Checks whether the given order is a goto-waypoint order. More... | |
static bool | IsConditionalOrder (VehicleID vehicle_id, OrderPosition order_position) |
Checks whether the given order is a conditional order. More... | |
static bool | IsVoidOrder (VehicleID vehicle_id, OrderPosition order_position) |
Checks whether the given order is a void order. More... | |
static bool | IsRefitOrder (VehicleID vehicle_id, OrderPosition order_position) |
Checks whether the given order has a valid refit cargo. More... | |
static bool | IsCurrentOrderPartOfOrderList (VehicleID vehicle_id) |
Checks whether the current order is part of the orderlist. More... | |
static OrderPosition | ResolveOrderPosition (VehicleID vehicle_id, OrderPosition order_position) |
Resolves the given order index to the correct index for the given vehicle. More... | |
static bool | AreOrderFlagsValid (TileIndex destination, AIOrderFlags order_flags) |
Checks whether the given order flags are valid for the given destination. More... | |
static bool | IsValidConditionalOrder (OrderCondition condition, CompareFunction compare) |
Checks whether the given combination of condition and compare function is valid. More... | |
static int | GetOrderCount (VehicleID vehicle_id) |
Returns the number of orders for the given vehicle. More... | |
static TileIndex | GetOrderDestination (VehicleID vehicle_id, OrderPosition order_position) |
Gets the destination of the given order for the given vehicle. More... | |
static AIOrderFlags | GetOrderFlags (VehicleID vehicle_id, OrderPosition order_position) |
Gets the AIOrderFlags of the given order for the given vehicle. More... | |
static OrderPosition | GetOrderJumpTo (VehicleID vehicle_id, OrderPosition order_position) |
Gets the OrderPosition to jump to if the check succeeds of the given order for the given vehicle. More... | |
static OrderCondition | GetOrderCondition (VehicleID vehicle_id, OrderPosition order_position) |
Gets the OrderCondition of the given order for the given vehicle. More... | |
static CompareFunction | GetOrderCompareFunction (VehicleID vehicle_id, OrderPosition order_position) |
Gets the CompareFunction of the given order for the given vehicle. More... | |
static int | GetOrderCompareValue (VehicleID vehicle_id, OrderPosition order_position) |
Gets the value to compare against of the given order for the given vehicle. More... | |
static StopLocation | GetStopLocation (VehicleID vehicle_id, OrderPosition order_position) |
Gets the stoplocation of the given order for the given train. More... | |
static CargoID | GetOrderRefit (VehicleID vehicle_id, OrderPosition order_position) |
Gets the refit cargo type of the given order for the given vehicle. More... | |
static bool | SetOrderJumpTo (VehicleID vehicle_id, OrderPosition order_position, OrderPosition jump_to) |
Sets the OrderPosition to jump to if the check succeeds of the given order for the given vehicle. More... | |
static bool | SetOrderCondition (VehicleID vehicle_id, OrderPosition order_position, OrderCondition condition) |
Sets the OrderCondition of the given order for the given vehicle. More... | |
static bool | SetOrderCompareFunction (VehicleID vehicle_id, OrderPosition order_position, CompareFunction compare) |
Sets the CompareFunction of the given order for the given vehicle. More... | |
static bool | SetOrderCompareValue (VehicleID vehicle_id, OrderPosition order_position, int value) |
Sets the value to compare against of the given order for the given vehicle. More... | |
static bool | SetStopLocation (VehicleID vehicle_id, OrderPosition order_position, StopLocation stop_location) |
Sets the stoplocation of the given order for the given train. More... | |
static bool | SetOrderRefit (VehicleID vehicle_id, OrderPosition order_position, CargoID refit_cargo) |
Sets the refit cargo type of the given order for the given vehicle. More... | |
static bool | AppendOrder (VehicleID vehicle_id, TileIndex destination, AIOrderFlags order_flags) |
Appends an order to the end of the vehicle's order list. More... | |
static bool | AppendConditionalOrder (VehicleID vehicle_id, OrderPosition jump_to) |
Appends a conditional order to the end of the vehicle's order list. More... | |
static bool | InsertOrder (VehicleID vehicle_id, OrderPosition order_position, TileIndex destination, AIOrderFlags order_flags) |
Inserts an order before the given order_position into the vehicle's order list. More... | |
static bool | InsertConditionalOrder (VehicleID vehicle_id, OrderPosition order_position, OrderPosition jump_to) |
Appends a conditional order before the given order_position into the vehicle's order list. More... | |
static bool | RemoveOrder (VehicleID vehicle_id, OrderPosition order_position) |
Removes an order from the vehicle's order list. More... | |
static bool | SetOrderFlags (VehicleID vehicle_id, OrderPosition order_position, AIOrderFlags order_flags) |
Changes the order flags of the given order. More... | |
static bool | MoveOrder (VehicleID vehicle_id, OrderPosition order_position_move, OrderPosition order_position_target) |
Move an order inside the orderlist. More... | |
static bool | SkipToOrder (VehicleID vehicle_id, OrderPosition next_order) |
Make a vehicle execute next_order instead of its current order. More... | |
static bool | CopyOrders (VehicleID vehicle_id, VehicleID main_vehicle_id) |
Copies the orders from another vehicle. More... | |
static bool | ShareOrders (VehicleID vehicle_id, VehicleID main_vehicle_id) |
Shares the orders between two vehicles. More... | |
static bool | UnshareOrders (VehicleID vehicle_id) |
Removes the given vehicle from a shared orders list. More... | |
static int | GetOrderDistance (AIVehicle::VehicleType vehicle_type, TileIndex origin_tile, TileIndex dest_tile) |
Get the distance between two points for a vehicle type. More... | |
Class that handles all order related functions.
Flags that can be used to modify the behaviour of orders.
Comparators for conditional orders.
All order related error messages.
All conditions a conditional order can depend on.
Enumerator | |
---|---|
OC_LOAD_PERCENTAGE | Skip based on the amount of load, value is in tons. |
OC_RELIABILITY | Skip based on the reliability, value is percent (0..100). |
OC_MAX_RELIABILITY | Skip based on the maximum reliability. Value in percent. |
OC_MAX_SPEED | Skip based on the maximum speed, value is in OpenTTD's internal speed unit, see AIEngine::GetMaxSpeed. |
OC_AGE | Skip based on the age, value is in calender-years.
|
OC_REQUIRES_SERVICE | Skip when the vehicle requires service, no value. |
OC_UNCONDITIONALLY | Always skip, no compare function, no value. |
OC_REMAINING_LIFETIME | Skip based on the remaining lifetime in calendar-years.
|
OC_INVALID | An invalid condition, do not use. |
Index in the list of orders for a vehicle.
The first order has index 0, the second order index 1, etc. The current order can be queried by using ORDER_CURRENT. Do not use ORDER_INVALID yourself, it's used as return value by for example ResolveOrderPosition.
Enumerator | |
---|---|
ORDER_CURRENT | Constant that gets resolved to the current order. |
ORDER_INVALID | An invalid order. |
Where to stop trains in a station that's longer than the train.
|
static |
Appends a conditional order to the end of the vehicle's order list.
vehicle_id | The vehicle to append the order to. |
jump_to | The OrderPosition to jump to if the condition is true. |
|
static |
Appends an order to the end of the vehicle's order list.
vehicle_id | The vehicle to append the order to. |
destination | The destination of the order. |
order_flags | The flags given to the order. |
AIError::ERR_OWNED_BY_ANOTHER_COMPANY | |
AIOrder::ERR_ORDER_TOO_MANY | |
AIOrder::ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION |
|
static |
Checks whether the given order flags are valid for the given destination.
destination | The destination of the order. |
order_flags | The flags given to the order. |
Copies the orders from another vehicle.
The orders of the main vehicle are going to be the orders of the changed vehicle.
vehicle_id | The vehicle to copy the orders to. |
main_vehicle_id | The vehicle to copy the orders from. |
AIError::ERR_OWNED_BY_ANOTHER_COMPANY | |
AIOrder::ERR_ORDER_TOO_MANY | |
AIOrder::ERR_ORDER_AIRCRAFT_NOT_ENOUGH_RANGE |
|
static |
Gets the CompareFunction of the given order for the given vehicle.
vehicle_id | The vehicle to get the compare function for. |
order_position | The order to get the compare function for. |
|
static |
Gets the value to compare against of the given order for the given vehicle.
vehicle_id | The vehicle to get the value for. |
order_position | The order to get the value for. |
|
static |
Gets the OrderCondition of the given order for the given vehicle.
vehicle_id | The vehicle to get the condition type for. |
order_position | The order to get the condition type for. |
|
static |
Returns the number of orders for the given vehicle.
vehicle_id | The vehicle to get the order count of. |
|
static |
Gets the destination of the given order for the given vehicle.
vehicle_id | The vehicle to get the destination for. |
order_position | The order to get the destination for. |
|
static |
Get the distance between two points for a vehicle type.
Use this function to compute the distance between two tiles wrt. a vehicle type. These vehicle-type specific distances are independent from other map distances, you may use the result of this function to compare it with the result of AIEngine::GetMaximumOrderDistance or AIVehicle::GetMaximumOrderDistance.
vehicle_type | The vehicle type to get the distance for. |
origin_tile | Origin, can be any tile or a tile of a specific station. |
dest_tile | Destination, can be any tile or a tile of a specific station. |
|
static |
Gets the AIOrderFlags of the given order for the given vehicle.
vehicle_id | The vehicle to get the destination for. |
order_position | The order to get the destination for. |
|
static |
Gets the OrderPosition to jump to if the check succeeds of the given order for the given vehicle.
vehicle_id | The vehicle to get the OrderPosition for. |
order_position | The order to get the OrderPosition for. |
|
static |
Gets the refit cargo type of the given order for the given vehicle.
vehicle_id | The vehicle to get the refit cargo for. |
order_position | The order to get the refit cargo for. |
|
static |
Gets the stoplocation of the given order for the given train.
vehicle_id | The vehicle to get the value for. |
order_position | The order to get the value for. |
|
static |
Appends a conditional order before the given order_position into the vehicle's order list.
vehicle_id | The vehicle to add the order to. |
order_position | The order to place the new order before. |
jump_to | The OrderPosition to jump to if the condition is true. |
|
static |
Inserts an order before the given order_position into the vehicle's order list.
vehicle_id | The vehicle to add the order to. |
order_position | The order to place the new order before. |
destination | The destination of the order. |
order_flags | The flags given to the order. |
AIError::ERR_OWNED_BY_ANOTHER_COMPANY | |
AIOrder::ERR_ORDER_TOO_MANY | |
AIOrder::ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION |
|
static |
Checks whether the given order is a conditional order.
vehicle_id | The vehicle to check. |
order_position | The order index to check. |
|
static |
Checks whether the current order is part of the orderlist.
vehicle_id | The vehicle to check. |
|
static |
Checks whether the given order is a goto-depot order.
vehicle_id | The vehicle to check. |
order_position | The order index to check. |
|
static |
Checks whether the given order is a goto-station order.
vehicle_id | The vehicle to check. |
order_position | The order index to check. |
|
static |
Checks whether the given order is a goto-waypoint order.
vehicle_id | The vehicle to check. |
order_position | The order index to check. |
|
static |
Checks whether the given order has a valid refit cargo.
vehicle_id | The vehicle to check. |
order_position | The order index to check. |
|
static |
Checks whether the given combination of condition and compare function is valid.
condition | The condition to check. |
compare | The compare function to check. |
|
static |
Checks whether the given order id is valid for the given vehicle.
vehicle_id | The vehicle to check the order index for. |
order_position | The order index to check. |
|
static |
Checks whether the given order is a void order.
A void order is an order that used to be a goto station, depot or waypoint order but its destination got removed. In OpenTTD these orders as shown as "(Invalid Order)" in the order list of a vehicle.
vehicle_id | The vehicle to check. |
order_position | The order index to check. |
|
static |
Move an order inside the orderlist.
vehicle_id | The vehicle to move the orders. |
order_position_move | The order to move. |
order_position_target | The target order |
AIError::ERR_OWNED_BY_ANOTHER_COMPANY |
|
static |
Removes an order from the vehicle's order list.
vehicle_id | The vehicle to remove the order from. |
order_position | The order to remove from the order list. |
AIError::ERR_OWNED_BY_ANOTHER_COMPANY |
|
static |
Resolves the given order index to the correct index for the given vehicle.
If the order index was ORDER_CURRENT it will be resolved to the index of the current order (as shown in the order list). If the order with the given index does not exist it will return ORDER_INVALID.
vehicle_id | The vehicle to check the order index for. |
order_position | The order index to resolve. |
|
static |
Sets the CompareFunction of the given order for the given vehicle.
vehicle_id | The vehicle to set the compare function for. |
order_position | The order to set the compare function for. |
compare | The new compare function of the order. |
|
static |
Sets the value to compare against of the given order for the given vehicle.
vehicle_id | The vehicle to set the value for. |
order_position | The order to set the value for. |
value | The value to compare against. |
|
static |
Sets the OrderCondition of the given order for the given vehicle.
vehicle_id | The vehicle to set the condition type for. |
order_position | The order to set the condition type for. |
condition | The condition to compare on. |
|
static |
Changes the order flags of the given order.
vehicle_id | The vehicle to change the order of. |
order_position | The order to change. |
order_flags | The new flags given to the order. |
AIError::ERR_OWNED_BY_ANOTHER_COMPANY |
|
static |
Sets the OrderPosition to jump to if the check succeeds of the given order for the given vehicle.
vehicle_id | The vehicle to set the OrderPosition for. |
order_position | The order to set the OrderPosition for. |
jump_to | The order to jump to if the check succeeds. |
|
static |
Sets the refit cargo type of the given order for the given vehicle.
vehicle_id | The vehicle to set the refit cargo for. |
order_position | The order to set the refit cargo for. |
refit_cargo | The cargo to refit to. The refit can be cleared by passing CT_NO_REFIT. |
|
static |
Sets the stoplocation of the given order for the given train.
vehicle_id | The vehicle to get the value for. |
order_position | The order to get the value for. |
stop_location | The relative position where a train will stop inside a station. |
Shares the orders between two vehicles.
The orders of the main vehicle are going to be the orders of the changed vehicle.
vehicle_id | The vehicle to add to the shared order list. |
main_vehicle_id | The vehicle to share the orders with. |
|
static |
Make a vehicle execute next_order instead of its current order.
vehicle_id | The vehicle that should skip some orders. |
next_order | The order the vehicle should skip to. |
AIError::ERR_OWNED_BY_ANOTHER_COMPANY |
|
static |
Removes the given vehicle from a shared orders list.
After unsharing orders, the orders list of the vehicle is empty.
vehicle_id | The vehicle to remove from the shared order list. |