Skip to content

Commit eb014cc

Browse files
committed
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
1 parent 3b5b3a9 commit eb014cc

File tree

125 files changed

+8090
-2799
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+8090
-2799
lines changed

README

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ Mapbase is intended to be usable by everyone, including licensed Source projects
4343
The Alien Swarm SDK was used to backport features and code from newer branches of Source into a Source 2013/Half-Life 2 environment.
4444
Mapbase also implements some of Tony Sergi's code changes from the Source 2007 SDK codebase. Both SDKs are publicly distributed by Valve and are available on Steam.
4545

46+
Some of the features backported from the Alien Swarm SDK (e.g. game instructor, particle rain) require assets from later versions of Source in order to work properly.
47+
The required assets have been backported from Alien Swarm and Left 4 Dead for the release build. They are not available in the code repository.
48+
4649
Here's a list of Mapbase's other known external code sources:
4750

48-
- https://github.com/95Navigator/insolence-2013 (Initial custom shader code and projected texture improvements)
51+
- https://github.com/95Navigator/insolence-2013 (Initial custom shader code and projected texture improvements; also used to implement ASW SDK particle precipitation code)
4952
- https://github.com/Biohazard90/g-string_2013 (Custom shadow filters, included indirectly via Insolence repo)
5053
- https://github.com/KyleGospo/City-17-Episode-One-Source (Brush phong and projected texture changes, included indirectly via Insolence repo)
5154
- https://github.com/DownFall-Team/DownFall (Multiple skybox code and fix for ent_fire delay not using floats; Also used as a guide to port certain Alien Swarm SDK changes to Source 2013,
@@ -87,11 +90,15 @@ Direct contributions:
8790
- https://github.com/mapbase-source/source-sdk-2013/pull/5 (Custom VScript implementation by ReDucTor; was placed into feature branch before being merged in a subsequent PR)
8891
- https://github.com/mapbase-source/source-sdk-2013/pull/3 ("playvideo" command playback fix from Avantate)
8992
- https://github.com/mapbase-source/source-sdk-2013/pull/21 (Various GCC/Linux fixes from z33ky)
93+
- https://github.com/mapbase-source/source-sdk-2013/pull/47 (VScript utility/consistency changes from samisalreadytaken)
94+
- https://github.com/mapbase-source/source-sdk-2013/pull/59 (New VScript functions and singletons from samisalreadytaken based on API documentation in later Source/Source 2 games)
95+
- https://github.com/mapbase-source/source-sdk-2013/pull/60 (Adjustment by RoyaleNoir to one of Saul's VDC changes)
9096
- Demo autorecord code provided by Klems
9197
- cc_emit crash fix provided by 1upD
9298
- Custom HL2 ammo crate models created by Rara (Textures created by Blixibon; This is asset-based and, aside from the SLAM crate, not reflected in the code)
9399
- Combine lock hardware on door01_left.mdl created by Kralich (This is asset-based and not reflected in the code)
94100
- npc_vehicledriver fixes provided by CrAzY
101+
- npc_combine cover behavior patches provided by iohnnyboy
95102

96103
//---------------------------------------------------------------------------------------------------------------------------------------------------
97104

sp/src/game/client/c_baseentity.cpp

Lines changed: 139 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
#ifdef MAPBASE
4444
#include "viewrender.h"
4545
#endif
46+
#ifdef MAPBASE_VSCRIPT
47+
#include "vscript_client.h"
48+
#endif
4649

4750
#include "gamestringpool.h"
4851

@@ -438,6 +441,9 @@ BEGIN_ENT_SCRIPTDESC_ROOT( C_BaseEntity, "Root class of all client-side entities
438441
DEFINE_SCRIPTFUNC_NAMED( ScriptGetUp, "GetUpVector", "Get the up vector of the entity" )
439442

440443
#ifdef MAPBASE_VSCRIPT
444+
DEFINE_SCRIPTFUNC( ValidateScriptScope, "Ensure that an entity's script scope has been created" )
445+
DEFINE_SCRIPTFUNC( GetScriptScope, "Retrieve the script-side data associated with an entity" )
446+
441447
DEFINE_SCRIPTFUNC( GetHealth, "" )
442448
DEFINE_SCRIPTFUNC( GetMaxHealth, "" )
443449

@@ -465,7 +471,7 @@ BEGIN_ENT_SCRIPTDESC_ROOT( C_BaseEntity, "Root class of all client-side entities
465471
DEFINE_SCRIPTFUNC( GetEffects, "Get effects" )
466472
DEFINE_SCRIPTFUNC( IsEffectActive, "Check if an effect is active" )
467473

468-
DEFINE_SCRIPTFUNC( entindex, "" )
474+
DEFINE_SCRIPTFUNC_NAMED( GetEntityIndex, "entindex", "" )
469475
#endif
470476
END_SCRIPTDESC();
471477

@@ -6519,6 +6525,138 @@ HSCRIPT C_BaseEntity::GetScriptInstance()
65196525
}
65206526

65216527
#ifdef MAPBASE_VSCRIPT
6528+
//-----------------------------------------------------------------------------
6529+
// Using my edict, cook up a unique VScript scope that's private to me, and
6530+
// persistent.
6531+
//-----------------------------------------------------------------------------
6532+
bool C_BaseEntity::ValidateScriptScope()
6533+
{
6534+
if (!m_ScriptScope.IsInitialized())
6535+
{
6536+
if (scriptmanager == NULL)
6537+
{
6538+
ExecuteOnce(DevMsg("Cannot execute script because scripting is disabled (-scripting)\n"));
6539+
return false;
6540+
}
6541+
6542+
if (g_pScriptVM == NULL)
6543+
{
6544+
ExecuteOnce(DevMsg(" Cannot execute script because there is no available VM\n"));
6545+
return false;
6546+
}
6547+
6548+
// Force instance creation
6549+
GetScriptInstance();
6550+
6551+
EHANDLE hThis;
6552+
hThis.Set(this);
6553+
6554+
bool bResult = m_ScriptScope.Init(STRING(m_iszScriptId));
6555+
6556+
if (!bResult)
6557+
{
6558+
DevMsg("%s couldn't create ScriptScope!\n", GetDebugName());
6559+
return false;
6560+
}
6561+
g_pScriptVM->SetValue(m_ScriptScope, "self", GetScriptInstance());
6562+
}
6563+
return true;
6564+
}
6565+
6566+
//-----------------------------------------------------------------------------
6567+
// Returns true if the function was located and called. false otherwise.
6568+
// NOTE: Assumes the function takes no parameters at the moment.
6569+
//-----------------------------------------------------------------------------
6570+
bool C_BaseEntity::CallScriptFunction( const char* pFunctionName, ScriptVariant_t* pFunctionReturn )
6571+
{
6572+
if (!ValidateScriptScope())
6573+
{
6574+
DevMsg("\n***\nFAILED to create private ScriptScope. ABORTING script\n***\n");
6575+
return false;
6576+
}
6577+
6578+
6579+
HSCRIPT hFunc = m_ScriptScope.LookupFunction(pFunctionName);
6580+
6581+
if (hFunc)
6582+
{
6583+
m_ScriptScope.Call(hFunc, pFunctionReturn);
6584+
m_ScriptScope.ReleaseFunction(hFunc);
6585+
6586+
return true;
6587+
}
6588+
6589+
return false;
6590+
}
6591+
6592+
//-----------------------------------------------------------------------------
6593+
// Gets a function handle
6594+
//-----------------------------------------------------------------------------
6595+
HSCRIPT C_BaseEntity::LookupScriptFunction( const char* pFunctionName )
6596+
{
6597+
if (!m_ScriptScope.IsInitialized())
6598+
{
6599+
return NULL;
6600+
}
6601+
6602+
return m_ScriptScope.LookupFunction(pFunctionName);
6603+
}
6604+
6605+
//-----------------------------------------------------------------------------
6606+
// Calls and releases a function handle (ASSUMES SCRIPT SCOPE AND FUNCTION ARE VALID!)
6607+
//-----------------------------------------------------------------------------
6608+
bool C_BaseEntity::CallScriptFunctionHandle( HSCRIPT hFunc, ScriptVariant_t* pFunctionReturn )
6609+
{
6610+
m_ScriptScope.Call(hFunc, pFunctionReturn);
6611+
m_ScriptScope.ReleaseFunction(hFunc);
6612+
6613+
return true;
6614+
}
6615+
6616+
//-----------------------------------------------------------------------------
6617+
// Purpose: Load, compile, and run a script file from disk.
6618+
// Input : *pScriptFile - The filename of the script file.
6619+
// bUseRootScope - If true, runs this script in the root scope, not
6620+
// in this entity's private scope.
6621+
//-----------------------------------------------------------------------------
6622+
bool C_BaseEntity::RunScriptFile( const char* pScriptFile, bool bUseRootScope )
6623+
{
6624+
if (!ValidateScriptScope())
6625+
{
6626+
DevMsg("\n***\nFAILED to create private ScriptScope. ABORTING script\n***\n");
6627+
return false;
6628+
}
6629+
6630+
if (bUseRootScope)
6631+
{
6632+
return VScriptRunScript(pScriptFile);
6633+
}
6634+
else
6635+
{
6636+
return VScriptRunScript(pScriptFile, m_ScriptScope, true);
6637+
}
6638+
}
6639+
6640+
//-----------------------------------------------------------------------------
6641+
// Purpose: Compile and execute a discrete string of script source code
6642+
// Input : *pScriptText - A string containing script code to compile and run
6643+
//-----------------------------------------------------------------------------
6644+
bool C_BaseEntity::RunScript( const char* pScriptText, const char* pDebugFilename )
6645+
{
6646+
if (!ValidateScriptScope())
6647+
{
6648+
DevMsg("\n***\nFAILED to create private ScriptScope. ABORTING script\n***\n");
6649+
return false;
6650+
}
6651+
6652+
if (m_ScriptScope.Run(pScriptText, pDebugFilename) == SCRIPT_ERROR)
6653+
{
6654+
DevWarning(" Entity %s encountered an error in RunScript()\n", GetDebugName());
6655+
}
6656+
6657+
return true;
6658+
}
6659+
65226660
//-----------------------------------------------------------------------------
65236661
//-----------------------------------------------------------------------------
65246662
HSCRIPT C_BaseEntity::ScriptGetMoveParent( void )

sp/src/game/client/c_baseentity.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,27 @@ class C_BaseEntity : public IClientEntity
261261

262262
string_t m_iClassname;
263263

264+
#ifdef MAPBASE_VSCRIPT
265+
// VSCRIPT
266+
bool ValidateScriptScope();
267+
bool CallScriptFunction( const char* pFunctionName, ScriptVariant_t* pFunctionReturn );
268+
269+
HSCRIPT GetScriptScope() { return m_ScriptScope; }
270+
271+
HSCRIPT LookupScriptFunction(const char* pFunctionName);
272+
bool CallScriptFunctionHandle(HSCRIPT hFunc, ScriptVariant_t* pFunctionReturn);
273+
274+
bool RunScriptFile( const char* pScriptFile, bool bUseRootScope = false );
275+
bool RunScript( const char* pScriptText, const char* pDebugFilename = "C_BaseEntity::RunScript" );
276+
#endif
277+
264278
HSCRIPT GetScriptInstance();
265279

266280
HSCRIPT m_hScriptInstance;
267281
string_t m_iszScriptId;
282+
#ifdef MAPBASE_VSCRIPT
283+
CScriptScope m_ScriptScope;
284+
#endif
268285

269286
// IClientUnknown overrides.
270287
public:
@@ -366,6 +383,11 @@ class C_BaseEntity : public IClientEntity
366383
bool IsMarkedForDeletion( void );
367384

368385
virtual int entindex( void ) const;
386+
387+
#ifdef MAPBASE_VSCRIPT
388+
// "I don't know why but wrapping entindex() works, while calling it directly crashes."
389+
inline int C_BaseEntity::GetEntityIndex() const { return entindex(); }
390+
#endif
369391

370392
// This works for client-only entities and returns the GetEntryIndex() of the entity's handle,
371393
// so the sound system can get an IClientEntity from it.

0 commit comments

Comments
 (0)