From c22e37622d71582d258a014fa9df6498bf769ac3 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Mon, 15 Mar 2021 07:01:26 +0200 Subject: [PATCH] Flatten tyres utility. --- module/Entity/Vehicle.cpp | 24 ++++++++++++++++++++++++ module/Entity/Vehicle.hpp | 5 +++++ 2 files changed, 29 insertions(+) diff --git a/module/Entity/Vehicle.cpp b/module/Entity/Vehicle.cpp index 49bca0a9..69fe1f48 100644 --- a/module/Entity/Vehicle.cpp +++ b/module/Entity/Vehicle.cpp @@ -342,6 +342,28 @@ void CVehicle::Explode() const _Func->ExplodeVehicle(m_ID); } +// ------------------------------------------------------------------------------------------------ +void CVehicle::FlattenTyres(bool toggle) const +{ + // Validate the managed identifier + Validate(); + // Perform the requested operation + if(toggle) + { + _Func->SetVehicleTyreStatus(m_ID, 0, 0); + _Func->SetVehicleTyreStatus(m_ID, 1, 0); + _Func->SetVehicleTyreStatus(m_ID, 2, 0); + _Func->SetVehicleTyreStatus(m_ID, 3, 0); + } + else + { + _Func->SetVehicleTyreStatus(m_ID, 0, 1); + _Func->SetVehicleTyreStatus(m_ID, 1, 1); + _Func->SetVehicleTyreStatus(m_ID, 2, 1); + _Func->SetVehicleTyreStatus(m_ID, 3, 1); + } +} + // ------------------------------------------------------------------------------------------------ bool CVehicle::IsWrecked() const { @@ -807,6 +829,7 @@ void CVehicle::Fix() const // Perform the requested operation _Func->SetVehicleHealth(m_ID, 1000); _Func->SetVehicleDamageData(m_ID, 0); + _Func->SetVehicleLightsData(m_ID, _Func->GetVehicleLightsData(m_ID) & 0xFFFFFF00); } // ------------------------------------------------------------------------------------------------ @@ -2101,6 +2124,7 @@ void Register_CVehicle(HSQUIRRELVM vm) .Func(_SC("HasOccupant"), &CVehicle::HasOccupant) .Func(_SC("Respawn"), &CVehicle::Respawn) .Func(_SC("Explode"), &CVehicle::Explode) + .Func(_SC("FlattenTyres"), &CVehicle::FlattenTyres) .Func(_SC("SetRot"), &CVehicle::SetRotationEx) .Func(_SC("SetRotation"), &CVehicle::SetRotationEx) .Func(_SC("SetEulerRot"), &CVehicle::SetRotationEulerEx) diff --git a/module/Entity/Vehicle.hpp b/module/Entity/Vehicle.hpp index 053aafa6..f9ef11c2 100644 --- a/module/Entity/Vehicle.hpp +++ b/module/Entity/Vehicle.hpp @@ -262,6 +262,11 @@ public: */ void Explode() const; + /* -------------------------------------------------------------------------------------------- + * Flatten the tyres of the managed vehicle entity. + */ + void FlattenTyres(bool toggle) const; + /* -------------------------------------------------------------------------------------------- * See whether the managed vehicle entity is wrecked. */