diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp index c763e1d3f4a..ea92a1e5945 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp @@ -100,6 +100,7 @@ void CLuaElementDefs::LoadFunctions() {"setElementCallPropagationEnabled", SetElementCallPropagationEnabled}, {"setElementLighting", ArgumentParser}, {"setElementOnFire", ArgumentParser}, + {"isElementOnGround", ArgumentParser}, }; // Add functions @@ -171,6 +172,7 @@ void CLuaElementDefs::AddClass(lua_State* luaVM) lua_classfunction(luaVM, "getData", "getElementData"); lua_classfunction(luaVM, "getAllData", "getAllElementData"); lua_classfunction(luaVM, "isOnFire", "isElementOnFire"); + lua_classfunction(luaVM, "onGround", "isElementOnGround"); lua_classfunction(luaVM, "setAttachedOffsets", "setElementAttachedOffsets"); lua_classfunction(luaVM, "setData", "setElementData"); @@ -231,6 +233,7 @@ void CLuaElementDefs::AddClass(lua_State* luaVM) lua_classvariable(luaVM, "isElement", NULL, "isElement"); lua_classvariable(luaVM, "lighting", "setElementLighting", "getElementLighting"); lua_classvariable(luaVM, "onFire", "setElementOnFire", "isElementOnFire"); + lua_classvariable(luaVM, "onGround", NULL, "isElementOnGround"); // TODO: Support element data: player.data["age"] = 1337; <=> setElementData(player, "age", 1337) lua_registerclass(luaVM, "Element"); @@ -2660,3 +2663,19 @@ bool CLuaElementDefs::IsElementOnFire(CClientEntity* entity) noexcept { return entity->IsOnFire(); } + +bool CLuaElementDefs::IsElementOnGround(CClientEntity* entity) +{ + switch (entity->GetType()) + { + case CCLIENTPLAYER: + case CCLIENTPED: + return static_cast(entity)->IsOnGround(); + case CCLIENTVEHICLE: + return static_cast(entity)->IsOnGround(); + default: + throw std::invalid_argument{"This element type does not support IsElementOnGround"}; + } + + return false; +} diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h index 3d82ddcb145..daaf62def72 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h @@ -72,6 +72,7 @@ class CLuaElementDefs : public CLuaDefs LUA_DECLARE(IsElementCallPropagationEnabled); LUA_DECLARE(IsElementWaitingForGroundToLoad); static bool IsElementOnFire(CClientEntity* entity) noexcept; + static bool IsElementOnGround(CClientEntity* entity); // Element set funcs LUA_DECLARE(CreateElement); diff --git a/Server/mods/deathmatch/logic/CResourceChecker.Data.h b/Server/mods/deathmatch/logic/CResourceChecker.Data.h index 51d8c22258c..dd552b98082 100644 --- a/Server/mods/deathmatch/logic/CResourceChecker.Data.h +++ b/Server/mods/deathmatch/logic/CResourceChecker.Data.h @@ -138,6 +138,9 @@ namespace {false, "removeAllGameBuildings", "removeGameWorld"}, {false, "restoreAllGameBuildings", "restoreGameWorld"}, + + {false, "isPedOnGround", "isElementOnGround"}, + {false, "isVehicleOnGround", "isElementOnGround"}, }; SDeprecatedItem serverDeprecatedList[] = { @@ -244,6 +247,10 @@ namespace // Ped {false, "setPedOnFire", "setElementOnFire"}, - {false, "isPedOnFire", "isElementOnFire"} + {false, "isPedOnFire", "isElementOnFire"}, + {false, "isPedOnGround", "isElementOnGround"}, + + // Vehicle + {false, "isVehicleOnGround", "isElementOnGround"} }; } // namespace diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp b/Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp index 7d339104fb3..6ef491ae393 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp +++ b/Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp @@ -62,6 +62,7 @@ void CLuaElementDefs::LoadFunctions() {"getElementCollisionsEnabled", getElementCollisionsEnabled}, {"getLowLODElement", getLowLODElement}, {"isElementOnFire", ArgumentParser}, + {"isElementOnGround", ArgumentParser}, // Attachement {"attachElements", attachElements}, @@ -193,6 +194,7 @@ void CLuaElementDefs::AddClass(lua_State* luaVM) lua_classfunction(luaVM, "isLowLOD", "isElementLowLOD"); lua_classfunction(luaVM, "isAttached", "isElementAttached"); lua_classfunction(luaVM, "isOnFire", "isElementOnFire"); + lua_classfunction(luaVM, "onGround", "isElementOnGround"); lua_classvariable(luaVM, "id", "setElementID", "getElementID"); lua_classvariable(luaVM, "callPropagationEnabled", "setElementCallPropagationEnabled", "isElementCallPropagationEnabled"); @@ -222,6 +224,7 @@ void CLuaElementDefs::AddClass(lua_State* luaVM) lua_classvariable(luaVM, "angularVelocity", "setElementAngularVelocity", "getElementAngularVelocity", setElementTurnVelocity, OOP_getElementTurnVelocity); lua_classvariable(luaVM, "isElement", NULL, "isElement"); lua_classvariable(luaVM, "onFire", "setElementOnFire", "isElementOnFire"); + lua_classvariable(luaVM, "onGround", NULL, "isElementOnGround"); lua_registerclass(luaVM, "Element"); } @@ -2460,3 +2463,19 @@ bool CLuaElementDefs::SetElementOnFire(CElement* element, bool onFire) noexcept { return CStaticFunctionDefinitions::SetElementOnFire(element, onFire); } + +bool CLuaElementDefs::IsElementOnGround(CElement* element) +{ + switch (element->GetType()) + { + case CElement::PLAYER: + case CElement::PED: + return static_cast(element)->IsOnGround(); + case CElement::VEHICLE: + return static_cast(element)->IsOnGround(); + default: + throw std::invalid_argument{"This element type does not support IsElementOnGround"}; + } + + return false; +} diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.h b/Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.h index 89745b5a3fb..ab2bfa9a0c6 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.h +++ b/Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.h @@ -108,4 +108,5 @@ class CLuaElementDefs : public CLuaDefs LUA_DECLARE(setLowLODElement); LUA_DECLARE(setElementCallPropagationEnabled); static bool SetElementOnFire(CElement* element, bool onFire) noexcept; + static bool IsElementOnGround(CElement* element); };