summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ai/api/ai_vehicle.cpp8
-rw-r--r--src/ai/api/ai_vehicle.hpp8
-rw-r--r--src/ai/api/ai_vehicle.hpp.sq1
3 files changed, 17 insertions, 0 deletions
diff --git a/src/ai/api/ai_vehicle.cpp b/src/ai/api/ai_vehicle.cpp
index f86eed7fd..b073c9612 100644
--- a/src/ai/api/ai_vehicle.cpp
+++ b/src/ai/api/ai_vehicle.cpp
@@ -425,3 +425,11 @@
Vehicle *v = ::Vehicle::Get(vehicle_id);
return v->orders.list != NULL && v->orders.list->GetNumVehicles() > 1;
}
+
+/* static */ int AIVehicle::GetReliability(VehicleID vehicle_id)
+{
+ if (!IsValidVehicle(vehicle_id)) return -1;
+
+ const Vehicle *v = ::Vehicle::Get(vehicle_id);
+ return v->reliability * 100 >> 16;
+}
diff --git a/src/ai/api/ai_vehicle.hpp b/src/ai/api/ai_vehicle.hpp
index a93cb8026..8d7442104 100644
--- a/src/ai/api/ai_vehicle.hpp
+++ b/src/ai/api/ai_vehicle.hpp
@@ -525,6 +525,14 @@ public:
*/
static bool HasSharedOrders(VehicleID vehicle_id);
+ /**
+ * Get the current reliability of a vehicle.
+ * @param vehicle_id The vehicle to check.
+ * @pre IsValidVehicle(vehicle_id).
+ * @return The current reliability (0-100%).
+ */
+ static int GetReliability(VehicleID vehicle_id);
+
private:
/**
* Internal function used by SellWagon(Chain).
diff --git a/src/ai/api/ai_vehicle.hpp.sq b/src/ai/api/ai_vehicle.hpp.sq
index 3f01d25d8..7d56cb7a4 100644
--- a/src/ai/api/ai_vehicle.hpp.sq
+++ b/src/ai/api/ai_vehicle.hpp.sq
@@ -142,6 +142,7 @@ void SQAIVehicle_Register(Squirrel *engine) {
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetGroupID, "GetGroupID", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::IsArticulated, "IsArticulated", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::HasSharedOrders, "HasSharedOrders", 2, ".i");
+ SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetReliability, "GetReliability", 2, ".i");
SQAIVehicle.PostRegister(engine);
}