Mapbase VScript server/client expansions

This commit is contained in:
Blixibon
2020-05-22 20:26:31 -05:00
parent 2dbaa2c4a6
commit 4320ae71e7
44 changed files with 2252 additions and 3 deletions

View File

@@ -0,0 +1,68 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: VScript functions for Half-Life 2.
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "hl2_gamerules.h"
#ifndef CLIENT_DLL
#include "eventqueue.h"
#endif
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
#ifndef CLIENT_DLL
extern CBaseEntity *CreatePlayerLoadSave( Vector vOrigin, float flDuration, float flHoldTime, float flLoadTime );
HSCRIPT ScriptGameOver( const char *pszMessage, float flDelay, float flFadeTime, float flLoadTime, int r, int g, int b )
{
CBaseEntity *pPlayer = AI_GetSinglePlayer();
if (pPlayer)
{
UTIL_ShowMessage( pszMessage, ToBasePlayer( pPlayer ) );
ToBasePlayer( pPlayer )->NotifySinglePlayerGameEnding();
}
else
{
// TODO: How should MP handle this?
return NULL;
}
CBaseEntity *pReload = CreatePlayerLoadSave( vec3_origin, flFadeTime, flLoadTime + 1.0f, flLoadTime );
if (pReload)
{
pReload->SetRenderColor( r, g, b, 255 );
g_EventQueue.AddEvent( pReload, "Reload", flDelay, pReload, pReload );
}
return ToHScript( pReload );
}
bool ScriptMegaPhyscannonActive()
{
return HL2GameRules()->MegaPhyscannonActive();
}
#endif
//-----------------------------------------------------------------------------
// Purpose: Returns how much damage the given ammo type should do to the victim
// when fired by the attacker.
// Input : pAttacker - Dude what shot the gun.
// pVictim - Dude what done got shot.
// nAmmoType - What been shot out.
// Output : How much hurt to put on dude what done got shot (pVictim).
//-----------------------------------------------------------------------------
void CHalfLife2::RegisterScriptFunctions( void )
{
BaseClass::RegisterScriptFunctions();
#ifndef CLIENT_DLL
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptGameOver, "GameOver", "Ends the game and reloads the last save." );
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptMegaPhyscannonActive, "MegaPhyscannonActive", "Checks if supercharged gravity gun mode is enabled." );
#endif
}