Skip to content

Commit

Permalink
Mapbase v6.0
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Blixibon committed Nov 26, 2020
1 parent 3b5b3a9 commit eb014cc
Show file tree
Hide file tree
Showing 125 changed files with 8,090 additions and 2,799 deletions.
9 changes: 8 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ Mapbase is intended to be usable by everyone, including licensed Source projects
The Alien Swarm SDK was used to backport features and code from newer branches of Source into a Source 2013/Half-Life 2 environment.
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.

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.
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.

Here's a list of Mapbase's other known external code sources:

- https://github.com/95Navigator/insolence-2013 (Initial custom shader code and projected texture improvements)
- https://github.com/95Navigator/insolence-2013 (Initial custom shader code and projected texture improvements; also used to implement ASW SDK particle precipitation code)
- https://github.com/Biohazard90/g-string_2013 (Custom shadow filters, included indirectly via Insolence repo)
- https://github.com/KyleGospo/City-17-Episode-One-Source (Brush phong and projected texture changes, included indirectly via Insolence repo)
- 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,
Expand Down Expand Up @@ -87,11 +90,15 @@ Direct contributions:
- 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)
- https://github.com/mapbase-source/source-sdk-2013/pull/3 ("playvideo" command playback fix from Avantate)
- https://github.com/mapbase-source/source-sdk-2013/pull/21 (Various GCC/Linux fixes from z33ky)
- https://github.com/mapbase-source/source-sdk-2013/pull/47 (VScript utility/consistency changes from samisalreadytaken)
- 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)
- https://github.com/mapbase-source/source-sdk-2013/pull/60 (Adjustment by RoyaleNoir to one of Saul's VDC changes)
- Demo autorecord code provided by Klems
- cc_emit crash fix provided by 1upD
- 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)
- Combine lock hardware on door01_left.mdl created by Kralich (This is asset-based and not reflected in the code)
- npc_vehicledriver fixes provided by CrAzY
- npc_combine cover behavior patches provided by iohnnyboy

//---------------------------------------------------------------------------------------------------------------------------------------------------

Expand Down
140 changes: 139 additions & 1 deletion sp/src/game/client/c_baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
#ifdef MAPBASE
#include "viewrender.h"
#endif
#ifdef MAPBASE_VSCRIPT
#include "vscript_client.h"
#endif

#include "gamestringpool.h"

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

#ifdef MAPBASE_VSCRIPT
DEFINE_SCRIPTFUNC( ValidateScriptScope, "Ensure that an entity's script scope has been created" )
DEFINE_SCRIPTFUNC( GetScriptScope, "Retrieve the script-side data associated with an entity" )

DEFINE_SCRIPTFUNC( GetHealth, "" )
DEFINE_SCRIPTFUNC( GetMaxHealth, "" )

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

DEFINE_SCRIPTFUNC( entindex, "" )
DEFINE_SCRIPTFUNC_NAMED( GetEntityIndex, "entindex", "" )
#endif
END_SCRIPTDESC();

Expand Down Expand Up @@ -6519,6 +6525,138 @@ HSCRIPT C_BaseEntity::GetScriptInstance()
}

#ifdef MAPBASE_VSCRIPT
//-----------------------------------------------------------------------------
// Using my edict, cook up a unique VScript scope that's private to me, and
// persistent.
//-----------------------------------------------------------------------------
bool C_BaseEntity::ValidateScriptScope()
{
if (!m_ScriptScope.IsInitialized())
{
if (scriptmanager == NULL)
{
ExecuteOnce(DevMsg("Cannot execute script because scripting is disabled (-scripting)\n"));
return false;
}

if (g_pScriptVM == NULL)
{
ExecuteOnce(DevMsg(" Cannot execute script because there is no available VM\n"));
return false;
}

// Force instance creation
GetScriptInstance();

EHANDLE hThis;
hThis.Set(this);

bool bResult = m_ScriptScope.Init(STRING(m_iszScriptId));

if (!bResult)
{
DevMsg("%s couldn't create ScriptScope!\n", GetDebugName());
return false;
}
g_pScriptVM->SetValue(m_ScriptScope, "self", GetScriptInstance());
}
return true;
}

//-----------------------------------------------------------------------------
// Returns true if the function was located and called. false otherwise.
// NOTE: Assumes the function takes no parameters at the moment.
//-----------------------------------------------------------------------------
bool C_BaseEntity::CallScriptFunction( const char* pFunctionName, ScriptVariant_t* pFunctionReturn )
{
if (!ValidateScriptScope())
{
DevMsg("\n***\nFAILED to create private ScriptScope. ABORTING script\n***\n");
return false;
}


HSCRIPT hFunc = m_ScriptScope.LookupFunction(pFunctionName);

if (hFunc)
{
m_ScriptScope.Call(hFunc, pFunctionReturn);
m_ScriptScope.ReleaseFunction(hFunc);

return true;
}

return false;
}

//-----------------------------------------------------------------------------
// Gets a function handle
//-----------------------------------------------------------------------------
HSCRIPT C_BaseEntity::LookupScriptFunction( const char* pFunctionName )
{
if (!m_ScriptScope.IsInitialized())
{
return NULL;
}

return m_ScriptScope.LookupFunction(pFunctionName);
}

//-----------------------------------------------------------------------------
// Calls and releases a function handle (ASSUMES SCRIPT SCOPE AND FUNCTION ARE VALID!)
//-----------------------------------------------------------------------------
bool C_BaseEntity::CallScriptFunctionHandle( HSCRIPT hFunc, ScriptVariant_t* pFunctionReturn )
{
m_ScriptScope.Call(hFunc, pFunctionReturn);
m_ScriptScope.ReleaseFunction(hFunc);

return true;
}

//-----------------------------------------------------------------------------
// Purpose: Load, compile, and run a script file from disk.
// Input : *pScriptFile - The filename of the script file.
// bUseRootScope - If true, runs this script in the root scope, not
// in this entity's private scope.
//-----------------------------------------------------------------------------
bool C_BaseEntity::RunScriptFile( const char* pScriptFile, bool bUseRootScope )
{
if (!ValidateScriptScope())
{
DevMsg("\n***\nFAILED to create private ScriptScope. ABORTING script\n***\n");
return false;
}

if (bUseRootScope)
{
return VScriptRunScript(pScriptFile);
}
else
{
return VScriptRunScript(pScriptFile, m_ScriptScope, true);
}
}

//-----------------------------------------------------------------------------
// Purpose: Compile and execute a discrete string of script source code
// Input : *pScriptText - A string containing script code to compile and run
//-----------------------------------------------------------------------------
bool C_BaseEntity::RunScript( const char* pScriptText, const char* pDebugFilename )
{
if (!ValidateScriptScope())
{
DevMsg("\n***\nFAILED to create private ScriptScope. ABORTING script\n***\n");
return false;
}

if (m_ScriptScope.Run(pScriptText, pDebugFilename) == SCRIPT_ERROR)
{
DevWarning(" Entity %s encountered an error in RunScript()\n", GetDebugName());
}

return true;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
HSCRIPT C_BaseEntity::ScriptGetMoveParent( void )
Expand Down
22 changes: 22 additions & 0 deletions sp/src/game/client/c_baseentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,27 @@ class C_BaseEntity : public IClientEntity

string_t m_iClassname;

#ifdef MAPBASE_VSCRIPT
// VSCRIPT
bool ValidateScriptScope();
bool CallScriptFunction( const char* pFunctionName, ScriptVariant_t* pFunctionReturn );

HSCRIPT GetScriptScope() { return m_ScriptScope; }

HSCRIPT LookupScriptFunction(const char* pFunctionName);
bool CallScriptFunctionHandle(HSCRIPT hFunc, ScriptVariant_t* pFunctionReturn);

bool RunScriptFile( const char* pScriptFile, bool bUseRootScope = false );
bool RunScript( const char* pScriptText, const char* pDebugFilename = "C_BaseEntity::RunScript" );
#endif

HSCRIPT GetScriptInstance();

HSCRIPT m_hScriptInstance;
string_t m_iszScriptId;
#ifdef MAPBASE_VSCRIPT
CScriptScope m_ScriptScope;
#endif

// IClientUnknown overrides.
public:
Expand Down Expand Up @@ -366,6 +383,11 @@ class C_BaseEntity : public IClientEntity
bool IsMarkedForDeletion( void );

virtual int entindex( void ) const;

#ifdef MAPBASE_VSCRIPT
// "I don't know why but wrapping entindex() works, while calling it directly crashes."
inline int C_BaseEntity::GetEntityIndex() const { return entindex(); }
#endif

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

0 comments on commit eb014cc

Please sign in to comment.