diff --git a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index 1d99e8312ec..d4e278f2e26 100644 --- a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -2450,6 +2450,17 @@ bool CStaticFunctionDefinitions::SetPedOnFire(CClientEntity& Entity, bool bOnFir return false; } +bool CStaticFunctionDefinitions::SetPedArmor(CClientPed& Ped, float fArmor) +{ + if (Ped.IsLocalEntity()) + { + Ped.SetArmor(fArmor); + return true; + } + + return false; +} + bool CStaticFunctionDefinitions::SetPedOxygenLevel(CClientEntity& Entity, float fOxygen) { if (IS_PED(&Entity)) diff --git a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.h b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.h index 258706d1824..402959a6628 100644 --- a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.h +++ b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.h @@ -189,6 +189,7 @@ class CStaticFunctionDefinitions static bool RemovePedFromVehicle(CClientPed* pPed); static bool WarpPedIntoVehicle(CClientPed* pPed, CClientVehicle* pVehicle, unsigned int uiSeat); static bool SetPedOxygenLevel(CClientEntity& Entity, float fOxygen); + static bool SetPedArmor(CClientPed& Ped, float fArmor); // Extra Clothes functions static bool GetBodyPartName(unsigned char ucID, SString& strOutName); diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp index 239a0a263d2..46288ab7ba1 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp @@ -87,6 +87,7 @@ void CLuaPedDefs::LoadFunctions() {"warpPedIntoVehicle", WarpPedIntoVehicle}, {"removePedFromVehicle", RemovePedFromVehicle}, {"setPedOxygenLevel", SetPedOxygenLevel}, + {"setPedArmor", SetPedArmor}, {"givePedWeapon", GivePedWeapon}, {"isPedReloadingWeapon", IsPedReloadingWeapon}, }; @@ -167,6 +168,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM) lua_classfunction(luaVM, "setControlState", "setPedControlState"); lua_classfunction(luaVM, "warpIntoVehicle", "warpPedIntoVehicle"); lua_classfunction(luaVM, "setOxygenLevel", "setPedOxygenLevel"); + lua_classfunction(luaVM, "setArmor", "setPedArmor"); lua_classfunction(luaVM, "setWeaponSlot", "setPedWeaponSlot"); lua_classfunction(luaVM, "setDoingGangDriveby", "setPedDoingGangDriveby"); lua_classfunction(luaVM, "setFightingStyle", "setPedFightingStyle"); @@ -187,7 +189,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM) lua_classvariable(luaVM, "canBeKnockedOffBike", "setPedCanBeKnockedOffBike", "canPedBeKnockedOffBike"); lua_classvariable(luaVM, "hasJetPack", NULL, "doesPedHaveJetPack"); lua_classvariable(luaVM, "jetpack", NULL, "isPedWearingJetpack"); // introduced in 1.5.5-9.13846 - lua_classvariable(luaVM, "armor", NULL, "getPedArmor"); + lua_classvariable(luaVM, "armor", "setPedArmor", "getPedArmor"); lua_classvariable(luaVM, "fightingStyle", "setPedFightingStyle", "getPedFightingStyle"); lua_classvariable(luaVM, "cameraRotation", "setPedCameraRotation", "getPedCameraRotation"); lua_classvariable(luaVM, "contactElement", NULL, "getPedContactElement"); @@ -2138,6 +2140,23 @@ int CLuaPedDefs::SetPedMoveAnim(lua_State* luaVM) return 1; } +int CLuaPedDefs::SetPedArmor(lua_State* luaVM) +{ + CClientPed* pPed; + float fArmor; + CScriptArgReader argStream(luaVM); + argStream.ReadUserData(pPed); + argStream.ReadNumber(fArmor); + + if (argStream.HasErrors()) + { + return luaL_error(luaVM, argStream.GetFullErrorMessage()); + } + + lua_pushboolean(luaVM, CStaticFunctionDefinitions::SetPedArmor(*pPed, fArmor)); + return 1; +} + int CLuaPedDefs::SetPedOxygenLevel(lua_State* luaVM) { // Verify the argument diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h index d3c77ec7b05..78736bb152d 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h @@ -72,6 +72,7 @@ class CLuaPedDefs : public CLuaDefs LUA_DECLARE(SetPedAnimationProgress); LUA_DECLARE(SetPedAnimationSpeed); LUA_DECLARE(SetPedMoveAnim); + LUA_DECLARE(SetPedArmor); LUA_DECLARE(SetPedWeaponSlot); LUA_DECLARE(GivePedWeapon); LUA_DECLARE(IsPedReloadingWeapon);