OpenTTD AI API: Lists all changes / additions to the API.

OpenTTD AI API 15.3

Lists all changes / additions to the API.

Only new / renamed / deleted api functions will be listed here.

A list of bug fixes can be found in the normal changelog. Note that removed API functions may still be available if you return an older API version in GetAPIVersion() in info.nut.

15.0

API additions:

- AIEventVehicleCrashed::GetVictims
- AIEventVehicleCrashed::GetVehicleOwner
- AIEventCompanyRenamed
- AIEventPresidentRenamed
- AICargo::CC_OVERSIZED
- AICargo::CC_POWDERIZED
- AICargo::CC_NON_POURABLE
- AICargo::CC_POTABLE
- AICargo::CC_NON_POTABLE
- AIVehicleList_Waypoint
- AIError::ERR_BRIDGE_TOO_LOW
- AIEngine::GetAllRailTypes
- AITile::IsHouseTile

Other changes:

- AIBridge::GetBridgeID renamed to AIBridge::GetBridgeType
- AIWaypoint::GetWaypointID now returns the StationID of any type of waypoint
- AIList instances can now be saved
- AIVehicleList_Station accepts an optional AIVehicle::VehicleType parameter
- AIList instances can now be cloned
- AIEngine::GetRailType will only return the first RailType of an engine, use AIEngine::GetAllRailTypes instead

14.0

API additions:

- AITown::ROAD_LAYOUT_RANDOM
- AIVehicle::IsPrimaryVehicle
- AITileList_StationCoverage
- AIAirport::GetAirportNumHelipads

API removals:

- AIError::ERR_PRECONDITION_TOO_MANY_PARAMETERS, that error is never returned anymore.
- AIInfo::CONFIG_RANDOM, no longer used.
- AIInfo::AddSettings random_deviation is no longer used.

Other changes:

- AIGroupList accepts an optional filter function
- AIIndustryList accepts an optional filter function
- AISignList accepts an optional filter function
- AISubsidyList accepts an optional filter function
- AITownList accepts an optional filter function
- AIVehicleList accepts an optional filter function
- AIInfo::AddSettings easy_value / medium_value / hard_value are replaced with default_value

13.0

API additions:

- AICargo::GetWeight
- AIIndustryType::ResolveNewGRFID
- AIObjectType::ResolveNewGRFID

Other changes:

- AIRoad::HasRoadType now correctly checks RoadType against RoadType

12.0

API additions:

- AINewGRF
- AINewGRFList
- AIGroup::GetNumVehicles
- AIMarine::BT_LOCK
- AIMarine::BT_CANAL
- AITile::IsSeaTile
- AITile::IsRiverTile
- AITile::BT_CLEAR_WATER
- AIObjectTypeList
- AIObjectType

1.11.0

API additions:

- AICargo::GetName
- AIPriorityQueue

Other changes:

- AIVehicle::CloneVehicle now correctly returns estimate when short on cash

1.10.0

API additions:

- AIGroup::SetPrimaryColour
- AIGroup::SetSecondaryColour
- AIGroup::GetPrimaryColour
- AIGroup::GetSecondaryColour
- AIVehicle::BuildVehicleWithRefit
- AIVehicle::GetBuildWithRefitCapacity
- AIRoad::GetName
- AIRoad::RoadVehCanRunOnRoad
- AIRoad::RoadVehHasPowerOnRoad
- AIRoad::ConvertRoadType
- AIRoad::GetMaxSpeed
- AIEngine::CanRunOnRoad
- AIEngine::HasPowerOnRoad
- AIRoadTypeList::RoadTypeList
- AIEventVehicleAutoReplaced

Other changes:

- AITile::DemolishTile works without a selected company

1.9.0

API additions:

- AIAirport::GetMonthlyMaintenanceCost
- AIGroup::SetParent
- AIGroup::GetParent
- AICompany::SetPrimaryLiveryColour
- AICompany::SetSecondaryLiveryColour
- AICompany::GetPrimaryLiveryColour
- AICompany::GetSecondaryLiveryColour

Other changes:

- AIBridge::GetName takes one extra parameter to refer the vehicle type
- AIGroup::CreateGroup gains parent_group_id parameter

1.8.0

No changes

API additions:

- AIRoad::ERR_ROADTYPE_DISALLOWS_CROSSING

1.7.0 - 1.7.2

No changes

1.6.1 - 1.6.0

No changes

1.5.3 - 1.5.1

No changes

1.5.0

API additions:

- AIList::SwapList
- AIStation::GetCargoPlanned
- AIStation::GetCargoPlannedFrom
- AIStation::GetCargoPlannedFromVia
- AIStation::GetCargoPlannedVia
- AIStation::GetCargoWaitingFromVia
- AIStationList_CargoPlannedByFrom
- AIStationList_CargoPlannedByVia
- AIStationList_CargoPlannedFromByVia
- AIStationList_CargoPlannedViaByFrom
- AIStationList_CargoWaitingByFrom
- AIStationList_CargoWaitingByVia
- AIStationList_CargoWaitingFromByVia
- AIStationList_CargoWaitingViaByFrom

1.4.4 - 1.4.1 No changes

1.4.0

API additions:

- AICargo::GetDistributionType
- AIDate::DATE_INVALID
- AIDate::IsValidDate
- AIStation::HasCargoRating
- AIStation::GetCargoWaitingFrom
- AIStation::GetCargoWaitingVia
- AITile::GetTerrainType
- AITown::FoundTown
- AITown::GetFundBuildingsDuration
- AITown::TOWN_GROWTH_NONE

Other changes:

- AIStation::GetCargoRating does return -1 for cargo-station combinations that do not have a rating yet instead of returning 69.

1.3.3 - 1.3.2

No changes

1.3.1

API additions:

- AITile::GetTerrainType

1.3.0

API additions:

- AIEventExclusiveTransportRights
- AIEventRoadReconstruction
- AIIndustryType::IsProcessingIndustry
- AIStation::IsAirportClosed
- AIStation::OpenCloseAirport
- AIController::Break

1.2.3 - 1.2.1

No changes

1.2.0

API additions:

- AIAirport::GetMaintenanceCostFactor
- AICargo::CT_AUTO_REFIT
- AICargo::CT_NO_REFIT
- AICargo::IsValidTownEffect
- AICargoList_StationAccepting
- AICompany::GetQuarterlyIncome
- AICompany::GetQuarterlyExpenses
- AICompany::GetQuarterlyCargoDelivered
- AICompany::GetQuarterlyPerformanceRating
- AICompany::GetQuarterlyCompanyValue
- AIController::GetOpsTillSuspend
- AIEngine::GetMaximumOrderDistance
- AIEventAircraftDestTooFar
- AIInfo::CONFIG_DEVELOPER
- AIInfrastructure
- AIOrder::ERR_ORDER_AIRCRAFT_NOT_ENOUGH_RANGE
- AIOrder::GetOrderDistance
- AIOrder::GetOrderRefit
- AIOrder::IsRefitOrder
- AIOrder::SetOrderRefit
- AIRail::GetMaintenanceCostFactor
- AIRoad::GetMaintenanceCostFactor
- AITile::GetTownAuthority
- AITown::GetCargoGoal
- AITown::GetGrowthRate
- AITown::GetLastMonthReceived
- AITownEffectList (to walk over all available town effects)
- AIVehicle::ERR_VEHICLE_TOO_LONG in case vehicle length limit is reached
- AIVehicle::GetMaximumOrderDistance

API renames:

- AITown::GetLastMonthTransported to AITown::GetLastMonthSupplied to better reflect what it does.
- AIInfo has all its configure settings renamed from AICONFIG to just CONFIG like CONFIG_RANDOM.
- AIEvent has all its types renamed from AI_ET_ prefix to just ET_ prefix, like ET_SUBSIDY_OFFER.
- AIOrder has all its types renamed from AIOF_ prefix to just OF_ prefix.

API removals:

- AICompany::GetCompanyValue, use AICompany::GetQuarterlyCompanyValue instead.

Other changes:

- AITown::GetLastMonthProduction no longer has prerequisites based on town effects.
- AITown::GetLastMonthTransported resp. AITown::GetLastMonthSupplied no longer has prerequisites based on town effects.
- AITown::GetLastMonthTransportedPercentage no longer has prerequisites based on town effects.

1.1.5

No changes

1.1.4

API additions:

- AIVehicle::ERR_VEHICLE_TOO_LONG in case vehicle length limit is reached.

1.1.3 - 1.1.1

No changes

1.1.0

API additions:

- IsEnd for all lists.
- AIEventTownFounded
- AIIndustry::GetIndustryID
- AIIndustryType::INDUSTRYTYPE_TOWN
- AIIndustryType::INDUSTRYTYPE_UNKNOWN
- AIOrder::IsVoidOrder
- AIRail::GetName
- AITown::IsCity

API removals:

- HasNext for all lists.
- AIAbstractList, use AIList instead.
- AIList::ChangeItem, use AIList::SetValue instead.
- AIRail::ERR_NONUNIFORM_STATIONS_DISABLED, that error is never returned anymore.

Other changes:

- AIEngine::GetMaxTractiveEffort can be used for road vehicles.
- AIEngine::GetPower can be used for road vehicles.
- AIEngine::GetWeight can be used for road vehicles.
- AIIndustry::IsCargoAccepted now returns CargoAcceptState instead of a boolean.
- AIOrder::GetOrderFlags returns AIOrder::AIOF_INVALID for void orders as well.
- AIRoad::BuildDriveThroughRoadStation now allows overbuilding.
- AIRoad::BuildRoadStation now allows overbuilding.

1.0.5 - 1.0.4

No changes

1.0.3

API additions:

- AIRail::ERR_RAILTYPE_DISALLOWS_CROSSING

1.0.2

Other changes:

- AIBridge::GetPrice now returns the price of the bridge without the cost for the rail or road.

1.0.1

API additions:

- AIRail::GetMaxSpeed

1.0.0

API additions:

- AIBaseStation
- AIEngine::IsBuildable
- AIEventCompanyAskMerger
- AIIndustry::GetLastMonthTransportedPercentage
- AIInfo::AICONFIG_INGAME
- AIMarine::GetBuildCost
- AIOrder::AIOF_GOTO_NEAREST_DEPOT
- AIOrder::GetStopLocation
- AIOrder::SetStopLocation
- AIRail::RemoveRailStationTileRectangle
- AIRail::RemoveRailWaypointTileRectangle
- AIRail::GetBuildCost
- AIRoad::GetBuildCost
- AISubsidy::SubsidyParticipantType
- AISubsidy::GetSourceType
- AISubsidy::GetSourceIndex
- AISubsidy::GetDestinationType
- AISubsidy::GetDestinationIndex
- AITile::GetBuildCost
- AITown::GetLastMonthTransportedPercentage
- AIVehicleList_Depot
- AIWaypoint::WaypointType
- AIWaypoint::HasWaypointType
- Some error messages to AIWaypoint

API removals:

- AIOrder::ChangeOrder, use AIOrder::SetOrderFlags instead
- AIRail::RemoveRailStationTileRect, use AIRail::RemoveRailStationTileRectangle instead
- AIRail::RemoveRailWaypoint, use AIRail::RemoveRailWaypointTileRectangle instead
- AISign::GetMaxSignID, use AISignList instead
- AIStation::ERR_STATION_TOO_LARGE, use AIError::ERR_STATION_TOO_SPREAD_OUT instead
- AISubsidy::SourceIsTown, use AISubsidy::GetSourceType instead
- AISubsidy::GetSource, use AISubsidy::GetSourceIndex instead
- AISubsidy::DestinationIsTown, use AISubsidy::GetDestinationType instead
- AISubsidy::GetDestination, use AISubsidy::GetDestinationIndex instead
- AITile::GetHeight, use AITile::GetMinHeight/GetMaxHeight/GetCornerHeight instead
- AITown::GetMaxProduction, use AITown::GetLastMonthProduction instead
- AIVehicle::SkipToVehicleOrder, use AIOrder::SkipToOrder instead
- AIWaypoint::WAYPOINT_INVALID, use AIBaseStation::STATION_INVALID instead

Other changes:

- The GetName / SetName / GetLocation functions were moved from AIStation and AIWaypoint to AIBaseStation, but you can still use AIStation.GetName as before
- The GetConstructionDate function was moved from AIStation to AIBaseStation, but can still be used as AIStation.GetConstructionDate
- WaypointID was replaced by StationID. All WaypointIDs from previous savegames are invalid. Use STATION_INVALID instead of WAYPOINT_INVALID
- AIWaypointList constructor now needs a WaypointType similar to AIStationList, it can also handle buoys.
- AIVehicleList_Station now also works for waypoints
- Stations can be build over rail without signals that is in the right direction for the to-be built station. It will also convert the rail if the station's rail type supports the old type.
- GetAPIVersion() was added as function to info.nut. If it does not exist API version 0.7 is assumed. This function should return the major and minor number of the stable version of the API the AI is written against. For 0.7.2 that would be 0.7, for 1.1.3 it would be 1.1, etc.
- The subsidy logic has changed. Subsidy is now awarded when cargo originating from subsidy source is delivered to station that has subsidy destination it its catchment area. One industry tile or one town house is enough as long as station accepts the cargo. Awarded subsidies are no longer bound to stations used for first delivery, any station can be used for loading and unloading as long as cargo is transferred from source to destination.
- Make AIEngine:CanRefitCargo() not report refittability to mail by default for aircraft. It is not necessarily true. This means that even if the aircraft can carry mail (as secondary cargo) it does not return true if the aircraft cannot carry it as its only cargo.
- Improve behaviour of AIEngine::GetCargoType(), AIEventEnginePreview::GetCargoType() and AIEngine::CanRefitCargo() for articulated vehicles. For CanRefitCargo true is returned if at least one part can be refitted. For GetCargoType the first most used cargo type is returned.
- AIIndustryType::GetConstructionCost() now returns -1 if the industry is neither buildable nor prospectable.
- AIEngine::IsValidEngine will now return true if you have at least one vehicle of that type in your company, regardless if it's still buildable or not. AIEngine::IsBuildable returns only true when you can actually build an engine.
- AITile::GetCargoProduction will now return the number of producers, including houses instead the number of producing tiles. This means that also industries that do not have a tile within the radius, but where the search bounding box and the industry's bounding box intersect, are counted. Previously these industries (and their cargoes), although they produced cargo for a station at the given location, were not returned.
- AIRail::BuildRail will now fail completely if there is an obstacle between the begin and end, instead of building up to the obstacle and returning that everything went okay.
- Orders for buoys are now waypoint orders, i.e. instead of using the station orders for buoys one has to use waypoint orders.
- Autoreplaces can now also be set for the default group via AIGroup.

0.7.5 - 0.7.4

No changes

0.7.3

API additions:

- AIAbstractList::SORT_ASCENDING
- AIAbstractList::SORT_DESCENDING
- AIAirport::IsAirportInformationAvailable
- AICompany::GetPresidentGender
- AICompany::SetPresidentGender
- AIEngine::GetDesignDate
- AIStation::GetConstructionDate

Other changes:

- AIs are now killed when they execute a DoCommand or Sleep at a time they are not allowed to do so.
- When the API requests a string as parameter you can give every squirrel type and it will be converted to a string
- AIs can create subclasses of API classes and use API constants as part of their own constants

0.7.2

API additions:

- AIVehicle::GetReliability

Other changes:

- DoCommands and sleeps in call, acall, pcall and valuators are disallowed

0.7.1

API additions:

- AIAirport::GetPrice
- AIController::GetVersion
- AIOrder::AIOF_DEPOT_FLAGS
- AIOrder::AIOF_STOP_IN_DEPOT
- AIOrder::IsCurrentOrderPartOfOrderList
- AIOrder::IsGotoDepotOrder
- AIOrder::IsGotoStationOrder
- AIOrder::IsGotoWaypointOrder
- AISignList
- AITile::CORNER_[WSEN]
- AITile::ERR_AREA_ALREADY_FLAT
- AITile::ERR_EXCAVATION_WOULD_DAMAGE
- AITile::GetCornerHeight
- AITile::GetMaxHeight
- AITile::GetMinHeight
- AIVehicle::SendVehicleToDepotForServicing

Other changes:

- GetURL() was added as optional function to info.nut
- UseAsRandomAI() was added as optional function to info.nut
- A limit was introduced on the time the AI spends in the constructor and Load function

0.7.0

- First stable release with the NoAI framework.