Mapbase v5.0

- Added keyvalue to hl2_gamerules which allows respawning in singleplayer
- Added the game instructor system (including env_instructor_hint) from later Valve games using a VDC tutorial which adjusts the version from the Alien Swarm SDK to FPS rules and a Source 2013 environment; Also added new KV and icons for further control from mappers (tutorial mentioned by Maestra Fenix)
- Added L4D/TF2 glows + point_glow entity as an all-purpose SDK-based off-shoot of tf_glow
- Fixed weapon pickup sound not playing (reported by Sl0th and later Cvoxulary)
- Fixed env_projectedtextures not updating on save/load
- Added func_fake_worldportal, a spatial point_camera inspired by linked_portal_door based on SDK code alone (WIP, may be changed a lot in future updates)
- Added option for point_camera and func_reflective_glass to use different render targets, therefore allowing multiple cameras and mirrors to be active at the same time
- Added additional RT camera textures to choose from with a default of 3, but also controllable through a -numcameratextures command line param
- Added adjustable convars for main view NearZ and skybox NearZ (suggested by someone recently, also suggested by Klems over a year ago)
- Fixed map-specific localization files, cleaned up map-specific file code
- Added a new block to gameinfo.txt which allows mods to automatically append their own command line parameters
- Fixed math_lightpattern corruption when setting pattern/style while active
- Fixed the "Touch" input crashing when given no entity
- Added a way to add EFlags via keyvalue (suggested by Niker107)
- Fixed ai_script_conditions not working without a NPC actor (reported by MetroHam)
- Fixed point_radiation_source causing huge problems when intensity is 0, even though it was already advised against (reported by beefbacon)
- Added "Mapbase" header to Mapbase-specific code files
- Fixed an issue with updating sky_camera not obtaining area correctly, causing some entities to not draw in the skybox
- Added "CopyFogController" and "CopyFogControllerWithScale" inputs to sky_camera, which copy fog parameters directly from a fog controller
- Added "SetScale" input to sky_camera for live scale changing
- Added convar to control player crouch speed multiplier (suggested by ArtyIF)
- Added a ton of fixes for people running the Debug configuration of the codebase (partial credit to stepa2)
- Added support for pre-defined enums and constants in VScript, starting with various values from the SDK code (damage types, trace masks, etc.)
- Added limited support for Valve's Quaternion class in VScript
- Added new instance helper capabilities, destructible game instances, and other misc. changes to VScript library
- Replaced most of the VScript "accessor" classes with direct references to the original classes, as they were getting complicated fast and adding new VScript-only functions to the original classes might not be as bad as previously thought
- Added base NPC hooks for AI sensing in VScript (allows control over sight and hearing), also exposed CSound for it
- Added various functions and hooks for VPhysics integration in VScript
- Added VScript-based custom suit devices
- Expanded trace info exposed to VScript to allow plane and surface access (suggested by krassell)
- Added ability to insert localization strings through VScript
- Added various misc. VScript functions with various purposes, including reading/writing EFlags, movetypes, collision groups, etc.
- Fixed VBSP not being able to correctly parse parallax corrected cubemaps in maps with instances
This commit is contained in:
Blixibon 2020-08-14 21:21:25 +00:00
parent f9ba141a31
commit c448f194ae
124 changed files with 12659 additions and 410 deletions

View File

@ -26,10 +26,15 @@ All contributions must follow the following rules:
full permission of the contribution's original creator(s).
* Code contributions are not obliged to follow Mapbase's preprocessor conventions (e.g. #ifdef MAPBASE),
although it's acceptable.
although it is acceptable.
If your contribution is accepted, you may be listed in Mapbase's credits:
* If you are contributing a file you created yourself specifically for Mapbase, you are required to
use the custom "Mapbase - Source 2013" header used in other Mapbase files as of Mapbase v5.0.
You are encouraged to append an "Author(s)" part to that header in your file in order to clarify who wrote it.
If your contribution is accepted, you may be listed in Mapbase's credits and the README's external content list:
https://github.com/mapbase-source/source-sdk-2013/wiki/Mapbase-Credits#Contributors
https://github.com/mapbase-source/source-sdk-2013/blob/master/README
You may also receive the "Contributor" or "Major Contributor" role on Mapbase's Discord server if you are
a member of it.

127
README
View File

@ -1,21 +1,126 @@
//===================================================================================================================================================
Mapbase - Source 2013
https://github.com/mapbase-source/source-sdk-2013
https://www.moddb.com/mods/mapbase
This repository contains the code and game files of the Source 2013 modification known as Mapbase.
//===================================================================================================================================================
The projected texture fixes within the "ASW_PROJECTED_TEXTURES" preprocessor and most of the shader changes involving projected textures are cumulative changes from Insolence's repository using fixes from Alien Swarm, G-String, and City 17: Episode One. (https://github.com/95Navigator/insolence-2013, https://github.com/Biohazard90/g-string_2013, https://github.com/KyleGospo/City-17-Episode-One-Source)
The original code for phong reflections on LightmappedGeneric-derived shaders are from City 17: Episode One. (https://github.com/KyleGospo/City-17-Episode-One-Source)
The Alien Swarm-based radial fog and rope code as well as the multiple skybox support are from Half-Life 2: Downfall. (https://github.com/DownFall-Team/DownFall)
The dynamic RTT shadow angles code is from Saul Rennison on the VDC. (https://developer.valvesoftware.com/wiki/Dynamic_RTT_shadow_angles_in_Source_2007)
The vortigaunt LOS fix is from Half-Life 2: Community Edition (dky.tehkingd.u in particular). (https://gitlab.com/RaraCerberus/HL2CE)
The parallax corrected cubemap code was originally created by Brian Charles. (https://developer.valvesoftware.com/wiki/Parallax_Corrected_Cubemaps)
The custom VScript library was created by reductor for Mapbase. (https://github.com/mapbase-source/source-sdk-2013/pull/5)
Various other code and contributions were based off of pull requests in the Source 2013 SDK (https://github.com/ValveSoftware/source-sdk-2013/pulls) and snippets on the Valve Developer Community (http://developer.valvesoftware.com/).
This repository contains code from Mapbase, a modification of the Source 2013 SDK which serves as a combined package
of general-purpose improvements, fixes, and utility features for mods.
All of the work mentioned above was open source when it was borrowed.
Mapbase's main content in this repository may include:
More credits can be found here:
- 80+ custom entities (new logic entities, filters, etc.)
- Hundreds of Inputs/Outputs/KeyValues additions and modifications
- Custom SDK_ shaders with improvements adapted from Alien Swarm SDK code, including projected texture fixes and radial fog
- Custom VScript implementation based on public Squirrel API and Alien Swarm SDK interfaces/descriptions
- Additional gameplay control for Half-Life 2 mods, including grenade features for more NPCs and singleplayer respawning
- More map-specific capabilities for maps unable to branch into their own mods, e.g. MP mods or map compilations
- View rendering changes for drawing 3D skyboxes and RT-based entities
- Countless other fixes and improvements
//===================================================================================================================================================
Mapbase is an open-source project and its contents can be distributed and used at the discretion of its users. However, this project represents many parts of
the Source modding community packaged into a whole, so credit is taken very seriously.
Up-to-date information about Mapbase content usage and credit are addressed in this article on Mapbase's wiki:
https://github.com/mapbase-source/source-sdk-2013/wiki/Using-Mapbase-Content
//===================================================================================================================================================
>>>>>>>> EXTERNAL CONTENT USED IN MAPBASE <<<<<<<<
The Mapbase project is a combination of original code from its creators, code contributed by other Source modders, and code borrowed from open-source articles
and repositories (especially ones which are specifically published as free source code). One of Mapbase's goals is to make the most popular fixes and the most obscure
or complicated code changes accessible and easy to use for level designers and other kinds of Source modders who would otherwise have no idea how to implement them.
*** DISCLAIMER: Mapbase has a strict no-leak-content policy and only allows content created directly by contributors or content originating from open-source repositories.
If you believe any content in Mapbase originates from any leak or unauthorized source (from Valve or otherwise), please contact Blixibon immediately.
Mapbase is intended to be usable by everyone, including licensed Source projects and Steam mods. ***
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.
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/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,
including radial fog, rope code, and treesway)
- https://github.com/DeathByNukes/source-sdk-2013 (VBSP manifest fixes)
- https://github.com/entropy-zero/source-sdk-2013 (skill_changed game event)
//---------------------------------------------------------------------------------------------------------------------------------------------------
Valve Developer Community (VDC) sources:
- https://developer.valvesoftware.com/wiki/Dynamic_RTT_shadow_angles_in_Source_2007 (Dynamic RTT shadow angles by Saul Rennison)
- https://developer.valvesoftware.com/wiki/Parallax_Corrected_Cubemaps (Parallax corrected cubemaps implementation from Brian Charles)
- https://developer.valvesoftware.com/wiki/Adding_the_Game_Instructor (ASW SDK game instructor adapted to Source 2013 by Kolesias123; was implemented based on a translated article)
- https://developer.valvesoftware.com/wiki/Brush_ladders (Functional func_ladders in Source 2013)
- https://developer.valvesoftware.com/wiki/CAreaPortalOneWay (func_areaportal_oneway)
- https://developer.valvesoftware.com/wiki/Implementing_Discord_RPC (Discord RPC implementation; Mapbase has its own framework originally based on this article)
- https://developer.valvesoftware.com/wiki/Rain_splashes (NOTE: This code is not completely used in Mapbase, but may still exist in its codebase)
- https://developer.valvesoftware.com/wiki/Hand_Viewmodels (NOTE: This code is not completely supported by default because Mapbase does not yet have weapon viewmodels which support
interchangeable arms; this may change in the future)
- https://developer.valvesoftware.com/wiki/General_SDK_Snippets_%26_Fixes (Various snippets on the article, including the dropship gun fix)
- https://developer.valvesoftware.com/wiki/Memory_Leak_Fixes (Most of these snippets were applied in later SDK updates, but some were not and have been added to Mapbase)
- https://developer.valvesoftware.com/wiki/Env_projectedtexture/fixes (Misc. env_projectedtexture fixes; Some of these are superceded by Alien Swarm-based changes and not used)
- https://developer.valvesoftware.com/wiki/Scenes.image (Original raw VCD file support; Code was improved for Mapbase and the article was later updated with it)
- https://developer.valvesoftware.com/wiki/Extending_Prop_Sphere (prop_sphere customization)
- https://developer.valvesoftware.com/wiki/TF2_Glow_Effect_(2013_SDK) (Glow effect)
- https://developer.valvesoftware.com/wiki/CFuncMoveLinear_ParentingFix (func_movelinear parenting fix; Code was improved for Mapbase and the article was later updated with it)
- https://developer.valvesoftware.com/wiki/Viewmodel_Prediction_Fix (Viewmodel prediction fix)
- https://developer.valvesoftware.com/wiki/Owner#Collisions_with_owner (FSOLID_COLLIDE_WITH_OWNER flag)
- https://developer.valvesoftware.com/wiki/Npc_clawscanner#Strider_Scout_Issue (npc_clawscanner strider scout fix)
- https://developer.valvesoftware.com/wiki/Ambient_generic:_stop_and_toggle_fix (Fixes for stopping/toggling ambient_generic)
- https://developer.valvesoftware.com/wiki/Func_clip_vphysics ("Start Disabled" keyvalue fix)
//---------------------------------------------------------------------------------------------------------------------------------------------------
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)
- 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
//---------------------------------------------------------------------------------------------------------------------------------------------------
Other sources:
- Various code from Source SDK 2013 pull requests on the GitHub repository (https://github.com/ValveSoftware/source-sdk-2013/pulls):
-- https://github.com/ValveSoftware/source-sdk-2013/pull/441 (Smooth scrape sound oversight fix)
-- https://github.com/ValveSoftware/source-sdk-2013/pull/436 (VRAD debug counter fix + thread bump)
-- https://github.com/ValveSoftware/source-sdk-2013/pull/416 (Ragdoll null pointer dereference fix)
-- https://github.com/ValveSoftware/source-sdk-2013/pull/401 (func_rot_button "Starts locked" flag fix)
-- https://github.com/ValveSoftware/source-sdk-2013/pull/391 (VBSP func_detail smoothing group fix)
-- https://github.com/ValveSoftware/source-sdk-2013/pull/362 (npc_manhack npc_maker fix; Adjusted for formatting and save/restore in Mapbase)
- https://github.com/momentum-mod/game/blob/1d066180b3bf74830c51e6914d46c40b0bea1fc2/mp/src/game/server/player.cpp#L6543 (spec_goto fix)
- Poison zombie barnacle crash fix implemented based on a snippet from HL2: Plus posted by Agent Agrimar on Discord (Mapbase makes the barnacle recognize it as poison just like poison headcrabs)
- https://gamebanana.com/skins/172192 (Airboat handling fix; This is asset-based and not reflected in the code)
- Vortigaunt LOS fix originally created by dky.tehkingd.u for HL2:CE
- https://combineoverwiki.net/wiki/File:Combine_main_symbol.svg ("icon_combine" instructor icon in "materials/vgui/hud/gameinstructor_hl2_1"; This is asset-based and not reflected in the code)
//---------------------------------------------------------------------------------------------------------------------------------------------------
If there is anything missing from this list, please contact Blixibon.
//===================================================================================================================================================
Aside from the content list above, Mapbase has more descriptive and up-to-date credits on this wiki article:
https://github.com/mapbase-source/source-sdk-2013/wiki/Mapbase-Credits
//===================================================================================================================================================
Please see the Source SDK 2013 license below:

View File

@ -85,9 +85,7 @@ static inline bool ShouldDrawLocalPlayerViewModel( void )
{
#if defined( PORTAL )
return false;
#else
#ifdef MAPBASE
#elif MAPBASE
// We shouldn't draw the viewmodel externally.
C_BasePlayer *localplayer = C_BasePlayer::GetLocalPlayer();
if (localplayer)
@ -101,15 +99,13 @@ static inline bool ShouldDrawLocalPlayerViewModel( void )
}
// Since we already have the local player, check its own ShouldDrawThisPlayer() to avoid extra checks
return localplayer->ShouldDrawThisPlayer();
return !localplayer->ShouldDrawThisPlayer();
}
else
return false;
#else
return !C_BasePlayer::ShouldDrawLocalPlayer();
#endif
#endif
}
//-----------------------------------------------------------------------------

View File

@ -459,6 +459,8 @@ 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, "" )
#endif
END_SCRIPTDESC();

View File

@ -868,6 +868,7 @@ public:
void SetSize( const Vector &vecMin, const Vector &vecMax ); // UTIL_SetSize( pev, mins, maxs );
char const *GetClassname( void );
char const *GetDebugName( void );
virtual const char *GetPlayerName() const { return NULL; }
static int PrecacheModel( const char *name );
static bool PrecacheSound( const char *name );
static void PrefetchSound( const char *name );

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,458 @@
//========= Copyright © 1996-2008, Valve Corporation, All rights reserved. ============//
//
// Purpose: Client handler for instruction players how to play
//
//=============================================================================//
#ifndef _C_BASELESSON_H_
#define _C_BASELESSON_H_
#include "GameEventListener.h"
#include "hud_locator_target.h"
#define DECLARE_LESSON( _lessonClassName, _baseLessonClassName ) \
typedef _baseLessonClassName BaseClass;\
typedef _lessonClassName ThisClass;\
_lessonClassName( const char *pchName, bool bIsDefaultHolder, bool bIsOpenOpportunity )\
: _baseLessonClassName( pchName, bIsDefaultHolder, bIsOpenOpportunity )\
{\
Init();\
}
enum LessonInstanceType
{
LESSON_INSTANCE_MULTIPLE,
LESSON_INSTANCE_SINGLE_OPEN,
LESSON_INSTANCE_FIXED_REPLACE,
LESSON_INSTANCE_SINGLE_ACTIVE,
LESSON_INSTANCE_TYPE_TOTAL
};
// This is used to solve a problem where bots can take the place of a player, where on or the other don't have valid entities on the client at the same time
#define MAX_DELAYED_PLAYER_SWAPS 8
struct delayed_player_swap_t
{
CHandle<C_BaseEntity> *phHandleToChange;
int iNewUserID;
delayed_player_swap_t( void )
{
phHandleToChange = NULL;
iNewUserID = -1;
}
};
abstract_class CBaseLesson : public CGameEventListener
{
public:
CBaseLesson( const char *pchName, bool bIsDefaultHolder, bool bIsOpenOpportunity );
virtual ~CBaseLesson( void );
void AddPrerequisite( const char *pchLessonName );
const CGameInstructorSymbol& GetNameSymbol( void ) const { return m_stringName; }
const char * GetName( void ) const { return m_stringName.String(); }
int GetPriority( void ) const { return m_iPriority; }
const char * GetCloseReason( void ) const { return m_stringCloseReason.String(); }
void SetCloseReason( const char *pchReason ) { m_stringCloseReason = pchReason; }
CBaseLesson* GetRoot( void ) const { return m_pRoot; }
void SetRoot( CBaseLesson *pRoot );
const CUtlVector < CBaseLesson * >* GetChildren( void ) const { return &m_OpenOpportunities; }
float GetInitTime( void ) { return m_fInitTime; }
void SetStartTime( void ) { m_fStartTime = gpGlobals->curtime; }
void ResetStartTime( void ) { m_fStartTime = 0.0f; m_bHasPlayedSound = false; }
bool ShouldShowSpew( void );
bool NoPriority( void ) const;
bool IsDefaultHolder( void ) const { return m_bIsDefaultHolder; }
bool IsOpenOpportunity( void ) const { return m_bIsOpenOpportunity; }
bool IsLocked( void ) const;
bool CanOpenWhenDead( void ) const { return m_bCanOpenWhenDead; }
bool IsInstructing( void ) const { return ( m_fStartTime > 0.0f ); }
bool IsLearned( void ) const;
bool PrerequisitesHaveBeenMet( void ) const;
bool IsTimedOut( void );
int InstanceType( void ) const { return m_iInstanceType; }
const CGameInstructorSymbol& GetReplaceKeySymbol( void ) const { return m_stringReplaceKey; }
const char* GetReplaceKey( void ) const { return m_stringReplaceKey.String(); }
int GetFixedInstancesMax( void ) const { return m_iFixedInstancesMax; }
bool ShouldReplaceOnlyWhenStopped( void ) const { return m_bReplaceOnlyWhenStopped; }
void SetInstanceActive( bool bInstanceActive ) { m_bInstanceActive = bInstanceActive; }
bool IsInstanceActive( void ) const { return m_bInstanceActive; }
void ResetDisplaysAndSuccesses( void );
bool IncDisplayCount( void );
bool IncSuccessCount( void );
void SetDisplayCount( int iDisplayCount ) { m_iDisplayCount = iDisplayCount; }
void SetSuccessCount( int iSuccessCount ) { m_iSuccessCount = iSuccessCount; }
int GetDisplayCount( void ) const { return m_iDisplayCount; }
int GetSuccessCount( void ) const { return m_iSuccessCount; }
int GetDisplayLimit( void ) const { return m_iDisplayLimit; }
int GetSuccessLimit( void ) const { return m_iSuccessLimit; }
void Init( void ); // NOT virtual, each constructor calls their own
virtual void InitPrerequisites( void ) {};
virtual void Start( void ) = 0;
virtual void Stop( void ) = 0;
virtual void OnOpen( void ) {};
virtual void Update( void ) {};
virtual void UpdateInactive( void ) {};
virtual bool ShouldDisplay( void ) const { return true; }
virtual bool IsVisible( void ) const { return true; }
virtual bool WasDisplayed( void ) const { return m_bWasDisplayed ? true : false; }
virtual void SwapOutPlayers( int iOldUserID, int iNewUserID ) {}
virtual void TakePlaceOf( CBaseLesson *pLesson );
const char *GetGroup() { return m_szLessonGroup.String(); }
void SetEnabled( bool bEnabled ) { m_bDisabled = !bEnabled; }
protected:
void MarkSucceeded( void );
void CloseOpportunity( const char *pchReason );
bool DoDelayedPlayerSwaps( void ) const;
private:
CBaseLesson *m_pRoot;
CUtlVector < CBaseLesson * > m_OpenOpportunities;
CUtlVector < const CBaseLesson * > m_Prerequisites;
CGameInstructorSymbol m_stringCloseReason;
CGameInstructorSymbol m_stringName;
bool m_bInstanceActive : 1;
bool m_bSuccessCounted : 1;
bool m_bIsDefaultHolder : 1;
bool m_bIsOpenOpportunity : 1;
protected:
LessonInstanceType m_iInstanceType;
int m_iPriority;
CGameInstructorSymbol m_stringReplaceKey;
int m_iFixedInstancesMax;
bool m_bReplaceOnlyWhenStopped;
int m_iTeam;
bool m_bOnlyKeyboard;
bool m_bOnlyGamepad;
int m_iDisplayLimit;
int m_iDisplayCount;
bool m_bWasDisplayed;
int m_iSuccessLimit;
int m_iSuccessCount;
float m_fLockDuration;
float m_fTimeout;
float m_fInitTime;
float m_fStartTime;
float m_fLockTime;
float m_fUpdateInterval;
bool m_bHasPlayedSound;
CGameInstructorSymbol m_szStartSound;
CGameInstructorSymbol m_szLessonGroup;
bool m_bCanOpenWhenDead;
bool m_bBumpWithTimeoutWhenLearned;
bool m_bCanTimeoutWhileInactive;
bool m_bDisabled;
// Right now we can only queue up 4 swaps...
// this number can be increased if more entity handle scripted variables are added
mutable delayed_player_swap_t m_pDelayedPlayerSwap[ MAX_DELAYED_PLAYER_SWAPS ];
mutable int m_iNumDelayedPlayerSwaps;
public:
// Colors for console spew in verbose mode
static Color m_rgbaVerboseHeader;
static Color m_rgbaVerbosePlain;
static Color m_rgbaVerboseName;
static Color m_rgbaVerboseOpen;
static Color m_rgbaVerboseClose;
static Color m_rgbaVerboseSuccess;
static Color m_rgbaVerboseUpdate;
};
class CTextLesson : public CBaseLesson
{
public:
DECLARE_LESSON( CTextLesson, CBaseLesson );
void Init( void ); // NOT virtual, each constructor calls their own
virtual void Start( void );
virtual void Stop( void );
protected:
CGameInstructorSymbol m_szDisplayText;
CGameInstructorSymbol m_szDisplayParamText;
CGameInstructorSymbol m_szBinding;
CGameInstructorSymbol m_szGamepadBinding;
};
class CIconLesson : public CTextLesson
{
public:
DECLARE_LESSON( CIconLesson, CTextLesson );
void Init( void ); // NOT virtual, each constructor calls their own
virtual void Start( void );
virtual void Stop( void );
virtual void Update( void );
virtual void UpdateInactive( void );
virtual bool ShouldDisplay( void ) const;
virtual bool IsVisible( void ) const;
virtual void SwapOutPlayers( int iOldUserID, int iNewUserID );
virtual void TakePlaceOf( CBaseLesson *pLesson );
void SetLocatorBinding( CLocatorTarget * pLocatorTarget );
const char *GetCaptionColorString() { return m_szCaptionColor.String(); }
bool IsPresentComplete( void );
void PresentStart( void );
void PresentEnd( void );
private:
virtual void UpdateLocatorTarget( CLocatorTarget *pLocatorTarget, C_BaseEntity *pIconTarget );
#ifdef MAPBASE
Vector GetIconTargetPosition( C_BaseEntity *pIconTarget );
#endif
protected:
CHandle<C_BaseEntity> m_hIconTarget;
CGameInstructorSymbol m_szVguiTargetName;
CGameInstructorSymbol m_szVguiTargetLookup;
int m_nVguiTargetEdge;
float m_flUpOffset;
float m_flRelativeUpOffset;
float m_fFixedPositionX;
float m_fFixedPositionY;
int m_hLocatorTarget;
int m_iFlags;
float m_fRange;
float m_fCurrentDistance;
float m_fOnScreenStartTime;
float m_fUpdateDistanceTime;
CGameInstructorSymbol m_szOnscreenIcon;
CGameInstructorSymbol m_szOffscreenIcon;
CGameInstructorSymbol m_szCaptionColor;
bool m_bFixedPosition;
bool m_bNoIconTarget;
bool m_bAllowNodrawTarget;
bool m_bVisible;
bool m_bShowWhenOccluded;
bool m_bNoOffscreen;
bool m_bForceCaption;
#ifdef MAPBASE
int m_iIconTargetPos;
enum
{
ICON_TARGET_EYE_POSITION,
ICON_TARGET_ORIGIN,
ICON_TARGET_CENTER,
};
#endif
};
enum LessonAction
{
LESSON_ACTION_NONE,
LESSON_ACTION_SCOPE_IN,
LESSON_ACTION_SCOPE_OUT,
LESSON_ACTION_CLOSE,
LESSON_ACTION_SUCCESS,
LESSON_ACTION_LOCK,
LESSON_ACTION_PRESENT_COMPLETE,
LESSON_ACTION_PRESENT_START,
LESSON_ACTION_PRESENT_END,
LESSON_ACTION_REFERENCE_OPEN,
LESSON_ACTION_SET,
LESSON_ACTION_ADD,
LESSON_ACTION_SUBTRACT,
LESSON_ACTION_MULTIPLY,
LESSON_ACTION_IS,
LESSON_ACTION_LESS_THAN,
LESSON_ACTION_HAS_PREFIX,
LESSON_ACTION_HAS_BIT,
LESSON_ACTION_BIT_COUNT_IS,
LESSON_ACTION_BIT_COUNT_LESS_THAN,
LESSON_ACTION_GET_DISTANCE,
LESSON_ACTION_GET_ANGULAR_DISTANCE,
LESSON_ACTION_GET_PLAYER_DISPLAY_NAME,
LESSON_ACTION_CLASSNAME_IS,
LESSON_ACTION_MODELNAME_IS,
LESSON_ACTION_TEAM_IS,
LESSON_ACTION_HEALTH_LESS_THAN,
LESSON_ACTION_HEALTH_PERCENTAGE_LESS_THAN,
LESSON_ACTION_GET_ACTIVE_WEAPON,
LESSON_ACTION_WEAPON_IS,
LESSON_ACTION_WEAPON_HAS,
LESSON_ACTION_GET_ACTIVE_WEAPON_SLOT,
LESSON_ACTION_GET_WEAPON_SLOT,
LESSON_ACTION_GET_WEAPON_IN_SLOT,
LESSON_ACTION_CLIP_PERCENTAGE_LESS_THAN,
LESSON_ACTION_WEAPON_AMMO_LOW,
LESSON_ACTION_WEAPON_AMMO_FULL,
LESSON_ACTION_WEAPON_AMMO_EMPTY,
LESSON_ACTION_WEAPON_CAN_USE,
LESSON_ACTION_USE_TARGET_IS,
LESSON_ACTION_GET_USE_TARGET,
LESSON_ACTION_GET_POTENTIAL_USE_TARGET,
// Enum continued in Mod_LessonAction
LESSON_ACTION_MOD_START,
};
struct LessonElement_t
{
int iVariable;
int iParamVarIndex;
int iAction;
_fieldtypes paramType;
CGameInstructorSymbol szParam;
bool bNot : 1;
bool bOptionalParam : 1;
LessonElement_t( int p_iVariable, int p_iAction, bool p_bNot, bool p_bOptionalParam, const char *pchParam, int p_iParamVarIndex, _fieldtypes p_paramType )
{
iVariable = p_iVariable;
iAction = p_iAction;
bNot = p_bNot;
bOptionalParam = p_bOptionalParam;
szParam = pchParam;
iParamVarIndex = p_iParamVarIndex;
paramType = p_paramType;
}
LessonElement_t( const LessonElement_t &p_LessonElement )
{
iVariable = p_LessonElement.iVariable;
iAction = p_LessonElement.iAction;
bNot = p_LessonElement.bNot;
bOptionalParam = p_LessonElement.bOptionalParam;
szParam = p_LessonElement.szParam;
iParamVarIndex = p_LessonElement.iParamVarIndex;
paramType = p_LessonElement.paramType;
}
};
struct LessonEvent_t
{
CUtlVector< LessonElement_t > elements;
CGameInstructorSymbol szEventName;
};
class CScriptedIconLesson : public CIconLesson
{
public:
DECLARE_LESSON( CScriptedIconLesson, CIconLesson )
virtual ~CScriptedIconLesson( void );
static void PreReadLessonsFromFile( void );
static void Mod_PreReadLessonsFromFile( void );
void Init( void ); // NOT virtual, each constructor calls their own
virtual void InitPrerequisites( void );
virtual void OnOpen( void );
virtual void Update( void );
virtual void SwapOutPlayers( int iOldUserID, int iNewUserID );
virtual void FireGameEvent( IGameEvent *event );
virtual void ProcessOpenGameEvents( const CScriptedIconLesson *pRootLesson, const char *name, IGameEvent *event );
virtual void ProcessCloseGameEvents( const CScriptedIconLesson *pRootLesson, const char *name, IGameEvent *event );
virtual void ProcessSuccessGameEvents( const CScriptedIconLesson *pRootLesson, const char *name, IGameEvent *event );
CUtlVector< LessonEvent_t >& GetOpenEvents( void ) { return m_OpenEvents; }
CUtlVector< LessonEvent_t >& GetCloseEvents( void ) { return m_CloseEvents; }
CUtlVector< LessonEvent_t >& GetSuccessEvents( void ) { return m_SuccessEvents; }
CUtlVector< LessonEvent_t >& GetOnOpenEvents( void ) { return m_OnOpenEvents; }
CUtlVector< LessonEvent_t >& GetUpdateEvents( void ) { return m_UpdateEvents; }
bool ProcessElements( IGameEvent *event, const CUtlVector< LessonElement_t > *pElements );
private:
void InitElementsFromKeys( CUtlVector< LessonElement_t > *pLessonElements, KeyValues *pKey );
void InitElementsFromElements( CUtlVector< LessonElement_t > *pLessonElements, const CUtlVector< LessonElement_t > *pLessonElements2 );
void InitFromKeys( KeyValues *pKey );
bool ProcessElement( IGameEvent *event, const LessonElement_t *pLessonElement, bool bInFailedScope );
bool ProcessElementAction( int iAction, bool bNot, const char *pchVarName, float &bVar, const CGameInstructorSymbol *pchParamName, float fParam );
bool ProcessElementAction( int iAction, bool bNot, const char *pchVarName, int &bVar, const CGameInstructorSymbol *pchParamName, float fParam );
bool ProcessElementAction( int iAction, bool bNot, const char *pchVarName, bool &bVar, const CGameInstructorSymbol *pchParamName, float fParam );
bool ProcessElementAction( int iAction, bool bNot, const char *pchVarName, EHANDLE &hVar, const CGameInstructorSymbol *pchParamName, float fParam, C_BaseEntity *pParam, const char *pchParam );
bool ProcessElementAction( int iAction, bool bNot, const char *pchVarName, CGameInstructorSymbol *pchVar, const CGameInstructorSymbol *pchParamName, const char *pchParam );
// Implemented per mod so they can have custom actions
bool Mod_ProcessElementAction( int iAction, bool bNot, const char *pchVarName, EHANDLE &hVar, const CGameInstructorSymbol *pchParamName, float fParam, C_BaseEntity *pParam, const char *pchParam, bool &bModHandled );
LessonEvent_t * AddOpenEvent( void );
LessonEvent_t * AddCloseEvent( void );
LessonEvent_t * AddSuccessEvent( void );
LessonEvent_t * AddOnOpenEvent( void );
LessonEvent_t * AddUpdateEvent( void );
private:
static CUtlDict< int, int > CScriptedIconLesson::LessonActionMap;
EHANDLE m_hLocalPlayer;
float m_fOutput;
CHandle<C_BaseEntity> m_hEntity1;
CHandle<C_BaseEntity> m_hEntity2;
CGameInstructorSymbol m_szString1;
CGameInstructorSymbol m_szString2;
int m_iInteger1;
int m_iInteger2;
float m_fFloat1;
float m_fFloat2;
CUtlVector< CGameInstructorSymbol > m_PrerequisiteNames;
CUtlVector< LessonEvent_t > m_OpenEvents;
CUtlVector< LessonEvent_t > m_CloseEvents;
CUtlVector< LessonEvent_t > m_SuccessEvents;
CUtlVector< LessonEvent_t > m_OnOpenEvents;
CUtlVector< LessonEvent_t > m_UpdateEvents;
float m_fUpdateEventTime;
CScriptedIconLesson *m_pDefaultHolder;
int m_iScopeDepth;
// Need this to get offsets to scripted variables
friend class LessonVariableInfo;
friend int LessonActionFromString( const char *pchName );
};
#endif // _C_BASELESSON_H_

View File

@ -6,6 +6,9 @@
//===========================================================================//
#include "cbase.h"
#include "view_shared.h"
#ifdef MAPBASE
#include "viewrender.h"
#endif
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
@ -23,10 +26,27 @@ public:
virtual bool ShouldDraw();
#ifdef MAPBASE
virtual void OnDataChanged( DataUpdateType_t type );
ITexture *ReflectionRenderTarget();
ITexture *RefractionRenderTarget();
char m_iszReflectRenderTarget[64];
char m_iszRefractRenderTarget[64];
ITexture *m_pReflectRenderTarget;
ITexture *m_pRefractRenderTarget;
#endif
C_FuncReflectiveGlass *m_pNext;
};
IMPLEMENT_CLIENTCLASS_DT( C_FuncReflectiveGlass, DT_FuncReflectiveGlass, CFuncReflectiveGlass )
#ifdef MAPBASE
RecvPropString( RECVINFO( m_iszReflectRenderTarget ) ),
RecvPropString( RECVINFO( m_iszRefractRenderTarget ) ),
#endif
END_RECV_TABLE()
@ -47,6 +67,11 @@ C_FuncReflectiveGlass* GetReflectiveGlassList()
//-----------------------------------------------------------------------------
C_FuncReflectiveGlass::C_FuncReflectiveGlass()
{
#ifdef MAPBASE
m_iszReflectRenderTarget[0] = '\0';
m_iszRefractRenderTarget[0] = '\0';
#endif
g_ReflectiveGlassList.Insert( this );
}
@ -114,5 +139,111 @@ bool IsReflectiveGlassInView( const CViewSetup& view, cplane_t &plane )
return false;
}
#ifdef MAPBASE
//-----------------------------------------------------------------------------
// Iterates through reflective glass instead of just picking one
//-----------------------------------------------------------------------------
C_BaseEntity *NextReflectiveGlass( C_BaseEntity *pStart, const CViewSetup& view, cplane_t &plane,
const Frustum_t &frustum, ITexture **pRenderTargets )
{
// Early out if no cameras
C_FuncReflectiveGlass *pReflectiveGlass = NULL;
if (!pStart)
pReflectiveGlass = GetReflectiveGlassList();
else
pReflectiveGlass = ((C_FuncReflectiveGlass*)pStart)->m_pNext;
cplane_t localPlane;
Vector vecOrigin, vecWorld, vecDelta;
for ( ; pReflectiveGlass != NULL; pReflectiveGlass = pReflectiveGlass->m_pNext )
{
if ( pReflectiveGlass->IsDormant() )
continue;
if ( pReflectiveGlass->m_iViewHideFlags & (1 << CurrentViewID()) )
continue;
Vector vecMins, vecMaxs;
pReflectiveGlass->GetRenderBoundsWorldspace( vecMins, vecMaxs );
if ( R_CullBox( vecMins, vecMaxs, frustum ) )
continue;
const model_t *pModel = pReflectiveGlass->GetModel();
const matrix3x4_t& mat = pReflectiveGlass->EntityToWorldTransform();
int nCount = modelinfo->GetBrushModelPlaneCount( pModel );
for ( int i = 0; i < nCount; ++i )
{
modelinfo->GetBrushModelPlane( pModel, i, localPlane, &vecOrigin );
MatrixTransformPlane( mat, localPlane, plane ); // Transform to world space
VectorTransform( vecOrigin, mat, vecWorld );
if ( view.origin.Dot( plane.normal ) <= plane.dist ) // Check for view behind plane
continue;
VectorSubtract( vecWorld, view.origin, vecDelta ); // Backface cull
if ( vecDelta.Dot( plane.normal ) >= 0 )
continue;
if (pRenderTargets != NULL)
{
pRenderTargets[0] = pReflectiveGlass->ReflectionRenderTarget();
pRenderTargets[1] = pReflectiveGlass->RefractionRenderTarget();
}
return pReflectiveGlass;
}
}
return NULL;
}
void C_FuncReflectiveGlass::OnDataChanged( DataUpdateType_t type )
{
// Reset render textures
m_pReflectRenderTarget = NULL;
m_pRefractRenderTarget = NULL;
return BaseClass::OnDataChanged( type );
}
ITexture *C_FuncReflectiveGlass::ReflectionRenderTarget()
{
if (m_iszReflectRenderTarget[0] != '\0')
{
if (!m_pReflectRenderTarget)
{
// We don't use a CTextureReference for this because we don't want to shut down the texture on removal/change
m_pReflectRenderTarget = materials->FindTexture( m_iszReflectRenderTarget, TEXTURE_GROUP_RENDER_TARGET );
}
if (m_pReflectRenderTarget)
return m_pReflectRenderTarget;
}
return NULL;
//return GetWaterReflectionTexture();
}
ITexture *C_FuncReflectiveGlass::RefractionRenderTarget()
{
if (m_iszRefractRenderTarget[0] != '\0')
{
if (!m_pRefractRenderTarget)
{
// We don't use a CTextureReference for this because we don't want to shut down the texture on removal/change
m_pRefractRenderTarget = materials->FindTexture( m_iszRefractRenderTarget, TEXTURE_GROUP_RENDER_TARGET );
}
if (m_pRefractRenderTarget)
return m_pRefractRenderTarget;
}
return NULL;
//return GetWaterRefractionTexture();
}
#endif

View File

@ -21,6 +21,11 @@ class CViewSetup;
//-----------------------------------------------------------------------------
bool IsReflectiveGlassInView( const CViewSetup& view, cplane_t &plane );
#ifdef MAPBASE
C_BaseEntity *NextReflectiveGlass( C_BaseEntity *pStart, const CViewSetup& view, cplane_t &plane,
const Frustum_t &frustum, ITexture **pRenderTargets = NULL );
#endif
#endif // C_FUNC_REFLECTIVE_GLASS

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,118 @@
//========= Copyright © 1996-2008, Valve Corporation, All rights reserved. ============//
//
// Purpose: Client handler for instruction players how to play
//
//=============================================================================//
#ifndef _C_GAMEINSTRUCTOR_H_
#define _C_GAMEINSTRUCTOR_H_
#include "GameEventListener.h"
#include "vgui_controls/phandle.h"
class CBaseLesson;
struct LessonGroupConVarToggle_t
{
ConVarRef var;
char szLessonGroupName[ 64 ];
LessonGroupConVarToggle_t( const char *pchConVarName ) :
var( pchConVarName )
{
}
};
class C_GameInstructor : public CAutoGameSystemPerFrame, public CGameEventListener
{
public:
C_GameInstructor() : CAutoGameSystemPerFrame( "C_GameInstructor" )
{
m_bHasLoadedSaveData = false;
m_bDirtySaveData = false;
}
// Methods of IGameSystem
virtual bool Init( void );
virtual void Shutdown( void );
virtual void Update( float frametime );
void UpdateHiddenByOtherElements( void );
bool Mod_HiddenByOtherElements( void );
virtual void FireGameEvent( IGameEvent *event );
void DefineLesson( CBaseLesson *pLesson );
const CBaseLesson * GetLesson( const char *pchLessonName );
bool IsLessonOfSameTypeOpen( const CBaseLesson *pLesson ) const;
bool ReadSaveData( void );
bool WriteSaveData( void );
void RefreshDisplaysAndSuccesses( void );
void ResetDisplaysAndSuccesses( void );
void MarkDisplayed( const char *pchLessonName );
void MarkSucceeded( const char *pchLessonName );
void PlaySound( const char *pchSoundName );
bool OpenOpportunity( CBaseLesson *pLesson );
void DumpOpenOpportunities( void );
KeyValues * GetScriptKeys( void );
C_BasePlayer * GetLocalPlayer( void );
void EvaluateLessonsForGameRules( void );
void SetLessonGroupEnabled( const char *pszGroup, bool bEnabled );
// Mapbase needs this to be public for map-specific file system
void ReadLessonsFromFile( const char *pchFileName );
private:
void FindErrors( void );
bool UpdateActiveLesson( CBaseLesson *pLesson, const CBaseLesson *pRootLesson );
void UpdateInactiveLesson( CBaseLesson *pLesson );
CBaseLesson * GetLesson_Internal( const char *pchLessonName );
void StopAllLessons( void );
void CloseAllOpenOpportunities( void );
void CloseOpportunity( CBaseLesson *pLesson );
void InitLessonPrerequisites( void );
private:
CUtlVector < CBaseLesson* > m_Lessons;
CUtlVector < CBaseLesson* > m_OpenOpportunities;
CUtlVector < LessonGroupConVarToggle_t > m_LessonGroupConVarToggles;
KeyValues *m_pScriptKeys;
bool m_bNoDraw;
bool m_bHiddenDueToOtherElements;
int m_iCurrentPriority;
EHANDLE m_hLastSpectatedPlayer;
bool m_bSpectatedPlayerChanged;
char m_szPreviousStartSound[ 128 ];
float m_fNextStartSoundTime;
bool m_bHasLoadedSaveData;
bool m_bDirtySaveData;
};
C_GameInstructor &GetGameInstructor();
void GameInstructor_Init();
void GameInstructor_Shutdown();
#endif // _C_GAMEINSTRUCTOR_H_

View File

@ -429,8 +429,10 @@ void CPixelVisibilityQuery::IssueQuery( IMatRenderContext *pRenderContext, float
return;
}
}
#ifndef MAPBASE // Mapbase can also query visibility several times via multiple point_cameras, etc.
#ifndef PORTAL // FIXME: In portal we query visibility multiple times per frame because of portal renders!
Assert ( ( m_frameIssued != gpGlobals->framecount ) || UseVR() );
#endif
#endif
m_frameIssued = gpGlobals->framecount;

View File

@ -27,6 +27,7 @@ IMPLEMENT_CLIENTCLASS_DT( C_PointCamera, DT_PointCamera, CPointCamera )
RecvPropInt( RECVINFO( m_bUseScreenAspectRatio ) ),
#ifdef MAPBASE
RecvPropInt( RECVINFO( m_iSkyMode ) ),
RecvPropString( RECVINFO( m_iszRenderTarget ) ),
#endif
END_RECV_TABLE()
@ -43,6 +44,10 @@ C_PointCamera::C_PointCamera()
m_bActive = false;
m_bFogEnable = false;
#ifdef MAPBASE
m_iszRenderTarget[0] = '\0';
#endif
g_PointCameraList.Insert( this );
}
@ -56,6 +61,16 @@ bool C_PointCamera::ShouldDraw()
return false;
}
void C_PointCamera::OnDataChanged( DataUpdateType_t type )
{
#ifdef MAPBASE
// Reset render texture
m_pRenderTarget = NULL;
#endif
return BaseClass::OnDataChanged( type );
}
float C_PointCamera::GetFOV()
{
return m_FOV;
@ -117,6 +132,26 @@ void C_PointCamera::GetToolRecordingState( KeyValues *msg )
}
#ifdef MAPBASE
extern ITexture *GetCameraTexture( void );
extern void AddReleaseFunc( void );
ITexture *C_PointCamera::RenderTarget()
{
if (m_iszRenderTarget[0] != '\0')
{
if (!m_pRenderTarget)
{
// We don't use a CTextureReference for this because we don't want to shut down the texture on removal/change
m_pRenderTarget = materials->FindTexture( m_iszRenderTarget, TEXTURE_GROUP_RENDER_TARGET );
}
if (m_pRenderTarget)
return m_pRenderTarget;
}
return GetCameraTexture();
}
IMPLEMENT_CLIENTCLASS_DT( C_PointCameraOrtho, DT_PointCameraOrtho, CPointCameraOrtho )
RecvPropInt( RECVINFO( m_bOrtho ) ),
RecvPropArray( RecvPropFloat( RECVINFO( m_OrthoDimensions[0] ) ), m_OrthoDimensions ),

View File

@ -29,6 +29,9 @@ public:
// C_BaseEntity.
virtual bool ShouldDraw();
// Mapbase uses this for m_iszRenderTarget
virtual void OnDataChanged( DataUpdateType_t type );
float GetFOV();
float GetResolution();
bool IsFogEnabled();
@ -42,6 +45,8 @@ public:
virtual void GetOrthoDimensions(float &up, float &dn, float &lf, float &rt) const {}
SkyboxVisibility_t SkyMode() { return m_iSkyMode; }
ITexture *RenderTarget();
#endif
virtual void GetToolRecordingState( KeyValues *msg );
@ -58,6 +63,8 @@ private:
bool m_bUseScreenAspectRatio;
#ifdef MAPBASE
SkyboxVisibility_t m_iSkyMode;
ITexture *m_pRenderTarget;
char m_iszRenderTarget[64];
#endif
public:

View File

@ -524,7 +524,7 @@ void CRopeManager::DrawRenderCache_NonQueued( bool bShadowDepth, RopeRenderData_
IMaterial *pMaterial = bShadowDepth ? g_pSplineCableShadowdepth : pRenderCache[iRenderCache].m_pSolidMaterial;
// Need to make sure that all rope materials use the splinerope shader since there are a lot of assumptions about how the shader interfaces with this code.
AssertOnce( V_stricmp( pMaterial->GetShaderName(), "SDK_Cable" ) == 0 ); // splinerope
AssertOnce( V_strstr( pMaterial->GetShaderName(), "SDK_Cable" ) != NULL ); // splinerope
pRenderContext->Bind( pMaterial );

View File

@ -8,9 +8,10 @@ $Configuration
{
$Compiler
{
$PreprocessorDefinitions "$BASE;ASW_PROJECTED_TEXTURES;DYNAMIC_RTT_SHADOWS"
$PreprocessorDefinitions "$BASE;ASW_PROJECTED_TEXTURES;DYNAMIC_RTT_SHADOWS;GLOWS_ENABLE"
$PreprocessorDefinitions "$BASE;MAPBASE_RPC;DISCORD_RPC;STEAM_RPC" [$MAPBASE_RPC]
$PreprocessorDefinitions "$BASE;MAPBASE_VSCRIPT" [$MAPBASE_VSCRIPT]
}
}
@ -21,6 +22,12 @@ $Project
$File "c_env_global_light.cpp"
$File "worldlight.cpp"
$File "worldlight.h"
$File "c_baselesson.cpp"
$File "c_baselesson.h"
$File "c_gameinstructor.cpp"
$File "c_gameinstructor.h"
$File "hud_locator_target.cpp"
$File "hud_locator_target.h"
$Folder "Mapbase"
{
@ -32,10 +39,16 @@ $Project
$File "$SRCDIR\game\shared\mapbase\matchers.cpp"
$File "$SRCDIR\game\shared\mapbase\matchers.h"
$File "$SRCDIR\game\shared\mapbase\vscript_funcs_shared.cpp" [$MAPBASE_VSCRIPT]
$File "$SRCDIR\game\shared\mapbase\vscript_funcs_shared.h" [$MAPBASE_VSCRIPT]
$File "$SRCDIR\game\shared\mapbase\vscript_funcs_math.cpp" [$MAPBASE_VSCRIPT]
$File "$SRCDIR\game\shared\mapbase\vscript_funcs_math.h" [$MAPBASE_VSCRIPT]
$File "$SRCDIR\game\shared\mapbase\vscript_funcs_hl2.cpp" [$MAPBASE_VSCRIPT]
$File "$SRCDIR\game\shared\mapbase\vscript_consts_shared.cpp" [$MAPBASE_VSCRIPT]
$File "mapbase\c_func_clientclip.cpp"
$File "mapbase\c_func_fake_worldportal.cpp"
$File "mapbase\c_func_fake_worldportal.h"
$File "mapbase\c_point_glow.cpp"
}
$Folder "HL2 DLL"

View File

@ -65,6 +65,10 @@ extern ConVar replay_rendersetting_renderglow;
#include "econ_item_description.h"
#endif
#ifdef GLOWS_ENABLE
#include "clienteffectprecachesystem.h"
#endif
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
@ -89,6 +93,13 @@ extern ConVar voice_modenable;
extern bool IsInCommentaryMode( void );
#ifdef GLOWS_ENABLE
CLIENTEFFECT_REGISTER_BEGIN( PrecachePostProcessingEffectsGlow )
CLIENTEFFECT_MATERIAL( "dev/glow_color" )
CLIENTEFFECT_MATERIAL( "dev/halo_add_to_screen" )
CLIENTEFFECT_REGISTER_END_CONDITIONAL( engine->GetDXSupportLevel() >= 90 )
#endif
#ifdef VOICE_VOX_ENABLE
void VoxCallback( IConVar *var, const char *oldString, float oldFloat )
{
@ -764,6 +775,10 @@ int ClientModeShared::HudElementKeyInput( int down, ButtonCode_t keynum, const c
//-----------------------------------------------------------------------------
bool ClientModeShared::DoPostScreenSpaceEffects( const CViewSetup *pSetup )
{
#ifdef GLOWS_ENABLE
g_GlowObjectManager.RenderGlowEffects( pSetup, 0 );
#endif
#if defined( REPLAY_ENABLED )
if ( engine->IsPlayingDemo() )
{

View File

@ -3235,7 +3235,8 @@ void CClientShadowMgr::PreRender()
{
#ifdef ASW_PROJECTED_TEXTURES
// only update shadows once per frame
Assert( gpGlobals->framecount != m_nPrevFrameCount );
if( gpGlobals->framecount == m_nPrevFrameCount )
return;
m_nPrevFrameCount = gpGlobals->framecount;
#endif

View File

@ -38,6 +38,12 @@ public:
bool IsFlashlightActive( void ) { return m_HL2Local.m_bitsActiveDevices & bits_SUIT_DEVICE_FLASHLIGHT; }
bool IsBreatherActive( void ) { return m_HL2Local.m_bitsActiveDevices & bits_SUIT_DEVICE_BREATHER; }
#ifdef MAPBASE
bool IsCustomDevice0Active( void ) { return m_HL2Local.m_bitsActiveDevices & bits_SUIT_DEVICE_CUSTOM0; }
bool IsCustomDevice1Active( void ) { return m_HL2Local.m_bitsActiveDevices & bits_SUIT_DEVICE_CUSTOM1; }
bool IsCustomDevice2Active( void ) { return m_HL2Local.m_bitsActiveDevices & bits_SUIT_DEVICE_CUSTOM2; }
#endif
virtual int DrawModel( int flags );
virtual void BuildTransformations( CStudioHdr *hdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed );

View File

@ -104,12 +104,27 @@ void CHudSuitPower::OnThink( void )
bool breatherActive = pPlayer->IsBreatherActive();
int activeDevices = (int)flashlightActive + (int)sprintActive + (int)breatherActive;
#ifdef MAPBASE
activeDevices += (int)pPlayer->IsCustomDevice0Active() + (int)pPlayer->IsCustomDevice1Active() + (int)pPlayer->IsCustomDevice2Active();
#endif
if (activeDevices != m_iActiveSuitDevices)
{
m_iActiveSuitDevices = activeDevices;
switch ( m_iActiveSuitDevices )
{
#ifdef MAPBASE
case 6:
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("SuitAuxPowerSixItemsActive");
break;
case 5:
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("SuitAuxPowerFiveItemsActive");
break;
case 4:
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("SuitAuxPowerFourItemsActive");
break;
#endif
default:
case 3:
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("SuitAuxPowerThreeItemsActive");
@ -251,6 +266,59 @@ void CHudSuitPower::Paint()
}
ypos += text2_gap;
}
#ifdef MAPBASE
if (pPlayer->IsCustomDevice0Active())
{
tempString = g_pVGuiLocalize->Find("#Mapbase_Hud_DEVICE0");
surface()->DrawSetTextPos(text2_xpos, ypos);
if (tempString)
{
surface()->DrawPrintText(tempString, wcslen(tempString));
}
else
{
surface()->DrawPrintText(L"CUSTOM 0", wcslen(L"CUSTOM 0"));
}
ypos += text2_gap;
}
if (pPlayer->IsCustomDevice1Active())
{
tempString = g_pVGuiLocalize->Find("#Mapbase_Hud_DEVICE1");
surface()->DrawSetTextPos(text2_xpos, ypos);
if (tempString)
{
surface()->DrawPrintText(tempString, wcslen(tempString));
}
else
{
surface()->DrawPrintText(L"CUSTOM 1", wcslen(L"CUSTOM 1"));
}
ypos += text2_gap;
}
if (pPlayer->IsCustomDevice2Active())
{
tempString = g_pVGuiLocalize->Find("#Mapbase_Hud_DEVICE2");
surface()->DrawSetTextPos(text2_xpos, ypos);
if (tempString)
{
surface()->DrawPrintText(tempString, wcslen(tempString));
}
else
{
surface()->DrawPrintText(L"CUSTOM 2", wcslen(L"CUSTOM 2"));
}
ypos += text2_gap;
}
#endif
}
}

View File

@ -472,6 +472,8 @@ void CHud::Init( void )
}
FreeHudTextureList( textureList );
HudIcons().Init();
}
//-----------------------------------------------------------------------------
@ -1200,3 +1202,232 @@ CON_COMMAND_F( testhudanim, "Test a hud element animation.\n\tArguments: <anim n
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( args[1] );
}
CHudIcons::CHudIcons() :
m_bHudTexturesLoaded( false )
{
}
CHudIcons::~CHudIcons()
{
int c = m_Icons.Count();
for ( int i = c - 1; i >= 0; i-- )
{
CHudTexture *tex = m_Icons[ i ];
g_HudTextureMemoryPool.Free( tex );
}
m_Icons.Purge();
}
void CHudIcons::Init()
{
if ( m_bHudTexturesLoaded )
return;
m_bHudTexturesLoaded = true;
CUtlDict< CHudTexture *, int > textureList;
// check to see if we have sprites for this res; if not, step down
LoadHudTextures( textureList, "scripts/hud_textures", NULL );
LoadHudTextures( textureList, "scripts/mod_textures", NULL );
LoadHudTextures( textureList, "scripts/instructor_textures", NULL );
#ifdef HL2_CLIENT_DLL
LoadHudTextures( textureList, "scripts/instructor_textures_hl2", NULL );
#endif
LoadHudTextures( textureList, "scripts/instructor_modtextures", NULL );
int c = textureList.Count();
for ( int index = 0; index < c; index++ )
{
CHudTexture* tex = textureList[ index ];
AddSearchableHudIconToList( *tex );
}
FreeHudTextureList( textureList );
}
void CHudIcons::Shutdown()
{
m_bHudTexturesLoaded = false;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CHudTexture *CHudIcons::AddUnsearchableHudIconToList( CHudTexture& texture )
{
// These names are composed based on the texture file name
char composedName[ 512 ];
if ( texture.bRenderUsingFont )
{
Q_snprintf( composedName, sizeof( composedName ), "%s_c%i",
texture.szTextureFile, texture.cCharacterInFont );
}
else
{
Q_snprintf( composedName, sizeof( composedName ), "%s_%i_%i_%i_%i",
texture.szTextureFile, texture.rc.left, texture.rc.top, texture.rc.right, texture.rc.bottom );
}
CHudTexture *icon = GetIcon( composedName );
if ( icon )
{
return icon;
}
CHudTexture *newTexture = ( CHudTexture * )g_HudTextureMemoryPool.Alloc();
*newTexture = texture;
SetupNewHudTexture( newTexture );
int idx = m_Icons.Insert( composedName, newTexture );
return m_Icons[ idx ];
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CHudTexture *CHudIcons::AddSearchableHudIconToList( CHudTexture& texture )
{
CHudTexture *icon = GetIcon( texture.szShortName );
if ( icon )
{
return icon;
}
CHudTexture *newTexture = ( CHudTexture * )g_HudTextureMemoryPool.Alloc();
*newTexture = texture;
SetupNewHudTexture( newTexture );
int idx = m_Icons.Insert( texture.szShortName, newTexture );
return m_Icons[ idx ];
}
//-----------------------------------------------------------------------------
// Purpose: returns a pointer to an icon in the list
//-----------------------------------------------------------------------------
CHudTexture *CHudIcons::GetIcon( const char *szIcon )
{
int i = m_Icons.Find( szIcon );
if ( i == m_Icons.InvalidIndex() )
return NULL;
return m_Icons[ i ];
}
//-----------------------------------------------------------------------------
// Purpose: Gets texture handles for the hud icon
//-----------------------------------------------------------------------------
void CHudIcons::SetupNewHudTexture( CHudTexture *t )
{
if ( t->bRenderUsingFont )
{
vgui::HScheme scheme = vgui::scheme()->GetScheme( "ClientScheme" );
t->hFont = vgui::scheme()->GetIScheme(scheme)->GetFont( t->szTextureFile, true );
t->rc.top = 0;
t->rc.left = 0;
t->rc.right = vgui::surface()->GetCharacterWidth( t->hFont, t->cCharacterInFont );
t->rc.bottom = vgui::surface()->GetFontTall( t->hFont );
}
else
{
// Set up texture id and texture coordinates
t->textureId = vgui::surface()->CreateNewTextureID();
vgui::surface()->DrawSetTextureFile( t->textureId, t->szTextureFile, false, false );
int wide, tall;
vgui::surface()->DrawGetTextureSize( t->textureId, wide, tall );
t->texCoords[ 0 ] = (float)(t->rc.left + 0.5f) / (float)wide;
t->texCoords[ 1 ] = (float)(t->rc.top + 0.5f) / (float)tall;
t->texCoords[ 2 ] = (float)(t->rc.right - 0.5f) / (float)wide;
t->texCoords[ 3 ] = (float)(t->rc.bottom - 0.5f) / (float)tall;
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CHudIcons::RefreshHudTextures()
{
if ( !m_bHudTexturesLoaded )
{
Assert( 0 );
return;
}
CUtlDict< CHudTexture *, int > textureList;
// check to see if we have sprites for this res; if not, step down
LoadHudTextures( textureList, "scripts/hud_textures", NULL );
LoadHudTextures( textureList, "scripts/mod_textures", NULL );
LoadHudTextures( textureList, "scripts/instructor_textures", NULL );
// fix up all the texture icons first
int c = textureList.Count();
for ( int index = 0; index < c; index++ )
{
CHudTexture *tex = textureList[ index ];
Assert( tex );
CHudTexture *icon = GetIcon( tex->szShortName );
if ( !icon )
continue;
// Update file
Q_strncpy( icon->szTextureFile, tex->szTextureFile, sizeof( icon->szTextureFile ) );
if ( !icon->bRenderUsingFont )
{
// Update subrect
icon->rc = tex->rc;
// Keep existing texture id, but now update texture file and texture coordinates
vgui::surface()->DrawSetTextureFile( icon->textureId, icon->szTextureFile, false, false );
// Get new texture dimensions in case it changed
int wide, tall;
vgui::surface()->DrawGetTextureSize( icon->textureId, wide, tall );
// Assign coords
icon->texCoords[ 0 ] = (float)(icon->rc.left + 0.5f) / (float)wide;
icon->texCoords[ 1 ] = (float)(icon->rc.top + 0.5f) / (float)tall;
icon->texCoords[ 2 ] = (float)(icon->rc.right - 0.5f) / (float)wide;
icon->texCoords[ 3 ] = (float)(icon->rc.bottom - 0.5f) / (float)tall;
}
}
FreeHudTextureList( textureList );
// fixup all the font icons
vgui::HScheme scheme = vgui::scheme()->GetScheme( "ClientScheme" );
for (int i = m_Icons.First(); m_Icons.IsValidIndex(i); i = m_Icons.Next(i))
{
CHudTexture *icon = m_Icons[i];
if ( !icon )
continue;
// Update file
if ( icon->bRenderUsingFont )
{
icon->hFont = vgui::scheme()->GetIScheme(scheme)->GetFont( icon->szTextureFile, true );
icon->rc.top = 0;
icon->rc.left = 0;
icon->rc.right = vgui::surface()->GetCharacterWidth( icon->hFont, icon->cCharacterInFont );
icon->rc.bottom = vgui::surface()->GetFontTall( icon->hFont );
}
}
}
static CHudIcons g_HudIcons;
CHudIcons &HudIcons()
{
return g_HudIcons;
}

View File

@ -194,6 +194,37 @@ private:
extern CHud gHUD;
//-----------------------------------------------------------------------------
// Purpose: CHudIcons
//-----------------------------------------------------------------------------
class CHudIcons
{
public:
CHudIcons();
~CHudIcons();
void Init();
void Shutdown();
CHudTexture *GetIcon( const char *szIcon );
// loads a new icon into the list, without duplicates
CHudTexture *AddUnsearchableHudIconToList( CHudTexture& texture );
CHudTexture *AddSearchableHudIconToList( CHudTexture& texture );
void RefreshHudTextures();
private:
void SetupNewHudTexture( CHudTexture *t );
bool m_bHudTexturesLoaded;
// Global list of known icons
CUtlDict< CHudTexture *, int > m_Icons;
};
CHudIcons &HudIcons();
//-----------------------------------------------------------------------------
// Global fonts used in the client DLL
//-----------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,184 @@
//====== Copyright © 1996-2008, Valve Corporation, All rights reserved. =======
//
// Purpose: Add entities to this system, and the Locator will maintain an arrow
// on the HUD that points to the entities when they are offscreen.
//
//=============================================================================
#ifndef L4D_HUD_LOCATOR_H
#define L4D_HUD_LOCATOR_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/PHandle.h"
#define MAX_LOCATOR_BINDINGS_SHOWN 8
#define MAX_LOCATOR_TARGETS 10
#define LOCATOR_FLAGS_NONE 0x00000000
#define LOCATOR_ICON_FX_NONE 0x00000000
#define LOCATOR_ICON_FX_PULSE_SLOW 0x00000001
#define LOCATOR_ICON_FX_PULSE_FAST 0x00000002
#define LOCATOR_ICON_FX_PULSE_URGENT 0x00000004
#define LOCATOR_ICON_FX_ALPHA_SLOW 0x00000008
#define LOCATOR_ICON_FX_ALPHA_FAST 0x00000010
#define LOCATOR_ICON_FX_ALPHA_URGENT 0x00000020
#define LOCATOR_ICON_FX_SHAKE_NARROW 0x00000040
#define LOCATOR_ICON_FX_SHAKE_WIDE 0x00000080
#define LOCATOR_ICON_FX_STATIC 0x00000100 // This icon draws at a fixed location on the HUD.
#define LOCATOR_ICON_FX_NO_OFFSCREEN 0x00000200
#define LOCATOR_ICON_FX_FORCE_CAPTION 0x00000400 // Always draw the caption, even when the icon is occluded.
#define LOCATOR_ICON_FX_FADE_OUT 0x00000800 // Set when deactivated so it can smoothly vanish
#define LOCATOR_ICON_FX_FADE_IN 0x00001000 // Set when activated so it can smoothly appear
#include "tier1/UtlSymbol.h"
// See comments in UtlSymbol on why this is useful
DECLARE_PRIVATE_SYMBOLTYPE( CGameInstructorSymbol );
//-----------------------------------------------------------------------------
// This class represents a single target to be tracked by the locator
//-----------------------------------------------------------------------------
class CLocatorTarget
{
public:
bool m_bOriginInScreenspace;
Vector m_vecOrigin; // The location in the world to draw on the locator
// ONLY the locator panel should fiddle with these fields.
bool m_isActive;
int m_serialNumber;
int m_frameLastUpdated;
bool m_bOnscreen;
bool m_bOccluded;
bool m_bVisible;
bool m_bIsDrawing;
float m_distFromPlayer;
CHudTexture *m_pIcon_onscreen;
CHudTexture *m_pIcon_offscreen;
int m_iBindingTick;
float m_flNextBindingTick;
float m_flNextOcclusionTest;
int m_iBindingChoicesCount;
const char *(m_pchBindingChoices[ MAX_LOCATOR_BINDINGS_SHOWN ]);
int m_iBindChoicesOriginalToken[ MAX_LOCATOR_BINDINGS_SHOWN ];
// Fields for drawing
int m_targetX; // screen X position of the actual target
int m_targetY; // screen Y position of the actual target
int m_iconX; // screen X position (top)
int m_iconY; // screen Y position (left)
int m_centerX; // screen X position (center)
int m_centerY; // screen Y position (center)
int m_wide; // draw width of icon (may be different from frame to frame as the icon's size animates, for instance)
int m_tall; // draw height of icon '' ''
float m_widthScale_onscreen; // for icons that are wider than standard
int m_alpha; //
float m_fadeStart; // time stamp when fade out started
float m_lerpStart; // time stamp when lerping started
float m_pulseStart; // time stamp when pulsing started
int m_declutterIndex; // sort order from the declutterer
int m_lastDeclutterIndex; // last sort order from the declutterer
int m_drawArrowDirection; // Whether to draw an arrow indicating this target is off-screen, also tells us which arrow to draw (left, up, etc.)
int m_captionWide; // How wide (pixels) my caption is.
bool m_bDrawControllerButton;
bool m_bDrawControllerButtonOffscreen;
int m_offsetX; // User-specified X offset which is applied in screenspace
int m_offsetY; // User-specified Y offset which is applied in screenspace
// Fields for interpolating icon position
float m_flTimeLerpDone; // How much time left before this icon arrives where it is supposed to be.
int m_lastXPos; // screen X position last frame
int m_lastYPos; // '' Y
CLocatorTarget( void );
void Activate( int serialNumber );
void Deactivate( bool bNoFade = false );
void Update();
int GetIconX( void );
int GetIconY( void );
int GetIconCenterX( void );
int GetIconCenterY( void );
int GetIconWidth( void );
int GetIconHeight( void );
void AddIconEffects( int add ) { m_iEffectsFlags |= add; }
void RemoveIconEffects( int remove ) { m_iEffectsFlags &= ~remove; }
int GetIconEffectsFlags() { return m_iEffectsFlags; }
void SetCaptionColor( Color col ) { m_captionColor = col; }
void SetCaptionColor( const char *pszCaptionColor );
bool IsStatic();
bool IsPresenting();
void StartTimedLerp();
void StartPresent();
void EndPresent();
void UpdateVguiTarget( void );
vgui::Panel *GetVguiTarget( void );
void SetVguiTargetName( const char *pchVguiTargetName );
const char *GetVguiTargetName( void ) { return m_szVguiTargetName.String(); }
void SetVguiTargetLookup( const char *pchVguiTargetLookup );
const char *GetVguiTargetLookup( void ) { return m_szVguiTargetLookup.String(); }
void SetVguiTargetEdge( int nVguiEdge );
int GetVguiTargetEdge( void ) const { return m_nVguiTargetEdge; }
void SetOnscreenIconTextureName( const char *pszTexture );
void SetOffscreenIconTextureName( const char *pszTexture );
void SetBinding( const char *pszBinding );
const char *UseBindingImage( char *pchIconTextureName, size_t bufSize );
const char *GetOnscreenIconTextureName() { return m_szOnscreenTexture.String(); }
const char *GetOffscreenIconTextureName() { return m_szOffscreenTexture.String(); }
const char *GetBinding() { return m_szBinding.String(); }
void SetVisible( bool bVisible );
bool IsVisible( void );
void SetCaptionText( const char *pszText, const char *pszParam );
const wchar_t *GetCaptionText( void ) { return (const wchar_t *)m_wszCaption.Base(); }
bool HasCaptionText( void ) { return m_wszCaption.Count() > 1; }
void DrawBindingName( const char *pchDrawName ) { m_pchDrawBindingName = pchDrawName; }
void DrawBindingNameOffscreen( const char *pchDrawName ) { m_pchDrawBindingNameOffscreen = pchDrawName; }
const char *DrawBindingName( void ) { return m_pchDrawBindingName; }
const char *DrawBindingNameOffscreen( void ) { return m_pchDrawBindingNameOffscreen; }
bool IsOnScreen() { return m_bOnscreen; }
bool IsOccluded() { return m_bOccluded; }
private:
CGameInstructorSymbol m_szVguiTargetName;
CGameInstructorSymbol m_szVguiTargetLookup;
vgui::DHANDLE<vgui::Panel> m_hVguiTarget;
int m_nVguiTargetEdge;
CGameInstructorSymbol m_szOnscreenTexture;
CGameInstructorSymbol m_szOffscreenTexture;
CGameInstructorSymbol m_szBinding;
bool m_bWasControllerLast;
const char *m_pchDrawBindingName;
const char *m_pchDrawBindingNameOffscreen;
int m_iEffectsFlags;
CUtlVector< wchar_t > m_wszCaption;
public:
Color m_captionColor;
#ifdef MAPBASE
Color m_bindingColor;
#endif
};
extern int Locator_AddTarget();
extern void Locator_RemoveTarget( int hTarget );
CLocatorTarget *Locator_GetTargetFromHandle( int hTarget );
void Locator_ComputeTargetIconPositionFromHandle( int hTarget );
#endif // L4D_HUD_LOCATOR_H

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose:
//

View File

@ -0,0 +1,226 @@
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: Recreates Portal 2 linked_portal_door functionality using SDK code only.
// (basically a combination of point_camera and func_reflective_glass)
//
// $NoKeywords: $
//===========================================================================//
#include "cbase.h"
#include "view_shared.h"
#include "viewrender.h"
#include "c_func_fake_worldportal.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
IMPLEMENT_CLIENTCLASS_DT( C_FuncFakeWorldPortal, DT_FuncFakeWorldPortal, CFuncFakeWorldPortal )
RecvPropEHandle( RECVINFO( m_hTargetPlane ) ),
RecvPropVector( RECVINFO( m_PlaneAngles ) ),
RecvPropInt( RECVINFO( m_iSkyMode ) ),
RecvPropFloat( RECVINFO( m_flScale ) ),
RecvPropString( RECVINFO( m_iszRenderTarget ) ),
RecvPropEHandle( RECVINFO( m_hFogController ) ),
END_RECV_TABLE()
//-----------------------------------------------------------------------------
// Globals
//-----------------------------------------------------------------------------
C_EntityClassList<C_FuncFakeWorldPortal> g_FakeWorldPortalList;
template<> C_FuncFakeWorldPortal *C_EntityClassList<C_FuncFakeWorldPortal>::m_pClassList = NULL;
C_FuncFakeWorldPortal* GetFakeWorldPortalList()
{
return g_FakeWorldPortalList.m_pClassList;
}
//-----------------------------------------------------------------------------
// Constructor, destructor
//-----------------------------------------------------------------------------
C_FuncFakeWorldPortal::C_FuncFakeWorldPortal()
{
m_iszRenderTarget[0] = '\0';
g_FakeWorldPortalList.Insert( this );
}
C_FuncFakeWorldPortal::~C_FuncFakeWorldPortal()
{
g_FakeWorldPortalList.Remove( this );
}
bool C_FuncFakeWorldPortal::ShouldDraw()
{
return true;
}
//-----------------------------------------------------------------------------
// Do we have a fake world portal in view?
//-----------------------------------------------------------------------------
C_FuncFakeWorldPortal *IsFakeWorldPortalInView( const CViewSetup& view, cplane_t &plane )
{
// Early out if no cameras
C_FuncFakeWorldPortal *pReflectiveGlass = GetFakeWorldPortalList();
if ( !pReflectiveGlass )
return NULL;
Frustum_t frustum;
GeneratePerspectiveFrustum( view.origin, view.angles, view.zNear, view.zFar, view.fov, view.m_flAspectRatio, frustum );
cplane_t localPlane;
Vector vecOrigin, vecWorld, vecDelta, vecForward;
AngleVectors( view.angles, &vecForward, NULL, NULL );
for ( ; pReflectiveGlass != NULL; pReflectiveGlass = pReflectiveGlass->m_pNext )
{
if ( pReflectiveGlass->IsDormant() )
continue;
if ( pReflectiveGlass->m_iViewHideFlags & (1 << CurrentViewID()) )
continue;
Vector vecMins, vecMaxs;
pReflectiveGlass->GetRenderBoundsWorldspace( vecMins, vecMaxs );
if ( R_CullBox( vecMins, vecMaxs, frustum ) )
continue;
const model_t *pModel = pReflectiveGlass->GetModel();
const matrix3x4_t& mat = pReflectiveGlass->EntityToWorldTransform();
int nCount = modelinfo->GetBrushModelPlaneCount( pModel );
for ( int i = 0; i < nCount; ++i )
{
modelinfo->GetBrushModelPlane( pModel, i, localPlane, &vecOrigin );
MatrixTransformPlane( mat, localPlane, plane ); // Transform to world space
VectorTransform( vecOrigin, mat, vecWorld );
if ( view.origin.Dot( plane.normal ) <= plane.dist ) // Check for view behind plane
continue;
VectorSubtract( vecWorld, view.origin, vecDelta ); // Backface cull
if ( vecDelta.Dot( plane.normal ) >= 0 )
continue;
// Must have valid plane
if ( !pReflectiveGlass->m_hTargetPlane )
continue;
return pReflectiveGlass;
}
}
return NULL;
}
//-----------------------------------------------------------------------------
// Iterates through fake world portals instead of just picking one
//-----------------------------------------------------------------------------
C_FuncFakeWorldPortal *NextFakeWorldPortal( C_FuncFakeWorldPortal *pStart, const CViewSetup& view, cplane_t &plane,
const Frustum_t &frustum )
{
// Early out if no cameras
C_FuncFakeWorldPortal *pReflectiveGlass = NULL;
if (!pStart)
pReflectiveGlass = GetFakeWorldPortalList();
else
pReflectiveGlass = pStart->m_pNext;
cplane_t localPlane;
Vector vecOrigin, vecWorld, vecDelta;
for ( ; pReflectiveGlass != NULL; pReflectiveGlass = pReflectiveGlass->m_pNext )
{
if ( pReflectiveGlass->IsDormant() )
continue;
if ( pReflectiveGlass->m_iViewHideFlags & (1 << CurrentViewID()) )
continue;
Vector vecMins, vecMaxs;
pReflectiveGlass->GetRenderBoundsWorldspace( vecMins, vecMaxs );
if ( R_CullBox( vecMins, vecMaxs, frustum ) )
continue;
const model_t *pModel = pReflectiveGlass->GetModel();
const matrix3x4_t& mat = pReflectiveGlass->EntityToWorldTransform();
int nCount = modelinfo->GetBrushModelPlaneCount( pModel );
for ( int i = 0; i < nCount; ++i )
{
modelinfo->GetBrushModelPlane( pModel, i, localPlane, &vecOrigin );
MatrixTransformPlane( mat, localPlane, plane ); // Transform to world space
VectorTransform( vecOrigin, mat, vecWorld );
if ( view.origin.Dot( plane.normal ) <= plane.dist ) // Check for view behind plane
continue;
VectorSubtract( vecWorld, view.origin, vecDelta ); // Backface cull
if ( vecDelta.Dot( plane.normal ) >= 0 )
continue;
// Must have valid plane
if ( !pReflectiveGlass->m_hTargetPlane )
continue;
return pReflectiveGlass;
}
}
return NULL;
}
void C_FuncFakeWorldPortal::OnDataChanged( DataUpdateType_t type )
{
// Reset render texture
m_pRenderTarget = NULL;
// Reset fog
m_pFog = NULL;
return BaseClass::OnDataChanged( type );
}
extern ITexture *GetWaterReflectionTexture( void );
ITexture *C_FuncFakeWorldPortal::RenderTarget()
{
if (m_iszRenderTarget[0] != '\0')
{
if (!m_pRenderTarget)
{
// We don't use a CTextureReference for this because we don't want to shut down the texture on removal/change
m_pRenderTarget = materials->FindTexture( m_iszRenderTarget, TEXTURE_GROUP_RENDER_TARGET );
}
if (m_pRenderTarget)
return m_pRenderTarget;
}
return GetWaterReflectionTexture();
}
fogparams_t *C_FuncFakeWorldPortal::GetFog()
{
if (m_pFog)
return m_pFog;
if (m_hFogController)
{
C_FogController *pFogController = dynamic_cast<C_FogController*>(m_hFogController.Get());
if (pFogController)
{
m_pFog = &pFogController->m_fog;
}
else
{
Warning("%s is not an env_fog_controller\n", m_hFogController->GetEntityName());
}
}
return NULL;
}

View File

@ -0,0 +1,64 @@
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: Recreates Portal 2 linked_portal_door functionality using SDK code only.
// (basically a combination of point_camera and func_reflective_glass)
//
// $NoKeywords: $
//===========================================================================//
#ifndef C_FUNC_FAKE_WORLDPORTAL
#define C_FUNC_FAKE_WORLDPORTAL
#ifdef _WIN32
#pragma once
#endif
struct cplane_t;
class CViewSetup;
class C_FuncFakeWorldPortal : public C_BaseEntity
{
public:
DECLARE_CLASS( C_FuncFakeWorldPortal, C_BaseEntity );
DECLARE_CLIENTCLASS();
C_FuncFakeWorldPortal();
virtual ~C_FuncFakeWorldPortal();
virtual bool ShouldDraw();
virtual void OnDataChanged( DataUpdateType_t type );
SkyboxVisibility_t SkyMode() { return m_iSkyMode; }
ITexture *RenderTarget();
fogparams_t *GetFog();
public:
EHANDLE m_hTargetPlane;
QAngle m_PlaneAngles;
SkyboxVisibility_t m_iSkyMode;
float m_flScale;
EHANDLE m_hFogController;
fogparams_t *m_pFog;
char m_iszRenderTarget[64];
ITexture *m_pRenderTarget;
C_FuncFakeWorldPortal *m_pNext;
};
//-----------------------------------------------------------------------------
// Do we have reflective glass in view? If so, what's the reflection plane?
//-----------------------------------------------------------------------------
C_FuncFakeWorldPortal *IsFakeWorldPortalInView( const CViewSetup& view, cplane_t &plane );
C_FuncFakeWorldPortal *NextFakeWorldPortal( C_FuncFakeWorldPortal *pStart, const CViewSetup& view, cplane_t &plane,
const Frustum_t &frustum );
#endif // C_FUNC_FAKE_WORLDPORTAL

View File

@ -0,0 +1,103 @@
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: Mapbase off-shoot of tf_glow (created using SDK code only)
//
//===========================================================================//
#include "cbase.h"
#include "glow_outline_effect.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
class C_PointGlow : public C_BaseEntity
{
public:
DECLARE_CLASS( C_PointGlow, C_BaseEntity );
DECLARE_CLIENTCLASS();
~C_PointGlow();
enum
{
GLOW_VIS_ALWAYS,
GLOW_VIS_NOT_WHEN_VISIBLE,
GLOW_VIS_ONLY_WHEN_VISIBLE,
};
void OnDataChanged( DataUpdateType_t type );
CGlowObject *GetGlowObject( void ){ return m_pGlowEffect; }
void UpdateGlowEffect( void );
void DestroyGlowEffect( void );
EHANDLE m_hGlowTarget;
color32 m_GlowColor;
bool m_bGlowDisabled;
CGlowObject *m_pGlowEffect;
};
IMPLEMENT_CLIENTCLASS_DT( C_PointGlow, DT_PointGlow, CPointGlow )
RecvPropEHandle( RECVINFO( m_hGlowTarget ) ),
RecvPropInt( RECVINFO( m_GlowColor ), 0, RecvProxy_IntToColor32 ),
RecvPropBool( RECVINFO( m_bGlowDisabled ) ),
END_RECV_TABLE()
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
C_PointGlow::~C_PointGlow()
{
DestroyGlowEffect();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_PointGlow::OnDataChanged( DataUpdateType_t updateType )
{
BaseClass::OnDataChanged( updateType );
UpdateGlowEffect();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_PointGlow::UpdateGlowEffect( void )
{
// destroy the existing effect
if ( m_pGlowEffect )
{
DestroyGlowEffect();
}
// create a new effect
if ( !m_bGlowDisabled )
{
Vector4D vecColor( m_GlowColor.r, m_GlowColor.g, m_GlowColor.b, m_GlowColor.a );
for (int i = 0; i < 4; i++)
{
if (vecColor[i] == 0.0f)
continue;
vecColor[i] /= 255.0f;
}
m_pGlowEffect = new CGlowObject( m_hGlowTarget, vecColor.AsVector3D(), vecColor.w, true );
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_PointGlow::DestroyGlowEffect( void )
{
if ( m_pGlowEffect )
{
delete m_pGlowEffect;
m_pGlowEffect = NULL;
}
}

View File

@ -126,6 +126,9 @@ ConVar gl_clear( "gl_clear", "0");
ConVar gl_clear_randomcolor( "gl_clear_randomcolor", "0", FCVAR_CHEAT, "Clear the back buffer to random colors every frame. Helps spot open seams in geometry." );
static ConVar r_farz( "r_farz", "-1", FCVAR_CHEAT, "Override the far clipping plane. -1 means to use the value in env_fog_controller." );
#ifdef MAPBASE
static ConVar r_nearz( "r_nearz", "-1", FCVAR_CHEAT, "Override the near clipping plane. -1 means to use the default value (usually 7)." );
#endif
static ConVar cl_demoviewoverride( "cl_demoviewoverride", "0", 0, "Override view during demo playback" );
@ -602,6 +605,11 @@ static QAngle s_DbgSetupAngles;
//-----------------------------------------------------------------------------
float CViewRender::GetZNear()
{
#ifdef MAPBASE
if (r_nearz.GetFloat() > 0)
return r_nearz.GetFloat();
#endif
return VIEW_NEARZ;
}

View File

@ -74,6 +74,10 @@
#include "c_point_camera.h"
#endif // USE_MONITORS
#ifdef MAPBASE
#include "mapbase/c_func_fake_worldportal.h"
#endif
// Projective textures
#include "C_Env_Projected_Texture.h"
@ -119,6 +123,10 @@ static ConVar r_drawtranslucentrenderables( "r_drawtranslucentrenderables", "1",
static ConVar r_drawopaquerenderables( "r_drawopaquerenderables", "1", FCVAR_CHEAT );
static ConVar r_threaded_renderables( "r_threaded_renderables", "0" );
#ifdef MAPBASE
static ConVar r_skybox_use_complex_views( "r_skybox_use_complex_views", "0", FCVAR_CHEAT, "Enable complex views in skyboxes, like reflective glass" );
#endif
// FIXME: This is not static because we needed to turn it off for TF2 playtests
ConVar r_DrawDetailProps( "r_DrawDetailProps", "1", FCVAR_NONE, "0=Off, 1=Normal, 2=Wireframe" );
@ -172,6 +180,10 @@ extern ConVar cl_leveloverview;
extern ConVar localplayer_visionflags;
#ifdef MAPBASE
static ConVar r_nearz_skybox( "r_nearz_skybox", "2.0", FCVAR_CHEAT );
#endif
//-----------------------------------------------------------------------------
// Globals
//-----------------------------------------------------------------------------
@ -484,6 +496,11 @@ protected:
void SSAO_DepthPass();
void DrawDepthOfField();
#ifdef MAPBASE
virtual ITexture *GetRefractionTexture() { return GetWaterRefractionTexture(); }
virtual ITexture *GetReflectionTexture() { return GetWaterReflectionTexture(); }
#endif
};
@ -670,6 +687,11 @@ public:
void Draw();
cplane_t m_ReflectionPlane;
#ifdef MAPBASE
ITexture *GetReflectionTexture() { return m_pRenderTarget; }
ITexture *m_pRenderTarget;
#endif
};
class CRefractiveGlassView : public CSimpleWorldView
@ -687,6 +709,11 @@ public:
void Draw();
cplane_t m_ReflectionPlane;
#ifdef MAPBASE
ITexture *GetRefractionTexture() { return m_pRenderTarget; }
ITexture *m_pRenderTarget;
#endif
};
@ -1969,6 +1996,27 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT
{
CViewSetup viewMiddle = GetView( STEREO_EYE_MONO );
DrawMonitors( viewMiddle );
#ifdef MAPBASE
// Any fake world portals?
Frustum_t frustum;
GeneratePerspectiveFrustum( view.origin, view.angles, view.zNear, view.zFar, view.fov, view.m_flAspectRatio, frustum );
cplane_t portalPlane;
//C_FuncFakeWorldPortal *pPortalEnt = IsFakeWorldPortalInView( view, portalPlane );
//if ( pPortalEnt )
C_FuncFakeWorldPortal *pPortalEnt = NextFakeWorldPortal( NULL, view, portalPlane, frustum );
while ( pPortalEnt != NULL )
{
ITexture *pCameraTarget = pPortalEnt->RenderTarget();
int width = pCameraTarget->GetActualWidth();
int height = pCameraTarget->GetActualHeight();
DrawFakeWorldPortal( pCameraTarget, pPortalEnt, viewMiddle, C_BasePlayer::GetLocalPlayer(), 0, 0, width, height, view, portalPlane );
pPortalEnt = NextFakeWorldPortal( pPortalEnt, view, portalPlane, frustum );
}
#endif
}
#endif
@ -2593,6 +2641,34 @@ void CViewRender::DrawWorldAndEntities( bool bDrawSkybox, const CViewSetup &view
{
tmZone( TELEMETRY_LEVEL0, TMZF_NONE, "bCheapWater" );
cplane_t glassReflectionPlane;
#ifdef MAPBASE
// New expansions allow for custom render targets and multiple mirror renders
Frustum_t frustum;
GeneratePerspectiveFrustum( viewIn.origin, viewIn.angles, viewIn.zNear, viewIn.zFar, viewIn.fov, viewIn.m_flAspectRatio, frustum );
ITexture *pTextureTargets[2];
C_BaseEntity *pReflectiveGlass = NextReflectiveGlass( NULL, viewIn, glassReflectionPlane, frustum, pTextureTargets );
while ( pReflectiveGlass != NULL )
{
if (pTextureTargets[0])
{
CRefPtr<CReflectiveGlassView> pGlassReflectionView = new CReflectiveGlassView( this );
pGlassReflectionView->m_pRenderTarget = pTextureTargets[0];
pGlassReflectionView->Setup( viewIn, VIEW_CLEAR_DEPTH | VIEW_CLEAR_COLOR, bDrawSkybox, fogVolumeInfo, info, glassReflectionPlane );
AddViewToScene( pGlassReflectionView );
}
if (pTextureTargets[1])
{
CRefPtr<CRefractiveGlassView> pGlassRefractionView = new CRefractiveGlassView( this );
pGlassRefractionView->Setup( viewIn, VIEW_CLEAR_DEPTH | VIEW_CLEAR_COLOR, bDrawSkybox, fogVolumeInfo, info, glassReflectionPlane );
pGlassRefractionView->m_pRenderTarget = pTextureTargets[1];
AddViewToScene( pGlassRefractionView );
}
pReflectiveGlass = NextReflectiveGlass( pReflectiveGlass, viewIn, glassReflectionPlane, frustum, pTextureTargets );
}
#else
if ( IsReflectiveGlassInView( viewIn, glassReflectionPlane ) )
{
CRefPtr<CReflectiveGlassView> pGlassReflectionView = new CReflectiveGlassView( this );
@ -2603,6 +2679,7 @@ void CViewRender::DrawWorldAndEntities( bool bDrawSkybox, const CViewSetup &view
pGlassRefractionView->Setup( viewIn, VIEW_CLEAR_DEPTH | VIEW_CLEAR_COLOR, bDrawSkybox, fogVolumeInfo, info, glassReflectionPlane );
AddViewToScene( pGlassRefractionView );
}
#endif
CRefPtr<CSimpleWorldView> pNoWaterView = new CSimpleWorldView( this );
pNoWaterView->Setup( viewIn, nClearFlags, bDrawSkybox, fogVolumeInfo, info, pCustomVisibility );
@ -3321,6 +3398,199 @@ bool CViewRender::DrawOneMonitor( ITexture *pRenderTarget, int cameraNum, C_Poin
return true;
}
#ifdef MAPBASE
ConVar r_fakeworldportal_debug("r_fakeworldportal_debug", "0");
//-----------------------------------------------------------------------------
// Purpose: Sets up scene and renders WIP fake world portal view.
// Based on code from monitors, mirrors, and 3D skyboxes.
// It's also terrible right now.
//
// Input : cameraNum -
// &cameraView
// *localPlayer -
// x -
// y -
// width -
// height -
// highend -
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CViewRender::DrawFakeWorldPortal( ITexture *pRenderTarget, C_FuncFakeWorldPortal *pCameraEnt, const CViewSetup &cameraView, C_BasePlayer *localPlayer,
int x, int y, int width, int height,
const CViewSetup &mainView, cplane_t &ourPlane )
{
#ifdef USE_MONITORS
VPROF_INCREMENT_COUNTER( "cameras rendered", 1 );
// Setup fog state for the camera.
fogparams_t oldFogParams;
float flOldZFar = 0.0f;
// If fog should be disabled instead of using the player's controller, a blank fog controller can just be used
bool fogEnabled = true; //pCameraEnt->IsFogEnabled();
CViewSetup monitorView = cameraView;
fogparams_t *pFogParams = NULL;
if ( fogEnabled )
{
if ( !localPlayer )
return false;
pFogParams = localPlayer->GetFogParams();
// Save old fog data.
oldFogParams = *pFogParams;
if ( pCameraEnt->GetFog() )
{
*pFogParams = *pCameraEnt->GetFog();
}
}
monitorView.width = width;
monitorView.height = height;
monitorView.x = x;
monitorView.y = y;
monitorView.origin = mainView.origin;
monitorView.angles = mainView.angles;
// Temporary debug stuff
static float flLastDebugTime = 0.0f;
bool bDebug = r_fakeworldportal_debug.GetBool() && gpGlobals->curtime > flLastDebugTime;
QAngle angTargetAngles = pCameraEnt->m_hTargetPlane->GetAbsAngles() + pCameraEnt->m_PlaneAngles;
// RED - First origin
if (bDebug)
debugoverlay->AddBoxOverlay( monitorView.origin, Vector(-32,-32,-32), Vector(32,32,32), monitorView.angles, 255, 0, 0, 128, 10.0f );
// Make sure the origin and angles are relative to the target plane
monitorView.origin -= pCameraEnt->GetAbsOrigin();
// scale origin by sky scale
if ( pCameraEnt->m_flScale > 0 )
{
float scale = 1.0f / pCameraEnt->m_flScale;
VectorScale( monitorView.origin, scale, monitorView.origin );
}
// YELLOW - Main origin
if (bDebug)
debugoverlay->AddBoxOverlay( pCameraEnt->GetAbsOrigin(), Vector(-32,-32,-32), Vector(32,32,32), monitorView.angles, 255, 224, 0, 128, 10.0f );
// Make sure our angles are relative to the main plane, just like the origin
QAngle angOurAngles;
VectorAngles( ourPlane.normal * -1, angOurAngles );
//angles -= angOurAngles;
// First, create a matrix for the sky's angles.
matrix3x4_t matSkyAngles;
AngleMatrix( angTargetAngles - angOurAngles, matSkyAngles );
Vector vecSkyForward, vecSkyRight, vecSkyUp;
// Get vectors from our original angles.
Vector vPlayerForward, vPlayerRight, vPlayerUp;
AngleVectors( monitorView.angles, &vPlayerForward, &vPlayerRight, &vPlayerUp );
VectorTransform( vPlayerForward, matSkyAngles, vecSkyForward );
VectorTransform( vPlayerRight, matSkyAngles, vecSkyRight );
VectorTransform( vPlayerUp, matSkyAngles, vecSkyUp );
// Normalize them.
VectorNormalize( vecSkyForward );
VectorNormalize( vecSkyRight );
VectorNormalize( vecSkyUp );
Quaternion quat;
BasisToQuaternion( vecSkyForward, vecSkyRight, vecSkyUp, quat );
QuaternionAngles( quat, monitorView.angles );
// End of code mostly lifted from projected texture screenspace stuff
// ----------------------------------------------------------------------
// Now just rotate our origin with that matrix.
// We create a copy of the origin since VectorRotate doesn't want in1 to be the same variable as the destination.
VectorRotate(Vector(monitorView.origin), matSkyAngles, monitorView.origin);
// BLUE - Target origin
if (bDebug)
debugoverlay->AddBoxOverlay( pCameraEnt->m_hTargetPlane->GetAbsOrigin(), Vector(-32,-32,-32), Vector(32,32,32), monitorView.angles, 0, 0, 255, 128, 10.0f );
monitorView.origin += pCameraEnt->m_hTargetPlane->GetAbsOrigin();
// GREEN - Final origin
if (bDebug)
{
debugoverlay->AddBoxOverlay( monitorView.origin, Vector(-32,-32,-32), Vector(32,32,32), monitorView.angles, 0, 255, 0, 128, 10.0f );
flLastDebugTime = gpGlobals->curtime + 5.0f;
}
monitorView.fov = mainView.fov;
monitorView.m_bOrtho = false;
monitorView.m_flAspectRatio = 0.0f;
monitorView.m_bViewToProjectionOverride = false;
// @MULTICORE (toml 8/11/2006): this should be a renderer....
int nClearFlags = (VIEW_CLEAR_DEPTH | VIEW_CLEAR_COLOR | VIEW_CLEAR_OBEY_STENCIL);
bool bDrew3dSkybox = false;
SkyboxVisibility_t nSkyMode = pCameraEnt->SkyMode();
Frustum frustum;
render->Push3DView( monitorView, nClearFlags, pRenderTarget, (VPlane *)frustum );
//
// Monitor sky handling
//
if ( pCameraEnt->SkyMode() == SKYBOX_3DSKYBOX_VISIBLE )
{
// if the 3d skybox world is drawn, then don't draw the normal skybox
CSkyboxView *pSkyView = new CSkyboxView( this );
if ( ( bDrew3dSkybox = pSkyView->Setup( monitorView, &nClearFlags, &nSkyMode ) ) != false )
{
AddViewToScene( pSkyView );
}
SafeRelease( pSkyView );
}
Vector4D plane;
// Combine the target angles and the plane angles
Vector vecAnglesNormal( angTargetAngles.x, angTargetAngles.y, angTargetAngles.z );
VectorNormalize( vecAnglesNormal );
VectorCopy( vecAnglesNormal, plane.AsVector3D() );
// TODO: How do we get a good value for this!?!?
//plane.w = m_OurPlane.dist + 0.1f;
plane.w = -32.0f + 0.1f;
CMatRenderContextPtr pRenderContext( materials );
pRenderContext->PushCustomClipPlane( plane.Base() );
ViewDrawScene( bDrew3dSkybox, nSkyMode, monitorView, nClearFlags, VIEW_MONITOR );
pRenderContext->PopCustomClipPlane();
render->PopView( frustum );
// Reset the world fog parameters.
if ( fogEnabled )
{
if ( pFogParams )
{
*pFogParams = oldFogParams;
}
monitorView.zFar = flOldZFar;
}
#endif // USE_MONITORS
return true;
}
#endif
void CViewRender::DrawMonitors( const CViewSetup &cameraView )
{
#ifdef PORTAL
@ -3354,6 +3624,17 @@ void CViewRender::DrawMonitors( const CViewSetup &cameraView )
if ( !pCameraEnt->IsActive() || pCameraEnt->IsDormant() )
continue;
#ifdef MAPBASE
// Check if the camera has its own render target
// (Multiple render target support)
if ( pCameraTarget != pCameraEnt->RenderTarget() )
{
pCameraTarget = pCameraEnt->RenderTarget();
width = pCameraTarget->GetActualWidth();
height = pCameraTarget->GetActualHeight();
}
#endif
if ( !DrawOneMonitor( pCameraTarget, cameraNum, pCameraEnt, cameraView, player, 0, 0, width, height ) )
continue;
@ -4949,8 +5230,9 @@ void CSkyboxView::DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostR
// if you can get really close to the skybox geometry it's possible that you'll be able to clip into it
// with this near plane. If so, move it in a bit. It's at 2.0 to give us more precision. That means you
// need to keep the eye position at least 2 * scale away from the geometry in the skybox
zNear = 2.0;
#ifdef MAPBASE
zNear = r_nearz_skybox.GetFloat();
// Use the fog's farz if specified
if (m_pSky3dParams->fog.farz > 0)
{
@ -4959,6 +5241,8 @@ void CSkyboxView::DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostR
m_pSky3dParams->fog.farz );
}
else
#else
zNear = 2.0;
#endif
zFar = MAX_TRACE_LENGTH;
@ -5040,6 +5324,51 @@ void CSkyboxView::DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostR
DrawTranslucentRenderables( true, false );
DrawNoZBufferTranslucentRenderables();
#ifdef MAPBASE
// Allows reflective glass to be drawn in the skybox.
// New expansions also allow for custom render targets and multiple mirror renders
if (r_skybox_use_complex_views.GetBool())
{
VisibleFogVolumeInfo_t fogVolumeInfo;
render->GetVisibleFogVolume( origin, &fogVolumeInfo );
WaterRenderInfo_t info;
info.m_bCheapWater = true;
info.m_bRefract = false;
info.m_bReflect = false;
info.m_bReflectEntities = false;
info.m_bDrawWaterSurface = false;
info.m_bOpaqueWater = true;
cplane_t glassReflectionPlane;
Frustum_t frustum;
GeneratePerspectiveFrustum( origin, angles, zNear, zFar, fov, m_flAspectRatio, frustum );
ITexture *pTextureTargets[2];
C_BaseEntity *pReflectiveGlass = NextReflectiveGlass( NULL, (*this), glassReflectionPlane, frustum, pTextureTargets );
while ( pReflectiveGlass != NULL )
{
if (pTextureTargets[0])
{
CRefPtr<CReflectiveGlassView> pGlassReflectionView = new CReflectiveGlassView( m_pMainView );
pGlassReflectionView->m_pRenderTarget = pTextureTargets[0];
pGlassReflectionView->Setup( (*this), VIEW_CLEAR_DEPTH, true, fogVolumeInfo, info, glassReflectionPlane );
m_pMainView->AddViewToScene( pGlassReflectionView );
}
if (pTextureTargets[1])
{
CRefPtr<CRefractiveGlassView> pGlassRefractionView = new CRefractiveGlassView( m_pMainView );
pGlassRefractionView->m_pRenderTarget = pTextureTargets[1];
pGlassRefractionView->Setup( (*this), VIEW_CLEAR_DEPTH, true, fogVolumeInfo, info, glassReflectionPlane );
m_pMainView->AddViewToScene( pGlassRefractionView );
}
pReflectiveGlass = NextReflectiveGlass( pReflectiveGlass, (*this), glassReflectionPlane, frustum, pTextureTargets );
}
}
#endif
m_pMainView->DisableFog();
CGlowOverlay::UpdateSkyOverlays( zFar, m_bCacheFullSceneState );
@ -5423,7 +5752,7 @@ bool CBaseWorldView::AdjustView( float waterHeight )
{
if( m_DrawFlags & DF_RENDER_REFRACTION )
{
ITexture *pTexture = GetWaterRefractionTexture();
ITexture *pTexture = GetRefractionTexture();
// Use the aspect ratio of the main view! So, don't recompute it here
x = y = 0;
@ -5435,7 +5764,7 @@ bool CBaseWorldView::AdjustView( float waterHeight )
if( m_DrawFlags & DF_RENDER_REFLECTION )
{
ITexture *pTexture = GetWaterReflectionTexture();
ITexture *pTexture = GetReflectionTexture();
// If the main view is overriding the projection matrix (for Stereo or
// some other nefarious purpose) make sure to include any Y offset in
@ -5497,14 +5826,14 @@ void CBaseWorldView::PushView( float waterHeight )
pRenderContext->SetHeightClipMode( clipMode );
// Have to re-set up the view since we reset the size
render->Push3DView( *this, m_ClearFlags, GetWaterRefractionTexture(), GetFrustum() );
render->Push3DView( *this, m_ClearFlags, GetRefractionTexture(), GetFrustum() );
return;
}
if( m_DrawFlags & DF_RENDER_REFLECTION )
{
ITexture *pTexture = GetWaterReflectionTexture();
ITexture *pTexture = GetReflectionTexture();
pRenderContext->SetFogZ( waterHeight );
@ -5558,11 +5887,11 @@ void CBaseWorldView::PopView()
// these renders paths used their surfaces, so blit their results
if ( m_DrawFlags & DF_RENDER_REFRACTION )
{
pRenderContext->CopyRenderTargetToTextureEx( GetWaterRefractionTexture(), NULL, NULL );
pRenderContext->CopyRenderTargetToTextureEx( GetRefractionTexture(), NULL, NULL );
}
if ( m_DrawFlags & DF_RENDER_REFLECTION )
{
pRenderContext->CopyRenderTargetToTextureEx( GetWaterReflectionTexture(), NULL, NULL );
pRenderContext->CopyRenderTargetToTextureEx( GetReflectionTexture(), NULL, NULL );
}
}
@ -6439,7 +6768,11 @@ void CReflectiveGlassView::Setup( const CViewSetup &view, int nClearFlags, bool
bool CReflectiveGlassView::AdjustView( float flWaterHeight )
{
#ifdef MAPBASE
ITexture *pTexture = GetReflectionTexture();
#else
ITexture *pTexture = GetWaterReflectionTexture();
#endif
// Use the aspect ratio of the main view! So, don't recompute it here
x = y = 0;
@ -6465,7 +6798,11 @@ bool CReflectiveGlassView::AdjustView( float flWaterHeight )
void CReflectiveGlassView::PushView( float waterHeight )
{
#ifdef MAPBASE
render->Push3DView( *this, m_ClearFlags, GetReflectionTexture(), GetFrustum() );
#else
render->Push3DView( *this, m_ClearFlags, GetWaterReflectionTexture(), GetFrustum() );
#endif
Vector4D plane;
VectorCopy( m_ReflectionPlane.normal, plane.AsVector3D() );
@ -6531,7 +6868,11 @@ void CRefractiveGlassView::Setup( const CViewSetup &view, int nClearFlags, bool
bool CRefractiveGlassView::AdjustView( float flWaterHeight )
{
#ifdef MAPBASE
ITexture *pTexture = GetRefractionTexture();
#else
ITexture *pTexture = GetWaterRefractionTexture();
#endif
// Use the aspect ratio of the main view! So, don't recompute it here
x = y = 0;
@ -6543,7 +6884,11 @@ bool CRefractiveGlassView::AdjustView( float flWaterHeight )
void CRefractiveGlassView::PushView( float waterHeight )
{
#ifdef MAPBASE
render->Push3DView( *this, m_ClearFlags, GetRefractionTexture(), GetFrustum() );
#else
render->Push3DView( *this, m_ClearFlags, GetWaterRefractionTexture(), GetFrustum() );
#endif
Vector4D plane;
VectorMultiply( m_ReflectionPlane.normal, -1, plane.AsVector3D() );

View File

@ -37,6 +37,10 @@ class CReplayScreenshotTaker;
class CStunEffect;
#endif // HL2_EPISODIC
#ifdef MAPBASE
class C_FuncFakeWorldPortal;
#endif
//-----------------------------------------------------------------------------
// Data specific to intro mode to control rendering.
//-----------------------------------------------------------------------------
@ -447,6 +451,12 @@ private:
bool DrawOneMonitor( ITexture *pRenderTarget, int cameraNum, C_PointCamera *pCameraEnt, const CViewSetup &cameraView, C_BasePlayer *localPlayer,
int x, int y, int width, int height );
#ifdef MAPBASE
bool DrawFakeWorldPortal( ITexture *pRenderTarget, C_FuncFakeWorldPortal *pCameraEnt, const CViewSetup &cameraView, C_BasePlayer *localPlayer,
int x, int y, int width, int height,
const CViewSetup &mainView, cplane_t &ourPlane );
#endif
// Drawing primitives
bool ShouldDrawViewModel( bool drawViewmodel );
void DrawViewModels( const CViewSetup &view, bool drawViewmodel );

View File

@ -496,11 +496,13 @@ bool VScriptClientInit()
#ifdef MAPBASE_VSCRIPT
g_pScriptVM->RegisterAllClasses();
g_pScriptVM->RegisterAllEnums();
g_pScriptVM->RegisterInstance( &g_ScriptEntityIterator, "Entities" );
IGameSystem::RegisterVScriptAllSystems();
RegisterSharedScriptConstants();
RegisterSharedScriptFunctions();
#else
//g_pScriptVM->RegisterInstance( &g_ScriptEntityIterator, "Entities" );

View File

@ -91,11 +91,15 @@ BEGIN_DATADESC( CSkyCamera )
DEFINE_INPUTFUNC( FIELD_VOID, "TurnOffFog", InputTurnOffFog ),
DEFINE_INPUTFUNC( FIELD_COLOR32, "SetFogColor", InputSetFogColor ),
DEFINE_INPUTFUNC( FIELD_COLOR32, "SetFogColorSecondary", InputSetFogColorSecondary ),
DEFINE_INPUTFUNC( FIELD_EHANDLE, "CopyFogController", InputCopyFogController ),
DEFINE_INPUTFUNC( FIELD_EHANDLE, "CopyFogControllerWithScale", InputCopyFogControllerWithScale ),
DEFINE_INPUTFUNC( FIELD_INTEGER, "SetFarZ", InputSetFarZ ),
DEFINE_INPUTFUNC( FIELD_COLOR32, "SetSkyColor", InputSetSkyColor ),
DEFINE_INPUTFUNC( FIELD_INTEGER, "SetScale", InputSetScale ),
DEFINE_THINKFUNC( UpdateThink ),
#endif
@ -259,7 +263,7 @@ bool CSkyCamera::DoUpdate( bool bUpdateData )
// this thinking is only used to update area and other parameters
// Getting into another area is unlikely, but if it's not expensive, I guess it's okay.
int area = engine->GetArea( m_skyboxData.origin );
int area = engine->GetArea( GetAbsOrigin() );
if (m_skyboxData.area != area)
{
m_skyboxData.area = area;
@ -407,4 +411,52 @@ void CSkyCamera::InputSetFogColor( inputdata_t &inputdata ) { m_skyboxData.fog.c
void CSkyCamera::InputSetFogColorSecondary( inputdata_t &inputdata ) { m_skyboxData.fog.colorSecondary = inputdata.value.Color32(); }
void CSkyCamera::InputSetFarZ( inputdata_t &inputdata ) { m_skyboxData.fog.farz = inputdata.value.Int(); }
void CSkyCamera::InputCopyFogController( inputdata_t &inputdata )
{
CFogController *pFogController = dynamic_cast<CFogController*>(inputdata.value.Entity().Get());
if (!pFogController)
return;
m_skyboxData.fog.dirPrimary = pFogController->m_fog.dirPrimary;
m_skyboxData.fog.colorPrimary = pFogController->m_fog.colorPrimary;
m_skyboxData.fog.colorSecondary = pFogController->m_fog.colorSecondary;
//m_skyboxData.fog.colorPrimaryLerpTo = pFogController->m_fog.colorPrimaryLerpTo;
//m_skyboxData.fog.colorSecondaryLerpTo = pFogController->m_fog.colorSecondaryLerpTo;
m_skyboxData.fog.start = pFogController->m_fog.start;
m_skyboxData.fog.end = pFogController->m_fog.end;
m_skyboxData.fog.farz = pFogController->m_fog.farz;
m_skyboxData.fog.maxdensity = pFogController->m_fog.maxdensity;
//m_skyboxData.fog.startLerpTo = pFogController->m_fog.startLerpTo;
//m_skyboxData.fog.endLerpTo = pFogController->m_fog.endLerpTo;
//m_skyboxData.fog.lerptime = pFogController->m_fog.lerptime;
//m_skyboxData.fog.duration = pFogController->m_fog.duration;
//m_skyboxData.fog.enable = pFogController->m_fog.enable;
m_skyboxData.fog.blend = pFogController->m_fog.blend;
}
void CSkyCamera::InputCopyFogControllerWithScale( inputdata_t &inputdata )
{
CFogController *pFogController = dynamic_cast<CFogController*>(inputdata.value.Entity().Get());
if (!pFogController)
return;
m_skyboxData.fog.dirPrimary = pFogController->m_fog.dirPrimary;
m_skyboxData.fog.colorPrimary = pFogController->m_fog.colorPrimary;
m_skyboxData.fog.colorSecondary = pFogController->m_fog.colorSecondary;
//m_skyboxData.fog.colorPrimaryLerpTo = pFogController->m_fog.colorPrimaryLerpTo;
//m_skyboxData.fog.colorSecondaryLerpTo = pFogController->m_fog.colorSecondaryLerpTo;
m_skyboxData.fog.start = pFogController->m_fog.start * m_skyboxData.scale;
m_skyboxData.fog.end = pFogController->m_fog.end * m_skyboxData.scale;
m_skyboxData.fog.farz = pFogController->m_fog.farz != -1 ? (pFogController->m_fog.farz * m_skyboxData.scale) : pFogController->m_fog.farz;
m_skyboxData.fog.maxdensity = pFogController->m_fog.maxdensity;
//m_skyboxData.fog.startLerpTo = pFogController->m_fog.startLerpTo;
//m_skyboxData.fog.endLerpTo = pFogController->m_fog.endLerpTo;
//m_skyboxData.fog.lerptime = pFogController->m_fog.lerptime;
//m_skyboxData.fog.duration = pFogController->m_fog.duration;
//m_skyboxData.fog.enable = pFogController->m_fog.enable;
m_skyboxData.fog.blend = pFogController->m_fog.blend;
}
#endif

View File

@ -72,10 +72,14 @@ public:
void InputSetFogColor( inputdata_t &data );
void InputSetFogColorSecondary( inputdata_t &data );
void InputSetFogMaxDensity( inputdata_t &inputdata );
void InputCopyFogController( inputdata_t &inputdata );
void InputCopyFogControllerWithScale( inputdata_t &inputdata );
void InputSetFarZ( inputdata_t &data );
void InputSetSkyColor( inputdata_t &inputdata ) { m_skyboxData.skycolor = inputdata.value.Color32(); }
void InputSetScale( inputdata_t &inputdata ) { m_skyboxData.scale = inputdata.value.Int(); }
#endif
public:

View File

@ -398,7 +398,9 @@ void Templates_StartUniqueInstance( void )
//-----------------------------------------------------------------------------
char *Templates_GetEntityIOFixedMapData( int iIndex )
{
#ifndef MAPBASE // This code also runs when the point_template's script scope is active
Assert( Templates_IndexRequiresEntityIOFixup( iIndex ) );
#endif
// First time through?
if ( !g_Templates[iIndex]->pszFixedMapData )

View File

@ -2179,7 +2179,7 @@ void CAI_BaseNPC::InitDefaultActivitySR(void)
ADD_ACTIVITY_TO_SR( ACT_RUN_AR2 );
ADD_ACTIVITY_TO_SR( ACT_RUN_AIM_AR2 );
//ADD_ACTIVITY_TO_SR( ACT_RELOAD_AR2 );
ADD_ACTIVITY_TO_SR( ACT_RELOAD_AR2 );
//ADD_ACTIVITY_TO_SR( ACT_RELOAD_AR2_LOW );
ADD_ACTIVITY_TO_SR( ACT_GESTURE_RELOAD_AR2 );

View File

@ -2293,6 +2293,28 @@ bool CAI_BaseNPC::QueryHearSound( CSound *pSound )
if( ShouldIgnoreSound( pSound ) )
return false;
#ifdef MAPBASE_VSCRIPT
if (HSCRIPT hFunc = LookupScriptFunction("QueryHearSound"))
{
HSCRIPT hSound = g_pScriptVM->RegisterInstance( pSound );
g_pScriptVM->SetValue( "sound", hSound );
ScriptVariant_t functionReturn;
bool bValid = true;
if ( CallScriptFunctionHandle( hFunc, &functionReturn ) )
{
if (functionReturn.m_bool == false)
bValid = false;
}
g_pScriptVM->ClearValue( "sound" );
g_pScriptVM->RemoveInstance( hSound );
if (bValid == false)
return false;
}
#endif
return true;
}
@ -2300,12 +2322,34 @@ bool CAI_BaseNPC::QueryHearSound( CSound *pSound )
bool CAI_BaseNPC::QuerySeeEntity( CBaseEntity *pEntity, bool bOnlyHateOrFearIfNPC )
{
bool bValid = true;
if ( bOnlyHateOrFearIfNPC && pEntity->IsNPC() )
{
Disposition_t disposition = IRelationType( pEntity );
return ( disposition == D_HT || disposition == D_FR );
bValid = ( disposition == D_HT || disposition == D_FR );
}
return true;
#ifdef MAPBASE_VSCRIPT
if (bValid)
{
if (HSCRIPT hFunc = LookupScriptFunction("QuerySeeEntity"))
{
g_pScriptVM->SetValue( "entity", ToHScript(pEntity) );
ScriptVariant_t functionReturn;
if ( CallScriptFunctionHandle( hFunc, &functionReturn ) )
{
if (functionReturn.m_bool == false)
bValid = false;
}
g_pScriptVM->ClearValue( "entity" );
}
}
#endif
return bValid;
}
//-----------------------------------------------------------------------------
@ -6555,13 +6599,13 @@ Activity CAI_BaseNPC::NPC_TranslateActivity( Activity eNewActivity )
}
#ifdef MAPBASE_VSCRIPT
if ( m_ScriptScope.IsInitialized() )
if (HSCRIPT hFunc = LookupScriptFunction("NPC_TranslateActivity"))
{
g_pScriptVM->SetValue( "activity", GetActivityName(eNewActivity) );
g_pScriptVM->SetValue( "activity_id", (int)eNewActivity );
ScriptVariant_t functionReturn;
if( CallScriptFunction( "NPC_TranslateActivity", &functionReturn ) )
if ( CallScriptFunctionHandle( hFunc, &functionReturn ) )
{
if (functionReturn.m_type == FIELD_INTEGER)
{

View File

@ -164,7 +164,7 @@ BEGIN_SCRIPTDESC_ROOT( AI_EnemyInfo_t, "Accessor for information about an enemy.
DEFINE_ENEMY_INFO_SCRIPTFUNCS( TimeAtFirstHand, "the time at which the enemy was seen firsthand." )
DEFINE_ENEMY_INFO_SCRIPTFUNCS( DangerMemory, "the memory of danger position w/o enemy pointer." )
DEFINE_ENEMY_INFO_SCRIPTFUNCS( EludedMe, "whether the enemy is not at the last known location." )
DEFINE_ENEMY_INFO_SCRIPTFUNCS( Unforgettable, "whether the enemy is unfortgettable." )
DEFINE_ENEMY_INFO_SCRIPTFUNCS( Unforgettable, "whether the enemy is unforgettable." )
DEFINE_ENEMY_INFO_SCRIPTFUNCS( MobbedMe, "whether the enemy was part of a mob at some point." )
END_SCRIPTDESC();
#endif

View File

@ -859,6 +859,11 @@ void CAI_ScriptConditions::OnEntitySpawned( CBaseEntity *pEntity )
if ( pEntity->MyNPCPointer() == NULL )
return;
#ifdef MAPBASE
if ( m_Actor == NULL_STRING )
return;
#endif
if ( pEntity->NameMatches( m_Actor ) )
{
if ( ActorInList( pEntity ) == false )

View File

@ -312,6 +312,8 @@ BEGIN_ENT_SCRIPTDESC( CBaseAnimating, CBaseEntity, "Animating models" )
DEFINE_SCRIPTFUNC_NAMED( ScriptSelectWeightedSequence, "SelectWeightedSequence", "Selects a sequence for the specified activity ID" )
DEFINE_SCRIPTFUNC_NAMED( ScriptSelectHeaviestSequence, "SelectHeaviestSequence", "Selects the sequence with the heaviest weight for the specified activity ID" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetSequenceKeyValues, "GetSequenceKeyValues", "Get a KeyValue class instance on the specified sequence. WARNING: This uses the same KeyValue pointer as GetModelKeyValues!" )
DEFINE_SCRIPTFUNC( GetSkin, "Gets the model's skin" )
DEFINE_SCRIPTFUNC( SetSkin, "Sets the model's skin" )
#endif
DEFINE_SCRIPTFUNC( IsSequenceFinished, "Ask whether the main sequence is done playing" )
DEFINE_SCRIPTFUNC( SetBodygroup, "Sets a bodygroup")
@ -2247,7 +2249,8 @@ HSCRIPT CBaseAnimating::ScriptGetSequenceKeyValues( int iSequence )
// UNDONE: who calls ReleaseInstance on this??? Does name need to be unique???
hScript = g_pScriptVM->RegisterInstance( m_pScriptModelKeyValues );
// Allow VScript to delete this when the instance is removed.
hScript = g_pScriptVM->RegisterInstance( m_pScriptModelKeyValues, true );
}
return hScript;

View File

@ -202,6 +202,10 @@ public:
int ScriptSelectWeightedSequence( int activity, int curSequence ) { return SelectWeightedSequence( (Activity)activity, curSequence ); }
HSCRIPT ScriptGetSequenceKeyValues( int iSequence );
// For VScript
int GetSkin() { return m_nSkin; }
void SetSkin( int iSkin ) { m_nSkin = iSkin; }
#endif
// These return the attachment in the space of the entity

View File

@ -2193,7 +2193,12 @@ BEGIN_ENT_SCRIPTDESC_ROOT( CBaseEntity, "Root class of all server-side entities"
DEFINE_SCRIPTFUNC_NAMED( ScriptGetUp, "GetUpVector", "Get the up vector of the entity" )
#ifdef MAPBASE_VSCRIPT
DEFINE_SCRIPTFUNC_NAMED( ScriptSetOriginAngles, "SetOriginAngles", "Set both the origin and the angles" )
DEFINE_SCRIPTFUNC_NAMED( ScriptSetOriginAnglesVelocity, "SetOriginAnglesVelocity", "Set the origin, the angles, and the velocity" )
DEFINE_SCRIPTFUNC_NAMED( ScriptEntityToWorldTransform, "EntityToWorldTransform", "Get the entity's transform" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetPhysicsObject, "GetPhysicsObject", "Get the entity's physics object if it has one" )
#endif
DEFINE_SCRIPTFUNC_NAMED( ScriptSetForward, "SetForwardVector", "Set the orientation of the entity to have this forward vector" )
@ -2265,6 +2270,9 @@ BEGIN_ENT_SCRIPTDESC_ROOT( CBaseEntity, "Root class of all server-side entities"
DEFINE_SCRIPTFUNC_NAMED( ScriptSetColorB, "SetColorB", "Set the render color's B value" )
DEFINE_SCRIPTFUNC_NAMED( ScriptSetAlpha, "SetAlpha", "Set the render color's alpha value" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetRenderMode, "GetRenderMode", "Get render mode" )
DEFINE_SCRIPTFUNC_NAMED( ScriptSetRenderMode, "SetRenderMode", "Set render mode" )
DEFINE_SCRIPTFUNC( GetSpawnFlags, "Get spawnflags" )
DEFINE_SCRIPTFUNC( AddSpawnFlags, "Add spawnflag(s)" )
DEFINE_SCRIPTFUNC( RemoveSpawnFlags, "Remove spawnflag(s)" )
@ -2278,10 +2286,25 @@ BEGIN_ENT_SCRIPTDESC_ROOT( CBaseEntity, "Root class of all server-side entities"
DEFINE_SCRIPTFUNC( SetEffects, "Set effect(s)" )
DEFINE_SCRIPTFUNC( IsEffectActive, "Check if an effect is active" )
DEFINE_SCRIPTFUNC( GetEFlags, "Get Eflags" )
DEFINE_SCRIPTFUNC( AddEFlags, "Add Eflags" )
DEFINE_SCRIPTFUNC( RemoveEFlags, "Remove Eflags" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetMoveType, "GetMoveType", "Get the move type" )
DEFINE_SCRIPTFUNC_NAMED( ScriptSetMoveType, "SetMoveType", "Set the move type" )
DEFINE_SCRIPTFUNC( GetCollisionGroup, "Get the collision group" )
DEFINE_SCRIPTFUNC( SetCollisionGroup, "Set the collision group" )
DEFINE_SCRIPTFUNC( GetSolidFlags, "Get solid flags" )
DEFINE_SCRIPTFUNC( AddSolidFlags, "Add solid flags" )
DEFINE_SCRIPTFUNC( RemoveSolidFlags, "Remove solid flags" )
DEFINE_SCRIPTFUNC( IsPlayer, "Returns true if this entity is a player." )
DEFINE_SCRIPTFUNC( IsNPC, "Returns true if this entity is a NPC." )
DEFINE_SCRIPTFUNC( IsCombatCharacter, "Returns true if this entity is a combat character (player or NPC)." )
DEFINE_SCRIPTFUNC_NAMED( IsBaseCombatWeapon, "IsWeapon", "Returns true if this entity is a weapon." )
DEFINE_SCRIPTFUNC( IsWorld, "Returns true if this entity is the world." )
#endif
DEFINE_SCRIPTFUNC( ValidateScriptScope, "Ensure that an entity's script scope has been created" )
@ -2986,6 +3009,30 @@ void CBaseEntity::VPhysicsCollision( int index, gamevcollisionevent_t *pEvent )
int otherIndex = !index;
CBaseEntity *pHitEntity = pEvent->pEntities[otherIndex];
#ifdef MAPBASE_VSCRIPT
if (HSCRIPT hFunc = LookupScriptFunction("VPhysicsCollision"))
{
// TODO: Unique class for collision events
g_pScriptVM->SetValue( "entity", ScriptVariant_t( pHitEntity->GetScriptInstance() ) );
g_pScriptVM->SetValue( "speed", pEvent->collisionSpeed );
Vector vecContactPoint;
pEvent->pInternalData->GetContactPoint( vecContactPoint );
g_pScriptVM->SetValue( "point", vecContactPoint );
Vector vecSurfaceNormal;
pEvent->pInternalData->GetSurfaceNormal( vecSurfaceNormal );
g_pScriptVM->SetValue( "normal", vecSurfaceNormal );
CallScriptFunctionHandle( hFunc, NULL );
g_pScriptVM->ClearValue( "entity" );
g_pScriptVM->ClearValue( "speed" );
g_pScriptVM->ClearValue( "point" );
g_pScriptVM->ClearValue( "normal" );
}
#endif
// Don't make sounds / effects if neither entity is MOVETYPE_VPHYSICS. The game
// physics should have done so.
if ( GetMoveType() != MOVETYPE_VPHYSICS && pHitEntity->GetMoveType() != MOVETYPE_VPHYSICS )
@ -7999,7 +8046,10 @@ void CBaseEntity::InputSetCollisionGroup( inputdata_t& inputdata )
//-----------------------------------------------------------------------------
void CBaseEntity::InputTouch( inputdata_t& inputdata )
{
if (inputdata.value.Entity())
Touch( inputdata.value.Entity() );
else
Warning( "%s InputTouch: Can't touch null entity", GetDebugName() );
}
//-----------------------------------------------------------------------------
@ -8185,6 +8235,36 @@ bool CBaseEntity::CallScriptFunction(const char* pFunctionName, ScriptVariant_t*
return false;
}
#ifdef MAPBASE_VSCRIPT
//-----------------------------------------------------------------------------
// Gets a function handle
//-----------------------------------------------------------------------------
HSCRIPT CBaseEntity::LookupScriptFunction(const char* pFunctionName)
{
START_VMPROFILE
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 CBaseEntity::CallScriptFunctionHandle(HSCRIPT hFunc, ScriptVariant_t* pFunctionReturn)
{
m_ScriptScope.Call(hFunc, pFunctionReturn);
m_ScriptScope.ReleaseFunction(hFunc);
UPDATE_VMPROFILE
return true;
}
#endif
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
@ -9539,7 +9619,12 @@ HSCRIPT CBaseEntity::ScriptGetModelKeyValues( void )
// UNDONE: who calls ReleaseInstance on this??? Does name need to be unique???
#ifdef MAPBASE_VSCRIPT
// Allow VScript to delete this when the instance is removed.
hScript = g_pScriptVM->RegisterInstance( m_pScriptModelKeyValues, true );
#else
hScript = g_pScriptVM->RegisterInstance( m_pScriptModelKeyValues );
#endif
/*
KeyValues *pParticleEffects = pModelKeyValues->FindKey("Particles");
@ -9684,6 +9769,17 @@ HSCRIPT CBaseEntity::ScriptEntityToWorldTransform( void )
{
return ScriptCreateMatrixInstance( EntityToWorldTransform() );
}
//-----------------------------------------------------------------------------
// Vscript: Gets the entity's physics object if it has one
//-----------------------------------------------------------------------------
HSCRIPT CBaseEntity::ScriptGetPhysicsObject( void )
{
if (VPhysicsGetObject())
return g_pScriptVM->RegisterInstance( VPhysicsGetObject() );
else
return NULL;
}
#endif

View File

@ -1963,6 +1963,11 @@ public:
void RunPrecacheScripts(void);
void RunOnPostSpawnScripts(void);
#ifdef MAPBASE_VSCRIPT
HSCRIPT LookupScriptFunction(const char* pFunctionName);
bool CallScriptFunctionHandle(HSCRIPT hFunc, ScriptVariant_t* pFunctionReturn);
#endif
HSCRIPT ScriptGetMoveParent(void);
HSCRIPT ScriptGetRootMoveParent();
HSCRIPT ScriptFirstMoveChild(void);
@ -1988,7 +1993,12 @@ public:
const Vector& ScriptGetUp(void) { static Vector vecUp; GetVectors(NULL, NULL, &vecUp); return vecUp; }
#ifdef MAPBASE_VSCRIPT
void ScriptSetOriginAngles(const Vector &vecOrigin, const QAngle &angAngles) { Teleport(&vecOrigin, &angAngles, NULL); }
void ScriptSetOriginAnglesVelocity(const Vector &vecOrigin, const QAngle &angAngles, const Vector &vecVelocity) { Teleport(&vecOrigin, &angAngles, &vecVelocity); }
HSCRIPT ScriptEntityToWorldTransform( void );
HSCRIPT ScriptGetPhysicsObject( void );
#endif
const char* ScriptGetModelName(void) const;
@ -2031,6 +2041,12 @@ public:
void ScriptSetColorG( int iVal ) { SetRenderColorG( iVal ); }
void ScriptSetColorB( int iVal ) { SetRenderColorB( iVal ); }
void ScriptSetAlpha( int iVal ) { SetRenderColorA( iVal ); }
int ScriptGetRenderMode() { return GetRenderMode(); }
void ScriptSetRenderMode( int nRenderMode ) { SetRenderMode( (RenderMode_t)nRenderMode ); }
int ScriptGetMoveType() { return GetMoveType(); }
void ScriptSetMoveType( int iMoveType ) { SetMoveType( (MoveType_t)iMoveType ); }
#endif
string_t m_iszVScripts;

View File

@ -0,0 +1,229 @@
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: An entity for creating instructor hints entirely with map logic
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "baseentity.h"
#include "world.h"
#ifdef INFESTED_DLL
#include "asw_marine.h"
#include "asw_player.h"
#endif
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CEnvInstructorHint : public CPointEntity
{
public:
DECLARE_CLASS( CEnvInstructorHint, CPointEntity );
DECLARE_DATADESC();
private:
void InputShowHint( inputdata_t &inputdata );
void InputEndHint( inputdata_t &inputdata );
#ifdef MAPBASE
void InputSetCaption( inputdata_t &inputdata ) { m_iszCaption = inputdata.value.StringID(); }
#endif
string_t m_iszReplace_Key;
string_t m_iszHintTargetEntity;
int m_iTimeout;
string_t m_iszIcon_Onscreen;
string_t m_iszIcon_Offscreen;
string_t m_iszCaption;
string_t m_iszActivatorCaption;
color32 m_Color;
float m_fIconOffset;
float m_fRange;
uint8 m_iPulseOption;
uint8 m_iAlphaOption;
uint8 m_iShakeOption;
bool m_bStatic;
bool m_bNoOffscreen;
bool m_bForceCaption;
string_t m_iszBinding;
bool m_bAllowNoDrawTarget;
bool m_bLocalPlayerOnly;
#ifdef MAPBASE
string_t m_iszStartSound;
int m_iHintTargetPos;
#endif
};
LINK_ENTITY_TO_CLASS( env_instructor_hint, CEnvInstructorHint );
BEGIN_DATADESC( CEnvInstructorHint )
DEFINE_KEYFIELD( m_iszReplace_Key, FIELD_STRING, "hint_replace_key" ),
DEFINE_KEYFIELD( m_iszHintTargetEntity, FIELD_STRING, "hint_target" ),
DEFINE_KEYFIELD( m_iTimeout, FIELD_INTEGER, "hint_timeout" ),
DEFINE_KEYFIELD( m_iszIcon_Onscreen, FIELD_STRING, "hint_icon_onscreen" ),
DEFINE_KEYFIELD( m_iszIcon_Offscreen, FIELD_STRING, "hint_icon_offscreen" ),
DEFINE_KEYFIELD( m_iszCaption, FIELD_STRING, "hint_caption" ),
DEFINE_KEYFIELD( m_iszActivatorCaption, FIELD_STRING, "hint_activator_caption" ),
DEFINE_KEYFIELD( m_Color, FIELD_COLOR32, "hint_color" ),
DEFINE_KEYFIELD( m_fIconOffset, FIELD_FLOAT, "hint_icon_offset" ),
DEFINE_KEYFIELD( m_fRange, FIELD_FLOAT, "hint_range" ),
DEFINE_KEYFIELD( m_iPulseOption, FIELD_CHARACTER, "hint_pulseoption" ),
DEFINE_KEYFIELD( m_iAlphaOption, FIELD_CHARACTER, "hint_alphaoption" ),
DEFINE_KEYFIELD( m_iShakeOption, FIELD_CHARACTER, "hint_shakeoption" ),
DEFINE_KEYFIELD( m_bStatic, FIELD_BOOLEAN, "hint_static" ),
DEFINE_KEYFIELD( m_bNoOffscreen, FIELD_BOOLEAN, "hint_nooffscreen" ),
DEFINE_KEYFIELD( m_bForceCaption, FIELD_BOOLEAN, "hint_forcecaption" ),
DEFINE_KEYFIELD( m_iszBinding, FIELD_STRING, "hint_binding" ),
DEFINE_KEYFIELD( m_bAllowNoDrawTarget, FIELD_BOOLEAN, "hint_allow_nodraw_target" ),
DEFINE_KEYFIELD( m_bLocalPlayerOnly, FIELD_BOOLEAN, "hint_local_player_only" ),
#ifdef MAPBASE
DEFINE_KEYFIELD( m_iszStartSound, FIELD_STRING, "hint_start_sound" ),
DEFINE_KEYFIELD( m_iHintTargetPos, FIELD_INTEGER, "hint_target_pos" ),
#endif
DEFINE_INPUTFUNC( FIELD_STRING, "ShowHint", InputShowHint ),
DEFINE_INPUTFUNC( FIELD_VOID, "EndHint", InputEndHint ),
#ifdef MAPBASE
DEFINE_INPUTFUNC( FIELD_STRING, "SetCaption", InputSetCaption ),
#endif
END_DATADESC()
#define LOCATOR_ICON_FX_PULSE_SLOW 0x00000001
#define LOCATOR_ICON_FX_ALPHA_SLOW 0x00000008
#define LOCATOR_ICON_FX_SHAKE_NARROW 0x00000040
#define LOCATOR_ICON_FX_STATIC 0x00000100 // This icon draws at a fixed location on the HUD.
//-----------------------------------------------------------------------------
// Purpose: Input handler for showing the message and/or playing the sound.
//-----------------------------------------------------------------------------
void CEnvInstructorHint::InputShowHint( inputdata_t &inputdata )
{
IGameEvent * event = gameeventmanager->CreateEvent( "instructor_server_hint_create", false );
if ( event )
{
CBaseEntity *pTargetEntity = gEntList.FindEntityByName( NULL, m_iszHintTargetEntity );
if( pTargetEntity == NULL && !m_bStatic )
pTargetEntity = inputdata.pActivator;
if( pTargetEntity == NULL )
pTargetEntity = GetWorldEntity();
char szColorString[128];
Q_snprintf( szColorString, sizeof( szColorString ), "%.3d,%.3d,%.3d", m_Color.r, m_Color.g, m_Color.b );
int iFlags = 0;
iFlags |= (m_iPulseOption == 0) ? 0 : (LOCATOR_ICON_FX_PULSE_SLOW << (m_iPulseOption - 1));
iFlags |= (m_iAlphaOption == 0) ? 0 : (LOCATOR_ICON_FX_ALPHA_SLOW << (m_iAlphaOption - 1));
iFlags |= (m_iShakeOption == 0) ? 0 : (LOCATOR_ICON_FX_SHAKE_NARROW << (m_iShakeOption - 1));
iFlags |= m_bStatic ? LOCATOR_ICON_FX_STATIC : 0;
CBasePlayer *pActivator = NULL;
bool bFilterByActivator = m_bLocalPlayerOnly;
#ifdef INFESTED_DLL
CASW_Marine *pMarine = dynamic_cast<CASW_Marine*>( inputdata.pActivator );
if ( pMarine )
{
pActivator = pMarine->GetCommander();
}
#else
if ( inputdata.value.StringID() != NULL_STRING )
{
CBaseEntity *pTarget = gEntList.FindEntityByName( NULL, inputdata.value.String() );
pActivator = dynamic_cast<CBasePlayer*>( pTarget );
if ( pActivator )
{
bFilterByActivator = true;
}
}
else
{
if ( GameRules()->IsMultiplayer() == false )
{
pActivator = UTIL_GetLocalPlayer();
}
else
{
Warning( "Failed to play server side instructor hint: no player specified for hint\n" );
Assert( 0 );
}
}
#endif
const char *pActivatorCaption = m_iszActivatorCaption.ToCStr();
if ( !pActivatorCaption || pActivatorCaption[ 0 ] == '\0' )
{
pActivatorCaption = m_iszCaption.ToCStr();
}
event->SetString( "hint_name", GetEntityName().ToCStr() );
event->SetString( "hint_replace_key", m_iszReplace_Key.ToCStr() );
event->SetInt( "hint_target", pTargetEntity->entindex() );
event->SetInt( "hint_activator_userid", ( pActivator ? pActivator->GetUserID() : 0 ) );
event->SetInt( "hint_timeout", m_iTimeout );
event->SetString( "hint_icon_onscreen", m_iszIcon_Onscreen.ToCStr() );
event->SetString( "hint_icon_offscreen", m_iszIcon_Offscreen.ToCStr() );
event->SetString( "hint_caption", m_iszCaption.ToCStr() );
event->SetString( "hint_activator_caption", pActivatorCaption );
event->SetString( "hint_color", szColorString );
event->SetFloat( "hint_icon_offset", m_fIconOffset );
event->SetFloat( "hint_range", m_fRange );
event->SetInt( "hint_flags", iFlags );
event->SetString( "hint_binding", m_iszBinding.ToCStr() );
event->SetBool( "hint_allow_nodraw_target", m_bAllowNoDrawTarget );
event->SetBool( "hint_nooffscreen", m_bNoOffscreen );
event->SetBool( "hint_forcecaption", m_bForceCaption );
event->SetBool( "hint_local_player_only", bFilterByActivator );
#ifdef MAPBASE
event->SetString( "hint_start_sound", m_iszStartSound.ToCStr() );
event->SetInt( "hint_target_pos", m_iHintTargetPos );
#endif
gameeventmanager->FireEvent( event );
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CEnvInstructorHint::InputEndHint( inputdata_t &inputdata )
{
IGameEvent * event = gameeventmanager->CreateEvent( "instructor_server_hint_stop", false );
if ( event )
{
event->SetString( "hint_name", GetEntityName().ToCStr() );
gameeventmanager->FireEvent( event );
}
}
//-----------------------------------------------------------------------------
// Purpose: A generic target entity that gets replicated to the client for instructor hint targetting
//-----------------------------------------------------------------------------
class CInfoInstructorHintTarget : public CPointEntity
{
public:
DECLARE_CLASS( CInfoInstructorHintTarget, CPointEntity );
virtual int UpdateTransmitState( void ) // set transmit filter to transmit always
{
return SetTransmitState( FL_EDICT_ALWAYS );
}
DECLARE_DATADESC();
};
LINK_ENTITY_TO_CLASS( info_target_instructor_hint, CInfoInstructorHintTarget );
BEGIN_DATADESC( CInfoInstructorHintTarget )
END_DATADESC()

View File

@ -21,6 +21,7 @@ BEGIN_DATADESC( CEnvProjectedTexture )
DEFINE_FIELD( m_hTargetEntity, FIELD_EHANDLE ),
#ifdef MAPBASE
DEFINE_KEYFIELD( m_bDontFollowTarget, FIELD_BOOLEAN, "dontfollowtarget" ),
DEFINE_FIELD( m_bAlwaysUpdate, FIELD_BOOLEAN ),
#endif
DEFINE_FIELD( m_bState, FIELD_BOOLEAN ),
DEFINE_KEYFIELD( m_flLightFOV, FIELD_FLOAT, "lightfov" ),

View File

@ -15,13 +15,44 @@ class CFuncReflectiveGlass : public CFuncBrush
DECLARE_DATADESC();
DECLARE_CLASS( CFuncReflectiveGlass, CFuncBrush );
DECLARE_SERVERCLASS();
CFuncReflectiveGlass()
{
#ifdef MAPBASE
m_iszReflectRenderTarget = AllocPooledString( "_rt_WaterReflection" );
m_iszRefractRenderTarget = AllocPooledString( "_rt_WaterRefraction" );
#endif
}
#ifdef MAPBASE
void InputSetReflectRenderTarget( inputdata_t &inputdata ) { m_iszReflectRenderTarget = inputdata.value.StringID(); }
void InputSetRefractRenderTarget( inputdata_t &inputdata ) { m_iszRefractRenderTarget = inputdata.value.StringID(); }
CNetworkVar( string_t, m_iszReflectRenderTarget );
CNetworkVar( string_t, m_iszRefractRenderTarget );
#endif
};
// automatically hooks in the system's callbacks
BEGIN_DATADESC( CFuncReflectiveGlass )
#ifdef MAPBASE
DEFINE_KEYFIELD( m_iszReflectRenderTarget, FIELD_STRING, "ReflectRenderTarget" ),
DEFINE_KEYFIELD( m_iszRefractRenderTarget, FIELD_STRING, "RefractRenderTarget" ),
DEFINE_INPUTFUNC( FIELD_STRING, "SetReflectRenderTarget", InputSetReflectRenderTarget ),
DEFINE_INPUTFUNC( FIELD_STRING, "SetRefractRenderTarget", InputSetRefractRenderTarget ),
#endif
END_DATADESC()
LINK_ENTITY_TO_CLASS( func_reflective_glass, CFuncReflectiveGlass );
IMPLEMENT_SERVERCLASS_ST( CFuncReflectiveGlass, DT_FuncReflectiveGlass )
#ifdef MAPBASE
SendPropStringT( SENDINFO( m_iszReflectRenderTarget ) ),
SendPropStringT( SENDINFO( m_iszRefractRenderTarget ) ),
#endif
END_SEND_TABLE()

View File

@ -137,6 +137,21 @@ void respawn( CBaseEntity *pEdict, bool fCopyCorpse )
// respawn player
pEdict->Spawn();
}
#ifdef MAPBASE
else if (g_pGameRules->AllowSPRespawn())
{
// In SP respawns, only create corpse if drawing externally
CBasePlayer *pPlayer = (CBasePlayer*)pEdict;
if ( fCopyCorpse && pPlayer->m_bDrawPlayerModelExternally )
{
// make a copy of the dead body for appearances sake
pPlayer->CreateCorpse();
}
// respawn player
pPlayer->Spawn();
}
#endif
else
{ // restart the entire server
engine->ServerCommand("reload\n");

View File

@ -230,6 +230,8 @@ public:
COutputInt m_RequestedPlayerArmor;
COutputFloat m_RequestedPlayerAuxPower;
COutputFloat m_RequestedPlayerFlashBattery;
COutputEvent m_OnPlayerSpawn;
#endif
void InputRequestPlayerHealth( inputdata_t &inputdata );
@ -602,6 +604,11 @@ BEGIN_ENT_SCRIPTDESC( CHL2_Player, CBasePlayer, "The HL2 player entity." )
DEFINE_SCRIPTFUNC_NAMED( SuitPower_GetCurrentPercentage, "GetAuxPower", "Gets the player's available aux power." )
DEFINE_SCRIPTFUNC( GetFlashlightBattery, "Gets the energy available in the player's flashlight. If the legacy (aux power-based) flashlight is enabled, this returns the aux power." )
DEFINE_SCRIPTFUNC( InitCustomSuitDevice, "Initializes a custom suit device. (just sets drain rate for now)" )
DEFINE_SCRIPTFUNC( AddCustomSuitDevice, "Adds a custom suit device ID. (1-3)" )
DEFINE_SCRIPTFUNC( RemoveCustomSuitDevice, "Removes a custom suit device ID. (1-3)" )
DEFINE_SCRIPTFUNC( IsCustomSuitDeviceActive, "Checks if a custom suit device is active." )
END_SCRIPTDESC();
#endif
@ -633,6 +640,16 @@ CHL2_Player::CHL2_Player()
#endif
CSuitPowerDevice SuitDeviceBreather( bits_SUIT_DEVICE_BREATHER, 6.7f ); // 100 units in 15 seconds (plus three padded seconds)
#ifdef MAPBASE
// Default: 100 units in 8 seconds
CSuitPowerDevice SuitDeviceCustom[] =
{
{ bits_SUIT_DEVICE_CUSTOM0, 12.5f },
{ bits_SUIT_DEVICE_CUSTOM1, 12.5f },
{ bits_SUIT_DEVICE_CUSTOM2, 12.5f },
};
#endif
IMPLEMENT_SERVERCLASS_ST(CHL2_Player, DT_HL2_Player)
SendPropDataTable(SENDINFO_DT(m_HL2Local), &REFERENCE_SEND_TABLE(DT_HL2Local), SendProxy_SendLocalDataTable),
@ -1322,6 +1339,13 @@ void CHL2_Player::PlayerRunCommand(CUserCmd *ucmd, IMoveHelper *moveHelper)
}
#ifdef MAPBASE
void CHL2_Player::SpawnedAtPoint( CBaseEntity *pSpawnPoint )
{
FirePlayerProxyOutput( "OnPlayerSpawn", variant_t(), this, pSpawnPoint );
}
//-----------------------------------------------------------------------------
ConVar hl2_use_hl2dm_anims( "hl2_use_hl2dm_anims", "0", FCVAR_NONE, "Allows SP HL2 players to use HL2:DM animations (for custom player models)" );
void CHL2_Player::ResetAnimation( void )
@ -1522,6 +1546,17 @@ void CHL2_Player::Spawn(void)
BaseClass::Spawn();
#ifdef MAPBASE
// Ported from CHL2MP_Player. Fixes issues with respawning players in SP
if ( !IsObserver() )
{
pl.deadflag = false;
RemoveSolidFlags( FSOLID_NOT_SOLID );
RemoveEffects( EF_NODRAW );
}
#endif
//
// Our player movement speed is set once here. This will override the cl_xxxx
// cvars unless they are set to be lower than this.
@ -3093,6 +3128,14 @@ void CHL2_Player::Event_Killed( const CTakeDamageInfo &info )
#ifdef MAPBASE
FirePlayerProxyOutput( "PlayerDied", variant_t(), info.GetAttacker(), this );
if (IsSuitEquipped())
{
// Make sure all devices are deactivated (for respawn)
m_HL2Local.m_bitsActiveDevices = 0x00000000;
m_flSuitPowerLoad = 0;
m_flTimeAllSuitDevicesOff = gpGlobals->curtime;
}
#else
FirePlayerProxyOutput( "PlayerDied", variant_t(), this, this );
#endif
@ -4336,6 +4379,64 @@ void CHL2_Player::DisplayLadderHudHint()
#endif//CLIENT_DLL
}
#ifdef MAPBASE
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CHL2_Player::InitCustomSuitDevice( int iDeviceID, float flDrainRate )
{
if (iDeviceID < 0 || iDeviceID > 2)
{
Warning("InitCustomSuitDevice : \"%i\" is not a valid custom device slot\n", iDeviceID);
return;
}
SuitDeviceCustom[iDeviceID].SetDeviceDrainRate( flDrainRate );
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CHL2_Player::AddCustomSuitDevice( int iDeviceID )
{
if (iDeviceID < 0 || iDeviceID > 2)
{
Warning("AddCustomSuitDevice : \"%i\" is not a valid custom device slot\n", iDeviceID);
return;
}
SuitPower_AddDevice( SuitDeviceCustom[iDeviceID] );
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CHL2_Player::RemoveCustomSuitDevice( int iDeviceID )
{
if (iDeviceID < 0 || iDeviceID > 2)
{
Warning("AddCustomSuitDevice : \"%i\" is not a valid custom device slot\n", iDeviceID);
return;
}
SuitPower_RemoveDevice( SuitDeviceCustom[iDeviceID] );
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
bool CHL2_Player::IsCustomSuitDeviceActive( int iDeviceID )
{
if (iDeviceID < 0 || iDeviceID > 2)
{
Warning("IsCustomSuitDeviceActive : \"%i\" is not a valid custom device slot\n", iDeviceID);
return false;
}
return SuitPower_IsDeviceActive( SuitDeviceCustom[iDeviceID] );
}
#endif
//-----------------------------------------------------------------------------
// Shuts down sounds
//-----------------------------------------------------------------------------
@ -4370,11 +4471,15 @@ void CHL2_Player::ModifyOrAppendPlayerCriteria( AI_CriteriaSet& set )
#ifdef MAPBASE
const char *CHL2_Player::GetOverrideStepSound( const char *pszBaseStepSoundName )
{
const char *szSound = GetContextValue(FindContextByName("footsteps"));
int idx = FindContextByName("footsteps");
if (idx != -1)
{
const char *szSound = GetContextValue(idx);
if (szSound[0] != '\0')
{
return szSound;
}
}
return pszBaseStepSoundName;
}
#endif
@ -4466,6 +4571,7 @@ BEGIN_DATADESC( CLogicPlayerProxy )
DEFINE_OUTPUT( m_RequestedPlayerArmor, "PlayerArmor" ),
DEFINE_OUTPUT( m_RequestedPlayerAuxPower, "PlayerAuxPower" ),
DEFINE_OUTPUT( m_RequestedPlayerFlashBattery, "PlayerFlashBattery" ),
DEFINE_OUTPUT( m_OnPlayerSpawn, "OnPlayerSpawn" ),
#endif
DEFINE_INPUTFUNC( FIELD_VOID, "RequestPlayerHealth", InputRequestPlayerHealth ),
DEFINE_INPUTFUNC( FIELD_VOID, "SetFlashlightSlowDrain", InputSetFlashlightSlowDrain ),

View File

@ -75,6 +75,9 @@ public:
else
return m_flDrainRate;
}
#ifdef MAPBASE
void SetDeviceDrainRate( float flDrainRate ) { m_flDrainRate = flDrainRate; }
#endif
};
//=============================================================================
@ -124,6 +127,9 @@ public:
virtual void ModifyOrAppendPlayerCriteria( AI_CriteriaSet& set );
#ifdef MAPBASE
// For the logic_playerproxy output
void SpawnedAtPoint( CBaseEntity *pSpawnPoint );
void ResetAnimation( void );
void SetAnimation( PLAYER_ANIM playerAnim );
@ -334,6 +340,13 @@ public:
// HUD HINTS
void DisplayLadderHudHint();
#ifdef MAPBASE
void InitCustomSuitDevice( int iDeviceID, float flDrainRate );
void AddCustomSuitDevice( int iDeviceID );
void RemoveCustomSuitDevice( int iDeviceID );
bool IsCustomSuitDeviceActive( int iDeviceID );
#endif
CSoundPatch *m_sndLeeches;
CSoundPatch *m_sndWaterSplashes;

View File

@ -2627,8 +2627,15 @@ public:
if ( !pEntity->IsNPC() && pEntity->GetMoveType() == MOVETYPE_VPHYSICS )
{
IPhysicsObject *pPhysics = pEntity->VPhysicsGetObject();
#ifdef MAPBASE
// A MOVETYPE_VPHYSICS object without a VPhysics object is an odd edge case, but it's evidently possible
// since my game crashed after an antlion guard tried to see me through an EP2 jalopy.
// Perhaps that's a sign of an underlying issue?
if ( pPhysics && pPhysics->IsMoveable() && pPhysics->GetMass() < m_minMass )
#else
Assert(pPhysics);
if ( pPhysics->IsMoveable() && pPhysics->GetMass() < m_minMass )
#endif
return false;
}

View File

@ -6413,6 +6413,7 @@ bool CMathLightPattern::KeyValue( const char *szKeyName, const char *szValue )
void CMathLightPattern::InputSetStyle( inputdata_t &inputdata )
{
m_iszPattern = AllocPooledString(GetDefaultLightstyleString(inputdata.value.Int()));
m_NextLetter = 0;
}
//-----------------------------------------------------------------------------
@ -6421,6 +6422,7 @@ void CMathLightPattern::InputSetStyle( inputdata_t &inputdata )
void CMathLightPattern::InputSetPattern( inputdata_t &inputdata )
{
m_iszPattern = inputdata.value.StringID();
m_NextLetter = 0;
}
//-----------------------------------------------------------------------------

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ==================
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ==================
//
// Purpose: See GlobalStrings.h for more information.
//

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ==================
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ==================
//
// Purpose: Shared global string library.
//

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: Mostly just Mapbase's convar mod code.
//

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: modifiedconvarts_t from CommentarySystem.cpp moved to a header file so Mapbase can use it.
//

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose:
//

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose:
//

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: An entity that watches an NPC for certain things.
//

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: Be warned, because this entity is TERRIBLE!
//

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose:
//

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose:
//

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose:
//

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: Response system properties (concepts, etc.) shared by npc_combine_s and npc_metropolice
//

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: A special brush that collides with clientside entities, primarily ragdolls.
//

View File

@ -0,0 +1,100 @@
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: Recreates Portal 2 linked_portal_door functionality using SDK code only.
// (basically a combination of point_camera and func_reflective_glass)
//
//===========================================================================//
#include "cbase.h"
#include "modelentities.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
class CFuncFakeWorldPortal : public CFuncBrush
{
DECLARE_DATADESC();
DECLARE_CLASS( CFuncFakeWorldPortal, CFuncBrush );
DECLARE_SERVERCLASS();
CFuncFakeWorldPortal()
{
// Equivalent to SKYBOX_2DSKYBOX_VISIBLE, the original sky setting
m_iSkyMode = 2;
}
public:
virtual void Spawn( void )
{
BaseClass::Spawn();
if (m_target != NULL_STRING)
{
m_hTargetPlane = gEntList.FindEntityByName( NULL, m_target, this );
if (!m_hTargetPlane)
Warning("%s: Invalid target plane \"%s\"!\n", GetDebugName(), STRING(m_target));
}
else
{
Warning("%s: No target plane!\n", GetDebugName());
}
if (m_iszFogController != NULL_STRING)
{
m_hFogController = gEntList.FindEntityByName( NULL, m_iszFogController, this );
if (!m_hFogController)
Warning("%s: Invalid fog controller \"%s\"!\n", GetDebugName(), STRING(m_iszFogController));
}
}
// Input handlers
void InputSetTargetPlane( inputdata_t &inputdata ) { m_hTargetPlane = inputdata.value.Entity(); if (m_hTargetPlane) { m_target = m_hTargetPlane->GetEntityName(); } }
void InputSetTargetPlaneAngle( inputdata_t &inputdata ) { Vector vec; inputdata.value.Vector3D(vec); m_PlaneAngles.Init(vec.x, vec.y, vec.z); }
void InputSetSkyMode( inputdata_t &inputdata ) { m_iSkyMode = inputdata.value.Int(); }
void InputSetRenderTarget( inputdata_t &inputdata ) { m_iszRenderTarget = inputdata.value.StringID(); }
void InputSetFogController( inputdata_t &inputdata ) { m_hFogController = inputdata.value.Entity(); if (m_hFogController) { m_iszFogController = m_hFogController->GetEntityName(); } }
private:
CNetworkHandle( CBaseEntity, m_hTargetPlane );
CNetworkQAngle( m_PlaneAngles );
CNetworkVar( int, m_iSkyMode );
CNetworkVar( float, m_flScale );
CNetworkVar( string_t, m_iszRenderTarget );
CNetworkHandle( CBaseEntity, m_hFogController );
string_t m_iszFogController;
};
// automatically hooks in the system's callbacks
BEGIN_DATADESC( CFuncFakeWorldPortal )
DEFINE_FIELD( m_hTargetPlane, FIELD_EHANDLE ),
DEFINE_KEYFIELD( m_PlaneAngles, FIELD_VECTOR, "PlaneAngles" ),
DEFINE_KEYFIELD( m_iSkyMode, FIELD_INTEGER, "SkyMode" ),
DEFINE_KEYFIELD( m_flScale, FIELD_FLOAT, "scale" ),
DEFINE_KEYFIELD( m_iszRenderTarget, FIELD_STRING, "RenderTarget" ),
DEFINE_FIELD( m_hFogController, FIELD_EHANDLE ),
DEFINE_KEYFIELD( m_iszFogController, FIELD_STRING, "FogController" ),
DEFINE_INPUTFUNC( FIELD_EHANDLE, "SetTargetPlane", InputSetTargetPlane ),
DEFINE_INPUTFUNC( FIELD_VECTOR, "SetTargetPlaneAngle", InputSetTargetPlaneAngle ),
DEFINE_INPUTFUNC( FIELD_INTEGER, "SetSkyMode", InputSetSkyMode ),
DEFINE_INPUTFUNC( FIELD_STRING, "SetRenderTarget", InputSetRenderTarget ),
DEFINE_INPUTFUNC( FIELD_EHANDLE, "SetFogController", InputSetFogController ),
END_DATADESC()
LINK_ENTITY_TO_CLASS( func_fake_worldportal, CFuncFakeWorldPortal );
IMPLEMENT_SERVERCLASS_ST( CFuncFakeWorldPortal, DT_FuncFakeWorldPortal )
SendPropEHandle( SENDINFO( m_hTargetPlane ) ),
SendPropVector( SENDINFO( m_PlaneAngles ), -1, SPROP_COORD ),
SendPropInt( SENDINFO( m_iSkyMode ) ),
SendPropFloat( SENDINFO( m_flScale ) ),
SendPropStringT( SENDINFO( m_iszRenderTarget ) ),
SendPropEHandle( SENDINFO( m_hFogController ) ),
END_SEND_TABLE()

View File

@ -1,8 +1,10 @@
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ====
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ====
//
// Attempts to replicate logic_eventlistener from Portal 2.
// Purpose: Source SDK-based replication of logic_eventlistener from later versions
// of Source.
//
// This is, in fact, a RECREATION! This is not an actual port.
// This is based entirely on Source 2013 code and Portal 2's FGD entry.
// It does not actually use code from Portal 2 or later.
//
//=============================================================================

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose:
//

View File

@ -1,8 +1,10 @@
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ====
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ====
//
// Attempts to replicate logic_register_activator from Portal 2.
// Purpose: Source SDK-based replication of logic_register_activator from later versions
// of Source.
//
// This is, in fact, a RECREATION! This is not an actual port.
// This is based entirely on Source 2013 code and Portal 2's FGD entry.
// It does not actually use code from Portal 2 or later.
//
//=============================================================================

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: Controls and detects difficulty level changes
//

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: A ballsier version of point_entity_finder.
// Originally called logic_entityfinder because a lot of this was written

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: Copies size.
//

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: A special entity for afflicting damage as specific as possible.
//

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: Replaces a thing with another thing.
//

View File

@ -0,0 +1,73 @@
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: Mapbase off-shoot of tf_glow (created using SDK code only)
//
//=============================================================================
#include "cbase.h"
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CPointGlow : public CPointEntity
{
DECLARE_CLASS( CPointGlow, CPointEntity );
public:
int UpdateTransmitState( void ) { return SetTransmitState( FL_EDICT_ALWAYS ); }
void Spawn( void );
void SetGlowTarget( CBaseEntity *pActivator, CBaseEntity *pCaller ) { m_hGlowTarget = gEntList.FindEntityByName(NULL, m_target, this, pActivator, pCaller); }
// Inputs
void InputSetTarget( inputdata_t &inputdata ) { BaseClass::InputSetTarget(inputdata); SetGlowTarget( inputdata.pActivator, inputdata.pCaller ); }
void InputEnable( inputdata_t &inputdata ) { m_bGlowDisabled = false; SetGlowTarget( inputdata.pActivator, inputdata.pCaller ); }
void InputDisable( inputdata_t &inputdata ) { m_bGlowDisabled = true; }
void InputToggle( inputdata_t &inputdata ) { m_bGlowDisabled ? InputEnable(inputdata) : InputDisable(inputdata); }
void InputSetGlowColor( inputdata_t &inputdata ) { m_GlowColor = inputdata.value.Color32(); }
CNetworkHandle( CBaseEntity, m_hGlowTarget );
CNetworkColor32( m_GlowColor );
CNetworkVar( bool, m_bGlowDisabled );
DECLARE_DATADESC();
DECLARE_SERVERCLASS();
};
LINK_ENTITY_TO_CLASS( point_glow, CPointGlow );
BEGIN_DATADESC( CPointGlow )
// Keys
DEFINE_KEYFIELD( m_GlowColor, FIELD_COLOR32, "GlowColor" ),
DEFINE_FIELD( m_hGlowTarget, FIELD_EHANDLE ),
DEFINE_KEYFIELD( m_bGlowDisabled, FIELD_BOOLEAN, "StartDisabled" ),
// Inputs
DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ),
DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ),
DEFINE_INPUTFUNC( FIELD_VOID, "Toggle", InputToggle ),
DEFINE_INPUTFUNC( FIELD_COLOR32, "SetGlowColor", InputSetGlowColor ),
END_DATADESC()
IMPLEMENT_SERVERCLASS_ST( CPointGlow, DT_PointGlow )
SendPropEHandle( SENDINFO( m_hGlowTarget ) ),
SendPropInt( SENDINFO( m_GlowColor ), 32, SPROP_UNSIGNED, SendProxy_Color32ToInt ),
SendPropBool( SENDINFO( m_bGlowDisabled ) ),
END_SEND_TABLE()
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPointGlow::Spawn()
{
m_hGlowTarget = gEntList.FindEntityByName( NULL, m_target, this );
BaseClass::Spawn();
}

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: Fires projectiles. What else is there to say?
//

View File

@ -1,4 +1,4 @@
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ====
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ====
//
// An entity that triggers the player's geiger counter.
//
@ -124,7 +124,11 @@ void CPointRadiationSource::RadiationThink( void )
float flRange = pPlayer->GetAbsOrigin().DistTo((GetAbsOrigin()));
if (m_flRadius <= 0 || flRange < m_flRadius)
{
Assert( m_flIntensity > 0 );
if (m_flIntensity == 0)
{
Warning("%s: INTENSITY IS ZERO!!! Can't notify of radiation\n", GetDebugName());
return;
}
//flRange *= 3.0f;
flRange /= m_flIntensity;

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose:
//

View File

@ -159,6 +159,19 @@ BEGIN_DATADESC(CRagdollProp)
END_DATADESC()
#ifdef MAPBASE_VSCRIPT
BEGIN_ENT_SCRIPTDESC( CRagdollProp, CBaseAnimating, "Ragdoll physics prop." )
DEFINE_SCRIPTFUNC( GetSourceClassName, "Gets the ragdoll's source classname." )
DEFINE_SCRIPTFUNC( SetSourceClassName, "Sets the ragdoll's source classname." )
DEFINE_SCRIPTFUNC( HasPhysgunInteraction, "Checks if the ragdoll has the specified interaction." )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetRagdollObject, "GetRagdollObject", "Gets the ragdoll object of the specified index." )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetRagdollObjectCount, "GetRagdollObjectCount", "Gets the number of ragdoll objects on this ragdoll." )
END_SCRIPTDESC()
#endif
//-----------------------------------------------------------------------------
// Disable auto fading under dx7 or when level fades are specified
//-----------------------------------------------------------------------------
@ -1803,6 +1816,24 @@ void CRagdollProp::InputFadeAndRemove( inputdata_t &inputdata )
FadeOut( 0.0f, flFadeDuration );
}
#ifdef MAPBASE_VSCRIPT
HSCRIPT CRagdollProp::ScriptGetRagdollObject( int iIndex )
{
if (iIndex < 0 || iIndex > m_ragdoll.listCount)
{
Warning("%s GetRagdollObject: Index %i not valid (%i objects)\n", GetDebugName(), iIndex, m_ragdoll.listCount);
return NULL;
}
return g_pScriptVM->RegisterInstance( m_ragdoll.list[iIndex].pObject );
}
int CRagdollProp::ScriptGetRagdollObjectCount()
{
return m_ragdoll.listCount;
}
#endif
void Ragdoll_GetAngleOverrideString( char *pOut, int size, CBaseEntity *pEntity )
{
CRagdollProp *pRagdoll = dynamic_cast<CRagdollProp *>(pEntity);

View File

@ -22,6 +22,9 @@
class CRagdollProp : public CBaseAnimating, public CDefaultPlayerPickupVPhysics
{
DECLARE_CLASS( CRagdollProp, CBaseAnimating );
#ifdef MAPBASE_VSCRIPT
DECLARE_ENT_SCRIPTDESC();
#endif
public:
CRagdollProp( void );
@ -59,6 +62,9 @@ public:
virtual IResponseSystem *GetResponseSystem();
virtual void ModifyOrAppendCriteria( AI_CriteriaSet& set );
void SetSourceClassName( const char *pClassname );
#ifdef MAPBASE
const char *GetSourceClassName() { return STRING( m_strSourceClassName ); }
#endif
// Physics attacker
virtual CBasePlayer *HasPhysicsAttacker( float dt );
@ -112,6 +118,11 @@ public:
void InputTurnOff( inputdata_t &inputdata );
void InputFadeAndRemove( inputdata_t &inputdata );
#ifdef MAPBASE_VSCRIPT
HSCRIPT ScriptGetRagdollObject( int iIndex );
int ScriptGetRagdollObjectCount();
#endif
DECLARE_DATADESC();
protected:

View File

@ -3797,13 +3797,12 @@ void CBasePlayer::PlayerRunCommand(CUserCmd *ucmd, IMoveHelper *moveHelper)
#ifdef MAPBASE_VSCRIPT
// Movement hook for VScript
if ( m_ScriptScope.IsInitialized() )
if ( HSCRIPT hFunc = LookupScriptFunction("PlayerRunCommand") )
{
CUserCmdAccessor accessor = CUserCmdAccessor( ucmd );
HSCRIPT hCmd = g_pScriptVM->RegisterInstance( &accessor );
HSCRIPT hCmd = g_pScriptVM->RegisterInstance( ucmd );
g_pScriptVM->SetValue( "command", hCmd );
CallScriptFunction( "PlayerRunCommand", NULL );
CallScriptFunctionHandle( hFunc, NULL );
g_pScriptVM->ClearValue( "command" );
g_pScriptVM->RemoveInstance( hCmd );
@ -5144,7 +5143,12 @@ void CBasePlayer::Spawn( void )
if ( !m_fGameHUDInitialized )
g_pGameRules->SetDefaultPlayerTeam( this );
#ifdef MAPBASE
CBaseEntity *pSpawnPoint = g_pGameRules->GetPlayerSpawnSpot( this );
SpawnedAtPoint( pSpawnPoint );
#else
g_pGameRules->GetPlayerSpawnSpot( this );
#endif
m_Local.m_bDucked = false;// This will persist over round restart if you hold duck otherwise.
m_Local.m_bDucking = false;

View File

@ -294,6 +294,11 @@ public:
virtual void SharedSpawn(); // Shared between client and server.
virtual void ForceRespawn( void );
#ifdef MAPBASE
// For the logic_playerproxy output
virtual void SpawnedAtPoint( CBaseEntity *pSpawnPoint ) {}
#endif
virtual void InitialSpawn( void );
virtual void InitHUD( void ) {}
virtual void ShowViewPortPanel( const char * name, bool bShow = true, KeyValues *data = NULL );

View File

@ -54,6 +54,8 @@ CPointCamera::CPointCamera()
#ifdef MAPBASE
// Equivalent to SKYBOX_2DSKYBOX_VISIBLE, the original sky setting
m_iSkyMode = 2;
m_iszRenderTarget = AllocPooledString( "_rt_Camera" );
#endif
g_PointCameraList.Insert( this );
@ -192,6 +194,13 @@ void CPointCamera::InputSetOnAndTurnOthersOff( inputdata_t &inputdata )
while ((pEntity = gEntList.FindEntityByClassname( pEntity, "point_camera" )) != NULL)
{
CPointCamera *pCamera = (CPointCamera*)pEntity;
#ifdef MAPBASE
// Do not turn off cameras which use different render targets
if (pCamera->m_iszRenderTarget.Get() != m_iszRenderTarget.Get())
continue;
#endif
pCamera->InputSetOff( inputdata );
}
@ -229,6 +238,7 @@ BEGIN_DATADESC( CPointCamera )
DEFINE_KEYFIELD( m_bUseScreenAspectRatio, FIELD_BOOLEAN, "UseScreenAspectRatio" ),
#ifdef MAPBASE
DEFINE_KEYFIELD( m_iSkyMode, FIELD_INTEGER, "SkyMode" ),
DEFINE_KEYFIELD( m_iszRenderTarget, FIELD_STRING, "RenderTarget" ),
#endif
DEFINE_FIELD( m_bActive, FIELD_BOOLEAN ),
DEFINE_FIELD( m_bIsOn, FIELD_BOOLEAN ),
@ -247,6 +257,7 @@ BEGIN_DATADESC( CPointCamera )
DEFINE_INPUTFUNC( FIELD_VOID, "SetOff", InputSetOff ),
#ifdef MAPBASE
DEFINE_INPUTFUNC( FIELD_INTEGER, "SetSkyMode", InputSetSkyMode ),
DEFINE_INPUTFUNC( FIELD_STRING, "SetRenderTarget", InputSetRenderTarget ),
#endif
END_DATADESC()
@ -263,6 +274,7 @@ IMPLEMENT_SERVERCLASS_ST( CPointCamera, DT_PointCamera )
SendPropInt( SENDINFO( m_bUseScreenAspectRatio ), 1, SPROP_UNSIGNED ),
#ifdef MAPBASE
SendPropInt( SENDINFO( m_iSkyMode ) ),
SendPropStringT( SENDINFO( m_iszRenderTarget ) ),
#endif
END_SEND_TABLE()

View File

@ -39,6 +39,7 @@ public:
void InputSetOff( inputdata_t &inputdata );
#ifdef MAPBASE
void InputSetSkyMode( inputdata_t &inputdata ) { m_iSkyMode = inputdata.value.Int(); }
void InputSetRenderTarget( inputdata_t &inputdata ) { m_iszRenderTarget = inputdata.value.StringID(); }
float GetFOV() const { return m_FOV; }
#endif
@ -58,6 +59,7 @@ private:
CNetworkVar( bool, m_bUseScreenAspectRatio );
#ifdef MAPBASE
CNetworkVar( int, m_iSkyMode );
CNetworkVar( string_t, m_iszRenderTarget );
#endif
// Allows the mapmaker to control whether a camera is active or not

View File

@ -8,7 +8,8 @@ $Configuration
{
$Compiler
{
$PreprocessorDefinitions "$BASE;ASW_PROJECTED_TEXTURES;DYNAMIC_RTT_SHADOWS"
$PreprocessorDefinitions "$BASE;ASW_PROJECTED_TEXTURES;DYNAMIC_RTT_SHADOWS;GLOWS_ENABLE"
$PreprocessorDefinitions "$BASE;MAPBASE_VSCRIPT" [$MAPBASE_VSCRIPT]
}
}
@ -21,6 +22,7 @@ $Project
$File "env_projectedtexture.h"
$File "env_global_light.cpp"
$File "skyboxswapper.cpp"
$File "env_instructor_hint.cpp"
$Folder "Mapbase"
{
@ -36,6 +38,7 @@ $Project
$File "$SRCDIR\game\shared\mapbase\vscript_funcs_math.cpp" [$MAPBASE_VSCRIPT]
$File "$SRCDIR\game\shared\mapbase\vscript_funcs_math.h" [$MAPBASE_VSCRIPT]
$File "$SRCDIR\game\shared\mapbase\vscript_funcs_hl2.cpp" [$MAPBASE_VSCRIPT]
$File "$SRCDIR\game\shared\mapbase\vscript_consts_shared.cpp" [$MAPBASE_VSCRIPT]
$File "mapbase\ai_grenade.cpp"
$File "mapbase\ai_grenade.h"
@ -46,6 +49,7 @@ $Project
$File "mapbase\datadesc_mod.h"
$File "mapbase\expandedrs_combine.h"
$File "mapbase\func_clientclip.cpp"
$File "mapbase\func_fake_worldportal.cpp"
$File "mapbase\GlobalStrings.cpp"
$File "mapbase\GlobalStrings.h"
$File "mapbase\logic_externaldata.cpp"
@ -57,6 +61,7 @@ $Project
//$File "mapbase\point_physics_control.cpp" // Backlogged
$File "mapbase\point_projectile.cpp"
$File "mapbase\point_radiation_source.cpp"
$File "mapbase\point_glow.cpp"
$File "mapbase\SystemConvarMod.cpp"
$File "mapbase\SystemConvarMod.h"
$File "mapbase\variant_tools.h"

View File

@ -45,6 +45,31 @@ BEGIN_SIMPLE_DATADESC( CSound )
END_DATADESC()
#ifdef MAPBASE_VSCRIPT
BEGIN_SCRIPTDESC_ROOT( CSound, "A sound NPCs can hear." )
DEFINE_SCRIPTFUNC( DoesSoundExpire, "Returns true if the sound expires." )
DEFINE_SCRIPTFUNC( SoundExpirationTime, "Gets the sound's expiration time." )
DEFINE_SCRIPTFUNC( SetSoundOrigin, "Sets the sound's origin." )
DEFINE_SCRIPTFUNC( GetSoundOrigin, "Gets the sound's origin." )
DEFINE_SCRIPTFUNC( GetSoundReactOrigin, "Gets the sound's react origin." )
DEFINE_SCRIPTFUNC_NAMED( FIsSound, "IsSound", "Returns true if this is a type of sound (as opposed to a scent)." )
DEFINE_SCRIPTFUNC_NAMED( FIsScent, "IsScent", "Returns true if this is a type of scent (as opposed to a sound)." )
DEFINE_SCRIPTFUNC( IsSoundType, "Returns true if the sound type is the specified type." )
DEFINE_SCRIPTFUNC( SoundType, "Gets the raw sound type." )
DEFINE_SCRIPTFUNC( SoundContext, "Gets the sound type with contexts only." )
DEFINE_SCRIPTFUNC( SoundTypeNoContext, "Gets the sound type with contexts excluded." )
DEFINE_SCRIPTFUNC( Volume, "Gets the sound's volume." )
DEFINE_SCRIPTFUNC( OccludedVolume, "Gets the sound's occluded volume." )
DEFINE_SCRIPTFUNC( Reset, "Clears the volume, type, and origin for the sound without actually removing it." )
DEFINE_SCRIPTFUNC( SoundChannel, "Gets the sound's channel." )
DEFINE_SCRIPTFUNC( ValidateOwner, "Returns true if the sound's owner is still valid or if the sound never had an owner in the first place." )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetOwner, "GetOwner", "Gets the sound's owner." )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetTarget, "GetTarget", "Gets the sound's target." )
END_SCRIPTDESC();
#endif
//=========================================================
// CSound - Clear - zeros all fields for a sound

View File

@ -136,6 +136,12 @@ public:
int SoundChannel( void ) const;
bool ValidateOwner() const;
#ifdef MAPBASE_VSCRIPT
// For VScript functions
HSCRIPT ScriptGetOwner() const { return ToHScript( m_hOwner ); }
HSCRIPT ScriptGetTarget() const { return ToHScript( m_hTarget ); }
#endif
EHANDLE m_hOwner; // sound's owner
EHANDLE m_hTarget; // Sounds's target - an odd concept. For a gunfire sound, the target is the entity being fired at
int m_iVolume; // how loud the sound is

View File

@ -578,9 +578,11 @@ bool VScriptServerInit()
#ifdef MAPBASE_VSCRIPT
g_pScriptVM->RegisterAllClasses();
g_pScriptVM->RegisterAllEnums();
IGameSystem::RegisterVScriptAllSystems();
RegisterSharedScriptConstants();
RegisterSharedScriptFunctions();
#endif

View File

@ -2153,6 +2153,7 @@ typedef enum
ACT_IDLE_AR2_RELAXED,
ACT_IDLE_AR2_STIMULATED,
ACT_WALK_AR2_RELAXED,
ACT_RUN_AR2_RELAXED,
ACT_WALK_AR2_STIMULATED,

View File

@ -444,6 +444,15 @@ bool CBaseEntity::KeyValue( const char *szKeyName, const char *szValue )
return true;
}
#ifdef MAPBASE
if ( FStrEq( szKeyName, "eflags" ) )
{
// Can't use DEFINE_KEYFIELD since eflags might be set before KV are parsed
AddEFlags( atoi( szValue ) );
return true;
}
#endif
#ifdef GAME_DLL
if ( FStrEq( szKeyName, "targetname" ) )
@ -1604,23 +1613,21 @@ typedef CTraceFilterSimpleList CBulletsTraceFilter;
void CBaseEntity::FireBullets( const FireBulletsInfo_t &info )
{
#if defined(MAPBASE_VSCRIPT) && defined(GAME_DLL)
if (m_ScriptScope.IsInitialized())
if (HSCRIPT hFunc = LookupScriptFunction("FireBullets"))
{
CFireBulletsInfoAccessor pInfo( const_cast<FireBulletsInfo_t*>(&info) );
HSCRIPT hInfo = g_pScriptVM->RegisterInstance( &pInfo );
HSCRIPT hInfo = g_pScriptVM->RegisterInstance( const_cast<FireBulletsInfo_t*>(&info) );
g_pScriptVM->SetValue( "info", hInfo );
ScriptVariant_t functionReturn;
if ( CallScriptFunction( "FireBullets", &functionReturn ) )
{
if (!functionReturn.m_bool)
return;
}
CallScriptFunctionHandle( hFunc, &functionReturn );
g_pScriptVM->RemoveInstance( hInfo );
g_pScriptVM->ClearValue( "info" );
if (!functionReturn.m_bool)
return;
}
#endif

View File

@ -55,6 +55,10 @@ ConVar player_limit_jump_speed( "player_limit_jump_speed", "1", FCVAR_REPLICATED
// duck controls. Its value is meaningless anytime we don't have the options window open.
ConVar option_duck_method("option_duck_method", "1", FCVAR_REPLICATED|FCVAR_ARCHIVE );// 0 = HOLD to duck, 1 = Duck is a toggle
#ifdef MAPBASE
ConVar player_crouch_multiplier( "player_crouch_multiplier", "0.33333333", FCVAR_NONE );
#endif
#ifdef STAGING_ONLY
#ifdef CLIENT_DLL
ConVar debug_latch_reset_onduck( "debug_latch_reset_onduck", "1", FCVAR_CHEAT );
@ -4303,7 +4307,8 @@ void CGameMovement::HandleDuckingSpeedCrop( void )
{
if ( !( m_iSpeedCropped & SPEED_CROPPED_DUCK ) && ( player->GetFlags() & FL_DUCKING ) && ( player->GetGroundEntity() != NULL ) )
{
float frac = 0.33333333f;
// Mapbase makes this an adjustable convar
float frac = player_crouch_multiplier.GetFloat();
mv->m_flForwardMove *= frac;
mv->m_flSideMove *= frac;
mv->m_flUpMove *= frac;

View File

@ -298,6 +298,10 @@ public:
virtual CBaseEntity *GetPlayerSpawnSpot( CBasePlayer *pPlayer );// Place this player on their spawnspot and face them the proper direction.
virtual bool IsSpawnPointValid( CBaseEntity *pSpot, CBasePlayer *pPlayer );
#ifdef MAPBASE
virtual bool AllowSPRespawn() { return false; }
#endif
virtual bool AllowAutoTargetCrosshair( void ) { return TRUE; };
virtual bool ClientCommand( CBaseEntity *pEdict, const CCommand &args ); // handles the user commands; returns TRUE if command handled properly
virtual void ClientSettingsChanged( CBasePlayer *pPlayer ); // the player has changed cvars

View File

@ -49,6 +49,7 @@ BEGIN_DATADESC( CHalfLife2Proxy )
DEFINE_FIELD( m_save_LegacyFlashlight, FIELD_CHARACTER ),
DEFINE_FIELD( m_save_PlayerSquadAutosummonDisabled, FIELD_BOOLEAN ),
DEFINE_FIELD( m_save_StunstickPickupBehavior, FIELD_INTEGER ),
DEFINE_FIELD( m_save_AllowSPRespawn, FIELD_BOOLEAN ),
// Inputs
DEFINE_INPUTFUNC( FIELD_VOID, "EpisodicOn", InputEpisodicOn ),
@ -60,6 +61,7 @@ BEGIN_DATADESC( CHalfLife2Proxy )
DEFINE_INPUTFUNC( FIELD_STRING, "SetLegacyFlashlight", InputSetLegacyFlashlight ),
DEFINE_INPUTFUNC( FIELD_STRING, "SetPlayerSquadAutosummon", InputSetPlayerSquadAutosummon ),
DEFINE_INPUTFUNC( FIELD_STRING, "SetStunstickPickupBehavior", InputSetStunstickPickupBehavior ),
DEFINE_INPUTFUNC( FIELD_STRING, "SetAllowSPRespawn", InputSetAllowSPRespawn ),
END_DATADESC()
#endif
@ -75,6 +77,7 @@ void CHalfLife2Proxy::InputSetDefaultCitizenType( inputdata_t &inputdata ) { Key
void CHalfLife2Proxy::InputSetLegacyFlashlight( inputdata_t &inputdata ) { KeyValue("SetLegacyFlashlight", inputdata.value.String()); }
void CHalfLife2Proxy::InputSetPlayerSquadAutosummon( inputdata_t &inputdata ) { KeyValue("SetPlayerSquadAutosummon", inputdata.value.String()); }
void CHalfLife2Proxy::InputSetStunstickPickupBehavior( inputdata_t &inputdata ) { KeyValue("SetStunstickPickupBehavior", inputdata.value.String()); }
void CHalfLife2Proxy::InputSetAllowSPRespawn( inputdata_t &inputdata ) { KeyValue( "SetAllowSPRespawn", inputdata.value.String() ); }
//-----------------------------------------------------------------------------
// Purpose: Cache user entity field values until spawn is called.
@ -129,6 +132,10 @@ bool CHalfLife2Proxy::KeyValue( const char *szKeyName, const char *szValue )
{
HL2GameRules()->SetStunstickPickupBehavior(atoi(szValue));
}
else if (FStrEq(szKeyName, "SetAllowSPRespawn"))
{
HL2GameRules()->SetAllowSPRespawn(!FStrEq(szValue, "0"));
}
else
{
return BaseClass::KeyValue( szKeyName, szValue );
@ -155,10 +162,18 @@ bool CHalfLife2Proxy::GetKeyValue( const char *szKeyName, char *szValue, int iMa
{
Q_snprintf( szValue, iMaxLen, "%d", g_bUseLegacyFlashlight );
}
else if (FStrEq(szKeyName, "SetPlayerSquadAutosummon"))
{
Q_snprintf( szValue, iMaxLen, "%d", HL2GameRules()->AutosummonDisabled() );
}
else if (FStrEq(szKeyName, "SetStunstickPickupBehavior"))
{
Q_snprintf( szValue, iMaxLen, "%i", HL2GameRules()->GetStunstickPickupBehavior() );
}
else if (FStrEq(szKeyName, "SetAllowSPRespawn"))
{
Q_snprintf( szValue, iMaxLen, "%d", HL2GameRules()->AllowSPRespawn() );
}
else
{
return BaseClass::GetKeyValue( szKeyName, szValue, iMaxLen );
@ -184,6 +199,8 @@ int CHalfLife2Proxy::Save( ISave &save )
m_save_StunstickPickupBehavior = HL2GameRules()->GetStunstickPickupBehavior();
m_save_AllowSPRespawn = HL2GameRules()->AllowSPRespawn();
return BaseClass::Save(save);
}
@ -211,6 +228,8 @@ int CHalfLife2Proxy::Restore( IRestore &restore )
HL2GameRules()->SetStunstickPickupBehavior(m_save_StunstickPickupBehavior);
HL2GameRules()->SetAllowSPRespawn(m_save_AllowSPRespawn);
return base;
}
@ -453,6 +472,7 @@ ConVar alyx_darkness_force( "alyx_darkness_force", "0", FCVAR_CHEAT | FCVAR_REP
#ifdef MAPBASE
m_DefaultCitizenType = 0;
m_bPlayerSquadAutosummonDisabled = false;
m_bAllowSPRespawn = false;
#endif
}
@ -2047,6 +2067,22 @@ void CHalfLife2::SetStunstickPickupBehavior(int val)
m_StunstickPickupBehavior = val;
}
//-----------------------------------------------------------------------------
// Gets our SP respawn setting.
//-----------------------------------------------------------------------------
bool CHalfLife2::AllowSPRespawn()
{
return m_bAllowSPRespawn;
}
//-----------------------------------------------------------------------------
// Sets our SP respawn setting.
//-----------------------------------------------------------------------------
void CHalfLife2::SetAllowSPRespawn( bool toggle )
{
m_bAllowSPRespawn = toggle;
}
//BEGIN_SIMPLE_DATADESC( CHalfLife2 )
//
// DEFINE_FIELD( m_DefaultCitizenType, FIELD_INTEGER ),

View File

@ -46,6 +46,7 @@ public:
void InputSetLegacyFlashlight( inputdata_t &inputdata );
void InputSetPlayerSquadAutosummon( inputdata_t &inputdata );
void InputSetStunstickPickupBehavior( inputdata_t &inputdata );
void InputSetAllowSPRespawn( inputdata_t &inputdata );
// Gamerules classes don't seem to support datadescs, so the hl2_gamerules entity takes the current values
// from the actual gamerules and saves them in the entity itself, where they're saved via the entity's own datadesc.
@ -54,6 +55,7 @@ public:
char m_save_LegacyFlashlight;
bool m_save_PlayerSquadAutosummonDisabled;
int m_save_StunstickPickupBehavior;
bool m_save_AllowSPRespawn;
DECLARE_DATADESC();
#endif
@ -136,6 +138,9 @@ public:
int GetStunstickPickupBehavior();
void SetStunstickPickupBehavior(int val);
virtual bool AllowSPRespawn();
void SetAllowSPRespawn( bool toggle );
#endif
private:
@ -147,6 +152,7 @@ private:
int m_DefaultCitizenType;
bool m_bPlayerSquadAutosummonDisabled;
int m_StunstickPickupBehavior;
bool m_bAllowSPRespawn;
#endif
void AdjustPlayerDamageTaken( CTakeDamageInfo *pInfo );

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: The flimsy MapEdit system that was
// heavily inspired by Synergy's MapEdit, completely based on the Commentary System

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: Accessing MapEdit
//

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: A special system designed to record game information for map testing.
//

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: Mapbase's RPC implementation.
//
@ -400,7 +400,7 @@ void MapbaseRPC_Update( int iRPCMask, int iType, const char *pMapName )
void MapbaseRPC_UpdateSteam( int iType, const char *pMapName )
{
// No Steam
if (!steamapicontext)
if (!steamapicontext || !steamapicontext->SteamFriends())
return;
const char *pszStatus = NULL;

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose: Carries the Mapbase CAutoGameSystem that loads manifest among other things.
// Also includes code that does not fit anywhere else.
@ -38,11 +38,6 @@
#define AUTOLOADED_MANIFEST_FILE UTIL_VarArgs("maps/%s_manifest.txt", g_MapName)
#endif
// The soundscape system does not operate in a way that supports soundscape loading after map initialization.
// I have decided to make a direct change to the system that loads "maps/%mapname%_soundscapes.txt" instead and suggest the usage of #include and #base to users.
// Sorry. It's not broken, so I won't fix it.
#define MAPBASE_SOUNDSCAPE_SUPPORT 0
const char *g_MapName;
extern ISoundEmitterSystemBase *soundemitterbase;
@ -53,16 +48,14 @@ ConVar mapbase_load_soundscripts("mapbase_load_soundscripts", "1", FCVAR_ARCHIVE
//ConVar mapbase_load_propdata("mapbase_load_propdata", "1", FCVAR_ARCHIVE, "Should we load map-specific propdata files? e.g. \"maps/mapname_propdata.txt\"");
#if MAPBASE_SOUNDSCAPE_SUPPORT
ConVar mapbase_load_soundscapes("mapbase_load_soundscapes", "1", FCVAR_ARCHIVE, "Should we load map-specific soundscapes? e.g. \"maps/mapname_soundscapes.txt\"");
#endif
//ConVar mapbase_load_soundscapes("mapbase_load_soundscapes", "1", FCVAR_ARCHIVE, "Should we load map-specific soundscapes? e.g. \"maps/mapname_soundscapes.txt\"");
ConVar mapbase_load_localization("mapbase_load_localization", "1", FCVAR_ARCHIVE, "Should we load map-specific localized text files? e.g. \"maps/mapname_english.txt\"");
#ifdef CLIENT_DLL
//ConVar mapbase_load_cc("mapbase_load_cc", "1", FCVAR_ARCHIVE, "Should we load map-specific closed captioning? e.g. \"maps/mapname_closecaption_english.txt\" and \"maps/mapname_closecaption_english.dat\"");
ConVar mapbase_load_localization("mapbase_load_localization", "1", FCVAR_ARCHIVE, "Should we load map-specific localized text files? e.g. \"maps/mapname_english.txt\"");
#else
ConVar mapbase_load_sentences("mapbase_load_sentences", "1", FCVAR_ARCHIVE, "Should we load map-specific sentences? e.g. \"maps/mapname_sentences.txt\"");
@ -96,12 +89,10 @@ enum
{
MANIFEST_SOUNDSCRIPTS,
//MANIFEST_PROPDATA,
#if MAPBASE_SOUNDSCAPE_SUPPORT
MANIFEST_SOUNDSCAPES,
#endif
//MANIFEST_SOUNDSCAPES,
MANIFEST_LOCALIZATION,
#ifdef CLIENT_DLL
//MANIFEST_CLOSECAPTION,
MANIFEST_LOCALIZATION,
MANIFEST_VGUI,
#else
MANIFEST_TALKER,
@ -124,12 +115,10 @@ struct ManifestType_t
static const ManifestType_t gm_szManifestFileStrings[MANIFEST_NUM_TYPES] = {
{ "soundscripts", &mapbase_load_soundscripts },
//{ "propdata", &mapbase_load_propdata },
#if MAPBASE_SOUNDSCAPE_SUPPORT
{ "soundscapes", &mapbase_load_soundscapes },
#endif
//{ "soundscapes", &mapbase_load_soundscapes },
{ "localization", &mapbase_load_localization },
#ifdef CLIENT_DLL
//{ "closecaption", &mapbase_load_cc },
{ "localization", &mapbase_load_localization },
{ "vgui", NULL },
#else
{ "talker", &mapbase_load_talker },
@ -152,7 +141,31 @@ public:
inline bool GetGameInfoKeyValues(KeyValues *pKeyValues)
{
return pKeyValues->LoadFromFile( filesystem, "gameinfo.txt", "GAME" );
return pKeyValues->LoadFromFile( filesystem, "gameinfo.txt", "MOD" );
}
virtual bool Init()
{
// Checks gameinfo.txt for additional command line options
KeyValues *gameinfo = new KeyValues("GameInfo");
if (GetGameInfoKeyValues(gameinfo))
{
KeyValues *pCommandLineList = gameinfo->FindKey("CommandLine", false);
if (pCommandLineList)
{
for (KeyValues *pKey = pCommandLineList->GetFirstSubKey(); pKey; pKey = pKey->GetNextKey())
{
CommandLine()->AppendParm( pKey->GetName(), pKey->GetString() );
}
}
}
gameinfo->deleteThis();
#ifdef CLIENT_DLL
InitializeRTs();
#endif
return true;
}
virtual void LevelInitPreEntity()
@ -193,17 +206,17 @@ public:
#else
//char mapname[128];
//Q_StripExtension(MapName(), mapname, sizeof(mapname));
g_MapName = MapName() - 4; // Removes ".bsp"
g_MapName = MapName();
#endif
// Shared Mapbase localization file
g_pVGuiLocalize->AddFile( "resource/mapbase_%language%.txt" );
#endif
}
virtual void LevelInitPostEntity()
{
// Check for a generic "mapname_manifest.txt" file and load it.
if (filesystem->FileExists( AUTOLOADED_MANIFEST_FILE, "GAME" ) /*&& !FStrEq(name, "closecaption")*/)
if (filesystem->FileExists( AUTOLOADED_MANIFEST_FILE, "GAME" ))
{
AddManifestFile( AUTOLOADED_MANIFEST_FILE );
}
@ -231,6 +244,61 @@ public:
g_MapName = NULL;
}
#ifdef CLIENT_DLL
bool m_bInitializedRTs = false;
CUtlVector<CTextureReference> m_CameraTextures;
//-----------------------------------------------------------------------------
// Initialize custom RT textures if necessary
//-----------------------------------------------------------------------------
void InitializeRTs()
{
if (!m_bInitializedRTs)
{
int iNumCameras = CommandLine()->ParmValue( "-numcameratextures", 3 );
materials->BeginRenderTargetAllocation();
for (int i = 0; i < iNumCameras; i++)
{
char szName[32];
Q_snprintf( szName, sizeof(szName), "_rt_Camera%i", i );
int iRefIndex = m_CameraTextures.AddToTail();
//m_CameraTextures[iRefIndex].InitRenderTarget(
// 256, 256, RT_SIZE_DEFAULT,
// g_pMaterialSystem->GetBackBufferFormat(),
// MATERIAL_RT_DEPTH_SHARED, true, szName );
m_CameraTextures[iRefIndex].Init( g_pMaterialSystem->CreateNamedRenderTargetTextureEx2(
szName,
256, 256, RT_SIZE_DEFAULT,
g_pMaterialSystem->GetBackBufferFormat(),
MATERIAL_RT_DEPTH_SHARED,
0,
CREATERENDERTARGETFLAGS_HDR ) );
}
materials->EndRenderTargetAllocation();
m_bInitializedRTs = true;
}
}
void Shutdown()
{
if (m_bInitializedRTs)
{
for (int i = 0; i < m_CameraTextures.Count(); i++)
{
m_CameraTextures[i].Shutdown();
}
m_bInitializedRTs = false;
}
}
#endif
// Get a generic, hardcoded manifest with hardcoded names.
void ParseGenericManifest()
{
@ -266,7 +334,7 @@ public:
void LoadFromValue( const char *value, int type, bool bDontWarn )
{
if (!filesystem->FileExists(value, "GAME") /*&& !FStrEq(name, "closecaption")*/)
if (!filesystem->FileExists(value, "MOD"))
{
if (!bDontWarn)
{
@ -279,21 +347,17 @@ public:
{
case MANIFEST_SOUNDSCRIPTS: { soundemitterbase->AddSoundOverrides(value); } break;
//case MANIFEST_PROPDATA: { g_PropDataSystem.ParsePropDataFile(value); } break;
case MANIFEST_LOCALIZATION: { g_pVGuiLocalize->AddFile( value, "MOD", true ); } break;
#ifdef CLIENT_DLL
//case MANIFEST_CLOSECAPTION: { todo } break;
case MANIFEST_LOCALIZATION: { g_pVGuiLocalize->AddFile( value, "GAME", true ); } break;
case MANIFEST_VGUI: { PanelMetaClassMgr()->LoadMetaClassDefinitionFile( value ); } break;
#if MAPBASE_SOUNDSCAPE_SUPPORT
case MANIFEST_SOUNDSCAPES: { Soundscape_AddFile(value); } break;
#endif
//case MANIFEST_SOUNDSCAPES: { Soundscape_AddFile(value); } break;
#else
case MANIFEST_TALKER: {
g_bMapContainsCustomTalker = true;
LoadResponseSystemFile(value); //PrecacheCustomResponseSystem( value );
} break;
#if MAPBASE_SOUNDSCAPE_SUPPORT
case MANIFEST_SOUNDSCAPES: { g_SoundscapeSystem.AddSoundscapeFile(value); } break;
#endif
//case MANIFEST_SOUNDSCAPES: { g_SoundscapeSystem.AddSoundscapeFile(value); } break;
case MANIFEST_SENTENCES: { engine->PrecacheSentenceFile(value); } break;
case MANIFEST_ACTBUSY: { ParseCustomActbusyFile(value); } break;
#endif
@ -303,50 +367,47 @@ public:
// This doesn't call deleteThis()!
void AddManifestFile(KeyValues *pKV, bool bDontWarn = false)
{
const char *name;
char value[MAX_PATH];
char *szToken;
bool inparam = false;
const char *name;
for (KeyValues *pKey = pKV->GetFirstSubKey(); pKey; pKey = pKey->GetNextKey())
{
value[0] = '\0';
name = pKey->GetName();
// Parse %mapname%, etc.
inparam = false;
value[0] = '\0';
szToken = strtok(strdup(pKey->GetString()), "%"); // Was tempvalue
while (szToken != NULL)
bool inparam = false;
CUtlStringList outStrings;
V_SplitString( pKey->GetString(), "%", outStrings );
FOR_EACH_VEC( outStrings, i )
{
if (inparam)
{
const char *append = szToken;
if (FStrEq(szToken, "mapname"))
append = g_MapName;
//else if (FStrEq(szToken, "mapdir"))
//{
// // TODO
//}
#ifdef CLIENT_DLL
else if (FStrEq(szToken, "language"))
if (FStrEq( outStrings[i], "mapname" ))
{
Q_strncat( value, g_MapName, sizeof( value ) );
}
else if (FStrEq( outStrings[i], "language" ))
{
#ifdef CLIENT_DLL
char uilanguage[64];
engine->GetUILanguage(uilanguage, sizeof(uilanguage));
append = uilanguage;
}
Q_strncat( value, uilanguage, sizeof( value ) );
#else
// Give up, use English
Q_strncat( value, "english", sizeof( value ) );
#endif
Q_strncat(value, append, sizeof(value));
inparam = false;
}
}
else
{
Q_strncat(value, szToken, sizeof(value));
Q_strncat( value, outStrings[i], sizeof( value ) );
}
inparam = true;
}
szToken = strtok(NULL, "%");
inparam = !inparam;
}
outStrings.PurgeAndDeleteElements();
if (FStrEq(name, "NoErrors"))
{
bDontWarn = pKey->GetBool();
@ -406,6 +467,17 @@ BEGIN_SCRIPTDESC_ROOT( CMapbaseSystem, SCRIPT_SINGLETON "All-purpose Mapbase sys
END_SCRIPTDESC();
#endif
static void CC_Mapbase_LoadManifestFile( const CCommand& args )
{
g_MapbaseSystem.AddManifestFile(args[1]);
}
#ifdef CLIENT_DLL
static ConCommand mapbase_loadmanifestfile("mapbase_loadmanifestfile_client", CC_Mapbase_LoadManifestFile, "Loads a Mapbase manifest file on the client. If you don't want this to be saved and found when reloaded, type a '1' after the file path." );
#else
static ConCommand mapbase_loadmanifestfile("mapbase_loadmanifestfile", CC_Mapbase_LoadManifestFile, "Loads a Mapbase manifest file. If you don't want this to be saved and found when reloaded, type a '1' after the file path." );
#endif
#ifdef GAME_DLL
static CUtlVector<MODTITLECOMMENT> g_MapbaseChapterMaps;
static CUtlVector<MODCHAPTER> g_MapbaseChapterList;
@ -467,13 +539,6 @@ ThreeState_t Flashlight_GetLegacyVersionKey()
return TRS_NONE;
}
static void CC_Mapbase_LoadManifestFile( const CCommand& args )
{
g_MapbaseSystem.AddManifestFile(args[1]);
}
static ConCommand mapbase_loadmanifestfile("mapbase_loadmanifestfile", CC_Mapbase_LoadManifestFile, "Loads a Mapbase manifest file. If you don't want this to be saved and found when reloaded, type a '1' after the file path." );
#define SF_MANIFEST_START_ACTIVATED (1 << 0)
class CMapbaseManifestEntity : public CPointEntity
@ -495,7 +560,7 @@ public:
void LoadManifestFile( void )
{
const char *scriptfile = STRING(m_target);
if ( filesystem->FileExists( scriptfile, "GAME" ) )
if ( filesystem->FileExists( scriptfile, "MOD" ) )
{
Msg("Mapbase: Adding manifest file \"%s\"\n", scriptfile);
g_MapbaseSystem.AddManifestFile(scriptfile);

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. =================
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 =================
//
// Purpose: General matching functions for things like wildcards and !=.
//

View File

@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. =================
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 =================
//
// Purpose: General matching functions for things like wildcards and !=.
//

Some files were not shown because too many files have changed in this diff Show More