Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6761,6 +6761,13 @@ CClientColShape* CStaticFunctionDefinitions::GetElementColShape(CClientEntity* p
return pColShape;
}

bool CStaticFunctionDefinitions::IsInsideColShape(CClientColShape* pColShape, const CVector& vecPosition, bool& inside)
{
inside = pColShape->DoHitDetection(vecPosition, 0);

return true;
}

bool CStaticFunctionDefinitions::GetWeaponNameFromID(unsigned char ucID, SString& strOutName)
{
if (ucID <= 59)
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CStaticFunctionDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ class CStaticFunctionDefinitions
static CClientColPolygon* CreateColPolygon(CResource& Resource, const CVector2D& vecPosition);
static CClientColTube* CreateColTube(CResource& Resource, const CVector& vecPosition, float fRadius, float fHeight);
static CClientColShape* GetElementColShape(CClientEntity* pEntity);
static bool IsInsideColShape(CClientColShape* pColShape, const CVector& vecPosition, bool& inside);
static void RefreshColShapeColliders(CClientColShape* pColShape);

// Weapon funcs
Expand Down
28 changes: 28 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaColShapeDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void CLuaColShapeDefs::LoadFunctions(void)
CLuaCFunctions::AddFunction("createColRectangle", CreateColRectangle);
CLuaCFunctions::AddFunction("createColPolygon", CreateColPolygon);
CLuaCFunctions::AddFunction("createColTube", CreateColTube);
CLuaCFunctions::AddFunction("isInsideColShape", IsInsideColShape);
}

void CLuaColShapeDefs::AddClass(lua_State* luaVM)
Expand All @@ -33,6 +34,7 @@ void CLuaColShapeDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "Polygon", "createColPolygon");

lua_classfunction(luaVM, "getElementsWithin", "getElementsWithinColShape");
lua_classfunction(luaVM, "isInside", "isInsideColShape");
lua_classvariable(luaVM, "elementsWithin", NULL, "getElementsWithinColShape");

lua_registerclass(luaVM, "ColShape", "Element");
Expand Down Expand Up @@ -308,3 +310,29 @@ int CLuaColShapeDefs::CreateColTube(lua_State* luaVM)
lua_pushboolean(luaVM, false);
return 1;
}

int CLuaColShapeDefs::IsInsideColShape(lua_State* luaVM)
{
// bool isInsideColShape ( colshape theColShape, float posX, float posY, float posZ )
CClientColShape* pColShape;
CVector vecPosition;

CScriptArgReader argStream(luaVM);
argStream.ReadUserData(pColShape);
argStream.ReadVector3D(vecPosition);

if (!argStream.HasErrors())
{
bool bInside = false;
if (CStaticFunctionDefinitions::IsInsideColShape(pColShape, vecPosition, bInside))
{
lua_pushboolean(luaVM, bInside);
return 1;
}
}
else
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

lua_pushboolean(luaVM, false);
return 1;
}
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaColShapeDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ class CLuaColShapeDefs : public CLuaDefs
LUA_DECLARE(CreateColRectangle);
LUA_DECLARE(CreateColPolygon);
LUA_DECLARE(CreateColTube);
LUA_DECLARE(IsInsideColShape);
};
7 changes: 7 additions & 0 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9323,6 +9323,13 @@ CColTube* CStaticFunctionDefinitions::CreateColTube(CResource* pResource, const
return pColShape;
}

bool CStaticFunctionDefinitions::IsInsideColShape(CColShape* pColShape, const CVector& vecPosition, bool& inside)
{
inside = pColShape->DoHitDetection(vecPosition);

return true;
}

// Make sure all colliders for a colshape are up to date
void CStaticFunctionDefinitions::RefreshColShapeColliders(CColShape* pColShape)
{
Expand Down
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ class CStaticFunctionDefinitions
static CColRectangle* CreateColRectangle(CResource* pResource, const CVector2D& vecPosition, const CVector2D& vecSize);
static CColPolygon* CreateColPolygon(CResource* pResource, const std::vector<CVector2D>& vecPointList);
static CColTube* CreateColTube(CResource* pResource, const CVector& vecPosition, float fRadius, float fHeight);
static bool IsInsideColShape(CColShape* pColShape, const CVector& vecPosition, bool& inside);
static void RefreshColShapeColliders(CColShape* pColShape);

// Weapon funcs
Expand Down
28 changes: 28 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaColShapeDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void CLuaColShapeDefs::LoadFunctions()
CLuaCFunctions::AddFunction("createColRectangle", CreateColRectangle);
CLuaCFunctions::AddFunction("createColPolygon", CreateColPolygon);
CLuaCFunctions::AddFunction("createColTube", CreateColTube);
CLuaCFunctions::AddFunction("isInsideColShape", IsInsideColShape);
}

void CLuaColShapeDefs::AddClass(lua_State* luaVM)
Expand All @@ -34,6 +35,7 @@ void CLuaColShapeDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "Polygon", "createColPolygon");

lua_classfunction(luaVM, "getElementsWithin", "getElementsWithinColShape");
lua_classfunction(luaVM, "isInside", "isInsideColShape");
lua_registerclass(luaVM, "ColShape", "Element");
}

Expand Down Expand Up @@ -297,3 +299,29 @@ int CLuaColShapeDefs::CreateColTube(lua_State* luaVM)
lua_pushboolean(luaVM, false);
return 1;
}

int CLuaColShapeDefs::IsInsideColShape(lua_State* luaVM)
{
// bool isInsideColShape ( colshape theColShape, float posX, float posY, float posZ )
CColShape* pColShape;
CVector vecPosition;

CScriptArgReader argStream(luaVM);
argStream.ReadUserData(pColShape);
argStream.ReadVector3D(vecPosition);

if (!argStream.HasErrors())
{
bool bInside = false;
if (CStaticFunctionDefinitions::IsInsideColShape(pColShape, vecPosition, bInside))
{
lua_pushboolean(luaVM, bInside);
return 1;
}
}
else
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

lua_pushboolean(luaVM, false);
return 1;
}
3 changes: 2 additions & 1 deletion Server/mods/deathmatch/logic/luadefs/CLuaColShapeDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ class CLuaColShapeDefs : public CLuaDefs
LUA_DECLARE(CreateColRectangle);
LUA_DECLARE(CreateColPolygon);
LUA_DECLARE(CreateColTube);
};
LUA_DECLARE(IsInsideColShape);
};