Skip to content

Commit 0d91bb7

Browse files
committed
TraceLineParams vscript function
i just want to use a custom mask and collision group...
1 parent fae989c commit 0d91bb7

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/game/server/vscript_server.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,22 @@ static float ScriptTraceLine( const Vector &vecStart, const Vector &vecEnd, HSCR
11431143
}
11441144
}
11451145

1146+
static float ScriptTraceLineParams( const Vector &vecStart, const Vector &vecEnd, HSCRIPT entIgnore, int nMask, int nCollisiongroup )
1147+
{
1148+
// UTIL_TraceLine( vecAbsStart, vecAbsEnd, MASK_BLOCKLOS, pLooker, COLLISION_GROUP_NONE, ptr );
1149+
trace_t tr;
1150+
CBaseEntity *pLooker = ToEnt(entIgnore);
1151+
UTIL_TraceLine( vecStart, vecEnd, ( unsigned int )nMask, pLooker, nCollisiongroup, &tr );
1152+
if (tr.fractionleftsolid && tr.startsolid)
1153+
{
1154+
return 1.0 - tr.fractionleftsolid;
1155+
}
1156+
else
1157+
{
1158+
return tr.fraction;
1159+
}
1160+
}
1161+
11461162
static void ScriptTraceLineTable( HSCRIPT hTable )
11471163
{
11481164
if ( !hTable )
@@ -1720,6 +1736,7 @@ bool VScriptServerInit()
17201736
ScriptRegisterFunction( g_pScriptVM, SendToServerConsole, "Send a string to the server console as a command" );
17211737
ScriptRegisterFunction( g_pScriptVM, GetMapName, "Get the name of the map.");
17221738
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptTraceLine, "TraceLine", "given 2 points & ent to ignore, return fraction along line that hits world or models" );
1739+
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptTraceLineParams, "TraceLineParams", "given 2 points, ent to ignore, mask and collision group, return fraction along line that hits world or models" );
17231740
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptTraceLineTable, "TraceLineTable", "Uses a configuration table to do a raytrace, puts return information into the table for return usage." );
17241741

17251742
ScriptRegisterFunction( g_pScriptVM, Time, "Get the current server time" );

0 commit comments

Comments
 (0)