@@ -54,8 +54,10 @@ void CLuaPedDefs::LoadFunctions()
5454 {" getPedBonePosition" , GetPedBonePosition},
5555 {" setElementBonePosition" , ArgumentParser<SetElementBonePosition>},
5656 {" setElementBoneRotation" , ArgumentParser<SetElementBoneRotation>},
57+ {" setElementBoneQuaternion" , ArgumentParser<SetElementBoneQuaternion>},
5758 {" getElementBonePosition" , ArgumentParser<GetElementBonePosition>},
5859 {" getElementBoneRotation" , ArgumentParser<GetElementBoneRotation>},
60+ {" getElementBoneQuaternion" , ArgumentParser<GetElementBoneQuaternion>},
5961 {" setElementBoneMatrix" , ArgumentParser<SetElementBoneMatrix>},
6062 {" getElementBoneMatrix" , ArgumentParser<GetElementBoneMatrix>},
6163 {" updateElementRpHAnim" , ArgumentParser<UpdateElementRpHAnim>},
@@ -998,19 +1000,31 @@ int CLuaPedDefs::CanPedBeKnockedOffBike(lua_State* luaVM)
9981000 return 1 ;
9991001}
10001002
1001- bool CLuaPedDefs::SetElementBonePosition (lua_State* const luaVM, CClientPed* entity, std::int32_t boneId, CVector position)
1003+ bool CLuaPedDefs::SetElementBonePosition (lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, CVector position)
10021004{
10031005 CEntity* theEntity = entity->GetGameEntity ();
10041006 return theEntity ? theEntity->SetBonePosition (static_cast <eBone>(boneId), position) : false ;
10051007}
10061008
1007- bool CLuaPedDefs::SetElementBoneRotation (lua_State* const luaVM, CClientPed* entity, std::int32_t boneId, float yaw, float pitch, float roll)
1009+ bool CLuaPedDefs::SetElementBoneRotation (lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, float yaw, float pitch, float roll)
10081010{
1011+ if (boneId > BONE_RIGHTFOOT)
1012+ throw LuaFunctionError (" Invalid bone ID" );
1013+
10091014 CEntity* theEntity = entity->GetGameEntity ();
10101015 return theEntity ? theEntity->SetBoneRotation (static_cast <eBone>(boneId), yaw, pitch, roll) : false ;
10111016}
10121017
1013- std::variant<bool , CLuaMultiReturn<float , float , float >> CLuaPedDefs::GetElementBonePosition (lua_State* const luaVM, CClientPed* entity, std::int32_t boneId)
1018+ bool CLuaPedDefs::SetElementBoneQuaternion (lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, float x, float y, float z, float w)
1019+ {
1020+ if (boneId > BONE_RIGHTFOOT)
1021+ throw LuaFunctionError (" Invalid bone ID" );
1022+
1023+ CEntity* theEntity = entity->GetGameEntity ();
1024+ return theEntity ? theEntity->SetBoneRotationQuat (static_cast <eBone>(boneId), x, y, z, w) : false ;
1025+ }
1026+
1027+ std::variant<bool , CLuaMultiReturn<float , float , float >> CLuaPedDefs::GetElementBonePosition (lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId)
10141028{
10151029 CEntity* theEntity = entity->GetGameEntity ();
10161030 CVector position;
@@ -1019,22 +1033,37 @@ std::variant<bool, CLuaMultiReturn<float, float, float>> CLuaPedDefs::GetElement
10191033 return false ;
10201034}
10211035
1022- std::variant<bool , CLuaMultiReturn<float , float , float >> CLuaPedDefs::GetElementBoneRotation (lua_State* const luaVM, CClientPed* entity, std::int32_t boneId)
1036+ std::variant<bool , CLuaMultiReturn<float , float , float >> CLuaPedDefs::GetElementBoneRotation (lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId)
10231037{
1038+ if (boneId > BONE_RIGHTFOOT)
1039+ throw LuaFunctionError (" Invalid bone ID" );
1040+
10241041 float yaw = 0 .0f , pitch = 0 .0f , roll = 0 .0f ;
10251042 CEntity* theEntity = entity->GetGameEntity ();
10261043 if (theEntity && theEntity->GetBoneRotation (static_cast <eBone>(boneId), yaw, pitch, roll))
10271044 return std::make_tuple (yaw, pitch, roll);
10281045 return false ;
10291046}
10301047
1031- bool CLuaPedDefs::SetElementBoneMatrix (lua_State* const luaVM, CClientPed* entity, std::int32_t boneId, CMatrix boneMatrix)
1048+ std::variant<bool , CLuaMultiReturn<float , float , float , float >> CLuaPedDefs::GetElementBoneQuaternion (lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId)
1049+ {
1050+ if (boneId > BONE_RIGHTFOOT)
1051+ throw LuaFunctionError (" Invalid bone ID" );
1052+
1053+ float x = 0 .0f , y = 0 .0f , z = 0 .0f , w = 0 .0f ;
1054+ CEntity* theEntity = entity->GetGameEntity ();
1055+ if (theEntity && theEntity->GetBoneRotationQuat (static_cast <eBone>(boneId), x, y, z, w))
1056+ return std::make_tuple (x, y, z, w);
1057+ return false ;
1058+ }
1059+
1060+ bool CLuaPedDefs::SetElementBoneMatrix (lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, CMatrix boneMatrix)
10321061{
10331062 CEntity* theEntity = entity->GetGameEntity ();
10341063 return theEntity ? theEntity->SetBoneMatrix (static_cast <eBone>(boneId), boneMatrix) : false ;
10351064}
10361065
1037- std::variant<bool , std::array<std::array<float , 4 >, 4 >> CLuaPedDefs::GetElementBoneMatrix (lua_State* const luaVM, CClientPed* entity, std::int32_t boneId)
1066+ std::variant<bool , std::array<std::array<float , 4 >, 4 >> CLuaPedDefs::GetElementBoneMatrix (lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId)
10381067{
10391068 CEntity* theEntity = entity->GetGameEntity ();
10401069 if (theEntity)
0 commit comments