mirror of
https://github.com/celisej567/BCWSsrc.git
synced 2026-09-21 20:15:08 +03:00
Mapbase v6.0
- Fixed path_track paths saving as pointers instead of handles - Fixed player animations not falling to base class correctly - Fixed logic_externaldata creating garbage in trailing spaces - Added "SetHandModelSkin" input - Added unique colors for various types of console message, adjustable via convars - Added the ability to use map-specific weapon scripts - Added a way to display (placeholder) text entirely from Faceposer scenes - Added "autobreak" keyvalue to game_text, which automatically breaks long text into different lines - Added the ability to change a game_text's font (very limited) - Added LightToggle input to point_spotlight - Added Enable/DisableSprites on npc_manhack - Added ai_goal_police behavior from metrocops to Combine soldiers and citizens - Added func_precipitation particle rain systems from the Alien Swarm SDK - Added new func_precipitation spawnflags for controlling behavior in particle types - Added "mapbase_version" cvar which shows the version of Mapbase a mod might be running on - Fixed an oversight with NPC crouch activities which was causing npc_metropolice to stop firing in standoffs - Added toggleable patches to npc_combine AI which make soldiers less likely to stand around without shooting or rush to melee when not needed - Added key for custom logo font on env_credits scripts - Added SetSpeed and SetPushDir inputs for trigger_push - Added a bunch of I/O/KV to func_fish_pool to allow for more control over the fish - Added OnLostEnemy/Player support for npc_combine_camera - Added enhanced save/restore for the Response System, toggleable via convar - Added a convar which allows users to disable weapon autoswitching when picking up ammo - Split VScript base script into its own file - Added VScript descriptions for NPC squads and the manager class which handles them - Moved several classes, functions, etc. to the VScript library itself for future usage in other projects, like VBSP - Added VScript to VBSP with basic map file interfacing - Made some VScript documentation more clear due to deprecation of online documentation - Added VScript "hook" registration, creating a standardized system which shows up in script_help documentation - Added VScript-driven custom weapons - Added clientside VScript scopes - Added a bunch of weapon-related VScript functions - Split a bunch of cluttered VScript stuff into different files - Added VScript functions for "following" entities/bonemerging - Added VScript functions for grenades - Added a few more VScript trigger functions - Added OnDeath hook for VScript - Fixed documentation for aliased functions in VScript - Fixed $bumpmask not working on SDK_LightmappedGeneric - Made vertex blend swapping in Hammer use a constant instead of a combo (makes it easier to compile the shader, especially for $bumpmask's sake) - Fixed brush phong, etc. causing SDK_WorldVertexTransition to stop working - Added limited support for $envmapmask in the bumpmapping shader - Fixed more issues with parallax corrected cubemaps and instances - Made instance variable recursion consistent with VMFII
This commit is contained in:
37
sp/src/public/tier1/mapbase_con_groups.h
Normal file
37
sp/src/public/tier1/mapbase_con_groups.h
Normal file
@@ -0,0 +1,37 @@
|
||||
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 =================
|
||||
//
|
||||
// Purpose: See tier1/mapbase_con_groups.cpp for more information
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#ifndef CON_VERBOSE_COLORS_H
|
||||
#define CON_VERBOSE_COLORS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//static const Color CON_COLOR_DEV_VERBOSE( 192, 128, 192, 255 );
|
||||
|
||||
// General
|
||||
#define CON_GROUP_MAPBASE_MISC "Mapbase Misc."
|
||||
#define CON_GROUP_PHYSICS "Physics"
|
||||
|
||||
// Server
|
||||
#define CON_GROUP_IO_SYSTEM "I/O System"
|
||||
#define CON_GROUP_NPC_SCRIPTS "NPC Scripts"
|
||||
#define CON_GROUP_CHOREO "Choreo"
|
||||
|
||||
// VScript
|
||||
#define CON_GROUP_VSCRIPT "VScript"
|
||||
#define CON_GROUP_VSCRIPT_PRINT "VScript Print"
|
||||
|
||||
// Mapbase console group message.
|
||||
void CGMsg( int level, const char *pszGroup, PRINTF_FORMAT_STRING const tchar* pMsg, ... ) FMTFUNCTION( 2, 3 );
|
||||
|
||||
#define CGWarning CGMsg
|
||||
|
||||
#endif
|
||||
@@ -128,6 +128,13 @@ class CUtlBuffer;
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class IScriptVM;
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
class KeyValues;
|
||||
|
||||
// This has been moved up a bit for IScriptManager
|
||||
DECLARE_POINTER_HANDLE( HSCRIPT );
|
||||
#define INVALID_HSCRIPT ((HSCRIPT)-1)
|
||||
#endif
|
||||
|
||||
enum ScriptLanguage_t
|
||||
{
|
||||
@@ -145,20 +152,25 @@ class IScriptManager : public IAppSystem
|
||||
public:
|
||||
virtual IScriptVM *CreateVM( ScriptLanguage_t language = SL_DEFAULT ) = 0;
|
||||
virtual void DestroyVM( IScriptVM * ) = 0;
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
virtual HSCRIPT CreateScriptKeyValues( IScriptVM *pVM, KeyValues *pKV, bool bAllowDestruct ) = 0;
|
||||
virtual KeyValues *GetKeyValuesFromScriptKV( IScriptVM *pVM, HSCRIPT hSKV ) = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DECLARE_POINTER_HANDLE( HSCRIPT );
|
||||
#define INVALID_HSCRIPT ((HSCRIPT)-1)
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
template <typename T> T *HScriptToClass( HSCRIPT hObj )
|
||||
{
|
||||
return (hObj) ? (T*)g_pScriptVM->GetInstanceValue( hObj, GetScriptDesc( (T*)NULL ) ) : NULL;
|
||||
}
|
||||
#else
|
||||
DECLARE_POINTER_HANDLE( HSCRIPT );
|
||||
#define INVALID_HSCRIPT ((HSCRIPT)-1)
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -305,6 +317,10 @@ public:
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
struct ScriptHook_t;
|
||||
#endif
|
||||
|
||||
struct ScriptClassDesc_t
|
||||
{
|
||||
ScriptClassDesc_t() : m_pszScriptName( 0 ), m_pszClassname( 0 ), m_pszDescription( 0 ), m_pBaseDesc( 0 ), m_pfnConstruct( 0 ), m_pfnDestruct( 0 ), pHelper(NULL)
|
||||
@@ -320,6 +336,10 @@ struct ScriptClassDesc_t
|
||||
ScriptClassDesc_t * m_pBaseDesc;
|
||||
CUtlVector<ScriptFunctionBinding_t> m_FunctionBindings;
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
CUtlVector<ScriptHook_t*> m_Hooks;
|
||||
#endif
|
||||
|
||||
void *(*m_pfnConstruct)();
|
||||
void (*m_pfnDestruct)( void *);
|
||||
IScriptInstanceHelper * pHelper; // optional helper
|
||||
@@ -607,6 +627,12 @@ struct ScriptEnumDesc_t
|
||||
#define ScriptRegisterConstant( pVM, constant, description ) ScriptRegisterConstantNamed( pVM, constant, #constant, description )
|
||||
#define ScriptRegisterConstantNamed( pVM, constant, scriptName, description ) do { static ScriptConstantBinding_t binding; binding.m_pszScriptName = scriptName; binding.m_pszDescription = description; binding.m_data = constant; pVM->RegisterConstant( &binding ); } while (0)
|
||||
|
||||
// Could probably use a better name.
|
||||
// This is used for registering variants (particularly vectors) not tied to existing variables.
|
||||
// The principal difference is that m_data is initted with bCopy set to true.
|
||||
#define ScriptRegisterConstantFromTemp( pVM, constant, description ) ScriptRegisterConstantFromTempNamed( pVM, constant, #constant, description )
|
||||
#define ScriptRegisterConstantFromTempNamed( pVM, constant, scriptName, description ) do { static ScriptConstantBinding_t binding; binding.m_pszScriptName = scriptName; binding.m_pszDescription = description; binding.m_data = ScriptVariant_t( constant, true ); pVM->RegisterConstant( &binding ); } while (0)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -697,6 +723,29 @@ struct ScriptEnumDesc_t
|
||||
#define DEFINE_SCRIPT_CONSTRUCTOR() ScriptAddConstructorToClassDesc( pDesc, _className );
|
||||
#define DEFINE_SCRIPT_INSTANCE_HELPER( p ) pDesc->pHelper = (p);
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
// Use this for hooks which have no parameters
|
||||
#define DEFINE_SIMPLE_SCRIPTHOOK( hook, hookName, returnType, description ) \
|
||||
if (!hook.m_bDefined) \
|
||||
{ \
|
||||
ScriptHook_t *pHook = &hook; \
|
||||
pHook->m_desc.m_pszScriptName = hookName; pHook->m_desc.m_pszFunction = #hook; pHook->m_desc.m_ReturnType = returnType; pHook->m_desc.m_pszDescription = description; \
|
||||
pDesc->m_Hooks.AddToTail(pHook); \
|
||||
}
|
||||
|
||||
#define BEGIN_SCRIPTHOOK( hook, hookName, returnType, description ) \
|
||||
if (!hook.m_bDefined) \
|
||||
{ \
|
||||
ScriptHook_t *pHook = &hook; \
|
||||
pHook->m_desc.m_pszScriptName = hookName; pHook->m_desc.m_pszFunction = #hook; pHook->m_desc.m_ReturnType = returnType; pHook->m_desc.m_pszDescription = description;
|
||||
|
||||
#define DEFINE_SCRIPTHOOK_PARAM( paramName, type ) pHook->AddParameter( paramName, type );
|
||||
|
||||
#define END_SCRIPTHOOK() \
|
||||
pDesc->m_Hooks.AddToTail(pHook); \
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename T> ScriptClassDesc_t *GetScriptDesc(T *);
|
||||
|
||||
struct ScriptNoBase_t;
|
||||
@@ -1468,6 +1517,100 @@ typedef CScriptScopeT<> CScriptScope;
|
||||
|
||||
#define VScriptAddEnumToRoot( enumVal ) g_pScriptVM->SetValue( #enumVal, (int)enumVal )
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
//-----------------------------------------------------------------------------
|
||||
// Function bindings allow script functions to run C++ functions.
|
||||
// Hooks allow C++ functions to run script functions.
|
||||
//
|
||||
// This was previously done with raw function lookups, but Mapbase adds more and
|
||||
// it's hard to keep track of them without proper standards or documentation.
|
||||
//
|
||||
// At the moment, this simply plugs hook documentation into VScript and maintains
|
||||
// the same function lookup method on the inside, but it's intended to be open for
|
||||
// more complex hook mechanisms with proper parameters in the future.
|
||||
//
|
||||
// For example:
|
||||
//
|
||||
// if (m_hFunc)
|
||||
// {
|
||||
// g_pScriptVM->ExecuteFunction( m_Func, pArgs, m_desc.m_Parameters.Count(), pReturn, m_ScriptScope, true );
|
||||
// }
|
||||
//-----------------------------------------------------------------------------
|
||||
struct ScriptHook_t
|
||||
{
|
||||
ScriptFuncDescriptor_t m_desc;
|
||||
CUtlVector<const char*> m_pszParameterNames;
|
||||
bool m_bDefined;
|
||||
|
||||
void AddParameter( const char *pszName, ScriptDataType_t type )
|
||||
{
|
||||
int iCur = m_desc.m_Parameters.Count();
|
||||
m_desc.m_Parameters.SetGrowSize( 1 ); m_desc.m_Parameters.EnsureCapacity( iCur + 1 ); m_desc.m_Parameters.AddToTail( type );
|
||||
m_pszParameterNames.SetGrowSize( 1 ); m_pszParameterNames.EnsureCapacity( iCur + 1 ); m_pszParameterNames.AddToTail( pszName );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
// Cached for when CanRunInScope() is called before Call()
|
||||
HSCRIPT m_hFunc;
|
||||
|
||||
// Checks if there's a function of this name which would run in this scope
|
||||
HSCRIPT CanRunInScope( HSCRIPT hScope )
|
||||
{
|
||||
extern IScriptVM *g_pScriptVM;
|
||||
m_hFunc = g_pScriptVM->LookupFunction( m_desc.m_pszScriptName, hScope );
|
||||
return m_hFunc;
|
||||
}
|
||||
|
||||
// Checks if an existing func can be used
|
||||
bool CheckFuncValid( HSCRIPT hFunc )
|
||||
{
|
||||
// TODO: Better crtieria for this?
|
||||
if (hFunc)
|
||||
{
|
||||
m_hFunc = hFunc;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Call the function
|
||||
bool Call( HSCRIPT hScope, ScriptVariant_t *pReturn, ScriptVariant_t *pArgs, bool bRelease = true )
|
||||
{
|
||||
extern IScriptVM *g_pScriptVM;
|
||||
|
||||
Assert( ARRAYSIZE(pArgs) == m_desc.m_Parameters.Count() );
|
||||
|
||||
// Make sure we have a function in this scope
|
||||
if (!m_hFunc && !CanRunInScope(hScope))
|
||||
return false;
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < m_desc.m_Parameters.Count(); i++)
|
||||
{
|
||||
g_pScriptVM->SetValue( m_pszParameterNames[i], pArgs[i] );
|
||||
}
|
||||
|
||||
g_pScriptVM->ExecuteFunction( m_hFunc, NULL, 0, pReturn, hScope, true );
|
||||
|
||||
if (bRelease)
|
||||
g_pScriptVM->ReleaseFunction( m_hFunc );
|
||||
|
||||
m_hFunc = NULL;
|
||||
|
||||
for (int i = 0; i < m_desc.m_Parameters.Count(); i++)
|
||||
{
|
||||
g_pScriptVM->ClearValue( m_pszParameterNames[i] );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Script function proxy support
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user