diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp index f38096dceea..e97a0ca1f67 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp @@ -37,7 +37,7 @@ void CLuaPedDefs::LoadFunctions() {"setElementBonePosition", ArgumentParser}, {"setElementBoneRotation", ArgumentParser}, {"setElementBoneQuaternion", ArgumentParser}, - {"setElementBoneMatrix", ArgumentParser}, + {"setElementBoneMatrix", SetElementBoneMatrix}, {"setPedRotation", SetPedRotation}, {"setPedWeaponSlot", SetPedWeaponSlot}, {"setPedCanBeKnockedOffBike", SetPedCanBeKnockedOffBike}, @@ -1072,10 +1072,43 @@ std::variant> CLuaPedDefs::Get return std::make_tuple(x, y, z, w); } -bool CLuaPedDefs::SetElementBoneMatrix(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, CMatrix boneMatrix) +int CLuaPedDefs::SetElementBoneMatrix(lua_State* const luaVM) { - CEntity* theEntity = entity->GetGameEntity(); - return theEntity ? theEntity->SetBoneMatrix(static_cast(boneId), boneMatrix) : false; + CClientEntity* entity = NULL; + std::uint32_t boneId; + CMatrix boneMatrix; + + CScriptArgReader argStream(luaVM); + argStream.ReadUserData(entity); + argStream.ReadNumber(boneId); + + if (argStream.NextIsTable()) + { + if (!ReadMatrix(luaVM, argStream.m_iIndex, boneMatrix)) + { + argStream.SetCustomError("Matrix is not 4 x 4"); + } + } + else + { + argStream.ReadMatrix(boneMatrix); + } + + if (!argStream.HasErrors()) + { + CEntity* theEntity = entity->GetGameEntity(); + + if (theEntity->SetBoneMatrix(static_cast(boneId), boneMatrix)) + { + lua_pushboolean(luaVM, true); + return 1; + } + } + else + m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage()); + + lua_pushboolean(luaVM, false); + return 0; } std::variant, 4>> CLuaPedDefs::GetElementBoneMatrix(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h index d97a484d8e1..20dbbe6faa7 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h @@ -58,8 +58,7 @@ class CLuaPedDefs : public CLuaDefs static std::variant> GetElementBoneRotation(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId); static std::variant> GetElementBoneQuaternion(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId); - static bool SetElementBoneMatrix(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, CMatrix boneMatrix); - + LUA_DECLARE(SetElementBoneMatrix); static std::variant, 4>> GetElementBoneMatrix(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId); static bool UpdateElementRpHAnim(lua_State* const luaVM, CClientEntity* entity);