From 9f5cc28e4ac3c2cb5954b8fc1711989b3f1da678 Mon Sep 17 00:00:00 2001 From: = <=> Date: Sun, 25 Aug 2024 18:46:32 +0200 Subject: [PATCH 1/9] add bone quaternion functions --- Client/game_sa/CEntitySA.cpp | 52 +++++++++++++++++++ Client/game_sa/CEntitySA.h | 2 + .../deathmatch/logic/luadefs/CLuaPedDefs.cpp | 17 ++++++ .../deathmatch/logic/luadefs/CLuaPedDefs.h | 2 + Client/sdk/game/CEntity.h | 2 + 5 files changed, 75 insertions(+) diff --git a/Client/game_sa/CEntitySA.cpp b/Client/game_sa/CEntitySA.cpp index 4466a53fe4b..ec6a4dfa715 100644 --- a/Client/game_sa/CEntitySA.cpp +++ b/Client/game_sa/CEntitySA.cpp @@ -603,6 +603,28 @@ bool CEntitySA::GetBoneRotation(eBone boneId, float& yaw, float& pitch, float& r return false; } +bool CEntitySA::GetBoneRotationQuat(eBone boneId, float& x, float& y, float& z, float& w) +{ + RpClump* clump = GetRpClump(); + if (clump) + { + // updating the bone frame orientation will also update its children + // This rotation is only applied when UpdateElementRpHAnim is called + CAnimBlendClumpDataSAInterface* clumpDataInterface = *pGame->GetClumpData(clump); + AnimBlendFrameData* frameData = clumpDataInterface->GetFrameDataByNodeId(boneId); + if (frameData) + { + RtQuat* boneOrientation = &frameData->m_pIFrame->orientation; + x = boneOrientation->imag.x; + y = boneOrientation->imag.y; + z = boneOrientation->imag.z; + w = boneOrientation->real; + return true; + } + } + return false; +} + bool CEntitySA::SetBoneRotation(eBone boneId, float yaw, float pitch, float roll) { RpClump* clump = GetRpClump(); @@ -628,6 +650,36 @@ bool CEntitySA::SetBoneRotation(eBone boneId, float yaw, float pitch, float roll return false; } +bool CEntitySA::SetBoneRotationQuat(eBone boneId, float x, float y, float z, float w) +{ + RpClump* clump = GetRpClump(); + printf("SetBoneRotationQuat: %f %f %f %f\n", x, y, z, w); + if (clump) + { + // updating the bone frame orientation will also update its children + // This rotation is only applied when UpdateElementRpHAnim is called + CAnimBlendClumpDataSAInterface* clumpDataInterface = *pGame->GetClumpData(clump); + AnimBlendFrameData* frameData = clumpDataInterface->GetFrameDataByNodeId(boneId); + printf("SetBoneRotationQuat 2: %f %f %f %f\n", x, y, z, w); + if (frameData) + { + RtQuat* boneOrientation = &frameData->m_pIFrame->orientation; + printf("SetBoneRotationQuat 3: %f %f %f %f\n", x, y, z, w); + boneOrientation->imag.x = x; + boneOrientation->imag.y = y; + boneOrientation->imag.z = z; + boneOrientation->real = w; + CEntitySAInterface* theInterface = GetInterface(); + if (theInterface) + { + theInterface->bDontUpdateHierarchy = false; + } + return true; + } + } + return false; +} + bool CEntitySA::GetBonePosition(eBone boneId, CVector& position) { RwMatrix* rwBoneMatrix = GetBoneRwMatrix(boneId); diff --git a/Client/game_sa/CEntitySA.h b/Client/game_sa/CEntitySA.h index 9de57edc0a8..548cb657f6b 100644 --- a/Client/game_sa/CEntitySA.h +++ b/Client/game_sa/CEntitySA.h @@ -324,7 +324,9 @@ class CEntitySA : public virtual CEntity bool SetBoneMatrix(eBone boneId, const CMatrix& matrix); bool GetBoneRotation(eBone boneId, float& yaw, float& pitch, float& roll); + bool GetBoneRotationQuat(eBone boneId, float& x, float& y, float& z, float& w); bool SetBoneRotation(eBone boneId, float yaw, float pitch, float roll); + bool SetBoneRotationQuat(eBone boneId, float x, float y, float z, float w); bool GetBonePosition(eBone boneId, CVector& position); bool SetBonePosition(eBone boneId, const CVector& position); diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp index 63c37110646..d00c2c915d7 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp @@ -54,8 +54,10 @@ void CLuaPedDefs::LoadFunctions() {"getPedBonePosition", GetPedBonePosition}, {"setElementBonePosition", ArgumentParser}, {"setElementBoneRotation", ArgumentParser}, + {"setElementBoneRotationQuaternion", ArgumentParser}, {"getElementBonePosition", ArgumentParser}, {"getElementBoneRotation", ArgumentParser}, + {"getElementBoneRotationQuaternion", ArgumentParser}, {"setElementBoneMatrix", ArgumentParser}, {"getElementBoneMatrix", ArgumentParser}, {"updateElementRpHAnim", ArgumentParser}, @@ -1010,6 +1012,12 @@ bool CLuaPedDefs::SetElementBoneRotation(lua_State* const luaVM, CClientPed* ent return theEntity ? theEntity->SetBoneRotation(static_cast(boneId), yaw, pitch, roll) : false; } +bool CLuaPedDefs::SetElementBoneRotationQuaternion(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId, float x, float y, float z, float w) +{ + CEntity* theEntity = entity->GetGameEntity(); + return theEntity ? theEntity->SetBoneRotationQuat(static_cast(boneId), x, y, z, w) : false; +} + std::variant> CLuaPedDefs::GetElementBonePosition(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId) { CEntity* theEntity = entity->GetGameEntity(); @@ -1028,6 +1036,15 @@ std::variant> CLuaPedDefs::GetElement return false; } +std::variant> CLuaPedDefs::GetElementBoneRotationQuaternion(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId) +{ + float x = 0.0f, y = 0.0f, z = 0.0f, w = 0.0f; + CEntity* theEntity = entity->GetGameEntity(); + if (theEntity && theEntity->GetBoneRotationQuat(static_cast(boneId), x, y, z, w)) + return std::make_tuple(x, y, z, w); + return false; +} + bool CLuaPedDefs::SetElementBoneMatrix(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId, CMatrix boneMatrix) { CEntity* theEntity = entity->GetGameEntity(); diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h index 1758011f705..9abac4dbbdb 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h @@ -52,9 +52,11 @@ class CLuaPedDefs : public CLuaDefs LUA_DECLARE(CanPedBeKnockedOffBike); static bool SetElementBonePosition(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId, CVector position); static bool SetElementBoneRotation(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId, float yaw, float pitch, float roll); + static bool SetElementBoneRotationQuaternion(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId, float x, float y, float z, float w); static std::variant> GetElementBonePosition(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId); static std::variant> GetElementBoneRotation(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId); + static std::variant> GetElementBoneRotationQuaternion(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId); static bool SetElementBoneMatrix(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId, CMatrix boneMatrix); diff --git a/Client/sdk/game/CEntity.h b/Client/sdk/game/CEntity.h index 085d92ab0e4..32b803d544a 100644 --- a/Client/sdk/game/CEntity.h +++ b/Client/sdk/game/CEntity.h @@ -112,7 +112,9 @@ class CEntity virtual bool SetBoneMatrix(eBone boneId, const CMatrix& matrix) = 0; virtual bool GetBoneRotation(eBone boneId, float& yaw, float& pitch, float& roll) = 0; + virtual bool GetBoneRotationQuat(eBone boneId, float& x, float& y, float& z, float& w) = 0; virtual bool SetBoneRotation(eBone boneId, float yaw, float pitch, float roll) = 0; + virtual bool SetBoneRotationQuat(eBone boneId, float x, float y, float z, float w) = 0; virtual bool GetBonePosition(eBone boneId, CVector& position) = 0; virtual bool SetBonePosition(eBone boneId, const CVector& position) = 0; }; From e567c14f67b012307c4ae0cce8c1744112af17ea Mon Sep 17 00:00:00 2001 From: = <=> Date: Sun, 25 Aug 2024 21:07:13 +0200 Subject: [PATCH 2/9] remove test prints --- Client/game_sa/CEntitySA.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Client/game_sa/CEntitySA.cpp b/Client/game_sa/CEntitySA.cpp index ec6a4dfa715..a55470adf6f 100644 --- a/Client/game_sa/CEntitySA.cpp +++ b/Client/game_sa/CEntitySA.cpp @@ -653,18 +653,15 @@ bool CEntitySA::SetBoneRotation(eBone boneId, float yaw, float pitch, float roll bool CEntitySA::SetBoneRotationQuat(eBone boneId, float x, float y, float z, float w) { RpClump* clump = GetRpClump(); - printf("SetBoneRotationQuat: %f %f %f %f\n", x, y, z, w); if (clump) { // updating the bone frame orientation will also update its children // This rotation is only applied when UpdateElementRpHAnim is called CAnimBlendClumpDataSAInterface* clumpDataInterface = *pGame->GetClumpData(clump); AnimBlendFrameData* frameData = clumpDataInterface->GetFrameDataByNodeId(boneId); - printf("SetBoneRotationQuat 2: %f %f %f %f\n", x, y, z, w); if (frameData) { RtQuat* boneOrientation = &frameData->m_pIFrame->orientation; - printf("SetBoneRotationQuat 3: %f %f %f %f\n", x, y, z, w); boneOrientation->imag.x = x; boneOrientation->imag.y = y; boneOrientation->imag.z = z; From 249e36f803a83a5ef70b40c910b3010b9062ae88 Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 26 Aug 2024 15:39:51 +0200 Subject: [PATCH 3/9] add lua bone id checks --- .../deathmatch/logic/luadefs/CLuaPedDefs.cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp index d00c2c915d7..f581db72db6 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp @@ -1008,12 +1008,26 @@ bool CLuaPedDefs::SetElementBonePosition(lua_State* const luaVM, CClientPed* ent bool CLuaPedDefs::SetElementBoneRotation(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId, float yaw, float pitch, float roll) { + if (boneId > BONE_RIGHTFOOT) + { + std::string error = "Invalid boneId: " + std::to_string(boneId); + m_pScriptDebugging->LogError(luaVM, error.c_str()); + return false; + } + CEntity* theEntity = entity->GetGameEntity(); return theEntity ? theEntity->SetBoneRotation(static_cast(boneId), yaw, pitch, roll) : false; } bool CLuaPedDefs::SetElementBoneRotationQuaternion(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId, float x, float y, float z, float w) { + if (boneId > BONE_RIGHTFOOT) + { + std::string error = "Invalid boneId: " + std::to_string(boneId); + m_pScriptDebugging->LogError(luaVM, error.c_str()); + return false; + } + CEntity* theEntity = entity->GetGameEntity(); return theEntity ? theEntity->SetBoneRotationQuat(static_cast(boneId), x, y, z, w) : false; } @@ -1029,6 +1043,13 @@ std::variant> CLuaPedDefs::GetElement std::variant> CLuaPedDefs::GetElementBoneRotation(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId) { + if (boneId > BONE_RIGHTFOOT) + { + std::string error = "Invalid boneId: " + std::to_string(boneId); + m_pScriptDebugging->LogError(luaVM, error.c_str()); + return false; + } + float yaw = 0.0f, pitch = 0.0f, roll = 0.0f; CEntity* theEntity = entity->GetGameEntity(); if (theEntity && theEntity->GetBoneRotation(static_cast(boneId), yaw, pitch, roll)) @@ -1038,6 +1059,13 @@ std::variant> CLuaPedDefs::GetElement std::variant> CLuaPedDefs::GetElementBoneRotationQuaternion(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId) { + if (boneId > BONE_RIGHTFOOT) + { + std::string error = "Invalid boneId: " + std::to_string(boneId); + m_pScriptDebugging->LogError(luaVM, error.c_str()); + return false; + } + float x = 0.0f, y = 0.0f, z = 0.0f, w = 0.0f; CEntity* theEntity = entity->GetGameEntity(); if (theEntity && theEntity->GetBoneRotationQuat(static_cast(boneId), x, y, z, w)) From d47910f4a398707081a73103c6de597d3546023e Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 26 Aug 2024 15:49:24 +0200 Subject: [PATCH 4/9] new error method --- .../deathmatch/logic/luadefs/CLuaPedDefs.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp index f581db72db6..6502b2eb872 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp @@ -1010,9 +1010,7 @@ bool CLuaPedDefs::SetElementBoneRotation(lua_State* const luaVM, CClientPed* ent { if (boneId > BONE_RIGHTFOOT) { - std::string error = "Invalid boneId: " + std::to_string(boneId); - m_pScriptDebugging->LogError(luaVM, error.c_str()); - return false; + throw std::invalid_argument("Invalid bone ID"); } CEntity* theEntity = entity->GetGameEntity(); @@ -1023,9 +1021,7 @@ bool CLuaPedDefs::SetElementBoneRotationQuaternion(lua_State* const luaVM, CClie { if (boneId > BONE_RIGHTFOOT) { - std::string error = "Invalid boneId: " + std::to_string(boneId); - m_pScriptDebugging->LogError(luaVM, error.c_str()); - return false; + throw std::invalid_argument("Invalid bone ID"); } CEntity* theEntity = entity->GetGameEntity(); @@ -1045,9 +1041,7 @@ std::variant> CLuaPedDefs::GetElement { if (boneId > BONE_RIGHTFOOT) { - std::string error = "Invalid boneId: " + std::to_string(boneId); - m_pScriptDebugging->LogError(luaVM, error.c_str()); - return false; + throw std::invalid_argument("Invalid bone ID"); } float yaw = 0.0f, pitch = 0.0f, roll = 0.0f; @@ -1061,9 +1055,7 @@ std::variant> CLuaPedDefs::Get { if (boneId > BONE_RIGHTFOOT) { - std::string error = "Invalid boneId: " + std::to_string(boneId); - m_pScriptDebugging->LogError(luaVM, error.c_str()); - return false; + throw std::invalid_argument("Invalid bone ID"); } float x = 0.0f, y = 0.0f, z = 0.0f, w = 0.0f; From 309e7294b0729d5c02004e1d2466d16587a1dae6 Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 26 Aug 2024 15:54:25 +0200 Subject: [PATCH 5/9] different error approach --- Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp index 6502b2eb872..f7ea1b83186 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp @@ -1010,7 +1010,7 @@ bool CLuaPedDefs::SetElementBoneRotation(lua_State* const luaVM, CClientPed* ent { if (boneId > BONE_RIGHTFOOT) { - throw std::invalid_argument("Invalid bone ID"); + throw LuaFunctionError("Invalid bone ID"); } CEntity* theEntity = entity->GetGameEntity(); @@ -1021,7 +1021,7 @@ bool CLuaPedDefs::SetElementBoneRotationQuaternion(lua_State* const luaVM, CClie { if (boneId > BONE_RIGHTFOOT) { - throw std::invalid_argument("Invalid bone ID"); + throw LuaFunctionError("Invalid bone ID"); } CEntity* theEntity = entity->GetGameEntity(); @@ -1041,7 +1041,7 @@ std::variant> CLuaPedDefs::GetElement { if (boneId > BONE_RIGHTFOOT) { - throw std::invalid_argument("Invalid bone ID"); + throw LuaFunctionError("Invalid bone ID"); } float yaw = 0.0f, pitch = 0.0f, roll = 0.0f; @@ -1055,7 +1055,7 @@ std::variant> CLuaPedDefs::Get { if (boneId > BONE_RIGHTFOOT) { - throw std::invalid_argument("Invalid bone ID"); + throw LuaFunctionError("Invalid bone ID"); } float x = 0.0f, y = 0.0f, z = 0.0f, w = 0.0f; From 2512926918c75fc1577c57d1252e6ad9acf1eaf7 Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 26 Aug 2024 16:05:58 +0200 Subject: [PATCH 6/9] use unsigned int --- .../deathmatch/logic/luadefs/CLuaPedDefs.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp index f7ea1b83186..d7b9abb8faa 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp @@ -1000,13 +1000,13 @@ int CLuaPedDefs::CanPedBeKnockedOffBike(lua_State* luaVM) return 1; } -bool CLuaPedDefs::SetElementBonePosition(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId, CVector position) +bool CLuaPedDefs::SetElementBonePosition(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, CVector position) { CEntity* theEntity = entity->GetGameEntity(); return theEntity ? theEntity->SetBonePosition(static_cast(boneId), position) : false; } -bool CLuaPedDefs::SetElementBoneRotation(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId, float yaw, float pitch, float roll) +bool CLuaPedDefs::SetElementBoneRotation(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, float yaw, float pitch, float roll) { if (boneId > BONE_RIGHTFOOT) { @@ -1017,7 +1017,7 @@ bool CLuaPedDefs::SetElementBoneRotation(lua_State* const luaVM, CClientPed* ent return theEntity ? theEntity->SetBoneRotation(static_cast(boneId), yaw, pitch, roll) : false; } -bool CLuaPedDefs::SetElementBoneRotationQuaternion(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId, float x, float y, float z, float w) +bool CLuaPedDefs::SetElementBoneRotationQuaternion(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, float x, float y, float z, float w) { if (boneId > BONE_RIGHTFOOT) { @@ -1028,7 +1028,7 @@ bool CLuaPedDefs::SetElementBoneRotationQuaternion(lua_State* const luaVM, CClie return theEntity ? theEntity->SetBoneRotationQuat(static_cast(boneId), x, y, z, w) : false; } -std::variant> CLuaPedDefs::GetElementBonePosition(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId) +std::variant> CLuaPedDefs::GetElementBonePosition(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId) { CEntity* theEntity = entity->GetGameEntity(); CVector position; @@ -1037,7 +1037,7 @@ std::variant> CLuaPedDefs::GetElement return false; } -std::variant> CLuaPedDefs::GetElementBoneRotation(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId) +std::variant> CLuaPedDefs::GetElementBoneRotation(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId) { if (boneId > BONE_RIGHTFOOT) { @@ -1051,7 +1051,7 @@ std::variant> CLuaPedDefs::GetElement return false; } -std::variant> CLuaPedDefs::GetElementBoneRotationQuaternion(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId) +std::variant> CLuaPedDefs::GetElementBoneRotationQuaternion(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId) { if (boneId > BONE_RIGHTFOOT) { @@ -1065,13 +1065,13 @@ std::variant> CLuaPedDefs::Get return false; } -bool CLuaPedDefs::SetElementBoneMatrix(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId, CMatrix boneMatrix) +bool CLuaPedDefs::SetElementBoneMatrix(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, CMatrix boneMatrix) { CEntity* theEntity = entity->GetGameEntity(); return theEntity ? theEntity->SetBoneMatrix(static_cast(boneId), boneMatrix) : false; } -std::variant, 4>> CLuaPedDefs::GetElementBoneMatrix(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId) +std::variant, 4>> CLuaPedDefs::GetElementBoneMatrix(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId) { CEntity* theEntity = entity->GetGameEntity(); if (theEntity) From 26b026056d43fef0be3021f707759070af7c8539 Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 26 Aug 2024 16:22:59 +0200 Subject: [PATCH 7/9] fix header files build fail --- .../mods/deathmatch/logic/luadefs/CLuaPedDefs.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h index 9abac4dbbdb..ef91a248c4d 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h @@ -50,17 +50,17 @@ class CLuaPedDefs : public CLuaDefs LUA_DECLARE(GetPedContactElement); LUA_DECLARE(GetPedRotation); LUA_DECLARE(CanPedBeKnockedOffBike); - static bool SetElementBonePosition(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId, CVector position); - static bool SetElementBoneRotation(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId, float yaw, float pitch, float roll); - static bool SetElementBoneRotationQuaternion(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId, float x, float y, float z, float w); - static std::variant> GetElementBonePosition(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId); + static bool SetElementBonePosition(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, CVector position); + static bool SetElementBoneRotation(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, float yaw, float pitch, float roll); + static bool SetElementBoneRotationQuaternion(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, float x, float y, float z, float w); + static std::variant> GetElementBonePosition(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId); - static std::variant> GetElementBoneRotation(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId); - static std::variant> GetElementBoneRotationQuaternion(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId); + static std::variant> GetElementBoneRotation(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId); + static std::variant> GetElementBoneRotationQuaternion(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId); - static bool SetElementBoneMatrix(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId, CMatrix boneMatrix); + static bool SetElementBoneMatrix(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, CMatrix boneMatrix); - static std::variant, 4>> GetElementBoneMatrix(lua_State* const luaVM, CClientPed* entity, std::int32_t boneId); + static std::variant, 4>> GetElementBoneMatrix(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId); static bool UpdateElementRpHAnim(lua_State* const luaVM, CClientEntity* entity); LUA_DECLARE_OOP(GetPedBonePosition); From 6d086222fa892a16d175aa7f071dfd5556169509 Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 29 Aug 2024 13:42:59 +0200 Subject: [PATCH 8/9] rename functions --- Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp | 8 ++++---- Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp index d7b9abb8faa..3dd6cff247b 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp @@ -54,10 +54,10 @@ void CLuaPedDefs::LoadFunctions() {"getPedBonePosition", GetPedBonePosition}, {"setElementBonePosition", ArgumentParser}, {"setElementBoneRotation", ArgumentParser}, - {"setElementBoneRotationQuaternion", ArgumentParser}, + {"setElementBoneQuaternion", ArgumentParser}, {"getElementBonePosition", ArgumentParser}, {"getElementBoneRotation", ArgumentParser}, - {"getElementBoneRotationQuaternion", ArgumentParser}, + {"getElementBoneQuaternion", ArgumentParser}, {"setElementBoneMatrix", ArgumentParser}, {"getElementBoneMatrix", ArgumentParser}, {"updateElementRpHAnim", ArgumentParser}, @@ -1017,7 +1017,7 @@ bool CLuaPedDefs::SetElementBoneRotation(lua_State* const luaVM, CClientPed* ent return theEntity ? theEntity->SetBoneRotation(static_cast(boneId), yaw, pitch, roll) : false; } -bool CLuaPedDefs::SetElementBoneRotationQuaternion(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, float x, float y, float z, float w) +bool CLuaPedDefs::SetElementBoneQuaternion(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, float x, float y, float z, float w) { if (boneId > BONE_RIGHTFOOT) { @@ -1051,7 +1051,7 @@ std::variant> CLuaPedDefs::GetElement return false; } -std::variant> CLuaPedDefs::GetElementBoneRotationQuaternion(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId) +std::variant> CLuaPedDefs::GetElementBoneQuaternion(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId) { if (boneId > BONE_RIGHTFOOT) { diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h index ef91a248c4d..126c463af7c 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h @@ -52,11 +52,11 @@ class CLuaPedDefs : public CLuaDefs LUA_DECLARE(CanPedBeKnockedOffBike); static bool SetElementBonePosition(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, CVector position); static bool SetElementBoneRotation(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, float yaw, float pitch, float roll); - static bool SetElementBoneRotationQuaternion(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, float x, float y, float z, float w); + static bool SetElementBoneQuaternion(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, float x, float y, float z, float w); static std::variant> GetElementBonePosition(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId); static std::variant> GetElementBoneRotation(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId); - static std::variant> GetElementBoneRotationQuaternion(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); From 71951a302c135479596b87e0d12abe13b0c2dba0 Mon Sep 17 00:00:00 2001 From: = <=> Date: Tue, 3 Sep 2024 18:14:08 +0200 Subject: [PATCH 9/9] fix the brackets --- Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp index 3dd6cff247b..6f6e4205e01 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp @@ -1009,9 +1009,7 @@ bool CLuaPedDefs::SetElementBonePosition(lua_State* const luaVM, CClientPed* ent bool CLuaPedDefs::SetElementBoneRotation(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, float yaw, float pitch, float roll) { if (boneId > BONE_RIGHTFOOT) - { throw LuaFunctionError("Invalid bone ID"); - } CEntity* theEntity = entity->GetGameEntity(); return theEntity ? theEntity->SetBoneRotation(static_cast(boneId), yaw, pitch, roll) : false; @@ -1020,9 +1018,7 @@ bool CLuaPedDefs::SetElementBoneRotation(lua_State* const luaVM, CClientPed* ent bool CLuaPedDefs::SetElementBoneQuaternion(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, float x, float y, float z, float w) { if (boneId > BONE_RIGHTFOOT) - { throw LuaFunctionError("Invalid bone ID"); - } CEntity* theEntity = entity->GetGameEntity(); return theEntity ? theEntity->SetBoneRotationQuat(static_cast(boneId), x, y, z, w) : false; @@ -1040,9 +1036,7 @@ std::variant> CLuaPedDefs::GetElement std::variant> CLuaPedDefs::GetElementBoneRotation(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId) { if (boneId > BONE_RIGHTFOOT) - { throw LuaFunctionError("Invalid bone ID"); - } float yaw = 0.0f, pitch = 0.0f, roll = 0.0f; CEntity* theEntity = entity->GetGameEntity(); @@ -1054,9 +1048,7 @@ std::variant> CLuaPedDefs::GetElement std::variant> CLuaPedDefs::GetElementBoneQuaternion(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId) { if (boneId > BONE_RIGHTFOOT) - { throw LuaFunctionError("Invalid bone ID"); - } float x = 0.0f, y = 0.0f, z = 0.0f, w = 0.0f; CEntity* theEntity = entity->GetGameEntity();