Added support for custom VScript procedural targets

This commit is contained in:
Blixibon
2022-01-17 11:44:40 -06:00
parent 2be559d50d
commit 4fdc0624a9
5 changed files with 346 additions and 72 deletions

View File

@@ -122,6 +122,24 @@ public:
return ToHScript( gEntList.FindEntityClassNearestFacing( origin, facing, threshold, const_cast<char*>(classname) ) );
}
HSCRIPT FindByClassnameNearest2D( const char *szName, const Vector &vecSrc, float flRadius )
{
return ToHScript( gEntList.FindEntityByClassnameNearest2D( szName, vecSrc, flRadius ) );
}
//
// Custom Procedurals
//
void AddCustomProcedural( const char *pszName, HSCRIPT hFunc, bool bCanReturnMultiple )
{
gEntList.AddCustomProcedural( pszName, hFunc, bCanReturnMultiple );
}
void RemoveCustomProcedural( const char *pszName )
{
gEntList.RemoveCustomProcedural( pszName );
}
void EnableEntityListening()
{
// Start getting entity updates!
@@ -186,6 +204,10 @@ BEGIN_SCRIPTDESC_ROOT_NAMED( CScriptEntityIterator, "CEntities", SCRIPT_SINGLETO
#ifdef MAPBASE_VSCRIPT
DEFINE_SCRIPTFUNC( FindByClassnameWithinBox, "Find entities by class name within an AABB. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search" )
DEFINE_SCRIPTFUNC( FindByClassNearestFacing, "Find the nearest entity along the facing direction from the given origin within the angular threshold with the given classname." )
DEFINE_SCRIPTFUNC( FindByClassnameNearest2D, "Find entities by class name nearest to a point in 2D space." )
DEFINE_SCRIPTFUNC( AddCustomProcedural, "Adds a custom '!' target name. The first parameter is the name of the procedural (which should NOT include the '!'), the second parameter is a function which should support 5 arguments (name, startEntity, searchingEntity, activator, caller), and the third parameter is whether or not this procedural can return multiple entities. Note that these are NOT saved and must be redeclared on restore!" )
DEFINE_SCRIPTFUNC( RemoveCustomProcedural, "Removes a custom '!' target name previously defined with AddCustomProcedural." )
DEFINE_SCRIPTFUNC( EnableEntityListening, "Enables the 'OnEntity' hooks. This function must be called before using them." )
DEFINE_SCRIPTFUNC( DisableEntityListening, "Disables the 'OnEntity' hooks." )