diff --git a/.gitignore b/.gitignore index b2eabb93..30855510 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,24 @@ config.cfg # shader files *.tmp +# Unnecessary files +*.lib +*.filters +*.vpc_crc +*.sentinel + +# Backup files +*.bak + +# Build folders +sp/src/.vs/ +sp/src/game/client/Debug_mod_episodic/ +sp/src/game/client/Debug_mod_hl2/ +sp/src/game/client/Release_mod_episodic/ +sp/src/game/client/Release_mod_hl2/ +sp/src/game/server/Debug_mod_episodic/ +sp/src/game/server/Debug_mod_hl2/ +sp/src/game/server/Release_mod_episodic/ +sp/src/game/server/Release_mod_hl2/ +sp/src/*/Debug/ +sp/src/*/Release/ diff --git a/README b/README index 3ade2f32..fcdd4ebc 100644 --- a/README +++ b/README @@ -1,3 +1,22 @@ + Mapbase - Source 2013 + +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 are from Insolence 2013. (https://github.com/95Navigator/insolence-2013) +The projected texture fixes within the "C17EP1_PROJECTED_TEXTURES" preprocessor are from City 17: Episode One. (https://github.com/KyleGospo/City-17-Episode-One-Source) +The vortigaunt LOS fix is from Half-Life 2: Community Edition, more specifically dky.tehkingd.u. (https://gitlab.com/RaraCerberus/HL2CE) +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) +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/). + +All of the work mentioned above was open source when it was borrowed. + +Miscellaneous credits can be found here: +https://trello.com/c/cnaEy4Jr + +Please see the Source SDK 2013 license below: + + + SOURCE 1 SDK LICENSE Source SDK Copyright(c) Valve Corp. diff --git a/sp/src/game/client/C_Env_Projected_Texture.h b/sp/src/game/client/C_Env_Projected_Texture.h index b15ea6ef..df916201 100644 --- a/sp/src/game/client/C_Env_Projected_Texture.h +++ b/sp/src/game/client/C_Env_Projected_Texture.h @@ -14,6 +14,99 @@ #include "c_baseentity.h" #include "basetypes.h" +#ifdef ASW_PROJECTED_TEXTURES + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +class C_EnvProjectedTexture : public C_BaseEntity +{ + DECLARE_CLASS( C_EnvProjectedTexture, C_BaseEntity ); +public: + DECLARE_CLIENTCLASS(); + + void SetMaterial( IMaterial *pMaterial ); + void SetLightColor( byte r, byte g, byte b, byte a ); + void SetSize( float flSize ); + void SetRotation( float flRotation ); + + virtual void OnDataChanged( DataUpdateType_t updateType ); + void ShutDownLightHandle( void ); + +#ifdef MAPBASE + virtual void Simulate(); +#else + virtual bool Simulate(); +#endif + + void UpdateLight( void ); + + C_EnvProjectedTexture(); + ~C_EnvProjectedTexture(); + + static void SetVisibleBBoxMinHeight( float flVisibleBBoxMinHeight ) { m_flVisibleBBoxMinHeight = flVisibleBBoxMinHeight; } + static float GetVisibleBBoxMinHeight( void ) { return m_flVisibleBBoxMinHeight; } + static C_EnvProjectedTexture *Create( ); + +private: + + inline bool IsBBoxVisible( void ); + bool IsBBoxVisible( Vector vecExtentsMin, + Vector vecExtentsMax ); + + ClientShadowHandle_t m_LightHandle; + bool m_bForceUpdate; + + EHANDLE m_hTargetEntity; +#ifdef MAPBASE + bool m_bDontFollowTarget; +#endif + + bool m_bState; + bool m_bAlwaysUpdate; + float m_flLightFOV; +#ifdef MAPBASE + float m_flLightHorFOV; +#endif + bool m_bEnableShadows; + bool m_bLightOnlyTarget; + bool m_bLightWorld; + bool m_bCameraSpace; + float m_flBrightnessScale; + color32 m_LightColor; + Vector m_CurrentLinearFloatLightColor; + float m_flCurrentLinearFloatLightAlpha; +#ifdef MAPBASE + float m_flCurrentBrightnessScale; +#endif + float m_flColorTransitionTime; + float m_flAmbient; + float m_flNearZ; + float m_flFarZ; + char m_SpotlightTextureName[ MAX_PATH ]; + CTextureReference m_SpotlightTexture; + int m_nSpotlightTextureFrame; + int m_nShadowQuality; +#ifdef MAPBASE + bool m_bAlwaysDraw; + //bool m_bProjectedTextureVersion; +#endif + + Vector m_vecExtentsMin; + Vector m_vecExtentsMax; + + static float m_flVisibleBBoxMinHeight; +}; + + + +bool C_EnvProjectedTexture::IsBBoxVisible( void ) +{ + return IsBBoxVisible( GetAbsOrigin() + m_vecExtentsMin, GetAbsOrigin() + m_vecExtentsMax ); +} + +#else + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -62,4 +155,6 @@ public: C_EnvProjectedTexture* GetEnvProjectedTextureList(); +#endif + #endif // C_ENVPROJECTEDTEXTURE_H diff --git a/sp/src/game/client/c_basecombatweapon.cpp b/sp/src/game/client/c_basecombatweapon.cpp index 55d21b39..87a11180 100644 --- a/sp/src/game/client/c_basecombatweapon.cpp +++ b/sp/src/game/client/c_basecombatweapon.cpp @@ -16,6 +16,9 @@ #include "tier1/KeyValues.h" #include "toolframework/itoolframework.h" #include "toolframework_client.h" +#ifdef MAPBASE +#include "viewrender.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -83,8 +86,30 @@ static inline bool ShouldDrawLocalPlayerViewModel( void ) #if defined( PORTAL ) return false; #else + +#ifdef MAPBASE + // We shouldn't draw the viewmodel externally. + C_BasePlayer *localplayer = C_BasePlayer::GetLocalPlayer(); + if (localplayer) + { + if (localplayer->m_bDrawPlayerModelExternally) + { + // If this isn't the main view, draw the weapon. + view_id_t viewID = CurrentViewID(); + if (viewID != VIEW_MAIN && viewID != VIEW_INTRO_CAMERA) + return false; + } + + // Since we already have the local player, check its own ShouldDrawThisPlayer() to avoid extra checks + return localplayer->ShouldDrawThisPlayer(); + } + else + return false; +#else return !C_BasePlayer::ShouldDrawLocalPlayer(); #endif + +#endif } //----------------------------------------------------------------------------- @@ -432,6 +457,12 @@ bool C_BaseCombatWeapon::ShouldDraw( void ) if ( !ShouldDrawLocalPlayerViewModel() ) return true; +#ifdef MAPBASE + // We're drawing this in non-main views, handle it in DrawModel() + if ( pLocalPlayer->m_bDrawPlayerModelExternally ) + return true; +#endif + // don't draw active weapon if not in some kind of 3rd person mode, the viewmodel will do that return false; } @@ -480,6 +511,16 @@ int C_BaseCombatWeapon::DrawModel( int flags ) if ( localplayer && localplayer->IsObserver() && GetOwner() ) { +#ifdef MAPBASE + if (localplayer->m_bDrawPlayerModelExternally) + { + // If this isn't the main view, draw the weapon. + view_id_t viewID = CurrentViewID(); + if (viewID != VIEW_MAIN && viewID != VIEW_INTRO_CAMERA) + return BaseClass::DrawModel( flags ); + } +#endif + // don't draw weapon if chasing this guy as spectator // we don't check that in ShouldDraw() since this may change // without notification diff --git a/sp/src/game/client/c_baseflex.cpp b/sp/src/game/client/c_baseflex.cpp index 6146b2dd..d13e5a75 100644 --- a/sp/src/game/client/c_baseflex.cpp +++ b/sp/src/game/client/c_baseflex.cpp @@ -1149,7 +1149,11 @@ void C_BaseFlex::SetupWeights( const matrix3x4_t *pBoneToWorld, int nFlexWeightC { // hack in an initialization LinkToGlobalFlexControllers( GetModelPtr() ); +#ifdef MAPBASE + m_iBlink = AddGlobalFlexController( "blink" ); +#else m_iBlink = AddGlobalFlexController( "UH" ); +#endif if ( SetupGlobalWeights( pBoneToWorld, nFlexWeightCount, pFlexWeights, pFlexDelayedWeights ) ) { diff --git a/sp/src/game/client/c_baseplayer.cpp b/sp/src/game/client/c_baseplayer.cpp index 942f7a37..3f8f913a 100644 --- a/sp/src/game/client/c_baseplayer.cpp +++ b/sp/src/game/client/c_baseplayer.cpp @@ -54,6 +54,10 @@ #include "econ_wearable.h" #endif +#ifdef MAPBASE +#include "viewrender.h" +#endif + // NVNT haptics system interface #include "haptics/ihaptics.h" @@ -176,6 +180,10 @@ BEGIN_RECV_TABLE_NOBASE( CPlayerLocalData, DT_Local ) // 3d skybox data RecvPropInt(RECVINFO(m_skybox3d.scale)), RecvPropVector(RECVINFO(m_skybox3d.origin)), +#ifdef MAPBASE + RecvPropVector(RECVINFO(m_skybox3d.angles)), + RecvPropInt( RECVINFO( m_skybox3d.skycolor ), 0, RecvProxy_IntToColor32 ), +#endif RecvPropInt(RECVINFO(m_skybox3d.area)), // 3d skybox fog data @@ -187,6 +195,9 @@ BEGIN_RECV_TABLE_NOBASE( CPlayerLocalData, DT_Local ) RecvPropFloat( RECVINFO( m_skybox3d.fog.start ) ), RecvPropFloat( RECVINFO( m_skybox3d.fog.end ) ), RecvPropFloat( RECVINFO( m_skybox3d.fog.maxdensity ) ), +#ifdef MAPBASE + RecvPropFloat( RECVINFO( m_skybox3d.fog.farz ) ), +#endif // fog data RecvPropEHandle( RECVINFO( m_PlayerFog.m_hCtrl ) ), @@ -245,6 +256,14 @@ END_RECV_TABLE() RecvPropInt ( RECVINFO( m_nWaterLevel ) ), RecvPropFloat ( RECVINFO( m_flLaggedMovementValue )), +#ifdef MAPBASE + // Transmitted from the server for internal player spawnflags. + // See baseplayer_shared.h for more details. + RecvPropInt ( RECVINFO( m_spawnflags ) ), + + RecvPropBool ( RECVINFO( m_bDrawPlayerModelExternally ) ), +#endif + END_RECV_TABLE() @@ -1054,6 +1073,16 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd ) // If we're in vgui mode *and* we're holding down mouse buttons, // stay in vgui mode even if we're outside the screen bounds +#ifdef VGUI_SCREEN_FIX + if (m_pCurrentVguiScreen.Get() && (pCmd->buttons & (IN_ATTACK | IN_ATTACK2 | IN_VALIDVGUIINPUT))) + { + SetVGuiScreenButtonState( m_pCurrentVguiScreen.Get(), pCmd->buttons ); + + // Kill all attack inputs if we're in vgui screen mode + pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2 | IN_VALIDVGUIINPUT); + return; + } +#else if (m_pCurrentVguiScreen.Get() && (pCmd->buttons & (IN_ATTACK | IN_ATTACK2)) ) { SetVGuiScreenButtonState( m_pCurrentVguiScreen.Get(), pCmd->buttons ); @@ -1062,6 +1091,7 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd ) pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2); return; } +#endif // We're not in vgui input mode if we're moving, or have hit a key // that will make us move... @@ -1183,7 +1213,12 @@ bool C_BasePlayer::CreateMove( float flInputSampleTime, CUserCmd *pCmd ) m_vecOldViewAngles = pCmd->viewangles; // Check to see if we're in vgui input mode... +#ifdef VGUI_SCREEN_FIX + if(pCmd->buttons & IN_VALIDVGUIINPUT) + DetermineVguiInputMode( pCmd ); +#else DetermineVguiInputMode( pCmd ); +#endif return true; } @@ -1385,11 +1420,34 @@ bool C_BasePlayer::ShouldInterpolate() bool C_BasePlayer::ShouldDraw() { +#ifdef MAPBASE + // We have to "always draw" a player with m_bDrawPlayerModelExternally in order to show up in whatever rendering list all of the views use, + // but we can't put this in ShouldDrawThisPlayer() because we would have no way of knowing if it stomps the other checks that draw the player model anyway. + // As a result, we have to put it here in the central ShouldDraw() function. DrawModel() makes sure we only draw in non-main views and nothing's drawing the model anyway. + return (ShouldDrawThisPlayer() || m_bDrawPlayerModelExternally) && BaseClass::ShouldDraw(); +#else return ShouldDrawThisPlayer() && BaseClass::ShouldDraw(); +#endif } int C_BasePlayer::DrawModel( int flags ) { +#ifdef MAPBASE + if (m_bDrawPlayerModelExternally) + { + // Draw the player in any view except the main or "intro" view, both of which are default first-person views. + view_id_t viewID = CurrentViewID(); + if (viewID == VIEW_MAIN || viewID == VIEW_INTRO_CAMERA) + { + // Make sure the player model wouldn't draw anyway... + if (!ShouldDrawThisPlayer()) + return 0; + } + + return BaseClass::DrawModel( flags ); + } +#endif + #ifndef PORTAL // In Portal this check is already performed as part of // C_Portal_Player::DrawModel() @@ -1398,6 +1456,7 @@ int C_BasePlayer::DrawModel( int flags ) return 0; } #endif + return BaseClass::DrawModel( flags ); } diff --git a/sp/src/game/client/c_baseplayer.h b/sp/src/game/client/c_baseplayer.h index 9d3657bf..5faec479 100644 --- a/sp/src/game/client/c_baseplayer.h +++ b/sp/src/game/client/c_baseplayer.h @@ -443,6 +443,19 @@ public: float m_flConstraintWidth; float m_flConstraintSpeedFactor; +#ifdef MAPBASE + // Transmitted from the server for internal player spawnflags. + // See baseplayer_shared.h for more details. + int m_spawnflags; + + inline bool HasSpawnFlags( int flags ) { return (m_spawnflags & flags) != 0; } + inline void RemoveSpawnFlags( int flags ) { m_spawnflags &= ~flags; } + inline void AddSpawnFlags( int flags ) { m_spawnflags |= flags; } + + // Allows the player's model to draw on non-main views, like monitors or mirrors. + bool m_bDrawPlayerModelExternally; +#endif + protected: void CalcPlayerView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov ); diff --git a/sp/src/game/client/c_effects.cpp b/sp/src/game/client/c_effects.cpp index 14a90a4c..b2a5f21c 100644 --- a/sp/src/game/client/c_effects.cpp +++ b/sp/src/game/client/c_effects.cpp @@ -33,7 +33,14 @@ Vector g_vSplashColor( 0.5, 0.5, 0.5 ); float g_flSplashScale = 0.15; float g_flSplashLifetime = 0.5f; float g_flSplashAlpha = 0.3f; +#ifdef MAPBASE +// Rain splash stuff based on Tony Sergei's VDC code +// (r_RainParticle can be found in effects.cpp on the server as well) +ConVar r_RainParticle("r_RainParticle", "Rain_01_impact", FCVAR_CHEAT | FCVAR_REPLICATED); +ConVar r_RainSplashPercentage( "r_RainSplashPercentage", "99", FCVAR_CHEAT ); // N% chance of a rain particle making a splash. +#else ConVar r_RainSplashPercentage( "r_RainSplashPercentage", "20", FCVAR_CHEAT ); // N% chance of a rain particle making a splash. +#endif float GUST_INTERVAL_MIN = 1; @@ -324,6 +331,20 @@ inline bool CClient_Precipitation::SimulateRain( CPrecipitationParticle* pPartic } } +#ifdef MAPBASE + // Based on Tony Sergi's code on the VDC. This version re-uses m_Splashes instead of dispatching the effect immediately. + trace_t trace; + UTIL_TraceLine(vOldPos, pParticle->m_Pos, MASK_SOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &trace); + + if (trace.fraction < 1 || trace.DidHit()) + { + if (RandomInt(0, 100) <= r_RainSplashPercentage.GetInt()) + m_Splashes.AddToTail( trace.endpos ); + + // Tell the framework it's time to remove the particle from the list + return false; + } +#else // No longer in the air? punt. if ( !IsInAir( pParticle->m_Pos ) ) { @@ -344,6 +365,7 @@ inline bool CClient_Precipitation::SimulateRain( CPrecipitationParticle* pPartic // Tell the framework it's time to remove the particle from the list return false; } +#endif // We still want this particle return true; @@ -550,7 +572,15 @@ void CClient_Precipitation::CreateWaterSplashes() if ( CurrentViewForward().Dot( vSplash - CurrentViewOrigin() ) > 1 ) { +#ifdef MAPBASE + // Use a particle or + if ( r_RainParticle.GetString()[0] != NULL ) + DispatchParticleEffect(r_RainParticle.GetString(), vSplash, QAngle(RandomFloat(0, 360), RandomFloat(0, 360), RandomFloat(0, 360)), NULL); + else + FX_WaterRipple( vSplash, g_flSplashScale, &g_vSplashColor, g_flSplashLifetime, g_flSplashAlpha ); +#else FX_WaterRipple( vSplash, g_flSplashScale, &g_vSplashColor, g_flSplashLifetime, g_flSplashAlpha ); +#endif } } m_Splashes.Purge(); @@ -668,6 +698,13 @@ void CClient_Precipitation::Precache( ) case PRECIPITATION_TYPE_RAIN: Assert( m_nPrecipType == PRECIPITATION_TYPE_RAIN ); +#ifdef MAPBASE + if (r_RainParticle.GetString()[0] != NULL) + { + PrecacheParticleSystem( r_RainParticle.GetString() ); + DevMsg("Rain particle system \"%s\" precached!\n", r_RainParticle.GetString()); + } +#endif m_Speed = RAIN_SPEED; m_MatHandle = materials->FindMaterial( "particle/rain", TEXTURE_GROUP_CLIENT_EFFECTS ); m_InitialRamp = 1.0f; @@ -1206,6 +1243,11 @@ BEGIN_RECV_TABLE_NOBASE(CEnvWindShared, DT_EnvWindShared) RecvPropFloat (RECVINFO(m_flStartTime)), RecvPropFloat (RECVINFO(m_flGustDuration)), // RecvPropInt (RECVINFO(m_iszGustSound)), +#ifdef MAPBASE + RecvPropFloat (RECVINFO(m_windRadius)), + RecvPropFloat (RECVINFO(m_windRadiusInner)), + RecvPropVector (RECVINFO(m_location)), +#endif END_RECV_TABLE() IMPLEMENT_CLIENTCLASS_DT( C_EnvWind, DT_EnvWind, CEnvWind ) @@ -1540,8 +1582,12 @@ public: pParticle->m_vecVelocity *= flSpeed; +#ifdef MAPBASE + Vector vecWindVelocity = GetWindspeedAtLocation( pParticle->m_Pos ); +#else Vector vecWindVelocity; GetWindspeedAtTime( gpGlobals->curtime, vecWindVelocity ); +#endif pParticle->m_vecVelocity += ( vecWindVelocity * r_SnowWindScale.GetFloat() ); } diff --git a/sp/src/game/client/c_env_global_light.cpp b/sp/src/game/client/c_env_global_light.cpp new file mode 100644 index 00000000..3647fff9 --- /dev/null +++ b/sp/src/game/client/c_env_global_light.cpp @@ -0,0 +1,331 @@ +//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============// +// +// Purpose: Sunlight shadow control entity. +// +// $NoKeywords: $ +//=============================================================================// +#include "cbase.h" + +#include "c_baseplayer.h" +#include "tier0/vprof.h" +#ifdef MAPBASE +#include "materialsystem/itexture.h" +#endif + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + + +extern ConVar cl_sunlight_ortho_size; +extern ConVar cl_sunlight_depthbias; + +ConVar cl_globallight_freeze( "cl_globallight_freeze", "0" ); +#ifdef MAPBASE +// I imagine these values might've been designed for the ASW view. +// You can set these as KV anyway. +ConVar cl_globallight_xoffset( "cl_globallight_xoffset", "0" ); +ConVar cl_globallight_yoffset( "cl_globallight_yoffset", "0" ); +#else +ConVar cl_globallight_xoffset( "cl_globallight_xoffset", "-800" ); +ConVar cl_globallight_yoffset( "cl_globallight_yoffset", "1600" ); +#endif + +//------------------------------------------------------------------------------ +// Purpose : Sunlights shadow control entity +//------------------------------------------------------------------------------ +class C_GlobalLight : public C_BaseEntity +{ +public: + DECLARE_CLASS( C_GlobalLight, C_BaseEntity ); + + DECLARE_CLIENTCLASS(); + + virtual ~C_GlobalLight(); + + void OnDataChanged( DataUpdateType_t updateType ); + void Spawn(); + bool ShouldDraw(); + + void ClientThink(); + +private: + Vector m_shadowDirection; + bool m_bEnabled; + char m_TextureName[ MAX_PATH ]; +#ifdef MAPBASE + int m_nSpotlightTextureFrame; +#endif + CTextureReference m_SpotlightTexture; + color32 m_LightColor; +#ifdef MAPBASE + float m_flBrightnessScale; + float m_flCurrentBrightnessScale; +#endif + Vector m_CurrentLinearFloatLightColor; + float m_flCurrentLinearFloatLightAlpha; + float m_flColorTransitionTime; + float m_flSunDistance; + float m_flFOV; + float m_flNearZ; + float m_flNorthOffset; +#ifdef MAPBASE + float m_flEastOffset; + float m_flForwardOffset; + float m_flOrthoSize; +#endif + bool m_bEnableShadows; + bool m_bOldEnableShadows; + + static ClientShadowHandle_t m_LocalFlashlightHandle; +}; + + +ClientShadowHandle_t C_GlobalLight::m_LocalFlashlightHandle = CLIENTSHADOW_INVALID_HANDLE; + + +IMPLEMENT_CLIENTCLASS_DT(C_GlobalLight, DT_GlobalLight, CGlobalLight) + RecvPropVector(RECVINFO(m_shadowDirection)), + RecvPropBool(RECVINFO(m_bEnabled)), + RecvPropString(RECVINFO(m_TextureName)), +#ifdef MAPBASE + RecvPropInt(RECVINFO(m_nSpotlightTextureFrame)), +#endif + /*RecvPropInt(RECVINFO(m_LightColor), 0, RecvProxy_Int32ToColor32),*/ + RecvPropInt(RECVINFO(m_LightColor), 0, RecvProxy_IntToColor32), +#ifdef MAPBASE + RecvPropFloat(RECVINFO(m_flBrightnessScale)), +#endif + RecvPropFloat(RECVINFO(m_flColorTransitionTime)), + RecvPropFloat(RECVINFO(m_flSunDistance)), + RecvPropFloat(RECVINFO(m_flFOV)), + RecvPropFloat(RECVINFO(m_flNearZ)), + RecvPropFloat(RECVINFO(m_flNorthOffset)), +#ifdef MAPBASE + RecvPropFloat(RECVINFO(m_flEastOffset)), + RecvPropFloat(RECVINFO(m_flForwardOffset)), + RecvPropFloat(RECVINFO(m_flOrthoSize)), +#endif + RecvPropBool(RECVINFO(m_bEnableShadows)), +END_RECV_TABLE() + + +C_GlobalLight::~C_GlobalLight() +{ + if ( m_LocalFlashlightHandle != CLIENTSHADOW_INVALID_HANDLE ) + { + g_pClientShadowMgr->DestroyFlashlight( m_LocalFlashlightHandle ); + m_LocalFlashlightHandle = CLIENTSHADOW_INVALID_HANDLE; + } +} + +void C_GlobalLight::OnDataChanged( DataUpdateType_t updateType ) +{ + if ( updateType == DATA_UPDATE_CREATED ) + { + m_SpotlightTexture.Init( m_TextureName, TEXTURE_GROUP_OTHER, true ); + } +#ifdef MAPBASE + else //if ( updateType == DATA_UPDATE_DATATABLE_CHANGED ) + { + // It could've been changed via input + if( !FStrEq(m_SpotlightTexture->GetName(), m_TextureName) ) + { + m_SpotlightTexture.Init( m_TextureName, TEXTURE_GROUP_OTHER, true ); + } + } +#endif + + BaseClass::OnDataChanged( updateType ); +} + +void C_GlobalLight::Spawn() +{ + BaseClass::Spawn(); + + m_bOldEnableShadows = m_bEnableShadows; + + SetNextClientThink( CLIENT_THINK_ALWAYS ); +} + +//------------------------------------------------------------------------------ +// We don't draw... +//------------------------------------------------------------------------------ +bool C_GlobalLight::ShouldDraw() +{ + return false; +} + +void C_GlobalLight::ClientThink() +{ + VPROF("C_GlobalLight::ClientThink"); + + bool bSupressWorldLights = false; + + if ( cl_globallight_freeze.GetBool() == true ) + { + return; + } + + if ( m_bEnabled ) + { + Vector vLinearFloatLightColor( m_LightColor.r, m_LightColor.g, m_LightColor.b ); + float flLinearFloatLightAlpha = m_LightColor.a; + +#ifdef MAPBASE + if ( m_CurrentLinearFloatLightColor != vLinearFloatLightColor || m_flCurrentLinearFloatLightAlpha != flLinearFloatLightAlpha || m_flCurrentBrightnessScale != m_flBrightnessScale ) + { + if (m_flColorTransitionTime != 0.0f) + { + float flColorTransitionSpeed = gpGlobals->frametime * m_flColorTransitionTime * 255.0f; + + m_CurrentLinearFloatLightColor.x = Approach( vLinearFloatLightColor.x, m_CurrentLinearFloatLightColor.x, flColorTransitionSpeed ); + m_CurrentLinearFloatLightColor.y = Approach( vLinearFloatLightColor.y, m_CurrentLinearFloatLightColor.y, flColorTransitionSpeed ); + m_CurrentLinearFloatLightColor.z = Approach( vLinearFloatLightColor.z, m_CurrentLinearFloatLightColor.z, flColorTransitionSpeed ); + m_flCurrentLinearFloatLightAlpha = Approach( flLinearFloatLightAlpha, m_flCurrentLinearFloatLightAlpha, flColorTransitionSpeed ); + m_flCurrentBrightnessScale = Approach( m_flBrightnessScale, m_flCurrentBrightnessScale, flColorTransitionSpeed ); + } + else + { + // Just do it instantly + m_CurrentLinearFloatLightColor.x = vLinearFloatLightColor.x; + m_CurrentLinearFloatLightColor.y = vLinearFloatLightColor.y; + m_CurrentLinearFloatLightColor.z = vLinearFloatLightColor.z; + m_flCurrentLinearFloatLightAlpha = flLinearFloatLightAlpha; + m_flCurrentBrightnessScale = m_flBrightnessScale; + } + } +#else + if ( m_CurrentLinearFloatLightColor != vLinearFloatLightColor || m_flCurrentLinearFloatLightAlpha != flLinearFloatLightAlpha ) + { + float flColorTransitionSpeed = gpGlobals->frametime * m_flColorTransitionTime * 255.0f; + + m_CurrentLinearFloatLightColor.x = Approach( vLinearFloatLightColor.x, m_CurrentLinearFloatLightColor.x, flColorTransitionSpeed ); + m_CurrentLinearFloatLightColor.y = Approach( vLinearFloatLightColor.y, m_CurrentLinearFloatLightColor.y, flColorTransitionSpeed ); + m_CurrentLinearFloatLightColor.z = Approach( vLinearFloatLightColor.z, m_CurrentLinearFloatLightColor.z, flColorTransitionSpeed ); + m_flCurrentLinearFloatLightAlpha = Approach( flLinearFloatLightAlpha, m_flCurrentLinearFloatLightAlpha, flColorTransitionSpeed ); + } +#endif + + FlashlightState_t state; + + Vector vDirection = m_shadowDirection; + VectorNormalize( vDirection ); + + //Vector vViewUp = Vector( 0.0f, 1.0f, 0.0f ); + Vector vSunDirection2D = vDirection; + vSunDirection2D.z = 0.0f; + + /*HACK_GETLOCALPLAYER_GUARD( "C_GlobalLight::ClientThink" );*/ + + if ( !C_BasePlayer::GetLocalPlayer() ) + return; + + Vector vPos; + QAngle EyeAngles; + float flZNear, flZFar, flFov; + + C_BasePlayer::GetLocalPlayer()->CalcView( vPos, EyeAngles, flZNear, flZFar, flFov ); +// Vector vPos = C_BasePlayer::GetLocalPlayer()->GetAbsOrigin(); + +// vPos = Vector( 0.0f, 0.0f, 500.0f ); + vPos = ( vPos + vSunDirection2D * m_flNorthOffset ) - vDirection * m_flSunDistance; +#ifdef MAPBASE + vPos += Vector( m_flEastOffset + cl_globallight_xoffset.GetFloat(), m_flForwardOffset + cl_globallight_yoffset.GetFloat(), 0.0f ); +#else + vPos += Vector( cl_globallight_xoffset.GetFloat(), cl_globallight_yoffset.GetFloat(), 0.0f ); +#endif + + QAngle angAngles; + VectorAngles( vDirection, angAngles ); + + Vector vForward, vRight, vUp; + AngleVectors( angAngles, &vForward, &vRight, &vUp ); + + state.m_fHorizontalFOVDegrees = m_flFOV; + state.m_fVerticalFOVDegrees = m_flFOV; + + state.m_vecLightOrigin = vPos; + BasisToQuaternion( vForward, vRight, vUp, state.m_quatOrientation ); + + state.m_fQuadraticAtten = 0.0f; + state.m_fLinearAtten = m_flSunDistance * 2.0f; + state.m_fConstantAtten = 0.0f; + state.m_FarZAtten = m_flSunDistance * 2.0f; + state.m_Color[0] = m_CurrentLinearFloatLightColor.x * ( 1.0f / 255.0f ) * m_flCurrentLinearFloatLightAlpha; + state.m_Color[1] = m_CurrentLinearFloatLightColor.y * ( 1.0f / 255.0f ) * m_flCurrentLinearFloatLightAlpha; + state.m_Color[2] = m_CurrentLinearFloatLightColor.z * ( 1.0f / 255.0f ) * m_flCurrentLinearFloatLightAlpha; + state.m_Color[3] = 0.0f; // fixme: need to make ambient work m_flAmbient; + state.m_NearZ = 4.0f; + state.m_FarZ = m_flSunDistance * 2.0f; + state.m_fBrightnessScale = 2.0f; + state.m_bGlobalLight = true; + +#ifdef MAPBASE + float flOrthoSize = m_flOrthoSize; +#else + float flOrthoSize = 1000.0f; +#endif + + if ( flOrthoSize > 0 ) + { + state.m_bOrtho = true; + state.m_fOrthoLeft = -flOrthoSize; + state.m_fOrthoTop = -flOrthoSize; + state.m_fOrthoRight = flOrthoSize; + state.m_fOrthoBottom = flOrthoSize; + } + else + { + state.m_bOrtho = false; + } + +#ifndef MAPBASE // Don't draw that huge debug thing + state.m_bDrawShadowFrustum = true; +#endif + /*state.m_flShadowSlopeScaleDepthBias = g_pMaterialSystemHardwareConfig->GetShadowSlopeScaleDepthBias();; + state.m_flShadowDepthBias = g_pMaterialSystemHardwareConfig->GetShadowDepthBias();*/ + state.m_bEnableShadows = m_bEnableShadows; + state.m_pSpotlightTexture = m_SpotlightTexture; +#ifdef MAPBASE + state.m_nSpotlightTextureFrame = m_nSpotlightTextureFrame; +#else + state.m_nSpotlightTextureFrame = 0; +#endif + + state.m_nShadowQuality = 1; // Allow entity to affect shadow quality +// state.m_bShadowHighRes = true; + + if ( m_bOldEnableShadows != m_bEnableShadows ) + { + // If they change the shadow enable/disable, we need to make a new handle + if ( m_LocalFlashlightHandle != CLIENTSHADOW_INVALID_HANDLE ) + { + g_pClientShadowMgr->DestroyFlashlight( m_LocalFlashlightHandle ); + m_LocalFlashlightHandle = CLIENTSHADOW_INVALID_HANDLE; + } + + m_bOldEnableShadows = m_bEnableShadows; + } + + if( m_LocalFlashlightHandle == CLIENTSHADOW_INVALID_HANDLE ) + { + m_LocalFlashlightHandle = g_pClientShadowMgr->CreateFlashlight( state ); + } + else + { + g_pClientShadowMgr->UpdateFlashlightState( m_LocalFlashlightHandle, state ); + g_pClientShadowMgr->UpdateProjectedTexture( m_LocalFlashlightHandle, true ); + } + + bSupressWorldLights = m_bEnableShadows; + } + else if ( m_LocalFlashlightHandle != CLIENTSHADOW_INVALID_HANDLE ) + { + g_pClientShadowMgr->DestroyFlashlight( m_LocalFlashlightHandle ); + m_LocalFlashlightHandle = CLIENTSHADOW_INVALID_HANDLE; + } + + g_pClientShadowMgr->SetShadowFromWorldLightsEnabled( !bSupressWorldLights ); + + BaseClass::ClientThink(); +} \ No newline at end of file diff --git a/sp/src/game/client/c_env_projectedtexture.cpp b/sp/src/game/client/c_env_projectedtexture.cpp index 310c3a27..f4e6cffb 100644 --- a/sp/src/game/client/c_env_projectedtexture.cpp +++ b/sp/src/game/client/c_env_projectedtexture.cpp @@ -5,6 +5,13 @@ //============================================================================= #include "cbase.h" +#ifdef ASW_PROJECTED_TEXTURES +#include "C_Env_Projected_Texture.h" +#include "vprof.h" +#endif +#ifdef MAPBASE +#include "materialsystem/itexture.h" +#endif #include "shareddefs.h" #include "materialsystem/imesh.h" #include "materialsystem/imaterial.h" @@ -17,8 +24,462 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" +#ifdef ASW_PROJECTED_TEXTURES +static ConVar mat_slopescaledepthbias_shadowmap( "mat_slopescaledepthbias_shadowmap", "16", FCVAR_CHEAT ); +static ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "0.00001", FCVAR_CHEAT ); + +float C_EnvProjectedTexture::m_flVisibleBBoxMinHeight = -FLT_MAX; + + +IMPLEMENT_CLIENTCLASS_DT( C_EnvProjectedTexture, DT_EnvProjectedTexture, CEnvProjectedTexture ) + RecvPropEHandle( RECVINFO( m_hTargetEntity ) ), +#ifdef MAPBASE + RecvPropBool( RECVINFO( m_bDontFollowTarget )), +#endif + RecvPropBool( RECVINFO( m_bState ) ), + RecvPropBool( RECVINFO( m_bAlwaysUpdate ) ), + RecvPropFloat( RECVINFO( m_flLightFOV ) ), +#ifdef MAPBASE + RecvPropFloat( RECVINFO( m_flLightHorFOV ) ), +#endif + RecvPropBool( RECVINFO( m_bEnableShadows ) ), + RecvPropBool( RECVINFO( m_bLightOnlyTarget ) ), + RecvPropBool( RECVINFO( m_bLightWorld ) ), + RecvPropBool( RECVINFO( m_bCameraSpace ) ), + RecvPropFloat( RECVINFO( m_flBrightnessScale ) ), + RecvPropInt( RECVINFO( m_LightColor ), 0, RecvProxy_IntToColor32 ), + RecvPropFloat( RECVINFO( m_flColorTransitionTime ) ), + RecvPropFloat( RECVINFO( m_flAmbient ) ), + RecvPropString( RECVINFO( m_SpotlightTextureName ) ), + RecvPropInt( RECVINFO( m_nSpotlightTextureFrame ) ), + RecvPropFloat( RECVINFO( m_flNearZ ) ), + RecvPropFloat( RECVINFO( m_flFarZ ) ), + RecvPropInt( RECVINFO( m_nShadowQuality ) ), +#ifdef MAPBASE + RecvPropBool( RECVINFO( m_bAlwaysDraw ) ), + + // Not needed on the client right now, change when it actually is needed + //RecvPropBool( RECVINFO( m_bProjectedTextureVersion ) ), +#endif +END_RECV_TABLE() + +C_EnvProjectedTexture *C_EnvProjectedTexture::Create( ) +{ + C_EnvProjectedTexture *pEnt = new C_EnvProjectedTexture(); + + pEnt->m_flNearZ = 4.0f; + pEnt->m_flFarZ = 2000.0f; +// strcpy( pEnt->m_SpotlightTextureName, "particle/rj" ); + pEnt->m_bLightWorld = true; + pEnt->m_bLightOnlyTarget = false; + pEnt->m_nShadowQuality = 1; + pEnt->m_flLightFOV = 10.0f; +#ifdef MAPBASE + pEnt->m_flLightHorFOV = 10.0f; +#endif + pEnt->m_LightColor.r = 255; + pEnt->m_LightColor.g = 255; + pEnt->m_LightColor.b = 255; + pEnt->m_LightColor.a = 255; + pEnt->m_bEnableShadows = false; + pEnt->m_flColorTransitionTime = 1.0f; + pEnt->m_bCameraSpace = false; + pEnt->SetAbsAngles( QAngle( 90, 0, 0 ) ); + pEnt->m_bAlwaysUpdate = true; + pEnt->m_bState = true; +#ifdef MAPBASE + pEnt->m_bAlwaysDraw = false; + //pEnt->m_bProjectedTextureVersion = 1; +#endif + + return pEnt; +} + +C_EnvProjectedTexture::C_EnvProjectedTexture( void ) +{ + m_LightHandle = CLIENTSHADOW_INVALID_HANDLE; + m_bForceUpdate = true; +#ifndef MAPBASE + AddToEntityList( ENTITY_LIST_SIMULATE ); +#endif +} + +C_EnvProjectedTexture::~C_EnvProjectedTexture( void ) +{ + ShutDownLightHandle(); +} + +void C_EnvProjectedTexture::ShutDownLightHandle( void ) +{ + // Clear out the light + if( m_LightHandle != CLIENTSHADOW_INVALID_HANDLE ) + { + g_pClientShadowMgr->DestroyFlashlight( m_LightHandle ); + m_LightHandle = CLIENTSHADOW_INVALID_HANDLE; + } +} + + +void C_EnvProjectedTexture::SetLightColor( byte r, byte g, byte b, byte a ) +{ + m_LightColor.r = r; + m_LightColor.g = g; + m_LightColor.b = b; + m_LightColor.a = a; +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : updateType - +//----------------------------------------------------------------------------- +void C_EnvProjectedTexture::OnDataChanged( DataUpdateType_t updateType ) +{ + if ( updateType == DATA_UPDATE_CREATED ) + { + m_SpotlightTexture.Init( m_SpotlightTextureName, TEXTURE_GROUP_OTHER, true ); + } +#ifdef MAPBASE + else //if ( updateType == DATA_UPDATE_DATATABLE_CHANGED ) + { + // It could've been changed via input + if( !FStrEq(m_SpotlightTexture->GetName(), m_SpotlightTextureName) ) + { + m_SpotlightTexture.Init( m_SpotlightTextureName, TEXTURE_GROUP_OTHER, true ); + } + } +#endif + + m_bForceUpdate = true; + UpdateLight(); + BaseClass::OnDataChanged( updateType ); +} + +static ConVar asw_perf_wtf("asw_perf_wtf", "0", FCVAR_DEVELOPMENTONLY, "Disable updating of projected shadow textures from UpdateLight" ); +void C_EnvProjectedTexture::UpdateLight( void ) +{ + VPROF("C_EnvProjectedTexture::UpdateLight"); + bool bVisible = true; + + Vector vLinearFloatLightColor( m_LightColor.r, m_LightColor.g, m_LightColor.b ); + float flLinearFloatLightAlpha = m_LightColor.a; + + if ( m_bAlwaysUpdate ) + { + m_bForceUpdate = true; + } + +#ifdef MAPBASE + if ( m_CurrentLinearFloatLightColor != vLinearFloatLightColor || m_flCurrentLinearFloatLightAlpha != flLinearFloatLightAlpha || m_flCurrentBrightnessScale != m_flBrightnessScale ) + { + if (m_flColorTransitionTime != 0.0f) + { + float flColorTransitionSpeed = gpGlobals->frametime * m_flColorTransitionTime * 255.0f; + + m_CurrentLinearFloatLightColor.x = Approach( vLinearFloatLightColor.x, m_CurrentLinearFloatLightColor.x, flColorTransitionSpeed ); + m_CurrentLinearFloatLightColor.y = Approach( vLinearFloatLightColor.y, m_CurrentLinearFloatLightColor.y, flColorTransitionSpeed ); + m_CurrentLinearFloatLightColor.z = Approach( vLinearFloatLightColor.z, m_CurrentLinearFloatLightColor.z, flColorTransitionSpeed ); + m_flCurrentLinearFloatLightAlpha = Approach( flLinearFloatLightAlpha, m_flCurrentLinearFloatLightAlpha, flColorTransitionSpeed ); + m_flCurrentBrightnessScale = Approach( m_flBrightnessScale, m_flCurrentBrightnessScale, flColorTransitionSpeed ); + } + else + { + // Just do it instantly + m_CurrentLinearFloatLightColor.x = vLinearFloatLightColor.x; + m_CurrentLinearFloatLightColor.y = vLinearFloatLightColor.y; + m_CurrentLinearFloatLightColor.z = vLinearFloatLightColor.z; + m_flCurrentLinearFloatLightAlpha = flLinearFloatLightAlpha; + m_flCurrentBrightnessScale = m_flBrightnessScale; + } + + m_bForceUpdate = true; + } +#else + if ( m_CurrentLinearFloatLightColor != vLinearFloatLightColor || m_flCurrentLinearFloatLightAlpha != flLinearFloatLightAlpha ) + { + float flColorTransitionSpeed = gpGlobals->frametime * m_flColorTransitionTime * 255.0f; + + m_CurrentLinearFloatLightColor.x = Approach( vLinearFloatLightColor.x, m_CurrentLinearFloatLightColor.x, flColorTransitionSpeed ); + m_CurrentLinearFloatLightColor.y = Approach( vLinearFloatLightColor.y, m_CurrentLinearFloatLightColor.y, flColorTransitionSpeed ); + m_CurrentLinearFloatLightColor.z = Approach( vLinearFloatLightColor.z, m_CurrentLinearFloatLightColor.z, flColorTransitionSpeed ); + m_flCurrentLinearFloatLightAlpha = Approach( flLinearFloatLightAlpha, m_flCurrentLinearFloatLightAlpha, flColorTransitionSpeed ); + + m_bForceUpdate = true; + } +#endif + + if ( !m_bForceUpdate ) + { + bVisible = IsBBoxVisible(); + } + + if ( m_bState == false || !bVisible ) + { + // Spotlight's extents aren't in view + ShutDownLightHandle(); + + return; + } + + if ( m_LightHandle == CLIENTSHADOW_INVALID_HANDLE || m_hTargetEntity != NULL || m_bForceUpdate ) + { + Vector vForward, vRight, vUp, vPos = GetAbsOrigin(); + FlashlightState_t state; + +#ifdef MAPBASE + if ( m_hTargetEntity != NULL && !m_bDontFollowTarget ) +#else + if ( m_hTargetEntity != NULL ) +#endif + { + if ( m_bCameraSpace ) + { + const QAngle &angles = GetLocalAngles(); + + C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); + if( pPlayer ) + { + const QAngle playerAngles = pPlayer->GetAbsAngles(); + + Vector vPlayerForward, vPlayerRight, vPlayerUp; + AngleVectors( playerAngles, &vPlayerForward, &vPlayerRight, &vPlayerUp ); + + matrix3x4_t mRotMatrix; + AngleMatrix( angles, mRotMatrix ); + + VectorITransform( vPlayerForward, mRotMatrix, vForward ); + VectorITransform( vPlayerRight, mRotMatrix, vRight ); + VectorITransform( vPlayerUp, mRotMatrix, vUp ); + + float dist = (m_hTargetEntity->GetAbsOrigin() - GetAbsOrigin()).Length(); + vPos = m_hTargetEntity->GetAbsOrigin() - vForward*dist; + + VectorNormalize( vForward ); + VectorNormalize( vRight ); + VectorNormalize( vUp ); + } + } + else + { + vForward = m_hTargetEntity->GetAbsOrigin() - GetAbsOrigin(); + VectorNormalize( vForward ); + + // JasonM - unimplemented + Assert (0); + + //Quaternion q = DirectionToOrientation( dir ); + + + // + // JasonM - set up vRight, vUp + // + + // VectorNormalize( vRight ); + // VectorNormalize( vUp ); + } + } + else + { + AngleVectors( GetAbsAngles(), &vForward, &vRight, &vUp ); + } + +#ifdef MAPBASE + float fHighFOV; + if( m_flLightFOV > m_flLightHorFOV ) + fHighFOV = m_flLightFOV; + else + fHighFOV = m_flLightHorFOV; + + state.m_fHorizontalFOVDegrees = m_flLightHorFOV; +#else + state.m_fHorizontalFOVDegrees = m_flLightFOV; +#endif + state.m_fVerticalFOVDegrees = m_flLightFOV; + + state.m_vecLightOrigin = vPos; + BasisToQuaternion( vForward, vRight, vUp, state.m_quatOrientation ); + state.m_NearZ = m_flNearZ; + state.m_FarZ = m_flFarZ; + + // quickly check the proposed light's bbox against the view frustum to determine whether we + // should bother to create it, if it doesn't exist, or cull it, if it does. + // get the half-widths of the near and far planes, + // based on the FOV which is in degrees. Remember that + // on planet Valve, x is forward, y left, and z up. +#ifdef MAPBASE + const float tanHalfAngle = tan( fHighFOV * ( M_PI/180.0f ) * 0.5f ); +#else + const float tanHalfAngle = tan( m_flLightFOV * ( M_PI/180.0f ) * 0.5f ); +#endif + const float halfWidthNear = tanHalfAngle * m_flNearZ; + const float halfWidthFar = tanHalfAngle * m_flFarZ; + // now we can build coordinates in local space: the near rectangle is eg + // (0, -halfWidthNear, -halfWidthNear), (0, halfWidthNear, -halfWidthNear), + // (0, halfWidthNear, halfWidthNear), (0, -halfWidthNear, halfWidthNear) + + VectorAligned vNearRect[4] = { + VectorAligned( m_flNearZ, -halfWidthNear, -halfWidthNear), VectorAligned( m_flNearZ, halfWidthNear, -halfWidthNear), + VectorAligned( m_flNearZ, halfWidthNear, halfWidthNear), VectorAligned( m_flNearZ, -halfWidthNear, halfWidthNear) + }; + + VectorAligned vFarRect[4] = { + VectorAligned( m_flFarZ, -halfWidthFar, -halfWidthFar), VectorAligned( m_flFarZ, halfWidthFar, -halfWidthFar), + VectorAligned( m_flFarZ, halfWidthFar, halfWidthFar), VectorAligned( m_flFarZ, -halfWidthFar, halfWidthFar) + }; + + matrix3x4_t matOrientation( vForward, -vRight, vUp, vPos ); + + enum + { + kNEAR = 0, + kFAR = 1, + }; + VectorAligned vOutRects[2][4]; + + for ( int i = 0 ; i < 4 ; ++i ) + { + VectorTransform( vNearRect[i].Base(), matOrientation, vOutRects[0][i].Base() ); + } + for ( int i = 0 ; i < 4 ; ++i ) + { + VectorTransform( vFarRect[i].Base(), matOrientation, vOutRects[1][i].Base() ); + } + + // now take the min and max extents for the bbox, and see if it is visible. + Vector mins = **vOutRects; + Vector maxs = **vOutRects; + for ( int i = 1; i < 8 ; ++i ) + { + VectorMin( mins, *(*vOutRects+i), mins ); + VectorMax( maxs, *(*vOutRects+i), maxs ); + } + +#if 0 //for debugging the visibility frustum we just calculated + NDebugOverlay::Triangle( vOutRects[0][0], vOutRects[0][1], vOutRects[0][2], 255, 0, 0, 100, true, 0.0f ); //first tri + NDebugOverlay::Triangle( vOutRects[0][2], vOutRects[0][1], vOutRects[0][0], 255, 0, 0, 100, true, 0.0f ); //make it double sided + NDebugOverlay::Triangle( vOutRects[0][2], vOutRects[0][3], vOutRects[0][0], 255, 0, 0, 100, true, 0.0f ); //second tri + NDebugOverlay::Triangle( vOutRects[0][0], vOutRects[0][3], vOutRects[0][2], 255, 0, 0, 100, true, 0.0f ); //make it double sided + + NDebugOverlay::Triangle( vOutRects[1][0], vOutRects[1][1], vOutRects[1][2], 0, 0, 255, 100, true, 0.0f ); //first tri + NDebugOverlay::Triangle( vOutRects[1][2], vOutRects[1][1], vOutRects[1][0], 0, 0, 255, 100, true, 0.0f ); //make it double sided + NDebugOverlay::Triangle( vOutRects[1][2], vOutRects[1][3], vOutRects[1][0], 0, 0, 255, 100, true, 0.0f ); //second tri + NDebugOverlay::Triangle( vOutRects[1][0], vOutRects[1][3], vOutRects[1][2], 0, 0, 255, 100, true, 0.0f ); //make it double sided + + NDebugOverlay::Box( vec3_origin, mins, maxs, 0, 255, 0, 100, 0.0f ); +#endif + + bool bVisible = IsBBoxVisible( mins, maxs ); + if (!bVisible) + { + // Spotlight's extents aren't in view + if ( m_LightHandle != CLIENTSHADOW_INVALID_HANDLE ) + { + ShutDownLightHandle(); + } + + return; + } + + float flAlpha = m_flCurrentLinearFloatLightAlpha * ( 1.0f / 255.0f ); + + state.m_fQuadraticAtten = 0.0; + state.m_fLinearAtten = 100; + state.m_fConstantAtten = 0.0f; + state.m_FarZAtten = m_flFarZ; +#ifdef MAPBASE + state.m_Color[0] = (m_CurrentLinearFloatLightColor.x * ( 1.0f / 255.0f ) * flAlpha) * m_flCurrentBrightnessScale; + state.m_Color[1] = (m_CurrentLinearFloatLightColor.y * ( 1.0f / 255.0f ) * flAlpha) * m_flCurrentBrightnessScale; + state.m_Color[2] = (m_CurrentLinearFloatLightColor.z * ( 1.0f / 255.0f ) * flAlpha) * m_flCurrentBrightnessScale; + state.m_Color[3] = 0.0f; // fixme: need to make ambient work m_flAmbient; + state.m_flShadowSlopeScaleDepthBias = mat_slopescaledepthbias_shadowmap.GetFloat(); + state.m_flShadowDepthBias = mat_depthbias_shadowmap.GetFloat(); +#else + state.m_fBrightnessScale = m_flBrightnessScale; + state.m_Color[0] = m_CurrentLinearFloatLightColor.x * ( 1.0f / 255.0f ) * flAlpha; + state.m_Color[1] = m_CurrentLinearFloatLightColor.y * ( 1.0f / 255.0f ) * flAlpha; + state.m_Color[2] = m_CurrentLinearFloatLightColor.z * ( 1.0f / 255.0f ) * flAlpha; + state.m_Color[3] = 0.0f; // fixme: need to make ambient work m_flAmbient; + state.m_flShadowSlopeScaleDepthBias = g_pMaterialSystemHardwareConfig->GetShadowSlopeScaleDepthBias(); + state.m_flShadowDepthBias = g_pMaterialSystemHardwareConfig->GetShadowDepthBias(); +#endif + state.m_bEnableShadows = m_bEnableShadows; + state.m_pSpotlightTexture = m_SpotlightTexture; + state.m_nSpotlightTextureFrame = m_nSpotlightTextureFrame; + + state.m_nShadowQuality = m_nShadowQuality; // Allow entity to affect shadow quality + +#ifdef MAPBASE + state.m_bAlwaysDraw = m_bAlwaysDraw; +#endif + + if( m_LightHandle == CLIENTSHADOW_INVALID_HANDLE ) + { + m_LightHandle = g_pClientShadowMgr->CreateFlashlight( state ); + + if ( m_LightHandle != CLIENTSHADOW_INVALID_HANDLE ) + { + m_bForceUpdate = false; + } + } + else + { + g_pClientShadowMgr->UpdateFlashlightState( m_LightHandle, state ); + m_bForceUpdate = false; + } + + g_pClientShadowMgr->GetFrustumExtents( m_LightHandle, m_vecExtentsMin, m_vecExtentsMax ); + + m_vecExtentsMin = m_vecExtentsMin - GetAbsOrigin(); + m_vecExtentsMax = m_vecExtentsMax - GetAbsOrigin(); + } + + if( m_bLightOnlyTarget ) + { + g_pClientShadowMgr->SetFlashlightTarget( m_LightHandle, m_hTargetEntity ); + } + else + { + g_pClientShadowMgr->SetFlashlightTarget( m_LightHandle, NULL ); + } + + g_pClientShadowMgr->SetFlashlightLightWorld( m_LightHandle, m_bLightWorld ); + + if ( !asw_perf_wtf.GetBool() && !m_bForceUpdate ) + { + g_pClientShadowMgr->UpdateProjectedTexture( m_LightHandle, true ); + } +} + +void C_EnvProjectedTexture::Simulate( void ) +{ + UpdateLight(); + + BaseClass::Simulate(); +} + +bool C_EnvProjectedTexture::IsBBoxVisible( Vector vecExtentsMin, Vector vecExtentsMax ) +{ +#ifdef MAPBASE + if (m_bAlwaysDraw) + return true; +#endif + + // Z position clamped to the min height (but must be less than the max) + float flVisibleBBoxMinHeight = MIN( vecExtentsMax.z - 1.0f, m_flVisibleBBoxMinHeight ); + vecExtentsMin.z = MAX( vecExtentsMin.z, flVisibleBBoxMinHeight ); + + // Check if the bbox is in the view + return !engine->CullBox( vecExtentsMin, vecExtentsMax ); +} + +#else + +#ifndef MAPBASE static ConVar mat_slopescaledepthbias_shadowmap( "mat_slopescaledepthbias_shadowmap", "16", FCVAR_CHEAT ); static ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "0.0005", FCVAR_CHEAT ); +#else +static ConVar mat_slopescaledepthbias_shadowmap( "mat_slopescaledepthbias_shadowmap", "4", FCVAR_CHEAT ); +static ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "0.00001", FCVAR_CHEAT ); +#endif //----------------------------------------------------------------------------- // Purpose: @@ -34,7 +495,11 @@ public: virtual void Simulate(); +#ifdef MAPBASE + void UpdateLight(); +#else void UpdateLight( bool bForceUpdate ); +#endif C_EnvProjectedTexture(); ~C_EnvProjectedTexture(); @@ -42,10 +507,16 @@ public: private: ClientShadowHandle_t m_LightHandle; +#ifdef MAPBASE + bool m_bForceUpdate; +#endif EHANDLE m_hTargetEntity; bool m_bState; +#ifdef MAPBASE + bool m_bAlwaysUpdate; +#endif float m_flLightFOV; bool m_bEnableShadows; bool m_bLightOnlyTarget; @@ -63,6 +534,9 @@ private: IMPLEMENT_CLIENTCLASS_DT( C_EnvProjectedTexture, DT_EnvProjectedTexture, CEnvProjectedTexture ) RecvPropEHandle( RECVINFO( m_hTargetEntity ) ), RecvPropBool( RECVINFO( m_bState ) ), +#ifdef MAPBASE + RecvPropBool( RECVINFO( m_bAlwaysUpdate ) ), +#endif RecvPropFloat( RECVINFO( m_flLightFOV ) ), RecvPropBool( RECVINFO( m_bEnableShadows ) ), RecvPropBool( RECVINFO( m_bLightOnlyTarget ) ), @@ -103,12 +577,22 @@ void C_EnvProjectedTexture::ShutDownLightHandle( void ) //----------------------------------------------------------------------------- void C_EnvProjectedTexture::OnDataChanged( DataUpdateType_t updateType ) { +#ifdef MAPBASE + m_bForceUpdate = true; + UpdateLight(); +#else UpdateLight( true ); +#endif BaseClass::OnDataChanged( updateType ); } +#ifndef MAPBASE void C_EnvProjectedTexture::UpdateLight( bool bForceUpdate ) +#else +void C_EnvProjectedTexture::UpdateLight() +#endif { +#ifndef MAPBASE if ( m_bState == false ) { if ( m_LightHandle != CLIENTSHADOW_INVALID_HANDLE ) @@ -118,7 +602,25 @@ void C_EnvProjectedTexture::UpdateLight( bool bForceUpdate ) return; } +#else + if ( m_bAlwaysUpdate ) + { + m_bForceUpdate = true; + } + if ( m_bState == false ) + { + // Spotlight's extents aren't in view + ShutDownLightHandle(); + + return; + } +#endif + +#ifdef MAPBASE + if ( m_LightHandle == CLIENTSHADOW_INVALID_HANDLE || m_hTargetEntity != NULL || m_bForceUpdate ) + { +#endif Vector vForward, vRight, vUp, vPos = GetAbsOrigin(); FlashlightState_t state; @@ -153,8 +655,24 @@ void C_EnvProjectedTexture::UpdateLight( bool bForceUpdate ) } else { +#ifndef MAPBASE vForward = m_hTargetEntity->GetAbsOrigin() - GetAbsOrigin(); VectorNormalize( vForward ); +#else + // VXP: Fixing targeting + Vector vecToTarget; + QAngle vecAngles; + if (m_hTargetEntity == NULL) + { + vecAngles = GetAbsAngles(); + } + else + { + vecToTarget = m_hTargetEntity->GetAbsOrigin() - GetAbsOrigin(); + VectorAngles(vecToTarget, vecAngles); + } + AngleVectors(vecAngles, &vForward, &vRight, &vUp); +#endif // JasonM - unimplemented Assert (0); @@ -204,11 +722,19 @@ void C_EnvProjectedTexture::UpdateLight( bool bForceUpdate ) } else { +#ifndef MAPBASE if ( m_hTargetEntity != NULL || bForceUpdate == true ) { g_pClientShadowMgr->UpdateFlashlightState( m_LightHandle, state ); } +#else + g_pClientShadowMgr->UpdateFlashlightState( m_LightHandle, state ); + m_bForceUpdate = false; +#endif } +#ifdef MAPBASE + } +#endif if( m_bLightOnlyTarget ) { @@ -221,16 +747,29 @@ void C_EnvProjectedTexture::UpdateLight( bool bForceUpdate ) g_pClientShadowMgr->SetFlashlightLightWorld( m_LightHandle, m_bLightWorld ); +#ifndef MAPBASE if ( bForceUpdate == false ) { g_pClientShadowMgr->UpdateProjectedTexture( m_LightHandle, true ); } +#else + if ( !m_bForceUpdate ) + { + g_pClientShadowMgr->UpdateProjectedTexture( m_LightHandle, true ); + } +#endif } void C_EnvProjectedTexture::Simulate( void ) { +#ifndef MAPBASE UpdateLight( false ); +#else + UpdateLight(); +#endif BaseClass::Simulate(); } +#endif + diff --git a/sp/src/game/client/c_func_dust.cpp b/sp/src/game/client/c_func_dust.cpp index 94f114e4..c3c3d79d 100644 --- a/sp/src/game/client/c_func_dust.cpp +++ b/sp/src/game/client/c_func_dust.cpp @@ -88,8 +88,9 @@ void CDustEffect::RenderParticles( CParticleRenderIterator *pIterator ) void CDustEffect::SimulateParticles( CParticleSimulateIterator *pIterator ) { Vector vecWind; +#ifndef MAPBASE GetWindspeedAtTime( gpGlobals->curtime, vecWind ); - +#endif CFuncDustParticle *pParticle = (CFuncDustParticle*)pIterator->GetFirst(); while ( pParticle ) @@ -105,6 +106,9 @@ void CDustEffect::SimulateParticles( CParticleSimulateIterator *pIterator ) } else { +#ifdef MAPBASE + vecWind = GetWindspeedAtLocation( pParticle->m_Pos ); +#endif for ( int i = 0 ; i < 2 ; i++ ) { if ( pParticle->m_vVelocity[i] < vecWind[i] ) diff --git a/sp/src/game/client/c_func_lod.cpp b/sp/src/game/client/c_func_lod.cpp index 766cced3..89998824 100644 --- a/sp/src/game/client/c_func_lod.cpp +++ b/sp/src/game/client/c_func_lod.cpp @@ -30,6 +30,9 @@ public: // These are documented in the server-side entity. public: float m_fDisappearDist; +#ifdef MAPBASE + float m_fDisappearMaxDist; +#endif }; @@ -43,6 +46,9 @@ ConVar lod_TransitionDist("lod_TransitionDist", "800"); // Datatable.. IMPLEMENT_CLIENTCLASS_DT(C_Func_LOD, DT_Func_LOD, CFunc_LOD) RecvPropFloat(RECVINFO(m_fDisappearDist)), +#ifdef MAPBASE + RecvPropFloat(RECVINFO(m_fDisappearMaxDist)), +#endif END_RECV_TABLE() @@ -54,6 +60,9 @@ END_RECV_TABLE() C_Func_LOD::C_Func_LOD() { m_fDisappearDist = 5000.0f; +#ifdef MAPBASE + m_fDisappearMaxDist = 0.0f; +#endif } //----------------------------------------------------------------------------- @@ -61,7 +70,11 @@ C_Func_LOD::C_Func_LOD() //----------------------------------------------------------------------------- unsigned char C_Func_LOD::GetClientSideFade() { +#ifdef MAPBASE + return UTIL_ComputeEntityFade( this, m_fDisappearDist, m_fDisappearDist + (m_fDisappearMaxDist != 0 ? m_fDisappearMaxDist : lod_TransitionDist.GetFloat()), 1.0f ); +#else return UTIL_ComputeEntityFade( this, m_fDisappearDist, m_fDisappearDist + lod_TransitionDist.GetFloat(), 1.0f ); +#endif } diff --git a/sp/src/game/client/c_lightglow.cpp b/sp/src/game/client/c_lightglow.cpp index 06f20a6c..501a2612 100644 --- a/sp/src/game/client/c_lightglow.cpp +++ b/sp/src/game/client/c_lightglow.cpp @@ -102,6 +102,10 @@ public: C_LightGlowOverlay m_Glow; float m_flGlowProxySize; + +#ifdef MAPBASE + bool m_bDisabled; +#endif }; static void RecvProxy_HDRColorScale( const CRecvProxyData *pData, void *pStruct, void *pOut ) @@ -123,6 +127,9 @@ IMPLEMENT_CLIENTCLASS_DT_NOBASE( C_LightGlow, DT_LightGlow, CLightGlow ) RecvPropQAngles( RECVINFO_NAME( m_angNetworkAngles, m_angRotation ) ), RecvPropInt( RECVINFO_NAME(m_hNetworkMoveParent, moveparent), 0, RecvProxy_IntToMoveParent ), RecvPropFloat(RECVINFO(m_flGlowProxySize)), +#ifdef MAPBASE + RecvPropBool( RECVINFO( m_bDisabled ) ), +#endif RecvPropFloat("HDRColorScale", 0, SIZEOF_IGNORE, 0, RecvProxy_HDRColorScale), END_RECV_TABLE() @@ -202,7 +209,11 @@ void C_LightGlow::OnDataChanged( DataUpdateType_t updateType ) void C_LightGlow::ClientThink( void ) { Vector mins = GetAbsOrigin(); +#ifdef MAPBASE + if ( engine->IsBoxVisible( mins, mins ) && !m_bDisabled ) +#else if ( engine->IsBoxVisible( mins, mins ) ) +#endif { m_Glow.Activate(); } diff --git a/sp/src/game/client/c_particle_system.cpp b/sp/src/game/client/c_particle_system.cpp index 57f3c375..27bafe0e 100644 --- a/sp/src/game/client/c_particle_system.cpp +++ b/sp/src/game/client/c_particle_system.cpp @@ -32,6 +32,9 @@ public: protected: int m_iEffectIndex; bool m_bActive; +#ifdef MAPBASE + bool m_bDestroyImmediately; +#endif bool m_bOldActive; float m_flStartTime; // Time at which the effect started @@ -56,6 +59,9 @@ BEGIN_RECV_TABLE_NOBASE( C_ParticleSystem, DT_ParticleSystem ) RecvPropInt( RECVINFO( m_iEffectIndex ) ), RecvPropBool( RECVINFO( m_bActive ) ), +#ifdef MAPBASE + RecvPropBool( RECVINFO( m_bDestroyImmediately ) ), +#endif RecvPropFloat( RECVINFO( m_flStartTime ) ), RecvPropArray3( RECVINFO_ARRAY(m_hControlPointEnts), RecvPropEHandle( RECVINFO( m_hControlPointEnts[0] ) ) ), @@ -108,9 +114,18 @@ void C_ParticleSystem::PostDataUpdate( DataUpdateType_t updateType ) SetNextClientThink( gpGlobals->curtime ); } else +#ifdef MAPBASE + { + if (!m_bDestroyImmediately) + ParticleProp()->StopEmission(); + else + ParticleProp()->StopEmissionAndDestroyImmediately(); + } +#else { ParticleProp()->StopEmission(); } +#endif } } } diff --git a/sp/src/game/client/c_point_camera.cpp b/sp/src/game/client/c_point_camera.cpp index 3d6eaa15..e4228422 100644 --- a/sp/src/game/client/c_point_camera.cpp +++ b/sp/src/game/client/c_point_camera.cpp @@ -25,6 +25,9 @@ IMPLEMENT_CLIENTCLASS_DT( C_PointCamera, DT_PointCamera, CPointCamera ) RecvPropFloat( RECVINFO( m_flFogMaxDensity ) ), RecvPropInt( RECVINFO( m_bActive ) ), RecvPropInt( RECVINFO( m_bUseScreenAspectRatio ) ), +#ifdef MAPBASE + RecvPropInt( RECVINFO( m_iSkyMode ) ), +#endif END_RECV_TABLE() C_EntityClassList g_PointCameraList; @@ -113,4 +116,11 @@ void C_PointCamera::GetToolRecordingState( KeyValues *msg ) msg->SetPtr( "monitor", &state ); } +#ifdef MAPBASE +IMPLEMENT_CLIENTCLASS_DT( C_PointCameraOrtho, DT_PointCameraOrtho, CPointCameraOrtho ) + RecvPropInt( RECVINFO( m_bOrtho ) ), + RecvPropArray( RecvPropFloat( RECVINFO( m_OrthoDimensions[0] ) ), m_OrthoDimensions ), +END_RECV_TABLE() +#endif + diff --git a/sp/src/game/client/c_point_camera.h b/sp/src/game/client/c_point_camera.h index 8bca63af..7ec2bd1e 100644 --- a/sp/src/game/client/c_point_camera.h +++ b/sp/src/game/client/c_point_camera.h @@ -37,6 +37,12 @@ public: float GetFogMaxDensity(); float GetFogEnd(); bool UseScreenAspectRatio() const { return m_bUseScreenAspectRatio; } +#ifdef MAPBASE + virtual bool IsOrtho() const { return false; } + virtual void GetOrthoDimensions(float &up, float &dn, float &lf, float &rt) const {} + + SkyboxVisibility_t SkyMode() { return m_iSkyMode; } +#endif virtual void GetToolRecordingState( KeyValues *msg ); @@ -50,11 +56,35 @@ private: float m_flFogMaxDensity; bool m_bActive; bool m_bUseScreenAspectRatio; +#ifdef MAPBASE + SkyboxVisibility_t m_iSkyMode; +#endif public: C_PointCamera *m_pNext; }; +#ifdef MAPBASE +class C_PointCameraOrtho : public C_PointCamera +{ +public: + DECLARE_CLASS( C_PointCameraOrtho, C_PointCamera ); + DECLARE_CLIENTCLASS(); + +public: + bool IsOrtho() const { return m_bOrtho; } + void GetOrthoDimensions( float &up, float &dn, float &lf, float &rt ) const + { + up = m_OrthoDimensions[0], dn = m_OrthoDimensions[1]; + lf = m_OrthoDimensions[2], rt = m_OrthoDimensions[3]; + } + +private: + bool m_bOrtho; + float m_OrthoDimensions[4]; +}; +#endif + C_PointCamera *GetPointCameraList(); #endif // C_POINTCAMERA_H diff --git a/sp/src/game/client/c_rope.cpp b/sp/src/game/client/c_rope.cpp index 605f4750..859663b3 100644 --- a/sp/src/game/client/c_rope.cpp +++ b/sp/src/game/client/c_rope.cpp @@ -28,6 +28,14 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" +#ifdef MAPBASE +static void PrecacheCable( void* ) +{ + PrecacheMaterial( "cable/rope_shadowdepth" ); +} +PRECACHE_REGISTER_FN( PrecacheCable ); +#endif + void RecvProxy_RecomputeSprings( const CRecvProxyData *pData, void *pStruct, void *pOut ) { // Have the regular proxy store the data. @@ -39,6 +47,9 @@ void RecvProxy_RecomputeSprings( const CRecvProxyData *pData, void *pStruct, voi IMPLEMENT_CLIENTCLASS_DT_NOBASE( C_RopeKeyframe, DT_RopeKeyframe, CRopeKeyframe ) +#ifdef MAPBASE + RecvPropInt( RECVINFO( m_nChangeCount ) ), +#endif RecvPropInt( RECVINFO(m_iRopeMaterialModelIndex) ), RecvPropEHandle( RECVINFO(m_hStartPoint) ), RecvPropEHandle( RECVINFO(m_hEndPoint) ), @@ -80,7 +91,9 @@ static ConVar rope_smooth_maxalpha( "rope_smooth_maxalpha", "0.5", 0, "Alpha for static ConVar mat_fullbright( "mat_fullbright", "0", FCVAR_CHEAT ); // get it from the engine static ConVar r_drawropes( "r_drawropes", "1", FCVAR_CHEAT ); +#ifndef MAPBASE static ConVar r_queued_ropes( "r_queued_ropes", "1" ); +#endif static ConVar r_ropetranslucent( "r_ropetranslucent", "1"); static ConVar r_rope_holiday_light_scale( "r_rope_holiday_light_scale", "0.055", FCVAR_DEVELOPMENTONLY ); static ConVar r_ropes_holiday_lights_allowed( "r_ropes_holiday_lights_allowed", "1", FCVAR_DEVELOPMENTONLY ); @@ -98,11 +111,17 @@ static ConVar rope_solid_minalpha( "rope_solid_minalpha", "0.0" ); static ConVar rope_solid_maxalpha( "rope_solid_maxalpha", "1" ); +#ifndef MAPBASE static CCycleCount g_RopeCollideTicks; static CCycleCount g_RopeDrawTicks; static CCycleCount g_RopeSimulateTicks; +#endif static int g_nRopePointsSimulated; +#ifdef MAPBASE +static IMaterial *g_pSplineCableShadowdepth = NULL; +#endif + // Active ropes. CUtlLinkedList g_Ropes; @@ -118,6 +137,7 @@ public: } } g_FullBrightLightValuesInit; +#ifndef MAPBASE // Precalculated info for rope subdivision. static Vector g_RopeSubdivs[MAX_ROPE_SUBDIVS][MAX_ROPE_SUBDIVS]; class CSubdivInit @@ -141,6 +161,7 @@ static int g_nBarbedSubdivs = 3; static Vector g_BarbedSubdivs[MAX_ROPE_SUBDIVS] = { Vector(1.5, 1.5*1.5, 1.5*1.5*1.5), Vector(-0.5, -0.5 * -0.5, -0.5*-0.5*-0.5), Vector(0.5, 0.5*0.5, 0.5*0.5*0.5) }; +#endif // This can be exposed through the entity if we ever care. static float g_flLockAmount = 0.1; @@ -148,7 +169,7 @@ static float g_flLockFalloff = 0.3; - +#ifndef MAPBASE class CQueuedRopeMemoryManager { public: @@ -218,6 +239,7 @@ struct RopeSegData_t // If this is less than rope_solid_minwidth and rope_solid_minalpha is 0, then we can avoid drawing.. float m_flMaxBackWidth; }; +#endif class CRopeManager : public IRopeManager { @@ -229,15 +251,18 @@ public: void ResetRenderCache( void ); void AddToRenderCache( C_RopeKeyframe *pRope ); void DrawRenderCache( bool bShadowDepth ); +#ifndef MAPBASE void OnRenderStart( void ) { m_QueuedModeMemory.SwitchStack(); } +#endif void SetHolidayLightMode( bool bHoliday ) { m_bDrawHolidayLights = bHoliday; } bool IsHolidayLightMode( void ); int GetHolidayLightStyle( void ); +#ifndef MAPBASE private: struct RopeRenderData_t; public: @@ -245,26 +270,32 @@ public: void ResetSegmentCache( int nMaxSegments ); RopeSegData_t *GetNextSegmentFromCache( void ); +#endif enum { MAX_ROPE_RENDERCACHE = 128 }; void RemoveRopeFromQueuedRenderCaches( C_RopeKeyframe *pRope ); +#ifndef MAPBASE private: void RenderNonSolidRopes( IMatRenderContext *pRenderContext, IMaterial *pMaterial, int nVertCount, int nIndexCount ); void RenderSolidRopes( IMatRenderContext *pRenderContext, IMaterial *pMaterial, int nVertCount, int nIndexCount, bool bRenderNonSolid ); +#endif private: struct RopeRenderData_t { IMaterial *m_pSolidMaterial; +#ifndef MAPBASE IMaterial *m_pBackMaterial; +#endif int m_nCacheCount; C_RopeKeyframe *m_aCache[MAX_ROPE_RENDERCACHE]; }; +#ifndef MAPBASE CUtlVector m_aRenderCache; int m_nSegmentCacheCount; CUtlVector m_aSegmentCache; @@ -274,20 +305,37 @@ private: CQueuedRopeMemoryManager m_QueuedModeMemory; IMaterial* m_pDepthWriteMaterial; +#endif struct RopeQueuedRenderCache_t { RopeRenderData_t *pCaches; int iCacheCount; +#ifdef MAPBASE + CThreadFastMutex *m_pRopeDataMutex; +#endif RopeQueuedRenderCache_t( void ) : pCaches(NULL), iCacheCount(0) { }; }; +#ifdef MAPBASE + void DrawRenderCache_NonQueued( bool bShadowDepth, RopeRenderData_t *pRenderCache, int nRenderCacheCount, const Vector &vCurrentViewForward, const Vector &vCurrentViewOrigin, C_RopeKeyframe::BuildRopeQueuedData_t *pBuildRopeQueuedData, CThreadFastMutex *pRopeDataMutex ); +#else CUtlLinkedList m_RopeQueuedRenderCaches; +#endif bool m_bDrawHolidayLights; bool m_bHolidayInitialized; int m_nHolidayLightsStyle; + +#ifdef MAPBASE + CUtlVector m_aRenderCache; + + //in queued material system mode we need to store off data for later use. + IMaterial* m_pDepthWriteMaterial; + CUtlLinkedList m_RopeQueuedRenderCaches; + CThreadFastMutex m_RopeQueuedRenderCaches_Mutex; //mutex just for changing m_RopeQueuedRenderCaches +#endif }; static CRopeManager s_RopeManager; @@ -297,11 +345,12 @@ IRopeManager *RopeManager() return &s_RopeManager; } - +#ifndef MAPBASE inline bool ShouldUseFakeAA( IMaterial *pBackMaterial ) { return pBackMaterial && rope_smooth.GetInt() && engine->GetDXSupportLevel() > 70 && !g_pMaterialSystemHardwareConfig->IsAAEnabled(); } +#endif //----------------------------------------------------------------------------- @@ -310,8 +359,10 @@ inline bool ShouldUseFakeAA( IMaterial *pBackMaterial ) CRopeManager::CRopeManager() { m_aRenderCache.Purge(); +#ifndef MAPBASE m_aSegmentCache.Purge(); m_nSegmentCacheCount = 0; +#endif m_pDepthWriteMaterial = NULL; m_bDrawHolidayLights = false; m_bHolidayInitialized = false; @@ -323,6 +374,9 @@ CRopeManager::CRopeManager() //----------------------------------------------------------------------------- CRopeManager::~CRopeManager() { +#ifdef MAPBASE + m_aRenderCache.Purge(); +#else int nRenderCacheCount = m_aRenderCache.Count(); for ( int iRenderCache = 0; iRenderCache < nRenderCacheCount; ++iRenderCache ) { @@ -338,6 +392,7 @@ CRopeManager::~CRopeManager() m_aRenderCache.Purge(); m_aSegmentCache.Purge(); +#endif } //----------------------------------------------------------------------------- @@ -367,8 +422,12 @@ void CRopeManager::AddToRenderCache( C_RopeKeyframe *pRope ) int nRenderCacheCount = m_aRenderCache.Count(); for ( ; iRenderCache < nRenderCacheCount; ++iRenderCache ) { +#ifdef MAPBASE + if ( pRope->GetSolidMaterial() == m_aRenderCache[iRenderCache].m_pSolidMaterial ) +#else if ( ( pRope->GetSolidMaterial() == m_aRenderCache[iRenderCache].m_pSolidMaterial ) && ( pRope->GetBackMaterial() == m_aRenderCache[iRenderCache].m_pBackMaterial ) ) +#endif break; } @@ -378,6 +437,7 @@ void CRopeManager::AddToRenderCache( C_RopeKeyframe *pRope ) { int iRenderCache = m_aRenderCache.AddToTail(); m_aRenderCache[iRenderCache].m_pSolidMaterial = pRope->GetSolidMaterial(); +#ifndef MAPBASE if ( m_aRenderCache[iRenderCache].m_pSolidMaterial ) { m_aRenderCache[iRenderCache].m_pSolidMaterial->IncrementReferenceCount(); @@ -387,6 +447,7 @@ void CRopeManager::AddToRenderCache( C_RopeKeyframe *pRope ) { m_aRenderCache[iRenderCache].m_pBackMaterial->IncrementReferenceCount(); } +#endif m_aRenderCache[iRenderCache].m_nCacheCount = 0; } @@ -400,6 +461,257 @@ void CRopeManager::AddToRenderCache( C_RopeKeyframe *pRope ) ++m_aRenderCache[iRenderCache].m_nCacheCount; } +#ifdef MAPBASE +#define OUTPUT_2SPLINE_VERTS( t, u ) \ + meshBuilder.Color4ub( nRed, nGreen, nBlue, nAlpha ); \ + meshBuilder.Position3f( (t), u, 0 ); \ + meshBuilder.TexCoord4fv( 0, vecP0.Base() ); \ + meshBuilder.TexCoord4fv( 1, vecP1.Base() ); \ + meshBuilder.TexCoord4fv( 2, vecP2.Base() ); \ + meshBuilder.TexCoord4fv( 3, vecP3.Base() ); \ + meshBuilder.AdvanceVertexF(); \ + meshBuilder.Color4ub( nRed, nGreen, nBlue, nAlpha ); \ + meshBuilder.Position3f( (t), u, 1 ); \ + meshBuilder.TexCoord4fv( 0, vecP0.Base() ); \ + meshBuilder.TexCoord4fv( 1, vecP1.Base() ); \ + meshBuilder.TexCoord4fv( 2, vecP2.Base() ); \ + meshBuilder.TexCoord4fv( 3, vecP3.Base() ); \ + meshBuilder.AdvanceVertexF(); + + +void CRopeManager::DrawRenderCache_NonQueued( bool bShadowDepth, RopeRenderData_t *pRenderCache, int nRenderCacheCount, const Vector &vCurrentViewForward, const Vector &vCurrentViewOrigin, C_RopeKeyframe::BuildRopeQueuedData_t *pBuildRopeQueuedData, CThreadFastMutex *pRopeDataMutex ) +{ + VPROF_BUDGET( "CRopeManager::DrawRenderCache", VPROF_BUDGETGROUP_ROPES ); + + CThreadFastMutex dummyMutex; + if( pRopeDataMutex == NULL ) + pRopeDataMutex = &dummyMutex; + + if ( bShadowDepth && !m_pDepthWriteMaterial && g_pMaterialSystem ) + { + KeyValues *pVMTKeyValues = new KeyValues( "SDK_DepthWrite" ); + pVMTKeyValues->SetInt( "$no_fullbright", 1 ); + pVMTKeyValues->SetInt( "$alphatest", 0 ); + pVMTKeyValues->SetInt( "$nocull", 1 ); + m_pDepthWriteMaterial = g_pMaterialSystem->FindProceduralMaterial( "__DepthWrite01", TEXTURE_GROUP_OTHER, pVMTKeyValues ); + } + CMatRenderContextPtr pRenderContext( materials ); + + // UNDONE: needs to use the queued data + { + AUTO_LOCK_FM( *pRopeDataMutex ); + int defaultSubdiv = rope_subdiv.GetInt(); + for ( int iRenderCache = 0; iRenderCache < nRenderCacheCount; ++iRenderCache ) + { + int nCacheCount = pRenderCache[iRenderCache].m_nCacheCount; + + int nTotalVerts = 0; + int nTotalIndices = 0; + for ( int iCache = 0; iCache < nCacheCount; ++iCache ) + { + C_RopeKeyframe *pRope = pRenderCache[iRenderCache].m_aCache[iCache]; + if ( pRope ) + { + int segs = pRope->m_RopePhysics.NumNodes()-1; + int nSubdivCount = (pRope->m_Subdiv != 255 ? pRope->m_Subdiv : defaultSubdiv) + 1; + nTotalVerts += ((2 * nSubdivCount) * segs) + 2; + nTotalIndices += (6 * nSubdivCount) * segs; + } + } + if ( nTotalVerts == 0 ) + continue; + + 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 + + pRenderContext->Bind( pMaterial ); + + int nMaxVertices = pRenderContext->GetMaxVerticesToRender( pMaterial ); + int nMaxIndices = pRenderContext->GetMaxIndicesToRender(); + + IMesh* pMesh = pRenderContext->GetDynamicMesh( true ); + CMeshBuilder meshBuilder; + int meshVertCount = MIN(nTotalVerts, nMaxVertices); + int meshIndexCount = MIN(nTotalIndices, nMaxIndices); + meshBuilder.Begin( pMesh, MATERIAL_TRIANGLES, meshVertCount, meshIndexCount ); + int nCurIDX = 0; + + int availableVerts = meshVertCount; + int availableIndices = meshIndexCount; + float flLastU = 1.0f; + + for ( int iCache = 0; iCache < nCacheCount; ++iCache ) + { + C_RopeKeyframe *pRope = pRenderCache[iRenderCache].m_aCache[iCache]; + if ( pRope ) + { + CSimplePhysics::CNode *pNode = pRope->m_RopePhysics.GetFirstNode(); + int nSegmentsToRender = pRope->m_RopePhysics.NumNodes()-1; + if ( !nSegmentsToRender ) + continue; + + int nParticles = pRope->m_RopePhysics.NumNodes(); + int nSubdivCount = (pRope->m_Subdiv != 255 ? pRope->m_Subdiv : defaultSubdiv) + 1; + + int nNumIndicesPerSegment = 6 * nSubdivCount; + int nNumVerticesPerSegment = 2 * nSubdivCount; + + int nSegmentsAvailableInBuffer = MIN( ( availableVerts - 2 ) / nNumVerticesPerSegment, + ( availableIndices ) / nNumIndicesPerSegment ); + + int segmentsInBuffer = MIN(nSegmentsAvailableInBuffer,nSegmentsToRender); + availableIndices -= nNumIndicesPerSegment * segmentsInBuffer; + availableVerts -= 2 + (nNumVerticesPerSegment * segmentsInBuffer); + + float width = pRope->m_Width; + Vector vModColor = pRope->m_vColorMod; + Vector *pColors = pRope->m_LightValues; + + // Figure out texture scale. + float flPixelsPerInch = 4.0f / pRope->m_TextureScale; + // This is the total number of texels for the length of the whole rope. + float flTotalTexCoord = flPixelsPerInch * ( pRope->m_RopeLength + pRope->m_Slack + ROPESLACK_FUDGEFACTOR ); + int nTotalPoints = (nSegmentsToRender * (nSubdivCount-1)) + 1; + float flDU = ( flTotalTexCoord / nTotalPoints ) / ( float )pRope->m_TextureHeight; + float flU = pRope->m_flCurScroll; + float m_flTStep = 1.0f / float(nSubdivCount); + + bool bFirstPoint = true; + + // initialize first spline segment + Vector4D vecP1; + Vector4D vecP2; + vecP1.Init( pNode[0].m_vPredicted, pRope->m_Width ); + vecP2.Init( pNode[1].m_vPredicted, pRope->m_Width ); + Vector4D vecP0 = vecP1; + + uint8 nRed = 0; + uint8 nGreen = 0; + uint8 nBlue = 0; + uint8 nAlpha = 255; + + Vector4D vecDelta = vecP2; + vecDelta -= vecP1; + vecP0 -= vecDelta; + + Vector4D vecP3; + + if ( nParticles < 3 ) + { + vecP3 = vecP2; + vecP3 += vecDelta; + } + else + { + vecP3.Init( pNode[2].m_vPredicted, width ); + } + int nPnt = 3; + int nColor = 1; + Vector vColor0( pColors[0].x * vModColor.x, pColors[0].y * vModColor.y, pColors[0].z * vModColor.z ); + Vector vColor1( pColors[1].x * vModColor.x, pColors[1].y * vModColor.y, pColors[1].z * vModColor.z ); + + float flT = 0; + do + { + if ( ! nSegmentsAvailableInBuffer ) + { + meshBuilder.End(); + pMesh->Draw(); + nTotalVerts -= (meshVertCount - availableVerts); + nTotalIndices -= (meshIndexCount - availableIndices); + meshVertCount = MIN(nTotalVerts, nMaxVertices); + meshIndexCount = MIN(nTotalIndices, nMaxIndices); + meshBuilder.Begin( pMesh, MATERIAL_TRIANGLES, meshVertCount, meshIndexCount ); + availableVerts = meshVertCount; + availableIndices = meshIndexCount; + // copy the last emitted points + OUTPUT_2SPLINE_VERTS( flT, flLastU ); + + nSegmentsAvailableInBuffer = MIN( ( availableVerts - 2 ) / nNumVerticesPerSegment, + availableIndices / nNumIndicesPerSegment ); + + nCurIDX = 0; + } + nSegmentsAvailableInBuffer--; + flT = 0.; + for( int nSlice = 0 ; nSlice < nSubdivCount; nSlice++ ) + { + float omt = 1.0f - flT; + nRed = FastFToC( (vColor0.x * omt) + (vColor1.x*flT) ); + nGreen = FastFToC( (vColor0.y * omt) + (vColor1.y*flT) ); + nBlue = FastFToC( (vColor0.z * omt) + (vColor1.z*flT) ); + OUTPUT_2SPLINE_VERTS( flT, flU ); + flT += m_flTStep; + flU += flDU; + if ( ! bFirstPoint ) + { + meshBuilder.FastIndex( nCurIDX ); + meshBuilder.FastIndex( nCurIDX+1 ); + meshBuilder.FastIndex( nCurIDX+2 ); + meshBuilder.FastIndex( nCurIDX+1 ); + meshBuilder.FastIndex( nCurIDX+3 ); + meshBuilder.FastIndex( nCurIDX+2 ); + nCurIDX += 2; + } + bFirstPoint = false; + } + // next segment + vColor0 = vColor1; + if ( nColor < nParticles-1 ) + { + nColor++; + vColor1.Init( pColors[nColor].x * vModColor.x, pColors[nColor].y * vModColor.y, pColors[nColor].z * vModColor.z ); + } + if ( nSegmentsToRender > 1 ) + { + vecP0 = vecP1; + vecP1 = vecP2; + vecP2 = vecP3; + + if ( nPnt < nParticles ) + { + vecP3.AsVector3D() = pNode[nPnt].m_vPredicted; + nPnt++; + } + else + { + // fake last point by extrapolating + vecP3 += vecP2; + vecP3 -= vecP1; + } + } + } while( --nSegmentsToRender ); + + // output last piece + OUTPUT_2SPLINE_VERTS( 1.0, flU ); + meshBuilder.FastIndex( nCurIDX ); + meshBuilder.FastIndex( nCurIDX+1 ); + meshBuilder.FastIndex( nCurIDX+2 ); + meshBuilder.FastIndex( nCurIDX+1 ); + meshBuilder.FastIndex( nCurIDX+3 ); + meshBuilder.FastIndex( nCurIDX+2 ); + nCurIDX += 4; + flLastU = flU; + } + } + + meshBuilder.End(); + pMesh->Draw(); + } + } + + m_RopeQueuedRenderCaches_Mutex.Lock(); + if( pBuildRopeQueuedData && (m_RopeQueuedRenderCaches.Count() != 0) ) + { + unsigned short iHeadIndex = m_RopeQueuedRenderCaches.Head(); + delete m_RopeQueuedRenderCaches[iHeadIndex].m_pRopeDataMutex; + m_RopeQueuedRenderCaches.Remove( iHeadIndex ); + } + m_RopeQueuedRenderCaches_Mutex.Unlock(); +} +#else void CRopeManager::DrawRenderCache_NonQueued( bool bShadowDepth, RopeRenderData_t *pRenderCache, int nRenderCacheCount, const Vector &vCurrentViewForward, const Vector &vCurrentViewOrigin, C_RopeKeyframe::BuildRopeQueuedData_t *pBuildRopeQueuedData ) { VPROF_BUDGET( "CRopeManager::DrawRenderCache", VPROF_BUDGETGROUP_ROPES ); @@ -518,6 +830,11 @@ void CRopeManager::DrawRenderCache_NonQueued( bool bShadowDepth, RopeRenderData_ m_RopeQueuedRenderCaches.Remove( m_RopeQueuedRenderCaches.Head() ); } } +#endif + +#ifdef MAPBASE +ConVar r_queued_ropes( "r_queued_ropes", "1" ); +#endif //----------------------------------------------------------------------------- // Purpose: @@ -529,15 +846,30 @@ void CRopeManager::DrawRenderCache( bool bShadowDepth ) if( iRenderCacheCount == 0 ) return; +#ifdef MAPBASE + // Check to see if we want to render the ropes. + if( !r_drawropes.GetBool() ) + return; +#endif + Vector vForward = CurrentViewForward(); Vector vOrigin = CurrentViewOrigin(); +#ifdef MAPBASE + CMatRenderContextPtr pRenderContext(materials); +#endif ICallQueue *pCallQueue; +#ifdef MAPBASE + if( r_queued_ropes.GetBool() && (pCallQueue = pRenderContext->GetCallQueue()) != NULL ) +#else if( r_queued_ropes.GetBool() && (pCallQueue = materials->GetRenderContext()->GetCallQueue()) != NULL ) +#endif { //material queue available and desired CRopeManager::RopeRenderData_t *pRenderCache = m_aRenderCache.Base(); +#ifndef MAPBASE AUTO_LOCK( m_RenderCacheMutex ); +#endif int iRopeCount = 0; int iNodeCount = 0; @@ -563,7 +895,12 @@ void CRopeManager::DrawRenderCache( bool bShadowDepth ) (iRopeCount * sizeof(C_RopeKeyframe::BuildRopeQueuedData_t)) + (iNodeCount * (sizeof(Vector) * 2)); +#ifdef MAPBASE + CMatRenderData< byte > rd(pRenderContext, iMemoryNeeded); + void *pMemory = rd.Base(); +#else void *pMemory = m_QueuedModeMemory.Alloc( iMemoryNeeded ); +#endif CRopeManager::RopeRenderData_t *pRenderCachesStart = (CRopeManager::RopeRenderData_t *)pMemory; C_RopeKeyframe::BuildRopeQueuedData_t *pBuildRopeQueuedDataStart = (C_RopeKeyframe::BuildRopeQueuedData_t *)(pRenderCachesStart + iRenderCacheCount); @@ -574,7 +911,11 @@ void CRopeManager::DrawRenderCache( bool bShadowDepth ) RopeQueuedRenderCache_t cache; cache.pCaches = pRenderCachesStart; cache.iCacheCount = iRenderCacheCount; +#ifdef MAPBASE + cache.m_pRopeDataMutex = new CThreadFastMutex; +#else m_RopeQueuedRenderCaches.AddToTail( cache ); +#endif C_RopeKeyframe::BuildRopeQueuedData_t *pWriteRopeQueuedData = pBuildRopeQueuedDataStart; Vector *pVectorWrite = (Vector *)pVectorDataStart; @@ -587,7 +928,9 @@ void CRopeManager::DrawRenderCache( bool bShadowDepth ) int iCacheCount = pReadCache->m_nCacheCount; pWriteCache->m_nCacheCount = 0; pWriteCache->m_pSolidMaterial = pReadCache->m_pSolidMaterial; +#ifndef MAPBASE pWriteCache->m_pBackMaterial = pReadCache->m_pBackMaterial; +#endif for( int j = 0; j != iCacheCount; ++j ) { C_RopeKeyframe *pRope = pReadCache->m_aCache[j]; @@ -618,6 +961,21 @@ void CRopeManager::DrawRenderCache( bool bShadowDepth ) pVectorWrite += iNodes; //so we don't overwrite the light values with the next rope's predicted positions } } +#ifdef MAPBASE + m_RopeQueuedRenderCaches_Mutex.Lock(); + unsigned short iLLIndex = m_RopeQueuedRenderCaches.AddToTail( cache ); + CThreadFastMutex *pRopeDataMutex = m_RopeQueuedRenderCaches[iLLIndex].m_pRopeDataMutex; + m_RopeQueuedRenderCaches_Mutex.Unlock(); + + Assert( ((void *)pVectorWrite == (void *)(((uint8 *)pMemory) + iMemoryNeeded)) && ((void *)pWriteRopeQueuedData == (void *)pVectorDataStart)); + pCallQueue->QueueCall( this, &CRopeManager::DrawRenderCache_NonQueued, bShadowDepth, pRenderCachesStart, iRenderCacheCount, vForward, vOrigin, pBuildRopeQueuedDataStart, pRopeDataMutex ); + + if ( IsHolidayLightMode() ) + { + // With holiday lights we need to also build the ropes non-queued without rendering them + DrawRenderCache_NonQueued( bShadowDepth, m_aRenderCache.Base(), iRenderCacheCount, vForward, vOrigin, NULL, NULL ); + } +#else Assert( ((void *)pVectorWrite == (void *)(((uint8 *)pMemory) + iMemoryNeeded)) && ((void *)pWriteRopeQueuedData == (void *)pVectorDataStart)); pCallQueue->QueueCall( this, &CRopeManager::DrawRenderCache_NonQueued, bShadowDepth, pRenderCachesStart, iRenderCacheCount, vForward, vOrigin, pBuildRopeQueuedDataStart ); @@ -626,10 +984,15 @@ void CRopeManager::DrawRenderCache( bool bShadowDepth ) // With holiday lights we need to also build the ropes non-queued without rendering them DrawRenderCache_NonQueued( bShadowDepth, m_aRenderCache.Base(), iRenderCacheCount, vForward, vOrigin, NULL ); } +#endif } else { +#ifdef MAPBASE + DrawRenderCache_NonQueued( bShadowDepth, m_aRenderCache.Base(), iRenderCacheCount, vForward, vOrigin, NULL, NULL ); +#else DrawRenderCache_NonQueued( bShadowDepth, m_aRenderCache.Base(), iRenderCacheCount, vForward, vOrigin, NULL ); +#endif } } @@ -671,6 +1034,7 @@ int CRopeManager::GetHolidayLightStyle( void ) return m_nHolidayLightsStyle; } +#ifndef MAPBASE //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -794,13 +1158,18 @@ RopeSegData_t *CRopeManager::GetNextSegmentFromCache( void ) ++m_nSegmentCacheCount; return &m_aSegmentCache[m_nSegmentCacheCount-1]; } +#endif void CRopeManager::RemoveRopeFromQueuedRenderCaches( C_RopeKeyframe *pRope ) { //remove this rope from queued render caches +#ifdef MAPBASE + AUTO_LOCK_FM( m_RopeQueuedRenderCaches_Mutex ); +#else AUTO_LOCK( m_RenderCacheMutex ); +#endif int index = m_RopeQueuedRenderCaches.Head(); while( m_RopeQueuedRenderCaches.IsValidIndex( index ) ) { @@ -812,7 +1181,13 @@ void CRopeManager::RemoveRopeFromQueuedRenderCaches( C_RopeKeyframe *pRope ) { if( pCache->m_aCache[j] == pRope ) { +#ifdef MAPBASE + RenderCacheData.m_pRopeDataMutex->Lock(); pCache->m_aCache[j] = NULL; + RenderCacheData.m_pRopeDataMutex->Unlock(); +#else + pCache->m_aCache[j] = NULL; +#endif } } } @@ -829,9 +1204,11 @@ void CRopeManager::RemoveRopeFromQueuedRenderCaches( C_RopeKeyframe *pRope ) void Rope_ResetCounters() { +#ifndef MAPBASE g_RopeCollideTicks.Init(); g_RopeDrawTicks.Init(); g_RopeSimulateTicks.Init(); +#endif g_nRopePointsSimulated = 0; } @@ -875,8 +1252,12 @@ void C_RopeKeyframe::CPhysicsDelegate::GetNodeForces( CSimplePhysics::CNode *pNo if( !m_pKeyframe->m_LinksTouchingSomething[iNode] && m_pKeyframe->m_bApplyWind) { +#ifdef MAPBASE + Vector vecWindVel = GetWindspeedAtLocation( m_pKeyframe->m_RopePhysics.GetNode( iNode )->m_vPos ); +#else Vector vecWindVel; GetWindspeedAtTime(gpGlobals->curtime, vecWindVel); +#endif if ( vecWindVel.LengthSqr() > 0 ) { Vector vecWindAccel; @@ -884,7 +1265,11 @@ void C_RopeKeyframe::CPhysicsDelegate::GetNodeForces( CSimplePhysics::CNode *pNo } else { +#ifdef MAPBASE + if ( ( m_pKeyframe->m_flCurrentGustLifetime != 0.0f ) && ( m_pKeyframe->m_flCurrentGustTimer < m_pKeyframe->m_flCurrentGustLifetime ) ) +#else if (m_pKeyframe->m_flCurrentGustTimer < m_pKeyframe->m_flCurrentGustLifetime ) +#endif { float div = m_pKeyframe->m_flCurrentGustTimer / m_pKeyframe->m_flCurrentGustLifetime; float scale = 1 - cos( div * M_PI ); @@ -902,8 +1287,17 @@ void C_RopeKeyframe::CPhysicsDelegate::GetNodeForces( CSimplePhysics::CNode *pNo } // Apply any instananeous forces and reset +#ifdef MAPBASE + *pAccel += ROPE_IMPULSE_SCALE * m_pKeyframe->m_vecImpulse; + m_pKeyframe->m_vecImpulse *= ROPE_IMPULSE_DECAY; + if ( m_pKeyframe->m_vecImpulse.LengthSqr() < 0.1f ) + { + m_pKeyframe->m_vecImpulse = vec3_origin; + } +#else *pAccel += ROPE_IMPULSE_SCALE * m_pKeyframe->m_flImpulse; m_pKeyframe->m_flImpulse *= ROPE_IMPULSE_DECAY; +#endif } @@ -940,21 +1334,31 @@ void C_RopeKeyframe::CPhysicsDelegate::ApplyConstraints( CSimplePhysics::CNode * { VPROF( "CPhysicsDelegate::ApplyConstraints" ); +#ifndef MAPBASE CTraceFilterWorldOnly traceFilter; +#endif // Collide with the world. if( ((m_pKeyframe->m_RopeFlags & ROPE_COLLIDE) && rope_collide.GetInt()) || (rope_collide.GetInt() == 2) ) { +#ifdef MAPBASE + CTraceFilterWorldOnly traceFilter; +#else CTimeAdder adder( &g_RopeCollideTicks ); +#endif for( int i=0; i < nNodes; i++ ) { CSimplePhysics::CNode *pNode = &pNodes[i]; int iIteration; +#ifdef MAPBASE + const int nIterations = 10; +#else int nIterations = 10; +#endif for( iIteration=0; iIteration < nIterations; iIteration++ ) { trace_t trace; @@ -972,7 +1376,11 @@ void C_RopeKeyframe::CPhysicsDelegate::ApplyConstraints( CSimplePhysics::CNode * } // Apply some friction. +#ifdef MAPBASE + const float flSlowFactor = 0.3f; +#else static float flSlowFactor = 0.3f; +#endif pNode->m_vPos -= (pNode->m_vPos - pNode->m_vPrevPos) * flSlowFactor; // Move it out along the face normal. @@ -1036,6 +1444,10 @@ C_RopeKeyframe::C_RopeKeyframe() m_vColorMod.Init( 1, 1, 1 ); m_nLinksTouchingSomething = 0; m_Subdiv = 255; // default to using the cvar +#ifdef MAPBASE + m_flCurrentGustLifetime = 0.0f; + m_flCurrentGustTimer = 0.0f; +#endif m_fLockedPoints = 0; m_fPrevLockedPoints = 0; @@ -1043,7 +1455,11 @@ C_RopeKeyframe::C_RopeKeyframe() m_iForcePointMoveCounter = 0; m_flCurScroll = m_flScrollSpeed = 0; m_TextureScale = 4; // 4:1 +#ifdef MAPBASE + m_vecImpulse.Init(); +#else m_flImpulse.Init(); +#endif g_Ropes.AddToTail( this ); } @@ -1054,11 +1470,13 @@ C_RopeKeyframe::~C_RopeKeyframe() s_RopeManager.RemoveRopeFromQueuedRenderCaches( this ); g_Ropes.FindAndRemove( this ); +#ifndef MAPBASE if ( m_pBackMaterial ) { m_pBackMaterial->DecrementReferenceCount(); m_pBackMaterial = NULL; } +#endif } @@ -1119,6 +1537,11 @@ C_RopeKeyframe* C_RopeKeyframe::CreateFromKeyValues( C_BaseAnimating *pEnt, KeyV pRope->m_RopeFlags |= ROPE_NO_GRAVITY; } +#ifdef MAPBASE + // Model ropes need wind to move + pRope->m_RopeFlags |= ROPE_USE_WIND; +#endif + pRope->m_RopeLength = pValues->GetInt( "Length" ); pRope->m_TextureScale = pValues->GetFloat( "TextureScale", pRope->m_TextureScale ); pRope->m_Slack = 0; @@ -1248,6 +1671,9 @@ void C_RopeKeyframe::RecomputeSprings() void C_RopeKeyframe::ShakeRope( const Vector &vCenter, float flRadius, float flMagnitude ) { // Sum up whatever it would apply to all of our points. +#ifdef MAPBASE + bool bWantsThink = false; +#endif for ( int i=0; i < m_nSegments; i++ ) { CSimplePhysics::CNode *pNode = m_RopePhysics.GetNode( i ); @@ -1257,9 +1683,21 @@ void C_RopeKeyframe::ShakeRope( const Vector &vCenter, float flRadius, float flM float flShakeAmount = 1.0f - flDist / flRadius; if ( flShakeAmount >= 0 ) { +#ifdef MAPBASE + m_vecImpulse.z += flShakeAmount * flMagnitude; + bWantsThink = true; +#else m_flImpulse.z += flShakeAmount * flMagnitude; +#endif } } + +#ifdef MAPBASE + if ( bWantsThink ) + { + SetNextClientThink( CLIENT_THINK_ALWAYS ); + } +#endif } @@ -1268,6 +1706,9 @@ void C_RopeKeyframe::OnDataChanged( DataUpdateType_t updateType ) BaseClass::OnDataChanged( updateType ); m_bNewDataThisFrame = true; +#ifdef MAPBASE + SetNextClientThink( CLIENT_THINK_ALWAYS ); +#endif if( updateType != DATA_UPDATE_CREATED ) return; @@ -1286,7 +1727,11 @@ void C_RopeKeyframe::OnDataChanged( DataUpdateType_t updateType ) } else { +#ifdef MAPBASE + Q_strncpy( str, "missing_rope_material", sizeof( str ) ); +#else Q_strncpy( str, "asdf", sizeof( str ) ); +#endif } FinishInit( str ); @@ -1297,11 +1742,21 @@ void C_RopeKeyframe::FinishInit( const char *pMaterialName ) { // Get the material from the material system. m_pMaterial = materials->FindMaterial( pMaterialName, TEXTURE_GROUP_OTHER ); + +#ifdef MAPBASE + if ( !g_pSplineCableShadowdepth ) + { + g_pSplineCableShadowdepth = g_pMaterialSystem->FindMaterial( "cable/rope_shadowdepth", TEXTURE_GROUP_OTHER ); + g_pSplineCableShadowdepth->IncrementReferenceCount(); + } +#endif + if( m_pMaterial ) m_TextureHeight = m_pMaterial->GetMappingHeight(); else m_TextureHeight = 1; +#ifndef MAPBASE char backName[512]; Q_snprintf( backName, sizeof( backName ), "%s_back", pMaterialName ); @@ -1314,6 +1769,7 @@ void C_RopeKeyframe::FinishInit( const char *pMaterialName ) m_pBackMaterial->IncrementReferenceCount(); m_pBackMaterial->GetMappingWidth(); } +#endif // Init rope physics. m_nSegments = clamp( m_nSegments, 2, ROPE_MAX_SEGMENTS ); @@ -1392,10 +1848,24 @@ void C_RopeKeyframe::ClientThink() if( !InitRopePhysics() ) // init if not already return; +#ifdef MAPBASE + if( DetectRestingState( m_bApplyWind ) ) +#else if( !DetectRestingState( m_bApplyWind ) ) +#endif { +#ifdef MAPBASE + if ( ( m_RopeFlags & ROPE_USE_WIND ) == 0 ) + { + SetNextClientThink( CLIENT_THINK_NEVER ); + } + return; + } +#endif // Update the simulation. +#ifndef MAPBASE CTimeAdder adder( &g_RopeSimulateTicks ); +#endif RunRopeSimulation( gpGlobals->frametime ); @@ -1404,6 +1874,10 @@ void C_RopeKeyframe::ClientThink() m_bNewDataThisFrame = false; // Setup a new wind gust? +#ifdef MAPBASE + if ( m_bApplyWind ) + { +#endif m_flCurrentGustTimer += gpGlobals->frametime; m_flTimeToNextGust -= gpGlobals->frametime; if( m_flTimeToNextGust <= 0 ) @@ -1421,8 +1895,13 @@ void C_RopeKeyframe::ClientThink() m_flTimeToNextGust = RandomFloat( 3.0f, 4.0f ); } +#ifdef MAPBASE + } + UpdateBBox(); +#else UpdateBBox(); } +#endif } @@ -1545,16 +2024,41 @@ bool C_RopeKeyframe::GetAttachment( int number, Vector &origin, QAngle &angles ) bool C_RopeKeyframe::AnyPointsMoved() { +#ifdef MAPBASE + int nNodeCount = m_RopePhysics.NumNodes(); + for( int i=0; i < nNodeCount; i++ ) +#else for( int i=0; i < m_RopePhysics.NumNodes(); i++ ) +#endif { CSimplePhysics::CNode *pNode = m_RopePhysics.GetNode( i ); +#ifdef MAPBASE + float flMoveDistSqr = pNode->m_vPos.DistToSqr( pNode->m_vPrevPos ); + if( flMoveDistSqr > 0.25f ) + { + if ( m_iForcePointMoveCounter < 5 ) + { + m_iForcePointMoveCounter = 5; + } + return true; + } +#else float flMoveDistSqr = (pNode->m_vPos - pNode->m_vPrevPos).LengthSqr(); if( flMoveDistSqr > 0.03f ) return true; +#endif } +#ifdef MAPBASE + if( m_iForcePointMoveCounter >= 0 ) + { + --m_iForcePointMoveCounter; + return true; + } +#else if( --m_iForcePointMoveCounter > 0 ) return true; +#endif return false; } @@ -1611,6 +2115,22 @@ bool C_RopeKeyframe::DetectRestingState( bool &bApplyWind ) Vector &vEnd1 = m_RopePhysics.GetFirstNode()->m_vPos; Vector &vEnd2 = m_RopePhysics.GetLastNode()->m_vPos; +#ifdef MAPBASE + if ( m_RopeFlags & ROPE_USE_WIND ) + { + // Don't apply wind if more than half of the nodes are touching something. + if( m_nLinksTouchingSomething < (m_RopePhysics.NumNodes() >> 1) ) + { + bApplyWind = CalcDistanceToLineSegment( MainViewOrigin(), vEnd1, vEnd2 ) < rope_wind_dist.GetFloat(); + } + } + + if ( m_vecPreviousImpulse != m_vecImpulse ) + { + m_vecPreviousImpulse = m_vecImpulse; + return false; + } +#else if ( !( m_RopeFlags & ROPE_NO_WIND ) ) { // Don't apply wind if more than half of the nodes are touching something. @@ -1624,6 +2144,7 @@ bool C_RopeKeyframe::DetectRestingState( bool &bApplyWind ) m_flPreviousImpulse = m_flImpulse; return false; } +#endif return !AnyPointsMoved() && !bApplyWind && !rope_shake.GetInt(); } @@ -1656,7 +2177,7 @@ inline void Catmull_Rom_Eval( const catmull_t &spline, const Vector &t, Vector & output = spline.c + (t.x * spline.t) + (t.y*spline.t2) + (t.z * spline.t3); } - +#ifndef MAPBASE //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -1823,6 +2344,7 @@ void C_RopeKeyframe::BuildRope( RopeSegData_t *pSegmentData, const Vector &vCurr } } } +#endif void C_RopeKeyframe::UpdateBBox() { @@ -1910,7 +2432,11 @@ bool C_RopeKeyframe::CalculateEndPointAttachment( C_BaseEntity *pEnt, int iAttac if ( m_RopeFlags & ROPE_PLAYER_WPN_ATTACH ) { +#ifdef MAPBASE + C_BasePlayer *pPlayer = ToBasePlayer( pEnt ); +#else C_BasePlayer *pPlayer = dynamic_cast< C_BasePlayer* >( pEnt ); +#endif if ( pPlayer ) { C_BaseAnimating *pModel = pPlayer->GetRenderedWeaponModel(); @@ -1976,10 +2502,12 @@ IMaterial* C_RopeKeyframe::GetSolidMaterial( void ) return m_pMaterial; } +#ifndef MAPBASE IMaterial* C_RopeKeyframe::GetBackMaterial( void ) { return m_pBackMaterial; } +#endif bool C_RopeKeyframe::GetEndPointAttachment( int iPt, Vector &vPos, QAngle &angle ) { @@ -1998,7 +2526,7 @@ bool C_RopeKeyframe::GetEndPointAttachment( int iPt, Vector &vPos, QAngle &angle return true; } - +#ifndef MAPBASE // Look at the global cvar and recalculate rope subdivision data if necessary. Vector *C_RopeKeyframe::GetRopeSubdivVectors( int *nSubdivs ) { @@ -2022,6 +2550,7 @@ Vector *C_RopeKeyframe::GetRopeSubdivVectors( int *nSubdivs ) return g_RopeSubdivs[subdiv]; } } +#endif void C_RopeKeyframe::CalcLightValues() @@ -2070,7 +2599,13 @@ void C_RopeKeyframe::ReceiveMessage( int classID, bf_read &msg ) } // Read instantaneous fore data +#ifdef MAPBASE + m_vecImpulse.x = msg.ReadFloat(); + m_vecImpulse.y = msg.ReadFloat(); + m_vecImpulse.z = msg.ReadFloat(); +#else m_flImpulse.x = msg.ReadFloat(); m_flImpulse.y = msg.ReadFloat(); m_flImpulse.z = msg.ReadFloat(); +#endif } diff --git a/sp/src/game/client/c_rope.h b/sp/src/game/client/c_rope.h index f04372f9..3d821081 100644 --- a/sp/src/game/client/c_rope.h +++ b/sp/src/game/client/c_rope.h @@ -107,7 +107,9 @@ public: // Get the rope material data. IMaterial *GetSolidMaterial( void ); +#ifndef MAPBASE IMaterial *GetBackMaterial( void ); +#endif struct BuildRopeQueuedData_t { @@ -119,7 +121,11 @@ public: float m_Slack; }; +#ifdef MAPBASE + void BuildRope( RopeSegData_t *pRopeSegment, const Vector &vCurrentViewForward, const Vector &vCurrentViewOrigin, BuildRopeQueuedData_t *pQueuedData ); +#else void BuildRope( RopeSegData_t *pRopeSegment, const Vector &vCurrentViewForward, const Vector &vCurrentViewOrigin, BuildRopeQueuedData_t *pQueuedData, bool bQueued ); +#endif // C_BaseEntity overrides. public: @@ -196,19 +202,29 @@ private: float m_TextureScale; // pixels per inch int m_fLockedPoints; // Which points are locked down. +#ifdef MAPBASE + int m_nChangeCount; +#endif float m_Width; CPhysicsDelegate m_PhysicsDelegate; IMaterial *m_pMaterial; +#ifndef MAPBASE IMaterial *m_pBackMaterial; // Optional translucent background material for the rope to help reduce aliasing. +#endif int m_TextureHeight; // Texture height, for texture scale calculations. // Instantaneous force +#ifdef MAPBASE + Vector m_vecImpulse; + Vector m_vecPreviousImpulse; +#else Vector m_flImpulse; Vector m_flPreviousImpulse; +#endif // Simulated wind gusts. float m_flCurrentGustTimer; @@ -250,7 +266,9 @@ public: virtual void ResetRenderCache( void ) = 0; virtual void AddToRenderCache( C_RopeKeyframe *pRope ) = 0; virtual void DrawRenderCache( bool bShadowDepth ) = 0; +#ifndef MAPBASE virtual void OnRenderStart( void ) = 0; +#endif virtual void SetHolidayLightMode( bool bHoliday ) = 0; virtual bool IsHolidayLightMode( void ) = 0; virtual int GetHolidayLightStyle( void ) = 0; diff --git a/sp/src/game/client/c_sceneentity.cpp b/sp/src/game/client/c_sceneentity.cpp index b44b59fd..99a412d2 100644 --- a/sp/src/game/client/c_sceneentity.cpp +++ b/sp/src/game/client/c_sceneentity.cpp @@ -804,11 +804,63 @@ CChoreoStringPool g_ChoreoStringPool; CChoreoScene *C_SceneEntity::LoadScene( const char *filename ) { +#ifdef MAPBASE + char loadfile[MAX_PATH]; +#else char loadfile[ 512 ]; +#endif Q_strncpy( loadfile, filename, sizeof( loadfile ) ); Q_SetExtension( loadfile, ".vcd", sizeof( loadfile ) ); Q_FixSlashes( loadfile ); +#ifdef MAPBASE + // + // Raw scene file support + // + void *pBuffer = 0; + size_t bufsize = scenefilecache->GetSceneBufferSize( loadfile ); + CChoreoScene *pScene = NULL; + if ( bufsize > 0 ) + { + // Definitely in scenes.image + pBuffer = new char[ bufsize ]; + if ( !scenefilecache->GetSceneData( filename, (byte *)pBuffer, bufsize ) ) + { + delete[] pBuffer; + return NULL; + } + + + if ( IsBufferBinaryVCD( (char*)pBuffer, bufsize ) ) + { + pScene = new CChoreoScene( this ); + CUtlBuffer buf( pBuffer, bufsize, CUtlBuffer::READ_ONLY ); + if ( !pScene->RestoreFromBinaryBuffer( buf, loadfile, &g_ChoreoStringPool ) ) + { + Warning( "Unable to restore scene '%s'\n", loadfile ); + delete pScene; + pScene = NULL; + } + } + } + else if (filesystem->ReadFileEx( loadfile, "MOD", &pBuffer, true )) + { + // Not in scenes.image, but it's a raw file + g_TokenProcessor.SetBuffer((char*)pBuffer); + pScene = ChoreoLoadScene( loadfile, this, &g_TokenProcessor, Scene_Printf ); + } + else + { + // Abandon ship + return NULL; + } + + if(pScene) + { + pScene->SetPrintFunc( Scene_Printf ); + pScene->SetEventCallbackInterface( this ); + } +#else char *pBuffer = NULL; size_t bufsize = scenefilecache->GetSceneBufferSize( loadfile ); if ( bufsize <= 0 ) @@ -843,6 +895,7 @@ CChoreoScene *C_SceneEntity::LoadScene( const char *filename ) g_TokenProcessor.SetBuffer( pBuffer ); pScene = ChoreoLoadScene( loadfile, this, &g_TokenProcessor, Scene_Printf ); } +#endif delete[] pBuffer; return pScene; diff --git a/sp/src/game/client/c_shadowcontrol.cpp b/sp/src/game/client/c_shadowcontrol.cpp index 80169241..c725a2ba 100644 --- a/sp/src/game/client/c_shadowcontrol.cpp +++ b/sp/src/game/client/c_shadowcontrol.cpp @@ -32,13 +32,24 @@ private: color32 m_shadowColor; float m_flShadowMaxDist; bool m_bDisableShadows; +#ifdef MAPBASE + bool m_bEnableLocalLightShadows; +#endif }; IMPLEMENT_CLIENTCLASS_DT(C_ShadowControl, DT_ShadowControl, CShadowControl) RecvPropVector(RECVINFO(m_shadowDirection)), +#ifdef MAPBASE + /*RecvPropInt(RECVINFO(m_shadowColor), 0, RecvProxy_Int32ToColor32),*/ + RecvPropInt(RECVINFO(m_shadowColor), 0, RecvProxy_IntToColor32), +#else RecvPropInt(RECVINFO(m_shadowColor)), +#endif RecvPropFloat(RECVINFO(m_flShadowMaxDist)), RecvPropBool(RECVINFO(m_bDisableShadows)), +#ifdef MAPBASE + RecvPropBool(RECVINFO(m_bEnableLocalLightShadows)), +#endif END_RECV_TABLE() @@ -54,6 +65,9 @@ void C_ShadowControl::OnDataChanged(DataUpdateType_t updateType) g_pClientShadowMgr->SetShadowColor( m_shadowColor.r, m_shadowColor.g, m_shadowColor.b ); g_pClientShadowMgr->SetShadowDistance( m_flShadowMaxDist ); g_pClientShadowMgr->SetShadowsDisabled( m_bDisableShadows ); +#ifdef DYNAMIC_RTT_SHADOWS + g_pClientShadowMgr->SetShadowFromWorldLightsEnabled( m_bEnableLocalLightShadows ); +#endif } //------------------------------------------------------------------------------ diff --git a/sp/src/game/client/c_soundscape.cpp b/sp/src/game/client/c_soundscape.cpp index 3196eb94..93a8aa2b 100644 --- a/sp/src/game/client/c_soundscape.cpp +++ b/sp/src/game/client/c_soundscape.cpp @@ -207,6 +207,9 @@ public: // "dsp_volume" void ProcessDSPVolume( KeyValues *pKey, subsoundscapeparams_t ¶ms ); +#ifdef MAPBASE // Moved to public space + void AddSoundScapeFile( const char *filename ); +#endif private: @@ -215,7 +218,9 @@ private: return gpGlobals->framecount == m_nRestoreFrame ? true : false; } +#ifndef MAPBASE // Moved to public space void AddSoundScapeFile( const char *filename ); +#endif void TouchPlayLooping( KeyValues *pAmbient ); void TouchPlayRandom( KeyValues *pPlayRandom ); @@ -265,6 +270,13 @@ void Soundscape_Update( audioparams_t &audio ) g_SoundscapeSystem.UpdateAudioParams( audio ); } +#ifdef MAPBASE +void Soundscape_AddFile( const char *szFile ) +{ + g_SoundscapeSystem.AddSoundScapeFile(szFile); +} +#endif + #define SOUNDSCAPE_MANIFEST_FILE "scripts/soundscapes_manifest.txt" void C_SoundscapeSystem::AddSoundScapeFile( const char *filename ) @@ -310,6 +322,16 @@ bool C_SoundscapeSystem::Init() mapSoundscapeFilename = VarArgs( "scripts/soundscapes_%s.txt", mapname ); } +#ifdef MAPBASE + if (filesystem->FileExists(VarArgs("maps/%s_soundscapes.txt", mapname))) + { + // A Mapbase-specific file exists. Load that instead. + // Any additional soundscape files, like the original scripts/soundscapes version, + // could be loaded through #include and/or #base. + mapSoundscapeFilename = VarArgs("maps/%s_soundscapes.txt", mapname); + } +#endif + KeyValues *manifest = new KeyValues( SOUNDSCAPE_MANIFEST_FILE ); if ( filesystem->LoadKeyValues( *manifest, IFileSystem::TYPE_SOUNDSCAPE, SOUNDSCAPE_MANIFEST_FILE, "GAME" ) ) { diff --git a/sp/src/game/client/c_soundscape.h b/sp/src/game/client/c_soundscape.h index 8c5f45e9..b42d4b42 100644 --- a/sp/src/game/client/c_soundscape.h +++ b/sp/src/game/client/c_soundscape.h @@ -24,4 +24,8 @@ extern void Soundscape_Update( audioparams_t &audio ); // sounds are still playing when they're not. void Soundscape_OnStopAllSounds(); +#ifdef MAPBASE +void Soundscape_AddFile( const char *szFile ); +#endif + #endif // C_SOUNDSCAPE_H diff --git a/sp/src/game/client/c_te_largefunnel.cpp b/sp/src/game/client/c_te_largefunnel.cpp index 25430db0..f8db20c4 100644 --- a/sp/src/game/client/c_te_largefunnel.cpp +++ b/sp/src/game/client/c_te_largefunnel.cpp @@ -64,7 +64,12 @@ void C_TELargeFunnel::CreateFunnel( void ) float ratio = 0.25; float invratio = 1 / ratio; +#ifdef MAPBASE + // Uh...figure out how to fix this PMaterialHandle hMaterial = pSimple->GetPMaterial( "sprites/flare6" ); +#else + PMaterialHandle hMaterial = pSimple->GetPMaterial( "sprites/flare6" ); +#endif for ( i = -256 ; i <= 256 ; i += 24 ) //24 from 32.. little more dense { diff --git a/sp/src/game/client/c_te_legacytempents.cpp b/sp/src/game/client/c_te_legacytempents.cpp index 3c8adf68..8cec8730 100644 --- a/sp/src/game/client/c_te_legacytempents.cpp +++ b/sp/src/game/client/c_te_legacytempents.cpp @@ -597,8 +597,12 @@ bool C_LocalTempEntity::Frame( float frametime, int framenumber ) if ( flags & FTENT_WINDBLOWN ) { +#ifdef MAPBASE + Vector vecWind = GetWindspeedAtLocation( GetAbsOrigin() ); +#else Vector vecWind; GetWindspeedAtTime( gpGlobals->curtime, vecWind ); +#endif for ( int i = 0 ; i < 2 ; i++ ) { diff --git a/sp/src/game/client/c_vehicle_choreo_generic.cpp b/sp/src/game/client/c_vehicle_choreo_generic.cpp index 52eba09e..82abc224 100644 --- a/sp/src/game/client/c_vehicle_choreo_generic.cpp +++ b/sp/src/game/client/c_vehicle_choreo_generic.cpp @@ -54,7 +54,12 @@ public: flFOV = m_flFOV; } virtual void DrawHudElements(); +#ifdef MAPBASE + virtual bool IsPassengerUsingStandardWeapons( int nRole = VEHICLE_ROLE_DRIVER ) { return m_bAllowStandardWeapons; } + bool m_bAllowStandardWeapons; +#else virtual bool IsPassengerUsingStandardWeapons( int nRole = VEHICLE_ROLE_DRIVER ) { return false; } +#endif virtual void UpdateViewAngles( C_BasePlayer *pLocalPlayer, CUserCmd *pCmd ); virtual C_BaseCombatCharacter *GetPassenger( int nRole ); virtual int GetPassengerRole( C_BaseCombatCharacter *pPassenger ); @@ -107,6 +112,9 @@ IMPLEMENT_CLIENTCLASS_DT(C_PropVehicleChoreoGeneric, DT_PropVehicleChoreoGeneric RecvPropFloat( RECVINFO( m_vehicleView.flYawMax ) ), RecvPropFloat( RECVINFO( m_vehicleView.flPitchMin ) ), RecvPropFloat( RECVINFO( m_vehicleView.flPitchMax ) ), +#ifdef MAPBASE + RecvPropBool( RECVINFO( m_bAllowStandardWeapons ) ), +#endif END_RECV_TABLE() diff --git a/sp/src/game/client/cdll_client_int.cpp b/sp/src/game/client/cdll_client_int.cpp index 10cce078..4365a0f8 100644 --- a/sp/src/game/client/cdll_client_int.cpp +++ b/sp/src/game/client/cdll_client_int.cpp @@ -147,6 +147,11 @@ #include "fbxsystem/fbxsystem.h" #endif +#ifdef DISCORD_RPC +#include "discord_rpc.h" +#include +#endif + extern vgui::IInputInternal *g_InputInternal; //============================================================================= @@ -335,6 +340,13 @@ static ConVar s_cl_class("cl_class", "default", FCVAR_USERINFO|FCVAR_ARCHIVE, "D static ConVar s_cl_load_hl1_content("cl_load_hl1_content", "0", FCVAR_ARCHIVE, "Mount the content from Half-Life: Source if possible"); #endif +#ifdef MAPBASE_RPC +// Mapbase stuff +extern void MapbaseRPC_Init(); +extern void MapbaseRPC_Shutdown(); +extern void MapbaseRPC_Update( int iType, const char *pMapName ); +#endif + // Physics system bool g_bLevelInitialized; @@ -843,6 +855,7 @@ CHLClient::CHLClient() } + extern IGameSystem *ViewportClientSystem(); @@ -1085,6 +1098,10 @@ int CHLClient::Init( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physi HookHapticMessages(); // Always hook the messages #endif +#ifdef MAPBASE_RPC + MapbaseRPC_Init(); +#endif + return true; } @@ -1209,6 +1226,10 @@ void CHLClient::Shutdown( void ) DisconnectDataModel(); ShutdownFbx(); #endif + +#ifdef MAPBASE_RPC + MapbaseRPC_Shutdown(); +#endif // This call disconnects the VGui libraries which we rely on later in the shutdown path, so don't do it // DisconnectTier3Libraries( ); @@ -1622,6 +1643,13 @@ void CHLClient::LevelInitPreEntity( char const* pMapName ) } #endif +#ifdef MAPBASE_RPC + if (!g_bTextMode) + { + MapbaseRPC_Update(RPCSTATE_LEVEL_INIT, pMapName); + } +#endif + // Check low violence settings for this map g_RagdollLVManager.SetLowViolence( pMapName ); @@ -1713,6 +1741,13 @@ void CHLClient::LevelShutdown( void ) gHUD.LevelShutdown(); +#ifdef MAPBASE_RPC + if (!g_bTextMode) + { + MapbaseRPC_Update(RPCSTATE_LEVEL_SHUTDOWN, NULL); + } +#endif + internalCenterPrint->Clear(); messagechars->Clear(); @@ -2143,7 +2178,9 @@ void OnRenderStart() // are at the correct location view->OnRenderStart(); +#ifndef MAPBASE RopeManager()->OnRenderStart(); +#endif // This will place all entities in the correct position in world space and in the KD-tree C_BaseAnimating::UpdateClientSideAnimations(); diff --git a/sp/src/game/client/cdll_client_int.h b/sp/src/game/client/cdll_client_int.h index c2456332..9272ef74 100644 --- a/sp/src/game/client/cdll_client_int.h +++ b/sp/src/game/client/cdll_client_int.h @@ -177,4 +177,16 @@ extern CSteamID GetSteamIDForPlayerIndex( int iPlayerIndex ); #endif +#ifdef MAPBASE +// Mapbase RPC stuff +enum +{ + RPCSTATE_INIT, + RPCSTATE_LEVEL_INIT, + RPCSTATE_LEVEL_SHUTDOWN, + + RPCSTATE_UPDATE, +}; +#endif + #endif // CDLL_CLIENT_INT_H diff --git a/sp/src/game/client/cdll_util.cpp b/sp/src/game/client/cdll_util.cpp index 4e877530..4e3f4d7a 100644 --- a/sp/src/game/client/cdll_util.cpp +++ b/sp/src/game/client/cdll_util.cpp @@ -703,6 +703,24 @@ int UTIL_EntitiesAlongRay( C_BaseEntity **pList, int listMax, const Ray_t &ray, return rayEnum.GetCount(); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Pass in an array of pointers and an array size, it fills the array and returns the number inserted +// Input : **pList - +// listMax - +// &point - +// flagMask - +// Output : int +//----------------------------------------------------------------------------- +int UTIL_EntitiesAtPoint( C_BaseEntity **pList, int listMax, const Vector &point, int flagMask, int partitionMask ) +{ + CFlaggedEntitiesEnum rayEnum( pList, listMax, flagMask ); + partition->EnumerateElementsAtPoint( partitionMask, point, false, &rayEnum ); + + return rayEnum.GetCount(); +} +#endif + CEntitySphereQuery::CEntitySphereQuery( const Vector ¢er, float radius, int flagMask, int partitionMask ) { m_listIndex = 0; diff --git a/sp/src/game/client/cdll_util.h b/sp/src/game/client/cdll_util.h index 64beb5fb..85f62cc0 100644 --- a/sp/src/game/client/cdll_util.h +++ b/sp/src/game/client/cdll_util.h @@ -119,6 +119,9 @@ void ClientPrint( C_BasePlayer *player, int msg_dest, const char *msg_name, cons int UTIL_EntitiesInBox( C_BaseEntity **pList, int listMax, const Vector &mins, const Vector &maxs, int flagMask, int partitionMask = PARTITION_CLIENT_NON_STATIC_EDICTS ); int UTIL_EntitiesInSphere( C_BaseEntity **pList, int listMax, const Vector ¢er, float radius, int flagMask, int partitionMask = PARTITION_CLIENT_NON_STATIC_EDICTS ); int UTIL_EntitiesAlongRay( C_BaseEntity **pList, int listMax, const Ray_t &ray, int flagMask, int partitionMask = PARTITION_CLIENT_NON_STATIC_EDICTS ); +#ifdef MAPBASE +int UTIL_EntitiesAtPoint( C_BaseEntity **pList, int listMax, const Vector &point, int flagMask, int partitionMask = PARTITION_CLIENT_NON_STATIC_EDICTS ); +#endif // make this a fixed size so it just sits on the stack #define MAX_SPHERE_QUERY 256 @@ -161,7 +164,13 @@ T *_CreateEntity( T *newClass, const char *className ) // Misc useful inline bool FStrEq(const char *sz1, const char *sz2) { - return (sz1 == sz2 || V_stricmp(sz1, sz2) == 0); +#ifdef MAPBASE + // V_stricmp() already checks if the pointers are equal, so having a comparison here is pointless. + // I had few reasons to do this, but maybe you'll thank me later. + return ( V_stricmp(sz1, sz2) == 0 ); +#else + return ( sz1 == sz2 || V_stricmp(sz1, sz2) == 0 ); +#endif } // Given a vector, clamps the scalar axes to MAX_COORD_FLOAT ranges from worldsize.h diff --git a/sp/src/game/client/client_base.vpc b/sp/src/game/client/client_base.vpc index 52dceb7e..e15c2a66 100644 --- a/sp/src/game/client/client_base.vpc +++ b/sp/src/game/client/client_base.vpc @@ -18,6 +18,9 @@ $include "$SRCDIR\vpc_scripts\protobuf_builder.vpc" $Include "$SRCDIR\vpc_scripts\source_replay.vpc" [$TF] $Include "$SRCDIR\game\protobuf_include.vpc" +// Mapbase stuff +$Include "$SRCDIR\game\client\client_mapbase.vpc" [$MAPBASE] + $Configuration "Debug" { $General diff --git a/sp/src/game/client/client_episodic.vpc b/sp/src/game/client/client_episodic.vpc index 5c89d940..3c6f20dd 100644 --- a/sp/src/game/client/client_episodic.vpc +++ b/sp/src/game/client/client_episodic.vpc @@ -79,7 +79,7 @@ $Project "Client (Episodic)" $File "hl2\c_weapon_crossbow.cpp" $File "episodic\c_weapon_hopwire.cpp" $File "hl2\c_weapon_physcannon.cpp" - $File "hl2\c_weapon_stunstick.cpp" + $File "hl2\c_weapon_stunstick.cpp" [!$MAPBASE] // See client_mapbase.vpc $File "$SRCDIR\game\shared\hl2\citadel_effects_shared.h" $File "hl2\clientmode_hlnormal.cpp" $File "hl2\clientmode_hlnormal.h" diff --git a/sp/src/game/client/client_hl2.vpc b/sp/src/game/client/client_hl2.vpc index db44981b..b8f6f0ef 100644 --- a/sp/src/game/client/client_hl2.vpc +++ b/sp/src/game/client/client_hl2.vpc @@ -74,7 +74,7 @@ $Project "Client (HL2)" $File "hl2\c_weapon__stubs_hl2.cpp" $File "hl2\c_weapon_crossbow.cpp" $File "hl2\c_weapon_physcannon.cpp" - $File "hl2\c_weapon_stunstick.cpp" + $File "hl2\c_weapon_stunstick.cpp" [!$MAPBASE] // See client_mapbase.vpc $File "$SRCDIR\game\shared\hl2\citadel_effects_shared.h" $File "hl2\clientmode_hlnormal.cpp" $File "hl2\clientmode_hlnormal.h" diff --git a/sp/src/game/client/client_mapbase.vpc b/sp/src/game/client/client_mapbase.vpc new file mode 100644 index 00000000..72cb3fc8 --- /dev/null +++ b/sp/src/game/client/client_mapbase.vpc @@ -0,0 +1,51 @@ +//----------------------------------------------------------------------------- +// CLIENT_MAPBASE.VPC +// +// Project Script +//----------------------------------------------------------------------------- + +$Configuration +{ + $Compiler + { + $PreprocessorDefinitions "$BASE;ASW_PROJECTED_TEXTURES;DYNAMIC_RTT_SHADOWS" + + $PreprocessorDefinitions "$BASE;MAPBASE_RPC;DISCORD_RPC;STEAM_RPC" [$MAPBASE_RPC] + } +} + +$Project +{ + $Folder "Source Files" + { + $File "c_env_global_light.cpp" + $File "worldlight.cpp" + $File "worldlight.h" + + $Folder "Mapbase" + { + $File "$SRCDIR\game\shared\mapbase\mapbase_shared.cpp" + $File "$SRCDIR\game\shared\mapbase\mapbase_rpc.cpp" + $File "$SRCDIR\game\shared\mapbase\MapEdit.cpp" + $File "$SRCDIR\game\shared\mapbase\MapEdit.h" + + $File "mapbase\c_func_clientclip.cpp" + } + + $Folder "HL2 DLL" + { + // Original stunstick files are conditional'd out in the HL2 VPCs + $File "$SRCDIR\game\shared\hl2mp\weapon_stunstick.cpp" + $File "$SRCDIR\game\shared\hl2mp\weapon_stunstick.h" + } + + $Folder "HL2MP" + { + $Folder "Weapons" + { + $File "$SRCDIR\game\shared\hl2mp\weapon_slam.cpp" + $File "$SRCDIR\game\shared\hl2mp\weapon_slam.h" + } + } + } +} diff --git a/sp/src/game/client/clientmode_shared.cpp b/sp/src/game/client/clientmode_shared.cpp index 5d10db6c..0f8d4948 100644 --- a/sp/src/game/client/clientmode_shared.cpp +++ b/sp/src/game/client/clientmode_shared.cpp @@ -77,6 +77,9 @@ class CHudVote; static vgui::HContext s_hVGuiContext = DEFAULT_VGUI_CONTEXT; ConVar cl_drawhud( "cl_drawhud", "1", FCVAR_CHEAT, "Enable the rendering of the hud" ); +#ifdef DEMO_AUTORECORD +ConVar cl_autorecord("cl_autorecord", "0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE, "Start recording demos automatically with an incremental name based on this value."); +#endif ConVar hud_takesshots( "hud_takesshots", "0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE, "Auto-save a scoreboard screenshot at the end of a map." ); ConVar hud_freezecamhide( "hud_freezecamhide", "0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE, "Hide the HUD during freeze-cam" ); ConVar cl_show_num_particle_systems( "cl_show_num_particle_systems", "0", FCVAR_CLIENTDLL, "Display the number of active particle systems." ); @@ -830,8 +833,54 @@ void ClientModeShared::LevelInit( const char *newmap ) // Reset any player explosion/shock effects CLocalPlayerFilter filter; enginesound->SetPlayerDSP( filter, 0, true ); + +#ifdef DEMO_AUTORECORD + AutoRecord(newmap); +#endif } +#ifdef DEMO_AUTORECORD +void ClientModeShared::AutoRecord(const char *map) +{ + if (!cl_autorecord.GetBool()) { + return; + } + + if (map == nullptr) { + Warning("null map in ClientModeShared::AutoRecord"); + return; + } + + // stop any demo to make sure they're saved + engine->ClientCmd("stop"); + + // KLEMS: sanitize space in client name because having to type "" while playing back lots of demos is annoying + ConVarRef name("name"); + char nameStr[128]; + memset(nameStr, 0, sizeof(nameStr)); + Q_snprintf(nameStr, sizeof(nameStr), "%s", name.GetString()); + int i = 0; + while (nameStr[i]) { + char c = nameStr[i]; + if (!( (c >= '0' && c <= '9') || + (c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z'))) { + nameStr[i] = '_'; + } + i++; + } + nameStr[127] = 0; + + char cmd[256]; + Q_snprintf(cmd, sizeof(cmd), "record \"%s_%04d_%s\"", nameStr, cl_autorecord.GetInt(), map); + cl_autorecord.SetValue(cl_autorecord.GetInt() + 1); + engine->ClientCmd(cmd); + + // write to config to make sure the cvar is recorded + engine->ClientCmd("host_writeconfig"); +} +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- diff --git a/sp/src/game/client/clientmode_shared.h b/sp/src/game/client/clientmode_shared.h index 27336964..e7b92c35 100644 --- a/sp/src/game/client/clientmode_shared.h +++ b/sp/src/game/client/clientmode_shared.h @@ -42,6 +42,10 @@ class CReplayReminderPanel; #define USERID2PLAYER(i) ToBasePlayer( ClientEntityList().GetEnt( engine->GetPlayerForUserID( i ) ) ) +#ifdef MAPBASE +#define DEMO_AUTORECORD 1 +#endif + extern IClientMode *GetClientModeNormal(); // must be implemented // This class implements client mode functionality common to HL2 and TF2. @@ -62,6 +66,10 @@ public: virtual void LevelInit( const char *newmap ); virtual void LevelShutdown( void ); +#ifdef DEMO_AUTORECORD + virtual void AutoRecord( const char *map ); +#endif + virtual void Enable(); virtual void Disable(); virtual void Layout(); diff --git a/sp/src/game/client/clientshadowmgr.cpp b/sp/src/game/client/clientshadowmgr.cpp index c37e7650..ca0f7ae2 100644 --- a/sp/src/game/client/clientshadowmgr.cpp +++ b/sp/src/game/client/clientshadowmgr.cpp @@ -81,6 +81,16 @@ #include "toolframework_client.h" #include "bonetoworldarray.h" #include "cmodel.h" +#ifdef MAPBASE +#include "renderparm.h" +#endif +#ifdef ASW_PROJECTED_TEXTURES +#include "flashlighteffect.h" +#endif +#ifdef DYNAMIC_RTT_SHADOWS +#include "debugoverlay_shared.h" +#include "worldlight.h" +#endif // memdbgon must be the last include file in a .cpp file!!! @@ -89,6 +99,12 @@ static ConVar r_flashlightdrawfrustum( "r_flashlightdrawfrustum", "0" ); static ConVar r_flashlightmodels( "r_flashlightmodels", "1" ); static ConVar r_shadowrendertotexture( "r_shadowrendertotexture", "0" ); +#ifdef ASW_PROJECTED_TEXTURES +static ConVar r_shadow_lightpos_lerptime( "r_shadow_lightpos_lerptime", "0.5" ); +static ConVar r_shadowfromworldlights_debug( "r_shadowfromworldlights_debug", "0", FCVAR_CHEAT ); +static ConVar r_shadow_shortenfactor( "r_shadow_shortenfactor", "2" , 0, "Makes shadows cast from local lights shorter" ); +static ConVar r_shadow_mincastintensity( "r_shadow_mincastintensity", "0.3", FCVAR_CHEAT, "Minimum brightness of a light to be classed as shadow casting", true, 0, false, 0 ); +#endif static ConVar r_flashlight_version2( "r_flashlight_version2", "0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY ); ConVar r_flashlightdepthtexture( "r_flashlightdepthtexture", "1" ); @@ -96,10 +112,18 @@ ConVar r_flashlightdepthtexture( "r_flashlightdepthtexture", "1" ); #if defined( _X360 ) ConVar r_flashlightdepthres( "r_flashlightdepthres", "512" ); #else +#ifdef MAPBASE +ConVar r_flashlightdepthres( "r_flashlightdepthres", "2048" ); +#else ConVar r_flashlightdepthres( "r_flashlightdepthres", "1024" ); #endif +#endif +#ifdef ASW_PROJECTED_TEXTURES +ConVar r_threaded_client_shadow_manager( "r_threaded_client_shadow_manager", "1" ); +#else ConVar r_threaded_client_shadow_manager( "r_threaded_client_shadow_manager", "0" ); +#endif #ifdef _WIN32 #pragma warning( disable: 4701 ) @@ -782,7 +806,11 @@ public: void RestoreRenderState(); // Computes a rough bounding box encompassing the volume of the shadow +#ifdef DYNAMIC_RTT_SHADOWS + void ComputeShadowBBox( IClientRenderable *pRenderable, ClientShadowHandle_t shadowHandle, const Vector &vecAbsCenter, float flRadius, Vector *pAbsMins, Vector *pAbsMaxs ); +#else void ComputeShadowBBox( IClientRenderable *pRenderable, const Vector &vecAbsCenter, float flRadius, Vector *pAbsMins, Vector *pAbsMaxs ); +#endif bool WillParentRenderBlobbyShadow( IClientRenderable *pRenderable ); @@ -794,6 +822,13 @@ public: r_shadows_gamecontrol.SetValue( bDisabled != 1 ); } +#ifdef DYNAMIC_RTT_SHADOWS + // Toggle shadow casting from world light sources + virtual void SetShadowFromWorldLightsEnabled( bool bEnable ); + void SuppressShadowFromWorldLights( bool bSuppress ); + bool IsShadowingFromWorldLights() const { return m_bShadowFromWorldLights && !m_bSuppressShadowFromWorldLights; } +#endif + private: enum { @@ -811,8 +846,16 @@ private: unsigned short m_Flags; VMatrix m_WorldToShadow; Vector2D m_WorldSize; +#ifdef DYNAMIC_RTT_SHADOWS + Vector m_ShadowDir; +#endif Vector m_LastOrigin; QAngle m_LastAngles; +#ifdef DYNAMIC_RTT_SHADOWS + Vector m_CurrentLightPos; // When shadowing from local lights, stores the position of the currently shadowing light + Vector m_TargetLightPos; // When shadowing from local lights, stores the position of the new shadowing light + float m_LightPosLerp; // Lerp progress when going from current to target light +#endif TextureHandle_t m_ShadowTexture; CTextureReference m_ShadowDepthTexture; int m_nRenderFrame; @@ -825,6 +868,11 @@ private: void UpdateBrushShadow( IClientRenderable *pRenderable, ClientShadowHandle_t handle ); void UpdateShadow( ClientShadowHandle_t handle, bool force ); +#ifdef DYNAMIC_RTT_SHADOWS + // Updates shadow cast direction when shadowing from world lights + void UpdateShadowDirectionFromLocalLightSource( ClientShadowHandle_t shadowHandle ); +#endif + // Gets the entity whose shadow this shadow will render into IClientRenderable *GetParentShadowEntity( ClientShadowHandle_t handle ); @@ -842,6 +890,10 @@ private: void BuildPerspectiveWorldToFlashlightMatrix( VMatrix& matWorldToShadow, const FlashlightState_t &flashlightState ); +#ifdef ASW_PROJECTED_TEXTURES + void BuildOrthoWorldToFlashlightMatrix( VMatrix& matWorldToShadow, const FlashlightState_t &flashlightState ); +#endif + // Update a shadow void UpdateProjectedTextureInternal( ClientShadowHandle_t handle, bool force ); @@ -910,6 +962,9 @@ private: // Returns renderable-specific shadow info float GetShadowDistance( IClientRenderable *pRenderable ) const; const Vector &GetShadowDirection( IClientRenderable *pRenderable ) const; +#ifdef DYNAMIC_RTT_SHADOWS + const Vector &GetShadowDirection( ClientShadowHandle_t shadowHandle ) const; +#endif // Initialize, shutdown render-to-texture shadows void InitDepthTextureShadows(); @@ -933,6 +988,11 @@ private: // Set and clear flashlight target renderable void SetFlashlightTarget( ClientShadowHandle_t shadowHandle, EHANDLE targetEntity ); +#ifdef ASW_PROJECTED_TEXTURES + // Get current frustum extents + void GetFrustumExtents( ClientShadowHandle_t handle, Vector &vecMin, Vector &vecMax ); +#endif + // Set flashlight light world flag void SetFlashlightLightWorld( ClientShadowHandle_t shadowHandle, bool bLightWorld ); @@ -941,9 +1001,18 @@ private: // Builds a list of active shadows requiring shadow depth renders int BuildActiveShadowDepthList( const CViewSetup &viewSetup, int nMaxDepthShadows, ClientShadowHandle_t *pActiveDepthShadows ); +#ifdef ASW_PROJECTED_TEXTURES + // Builds a list of active flashlights + int BuildActiveFlashlightList( const CViewSetup &viewSetup, int nMaxFlashlights, ClientShadowHandle_t *pActiveFlashlights ); +#endif + // Sets the view's active flashlight render state void SetViewFlashlightState( int nActiveFlashlightCount, ClientShadowHandle_t* pActiveFlashlights ); +#ifdef DYNAMIC_RTT_SHADOWS + void UpdateDirtyShadow( ClientShadowHandle_t handle ); +#endif + private: Vector m_SimpleShadowDir; color32 m_AmbientLightColor; @@ -963,6 +1032,10 @@ private: CUtlRBTree< ClientShadowHandle_t, unsigned short > m_DirtyShadows; CUtlVector< ClientShadowHandle_t > m_TransparentShadows; +#ifdef ASW_PROJECTED_TEXTURES + int m_nPrevFrameCount; +#endif + // These members maintain current state of depth texturing (size and global active state) // If either changes in a frame, PreRender() will catch it and do the appropriate allocation, deallocation or reallocation bool m_bDepthTextureActive; @@ -972,6 +1045,11 @@ private: CUtlVector< bool > m_DepthTextureCacheLocks; int m_nMaxDepthTextureShadows; +#ifdef DYNAMIC_RTT_SHADOWS + bool m_bShadowFromWorldLights; + bool m_bSuppressShadowFromWorldLights; +#endif + friend class CVisibleShadowList; friend class CVisibleShadowFrustumList; }; @@ -1064,6 +1142,12 @@ void CVisibleShadowList::EnumShadow( unsigned short clientShadowHandle ) if ( shadow.m_nRenderFrame == gpGlobals->framecount ) return; +#ifdef ASW_PROJECTED_TEXTURES + // Don't bother with flashlights + if ( ( shadow.m_Flags & SHADOW_FLAGS_FLASHLIGHT ) != 0 ) + return; +#endif + // We don't need to bother with it if it's not render-to-texture if ( s_ClientShadowMgr.GetActualShadowCastType( clientShadowHandle ) != SHADOWS_RENDER_TO_TEXTURE ) return; @@ -1088,7 +1172,11 @@ void CVisibleShadowList::EnumShadow( unsigned short clientShadowHandle ) // Compute a box surrounding the shadow Vector vecAbsMins, vecAbsMaxs; +#ifdef DYNAMIC_RTT_SHADOWS + s_ClientShadowMgr.ComputeShadowBBox( pRenderable, shadow.m_ShadowHandle, vecAbsCenter, flRadius, &vecAbsMins, &vecAbsMaxs ); +#else s_ClientShadowMgr.ComputeShadowBBox( pRenderable, vecAbsCenter, flRadius, &vecAbsMins, &vecAbsMaxs ); +#endif // FIXME: Add distance check here? @@ -1167,8 +1255,19 @@ int CVisibleShadowList::FindShadows( const CViewSetup *pView, int nLeafCount, Le //----------------------------------------------------------------------------- CClientShadowMgr::CClientShadowMgr() : m_DirtyShadows( 0, 0, ShadowHandleCompareFunc ), +#ifdef ASW_PROJECTED_TEXTURES + m_nPrevFrameCount( -1 ), +#endif m_RenderToTextureActive( false ), +#ifdef ASW_PROJECTED_TEXTURES + m_bDepthTextureActive( false ), +#else m_bDepthTextureActive( false ) +#endif +#ifdef DYNAMIC_RTT_SHADOWS + m_bShadowFromWorldLights( false ), + m_bSuppressShadowFromWorldLights( false ) +#endif { m_nDepthTextureResolution = r_flashlightdepthres.GetInt(); m_bThreaded = false; @@ -1271,6 +1370,15 @@ CON_COMMAND_F( r_shadowblobbycutoff, "some shadow stuff", FCVAR_CHEAT ) } } +#ifdef DYNAMIC_RTT_SHADOWS +void OnShadowFromWorldLights( IConVar *var, const char *pOldValue, float flOldValue ); +static ConVar r_shadowfromworldlights( "r_shadowfromworldlights", "1", FCVAR_NONE, "Enable shadowing from world lights", OnShadowFromWorldLights ); +void OnShadowFromWorldLights( IConVar *var, const char *pOldValue, float flOldValue ) +{ + s_ClientShadowMgr.SuppressShadowFromWorldLights( !r_shadowfromworldlights.GetBool() ); +} +#endif + static void ShadowRestoreFunc( int nChangeFlags ) { s_ClientShadowMgr.RestoreRenderState(); @@ -1290,8 +1398,14 @@ bool CClientShadowMgr::Init() SetShadowBlobbyCutoffArea( 0.005 ); +#ifndef MAPBASE bool bTools = CommandLine()->CheckParm( "-tools" ) != NULL; m_nMaxDepthTextureShadows = bTools ? 4 : 1; // Just one shadow depth texture in games, more in tools +#else + // 5 lets mappers use up to 4 shadow-casting projected textures, which is better than 3. + int iNumShadows = CommandLine()->ParmValue( "-numshadowtextures", 5 ); + m_nMaxDepthTextureShadows = iNumShadows; +#endif bool bLowEnd = ( g_pMaterialSystemHardwareConfig->GetDXSupportLevel() < 80 ); @@ -1336,6 +1450,14 @@ void CClientShadowMgr::InitDepthTextureShadows() { VPROF_BUDGET( "CClientShadowMgr::InitDepthTextureShadows", VPROF_BUDGETGROUP_SHADOW_DEPTH_TEXTURING ); +#if defined(MAPBASE) //&& !defined(ASW_PROJECTED_TEXTURES) + // SAUL: start benchmark timer + //CFastTimer timer; + //timer.Start(); + // SAUL: set m_nDepthTextureResolution to the depth resolution we want + m_nDepthTextureResolution = r_flashlightdepthres.GetInt(); +#endif + if( !m_bDepthTextureActive ) { m_bDepthTextureActive = true; @@ -1351,8 +1473,13 @@ void CClientShadowMgr::InitDepthTextureShadows() // only need the dummy surface, don't care about color results m_DummyColorTexture.InitRenderTargetTexture( r_flashlightdepthres.GetInt(), r_flashlightdepthres.GetInt(), RT_SIZE_OFFSCREEN, IMAGE_FORMAT_BGR565, MATERIAL_RT_DEPTH_SHARED, false, "_rt_ShadowDummy" ); m_DummyColorTexture.InitRenderTargetSurface( r_flashlightdepthres.GetInt(), r_flashlightdepthres.GetInt(), IMAGE_FORMAT_BGR565, true ); +#else +#if defined(MAPBASE) //&& !defined(ASW_PROJECTED_TEXTURES) + // SAUL: we want to create a render target of specific size, so use RT_SIZE_NO_CHANGE + m_DummyColorTexture.InitRenderTarget( m_nDepthTextureResolution, m_nDepthTextureResolution, RT_SIZE_NO_CHANGE, nullFormat, MATERIAL_RT_DEPTH_NONE, false, "_rt_ShadowDummy" ); #else m_DummyColorTexture.InitRenderTarget( r_flashlightdepthres.GetInt(), r_flashlightdepthres.GetInt(), RT_SIZE_OFFSCREEN, nullFormat, MATERIAL_RT_DEPTH_NONE, false, "_rt_ShadowDummy" ); +#endif #endif // Create some number of depth-stencil textures @@ -1371,9 +1498,19 @@ void CClientShadowMgr::InitDepthTextureShadows() // surface is effectively never used depthTex.InitRenderTargetTexture( m_nDepthTextureResolution, m_nDepthTextureResolution, RT_SIZE_OFFSCREEN, dstFormat, MATERIAL_RT_DEPTH_NONE, false, strRTName ); depthTex.InitRenderTargetSurface( 1, 1, dstFormat, false ); +#else +#if defined(MAPBASE) //&& !defined(ASW_PROJECTED_TEXTURES) + // SAUL: we want to create a *DEPTH TEXTURE* of specific size, so use RT_SIZE_NO_CHANGE and MATERIAL_RT_DEPTH_ONLY + depthTex.InitRenderTarget( m_nDepthTextureResolution, m_nDepthTextureResolution, RT_SIZE_NO_CHANGE, dstFormat, MATERIAL_RT_DEPTH_ONLY, false, strRTName ); #else depthTex.InitRenderTarget( m_nDepthTextureResolution, m_nDepthTextureResolution, RT_SIZE_OFFSCREEN, dstFormat, MATERIAL_RT_DEPTH_NONE, false, strRTName ); #endif +#endif + +#if defined(MAPBASE) //&& !defined(ASW_PROJECTED_TEXTURES) + // SAUL: ensure the depth texture size wasn't changed + Assert(depthTex->GetActualWidth() == m_nDepthTextureResolution); +#endif if ( i == 0 ) { @@ -1388,6 +1525,11 @@ void CClientShadowMgr::InitDepthTextureShadows() materials->EndRenderTargetAllocation(); } + +#if defined(MAPBASE) && !defined(ASW_PROJECTED_TEXTURES) + //timer.End(); + //DevMsg("InitDepthTextureShadows took %.2f msec\n", timer.GetDuration().GetMillisecondsF()); +#endif } void CClientShadowMgr::ShutdownDepthTextureShadows() @@ -1514,6 +1656,15 @@ void CClientShadowMgr::LevelInitPreEntity() { m_bUpdatingDirtyShadows = false; +#ifdef DYNAMIC_RTT_SHADOWS + // Default setting for this, can be overridden by shadow control entities +#ifdef MAPBASE + SetShadowFromWorldLightsEnabled( false ); +#else + SetShadowFromWorldLightsEnabled( true ); +#endif +#endif + Vector ambientColor; engine->GetAmbientLightColor( ambientColor ); ambientColor *= 3; @@ -1698,6 +1849,158 @@ const Vector &CClientShadowMgr::GetShadowDirection( IClientRenderable *pRenderab return vecResult; } +#ifdef DYNAMIC_RTT_SHADOWS +const Vector &CClientShadowMgr::GetShadowDirection( ClientShadowHandle_t shadowHandle ) const +{ + Assert( shadowHandle != CLIENTSHADOW_INVALID_HANDLE ); + + IClientRenderable* pRenderable = ClientEntityList().GetClientRenderableFromHandle( m_Shadows[shadowHandle].m_Entity ); + Assert( pRenderable ); + + if ( !IsShadowingFromWorldLights() ) + { + return GetShadowDirection( pRenderable ); + } + + Vector &vecResult = AllocTempVector(); + vecResult = m_Shadows[shadowHandle].m_ShadowDir; + + // Allow the renderable to override the default + pRenderable->GetShadowCastDirection( &vecResult, GetActualShadowCastType( pRenderable ) ); + + return vecResult; +} + +void CClientShadowMgr::UpdateShadowDirectionFromLocalLightSource( ClientShadowHandle_t shadowHandle ) +{ + Assert( shadowHandle != CLIENTSHADOW_INVALID_HANDLE ); + + ClientShadow_t& shadow = m_Shadows[shadowHandle]; + + IClientRenderable* pRenderable = ClientEntityList().GetClientRenderableFromHandle( shadow.m_Entity ); + + // TODO: Figure out why this still gets hit + Assert( pRenderable ); + if ( !pRenderable ) + { + DevWarning( "%s(): Skipping shadow with invalid client renderable (shadow handle %d)\n", __FUNCTION__, shadowHandle ); + return; + } + + Vector bbMin, bbMax; + pRenderable->GetRenderBoundsWorldspace( bbMin, bbMax ); + Vector origin( 0.5f * ( bbMin + bbMax ) ); + origin.z = bbMin.z; // Putting origin at the bottom of the bounding box makes the shadows a little shorter + + Vector lightPos; + Vector lightBrightness; + + if ( shadow.m_LightPosLerp >= 1.0f ) // skip finding new light source if we're in the middle of a lerp + { + // Calculate minimum brightness squared + float flMinBrightnessSqr = r_shadow_mincastintensity.GetFloat(); + flMinBrightnessSqr *= flMinBrightnessSqr; + + if(g_pWorldLights->GetBrightestLightSource(pRenderable->GetRenderOrigin(), lightPos, lightBrightness) == false || + lightBrightness.LengthSqr() < flMinBrightnessSqr ) + { + // didn't find a light source at all, use default shadow direction + // TODO: Could switch to using blobby shadow in this case + lightPos.Init( FLT_MAX, FLT_MAX, FLT_MAX ); + } + } + + if ( shadow.m_LightPosLerp == FLT_MAX ) // first light pos ever, just init + { + shadow.m_CurrentLightPos = lightPos; + shadow.m_TargetLightPos = lightPos; + shadow.m_LightPosLerp = 1.0f; + } + else if ( shadow.m_LightPosLerp < 1.0f ) + { + // We're in the middle of a lerp from current to target light. Finish it. + shadow.m_LightPosLerp += gpGlobals->frametime * 1.0f/r_shadow_lightpos_lerptime.GetFloat(); + shadow.m_LightPosLerp = clamp( shadow.m_LightPosLerp, 0.0f, 1.0f ); + + Vector currLightPos( shadow.m_CurrentLightPos ); + Vector targetLightPos( shadow.m_TargetLightPos ); + if ( currLightPos.x == FLT_MAX ) + { + currLightPos = origin - 200.0f * GetShadowDirection(); + } + if ( targetLightPos.x == FLT_MAX ) + { + targetLightPos = origin - 200.0f * GetShadowDirection(); + } + + // lerp light pos + Vector v1 = origin - shadow.m_CurrentLightPos; + v1.NormalizeInPlace(); + + Vector v2 = origin - shadow.m_TargetLightPos; + v2.NormalizeInPlace(); + + // SAULUNDONE: caused over top sweeping far too often +#if 0 + if ( v1.Dot( v2 ) < 0.0f ) + { + // if change in shadow angle is more than 90 degrees, lerp over the renderable's top to avoid long sweeping shadows + Vector fakeOverheadLightPos( origin.x, origin.y, origin.z + 200.0f ); + if( shadow.m_LightPosLerp < 0.5f ) + { + lightPos = Lerp( 2.0f * shadow.m_LightPosLerp, currLightPos, fakeOverheadLightPos ); + } + else + { + lightPos = Lerp( 2.0f * shadow.m_LightPosLerp - 1.0f, fakeOverheadLightPos, targetLightPos ); + } + } + else +#endif + { + lightPos = Lerp( shadow.m_LightPosLerp, currLightPos, targetLightPos ); + } + + if ( shadow.m_LightPosLerp >= 1.0f ) + { + shadow.m_CurrentLightPos = shadow.m_TargetLightPos; + } + } + else if ( shadow.m_LightPosLerp >= 1.0f ) + { + // check if we have a new closest light position and start a new lerp + float flDistSq = ( lightPos - shadow.m_CurrentLightPos ).LengthSqr(); + + if ( flDistSq > 1.0f ) + { + // light position has changed, which means we got a new light source. Initiate a lerp + shadow.m_TargetLightPos = lightPos; + shadow.m_LightPosLerp = 0.0f; + } + + lightPos = shadow.m_CurrentLightPos; + } + + if ( lightPos.x == FLT_MAX ) + { + lightPos = origin - 200.0f * GetShadowDirection(); + } + + Vector vecResult( origin - lightPos ); + vecResult.NormalizeInPlace(); + + vecResult.z *= r_shadow_shortenfactor.GetFloat(); + vecResult.NormalizeInPlace(); + + shadow.m_ShadowDir = vecResult; + + if ( r_shadowfromworldlights_debug.GetBool() ) + { + NDebugOverlay::Line( lightPos, origin, 255, 255, 0, false, 0.0f ); + } +} +#endif + //----------------------------------------------------------------------------- // Sets the shadow distance @@ -1815,6 +2118,12 @@ ClientShadowHandle_t CClientShadowMgr::CreateProjectedTexture( ClientEntityHandl shadow.m_ClientLeafShadowHandle = ClientLeafSystem()->AddShadow( h, flags ); shadow.m_Flags = flags; shadow.m_nRenderFrame = -1; +#ifdef DYNAMIC_RTT_SHADOWS + shadow.m_ShadowDir = GetShadowDirection(); + shadow.m_CurrentLightPos.Init( FLT_MAX, FLT_MAX, FLT_MAX ); + shadow.m_TargetLightPos.Init( FLT_MAX, FLT_MAX, FLT_MAX ); + shadow.m_LightPosLerp = FLT_MAX; +#endif shadow.m_LastOrigin.Init( FLT_MAX, FLT_MAX, FLT_MAX ); shadow.m_LastAngles.Init( FLT_MAX, FLT_MAX, FLT_MAX ); Assert( ( ( shadow.m_Flags & SHADOW_FLAGS_FLASHLIGHT ) == 0 ) != @@ -1834,12 +2143,21 @@ ClientShadowHandle_t CClientShadowMgr::CreateProjectedTexture( ClientEntityHandl pShadowProxyData = (void*)(uintp)h; } +#ifdef ASW_PROJECTED_TEXTURES + if( ( flags & SHADOW_FLAGS_USE_DEPTH_TEXTURE ) || ( flags & ( SHADOW_FLAGS_FLASHLIGHT ) ) ) + { + pShadowMaterial = NULL; // these materials aren't used for shadow depth texture shadows. + pShadowModelMaterial = NULL; + pShadowProxyData = (void*)h; + } +#else if( flags & SHADOW_FLAGS_USE_DEPTH_TEXTURE ) { pShadowMaterial = m_RenderShadow; pShadowModelMaterial = m_RenderModelShadow; pShadowProxyData = (void*)(uintp)h; } +#endif int createShadowFlags; if( flags & SHADOW_FLAGS_FLASHLIGHT ) @@ -1902,7 +2220,27 @@ void CClientShadowMgr::UpdateFlashlightState( ClientShadowHandle_t shadowHandle, { VPROF_BUDGET( "CClientShadowMgr::UpdateFlashlightState", VPROF_BUDGETGROUP_SHADOW_DEPTH_TEXTURING ); +#ifdef ASW_PROJECTED_TEXTURES + if( flashlightState.m_bEnableShadows && r_flashlightdepthtexture.GetBool() ) + { + m_Shadows[shadowHandle].m_Flags |= SHADOW_FLAGS_USE_DEPTH_TEXTURE; + } + else + { + m_Shadows[shadowHandle].m_Flags &= ~SHADOW_FLAGS_USE_DEPTH_TEXTURE; + } + + if ( flashlightState.m_bOrtho ) + { + BuildOrthoWorldToFlashlightMatrix( m_Shadows[shadowHandle].m_WorldToShadow, flashlightState ); + } + else + { + BuildPerspectiveWorldToFlashlightMatrix( m_Shadows[shadowHandle].m_WorldToShadow, flashlightState ); + } +#else BuildPerspectiveWorldToFlashlightMatrix( m_Shadows[shadowHandle].m_WorldToShadow, flashlightState ); +#endif shadowmgr->UpdateFlashlightState( m_Shadows[shadowHandle].m_ShadowHandle, flashlightState ); } @@ -2013,6 +2351,40 @@ void CClientShadowMgr::BuildPerspectiveWorldToFlashlightMatrix( VMatrix& matWorl MatrixMultiply( matPerspective, matWorldToShadowView, matWorldToShadow ); } +#ifdef ASW_PROJECTED_TEXTURES +void CClientShadowMgr::BuildOrthoWorldToFlashlightMatrix( VMatrix& matWorldToShadow, const FlashlightState_t &flashlightState ) +{ + VPROF_BUDGET( "CClientShadowMgr::BuildPerspectiveWorldToFlashlightMatrix", VPROF_BUDGETGROUP_SHADOW_DEPTH_TEXTURING ); + + // Buildworld to shadow matrix, then perspective projection and concatenate + VMatrix matWorldToShadowView, matPerspective; + BuildWorldToShadowMatrix( matWorldToShadowView, flashlightState.m_vecLightOrigin, + flashlightState.m_quatOrientation ); + + MatrixBuildOrtho( matPerspective, + flashlightState.m_fOrthoLeft, flashlightState.m_fOrthoTop, flashlightState.m_fOrthoRight, flashlightState.m_fOrthoBottom, + flashlightState.m_NearZ, flashlightState.m_FarZ ); + + // Shift it z/y to 0 to -2 space + VMatrix addW; + addW.Identity(); + addW[0][3] = -1.0f; + addW[1][3] = -1.0f; + addW[2][3] = 0.0f; + MatrixMultiply( addW, matPerspective, matPerspective ); + + // Flip x/y to positive 0 to 1... flip z to negative + VMatrix scaleHalf; + scaleHalf.Identity(); + scaleHalf[0][0] = -0.5f; + scaleHalf[1][1] = -0.5f; + scaleHalf[2][2] = -1.0f; + MatrixMultiply( scaleHalf, matPerspective, matPerspective ); + + MatrixMultiply( matPerspective, matWorldToShadowView, matWorldToShadow ); +} +#endif + //----------------------------------------------------------------------------- // Compute the shadow origin and attenuation start distance //----------------------------------------------------------------------------- @@ -2286,7 +2658,11 @@ void CClientShadowMgr::BuildOrthoShadow( IClientRenderable* pRenderable, AngleVectors( pRenderable->GetRenderAngles(), &vec[0], &vec[1], &vec[2] ); vec[1] *= -1.0f; +#ifdef DYNAMIC_RTT_SHADOWS + Vector vecShadowDir = GetShadowDirection( handle ); +#else Vector vecShadowDir = GetShadowDirection( pRenderable ); +#endif // Project the shadow casting direction into the space of the object Vector localShadowDir; @@ -2372,7 +2748,11 @@ void CClientShadowMgr::BuildOrthoShadow( IClientRenderable* pRenderable, // Compute extra clip planes to prevent poke-thru // FIXME!!!!!!!!!!!!!! Removing this for now since it seems to mess up the blobby shadows. +#ifdef ASW_PROJECTED_TEXTURES + ComputeExtraClipPlanes( pRenderable, handle, vec, mins, maxs, localShadowDir ); +#else // ComputeExtraClipPlanes( pEnt, handle, vec, mins, maxs, localShadowDir ); +#endif // Add the shadow to the client leaf system so it correctly marks // leafs as being affected by a particular shadow @@ -2469,7 +2849,11 @@ void CClientShadowMgr::BuildRenderToTextureShadow( IClientRenderable* pRenderabl AngleVectors( pRenderable->GetRenderAngles(), &vec[0], &vec[1], &vec[2] ); vec[1] *= -1.0f; +#ifdef DYNAMIC_RTT_SHADOWS + Vector vecShadowDir = GetShadowDirection( handle ); +#else Vector vecShadowDir = GetShadowDirection( pRenderable ); +#endif // Debugging aid // const model_t *pModel = pRenderable->GetModel(); @@ -2861,6 +3245,12 @@ bool CClientShadowMgr::ShouldUseParentShadow( IClientRenderable *pRenderable ) //----------------------------------------------------------------------------- void CClientShadowMgr::PreRender() { +#ifdef ASW_PROJECTED_TEXTURES + // only update shadows once per frame + Assert( gpGlobals->framecount != m_nPrevFrameCount ); + m_nPrevFrameCount = gpGlobals->framecount; +#endif + VPROF_BUDGET( "CClientShadowMgr::PreRender", VPROF_BUDGETGROUP_SHADOW_RENDERING ); MDLCACHE_CRITICAL_SECTION(); @@ -2933,8 +3323,12 @@ void CClientShadowMgr::PreRender() { MDLCACHE_CRITICAL_SECTION(); ClientShadowHandle_t& handle = m_DirtyShadows[ i ]; +#ifdef DYNAMIC_RTT_SHADOWS + UpdateDirtyShadow(handle); +#else Assert( m_Shadows.IsValidIndex( handle ) ); UpdateProjectedTextureInternal( handle, false ); +#endif i = m_DirtyShadows.NextInorder(i); } m_DirtyShadows.RemoveAll(); @@ -2950,6 +3344,20 @@ void CClientShadowMgr::PreRender() m_bUpdatingDirtyShadows = false; } +#ifdef DYNAMIC_RTT_SHADOWS +//----------------------------------------------------------------------------- +// Updates a single dirty shadow +//----------------------------------------------------------------------------- +void CClientShadowMgr::UpdateDirtyShadow( ClientShadowHandle_t handle ) +{ + Assert( m_Shadows.IsValidIndex( handle ) ); + if ( IsShadowingFromWorldLights() ) + { + UpdateShadowDirectionFromLocalLightSource( handle ); + } + UpdateProjectedTextureInternal( handle, false ); +} +#endif //----------------------------------------------------------------------------- // Gets the entity whose shadow this shadow will render into @@ -3124,7 +3532,11 @@ void CClientShadowMgr::UpdateShadow( ClientShadowHandle_t handle, bool force ) const Vector& origin = pRenderable->GetRenderOrigin(); const QAngle& angles = pRenderable->GetRenderAngles(); +#ifdef DYNAMIC_RTT_SHADOWS + if (force || (origin != shadow.m_LastOrigin) || (angles != shadow.m_LastAngles) || shadow.m_LightPosLerp < 1.0f) +#else if (force || (origin != shadow.m_LastOrigin) || (angles != shadow.m_LastAngles)) +#endif { // Store off the new pos/orientation VectorCopy( origin, shadow.m_LastOrigin ); @@ -3243,12 +3655,20 @@ void CClientShadowMgr::ComputeBoundingSphere( IClientRenderable* pRenderable, Ve //----------------------------------------------------------------------------- // Computes a rough AABB encompassing the volume of the shadow //----------------------------------------------------------------------------- +#ifdef DYNAMIC_RTT_SHADOWS +void CClientShadowMgr::ComputeShadowBBox( IClientRenderable *pRenderable, ClientShadowHandle_t shadowHandle, const Vector &vecAbsCenter, float flRadius, Vector *pAbsMins, Vector *pAbsMaxs ) +#else void CClientShadowMgr::ComputeShadowBBox( IClientRenderable *pRenderable, const Vector &vecAbsCenter, float flRadius, Vector *pAbsMins, Vector *pAbsMaxs ) +#endif { // This is *really* rough. Basically we simply determine the // maximum shadow casting length and extrude the box by that distance +#ifdef DYNAMIC_RTT_SHADOWS + Vector vecShadowDir = GetShadowDirection( shadowHandle ); +#else Vector vecShadowDir = GetShadowDirection( pRenderable ); +#endif for (int i = 0; i < 3; ++i) { float flShadowCastDistance = GetShadowDistance( pRenderable ); @@ -3346,7 +3766,11 @@ bool CClientShadowMgr::CullReceiver( ClientShadowHandle_t handle, IClientRendera if (foundSeparatingPlane) { // Compute which side of the plane the renderable is on.. +#ifdef DYNAMIC_RTT_SHADOWS + Vector vecShadowDir = GetShadowDirection( handle ); +#else Vector vecShadowDir = GetShadowDirection( pSourceRenderable ); +#endif float shadowDot = DotProduct( vecShadowDir, plane.normal ); float receiverDot = DotProduct( plane.normal, origin ); float sourceDot = DotProduct( plane.normal, originSource ); @@ -3833,6 +4257,11 @@ void CClientShadowMgr::AdvanceFrame() //----------------------------------------------------------------------------- int CClientShadowMgr::BuildActiveShadowDepthList( const CViewSetup &viewSetup, int nMaxDepthShadows, ClientShadowHandle_t *pActiveDepthShadows ) { +#ifdef ASW_PROJECTED_TEXTURES + Frustum_t viewFrustum; + GeneratePerspectiveFrustum( viewSetup.origin, viewSetup.angles, viewSetup.zNear, viewSetup.zFar, viewSetup.fov, viewSetup.m_flAspectRatio, viewFrustum ); +#endif + int nActiveDepthShadowCount = 0; for ( ClientShadowHandle_t i = m_Shadows.Head(); i != m_Shadows.InvalidIndex(); i = m_Shadows.Next(i) ) { @@ -3857,7 +4286,13 @@ int CClientShadowMgr::BuildActiveShadowDepthList( const CViewSetup &viewSetup, i // FIXME: Could do other sorts of culling here, such as frustum-frustum test, distance etc. // If it's not in the view frustum, move on +#ifdef MAPBASE + if ( !flashlightState.m_bAlwaysDraw && !flashlightState.m_bOrtho && R_CullBox( vecAbsMins, vecAbsMaxs, viewFrustum ) ) +#elif ASW_PROJECTED_TEXTURES + if ( !flashlightState.m_bOrtho && R_CullBox( vecAbsMins, vecAbsMaxs, viewFrustum ) ) +#else if ( R_CullBox( vecAbsMins, vecAbsMaxs, viewFrustum ) ) +#endif { shadowmgr->SetFlashlightDepthTexture( shadow.m_ShadowHandle, NULL, 0 ); continue; @@ -3882,6 +4317,53 @@ int CClientShadowMgr::BuildActiveShadowDepthList( const CViewSetup &viewSetup, i } +#ifdef ASW_PROJECTED_TEXTURES +//----------------------------------------------------------------------------- +// Re-render shadow depth textures that lie in the leaf list +//----------------------------------------------------------------------------- +int CClientShadowMgr::BuildActiveFlashlightList( const CViewSetup &viewSetup, int nMaxFlashlights, ClientShadowHandle_t *pActiveFlashlights ) +{ + int nActiveFlashlightCount = 0; + for ( ClientShadowHandle_t i = m_Shadows.Head(); i != m_Shadows.InvalidIndex(); i = m_Shadows.Next(i) ) + { + ClientShadow_t& shadow = m_Shadows[i]; + + if ( ( shadow.m_Flags & SHADOW_FLAGS_FLASHLIGHT ) == 0 ) + continue; + + // Calculate an AABB around the shadow frustum + Vector vecAbsMins, vecAbsMaxs; + CalculateAABBFromProjectionMatrix( shadow.m_WorldToShadow, &vecAbsMins, &vecAbsMaxs ); + + Frustum_t viewFrustum; + GeneratePerspectiveFrustum( viewSetup.origin, viewSetup.angles, viewSetup.zNear, viewSetup.zFar, viewSetup.fov, viewSetup.m_flAspectRatio, viewFrustum ); + + // FIXME: Could do other sorts of culling here, such as frustum-frustum test, distance etc. + // If it's not in the view frustum, move on + if ( R_CullBox( vecAbsMins, vecAbsMaxs, viewFrustum ) ) + { + continue; + } + + if ( nActiveFlashlightCount >= nMaxFlashlights ) + { + static bool s_bOverflowWarning = false; + if ( !s_bOverflowWarning ) + { + Warning( "Too many flashlights rendered in a single view!\n" ); + Assert( 0 ); + s_bOverflowWarning = true; + } + //shadowmgr->SetFlashlightDepthTexture( shadow.m_ShadowHandle, NULL, 0 ); + continue; + } + + pActiveFlashlights[nActiveFlashlightCount++] = i; + } + return nActiveFlashlightCount; +} +#endif + //----------------------------------------------------------------------------- // Sets the view's active flashlight render state //----------------------------------------------------------------------------- @@ -3905,12 +4387,56 @@ void CClientShadowMgr::SetViewFlashlightState( int nActiveFlashlightCount, Clien } } +#ifdef ASW_PROJECTED_TEXTURES +void AddPointToExtentsHelper( const VMatrix &flashlightToWorld, const Vector &vecPos, Vector &vecMin, Vector &vecMax ) +{ + Vector worldSpacePos; + + Vector3DMultiplyPositionProjective( flashlightToWorld, vecPos, worldSpacePos ); + VectorMin( vecMin, worldSpacePos, vecMin ); + VectorMax( vecMax, worldSpacePos, vecMax ); +} + + +void CClientShadowMgr::GetFrustumExtents( ClientShadowHandle_t handle, Vector &vecMin, Vector &vecMax ) +{ + Assert( m_Shadows.IsValidIndex( handle ) ); + + CClientShadowMgr::ClientShadow_t &shadow = m_Shadows[ handle ]; + + VMatrix flashlightToWorld; + MatrixInverseGeneral( shadow.m_WorldToShadow, flashlightToWorld ); + + vecMin = Vector( FLT_MAX, FLT_MAX, FLT_MAX ); + vecMax = Vector( -FLT_MAX, -FLT_MAX, -FLT_MAX ); + + AddPointToExtentsHelper( flashlightToWorld, Vector( 0.0f, 0.0f, 0.0f ), vecMin, vecMax ); + AddPointToExtentsHelper( flashlightToWorld, Vector( 0.0f, 0.0f, 1.0f ), vecMin, vecMax ); + AddPointToExtentsHelper( flashlightToWorld, Vector( 0.0f, 1.0f, 0.0f ), vecMin, vecMax ); + AddPointToExtentsHelper( flashlightToWorld, Vector( 1.0f, 0.0f, 0.0f ), vecMin, vecMax ); + AddPointToExtentsHelper( flashlightToWorld, Vector( 0.0f, 1.0f, 1.0f ), vecMin, vecMax ); + AddPointToExtentsHelper( flashlightToWorld, Vector( 1.0f, 0.0f, 1.0f ), vecMin, vecMax ); + AddPointToExtentsHelper( flashlightToWorld, Vector( 1.0f, 1.0f, 0.0f ), vecMin, vecMax ); + AddPointToExtentsHelper( flashlightToWorld, Vector( 1.0f, 1.0f, 1.0f ), vecMin, vecMax ); +} +#endif //----------------------------------------------------------------------------- // Re-render shadow depth textures that lie in the leaf list //----------------------------------------------------------------------------- void CClientShadowMgr::ComputeShadowDepthTextures( const CViewSetup &viewSetup ) { +#ifdef ASW_PROJECTED_TEXTURES + if ( !r_flashlightdepthtexture.GetBool() ) + { + // Build list of active flashlights + ClientShadowHandle_t pActiveFlashlights[16]; + int nActiveFlashlights = BuildActiveFlashlightList( viewSetup, ARRAYSIZE( pActiveFlashlights ), pActiveFlashlights ); + SetViewFlashlightState( nActiveFlashlights, pActiveFlashlights ); + return; + } +#endif + VPROF_BUDGET( "CClientShadowMgr::ComputeShadowDepthTextures", VPROF_BUDGETGROUP_SHADOW_DEPTH_TEXTURING ); CMatRenderContextPtr pRenderContext( materials ); @@ -3926,6 +4452,10 @@ void CClientShadowMgr::ComputeShadowDepthTextures( const CViewSetup &viewSetup ) { ClientShadow_t& shadow = m_Shadows[ pActiveDepthShadows[j] ]; +#ifdef ASW_PROJECTED_TEXTURES + FlashlightState_t& flashlightState = const_cast( shadowmgr->GetFlashlightState( shadow.m_ShadowHandle ) ); +#endif + CTextureReference shadowDepthTexture; bool bGotShadowDepthTexture = LockShadowDepthTexture( &shadowDepthTexture ); if ( !bGotShadowDepthTexture ) @@ -3940,6 +4470,12 @@ void CClientShadowMgr::ComputeShadowDepthTextures( const CViewSetup &viewSetup ) Assert(0); shadowmgr->SetFlashlightDepthTexture( shadow.m_ShadowHandle, NULL, 0 ); +#ifdef MAPBASE + if ( j <= ( INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_LAST - INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_FIRST ) ) + { + pRenderContext->SetIntRenderingParameter( INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_FIRST + j, 0 ); + } +#endif continue; } @@ -3948,11 +4484,30 @@ void CClientShadowMgr::ComputeShadowDepthTextures( const CViewSetup &viewSetup ) shadowView.x = shadowView.y = 0; shadowView.width = shadowDepthTexture->GetActualWidth(); shadowView.height = shadowDepthTexture->GetActualHeight(); +#ifndef ASW_PROJECTED_TEXTURES shadowView.m_bOrtho = false; shadowView.m_bDoBloomAndToneMapping = false; +#endif // Copy flashlight parameters +#ifdef ASW_PROJECTED_TEXTURES + if ( !flashlightState.m_bOrtho ) + { + shadowView.m_bOrtho = false; + } + else + { + shadowView.m_bOrtho = true; + shadowView.m_OrthoLeft = flashlightState.m_fOrthoLeft; + shadowView.m_OrthoTop = flashlightState.m_fOrthoTop; + shadowView.m_OrthoRight = flashlightState.m_fOrthoRight; + shadowView.m_OrthoBottom = flashlightState.m_fOrthoBottom; + } + + shadowView.m_bDoBloomAndToneMapping = false; +#else const FlashlightState_t& flashlightState = shadowmgr->GetFlashlightState( shadow.m_ShadowHandle ); +#endif shadowView.fov = shadowView.fovViewmodel = flashlightState.m_fHorizontalFOVDegrees; shadowView.origin = flashlightState.m_vecLightOrigin; QuaternionAngles( flashlightState.m_quatOrientation, shadowView.angles ); // Convert from Quaternion to QAngle @@ -3973,6 +4528,19 @@ void CClientShadowMgr::ComputeShadowDepthTextures( const CViewSetup &viewSetup ) // Render to the shadow depth texture with appropriate view view->UpdateShadowDepthTexture( m_DummyColorTexture, shadowDepthTexture, shadowView ); +#ifdef MAPBASE + if ( j <= ( INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_LAST - INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_FIRST ) ) + { + pRenderContext->SetIntRenderingParameter( INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_FIRST + j, int((ITexture*)shadowDepthTexture) ); + + FlashlightState_t state = shadowmgr->GetFlashlightState( shadow.m_ShadowHandle ); + + state.m_nShadowQuality = state.m_nShadowQuality | ( ( j + 1 ) << 16 ); + + shadowmgr->UpdateFlashlightState( shadow.m_ShadowHandle, state ); + } +#endif + // Associate the shadow depth texture and stencil bit with the flashlight for use during scene rendering shadowmgr->SetFlashlightDepthTexture( shadow.m_ShadowHandle, shadowDepthTexture, 0 ); } @@ -3997,7 +4565,11 @@ void CClientShadowMgr::ComputeShadowTextures( const CViewSetup &view, int leafCo if ( !m_RenderToTextureActive || (r_shadows.GetInt() == 0) || r_shadows_gamecontrol.GetInt() == 0 ) return; +#ifdef ASW_PROJECTED_TEXTURES + m_bThreaded = ( r_threaded_client_shadow_manager.GetBool() && g_pThreadPool->NumIdleThreads() ); +#else m_bThreaded = false;//( r_threaded_client_shadow_manager.GetBool() && g_pThreadPool->NumIdleThreads() ); +#endif MDLCACHE_CRITICAL_SECTION(); // First grab all shadow textures we may want to render @@ -4181,6 +4753,28 @@ bool CClientShadowMgr::IsFlashlightTarget( ClientShadowHandle_t shadowHandle, IC return false; } +#ifdef DYNAMIC_RTT_SHADOWS +void CClientShadowMgr::SetShadowFromWorldLightsEnabled( bool bEnable ) +{ + bool bIsShadowingFromWorldLights = IsShadowingFromWorldLights(); + m_bShadowFromWorldLights = bEnable; + if ( bIsShadowingFromWorldLights != IsShadowingFromWorldLights() ) + { + UpdateAllShadows(); + } +} + +void CClientShadowMgr::SuppressShadowFromWorldLights( bool bSuppress ) +{ + bool bIsShadowingFromWorldLights = IsShadowingFromWorldLights(); + m_bSuppressShadowFromWorldLights = bSuppress; + if ( bIsShadowingFromWorldLights != IsShadowingFromWorldLights() ) + { + UpdateAllShadows(); + } +} +#endif + //----------------------------------------------------------------------------- // A material proxy that resets the base texture to use the rendered shadow //----------------------------------------------------------------------------- diff --git a/sp/src/game/client/detailobjectsystem.cpp b/sp/src/game/client/detailobjectsystem.cpp index 3e211bb0..75c860be 100644 --- a/sp/src/game/client/detailobjectsystem.cpp +++ b/sp/src/game/client/detailobjectsystem.cpp @@ -1471,6 +1471,7 @@ void CDetailObjectSystem::LevelInitPreEntity() } } +#ifndef MAPBASE if ( m_DetailObjects.Count() || m_DetailSpriteDict.Count() ) { // There are detail objects in the level, so precache the material @@ -1489,6 +1490,7 @@ void CDetailObjectSystem::LevelInitPreEntity() } } } +#endif int detailPropLightingLump; if( g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE ) @@ -1512,6 +1514,32 @@ void CDetailObjectSystem::LevelInitPreEntity() void CDetailObjectSystem::LevelInitPostEntity() { +#ifdef MAPBASE + if ( m_DetailObjects.Count() || m_DetailSpriteDict.Count() ) + { + const char *pDetailSpriteMaterial = DETAIL_SPRITE_MATERIAL; + C_World *pWorld = GetClientWorldEntity(); + if ( pWorld && pWorld->GetDetailSpriteMaterial() && *(pWorld->GetDetailSpriteMaterial()) ) + pDetailSpriteMaterial = pWorld->GetDetailSpriteMaterial(); + + m_DetailSpriteMaterial.Init( pDetailSpriteMaterial, TEXTURE_GROUP_OTHER ); + PrecacheMaterial( pDetailSpriteMaterial ); + IMaterial *pMat = m_DetailSpriteMaterial; + + // adjust for non-square textures (cropped) + float flRatio = pMat->GetMappingWidth() / pMat->GetMappingHeight(); + if ( flRatio > 1.0 ) + { + for( int i = 0; iGetDetailSpriteMaterial() && *(pWorld->GetDetailSpriteMaterial()) ) @@ -1519,6 +1547,7 @@ void CDetailObjectSystem::LevelInitPostEntity() pDetailSpriteMaterial = pWorld->GetDetailSpriteMaterial(); } m_DetailSpriteMaterial.Init( pDetailSpriteMaterial, TEXTURE_GROUP_OTHER ); +#endif if ( GetDetailController() ) { diff --git a/sp/src/game/client/flashlighteffect.cpp b/sp/src/game/client/flashlighteffect.cpp index 6385ad30..6733fc56 100644 --- a/sp/src/game/client/flashlighteffect.cpp +++ b/sp/src/game/client/flashlighteffect.cpp @@ -48,8 +48,16 @@ static ConVar r_flashlightvisualizetrace( "r_flashlightvisualizetrace", "0", FCV static ConVar r_flashlightambient( "r_flashlightambient", "0.0", FCVAR_CHEAT ); static ConVar r_flashlightshadowatten( "r_flashlightshadowatten", "0.35", FCVAR_CHEAT ); static ConVar r_flashlightladderdist( "r_flashlightladderdist", "40.0", FCVAR_CHEAT ); +#ifndef MAPBASE static ConVar mat_slopescaledepthbias_shadowmap( "mat_slopescaledepthbias_shadowmap", "16", FCVAR_CHEAT ); static ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "0.0005", FCVAR_CHEAT ); +#else +static ConVar mat_slopescaledepthbias_shadowmap( "mat_slopescaledepthbias_shadowmap", "4", FCVAR_CHEAT ); +static ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "0.00001", FCVAR_CHEAT ); +#endif +#ifdef MAPBASE +static ConVar r_flashlighttextureoverride( "r_flashlighttextureoverride", "", FCVAR_CHEAT ); +#endif void r_newflashlightCallback_f( IConVar *pConVar, const char *pOldString, float flOldValue ) @@ -78,6 +86,13 @@ CFlashlightEffect::CFlashlightEffect(int nEntIndex) r_newflashlight.SetValue( 0 ); } +#ifdef MAPBASE + if ( r_flashlighttextureoverride.GetString()[0] != '\0' ) + { + m_FlashlightTexture.Init( r_flashlighttextureoverride.GetString(), TEXTURE_GROUP_OTHER, true ); + } + else +#endif if ( g_pMaterialSystemHardwareConfig->SupportsBorderColor() ) { m_FlashlightTexture.Init( "effects/flashlight_border", TEXTURE_GROUP_OTHER, true ); diff --git a/sp/src/game/client/hl2/c_basehlplayer.cpp b/sp/src/game/client/hl2/c_basehlplayer.cpp index fbc40eb2..1bfe8891 100644 --- a/sp/src/game/client/hl2/c_basehlplayer.cpp +++ b/sp/src/game/client/hl2/c_basehlplayer.cpp @@ -66,6 +66,11 @@ C_BaseHLPlayer::C_BaseHLPlayer() m_flZoomRate = 0.0f; m_flZoomStartTime = 0.0f; m_flSpeedMod = cl_forwardspeed.GetFloat(); + +#ifdef MAPBASE + ConVarRef scissor("r_flashlightscissor"); + scissor.SetValue("0"); +#endif } //----------------------------------------------------------------------------- diff --git a/sp/src/game/client/hl2/c_script_intro.cpp b/sp/src/game/client/hl2/c_script_intro.cpp index eb97cb4f..ecfdb37c 100644 --- a/sp/src/game/client/hl2/c_script_intro.cpp +++ b/sp/src/game/client/hl2/c_script_intro.cpp @@ -53,6 +53,10 @@ private: float m_flBlendStartTime; bool m_bActive; EHANDLE m_hCameraEntity; +#ifdef MAPBASE + bool m_bDrawSky; + bool m_bDrawSky2; +#endif // Fades float m_flFadeColor[3]; // Server's desired fade color @@ -71,6 +75,10 @@ IMPLEMENT_CLIENTCLASS_DT( C_ScriptIntro, DT_ScriptIntro, CScriptIntro ) RecvPropFloat( RECVINFO( m_flNextBlendTime ) ), RecvPropFloat( RECVINFO( m_flBlendStartTime ) ), RecvPropBool( RECVINFO( m_bActive ) ), +#ifdef MAPBASE + RecvPropBool( RECVINFO( m_bDrawSky ) ), + RecvPropBool( RECVINFO( m_bDrawSky2 ) ), +#endif // Fov & fov blends RecvPropInt( RECVINFO( m_iFOV ) ), @@ -140,6 +148,10 @@ void C_ScriptIntro::PostDataUpdate( DataUpdateType_t updateType ) m_IntroData.m_vecCameraViewAngles = m_vecCameraViewAngles; m_IntroData.m_Passes.SetCount( 0 ); +#ifdef MAPBASE + m_IntroData.m_bDrawSky = m_bDrawSky; +#endif + // Find/Create our first pass IntroDataBlendPass_t *pass1; if ( m_IntroData.m_Passes.Count() == 0 ) @@ -161,6 +173,9 @@ void C_ScriptIntro::PostDataUpdate( DataUpdateType_t updateType ) else { m_IntroData.m_bDrawPrimary = true; +#ifdef MAPBASE + m_IntroData.m_bDrawSky2 = m_bDrawSky2; +#endif } // If we're currently blending to a new mode, set the second pass diff --git a/sp/src/game/client/hl2/c_weapon__stubs_hl2.cpp b/sp/src/game/client/hl2/c_weapon__stubs_hl2.cpp index 68693bfc..1bb922ee 100644 --- a/sp/src/game/client/hl2/c_weapon__stubs_hl2.cpp +++ b/sp/src/game/client/hl2/c_weapon__stubs_hl2.cpp @@ -33,7 +33,9 @@ STUB_WEAPON_CLASS( weapon_shotgun, WeaponShotgun, C_BaseHLCombatWeapon ); STUB_WEAPON_CLASS( weapon_smg1, WeaponSMG1, C_HLSelectFireMachineGun ); STUB_WEAPON_CLASS( weapon_357, Weapon357, C_BaseHLCombatWeapon ); STUB_WEAPON_CLASS( weapon_crossbow, WeaponCrossbow, C_BaseHLCombatWeapon ); +#ifndef MAPBASE STUB_WEAPON_CLASS( weapon_slam, Weapon_SLAM, C_BaseHLCombatWeapon ); +#endif STUB_WEAPON_CLASS( weapon_crowbar, WeaponCrowbar, C_BaseHLBludgeonWeapon ); #ifdef HL2_EPISODIC STUB_WEAPON_CLASS( weapon_hopwire, WeaponHopwire, C_BaseHLCombatWeapon ); diff --git a/sp/src/game/client/hl2/hud_credits.cpp b/sp/src/game/client/hl2/hud_credits.cpp index 8021c49a..da6d070b 100644 --- a/sp/src/game/client/hl2/hud_credits.cpp +++ b/sp/src/game/client/hl2/hud_credits.cpp @@ -109,6 +109,9 @@ private: float m_flScrollTime; float m_flSeparation; +#ifdef MAPBASE + int m_iEndLines; +#endif float m_flFadeTime; bool m_bLastOneInPlace; int m_Alpha; @@ -133,6 +136,10 @@ private: char m_szLogo2[256]; Color m_cColor; + +#ifdef MAPBASE + char m_szCreditsFile[MAX_PATH]; +#endif }; @@ -141,7 +148,11 @@ void CHudCredits::PrepareCredits( const char *pKeyName ) Clear(); KeyValues *pKV= new KeyValues( "CreditsFile" ); +#ifdef MAPBASE + if ( !pKV->LoadFromFile( filesystem, m_szCreditsFile, "MOD" ) ) +#else if ( !pKV->LoadFromFile( filesystem, CREDITS_FILE, "MOD" ) ) +#endif { pKV->deleteThis(); @@ -215,8 +226,8 @@ void CHudCredits::ReadNames( KeyValues *pKeyValue ) while ( pKVNames ) { creditname_t Credits; - Q_strcpy( Credits.szCreditName, pKVNames->GetName()); - Q_strcpy( Credits.szFontName, pKeyValue->GetString( Credits.szCreditName, "Default" ) ); + V_strcpy_safe( Credits.szCreditName, pKVNames->GetName() ); + V_strcpy_safe( Credits.szFontName, pKeyValue->GetString( Credits.szCreditName, "Default" ) ); m_CreditsList.AddToTail( Credits ); pKVNames = pKVNames->GetNextKey(); @@ -233,6 +244,9 @@ void CHudCredits::ReadParams( KeyValues *pKeyValue ) m_flScrollTime = pKeyValue->GetFloat( "scrolltime", 57 ); m_flSeparation = pKeyValue->GetFloat( "separation", 5 ); +#ifdef MAPBASE + m_iEndLines = pKeyValue->GetInt( "endlines", 1 ); +#endif m_flFadeInTime = pKeyValue->GetFloat( "fadeintime", 1 ); m_flFadeHoldTime = pKeyValue->GetFloat( "fadeholdtime", 3 ); @@ -296,9 +310,14 @@ void CHudCredits::DrawOutroCreditsName( void ) Color cColor = m_TextColor; +#ifdef MAPBASE + // Some lines should stick around and fade out + if ( i >= m_CreditsList.Count()-m_iEndLines ) +#else //HACKHACK //Last one stays on screen and fades out if ( i == m_CreditsList.Count()-1 ) +#endif { if ( m_bLastOneInPlace == false ) { @@ -638,6 +657,20 @@ void CHudCredits::PrepareOutroCredits( void ) int iHeight = iTall; +#ifdef MAPBASE + if (m_iEndLines <= 0) + { + // We need a credit to fade out at the end so we know when the credits are done. + // Add a dummy credit to act as the "end line". + creditname_t DummyCredit; + V_strcpy_safe( DummyCredit.szCreditName, ""); + V_strcpy_safe( DummyCredit.szFontName, "Default" ); + + m_CreditsList.AddToTail(DummyCredit); + m_iEndLines = 1; + } +#endif + for ( int i = 0; i < m_CreditsList.Count(); i++ ) { creditname_t *pCredit = &m_CreditsList[i]; @@ -706,6 +739,13 @@ void CHudCredits::MsgFunc_CreditsMsg( bf_read &msg ) { m_iCreditsType = msg.ReadByte(); +#ifdef MAPBASE + msg.ReadString(m_szCreditsFile, sizeof(m_szCreditsFile)); + + if (m_szCreditsFile[0] == '\0') + Q_strncpy(m_szCreditsFile, CREDITS_FILE, sizeof(m_szCreditsFile)); +#endif + switch ( m_iCreditsType ) { case CREDITS_LOGO: @@ -729,7 +769,17 @@ void CHudCredits::MsgFunc_CreditsMsg( bf_read &msg ) void CHudCredits::MsgFunc_LogoTimeMsg( bf_read &msg ) { m_iCreditsType = CREDITS_LOGO; +#ifdef MAPBASE + float flLogoTime = msg.ReadFloat(); + msg.ReadString(m_szCreditsFile, sizeof(m_szCreditsFile)); + + if (m_szCreditsFile[0] == '\0') + Q_strncpy(m_szCreditsFile, CREDITS_FILE, sizeof(m_szCreditsFile)); + + PrepareLogo(flLogoTime); +#else PrepareLogo( msg.ReadFloat() ); +#endif } diff --git a/sp/src/game/client/hud_closecaption.cpp b/sp/src/game/client/hud_closecaption.cpp index f72b9fc1..f0594e7a 100644 --- a/sp/src/game/client/hud_closecaption.cpp +++ b/sp/src/game/client/hud_closecaption.cpp @@ -31,12 +31,20 @@ extern ISoundEmitterSystemBase *soundemitterbase; // Marked as FCVAR_USERINFO so that the server can cull CC messages before networking them down to us!!! +#ifdef MAPBASE +ConVar closecaption( "closecaption", "1", FCVAR_ARCHIVE | FCVAR_ARCHIVE_XBOX | FCVAR_USERINFO, "Enable close captioning." ); +#else ConVar closecaption( "closecaption", "0", FCVAR_ARCHIVE | FCVAR_ARCHIVE_XBOX | FCVAR_USERINFO, "Enable close captioning." ); +#endif extern ConVar cc_lang; static ConVar cc_linger_time( "cc_linger_time", "1.0", FCVAR_ARCHIVE, "Close caption linger time." ); static ConVar cc_predisplay_time( "cc_predisplay_time", "0.25", FCVAR_ARCHIVE, "Close caption delay before showing caption." ); static ConVar cc_captiontrace( "cc_captiontrace", "1", 0, "Show missing closecaptions (0 = no, 1 = devconsole, 2 = show in hud)" ); +#ifdef MAPBASE +static ConVar cc_subtitles( "cc_subtitles", "1", FCVAR_ARCHIVE | FCVAR_ARCHIVE_XBOX, "If set, don't show sound effect captions, just voice overs (i.e., won't help hearing impaired players)." ); +#else static ConVar cc_subtitles( "cc_subtitles", "0", FCVAR_ARCHIVE | FCVAR_ARCHIVE_XBOX, "If set, don't show sound effect captions, just voice overs (i.e., won't help hearing impaired players)." ); +#endif ConVar english( "english", "1", FCVAR_USERINFO, "If set to 1, running the english language set of assets." ); static ConVar cc_smallfontlength( "cc_smallfontlength", "300", 0, "If text stream is this long, force usage of small font size." ); @@ -2692,6 +2700,11 @@ CON_COMMAND_F_COMPLETION( cc_emit, "Emits a closed caption", 0, EmitCaptionCompl return; } +#ifdef MAPBASE // 1upD + if (!closecaption.GetBool()) + return; +#endif + CHudCloseCaption *hudCloseCaption = GET_HUDELEMENT( CHudCloseCaption ); if ( hudCloseCaption ) { diff --git a/sp/src/game/client/hud_hintdisplay.cpp b/sp/src/game/client/hud_hintdisplay.cpp index 487633bd..50ab208a 100644 --- a/sp/src/game/client/hud_hintdisplay.cpp +++ b/sp/src/game/client/hud_hintdisplay.cpp @@ -599,10 +599,39 @@ bool CHudHintKeyDisplay::SetHintText( const char *text ) else { const char *key = engine->Key_LookupBinding( *binding == '+' ? binding + 1 : binding ); +#ifdef MAPBASE + if ( !key ) + { + const char *pszNotBound = VarArgs("< %s, not bound >", *binding == '+' ? binding + 1 : binding); + if (strchr(binding, '&')) + { + // "%walk&use%" >> "ALT + E" + char *token = strtok(binding, "&"); + while (token) + { + const char *tokenkey = engine->Key_LookupBinding( *token == '+' ? token + 1 : token ); + + key = VarArgs("%s%s%s", key ? key : "", key ? " + " : "", tokenkey ? tokenkey : pszNotBound); + + token = strtok(NULL, "&"); + } + } + else if (binding[0] == '$') + { + // "%$COOL STRING DUDE%" >> "COOL STRING DUDE" + key = binding + 1; + } + else + { + key = pszNotBound; + } + } +#else if ( !key ) { key = "< not bound >"; } +#endif Q_snprintf( friendlyName, sizeof(friendlyName), "#%s", key ); Q_strupr( friendlyName ); diff --git a/sp/src/game/client/iclientshadowmgr.h b/sp/src/game/client/iclientshadowmgr.h index 174f57a8..df8f9352 100644 --- a/sp/src/game/client/iclientshadowmgr.h +++ b/sp/src/game/client/iclientshadowmgr.h @@ -97,6 +97,15 @@ public: // Set flashlight light world flag virtual void SetFlashlightLightWorld( ClientShadowHandle_t shadowHandle, bool bLightWorld ) = 0; +#ifdef ASW_PROJECTED_TEXTURES + virtual void GetFrustumExtents( ClientShadowHandle_t handle, Vector &vecMin, Vector &vecMax ) = 0; +#endif + +#ifdef DYNAMIC_RTT_SHADOWS + // Toggle shadow casting from world light sources + virtual void SetShadowFromWorldLightsEnabled( bool bEnable ) = 0; +#endif + virtual void SetShadowsDisabled( bool bDisabled ) = 0; virtual void ComputeShadowDepthTextures( const CViewSetup &pView ) = 0; diff --git a/sp/src/game/client/in_main.cpp b/sp/src/game/client/in_main.cpp index 21eb30a0..2cd8a6b5 100644 --- a/sp/src/game/client/in_main.cpp +++ b/sp/src/game/client/in_main.cpp @@ -1219,6 +1219,9 @@ void CInput::CreateMove ( int sequence_number, float input_sample_frametime, boo } // Let the move manager override anything it wants to. +#ifdef VGUI_SCREEN_FIX + cmd->buttons |= IN_VALIDVGUIINPUT; +#endif if ( g_pClientMode->CreateMove( input_sample_frametime, cmd ) ) { // Get current view angles after the client mode tweaks with it diff --git a/sp/src/game/client/mapbase/c_func_clientclip.cpp b/sp/src/game/client/mapbase/c_func_clientclip.cpp new file mode 100644 index 00000000..03cc50d4 --- /dev/null +++ b/sp/src/game/client/mapbase/c_func_clientclip.cpp @@ -0,0 +1,93 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//===========================================================================// + +#include "cbase.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + + +class C_FuncClientClip : public C_BaseEntity +{ +public: + DECLARE_CLASS( C_FuncClientClip, C_BaseEntity ); + DECLARE_CLIENTCLASS(); + + void OnDataChanged( DataUpdateType_t type ); + void ClientThink(); + bool TestCollision( const Ray_t &ray, unsigned int mask, trace_t& trace ); + + bool m_bDisabled; +}; + +IMPLEMENT_CLIENTCLASS_DT( C_FuncClientClip, DT_FuncClientClip, CFuncClientClip ) + RecvPropBool( RECVINFO( m_bDisabled ) ), +END_RECV_TABLE() + +void C_FuncClientClip::OnDataChanged( DataUpdateType_t type ) +{ + BaseClass::OnDataChanged( type ); + + //if ( type == DATA_UPDATE_CREATED ) + //{ + SetSolid(GetMoveParent() ? SOLID_VPHYSICS : SOLID_BSP); // SOLID_VPHYSICS + //} + + if ( !m_bDisabled ) + { + VPhysicsDestroyObject(); + VPhysicsInitShadow( true, true ); + + // Think constantly updates the shadow + if (GetMoveParent()) + SetNextClientThink( CLIENT_THINK_ALWAYS ); + } + else + { + // Disabling + VPhysicsDestroyObject(); + SetNextClientThink( CLIENT_THINK_NEVER ); + } +} + +void C_FuncClientClip::ClientThink() +{ + // We shouldn't be thinking if we're disabled + Assert(!m_bDisabled); + + if (VPhysicsGetObject()) + { + // Constantly updates the shadow. + // This think function should really only be active when we're parented. + VPhysicsGetObject()->UpdateShadow( GetAbsOrigin(), GetAbsAngles(), false, TICK_INTERVAL ); + } + else + { + // This should never happen... + VPhysicsInitShadow( true, true ); + } + + BaseClass::ClientThink(); +} + +bool C_FuncClientClip::TestCollision( const Ray_t &ray, unsigned int mask, trace_t& trace ) +{ + if ( m_bDisabled ) + return false; + + if ( !VPhysicsGetObject() ) + return false; + + physcollision->TraceBox( ray, VPhysicsGetObject()->GetCollide(), GetAbsOrigin(), GetAbsAngles(), &trace ); + + if ( trace.DidHit() ) + { + trace.surface.surfaceProps = VPhysicsGetObject()->GetMaterialIndex(); + return true; + } + + return false; +} diff --git a/sp/src/game/client/panelmetaclassmgr.cpp b/sp/src/game/client/panelmetaclassmgr.cpp index 6f0b50d0..2b36cc44 100644 --- a/sp/src/game/client/panelmetaclassmgr.cpp +++ b/sp/src/game/client/panelmetaclassmgr.cpp @@ -234,6 +234,14 @@ CPanelMetaClassMgrImp::CPanelMetaClassMgrImp() : m_PanelTypeDict( true, 0, 32 ) CPanelMetaClassMgrImp::~CPanelMetaClassMgrImp() { +#ifdef MAPBASE // VDC Memory Leak Fixes + while (m_MetaClassKeyValues.Count()>0) + { + if (m_MetaClassKeyValues[0]) + m_MetaClassKeyValues[0]->deleteThis(); + m_MetaClassKeyValues.RemoveAt(0); + } +#endif } diff --git a/sp/src/game/client/particles_simple.cpp b/sp/src/game/client/particles_simple.cpp index b2971dbb..20500b32 100644 --- a/sp/src/game/client/particles_simple.cpp +++ b/sp/src/game/client/particles_simple.cpp @@ -308,8 +308,12 @@ void CSimpleEmitter::UpdateVelocity( SimpleParticle *pParticle, float timeDelta { if (pParticle->m_iFlags & SIMPLE_PARTICLE_FLAG_WINDBLOWN) { +#ifdef MAPBASE + Vector vecWind = GetWindspeedAtLocation( pParticle->m_Pos ); +#else Vector vecWind; GetWindspeedAtTime( gpGlobals->curtime, vecWind ); +#endif for ( int i = 0 ; i < 2 ; i++ ) { diff --git a/sp/src/game/client/prediction.cpp b/sp/src/game/client/prediction.cpp index 6646f8f9..d7dfbff7 100644 --- a/sp/src/game/client/prediction.cpp +++ b/sp/src/game/client/prediction.cpp @@ -30,6 +30,13 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" +#ifdef MAPBASE +// This turned out to be causing major issues with VPhysics collision. +// It's deactivated until a fix is found. +// See player_command.cpp as well. +//#define PLAYER_COMMAND_FIX 1 +#endif + IPredictionSystem *IPredictionSystem::g_pPredictionSystems = NULL; #if !defined( NO_ENTITY_PREDICTION ) @@ -903,9 +910,15 @@ void CPrediction::RunCommand( C_BasePlayer *player, CUserCmd *ucmd, IMoveHelper pVehicle->ProcessMovement( player, g_pMoveData ); } +#ifdef PLAYER_COMMAND_FIX + RunPostThink( player ); + + FinishMove( player, ucmd, g_pMoveData ); +#else FinishMove( player, ucmd, g_pMoveData ); RunPostThink( player ); +#endif g_pGameMovement->FinishTrackPredictionErrors( player ); diff --git a/sp/src/game/client/viewrender.cpp b/sp/src/game/client/viewrender.cpp index a629071b..ca52a711 100644 --- a/sp/src/game/client/viewrender.cpp +++ b/sp/src/game/client/viewrender.cpp @@ -1327,6 +1327,9 @@ void CViewRender::ViewDrawScene( bool bDrew3dSkybox, SkyboxVisibility_t nSkyboxV if ( r_flashlightdepthtexture.GetBool() && (viewID == VIEW_MAIN) ) { g_pClientShadowMgr->ComputeShadowDepthTextures( view ); +#ifdef ASW_PROJECTED_TEXTURES + CMatRenderContextPtr pRenderContext( materials ); +#endif } m_BaseDrawFlags = baseDrawFlags; @@ -1980,6 +1983,7 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT bool bDrew3dSkybox = false; SkyboxVisibility_t nSkyboxVisible = SKYBOX_NOT_VISIBLE; +#ifndef MAPBASE // Moved to respective ViewDrawScenes() for script_intro skybox fix // if the 3d skybox world is drawn, then don't draw the normal skybox CSkyboxView *pSkyView = new CSkyboxView( this ); if ( ( bDrew3dSkybox = pSkyView->Setup( view, &nClearFlags, &nSkyboxVisible ) ) != false ) @@ -1987,6 +1991,7 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT AddViewToScene( pSkyView ); } SafeRelease( pSkyView ); +#endif // Force it to clear the framebuffer if they're in solid space. if ( ( nClearFlags & VIEW_CLEAR_COLOR ) == 0 ) @@ -1997,14 +2002,37 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT } } +#ifdef MAPBASE + // For script_intro viewmodel fix + bool bDrawnViewmodel = false; +#endif + // Render world and all entities, particles, etc. if( !g_pIntroData ) { +#ifdef MAPBASE + // Moved here for the script_intro skybox fix. + // We can't put it in ViewDrawScene() directly because other functions use it as well. + + // if the 3d skybox world is drawn, then don't draw the normal skybox + CSkyboxView *pSkyView = new CSkyboxView( this ); + if ( ( bDrew3dSkybox = pSkyView->Setup( view, &nClearFlags, &nSkyboxVisible ) ) != false ) + { + AddViewToScene( pSkyView ); + } + SafeRelease( pSkyView ); +#endif + ViewDrawScene( bDrew3dSkybox, nSkyboxVisible, view, nClearFlags, VIEW_MAIN, whatToDraw & RENDERVIEW_DRAWVIEWMODEL ); } else { +#ifdef MAPBASE + ViewDrawScene_Intro( view, nClearFlags, *g_pIntroData, bDrew3dSkybox, nSkyboxVisible, whatToDraw & RENDERVIEW_DRAWVIEWMODEL ); + bDrawnViewmodel = true; +#else ViewDrawScene_Intro( view, nClearFlags, *g_pIntroData ); +#endif } // We can still use the 'current view' stuff set up in ViewDrawScene @@ -2040,6 +2068,9 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT GetClientModeNormal()->DoPostScreenSpaceEffects( &view ); // Now actually draw the viewmodel +#ifdef MAPBASE + if (!bDrawnViewmodel) +#endif DrawViewModels( view, whatToDraw & RENDERVIEW_DRAWVIEWMODEL ); DrawUnderwaterOverlay(); @@ -2858,7 +2889,12 @@ void CViewRender::GetWaterLODParams( float &flCheapWaterStartDistance, float &fl // Input : &view - // &introData - //----------------------------------------------------------------------------- +#ifdef MAPBASE +void CViewRender::ViewDrawScene_Intro( const CViewSetup &view, int nClearFlags, const IntroData_t &introData, + bool bDrew3dSkybox, SkyboxVisibility_t nSkyboxVisible, bool bDrawViewModel, ViewCustomVisibility_t *pCustomVisibility ) +#else void CViewRender::ViewDrawScene_Intro( const CViewSetup &view, int nClearFlags, const IntroData_t &introData ) +#endif { VPROF( "CViewRender::ViewDrawScene" ); @@ -2893,6 +2929,29 @@ void CViewRender::ViewDrawScene_Intro( const CViewSetup &view, int nClearFlags, playerView.fov = ScaleFOVByWidthRatio( introData.m_playerViewFOV, engine->GetScreenAspectRatio() / ( 4.0f / 3.0f ) ); } +#ifdef MAPBASE + bool drawSkybox; + int nViewFlags; + if (introData.m_bDrawSky2) + { + drawSkybox = r_skybox.GetBool(); + nViewFlags = VIEW_CLEAR_DEPTH; + + // if the 3d skybox world is drawn, then don't draw the normal skybox + CSkyboxView *pSkyView = new CSkyboxView( this ); + if ( ( bDrew3dSkybox = pSkyView->Setup( playerView, &nClearFlags, &nSkyboxVisible ) ) != false ) + { + AddViewToScene( pSkyView ); + } + SafeRelease( pSkyView ); + } + else + { + drawSkybox = false; + nViewFlags = (VIEW_CLEAR_COLOR | VIEW_CLEAR_DEPTH); + } +#endif + g_pClientShadowMgr->PreRender(); // Shadowed flashlights supported on ps_2_b and up... @@ -2907,10 +2966,38 @@ void CViewRender::ViewDrawScene_Intro( const CViewSetup &view, int nClearFlags, IGameSystem::PreRenderAllSystems(); // Start view, clear frame/z buffer if necessary +#ifdef MAPBASE + SetupVis( playerView, visFlags, pCustomVisibility ); +#else SetupVis( playerView, visFlags ); +#endif + +#ifdef MAPBASE + if (introData.m_bDrawSky2) + { + if ( !bDrew3dSkybox && + ( nSkyboxVisible == SKYBOX_NOT_VISIBLE ) /*&& ( visFlags & IVRenderView::VIEW_SETUP_VIS_EX_RETURN_FLAGS_USES_RADIAL_VIS )*/ ) + { + // This covers the case where we don't see a 3dskybox, yet radial vis is clipping + // the far plane. Need to clear to fog color in this case. + nClearFlags |= VIEW_CLEAR_COLOR; + //SetClearColorToFogColor( ); + } + if ( bDrew3dSkybox || ( nSkyboxVisible == SKYBOX_NOT_VISIBLE ) ) + { + drawSkybox = false; + } + } +#endif + +#ifdef MAPBASE + render->Push3DView( playerView, nViewFlags, NULL, GetFrustum() ); + DrawWorldAndEntities( drawSkybox, playerView, nViewFlags ); +#else render->Push3DView( playerView, VIEW_CLEAR_COLOR | VIEW_CLEAR_DEPTH, NULL, GetFrustum() ); DrawWorldAndEntities( true /* drawSkybox */, playerView, VIEW_CLEAR_COLOR | VIEW_CLEAR_DEPTH ); +#endif render->PopView( GetFrustum() ); // Free shadow depth textures for use in future view @@ -2926,12 +3013,28 @@ void CViewRender::ViewDrawScene_Intro( const CViewSetup &view, int nClearFlags, Rect_t actualRect; UpdateScreenEffectTexture( 0, view.x, view.y, view.width, view.height, false, &actualRect ); +#ifdef MAPBASE + if (introData.m_bDrawSky) + { + // if the 3d skybox world is drawn, then don't draw the normal skybox + CSkyboxView *pSkyView = new CSkyboxView( this ); + if ( ( bDrew3dSkybox = pSkyView->Setup( view, &nClearFlags, &nSkyboxVisible ) ) != false ) + { + AddViewToScene( pSkyView ); + } + SafeRelease( pSkyView ); + } +#endif + g_pClientShadowMgr->PreRender(); // Shadowed flashlights supported on ps_2_b and up... if ( r_flashlightdepthtexture.GetBool() ) { g_pClientShadowMgr->ComputeShadowDepthTextures( view ); +#ifdef ASW_PROJECTED_TEXTURES + CMatRenderContextPtr pRenderContext( materials ); +#endif } // ----------------------------------------------------------------------- @@ -2948,7 +3051,41 @@ void CViewRender::ViewDrawScene_Intro( const CViewSetup &view, int nClearFlags, // Clear alpha to 255 so that masking with the vortigaunts (0) works properly. pRenderContext->ClearColor4ub( 0, 0, 0, 255 ); +#ifdef MAPBASE + bool drawSkybox; + int nViewFlags; + if (introData.m_bDrawSky) + { + drawSkybox = r_skybox.GetBool(); + nViewFlags = VIEW_CLEAR_DEPTH; + + if ( !bDrew3dSkybox && + ( nSkyboxVisible == SKYBOX_NOT_VISIBLE ) /*&& ( visFlags & IVRenderView::VIEW_SETUP_VIS_EX_RETURN_FLAGS_USES_RADIAL_VIS )*/ ) + { + // This covers the case where we don't see a 3dskybox, yet radial vis is clipping + // the far plane. Need to clear to fog color in this case. + nViewFlags |= VIEW_CLEAR_COLOR; + //SetClearColorToFogColor( ); + } + + if ( bDrew3dSkybox || ( nSkyboxVisible == SKYBOX_NOT_VISIBLE ) ) + { + drawSkybox = false; + } + } + else + { + drawSkybox = false; + nViewFlags = (VIEW_CLEAR_COLOR | VIEW_CLEAR_DEPTH); + } + + DrawWorldAndEntities( drawSkybox, view, nViewFlags ); + + // Solution for viewmodels not drawing in script_intro + DrawViewModels( view, bDrawViewModel ); +#else DrawWorldAndEntities( true /* drawSkybox */, view, VIEW_CLEAR_COLOR | VIEW_CLEAR_DEPTH ); +#endif UpdateScreenEffectTexture( 1, view.x, view.y, view.width, view.height ); @@ -3027,6 +3164,11 @@ void CViewRender::ViewDrawScene_Intro( const CViewSetup &view, int nClearFlags, // Let the particle manager simulate things that haven't been simulated. ParticleMgr()->PostRender(); +#ifdef MAPBASE + // Invoke post-render methods + IGameSystem::PostRenderAllSystems(); +#endif + FinishCurrentView(); // Free shadow depth textures for use in future view @@ -3096,15 +3238,62 @@ bool CViewRender::DrawOneMonitor( ITexture *pRenderTarget, int cameraNum, C_Poin monitorView.origin = pCameraEnt->GetAbsOrigin(); monitorView.angles = pCameraEnt->GetAbsAngles(); monitorView.fov = pCameraEnt->GetFOV(); +#ifdef MAPBASE + if (pCameraEnt->IsOrtho()) + { + monitorView.m_bOrtho = true; + pCameraEnt->GetOrthoDimensions( monitorView.m_OrthoTop, monitorView.m_OrthoBottom, + monitorView.m_OrthoLeft, monitorView.m_OrthoRight ); + } + else + { + monitorView.m_bOrtho = false; + } +#else monitorView.m_bOrtho = false; +#endif monitorView.m_flAspectRatio = pCameraEnt->UseScreenAspectRatio() ? 0.0f : 1.0f; monitorView.m_bViewToProjectionOverride = false; +#ifdef MAPBASE + // + // Monitor sky handling + // + if ( pCameraEnt->SkyMode() == SKYBOX_3DSKYBOX_VISIBLE ) + { + int nClearFlags = (VIEW_CLEAR_DEPTH | VIEW_CLEAR_COLOR); + bool bDrew3dSkybox = false; + SkyboxVisibility_t nSkyMode = pCameraEnt->SkyMode(); + + Frustum frustum; + render->Push3DView( monitorView, nClearFlags, pRenderTarget, (VPlane *)frustum ); + + // 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 ); + + ViewDrawScene( bDrew3dSkybox, nSkyMode, monitorView, nClearFlags, VIEW_MONITOR ); + render->PopView( frustum ); + } + else + { + // @MULTICORE (toml 8/11/2006): this should be a renderer.... + Frustum frustum; + render->Push3DView( monitorView, VIEW_CLEAR_DEPTH | VIEW_CLEAR_COLOR, pRenderTarget, (VPlane *)frustum ); + ViewDrawScene( false, SKYBOX_2DSKYBOX_VISIBLE, monitorView, 0, VIEW_MONITOR ); + render->PopView( frustum ); + } +#else // @MULTICORE (toml 8/11/2006): this should be a renderer.... Frustum frustum; render->Push3DView( monitorView, VIEW_CLEAR_DEPTH | VIEW_CLEAR_COLOR, pRenderTarget, (VPlane *)frustum ); ViewDrawScene( false, SKYBOX_2DSKYBOX_VISIBLE, monitorView, 0, VIEW_MONITOR ); render->PopView( frustum ); +#endif // Reset the world fog parameters. if ( fogEnabled ) @@ -4748,6 +4937,16 @@ void CSkyboxView::DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostR // 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 + // Use the fog's farz if specified + if (m_pSky3dParams->fog.farz > 0) + { + zFar = ( m_pSky3dParams->scale > 0.0f ? + m_pSky3dParams->fog.farz / m_pSky3dParams->scale : + m_pSky3dParams->fog.farz ); + } + else +#endif zFar = MAX_TRACE_LENGTH; // scale origin by sky scale @@ -4757,6 +4956,56 @@ void CSkyboxView::DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostR VectorScale( origin, scale, origin ); } Enable3dSkyboxFog(); +#ifdef MAPBASE + // Skybox angle support. + // + // If any of the angles aren't 0, do the rotation code. + if (m_pSky3dParams->angles.GetX() != 0 || + m_pSky3dParams->angles.GetY() != 0 || + m_pSky3dParams->angles.GetZ() != 0) + { + // Unfortunately, it's not as simple as "angles += m_pSky3dParams->angles". + // This stuff took a long time to figure out. I'm glad I got it working. + + // First, create a matrix for the sky's angles. + matrix3x4_t matSkyAngles; + AngleMatrix( m_pSky3dParams->angles, matSkyAngles ); + + // The code in between the lines below was mostly lifted from projected texture screenspace code and was a huge lifesaver. + // The comments are my attempt at explaining the little I understand of what's going on here. + // ---------------------------------------------------------------------- + + // These are the vectors that would eventually become our final angle directions. + Vector vecSkyForward, vecSkyRight, vecSkyUp; + + // Get vectors from our original angles. + Vector vPlayerForward, vPlayerRight, vPlayerUp; + AngleVectors( angles, &vPlayerForward, &vPlayerRight, &vPlayerUp ); + + // Transform them from our sky angles matrix and put the results in those vectors we declared earlier. + VectorTransform( vPlayerForward, matSkyAngles, vecSkyForward ); + VectorTransform( vPlayerRight, matSkyAngles, vecSkyRight ); + VectorTransform( vPlayerUp, matSkyAngles, vecSkyUp ); + + // Normalize them. + VectorNormalize( vecSkyForward ); + VectorNormalize( vecSkyRight ); + VectorNormalize( vecSkyUp ); + + // Now do a bit of quaternion magic and apply that to our original angles. + // This works perfectly, so I'm not gonna touch it. + Quaternion quat; + BasisToQuaternion( vecSkyForward, vecSkyRight, vecSkyUp, quat ); + QuaternionAngles( quat, 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(origin), matSkyAngles, origin); + } +#endif VectorAdd( origin, m_pSky3dParams->origin, origin ); // BUGBUG: Fix this!!! We shouldn't need to call setup vis for the sky if we're connecting @@ -4844,6 +5093,20 @@ bool CSkyboxView::Setup( const CViewSetup &view, int *pClearFlags, SkyboxVisibil *pClearFlags |= VIEW_CLEAR_DEPTH; // Need to clear depth after rednering the skybox m_DrawFlags = DF_RENDER_UNDERWATER | DF_RENDER_ABOVEWATER | DF_RENDER_WATER; +#ifdef MAPBASE + if (m_pSky3dParams->skycolor.GetA() != 0 && *pSkyboxVisible != SKYBOX_NOT_VISIBLE) + { + m_ClearFlags |= (VIEW_CLEAR_COLOR | VIEW_CLEAR_DEPTH); + m_DrawFlags |= DF_CLIP_SKYBOX; + + color32 color = m_pSky3dParams->skycolor.Get(); + + CMatRenderContextPtr pRenderContext( materials ); + pRenderContext->ClearColor4ub( color.r, color.g, color.b, color.a ); + pRenderContext.SafeRelease(); + } + else +#endif if( r_skybox.GetBool() ) { m_DrawFlags |= DF_DRAWSKYBOX; diff --git a/sp/src/game/client/viewrender.h b/sp/src/game/client/viewrender.h index 723c3222..ecd92340 100644 --- a/sp/src/game/client/viewrender.h +++ b/sp/src/game/client/viewrender.h @@ -56,6 +56,13 @@ struct IntroData_t // Fade overriding for the intro float m_flCurrentFadeColor[4]; + +#ifdef MAPBASE + // Draws the skybox. + bool m_bDrawSky; + // Draws the skybox in the secondary camera as well. + bool m_bDrawSky2; +#endif }; // Robin, make this point at something to get intro mode. @@ -452,7 +459,11 @@ private: // Water-related methods void DrawWorldAndEntities( bool drawSkybox, const CViewSetup &view, int nClearFlags, ViewCustomVisibility_t *pCustomVisibility = NULL ); +#ifdef MAPBASE + virtual void ViewDrawScene_Intro( const CViewSetup &view, int nClearFlags, const IntroData_t &introData, bool bDrew3dSkybox = false, SkyboxVisibility_t nSkyboxVisible = SKYBOX_NOT_VISIBLE, bool bDrawViewModel = false, ViewCustomVisibility_t *pCustomVisibility = NULL ); +#else virtual void ViewDrawScene_Intro( const CViewSetup &view, int nClearFlags, const IntroData_t &introData ); +#endif #ifdef PORTAL // Intended for use in the middle of another ViewDrawScene call, this allows stencils to be drawn after opaques but before translucents are drawn in the main view. diff --git a/sp/src/game/client/worldlight.cpp b/sp/src/game/client/worldlight.cpp new file mode 100644 index 00000000..7fe01a43 --- /dev/null +++ b/sp/src/game/client/worldlight.cpp @@ -0,0 +1,305 @@ +//========= Copyright (C) 2018, CSProMod Team, All rights reserved. =========// +// +// Purpose: provide world light related functions to the client +// +// As the engine provides no access to brush/model data (brushdata_t, model_t), +// we hence have no access to dworldlight_t. Therefore, we manually extract the +// world light data from the BSP itself, before entities are initialised on map +// load. +// +// To find the brightest light at a point, all world lights are iterated. +// Lights whose radii do not encompass our sample point are quickly rejected, +// as are lights which are not in our PVS, or visible from the sample point. +// If the sky light is visible from the sample point, then it shall supersede +// all other world lights. +// +// Written: November 2011 +// Author: Saul Rennison +// +//===========================================================================// + +#include "cbase.h" +#include "worldlight.h" +#include "bspfile.h" +#include "filesystem.h" +#include "client_factorylist.h" // FactoryList_Retrieve +#include "eiface.h" // IVEngineServer + +static IVEngineServer *g_pEngineServer = NULL; + +//----------------------------------------------------------------------------- +// Singleton exposure +//----------------------------------------------------------------------------- +static CWorldLights s_WorldLights; +CWorldLights *g_pWorldLights = &s_WorldLights; + +//----------------------------------------------------------------------------- +// Purpose: calculate intensity ratio for a worldlight by distance +// Author: Valve Software +//----------------------------------------------------------------------------- +static float Engine_WorldLightDistanceFalloff( const dworldlight_t *wl, const Vector& delta ) +{ + float falloff; + + switch (wl->type) + { + case emit_surface: + // Cull out stuff that's too far + if(wl->radius != 0) + { + if(DotProduct( delta, delta ) > (wl->radius * wl->radius)) + return 0.0f; + } + + return InvRSquared(delta); + break; + + case emit_skylight: + return 1.f; + break; + + case emit_quakelight: + // X - r; + falloff = wl->linear_attn - FastSqrt( DotProduct( delta, delta ) ); + if(falloff < 0) + return 0.f; + + return falloff; + break; + + case emit_skyambient: + return 1.f; + break; + + case emit_point: + case emit_spotlight: // directional & positional + { + float dist2, dist; + + dist2 = DotProduct(delta, delta); + dist = FastSqrt(dist2); + + // Cull out stuff that's too far + if(wl->radius != 0 && dist > wl->radius) + return 0.f; + + return 1.f / (wl->constant_attn + wl->linear_attn * dist + wl->quadratic_attn * dist2); + } + + break; + } + + return 1.f; +} + +//----------------------------------------------------------------------------- +// Purpose: initialise game system and members +//----------------------------------------------------------------------------- +CWorldLights::CWorldLights() : CAutoGameSystem("World lights") +{ + m_nWorldLights = 0; + m_pWorldLights = NULL; +} + +//----------------------------------------------------------------------------- +// Purpose: clear worldlights, free memory +//----------------------------------------------------------------------------- +void CWorldLights::Clear() +{ + m_nWorldLights = 0; + + if(m_pWorldLights) + { + delete [] m_pWorldLights; + m_pWorldLights = NULL; + } +} + +//----------------------------------------------------------------------------- +// Purpose: get the IVEngineServer, we need this for the PVS functions +//----------------------------------------------------------------------------- +bool CWorldLights::Init() +{ + factorylist_t factories; + FactoryList_Retrieve(factories); + + if((g_pEngineServer = (IVEngineServer*)factories.appSystemFactory(INTERFACEVERSION_VENGINESERVER, NULL)) == NULL) + return false; + + return true; +} + +//----------------------------------------------------------------------------- +// Purpose: get all world lights from the BSP +//----------------------------------------------------------------------------- +void CWorldLights::LevelInitPreEntity() +{ + // Get the map path + const char *pszMapName = modelinfo->GetModelName(modelinfo->GetModel(1)); + + // Open map + FileHandle_t hFile = g_pFullFileSystem->Open(pszMapName, "rb"); + if(!hFile) + { + Warning("CWorldLights: unable to open map\n"); + return; + } + + // Read the BSP header. We don't need to do any version checks, etc. as we + // can safely assume that the engine did this for us + dheader_t hdr; + g_pFullFileSystem->Read(&hdr, sizeof(hdr), hFile); + + // Grab the light lump and seek to it + lump_t &lightLump = hdr.lumps[LUMP_WORLDLIGHTS]; + + // INSOLENCE: If the worldlights lump is empty, that means theres no normal, LDR lights to extract + // This can happen when, for example, the map is compiled in HDR mode only + // So move on to the HDR worldlights lump + if (lightLump.filelen == 0) + { + lightLump = hdr.lumps[LUMP_WORLDLIGHTS_HDR]; + } + + // If we can't divide the lump data into a whole number of worldlights, + // then the BSP format changed and we're unaware + if(lightLump.filelen % sizeof(dworldlight_t)) + { + Warning("CWorldLights: unknown world light lump\n"); + + // Close file + g_pFullFileSystem->Close(hFile); + return; + } + + g_pFullFileSystem->Seek(hFile, lightLump.fileofs, FILESYSTEM_SEEK_HEAD); + + // Allocate memory for the worldlights + m_nWorldLights = lightLump.filelen / sizeof(dworldlight_t); + m_pWorldLights = new dworldlight_t[m_nWorldLights]; + + // Read worldlights then close + g_pFullFileSystem->Read(m_pWorldLights, lightLump.filelen, hFile); + g_pFullFileSystem->Close(hFile); + + DevMsg("CWorldLights: load successful (%d lights at 0x%p)\n", m_nWorldLights, m_pWorldLights); +} + +//----------------------------------------------------------------------------- +// Purpose: find the brightest light source at a point +//----------------------------------------------------------------------------- +bool CWorldLights::GetBrightestLightSource(const Vector &vecPosition, Vector &vecLightPos, Vector &vecLightBrightness) +{ + if(!m_nWorldLights || !m_pWorldLights) + return false; + + // Default light position and brightness to zero + vecLightBrightness.Init(); + vecLightPos.Init(); + + // Find the size of the PVS for our current position + int nCluster = g_pEngineServer->GetClusterForOrigin(vecPosition); + int nPVSSize = g_pEngineServer->GetPVSForCluster(nCluster, 0, NULL); + + // Get the PVS at our position + byte *pvs = new byte[nPVSSize]; + g_pEngineServer->GetPVSForCluster(nCluster, nPVSSize, pvs); + + // Iterate through all the worldlights + for(int i = 0; i < m_nWorldLights; ++i) + { + dworldlight_t *light = &m_pWorldLights[i]; + + // Skip skyambient + if(light->type == emit_skyambient) + { + //engine->Con_NPrintf(i, "%d: skyambient", i); + continue; + } + + // Handle sun + if(light->type == emit_skylight) + { + // Calculate sun position + Vector vecAbsStart = vecPosition + Vector(0,0,30); + Vector vecAbsEnd = vecAbsStart - (light->normal * MAX_TRACE_LENGTH); + + trace_t tr; + UTIL_TraceLine(vecPosition, vecAbsEnd, MASK_OPAQUE, NULL, COLLISION_GROUP_NONE, &tr); + + // If we didn't hit anything then we have a problem + if(!tr.DidHit()) + { + //engine->Con_NPrintf(i, "%d: skylight: couldn't touch sky", i); + continue; + } + + // If we did hit something, and it wasn't the skybox, then skip + // this worldlight + if(!(tr.surface.flags & SURF_SKY) && !(tr.surface.flags & SURF_SKY2D)) + { + //engine->Con_NPrintf(i, "%d: skylight: no sight to sun", i); + continue; + } + + // Act like we didn't find any valid worldlights, so the shadow + // manager uses the default shadow direction instead (should be the + // sun direction) + + delete[] pvs; + + return false; + } + + // Calculate square distance to this worldlight + Vector vecDelta = light->origin - vecPosition; + float flDistSqr = vecDelta.LengthSqr(); + float flRadiusSqr = light->radius * light->radius; + + // Skip lights that are out of our radius + if(flRadiusSqr > 0 && flDistSqr >= flRadiusSqr) + { + //engine->Con_NPrintf(i, "%d: out-of-radius (dist: %d, radius: %d)", i, sqrt(flDistSqr), light->radius); + continue; + } + + // Is it out of our PVS? + if(!g_pEngineServer->CheckOriginInPVS(light->origin, pvs, nPVSSize)) + { + //engine->Con_NPrintf(i, "%d: out of PVS", i); + continue; + } + + // Calculate intensity at our position + float flRatio = Engine_WorldLightDistanceFalloff(light, vecDelta); + Vector vecIntensity = light->intensity * flRatio; + + // Is this light more intense than the one we already found? + if(vecIntensity.LengthSqr() <= vecLightBrightness.LengthSqr()) + { + //engine->Con_NPrintf(i, "%d: too dim", i); + continue; + } + + // Can we see the light? + trace_t tr; + Vector vecAbsStart = vecPosition + Vector(0,0,30); + UTIL_TraceLine(vecAbsStart, light->origin, MASK_OPAQUE, NULL, COLLISION_GROUP_NONE, &tr); + + if(tr.DidHit()) + { + //engine->Con_NPrintf(i, "%d: trace failed", i); + continue; + } + + vecLightPos = light->origin; + vecLightBrightness = vecIntensity; + + //engine->Con_NPrintf(i, "%d: set (%.2f)", i, vecIntensity.Length()); + } + + delete[] pvs; + + //engine->Con_NPrintf(m_nWorldLights, "result: %d", !vecLightBrightness.IsZero()); + return !vecLightBrightness.IsZero(); +} diff --git a/sp/src/game/client/worldlight.h b/sp/src/game/client/worldlight.h new file mode 100644 index 00000000..b5650878 --- /dev/null +++ b/sp/src/game/client/worldlight.h @@ -0,0 +1,47 @@ +//========= Copyright (C) 2018, CSProMod Team, All rights reserved. =========// +// +// Purpose: provide world light related functions to the client +// +// Written: November 2011 +// Author: Saul Rennison +// +//===========================================================================// + +#pragma once + +#include "igamesystem.h" // CAutoGameSystem + +class Vector; +struct dworldlight_t; + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +class CWorldLights : public CAutoGameSystem +{ +public: + CWorldLights(); + ~CWorldLights() { Clear(); } + + //------------------------------------------------------------------------- + // Find the brightest light source at a point + //------------------------------------------------------------------------- + bool GetBrightestLightSource(const Vector &vecPosition, Vector &vecLightPos, Vector &vecLightBrightness); + + // CAutoGameSystem overrides +public: + virtual bool Init(); + virtual void LevelInitPreEntity(); + virtual void LevelShutdownPostEntity() { Clear(); } + +private: + void Clear(); + + int m_nWorldLights; + dworldlight_t *m_pWorldLights; +}; + +//----------------------------------------------------------------------------- +// Singleton exposure +//----------------------------------------------------------------------------- +extern CWorldLights *g_pWorldLights; diff --git a/sp/src/game/server/AI_Criteria.cpp b/sp/src/game/server/AI_Criteria.cpp index ff84decd..d0b25e8a 100644 --- a/sp/src/game/server/AI_Criteria.cpp +++ b/sp/src/game/server/AI_Criteria.cpp @@ -176,6 +176,22 @@ void AI_CriteriaSet::Describe() } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Merges another AI_CriteriaSet without clearing +// Input : src - +//----------------------------------------------------------------------------- +void AI_CriteriaSet::MergeSet( const AI_CriteriaSet& src ) +{ + for ( short i = src.m_Lookup.FirstInorder(); + i != src.m_Lookup.InvalidIndex(); + i = src.m_Lookup.NextInorder( i ) ) + { + m_Lookup.Insert( src.m_Lookup[ i ] ); + } +} +#endif + BEGIN_SIMPLE_DATADESC( AI_ResponseParams ) DEFINE_FIELD( flags, FIELD_SHORT ), DEFINE_FIELD( odds, FIELD_SHORT ), @@ -202,7 +218,11 @@ AI_Response::AI_Response() m_pCriteria = NULL; m_szMatchingRule[0]=0; m_szContext = NULL; +#ifdef MAPBASE + m_iContextFlags = 0; +#else m_bApplyContextToWorld = false; +#endif } //----------------------------------------------------------------------------- @@ -215,7 +235,11 @@ AI_Response::AI_Response( const AI_Response &from ) m_pCriteria = NULL; m_szContext = NULL; SetContext( from.m_szContext ); +#ifdef MAPBASE + m_iContextFlags = from.m_iContextFlags; +#else m_bApplyContextToWorld = from.m_bApplyContextToWorld; +#endif } //----------------------------------------------------------------------------- @@ -237,7 +261,11 @@ AI_Response &AI_Response::operator=( const AI_Response &from ) m_pCriteria = NULL; m_szContext = NULL; SetContext( from.m_szContext ); +#ifdef MAPBASE + m_iContextFlags = from.m_iContextFlags; +#else m_bApplyContextToWorld = from.m_bApplyContextToWorld; +#endif return *this; } @@ -255,9 +283,32 @@ void AI_Response::Init( ResponseType_t type, const char *responseName, const AI_ Q_strncpy( m_szMatchingRule, ruleName ? ruleName : "NULL", sizeof( m_szMatchingRule ) ); m_Params = responseparams; SetContext( applyContext ); +#ifdef MAPBASE + bApplyContextToWorld ? m_iContextFlags = APPLYCONTEXT_WORLD : m_iContextFlags = 0; +#else m_bApplyContextToWorld = bApplyContextToWorld; +#endif } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +// Input : *response - +// *criteria - +//----------------------------------------------------------------------------- +void AI_Response::Init( ResponseType_t type, const char *responseName, const AI_CriteriaSet& criteria, const AI_ResponseParams& responseparams, const char *ruleName, const char *applyContext, int iContextFlags ) +{ + m_Type = type; + Q_strncpy( m_szResponseName, responseName, sizeof( m_szResponseName ) ); + // Copy underlying criteria + m_pCriteria = new AI_CriteriaSet( criteria ); + Q_strncpy( m_szMatchingRule, ruleName ? ruleName : "NULL", sizeof( m_szMatchingRule ) ); + m_Params = responseparams; + SetContext( applyContext ); + m_iContextFlags = iContextFlags; +} +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -274,7 +325,19 @@ void AI_Response::Describe() } if ( m_szContext ) { +#ifdef MAPBASE + DevMsg( "Contexts to set '%s' on ", m_szContext ); + if (m_iContextFlags & APPLYCONTEXT_WORLD) + DevMsg("world, "); + else if (m_iContextFlags & APPLYCONTEXT_SQUAD) + DevMsg("squad, "); + else if (m_iContextFlags & APPLYCONTEXT_ENEMY) + DevMsg("enemy, "); + else + DevMsg("speaker, "); +#else DevMsg( "Contexts to set '%s' on %s, ", m_szContext, m_bApplyContextToWorld ? "world" : "speaker" ); +#endif } DevMsg( "response %s = '%s'\n", DescribeResponse( (ResponseType_t)m_Type ), m_szResponseName ); diff --git a/sp/src/game/server/AI_Criteria.h b/sp/src/game/server/AI_Criteria.h index 72c54080..81ddc169 100644 --- a/sp/src/game/server/AI_Criteria.h +++ b/sp/src/game/server/AI_Criteria.h @@ -37,6 +37,10 @@ public: const char *GetValue( int index ) const; float GetWeight( int index ) const; +#ifdef MAPBASE + void MergeSet( const AI_CriteriaSet& src ); +#endif + private: struct CritEntry_t @@ -168,6 +172,24 @@ enum ResponseType_t NUM_RESPONSES, }; +#ifdef MAPBASE +// I wanted to add more options to apply contexts to, +// so I replaced the existing system with a flag-based integer instead of a bunch of booleans. +// +// New ones should be implemented in: +// CResponseSystem::ParseRule() - AI_ResponseSystem.cpp +// AI_Response::Describe() - AI_Criteria.cpp +// CAI_Expresser::SpeakDispatchResponse() - ai_speech.cpp +enum +{ + APPLYCONTEXT_SELF = (1 << 0), // Included for contexts that apply to both self and something else + APPLYCONTEXT_WORLD = (1 << 1), // Apply to world + + APPLYCONTEXT_SQUAD = (1 << 2), // Apply to squad + APPLYCONTEXT_ENEMY = (1 << 3), // Apply to enemy +}; +#endif + class AI_Response { public: @@ -197,7 +219,12 @@ public: void SetContext( const char *context ); const char * GetContext( void ) const { return m_szContext; } +#ifdef MAPBASE + int GetContextFlags() { return m_iContextFlags; } + bool IsApplyContextToWorld( void ) { return (m_iContextFlags & APPLYCONTEXT_WORLD) != 0; } +#else bool IsApplyContextToWorld( void ) { return m_bApplyContextToWorld; } +#endif void Describe(); @@ -211,6 +238,16 @@ public: const char *applyContext, bool bApplyContextToWorld ); +#ifdef MAPBASE + void Init( ResponseType_t type, + const char *responseName, + const AI_CriteriaSet& criteria, + const AI_ResponseParams& responseparams, + const char *matchingRule, + const char *applyContext, + int iContextFlags ); +#endif + static const char *DescribeResponse( ResponseType_t type ); enum @@ -231,7 +268,11 @@ private: AI_ResponseParams m_Params; char * m_szContext; +#ifdef MAPBASE + int m_iContextFlags; +#else bool m_bApplyContextToWorld; +#endif }; #endif // AI_CRITERIA_H diff --git a/sp/src/game/server/AI_ResponseSystem.cpp b/sp/src/game/server/AI_ResponseSystem.cpp index 510a1d4e..2023de4b 100644 --- a/sp/src/game/server/AI_ResponseSystem.cpp +++ b/sp/src/game/server/AI_ResponseSystem.cpp @@ -22,6 +22,9 @@ #include "stringpool.h" #include "fmtstr.h" #include "multiplay_gamerules.h" +#ifdef MAPBASE +#include "mapbase/matchers.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -57,6 +60,9 @@ public: minequals = false; usemax = false; maxequals = false; +#ifdef MAPBASE + isbit = false; +#endif maxval = 0.0f; minval = 0.0f; @@ -99,6 +105,14 @@ public: return; } +#ifdef MAPBASE + if (isbit) + { + DevMsg( " matcher: &%s%s\n", notequal ? "~" : "", GetToken() ); + return; + } +#endif + if ( notequal ) { DevMsg( " matcher: !=%s\n", GetToken() ); @@ -118,6 +132,9 @@ public: bool minequals : 1; //5 bool usemax : 1; //6 bool maxequals : 1; //7 +#ifdef MAPBASE + bool isbit : 1; //8 +#endif void SetToken( char const *s ) { @@ -461,7 +478,11 @@ struct Rule m_bMatchOnce = false; m_bEnabled = true; m_szContext = NULL; +#ifdef MAPBASE + m_iContextFlags = 0; +#else m_bApplyContextToWorld = false; +#endif } Rule& operator =( const Rule& src ) @@ -487,7 +508,11 @@ struct Rule SetContext( src.m_szContext ); m_bMatchOnce = src.m_bMatchOnce; m_bEnabled = src.m_bEnabled; +#ifdef MAPBASE + m_iContextFlags = src.m_iContextFlags; +#else m_bApplyContextToWorld = src.m_bApplyContextToWorld; +#endif return *this; } @@ -511,7 +536,11 @@ struct Rule SetContext( src.m_szContext ); m_bMatchOnce = src.m_bMatchOnce; m_bEnabled = src.m_bEnabled; +#ifdef MAPBASE + m_iContextFlags = src.m_iContextFlags; +#else m_bApplyContextToWorld = src.m_bApplyContextToWorld; +#endif } ~Rule() @@ -530,14 +559,22 @@ struct Rule bool IsEnabled() const { return m_bEnabled; } void Disable() { m_bEnabled = false; } bool IsMatchOnce() const { return m_bMatchOnce; } +#ifdef MAPBASE + bool IsApplyContextToWorld() const { return (m_iContextFlags & APPLYCONTEXT_WORLD) != 0; } +#else bool IsApplyContextToWorld() const { return m_bApplyContextToWorld; } +#endif // Indices into underlying criteria and response dictionaries CUtlVector< unsigned short > m_Criteria; CUtlVector< unsigned short> m_Responses; char *m_szContext; +#ifdef MAPBASE + int m_iContextFlags; +#else bool m_bApplyContextToWorld : 1; +#endif bool m_bMatchOnce : 1; bool m_bEnabled : 1; @@ -668,7 +705,11 @@ public: void ParseOneResponse( const char *responseGroupName, ResponseGroup& group ); +#ifdef MAPBASE + void ParseInclude( CStringPool &includedFiles, const char *scriptfile = NULL ); +#else void ParseInclude( CStringPool &includedFiles ); +#endif void ParseResponse( void ); void ParseCriterion( void ); void ParseRule( void ); @@ -865,6 +906,7 @@ void CResponseSystem::ResolveToken( Matcher& matcher, char *token, size_t bufsiz } +#ifndef MAPBASE // Moved to matchers.h static bool AppearsToBeANumber( char const *token ) { if ( atof( token ) != 0.0f ) @@ -881,6 +923,7 @@ static bool AppearsToBeANumber( char const *token ) return true; } +#endif void CResponseSystem::ComputeMatcher( Criteria *c, Matcher& matcher ) { @@ -905,6 +948,9 @@ void CResponseSystem::ComputeMatcher( Criteria *c, Matcher& matcher ) bool lt = false; bool eq = false; bool nt = false; +#ifdef MAPBASE + bool bit = false; +#endif bool done = false; while ( !done ) @@ -937,6 +983,17 @@ void CResponseSystem::ComputeMatcher( Criteria *c, Matcher& matcher ) // Convert raw token to real token in case token is an enumerated type specifier ResolveToken( matcher, token, sizeof( token ), rawtoken ); +#ifdef MAPBASE + // Bits are an entirely different and independent story + if (bit) + { + matcher.isbit = true; + matcher.notequal = nt; + + matcher.isnumeric = true; + } + else +#endif // Fill in first data set if ( gt ) { @@ -978,6 +1035,13 @@ void CResponseSystem::ComputeMatcher( Criteria *c, Matcher& matcher ) case '!': nt = true; break; +#ifdef MAPBASE + case '~': + nt = true; + case '&': + bit = true; + break; +#endif default: rawtoken[ n++ ] = *in; break; @@ -1002,6 +1066,19 @@ bool CResponseSystem::CompareUsingMatcher( const char *setValue, Matcher& m, boo bool found = false; v = LookupEnumeration( setValue, found ); } + +#ifdef MAPBASE + // Bits are always a different story + if (m.isbit) + { + int v1 = v; + int v2 = atoi(m.GetToken()); + if (m.notequal) + return (v1 & v2) == 0; + else + return (v1 & v2) != 0; + } +#endif int minmaxcount = 0; @@ -1052,7 +1129,11 @@ bool CResponseSystem::CompareUsingMatcher( const char *setValue, Matcher& m, boo } else { +#ifdef MAPBASE + if ( Matcher_NamesMatch(m.GetToken(), setValue) ) +#else if ( !Q_stricmp( setValue, m.GetToken() ) ) +#endif return false; } @@ -1069,7 +1150,12 @@ bool CResponseSystem::CompareUsingMatcher( const char *setValue, Matcher& m, boo return v == (float)atof( m.GetToken() ); } +#ifdef MAPBASE + // Wildcards. + return Matcher_NamesMatch(m.GetToken(), setValue) ? true : false; +#else return !Q_stricmp( setValue, m.GetToken() ) ? true : false; +#endif } bool CResponseSystem::Compare( const char *setValue, Criteria *c, bool verbose /*= false*/ ) @@ -1745,11 +1831,19 @@ bool CResponseSystem::FindBestResponse( const AI_CriteriaSet& set, AI_Response& char ruleName[ 128 ]; char responseName[ 128 ]; const char *context; +#ifdef MAPBASE + int contextflags; +#else bool bcontexttoworld; +#endif ruleName[ 0 ] = 0; responseName[ 0 ] = 0; context = NULL; +#ifdef MAPBASE + contextflags = 0; +#else bcontexttoworld = false; +#endif if ( bestRule != -1 ) { Rule *r = &m_Rules[ bestRule ]; @@ -1770,12 +1864,20 @@ bool CResponseSystem::FindBestResponse( const AI_CriteriaSet& set, AI_Response& r->Disable(); } context = r->GetContext(); +#ifdef MAPBASE + contextflags = r->m_iContextFlags; +#else bcontexttoworld = r->IsApplyContextToWorld(); +#endif valid = true; } +#ifdef MAPBASE + response.Init( responseType, responseName, set, rp, ruleName, context, contextflags ); +#else response.Init( responseType, responseName, set, rp, ruleName, context, bcontexttoworld ); +#endif if ( showResult ) { @@ -1894,11 +1996,42 @@ void CResponseSystem::Precache() } } +#ifdef MAPBASE +void CResponseSystem::ParseInclude( CStringPool &includedFiles, const char *scriptfile ) +#else void CResponseSystem::ParseInclude( CStringPool &includedFiles ) +#endif { char includefile[ 256 ]; ParseToken(); +#ifdef MAPBASE + if (scriptfile) + { + // Gets first path + // (for example, an #include from a file in resource/script/resp will return resource) + size_t len = strlen(scriptfile)-1; + for (size_t i = 0; i < len; i++) + { + if (scriptfile[i] == CORRECT_PATH_SEPARATOR || scriptfile[i] == INCORRECT_PATH_SEPARATOR) + { + len = i; + } + } + Q_strncpy(includefile, scriptfile, len+1); + + if (len+1 != strlen(scriptfile)) + { + Q_snprintf(includefile, sizeof(includefile), "%s/%s", includefile, token); + } + else + includefile[0] = '\0'; + } + + if (!includefile[0]) + Q_snprintf( includefile, sizeof( includefile ), "scripts/%s", token ); +#else Q_snprintf( includefile, sizeof( includefile ), "scripts/%s", token ); +#endif // check if the file is already included if ( includedFiles.Find( includefile ) != NULL ) @@ -1939,8 +2072,19 @@ void CResponseSystem::LoadFromBuffer( const char *scriptfile, const char *buffer if ( !Q_stricmp( token, "#include" ) ) { +#ifdef MAPBASE + ParseInclude( includedFiles, scriptfile ); +#else ParseInclude( includedFiles ); +#endif } +#ifdef MAPBASE + else if ( !Q_stricmp( token, "#base" ) ) + { + // Actual #base in the future? + ParseInclude( includedFiles, scriptfile ); + } +#endif else if ( !Q_stricmp( token, "response" ) ) { ParseResponse(); @@ -2324,6 +2468,16 @@ void CResponseSystem::ParseResponse( void ) ParseOneResponse( responseGroupName, newGroup ); } +#ifdef MAPBASE + short existing = m_Responses.Find( responseGroupName ); + if ( existing != m_Responses.InvalidIndex() ) + { + //ResponseWarning( "Additional definition for response '%s', overwriting\n", responseGroupName ); + m_Responses[existing] = newGroup; + m_Responses.SetElementName(existing, responseGroupName); + return; + } +#endif m_Responses.Insert( responseGroupName, newGroup ); } @@ -2405,11 +2559,22 @@ int CResponseSystem::ParseOneCriterion( const char *criterionName ) ComputeMatcher( &newCriterion, newCriterion.matcher ); } +#ifdef MAPBASE + short existing = m_Criteria.Find( criterionName ); + if ( existing != m_Criteria.InvalidIndex() ) + { + //ResponseWarning( "Additional definition for criteria '%s', overwriting\n", criterionName ); + m_Criteria[existing] = newCriterion; + m_Criteria.SetElementName(existing, criterionName); + return existing; + } +#else if ( m_Criteria.Find( criterionName ) != m_Criteria.InvalidIndex() ) { ResponseWarning( "Multiple definitions for criteria '%s'\n", criterionName ); return m_Criteria.InvalidIndex(); } +#endif int idx = m_Criteria.Insert( criterionName, newCriterion ); return idx; @@ -2475,12 +2640,22 @@ void CResponseSystem::ParseEnumeration( void ) { m_Enumerations.Insert( sz, newEnum ); } +#ifdef MAPBASE + else + { + short existing = m_Enumerations.Find( sz ); + //ResponseWarning( "Additional definition for enumeration '%s', overwriting\n", sz ); + m_Enumerations[existing] = newEnum; + m_Enumerations.SetElementName(existing, sz); + } +#else /* else { ResponseWarning( "Ignoring duplication enumeration '%s'\n", sz ); } */ +#endif } } @@ -2531,10 +2706,28 @@ void CResponseSystem::ParseRule( void ) if ( !Q_stricmp( token, "applyContextToWorld" ) ) { +#ifdef MAPBASE + newRule.m_iContextFlags |= APPLYCONTEXT_WORLD; +#else newRule.m_bApplyContextToWorld = true; +#endif continue; } +#ifdef MAPBASE + if ( !Q_stricmp( token, "applyContextToSquad" ) ) + { + newRule.m_iContextFlags |= APPLYCONTEXT_SQUAD; + continue; + } + + if ( !Q_stricmp( token, "applyContextToEnemy" ) ) + { + newRule.m_iContextFlags |= APPLYCONTEXT_ENEMY; + continue; + } +#endif + if ( !Q_stricmp( token, "applyContext" ) ) { ParseToken(); @@ -2606,6 +2799,16 @@ void CResponseSystem::ParseRule( void ) if ( validRule ) { +#ifdef MAPBASE + short existing = m_Rules.Find( ruleName ); + if ( existing != m_Rules.InvalidIndex() ) + { + //ResponseWarning( "Additional definition for rule '%s', overwriting\n", ruleName ); + m_Rules[existing] = newRule; + m_Rules.SetElementName(existing, ruleName); + return; + } +#endif m_Rules.Insert( ruleName, newRule ); } else @@ -2791,7 +2994,11 @@ void CResponseSystem::CopyRuleFrom( Rule *pSrcRule, int iRule, CResponseSystem * dstRule.SetContext( pSrcRule->GetContext() ); dstRule.m_bMatchOnce = pSrcRule->m_bMatchOnce; dstRule.m_bEnabled = pSrcRule->m_bEnabled; +#ifdef MAPBASE + dstRule.m_iContextFlags = pSrcRule->m_iContextFlags; +#else dstRule.m_bApplyContextToWorld = pSrcRule->m_bApplyContextToWorld; +#endif // Copy off criteria. CopyCriteriaFrom( pSrcRule, &dstRule, pCustomSystem ); @@ -2806,6 +3013,10 @@ void CResponseSystem::CopyRuleFrom( Rule *pSrcRule, int iRule, CResponseSystem * pCustomSystem->m_Rules.Insert( m_Rules.GetElementName( iRule ), dstRule ); } +#ifdef MAPBASE +ConVar mapbase_rs_clear("mapbase_rs_clear", "1"); +#endif + //----------------------------------------------------------------------------- // Purpose: A special purpose response system associated with a custom entity //----------------------------------------------------------------------------- @@ -2853,6 +3064,32 @@ public: Clear(); delete this; } + +#ifdef MAPBASE + // From an old version of Mapbase's map-specific response system stuff. + /* + #define CopyRSDict(dict) for (unsigned int i = 0; i < dict.Count(); i++) \ + { \ + rs->dict.Insert(dict.GetElementName(i), dict[i]); \ + } \ + + bool MergeWithMain(bool bRemoveThis = true) + { + extern IResponseSystem *g_pResponseSystem; + CResponseSystem *rs = static_cast(g_pResponseSystem); + + CopyRSDict(m_Responses); + CopyRSDict(m_Criteria); + CopyRSDict(m_Rules); + CopyRSDict(m_Enumerations); + + if (mapbase_rs_clear.GetBool()) + Release(); + + return true; + } + */ +#endif private: char *m_pszScriptFile; @@ -3051,6 +3288,254 @@ CON_COMMAND( rr_reloadresponsesystems, "Reload all response system scripts." ) #endif } +#ifdef MAPBASE +// Designed for extern magic, this gives the <, >, etc. of response system criteria to the outside world. +// Mostly just used for Matcher_Match in matchers.h. +bool ResponseSystemCompare(const char *criterion, const char *value) +{ + Criteria criteria; + criteria.value = CopyString( criterion ); + defaultresponsesytem.ComputeMatcher(&criteria, criteria.matcher); + return defaultresponsesytem.CompareUsingMatcher(value, criteria.matcher, true); + + return false; +} + +// Another version that returns the criterion without the operators. +// I ended up not using this, but feel free to uncomment it. +// Just keep in mind it was scrapped before I could test it... +/* +const char *ResponseSystemCompare(const char *criterion, const char *value, bool bReturnToken) +{ + CResponseSystem *responsesys = dynamic_cast(g_pResponseSystem); + if (responsesys) + { + Criteria criteria; + criteria.value = CopyString( criterion ); + responsesys->ComputeMatcher(&criteria, criteria.matcher); + return responsesys->CompareUsingMatcher(value, criteria.matcher, true) ? criteria.matcher.GetToken() : NULL; + } + return NULL; +} +*/ + +//----------------------------------------------------------------------------- +// CResponseFilePrecacher +// +// Purpose: Precaches a single talker file. That's it. +// +// It copies from a bunch of the original Response System class and therefore it's really messy. +// Despite the horrors a normal programmer might find in here, I think it performs better than anything else I could've come up with. +//----------------------------------------------------------------------------- +class CResponseFilePrecacher +{ +public: + + // Stuff copied from the Response System. + // Direct copy-pastes are very compact, to say the least. + inline bool ParseToken( void ) + { + if ( m_bUnget ) + { m_bUnget = false; return true; } + if ( m_ScriptStack.Count() <= 0 ) + { return false; } + + m_ScriptStack[ 0 ].currenttoken = engine->ParseFile( m_ScriptStack[ 0 ].currenttoken, token, sizeof( token ) ); + m_ScriptStack[ 0 ].tokencount++; + return m_ScriptStack[ 0 ].currenttoken != NULL ? true : false; + } + + CUtlVector< CResponseSystem::ScriptEntry > m_ScriptStack; + bool m_bUnget; + char token[ 1204 ]; + + + void PrecacheResponse( const char *response, byte type ) + { + switch ( type ) + { + default: + break; + case RESPONSE_SCENE: + { + DevMsg("Precaching scene %s...\n", response); + + // fixup $gender references + char file[_MAX_PATH]; + Q_strncpy( file, response, sizeof(file) ); + char *gender = strstr( file, "$gender" ); + if ( gender ) + { + // replace with male & female + const char *postGender = gender + strlen("$gender"); + *gender = 0; + char genderFile[_MAX_PATH]; + + Q_snprintf( genderFile, sizeof(genderFile), "%smale%s", file, postGender); + PrecacheInstancedScene( genderFile ); + + Q_snprintf( genderFile, sizeof(genderFile), "%sfemale%s", file, postGender); + PrecacheInstancedScene( genderFile ); + } + else + { + PrecacheInstancedScene( file ); + } + } + break; + case RESPONSE_SPEAK: + { + DevMsg("Precaching sound %s...\n", response); + CBaseEntity::PrecacheScriptSound( response ); + } + break; + } + } + + bool IsRootCommand() + { + if (!Q_stricmp( token, "#include" ) || !Q_stricmp( token, "response" ) + || !Q_stricmp( token, "enumeration" ) || !Q_stricmp( token, "criteria" ) + || !Q_stricmp( token, "criterion" ) || !Q_stricmp( token, "rule" )) + return true; + return false; + } + + void ParseResponse( void ) + { + // Must go to response group name + ParseToken(); + + while ( 1 ) + { + ParseToken(); + + if ( !Q_stricmp( token, "{" ) ) + { + while ( 1 ) + { + ParseToken(); + if ( !Q_stricmp( token, "}" ) ) + break; + + byte type = ComputeResponseType( token ); + if (type == RESPONSE_NONE) + continue; + + ParseToken(); + char *value = CopyString( token ); + + PrecacheResponse(value, type); + } + break; + } + + byte type = ComputeResponseType( token ); + if (type == RESPONSE_NONE) + break; + + ParseToken(); + char *value = CopyString( token ); + + PrecacheResponse(value, type); + + break; + } + } + + bool LoadFromBuffer(const char *scriptfile, unsigned char *buffer, CStringPool &includedFiles) + { + includedFiles.Allocate( scriptfile ); + + CResponseSystem::ScriptEntry e; + e.name = filesystem->FindOrAddFileName( scriptfile ); + e.buffer = buffer; + e.currenttoken = (char *)e.buffer; + e.tokencount = 0; + m_ScriptStack.AddToHead( e ); + + while ( 1 ) + { + ParseToken(); + if ( !token[0] ) + { + break; + } + + if ( !Q_stricmp( token, "response" ) ) + { + ParseResponse(); + } + else if ( !Q_stricmp( token, "#include" ) || !Q_stricmp( token, "#base" ) ) + { + // Compacted version of ParseInclude(), including new changes. + // Look at that if you want to read. + char includefile[ 256 ]; + ParseToken(); + if (scriptfile) { size_t len = strlen(scriptfile)-1; + for (size_t i = 0; i < len; i++) + { if (scriptfile[i] == CORRECT_PATH_SEPARATOR || scriptfile[i] == INCORRECT_PATH_SEPARATOR) + { len = i; } + } Q_strncpy(includefile, scriptfile, len+1); + if (len+1 != strlen(scriptfile)) + { Q_snprintf(includefile, sizeof(includefile), "%s/%s", includefile, token); } + else includefile[0] = '\0'; + } if (!includefile[0]) Q_snprintf( includefile, sizeof( includefile ), "scripts/%s", token ); + + if ( includedFiles.Find( includefile ) == NULL ) + { + MEM_ALLOC_CREDIT(); + + // Try and load it + CUtlBuffer buf; + if ( filesystem->ReadFile( includefile, "GAME", buf ) ) + { + LoadFromBuffer( includefile, (unsigned char *)buf.PeekGet(), includedFiles ); + } + } + } + } + + if ( m_ScriptStack.Count() > 0 ) + m_ScriptStack.Remove( 0 ); + + return true; + } +}; + +// Loads a file directly to the main response system +bool LoadResponseSystemFile(const char *scriptfile) +{ + CUtlBuffer buf; + if ( !filesystem->ReadFile( scriptfile, "GAME", buf ) ) + { + return false; + } + + // This is a really messy and specialized system that precaches the responses and only the responses of a talker file. + CStringPool includedFiles; + CResponseFilePrecacher *rs = new CResponseFilePrecacher(); + if (!rs || !rs->LoadFromBuffer(scriptfile, (unsigned char *)buf.PeekGet(), includedFiles)) + { + Warning( "Failed to load response system data from %s", scriptfile ); + delete rs; + return false; + } + delete rs; + + CStringPool includedFiles2; + defaultresponsesytem.LoadFromBuffer(scriptfile, (const char *)buf.PeekGet(), includedFiles2); + + return true; +} + +// Called from Mapbase manifests to flush +void ReloadResponseSystem() +{ + defaultresponsesytem.ReloadAllResponseSystems(); +} +#endif + static short RESPONSESYSTEM_SAVE_RESTORE_VERSION = 1; // note: this won't save/restore settings from instanced response systems. Could add that with a CDefSaveRestoreOps implementation if needed diff --git a/sp/src/game/server/BasePropDoor.h b/sp/src/game/server/BasePropDoor.h index 1bfdc406..d96c75c5 100644 --- a/sp/src/game/server/BasePropDoor.h +++ b/sp/src/game/server/BasePropDoor.h @@ -75,6 +75,10 @@ public: virtual float GetOpenInterval(void) = 0; // } +#ifdef MAPBASE + virtual bool PassesDoorFilter(CBaseEntity *pEntity) { return true; } +#endif + protected: enum DoorState_t @@ -163,6 +167,10 @@ private: void InputOpenAwayFrom(inputdata_t &inputdata); void InputToggle(inputdata_t &inputdata); void InputUnlock(inputdata_t &inputdata); +#ifdef MAPBASE + void InputAllowPlayerUse(inputdata_t &inputdata); + void InputDisallowPlayerUse(inputdata_t &inputdata); +#endif void SetDoorBlocker( CBaseEntity *pBlocker ); diff --git a/sp/src/game/server/CRagdollMagnet.cpp b/sp/src/game/server/CRagdollMagnet.cpp index 454f7804..f64afb4f 100644 --- a/sp/src/game/server/CRagdollMagnet.cpp +++ b/sp/src/game/server/CRagdollMagnet.cpp @@ -20,10 +20,17 @@ BEGIN_DATADESC( CRagdollMagnet ) DEFINE_KEYFIELD( m_force, FIELD_FLOAT, "force" ), DEFINE_KEYFIELD( m_axis, FIELD_VECTOR, "axis" ), DEFINE_KEYFIELD( m_bDisabled, FIELD_BOOLEAN, "StartDisabled" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_BoneTarget, FIELD_STRING, "BoneTarget" ), +#endif DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OnUsed, "OnUsed" ), +#endif + END_DATADESC() //----------------------------------------------------------------------------- @@ -111,20 +118,54 @@ CRagdollMagnet *CRagdollMagnet::FindBestMagnet( CBaseEntity *pNPC ) // // NOTE: This function assumes pNPC is within this magnet's radius. //----------------------------------------------------------------------------- +#ifdef MAPBASE +Vector CRagdollMagnet::GetForceVector( CBaseEntity *pNPC, int *pBone ) +#else Vector CRagdollMagnet::GetForceVector( CBaseEntity *pNPC ) +#endif { Vector vecForceToApply; +#ifdef MAPBASE + Vector vecNPCPos = pNPC->WorldSpaceCenter(); + + if (pBone) + { + CBaseAnimating *pAnimating = pNPC->GetBaseAnimating(); + Assert( pAniamting != NULL ); + + const char *szBoneTarget = BoneTarget(); + Assert( szBoneTarget != NULL ); + + int iBone = pAnimating->LookupBone( szBoneTarget ); + + if (iBone != -1) + { + matrix3x4_t bonetoworld; + pAnimating->GetBoneTransform( iBone, bonetoworld ); + MatrixPosition( bonetoworld, vecNPCPos ); + *pBone = iBone; + } + } +#endif + if( IsBarMagnet() ) { CPlane axis; Vector vecForceDir; Vector vecClosest; +#ifdef MAPBASE + CalcClosestPointOnLineSegment( vecNPCPos, GetAbsOrigin(), m_axis, vecClosest, NULL ); + + vecForceDir = (vecClosest - vecNPCPos ); + VectorNormalize( vecForceDir ); +#else CalcClosestPointOnLineSegment( pNPC->WorldSpaceCenter(), GetAbsOrigin(), m_axis, vecClosest, NULL ); vecForceDir = (vecClosest - pNPC->WorldSpaceCenter() ); VectorNormalize( vecForceDir ); +#endif vecForceToApply = vecForceDir * m_force; } @@ -132,7 +173,11 @@ Vector CRagdollMagnet::GetForceVector( CBaseEntity *pNPC ) { Vector vecForce; +#ifdef MAPBASE + vecForce = GetAbsOrigin() - vecNPCPos; +#else vecForce = GetAbsOrigin() - pNPC->WorldSpaceCenter(); +#endif VectorNormalize( vecForce ); vecForceToApply = vecForce * m_force; diff --git a/sp/src/game/server/CRagdollMagnet.h b/sp/src/game/server/CRagdollMagnet.h index b2211724..52d3f57d 100644 --- a/sp/src/game/server/CRagdollMagnet.h +++ b/sp/src/game/server/CRagdollMagnet.h @@ -18,7 +18,11 @@ public: DECLARE_CLASS( CRagdollMagnet, CPointEntity ); DECLARE_DATADESC(); +#ifdef MAPBASE + Vector GetForceVector( CBaseEntity *pNPC, int *pBone = NULL ); +#else Vector GetForceVector( CBaseEntity *pNPC ); +#endif float GetRadius( void ) { return m_radius; } Vector GetAxisVector( void ) { return m_axis - GetAbsOrigin(); } float DistToPoint( const Vector &vecPoint ); @@ -35,11 +39,20 @@ public: void InputEnable( inputdata_t &inputdata ); void InputDisable( inputdata_t &inputdata ); +#ifdef MAPBASE + const char *BoneTarget() { return STRING(m_BoneTarget); } + + COutputVector m_OnUsed; +#endif + private: bool m_bDisabled; float m_radius; float m_force; Vector m_axis; +#ifdef MAPBASE + string_t m_BoneTarget; +#endif }; #endif //CRAGDOLLMAGNET_H \ No newline at end of file diff --git a/sp/src/game/server/CommentarySystem.cpp b/sp/src/game/server/CommentarySystem.cpp index f846a029..4d010151 100644 --- a/sp/src/game/server/CommentarySystem.cpp +++ b/sp/src/game/server/CommentarySystem.cpp @@ -22,6 +22,9 @@ #include "gamestats.h" #include "ai_basenpc.h" #include "Sprite.h" +#ifdef MAPBASE +#include "mapbase/SystemConvarMod.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -42,6 +45,7 @@ enum teleport_stages_t TELEPORT_FADEIN, }; +#ifndef MAPBASE // This has been moved to mapbase/SystemConvarMod.h // Convar restoration save/restore #define MAX_MODIFIED_CONVAR_STRING 128 struct modifiedconvars_t @@ -52,6 +56,7 @@ struct modifiedconvars_t char pszCurrentValue[MAX_MODIFIED_CONVAR_STRING]; char pszOrgValue[MAX_MODIFIED_CONVAR_STRING]; }; +#endif bool g_bInCommentaryMode = false; bool IsInCommentaryMode( void ) @@ -663,6 +668,10 @@ public: Msg( "Commentary: Could not find commentary data file '%s'. \n", szFullName ); } +#ifdef MAPBASE // VDC Memory Leak Fixes + pkvFile->deleteThis(); +#endif + engine->LockNetworkStringTables( oldLock ); } @@ -821,11 +830,13 @@ BEGIN_DATADESC_NO_BASE( CCommentarySystem ) DEFINE_FIELD( m_iCommentaryNodeCount, FIELD_INTEGER ), END_DATADESC() +#ifndef MAPBASE // This has been moved to mapbase/SystemConvarMod.h BEGIN_SIMPLE_DATADESC( modifiedconvars_t ) DEFINE_ARRAY( pszConvar, FIELD_CHARACTER, MAX_MODIFIED_CONVAR_STRING ), DEFINE_ARRAY( pszCurrentValue, FIELD_CHARACTER, MAX_MODIFIED_CONVAR_STRING ), DEFINE_ARRAY( pszOrgValue, FIELD_CHARACTER, MAX_MODIFIED_CONVAR_STRING ), END_DATADESC() +#endif //----------------------------------------------------------------------------- diff --git a/sp/src/game/server/EnvBeam.cpp b/sp/src/game/server/EnvBeam.cpp index b4308811..dab78145 100644 --- a/sp/src/game/server/EnvBeam.cpp +++ b/sp/src/game/server/EnvBeam.cpp @@ -48,6 +48,11 @@ public: void InputTurnOff( inputdata_t &inputdata ); void InputToggle( inputdata_t &inputdata ); void InputStrikeOnce( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputAmplitude( inputdata_t &inputdata ); + void InputSetStartEntity( inputdata_t &inputdata ) { m_iszStartEntity = inputdata.value.StringID(); } + void InputSetEndEntity( inputdata_t &inputdata ) { m_iszEndEntity = inputdata.value.StringID(); } +#endif void TurnOn( void ); void TurnOff( void ); @@ -123,6 +128,11 @@ BEGIN_DATADESC( CEnvBeam ) DEFINE_INPUTFUNC( FIELD_VOID, "TurnOff", InputTurnOff ), DEFINE_INPUTFUNC( FIELD_VOID, "Toggle", InputToggle ), DEFINE_INPUTFUNC( FIELD_VOID, "StrikeOnce", InputStrikeOnce ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_FLOAT, "Amplitude", InputAmplitude ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetStartEntity", InputSetStartEntity ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetEndEntity", InputSetEndEntity ), +#endif DEFINE_OUTPUT( m_OnTouchedByEntity, "OnTouchedByEntity" ), @@ -287,6 +297,17 @@ void CEnvBeam::InputStrikeOnce( inputdata_t &inputdata ) } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Input handler for amplitude +//----------------------------------------------------------------------------- +void CEnvBeam::InputAmplitude( inputdata_t &inputdata ) +{ + m_noiseAmplitude = inputdata.value.Float(); +} +#endif + + //----------------------------------------------------------------------------- // Purpose: Turns the lightning on. If it is set for interval refiring, it will // begin doing so. If it is set to be continually on, it will do so. @@ -383,11 +404,53 @@ void CEnvBeam::Strike( void ) m_speed = clamp( (int) m_speed, 0, (int) MAX_BEAM_SCROLLSPEED ); +#ifdef MAPBASE + bool pointStart = IsStaticPointEntity( pStart ); + bool pointEnd = IsStaticPointEntity( pEnd ); +#else int pointStart = IsStaticPointEntity( pStart ); int pointEnd = IsStaticPointEntity( pEnd ); +#endif if ( pointStart || pointEnd ) { +#ifdef MAPBASE + if ( m_spawnflags & SF_BEAM_RING ) + { + te->BeamRing( filter, 0.0, + pStart->entindex(), + pEnd->entindex(), + m_spriteTexture, + 0, // No halo + m_frameStart, + (int)m_flFrameRate, + m_life, + m_boltWidth, + 0, // No spread + m_noiseAmplitude, + m_clrRender->r, m_clrRender->g, m_clrRender->b, m_clrRender->a, + m_speed ); + } + else + { + te->BeamEntPoint( filter, 0.0, + pStart->entindex(), + &pStart->GetAbsOrigin(), + pEnd->entindex(), + &pEnd->GetAbsOrigin(), + m_spriteTexture, + 0, // No halo + m_frameStart, + (int)m_flFrameRate, + m_life, + m_boltWidth, + m_boltWidth, // End width + 0, // No fade + m_noiseAmplitude, + m_clrRender->r, m_clrRender->g, m_clrRender->b, m_clrRender->a, + m_speed ); + } +#else if ( m_spawnflags & SF_BEAM_RING ) { // don't work @@ -410,6 +473,7 @@ void CEnvBeam::Strike( void ) m_noiseAmplitude, m_clrRender->r, m_clrRender->g, m_clrRender->b, m_clrRender->a, m_speed ); +#endif } else { diff --git a/sp/src/game/server/EnvFade.cpp b/sp/src/game/server/EnvFade.cpp index fa0185d5..8b6c58f2 100644 --- a/sp/src/game/server/EnvFade.cpp +++ b/sp/src/game/server/EnvFade.cpp @@ -58,6 +58,9 @@ END_DATADESC() #define SF_FADE_MODULATE 0x0002 // Modulate, don't blend #define SF_FADE_ONLYONE 0x0004 #define SF_FADE_STAYOUT 0x0008 +#ifdef MAPBASE +#define SF_FADE_DONT_PURGE 0x0016 +#endif //----------------------------------------------------------------------------- // Purpose: @@ -93,6 +96,13 @@ void CEnvFade::InputFade( inputdata_t &inputdata ) fadeFlags |= FFADE_STAYOUT; } +#ifdef MAPBASE + if ( !HasSpawnFlags(SF_FADE_DONT_PURGE) ) + { + fadeFlags |= FFADE_PURGE; + } +#endif + if ( m_spawnflags & SF_FADE_ONLYONE ) { if ( inputdata.pActivator && inputdata.pActivator->IsNetClient() ) @@ -102,7 +112,11 @@ void CEnvFade::InputFade( inputdata_t &inputdata ) } else { +#ifdef MAPBASE + UTIL_ScreenFadeAll( m_clrRender, Duration(), HoldTime(), fadeFlags ); +#else UTIL_ScreenFadeAll( m_clrRender, Duration(), HoldTime(), fadeFlags|FFADE_PURGE ); +#endif } m_OnBeginFade.FireOutput( inputdata.pActivator, this ); diff --git a/sp/src/game/server/EnvHudHint.cpp b/sp/src/game/server/EnvHudHint.cpp index 858fc7b9..2cb38eab 100644 --- a/sp/src/game/server/EnvHudHint.cpp +++ b/sp/src/game/server/EnvHudHint.cpp @@ -32,6 +32,9 @@ private: void InputShowHudHint( inputdata_t &inputdata ); void InputHideHudHint( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetHudHint( inputdata_t &inputdata ); +#endif string_t m_iszMessage; DECLARE_DATADESC(); }; @@ -43,6 +46,9 @@ BEGIN_DATADESC( CEnvHudHint ) DEFINE_KEYFIELD( m_iszMessage, FIELD_STRING, "message" ), DEFINE_INPUTFUNC( FIELD_VOID, "ShowHudHint", InputShowHudHint ), DEFINE_INPUTFUNC( FIELD_VOID, "HideHudHint", InputHideHudHint ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_STRING, "SetHudHint", InputSetHudHint ), +#endif END_DATADESC() @@ -140,3 +146,12 @@ void CEnvHudHint::InputHideHudHint( inputdata_t &inputdata ) MessageEnd(); } } + +#ifdef MAPBASE +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CEnvHudHint::InputSetHudHint( inputdata_t &inputdata ) +{ + m_iszMessage = inputdata.value.StringID(); +} +#endif diff --git a/sp/src/game/server/EnvLaser.cpp b/sp/src/game/server/EnvLaser.cpp index 0e603db6..3db94e7c 100644 --- a/sp/src/game/server/EnvLaser.cpp +++ b/sp/src/game/server/EnvLaser.cpp @@ -31,6 +31,10 @@ BEGIN_DATADESC( CEnvLaser ) DEFINE_INPUTFUNC( FIELD_VOID, "TurnOff", InputTurnOff ), DEFINE_INPUTFUNC( FIELD_VOID, "Toggle", InputToggle ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OnTouchedByEntity, "OnTouchedByEntity" ), +#endif + END_DATADESC() @@ -221,6 +225,12 @@ void CEnvLaser::FireAtPoint( trace_t &tr ) // Apply damage and do sparks every 1/10th of a second. if ( gpGlobals->curtime >= m_flFireTime + 0.1 ) { +#ifdef MAPBASE + if ( tr.fraction != 1.0 && tr.m_pEnt && !tr.m_pEnt->IsWorld() ) + { + m_OnTouchedByEntity.FireOutput( tr.m_pEnt, this ); + } +#endif BeamDamage( &tr ); DoSparks( GetAbsStartPos(), tr.endpos ); } diff --git a/sp/src/game/server/EnvLaser.h b/sp/src/game/server/EnvLaser.h index 79165042..fc740442 100644 --- a/sp/src/game/server/EnvLaser.h +++ b/sp/src/game/server/EnvLaser.h @@ -37,6 +37,9 @@ public: void InputTurnOn( inputdata_t &inputdata ); void InputTurnOff( inputdata_t &inputdata ); void InputToggle( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetTarget( inputdata_t &inputdata ) { m_iszLaserTarget = inputdata.value.StringID(); } +#endif DECLARE_DATADESC(); @@ -45,6 +48,10 @@ public: string_t m_iszSpriteName; Vector m_firePosition; +#ifdef MAPBASE + COutputEvent m_OnTouchedByEntity; +#endif + float m_flStartFrame; }; diff --git a/sp/src/game/server/EnvMessage.cpp b/sp/src/game/server/EnvMessage.cpp index a22dfc11..3f47c2ea 100644 --- a/sp/src/game/server/EnvMessage.cpp +++ b/sp/src/game/server/EnvMessage.cpp @@ -168,6 +168,11 @@ private: bool m_bRolledOutroCredits; float m_flLogoLength; + +#ifdef MAPBASE + // Custom credits.txt, defaults to that + string_t m_iszCreditsFile; +#endif }; LINK_ENTITY_TO_CLASS( env_credits, CCredits ); @@ -179,6 +184,10 @@ BEGIN_DATADESC( CCredits ) DEFINE_INPUTFUNC( FIELD_FLOAT, "SetLogoLength", InputSetLogoLength ), DEFINE_OUTPUT( m_OnCreditsDone, "OnCreditsDone"), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_iszCreditsFile, FIELD_STRING, "CreditsFile" ), +#endif + DEFINE_FIELD( m_bRolledOutroCredits, FIELD_BOOLEAN ), DEFINE_FIELD( m_flLogoLength, FIELD_FLOAT ) END_DATADESC() @@ -226,6 +235,9 @@ void CCredits::RollOutroCredits() UserMessageBegin( user, "CreditsMsg" ); WRITE_BYTE( 3 ); +#ifdef MAPBASE + WRITE_STRING( STRING(m_iszCreditsFile) ); +#endif MessageEnd(); } @@ -250,12 +262,18 @@ void CCredits::InputShowLogo( inputdata_t &inputdata ) { UserMessageBegin( user, "LogoTimeMsg" ); WRITE_FLOAT( m_flLogoLength ); +#ifdef MAPBASE + WRITE_STRING( STRING(m_iszCreditsFile) ); +#endif MessageEnd(); } else { UserMessageBegin( user, "CreditsMsg" ); WRITE_BYTE( 1 ); +#ifdef MAPBASE + WRITE_STRING( STRING(m_iszCreditsFile) ); +#endif MessageEnd(); } } @@ -274,5 +292,8 @@ void CCredits::InputRollCredits( inputdata_t &inputdata ) UserMessageBegin( user, "CreditsMsg" ); WRITE_BYTE( 2 ); +#ifdef MAPBASE + WRITE_STRING( STRING(m_iszCreditsFile) ); +#endif MessageEnd(); } diff --git a/sp/src/game/server/RagdollBoogie.cpp b/sp/src/game/server/RagdollBoogie.cpp index 6344b74a..9233872e 100644 --- a/sp/src/game/server/RagdollBoogie.cpp +++ b/sp/src/game/server/RagdollBoogie.cpp @@ -15,6 +15,9 @@ #include "effect_dispatch_data.h" #include "te_effect_dispatch.h" #include "IEffects.h" +#ifdef MAPBASE +#include "saverestore_utlvector.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -266,3 +269,137 @@ void CRagdollBoogie::BoogieThink( void ) SetNextThink( gpGlobals->curtime + random->RandomFloat( 0.1, 0.2f ) ); } + +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Allows mappers to control ragdoll dancing +//----------------------------------------------------------------------------- +class CPointRagdollBoogie : public CBaseEntity +{ + DECLARE_DATADESC(); + DECLARE_CLASS( CPointRagdollBoogie, CBaseEntity ); + +public: + bool ApplyBoogie(CBaseEntity *pTarget, CBaseEntity *pActivator); + + void InputActivate( inputdata_t &inputdata ); + void InputDeactivate( inputdata_t &inputdata ); + void InputBoogieTarget( inputdata_t &inputdata ); + +private: + float m_flStartTime; + float m_flBoogieLength; + float m_flMagnitude; + + // This allows us to remove active boogies later. + CUtlVector m_Boogies; +}; + +//----------------------------------------------------------------------------- +// Save/load +//----------------------------------------------------------------------------- +BEGIN_DATADESC( CPointRagdollBoogie ) + + DEFINE_KEYFIELD( m_flStartTime, FIELD_FLOAT, "StartTime" ), + DEFINE_KEYFIELD( m_flBoogieLength, FIELD_FLOAT, "BoogieLength" ), + DEFINE_KEYFIELD( m_flMagnitude, FIELD_FLOAT, "Magnitude" ), + + // Think this should be handled by StartTouch/etc. +// DEFINE_FIELD( m_nSuppressionCount, FIELD_INTEGER ), + + DEFINE_UTLVECTOR( m_Boogies, FIELD_EHANDLE ), + + // Inputs + DEFINE_INPUTFUNC( FIELD_VOID, "Activate", InputActivate ), + DEFINE_INPUTFUNC( FIELD_VOID, "Deactivate", InputDeactivate ), + DEFINE_INPUTFUNC( FIELD_STRING, "BoogieTarget", InputBoogieTarget ), + +END_DATADESC() + +LINK_ENTITY_TO_CLASS( point_ragdollboogie, CPointRagdollBoogie ); + +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +bool CPointRagdollBoogie::ApplyBoogie( CBaseEntity *pTarget, CBaseEntity *pActivator ) +{ + if (dynamic_cast(pTarget)) + { + m_Boogies.AddToTail(CRagdollBoogie::Create(pTarget, m_flMagnitude, gpGlobals->curtime + m_flStartTime, m_flBoogieLength, GetSpawnFlags())); + } + else if (pTarget->MyCombatCharacterPointer()) + { + // Basically CBaseCombatCharacter::BecomeRagdollBoogie(), but adjusted to our needs + CTakeDamageInfo info(this, pActivator, 1.0f, DMG_GENERIC); + + CBaseEntity *pRagdoll = CreateServerRagdoll(pTarget->MyCombatCharacterPointer(), 0, info, COLLISION_GROUP_INTERACTIVE_DEBRIS, true); + + pRagdoll->SetCollisionBounds(CollisionProp()->OBBMins(), CollisionProp()->OBBMaxs()); + + m_Boogies.AddToTail(CRagdollBoogie::Create(pRagdoll, m_flMagnitude, gpGlobals->curtime + m_flStartTime, m_flBoogieLength, GetSpawnFlags())); + + CTakeDamageInfo ragdollInfo(this, pActivator, 10000.0, DMG_GENERIC | DMG_REMOVENORAGDOLL); + ragdollInfo.SetDamagePosition(WorldSpaceCenter()); + ragdollInfo.SetDamageForce(Vector(0, 0, 1)); + ragdollInfo.SetForceFriendlyFire(true); + pTarget->TakeDamage(ragdollInfo); + } + else + { + return false; + } + + return true; +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CPointRagdollBoogie::InputActivate( inputdata_t &inputdata ) +{ + CBaseEntity *pEnt = gEntList.FindEntityByName(NULL, STRING(m_target), this, inputdata.pActivator, inputdata.pCaller); + while (pEnt) + { + ApplyBoogie(pEnt, inputdata.pActivator); + + pEnt = gEntList.FindEntityByName(pEnt, STRING(m_target), this, inputdata.pActivator, inputdata.pCaller); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CPointRagdollBoogie::InputDeactivate( inputdata_t &inputdata ) +{ + if (m_Boogies.Count() == 0) + return; + + for (int i = 0; i < m_Boogies.Count(); i++) + { + UTIL_Remove(m_Boogies[i]); + } + + //m_Boogies.RemoveAll(); +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CPointRagdollBoogie::InputBoogieTarget( inputdata_t &inputdata ) +{ + CBaseEntity *pEnt = gEntList.FindEntityByName(NULL, inputdata.value.String(), this, inputdata.pActivator, inputdata.pCaller); + while (pEnt) + { + if (!ApplyBoogie(pEnt, inputdata.pActivator)) + { + Warning("%s was unable to apply ragdoll boogie to %s, classname %s.\n", GetDebugName(), pEnt->GetDebugName(), pEnt->GetClassname()); + } + + pEnt = gEntList.FindEntityByName(pEnt, inputdata.value.String(), this, inputdata.pActivator, inputdata.pCaller); + } +} +#endif diff --git a/sp/src/game/server/SkyCamera.cpp b/sp/src/game/server/SkyCamera.cpp index 294c9c25..5dc7df57 100644 --- a/sp/src/game/server/SkyCamera.cpp +++ b/sp/src/game/server/SkyCamera.cpp @@ -15,13 +15,24 @@ // automatically hooks in the system's callbacks CEntityClassList g_SkyList; template <> CSkyCamera *CEntityClassList::m_pClassList = NULL; +#ifdef MAPBASE +CHandle g_hActiveSkybox = NULL; +#endif //----------------------------------------------------------------------------- // Retrives the current skycamera //----------------------------------------------------------------------------- CSkyCamera* GetCurrentSkyCamera() { +#ifdef MAPBASE + if ( g_hActiveSkybox.Get() == NULL ) + { + g_hActiveSkybox = GetSkyCameraList(); + } + return g_hActiveSkybox.Get(); +#else return g_SkyList.m_pClassList; +#endif } CSkyCamera* GetSkyCameraList() @@ -38,6 +49,10 @@ BEGIN_DATADESC( CSkyCamera ) DEFINE_KEYFIELD( m_skyboxData.scale, FIELD_INTEGER, "scale" ), DEFINE_FIELD( m_skyboxData.origin, FIELD_VECTOR ), DEFINE_FIELD( m_skyboxData.area, FIELD_INTEGER ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_skyboxData.skycolor, FIELD_COLOR32, "skycolor" ), + DEFINE_KEYFIELD( m_bUseAnglesForSky, FIELD_BOOLEAN, "use_angles_for_sky" ), +#endif // Quiet down classcheck // DEFINE_FIELD( m_skyboxData, sky3dparams_t ), @@ -55,6 +70,32 @@ BEGIN_DATADESC( CSkyCamera ) DEFINE_KEYFIELD( m_skyboxData.fog.start, FIELD_FLOAT, "fogstart" ), DEFINE_KEYFIELD( m_skyboxData.fog.end, FIELD_FLOAT, "fogend" ), DEFINE_KEYFIELD( m_skyboxData.fog.maxdensity, FIELD_FLOAT, "fogmaxdensity" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_skyboxData.fog.farz, FIELD_FLOAT, "farz" ), +#endif + +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "ForceUpdate", InputForceUpdate ), + DEFINE_INPUTFUNC( FIELD_VOID, "StartUpdating", InputStartUpdating ), + DEFINE_INPUTFUNC( FIELD_VOID, "StopUpdating", InputStopUpdating ), + + DEFINE_INPUTFUNC( FIELD_VOID, "ActivateSkybox", InputActivateSkybox ), + DEFINE_INPUTFUNC( FIELD_VOID, "DeactivateSkybox", InputDeactivateSkybox ), + + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetFogStartDist", InputSetFogStartDist ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetFogEndDist", InputSetFogEndDist ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetFogMaxDensity", InputSetFogMaxDensity ), + DEFINE_INPUTFUNC( FIELD_VOID, "TurnOnFog", InputTurnOnFog ), + DEFINE_INPUTFUNC( FIELD_VOID, "TurnOffFog", InputTurnOffFog ), + DEFINE_INPUTFUNC( FIELD_COLOR32, "SetFogColor", InputSetFogColor ), + DEFINE_INPUTFUNC( FIELD_COLOR32, "SetFogColorSecondary", InputSetFogColorSecondary ), + + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetFarZ", InputSetFarZ ), + + DEFINE_INPUTFUNC( FIELD_COLOR32, "SetSkyColor", InputSetSkyColor ), + + DEFINE_THINKFUNC( Update ), +#endif END_DATADESC() @@ -93,6 +134,9 @@ CSkyCamera::CSkyCamera() { g_SkyList.Insert( this ); m_skyboxData.fog.maxdensity = 1.0f; +#ifdef MAPBASE + m_skyboxData.skycolor.Init(0, 0, 0, 0); +#endif } CSkyCamera::~CSkyCamera() @@ -102,7 +146,23 @@ CSkyCamera::~CSkyCamera() void CSkyCamera::Spawn( void ) { +#ifdef MAPBASE + if (HasSpawnFlags(SF_SKY_MASTER)) + g_hActiveSkybox = this; + + if (HasSpawnFlags(SF_SKY_START_UPDATING) && GetCurrentSkyCamera() == this) + { + SetThink( &CSkyCamera::Update ); + SetNextThink( gpGlobals->curtime + TICK_INTERVAL ); + } + + // Must be absolute now that the sky_camera can be parented + m_skyboxData.origin = GetAbsOrigin(); + if (m_bUseAnglesForSky) + m_skyboxData.angles = GetAbsAngles(); +#else m_skyboxData.origin = GetLocalOrigin(); +#endif m_skyboxData.area = engine->GetArea( m_skyboxData.origin ); Precache(); @@ -145,3 +205,152 @@ void CSkyCamera::Activate( ) } #endif } + +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CSkyCamera::AcceptInput( const char *szInputName, CBaseEntity *pActivator, CBaseEntity *pCaller, variant_t Value, int outputID ) +{ + if (!BaseClass::AcceptInput( szInputName, pActivator, pCaller, Value, outputID )) + return false; + + if (g_hActiveSkybox == this) + { + // Most inputs require an update + Update(); + } + + return true; +} + +//----------------------------------------------------------------------------- +// Purpose: Update sky position mid-game +//----------------------------------------------------------------------------- +void CSkyCamera::Update() +{ + m_skyboxData.origin = GetAbsOrigin(); + if (m_bUseAnglesForSky) + m_skyboxData.angles = GetAbsAngles(); + + // Getting into another area is unlikely, but if it's not expensive, I guess it's okay. + m_skyboxData.area = engine->GetArea( m_skyboxData.origin ); + + if ( m_bUseAngles ) + { + AngleVectors( GetAbsAngles(), &m_skyboxData.fog.dirPrimary.GetForModify() ); + m_skyboxData.fog.dirPrimary.GetForModify() *= -1.0f; + } + +#ifdef MAPBASE_MP + // Updates client data, this completely ignores m_pOldSkyCamera + CBasePlayer *pPlayer = NULL; + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + pPlayer = UTIL_PlayerByIndex(i); + if (pPlayer) + pPlayer->m_Local.m_skybox3d.CopyFrom(m_skyboxData); + } +#else + // Updates client data, this completely ignores m_pOldSkyCamera + CBasePlayer *pPlayer = UTIL_PlayerByIndex(1); + if (pPlayer) + { + pPlayer->m_Local.m_skybox3d.CopyFrom(m_skyboxData); + } +#endif + + SetNextThink( gpGlobals->curtime + TICK_INTERVAL ); +} + +void CSkyCamera::InputForceUpdate( inputdata_t &inputdata ) +{ + Update(); + + // Updates client data, this completely ignores m_pOldSkyCamera + CBasePlayer *pPlayer = NULL; + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + pPlayer = UTIL_PlayerByIndex( i ); + if (pPlayer) + pPlayer->m_Local.m_skybox3d.CopyFrom( m_skyboxData ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CSkyCamera::InputStartUpdating( inputdata_t &inputdata ) +{ + if (GetCurrentSkyCamera() == this) + { + SetThink( &CSkyCamera::Update ); + SetNextThink( gpGlobals->curtime + TICK_INTERVAL ); + } + + // If we become the current sky camera later, remember that we want to update + AddSpawnFlags( SF_SKY_START_UPDATING ); +} + +void CSkyCamera::InputStopUpdating( inputdata_t &inputdata ) +{ + SetThink( NULL ); + SetNextThink( TICK_NEVER_THINK ); + RemoveSpawnFlags( SF_SKY_START_UPDATING ); +} + +//----------------------------------------------------------------------------- +// Activate! +//----------------------------------------------------------------------------- +void CSkyCamera::InputActivateSkybox( inputdata_t &inputdata ) +{ + CSkyCamera *pActiveSky = GetCurrentSkyCamera(); + if (pActiveSky && pActiveSky->GetNextThink() != TICK_NEVER_THINK && pActiveSky != this) + { + // Deactivate that skybox + pActiveSky->SetThink( NULL ); + pActiveSky->SetNextThink( TICK_NEVER_THINK ); + } + + g_hActiveSkybox = this; + + if (HasSpawnFlags( SF_SKY_START_UPDATING )) + InputStartUpdating( inputdata ); +} + +//----------------------------------------------------------------------------- +// Deactivate! +//----------------------------------------------------------------------------- +void CSkyCamera::InputDeactivateSkybox( inputdata_t &inputdata ) +{ + if (GetCurrentSkyCamera() == this) + { + g_hActiveSkybox = NULL; + + // ClientData doesn't catch this immediately + CBasePlayer *pPlayer = NULL; + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + pPlayer = UTIL_PlayerByIndex( i ); + if (pPlayer) + pPlayer->m_Local.m_skybox3d.area = 255; + } + } + + SetThink( NULL ); + SetNextThink( TICK_NEVER_THINK ); +} + +//------------------------------------------------------------------------------ +// Purpose: Input handlers for setting fog stuff. +//------------------------------------------------------------------------------ +void CSkyCamera::InputSetFogStartDist( inputdata_t &inputdata ) { m_skyboxData.fog.start = inputdata.value.Float(); } +void CSkyCamera::InputSetFogEndDist( inputdata_t &inputdata ) { m_skyboxData.fog.end = inputdata.value.Float(); } +void CSkyCamera::InputSetFogMaxDensity( inputdata_t &inputdata ) { m_skyboxData.fog.maxdensity = inputdata.value.Float(); } +void CSkyCamera::InputTurnOnFog( inputdata_t &inputdata ) { m_skyboxData.fog.enable = true; } +void CSkyCamera::InputTurnOffFog( inputdata_t &inputdata ) { m_skyboxData.fog.enable = false; } +void CSkyCamera::InputSetFogColor( inputdata_t &inputdata ) { m_skyboxData.fog.colorPrimary = inputdata.value.Color32(); } +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(); } +#endif diff --git a/sp/src/game/server/SkyCamera.h b/sp/src/game/server/SkyCamera.h index 8032d8fd..b7393527 100644 --- a/sp/src/game/server/SkyCamera.h +++ b/sp/src/game/server/SkyCamera.h @@ -14,13 +14,30 @@ class CSkyCamera; +#ifdef MAPBASE +#define SF_SKY_MASTER (1 << 0) +#define SF_SKY_START_UPDATING (1 << 1) + +//============================================================================= +// +// Sky Camera Class +// Now derived directly from CBaseEntity for parenting and angles! (please don't break anything) +// +//============================================================================= +class CSkyCamera : public CBaseEntity +#else //============================================================================= // // Sky Camera Class // class CSkyCamera : public CLogicalEntity +#endif { +#ifdef MAPBASE + DECLARE_CLASS( CSkyCamera, CBaseEntity ); +#else DECLARE_CLASS( CSkyCamera, CLogicalEntity ); +#endif public: @@ -30,9 +47,37 @@ public: virtual void Spawn( void ); virtual void Activate(); +#ifdef MAPBASE + bool AcceptInput( const char *szInputName, CBaseEntity *pActivator, CBaseEntity *pCaller, variant_t Value, int outputID ); + + void Update(); + void InputForceUpdate( inputdata_t &inputdata ); + void InputStartUpdating( inputdata_t &inputdata ); + void InputStopUpdating( inputdata_t &inputdata ); + + void InputActivateSkybox( inputdata_t &inputdata ); + void InputDeactivateSkybox( inputdata_t &inputdata ); + + void InputSetFogStartDist( inputdata_t &data ); + void InputSetFogEndDist( inputdata_t &data ); + void InputTurnOnFog( inputdata_t &data ); + void InputTurnOffFog( inputdata_t &data ); + void InputSetFogColor( inputdata_t &data ); + void InputSetFogColorSecondary( inputdata_t &data ); + void InputSetFogMaxDensity( inputdata_t &inputdata ); + + void InputSetFarZ( inputdata_t &data ); + + void InputSetSkyColor( inputdata_t &inputdata ) { m_skyboxData.skycolor = inputdata.value.Color32(); } +#endif + public: sky3dparams_t m_skyboxData; bool m_bUseAngles; +#ifdef MAPBASE + // Uses angles for actual skybox + bool m_bUseAnglesForSky; +#endif CSkyCamera *m_pNext; }; diff --git a/sp/src/game/server/ai_activity.cpp b/sp/src/game/server/ai_activity.cpp index a476a9f3..ca0c63e3 100644 --- a/sp/src/game/server/ai_activity.cpp +++ b/sp/src/game/server/ai_activity.cpp @@ -157,6 +157,10 @@ void CAI_BaseNPC::InitDefaultActivitySR(void) ADD_ACTIVITY_TO_SR( ACT_RELOAD_LOW ); ADD_ACTIVITY_TO_SR( ACT_ARM ); ADD_ACTIVITY_TO_SR( ACT_DISARM ); +#ifdef COMPANION_HOLSTER_WORKAROUND + ADD_ACTIVITY_TO_SR( ACT_ARM_RIFLE ); + ADD_ACTIVITY_TO_SR( ACT_DISARM_RIFLE ); +#endif ADD_ACTIVITY_TO_SR( ACT_DROP_WEAPON ); ADD_ACTIVITY_TO_SR( ACT_DROP_WEAPON_SHOTGUN ); ADD_ACTIVITY_TO_SR( ACT_PICKUP_GROUND ); @@ -396,6 +400,11 @@ void CAI_BaseNPC::InitDefaultActivitySR(void) ADD_ACTIVITY_TO_SR( ACT_SMG2_TOAUTO ); ADD_ACTIVITY_TO_SR( ACT_SMG2_TOBURST ); +#ifdef SHARED_COMBINE_ACTIVITIES + ADD_ACTIVITY_TO_SR( ACT_COMBINE_THROW_GRENADE ); + ADD_ACTIVITY_TO_SR( ACT_COMBINE_AR2_ALTFIRE ); +#endif + // Physcannon special activities ADD_ACTIVITY_TO_SR( ACT_PHYSCANNON_UPGRADE ); @@ -447,6 +456,10 @@ void CAI_BaseNPC::InitDefaultActivitySR(void) ADD_ACTIVITY_TO_SR( ACT_IDLE_RIFLE ); ADD_ACTIVITY_TO_SR( ACT_IDLE_SMG1 ); ADD_ACTIVITY_TO_SR( ACT_IDLE_ANGRY_SMG1 ); +#if AR2_ACTIVITY_FIX == 1 + ADD_ACTIVITY_TO_SR( ACT_IDLE_AR2 ); + ADD_ACTIVITY_TO_SR( ACT_IDLE_ANGRY_AR2 ); +#endif ADD_ACTIVITY_TO_SR( ACT_IDLE_PISTOL ); ADD_ACTIVITY_TO_SR( ACT_IDLE_ANGRY_PISTOL ); ADD_ACTIVITY_TO_SR( ACT_IDLE_ANGRY_SHOTGUN ); @@ -465,10 +478,26 @@ void CAI_BaseNPC::InitDefaultActivitySR(void) ADD_ACTIVITY_TO_SR( ACT_WALK_RIFLE_STIMULATED ); ADD_ACTIVITY_TO_SR( ACT_RUN_RIFLE_STIMULATED ); +#if AR2_ACTIVITY_FIX == 1 + ADD_ACTIVITY_TO_SR( ACT_IDLE_AR2_RELAXED ); + ADD_ACTIVITY_TO_SR( ACT_IDLE_AR2_STIMULATED ); + + ADD_ACTIVITY_TO_SR( ACT_WALK_AR2_RELAXED ); + ADD_ACTIVITY_TO_SR( ACT_RUN_AR2_RELAXED ); + ADD_ACTIVITY_TO_SR( ACT_WALK_AR2_STIMULATED ); + ADD_ACTIVITY_TO_SR( ACT_RUN_AR2_STIMULATED ); +#endif + ADD_ACTIVITY_TO_SR( ACT_IDLE_AIM_RIFLE_STIMULATED ); ADD_ACTIVITY_TO_SR( ACT_WALK_AIM_RIFLE_STIMULATED ); ADD_ACTIVITY_TO_SR( ACT_RUN_AIM_RIFLE_STIMULATED ); +#if AR2_ACTIVITY_FIX == 1 + ADD_ACTIVITY_TO_SR( ACT_IDLE_AIM_AR2_STIMULATED ); + ADD_ACTIVITY_TO_SR( ACT_WALK_AIM_AR2_STIMULATED ); + ADD_ACTIVITY_TO_SR( ACT_RUN_AIM_AR2_STIMULATED ); +#endif + ADD_ACTIVITY_TO_SR( ACT_IDLE_SHOTGUN_RELAXED ); ADD_ACTIVITY_TO_SR( ACT_IDLE_SHOTGUN_STIMULATED ); ADD_ACTIVITY_TO_SR( ACT_IDLE_SHOTGUN_AGITATED ); @@ -518,6 +547,13 @@ void CAI_BaseNPC::InitDefaultActivitySR(void) ADD_ACTIVITY_TO_SR( ACT_WALK_AIM_STEALTH_PISTOL ); ADD_ACTIVITY_TO_SR( ACT_RUN_AIM_STEALTH_PISTOL ); +#if AR2_ACTIVITY_FIX == 1 + ADD_ACTIVITY_TO_SR( ACT_WALK_AR2 ); + ADD_ACTIVITY_TO_SR( ACT_WALK_AIM_AR2 ); + ADD_ACTIVITY_TO_SR( ACT_RUN_AR2 ); + ADD_ACTIVITY_TO_SR( ACT_RUN_AIM_AR2 ); +#endif + ADD_ACTIVITY_TO_SR( ACT_RELOAD_PISTOL ); ADD_ACTIVITY_TO_SR( ACT_RELOAD_PISTOL_LOW ); ADD_ACTIVITY_TO_SR( ACT_RELOAD_SMG1 ); diff --git a/sp/src/game/server/ai_baseactor.cpp b/sp/src/game/server/ai_baseactor.cpp index e9814967..30382ab7 100644 --- a/sp/src/game/server/ai_baseactor.cpp +++ b/sp/src/game/server/ai_baseactor.cpp @@ -230,6 +230,13 @@ void CAI_BaseActor::SetModel( const char *szModelName ) // Purpose: //----------------------------------------------------------------------------- +#ifdef MAPBASE +// Half-Laugh had a nasty way of implementing CSceneEntity into StartSceneEvent and I'm both afraid to do it here +// and I don't remember exactly how I did it. This is extremely important because +// it's the only way we can access !target1, !target2, etc. Please revisit this later. +#define STARTSCENEEVENT_HAS_CSCENEENTITY 0 +#endif + bool CAI_BaseActor::StartSceneEvent( CSceneEventInfo *info, CChoreoScene *scene, CChoreoEvent *event, CChoreoActor *actor, CBaseEntity *pTarget ) { Assert( info ); @@ -314,6 +321,116 @@ bool CAI_BaseActor::StartSceneEvent( CSceneEventInfo *info, CChoreoScene *scene, { info->m_nType = SCENE_AI_DISABLEAI; } +#ifdef MAPBASE + else if (stricmp(event->GetParameters(), "AI_ADDCONTEXT") == 0) + { + // Adds a response context to the caller in place of the target field. + // This is supposed to be used with the talker system. + if (event->GetParameters2()) + { + info->m_nType = SCENE_AI_ADDCONTEXT; + AddContext(event->GetParameters2()); + return true; + } + } + else if (stricmp(event->GetParameters(), "AI_INPUT") == 0) + { + // Fires an input on an entity in place of the target field. + // This is supposed to be used with the talker system. + if (event->GetParameters2()) + { + info->m_nType = SCENE_AI_INPUT; + + const char *raw = event->GetParameters2(); + char sTarget[128]; + char sInput[128]; + char sParameter[128]; + char *colon1 = Q_strstr( raw, ":" ); + if (!colon1) + { + Warning("%s (%s) AI_INPUT missing colon separator!\n", GetClassname(), GetDebugName()); + return false; + } + + int len = colon1 - raw; + Q_strncpy( sTarget, raw, MIN( len + 1, sizeof(sTarget) ) ); + sTarget[MIN(len, sizeof(sTarget) - 1)] = 0; + + bool bParameter = true; + char *colon2 = Q_strstr(colon1 + 1, ":"); + if (!colon2) + { + DevMsg("Assuming no parameter\n"); + colon2 = colon1 + 1; + bParameter = false; + } + + if (bParameter) + { + len = MIN(colon2 - (colon1 + 1), sizeof(sInput) - 1); + Q_strncpy(sInput, colon1 + 1, MIN(len + 1, sizeof(sInput))); + sInput[MIN(len, sizeof(sInput) - 1)] = 0; + + Q_strncpy(sParameter, colon2 + 1, sizeof(sInput)); + } + else + { + len = colon2 - raw; + Q_strncpy(sInput, colon2, sizeof(sInput)); + } + + CBaseEntity *pEnt = gEntList.FindEntityByName(NULL, sTarget, this); + if (!pEnt) + { +#if STARTSCENEEVENT_HAS_CSCENEENTITY + DevMsg("%s not found with normal search, slamming to scene ent\n", sTarget); + pEnt = UTIL_FindNamedSceneEntity(sTarget, this, csceneent); + if (!pEnt) + { + DevWarning("%s slammed to self!\n", sTarget); + pEnt = this; + } +#else + DevWarning("%s slammed to self!\n", sTarget); + pEnt = this; +#endif + } + + if (pEnt && sInput) + { + variant_t variant; + if (bParameter && sParameter) + { + const char *strParam = sParameter; +#if STARTSCENEEVENT_HAS_CSCENEENTITY + if (strParam[0] == '!') + { + CBaseEntity *pParamEnt = UTIL_FindNamedSceneEntity(strParam, this, csceneent); + if (pParamEnt && pParamEnt->GetEntityName() != NULL_STRING && !gEntList.FindEntityProcedural(strParam)) + { + // We make sure it's a scene entity that can't be found with entlist procedural so we can translate !target# without messing with !activators, etc. + //const char *newname = pParamEnt->GetEntityName().ToCStr(); + strParam = pParamEnt->GetEntityName().ToCStr(); + } + } +#endif + + if (strParam) + { + variant.SetString(MAKE_STRING(strParam)); + } + } + + pEnt->AcceptInput(sInput, this, this, variant, 0); + return true; + } + else + { + Warning("%s (%s) AI_INPUT cannot find entity %s!\n", GetClassname(), GetDebugName(), sTarget); + } + } + } +#endif else { return BaseClass::StartSceneEvent( info, scene, event, actor, pTarget ); @@ -508,6 +625,11 @@ bool CAI_BaseActor::ProcessSceneEvent( CSceneEventInfo *info, CChoreoScene *scen Vector vecAimTargetLoc = info->m_hTarget->EyePosition(); Vector vecAimDir = vecAimTargetLoc - EyePosition(); +#ifdef MAPBASE + // Mind the ramp + vecAimDir *= event->GetIntensity(scene->GetTime()); +#endif + VectorNormalize( vecAimDir ); SetAim( vecAimDir); } @@ -548,6 +670,16 @@ bool CAI_BaseActor::ProcessSceneEvent( CSceneEventInfo *info, CChoreoScene *scen EnterSceneSequence( scene, event ); } return true; +#ifdef MAPBASE + case SCENE_AI_ADDCONTEXT: + { + } + return true; + case SCENE_AI_INPUT: + { + } + return true; +#endif default: return false; } diff --git a/sp/src/game/server/ai_baseactor.h b/sp/src/game/server/ai_baseactor.h index 49caea53..87d10f50 100644 --- a/sp/src/game/server/ai_baseactor.h +++ b/sp/src/game/server/ai_baseactor.h @@ -177,6 +177,11 @@ public: SCENE_AI_RANDOMHEADFLEX, SCENE_AI_IGNORECOLLISION, SCENE_AI_DISABLEAI +#ifdef MAPBASE + , + SCENE_AI_ADDCONTEXT, + SCENE_AI_INPUT, +#endif }; diff --git a/sp/src/game/server/ai_basenpc.cpp b/sp/src/game/server/ai_basenpc.cpp index 1db9eab1..8c97a097 100644 --- a/sp/src/game/server/ai_basenpc.cpp +++ b/sp/src/game/server/ai_basenpc.cpp @@ -95,6 +95,10 @@ #include "prop_portal_shared.h" #endif +#ifdef MAPBASE +#include "mapbase/matchers.h" +#endif + #include "env_debughistory.h" #include "collisionutils.h" @@ -156,6 +160,12 @@ ConVar ai_test_moveprobe_ignoresmall( "ai_test_moveprobe_ignoresmall", "0" ); extern ConVar ai_vehicle_avoidance; #endif // HL2_EPISODIC +#ifdef MAPBASE +extern ISoundEmitterSystemBase *soundemitterbase; + +ConVar ai_dynint_always_enabled( "ai_dynint_always_enabled", "0", FCVAR_NONE, "Makes the \"Don't Care\" setting equivalent to \"Yes\"." ); +#endif + #ifndef _RETAIL #define ShouldUseEfficiency() ( ai_use_think_optimizations.GetBool() && ai_use_efficiency.GetBool() ) #define ShouldUseFrameThinkLimits() ( ai_use_think_optimizations.GetBool() && ai_use_frame_think_limits.GetBool() ) @@ -660,11 +670,62 @@ void CAI_BaseNPC::Ignite( float flFlameLifetime, bool bNPCOnly, float flSize, bo ConVar ai_block_damage( "ai_block_damage","0" ); +#ifdef MAPBASE +bool CAI_BaseNPC::FriendlyFireEnabled() +{ + if (m_FriendlyFireOverride != TRS_NONE) + return m_FriendlyFireOverride == TRS_TRUE; + + if (HL2GameRules()->GlobalFriendlyFire() != TRS_NONE) + return HL2GameRules()->GlobalFriendlyFire() == TRS_TRUE; + + return !(CapabilitiesGet() & bits_CAP_FRIENDLY_DMG_IMMUNE); +} + +//----------------------------------------------------------------------------- +void CAI_BaseNPC::InputSetFriendlyFire( inputdata_t &inputdata ) +{ + m_FriendlyFireOverride = TO_THREESTATE(inputdata.value.Int()); +} +#endif + bool CAI_BaseNPC::PassesDamageFilter( const CTakeDamageInfo &info ) { if ( ai_block_damage.GetBool() ) return false; // FIXME: hook a friendly damage filter to the npc instead? +#ifdef MAPBASE + if ( !FriendlyFireEnabled() && info.GetAttacker() && info.GetAttacker() != this && !info.IsForceFriendlyFire() ) + { + // check attackers relationship with me + CBaseCombatCharacter *npcEnemy = info.GetAttacker()->MyCombatCharacterPointer(); + + if ( npcEnemy && npcEnemy->IRelationType( this ) == D_LI ) + { + m_fNoDamageDecal = true; + + if ( npcEnemy->IsPlayer() ) + { + m_OnDamagedByPlayer.FireOutput( info.GetAttacker(), this ); + // This also counts as being harmed by player's squad. + m_OnDamagedByPlayerSquad.FireOutput( info.GetAttacker(), this ); + } + + return false; + } + + if ( IServerVehicle *pVehicle = info.GetAttacker()->GetServerVehicle() ) + { + m_fNoDamageDecal = true; + if (pVehicle->GetPassenger() && pVehicle->GetPassenger()->IRelationType(this) != D_LI) + { + // MAPBASE FIXME: Players could probably bail from their cars to kill NPCs with this! + // Is there a "last passenger" variable we could use? + return false; + } + } + } +#else if ( (CapabilitiesGet() & bits_CAP_FRIENDLY_DMG_IMMUNE) && info.GetAttacker() && info.GetAttacker() != this ) { // check attackers relationship with me @@ -692,6 +753,7 @@ bool CAI_BaseNPC::PassesDamageFilter( const CTakeDamageInfo &info ) return false; } } +#endif if ( !BaseClass::PassesDamageFilter( info ) ) { @@ -714,7 +776,11 @@ int CAI_BaseNPC::OnTakeDamage_Alive( const CTakeDamageInfo &info ) return 0; if ( GetSleepState() == AISS_WAITING_FOR_THREAT ) +#ifdef MAPBASE + Wake( info.GetAttacker() ); +#else Wake(); +#endif // NOTE: This must happen after the base class is called; we need to reduce // health before the pain sound, since some NPCs use the final health @@ -776,7 +842,12 @@ int CAI_BaseNPC::OnTakeDamage_Alive( const CTakeDamageInfo &info ) else { // See if the person that injured me is an NPC. +#ifdef MAPBASE + // Sometimes I find these things and I can't just sit idly by. + CAI_BaseNPC *pAttacker = info.GetAttacker()->MyNPCPointer(); +#else CAI_BaseNPC *pAttacker = dynamic_cast( info.GetAttacker() ); +#endif CBasePlayer *pPlayer = AI_GetSinglePlayer(); if( pAttacker && pAttacker->IsAlive() && pPlayer ) @@ -1013,7 +1084,11 @@ void CAI_BaseNPC::OnFriendDamaged( CBaseCombatCharacter *pSquadmate, CBaseEntity float distSqToThreat = ( GetAbsOrigin() - pAttacker->GetAbsOrigin() ).LengthSqr(); if ( GetSleepState() != AISS_AWAKE && distSqToThreat < Square( 20 * 12 ) ) +#ifdef MAPBASE + Wake( pAttacker ); +#else Wake(); +#endif if ( distSqToThreat < Square( 50 * 12 ) ) ForceGatherConditions(); @@ -1182,7 +1257,12 @@ void CAI_BaseNPC::TraceAttack( const CTakeDamageInfo &info, const Vector &vecDir break; } +#ifdef MAPBASE + bool bBloodAllowed = DamageFilterAllowsBlood( info ); + if ( subInfo.GetDamage() >= 1.0 && !(subInfo.GetDamageType() & DMG_SHOCK ) && bBloodAllowed ) +#else if ( subInfo.GetDamage() >= 1.0 && !(subInfo.GetDamageType() & DMG_SHOCK ) ) +#endif { if( !IsPlayer() || ( IsPlayer() && g_pGameRules->IsMultiplayer() ) ) { @@ -1197,6 +1277,12 @@ void CAI_BaseNPC::TraceAttack( const CTakeDamageInfo &info, const Vector &vecDir m_fNoDamageDecal = true; } } +#ifdef MAPBASE + else if (!bBloodAllowed) + { + m_fNoDamageDecal = true; + } +#endif // Airboat gun will impart major force if it's about to kill him.... if ( info.GetDamageType() & DMG_AIRBOAT ) @@ -1286,7 +1372,12 @@ bool CAI_BaseNPC::PlayerInSpread( const Vector &sourcePos, const Vector &targetP { CBasePlayer *pPlayer = UTIL_PlayerByIndex( i ); +#ifdef MAPBASE + // "> D_FR" means it isn't D_HT, D_FR, or D_ER (error disposition) + if ( pPlayer && ( !ignoreHatedPlayers || IRelationType( pPlayer ) > D_FR ) ) +#else if ( pPlayer && ( !ignoreHatedPlayers || IRelationType( pPlayer ) != D_HT ) ) +#endif { if ( PointInSpread( pPlayer, sourcePos, targetPos, pPlayer->WorldSpaceCenter(), flSpread, maxDistOffCenter ) ) return true; @@ -1738,6 +1829,55 @@ void CAI_BaseNPC::ClearIgnoreConditions( int *pConditions, int nConditions ) } } +#ifdef MAPBASE +//------------------------------------------------------------------------------ +// Purpose: Adds a condition to this NPC, integral or not +//------------------------------------------------------------------------------ +void CAI_BaseNPC::InputSetCondition( inputdata_t &inputdata ) +{ + const char *pszCondition = inputdata.value.String(); + if (!pszCondition || !pszCondition[0]) + return; + + int iCondition = atoi(pszCondition); + if (iCondition == 0) + { + // Convert from string + iCondition = GetConditionID(pszCondition); + } + + SetCondition(iCondition); +} + +//------------------------------------------------------------------------------ +// Purpose: Removes a condition from this NPC, integral or not +//------------------------------------------------------------------------------ +void CAI_BaseNPC::InputClearCondition( inputdata_t &inputdata ) +{ + const char *pszCondition = inputdata.value.String(); + if (!pszCondition || !pszCondition[0]) + return; + + int iCondition = atoi(pszCondition); + if (iCondition == 0) + { + // Convert from string + iCondition = GetConditionID(pszCondition); + } + + ClearCondition(iCondition); +} + +//------------------------------------------------------------------------------ +// Purpose: Sets our think to CallNPCThink() in case SetThinkNull was fired before +//------------------------------------------------------------------------------ +void CAI_BaseNPC::InputSetThinkNPC( inputdata_t &inputdata ) +{ + SetThink ( &CAI_BaseNPC::CallNPCThink ); + SetNextThink(gpGlobals->curtime + inputdata.value.Float()); +} +#endif + //--------------------------------------------------------- //--------------------------------------------------------- bool CAI_BaseNPC::HasInterruptCondition( int iCondition ) @@ -1935,6 +2075,15 @@ bool CAI_BaseNPC::QueryHearSound( CSound *pSound ) return false; } +#ifdef MAPBASE + if ( pSound->SoundContext() & SOUND_CONTEXT_OWNER_ALLIES ) + { + CBaseCombatCharacter *pOwner = ToBaseCombatCharacter(pSound->m_hOwner); + if (!pOwner || pOwner->IRelationType(this) != D_LI) + return false; + } +#endif + if ( pSound->IsSoundType( SOUND_PLAYER ) && GetState() == NPC_STATE_IDLE && !FVisible( pSound->GetSoundReactOrigin() ) ) { // NPC's that are IDLE should disregard player movement sounds if they can't see them. @@ -3354,6 +3503,9 @@ void CAI_BaseNPC::UpdateSleepState( bool bInPVS ) { if ( GetSleepState() > AISS_AWAKE ) { +#ifdef MAPBASE +#define Wake() Wake(pLocalPlayer) +#endif CBasePlayer *pLocalPlayer = AI_GetSinglePlayer(); if ( !pLocalPlayer ) { @@ -3414,6 +3566,9 @@ void CAI_BaseNPC::UpdateSleepState( bool bInPVS ) } } } +#ifdef MAPBASE +#undef Wake +#endif } else { @@ -4176,6 +4331,24 @@ int CAI_BaseNPC::CapabilitiesGet( void ) const return capability; } +#ifdef MAPBASE +//------------------------------------------------------------------------------ +// Purpose: Adds capabilities to this NPC +//------------------------------------------------------------------------------ +void CAI_BaseNPC::InputAddCapabilities( inputdata_t &inputdata ) +{ + CapabilitiesAdd(inputdata.value.Int()); +} + +//------------------------------------------------------------------------------ +// Purpose: Removes capabilities from this NPC +//------------------------------------------------------------------------------ +void CAI_BaseNPC::InputRemoveCapabilities( inputdata_t &inputdata ) +{ + CapabilitiesRemove(inputdata.value.Int()); +} +#endif + // Set capability mask int CAI_BaseNPC::CapabilitiesAdd( int capability ) { @@ -4414,10 +4587,39 @@ void CAI_BaseNPC::Wake( bool bFireOutput ) if ( GetSleepState() != AISS_AWAKE ) { m_nWakeTick = gpGlobals->tickcount; +#ifndef MAPBASE SetSleepState( AISS_AWAKE ); +#endif RemoveEffects( EF_NODRAW ); if ( bFireOutput ) +#ifdef MAPBASE + { + // Activator is based on sleep state + CBaseEntity *pActivator = this; + + switch (GetSleepState()) + { + case AISS_WAITING_FOR_THREAT: + pActivator = GetEnemy(); + break; + + case AISS_WAITING_FOR_PVS: + case AISS_AUTO_PVS: + case AISS_AUTO_PVS_AFTER_PVS: + pActivator = UTIL_GetLocalPlayer(); + break; + + case AISS_WAITING_FOR_INPUT: + // I can't really do this here, but InputWake() uses the new function with pActivator, so it's fine + break; + } + + m_OnWake.FireOutput( pActivator, this ); + } + SetSleepState( AISS_AWAKE ); +#else m_OnWake.FireOutput( this, this ); +#endif if ( m_bWakeSquad && GetSquad() ) { @@ -4435,6 +4637,37 @@ void CAI_BaseNPC::Wake( bool bFireOutput ) } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CAI_BaseNPC::Wake( CBaseEntity *pActivator ) +{ + if ( GetSleepState() != AISS_AWAKE ) + { + m_nWakeTick = gpGlobals->tickcount; + RemoveEffects( EF_NODRAW ); + + m_OnWake.FireOutput( pActivator, this ); + + SetSleepState( AISS_AWAKE ); + + if ( m_bWakeSquad && GetSquad() ) + { + AISquadIter_t iter; + for ( CAI_BaseNPC *pSquadMember = GetSquad()->GetFirstMember( &iter ); pSquadMember; pSquadMember = GetSquad()->GetNextMember( &iter ) ) + { + if ( pSquadMember->IsAlive() && pSquadMember != this ) + { + pSquadMember->m_bWakeSquad = false; + pSquadMember->Wake(pActivator); + } + } + + } + } +} +#endif + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void CAI_BaseNPC::Sleep() @@ -4750,8 +4983,22 @@ void CAI_BaseNPC::PrescheduleThink( void ) CheckForScriptedNPCInteractions(); #endif +#ifdef MAPBASE + // Please excuse the readability here. + if (CapabilitiesGet() & bits_CAP_USE_WEAPONS) + { + // If we should have our gun out, fetch it + if ( ShouldUnholsterWeapon() && m_iDesiredWeaponState == DESIREDWEAPONSTATE_IGNORE ) + { + SetDesiredWeaponState( DESIREDWEAPONSTATE_UNHOLSTERED ); + } + + // If our desired weapon state is not the current, fix it + if( (m_iDesiredWeaponState == DESIREDWEAPONSTATE_HOLSTERED || m_iDesiredWeaponState == DESIREDWEAPONSTATE_UNHOLSTERED || m_iDesiredWeaponState == DESIREDWEAPONSTATE_HOLSTERED_DESTROYED ) ) +#else // If we use weapons, and our desired weapon state is not the current, fix it if( (CapabilitiesGet() & bits_CAP_USE_WEAPONS) && (m_iDesiredWeaponState == DESIREDWEAPONSTATE_HOLSTERED || m_iDesiredWeaponState == DESIREDWEAPONSTATE_UNHOLSTERED || m_iDesiredWeaponState == DESIREDWEAPONSTATE_HOLSTERED_DESTROYED ) ) +#endif { if ( IsAlive() && !IsInAScript() ) { @@ -4774,6 +5021,9 @@ void CAI_BaseNPC::PrescheduleThink( void ) m_iDesiredWeaponState = DESIREDWEAPONSTATE_IGNORE; } } +#ifdef MAPBASE + } +#endif } //----------------------------------------------------------------------------- @@ -5130,6 +5380,62 @@ NPC_STATE CAI_BaseNPC::SelectIdealState( void ) return m_IdealNPCState; } +#ifdef MAPBASE +//------------------------------------------------------------------------------ +// Purpose: Creates a new weapon and makes us equip it. +//------------------------------------------------------------------------------ +CBaseCombatWeapon *CAI_BaseNPC::GiveWeapon( string_t iszWeaponName, bool bDiscardCurrent ) +{ + CBaseCombatWeapon *pWeapon = Weapon_Create( STRING(iszWeaponName) ); + if ( !pWeapon ) + { + Warning( "Couldn't create weapon %s to give NPC %s.\n", STRING(iszWeaponName), GetDebugName() ); + return NULL; + } + + // If I have a weapon already, drop it + if ( bDiscardCurrent && GetActiveWeapon() ) + { + Weapon_Drop( GetActiveWeapon() ); + } + + // If I have a name, make my weapon match it with "_weapon" appended + if ( GetEntityName() != NULL_STRING ) + { + pWeapon->SetName( AllocPooledString(UTIL_VarArgs("%s_weapon", STRING(GetEntityName()) )) ); + } + + Weapon_Equip( pWeapon ); + + // Handle this case + OnGivenWeapon( pWeapon ); + + return pWeapon; +} + +//------------------------------------------------------------------------------ +// Purpose: Creates a new weapon and puts it in our inventory. +//------------------------------------------------------------------------------ +CBaseCombatWeapon *CAI_BaseNPC::GiveWeaponHolstered( string_t iszWeaponName ) +{ + CBaseCombatWeapon *pWeapon = Weapon_Create( STRING(iszWeaponName) ); + if ( !pWeapon ) + { + Warning( "Couldn't create weapon %s to give NPC %s.\n", STRING(iszWeaponName), GetDebugName() ); + return NULL; + } + + // If I have a name, make my weapon match it with "_weapon" appended + if ( GetEntityName() != NULL_STRING ) + { + pWeapon->SetName( AllocPooledString(UTIL_VarArgs("%s_weapon", STRING(GetEntityName()) )) ); + } + + Weapon_EquipHolstered( pWeapon ); + + return pWeapon; +} +#else //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void CAI_BaseNPC::GiveWeapon( string_t iszWeaponName ) @@ -5158,6 +5464,7 @@ void CAI_BaseNPC::GiveWeapon( string_t iszWeaponName ) // Handle this case OnGivenWeapon( pWeapon ); } +#endif //----------------------------------------------------------------------------- // Rather specific function that tells us if an NPC is in the process of @@ -5599,6 +5906,11 @@ void CAI_BaseNPC::GatherEnemyConditions( CBaseEntity *pEnemy ) EHANDLE hEnemy; hEnemy.Set( GetEnemy() ); +#ifdef MAPBASE + if (hEnemy->IsPlayer()) + m_OnFoundPlayer.Set(hEnemy, hEnemy, this); + m_OnFoundEnemy.Set(hEnemy, hEnemy, this); +#else if (GetEnemy()->IsPlayer()) { m_OnFoundPlayer.Set(hEnemy, this, this); @@ -5608,6 +5920,7 @@ void CAI_BaseNPC::GatherEnemyConditions( CBaseEntity *pEnemy ) { m_OnFoundEnemy.Set(hEnemy, this, this); } +#endif } Remember( bits_MEMORY_HAD_LOS ); } @@ -5904,6 +6217,104 @@ CAI_BaseNPC *CAI_BaseNPC::CreateCustomTarget( const Vector &vecOrigin, float dur #endif// HL2_DLL } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: This is used by TranslateActivity() before anything else. +// Input : eNewActivity - +// Output : Activity +//----------------------------------------------------------------------------- +Activity CAI_BaseNPC::TranslateCrouchActivity( Activity eNewActivity ) +{ + if (CapabilitiesGet() & bits_CAP_DUCK) + { + // ======================================================================== + // The main issue with cover hint nodes is that crouch activities are not translated at the right time + // in the activity translation process. Weapons aren't given a chance to translate from them + // and therefore the crouch activities on many NPCs are inaccessible. + // + // Regular, non-hint-node crouching seen on Combine soldiers and Episodic Alyx + // seemingly don't work when put here, so don't bother. + // ======================================================================== + Activity nCoverActivity = eNewActivity; + if (eNewActivity == ACT_RELOAD) + { + nCoverActivity = GetReloadActivity(GetHintNode()); + } + // INCOVER is synonymous with crouching at crouch cover nodes. + // Any time we need to crouch at cover is when INCOVER is valid. + else if (HasMemory(bits_MEMORY_INCOVER)) + { + if (eNewActivity == ACT_IDLE || eNewActivity == ACT_COVER) + { + // They stick to cover sometimes, but that might just be when they can't path to the enemy. + if (GetState() == NPC_STATE_COMBAT /*&& !IsCurSchedule(SCHED_COMBAT_STAND, false)*/) + nCoverActivity = GetCoverActivity(GetHintNode()); + } + else if (eNewActivity == ACT_RANGE_ATTACK1) + { + // Soldiers are the only ones I've seen attack while INCOVER, + // so I don't think we have to give it its own function. + CAI_Hint *pHint = GetHintNode(); + if (pHint) + { + if (pHint->HintType() == HINT_TACTICAL_COVER_LOW || pHint->HintType() == HINT_TACTICAL_COVER_MED) + { + nCoverActivity = ACT_RANGE_ATTACK1_LOW; + } + } + } + } + + if (nCoverActivity != ACT_IDLE) + eNewActivity = nCoverActivity; + + /* + // --------------------------------------------------------------- + // Some NPCs don't have a cover activity defined so just use idle + // --------------------------------------------------------------- + if (nCoverActivity != eNewActivity) + { + if (SelectWeightedSequence(nCoverActivity) != ACTIVITY_NOT_AVAILABLE) + { + eNewActivity = nCoverActivity; + } + else if (eNewActivity == ACT_COVER) + { + // Untranslated ACT_COVER should revert to ACT_IDLE + eNewActivity = ACT_IDLE; + } + } + */ + } + + return eNewActivity; +} + +//----------------------------------------------------------------------------- +// Purpose: Backup activity (NPC version of Weapon_BackupActivity) +// This only gets called if the NPC absolutely does not have an animation. +// This means if we don't return another activity, the NPC will most likely T-pose. +// Input : eNewActivity - +// Output : Activity +//----------------------------------------------------------------------------- +Activity CAI_BaseNPC::NPC_BackupActivity( Activity eNewActivity ) +{ + //if (eNewActivity == ACT_DROP_WEAPON) + // return TranslateActivity(ACT_IDLE); + + // Accounts for certain act busy activities that aren't on all NPCs. + if (eNewActivity == ACT_BUSY_QUEUE || eNewActivity == ACT_BUSY_STAND) + return TranslateActivity(ACT_IDLE); + + // GetCoverActivity() should have this covered. + // --------------------------------------------- + //if (eNewActivity == ACT_COVER) + // return TranslateActivity(ACT_IDLE); + + return eNewActivity; +} +#endif + //----------------------------------------------------------------------------- // Purpose: // Input : eNewActivity - @@ -5911,6 +6322,27 @@ CAI_BaseNPC *CAI_BaseNPC::CreateCustomTarget( const Vector &vecOrigin, float dur //----------------------------------------------------------------------------- Activity CAI_BaseNPC::NPC_TranslateActivity( Activity eNewActivity ) { +#ifdef MAPBASE + Assert( eNewActivity != ACT_INVALID ); + + if (IsCrouching()) + { + switch (eNewActivity) + { + case ACT_RANGE_ATTACK1: eNewActivity = ACT_RANGE_ATTACK1_LOW; break; + case ACT_RELOAD: eNewActivity = ACT_RELOAD_LOW; break; + case ACT_IDLE: eNewActivity = ACT_CROUCHIDLE; break; + + // ==== + // HACK : LEIPZIG 06 - The underlying problem is that the AR2 and SMG1 cannot map IDLE_ANGRY to a crouched equivalent automatically + // which causes the character to pop up and down in their idle state of firing while crouched. -- jdw + case ACT_IDLE_ANGRY_SMG1: + case ACT_IDLE_ANGRY_AR2: + eNewActivity = ACT_RANGE_AIM_LOW; + break; + } + } +#else Assert( eNewActivity != ACT_INVALID ); if (eNewActivity == ACT_RANGE_ATTACK1) @@ -5967,6 +6399,7 @@ Activity CAI_BaseNPC::NPC_TranslateActivity( Activity eNewActivity ) return nCoverActivity; } } +#endif return eNewActivity; } @@ -5986,6 +6419,13 @@ Activity CAI_BaseNPC::TranslateActivity( Activity idealActivity, Activity *pIdea Activity last; Activity current; +#ifdef MAPBASE + // Crouch activities are translated before everything else. + idealActivity = TranslateCrouchActivity( idealActivity ); + //if ( idealWeaponActivity != idealActivity /*&& HaveSequenceForActivity(idealWeaponActivity)*/ ) + // idealActivity = idealWeaponActivity; +#endif + idealWeaponActivity = Weapon_TranslateActivity( idealActivity, &bIdealWeaponRequired ); if ( pIdealWeaponActivity ) *pIdealWeaponActivity = idealWeaponActivity; @@ -6013,6 +6453,12 @@ Activity CAI_BaseNPC::TranslateActivity( Activity idealActivity, Activity *pIdea if ( HaveSequenceForActivity( weaponTranslation ) ) return weaponTranslation; +#ifdef MAPBASE + // This is used so NPCs can use any weapon, restored AR2 activities on one NPC don't T-pose another, etc. + Activity backupActivity = Weapon_BackupActivity(baseTranslation, bWeaponRequired); + if (baseTranslation != backupActivity && HaveSequenceForActivity(backupActivity)) + return backupActivity; +#endif if ( bWeaponRequired ) { @@ -6038,6 +6484,22 @@ Activity CAI_BaseNPC::TranslateActivity( Activity idealActivity, Activity *pIdea if ( idealActivity != idealWeaponActivity && HaveSequenceForActivity( idealActivity ) ) return idealActivity; +#ifdef MAPBASE + // We absolutely do not have an activity for this. + // Do the same as above, but with any backup activity we may have available. + backupActivity = NPC_BackupActivity(baseTranslation); + if (backupActivity != baseTranslation && HaveSequenceForActivity(backupActivity)) + return backupActivity; + + backupActivity = NPC_BackupActivity(idealWeaponActivity); + if (backupActivity != idealWeaponActivity && HaveSequenceForActivity(backupActivity)) + return backupActivity; + + backupActivity = NPC_BackupActivity(idealActivity); + if (backupActivity != idealActivity && HaveSequenceForActivity(backupActivity)) + return backupActivity; +#endif + Assert( !HaveSequenceForActivity( idealActivity ) ); if ( idealActivity == ACT_RUN ) { @@ -6983,7 +7445,11 @@ void CAI_BaseNPC::OnChangeActiveWeapon( CBaseCombatWeapon *pOldWeapon, CBaseComb //----------------------------------------------------------------------------- bool CAI_BaseNPC::CanHolsterWeapon( void ) { +#ifdef MAPBASE + int seq = SelectWeightedSequence( TranslateActivity(ACT_DISARM) ); +#else int seq = SelectWeightedSequence( ACT_DISARM ); +#endif return (seq >= 0); } @@ -6995,12 +7461,22 @@ int CAI_BaseNPC::HolsterWeapon( void ) if ( IsWeaponHolstered() ) return -1; +#ifdef COMPANION_HOLSTER_WORKAROUND + Activity activity = TranslateActivity( ACT_DISARM ); + int iHolsterGesture = FindGestureLayer( activity ); + if ( iHolsterGesture != -1 ) + return iHolsterGesture; + + int iLayer = AddGesture( activity, true ); + //iLayer = AddGesture( ACT_GESTURE_DISARM, true ); +#else int iHolsterGesture = FindGestureLayer( ACT_DISARM ); if ( iHolsterGesture != -1 ) return iHolsterGesture; int iLayer = AddGesture( ACT_DISARM, true ); //iLayer = AddGesture( ACT_GESTURE_DISARM, true ); +#endif if (iLayer != -1) { @@ -7022,6 +7498,13 @@ int CAI_BaseNPC::HolsterWeapon( void ) ClearCondition(COND_NO_PRIMARY_AMMO); ClearCondition(COND_NO_SECONDARY_AMMO); } +#ifdef MAPBASE + else + { + // We don't have the animation, so just make our weapon holster instantaneously. + DoHolster(); + } +#endif return iLayer; } @@ -7034,19 +7517,42 @@ int CAI_BaseNPC::UnholsterWeapon( void ) if ( !IsWeaponHolstered() ) return -1; +#ifdef COMPANION_HOLSTER_WORKAROUND + Activity activity = TranslateActivity( ACT_ARM ); + int iHolsterGesture = FindGestureLayer( activity ); +#else int iHolsterGesture = FindGestureLayer( ACT_ARM ); +#endif if ( iHolsterGesture != -1 ) return iHolsterGesture; +#ifdef MAPBASE + int i = m_iLastHolsteredWeapon >= 0 && GetWeapon(m_iLastHolsteredWeapon) ? m_iLastHolsteredWeapon : -1; + if (i == -1) + { + // Set i to the first weapon you can find + for (i = 0; i < WeaponCount(); i++) + { + if (GetWeapon(i)) + break; + } + } +#else // Deploy the first weapon you can find for (int i = 0; i < WeaponCount(); i++) +#endif { if ( GetWeapon( i )) { SetActiveWeapon( GetWeapon(i) ); +#ifdef COMPANION_HOLSTER_WORKAROUND + int iLayer = AddGesture( activity, true ); + //iLayer = AddGesture( ACT_GESTURE_ARM, true ); +#else int iLayer = AddGesture( ACT_ARM, true ); //iLayer = AddGesture( ACT_GESTURE_ARM, true ); +#endif if (iLayer != -1) { @@ -7056,6 +7562,13 @@ int CAI_BaseNPC::UnholsterWeapon( void ) m_iDesiredWeaponState = DESIREDWEAPONSTATE_CHANGING; } +#ifdef MAPBASE + else + { + // We don't have the animation, so just make our weapon unholster instantaneously. + DoUnholster(); + } +#endif // Refill the clip if ( GetActiveWeapon()->UsesClipsForAmmo1() ) @@ -7096,6 +7609,26 @@ void CAI_BaseNPC::InputHolsterAndDestroyWeapon( inputdata_t &inputdata ) //----------------------------------------------------------------------------- void CAI_BaseNPC::InputUnholsterWeapon( inputdata_t &inputdata ) { +#ifdef MAPBASE + // Support for unholstering a specific weapon + if (inputdata.value.String()) + { + if (IsWeaponHolstered()) + { + for (int i=0;im_iClassname == inputdata.value.StringID() ) + { + //Weapon_Switch(m_hMyWeapons[i]); + //DoHolster(); + m_iLastHolsteredWeapon = i; + } + } + } + } +#endif + m_iDesiredWeaponState = DESIREDWEAPONSTATE_UNHOLSTERED; } @@ -7121,6 +7654,190 @@ bool CAI_BaseNPC::IsWeaponStateChanging( void ) return ( m_iDesiredWeaponState == DESIREDWEAPONSTATE_CHANGING || m_iDesiredWeaponState == DESIREDWEAPONSTATE_CHANGING_DESTROY ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Allows NPC to holster from more than just the animation event +//----------------------------------------------------------------------------- +bool CAI_BaseNPC::DoHolster( void ) +{ + // Cache off the weapon. + CBaseCombatWeapon *pWeapon = GetActiveWeapon(); + + if (pWeapon) + { + // Mark this as our last weapon + for (int i = 0; i < MAX_WEAPONS; i++) + { + if (m_hMyWeapons[i].Get() == pWeapon) + { + m_iLastHolsteredWeapon = i; + break; + } + } + + GetActiveWeapon()->Holster(); + SetActiveWeapon( NULL ); + + //Force the NPC to recalculate it's arrival activity since it'll most likely be wrong now that we don't have a weapon out. + GetNavigator()->SetArrivalSequence( ACT_INVALID ); + + if ( m_iDesiredWeaponState == DESIREDWEAPONSTATE_CHANGING_DESTROY ) + { + // Get rid of it! + UTIL_Remove( pWeapon ); + } + + if ( m_iDesiredWeaponState != DESIREDWEAPONSTATE_IGNORE ) + { + m_iDesiredWeaponState = DESIREDWEAPONSTATE_IGNORE; + m_Activity = ACT_RESET; + } + + return true; + } + else + { + return false; + } +} + +//----------------------------------------------------------------------------- +// Purpose: Allows NPC to unholster from more than just the animation event +//----------------------------------------------------------------------------- +bool CAI_BaseNPC::DoUnholster( void ) +{ + if (GetActiveWeapon()) + { + GetActiveWeapon()->Deploy(); + + //Force the NPC to recalculate it's arrival activity since it'll most likely be wrong now. + GetNavigator()->SetArrivalSequence( ACT_INVALID ); + + if ( m_iDesiredWeaponState != DESIREDWEAPONSTATE_IGNORE ) + { + m_iDesiredWeaponState = DESIREDWEAPONSTATE_IGNORE; + m_Activity = ACT_RESET; + } + + return true; + } + + return false; +} + +//------------------------------------------------------------------------------ +// Purpose: Give the NPC in question the weapon specified +//------------------------------------------------------------------------------ +void CAI_BaseNPC::InputGiveWeaponHolstered( inputdata_t &inputdata ) +{ + string_t iszWeaponName = inputdata.value.StringID(); + if ( iszWeaponName != NULL_STRING ) + { + GiveWeaponHolstered( iszWeaponName ); + } +} + +//------------------------------------------------------------------------------ +// Purpose: Makes the NPC change to the specified weapon via successive holster/unholster animations, creates it if it doesn't exist +//------------------------------------------------------------------------------ +void CAI_BaseNPC::InputChangeWeapon( inputdata_t &inputdata ) +{ + CBaseCombatWeapon *pSwitchTo = NULL; // The weapon itself + int iSwitchTo; // Index in m_hMyWeapons + for (int i=0;im_iClassname == inputdata.value.StringID() ) + { + pSwitchTo = m_hMyWeapons[i]; + iSwitchTo = i; + break; + } + } + + if (!pSwitchTo) + { + // We must not have it + pSwitchTo = GiveWeaponHolstered(inputdata.value.StringID()); + for (int i = 0; im_iClassname); + g_EventQueue.AddEvent(this, "UnholsterWeapon", variant, GetLayerDuration(iHolsterLayer) /*+ 0.65*/, this, this); + } +} + +//------------------------------------------------------------------------------ +// Purpose: Makes the NPC pick up the specified weapon if it can +//------------------------------------------------------------------------------ +void CAI_BaseNPC::InputPickupWeapon( inputdata_t &inputdata ) +{ + string_t iszWeaponName = inputdata.value.StringID(); + if (iszWeaponName == NULL_STRING) + return; + + // Searching "generically" could potentially get a weapon already held by someone. + CBaseEntity *pEntity = gEntList.FindEntityByNameNearest(STRING(iszWeaponName), GetLocalOrigin(), 0, this, inputdata.pActivator, inputdata.pCaller); + CBaseCombatWeapon *pWeapon = NULL; + if (pEntity) + pWeapon = pEntity->MyCombatWeaponPointer(); + + if (!pEntity || !pWeapon) + return; + + m_flNextWeaponSearchTime = gpGlobals->curtime + 10.0; + // Now lock the weapon for several seconds while we go to pick it up. + pWeapon->Lock( 10.0, this ); + SetTarget( pWeapon ); + SetSchedule(SCHED_NEW_WEAPON); +} + +//------------------------------------------------------------------------------ +// Purpose: Makes the NPC pick up the specified item if it can +//------------------------------------------------------------------------------ +void CAI_BaseNPC::InputPickupItem( inputdata_t &inputdata ) +{ + string_t iszItemName = inputdata.value.StringID(); + if (iszItemName == NULL_STRING) + return; + + // Searching "generically" could potentially get a weapon already held by someone. + CBaseEntity *pEntity = gEntList.FindEntityByNameNearest(STRING(iszItemName), GetLocalOrigin(), 0, this, inputdata.pActivator, inputdata.pCaller); + if (!pEntity) + return; + + SetTarget( pEntity ); + + // Can apply to anything, not just healthkits + SetSchedule(SCHED_GET_HEALTHKIT); +} +#endif + //----------------------------------------------------------------------------- // Set up the shot regulator based on the equipped weapon //----------------------------------------------------------------------------- @@ -7152,6 +7869,7 @@ void CAI_BaseNPC::InitRelationshipTable(void) } +#ifndef MAPBASE // Moved to CBaseCombatCharacter //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -7236,6 +7954,28 @@ void CAI_BaseNPC::AddRelationship( const char *pszRelationship, CBaseEntity *pAc } else { +#ifdef MAPBASE + if (!Q_strnicmp(entityString, "CLASS_", 5)) + { + // Go through all of the classes and find which one this is + Class_T resultClass = CLASS_NONE; + for (int i = 0; i < NUM_AI_CLASSES; i++) + { + if (FStrEq(g_pGameRules->AIClassText(i), entityString)) + { + resultClass = (Class_T)i; + } + } + + if (resultClass != CLASS_NONE) + { + AddClassRelationship( resultClass, disposition, priority ); + bFoundEntity = true; + } + } + + if (!bFoundEntity) +#endif DevWarning( "Couldn't set relationship to unknown entity or class (%s)!\n", entityString ); } } @@ -7244,6 +7984,7 @@ void CAI_BaseNPC::AddRelationship( const char *pszRelationship, CBaseEntity *pAc entityString = strtok(NULL," "); } } +#endif //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- @@ -7966,6 +8707,24 @@ Activity CAI_BaseNPC::GetReloadActivity( CAI_Hint* pHint ) case HINT_TACTICAL_COVER_LOW: case HINT_TACTICAL_COVER_MED: { +#ifdef MAPBASE + if (HasMemory(bits_MEMORY_INCOVER)) + { + // Don't do that trace thing. INCOVER means we're already crouching. + nReloadActivity = ACT_RELOAD_LOW; + } + else + { + Vector vEyePos = GetAbsOrigin() + GetCrouchEyeOffset(); + // Check if this location will block the threat's line of sight to me + trace_t tr; + AI_TraceLOS(vEyePos, GetEnemy()->EyePosition(), this, &tr); + if (tr.fraction != 1.0) + { + nReloadActivity = ACT_RELOAD_LOW; + } + } +#else if (SelectWeightedSequence( ACT_RELOAD_LOW ) != ACTIVITY_NOT_AVAILABLE) { Vector vEyePos = GetAbsOrigin() + EyeOffset(ACT_RELOAD_LOW); @@ -7977,6 +8736,7 @@ Activity CAI_BaseNPC::GetReloadActivity( CAI_Hint* pHint ) nReloadActivity = ACT_RELOAD_LOW; } } +#endif break; } } @@ -8001,12 +8761,24 @@ Activity CAI_BaseNPC::GetCoverActivity( CAI_Hint *pHint ) switch (pHint->HintType()) { case HINT_TACTICAL_COVER_MED: +#ifndef MAPBASE // I know what you're thinking, but ACT_COVER_MED is pretty much deprecated at this point anyway. { nCoverActivity = ACT_COVER_MED; +#ifdef MAPBASE + // Some NPCs lack ACT_COVER_MED, but could easily use ACT_COVER_LOW. + if (SelectWeightedSequence(nCoverActivity) == ACTIVITY_NOT_AVAILABLE) + nCoverActivity = ACT_COVER_LOW; +#endif break; } +#endif case HINT_TACTICAL_COVER_LOW: { +#ifdef MAPBASE + if (pHint->HintActivityName() != NULL_STRING) + nCoverActivity = (Activity)CAI_BaseNPC::GetActivityID( STRING(pHint->HintActivityName()) ); + else +#endif nCoverActivity = ACT_COVER_LOW; break; } @@ -8014,7 +8786,11 @@ Activity CAI_BaseNPC::GetCoverActivity( CAI_Hint *pHint ) } if ( nCoverActivity == ACT_INVALID ) +#ifdef MAPBASE + nCoverActivity = ACT_IDLE; +#else nCoverActivity = ACT_COVER; +#endif return nCoverActivity; } @@ -8382,8 +9158,12 @@ void CAI_BaseNPC::HandleAnimEvent( animevent_t *pEvent ) { if ( GetActiveWeapon() ) { +#ifdef MAPBASE + GetActiveWeapon()->Reload_NPC(); +#else GetActiveWeapon()->WeaponSound( RELOAD_NPC ); GetActiveWeapon()->m_iClip1 = GetActiveWeapon()->GetMaxClip1(); +#endif ClearCondition(COND_LOW_PRIMARY_AMMO); ClearCondition(COND_NO_PRIMARY_AMMO); ClearCondition(COND_NO_SECONDARY_AMMO); @@ -8433,6 +9213,11 @@ void CAI_BaseNPC::HandleAnimEvent( animevent_t *pEvent ) { if (pEvent->event == AE_NPC_HOLSTER) { +#ifdef MAPBASE + CBaseCombatWeapon *pWeapon = GetActiveWeapon(); + if (DoHolster()) + m_OnHolsterWeapon.Set(pWeapon, pWeapon, this); +#else // Cache off the weapon. CBaseCombatWeapon *pWeapon = GetActiveWeapon(); @@ -8455,11 +9240,16 @@ void CAI_BaseNPC::HandleAnimEvent( animevent_t *pEvent ) m_iDesiredWeaponState = DESIREDWEAPONSTATE_IGNORE; m_Activity = ACT_RESET; } +#endif return; } else if (pEvent->event == AE_NPC_DRAW) { +#ifdef MAPBASE + if (DoUnholster()) + m_OnUnholsterWeapon.Set(GetActiveWeapon(), GetActiveWeapon(), this); +#else if (GetActiveWeapon()) { GetActiveWeapon()->Deploy(); @@ -8473,6 +9263,7 @@ void CAI_BaseNPC::HandleAnimEvent( animevent_t *pEvent ) m_Activity = ACT_RESET; } } +#endif return; } else if ( pEvent->event == AE_NPC_BODYDROP_HEAVY ) @@ -9887,6 +10678,7 @@ int CAI_BaseNPC::PlayScriptedSentence( const char *pszSentence, float delay, flo return PlaySentence( pszSentence, delay, volume, soundlevel, pListener ); } +#ifndef MAPBASE // Moved to CBaseCombatCharacter //----------------------------------------------------------------------------- // Purpose: // Input : @@ -9961,6 +10753,7 @@ CBaseEntity *CAI_BaseNPC::FindNamedEntity( const char *name, IEntityFindFilter * return NULL; } +#endif void CAI_BaseNPC::CorpseFallThink( void ) @@ -10345,6 +11138,51 @@ void CAI_BaseNPC::PickupWeapon( CBaseCombatWeapon *pWeapon ) m_iszPendingWeapon = NULL_STRING; } +#ifdef MAPBASE +extern ConVar sk_healthvial; + +//------------------------------------------------------------------------------ +// Purpose: Moved from CNPC_Citizen to CAI_BaseNPC for new pickup input +//------------------------------------------------------------------------------ +void CAI_BaseNPC::PickupItem( CBaseEntity *pItem ) +{ + // Must cache number of elements in case any fire only once (therefore being removed after being fired) + int iNumElements = m_OnItemPickup.NumberOfElements(); + if (iNumElements > 0) + m_OnItemPickup.Set( pItem, pItem, this ); + + Assert( pItem != NULL ); + if( FClassnameIs( pItem, "item_healthkit" ) ) + { + if ( TakeHealth( sk_healthkit.GetFloat(), DMG_GENERIC ) ) + { + RemoveAllDecals(); + UTIL_Remove( pItem ); + } + } + else if( FClassnameIs( pItem, "item_healthvial" ) ) + { + if ( TakeHealth( sk_healthvial.GetFloat(), DMG_GENERIC ) ) + { + RemoveAllDecals(); + UTIL_Remove( pItem ); + } + } + else if ( FClassnameIs(pItem, "item_ammo_ar2_altfire") || FClassnameIs(pItem, "item_ammo_smg1_grenade") || + FClassnameIs(pItem, "weapon_frag") ) + { + AddGrenades( 1 ); + UTIL_Remove( pItem ); + } + + // Only warn if we didn't have any elements of OnItemPickup + else if (iNumElements <= 0) + { + DevMsg("%s doesn't know how to pick up %s!\n", GetClassname(), pItem->GetClassname() ); + } +} +#endif + //========================================================= // DropItem - dead npc drops named item //========================================================= @@ -10619,6 +11457,9 @@ BEGIN_DATADESC( CAI_BaseNPC ) DEFINE_FIELD( m_iInteractionPlaying, FIELD_INTEGER ), DEFINE_UTLVECTOR(m_ScriptedInteractions,FIELD_EMBEDDED), DEFINE_FIELD( m_flInteractionYaw, FIELD_FLOAT ), +#ifdef MAPBASE + DEFINE_INPUT( m_iDynamicInteractionsAllowed, FIELD_INTEGER, "SetDynamicInteractions" ), +#endif DEFINE_EMBEDDED( m_CheckOnGroundTimer ), DEFINE_FIELD( m_vDefaultEyeOffset, FIELD_VECTOR ), DEFINE_FIELD( m_flNextEyeLookTime, FIELD_TIME ), @@ -10629,7 +11470,11 @@ BEGIN_DATADESC( CAI_BaseNPC ) DEFINE_FIELD( m_flHeadYaw, FIELD_FLOAT ), DEFINE_FIELD( m_flHeadPitch, FIELD_FLOAT ), DEFINE_FIELD( m_flOriginalYaw, FIELD_FLOAT ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bInAScript, FIELD_BOOLEAN, "SpawnWithStartScripting" ), +#else DEFINE_FIELD( m_bInAScript, FIELD_BOOLEAN ), +#endif DEFINE_FIELD( m_scriptState, FIELD_INTEGER ), DEFINE_FIELD( m_hCine, FIELD_EHANDLE ), DEFINE_CUSTOM_FIELD( m_ScriptArrivalActivity, ActivityDataOps() ), @@ -10650,6 +11495,9 @@ BEGIN_DATADESC( CAI_BaseNPC ) DEFINE_KEYFIELD( m_bIgnoreUnseenEnemies, FIELD_BOOLEAN , "ignoreunseenenemies"), DEFINE_EMBEDDED( m_ShotRegulator ), DEFINE_FIELD( m_iDesiredWeaponState, FIELD_INTEGER ), +#ifdef MAPBASE + DEFINE_FIELD( m_iLastHolsteredWeapon, FIELD_INTEGER ), +#endif // m_pSquad Saved specially in ai_saverestore.cpp DEFINE_KEYFIELD(m_SquadName, FIELD_STRING, "squadname" ), DEFINE_FIELD( m_iMySquadSlot, FIELD_INTEGER ), @@ -10692,6 +11540,10 @@ BEGIN_DATADESC( CAI_BaseNPC ) DEFINE_FIELD( m_bImportanRagdoll, FIELD_BOOLEAN ), DEFINE_FIELD( m_bPlayerAvoidState, FIELD_BOOLEAN ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_FriendlyFireOverride, FIELD_INTEGER, "FriendlyFireOverride" ), +#endif + // Satisfy classcheck // DEFINE_FIELD( m_ScheduleHistory, CUtlVector < AIScheduleChoice_t > ), @@ -10733,11 +11585,20 @@ BEGIN_DATADESC( CAI_BaseNPC ) DEFINE_OUTPUT( m_OnForcedInteractionStarted, "OnForcedInteractionStarted" ), DEFINE_OUTPUT( m_OnForcedInteractionAborted, "OnForcedInteractionAborted" ), DEFINE_OUTPUT( m_OnForcedInteractionFinished, "OnForcedInteractionFinished" ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OnItemPickup, "OnItemPickup" ), +#endif // Inputs +#ifndef MAPBASE DEFINE_INPUTFUNC( FIELD_STRING, "SetRelationship", InputSetRelationship ), +#endif DEFINE_INPUTFUNC( FIELD_STRING, "SetEnemyFilter", InputSetEnemyFilter ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetHealthFraction", InputSetHealthFraction ), +#else DEFINE_INPUTFUNC( FIELD_INTEGER, "SetHealth", InputSetHealth ), +#endif DEFINE_INPUTFUNC( FIELD_VOID, "BeginRappel", InputBeginRappel ), DEFINE_INPUTFUNC( FIELD_STRING, "SetSquad", InputSetSquad ), DEFINE_INPUTFUNC( FIELD_VOID, "Wake", InputWake ), @@ -10754,12 +11615,35 @@ BEGIN_DATADESC( CAI_BaseNPC ) DEFINE_INPUTFUNC( FIELD_VOID, "DisableSpeedModifier", InputDisableSpeedModifier ), DEFINE_INPUTFUNC( FIELD_INTEGER, "SetSpeedModRadius", InputSetSpeedModifierRadius ), DEFINE_INPUTFUNC( FIELD_INTEGER, "SetSpeedModSpeed", InputSetSpeedModifierSpeed ), +#ifndef MAPBASE // Moved to CBaseCombatCharacter DEFINE_INPUTFUNC( FIELD_VOID, "HolsterWeapon", InputHolsterWeapon ), DEFINE_INPUTFUNC( FIELD_VOID, "HolsterAndDestroyWeapon", InputHolsterAndDestroyWeapon ), DEFINE_INPUTFUNC( FIELD_VOID, "UnholsterWeapon", InputUnholsterWeapon ), +#endif DEFINE_INPUTFUNC( FIELD_STRING, "ForceInteractionWithNPC", InputForceInteractionWithNPC ), DEFINE_INPUTFUNC( FIELD_STRING, "UpdateEnemyMemory", InputUpdateEnemyMemory ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetFriendlyFire", InputSetFriendlyFire ), + + DEFINE_INPUTFUNC( FIELD_STRING, "GiveWeaponHolstered", InputGiveWeaponHolstered ), + DEFINE_INPUTFUNC( FIELD_STRING, "ChangeWeapon", InputChangeWeapon ), + DEFINE_INPUTFUNC( FIELD_STRING, "PickupWeapon", InputPickupWeapon ), + DEFINE_INPUTFUNC( FIELD_STRING, "PickupItem", InputPickupItem ), + DEFINE_OUTPUT( m_OnHolsterWeapon, "OnHolsterWeapon" ), + DEFINE_OUTPUT( m_OnUnholsterWeapon, "OnUnholsterWeapon" ), + + DEFINE_INPUTFUNC( FIELD_INTEGER, "AddCapabilities", InputAddCapabilities ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "RemoveCapabilities", InputRemoveCapabilities ), + + DEFINE_INPUTFUNC( FIELD_STRING, "SetCondition", InputSetCondition ), + DEFINE_INPUTFUNC( FIELD_STRING, "ClearCondition", InputClearCondition ), + + DEFINE_INPUTFUNC( FIELD_STRING, "SetHintGroup", InputSetHintGroup ), + + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetThinkNPC", InputSetThinkNPC ), +#endif + // Function pointers DEFINE_USEFUNC( NPCUse ), DEFINE_THINKFUNC( CallNPCThink ), @@ -10822,6 +11706,9 @@ BEGIN_SIMPLE_DATADESC( ScriptedNPCInteraction_t ) DEFINE_FIELD( vecRelativeOrigin, FIELD_VECTOR ), DEFINE_FIELD( angRelativeAngles, FIELD_VECTOR ), DEFINE_FIELD( vecRelativeVelocity, FIELD_VECTOR ), +#ifdef MAPBASE + DEFINE_FIELD( vecRelativeEndPos, FIELD_VECTOR ), +#endif DEFINE_FIELD( flDelay, FIELD_FLOAT ), DEFINE_FIELD( flDistSqr, FIELD_FLOAT ), DEFINE_FIELD( iszMyWeapon, FIELD_STRING ), @@ -10830,6 +11717,9 @@ BEGIN_SIMPLE_DATADESC( ScriptedNPCInteraction_t ) DEFINE_FIELD( matDesiredLocalToWorld, FIELD_VMATRIX ), DEFINE_FIELD( bValidOnCurrentEnemy, FIELD_BOOLEAN ), DEFINE_FIELD( flNextAttemptTime, FIELD_TIME ), +#ifdef MAPBASE + DEFINE_FIELD( MiscCriteria, FIELD_STRING ),//DEFINE_UTLVECTOR( MiscCriteria, FIELD_EMBEDDED ), +#endif END_DATADESC() //------------------------------------- @@ -11242,6 +12132,36 @@ bool CAI_BaseNPC::KeyValue( const char *szKeyName, const char *szValue ) return bResult; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +bool CAI_BaseNPC::GetKeyValue( const char *szKeyName, char *szValue, int iMaxLen ) +{ + // Why was GetKeyValue("squadname") pointless again? + /* + if (FStrEq(szKeyName, "squadname")) + { + // "squadname" does change initially and in InputSetSquad(), but not in SetSquad() itself. + // Probably not in any other function that changes the squad either. This is needed so we get + // an accurate reading of the squad name. + GetSquad() ? + Q_strncpy(szValue, GetSquad()->GetName(), iMaxLen) : + Q_strncpy(szValue, "", iMaxLen); + } + else*/ if (FStrEq(szKeyName, "additionalequipment")) + { + if (GetActiveWeapon()) + Q_strncpy(szValue, GetActiveWeapon()->GetClassname(), iMaxLen); + else + return false; + } + else + return BaseClass::GetKeyValue(szKeyName, szValue, iMaxLen); + + return true; +} +#endif + //----------------------------------------------------------------------------- // Purpose: Debug function to make this NPC freeze in place (or unfreeze). //----------------------------------------------------------------------------- @@ -11374,6 +12294,10 @@ CAI_BaseNPC::CAI_BaseNPC(void) m_bInChoreo = true; // assume so until call to UpdateEfficiency() SetCollisionGroup( COLLISION_GROUP_NPC ); + +#ifdef MAPBASE + m_iDynamicInteractionsAllowed = TRS_NONE; +#endif } //----------------------------------------------------------------------------- @@ -11521,6 +12445,7 @@ CAI_Pathfinder *CAI_BaseNPC::CreatePathfinder() return new CAI_Pathfinder( this ); } +#ifndef MAPBASE //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -11528,6 +12453,7 @@ void CAI_BaseNPC::InputSetRelationship( inputdata_t &inputdata ) { AddRelationship( inputdata.value.String(), inputdata.pActivator ); } +#endif //----------------------------------------------------------------------------- @@ -11540,6 +12466,39 @@ void CAI_BaseNPC::InputSetEnemyFilter( inputdata_t &inputdata ) m_hEnemyFilter = dynamic_cast(pFilter); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CAI_BaseNPC::InputSetHealthFraction( inputdata_t &inputdata ) +{ + // npc_helicopter uses SetHealth() instead of the regular NPC practice of TakeHealth() and TakeDamage(). + // It also also uses 50, 75, etc. and scales it by 0.01 for some reason. + // We're using the same model as InputSetHealth() and just letting npc_helicopter override it. No big deal. + // We're also adding support for its "whole number * 0.01" thing too. + float flFactor = inputdata.value.Float(); + if ( flFactor > 1.0f ) + { + flFactor *= 0.01f; + } + + // Excuse the complication... + float flNewHealth = (GetMaxHealth() * flFactor); + int iNewHealth = (int)flNewHealth; + if (flNewHealth < (GetMaxHealth() / 2)) + iNewHealth = (int)ceil(flNewHealth); + + int iDelta = abs(GetHealth() - iNewHealth); + if ( iNewHealth > GetHealth() ) + { + TakeHealth( iDelta, DMG_GENERIC ); + } + else if ( iNewHealth < GetHealth() ) + { + TakeDamage( CTakeDamageInfo( this, this, iDelta, DMG_GENERIC ) ); + } +} +#else //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -11556,6 +12515,7 @@ void CAI_BaseNPC::InputSetHealth( inputdata_t &inputdata ) TakeDamage( CTakeDamageInfo( this, this, iDelta, DMG_GENERIC ) ); } } +#endif //----------------------------------------------------------------------------- // Purpose: @@ -11598,7 +12558,11 @@ void CAI_BaseNPC::InputSetSquad( inputdata_t &inputdata ) //----------------------------------------------------------------------------- void CAI_BaseNPC::InputWake( inputdata_t &inputdata ) { +#ifdef MAPBASE + Wake( inputdata.pActivator ); +#else Wake(); +#endif // Check if we have a path to follow. This is normally done in StartNPC, // but putting the NPC to sleep will cancel it, so we have to do it again. @@ -11625,10 +12589,16 @@ void CAI_BaseNPC::InputForgetEntity( inputdata_t &inputdata ) { const char *pszEntityToForget = inputdata.value.String(); +#ifndef MAPBASE // I would assume this was here for a reason, but wildcards have nothing to do with ClearMemory(), so I really have no idea. if ( g_pDeveloper->GetInt() && pszEntityToForget[strlen( pszEntityToForget ) - 1] == '*' ) DevMsg( "InputForgetEntity does not support wildcards\n" ); +#endif +#ifdef MAPBASE + CBaseEntity *pEntity = gEntList.FindEntityGeneric( NULL, pszEntityToForget, this, inputdata.pActivator, inputdata.pCaller ); +#else CBaseEntity *pEntity = gEntList.FindEntityByName( NULL, pszEntityToForget ); +#endif if ( pEntity ) { if ( GetEnemy() == pEntity ) @@ -11660,7 +12630,11 @@ void CAI_BaseNPC::InputIgnoreDangerSounds( inputdata_t &inputdata ) void CAI_BaseNPC::InputUpdateEnemyMemory( inputdata_t &inputdata ) { const char *pszEnemy = inputdata.value.String(); +#ifdef MAPBASE + CBaseEntity *pEnemy = gEntList.FindEntityByName( NULL, pszEnemy, this, inputdata.pActivator, inputdata.pCaller ); +#else CBaseEntity *pEnemy = gEntList.FindEntityByName( NULL, pszEnemy ); +#endif if( pEnemy ) { @@ -11800,7 +12774,11 @@ bool CAI_BaseNPC::CineCleanup() if ( m_hForcedInteractionPartner ) { // We've finished a forced interaction. Let the mapmaker know. +#ifdef MAPBASE + m_OnForcedInteractionFinished.FireOutput( m_hInteractionPartner, this ); +#else m_OnForcedInteractionFinished.FireOutput( this, this ); +#endif } // Clear interaction partner, because we're not running a scripted sequence anymore @@ -12129,7 +13107,19 @@ bool CAI_BaseNPC::OnCalcBaseMove( AILocalMoveGoal_t *pMoveGoal, { if ( pMoveGoal->directTrace.pObstruction ) { +#ifdef MAPBASE + CBaseEntity *pObstruction = pMoveGoal->directTrace.pObstruction; + CBasePropDoor *pPropDoor = dynamic_cast( pObstruction ); + + // It could be another entity (e.g. a func_brush) parented to a blank door + if (!pPropDoor && pObstruction->GetParent()) + { + pObstruction = pObstruction->GetParent(); + pPropDoor = dynamic_cast( pObstruction ); + } +#else CBasePropDoor *pPropDoor = dynamic_cast( pMoveGoal->directTrace.pObstruction ); +#endif if ( pPropDoor && OnUpcomingPropDoor( pMoveGoal, pPropDoor, distClear, pResult ) ) { return true; @@ -12221,7 +13211,11 @@ bool CAI_BaseNPC::OnUpcomingPropDoor( AILocalMoveGoal_t *pMoveGoal, m_hOpeningDoor = NULL; } +#ifdef MAPBASE + if ((CapabilitiesGet() & bits_CAP_DOORS_GROUP) && !pDoor->IsDoorLocked() && (pDoor->IsDoorClosed() || pDoor->IsDoorClosing()) && pDoor->PassesDoorFilter(this)) +#else if ((CapabilitiesGet() & bits_CAP_DOORS_GROUP) && !pDoor->IsDoorLocked() && (pDoor->IsDoorClosed() || pDoor->IsDoorClosing())) +#endif { AI_Waypoint_t *pOpenDoorRoute = NULL; @@ -12950,6 +13944,182 @@ void CAI_BaseNPC::ParseScriptedNPCInteractions( void ) ScriptedNPCInteraction_t sInteraction; sInteraction.iszInteractionName = AllocPooledString( pkvNode->GetName() ); +#ifdef MAPBASE + // The method for parsing dynamic interactions has been reworked. + // Unknown values are now stored as response contexts to test against response criteria. + + bool bValidInteraction = true; + + // Default values + UTIL_StringToVector( sInteraction.vecRelativeOrigin.Base(), "0 0 0" ); + sInteraction.flDelay = 10.0; + sInteraction.flDistSqr = (DSS_MAX_DIST * DSS_MAX_DIST); + + // Misc. response criteria + char *szCriteria = ""; + + KeyValues *pCurNode = pkvNode->GetFirstSubKey(); + const char *szName = NULL; + const char *szValue = NULL; + while (pCurNode) + { + szName = pCurNode->GetName(); + szValue = pCurNode->GetString(); + + if (!szName || !szValue) + { + DevWarning("ERROR: Invalid dynamic interaction string\n"); + pCurNode = pCurNode->GetNextKey(); + } + + if (!Q_strncmp(szName, "classname", 9)) + { + bool pass = false; + if (Q_strstr(szValue, "!=")) + { + szValue += 2; + pass = true; + } + + if (!FStrEq(GetClassname(), szValue)) + pass = !pass; + } + else if (!Q_strncmp(szName, "mapbase", 7)) + { + sInteraction.iFlags |= SCNPC_FLAG_MAPBASE_ADDITION; + } + else if (!Q_strncmp(szName, "trigger", 7)) + { + if (!Q_strncmp(szValue, "auto_in_combat", 14)) + sInteraction.iTriggerMethod = SNPCINT_AUTOMATIC_IN_COMBAT; + } + else if (!Q_strncmp(szValue, "loop_break_trigger", 18)) + { + char szTrigger[256]; + Q_strncpy( szTrigger, szValue, sizeof(szTrigger) ); + char *pszParam = strtok( szTrigger, " " ); + while (pszParam) + { + if ( !Q_strncmp( pszParam, "on_damage", 9) ) + { + sInteraction.iLoopBreakTriggerMethod |= SNPCINT_LOOPBREAK_ON_DAMAGE; + } + else if ( !Q_strncmp( pszParam, "on_flashlight_illum", 19) ) + { + sInteraction.iLoopBreakTriggerMethod |= SNPCINT_LOOPBREAK_ON_FLASHLIGHT_ILLUM; + } + + pszParam = strtok(NULL," "); + } + } + else if (!Q_strncmp(szName, "origin_relative", 15)) + UTIL_StringToVector( sInteraction.vecRelativeOrigin.Base(), szValue ); + else if (!Q_strncmp(szName, "angles_relative", 15)) + { + sInteraction.iFlags |= SCNPC_FLAG_TEST_OTHER_ANGLES; + UTIL_StringToVector( sInteraction.angRelativeAngles.Base(), szValue ); + } + else if (!Q_strncmp(szName, "velocity_relative", 17)) + { + sInteraction.iFlags |= SCNPC_FLAG_TEST_OTHER_VELOCITY; + UTIL_StringToVector( sInteraction.vecRelativeVelocity.Base(), szValue ); + } +#ifdef MAPBASE + else if (!Q_strncmp(szName, "end_position", 12)) + { + sInteraction.iFlags |= SCNPC_FLAG_TEST_END_POSITION; + UTIL_StringToVector( sInteraction.vecRelativeEndPos.Base(), szValue ); + } +#endif + + else if (!Q_strncmp(szName, "entry_sequence", 14)) + sInteraction.sPhases[SNPCINT_ENTRY].iszSequence = AllocPooledString( szValue ); + else if (!Q_strncmp(szName, "entry_activity", 14)) + sInteraction.sPhases[SNPCINT_ENTRY].iActivity = GetActivityID( szValue ); + + else if (!Q_strncmp(szName, "sequence", 8)) + sInteraction.sPhases[SNPCINT_SEQUENCE].iszSequence = AllocPooledString( szValue ); + else if (!Q_strncmp(szName, "activity", 8)) + sInteraction.sPhases[SNPCINT_SEQUENCE].iActivity = GetActivityID( szValue ); + + else if (!Q_strncmp(szName, "exit_sequence", 13)) + sInteraction.sPhases[SNPCINT_EXIT].iszSequence = AllocPooledString( szValue ); + else if (!Q_strncmp(szName, "exit_activity", 13)) + sInteraction.sPhases[SNPCINT_EXIT].iActivity = GetActivityID(szValue); + + else if (!Q_strncmp(szName, "delay", 5)) + sInteraction.flDelay = atof(szValue); + else if (!Q_strncmp(szName, "origin_max_delta", 16)) + sInteraction.flDistSqr = atof(szValue); + + else if (!Q_strncmp(szName, "loop_in_action", 14) && !FStrEq(szValue, "0")) + sInteraction.iFlags |= SCNPC_FLAG_LOOP_IN_ACTION; + + else if (!Q_strncmp(szName, "dont_teleport_at_end", 20)) + { + if ( !Q_stricmp( szValue, "me" ) || !Q_stricmp( szValue, "both" ) ) + sInteraction.iFlags |= SCNPC_FLAG_DONT_TELEPORT_AT_END_ME; + else if ( !Q_stricmp( szValue, "them" ) || !Q_stricmp( szValue, "both" ) ) + sInteraction.iFlags |= SCNPC_FLAG_DONT_TELEPORT_AT_END_THEM; + } + + else if (!Q_strncmp(szName, "needs_weapon", 12)) + { + if ( !Q_strncmp( szValue, "ME", 2 ) ) + sInteraction.iFlags |= SCNPC_FLAG_NEEDS_WEAPON_ME; + else if ( !Q_strncmp( szValue, "THEM", 4 ) ) + sInteraction.iFlags |= SCNPC_FLAG_NEEDS_WEAPON_THEM; + else if ( !Q_strncmp( szValue, "BOTH", 4 ) ) + { + sInteraction.iFlags |= SCNPC_FLAG_NEEDS_WEAPON_ME; + sInteraction.iFlags |= SCNPC_FLAG_NEEDS_WEAPON_THEM; + } + } + + else if (!Q_strncmp(szName, "weapon_mine", 11)) + { + sInteraction.iFlags |= SCNPC_FLAG_NEEDS_WEAPON_ME; + sInteraction.iszMyWeapon = AllocPooledString( szValue ); + } + else if (!Q_strncmp(szName, "weapon_theirs", 13)) + { + sInteraction.iFlags |= SCNPC_FLAG_NEEDS_WEAPON_THEM; + sInteraction.iszTheirWeapon = AllocPooledString( szValue ); + } + + // Add anything else to our miscellaneous criteria + else + { + szCriteria = UTIL_VarArgs("%s,%s:%s", szCriteria, szName, szValue); + + /* + ResponseContext_t context; + context.m_iszName = AllocPooledString(szName); + context.m_iszValue = AllocPooledString(szValue); + context.m_fExpirationTime = 0.0; + + DevMsg("ADDING CONTEXT: \"%s, %s\"\n", szName, szValue); + + sInteraction.MiscCriteria.AddToTail(context); + */ + } + + pCurNode = pCurNode->GetNextKey(); + } + + if (!bValidInteraction) + { + DevMsg("Scripted interaction %s rejected by %s\n", pkvNode->GetName(), GetClassname()); + pkvNode = pkvNode->GetNextKey(); + continue; + } + + if (szCriteria[0] == ',') + { + szCriteria += 1; + sInteraction.MiscCriteria = AllocPooledString(szCriteria); + } +#else // Trigger method const char *pszTrigger = pkvNode->GetString( "trigger", NULL ); if ( pszTrigger ) @@ -13099,6 +14269,7 @@ void CAI_BaseNPC::ParseScriptedNPCInteractions( void ) sInteraction.iFlags |= SCNPC_FLAG_NEEDS_WEAPON_THEM; sInteraction.iszTheirWeapon = AllocPooledString( pszWeaponName ); } +#endif // Add it to the list AddScriptedNPCInteraction( &sInteraction ); @@ -13336,6 +14507,11 @@ void CAI_BaseNPC::StartScriptedNPCInteraction( CAI_BaseNPC *pOtherNPC, ScriptedN //----------------------------------------------------------------------------- bool CAI_BaseNPC::CanRunAScriptedNPCInteraction( bool bForced ) { +#ifdef MAPBASE + if ( m_iDynamicInteractionsAllowed == TRS_FALSE && !bForced ) + return false; +#endif + if ( m_NPCState != NPC_STATE_IDLE && m_NPCState != NPC_STATE_ALERT && m_NPCState != NPC_STATE_COMBAT ) return false; @@ -13419,6 +14595,11 @@ void CAI_BaseNPC::CheckForScriptedNPCInteractions( void ) if ( pInteraction->flNextAttemptTime > gpGlobals->curtime ) continue; +#ifdef MAPBASE + if ( !InteractionIsAllowed(pNPC, pInteraction) ) + continue; +#endif + Vector vecOrigin; QAngle angAngles; if ( InteractionCouldStart( pNPC, pInteraction, vecOrigin, angAngles ) ) @@ -13472,23 +14653,82 @@ void CAI_BaseNPC::CalculateValidEnemyInteractions( void ) continue; // Check the specific weapon type +#ifdef MAPBASE + if ( pInteraction->iszMyWeapon != NULL_STRING ) + { + const char *myweapon = STRING(pInteraction->iszMyWeapon); + bool pass = false; + if (Q_strstr(myweapon, "!=")) + { + myweapon += 2; + pass = true; + } + + if (Q_strstr(myweapon, "WEPCLASS")) + pass = (GetActiveWeapon()->WeaponClassFromString(myweapon) == GetActiveWeapon()->WeaponClassify()) ? !pass : pass; + else + pass = (GetActiveWeapon()->m_iClassname == pInteraction->iszMyWeapon) ? !pass : pass; + + if (!pass) + continue; + } +#else if ( pInteraction->iszMyWeapon != NULL_STRING && GetActiveWeapon()->m_iClassname != pInteraction->iszMyWeapon ) continue; +#endif } if ( pInteraction->iFlags & SCNPC_FLAG_NEEDS_WEAPON_THEM ) { if ( !pNPC->GetActiveWeapon() ) continue; +#ifdef MAPBASE + if ( pInteraction->iszTheirWeapon != NULL_STRING ) + { + const char *theirweapon = STRING(pInteraction->iszTheirWeapon); + bool pass = false; + if (Q_strstr(theirweapon, "!=")) + { + theirweapon += 2; + pass = true; + } + + if (Q_strstr(theirweapon, "WEPCLASS")) + pass = (pNPC->GetActiveWeapon()->WeaponClassFromString(theirweapon) == pNPC->GetActiveWeapon()->WeaponClassify()) ? !pass : pass; + else + pass = (pNPC->GetActiveWeapon()->m_iClassname == pInteraction->iszTheirWeapon) ? !pass : pass; + + if (!pass) + continue; + } +#else // Check the specific weapon type if ( pInteraction->iszTheirWeapon != NULL_STRING && pNPC->GetActiveWeapon()->m_iClassname != pInteraction->iszTheirWeapon ) continue; +#endif } // Script needs the other NPC, so make sure they're not dead if ( !pNPC->IsAlive() ) continue; +#ifdef MAPBASE + // If they have an interaction with the same name, it means we're not supposed to engage with them + bool bSame = false; + for ( int i2 = 0; i2 < pNPC->m_ScriptedInteractions.Count(); i2++ ) + { + // These strings are pooled, so this works + if (m_ScriptedInteractions[i].iszInteractionName == pNPC->m_ScriptedInteractions[i2].iszInteractionName) + { + bSame = true; + break; + } + } + + if (bSame) + continue; +#endif + // Use sequence? or activity? if ( pInteraction->sPhases[SNPCINT_SEQUENCE].iActivity != ACT_INVALID ) { @@ -13505,6 +14745,50 @@ void CAI_BaseNPC::CalculateValidEnemyInteractions( void ) continue; } +#ifdef MAPBASE + if (pInteraction->MiscCriteria != NULL_STRING) + { + // Test against response system criteria + AI_CriteriaSet set; + ModifyOrAppendCriteria( set ); + CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); + if( pPlayer ) + pPlayer->ModifyOrAppendPlayerCriteria( set ); + ReAppendContextCriteria( set ); + + DevMsg("Testing %s misc criteria\n", pInteraction->MiscCriteria); + + int index; + const char *criteriavalue; + char key[128]; + char value[128]; + const char *p = STRING(pInteraction->MiscCriteria); + while ( p ) + { + p = SplitContext( p, key, sizeof( key ), value, sizeof( value ), NULL ); + + index = set.FindCriterionIndex(key); + if (index != -1) + { + criteriavalue = set.GetValue(index); + if (!Matcher_Match(value, criteriavalue)) + { + continue; + } + } + else + { + // Test with empty string in case our criteria is != or something + criteriavalue = ""; + if (!Matcher_Match(value, criteriavalue)) + { + continue; + } + } + } + } +#endif + pInteraction->bValidOnCurrentEnemy = true; bFound = true; @@ -13572,7 +14856,11 @@ void CAI_BaseNPC::CheckForcedNPCInteractions( void ) if ( m_hForcedInteractionPartner ) { // We've aborted a forced interaction. Let the mapmaker know. +#ifdef MAPBASE + m_OnForcedInteractionAborted.FireOutput( pNPC, this ); +#else m_OnForcedInteractionAborted.FireOutput( this, this ); +#endif } CleanupForcedInteraction(); @@ -13582,7 +14870,11 @@ void CAI_BaseNPC::CheckForcedNPCInteractions( void ) } StartScriptedNPCInteraction( pNPC, pInteraction, vecOrigin, angAngles ); +#ifdef MAPBASE + m_OnForcedInteractionStarted.FireOutput( pNPC, this ); +#else m_OnForcedInteractionStarted.FireOutput( this, this ); +#endif } @@ -13648,6 +14940,25 @@ bool CanNPCsTradePlaces( CAI_BaseNPC *pNPC1, CAI_BaseNPC *pNPC2, bool bDebug ) return true; } +#ifdef MAPBASE +bool CAI_BaseNPC::InteractionIsAllowed( CAI_BaseNPC *pOtherNPC, ScriptedNPCInteraction_t *pInteraction ) +{ + // Now that female citizens have hunter interactions, Alyx is vulnerable to being murdered by hunters *dynamically*! + // Citizens also have antlion interaction kill animations, so antlions could potentially murder her as well. + // + // Forced interactions should still work, but this prevents regular interactions from targeting vital allies. + // Hopefully there aren't any maps that already have hunters murder Barneys. + if (pOtherNPC->Classify() == CLASS_PLAYER_ALLY_VITAL) + return false; + + // This convar allows all NPCs to perform Mapbase interactions for both testing and player fun. + if (ai_dynint_always_enabled.GetBool() && m_iDynamicInteractionsAllowed != TRS_FALSE) + return true; + + // m_iDynamicInteractionsAllowed == TRS_FALSE case is already handled in CanRunAScriptedNPCInteraction(). + return !(pInteraction->iFlags & SCNPC_FLAG_MAPBASE_ADDITION && m_iDynamicInteractionsAllowed == TRS_NONE); +} +#endif //----------------------------------------------------------------------------- // Purpose: @@ -13789,6 +15100,34 @@ bool CAI_BaseNPC::InteractionCouldStart( CAI_BaseNPC *pOtherNPC, ScriptedNPCInte return false; } +#ifdef MAPBASE + // Make sure we could fit at the sequence end position too. + if (pInteraction->iFlags & SCNPC_FLAG_TEST_END_POSITION) + { + VMatrix matTestToWorld; + matTestToWorld.SetupMatrixOrgAngles(pInteraction->vecRelativeEndPos, angMyCurrent); + MatrixMultiply( matMeToWorld, matTestToWorld, matLocalToWorld ); + Vector vecPos = (matLocalToWorld.GetTranslation()); + + // Start from the NPC's position. + AI_TraceHull( pOtherNPC->GetAbsOrigin(), vecPos, GetHullMins(), GetHullMaxs(), MASK_SOLID, &traceFilter, &tr ); + if ( tr.fraction != 1.0 ) + { + if ( bDebug ) + { + NDebugOverlay::Box( vecPos, GetHullMins(), GetHullMaxs(), 255,0,0, 100, 1.0 ); + } + return false; + } + else if ( bDebug ) + { + //NDebugOverlay::Box( vecPos, GetHullMins(), GetHullMaxs(), 0,255,0, 100, 1.0 ); + + NDebugOverlay::Axis( vecPos, angAngles, 20, true, 10.0 ); + } + } +#endif + // If the NPCs are swapping places during this interaction, make sure they can fit at each // others' origins before allowing the interaction. if ( !CanNPCsTradePlaces( this, pOtherNPC, bDebug ) ) @@ -13985,6 +15324,9 @@ void CAI_BaseNPC::ModifyOrAppendCriteria( AI_CriteriaSet& set ) set.AppendCriteria( "timesinceseenplayer", "-1" ); } +#ifdef MAPBASE + ModifyOrAppendEnemyCriteria(set, GetEnemy()); +#else // Append distance to my enemy if ( GetEnemy() ) { @@ -13994,8 +15336,96 @@ void CAI_BaseNPC::ModifyOrAppendCriteria( AI_CriteriaSet& set ) { set.AppendCriteria( "distancetoenemy", "-1" ); } +#endif + +#ifdef MAPBASE + // Append our gender + // I know scenes can use $gender01, but some rules now use more than scenes. + const char *modelname = STRING(GetModelName()); + if (modelname) + { + set.AppendCriteria( "gender", UTIL_VarArgs("%i", soundemitterbase->GetActorGender(modelname)) ); + } + + if (IsInSquad()) + { + set.AppendCriteria( "insquad", "1" ); + set.AppendCriteria( "squadmates", UTIL_VarArgs( "%i", GetSquad()->NumMembers() ) ); + set.AppendCriteria( "isleader", GetSquad()->IsLeader(this) ? "0" : "1" ); + } + else + { + set.AppendCriteria( "insquad", "0" ); + } +#endif } +#ifdef MAPBASE +// Went for a different structure that directly takes AI_CriteriaSet for modifiers +/* +#define GetModifiersFromCriteria( function, output, maxlen ) AI_CriteriaSet set; \ + function; \ + for (int i = 0; i < set.GetCount(); i++) { Q_snprintf(output, maxlen, "%s,%s:%s", output, set.GetName(i), set.GetValue(i)); } \ + memmove(output, output + 1, strlen(output + 1) + 1); \ + */ + +//----------------------------------------------------------------------------- +// Purpose: Appends enemy criteria so some classes could re-define it for, say, killing something +//----------------------------------------------------------------------------- +void CAI_BaseNPC::ModifyOrAppendEnemyCriteria( AI_CriteriaSet& set, CBaseEntity *pEnemy ) +{ + if ( pEnemy ) + { + set.AppendCriteria( "enemy", pEnemy->GetClassname() ); + set.AppendCriteria( "enemyclass", g_pGameRules->AIClassText( pEnemy->Classify() ) ); // UTIL_VarArgs("%i", pEnemy->Classify()) + set.AppendCriteria( "distancetoenemy", UTIL_VarArgs( "%f", EnemyDistance(pEnemy) ) ); + set.AppendCriteria( "timesincecombat", "-1" ); + } + else + { + if ( GetLastEnemyTime() == 0.0 ) + set.AppendCriteria( "timesincecombat", "999999.0" ); + else + set.AppendCriteria( "timesincecombat", UTIL_VarArgs( "%f", gpGlobals->curtime - GetLastEnemyTime() ) ); + + set.AppendCriteria( "distancetoenemy", "-1" ); + } +} + +/* +//----------------------------------------------------------------------------- +// Purpose: Gets enemy criteria in context form +//----------------------------------------------------------------------------- +void CAI_BaseNPC::GetEnemyCriteriaModifiers( CBaseEntity *pEnemy, char *szCriteria, int iMaxLen ) +{ + GetModifiersFromCriteria(ModifyOrAppendEnemyCriteria(set, pEnemy), szCriteria, iMaxLen); +} +*/ + +//----------------------------------------------------------------------------- +// Purpose: Appends damage criteria for pain sounds, death sounds, etc. +//----------------------------------------------------------------------------- +void CAI_BaseNPC::ModifyOrAppendDamageCriteria( AI_CriteriaSet& set, const CTakeDamageInfo &info ) +{ + if ( info.GetAttacker() && info.GetAttacker() != this ) + set.AppendCriteria("attacker", info.GetAttacker()->GetClassname()); + else + set.AppendCriteria("attacker", ""); + + set.AppendCriteria("damagetype", UTIL_VarArgs("%i", info.GetDamageType())); +} + +/* +//----------------------------------------------------------------------------- +// Purpose: Gets damage criteria in context form +//----------------------------------------------------------------------------- +void CAI_BaseNPC::GetDamageCriteriaModifiers( const CTakeDamageInfo &info, char *szCriteria, int iMaxLen ) +{ + GetModifiersFromCriteria(ModifyOrAppendDamageCriteria(set, info), szCriteria, iMaxLen); +} +*/ +#endif + //----------------------------------------------------------------------------- // If I were crouching at my current location, could I shoot this target? //----------------------------------------------------------------------------- @@ -14038,6 +15468,16 @@ bool CAI_BaseNPC::IsCrouchedActivity( Activity activity ) case ACT_COVER_PISTOL_LOW: case ACT_COVER_SMG1_LOW: case ACT_RELOAD_SMG1_LOW: +#ifdef MAPBASE + //case ACT_RELOAD_AR2_LOW: + case ACT_RELOAD_PISTOL_LOW: + case ACT_RELOAD_SHOTGUN_LOW: + + case ACT_RANGE_AIM_LOW: + case ACT_RANGE_AIM_AR2_LOW: + case ACT_RANGE_AIM_SMG1_LOW: + case ACT_RANGE_AIM_PISTOL_LOW: +#endif return true; } diff --git a/sp/src/game/server/ai_basenpc.h b/sp/src/game/server/ai_basenpc.h index 2131a0f4..6f8d5450 100644 --- a/sp/src/game/server/ai_basenpc.h +++ b/sp/src/game/server/ai_basenpc.h @@ -95,6 +95,36 @@ extern bool AIStrongOpt( void ); // Max's of the box used to search for a weapon to pick up. 45x45x~8 ft. #define WEAPON_SEARCH_DELTA Vector( 540, 540, 100 ) +#ifdef MAPBASE +// Defines Mapbase's extended NPC response system usage. +#define EXPANDED_RESPONSE_SYSTEM_USAGE +#endif + +#ifdef EXPANDED_RESPONSE_SYSTEM_USAGE + +// This macro implements the response system on any NPC, particularly non-actors that can't use CAI_ExpresserHost. +// NOTE: Because of the lack of CAI_ExpresserHost, some Response System settings like odds, delays, etc. cannot be used. +// It's recommended to just use CAI_ExpresserHost if possible. +#define DeclareResponseSystem IResponseSystem *GetResponseSystem() { extern IResponseSystem *g_pResponseSystem; return g_pResponseSystem; } + +// Default CAI_ExpresserHost implementation for NPCs using CAI_ExpresserHost. +#define DeclareDefaultExpresser() virtual CAI_Expresser *CreateExpresser( void ) { m_pExpresser = new CAI_Expresser(this); if (!m_pExpresser) return NULL; m_pExpresser->Connect(this); return m_pExpresser; } \\ + virtual CAI_Expresser *GetExpresser() { return m_pExpresser; } \\ + virtual void PostConstructor(const char *szClassname) { BaseClass::PostConstructor(szClassname); CreateExpresser(); } \\ + private: \\ + CAI_Expresser *m_pExpresser; \\ + public: + +// Variant of DeclareDefaultExpresser() that doesn't implement its own PostConstructor. +// CreateExpresser() should still be called from there. +#define DeclareDefaultExpresser_ExistingPC() virtual CAI_Expresser *CreateExpresser( void ) { m_pExpresser = new CAI_Expresser(this); if (!m_pExpresser) return NULL; m_pExpresser->Connect(this); return m_pExpresser; } \\ + virtual CAI_Expresser *GetExpresser() { return m_pExpresser; } \\ + private: \\ + CAI_Expresser *m_pExpresser; \\ + public: + +#endif + enum Interruptability_t { GENERAL_INTERRUPTABILITY, @@ -316,6 +346,10 @@ struct UnreachableEnt_t #define SCNPC_FLAG_NEEDS_WEAPON_THEM ( 1 << 5 ) #define SCNPC_FLAG_DONT_TELEPORT_AT_END_ME ( 1 << 6 ) #define SCNPC_FLAG_DONT_TELEPORT_AT_END_THEM ( 1 << 7 ) +#ifdef MAPBASE +#define SCNPC_FLAG_MAPBASE_ADDITION ( 1 << 8 ) +#define SCNPC_FLAG_TEST_END_POSITION ( 1 << 9 ) +#endif // ----------------------------------------- // Scripted NPC interaction trigger methods @@ -387,6 +421,10 @@ struct ScriptedNPCInteraction_t flNextAttemptTime = 0; iszMyWeapon = NULL_STRING; iszTheirWeapon = NULL_STRING; +#ifdef MAPBASE + vecRelativeEndPos = vec3_origin; + MiscCriteria = NULL_STRING; +#endif for ( int i = 0; i < SNPCINT_NUM_PHASES; i++) { @@ -403,6 +441,9 @@ struct ScriptedNPCInteraction_t Vector vecRelativeOrigin; // (forward, right, up) QAngle angRelativeAngles; Vector vecRelativeVelocity; // Desired relative velocity of the other NPC +#ifdef MAPBASE + Vector vecRelativeEndPos; // Relative position that the NPC must fit in +#endif float flDelay; // Delay before interaction can be used again float flDistSqr; // Max distance sqr from the relative origin the NPC is allowed to be to trigger string_t iszMyWeapon; // Classname of the weapon I'm holding, if any @@ -415,6 +456,13 @@ struct ScriptedNPCInteraction_t float flNextAttemptTime; +#ifdef MAPBASE + // Unrecognized keyvalues are tested against response criteria later. + // This was originally a CUtlVector that carries response contexts, but I couldn't get it working due to some CUtlVector-struct shenanigans. + // It works when we use a single string_t that's split and read each time the code runs, but feel free to improve on this. + string_t MiscCriteria; // CUtlVector +#endif + DECLARE_SIMPLE_DATADESC(); }; @@ -510,6 +558,9 @@ public: virtual unsigned int PhysicsSolidMaskForEntity( void ) const; virtual bool KeyValue( const char *szKeyName, const char *szValue ); +#ifdef MAPBASE + virtual bool GetKeyValue( const char *szKeyName, char *szValue, int iMaxLen ); +#endif //--------------------------------- @@ -565,6 +616,10 @@ public: // Thinking, including core thinking, movement, animation virtual void NPCThink( void ); +#ifdef MAPBASE + void InputSetThinkNPC( inputdata_t &inputdata ); +#endif + // Core thinking (schedules & tasks) virtual void RunAI( void );// core ai function! @@ -853,6 +908,11 @@ public: bool DidChooseEnemy() const { return !m_bSkippedChooseEnemy; } +#ifdef MAPBASE + void InputSetCondition( inputdata_t &inputdata ); + void InputClearCondition( inputdata_t &inputdata ); +#endif + private: CAI_ScheduleBits m_Conditions; CAI_ScheduleBits m_CustomInterruptConditions; //Bit string assembled by the schedule running, then @@ -897,6 +957,10 @@ public: void UpdateSleepState( bool bInPVS ); virtual void Wake( bool bFireOutput = true ); +#ifdef MAPBASE + // A version of Wake() that takes an activator + virtual void Wake( CBaseEntity *pActivator ); +#endif void Sleep(); bool WokeThisTick() const; @@ -926,6 +990,10 @@ public: Activity TranslateActivity( Activity idealActivity, Activity *pIdealWeaponActivity = NULL ); Activity NPC_TranslateActivity( Activity eNewActivity ); +#ifdef MAPBASE + Activity TranslateCrouchActivity( Activity baseAct ); + virtual Activity NPC_BackupActivity( Activity eNewActivity ); +#endif Activity GetActivity( void ) { return m_Activity; } virtual void SetActivity( Activity NewActivity ); Activity GetIdealActivity( void ) { return m_IdealActivity; } @@ -1122,6 +1190,19 @@ private: public: CAI_MoveMonitor m_CommandMoveMonitor; +#ifdef MAPBASE + ThreeState_t m_FriendlyFireOverride = TRS_NONE; + virtual bool FriendlyFireEnabled(); + void InputSetFriendlyFire( inputdata_t &inputdata ); + + // Grenade-related functions from Combine soldiers ported to ai_basenpc so they could be shared. + // + // This is necessary because other NPCs can use them now and many instances where they were used relied on dynamic_casts. + virtual Vector GetAltFireTarget() { return GetEnemy() ? GetEnemy()->BodyTarget(Weapon_ShootPosition()) : vec3_origin; } + virtual void DelayGrenadeCheck(float delay) { ; } + virtual void AddGrenades( int inc, CBaseEntity *pLastGrenade = NULL ) { ; } +#endif + //----------------------------------------------------- // Dynamic scripted NPC interactions //----------------------------------------------------- @@ -1137,6 +1218,11 @@ protected: void CheckForScriptedNPCInteractions( void ); void CalculateValidEnemyInteractions( void ); void CheckForcedNPCInteractions( void ); +#ifdef MAPBASE + // This is checked during automatic dynamic interactions, but not during forced interactions. + // This is so we can control interaction permissions while still letting forced interactions play when needed. + virtual bool InteractionIsAllowed( CAI_BaseNPC *pOtherNPC, ScriptedNPCInteraction_t *pInteraction ); +#endif bool InteractionCouldStart( CAI_BaseNPC *pOtherNPC, ScriptedNPCInteraction_t *pInteraction, Vector &vecOrigin, QAngle &angAngles ); virtual bool CanRunAScriptedNPCInteraction( bool bForced = false ); bool IsRunningDynamicInteraction( void ) { return (m_iInteractionState != NPCINT_NOT_RUNNING && (m_hCine != NULL)); } @@ -1162,10 +1248,20 @@ private: bool m_bCannotDieDuringInteraction; int m_iInteractionState; int m_iInteractionPlaying; +#ifdef MAPBASE +public: +#endif CUtlVector m_ScriptedInteractions; float m_flInteractionYaw; +#ifdef MAPBASE + // Allows mappers to control dynamic interactions. + // DI added by Mapbase requires this to be on TRS_TRUE (1). Others, like Alyx's interactions, only require TRS_NONE (2). + // TRS_FALSE (0) disables all dynamic interactions, including existing ones. + ThreeState_t m_iDynamicInteractionsAllowed; +#endif + public: //----------------------------------------------------- @@ -1209,6 +1305,10 @@ public: virtual void PlayerHasIlluminatedNPC( CBasePlayer *pPlayer, float flDot ); virtual void ModifyOrAppendCriteria( AI_CriteriaSet& set ); +#ifdef MAPBASE + virtual void ModifyOrAppendEnemyCriteria( AI_CriteriaSet& set, CBaseEntity *pEnemy ); + virtual void ModifyOrAppendDamageCriteria( AI_CriteriaSet& set, const CTakeDamageInfo &info ); +#endif protected: float SoundWaitTime() const { return m_flSoundWaitTime; } @@ -1226,6 +1326,11 @@ public: int CapabilitiesRemove( int capabilities ); void CapabilitiesClear( void ); +#ifdef MAPBASE + void InputAddCapabilities( inputdata_t &inputdata ); + void InputRemoveCapabilities( inputdata_t &inputdata ); +#endif + private: int m_afCapability; // tells us what a npc can/can't do. @@ -1562,8 +1667,25 @@ public: bool IsWeaponStateChanging( void ); void SetDesiredWeaponState( DesiredWeaponState_t iState ) { m_iDesiredWeaponState = iState; } +#ifdef MAPBASE + virtual bool DoHolster(void); + virtual bool DoUnholster(void); + + virtual bool ShouldUnholsterWeapon() { return GetState() == NPC_STATE_COMBAT && CanUnholsterWeapon(); } + virtual bool CanUnholsterWeapon() { return IsWeaponHolstered(); } + + void InputGiveWeaponHolstered( inputdata_t &inputdata ); + void InputChangeWeapon( inputdata_t &inputdata ); + void InputPickupWeapon( inputdata_t &inputdata ); + void InputPickupItem( inputdata_t &inputdata ); +#endif + // NOTE: The Shot Regulator is used to manage the RangeAttack1 weapon. inline CAI_ShotRegulator* GetShotRegulator() { return &m_ShotRegulator; } +#ifdef MAPBASE + // A special function for ai_weaponmodifier. + inline void SetShotRegulator(CAI_ShotRegulator NewRegulator) { m_ShotRegulator = NewRegulator; } +#endif virtual void OnRangeAttack1(); protected: @@ -1582,6 +1704,10 @@ protected: float m_flLastAttackTime; // Last time that I attacked my current enemy float m_flLastEnemyTime; float m_flNextWeaponSearchTime; // next time to search for a better weapon +#ifdef MAPBASE +public: + int m_iLastHolsteredWeapon; +#endif string_t m_iszPendingWeapon; // THe NPC should create and equip this weapon. bool m_bIgnoreUnseenEnemies; @@ -1624,6 +1750,10 @@ public: void SetHintGroup( string_t name, bool bHintGroupNavLimiting = false ); bool IsLimitingHintGroups( void ) { return m_bHintGroupNavLimiting; } +#ifdef MAPBASE + void InputSetHintGroup( inputdata_t &inputdata ) { SetHintGroup(inputdata.value.StringID()); } +#endif + //--------------------------------- CAI_TacticalServices *GetTacticalServices() { return m_pTacticalServices; } @@ -1663,7 +1793,9 @@ public: //----------------------------------------------------- void InitRelationshipTable( void ); +#ifndef MAPBASE void AddRelationship( const char *pszRelationship, CBaseEntity *pActivator ); +#endif virtual void AddEntityRelationship( CBaseEntity *pEntity, Disposition_t nDisposition, int nPriority ); virtual void AddClassRelationship( Class_T nClass, Disposition_t nDisposition, int nPriority ); @@ -1695,7 +1827,9 @@ public: //--------------------------------- +#ifndef MAPBASE // Moved to CBaseCombatCharacter virtual CBaseEntity *FindNamedEntity( const char *pszName, IEntityFindFilter *pFilter = NULL ); +#endif //--------------------------------- // States @@ -1706,7 +1840,12 @@ public: virtual bool ShouldLookForBetterWeapon(); bool Weapon_IsBetterAvailable ( void ) ; virtual Vector Weapon_ShootPosition( void ); +#ifdef MAPBASE + virtual CBaseCombatWeapon* GiveWeapon( string_t iszWeaponName, bool bDiscardCurrent = true ); + virtual CBaseCombatWeapon* GiveWeaponHolstered( string_t iszWeaponName ); +#else virtual void GiveWeapon( string_t iszWeaponName ); +#endif virtual void OnGivenWeapon( CBaseCombatWeapon *pNewWeapon ) { } bool IsMovingToPickupWeapon(); virtual bool WeaponLOSCondition(const Vector &ownerPos, const Vector &targetPos, bool bSetConditions); @@ -1804,16 +1943,27 @@ public: //--------------------------------- virtual void PickupWeapon( CBaseCombatWeapon *pWeapon ); +#ifdef MAPBASE + virtual void PickupItem( CBaseEntity *pItem ); +#else virtual void PickupItem( CBaseEntity *pItem ) { }; +#endif CBaseEntity* DropItem( const char *pszItemName, Vector vecPos, QAngle vecAng );// drop an item. //--------------------------------- // Inputs //--------------------------------- +#ifndef MAPBASE // Moved to CBaseCombatCharacter void InputSetRelationship( inputdata_t &inputdata ); +#endif void InputSetEnemyFilter( inputdata_t &inputdata ); +#ifdef MAPBASE + // This is virtual so npc_helicopter can override it + virtual void InputSetHealthFraction( inputdata_t &inputdata ); +#else void InputSetHealth( inputdata_t &inputdata ); +#endif void InputBeginRappel( inputdata_t &inputdata ); void InputSetSquad( inputdata_t &inputdata ); void InputWake( inputdata_t &inputdata ); @@ -1904,6 +2054,13 @@ public: COutputEvent m_OnForcedInteractionAborted; COutputEvent m_OnForcedInteractionFinished; +#ifdef MAPBASE + COutputEHANDLE m_OnHolsterWeapon; + COutputEHANDLE m_OnUnholsterWeapon; + + COutputEHANDLE m_OnItemPickup; +#endif + public: // use this to shrink the bbox temporarily void SetHullSizeNormal( bool force = false ); @@ -3059,10 +3216,19 @@ public: // NOTE: YOU MUST DEFINE THE OUTPUTS IN YOUR CLASS'S DATADESC! // THE DO SO, INSERT THE FOLLOWING MACRO INTO YOUR CLASS'S DATADESC. // +#ifdef MAPBASE +#define DEFINE_BASENPCINTERACTABLE_DATADESC() \ + DEFINE_OUTPUT( m_OnAlyxStartedInteraction, "OnAlyxStartedInteraction" ), \ + DEFINE_OUTPUT( m_OnAlyxFinishedInteraction, "OnAlyxFinishedInteraction" ), \ + DEFINE_OUTPUT( m_OnHacked, "OnHacked" ), \ + DEFINE_INPUTFUNC( FIELD_VOID, "InteractivePowerDown", InputPowerdown ), \ + DEFINE_INPUTFUNC( FIELD_VOID, "Hack", InputDoInteraction ) +#else #define DEFINE_BASENPCINTERACTABLE_DATADESC() \ DEFINE_OUTPUT( m_OnAlyxStartedInteraction, "OnAlyxStartedInteraction" ), \ DEFINE_OUTPUT( m_OnAlyxFinishedInteraction, "OnAlyxFinishedInteraction" ), \ DEFINE_INPUTFUNC( FIELD_VOID, "InteractivePowerDown", InputPowerdown ) +#endif template class CNPCBaseInteractive : public NPC_CLASS, public INPCInteractive @@ -3078,6 +3244,13 @@ public: } +#ifdef MAPBASE + virtual void InputDoInteraction( inputdata_t &inputdata ) + { + NotifyInteraction(inputdata.pActivator ? inputdata.pActivator->MyNPCPointer() : NULL); + } +#endif + // Alyx specific interactions virtual void AlyxStartedInteraction( void ) { @@ -3093,6 +3266,9 @@ public: // Alyx specific interactions COutputEvent m_OnAlyxStartedInteraction; COutputEvent m_OnAlyxFinishedInteraction; +#ifdef MAPBASE + COutputEvent m_OnHacked; +#endif }; // diff --git a/sp/src/game/server/ai_basenpc_schedule.cpp b/sp/src/game/server/ai_basenpc_schedule.cpp index 5b7cb1f1..a508837e 100644 --- a/sp/src/game/server/ai_basenpc_schedule.cpp +++ b/sp/src/game/server/ai_basenpc_schedule.cpp @@ -981,6 +981,9 @@ bool CAI_BaseNPC::FindCoverFromEnemy( bool bNodesOnly, float flMinDistance, floa if (GetHintNode()) { GetNavigator()->SetArrivalActivity( GetCoverActivity( GetHintNode() ) ); +#ifdef MAPBASE + if (GetHintNode()->GetIgnoreFacing() != HIF_NO) +#endif GetNavigator()->SetArrivalDirection( GetHintNode()->GetDirection() ); } @@ -1585,6 +1588,39 @@ void CAI_BaseNPC::StartTask( const Task_t *pTask ) SetWait( pTask->flTaskData ); break; +#ifdef MAPBASE + case TASK_FACE_INTERACTION_ANGLES: + { + if ( !m_hForcedInteractionPartner ) + { + TaskFail( FAIL_NO_TARGET ); + return; + } + + // Get our running interaction from our partner, + // as this should only run with the NPC "receiving" the interaction + ScriptedNPCInteraction_t *pInteraction = m_hForcedInteractionPartner->GetRunningDynamicInteraction(); + + // Get our target's origin + Vector vecTarget = m_hForcedInteractionPartner->GetAbsOrigin(); + + // Face the angles the interaction actually wants us at, opposite to the partner + float angInteractionAngle = pInteraction->angRelativeAngles.y; + angInteractionAngle += 180.0f; + + GetMotor()->SetIdealYaw( CalcIdealYaw( vecTarget ) + angInteractionAngle ); + + if (FacingIdeal()) + TaskComplete(); + else + { + GetMotor()->SetIdealYaw( CalcReasonableFacing( true ) ); + SetTurnActivity(); + } + } + break; +#endif + case TASK_FACE_ENEMY: { Vector vecEnemyLKP = GetEnemyLKP(); @@ -2767,6 +2803,13 @@ void CAI_BaseNPC::StartTask( const Task_t *pTask ) string_t iszArrivalText; +#ifdef MAPBASE + if ( m_hCine->m_iszPreIdle != NULL_STRING ) + { + iszArrivalText = m_hCine->m_iszPreIdle; + } + else +#endif if ( m_hCine->m_iszEntry != NULL_STRING ) { iszArrivalText = m_hCine->m_iszEntry; @@ -3380,6 +3423,36 @@ void CAI_BaseNPC::RunTask( const Task_t *pTask ) } break; +#ifdef MAPBASE + case TASK_FACE_INTERACTION_ANGLES: + { + if ( !m_hForcedInteractionPartner ) + { + TaskFail( FAIL_NO_TARGET ); + return; + } + + // Get our running interaction from our partner, + // as this should only run with the NPC "receiving" the interaction + ScriptedNPCInteraction_t *pInteraction = m_hForcedInteractionPartner->GetRunningDynamicInteraction(); + + // Get our target's origin + Vector vecTarget = m_hForcedInteractionPartner->GetAbsOrigin(); + + // Face the angles the interaction actually wants us at, opposite to the partner + float angInteractionAngle = pInteraction->angRelativeAngles.y; + angInteractionAngle += 180.0f; + + GetMotor()->SetIdealYawAndUpdate( CalcIdealYaw( vecTarget ) + angInteractionAngle, AI_KEEP_YAW_SPEED ); + + if (IsWaitFinished()) + { + TaskComplete(); + } + } + break; +#endif + case TASK_FIND_COVER_FROM_BEST_SOUND: { switch( GetTaskInterrupt() ) @@ -3668,9 +3741,24 @@ void CAI_BaseNPC::RunTask( const Task_t *pTask ) { if( GetNavigator()->SetGoal(vecGoal) ) { +#ifdef MAPBASE + // Pushaway destinations could be an entire floor above. + // That would get frustrating. Only go to hints within a path distance of 300 units, + // only slightly above our initial search conditions. + if (GetNavigator()->BuildAndGetPathDistToGoal() < 300.0f) + { + // NOTE: Remove this DevMsg() when this is tested! + DevMsg("Player Withdrawal Destination Dist: %f\n", GetNavigator()->GetPathDistToGoal()); + pHint->NPCHandleStartNav(this, false); + pHint->DisableForSeconds( 0.1f ); // Force others to find their own. + TaskComplete(); + break; + } +#else pHint->DisableForSeconds( 0.1f ); // Force others to find their own. TaskComplete(); break; +#endif } } } @@ -3881,7 +3969,11 @@ void CAI_BaseNPC::RunTask( const Task_t *pTask ) if ( m_hCine && m_hCine->IsTimeToStart() ) { TaskComplete(); +#ifdef MAPBASE + m_hCine->OnBeginSequence(this); +#else m_hCine->OnBeginSequence(); +#endif // If we have an entry, we have to play it first if ( m_hCine->m_iszEntry != NULL_STRING ) diff --git a/sp/src/game/server/ai_behavior.cpp b/sp/src/game/server/ai_behavior.cpp index 7071bd50..8822f750 100644 --- a/sp/src/game/server/ai_behavior.cpp +++ b/sp/src/game/server/ai_behavior.cpp @@ -411,6 +411,17 @@ void CAI_BehaviorBase::HandleAnimEvent( animevent_t *pEvent ) m_pBackBridge->BackBridge_HandleAnimEvent( pEvent ); } +#ifdef MAPBASE +//------------------------------------- + +bool CAI_BehaviorBase::CanUnholsterWeapon( void ) +{ + Assert( m_pBackBridge != NULL ); + + return m_pBackBridge->BackBridge_CanUnholsterWeapon(); +} +#endif + //------------------------------------- bool CAI_BehaviorBase::NotifyChangeBehaviorStatus( bool fCanFinishSchedule ) diff --git a/sp/src/game/server/ai_behavior.h b/sp/src/game/server/ai_behavior.h index f88a0c45..ce26ca61 100644 --- a/sp/src/game/server/ai_behavior.h +++ b/sp/src/game/server/ai_behavior.h @@ -130,6 +130,9 @@ public: void BridgeModifyOrAppendCriteria( AI_CriteriaSet& criteriaSet ); void BridgeTeleport( const Vector *newPosition, const QAngle *newAngles, const Vector *newVelocity ); void BridgeHandleAnimEvent( animevent_t *pEvent ); +#ifdef MAPBASE + bool BridgeCanUnholsterWeapon( void ); +#endif virtual void GatherConditions(); virtual void GatherConditionsNotActive() { return; } // Override this and your behavior will call this in place of GatherConditions() when your behavior is NOT the active one. @@ -215,6 +218,9 @@ protected: virtual void ModifyOrAppendCriteria( AI_CriteriaSet& criteriaSet ); virtual void Teleport( const Vector *newPosition, const QAngle *newAngles, const Vector *newVelocity ); virtual void HandleAnimEvent( animevent_t *pEvent ); +#ifdef MAPBASE + virtual bool CanUnholsterWeapon( void ); +#endif virtual bool ShouldAlwaysThink(); @@ -361,6 +367,11 @@ public: virtual void BackBridge_HandleAnimEvent( animevent_t *pEvent ) = 0; +#ifdef MAPBASE + // For func_tank behavior + virtual bool BackBridge_CanUnholsterWeapon( void ) = 0; +#endif + //------------------------------------- }; @@ -457,6 +468,9 @@ public: Activity GetFlinchActivity( bool bHeavyDamage, bool bGesture ); bool OnCalcBaseMove( AILocalMoveGoal_t *pMoveGoal, float distClear, AIMoveResult_t *pResult ); void HandleAnimEvent( animevent_t *pEvent ); +#ifdef MAPBASE + bool CanUnholsterWeapon( void ); +#endif bool ShouldAlwaysThink(); @@ -517,6 +531,11 @@ private: void BackBridge_HandleAnimEvent( animevent_t *pEvent ); +#ifdef MAPBASE + // For func_tank behavior + bool BackBridge_CanUnholsterWeapon( void ); +#endif + CAI_BehaviorBase **AccessBehaviors(); int NumBehaviors(); @@ -887,6 +906,15 @@ inline void CAI_BehaviorBase::BridgeHandleAnimEvent( animevent_t *pEvent ) HandleAnimEvent( pEvent ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- + +inline bool CAI_BehaviorBase::BridgeCanUnholsterWeapon( void ) +{ + return CanUnholsterWeapon(); +} +#endif + //----------------------------------------------------------------------------- template @@ -1462,6 +1490,16 @@ inline void CAI_BehaviorHost::BackBridge_HandleAnimEvent( animevent_t BaseClass::HandleAnimEvent( pEvent ); } +#ifdef MAPBASE +//------------------------------------- + +template +inline bool CAI_BehaviorHost::BackBridge_CanUnholsterWeapon( void ) +{ + return BaseClass::CanUnholsterWeapon(); +} +#endif + //------------------------------------- template @@ -1865,6 +1903,19 @@ inline void CAI_BehaviorHost::HandleAnimEvent( animevent_t *pEvent ) return BaseClass::HandleAnimEvent( pEvent ); } +#ifdef MAPBASE +//------------------------------------- + +template +inline bool CAI_BehaviorHost::CanUnholsterWeapon( void ) +{ + if ( m_pCurBehavior ) + return m_pCurBehavior->BridgeCanUnholsterWeapon(); + + return BaseClass::CanUnholsterWeapon(); +} +#endif + //------------------------------------- template diff --git a/sp/src/game/server/ai_behavior_assault.cpp b/sp/src/game/server/ai_behavior_assault.cpp index e02627cc..bacb4d6a 100644 --- a/sp/src/game/server/ai_behavior_assault.cpp +++ b/sp/src/game/server/ai_behavior_assault.cpp @@ -251,7 +251,12 @@ CAssaultPoint *CAI_AssaultBehavior::FindAssaultPoint( string_t iszAssaultPointNa CUtlVectorpAssaultPoints; CUtlVectorpClearAssaultPoints; +#ifdef MAPBASE + // Prevents non-assault points (e.g. rally points) from crashing the game + CAssaultPoint *pAssaultEnt = dynamic_cast(gEntList.FindEntityByName( NULL, iszAssaultPointName )); +#else CAssaultPoint *pAssaultEnt = (CAssaultPoint *)gEntList.FindEntityByName( NULL, iszAssaultPointName ); +#endif while( pAssaultEnt != NULL ) { diff --git a/sp/src/game/server/ai_behavior_fear.cpp b/sp/src/game/server/ai_behavior_fear.cpp index ea908ba6..d153b7e3 100644 --- a/sp/src/game/server/ai_behavior_fear.cpp +++ b/sp/src/game/server/ai_behavior_fear.cpp @@ -20,6 +20,9 @@ BEGIN_DATADESC( CAI_FearBehavior ) DEFINE_FIELD( m_hMovingToHint, FIELD_EHANDLE ), DEFINE_EMBEDDED( m_SafePlaceMoveMonitor ), DEFINE_FIELD( m_flDeferUntil, FIELD_TIME ), +#ifdef MAPBASE + DEFINE_FIELD( m_hFearGoal, FIELD_EHANDLE ), +#endif END_DATADESC(); #define BEHAVIOR_FEAR_SAFETY_TIME 5 @@ -61,6 +64,11 @@ void CAI_FearBehavior::StartTask( const Task_t *pTask ) m_hSafePlaceHint = m_hMovingToHint; m_hSafePlaceHint->Lock( GetOuter() ); m_SafePlaceMoveMonitor.SetMark( GetOuter(), FEAR_SAFE_PLACE_TOLERANCE ); +#ifdef MAPBASE + m_hSafePlaceHint->NPCStartedUsing( GetOuter() ); + if (m_hFearGoal) + m_hFearGoal->m_OnArriveAtFearNode.FireOutput(m_hSafePlaceHint, GetOuter()); +#endif TaskComplete(); break; @@ -149,7 +157,11 @@ void CAI_FearBehavior::RunTask( const Task_t *pTask ) } else { +#ifdef MAPBASE + m_hMovingToHint->NPCHandleStartNav( GetOuter(), true ); +#else GetNavigator()->SetArrivalDirection( m_hMovingToHint->GetAbsAngles() ); +#endif } } break; @@ -231,6 +243,10 @@ void CAI_FearBehavior::ReleaseAllHints() // If I have a safe place, unlock it for others. m_hSafePlaceHint->Unlock(); +#ifdef MAPBASE + m_hSafePlaceHint->NPCStoppedUsing(GetOuter()); +#endif + // Don't make it available right away. I probably left for a good reason. // We also don't want to oscillate m_hSafePlaceHint->DisableForSeconds( 4.0f ); @@ -274,6 +290,22 @@ bool CAI_FearBehavior::CanSelectSchedule() if( GetOuter()->IRelationType(pEnemy) != D_FR ) return false; +#ifdef MAPBASE + // Don't run fear behavior if we've been ordered somewhere + if (GetOuter()->GetCommandGoal() != vec3_invalid) + return false; + + // Don't run fear behavior if we're running any non-follow behaviors + if (GetOuter()->GetRunningBehavior() && GetOuter()->GetRunningBehavior() != this && !FStrEq(GetOuter()->GetRunningBehavior()->GetName(), "Follow")) + return false; + + if (m_hFearGoal && m_iszFearTarget != NULL_STRING) + { + if (pEnemy->NameMatches(m_iszFearTarget) || pEnemy->ClassMatches(m_iszFearTarget)) + return true; + } +#endif + if( !pEnemy->ClassMatches("npc_hunter") ) return false; @@ -457,6 +489,9 @@ CAI_Hint *CAI_FearBehavior::FindFearWithdrawalDest() hintCriteria.AddHintType( HINT_PLAYER_ALLY_FEAR_DEST ); hintCriteria.SetFlag( bits_HINT_NODE_VISIBLE_TO_PLAYER | bits_HINT_NOT_CLOSE_TO_ENEMY /*| bits_HINT_NODE_IN_VIEWCONE | bits_HINT_NPC_IN_NODE_FOV*/ ); +#ifdef MAPBASE + hintCriteria.SetFlag(bits_HINT_NODE_USE_GROUP); +#endif hintCriteria.AddIncludePosition( AI_GetSinglePlayer()->GetAbsOrigin(), ( ai_fear_player_dist.GetFloat() ) ); pHint = CAI_HintManager::FindHint( pOuter, hintCriteria ); @@ -478,6 +513,108 @@ CAI_Hint *CAI_FearBehavior::FindFearWithdrawalDest() return pHint; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------- +Activity CAI_FearBehavior::NPC_TranslateActivity( Activity activity ) +{ + if ( activity == ACT_IDLE && m_hSafePlaceHint && m_hSafePlaceHint->HintActivityName() != NULL_STRING ) + { + return GetOuter()->GetHintActivity(m_hSafePlaceHint->HintType(), (Activity)CAI_BaseNPC::GetActivityID( STRING(m_hSafePlaceHint->HintActivityName()) ) ); + } + return BaseClass::NPC_TranslateActivity( activity ); +} + +//----------------------------------------------------------------------------- +// Updates the fear goal's target. +//----------------------------------------------------------------------------- +void CAI_FearBehavior::OnRestore() +{ + BaseClass::OnRestore(); + + if (m_hFearGoal.Get() != NULL) + { + m_iszFearTarget = m_hFearGoal->m_target; + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CAI_FearBehavior::SetParameters( CAI_FearGoal *pGoal, string_t target ) +{ + m_hFearGoal = pGoal; + m_iszFearTarget = target; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//============================================================================= +//============================================================================= +// >AI_GOAL_FEAR +//============================================================================= +//============================================================================= +LINK_ENTITY_TO_CLASS( ai_goal_fear, CAI_FearGoal ); + +BEGIN_DATADESC( CAI_FearGoal ) + //DEFINE_KEYFIELD( m_iSomething, FIELD_INTEGER, "something" ), + + // Inputs + DEFINE_INPUTFUNC( FIELD_VOID, "Activate", InputActivate ), + + // Outputs + //DEFINE_OUTPUT( m_OnSeeFearEntity, "OnSeeFearEntity" ), + DEFINE_OUTPUT( m_OnArriveAtFearNode, "OnArrivedAtNode" ), +END_DATADESC() + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CAI_FearGoal::EnableGoal( CAI_BaseNPC *pAI ) +{ + CAI_FearBehavior *pBehavior; + + if ( !pAI->GetBehavior( &pBehavior ) ) + { + return; + } + + pBehavior->SetParameters(this, m_target); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CAI_FearGoal::DisableGoal( CAI_BaseNPC *pAI ) +{ + CAI_FearBehavior *pBehavior; + + if ( !pAI->GetBehavior( &pBehavior ) ) + { + return; + } + + pBehavior->SetParameters(NULL, NULL_STRING); +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CAI_FearGoal::InputActivate( inputdata_t &inputdata ) +{ + BaseClass::InputActivate( inputdata ); +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CAI_FearGoal::InputDeactivate( inputdata_t &inputdata ) +{ + BaseClass::InputDeactivate( inputdata ); +} +#endif + AI_BEGIN_CUSTOM_SCHEDULE_PROVIDER( CAI_FearBehavior ) DECLARE_TASK( TASK_FEAR_GET_PATH_TO_SAFETY_HINT ) @@ -531,6 +668,25 @@ AI_BEGIN_CUSTOM_SCHEDULE_PROVIDER( CAI_FearBehavior ) //=============================================== //=============================================== +#ifdef MAPBASE + DEFINE_SCHEDULE + ( + SCHED_FEAR_STAY_IN_SAFE_PLACE, + + " Tasks" + " TASK_FEAR_WAIT_FOR_SAFETY 0" + "" + " Interrupts" + "" + " COND_NEW_ENEMY" + " COND_HEAR_DANGER" + " COND_FEAR_ENEMY_CLOSE" + " COND_FEAR_ENEMY_TOO_CLOSE" + " COND_CAN_RANGE_ATTACK1" + " COND_FEAR_SEPARATED_FROM_PLAYER" + " COND_ENEMY_DEAD" // Allows the fearful to follow the player when enemy dies + ); +#else DEFINE_SCHEDULE ( SCHED_FEAR_STAY_IN_SAFE_PLACE, @@ -547,6 +703,7 @@ AI_BEGIN_CUSTOM_SCHEDULE_PROVIDER( CAI_FearBehavior ) " COND_CAN_RANGE_ATTACK1" " COND_FEAR_SEPARATED_FROM_PLAYER" ); +#endif AI_END_CUSTOM_SCHEDULE_PROVIDER() diff --git a/sp/src/game/server/ai_behavior_fear.h b/sp/src/game/server/ai_behavior_fear.h index b13848cb..e92ae689 100644 --- a/sp/src/game/server/ai_behavior_fear.h +++ b/sp/src/game/server/ai_behavior_fear.h @@ -20,6 +20,37 @@ #include "ai_behavior.h" +#ifdef MAPBASE +#include "ai_goalentity.h" + +//========================================================= +//========================================================= +class CAI_FearGoal : public CAI_GoalEntity +{ + DECLARE_CLASS( CAI_FearGoal, CAI_GoalEntity ); +public: + CAI_FearGoal() + { + } + + void EnableGoal( CAI_BaseNPC *pAI ); + void DisableGoal( CAI_BaseNPC *pAI ); + + // Inputs + virtual void InputActivate( inputdata_t &inputdata ); + virtual void InputDeactivate( inputdata_t &inputdata ); + + // Note that the outer is the caller in these outputs + //COutputEvent m_OnSeeFearEntity; + COutputEvent m_OnArriveAtFearNode; + + DECLARE_DATADESC(); + +protected: + // Put something here +}; +#endif + class CAI_FearBehavior : public CAI_SimpleBehavior { DECLARE_CLASS( CAI_FearBehavior, CAI_SimpleBehavior ); @@ -56,6 +87,17 @@ public: void BuildScheduleTestBits(); int TranslateSchedule( int scheduleType ); +#ifdef MAPBASE + virtual Activity NPC_TranslateActivity( Activity activity ); + + virtual void OnRestore(); + virtual void SetParameters( CAI_FearGoal *pGoal, string_t target ); + CHandle m_hFearGoal; + + // Points to goal's fear target + string_t m_iszFearTarget; +#endif + enum { diff --git a/sp/src/game/server/ai_behavior_follow.cpp b/sp/src/game/server/ai_behavior_follow.cpp index 4c77972c..2b5a084c 100644 --- a/sp/src/game/server/ai_behavior_follow.cpp +++ b/sp/src/game/server/ai_behavior_follow.cpp @@ -20,6 +20,9 @@ #ifdef HL2_EPISODIC #include "info_darknessmode_lightsource.h" +#ifdef MAPBASE + #include "globalstate.h" +#endif #endif // memdbgon must be the last include file in a .cpp file!!! @@ -403,7 +406,11 @@ bool CAI_FollowBehavior::SetFollowGoal( CAI_FollowGoal *pGoal, bool fFinishCurSc } SetFollowTarget( pGoal->GetGoalEntity() ); +#ifdef MAPBASE + Assert( pGoal->m_iFormation < AIF_NUM_FORMATIONS ); +#else Assert( pGoal->m_iFormation == AIF_SIMPLE || pGoal->m_iFormation == AIF_WIDE || pGoal->m_iFormation == AIF_MEDIUM || pGoal->m_iFormation == AIF_SIDEKICK || pGoal->m_iFormation == AIF_VORTIGAUNT ); +#endif SetParameters( AI_FollowParams_t( (AI_Formations_t)pGoal->m_iFormation ) ); m_hFollowGoalEnt = pGoal; m_flTimeUpdatedFollowPosition = 0; @@ -764,7 +771,12 @@ void CAI_FollowBehavior::GatherConditions( void ) #ifdef HL2_EPISODIC // Let followers know if the player is lit in the darkness +#ifdef MAPBASE + // If the darkness mode counter is 1, follow behavior is not affected by darkness. + if ( GetFollowTarget()->IsPlayer() && HL2GameRules()->IsAlyxInDarknessMode() && GlobalEntity_GetCounter("ep_alyx_darknessmode") != 1 ) +#else if ( GetFollowTarget()->IsPlayer() && HL2GameRules()->IsAlyxInDarknessMode() ) +#endif { if ( LookerCouldSeeTargetInDarkness( GetOuter(), GetFollowTarget() ) ) { @@ -907,6 +919,11 @@ void CAI_FollowBehavior::ClearFollowPoint() { if ( GetHintNode() && GetHintNode()->HintType() == HINT_FOLLOW_WAIT_POINT ) { +#ifdef MAPBASE + // If we were in range, we were probably already using it + if ((GetHintNode()->GetAbsOrigin() - GetFollowTarget()->GetAbsOrigin()).LengthSqr() < Square(MAX(m_FollowNavGoal.followPointTolerance, GetGoalRange()))) + GetHintNode()->NPCStoppedUsing(GetOuter()); +#endif GetHintNode()->Unlock(); SetHintNode( NULL ); } @@ -931,7 +948,14 @@ CAI_Hint *CAI_FollowBehavior::FindFollowPoint() CHintCriteria hintCriteria; hintCriteria.SetHintType( HINT_FOLLOW_WAIT_POINT ); +#ifdef MAPBASE + // NOTE: Does this make them stop following? + hintCriteria.SetGroup( GetOuter()->GetHintGroup() ); + hintCriteria.SetFlag( bits_HINT_NODE_VISIBLE | bits_HINT_NODE_NEAREST | bits_HINT_NODE_USE_GROUP ); + //hintCriteria.SetFlag( bits_HINT_NODE_VISIBLE | bits_HINT_NODE_NEAREST ); +#else hintCriteria.SetFlag( bits_HINT_NODE_VISIBLE | bits_HINT_NODE_NEAREST ); +#endif // Add the search position hintCriteria.AddIncludePosition( GetGoalPosition(), MAX( m_FollowNavGoal.followPointTolerance, GetGoalRange() ) ); @@ -1033,6 +1057,9 @@ int CAI_FollowBehavior::SelectScheduleFollowPoints() { if ( bNewHint || distSqToPoint > WAIT_HINT_MIN_DIST ) return SCHED_FOLLOWER_GO_TO_WAIT_POINT; +#ifdef MAPBASE + GetHintNode()->NPCStartedUsing(GetOuter()); +#endif if ( !ShouldIgnoreFollowPointFacing() ) return SCHED_FOLLOWER_STAND_AT_WAIT_POINT; } diff --git a/sp/src/game/server/ai_behavior_follow.h b/sp/src/game/server/ai_behavior_follow.h index a0e43837..84cb0109 100644 --- a/sp/src/game/server/ai_behavior_follow.h +++ b/sp/src/game/server/ai_behavior_follow.h @@ -36,6 +36,9 @@ enum AI_Formations_t AIF_SIDEKICK, AIF_HUNTER, AIF_VORTIGAUNT, +#ifdef MAPBASE + AIF_NUM_FORMATIONS, +#endif }; enum AI_FollowFormationFlags_t diff --git a/sp/src/game/server/ai_behavior_lead.cpp b/sp/src/game/server/ai_behavior_lead.cpp index 6a316c1e..733f9f1d 100644 --- a/sp/src/game/server/ai_behavior_lead.cpp +++ b/sp/src/game/server/ai_behavior_lead.cpp @@ -543,8 +543,12 @@ int CAI_LeadBehavior::SelectSchedule() if ( !m_flWeaponSafetyTimeOut || (m_flWeaponSafetyTimeOut > gpGlobals->curtime) ) return SCHED_LEAD_PLAYERNEEDSWEAPON; +#ifdef MAPBASE + pFollower->GiveNamedItem( STRING(m_weaponname) ); +#else string_t iszItem = AllocPooledString( "weapon_bugbait" ); pFollower->GiveNamedItem( STRING(iszItem) ); +#endif } } @@ -1649,6 +1653,9 @@ public: private: string_t m_iszWeaponName; +#ifdef MAPBASE + float m_flTimeoutTime = 60; +#endif string_t m_iszMissingWeaponConceptModifier; DECLARE_DATADESC(); @@ -1664,6 +1671,9 @@ LINK_ENTITY_TO_CLASS( ai_goal_lead_weapon, CAI_LeadGoal_Weapon ); BEGIN_DATADESC( CAI_LeadGoal_Weapon ) DEFINE_KEYFIELD( m_iszWeaponName, FIELD_STRING, "WeaponName"), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_flTimeoutTime, FIELD_FLOAT, "TimeoutTime" ), +#endif DEFINE_KEYFIELD( m_iszMissingWeaponConceptModifier, FIELD_STRING, "MissingWeaponConceptModifier"), END_DATADESC() @@ -1688,6 +1698,10 @@ void CAI_LeadGoal_Weapon::InputActivate( inputdata_t &inputdata ) CAI_LeadBehavior *pBehavior = GetLeadBehavior(); if ( pBehavior ) { +#ifdef MAPBASE + pBehavior->SetWaitForWeapon( m_iszWeaponName, m_flTimeoutTime ); +#else pBehavior->SetWaitForWeapon( m_iszWeaponName ); +#endif } } diff --git a/sp/src/game/server/ai_behavior_lead.h b/sp/src/game/server/ai_behavior_lead.h index d59a87d3..2104b1f2 100644 --- a/sp/src/game/server/ai_behavior_lead.h +++ b/sp/src/game/server/ai_behavior_lead.h @@ -125,7 +125,11 @@ public: bool Connect( CAI_LeadBehaviorHandler *); bool Disconnect( CAI_LeadBehaviorHandler *); +#ifdef MAPBASE + void SetWaitForWeapon( string_t iszWeaponName, float flTimeout = 60 ) { m_weaponname = iszWeaponName; m_flWeaponSafetyTimeOut = gpGlobals->curtime + flTimeout; } +#else void SetWaitForWeapon( string_t iszWeaponName ) { m_weaponname = iszWeaponName; m_flWeaponSafetyTimeOut = gpGlobals->curtime + 60; } +#endif enum { diff --git a/sp/src/game/server/ai_behavior_standoff.cpp b/sp/src/game/server/ai_behavior_standoff.cpp index 4f5f7469..0792df23 100644 --- a/sp/src/game/server/ai_behavior_standoff.cpp +++ b/sp/src/game/server/ai_behavior_standoff.cpp @@ -516,7 +516,11 @@ int CAI_StandoffBehavior::SelectScheduleCheckCover( void ) if ( GetOuter()->GetShotRegulator()->IsInRestInterval() ) { StandoffMsg( "Regulated to not shoot\n" ); +#ifdef MAPBASE + if ( GetHintType() == HINT_TACTICAL_COVER_LOW || GetHintType() == HINT_TACTICAL_COVER_MED ) +#else if ( GetHintType() == HINT_TACTICAL_COVER_LOW ) +#endif SetPosture( AIP_CROUCHING ); else SetPosture( AIP_STANDING ); @@ -1067,10 +1071,18 @@ void CAI_StandoffBehavior::UnlockHintNode() Activity CAI_StandoffBehavior::GetCoverActivity() { +#ifdef MAPBASE + // This does two things: + // A. Allows medium cover nodes to be used, kind of. + // B. GetCoverActivity() already checks everything we checked here. + Activity coveract = GetOuter()->GetCoverActivity( GetHintNode() ); + return coveract == ACT_IDLE ? ACT_INVALID : coveract; +#else CAI_Hint *pHintNode = GetHintNode(); if ( pHintNode && pHintNode->HintType() == HINT_TACTICAL_COVER_LOW ) return GetOuter()->GetCoverActivity( pHintNode ); return ACT_INVALID; +#endif } @@ -1114,7 +1126,12 @@ void CAI_MappedActivityBehavior_Temporary::UpdateTranslateActivityMap() { if ( !mappings[i].pszWeapon || stricmp( mappings[i].pszWeapon, pszWeaponClass ) == 0 ) { +#ifdef MAPBASE + // Check backup activity + if ( HaveSequenceForActivity( mappings[i].translation ) || HaveSequenceForActivity( GetOuter()->Weapon_TranslateActivity( mappings[i].translation ) ) || HaveSequenceForActivity( GetOuter()->Weapon_BackupActivity( mappings[i].translation ) ) ) +#else if ( HaveSequenceForActivity( mappings[i].translation ) || HaveSequenceForActivity( GetOuter()->Weapon_TranslateActivity( mappings[i].translation ) ) ) +#endif { Assert( m_ActivityMap.Find( MAKE_ACTMAP_KEY( mappings[i].posture, mappings[i].activity ) ) == m_ActivityMap.InvalidIndex() ); m_ActivityMap.Insert( MAKE_ACTMAP_KEY( mappings[i].posture, mappings[i].activity ), mappings[i].translation ); diff --git a/sp/src/game/server/ai_concommands.cpp b/sp/src/game/server/ai_concommands.cpp index 8c647f55..17e77120 100644 --- a/sp/src/game/server/ai_concommands.cpp +++ b/sp/src/game/server/ai_concommands.cpp @@ -411,6 +411,20 @@ void CC_NPC_Create( const CCommand &args ) { baseNPC->SetName( AllocPooledString( args[2] ) ); } +#ifdef MAPBASE + else if ( args.ArgC() > 3 ) + { + baseNPC->SetName( AllocPooledString( args[2] ) ); + + // Pass in any additional parameters. + for ( int i = 3; i + 1 < args.ArgC(); i += 2 ) + { + const char *pKeyName = args[i]; + const char *pValue = args[i+1]; + baseNPC->KeyValue( pKeyName, pValue ); + } + } +#endif DispatchSpawn(baseNPC); // Now attempt to drop into the world diff --git a/sp/src/game/server/ai_default.cpp b/sp/src/game/server/ai_default.cpp index ffa85e08..e80817ad 100644 --- a/sp/src/game/server/ai_default.cpp +++ b/sp/src/game/server/ai_default.cpp @@ -1774,6 +1774,24 @@ AI_DEFINE_SCHEDULE // Run to cover, but don't turn to face enemy and upon // fail run around randomly //========================================================= +#ifdef MAPBASE +AI_DEFINE_SCHEDULE +( + SCHED_RUN_FROM_ENEMY, + + " Tasks" + " TASK_SET_FAIL_SCHEDULE SCHEDULE:SCHED_RUN_FROM_ENEMY_FALLBACK" + " TASK_STOP_MOVING 0" + " TASK_FIND_COVER_FROM_ENEMY 0" + " TASK_RUN_PATH 0" + " TASK_WAIT_FOR_MOVEMENT 0" + " TASK_REMEMBER MEMORY:INCOVER" // Now that crouch nodes are fixed, this is necessary in case cover leads to a crouch node + "" + " Interrupts" + " COND_NEW_ENEMY" + " COND_ENEMY_DEAD" +); +#else AI_DEFINE_SCHEDULE ( SCHED_RUN_FROM_ENEMY, @@ -1789,6 +1807,7 @@ AI_DEFINE_SCHEDULE " COND_NEW_ENEMY" " COND_ENEMY_DEAD" ); +#endif AI_DEFINE_SCHEDULE ( @@ -2351,6 +2370,19 @@ AI_DEFINE_SCHEDULE //========================================================= // > SCHED_INTERACTION_WAIT_FOR_PARTNER //========================================================= +#ifdef MAPBASE +AI_DEFINE_SCHEDULE +( + SCHED_INTERACTION_WAIT_FOR_PARTNER, + + " Tasks" + " TASK_FACE_INTERACTION_ANGLES 0" // New task to fix forced interaction anomalies + " TASK_WAIT 1" + "" + " Interrupts" + " COND_NO_CUSTOM_INTERRUPTS" +); +#else AI_DEFINE_SCHEDULE ( SCHED_INTERACTION_WAIT_FOR_PARTNER, @@ -2362,6 +2394,7 @@ AI_DEFINE_SCHEDULE " Interrupts" " COND_NO_CUSTOM_INTERRUPTS" ); +#endif //========================================================= // > SCHED_SLEEP diff --git a/sp/src/game/server/ai_dynamiclink.cpp b/sp/src/game/server/ai_dynamiclink.cpp index 5f5fba9c..a08402e8 100644 --- a/sp/src/game/server/ai_dynamiclink.cpp +++ b/sp/src/game/server/ai_dynamiclink.cpp @@ -15,6 +15,14 @@ #include "ai_link.h" #include "ai_network.h" #include "ai_networkmanager.h" +#ifdef MAPBASE +#include "ai_hint.h" +#include "ai_basenpc.h" +#include "filters.h" +#include "point_template.h" +#include "TemplateEntities.h" +#include "mapentities.h" +#endif #include "saverestore_utlvector.h" #include "editor_sendcommand.h" #include "bitstring.h" @@ -169,6 +177,156 @@ void CAI_DynamicLinkController::InputSetInvert( inputdata_t &inputdata ) } } +#ifdef MAPBASE +//============================================================================= +// >> CAI_CustomLinkController +// Uses the specified link class +//============================================================================= +class CAI_CustomLinkController : public CAI_DynamicLinkController +{ + DECLARE_CLASS( CAI_CustomLinkController, CAI_DynamicLinkController ); +public: + CAI_CustomLinkController(); + + void GenerateLinksFromVolume(); + int GetReferenceLinkIndex(); + + string_t m_iszReferenceLinkTemplate; + int m_iReferenceLink; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(info_template_link_controller, CAI_CustomLinkController); + +BEGIN_DATADESC( CAI_CustomLinkController ) + + DEFINE_KEYFIELD( m_iszReferenceLinkTemplate, FIELD_STRING, "ReferenceTemplate" ), + //DEFINE_FIELD( m_iReferenceLink, FIELD_INTEGER ), // I don't know if this should be saved. It's only a cached variable, so not saving it shouldn't hurt anything. + +END_DATADESC() + +CAI_CustomLinkController::CAI_CustomLinkController() +{ + m_iReferenceLink = -1; +} + +int CAI_CustomLinkController::GetReferenceLinkIndex() +{ + if (m_iReferenceLink != -1) + return m_iReferenceLink; + + CBaseEntity *pEnt = gEntList.FindEntityByName(NULL, STRING(m_iszReferenceLinkTemplate), this); + if (CPointTemplate *pTemplate = dynamic_cast(pEnt)) + { + Assert(pTemplate->GetTemplateEntity(0)); + + m_iReferenceLink = pTemplate->GetTemplateIndexForTemplate(0); + return m_iReferenceLink; + } + + return -1; +} + +void CAI_CustomLinkController::GenerateLinksFromVolume() +{ + Assert( m_ControlledLinks.Count() == 0 ); + + int nNodes = g_pBigAINet->NumNodes(); + CAI_Node **ppNodes = g_pBigAINet->AccessNodes(); + + float MinDistCareSq = 0; + if (m_bUseAirLinkRadius) + { + MinDistCareSq = Square(MAX_AIR_NODE_LINK_DIST + 0.1); + } + else + { + MinDistCareSq = Square(MAX_NODE_LINK_DIST + 0.1); + } + + const Vector &origin = WorldSpaceCenter(); + Vector vAbsMins, vAbsMaxs; + CollisionProp()->WorldSpaceAABB( &vAbsMins, &vAbsMaxs ); + vAbsMins -= Vector( 1, 1, 1 ); + vAbsMaxs += Vector( 1, 1, 1 ); + + int iReference = GetReferenceLinkIndex(); + if (iReference == -1) + { + Warning("WARNING! %s reference link is invalid!\n", GetDebugName()); + return; + } + + // Get the map data before the loop + char *pMapData = (char*)STRING( Templates_FindByIndex( iReference ) ); + + // Make sure the entity is a dynamic link before doing anything + CBaseEntity *pEntity = NULL; + MapEntity_ParseEntity( pEntity, pMapData, NULL ); + if ( !dynamic_cast(pEntity) ) + { + Warning("WARNING! %s reference link is not a node link!\n", GetDebugName()); + UTIL_RemoveImmediate(pEntity); + return; + } + + UTIL_RemoveImmediate(pEntity); + + for ( int i = 0; i < nNodes; i++ ) + { + CAI_Node *pNode = ppNodes[i]; + const Vector &nodeOrigin = pNode->GetOrigin(); + if ( origin.DistToSqr(nodeOrigin) < MinDistCareSq ) + { + int nLinks = pNode->NumLinks(); + for ( int j = 0; j < nLinks; j++ ) + { + CAI_Link *pLink = pNode->GetLinkByIndex( j ); + int iLinkDest = pLink->DestNodeID( i ); + if ( iLinkDest > i ) + { + const Vector &originOther = ppNodes[iLinkDest]->GetOrigin(); + if ( origin.DistToSqr(originOther) < MinDistCareSq ) + { + if ( IsBoxIntersectingRay( vAbsMins, vAbsMaxs, nodeOrigin, originOther - nodeOrigin ) ) + { + Assert( IsBoxIntersectingRay( vAbsMins, vAbsMaxs, originOther, nodeOrigin - originOther ) ); + + CBaseEntity *pEntity = NULL; + + // Create the entity from the mapdata + MapEntity_ParseEntity( pEntity, pMapData, NULL ); + if ( pEntity == NULL ) + { + Msg("%s failed to initialize templated link with mapdata: %s\n", GetDebugName(), pMapData ); + return; + } + + // We already made sure it was an info_node_link template earlier. + CAI_DynamicLink *pLink = static_cast(pEntity); + + pLink->m_nSrcID = i; + pLink->m_nDestID = iLinkDest; + pLink->m_nSrcEditID = g_pAINetworkManager->GetEditOps()->GetWCIdFromNodeId( pLink->m_nSrcID ); + pLink->m_nDestEditID = g_pAINetworkManager->GetEditOps()->GetWCIdFromNodeId( pLink->m_nDestID ); + pLink->m_nLinkState = m_nLinkState; + pLink->m_strAllowUse = m_strAllowUse; + pLink->m_bInvertAllow = m_bInvertAllow; + pLink->m_bFixedUpIds = true; + pLink->m_bNotSaved = true; + + pLink->Spawn(); + m_ControlledLinks.AddToTail( pLink ); + } + } + } + } + } + } +} +#endif + //----------------------------------------------------------------------------- LINK_ENTITY_TO_CLASS(info_node_link, CAI_DynamicLink); @@ -579,6 +737,242 @@ CAI_DynamicLink::~CAI_DynamicLink(void) { } } +#ifdef MAPBASE +//------------------------------------------------------------------------------ +// Purpose : Determines if usage is allowed by a NPC, whether the link is disabled or not. +// This was created for info_node_link derivatives. +// Input : +// Output : +//------------------------------------------------------------------------------ +bool CAI_DynamicLink::UseAllowed(CAI_BaseNPC *pNPC, bool bFromEnd) +{ + if (!(FindLink()->m_LinkInfo & bits_LINK_OFF)) + return true; + + if ( m_strAllowUse == NULL_STRING ) + return false; + + const char *pszAllowUse = STRING( m_strAllowUse ); + if ( m_bInvertAllow ) + { + // Exlude only the specified entity name or classname + if ( !pNPC->NameMatches(pszAllowUse) && !pNPC->ClassMatches( pszAllowUse ) ) + return true; + } + else + { + // Exclude everything but the allowed entity name or classname + if ( pNPC->NameMatches( pszAllowUse) || pNPC->ClassMatches( pszAllowUse ) ) + return true; + } + + return false; +} + +//============================================================================= +// >> CAI_DynanicLinkOneWay +//============================================================================= +class CAI_DynamicLinkOneWay : public CAI_DynamicLink +{ + DECLARE_CLASS( CAI_DynamicLinkOneWay, CAI_DynamicLink ); +public: + virtual bool UseAllowed(CAI_BaseNPC *pNPC, bool bFromEnd); + //virtual void SetLinkState( void ); + + bool m_bNormalWhenEnabled; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(info_node_link_oneway, CAI_DynamicLinkOneWay); + +BEGIN_DATADESC( CAI_DynamicLinkOneWay ) + + DEFINE_KEYFIELD( m_bNormalWhenEnabled, FIELD_BOOLEAN, "Usage" ), + +END_DATADESC() + +//------------------------------------------------------------------------------ +// Purpose : Determines if usage is allowed by a NPC. +// This was created for info_node_link derivatives. +// Input : +// Output : +//------------------------------------------------------------------------------ +bool CAI_DynamicLinkOneWay::UseAllowed(CAI_BaseNPC *pNPC, bool bFromEnd) +{ + if (m_bNormalWhenEnabled) + return (m_nLinkState == LINK_OFF && bFromEnd) ? BaseClass::UseAllowed(pNPC, bFromEnd) : true; + + if (bFromEnd || m_nLinkState == LINK_OFF) + return BaseClass::UseAllowed(pNPC, bFromEnd); + + return true; +} + +#if 0 +//------------------------------------------------------------------------------ +// Purpose : Updates network link state if dynamic link state has changed +// Input : +// Output : +//------------------------------------------------------------------------------ +void CAI_DynamicLinkOneWay::SetLinkState(void) +{ + if (m_bNormalWhenEnabled) + return BaseClass::SetLinkState(); + + if ( !gm_bInitialized ) + { + // Safe to quietly return. Consistency will be enforced when InitDynamicLinks() is called + return; + } + + if (m_nSrcID == NO_NODE || m_nDestID == NO_NODE) + { + Vector pos = GetAbsOrigin(); + DevWarning("ERROR: Dynamic link at %f %f %f pointing to invalid node ID!!\n", pos.x, pos.y, pos.z); + return; + } + + CAI_Node * pSrcNode = g_pBigAINet->GetNode(m_nSrcID, false); + if ( pSrcNode ) + { + CAI_Link* pLink = FindLink(); + if ( pLink ) + { + // One-way always registers as off so it always calls UseAllowed() + pLink->m_pDynamicLink = this; + pLink->m_LinkInfo |= bits_LINK_OFF; + } + else + { + DevMsg("Dynamic Link Error: (%s) unable to form between nodes %d and %d\n", GetDebugName(), m_nSrcID, m_nDestID ); + } + } +} +#endif + +//============================================================================= +// >> CAI_DynamicLinkFilter +//============================================================================= +class CAI_DynamicLinkFilter : public CAI_DynamicLink +{ + DECLARE_CLASS( CAI_DynamicLinkFilter, CAI_DynamicLink ); +public: + virtual bool UseAllowed(CAI_BaseNPC *pNPC, bool bFromEnd); + //virtual void SetLinkState( void ); + + bool m_bNormalWhenEnabled; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(info_node_link_filtered, CAI_DynamicLinkFilter); + +BEGIN_DATADESC( CAI_DynamicLinkFilter ) + + DEFINE_KEYFIELD( m_bNormalWhenEnabled, FIELD_BOOLEAN, "Usage" ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetLinkFilter", InputSetDamageFilter ), + +END_DATADESC() + +//------------------------------------------------------------------------------ +// Purpose : Determines if usage is allowed by a NPC. +// This was created for info_node_link derivatives. +// Input : +// Output : +//------------------------------------------------------------------------------ +bool CAI_DynamicLinkFilter::UseAllowed(CAI_BaseNPC *pNPC, bool bFromEnd) +{ + if ( !m_hDamageFilter ) + { + m_hDamageFilter = gEntList.FindEntityByName( NULL, m_iszDamageFilterName ); + if (!m_hDamageFilter) + { + Warning("%s (%s) couldn't find filter \"%s\"!\n", GetClassname(), GetDebugName(), STRING(m_iszDamageFilterName)); + return BaseClass::UseAllowed(pNPC, bFromEnd); + } + } + + CBaseFilter *pFilter = (CBaseFilter *)(m_hDamageFilter.Get()); + + if (m_bNormalWhenEnabled) + return (m_nLinkState == LINK_OFF) ? (pFilter->PassesFilter(this, pNPC) || BaseClass::UseAllowed(pNPC, bFromEnd)) : true; + + if (m_nLinkState == LINK_OFF) + return BaseClass::UseAllowed(pNPC, bFromEnd); + + return pFilter->PassesFilter(this, pNPC); +} + +//============================================================================= +// >> CAI_DynamicLinkLogic +//============================================================================= +class CAI_DynamicLinkLogic : public CAI_DynamicLink +{ + DECLARE_CLASS( CAI_DynamicLinkLogic, CAI_DynamicLink ); +public: + virtual bool UseAllowed(CAI_BaseNPC *pNPC, bool bFromEnd); + virtual bool FinalUseAllowed(CAI_BaseNPC *pNPC, bool bFromEnd); + + COutputEvent m_OnUsageAccepted; + COutputEvent m_OnUsageAcceptedWhileDisabled; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(info_node_link_logic, CAI_DynamicLinkLogic); + +BEGIN_DATADESC( CAI_DynamicLinkLogic ) + + DEFINE_OUTPUT( m_OnUsageAccepted, "OnUsageAccepted" ), + DEFINE_OUTPUT( m_OnUsageAcceptedWhileDisabled, "OnUsageAcceptedWhileDisabled" ), + +END_DATADESC() + +//------------------------------------------------------------------------------ +// Purpose : Determines if usage is allowed by a NPC. +// This was created for info_node_link derivatives. +// Input : +// Output : +//------------------------------------------------------------------------------ +bool CAI_DynamicLinkLogic::UseAllowed(CAI_BaseNPC *pNPC, bool bFromEnd) +{ + // + // If the link is off, we want to fire "OnUsageAcceptedWhileDisabled", but we have to make sure + // the rest of the pathfinding calculations work. Yes, they might do all of this just to find a disabled link, + // but we have to fire the output somehow. + // + // Links already enabled go through regular usage rules. + // + if (m_nLinkState == LINK_OFF) + return true; + else + return BaseClass::UseAllowed( pNPC, bFromEnd ); +} + +//------------------------------------------------------------------------------ +// Purpose : After nothing else is left, finally determines if usage is allowed by a NPC. +// This was created for info_node_link derivatives. +// Input : +// Output : +//------------------------------------------------------------------------------ +bool CAI_DynamicLinkLogic::FinalUseAllowed(CAI_BaseNPC *pNPC, bool bFromEnd) +{ + if (m_nLinkState == LINK_ON) + { + m_OnUsageAccepted.FireOutput(pNPC, this); + return true; + } + else + { + m_OnUsageAcceptedWhileDisabled.FireOutput(pNPC, this); + + // We skipped the usage rules before. Do them now. + return BaseClass::UseAllowed(pNPC, bFromEnd); + } +} +#endif + LINK_ENTITY_TO_CLASS(info_radial_link_controller, CAI_RadialLinkController); BEGIN_DATADESC( CAI_RadialLinkController ) diff --git a/sp/src/game/server/ai_dynamiclink.h b/sp/src/game/server/ai_dynamiclink.h index cefec66c..971df96a 100644 --- a/sp/src/game/server/ai_dynamiclink.h +++ b/sp/src/game/server/ai_dynamiclink.h @@ -65,6 +65,13 @@ public: int ObjectCaps(); +#ifdef MAPBASE + virtual bool UseAllowed(CAI_BaseNPC *pNPC, bool bFromEnd); + + // Called after we know the NPC meets all of the node's criteria + virtual bool FinalUseAllowed(CAI_BaseNPC *pNPC, bool bFromEnd) { return true; } +#endif + // ---------------- // Inputs // ---------------- @@ -83,6 +90,9 @@ class CAI_DynamicLinkController : public CServerOnlyEntity { DECLARE_CLASS( CAI_DynamicLinkController, CServerOnlyEntity ); public: +#ifdef MAPBASE + virtual +#endif void GenerateLinksFromVolume(); // ---------------- diff --git a/sp/src/game/server/ai_hint.cpp b/sp/src/game/server/ai_hint.cpp index c0014220..644e054f 100644 --- a/sp/src/game/server/ai_hint.cpp +++ b/sp/src/game/server/ai_hint.cpp @@ -890,6 +890,9 @@ BEGIN_DATADESC( CAI_Hint ) // Inputs DEFINE_INPUTFUNC( FIELD_VOID, "EnableHint", InputEnableHint ), DEFINE_INPUTFUNC( FIELD_VOID, "DisableHint", InputDisableHint ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_STRING, "SetHintGroup", InputSetHintGroup ), +#endif // Outputs DEFINE_OUTPUT( m_OnNPCStartedUsing, "OnNPCStartedUsing" ), @@ -913,6 +916,18 @@ void CAI_Hint::InputDisableHint( inputdata_t &inputdata ) m_NodeData.iDisabled = true; } +#ifdef MAPBASE +void CAI_Hint::SetGroup( string_t iszNewGroup ) +{ + m_NodeData.strGroup = iszNewGroup; +} + +void CAI_Hint::InputSetHintGroup( inputdata_t &inputdata ) +{ + SetGroup(inputdata.value.StringID()); +} +#endif + //------------------------------------------------------------------------------ // Purpose : @@ -1075,6 +1090,40 @@ bool CAI_Hint::IsInNodeFOV( CBaseEntity *pOther ) return false; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// An easy way of engaging certain hint parameters on certain hint types that didn't use it before. +//----------------------------------------------------------------------------- +void CAI_Hint::NPCHandleStartNav( CAI_BaseNPC *pNPC, bool bDefaultFacing ) +{ + Assert( pNPC != NULL ); + + HintIgnoreFacing_t facing = GetIgnoreFacing(); + if (facing == HIF_DEFAULT) + facing = bDefaultFacing ? HIF_YES : HIF_NO; + + if (facing == HIF_YES) + pNPC->GetNavigator()->SetArrivalDirection(GetDirection()); + + if (HintActivityName() != NULL_STRING) + { + Activity hintActivity = (Activity)CAI_BaseNPC::GetActivityID( STRING(HintActivityName()) ); + if ( hintActivity != ACT_INVALID ) + { + pNPC->GetNavigator()->SetArrivalActivity( pNPC->GetHintActivity(HintType(), hintActivity) ); + } + else + { + int iSequence = pNPC->LookupSequence(STRING(HintActivityName())); + if ( iSequence != ACT_INVALID ) + { + pNPC->GetNavigator()->SetArrivalSequence( iSequence ); + } + } + } +} +#endif + //----------------------------------------------------------------------------- // Purpose: Locks the node for use by an AI for hints // Output : Returns true if the node was available for locking, false on failure. @@ -1426,6 +1475,15 @@ int CAI_Hint::DrawDebugTextOverlays(void) EntityText(text_offset,tempstr,0); text_offset++; +#ifdef MAPBASE + if (m_NodeData.strGroup != NULL_STRING) + { + Q_snprintf(tempstr,sizeof(tempstr),"hintgroup %s", STRING(m_NodeData.strGroup) ) ; + EntityText(text_offset,tempstr,0); + text_offset++; + } +#endif + if ( m_NodeData.iDisabled ) { Q_snprintf(tempstr,sizeof(tempstr),"DISABLED" ); diff --git a/sp/src/game/server/ai_hint.h b/sp/src/game/server/ai_hint.h index 89daef3d..e88d8021 100644 --- a/sp/src/game/server/ai_hint.h +++ b/sp/src/game/server/ai_hint.h @@ -281,6 +281,9 @@ public: float Yaw( void ); CAI_Node *GetNode( void ); string_t GetGroup( void ) const { return m_NodeData.strGroup; } +#ifdef MAPBASE + void SetGroup( string_t iszNewGroup ); +#endif CBaseEntity *User( void ) const { return m_hHintOwner; }; Hint_e HintType( void ) const { return (Hint_e)m_NodeData.nHintType; }; void SetHintType( int hintType, bool force = false ); @@ -305,6 +308,10 @@ public: bool HintMatchesCriteria( CAI_BaseNPC *pNPC, const CHintCriteria &hintCriteria, const Vector &position, float *flNearestDistance, bool bIgnoreLock = false, bool bIgnoreHintType = false ); bool IsInNodeFOV( CBaseEntity *pOther ); +#ifdef MAPBASE + void NPCHandleStartNav( CAI_BaseNPC *pNPC, bool bDefaultFacing ); +#endif + private: void Spawn( void ); virtual void Activate(); @@ -317,6 +324,9 @@ private: // Input handlers void InputEnableHint( inputdata_t &inputdata ); void InputDisableHint( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetHintGroup( inputdata_t &inputdata ); +#endif private: diff --git a/sp/src/game/server/ai_moveprobe.cpp b/sp/src/game/server/ai_moveprobe.cpp index b2a86d83..bdf8796b 100644 --- a/sp/src/game/server/ai_moveprobe.cpp +++ b/sp/src/game/server/ai_moveprobe.cpp @@ -94,10 +94,16 @@ bool CAI_MoveProbe::ShouldBrushBeIgnored( CBaseEntity *pEntity ) CFuncBrush *pFuncBrush = assert_cast(pEntity); // this is true if my class or entity name matches the exclusion name on the func brush +#ifdef MAPBASE + // The only way it could conflict is if a map has a NPC using a classname as its targetname, like a single npc_fastzombie entity referred to as "npc_zombie". + // I doubt anyone's doing that unless they don't know what they're doing, and even then this still shouldn't be barred from plain-HL2 mappers. + bool nameMatches = GetOuter()->ClassMatches(pFuncBrush->m_iszExcludedClass) || GetOuter()->NameMatches(pFuncBrush->m_iszExcludedClass); +#else #if HL2_EPISODIC bool nameMatches = ( pFuncBrush->m_iszExcludedClass == GetOuter()->m_iClassname ) || GetOuter()->NameMatches(pFuncBrush->m_iszExcludedClass); #else // do not match against entity name in base HL2 (just in case there is some case somewhere that might be broken by this) bool nameMatches = ( pFuncBrush->m_iszExcludedClass == GetOuter()->m_iClassname ); +#endif #endif // return true (ignore brush) if the name matches, or, if exclusion is inverted, if the name does not match diff --git a/sp/src/game/server/ai_pathfinder.cpp b/sp/src/game/server/ai_pathfinder.cpp index 5099925e..61c641a5 100644 --- a/sp/src/game/server/ai_pathfinder.cpp +++ b/sp/src/game/server/ai_pathfinder.cpp @@ -597,6 +597,17 @@ bool CAI_Pathfinder::IsLinkUsable(CAI_Link *pLink, int startID) // -------------------------------------------------------------------------- // Skip if link turned off // -------------------------------------------------------------------------- +#ifdef MAPBASE + if (pLink->m_pDynamicLink) + { + if (!pLink->m_pDynamicLink->UseAllowed(GetOuter(), startID == pLink->m_pDynamicLink->m_nDestID)) + return false; + } + else if (pLink->m_LinkInfo & bits_LINK_OFF) + { + return false; + } +#else if (pLink->m_LinkInfo & bits_LINK_OFF) { CAI_DynamicLink *pDynamicLink = pLink->m_pDynamicLink; @@ -618,6 +629,7 @@ bool CAI_Pathfinder::IsLinkUsable(CAI_Link *pLink, int startID) return false; } } +#endif // -------------------------------------------------------------------------- // Get the destination nodeID @@ -691,6 +703,12 @@ bool CAI_Pathfinder::IsLinkUsable(CAI_Link *pLink, int startID) return false; } } +#ifdef MAPBASE + if (pLink->m_pDynamicLink) + { + return pLink->m_pDynamicLink->FinalUseAllowed(GetOuter(), startID == pLink->m_pDynamicLink->m_nDestID); + } +#endif return true; } diff --git a/sp/src/game/server/ai_playerally.cpp b/sp/src/game/server/ai_playerally.cpp index 1f371fc9..2f1de740 100644 --- a/sp/src/game/server/ai_playerally.cpp +++ b/sp/src/game/server/ai_playerally.cpp @@ -12,6 +12,9 @@ #include "eventqueue.h" #include "ai_behavior_lead.h" #include "gameinterface.h" +#ifdef MAPBASE +#include "mapbase/matchers.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -338,6 +341,9 @@ BEGIN_DATADESC( CAI_PlayerAlly ) DEFINE_INPUTFUNC( FIELD_STRING, "SpeakResponseConcept", InputSpeakResponseConcept ), DEFINE_INPUTFUNC( FIELD_VOID, "MakeGameEndAlly", InputMakeGameEndAlly ), DEFINE_INPUTFUNC( FIELD_VOID, "MakeRegularAlly", InputMakeRegularAlly ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_STRING, "AskQuestion", InputAskQuestion ), +#endif DEFINE_INPUTFUNC( FIELD_INTEGER, "AnswerQuestion", InputAnswerQuestion ), DEFINE_INPUTFUNC( FIELD_INTEGER, "AnswerQuestionHello", InputAnswerQuestionHello ), DEFINE_INPUTFUNC( FIELD_VOID, "EnableSpeakWhileScripting", InputEnableSpeakWhileScripting ), @@ -725,8 +731,13 @@ bool CAI_PlayerAlly::SelectQuestionAndAnswerSpeech( AISpeechSelection_t *pSelect return false; // if there is a friend nearby to speak to, play sentence, set friend's response time, return +#ifdef MAPBASE + CAI_PlayerAlly *pFriend = dynamic_cast(FindSpeechTarget( AIST_NPCS | AIST_NOT_GAGGED )); + if ( pFriend && !pFriend->IsMoving() ) +#else CAI_PlayerAlly *pFriend = dynamic_cast(FindSpeechTarget( AIST_NPCS )); if ( pFriend && !pFriend->IsMoving() && !pFriend->HasSpawnFlags(SF_NPC_GAG) ) +#endif return SelectQuestionFriend( pFriend, pSelection ); return false; @@ -816,7 +827,17 @@ bool CAI_PlayerAlly::SelectQuestionFriend( CBaseEntity *pFriend, AISpeechSelecti // If we haven't said hello, say hello first. // Only ever say hello to NPCs other than my type. +#ifdef MAPBASE + // Why only say hello to NPCs other than my type? + // Are citizens a hivemind? Do they not greet each other? + // They don't have any responses for it anyway, so SelectSpeechResponse() will fail + // and TLK_HELLO_NPC will be marked as spoken. + // + // Responses could be added so modders/mappers can take advantage of this. + if ( !GetExpresser()->SpokeConcept( TLK_HELLO_NPC ) ) +#else if ( !GetExpresser()->SpokeConcept( TLK_HELLO_NPC ) && !FClassnameIs( this, pFriend->GetClassname()) ) +#endif { if ( SelectSpeechResponse( TLK_HELLO_NPC, NULL, pFriend, pSelection ) ) return true; @@ -844,6 +865,74 @@ bool CAI_PlayerAlly::SelectAnswerFriend( CBaseEntity *pFriend, AISpeechSelection return SelectSpeechResponse( TLK_ANSWER, NULL, pFriend, pSelection ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Asks a question now. +//----------------------------------------------------------------------------- +bool CAI_PlayerAlly::AskQuestionNow( CBaseEntity *pSpeechTarget, int iQARandomNumber, const char *concept ) +{ + m_hPotentialSpeechTarget = pSpeechTarget; + m_iQARandomNumber = iQARandomNumber; + + if (!m_hPotentialSpeechTarget) + m_hPotentialSpeechTarget = /*dynamic_cast*/(FindSpeechTarget( AIST_NPCS | AIST_NOT_GAGGED )); + + if (m_iQARandomNumber == -1) + m_iQARandomNumber = RandomInt(0, 100); + + AISpeechSelection_t selection; + SelectSpeechResponse( concept, NULL, m_hPotentialSpeechTarget.Get(), &selection ); + + SetSpeechTarget( selection.hSpeechTarget ); + ClearPendingSpeech(); + + if (!selection.pResponse) + return false; + + // Speak immediately + return SpeakDispatchResponse( selection.concept.c_str(), selection.pResponse ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CAI_PlayerAlly::InputAskQuestion( inputdata_t &inputdata ) +{ + CBaseEntity *pSpeechTarget = NULL; + int iQARandomNumber = 0; + const char *concept = TLK_QUESTION; + + // I didn't feel like using strtok today. + CUtlStringList vecStrings; + V_SplitString(inputdata.value.String(), " ", vecStrings); + FOR_EACH_VEC( vecStrings, i ) + { + // 0 : QA Number (-1 for N/A) + // 1 : Speech Target + // 2 : Concept + switch (i) + { + case 0: iQARandomNumber = atoi(vecStrings[i]); break; + case 1: pSpeechTarget = gEntList.FindEntityByName(NULL, vecStrings[i], this, inputdata.pActivator, inputdata.pCaller); break; + case 2: concept = vecStrings[i]; break; + } + } + + if (pSpeechTarget == NULL) + { + CAI_PlayerAlly *pFriend = dynamic_cast(FindSpeechTarget( AIST_NPCS | AIST_NOT_GAGGED )); + if ( pFriend ) + pSpeechTarget = pFriend; + } + else if (pSpeechTarget == this) + { + pSpeechTarget = NULL; + } + + AskQuestionNow(pSpeechTarget, iQARandomNumber, concept); +} +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -1077,6 +1166,24 @@ void CAI_PlayerAlly::Touch( CBaseEntity *pOther ) } } +#ifdef MAPBASE +ConVar mapbase_ally_flinching("mapbase_ally_flinching", "1", FCVAR_ARCHIVE, "Enables/disables the new flinching animations."); +//----------------------------------------------------------------------------- +// Purpose: This is to adjust for the new citizen flinching animations, +// as they would exist on all NPCs that use citizen animations. +// +// Vortigaunts and Alyx in the Episodes are the only ones who can flinch normally, +// and that's been rectified with their own functions. (they currently skip CAI_PlayerAlly's implementation) +//----------------------------------------------------------------------------- +bool CAI_PlayerAlly::CanFlinch( void ) +{ + if (mapbase_ally_flinching.GetBool() != true) + return false; + + return BaseClass::CanFlinch(); +} +#endif + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void CAI_PlayerAlly::OnKilledNPC( CBaseCombatCharacter *pKilled ) @@ -1087,6 +1194,10 @@ void CAI_PlayerAlly::OnKilledNPC( CBaseCombatCharacter *pKilled ) ( pKilled->MyNPCPointer()->GetLastPlayerDamageTime() == 0 || gpGlobals->curtime - pKilled->MyNPCPointer()->GetLastPlayerDamageTime() > 5 ) ) { +#ifdef MAPBASE + m_hPotentialSpeechTarget = pKilled; + SetSpeechTarget(pKilled); +#endif SpeakIfAllowed( TLK_ENEMY_DEAD ); } } @@ -1174,8 +1285,14 @@ void CAI_PlayerAlly::Event_Killed( const CTakeDamageInfo &info ) CBasePlayer *player = AI_GetSinglePlayer(); if ( player ) { +#ifdef MAPBASE + variant_t variant; + variant.SetEntity(this); + player->AcceptInput( "OnSquadMemberKilled", info.GetAttacker(), this, variant, 0 ); +#else variant_t emptyVariant; player->AcceptInput( "OnSquadMemberKilled", this, this, emptyVariant, 0 ); +#endif } } @@ -1185,6 +1302,10 @@ void CAI_PlayerAlly::Event_Killed( const CTakeDamageInfo &info ) CAI_PlayerAlly *pMourner = dynamic_cast(FindSpeechTarget( AIST_NPCS )); if ( pMourner ) { +#ifdef MAPBASE + pMourner->m_hPotentialSpeechTarget = this; + pMourner->SetSpeechTarget(this); +#endif pMourner->SpeakIfAllowed( TLK_ALLY_KILLED ); } @@ -1286,6 +1407,11 @@ bool CAI_PlayerAlly::IsValidSpeechTarget( int flags, CBaseEntity *pEntity ) // Don't bother people who don't want to be bothered if ( !pNPC->CanBeUsedAsAFriend() ) return false; + +#ifdef MAPBASE + if (flags & AIST_NOT_GAGGED && pNPC->HasSpawnFlags(SF_NPC_GAG)) + return false; +#endif } if ( flags & AIST_FACING_TARGET ) @@ -1591,6 +1717,19 @@ bool CAI_PlayerAlly::SpeakIfAllowed( AIConcept_t concept, const char *modifiers, return false; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +bool CAI_PlayerAlly::SpeakIfAllowed( AIConcept_t concept, AI_CriteriaSet& modifiers, bool bRespondingToPlayer, char *pszOutResponseChosen, size_t bufsize ) +{ + if ( IsAllowedToSpeak( concept, bRespondingToPlayer ) ) + { + return Speak( concept, modifiers, pszOutResponseChosen, bufsize ); + } + return false; +} +#endif + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void CAI_PlayerAlly::ModifyOrAppendCriteria( AI_CriteriaSet& set ) @@ -1602,6 +1741,11 @@ void CAI_PlayerAlly::ModifyOrAppendCriteria( AI_CriteriaSet& set ) set.AppendCriteria( "speechtarget", m_hPotentialSpeechTarget->GetClassname() ); set.AppendCriteria( "speechtargetname", STRING(m_hPotentialSpeechTarget->GetEntityName()) ); set.AppendCriteria( "randomnum", UTIL_VarArgs("%d", m_iQARandomNumber) ); + +#ifdef MAPBASE + // Speech target contexts. + m_hPotentialSpeechTarget->AppendContextToCriteria(set, "speechtarget_"); +#endif } // Do we have a speech filter? If so, append it's criteria too @@ -1618,11 +1762,13 @@ void CAI_PlayerAlly::OnSpokeConcept( AIConcept_t concept, AI_Response *response CAI_AllySpeechManager *pSpeechManager = GetAllySpeechManager(); pSpeechManager->OnSpokeConcept( this, concept, response ); +#ifndef MAPBASE // This has been moved directly to CAI_Expresser if( response != NULL && (response->GetParams()->flags & AI_ResponseParams::RG_WEAPONDELAY) ) { // Stop shooting, as instructed, so that my speech can be heard. GetShotRegulator()->FireNoEarlierThan( gpGlobals->curtime + response->GetWeaponDelay() ); } +#endif } //----------------------------------------------------------------------------- diff --git a/sp/src/game/server/ai_playerally.h b/sp/src/game/server/ai_playerally.h index 173b045a..dc9948ce 100644 --- a/sp/src/game/server/ai_playerally.h +++ b/sp/src/game/server/ai_playerally.h @@ -244,6 +244,10 @@ enum AISpeechTargetSearchFlags_t AIST_IGNORE_RELATIONSHIP = (1<<2), AIST_ANY_QUALIFIED = (1<<3), AIST_FACING_TARGET = (1<<4), +#ifdef MAPBASE + // I needed this for something + AIST_NOT_GAGGED = (1<<5), +#endif }; struct AISpeechSelection_t @@ -296,6 +300,10 @@ public: void ClearTransientConditions(); void Touch( CBaseEntity *pOther ); +#ifdef MAPBASE + virtual bool CanFlinch( void ); +#endif + //--------------------------------- // Combat //--------------------------------- @@ -325,6 +333,12 @@ public: CBaseEntity *GetSpeechTarget() { return m_hTalkTarget.Get(); } void SetSpeechTarget( CBaseEntity *pSpeechTarget ) { m_hTalkTarget = pSpeechTarget; } + +#ifdef MAPBASE + // Needed for additional speech target responses + CBaseEntity *GetPotentialSpeechTarget() { return m_hPotentialSpeechTarget.Get(); } + void SetPotentialSpeechTarget( CBaseEntity *pSpeechTarget ) { m_hPotentialSpeechTarget = pSpeechTarget; } +#endif void SetSpeechFilter( CAI_SpeechFilter *pFilter ) { m_hSpeechFilter = pFilter; } CAI_SpeechFilter *GetSpeechFilter( void ) { return m_hSpeechFilter; } @@ -373,6 +387,9 @@ public: bool ShouldSpeakRandom( AIConcept_t concept, int iChance ); bool IsAllowedToSpeak( AIConcept_t concept, bool bRespondingToPlayer = false ); virtual bool SpeakIfAllowed( AIConcept_t concept, const char *modifiers = NULL, bool bRespondingToPlayer = false, char *pszOutResponseChosen = NULL, size_t bufsize = 0 ); +#ifdef MAPBASE + virtual bool SpeakIfAllowed( AIConcept_t concept, AI_CriteriaSet& modifiers, bool bRespondingToPlayer = false, char *pszOutResponseChosen = NULL, size_t bufsize = 0 ); +#endif void ModifyOrAppendCriteria( AI_CriteriaSet& set ); //--------------------------------- @@ -398,6 +415,10 @@ public: virtual const char *GetDeathMessageText( void ) { return "GAMEOVER_ALLY"; } void InputMakeGameEndAlly( inputdata_t &inputdata ); void InputMakeRegularAlly( inputdata_t &inputdata ); +#ifdef MAPBASE + bool AskQuestionNow( CBaseEntity *pSpeechTarget = NULL, int iQARandomNumber = -1, const char *concept = TLK_QUESTION ); + void InputAskQuestion( inputdata_t &inputdata ); +#endif void InputAnswerQuestion( inputdata_t &inputdata ); void InputAnswerQuestionHello( inputdata_t &inputdata ); void InputEnableSpeakWhileScripting( inputdata_t &inputdata ); diff --git a/sp/src/game/server/ai_relationship.cpp b/sp/src/game/server/ai_relationship.cpp index eec28d99..a700552a 100644 --- a/sp/src/game/server/ai_relationship.cpp +++ b/sp/src/game/server/ai_relationship.cpp @@ -7,6 +7,9 @@ #include "cbase.h" #include "ndebugoverlay.h" #include "ai_basenpc.h" +#ifdef MAPBASE +#include "mapbase/matchers.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -34,6 +37,9 @@ public: void Activate(); void SetActive( bool bActive ); +#ifdef MAPBASE + virtual +#endif void ChangeRelationships( int disposition, int iReverting, CBaseEntity *pActivator = NULL, CBaseEntity *pCaller = NULL ); void ApplyRelationship( CBaseEntity *pActivator = NULL, CBaseEntity *pCaller = NULL ); @@ -45,11 +51,20 @@ public: bool IsASubject( CBaseEntity *pEntity ); bool IsATarget( CBaseEntity *pEntity ); +#ifdef MAPBASE + // Assume no insane person already has "CLASS_" at the beginning of an entity's (class)name. + inline bool IsSubjectClassify() { return Q_strncmp(STRING(m_target), "CLASS_", 6) == 0; } + inline bool IsTargetClassify() { return Q_strncmp(STRING(m_target), "CLASS_", 6) == 0; } +#endif void OnEntitySpawned( CBaseEntity *pEntity ); void OnEntityDeleted( CBaseEntity *pEntity ); +#ifdef MAPBASE +protected: +#else private: +#endif void ApplyRelationshipThink( void ); CBaseEntity *FindEntityForProceduralName( string_t iszName, CBaseEntity *pActivator, CBaseEntity *pCaller ); @@ -259,6 +274,12 @@ bool CAI_Relationship::IsASubject( CBaseEntity *pEntity ) if( pEntity->ClassMatches( m_iszSubject ) ) return true; +#ifdef MAPBASE + // Hopefully doesn't impact performance. + if (Matcher_NamesMatch(STRING(m_iszSubject), g_pGameRules->AIClassText((pEntity->Classify())))) + return true; +#endif + return false; } @@ -272,6 +293,12 @@ bool CAI_Relationship::IsATarget( CBaseEntity *pEntity ) if( pEntity->ClassMatches( m_target ) ) return true; +#ifdef MAPBASE + // Hopefully doesn't impact performance. + if (Matcher_NamesMatch(STRING(m_target), g_pGameRules->AIClassText((pEntity->Classify())))) + return true; +#endif + return false; } @@ -494,3 +521,133 @@ void CAI_Relationship::ChangeRelationships( int disposition, int iReverting, CBa } } +#ifdef MAPBASE +//========================================================= +//========================================================= +class CAI_ClassRelationship : public CAI_Relationship +{ + DECLARE_CLASS( CAI_ClassRelationship, CAI_Relationship ); + +public: + + // Must override CAI_Relationship + void Spawn() { m_bIsActive = false; } + + bool KeyValue( const char *szKeyName, const char *szValue ); + + void ChangeRelationships( int disposition, int iReverting, CBaseEntity *pActivator = NULL, CBaseEntity *pCaller = NULL ); + + inline bool SubjectUsingClassify() { return m_iSubjectClass != NUM_AI_CLASSES; } + inline bool TargetUsingClassify() { return m_iTargetClass != NUM_AI_CLASSES; } + +protected: + + Class_T m_iSubjectClass; + Class_T m_iTargetClass; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS( ai_relationship_classify, CAI_ClassRelationship ); + +BEGIN_DATADESC( CAI_ClassRelationship ) + + DEFINE_FIELD( m_iSubjectClass, FIELD_INTEGER ), + DEFINE_FIELD( m_iTargetClass, FIELD_INTEGER ), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: Caches entity key values until spawn is called. +// Input : szKeyName - +// szValue - +// Output : +//----------------------------------------------------------------------------- +bool CAI_ClassRelationship::KeyValue( const char *szKeyName, const char *szValue ) +{ + // Override regular subject and target from ai_relationship + if (FStrEq(szKeyName, "subject")) + { + m_iSubjectClass = (Class_T)atoi(szValue); + + // Direct string maybe + if (m_iSubjectClass == CLASS_NONE) + { + for (int i = 0; i < NUM_AI_CLASSES; i++) + { + if (FStrEq(szValue, g_pGameRules->AIClassText(i))) + { + m_iSubjectClass = (Class_T)i; + } + } + } + } + else if (FStrEq(szKeyName, "target")) + { + m_iTargetClass = (Class_T)atoi(szValue); + + // Direct string maybe + if (m_iTargetClass == CLASS_NONE) + { + for (int i = 0; i < NUM_AI_CLASSES; i++) + { + if (FStrEq(szValue, g_pGameRules->AIClassText(i))) + { + m_iTargetClass = (Class_T)i; + } + } + } + } + else + return BaseClass::KeyValue(szKeyName, szValue); + + return true; +} + +//--------------------------------------------------------- +//--------------------------------------------------------- +void CAI_ClassRelationship::ChangeRelationships( int disposition, int iReverting, CBaseEntity *pActivator, CBaseEntity *pCaller ) +{ + if( iReverting != NOT_REVERTING && m_iPreviousDisposition == -1 ) + { + // Trying to revert without having ever set the relationships! + DevMsg( 2, "ai_relationship cannot revert changes before they are applied!\n"); + return; + } + + if ( m_iPreviousDisposition == -1 && iReverting == NOT_REVERTING ) + { + // Set previous disposition. + m_iPreviousDisposition = CBaseCombatCharacter::GetDefaultRelationshipDisposition( m_iSubjectClass, m_iTargetClass ); + m_iPreviousRank = CBaseCombatCharacter::GetDefaultRelationshipPriority( m_iSubjectClass, m_iTargetClass ); + } + + // We can't actually reset to "default" without resetting all class relationships period, so we just use the previous disposition. + // There probably wouldn't be much overlap with this entity anyway. + if ( iReverting == REVERTING_TO_PREV || iReverting == REVERTING_TO_DEFAULT ) + { + CBaseCombatCharacter::SetDefaultRelationship(m_iSubjectClass, m_iTargetClass, (Disposition_t)m_iPreviousDisposition, m_iPreviousRank ); + + if( m_bReciprocal ) + { + CBaseCombatCharacter::SetDefaultRelationship(m_iTargetClass, m_iSubjectClass, (Disposition_t)m_iPreviousDisposition, m_iPreviousRank ); + } + } + else if( CBaseCombatCharacter::GetDefaultRelationshipDisposition( m_iSubjectClass, m_iTargetClass ) != disposition || + CBaseCombatCharacter::GetDefaultRelationshipPriority( m_iSubjectClass, m_iTargetClass ) != m_iRank ) + { + // Apply the relationship to the subject + CBaseCombatCharacter::SetDefaultRelationship(m_iSubjectClass, m_iTargetClass, (Disposition_t)disposition, m_iRank ); + + // Notification flags can't be used here. Sorry. + + // This relationship is applied to target and subject alike + if ( m_bReciprocal ) + { + // Apply the relationship to the target + CBaseCombatCharacter::SetDefaultRelationship(m_iTargetClass, m_iSubjectClass, (Disposition_t)disposition, m_iRank ); + } + } +} +#endif + diff --git a/sp/src/game/server/ai_scriptconditions.cpp b/sp/src/game/server/ai_scriptconditions.cpp index 9f10c0c3..18afdc3f 100644 --- a/sp/src/game/server/ai_scriptconditions.cpp +++ b/sp/src/game/server/ai_scriptconditions.cpp @@ -52,6 +52,9 @@ BEGIN_DATADESC( CAI_ScriptConditions ) DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_EHANDLE, "SatisfyConditions", InputSatisfyConditions ), +#endif //--------------------------------- @@ -195,12 +198,20 @@ bool CAI_ScriptConditions::EvalState( const EvalArgs_t &args ) -1, // NPC_STATE_PLAYDEAD -1, // NPC_STATE_PRONE -1, // NPC_STATE_DEAD +#ifdef MAPBASE + 3, // A "Don't care" for the maximum value +#endif }; int valState = stateVals[pNpc->m_NPCState]; if ( valState < 0 ) { +#ifdef MAPBASE + if (m_fMinState == 0) + return true; +#endif + if ( pNpc->m_NPCState == NPC_STATE_SCRIPT && m_fScriptStatus >= TRS_TRUE ) return true; @@ -676,6 +687,25 @@ void CAI_ScriptConditions::InputDisable( inputdata_t &inputdata ) Disable(); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- + +void CAI_ScriptConditions::InputSatisfyConditions( inputdata_t &inputdata ) +{ + // This satisfies things. + CBaseEntity *pActivator = HasSpawnFlags(SF_ACTOR_AS_ACTIVATOR) ? inputdata.value.Entity() : this; + m_OnConditionsSatisfied.FireOutput(pActivator, this); + + + //All done! + if ( m_ElementList.Count() == 1 ) + { + Disable(); + m_ElementList.Purge(); + } +} +#endif + //----------------------------------------------------------------------------- bool CAI_ScriptConditions::IsInFOV( CBaseEntity *pViewer, CBaseEntity *pViewed, float fov, bool bTrueCone ) diff --git a/sp/src/game/server/ai_scriptconditions.h b/sp/src/game/server/ai_scriptconditions.h index 8162c100..f63096ce 100644 --- a/sp/src/game/server/ai_scriptconditions.h +++ b/sp/src/game/server/ai_scriptconditions.h @@ -159,6 +159,9 @@ private: // Input handlers void InputEnable( inputdata_t &inputdata ); void InputDisable( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSatisfyConditions( inputdata_t &inputdata ); +#endif // Output handlers COutputEvent m_OnConditionsSatisfied; diff --git a/sp/src/game/server/ai_speech.cpp b/sp/src/game/server/ai_speech.cpp index d98fe7b8..2c729c33 100644 --- a/sp/src/game/server/ai_speech.cpp +++ b/sp/src/game/server/ai_speech.cpp @@ -16,6 +16,9 @@ #include "AI_Criteria.h" #include "isaverestore.h" #include "sceneentity.h" +#ifdef MAPBASE +#include "ai_squad.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include @@ -275,6 +278,17 @@ static const int LEN_SPECIFIC_SCENE_MODIFIER = strlen( AI_SPECIFIC_SCENE_MODIFIE //----------------------------------------------------------------------------- AI_Response *CAI_Expresser::SpeakFindResponse( AIConcept_t concept, const char *modifiers /*= NULL*/ ) { +#ifdef MAPBASE + AI_CriteriaSet set; + + if (modifiers) + { + MergeModifiers(set, modifiers); + } + + // Now return the code in the new function. + return SpeakFindResponse(concept, set); +#else IResponseSystem *rs = GetOuter()->GetResponseSystem(); if ( !rs ) { @@ -319,6 +333,131 @@ AI_Response *CAI_Expresser::SpeakFindResponse( AIConcept_t concept, const char * pPlayer->ModifyOrAppendPlayerCriteria( set ); } +#ifdef MAPBASE + GetOuter()->ReAppendContextCriteria( set ); +#endif + + // Now that we have a criteria set, ask for a suitable response + AI_Response *result = new AI_Response; + Assert( result && "new AI_Response: Returned a NULL AI_Response!" ); + bool found = rs->FindBestResponse( set, *result, this ); + + if ( rr_debugresponses.GetInt() == 3 ) + { + if ( ( GetOuter()->MyNPCPointer() && GetOuter()->m_debugOverlays & OVERLAY_NPC_SELECTED_BIT ) || GetOuter()->IsPlayer() ) + { + const char *pszName; + if ( GetOuter()->IsPlayer() ) + { + pszName = ((CBasePlayer*)GetOuter())->GetPlayerName(); + } + else + { + pszName = GetOuter()->GetDebugName(); + } + + if ( found ) + { + char response[ 256 ]; + result->GetResponse( response, sizeof( response ) ); + + Warning( "RESPONSERULES: %s spoke '%s'. Found response '%s'.\n", pszName, concept, response ); + } + else + { + Warning( "RESPONSERULES: %s spoke '%s'. Found no matching response.\n", pszName, concept ); + } + } + } + + if ( !found ) + { + //Assert( !"rs->FindBestResponse: Returned a NULL AI_Response!" ); + delete result; + return NULL; + } + + char response[ 256 ]; + result->GetResponse( response, sizeof( response ) ); + + if ( !response[0] ) + { + delete result; + return NULL; + } + + if ( result->GetOdds() < 100 && random->RandomInt( 1, 100 ) <= result->GetOdds() ) + { + delete result; + return NULL; + } + + return result; +#endif +} + +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Merges modifiers with set. +//----------------------------------------------------------------------------- +void CAI_Expresser::MergeModifiers( AI_CriteriaSet& set, const char *modifiers ) +{ + char copy_modifiers[ 255 ]; + const char *pCopy; + char key[ 128 ] = { 0 }; + char value[ 128 ] = { 0 }; + + Q_strncpy( copy_modifiers, modifiers, sizeof( copy_modifiers ) ); + pCopy = copy_modifiers; + + while( pCopy ) + { + pCopy = SplitContext( pCopy, key, sizeof( key ), value, sizeof( value ), NULL ); + + if( *key && *value ) + { + set.AppendCriteria( key, value, CONCEPT_WEIGHT ); + } + } +} + +//----------------------------------------------------------------------------- +// Purpose: Searches for a possible response, takes an AI_CriteriaSet instead. +// Input : concept - +// NULL - +// Output : AI_Response +//----------------------------------------------------------------------------- +AI_Response *CAI_Expresser::SpeakFindResponse( AIConcept_t concept, AI_CriteriaSet &modifiers ) +{ + IResponseSystem *rs = GetOuter()->GetResponseSystem(); + if ( !rs ) + { + Assert( !"No response system installed for CAI_Expresser::GetOuter()!!!" ); + return NULL; + } + + AI_CriteriaSet set; + // Always include the concept name + set.AppendCriteria( "concept", concept, CONCEPT_WEIGHT ); + + // Tier 1: Criteria + // Let our outer fill in most match criteria + GetOuter()->ModifyOrAppendCriteria( set ); + + // Append local player criteria to set, but not if this is a player doing the talking + if ( !GetOuter()->IsPlayer() ) + { + CBasePlayer *pPlayer = UTIL_PlayerByIndex( 1 ); + if( pPlayer ) + pPlayer->ModifyOrAppendPlayerCriteria( set ); + } + + // Tier 2: Modifiers + set.MergeSet(modifiers); + + // Tier 3: Contexts + GetOuter()->ReAppendContextCriteria( set ); + // Now that we have a criteria set, ask for a suitable response AI_Response *result = new AI_Response; Assert( result && "new AI_Response: Returned a NULL AI_Response!" ); @@ -376,16 +515,45 @@ AI_Response *CAI_Expresser::SpeakFindResponse( AIConcept_t concept, const char * return result; } +#endif //----------------------------------------------------------------------------- // Purpose: Dispatches the result // Input : *response - //----------------------------------------------------------------------------- +#ifdef MAPBASE +bool CAI_Expresser::SpeakDispatchResponse( AIConcept_t concept, AI_Response *result, IRecipientFilter *filter, const char *modifiers ) +#else bool CAI_Expresser::SpeakDispatchResponse( AIConcept_t concept, AI_Response *result, IRecipientFilter *filter /* = NULL */ ) +#endif { char response[ 256 ]; result->GetResponse( response, sizeof( response ) ); +#ifdef MAPBASE + if (response[0] == '$') + { + response[0] = '\0'; + const char *replace = GetOuter()->GetContextValue(response); + if (!replace) + { + replace = modifiers; + + char key[128] = { 0 }; + char value[128] = { 0 }; + replace = SplitContext(replace, key, sizeof(key), value, sizeof(value), NULL); + replace = value; + } + + if (replace) + { + DevMsg("Replacing %s with %s...\n", response, GetOuter()->GetContextValue(response)); + Q_strncpy(response, replace, sizeof(response)); + GetOuter()->PrecacheScriptSound( response ); + } + } +#endif + float delay = result->GetDelay(); bool spoke = false; @@ -475,6 +643,57 @@ bool CAI_Expresser::SpeakDispatchResponse( AIConcept_t concept, AI_Response *res NDebugOverlay::Text( vPrintPos, CFmtStr( "%s: %s", concept, response ), true, 1.5 ); } +#ifdef MAPBASE + if (result->GetContext()) + { + const char *pszContext = result->GetContext(); + + // Check for operators + char *pOperator = Q_strstr(pszContext, ":")+1; + if (pOperator && (pOperator[0] == '+' || pOperator[0] == '-' || + pOperator[0] == '*' || pOperator[0] == '/')) + { + pszContext = ParseApplyContext(pszContext); + } + + int iContextFlags = result->GetContextFlags(); + if ( iContextFlags & APPLYCONTEXT_SQUAD ) + { + CAI_BaseNPC *pNPC = GetOuter()->MyNPCPointer(); + if (pNPC && pNPC->GetSquad()) + { + AISquadIter_t iter; + CAI_BaseNPC *pSquadmate = pNPC->GetSquad()->GetFirstMember( &iter ); + while ( pSquadmate ) + { + pSquadmate->AddContext( pszContext ); + + pSquadmate = pNPC->GetSquad()->GetNextMember( &iter ); + } + } + } + if ( iContextFlags & APPLYCONTEXT_ENEMY ) + { + CBaseEntity *pEnemy = GetOuter()->GetEnemy(); + if ( pEnemy ) + { + pEnemy->AddContext( pszContext ); + } + } + if ( iContextFlags & APPLYCONTEXT_WORLD ) + { + CBaseEntity *pEntity = CBaseEntity::Instance( engine->PEntityOfEntIndex( 0 ) ); + if ( pEntity ) + { + pEntity->AddContext( pszContext ); + } + } + if ( iContextFlags == 0 || iContextFlags & APPLYCONTEXT_SELF ) + { + GetOuter()->AddContext( pszContext ); + } + } +#else if ( result->IsApplyContextToWorld() ) { CBaseEntity *pEntity = CBaseEntity::Instance( engine->PEntityOfEntIndex( 0 ) ); @@ -487,6 +706,7 @@ bool CAI_Expresser::SpeakDispatchResponse( AIConcept_t concept, AI_Response *res { GetOuter()->AddContext( result->GetContext() ); } +#endif SetSpokeConcept( concept, result ); } else @@ -569,6 +789,32 @@ bool CAI_Expresser::Speak( AIConcept_t concept, const char *modifiers /*= NULL*/ return spoke; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Uses an AI_CriteriaSet directly instead of using context-format modifier text. +// Input : concept - +// Output : Returns true on success, false on failure. +//----------------------------------------------------------------------------- +bool CAI_Expresser::Speak( AIConcept_t concept, AI_CriteriaSet& modifiers, char *pszOutResponseChosen /* = NULL*/, size_t bufsize /* = 0 */, IRecipientFilter *filter /* = NULL */ ) +{ + AI_Response *result = SpeakFindResponse( concept, modifiers ); + if ( !result ) + { + return false; + } + + SpeechMsg( GetOuter(), "%s (%p) spoke %s (%f)\n", STRING(GetOuter()->GetEntityName()), GetOuter(), concept, gpGlobals->curtime ); + + bool spoke = SpeakDispatchResponse( concept, result, filter ); + if ( pszOutResponseChosen ) + { + result->GetResponse( pszOutResponseChosen, bufsize ); + } + + return spoke; +} +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -821,8 +1067,32 @@ void CAI_Expresser::SetSpokeConcept( AIConcept_t concept, AI_Response *response, slot->response = response; } +#ifdef MAPBASE + // This "weapondelay" was just in player allies before. + // Putting it here eliminates the need to implement OnSpokeConcept on all NPCs for weapondelay. + if ( bCallback ) + { + if( response != NULL && (response->GetParams()->flags & AI_ResponseParams::RG_WEAPONDELAY) ) + { + if ( GetOuter()->IsNPC() ) + { + // Stop shooting, as instructed, so that my speech can be heard. + GetOuter()->MyNPCPointer()->GetShotRegulator()->FireNoEarlierThan( gpGlobals->curtime + response->GetWeaponDelay() ); + } + else + { + char szResponse[64]; + response->GetName(szResponse, sizeof(szResponse)); + Warning("%s response %s wants to use weapondelay, but %s is not a NPC!\n", GetOuter()->GetDebugName(), szResponse, GetOuter()->GetDebugName()); + } + } + + GetSink()->OnSpokeConcept( concept, response ); + } +#else if ( bCallback ) GetSink()->OnSpokeConcept( concept, response ); +#endif } //------------------------------------- @@ -894,6 +1164,66 @@ void CAI_Expresser::SpeechMsg( CBaseEntity *pFlex, const char *pszFormat, ... ) UTIL_LogPrintf( string ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +char *CAI_Expresser::ParseApplyContext( const char *szContext ) +{ + char szKey[128]; + char szValue[128]; + float flDuration = 0.0; + + SplitContext(szContext, szKey, sizeof(szKey), szValue, sizeof(szValue), &flDuration); + + // This is the value without the operator + const char *pszValue = szValue + 1; + + // This is the operator itself + char cOperator = szValue[0]; + + // This is the value to operate with (e.g. the "7" in "+7") + float flNewValue = atof( pszValue ); + + if (flNewValue == 0.0f) + { + // If it's really 0, then this is a waste of time + Warning("\"%s\" was detected by applyContext operators as an operable number, but it's not.\n", szValue); + return strdup(szContext); + } + + // This is the existing value; will be operated upon and become the final assignment + float flValue = 0.0f; + const char *szExistingValue = GetOuter()->GetContextValue(szKey); + if (szExistingValue) + flValue = atof(szExistingValue); + + // Do the operation based on what the character was + switch (cOperator) + { + case '+': flValue += flNewValue; break; + case '-': flValue -= flNewValue; break; + case '*': flValue *= flNewValue; break; + case '/': flValue /= flNewValue; break; + } + + Q_snprintf(szValue, sizeof(szValue), "%f", flValue); + + // Remove all trailing 0's from the float to maintain whole integers + int i; + for (i = strlen(szValue)-1; szValue[i] == '0'; i--) + { + szValue[i] = '\0'; + } + + // If there were only zeroes past the period, this is a whole number. Remove the period + if (szValue[i] == '.') + szValue[i] = '\0'; + + return UTIL_VarArgs("%s:%s:%f", szKey, szValue, flDuration); +} +#endif + //----------------------------------------------------------------------------- @@ -912,6 +1242,7 @@ void CAI_ExpresserHost_NPC_DoModifyOrAppendCriteria( CAI_BaseNPC *pSpeaker, AI_C set.AppendCriteria( "npcstate", UTIL_VarArgs( "[NPCState::%s]", pStateNames[pSpeaker->m_NPCState] ) ); } +#ifndef MAPBASE if ( pSpeaker->GetEnemy() ) { set.AppendCriteria( "enemy", pSpeaker->GetEnemy()->GetClassname() ); @@ -924,6 +1255,7 @@ void CAI_ExpresserHost_NPC_DoModifyOrAppendCriteria( CAI_BaseNPC *pSpeaker, AI_C else set.AppendCriteria( "timesincecombat", UTIL_VarArgs( "%f", gpGlobals->curtime - pSpeaker->GetLastEnemyTime() ) ); } +#endif set.AppendCriteria( "speed", UTIL_VarArgs( "%.3f", pSpeaker->GetSmoothedVelocity().Length() ) ); diff --git a/sp/src/game/server/ai_speech.h b/sp/src/game/server/ai_speech.h index 683b4e62..7c3c30cb 100644 --- a/sp/src/game/server/ai_speech.h +++ b/sp/src/game/server/ai_speech.h @@ -157,10 +157,19 @@ public: // -------------------------------- bool Speak( AIConcept_t concept, const char *modifiers = NULL, char *pszOutResponseChosen = NULL, size_t bufsize = 0, IRecipientFilter *filter = NULL ); +#ifdef MAPBASE + bool Speak( AIConcept_t concept, AI_CriteriaSet& modifiers, char *pszOutResponseChosen = NULL, size_t bufsize = 0, IRecipientFilter *filter = NULL ); + AI_Response *SpeakFindResponse( AIConcept_t concept, AI_CriteriaSet& modifiers ); + void MergeModifiers( AI_CriteriaSet& set, const char *modifiers ); +#endif // These two methods allow looking up a response and dispatching it to be two different steps AI_Response *SpeakFindResponse( AIConcept_t concept, const char *modifiers = NULL ); +#ifdef MAPBASE + bool SpeakDispatchResponse( AIConcept_t concept, AI_Response *response, IRecipientFilter *filter = NULL, const char *modifiers = NULL ); +#else bool SpeakDispatchResponse( AIConcept_t concept, AI_Response *response, IRecipientFilter *filter = NULL ); +#endif float GetResponseDuration( AI_Response *response ); virtual int SpeakRawSentence( const char *pszSentence, float delay, float volume = VOL_NORM, soundlevel_t soundlevel = SNDLVL_TALKING, CBaseEntity *pListener = NULL ); @@ -205,6 +214,11 @@ protected: void SpeechMsg( CBaseEntity *pFlex, PRINTF_FORMAT_STRING const char *pszFormat, ... ); +#ifdef MAPBASE + // Handles context operators + char *ParseApplyContext( const char *szContext ); +#endif + // -------------------------------- CAI_ExpresserSink *GetSink() { return m_pSink; } @@ -281,9 +295,15 @@ public: virtual void NoteSpeaking( float duration, float delay ); virtual bool Speak( AIConcept_t concept, const char *modifiers = NULL, char *pszOutResponseChosen = NULL, size_t bufsize = 0, IRecipientFilter *filter = NULL ); +#ifdef MAPBASE + virtual bool Speak( AIConcept_t concept, AI_CriteriaSet& modifiers, char *pszOutResponseChosen = NULL, size_t bufsize = 0, IRecipientFilter *filter = NULL ); +#endif // These two methods allow looking up a response and dispatching it to be two different steps AI_Response * SpeakFindResponse( AIConcept_t concept, const char *modifiers = NULL ); +#ifdef MAPBASE + AI_Response * SpeakFindResponse( AIConcept_t concept, AI_CriteriaSet& modifiers ); +#endif bool SpeakDispatchResponse( AIConcept_t concept, AI_Response *response ); virtual void PostSpeakDispatchResponse( AIConcept_t concept, AI_Response *response ) { return; } float GetResponseDuration( AI_Response *response ); @@ -324,6 +344,18 @@ inline bool CAI_ExpresserHost::Speak( AIConcept_t concept, const char return this->GetExpresser()->Speak( concept, modifiers, pszOutResponseChosen, bufsize, filter ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Version of Speak() that takes a direct AI_CriteriaSet for modifiers. +//----------------------------------------------------------------------------- +template +inline bool CAI_ExpresserHost::Speak( AIConcept_t concept, AI_CriteriaSet& modifiers, char *pszOutResponseChosen /*=NULL*/, size_t bufsize /* = 0 */, IRecipientFilter *filter /* = NULL */ ) +{ + AssertOnce( this->GetExpresser()->GetOuter() == this ); + return this->GetExpresser()->Speak( concept, modifiers, pszOutResponseChosen, bufsize, filter ); +} +#endif + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- template @@ -365,6 +397,16 @@ inline AI_Response *CAI_ExpresserHost::SpeakFindResponse( AIConcept_t return this->GetExpresser()->SpeakFindResponse( concept, modifiers ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +template +inline AI_Response *CAI_ExpresserHost::SpeakFindResponse( AIConcept_t concept, AI_CriteriaSet& modifiers ) +{ + return this->GetExpresser()->SpeakFindResponse( concept, modifiers ); +} +#endif + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- template diff --git a/sp/src/game/server/ai_task.cpp b/sp/src/game/server/ai_task.cpp index a2cf6be6..6e471351 100644 --- a/sp/src/game/server/ai_task.cpp +++ b/sp/src/game/server/ai_task.cpp @@ -222,6 +222,9 @@ void CAI_BaseNPC::InitDefaultTaskSR(void) ADD_DEF_TASK( TASK_ADD_HEALTH ); ADD_DEF_TASK( TASK_GET_PATH_TO_INTERACTION_PARTNER ); ADD_DEF_TASK( TASK_PRE_SCRIPT ); +#ifdef MAPBASE + ADD_DEF_TASK( TASK_FACE_INTERACTION_ANGLES ); +#endif } diff --git a/sp/src/game/server/ai_task.h b/sp/src/game/server/ai_task.h index 43170a39..dc167752 100644 --- a/sp/src/game/server/ai_task.h +++ b/sp/src/game/server/ai_task.h @@ -494,6 +494,11 @@ enum sharedtasks_e // First task of all schedules for playing back scripted sequences TASK_PRE_SCRIPT, +#ifdef MAPBASE + // Faces the actual interaction angles instead of just facing the enemy + TASK_FACE_INTERACTION_ANGLES, +#endif + // ====================================== // IMPORTANT: This must be the last enum // ====================================== diff --git a/sp/src/game/server/baseanimating.cpp b/sp/src/game/server/baseanimating.cpp index 34bf6378..17957d95 100644 --- a/sp/src/game/server/baseanimating.cpp +++ b/sp/src/game/server/baseanimating.cpp @@ -27,6 +27,11 @@ #include "datacache/idatacache.h" #include "smoke_trail.h" #include "props.h" +#ifdef MAPBASE +#include "ai_speech.h" +#include "gib.h" +#include "CRagdollMagnet.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -202,9 +207,16 @@ BEGIN_DATADESC( CBaseAnimating ) DEFINE_INPUTFUNC( FIELD_INTEGER, "IgniteNumHitboxFires", InputIgniteNumHitboxFires ), DEFINE_INPUTFUNC( FIELD_FLOAT, "IgniteHitboxFireScale", InputIgniteHitboxFireScale ), DEFINE_INPUTFUNC( FIELD_VOID, "BecomeRagdoll", InputBecomeRagdoll ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "CreateSeparateRagdoll", InputCreateSeparateRagdoll ), + DEFINE_INPUTFUNC( FIELD_VOID, "CreateSeparateRagdollClient", InputCreateSeparateRagdollClient ), +#endif DEFINE_INPUTFUNC( FIELD_STRING, "SetLightingOriginHack", InputSetLightingOriginRelative ), DEFINE_INPUTFUNC( FIELD_STRING, "SetLightingOrigin", InputSetLightingOrigin ), DEFINE_OUTPUT( m_OnIgnite, "OnIgnite" ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OnServerRagdoll, "OnServerRagdoll" ), +#endif DEFINE_INPUT( m_fadeMinDist, FIELD_FLOAT, "fademindist" ), DEFINE_INPUT( m_fadeMaxDist, FIELD_FLOAT, "fademaxdist" ), @@ -212,6 +224,12 @@ BEGIN_DATADESC( CBaseAnimating ) DEFINE_KEYFIELD( m_flModelScale, FIELD_FLOAT, "modelscale" ), DEFINE_INPUTFUNC( FIELD_VECTOR, "SetModelScale", InputSetModelScale ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_STRING, "SetModel", InputSetModel ), + + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetCycle", InputSetCycle ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetPlaybackRate", InputSetPlaybackRate ), +#endif DEFINE_FIELD( m_fBoneCacheFlags, FIELD_SHORT ), @@ -528,7 +546,11 @@ void CBaseAnimating::StudioFrameAdvance() //----------------------------------------------------------------------------- // Set the relative lighting origin //----------------------------------------------------------------------------- +#ifdef MAPBASE +void CBaseAnimating::SetLightingOriginRelative( string_t strLightingOriginRelative, inputdata_t *inputdata ) +#else void CBaseAnimating::SetLightingOriginRelative( string_t strLightingOriginRelative ) +#endif { if ( strLightingOriginRelative == NULL_STRING ) { @@ -536,7 +558,11 @@ void CBaseAnimating::SetLightingOriginRelative( string_t strLightingOriginRelati } else { +#ifdef MAPBASE + CBaseEntity *pLightingOrigin = gEntList.FindEntityByName( NULL, strLightingOriginRelative, this, inputdata ? inputdata->pActivator : NULL, inputdata ? inputdata->pCaller : NULL ); +#else CBaseEntity *pLightingOrigin = gEntList.FindEntityByName( NULL, strLightingOriginRelative ); +#endif if ( !pLightingOrigin ) { DevWarning( "%s: Could not find info_lighting_relative '%s'!\n", GetClassname(), STRING( strLightingOriginRelative ) ); @@ -566,7 +592,11 @@ void CBaseAnimating::SetLightingOriginRelative( string_t strLightingOriginRelati //----------------------------------------------------------------------------- // Set the lighting origin //----------------------------------------------------------------------------- +#ifdef MAPBASE +void CBaseAnimating::SetLightingOrigin( string_t strLightingOrigin, inputdata_t *inputdata ) +#else void CBaseAnimating::SetLightingOrigin( string_t strLightingOrigin ) +#endif { if ( strLightingOrigin == NULL_STRING ) { @@ -574,7 +604,11 @@ void CBaseAnimating::SetLightingOrigin( string_t strLightingOrigin ) } else { +#ifdef MAPBASE + CBaseEntity *pLightingOrigin = gEntList.FindEntityByName( NULL, strLightingOrigin, this, inputdata ? inputdata->pActivator : NULL, inputdata ? inputdata->pCaller : NULL ); +#else CBaseEntity *pLightingOrigin = gEntList.FindEntityByName( NULL, strLightingOrigin ); +#endif if ( !pLightingOrigin ) { DevWarning( "%s: Could not find lighting origin entity named '%s'!\n", GetClassname(), STRING( strLightingOrigin ) ); @@ -597,9 +631,15 @@ void CBaseAnimating::SetLightingOrigin( string_t strLightingOrigin ) //----------------------------------------------------------------------------- void CBaseAnimating::InputSetLightingOriginRelative( inputdata_t &inputdata ) { +#ifdef MAPBASE + // Pass our input data now. + // (and stop doing that MAKE_STRING nonsense) + SetLightingOriginRelative( inputdata.value.StringID(), &inputdata ); +#else // Find our specified target string_t strLightingOriginRelative = MAKE_STRING( inputdata.value.String() ); SetLightingOriginRelative( strLightingOriginRelative ); +#endif } //----------------------------------------------------------------------------- @@ -608,9 +648,15 @@ void CBaseAnimating::InputSetLightingOriginRelative( inputdata_t &inputdata ) //----------------------------------------------------------------------------- void CBaseAnimating::InputSetLightingOrigin( inputdata_t &inputdata ) { +#ifdef MAPBASE + // Pass our input data now. + // (and stop doing that MAKE_STRING nonsense) + SetLightingOrigin( inputdata.value.StringID(), &inputdata ); +#else // Find our specified target string_t strLightingOrigin = MAKE_STRING( inputdata.value.String() ); SetLightingOrigin( strLightingOrigin ); +#endif } //----------------------------------------------------------------------------- @@ -624,6 +670,37 @@ void CBaseAnimating::InputSetModelScale( inputdata_t &inputdata ) SetModelScale( vecScale.x, vecScale.y ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Sets our current model +//----------------------------------------------------------------------------- +void CBaseAnimating::InputSetModel( inputdata_t &inputdata ) +{ + const char *szModel = inputdata.value.String(); + if (PrecacheModel(szModel) != -1) + { + SetModelName(AllocPooledString(szModel)); + SetModel(szModel); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Sets our current cycle +//----------------------------------------------------------------------------- +void CBaseAnimating::InputSetCycle( inputdata_t &inputdata ) +{ + SetCycle( inputdata.value.Float() ); +} + +//----------------------------------------------------------------------------- +// Purpose: Sets our current cycle +//----------------------------------------------------------------------------- +void CBaseAnimating::InputSetPlaybackRate( inputdata_t &inputdata ) +{ + SetPlaybackRate( inputdata.value.Float() ); +} +#endif + //========================================================= // SelectWeightedSequence @@ -1145,6 +1222,21 @@ void CBaseAnimating::HandleAnimEvent( animevent_t *pEvent ) EmitSound( pEvent->options ); return; } +#ifdef MAPBASE + else if ( pEvent->event == AE_NPC_RESPONSE ) + { + if (!MyNPCPointer()->GetExpresser()->IsSpeaking()) + { + DispatchResponse( pEvent->options ); + } + return; + } + else if ( pEvent->event == AE_NPC_RESPONSE_FORCED ) + { + DispatchResponse( pEvent->options ); + return; + } +#endif else if ( pEvent->event == AE_RAGDOLL ) { // Convert to ragdoll immediately @@ -3539,6 +3631,44 @@ void CBaseAnimating::InputBecomeRagdoll( inputdata_t &inputdata ) BecomeRagdollOnClient( vec3_origin ); } +#ifdef MAPBASE +void CBaseAnimating::InputCreateSeparateRagdoll( inputdata_t &inputdata ) +{ + CTakeDamageInfo info( this, inputdata.pActivator, 0.0f, DMG_GENERIC ); + + // See if there's a ragdoll magnet that should influence our force. + CRagdollMagnet *pMagnet = CRagdollMagnet::FindBestMagnet( this ); + if( pMagnet ) + { + info.SetDamageForce(pMagnet->GetForceVector( this )); + pMagnet->m_OnUsed.Set(info.GetDamageForce(), this, pMagnet); + } + + CreateServerRagdoll( this, 0, info, COLLISION_GROUP_INTERACTIVE_DEBRIS, true ); +} + +void CBaseAnimating::InputCreateSeparateRagdollClient( inputdata_t &inputdata ) +{ + // I remember there being a reason why this must be initialized to all 0's... + Vector forceVector = Vector(0.0f, 0.0f, 0.0f); + + // See if there's a ragdoll magnet that should influence our force. + CRagdollMagnet *pMagnet = CRagdollMagnet::FindBestMagnet( this ); + if( pMagnet ) + { + forceVector += pMagnet->GetForceVector( this ); + pMagnet->m_OnUsed.Set(forceVector, this, pMagnet); + } + + CBaseEntity *pRagdoll = CreateRagGib( STRING( GetModelName() ), GetAbsOrigin(), GetAbsAngles(), forceVector, 25.0f ); + + if (pRagdoll->GetBaseAnimating()) + { + pRagdoll->GetBaseAnimating()->CopyAnimationDataFrom( this ); + } +} +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- diff --git a/sp/src/game/server/baseanimating.h b/sp/src/game/server/baseanimating.h index 75300e8e..abaec974 100644 --- a/sp/src/game/server/baseanimating.h +++ b/sp/src/game/server/baseanimating.h @@ -297,6 +297,10 @@ public: void InputIgniteNumHitboxFires( inputdata_t &inputdata ); void InputIgniteHitboxFireScale( inputdata_t &inputdata ); void InputBecomeRagdoll( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputCreateSeparateRagdoll( inputdata_t &inputdata ); + void InputCreateSeparateRagdollClient( inputdata_t &inputdata ); +#endif // Dissolve, returns true if the ragdoll has been created bool Dissolve( const char *pMaterialName, float flStartTime, bool bNPCOnly = true, int nDissolveType = 0, Vector vDissolverOrigin = vec3_origin, int iMagnitude = 0 ); @@ -308,11 +312,19 @@ public: float m_flLastEventCheck; // cycle index of when events were last checked virtual void SetLightingOriginRelative( CBaseEntity *pLightingOriginRelative ); +#ifdef MAPBASE + void SetLightingOriginRelative( string_t strLightingOriginRelative, inputdata_t *inputdata = NULL ); +#else void SetLightingOriginRelative( string_t strLightingOriginRelative ); +#endif CBaseEntity *GetLightingOriginRelative(); virtual void SetLightingOrigin( CBaseEntity *pLightingOrigin ); +#ifdef MAPBASE + void SetLightingOrigin( string_t strLightingOrigin, inputdata_t *inputdata = NULL ); +#else void SetLightingOrigin( string_t strLightingOrigin ); +#endif CBaseEntity *GetLightingOrigin(); const float* GetPoseParameterArray() { return m_flPoseParameter.Base(); } @@ -339,6 +351,12 @@ private: void InputSetLightingOriginRelative( inputdata_t &inputdata ); void InputSetLightingOrigin( inputdata_t &inputdata ); void InputSetModelScale( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetModel( inputdata_t &inputdata ); + + void InputSetCycle( inputdata_t &inputdata ); + void InputSetPlaybackRate( inputdata_t &inputdata ); +#endif bool CanSkipAnimation( void ); @@ -415,6 +433,9 @@ protected: public: COutputEvent m_OnIgnite; +#ifdef MAPBASE + COutputEHANDLE m_OnServerRagdoll; +#endif private: CStudioHdr *m_pStudioHdr; diff --git a/sp/src/game/server/basebludgeonweapon.cpp b/sp/src/game/server/basebludgeonweapon.cpp index ff8df099..cb9c1fc8 100644 --- a/sp/src/game/server/basebludgeonweapon.cpp +++ b/sp/src/game/server/basebludgeonweapon.cpp @@ -93,6 +93,14 @@ void CBaseHLBludgeonWeapon::ItemPostFrame( void ) if ( pOwner == NULL ) return; +#ifdef MAPBASE + if (pOwner->HasSpawnFlags( SF_PLAYER_SUPPRESS_FIRING )) + { + WeaponIdle(); + return; + } +#endif + if ( (pOwner->m_nButtons & IN_ATTACK) && (m_flNextPrimaryAttack <= gpGlobals->curtime) ) { PrimaryAttack(); @@ -363,12 +371,27 @@ void CBaseHLBludgeonWeapon::Swing( int bIsSecondary ) // We want to test the first swing again Vector testEnd = swingStart + forward * GetRange(); + +#ifdef MAPBASE + // Sound has been moved here since we're using the other melee sounds now + WeaponSound( SINGLE ); +#endif // See if we happened to hit water ImpactWater( swingStart, testEnd ); } else { +#ifdef MAPBASE + // Other melee sounds + if (traceHit.m_pEnt && traceHit.m_pEnt->IsWorld()) + WeaponSound(MELEE_HIT_WORLD); + else if (traceHit.m_pEnt && !traceHit.m_pEnt->PassesDamageFilter(triggerInfo)) + WeaponSound(MELEE_MISS); + else + WeaponSound(MELEE_HIT); +#endif + Hit( traceHit, nHitActivity, bIsSecondary ? true : false ); } @@ -379,6 +402,8 @@ void CBaseHLBludgeonWeapon::Swing( int bIsSecondary ) m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate(); m_flNextSecondaryAttack = gpGlobals->curtime + SequenceDuration(); +#ifndef MAPBASE //Play swing sound WeaponSound( SINGLE ); +#endif } diff --git a/sp/src/game/server/basecombatcharacter.cpp b/sp/src/game/server/basecombatcharacter.cpp index 9f6a8674..37764b22 100644 --- a/sp/src/game/server/basecombatcharacter.cpp +++ b/sp/src/game/server/basecombatcharacter.cpp @@ -61,6 +61,11 @@ extern int g_interactionBarnacleVictimReleased; #endif //HL2_DLL +#ifdef MAPBASE +extern acttable_t *GetSMG1Acttable(); +extern int GetSMG1ActtableCount(); +#endif + extern ConVar weapon_showproficiency; ConVar ai_show_hull_attacks( "ai_show_hull_attacks", "0" ); @@ -97,16 +102,46 @@ BEGIN_DATADESC( CBaseCombatCharacter ) DEFINE_FIELD( m_flDamageAccumulator, FIELD_FLOAT ), DEFINE_INPUT( m_impactEnergyScale, FIELD_FLOAT, "physdamagescale" ), DEFINE_FIELD( m_CurrentWeaponProficiency, FIELD_INTEGER), +#ifdef MAPBASE + DEFINE_INPUT( m_ProficiencyOverride, FIELD_INTEGER, "SetProficiencyOverride"), +#endif DEFINE_UTLVECTOR( m_Relationship, FIELD_EMBEDDED), DEFINE_AUTO_ARRAY( m_iAmmo, FIELD_INTEGER ), DEFINE_AUTO_ARRAY( m_hMyWeapons, FIELD_EHANDLE ), DEFINE_FIELD( m_hActiveWeapon, FIELD_EHANDLE ), +#ifdef MAPBASE + DEFINE_INPUT( m_bForceServerRagdoll, FIELD_BOOLEAN, "SetForceServerRagdoll" ), +#else DEFINE_FIELD( m_bForceServerRagdoll, FIELD_BOOLEAN ), +#endif DEFINE_FIELD( m_bPreventWeaponPickup, FIELD_BOOLEAN ), +#ifndef MAPBASE // See CBaseEntity::InputKilledNPC() DEFINE_INPUTFUNC( FIELD_VOID, "KilledNPC", InputKilledNPC ), +#endif + +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetBloodColor", InputSetBloodColor ), + + DEFINE_INPUTFUNC( FIELD_STRING, "SetRelationship", InputSetRelationship ), + + DEFINE_INPUTFUNC( FIELD_VOID, "HolsterWeapon", InputHolsterWeapon ), + DEFINE_INPUTFUNC( FIELD_VOID, "HolsterAndDestroyWeapon", InputHolsterAndDestroyWeapon ), + DEFINE_INPUTFUNC( FIELD_STRING, "UnholsterWeapon", InputUnholsterWeapon ), + DEFINE_INPUTFUNC( FIELD_STRING, "SwitchToWeapon", InputSwitchToWeapon ), + + DEFINE_INPUTFUNC( FIELD_STRING, "GiveWeapon", InputGiveWeapon ), + DEFINE_INPUTFUNC( FIELD_STRING, "DropWeapon", InputDropWeapon ), + DEFINE_INPUTFUNC( FIELD_EHANDLE, "PickupWeaponInstant", InputPickupWeaponInstant ), + DEFINE_OUTPUT( m_OnWeaponEquip, "OnWeaponEquip" ), + DEFINE_OUTPUT( m_OnWeaponDrop, "OnWeaponDrop" ), + + DEFINE_OUTPUT( m_OnKilledEnemy, "OnKilledEnemy" ), + DEFINE_OUTPUT( m_OnKilledPlayer, "OnKilledPlayer" ), + DEFINE_OUTPUT( m_OnHealthChanged, "OnHealthChanged" ), +#endif END_DATADESC() @@ -1162,7 +1197,11 @@ bool CTraceFilterMelee::ShouldHitEntity( IHandleEntity *pHandleEntity, int conte if ( pBCC && pVictimBCC ) { // Can only damage other NPCs that we hate +#ifdef MAPBASE + if ( m_bDamageAnyNPC || pBCC->IRelationType( pEntity ) <= D_FR ) +#else if ( m_bDamageAnyNPC || pBCC->IRelationType( pEntity ) == D_HT ) +#endif { if ( info.GetDamage() ) { @@ -1593,7 +1632,23 @@ void CBaseCombatCharacter::Event_Killed( const CTakeDamageInfo &info ) CRagdollMagnet *pMagnet = CRagdollMagnet::FindBestMagnet( this ); if( pMagnet ) { +#ifdef MAPBASE + if (pMagnet->BoneTarget() && pMagnet->BoneTarget()[0] != '\0') + { + int iBone = -1; + forceVector += pMagnet->GetForceVector( this, &iBone ); + if (iBone != -1) + m_nForceBone = GetPhysicsBone(iBone); + } + else + { + forceVector += pMagnet->GetForceVector( this ); + } + + pMagnet->m_OnUsed.Set(forceVector, this, pMagnet); +#else forceVector += pMagnet->GetForceVector( this ); +#endif } CBaseCombatWeapon *pDroppedWeapon = m_hActiveWeapon.Get(); @@ -1646,7 +1701,11 @@ void CBaseCombatCharacter::Event_Killed( const CTakeDamageInfo &info ) } } #ifdef HL2_DLL +#ifdef MAPBASE + else if ( PlayerHasMegaPhysCannon() && GlobalEntity_GetCounter("super_phys_gun") != 1 ) +#else else if ( PlayerHasMegaPhysCannon() ) +#endif { if ( pDroppedWeapon ) { @@ -1906,7 +1965,11 @@ void CBaseCombatCharacter::Weapon_Drop( CBaseCombatWeapon *pWeapon, const Vector return; // If I'm an NPC, fill the weapon with ammo before I drop it. +#ifdef MAPBASE + if ( GetFlags() & FL_NPC && !pWeapon->HasSpawnFlags(SF_WEAPON_PRESERVE_AMMO) ) +#else if ( GetFlags() & FL_NPC ) +#endif { if ( pWeapon->UsesClipsForAmmo1() ) { @@ -2042,6 +2105,10 @@ void CBaseCombatCharacter::Weapon_Drop( CBaseCombatWeapon *pWeapon, const Vector pWeapon->Drop( vecThrow ); Weapon_Detach( pWeapon ); +#ifdef MAPBASE + m_OnWeaponDrop.FireOutput(pWeapon, this); +#endif + if ( HasSpawnFlags( SF_NPC_NO_WEAPON_DROP ) ) { // Don't drop weapons when the super physgun is happening. @@ -2064,6 +2131,227 @@ void CBaseCombatCharacter::SetLightingOriginRelative( CBaseEntity *pLightingOrig } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Gives character new weapon and equips it +// Input : New weapon +//----------------------------------------------------------------------------- +void CBaseCombatCharacter::Weapon_Equip( CBaseCombatWeapon *pWeapon ) +{ + Weapon_HandleEquip(pWeapon); + + // Players don't automatically holster their current weapon + if ( IsPlayer() == false ) + { + if ( m_hActiveWeapon ) + { + m_hActiveWeapon->Holster(); + // FIXME: isn't this handeled by the weapon? + m_hActiveWeapon->AddEffects( EF_NODRAW ); + } + SetActiveWeapon( pWeapon ); + m_hActiveWeapon->RemoveEffects( EF_NODRAW ); + + } + + WeaponProficiency_t proficiency; + proficiency = CalcWeaponProficiency( pWeapon ); + + if( weapon_showproficiency.GetBool() != 0 ) + { + Msg("%s equipped with %s, proficiency is %s\n", GetClassname(), pWeapon->GetClassname(), GetWeaponProficiencyName( proficiency ) ); + } + + SetCurrentWeaponProficiency( proficiency ); +} + +//----------------------------------------------------------------------------- +// Purpose: Puts a new weapon in the inventory +// Input : New weapon +//----------------------------------------------------------------------------- +void CBaseCombatCharacter::Weapon_EquipHolstered( CBaseCombatWeapon *pWeapon ) +{ + Weapon_HandleEquip(pWeapon); + pWeapon->AddEffects( EF_NODRAW ); +} + +//----------------------------------------------------------------------------- +// Purpose: Adds new weapon to the character +// Input : New weapon +//----------------------------------------------------------------------------- +void CBaseCombatCharacter::Weapon_HandleEquip( CBaseCombatWeapon *pWeapon ) +{ + // Add the weapon to my weapon inventory + if (IsPlayer()) + { + // This code drops existing weapons that are in the same bucket and bucket position. + // This doesn't really harm anything since that situation would've broken the HUD anyway. + // + // It goes through every single index in case there's a NULL pointer in between weapons. + int iFirstNullIndex = -1; + for (int i=0;iGetSlot() == m_hMyWeapons[i]->GetSlot() && + pWeapon->GetPosition() == m_hMyWeapons[i]->GetPosition()) + { + // Replace our existing weapon in this slot + Weapon_Drop(m_hMyWeapons[i]); + { + // We found a slot, we don't care about the first null index anymore + iFirstNullIndex = -1; + + m_hMyWeapons.Set( i, pWeapon ); + break; + } + } + } + } + + if (iFirstNullIndex != -1) + m_hMyWeapons.Set( iFirstNullIndex, pWeapon ); + } + else + { + for (int i=0;iChangeTeam( GetTeamNumber() ); + + bool bPreserveAmmo = pWeapon->HasSpawnFlags(SF_WEAPON_PRESERVE_AMMO); + if (!bPreserveAmmo) + { + // ---------------------- + // Give Primary Ammo + // ---------------------- + // If gun doesn't use clips, just give ammo + if (pWeapon->GetMaxClip1() == -1) + { +#ifdef HL2_DLL + if( FStrEq(STRING(gpGlobals->mapname), "d3_c17_09") && FClassnameIs(pWeapon, "weapon_rpg") && pWeapon->NameMatches("player_spawn_items") ) + { + // !!!HACK - Don't give any ammo with the spawn equipment RPG in d3_c17_09. This is a chapter + // start and the map is way to easy if you start with 3 RPG rounds. It's fine if a player conserves + // them and uses them here, but it's not OK to start with enough ammo to bypass the snipers completely. + GiveAmmo( 0, pWeapon->m_iPrimaryAmmoType); + } + else +#endif // HL2_DLL + GiveAmmo(pWeapon->GetDefaultClip1(), pWeapon->m_iPrimaryAmmoType); + } + // If default ammo given is greater than clip + // size, fill clips and give extra ammo + else if ( pWeapon->GetDefaultClip1() > pWeapon->GetMaxClip1() ) + { + pWeapon->m_iClip1 = pWeapon->GetMaxClip1(); + GiveAmmo( (pWeapon->GetDefaultClip1() - pWeapon->GetMaxClip1()), pWeapon->m_iPrimaryAmmoType); + } + + // ---------------------- + // Give Secondary Ammo + // ---------------------- + // If gun doesn't use clips, just give ammo + if (pWeapon->GetMaxClip2() == -1) + { + GiveAmmo(pWeapon->GetDefaultClip2(), pWeapon->m_iSecondaryAmmoType); + } + // If default ammo given is greater than clip + // size, fill clips and give extra ammo + else if ( pWeapon->GetDefaultClip2() > pWeapon->GetMaxClip2() ) + { + pWeapon->m_iClip2 = pWeapon->GetMaxClip2(); + GiveAmmo( (pWeapon->GetDefaultClip2() - pWeapon->GetMaxClip2()), pWeapon->m_iSecondaryAmmoType); + } + } + else //if (IsPlayer()) + { + if (pWeapon->UsesClipsForAmmo1()) + { + if (pWeapon->m_iClip1 > pWeapon->GetMaxClip1()) + { + // Handle excess ammo + GiveAmmo( pWeapon->m_iClip1 - pWeapon->GetMaxClip1(), pWeapon->m_iPrimaryAmmoType ); + pWeapon->m_iClip1 = pWeapon->GetMaxClip1(); + } + } + else if (pWeapon->m_iClip1 > 0) + { + // Just because the weapon can't use clips doesn't mean + // the mapper can't override their clip value for ammo. + GiveAmmo(pWeapon->m_iClip1, pWeapon->m_iPrimaryAmmoType); + pWeapon->m_iClip1 = WEAPON_NOCLIP; + } + + if (pWeapon->UsesClipsForAmmo2()) + { + if (pWeapon->m_iClip2 > pWeapon->GetMaxClip2()) + { + // Handle excess ammo + GiveAmmo(pWeapon->m_iClip2 - pWeapon->GetMaxClip2(), pWeapon->m_iSecondaryAmmoType); + pWeapon->m_iClip2 = pWeapon->GetMaxClip2(); + } + } + else if (pWeapon->m_iClip2 > 0) + { + // Just because the weapon can't use clips doesn't mean + // the mapper can't override their clip value for ammo. + GiveAmmo(pWeapon->m_iClip2, pWeapon->m_iSecondaryAmmoType); + pWeapon->m_iClip2 = WEAPON_NOCLIP; + } + } + + pWeapon->Equip( this ); + + // Gotta do this *after* Equip because it may whack maxRange + if ( IsPlayer() == false ) + { + // If SF_NPC_LONG_RANGE spawn flags is set let weapon work from any distance + if ( HasSpawnFlags(SF_NPC_LONG_RANGE) ) + { + pWeapon->m_fMaxRange1 = 999999999; + pWeapon->m_fMaxRange2 = 999999999; + } + } + else if (bPreserveAmmo) + { + // The clip doesn't update on the client unless we do this. + // This is the only way I've figured out how to update without doing something worse. + // TODO: Remove this hack, we've finally fixed it + /* + variant_t clip1; + clip1.SetInt(pWeapon->m_iClip1); + variant_t clip2; + clip2.SetInt(pWeapon->m_iClip2); + + pWeapon->m_iClip1 = pWeapon->m_iClip1 - 1; + pWeapon->m_iClip2 = pWeapon->m_iClip2 - 1; + + g_EventQueue.AddEvent(pWeapon, "SetAmmo1", clip1, 0.0001f, this, this, 0); + g_EventQueue.AddEvent(pWeapon, "SetAmmo2", clip2, 0.0001f, this, this, 0); + */ + } + + // Pass the lighting origin over to the weapon if we have one + pWeapon->SetLightingOriginRelative( GetLightingOriginRelative() ); + + //if (m_aliveTimer.IsLessThen(0.01f)) + m_OnWeaponEquip.FireOutput(pWeapon, this); +} +#else //----------------------------------------------------------------------------- // Purpose: Add new weapon to the character // Input : New weapon @@ -2165,6 +2453,7 @@ void CBaseCombatCharacter::Weapon_Equip( CBaseCombatWeapon *pWeapon ) // Pass the lighting origin over to the weapon if we have one pWeapon->SetLightingOriginRelative( GetLightingOriginRelative() ); } +#endif //----------------------------------------------------------------------------- // Purpose: Leaves weapon, giving only ammo to the character @@ -2298,6 +2587,12 @@ bool CBaseCombatCharacter::Weapon_CanUse( CBaseCombatWeapon *pWeapon ) if ( SelectWeightedSequence(translatedActivity) == ACTIVITY_NOT_AVAILABLE ) { +#ifdef MAPBASE + // Do we have a backup? + translatedActivity = Weapon_BackupActivity((Activity)(pTable->baseAct), true, pWeapon); + if (SelectWeightedSequence(translatedActivity) != ACTIVITY_NOT_AVAILABLE) + return true; +#endif return false; } } @@ -2306,6 +2601,48 @@ bool CBaseCombatCharacter::Weapon_CanUse( CBaseCombatWeapon *pWeapon ) return true; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Uses an activity from a different weapon when the activity we were originally looking for does not exist on this character. +// Created to give NPCs the ability to use weapons they are not otherwise allowed to use. +// Right now, everyone falls back to the SMG act table. +//----------------------------------------------------------------------------- +Activity CBaseCombatCharacter::Weapon_BackupActivity( Activity activity, bool weaponTranslationWasRequired, CBaseCombatWeapon *pSpecificWeapon ) +{ + CBaseCombatWeapon *pWeapon = pSpecificWeapon ? pSpecificWeapon : GetActiveWeapon(); + if (!pWeapon) + return activity; + + // Make sure the weapon allows this activity to have a backup. + if (!pWeapon->SupportsBackupActivity(activity)) + return activity; + + // Sometimes, the NPC is supposed to use the default activity. Return that if the weapon translation was "not required" and we have an original activity. + if (!weaponTranslationWasRequired && GetModelPtr()->HaveSequenceForActivity(activity)) + { + return activity; + } + + acttable_t *pTable = GetSMG1Acttable(); + int actCount = GetSMG1ActtableCount(); + for ( int i = 0; i < actCount; i++, pTable++ ) + { + if ( activity == pTable->baseAct ) + { + // Don't pick SMG animations we don't actually have an animation for. + if (GetModelPtr() ? !GetModelPtr()->HaveSequenceForActivity(pTable->weaponAct) : false) + { + return activity; + } + + return (Activity)pTable->weaponAct; + } + } + + return activity; +} +#endif + //----------------------------------------------------------------------------- // Purpose: // Input : @@ -2352,6 +2689,11 @@ int CBaseCombatCharacter::TakeHealth (float flHealth, int bitsDamageType) { if (!m_takedamage) return 0; + +#ifdef MAPBASE + float flRatio = clamp( (float)m_iHealth / (float)m_iMaxHealth, 0.f, 1.f ); + m_OnHealthChanged.Set(flRatio, NULL, this); +#endif return BaseClass::TakeHealth(flHealth, bitsDamageType); } @@ -2418,6 +2760,13 @@ int CBaseCombatCharacter::OnTakeDamage( const CTakeDamageInfo &info ) { case LIFE_ALIVE: retVal = OnTakeDamage_Alive( info ); +#ifdef MAPBASE + if (retVal) + { + float flRatio = clamp( (float)m_iHealth / (float)m_iMaxHealth, 0.f, 1.f ); + m_OnHealthChanged.Set(flRatio, NULL, this); + } +#endif if ( m_iHealth <= 0 ) { IPhysicsObject *pPhysics = VPhysicsGetObject(); @@ -2445,11 +2794,28 @@ int CBaseCombatCharacter::OnTakeDamage( const CTakeDamageInfo &info ) break; case LIFE_DYING: +#ifdef MAPBASE + retVal = OnTakeDamage_Dying( info ); + if (retVal) + { + float flRatio = clamp( (float)m_iHealth / (float)m_iMaxHealth, 0.f, 1.f ); + m_OnHealthChanged.Set(flRatio, NULL, this); + } + return retVal; +#else return OnTakeDamage_Dying( info ); +#endif default: case LIFE_DEAD: retVal = OnTakeDamage_Dead( info ); +#ifdef MAPBASE + if (retVal) + { + float flRatio = clamp( (float)m_iHealth / (float)m_iMaxHealth, 0.f, 1.f ); + m_OnHealthChanged.Set(flRatio, NULL, this); + } +#endif if ( m_iHealth <= 0 && g_pGameRules->Damage_ShouldGibCorpse( info.GetDamageType() ) && ShouldGib( info ) ) { Event_Gibbed( info ); @@ -2609,6 +2975,29 @@ void CBaseCombatCharacter::AddClassRelationship ( Class_T class_type, Dispositio m_Relationship[index].priority = ( priority != DEF_RELATIONSHIP_PRIORITY ) ? priority : 0; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Removes a class relationship from our list +// Input : *class_type - Class with whom the relationship should be ended +// Output : True is relation was removed, false if it was not found +//----------------------------------------------------------------------------- +bool CBaseCombatCharacter::RemoveClassRelationship( Class_T class_type ) +{ + // Find the relationship in our list, if it exists + for ( int i = m_Relationship.Count()-1; i >= 0; i-- ) + { + if ( m_Relationship[i].classType == class_type ) + { + // Done, remove it + m_Relationship.Remove( i ); + return true; + } + } + + return false; +} +#endif + //----------------------------------------------------------------------------- // Purpose: Add or Change a entity relationship for this entity // Input : @@ -2690,6 +3079,44 @@ void CBaseCombatCharacter::SetDefaultRelationship(Class_T nClass, Class_T nClass } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Fetch the default (ignore ai_relationship changes) relationship +// Input : +// Output : +//----------------------------------------------------------------------------- +Disposition_t CBaseCombatCharacter::GetDefaultRelationshipDisposition( Class_T nClassSource, Class_T nClassTarget ) +{ + Assert( m_DefaultRelationship != NULL ); + + return m_DefaultRelationship[nClassSource][nClassTarget].disposition; +} + +//----------------------------------------------------------------------------- +// Purpose: Fetch the default (ignore ai_relationship changes) priority +// Input : +// Output : +//----------------------------------------------------------------------------- +int CBaseCombatCharacter::GetDefaultRelationshipPriority( Class_T nClassSource, Class_T nClassTarget ) +{ + Assert( m_DefaultRelationship != NULL ); + + return m_DefaultRelationship[nClassSource][nClassTarget].priority; +} + +//----------------------------------------------------------------------------- +// Purpose: Fetch the default (ignore ai_relationship changes) priority +// Input : +// Output : +//----------------------------------------------------------------------------- +int CBaseCombatCharacter::GetDefaultRelationshipPriority( Class_T nClassTarget ) +{ + Assert( m_DefaultRelationship != NULL ); + + return m_DefaultRelationship[Classify()][nClassTarget].priority; +} +#endif + //----------------------------------------------------------------------------- // Purpose: Fetch the default (ignore ai_relationship changes) relationship // Input : @@ -2761,6 +3188,131 @@ int CBaseCombatCharacter::IRelationPriority( CBaseEntity *pTarget ) return 0; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Ported from CAI_BaseNPC so players can use it +//----------------------------------------------------------------------------- +void CBaseCombatCharacter::AddRelationship( const char *pszRelationship, CBaseEntity *pActivator ) +{ + // Parse the keyvalue data + char parseString[1000]; + Q_strncpy(parseString, pszRelationship, sizeof(parseString)); + + // Look for an entity string + char *entityString = strtok(parseString," "); + while (entityString) + { + // Get the disposition + char *dispositionString = strtok(NULL," "); + Disposition_t disposition = D_NU; + if ( dispositionString ) + { + if (!stricmp(dispositionString,"D_HT")) + { + disposition = D_HT; + } + else if (!stricmp(dispositionString,"D_FR")) + { + disposition = D_FR; + } + else if (!stricmp(dispositionString,"D_LI")) + { + disposition = D_LI; + } + else if (!stricmp(dispositionString,"D_NU")) + { + disposition = D_NU; + } + else + { + disposition = D_NU; + Warning( "***ERROR***\nBad relationship type (%s) to unknown entity (%s)!\n", dispositionString,entityString ); + Assert( 0 ); + return; + } + } + else + { + Warning("Can't parse relationship info (%s) - Expecting 'name [D_HT, D_FR, D_LI, D_NU] [1-99]'\n", pszRelationship ); + Assert(0); + return; + } + + // Get the priority + char *priorityString = strtok(NULL," "); + int priority = ( priorityString ) ? atoi(priorityString) : DEF_RELATIONSHIP_PRIORITY; + + bool bFoundEntity = false; + + // Try to get pointer to an entity of this name + CBaseEntity *entity = gEntList.FindEntityByName( NULL, entityString ); + while( entity ) + { + // make sure you catch all entities of this name. + bFoundEntity = true; + AddEntityRelationship(entity, disposition, priority ); + entity = gEntList.FindEntityByName( entity, entityString ); + } + + if( !bFoundEntity ) + { + // Need special condition for player as we can only have one + if (!stricmp("player", entityString) || !stricmp("!player", entityString)) + { + AddClassRelationship( CLASS_PLAYER, disposition, priority ); + } + // Otherwise try to create one too see if a valid classname and get class type + else + { + // HACKHACK: + CBaseEntity *pEntity = CanCreateEntityClass( entityString ) ? CreateEntityByName( entityString ) : NULL; + if (pEntity) + { + AddClassRelationship( pEntity->Classify(), disposition, priority ); + UTIL_RemoveImmediate(pEntity); + } + else + { +#ifdef MAPBASE // I know the extra #ifdef is pointless, but it's there so you know this is new + if (!Q_strnicmp(entityString, "CLASS_", 5)) + { + // Go through all of the classes and find which one this is + Class_T resultClass = CLASS_NONE; + for (int i = 0; i < NUM_AI_CLASSES; i++) + { + if (FStrEq(g_pGameRules->AIClassText(i), entityString)) + { + resultClass = (Class_T)i; + } + } + + if (resultClass != CLASS_NONE) + { + AddClassRelationship( resultClass, disposition, priority ); + bFoundEntity = true; + } + } + + if (!bFoundEntity) +#endif + DevWarning( "Couldn't set relationship to unknown entity or class (%s)!\n", entityString ); + } + } + } + // Check for another entity in the list + entityString = strtok(NULL," "); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBaseCombatCharacter::InputSetRelationship( inputdata_t &inputdata ) +{ + AddRelationship( inputdata.value.String(), inputdata.pActivator ); +} +#endif + //----------------------------------------------------------------------------- // Purpose: Get shoot position of BCC at current position/orientation // Input : @@ -2793,6 +3345,11 @@ CBaseEntity *CBaseCombatCharacter::FindHealthItem( const Vector &vecPosition, co if( pItem ) { +#ifdef MAPBASE + if (pItem->HasSpawnFlags(SF_ITEM_NO_NPC_PICKUP)) + continue; +#endif + // Healthkits and healthvials if( pItem->ClassMatches( "item_health*" ) && FVisible( pItem ) ) { @@ -2837,6 +3394,18 @@ CBaseEntity *CBaseCombatCharacter::Weapon_FindUsable( const Vector &range ) { bool bConservative = false; +#ifdef MAPBASE + if (HasContext("weapon_conservative:1")) + bConservative = true; +#ifdef HL2_DLL + else if (hl2_episodic.GetBool() && !GetActiveWeapon()) + { + // Unarmed citizens are conservative in their weapon finding...in Episode One + if (Classify() != CLASS_PLAYER_ALLY_VITAL && Q_strncmp(STRING(gpGlobals->mapname), "ep1_", 4)) + bConservative = true; + } +#endif +#else #ifdef HL2_DLL if( hl2_episodic.GetBool() && !GetActiveWeapon() ) { @@ -2846,6 +3415,7 @@ CBaseEntity *CBaseCombatCharacter::Weapon_FindUsable( const Vector &range ) bConservative = true; } } +#endif #endif CBaseCombatWeapon *weaponList[64]; @@ -2869,26 +3439,56 @@ CBaseEntity *CBaseCombatCharacter::Weapon_FindUsable( const Vector &range ) if ( pWeapon->CanBePickedUpByNPCs() == false ) continue; +#ifdef MAPBASE + if ( pWeapon->HasSpawnFlags(SF_WEAPON_NO_NPC_PICKUP) ) + continue; +#endif + if ( velocity.LengthSqr() > 1 || !Weapon_CanUse(pWeapon) ) continue; if ( pWeapon->IsLocked(this) ) continue; +#ifdef MAPBASE + // Skip weapons we already own + if ( Weapon_OwnsThisType(pWeapon->GetClassname()) ) + continue; +#endif + if ( GetActiveWeapon() ) { // Already armed. Would picking up this weapon improve my situation? +#ifndef MAPBASE if( GetActiveWeapon()->m_iClassname == pWeapon->m_iClassname ) { // No, I'm already using this type of weapon. continue; } +#endif +#ifdef MAPBASE + if ( pWeapon->IsMeleeWeapon() && !GetActiveWeapon()->IsMeleeWeapon() ) + { + // This weapon is a melee weapon and the weapon I have now is not. + // Picking up this weapon might not improve my situation. + continue; + } + + if ( pWeapon->GetWeight() != 0 && GetActiveWeapon()->GetWeight() > pWeapon->GetWeight() ) + { + // Discard if our target weapon supports weight but our current weapon has more of it. + // + // (RIP going from AR2 to shotgun) + continue; + } +#else if( FClassnameIs( pWeapon, "weapon_pistol" ) ) { // No, it's a pistol. continue; } +#endif } float fCurDist = (pWeapon->GetLocalOrigin() - GetLocalOrigin()).Length(); @@ -2901,6 +3501,23 @@ CBaseEntity *CBaseCombatCharacter::Weapon_FindUsable( const Vector &range ) if ( pBestWeapon ) { +#ifdef MAPBASE + // NPCs now use weight to determine which weapon is best. + // All HL2 weapons are weighted and are usually good enough. + // + // This probably won't cause problems... + if (pWeapon->GetWeight() > 1) + { +#if 0 + float flRatio = MIN( (2.5f / (pWeapon->GetWeight() - (GetActiveWeapon() ? GetActiveWeapon()->GetWeight() : 0))), 1.0 ); + if (flRatio < 0) + flRatio *= -1; flRatio += 1.0f; + fCurDist *= flRatio; +#else + fCurDist *= MIN( (2.5f / pWeapon->GetWeight()), 1.0 ); +#endif + } +#else // UNDONE: Better heuristic needed here // Need to pick by power of weapons // Don't want to pick a weapon right next to a NPC! @@ -2910,6 +3527,7 @@ CBaseEntity *CBaseCombatCharacter::Weapon_FindUsable( const Vector &range ) { fCurDist *= 0.5; } +#endif // choose the last range attack weapon you find or the first available other weapon if ( ! (pWeapon->CapabilitiesGet() & bits_CAP_RANGE_ATTACK_GROUP) ) @@ -3257,6 +3875,16 @@ bool CBaseCombatCharacter::IsGlowEffectActive( void ) } #endif // GLOWS_ENABLE +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Mapbase adds proficiency override +//----------------------------------------------------------------------------- +inline WeaponProficiency_t CBaseCombatCharacter::GetCurrentWeaponProficiency() +{ + return (m_ProficiencyOverride > WEAPON_PROFICIENCY_INVALID) ? m_ProficiencyOverride : m_CurrentWeaponProficiency; +} +#endif + //----------------------------------------------------------------------------- // Assume everyone is average with every weapon. Override this to make exceptions. //----------------------------------------------------------------------------- @@ -3324,6 +3952,301 @@ void CBaseCombatCharacter::InputKilledNPC( inputdata_t &inputdata ) OnKilledNPC( inputdata.pActivator ? inputdata.pActivator->MyCombatCharacterPointer() : NULL ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Handle enemy kills. This actually measures players too. +//----------------------------------------------------------------------------- +void CBaseCombatCharacter::OnKilledNPC( CBaseCombatCharacter *pKilled ) +{ + // I know this can sometimes pass as NULL, but that can work here...right? + m_OnKilledEnemy.Set(pKilled, pKilled, this); + + // Fire an additional output if this was the player + if (pKilled && pKilled->IsPlayer()) + m_OnKilledPlayer.Set(pKilled, pKilled, this); +} + +//------------------------------------------------------------------------------ +// Purpose: Give the NPC in question the weapon specified +//------------------------------------------------------------------------------ +void CBaseCombatCharacter::InputGiveWeapon( inputdata_t &inputdata ) +{ + // Give the NPC the specified weapon + string_t iszWeaponName = inputdata.value.StringID(); + if ( iszWeaponName != NULL_STRING ) + { + if (IsNPC()) + { + if( Classify() == CLASS_PLAYER_ALLY_VITAL ) + { + MyNPCPointer()->m_iszPendingWeapon = iszWeaponName; + } + else + { + MyNPCPointer()->GiveWeapon( iszWeaponName ); + } + } + else + { + CBaseCombatWeapon *pWeapon = Weapon_Create(STRING(iszWeaponName)); + if (pWeapon) + { + Weapon_Equip(pWeapon); + } + else + { + Warning( "Couldn't create weapon %s to give %s.\n", STRING(iszWeaponName), GetDebugName() ); + return; + } + } + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CBaseCombatCharacter::InputDropWeapon( inputdata_t &inputdata ) +{ + CBaseCombatWeapon *pWeapon = FStrEq(inputdata.value.String(), "") ? GetActiveWeapon() : Weapon_OwnsThisType(inputdata.value.String()); + if (pWeapon) + { + Weapon_Drop(pWeapon); + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CBaseCombatCharacter::InputPickupWeaponInstant( inputdata_t &inputdata ) +{ + if (inputdata.value.Entity() && inputdata.value.Entity()->IsBaseCombatWeapon()) + { + CBaseCombatWeapon *pWeapon = inputdata.value.Entity()->MyCombatWeaponPointer(); + + if (CBaseCombatWeapon *pExistingWeapon = Weapon_OwnsThisType(pWeapon->GetClassname())) + { + // Drop our existing weapon then! + Weapon_Drop(pExistingWeapon); + } + + if (IsNPC()) + { + Weapon_Equip(pWeapon); + MyNPCPointer()->OnGivenWeapon(pWeapon); + } + else + { + Weapon_Equip(pWeapon); + } + } + else + { + Warning("%s received PickupWeaponInstant with invalid entity %s\n", inputdata.value.Entity() ? "null" : inputdata.value.Entity()->GetDebugName()); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBaseCombatCharacter::InputHolsterWeapon( inputdata_t &inputdata ) +{ + CBaseCombatWeapon *pWeapon = GetActiveWeapon(); + if (pWeapon) + { + pWeapon->Holster(); + //SetActiveWeapon( NULL ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBaseCombatCharacter::InputHolsterAndDestroyWeapon( inputdata_t &inputdata ) +{ + CBaseCombatWeapon *pWeapon = GetActiveWeapon(); + if (pWeapon) + { + pWeapon->Holster(); + SetActiveWeapon( NULL ); + + if (pWeapon->GetActivity() == ACT_VM_HOLSTER) + { + // Remove when holster is finished + pWeapon->ThinkSet( &CBaseEntity::SUB_Remove, gpGlobals->curtime + pWeapon->GetViewModelSequenceDuration() ); + } + else + { + // Remove now + UTIL_Remove( pWeapon ); + } + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBaseCombatCharacter::InputUnholsterWeapon( inputdata_t &inputdata ) +{ + // NPCs can handle strings, but players fall back to SwitchToWeapon + if (inputdata.value.StringID() != NULL_STRING) + InputSwitchToWeapon( inputdata ); + + CBaseCombatWeapon *pWeapon = GetActiveWeapon(); + if (pWeapon && pWeapon->IsEffectActive(EF_NODRAW)) + { + pWeapon->Deploy(); + } +} + +//------------------------------------------------------------------------------ +// Purpose: Makes the NPC instantly switch to the specified weapon, creates it if it doesn't exist +//------------------------------------------------------------------------------ +void CBaseCombatCharacter::InputSwitchToWeapon( inputdata_t &inputdata ) +{ + for (int i = 0; im_iClassname == inputdata.value.StringID()) + { + Weapon_Switch( m_hMyWeapons[i] ); + return; + } + } + + // We must not have it + if (IsNPC()) + MyNPCPointer()->GiveWeapon( inputdata.value.StringID(), false ); + else + { + CBaseCombatWeapon *pWeapon = Weapon_Create( inputdata.value.String() ); + if (pWeapon) + { + Weapon_Equip( pWeapon ); + } + else + { + Warning( "Couldn't create weapon %s to give %s.\n", inputdata.value.String(), GetDebugName() ); + } + } +} + +#define FINDNAMEDENTITY_MAX_ENTITIES 32 +//----------------------------------------------------------------------------- +// Purpose: FindNamedEntity has been moved from CAI_BaseNPC to CBaseCombatCharacter so players can use it. +// Coincidentally, everything that it did on NPCs could be done on BaseCombatCharacters with no consequences. +// Input : +// Output : +//----------------------------------------------------------------------------- +CBaseEntity *CBaseCombatCharacter::FindNamedEntity( const char *szName, IEntityFindFilter *pFilter ) +{ + const char *name = szName; + if (name[0] == '!') + name++; + + if ( !stricmp( name, "player" )) + { + return AI_GetSinglePlayer(); + } + else if ( !stricmp( name, "enemy" ) ) + { + return GetEnemy(); + } + else if ( !stricmp( name, "self" ) || !stricmp( name, "target1" ) ) + { + return this; + } + else if ( !stricmp( name, "nearestfriend" ) || !strnicmp( name, "friend", 6 ) ) + { + // Just look for the nearest friendly NPC within 500 units + // (most of this was stolen from CAI_PlayerAlly::FindSpeechTarget()) + const Vector & vAbsOrigin = GetAbsOrigin(); + float closestDistSq = Square(500.0); + CBaseEntity * pNearest = NULL; + float distSq; + int i; + for ( i = 0; i < g_AI_Manager.NumAIs(); i++ ) + { + CAI_BaseNPC *pNPC = (g_AI_Manager.AccessAIs())[i]; + + if ( pNPC == this ) + continue; + + distSq = ( vAbsOrigin - pNPC->GetAbsOrigin() ).LengthSqr(); + + if ( distSq > closestDistSq ) + continue; + + if ( IRelationType( pNPC ) == D_LI ) + { + closestDistSq = distSq; + pNearest = pNPC; + } + } + + if (stricmp(name, "friend_npc") != 0) + { + // Okay, find the nearest friendly client. + for ( i = 1; i <= gpGlobals->maxClients; i++ ) + { + CBaseEntity *pPlayer = UTIL_PlayerByIndex( i ); + if ( pPlayer ) + { + // Don't get players with notarget + if (pPlayer->GetFlags() & FL_NOTARGET) + continue; + + distSq = ( vAbsOrigin - pPlayer->GetAbsOrigin() ).LengthSqr(); + + if ( distSq > closestDistSq ) + continue; + + if ( IRelationType( pPlayer ) == D_LI ) + { + closestDistSq = distSq; + pNearest = pPlayer; + } + } + } + } + + return pNearest; + } + else if (!stricmp( name, "weapon" )) + { + return GetActiveWeapon(); + } + + // FindEntityProcedural can go through this now, so running this code would likely cause an infinite loop or something. + // As a result, FindEntityProcedural identifies itself with this weird new entity filter. + // Hey, if you've got a better idea, go ahead. + else if (!pFilter || !dynamic_cast(pFilter)) + { + // search for up to 32 entities with the same name and choose one randomly + CBaseEntity *entityList[ FINDNAMEDENTITY_MAX_ENTITIES ]; + CBaseEntity *entity; + int iCount; + + entity = NULL; + for( iCount = 0; iCount < FINDNAMEDENTITY_MAX_ENTITIES; iCount++ ) + { + entity = gEntList.FindEntityByName( entity, szName, this, NULL, NULL, pFilter ); + if ( !entity ) + { + break; + } + entityList[ iCount ] = entity; + } + + if ( iCount > 0 ) + { + int index = RandomInt( 0, iCount - 1 ); + entity = entityList[ index ]; + return entity; + } + } + + return NULL; +} +#endif + //----------------------------------------------------------------------------- // Purpose: Overload our muzzle flash and send it to any actively held weapon //----------------------------------------------------------------------------- diff --git a/sp/src/game/server/basecombatcharacter.h b/sp/src/game/server/basecombatcharacter.h index 3e92332b..31ba9998 100644 --- a/sp/src/game/server/basecombatcharacter.h +++ b/sp/src/game/server/basecombatcharacter.h @@ -225,7 +225,14 @@ public: virtual void Weapon_HandleAnimEvent( animevent_t *pEvent ); CBaseCombatWeapon* Weapon_OwnsThisType( const char *pszWeapon, int iSubType = 0 ) const; // True if already owns a weapon of this class virtual bool Weapon_CanUse( CBaseCombatWeapon *pWeapon ); // True is allowed to use this class of weapon +#ifdef MAPBASE + virtual Activity Weapon_BackupActivity( Activity activity, bool weaponTranslationWasRequired = false, CBaseCombatWeapon *pSpecificWeapon = NULL ); virtual void Weapon_Equip( CBaseCombatWeapon *pWeapon ); // Adds weapon to player + virtual void Weapon_EquipHolstered( CBaseCombatWeapon *pWeapon ); // Pretty much only useful for NPCs + virtual void Weapon_HandleEquip( CBaseCombatWeapon *pWeapon ); +#else + virtual void Weapon_Equip( CBaseCombatWeapon *pWeapon ); // Adds weapon to player +#endif virtual bool Weapon_EquipAmmoOnly( CBaseCombatWeapon *pWeapon ); // Adds weapon ammo to player, leaves weapon bool Weapon_Detach( CBaseCombatWeapon *pWeapon ); // Clear any pointers to the weapon. virtual void Weapon_Drop( CBaseCombatWeapon *pWeapon, const Vector *pvecTarget = NULL, const Vector *pVelocity = NULL ); @@ -288,7 +295,29 @@ public: // Killed a character void InputKilledNPC( inputdata_t &inputdata ); +#ifdef MAPBASE + + void InputGiveWeapon( inputdata_t &inputdata ); + void InputDropWeapon( inputdata_t &inputdata ); + void InputPickupWeaponInstant( inputdata_t &inputdata ); + COutputEvent m_OnWeaponEquip; + COutputEvent m_OnWeaponDrop; + + virtual void InputHolsterWeapon( inputdata_t &inputdata ); + virtual void InputHolsterAndDestroyWeapon( inputdata_t &inputdata ); + virtual void InputUnholsterWeapon( inputdata_t &inputdata ); + void InputSwitchToWeapon( inputdata_t &inputdata ); + + COutputEHANDLE m_OnKilledEnemy; + COutputEHANDLE m_OnKilledPlayer; + virtual void OnKilledNPC( CBaseCombatCharacter *pKilled ); + + virtual CBaseEntity *FindNamedEntity( const char *pszName, IEntityFindFilter *pFilter = NULL ); + + COutputFloat m_OnHealthChanged; +#else virtual void OnKilledNPC( CBaseCombatCharacter *pKilled ) {}; +#endif // Exactly one of these happens immediately after killed (gibbed may happen later when the corpse gibs) // Character gibbed or faded out (violence controls) (only fired once) @@ -327,6 +356,11 @@ public: virtual Disposition_t IRelationType( CBaseEntity *pTarget ); virtual int IRelationPriority( CBaseEntity *pTarget ); +#ifdef MAPBASE + void AddRelationship( const char *pszRelationship, CBaseEntity *pActivator ); + void InputSetRelationship( inputdata_t &inputdata ); +#endif + virtual void SetLightingOriginRelative( CBaseEntity *pLightingOrigin ); protected: @@ -342,6 +376,9 @@ public: // Blood color (see BLOOD_COLOR_* macros in baseentity.h) void SetBloodColor( int nBloodColor ); +#ifdef MAPBASE + void InputSetBloodColor( inputdata_t &inputdata ); +#endif // Weapons.. CBaseCombatWeapon* GetActiveWeapon() const; @@ -349,7 +386,11 @@ public: CBaseCombatWeapon* GetWeapon( int i ) const; bool RemoveWeapon( CBaseCombatWeapon *pWeapon ); virtual void RemoveAllWeapons(); +#ifdef MAPBASE + WeaponProficiency_t GetCurrentWeaponProficiency(); +#else WeaponProficiency_t GetCurrentWeaponProficiency() { return m_CurrentWeaponProficiency; } +#endif void SetCurrentWeaponProficiency( WeaponProficiency_t iProficiency ) { m_CurrentWeaponProficiency = iProficiency; } virtual WeaponProficiency_t CalcWeaponProficiency( CBaseCombatWeapon *pWeapon ); virtual Vector GetAttackSpread( CBaseCombatWeapon *pWeapon, CBaseEntity *pTarget = NULL ); @@ -362,10 +403,18 @@ public: // Relationships static void AllocateDefaultRelationships( ); static void SetDefaultRelationship( Class_T nClass, Class_T nClassTarget, Disposition_t nDisposition, int nPriority ); +#ifdef MAPBASE + static Disposition_t GetDefaultRelationshipDisposition( Class_T nClassSource, Class_T nClassTarget ); + static int GetDefaultRelationshipPriority( Class_T nClassSource, Class_T nClassTarget ); + int GetDefaultRelationshipPriority( Class_T nClassTarget ); +#endif Disposition_t GetDefaultRelationshipDisposition( Class_T nClassTarget ); virtual void AddEntityRelationship( CBaseEntity *pEntity, Disposition_t nDisposition, int nPriority ); virtual bool RemoveEntityRelationship( CBaseEntity *pEntity ); virtual void AddClassRelationship( Class_T nClass, Disposition_t nDisposition, int nPriority ); +#ifdef MAPBASE + virtual bool RemoveClassRelationship( Class_T nClass ); +#endif virtual void ChangeTeam( int iTeamNum ); @@ -450,7 +499,9 @@ public: public: // returns the last body region that took damage int LastHitGroup() const { return m_LastHitGroup; } +#ifndef MAPBASE // For filter_damage_transfer protected: +#endif void SetLastHitGroup( int nHitGroup ) { m_LastHitGroup = nHitGroup; } public: @@ -503,6 +554,11 @@ private: // cached off as the CurrentWeaponProficiency. WeaponProficiency_t m_CurrentWeaponProficiency; +#ifdef MAPBASE + // Weapon proficiency can be overridden with this. + WeaponProficiency_t m_ProficiencyOverride = WEAPON_PROFICIENCY_INVALID; +#endif + // --------------- // Relationships // --------------- diff --git a/sp/src/game/server/basecombatweapon.cpp b/sp/src/game/server/basecombatweapon.cpp index c05cb33d..1135aa82 100644 --- a/sp/src/game/server/basecombatweapon.cpp +++ b/sp/src/game/server/basecombatweapon.cpp @@ -342,7 +342,11 @@ bool CBaseCombatWeapon::WeaponLOSCondition( const Vector &ownerPos, const Vector if ( pBCC ) { +#ifdef MAPBASE + if ( npcOwner->IRelationType( pBCC ) <= D_FR ) +#else if ( npcOwner->IRelationType( pBCC ) == D_HT ) +#endif return true; if ( bSetConditions ) @@ -716,6 +720,11 @@ void CBaseCombatWeapon::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ { m_OnPlayerUse.FireOutput( pActivator, pCaller ); +#ifdef MAPBASE + // Mark that we're being +USE'd, not bumped + AddSpawnFlags(SF_WEAPON_USED); +#endif + // // Bump the weapon to try equipping it before picking it up physically. This is // important in a few spots in the game where the player could potentially +use pickup @@ -729,6 +738,10 @@ void CBaseCombatWeapon::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ { pPlayer->PickupObject( this ); } + +#ifdef MAPBASE + RemoveSpawnFlags(SF_WEAPON_USED); +#endif } } diff --git a/sp/src/game/server/baseentity.cpp b/sp/src/game/server/baseentity.cpp index b42f2abe..629e1130 100644 --- a/sp/src/game/server/baseentity.cpp +++ b/sp/src/game/server/baseentity.cpp @@ -62,6 +62,10 @@ #include "env_debughistory.h" #include "tier1/utlstring.h" #include "utlhashtable.h" +#ifdef MAPBASE +#include "mapbase/matchers.h" +#include "mapbase/datadesc_mod.h" +#endif #if defined( TF_DLL ) #include "tf_gamerules.h" @@ -1029,6 +1033,20 @@ int CBaseEntity::DrawDebugTextOverlays(void) EntityText( offset,tempstr,0 ); offset++; } + +#ifdef MAPBASE + if (m_ResponseContexts.Count() > 0) + { + const char *contexts = UTIL_VarArgs("%s:%s", STRING(m_ResponseContexts[0].m_iszName), STRING(m_ResponseContexts[0].m_iszValue)); + for (int i = 1; i < GetContextCount(); i++) + { + contexts = UTIL_VarArgs("%s,%s:%s", contexts, STRING(m_ResponseContexts[i].m_iszName), STRING(m_ResponseContexts[i].m_iszValue)); + } + Q_snprintf(tempstr, sizeof(tempstr), "Response Contexts:%s", contexts); + EntityText(offset, tempstr, 0); + offset++; + } +#endif } if (m_debugOverlays & OVERLAY_VIEWOFFSET) @@ -1043,7 +1061,11 @@ int CBaseEntity::DrawDebugTextOverlays(void) void CBaseEntity::SetParent( string_t newParent, CBaseEntity *pActivator, int iAttachment ) { // find and notify the new parent +#ifdef MAPBASE + CBaseEntity *pParent = gEntList.FindEntityByName( NULL, newParent, this, pActivator ); +#else CBaseEntity *pParent = gEntList.FindEntityByName( NULL, newParent, NULL, pActivator ); +#endif // debug check if ( newParent != NULL_STRING && pParent == NULL ) @@ -1053,7 +1075,11 @@ void CBaseEntity::SetParent( string_t newParent, CBaseEntity *pActivator, int iA else { // make sure there isn't any ambiguity +#ifdef MAPBASE + if ( gEntList.FindEntityByName( pParent, newParent, this, pActivator ) ) +#else if ( gEntList.FindEntityByName( pParent, newParent, NULL, pActivator ) ) +#endif { Msg( "Entity %s(%s) has ambigious parent %s\n", STRING(m_iClassname), GetDebugName(), STRING(newParent) ); } @@ -1470,17 +1496,27 @@ void CBaseEntity::TakeDamage( const CTakeDamageInfo &inputInfo ) } } +#ifndef MAPBASE // Moved below the gamerules AllowDamage() check // Make sure our damage filter allows the damage. if ( !PassesDamageFilter( inputInfo )) { return; } +#endif if( !g_pGameRules->AllowDamage(this, inputInfo) ) { return; } +#ifdef MAPBASE + // Make sure our damage filter allows the damage. + if ( !PassesFinalDamageFilter( inputInfo )) + { + return; + } +#endif + if ( PhysIsInCallback() ) { PhysCallbackDamage( this, inputInfo ); @@ -1500,6 +1536,11 @@ void CBaseEntity::TakeDamage( const CTakeDamageInfo &inputInfo ) //Msg("%s took %.2f Damage, at %.2f\n", GetClassname(), info.GetDamage(), gpGlobals->curtime ); +#ifdef MAPBASE + // Modify damage if we have a filter that does that + DamageFilterDamageMod(info); +#endif + OnTakeDamage( info ); } } @@ -1823,7 +1864,11 @@ BEGIN_DATADESC_NO_BASE( CBaseEntity ) DEFINE_FIELD( m_MoveType, FIELD_CHARACTER ), DEFINE_FIELD( m_MoveCollide, FIELD_CHARACTER ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_hOwnerEntity, FIELD_EHANDLE, "OwnerEntity" ), +#else DEFINE_FIELD( m_hOwnerEntity, FIELD_EHANDLE ), +#endif DEFINE_FIELD( m_CollisionGroup, FIELD_INTEGER ), DEFINE_PHYSPTR( m_pPhysicsObject), DEFINE_FIELD( m_flElasticity, FIELD_FLOAT ), @@ -1874,7 +1919,12 @@ BEGIN_DATADESC_NO_BASE( CBaseEntity ) DEFINE_KEYFIELD( m_vecViewOffset, FIELD_VECTOR, "view_ofs" ), +#ifdef MAPBASE + // You know, m_fFlags access + DEFINE_KEYFIELD( m_fFlags, FIELD_INTEGER, "m_fFlags" ), +#else DEFINE_FIELD( m_fFlags, FIELD_INTEGER ), +#endif #if !defined( NO_ENTITY_PREDICTION ) // DEFINE_FIELD( m_bIsPlayerSimulated, FIELD_INTEGER ), // DEFINE_FIELD( m_hPlayerSimulationOwner, FIELD_EHANDLE ), @@ -1923,17 +1973,91 @@ BEGIN_DATADESC_NO_BASE( CBaseEntity ) DEFINE_INPUTFUNC( FIELD_VOID, "EnableShadow", InputEnableShadow ), DEFINE_INPUTFUNC( FIELD_STRING, "AddOutput", InputAddOutput ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_STRING, "ChangeVariable", InputChangeVariable ), +#endif +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_INPUT, "PassUser1", InputPassUser1 ), + DEFINE_INPUTFUNC( FIELD_INPUT, "PassUser2", InputPassUser2 ), + DEFINE_INPUTFUNC( FIELD_INPUT, "PassUser3", InputPassUser3 ), + DEFINE_INPUTFUNC( FIELD_INPUT, "PassUser4", InputPassUser4 ), + + DEFINE_INPUTFUNC( FIELD_VOID, "FireUser1", InputFireUser1 ), + DEFINE_INPUTFUNC( FIELD_VOID, "FireUser2", InputFireUser2 ), + DEFINE_INPUTFUNC( FIELD_VOID, "FireUser3", InputFireUser3 ), + DEFINE_INPUTFUNC( FIELD_VOID, "FireUser4", InputFireUser4 ), + + DEFINE_INPUTFUNC( FIELD_VOID, "FireRandomUser", InputFireRandomUser ), + DEFINE_INPUTFUNC( FIELD_INPUT, "PassRandomUser", InputPassRandomUser ), +#else DEFINE_INPUTFUNC( FIELD_STRING, "FireUser1", InputFireUser1 ), DEFINE_INPUTFUNC( FIELD_STRING, "FireUser2", InputFireUser2 ), DEFINE_INPUTFUNC( FIELD_STRING, "FireUser3", InputFireUser3 ), DEFINE_INPUTFUNC( FIELD_STRING, "FireUser4", InputFireUser4 ), +#endif + +#ifdef MAPBASE + DEFINE_OUTPUT( m_OutUser1, "OutUser1" ), + DEFINE_OUTPUT( m_OutUser2, "OutUser2" ), + DEFINE_OUTPUT( m_OutUser3, "OutUser3" ), + DEFINE_OUTPUT( m_OutUser4, "OutUser4" ), +#endif DEFINE_OUTPUT( m_OnUser1, "OnUser1" ), DEFINE_OUTPUT( m_OnUser2, "OnUser2" ), DEFINE_OUTPUT( m_OnUser3, "OnUser3" ), DEFINE_OUTPUT( m_OnUser4, "OnUser4" ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_STRING, "SetTarget", InputSetTarget ), + DEFINE_INPUTFUNC( FIELD_EHANDLE, "SetOwnerEntity", InputSetOwnerEntity ), + + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetHealth", InputSetHealth ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "AddHealth", InputAddHealth ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "RemoveHealth", InputRemoveHealth ), + + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetMaxHealth", InputSetMaxHealth ), + + DEFINE_INPUTFUNC( FIELD_STRING, "FireOutput", InputFireOutput ), + DEFINE_INPUTFUNC( FIELD_STRING, "RemoveOutput", InputRemoveOutput ), + //DEFINE_INPUTFUNC( FIELD_STRING, "CancelOutput", InputCancelOutput ), // Find a way to implement this + DEFINE_INPUTFUNC( FIELD_STRING, "ReplaceOutput", InputReplaceOutput ), + DEFINE_INPUTFUNC( FIELD_STRING, "AcceptInput", InputAcceptInput ), + DEFINE_INPUTFUNC( FIELD_VOID, "CancelPending", InputCancelPending ), + + DEFINE_INPUTFUNC( FIELD_VOID, "FreeChildren", InputFreeChildren ), + + DEFINE_INPUTFUNC( FIELD_VECTOR, "SetLocalOrigin", InputSetLocalOrigin ), + DEFINE_INPUTFUNC( FIELD_VECTOR, "SetLocalAngles", InputSetLocalAngles ), + DEFINE_INPUTFUNC( FIELD_VECTOR, "SetLocalVelocity", InputSetLocalVelocity ), + DEFINE_INPUTFUNC( FIELD_VECTOR, "SetLocalAngularVelocity", InputSetLocalAngularVelocity ), + + DEFINE_INPUTFUNC( FIELD_INTEGER, "AddSpawnFlags", InputAddSpawnFlags ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "RemoveSpawnFlags", InputRemoveSpawnFlags ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetRenderMode", InputSetRenderMode ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetRenderFX", InputSetRenderFX ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "AddEffects", InputAddEffects ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "RemoveEffects", InputRemoveEffects ), + DEFINE_INPUTFUNC( FIELD_VOID, "EnableDraw", InputDrawEntity ), + DEFINE_INPUTFUNC( FIELD_VOID, "DisableDraw", InputUndrawEntity ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "AddEFlags", InputAddEFlags ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "RemoveEFlags", InputRemoveEFlags ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetMoveType", InputSetMoveType ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetCollisionGroup", InputSetCollisionGroup ), + + DEFINE_INPUTFUNC( FIELD_EHANDLE, "Touch", InputTouch ), + + DEFINE_INPUTFUNC( FIELD_INPUT, "KilledNPC", InputKilledNPC ), + + DEFINE_INPUTFUNC( FIELD_VOID, "KillIfNotVisible", InputKillIfNotVisible ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "KillWhenNotVisible", InputKillWhenNotVisible ), + + DEFINE_INPUTFUNC( FIELD_STRING, "SetThinkNull", InputSetThinkNull ), + + DEFINE_OUTPUT( m_OnKilled, "OnKilled" ), +#endif + // Function Pointers DEFINE_FUNCTION( SUB_Remove ), DEFINE_FUNCTION( SUB_DoNothing ), @@ -1944,6 +2068,10 @@ BEGIN_DATADESC_NO_BASE( CBaseEntity ) DEFINE_FUNCTION( SUB_CallUseToggle ), DEFINE_THINKFUNC( ShadowCastDistThink ), +#ifdef MAPBASE + DEFINE_FUNCTION( SUB_RemoveWhenNotVisible ), +#endif + DEFINE_FIELD( m_hEffectEntity, FIELD_EHANDLE ), //DEFINE_FIELD( m_DamageModifiers, FIELD_?? ), // can't save? @@ -2963,14 +3091,80 @@ bool CBaseEntity::PassesDamageFilter( const CTakeDamageInfo &info ) if (m_hDamageFilter) { CBaseFilter *pFilter = (CBaseFilter *)(m_hDamageFilter.Get()); +#ifdef MAPBASE + return pFilter->PassesDamageFilter(this, info); +#else return pFilter->PassesDamageFilter(info); +#endif } return true; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: A damage filter pass for when this is most certainly the part where we might actually take damage. +// Made for the "damage" family of filters, including filter_damage_transfer. +//----------------------------------------------------------------------------- +bool CBaseEntity::PassesFinalDamageFilter( const CTakeDamageInfo &info ) +{ + if (!PassesDamageFilter(info)) + return false; + + if (m_hDamageFilter) + { + CBaseFilter *pFilter = (CBaseFilter *)(m_hDamageFilter.Get()); + if (!pFilter->PassesFinalDamageFilter(this, info)) + { + return false; + } + } + + return true; +} + +//----------------------------------------------------------------------------- +// Purpose: A hack for damage transfers. +//----------------------------------------------------------------------------- +bool CBaseEntity::DamageFilterAllowsBlood( const CTakeDamageInfo &info ) +{ + if (m_hDamageFilter) + { + CBaseFilter *pFilter = (CBaseFilter *)(m_hDamageFilter.Get()); + if (!pFilter->BloodAllowed(this, info)) + { + return false; + } + } + + return true; +} + +//----------------------------------------------------------------------------- +// Purpose: Modifies damage taken. Returns true if damage was successfully modded. +//----------------------------------------------------------------------------- +bool CBaseEntity::DamageFilterDamageMod( CTakeDamageInfo &info ) +{ + if (m_hDamageFilter) + { + CBaseFilter *pFilter = (CBaseFilter *)(m_hDamageFilter.Get()); + if (pFilter->DamageMod(this, info)) + { + return true; + } + } + + return false; +} +#endif + FORCEINLINE bool NamesMatch( const char *pszQuery, string_t nameToMatch ) { +#ifdef MAPBASE + // NamesMatch has been turned into Matcher_NamesMatch in matchers.h + // for a wider range of accessibility and flexibility. + return Matcher_NamesMatch(pszQuery, STRING(nameToMatch)); +#else if ( nameToMatch == NULL_STRING ) return (!pszQuery || *pszQuery == 0 || *pszQuery == '*'); @@ -3005,6 +3199,7 @@ FORCEINLINE bool NamesMatch( const char *pszQuery, string_t nameToMatch ) return true; return false; +#endif } bool CBaseEntity::NameMatchesComplex( const char *pszNameOrWildcard ) @@ -3244,6 +3439,7 @@ void CBaseEntity::OnSave( IEntitySaveUtils *pUtils ) //----------------------------------------------------------------------------- void CBaseEntity::OnRestore() { +#ifndef MAPBASE // It's your fault if you're trying to load old, broken saves from a possibly closed 2013 beta in Mapbase. #if defined( PORTAL ) || defined( HL2_EPISODIC ) || defined ( HL2_DLL ) || defined( HL2_LOSTCOAST ) // We had a short period during the 2013 beta where the FL_* flags had a bogus value near the top, so detect // these bad saves and just give up. Only saves from the short beta period should have been effected. @@ -3255,6 +3451,7 @@ void CBaseEntity::OnRestore() engine->ServerCommand("wait;wait;disconnect;showconsole\n"); } +#endif #endif SimThink_EntityChanged( this ); @@ -3916,6 +4113,41 @@ bool CBaseEntity::AcceptInput( const char *szInputName, CBaseEntity *pActivator, { if ( !(Value.FieldType() == FIELD_VOID && dmap->dataDesc[i].fieldType == FIELD_STRING) ) // allow empty strings { +#ifdef MAPBASE + // Activator, etc. support for EHANDLE convert + if ( !Value.Convert( (fieldtype_t)dmap->dataDesc[i].fieldType, this, pActivator, pCaller ) ) + { + bool bBadConversion = true; + + // Attempt to convert to string and back. + // Almost all field types support being converted to a string, and many support being parsed from a string too. + fieldtype_t originalfield = Value.FieldType(); + if (Value.Convert(FIELD_STRING)) + { + bBadConversion = !(Value.Convert((fieldtype_t)dmap->dataDesc[i].fieldType, this, pActivator, pCaller)); + if (!bBadConversion) + { + // Actual support should be added for each field, but if it works, it works. + // Warning against it only matters if you're a programmer and want to add support for each field. + // Only send a warning in dev mode. + DevWarning("!! Had to convert to string and back\n" + "!! Source Field Type: %i, Target Field Type: %i\n", + originalfield, dmap->dataDesc[i].fieldType); + } + } + + if (bBadConversion) + { + Warning( "!! ERROR: bad input/output link:\n!! Unable to convert value \"%s\" from %s (%s) to field type %i\n!! Target Entity: %s (%s), Input: %s\n", + Value.GetDebug(), + ( pCaller != NULL ) ? STRING(pCaller->m_iClassname) : "", + ( pCaller != NULL ) ? STRING(pCaller->m_iName) : "", + dmap->dataDesc[i].fieldType, + STRING(m_iClassname), GetDebugName(), szInputName ); + return false; + } + } +#else if ( !Value.Convert( (fieldtype_t)dmap->dataDesc[i].fieldType ) ) { // bad conversion @@ -3925,6 +4157,7 @@ bool CBaseEntity::AcceptInput( const char *szInputName, CBaseEntity *pActivator, ( pCaller != NULL ) ? STRING(pCaller->m_iName) : "" ); return false; } +#endif } } @@ -4117,6 +4350,10 @@ void CBaseEntity::InputKill( inputdata_t &inputdata ) SetOwnerEntity( NULL ); } +#ifdef MAPBASE + m_OnKilled.FireOutput( inputdata.pActivator, this ); +#endif + UTIL_Remove( this ); } @@ -4137,6 +4374,10 @@ void CBaseEntity::InputKillHierarchy( inputdata_t &inputdata ) SetOwnerEntity( NULL ); } +#ifdef MAPBASE + m_OnKilled.FireOutput( inputdata.pActivator, this ); +#endif + UTIL_Remove( this ); } @@ -4976,6 +5217,64 @@ void ConsoleFireTargets( CBasePlayer *pPlayer, const char *name) FireTargets( name, pPlayer, pPlayer, USE_TOGGLE, 0 ); } +#ifdef MAPBASE +inline bool UtlStringLessFunc( const CUtlString &lhs, const CUtlString &rhs ) +{ + return Q_stricmp( lhs.String(), rhs.String() ) < 0; +} + +//------------------------------------------------------------------------------ +// Purpose : More concommands needed access to entities, so this has been moved to its own function. +// Input : cmdname - The name of the command. +// &commands - Where the complete autocompletes should be sent to. +// substring - The current search query. (only pool entities that start with this) +// checklen - The number of characters to check. +// Output : A pointer to a cUtlRBTRee containing all of the entities. +//------------------------------------------------------------------------------ +static int AutoCompleteEntities(const char *cmdname, CUtlVector< CUtlString > &commands, CUtlRBTree< CUtlString > &symbols, char *substring, int checklen = 0) +{ + CBaseEntity *pos = NULL; + while ((pos = gEntList.NextEnt(pos)) != NULL) + { + const char *name = pos->GetClassname(); + if (pos->GetEntityName() == NULL_STRING || Q_strnicmp(STRING(pos->GetEntityName()), substring, checklen)) + { + if (Q_strnicmp(pos->GetClassname(), substring, checklen)) + continue; + } + else + name = STRING(pos->GetEntityName()); + + CUtlString sym = name; + int idx = symbols.Find(sym); + if (idx == symbols.InvalidIndex()) + { + symbols.Insert(sym); + } + + // Too many + if (symbols.Count() >= COMMAND_COMPLETION_MAXITEMS) + break; + } + + // Now fill in the results + for (int i = symbols.FirstInorder(); i != symbols.InvalidIndex(); i = symbols.NextInorder(i)) + { + const char *name = symbols[i].String(); + + char buf[512]; + Q_strncpy(buf, name, sizeof(buf)); + Q_strlower(buf); + + CUtlString command; + command = CFmtStr("%s %s", cmdname, buf); + commands.AddToTail(command); + } + + return symbols.Count(); +} +#endif + //------------------------------------------------------------------------------ // Purpose : // Input : @@ -4988,11 +5287,46 @@ void CC_Ent_Name( const CCommand& args ) static ConCommand ent_name("ent_name", CC_Ent_Name, 0, FCVAR_CHEAT); //------------------------------------------------------------------------------ +#ifdef MAPBASE +class CEntTextAutoCompletionFunctor : public ICommandCallback, public ICommandCompletionCallback +{ +public: + virtual void CommandCallback( const CCommand &command ) + { + SetDebugBits(UTIL_GetCommandClient(), command.Arg(1), OVERLAY_TEXT_BIT); + } + + virtual int CommandCompletionCallback( const char *partial, CUtlVector< CUtlString > &commands ) + { + if ( !g_pGameRules ) + { + return 0; + } + + const char *cmdname = "ent_text"; + + char *substring = (char *)partial; + if ( Q_strstr( partial, cmdname ) ) + { + substring = (char *)partial + strlen( cmdname ) + 1; + } + + int checklen = Q_strlen( substring ); + + CUtlRBTree< CUtlString > symbols( 0, 0, UtlStringLessFunc ); + return AutoCompleteEntities(cmdname, commands, symbols, substring, checklen); + } +}; + +static CEntTextAutoCompletionFunctor g_EntTextAutoComplete; +static ConCommand ent_text("ent_text", &g_EntTextAutoComplete, "Displays text debugging information about the given entity(ies) on top of the entity (See Overlay Text)\n\tArguments: {entity_name} / {class_name} / no argument picks what player is looking at ", FCVAR_CHEAT, &g_EntTextAutoComplete); +#else void CC_Ent_Text( const CCommand& args ) { SetDebugBits(UTIL_GetCommandClient(),args[1],OVERLAY_TEXT_BIT); } static ConCommand ent_text("ent_text", CC_Ent_Text, "Displays text debugging information about the given entity(ies) on top of the entity (See Overlay Text)\n\tArguments: {entity_name} / {class_name} / no argument picks what player is looking at ", FCVAR_CHEAT); +#endif //------------------------------------------------------------------------------ void CC_Ent_BBox( const CCommand& args ) @@ -5316,10 +5650,12 @@ void CC_Ent_FireTarget( const CCommand& args ) } static ConCommand firetarget("firetarget", CC_Ent_FireTarget, 0, FCVAR_CHEAT); +#ifndef MAPBASE static bool UtlStringLessFunc( const CUtlString &lhs, const CUtlString &rhs ) { return Q_stricmp( lhs.String(), rhs.String() ) < 0; } +#endif class CEntFireAutoCompletionFunctor : public ICommandCallback, public ICommandCompletionCallback { @@ -5412,6 +5748,10 @@ public: checklen = Q_strlen( substring ); } +#ifdef MAPBASE + CUtlRBTree< CUtlString > symbols( 0, 0, UtlStringLessFunc ); + return AutoCompleteEntities(cmdname, commands, symbols, substring, checklen); +#else CUtlRBTree< CUtlString > symbols( 0, 0, UtlStringLessFunc ); CBaseEntity *pos = NULL; @@ -5451,6 +5791,7 @@ public: } return symbols.Count(); +#endif } private: int EntFire_AutoCompleteInput( const char *partial, CUtlVector< CUtlString > &commands ) @@ -5479,7 +5820,12 @@ private: Q_strncat( targetEntity, substring, sizeof( targetEntity ), nEntityNameLength ); // Find the target entity by name +#ifdef MAPBASE + CBasePlayer *pPlayer = UTIL_GetCommandClient(); + CBaseEntity *target = gEntList.FindEntityGeneric( NULL, targetEntity, pPlayer, pPlayer, pPlayer ); +#else CBaseEntity *target = gEntList.FindEntityByName( NULL, targetEntity ); +#endif if ( target == NULL ) return 0; @@ -5506,10 +5852,14 @@ private: if ( !( field->flags & FTYPEDESC_INPUT ) ) continue; +#ifndef MAPBASE // What did input variables ever do to you? + // Only want input functions if ( field->flags & FTYPEDESC_SAVE ) continue; +#endif + // See if we've got a partial string for the input name already if ( inputPartial != NULL ) { @@ -5624,6 +5974,153 @@ void CC_Ent_Info( const CCommand& args ) } static ConCommand ent_info("ent_info", CC_Ent_Info, "Usage:\n ent_info \n", FCVAR_CHEAT); +#ifdef MAPBASE +//------------------------------------------------------------------------------ +// Purpose : +// Input : +// Output : +//------------------------------------------------------------------------------ +void CC_Ent_Info_Datatable( const CCommand& args ) +{ + CBasePlayer *pPlayer = ToBasePlayer( UTIL_GetCommandClient() ); + if (!pPlayer) + { + return; + } + + if ( args.ArgC() < 2 ) + { + ClientPrint( pPlayer, HUD_PRINTCONSOLE, "Usage:\n ent_info_datatable \n" ); + } + else + { + // Each element corresponds to a specific field type. + // Hey, if you've got a better idea, be my guest. + static const char *g_FieldStrings[FIELD_TYPECOUNT] = + { + "VOID", + "FLOAT", + "STRING", + "VECTOR", + "QUATERNION", + "INTEGER", + "BOOLEAN", + "SHORT", + "CHARACTER", + "COLOR32", + "EMBEDDED", + "CUSTOM", + + "CLASSPTR", + "EHANDLE", + "EDICT", + + "POSITION_VECTOR", + "TIME", + "TICK", + "MODELNAME", + "SOUNDNAME", + + "INPUT", + "FUNCTION", + "VMATRIX", + "VMATRIX_WORLDSPACE", + "MATRIX3X4_WORLDSPACE", + "INTERVAL", + "MODELINDEX", + "MATERIALINDEX", + + "VECTOR2D", + }; + + // iterate through all the ents printing out their details + CBaseEntity *ent = CreateEntityByName( args[1] ); + + if ( ent ) + { +#define ENT_INFO_BY_HIERARCHY 1 +#ifdef ENT_INFO_BY_HIERARCHY + CUtlVector dmap_namelist; + + CUtlVector< CUtlVector > dmap_fieldlist; + CUtlVector< CUtlVector > dmap_fieldtypelist; + + datamap_t *dmap; + int dmapnum = 0; + for ( dmap = ent->GetDataDescMap(); dmap != NULL; dmap = dmap->baseMap ) + { + dmap_fieldlist.AddToTail(); + dmap_fieldtypelist.AddToTail(); + + // search through all the actions in the data description, printing out details + for ( int i = 0; i < dmap->dataNumFields; i++ ) + { + dmap_fieldlist[dmapnum].AddToTail(dmap->dataDesc[i].fieldName); + dmap_fieldtypelist[dmapnum].AddToTail(dmap->dataDesc[i].fieldType); + } + + dmapnum++; + dmap_namelist.AddToTail(dmap->dataClassName); + } + + char offset[64] = { 0 }; // Needed so garbage isn't spewed at the beginning + for ( int i = 0; i < dmapnum; i++ ) + { + Q_strncat(offset, " ", sizeof(offset)); + + // Header for each class + ClientPrint( pPlayer, HUD_PRINTCONSOLE, UTIL_VarArgs("%s=========| %s |=========\n", offset, dmap_namelist[i]) ); + + Q_strncat(offset, " ", sizeof(offset)); + + int iFieldCount = dmap_fieldlist[i].Count(); + for ( int index = 0; index < iFieldCount; index++ ) + { + int iType = dmap_fieldtypelist[i][index]; + ClientPrint( pPlayer, HUD_PRINTCONSOLE, UTIL_VarArgs("%s%s (%i): %s\n", offset, g_FieldStrings[iType], iType, dmap_fieldlist[i][index]) ); + } + + // Clean up after ourselves + dmap_fieldlist[i].RemoveAll(); + dmap_fieldtypelist[i].RemoveAll(); + } +#else // This sorts by field type instead + CUtlVector fieldlist[FIELD_TYPECOUNT]; + + datamap_t *dmap; + for ( dmap = ent->GetDataDescMap(); dmap != NULL; dmap = dmap->baseMap ) + { + // search through all the actions in the data description, printing out details + for ( int i = 0; i < dmap->dataNumFields; i++ ) + { + fieldlist[dmap->dataDesc[i].fieldType].AddToTail(dmap->dataDesc[i].fieldName); + } + } + + for ( int i = 0; i < FIELD_TYPECOUNT; i++ ) + { + const char *typestring = g_FieldStrings[i]; + for ( int index = 0; index < fieldlist[i].Count(); index++ ) + { + ClientPrint( pPlayer, HUD_PRINTCONSOLE, UTIL_VarArgs(" %s (%i): %s\n", typestring, i, fieldlist[i][index]) ); + } + + // Clean up after ourselves + fieldlist[i].RemoveAll(); + } +#endif + + delete ent; + } + else + { + ClientPrint( pPlayer, HUD_PRINTCONSOLE, UTIL_VarArgs("no such entity %s\n", args[1]) ); + } + } +} +static ConCommand ent_info_datatable("ent_info_datatable", CC_Ent_Info_Datatable, "Usage:\n ent_info_datatable \n", FCVAR_CHEAT); +#endif + //------------------------------------------------------------------------------ // Purpose : @@ -6324,8 +6821,10 @@ void CBaseEntity::ModifyOrAppendCriteria( AI_CriteriaSet& set ) set.AppendCriteria( szGlobalName, UTIL_VarArgs( "%i", iGlobalState ) ); } +#ifndef MAPBASE // We do this later now so contexts can override criteria. I originally didn't want to remove it here in case there would be problems, but I think I have all of the bases covered. // Append anything from I/O or keyvalues pairs AppendContextToCriteria( set ); +#endif if( hl2_episodic.GetBool() ) { @@ -6333,11 +6832,21 @@ void CBaseEntity::ModifyOrAppendCriteria( AI_CriteriaSet& set ) } // Append anything from world I/O/keyvalues with "world" as prefix +#ifdef MAPBASE + CWorld *world = GetWorldEntity(); +#else CWorld *world = dynamic_cast< CWorld * >( CBaseEntity::Instance( engine->PEntityOfEntIndex( 0 ) ) ); +#endif if ( world ) { world->AppendContextToCriteria( set, "world" ); } + +#ifdef MAPBASE + // Append base stuff + set.AppendCriteria("spawnflags", UTIL_VarArgs("%i", GetSpawnFlags())); + set.AppendCriteria("flags", UTIL_VarArgs("%i", GetFlags())); +#endif } //----------------------------------------------------------------------------- @@ -6364,6 +6873,29 @@ void CBaseEntity::AppendContextToCriteria( AI_CriteriaSet& set, const char *pref } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +// Input : set - +// "" - +//----------------------------------------------------------------------------- +void CBaseEntity::ReAppendContextCriteria( AI_CriteriaSet& set ) +{ + // Append contexts again. This allows it to override standard criteria, including that of derived classes. + CWorld *world = GetWorldEntity(); + if ( world ) + { + // I didn't know this until recently, but world contexts are actually prefixed by "world". + // I'm changing this here to reduce confusion and allow greater potential. + // (e.g. disabling combine soldier episodic on/off in Episodic binaries with world context "episodic:0", even though that's not happening anymore) + // The old prefixed ones still exist. They're just not appended again. + world->AppendContextToCriteria( set ); + } + + AppendContextToCriteria( set ); +} +#endif + //----------------------------------------------------------------------------- // Purpose: Removes expired concepts from list // Output : @@ -6464,6 +6996,120 @@ int CBaseEntity::FindContextByName( const char *name ) const return -1; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Searches entity for named context string and/or value. +// Intended to be called by entities rather than the conventional response system. +// Input : *name - Context name. +// *value - Context value. (optional) +// Output : bool +//----------------------------------------------------------------------------- +bool CBaseEntity::HasContext( const char *name, const char *value ) const +{ + int c = m_ResponseContexts.Count(); + for ( int i = 0; i < c; i++ ) + { + if ( Matcher_NamesMatch( name, STRING(m_ResponseContexts[i].m_iszName) ) ) + { + if (value == NULL) + return true; + else + return Matcher_Compare(STRING(m_ResponseContexts[i].m_iszValue), value); + } + } + + return false; +} + +//----------------------------------------------------------------------------- +// Purpose: Searches entity for named context string and/or value. +// Intended to be called by entities rather than the conventional response system. +// Input : *name - Context name. +// *value - Context value. (optional) +// Output : bool +//----------------------------------------------------------------------------- +bool CBaseEntity::HasContext( string_t name, string_t value ) const +{ + int c = m_ResponseContexts.Count(); + for ( int i = 0; i < c; i++ ) + { + if ( name == m_ResponseContexts[i].m_iszName ) + { + if (value == NULL_STRING) + return true; + else + return value == m_ResponseContexts[i].m_iszValue; + } + } + + return false; +} + +//----------------------------------------------------------------------------- +// Purpose: Searches entity for named context string and/or value. +// Intended to be called by entities rather than the conventional response system. +// Input : *nameandvalue - Context name and value. +// Output : bool +//----------------------------------------------------------------------------- +bool CBaseEntity::HasContext( const char *nameandvalue ) const +{ + char key[ 128 ]; + char value[ 128 ]; + + const char *p = nameandvalue; + while ( p ) + { + p = SplitContext( p, key, sizeof( key ), value, sizeof( value ), NULL ); + + return HasContext( key, value ); + } + + return false; +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : index - +// Output : const char +//----------------------------------------------------------------------------- +const char *CBaseEntity::GetContextValue( const char *contextName ) const +{ + int idx = FindContextByName( contextName ); + if ( idx == -1 ) + return NULL; + + return m_ResponseContexts[ idx ].m_iszValue.ToCStr(); +} + +//----------------------------------------------------------------------------- +// Purpose: Internal method or removing contexts and can remove multiple contexts in one call +// Input : *contextName - +//----------------------------------------------------------------------------- +void CBaseEntity::RemoveContext( const char *contextName ) +{ + char key[ 128 ]; + char value[ 128 ]; + float duration; + + const char *p = contextName; + while ( p ) + { + duration = 0.0f; + p = SplitContext( p, key, sizeof( key ), value, sizeof( value ), &duration ); + if ( duration ) + { + duration += gpGlobals->curtime; + } + + int iIndex = FindContextByName( key ); + if ( iIndex != -1 ) + { + m_ResponseContexts.Remove( iIndex ); + } + } +} +#endif + //----------------------------------------------------------------------------- // Purpose: // Input : inputdata - @@ -6510,6 +7156,596 @@ void CBaseEntity::InputFireUser4( inputdata_t& inputdata ) } +#ifdef MAPBASE +void CBaseEntity::InputPassUser1( inputdata_t& inputdata ) +{ + m_OutUser1.Set( inputdata.value, inputdata.pActivator, this ); +} + +void CBaseEntity::InputPassUser2( inputdata_t& inputdata ) +{ + m_OutUser2.Set( inputdata.value, inputdata.pActivator, this ); +} + +void CBaseEntity::InputPassUser3( inputdata_t& inputdata ) +{ + m_OutUser3.Set( inputdata.value, inputdata.pActivator, this ); +} + +void CBaseEntity::InputPassUser4( inputdata_t& inputdata ) +{ + m_OutUser4.Set( inputdata.value, inputdata.pActivator, this ); +} + + +void CBaseEntity::InputFireRandomUser( inputdata_t& inputdata ) +{ + switch (RandomInt(1, 4)) + { + case 1: m_OnUser1.FireOutput( inputdata.pActivator, this ); break; + case 2: m_OnUser2.FireOutput( inputdata.pActivator, this ); break; + case 3: m_OnUser3.FireOutput( inputdata.pActivator, this ); break; + case 4: m_OnUser4.FireOutput( inputdata.pActivator, this ); break; + } +} + +void CBaseEntity::InputPassRandomUser( inputdata_t& inputdata ) +{ + switch (RandomInt(1, 4)) + { + case 1: m_OutUser1.Set( inputdata.value, inputdata.pActivator, this ); break; + case 2: m_OutUser2.Set( inputdata.value, inputdata.pActivator, this ); break; + case 3: m_OutUser3.Set( inputdata.value, inputdata.pActivator, this ); break; + case 4: m_OutUser4.Set( inputdata.value, inputdata.pActivator, this ); break; + } +} +#endif + + +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Sets the generic target field. +//----------------------------------------------------------------------------- +void CBaseEntity::InputSetTarget( inputdata_t& inputdata ) +{ + m_target = inputdata.value.StringID(); + Activate(); +} + +//----------------------------------------------------------------------------- +// Purpose: Sets our owner entity. +//----------------------------------------------------------------------------- +void CBaseEntity::InputSetOwnerEntity( inputdata_t& inputdata ) +{ + SetOwnerEntity(inputdata.value.Entity()); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for adding to the entity's health. +// Input : Integer health points to add. +//----------------------------------------------------------------------------- +void CBaseEntity::InputAddHealth( inputdata_t &inputdata ) +{ + TakeHealth( abs(inputdata.value.Int()), DMG_GENERIC ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for removing health from the entity. +// Input : Integer health points to remove. +//----------------------------------------------------------------------------- +void CBaseEntity::InputRemoveHealth( inputdata_t &inputdata ) +{ + TakeDamage( CTakeDamageInfo( this, this, abs(inputdata.value.Int()), DMG_GENERIC ) ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBaseEntity::InputSetHealth( inputdata_t &inputdata ) +{ + int iNewHealth = inputdata.value.Int(); + int iDelta = abs(GetHealth() - iNewHealth); + if ( iNewHealth > GetHealth() ) + { + TakeHealth( iDelta, DMG_GENERIC ); + } + else if ( iNewHealth < GetHealth() ) + { + TakeDamage( CTakeDamageInfo( this, this, iDelta, DMG_GENERIC ) ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBaseEntity::InputSetMaxHealth( inputdata_t &inputdata ) +{ + int iNewMaxHealth = inputdata.value.Int(); + SetMaxHealth(iNewMaxHealth); + + if (GetHealth() > iNewMaxHealth) + { + SetHealth(iNewMaxHealth); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Forces the named output to fire. +// In addition to the output itself, parameter may include !activator, !caller, and what to pass. +//----------------------------------------------------------------------------- +void CBaseEntity::InputFireOutput( inputdata_t& inputdata ) +{ + char sParameter[MAX_PATH]; + Q_strncpy( sParameter, inputdata.value.String(), sizeof(sParameter) ); + if ( sParameter ) + { + int iter = 0; + char *data[5] = {sParameter}; + char *sToken = strtok( sParameter, ":" ); + while ( sToken && iter < 5 ) + { + data[iter] = sToken; + iter++; + sToken = strtok( NULL, ":" ); + } + + //DevMsg("data[0]: %s\ndata[1]: %s\ndata[2]: %s\ndata[3]: %s\ndata[4]: %s\n", data[0], data[1], data[2], data[3], data[4]); + + // Format: :::: + // + // data[0] = Output Name + // data[1] = Activator + // data[2] = Caller + // data[3] = Parameter + // data[4] = Delay + // + CBaseEntity *pActivator = inputdata.pActivator; + if (data[1]) + pActivator = gEntList.FindEntityByName(NULL, data[1], this, inputdata.pActivator, inputdata.pCaller); + + CBaseEntity *pCaller = this; + if (data[2]) + pCaller = gEntList.FindEntityByName(NULL, data[2], this, inputdata.pActivator, inputdata.pCaller); + + variant_t parameter; + if (data[3]) + { + parameter.SetString(MAKE_STRING(data[3])); + } + + float flDelay = 0.0f; + if (data[4]) + flDelay = atof(data[4]); + + FireNamedOutput(data[0], parameter, pActivator, pCaller, flDelay); + //Msg("Output Name: %s, Activator: %s, Caller: %s, Data: %s, Delay: %f\n", data[0], pActivator->GetDebugName(), pCaller->GetDebugName(), parameter.String(), flDelay); + } + else + { + Warning("FireOutput input fired with bad parameter. Format: ::::\n"); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Removes all outputs of the specified name. +//----------------------------------------------------------------------------- +void CBaseEntity::InputRemoveOutput( inputdata_t& inputdata ) +{ + const char *szOutput = inputdata.value.String(); + datamap_t *dmap = GetDataDescMap(); + while ( dmap ) + { + int fields = dmap->dataNumFields; + for ( int i = 0; i < fields; i++ ) + { + typedescription_t *dataDesc = &dmap->dataDesc[i]; + if ( ( dataDesc->fieldType == FIELD_CUSTOM ) && ( dataDesc->flags & FTYPEDESC_OUTPUT ) ) + { + // If our names match, remove + if (Matcher_NamesMatch(szOutput, dataDesc->externalName)) + { + CBaseEntityOutput *pOutput = (CBaseEntityOutput *)((int)this + (int)dataDesc->fieldOffset[0]); + pOutput->DeleteAllElements(); + } + } + } + + dmap = dmap->baseMap; + } +} + +// Find a way to implement this +/* +//------------------------------------------------------------------------------ +// Purpose: Cancels all I/O events of a specific output. +//------------------------------------------------------------------------------ +void CBaseEntity::InputCancelOutput( inputdata_t &inputdata ) +{ + +} +*/ + +//----------------------------------------------------------------------------- +// Purpose: Replaces all outputs of the specified name. +//----------------------------------------------------------------------------- +void CBaseEntity::InputReplaceOutput( inputdata_t& inputdata ) +{ + char sParameter[128]; + Q_strncpy( sParameter, inputdata.value.String(), sizeof(sParameter) ); + if (!sParameter) + return; + + int iter = 0; + char *data[2]; + char *sToken = strtok( sParameter, ": " ); + while ( sToken && iter < 2 ) + { + data[iter] = sToken; + iter++; + sToken = strtok( NULL, ": " ); + } + + const char *szOutput = data[0]; + const char *szNewOutput = data[1]; + if (!szOutput || !szNewOutput) + { + Warning("ReplaceOutput input fired with bad parameter. Format: :\n"); + return; + } + + int iOutputsReplaced = 0; + datamap_t *dmap = GetDataDescMap(); + while ( dmap ) + { + int fields = dmap->dataNumFields; + for ( int i = 0; i < fields; i++ ) + { + typedescription_t *dataDesc = &dmap->dataDesc[i]; + if ( ( dataDesc->fieldType == FIELD_CUSTOM ) && ( dataDesc->flags & FTYPEDESC_OUTPUT ) ) + { + // If our names match, replace + if (Matcher_NamesMatch(szOutput, dataDesc->externalName)) + { + CBaseEntityOutput *pOutput = (CBaseEntityOutput *)((int)this + (int)dataDesc->fieldOffset[0]); + const char *szTarget; + const char *szInputName; + const char *szParam; + float flDelay; + int iNumTimes; + char szData[256]; + for ( CEventAction *ev = pOutput->GetActionList(); ev != NULL; ev = ev->m_pNext ) + { + // This is the only way I think we could do this. Accomplishes the job more or less anyway + szTarget = STRING(ev->m_iTarget); + szInputName = STRING(ev->m_iTargetInput); + szParam = ev->m_iParameter == NULL_STRING ? "" : STRING(ev->m_iParameter); + flDelay = ev->m_flDelay; + iNumTimes = ev->m_nTimesToFire; + Q_snprintf(szData, sizeof(szData), "%s,%s,%s,%f,%i", szTarget, szInputName, szParam, flDelay, iNumTimes); + + KeyValue(szNewOutput, szData); + + DevMsg("ReplaceOutput: %s %s\n", szNewOutput, szData); + + iOutputsReplaced++; + } + pOutput->DeleteAllElements(); + } + } + } + + dmap = dmap->baseMap; + } + + if (iOutputsReplaced == 0) + { + Warning("ReplaceOutput unable to find %s on %s\n", szOutput, GetDebugName()); + } + else + { + DevMsg("Replaced %i instances of %s with %s on %s\n", iOutputsReplaced, szOutput, szNewOutput, GetDebugName()); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Forces the named input to fire...what? +// Inputception...or is it just "Inception"? Whatever. +// True inception would be using this input to fire AcceptInput. +// (it would probably crash, I haven't tested it) +// +// In addition to the input itself, parameter may include !activator, !caller, and what to pass. +//----------------------------------------------------------------------------- +void CBaseEntity::InputAcceptInput( inputdata_t& inputdata ) +{ + char sParameter[MAX_PATH]; + Q_strncpy( sParameter, inputdata.value.String(), sizeof(sParameter) ); + if ( sParameter ) + { + int iter = 0; + char *data[5] = {sParameter}; + char *sToken = strtok( sParameter, ":" ); + while ( sToken && iter < 5 ) + { + data[iter] = sToken; + iter++; + sToken = strtok( NULL, ":" ); + } + + //DevMsg("data[0]: %s\ndata[1]: %s\ndata[2]: %s\ndata[3]: %s\ndata[4]: %s\n", data[0], data[1], data[2], data[3], data[4]); + + // Format: :::: + // + // data[0] = Input Name + // data[1] = Parameter + // data[2] = Activator + // data[3] = Caller + // data[4] = Output ID + // + variant_t parameter; + if (data[1]) + { + parameter.SetString(MAKE_STRING(data[1])); + } + + CBaseEntity *pActivator = inputdata.pActivator; + if (data[2]) + pActivator = gEntList.FindEntityByName(NULL, data[2], this, inputdata.pActivator, inputdata.pCaller); + + CBaseEntity *pCaller = this; + if (data[3]) + pCaller = gEntList.FindEntityByName(NULL, data[3], this, inputdata.pActivator, inputdata.pCaller); + + int iOutputID = -1; + if (data[4]) + iOutputID = atoi(data[4]); + + AcceptInput(data[0], pActivator, pCaller, parameter, iOutputID); + Msg("Input Name: %s, Activator: %s, Caller: %s, Data: %s, Output ID: %i\n", data[0], pActivator ? pActivator->GetDebugName() : "None", pCaller ? pCaller->GetDebugName() : "None", parameter.String(), iOutputID); + } + else + { + Warning("AcceptInput input fired with bad parameter. Format: ::::\n"); + } +} + +//------------------------------------------------------------------------------ +// Purpose: Cancels any I/O events in the queue that were fired by this entity. +//------------------------------------------------------------------------------ +void CBaseEntity::InputCancelPending( inputdata_t &inputdata ) +{ + g_EventQueue.CancelEvents( this ); +} + +//----------------------------------------------------------------------------- +// Purpose: Frees all of our children, entities parented to this entity. +//----------------------------------------------------------------------------- +void CBaseEntity::InputFreeChildren( inputdata_t& inputdata ) +{ + UnlinkAllChildren( this ); +} + +//----------------------------------------------------------------------------- +// Purpose: Sets our origin. +//----------------------------------------------------------------------------- +void CBaseEntity::InputSetLocalOrigin( inputdata_t& inputdata ) +{ + Vector vec; + inputdata.value.Vector3D(vec); + SetLocalOrigin(vec); +} + +//----------------------------------------------------------------------------- +// Purpose: Sets our angles. +//----------------------------------------------------------------------------- +void CBaseEntity::InputSetLocalAngles( inputdata_t& inputdata ) +{ + Vector vec; + inputdata.value.Vector3D(vec); + SetLocalAngles(QAngle(vec.x, vec.y, vec.z)); +} + +//----------------------------------------------------------------------------- +// Purpose: Sets our velocity. +//----------------------------------------------------------------------------- +void CBaseEntity::InputSetLocalVelocity( inputdata_t& inputdata ) +{ + Vector vec; + inputdata.value.Vector3D(vec); + SetLocalVelocity(vec); +} + +//----------------------------------------------------------------------------- +// Purpose: Sets our angular velocity. +//----------------------------------------------------------------------------- +void CBaseEntity::InputSetLocalAngularVelocity( inputdata_t& inputdata ) +{ + Vector vec; + inputdata.value.Vector3D(vec); + SetLocalAngularVelocity(QAngle(vec.x, vec.y, vec.z)); +} + +//----------------------------------------------------------------------------- +// Purpose: Adds spawn flags. +//----------------------------------------------------------------------------- +void CBaseEntity::InputAddSpawnFlags( inputdata_t& inputdata ) +{ + AddSpawnFlags(inputdata.value.Int()); +} + +//----------------------------------------------------------------------------- +// Purpose: Removes spawn flags. +//----------------------------------------------------------------------------- +void CBaseEntity::InputRemoveSpawnFlags( inputdata_t& inputdata ) +{ + RemoveSpawnFlags(inputdata.value.Int()); +} + +//----------------------------------------------------------------------------- +// Purpose: Sets our render mode. +//----------------------------------------------------------------------------- +void CBaseEntity::InputSetRenderMode( inputdata_t& inputdata ) +{ + SetRenderMode((RenderMode_t)inputdata.value.Int()); +} + +//----------------------------------------------------------------------------- +// Purpose: Sets our render FX. +//----------------------------------------------------------------------------- +void CBaseEntity::InputSetRenderFX( inputdata_t& inputdata ) +{ + m_nRenderFX = inputdata.value.Int(); +} + +//----------------------------------------------------------------------------- +// Purpose: Adds effects. +//----------------------------------------------------------------------------- +void CBaseEntity::InputAddEffects( inputdata_t& inputdata ) +{ + AddEffects(inputdata.value.Int()); +} + +//----------------------------------------------------------------------------- +// Purpose: Removes effects. +//----------------------------------------------------------------------------- +void CBaseEntity::InputRemoveEffects( inputdata_t& inputdata ) +{ + RemoveEffects(inputdata.value.Int()); +} + +//----------------------------------------------------------------------------- +// Purpose: Shortcut for removing nodraw. +//----------------------------------------------------------------------------- +void CBaseEntity::InputDrawEntity( inputdata_t& inputdata ) +{ + RemoveEffects(EF_NODRAW); +} + +//----------------------------------------------------------------------------- +// Purpose: Shortcut to adding nodraw. +//----------------------------------------------------------------------------- +void CBaseEntity::InputUndrawEntity( inputdata_t& inputdata ) +{ + AddEffects(EF_NODRAW); +} + +//----------------------------------------------------------------------------- +// Purpose: Adds eflags. +//----------------------------------------------------------------------------- +void CBaseEntity::InputAddEFlags( inputdata_t& inputdata ) +{ + AddEFlags(inputdata.value.Int()); +} + +//----------------------------------------------------------------------------- +// Purpose: Removes eflags. +//----------------------------------------------------------------------------- +void CBaseEntity::InputRemoveEFlags( inputdata_t& inputdata ) +{ + RemoveEFlags(inputdata.value.Int()); +} + +//----------------------------------------------------------------------------- +// Purpose: Sets the movetype. +//----------------------------------------------------------------------------- +void CBaseEntity::InputSetMoveType( inputdata_t& inputdata ) +{ + SetMoveType((MoveType_t)inputdata.value.Int()); +} + +//----------------------------------------------------------------------------- +// Purpose: Sets the collision group. +//----------------------------------------------------------------------------- +void CBaseEntity::InputSetCollisionGroup( inputdata_t& inputdata ) +{ + SetCollisionGroup(inputdata.value.Int()); +} + +//----------------------------------------------------------------------------- +// Purpose: Touch touch :) +//----------------------------------------------------------------------------- +void CBaseEntity::InputTouch( inputdata_t& inputdata ) +{ + Touch(inputdata.value.Entity()); +} + +//----------------------------------------------------------------------------- +// Purpose: Passes KilledNPC to our possibly more capable parents. +//----------------------------------------------------------------------------- +void CBaseEntity::InputKilledNPC( inputdata_t &inputdata ) +{ + // Don't get stuck in an endless loop + if (inputdata.value.Int() > 16) + return; + else + inputdata.value.SetInt(inputdata.value.Int() + 1); + + if (GetOwnerEntity()) + { + GetOwnerEntity()->AcceptInput("KilledNPC", inputdata.pActivator, inputdata.pCaller, inputdata.value, inputdata.nOutputID); + } + else if (HasPhysicsAttacker(4.0f)) + { + HasPhysicsAttacker(4.0f)->AcceptInput("KilledNPC", inputdata.pActivator, inputdata.pCaller, inputdata.value, inputdata.nOutputID); + } + else if (GetMoveParent()) + { + GetMoveParent()->AcceptInput("KilledNPC", inputdata.pActivator, inputdata.pCaller, inputdata.value, inputdata.nOutputID); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Remove if not visible by any players +//----------------------------------------------------------------------------- +void CBaseEntity::InputKillIfNotVisible( inputdata_t& inputdata ) +{ +#ifdef MAPBASE_MP + // Go through each client and check if we're in their viewcone. + // If we're in someone's viewcone, return immediately. + for ( int i = 1; i <= gpGlobals->maxClients; i++ ) + { + CBasePlayer *pPlayer = UTIL_PlayerByIndex( i ); + if ( pPlayer && pPlayer->FInViewCone( this ) ) + return; + } +#else + CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); + if ( !pPlayer || !pPlayer->FInViewCone( this ) ) +#endif + { + m_OnKilled.FireOutput(inputdata.pActivator, this); + UTIL_Remove(this); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Remove when not visible by any players +//----------------------------------------------------------------------------- +void CBaseEntity::InputKillWhenNotVisible( inputdata_t& inputdata ) +{ + SetContextThink( &CBaseEntity::SUB_RemoveWhenNotVisible, gpGlobals->curtime + inputdata.value.Float(), "SUB_RemoveWhenNotVisible" ); + //SetRenderColorA( 255 ); + //m_nRenderMode = kRenderNormal; +} + +//----------------------------------------------------------------------------- +// Purpose: Stop thinking +//----------------------------------------------------------------------------- +void CBaseEntity::InputSetThinkNull( inputdata_t& inputdata ) +{ + const char *szContext = inputdata.value.String(); + if (szContext && szContext[0] != '\0') + { + SetContextThink( NULL, TICK_NEVER_THINK, szContext ); + } + else + { + SetThink( NULL ); + SetNextThink( TICK_NEVER_THINK ); + } +} +#endif + + //----------------------------------------------------------------------------- // Purpose: // Input : *contextName - @@ -6548,6 +7784,27 @@ void CBaseEntity::AddContext( const char *contextName ) } } +#ifdef MAPBASE +void CBaseEntity::AddContext( const char *name, const char *value, float duration ) +{ + int iIndex = FindContextByName( name ); + if ( iIndex != -1 ) + { + // Set the existing context to the new value + m_ResponseContexts[iIndex].m_iszValue = AllocPooledString( value ); + m_ResponseContexts[iIndex].m_fExpirationTime = duration; + return; + } + + ResponseContext_t newContext; + newContext.m_iszName = AllocPooledString( name ); + newContext.m_iszValue = AllocPooledString( value ); + newContext.m_fExpirationTime = duration; + + m_ResponseContexts.AddToTail( newContext ); +} +#endif + //----------------------------------------------------------------------------- // Purpose: // Input : inputdata - @@ -6631,6 +7888,67 @@ void CBaseEntity::InputAddOutput( inputdata_t &inputdata ) } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CBaseEntity::InputChangeVariable( inputdata_t &inputdata ) +{ + const char *szKeyName = NULL; + const char *szValue = NULL; + + char sOutputName[MAX_PATH]; + Q_strncpy( sOutputName, inputdata.value.String(), sizeof(sOutputName) ); + char *sChar = strchr( sOutputName, ' ' ); + if ( sChar ) + { + *sChar = '\0'; + // Now replace all the :'s in the string with ,'s. + // Has to be done this way because Hammer doesn't allow ,'s inside parameters. + char *sColon = strchr( sChar+1, ':' ); + while ( sColon ) + { + *sColon = ','; + sColon = strchr( sChar+1, ':' ); + } + + szKeyName = sOutputName; + szValue = sChar + 1; + } + else + { + Warning("ChangeVariable input fired with bad string. Format: ,,,,\n"); + return; + } + + if (szKeyName == NULL) + return; + + for ( datamap_t *dmap = GetDataDescMap(); dmap != NULL; dmap = dmap->baseMap ) + { + // search through all the readable fields in the data description, looking for a match + for ( int i = 0; i < dmap->dataNumFields; i++ ) + { + if ( dmap->dataDesc[i].flags & (FTYPEDESC_SAVE | FTYPEDESC_KEY) ) + { + if ( Matcher_NamesMatch(szKeyName, dmap->dataDesc[i].fieldName) ) + { + // Copied from ::ParseKeyvalue...or technically logic_datadesc_accessor... + typedescription_t *pField = &dmap->dataDesc[i]; + char *data = Datadesc_SetFieldString( szValue, this, pField, NULL ); + + if (!data) + { + Warning( "%s cannot set field of type %i.\n", GetDebugName(), dmap->dataDesc[i].fieldType ); + } + } + } + } + } +} +#endif + //----------------------------------------------------------------------------- // Purpose: // Input : *conceptName - @@ -6652,6 +7970,10 @@ void CBaseEntity::DispatchResponse( const char *conceptName ) if( pPlayer ) pPlayer->ModifyOrAppendPlayerCriteria( set ); +#ifdef MAPBASE + ReAppendContextCriteria( set ); +#endif + // Now that we have a criteria set, ask for a suitable response AI_Response result; bool found = rs->FindBestResponse( set, result ); @@ -6663,6 +7985,15 @@ void CBaseEntity::DispatchResponse( const char *conceptName ) // Handle the response here... char response[ 256 ]; result.GetResponse( response, sizeof( response ) ); +#ifdef MAPBASE + if (response[0] == '$') + { + response[0] = '\0'; + DevMsg("Replacing %s with %s...\n", response, GetContextValue(response)); + Q_strncpy(response, GetContextValue(response), sizeof(response)); + PrecacheScriptSound( response ); + } +#endif switch ( result.GetType() ) { case RESPONSE_SPEAK: @@ -6672,6 +8003,13 @@ void CBaseEntity::DispatchResponse( const char *conceptName ) break; case RESPONSE_SENTENCE: { +#ifdef MAPBASE + if (response[0] != '!') + { + SENTENCEG_PlayRndSz( edict(), response, 1, result.GetSoundLevel(), 0, PITCH_NORM ); + break; + } +#endif int sentenceIndex = SENTENCEG_Lookup( response ); if( sentenceIndex == -1 ) { @@ -6686,8 +8024,29 @@ void CBaseEntity::DispatchResponse( const char *conceptName ) break; case RESPONSE_SCENE: { +#ifdef MAPBASE + // Most flexing actors that use scenes override DispatchResponse via CAI_Expresser in ai_speech. + // So, in order for non-actors to use scenes by themselves, they actually don't really use them at all. + // Most scenes that would be used as responses only have one sound, so we take the first sound in a scene and emit it manually. + // + // Of course, env_speaker uses scenes without using itself as an actor, but that overrides DispatchResponse in Mapbase + // with the original code intact. Hopefully no other entity uses this like that... + + //if (!ClassMatches("env_speaker")) + { + // Expand gender string + GenderExpandString( response, response, sizeof( response ) ); + + // Trust that it's been precached + const char *pszSound = GetFirstSoundInScene(response); + EmitSound(pszSound); + } + //else + // InstancedScriptedScene(NULL, response); +#else // Try to fire scene w/o an actor InstancedScriptedScene( NULL, response ); +#endif } break; case RESPONSE_PRINT: @@ -6720,6 +8079,10 @@ void CBaseEntity::DumpResponseCriteria( void ) pPlayer->ModifyOrAppendPlayerCriteria( set ); } +#ifdef MAPBASE + ReAppendContextCriteria( set ); +#endif + // Now dump it all to console set.Describe(); } @@ -7224,6 +8587,11 @@ void CBaseEntity::SUB_FadeOut( void ) if ( m_clrRender->a == 0 ) { +#ifdef MAPBASE + // This was meant for KillWhenNotVisible before it used its own function, + // but there's not really any harm for keeping this here. + m_OnKilled.FireOutput(this, this); +#endif UTIL_Remove(this); } else @@ -7232,6 +8600,33 @@ void CBaseEntity::SUB_FadeOut( void ) } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: For KillWhenNotVisible, based off of SUB_FadeOut +//----------------------------------------------------------------------------- +void CBaseEntity::SUB_RemoveWhenNotVisible( void ) +{ + if ( SUB_AllowedToFade() == false ) + { + SetNextThink( gpGlobals->curtime + 1, "SUB_RemoveWhenNotVisible" ); + SetRenderColorA( 255 ); + return; + } + + SetRenderColorA( m_clrRender->a - 1 ); + + if ( m_clrRender->a == 0 ) + { + m_OnKilled.FireOutput(this, this); + UTIL_Remove(this); + } + else + { + SetNextThink( gpGlobals->curtime, "SUB_RemoveWhenNotVisible" ); + } +} +#endif + inline bool AnyPlayersInHierarchy_R( CBaseEntity *pEnt ) { @@ -7432,6 +8827,51 @@ bool CC_GetCommandEnt( const CCommand& args, CBaseEntity **ent, Vector *vecTarge return true; } +#ifdef MAPBASE +class CEntTeleportAutoCompletionFunctor : public ICommandCallback, public ICommandCompletionCallback +{ +public: + virtual void CommandCallback( const CCommand &command ) + { + if ( command.ArgC() < 2 ) + { + Msg( "Format: ent_teleport \n" ); + return; + } + + CBaseEntity *pEnt; + Vector vecTargetPoint; + if ( CC_GetCommandEnt( command, &pEnt, &vecTargetPoint, NULL ) ) + { + pEnt->Teleport( &vecTargetPoint, NULL, NULL ); + } + } + + virtual int CommandCompletionCallback( const char *partial, CUtlVector< CUtlString > &commands ) + { + if ( !g_pGameRules ) + { + return 0; + } + + const char *cmdname = "ent_teleport"; + + char *substring = (char *)partial; + if ( Q_strstr( partial, cmdname ) ) + { + substring = (char *)partial + strlen( cmdname ) + 1; + } + + int checklen = Q_strlen( substring ); + + CUtlRBTree< CUtlString > symbols( 0, 0, UtlStringLessFunc ); + return AutoCompleteEntities(cmdname, commands, symbols, substring, checklen); + } +}; + +static CEntTeleportAutoCompletionFunctor g_EntTeleportAutoComplete; +static ConCommand ent_teleport("ent_teleport", &g_EntTeleportAutoComplete, "Teleport the specified entity to where the player is looking.\n\tFormat: ent_teleport ", FCVAR_CHEAT, &g_EntTeleportAutoComplete); +#else //------------------------------------------------------------------------------ // Purpose: Teleport a specified entity to where the player is looking //------------------------------------------------------------------------------ @@ -7452,6 +8892,7 @@ void CC_Ent_Teleport( const CCommand& args ) } static ConCommand ent_teleport("ent_teleport", CC_Ent_Teleport, "Teleport the specified entity to where the player is looking.\n\tFormat: ent_teleport ", FCVAR_CHEAT); +#endif //------------------------------------------------------------------------------ // Purpose: Orient a specified entity to match the player's angles diff --git a/sp/src/game/server/baseentity.h b/sp/src/game/server/baseentity.h index c5843015..d8b4d367 100644 --- a/sp/src/game/server/baseentity.h +++ b/sp/src/game/server/baseentity.h @@ -663,11 +663,71 @@ public: void InputDisableShadow( inputdata_t &inputdata ); void InputEnableShadow( inputdata_t &inputdata ); void InputAddOutput( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputChangeVariable( inputdata_t &inputdata ); +#endif void InputFireUser1( inputdata_t &inputdata ); void InputFireUser2( inputdata_t &inputdata ); void InputFireUser3( inputdata_t &inputdata ); void InputFireUser4( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputPassUser1( inputdata_t &inputdata ); + void InputPassUser2( inputdata_t &inputdata ); + void InputPassUser3( inputdata_t &inputdata ); + void InputPassUser4( inputdata_t &inputdata ); + + void InputFireRandomUser( inputdata_t &inputdata ); + void InputPassRandomUser( inputdata_t &inputdata ); + + virtual void InputSetTarget( inputdata_t &inputdata ); + virtual void InputSetOwnerEntity( inputdata_t &inputdata ); + + virtual void InputAddHealth( inputdata_t &inputdata ); + virtual void InputRemoveHealth( inputdata_t &inputdata ); + virtual void InputSetHealth( inputdata_t &inputdata ); + + virtual void InputSetMaxHealth( inputdata_t &inputdata ); + + void InputFireOutput( inputdata_t &inputdata ); + void InputRemoveOutput( inputdata_t &inputdata ); + //virtual void InputCancelOutput( inputdata_t &inputdata ); // Find a way to implement this + void InputReplaceOutput( inputdata_t &inputdata ); + void InputAcceptInput( inputdata_t &inputdata ); + virtual void InputCancelPending( inputdata_t &inputdata ); + + void InputFreeChildren( inputdata_t &inputdata ); + + void InputSetLocalOrigin( inputdata_t &inputdata ); + void InputSetLocalAngles( inputdata_t &inputdata ); + void InputSetLocalVelocity( inputdata_t &inputdata ); + void InputSetLocalAngularVelocity( inputdata_t &inputdata ); + + void InputAddSpawnFlags( inputdata_t &inputdata ); + void InputRemoveSpawnFlags( inputdata_t &inputdata ); + void InputSetRenderMode( inputdata_t &inputdata ); + void InputSetRenderFX( inputdata_t &inputdata ); + void InputAddEffects( inputdata_t &inputdata ); + void InputRemoveEffects( inputdata_t &inputdata ); + void InputDrawEntity( inputdata_t &inputdata ); + void InputUndrawEntity( inputdata_t &inputdata ); + void InputAddEFlags( inputdata_t &inputdata ); + void InputRemoveEFlags( inputdata_t &inputdata ); + void InputSetMoveType( inputdata_t &inputdata ); + void InputSetCollisionGroup( inputdata_t &inputdata ); + + void InputTouch( inputdata_t &inputdata ); + + virtual void InputKilledNPC( inputdata_t &inputdata ); + + void InputKillIfNotVisible( inputdata_t &inputdata ); + void InputKillWhenNotVisible( inputdata_t &inputdata ); + + void InputSetThinkNull( inputdata_t &inputdata ); + + COutputEvent m_OnKilled; +#endif + // Returns the origin at which to play an inputted dispatcheffect virtual void GetInputDispatchEffectPosition( const char *sInputString, Vector &pOrigin, QAngle &pAngles ); @@ -841,12 +901,28 @@ protected: #endif void RemoveExpiredConcepts( void ); +#ifdef MAPBASE + // Some new code needs to access these functions from outside of the class. +public: +#endif int GetContextCount() const; // Call RemoveExpiredConcepts to clean out expired concepts const char *GetContextName( int index ) const; // note: context may be expired const char *GetContextValue( int index ) const; // note: context may be expired bool ContextExpired( int index ) const; int FindContextByName( const char *name ) const; +#ifndef MAPBASE public: +#endif + +#ifdef MAPBASE + bool HasContext( const char *name, const char *value ) const; + bool HasContext( string_t name, string_t value ) const; // NOTE: string_t version only compares pointers! + bool HasContext( const char *nameandvalue ) const; + const char *GetContextValue( const char *contextName ) const; + void RemoveContext( const char *nameandvalue ); + void AddContext( const char *name, const char *value, float duration = 0.0f ); +#endif + void AddContext( const char *nameandvalue ); protected: @@ -891,6 +967,12 @@ public: // Call this to do a TraceAttack on an entity, performs filtering. Don't call TraceAttack() directly except when chaining up to base class void DispatchTraceAttack( const CTakeDamageInfo &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator = NULL ); virtual bool PassesDamageFilter( const CTakeDamageInfo &info ); +#ifdef MAPBASE + // Special filter functions made for the "damage" family of filters, including filter_damage_transfer. + bool PassesFinalDamageFilter( const CTakeDamageInfo &info ); + bool DamageFilterAllowsBlood( const CTakeDamageInfo &info ); + bool DamageFilterDamageMod( CTakeDamageInfo &info ); +#endif protected: @@ -1049,6 +1131,10 @@ public: void SUB_CallUseToggle( void ) { this->Use( this, this, USE_TOGGLE, 0 ); } void SUB_PerformFadeOut( void ); virtual bool SUB_AllowedToFade( void ); +#ifdef MAPBASE + // For KillWhenNotVisible + void SUB_RemoveWhenNotVisible( void ); +#endif // change position, velocity, orientation instantly // passing NULL means no change @@ -1128,6 +1214,9 @@ public: #endif virtual void ModifyOrAppendCriteria( AI_CriteriaSet& set ); void AppendContextToCriteria( AI_CriteriaSet& set, const char *prefix = "" ); +#ifdef MAPBASE + void ReAppendContextCriteria( AI_CriteriaSet& set ); +#endif void DumpResponseCriteria( void ); private: @@ -1448,6 +1537,11 @@ public: // Callbacks for the physgun/cannon picking up an entity virtual CBasePlayer *HasPhysicsAttacker( float dt ) { return NULL; } +#ifdef MAPBASE + // This function needed to be extended to phys_magnet and I didn't like the dynamic_casts. + virtual bool CanBePickedUpByPhyscannon() { return false; } +#endif + // UNDONE: Make this data? virtual unsigned int PhysicsSolidMaskForEntity( void ) const; @@ -1686,6 +1780,12 @@ private: CNetworkVar( bool, m_bAlternateSorting ); // User outputs. Fired when the "FireInputX" input is triggered. +#ifdef MAPBASE + COutputVariant m_OutUser1; + COutputVariant m_OutUser2; + COutputVariant m_OutUser3; + COutputVariant m_OutUser4; +#endif COutputEvent m_OnUser1; COutputEvent m_OnUser2; COutputEvent m_OnUser3; diff --git a/sp/src/game/server/bmodels.cpp b/sp/src/game/server/bmodels.cpp index 71be7d39..949e0940 100644 --- a/sp/src/game/server/bmodels.cpp +++ b/sp/src/game/server/bmodels.cpp @@ -962,6 +962,18 @@ void CFuncRotating::UpdateSpeed( float flNewSpeed ) RampPitchVol(); } +#ifdef MAPBASE + QAngle angNormalizedAngles = GetLocalAngles(); + if (m_vecMoveAng.x) + angNormalizedAngles.x = AngleNormalize( angNormalizedAngles.x ); + if (m_vecMoveAng.y) + angNormalizedAngles.y = AngleNormalize( angNormalizedAngles.y ); + if (m_vecMoveAng.z) + angNormalizedAngles.z = AngleNormalize( angNormalizedAngles.z ); + + SetLocalAngles(angNormalizedAngles); +#endif + SetLocalAngularVelocity( m_vecMoveAng * m_flSpeed ); } @@ -1394,7 +1406,11 @@ BEGIN_DATADESC( CFuncVPhysicsClip ) // Keyfields DEFINE_KEYFIELD( m_iFilterName, FIELD_STRING, "filtername" ), DEFINE_FIELD( m_hFilter, FIELD_EHANDLE ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bDisabled, FIELD_BOOLEAN, "StartDisabled" ), +#else DEFINE_FIELD( m_bDisabled, FIELD_BOOLEAN ), +#endif DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), @@ -1440,6 +1456,12 @@ bool CFuncVPhysicsClip::EntityPassesFilter( CBaseEntity *pOther ) if ( pFilter ) return pFilter->PassesFilter( this, pOther ); +#ifdef MAPBASE + // I couldn't figure out what else made this crash. The entity shouldn't be NULL. + if ( !pOther->VPhysicsGetObject() ) + return false; +#endif + if ( pOther->GetMoveType() == MOVETYPE_VPHYSICS && pOther->VPhysicsGetObject()->IsMoveable() ) return true; diff --git a/sp/src/game/server/buttons.cpp b/sp/src/game/server/buttons.cpp index af46d0c4..47472d43 100644 --- a/sp/src/game/server/buttons.cpp +++ b/sp/src/game/server/buttons.cpp @@ -898,6 +898,13 @@ void CRotButton::Spawn( void ) SetUse(&CRotButton::ButtonUse); +#ifdef MAPBASE + if (HasSpawnFlags(SF_BUTTON_LOCKED)) + { + m_bLocked = true; + } +#endif + // // If touching activates the button, set its touch function. // diff --git a/sp/src/game/server/cbase.cpp b/sp/src/game/server/cbase.cpp index 19dd3ac2..9f4cee80 100644 --- a/sp/src/game/server/cbase.cpp +++ b/sp/src/game/server/cbase.cpp @@ -84,6 +84,10 @@ OUTPUTS: #include "tier1/strtools.h" #include "datacache/imdlcache.h" #include "env_debughistory.h" +#ifdef MAPBASE +#include "mapbase/variant_tools.h" +#include "mapbase/matchers.h" +#endif #include "tier0/vprof.h" @@ -272,7 +276,12 @@ void CBaseEntityOutput::FireOutput(variant_t Value, CBaseEntity *pActivator, CBa // variant_t ValueOverride; ValueOverride.SetString( ev->m_iParameter ); +#ifdef MAPBASE + // I found this while making point_advanced_finder. FireOutput()'s own delay parameter doesn't work with...uh...parameters. + g_EventQueue.AddEvent( STRING(ev->m_iTarget), STRING(ev->m_iTargetInput), ValueOverride, ev->m_flDelay + fDelay, pActivator, pCaller, ev->m_iIDStamp ); +#else g_EventQueue.AddEvent( STRING(ev->m_iTarget), STRING(ev->m_iTargetInput), ValueOverride, ev->m_flDelay, pActivator, pCaller, ev->m_iIDStamp ); +#endif } if ( ev->m_flDelay ) @@ -922,6 +931,72 @@ void CEventQueue::ServiceEvents( void ) { // In the context the event, the searching entity is also the caller CBaseEntity *pSearchingEntity = pe->m_pCaller; +#ifdef MAPBASE + //=============================================================== + // + // This is the code that the I/O system uses to look for its targets. + // + // I wanted a good way to access a COutputEHANDLE's handle parameter. + // Sure, you could do it through logic_register_activator, but what if that's not good enough? + // + // Basic gEntList searches, which this originally used, would require extra implementation for another entity pointer to be passed. + // Without changing the way entity searching works, I just created a custom version of it here. + // + // Yes, all of this for mere "!output" support. + // + // I don't think there's much harm in this anyway. It's functionally identical and might even run a few nanoseconds faster + // since we don't need to check for filters or call the same loop over and over again. + // + //=============================================================== + const char *szName = STRING(pe->m_iTarget); + if ( szName[0] == '!' ) + { + CBaseEntity *target = gEntList.FindEntityProcedural( szName, pSearchingEntity, pe->m_pActivator, pe->m_pCaller ); + + if (!target) + { + // Here's the !output I was talking about. + // It only checks for it if we're looking for a procedural entity ('!' confirmed) + // and we didn't find one from FindEntityProcedural. + if (FStrEq(szName, "!output")) + { + pe->m_VariantValue.Convert( FIELD_EHANDLE ); + target = pe->m_VariantValue.Entity(); + } + } + + if (target) + { + // pump the action into the target + target->AcceptInput( STRING(pe->m_iTargetInput), pe->m_pActivator, pe->m_pCaller, pe->m_VariantValue, pe->m_iOutputID ); + targetFound = true; + } + } + else + { + const CEntInfo *pInfo = gEntList.FirstEntInfo(); + + for ( ;pInfo; pInfo = pInfo->m_pNext ) + { + CBaseEntity *ent = (CBaseEntity *)pInfo->m_pEntity; + if ( !ent ) + { + DevWarning( "NULL entity in global entity list!\n" ); + continue; + } + + if ( !ent->GetEntityName() ) + continue; + + if ( ent->NameMatches( szName ) ) + { + // pump the action into the target + ent->AcceptInput( STRING(pe->m_iTargetInput), pe->m_pActivator, pe->m_pCaller, pe->m_VariantValue, pe->m_iOutputID ); + targetFound = true; + } + } + } +#else CBaseEntity *target = NULL; while ( 1 ) { @@ -933,6 +1008,7 @@ void CEventQueue::ServiceEvents( void ) target->AcceptInput( STRING(pe->m_iTargetInput), pe->m_pActivator, pe->m_pCaller, pe->m_VariantValue, pe->m_iOutputID ); targetFound = true; } +#endif } // direct pointer @@ -1252,6 +1328,23 @@ void variant_t::Set( fieldtype_t ftype, void *data ) break; } +#ifdef MAPBASE + // There's this output class called COutputVariant which could output any data type, like a FIELD_INPUT input function. + // Well...nobody added support for it. It was there, but it wasn't functional. + // Mapbase adds support for it so you could variant your outputs as you please. + case FIELD_INPUT: + { + variant_t *variant = (variant_t*)data; + + // Pretty much just copying over its stored value. + fieldType = variant->FieldType(); + variant->SetOther(data); + + Set(fieldType, data); + break; + } +#endif + case FIELD_EHANDLE: eVal = *((EHANDLE *)data); break; case FIELD_CLASSPTR: eVal = *((CBaseEntity **)data); break; case FIELD_VOID: @@ -1292,6 +1385,10 @@ void variant_t::SetOther( void *data ) } } +#ifdef MAPBASE +// This way we don't have to use string comparisons when reading failed conversions +static const char *g_szNoConversion = "No conversion to string"; +#endif //----------------------------------------------------------------------------- // Purpose: Converts the variant to a new type. This function defines which I/O @@ -1324,6 +1421,24 @@ bool variant_t::Convert( fieldtype_t newType ) return true; } +#ifdef MAPBASE + if (newType == FIELD_STRING) + { + // I got a conversion error when I tried to convert int to string. I'm actually quite baffled. + // Was that case really not handled before? Did I do something that overrode something that already did this? + const char *szString = ToString(); + + // g_szNoConversion is returned in ToString() when we can't convert to a string, + // so this is safe and it lets us get away with a pointer comparison. + if (szString != g_szNoConversion) + { + SetString(AllocPooledString(szString)); + return true; + } + return false; + } +#endif + switch ( fieldType ) { case FIELD_INTEGER: @@ -1441,8 +1556,14 @@ bool variant_t::Convert( fieldtype_t newType ) CBaseEntity *ent = NULL; if ( iszVal != NULL_STRING ) { +#ifdef MAPBASE + // We search by both entity name and class name now. + // We also have an entirely new version of Convert specifically for !activators on FIELD_EHANDLE. + ent = gEntList.FindEntityGeneric( NULL, STRING(iszVal) ); +#else // FIXME: do we need to pass an activator in here? ent = gEntList.FindEntityByName( NULL, iszVal ); +#endif } SetEntity( ent ); return true; @@ -1452,6 +1573,7 @@ bool variant_t::Convert( fieldtype_t newType ) break; } +#ifndef MAPBASE // ToString() above handles this case FIELD_EHANDLE: { switch ( newType ) @@ -1469,12 +1591,64 @@ bool variant_t::Convert( fieldtype_t newType ) } break; } +#endif + +#ifdef MAPBASE + case FIELD_VOID: + { + // Many fields already turn into some equivalent of "NULL" when given a null string_t. + // This takes advantage of that and allows FIELD_VOID to be converted to more than just empty strings. + SetString(NULL_STRING); + return Convert(newType); + } +#endif } // invalid conversion return false; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Only for when something like !activator needs to become a FIELD_EHANDLE, or when that's a possibility. +//----------------------------------------------------------------------------- +bool variant_t::Convert( fieldtype_t newType, CBaseEntity *pSelf, CBaseEntity *pActivator, CBaseEntity *pCaller ) +{ + // Support for turning !activator, !caller, and !self into a FIELD_EHANDLE. + // Extremely necessary. + if (newType == FIELD_EHANDLE) + { + if (newType == fieldType) + return true; + + CBaseEntity *ent = NULL; + if (iszVal != NULL_STRING) + { + ent = gEntList.FindEntityGeneric(NULL, STRING(iszVal), pSelf, pActivator, pCaller); + } + SetEntity(ent); + return true; + } + +#if 0 // This was scrapped almost immediately. See the Trello card for details. + // Serves as a way of converting the name of the !activator, !caller, or !self into a string + // without passing the text "!activator" and stuff. + else if (fieldType == FIELD_STRING && STRING(iszVal)[0] == '&') + { + const char *val = STRING(iszVal) + 1; + + #define GetRealName(string, ent) if (FStrEq(val, string)) { if (ent) {SetString(ent->GetEntityName());} return true; } + + GetRealName("!activator", pActivator) + else GetRealName("!caller", pCaller) + else GetRealName("!self", pSelf) + } +#endif + + return Convert(newType); +} +#endif + //----------------------------------------------------------------------------- // Purpose: All types must be able to display as strings for debugging purposes. @@ -1542,13 +1716,22 @@ const char *variant_t::ToString( void ) const case FIELD_EHANDLE: { +#ifdef MAPBASE + // This is a really bad idea. + const char *pszName = (Entity()) ? Entity()->GetDebugName() : "<>"; +#else const char *pszName = (Entity()) ? STRING(Entity()->GetEntityName()) : "<>"; +#endif Q_strncpy( szBuf, pszName, 512 ); return (szBuf); } } +#ifdef MAPBASE + return g_szNoConversion; +#else return("No conversion to string"); +#endif } #define classNameTypedef variant_t // to satisfy DEFINE... macros @@ -1756,6 +1939,21 @@ class CVariantSaveDataOps : public CDefSaveRestoreOps // Don't no how to. This is okay, since objects of this type // are always born clean before restore, and not reused } + +#ifdef MAPBASE + // Parses a keyvalue string into a variant_t. + // We could just turn it into a string since variant_t can convert it later, but this keyvalue is probably a variant_t for a reason, + // meaning it might use strings and numbers completely differently without converting them. + // As a result, we try to read it to figure out what type it is. + virtual bool Parse( const SaveRestoreFieldInfo_t &fieldInfo, char const* szValue ) + { + variant_t *var = (variant_t*)fieldInfo.pField; + + *var = Variant_Parse(szValue); + + return true; + } +#endif }; CVariantSaveDataOps g_VariantSaveDataOps; diff --git a/sp/src/game/server/effects.cpp b/sp/src/game/server/effects.cpp index f9d457c6..cb1b51b4 100644 --- a/sp/src/game/server/effects.cpp +++ b/sp/src/game/server/effects.cpp @@ -29,11 +29,19 @@ #include "Sprite.h" #include "precipitation_shared.h" #include "shot_manipulator.h" +#ifdef MAPBASE +#include "point_template.h" +#include "TemplateEntities.h" +#include "mapentities_shared.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" #define SF_FUNNEL_REVERSE 1 // funnel effect repels particles instead of attracting them. +#ifdef MAPBASE +#define SF_FUNNEL_DONT_REMOVE 2 +#endif #define SF_GIBSHOOTER_REPEATABLE (1<<0) // allows a gibshooter to be refired #define SF_SHOOTER_FLAMING (1<<1) // gib is on fire @@ -536,7 +544,11 @@ CBaseEntity *CGibShooter::SpawnGib( const Vector &vecShootDir, float flSpeed ) { // UNDONE: Assume a mass of 200 for now Vector force = vecShootDir * flSpeed * 200; +#ifdef MAPBASE + return CreateRagGib( STRING( GetModelName() ), GetAbsOrigin(), GetAbsAngles(), force, m_flGibLife, HasSpawnFlags(SF_SHOOTER_FLAMING) ); +#else return CreateRagGib( STRING( GetModelName() ), GetAbsOrigin(), GetAbsAngles(), force, m_flGibLife ); +#endif } case GIB_SIMULATE_PHYSICS: @@ -1246,6 +1258,10 @@ public: void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); int m_iSprite; // Don't save, precache +#ifdef MAPBASE + // This unfortunately doesn't work with the way the effect is set up + //string_t m_iszSprite; +#endif }; LINK_ENTITY_TO_CLASS( env_funnel, CEnvFunnel ); @@ -1255,6 +1271,10 @@ LINK_ENTITY_TO_CLASS( env_funnel, CEnvFunnel ); //--------------------------------------------------------- BEGIN_DATADESC( CEnvFunnel ) +#ifdef MAPBASE + //DEFINE_KEYFIELD( m_iszSprite, FIELD_STRING, "Sprite" ), + DEFINE_INPUTFUNC( FIELD_VOID, "Activate", InputUse ), +#endif // DEFINE_FIELD( m_iSprite, FIELD_INTEGER ), END_DATADESC() @@ -1263,7 +1283,15 @@ END_DATADESC() void CEnvFunnel::Precache ( void ) { +#ifdef MAPBASE + //if (m_iszSprite == NULL_STRING) + // m_iszSprite = AllocPooledString("sprites/flare6.vmt"); + + //m_iSprite = PrecacheModel(STRING(m_iszSprite)); m_iSprite = PrecacheModel ( "sprites/flare6.vmt" ); +#else + m_iSprite = PrecacheModel ( "sprites/flare6.vmt" ); +#endif } void CEnvFunnel::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) @@ -1272,6 +1300,10 @@ void CEnvFunnel::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE us te->LargeFunnel( filter, 0.0, &GetAbsOrigin(), m_iSprite, HasSpawnFlags( SF_FUNNEL_REVERSE ) ? 1 : 0 ); +#ifdef MAPBASE + if (HasSpawnFlags(SF_FUNNEL_DONT_REMOVE)) + return; +#endif SetThink( &CEnvFunnel::SUB_Remove ); SetNextThink( gpGlobals->curtime ); } @@ -1472,6 +1504,12 @@ void CItemSoda::CanTouch ( CBaseEntity *pOther ) // technology demo //========================================================= +#ifdef MAPBASE +// I would leave this on the client, but it sems as if I could only precache the particle system on the server for some reason. +// That desn't sound right...look into this further later. +ConVar r_RainParticle( "r_RainParticle", "Rain_01_impact", FCVAR_CHEAT | FCVAR_REPLICATED ); +#endif + class CPrecipitation : public CBaseEntity { public: @@ -1508,6 +1546,9 @@ void CPrecipitation::Spawn( void ) PrecacheMaterial( "effects/fleck_ash2" ); PrecacheMaterial( "effects/fleck_ash3" ); PrecacheMaterial( "effects/ember_swirling001" ); +#ifdef MAPBASE + PrecacheParticleSystem( r_RainParticle.GetString() ); +#endif Precache(); SetSolid( SOLID_NONE ); // Remove model & collisions @@ -1559,6 +1600,10 @@ BEGIN_DATADESC( CEnvWind ) DEFINE_KEYFIELD( m_EnvWindShared.m_iGustDirChange, FIELD_INTEGER, "gustdirchange" ), DEFINE_KEYFIELD( m_EnvWindShared.m_flGustDuration, FIELD_FLOAT, "gustduration" ), // DEFINE_KEYFIELD( m_EnvWindShared.m_iszGustSound, FIELD_STRING, "gustsound" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_EnvWindShared.m_windRadius, FIELD_FLOAT, "windradius" ), + DEFINE_KEYFIELD( m_EnvWindShared.m_windRadiusInner, FIELD_FLOAT, "windradiusinner" ), +#endif // Just here to quiet down classcheck // DEFINE_FIELD( m_EnvWindShared, CEnvWindShared ), @@ -1594,6 +1639,11 @@ BEGIN_SEND_TABLE_NOBASE(CEnvWindShared, DT_EnvWindShared) SendPropFloat (SENDINFO(m_flGustDuration), 0, SPROP_NOSCALE), // Sound related // SendPropInt (SENDINFO(m_iszGustSound), 10, SPROP_UNSIGNED ), +#ifdef MAPBASE + SendPropFloat (SENDINFO(m_windRadius), 0, SPROP_NOSCALE), + SendPropFloat (SENDINFO(m_windRadiusInner), 0, SPROP_NOSCALE), + SendPropVector (SENDINFO(m_location), -1, SPROP_COORD), +#endif END_SEND_TABLE() // This table encodes the CBaseEntity data. @@ -1615,7 +1665,13 @@ void CEnvWind::Spawn( void ) SetSolid( SOLID_NONE ); AddEffects( EF_NODRAW ); +#ifdef MAPBASE + m_EnvWindShared.m_iInitialWindDir = (int)(anglemod( m_EnvWindShared.m_iInitialWindDir )); + m_EnvWindShared.Init( entindex(), 0, gpGlobals->curtime, GetLocalAngles().y, 0 ); + m_EnvWindShared.m_location = GetAbsOrigin(); +#else m_EnvWindShared.Init( entindex(), 0, gpGlobals->frametime, GetLocalAngles().y, 0 ); +#endif SetThink( &CEnvWind::WindThink ); SetNextThink( gpGlobals->curtime ); @@ -2037,6 +2093,10 @@ public: void InputEnable( inputdata_t &inputdata ); void InputDisable( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputFireBurst( inputdata_t &inputdata ); +#endif + int m_iMinBurstSize; int m_iMaxBurstSize; @@ -2062,6 +2122,10 @@ public: EHANDLE m_hTarget; +#ifdef MAPBASE + COutputEvent m_OnFire; +#endif + DECLARE_DATADESC(); }; @@ -2090,6 +2154,11 @@ BEGIN_DATADESC( CEnvGunfire ) DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_INTEGER, "FireBurst", InputFireBurst ), + + DEFINE_OUTPUT( m_OnFire, "OnFire" ), +#endif END_DATADESC() LINK_ENTITY_TO_CLASS( env_gunfire, CEnvGunfire ); @@ -2234,10 +2303,26 @@ void CEnvGunfire::ShootThink() m_iShotsRemaining--; +#ifdef MAPBASE + m_OnFire.FireOutput(m_hTarget, this); +#endif + if( m_iShotsRemaining == 0 ) { +#ifdef MAPBASE + if (m_bDisabled) + { + StopShooting(); + } + else + { + StartShooting(); + SetNextThink( gpGlobals->curtime + random->RandomFloat( m_flMinBurstDelay, m_flMaxBurstDelay ) ); + } +#else StartShooting(); SetNextThink( gpGlobals->curtime + random->RandomFloat( m_flMinBurstDelay, m_flMaxBurstDelay ) ); +#endif } } @@ -2257,6 +2342,18 @@ void CEnvGunfire::InputDisable( inputdata_t &inputdata ) SetThink( NULL ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CEnvGunfire::InputFireBurst( inputdata_t &inputdata ) +{ + m_iShotsRemaining = inputdata.value.Int(); + + SetThink( &CEnvGunfire::ShootThink ); + SetNextThink( gpGlobals->curtime ); +} +#endif + //----------------------------------------------------------------------------- // Quadratic spline beam effect //----------------------------------------------------------------------------- @@ -2377,3 +2474,122 @@ void CEnvViewPunch::InputViewPunch( inputdata_t &inputdata ) { DoViewPunch(); } + +#ifdef MAPBASE +class CBreakableGibShooter : public CBaseEntity +{ + DECLARE_CLASS( CBreakableGibShooter, CBaseEntity ); + DECLARE_DATADESC(); +public: + + const char *GetRandomTemplateModel( CPointTemplate *pTemplate ); + + void Precache( void ); + + void Shoot( void ); + + // ---------------- + // Inputs + // ---------------- + void InputShoot( inputdata_t &inputdata ); + +public: + + int m_iModelType; + enum + { + MODELTYPE_BREAKABLECHUNKS, + MODELTYPE_MODEL, + MODELTYPE_TEMPLATE, + }; + + int m_iCount; + float m_flDelay; + Vector m_vecGibSize; + Vector m_vecGibVelocity; + int m_iRandomization; + float m_flLifetime; + int m_iGibFlags; +}; + +BEGIN_DATADESC( CBreakableGibShooter ) + + DEFINE_KEYFIELD( m_iModelType, FIELD_INTEGER, "modeltype" ), + DEFINE_INPUT( m_iCount, FIELD_INTEGER, "SetCount" ), + DEFINE_INPUT( m_flDelay, FIELD_FLOAT, "SetDelay" ), + DEFINE_INPUT( m_vecGibSize, FIELD_VECTOR, "SetGibSize" ), + DEFINE_INPUT( m_vecGibVelocity, FIELD_VECTOR, "SetGibVelocity" ), + DEFINE_INPUT( m_iRandomization, FIELD_INTEGER, "SetRandomization" ), + DEFINE_INPUT( m_flLifetime, FIELD_FLOAT, "SetLifetime" ), + DEFINE_INPUT( m_iGibFlags, FIELD_INTEGER, "SetGibFlags" ), + + DEFINE_INPUTFUNC( FIELD_VOID, "Shoot", InputShoot ), + +END_DATADESC() + + +LINK_ENTITY_TO_CLASS( env_break_shooter, CBreakableGibShooter ); + + +const char *CBreakableGibShooter::GetRandomTemplateModel( CPointTemplate *pTemplate ) +{ + int iIndex = RandomInt( 0, pTemplate->GetNumTemplates() ); + char *iszTemplate = (char*)(STRING(Templates_FindByIndex(pTemplate->GetTemplateIndexForTemplate(iIndex)))); + + CEntityMapData entData( iszTemplate ); + + // This might seem a little messy, but I think it's cheaper than creating the entity. + char szModel[MAPKEY_MAXLENGTH]; + if (!entData.ExtractValue("model", szModel)) + return NULL; + + return strdup(szModel); +} + +void CBreakableGibShooter::Precache( void ) +{ + if (m_iModelType == MODELTYPE_MODEL) + PrecacheModel( STRING(GetModelName()) ); +} + +void CBreakableGibShooter::Shoot( void ) +{ + int iModelIndex = 0; + if (m_iModelType == MODELTYPE_MODEL) + iModelIndex = modelinfo->GetModelIndex( STRING(GetModelName()) ); + + CPointTemplate *pTemplate = NULL; + if (m_iModelType == MODELTYPE_TEMPLATE) + { + pTemplate = dynamic_cast(gEntList.FindEntityByName(NULL, STRING(GetModelName()), this)); + if (!pTemplate) + { + Warning("%s cannot find point_template %s!\n", GetDebugName(), STRING(GetModelName())); + return; + } + } + + CPVSFilter filter( GetAbsOrigin() ); + for ( int i = 0; i < m_iCount; i++ ) + { + if (m_iModelType == MODELTYPE_BREAKABLECHUNKS) + iModelIndex = modelinfo->GetModelIndex( g_PropDataSystem.GetRandomChunkModel( STRING( GetModelName() ) ) ); + else if (m_iModelType == MODELTYPE_TEMPLATE) + iModelIndex = modelinfo->GetModelIndex( GetRandomTemplateModel(pTemplate) ); + + // All objects except the first one in this run are marked as slaves... + int slaveFlag = 0; + if ( i != 0 ) + { + slaveFlag = BREAK_SLAVE; + } + + te->BreakModel( filter, m_flDelay, GetAbsOrigin(), GetAbsAngles(), m_vecGibSize, m_vecGibVelocity, iModelIndex, m_iRandomization, 1, m_flLifetime, m_iGibFlags | slaveFlag ); + } +} + +void CBreakableGibShooter::InputShoot( inputdata_t &inputdata ) +{ + Shoot(); +} +#endif diff --git a/sp/src/game/server/entitylist.cpp b/sp/src/game/server/entitylist.cpp index 6244fa7d..74135391 100644 --- a/sp/src/game/server/entitylist.cpp +++ b/sp/src/game/server/entitylist.cpp @@ -20,6 +20,9 @@ #ifdef HL2_DLL #include "npc_playercompanion.h" +#ifdef MAPBASE +#include "hl2_player.h" +#endif #endif // HL2_DLL // memdbgon must be the last include file in a .cpp file!!! @@ -479,7 +482,11 @@ bool CGlobalEntityList::IsEntityPtr( void *pTest ) // Input : pStartEntity - Last entity found, NULL to start a new iteration. // szName - Classname to search for. //----------------------------------------------------------------------------- +#ifdef MAPBASE +CBaseEntity *CGlobalEntityList::FindEntityByClassname( CBaseEntity *pStartEntity, const char *szName, IEntityFindFilter *pFilter ) +#else CBaseEntity *CGlobalEntityList::FindEntityByClassname( CBaseEntity *pStartEntity, const char *szName ) +#endif { const CEntInfo *pInfo = pStartEntity ? GetEntInfoPtr( pStartEntity->GetRefEHandle() )->m_pNext : FirstEntInfo(); @@ -492,8 +499,18 @@ CBaseEntity *CGlobalEntityList::FindEntityByClassname( CBaseEntity *pStartEntity continue; } +#ifdef MAPBASE + if ( pEntity->ClassMatches(szName) ) + { + if ( pFilter && !pFilter->ShouldFindEntity(pEntity) ) + continue; + + return pEntity; + } +#else if ( pEntity->ClassMatches(szName) ) return pEntity; +#endif } return NULL; @@ -551,12 +568,60 @@ CBaseEntity *CGlobalEntityList::FindEntityProcedural( const char *szName, CBaseE } else if ( FStrEq( pName, "picker" ) ) { +#ifdef MAPBASE_MP + // TODO: Player could be activator instead + CBasePlayer *pPlayer = ToBasePlayer(pSearchingEntity); + return FindPickerEntity( pPlayer ? pPlayer : UTIL_PlayerByIndex(1) ); +#else return FindPickerEntity( UTIL_PlayerByIndex(1) ); +#endif } else if ( FStrEq( pName, "self" ) ) { return pSearchingEntity; } +#ifdef MAPBASE + else if ( FStrEq( pName, "parent" ) ) + { + return pSearchingEntity ? pSearchingEntity->GetParent() : NULL; + } + else if ( FStrEq( pName, "owner" ) ) + { + return pSearchingEntity ? pSearchingEntity->GetOwnerEntity() : NULL; + } + else if ( FStrEq( pName, "plrsquadrep" ) ) + { +#ifdef HL2_DLL + CHL2_Player *pPlayer = static_cast(UTIL_PlayerByIndex(1)); + if (pPlayer) + { + return pPlayer->GetSquadCommandRepresentative(); + } +#endif + } + else if (strchr(pName, ':')) + { + char name[128]; + Q_strncpy(name, pName, strchr(pName, ':')-pName+1); + + CBaseEntity *pEntity = FindEntityProcedural(UTIL_VarArgs("!%s", name), pSearchingEntity, pActivator, pCaller); + if (pEntity && pEntity->IsNPC()) + { + char *target = (Q_strstr(pName, ":") + 1); + if (target[0] != '!') + target = UTIL_VarArgs("!%s", target); + + return pEntity->MyNPCPointer()->FindNamedEntity(target); + } + } + else if (pSearchingEntity && pSearchingEntity->IsCombatCharacter()) + { + // Perhaps the entity itself has the answer? + // This opens up new possibilities. The weird filter is there so it doesn't go through this twice. + CNullEntityFilter pFilter; + return pSearchingEntity->MyCombatCharacterPointer()->FindNamedEntity(szName, &pFilter); + } +#endif else { Warning( "Invalid entity search name %s\n", szName ); @@ -917,6 +982,20 @@ CBaseEntity *CGlobalEntityList::FindEntityByClassnameWithin( CBaseEntity *pStart // or Use handler, NULL otherwise. // Output : Returns a pointer to the found entity, NULL if none. //----------------------------------------------------------------------------- +#ifdef MAPBASE +CBaseEntity *CGlobalEntityList::FindEntityGeneric( CBaseEntity *pStartEntity, const char *szName, CBaseEntity *pSearchingEntity, CBaseEntity *pActivator, CBaseEntity *pCaller, IEntityFindFilter *pFilter ) +{ + CBaseEntity *pEntity = NULL; + + pEntity = gEntList.FindEntityByName( pStartEntity, szName, pSearchingEntity, pActivator, pCaller, pFilter ); + if (!pEntity) + { + pEntity = gEntList.FindEntityByClassname( pStartEntity, szName, pFilter ); + } + + return pEntity; +} +#else CBaseEntity *CGlobalEntityList::FindEntityGeneric( CBaseEntity *pStartEntity, const char *szName, CBaseEntity *pSearchingEntity, CBaseEntity *pActivator, CBaseEntity *pCaller ) { CBaseEntity *pEntity = NULL; @@ -929,6 +1008,7 @@ CBaseEntity *CGlobalEntityList::FindEntityGeneric( CBaseEntity *pStartEntity, co return pEntity; } +#endif //----------------------------------------------------------------------------- diff --git a/sp/src/game/server/entitylist.h b/sp/src/game/server/entitylist.h index bd9412c5..505b1968 100644 --- a/sp/src/game/server/entitylist.h +++ b/sp/src/game/server/entitylist.h @@ -66,6 +66,16 @@ public: virtual CBaseEntity *GetFilterResult( void ) = 0; }; +#ifdef MAPBASE +// Returns false every time. Created for some sick hack involving FindEntityProcedural looking at FindNamedEntity. +class CNullEntityFilter : public IEntityFindFilter +{ +public: + virtual bool ShouldFindEntity( CBaseEntity *pEntity ) { return false; } + virtual CBaseEntity *GetFilterResult( void ) { return NULL; } +}; +#endif + //----------------------------------------------------------------------------- // Purpose: a global list of all the entities in the game. All iteration through // entities is done through this object. @@ -133,7 +143,11 @@ public: // search functions bool IsEntityPtr( void *pTest ); +#ifdef MAPBASE + CBaseEntity *FindEntityByClassname( CBaseEntity *pStartEntity, const char *szName, IEntityFindFilter *pFilter = NULL ); +#else CBaseEntity *FindEntityByClassname( CBaseEntity *pStartEntity, const char *szName ); +#endif CBaseEntity *FindEntityByName( CBaseEntity *pStartEntity, const char *szName, CBaseEntity *pSearchingEntity = NULL, CBaseEntity *pActivator = NULL, CBaseEntity *pCaller = NULL, IEntityFindFilter *pFilter = NULL ); CBaseEntity *FindEntityByName( CBaseEntity *pStartEntity, string_t iszName, CBaseEntity *pSearchingEntity = NULL, CBaseEntity *pActivator = NULL, CBaseEntity *pCaller = NULL, IEntityFindFilter *pFilter = NULL ) { @@ -149,7 +163,11 @@ public: CBaseEntity *FindEntityByClassnameWithin( CBaseEntity *pStartEntity , const char *szName, const Vector &vecSrc, float flRadius ); CBaseEntity *FindEntityByClassnameWithin( CBaseEntity *pStartEntity , const char *szName, const Vector &vecMins, const Vector &vecMaxs ); +#ifdef MAPBASE + CBaseEntity *FindEntityGeneric( CBaseEntity *pStartEntity, const char *szName, CBaseEntity *pSearchingEntity = NULL, CBaseEntity *pActivator = NULL, CBaseEntity *pCaller = NULL, IEntityFindFilter *pFilter = NULL ); +#else CBaseEntity *FindEntityGeneric( CBaseEntity *pStartEntity, const char *szName, CBaseEntity *pSearchingEntity = NULL, CBaseEntity *pActivator = NULL, CBaseEntity *pCaller = NULL ); +#endif CBaseEntity *FindEntityGenericWithin( CBaseEntity *pStartEntity, const char *szName, const Vector &vecSrc, float flRadius, CBaseEntity *pSearchingEntity = NULL, CBaseEntity *pActivator = NULL, CBaseEntity *pCaller = NULL ); CBaseEntity *FindEntityGenericNearest( const char *szName, const Vector &vecSrc, float flRadius, CBaseEntity *pSearchingEntity = NULL, CBaseEntity *pActivator = NULL, CBaseEntity *pCaller = NULL ); diff --git a/sp/src/game/server/entityoutput.h b/sp/src/game/server/entityoutput.h index 6aeb7380..6aa36b84 100644 --- a/sp/src/game/server/entityoutput.h +++ b/sp/src/game/server/entityoutput.h @@ -78,6 +78,12 @@ public: /// Delete every single action in the action list. void DeleteAllElements( void ) ; +#ifdef MAPBASE + // Needed for ReplaceOutput, hopefully not bad + CEventAction *GetActionList() { return m_ActionList; } + void SetActionList(CEventAction *newlist) { m_ActionList = newlist; } +#endif + protected: variant_t m_Value; CEventAction *m_ActionList; diff --git a/sp/src/game/server/env_entity_maker.cpp b/sp/src/game/server/env_entity_maker.cpp index d8ad528e..cbbf1b0a 100644 --- a/sp/src/game/server/env_entity_maker.cpp +++ b/sp/src/game/server/env_entity_maker.cpp @@ -38,6 +38,10 @@ public: void CheckSpawnThink( void ); void InputForceSpawn( inputdata_t &inputdata ); void InputForceSpawnAtEntityOrigin( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputForceSpawnAtEntityCenter( inputdata_t &inputdata ); + void InputForceSpawnAtPosition( inputdata_t &inputdata ); +#endif private: @@ -62,6 +66,9 @@ private: COutputEvent m_pOutputOnSpawned; COutputEvent m_pOutputOnFailedSpawn; +#ifdef MAPBASE + COutputEHANDLE m_pOutputOutEntity; +#endif }; BEGIN_DATADESC( CEnvEntityMaker ) @@ -79,10 +86,17 @@ BEGIN_DATADESC( CEnvEntityMaker ) // Outputs DEFINE_OUTPUT( m_pOutputOnSpawned, "OnEntitySpawned" ), DEFINE_OUTPUT( m_pOutputOnFailedSpawn, "OnEntityFailedSpawn" ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_pOutputOutEntity, "OutSpawnedEntity" ), +#endif // Inputs DEFINE_INPUTFUNC( FIELD_VOID, "ForceSpawn", InputForceSpawn ), DEFINE_INPUTFUNC( FIELD_STRING, "ForceSpawnAtEntityOrigin", InputForceSpawnAtEntityOrigin ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_STRING, "ForceSpawnAtEntityCenter", InputForceSpawnAtEntityCenter ), + DEFINE_INPUTFUNC( FIELD_VECTOR, "ForceSpawnAtPosition", InputForceSpawnAtPosition ), +#endif // Functions DEFINE_THINKFUNC( CheckSpawnThink ), @@ -201,6 +215,11 @@ void CEnvEntityMaker::SpawnEntity( Vector vecAlternateOrigin, QAngle vecAlternat for ( int i = 0; i < hNewEntities.Count(); i++ ) { CBaseEntity *pEntity = hNewEntities[i]; + +#ifdef MAPBASE + m_pOutputOutEntity.Set(pEntity, pEntity, this); +#endif + if ( pEntity->GetMoveType() == MOVETYPE_NONE ) continue; @@ -238,6 +257,15 @@ void CEnvEntityMaker::SpawnEntity( Vector vecAlternateOrigin, QAngle vecAlternat } } } +#ifdef MAPBASE + else + { + for ( int i = 0; i < hNewEntities.Count(); i++ ) + { + m_pOutputOutEntity.Set(hNewEntities[i], hNewEntities[i], this); + } + } +#endif } @@ -364,3 +392,30 @@ void CEnvEntityMaker::InputForceSpawnAtEntityOrigin( inputdata_t &inputdata ) SpawnEntity( pTargetEntity->GetAbsOrigin(), pTargetEntity->GetAbsAngles() ); } } + +#ifdef MAPBASE +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CEnvEntityMaker::InputForceSpawnAtEntityCenter( inputdata_t &inputdata ) +{ + CBaseEntity *pTargetEntity = gEntList.FindEntityByName( NULL, inputdata.value.String(), this, inputdata.pActivator, inputdata.pCaller ); + + if( pTargetEntity ) + { + SpawnEntity( pTargetEntity->WorldSpaceCenter(), pTargetEntity->GetAbsAngles() ); + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CEnvEntityMaker::InputForceSpawnAtPosition(inputdata_t &inputdata) +{ + Vector vecPos; + inputdata.value.Vector3D(vecPos); + if (vecPos != vec3_origin && vecPos.IsValid()) + { + SpawnEntity(vecPos, GetLocalAngles()); + } +} +#endif // MAPBASE + diff --git a/sp/src/game/server/env_global_light.cpp b/sp/src/game/server/env_global_light.cpp new file mode 100644 index 00000000..5ebd520b --- /dev/null +++ b/sp/src/game/server/env_global_light.cpp @@ -0,0 +1,315 @@ +//========= Copyright 1996-2010, Valve Corporation, All rights reserved. ============// +// +// Purpose: global dynamic light. Ported from Insolence's port of Alien Swarm's env_global_light. +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +//------------------------------------------------------------------------------ +// FIXME: This really should inherit from something more lightweight +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +// Purpose : Sunlight shadow control entity +//------------------------------------------------------------------------------ +class CGlobalLight : public CBaseEntity +{ +public: + DECLARE_CLASS( CGlobalLight, CBaseEntity ); + + CGlobalLight(); + + void Spawn( void ); + bool KeyValue( const char *szKeyName, const char *szValue ); + virtual bool GetKeyValue( const char *szKeyName, char *szValue, int iMaxLen ); + int UpdateTransmitState(); + + // Inputs + void InputSetAngles( inputdata_t &inputdata ); + void InputEnable( inputdata_t &inputdata ); + void InputDisable( inputdata_t &inputdata ); + void InputSetTexture( inputdata_t &inputdata ); + void InputSetEnableShadows( inputdata_t &inputdata ); + void InputSetLightColor( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetBrightness( inputdata_t &inputdata ); + void InputSetColorTransitionTime( inputdata_t &inputdata ); +#endif + + virtual int ObjectCaps( void ) { return BaseClass::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + + DECLARE_SERVERCLASS(); + DECLARE_DATADESC(); + +private: + CNetworkVector( m_shadowDirection ); + + CNetworkVar( bool, m_bEnabled ); + bool m_bStartDisabled; + + CNetworkString( m_TextureName, MAX_PATH ); +#ifdef MAPBASE + CNetworkVar( int, m_nSpotlightTextureFrame ); +#endif + CNetworkColor32( m_LightColor ); +#ifdef MAPBASE + CNetworkVar( float, m_flBrightnessScale ); +#endif + CNetworkVar( float, m_flColorTransitionTime ); + CNetworkVar( float, m_flSunDistance ); + CNetworkVar( float, m_flFOV ); + CNetworkVar( float, m_flNearZ ); + CNetworkVar( float, m_flNorthOffset ); +#ifdef MAPBASE + CNetworkVar( float, m_flEastOffset ); // xoffset + CNetworkVar( float, m_flForwardOffset ); // yoffset + CNetworkVar( float, m_flOrthoSize ); +#endif + CNetworkVar( bool, m_bEnableShadows ); +}; + +LINK_ENTITY_TO_CLASS(env_global_light, CGlobalLight); + +BEGIN_DATADESC( CGlobalLight ) + + DEFINE_KEYFIELD( m_bEnabled, FIELD_BOOLEAN, "enabled" ), + DEFINE_KEYFIELD( m_bStartDisabled, FIELD_BOOLEAN, "StartDisabled" ), + DEFINE_AUTO_ARRAY_KEYFIELD( m_TextureName, FIELD_CHARACTER, "texturename" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_nSpotlightTextureFrame, FIELD_INTEGER, "textureframe" ), +#endif + DEFINE_KEYFIELD( m_flSunDistance, FIELD_FLOAT, "distance" ), + DEFINE_KEYFIELD( m_flFOV, FIELD_FLOAT, "fov" ), + DEFINE_KEYFIELD( m_flNearZ, FIELD_FLOAT, "nearz" ), + DEFINE_KEYFIELD( m_flNorthOffset, FIELD_FLOAT, "northoffset" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_flEastOffset, FIELD_FLOAT, "eastoffset" ), + DEFINE_KEYFIELD( m_flForwardOffset, FIELD_FLOAT, "forwardoffset" ), + DEFINE_KEYFIELD( m_flOrthoSize, FIELD_FLOAT, "orthosize" ), +#endif + DEFINE_KEYFIELD( m_bEnableShadows, FIELD_BOOLEAN, "enableshadows" ), + DEFINE_FIELD( m_LightColor, FIELD_COLOR32 ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_flBrightnessScale, FIELD_FLOAT, "brightnessscale" ), +#endif + DEFINE_KEYFIELD( m_flColorTransitionTime, FIELD_FLOAT, "colortransitiontime" ), + + // Inputs + DEFINE_INPUT( m_flSunDistance, FIELD_FLOAT, "SetDistance" ), + DEFINE_INPUT( m_flFOV, FIELD_FLOAT, "SetFOV" ), + DEFINE_INPUT( m_flNearZ, FIELD_FLOAT, "SetNearZDistance" ), + DEFINE_INPUT( m_flNorthOffset, FIELD_FLOAT, "SetNorthOffset" ), +#ifdef MAPBASE + DEFINE_INPUT( m_flEastOffset, FIELD_FLOAT, "SetXOffset" ), + DEFINE_INPUT( m_flForwardOffset, FIELD_FLOAT, "SetYOffset" ), + DEFINE_INPUT( m_flOrthoSize, FIELD_FLOAT, "SetOrthoSize" ), +#endif + + DEFINE_INPUTFUNC( FIELD_COLOR32, "LightColor", InputSetLightColor ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetAngles", InputSetAngles ), + DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), + DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetTexture", InputSetTexture ), + DEFINE_INPUTFUNC( FIELD_BOOLEAN, "EnableShadows", InputSetEnableShadows ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetBrightness", InputSetBrightness ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetColorTransitionTime", InputSetColorTransitionTime ), +#endif + +END_DATADESC() + + +IMPLEMENT_SERVERCLASS_ST_NOBASE(CGlobalLight, DT_GlobalLight) + SendPropVector(SENDINFO(m_shadowDirection), -1, SPROP_NOSCALE ), + SendPropBool(SENDINFO(m_bEnabled) ), + SendPropString(SENDINFO(m_TextureName)), +#ifdef MAPBASE + SendPropInt(SENDINFO(m_nSpotlightTextureFrame)), +#endif + /*SendPropInt(SENDINFO (m_LightColor ), 32, SPROP_UNSIGNED, SendProxy_Color32ToInt32 ),*/ + SendPropInt(SENDINFO (m_LightColor ), 32, SPROP_UNSIGNED, SendProxy_Color32ToInt ), +#ifdef MAPBASE + SendPropFloat( SENDINFO( m_flBrightnessScale ) ), +#endif + SendPropFloat( SENDINFO( m_flColorTransitionTime ) ), + SendPropFloat(SENDINFO(m_flSunDistance), 0, SPROP_NOSCALE ), + SendPropFloat(SENDINFO(m_flFOV), 0, SPROP_NOSCALE ), + SendPropFloat(SENDINFO(m_flNearZ), 0, SPROP_NOSCALE ), + SendPropFloat(SENDINFO(m_flNorthOffset), 0, SPROP_NOSCALE ), +#ifdef MAPBASE + SendPropFloat(SENDINFO(m_flEastOffset), 0, SPROP_NOSCALE ), + SendPropFloat(SENDINFO(m_flForwardOffset), 0, SPROP_NOSCALE ), + SendPropFloat(SENDINFO(m_flOrthoSize), 0, SPROP_NOSCALE ), +#endif + SendPropBool( SENDINFO( m_bEnableShadows ) ), +END_SEND_TABLE() + + +CGlobalLight::CGlobalLight() +{ +#if defined( _X360 ) + Q_strcpy( m_TextureName.GetForModify(), "effects/flashlight_border" ); +#else + Q_strcpy( m_TextureName.GetForModify(), "effects/flashlight001" ); +#endif + m_LightColor.Init( 255, 255, 255, 1 ); + m_flColorTransitionTime = 0.5f; + m_flSunDistance = 10000.0f; + m_flFOV = 5.0f; + m_bEnableShadows = false; +#ifdef MAPBASE + m_nSpotlightTextureFrame = 0; + m_flBrightnessScale = 1.0f; + m_flOrthoSize = 1000.0f; +#endif +} + + +//------------------------------------------------------------------------------ +// Purpose : Send even though we don't have a model +//------------------------------------------------------------------------------ +int CGlobalLight::UpdateTransmitState() +{ + // ALWAYS transmit to all clients. + return SetTransmitState( FL_EDICT_ALWAYS ); +} + + +bool CGlobalLight::KeyValue( const char *szKeyName, const char *szValue ) +{ + if ( FStrEq( szKeyName, "color" ) ) + { + float tmp[4]; + UTIL_StringToFloatArray( tmp, 4, szValue ); + + m_LightColor.SetR( tmp[0] ); + m_LightColor.SetG( tmp[1] ); + m_LightColor.SetB( tmp[2] ); + m_LightColor.SetA( tmp[3] ); + } + else if ( FStrEq( szKeyName, "angles" ) ) + { + QAngle angles; + UTIL_StringToVector( angles.Base(), szValue ); + if (angles == vec3_angle) + { + angles.Init( 80, 30, 0 ); + } + Vector vForward; + AngleVectors( angles, &vForward ); + m_shadowDirection = vForward; + return true; + } + else if ( FStrEq( szKeyName, "texturename" ) ) + { +#if defined( _X360 ) + if ( Q_strcmp( szValue, "effects/flashlight001" ) == 0 ) + { + // Use this as the default for Xbox + Q_strcpy( m_TextureName.GetForModify(), "effects/flashlight_border" ); + } + else + { + Q_strcpy( m_TextureName.GetForModify(), szValue ); + } +#else + Q_strcpy( m_TextureName.GetForModify(), szValue ); +#endif + } + + return BaseClass::KeyValue( szKeyName, szValue ); +} + +bool CGlobalLight::GetKeyValue( const char *szKeyName, char *szValue, int iMaxLen ) +{ + if ( FStrEq( szKeyName, "color" ) ) + { + Q_snprintf( szValue, iMaxLen, "%d %d %d %d", m_LightColor.GetR(), m_LightColor.GetG(), m_LightColor.GetB(), m_LightColor.GetA() ); + return true; + } + else if ( FStrEq( szKeyName, "texturename" ) ) + { + Q_snprintf( szValue, iMaxLen, "%s", m_TextureName.Get() ); + return true; + } + return BaseClass::GetKeyValue( szKeyName, szValue, iMaxLen ); +} + +//------------------------------------------------------------------------------ +// Purpose : +//------------------------------------------------------------------------------ +void CGlobalLight::Spawn( void ) +{ + Precache(); + SetSolid( SOLID_NONE ); + + if( m_bStartDisabled ) + { + m_bEnabled = false; + } + else + { + m_bEnabled = true; + } +} + +//------------------------------------------------------------------------------ +// Input values +//------------------------------------------------------------------------------ +void CGlobalLight::InputSetAngles( inputdata_t &inputdata ) +{ + const char *pAngles = inputdata.value.String(); + + QAngle angles; + UTIL_StringToVector( angles.Base(), pAngles ); + + Vector vTemp; + AngleVectors( angles, &vTemp ); + m_shadowDirection = vTemp; +} + +//------------------------------------------------------------------------------ +// Purpose : Input handlers +//------------------------------------------------------------------------------ +void CGlobalLight::InputEnable( inputdata_t &inputdata ) +{ + m_bEnabled = true; +} + +void CGlobalLight::InputDisable( inputdata_t &inputdata ) +{ + m_bEnabled = false; +} + +void CGlobalLight::InputSetTexture( inputdata_t &inputdata ) +{ + Q_strcpy( m_TextureName.GetForModify(), inputdata.value.String() ); +} + +void CGlobalLight::InputSetEnableShadows( inputdata_t &inputdata ) +{ + m_bEnableShadows = inputdata.value.Bool(); +} + +void CGlobalLight::InputSetLightColor( inputdata_t &inputdata ) +{ + m_LightColor = inputdata.value.Color32(); +} + +#ifdef MAPBASE +void CGlobalLight::InputSetBrightness( inputdata_t &inputdata ) +{ + m_flBrightnessScale = inputdata.value.Float(); +} + +void CGlobalLight::InputSetColorTransitionTime( inputdata_t &inputdata ) +{ + m_flColorTransitionTime = inputdata.value.Float(); +} +#endif diff --git a/sp/src/game/server/env_projectedtexture.cpp b/sp/src/game/server/env_projectedtexture.cpp index 3cdacb40..2f69064f 100644 --- a/sp/src/game/server/env_projectedtexture.cpp +++ b/sp/src/game/server/env_projectedtexture.cpp @@ -6,11 +6,389 @@ #include "cbase.h" #include "shareddefs.h" +#ifdef ASW_PROJECTED_TEXTURES +#include "env_projectedtexture.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" +#ifdef ASW_PROJECTED_TEXTURES + +LINK_ENTITY_TO_CLASS( env_projectedtexture, CEnvProjectedTexture ); + +BEGIN_DATADESC( CEnvProjectedTexture ) + DEFINE_FIELD( m_hTargetEntity, FIELD_EHANDLE ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bDontFollowTarget, FIELD_BOOLEAN, "dontfollowtarget" ), +#endif + DEFINE_FIELD( m_bState, FIELD_BOOLEAN ), + DEFINE_KEYFIELD( m_flLightFOV, FIELD_FLOAT, "lightfov" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_flLightHorFOV, FIELD_FLOAT, "lighthorfov" ), +#endif + DEFINE_KEYFIELD( m_bEnableShadows, FIELD_BOOLEAN, "enableshadows" ), + DEFINE_KEYFIELD( m_bLightOnlyTarget, FIELD_BOOLEAN, "lightonlytarget" ), + DEFINE_KEYFIELD( m_bLightWorld, FIELD_BOOLEAN, "lightworld" ), + DEFINE_KEYFIELD( m_bCameraSpace, FIELD_BOOLEAN, "cameraspace" ), + DEFINE_KEYFIELD( m_flAmbient, FIELD_FLOAT, "ambient" ), + DEFINE_AUTO_ARRAY( m_SpotlightTextureName, FIELD_CHARACTER ), + DEFINE_KEYFIELD( m_nSpotlightTextureFrame, FIELD_INTEGER, "textureframe" ), + DEFINE_KEYFIELD( m_flNearZ, FIELD_FLOAT, "nearz" ), + DEFINE_KEYFIELD( m_flFarZ, FIELD_FLOAT, "farz" ), + DEFINE_KEYFIELD( m_nShadowQuality, FIELD_INTEGER, "shadowquality" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bAlwaysDraw, FIELD_BOOLEAN, "alwaysdraw" ), + DEFINE_KEYFIELD( m_bProjectedTextureVersion, FIELD_BOOLEAN, "ProjectedTextureVersion" ), +#endif + DEFINE_KEYFIELD( m_flBrightnessScale, FIELD_FLOAT, "brightnessscale" ), + DEFINE_FIELD( m_LightColor, FIELD_COLOR32 ), + DEFINE_KEYFIELD( m_flColorTransitionTime, FIELD_FLOAT, "colortransitiontime" ), + + DEFINE_INPUTFUNC( FIELD_VOID, "TurnOn", InputTurnOn ), + DEFINE_INPUTFUNC( FIELD_VOID, "TurnOff", InputTurnOff ), + DEFINE_INPUTFUNC( FIELD_VOID, "AlwaysUpdateOn", InputAlwaysUpdateOn ), + DEFINE_INPUTFUNC( FIELD_VOID, "AlwaysUpdateOff", InputAlwaysUpdateOff ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "FOV", InputSetFOV ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_FLOAT, "VerFOV", InputSetVerFOV ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "HorFOV", InputSetHorFOV ), +#endif + DEFINE_INPUTFUNC( FIELD_EHANDLE, "Target", InputSetTarget ), + DEFINE_INPUTFUNC( FIELD_BOOLEAN, "CameraSpace", InputSetCameraSpace ), + DEFINE_INPUTFUNC( FIELD_BOOLEAN, "LightOnlyTarget", InputSetLightOnlyTarget ), + DEFINE_INPUTFUNC( FIELD_BOOLEAN, "LightWorld", InputSetLightWorld ), + DEFINE_INPUTFUNC( FIELD_BOOLEAN, "EnableShadows", InputSetEnableShadows ), + DEFINE_INPUTFUNC( FIELD_COLOR32, "LightColor", InputSetLightColor ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "Ambient", InputSetAmbient ), + DEFINE_INPUTFUNC( FIELD_STRING, "SpotlightTexture", InputSetSpotlightTexture ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetSpotlightFrame", InputSetSpotlightFrame ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetBrightness", InputSetBrightness ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetColorTransitionTime", InputSetColorTransitionTime ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetNearZ", InputSetNearZ ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetFarZ", InputSetFarZ ), + DEFINE_INPUTFUNC( FIELD_VOID, "AlwaysDrawOn", InputAlwaysDrawOn ), + DEFINE_INPUTFUNC( FIELD_VOID, "StopFollowingTarget", InputStopFollowingTarget ), + DEFINE_INPUTFUNC( FIELD_VOID, "StartFollowingTarget", InputStartFollowingTarget ), +#endif + DEFINE_THINKFUNC( InitialThink ), +END_DATADESC() + +IMPLEMENT_SERVERCLASS_ST( CEnvProjectedTexture, DT_EnvProjectedTexture ) + SendPropEHandle( SENDINFO( m_hTargetEntity ) ), +#ifdef MAPBASE + SendPropBool( SENDINFO( m_bDontFollowTarget ) ), +#endif + SendPropBool( SENDINFO( m_bState ) ), + SendPropBool( SENDINFO( m_bAlwaysUpdate ) ), + SendPropFloat( SENDINFO( m_flLightFOV ) ), +#ifdef MAPBASE + SendPropFloat( SENDINFO( m_flLightHorFOV ) ), +#endif + SendPropBool( SENDINFO( m_bEnableShadows ) ), + SendPropBool( SENDINFO( m_bLightOnlyTarget ) ), + SendPropBool( SENDINFO( m_bLightWorld ) ), + SendPropBool( SENDINFO( m_bCameraSpace ) ), + SendPropFloat( SENDINFO( m_flBrightnessScale ) ), + SendPropInt( SENDINFO ( m_LightColor ), 32, SPROP_UNSIGNED, SendProxy_Color32ToInt ), + SendPropFloat( SENDINFO( m_flColorTransitionTime ) ), + SendPropFloat( SENDINFO( m_flAmbient ) ), + SendPropString( SENDINFO( m_SpotlightTextureName ) ), + SendPropInt( SENDINFO( m_nSpotlightTextureFrame ) ), + SendPropFloat( SENDINFO( m_flNearZ ), 16, SPROP_ROUNDDOWN, 0.0f, 500.0f ), + SendPropFloat( SENDINFO( m_flFarZ ), 18, SPROP_ROUNDDOWN, 0.0f, 1500.0f ), + SendPropInt( SENDINFO( m_nShadowQuality ), 1, SPROP_UNSIGNED ), // Just one bit for now +#ifdef MAPBASE + SendPropBool( SENDINFO( m_bAlwaysDraw ) ), + + // Not needed on the client right now, change when it actually is needed + //SendPropBool( SENDINFO( m_bProjectedTextureVersion ) ), +#endif +END_SEND_TABLE() + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CEnvProjectedTexture::CEnvProjectedTexture( void ) +{ + m_bState = true; + m_bAlwaysUpdate = false; + m_flLightFOV = 45.0f; + m_bEnableShadows = false; + m_bLightOnlyTarget = false; + m_bLightWorld = true; + m_bCameraSpace = false; + +#ifndef MAPBASE + Q_strcpy( m_SpotlightTextureName.GetForModify(), "effects/flashlight_border" ); +#endif + Q_strcpy( m_SpotlightTextureName.GetForModify(), "effects/flashlight001" ); + + m_nSpotlightTextureFrame = 0; + m_flBrightnessScale = 1.0f; + m_LightColor.Init( 255, 255, 255, 255 ); + m_flColorTransitionTime = 0.5f; + m_flAmbient = 0.0f; + m_flNearZ = 4.0f; + m_flFarZ = 750.0f; + m_nShadowQuality = 0; +} + +void UTIL_ColorStringToLinearFloatColor( Vector &color, const char *pString ) +{ + float tmp[4]; + UTIL_StringToFloatArray( tmp, 4, pString ); + if( tmp[3] <= 0.0f ) + { + tmp[3] = 255.0f; + } + tmp[3] *= ( 1.0f / 255.0f ); + color.x = tmp[0] * ( 1.0f / 255.0f ) * tmp[3]; + color.y = tmp[1] * ( 1.0f / 255.0f ) * tmp[3]; + color.z = tmp[2] * ( 1.0f / 255.0f ) * tmp[3]; +} + +bool CEnvProjectedTexture::KeyValue( const char *szKeyName, const char *szValue ) +{ + if ( FStrEq( szKeyName, "lightcolor" ) ) + { +#ifdef MAPBASE + // + // Most existing projected textures don't have intensity implemented. + // This can give them 0% intensity, which makes them invisible. + // If intensity is not detected, assume 255. + // + // Also, get rid of the floats, for god's sake. Have you ever seen a color32 with decimals? + // + int tmp[4]; + tmp[3] = 255; + UTIL_StringToIntArray_PreserveArray( tmp, 4, szValue ); + + m_LightColor.SetR( tmp[0] ); + m_LightColor.SetG( tmp[1] ); + m_LightColor.SetB( tmp[2] ); + m_LightColor.SetA( tmp[3] ); +#else + float tmp[4]; + UTIL_StringToFloatArray( tmp, 4, szValue ); + + m_LightColor.SetR( tmp[0] ); + m_LightColor.SetG( tmp[1] ); + m_LightColor.SetB( tmp[2] ); + m_LightColor.SetA( tmp[3] ); +#endif + } + else if ( FStrEq( szKeyName, "texturename" ) ) + { +#if defined( _X360 ) + if ( Q_strcmp( szValue, "effects/flashlight001" ) == 0 ) + { + // Use this as the default for Xbox + Q_strcpy( m_SpotlightTextureName.GetForModify(), "effects/flashlight_border" ); + } + else + { + Q_strcpy( m_SpotlightTextureName.GetForModify(), szValue ); + } +#else + Q_strcpy( m_SpotlightTextureName.GetForModify(), szValue ); +#endif + } + else + { + return BaseClass::KeyValue( szKeyName, szValue ); + } + + return true; +} + +bool CEnvProjectedTexture::GetKeyValue( const char *szKeyName, char *szValue, int iMaxLen ) +{ + if ( FStrEq( szKeyName, "lightcolor" ) ) + { + Q_snprintf( szValue, iMaxLen, "%d %d %d %d", m_LightColor.GetR(), m_LightColor.GetG(), m_LightColor.GetB(), m_LightColor.GetA() ); + return true; + } + else if ( FStrEq( szKeyName, "texturename" ) ) + { + Q_snprintf( szValue, iMaxLen, "%s", m_SpotlightTextureName.Get() ); + return true; + } + return BaseClass::GetKeyValue( szKeyName, szValue, iMaxLen ); +} + +void CEnvProjectedTexture::InputTurnOn( inputdata_t &inputdata ) +{ + m_bState = true; +} + +void CEnvProjectedTexture::InputTurnOff( inputdata_t &inputdata ) +{ + m_bState = false; +} + +void CEnvProjectedTexture::InputAlwaysUpdateOn( inputdata_t &inputdata ) +{ + m_bAlwaysUpdate = true; +} + +void CEnvProjectedTexture::InputAlwaysUpdateOff( inputdata_t &inputdata ) +{ + m_bAlwaysUpdate = false; +} + +void CEnvProjectedTexture::InputSetFOV( inputdata_t &inputdata ) +{ + m_flLightFOV = inputdata.value.Float(); +#ifdef MAPBASE + m_flLightHorFOV = inputdata.value.Float(); +#endif +} + +#ifdef MAPBASE +void CEnvProjectedTexture::InputSetVerFOV( inputdata_t &inputdata ) +{ + m_flLightFOV = inputdata.value.Float(); +} + +void CEnvProjectedTexture::InputSetHorFOV( inputdata_t &inputdata ) +{ + m_flLightHorFOV = inputdata.value.Float(); +} +#endif + +void CEnvProjectedTexture::InputSetTarget( inputdata_t &inputdata ) +{ +#ifdef MAPBASE + // env_projectedtexture's "Target" uses FIELD_EHANDLE while Mapbase's base entity "SetTarget" uses FIELD_STRING + if (inputdata.value.FieldType() != FIELD_EHANDLE) + inputdata.value.Convert(FIELD_EHANDLE, this, inputdata.pActivator, inputdata.pCaller); +#endif + m_hTargetEntity = inputdata.value.Entity(); +} + +void CEnvProjectedTexture::InputSetCameraSpace( inputdata_t &inputdata ) +{ + m_bCameraSpace = inputdata.value.Bool(); +} + +void CEnvProjectedTexture::InputSetLightOnlyTarget( inputdata_t &inputdata ) +{ + m_bLightOnlyTarget = inputdata.value.Bool(); +} + +void CEnvProjectedTexture::InputSetLightWorld( inputdata_t &inputdata ) +{ + m_bLightWorld = inputdata.value.Bool(); +} + +void CEnvProjectedTexture::InputSetEnableShadows( inputdata_t &inputdata ) +{ + m_bEnableShadows = inputdata.value.Bool(); +} + +void CEnvProjectedTexture::InputSetLightColor( inputdata_t &inputdata ) +{ + m_LightColor = inputdata.value.Color32(); +} + +void CEnvProjectedTexture::InputSetAmbient( inputdata_t &inputdata ) +{ + m_flAmbient = inputdata.value.Float(); +} + +void CEnvProjectedTexture::InputSetSpotlightTexture( inputdata_t &inputdata ) +{ + Q_strcpy( m_SpotlightTextureName.GetForModify(), inputdata.value.String() ); +} + +#ifdef MAPBASE +void CEnvProjectedTexture::InputSetSpotlightFrame( inputdata_t &inputdata ) +{ + m_nSpotlightTextureFrame = inputdata.value.Int(); +} + +void CEnvProjectedTexture::InputSetBrightness( inputdata_t &inputdata ) +{ + m_flBrightnessScale = inputdata.value.Float(); +} + +void CEnvProjectedTexture::InputSetColorTransitionTime( inputdata_t &inputdata ) +{ + m_flColorTransitionTime = inputdata.value.Float(); +} + +void CEnvProjectedTexture::InputSetNearZ( inputdata_t &inputdata ) +{ + m_flNearZ = inputdata.value.Float(); +} + +void CEnvProjectedTexture::InputSetFarZ( inputdata_t &inputdata ) +{ + m_flFarZ = inputdata.value.Float(); +} +#endif + +#ifdef MAPBASE +void CEnvProjectedTexture::Spawn( void ) +{ + // Set m_flLightHorFOV to m_flLightFOV if it's still 0, indicating either legacy support or desire to do this + if (m_flLightHorFOV == 0.0f) + { + m_flLightHorFOV = m_flLightFOV; + } + + BaseClass::Spawn(); +} +#endif + +void CEnvProjectedTexture::Activate( void ) +{ + m_bState = ( ( GetSpawnFlags() & ENV_PROJECTEDTEXTURE_STARTON ) != 0 ); + m_bAlwaysUpdate = ( ( GetSpawnFlags() & ENV_PROJECTEDTEXTURE_ALWAYSUPDATE ) != 0 ); + + SetThink( &CEnvProjectedTexture::InitialThink ); + SetNextThink( gpGlobals->curtime + 0.1f ); + + BaseClass::Activate(); +} + +#ifdef MAPBASE +void CEnvProjectedTexture::SetParent( CBaseEntity* pNewParent, int iAttachment ) +{ + BaseClass::SetParent( pNewParent, iAttachment ); + + if (m_bProjectedTextureVersion == 0) + { + // Pre-Mapbase projected textures should use the VDC parenting fix. + // Since the ASW changes structure projected textures differently, + // we have to set it here on the server when our parent changes. + // Don't run this code if we already have the spawnflag though. + if ( ( GetSpawnFlags() & ENV_PROJECTEDTEXTURE_ALWAYSUPDATE ) == 0 ) + { + m_bAlwaysUpdate = GetMoveParent() != NULL; + } + } +} +#endif + +void CEnvProjectedTexture::InitialThink( void ) +{ + m_hTargetEntity = gEntList.FindEntityByName( NULL, m_target ); +} + +int CEnvProjectedTexture::UpdateTransmitState() +{ + return SetTransmitState( FL_EDICT_ALWAYS ); +} + +#else + #define ENV_PROJECTEDTEXTURE_STARTON (1<<0) +#ifdef MAPBASE +#define ENV_PROJECTEDTEXTURE_ALWAYSUPDATE (1<<1) +#endif //----------------------------------------------------------------------------- // Purpose: @@ -31,13 +409,21 @@ public: void InputTurnOn( inputdata_t &inputdata ); void InputTurnOff( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputAlwaysUpdateOn( inputdata_t &inputdata ); + void InputAlwaysUpdateOff( inputdata_t &inputdata ); +#endif void InputSetFOV( inputdata_t &inputdata ); void InputSetTarget( inputdata_t &inputdata ); void InputSetCameraSpace( inputdata_t &inputdata ); void InputSetLightOnlyTarget( inputdata_t &inputdata ); void InputSetLightWorld( inputdata_t &inputdata ); void InputSetEnableShadows( inputdata_t &inputdata ); +#ifndef MAPBASE // void InputSetLightColor( inputdata_t &inputdata ); +#else + void InputSetLightColor( inputdata_t &inputdata ); +#endif void InputSetSpotlightTexture( inputdata_t &inputdata ); void InputSetAmbient( inputdata_t &inputdata ); @@ -48,6 +434,9 @@ public: private: CNetworkVar( bool, m_bState ); +#ifdef MAPBASE + CNetworkVar( bool, m_bAlwaysUpdate ); +#endif CNetworkVar( float, m_flLightFOV ); CNetworkVar( bool, m_bEnableShadows ); CNetworkVar( bool, m_bLightOnlyTarget ); @@ -73,7 +462,11 @@ BEGIN_DATADESC( CEnvProjectedTexture ) DEFINE_KEYFIELD( m_bLightWorld, FIELD_BOOLEAN, "lightworld" ), DEFINE_KEYFIELD( m_bCameraSpace, FIELD_BOOLEAN, "cameraspace" ), DEFINE_KEYFIELD( m_flAmbient, FIELD_FLOAT, "ambient" ), +#ifndef MAPBASE DEFINE_AUTO_ARRAY_KEYFIELD( m_SpotlightTextureName, FIELD_CHARACTER, "texturename" ), +#else + DEFINE_AUTO_ARRAY( m_SpotlightTextureName, FIELD_CHARACTER ), +#endif DEFINE_KEYFIELD( m_nSpotlightTextureFrame, FIELD_INTEGER, "textureframe" ), DEFINE_KEYFIELD( m_flNearZ, FIELD_FLOAT, "nearz" ), DEFINE_KEYFIELD( m_flFarZ, FIELD_FLOAT, "farz" ), @@ -82,14 +475,22 @@ BEGIN_DATADESC( CEnvProjectedTexture ) DEFINE_INPUTFUNC( FIELD_VOID, "TurnOn", InputTurnOn ), DEFINE_INPUTFUNC( FIELD_VOID, "TurnOff", InputTurnOff ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "AlwaysUpdateOn", InputAlwaysUpdateOn ), + DEFINE_INPUTFUNC( FIELD_VOID, "AlwaysUpdateOff", InputAlwaysUpdateOff ), +#endif DEFINE_INPUTFUNC( FIELD_FLOAT, "FOV", InputSetFOV ), DEFINE_INPUTFUNC( FIELD_EHANDLE, "Target", InputSetTarget ), DEFINE_INPUTFUNC( FIELD_BOOLEAN, "CameraSpace", InputSetCameraSpace ), DEFINE_INPUTFUNC( FIELD_BOOLEAN, "LightOnlyTarget", InputSetLightOnlyTarget ), DEFINE_INPUTFUNC( FIELD_BOOLEAN, "LightWorld", InputSetLightWorld ), DEFINE_INPUTFUNC( FIELD_BOOLEAN, "EnableShadows", InputSetEnableShadows ), +#ifndef MAPBASE // this is broken . . need to be able to set color and intensity like light_dynamic // DEFINE_INPUTFUNC( FIELD_COLOR32, "LightColor", InputSetLightColor ), +#else + DEFINE_INPUTFUNC( FIELD_STRING, "LightColor", InputSetLightColor ), +#endif DEFINE_INPUTFUNC( FIELD_FLOAT, "Ambient", InputSetAmbient ), DEFINE_INPUTFUNC( FIELD_STRING, "SpotlightTexture", InputSetSpotlightTexture ), DEFINE_THINKFUNC( InitialThink ), @@ -98,6 +499,9 @@ END_DATADESC() IMPLEMENT_SERVERCLASS_ST( CEnvProjectedTexture, DT_EnvProjectedTexture ) SendPropEHandle( SENDINFO( m_hTargetEntity ) ), SendPropBool( SENDINFO( m_bState ) ), +#ifdef MAPBASE + SendPropBool( SENDINFO( m_bAlwaysUpdate ) ), +#endif SendPropFloat( SENDINFO( m_flLightFOV ) ), SendPropBool( SENDINFO( m_bEnableShadows ) ), SendPropBool( SENDINFO( m_bLightOnlyTarget ) ), @@ -161,6 +565,12 @@ bool CEnvProjectedTexture::KeyValue( const char *szKeyName, const char *szValue UTIL_ColorStringToLinearFloatColor( tmp, szValue ); m_LinearFloatLightColor = tmp; } +#ifdef MAPBASE + else if ( FStrEq(szKeyName, "texturename") ) + { + Q_strcpy(m_SpotlightTextureName.GetForModify(), szValue); + } +#endif else { return BaseClass::KeyValue( szKeyName, szValue ); @@ -179,6 +589,18 @@ void CEnvProjectedTexture::InputTurnOff( inputdata_t &inputdata ) m_bState = false; } +#ifdef MAPBASE +void CEnvProjectedTexture::InputAlwaysUpdateOn( inputdata_t &inputdata ) +{ + m_bAlwaysUpdate = true; +} + +void CEnvProjectedTexture::InputAlwaysUpdateOff( inputdata_t &inputdata ) +{ + m_bAlwaysUpdate = false; +} +#endif + void CEnvProjectedTexture::InputSetFOV( inputdata_t &inputdata ) { m_flLightFOV = inputdata.value.Float(); @@ -209,10 +631,19 @@ void CEnvProjectedTexture::InputSetEnableShadows( inputdata_t &inputdata ) m_bEnableShadows = inputdata.value.Bool(); } +#ifndef MAPBASE //void CEnvProjectedTexture::InputSetLightColor( inputdata_t &inputdata ) //{ // m_cLightColor = inputdata.value.Color32(); //} +#else +void CEnvProjectedTexture::InputSetLightColor( inputdata_t &inputdata ) +{ + Vector tmp; + UTIL_ColorStringToLinearFloatColor( tmp, inputdata.value.String() ); + m_LinearFloatLightColor = tmp; +} +#endif void CEnvProjectedTexture::InputSetAmbient( inputdata_t &inputdata ) { @@ -230,6 +661,9 @@ void CEnvProjectedTexture::Activate( void ) { m_bState = true; } +#ifdef MAPBASE + m_bAlwaysUpdate = ( ( GetSpawnFlags() & ENV_PROJECTEDTEXTURE_ALWAYSUPDATE ) != 0 ); +#endif SetThink( &CEnvProjectedTexture::InitialThink ); SetNextThink( gpGlobals->curtime + 0.1f ); @@ -239,7 +673,19 @@ void CEnvProjectedTexture::Activate( void ) void CEnvProjectedTexture::InitialThink( void ) { +#ifndef MAPBASE m_hTargetEntity = gEntList.FindEntityByName( NULL, m_target ); +#else + if (m_hTargetEntity == NULL && m_target != NULL_STRING) + m_hTargetEntity = gEntList.FindEntityByName(NULL, m_target); + if (m_hTargetEntity == NULL) + return; + Vector vecToTarget = (m_hTargetEntity->GetAbsOrigin() - GetAbsOrigin()); + QAngle vecAngles; + VectorAngles(vecToTarget, vecAngles); + SetAbsAngles(vecAngles); + SetNextThink(gpGlobals->curtime + 0.1); +#endif } int CEnvProjectedTexture::UpdateTransmitState() @@ -247,6 +693,8 @@ int CEnvProjectedTexture::UpdateTransmitState() return SetTransmitState( FL_EDICT_ALWAYS ); } +#endif + // Console command for creating env_projectedtexture entities void CC_CreateFlashlight( const CCommand &args ) diff --git a/sp/src/game/server/env_projectedtexture.h b/sp/src/game/server/env_projectedtexture.h new file mode 100644 index 00000000..c2ad6647 --- /dev/null +++ b/sp/src/game/server/env_projectedtexture.h @@ -0,0 +1,104 @@ + +#ifndef ENV_PROJECTEDTEXTURE_H +#define ENV_PROJECTEDTEXTURE_H +#ifdef _WIN32 +#pragma once +#endif + +#define ENV_PROJECTEDTEXTURE_STARTON (1<<0) +#define ENV_PROJECTEDTEXTURE_ALWAYSUPDATE (1<<1) + +#ifdef ASW_PROJECTED_TEXTURES +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +class CEnvProjectedTexture : public CPointEntity +{ + DECLARE_CLASS( CEnvProjectedTexture, CPointEntity ); +public: + DECLARE_DATADESC(); + DECLARE_SERVERCLASS(); + + CEnvProjectedTexture(); + bool KeyValue( const char *szKeyName, const char *szValue ); + virtual bool GetKeyValue( const char *szKeyName, char *szValue, int iMaxLen ); + + // Always transmit to clients + virtual int UpdateTransmitState(); +#ifdef MAPBASE + virtual void Spawn( void ); +#endif + virtual void Activate( void ); +#ifdef MAPBASE + void SetParent( CBaseEntity* pNewParent, int iAttachment = -1 ); +#endif + + void InputTurnOn( inputdata_t &inputdata ); + void InputTurnOff( inputdata_t &inputdata ); + void InputAlwaysUpdateOn( inputdata_t &inputdata ); + void InputAlwaysUpdateOff( inputdata_t &inputdata ); + void InputSetFOV( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetVerFOV( inputdata_t &inputdata ); + void InputSetHorFOV( inputdata_t &inputdata ); +#endif + void InputSetTarget( inputdata_t &inputdata ); + void InputSetCameraSpace( inputdata_t &inputdata ); + void InputSetLightOnlyTarget( inputdata_t &inputdata ); + void InputSetLightWorld( inputdata_t &inputdata ); + void InputSetEnableShadows( inputdata_t &inputdata ); + void InputSetLightColor( inputdata_t &inputdata ); + void InputSetSpotlightTexture( inputdata_t &inputdata ); + void InputSetAmbient( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetSpotlightFrame( inputdata_t &inputdata ); + void InputSetBrightness( inputdata_t &inputdata ); + void InputSetColorTransitionTime( inputdata_t &inputdata ); + void InputSetNearZ( inputdata_t &inputdata ); + void InputSetFarZ( inputdata_t &inputdata ); + void InputAlwaysDrawOn( inputdata_t &inputdata ) { m_bAlwaysDraw = true; } + void InputAlwaysDrawOff( inputdata_t &inputdata ) { m_bAlwaysDraw = false; } + void InputStopFollowingTarget( inputdata_t &inputdata ) { m_bDontFollowTarget = true; } + void InputStartFollowingTarget( inputdata_t &inputdata ) { m_bDontFollowTarget = false; } +#endif + + void InitialThink( void ); + + CNetworkHandle( CBaseEntity, m_hTargetEntity ); +#ifdef MAPBASE + CNetworkVar( bool, m_bDontFollowTarget ); +#endif + +private: + + CNetworkVar( bool, m_bState ); + CNetworkVar( bool, m_bAlwaysUpdate ); + CNetworkVar( float, m_flLightFOV ); +#ifdef MAPBASE + CNetworkVar( float, m_flLightHorFOV ); +#endif + CNetworkVar( bool, m_bEnableShadows ); + CNetworkVar( bool, m_bLightOnlyTarget ); + CNetworkVar( bool, m_bLightWorld ); + CNetworkVar( bool, m_bCameraSpace ); + CNetworkVar( float, m_flBrightnessScale ); + CNetworkColor32( m_LightColor ); + CNetworkVar( float, m_flColorTransitionTime ); + CNetworkVar( float, m_flAmbient ); + CNetworkString( m_SpotlightTextureName, MAX_PATH ); + CNetworkVar( int, m_nSpotlightTextureFrame ); + CNetworkVar( float, m_flNearZ ); + CNetworkVar( float, m_flFarZ ); + CNetworkVar( int, m_nShadowQuality ); +#ifdef MAPBASE + CNetworkVar( bool, m_bAlwaysDraw ); + + // 1 = New projected texture + // 0 = Non-Mapbase projected texture, e.g. one that uses the VDC parenting fix instead of the spawnflag + CNetworkVar( bool, m_bProjectedTextureVersion ); +#endif +}; +#endif + + +#endif // ENV_PROJECTEDTEXTURE_H \ No newline at end of file diff --git a/sp/src/game/server/env_tonemap_controller.cpp b/sp/src/game/server/env_tonemap_controller.cpp index 613d4548..a45a1107 100644 --- a/sp/src/game/server/env_tonemap_controller.cpp +++ b/sp/src/game/server/env_tonemap_controller.cpp @@ -83,7 +83,11 @@ BEGIN_DATADESC( CEnvTonemapController ) DEFINE_INPUTFUNC( FIELD_VOID, "UseDefaultAutoExposure", InputUseDefaultAutoExposure ), DEFINE_INPUTFUNC( FIELD_VOID, "UseDefaultBloomScale", InputUseDefaultBloomScale ), DEFINE_INPUTFUNC( FIELD_FLOAT, "SetBloomScale", InputSetBloomScale ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_STRING, "SetBloomScaleRange", InputSetBloomScaleRange ), +#else DEFINE_INPUTFUNC( FIELD_FLOAT, "SetBloomScaleRange", InputSetBloomScaleRange ), +#endif END_DATADESC() IMPLEMENT_SERVERCLASS_ST( CEnvTonemapController, DT_EnvTonemapController ) diff --git a/sp/src/game/server/envmicrophone.cpp b/sp/src/game/server/envmicrophone.cpp index 9e85b0d9..0b0fc5ff 100644 --- a/sp/src/game/server/envmicrophone.cpp +++ b/sp/src/game/server/envmicrophone.cpp @@ -44,6 +44,10 @@ BEGIN_DATADESC( CEnvMicrophone ) DEFINE_KEYFIELD(m_iszListenFilter, FIELD_STRING, "ListenFilter"), DEFINE_FIELD(m_hListenFilter, FIELD_EHANDLE), DEFINE_FIELD(m_hSpeaker, FIELD_EHANDLE), +#ifdef MAPBASE + DEFINE_KEYFIELD(m_iszLandmarkName, FIELD_STRING, "landmark"), + DEFINE_FIELD(m_hLandmark, FIELD_EHANDLE), +#endif // DEFINE_FIELD(m_bAvoidFeedback, FIELD_BOOLEAN), // DONT SAVE DEFINE_KEYFIELD(m_iSpeakerDSPPreset, FIELD_INTEGER, "speaker_dsp_preset" ), DEFINE_KEYFIELD(m_flMaxRange, FIELD_FLOAT, "MaxRange"), @@ -52,6 +56,9 @@ BEGIN_DATADESC( CEnvMicrophone ) DEFINE_INPUTFUNC(FIELD_VOID, "Enable", InputEnable), DEFINE_INPUTFUNC(FIELD_VOID, "Disable", InputDisable), DEFINE_INPUTFUNC(FIELD_STRING, "SetSpeakerName", InputSetSpeakerName), +#ifdef MAPBASE + DEFINE_INPUTFUNC(FIELD_INTEGER, "SetDSPPreset", InputSetDSPPreset), +#endif DEFINE_OUTPUT(m_SoundLevel, "SoundLevel"), DEFINE_OUTPUT(m_OnRoutedSound, "OnRoutedSound" ), @@ -190,6 +197,13 @@ void CEnvMicrophone::ActivateSpeaker( void ) s_Microphones.AddToTail( this ); } } + +#ifdef MAPBASE + if (m_iszLandmarkName != NULL_STRING) + { + m_hLandmark = gEntList.FindEntityByName(NULL, m_iszLandmarkName, this, NULL, NULL); + } +#endif } //----------------------------------------------------------------------------- @@ -234,6 +248,18 @@ void CEnvMicrophone::InputSetSpeakerName( inputdata_t &inputdata ) SetSpeakerName( inputdata.value.StringID() ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CEnvMicrophone::InputSetDSPPreset( inputdata_t &inputdata ) +{ + m_iSpeakerDSPPreset = inputdata.value.Int(); + ActivateSpeaker(); +} +#endif + //----------------------------------------------------------------------------- // Purpose: Checks whether this microphone can hear a given sound, and at what // relative volume level. @@ -473,6 +499,21 @@ MicrophoneResult_t CEnvMicrophone::SoundPlayed( int entindex, const char *soundn } } +#ifdef MAPBASE + // Something similar to trigger_teleport landmarks for sounds transmitting to speaker + Vector vecOrigin = m_hSpeaker->GetAbsOrigin(); + if (m_hLandmark) + { + Vector vecSoundPos; + if (pOrigin) + vecSoundPos = *pOrigin; + else if (CBaseEntity *pEntity = CBaseEntity::Instance(engine->PEntityOfEntIndex(entindex))) + vecSoundPos = pEntity->GetAbsOrigin(); + + vecOrigin += (vecSoundPos - m_hLandmark->GetAbsOrigin()); + } +#endif + m_bAvoidFeedback = true; // Add the speaker flag. Detected at playback and applies the speaker filter. @@ -486,7 +527,11 @@ MicrophoneResult_t CEnvMicrophone::SoundPlayed( int entindex, const char *soundn ep.m_SoundLevel = soundlevel; ep.m_nFlags = iFlags; ep.m_nPitch = iPitch; +#ifdef MAPBASE + ep.m_pOrigin = &vecOrigin; +#else ep.m_pOrigin = &m_hSpeaker->GetAbsOrigin(); +#endif ep.m_flSoundTime = soundtime; ep.m_nSpeakerEntity = entindex; diff --git a/sp/src/game/server/envmicrophone.h b/sp/src/game/server/envmicrophone.h index 1cad0761..254486ff 100644 --- a/sp/src/game/server/envmicrophone.h +++ b/sp/src/game/server/envmicrophone.h @@ -54,6 +54,9 @@ public: void InputEnable( inputdata_t &inputdata ); void InputDisable( inputdata_t &inputdata ); void InputSetSpeakerName( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetDSPPreset( inputdata_t &inputdata ); +#endif DECLARE_DATADESC(); @@ -79,6 +82,10 @@ private: int m_iSpeakerDSPPreset; // Speaker DSP preset to use when this microphone is enabled string_t m_iszListenFilter; CHandle m_hListenFilter; +#ifdef MAPBASE + string_t m_iszLandmarkName; + EHANDLE m_hLandmark; +#endif COutputFloat m_SoundLevel; // Fired when the sampled volume level changes. COutputEvent m_OnRoutedSound; // Fired when a sound has been played through our speaker diff --git a/sp/src/game/server/episodic/ai_behavior_passenger_companion.cpp b/sp/src/game/server/episodic/ai_behavior_passenger_companion.cpp index f96c2a55..a9568c69 100644 --- a/sp/src/game/server/episodic/ai_behavior_passenger_companion.cpp +++ b/sp/src/game/server/episodic/ai_behavior_passenger_companion.cpp @@ -530,7 +530,11 @@ void CAI_PassengerBehaviorCompanion::GatherConditions( void ) AIEnemiesIter_t iter; for( AI_EnemyInfo_t *pEMemory = GetEnemies()->GetFirst(&iter); pEMemory != NULL; pEMemory = GetEnemies()->GetNext(&iter) ) { +#ifdef MAPBASE + if( GetOuter()->IRelationType( pEMemory->hEnemy ) <= D_FR ) +#else if( GetOuter()->IRelationType( pEMemory->hEnemy ) == D_HT ) +#endif { if( pEMemory->timeLastSeen == gpGlobals->curtime ) { diff --git a/sp/src/game/server/episodic/npc_hunter.cpp b/sp/src/game/server/episodic/npc_hunter.cpp index d55053bc..dcc1fb0b 100644 --- a/sp/src/game/server/episodic/npc_hunter.cpp +++ b/sp/src/game/server/episodic/npc_hunter.cpp @@ -63,6 +63,9 @@ #include "weapon_striderbuster.h" #include "monstermaker.h" #include "weapon_rpg.h" +#ifdef MAPBASE +#include "mapbase/GlobalStrings.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -201,11 +204,19 @@ int g_interactionHunterFoundEnemy = 0; //----------------------------------------------------------------------------- // Local stuff. //----------------------------------------------------------------------------- +#ifdef MAPBASE +#define s_iszStriderClassname gm_isz_class_Strider +#define s_iszPhysPropClassname gm_isz_class_PropPhysics +static string_t s_iszStriderBusterClassname; +static string_t s_iszMagnadeClassname; +static string_t s_iszHuntersToRunOver; +#else static string_t s_iszStriderClassname; static string_t s_iszStriderBusterClassname; static string_t s_iszMagnadeClassname; static string_t s_iszPhysPropClassname; static string_t s_iszHuntersToRunOver; +#endif //----------------------------------------------------------------------------- @@ -1973,11 +1984,17 @@ void CNPC_Hunter::Activate() { BaseClass::Activate(); +#ifdef MAPBASE + s_iszStriderBusterClassname = AllocPooledString( "weapon_striderbuster" ); + s_iszMagnadeClassname = AllocPooledString( "npc_grenade_magna" ); + s_iszHuntersToRunOver = AllocPooledString( "hunters_to_run_over" ); +#else s_iszStriderBusterClassname = AllocPooledString( "weapon_striderbuster" ); s_iszStriderClassname = AllocPooledString( "npc_strider" ); s_iszMagnadeClassname = AllocPooledString( "npc_grenade_magna" ); s_iszPhysPropClassname = AllocPooledString( "prop_physics" ); s_iszHuntersToRunOver = AllocPooledString( "hunters_to_run_over" ); +#endif // If no one has initialized the hunters to run over counter, just zero it out. if ( !GlobalEntity_IsInTable( s_iszHuntersToRunOver ) ) @@ -4089,7 +4106,11 @@ bool CNPC_Hunter::HandleChargeImpact( Vector vecImpact, CBaseEntity *pEntity ) } // Hit anything we don't like +#ifdef MAPBASE + if ( IRelationType( pEntity ) <= D_FR && ( GetNextAttack() < gpGlobals->curtime ) ) +#else if ( IRelationType( pEntity ) == D_HT && ( GetNextAttack() < gpGlobals->curtime ) ) +#endif { EmitSound( "NPC_Hunter.ChargeHitEnemy" ); @@ -4371,7 +4392,11 @@ void CNPC_Hunter::HandleAnimEvent( animevent_t *pEvent ) //----------------------------------------------------------------------------- void CNPC_Hunter::AddEntityRelationship( CBaseEntity *pEntity, Disposition_t nDisposition, int nPriority ) { +#ifdef MAPBASE + if ( nDisposition == D_HT && pEntity->ClassMatches(gm_isz_class_Bullseye) ) +#else if ( nDisposition == D_HT && pEntity->ClassMatches("npc_bullseye") ) +#endif UpdateEnemyMemory( pEntity, pEntity->GetAbsOrigin() ); BaseClass::AddEntityRelationship( pEntity, nDisposition, nPriority ); } @@ -5006,7 +5031,11 @@ int CNPC_Hunter::RangeAttack2Conditions( float flDot, float flDist ) { return COND_TOO_FAR_TO_ATTACK; } +#ifdef MAPBASE + else if ( !bIsBuster && ( !GetEnemy() || !GetEnemy()->ClassMatches( gm_isz_class_Bullseye ) ) && flDist < hunter_flechette_min_range.GetFloat() ) +#else else if ( !bIsBuster && ( !GetEnemy() || !GetEnemy()->ClassMatches( "npc_bullseye" ) ) && flDist < hunter_flechette_min_range.GetFloat() ) +#endif { return COND_TOO_CLOSE_TO_ATTACK; } @@ -5611,6 +5640,40 @@ int CNPC_Hunter::OnTakeDamage( const CTakeDamageInfo &info ) } } } +#ifdef MAPBASE + else if (info.GetDamageType() == DMG_CLUB && + info.GetInflictor() && info.GetInflictor()->IsNPC()) + { + // If the *inflictor* is a NPC doing club damage, it's most likely an antlion guard or even another hunter charging us. + // Add DMG_CRUSH so we ragdoll immediately if we die. + myInfo.AddDamageType( DMG_CRUSH ); + } + + + // "So, do you know what the alternative fire method does on the AR2? It kills hunters. How did--" + // "No, only Freeman's does it!" + // "What do you mean 'Only Freeman's does it'?" + // "Only energy balls fired by the player can dissolve hunters. Energy balls fired by NPCs only do a metered amount of damage." + // "...Huh. Well, in that case, we'll just use rocket launchers." + // + // That instructor was straight-up lying to those rebels, but now he's telling the truth. + // Hunters die to NPC balls instantly and act like it was a player ball. + // Implementation is sketchy, but it was the best I could do. + if (myInfo.GetDamageType() & DMG_DISSOLVE && + info.GetAttacker() && info.GetAttacker()->IsNPC() && + info.GetInflictor() && info.GetInflictor()->ClassMatches("prop_combine_ball")) + { + // We divide by the ally damage scale to counter its usage in OnTakeDamage_Alive. + myInfo.SetDamage( (float)GetMaxHealth() / sk_hunter_citizen_damage_scale.GetFloat() ); + + myInfo.AddDamageType( DMG_CRUSH ); + //myInfo.SetDamagePosition( info.GetInflictor()->GetAbsOrigin() ); + //myInfo.SetDamageForce( info.GetInflictor()->GetAbsVelocity() ); + + // Make the NPC's ball explode + info.GetInflictor()->AcceptInput( "Explode", this, this, variant_t(), 0 ); + } +#endif return BaseClass::OnTakeDamage( myInfo ); } diff --git a/sp/src/game/server/episodic/vehicle_jeep_episodic.cpp b/sp/src/game/server/episodic/vehicle_jeep_episodic.cpp index 368f1b9f..b5db0d1b 100644 --- a/sp/src/game/server/episodic/vehicle_jeep_episodic.cpp +++ b/sp/src/game/server/episodic/vehicle_jeep_episodic.cpp @@ -328,6 +328,9 @@ BEGIN_DATADESC( CPropJeepEpisodic ) DEFINE_ARRAY( m_hHazardLights, FIELD_EHANDLE, NUM_HAZARD_LIGHTS ), DEFINE_FIELD( m_flCargoStartTime, FIELD_TIME ), DEFINE_FIELD( m_bBlink, FIELD_BOOLEAN ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bNoHazardLights, FIELD_BOOLEAN, "NoHazardLights" ), +#endif DEFINE_FIELD( m_bRadarEnabled, FIELD_BOOLEAN ), DEFINE_FIELD( m_bRadarDetectsEnemies, FIELD_BOOLEAN ), DEFINE_FIELD( m_hRadarScreen, FIELD_EHANDLE ), @@ -357,8 +360,10 @@ BEGIN_DATADESC( CPropJeepEpisodic ) DEFINE_INPUTFUNC( FIELD_VOID, "EnableRadarDetectEnemies", InputEnableRadarDetectEnemies ), DEFINE_INPUTFUNC( FIELD_VOID, "AddBusterToCargo", InputAddBusterToCargo ), DEFINE_INPUTFUNC( FIELD_VOID, "OutsideTransition", InputOutsideTransition ), +#ifndef MAPBASE DEFINE_INPUTFUNC( FIELD_VOID, "DisablePhysGun", InputDisablePhysGun ), DEFINE_INPUTFUNC( FIELD_VOID, "EnablePhysGun", InputEnablePhysGun ), +#endif DEFINE_INPUTFUNC( FIELD_VOID, "CreateLinkController", InputCreateLinkController ), DEFINE_INPUTFUNC( FIELD_VOID, "DestroyLinkController", InputDestroyLinkController ), @@ -1354,6 +1359,11 @@ void CPropJeepEpisodic::DriveVehicle( float flFrameTime, CUserCmd *ucmd, int iBu //----------------------------------------------------------------------------- void CPropJeepEpisodic::CreateHazardLights( void ) { +#ifdef MAPBASE + if (m_bNoHazardLights) + return; +#endif + static const char *s_szAttach[NUM_HAZARD_LIGHTS] = { "rearlight_r", @@ -1664,6 +1674,7 @@ void CPropJeepEpisodic::InputOutsideTransition( inputdata_t &inputdata ) Warning("No valid vehicle teleport points!\n"); } +#ifndef MAPBASE //----------------------------------------------------------------------------- // Purpose: Stop players punting the car around. //----------------------------------------------------------------------------- @@ -1678,6 +1689,7 @@ void CPropJeepEpisodic::InputEnablePhysGun( inputdata_t &data ) { RemoveEFlags( EFL_NO_PHYSCANNON_INTERACTION ); } +#endif //----------------------------------------------------------------------------- // Create and parent two radial node link controllers. diff --git a/sp/src/game/server/episodic/vehicle_jeep_episodic.h b/sp/src/game/server/episodic/vehicle_jeep_episodic.h index 70cb5894..e18e559b 100644 --- a/sp/src/game/server/episodic/vehicle_jeep_episodic.h +++ b/sp/src/game/server/episodic/vehicle_jeep_episodic.h @@ -105,8 +105,10 @@ private: void InputAddBusterToCargo( inputdata_t &data ); void InputSetCargoVisibility( inputdata_t &data ); void InputOutsideTransition( inputdata_t &data ); +#ifndef MAPBASE void InputDisablePhysGun( inputdata_t &data ); void InputEnablePhysGun( inputdata_t &data ); +#endif void InputCreateLinkController( inputdata_t &data ); void InputDestroyLinkController( inputdata_t &data ); void CreateAvoidanceZone( void ); @@ -116,6 +118,10 @@ private: bool m_bAddingCargo; bool m_bBlink; +#ifdef MAPBASE + bool m_bNoHazardLights; +#endif + float m_flCargoStartTime; // Time when the cargo was first added to the vehicle (used for animating into hold) float m_flNextAvoidBroadcastTime; // Next time we'll warn entity to move out of us diff --git a/sp/src/game/server/explode.cpp b/sp/src/game/server/explode.cpp index 42d8df35..186c0997 100644 --- a/sp/src/game/server/explode.cpp +++ b/sp/src/game/server/explode.cpp @@ -111,6 +111,9 @@ public: // Input handlers void InputExplode( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetIgnoredEntity( inputdata_t &inputdata ); +#endif DECLARE_DATADESC(); @@ -150,6 +153,9 @@ BEGIN_DATADESC( CEnvExplosion ) // Inputs DEFINE_INPUTFUNC(FIELD_VOID, "Explode", InputExplode), +#ifdef MAPBASE + DEFINE_INPUTFUNC(FIELD_EHANDLE, "SetIgnoredEntity", InputSetIgnoredEntity), +#endif END_DATADESC() @@ -369,6 +375,16 @@ void CEnvExplosion::InputExplode( inputdata_t &inputdata ) } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Input handler for setting the ignored entity. +//----------------------------------------------------------------------------- +void CEnvExplosion::InputSetIgnoredEntity( inputdata_t &inputdata ) +{ + m_hEntityIgnore = inputdata.value.Entity(); +} +#endif + void CEnvExplosion::Smoke( void ) { diff --git a/sp/src/game/server/filters.cpp b/sp/src/game/server/filters.cpp index 6179254d..21d5c374 100644 --- a/sp/src/game/server/filters.cpp +++ b/sp/src/game/server/filters.cpp @@ -9,6 +9,12 @@ #include "entitylist.h" #include "ai_squad.h" #include "ai_basenpc.h" +#ifdef MAPBASE +#include "mapbase/matchers.h" +#include "AI_Criteria.h" +#include "ai_hint.h" +#include "mapbase/GlobalStrings.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -21,9 +27,16 @@ LINK_ENTITY_TO_CLASS(filter_base, CBaseFilter); BEGIN_DATADESC( CBaseFilter ) DEFINE_KEYFIELD(m_bNegated, FIELD_BOOLEAN, "Negated"), +#ifdef MAPBASE + DEFINE_KEYFIELD(m_bPassCallerWhenTested, FIELD_BOOLEAN, "PassCallerWhenTested"), +#endif // Inputs DEFINE_INPUTFUNC( FIELD_INPUT, "TestActivator", InputTestActivator ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_EHANDLE, "TestEntity", InputTestEntity ), + DEFINE_INPUTFUNC( FIELD_INPUT, "SetField", InputSetField ), +#endif // Outputs DEFINE_OUTPUT( m_OnPass, "OnPass"), @@ -46,17 +59,37 @@ bool CBaseFilter::PassesFilter( CBaseEntity *pCaller, CBaseEntity *pEntity ) } +#ifdef MAPBASE +bool CBaseFilter::PassesDamageFilter(CBaseEntity *pCaller, const CTakeDamageInfo &info) +{ + bool baseResult = PassesDamageFilterImpl(pCaller, info); + return (m_bNegated) ? !baseResult : baseResult; +} +#endif + bool CBaseFilter::PassesDamageFilter(const CTakeDamageInfo &info) { +#ifdef MAPBASE + Warning("WARNING: Deprecated usage of PassesDamageFilter!\n"); + bool baseResult = PassesDamageFilterImpl(NULL, info); +#else bool baseResult = PassesDamageFilterImpl(info); +#endif return (m_bNegated) ? !baseResult : baseResult; } +#ifdef MAPBASE +bool CBaseFilter::PassesDamageFilterImpl( CBaseEntity *pCaller, const CTakeDamageInfo &info ) +{ + return PassesFilterImpl( pCaller, info.GetAttacker() ); +} +#else bool CBaseFilter::PassesDamageFilterImpl( const CTakeDamageInfo &info ) { return PassesFilterImpl( NULL, info.GetAttacker() ); } +#endif //----------------------------------------------------------------------------- // Purpose: Input handler for testing the activator. If the activator passes the @@ -66,14 +99,49 @@ void CBaseFilter::InputTestActivator( inputdata_t &inputdata ) { if ( PassesFilter( inputdata.pCaller, inputdata.pActivator ) ) { +#ifdef MAPBASE + m_OnPass.FireOutput( inputdata.pActivator, m_bPassCallerWhenTested ? inputdata.pCaller : this ); +#else m_OnPass.FireOutput( inputdata.pActivator, this ); +#endif } else { +#ifdef MAPBASE + m_OnFail.FireOutput( inputdata.pActivator, m_bPassCallerWhenTested ? inputdata.pCaller : this ); +#else m_OnFail.FireOutput( inputdata.pActivator, this ); +#endif } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Input handler for testing the activator. If the activator passes the +// filter test, the OnPass output is fired. If not, the OnFail output is fired. +//----------------------------------------------------------------------------- +void CBaseFilter::InputTestEntity( inputdata_t &inputdata ) +{ + if ( PassesFilter( inputdata.pCaller, inputdata.value.Entity() ) ) + { + m_OnPass.FireOutput( inputdata.value.Entity(), m_bPassCallerWhenTested ? inputdata.pCaller : this ); + } + else + { + m_OnFail.FireOutput( inputdata.value.Entity(), m_bPassCallerWhenTested ? inputdata.pCaller : this ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Tries to set the filter's target since most filters use "filtername" anyway +//----------------------------------------------------------------------------- +void CBaseFilter::InputSetField( inputdata_t& inputdata ) +{ + KeyValue("filtername", inputdata.value.String()); + Activate(); +} +#endif + // ################################################################### // > FilterMultiple @@ -97,7 +165,11 @@ class CFilterMultiple : public CBaseFilter EHANDLE m_hFilter[MAX_FILTERS]; bool PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity ); +#ifdef MAPBASE + bool PassesDamageFilterImpl(CBaseEntity *pCaller, const CTakeDamageInfo &info); +#else bool PassesDamageFilterImpl(const CTakeDamageInfo &info); +#endif void Activate(void); }; @@ -198,7 +270,11 @@ bool CFilterMultiple::PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEnti // Purpose: Returns true if the entity passes our filter, false if not. // Input : pEntity - Entity to test. //----------------------------------------------------------------------------- +#ifdef MAPBASE +bool CFilterMultiple::PassesDamageFilterImpl(CBaseEntity *pCaller, const CTakeDamageInfo &info) +#else bool CFilterMultiple::PassesDamageFilterImpl(const CTakeDamageInfo &info) +#endif { // Test against each filter if (m_nFilterType == FILTER_AND) @@ -208,7 +284,11 @@ bool CFilterMultiple::PassesDamageFilterImpl(const CTakeDamageInfo &info) if (m_hFilter[i] != NULL) { CBaseFilter* pFilter = (CBaseFilter *)(m_hFilter[i].Get()); +#ifdef MAPBASE + if (!pFilter->PassesDamageFilter(pCaller, info)) +#else if (!pFilter->PassesDamageFilter(info)) +#endif { return false; } @@ -223,7 +303,11 @@ bool CFilterMultiple::PassesDamageFilterImpl(const CTakeDamageInfo &info) if (m_hFilter[i] != NULL) { CBaseFilter* pFilter = (CBaseFilter *)(m_hFilter[i].Get()); - if (pFilter->PassesDamageFilter(info)) +#ifdef MAPBASE + if (!pFilter->PassesDamageFilter(pCaller, info)) +#else + if (!pFilter->PassesDamageFilter(info)) +#endif { return true; } @@ -257,6 +341,14 @@ public: return pEntity->NameMatches( STRING(m_iFilterName) ); } } + +#ifdef MAPBASE + void InputSetField( inputdata_t& inputdata ) + { + inputdata.value.Convert(FIELD_STRING); + m_iFilterName = inputdata.value.StringID(); + } +#endif }; LINK_ENTITY_TO_CLASS( filter_activator_name, CFilterName ); @@ -285,6 +377,14 @@ public: { return pEntity->ClassMatches( STRING(m_iFilterClass) ); } + +#ifdef MAPBASE + void InputSetField( inputdata_t& inputdata ) + { + inputdata.value.Convert(FIELD_STRING); + m_iFilterClass = inputdata.value.StringID(); + } +#endif }; LINK_ENTITY_TO_CLASS( filter_activator_class, CFilterClass ); @@ -312,6 +412,14 @@ public: { return ( pEntity->GetTeamNumber() == m_iFilterTeam ); } + +#ifdef MAPBASE + void InputSetField( inputdata_t& inputdata ) + { + inputdata.value.Convert(FIELD_INTEGER); + m_iFilterTeam = inputdata.value.Int(); + } +#endif }; LINK_ENTITY_TO_CLASS( filter_activator_team, FilterTeam ); @@ -342,6 +450,14 @@ public: return ( pEntity->VPhysicsGetObject()->GetMass() > m_fFilterMass ); } + +#ifdef MAPBASE + void InputSetField( inputdata_t& inputdata ) + { + inputdata.value.Convert(FIELD_FLOAT); + m_fFilterMass = inputdata.value.Float(); + } +#endif }; LINK_ENTITY_TO_CLASS( filter_activator_mass_greater, CFilterMassGreater ); @@ -370,12 +486,58 @@ protected: return true; } +#ifdef MAPBASE + bool PassesDamageFilterImpl(CBaseEntity *pCaller, const CTakeDamageInfo &info) +#else bool PassesDamageFilterImpl(const CTakeDamageInfo &info) +#endif { +#ifdef MAPBASE + switch (m_iFilterType) + { + case 1: return (info.GetDamageType() & m_iDamageType) != 0; + case 2: + { + int iRecvDT = info.GetDamageType(); + int iOurDT = m_iDamageType; + while (iRecvDT) + { + if (iRecvDT & iOurDT) + return true; + + iRecvDT >>= 1; iOurDT >>= 1; + } + return false; + } break; + } +#endif return info.GetDamageType() == m_iDamageType; } +#ifdef MAPBASE + void InputSetField( inputdata_t& inputdata ) + { + inputdata.value.Convert(FIELD_INTEGER); + m_iDamageType = inputdata.value.Int(); + } + + bool KeyValue( const char *szKeyName, const char *szValue ) + { + if (FStrEq( szKeyName, "damageor" ) || FStrEq( szKeyName, "damagepresets" )) + { + m_iDamageType |= atoi( szValue ); + } + else + return BaseClass::KeyValue( szKeyName, szValue ); + + return true; + } +#endif + int m_iDamageType; +#ifdef MAPBASE + int m_iFilterType; +#endif }; LINK_ENTITY_TO_CLASS( filter_damage_type, FilterDamageType ); @@ -384,6 +546,9 @@ BEGIN_DATADESC( FilterDamageType ) // Keyfields DEFINE_KEYFIELD( m_iDamageType, FIELD_INTEGER, "damagetype" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_iFilterType, FIELD_INTEGER, "FilterType" ), +#endif END_DATADESC() @@ -403,7 +568,19 @@ class CFilterEnemy : public CBaseFilter public: virtual bool PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity ); - virtual bool PassesDamageFilterImpl( const CTakeDamageInfo &info ); +#ifdef MAPBASE + virtual bool PassesDamageFilterImpl(CBaseEntity *pCaller, const CTakeDamageInfo &info); +#else + virtual bool PassesDamageFilterImpl(const CTakeDamageInfo &info); +#endif + +#ifdef MAPBASE + void InputSetField( inputdata_t& inputdata ) + { + inputdata.value.Convert(FIELD_STRING); + m_iszEnemyName = inputdata.value.StringID(); + } +#endif private: @@ -415,7 +592,9 @@ private: float m_flRadius; // Radius (enemies are acquired at this range) float m_flOuterRadius; // Outer radius (enemies are LOST at this range) int m_nMaxSquadmatesPerEnemy; // Maximum number of squadmates who may share the same enemy +#ifndef MAPBASE string_t m_iszPlayerName; // "!player" +#endif }; //----------------------------------------------------------------------------- @@ -452,7 +631,11 @@ bool CFilterEnemy::PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- +#ifdef MAPBASE +bool CFilterEnemy::PassesDamageFilterImpl( CBaseEntity *pCaller, const CTakeDamageInfo &info ) +#else bool CFilterEnemy::PassesDamageFilterImpl( const CTakeDamageInfo &info ) +#endif { // NOTE: This function has no meaning to this implementation of the filter class! Assert( 0 ); @@ -470,6 +653,9 @@ bool CFilterEnemy::PassesNameFilter( CBaseEntity *pEnemy ) if ( m_iszEnemyName == NULL_STRING ) return true; +#ifdef MAPBASE + if ( m_iszEnemyName == gm_isz_name_player ) +#else // Cache off the special case player name if ( m_iszPlayerName == NULL_STRING ) { @@ -477,6 +663,7 @@ bool CFilterEnemy::PassesNameFilter( CBaseEntity *pEnemy ) } if ( m_iszEnemyName == m_iszPlayerName ) +#endif { if ( pEnemy->IsPlayer() ) { @@ -488,7 +675,11 @@ bool CFilterEnemy::PassesNameFilter( CBaseEntity *pEnemy ) } // May be either a targetname or classname +#ifdef MAPBASE + bool bNameOrClassnameMatches = ( pEnemy->NameMatches(STRING(m_iszEnemyName)) || pEnemy->ClassMatches(STRING(m_iszEnemyName)) ); +#else bool bNameOrClassnameMatches = ( m_iszEnemyName == pEnemy->GetEntityName() || m_iszEnemyName == pEnemy->m_iClassname ); +#endif // We only leave this code block in a state meaning we've "succeeded" in any context if ( m_bNegated ) @@ -626,6 +817,1151 @@ BEGIN_DATADESC( CFilterEnemy ) DEFINE_KEYFIELD( m_flRadius, FIELD_FLOAT, "filter_radius" ), DEFINE_KEYFIELD( m_flOuterRadius, FIELD_FLOAT, "filter_outer_radius" ), DEFINE_KEYFIELD( m_nMaxSquadmatesPerEnemy, FIELD_INTEGER, "filter_max_per_enemy" ), +#ifndef MAPBASE DEFINE_FIELD( m_iszPlayerName, FIELD_STRING ), +#endif END_DATADESC() + +#ifdef MAPBASE +// ################################################################### +// > CFilterModel +// ################################################################### +class CFilterModel : public CBaseFilter +{ + DECLARE_CLASS( CFilterModel, CBaseFilter ); + DECLARE_DATADESC(); + +public: + string_t m_iFilterModel; + string_t m_strFilterSkin; + + bool PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity ) + { + if (FStrEq(STRING(m_strFilterSkin), "-1") /*m_strFilterSkin == NULL_STRING|| FStrEq(STRING(m_strFilterSkin), "")*/) + return Matcher_NamesMatch(STRING(m_iFilterModel), STRING(pEntity->GetModelName())); + else if (pEntity->GetBaseAnimating()) + { + //DevMsg("Skin isn't null\n"); + return Matcher_NamesMatch(STRING(m_iFilterModel), STRING(pEntity->GetModelName())) && Matcher_Match(STRING(m_strFilterSkin), pEntity->GetBaseAnimating()->m_nSkin); + } + return false; + } + + void InputSetField( inputdata_t& inputdata ) + { + inputdata.value.Convert(FIELD_STRING); + m_iFilterModel = inputdata.value.StringID(); + } +}; + +LINK_ENTITY_TO_CLASS( filter_activator_model, CFilterModel ); + +BEGIN_DATADESC( CFilterModel ) + + // Keyfields + DEFINE_KEYFIELD( m_iFilterModel, FIELD_STRING, "filtermodel" ), + DEFINE_KEYFIELD( m_iFilterModel, FIELD_STRING, "filtername" ), + DEFINE_KEYFIELD( m_strFilterSkin, FIELD_STRING, "skin" ), + +END_DATADESC() + +// ################################################################### +// > CFilterContext +// ################################################################### +class CFilterContext : public CBaseFilter +{ + DECLARE_CLASS( CFilterContext, CBaseFilter ); + DECLARE_DATADESC(); + +public: + bool m_bAny; + + bool PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity ) + { + bool passes = false; + ResponseContext_t curcontext; + const char *contextvalue; + for (int i = 0; i < GetContextCount(); i++) + { + curcontext = m_ResponseContexts[i]; + if (!pEntity->HasContext(STRING(curcontext.m_iszName), NULL)) + { + if (m_bAny) + continue; + else + return false; + } + + contextvalue = pEntity->GetContextValue(STRING(curcontext.m_iszName)); + if (Matcher_NamesMatch(STRING(m_ResponseContexts[i].m_iszValue), contextvalue)) + { + passes = true; + if (m_bAny) + break; + } + else if (!m_bAny) + { + return false; + } + } + + return passes; + } + + void InputSetField( inputdata_t& inputdata ) + { + m_ResponseContexts.RemoveAll(); + AddContext(inputdata.value.String()); + } +}; + +LINK_ENTITY_TO_CLASS( filter_activator_context, CFilterContext ); + +BEGIN_DATADESC( CFilterContext ) + + // Keyfields + DEFINE_KEYFIELD( m_bAny, FIELD_BOOLEAN, "any" ), + +END_DATADESC() + +// ################################################################### +// > CFilterSquad +// ################################################################### +class CFilterSquad : public CBaseFilter +{ + DECLARE_CLASS( CFilterSquad, CBaseFilter ); + DECLARE_DATADESC(); + +public: + string_t m_iFilterName; + bool m_bAllowSilentSquadMembers; + + bool PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity ) + { + CAI_BaseNPC *pNPC = pEntity->MyNPCPointer(); + if (pEntity && pNPC) + { + if (pNPC->GetSquad() && Matcher_NamesMatch(STRING(m_iFilterName), pNPC->GetSquad()->GetName())) + { + if (CAI_Squad::IsSilentMember(pNPC)) + { + return m_bAllowSilentSquadMembers; + } + else + { + return true; + } + } + } + + return false; + } + + void InputSetField( inputdata_t& inputdata ) + { + inputdata.value.Convert(FIELD_STRING); + m_iFilterName = inputdata.value.StringID(); + } +}; + +LINK_ENTITY_TO_CLASS( filter_activator_squad, CFilterSquad ); + +BEGIN_DATADESC( CFilterSquad ) + + // Keyfields + DEFINE_KEYFIELD( m_iFilterName, FIELD_STRING, "filtername" ), + DEFINE_KEYFIELD( m_bAllowSilentSquadMembers, FIELD_BOOLEAN, "allowsilentmembers" ), + +END_DATADESC() + +// ################################################################### +// > CFilterHintGroup +// ################################################################### +class CFilterHintGroup : public CBaseFilter +{ + DECLARE_CLASS( CFilterHintGroup, CBaseFilter ); + DECLARE_DATADESC(); + +public: + string_t m_iFilterName; + ThreeState_t m_fHintLimiting; + + bool PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity ) + { + if (!pEntity) + return false; + + if (CAI_BaseNPC *pNPC = pEntity->MyNPCPointer()) + { + if (pNPC->GetHintGroup() == NULL_STRING || Matcher_NamesMatch(STRING(m_iFilterName), STRING(pNPC->GetHintGroup()))) + { + switch (m_fHintLimiting) + { + case TRS_FALSE: return !pNPC->IsLimitingHintGroups(); break; + case TRS_TRUE: return pNPC->IsLimitingHintGroups(); break; + } + + return true; + } + } + else if (CAI_Hint *pHint = dynamic_cast(pEntity)) + { + // Just in case someone somehow puts a hint node through a filter. + // Maybe they'd use a point_advanced_finder or something, I dunno. + return Matcher_NamesMatch(STRING(m_iFilterName), STRING(pHint->GetGroup())); + } + + return false; + } + + void InputSetField( inputdata_t& inputdata ) + { + inputdata.value.Convert(FIELD_STRING); + m_iFilterName = inputdata.value.StringID(); + } +}; + +LINK_ENTITY_TO_CLASS( filter_activator_hintgroup, CFilterHintGroup ); + +BEGIN_DATADESC( CFilterHintGroup ) + + // Keyfields + DEFINE_KEYFIELD( m_iFilterName, FIELD_STRING, "filtername" ), + DEFINE_KEYFIELD( m_fHintLimiting, FIELD_INTEGER, "hintlimiting" ), + +END_DATADESC() + +extern bool ReadUnregisteredKeyfields(CBaseEntity *pTarget, const char *szKeyName, variant_t *variant); + +// ################################################################### +// > CFilterKeyfield +// ################################################################### +class CFilterKeyfield : public CBaseFilter +{ + DECLARE_CLASS( CFilterKeyfield, CBaseFilter ); + DECLARE_DATADESC(); + +public: + string_t m_iFilterKey; + string_t m_iFilterValue; + + bool PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity ) + { + variant_t var; + bool found = (pEntity->ReadKeyField(STRING(m_iFilterKey), &var) || ReadUnregisteredKeyfields(pEntity, STRING(m_iFilterKey), &var)); + return m_iFilterValue != NULL_STRING ? Matcher_Match(STRING(m_iFilterValue), var.String()) : found; + } + + void InputSetField( inputdata_t& inputdata ) + { + inputdata.value.Convert(FIELD_STRING); + m_iFilterKey = inputdata.value.StringID(); + } +}; + +LINK_ENTITY_TO_CLASS( filter_activator_keyfield, CFilterKeyfield ); + +BEGIN_DATADESC( CFilterKeyfield ) + + // Keyfields + DEFINE_KEYFIELD( m_iFilterKey, FIELD_STRING, "keyname" ), + DEFINE_KEYFIELD( m_iFilterValue, FIELD_STRING, "value" ), + +END_DATADESC() + +// ################################################################### +// > CFilterRelationship +// ################################################################### +class CFilterRelationship : public CBaseFilter +{ + DECLARE_CLASS( CFilterKeyfield, CBaseFilter ); + DECLARE_DATADESC(); + +public: + Disposition_t m_iDisposition; + string_t m_iszPriority; // string_t to support matchers + bool m_bInvertTarget; + bool m_bReciprocal; + EHANDLE m_hTarget; + + bool RelationshipPasses(CBaseCombatCharacter *pBCC, CBaseEntity *pTarget) + { + if (!pBCC || !pTarget) + return m_iDisposition == D_NU; + + Disposition_t disposition = pBCC->IRelationType(pTarget); + int priority = pBCC->IRelationPriority(pTarget); + + bool passes = (disposition == m_iDisposition); + if (!passes) + return false; + + if (m_iszPriority != NULL_STRING) + { + passes = Matcher_Match(STRING(m_iszPriority), priority); + } + + return passes; + } + + bool PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity ) + { + CBaseEntity *pSubject = NULL; + if (m_target != NULL_STRING) + { + if (!m_hTarget) + { + m_hTarget = gEntList.FindEntityGeneric(NULL, STRING(m_target), pCaller, pEntity, pCaller); + } + pSubject = m_hTarget; + } + + if (!pSubject) + pSubject = pCaller; + + // No subject or entity, cannot continue + if (!pSubject || !pEntity) + return m_iDisposition == D_NU; + + CBaseCombatCharacter *pBCC1 = !m_bInvertTarget ? pSubject->MyCombatCharacterPointer() : pEntity->MyCombatCharacterPointer(); + CBaseEntity *pTarget = m_bInvertTarget ? pSubject : pEntity; + if (!pBCC1) + { + //Warning("Error: %s subject %s is not a character that uses relationships!\n", GetDebugName(), !m_bInvertTarget ? pSubject->GetDebugName() : pEntity->GetDebugName()); + return m_iDisposition == D_NU; + } + + bool passes = RelationshipPasses(pBCC1, pTarget); + if (m_bReciprocal) + passes = RelationshipPasses(pTarget->MyCombatCharacterPointer(), pBCC1); + + return passes; + } + + void InputSetField( inputdata_t& inputdata ) + { + inputdata.value.Convert(FIELD_STRING); + m_target = inputdata.value.StringID(); + } +}; + +LINK_ENTITY_TO_CLASS( filter_activator_relationship, CFilterRelationship ); + +BEGIN_DATADESC( CFilterRelationship ) + + // Keyfields + DEFINE_KEYFIELD( m_iDisposition, FIELD_INTEGER, "disposition" ), + DEFINE_KEYFIELD( m_iszPriority, FIELD_STRING, "rank" ), + DEFINE_KEYFIELD( m_bInvertTarget, FIELD_BOOLEAN, "inverttarget" ), + DEFINE_KEYFIELD( m_bReciprocal, FIELD_BOOLEAN, "Reciprocal" ), + DEFINE_FIELD( m_hTarget, FIELD_EHANDLE ), + +END_DATADESC() + +// ################################################################### +// > CFilterClassify +// ################################################################### +class CFilterClassify : public CBaseFilter +{ + DECLARE_CLASS( CFilterClassify, CBaseFilter ); + DECLARE_DATADESC(); + +public: + Class_T m_iFilterClassify; + + bool PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity ) + { + return pEntity->Classify() == m_iFilterClassify; + } + + void InputSetField( inputdata_t& inputdata ) + { + inputdata.value.Convert(FIELD_INTEGER); + m_iFilterClassify = (Class_T)inputdata.value.Int(); + } +}; + +LINK_ENTITY_TO_CLASS( filter_activator_classify, CFilterClassify ); + +BEGIN_DATADESC( CFilterClassify ) + + // Keyfields + DEFINE_KEYFIELD( m_iFilterClassify, FIELD_INTEGER, "filterclassify" ), + +END_DATADESC() + +// ################################################################### +// > CFilterCriteria +// ################################################################### +class CFilterCriteria : public CBaseFilter +{ + DECLARE_CLASS( CFilterCriteria, CBaseFilter ); + DECLARE_DATADESC(); + +public: + bool m_bAny; + bool m_bFull; // All criteria functions are gathered + + bool PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity ) + { + if (!pEntity) + return false; + + AI_CriteriaSet set; + pEntity->ModifyOrAppendCriteria( set ); + if (m_bFull) + { + // Meeets the full wrath of the response criteria + CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); + if( pPlayer ) + pPlayer->ModifyOrAppendPlayerCriteria( set ); + + pEntity->ReAppendContextCriteria( set ); + } + + bool passes = false; + const char *contextname; + const char *contextvalue; + const char *matchingvalue; + for (int i = 0; i < set.GetCount(); i++) + { + contextname = set.GetName(i); + contextvalue = set.GetValue(i); + + matchingvalue = GetContextValue(contextname); + if (matchingvalue == NULL) + { + if (m_bAny) + continue; + else + return false; + } + else + { + if (Matcher_NamesMatch(matchingvalue, contextvalue)) + { + passes = true; + if (m_bAny) + break; + } + else if (!m_bAny) + { + return false; + } + } + } + + return passes; + } + + void InputSetField( inputdata_t& inputdata ) + { + m_ResponseContexts.RemoveAll(); + AddContext(inputdata.value.String()); + } +}; + +LINK_ENTITY_TO_CLASS( filter_activator_criteria, CFilterCriteria ); + +BEGIN_DATADESC( CFilterCriteria ) + + // Keyfields + DEFINE_KEYFIELD( m_bAny, FIELD_BOOLEAN, "any" ), + DEFINE_KEYFIELD( m_bFull, FIELD_BOOLEAN, "full" ), + +END_DATADESC() + +extern bool TestEntityTriggerIntersection_Accurate( CBaseEntity *pTrigger, CBaseEntity *pEntity ); + +// ################################################################### +// > CFilterInVolume +// Passes when the entity is within the specified volume. +// ################################################################### +class CFilterInVolume : public CBaseFilter +{ + DECLARE_CLASS( CFilterInVolume, CBaseFilter ); + DECLARE_DATADESC(); + +public: + string_t m_iszVolumeTester; + + void Spawn() + { + BaseClass::Spawn(); + + // Assume no string = use activator + if (m_iszVolumeTester == NULL_STRING) + m_iszVolumeTester = AllocPooledString("!activator"); + } + + bool PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity ) + { + CBaseEntity *pVolume = gEntList.FindEntityByNameNearest(STRING(m_target), pEntity->GetLocalOrigin(), 0, this, pEntity, pCaller); + if (!pVolume) + { + Msg("%s cannot find volume %s\n", GetDebugName(), STRING(m_target)); + return false; + } + + CBaseEntity *pTarget = gEntList.FindEntityByName(NULL, STRING(m_iszVolumeTester), this, pEntity, pCaller); + if (pTarget) + return TestEntityTriggerIntersection_Accurate(pVolume, pTarget); + else + { + Msg("%s cannot find target entity %s, returning false\n", STRING(m_iszVolumeTester)); + return false; + } + } + + void InputSetField( inputdata_t& inputdata ) + { + inputdata.value.Convert(FIELD_STRING); + m_iszVolumeTester = inputdata.value.StringID(); + } +}; + +LINK_ENTITY_TO_CLASS( filter_activator_involume, CFilterInVolume ); + +BEGIN_DATADESC( CFilterInVolume ) + + // Keyfields + DEFINE_KEYFIELD( m_iszVolumeTester, FIELD_STRING, "tester" ), + +END_DATADESC() + +// ################################################################### +// > CFilterSurfaceProp +// ################################################################### +class CFilterSurfaceData : public CBaseFilter +{ + DECLARE_CLASS( CFilterSurfaceData, CBaseFilter ); + DECLARE_DATADESC(); + +public: + string_t m_iFilterSurface; + int m_iSurfaceIndex; + + enum + { + SURFACETYPE_SURFACEPROP, + SURFACETYPE_GAMEMATERIAL, + }; + + // Gets the surfaceprop's game material and filters by that. + int m_iSurfaceType; + + void ParseSurfaceIndex() + { + m_iSurfaceIndex = physprops->GetSurfaceIndex(STRING(m_iFilterSurface)); + + switch (m_iSurfaceType) + { + case SURFACETYPE_GAMEMATERIAL: + { + const surfacedata_t *pSurfaceData = physprops->GetSurfaceData(m_iSurfaceIndex); + if (pSurfaceData) + m_iSurfaceIndex = pSurfaceData->game.material; + else + Warning("Can't get surface data for %s\n", STRING(m_iFilterSurface)); + } break; + } + } + + void Activate() + { + ParseSurfaceIndex(); + } + + bool PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity ) + { + if (pEntity->VPhysicsGetObject()) + { + int iMatIndex = pEntity->VPhysicsGetObject()->GetMaterialIndex(); + switch (m_iSurfaceType) + { + case SURFACETYPE_GAMEMATERIAL: + { + const surfacedata_t *pSurfaceData = physprops->GetSurfaceData(iMatIndex); + if (pSurfaceData) + return m_iSurfaceIndex == pSurfaceData->game.material; + } + default: + return iMatIndex == m_iSurfaceIndex; + } + } + + return false; + } + + void InputSetField( inputdata_t& inputdata ) + { + inputdata.value.Convert(FIELD_STRING); + m_iFilterSurface = inputdata.value.StringID(); + ParseSurfaceIndex(); + } +}; + +LINK_ENTITY_TO_CLASS( filter_activator_surfacedata, CFilterSurfaceData ); + +BEGIN_DATADESC( CFilterSurfaceData ) + + // Keyfields + DEFINE_KEYFIELD( m_iFilterSurface, FIELD_STRING, "filterstring" ), + DEFINE_KEYFIELD( m_iSurfaceType, FIELD_INTEGER, "SurfaceType" ), + +END_DATADESC() + +// =================================================================== +// Redirect filters +// +// Redirects certain data to a specific filter. +// =================================================================== +class CBaseFilterRedirect : public CBaseFilter +{ + DECLARE_CLASS( CBaseFilterRedirect, CBaseFilter ); + +public: + inline CBaseEntity *GetTargetFilter() + { + // Yes, this hijacks damage filter functionality. + // It's not like it was using it before anyway. + return m_hDamageFilter.Get(); + } + + bool RedirectToFilter( CBaseEntity *pCaller, CBaseEntity *pEntity ) + { + if (GetTargetFilter()) + { + CBaseFilter *pFilter = static_cast(GetTargetFilter()); + return pFilter->PassesFilter(pCaller, pEntity); + } + + return false; + } + + bool RedirectToDamageFilter( CBaseEntity *pCaller, const CTakeDamageInfo &info ) + { + if (GetTargetFilter()) + { + CBaseFilter *pFilter = static_cast(GetTargetFilter()); + return pFilter->PassesDamageFilter(pCaller, info); + } + + return false; + } + + virtual bool PassesDamageFilterImpl( CBaseEntity *pCaller, const CTakeDamageInfo &info ) + { + return RedirectToDamageFilter( pCaller, info ); + } + + virtual bool PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity ) + { + return RedirectToFilter( pCaller, pEntity ); + } + + virtual bool BloodAllowed( CBaseEntity *pCaller, const CTakeDamageInfo &info ) + { + if (GetTargetFilter()) + { + CBaseFilter *pFilter = static_cast(GetTargetFilter()); + return pFilter->BloodAllowed(pCaller, info); + } + + return true; + } + + virtual bool DamageMod( CBaseEntity *pCaller, CTakeDamageInfo &info ) + { + if (GetTargetFilter()) + { + CBaseFilter *pFilter = static_cast(GetTargetFilter()); + return pFilter->DamageMod( pCaller, info ); + } + + return true; + } + + void InputSetField( inputdata_t& inputdata ) + { + inputdata.value.Convert(FIELD_STRING); + InputSetDamageFilter(inputdata); + } + + enum + { + REDIRECT_MUST_PASS_TO_DAMAGE_CALLER, // Must pass to damage caller, if damage is allowed + REDIRECT_MUST_PASS_TO_ACT, // Must pass to do action + REDIRECT_MUST_PASS_ACTIVATORS, // Each activator must pass this filter + }; +}; + +// ################################################################### +// > CFilterRedirectInflictor +// Uses the specified filter to filter by damage inflictor. +// ################################################################### +class CFilterRedirectInflictor : public CBaseFilterRedirect +{ + DECLARE_CLASS( CFilterRedirectInflictor, CBaseFilterRedirect ); + +public: + bool PassesDamageFilterImpl( CBaseEntity *pCaller, const CTakeDamageInfo &info ) + { + return RedirectToFilter(pCaller, info.GetInflictor()); + } +}; + +LINK_ENTITY_TO_CLASS( filter_redirect_inflictor, CFilterRedirectInflictor ); + +// ################################################################### +// > CFilterRedirectWeapon +// Uses the specified filter to filter by either the entity's active weapon or the weapon causing damage, +// depending on the context. +// ################################################################### +class CFilterRedirectWeapon : public CBaseFilterRedirect +{ + DECLARE_CLASS( CFilterRedirectWeapon, CBaseFilterRedirect ); + +public: + bool PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity ) + { + CBaseCombatCharacter *pBCC = pEntity->MyCombatCharacterPointer(); + if (pBCC && pBCC->GetActiveWeapon()) + { + return RedirectToFilter( pCaller, pBCC->GetActiveWeapon() ); + } + + return false; + } + + bool PassesDamageFilterImpl( CBaseEntity *pCaller, const CTakeDamageInfo &info ) + { + // Pass any weapon found in the damage info + if (info.GetWeapon()) + { + return RedirectToFilter( pCaller, info.GetWeapon() ); + } + + // Check the attacker's active weapon instead + if (info.GetAttacker()) + { + return PassesFilterImpl( pCaller, info.GetAttacker() ); + } + + // No weapon to check + return false; + } +}; + +LINK_ENTITY_TO_CLASS( filter_redirect_weapon, CFilterRedirectWeapon ); + +// ################################################################### +// > CFilterRedirectOwner +// Uses the specified filter to filter by owner entity. +// ################################################################### +class CFilterRedirectOwner : public CBaseFilterRedirect +{ + DECLARE_CLASS( CFilterRedirectOwner, CBaseFilterRedirect ); + +public: + bool PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity ) + { + if (pEntity->GetOwnerEntity()) + { + return RedirectToFilter(pCaller, pEntity->GetOwnerEntity()); + } + + return false; + } +}; + +LINK_ENTITY_TO_CLASS( filter_redirect_owner, CFilterRedirectOwner ); + +// ################################################################### +// > CFilterDamageTransfer +// Transfers damage to another entity. +// ################################################################### +class CFilterDamageTransfer : public CBaseFilterRedirect +{ + DECLARE_CLASS( CFilterDamageTransfer, CBaseFilterRedirect ); + DECLARE_DATADESC(); + +public: + void Spawn() + { + BaseClass::Spawn(); + + // Assume no string = use activator + if (m_target == NULL_STRING) + m_target = AllocPooledString("!activator"); + + // A number less than or equal to 0 is always synonymous with no limit + if (m_iMaxEntities <= 0) + m_iMaxEntities = MAX_EDICTS; + } + + // Some secondary filter modes shouldn't be used in non-final filter passes + // Always return true on non-standard secondary filter modes + /* + bool PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity ) + { + return true; + } + */ + + // A hack because of the way final damage filtering now works. + bool BloodAllowed( CBaseEntity *pCaller, const CTakeDamageInfo &info ) + { + if (!m_bCallerDamageAllowed) + return false; + else + return m_iSecondaryFilterMode == REDIRECT_MUST_PASS_TO_DAMAGE_CALLER && GetTargetFilter() ? RedirectToDamageFilter(pCaller, info) : true; + } + + // PassesFinalDamageFilter() was created for the express purpose of having filter_damage_transfer function without + // passing damage on filter checks that don't actually lead to us taking damage in the first place. + // PassesFinalDamageFilter() is only called in certain base entity functions where we DEFINITELY will take damage otherwise. + bool PassesFinalDamageFilter( CBaseEntity *pCaller, const CTakeDamageInfo &info ) + { + if (m_iSecondaryFilterMode == REDIRECT_MUST_PASS_TO_ACT) + { + // Transfer only if the secondary filter passes + if (!RedirectToDamageFilter(pCaller, info)) + { + // Otherwise just return the other flag + return m_bCallerDamageAllowed; + } + } + + CBaseEntity *pTarget = gEntList.FindEntityGeneric(NULL, STRING(m_target), this, info.GetAttacker(), pCaller); + int iNumDamaged = 0; + while (pTarget) + { + // Avoid recursive loops! + if (pTarget->m_hDamageFilter != this) + { + CTakeDamageInfo info2 = info; + + // Adjust damage position stuff + if (m_bAdjustDamagePosition) + { + info2.SetDamagePosition(pTarget->GetAbsOrigin() + (pCaller->GetAbsOrigin() - info.GetDamagePosition())); + + if (pCaller->IsCombatCharacter() && pTarget->IsCombatCharacter()) + pTarget->MyCombatCharacterPointer()->SetLastHitGroup(pCaller->MyCombatCharacterPointer()->LastHitGroup()); + } + + if (m_iSecondaryFilterMode != REDIRECT_MUST_PASS_ACTIVATORS || RedirectToFilter(pCaller, pTarget)) + { + pTarget->TakeDamage(info2); + iNumDamaged++; + } + } + + if (iNumDamaged < m_iMaxEntities) + pTarget = gEntList.FindEntityGeneric(pTarget, STRING(m_target), this, info.GetAttacker(), pCaller); + else + break; + } + + // We've transferred the damage, now determine whether the caller should take damage. + // Boolean surpasses all. + if (!m_bCallerDamageAllowed) + return false; + else + return m_iSecondaryFilterMode == REDIRECT_MUST_PASS_TO_DAMAGE_CALLER && GetTargetFilter() ? RedirectToDamageFilter(pCaller, info) : true; + } + + /* + void InputSetTarget( inputdata_t& inputdata ) + { + m_target = inputdata.value.StringID(); + m_hTarget = NULL; + } + */ + + inline CBaseEntity *GetTarget(CBaseEntity *pCaller, CBaseEntity *pActivator) + { + return gEntList.FindEntityGeneric(NULL, STRING(m_target), this, pActivator, pCaller); + } + + //EHANDLE m_hTarget; + + bool m_bAdjustDamagePosition; + + // See CBaseRedirectFilter enum for more info + int m_iSecondaryFilterMode; + + // If enabled, the caller can be damaged after the transfer. If disabled, the caller cannot. + bool m_bCallerDamageAllowed; + + int m_iMaxEntities = MAX_EDICTS; +}; + +LINK_ENTITY_TO_CLASS( filter_damage_transfer, CFilterDamageTransfer ); + +BEGIN_DATADESC( CFilterDamageTransfer ) + + //DEFINE_FIELD( m_hTarget, FIELD_EHANDLE ), + DEFINE_KEYFIELD( m_bAdjustDamagePosition, FIELD_BOOLEAN, "AdjustDamagePosition" ), + DEFINE_KEYFIELD( m_iMaxEntities, FIELD_INTEGER, "MaxEntities" ), + DEFINE_KEYFIELD( m_iSecondaryFilterMode, FIELD_INTEGER, "SecondaryFilterMode" ), + DEFINE_KEYFIELD( m_bCallerDamageAllowed, FIELD_BOOLEAN, "CallerDamageAllowed" ), + +END_DATADESC() + +// ################################################################### +// > CFilterBloodControl +// Takes advantage of hacks created for filter_damage_transfer to control blood. +// ################################################################### +class CFilterBloodControl : public CBaseFilterRedirect +{ + DECLARE_CLASS( CFilterBloodControl, CBaseFilterRedirect ); + DECLARE_DATADESC(); +public: + bool PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity ) + { + if (GetTargetFilter() && m_bSecondaryFilterIsDamageFilter) + return RedirectToFilter(pCaller, pEntity); + + return true; + } + + bool BloodAllowed( CBaseEntity *pCaller, const CTakeDamageInfo &info ) + { + if (m_bBloodDisabled) + return false; + + return GetTargetFilter() ? RedirectToDamageFilter(pCaller, info) : true; + } + + void InputDisableBlood( inputdata_t &inputdata ) { m_bBloodDisabled = true; } + void InputEnableBlood( inputdata_t &inputdata ) { m_bBloodDisabled = false; } + + bool m_bBloodDisabled; + + // Uses the secondary filter as a damage filter instead of just a blood filter + bool m_bSecondaryFilterIsDamageFilter; +}; + +LINK_ENTITY_TO_CLASS( filter_blood_control, CFilterBloodControl ); + +BEGIN_DATADESC( CFilterBloodControl ) + + DEFINE_KEYFIELD( m_bBloodDisabled, FIELD_BOOLEAN, "BloodDisabled" ), + DEFINE_KEYFIELD( m_bSecondaryFilterIsDamageFilter, FIELD_BOOLEAN, "SecondaryFilterMode" ), + + DEFINE_INPUTFUNC( FIELD_VOID, "DisableBlood", InputDisableBlood ), + DEFINE_INPUTFUNC( FIELD_VOID, "EnableBlood", InputEnableBlood ), + +END_DATADESC() + +// ################################################################### +// > CFilterDamageMod +// Modifies damage. +// ################################################################### +class CFilterDamageMod : public CBaseFilterRedirect +{ + DECLARE_CLASS( CFilterDamageMod, CBaseFilterRedirect ); + DECLARE_DATADESC(); +public: + bool PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity ) + { + if (GetTargetFilter() && m_iSecondaryFilterMode == REDIRECT_MUST_PASS_TO_DAMAGE_CALLER) + return RedirectToFilter(pCaller, pEntity); + + return true; + } + + bool DamageMod( CBaseEntity *pCaller, CTakeDamageInfo &info ) + { + if (GetTargetFilter()) + { + bool bPass = true; + + switch (m_iSecondaryFilterMode) + { + case REDIRECT_MUST_PASS_TO_DAMAGE_CALLER: + case REDIRECT_MUST_PASS_TO_ACT: bPass = (RedirectToDamageFilter(pCaller, info)); + + case REDIRECT_MUST_PASS_ACTIVATORS: bPass = (info.GetAttacker() && RedirectToFilter(pCaller, info.GetAttacker())); + } + + if (!bPass) + return false; + } + + info.ScaleDamage(m_flDamageMultiplier); + info.AddDamage(m_flDamageAddend); + + if (m_iszNewAttacker != NULL_STRING) + { + if (!m_hNewAttacker) + m_hNewAttacker = gEntList.FindEntityByName(NULL, m_iszNewAttacker, this, info.GetAttacker(), pCaller); + info.SetAttacker(m_hNewAttacker); + } + if (m_iszNewInflictor != NULL_STRING) + { + if (!m_hNewInflictor) + m_hNewInflictor = gEntList.FindEntityByName(NULL, m_iszNewInflictor, this, info.GetAttacker(), pCaller); + info.SetInflictor(m_hNewInflictor); + } + if (m_iszNewWeapon != NULL_STRING) + { + if (!m_hNewWeapon) + m_hNewWeapon = gEntList.FindEntityByName(NULL, m_iszNewWeapon, this, info.GetAttacker(), pCaller); + info.SetWeapon(m_hNewWeapon); + } + + return true; + } + + void InputSetNewAttacker( inputdata_t &inputdata ) { m_iszNewAttacker = inputdata.value.StringID(); m_hNewAttacker = NULL; } + void InputSetNewInflictor( inputdata_t &inputdata ) { m_iszNewInflictor = inputdata.value.StringID(); m_hNewInflictor = NULL; } + void InputSetNewWeapon( inputdata_t &inputdata ) { m_iszNewWeapon = inputdata.value.StringID(); m_hNewWeapon = NULL; } + + float m_flDamageMultiplier = 1.0f; + float m_flDamageAddend; + + string_t m_iszNewAttacker; EHANDLE m_hNewAttacker; + string_t m_iszNewInflictor; EHANDLE m_hNewInflictor; + string_t m_iszNewWeapon; EHANDLE m_hNewWeapon; + + // See CBaseRedirectFilter enum for more info + int m_iSecondaryFilterMode; +}; + +LINK_ENTITY_TO_CLASS( filter_damage_mod, CFilterDamageMod ); + +BEGIN_DATADESC( CFilterDamageMod ) + + DEFINE_KEYFIELD( m_iszNewAttacker, FIELD_STRING, "NewAttacker" ), + DEFINE_KEYFIELD( m_iszNewInflictor, FIELD_STRING, "NewInflictor" ), + DEFINE_KEYFIELD( m_iszNewWeapon, FIELD_STRING, "NewWeapon" ), + DEFINE_FIELD( m_hNewAttacker, FIELD_EHANDLE ), + DEFINE_FIELD( m_hNewInflictor, FIELD_EHANDLE ), + DEFINE_FIELD( m_hNewWeapon, FIELD_EHANDLE ), + + DEFINE_INPUT( m_flDamageMultiplier, FIELD_FLOAT, "SetDamageMultiplier" ), + DEFINE_INPUT( m_flDamageAddend, FIELD_FLOAT, "SetDamageAddend" ), + + DEFINE_KEYFIELD( m_iSecondaryFilterMode, FIELD_INTEGER, "SecondaryFilterMode" ), + + DEFINE_INPUTFUNC( FIELD_STRING, "SetNewAttacker", InputSetNewAttacker ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetNewInflictor", InputSetNewInflictor ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetNewWeapon", InputSetNewWeapon ), + +END_DATADESC() + +// ################################################################### +// > CFilterDamageLogic +// Fires outputs from damage information. +// ################################################################### +class CFilterDamageLogic : public CBaseFilterRedirect +{ + DECLARE_CLASS( CFilterDamageLogic, CBaseFilterRedirect ); + DECLARE_DATADESC(); +public: + bool PassesFinalDamageFilter( CBaseEntity *pCaller, const CTakeDamageInfo &info ) + { + bool bPassesFilter = !GetTargetFilter() || RedirectToDamageFilter( pCaller, info ); + if (!bPassesFilter) + { + if (m_iSecondaryFilterMode == 2) + return true; + else if (m_iSecondaryFilterMode != 1) + return false; + } + + CBaseEntity *pActivator = info.GetAttacker(); + + m_OutInflictor.Set( info.GetInflictor(), pActivator, pCaller ); + m_OutAttacker.Set( info.GetAttacker(), pActivator, pCaller ); + m_OutWeapon.Set( info.GetWeapon(), pActivator, pCaller ); + + m_OutDamage.Set( info.GetDamage(), pActivator, pCaller ); + m_OutMaxDamage.Set( info.GetMaxDamage(), pActivator, pCaller ); + m_OutBaseDamage.Set( info.GetBaseDamage(), pActivator, pCaller ); + + m_OutDamageType.Set( info.GetDamageType(), pActivator, pCaller ); + m_OutDamageCustom.Set( info.GetDamageCustom(), pActivator, pCaller ); + m_OutDamageStats.Set( info.GetDamageStats(), pActivator, pCaller ); + m_OutAmmoType.Set( info.GetAmmoType(), pActivator, pCaller ); + + m_OutDamageForce.Set( info.GetDamageForce(), pActivator, pCaller ); + m_OutDamagePosition.Set( info.GetDamagePosition(), pActivator, pCaller ); + + m_OutForceFriendlyFire.Set( info.IsForceFriendlyFire() ? 1 : 0, pActivator, pCaller ); + + return bPassesFilter; + } + + bool PassesDamageFilterImpl( CBaseEntity *pCaller, const CTakeDamageInfo &info ) + { + if (GetTargetFilter() && m_iSecondaryFilterMode != 2) + return RedirectToDamageFilter( pCaller, info ); + + return true; + } + + bool PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity ) + { + if (GetTargetFilter() && m_iSecondaryFilterMode != 2) + return RedirectToFilter( pCaller, pEntity ); + + return true; + } + + // 0 = Use as a regular damage filter. If it doesn't pass, damage won't be outputted. + // 1 = Fire outputs even if the secondary filter doesn't pass. + // 2 = Only use the secondary filter for whether to output damage, other damage is actually dealt. + int m_iSecondaryFilterMode; + + // Outputs + COutputEHANDLE m_OutInflictor; + COutputEHANDLE m_OutAttacker; + COutputEHANDLE m_OutWeapon; + + COutputFloat m_OutDamage; + COutputFloat m_OutMaxDamage; + COutputFloat m_OutBaseDamage; + + COutputInt m_OutDamageType; + COutputInt m_OutDamageCustom; + COutputInt m_OutDamageStats; + COutputInt m_OutAmmoType; + + COutputVector m_OutDamageForce; + COutputPositionVector m_OutDamagePosition; + + COutputInt m_OutForceFriendlyFire; +}; + +LINK_ENTITY_TO_CLASS( filter_damage_logic, CFilterDamageLogic ); + +BEGIN_DATADESC( CFilterDamageLogic ) + + DEFINE_KEYFIELD( m_iSecondaryFilterMode, FIELD_INTEGER, "SecondaryFilterMode" ), + + // Outputs + DEFINE_OUTPUT( m_OutInflictor, "OutInflictor" ), + DEFINE_OUTPUT( m_OutAttacker, "OutAttacker" ), + DEFINE_OUTPUT( m_OutWeapon, "OutWeapon" ), + + DEFINE_OUTPUT( m_OutDamage, "OutDamage" ), + DEFINE_OUTPUT( m_OutMaxDamage, "OutMaxDamage" ), + DEFINE_OUTPUT( m_OutBaseDamage, "OutBaseDamage" ), + + DEFINE_OUTPUT( m_OutDamageType, "OutDamageType" ), + DEFINE_OUTPUT( m_OutDamageCustom, "OutDamageCustom" ), + DEFINE_OUTPUT( m_OutDamageStats, "OutDamageStats" ), + DEFINE_OUTPUT( m_OutAmmoType, "OutAmmoType" ), + + DEFINE_OUTPUT( m_OutDamageForce, "OutDamageForce" ), + DEFINE_OUTPUT( m_OutDamagePosition, "OutDamagePosition" ), + + DEFINE_OUTPUT( m_OutForceFriendlyFire, "OutForceFriendlyFire" ), + +END_DATADESC() +#endif diff --git a/sp/src/game/server/filters.h b/sp/src/game/server/filters.h index 483de243..46345f51 100644 --- a/sp/src/game/server/filters.h +++ b/sp/src/game/server/filters.h @@ -40,13 +40,34 @@ public: DECLARE_DATADESC(); bool PassesFilter( CBaseEntity *pCaller, CBaseEntity *pEntity ); +#ifdef MAPBASE + bool PassesDamageFilter( CBaseEntity *pCaller, const CTakeDamageInfo &info ); + + // This was made for filter_damage_transfer. Should return true on all other filters. + virtual bool PassesFinalDamageFilter( CBaseEntity *pCaller, const CTakeDamageInfo &info ) { return true; } + + virtual bool BloodAllowed( CBaseEntity *pCaller, const CTakeDamageInfo &info ) { return true; } + + virtual bool DamageMod( CBaseEntity *pCaller, CTakeDamageInfo &info ) { return false; } + + // Deprecated. Pass the caller in front. bool PassesDamageFilter( const CTakeDamageInfo &info ); +#else + bool PassesDamageFilter( const CTakeDamageInfo &info ); +#endif bool m_bNegated; // Inputs void InputTestActivator( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputTestEntity( inputdata_t &inputdata ); + virtual void InputSetField( inputdata_t &inputdata ); + + bool m_bPassCallerWhenTested; +#endif + // Outputs COutputEvent m_OnPass; // Fired when filter is passed COutputEvent m_OnFail; // Fired when filter is failed @@ -54,7 +75,49 @@ public: protected: virtual bool PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity ); +#ifdef MAPBASE + virtual bool PassesDamageFilterImpl(CBaseEntity *pCaller, const CTakeDamageInfo &info); +#else virtual bool PassesDamageFilterImpl(const CTakeDamageInfo &info); +#endif }; +#ifdef MAPBASE +//========================================================= +// Trace filter that uses a filter entity. +// If the regular trace filter stuff tells this trace to hit an entity, it will go through a filter entity. +// If the entity passes the filter, the trace will go through. +// This can be negated with m_bHitIfPassed, meaning entities that pass will be hit. +// Use m_bFilterExclusive to make the filter the sole factor in hitting an entity. +//========================================================= +class CTraceFilterEntityFilter : public CTraceFilterSimple +{ +public: + CTraceFilterEntityFilter( const IHandleEntity *passentity, int collisionGroup ) : CTraceFilterSimple( passentity, collisionGroup ) {} + CTraceFilterEntityFilter( int collisionGroup ) : CTraceFilterSimple( NULL, collisionGroup ) {} + + bool ShouldHitEntity( IHandleEntity *pHandleEntity, int contentsMask ) + { + bool base = CTraceFilterSimple::ShouldHitEntity( pHandleEntity, contentsMask ); + CBaseEntity *pEntity = EntityFromEntityHandle( pHandleEntity ); + + if (m_bFilterExclusive && m_pFilter) + return m_pFilter->PassesFilter(m_pCaller, pEntity) ? m_bHitIfPassed : !m_bHitIfPassed; + else if (m_pFilter && (base ? !m_bHitIfPassed : m_bHitIfPassed)) + { + return m_bHitIfPassed ? m_pFilter->PassesFilter(m_pCaller, pEntity) : !m_pFilter->PassesFilter(m_pCaller, pEntity); + } + + return base; + } + + CBaseFilter *m_pFilter; + CBaseEntity *m_pCaller; + + bool m_bHitIfPassed; + bool m_bFilterExclusive; + +}; +#endif + #endif // FILTERS_H diff --git a/sp/src/game/server/fire.cpp b/sp/src/game/server/fire.cpp index ee5fd24c..a4fb9720 100644 --- a/sp/src/game/server/fire.cpp +++ b/sp/src/game/server/fire.cpp @@ -17,11 +17,16 @@ #include "ispatialpartition.h" #include "collisionutils.h" #include "tier0/vprof.h" +#ifdef MAPBASE +#include "weapon_flaregun.h" +#include "mapbase/GlobalStrings.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" +#ifndef MAPBASE /******************************************************************** NOTE: if you are looking at this file becase you would like flares to be considered as fires (and thereby trigger gas traps), be aware @@ -40,7 +45,13 @@ For some partial work towards this end, see changelist 192474. ********************************************************************/ - +#else +// ================================================================ // +// env_firesensors now have the ability to sense flares, toggled via spawnflag. +// This is different from integrating it with the greater fire system and easily preserves original behavior. +// You could try treating flares as real fires yourself if you think it's an issue. +// ================================================================ // +#endif @@ -243,7 +254,11 @@ IterationRetval_t CFireSphere::EnumElement( IHandleEntity *pHandleEntity ) { // UNDONE: Measure which of these is faster // CFire *pFire = dynamic_cast(pEntity); +#ifdef MAPBASE + if ( !EntIsClass( pEntity, gm_isz_class_EnvFire ) ) +#else if ( !FClassnameIs( pEntity, "env_fire" ) ) +#endif return ITERATION_CONTINUE; CFire *pFire = static_cast(pEntity); @@ -995,7 +1010,11 @@ void CFire::Update( float simTime ) { continue; } +#ifdef MAPBASE + else if ( EntIsClass( pOther, gm_isz_class_EnvFire ) ) +#else else if ( FClassnameIs( pOther, "env_fire" ) ) +#endif { if ( fireCount < ARRAYSIZE(pFires) ) { @@ -1307,6 +1326,9 @@ void CEnvFireSource::InputDisable( inputdata_t &inputdata ) // CEnvFireSensor detects changes in heat //================================================== #define SF_FIRESENSOR_START_ON 1 +#ifdef MAPBASE +#define SF_FIRESENSOR_ACCEPT_FLARES 2 +#endif class CEnvFireSensor : public CBaseEntity { @@ -1318,6 +1340,9 @@ public: void TurnOff(); void InputEnable( inputdata_t &inputdata ); void InputDisable( inputdata_t &inputdata ); +#ifdef MAPBASE + int DrawDebugTextOverlays(void); +#endif DECLARE_DATADESC(); @@ -1328,6 +1353,10 @@ private: float m_targetLevel; float m_targetTime; float m_levelTime; +#ifdef MAPBASE + // Only stored for access in debug overlays, don't save + float m_curheat; +#endif COutputEvent m_OnHeatLevelStart; COutputEvent m_OnHeatLevelEnd; @@ -1385,6 +1414,28 @@ void CEnvFireSensor::Think() heat += pFires[i]->GetHeatLevel(); } +#ifdef MAPBASE + if (HasSpawnFlags(SF_FIRESENSOR_ACCEPT_FLARES)) + { + // Also look for nearby flares + CBaseEntity *pEntity = gEntList.FindEntityByClassnameWithin( NULL, "env_flare", GetAbsOrigin(), m_radius ); + while (pEntity) + { + CFlare *pFlare = static_cast(pEntity); + if (pFlare) + { + heat += (pFlare->m_flTimeBurnOut > -1.0 ? (pFlare->m_flTimeBurnOut - gpGlobals->curtime) : 32); + } + + pEntity = gEntList.FindEntityByClassnameWithin( pEntity, "env_flare", GetAbsOrigin(), m_radius ); + } + } +#endif + +#ifdef MAPBASE + m_curheat = heat; +#endif + if ( heat >= m_targetLevel ) { m_levelTime += time; @@ -1442,6 +1493,28 @@ void CEnvFireSensor::InputDisable( inputdata_t &inputdata ) TurnOff(); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Draw any debug text overlays +// Output : Current text offset from the top +//----------------------------------------------------------------------------- +int CEnvFireSensor::DrawDebugTextOverlays( void ) +{ + int text_offset = BaseClass::DrawDebugTextOverlays(); + + if (m_debugOverlays & OVERLAY_TEXT_BIT) + { + char tempstr[512]; + + // print flame size + Q_snprintf(tempstr, sizeof(tempstr), " Current Heat: %f", m_curheat); + EntityText(text_offset,tempstr,0); + text_offset++; + } + return text_offset; +} +#endif + //----------------------------------------------------------------------------- // Purpose: Draw any debug text overlays // Output : Current text offset from the top diff --git a/sp/src/game/server/func_areaportal.cpp b/sp/src/game/server/func_areaportal.cpp index ca391317..d2e50a35 100644 --- a/sp/src/game/server/func_areaportal.cpp +++ b/sp/src/game/server/func_areaportal.cpp @@ -42,6 +42,11 @@ public: virtual bool UpdateVisibility( const Vector &vOrigin, float fovDistanceAdjustFactor, bool &bIsOpenOnClient ); +#ifdef MAPBASE + // For func_areaportal_oneway. + int GetPortalState() { return m_state; } +#endif + DECLARE_DATADESC(); private: @@ -189,3 +194,197 @@ int CAreaPortal::UpdateTransmitState() return SetTransmitState( FL_EDICT_DONTSEND ); } +#ifdef MAPBASE +// An areaportal that automatically closes and opens depending on the direction of the client. +// http://developer.valvesoftware.com/wiki/CAreaPortalOneWay +class CAreaPortalOneWay : public CAreaPortal // CAPOW! +{ + DECLARE_CLASS( CAreaPortalOneWay, CAreaPortal ); + DECLARE_DATADESC(); + +public: + Vector m_vecOpenVector; + bool m_bAvoidPop; + bool m_bOneWayActive; + + void Spawn(); + void Activate(); + int Restore(IRestore &restore); + bool UpdateVisibility( const Vector &vOrigin, float fovDistanceAdjustFactor, bool &bIsOpenOnClient ); + + void InputDisableOneWay( inputdata_t &inputdata ); + void InputEnableOneWay( inputdata_t &inputdata ); + void InputToggleOneWay( inputdata_t &inputdata ); + void InputInvertOneWay( inputdata_t &inputdata ); + +protected: + void RemoteUpdate( bool IsOpen ); + + bool m_bRemotelyUpdated; + bool m_bRemoteCalcWasOpen; + CHandle m_hNextPortal; // This get saved to disc... + CAreaPortalOneWay* m_pNextPortal; // ...while this gets used at runtime, avoiding loads of casts + +private: + void UpdateNextPortal( bool IsOpen ); + + // These two are irrelevant once the entity has established itself + string_t m_strGroupName; + Vector m_vecOrigin_; // The portal won't compile properly if vecOrigin itself has a value, but it's okay to move something in at runtime +}; + +LINK_ENTITY_TO_CLASS( func_areaportal_oneway, CAreaPortalOneWay ); + +BEGIN_DATADESC( CAreaPortalOneWay ) + DEFINE_KEYFIELD( m_vecOpenVector, FIELD_VECTOR, "onewayfacing" ), + DEFINE_KEYFIELD( m_bAvoidPop, FIELD_BOOLEAN, "avoidpop" ), + DEFINE_KEYFIELD_NOT_SAVED( m_vecOrigin_, FIELD_VECTOR, "origin_" ), + DEFINE_KEYFIELD_NOT_SAVED( m_strGroupName, FIELD_STRING, "group" ), + DEFINE_FIELD( m_bOneWayActive, FIELD_BOOLEAN ), + DEFINE_FIELD( m_hNextPortal, FIELD_EHANDLE ), + DEFINE_INPUTFUNC( FIELD_VOID, "DisableOneWay", InputDisableOneWay ), + DEFINE_INPUTFUNC( FIELD_VOID, "EnableOneWay", InputEnableOneWay ), + DEFINE_INPUTFUNC( FIELD_VOID, "ToggleOneWay", InputToggleOneWay ), + DEFINE_INPUTFUNC( FIELD_VOID, "InvertOneWay", InputInvertOneWay ), +END_DATADESC() + +void CAreaPortalOneWay::Spawn() +{ + // Convert our angle from Hammer to a proper vector + QAngle angOpenDir = QAngle( m_vecOpenVector.x, m_vecOpenVector.y, m_vecOpenVector.z ); + AngleVectors( angOpenDir, &m_vecOpenVector ); + + SetLocalOrigin(m_vecOrigin_); + m_bOneWayActive = true; + m_bRemotelyUpdated = false; + + BaseClass::Spawn(); +} + +void CAreaPortalOneWay::Activate() +{ + // Optimisation: share open/closed value for CAPOWs with the same GroupName. + if (m_strGroupName != NULL_STRING) + { + for( unsigned short i = GetPortalListElement(); i != g_AreaPortals.InvalidIndex(); i = g_AreaPortals.Next(i) ) + { + CAreaPortalOneWay* pCur = dynamic_cast(g_AreaPortals[i]); + + if ( pCur && pCur != this && strcmp( STRING(m_strGroupName),STRING(pCur->m_strGroupName) ) == 0 ) + { + m_pNextPortal = pCur; + m_hNextPortal = pCur; + break; + } + } + } + + BaseClass::Activate(); +} + +int CAreaPortalOneWay::Restore(IRestore &restore) +{ + if ( m_hNextPortal.IsValid() ) + m_pNextPortal = m_hNextPortal.Get(); + + return BaseClass::Restore(restore); +} + +// Disable the CAPOW (becomes a normal AP) +void CAreaPortalOneWay::InputDisableOneWay( inputdata_t &inputdata ) +{ + m_bOneWayActive = false; +} + +// Re-enable the CAPOW +void CAreaPortalOneWay::InputEnableOneWay( inputdata_t &inputdata ) +{ + m_bOneWayActive = true; +} + +// Toggle CAPOW +void CAreaPortalOneWay::InputToggleOneWay( inputdata_t &inputdata ) +{ + m_bOneWayActive = !m_bOneWayActive; +} + +// Flip the one way direction +void CAreaPortalOneWay::InputInvertOneWay( inputdata_t &inputdata ) +{ + m_vecOpenVector.Negate(); +} + +// Recieve a shared state from another CAPOW, then pass it on to the next +void CAreaPortalOneWay::RemoteUpdate( bool IsOpen ) +{ + m_bRemotelyUpdated = true; + m_bRemoteCalcWasOpen = IsOpen; + UpdateNextPortal(IsOpen); +} + +// Inline func since this code is required three times +inline void CAreaPortalOneWay::UpdateNextPortal( bool IsOpen ) +{ + if (m_pNextPortal) + m_pNextPortal->RemoteUpdate(IsOpen); +} + +#define VIEWER_PADDING 80 // Value copied from func_areaportalbase.cpp + +bool CAreaPortalOneWay::UpdateVisibility( const Vector &vOrigin, float fovDistanceAdjustFactor, bool &bIsOpenOnClient ) +{ + if (!m_bOneWayActive) + return BaseClass::UpdateVisibility( vOrigin, fovDistanceAdjustFactor, bIsOpenOnClient ); + + if( m_portalNumber == -1 || GetPortalState() == AREAPORTAL_CLOSED ) + { + bIsOpenOnClient = false; + return false; + } + + // Has another CAPOW on our plane already done a calculation? + // Note that the CAPOW chain is traversed with new values in RemoteUpdate(), NOT here + if (m_bRemotelyUpdated) + { + m_bRemotelyUpdated = false; + return m_bRemoteCalcWasOpen ? BaseClass::UpdateVisibility( vOrigin, fovDistanceAdjustFactor, bIsOpenOnClient ) : false; + } + + // *********************** + // If we've got this far then we're the first CAPOW in the chain this frame + // and need to calculate a value and pass it along said chain ourselves + // *********************** + + float dist = VIEWER_PADDING; // Assume open for backfacing tests... + VPlane plane; + if( engine->GetAreaPortalPlane(vOrigin,m_portalNumber,&plane) ) + dist = plane.DistTo(vOrigin); // ...but if we find a plane, use a genuine figure instead. + // This is done because GetAreaPortalPlane only works for + // portals facing the current area. + + // We can use LocalOrigin here because APs never have parents. + float dot = DotProduct(m_vecOpenVector,vOrigin - GetLocalOrigin()); + + if( dot > 0 ) + { + // We are on the open side of the portal. Pass the result on! + UpdateNextPortal(true); + + // The following backfacing check is the inverse of CFuncAreaPortalBase's: + // it /closes/ the portal if the camera is /behind/ the plane. IsOpenOnClient + // is left alone as per func_areaportalbase.h + return dist < -VIEWER_PADDING ? false : true; + } + else // Closed side + { + // To avoid latency pop when crossing the portal's plane, it is only + // closed on the client if said client is outside the "padding zone". + if ( !m_bAvoidPop || (m_bAvoidPop && dist > VIEWER_PADDING) ) + bIsOpenOnClient = false; + + // We are definitely closed on the server, however. + UpdateNextPortal(false); + return false; + } +} +#endif diff --git a/sp/src/game/server/func_areaportalbase.h b/sp/src/game/server/func_areaportalbase.h index ff6c167e..124ece47 100644 --- a/sp/src/game/server/func_areaportalbase.h +++ b/sp/src/game/server/func_areaportalbase.h @@ -95,6 +95,10 @@ public: // see into area 2. virtual bool UpdateVisibility( const Vector &vOrigin, float fovDistanceAdjustFactor, bool &bIsOpenOnClient ); +#ifdef MAPBASE + // For func_areaportal_oneway. + unsigned short GetPortalListElement() { return m_AreaPortalsElement; } +#endif public: diff --git a/sp/src/game/server/func_break.cpp b/sp/src/game/server/func_break.cpp index d0b815e2..dcb5c040 100644 --- a/sp/src/game/server/func_break.cpp +++ b/sp/src/game/server/func_break.cpp @@ -431,9 +431,28 @@ void CBreakable::Precache( void ) case matCinderBlock: pGibName = "ConcreteChunks"; break; + +#ifdef MAPBASE + case matComputer: + pGibName = "ComputerGibs"; + break; + + case matCeilingTile: + pGibName = "CeilingTile"; + break; + + case matFlesh: + pGibName = "FleshGibs"; + break; + + case matWeb: + pGibName = "WebGibs"; + break; #endif -#if HL2_EPISODIC +#endif + +#if HL2_EPISODIC || MAPBASE case matNone: pGibName = ""; break; @@ -1054,6 +1073,11 @@ void CBreakable::Die( void ) iCount = func_break_max_pieces.GetInt(); } +#ifdef MAPBASE + // TEMP TEMP TEMP TEMP + DevMsg("vSize: %f %f %f\n", vSize.x, vSize.y, vSize.z); +#endif + ConVarRef breakable_disable_gib_limit( "breakable_disable_gib_limit" ); if ( !breakable_disable_gib_limit.GetBool() && iCount ) { diff --git a/sp/src/game/server/func_lod.cpp b/sp/src/game/server/func_lod.cpp index f88c4c0d..e1c41c12 100644 --- a/sp/src/game/server/func_lod.cpp +++ b/sp/src/game/server/func_lod.cpp @@ -28,6 +28,9 @@ public: // (waits until it's out of the view frustrum or until there's a lot of motion) // (m_fDisappearDist+): the bmodel is forced to be invisible CNetworkVar( float, m_fDisappearDist ); +#ifdef MAPBASE + CNetworkVar( float, m_fDisappearMaxDist ); +#endif // CBaseEntity overrides. public: @@ -41,6 +44,9 @@ public: IMPLEMENT_SERVERCLASS_ST(CFunc_LOD, DT_Func_LOD) SendPropFloat(SENDINFO(m_fDisappearDist), 0, SPROP_NOSCALE), +#ifdef MAPBASE + SendPropFloat(SENDINFO(m_fDisappearMaxDist), 0, SPROP_NOSCALE), +#endif END_SEND_TABLE() @@ -53,6 +59,9 @@ LINK_ENTITY_TO_CLASS(func_lod, CFunc_LOD); BEGIN_DATADESC( CFunc_LOD ) DEFINE_FIELD( m_fDisappearDist, FIELD_FLOAT ), +#ifdef MAPBASE + DEFINE_FIELD( m_fDisappearMaxDist, FIELD_FLOAT ), +#endif END_DATADESC() @@ -98,6 +107,12 @@ bool CFunc_LOD::KeyValue( const char *szKeyName, const char *szValue ) { m_fDisappearDist = (float)atof(szValue); } +#ifdef MAPBASE + else if (FStrEq(szKeyName, "DisappearMaxDist")) + { + m_fDisappearMaxDist = (float)atof(szValue); + } +#endif else if (FStrEq(szKeyName, "Solid")) { if (atoi(szValue) != 0) diff --git a/sp/src/game/server/func_movelinear.cpp b/sp/src/game/server/func_movelinear.cpp index 397fefd1..0fd92a82 100644 --- a/sp/src/game/server/func_movelinear.cpp +++ b/sp/src/game/server/func_movelinear.cpp @@ -39,6 +39,9 @@ BEGIN_DATADESC( CFuncMoveLinear ) DEFINE_KEYFIELD( m_flBlockDamage, FIELD_FLOAT, "BlockDamage"), DEFINE_KEYFIELD( m_flStartPosition, FIELD_FLOAT, "StartPosition"), DEFINE_KEYFIELD( m_flMoveDistance, FIELD_FLOAT, "MoveDistance"), +#ifdef MAPBASE + DEFINE_FIELD( m_vecReference, FIELD_VECTOR ), +#endif // DEFINE_PHYSPTR( m_pFluidController ), // Inputs @@ -84,9 +87,16 @@ void CFuncMoveLinear::Spawn( void ) m_flMoveDistance = DotProductAbs( m_vecMoveDir, vecOBB ) - m_flLip; } +#ifdef MAPBASE + m_vecPosition1 = GetLocalOrigin() - (m_vecMoveDir * m_flMoveDistance * m_flStartPosition); + m_vecPosition2 = m_vecPosition1 + (m_vecMoveDir * m_flMoveDistance); + m_vecFinalDest = GetLocalOrigin(); + m_vecReference = GetLocalOrigin(); +#else m_vecPosition1 = GetAbsOrigin() - (m_vecMoveDir * m_flMoveDistance * m_flStartPosition); m_vecPosition2 = m_vecPosition1 + (m_vecMoveDir * m_flMoveDistance); m_vecFinalDest = GetAbsOrigin(); +#endif SetTouch( NULL ); @@ -116,6 +126,30 @@ bool CFuncMoveLinear::ShouldSavePhysics( void ) } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Sets the movement parent of this entity. This entity will be moved +// to a local coordinate calculated from its current absolute offset +// from the parent entity and will then follow the parent entity. +// Input : pParentEntity - This entity's new parent in the movement hierarchy. +//----------------------------------------------------------------------------- +void CFuncMoveLinear::SetParent( CBaseEntity *pParentEntity, int iAttachment ) +{ + Vector oldLocal = GetLocalOrigin(); + + BaseClass::SetParent( pParentEntity, iAttachment ); + + // SOLID_NONE indicates we haven't spawned yet + if (GetSolid() != SOLID_NONE) + { + m_vecReference = ((m_vecReference - oldLocal) + GetLocalOrigin()); + m_vecPosition1 = m_vecReference - (m_vecMoveDir * m_flMoveDistance * m_flStartPosition); + m_vecPosition2 = m_vecPosition1 + (m_vecMoveDir * m_flMoveDistance); + m_vecFinalDest = m_vecReference - m_vecFinalDest; + } +} +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -256,6 +290,16 @@ void CFuncMoveLinear::MoveDone( void ) SetNextThink( gpGlobals->curtime + 0.1f ); BaseClass::MoveDone(); +#ifdef MAPBASE + if ( GetLocalOrigin() == m_vecPosition2 ) + { + m_OnFullyOpen.FireOutput( this, this ); + } + else if ( GetLocalOrigin() == m_vecPosition1 ) + { + m_OnFullyClosed.FireOutput( this, this ); + } +#else if ( GetAbsOrigin() == m_vecPosition2 ) { m_OnFullyOpen.FireOutput( this, this ); @@ -264,6 +308,7 @@ void CFuncMoveLinear::MoveDone( void ) { m_OnFullyClosed.FireOutput( this, this ); } +#endif } @@ -277,8 +322,9 @@ void CFuncMoveLinear::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY if ( value > 1.0 ) value = 1.0; + Vector move = m_vecPosition1 + (value * (m_vecPosition2 - m_vecPosition1)); - + Vector delta = move - GetLocalOrigin(); float speed = delta.Length() * 10; @@ -380,6 +426,36 @@ int CFuncMoveLinear::DrawDebugTextOverlays(void) if (m_debugOverlays & OVERLAY_TEXT_BIT) { +#ifdef MAPBASE + if (GetMoveParent()) + { + Vector vecReference, vecPosition1, vecPosition2; + QAngle angReference; + + vecReference = m_vecFinalDest + GetMoveParent()->GetAbsOrigin(); + angReference = GetAbsAngles(); + vecPosition1 = vecReference + m_vecPosition1; + vecPosition2 = vecReference + m_vecPosition2; + + NDebugOverlay::Axis( vecReference, angReference, 12.0f, true, 0.15f ); + NDebugOverlay::Axis( vecPosition1, angReference, 5.0f, true, 0.15f ); + NDebugOverlay::Axis( vecPosition2, angReference, 2.5f, true, 0.15f ); + + char tempstr[512]; + float flTravelDist = (vecPosition1 - vecPosition2).Length(); + float flCurDist = (vecPosition1 - GetAbsOrigin()).Length(); + Q_snprintf(tempstr,sizeof(tempstr),"Current Pos: %3.3f",flCurDist/flTravelDist); + EntityText(text_offset,tempstr,0); + text_offset++; + + float flTargetDist = (vecPosition1 - m_vecFinalDest).Length(); + Q_snprintf(tempstr,sizeof(tempstr),"Target Pos: %3.3f",flTargetDist/flTravelDist); + EntityText(text_offset,tempstr,0); + text_offset++; + } + else + { +#else char tempstr[512]; float flTravelDist = (m_vecPosition1 - m_vecPosition2).Length(); float flCurDist = (m_vecPosition1 - GetLocalOrigin()).Length(); @@ -391,6 +467,10 @@ int CFuncMoveLinear::DrawDebugTextOverlays(void) Q_snprintf(tempstr,sizeof(tempstr),"Target Pos: %3.3f",flTargetDist/flTravelDist); EntityText(text_offset,tempstr,0); text_offset++; +#endif +#ifdef MAPBASE + } +#endif } return text_offset; } diff --git a/sp/src/game/server/func_movelinear.h b/sp/src/game/server/func_movelinear.h index 8f09adc2..ac58f963 100644 --- a/sp/src/game/server/func_movelinear.h +++ b/sp/src/game/server/func_movelinear.h @@ -27,6 +27,10 @@ public: bool CreateVPhysics( void ); bool ShouldSavePhysics( void ); +#ifdef MAPBASE + void SetParent( CBaseEntity* pNewParent, int iAttachment = -1 ); +#endif + void MoveTo(Vector vPosition, float flSpeed); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void MoveDone( void ); @@ -53,6 +57,11 @@ public: float m_flBlockDamage; // Damage inflicted when blocked. float m_flStartPosition; // Position of brush when spawned float m_flMoveDistance; // Total distance the brush can move +#ifdef MAPBASE + // For the parenting fix. + // Prevents position inconsistencies when changing parent. + Vector m_vecReference; +#endif IPhysicsFluidController *m_pFluidController; diff --git a/sp/src/game/server/game_ui.cpp b/sp/src/game/server/game_ui.cpp index 0e57ada9..e0b03122 100644 --- a/sp/src/game/server/game_ui.cpp +++ b/sp/src/game/server/game_ui.cpp @@ -38,6 +38,9 @@ public: // Input handlers void InputDeactivate( inputdata_t &inputdata ); void InputActivate( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputGetButtons( inputdata_t &inputdata ); +#endif void Think( void ); void Deactivate( CBaseEntity *pActivator ); @@ -54,6 +57,14 @@ public: COutputEvent m_pressedBack; COutputEvent m_pressedAttack; COutputEvent m_pressedAttack2; +#ifdef MAPBASE + COutputEvent m_pressedUse; + COutputEvent m_pressedJump; + COutputEvent m_pressedCrouch; + COutputEvent m_pressedAttack3; + COutputEvent m_pressedSprint; + COutputEvent m_pressedReload; +#endif COutputEvent m_unpressedMoveLeft; COutputEvent m_unpressedMoveRight; @@ -61,12 +72,24 @@ public: COutputEvent m_unpressedBack; COutputEvent m_unpressedAttack; COutputEvent m_unpressedAttack2; +#ifdef MAPBASE + COutputEvent m_unpressedUse; + COutputEvent m_unpressedJump; + COutputEvent m_unpressedCrouch; + COutputEvent m_unpressedAttack3; + COutputEvent m_unpressedSprint; + COutputEvent m_unpressedReload; +#endif COutputFloat m_xaxis; COutputFloat m_yaxis; COutputFloat m_attackaxis; COutputFloat m_attack2axis; +#ifdef MAPBASE + COutputInt m_OutButtons; +#endif + bool m_bForceUpdate; int m_nLastButtonState; @@ -84,6 +107,9 @@ BEGIN_DATADESC( CGameUI ) DEFINE_INPUTFUNC( FIELD_VOID, "Deactivate", InputDeactivate ), DEFINE_INPUTFUNC( FIELD_STRING, "Activate", InputActivate ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "GetButtons", InputGetButtons ), +#endif DEFINE_OUTPUT( m_playerOn, "PlayerOn" ), DEFINE_OUTPUT( m_playerOff, "PlayerOff" ), @@ -94,6 +120,14 @@ BEGIN_DATADESC( CGameUI ) DEFINE_OUTPUT( m_pressedBack, "PressedBack" ), DEFINE_OUTPUT( m_pressedAttack, "PressedAttack" ), DEFINE_OUTPUT( m_pressedAttack2, "PressedAttack2" ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_pressedUse, "PressedUse" ), + DEFINE_OUTPUT( m_pressedJump, "PressedJump" ), + DEFINE_OUTPUT( m_pressedCrouch, "PressedCrouch" ), + DEFINE_OUTPUT( m_pressedAttack3, "PressedAttack3" ), + DEFINE_OUTPUT( m_pressedSprint, "PressedSprint" ), + DEFINE_OUTPUT( m_pressedReload, "PressedReload" ), +#endif DEFINE_OUTPUT( m_unpressedMoveLeft, "UnpressedMoveLeft" ), DEFINE_OUTPUT( m_unpressedMoveRight, "UnpressedMoveRight" ), @@ -101,6 +135,16 @@ BEGIN_DATADESC( CGameUI ) DEFINE_OUTPUT( m_unpressedBack, "UnpressedBack" ), DEFINE_OUTPUT( m_unpressedAttack, "UnpressedAttack" ), DEFINE_OUTPUT( m_unpressedAttack2, "UnpressedAttack2" ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_unpressedUse, "UnpressedUse" ), + DEFINE_OUTPUT( m_unpressedJump, "UnpressedJump" ), + DEFINE_OUTPUT( m_unpressedCrouch, "UnpressedCrouch" ), + DEFINE_OUTPUT( m_unpressedAttack3, "UnpressedAttack3" ), + DEFINE_OUTPUT( m_unpressedSprint, "UnpressedSprint" ), + DEFINE_OUTPUT( m_unpressedReload, "UnpressedReload" ), + + DEFINE_OUTPUT( m_OutButtons, "OutButtons" ), +#endif DEFINE_OUTPUT( m_xaxis, "XAxis" ), DEFINE_OUTPUT( m_yaxis, "YAxis" ), @@ -297,6 +341,13 @@ void CGameUI::Think( void ) if ((( pPlayer->m_afButtonPressed & IN_USE ) && ( m_spawnflags & SF_GAMEUI_USE_DEACTIVATES )) || (( pPlayer->m_afButtonPressed & IN_JUMP ) && ( m_spawnflags & SF_GAMEUI_JUMP_DEACTIVATES ))) { +#ifdef MAPBASE + if (pPlayer->m_afButtonPressed & IN_USE) + m_pressedUse.FireOutput( pPlayer, this, 0 ); + if (pPlayer->m_afButtonPressed & IN_JUMP) + m_pressedJump.FireOutput( pPlayer, this, 0 ); +#endif + Deactivate( pPlayer ); return; } @@ -380,6 +431,80 @@ void CGameUI::Think( void ) } } +#ifdef MAPBASE + if ( nButtonsChanged & IN_USE ) + { + if ( m_nLastButtonState & IN_USE ) + { + m_unpressedUse.FireOutput( pPlayer, this, 0 ); + } + else + { + m_pressedUse.FireOutput( pPlayer, this, 0 ); + } + } + + if ( nButtonsChanged & IN_JUMP ) + { + if ( m_nLastButtonState & IN_JUMP ) + { + m_unpressedJump.FireOutput( pPlayer, this, 0 ); + } + else + { + m_pressedJump.FireOutput( pPlayer, this, 0 ); + } + } + + if ( nButtonsChanged & IN_DUCK ) + { + if ( m_nLastButtonState & IN_DUCK ) + { + m_unpressedCrouch.FireOutput( pPlayer, this, 0 ); + } + else + { + m_pressedCrouch.FireOutput( pPlayer, this, 0 ); + } + } + + if ( nButtonsChanged & IN_ATTACK3 ) + { + if ( m_nLastButtonState & IN_ATTACK3 ) + { + m_unpressedAttack3.FireOutput( pPlayer, this, 0 ); + } + else + { + m_pressedAttack3.FireOutput( pPlayer, this, 0 ); + } + } + + if ( nButtonsChanged & IN_SPEED ) + { + if ( m_nLastButtonState & IN_SPEED ) + { + m_unpressedSprint.FireOutput( pPlayer, this, 0 ); + } + else + { + m_pressedSprint.FireOutput( pPlayer, this, 0 ); + } + } + + if ( nButtonsChanged & IN_RELOAD ) + { + if ( m_nLastButtonState & IN_RELOAD ) + { + m_unpressedReload.FireOutput( pPlayer, this, 0 ); + } + else + { + m_pressedReload.FireOutput( pPlayer, this, 0 ); + } + } +#endif + // Setup for the next frame m_nLastButtonState = pPlayer->m_nButtons; @@ -437,3 +562,13 @@ void CGameUI::Think( void ) m_bForceUpdate = false; } + +#ifdef MAPBASE +//------------------------------------------------------------------------------ +// Purpose: Gets and outputs the player's current buttons +//------------------------------------------------------------------------------ +void CGameUI::InputGetButtons( inputdata_t &inputdata ) +{ + m_OutButtons.Set(m_player ? m_player->m_nButtons : m_nLastButtonState, m_player, this); +} +#endif diff --git a/sp/src/game/server/genericactor.cpp b/sp/src/game/server/genericactor.cpp index 6f104887..fff148ff 100644 --- a/sp/src/game/server/genericactor.cpp +++ b/sp/src/game/server/genericactor.cpp @@ -48,6 +48,9 @@ public: void TempGunEffect( void ); string_t m_strHullName; +#ifdef MAPBASE + Class_T m_iClassify = CLASS_NONE; +#endif DECLARE_DATADESC(); }; @@ -56,6 +59,9 @@ LINK_ENTITY_TO_CLASS( generic_actor, CGenericActor ); BEGIN_DATADESC( CGenericActor ) DEFINE_KEYFIELD(m_strHullName, FIELD_STRING, "hull_name" ), +#ifdef MAPBASE + DEFINE_INPUT(m_iClassify, FIELD_INTEGER, "SetClassify" ), +#endif END_DATADESC() @@ -66,7 +72,11 @@ END_DATADESC() //========================================================= Class_T CGenericActor::Classify ( void ) { +#ifdef MAPBASE + return m_iClassify; +#else return CLASS_NONE; +#endif } //========================================================= @@ -139,6 +149,10 @@ void CGenericActor::Spawn() m_NPCState = NPC_STATE_NONE; CapabilitiesAdd( bits_CAP_MOVE_GROUND | bits_CAP_OPEN_DOORS ); + +#ifdef MAPBASE + CapabilitiesAdd( bits_CAP_SQUAD ); +#endif // remove head turn if no eyes or forward attachment if (LookupAttachment( "eyes" ) > 0 && LookupAttachment( "forward" ) > 0) diff --git a/sp/src/game/server/genericmonster.cpp b/sp/src/game/server/genericmonster.cpp index ed1be819..71fd197f 100644 --- a/sp/src/game/server/genericmonster.cpp +++ b/sp/src/game/server/genericmonster.cpp @@ -17,6 +17,12 @@ #include "physics_bone_follower.h" #include "ai_baseactor.h" #include "ai_senses.h" +#ifdef MAPBASE +/* +#include "ai_basenpc_flyer.h" +#include "player_pickup.h" +*/ +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -470,3 +476,97 @@ void CNPC_Furniture::DrawDebugGeometryOverlays( void ) BaseClass::DrawDebugGeometryOverlays(); } + +#ifdef MAPBASE +/* +//========================================================= +// Generic flying monster +//========================================================= + +class CGenericFlyingMonster : public CAI_BaseFlyingBot +{ +public: + DECLARE_CLASS( CGenericFlyingMonster, CAI_BaseFlyingBot ); + + CGenericFlyingMonster(); + + void Spawn( void ); + void Precache( void ); + int GetSoundInterests ( void ); +}; + +LINK_ENTITY_TO_CLASS( monster_flying_generic, CGenericFlyingMonster ); + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CGenericFlyingMonster::CGenericFlyingMonster() +{ +} + +//========================================================= +// GetSoundInterests - generic NPC can't hear. +//========================================================= +int CGenericFlyingMonster::GetSoundInterests ( void ) +{ + return NULL; +} + +//========================================================= +// Spawn +//========================================================= +void CGenericFlyingMonster::Spawn() +{ + Precache(); + + SetModel( STRING( GetModelName() ) ); + + if ( FStrEq( STRING( GetModelName() ), "models/player.mdl" ) || FStrEq( STRING( GetModelName() ), "models/holo.mdl" ) ) + UTIL_SetSize(this, VEC_HULL_MIN, VEC_HULL_MAX); + else + UTIL_SetSize(this, NAI_Hull::Mins(HULL_HUMAN), NAI_Hull::Maxs(HULL_HUMAN)); + + SetSolid( SOLID_BBOX ); + AddSolidFlags( FSOLID_NOT_STANDABLE ); + SetMoveType( MOVETYPE_FLY ); + m_bloodColor = BLOOD_COLOR_RED; + m_flFieldOfView = 0.5;// indicates the width of this NPC's forward view cone ( as a dotproduct result ) + m_NPCState = NPC_STATE_NONE; + + CapabilitiesAdd( bits_CAP_MOVE_FLY ); + + SetNavType( NAV_FLY ); + + AddFlag( FL_FLY ); + + NPCInit(); + if ( !HasSpawnFlags(SF_GENERICNPC_NOTSOLID) ) + { + trace_t tr; + UTIL_TraceEntity( this, GetAbsOrigin(), GetAbsOrigin(), MASK_SOLID, &tr ); + if ( tr.startsolid ) + { + Msg("Placed npc_generic in solid!!! (%s)\n", STRING(GetModelName()) ); + m_spawnflags |= SF_GENERICNPC_NOTSOLID; + } + } + + if ( HasSpawnFlags(SF_GENERICNPC_NOTSOLID) ) + { + AddSolidFlags( FSOLID_NOT_SOLID ); + m_takedamage = DAMAGE_NO; + VPhysicsDestroyObject(); + } +} + +//----------------------------------------------------------------------------- +// Purpose: precaches all resources this NPC needs +//----------------------------------------------------------------------------- +void CGenericFlyingMonster::Precache() +{ + BaseClass::Precache(); + + PrecacheModel( STRING( GetModelName() ) ); +} +*/ +#endif diff --git a/sp/src/game/server/hl2/ai_behavior_actbusy.cpp b/sp/src/game/server/hl2/ai_behavior_actbusy.cpp index 9f1ac3ef..83aaae5b 100644 --- a/sp/src/game/server/hl2/ai_behavior_actbusy.cpp +++ b/sp/src/game/server/hl2/ai_behavior_actbusy.cpp @@ -18,6 +18,9 @@ #include "SoundEmitterSystem/isoundemittersystembase.h" #include "entityblocker.h" #include "npcevent.h" +#ifdef MAPBASE +#include "interval.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -58,6 +61,9 @@ BEGIN_DATADESC( CAI_ActBusyBehavior ) DEFINE_FIELD( m_bInQueue, FIELD_BOOLEAN ), DEFINE_FIELD( m_iCurrentBusyAnim, FIELD_INTEGER ), DEFINE_FIELD( m_hActBusyGoal, FIELD_EHANDLE ), +#ifdef MAPBASE + DEFINE_FIELD( m_hNextActBusyGoal, FIELD_EHANDLE ), +#endif DEFINE_FIELD( m_bNeedToSetBounds, FIELD_BOOLEAN ), DEFINE_FIELD( m_hSeeEntity, FIELD_EHANDLE ), DEFINE_FIELD( m_fTimeLastSawSeeEntity, FIELD_TIME ), @@ -65,6 +71,9 @@ BEGIN_DATADESC( CAI_ActBusyBehavior ) DEFINE_FIELD( m_bExitedBusyToDueSeeEnemy, FIELD_BOOLEAN ), DEFINE_FIELD( m_iNumConsecutivePathFailures, FIELD_INTEGER ), DEFINE_FIELD( m_bAutoFireWeapon, FIELD_BOOLEAN ), +#ifdef MAPBASE + DEFINE_FIELD( m_flNextAutoFireTime, FIELD_TIME ), +#endif DEFINE_FIELD( m_flDeferUntil, FIELD_TIME ), DEFINE_FIELD( m_iNumEnemiesInSafeZone, FIELD_INTEGER ), END_DATADESC(); @@ -91,7 +100,11 @@ public: virtual void LevelShutdownPostEntity( void ); // Read in the data from the anim data file +#ifdef MAPBASE + void ParseAnimDataFile( const char *file = "scripts/actbusy.txt" ); +#else void ParseAnimDataFile( void ); +#endif // Parse a keyvalues section into an act busy anim bool ParseActBusyFromKV( busyanim_t *pAnim, KeyValues *pSection ); @@ -107,6 +120,13 @@ protected: CActBusyAnimData g_ActBusyAnimDataSystem; +#ifdef MAPBASE +void ParseCustomActbusyFile( const char *file ) +{ + g_ActBusyAnimDataSystem.ParseAnimDataFile(file); +} +#endif + //----------------------------------------------------------------------------- // Inherited from IAutoServerSystem //----------------------------------------------------------------------------- @@ -126,10 +146,18 @@ void CActBusyAnimData::LevelShutdownPostEntity( void ) //----------------------------------------------------------------------------- // Clear out the stats + their history //----------------------------------------------------------------------------- +#ifdef MAPBASE +void CActBusyAnimData::ParseAnimDataFile( const char *file ) +#else void CActBusyAnimData::ParseAnimDataFile( void ) +#endif { KeyValues *pKVAnimData = new KeyValues( "ActBusyAnimDatafile" ); +#ifdef MAPBASE + if ( pKVAnimData->LoadFromFile( filesystem, file ) ) +#else if ( pKVAnimData->LoadFromFile( filesystem, "scripts/actbusy.txt" ) ) +#endif { // Now try and parse out each act busy anim KeyValues *pKVAnim = pKVAnimData->GetFirstSubKey(); @@ -207,6 +235,10 @@ bool CActBusyAnimData::ParseActBusyFromKV( busyanim_t *pAnim, KeyValues *pSectio pAnim->iBusyInterruptType = BA_INT_NONE; } +#ifdef MAPBASE + pAnim->bTranslateActivity = pSection->GetBool("translateactivity", false); +#endif + return true; } @@ -271,7 +303,11 @@ void CAI_ActBusyBehavior::Enable( CAI_ActBusyGoal *pGoal, float flRange, bool bV m_bMovingToBusy = false; m_bNeedsToPlayExitAnim = false; m_bLeaving = false; +#ifdef MAPBASE + m_flNextBusySearchTime = gpGlobals->curtime + (m_hActBusyGoal.Get() ? m_hActBusyGoal->NextBusySearchInterval().start : ai_actbusy_search_time.GetFloat()); +#else m_flNextBusySearchTime = gpGlobals->curtime + ai_actbusy_search_time.GetFloat(); +#endif m_flEndBusyAt = 0; m_bVisibleOnly = bVisibleOnly; m_bInQueue = dynamic_cast(m_hActBusyGoal.Get()) != NULL; @@ -354,6 +390,16 @@ void CAI_ActBusyBehavior::ForceActBusy( CAI_ActBusyGoal *pGoal, CAI_Hint *pHintN { Assert( !m_bLeaving ); +#ifdef MAPBASE + if ( m_bNeedsToPlayExitAnim && !bTeleportToBusy ) + { + if ( HasAnimForActBusy( m_iCurrentBusyAnim, BA_EXIT ) ) + { + m_hNextActBusyGoal = pGoal; + //m_bNextActBusyVisOnly = bVisibleOnly; + } + } +#else if ( m_bNeedsToPlayExitAnim ) { // If we hit this, the mapmaker's told this NPC to actbusy somewhere while it's still in an actbusy. @@ -364,6 +410,7 @@ void CAI_ActBusyBehavior::ForceActBusy( CAI_ActBusyGoal *pGoal, CAI_Hint *pHintN return; } } +#endif if ( ai_debug_actbusy.GetInt() == 4 ) { @@ -379,7 +426,18 @@ void CAI_ActBusyBehavior::ForceActBusy( CAI_ActBusyGoal *pGoal, CAI_Hint *pHintN Msg("\n"); } +#ifdef MAPBASE + if (!m_hNextActBusyGoal) + { + Enable( pGoal, m_flBusySearchRange, bVisibleOnly ); + } + else + { + Enable( NULL, m_flBusySearchRange, bVisibleOnly ); + } +#else Enable( pGoal, m_flBusySearchRange, bVisibleOnly ); +#endif m_bForceActBusy = true; m_flForcedMaxTime = flMaxTime; m_bTeleportToBusy = bTeleportToBusy; @@ -703,7 +761,12 @@ bool CAI_ActBusyBehavior::ShouldIgnoreSound( CSound *pSound ) //----------------------------------------------------------------------------- void CAI_ActBusyBehavior::OnFriendDamaged( CBaseCombatCharacter *pSquadmate, CBaseEntity *pAttacker ) { +#ifdef MAPBASE + // Now that this has been extended beyond Alyx, it doesn't just need to be the player anymore + if( IsCombatActBusy() && IsInSafeZone( pAttacker ) ) +#else if( IsCombatActBusy() && pSquadmate->IsPlayer() && IsInSafeZone( pAttacker ) ) +#endif { SetCondition( COND_ACTBUSY_AWARE_OF_ENEMY_IN_SAFE_ZONE ); // Break the actbusy, if we're running it. m_flDeferUntil = gpGlobals->curtime + 4.0f; // Stop actbusying and go deal with that enemy!! @@ -804,7 +867,12 @@ void CAI_ActBusyBehavior::GatherConditions( void ) SetCondition( COND_ACTBUSY_LOST_SEE_ENTITY ); m_hActBusyGoal->NPCLostSeeEntity( GetOuter() ); +#ifdef MAPBASE + // Now that this has been extended beyond Alyx, this could just apply to player allies in general + if( IsCombatActBusy() && (m_hSeeEntity->IsPlayer() && GetOuter()->IsPlayerAlly()) ) +#else if( IsCombatActBusy() && (GetOuter()->Classify() == CLASS_PLAYER_ALLY_VITAL && m_hSeeEntity->IsPlayer()) ) +#endif { // Defer any actbusying for several seconds. This serves as a heuristic for waiting // for the player to settle after moving out of the room. This helps Alyx pick a more @@ -892,13 +960,21 @@ void CAI_ActBusyBehavior::GatherConditions( void ) } } +#ifdef MAPBASE + if( m_bAutoFireWeapon && m_flNextAutoFireTime <= gpGlobals->curtime && random->RandomInt(0, 4) <= 3 ) +#else if( m_bAutoFireWeapon && random->RandomInt(0, 5) <= 3 ) +#endif { CBaseCombatWeapon *pWeapon = GetOuter()->GetActiveWeapon(); if( pWeapon ) { pWeapon->Operator_ForceNPCFire( GetOuter(), false ); +#ifdef MAPBASE + pWeapon->DoMuzzleFlash(); + m_flNextAutoFireTime = gpGlobals->curtime + pWeapon->GetFireRate(); +#endif } } @@ -1158,7 +1234,11 @@ int CAI_ActBusyBehavior::SelectScheduleWhileNotBusy( int iBase ) } else { +#ifdef MAPBASE + m_flNextBusySearchTime = gpGlobals->curtime + (m_hActBusyGoal ? RandomInterval(m_hActBusyGoal->NextBusySearchInterval()) : RandomFloat(ai_actbusy_search_time.GetFloat(), ai_actbusy_search_time.GetFloat()*2)); +#else m_flNextBusySearchTime = gpGlobals->curtime + RandomFloat(ai_actbusy_search_time.GetFloat(), ai_actbusy_search_time.GetFloat()*2); +#endif } // We may already have a node @@ -1349,6 +1429,23 @@ int CAI_ActBusyBehavior::SelectSchedule() if ( m_bLeaving ) return SelectScheduleForLeaving(); +#ifdef MAPBASE + if (m_hNextActBusyGoal) + { + if (m_bBusy) + { + m_flEndBusyAt = gpGlobals->curtime; + } + else + { + // Next busy + // (the parameters should've been safely stored when we transferred) + Enable(m_hNextActBusyGoal, m_flBusySearchRange, m_bVisibleOnly); + m_hNextActBusyGoal = NULL; + } + } +#endif + // NPCs should not be busy if the actbusy behaviour has been disabled, or if they've received player squad commands bool bShouldNotBeBusy = (!m_bEnabled || HasCondition( COND_PLAYER_ADDED_TO_SQUAD ) || HasCondition( COND_RECEIVED_ORDERS ) ); if ( bShouldNotBeBusy ) @@ -1615,7 +1712,20 @@ bool CAI_ActBusyBehavior::HasAnimForActBusy( int iActBusy, busyanimparts_t AnimP // Try and play the activity second if ( pBusyAnim->iActivities[AnimPart] != ACT_INVALID ) +#ifdef MAPBASE + { + if (pBusyAnim->bTranslateActivity == true) + { + return GetOuter()->HaveSequenceForActivity( GetOuter()->TranslateActivity(pBusyAnim->iActivities[AnimPart]) ); + } + else + { + return GetOuter()->HaveSequenceForActivity( pBusyAnim->iActivities[AnimPart] ); + } + } +#else return GetOuter()->HaveSequenceForActivity( pBusyAnim->iActivities[AnimPart] ); +#endif return false; } @@ -1677,7 +1787,11 @@ bool CAI_ActBusyBehavior::PlayAnimForActBusy( busyanimparts_t AnimPart ) // Try and play the activity second if ( pBusyAnim->iActivities[AnimPart] != ACT_INVALID ) { +#ifdef MAPBASE + GetOuter()->SetIdealActivity( pBusyAnim->bTranslateActivity ? GetOuter()->TranslateActivity(pBusyAnim->iActivities[AnimPart]) : pBusyAnim->iActivities[AnimPart] ); +#else GetOuter()->SetIdealActivity( pBusyAnim->iActivities[AnimPart] ); +#endif return true; } @@ -2196,7 +2310,11 @@ void CAI_ActBusyBehavior::NotifyBusyEnding( void ) } else { +#ifdef MAPBASE + m_flNextBusySearchTime = gpGlobals->curtime + (m_hActBusyGoal ? RandomInterval(m_hActBusyGoal->NextBusySearchInterval()) : RandomFloat(ai_actbusy_search_time.GetFloat(), ai_actbusy_search_time.GetFloat()*2)); +#else m_flNextBusySearchTime = gpGlobals->curtime + (RandomFloat(ai_actbusy_search_time.GetFloat(), ai_actbusy_search_time.GetFloat()*2)); +#endif } } @@ -2306,6 +2424,12 @@ BEGIN_DATADESC( CAI_ActBusyGoal ) DEFINE_KEYFIELD( m_bVisibleOnly, FIELD_BOOLEAN, "visibleonly" ), DEFINE_KEYFIELD( m_iType, FIELD_INTEGER, "type" ), DEFINE_KEYFIELD( m_bAllowCombatActBusyTeleport, FIELD_BOOLEAN, "allowteleport" ), +#ifdef MAPBASE + // interval_t's can be saved. No instance of its use exists in vanilla Source 2013, + // so it's either an unused field type or something used in the engine. It appears to be functional either way. + // I added built-in keyvalue support as an experiment, and this keyvalue is part of said experiment. + DEFINE_KEYFIELD( m_NextBusySearch, FIELD_INTERVAL, "NextBusy" ), +#endif DEFINE_KEYFIELD( m_iszSeeEntityName, FIELD_STRING, "SeeEntity" ), DEFINE_KEYFIELD( m_flSeeEntityTimeout, FIELD_FLOAT, "SeeEntityTimeout" ), DEFINE_KEYFIELD( m_iszSafeZoneVolume, FIELD_STRING, "SafeZone" ), @@ -2316,10 +2440,18 @@ BEGIN_DATADESC( CAI_ActBusyGoal ) DEFINE_INPUTFUNC( FIELD_STRING, "ForceNPCToActBusy", InputForceNPCToActBusy ), DEFINE_INPUTFUNC( FIELD_EHANDLE, "ForceThisNPCToActBusy", InputForceThisNPCToActBusy ), DEFINE_INPUTFUNC( FIELD_EHANDLE, "ForceThisNPCToLeave", InputForceThisNPCToLeave ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_EHANDLE, "ForceThisNPCToStopBusy", InputForceThisNPCToStopBusy ), +#endif // Outputs DEFINE_OUTPUT( m_OnNPCStartedBusy, "OnNPCStartedBusy" ), DEFINE_OUTPUT( m_OnNPCFinishedBusy, "OnNPCFinishedBusy" ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OnNPCStartedLeavingBusy, "OnNPCStartedLeavingBusy" ), + DEFINE_OUTPUT( m_OnNPCMovingToBusy, "OnNPCMovingToBusy" ), + DEFINE_OUTPUT( m_OnNPCAbortedMoveTo, "OnNPCAbortedMoveTo" ), +#endif DEFINE_OUTPUT( m_OnNPCLeft, "OnNPCLeft" ), DEFINE_OUTPUT( m_OnNPCLostSeeEntity, "OnNPCLostSeeEntity" ), DEFINE_OUTPUT( m_OnNPCSeeEnemy, "OnNPCSeeEnemy" ), @@ -2586,12 +2718,30 @@ void CAI_ActBusyGoal::InputForceThisNPCToLeave( inputdata_t &inputdata ) pBehavior->ForceActBusyLeave(); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Forces a specific NPC to stop acting busy +//----------------------------------------------------------------------------- +void CAI_ActBusyGoal::InputForceThisNPCToStopBusy( inputdata_t &inputdata ) +{ + CAI_ActBusyBehavior *pBehavior = GetBusyBehaviorForNPC( inputdata.value.Entity(), "InputForceThisNPCToStopBusy" ); + if ( !pBehavior ) + return; + + // Just stop busying + pBehavior->StopBusying(); +} +#endif + //----------------------------------------------------------------------------- // Purpose: // Input : *pNPC - //----------------------------------------------------------------------------- void CAI_ActBusyGoal::NPCMovingToBusy( CAI_BaseNPC *pNPC ) { +#ifdef MAPBASE + m_OnNPCMovingToBusy.Set( pNPC, pNPC, this ); +#endif } //----------------------------------------------------------------------------- @@ -2608,6 +2758,9 @@ void CAI_ActBusyGoal::NPCStartedBusy( CAI_BaseNPC *pNPC ) //----------------------------------------------------------------------------- void CAI_ActBusyGoal::NPCStartedLeavingBusy( CAI_BaseNPC *pNPC ) { +#ifdef MAPBASE + m_OnNPCStartedLeavingBusy.Set( pNPC, pNPC, this ); +#endif } //----------------------------------------------------------------------------- @@ -2616,6 +2769,9 @@ void CAI_ActBusyGoal::NPCStartedLeavingBusy( CAI_BaseNPC *pNPC ) //----------------------------------------------------------------------------- void CAI_ActBusyGoal::NPCAbortedMoveTo( CAI_BaseNPC *pNPC ) { +#ifdef MAPBASE + m_OnNPCAbortedMoveTo.Set( pNPC, pNPC, this ); +#endif } //----------------------------------------------------------------------------- @@ -2650,6 +2806,24 @@ void CAI_ActBusyGoal::NPCSeeEnemy( CAI_BaseNPC *pNPC ) m_OnNPCSeeEnemy.Set( pNPC, pNPC, this ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +interval_t &CAI_ActBusyGoal::NextBusySearchInterval() +{ + if (m_NextBusySearch.start == 0) + { + // Return an interval_t version of the convar + static interval_t defaultInterval; + defaultInterval.start = ai_actbusy_search_time.GetFloat(); + defaultInterval.range = ai_actbusy_search_time.GetFloat(); // Range is end - start, so we don't have to multiply it here + return defaultInterval; + } + + return m_NextBusySearch; +} +#endif + //========================================================================================================== // ACT BUSY QUEUE //========================================================================================================== diff --git a/sp/src/game/server/hl2/ai_behavior_actbusy.h b/sp/src/game/server/hl2/ai_behavior_actbusy.h index 750b600f..3389def5 100644 --- a/sp/src/game/server/hl2/ai_behavior_actbusy.h +++ b/sp/src/game/server/hl2/ai_behavior_actbusy.h @@ -50,6 +50,9 @@ struct busyanim_t float flMaxTime; // Max time spent in this busy animation. 0 means continue until interrupted. busyinterrupt_t iBusyInterruptType; bool bUseAutomovement; +#ifdef MAPBASE + bool bTranslateActivity; +#endif }; struct busysafezone_t @@ -181,6 +184,10 @@ private: bool m_bInQueue; int m_iCurrentBusyAnim; CHandle m_hActBusyGoal; +#ifdef MAPBASE + // So exit animations can play + CHandle m_hNextActBusyGoal; +#endif bool m_bNeedToSetBounds; EHANDLE m_hSeeEntity; float m_fTimeLastSawSeeEntity; @@ -189,6 +196,9 @@ private: int m_iNumConsecutivePathFailures; // Count how many times we failed to find a path to a node, so we can consider teleporting. bool m_bAutoFireWeapon; +#ifdef MAPBASE + float m_flNextAutoFireTime; +#endif float m_flDeferUntil; int m_iNumEnemiesInSafeZone; @@ -225,6 +235,10 @@ public: int GetType() { return m_iType; } bool IsCombatActBusyTeleportAllowed() { return m_bAllowCombatActBusyTeleport; } +#ifdef MAPBASE + interval_t &NextBusySearchInterval(); +#endif + protected: CAI_ActBusyBehavior *GetBusyBehaviorForNPC( const char *pszActorName, CBaseEntity *pActivator, CBaseEntity *pCaller, const char *sInputName ); CAI_ActBusyBehavior *GetBusyBehaviorForNPC( CBaseEntity *pEntity, const char *sInputName ); @@ -238,6 +252,9 @@ protected: void InputForceNPCToActBusy( inputdata_t &inputdata ); void InputForceThisNPCToActBusy( inputdata_t &inputdata ); void InputForceThisNPCToLeave( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputForceThisNPCToStopBusy( inputdata_t &inputdata ); +#endif DECLARE_DATADESC(); @@ -246,6 +263,9 @@ protected: bool m_bVisibleOnly; int m_iType; bool m_bAllowCombatActBusyTeleport; +#ifdef MAPBASE + interval_t m_NextBusySearch; +#endif public: // Let the actbusy behavior query these so we don't have to duplicate the data. @@ -257,6 +277,11 @@ public: protected: COutputEHANDLE m_OnNPCStartedBusy; COutputEHANDLE m_OnNPCFinishedBusy; +#ifdef MAPBASE + COutputEHANDLE m_OnNPCStartedLeavingBusy; + COutputEHANDLE m_OnNPCMovingToBusy; + COutputEHANDLE m_OnNPCAbortedMoveTo; +#endif COutputEHANDLE m_OnNPCLeft; COutputEHANDLE m_OnNPCLostSeeEntity; COutputEHANDLE m_OnNPCSeeEnemy; diff --git a/sp/src/game/server/hl2/ai_behavior_functank.cpp b/sp/src/game/server/hl2/ai_behavior_functank.cpp index 0c1ae3bf..f0a32601 100644 --- a/sp/src/game/server/hl2/ai_behavior_functank.cpp +++ b/sp/src/game/server/hl2/ai_behavior_functank.cpp @@ -50,6 +50,12 @@ bool CAI_FuncTankBehavior::CanSelectSchedule() if ( !m_hFuncTank ) return false; +#ifdef MAPBASE + // We're glued to our func_tank, don't get off of it + if ( m_hFuncTank->m_bControllerGlued ) + return true; +#endif + // Are you alive, in a script? if ( !GetOuter()->IsInterruptable() ) return false; @@ -92,6 +98,20 @@ void CAI_FuncTankBehavior::PrescheduleThink() } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +// Output : Returns true on success, false on failure. +//----------------------------------------------------------------------------- +bool CAI_FuncTankBehavior::IsInterruptable( void ) +{ + if ( m_hFuncTank && m_hFuncTank->m_bControllerGlued ) + return false; + + return BaseClass::IsInterruptable(); +} +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -114,6 +134,15 @@ int CAI_FuncTankBehavior::SelectSchedule() // If we are not mounted to a func_tank look for one. if ( !IsMounted() ) { +#ifdef MAPBASE + // Forced mounts use a special schedule. + // If our outer is parented, automatically grab the tank if we're in its control volume. + if (HasCondition(COND_FUNCTANK_FORCED) || (GetOuter()->GetParent() && m_hFuncTank->m_hControlVolume)) + { + return SCHED_FORCE_MOUNT_FUNCTANK; + } +#endif + return SCHED_MOVE_TO_FUNCTANK; } @@ -180,6 +209,10 @@ void CAI_FuncTankBehavior::Dismount( void ) // Set this condition to force breakout of any func_tank behavior schedules SetCondition( COND_FUNCTANK_DISMOUNT ); + +#ifdef MAPBASE + ClearCondition( COND_FUNCTANK_FORCED ); +#endif } //----------------------------------------------------------------------------- @@ -204,7 +237,11 @@ int CAI_FuncTankBehavior::OnTakeDamage_Alive( const CTakeDamageInfo &info ) if ( m_hFuncTank && bValidDismountAttacker == true ) { +#ifdef MAPBASE + if ( !m_hFuncTank->IsEntityInViewCone( pAttacker ) && !m_hFuncTank->m_bControllerGlued ) +#else if ( !m_hFuncTank->IsEntityInViewCone( pAttacker ) ) +#endif { SetCondition( COND_FUNCTANK_DISMOUNT ); } @@ -571,7 +608,12 @@ void CAI_FuncTankBehavior::GatherConditions() } } +#ifdef MAPBASE + // So they don't unholster every time there's a tank in the map looking for NPCs + if (!m_hFuncTank && m_bMounted) +#else if ( !m_hFuncTank ) +#endif { m_bMounted = false; GetOuter()->SetDesiredWeaponState( DESIREDWEAPONSTATE_UNHOLSTERED ); @@ -704,6 +746,9 @@ AI_BEGIN_CUSTOM_SCHEDULE_PROVIDER( CAI_FuncTankBehavior ) DECLARE_TASK( TASK_FUNCTANK_ANNOUNCE_SCAN ) DECLARE_CONDITION( COND_FUNCTANK_DISMOUNT ) +#ifdef MAPBASE + DECLARE_CONDITION( COND_FUNCTANK_FORCED ) +#endif //========================================================= //========================================================= @@ -773,4 +818,20 @@ AI_BEGIN_CUSTOM_SCHEDULE_PROVIDER( CAI_FuncTankBehavior ) " Interrupts" ) +#ifdef MAPBASE + //========================================================= + //========================================================= + DEFINE_SCHEDULE + ( + SCHED_FORCE_MOUNT_FUNCTANK, + + " Tasks" + " TASK_STOP_MOVING 0" + " TASK_FACE_FUNCTANK 0" + " TASK_HOLSTER_WEAPON 0" + " " + " Interrupts" + ) +#endif + AI_END_CUSTOM_SCHEDULE_PROVIDER() diff --git a/sp/src/game/server/hl2/ai_behavior_functank.h b/sp/src/game/server/hl2/ai_behavior_functank.h index a8d61466..a9f19496 100644 --- a/sp/src/game/server/hl2/ai_behavior_functank.h +++ b/sp/src/game/server/hl2/ai_behavior_functank.h @@ -49,6 +49,9 @@ public: void BeginScheduleSelection(); void EndScheduleSelection(); void PrescheduleThink(); +#ifdef MAPBASE + bool IsInterruptable( void ); +#endif Activity NPC_TranslateActivity( Activity activity ); @@ -61,6 +64,9 @@ public: SCHED_FIRE_FUNCTANK, SCHED_SCAN_WITH_FUNCTANK, SCHED_FAIL_MOVE_TO_FUNCTANK, +#ifdef MAPBASE + SCHED_FORCE_MOUNT_FUNCTANK, +#endif }; // Tasks @@ -82,6 +88,9 @@ public: enum { COND_FUNCTANK_DISMOUNT = BaseClass::NEXT_CONDITION, +#ifdef MAPBASE + COND_FUNCTANK_FORCED, +#endif NEXT_CONDITION, }; @@ -104,6 +113,12 @@ public: bool IsMounted( void ) { return m_bMounted; } +#ifdef MAPBASE + void SetMounted( bool bMounted ) { m_bMounted = bMounted; } + + bool CanUnholsterWeapon( void ) { return !IsMounted(); } +#endif + private: // Schedule diff --git a/sp/src/game/server/hl2/ai_behavior_police.cpp b/sp/src/game/server/hl2/ai_behavior_police.cpp index eb1b45b3..ea97ec9c 100644 --- a/sp/src/game/server/hl2/ai_behavior_police.cpp +++ b/sp/src/game/server/hl2/ai_behavior_police.cpp @@ -125,12 +125,32 @@ void CAI_PolicingBehavior::HostSpeakSentence( const char *pSentence, SentencePri if ( pCop != NULL ) { +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + pCop->SpeakIfAllowed( pSentence, nSoundPriority, nCriteria ); +#else CAI_Sentence< CNPC_MetroPolice > *pSentences = pCop->GetSentences(); pSentences->Speak( pSentence, nSoundPriority, nCriteria ); +#endif } } +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CAI_PolicingBehavior::HostSpeakSentence( const char *pSentence, const char *modifiers, SentencePriority_t nSoundPriority, SentenceCriteria_t nCriteria ) +{ + // If we're a cop, turn the baton on + CNPC_MetroPolice *pCop = dynamic_cast(GetOuter()); + + if ( pCop != NULL ) + { + pCop->SpeakIfAllowed( pSentence, modifiers, nSoundPriority, nCriteria ); + } +} +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -214,6 +234,9 @@ void CAI_PolicingBehavior::AnnouncePolicing( void ) "METROPOLICE_MOVE_ALONG_C", }; +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + HostSpeakSentence(TLK_COP_MOVE_ALONG, UTIL_VarArgs("numwarnings:%i", m_nNumWarnings), SENTENCE_PRIORITY_MEDIUM, SENTENCE_CRITERIA_NORMAL); +#else if ( m_nNumWarnings <= 3 ) { HostSpeakSentence( pWarnings[ m_nNumWarnings - 1 ], SENTENCE_PRIORITY_MEDIUM, SENTENCE_CRITERIA_NORMAL ); @@ -226,6 +249,7 @@ void CAI_PolicingBehavior::AnnouncePolicing( void ) int iSentence = RandomInt( 0, 1 ); HostSpeakSentence( pWarnings[ iSentence ], SENTENCE_PRIORITY_MEDIUM, SENTENCE_CRITERIA_NORMAL ); } +#endif } //----------------------------------------------------------------------------- diff --git a/sp/src/game/server/hl2/ai_behavior_police.h b/sp/src/game/server/hl2/ai_behavior_police.h index 84f132be..ed1f58da 100644 --- a/sp/src/game/server/hl2/ai_behavior_police.h +++ b/sp/src/game/server/hl2/ai_behavior_police.h @@ -68,6 +68,9 @@ public: private: void HostSpeakSentence( const char *pSentence, SentencePriority_t nSoundPriority, SentenceCriteria_t nCriteria ); +#ifdef MAPBASE + void HostSpeakSentence( const char *pSentence, const char *modifiers, SentencePriority_t nSoundPriority, SentenceCriteria_t nCriteria ); +#endif int TranslateSchedule( int scheduleType ); diff --git a/sp/src/game/server/hl2/cbasehelicopter.cpp b/sp/src/game/server/hl2/cbasehelicopter.cpp index 1243fe18..2b46bce6 100644 --- a/sp/src/game/server/hl2/cbasehelicopter.cpp +++ b/sp/src/game/server/hl2/cbasehelicopter.cpp @@ -101,6 +101,10 @@ BEGIN_DATADESC( CBaseHelicopter ) DEFINE_FIELD( m_bSuppressSound, FIELD_BOOLEAN ), DEFINE_FIELD( m_flStartupTime, FIELD_TIME ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bAllowAnyDamage, FIELD_BOOLEAN, "AllowAnyDamage" ), +#endif + DEFINE_FIELD( m_cullBoxMins, FIELD_VECTOR ), DEFINE_FIELD( m_cullBoxMaxs, FIELD_VECTOR ), @@ -193,8 +197,15 @@ void CBaseHelicopter::Spawn( void ) AddFlag( FL_NPC ); +#ifdef MAPBASE + if (m_flMaxSpeed == 0) + m_flMaxSpeed = BASECHOPPER_MAX_SPEED; + if (m_flMaxSpeedFiring == 0) + m_flMaxSpeedFiring = BASECHOPPER_MAX_FIRING_SPEED; +#else m_flMaxSpeed = BASECHOPPER_MAX_SPEED; m_flMaxSpeedFiring = BASECHOPPER_MAX_FIRING_SPEED; +#endif m_takedamage = DAMAGE_AIM; // Don't start up if the level designer has asked the @@ -1110,6 +1121,11 @@ void CBaseHelicopter::InputDisableRotorSound( inputdata_t &inputdata ) //----------------------------------------------------------------------------- void CBaseHelicopter::InputKill( inputdata_t &inputdata ) { +#ifdef MAPBASE + // Finally, an InputKill override that makes sense. + m_OnKilled.FireOutput( inputdata.pActivator, this ); +#endif + StopRotorWash(); m_bSuppressSound = true; @@ -1269,7 +1285,11 @@ void CBaseHelicopter::TraceAttack( const CTakeDamageInfo &info, const Vector &ve // Take no damage from trace attacks unless it's blast damage. RadiusDamage() sometimes calls // TraceAttack() as a means for delivering blast damage. Usually when the explosive penetrates // the target. (RPG missiles do this sometimes). +#ifdef MAPBASE + if ( info.GetDamageType() & (DMG_BLAST|DMG_AIRBOAT) || m_bAllowAnyDamage ) +#else if( info.GetDamageType() & (DMG_BLAST|DMG_AIRBOAT) ) +#endif { BaseClass::TraceAttack( info, vecDir, ptr, pAccumulator ); } @@ -1520,9 +1540,23 @@ bool CBaseHelicopter::ChooseEnemy( void ) // New enemy! Clear the timers and set conditions. SetEnemy( pNewEnemy ); m_flLastSeen = m_flPrevSeen = gpGlobals->curtime; +#ifdef MAPBASE + Remember( ( pNewEnemy->IsPlayer() ) ? bits_MEMORY_HAD_PLAYER : bits_MEMORY_HAD_ENEMY ); +#endif } else { +#ifdef MAPBASE + if (!pNewEnemy) + { + if ( HasMemory( bits_MEMORY_HAD_PLAYER ) ) + { + m_OnLostPlayer.FireOutput( GetEnemy(), this ); + } + m_OnLostEnemy.FireOutput( GetEnemy(), this ); + } +#endif + SetEnemy( NULL ); SetState( NPC_STATE_ALERT ); } @@ -1542,6 +1576,45 @@ bool CBaseHelicopter::ChooseEnemy( void ) //----------------------------------------------------------------------------- void CBaseHelicopter::GatherEnemyConditions( CBaseEntity *pEnemy ) { +#ifdef MAPBASE + // --------------------------- + // Ported from CAI_BaseNPC. Need it to fire outputs without setting all kinds of conditions + // --------------------------- + if ( HasCondition( COND_NEW_ENEMY ) || GetSenses()->GetTimeLastUpdate( GetEnemy() ) == gpGlobals->curtime ) + { + bool bSensesDidSee = GetSenses()->DidSeeEntity( pEnemy ); + + if ( !bSensesDidSee && ( ( EnemyDistance( pEnemy ) >= GetSenses()->GetDistLook() ) || !FVisible( pEnemy, MASK_BLOCKLOS ) ) ) + { + // No LOS to enemy + if (HasMemory( bits_MEMORY_HAD_LOS )) + { + // Send output event + if (GetEnemy()->IsPlayer()) + { + m_OnLostPlayerLOS.FireOutput( GetEnemy(), this ); + } + m_OnLostEnemyLOS.FireOutput( GetEnemy(), this ); + } + Forget( bits_MEMORY_HAD_LOS ); + } + else + { + if (!HasMemory( bits_MEMORY_HAD_LOS )) + { + // Send output event + EHANDLE hEnemy; + hEnemy.Set( GetEnemy() ); + + if (GetEnemy()->IsPlayer()) + m_OnFoundPlayer.Set(hEnemy, hEnemy, this); + m_OnFoundEnemy.Set(hEnemy, hEnemy, this); + } + Remember( bits_MEMORY_HAD_LOS ); + } + } +#endif + // ------------------- // If enemy is dead // ------------------- @@ -1595,3 +1668,103 @@ void ExpandBBox(Vector &vecMins, Vector &vecMaxs) vecMins.Init(-maxval, -maxval, -maxval); vecMaxs.Init(maxval, maxval, maxval); } + +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// A custom helicopter +//----------------------------------------------------------------------------- +class CNPC_CustomHelicopter : public CBaseHelicopter +{ +public: + DECLARE_CLASS( CNPC_CustomHelicopter, CBaseHelicopter ); + DECLARE_DATADESC(); + + CNPC_CustomHelicopter(); + ~CNPC_CustomHelicopter(); + + virtual void Precache( void ); + virtual void Spawn( void ); + + void InitializeRotorSound( void ); + + float GetAcceleration( void ) { return m_flAcceleration; } + + float m_flAcceleration; + + string_t m_iszRotorSound; + string_t m_iszRotorBlast; +}; + +LINK_ENTITY_TO_CLASS( npc_helicopter_custom, CNPC_CustomHelicopter ); + +BEGIN_DATADESC( CNPC_CustomHelicopter ) + + DEFINE_KEYFIELD( m_flMaxSpeed, FIELD_FLOAT, "MaxSpeed" ), + DEFINE_KEYFIELD( m_flMaxSpeedFiring, FIELD_FLOAT, "MaxSpeedfiring" ), + + DEFINE_KEYFIELD( m_flAcceleration, FIELD_FLOAT, "Acceleration" ), + + DEFINE_KEYFIELD( m_iszRotorSound, FIELD_STRING, "RotorSound" ), + DEFINE_KEYFIELD( m_iszRotorBlast, FIELD_STRING, "RotorBlast" ), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CNPC_CustomHelicopter::CNPC_CustomHelicopter() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CNPC_CustomHelicopter::~CNPC_CustomHelicopter() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CNPC_CustomHelicopter::Precache( void ) +{ + PrecacheModel( STRING(GetModelName()) ); + + PrecacheScriptSound( STRING(m_iszRotorSound) ); + PrecacheScriptSound( STRING(m_iszRotorBlast) ); + + BaseClass::Precache(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CNPC_CustomHelicopter::Spawn( void ) +{ + SetModel( STRING(GetModelName()) ); + + BaseClass::Spawn(); +} + +//------------------------------------------------------------------------------ +// Purpose: Create our rotor sound +//------------------------------------------------------------------------------ +void CNPC_CustomHelicopter::InitializeRotorSound( void ) +{ + if ( !m_pRotorSound ) + { + CSoundEnvelopeController &controller = CSoundEnvelopeController::GetController(); + CPASAttenuationFilter filter( this ); + + m_pRotorSound = controller.SoundCreate( filter, entindex(), STRING(m_iszRotorSound) ); + m_pRotorBlast = controller.SoundCreate( filter, entindex(), STRING(m_iszRotorBlast) ); + } + else + { + Assert(m_pRotorSound); + Assert(m_pRotorBlast); + } + + BaseClass::InitializeRotorSound(); +} +#endif diff --git a/sp/src/game/server/hl2/cbasehelicopter.h b/sp/src/game/server/hl2/cbasehelicopter.h index 4ca3b091..fcf74291 100644 --- a/sp/src/game/server/hl2/cbasehelicopter.h +++ b/sp/src/game/server/hl2/cbasehelicopter.h @@ -215,6 +215,10 @@ protected: EHANDLE m_hRotorWash; // Attached rotorwash entity +#ifdef MAPBASE + bool m_bAllowAnyDamage; +#endif + // Inputs void InputActivate( inputdata_t &inputdata ); diff --git a/sp/src/game/server/hl2/combine_mine.cpp b/sp/src/game/server/hl2/combine_mine.cpp index 4eb7283f..82034a11 100644 --- a/sp/src/game/server/hl2/combine_mine.cpp +++ b/sp/src/game/server/hl2/combine_mine.cpp @@ -87,9 +87,16 @@ BEGIN_DATADESC( CBounceBomb ) DEFINE_FIELD( m_bFoeNearest, FIELD_BOOLEAN ), DEFINE_FIELD( m_flIgnoreWorldTime, FIELD_TIME ), DEFINE_KEYFIELD( m_bDisarmed, FIELD_BOOLEAN, "StartDisarmed" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_iInitialState, FIELD_INTEGER, "InitialState" ), +#endif DEFINE_KEYFIELD( m_iModification, FIELD_INTEGER, "Modification" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bPlacedByPlayer, FIELD_BOOLEAN, "Friendly" ), +#else DEFINE_FIELD( m_bPlacedByPlayer, FIELD_BOOLEAN ), +#endif DEFINE_FIELD( m_bHeldByPhysgun, FIELD_BOOLEAN ), DEFINE_FIELD( m_iFlipAttempts, FIELD_INTEGER ), @@ -106,6 +113,14 @@ BEGIN_DATADESC( CBounceBomb ) DEFINE_OUTPUT( m_OnPulledUp, "OnPulledUp" ), DEFINE_INPUTFUNC( FIELD_VOID, "Disarm", InputDisarm ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "Bounce", InputBounce ), + DEFINE_INPUTFUNC( FIELD_EHANDLE, "BounceAtTarget", InputBounceAtTarget ), + + DEFINE_OUTPUT( m_OnTriggered, "OnTriggered" ), + DEFINE_OUTPUT( m_OnExplode, "OnExplode" ), +#endif + END_DATADESC() string_t CBounceBomb::gm_iszFloorTurretClassname; @@ -178,10 +193,23 @@ void CBounceBomb::Spawn() { SetMineState( MINE_STATE_DORMANT ); } +#ifdef MAPBASE + else + { + // NOTE: MINE_STATE_DEPLOY and MINE_STATE_DORMANT are swapped in this case! + if (m_iInitialState == 0) + SetMineState( MINE_STATE_DEPLOY ); + else if (m_iInitialState == 1) + SetMineState( MINE_STATE_DORMANT ); + else + SetMineState( m_iInitialState ); + } +#else else { SetMineState( MINE_STATE_DEPLOY ); } +#endif // default to a different skin for cavern turrets (unless explicitly overridden) if ( m_iModification == MINE_MODIFICATION_CAVERN ) @@ -352,7 +380,11 @@ void CBounceBomb::SetMineState( int iState ) else { SetThink( &CBounceBomb::BounceThink ); +#ifdef MAPBASE + SetNextThink( gpGlobals->curtime + m_flExplosionDelay ); +#else SetNextThink( gpGlobals->curtime + 0.5 ); +#endif } } break; @@ -872,6 +904,22 @@ float CBounceBomb::FindNearestNPC() } } +#ifdef MAPBASE_MP + for (i = 1; i <= gpGlobals->maxClients; i++) + { + CBaseEntity *pPlayer = UTIL_PlayerByIndex( i ); + if ( pPlayer && !(pPlayer->GetFlags() & FL_NOTARGET) ) + { + float flDist = (pPlayer->GetAbsOrigin() - GetAbsOrigin() ).LengthSqr(); + + if( flDist < flNearest && FVisible( pPlayer, MASK_SOLID_BRUSHONLY ) ) + { + flNearest = flDist; + SetNearestNPC( pPlayer ); + } + } + } +#else // finally, check the player. CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); @@ -885,6 +933,7 @@ float CBounceBomb::FindNearestNPC() SetNearestNPC( pPlayer ); } } +#endif if( m_hNearestNPC.Get() ) { @@ -930,10 +979,16 @@ bool CBounceBomb::IsFriend( CBaseEntity *pEntity ) return false; } - if( classify == CLASS_METROPOLICE || + if( classify == CLASS_METROPOLICE || classify == CLASS_COMBINE || classify == CLASS_MILITARY || classify == CLASS_COMBINE_HUNTER || +#ifdef MAPBASE + classify == CLASS_MANHACK || + classify == CLASS_STALKER || + classify == CLASS_PROTOSNIPER || + classify == CLASS_COMBINE_GUNSHIP || +#endif classify == CLASS_SCANNER ) { bIsCombine = true; @@ -976,7 +1031,12 @@ void CBounceBomb::SearchThink() if( m_pConstraint && gpGlobals->curtime - m_flTimeGrabbed >= 1.0f ) { +#ifdef MAPBASE + // We don't already store our holder for some reason + m_OnPulledUp.FireOutput( UTIL_GetLocalPlayer(), this ); +#else m_OnPulledUp.FireOutput( this, this ); +#endif SetMineState( MINE_STATE_CAPTIVE ); return; } @@ -1002,6 +1062,9 @@ void CBounceBomb::SearchThink() if( flNearestNPCDist <= BOUNCEBOMB_DETONATE_RADIUS && !IsFriend( m_hNearestNPC ) ) { +#ifdef MAPBASE + m_OnTriggered.FireOutput( m_hNearestNPC, this ); +#endif if( m_bBounce ) { SetMineState( MINE_STATE_TRIGGERED ); @@ -1087,6 +1150,11 @@ void CBounceBomb::ExplodeThink() { ExplosionCreate( GetAbsOrigin(), GetAbsAngles(), (pThrower) ? pThrower : this, BOUNCEBOMB_EXPLODE_DAMAGE, BOUNCEBOMB_EXPLODE_RADIUS, true); } + +#ifdef MAPBASE + m_OnExplode.FireOutput( m_hNearestNPC, this ); +#endif + UTIL_Remove( this ); } @@ -1165,6 +1233,24 @@ void CBounceBomb::InputDisarm( inputdata_t &inputdata ) } } +#ifdef MAPBASE +//--------------------------------------------------------- +//--------------------------------------------------------- +void CBounceBomb::InputBounce( inputdata_t &inputdata ) +{ + m_hNearestNPC = NULL; + SetMineState(MINE_STATE_TRIGGERED); +} + +//--------------------------------------------------------- +//--------------------------------------------------------- +void CBounceBomb::InputBounceAtTarget( inputdata_t &inputdata ) +{ + m_hNearestNPC = inputdata.value.Entity(); + SetMineState(MINE_STATE_TRIGGERED); +} +#endif + //--------------------------------------------------------- //--------------------------------------------------------- void CBounceBomb::OnPhysGunDrop( CBasePlayer *pPhysGunUser, PhysGunDrop_t Reason ) diff --git a/sp/src/game/server/hl2/combine_mine.h b/sp/src/game/server/hl2/combine_mine.h index 48dbb468..12384ee9 100644 --- a/sp/src/game/server/hl2/combine_mine.h +++ b/sp/src/game/server/hl2/combine_mine.h @@ -30,7 +30,11 @@ class CBounceBomb : public CBaseAnimating, public CDefaultPlayerPickupVPhysics DECLARE_CLASS( CBounceBomb, CBaseAnimating ); public: +#ifdef MAPBASE + CBounceBomb() { m_pWarnSound = NULL; m_bPlacedByPlayer = false; m_flExplosionDelay = 0.5f; } +#else CBounceBomb() { m_pWarnSound = NULL; m_bPlacedByPlayer = false; } +#endif void Precache(); void Spawn(); void OnRestore(); @@ -104,6 +108,9 @@ private: float m_flIgnoreWorldTime; bool m_bDisarmed; +#ifdef MAPBASE + int m_iInitialState; +#endif bool m_bPlacedByPlayer; @@ -121,6 +128,12 @@ private: COutputEvent m_OnPulledUp; void InputDisarm( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputBounce( inputdata_t &inputdata ); + void InputBounceAtTarget( inputdata_t &inputdata ); + COutputEvent m_OnTriggered; + COutputEvent m_OnExplode; +#endif }; diff --git a/sp/src/game/server/hl2/env_headcrabcanister.cpp b/sp/src/game/server/hl2/env_headcrabcanister.cpp index ed1883d1..e94fe3f1 100644 --- a/sp/src/game/server/hl2/env_headcrabcanister.cpp +++ b/sp/src/game/server/hl2/env_headcrabcanister.cpp @@ -95,6 +95,9 @@ private: void InputOpenCanister( inputdata_t &inputdata ); void InputSpawnHeadcrabs( inputdata_t &inputdata ); void InputStopSmoke( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputStopHissing( inputdata_t &inputdata ); +#endif // Think(s) void HeadcrabCanisterSkyboxThink( void ); @@ -152,6 +155,9 @@ private: COutputEHANDLE m_OnLaunched; COutputEvent m_OnImpacted; COutputEvent m_OnOpened; +#ifdef MAPBASE + COutputEHANDLE m_OnCrab; +#endif // Only for skybox only cannisters. float m_flMinRefireTime; @@ -201,11 +207,17 @@ BEGIN_DATADESC( CEnvHeadcrabCanister ) DEFINE_INPUTFUNC( FIELD_VOID, "OpenCanister", InputOpenCanister ), DEFINE_INPUTFUNC( FIELD_VOID, "SpawnHeadcrabs", InputSpawnHeadcrabs ), DEFINE_INPUTFUNC( FIELD_VOID, "StopSmoke", InputStopSmoke ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "StopHissing", InputStopHissing ), +#endif // Outputs DEFINE_OUTPUT( m_OnLaunched, "OnLaunched" ), DEFINE_OUTPUT( m_OnImpacted, "OnImpacted" ), DEFINE_OUTPUT( m_OnOpened, "OnOpened" ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OnCrab, "OnCrab" ), +#endif END_DATADESC() @@ -545,6 +557,17 @@ void CEnvHeadcrabCanister::InputStopSmoke( inputdata_t &inputdata ) } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CEnvHeadcrabCanister::InputStopHissing( inputdata_t &inputdata ) +{ + StopSound( "HeadcrabCanister.AfterLanding" ); +} +#endif + //============================================================================= // // Enumerator for swept bbox collision. @@ -725,6 +748,10 @@ void CEnvHeadcrabCanister::HeadcrabCanisterSpawnHeadcrabThink() pHeadCrab->SetLocalOrigin( vec3_origin ); pHeadCrab->SetLocalAngles( vec3_angle ); pHeadCrab->CrawlFromCanister(); + +#ifdef MAPBASE + m_OnCrab.Set(pHeadCrab, pHeadCrab, this); +#endif } if ( m_nHeadcrabCount != 0 ) diff --git a/sp/src/game/server/hl2/env_speaker.cpp b/sp/src/game/server/hl2/env_speaker.cpp index dd141eca..7b193a9b 100644 --- a/sp/src/game/server/hl2/env_speaker.cpp +++ b/sp/src/game/server/hl2/env_speaker.cpp @@ -21,6 +21,9 @@ #include "ndebugoverlay.h" #include "soundscape.h" #include "AI_ResponseSystem.h" +#ifdef MAPBASE +#include "sceneentity.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -35,6 +38,10 @@ LINK_ENTITY_TO_CLASS( env_speaker, CSpeaker ); BEGIN_DATADESC( CSpeaker ) +#ifdef MAPBASE + DEFINE_FIELD( m_hTarget, FIELD_EHANDLE ), +#endif + DEFINE_KEYFIELD( m_delayMin, FIELD_FLOAT, "delaymin" ), DEFINE_KEYFIELD( m_delayMax, FIELD_FLOAT, "delaymax" ), DEFINE_KEYFIELD( m_iszRuleScriptFile, FIELD_STRING, "rulescript" ), @@ -50,6 +57,10 @@ BEGIN_DATADESC( CSpeaker ) DEFINE_INPUTFUNC( FIELD_VOID, "TurnOff", InputTurnOff ), DEFINE_INPUTFUNC( FIELD_VOID, "Toggle", InputToggle ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OnSpeak, "OnSpeak" ), +#endif + END_DATADESC() @@ -181,6 +192,103 @@ void CSpeaker::SpeakerThink( void ) g_AIFoesTalkSemaphore.Acquire( 5, this ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +inline CBaseEntity *CSpeaker::GetTarget() +{ + if (!m_hTarget && m_target != NULL_STRING) + m_hTarget = gEntList.FindEntityByName(NULL, STRING(m_target), this, NULL, this); + return m_hTarget; +} + +//----------------------------------------------------------------------------- +// Purpose: Copied from CBaseEntity so we could use a !target for everything +// Input : *conceptName - +//----------------------------------------------------------------------------- +void CSpeaker::DispatchResponse( const char *conceptName ) +{ + IResponseSystem *rs = GetResponseSystem(); + if ( !rs ) + return; + + CBaseEntity *pTarget = GetTarget(); + if (!pTarget) + pTarget = this; + + // See CBaseEntity and stuff... + AI_CriteriaSet set; + set.AppendCriteria( "concept", conceptName, CONCEPT_WEIGHT ); + ModifyOrAppendCriteria( set ); + CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); + if( pPlayer ) + pPlayer->ModifyOrAppendPlayerCriteria( set ); + ReAppendContextCriteria( set ); + AI_Response result; + bool found = rs->FindBestResponse( set, result ); + if ( !found ) + { + return; + } + + // Handle the response here... + char response[ 256 ]; + result.GetResponse( response, sizeof( response ) ); + if (response[0] == '$') + { + response[0] = '\0'; + DevMsg("Replacing %s with %s...\n", response, GetContextValue(response)); + Q_strncpy(response, GetContextValue(response), sizeof(response)); + PrecacheScriptSound( response ); + } + + switch ( result.GetType() ) + { + case RESPONSE_SPEAK: + { + pTarget->EmitSound( response ); + } + break; + case RESPONSE_SENTENCE: + { + int sentenceIndex = SENTENCEG_Lookup( response ); + if( sentenceIndex == -1 ) + { + // sentence not found + break; + } + + // FIXME: Get pitch from npc? + CPASAttenuationFilter filter( pTarget ); + CBaseEntity::EmitSentenceByIndex( filter, pTarget->entindex(), CHAN_VOICE, sentenceIndex, 1, result.GetSoundLevel(), 0, PITCH_NORM ); + } + break; + case RESPONSE_SCENE: + { + CBaseFlex *pFlex = NULL; + if (pTarget != this) + { + // Attempt to get flex on the target + pFlex = dynamic_cast(pTarget); + } + InstancedScriptedScene(pFlex, response); + } + break; + case RESPONSE_PRINT: + { + + } + break; + default: + break; + } + + // AllocPooledString? + m_OnSpeak.Set(MAKE_STRING(response), pTarget, this); +} +#endif + void CSpeaker::InputTurnOn( inputdata_t &inputdata ) { diff --git a/sp/src/game/server/hl2/env_speaker.h b/sp/src/game/server/hl2/env_speaker.h index 20fbeb6b..a28a2a47 100644 --- a/sp/src/game/server/hl2/env_speaker.h +++ b/sp/src/game/server/hl2/env_speaker.h @@ -36,6 +36,13 @@ protected: void SpeakerThink( void ); +#ifdef MAPBASE + EHANDLE m_hTarget; + virtual void InputSetTarget( inputdata_t &inputdata ) { BaseClass::InputSetTarget(inputdata); m_hTarget = NULL; } + CBaseEntity *GetTarget(); + virtual void DispatchResponse( const char *conceptName ); +#endif + void InputToggle( inputdata_t &inputdata ); float m_delayMin; @@ -49,6 +56,10 @@ public: void InputTurnOff( inputdata_t &inputdata ); void InputTurnOn( inputdata_t &inputdata ); + +#ifdef MAPBASE + COutputString m_OnSpeak; +#endif }; #endif // ENV_SPEAKER_H diff --git a/sp/src/game/server/hl2/func_recharge.cpp b/sp/src/game/server/hl2/func_recharge.cpp index 37c42637..e68c1c96 100644 --- a/sp/src/game/server/hl2/func_recharge.cpp +++ b/sp/src/game/server/hl2/func_recharge.cpp @@ -35,6 +35,9 @@ public: DECLARE_CLASS( CRecharge, CBaseToggle ); void Spawn( ); +#ifdef MAPBASE + void Precache( void ); +#endif bool CreateVPhysics(); int DrawDebugTextOverlays(void); void Off(void); @@ -45,6 +48,10 @@ public: private: void InputRecharge( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetCharge( inputdata_t &inputdata ); + void InputSetChargeNoMax( inputdata_t &inputdata ); +#endif float MaxJuice() const; void UpdateJuice( int newJuice ); @@ -56,6 +63,10 @@ private: int m_iJuice; int m_iOn; // 0 = off, 1 = startup, 2 = going float m_flSoundTime; +#ifdef MAPBASE + int m_iMaxJuice; + int m_iIncrementValue; +#endif int m_nState; @@ -70,9 +81,16 @@ BEGIN_DATADESC( CRecharge ) DEFINE_FIELD( m_flNextCharge, FIELD_TIME ), DEFINE_FIELD( m_iReactivate, FIELD_INTEGER), - DEFINE_FIELD( m_iJuice, FIELD_INTEGER), +#ifdef MAPBASE + DEFINE_KEYFIELD(m_iJuice, FIELD_INTEGER, "Charge"), +#else + DEFINE_FIELD(m_iJuice, FIELD_INTEGER), +#endif DEFINE_FIELD( m_iOn, FIELD_INTEGER), DEFINE_FIELD( m_flSoundTime, FIELD_TIME ), +#ifdef MAPBASE + DEFINE_INPUT( m_iIncrementValue, FIELD_INTEGER, "SetIncrementValue" ), +#endif DEFINE_FIELD( m_nState, FIELD_INTEGER ), // Function Pointers @@ -86,6 +104,10 @@ BEGIN_DATADESC( CRecharge ) DEFINE_OUTPUT(m_OnPlayerUse, "OnPlayerUse" ), DEFINE_INPUTFUNC( FIELD_VOID, "Recharge", InputRecharge ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetCharge", InputSetCharge ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetChargeNoMax", InputSetChargeNoMax ), +#endif END_DATADESC() @@ -123,13 +145,30 @@ void CRecharge::Spawn() SetModel( STRING( GetModelName() ) ); +#ifdef MAPBASE + // In case the juice was overridden + if (m_iJuice == 0) + UpdateJuice( MaxJuice() ); + else if (m_iJuice == -1) + m_iJuice = 0; +#else UpdateJuice( MaxJuice() ); +#endif m_nState = 0; CreateVPhysics(); } +#ifdef MAPBASE +void CRecharge::Precache( void ) +{ + PrecacheScriptSound( "SuitRecharge.Deny" ); + PrecacheScriptSound( "SuitRecharge.Start" ); + PrecacheScriptSound( "SuitRecharge.ChargingLoop" ); +} +#endif + bool CRecharge::CreateVPhysics() { VPhysicsInitStatic(); @@ -156,6 +195,14 @@ int CRecharge::DrawDebugTextOverlays(void) //----------------------------------------------------------------------------- float CRecharge::MaxJuice() const { +#ifdef MAPBASE + if ( m_iMaxJuice != 0 ) + { + // It must've been overridden by the mapper + return m_iMaxJuice; + } +#endif + if ( HasSpawnFlags( SF_CITADEL_RECHARGER ) ) { return sk_suitcharger_citadel.GetFloat(); @@ -199,6 +246,18 @@ void CRecharge::InputRecharge( inputdata_t &inputdata ) Recharge(); } +#ifdef MAPBASE +void CRecharge::InputSetCharge( inputdata_t &inputdata ) +{ + m_iMaxJuice = m_iJuice = inputdata.value.Int(); +} + +void CRecharge::InputSetChargeNoMax( inputdata_t &inputdata ) +{ + UpdateJuice(inputdata.value.Int()); +} +#endif + void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { // if it's not a player, ignore @@ -287,6 +346,11 @@ void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use } } +#ifdef MAPBASE + if (m_iIncrementValue != 0) + nIncrementArmor = m_iIncrementValue; +#endif + if (pl->ArmorValue() < nMaxArmor) { UpdateJuice( m_iJuice - nIncrementArmor ); @@ -350,6 +414,9 @@ public: private: void InputRecharge( inputdata_t &inputdata ); void InputSetCharge( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetChargeNoMax( inputdata_t &inputdata ); +#endif float MaxJuice() const; void UpdateJuice( int newJuice ); void Precache( void ); @@ -365,6 +432,9 @@ private: int m_nState; int m_iCaps; int m_iMaxJuice; +#ifdef MAPBASE + int m_iIncrementValue; +#endif COutputFloat m_OutRemainingCharge; COutputEvent m_OnHalfEmpty; @@ -380,12 +450,21 @@ BEGIN_DATADESC( CNewRecharge ) DEFINE_FIELD( m_flNextCharge, FIELD_TIME ), DEFINE_FIELD( m_iReactivate, FIELD_INTEGER), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_iJuice, FIELD_INTEGER, "Charge" ), +#else DEFINE_FIELD( m_iJuice, FIELD_INTEGER), +#endif DEFINE_FIELD( m_iOn, FIELD_INTEGER), DEFINE_FIELD( m_flSoundTime, FIELD_TIME ), DEFINE_FIELD( m_nState, FIELD_INTEGER ), DEFINE_FIELD( m_iCaps, FIELD_INTEGER ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_iMaxJuice, FIELD_INTEGER, "MaxCharge" ), + DEFINE_INPUT( m_iIncrementValue, FIELD_INTEGER, "SetIncrementValue" ), +#else DEFINE_FIELD( m_iMaxJuice, FIELD_INTEGER ), +#endif // Function Pointers DEFINE_FUNCTION( Off ), @@ -400,6 +479,9 @@ BEGIN_DATADESC( CNewRecharge ) DEFINE_INPUTFUNC( FIELD_VOID, "Recharge", InputRecharge ), DEFINE_INPUTFUNC( FIELD_INTEGER, "SetCharge", InputSetCharge ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetChargeNoMax", InputSetChargeNoMax ), +#endif END_DATADESC() @@ -412,6 +494,10 @@ LINK_ENTITY_TO_CLASS( item_suitcharger, CNewRecharge); #define CITADEL_CHARGES_PER_SECOND 10 / CHARGE_RATE #define CALLS_PER_SECOND 7.0f * CHARGES_PER_SECOND +#ifdef MAPBASE +#define CUSTOM_CHARGES_PER_SECOND(inc) inc / CHARGE_RATE +#endif + bool CNewRecharge::KeyValue( const char *szKeyName, const char *szValue ) { @@ -446,6 +532,14 @@ void CNewRecharge::Precache( void ) void CNewRecharge::SetInitialCharge( void ) { +#ifdef MAPBASE + if ( m_iMaxJuice != 0 ) + { + // It must've been overridden by the mapper + return; + } +#endif + if ( HasSpawnFlags( SF_KLEINER_RECHARGER ) ) { // The charger in Kleiner's lab. @@ -477,7 +571,17 @@ void CNewRecharge::Spawn() SetInitialCharge(); +#ifdef MAPBASE + // In case the juice was overridden + if (m_iJuice == 0) + UpdateJuice( MaxJuice() ); + else if (m_iJuice == -1) + UpdateJuice( 0 ); + else + UpdateJuice( m_iJuice ); +#else UpdateJuice( MaxJuice() ); +#endif m_nState = 0; m_iCaps = FCAP_CONTINUOUS_USE; @@ -587,6 +691,18 @@ void CNewRecharge::InputSetCharge( inputdata_t &inputdata ) StudioFrameAdvance(); } +#ifdef MAPBASE +void CNewRecharge::InputSetChargeNoMax( inputdata_t &inputdata ) +{ + ResetSequence( LookupSequence( "idle" ) ); + + m_flJuice = inputdata.value.Float(); + + UpdateJuice(m_flJuice); + StudioFrameAdvance(); +} +#endif + void CNewRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { // if it's not a player, ignore @@ -606,6 +722,11 @@ void CNewRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE if ( HasSpawnFlags( SF_CITADEL_RECHARGER ) ) flCharges = CITADEL_CHARGES_PER_SECOND; +#ifdef MAPBASE + if ( m_iIncrementValue != 0 ) + flCharges = CUSTOM_CHARGES_PER_SECOND(m_iIncrementValue); +#endif + m_flJuice -= flCharges / flCalls; StudioFrameAdvance(); } @@ -667,6 +788,11 @@ void CNewRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE } } +#ifdef MAPBASE + if (m_iIncrementValue != 0) + nIncrementArmor = m_iIncrementValue; +#endif + // If we're over our limit, debounce our keys if ( pPlayer->ArmorValue() >= nMaxArmor) { diff --git a/sp/src/game/server/hl2/func_tank.cpp b/sp/src/game/server/hl2/func_tank.cpp index db5a2e32..b2d99cdf 100644 --- a/sp/src/game/server/hl2/func_tank.cpp +++ b/sp/src/game/server/hl2/func_tank.cpp @@ -39,6 +39,10 @@ #include "particle_parse.h" // NVNT turret recoil #include "haptics/haptic_utils.h" +#ifdef MAPBASE +#include "shot_manipulator.h" +#include "filters.h" +#endif #ifdef HL2_DLL #include "hl2_player.h" @@ -49,6 +53,10 @@ extern Vector PointOnLineNearestPoint(const Vector& vStartPos, const Vector& vEndPos, const Vector& vPoint); +#ifdef MAPBASE +extern ConVar ai_debug_shoot_positions; +#endif + ConVar mortar_visualize("mortar_visualize", "0" ); BEGIN_DATADESC( CFuncTank ) @@ -70,13 +78,19 @@ BEGIN_DATADESC( CFuncTank ) DEFINE_KEYFIELD( m_spriteScale, FIELD_FLOAT, "spritescale" ), DEFINE_KEYFIELD( m_iszSpriteSmoke, FIELD_STRING, "spritesmoke" ), DEFINE_KEYFIELD( m_iszSpriteFlash, FIELD_STRING, "spriteflash" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_iszShootSound, FIELD_SOUNDNAME, "shootsound" ), +#endif +#ifndef AMMOTYPE_MOVED DEFINE_KEYFIELD( m_bulletType, FIELD_INTEGER, "bullet" ), +#endif DEFINE_FIELD( m_nBulletCount, FIELD_INTEGER ), DEFINE_KEYFIELD( m_spread, FIELD_INTEGER, "firespread" ), DEFINE_KEYFIELD( m_iBulletDamage, FIELD_INTEGER, "bullet_damage" ), DEFINE_KEYFIELD( m_iBulletDamageVsPlayer, FIELD_INTEGER, "bullet_damage_vs_player" ), DEFINE_KEYFIELD( m_iszMaster, FIELD_STRING, "master" ), +#ifndef AMMOTYPE_MOVED #ifdef HL2_EPISODIC DEFINE_KEYFIELD( m_iszAmmoType, FIELD_STRING, "ammotype" ), DEFINE_FIELD( m_iAmmoType, FIELD_INTEGER ), @@ -85,6 +99,7 @@ BEGIN_DATADESC( CFuncTank ) DEFINE_FIELD( m_iMediumAmmoType, FIELD_INTEGER ), DEFINE_FIELD( m_iLargeAmmoType, FIELD_INTEGER ), #endif // HL2_EPISODIC +#endif // AMMOTYPE_MOVED DEFINE_KEYFIELD( m_soundStartRotate, FIELD_SOUNDNAME, "rotatestartsound" ), DEFINE_KEYFIELD( m_soundStopRotate, FIELD_SOUNDNAME, "rotatestopsound" ), @@ -115,7 +130,11 @@ BEGIN_DATADESC( CFuncTank ) DEFINE_FIELD( m_hControlVolume, FIELD_EHANDLE ), DEFINE_KEYFIELD( m_iszControlVolume, FIELD_STRING, "control_volume" ), DEFINE_FIELD( m_flNextControllerSearch, FIELD_TIME ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bShouldFindNPCs, FIELD_BOOLEAN, "ShouldFindNPCs" ), +#else DEFINE_FIELD( m_bShouldFindNPCs, FIELD_BOOLEAN ), +#endif DEFINE_FIELD( m_bNPCInRoute, FIELD_BOOLEAN ), DEFINE_KEYFIELD( m_iszNPCManPoint, FIELD_STRING, "npc_man_point" ), DEFINE_FIELD( m_bReadyToFire, FIELD_BOOLEAN ), @@ -140,6 +159,16 @@ BEGIN_DATADESC( CFuncTank ) DEFINE_KEYFIELD( m_iEffectHandling, FIELD_INTEGER, "effecthandling" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bDontHitController, FIELD_BOOLEAN, "DontHitController" ), + DEFINE_KEYFIELD( m_bControllerGlued, FIELD_BOOLEAN, "ControllerGlued" ), + + DEFINE_KEYFIELD( m_iszTraceFilter, FIELD_STRING, "TraceFilter" ), + DEFINE_FIELD( m_hTraceFilter, FIELD_EHANDLE ), + + DEFINE_KEYFIELD( m_flPlayerBBoxDist, FIELD_FLOAT, "PlayerBBoxDist" ), +#endif + // Inputs DEFINE_INPUTFUNC( FIELD_VOID, "Activate", InputActivate ), DEFINE_INPUTFUNC( FIELD_VOID, "Deactivate", InputDeactivate ), @@ -151,6 +180,10 @@ BEGIN_DATADESC( CFuncTank ) DEFINE_INPUTFUNC( FIELD_EHANDLE, "SetTargetEntity", InputSetTargetEntity ), DEFINE_INPUTFUNC( FIELD_VOID, "ClearTargetEntity", InputClearTargetEntity ), DEFINE_INPUTFUNC( FIELD_STRING, "FindNPCToManTank", InputFindNPCToManTank ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_STRING, "TeleportNPCToManTank", InputTeleportNPCToManTank ), + DEFINE_INPUTFUNC( FIELD_STRING, "ForceNPCToManTank", InputForceNPCToManTank ), +#endif DEFINE_INPUTFUNC( FIELD_VOID, "StopFindingNPCs", InputStopFindingNPCs ), DEFINE_INPUTFUNC( FIELD_VOID, "StartFindingNPCs", InputStartFindingNPCs ), DEFINE_INPUTFUNC( FIELD_VOID, "ForceNPCOff", InputForceNPCOff ), @@ -178,6 +211,10 @@ CFuncTank::CFuncTank() m_bNPCInRoute = false; m_flNextControllerSearch = 0; m_bShouldFindNPCs = true; + +#ifdef MAPBASE + m_flPlayerBBoxDist = 24; +#endif } //----------------------------------------------------------------------------- @@ -353,7 +390,11 @@ void CFuncTank::InputFindNPCToManTank( inputdata_t &inputdata ) return; // NPC assigned to man the func_tank? +#ifdef MAPBASE + CBaseEntity *pEntity = gEntList.FindEntityByNameNearest( inputdata.value.String(), GetAbsOrigin(), 0, this, inputdata.pActivator, inputdata.pCaller ); +#else CBaseEntity *pEntity = gEntList.FindEntityByName( NULL, inputdata.value.StringID() ); +#endif if ( pEntity ) { CAI_BaseNPC *pNPC = pEntity->MyNPCPointer(); @@ -375,6 +416,124 @@ void CFuncTank::InputFindNPCToManTank( inputdata_t &inputdata ) NPC_FindController(); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Input handler for telling the func_tank to teleport an NPC to man it. +//----------------------------------------------------------------------------- +void CFuncTank::InputTeleportNPCToManTank( inputdata_t &inputdata ) +{ + // Verify the func_tank is controllable and available. + if ( !IsNPCControllable() && !IsNPCSetController() ) + return; + + // If we have a controller already - don't look for one. + if ( HasController() ) + return; + + // NPC assigned to man the func_tank? + CBaseEntity *pEntity = gEntList.FindEntityByNameNearest( inputdata.value.String(), GetAbsOrigin(), 0, this, inputdata.pActivator, inputdata.pCaller ); + if ( pEntity ) + { + CAI_BaseNPC *pNPC = pEntity->MyNPCPointer(); + if ( pNPC ) + { + // Verify the npc has the func_tank controller behavior. + CAI_FuncTankBehavior *pBehavior; + if ( pNPC->GetBehavior( &pBehavior ) ) + { + Vector vecVec; + QAngle angAng; + Vector vecVel = vec3_origin; + if ( m_iszNPCManPoint != NULL_STRING ) + { + CBaseEntity *pEntity = gEntList.FindEntityByName( NULL, m_iszNPCManPoint, this ); + if ( pEntity ) + { + vecVec = pEntity->GetAbsOrigin(); + } + } + + angAng = pNPC->GetAbsAngles(); + angAng.y = UTIL_VecToYaw ( GetAbsOrigin() - vecVec ); // Yaw from man point to turret + + pNPC->Teleport(&vecVec, &angAng, &vecVel); + + m_hController = pNPC; + pBehavior->SetFuncTank( this ); + NPC_SetInRoute( true ); + +#if 1 + pNPC->GetMotor()->SetIdealYawToTarget( GetAbsOrigin() ); + pNPC->SetTurnActivity(); + + pNPC->DoHolster(); + + pNPC->SpeakSentence( FUNCTANK_SENTENCE_JUST_MOUNTED ); + + // We are at the correct position and facing for the func_tank, mount it. + StartControl( pNPC ); + pNPC->ClearEnemyMemory(); + pBehavior->SetMounted(true); + + pNPC->SetIdealActivity( ACT_IDLE_MANNEDGUN ); +#endif + + return; + } + } + } + else + { + Warning("%s unable to find NPC \"%s\" to teleport to tank\n", GetDebugName(), inputdata.value.String()); + } + + // NPC_FindController() doesn't return a NPC and teleporting a random NPC seems kind of dangerous anyway. +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for telling the func_tank to find a NPC and instantly make them man it, no matter what they're doing or where they are. +//----------------------------------------------------------------------------- +void CFuncTank::InputForceNPCToManTank( inputdata_t &inputdata ) +{ + // Verify the func_tank is controllable and available. + if ( !IsNPCControllable() && !IsNPCSetController() ) + return; + + // If we have a controller already - don't look for one. + if ( HasController() ) + return; + + // NPC assigned to man the func_tank? + CBaseEntity *pEntity = gEntList.FindEntityByNameNearest( inputdata.value.String(), GetAbsOrigin(), 0, this, inputdata.pActivator, inputdata.pCaller ); + if ( pEntity ) + { + CAI_BaseNPC *pNPC = pEntity->MyNPCPointer(); + if ( pNPC ) + { + // Verify the npc has the func_tank controller behavior. + CAI_FuncTankBehavior *pBehavior; + if ( pNPC->GetBehavior( &pBehavior ) ) + { + // Set the forced condition + pBehavior->SetCondition( CAI_FuncTankBehavior::COND_FUNCTANK_FORCED ); + + m_hController = pNPC; + pBehavior->SetFuncTank( this ); + NPC_SetInRoute( true ); + + return; + } + } + } + else + { + Warning("%s unable to find NPC \"%s\" to force to tank\n", GetDebugName(), inputdata.value.String()); + } + + // NPC_FindController() doesn't return a NPC and teleporting a random NPC seems kind of dangerous anyway. +} +#endif + //----------------------------------------------------------------------------- // Purpose: // Input : &inputdata - @@ -735,13 +894,16 @@ void CFuncTank::Spawn( void ) { Precache(); +#ifndef AMMOTYPE_MOVED #ifdef HL2_EPISODIC - m_iAmmoType = GetAmmoDef()->Index( STRING( m_iszAmmoType ) ); + m_iAmmoType = GetAmmoDef()->Index(STRING(m_iszAmmoType)); #else - m_iSmallAmmoType = GetAmmoDef()->Index("Pistol"); - m_iMediumAmmoType = GetAmmoDef()->Index("SMG1"); - m_iLargeAmmoType = GetAmmoDef()->Index("AR2"); -#endif // HL2_EPISODIC + m_iSmallAmmoType = GetAmmoDef()->Index("Pistol"); + m_iMediumAmmoType = GetAmmoDef()->Index("SMG1"); + m_iLargeAmmoType = GetAmmoDef()->Index("AR2"); +#endif // HL2_EPISODIC +#endif // AMMOTYPE_MOVED + SetMoveType( MOVETYPE_PUSH ); // so it doesn't get pushed by anything SetSolid( SOLID_VPHYSICS ); @@ -878,6 +1040,15 @@ void CFuncTank::Activate( void ) m_nBarrelAttachment = pAnim->LookupAttachment( STRING(m_iszBarrelAttachment) ); } } + +#ifdef MAPBASE + if ( m_iszTraceFilter != NULL_STRING ) + { + m_hTraceFilter = dynamic_cast(gEntList.FindEntityByName( NULL, STRING(m_iszTraceFilter) )); + if (!m_hTraceFilter) + Warning("WARNING: %s trace filter %s is not a filter!\n", GetDebugName(), STRING(m_iszTraceFilter)); + } +#endif } bool CFuncTank::CreateVPhysics() @@ -893,6 +1064,10 @@ void CFuncTank::Precache( void ) PrecacheModel( STRING(m_iszSpriteSmoke) ); if ( m_iszSpriteFlash != NULL_STRING ) PrecacheModel( STRING(m_iszSpriteFlash) ); +#ifdef MAPBASE + if ( m_iszShootSound != NULL_STRING ) + PrecacheScriptSound( STRING(m_iszShootSound) ); +#endif if ( m_soundStartRotate != NULL_STRING ) PrecacheScriptSound( STRING(m_soundStartRotate) ); @@ -1046,6 +1221,16 @@ bool CFuncTank::StartControl( CBaseCombatCharacter *pController ) SetNextThink( gpGlobals->curtime + 0.1f ); // Let the map maker know a controller has been found +#ifdef MAPBASE + if ( m_hController->IsPlayer() ) + { + m_OnGotPlayerController.FireOutput( m_hController, this ); + } + else + { + m_OnGotController.FireOutput( m_hController, this ); + } +#else if ( m_hController->IsPlayer() ) { m_OnGotPlayerController.FireOutput( this, this ); @@ -1054,6 +1239,7 @@ bool CFuncTank::StartControl( CBaseCombatCharacter *pController ) { m_OnGotController.FireOutput( this, this ); } +#endif OnStartControlled(); return true; @@ -1071,8 +1257,13 @@ void CFuncTank::StopControl() OnStopControlled(); +#ifdef MAPBASE + // Arm player/npc weapon if they're not in a vehicle. + if ( !m_hController->IsInAVehicle() && m_hController->GetActiveWeapon() ) +#else // Arm player/npc weapon. if ( m_hController->GetActiveWeapon() ) +#endif { m_hController->GetActiveWeapon()->Deploy(); } @@ -1087,6 +1278,16 @@ void CFuncTank::StopControl() SetNextThink( TICK_NEVER_THINK ); // Let the map maker know a controller has been lost. +#ifdef MAPBASE + if ( m_hController->IsPlayer() ) + { + m_OnLostPlayerController.FireOutput( m_hController, this ); + } + else + { + m_OnLostController.FireOutput( m_hController, this ); + } +#else if ( m_hController->IsPlayer() ) { m_OnLostPlayerController.FireOutput( this, this ); @@ -1095,6 +1296,7 @@ void CFuncTank::StopControl() { m_OnLostController.FireOutput( this, this ); } +#endif // Reset the func_tank as unmanned (player/npc). if ( m_hController->IsPlayer() ) @@ -1161,7 +1363,12 @@ void CFuncTank::ControllerPostFrame( void ) Vector start = WorldBarrelPosition(); Vector dir = forward; +#ifdef MAPBASE + CTraceFilterSimple traceFilter = GetTraceFilter(); + UTIL_TraceHull( start, start + forward * 8192, -Vector(8,8,8), Vector(8,8,8), MASK_SHOT, &traceFilter, &tr ); +#else UTIL_TraceHull( start, start + forward * 8192, -Vector(8,8,8), Vector(8,8,8), MASK_SHOT, this, COLLISION_GROUP_NONE, &tr ); +#endif if( tr.m_pEnt && tr.m_pEnt->m_takedamage != DAMAGE_NO && (tr.m_pEnt->GetFlags() & FL_AIMTARGET) ) { @@ -1189,6 +1396,9 @@ void CFuncTank::ControllerPostFrame( void ) if( --m_iAmmoCount == 0 ) { // Kick the player off the gun, and make myself not usable. +#ifdef MAPBASE + m_OnAmmoDepleted.FireOutput(pPlayer, this); +#endif m_spawnflags &= ~SF_TANK_CANCONTROL; StopControl(); return; @@ -1335,6 +1545,11 @@ void CFuncTank::NPC_Fire( void ) { SetNextAttack( gpGlobals->curtime + m_fireTime ); } + +#ifdef MAPBASE + // This is now needed in some cases + m_fireLast = gpGlobals->curtime; +#endif } @@ -1706,8 +1921,14 @@ void CFuncTank::CalcPlayerCrosshairTarget( Vector *pVecTarget ) vecDir = pPlayer->GetAutoaimVector( AUTOAIM_SCALE_DEFAULT ); } +#ifdef MAPBASE + CTraceFilterSimple traceFilter = GetTraceFilter(); + UTIL_TraceLine( vecStart + vecDir * m_flPlayerBBoxDist, vecStart + vecDir * 8192, MASK_BLOCKLOS_AND_NPCS, &traceFilter, &tr ); + //DebugDrawLine(tr.startpos, tr.endpos, 222, 222, 0, false, 0.1); +#else // Make sure to start the trace outside of the player's bbox! UTIL_TraceLine( vecStart + vecDir * 24, vecStart + vecDir * 8192, MASK_BLOCKLOS_AND_NPCS, this, COLLISION_GROUP_NONE, &tr ); +#endif *pVecTarget = tr.endpos; } @@ -1822,11 +2043,15 @@ bool CFuncTank::RotateTankToAngles( const QAngle &angles, float *pDistX, float * //----------------------------------------------------------------------------- // We lost our target! //----------------------------------------------------------------------------- -void CFuncTank::LostTarget( void ) +void CFuncTank::LostTarget( CBaseEntity *pTarget ) { if (m_fireLast != 0) { +#ifdef MAPBASE + m_OnLoseTarget.Set(pTarget, pTarget, this); +#else m_OnLoseTarget.FireOutput(this, this); +#endif m_fireLast = 0; } } @@ -1929,7 +2154,11 @@ void CFuncTank::AimFuncTankAtTarget( void ) m_hTarget = FindTarget( m_targetEntityName, NULL ); } +#ifdef MAPBASE + LostTarget(pEntity); +#else LostTarget(); +#endif return; } @@ -1953,8 +2182,13 @@ void CFuncTank::AimFuncTankAtTarget( void ) { if ( m_hTarget ) { +#ifdef MAPBASE + LostTarget(m_hTarget); + m_hTarget = NULL; +#else m_hTarget = NULL; LostTarget(); +#endif } return; } @@ -2053,18 +2287,30 @@ void CFuncTank::AimFuncTankAtTarget( void ) { if (m_fireLast == 0) { +#ifdef MAPBASE + m_OnAquireTarget.Set(pTarget, pTarget, this); +#else m_OnAquireTarget.FireOutput(this, this); +#endif } FiringSequence( barrelEnd, forward, this ); } else { +#ifdef MAPBASE + LostTarget(pTarget); +#else LostTarget(); +#endif } } else { +#ifdef MAPBASE + LostTarget(pTarget); +#else LostTarget(); +#endif } } @@ -2203,6 +2449,55 @@ const char *CFuncTank::GetTracerType( void ) //----------------------------------------------------------------------------- void CFuncTank::Fire( int bulletCount, const Vector &barrelEnd, const Vector &forward, CBaseEntity *pAttacker, bool bIgnoreSpread ) { +#ifdef MAPBASE + bool bSpriteSmoke = m_iszSpriteSmoke != NULL_STRING; + bool bSpriteFlash = m_iszSpriteFlash != NULL_STRING; + + if (bSpriteSmoke || bSpriteFlash) + { + if (bSpriteSmoke) + { + CSprite *pSmoke = CSprite::SpriteCreate( STRING(m_iszSpriteSmoke), barrelEnd, TRUE ); + pSmoke->AnimateAndDie( random->RandomFloat( 15.0, 20.0 ) ); + pSmoke->SetTransparency( kRenderTransAlpha, m_clrRender->r, m_clrRender->g, m_clrRender->b, 255, kRenderFxNone ); + + Vector vecVelocity( 0, 0, random->RandomFloat(40, 80) ); + pSmoke->SetAbsVelocity( vecVelocity ); + pSmoke->SetScale( m_spriteScale ); + } + + if (bSpriteFlash) + { + CSprite *pFlash = CSprite::SpriteCreate( STRING(m_iszSpriteFlash), barrelEnd, TRUE ); + pFlash->AnimateAndDie( 5 ); + pFlash->SetTransparency( kRenderTransAdd, 255, 255, 255, 255, kRenderFxNoDissipation ); + pFlash->SetScale( m_spriteScale ); + } + } + else if ( m_iEffectHandling == EH_AR2 ) + { + DoMuzzleFlash(); + } + else if ( m_iEffectHandling == EH_COMBINE_CANNON ) + { + DoMuzzleFlash(); + } + + if (m_iszShootSound != NULL_STRING) + { + EmitSound(STRING(m_iszShootSound)); + } + else if ( m_iEffectHandling == EH_AR2 ) + { + // Play the AR2 sound + EmitSound( "Weapon_functank.Single" ); + } + else if ( m_iEffectHandling == EH_COMBINE_CANNON ) + { + // Play the cannon sound + EmitSound( "NPC_Combine_Cannon.FireBullet" ); + } +#else // If we have a specific effect handler, apply it's effects if ( m_iEffectHandling == EH_AR2 ) { @@ -2238,6 +2533,7 @@ void CFuncTank::Fire( int bulletCount, const Vector &barrelEnd, const Vector &fo pSprite->SetScale( m_spriteScale ); } } +#endif if( pAttacker && pAttacker->IsPlayer() ) { @@ -2252,7 +2548,11 @@ void CFuncTank::Fire( int bulletCount, const Vector &barrelEnd, const Vector &fo } +#ifdef MAPBASE + m_OnFire.FireOutput(pAttacker, this); +#else m_OnFire.FireOutput(this, this); +#endif m_bReadyToFire = false; } @@ -2384,6 +2684,84 @@ bool CFuncTank::IsEntityInViewCone( CBaseEntity *pEntity ) return true; } +#ifdef MAPBASE +//========================================================= +// I decided to make a custom trace filter for func_tank trace filters. +// If the base class thinks the trace should hit the entity, it goes through +// a filter and if it passes the filter, the trace passes the entity instead. +// +// This is different from CTraceFilterEntityFilter because it's simplified and can use its own exclusion list. +// (it also came before it) +//========================================================= +class CTankTraceFilter : public CTraceFilterSimpleList +{ +public: + CTankTraceFilter( int collisionGroup ) : CTraceFilterSimpleList( collisionGroup ) {} + + bool ShouldHitEntity( IHandleEntity *pHandleEntity, int contentsMask ) + { + bool base = CTraceFilterSimpleList::ShouldHitEntity( pHandleEntity, contentsMask ); + + // Our base is telling us to hit. If it passes the filter, don't. + if ( base && m_pFilter ) + { + CBaseEntity *pEntity = EntityFromEntityHandle( pHandleEntity ); + return !m_pFilter->PassesFilter(m_pCaller, pEntity); + + // TODO: Should we use this code from CBulletsTraceFilter? + /* + CBaseEntity *pEntity = EntityFromEntityHandle( pHandleEntity ); + CBaseEntity *pPassEntity = EntityFromEntityHandle( m_PassEntities[0] ); + if ( pEntity && pPassEntity && pEntity->GetOwnerEntity() == pPassEntity && + pPassEntity->IsSolidFlagSet(FSOLID_NOT_SOLID) && pPassEntity->IsSolidFlagSet( FSOLID_CUSTOMBOXTEST ) && + pPassEntity->IsSolidFlagSet( FSOLID_CUSTOMRAYTEST ) ) + { + // It's a bone follower of the entity to ignore (toml 8/3/2007) + return false; + } + */ + } + + return base; + } + + CBaseFilter *m_pFilter; + CBaseEntity *m_pCaller; + +}; + +//----------------------------------------------------------------------------- +// Purpose: Gets our general trace filter we use for LOS, trace locations, etc. +// This was created so we could easily change the trace filter func_tank generally uses, +// but it can be overridden by derived classes, so there's that. +//----------------------------------------------------------------------------- +CTraceFilterSimple CFuncTank::GetTraceFilter() +{ + //CTraceFilterSkipTwoEntities traceFilter( this, GetParent(), COLLISION_GROUP_NONE ); + + CTankTraceFilter traceFilter( COLLISION_GROUP_NONE ); + traceFilter.SetPassEntity(this); + + if (GetParent()) + { + CBaseEntity *pParent = GetParent(); + traceFilter.AddEntityToIgnore(pParent); + + // Add the parent's parent too. (for func_tanks mounted on moving things, like vehicles) + if (pParent->GetParent()) + traceFilter.AddEntityToIgnore(pParent->GetParent()); + } + + if (m_bDontHitController) + traceFilter.AddEntityToIgnore(GetController()); + + traceFilter.m_pFilter = m_hTraceFilter.Get(); + traceFilter.m_pCaller = this; + + return traceFilter; +} +#endif + //----------------------------------------------------------------------------- // Purpose: Return true if this func tank can see the enemy //----------------------------------------------------------------------------- @@ -2398,7 +2776,11 @@ bool CFuncTank::HasLOSTo( CBaseEntity *pEntity ) trace_t tr; // Ignore the func_tank and any prop it's parented to +#ifdef MAPBASE + CTraceFilterSimple traceFilter = GetTraceFilter(); +#else CTraceFilterSkipTwoEntities traceFilter( this, GetParent(), COLLISION_GROUP_NONE ); +#endif // UNDONE: Should this hit BLOCKLOS brushes? AI_TraceLine( vecBarrelEnd, vecTarget, MASK_BLOCKLOS_AND_NPCS, &traceFilter, &tr ); @@ -2428,10 +2810,76 @@ class CFuncTankGun : public CFuncTank public: DECLARE_CLASS( CFuncTankGun, CFuncTank ); +#ifdef AMMOTYPE_MOVED + DECLARE_DATADESC(); + + string_t m_iszAmmoType; // The name of the ammodef that we use when we fire. Bullet damage still comes from keyvalues. + int m_iAmmoType; // The cached index of the ammodef that we use when we fire. +#endif // !AMMOTYPE_MOVED + +#ifdef AMMOTYPE_MOVED + void Spawn( void ); + bool KeyValue( const char *szKeyName, const char *szValue ); +#endif // AMMOTYPE_MOVED + + void Fire( int bulletCount, const Vector &barrelEnd, const Vector &forward, CBaseEntity *pAttacker, bool bIgnoreSpread ); }; + +#ifdef AMMOTYPE_MOVED +BEGIN_DATADESC(CFuncTankGun) + + DEFINE_KEYFIELD( m_iszAmmoType, FIELD_STRING, "ammotype" ), + DEFINE_FIELD( m_iAmmoType, FIELD_INTEGER ), + +END_DATADESC() +#endif // AMMOTYPE_MOVED + LINK_ENTITY_TO_CLASS( func_tank, CFuncTankGun ); +#ifdef AMMOTYPE_MOVED +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CFuncTankGun::Spawn( void ) +{ + if (m_iszAmmoType != NULL_STRING) + m_iAmmoType = GetAmmoDef()->Index(STRING(m_iszAmmoType)); + + BaseClass::Spawn(); +} + +//----------------------------------------------------------------------------- +// Purpose: Caches entity key values until spawn is called. +// Input : szKeyName - +// szValue - +// Output : +//----------------------------------------------------------------------------- +bool CFuncTankGun::KeyValue( const char *szKeyName, const char *szValue ) +{ + if (FStrEq(szKeyName, "bullet")) + { + switch (atoi(szValue)) + { + case TANK_BULLET_SMALL: + m_iAmmoType = GetAmmoDef()->Index("Pistol"); + break; + case TANK_BULLET_MEDIUM: + m_iAmmoType = GetAmmoDef()->Index("SMG1"); + break; + case TANK_BULLET_LARGE: + m_iAmmoType = GetAmmoDef()->Index("AR2"); + break; + default: + m_iAmmoType = -1; + } + return true; + } + + return BaseClass::KeyValue( szKeyName, szValue ); +} +#endif // AMMOTYPE_MOVED + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -2459,7 +2907,27 @@ void CFuncTankGun::Fire( int bulletCount, const Vector &barrelEnd, const Vector info.m_pAttacker = pAttacker; info.m_pAdditionalIgnoreEnt = GetParent(); -#ifdef HL2_EPISODIC +#ifdef MAPBASE + CUtlVector ignorelist; + + if (pAttacker) + { + if (m_bDontHitController) + { + ignorelist.AddToTail(pAttacker); + } + + // Ignore any vehicle our controller is in + if (pAttacker->MyCombatCharacterPointer() && pAttacker->MyCombatCharacterPointer()->IsInAVehicle()) + { + ignorelist.AddToTail(pAttacker->MyCombatCharacterPointer()->GetVehicleEntity()); + } + } + + info.m_pIgnoreEntList = &ignorelist; +#endif + +#if defined(HL2_EPISODIC) || defined(AMMOTYPE_MOVED) if ( m_iAmmoType != -1 ) { for ( i = 0; i < bulletCount; i++ ) @@ -2515,7 +2983,11 @@ public: color32 m_flPulseColor; float m_flPulseLife; float m_flPulseLag; +#ifdef MAPBASE + #define m_sPulseFireSound m_iszShootSound +#else string_t m_sPulseFireSound; +#endif }; LINK_ENTITY_TO_CLASS( func_tankpulselaser, CFuncTankPulseLaser ); @@ -2695,6 +3167,82 @@ void CFuncTankLaser::Fire( int bulletCount, const Vector &barrelEnd, const Vecto } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Missile for func_tankrocket so kills are credited properly and don't kill friendlies +//----------------------------------------------------------------------------- +class CFuncTankMissile : public CMissile +{ + DECLARE_CLASS( CFuncTankMissile, CMissile ); + DECLARE_DATADESC(); + +public: + virtual void Spawn( void ); + + EHANDLE m_hTurret; + +private: + void FTnkMissileTouch( CBaseEntity *pOther ); +}; + +BEGIN_DATADESC( CFuncTankMissile ) + + DEFINE_FIELD( m_hTurret, FIELD_EHANDLE ), + + // Function Pointers + DEFINE_FUNCTION( FTnkMissileTouch ), + +END_DATADESC() + +LINK_ENTITY_TO_CLASS( func_tankrocket_missile, CFuncTankMissile ); + +void CFuncTankMissile::Spawn( void ) +{ + Precache(); + + SetSolid( SOLID_BBOX ); + SetModel("models/weapons/w_missile_launch.mdl"); + UTIL_SetSize( this, -Vector(4,4,4), Vector(4,4,4) ); + + SetTouch( &CFuncTankMissile::FTnkMissileTouch ); + + SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE ); + SetThink( &CMissile::IgniteThink ); + + SetNextThink( gpGlobals->curtime + 0.3f ); + + m_takedamage = DAMAGE_YES; + m_iHealth = m_iMaxHealth = 100; + m_bloodColor = DONT_BLEED; + + AddFlag( FL_OBJECT ); +} + +//----------------------------------------------------------------------------- +// The actual explosion +//----------------------------------------------------------------------------- +void CFuncTankMissile::FTnkMissileTouch( CBaseEntity *pOther ) +{ + Assert( pOther ); + + // Don't touch triggers (but DO hit weapons) + if ( pOther->IsSolidFlagSet(FSOLID_TRIGGER|FSOLID_VOLUME_CONTENTS) && pOther->GetCollisionGroup() != COLLISION_GROUP_WEAPON ) + { + // Some NPCs are triggers that can take damage (like antlion grubs). We should hit them. + if ( ( pOther->m_takedamage == DAMAGE_NO ) || ( pOther->m_takedamage == DAMAGE_EVENTS_ONLY ) ) + return; + } + + // Do not touch the turret we fired from + if (pOther == m_hTurret.Get()) + { + return; + } + + Explode(); +} +#endif + class CFuncTankRocket : public CFuncTank { public: @@ -2720,13 +3268,23 @@ LINK_ENTITY_TO_CLASS( func_tankrocket, CFuncTankRocket ); void CFuncTankRocket::Precache( void ) { +#ifdef MAPBASE + UTIL_PrecacheOther( "func_tankrocket_missile" ); +#else UTIL_PrecacheOther( "rpg_missile" ); +#endif CFuncTank::Precache(); } void CFuncTankRocket::Fire( int bulletCount, const Vector &barrelEnd, const Vector &forward, CBaseEntity *pAttacker, bool bIgnoreSpread ) { +#ifdef MAPBASE + CFuncTankMissile *pRocket = (CFuncTankMissile*)CBaseEntity::Create( "func_tankrocket_missile", barrelEnd, GetAbsAngles(), GetController() ); + pRocket->AddEffects( EF_NOSHADOW ); + pRocket->m_hTurret.Set(this); +#else CMissile *pRocket = (CMissile *) CBaseEntity::Create( "rpg_missile", barrelEnd, GetAbsAngles(), this ); +#endif pRocket->DumbFire(); pRocket->SetNextThink( gpGlobals->curtime + 0.1f ); @@ -2743,6 +3301,9 @@ void CFuncTankRocket::Fire( int bulletCount, const Vector &barrelEnd, const Vect CFuncTank::Fire( bulletCount, barrelEnd, forward, this, bIgnoreSpread ); } +#ifdef MAPBASE +static const char *s_pAirboatGunThinkContext = "AirboatGunThinkContext"; +#endif //----------------------------------------------------------------------------- // Airboat gun @@ -2753,15 +3314,32 @@ public: DECLARE_CLASS( CFuncTankAirboatGun, CFuncTank ); DECLARE_DATADESC(); +#ifdef MAPBASE + CFuncTankAirboatGun() + { + // -1 = original behavior + m_spread = -1; + } +#endif + void Precache( void ); virtual void Spawn(); virtual void Activate(); virtual void Fire( int bulletCount, const Vector &barrelEnd, const Vector &forward, CBaseEntity *pAttacker, bool bIgnoreSpread ); virtual void ControllerPostFrame(); +#ifdef MAPBASE + virtual void FuncTankAirboatGunThink(); + virtual void TankActivate(void); + virtual void TankDeactivate(void); + virtual void OnStartControlled(); +#endif virtual void OnStopControlled(); virtual const char *GetTracerType( void ); virtual Vector WorldBarrelPosition( void ); virtual void DoImpactEffect( trace_t &tr, int nDamageType ); +#ifdef MAPBASE + virtual void StopLoopingSounds() { DestroySounds(); BaseClass::StopLoopingSounds(); } +#endif private: void CreateSounds(); @@ -2778,6 +3356,11 @@ private: CHandle m_hAirboatGunModel; int m_nGunBarrelAttachment; float m_flLastImpactEffectTime; + +#ifdef MAPBASE + float m_flHeavyShotInterval = 0.2f; + int m_iHeavyShotSpread; +#endif }; @@ -2793,6 +3376,14 @@ BEGIN_DATADESC( CFuncTankAirboatGun ) // DEFINE_FIELD( m_hAirboatGunModel, FIELD_EHANDLE ), // DEFINE_FIELD( m_nGunBarrelAttachment, FIELD_INTEGER ), DEFINE_FIELD( m_flLastImpactEffectTime, FIELD_TIME ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_flHeavyShotInterval, FIELD_FLOAT, "heavy_shot_interval" ), + DEFINE_KEYFIELD( m_iHeavyShotSpread, FIELD_INTEGER, "heavy_shot_spread" ), +#endif + +#ifdef MAPBASE + DEFINE_THINKFUNC( FuncTankAirboatGunThink ), +#endif END_DATADESC() @@ -2805,7 +3396,16 @@ LINK_ENTITY_TO_CLASS( func_tankairboatgun, CFuncTankAirboatGun ); void CFuncTankAirboatGun::Precache( void ) { BaseClass::Precache(); +#ifdef MAPBASE + // Odd placement, but it works + if (m_iszShootSound == NULL_STRING) + { + m_iszShootSound = AllocPooledString("Airboat.FireGunLoop"); + PrecacheScriptSound(STRING(m_iszShootSound)); + } +#else PrecacheScriptSound( "Airboat.FireGunLoop" ); +#endif PrecacheScriptSound( "Airboat.FireGunRevDown"); CreateSounds(); } @@ -2820,6 +3420,10 @@ void CFuncTankAirboatGun::Spawn( void ) m_flNextHeavyShotTime = 0.0f; m_bIsFiring = false; m_flLastImpactEffectTime = -1; + +#ifdef MAPBASE + SetContextThink( &CFuncTankAirboatGun::FuncTankAirboatGunThink, gpGlobals->curtime, s_pAirboatGunThinkContext ); +#endif } @@ -2838,6 +3442,13 @@ void CFuncTankAirboatGun::Activate() m_nGunBarrelAttachment = m_hAirboatGunModel->LookupAttachment( "muzzle" ); } } +#ifdef MAPBASE + else if (GetParent() && GetParent()->GetBaseAnimating()) + { + m_hAirboatGunModel = GetParent()->GetBaseAnimating(); + m_nGunBarrelAttachment = GetGunBarrelAttachment(); + } +#endif } @@ -2851,7 +3462,11 @@ void CFuncTankAirboatGun::CreateSounds() CPASAttenuationFilter filter( this ); if (!m_pGunFiringSound) { +#ifdef MAPBASE + m_pGunFiringSound = controller.SoundCreate( filter, entindex(), STRING(m_iszShootSound) ); +#else m_pGunFiringSound = controller.SoundCreate( filter, entindex(), "Airboat.FireGunLoop" ); +#endif controller.Play( m_pGunFiringSound, 0, 100 ); } } @@ -2914,11 +3529,73 @@ void CFuncTankAirboatGun::ControllerPostFrame( void ) } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Maintains airboat gun sounds on NPCs +//----------------------------------------------------------------------------- +void CFuncTankAirboatGun::FuncTankAirboatGunThink( void ) +{ + if (!GetController()) + { + if (m_fireLast != 0) + { + StartFiring(); + } + else + { + StopFiring(); + } + } + else if (GetController()->IsNPC()) + { + // Attempt to estimate when we wouldn't be firing + if ((gpGlobals->curtime - m_fireLast - (1.0 / m_fireRate)) < 0.1f) + { + StartFiring(); + } + else + { + StopFiring(); + } + } + + SetNextThink( gpGlobals->curtime + 0.05f, s_pAirboatGunThinkContext ); +} + + +void CFuncTankAirboatGun::TankActivate(void) +{ + SetNextThink( gpGlobals->curtime + 0.05f, s_pAirboatGunThinkContext ); + BaseClass::TankActivate(); +} + +void CFuncTankAirboatGun::TankDeactivate(void) +{ + DevMsg("Tank deactivate\n"); + SetNextThink( TICK_NEVER_THINK, s_pAirboatGunThinkContext ); + StopFiring(); + BaseClass::TankDeactivate(); +} + +void CFuncTankAirboatGun::OnStartControlled() +{ + if (GetController() && GetController()->IsNPC()) + SetNextThink( gpGlobals->curtime + 0.05f, s_pAirboatGunThinkContext ); + + BaseClass::OnStartControlled(); +} +#endif + + //----------------------------------------------------------------------------- // Stop controlled //----------------------------------------------------------------------------- void CFuncTankAirboatGun::OnStopControlled() { +#ifdef MAPBASE + DevMsg("Tank stop control\n"); + SetNextThink( TICK_NEVER_THINK, s_pAirboatGunThinkContext ); +#endif StopFiring(); BaseClass::OnStopControlled(); } @@ -3002,13 +3679,21 @@ void CFuncTankAirboatGun::Fire( int bulletCount, const Vector &barrelEnd, const if ( gpGlobals->curtime >= m_flNextHeavyShotTime ) { info.m_iShots = 1; +#ifdef MAPBASE + info.m_vecSpread = gTankSpread[m_iHeavyShotSpread]; +#else info.m_vecSpread = VECTOR_CONE_PRECALCULATED; +#endif info.m_flDamageForceScale = 1000.0f; } else { info.m_iShots = 2; +#ifdef MAPBASE + info.m_vecSpread = m_spread != -1 ? gTankSpread[m_spread] : VECTOR_CONE_5DEGREES; +#else info.m_vecSpread = VECTOR_CONE_5DEGREES; +#endif } FireBullets( info ); @@ -3016,10 +3701,39 @@ void CFuncTankAirboatGun::Fire( int bulletCount, const Vector &barrelEnd, const DoMuzzleFlash(); // NOTE: This must occur after FireBullets +#ifdef MAPBASE + if ( gpGlobals->curtime >= m_flNextHeavyShotTime && m_flHeavyShotInterval != -1 ) +#else if ( gpGlobals->curtime >= m_flNextHeavyShotTime ) +#endif { +#ifdef MAPBASE + m_flNextHeavyShotTime = gpGlobals->curtime + m_flHeavyShotInterval; +#else m_flNextHeavyShotTime = gpGlobals->curtime + AIRBOAT_GUN_HEAVY_SHOT_INTERVAL; +#endif } + +#ifdef MAPBASE + // Things from CFuncTank::Fire(). + // We can't use everything because it overrides a few things. + if( pAttacker && pAttacker->IsPlayer() ) + { + if ( IsX360() ) + { + // Now, if you're playing Mapbase on the Xbox 360, the airboat gun turret will make your controller rumble! + // Isn't that lovely? Hmm? + UTIL_PlayerByIndex(1)->RumbleEffect( RUMBLE_AR2, 0, RUMBLE_FLAG_RESTART | RUMBLE_FLAG_RANDOM_AMPLITUDE ); + } + else + { + CSoundEnt::InsertSound( SOUND_MOVE_AWAY, barrelEnd + forward * 32.0f, 32.0f, 0.2f, pAttacker, SOUNDENT_CHANNEL_WEAPON ); + } + } + + m_OnFire.FireOutput(pAttacker, this); + m_bReadyToFire = false; +#endif } @@ -3216,7 +3930,11 @@ class CMortarShell : public CBaseEntity public: DECLARE_CLASS( CMortarShell, CBaseEntity ); +#ifdef MAPBASE + static CMortarShell *Create( const Vector &vecStart, const trace_t &tr, const Vector &vecShotDir, float flImpactDelay, float flWarnDelay, string_t warnSound ); +#else static CMortarShell *Create( const Vector &vecStart, const Vector &vecTarget, const Vector &vecShotDir, float flImpactDelay, float flWarnDelay, string_t warnSound ); +#endif void Spawn( void ); void Precache( void ); @@ -3226,6 +3944,15 @@ public: void FadeThink( void ); int UpdateTransmitState( void ); +#ifdef MAPBASE + void SetRadius(float fl) { m_flRadius = fl; } + void SetMagnitude(int i) { m_Magnitude = i; } + +public: + + bool m_bDontHitController; +#endif + private: void FixUpImpactPoint( const Vector &initialPos, const Vector &initialNormal, Vector *endPos, Vector *endNormal ); @@ -3240,6 +3967,9 @@ private: Vector m_vecFiredFrom; Vector m_vecFlyDir; float m_flSpawnedTime; +#ifdef MAPBASE + int m_Magnitude; +#endif CHandle m_pBeamEffect[4]; @@ -3268,6 +3998,10 @@ BEGIN_DATADESC( CMortarShell ) DEFINE_AUTO_ARRAY( m_pBeamEffect, FIELD_EHANDLE), DEFINE_FIELD( m_flRadius, FIELD_FLOAT ), DEFINE_FIELD( m_vecSurfaceNormal, FIELD_VECTOR ), +#ifdef MAPBASE + DEFINE_FIELD( m_bDontHitController, FIELD_BOOLEAN ), + DEFINE_FIELD( m_Magnitude, FIELD_INTEGER ), +#endif DEFINE_FUNCTION( FlyThink ), DEFINE_FUNCTION( FadeThink ), @@ -3327,13 +4061,19 @@ void CMortarShell::FixUpImpactPoint( const Vector &initialPos, const Vector &ini #define MORTAR_BLAST_DAMAGE 50 #define MORTAR_BLAST_HEIGHT 7500 +#ifdef MAPBASE +CMortarShell *CMortarShell::Create( const Vector &vecStart, const trace_t &tr, const Vector &vecShotDir, float flImpactDelay, float flWarnDelay, string_t warnSound ) +#else CMortarShell *CMortarShell::Create( const Vector &vecStart, const Vector &vecTarget, const Vector &vecShotDir, float flImpactDelay, float flWarnDelay, string_t warnSound ) +#endif { CMortarShell *pShell = (CMortarShell *)CreateEntityByName("mortarshell" ); +#ifndef MAPBASE // Place the mortar shell at the target location so that it can make the sound and explode. trace_t tr; UTIL_TraceLine( vecTarget, vecTarget + ( vecShotDir * 128.0f ), MASK_SOLID_BRUSHONLY, pShell, COLLISION_GROUP_NONE, &tr ); +#endif Vector targetPos, targetNormal; pShell->FixUpImpactPoint( tr.endpos, tr.plane.normal, &targetPos, &targetNormal ); @@ -3619,7 +4359,11 @@ void CMortarShell::Impact( void ) // Fire the bullets Vector vecSrc, vecShootDir; +#ifdef MAPBASE + float flRadius = m_flRadius; +#else float flRadius = MORTAR_BLAST_RADIUS; +#endif trace_t tr; UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() - Vector( 0, 0, 128 ), MASK_SOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &tr ); @@ -3680,7 +4424,11 @@ void CMortarShell::Impact( void ) FBEAM_FADEOUT ); +#ifdef MAPBASE + RadiusDamage( CTakeDamageInfo( this, GetOwnerEntity(), m_Magnitude / 2, (DMG_BLAST|DMG_DISSOLVE) ), GetAbsOrigin(), flRadius, CLASS_NONE, m_bDontHitController ? GetOwnerEntity() : NULL ); +#else RadiusDamage( CTakeDamageInfo( this, GetOwnerEntity(), MORTAR_BLAST_DAMAGE, (DMG_BLAST|DMG_DISSOLVE) ), GetAbsOrigin(), MORTAR_BLAST_RADIUS, CLASS_NONE, NULL ); +#endif EmitSound( "Weapon_Mortar.Impact" ); @@ -3772,7 +4520,11 @@ public: int m_Magnitude; float m_fireDelay; +#ifdef MAPBASE + #define m_fireStartSound m_iszShootSound +#else string_t m_fireStartSound; +#endif //string_t m_fireEndSound; string_t m_incomingSound; @@ -3781,6 +4533,11 @@ public: bool m_fLastShotMissed; +#ifdef MAPBASE + float m_flRadius; + int m_iMortarTraceMask = MASK_SOLID_BRUSHONLY; +#endif + // store future firing event CBaseEntity *m_pAttacker; }; @@ -3799,6 +4556,11 @@ BEGIN_DATADESC( CFuncTankMortar ) DEFINE_FIELD( m_fLastShotMissed, FIELD_BOOLEAN ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_flRadius, FIELD_FLOAT, "radius" ), + DEFINE_KEYFIELD( m_iMortarTraceMask, FIELD_INTEGER, "trace_mask" ), +#endif + DEFINE_FIELD( m_pAttacker, FIELD_CLASSPTR ), // Inputs @@ -3933,13 +4695,21 @@ void CFuncTankMortar::Fire( int bulletCount, const Vector &barrelEnd, const Vect vecSpot.z = GetAbsOrigin().z; // Trace up to find the fake 'apex' of the shell. The skybox or 1024 units, whichever comes first. +#ifdef MAPBASE + UTIL_TraceLine( vecSpot, vecSpot + Vector(0, 0, 1024), m_iMortarTraceMask, NULL, COLLISION_GROUP_NONE, &tr ); +#else UTIL_TraceLine( vecSpot, vecSpot + Vector(0, 0, 1024), MASK_SOLID_BRUSHONLY, NULL, COLLISION_GROUP_NONE, &tr ); +#endif vecSpot = tr.endpos; //NDebugOverlay::Line( tr.startpos, tr.endpos, 0,255,0, false, 5 ); // Now trace from apex to target +#ifdef MAPBASE + UTIL_TraceLine( vecSpot, vecProjectedPosition, m_iMortarTraceMask, NULL, COLLISION_GROUP_NONE, &tr ); +#else UTIL_TraceLine( vecSpot, vecProjectedPosition, MASK_SOLID_BRUSHONLY, NULL, COLLISION_GROUP_NONE, &tr ); +#endif if( mortar_visualize.GetBool() ) { @@ -3962,7 +4732,16 @@ void CFuncTankMortar::Fire( int bulletCount, const Vector &barrelEnd, const Vect Vector vecFinalDir = tr.endpos - tr.startpos; VectorNormalize( vecFinalDir ); +#ifdef MAPBASE + CMortarShell *pShell = CMortarShell::Create( barrelEnd, tr, vecFinalDir, m_fireDelay, m_flWarningTime, m_incomingSound ); + pShell->SetOwnerEntity(GetController()); + pShell->m_bDontHitController = m_bDontHitController; + if (m_flRadius != 0) + pShell->SetRadius(m_flRadius); + pShell->SetMagnitude(m_Magnitude); +#else CMortarShell::Create( barrelEnd, tr.endpos, vecFinalDir, m_fireDelay, m_flWarningTime, m_incomingSound ); +#endif BaseClass::Fire( bulletCount, barrelEnd, vecForward, this, bIgnoreSpread ); } @@ -4063,6 +4842,9 @@ private: Vector m_vecTrueForward; bool m_bShouldHarrass; bool m_bLastTargetWasNPC; // Tells whether the last entity we fired a shot at was an NPC (otherwise it was the player) +#ifdef MAPBASE + bool m_bControllableVersion = false; // Allows new behavior that makes player/NPC control easier. Doesn't use spawnflag for legacy purposes, as if anyone used this as a regular tank before. +#endif }; BEGIN_DATADESC( CFuncTankCombineCannon ) @@ -4074,6 +4856,9 @@ BEGIN_DATADESC( CFuncTankCombineCannon ) DEFINE_FIELD( m_vecTrueForward, FIELD_VECTOR ), DEFINE_FIELD( m_bShouldHarrass, FIELD_BOOLEAN ), DEFINE_FIELD( m_bLastTargetWasNPC, FIELD_BOOLEAN ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bControllableVersion, FIELD_BOOLEAN, "ControllableVersion" ), +#endif DEFINE_INPUTFUNC( FIELD_VOID, "EnableHarrass", InputEnableHarrass ), DEFINE_INPUTFUNC( FIELD_VOID, "DisableHarrass", InputDisableHarrass ), @@ -4100,7 +4885,12 @@ void CFuncTankCombineCannon::Spawn() { BaseClass::Spawn(); m_flTimeBeamOn = gpGlobals->curtime; +#ifdef MAPBASE + if (!m_bControllableVersion) + CreateBeam(); +#else CreateBeam(); +#endif m_bShouldHarrass = true; @@ -4154,8 +4944,14 @@ void CFuncTankCombineCannon::DestroyBeam() //--------------------------------------------------------- void CFuncTankCombineCannon::AdjustRateOfFire() { +#ifdef MAPBASE + // Only maintain 1.5 rounds per second if we're using legacy behavior. + if (!m_bControllableVersion) + m_fireRate = 1.5; +#else // Maintain 1.5 rounds per second rate of fire. m_fireRate = 1.5; +#endif /* if( m_hTarget.Get() != NULL && m_hTarget->IsPlayer() ) { @@ -4208,6 +5004,12 @@ void CFuncTankCombineCannon::FuncTankPostThink() { AdjustRateOfFire(); +#ifdef MAPBASE + // Controllables don't sweep + if (m_bControllableVersion) + return; +#endif + if( m_hTarget.Get() == NULL ) { if( gpGlobals->curtime > m_flTimeNextSweep ) @@ -4263,7 +5065,11 @@ void CFuncTankCombineCannon::FuncTankPostThink() // Ignore the func_tank and any prop it's parented to, and check line of sight to the point // Trace to the point. If an opaque trace doesn't reach the point, that means the beam hit // something closer, (including a blockLOS), so try again. +#ifdef MAPBASE + CTraceFilterSimple traceFilter = GetTraceFilter(); +#else CTraceFilterSkipTwoEntities traceFilter( this, GetParent(), COLLISION_GROUP_NONE ); +#endif AI_TraceLine( vecBarrelEnd, vecTest, MASK_BLOCKLOS_AND_NPCS, &traceFilter, &trLOS ); AI_TraceLine( vecBarrelEnd, vecTest, MASK_SHOT, &traceFilter, &trShoot ); @@ -4320,13 +5126,23 @@ void CFuncTankCombineCannon::FuncTankPostThink() //--------------------------------------------------------- void CFuncTankCombineCannon::Fire( int bulletCount, const Vector &barrelEnd, const Vector &forward, CBaseEntity *pAttacker, bool bIgnoreSpread ) { +#ifdef MAPBASE + // If we're in aim-at-pos mode and not in the new controllable version, don't fire in this mode + if ( HasSpawnFlags(SF_TANK_AIM_AT_POS) && !m_bControllableVersion ) + return; +#else // Specifically do NOT fire in aim at pos mode. This is just for show. if( HasSpawnFlags(SF_TANK_AIM_AT_POS) ) return; +#endif Vector vecAdjustedForward = forward; +#ifdef MAPBASE + if ( !IsPlayerManned() && m_hTarget != NULL ) +#else if( m_hTarget != NULL ) +#endif { Vector vecToTarget = m_hTarget->BodyTarget( barrelEnd, false ) - barrelEnd; VectorNormalize( vecToTarget ); @@ -4429,3 +5245,93 @@ void CFuncTankCombineCannon::InputDisableHarrass( inputdata_t &inputdata ) LINK_ENTITY_TO_CLASS( func_tank_combine_cannon, CFuncTankCombineCannon ); + +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Func tank that fires a bunch of outputs instead +//----------------------------------------------------------------------------- +class CFuncTankLogic : public CFuncTank +{ +public: + DECLARE_CLASS(CFuncTankLogic, CFuncTank); + DECLARE_DATADESC(); + + CFuncTankLogic(); + + void Fire(int bulletCount, const Vector &barrelEnd, const Vector &forward, CBaseEntity *pAttacker, bool bIgnoreSpread); + +protected: + + bool m_bShootsThroughWater; + + COutputVector m_OnFire_BarrelPos; + COutputVector m_OnFire_BarrelAng; + COutputVector m_OnFire_ShootPos; + COutputEHANDLE m_OnFire_FirstEnt; +}; + +LINK_ENTITY_TO_CLASS(func_tanklogic, CFuncTankLogic); + +BEGIN_DATADESC(CFuncTankLogic) + + //DEFINE_KEYFIELD( m_bDontHitController, FIELD_BOOLEAN, "DontHitController" ), + + DEFINE_OUTPUT( m_OnFire_BarrelPos, "OnFire_BarrelPos" ), + DEFINE_OUTPUT( m_OnFire_BarrelAng, "OnFire_BarrelAng" ), + DEFINE_OUTPUT( m_OnFire_ShootPos, "OnFire_ShootPos" ), + DEFINE_OUTPUT( m_OnFire_FirstEnt, "OnFire_FirstEnt" ), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CFuncTankLogic::CFuncTankLogic() +{ + // This is overriden by KV later + m_bDontHitController = true; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CFuncTankLogic::Fire(int bulletCount, const Vector &barrelEnd, const Vector &forward, CBaseEntity *pAttacker, bool bIgnoreSpread) +{ + // A bunch of stuff from FireBullets() to replicate firing a regular func_tank. + // It mostly just has the trace stuff. + Vector vecDir; + Vector vecEnd; + + trace_t tr; + CTraceFilterSimple traceFilter = GetTraceFilter(); + + CShotManipulator Manipulator( forward ); + vecDir = Manipulator.ApplySpread( bIgnoreSpread ? gTankSpread[0] : gTankSpread[m_spread] ); + + vecEnd = barrelEnd + vecDir * MAX_TRACE_LENGTH; + + int mask = MASK_SHOT; + + if (!m_bShootsThroughWater) + mask |= CONTENTS_WATER; + + AI_TraceLine(barrelEnd, vecEnd, mask, &traceFilter, &tr); + + if ( tr.startsolid ) + { + tr.endpos = tr.startpos; + tr.fraction = 0.0f; + } + + if ( ai_debug_shoot_positions.GetBool() ) + NDebugOverlay::Line(barrelEnd, tr.endpos, 255, 255, 255, false, .1 ); + + BaseClass::Fire(bulletCount, barrelEnd, forward, pAttacker, bIgnoreSpread); + + m_OnFire_BarrelPos.Set(barrelEnd, pAttacker, this); + m_OnFire_BarrelAng.Set(forward, pAttacker, this); + m_OnFire_ShootPos.Set(tr.endpos, pAttacker, this); + m_OnFire_FirstEnt.Set(tr.m_pEnt, tr.m_pEnt, this); +} +#endif // MAPBASE + diff --git a/sp/src/game/server/hl2/func_tank.h b/sp/src/game/server/hl2/func_tank.h index 46b444d5..0ecacce5 100644 --- a/sp/src/game/server/hl2/func_tank.h +++ b/sp/src/game/server/hl2/func_tank.h @@ -55,6 +55,20 @@ enum TANKBULLET #define MORTAR_BLAST_RADIUS 350 +#ifdef MAPBASE +// This moves variables related to ammo types from CFuncTank to CFuncTankGun, as CFuncTankGun and its derivatives are the only classes that use it. +// It also completely replaces the legacy "bullet" keyvalue with the AmmoType keyvalue, making bullet translate to the ammo type variable directly. +// This fixes the issue where some func_tanks don't fire any bullets. +// +// This code was created in September-October 2018 and moving existing variables like this seems risky and somewhat pointless, but the nature of func_tanks +// make this unlikely to cause any problems and helps my OCD. +// +// Disable this preprocessor if it causes problems. +#define AMMOTYPE_MOVED 1 + +class CTraceFilterSimple; +#endif + // Custom damage // env_laser (duration is 0.5 rate of fire) @@ -134,6 +148,13 @@ public: virtual void DoMuzzleFlash( void ); virtual const char *GetTracerType( void ); +#ifdef MAPBASE + virtual CTraceFilterSimple GetTraceFilter(); + + // Needed because func_tankairboatgun needs the barrel + int GetGunBarrelAttachment() { return m_nBarrelAttachment; } +#endif + protected: virtual float GetShotSpeed() { return 0; } @@ -179,6 +200,10 @@ protected: private: void InputFindNPCToManTank( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputTeleportNPCToManTank( inputdata_t &inputdata ); + void InputForceNPCToManTank( inputdata_t &inputdata ); +#endif void InputStopFindingNPCs( inputdata_t &inputdata ); void InputStartFindingNPCs( inputdata_t &inputdata ); void InputForceNPCOff( inputdata_t &inputdata ); @@ -217,7 +242,11 @@ private: bool RotateTankToAngles( const QAngle &angles, float *pDistX = NULL, float *pDistY = NULL ); // We lost our target! +#ifdef MAPBASE + void LostTarget( CBaseEntity *pTarget ); +#else void LostTarget( void ); +#endif // Purpose: void ComputeLeadingPosition( const Vector &vecShootPosition, CBaseEntity *pTarget, Vector *pLeadPosition ); @@ -237,6 +266,7 @@ protected: int m_iBulletDamage; // 0 means use Bullet type's default damage int m_iBulletDamageVsPlayer; // Damage vs player. 0 means use m_iBulletDamage +#ifndef AMMOTYPE_MOVED #ifdef HL2_EPISODIC string_t m_iszAmmoType; // The name of the ammodef that we use when we fire. Bullet damage still comes from keyvalues. int m_iAmmoType; // The cached index of the ammodef that we use when we fire. @@ -244,7 +274,9 @@ protected: int m_iSmallAmmoType; int m_iMediumAmmoType; int m_iLargeAmmoType; -#endif // HL2_EPISODIC +#endif // HL2_EPISODIC +#endif // !AMMOTYPE_MOVED + int m_spread; // firing spread @@ -255,6 +287,15 @@ protected: int m_nBulletCount; +#ifdef MAPBASE + bool m_bDontHitController; + string_t m_iszTraceFilter; + CHandle m_hTraceFilter; + + // Created to nullify aiming problems when the func_tank is on a vehicle or the player is too close to the barrel + float m_flPlayerBBoxDist; +#endif + private: // This is either the player manning the func_tank, or an NPC. The NPC is either manning the tank, or running @@ -293,6 +334,19 @@ private: string_t m_iszSpriteSmoke; string_t m_iszSpriteFlash; +#ifdef MAPBASE +public: + // This is kind of tricky to implement. + // Some derived classes already have their own shoot sound variables, making this one redundant, etc. + // To rectify this, m_iszShootSound replaces all of them and takes their keyfield names. + // It's like the TF spy of func_tank. + string_t m_iszShootSound; + + // NPC controllers cannot leave. >:) + bool m_bControllerGlued; +private: +#endif + string_t m_iszMaster; // Master entity (game_team_master or multisource) string_t m_soundStartRotate; @@ -327,9 +381,16 @@ private: float m_flNextLeadFactor; float m_flNextLeadFactorTime; +#ifdef MAPBASE +public: + COutputEvent m_OnFire; + COutputEHANDLE m_OnLoseTarget; + COutputEHANDLE m_OnAquireTarget; +#else COutputEvent m_OnFire; COutputEvent m_OnLoseTarget; COutputEvent m_OnAquireTarget; +#endif COutputEvent m_OnAmmoDepleted; COutputEvent m_OnGotController; COutputEvent m_OnLostController; diff --git a/sp/src/game/server/hl2/grenade_ar2.cpp b/sp/src/game/server/hl2/grenade_ar2.cpp index 70841c66..455efb18 100644 --- a/sp/src/game/server/hl2/grenade_ar2.cpp +++ b/sp/src/game/server/hl2/grenade_ar2.cpp @@ -34,6 +34,9 @@ extern ConVar sk_npc_dmg_smg1_grenade; extern ConVar sk_max_smg1_grenade; ConVar sk_smg1_grenade_radius ( "sk_smg1_grenade_radius","0"); +#ifdef MAPBASE +ConVar smg1_grenade_credit_transfer("smg1_grenade_credit_transfer", "1"); +#endif ConVar g_CV_SmokeTrail("smoke_trail", "1", 0); // temporary dust explosion switch @@ -161,6 +164,14 @@ void CGrenadeAR2::GrenadeAR2Think( void ) void CGrenadeAR2::Event_Killed( const CTakeDamageInfo &info ) { +#ifdef MAPBASE + if (smg1_grenade_credit_transfer.GetBool() && info.GetAttacker()->MyCombatCharacterPointer()) + { + CBaseCombatCharacter *pBCC = info.GetAttacker()->MyCombatCharacterPointer(); + SetThrower(pBCC); + SetOwnerEntity(pBCC); + } +#endif Detonate( ); } diff --git a/sp/src/game/server/hl2/grenade_bugbait.cpp b/sp/src/game/server/hl2/grenade_bugbait.cpp index 12e3dda1..7d5d7a47 100644 --- a/sp/src/game/server/hl2/grenade_bugbait.cpp +++ b/sp/src/game/server/hl2/grenade_bugbait.cpp @@ -200,6 +200,11 @@ void CGrenadeBugBait::BugBaitTouch( CBaseEntity *pOther ) // Tell all spawners to now fight to this position g_AntlionMakerManager.BroadcastFightGoal( GetAbsOrigin() ); +#ifdef MAPBASE + m_OnDetonate.FireOutput(GetThrower(), this); + m_OnDetonate_OutPosition.Set(GetAbsOrigin(), GetThrower(), this); +#endif + //Go away UTIL_Remove( this ); } diff --git a/sp/src/game/server/hl2/grenade_spit.cpp b/sp/src/game/server/hl2/grenade_spit.cpp index 4b713e6d..5f3e8ef9 100644 --- a/sp/src/game/server/hl2/grenade_spit.cpp +++ b/sp/src/game/server/hl2/grenade_spit.cpp @@ -131,7 +131,19 @@ void CGrenadeSpit::GrenadeSpitTouch( CBaseEntity *pOther ) if ( pOther->IsSolidFlagSet(FSOLID_VOLUME_CONTENTS | FSOLID_TRIGGER) ) { // Some NPCs are triggers that can take damage (like antlion grubs). We should hit them. +#ifdef MAPBASE + // But some physics objects that are also triggers (like weapons) shouldn't go through this check. + // + // Note: rpg_missile has the same code, except it properly accounts for weapons in a different way. + // This was discovered after I implemented this and both work fine, but if this ever causes problems, + // use rpg_missile's implementation: + // + // if ( pOther->IsSolidFlagSet(FSOLID_TRIGGER|FSOLID_VOLUME_CONTENTS) && pOther->GetCollisionGroup() != COLLISION_GROUP_WEAPON ) + // + if ( pOther->GetMoveType() == MOVETYPE_NONE && (( pOther->m_takedamage == DAMAGE_NO ) || ( pOther->m_takedamage == DAMAGE_EVENTS_ONLY )) ) +#else if ( ( pOther->m_takedamage == DAMAGE_NO ) || ( pOther->m_takedamage == DAMAGE_EVENTS_ONLY ) ) +#endif return; } diff --git a/sp/src/game/server/hl2/hl2_player.cpp b/sp/src/game/server/hl2/hl2_player.cpp index e7583f5a..3283c71a 100644 --- a/sp/src/game/server/hl2/hl2_player.cpp +++ b/sp/src/game/server/hl2/hl2_player.cpp @@ -55,12 +55,21 @@ #include "portal_player.h" #endif // PORTAL +#ifdef MAPBASE +#include "triggers.h" +#include "mapbase/variant_tools.h" +#endif + // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" extern ConVar weapon_showproficiency; extern ConVar autoaim_max_dist; +#ifdef MAPBASE +extern ConVar player_squad_autosummon_enabled; +#endif + // Do not touch with without seeing me, please! (sjb) // For consistency's sake, enemy gunfire is traced against a scaled down // version of the player's hull, not the hitboxes for the player's model @@ -157,12 +166,26 @@ static impactdamagetable_t gCappedPlayerImpactDamageTable = // Flashlight utility bool g_bCacheLegacyFlashlightStatus = true; +#ifdef MAPBASE +extern ThreeState_t Flashlight_GetLegacyVersionKey(); +#endif bool g_bUseLegacyFlashlight; bool Flashlight_UseLegacyVersion( void ) { // If this is the first run through, cache off what the answer should be (cannot change during a session) if ( g_bCacheLegacyFlashlightStatus ) { +#ifdef MAPBASE + // Check if there's a gameinfo setting. + ThreeState_t iGameKey = Flashlight_GetLegacyVersionKey(); + if (iGameKey != TRS_NONE) + { + g_bUseLegacyFlashlight = (iGameKey == TRS_TRUE); + g_bCacheLegacyFlashlightStatus = false; + return g_bUseLegacyFlashlight; + } +#endif + char modDir[MAX_PATH]; if ( UTIL_GetModDir( modDir, sizeof(modDir) ) == false ) return false; @@ -200,6 +223,15 @@ public: COutputInt m_RequestedPlayerHealth; +#ifdef MAPBASE + COutputInt m_OnGetAmmo; + COutputEvent m_PlayerDamaged; + COutputEvent m_OnSquadMemberKilled; + COutputInt m_RequestedPlayerArmor; + COutputFloat m_RequestedPlayerAuxPower; + COutputFloat m_RequestedPlayerFlashBattery; +#endif + void InputRequestPlayerHealth( inputdata_t &inputdata ); void InputSetFlashlightSlowDrain( inputdata_t &inputdata ); void InputSetFlashlightNormalDrain( inputdata_t &inputdata ); @@ -212,14 +244,164 @@ public: #ifdef PORTAL void InputSuppressCrosshair( inputdata_t &inputdata ); #endif // PORTAL2 +#ifdef MAPBASE + void InputRequestPlayerArmor( inputdata_t &inputdata ); + void InputRequestPlayerAuxPower( inputdata_t &inputdata ); + void InputRequestPlayerFlashBattery( inputdata_t &inputdata ); + + void InputGetAmmoOnWeapon( inputdata_t &inputdata ); + + void InputSetHandModel( inputdata_t &inputdata ); + + void InputSetPlayerModel( inputdata_t &inputdata ); + void InputSetPlayerDrawExternally( inputdata_t &inputdata ); +#endif void Activate ( void ); +#ifdef MAPBASE + bool KeyValue( const char *szKeyName, const char *szValue ); + + bool AcceptInput( const char *szInputName, CBaseEntity *pActivator, CBaseEntity *pCaller, variant_t Value, int outputID ); + + void NotifyPlayerHasProxy(); + + // This is here because the player might not be available when we spawn. + // Hope there wouldn't be enough time for this to need to be saved... + CUtlDict m_QueuedKV; + + int m_MaxArmor = 100; +#endif + bool PassesDamageFilter( const CTakeDamageInfo &info ); EHANDLE m_hPlayer; }; +#ifdef MAPBASE +static CUtlVector g_pCommandRedirects; + +//----------------------------------------------------------------------------- +// Redirects player squad commands +//----------------------------------------------------------------------------- +class CCommandRedirect : public CBaseTrigger +{ + DECLARE_CLASS( CCommandRedirect, CBaseTrigger ); +public: + CCommandRedirect() + { + g_pCommandRedirects.AddToTail(this); + //int i = g_pCommandRedirects.AddToTail(); + //g_pCommandRedirects[i].Set( this ); + } + + ~CCommandRedirect() + { + g_pCommandRedirects.AddToTail(this); + /* + for (int i = 0; i < g_pCommandRedirects.Count(); i++) + { + if (g_pCommandRedirects[i].Get() == this) + { + g_pCommandRedirects.Remove( i ); + break; + } + } + */ + } + + void Spawn() + { + BaseClass::Spawn(); + InitTrigger(); + } + + // Will the command point change? + // True = Judged guilty and changed. + // False = Judged not guilty and unchanged. + bool GetVerdict(Vector *defendant, CHL2_Player *pPlayer) + { + // Deliver goal to relevant destinations before sentencing. + m_OnCommandGoal.Set(*defendant, pPlayer, this); + + if (m_target == NULL_STRING) + { + // Abort sentencing. + return false; + } + else if (FStrEq(STRING(m_target), "-1")) + { + // Deliver verdict immediately. + *defendant = Vector(0, 0, 0); + return false; + } + else + { + // Locate entity of interest. + // Player is caller. + // Player squad representative is activator. + CBaseEntity *pEntOfInterest = gEntList.FindEntityGeneric(NULL, STRING(m_target), this, pPlayer->GetSquadCommandRepresentative(), pPlayer); + if (pEntOfInterest) + { + // Deliver their local origin. + *defendant = pEntOfInterest->GetLocalOrigin(); + return true; + } + } + + // No sentence. + return false; + } + + void HandleAllies(CAI_Squad *pSquad, CHL2_Player *pPlayer) + { + if (m_bRepOnly) + { + CBaseEntity *pSquadRep = pPlayer->GetSquadCommandRepresentative(); + if (pSquadRep) + m_OutAlly.Set(pSquadRep, pSquadRep, this); + } + else + { + AISquadIter_t iter; + for ( CBaseEntity *pAllyNpc = pSquad->GetFirstMember(&iter); pAllyNpc; pAllyNpc = pSquad->GetNextMember(&iter) ) + { + m_OutAlly.Set(pAllyNpc, pAllyNpc, this); + } + } + } + + bool PassesTriggerFilters(CBaseEntity *pOther) + { + return pOther->IsPlayer() || (pOther->MyNPCPointer() && pOther->MyNPCPointer()->IsInPlayerSquad()); + } + + bool IsDisabled() { return m_bDisabled; } + + DECLARE_DATADESC(); + +private: + bool m_bRepOnly; + + COutputVector m_OnCommandGoal; + COutputEHANDLE m_OutAlly; +}; + +LINK_ENTITY_TO_CLASS( func_commandredirect, CCommandRedirect ); +BEGIN_DATADESC( CCommandRedirect ) + + DEFINE_KEYFIELD( m_bRepOnly, FIELD_BOOLEAN, "reponly" ), + DEFINE_KEYFIELD( m_bDisabled, FIELD_BOOLEAN, "StartDisabled" ), + + DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), + DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), + + DEFINE_OUTPUT( m_OnCommandGoal, "OnCommandGoal" ), + DEFINE_OUTPUT( m_OutAlly, "OutAlly" ), + +END_DATADESC() +#endif + //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ @@ -366,10 +548,34 @@ BEGIN_DATADESC( CHL2_Player ) DEFINE_INPUTFUNC( FIELD_FLOAT, "IgnoreFallDamage", InputIgnoreFallDamage ), DEFINE_INPUTFUNC( FIELD_FLOAT, "IgnoreFallDamageWithoutReset", InputIgnoreFallDamageWithoutReset ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_EHANDLE, "OnSquadMemberKilled", OnSquadMemberKilled ), +#else DEFINE_INPUTFUNC( FIELD_VOID, "OnSquadMemberKilled", OnSquadMemberKilled ), +#endif DEFINE_INPUTFUNC( FIELD_VOID, "DisableFlashlight", InputDisableFlashlight ), DEFINE_INPUTFUNC( FIELD_VOID, "EnableFlashlight", InputEnableFlashlight ), DEFINE_INPUTFUNC( FIELD_VOID, "ForceDropPhysObjects", InputForceDropPhysObjects ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "SquadForceSummon", InputSquadForceSummon ), + DEFINE_INPUTFUNC( FIELD_INPUT, "SquadForceGoTo", InputSquadForceGoTo ), // FIELD_INPUT so it supports vectors, ehandles, and strings + + DEFINE_INPUTFUNC( FIELD_INTEGER, "AddArmor", InputAddArmor ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "RemoveArmor", InputRemoveArmor ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetArmor", InputSetArmor ), + + DEFINE_INPUTFUNC( FIELD_FLOAT, "AddAuxPower", InputAddAuxPower ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "RemoveAuxPower", InputRemoveAuxPower ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetAuxPower", InputSetAuxPower ), + + DEFINE_INPUTFUNC( FIELD_VOID, "TurnFlashlightOn", InputTurnFlashlightOn ), + DEFINE_INPUTFUNC( FIELD_VOID, "TurnFlashlightOff", InputTurnFlashlightOff ), + + DEFINE_INPUTFUNC( FIELD_VOID, "EnableGeigerCounter", InputEnableGeigerCounter ), + DEFINE_INPUTFUNC( FIELD_VOID, "DisableGeigerCounter", InputDisableGeigerCounter ), + DEFINE_INPUTFUNC( FIELD_VOID, "ShowSquadHUD", InputShowSquadHUD ), + DEFINE_INPUTFUNC( FIELD_VOID, "HideSquadHUD", InputHideSquadHUD ), +#endif DEFINE_SOUNDPATCH( m_sndLeeches ), DEFINE_SOUNDPATCH( m_sndWaterSplashes ), @@ -1103,6 +1309,193 @@ void CHL2_Player::PlayerRunCommand(CUserCmd *ucmd, IMoveHelper *moveHelper) BaseClass::PlayerRunCommand( ucmd, moveHelper ); } +#ifdef MAPBASE +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 ) +{ + if (!hl2_use_hl2dm_anims.GetBool()) + return; + + if (IsAlive()) + { + SetSequence( -1 ); + SetActivity( ACT_INVALID ); + + if (!GetAbsVelocity().x && !GetAbsVelocity().y) + SetAnimation( PLAYER_IDLE ); + else if ((GetAbsVelocity().x || GetAbsVelocity().y) && (GetFlags() & FL_ONGROUND)) + SetAnimation( PLAYER_WALK ); + else if (GetWaterLevel() > 1) + SetAnimation( PLAYER_WALK ); + } +} + +// Set the activity based on an event or current state +void CHL2_Player::SetAnimation( PLAYER_ANIM playerAnim ) +{ + if (!hl2_use_hl2dm_anims.GetBool()) + return; + + int animDesired; + + float speed; + + speed = GetAbsVelocity().Length2D(); + + + // bool bRunning = true; + + //Revisit! +/* if ( ( m_nButtons & ( IN_FORWARD | IN_BACK | IN_MOVELEFT | IN_MOVERIGHT ) ) ) + { + if ( speed > 1.0f && speed < hl2_normspeed.GetFloat() - 20.0f ) + { + bRunning = false; + } + }*/ + + if ( GetFlags() & ( FL_FROZEN | FL_ATCONTROLS ) ) + { + speed = 0; + playerAnim = PLAYER_IDLE; + } + + Activity idealActivity = ACT_HL2MP_RUN; + + // This could stand to be redone. Why is playerAnim abstracted from activity? (sjb) + if ( playerAnim == PLAYER_JUMP ) + { + idealActivity = ACT_HL2MP_JUMP; + } + else if ( playerAnim == PLAYER_DIE ) + { + if ( m_lifeState == LIFE_ALIVE ) + { + return; + } + } + else if ( playerAnim == PLAYER_ATTACK1 ) + { + if ( GetActivity( ) == ACT_HOVER || + GetActivity( ) == ACT_SWIM || + GetActivity( ) == ACT_HOP || + GetActivity( ) == ACT_LEAP || + GetActivity( ) == ACT_DIESIMPLE ) + { + idealActivity = GetActivity( ); + } + else + { + idealActivity = ACT_HL2MP_GESTURE_RANGE_ATTACK; + } + } + else if ( playerAnim == PLAYER_RELOAD ) + { + idealActivity = ACT_HL2MP_GESTURE_RELOAD; + } + else if ( playerAnim == PLAYER_IDLE || playerAnim == PLAYER_WALK ) + { + if ( !( GetFlags() & FL_ONGROUND ) && GetActivity( ) == ACT_HL2MP_JUMP ) // Still jumping + { + idealActivity = GetActivity( ); + } + /* + else if ( GetWaterLevel() > 1 ) + { + if ( speed == 0 ) + idealActivity = ACT_HOVER; + else + idealActivity = ACT_SWIM; + } + */ + else + { + if ( GetFlags() & FL_DUCKING ) + { + if ( speed > 0 ) + { + idealActivity = ACT_HL2MP_WALK_CROUCH; + } + else + { + idealActivity = ACT_HL2MP_IDLE_CROUCH; + } + } + else + { + if ( speed > 0 ) + { + /* + if ( bRunning == false ) + { + idealActivity = ACT_WALK; + } + else + */ + { + idealActivity = ACT_HL2MP_RUN; + } + } + else + { + idealActivity = ACT_HL2MP_IDLE; + } + } + } + } + + if ( idealActivity == ACT_HL2MP_GESTURE_RANGE_ATTACK ) + { + RestartGesture( Weapon_TranslateActivity( idealActivity ) ); + + // FIXME: this seems a bit wacked + Weapon_SetActivity( Weapon_TranslateActivity( ACT_RANGE_ATTACK1 ), 0 ); + + return; + } + else if ( idealActivity == ACT_HL2MP_GESTURE_RELOAD ) + { + RestartGesture( Weapon_TranslateActivity( idealActivity ) ); + return; + } + else + { + SetActivity( idealActivity ); + + animDesired = SelectWeightedSequence( Weapon_TranslateActivity ( idealActivity ) ); + + if (animDesired == -1) + { + animDesired = SelectWeightedSequence( idealActivity ); + + if ( animDesired == -1 ) + { + animDesired = 0; + } + } + + // Already using the desired animation? + if ( GetSequence() == animDesired ) + return; + + m_flPlaybackRate = 1.0; + ResetSequence( animDesired ); + SetCycle( 0 ); + return; + } + + // Already using the desired animation? + if ( GetSequence() == animDesired ) + return; + + //Msg( "Set animation to %d\n", animDesired ); + // Reset to first frame of desired animation + ResetSequence( animDesired ); + SetCycle( 0 ); +} +#endif + //----------------------------------------------------------------------------- // Purpose: Sets HL2 specific defaults. //----------------------------------------------------------------------------- @@ -1401,6 +1794,39 @@ bool CHL2_Player::CommanderFindGoal( commandgoal_t *pGoal ) UTIL_TraceLine( EyePosition(), EyePosition() + forward * MAX_COORD_RANGE, MASK_SHOT, &filter, &tr ); +#ifdef MAPBASE + // func_commandredirect handling + if (g_pCommandRedirects.Count() > 0) + { + for (int i = 0; i < g_pCommandRedirects.Count(); i++) + { + CCommandRedirect *pCommandRedirect = static_cast(g_pCommandRedirects[i]); + if (!pCommandRedirect || pCommandRedirect->IsDisabled() || !pCommandRedirect->PointIsWithin(tr.endpos)) + continue; + + // First, GIVE IT OUR ALLIES so it could fire outputs + pCommandRedirect->HandleAllies(m_pPlayerAISquad, this); + + Vector vec = tr.endpos; + if (pCommandRedirect->GetVerdict(&vec, this)) + { + // It doesn't want us moving, so just don't find a goal at all + if (vec.IsZero()) + { + return false; + } + + // Just set our goal to this, the mapper didn't sign up for these checks + pGoal->m_vecGoalLocation = vec; + return true; + } + + // Only one should be necessary + break; + } + } + //else +#endif if( !tr.DidHitWorld() ) { CUtlVector Allies; @@ -1521,7 +1947,11 @@ void CHL2_Player::CommanderUpdate() { CAI_BaseNPC *pCommandRepresentative = GetSquadCommandRepresentative(); bool bFollowMode = false; +#ifdef MAPBASE + if ( pCommandRepresentative && !HasSpawnFlags(SF_PLAYER_HIDE_SQUAD_HUD) ) +#else if ( pCommandRepresentative ) +#endif { bFollowMode = ( pCommandRepresentative->GetCommandGoal() == vec3_invalid ); @@ -1567,8 +1997,22 @@ void CHL2_Player::CommanderUpdate() { m_CommanderUpdateTimer.Set(2.5); +#ifdef MAPBASE + if ( pCommandRepresentative->ShouldAutoSummon() ) + { + if (!HL2GameRules()->AutosummonDisabled() && player_squad_autosummon_enabled.GetBool()) + CommanderExecute( CC_FOLLOW ); + else + { + // Show a hud hint if autosummoning has been disabled + UTIL_HudHintText( this, "#Valve_Hint_Command_recall" ); + //m_CommanderUpdateTimer.Set(10.0); + } + } +#else if ( pCommandRepresentative->ShouldAutoSummon() ) CommanderExecute( CC_FOLLOW ); +#endif } } @@ -1696,6 +2140,95 @@ void CHL2_Player::CommanderMode() } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CHL2_Player::InputSquadForceSummon( inputdata_t &inputdata ) +{ + CommanderExecute( CC_FOLLOW ); +} + +//----------------------------------------------------------------------------- +// Purpose: Forces the player's squad to go to a specific location or entity. +//----------------------------------------------------------------------------- +void CHL2_Player::InputSquadForceGoTo( inputdata_t &inputdata ) +{ + CAI_BaseNPC *pPlayerSquadLeader = GetSquadCommandRepresentative(); + + if ( !pPlayerSquadLeader ) + return; + + int i; + CUtlVector Allies; + commandgoal_t goal; + + variant_t var = Variant_ParseInput(inputdata); + + if (var.FieldType() == FIELD_VECTOR) + { + goal.m_pGoalEntity = NULL; + var.Vector3D(goal.m_vecGoalLocation); + } + else + { + goal.m_pGoalEntity = var.FieldType() == FIELD_EHANDLE ? var.Entity() : gEntList.FindEntityByNameNearest(var.String(), pPlayerSquadLeader->GetLocalOrigin(), 0, this, inputdata.pActivator, inputdata.pCaller); + goal.m_vecGoalLocation = vec3_invalid; + } + + AISquadIter_t iter; + for ( CAI_BaseNPC *pAllyNpc = m_pPlayerAISquad->GetFirstMember(&iter); pAllyNpc; pAllyNpc = m_pPlayerAISquad->GetNextMember(&iter) ) + { + if ( pAllyNpc->IsCommandable() ) + Allies.AddToTail( pAllyNpc ); + } + + CAI_BaseNPC * pTargetNpc = (goal.m_pGoalEntity) ? goal.m_pGoalEntity->MyNPCPointer() : NULL; + + bool bHandled = false; + if( pTargetNpc ) + { + bHandled = !CommanderExecuteOne( pTargetNpc, goal, Allies.Base(), Allies.Count() ); + } + + for ( i = 0; !bHandled && i < Allies.Count(); i++ ) + { + if ( Allies[i] != pTargetNpc && Allies[i]->IsPlayerAlly() ) + { + bHandled = !CommanderExecuteOne( Allies[i], goal, Allies.Base(), Allies.Count() ); + } + } + + //CommanderExecute( CC_SEND ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CHL2_Player::InputEnableGeigerCounter( inputdata_t &inputdata ) +{ + RemoveSpawnFlags(SF_PLAYER_NO_GEIGER); +} + +void CHL2_Player::InputDisableGeigerCounter( inputdata_t &inputdata ) +{ + AddSpawnFlags(SF_PLAYER_NO_GEIGER); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CHL2_Player::InputShowSquadHUD( inputdata_t &inputdata ) +{ + RemoveSpawnFlags(SF_PLAYER_HIDE_SQUAD_HUD); +} + +void CHL2_Player::InputHideSquadHUD( inputdata_t &inputdata ) +{ + AddSpawnFlags(SF_PLAYER_HIDE_SQUAD_HUD); +} +#endif + //----------------------------------------------------------------------------- // Purpose: // Input : iImpulse - @@ -2239,6 +2772,72 @@ void CHL2_Player::InputIgnoreFallDamageWithoutReset( inputdata_t &inputdata ) m_bIgnoreFallDamageResetAfterImpact = false; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CHL2_Player::InputAddArmor( inputdata_t &inputdata ) +{ + int iArmor = MIN((GetPlayerProxy() ? GetPlayerProxy()->m_MaxArmor : 100) - ArmorValue(), inputdata.value.Int()); + + IncrementArmorValue( iArmor ); +} + +//----------------------------------------------------------------------------- +// This can also add to the player's armor by passing a negative input +// which can bypass the maximum armor set in the player proxy. +//----------------------------------------------------------------------------- +void CHL2_Player::InputRemoveArmor( inputdata_t &inputdata ) +{ + int iArmor = MIN(ArmorValue(), inputdata.value.Int()); + + IncrementArmorValue( -iArmor ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CHL2_Player::InputSetArmor( inputdata_t &inputdata ) +{ + int iArmor = MIN(GetPlayerProxy() ? GetPlayerProxy()->m_MaxArmor : 100, inputdata.value.Int()); + + SetArmorValue( iArmor ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CHL2_Player::InputAddAuxPower( inputdata_t &inputdata ) +{ + SuitPower_Charge( inputdata.value.Float() ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CHL2_Player::InputRemoveAuxPower( inputdata_t &inputdata ) +{ + SuitPower_Drain( inputdata.value.Float() ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CHL2_Player::InputSetAuxPower( inputdata_t &inputdata ) +{ + SuitPower_SetCharge( inputdata.value.Float() ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CHL2_Player::InputTurnFlashlightOn( inputdata_t &inputdata ) +{ + FlashlightTurnOn(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CHL2_Player::InputTurnFlashlightOff( inputdata_t &inputdata ) +{ + FlashlightTurnOff(); +} +#endif + //----------------------------------------------------------------------------- // Purpose: Notification of a player's npc ally in the players squad being killed //----------------------------------------------------------------------------- @@ -2249,6 +2848,10 @@ void CHL2_Player::OnSquadMemberKilled( inputdata_t &data ) user.MakeReliable(); UserMessageBegin( user, "SquadMemberDied" ); MessageEnd(); + +#ifdef MAPBASE + FirePlayerProxyOutput("OnSquadMemberKilled", data.value, data.pActivator, data.value.Entity()); +#endif } //----------------------------------------------------------------------------- @@ -2350,6 +2953,10 @@ int CHL2_Player::OnTakeDamage( const CTakeDamageInfo &info ) gamestats->Event_PlayerDamage( this, info ); +#ifdef MAPBASE + FirePlayerProxyOutput("PlayerDamaged", variant_t(), info.GetAttacker(), this); +#endif + return BaseClass::OnTakeDamage( playerDamage ); } @@ -2463,7 +3070,11 @@ void CHL2_Player::Event_Killed( const CTakeDamageInfo &info ) { BaseClass::Event_Killed( info ); +#ifdef MAPBASE + FirePlayerProxyOutput( "PlayerDied", variant_t(), info.GetAttacker(), this ); +#else FirePlayerProxyOutput( "PlayerDied", variant_t(), this, this ); +#endif NotifyScriptsOfDeath(); } @@ -2630,12 +3241,45 @@ int CHL2_Player::GiveAmmo( int nCount, int nAmmoIndex, bool bSuppressSound) bool CHL2_Player::Weapon_CanUse( CBaseCombatWeapon *pWeapon ) { #ifndef HL2MP +#ifdef MAPBASE + if ( pWeapon->ClassMatches( "weapon_stunstick" ) ) + { + switch (HL2GameRules()->GetStunstickPickupBehavior()) + { + // Default, including 0 + default: + { + if ( ApplyBattery( 0.5 ) ) + UTIL_Remove( pWeapon ); + return false; + } break; + + // Allow pickup, if already picked up just apply battery + case 1: + { + if ( Weapon_OwnsThisType("weapon_stunstick") ) + { + if ( ApplyBattery( 0.5 ) ) + UTIL_Remove( pWeapon ); + return false; + } + } break; + + // Don't pickup, don't even apply battery + case 2: return false; + + // Just pickup, never apply battery + case 3: break; + } + } +#else if ( pWeapon->ClassMatches( "weapon_stunstick" ) ) { if ( ApplyBattery( 0.5 ) ) UTIL_Remove( pWeapon ); return false; } +#endif #endif return BaseClass::Weapon_CanUse( pWeapon ); @@ -3697,6 +4341,18 @@ void CHL2_Player::ModifyOrAppendPlayerCriteria( AI_CriteriaSet& set ) } } +#ifdef MAPBASE +const char *CHL2_Player::GetOverrideStepSound( const char *pszBaseStepSoundName ) +{ + const char *szSound = GetContextValue(FindContextByName("footsteps")); + if (szSound[0] != '\0') + { + return szSound; + } + return pszBaseStepSoundName; +} +#endif + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- @@ -3751,6 +4407,9 @@ CLogicPlayerProxy *CHL2_Player::GetPlayerProxy( void ) pProxy->m_hPlayer = this; m_hPlayerProxy = pProxy; +#ifdef MAPBASE + pProxy->NotifyPlayerHasProxy(); +#endif } return pProxy; @@ -3774,6 +4433,14 @@ BEGIN_DATADESC( CLogicPlayerProxy ) DEFINE_OUTPUT( m_PlayerHasNoAmmo, "PlayerHasNoAmmo" ), DEFINE_OUTPUT( m_PlayerDied, "PlayerDied" ), DEFINE_OUTPUT( m_PlayerMissedAR2AltFire, "PlayerMissedAR2AltFire" ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_PlayerDamaged, "PlayerDamaged" ), + DEFINE_OUTPUT( m_OnSquadMemberKilled, "OnSquadMemberKilled" ), + DEFINE_OUTPUT( m_OnGetAmmo, "OnGetAmmo" ), + DEFINE_OUTPUT( m_RequestedPlayerArmor, "PlayerArmor" ), + DEFINE_OUTPUT( m_RequestedPlayerAuxPower, "PlayerAuxPower" ), + DEFINE_OUTPUT( m_RequestedPlayerFlashBattery, "PlayerFlashBattery" ), +#endif DEFINE_INPUTFUNC( FIELD_VOID, "RequestPlayerHealth", InputRequestPlayerHealth ), DEFINE_INPUTFUNC( FIELD_VOID, "SetFlashlightSlowDrain", InputSetFlashlightSlowDrain ), DEFINE_INPUTFUNC( FIELD_VOID, "SetFlashlightNormalDrain", InputSetFlashlightNormalDrain ), @@ -3786,6 +4453,16 @@ BEGIN_DATADESC( CLogicPlayerProxy ) #ifdef PORTAL DEFINE_INPUTFUNC( FIELD_VOID, "SuppressCrosshair", InputSuppressCrosshair ), #endif // PORTAL +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "RequestPlayerArmor", InputRequestPlayerArmor ), + DEFINE_INPUTFUNC( FIELD_VOID, "RequestPlayerAuxPower", InputRequestPlayerAuxPower ), + DEFINE_INPUTFUNC( FIELD_VOID, "RequestPlayerFlashBattery", InputRequestPlayerFlashBattery ), + DEFINE_INPUTFUNC( FIELD_STRING, "GetAmmoOnWeapon", InputGetAmmoOnWeapon ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetHandModel", InputSetHandModel ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetPlayerModel", InputSetPlayerModel ), + DEFINE_INPUTFUNC( FIELD_BOOLEAN, "SetPlayerDrawExternally", InputSetPlayerDrawExternally ), + DEFINE_INPUT( m_MaxArmor, FIELD_INTEGER, "SetMaxInputArmor" ), +#endif DEFINE_FIELD( m_hPlayer, FIELD_EHANDLE ), END_DATADESC() @@ -3799,12 +4476,150 @@ void CLogicPlayerProxy::Activate( void ) } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Cache user entity field values until spawn is called. +// Input : szKeyName - Key to handle. +// szValue - Value for key. +// Output : Returns true if the key was handled, false if not. +//----------------------------------------------------------------------------- +bool CLogicPlayerProxy::KeyValue( const char *szKeyName, const char *szValue ) +{ + bool bPlayerKV = false; + + if (Q_strnicmp(szKeyName, "HandsVM", 7) == 0) + { + if (m_hPlayer) + { + szKeyName += 7; + CBasePlayer *pPlayer = static_cast( m_hPlayer.Get() ); + CBaseViewModel *vm = pPlayer->GetViewModel(1); + if (vm) + { + if (*szKeyName == NULL && PrecacheModel(szValue)) // HandsVM + vm->SetModel(szValue); + else if (FStrEq(szKeyName, "Skin")) // HandsVMSkin + vm->m_nSkin = atoi(szValue); + } + return true; + } + } + else if (FStrEq(szKeyName, "ResponseContext")) + { + bPlayerKV = true; + if (m_hPlayer) + return m_hPlayer->KeyValue(szKeyName, szValue); + } + else if (FStrEq(szKeyName, "HideSquadHUD")) + { + if (m_hPlayer) + { + if (szValue[0] != '0') + m_hPlayer->AddSpawnFlags(SF_PLAYER_HIDE_SQUAD_HUD); + else + m_hPlayer->RemoveSpawnFlags(SF_PLAYER_HIDE_SQUAD_HUD); + return true; + } + } + else if (FStrEq(szKeyName, "PlayerModel")) + { + if (m_hPlayer) + { + if (PrecacheModel( szValue )) + { + m_hPlayer->SetModel( szValue ); + } + return true; + } + } + else + { + if (BaseClass::KeyValue( szKeyName, szValue )) + return true; + + if (m_hPlayer) + { + DevMsg("logic_playerproxy: Passing unhandled keyvalue \"%s, %s\" to player\n", szKeyName, szValue); + return m_hPlayer->KeyValue(szKeyName, szValue); + } + } + + // If we reach this point, player is not available to test unidentified/special KV + // Queue it up + DevMsg("logic_playerproxy: Queueing %s, %s\n", szKeyName, szValue); + m_QueuedKV.Insert(bPlayerKV ? UTIL_VarArgs("&&%s", szKeyName) : szKeyName, AllocPooledString(szValue)); + + return true; +} + +//----------------------------------------------------------------------------- +// Purpose: calls the appropriate message mapped function in the entity according +// to the fired action. +// Input : char *szInputName - input destination +// *pActivator - entity which initiated this sequence of actions +// *pCaller - entity from which this event is sent +// Output : Returns true on success, false on failure. +//----------------------------------------------------------------------------- +bool CLogicPlayerProxy::AcceptInput( const char *szInputName, CBaseEntity *pActivator, CBaseEntity *pCaller, variant_t Value, int outputID ) +{ + bool base = BaseClass::AcceptInput( szInputName, pActivator, pCaller, Value, outputID ); + + if (!base) + { + if (m_hPlayer) + { + DevMsg("logic_playerproxy: Passing unhandled input \"%s\" to player\n", szInputName); + return m_hPlayer->AcceptInput( szInputName, pActivator, pCaller, Value, outputID ); + } + else + { + DevMsg("logic_playerproxy: Player not found!\n"); + + g_EventQueue.AddEvent("!player", szInputName, Value, 0.01f, pActivator, pCaller); + } + } + + return base; +} + +//----------------------------------------------------------------------------- +// Purpose: Notifies logic_playerproxy when player is valid +//----------------------------------------------------------------------------- +void CLogicPlayerProxy::NotifyPlayerHasProxy() +{ + Assert( m_hPlayer != NULL ); + + // Handle any queued keyvalues + int iQueueCount = m_QueuedKV.Count(); + for (int i = 0; i < iQueueCount; i++) + { + const char *name = m_QueuedKV.GetElementName(i); + const char *value = STRING(m_QueuedKV[i]); + DevMsg("logic_playerproxy: Handing over %s, %s from dict\n", name, value); + + if (name[0] == '&' && name[1] == '&') + { + // We're supposed to send this to the player + m_hPlayer->KeyValue(name + 2, value); + } + + KeyValue(name, value); + } + + m_QueuedKV.RemoveAll(); +} +#endif + bool CLogicPlayerProxy::PassesDamageFilter( const CTakeDamageInfo &info ) { if (m_hDamageFilter) { CBaseFilter *pFilter = (CBaseFilter *)(m_hDamageFilter.Get()); +#ifdef MAPBASE + return pFilter->PassesDamageFilter(m_hPlayer.Get(), info); +#else return pFilter->PassesDamageFilter(info); +#endif } return true; @@ -3827,6 +4642,43 @@ void CLogicPlayerProxy::InputRequestPlayerHealth( inputdata_t &inputdata ) m_RequestedPlayerHealth.Set( m_hPlayer->GetHealth(), inputdata.pActivator, inputdata.pCaller ); } +#ifdef MAPBASE +void CLogicPlayerProxy::InputRequestPlayerArmor( inputdata_t &inputdata ) +{ + if ( m_hPlayer == NULL ) + return; + + m_RequestedPlayerArmor.Set( static_cast(m_hPlayer.Get())->ArmorValue(), inputdata.pActivator, inputdata.pCaller ); +} + +void CLogicPlayerProxy::InputRequestPlayerAuxPower( inputdata_t &inputdata ) +{ + if ( m_hPlayer == NULL ) + return; + + m_RequestedPlayerAuxPower.Set( static_cast(m_hPlayer.Get())->SuitPower_GetCurrentPercentage(), inputdata.pActivator, inputdata.pCaller ); +} + +void CLogicPlayerProxy::InputRequestPlayerFlashBattery( inputdata_t &inputdata ) +{ + if ( m_hPlayer == NULL ) + return; + + m_RequestedPlayerFlashBattery.Set( static_cast(m_hPlayer.Get())->GetFlashlightBattery(), inputdata.pActivator, inputdata.pCaller ); +} + +// If it's the EP2 flashlight, it returns the flashlight battery. If it's the legacy flashlight, it returns the aux power. +// Note that this is on CHL2_Player, not CLogicPlayerProxy. +inline float CHL2_Player::GetFlashlightBattery() +{ +#ifdef HL2_EPISODIC + return Flashlight_UseLegacyVersion() ? SuitPower_GetCurrentPercentage() : m_HL2Local.m_flFlashBattery; +#else + return SuitPower_GetCurrentPercentage(); +#endif +} +#endif + void CLogicPlayerProxy::InputSetFlashlightSlowDrain( inputdata_t &inputdata ) { if( m_hPlayer == NULL ) @@ -3873,6 +4725,99 @@ void CLogicPlayerProxy::InputRequestAmmoState( inputdata_t &inputdata ) m_PlayerHasNoAmmo.FireOutput( this, this, 0 ); } +#ifdef MAPBASE +void CLogicPlayerProxy::InputGetAmmoOnWeapon( inputdata_t &inputdata ) +{ + if( m_hPlayer == NULL ) + return; + + CHL2_Player *pPlayer = dynamic_cast(m_hPlayer.Get()); + + const char *szClass = inputdata.value.String(); + + // Support secondary cases + bool bAmmo2 = szClass[0] == '@'; + if (bAmmo2) + szClass++; + + bool bClipOnly = szClass[0] == '#'; + if (bClipOnly) + szClass++; + + if (szClass[0] != NULL) + { + // Find weapon that matches class + for ( int i = 0 ; i < pPlayer->WeaponCount(); ++i ) + { + CBaseCombatWeapon* pCheck = pPlayer->GetWeapon( i ); + + if ( pCheck && FClassnameIs(pCheck, szClass) ) + { + int ammo = 0; + if (!bAmmo2) + { + // Ammo 1 + if (!bClipOnly) + ammo = pPlayer->GetAmmoCount(pCheck->GetPrimaryAmmoType()); + + if (pCheck->UsesClipsForAmmo1()) + ammo += pCheck->m_iClip1; + else + ammo += pCheck->GetPrimaryAmmoCount(); + } + else + { + // Ammo 2 + if (!bClipOnly) + ammo = pPlayer->GetAmmoCount(pCheck->GetSecondaryAmmoType()); + + if (pCheck->UsesClipsForAmmo2()) + ammo += pCheck->m_iClip2; + else + ammo += pCheck->GetSecondaryAmmoCount(); + } + + m_OnGetAmmo.Set( ammo, this, 0 ); + return; + } + } + } + else + { + // Get current weapon ammo + if (CBaseCombatWeapon *pCheck = pPlayer->GetActiveWeapon()) + { + int ammo = 0; + if (!bAmmo2) + { + // Ammo 1 + if (!bClipOnly) + ammo = pPlayer->GetAmmoCount(pCheck->GetPrimaryAmmoType()); + + if (pCheck->UsesClipsForAmmo1()) + ammo += pCheck->m_iClip1; + else + ammo += pCheck->GetPrimaryAmmoCount(); + } + else + { + // Ammo 2 + if (!bClipOnly) + ammo = pPlayer->GetAmmoCount(pCheck->GetSecondaryAmmoType()); + + if (pCheck->UsesClipsForAmmo2()) + ammo += pCheck->m_iClip2; + else + ammo += pCheck->GetSecondaryAmmoCount(); + } + + m_OnGetAmmo.Set( ammo, this, 0 ); + return; + } + } +} +#endif + void CLogicPlayerProxy::InputLowerWeapon( inputdata_t &inputdata ) { if( m_hPlayer == NULL ) @@ -3928,3 +4873,51 @@ void CLogicPlayerProxy::InputSuppressCrosshair( inputdata_t &inputdata ) pPlayer->SuppressCrosshair( true ); } #endif // PORTAL + +#ifdef MAPBASE +void CLogicPlayerProxy::InputSetHandModel( inputdata_t &inputdata ) +{ + if (!m_hPlayer) + return; + + string_t iszModel = inputdata.value.StringID(); + + if (iszModel != NULL_STRING) + PrecacheModel(STRING(iszModel)); + + CBasePlayer *pPlayer = static_cast( m_hPlayer.Get() ); + CBaseViewModel *vm = pPlayer->GetViewModel(1); + if (vm) + vm->SetModel(STRING(iszModel)); +} + +void CLogicPlayerProxy::InputSetPlayerModel( inputdata_t &inputdata ) +{ + if (!m_hPlayer) + return; + + string_t iszModel = inputdata.value.StringID(); + + if (iszModel != NULL_STRING) + PrecacheModel( STRING( iszModel ) ); + else + { + // We're resetting the model. The original model should've been cached to our own model name. + iszModel = GetModelName(); + } + + // Cache the original model as our own model name. + SetModelName( m_hPlayer->GetModelName() ); + + m_hPlayer->SetModel( STRING(iszModel) ); +} + +void CLogicPlayerProxy::InputSetPlayerDrawExternally( inputdata_t &inputdata ) +{ + if (!m_hPlayer) + return; + + CBasePlayer *pPlayer = static_cast(m_hPlayer.Get()); + pPlayer->m_bDrawPlayerModelExternally = inputdata.value.Bool(); +} +#endif diff --git a/sp/src/game/server/hl2/hl2_player.h b/sp/src/game/server/hl2/hl2_player.h index 6e72bb9e..3f65b17e 100644 --- a/sp/src/game/server/hl2/hl2_player.h +++ b/sp/src/game/server/hl2/hl2_player.h @@ -107,6 +107,13 @@ public: virtual void Splash( void ); virtual void ModifyOrAppendPlayerCriteria( AI_CriteriaSet& set ); +#ifdef MAPBASE + void ResetAnimation( void ); + void SetAnimation( PLAYER_ANIM playerAnim ); + + virtual const char *GetOverrideStepSound( const char *pszBaseStepSoundName ); +#endif + void DrawDebugGeometryOverlays(void); virtual Vector EyeDirection2D( void ); @@ -139,6 +146,11 @@ public: void SetFlashlightEnabled( bool bState ); +#ifdef MAPBASE + // Needed for logic_playerproxy + float GetFlashlightBattery(); +#endif + // Apply a battery bool ApplyBattery( float powerMultiplier = 1.0 ); @@ -159,6 +171,17 @@ public: int GetNumSquadCommandables(); int GetNumSquadCommandableMedics(); +#ifdef MAPBASE + void InputSquadForceSummon( inputdata_t &inputdata ); + void InputSquadForceGoTo( inputdata_t &inputdata ); + + void InputEnableGeigerCounter( inputdata_t &inputdata ); + void InputDisableGeigerCounter( inputdata_t &inputdata ); + + void InputShowSquadHUD( inputdata_t &inputdata ); + void InputHideSquadHUD( inputdata_t &inputdata ); +#endif + // Locator void UpdateLocatorPosition( const Vector &vecPosition ); @@ -195,6 +218,19 @@ public: void InputEnableFlashlight( inputdata_t &inputdata ); void InputDisableFlashlight( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputAddArmor( inputdata_t &inputdata ); + void InputRemoveArmor( inputdata_t &inputdata ); + void InputSetArmor( inputdata_t &inputdata ); + + void InputAddAuxPower( inputdata_t &inputdata ); + void InputRemoveAuxPower( inputdata_t &inputdata ); + void InputSetAuxPower( inputdata_t &inputdata ); + + void InputTurnFlashlightOn( inputdata_t &inputdata ); + void InputTurnFlashlightOff( inputdata_t &inputdata ); +#endif + const impactdamagetable_t &GetPhysicsImpactDamageTable(); virtual int OnTakeDamage( const CTakeDamageInfo &info ); virtual int OnTakeDamage_Alive( const CTakeDamageInfo &info ); diff --git a/sp/src/game/server/hl2/item_ammo.cpp b/sp/src/game/server/hl2/item_ammo.cpp index 6b03c3e7..15f2362c 100644 --- a/sp/src/game/server/hl2/item_ammo.cpp +++ b/sp/src/game/server/hl2/item_ammo.cpp @@ -15,6 +15,62 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" +#ifdef MAPBASE +// ======================================================================== +// >> CItemAmmo +// +// All ammo items now derive from this for multiplier purposes. +// ======================================================================== +class CItemAmmo : public CItem +{ +public: + DECLARE_CLASS( CItemAmmo, CItem ); + DECLARE_DATADESC(); + + int ITEM_GiveAmmo( CBasePlayer *pPlayer, float flCount, const char *pszAmmoName, bool bSuppressSound = false ) + { + int iAmmoType = GetAmmoDef()->Index(pszAmmoName); + if (iAmmoType == -1) + { + Msg("ERROR: Attempting to give unknown ammo type (%s)\n",pszAmmoName); + return 0; + } + + flCount *= g_pGameRules->GetAmmoQuantityScale(iAmmoType); + + // Don't give out less than 1 of anything. + flCount = MAX( 1.0f, flCount ); + + // Mapper-specific ammo multiplier. + // If it results in 0, the ammo will simply be ignored. + // If the ammo multiplier is negative, assume it's actually a direct number to override with. + if (m_flAmmoMultiplier != 1.0f) + { + if (m_flAmmoMultiplier >= 0) + flCount *= m_flAmmoMultiplier; + else + flCount = -m_flAmmoMultiplier; + } + + return pPlayer->GiveAmmo( flCount, iAmmoType, bSuppressSound ); + } + + void InputSetAmmoMultiplier( inputdata_t &inputdata ) { m_flAmmoMultiplier = inputdata.value.Float(); } + + float m_flAmmoMultiplier = 1.0f; +}; + +BEGIN_DATADESC( CItemAmmo ) + + DEFINE_KEYFIELD( m_flAmmoMultiplier, FIELD_FLOAT, "AmmoMultiplier" ), + + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetAmmoMultiplier", InputSetAmmoMultiplier ), + +END_DATADESC() + +#define CItem CItemAmmo + +#else //--------------------------------------------------------- // Applies ammo quantity scale. //--------------------------------------------------------- @@ -34,6 +90,7 @@ int ITEM_GiveAmmo( CBasePlayer *pPlayer, float flCount, const char *pszAmmoName, return pPlayer->GiveAmmo( flCount, iAmmoType, bSuppressSound ); } +#endif // ======================================================================== // >> BoxSRounds @@ -606,6 +663,10 @@ enum AMMOCRATE_CROSSBOW, AMMOCRATE_AR2_ALTFIRE, AMMOCRATE_SMG_ALTFIRE, +#ifdef MAPBASE + AMMOCRATE_SLAM, + AMMOCRATE_EMPTY, +#endif NUM_AMMO_CRATE_TYPES, }; @@ -648,6 +709,10 @@ protected: COutputEvent m_OnUsed; CHandle< CBasePlayer > m_hActivator; +#ifdef MAPBASE + COutputEvent m_OnAmmoTaken; +#endif + DECLARE_DATADESC(); }; @@ -668,6 +733,10 @@ BEGIN_DATADESC( CItem_AmmoCrate ) DEFINE_OUTPUT( m_OnUsed, "OnUsed" ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OnAmmoTaken, "OnAmmoTaken" ), +#endif + DEFINE_INPUTFUNC( FIELD_VOID, "Kill", InputKill ), DEFINE_THINKFUNC( CrateThink ), @@ -687,12 +756,22 @@ const char *CItem_AmmoCrate::m_lpzModelNames[NUM_AMMO_CRATE_TYPES] = "models/items/ammocrate_rockets.mdl", // RPG rounds "models/items/ammocrate_buckshot.mdl", // Buckshot "models/items/ammocrate_grenade.mdl", // Grenades +#ifdef MAPBASE + "models/items/ammocrate_357.mdl", // 357 + "models/items/ammocrate_xbow.mdl", // Crossbow + "models/items/ammocrate_ar2alt.mdl", // Combine Ball +#else "models/items/ammocrate_smg1.mdl", // 357 "models/items/ammocrate_smg1.mdl", // Crossbow - + //FIXME: This model is incorrect! "models/items/ammocrate_ar2.mdl", // Combine Ball +#endif "models/items/ammocrate_smg2.mdl", // smg grenade +#ifdef MAPBASE + "models/items/ammocrate_slam.mdl", // slam + "models/items/ammocrate_empty.mdl", // empty +#endif }; // Ammo type names @@ -708,6 +787,10 @@ const char *CItem_AmmoCrate::m_lpzAmmoNames[NUM_AMMO_CRATE_TYPES] = "XBowBolt", "AR2AltFire", "SMG1_Grenade", +#ifdef MAPBASE + "slam", + NULL, +#endif }; // Ammo amount given per +use @@ -723,6 +806,10 @@ int CItem_AmmoCrate::m_nAmmoAmounts[NUM_AMMO_CRATE_TYPES] = 50, // Crossbow 3, // AR2 alt-fire 5, +#ifdef MAPBASE + 5, // SLAM + NULL, // Empty +#endif }; const char *CItem_AmmoCrate::m_pGiveWeapon[NUM_AMMO_CRATE_TYPES] = @@ -737,6 +824,10 @@ const char *CItem_AmmoCrate::m_pGiveWeapon[NUM_AMMO_CRATE_TYPES] = NULL, // Crossbow NULL, // AR2 alt-fire NULL, // SMG alt-fire +#ifdef MAPBASE + "weapon_slam", // SLAM + NULL, // Empty +#endif }; #define AMMO_CRATE_CLOSE_DELAY 1.5f @@ -792,6 +883,10 @@ void CItem_AmmoCrate::Precache( void ) //----------------------------------------------------------------------------- void CItem_AmmoCrate::SetupCrate( void ) { +#ifdef MAPBASE + // Custom models might be desired on, say, empty crates with custom textures + if (GetModelName() == NULL_STRING) +#endif SetModelName( AllocPooledString( m_lpzModelNames[m_nAmmoType] ) ); m_nAmmoIndex = GetAmmoDef()->Index( m_lpzAmmoNames[m_nAmmoType] ); @@ -915,13 +1010,24 @@ void CItem_AmmoCrate::HandleAnimEvent( animevent_t *pEvent ) } else { +#ifdef MAPBASE + m_OnAmmoTaken.FireOutput(m_hActivator, this); +#endif SetBodygroup( 1, false ); } } } +#ifdef MAPBASE + // Empty ammo crates should still fire OnAmmoTaken + if ( m_hActivator->GiveAmmo( m_nAmmoAmounts[m_nAmmoType], m_nAmmoIndex ) != 0 || m_nAmmoType == AMMOCRATE_EMPTY ) +#else if ( m_hActivator->GiveAmmo( m_nAmmoAmounts[m_nAmmoType], m_nAmmoIndex ) != 0 ) +#endif { +#ifdef MAPBASE + m_OnAmmoTaken.FireOutput(m_hActivator, this); +#endif SetBodygroup( 1, false ); } m_hActivator = NULL; @@ -979,6 +1085,13 @@ void CItem_AmmoCrate::CrateThink( void ) //----------------------------------------------------------------------------- void CItem_AmmoCrate::InputKill( inputdata_t &data ) { +#ifdef MAPBASE + // Why is this its own function? + // item_dynamic_resupply and item_item_crate are in the same boat. + // I don't understand. + m_OnKilled.FireOutput( data.pActivator, this ); +#endif + UTIL_Remove( this ); } diff --git a/sp/src/game/server/hl2/item_dynamic_resupply.cpp b/sp/src/game/server/hl2/item_dynamic_resupply.cpp index 6bdcff62..bc0a6c96 100644 --- a/sp/src/game/server/hl2/item_dynamic_resupply.cpp +++ b/sp/src/game/server/hl2/item_dynamic_resupply.cpp @@ -116,6 +116,10 @@ private: float m_flDesiredAmmo[ NUM_AMMO_ITEMS ]; bool m_bIsMaster; + +#ifdef MAPBASE + COutputEHANDLE m_OnItem; +#endif }; LINK_ENTITY_TO_CLASS(item_dynamic_resupply, CItem_DynamicResupply); @@ -153,6 +157,10 @@ BEGIN_DATADESC( CItem_DynamicResupply ) DEFINE_FIELD( m_version, FIELD_INTEGER ), DEFINE_FIELD( m_bIsMaster, FIELD_BOOLEAN ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OnItem, "OnItem" ), +#endif + // Silence, Classcheck! // DEFINE_ARRAY( m_flDesiredHealth, FIELD_FLOAT, NUM_HEALTH_ITEMS ), // DEFINE_ARRAY( m_flDesiredAmmo, FIELD_FLOAT, NUM_AMMO_ITEMS ), @@ -282,6 +290,11 @@ void CItem_DynamicResupply::CheckPVSThink( void ) //----------------------------------------------------------------------------- void CItem_DynamicResupply::InputKill( inputdata_t &data ) { +#ifdef MAPBASE + // What's the point of this being its own function? + m_OnKilled.FireOutput( data.pActivator, this ); +#endif + UTIL_Remove( this ); } @@ -345,7 +358,12 @@ void CItem_DynamicResupply::SpawnFullItem( CItem_DynamicResupply *pMaster, CBase // If we're supposed to fallback to just a health vial, do that and finish. if ( pMaster->HasSpawnFlags(SF_DYNAMICRESUPPLY_FALLBACK_TO_VIAL) ) { +#ifdef MAPBASE + CBaseEntity *pItem = CBaseEntity::Create("item_healthvial", GetAbsOrigin(), GetAbsAngles(), this); + m_OnItem.Set(pItem, pItem, this); +#else CBaseEntity::Create( "item_healthvial", GetAbsOrigin(), GetAbsAngles(), this ); +#endif if ( iDebug ) { @@ -364,7 +382,12 @@ void CItem_DynamicResupply::SpawnFullItem( CItem_DynamicResupply *pMaster, CBase { if ( flChoice <= flRatio[i] ) { +#ifdef MAPBASE + CBaseEntity *pItem = CBaseEntity::Create( g_DynamicResupplyAmmoItems[i].sEntityName, GetAbsOrigin(), GetAbsAngles(), this ); + m_OnItem.Set(pItem, pItem, this); +#else CBaseEntity::Create( g_DynamicResupplyAmmoItems[i].sEntityName, GetAbsOrigin(), GetAbsAngles(), this ); +#endif if ( iDebug ) { @@ -546,6 +569,10 @@ bool CItem_DynamicResupply::SpawnItemFromRatio( int nCount, DynamicResupplyItems pEnt->SetAbsVelocity( GetAbsVelocity() ); pEnt->SetLocalAngularVelocity( GetLocalAngularVelocity() ); +#ifdef MAPBASE + m_OnItem.Set(pEnt, pEnt, this); +#endif + // Move the entity up so that it doesn't go below the spawn origin Vector vecWorldMins, vecWorldMaxs; pEnt->CollisionProp()->WorldSpaceAABB( &vecWorldMins, &vecWorldMaxs ); @@ -654,4 +681,9 @@ void DynamicResupply_InitFromAlternateMaster( CBaseEntity *pTargetEnt, string_t memcpy( pTargetResupply->m_flDesiredHealth, pMasterResupply->m_flDesiredHealth, sizeof( pMasterResupply->m_flDesiredHealth ) ); memcpy( pTargetResupply->m_flDesiredAmmo, pMasterResupply->m_flDesiredAmmo, sizeof( pMasterResupply->m_flDesiredAmmo ) ); +#ifdef MAPBASE + if (pMasterResupply->HasSpawnFlags(SF_DYNAMICRESUPPLY_FALLBACK_TO_VIAL)) + pTargetResupply->AddSpawnFlags(SF_DYNAMICRESUPPLY_FALLBACK_TO_VIAL); +#endif + } \ No newline at end of file diff --git a/sp/src/game/server/hl2/item_healthkit.cpp b/sp/src/game/server/hl2/item_healthkit.cpp index 9a56ee98..e977c080 100644 --- a/sp/src/game/server/hl2/item_healthkit.cpp +++ b/sp/src/game/server/hl2/item_healthkit.cpp @@ -432,6 +432,17 @@ public: void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); virtual int ObjectCaps( void ) { return BaseClass::ObjectCaps() | m_iCaps; } +#ifdef MAPBASE + void InputRecharge( inputdata_t &inputdata ); + void InputSetCharge( inputdata_t &inputdata ); + void InputSetChargeNoMax( inputdata_t &inputdata ); + void UpdateJuice( int newJuice ); + float MaxJuice() const; + int SetInitialCharge( void ); + int m_iMaxJuice; + int m_iIncrementValue; +#endif + float m_flNextCharge; int m_iReactivate ; // DeathMatch Delay until reactvated int m_iJuice; @@ -442,6 +453,11 @@ public: int m_iCaps; COutputFloat m_OutRemainingHealth; +#ifdef MAPBASE + COutputEvent m_OnHalfEmpty; + COutputEvent m_OnEmpty; + COutputEvent m_OnFull; +#endif COutputEvent m_OnPlayerUse; void StudioFrameAdvance ( void ); @@ -458,12 +474,20 @@ BEGIN_DATADESC( CNewWallHealth ) DEFINE_FIELD( m_flNextCharge, FIELD_TIME), DEFINE_FIELD( m_iReactivate, FIELD_INTEGER), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_iJuice, FIELD_INTEGER, "Charge" ), +#else DEFINE_FIELD( m_iJuice, FIELD_INTEGER), +#endif DEFINE_FIELD( m_iOn, FIELD_INTEGER), DEFINE_FIELD( m_flSoundTime, FIELD_TIME), DEFINE_FIELD( m_nState, FIELD_INTEGER ), DEFINE_FIELD( m_iCaps, FIELD_INTEGER ), DEFINE_FIELD( m_flJuice, FIELD_FLOAT ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_iMaxJuice, FIELD_INTEGER, "MaxCharge" ), + DEFINE_INPUT( m_iIncrementValue, FIELD_INTEGER, "SetIncrementValue" ), +#endif // Function Pointers DEFINE_FUNCTION( Off ), @@ -471,6 +495,15 @@ BEGIN_DATADESC( CNewWallHealth ) DEFINE_OUTPUT( m_OnPlayerUse, "OnPlayerUse" ), DEFINE_OUTPUT( m_OutRemainingHealth, "OutRemainingHealth"), +#ifdef MAPBASE + DEFINE_OUTPUT(m_OnHalfEmpty, "OnHalfEmpty" ), + DEFINE_OUTPUT(m_OnEmpty, "OnEmpty" ), + DEFINE_OUTPUT(m_OnFull, "OnFull" ), + + DEFINE_INPUTFUNC( FIELD_VOID, "Recharge", InputRecharge ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetCharge", InputSetCharge ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetChargeNoMax", InputSetChargeNoMax ), +#endif END_DATADESC() @@ -479,6 +512,10 @@ END_DATADESC() #define CHARGES_PER_SECOND 1.0f / CHARGE_RATE #define CALLS_PER_SECOND 7.0f * CHARGES_PER_SECOND +#ifdef MAPBASE +#define CUSTOM_CHARGES_PER_SECOND(inc) inc / CHARGE_RATE +#endif + //----------------------------------------------------------------------------- // Purpose: @@ -503,6 +540,28 @@ bool CNewWallHealth::KeyValue( const char *szKeyName, const char *szValue ) return(BaseClass::KeyValue( szKeyName, szValue )); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +int CNewWallHealth::SetInitialCharge( void ) +{ + if ( m_iMaxJuice == 0 ) + { + m_iMaxJuice = sk_healthcharger.GetFloat(); + } + return m_iMaxJuice; +} + +//----------------------------------------------------------------------------- +// Max juice for recharger +//----------------------------------------------------------------------------- +float CNewWallHealth::MaxJuice() const +{ + return m_iMaxJuice; +} +#endif + //----------------------------------------------------------------------------- // Purpose: @@ -520,7 +579,22 @@ void CNewWallHealth::Spawn(void) ResetSequence( LookupSequence( "idle" ) ); +#ifdef MAPBASE + if (m_iIncrementValue == 0) + m_iIncrementValue = 1; + + int iMaxJuice = SetInitialCharge(); + + // In case the juice was overridden + if (m_iJuice == 0) + UpdateJuice( MaxJuice() ); + else if (m_iJuice == -1) + UpdateJuice( 0 ); + else + UpdateJuice( m_iJuice ); +#else m_iJuice = sk_healthcharger.GetFloat(); +#endif m_nState = 0; @@ -530,7 +604,11 @@ void CNewWallHealth::Spawn(void) CreateVPhysics(); m_flJuice = m_iJuice; +#ifdef MAPBASE + SetCycle( 1.0f - ( m_flJuice / iMaxJuice ) ); +#else SetCycle( 1.0f - ( m_flJuice / sk_healthcharger.GetFloat() ) ); +#endif } int CNewWallHealth::DrawDebugTextOverlays(void) @@ -572,7 +650,11 @@ void CNewWallHealth::StudioFrameAdvance( void ) { m_flPlaybackRate = 0; +#ifdef MAPBASE + float flMaxJuice = MaxJuice(); +#else float flMaxJuice = sk_healthcharger.GetFloat(); +#endif SetCycle( 1.0f - (float)( m_flJuice / flMaxJuice ) ); // Msg( "Cycle: %f - Juice: %d - m_flJuice :%f - Interval: %f\n", (float)GetCycle(), (int)m_iJuice, (float)m_flJuice, GetAnimTimeInterval() ); @@ -588,6 +670,62 @@ void CNewWallHealth::StudioFrameAdvance( void ) m_flAnimTime = gpGlobals->curtime; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +// Input : newJuice - +//----------------------------------------------------------------------------- +void CNewWallHealth::UpdateJuice( int newJuice ) +{ + bool reduced = newJuice < m_iJuice; + if ( reduced ) + { + // Fire 1/2 way output and/or empyt output + int oneHalfJuice = (int)(MaxJuice() * 0.5f); + if ( newJuice <= oneHalfJuice && m_iJuice > oneHalfJuice ) + { + m_OnHalfEmpty.FireOutput( this, this ); + } + + if ( newJuice <= 0 ) + { + m_OnEmpty.FireOutput( this, this ); + } + } + else if ( newJuice != m_iJuice && + newJuice == (int)MaxJuice() ) + { + m_OnFull.FireOutput( this, this ); + } + m_iJuice = newJuice; +} + +void CNewWallHealth::InputRecharge( inputdata_t &inputdata ) +{ + Recharge(); +} + +void CNewWallHealth::InputSetCharge( inputdata_t &inputdata ) +{ + ResetSequence( LookupSequence( "idle" ) ); + + int iJuice = inputdata.value.Int(); + + m_flJuice = m_iMaxJuice = m_iJuice = iJuice; + StudioFrameAdvance(); +} + +void CNewWallHealth::InputSetChargeNoMax( inputdata_t &inputdata ) +{ + ResetSequence( LookupSequence( "idle" ) ); + + m_flJuice = inputdata.value.Float(); + + UpdateJuice(m_flJuice); + StudioFrameAdvance(); +} +#endif + //----------------------------------------------------------------------------- // Purpose: // Input : *pActivator - @@ -614,6 +752,11 @@ void CNewWallHealth::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP float flCharges = CHARGES_PER_SECOND; float flCalls = CALLS_PER_SECOND; +#ifdef MAPBASE + if ( m_iIncrementValue != 0 ) + flCharges = CUSTOM_CHARGES_PER_SECOND(m_iIncrementValue); +#endif + m_flJuice -= flCharges / flCalls; StudioFrameAdvance(); } @@ -679,13 +822,24 @@ void CNewWallHealth::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP } // charge the player +#ifdef MAPBASE + if ( pActivator->TakeHealth( m_iIncrementValue, DMG_GENERIC ) ) + { + UpdateJuice(m_iJuice - m_iIncrementValue); + } +#else if ( pActivator->TakeHealth( 1, DMG_GENERIC ) ) { m_iJuice--; } +#endif // Send the output. +#ifdef MAPBASE + float flRemaining = m_iJuice / MaxJuice(); +#else float flRemaining = m_iJuice / sk_healthcharger.GetFloat(); +#endif m_OutRemainingHealth.Set(flRemaining, pActivator, this); // govern the rate of charge @@ -699,7 +853,12 @@ void CNewWallHealth::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP void CNewWallHealth::Recharge(void) { EmitSound( "WallHealth.Recharge" ); +#ifdef MAPBASE + UpdateJuice(MaxJuice()); + m_flJuice = m_iJuice; +#else m_flJuice = m_iJuice = sk_healthcharger.GetFloat(); +#endif m_nState = 0; ResetSequence( LookupSequence( "idle" ) ); diff --git a/sp/src/game/server/hl2/item_itemcrate.cpp b/sp/src/game/server/hl2/item_itemcrate.cpp index 20ee2ff7..6c5469fb 100644 --- a/sp/src/game/server/hl2/item_itemcrate.cpp +++ b/sp/src/game/server/hl2/item_itemcrate.cpp @@ -8,6 +8,9 @@ #include "props.h" #include "items.h" #include "item_dynamic_resupply.h" +#ifdef MAPBASE +#include "point_template.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -16,6 +19,9 @@ const char *pszItemCrateModelName[] = { "models/items/item_item_crate.mdl", "models/items/item_beacon_crate.mdl", +#ifdef MAPBASE + "models/items/item_item_crate.mdl", // Custom model placeholder/fallback, this should never be selected +#endif }; //----------------------------------------------------------------------------- @@ -39,14 +45,28 @@ public: virtual void VPhysicsCollision( int index, gamevcollisionevent_t *pEvent ); virtual void OnPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t reason ); +#ifdef MAPBASE + // Item crates always override prop data for custom models + bool OverridePropdata( void ) { return true; } +#endif + protected: virtual void OnBreak( const Vector &vecVelocity, const AngularImpulse &angVel, CBaseEntity *pBreaker ); +#ifdef MAPBASE + bool ShouldRandomizeAngles( CBaseEntity *pEnt ); + #define ITEM_ITEMCRATE_TEMPLATE_TARGET m_strAlternateMaster + CPointTemplate *FindTemplate(); +#endif + private: // Crate types. Add more! enum CrateType_t { CRATE_SPECIFIC_ITEM = 0, +#ifdef MAPBASE + CRATE_POINT_TEMPLATE, +#endif CRATE_TYPE_COUNT, }; @@ -54,6 +74,9 @@ private: { CRATE_APPEARANCE_DEFAULT = 0, CRATE_APPEARANCE_RADAR_BEACON, +#ifdef MAPBASE + CRATE_APPEARANCE_CUSTOM, +#endif }; private: @@ -64,6 +87,9 @@ private: CrateAppearance_t m_CrateAppearance; COutputEvent m_OnCacheInteraction; +#ifdef MAPBASE + COutputEHANDLE m_OnItem; +#endif }; @@ -82,6 +108,9 @@ BEGIN_DATADESC( CItem_ItemCrate ) DEFINE_KEYFIELD( m_CrateAppearance, FIELD_INTEGER, "CrateAppearance" ), DEFINE_INPUTFUNC( FIELD_VOID, "Kill", InputKill ), DEFINE_OUTPUT( m_OnCacheInteraction, "OnCacheInteraction" ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OnItem, "OnItem" ), +#endif END_DATADESC() @@ -92,8 +121,17 @@ END_DATADESC() void CItem_ItemCrate::Precache( void ) { // Set this here to quiet base prop warnings +#ifdef MAPBASE + // Set our model name here instead of in Spawn() so we could use custom crates. + if (m_CrateAppearance != CRATE_APPEARANCE_CUSTOM) + SetModelName(AllocPooledString(pszItemCrateModelName[m_CrateAppearance])); + + PrecacheModel( STRING(GetModelName()) ); + SetModel( STRING(GetModelName()) ); +#else PrecacheModel( pszItemCrateModelName[m_CrateAppearance] ); SetModel( pszItemCrateModelName[m_CrateAppearance] ); +#endif BaseClass::Precache(); if ( m_CrateType == CRATE_SPECIFIC_ITEM ) @@ -118,7 +156,9 @@ void CItem_ItemCrate::Spawn( void ) } DisableAutoFade(); +#ifndef MAPBASE SetModelName( AllocPooledString( pszItemCrateModelName[m_CrateAppearance] ) ); +#endif if ( NULL_STRING == m_strItemClass ) { @@ -128,7 +168,11 @@ void CItem_ItemCrate::Spawn( void ) } Precache( ); +#ifdef MAPBASE + SetModel( STRING(GetModelName()) ); +#else SetModel( pszItemCrateModelName[m_CrateAppearance] ); +#endif AddEFlags( EFL_NO_ROTORWASH_PUSH ); BaseClass::Spawn( ); } @@ -140,6 +184,12 @@ void CItem_ItemCrate::Spawn( void ) //----------------------------------------------------------------------------- void CItem_ItemCrate::InputKill( inputdata_t &data ) { +#ifdef MAPBASE + // Why is this its own function anyway? + // It just overwrites the death notice stuff. + m_OnKilled.FireOutput(data.pActivator, this); +#endif + UTIL_Remove( this ); } @@ -178,6 +228,34 @@ void CItem_ItemCrate::VPhysicsCollision( int index, gamevcollisionevent_t *pEven } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Finds the template for CRATE_POINT_TEMPLATE. +//----------------------------------------------------------------------------- +inline CPointTemplate *CItem_ItemCrate::FindTemplate() +{ + return dynamic_cast(gEntList.FindEntityByName( NULL, STRING(ITEM_ITEMCRATE_TEMPLATE_TARGET) )); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CItem_ItemCrate::ShouldRandomizeAngles( CBaseEntity *pEnt ) +{ + // Angles probably not supposed to be randomized. + if (m_CrateType == CRATE_POINT_TEMPLATE) + return false; + + // If we have only one NPC, it's probably supposed to spawn correctly. + // (if we have a bunch, it's probably a gag) + if (m_nItemCount == 1 && pEnt->IsNPC()) + return false; + + return true; +} +#endif + + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -189,7 +267,31 @@ void CItem_ItemCrate::OnBreak( const Vector &vecVelocity, const AngularImpulse & m_OnCacheInteraction.FireOutput(pBreaker,this); +#ifdef MAPBASE + int iCount = m_nItemCount; + CUtlVector hNewEntities; + CPointTemplate *pTemplate = FindTemplate(); + + if (m_CrateType == CRATE_POINT_TEMPLATE) + { + if (pTemplate && pTemplate->CreateInstance(GetLocalOrigin(), GetLocalAngles(), &hNewEntities)) + { + iCount = hNewEntities.Count() * m_nItemCount; + } + else + { + // This only runs if our template can't be found or its template instancing didn't work. + Warning("item_item_crate %s with CRATE_POINT_TEMPLATE couldn't find point_template %s! Falling back to CRATE_SPECIFIC_ITEM...\n", GetDebugName(), STRING(ITEM_ITEMCRATE_TEMPLATE_TARGET)); + m_CrateType = CRATE_SPECIFIC_ITEM; + } + } +#endif + +#ifdef MAPBASE + for ( int i = 0; i < iCount; i++ ) +#else for ( int i = 0; i < m_nItemCount; ++i ) +#endif { CBaseEntity *pSpawn = NULL; switch( m_CrateType ) @@ -198,6 +300,25 @@ void CItem_ItemCrate::OnBreak( const Vector &vecVelocity, const AngularImpulse & pSpawn = CreateEntityByName( STRING(m_strItemClass) ); break; +#ifdef MAPBASE + case CRATE_POINT_TEMPLATE: + { + if (i >= hNewEntities.Count()) + { + if (!pTemplate || !pTemplate->CreateInstance(GetLocalOrigin(), GetLocalAngles(), &hNewEntities)) + { + pSpawn = NULL; + i = iCount; + break; + } + + i = 0; + iCount -= hNewEntities.Count(); + } + pSpawn = hNewEntities[i]; + } break; +#endif + default: break; } @@ -205,6 +326,55 @@ void CItem_ItemCrate::OnBreak( const Vector &vecVelocity, const AngularImpulse & if ( !pSpawn ) return; +#ifdef MAPBASE + Vector vecOrigin; + CollisionProp()->RandomPointInBounds(Vector(0.25, 0.25, 0.25), Vector(0.75, 0.75, 0.75), &vecOrigin); + pSpawn->SetAbsOrigin(vecOrigin); + + if (ShouldRandomizeAngles(pSpawn)) + { + // Give a little randomness... + QAngle vecAngles; + vecAngles.x = random->RandomFloat(-20.0f, 20.0f); + vecAngles.y = random->RandomFloat(0.0f, 360.0f); + vecAngles.z = random->RandomFloat(-20.0f, 20.0f); + pSpawn->SetAbsAngles(vecAngles); + + Vector vecActualVelocity; + vecActualVelocity.Random(-10.0f, 10.0f); + // vecActualVelocity += vecVelocity; + pSpawn->SetAbsVelocity(vecActualVelocity); + + QAngle angVel; + AngularImpulseToQAngle(angImpulse, angVel); + pSpawn->SetLocalAngularVelocity(angVel); + } + else + { + // Only modify the Y value. + QAngle vecAngles; + vecAngles.x = 0; + vecAngles.y = GetLocalAngles().y; + vecAngles.z = 0; + pSpawn->SetAbsAngles(vecAngles); + } + + // We handle dynamic resupplies differently + bool bDynResup = FClassnameIs( pSpawn, "item_dynamic_resupply" ); + if (!bDynResup) + m_OnItem.Set(pSpawn, pSpawn, this); + else if (m_OnItem.NumberOfElements() > 0) + { + // This is here so it could fire OnItem for each item + CEventAction *ourlist = m_OnItem.GetActionList(); + char outputdata[256]; + for (CEventAction *ev = ourlist; ev != NULL; ev = ev->m_pNext) + { + Q_snprintf(outputdata, sizeof(outputdata), "%s,%s,%s,%f,%i", STRING(ev->m_iTarget), STRING(ev->m_iTargetInput), STRING(ev->m_iParameter), ev->m_flDelay, ev->m_nTimesToFire); + pSpawn->KeyValue("OnItem", outputdata); + } + } +#else // Give a little randomness... Vector vecOrigin; CollisionProp()->RandomPointInBounds( Vector(0.25, 0.25, 0.25), Vector( 0.75, 0.75, 0.75 ), &vecOrigin ); @@ -224,6 +394,7 @@ void CItem_ItemCrate::OnBreak( const Vector &vecVelocity, const AngularImpulse & QAngle angVel; AngularImpulseToQAngle( angImpulse, angVel ); pSpawn->SetLocalAngularVelocity( angVel ); +#endif // If we're creating an item, it can't be picked up until it comes to rest // But only if it wasn't broken by a vehicle @@ -236,7 +407,11 @@ void CItem_ItemCrate::OnBreak( const Vector &vecVelocity, const AngularImpulse & pSpawn->Spawn(); // Avoid missing items drops by a dynamic resupply because they don't think immediately +#ifdef MAPBASE + if (bDynResup) +#else if ( FClassnameIs( pSpawn, "item_dynamic_resupply" ) ) +#endif { if ( m_strAlternateMaster != NULL_STRING ) { diff --git a/sp/src/game/server/hl2/item_suit.cpp b/sp/src/game/server/hl2/item_suit.cpp index 5441234f..67d327b9 100644 --- a/sp/src/game/server/hl2/item_suit.cpp +++ b/sp/src/game/server/hl2/item_suit.cpp @@ -49,7 +49,11 @@ public: else UTIL_EmitSoundSuit(pPlayer->edict(), "!HEV_AAx"); // long version of suit logon +#ifdef MAPBASE + pPlayer->EquipSuit(!HasSpawnFlags(SF_SUIT_SHORTLOGON)); +#else pPlayer->EquipSuit(); +#endif return true; } diff --git a/sp/src/game/server/hl2/npc_BaseZombie.cpp b/sp/src/game/server/hl2/npc_BaseZombie.cpp index e7e5c6fc..316145ee 100644 --- a/sp/src/game/server/hl2/npc_BaseZombie.cpp +++ b/sp/src/game/server/hl2/npc_BaseZombie.cpp @@ -205,7 +205,11 @@ BEGIN_DATADESC( CNPC_BaseZombie ) DEFINE_SOUNDPATCH( m_pMoanSound ), DEFINE_FIELD( m_fIsTorso, FIELD_BOOLEAN ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_fIsHeadless, FIELD_BOOLEAN, "Headless" ), +#else DEFINE_FIELD( m_fIsHeadless, FIELD_BOOLEAN ), +#endif DEFINE_FIELD( m_flNextFlinch, FIELD_TIME ), DEFINE_FIELD( m_bHeadShot, FIELD_BOOLEAN ), DEFINE_FIELD( m_flBurnDamage, FIELD_FLOAT ), @@ -220,6 +224,10 @@ BEGIN_DATADESC( CNPC_BaseZombie ) DEFINE_FIELD( m_hObstructor, FIELD_EHANDLE ), DEFINE_FIELD( m_bIsSlumped, FIELD_BOOLEAN ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OnSwattedProp, "OnSwattedProp" ), +#endif + END_DATADESC() @@ -311,6 +319,12 @@ bool CNPC_BaseZombie::FindNearestPhysicsObject( int iMaxMass ) pEntity->VPhysicsGetObject()->IsAsleep() && pEntity->VPhysicsGetObject()->IsMoveable() ) { +#ifdef MAPBASE + // Don't swat props that don't want to be swatted + if (pEntity->HasSpawnFlags(SF_PHYSPROP_NO_ZOMBIE_SWAT) && dynamic_cast(pEntity)) + return ITERATION_CONTINUE; +#endif + return CFlaggedEntitiesEnum::EnumElement( pHandleEntity ); } return ITERATION_CONTINUE; @@ -716,6 +730,11 @@ bool CNPC_BaseZombie::ShouldBecomeTorso( const CTakeDamageInfo &info, float flDa if ( info.GetDamageType() & DMG_REMOVENORAGDOLL ) return false; +#ifdef MAPBASE + if ( HasSpawnFlags(SF_ZOMBIE_NO_TORSO) ) + return false; +#endif + if ( m_fIsTorso ) { // Already split. @@ -761,7 +780,11 @@ bool CNPC_BaseZombie::ShouldBecomeTorso( const CTakeDamageInfo &info, float flDa //----------------------------------------------------------------------------- HeadcrabRelease_t CNPC_BaseZombie::ShouldReleaseHeadcrab( const CTakeDamageInfo &info, float flDamageThreshold ) { +#ifdef MAPBASE + if ( m_iHealth <= 0 && !m_fIsHeadless ) +#else if ( m_iHealth <= 0 ) +#endif { if ( info.GetDamageType() & DMG_REMOVENORAGDOLL ) return RELEASE_NO; @@ -853,7 +876,11 @@ int CNPC_BaseZombie::OnTakeDamage_Alive( const CTakeDamageInfo &inputInfo ) bool bSquashed = IsSquashed(info); bool bKilledByVehicle = ( ( info.GetDamageType() & DMG_VEHICLE ) != 0 ); +#ifdef MAPBASE + if ( !m_fIsTorso && (bChopped || bSquashed) && !bKilledByVehicle && !(info.GetDamageType() & DMG_REMOVENORAGDOLL) && !HasSpawnFlags(SF_ZOMBIE_NO_TORSO) ) +#else if( !m_fIsTorso && (bChopped || bSquashed) && !bKilledByVehicle && !(info.GetDamageType() & DMG_REMOVENORAGDOLL) ) +#endif { if( bChopped ) { @@ -1082,6 +1109,14 @@ void CNPC_BaseZombie::DieChopped( const CTakeDamageInfo &info ) } } +#ifdef MAPBASE + // Hack for fast zombies using base torso rules. + if (m_iHealth > 0) + { + SetHealth( 0 ); + } +#endif + float flFadeTime = 0.0; if( HasSpawnFlags( SF_NPC_FADE_CORPSE ) ) @@ -1559,6 +1594,10 @@ void CNPC_BaseZombie::HandleAnimEvent( animevent_t *pEvent ) pPhysObj->AddVelocity( &v, &angVelocity ); +#ifdef MAPBASE + m_OnSwattedProp.Set(pPhysicsEntity, pPhysicsEntity, this); +#endif + // If we don't put the object scan time well into the future, the zombie // will re-select the object he just hit as it is flying away from him. // It will likely always be the nearest object because the zombie moved diff --git a/sp/src/game/server/hl2/npc_BaseZombie.h b/sp/src/game/server/hl2/npc_BaseZombie.h index d4800f3c..2934fcb9 100644 --- a/sp/src/game/server/hl2/npc_BaseZombie.h +++ b/sp/src/game/server/hl2/npc_BaseZombie.h @@ -42,6 +42,10 @@ extern int AE_ZOMBIE_POUND; #define ZOMBIE_BLOOD_RIGHT_HAND 1 #define ZOMBIE_BLOOD_BOTH_HANDS 2 #define ZOMBIE_BLOOD_BITE 3 + +#ifdef MAPBASE +#define SF_ZOMBIE_NO_TORSO ( 1 << 15 ) +#endif enum HeadcrabRelease_t @@ -259,6 +263,9 @@ protected: float m_flBurnDamageResetTime; // Time at which we reset the burn damage. EHANDLE m_hPhysicsEnt; +#ifdef MAPBASE + COutputEHANDLE m_OnSwattedProp; +#endif float m_flNextMoanSound; float m_flNextSwat; diff --git a/sp/src/game/server/hl2/npc_PoisonZombie.cpp b/sp/src/game/server/hl2/npc_PoisonZombie.cpp index eafebe2d..1611e15b 100644 --- a/sp/src/game/server/hl2/npc_PoisonZombie.cpp +++ b/sp/src/game/server/hl2/npc_PoisonZombie.cpp @@ -285,7 +285,11 @@ void CNPC_PoisonZombie::Spawn( void ) { Precache(); +#ifndef MAPBASE // Controlled by KV m_fIsTorso = m_fIsHeadless = false; +#else + m_fIsTorso = false; +#endif #ifdef HL2_EPISODIC SetBloodColor( BLOOD_COLOR_ZOMBIE ); @@ -632,10 +636,16 @@ void CNPC_PoisonZombie::BreatheOffShort( void ) { if ( m_bNearEnemy ) { +#ifdef MAPBASE + if (m_pFastBreathSound) +#endif ENVELOPE_CONTROLLER.SoundPlayEnvelope( m_pFastBreathSound, SOUNDCTRL_CHANGE_VOLUME, envPoisonZombieBreatheVolumeOffShort, ARRAYSIZE(envPoisonZombieBreatheVolumeOffShort) ); } else { +#ifdef MAPBASE + if (m_pSlowBreathSound) +#endif ENVELOPE_CONTROLLER.SoundPlayEnvelope( m_pSlowBreathSound, SOUNDCTRL_CHANGE_VOLUME, envPoisonZombieBreatheVolumeOffShort, ARRAYSIZE(envPoisonZombieBreatheVolumeOffShort) ); } } diff --git a/sp/src/game/server/hl2/npc_alyx.h b/sp/src/game/server/hl2/npc_alyx.h index 96c1c917..551460b2 100644 --- a/sp/src/game/server/hl2/npc_alyx.h +++ b/sp/src/game/server/hl2/npc_alyx.h @@ -31,6 +31,13 @@ public: bool IsReadinessCapable() { return false; } void DeathSound( const CTakeDamageInfo &info ); +#ifdef MAPBASE + // Alyx was never meant to automatically unholster her weapon in non-episodic Half-Life 2. + // Now that all allies can holster/unholster, this is a precaution in case it breaks anything. + // Try OnFoundEnemy > UnholsterWeapon if you want Alyx to automatically unholster in non-episodic HL2 maps. + bool CanUnholsterWeapon() { return false; } +#endif + EHANDLE m_hEmpTool; DECLARE_DATADESC(); diff --git a/sp/src/game/server/hl2/npc_alyx_episodic.cpp b/sp/src/game/server/hl2/npc_alyx_episodic.cpp index e98c89f5..f512411f 100644 --- a/sp/src/game/server/hl2/npc_alyx_episodic.cpp +++ b/sp/src/game/server/hl2/npc_alyx_episodic.cpp @@ -36,6 +36,9 @@ #include "ai_interactions.h" #include "weapon_flaregun.h" #include "env_debughistory.h" +#ifdef MAPBASE +#include "mapbase/GlobalStrings.h" +#endif extern Vector PointOnLineNearestPoint(const Vector& vStartPos, const Vector& vEndPos, const Vector& vPoint); @@ -136,14 +139,21 @@ END_DATADESC() static int AE_ALYX_EMPTOOL_ATTACHMENT; static int AE_ALYX_EMPTOOL_SEQUENCE; static int AE_ALYX_EMPTOOL_USE; +#ifndef MAPBASE static int COMBINE_AE_BEGIN_ALTFIRE; static int COMBINE_AE_ALTFIRE; +#endif ConVar npc_alyx_readiness( "npc_alyx_readiness", "1" ); ConVar npc_alyx_force_stop_moving( "npc_alyx_force_stop_moving", "1" ); ConVar npc_alyx_readiness_transitions( "npc_alyx_readiness_transitions", "1" ); ConVar npc_alyx_crouch( "npc_alyx_crouch", "1" ); +#ifdef MAPBASE +ConVar npc_alyx_interact_manhacks( "npc_alyx_interact_manhacks", "1" ); +ConVar npc_alyx_interact_turrets( "npc_alyx_interact_turrets", "0" ); +#endif + // global pointer to Alyx for fast lookups CEntityClassList g_AlyxList; template <> CNPC_Alyx *CEntityClassList::m_pClassList = NULL; @@ -264,6 +274,7 @@ void CNPC_Alyx::HandleAnimEvent( animevent_t *pEvent ) } return; } +#ifndef MAPBASE else if ( pEvent->event == COMBINE_AE_BEGIN_ALTFIRE ) { EmitSound( "Weapon_CombineGuard.Special1" ); @@ -280,6 +291,7 @@ void CNPC_Alyx::HandleAnimEvent( animevent_t *pEvent ) return; } +#endif switch( pEvent->event ) { @@ -379,9 +391,15 @@ void CNPC_Alyx::Precache() UTIL_PrecacheOther( "env_alyxemp" ); CLASSNAME_ALYXGUN = AllocPooledString( "weapon_alyxgun" ); +#ifdef MAPBASE + CLASSNAME_SMG1 = gm_iszSMG1Classname; + CLASSNAME_SHOTGUN = gm_iszShotgunClassname; + CLASSNAME_AR2 = gm_iszAR2Classname; +#else CLASSNAME_SMG1 = AllocPooledString( "weapon_smg1" ); CLASSNAME_SHOTGUN = AllocPooledString( "weapon_shotgun" ); CLASSNAME_AR2 = AllocPooledString( "weapon_ar2" ); +#endif } //----------------------------------------------------------------------------- @@ -426,6 +444,19 @@ void CNPC_Alyx::Activate( void ) { g_HackOutland10DamageHack = true; } + +#ifdef MAPBASE + // Please, this is not the worst hack you've caught me doing. + for ( int i = 0; i < m_ScriptedInteractions.Count(); i++ ) + { + ScriptedNPCInteraction_t *pInteraction = &m_ScriptedInteractions[i]; + + if (pInteraction->iszMyWeapon == CLASSNAME_ALYXGUN) + pInteraction->iszMyWeapon = AllocPooledString("WEPCLASS_HANDGUN"); + else if (pInteraction->iszMyWeapon == CLASSNAME_SHOTGUN) + pInteraction->iszMyWeapon = AllocPooledString("!=WEPCLASS_HANDGUN"); + } +#endif } //----------------------------------------------------------------------------- @@ -612,11 +643,13 @@ void CNPC_Alyx::PrescheduleThink( void ) } } +#ifndef MAPBASE // See CAI_BaseNPC // If Alyx is in combat, and she doesn't have her gun out, fetch it if ( GetState() == NPC_STATE_COMBAT && IsWeaponHolstered() && !m_FuncTankBehavior.IsRunning() ) { SetDesiredWeaponState( DESIREDWEAPONSTATE_UNHOLSTERED ); } +#endif // If we're in stealth mode, and we can still see the stealth node, keep using it if ( GetReadinessLevel() == AIRL_STEALTH ) @@ -759,11 +792,12 @@ void CNPC_Alyx::GatherConditions() } } - +#ifndef MAPBASE // Moved to CNPC_PlayerCompanion if ( m_NPCState == NPC_STATE_COMBAT ) { DoCustomCombatAI(); } +#endif if( HasInteractTarget() ) { @@ -928,7 +962,12 @@ bool CNPC_Alyx::IsValidEnemy( CBaseEntity *pEnemy ) return false; } +#ifdef MAPBASE + // Come to the defense of anyone we like, not just ourselves or the player. + if( pEnemy->GetEnemy() != this && IRelationType(pEnemy->GetEnemy()) == D_LI ) +#else if( pEnemy->GetEnemy() != this && !pEnemy->GetEnemy()->IsPlayer() ) +#endif { return false; } @@ -991,7 +1030,12 @@ void CNPC_Alyx::Event_KilledOther( CBaseEntity *pVictim, const CTakeDamageInfo & return; } +#ifdef MAPBASE + // Don't do the custom target thing against dissolve or blast damage (Alyx can do that with companion grenades/balls) + if( !HasShotgun() && !(info.GetDamageType() & (DMG_DISSOLVE | DMG_BLAST)) ) +#else if( !HasShotgun() ) +#endif { CAI_BaseNPC *pTarget = CreateCustomTarget( pVictim->GetAbsOrigin(), 2.0f ); @@ -1849,6 +1893,29 @@ int CNPC_Alyx::TranslateSchedule( int scheduleType ) //Warning("CROUCH: Standing, no enemy.\n" ); Stand(); } + +#ifdef MAPBASE + // This stuff was ported from npc_playercompanion to help Alyx use grenades. + if (HasGrenades() && !IsCrouching()) + { + if (CanAltFireEnemy( true ) && OccupyStrategySlot( SQUAD_SLOT_SPECIAL_ATTACK )) + { + return SCHED_PC_AR2_ALTFIRE; + } + + if ( !OccupyStrategySlotRange( SQUAD_SLOT_ATTACK1, SQUAD_SLOT_ATTACK2 ) ) + { + // Try throwing a grenade if Alyx is in a squad that already has attacking well in hand. + if ( CanGrenadeEnemy() ) + { + if ( OccupyStrategySlot( SQUAD_SLOT_SPECIAL_ATTACK ) ) + { + return SCHED_RANGE_ATTACK2; + } + } + } + } +#endif } return SCHED_ALYX_RANGE_ATTACK1; @@ -2941,7 +3008,12 @@ bool CNPC_Alyx::Crouch( void ) return false; // Alyx will ignore crouch requests while she has the shotgun +#ifdef MAPBASE + // Alyx will ignore crouch requests from anything that isn't a "pistol", e.g. her Alyx gun. + if ( GetActiveWeapon() && GetActiveWeapon()->WeaponClassify() != WEPCLASS_HANDGUN ) +#else if ( HasShotgun() ) +#endif return false; bool bWasStanding = !IsCrouching(); @@ -2974,9 +3046,13 @@ void CNPC_Alyx::DesireCrouch( void ) //----------------------------------------------------------------------------- void CNPC_Alyx::ModifyOrAppendCriteria( AI_CriteriaSet &set ) { +#ifdef MAPBASE + float fLengthOfLastCombat; +#else AIEnemiesIter_t iter; float fLengthOfLastCombat; int iNumEnemies; +#endif if ( GetState() == NPC_STATE_COMBAT ) { @@ -2989,6 +3065,7 @@ void CNPC_Alyx::ModifyOrAppendCriteria( AI_CriteriaSet &set ) set.AppendCriteria( "combat_length", UTIL_VarArgs( "%.3f", fLengthOfLastCombat ) ); +#ifndef MAPBASE // Moved to CNPC_PlayerCompanion iNumEnemies = 0; for ( AI_EnemyInfo_t *pEMemory = GetEnemies()->GetFirst(&iter); pEMemory != NULL; pEMemory = GetEnemies()->GetNext(&iter) ) { @@ -2998,6 +3075,7 @@ void CNPC_Alyx::ModifyOrAppendCriteria( AI_CriteriaSet &set ) } } set.AppendCriteria( "num_enemies", UTIL_VarArgs( "%d", iNumEnemies ) ); +#endif set.AppendCriteria( "darkness_mode", UTIL_VarArgs( "%d", HasCondition( COND_ALYX_IN_DARK ) ) ); set.AppendCriteria( "water_level", UTIL_VarArgs( "%d", GetWaterLevel() ) ); @@ -3324,8 +3402,10 @@ AI_BEGIN_CUSTOM_NPC( npc_alyx, CNPC_Alyx ) DECLARE_ANIMEVENT( AE_ALYX_EMPTOOL_ATTACHMENT ) DECLARE_ANIMEVENT( AE_ALYX_EMPTOOL_SEQUENCE ) DECLARE_ANIMEVENT( AE_ALYX_EMPTOOL_USE ) +#ifndef MAPBASE DECLARE_ANIMEVENT( COMBINE_AE_BEGIN_ALTFIRE ) DECLARE_ANIMEVENT( COMBINE_AE_ALTFIRE ) +#endif DECLARE_CONDITION( COND_ALYX_HAS_INTERACT_TARGET ) DECLARE_CONDITION( COND_ALYX_NO_INTERACT_TARGET ) diff --git a/sp/src/game/server/hl2/npc_alyx_episodic.h b/sp/src/game/server/hl2/npc_alyx_episodic.h index 5657dae7..9e72fd8d 100644 --- a/sp/src/game/server/hl2/npc_alyx_episodic.h +++ b/sp/src/game/server/hl2/npc_alyx_episodic.h @@ -54,6 +54,11 @@ public: bool OnBeginMoveAndShoot(); void SpeakAttacking( void ); +#ifdef MAPBASE + // This skips CAI_PlayerAlly's CanFlinch() function since Episodic Alyx can flinch to begin with. + virtual bool CanFlinch( void ) { return CAI_BaseActor::CanFlinch(); } +#endif + virtual float GetJumpGravity() const { return 1.8f; } // Crouching diff --git a/sp/src/game/server/hl2/npc_antlion.cpp b/sp/src/game/server/hl2/npc_antlion.cpp index 8cb7f789..d94c658d 100644 --- a/sp/src/game/server/hl2/npc_antlion.cpp +++ b/sp/src/game/server/hl2/npc_antlion.cpp @@ -247,6 +247,9 @@ BEGIN_DATADESC( CNPC_Antlion ) DEFINE_INPUTFUNC( FIELD_VOID, "IgnoreBugbait", InputIgnoreBugbait ), DEFINE_INPUTFUNC( FIELD_VOID, "HearBugbait", InputHearBugbait ), DEFINE_INPUTFUNC( FIELD_STRING, "JumpAtTarget", InputJumpAtTarget ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_STRING, "SetFollowTarget", InputSetFollowTarget ), +#endif DEFINE_OUTPUT( m_OnReachFightGoal, "OnReachedFightGoal" ), DEFINE_OUTPUT( m_OnUnBurrowed, "OnUnBurrowed" ), @@ -361,6 +364,43 @@ void CNPC_Antlion::Spawn( void ) BaseClass::Spawn(); m_nSkin = random->RandomInt( 0, ANTLION_SKIN_COUNT-1 ); + +#if defined(MAPBASE) && defined(HL2_EPISODIC) + // Implement dynamic interactions here since we can't recompile the model + if (GetModelPtr()) + { + ScriptedNPCInteraction_t sInteraction01; + sInteraction01.iszInteractionName = AllocPooledString( "antlion_v_soldier_01" ); + sInteraction01.sPhases[SNPCINT_SEQUENCE].iszSequence = AllocPooledString( "antlion_soldier_DI_01" ); + + sInteraction01.vecRelativeOrigin = Vector(224, 0, 0); + sInteraction01.angRelativeAngles = QAngle(0, 180, 0); + //sInteraction01.iFlags |= SCNPC_FLAG_TEST_OTHER_ANGLES; + sInteraction01.iFlags |= SCNPC_FLAG_TEST_END_POSITION; + sInteraction01.vecRelativeEndPos = Vector(312, -10, 0); + sInteraction01.iTriggerMethod = SNPCINT_AUTOMATIC_IN_COMBAT; + sInteraction01.flDelay = 15.0f; + sInteraction01.iFlags |= SCNPC_FLAG_MAPBASE_ADDITION; + sInteraction01.flDistSqr = (8 * 8); + + + ScriptedNPCInteraction_t sInteraction02; + sInteraction02.iszInteractionName = AllocPooledString( "antlion_v_soldier_02" ); + sInteraction02.sPhases[SNPCINT_SEQUENCE].iszSequence = AllocPooledString( "antlion_soldier_DI_02" ); + + sInteraction02.vecRelativeOrigin = Vector(64, 0, 0); + sInteraction02.angRelativeAngles = QAngle(0, 180, 0); + //sInteraction01.iFlags |= SCNPC_FLAG_TEST_OTHER_ANGLES; + sInteraction02.iTriggerMethod = SNPCINT_AUTOMATIC_IN_COMBAT; + sInteraction02.flDelay = 7.5f; + sInteraction02.iFlags |= SCNPC_FLAG_MAPBASE_ADDITION; + sInteraction02.flDistSqr = (8 * 8); + + + AddScriptedNPCInteraction(&sInteraction01); + AddScriptedNPCInteraction(&sInteraction02); + } +#endif } //----------------------------------------------------------------------------- @@ -657,7 +697,11 @@ void CNPC_Antlion::MeleeAttack( float distance, float damage, QAngle &viewPunch, vecForceDir = ( pHurt->WorldSpaceCenter() - WorldSpaceCenter() ); //FIXME: Until the interaction is setup, kill combine soldiers in one hit -- jdw +#ifdef MAPBASE + if ( pHurt->Classify() == CLASS_COMBINE && FClassnameIs( pHurt, "npc_combine_s" ) && GlobalEntity_GetState("antlion_noinstakill") != GLOBAL_ON ) +#else if ( FClassnameIs( pHurt, "npc_combine_s" ) ) +#endif { CTakeDamageInfo dmgInfo( this, this, pHurt->m_iHealth+25, DMG_SLASH ); CalculateMeleeDamageForce( &dmgInfo, vecForceDir, pHurt->GetAbsOrigin() ); @@ -2465,6 +2509,38 @@ int CNPC_Antlion::SelectSchedule( void ) return SCHED_ANTLION_WORKER_RANGE_ATTACK1; } } + +#ifdef MAPBASE + // "Nemesis" is assigned to enemies we hate with 10+ priority. + // Since bugbait targets are given 99 priority, this means the AI here usually only applies + // when the antlion worker is following bugbait. + // + // This is just so antlion workers are more potent when commanded by bugbait, + // which wasn't explored in the official games, but may be used in HL2 mods. + if ( m_hFollowTarget && IsAllied() /*HasCondition( COND_SEE_NEMESIS )*/ ) + { + // Establish LOF if we can't see the enemy + if ( HasCondition( COND_ENEMY_OCCLUDED ) ) + return SCHED_ESTABLISH_LINE_OF_FIRE; + + // See if we need to destroy breakable cover + if ( HasCondition( COND_WEAPON_SIGHT_OCCLUDED ) ) + return SCHED_SHOOT_ENEMY_COVER; + + // Just face as usual if we're not too close to attack, + // otherwise fall back to base class and charge like any other antlion + if ( !HasCondition( COND_TOO_CLOSE_TO_ATTACK ) ) + { + // Run around randomly if our target is looking in our direction + if ( HasCondition( COND_BEHIND_ENEMY ) == false ) + return SCHED_ANTLION_WORKER_RUN_RANDOM; + + return SCHED_COMBAT_FACE; + } + } + else + { +#endif // Back up, we're too near an enemy or can't see them if ( HasCondition( COND_TOO_CLOSE_TO_ATTACK ) || HasCondition( COND_ENEMY_OCCLUDED ) ) @@ -2480,6 +2556,9 @@ int CNPC_Antlion::SelectSchedule( void ) // Face our target and continue to fire return SCHED_COMBAT_FACE; +#ifdef MAPBASE + } +#endif } else { @@ -2887,7 +2966,11 @@ int CNPC_Antlion::MeleeAttack1Conditions( float flDot, float flDist ) AI_TraceHull( WorldSpaceCenter(), GetEnemy()->WorldSpaceCenter(), -Vector(8,8,8), Vector(8,8,8), MASK_NPCSOLID, this, COLLISION_GROUP_NONE, &tr ); // If the hit entity isn't our target and we don't hate it, don't hit it +#ifdef MAPBASE + if ( tr.m_pEnt != GetEnemy() && tr.fraction < 1.0f && IRelationType( tr.m_pEnt ) > D_FR ) +#else if ( tr.m_pEnt != GetEnemy() && tr.fraction < 1.0f && IRelationType( tr.m_pEnt ) != D_HT ) +#endif return 0; #else @@ -4224,6 +4307,25 @@ void CNPC_Antlion::SetFollowTarget( CBaseEntity *pTarget ) } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CNPC_Antlion::InputSetFollowTarget( inputdata_t &inputdata ) +{ + if ( IsAlive() == false ) + return; + + CBaseEntity *pEntity = gEntList.FindEntityByName( NULL, inputdata.value.String(), NULL, inputdata.pActivator, inputdata.pCaller ); + + if ( pEntity != NULL ) + { + SetFollowTarget( pEntity ); + } +} +#endif + //----------------------------------------------------------------------------- // Purpose: // Output : Returns true on success, false on failure. @@ -4438,7 +4540,15 @@ bool CNPC_Antlion::IsHeavyDamage( const CTakeDamageInfo &info ) bool CNPC_Antlion::CanRunAScriptedNPCInteraction( bool bForced /*= false*/ ) { // Workers shouldn't do DSS's because they explode +#ifdef MAPBASE + // Now that antlions have their DI restored, one might want workers to use them as well. + // Forced interactions are allowed now, but I went a step further and enabling dynamic interactions + // will disregard this check. This will allow vortigaunts to use dangerous melee interactions with workers, + // but if you're concerned about that just turn the antlion's interactions off. + if ( IsWorker() && !bForced && m_iDynamicInteractionsAllowed != TRS_TRUE ) +#else if ( IsWorker() ) +#endif return false; return BaseClass::CanRunAScriptedNPCInteraction( bForced ); diff --git a/sp/src/game/server/hl2/npc_antlion.h b/sp/src/game/server/hl2/npc_antlion.h index 1de36066..dd26ec2a 100644 --- a/sp/src/game/server/hl2/npc_antlion.h +++ b/sp/src/game/server/hl2/npc_antlion.h @@ -143,6 +143,9 @@ public: void InputJumpAtTarget( inputdata_t &inputdata ); void SetFollowTarget( CBaseEntity *pTarget ); +#ifdef MAPBASE + void InputSetFollowTarget( inputdata_t &inputdata ); +#endif int TranslateSchedule( int scheduleType ); virtual Activity NPC_TranslateActivity( Activity baseAct ); diff --git a/sp/src/game/server/hl2/npc_antliongrub.cpp b/sp/src/game/server/hl2/npc_antliongrub.cpp index 16ee2ed5..7e9ef2d0 100644 --- a/sp/src/game/server/hl2/npc_antliongrub.cpp +++ b/sp/src/game/server/hl2/npc_antliongrub.cpp @@ -15,6 +15,9 @@ #include "items.h" #include "item_dynamic_resupply.h" #include "npc_vortigaunt_episodic.h" +#ifdef MAPBASE +#include "filters.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -659,6 +662,16 @@ void CAntlionGrub::GrubTouch( CBaseEntity *pOther ) IPhysicsObject *pPhysOther = pOther->VPhysicsGetObject(); // bool bThrown = ( pTarget->VPhysicsGetObject()->GetGameFlags() & FVPHYSICS_WAS_THROWN ) != 0; if ( pOther->IsPlayer() || FClassnameIs(pOther,"npc_vortigaunt") || ( pPhysOther && (pPhysOther->GetGameFlags() & FVPHYSICS_WAS_THROWN )) ) { +#ifdef MAPBASE + if (m_hDamageFilter) + { + // Don't squash if they don't pass our damage filter + CBaseFilter *pFilter = static_cast(m_hDamageFilter.Get()); + if (pFilter && !pFilter->PassesFilter(this, pOther)) + return; + } +#endif + m_OnAgitated.FireOutput( pOther, pOther ); Squash( pOther, true, true ); } diff --git a/sp/src/game/server/hl2/npc_antlionguard.cpp b/sp/src/game/server/hl2/npc_antlionguard.cpp index 9ed2eff4..a571e1e2 100644 --- a/sp/src/game/server/hl2/npc_antlionguard.cpp +++ b/sp/src/game/server/hl2/npc_antlionguard.cpp @@ -1573,7 +1573,11 @@ public: if ( pVictimBCC ) { // Can only damage other NPCs that we hate +#ifdef MAPBASE + if ( m_pAttacker->IRelationType( pEntity ) <= D_FR ) +#else if ( m_pAttacker->IRelationType( pEntity ) == D_HT ) +#endif { pEntity->TakeDamage( info ); return true; @@ -2729,7 +2733,11 @@ bool CNPC_AntlionGuard::HandleChargeImpact( Vector vecImpact, CBaseEntity *pEnti } // Hit anything we don't like +#ifdef MAPBASE + if ( IRelationType( pEntity ) <= D_FR && ( GetNextAttack() < gpGlobals->curtime ) ) +#else if ( IRelationType( pEntity ) == D_HT && ( GetNextAttack() < gpGlobals->curtime ) ) +#endif { EmitSound( "NPC_AntlionGuard.Shove" ); diff --git a/sp/src/game/server/hl2/npc_attackchopper.cpp b/sp/src/game/server/hl2/npc_attackchopper.cpp index 0687c915..f91128ae 100644 --- a/sp/src/game/server/hl2/npc_attackchopper.cpp +++ b/sp/src/game/server/hl2/npc_attackchopper.cpp @@ -347,6 +347,10 @@ protected: void CollisionCallback( CHelicopterChunk *pCaller ); +#ifdef MAPBASE + void InputFallApart( inputdata_t &inputdata ); +#endif + void FallThink( void ); bool m_bLanded; @@ -760,8 +764,13 @@ private: CSoundPatch *m_pGunFiringSound; // Outputs +#ifndef MAPBASE COutputInt m_OnHealthChanged; +#endif COutputEvent m_OnShotDown; +#ifdef MAPBASE + COutputEHANDLE m_OutBomb; +#endif // Crashing EHANDLE m_hCrashPoint; @@ -842,6 +851,10 @@ BEGIN_DATADESC( CNPC_AttackHelicopter ) DEFINE_KEYFIELD( m_flMaxSpeed, FIELD_FLOAT, "PatrolSpeed" ), DEFINE_KEYFIELD( m_bNonCombat, FIELD_BOOLEAN, "NonCombat" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_flFieldOfView, FIELD_FLOAT, "FieldOfView" ), +#endif + DEFINE_FIELD( m_hCrashPoint, FIELD_EHANDLE ), DEFINE_INPUTFUNC( FIELD_VOID, "ResetIdleTime", InputResetIdleTime ), @@ -866,7 +879,9 @@ BEGIN_DATADESC( CNPC_AttackHelicopter ) DEFINE_INPUTFUNC( FIELD_VOID, "StartContinuousShooting", InputStartContinuousShooting ), DEFINE_INPUTFUNC( FIELD_VOID, "StartFastShooting", InputStartFastShooting ), DEFINE_INPUTFUNC( FIELD_VOID, "GunOff", InputGunOff ), +#ifndef MAPBASE // This has been added to all NPCs. npc_helicopter overrides it with its original function, but the datadesc entry isn't needed anymore. DEFINE_INPUTFUNC( FIELD_FLOAT, "SetHealthFraction", InputSetHealthFraction ), +#endif DEFINE_INPUTFUNC( FIELD_VOID, "StartBombExplodeOnContact", InputStartBombExplodeOnContact ), DEFINE_INPUTFUNC( FIELD_VOID, "StopBombExplodeOnContact", InputStopBombExplodeOnContact ), @@ -878,8 +893,13 @@ BEGIN_DATADESC( CNPC_AttackHelicopter ) DEFINE_THINKFUNC( BlinkLightsThink ), DEFINE_THINKFUNC( SpotlightThink ), +#ifndef MAPBASE DEFINE_OUTPUT( m_OnHealthChanged, "OnHealthChanged" ), +#endif DEFINE_OUTPUT( m_OnShotDown, "OnShotDown" ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OutBomb, "OutBomb" ), +#endif END_DATADESC() @@ -893,6 +913,9 @@ CNPC_AttackHelicopter::CNPC_AttackHelicopter() : m_bBombsExplodeOnContact( false ) { m_flMaxSpeed = 0; +#ifdef MAPBASE + m_flFieldOfView = -1.0; // 360 degrees +#endif } CNPC_AttackHelicopter::~CNPC_AttackHelicopter(void) @@ -937,6 +960,13 @@ void CNPC_AttackHelicopter::Precache( void ) { BaseClass::Precache(); +#ifdef MAPBASE + if ( GetModelName() != NULL_STRING ) + { + PrecacheModel( STRING(GetModelName()) ); + } + else +#endif if ( !HasSpawnFlags(SF_HELICOPTER_ELECTRICAL_DRONE) ) { PrecacheModel( CHOPPER_MODEL_NAME ); @@ -1038,6 +1068,13 @@ void CNPC_AttackHelicopter::Spawn( void ) m_bBombingSuppressed = false; m_bIgnorePathVisibilityTests = false; +#ifdef MAPBASE + if ( GetModelName() != NULL_STRING ) + { + SetModel( STRING(GetModelName()) ); + } + else +#endif if ( !HasSpawnFlags(SF_HELICOPTER_ELECTRICAL_DRONE) ) { SetModel( CHOPPER_MODEL_NAME ); @@ -1070,6 +1107,11 @@ void CNPC_AttackHelicopter::Spawn( void ) SetPauseState( PAUSE_NO_PAUSE ); +#ifdef MAPBASE + if (m_iHealth != 0) + m_iMaxHealth = m_iHealth; + else +#endif m_iMaxHealth = m_iHealth = sk_helicopter_health.GetInt(); m_flMaxSpeed = flLoadedSpeed; @@ -1081,7 +1123,9 @@ void CNPC_AttackHelicopter::Spawn( void ) m_nGrenadeCount = CHOPPER_BOMB_DROP_COUNT; +#ifndef MAPBASE // Moved to constructor because this is a keyvalue now m_flFieldOfView = -1.0; // 360 degrees +#endif m_flIdleTimeDelay = 0.0f; m_iAmmoType = GetAmmoDef()->Index("HelicopterGun"); @@ -2790,6 +2834,10 @@ CGrenadeHelicopter *CNPC_AttackHelicopter::SpawnBombEntity( const Vector &vecPos } #endif // HL2_EPISODIC +#ifdef MAPBASE + m_OutBomb.Set(pGrenade, pGrenade, this); +#endif + return pGrenade; } @@ -3475,9 +3523,16 @@ void CNPC_AttackHelicopter::TraceAttack( const CTakeDamageInfo &info, const Vect // Take no damage from trace attacks unless it's blast damage. RadiusDamage() sometimes calls // TraceAttack() as a means for delivering blast damage. Usually when the explosive penetrates // the target. (RPG missiles do this sometimes). +#ifdef MAPBASE + if ( ( info.GetDamageType() & DMG_AIRBOAT ) || + ( info.GetInflictor()->Classify() == CLASS_MISSILE ) || + ( info.GetAttacker()->Classify() == CLASS_MISSILE ) || + m_bAllowAnyDamage ) +#else if ( ( info.GetDamageType() & DMG_AIRBOAT ) || ( info.GetInflictor()->Classify() == CLASS_MISSILE ) || ( info.GetAttacker()->Classify() == CLASS_MISSILE ) ) +#endif { BaseClass::BaseClass::TraceAttack( info, vecDir, ptr, pAccumulator ); } @@ -3490,7 +3545,11 @@ void CNPC_AttackHelicopter::TraceAttack( const CTakeDamageInfo &info, const Vect int CNPC_AttackHelicopter::OnTakeDamage( const CTakeDamageInfo &info ) { // We don't take blast damage from anything but the airboat or missiles (or myself!) +#ifdef MAPBASE + if( info.GetInflictor() != this && !m_bAllowAnyDamage ) +#else if( info.GetInflictor() != this ) +#endif { if ( ( ( info.GetDamageType() & DMG_AIRBOAT ) == 0 ) && ( info.GetInflictor()->Classify() != CLASS_MISSILE ) && @@ -3605,12 +3664,14 @@ int CNPC_AttackHelicopter::OnTakeDamage_Alive( const CTakeDamageInfo &info ) ExplodeAndThrowChunk( info.GetDamagePosition() ); } +#ifndef MAPBASE // We need to make sure the base OnHealthChanged works with helicopters int nPrevPercent = (int)(100.0f * nPrevHealth / GetMaxHealth()); int nCurrPercent = (int)(100.0f * GetHealth() / GetMaxHealth()); if (( (nPrevPercent + 9) / 10 ) != ( (nCurrPercent + 9) / 10 )) { m_OnHealthChanged.Set( nCurrPercent, this, this ); } +#endif } return nRetVal; @@ -5939,6 +6000,10 @@ BEGIN_DATADESC( CHelicopterChunk ) DEFINE_PHYSPTR( m_pTailConstraint ), DEFINE_PHYSPTR( m_pCockpitConstraint ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "FallApart", InputFallApart ), +#endif + END_DATADESC() //----------------------------------------------------------------------------- @@ -6040,6 +6105,17 @@ void CHelicopterChunk::CollisionCallback( CHelicopterChunk *pCaller ) } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +// Input : *pCaller - +//----------------------------------------------------------------------------- +void CHelicopterChunk::InputFallApart( inputdata_t &inputdata ) +{ + CollisionCallback(this); +} +#endif + //----------------------------------------------------------------------------- // Purpose: // Input : &vecPos - diff --git a/sp/src/game/server/hl2/npc_barnacle.cpp b/sp/src/game/server/hl2/npc_barnacle.cpp index 1c195b90..38d9aad3 100644 --- a/sp/src/game/server/hl2/npc_barnacle.cpp +++ b/sp/src/game/server/hl2/npc_barnacle.cpp @@ -177,7 +177,7 @@ BEGIN_DATADESC( CNPC_Barnacle ) DEFINE_INPUTFUNC( FIELD_VOID, "DropTongue", InputDropTongue ), DEFINE_INPUTFUNC( FIELD_INTEGER, "SetDropTongueSpeed", InputSetDropTongueSpeed ), -#ifdef HL2_EPISODIC +#if HL2_EPISODIC || MAPBASE DEFINE_INPUTFUNC( FIELD_VOID, "LetGo", InputLetGo ), DEFINE_OUTPUT( m_OnGrab, "OnGrab" ), DEFINE_OUTPUT( m_OnRelease, "OnRelease" ), @@ -1355,7 +1355,7 @@ void CNPC_Barnacle::InputDropTongue( inputdata_t &inputdata ) void CNPC_Barnacle::AttachTongueToTarget( CBaseEntity *pTouchEnt, Vector vecGrabPos ) { -#if HL2_EPISODIC +#if HL2_EPISODIC || MAPBASE m_OnGrab.Set( pTouchEnt, this, this ); #endif @@ -1873,7 +1873,7 @@ void CNPC_Barnacle::RemoveRagdoll( bool bDestroyRagdoll ) void CNPC_Barnacle::LostPrey( bool bRemoveRagdoll ) { -#if HL2_EPISODIC +#if HL2_EPISODIC || MAPBASE m_OnRelease.Set( GetEnemy(), this, this ); #endif @@ -2213,6 +2213,11 @@ bool CNPC_Barnacle::IsPoisonous( CBaseEntity *pVictim ) if ( FClassnameIs(pVictim,"npc_headcrab_black") ) return true; +#ifdef MAPBASE + if (FClassnameIs( pVictim, "npc_poisonzombie" )) + return true; +#endif + if ( FClassnameIs(pVictim,"npc_antlion") && static_cast(pVictim)->IsWorker() ) @@ -2220,10 +2225,12 @@ bool CNPC_Barnacle::IsPoisonous( CBaseEntity *pVictim ) return false; } +#endif +#if HL2_EPISODIC || MAPBASE //========================================================= // script input to immediately abandon whatever I am lifting //========================================================= @@ -2240,8 +2247,10 @@ void CNPC_Barnacle::InputLetGo( inputdata_t &inputdata ) LostPrey( false ); } } +#endif +#if HL2_EPISODIC // Barnacle has custom impact damage tables, so it can take grave damage from sawblades. static impactentry_t barnacleLinearTable[] = { diff --git a/sp/src/game/server/hl2/npc_barnacle.h b/sp/src/game/server/hl2/npc_barnacle.h index bcb191cf..1ede1d70 100644 --- a/sp/src/game/server/hl2/npc_barnacle.h +++ b/sp/src/game/server/hl2/npc_barnacle.h @@ -145,6 +145,19 @@ private: +#ifdef MAPBASE + +#if HL2_EPISODIC + /// Decides whether something should poison the barnacle upon eating + static bool IsPoisonous( CBaseEntity *pVictim ); + const impactdamagetable_t &GetPhysicsImpactDamageTable( void ); +#endif + + // Regular HL2 DLL has these now + void InputLetGo( inputdata_t &inputdata ); + COutputEHANDLE m_OnGrab, m_OnRelease; + +#else #if HL2_EPISODIC /// Decides whether something should poison the barnacle upon eating static bool IsPoisonous( CBaseEntity *pVictim ); @@ -153,6 +166,7 @@ private: COutputEHANDLE m_OnGrab, m_OnRelease; const impactdamagetable_t &GetPhysicsImpactDamageTable( void ); +#endif #endif CNetworkVar( float, m_flAltitude ); diff --git a/sp/src/game/server/hl2/npc_barney.cpp b/sp/src/game/server/hl2/npc_barney.cpp index 337d0eb6..f4b04074 100644 --- a/sp/src/game/server/hl2/npc_barney.cpp +++ b/sp/src/game/server/hl2/npc_barney.cpp @@ -111,6 +111,9 @@ END_DATADESC() //----------------------------------------------------------------------------- void CNPC_Barney::SelectModel() { +#ifdef MAPBASE + if (GetModelName() == NULL_STRING) +#endif SetModelName( AllocPooledString( BARNEY_MODEL ) ); } diff --git a/sp/src/game/server/hl2/npc_citizen17.cpp b/sp/src/game/server/hl2/npc_citizen17.cpp index d48cf6c2..7efaa294 100644 --- a/sp/src/game/server/hl2/npc_citizen17.cpp +++ b/sp/src/game/server/hl2/npc_citizen17.cpp @@ -25,6 +25,12 @@ #include "eventqueue.h" +#ifdef MAPBASE +#include "hl2_gamerules.h" +#include "mapbase/GlobalStrings.h" +#include "collisionutils.h" +#endif + #include "ai_squad.h" #include "ai_pathfinder.h" #include "ai_route.h" @@ -69,6 +75,10 @@ ConVar npc_citizen_squad_marker( "npc_citizen_squad_marker", "0" ); ConVar npc_citizen_explosive_resist( "npc_citizen_explosive_resist", "0" ); ConVar npc_citizen_auto_player_squad( "npc_citizen_auto_player_squad", "1" ); ConVar npc_citizen_auto_player_squad_allow_use( "npc_citizen_auto_player_squad_allow_use", "0" ); +#ifdef MAPBASE +ConVar npc_citizen_squad_secondary_toggle_use_button("npc_citizen_squad_toggle_use_button", "262144"); // IN_WALK by default +ConVar npc_citizen_squad_secondary_toggle_use_always( "npc_citizen_squad_secondary_toggle_use_always", "0", FCVAR_NONE, "Allows all citizens not strictly stuck to the player's squad to be toggled via Alt + E." ); +#endif ConVar npc_citizen_dont_precache_all( "npc_citizen_dont_precache_all", "0" ); @@ -84,15 +94,29 @@ ConVar sk_citizen_heal_toss_player_delay("sk_citizen_heal_toss_player_delay", "2 #define MEDIC_THROW_SPEED npc_citizen_medic_throw_speed.GetFloat() +#ifdef MAPBASE +// We use a boolean now, so NameMatches("griggs") is handled in CNPC_Citizen::Spawn(). +#define USE_EXPERIMENTAL_MEDIC_CODE() (npc_citizen_heal_chuck_medkit.GetBool() && m_bTossesMedkits) +#else #define USE_EXPERIMENTAL_MEDIC_CODE() (npc_citizen_heal_chuck_medkit.GetBool() && NameMatches("griggs")) #endif +#endif +#ifdef MAPBASE +ConVar player_squad_autosummon_enabled( "player_squad_autosummon_enabled", "1" ); +#endif ConVar player_squad_autosummon_time( "player_squad_autosummon_time", "5" ); ConVar player_squad_autosummon_move_tolerance( "player_squad_autosummon_move_tolerance", "20" ); ConVar player_squad_autosummon_player_tolerance( "player_squad_autosummon_player_tolerance", "10" ); ConVar player_squad_autosummon_time_after_combat( "player_squad_autosummon_time_after_combat", "8" ); ConVar player_squad_autosummon_debug( "player_squad_autosummon_debug", "0" ); +#ifdef MAPBASE +ConVar npc_citizen_resupplier_adjust_ammo("npc_citizen_resupplier_adjust_ammo", "1", FCVAR_NONE, "If what ammo we give to the player would go over their max, should we adjust what we give accordingly (1) or cancel it altogether? (0)" ); + +ConVar npc_citizen_nocollide_player( "npc_citizen_nocollide_player", "1" ); +#endif + #define ShouldAutosquad() (npc_citizen_auto_player_squad.GetBool()) enum SquadSlot_T @@ -247,6 +271,10 @@ class CMattsPipe : public CWeaponCrowbar void SetPickupTouch( void ) { /* do nothing */ } }; +#ifdef MAPBASE +LINK_ENTITY_TO_CLASS(weapon_mattpipe, CMattsPipe); +#endif + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- @@ -335,6 +363,10 @@ BEGIN_DATADESC( CNPC_Citizen ) DEFINE_KEYFIELD( m_bNotifyNavFailBlocked, FIELD_BOOLEAN, "notifynavfailblocked" ), DEFINE_KEYFIELD( m_bNeverLeavePlayerSquad, FIELD_BOOLEAN, "neverleaveplayersquad" ), DEFINE_KEYFIELD( m_iszDenyCommandConcept, FIELD_STRING, "denycommandconcept" ), +#ifdef MAPBASE + DEFINE_INPUT( m_bTossesMedkits, FIELD_BOOLEAN, "SetTossMedkits" ), + DEFINE_KEYFIELD( m_bAlternateAiming, FIELD_BOOLEAN, "AlternateAiming" ), +#endif DEFINE_OUTPUT( m_OnJoinedPlayerSquad, "OnJoinedPlayerSquad" ), DEFINE_OUTPUT( m_OnLeftPlayerSquad, "OnLeftPlayerSquad" ), @@ -342,11 +374,20 @@ BEGIN_DATADESC( CNPC_Citizen ) DEFINE_OUTPUT( m_OnStationOrder, "OnStationOrder" ), DEFINE_OUTPUT( m_OnPlayerUse, "OnPlayerUse" ), DEFINE_OUTPUT( m_OnNavFailBlocked, "OnNavFailBlocked" ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OnHealedNPC, "OnHealedNPC" ), + DEFINE_OUTPUT( m_OnHealedPlayer, "OnHealedPlayer" ), + DEFINE_OUTPUT( m_OnThrowMedkit, "OnTossMedkit" ), + DEFINE_OUTPUT( m_OnGiveAmmo, "OnGiveAmmo" ), +#endif DEFINE_INPUTFUNC( FIELD_VOID, "RemoveFromPlayerSquad", InputRemoveFromPlayerSquad ), DEFINE_INPUTFUNC( FIELD_VOID, "StartPatrolling", InputStartPatrolling ), DEFINE_INPUTFUNC( FIELD_VOID, "StopPatrolling", InputStopPatrolling ), DEFINE_INPUTFUNC( FIELD_VOID, "SetCommandable", InputSetCommandable ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "SetUnCommandable", InputSetUnCommandable ), +#endif DEFINE_INPUTFUNC( FIELD_VOID, "SetMedicOn", InputSetMedicOn ), DEFINE_INPUTFUNC( FIELD_VOID, "SetMedicOff", InputSetMedicOff ), DEFINE_INPUTFUNC( FIELD_VOID, "SetAmmoResupplierOn", InputSetAmmoResupplierOn ), @@ -374,6 +415,9 @@ bool CNPC_Citizen::CreateBehaviors() { BaseClass::CreateBehaviors(); AddBehavior( &m_FuncTankBehavior ); +#ifdef MAPBASE + AddBehavior( &m_RappelBehavior ); +#endif return true; } @@ -481,6 +525,26 @@ void CNPC_Citizen::Spawn() m_bShouldPatrol = false; m_iHealth = sk_citizen_health.GetFloat(); +#ifdef MAPBASE + // Now only gets citizen_trains. + if ( GetMoveParent() && FClassnameIs( GetMoveParent(), "func_tracktrain" ) ) + { + if ( NameMatches("citizen_train_2") ) + { + CapabilitiesRemove( bits_CAP_MOVE_GROUND ); + SetMoveType( MOVETYPE_NONE ); + SetSequenceByName( "d1_t01_TrainRide_Sit_Idle" ); + SetIdealActivity( ACT_DO_NOT_DISTURB ); + } + else if ( NameMatches("citizen_train_1") ) + { + CapabilitiesRemove( bits_CAP_MOVE_GROUND ); + SetMoveType( MOVETYPE_NONE ); + SetSequenceByName( "d1_t01_TrainRide_Stand" ); + SetIdealActivity( ACT_DO_NOT_DISTURB ); + } + } +#else // Are we on a train? Used in trainstation to have NPCs on trains. if ( GetMoveParent() && FClassnameIs( GetMoveParent(), "func_tracktrain" ) ) { @@ -497,6 +561,7 @@ void CNPC_Citizen::Spawn() SetIdealActivity( ACT_DO_NOT_DISTURB ); } } +#endif m_flStopManhackFlinch = -1; @@ -528,6 +593,13 @@ void CNPC_Citizen::Spawn() // Use render bounds instead of human hull for guys sitting in chairs, etc. m_ActBusyBehavior.SetUseRenderBounds( HasSpawnFlags( SF_CITIZEN_USE_RENDER_BOUNDS ) ); + +#ifdef MAPBASE + if (NameMatches("griggs")) + { + m_bTossesMedkits = true; + } +#endif } //----------------------------------------------------------------------------- @@ -589,6 +661,14 @@ void CNPC_Citizen::SelectModel() if ( m_Type == CT_DEFAULT ) { +#ifdef MAPBASE + if (HL2GameRules()->GetDefaultCitizenType() != CT_DEFAULT) + { + m_Type = static_cast(HL2GameRules()->GetDefaultCitizenType()); + } + else + { +#endif struct CitizenTypeMapping { const char *pszMapTag; @@ -621,6 +701,9 @@ void CNPC_Citizen::SelectModel() if ( m_Type == CT_DEFAULT ) m_Type = CT_DOWNTRODDEN; +#ifdef MAPBASE + } +#endif } if( HasSpawnFlags( SF_CITIZEN_RANDOM_HEAD | SF_CITIZEN_RANDOM_HEAD_MALE | SF_CITIZEN_RANDOM_HEAD_FEMALE ) || GetModelName() == NULL_STRING ) @@ -751,7 +834,11 @@ void CNPC_Citizen::SelectExpressionType() void CNPC_Citizen::FixupMattWeapon() { CBaseCombatWeapon *pWeapon = GetActiveWeapon(); +#ifdef MAPBASE + if ( pWeapon && EntIsClass( pWeapon, gm_isz_class_Crowbar ) && NameMatches( "matt" ) ) +#else if ( pWeapon && pWeapon->ClassMatches( "weapon_crowbar" ) && NameMatches( "matt" ) ) +#endif { Weapon_Drop( pWeapon ); UTIL_Remove( pWeapon ); @@ -1165,6 +1252,19 @@ int CNPC_Citizen::SelectFailSchedule( int failedSchedule, int failedTask, AI_Tas //----------------------------------------------------------------------------- int CNPC_Citizen::SelectSchedule() { +#ifdef MAPBASE + if ( IsWaitingToRappel() && BehaviorSelectSchedule() ) + { + return BaseClass::SelectSchedule(); + } + + if ( GetMoveType() == MOVETYPE_NONE && !Q_strncmp(STRING(GetEntityName()), "citizen_train_", 14) ) + { + // Only "sit on train" if we're a citizen_train_ + Assert( GetMoveParent() && FClassnameIs( GetMoveParent(), "func_tracktrain" ) ); + return SCHED_CITIZEN_SIT_ON_TRAIN; + } +#else // If we can't move, we're on a train, and should be sitting. if ( GetMoveType() == MOVETYPE_NONE ) { @@ -1173,13 +1273,23 @@ int CNPC_Citizen::SelectSchedule() Assert( GetMoveParent() && FClassnameIs( GetMoveParent(), "func_tracktrain" ) ); return SCHED_CITIZEN_SIT_ON_TRAIN; } +#endif +#ifdef MAPBASE + if ( GetActiveWeapon() && EntIsClass(GetActiveWeapon(), gm_isz_class_RPG) ) + { + CWeaponRPG *pRPG = static_cast(GetActiveWeapon()); +#else CWeaponRPG *pRPG = dynamic_cast(GetActiveWeapon()); +#endif if ( pRPG && pRPG->IsGuiding() ) { DevMsg( "Citizen in select schedule but RPG is guiding?\n"); pRPG->StopGuiding(); } +#ifdef MAPBASE + } +#endif return BaseClass::SelectSchedule(); } @@ -1479,9 +1589,15 @@ int CNPC_Citizen::TranslateSchedule( int scheduleType ) case SCHED_RANGE_ATTACK1: // If we have an RPG, we use a custom schedule for it +#ifdef MAPBASE + if ( !IsMortar( GetEnemy() ) && GetActiveWeapon() && EntIsClass(GetActiveWeapon(), gm_isz_class_RPG) ) + { + if ( GetEnemy() && EntIsClass(GetEnemy(), gm_isz_class_Strider) ) +#else if ( !IsMortar( GetEnemy() ) && GetActiveWeapon() && FClassnameIs( GetActiveWeapon(), "weapon_rpg" ) ) { if ( GetEnemy() && GetEnemy()->ClassMatches( "npc_strider" ) ) +#endif { if (OccupyStrategySlotRange( SQUAD_SLOT_CITIZEN_RPG1, SQUAD_SLOT_CITIZEN_RPG2 ) ) { @@ -1494,14 +1610,21 @@ int CNPC_Citizen::TranslateSchedule( int scheduleType ) } else { +#ifndef MAPBASE // This has been disabled for now. CBasePlayer *pPlayer = AI_GetSinglePlayer(); +#ifdef MAPBASE + // Don't avoid player if notarget is on + if ( pPlayer && GetEnemy() && !(pPlayer->GetFlags() & FL_NOTARGET) && ( ( GetEnemy()->GetAbsOrigin() - +#else if ( pPlayer && GetEnemy() && ( ( GetEnemy()->GetAbsOrigin() - +#endif pPlayer->GetAbsOrigin() ).LengthSqr() < RPG_SAFE_DISTANCE * RPG_SAFE_DISTANCE ) ) { // Don't fire our RPG at an enemy too close to the player return SCHED_STANDOFF; } else +#endif { return SCHED_CITIZEN_RANGE_ATTACK1_RPG; } @@ -1767,13 +1890,20 @@ void CNPC_Citizen::RunTask( const Task_t *pTask ) } Vector vecEnemyPos = GetEnemy()->BodyTarget(GetAbsOrigin(), false); +#ifndef MAPBASE // This has been disabled for now. CBasePlayer *pPlayer = AI_GetSinglePlayer(); +#ifdef MAPBASE + // Don't avoid player if notarget is on + if ( pPlayer && !(pPlayer->GetFlags() & FL_NOTARGET) && ( ( vecEnemyPos - pPlayer->GetAbsOrigin() ).LengthSqr() < RPG_SAFE_DISTANCE * RPG_SAFE_DISTANCE ) ) +#else if ( pPlayer && ( ( vecEnemyPos - pPlayer->GetAbsOrigin() ).LengthSqr() < RPG_SAFE_DISTANCE * RPG_SAFE_DISTANCE ) ) +#endif { m_bRPGAvoidPlayer = true; Speak( TLK_WATCHOUT ); } else +#endif { // Pull the laserdot towards the target Vector vecToTarget = (vecEnemyPos - vecLaserPos); @@ -1797,7 +1927,12 @@ void CNPC_Citizen::RunTask( const Task_t *pTask ) return; } // Add imprecision to avoid obvious robotic perfection stationary targets +#ifdef MAPBASE + // More imprecision with low-accuracy citizens + float imprecision = 18*sin(gpGlobals->curtime) + cosh(GetCurrentWeaponProficiency() - 4); +#else float imprecision = 18*sin(gpGlobals->curtime); +#endif vecLaserPos.x += imprecision; vecLaserPos.y += imprecision; vecLaserPos.z += imprecision; @@ -1838,9 +1973,18 @@ Activity CNPC_Citizen::NPC_TranslateActivity( Activity activity ) { if ( activity == ACT_MELEE_ATTACK1 ) { +#ifdef MAPBASE + // It could be the new weapon punt activity. + if (GetActiveWeapon() && GetActiveWeapon()->IsMeleeWeapon()) + { + return ACT_MELEE_ATTACK_SWING; + } +#else return ACT_MELEE_ATTACK_SWING; +#endif } +#ifndef MAPBASE // Covered by the new backup activity system // !!!HACK - Citizens don't have the required animations for shotguns, // so trick them into using the rifle counterparts for now (sjb) if ( activity == ACT_RUN_AIM_SHOTGUN ) @@ -1851,6 +1995,22 @@ Activity CNPC_Citizen::NPC_TranslateActivity( Activity activity ) return ACT_IDLE_ANGRY_SMG1; if ( activity == ACT_RANGE_ATTACK_SHOTGUN_LOW ) return ACT_RANGE_ATTACK_SMG1_LOW; +#endif + +#ifdef MAPBASE + if (m_bAlternateAiming) + { + if (activity == ACT_RUN_AIM_RIFLE) + return ACT_RUN_AIM_RIFLE_STIMULATED; + if (activity == ACT_WALK_AIM_RIFLE) + return ACT_WALK_AIM_RIFLE_STIMULATED; + + if (activity == ACT_RUN_AIM_AR2) + return ACT_RUN_AIM_AR2_STIMULATED; + if (activity == ACT_WALK_AIM_AR2) + return ACT_WALK_AIM_AR2_STIMULATED; + } +#endif return BaseClass::NPC_TranslateActivity( activity ); } @@ -1878,7 +2038,12 @@ void CNPC_Citizen::HandleAnimEvent( animevent_t *pEvent ) { // Heal my target (if within range) #if HL2_EPISODIC +#ifdef MAPBASE + // Don't throw medkits at NPCs, that's not how it works + if ( USE_EXPERIMENTAL_MEDIC_CODE() && IsMedic() && GetTarget() && !GetTarget()->IsNPC() ) +#else if ( USE_EXPERIMENTAL_MEDIC_CODE() && IsMedic() ) +#endif { CBaseCombatCharacter *pTarget = dynamic_cast( GetTarget() ); Assert(pTarget); @@ -1918,6 +2083,7 @@ void CNPC_Citizen::HandleAnimEvent( animevent_t *pEvent ) } } +#ifndef MAPBASE // Moved to CAI_BaseNPC //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void CNPC_Citizen::PickupItem( CBaseEntity *pItem ) @@ -1944,6 +2110,7 @@ void CNPC_Citizen::PickupItem( CBaseEntity *pItem ) DevMsg("Citizen doesn't know how to pick up %s!\n", pItem->GetClassname() ); } } +#endif //----------------------------------------------------------------------------- // Purpose: @@ -2092,7 +2259,12 @@ bool CNPC_Citizen::IsManhackMeleeCombatant() { CBaseCombatWeapon *pWeapon = GetActiveWeapon(); CBaseEntity *pEnemy = GetEnemy(); +#ifdef MAPBASE + // Any melee weapon passes + return ( pEnemy && pWeapon && pEnemy->Classify() == CLASS_MANHACK && pWeapon->IsMeleeWeapon() ); +#else return ( pEnemy && pWeapon && pEnemy->Classify() == CLASS_MANHACK && pWeapon->ClassMatches( "weapon_crowbar" ) ); +#endif } //----------------------------------------------------------------------------- @@ -2101,13 +2273,25 @@ bool CNPC_Citizen::IsManhackMeleeCombatant() //----------------------------------------------------------------------------- Vector CNPC_Citizen::GetActualShootPosition( const Vector &shootOrigin ) { +#ifdef MAPBASE + // The code below is probably broken. If not, it definitely isn't very effective. + return BaseClass::GetActualShootPosition( shootOrigin ); +#else Vector vecTarget = BaseClass::GetActualShootPosition( shootOrigin ); +#ifdef MAPBASE + // If we're firing an RPG at a gunship, aim off to it's side, because we'll auger towards it. + if ( GetActiveWeapon() && EntIsClass(GetActiveWeapon(), gm_isz_class_RPG) && GetEnemy() ) + { + CWeaponRPG *pRPG = static_cast(GetActiveWeapon()); + if ( EntIsClass( GetEnemy(), gm_isz_class_Gunship ) ) +#else CWeaponRPG *pRPG = dynamic_cast(GetActiveWeapon()); // If we're firing an RPG at a gunship, aim off to it's side, because we'll auger towards it. if ( pRPG && GetEnemy() ) { if ( FClassnameIs( GetEnemy(), "npc_combinegunship" ) ) +#endif { Vector vecRight; GetVectors( NULL, &vecRight, NULL ); @@ -2146,6 +2330,7 @@ Vector CNPC_Citizen::GetActualShootPosition( const Vector &shootOrigin ) } return vecTarget; +#endif } //----------------------------------------------------------------------------- @@ -2194,19 +2379,31 @@ bool CNPC_Citizen::ShouldLookForBetterWeapon() { bool bDefer = false; +#ifdef MAPBASE + if ( EntIsClass(pWeapon, gm_isz_class_AR2) ) +#else if( FClassnameIs( pWeapon, "weapon_ar2" ) ) +#endif { // Content to keep this weapon forever m_flNextWeaponSearchTime = OTHER_DEFER_SEARCH_TIME; bDefer = true; } +#ifdef MAPBASE + else if( EntIsClass(pWeapon, gm_isz_class_RPG) ) +#else else if( FClassnameIs( pWeapon, "weapon_rpg" ) ) +#endif { // Content to keep this weapon forever m_flNextWeaponSearchTime = OTHER_DEFER_SEARCH_TIME; bDefer = true; } +#ifdef MAPBASE + else if ( EntIsClass(pWeapon, gm_isz_class_Shotgun) ) +#else else if( FClassnameIs( pWeapon, "weapon_shotgun" ) ) +#endif { // Shotgunners do not defer their weapon search indefinitely. // If more than one citizen in the squad has a shotgun, we force @@ -2294,6 +2491,20 @@ int CNPC_Citizen::OnTakeDamage_Alive( const CTakeDamageInfo &info ) return BaseClass::OnTakeDamage_Alive( newInfo ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CNPC_Citizen::ModifyOrAppendCriteria( AI_CriteriaSet& set ) +{ + BaseClass::ModifyOrAppendCriteria( set ); + + // No need to tell me. + set.AppendCriteria("medic", IsMedic() ? "1" : "0"); + + set.AppendCriteria("citizentype", UTIL_VarArgs("%i", m_Type)); +} +#endif + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- bool CNPC_Citizen::IsCommandable() @@ -2337,6 +2548,11 @@ bool CNPC_Citizen::CanJoinPlayerSquad() if ( IRelationType( UTIL_GetLocalPlayer() ) != D_LI ) return false; +#ifdef MAPBASE + if ( IsWaitingToRappel() ) + return false; +#endif + return true; } @@ -2511,6 +2727,64 @@ bool CNPC_Citizen::SpeakCommandResponse( AIConcept_t concept, const char *modifi ( modifiers ) ? CFmtStr(",%s", modifiers).operator const char *() : "" ) ); } +#ifdef MAPBASE +extern ConVar ai_debug_avoidancebounds; + +//----------------------------------------------------------------------------- +// Purpose: Implements player nocollide. +//----------------------------------------------------------------------------- +void CNPC_Citizen::SetPlayerAvoidState( void ) +{ + bool bShouldPlayerAvoid = false; + Vector vNothing; + + GetSequenceLinearMotion( GetSequence(), &vNothing ); + bool bIsMoving = ( IsMoving() || ( vNothing != vec3_origin ) ); + + m_bPlayerAvoidState = ShouldPlayerAvoid(); + bool bSquadNoCollide = (IsInPlayerSquad() && npc_citizen_nocollide_player.GetBool()); + + // If we are coming out of a script, check if we are stuck inside the player. + if ( m_bPerformAvoidance || ( m_bPlayerAvoidState && bIsMoving ) || bSquadNoCollide ) + { + trace_t trace; + Vector vMins, vMaxs; + + GetPlayerAvoidBounds( &vMins, &vMaxs ); + + CBasePlayer *pLocalPlayer = AI_GetSinglePlayer(); + + if ( pLocalPlayer ) + { + bShouldPlayerAvoid = (!bSquadNoCollide || !pLocalPlayer->IsMoving()) && IsBoxIntersectingBox( GetAbsOrigin() + vMins, GetAbsOrigin() + vMaxs, + pLocalPlayer->GetAbsOrigin() + pLocalPlayer->WorldAlignMins(), pLocalPlayer->GetAbsOrigin() + pLocalPlayer->WorldAlignMaxs() ); + } + + if ( ai_debug_avoidancebounds.GetBool() ) + { + int iRed = ( bShouldPlayerAvoid == true ) ? 255 : 0; + + NDebugOverlay::Box( GetAbsOrigin(), vMins, vMaxs, iRed, 0, 255, 64, 0.1 ); + } + } + + m_bPerformAvoidance = bShouldPlayerAvoid; + + if ( GetCollisionGroup() == COLLISION_GROUP_NPC || GetCollisionGroup() == COLLISION_GROUP_NPC_ACTOR ) + { + if ( m_bPerformAvoidance == true || + (bSquadNoCollide && !m_bPlayerAvoidState)) + { + SetCollisionGroup( COLLISION_GROUP_NPC_ACTOR ); + } + else + { + SetCollisionGroup( COLLISION_GROUP_NPC ); + } + } +} +#endif + //----------------------------------------------------------------------------- // Purpose: return TRUE if the commander mode should try to give this order // to more people. return FALSE otherwise. For instance, we don't @@ -2553,7 +2827,11 @@ void CNPC_Citizen::MoveOrder( const Vector &vecDest, CAI_BaseNPC **Allies, int n if ( !AI_IsSinglePlayer() ) return; +#ifdef MAPBASE + if ( m_iszDenyCommandConcept != NULL_STRING ) +#else if( hl2_episodic.GetBool() && m_iszDenyCommandConcept != NULL_STRING ) +#endif { SpeakCommandResponse( STRING(m_iszDenyCommandConcept) ); return; @@ -2635,6 +2913,28 @@ void CNPC_Citizen::OnMoveOrder() BaseClass::OnMoveOrder(); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline bool CNPC_Citizen::ShouldAllowSquadToggleUse( CBasePlayer *pPlayer ) +{ + if (HasSpawnFlags( SF_CITIZEN_NOT_COMMANDABLE )) + return false; + + //if (!HL2GameRules() || !HL2GameRules()->AllowSquadToggleUse()) + if (!HasSpawnFlags( SF_CITIZEN_PLAYER_TOGGLE_SQUAD )) + { + if (!npc_citizen_squad_secondary_toggle_use_always.GetBool() || m_bNeverLeavePlayerSquad) + return false; + + // npc_citizen_squad_secondary_toggle_use_always was invoked + AddSpawnFlags( SF_CITIZEN_PLAYER_TOGGLE_SQUAD ); + } + + return (pPlayer->m_nButtons & npc_citizen_squad_secondary_toggle_use_button.GetInt()) != 0; +} +#endif + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void CNPC_Citizen::CommanderUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) @@ -2654,6 +2954,31 @@ void CNPC_Citizen::CommanderUse( CBaseEntity *pActivator, CBaseEntity *pCaller, // Don't say hi after you've been addressed by the player SetSpokeConcept( TLK_HELLO, NULL ); +#ifdef MAPBASE + if ( ShouldAllowSquadToggleUse(UTIL_GetLocalPlayer()) || npc_citizen_auto_player_squad_allow_use.GetBool() ) + { + // Version of TogglePlayerSquadState() that has "used" as a modifier + static const char *szSquadUseModifier = "used:1"; + if ( !IsInPlayerSquad() ) + { + AddToPlayerSquad(); + + if ( HaveCommandGoal() ) + { + SpeakCommandResponse( TLK_COMMANDED, szSquadUseModifier ); + } + else if ( m_FollowBehavior.GetFollowTarget() == UTIL_GetLocalPlayer() ) + { + SpeakCommandResponse( TLK_STARTFOLLOW, szSquadUseModifier ); + } + } + else + { + SpeakCommandResponse( TLK_STOPFOLLOW, szSquadUseModifier ); + RemoveFromPlayerSquad(); + } + } +#else if ( npc_citizen_auto_player_squad_allow_use.GetBool() ) { if ( !ShouldAutosquad() ) @@ -2661,8 +2986,37 @@ void CNPC_Citizen::CommanderUse( CBaseEntity *pActivator, CBaseEntity *pCaller, else if ( !IsInPlayerSquad() && npc_citizen_auto_player_squad_allow_use.GetBool() ) AddToPlayerSquad(); } +#endif else if ( GetCurSchedule() && ConditionInterruptsCurSchedule( COND_IDLE_INTERRUPT ) ) { +#ifdef MAPBASE + // Just do regular idle question behavior so question groups, etc. work on +USE. + if ( IsAllowedToSpeak( TLK_QUESTION, true ) ) + { + // 1 = Old "SpeakIdleResponse" behavior + // 2, 3 = AskQuestion() for QA groups, etc. + // 4 = Just speak + int iRandom = random->RandomInt(1, 4); + if ( iRandom == 1 ) + { + CBaseEntity *pRespondant = FindSpeechTarget( AIST_NPCS ); + if ( pRespondant ) + { + g_EventQueue.AddEvent( pRespondant, "SpeakIdleResponse", ( GetTimeSpeechComplete() - gpGlobals->curtime ) + .2, this, this ); + } + } + if ( iRandom < 4 ) + { + // Ask someone else + AskQuestionNow(); + } + else + { + // Just speak + Speak( TLK_QUESTION ); + } + } +#else if ( SpeakIfAllowed( TLK_QUESTION, NULL, true ) ) { if ( random->RandomInt( 1, 4 ) < 4 ) @@ -2674,6 +3028,7 @@ void CNPC_Citizen::CommanderUse( CBaseEntity *pActivator, CBaseEntity *pCaller, } } } +#endif } } } @@ -2883,6 +3238,11 @@ void CNPC_Citizen::UpdatePlayerSquad() if ( !pCitizen->CanJoinPlayerSquad() ) continue; +#ifdef MAPBASE + if ( pCitizen->HasSpawnFlags(SF_CITIZEN_PLAYER_TOGGLE_SQUAD) ) + continue; +#endif + bool bShouldAdd = false; if ( pCitizen->HasCondition( COND_SEE_PLAYER ) ) @@ -2940,7 +3300,11 @@ void CNPC_Citizen::UpdatePlayerSquad() if ( ppAIs[j]->GetClassname() != GetClassname() ) continue; +#ifdef MAPBASE + if ( ppAIs[j]->HasSpawnFlags( SF_CITIZEN_NOT_COMMANDABLE | SF_CITIZEN_PLAYER_TOGGLE_SQUAD ) ) +#else if ( ppAIs[j]->HasSpawnFlags( SF_CITIZEN_NOT_COMMANDABLE ) ) +#endif continue; CNPC_Citizen *pCitizen = assert_cast(ppAIs[j]); @@ -3415,7 +3779,11 @@ bool CNPC_Citizen::ShouldHealTarget( CBaseEntity *pTarget, bool bActiveUse ) { Disposition_t disposition; +#ifdef MAPBASE + if ( pTarget && ( ( disposition = IRelationType( pTarget ) ) != D_LI && disposition != D_NU ) ) +#else if ( !pTarget && ( ( disposition = IRelationType( pTarget ) ) != D_LI && disposition != D_NU ) ) +#endif return false; // Don't heal if I'm in the middle of talking @@ -3497,6 +3865,14 @@ bool CNPC_Citizen::ShouldHealTarget( CBaseEntity *pTarget, bool bActiveUse ) if ( ((CBasePlayer*)pTarget)->Weapon_GetWpnForAmmo( iAmmoType ) ) return true; } +#ifdef MAPBASE + else if ( (iMax - iCount) < m_iAmmoAmount && (iMax - iCount) != 0 ) + { + // If we're allowed to adjust our ammo, the amount of ammo we give may be reduced, but that's better than not giving any at all! + if (npc_citizen_resupplier_adjust_ammo.GetBool() == true && ((CBasePlayer*)pTarget)->Weapon_GetWpnForAmmo( iAmmoType )) + return true; + } +#endif } } } @@ -3515,14 +3891,25 @@ bool CNPC_Citizen::ShouldHealTossTarget( CBaseEntity *pTarget, bool bActiveUse ) if ( !IsMedic() ) return false; +#ifdef MAPBASE + if ( pTarget && ( ( disposition = IRelationType( pTarget ) ) != D_LI && disposition != D_NU ) ) +#else if ( !pTarget && ( ( disposition = IRelationType( pTarget ) ) != D_LI && disposition != D_NU ) ) +#endif return false; // Don't heal if I'm in the middle of talking if ( IsSpeaking() ) return false; +#ifdef MAPBASE + // NPCs cannot be healed by throwing medkits at them. + // I don't think NPCs even pass through this function anyway, it's just the actual heal event that's the problem. + if (!pTarget->IsPlayer()) + return false; +#else bool bTargetIsPlayer = pTarget->IsPlayer(); +#endif // Don't heal or give ammo to targets in vehicles CBaseCombatCharacter *pCCTarget = pTarget->MyCombatCharacterPointer(); @@ -3550,18 +3937,26 @@ bool CNPC_Citizen::ShouldHealTossTarget( CBaseEntity *pTarget, bool bActiveUse ) } // Are we ready to heal again? +#ifdef MAPBASE + bool bReadyToHeal = m_flPlayerHealTime <= gpGlobals->curtime; +#else bool bReadyToHeal = ( ( bTargetIsPlayer && m_flPlayerHealTime <= gpGlobals->curtime ) || ( !bTargetIsPlayer && m_flAllyHealTime <= gpGlobals->curtime ) ); +#endif // Only heal if we're ready if ( bReadyToHeal ) { int requiredHealth; +#ifdef MAPBASE + requiredHealth = pTarget->GetMaxHealth() - sk_citizen_heal_player.GetFloat(); +#else if ( bTargetIsPlayer ) requiredHealth = pTarget->GetMaxHealth() - sk_citizen_heal_player.GetFloat(); else requiredHealth = pTarget->GetMaxHealth() * sk_citizen_heal_player_min_pct.GetFloat(); +#endif if ( ( pTarget->m_iHealth <= requiredHealth ) && IRelationType( pTarget ) == D_LI ) return true; @@ -3625,6 +4020,10 @@ void CNPC_Citizen::Heal() EmitSound( filter, pTarget->entindex(), "HealthKit.Touch" ); } +#ifdef MAPBASE + pTarget->IsPlayer() ? m_OnHealedPlayer.FireOutput(pTarget, this) : m_OnHealedNPC.FireOutput(pTarget, this); +#endif + pTarget->TakeHealth( healAmt, DMG_GENERIC ); pTarget->RemoveAllDecals(); } @@ -3643,6 +4042,10 @@ void CNPC_Citizen::Heal() else { ((CBasePlayer*)pTarget)->GiveAmmo( m_iAmmoAmount, iAmmoType, false ); + +#ifdef MAPBASE + m_OnGiveAmmo.FireOutput(pTarget, this); +#endif } m_flPlayerGiveAmmoTime = gpGlobals->curtime + sk_citizen_giveammo_player_delay.GetFloat(); @@ -3715,6 +4118,10 @@ void CNPC_Citizen::TossHealthKit(CBaseCombatCharacter *pThrowAt, const Vector &o pPhysicsObject->SetVelocity( &tossVelocity, &angDummy ); } } + +#ifdef MAPBASE + m_OnThrowMedkit.Set(pHealthKit, pHealthKit, this); +#endif } else { @@ -3790,6 +4197,16 @@ void CNPC_Citizen::InputSetCommandable( inputdata_t &inputdata ) gm_PlayerSquadEvaluateTimer.Force(); } +#ifdef MAPBASE +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void CNPC_Citizen::InputSetUnCommandable( inputdata_t &inputdata ) +{ + AddSpawnFlags( SF_CITIZEN_NOT_COMMANDABLE ); + RemoveFromPlayerSquad(); +} +#endif + //----------------------------------------------------------------------------- // Purpose: // Input : &inputdata - @@ -3840,7 +4257,13 @@ void CNPC_Citizen::DeathSound( const CTakeDamageInfo &info ) // Sentences don't play on dead NPCs SentenceStop(); +#ifdef MAPBASE + AI_CriteriaSet set; + ModifyOrAppendDamageCriteria(set, info); + Speak( TLK_DEATH, set ); +#else EmitSound( "NPC_Citizen.Die" ); +#endif } //------------------------------------------------------------------------------ diff --git a/sp/src/game/server/hl2/npc_citizen17.h b/sp/src/game/server/hl2/npc_citizen17.h index 49efbc7a..548107cc 100644 --- a/sp/src/game/server/hl2/npc_citizen17.h +++ b/sp/src/game/server/hl2/npc_citizen17.h @@ -11,6 +11,9 @@ #include "npc_playercompanion.h" #include "ai_behavior_functank.h" +#ifdef MAPBASE +#include "ai_behavior_rappel.h" +#endif struct SquadCandidate_t; @@ -33,6 +36,9 @@ struct SquadCandidate_t; #define SF_CITIZEN_RANDOM_HEAD_MALE ( 1 << 22 ) //4194304 #define SF_CITIZEN_RANDOM_HEAD_FEMALE ( 1 << 23 )//8388608 #define SF_CITIZEN_USE_RENDER_BOUNDS ( 1 << 24 )//16777216 +#ifdef MAPBASE +#define SF_CITIZEN_PLAYER_TOGGLE_SQUAD ( 1 << 25 ) //33554432 Prevents the citizen from joining the squad automatically, but still being commandable if the player toggles it +#endif //------------------------------------- // Animation events @@ -130,7 +136,9 @@ public: void HandleAnimEvent( animevent_t *pEvent ); void TaskFail( AI_TaskFailureCode_t code ); +#ifndef MAPBASE // Moved to CAI_BaseNPC void PickupItem( CBaseEntity *pItem ); +#endif void SimpleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); @@ -161,6 +169,11 @@ public: // Damage handling //--------------------------------- int OnTakeDamage_Alive( const CTakeDamageInfo &info ); + +#ifdef MAPBASE + //--------------------------------- + void ModifyOrAppendCriteria( AI_CriteriaSet& set ); +#endif //--------------------------------- // Commander mode @@ -179,6 +192,9 @@ public: void MoveOrder( const Vector &vecDest, CAI_BaseNPC **Allies, int numAllies ); void OnMoveOrder(); void CommanderUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); +#ifdef MAPBASE + bool ShouldAllowSquadToggleUse( CBasePlayer *pPlayer ); +#endif bool ShouldSpeakRadio( CBaseEntity *pListener ); void OnMoveToCommandGoalFailed(); void AddToPlayerSquad(); @@ -195,6 +211,10 @@ public: void AddInsignia(); void RemoveInsignia(); bool SpeakCommandResponse( AIConcept_t concept, const char *modifiers = NULL ); + +#ifdef MAPBASE + virtual void SetPlayerAvoidState( void ); +#endif //--------------------------------- // Scanner interaction @@ -235,6 +255,9 @@ public: void InputStartPatrolling( inputdata_t &inputdata ); void InputStopPatrolling( inputdata_t &inputdata ); void InputSetCommandable( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetUnCommandable( inputdata_t &inputdata ); +#endif void InputSetMedicOn( inputdata_t &inputdata ); void InputSetMedicOff( inputdata_t &inputdata ); void InputSetAmmoResupplierOn( inputdata_t &inputdata ); @@ -303,6 +326,10 @@ private: bool m_bWasInPlayerSquad; float m_flTimeLastCloseToPlayer; string_t m_iszDenyCommandConcept; +#ifdef MAPBASE + bool m_bTossesMedkits; + bool m_bAlternateAiming; +#endif CSimpleSimTimer m_AutoSummonTimer; Vector m_vAutoSummonAnchor; @@ -326,9 +353,22 @@ private: COutputEvent m_OnStationOrder; COutputEvent m_OnPlayerUse; COutputEvent m_OnNavFailBlocked; +#ifdef MAPBASE + COutputEvent m_OnHealedNPC; + COutputEvent m_OnHealedPlayer; + COutputEHANDLE m_OnThrowMedkit; + COutputEvent m_OnGiveAmmo; +#endif //----------------------------------------------------- CAI_FuncTankBehavior m_FuncTankBehavior; +#ifdef MAPBASE + CAI_RappelBehavior m_RappelBehavior; + + // Rappel + virtual bool IsWaitingToRappel( void ) { return m_RappelBehavior.IsWaitingToRappel(); } + void BeginRappel() { m_RappelBehavior.BeginRappel(); } +#endif CHandle m_hSavedFollowGoalEnt; diff --git a/sp/src/game/server/hl2/npc_combine.cpp b/sp/src/game/server/hl2/npc_combine.cpp index 09cae88a..0d728f02 100644 --- a/sp/src/game/server/hl2/npc_combine.cpp +++ b/sp/src/game/server/hl2/npc_combine.cpp @@ -29,23 +29,37 @@ #include "weapon_physcannon.h" #include "SoundEmitterSystem/isoundemittersystembase.h" #include "npc_headcrab.h" +#ifdef MAPBASE +#include "mapbase/GlobalStrings.h" +#include "globalstate.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" int g_fCombineQuestion; // true if an idle grunt asked a question. Cleared when someone answers. YUCK old global from grunt code +#ifdef MAPBASE +ConVar npc_combine_idle_walk_easy("npc_combine_idle_walk_easy", "1"); +ConVar npc_combine_unarmed_anims("npc_combine_unarmed_anims", "1"); +ConVar npc_combine_altfire_alliesonly("npc_combine_altfire_alliesonly", "0"); +#endif + #define COMBINE_SKIN_DEFAULT 0 #define COMBINE_SKIN_SHOTGUNNER 1 +#ifndef MAPBASE #define COMBINE_GRENADE_THROW_SPEED 650 #define COMBINE_GRENADE_TIMER 3.5 #define COMBINE_GRENADE_FLUSH_TIME 3.0 // Don't try to flush an enemy who has been out of sight for longer than this. #define COMBINE_GRENADE_FLUSH_DIST 256.0 // Don't try to flush an enemy who has moved farther than this distance from the last place I saw him. +#endif #define COMBINE_LIMP_HEALTH 20 +#ifndef MAPBASE #define COMBINE_MIN_GRENADE_CLEAR_DIST 250 +#endif #define COMBINE_EYE_STANDING_POSITION Vector( 0, 0, 66 ) #define COMBINE_GUN_STANDING_POSITION Vector( 0, 0, 57 ) @@ -60,7 +74,11 @@ int g_fCombineQuestion; // true if an idle grunt asked a question. Cleared wh //----------------------------------------------------------------------------- // This is the index to the name of the shotgun's classname in the string pool // so that we can get away with an integer compare rather than a string compare. +#ifdef MAPBASE +#define s_iszShotgunClassname gm_isz_class_Shotgun +#else string_t s_iszShotgunClassname; +#endif //----------------------------------------------------------------------------- // Interactions @@ -73,13 +91,17 @@ int g_interactionCombineBash = 0; // melee bash attack #define COMBINE_AE_RELOAD ( 2 ) #define COMBINE_AE_KICK ( 3 ) #define COMBINE_AE_AIM ( 4 ) +#ifndef MAPBASE #define COMBINE_AE_GREN_TOSS ( 7 ) +#endif #define COMBINE_AE_GREN_LAUNCH ( 8 ) #define COMBINE_AE_GREN_DROP ( 9 ) #define COMBINE_AE_CAUGHT_ENEMY ( 10) // grunt established sight with an enemy (player only) that had previously eluded the squad. +#ifndef MAPBASE int COMBINE_AE_BEGIN_ALTFIRE; int COMBINE_AE_ALTFIRE; +#endif //========================================================= // Combine activities @@ -91,12 +113,20 @@ int COMBINE_AE_ALTFIRE; //Activity ACT_COMBINE_WALKING_AR2; //Activity ACT_COMBINE_STANDING_SHOTGUN; //Activity ACT_COMBINE_CROUCHING_SHOTGUN; +#ifndef SHARED_COMBINE_ACTIVITIES Activity ACT_COMBINE_THROW_GRENADE; +#endif Activity ACT_COMBINE_LAUNCH_GRENADE; Activity ACT_COMBINE_BUGBAIT; +#ifndef SHARED_COMBINE_ACTIVITIES Activity ACT_COMBINE_AR2_ALTFIRE; +#endif Activity ACT_WALK_EASY; Activity ACT_WALK_MARCH; +#ifdef MAPBASE +Activity ACT_IDLE_UNARMED; +Activity ACT_WALK_UNARMED; +#endif // ----------------------------------------------- // > Squad slots @@ -114,6 +144,9 @@ enum TacticalVariant_T TACTICAL_VARIANT_DEFAULT = 0, TACTICAL_VARIANT_PRESSURE_ENEMY, // Always try to close in on the player. TACTICAL_VARIANT_PRESSURE_ENEMY_UNTIL_CLOSE, // Act like VARIANT_PRESSURE_ENEMY, but go to VARIANT_DEFAULT once within 30 feet +#ifdef MAPBASE + TACTICAL_VARIANT_GRENADE_HAPPY, // Throw grenades as if you're fighting a turret +#endif }; enum PathfindingVariant_T @@ -135,20 +168,32 @@ BEGIN_DATADESC( CNPC_Combine ) DEFINE_FIELD( m_nKickDamage, FIELD_INTEGER ), DEFINE_FIELD( m_vecTossVelocity, FIELD_VECTOR ), +#ifndef MAPBASE DEFINE_FIELD( m_hForcedGrenadeTarget, FIELD_EHANDLE ), +#endif DEFINE_FIELD( m_bShouldPatrol, FIELD_BOOLEAN ), DEFINE_FIELD( m_bFirstEncounter, FIELD_BOOLEAN ), DEFINE_FIELD( m_flNextPainSoundTime, FIELD_TIME ), DEFINE_FIELD( m_flNextAlertSoundTime, FIELD_TIME ), +#ifndef MAPBASE DEFINE_FIELD( m_flNextGrenadeCheck, FIELD_TIME ), +#endif DEFINE_FIELD( m_flNextLostSoundTime, FIELD_TIME ), DEFINE_FIELD( m_flAlertPatrolTime, FIELD_TIME ), +#ifndef MAPBASE DEFINE_FIELD( m_flNextAltFireTime, FIELD_TIME ), +#endif DEFINE_FIELD( m_nShots, FIELD_INTEGER ), DEFINE_FIELD( m_flShotDelay, FIELD_FLOAT ), DEFINE_FIELD( m_flStopMoveShootTime, FIELD_TIME ), +#ifndef MAPBASE // See ai_grenade.h DEFINE_KEYFIELD( m_iNumGrenades, FIELD_INTEGER, "NumGrenades" ), +#else +DEFINE_INPUT( m_bUnderthrow, FIELD_BOOLEAN, "UnderthrowGrenades" ), +#endif +#ifndef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM DEFINE_EMBEDDED( m_Sentences ), +#endif // m_AssaultBehavior (auto saved by AI) // m_StandoffBehavior (auto saved by AI) @@ -167,11 +212,23 @@ DEFINE_INPUTFUNC( FIELD_STRING, "Assault", InputAssault ), DEFINE_INPUTFUNC( FIELD_VOID, "HitByBugbait", InputHitByBugbait ), +#ifndef MAPBASE DEFINE_INPUTFUNC( FIELD_STRING, "ThrowGrenadeAtTarget", InputThrowGrenadeAtTarget ), +#else +DEFINE_INPUTFUNC( FIELD_BOOLEAN, "SetElite", InputSetElite ), + +DEFINE_INPUTFUNC( FIELD_VOID, "DropGrenade", InputDropGrenade ), + +DEFINE_INPUTFUNC( FIELD_INTEGER, "SetTacticalVariant", InputSetTacticalVariant ), + +DEFINE_AIGRENADE_DATADESC() +#endif DEFINE_FIELD( m_iLastAnimEventHandled, FIELD_INTEGER ), DEFINE_FIELD( m_fIsElite, FIELD_BOOLEAN ), +#ifndef MAPBASE DEFINE_FIELD( m_vecAltFireTarget, FIELD_VECTOR ), +#endif DEFINE_KEYFIELD( m_iTacticalVariant, FIELD_INTEGER, "tacticalvariant" ), DEFINE_KEYFIELD( m_iPathfindingVariant, FIELD_INTEGER, "pathfindingvariant" ), @@ -196,7 +253,9 @@ bool CNPC_Combine::CreateComponents() if ( !BaseClass::CreateComponents() ) return false; +#ifndef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM m_Sentences.Init( this, "NPC_Combine.SentenceParameters" ); +#endif return true; } @@ -249,6 +308,7 @@ void CNPC_Combine::InputHitByBugbait( inputdata_t &inputdata ) SetCondition( COND_COMBINE_HIT_BY_BUGBAIT ); } +#ifndef MAPBASE //----------------------------------------------------------------------------- // Purpose: Force the combine soldier to throw a grenade at the target // If I'm a combine elite, fire my combine ball at the target instead. @@ -260,7 +320,11 @@ void CNPC_Combine::InputThrowGrenadeAtTarget( inputdata_t &inputdata ) if ( m_NPCState == NPC_STATE_SCRIPT && m_hCine ) return; +#ifdef MAPBASE + CBaseEntity *pEntity = gEntList.FindEntityByName( NULL, inputdata.value.String(), this, inputdata.pActivator, inputdata.pCaller ); +#else CBaseEntity *pEntity = gEntList.FindEntityByName( NULL, inputdata.value.String(), NULL, inputdata.pActivator, inputdata.pCaller ); +#endif if ( !pEntity ) { DevMsg("%s (%s) received ThrowGrenadeAtTarget input, but couldn't find target entity '%s'\n", GetClassname(), GetDebugName(), inputdata.value.String() ); @@ -272,6 +336,35 @@ void CNPC_Combine::InputThrowGrenadeAtTarget( inputdata_t &inputdata ) ClearSchedule( "Told to throw grenade via input" ); } +#endif + +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Instant transformation of arsenal from grenades to energy balls, or vice versa +//----------------------------------------------------------------------------- +void CNPC_Combine::InputSetElite( inputdata_t &inputdata ) +{ + m_fIsElite = inputdata.value.Bool(); +} + +//----------------------------------------------------------------------------- +// We were told to drop a grenade +//----------------------------------------------------------------------------- +void CNPC_Combine::InputDropGrenade( inputdata_t &inputdata ) +{ + SetCondition( COND_COMBINE_DROP_GRENADE ); + + ClearSchedule( "Told to drop grenade via input" ); +} + +//----------------------------------------------------------------------------- +// Changes our tactical variant easily +//----------------------------------------------------------------------------- +void CNPC_Combine::InputSetTacticalVariant( inputdata_t &inputdata ) +{ + m_iTacticalVariant = inputdata.value.Int(); +} +#endif //----------------------------------------------------------------------------- // Purpose: @@ -283,7 +376,9 @@ void CNPC_Combine::Precache() PrecacheScriptSound( "NPC_Combine.GrenadeLaunch" ); PrecacheScriptSound( "NPC_Combine.WeaponBash" ); +#ifndef MAPBASE // Now that we use WeaponSound(SPECIAL1), this isn't necessary PrecacheScriptSound( "Weapon_CombineGuard.Special1" ); +#endif BaseClass::Precache(); } @@ -292,7 +387,9 @@ void CNPC_Combine::Precache() //----------------------------------------------------------------------------- void CNPC_Combine::Activate() { +#ifndef MAPBASE s_iszShotgunClassname = FindPooledString( "weapon_shotgun" ); +#endif BaseClass::Activate(); } @@ -372,6 +469,7 @@ bool CNPC_Combine::CreateBehaviors() //----------------------------------------------------------------------------- void CNPC_Combine::PostNPCInit() { +#ifndef MAPBASE if( IsElite() ) { // Give a warning if a Combine Soldier is equipped with anything other than @@ -381,6 +479,7 @@ void CNPC_Combine::PostNPCInit() DevWarning("**Combine Elite Soldier MUST be equipped with AR2\n"); } } +#endif BaseClass::PostNPCInit(); } @@ -428,7 +527,9 @@ void CNPC_Combine::PrescheduleThink() BaseClass::PrescheduleThink(); // Speak any queued sentences +#ifndef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM m_Sentences.UpdateSentenceQueue(); +#endif if ( IsOnFire() ) { @@ -467,7 +568,7 @@ void CNPC_Combine::PrescheduleThink() } } - +#ifndef MAPBASE //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void CNPC_Combine::DelayAltFireAttack( float flDelay ) @@ -494,7 +595,11 @@ void CNPC_Combine::DelaySquadAltFireAttack( float flDelay ) { CNPC_Combine *pCombine = dynamic_cast(pSquadmate); +#ifdef MAPBASE + if( pCombine && pCombine->IsAltFireCapable() ) +#else if( pCombine && pCombine->IsElite() ) +#endif { pCombine->DelayAltFireAttack( flDelay ); } @@ -502,6 +607,7 @@ void CNPC_Combine::DelaySquadAltFireAttack( float flDelay ) pSquadmate = m_pSquad->GetNextMember( &iter ); } } +#endif //----------------------------------------------------------------------------- // Purpose: degrees to turn in 0.1 seconds @@ -586,6 +692,28 @@ Class_T CNPC_Combine::Classify ( void ) return CLASS_COMBINE; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +inline bool CNPC_Combine::IsElite( void ) +{ + //if (m_bUnderthrow) + // return false; + + return m_fIsElite; +} + +//----------------------------------------------------------------------------- +// Purpose: Function for gauging whether we're capable of alt-firing. +// It just returns IsElite() right now, but you could change it here. +//----------------------------------------------------------------------------- +inline bool CNPC_Combine::IsAltFireCapable( void ) +{ + return IsElite(); +} +#endif + //----------------------------------------------------------------------------- // Continuous movement tasks @@ -719,7 +847,6 @@ void CNPC_Combine::RunTaskChaseEnemyContinuously( const Task_t *pTask ) m_vSavePosition = pEnemy->WorldSpaceCenter(); } - //========================================================= // start task //========================================================= @@ -813,7 +940,11 @@ void CNPC_Combine::StartTask( const Task_t *pTask ) { m_flLastAttackTime = gpGlobals->curtime; +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_CMB_ANNOUNCE, SENTENCE_PRIORITY_HIGH ); +#else m_Sentences.Speak( "COMBINE_ANNOUNCE", SENTENCE_PRIORITY_HIGH ); +#endif // Wait two seconds SetWait( 2.0 ); @@ -837,7 +968,11 @@ void CNPC_Combine::StartTask( const Task_t *pTask ) } else { +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_CMB_THROWGRENADE, SENTENCE_PRIORITY_MEDIUM ); +#else m_Sentences.Speak( "COMBINE_THROW_GRENADE", SENTENCE_PRIORITY_MEDIUM ); +#endif SetActivity(ACT_IDLE); // Wait two seconds @@ -857,6 +992,9 @@ void CNPC_Combine::StartTask( const Task_t *pTask ) break; case TASK_COMBINE_GET_PATH_TO_FORCED_GREN_LOS: +#ifdef MAPBASE + StartTask_GetPathToForced(pTask); +#else { if ( !m_hForcedGrenadeTarget ) { @@ -895,6 +1033,7 @@ void CNPC_Combine::StartTask( const Task_t *pTask ) m_vInterruptSavePosition = posLos; } } +#endif break; case TASK_COMBINE_IGNORE_ATTACKS: @@ -912,6 +1051,9 @@ void CNPC_Combine::StartTask( const Task_t *pTask ) case TASK_COMBINE_DEFER_SQUAD_GRENADES: { +#ifdef MAPBASE + StartTask_DeferSquad(pTask); +#else if ( m_pSquad ) { // iterate my squad and stop everyone from throwing grenades for a little while. @@ -920,18 +1062,23 @@ void CNPC_Combine::StartTask( const Task_t *pTask ) CAI_BaseNPC *pSquadmate = m_pSquad ? m_pSquad->GetFirstMember( &iter ) : NULL; while ( pSquadmate ) { +#ifdef MAPBASE + pSquadmate->DelayGrenadeCheck(5); +#else CNPC_Combine *pCombine = dynamic_cast(pSquadmate); if( pCombine ) { pCombine->m_flNextGrenadeCheck = gpGlobals->curtime + 5; } +#endif pSquadmate = m_pSquad->GetNextMember( &iter ); } } TaskComplete(); +#endif break; } @@ -973,7 +1120,11 @@ void CNPC_Combine::StartTask( const Task_t *pTask ) m_pSquad->SquadRemember(bits_MEMORY_PLAYER_HURT); } +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_CMB_PLAYERHIT, SENTENCE_PRIORITY_INVALID ); +#else m_Sentences.Speak( "COMBINE_PLAYERHIT", SENTENCE_PRIORITY_INVALID ); +#endif JustMadeSound( SENTENCE_PRIORITY_HIGH ); } if ( pEntity->MyNPCPointer() ) @@ -1079,6 +1230,19 @@ void CNPC_Combine::RunTask( const Task_t *pTask ) } break; +#ifdef MAPBASE + case TASK_COMBINE_PLAY_SEQUENCE_FACE_ALTFIRE_TARGET: + RunTask_FaceAltFireTarget(pTask); + break; + + case TASK_COMBINE_FACE_TOSS_DIR: + RunTask_FaceTossDir(pTask); + break; + + case TASK_COMBINE_GET_PATH_TO_FORCED_GREN_LOS: + RunTask_GetPathToForced(pTask); + break; +#else case TASK_COMBINE_PLAY_SEQUENCE_FACE_ALTFIRE_TARGET: GetMotor()->SetIdealYawToTargetAndUpdate( m_vecAltFireTarget, AI_KEEP_YAW_SPEED ); @@ -1124,6 +1288,7 @@ void CNPC_Combine::RunTask( const Task_t *pTask ) } } break; +#endif case TASK_RANGE_ATTACK1: { @@ -1239,7 +1404,11 @@ void CNPC_Combine::Event_Killed( const CTakeDamageInfo &info ) } // In the Citadel we need to dissolve this +#ifdef MAPBASE + if ( PlayerHasMegaPhysCannon() && GlobalEntity_GetCounter("super_phys_gun") != 1 ) +#else if ( PlayerHasMegaPhysCannon() ) +#endif { CBaseCombatWeapon *pWeapon = static_cast(pItem); @@ -1291,6 +1460,37 @@ void CNPC_Combine::BuildScheduleTestBits( void ) } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +// Input : eNewActivity - +// Output : Activity +//----------------------------------------------------------------------------- +Activity CNPC_Combine::Weapon_TranslateActivity( Activity eNewActivity, bool *pRequired ) +{ + // We have differing low animations and ACT_CROUCHIDLE is not friendly to weapon translation. + // ACT_CROUCHIDLE is pretty much deprecated at this point anyway. + if (eNewActivity == ACT_CROUCHIDLE) + eNewActivity = ACT_RANGE_AIM_LOW; + + return BaseClass::Weapon_TranslateActivity(eNewActivity, pRequired); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +Activity CNPC_Combine::NPC_BackupActivity( Activity eNewActivity ) +{ + // Otherwise we move around, T-posing. + if (eNewActivity == ACT_WALK) + return ACT_WALK_UNARMED; + else if (eNewActivity == ACT_RUN) + return ACT_RUN_RIFLE; + + return BaseClass::NPC_BackupActivity( eNewActivity ); +} +#endif + //----------------------------------------------------------------------------- // Purpose: Translate base class activities into combot activites //----------------------------------------------------------------------------- @@ -1302,6 +1502,7 @@ Activity CNPC_Combine::NPC_TranslateActivity( Activity eNewActivity ) if (eNewActivity == ACT_RANGE_ATTACK2) { +#ifndef MAPBASE // grunt is going to a secondary long range attack. This may be a thrown // grenade or fired grenade, we must determine which and pick proper sequence if (Weapon_OwnsThisType( "weapon_grenadelauncher" ) ) @@ -1309,8 +1510,19 @@ Activity CNPC_Combine::NPC_TranslateActivity( Activity eNewActivity ) return ( Activity )ACT_COMBINE_LAUNCH_GRENADE; } else +#else + if (m_bUnderthrow) { + return ACT_SPECIAL_ATTACK1; + } + else +#endif + { +#ifdef SHARED_COMBINE_ACTIVITIES + return ACT_COMBINE_THROW_GRENADE; +#else return ( Activity )ACT_COMBINE_THROW_GRENADE; +#endif } } else if (eNewActivity == ACT_IDLE) @@ -1338,6 +1550,19 @@ Activity CNPC_Combine::NPC_TranslateActivity( Activity eNewActivity ) break; } } +#ifdef MAPBASE + else if (!GetActiveWeapon() && npc_combine_unarmed_anims.GetBool()) + { + if (eNewActivity == ACT_IDLE || eNewActivity == ACT_IDLE_ANGRY) + eNewActivity = ACT_IDLE_UNARMED; + else if (eNewActivity == ACT_WALK) + eNewActivity = ACT_WALK_UNARMED; + } + else if (eNewActivity == ACT_WALK && m_NPCState == NPC_STATE_IDLE && npc_combine_idle_walk_easy.GetBool()) + { + eNewActivity = ACT_WALK_EASY; + } +#endif return BaseClass::NPC_TranslateActivity( eNewActivity ); } @@ -1399,13 +1624,20 @@ void CNPC_Combine::AnnounceAssault(void) // Make sure player can see me if ( FVisible( pBCC ) ) { +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_CMB_ASSAULT ); +#else m_Sentences.Speak( "COMBINE_ASSAULT" ); +#endif } } void CNPC_Combine::AnnounceEnemyType( CBaseEntity *pEnemy ) { +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_CMB_ENEMY, SENTENCE_PRIORITY_HIGH ); +#else const char *pSentenceName = "COMBINE_MONST"; switch ( pEnemy->Classify() ) { @@ -1439,6 +1671,7 @@ void CNPC_Combine::AnnounceEnemyType( CBaseEntity *pEnemy ) } m_Sentences.Speak( pSentenceName, SENTENCE_PRIORITY_HIGH ); +#endif } void CNPC_Combine::AnnounceEnemyKill( CBaseEntity *pEnemy ) @@ -1446,6 +1679,11 @@ void CNPC_Combine::AnnounceEnemyKill( CBaseEntity *pEnemy ) if (!pEnemy ) return; +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + AI_CriteriaSet set; + ModifyOrAppendEnemyCriteria(set, pEnemy); + SpeakIfAllowed( TLK_CMB_KILLENEMY, set, SENTENCE_PRIORITY_HIGH ); +#else const char *pSentenceName = "COMBINE_KILL_MONST"; switch ( pEnemy->Classify() ) { @@ -1475,6 +1713,7 @@ void CNPC_Combine::AnnounceEnemyKill( CBaseEntity *pEnemy ) } m_Sentences.Speak( pSentenceName, SENTENCE_PRIORITY_HIGH ); +#endif } //----------------------------------------------------------------------------- @@ -1705,7 +1944,11 @@ int CNPC_Combine::SelectSchedule( void ) { Vector vecTarget = m_hForcedGrenadeTarget->WorldSpaceCenter(); +#ifdef MAPBASE + if ( IsAltFireCapable() ) +#else if ( IsElite() ) +#endif { if ( FVisible( m_hForcedGrenadeTarget ) ) { @@ -1776,7 +2019,11 @@ int CNPC_Combine::SelectSchedule( void ) { // I hear something dangerous, probably need to take cover. // dangerous sound nearby!, call it out +#ifndef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM const char *pSentenceName = "COMBINE_DANGER"; +#else + bool bGrenade = false; +#endif CBaseEntity *pSoundOwner = pSound->m_hOwner; if ( pSoundOwner ) @@ -1787,12 +2034,20 @@ int CNPC_Combine::SelectSchedule( void ) if ( IRelationType( pGrenade->GetThrower() ) != D_LI ) { // special case call out for enemy grenades +#ifndef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM pSentenceName = "COMBINE_GREN"; +#else + bGrenade = true; +#endif } } } +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_CMB_DANGER, UTIL_VarArgs( "grenade:%d", bGrenade ) ); +#else m_Sentences.Speak( pSentenceName, SENTENCE_PRIORITY_NORMAL, SENTENCE_CRITERIA_NORMAL ); +#endif // If the sound is approaching danger, I have no enemy, and I don't see it, turn to face. if( !GetEnemy() && pSound->IsSoundType(SOUND_CONTEXT_DANGER_APPROACH) && pSound->m_hOwner && !FInViewCone(pSound->GetSoundReactOrigin()) ) @@ -1924,7 +2179,11 @@ int CNPC_Combine::SelectScheduleAttack() // If I'm fighting a combine turret (it's been hacked to attack me), I can't really // hurt it with bullets, so become grenade happy. +#ifdef MAPBASE + if ( GetEnemy() && ( (IsUsingTacticalVariant(TACTICAL_VARIANT_GRENADE_HAPPY)) || GetEnemy()->ClassMatches(gm_isz_class_FloorTurret) ) ) +#else if ( GetEnemy() && GetEnemy()->Classify() == CLASS_COMBINE && FClassnameIs(GetEnemy(), "npc_turret_floor") ) +#endif { // Don't do this until I've been fighting the turret for a few seconds float flTimeAtFirstHand = GetEnemies()->TimeAtFirstHand(GetEnemy()); @@ -1938,6 +2197,15 @@ int CNPC_Combine::SelectScheduleAttack() } } +#ifdef MAPBASE + if (IsUsingTacticalVariant(TACTICAL_VARIANT_GRENADE_HAPPY)) + { + // Don't do turret charging during grenade happiness. + // I guess just do nothing and let the rest of the AI handle it. + } + else +#endif + // If we're not in the viewcone of the turret, run up and hit it. Do this a bit later to // give other squadmembers a chance to throw a grenade before I run in. if ( !GetEnemy()->MyNPCPointer()->FInViewCone( this ) && OccupyStrategySlot( SQUAD_SLOT_GRENADE1 ) ) @@ -2058,7 +2326,11 @@ int CNPC_Combine::TranslateSchedule( int scheduleType ) HasCondition(COND_CAN_RANGE_ATTACK2) && OccupyStrategySlot( SQUAD_SLOT_GRENADE1 ) ) { +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_CMB_THROWGRENADE ); +#else m_Sentences.Speak( "COMBINE_THROW_GRENADE" ); +#endif return SCHED_COMBINE_TOSS_GRENADE_COVER1; } else @@ -2237,6 +2509,13 @@ int CNPC_Combine::TranslateSchedule( int scheduleType ) Stand(); } +#ifdef MAPBASE + // SCHED_COMBINE_WAIT_IN_COVER uses INCOVER, but only gets out of it when the soldier moves. + // That seems to mess up shooting, so this Forget() attempts to fix that. + // I don't know if there's a better workaround. + Forget( bits_MEMORY_INCOVER ); +#endif + return SCHED_COMBINE_RANGE_ATTACK1; } case SCHED_RANGE_ATTACK2: @@ -2320,12 +2599,24 @@ void CNPC_Combine::HandleAnimEvent( animevent_t *pEvent ) { if ( pEvent->event == COMBINE_AE_BEGIN_ALTFIRE ) { +#ifdef MAPBASE + if (GetActiveWeapon()) + GetActiveWeapon()->WeaponSound(SPECIAL1); +#else EmitSound( "Weapon_CombineGuard.Special1" ); +#endif +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_CMB_THROWGRENADE, "altfire:1", SENTENCE_PRIORITY_MEDIUM ); +#endif handledEvent = true; } else if ( pEvent->event == COMBINE_AE_ALTFIRE ) { - if( IsElite() ) +#ifdef MAPBASE + if ( IsAltFireCapable() ) +#else + if ( IsElite() ) +#endif { animevent_t fakeEvent; @@ -2343,7 +2634,15 @@ void CNPC_Combine::HandleAnimEvent( animevent_t *pEvent ) // that makes sure the elite has grenades in order to fire a combine ball, we // preserve the legacy behavior while making it possible for a designer to prevent // elites from shooting combine balls by setting grenades to '0' in hammer. (sjb) EP2_OUTLAND_10 +#ifdef MAPBASE + // + // Here's a tip: In Mapbase, "OnThrowGrenade" is fired during alt-fire as well, fired by the weapon so it could pass its alt-fire projectile. + // So if you want elites to decrement on each grenade again, you could fire "!self > AddGrenades -1" every time an elite fires OnThrowGrenade. + // + // AddGrenades(-1); +#else // m_iNumGrenades--; +#endif } handledEvent = true; @@ -2367,8 +2666,12 @@ void CNPC_Combine::HandleAnimEvent( animevent_t *pEvent ) // We never actually run out of ammo, just need to refill the clip if (GetActiveWeapon()) { +#ifdef MAPBASE + GetActiveWeapon()->Reload_NPC(); +#else GetActiveWeapon()->WeaponSound( RELOAD_NPC ); GetActiveWeapon()->m_iClip1 = GetActiveWeapon()->GetMaxClip1(); +#endif GetActiveWeapon()->m_iClip2 = GetActiveWeapon()->GetMaxClip2(); } ClearCondition(COND_LOW_PRIMARY_AMMO); @@ -2395,13 +2698,24 @@ void CNPC_Combine::HandleAnimEvent( animevent_t *pEvent ) GetVectors( &forward, NULL, &up ); vecThrow = forward * 750 + up * 175; +#ifdef MAPBASE + CBaseEntity *pGrenade = Fraggrenade_Create( vecStart, vec3_angle, vecThrow, vecSpin, this, COMBINE_GRENADE_TIMER, true ); + m_OnThrowGrenade.Set(pGrenade, pGrenade, this); +#else Fraggrenade_Create( vecStart, vec3_angle, vecThrow, vecSpin, this, COMBINE_GRENADE_TIMER, true ); +#endif } else { // Use the Velocity that AI gave us. +#ifdef MAPBASE + CBaseEntity *pGrenade = Fraggrenade_Create( vecStart, vec3_angle, m_vecTossVelocity, vecSpin, this, COMBINE_GRENADE_TIMER, true ); + m_OnThrowGrenade.Set(pGrenade, pGrenade, this); + AddGrenades(-1, pGrenade); +#else Fraggrenade_Create( vecStart, vec3_angle, m_vecTossVelocity, vecSpin, this, COMBINE_GRENADE_TIMER, true ); m_iNumGrenades--; +#endif } // wait six seconds before even looking again to see if a grenade can be thrown. @@ -2429,10 +2743,34 @@ void CNPC_Combine::HandleAnimEvent( animevent_t *pEvent ) case COMBINE_AE_GREN_DROP: { Vector vecStart; +#ifdef MAPBASE + QAngle angStart; + m_vecTossVelocity.x = 15; + m_vecTossVelocity.y = 0; + m_vecTossVelocity.z = 0; + + GetAttachment( "lefthand", vecStart, angStart ); + + CBaseEntity *pGrenade = NULL; + if (m_NPCState == NPC_STATE_SCRIPT) + { + // While scripting, have the grenade face upwards like it was originally and also don't decrement grenade count. + pGrenade = Fraggrenade_Create( vecStart, vec3_angle, m_vecTossVelocity, vec3_origin, this, COMBINE_GRENADE_TIMER, true ); + } + else + { + pGrenade = Fraggrenade_Create( vecStart, angStart, m_vecTossVelocity, vec3_origin, this, COMBINE_GRENADE_TIMER, true ); + AddGrenades(-1); + } + + // Well, technically we're not throwing, but...still. + m_OnThrowGrenade.Set(pGrenade, pGrenade, this); +#else GetAttachment( "lefthand", vecStart ); Fraggrenade_Create( vecStart, vec3_angle, m_vecTossVelocity, vec3_origin, this, COMBINE_GRENADE_TIMER, true ); m_iNumGrenades--; +#endif } handledEvent = true; break; @@ -2463,13 +2801,21 @@ void CNPC_Combine::HandleAnimEvent( animevent_t *pEvent ) } } +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_CMB_KICK ); +#else m_Sentences.Speak( "COMBINE_KICK" ); +#endif handledEvent = true; break; } case COMBINE_AE_CAUGHT_ENEMY: +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_CMB_ENEMY ); //SpeakIfAllowed( "TLK_CMB_ALERT" ); +#else m_Sentences.Speak( "COMBINE_ALERT" ); +#endif handledEvent = true; break; @@ -2556,16 +2902,82 @@ void CNPC_Combine::SpeakSentence( int sentenceType ) // If I'm moving more than 20ft, I need to talk about it if ( GetNavigator()->GetPath()->GetPathLength() > 20 * 12.0f ) { +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_CMB_FLANK ); +#else m_Sentences.Speak( "COMBINE_FLANK" ); +#endif } break; } } +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM +//========================================================= +//========================================================= +inline bool CNPC_Combine::SpeakIfAllowed( const char *concept, SentencePriority_t sentencepriority, SentenceCriteria_t sentencecriteria ) +{ + return SpeakIfAllowed( concept, NULL, sentencepriority, sentencecriteria ); +} + +//========================================================= +//========================================================= +bool CNPC_Combine::SpeakIfAllowed( const char *concept, const char *modifiers, SentencePriority_t sentencepriority, SentenceCriteria_t sentencecriteria ) +{ + AI_CriteriaSet set; + if (modifiers) + { + GetExpresser()->MergeModifiers(set, modifiers); + } + return SpeakIfAllowed( concept, set, sentencepriority, sentencecriteria ); +} + +//========================================================= +//========================================================= +bool CNPC_Combine::SpeakIfAllowed( const char *concept, AI_CriteriaSet& modifiers, SentencePriority_t sentencepriority, SentenceCriteria_t sentencecriteria ) +{ + if ( sentencepriority != SENTENCE_PRIORITY_INVALID && !FOkToMakeSound( sentencepriority ) ) + return false; + + if ( !GetExpresser()->CanSpeakConcept( concept ) ) + return false; + + if ( Speak( concept, modifiers ) ) + { + JustMadeSound( sentencepriority, 2.0f /*GetTimeSpeechComplete()*/ ); + return true; + } + + return false; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CNPC_Combine::ModifyOrAppendCriteria( AI_CriteriaSet& set ) +{ + BaseClass::ModifyOrAppendCriteria( set ); + + set.AppendCriteria( "numgrenades", UTIL_VarArgs("%d", m_iNumGrenades) ); + + if (IsElite()) + { + set.AppendCriteria( "elite", "1" ); + } + else + { + set.AppendCriteria( "elite", "0" ); + } +} +#endif + //========================================================= // PainSound //========================================================= +#ifdef MAPBASE +void CNPC_Combine::PainSound ( const CTakeDamageInfo &info ) +#else void CNPC_Combine::PainSound ( void ) +#endif { // NOTE: The response system deals with this at the moment if ( GetFlags() & FL_DISSOLVING ) @@ -2573,6 +2985,11 @@ void CNPC_Combine::PainSound ( void ) if ( gpGlobals->curtime > m_flNextPainSoundTime ) { +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + AI_CriteriaSet set; + ModifyOrAppendDamageCriteria(set, info); + SpeakIfAllowed( TLK_CMB_PAIN, set, SENTENCE_PRIORITY_INVALID, SENTENCE_CRITERIA_ALWAYS ); +#else const char *pSentenceName = "COMBINE_PAIN"; float healthRatio = (float)GetHealth() / (float)GetMaxHealth(); if ( !HasMemory(bits_MEMORY_PAIN_LIGHT_SOUND) && healthRatio > 0.9 ) @@ -2587,6 +3004,7 @@ void CNPC_Combine::PainSound ( void ) } m_Sentences.Speak( pSentenceName, SENTENCE_PRIORITY_INVALID, SENTENCE_CRITERIA_ALWAYS ); +#endif m_flNextPainSoundTime = gpGlobals->curtime + 1; } } @@ -2602,6 +3020,12 @@ void CNPC_Combine::LostEnemySound( void) if ( gpGlobals->curtime <= m_flNextLostSoundTime ) return; +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + if (SpeakIfAllowed( TLK_CMB_LOSTENEMY, UTIL_VarArgs("lastseenenemy:%d", GetEnemyLastTimeSeen()) )) + { + m_flNextLostSoundTime = gpGlobals->curtime + random->RandomFloat(5.0,15.0); + } +#else const char *pSentence; if (!(CBaseEntity*)GetEnemy() || gpGlobals->curtime - GetEnemyLastTimeSeen() > 10) { @@ -2616,6 +3040,7 @@ void CNPC_Combine::LostEnemySound( void) { m_flNextLostSoundTime = gpGlobals->curtime + random->RandomFloat(5.0,15.0); } +#endif } //----------------------------------------------------------------------------- @@ -2626,7 +3051,11 @@ void CNPC_Combine::LostEnemySound( void) //----------------------------------------------------------------------------- void CNPC_Combine::FoundEnemySound( void) { +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_CMB_REFINDENEMY, SENTENCE_PRIORITY_HIGH ); +#else m_Sentences.Speak( "COMBINE_REFIND_ENEMY", SENTENCE_PRIORITY_HIGH ); +#endif } //----------------------------------------------------------------------------- @@ -2641,7 +3070,11 @@ void CNPC_Combine::AlertSound( void) { if ( gpGlobals->curtime > m_flNextAlertSoundTime ) { +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_CMB_GOALERT, SENTENCE_PRIORITY_HIGH ); +#else m_Sentences.Speak( "COMBINE_GO_ALERT", SENTENCE_PRIORITY_HIGH ); +#endif m_flNextAlertSoundTime = gpGlobals->curtime + 10.0f; } } @@ -2651,16 +3084,22 @@ void CNPC_Combine::AlertSound( void) //========================================================= void CNPC_Combine::NotifyDeadFriend ( CBaseEntity* pFriend ) { +#ifndef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM if ( GetSquad()->NumMembers() < 2 ) { m_Sentences.Speak( "COMBINE_LAST_OF_SQUAD", SENTENCE_PRIORITY_INVALID, SENTENCE_CRITERIA_NORMAL ); JustMadeSound(); return; } +#endif // relaxed visibility test so that guys say this more often //if( FInViewCone( pFriend ) && FVisible( pFriend ) ) { +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_CMB_MANDOWN ); +#else m_Sentences.Speak( "COMBINE_MAN_DOWN" ); +#endif } BaseClass::NotifyDeadFriend(pFriend); } @@ -2668,13 +3107,23 @@ void CNPC_Combine::NotifyDeadFriend ( CBaseEntity* pFriend ) //========================================================= // DeathSound //========================================================= +#ifdef MAPBASE +void CNPC_Combine::DeathSound ( const CTakeDamageInfo &info ) +#else void CNPC_Combine::DeathSound ( void ) +#endif { +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + AI_CriteriaSet set; + ModifyOrAppendDamageCriteria(set, info); + SpeakIfAllowed(TLK_CMB_DIE, set, SENTENCE_PRIORITY_INVALID, SENTENCE_CRITERIA_ALWAYS); +#else // NOTE: The response system deals with this at the moment if ( GetFlags() & FL_DISSOLVING ) return; m_Sentences.Speak( "COMBINE_DIE", SENTENCE_PRIORITY_INVALID, SENTENCE_CRITERIA_ALWAYS ); +#endif } //========================================================= @@ -2686,6 +3135,11 @@ void CNPC_Combine::IdleSound( void ) { if (!g_fCombineQuestion) { +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + int iRandom = random->RandomInt(0, 2); + SpeakIfAllowed( TLK_CMB_QUESTION, UTIL_VarArgs("combinequestion:%d", iRandom) ); + g_fCombineQuestion = iRandom + 1; +#else // ask question or make statement switch (random->RandomInt(0,2)) { @@ -2707,9 +3161,14 @@ void CNPC_Combine::IdleSound( void ) m_Sentences.Speak( "COMBINE_IDLE" ); break; } +#endif } else { +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_CMB_ANSWER, UTIL_VarArgs("combinequestion:%d", g_fCombineQuestion) ); + g_fCombineQuestion = 0; +#else switch (g_fCombineQuestion) { case 1: // check in @@ -2725,6 +3184,7 @@ void CNPC_Combine::IdleSound( void ) } break; } +#endif } } } @@ -2744,6 +3204,7 @@ int CNPC_Combine::RangeAttack2Conditions( float flDot, float flDist ) return COND_NONE; } +#ifndef MAPBASE //----------------------------------------------------------------------------- // Purpose: Return true if the combine has grenades, hasn't checked lately, and // can throw a grenade at the target point. @@ -2858,12 +3319,17 @@ bool CNPC_Combine::CheckCanThrowGrenade( const Vector &vecTarget ) return false; } } +#endif //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- bool CNPC_Combine::CanAltFireEnemy( bool bUseFreeKnowledge ) { - if (!IsElite() ) +#ifdef MAPBASE + if ( !IsAltFireCapable() ) +#else + if ( !IsElite() ) +#endif return false; if (IsCrouching()) @@ -2884,7 +3350,14 @@ bool CNPC_Combine::CanAltFireEnemy( bool bUseFreeKnowledge ) CBaseEntity *pEnemy = GetEnemy(); +#ifdef MAPBASE + // "Our weapons alone cannot take down the antlion guard!" + // "Wait, you're an elite, don't you have, like, disintegration balls or somethi--" + // "SHUT UP!" + if ( npc_combine_altfire_alliesonly.GetBool() && !pEnemy->IsPlayer() && (!pEnemy->IsNPC() || !pEnemy->MyNPCPointer()->IsPlayerAlly()) ) +#else if( !pEnemy->IsPlayer() && (!pEnemy->IsNPC() || !pEnemy->MyNPCPointer()->IsPlayerAlly()) ) +#endif return false; Vector vecTarget; @@ -2913,14 +3386,23 @@ bool CNPC_Combine::CanAltFireEnemy( bool bUseFreeKnowledge ) } // Trace a hull about the size of the combine ball. +#ifdef MAPBASE + UTIL_TraceHull( vShootPosition, vecTarget, mins, maxs, MASK_COMBINE_BALL_LOS, this, COLLISION_GROUP_NONE, &tr ); +#else UTIL_TraceHull( vShootPosition, vecTarget, mins, maxs, MASK_SHOT, this, COLLISION_GROUP_NONE, &tr ); +#endif float flLength = (vShootPosition - vecTarget).Length(); flLength *= tr.fraction; //If the ball can travel at least 65% of the distance to the player then let the NPC shoot it. +#ifdef MAPBASE + // (unless it hit the world) + if( tr.fraction >= 0.65 && (!tr.m_pEnt || !tr.m_pEnt->IsWorld()) && flLength > 128.0f ) +#else if( tr.fraction >= 0.65 && flLength > 128.0f ) +#endif { // Target is valid m_vecAltFireTarget = vecTarget; @@ -2938,7 +3420,11 @@ bool CNPC_Combine::CanAltFireEnemy( bool bUseFreeKnowledge ) //----------------------------------------------------------------------------- bool CNPC_Combine::CanGrenadeEnemy( bool bUseFreeKnowledge ) { - if( IsElite() ) +#ifdef MAPBASE + if ( IsAltFireCapable() ) +#else + if ( IsElite() ) +#endif return false; CBaseEntity *pEnemy = GetEnemy(); @@ -3029,14 +3515,20 @@ Vector CNPC_Combine::EyePosition( void ) */ } +#ifndef MAPBASE //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- Vector CNPC_Combine::GetAltFireTarget() { +#ifdef MAPBASE + Assert( IsAltFireCapable() ); +#else Assert( IsElite() ); +#endif return m_vecAltFireTarget; } +#endif //----------------------------------------------------------------------------- // Purpose: @@ -3138,7 +3630,11 @@ void CNPC_Combine::OnEndMoveAndShoot() //----------------------------------------------------------------------------- WeaponProficiency_t CNPC_Combine::CalcWeaponProficiency( CBaseCombatWeapon *pWeapon ) { +#ifdef MAPBASE + if( pWeapon->ClassMatches( gm_isz_class_AR2 ) ) +#else if( FClassnameIs( pWeapon, "weapon_ar2" ) ) +#endif { if( hl2_episodic.GetBool() ) { @@ -3149,7 +3645,11 @@ WeaponProficiency_t CNPC_Combine::CalcWeaponProficiency( CBaseCombatWeapon *pWea return WEAPON_PROFICIENCY_GOOD; } } +#ifdef MAPBASE + else if( pWeapon->ClassMatches( gm_isz_class_Shotgun ) ) +#else else if( FClassnameIs( pWeapon, "weapon_shotgun" ) ) +#endif { if( m_nSkin != COMBINE_SKIN_SHOTGUNNER ) { @@ -3158,7 +3658,11 @@ WeaponProficiency_t CNPC_Combine::CalcWeaponProficiency( CBaseCombatWeapon *pWea return WEAPON_PROFICIENCY_PERFECT; } +#ifdef MAPBASE + else if( pWeapon->ClassMatches( gm_isz_class_SMG1 ) ) +#else else if( FClassnameIs( pWeapon, "weapon_smg1" ) ) +#endif { return WEAPON_PROFICIENCY_GOOD; } @@ -3300,12 +3804,20 @@ DECLARE_TASK( TASK_COMBINE_GET_PATH_TO_FORCED_GREN_LOS ) DECLARE_TASK( TASK_COMBINE_SET_STANDING ) //Activities +#ifndef SHARED_COMBINE_ACTIVITIES DECLARE_ACTIVITY( ACT_COMBINE_THROW_GRENADE ) +#endif DECLARE_ACTIVITY( ACT_COMBINE_LAUNCH_GRENADE ) DECLARE_ACTIVITY( ACT_COMBINE_BUGBAIT ) +#ifndef SHARED_COMBINE_ACTIVITIES DECLARE_ACTIVITY( ACT_COMBINE_AR2_ALTFIRE ) +#endif DECLARE_ACTIVITY( ACT_WALK_EASY ) DECLARE_ACTIVITY( ACT_WALK_MARCH ) +#ifdef MAPBASE +DECLARE_ACTIVITY( ACT_IDLE_UNARMED ) +DECLARE_ACTIVITY( ACT_WALK_UNARMED ) +#endif DECLARE_ANIMEVENT( COMBINE_AE_BEGIN_ALTFIRE ) DECLARE_ANIMEVENT( COMBINE_AE_ALTFIRE ) diff --git a/sp/src/game/server/hl2/npc_combine.h b/sp/src/game/server/hl2/npc_combine.h index ab166723c..f88bc95c 100644 --- a/sp/src/game/server/hl2/npc_combine.h +++ b/sp/src/game/server/hl2/npc_combine.h @@ -21,6 +21,14 @@ #include "ai_behavior_actbusy.h" #include "ai_sentence.h" #include "ai_baseactor.h" +#ifdef MAPBASE +#include "mapbase/ai_grenade.h" +#endif +#ifdef EXPANDED_RESPONSE_SYSTEM_USAGE +#include "mapbase/expandedrs_combine.h" +//#define CAI_Sentence CAI_SentenceTalker +#define COMBINE_SOLDIER_USES_RESPONSE_SYSTEM 1 +#endif // Used when only what combine to react to what the spotlight sees #define SF_COMBINE_NO_LOOK (1 << 16) @@ -30,11 +38,19 @@ //========================================================= // >> CNPC_Combine //========================================================= +#ifdef MAPBASE +class CNPC_Combine : public CAI_GrenadeUser +{ + DECLARE_DATADESC(); + DEFINE_CUSTOM_AI; + DECLARE_CLASS( CNPC_Combine, CAI_GrenadeUser ); +#else class CNPC_Combine : public CAI_BaseActor { DECLARE_DATADESC(); DEFINE_CUSTOM_AI; DECLARE_CLASS( CNPC_Combine, CAI_BaseActor ); +#endif public: CNPC_Combine(); @@ -42,8 +58,10 @@ public: // Create components virtual bool CreateComponents(); +#ifndef MAPBASE bool CanThrowGrenade( const Vector &vecTarget ); bool CheckCanThrowGrenade( const Vector &vecTarget ); +#endif virtual bool CanGrenadeEnemy( bool bUseFreeKnowledge = true ); virtual bool CanAltFireEnemy( bool bUseFreeKnowledge ); int GetGrenadeConditions( float flDot, float flDist ); @@ -69,7 +87,15 @@ public: void InputStopPatrolling( inputdata_t &inputdata ); void InputAssault( inputdata_t &inputdata ); void InputHitByBugbait( inputdata_t &inputdata ); +#ifndef MAPBASE void InputThrowGrenadeAtTarget( inputdata_t &inputdata ); +#else + void InputSetElite( inputdata_t &inputdata ); + + void InputDropGrenade( inputdata_t &inputdata ); + + void InputSetTacticalVariant( inputdata_t &inputdata ); +#endif bool UpdateEnemyMemory( CBaseEntity *pEnemy, const Vector &position, CBaseEntity *pInformer = NULL ); @@ -78,9 +104,17 @@ public: void Activate(); Class_T Classify( void ); +#ifdef MAPBASE + bool IsElite(); + bool IsAltFireCapable(); + const char* GetGrenadeAttachment() { return "lefthand"; } +#else bool IsElite() { return m_fIsElite; } +#endif +#ifndef MAPBASE void DelayAltFireAttack( float flDelay ); void DelaySquadAltFireAttack( float flDelay ); +#endif float MaxYawSpeed( void ); bool ShouldMoveAndShoot(); bool OverrideMoveFacing( const AILocalMoveGoal_t &move, float flInterval );; @@ -90,7 +124,9 @@ public: Vector EyeOffset( Activity nActivity ); Vector EyePosition( void ); Vector BodyTarget( const Vector &posSrc, bool bNoisy = true ); +#ifndef MAPBASE Vector GetAltFireTarget(); +#endif void StartTask( const Task_t *pTask ); void RunTask( const Task_t *pTask ); @@ -98,6 +134,10 @@ public: void GatherConditions(); virtual void PrescheduleThink(); +#ifdef MAPBASE + Activity Weapon_TranslateActivity( Activity baseAct, bool *pRequired = NULL ); + Activity NPC_BackupActivity( Activity eNewActivity ); +#endif Activity NPC_TranslateActivity( Activity eNewActivity ); void BuildScheduleTestBits( void ); virtual int SelectSchedule( void ); @@ -125,8 +165,13 @@ public: // ------------- // Sounds // ------------- +#ifdef MAPBASE + void DeathSound( const CTakeDamageInfo &info ); + void PainSound( const CTakeDamageInfo &info ); +#else void DeathSound( void ); void PainSound( void ); +#endif void IdleSound( void ); void AlertSound( void ); void LostEnemySound( void ); @@ -143,6 +188,12 @@ public: // Speaking void SpeakSentence( int sentType ); +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + bool SpeakIfAllowed( const char *concept, SentencePriority_t sentencepriority = SENTENCE_PRIORITY_NORMAL, SentenceCriteria_t sentencecriteria = SENTENCE_CRITERIA_IN_SQUAD ); + bool SpeakIfAllowed( const char *concept, const char *modifiers, SentencePriority_t sentencepriority = SENTENCE_PRIORITY_NORMAL, SentenceCriteria_t sentencecriteria = SENTENCE_CRITERIA_IN_SQUAD ); + bool SpeakIfAllowed( const char *concept, AI_CriteriaSet& modifiers, SentencePriority_t sentencepriority = SENTENCE_PRIORITY_NORMAL, SentenceCriteria_t sentencecriteria = SENTENCE_CRITERIA_IN_SQUAD ); + void ModifyOrAppendCriteria( AI_CriteriaSet& set ); +#endif virtual int TranslateSchedule( int scheduleType ); void OnStartSchedule( int scheduleType ); @@ -151,7 +202,9 @@ public: protected: void SetKickDamage( int nDamage ) { m_nKickDamage = nDamage; } +#ifndef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM CAI_Sentence< CNPC_Combine > *GetSentences() { return &m_Sentences; } +#endif private: //========================================================= @@ -257,26 +310,39 @@ private: private: int m_nKickDamage; +#ifndef MAPBASE Vector m_vecTossVelocity; EHANDLE m_hForcedGrenadeTarget; +#else + // Underthrow grenade at target + bool m_bUnderthrow; +#endif bool m_bShouldPatrol; bool m_bFirstEncounter;// only put on the handsign show in the squad's first encounter. // Time Variables float m_flNextPainSoundTime; float m_flNextAlertSoundTime; +#ifndef MAPBASE float m_flNextGrenadeCheck; +#endif float m_flNextLostSoundTime; float m_flAlertPatrolTime; // When to stop doing alert patrol +#ifndef MAPBASE float m_flNextAltFireTime; // Elites only. Next time to begin considering alt-fire attack. +#endif int m_nShots; float m_flShotDelay; float m_flStopMoveShootTime; +#ifndef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM CAI_Sentence< CNPC_Combine > m_Sentences; +#endif +#ifndef MAPBASE int m_iNumGrenades; +#endif CAI_AssaultBehavior m_AssaultBehavior; CCombineStandoffBehavior m_StandoffBehavior; CAI_FollowBehavior m_FollowBehavior; @@ -287,7 +353,9 @@ private: public: int m_iLastAnimEventHandled; bool m_fIsElite; +#ifndef MAPBASE Vector m_vecAltFireTarget; +#endif int m_iTacticalVariant; int m_iPathfindingVariant; diff --git a/sp/src/game/server/hl2/npc_combinecamera.cpp b/sp/src/game/server/hl2/npc_combinecamera.cpp index 26d1f07e..22e56379 100644 --- a/sp/src/game/server/hl2/npc_combinecamera.cpp +++ b/sp/src/game/server/hl2/npc_combinecamera.cpp @@ -547,7 +547,11 @@ bool CNPC_CombineCamera::FVisible(CBaseEntity *pEntity, int traceMask, CBaseEnti // If we hit something that's okay to hit anyway, still fire if ( pHitEntity && pHitEntity->MyCombatCharacterPointer() ) { +#ifdef MAPBASE + if (IRelationType(pHitEntity) <= D_FR) +#else if (IRelationType(pHitEntity) == D_HT) +#endif return true; } diff --git a/sp/src/game/server/hl2/npc_combinedropship.cpp b/sp/src/game/server/hl2/npc_combinedropship.cpp index ffe1befd..0e7e973c 100644 --- a/sp/src/game/server/hl2/npc_combinedropship.cpp +++ b/sp/src/game/server/hl2/npc_combinedropship.cpp @@ -175,6 +175,11 @@ public: virtual int OnTakeDamage( const CTakeDamageInfo &info ); virtual void Event_Killed( const CTakeDamageInfo &info ); +#ifdef MAPBASE + // NOTE: This function is shared across containers and dropships; this is the container's version + bool AllowsAnyDamage( const CTakeDamageInfo &info ); +#endif + private: enum { @@ -247,6 +252,11 @@ public: void MakeTracer( const Vector &vecTracerSrc, const trace_t &tr, int iTracerType ); int OnTakeDamage_Alive( const CTakeDamageInfo &inputInfo ); +#ifdef MAPBASE + // NOTE: This function is shared across containers and dropships; this is the dropship's version + bool AllowsAnyDamage() { return m_bAllowAnyDamage; } +#endif + // Input handlers. void InputLandLeave( inputdata_t &inputdata ); void InputLandTake( inputdata_t &inputdata ); @@ -254,6 +264,9 @@ public: void InputDropMines( inputdata_t &inputdata ); void InputDropStrider( inputdata_t &inputdata ); void InputDropAPC( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputDropCargo( inputdata_t &inputdata ); +#endif void InputPickup( inputdata_t &inputdata ); void InputSetGunRange( inputdata_t &inputdata ); @@ -317,6 +330,9 @@ private: EHANDLE m_hPickupTarget; int m_iContainerMoveType; bool m_bWaitForDropoffInput; +#ifdef MAPBASE + bool m_bDontEmitDanger; +#endif DECLARE_DATADESC(); DEFINE_CUSTOM_AI; @@ -614,6 +630,23 @@ void CCombineDropshipContainer::Event_Killed( const CTakeDamageInfo &info ) } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CCombineDropshipContainer::AllowsAnyDamage( const CTakeDamageInfo &info ) +{ + if (GetOwnerEntity()) + { + CNPC_CombineDropship *pDropship = assert_cast(GetOwnerEntity()); + return pDropship->AllowsAnyDamage() && pDropship->PassesDamageFilter(info); + } + + return false; +} +#endif + + //----------------------------------------------------------------------------- // Damage effects //----------------------------------------------------------------------------- @@ -623,7 +656,11 @@ int CCombineDropshipContainer::OnTakeDamage( const CTakeDamageInfo &info ) return 0; // Airboat guns + explosive damage is all that can hurt it +#ifdef MAPBASE + if (( info.GetDamageType() & (DMG_BLAST | DMG_AIRBOAT) ) == 0 && !AllowsAnyDamage(info) ) +#else if (( info.GetDamageType() & (DMG_BLAST | DMG_AIRBOAT) ) == 0 ) +#endif return 0; CTakeDamageInfo dmgInfo = info; @@ -764,6 +801,9 @@ BEGIN_DATADESC( CNPC_CombineDropship ) DEFINE_FIELD( m_hPickupTarget, FIELD_EHANDLE ), DEFINE_FIELD( m_iContainerMoveType, FIELD_INTEGER ), DEFINE_FIELD( m_bWaitForDropoffInput, FIELD_BOOLEAN ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bDontEmitDanger, FIELD_BOOLEAN, "DontEmitDanger" ), +#endif DEFINE_FIELD( m_hLandTarget, FIELD_EHANDLE ), DEFINE_FIELD( m_bHasDroppedOff, FIELD_BOOLEAN ), DEFINE_KEYFIELD( m_bInvulnerable, FIELD_BOOLEAN, "Invulnerable" ), @@ -810,6 +850,9 @@ BEGIN_DATADESC( CNPC_CombineDropship ) DEFINE_INPUTFUNC( FIELD_INTEGER, "DropMines", InputDropMines ), DEFINE_INPUTFUNC( FIELD_VOID, "DropStrider", InputDropStrider ), DEFINE_INPUTFUNC( FIELD_VOID, "DropAPC", InputDropAPC ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "DropCargo", InputDropCargo ), +#endif DEFINE_INPUTFUNC( FIELD_STRING, "Pickup", InputPickup ), DEFINE_INPUTFUNC( FIELD_FLOAT, "SetGunRange", InputSetGunRange ), DEFINE_INPUTFUNC( FIELD_STRING, "NPCFinishDustoff", InputNPCFinishDustoff ), @@ -896,6 +939,11 @@ void CNPC_CombineDropship::Spawn( void ) m_iMachineGunBaseAttachment = m_hContainer->LookupAttachment( "gun_base" ); // NOTE: gun_ref must have the same position as gun_base, but rotates with the gun m_iMachineGunRefAttachment = m_hContainer->LookupAttachment( "gun_ref" ); + +#ifdef MAPBASE + m_poseWeapon_Pitch = m_hContainer->LookupPoseParameter("weapon_pitch"); //added these two lines + m_poseWeapon_Yaw = m_hContainer->LookupPoseParameter("weapon_yaw"); +#endif } break; @@ -1399,7 +1447,11 @@ int CNPC_CombineDropship::OnTakeDamage_Alive( const CTakeDamageInfo &inputInfo ) // code above to see how to do it. if ( m_hContainer && !m_bInvulnerable ) { +#ifdef MAPBASE + if ( (inputInfo.GetDamageType() & DMG_AIRBOAT) || (m_iCrateType == CRATE_SOLDIER) || m_bAllowAnyDamage ) +#else if ( (inputInfo.GetDamageType() & DMG_AIRBOAT) || (m_iCrateType == CRATE_SOLDIER) ) +#endif { m_hContainer->TakeDamage( inputInfo ); } @@ -1754,12 +1806,60 @@ void CNPC_CombineDropship::InputDropAPC( inputdata_t &inputdata ) UTIL_SetSize( this, DROPSHIP_BBOX_MIN, DROPSHIP_BBOX_MAX ); +#ifdef MAPBASE + m_OnFinishedDropoff.FireOutput( m_hContainer, this ); + m_hContainer = NULL; +#else m_hContainer = NULL; m_OnFinishedDropoff.FireOutput( this, this ); +#endif SetLandingState( LANDING_NO ); m_hLandTarget = NULL; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CNPC_CombineDropship::InputDropCargo( inputdata_t &inputdata ) +{ + if ( !m_hContainer ) + { + Warning("npc_combinedropship %s was told to drop cargo, but isn't carrying any!\n", STRING(GetEntityName()) ); + return; + } + + m_hContainer->SetParent(NULL, 0); +// m_hContainer->SetOwnerEntity(NULL); + + Vector vecAbsVelocity = GetAbsVelocity(); + if ( vecAbsVelocity.z > 0 ) + { + vecAbsVelocity.z = 0.0f; + } + if ( m_hContainer->GetHealth() > 0 ) + { + vecAbsVelocity = vec3_origin; + } + + m_hContainer->SetAbsVelocity( vecAbsVelocity ); + m_hContainer->SetMoveType( (MoveType_t)m_iContainerMoveType ); + + // If the container has a physics object, remove it's shadow + IPhysicsObject *pPhysicsObject = m_hContainer->VPhysicsGetObject(); + if ( pPhysicsObject ) + { + pPhysicsObject->RemoveShadowController(); + } + + UTIL_SetSize( this, DROPSHIP_BBOX_MIN, DROPSHIP_BBOX_MAX ); + + m_OnFinishedDropoff.FireOutput( m_hContainer, this ); + m_hContainer = NULL; + SetLandingState( LANDING_NO ); + m_hLandTarget = NULL; +} +#endif + //----------------------------------------------------------------------------- // Drop the soldier container @@ -1796,13 +1896,19 @@ void CNPC_CombineDropship::DropSoldierContainer( ) UTIL_SetSize( this, DROPSHIP_BBOX_MIN, DROPSHIP_BBOX_MAX ); +#ifndef MAPBASE m_hContainer = NULL; +#endif SetLandingState( LANDING_NO ); m_hLandTarget = NULL; if ( m_bHasDroppedOff ) { +#ifdef MAPBASE + m_OnContainerShotDownAfterDropoff.FireOutput( m_hContainer, this ); +#else m_OnContainerShotDownAfterDropoff.FireOutput( this, this ); +#endif } else { @@ -1812,8 +1918,16 @@ void CNPC_CombineDropship::DropSoldierContainer( ) Msg("Dropship died, troops not unloaded: %d\n", iTroopsNotUnloaded ); } +#ifdef MAPBASE + m_OnContainerShotDownBeforeDropoff.Set( iTroopsNotUnloaded, m_hContainer, this ); +#else m_OnContainerShotDownBeforeDropoff.Set( iTroopsNotUnloaded, this, this ); +#endif } + +#ifdef MAPBASE + m_hContainer = NULL; +#endif } @@ -2082,10 +2196,17 @@ void CNPC_CombineDropship::PrescheduleThink( void ) // place danger sounds 1 foot above ground to get troops to scatter if they are below dropship Vector vecBottom = GetAbsOrigin(); vecBottom.z += WorldAlignMins().z; +#ifdef MAPBASE + if (!m_bDontEmitDanger) + { +#endif Vector vecSpot = vecBottom + Vector(0, 0, -1) * (flAltitude - 12 ); CSoundEnt::InsertSound( SOUND_DANGER, vecSpot, 400, 0.1, this, 0 ); CSoundEnt::InsertSound( SOUND_PHYSICS_DANGER, vecSpot, 400, 0.1, this, 1 ); // NDebugOverlay::Cross3D( vecSpot, -Vector(4,4,4), Vector(4,4,4), 255, 0, 255, false, 10.0f ); +#ifdef MAPBASE + } +#endif // now check to see if player is below us, if so, cause heat damage to them (i.e. get them to move) trace_t tr; @@ -2257,7 +2378,11 @@ void CNPC_CombineDropship::PrescheduleThink( void ) SetLandingState( LANDING_NO ); m_hLandTarget = NULL; m_bHasDroppedOff = true; +#ifdef MAPBASE + m_OnFinishedDropoff.FireOutput( m_hContainer, this ); +#else m_OnFinishedDropoff.FireOutput( this, this ); +#endif } if ( m_hContainer ) @@ -2317,7 +2442,11 @@ void CNPC_CombineDropship::PrescheduleThink( void ) m_hContainer->SetMoveType( MOVETYPE_PUSH ); m_hContainer->SetGroundEntity( NULL ); +#ifdef MAPBASE + m_OnFinishedPickup.FireOutput( m_hContainer, this ); +#else m_OnFinishedPickup.FireOutput( this, this ); +#endif SetLandingState( LANDING_NO ); } } @@ -2395,6 +2524,9 @@ void CNPC_CombineDropship::SpawnTroop( void ) QAngle vecDeployEndAngles; m_hContainer->GetAttachment( m_iAttachmentTroopDeploy, vecDeployEndPoint, vecDeployEndAngles ); vecDeployEndPoint = GetDropoffFinishPosition( vecDeployEndPoint, NULL, vecNPCMins, vecNPCMaxs ); +#ifdef MAPBASE + if (!m_bDontEmitDanger) +#endif CSoundEnt::InsertSound( SOUND_DANGER, vecDeployEndPoint, 120.0f, 2.0f, this ); // Make sure there are no NPCs on the spot diff --git a/sp/src/game/server/hl2/npc_combinegunship.cpp b/sp/src/game/server/hl2/npc_combinegunship.cpp index 25831053..dfe0aa20 100644 --- a/sp/src/game/server/hl2/npc_combinegunship.cpp +++ b/sp/src/game/server/hl2/npc_combinegunship.cpp @@ -51,6 +51,10 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" +#ifdef MAPBASE +#define BELLYBLAST +#endif + #define GUNSHIP_MSG_BIG_SHOT 1 #define GUNSHIP_MSG_STREAKS 2 @@ -370,6 +374,10 @@ private: int m_iDoSmokePuff; int m_iAmmoType; int m_iBurstSize; + +#ifdef MAPBASE + int m_iHealthIncrements; +#endif bool m_fBlindfire; bool m_fOmniscient; @@ -420,7 +428,11 @@ BEGIN_DATADESC( CNPC_CombineGunship ) DEFINE_FIELD( m_flNextGroundAttack,FIELD_TIME ), DEFINE_FIELD( m_bIsGroundAttacking,FIELD_BOOLEAN ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bCanGroundAttack, FIELD_BOOLEAN, "CanGroundAttack" ), +#else DEFINE_FIELD( m_bCanGroundAttack, FIELD_BOOLEAN ), +#endif DEFINE_FIELD( m_flGroundAttackTime,FIELD_TIME ), DEFINE_FIELD( m_pRotorWashModel, FIELD_CLASSPTR ), DEFINE_FIELD( m_pSmokeTrail, FIELD_EHANDLE ), @@ -437,6 +449,9 @@ BEGIN_DATADESC( CNPC_CombineGunship ) DEFINE_FIELD( m_iDoSmokePuff, FIELD_INTEGER ), DEFINE_FIELD( m_iAmmoType, FIELD_INTEGER ), DEFINE_FIELD( m_iBurstSize, FIELD_INTEGER ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_iHealthIncrements, FIELD_INTEGER, "HealthIncrements" ), +#endif DEFINE_FIELD( m_flBurstDelay, FIELD_FLOAT ), DEFINE_FIELD( m_fBlindfire, FIELD_BOOLEAN ), DEFINE_FIELD( m_fOmniscient, FIELD_BOOLEAN ), @@ -552,6 +567,11 @@ void CNPC_CombineGunship::Spawn( void ) m_iMaxHealth = m_iHealth = 100; +#ifdef MAPBASE + if (m_iHealthIncrements == 0) + m_iHealthIncrements = sk_gunship_health_increments.GetInt(); +#endif + m_flFieldOfView = -0.707; // 270 degrees m_fHelicopterFlags |= BITS_HELICOPTER_GUN_ON; @@ -601,8 +621,10 @@ void CNPC_CombineGunship::Spawn( void ) m_bPreFire = false; m_bInvulnerable = false; +#ifndef MAPBASE // Spawnflag has been replaced with KV // See if we should start being able to attack m_bCanGroundAttack = ( m_spawnflags & SF_GUNSHIP_NO_GROUND_ATTACK ) ? false : true; +#endif m_flEndDestructTime = 0; @@ -2831,7 +2853,13 @@ void CNPC_CombineGunship::MakeTracer( const Vector &vecTracerSrc, const trace_t void CNPC_CombineGunship::TraceAttack( const CTakeDamageInfo &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator ) { // Reflect bullets +#ifdef MAPBASE + // There's a keyvalue that allows any damage, but still reflect if the bullets wouldn't pass our damage filter. + if ( info.GetDamageType() & DMG_BULLET && + (!m_bAllowAnyDamage || !PassesDamageFilter(info)) ) +#else if ( info.GetDamageType() & DMG_BULLET ) +#endif { if ( random->RandomInt( 0, 2 ) == 0 ) { @@ -2912,7 +2940,11 @@ void CNPC_CombineGunship::FireDamageOutputsUpto( int iDamageNumber ) int CNPC_CombineGunship::OnTakeDamage_Alive( const CTakeDamageInfo &inputInfo ) { // Allow npc_kill to kill me +#ifdef MAPBASE + if ( inputInfo.GetDamageType() != DMG_GENERIC && !m_bAllowAnyDamage ) +#else if ( inputInfo.GetDamageType() != DMG_GENERIC ) +#endif { // Ignore mundane bullet damage. if ( ( inputInfo.GetDamageType() & DMG_BLAST ) == false ) @@ -2945,7 +2977,11 @@ int CNPC_CombineGunship::OnTakeDamage_Alive( const CTakeDamageInfo &inputInfo ) { // Take a percentage of our health away // Adjust health for damage +#ifdef MAPBASE + int iHealthIncrements = m_iHealthIncrements; +#else int iHealthIncrements = sk_gunship_health_increments.GetInt(); +#endif if ( g_pGameRules->IsSkillLevel( SKILL_EASY ) ) { iHealthIncrements = ceil( iHealthIncrements * 0.5 ); diff --git a/sp/src/game/server/hl2/npc_combines.cpp b/sp/src/game/server/hl2/npc_combines.cpp index 9addfbeb..314b26e1 100644 --- a/sp/src/game/server/hl2/npc_combines.cpp +++ b/sp/src/game/server/hl2/npc_combines.cpp @@ -122,11 +122,17 @@ void CNPC_CombineS::Precache() void CNPC_CombineS::DeathSound( const CTakeDamageInfo &info ) { +#ifdef COMBINE_SOLDIER_USES_RESPONSE_SYSTEM + AI_CriteriaSet set; + ModifyOrAppendDamageCriteria(set, info); + SpeakIfAllowed( TLK_CMB_DIE, set, SENTENCE_PRIORITY_INVALID, SENTENCE_CRITERIA_ALWAYS ); +#else // NOTE: The response system deals with this at the moment if ( GetFlags() & FL_DISSOLVING ) return; GetSentences()->Speak( "COMBINE_DIE", SENTENCE_PRIORITY_INVALID, SENTENCE_CRITERIA_ALWAYS ); +#endif } @@ -307,7 +313,15 @@ void CNPC_CombineS::Event_Killed( const CTakeDamageInfo &info ) if ( HasSpawnFlags( SF_COMBINE_NO_AR2DROP ) == false ) #endif { +#ifdef MAPBASE + CBaseEntity *pItem; + if (GetActiveWeapon() && FClassnameIs(GetActiveWeapon(), "weapon_smg1")) + pItem = DropItem( "item_ammo_smg1_grenade", WorldSpaceCenter()+RandomVector(-4,4), RandomAngle(0,360) ); + else + pItem = DropItem( "item_ammo_ar2_altfire", WorldSpaceCenter()+RandomVector(-4,4), RandomAngle(0,360) ); +#else CBaseEntity *pItem = DropItem( "item_ammo_ar2_altfire", WorldSpaceCenter()+RandomVector(-4,4), RandomAngle(0,360) ); +#endif if ( pItem ) { diff --git a/sp/src/game/server/hl2/npc_enemyfinder.cpp b/sp/src/game/server/hl2/npc_enemyfinder.cpp index 02afc08b..f8fc21bd 100644 --- a/sp/src/game/server/hl2/npc_enemyfinder.cpp +++ b/sp/src/game/server/hl2/npc_enemyfinder.cpp @@ -69,6 +69,10 @@ private: bool m_bEnemyStatus; +#ifdef MAPBASE + Class_T m_iClassify = CLASS_NONE; +#endif + COutputEvent m_OnLostEnemies; COutputEvent m_OnAcquireEnemies; @@ -103,6 +107,10 @@ BEGIN_DATADESC( CNPC_EnemyFinder ) DEFINE_FIELD( m_bEnemyStatus, FIELD_BOOLEAN ), +#ifdef MAPBASE + DEFINE_INPUT( m_iClassify, FIELD_INTEGER, "SetClassify" ), +#endif + DEFINE_INPUTFUNC( FIELD_VOID, "TurnOn", InputTurnOn ), DEFINE_INPUTFUNC( FIELD_VOID, "TurnOff", InputTurnOff ), @@ -417,7 +425,11 @@ bool CNPC_EnemyFinder::ShouldAlwaysThink() return true; CBasePlayer *pPlayer = AI_GetSinglePlayer(); +#ifdef MAPBASE + if ( pPlayer && IRelationType( pPlayer ) <= D_FR ) +#else if ( pPlayer && IRelationType( pPlayer ) == D_HT ) +#endif { float playerDistSqr = GetAbsOrigin().DistToSqr( pPlayer->GetAbsOrigin() ); @@ -454,6 +466,11 @@ void CNPC_EnemyFinder::GatherConditions() //----------------------------------------------------------------------------- Class_T CNPC_EnemyFinder::Classify( void ) { +#ifdef MAPBASE + if (m_iClassify != CLASS_NONE) + return m_iClassify; +#endif + if ( GetSquad() ) { AISquadIter_t iter; diff --git a/sp/src/game/server/hl2/npc_fastzombie.cpp b/sp/src/game/server/hl2/npc_fastzombie.cpp index 0ecd7155..0e15e2a8 100644 --- a/sp/src/game/server/hl2/npc_fastzombie.cpp +++ b/sp/src/game/server/hl2/npc_fastzombie.cpp @@ -61,6 +61,12 @@ enum COND_FASTZOMBIE_CLIMB_TOUCH = LAST_BASE_ZOMBIE_CONDITION, }; +#ifdef MAPBASE +ConVar sk_zombie_fast_health( "sk_zombie_fast_health", "50"); +ConVar sk_zombie_fast_dmg_one_slash( "sk_zombie_fast_dmg_claw","3"); +ConVar sk_zombie_fast_dmg_both_slash( "sk_zombie_fast_dmg_leap","5"); +#endif + envelopePoint_t envFastZombieVolumeJump[] = { { 1.0f, 1.0f, @@ -255,7 +261,9 @@ public: void OnChangeActivity( Activity NewActivity ); void OnStateChange( NPC_STATE OldState, NPC_STATE NewState ); void Event_Killed( const CTakeDamageInfo &info ); +#ifndef MAPBASE bool ShouldBecomeTorso( const CTakeDamageInfo &info, float flDamageThreshold ); +#endif virtual Vector GetAutoAimCenter() { return WorldSpaceCenter() - Vector( 0, 0, 12.0f ); } @@ -652,7 +660,9 @@ void CFastZombie::Spawn( void ) m_fJustJumped = false; +#ifndef MAPBASE // Controlled by KV m_fIsTorso = m_fIsHeadless = false; +#endif if( FClassnameIs( this, "npc_fastzombie" ) ) { @@ -670,7 +680,11 @@ void CFastZombie::Spawn( void ) SetBloodColor( BLOOD_COLOR_YELLOW ); #endif // HL2_EPISODIC +#ifdef MAPBASE + m_iHealth = sk_zombie_fast_health.GetInt(); +#else m_iHealth = 50; +#endif m_flFieldOfView = 0.2; CapabilitiesClear(); @@ -1084,7 +1098,11 @@ void CFastZombie::HandleAnimEvent( animevent_t *pEvent ) right = right * -50; QAngle angle( -3, -5, -3 ); +#ifdef MAPBASE + ClawAttack( GetClawAttackRange(), sk_zombie_fast_dmg_one_slash.GetInt(), angle, right, ZOMBIE_BLOOD_RIGHT_HAND ); +#else ClawAttack( GetClawAttackRange(), 3, angle, right, ZOMBIE_BLOOD_RIGHT_HAND ); +#endif return; } @@ -1094,7 +1112,11 @@ void CFastZombie::HandleAnimEvent( animevent_t *pEvent ) AngleVectors( GetLocalAngles(), NULL, &right, NULL ); right = right * 50; QAngle angle( -3, 5, -3 ); +#ifdef MAPBASE + ClawAttack( GetClawAttackRange(), sk_zombie_fast_dmg_one_slash.GetInt(), angle, right, ZOMBIE_BLOOD_LEFT_HAND ); +#else ClawAttack( GetClawAttackRange(), 3, angle, right, ZOMBIE_BLOOD_LEFT_HAND ); +#endif return; } @@ -1480,7 +1502,11 @@ void CFastZombie::LeapAttackTouch( CBaseEntity *pOther ) forward *= 500; QAngle qaPunch( 15, random->RandomInt(-5,5), random->RandomInt(-5,5) ); +#ifdef MAPBASE + ClawAttack( GetClawAttackRange(), sk_zombie_fast_dmg_both_slash.GetInt(), qaPunch, forward, ZOMBIE_BLOOD_BOTH_HANDS ); +#else ClawAttack( GetClawAttackRange(), 5, qaPunch, forward, ZOMBIE_BLOOD_BOTH_HANDS ); +#endif SetTouch( NULL ); } @@ -1848,6 +1874,7 @@ void CFastZombie::Event_Killed( const CTakeDamageInfo &info ) BaseClass::Event_Killed( dInfo ); } +#ifndef MAPBASE //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- bool CFastZombie::ShouldBecomeTorso( const CTakeDamageInfo &info, float flDamageThreshold ) @@ -1868,6 +1895,7 @@ bool CFastZombie::ShouldBecomeTorso( const CTakeDamageInfo &info, float flDamage return false; } +#endif //============================================================================= #ifdef HL2_EPISODIC diff --git a/sp/src/game/server/hl2/npc_headcrab.cpp b/sp/src/game/server/hl2/npc_headcrab.cpp index 6e7d3e71..26c7dbfb 100644 --- a/sp/src/game/server/hl2/npc_headcrab.cpp +++ b/sp/src/game/server/hl2/npc_headcrab.cpp @@ -218,6 +218,10 @@ BEGIN_DATADESC( CBaseHeadcrab ) DEFINE_INPUTFUNC( FIELD_VOID, "StartHangingFromCeiling", InputStartHangingFromCeiling ), DEFINE_INPUTFUNC( FIELD_VOID, "DropFromCeiling", InputDropFromCeiling ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OnLeap, "OnLeap" ), +#endif + // Function Pointers DEFINE_THINKFUNC( EliminateRollAndPitch ), DEFINE_THINKFUNC( ThrowThink ), @@ -482,6 +486,11 @@ void CBaseHeadcrab::Leap( const Vector &vecVel ) m_bMidJump = true; SetThink( &CBaseHeadcrab::ThrowThink ); SetNextThink( gpGlobals->curtime ); + +#ifdef MAPBASE + // We usually leap at an enemy, so use that as the activator + m_OnLeap.FireOutput(GetEnemy(), this); +#endif } @@ -926,7 +935,11 @@ void CBaseHeadcrab::LeapTouch( CBaseEntity *pOther ) { m_bMidJump = false; +#ifdef MAPBASE + if ( IRelationType( pOther ) <= D_FR ) +#else if ( IRelationType( pOther ) == D_HT ) +#endif { // Don't hit if back on ground if ( !( GetFlags() & FL_ONGROUND ) ) diff --git a/sp/src/game/server/hl2/npc_headcrab.h b/sp/src/game/server/hl2/npc_headcrab.h index daf79b46..8c4103ad 100644 --- a/sp/src/game/server/hl2/npc_headcrab.h +++ b/sp/src/game/server/hl2/npc_headcrab.h @@ -149,6 +149,10 @@ protected: bool m_bHangingFromCeiling; float m_flIlluminatedTime; + +#ifdef MAPBASE + COutputEvent m_OnLeap; +#endif }; diff --git a/sp/src/game/server/hl2/npc_launcher.cpp b/sp/src/game/server/hl2/npc_launcher.cpp index 9e942862..817bab23 100644 --- a/sp/src/game/server/hl2/npc_launcher.cpp +++ b/sp/src/game/server/hl2/npc_launcher.cpp @@ -62,6 +62,9 @@ public: // Outputs // ---------------- COutputEvent m_OnLaunch; // Triggered when missile is launched. +#ifdef MAPBASE + COutputEHANDLE m_OutMissile; // Passes the missile. +#endif // ---------------- // Inputs @@ -126,6 +129,9 @@ BEGIN_DATADESC( CNPC_Launcher ) DEFINE_INPUTFUNC( FIELD_VOID, "ClearEnemyEntity", InputClearEnemy ), DEFINE_OUTPUT( m_OnLaunch, "OnLaunch" ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OutMissile, "OutMissile" ), +#endif // Function Pointers DEFINE_THINKFUNC( LauncherThink ), @@ -278,6 +284,13 @@ void CNPC_Launcher::LaunchGrenade( CBaseEntity* pEnemy ) pGrenade->SetDamage(m_flDamage); pGrenade->SetDamageRadius(m_flDamageRadius); pGrenade->Launch(m_flLaunchSpeed,m_sPathCornerName); + +#ifdef MAPBASE + if (GetOwnerEntity()) + pGrenade->SetOwnerEntity(GetOwnerEntity()); + + m_OutMissile.Set(pGrenade, pGrenade, this); +#endif } else { @@ -292,6 +305,13 @@ void CNPC_Launcher::LaunchGrenade( CBaseEntity* pEnemy ) pGrenade->SetDamage(m_flDamage); pGrenade->SetDamageRadius(m_flDamageRadius); pGrenade->Launch(this,pEnemy,vLaunchVelocity,m_flHomingSpeed,GetGravity(),m_nSmokeTrail); + +#ifdef MAPBASE + if (GetOwnerEntity()) + pGrenade->SetOwnerEntity(GetOwnerEntity()); + + m_OutMissile.Set(pGrenade, pGrenade, this); +#endif } CPASAttenuationFilter filter( this, 0.3 ); diff --git a/sp/src/game/server/hl2/npc_manhack.cpp b/sp/src/game/server/hl2/npc_manhack.cpp index feef84f8..c68add8c 100644 --- a/sp/src/game/server/hl2/npc_manhack.cpp +++ b/sp/src/game/server/hl2/npc_manhack.cpp @@ -78,6 +78,10 @@ #define MANHACK_CHARGE_MIN_DIST 200 +#if defined(MAPBASE) && defined(HL2_EPISODIC) +extern ConVar npc_alyx_interact_manhacks; +#endif + ConVar sk_manhack_health( "sk_manhack_health","0"); ConVar sk_manhack_melee_dmg( "sk_manhack_melee_dmg","0"); ConVar sk_manhack_v2( "sk_manhack_v2","1"); @@ -149,7 +153,11 @@ BEGIN_DATADESC( CNPC_Manhack ) DEFINE_FIELD( m_bGib, FIELD_BOOLEAN), DEFINE_FIELD( m_bHeld, FIELD_BOOLEAN), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bHackedByAlyx, FIELD_BOOLEAN, "Hacked" ), +#else DEFINE_FIELD( m_bHackedByAlyx, FIELD_BOOLEAN), +#endif DEFINE_FIELD( m_vecLoiterPosition, FIELD_POSITION_VECTOR), DEFINE_FIELD( m_fTimeNextLoiterPulse, FIELD_TIME), @@ -159,6 +167,9 @@ BEGIN_DATADESC( CNPC_Manhack ) DEFINE_FIELD( m_flBladeSpeed, FIELD_FLOAT), DEFINE_KEYFIELD( m_bIgnoreClipbrushes, FIELD_BOOLEAN, "ignoreclipbrushes" ), DEFINE_FIELD( m_hSmokeTrail, FIELD_EHANDLE), +#ifdef MAPBASE + DEFINE_FIELD( m_hPrevOwner, FIELD_EHANDLE ), +#endif // DEFINE_FIELD( m_pLightGlow, FIELD_CLASSPTR ), // DEFINE_FIELD( m_pEyeGlow, FIELD_CLASSPTR ), @@ -1519,7 +1530,11 @@ void CNPC_Manhack::Slice( CBaseEntity *pHitEntity, float flInterval, trace_t &tr pHitEntity->TakeDamage( info ); // Spawn some extra blood where we hit +#ifdef MAPBASE + if ( pHitEntity->BloodColor() == DONT_BLEED || (m_bHackedByAlyx && !pHitEntity->PassesDamageFilter(info)) ) +#else if ( pHitEntity->BloodColor() == DONT_BLEED ) +#endif { CEffectData data; Vector velocity = GetCurrentVelocity(); @@ -2453,7 +2468,9 @@ void CNPC_Manhack::Spawn(void) SetCollisionGroup( COLLISION_GROUP_NONE ); m_bHeld = false; +#ifndef MAPBASE m_bHackedByAlyx = false; +#endif StopLoitering(); } @@ -3007,6 +3024,11 @@ void CNPC_Manhack::OnPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t r } else { +#ifdef MAPBASE + // Store the previous owner in case of npc_maker + m_hPrevOwner.Set(GetOwnerEntity()); +#endif + // Suppress collisions between the manhack and the player; we're currently bumping // almost certainly because it's not purely a physics object. SetOwnerEntity( pPhysGunUser ); @@ -3023,7 +3045,13 @@ void CNPC_Manhack::OnPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t r void CNPC_Manhack::OnPhysGunDrop( CBasePlayer *pPhysGunUser, PhysGunDrop_t Reason ) { // Stop suppressing collisions between the manhack and the player +#ifndef MAPBASE SetOwnerEntity( NULL ); +#else + SetOwnerEntity( m_hPrevOwner ); + + m_hPrevOwner = NULL; +#endif m_bHeld = false; @@ -3088,6 +3116,20 @@ float CNPC_Manhack::GetMaxEnginePower() return 1.0f; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Option to restore Alyx's interactions with non-rollermines +//----------------------------------------------------------------------------- +bool CNPC_Manhack::CanInteractWith( CAI_BaseNPC *pUser ) +{ +#ifdef HL2_EPISODIC + return npc_alyx_interact_manhacks.GetBool(); +#else + return false; +#endif +} +#endif + //----------------------------------------------------------------------------- // Purpose: @@ -3199,16 +3241,44 @@ void CNPC_Manhack::SetEyeState( int state ) if ( m_pEyeGlow ) { //Toggle our state +#ifdef MAPBASE + // Something from Half-Laugh. + // Makes it easier to distinguish between hostile and friendly manhacks. + if( m_bHackedByAlyx ) + { + m_pEyeGlow->SetColor( 0, 0, 255 ); + m_pEyeGlow->SetScale( 0.35f, 0.6f ); + } + else + { + m_pEyeGlow->SetColor( 255, 128, 0 ); + m_pEyeGlow->SetScale( 0.15f, 0.1f ); + } +#else m_pEyeGlow->SetColor( 255, 128, 0 ); m_pEyeGlow->SetScale( 0.15f, 0.1f ); +#endif m_pEyeGlow->SetBrightness( 164, 0.1f ); m_pEyeGlow->m_nRenderFX = kRenderFxStrobeFast; } if ( m_pLightGlow ) { +#ifdef MAPBASE + if( m_bHackedByAlyx ) + { + m_pLightGlow->SetColor( 0, 0, 255 ); + m_pLightGlow->SetScale( 0.35f, 0.6f ); + } + else + { + m_pLightGlow->SetColor( 255, 128, 0 ); + m_pLightGlow->SetScale( 0.15f, 0.1f ); + } +#else m_pLightGlow->SetColor( 255, 128, 0 ); m_pLightGlow->SetScale( 0.15f, 0.1f ); +#endif m_pLightGlow->SetBrightness( 164, 0.1f ); m_pLightGlow->m_nRenderFX = kRenderFxStrobeFast; } diff --git a/sp/src/game/server/hl2/npc_manhack.h b/sp/src/game/server/hl2/npc_manhack.h index 17a3cedb..b2dec9b9 100644 --- a/sp/src/game/server/hl2/npc_manhack.h +++ b/sp/src/game/server/hl2/npc_manhack.h @@ -155,7 +155,11 @@ public: float GetMaxEnginePower(); // INPCInteractive Functions +#ifdef MAPBASE + virtual bool CanInteractWith( CAI_BaseNPC *pUser ); +#else virtual bool CanInteractWith( CAI_BaseNPC *pUser ) { return false; } // Disabled for now (sjb) +#endif virtual bool HasBeenInteractedWith() { return m_bHackedByAlyx; } virtual void NotifyInteraction( CAI_BaseNPC *pUser ) { @@ -163,6 +167,9 @@ public: KillSprites(0.0f); m_bHackedByAlyx = true; StartEye(); +#ifdef MAPBASE + m_OnHacked.FireOutput(pUser, this); +#endif } virtual void InputPowerdown( inputdata_t &inputdata ) @@ -254,6 +261,9 @@ private: CSprite *m_pLightGlow; CHandle m_hSmokeTrail; +#ifdef MAPBASE + EHANDLE m_hPrevOwner; +#endif int m_iPanel1; int m_iPanel2; diff --git a/sp/src/game/server/hl2/npc_metropolice.cpp b/sp/src/game/server/hl2/npc_metropolice.cpp index 01d66258..31de6e8e 100644 --- a/sp/src/game/server/hl2/npc_metropolice.cpp +++ b/sp/src/game/server/hl2/npc_metropolice.cpp @@ -19,6 +19,10 @@ #include "iservervehicle.h" #include "items.h" #include "hl2_gamerules.h" +#ifdef MAPBASE +#include "grenade_frag.h" +#include "mapbase/GlobalStrings.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -172,7 +176,9 @@ BEGIN_DATADESC( CNPC_MetroPolice ) DEFINE_KEYFIELD( m_fWeaponDrawn, FIELD_BOOLEAN, "weapondrawn" ), DEFINE_FIELD( m_LastShootSlot, FIELD_INTEGER ), DEFINE_EMBEDDED( m_TimeYieldShootSlot ), +#ifndef METROPOLICE_USES_RESPONSE_SYSTEM DEFINE_EMBEDDED( m_Sentences ), +#endif DEFINE_FIELD( m_bPlayerIsNear, FIELD_BOOLEAN ), DEFINE_FIELD( m_vecBurstTargetPos, FIELD_POSITION_VECTOR ), @@ -225,13 +231,32 @@ BEGIN_DATADESC( CNPC_MetroPolice ) DEFINE_KEYFIELD( m_iManhacks, FIELD_INTEGER, "manhacks" ), DEFINE_INPUTFUNC( FIELD_VOID, "EnableManhackToss", InputEnableManhackToss ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "DisableManhackToss", InputDisableManhackToss ), + DEFINE_INPUTFUNC( FIELD_VOID, "DeployManhack", InputDeployManhack ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "AddManhacks", InputAddManhacks ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetManhacks", InputSetManhacks ), +#endif DEFINE_INPUTFUNC( FIELD_STRING, "SetPoliceGoal", InputSetPoliceGoal ), DEFINE_INPUTFUNC( FIELD_VOID, "ActivateBaton", InputActivateBaton ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "AdministerJustice", InputAdministerJustice ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "AddWarnings", InputAddWarnings ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetWarnings", InputSetWarnings ), +#endif DEFINE_USEFUNC( PrecriminalUse ), DEFINE_OUTPUT( m_OnStunnedPlayer, "OnStunnedPlayer" ), DEFINE_OUTPUT( m_OnCupCopped, "OnCupCopped" ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OnHitByPhysicsObject, "OnHitByPhysicsObject" ), + DEFINE_OUTPUT( m_OutManhack, "OutManhack" ), +#endif + +#ifdef MAPBASE + DEFINE_AIGRENADE_DATADESC() +#endif END_DATADESC() @@ -333,7 +358,11 @@ public: if ( pBCC && pVictimBCC ) { // Can only damage other NPCs that we hate +#ifdef MAPBASE + if ( m_bDamageAnyNPC || pBCC->IRelationType( pEntity ) <= D_FR || pEntity->IsPlayer() ) +#else if ( m_bDamageAnyNPC || pBCC->IRelationType( pEntity ) == D_HT || pEntity->IsPlayer() ) +#endif { if ( info.GetDamage() ) { @@ -436,7 +465,11 @@ void CNPC_MetroPolice::NotifyDeadFriend( CBaseEntity* pFriend ) if ( pFriend == m_hManhack ) { +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + SpeakIfAllowed(TLK_COP_MANHACKKILLED, "my_manhack:1", SENTENCE_PRIORITY_NORMAL, SENTENCE_CRITERIA_NORMAL); +#else m_Sentences.Speak( "METROPOLICE_MANHACK_KILLED", SENTENCE_PRIORITY_NORMAL, SENTENCE_CRITERIA_NORMAL ); +#endif DevMsg("My manhack died!\n"); m_hManhack = NULL; return; @@ -452,6 +485,9 @@ void CNPC_MetroPolice::NotifyDeadFriend( CBaseEntity* pFriend ) m_nIdleChatterType = METROPOLICE_CHATTER_ASK_QUESTION; } +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + SpeakIfAllowed(TLK_COP_MANDOWN, SENTENCE_PRIORITY_MEDIUM, SENTENCE_CRITERIA_NORMAL); +#else if ( GetSquad()->NumMembers() < 2 ) { m_Sentences.Speak( "METROPOLICE_LAST_OF_SQUAD", SENTENCE_PRIORITY_MEDIUM, SENTENCE_CRITERIA_NORMAL ); @@ -459,6 +495,7 @@ void CNPC_MetroPolice::NotifyDeadFriend( CBaseEntity* pFriend ) } m_Sentences.Speak( "METROPOLICE_MAN_DOWN", SENTENCE_PRIORITY_MEDIUM ); +#endif } @@ -490,8 +527,10 @@ void CNPC_MetroPolice::PrescheduleThink( void ) { BaseClass::PrescheduleThink(); +#ifndef METROPOLICE_USES_RESPONSE_SYSTEM // Speak any queued sentences m_Sentences.UpdateSentenceQueue(); +#endif // Look at near players, always m_bPlayerIsNear = false; @@ -572,6 +611,11 @@ bool CNPC_MetroPolice::OverrideMoveFacing( const AILocalMoveGoal_t &move, float //----------------------------------------------------------------------------- void CNPC_MetroPolice::Precache( void ) { +#ifdef MAPBASE + // It doesn't matter if we can't find models/police.mdl in the string pool because then we know this NPC doesn't have that model. + if ( GetModelName() == NULL_STRING || GetModelName() == FindPooledString("models/police.mdl") ) + { +#endif if ( HasSpawnFlags( SF_NPC_START_EFFICIENT ) ) { SetModelName( AllocPooledString("models/police_cheaple.mdl" ) ); @@ -580,6 +624,9 @@ void CNPC_MetroPolice::Precache( void ) { SetModelName( AllocPooledString("models/police.mdl") ); } +#ifdef MAPBASE + } +#endif PrecacheModel( STRING( GetModelName() ) ); @@ -602,7 +649,9 @@ bool CNPC_MetroPolice::CreateComponents() if ( !BaseClass::CreateComponents() ) return false; +#ifndef METROPOLICE_USES_RESPONSE_SYSTEM m_Sentences.Init( this, "NPC_Metropolice.SentenceParameters" ); +#endif return true; } @@ -681,7 +730,11 @@ void CNPC_MetroPolice::Spawn( void ) pWeapon = GetActiveWeapon(); +#ifdef MAPBASE + if (!EntIsClass(pWeapon, gm_isz_class_Pistol) && !EntIsClass(pWeapon, gm_isz_class_357)) +#else if( !FClassnameIs( pWeapon, "weapon_pistol" ) ) +#endif { m_fWeaponDrawn = true; } @@ -706,7 +759,11 @@ void CNPC_MetroPolice::Spawn( void ) // Clear out spawnflag if we're missing the smg1 if( HasSpawnFlags( SF_METROPOLICE_ALWAYS_STITCH ) ) { +#ifdef MAPBASE + if ( !Weapon_OwnsThisType( STRING(gm_isz_class_SMG1) ) ) +#else if ( !Weapon_OwnsThisType( "weapon_smg1" ) ) +#endif { Warning( "Warning! Metrocop is trying to use the stitch behavior but he has no smg1!\n" ); RemoveSpawnFlags( SF_METROPOLICE_ALWAYS_STITCH ); @@ -752,6 +809,23 @@ void CNPC_MetroPolice::SpeakFuncTankSentence( int nSentenceType ) { switch ( nSentenceType ) { +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + case FUNCTANK_SENTENCE_MOVE_TO_MOUNT: + SpeakIfAllowed( TLK_COP_FT_APPROACH, SENTENCE_PRIORITY_MEDIUM ); + break; + + case FUNCTANK_SENTENCE_JUST_MOUNTED: + SpeakIfAllowed( TLK_COP_FT_MOUNT, SENTENCE_PRIORITY_HIGH ); + break; + + case FUNCTANK_SENTENCE_SCAN_FOR_ENEMIES: + SpeakIfAllowed( TLK_COP_FT_SCAN, SENTENCE_PRIORITY_NORMAL ); + break; + + case FUNCTANK_SENTENCE_DISMOUNTING: + SpeakIfAllowed( TLK_COP_FT_DISMOUNT, SENTENCE_PRIORITY_HIGH ); + break; +#else case FUNCTANK_SENTENCE_MOVE_TO_MOUNT: m_Sentences.Speak( "METROPOLICE_FT_APPROACH", SENTENCE_PRIORITY_MEDIUM ); break; @@ -767,6 +841,7 @@ void CNPC_MetroPolice::SpeakFuncTankSentence( int nSentenceType ) case FUNCTANK_SENTENCE_DISMOUNTING: m_Sentences.Speak( "METROPOLICE_FT_DISMOUNT", SENTENCE_PRIORITY_HIGH ); break; +#endif } } @@ -778,6 +853,31 @@ void CNPC_MetroPolice::SpeakStandoffSentence( int nSentenceType ) { switch ( nSentenceType ) { +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + case STANDOFF_SENTENCE_BEGIN_STANDOFF: + SpeakIfAllowed( TLK_COP_SO_BEGIN, SENTENCE_PRIORITY_HIGH, SENTENCE_CRITERIA_SQUAD_LEADER ); + break; + + case STANDOFF_SENTENCE_END_STANDOFF: + SpeakIfAllowed( TLK_COP_SO_END, SENTENCE_PRIORITY_HIGH, SENTENCE_CRITERIA_SQUAD_LEADER ); + break; + + case STANDOFF_SENTENCE_OUT_OF_AMMO: + AnnounceOutOfAmmo( ); + break; + + case STANDOFF_SENTENCE_FORCED_TAKE_COVER: + SpeakIfAllowed( TLK_COP_SO_END ); + break; + + case STANDOFF_SENTENCE_STAND_CHECK_TARGET: + if ( gm_flTimeLastSpokePeek != 0 && gpGlobals->curtime - gm_flTimeLastSpokePeek > 20 ) + { + SpeakIfAllowed( TLK_COP_SO_PEEK ); + gm_flTimeLastSpokePeek = gpGlobals->curtime; + } + break; +#else case STANDOFF_SENTENCE_BEGIN_STANDOFF: m_Sentences.Speak( "METROPOLICE_SO_BEGIN", SENTENCE_PRIORITY_HIGH, SENTENCE_CRITERIA_SQUAD_LEADER ); break; @@ -801,6 +901,7 @@ void CNPC_MetroPolice::SpeakStandoffSentence( int nSentenceType ) gm_flTimeLastSpokePeek = gpGlobals->curtime; } break; +#endif } } @@ -811,6 +912,37 @@ void CNPC_MetroPolice::SpeakAssaultSentence( int nSentenceType ) { switch ( nSentenceType ) { +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + case ASSAULT_SENTENCE_HIT_RALLY_POINT: + SpeakIfAllowed( TLK_COP_AS_HIT_RALLY, SENTENCE_PRIORITY_NORMAL ); + break; + + case ASSAULT_SENTENCE_HIT_ASSAULT_POINT: + SpeakIfAllowed( TLK_COP_AS_HIT_ASSAULT, SENTENCE_PRIORITY_NORMAL ); + break; + + case ASSAULT_SENTENCE_SQUAD_ADVANCE_TO_RALLY: + if ( SpeakIfAllowed( TLK_COP_AS_ADV_RALLY, SENTENCE_PRIORITY_MEDIUM, SENTENCE_CRITERIA_SQUAD_LEADER ) ) + { + GetSquad()->BroadcastInteraction( g_interactionMetrocopClearSentenceQueues, NULL ); + } + break; + + case ASSAULT_SENTENCE_SQUAD_ADVANCE_TO_ASSAULT: + if ( SpeakIfAllowed( TLK_COP_AS_ADV_ASSAULT, SENTENCE_PRIORITY_MEDIUM, SENTENCE_CRITERIA_SQUAD_LEADER ) ) + { + GetSquad()->BroadcastInteraction( g_interactionMetrocopClearSentenceQueues, NULL ); + } + break; + + case ASSAULT_SENTENCE_COVER_NO_AMMO: + AnnounceOutOfAmmo( ); + break; + + case ASSAULT_SENTENCE_UNDER_ATTACK: + SpeakIfAllowed( TLK_COP_GO_ALERT ); + break; +#else case ASSAULT_SENTENCE_HIT_RALLY_POINT: m_Sentences.SpeakQueued( "METROPOLICE_AS_HIT_RALLY", SENTENCE_PRIORITY_NORMAL ); break; @@ -840,6 +972,7 @@ void CNPC_MetroPolice::SpeakAssaultSentence( int nSentenceType ) case ASSAULT_SENTENCE_UNDER_ATTACK: m_Sentences.Speak( "METROPOLICE_GO_ALERT" ); break; +#endif } } @@ -875,6 +1008,65 @@ void CNPC_MetroPolice::SpeakSentence( int nSentenceType ) switch ( nSentenceType ) { +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + case METROPOLICE_SENTENCE_FREEZE: + SpeakIfAllowed( TLK_COP_FREEZE, SENTENCE_PRIORITY_MEDIUM, SENTENCE_CRITERIA_NORMAL ); + break; + + case METROPOLICE_SENTENCE_HES_OVER_HERE: + SpeakIfAllowed( TLK_COP_OVER_HERE, SENTENCE_PRIORITY_MEDIUM, SENTENCE_CRITERIA_NORMAL ); + break; + + case METROPOLICE_SENTENCE_HES_RUNNING: + SpeakIfAllowed( TLK_COP_HES_RUNNING, SENTENCE_PRIORITY_HIGH, SENTENCE_CRITERIA_NORMAL ); + break; + + case METROPOLICE_SENTENCE_TAKE_HIM_DOWN: + SpeakIfAllowed( TLK_COP_TAKE_HIM_DOWN, SENTENCE_PRIORITY_HIGH, SENTENCE_CRITERIA_NORMAL ); + break; + + case METROPOLICE_SENTENCE_ARREST_IN_POSITION: + SpeakIfAllowed( TLK_COP_ARREST_IN_POS, SENTENCE_PRIORITY_MEDIUM, SENTENCE_CRITERIA_NORMAL ); + break; + + case METROPOLICE_SENTENCE_DEPLOY_MANHACK: + SpeakIfAllowed( TLK_COP_DEPLOY_MANHACK ); + break; + + case METROPOLICE_SENTENCE_MOVE_INTO_POSITION: + { + CBaseEntity *pEntity = GetEnemy(); + + // NOTE: This is a good time to check to see if the player is hurt. + // Have the cops notice this and call out + if ( pEntity && !HasSpawnFlags( SF_METROPOLICE_ARREST_ENEMY ) ) + { + if ( pEntity->IsPlayer() && (pEntity->GetHealth() <= 20) ) + { + if ( !HasMemory(bits_MEMORY_PLAYER_HURT) ) + { + if ( SpeakIfAllowed( TLK_COP_PLAYERHIT, SENTENCE_PRIORITY_HIGH ) ) + { + m_pSquad->SquadRemember(bits_MEMORY_PLAYER_HURT); + } + } + } + + if ( GetNavigator()->GetPath()->GetPathLength() > 20 * 12.0f ) + { + SpeakIfAllowed( TLK_COP_FLANK ); + } + } + } + break; + + case METROPOLICE_SENTENCE_HEARD_SOMETHING: + if ( ( GetState() == NPC_STATE_ALERT ) || ( GetState() == NPC_STATE_IDLE ) ) + { + SpeakIfAllowed( TLK_COP_HEARD_SOMETHING, SENTENCE_PRIORITY_MEDIUM ); + } + break; +#else case METROPOLICE_SENTENCE_FREEZE: m_Sentences.Speak( "METROPOLICE_FREEZE", SENTENCE_PRIORITY_MEDIUM, SENTENCE_CRITERIA_NORMAL ); break; @@ -932,9 +1124,59 @@ void CNPC_MetroPolice::SpeakSentence( int nSentenceType ) m_Sentences.Speak( "METROPOLICE_HEARD_SOMETHING", SENTENCE_PRIORITY_MEDIUM ); } break; +#endif } } +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM +//========================================================= +//========================================================= +inline bool CNPC_MetroPolice::SpeakIfAllowed( const char *concept, SentencePriority_t sentencepriority, SentenceCriteria_t sentencecriteria ) +{ + return SpeakIfAllowed( concept, NULL, sentencepriority, sentencecriteria ); +} + +//========================================================= +//========================================================= +bool CNPC_MetroPolice::SpeakIfAllowed( const char *concept, const char *modifiers, SentencePriority_t sentencepriority, SentenceCriteria_t sentencecriteria ) +{ + AI_CriteriaSet set; + if (modifiers) + { + GetExpresser()->MergeModifiers(set, modifiers); + } + return SpeakIfAllowed( concept, set, sentencepriority, sentencecriteria ); +} + +//========================================================= +//========================================================= +bool CNPC_MetroPolice::SpeakIfAllowed( const char *concept, AI_CriteriaSet& modifiers, SentencePriority_t sentencepriority, SentenceCriteria_t sentencecriteria ) +{ + if ( sentencepriority != SENTENCE_PRIORITY_INVALID && !FOkToMakeSound( sentencepriority ) ) + return false; + + if ( !GetExpresser()->CanSpeakConcept( concept ) ) + return false; + + if ( Speak( concept, modifiers ) ) + { + JustMadeSound( sentencepriority, 2.0f /*GetTimeSpeechComplete()*/ ); + return true; + } + + return false; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CNPC_MetroPolice::ModifyOrAppendCriteria( AI_CriteriaSet& set ) +{ + BaseClass::ModifyOrAppendCriteria( set ); + + set.AppendCriteria( "numwarnings", UTIL_VarArgs("%d", m_nNumWarnings) ); +} +#endif + //----------------------------------------------------------------------------- // Speaking @@ -954,6 +1196,24 @@ void CNPC_MetroPolice::AnnounceEnemyType( CBaseEntity *pEnemy ) if ( m_pSquad->IsLeader( this ) || ( m_pSquad->GetLeader() && m_pSquad->GetLeader()->GetEnemy() != GetEnemy() ) ) { +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + // First contact, and I'm the squad leader. + bool bEnemyInVehicle = false; + switch ( pEnemy->Classify() ) + { + case CLASS_PLAYER: + { + CBasePlayer *pPlayer = assert_cast( pEnemy ); + if ( pPlayer && pPlayer->IsInAVehicle() ) + { + bEnemyInVehicle = true; + } + } + break; + } + + SpeakIfAllowed( TLK_COP_ENEMY, UTIL_VarArgs("enemy_in_vehicle:%d", bEnemyInVehicle), SENTENCE_PRIORITY_HIGH ); +#else // First contact, and I'm the squad leader. const char *pSentenceName = "METROPOLICE_MONST"; switch ( pEnemy->Classify() ) @@ -998,6 +1258,7 @@ void CNPC_MetroPolice::AnnounceEnemyType( CBaseEntity *pEnemy ) } m_Sentences.Speak( pSentenceName, SENTENCE_PRIORITY_HIGH ); +#endif } else { @@ -1019,6 +1280,11 @@ void CNPC_MetroPolice::AnnounceEnemyKill( CBaseEntity *pEnemy ) if ( !pEnemy ) return; +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + AI_CriteriaSet set; + ModifyOrAppendEnemyCriteria(set, pEnemy); + SpeakIfAllowed( TLK_COP_KILLENEMY, set, SENTENCE_PRIORITY_HIGH ); +#else const char *pSentenceName = "METROPOLICE_KILL_MONST"; switch ( pEnemy->Classify() ) { @@ -1053,6 +1319,7 @@ void CNPC_MetroPolice::AnnounceEnemyKill( CBaseEntity *pEnemy ) } m_Sentences.Speak( pSentenceName, SENTENCE_PRIORITY_HIGH ); +#endif } @@ -1061,6 +1328,16 @@ void CNPC_MetroPolice::AnnounceEnemyKill( CBaseEntity *pEnemy ) //----------------------------------------------------------------------------- void CNPC_MetroPolice::AnnounceOutOfAmmo( ) { +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + if ( HasCondition( COND_NO_PRIMARY_AMMO ) ) + { + SpeakIfAllowed( TLK_COP_NOAMMO ); + } + else + { + SpeakIfAllowed( TLK_COP_LOWAMMO ); + } +#else if ( HasCondition( COND_NO_PRIMARY_AMMO ) ) { m_Sentences.Speak( "METROPOLICE_COVER_NO_AMMO" ); @@ -1069,6 +1346,7 @@ void CNPC_MetroPolice::AnnounceOutOfAmmo( ) { m_Sentences.Speak( "METROPOLICE_COVER_LOW_AMMO" ); } +#endif } //----------------------------------------------------------------------------- @@ -1076,6 +1354,38 @@ void CNPC_MetroPolice::AnnounceOutOfAmmo( ) //----------------------------------------------------------------------------- void CNPC_MetroPolice::AnnounceTakeCoverFromDanger( CSound *pSound ) { +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + bool bGrenade = false; + bool bVehicle = false; + bool bManhack = false; + + CBaseEntity *pSoundOwner = pSound->m_hOwner; + if ( pSoundOwner ) + { + CBaseGrenade *pGrenade = dynamic_cast(pSoundOwner); + if ( pGrenade ) + { + if ( IRelationType( pGrenade->GetThrower() ) != D_LI ) + { + // special case call out for enemy grenades + bGrenade = true; + } + } + else if ( pSoundOwner->GetServerVehicle() ) + { + bVehicle = true; + } + else if ( FClassnameIs( pSoundOwner, "npc_manhack" ) ) + { + if ( pSoundOwner->HasPhysicsAttacker( 1.0f ) ) + { + bManhack = true; + } + } + } + + SpeakIfAllowed(TLK_COP_DANGER, UTIL_VarArgs("grenade:%d,vehicle:%d,manhack:%d", bGrenade, bVehicle, bManhack), SENTENCE_PRIORITY_HIGH, SENTENCE_CRITERIA_NORMAL); +#else CBaseEntity *pSoundOwner = pSound->m_hOwner; if ( pSoundOwner ) { @@ -1110,6 +1420,7 @@ void CNPC_MetroPolice::AnnounceTakeCoverFromDanger( CSound *pSound ) // dangerous sound nearby!, call it out const char *pSentenceName = "METROPOLICE_DANGER"; m_Sentences.Speak( pSentenceName, SENTENCE_PRIORITY_HIGH, SENTENCE_CRITERIA_NORMAL ); +#endif } @@ -1197,8 +1508,12 @@ void CNPC_MetroPolice::OnUpdateShotRegulator( ) { BaseClass::OnUpdateShotRegulator(); +#ifdef MAPBASE + if ( GetActiveWeapon() && GetActiveWeapon()->WeaponClassify() == WEPCLASS_HANDGUN ) +#else // FIXME: This code (except the burst interval) could be used for all weapon types if( Weapon_OwnsThisType( "weapon_pistol" ) ) +#endif { if ( m_nBurstMode == BURST_NOT_ACTIVE ) { @@ -2444,12 +2759,54 @@ void CNPC_MetroPolice::InputEnableManhackToss( inputdata_t &inputdata ) } } +#ifdef MAPBASE +void CNPC_MetroPolice::InputDisableManhackToss( inputdata_t &inputdata ) +{ + if ( !HasSpawnFlags( SF_METROPOLICE_NO_MANHACK_DEPLOY ) ) + { + AddSpawnFlags( SF_METROPOLICE_NO_MANHACK_DEPLOY ); + } +} + +void CNPC_MetroPolice::InputDeployManhack( inputdata_t &inputdata ) +{ + // I am aware this bypasses regular deployment conditions, but the mapper wants us to deploy a manhack, damn it! + // We do have to have one, though. + if ( m_iManhacks > 0 ) + { + SetSchedule(SCHED_METROPOLICE_DEPLOY_MANHACK); + } +} + +void CNPC_MetroPolice::InputAddManhacks( inputdata_t &inputdata ) +{ + m_iManhacks += inputdata.value.Int(); + + SetBodygroup( METROPOLICE_BODYGROUP_MANHACK, (m_iManhacks > 0) ); +} + +void CNPC_MetroPolice::InputSetManhacks( inputdata_t &inputdata ) +{ + m_iManhacks = inputdata.value.Int(); + + SetBodygroup( METROPOLICE_BODYGROUP_MANHACK, (m_iManhacks > 0) ); +} +#endif + //----------------------------------------------------------------------------- // Purpose: // Input : &inputdata - //----------------------------------------------------------------------------- void CNPC_MetroPolice::InputSetPoliceGoal( inputdata_t &inputdata ) { +#ifdef MAPBASE + if (/*!inputdata.value.String() ||*/ inputdata.value.String()[0] == 0) + { + m_PolicingBehavior.Disable(); + return; + } +#endif + CBaseEntity *pGoal = gEntList.FindEntityByName( NULL, inputdata.value.String() ); if ( pGoal == NULL ) @@ -2478,6 +2835,35 @@ void CNPC_MetroPolice::InputActivateBaton( inputdata_t &inputdata ) SetBatonState( inputdata.value.Bool() ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CNPC_MetroPolice::InputAdministerJustice( inputdata_t &inputdata ) +{ + AdministerJustice(); +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CNPC_MetroPolice::InputAddWarnings( inputdata_t &inputdata ) +{ + m_nNumWarnings += inputdata.value.Int(); +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CNPC_MetroPolice::InputSetWarnings( inputdata_t &inputdata ) +{ + m_nNumWarnings = inputdata.value.Int(); +} +#endif + //----------------------------------------------------------------------------- // Purpose: @@ -2485,7 +2871,11 @@ void CNPC_MetroPolice::InputActivateBaton( inputdata_t &inputdata ) //----------------------------------------------------------------------------- void CNPC_MetroPolice::AlertSound( void ) { +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_COP_GO_ALERT ); +#else m_Sentences.Speak( "METROPOLICE_GO_ALERT" ); +#endif } @@ -2498,7 +2888,13 @@ void CNPC_MetroPolice::DeathSound( const CTakeDamageInfo &info ) if ( IsOnFire() ) return; +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + AI_CriteriaSet set; + ModifyOrAppendDamageCriteria(set, info); + SpeakIfAllowed( TLK_COP_DIE, set, SENTENCE_PRIORITY_INVALID, SENTENCE_CRITERIA_ALWAYS ); +#else m_Sentences.Speak( "METROPOLICE_DIE", SENTENCE_PRIORITY_INVALID, SENTENCE_CRITERIA_ALWAYS ); +#endif } @@ -2517,6 +2913,12 @@ void CNPC_MetroPolice::LostEnemySound( void) if ( gpGlobals->curtime <= m_flNextLostSoundTime ) return; +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + if (SpeakIfAllowed(TLK_COP_LOSTENEMY)) + { + m_flNextLostSoundTime = gpGlobals->curtime + random->RandomFloat(5.0,15.0); + } +#else const char *pSentence; if (!(CBaseEntity*)GetEnemy() || gpGlobals->curtime - GetEnemyLastTimeSeen() > 10) { @@ -2531,6 +2933,7 @@ void CNPC_MetroPolice::LostEnemySound( void) { m_flNextLostSoundTime = gpGlobals->curtime + random->RandomFloat(5.0,15.0); } +#endif } @@ -2546,7 +2949,11 @@ void CNPC_MetroPolice::FoundEnemySound( void) if ( HasSpawnFlags( SF_METROPOLICE_ARREST_ENEMY ) ) return; +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_COP_REFINDENEMY, SENTENCE_PRIORITY_HIGH ); +#else m_Sentences.Speak( "METROPOLICE_REFIND_ENEMY", SENTENCE_PRIORITY_HIGH ); +#endif } @@ -2571,6 +2978,59 @@ bool CNPC_MetroPolice::ShouldPlayIdleSound( void ) //----------------------------------------------------------------------------- void CNPC_MetroPolice::IdleSound( void ) { +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + // This happens when the NPC is waiting for his buddies to respond to him + switch( m_nIdleChatterType ) + { + case METROPOLICE_CHATTER_WAIT_FOR_RESPONSE: + break; + + case METROPOLICE_CHATTER_ASK_QUESTION: + { + if ( m_bPlayerIsNear && !HasMemory(bits_MEMORY_PLAYER_HARASSED) ) + { + if ( SpeakIfAllowed( TLK_COP_HARASS, SENTENCE_PRIORITY_NORMAL, SENTENCE_CRITERIA_NORMAL ) ) + { + Remember( bits_MEMORY_PLAYER_HARASSED ); + if ( GetSquad() ) + { + GetSquad()->SquadRemember(bits_MEMORY_PLAYER_HARASSED); + } + } + return; + } + + if ( !random->RandomInt(0,1) ) + break; + + int nQuestionType = random->RandomInt( 0, METROPOLICE_CHATTER_RESPONSE_TYPE_COUNT ); + if ( !IsInSquad() || ( nQuestionType == METROPOLICE_CHATTER_RESPONSE_TYPE_COUNT ) ) + { + SpeakIfAllowed(TLK_COP_IDLE); + break; + } + + if ( SpeakIfAllowed( TLK_COP_QUESTION, UTIL_VarArgs("combinequestion:%d", nQuestionType) ) ) + { + GetSquad()->BroadcastInteraction( g_interactionMetrocopIdleChatter, (void*)(METROPOLICE_CHATTER_RESPONSE + nQuestionType), this ); + m_nIdleChatterType = METROPOLICE_CHATTER_WAIT_FOR_RESPONSE; + } + } + break; + + default: + { + int nResponseType = m_nIdleChatterType - METROPOLICE_CHATTER_RESPONSE; + + if ( SpeakIfAllowed( TLK_COP_ANSWER, UTIL_VarArgs("combinequestion:%d", nResponseType) ) ) + { + GetSquad()->BroadcastInteraction( g_interactionMetrocopIdleChatter, (void*)(METROPOLICE_CHATTER_ASK_QUESTION), this ); + m_nIdleChatterType = METROPOLICE_CHATTER_ASK_QUESTION; + } + } + break; + } +#else bool bIsCriminal = PlayerIsCriminal(); // This happens when the NPC is waiting for his buddies to respond to him @@ -2636,6 +3096,7 @@ void CNPC_MetroPolice::IdleSound( void ) } break; } +#endif } @@ -2651,6 +3112,12 @@ void CNPC_MetroPolice::PainSound( const CTakeDamageInfo &info ) if ( IsOnFire() ) return; +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + AI_CriteriaSet set; + ModifyOrAppendDamageCriteria(set, info); + SpeakIfAllowed(TLK_COP_PAIN, set, SENTENCE_PRIORITY_INVALID, SENTENCE_CRITERIA_ALWAYS); + m_flNextPainSoundTime = gpGlobals->curtime + 1; +#else float healthRatio = (float)GetHealth() / (float)GetMaxHealth(); if ( healthRatio > 0.0f ) { @@ -2670,6 +3137,7 @@ void CNPC_MetroPolice::PainSound( const CTakeDamageInfo &info ) m_Sentences.Speak( pSentenceName, SENTENCE_PRIORITY_INVALID, SENTENCE_CRITERIA_ALWAYS ); m_flNextPainSoundTime = gpGlobals->curtime + 1; } +#endif } //----------------------------------------------------------------------------- @@ -2806,6 +3274,10 @@ void CNPC_MetroPolice::OnAnimEventStartDeployManhack( void ) pManhack->SetParent( this, handAttachment ); m_hManhack = pManhack; + +#ifdef MAPBASE + m_OutManhack.Set(m_hManhack, pManhack, this); +#endif } //----------------------------------------------------------------------------- @@ -2883,7 +3355,7 @@ void CNPC_MetroPolice::OnAnimEventShove( void ) //----------------------------------------------------------------------------- void CNPC_MetroPolice::OnAnimEventBatonOn( void ) { -#ifndef HL2MP +#if !defined(HL2MP) || defined(MAPBASE) CWeaponStunStick *pStick = dynamic_cast(GetActiveWeapon()); @@ -2900,7 +3372,7 @@ void CNPC_MetroPolice::OnAnimEventBatonOn( void ) //----------------------------------------------------------------------------- void CNPC_MetroPolice::OnAnimEventBatonOff( void ) { -#ifndef HL2MP +#if !defined(HL2MP) || defined(MAPBASE) CWeaponStunStick *pStick = dynamic_cast(GetActiveWeapon()); @@ -2989,7 +3461,9 @@ bool CNPC_MetroPolice::HandleInteraction(int interactionType, void *data, CBaseC if ( interactionType == g_interactionMetrocopClearSentenceQueues ) { +#ifndef METROPOLICE_USES_RESPONSE_SYSTEM m_Sentences.ClearQueue(); +#endif return true; } @@ -3010,8 +3484,15 @@ bool CNPC_MetroPolice::HandleInteraction(int interactionType, void *data, CBaseC CBaseProp *pProp = (CBaseProp*)data; if( pProp != NULL ) { +#ifdef MAPBASE + if( pProp->NameMatches("cupcop_can") ) + m_OnCupCopped.FireOutput( sourceEnt, this ); + + m_OnHitByPhysicsObject.Set(pProp, sourceEnt, this); +#else if( pProp->NameMatches("cupcop_can") ) m_OnCupCopped.FireOutput( this, NULL ); +#endif } return true; @@ -3046,9 +3527,71 @@ Activity CNPC_MetroPolice::NPC_TranslateActivity( Activity newActivity ) newActivity = ACT_IDLE_ANGRY; } +#ifdef MAPBASE + if (newActivity == ACT_RANGE_ATTACK2) + { + return ACT_COMBINE_THROW_GRENADE; + } +#endif + return newActivity; } +#ifdef MAPBASE +Activity CNPC_MetroPolice::Weapon_TranslateActivity( Activity baseAct, bool *pRequired ) +{ + Activity translated = BaseClass::Weapon_TranslateActivity(baseAct, pRequired); + + if (!m_fWeaponDrawn) + { + // If our pistol is holstered, don't act like we have one in our hands. + switch (translated) + { + case ACT_WALK_PISTOL: return ACT_WALK; + case ACT_RUN_PISTOL: return ACT_RUN; + case ACT_IDLE_PISTOL: return ACT_IDLE; + } + } + + return translated; +} + +int CNPC_MetroPolice::UnholsterWeapon() +{ +#if 0 + if (!m_fWeaponDrawn && (!IsCurSchedule(SCHED_METROPOLICE_DRAW_PISTOL))) + SetSchedule(SCHED_METROPOLICE_DRAW_PISTOL); + + return -1; +#else + // Remain compatible with the original behavior + if (IsCurSchedule(SCHED_METROPOLICE_DRAW_PISTOL)) + return -1; + else if (!m_fWeaponDrawn) + { + SetSchedule(SCHED_METROPOLICE_DRAW_PISTOL); + return -1; + } + + return BaseClass::UnholsterWeapon(); +#endif +} + +void CNPC_MetroPolice::OnChangeRunningBehavior( CAI_BehaviorBase *pOldBehavior, CAI_BehaviorBase *pNewBehavior ) +{ + BaseClass::OnChangeRunningBehavior( pOldBehavior, pNewBehavior ); + + // Fix the npc_metropolice using an invisible gun + if (!m_fWeaponDrawn) + { + // We can't just stop and draw, so fall back to gesture unholstering. + // Our implementation of UnholsterWeapon() just handles stopping and drawing, which we can skip in this case. + m_fWeaponDrawn = true; + BaseClass::UnholsterWeapon(); + } +} +#endif + //----------------------------------------------------------------------------- // Purpose: Makes the held manhack solid //----------------------------------------------------------------------------- @@ -3160,6 +3703,17 @@ int CNPC_MetroPolice::SelectRangeAttackSchedule() return SCHED_METROPOLICE_DEPLOY_MANHACK; } +#ifdef MAPBASE + // Throw a grenade if not allowed to engage with weapon. + if ( CanGrenadeEnemy() ) + { + if ( OccupyStrategySlot( SQUAD_SLOT_SPECIAL_ATTACK ) ) + { + return SCHED_RANGE_ATTACK2; + } + } +#endif + return SCHED_METROPOLICE_ADVANCE; } @@ -3333,7 +3887,11 @@ int CNPC_MetroPolice::SelectCombatSchedule() { m_nRecentDamage = 0; m_flRecentDamageTime = 0; +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + SpeakIfAllowed(TLK_COP_COVER_HEAVY_DAMAGE, SENTENCE_PRIORITY_MEDIUM, SENTENCE_CRITERIA_NORMAL); +#else m_Sentences.Speak( "METROPOLICE_COVER_HEAVY_DAMAGE", SENTENCE_PRIORITY_MEDIUM, SENTENCE_CRITERIA_NORMAL ); +#endif return SCHED_TAKE_COVER_FROM_ENEMY; } @@ -3376,7 +3934,11 @@ int CNPC_MetroPolice::SelectCombatSchedule() CBaseEntity *pBlocker = GetEnemyOccluder(); if ( pBlocker && pBlocker->GetHealth() > 0 && OccupyStrategySlotRange( SQUAD_SLOT_POLICE_ATTACK_OCCLUDER1, SQUAD_SLOT_POLICE_ATTACK_OCCLUDER2 ) ) { +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + SpeakIfAllowed(TLK_COP_SHOOTCOVER); +#else m_Sentences.Speak( "METROPOLICE_SHOOT_COVER" ); +#endif return SCHED_SHOOT_ENEMY_COVER; } } @@ -3385,6 +3947,27 @@ int CNPC_MetroPolice::SelectCombatSchedule() { if ( GetEnemy() && !(GetEnemy()->GetFlags() & FL_NOTARGET) ) { +#ifdef MAPBASE + if ( HasGrenades() ) + { + // We don't see our enemy. If it hasn't been long since I last saw him, + // and he's pretty close to the last place I saw him, throw a grenade in + // to flush him out. A wee bit of cheating here... + + float flTime; + float flDist; + + flTime = gpGlobals->curtime - GetEnemies()->LastTimeSeen( GetEnemy() ); + flDist = ( GetEnemy()->GetAbsOrigin() - GetEnemies()->LastSeenPosition( GetEnemy() ) ).Length(); + + //Msg("Time: %f Dist: %f\n", flTime, flDist ); + if ( flTime <= COMBINE_GRENADE_FLUSH_TIME && flDist <= COMBINE_GRENADE_FLUSH_DIST && CanGrenadeEnemy( false ) && OccupyStrategySlot( SQUAD_SLOT_SPECIAL_ATTACK ) ) + { + return SCHED_RANGE_ATTACK2; + } + } +#endif + // Charge in and break the enemy's cover! return SCHED_ESTABLISH_LINE_OF_FIRE; } @@ -3884,6 +4467,9 @@ void CNPC_MetroPolice::PlayFlinchGesture( void ) //----------------------------------------------------------------------------- void CNPC_MetroPolice::AnnounceHarrassment( void ) { +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + SpeakIfAllowed(TLK_COP_BACK_UP, SENTENCE_PRIORITY_MEDIUM, SENTENCE_CRITERIA_NORMAL); +#else static const char *pWarnings[3] = { "METROPOLICE_BACK_UP_A", @@ -3892,6 +4478,7 @@ void CNPC_MetroPolice::AnnounceHarrassment( void ) }; m_Sentences.Speak( pWarnings[ random->RandomInt( 0, ARRAYSIZE(pWarnings)-1 ) ], SENTENCE_PRIORITY_MEDIUM, SENTENCE_CRITERIA_NORMAL ); +#endif } //----------------------------------------------------------------------------- @@ -4013,7 +4600,11 @@ int CNPC_MetroPolice::SelectSchedule( void ) if ( HasCondition(COND_METROPOLICE_ON_FIRE) ) { +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + SpeakIfAllowed(TLK_COP_ON_FIRE, "hurt_by_fire:1", SENTENCE_PRIORITY_INVALID, SENTENCE_CRITERIA_ALWAYS); +#else m_Sentences.Speak( "METROPOLICE_ON_FIRE", SENTENCE_PRIORITY_INVALID, SENTENCE_CRITERIA_ALWAYS ); +#endif return SCHED_METROPOLICE_BURNING_STAND; } @@ -4025,17 +4616,50 @@ int CNPC_MetroPolice::SelectSchedule( void ) // See which state our player relationship is in if ( PlayerIsCriminal() == false ) { +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_COP_HIT_BY_PHYSOBJ, SENTENCE_PRIORITY_INVALID, SENTENCE_CRITERIA_ALWAYS ); +#else m_Sentences.Speak( "METROPOLICE_HIT_BY_PHYSOBJECT", SENTENCE_PRIORITY_INVALID, SENTENCE_CRITERIA_ALWAYS ); +#endif m_nNumWarnings = METROPOLICE_MAX_WARNINGS; AdministerJustice(); } else if ( GlobalEntity_GetState( "gordon_precriminal" ) == GLOBAL_ON ) { // We're not allowed to respond, but warn them +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_COP_HARASS, SENTENCE_PRIORITY_INVALID, SENTENCE_CRITERIA_ALWAYS ); +#else m_Sentences.Speak( "METROPOLICE_IDLE_HARASS_PLAYER", SENTENCE_PRIORITY_INVALID, SENTENCE_CRITERIA_ALWAYS ); +#endif } } +#ifdef MAPBASE + if ( m_hForcedGrenadeTarget ) + { + if ( m_flNextGrenadeCheck < gpGlobals->curtime ) + { + Vector vecTarget = m_hForcedGrenadeTarget->WorldSpaceCenter(); + { + // If we can, throw a grenade at the target. + // Ignore grenade count / distance / etc + if ( CheckCanThrowGrenade( vecTarget ) ) + { + m_hForcedGrenadeTarget = NULL; + return SCHED_METROPOLICE_FORCED_GRENADE_THROW; + } + } + } + + // Can't throw at the target, so lets try moving to somewhere where I can see it + if ( !FVisible( m_hForcedGrenadeTarget ) ) + { + return SCHED_METROPOLICE_MOVE_TO_FORCED_GREN_LOS; + } + } +#endif + int nSched = SelectFlinchSchedule(); if ( nSched != SCHED_NONE ) return nSched; @@ -4125,7 +4749,11 @@ int CNPC_MetroPolice::SelectSchedule( void ) { if ( GetActiveWeapon() && (GetActiveWeapon()->m_iClip1 <= 5) ) { +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_COP_LOWAMMO ); +#else m_Sentences.Speak( "METROPOLICE_COVER_LOW_AMMO" ); +#endif return SCHED_HIDE_AND_RELOAD; } } @@ -4168,7 +4796,11 @@ int CNPC_MetroPolice::SelectSchedule( void ) break; case NPC_STATE_COMBAT: +#ifdef MAPBASE + if (!IsEnemyInAnAirboat() || !GetActiveWeapon() || !EntIsClass(GetActiveWeapon(), gm_isz_class_SMG1)) +#else if (!IsEnemyInAnAirboat() || !Weapon_OwnsThisType( "weapon_smg1" ) ) +#endif { int nResult = SelectCombatSchedule(); if ( nResult != SCHED_NONE ) @@ -4270,7 +4902,11 @@ int CNPC_MetroPolice::TranslateSchedule( int scheduleType ) return SCHED_METROPOLICE_DRAW_PISTOL; } +#ifdef MAPBASE + if (GetActiveWeapon() && EntIsClass(GetActiveWeapon(), gm_isz_class_SMG1)) +#else if( Weapon_OwnsThisType( "weapon_smg1" ) ) +#endif { if ( IsEnemyInAnAirboat() ) { @@ -4289,10 +4925,44 @@ int CNPC_MetroPolice::TranslateSchedule( int scheduleType ) } } break; +#ifdef MAPBASE + case SCHED_TAKE_COVER_FROM_ENEMY: + { + if ( m_pSquad ) + { + // Have to explicitly check innate range attack condition as may have weapon with range attack 2 + if ( g_pGameRules->IsSkillLevel( SKILL_HARD ) && + HasCondition(COND_CAN_RANGE_ATTACK2) && + OccupyStrategySlot( SQUAD_SLOT_SPECIAL_ATTACK ) ) + { + #ifdef METROPOLICE_USES_RESPONSE_SYSTEM + SpeakIfAllowed( TLK_COP_THROWGRENADE ); + #else + m_Sentences.Speak( "COMBINE_THROW_GRENADE" ); + #endif + return SCHED_METROPOLICE_RANGE_ATTACK2; + } + } + } + break; + case SCHED_HIDE_AND_RELOAD: + { + if( CanGrenadeEnemy() && OccupyStrategySlot( SQUAD_SLOT_SPECIAL_ATTACK ) && random->RandomInt( 0, 100 ) < 20 ) + { + // If I COULD throw a grenade and I need to reload, 20% chance I'll throw a grenade before I hide to reload. + return SCHED_METROPOLICE_RANGE_ATTACK2; + } + } + break; +#endif case SCHED_METROPOLICE_ADVANCE: if ( m_NextChargeTimer.Expired() && metropolice_charge.GetBool() ) { +#ifdef MAPBASE + if (GetActiveWeapon() && EntIsClass(GetActiveWeapon(), gm_isz_class_Pistol)) +#else if ( Weapon_OwnsThisType( "weapon_pistol" ) ) +#endif { if ( GetEnemy() && GetEnemy()->GetAbsOrigin().DistToSqr( GetAbsOrigin() ) > 300*300 ) { @@ -4417,7 +5087,11 @@ void CNPC_MetroPolice::StartTask( const Task_t *pTask ) break; } +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + SpeakIfAllowed(TLK_COP_ACTIVATE_BATON, SENTENCE_PRIORITY_NORMAL, SENTENCE_CRITERIA_NORMAL); +#else m_Sentences.Speak( "METROPOLICE_ACTIVATE_BATON", SENTENCE_PRIORITY_NORMAL, SENTENCE_CRITERIA_NORMAL ); +#endif SetIdealActivity( (Activity) ACT_ACTIVATE_BATON ); } else @@ -4428,7 +5102,11 @@ void CNPC_MetroPolice::StartTask( const Task_t *pTask ) break; } +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + SpeakIfAllowed(TLK_COP_DEACTIVATE_BATON, SENTENCE_PRIORITY_NORMAL, SENTENCE_CRITERIA_NORMAL); +#else m_Sentences.Speak( "METROPOLICE_DEACTIVATE_BATON", SENTENCE_PRIORITY_NORMAL, SENTENCE_CRITERIA_NORMAL ); +#endif SetIdealActivity( (Activity) ACT_DEACTIVATE_BATON ); } } @@ -4465,6 +5143,19 @@ void CNPC_MetroPolice::StartTask( const Task_t *pTask ) TaskComplete(); break; +#ifdef MAPBASE + case TASK_METROPOLICE_GET_PATH_TO_FORCED_GREN_LOS: + StartTask_GetPathToForced( pTask ); + break; + + case TASK_METROPOLICE_DEFER_SQUAD_GRENADES: + StartTask_DeferSquad( pTask ); + break; + + case TASK_METROPOLICE_FACE_TOSS_DIR: + break; +#endif + case TASK_METROPOLICE_GET_PATH_TO_STITCH: { if ( !ShouldAttemptToStitch() ) @@ -4828,6 +5519,16 @@ void CNPC_MetroPolice::RunTask( const Task_t *pTask ) } break; +#ifdef MAPBASE + case TASK_METROPOLICE_GET_PATH_TO_FORCED_GREN_LOS: + RunTask_GetPathToForced( pTask ); + break; + + case TASK_METROPOLICE_FACE_TOSS_DIR: + RunTask_FaceTossDir( pTask ); + break; +#endif + default: BaseClass::RunTask( pTask ); break; @@ -4947,18 +5648,34 @@ void CNPC_MetroPolice::BuildScheduleTestBits( void ) { ClearCustomInterruptCondition( COND_CAN_MELEE_ATTACK1 ); } + +#ifdef MAPBASE + if (gpGlobals->curtime < m_flNextAttack) + { + ClearCustomInterruptCondition( COND_CAN_RANGE_ATTACK1 ); + ClearCustomInterruptCondition( COND_CAN_RANGE_ATTACK2 ); + } +#endif } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- WeaponProficiency_t CNPC_MetroPolice::CalcWeaponProficiency( CBaseCombatWeapon *pWeapon ) { +#ifdef MAPBASE + if (EntIsClass(pWeapon, gm_isz_class_Pistol)) +#else if( FClassnameIs( pWeapon, "weapon_pistol" ) ) +#endif { return WEAPON_PROFICIENCY_POOR; } +#ifdef MAPBASE + if (EntIsClass(pWeapon, gm_isz_class_SMG1)) +#else if( FClassnameIs( pWeapon, "weapon_smg1" ) ) +#endif { return WEAPON_PROFICIENCY_VERY_GOOD; } @@ -5040,7 +5757,11 @@ bool CNPC_MetroPolice::HasBaton( void ) CBaseCombatWeapon *pWeapon = GetActiveWeapon(); if ( pWeapon ) +#ifdef MAPBASE + return EntIsClass(pWeapon, gm_isz_class_Stunstick); +#else return FClassnameIs( pWeapon, "weapon_stunstick" ); +#endif return false; } @@ -5051,7 +5772,7 @@ bool CNPC_MetroPolice::HasBaton( void ) //----------------------------------------------------------------------------- bool CNPC_MetroPolice::BatonActive( void ) { -#ifndef HL2MP +#if !defined(HL2MP) || defined(MAPBASE) CWeaponStunStick *pStick = dynamic_cast(GetActiveWeapon()); @@ -5223,6 +5944,11 @@ AI_BEGIN_CUSTOM_NPC( npc_metropolice, CNPC_MetroPolice ) DECLARE_TASK( TASK_METROPOLICE_WAIT_FOR_SENTENCE ); DECLARE_TASK( TASK_METROPOLICE_GET_PATH_TO_PRECHASE ); DECLARE_TASK( TASK_METROPOLICE_CLEAR_PRECHASE ); +#ifdef MAPBASE + DECLARE_TASK( TASK_METROPOLICE_GET_PATH_TO_FORCED_GREN_LOS ) + DECLARE_TASK( TASK_METROPOLICE_DEFER_SQUAD_GRENADES ) + DECLARE_TASK( TASK_METROPOLICE_FACE_TOSS_DIR ) +#endif DECLARE_CONDITION( COND_METROPOLICE_ON_FIRE ); DECLARE_CONDITION( COND_METROPOLICE_ENEMY_RESISTING_ARREST ); @@ -5842,5 +6568,69 @@ DEFINE_SCHEDULE " COND_ENEMY_DEAD" ); +#ifdef MAPBASE +//========================================================= + // Mapmaker forced grenade throw + //========================================================= + DEFINE_SCHEDULE + ( + SCHED_METROPOLICE_FORCED_GRENADE_THROW, + + " Tasks" + " TASK_STOP_MOVING 0" + " TASK_METROPOLICE_FACE_TOSS_DIR 0" + " TASK_ANNOUNCE_ATTACK 2" // 2 = grenade + " TASK_PLAY_SEQUENCE ACTIVITY:ACT_RANGE_ATTACK2" + " TASK_METROPOLICE_DEFER_SQUAD_GRENADES 0" + "" + " Interrupts" + ) + + //========================================================= + // Move to LOS of the mapmaker's forced grenade throw target + //========================================================= + DEFINE_SCHEDULE + ( + SCHED_METROPOLICE_MOVE_TO_FORCED_GREN_LOS, + + " Tasks " + " TASK_SET_TOLERANCE_DISTANCE 48" + " TASK_METROPOLICE_GET_PATH_TO_FORCED_GREN_LOS 0" + " TASK_SPEAK_SENTENCE 1" + " TASK_RUN_PATH 0" + " TASK_WAIT_FOR_MOVEMENT 0" + " " + " Interrupts " + " COND_NEW_ENEMY" + " COND_ENEMY_DEAD" + " COND_CAN_MELEE_ATTACK1" + " COND_CAN_MELEE_ATTACK2" + " COND_HEAR_DANGER" + " COND_HEAR_MOVE_AWAY" + " COND_HEAVY_DAMAGE" + ) + + //========================================================= + // SCHED_METROPOLICE_RANGE_ATTACK2 + // + // secondary range attack. Overriden because base class stops attacking when the enemy is occluded. + // combines's grenade toss requires the enemy be occluded. + //========================================================= + DEFINE_SCHEDULE + ( + SCHED_METROPOLICE_RANGE_ATTACK2, + + " Tasks" + " TASK_STOP_MOVING 0" + " TASK_METROPOLICE_FACE_TOSS_DIR 0" + " TASK_ANNOUNCE_ATTACK 2" // 2 = grenade + " TASK_PLAY_SEQUENCE ACTIVITY:ACT_RANGE_ATTACK2" + " TASK_METROPOLICE_DEFER_SQUAD_GRENADES 0" + " TASK_SET_SCHEDULE SCHEDULE:SCHED_HIDE_AND_RELOAD" // don't run immediately after throwing grenade. + "" + " Interrupts" + ) +#endif + AI_END_CUSTOM_NPC() diff --git a/sp/src/game/server/hl2/npc_metropolice.h b/sp/src/game/server/hl2/npc_metropolice.h index 544fc68b..6d3f065d 100644 --- a/sp/src/game/server/hl2/npc_metropolice.h +++ b/sp/src/game/server/hl2/npc_metropolice.h @@ -24,13 +24,26 @@ #include "ai_behavior_police.h" #include "ai_behavior_follow.h" #include "ai_sentence.h" +#ifdef MAPBASE +#include "mapbase/ai_grenade.h" +#endif #include "props.h" +#ifdef EXPANDED_RESPONSE_SYSTEM_USAGE +#include "mapbase/expandedrs_combine.h" +#define METROPOLICE_USES_RESPONSE_SYSTEM 1 +#endif class CNPC_MetroPolice; +#ifdef MAPBASE +class CNPC_MetroPolice : public CAI_GrenadeUser +{ + DECLARE_CLASS( CNPC_MetroPolice, CAI_GrenadeUser ); +#else class CNPC_MetroPolice : public CAI_BaseActor { DECLARE_CLASS( CNPC_MetroPolice, CAI_BaseActor ); +#endif DECLARE_DATADESC(); public: @@ -46,6 +59,14 @@ public: float MaxYawSpeed( void ); void HandleAnimEvent( animevent_t *pEvent ); Activity NPC_TranslateActivity( Activity newActivity ); +#ifdef MAPBASE + Activity Weapon_TranslateActivity( Activity baseAct, bool *pRequired ); + + virtual int UnholsterWeapon( void ); + virtual void OnChangeRunningBehavior( CAI_BehaviorBase *pOldBehavior, CAI_BehaviorBase *pNewBehavior ); + + const char* GetGrenadeAttachment() { return "LHand"; } +#endif Vector EyeDirection3D( void ) { return CAI_BaseHumanoid::EyeDirection3D(); } // cops don't have eyes @@ -87,6 +108,12 @@ public: // Speaking virtual void SpeakSentence( int nSentenceType ); +#ifdef METROPOLICE_USES_RESPONSE_SYSTEM + bool SpeakIfAllowed( const char *concept, SentencePriority_t sentencepriority = SENTENCE_PRIORITY_NORMAL, SentenceCriteria_t sentencecriteria = SENTENCE_CRITERIA_IN_SQUAD ); + bool SpeakIfAllowed( const char *concept, const char *modifiers, SentencePriority_t sentencepriority = SENTENCE_PRIORITY_NORMAL, SentenceCriteria_t sentencecriteria = SENTENCE_CRITERIA_IN_SQUAD ); + bool SpeakIfAllowed( const char *concept, AI_CriteriaSet& modifiers, SentencePriority_t sentencepriority = SENTENCE_PRIORITY_NORMAL, SentenceCriteria_t sentencecriteria = SENTENCE_CRITERIA_IN_SQUAD ); + void ModifyOrAppendCriteria( AI_CriteriaSet& set ); +#endif // Set up the shot regulator based on the equipped weapon virtual void OnUpdateShotRegulator( ); @@ -101,7 +128,9 @@ public: void SetBatonState( bool state ); bool BatonActive( void ); +#ifndef METROPOLICE_USES_RESPONSE_SYSTEM CAI_Sentence< CNPC_MetroPolice > *GetSentences() { return &m_Sentences; } +#endif virtual bool AllowedToIgnite( void ) { return true; } @@ -164,8 +193,19 @@ private: // Inputs void InputEnableManhackToss( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputDisableManhackToss( inputdata_t &inputdata ); + void InputDeployManhack( inputdata_t &inputdata ); + void InputAddManhacks( inputdata_t &inputdata ); + void InputSetManhacks( inputdata_t &inputdata ); +#endif void InputSetPoliceGoal( inputdata_t &inputdata ); void InputActivateBaton( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputAdministerJustice( inputdata_t &inputdata ); + void InputAddWarnings( inputdata_t &inputdata ); + void InputSetWarnings( inputdata_t &inputdata ); +#endif void NotifyDeadFriend ( CBaseEntity* pFriend ); @@ -361,6 +401,11 @@ private: SCHED_METROPOLICE_ALERT_FACE_BESTSOUND, SCHED_METROPOLICE_RETURN_TO_PRECHASE, SCHED_METROPOLICE_SMASH_PROP, +#ifdef MAPBASE + SCHED_METROPOLICE_FORCED_GRENADE_THROW, + SCHED_METROPOLICE_MOVE_TO_FORCED_GREN_LOS, + SCHED_METROPOLICE_RANGE_ATTACK2, +#endif }; enum @@ -387,6 +432,11 @@ private: TASK_METROPOLICE_WAIT_FOR_SENTENCE, TASK_METROPOLICE_GET_PATH_TO_PRECHASE, TASK_METROPOLICE_CLEAR_PRECHASE, +#ifdef MAPBASE + TASK_METROPOLICE_GET_PATH_TO_FORCED_GREN_LOS, + TASK_METROPOLICE_DEFER_SQUAD_GRENADES, + TASK_METROPOLICE_FACE_TOSS_DIR, +#endif }; private: @@ -441,6 +491,10 @@ private: // Outputs COutputEvent m_OnStunnedPlayer; COutputEvent m_OnCupCopped; +#ifdef MAPBASE + COutputEHANDLE m_OnHitByPhysicsObject; + COutputEHANDLE m_OutManhack; +#endif AIHANDLE m_hManhack; CHandle m_hBlockingProp; @@ -453,7 +507,9 @@ private: CAI_PolicingBehavior m_PolicingBehavior; CAI_FollowBehavior m_FollowBehavior; +#ifndef METROPOLICE_USES_RESPONSE_SYSTEM CAI_Sentence< CNPC_MetroPolice > m_Sentences; +#endif int m_nRecentDamage; float m_flRecentDamageTime; diff --git a/sp/src/game/server/hl2/npc_monk.cpp b/sp/src/game/server/hl2/npc_monk.cpp index c20f558c..63a4ee6d 100644 --- a/sp/src/game/server/hl2/npc_monk.cpp +++ b/sp/src/game/server/hl2/npc_monk.cpp @@ -16,6 +16,9 @@ #include "ai_behavior.h" #include "ai_behavior_assault.h" #include "ai_behavior_lead.h" +#ifdef MAPBASE +#include "ai_behavior_functank.h" +#endif #include "npcevent.h" #include "ai_playerally.h" #include "ai_senses.h" @@ -103,6 +106,10 @@ private: CAI_AssaultBehavior m_AssaultBehavior; CAI_LeadBehavior m_LeadBehavior; +#ifdef MAPBASE + CAI_FuncTankBehavior m_FuncTankBehavior; +#endif + int m_iNumZombies; int m_iDangerousZombies; bool m_bPerfectAccuracy; @@ -113,6 +120,9 @@ private: BEGIN_DATADESC( CNPC_Monk ) // m_AssaultBehavior // m_LeadBehavior +#ifdef MAPBASE +// m_FuncTankBehavior +#endif DEFINE_FIELD( m_iNumZombies, FIELD_INTEGER ), DEFINE_FIELD( m_iDangerousZombies, FIELD_INTEGER ), DEFINE_FIELD( m_bPerfectAccuracy, FIELD_BOOLEAN ), @@ -132,6 +142,9 @@ bool CNPC_Monk::CreateBehaviors() { AddBehavior( &m_LeadBehavior ); AddBehavior( &m_AssaultBehavior ); +#ifdef MAPBASE + AddBehavior( &m_FuncTankBehavior ); +#endif return BaseClass::CreateBehaviors(); } @@ -665,6 +678,17 @@ int CNPC_Monk::SelectFailSchedule( int failedSchedule, int failedTask, AI_TaskFa { if( HasCondition( COND_CAN_RANGE_ATTACK1 ) ) { +#ifdef MAPBASE + // I thought it would be a nice touch. + if (RandomInt(1, 2) == 1 && CanRunAScriptedNPCInteraction(false)) + { + for ( int i = 0; i < m_ScriptedInteractions.Count(); i++ ) + { + m_ScriptedInteractions[i].flNextAttemptTime = gpGlobals->curtime; + } + } +#endif + // Most likely backed into a corner. Just blaze away. return SCHED_MONK_RANGE_ATTACK1; } diff --git a/sp/src/game/server/hl2/npc_playercompanion.cpp b/sp/src/game/server/hl2/npc_playercompanion.cpp index a03a752f..0ec05069 100644 --- a/sp/src/game/server/hl2/npc_playercompanion.cpp +++ b/sp/src/game/server/hl2/npc_playercompanion.cpp @@ -31,12 +31,20 @@ #include "grenade_frag.h" #include #include "physics_npc_solver.h" +#ifdef MAPBASE +#include "mapbase/GlobalStrings.h" +#include "world.h" +#endif ConVar ai_debug_readiness("ai_debug_readiness", "0" ); ConVar ai_use_readiness("ai_use_readiness", "1" ); // 0 = off, 1 = on, 2 = on for player squad only ConVar ai_readiness_decay( "ai_readiness_decay", "120" );// How many seconds it takes to relax completely ConVar ai_new_aiming( "ai_new_aiming", "1" ); +#ifdef COMPANION_MELEE_ATTACK +ConVar sk_companion_melee_damage("sk_companion_melee_damage", "25"); +#endif + #define GetReadinessUse() ai_use_readiness.GetInt() extern ConVar g_debug_transitions; @@ -46,6 +54,11 @@ extern ConVar g_debug_transitions; int AE_COMPANION_PRODUCE_FLARE; int AE_COMPANION_LIGHT_FLARE; int AE_COMPANION_RELEASE_FLARE; +#if COMPANION_MELEE_ATTACK +#define AE_PC_MELEE 3 + +#define COMPANION_MELEE_DIST 64.0 +#endif #define MAX_TIME_BETWEEN_BARRELS_EXPLODING 5.0f #define MAX_TIME_BETWEEN_CONSECUTIVE_PLAYER_KILLS 3.0f @@ -97,7 +110,9 @@ BEGIN_DATADESC( CNPC_PlayerCompanion ) #endif // HL2_EPISODIC //------------------------------------------------------------------------------ +#ifndef MAPBASE DEFINE_INPUTFUNC( FIELD_STRING, "GiveWeapon", InputGiveWeapon ), +#endif DEFINE_FIELD( m_flReadiness, FIELD_FLOAT ), DEFINE_FIELD( m_flReadinessSensitivity, FIELD_FLOAT ), @@ -130,6 +145,11 @@ BEGIN_DATADESC( CNPC_PlayerCompanion ) DEFINE_OUTPUT( m_OnWeaponPickup, "OnWeaponPickup" ), +#ifdef MAPBASE + DEFINE_AIGRENADE_DATADESC() + DEFINE_INPUT( m_iGrenadeCapabilities, FIELD_INTEGER, "SetGrenadeCapabilities" ), +#endif + END_DATADESC() //----------------------------------------------------------------------------- @@ -137,11 +157,21 @@ END_DATADESC() CNPC_PlayerCompanion::eCoverType CNPC_PlayerCompanion::gm_fCoverSearchType; bool CNPC_PlayerCompanion::gm_bFindingCoverFromAllEnemies; +#ifdef MAPBASE +string_t CNPC_PlayerCompanion::gm_iszMortarClassname; +string_t CNPC_PlayerCompanion::gm_iszGroundTurretClassname; +string_t CNPC_PlayerCompanion::gm_iszRollerMineClassname; +#else string_t CNPC_PlayerCompanion::gm_iszMortarClassname; string_t CNPC_PlayerCompanion::gm_iszFloorTurretClassname; string_t CNPC_PlayerCompanion::gm_iszGroundTurretClassname; string_t CNPC_PlayerCompanion::gm_iszShotgunClassname; string_t CNPC_PlayerCompanion::gm_iszRollerMineClassname; +#ifdef MAPBASE +string_t CNPC_PlayerCompanion::gm_iszSMG1Classname; +string_t CNPC_PlayerCompanion::gm_iszAR2Classname; +#endif +#endif //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- @@ -175,11 +205,21 @@ bool CNPC_PlayerCompanion::CreateBehaviors() //----------------------------------------------------------------------------- void CNPC_PlayerCompanion::Precache() { +#ifdef MAPBASE + SetGlobalString(gm_iszMortarClassname, "func_tankmortar"); + SetGlobalString(gm_iszGroundTurretClassname, "npc_turret_ground"); + SetGlobalString(gm_iszRollerMineClassname, "npc_rollermine"); +#else gm_iszMortarClassname = AllocPooledString( "func_tankmortar" ); gm_iszFloorTurretClassname = AllocPooledString( "npc_turret_floor" ); gm_iszGroundTurretClassname = AllocPooledString( "npc_turret_ground" ); gm_iszShotgunClassname = AllocPooledString( "weapon_shotgun" ); gm_iszRollerMineClassname = AllocPooledString( "npc_rollermine" ); +#ifdef MAPBASE + gm_iszSMG1Classname = AllocPooledString( "weapon_smg1" ); + gm_iszAR2Classname = AllocPooledString( "weapon_ar2" ); +#endif +#endif PrecacheModel( STRING( GetModelName() ) ); @@ -188,6 +228,10 @@ void CNPC_PlayerCompanion::Precache() PrecacheModel( "models/props_junk/flare.mdl" ); #endif // HL2_EPISODIC +#ifdef MAPBASE + PrecacheScriptSound( "Weapon_CombineGuard.Special1" ); +#endif + BaseClass::Precache(); } @@ -245,6 +289,10 @@ void CNPC_PlayerCompanion::Spawn() m_hFlare = NULL; #endif // HL2_EPISODIC +#if COMPANION_MELEE_ATTACK + m_nMeleeDamage = sk_companion_melee_damage.GetInt(); +#endif + BaseClass::Spawn(); } @@ -315,8 +363,13 @@ Disposition_t CNPC_PlayerCompanion::IRelationType( CBaseEntity *pTarget ) else if ( baseRelationship == D_HT && pTarget->IsNPC() && ((CAI_BaseNPC *)pTarget)->GetActiveWeapon() && +#ifdef MAPBASE + (EntIsClass( ((CAI_BaseNPC *)pTarget)->GetActiveWeapon(), gm_iszShotgunClassname ) && + ( !GetActiveWeapon() || !EntIsClass( GetActiveWeapon(), gm_iszShotgunClassname ) ) ) ) +#else ((CAI_BaseNPC *)pTarget)->GetActiveWeapon()->ClassMatches( gm_iszShotgunClassname ) && ( !GetActiveWeapon() || !GetActiveWeapon()->ClassMatches( gm_iszShotgunClassname ) ) ) +#endif { if ( (pTarget->GetAbsOrigin() - GetAbsOrigin()).LengthSqr() < Square( 25 * 12 ) ) { @@ -496,6 +549,14 @@ void CNPC_PlayerCompanion::GatherConditions() DoCustomSpeechAI(); } +#ifdef MAPBASE + // Alyx's custom combat AI copied to CNPC_PlayerCompanion for reasons specified in said function. + if ( m_NPCState == NPC_STATE_COMBAT ) + { + DoCustomCombatAI(); + } +#endif + if ( AI_IsSinglePlayer() && hl2_episodic.GetBool() && !GetEnemy() && HasCondition( COND_HEAR_PLAYER ) ) { Vector los = ( UTIL_GetLocalPlayer()->EyePosition() - EyePosition() ); @@ -538,7 +599,12 @@ void CNPC_PlayerCompanion::DoCustomSpeechAI( void ) } // Mention the player is dead +#ifdef MAPBASE + // (unless we hate them) + if ( HasCondition( COND_TALKER_PLAYER_DEAD ) && (!pPlayer || IRelationType(pPlayer) > D_FR) ) +#else if ( HasCondition( COND_TALKER_PLAYER_DEAD ) ) +#endif { SpeakIfAllowed( TLK_PLDEAD ); } @@ -573,6 +639,15 @@ void CNPC_PlayerCompanion::BuildScheduleTestBits() SetCustomInterruptCondition( COND_PLAYER_PUSHING ); } +#if COMPANION_MELEE_ATTACK + if (IsCurSchedule(SCHED_RANGE_ATTACK1) || + IsCurSchedule(SCHED_BACK_AWAY_FROM_ENEMY) || + IsCurSchedule(SCHED_RUN_FROM_ENEMY)) + { + SetCustomInterruptCondition( COND_CAN_MELEE_ATTACK1 ); + } +#endif + if ( ( ConditionInterruptsCurSchedule( COND_GIVE_WAY ) || IsCurSchedule(SCHED_HIDE_AND_RELOAD ) || IsCurSchedule(SCHED_RELOAD ) || @@ -715,6 +790,46 @@ int CNPC_PlayerCompanion::SelectSchedule() } } +#ifdef MAPBASE + if ( m_hForcedGrenadeTarget ) + { + // Can't throw at the target, so lets try moving to somewhere where I can see it + if ( !FVisible( m_hForcedGrenadeTarget ) ) + { + return SCHED_PC_MOVE_TO_FORCED_GREN_LOS; + } + else if ( m_flNextGrenadeCheck < gpGlobals->curtime ) + { + Vector vecTarget = m_hForcedGrenadeTarget->WorldSpaceCenter(); + + // The fact we have a forced grenade target overrides whether we're marked as "capable". + // If we're *only* alt-fire capable, use an energy ball. If not, throw a grenade. + if (!IsAltFireCapable() || IsGrenadeCapable()) + { + Vector vecTarget = m_hForcedGrenadeTarget->WorldSpaceCenter(); + { + // If we can, throw a grenade at the target. + // Ignore grenade count / distance / etc + if ( CheckCanThrowGrenade( vecTarget ) ) + { + m_hForcedGrenadeTarget = NULL; + return SCHED_PC_FORCED_GRENADE_THROW; + } + } + } + else + { + if ( FVisible( m_hForcedGrenadeTarget ) ) + { + m_vecAltFireTarget = vecTarget; + m_hForcedGrenadeTarget = NULL; + return SCHED_PC_AR2_ALTFIRE; + } + } + } + } +#endif + int nSched = SelectFlinchSchedule(); if ( nSched != SCHED_NONE ) return nSched; @@ -873,10 +988,39 @@ bool CNPC_PlayerCompanion::IgnorePlayerPushing( void ) //----------------------------------------------------------------------------- int CNPC_PlayerCompanion::SelectScheduleCombat() { +#if COMPANION_MELEE_ATTACK + if ( HasCondition( COND_CAN_MELEE_ATTACK1 ) ) + { + DevMsg("Returning melee attack schedule\n"); + return SCHED_MELEE_ATTACK1; + } +#endif + if ( CanReload() && (HasCondition ( COND_NO_PRIMARY_AMMO ) || HasCondition(COND_LOW_PRIMARY_AMMO)) ) { return SCHED_HIDE_AND_RELOAD; } + +#ifdef MAPBASE + if ( HasGrenades() && GetEnemy() && !HasCondition(COND_SEE_ENEMY) ) + { + // We don't see our enemy. If it hasn't been long since I last saw him, + // and he's pretty close to the last place I saw him, throw a grenade in + // to flush him out. A wee bit of cheating here... + + float flTime; + float flDist; + + flTime = gpGlobals->curtime - GetEnemies()->LastTimeSeen( GetEnemy() ); + flDist = ( GetEnemy()->GetAbsOrigin() - GetEnemies()->LastSeenPosition( GetEnemy() ) ).Length(); + + //Msg("Time: %f Dist: %f\n", flTime, flDist ); + if ( flTime <= COMBINE_GRENADE_FLUSH_TIME && flDist <= COMBINE_GRENADE_FLUSH_DIST && CanGrenadeEnemy( false ) && OccupyStrategySlot( SQUAD_SLOT_SPECIAL_ATTACK ) ) + { + return SCHED_RANGE_ATTACK2; + } + } +#endif return SCHED_NONE; } @@ -908,6 +1052,14 @@ bool CNPC_PlayerCompanion::ShouldDeferToFollowBehavior() return false; } +#if COMPANION_MELEE_ATTACK + if (HasCondition(COND_CAN_MELEE_ATTACK1) /*&& !GetFollowBehavior().IsActive()*/) + { + // We should only get melee condition if we're not moving + return false; + } +#endif + // Even though assault and act busy are placed ahead of the follow behavior in precedence, the below // code is necessary because we call ShouldDeferToFollowBehavior BEFORE we call the generic // BehaviorSelectSchedule, which tries the behaviors in priority order. @@ -978,6 +1130,10 @@ int CNPC_PlayerCompanion::TranslateSchedule( int scheduleType ) pWeapon->Clip1() < ( pWeapon->GetMaxClip1() * .75 ) && pPlayer->GetAmmoCount( pWeapon->GetPrimaryAmmoType() ) ) { +#ifdef MAPBASE + // Less annoying + if ( !pWeapon->m_bInReload && (gpGlobals->curtime - GetLastEnemyTime()) > 5.0f ) +#endif SpeakIfAllowed( TLK_PLRELOAD ); } } @@ -1009,6 +1165,14 @@ int CNPC_PlayerCompanion::TranslateSchedule( int scheduleType ) return SCHED_PC_FLEE_FROM_BEST_SOUND; case SCHED_ESTABLISH_LINE_OF_FIRE: +#ifdef MAPBASE + if ( CanAltFireEnemy(false) && OccupyStrategySlot(SQUAD_SLOT_SPECIAL_ATTACK) ) + { + // If this companion has the balls to alt-fire the enemy's last known position, + // do so! + return SCHED_PC_AR2_ALTFIRE; + } +#endif case SCHED_MOVE_TO_WEAPON_RANGE: if ( IsMortar( GetEnemy() ) ) return SCHED_TAKE_COVER_FROM_ENEMY; @@ -1017,13 +1181,21 @@ int CNPC_PlayerCompanion::TranslateSchedule( int scheduleType ) case SCHED_CHASE_ENEMY: if ( IsMortar( GetEnemy() ) ) return SCHED_TAKE_COVER_FROM_ENEMY; +#ifdef MAPBASE + if ( GetEnemy() && EntIsClass( GetEnemy(), gm_isz_class_Gunship ) ) +#else if ( GetEnemy() && FClassnameIs( GetEnemy(), "npc_combinegunship" ) ) +#endif return SCHED_ESTABLISH_LINE_OF_FIRE; break; case SCHED_ESTABLISH_LINE_OF_FIRE_FALLBACK: // If we're fighting a gunship, try again +#ifdef MAPBASE + if ( GetEnemy() && EntIsClass( GetEnemy(), gm_isz_class_Gunship ) ) +#else if ( GetEnemy() && FClassnameIs( GetEnemy(), "npc_combinegunship" ) ) +#endif return SCHED_ESTABLISH_LINE_OF_FIRE; break; @@ -1034,10 +1206,44 @@ int CNPC_PlayerCompanion::TranslateSchedule( int scheduleType ) if ( GetShotRegulator()->IsInRestInterval() ) return SCHED_STANDOFF; +#ifdef MAPBASE + if (CanAltFireEnemy( true ) && OccupyStrategySlot( SQUAD_SLOT_SPECIAL_ATTACK )) + { + // Since I'm holding this squadslot, no one else can try right now. If I die before the shot + // goes off, I won't have affected anyone else's ability to use this attack at their nearest + // convenience. + return SCHED_PC_AR2_ALTFIRE; + } + + if ( !OccupyStrategySlotRange( SQUAD_SLOT_ATTACK1, SQUAD_SLOT_ATTACK2 ) ) + { + // Throw a grenade if not allowed to engage with weapon. + if ( CanGrenadeEnemy() ) + { + if ( OccupyStrategySlot( SQUAD_SLOT_SPECIAL_ATTACK ) ) + { + return SCHED_RANGE_ATTACK2; + } + } + + return SCHED_STANDOFF; + } +#else if( !OccupyStrategySlotRange( SQUAD_SLOT_ATTACK1, SQUAD_SLOT_ATTACK2 ) ) return SCHED_STANDOFF; +#endif break; +#if COMPANION_MELEE_ATTACK + //case SCHED_BACK_AWAY_FROM_ENEMY: + // if (HasCondition(COND_CAN_MELEE_ATTACK1)) + // return SCHED_MELEE_ATTACK1; + // break; + + case SCHED_MELEE_ATTACK1: + return SCHED_PC_MELEE_AND_MOVE_AWAY; +#endif + case SCHED_FAIL_TAKE_COVER: if ( IsEnemyTurret() ) { @@ -1046,17 +1252,53 @@ int CNPC_PlayerCompanion::TranslateSchedule( int scheduleType ) break; case SCHED_RUN_FROM_ENEMY_FALLBACK: { +#if COMPANION_MELEE_ATTACK + if (HasCondition(COND_CAN_MELEE_ATTACK1) && !HasCondition(COND_HEAVY_DAMAGE)) + { + return SCHED_MELEE_ATTACK1; + } +#endif if ( HasCondition( COND_CAN_RANGE_ATTACK1 ) ) { return SCHED_RANGE_ATTACK1; } break; } + +#ifdef MAPBASE + case SCHED_TAKE_COVER_FROM_ENEMY: + { + if ( m_pSquad ) + { + // Have to explicitly check innate range attack condition as may have weapon with range attack 2 + if ( HasCondition(COND_CAN_RANGE_ATTACK2) && + OccupyStrategySlot( SQUAD_SLOT_SPECIAL_ATTACK ) ) + { + SpeakIfAllowed("TLK_THROWGRENADE"); + return SCHED_PC_RANGE_ATTACK2; + } + } + } + break; + case SCHED_HIDE_AND_RELOAD: + { + if( CanGrenadeEnemy() && OccupyStrategySlot( SQUAD_SLOT_SPECIAL_ATTACK ) && random->RandomInt( 0, 100 ) < 20 ) + { + // If I COULD throw a grenade and I need to reload, 20% chance I'll throw a grenade before I hide to reload. + return SCHED_PC_RANGE_ATTACK2; + } + } + break; +#endif } return BaseClass::TranslateSchedule( scheduleType ); } +#ifdef MAPBASE +//extern float GetCurrentGravity( void ); +#endif + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void CNPC_PlayerCompanion::StartTask( const Task_t *pTask ) @@ -1114,6 +1356,23 @@ void CNPC_PlayerCompanion::StartTask( const Task_t *pTask ) } break; +#ifdef MAPBASE + case TASK_PC_PLAY_SEQUENCE_FACE_ALTFIRE_TARGET: + StartTask_FaceAltFireTarget( pTask ); + break; + + case TASK_PC_GET_PATH_TO_FORCED_GREN_LOS: + StartTask_GetPathToForced( pTask ); + break; + + case TASK_PC_DEFER_SQUAD_GRENADES: + StartTask_DeferSquad( pTask ); + break; + + case TASK_PC_FACE_TOSS_DIR: + break; +#endif + default: BaseClass::StartTask( pTask ); break; @@ -1161,6 +1420,20 @@ void CNPC_PlayerCompanion::RunTask( const Task_t *pTask ) } break; +#ifdef MAPBASE + case TASK_PC_PLAY_SEQUENCE_FACE_ALTFIRE_TARGET: + RunTask_FaceAltFireTarget( pTask ); + break; + + case TASK_PC_GET_PATH_TO_FORCED_GREN_LOS: + RunTask_GetPathToForced( pTask ); + break; + + case TASK_PC_FACE_TOSS_DIR: + RunTask_FaceTossDir( pTask ); + break; +#endif + default: BaseClass::RunTask( pTask ); break; @@ -1366,6 +1639,21 @@ Activity CNPC_PlayerCompanion::NPC_TranslateActivity( Activity activity ) activity = ACT_RUN_PROTECTED; } +#ifdef COMPANION_HOLSTER_WORKAROUND + if (activity == ACT_DISARM || activity == ACT_ARM) + { + CBaseCombatWeapon *pWeapon = GetActiveWeapon() ? GetActiveWeapon() : m_hWeapons[m_iLastHolsteredWeapon]; + if (pWeapon && pWeapon->WeaponClassify() != WEPCLASS_HANDGUN) + { + switch (activity) + { + case ACT_DISARM: return ACT_DISARM_RIFLE; + case ACT_ARM: return ACT_ARM_RIFLE; + } + } + } +#endif + activity = BaseClass::NPC_TranslateActivity( activity ); if ( activity == ACT_IDLE ) @@ -1376,6 +1664,15 @@ Activity CNPC_PlayerCompanion::NPC_TranslateActivity( Activity activity ) } } +#ifdef MAPBASE + // Vorts use ACT_RANGE_ATTACK2, but they should translate to ACT_VORTIGAUNT_DISPEL + // before that reaches this code... + if (activity == ACT_RANGE_ATTACK2) + { + activity = ACT_COMBINE_THROW_GRENADE; + } +#endif + return TranslateActivityReadiness( activity ); } @@ -1449,14 +1746,44 @@ void CNPC_PlayerCompanion::HandleAnimEvent( animevent_t *pEvent ) case EVENT_WEAPON_RELOAD: if ( GetActiveWeapon() ) { +#ifdef MAPBASE + GetActiveWeapon()->Reload_NPC(); +#else GetActiveWeapon()->WeaponSound( RELOAD_NPC ); GetActiveWeapon()->m_iClip1 = GetActiveWeapon()->GetMaxClip1(); +#endif ClearCondition(COND_LOW_PRIMARY_AMMO); ClearCondition(COND_NO_PRIMARY_AMMO); ClearCondition(COND_NO_SECONDARY_AMMO); } break; +#if COMPANION_MELEE_ATTACK + case AE_PC_MELEE: + { + CBaseEntity *pHurt = CheckTraceHullAttack(COMPANION_MELEE_DIST, -Vector(16, 16, 18), Vector(16, 16, 18), 0, DMG_CLUB); + CBaseCombatCharacter* pBCC = ToBaseCombatCharacter(pHurt); + if (pBCC) + { + Vector forward, up; + AngleVectors(GetLocalAngles(), &forward, NULL, &up); + + if (pBCC->IsPlayer()) + { + pBCC->ViewPunch(QAngle(-12, -7, 0)); + pHurt->ApplyAbsVelocityImpulse(forward * 100 + up * 50); + } + + CTakeDamageInfo info(this, this, m_nMeleeDamage, DMG_CLUB); + CalculateMeleeDamageForce(&info, forward, pBCC->GetAbsOrigin()); + pBCC->TakeDamage(info); + + EmitSound("NPC_Combine.WeaponBash"); + } + break; + } +#endif + default: BaseClass::HandleAnimEvent( pEvent ); break; @@ -1533,6 +1860,20 @@ void CNPC_PlayerCompanion::ModifyOrAppendCriteria( AI_CriteriaSet& set ) set.AppendCriteria( "hurt_by_fire", "1" ); } +#ifdef MAPBASE + // Ported from Alyx. + AIEnemiesIter_t iter; + int iNumEnemies = 0; + for ( AI_EnemyInfo_t *pEMemory = GetEnemies()->GetFirst(&iter); pEMemory != NULL; pEMemory = GetEnemies()->GetNext(&iter) ) + { + if ( pEMemory->hEnemy->IsAlive() && ( pEMemory->hEnemy->Classify() != CLASS_BULLSEYE ) ) + { + iNumEnemies++; + } + } + set.AppendCriteria( "num_enemies", UTIL_VarArgs( "%d", iNumEnemies ) ); +#endif + if ( m_bReadinessCapable ) { switch( GetReadinessLevel() ) @@ -1574,11 +1915,35 @@ bool CNPC_PlayerCompanion::IsReadinessCapable() return false; #endif +#ifdef MAPBASE +#ifdef HL2_EPISODIC + if (GetActiveWeapon()) +#else + // We already know we have a weapon due to the check above +#endif + { + // Rather than looking up the activity string, we just make sure our weapon accepts a few basic readiness activity overrides. + // This lets us make sure our weapon is readiness-capable to begin with. + CBaseCombatWeapon *pWeapon = GetActiveWeapon(); + if ( pWeapon->ActivityOverride(ACT_IDLE_RELAXED, NULL) == ACT_IDLE_RELAXED && + pWeapon->ActivityOverride( ACT_IDLE_STIMULATED, NULL ) == ACT_IDLE_STIMULATED && + pWeapon->ActivityOverride( ACT_IDLE_AGITATED, NULL ) == ACT_IDLE_AGITATED ) + return false; + +#ifdef MAPBASE + if (EntIsClass(GetActiveWeapon(), gm_isz_class_RPG)) +#else + if (FClassnameIs( GetActiveWeapon(), "weapon_rpg" )) +#endif + return false; + } +#else if( GetActiveWeapon() && LookupActivity("ACT_IDLE_AIM_RIFLE_STIMULATED") == ACT_INVALID ) return false; if( GetActiveWeapon() && FClassnameIs( GetActiveWeapon(), "weapon_rpg" ) ) return false; +#endif return true; } @@ -2329,7 +2694,11 @@ Vector CNPC_PlayerCompanion::GetActualShootPosition( const Vector &shootOrigin ) //------------------------------------------------------------------------------ WeaponProficiency_t CNPC_PlayerCompanion::CalcWeaponProficiency( CBaseCombatWeapon *pWeapon ) { +#ifdef MAPBASE + if ( EntIsClass(pWeapon, gm_iszAR2Classname) ) +#else if( FClassnameIs( pWeapon, "weapon_ar2" ) ) +#endif { return WEAPON_PROFICIENCY_VERY_GOOD; } @@ -2346,7 +2715,11 @@ bool CNPC_PlayerCompanion::Weapon_CanUse( CBaseCombatWeapon *pWeapon ) // If this weapon is a shotgun, take measures to control how many // are being used in this squad. Don't allow a companion to pick up // a shotgun if a squadmate already has one. +#ifdef MAPBASE + if (EntIsClass(pWeapon, gm_iszShotgunClassname)) +#else if( pWeapon->ClassMatches( gm_iszShotgunClassname ) ) +#endif { return (NumWeaponsInSquad("weapon_shotgun") < 1 ); } @@ -2366,6 +2739,15 @@ bool CNPC_PlayerCompanion::ShouldLookForBetterWeapon() if ( m_bDontPickupWeapons ) return false; +#ifdef MAPBASE + // Now that citizens can holster weapons, they might look for a new one while unarmed. + // Since that could already be worked around with OnHolster > DisableWeaponPickup, I decided to keep it that way in case it's desirable. + + // Don't look for a new weapon if we have secondary ammo for our current one. + if (m_iNumGrenades > 0 && IsAltFireCapable() && GetActiveWeapon() && GetActiveWeapon()->UsesSecondaryAmmo()) + return false; +#endif + return BaseClass::ShouldLookForBetterWeapon(); } @@ -2382,10 +2764,94 @@ void CNPC_PlayerCompanion::Weapon_Equip( CBaseCombatWeapon *pWeapon ) void CNPC_PlayerCompanion::PickupWeapon( CBaseCombatWeapon *pWeapon ) { BaseClass::PickupWeapon( pWeapon ); +#ifdef MAPBASE + SetPotentialSpeechTarget( pWeapon ); + SetSpeechTarget(pWeapon); + SpeakIfAllowed( TLK_NEWWEAPON ); + m_OnWeaponPickup.FireOutput( pWeapon, this ); +#else SpeakIfAllowed( TLK_NEWWEAPON ); m_OnWeaponPickup.FireOutput( this, this ); +#endif } +#if COMPANION_MELEE_ATTACK +//----------------------------------------------------------------------------- +// Purpose: Cache user entity field values until spawn is called. +// Input : szKeyName - Key to handle. +// szValue - Value for key. +// Output : Returns true if the key was handled, false if not. +//----------------------------------------------------------------------------- +bool CNPC_PlayerCompanion::KeyValue( const char *szKeyName, const char *szValue ) +{ + // MeleeAttack01 restoration, see CNPC_PlayerCompanion::MeleeAttack1Conditions + if (FStrEq(szKeyName, "EnableMeleeAttack")) + { + if (!FStrEq(szValue, "0")) + CapabilitiesAdd( bits_CAP_INNATE_MELEE_ATTACK1 ); + else + CapabilitiesRemove( bits_CAP_INNATE_MELEE_ATTACK1 ); + + return true; + } + + return BaseClass::KeyValue( szKeyName, szValue ); +} + +//----------------------------------------------------------------------------- +// Purpose: For unused citizen melee attack (vorts might use this too) +// Input : +// Output : +//----------------------------------------------------------------------------- +int CNPC_PlayerCompanion::MeleeAttack1Conditions ( float flDot, float flDist ) +{ + if (!GetActiveWeapon()) + return COND_NONE; + + if (IsMoving()) + { + // Is moving, cond_none + return COND_NONE; + } + + if (flDist > COMPANION_MELEE_DIST) + { + return COND_NONE; // COND_TOO_FAR_TO_ATTACK; + } + else if (flDot < 0.7) + { + return COND_NONE; // COND_NOT_FACING_ATTACK; + } + + if (GetEnemy()) + { + // Check Z + if ( fabs(GetEnemy()->GetAbsOrigin().z - GetAbsOrigin().z) > 64 ) + return COND_NONE; + + if ( GetEnemy()->MyCombatCharacterPointer() && GetEnemy()->MyCombatCharacterPointer()->GetHullType() == HULL_TINY ) + { + return COND_NONE; + } + } + + // Make sure not trying to kick through a window or something. + trace_t tr; + Vector vecSrc, vecEnd; + + vecSrc = WorldSpaceCenter(); + vecEnd = GetEnemy()->WorldSpaceCenter(); + + AI_TraceLine(vecSrc, vecEnd, MASK_SHOT, this, COLLISION_GROUP_NONE, &tr); + if( tr.m_pEnt != GetEnemy() ) + { + return COND_NONE; + } + + return COND_CAN_MELEE_ATTACK1; +} +#endif + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- @@ -2880,11 +3346,19 @@ bool CNPC_PlayerCompanion::OverrideMove( float flInterval ) if ( !overrode && GetNavigator()->GetGoalType() != GOALTYPE_NONE ) { +#ifdef MAPBASE + #define iszEnvFire gm_isz_class_EnvFire +#else string_t iszEnvFire = AllocPooledString( "env_fire" ); +#endif string_t iszBounceBomb = AllocPooledString( "combine_mine" ); #ifdef HL2_EPISODIC +#ifdef MAPBASE + #define iszNPCTurretFloor gm_isz_class_FloorTurret +#else string_t iszNPCTurretFloor = AllocPooledString( "npc_turret_floor" ); +#endif string_t iszEntityFlame = AllocPooledString( "entityflame" ); #endif // HL2_EPISODIC @@ -3503,6 +3977,7 @@ void CNPC_PlayerCompanion::InputDisableWeaponPickup( inputdata_t &inputdata ) m_bDontPickupWeapons = true; } +#ifndef MAPBASE // See CAI_BaseNPC::InputGiveWeapon() //------------------------------------------------------------------------------ // Purpose: Give the NPC in question the weapon specified //------------------------------------------------------------------------------ @@ -3522,6 +3997,7 @@ void CNPC_PlayerCompanion::InputGiveWeapon( inputdata_t &inputdata ) } } } +#endif #if HL2_EPISODIC //------------------------------------------------------------------------------ @@ -3570,6 +4046,9 @@ void CNPC_PlayerCompanion::OnPlayerKilledOther( CBaseEntity *pVictim, const CTak } CBaseEntity *pInflictor = info.GetInflictor(); +#ifdef MAPBASE + AI_CriteriaSet modifiers; +#else int iNumBarrels = 0; int iConsecutivePlayerKills = 0; bool bPuntedGrenade = false; @@ -3578,6 +4057,7 @@ void CNPC_PlayerCompanion::OnPlayerKilledOther( CBaseEntity *pVictim, const CTak bool bVictimWasAttacker = false; bool bHeadshot = false; bool bOneShot = false; +#endif if ( dynamic_cast( pInflictor ) && ( info.GetDamageType() & DMG_BLAST ) ) { @@ -3590,7 +4070,11 @@ void CNPC_PlayerCompanion::OnPlayerKilledOther( CBaseEntity *pVictim, const CTak m_iNumConsecutiveBarrelsExploded++; m_fLastBarrelExploded = gpGlobals->curtime; +#ifdef MAPBASE + modifiers.AppendCriteria( "num_barrels", UTIL_VarArgs("%i", m_iNumConsecutiveBarrelsExploded) ); +#else iNumBarrels = m_iNumConsecutiveBarrelsExploded; +#endif } else { @@ -3602,7 +4086,11 @@ void CNPC_PlayerCompanion::OnPlayerKilledOther( CBaseEntity *pVictim, const CTak } m_iNumConsecutivePlayerKills++; m_fLastPlayerKill = gpGlobals->curtime; +#ifdef MAPBASE + modifiers.AppendCriteria( "consecutive_player_kills", UTIL_VarArgs("%i", m_iNumConsecutivePlayerKills) ); +#else iConsecutivePlayerKills = m_iNumConsecutivePlayerKills; +#endif } // don't comment on kills when she can't see the victim @@ -3612,29 +4100,53 @@ void CNPC_PlayerCompanion::OnPlayerKilledOther( CBaseEntity *pVictim, const CTak } // check if the player killed an enemy by punting a grenade +#ifdef MAPBASE + modifiers.AppendCriteria( "punted_grenade", ( pInflictor && Fraggrenade_WasPunted( pInflictor ) && Fraggrenade_WasCreatedByCombine( pInflictor ) ) ? "1" : "0" ); +#else if ( pInflictor && Fraggrenade_WasPunted( pInflictor ) && Fraggrenade_WasCreatedByCombine( pInflictor ) ) { bPuntedGrenade = true; } +#endif // check if the victim was Alyx's enemy +#ifdef MAPBASE + modifiers.AppendCriteria( "victim_was_enemy", GetEnemy() == pVictim ? "1" : "0" ); +#else if ( GetEnemy() == pVictim ) { bVictimWasEnemy = true; } +#endif AI_EnemyInfo_t *pEMemory = GetEnemies()->Find( pVictim ); if ( pEMemory != NULL ) { // was Alyx being mobbed by this enemy? +#ifdef MAPBASE + modifiers.AppendCriteria( "victim_was_mob", pEMemory->bMobbedMe ? "1" : "0" ); + modifiers.AppendCriteria( "victim_was_attacker", pEMemory->timeLastReceivedDamageFrom > 0 ? "1" : "0" ); +#else bVictimWasMob = pEMemory->bMobbedMe; // has Alyx recieved damage from this enemy? if ( pEMemory->timeLastReceivedDamageFrom > 0 ) { bVictimWasAttacker = true; } +#endif } +#ifdef MAPBASE + else + { + modifiers.AppendCriteria( "victim_was_mob", "0" ); + modifiers.AppendCriteria( "victim_was_attacker", "0" ); + } +#endif +#ifdef MAPBASE + modifiers.AppendCriteria( "headshot", ((pCombatVictim->LastHitGroup() == HITGROUP_HEAD) && (info.GetDamageType() & DMG_BULLET)) ? "1" : "0" ); + modifiers.AppendCriteria( "oneshot", ((pCombatVictim->GetDamageCount() == 1) && (info.GetDamageType() & DMG_BULLET)) ? "1" : "0" ); +#else // Was it a headshot? if ( ( pCombatVictim->LastHitGroup() == HITGROUP_HEAD ) && ( info.GetDamageType() & DMG_BULLET ) ) { @@ -3646,18 +4158,145 @@ void CNPC_PlayerCompanion::OnPlayerKilledOther( CBaseEntity *pVictim, const CTak { bOneShot = true; } +#endif +#ifdef MAPBASE + ModifyOrAppendEnemyCriteria(modifiers, pVictim); +#else // set up the speech modifiers CFmtStrN<512> modifiers( "num_barrels:%d,distancetoplayerenemy:%f,playerAmmo:%s,consecutive_player_kills:%d," "punted_grenade:%d,victim_was_enemy:%d,victim_was_mob:%d,victim_was_attacker:%d,headshot:%d,oneshot:%d", iNumBarrels, EnemyDistance( pVictim ), info.GetAmmoName(), iConsecutivePlayerKills, bPuntedGrenade, bVictimWasEnemy, bVictimWasMob, bVictimWasAttacker, bHeadshot, bOneShot ); +#endif SpeakIfAllowed( TLK_PLAYER_KILLED_NPC, modifiers ); BaseClass::OnPlayerKilledOther( pVictim, info ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CNPC_PlayerCompanion::Event_KilledOther( CBaseEntity *pVictim, const CTakeDamageInfo &info ) +{ + if ( pVictim ) + { + if (pVictim->IsPlayer() || (pVictim->IsNPC() && + ( pVictim->MyNPCPointer()->GetLastPlayerDamageTime() == 0 || + gpGlobals->curtime - pVictim->MyNPCPointer()->GetLastPlayerDamageTime() > 5 )) ) + { + AI_CriteriaSet modifiers; + + AI_EnemyInfo_t *pEMemory = GetEnemies()->Find( pVictim ); + if ( pEMemory != NULL ) + { + modifiers.AppendCriteria( "victim_was_mob", pEMemory->bMobbedMe ? "1" : "0" ); + modifiers.AppendCriteria( "victim_was_attacker", pEMemory->timeLastReceivedDamageFrom > 0 ? "1" : "0" ); + } + else + { + modifiers.AppendCriteria( "victim_was_mob", "0" ); + modifiers.AppendCriteria( "victim_was_attacker", "0" ); + } + + CBaseCombatCharacter *pCombatVictim = pVictim->MyCombatCharacterPointer(); + if (pCombatVictim) + { + modifiers.AppendCriteria( "headshot", ((pCombatVictim->LastHitGroup() == HITGROUP_HEAD) && (info.GetDamageType() & DMG_BULLET)) ? "1" : "0" ); + modifiers.AppendCriteria( "oneshot", ((pCombatVictim->GetDamageCount() == 1) && (info.GetDamageType() & DMG_BULLET)) ? "1" : "0" ); + } + else + { + modifiers.AppendCriteria( "headshot", "0" ); + modifiers.AppendCriteria( "oneshot", "0" ); + } + + SetPotentialSpeechTarget( pVictim ); + SetSpeechTarget( pVictim ); + SpeakIfAllowed( TLK_ENEMY_DEAD, modifiers ); + } + } +} + +//----------------------------------------------------------------------------- +// Purpose: Handles stuff ported from Alyx. +// +// For some reason, I thought Alyx's mobbed AI was used to measure enemy count for criteria stuff, which I wanted citizens to use. +// Now that I realize enemy counting for criteria is elsewhere and this is used for just mobbing in general, I deactivated it +// since it would barely be used and I don't know what kind of an impact it has on performance. +// +// If you want to use it, feel free to re-activate. +//----------------------------------------------------------------------------- +void CNPC_PlayerCompanion::DoCustomCombatAI( void ) +{ + /* + #define COMPANION_MIN_MOB_DIST_SQR Square(120) // Any enemy closer than this adds to the 'mob' + #define COMPANION_MIN_CONSIDER_DIST Square(1200) // Only enemies within this range are counted and considered to generate AI speech + + AIEnemiesIter_t iter; + + float visibleEnemiesScore = 0.0f; + float closeEnemiesScore = 0.0f; + + for ( AI_EnemyInfo_t *pEMemory = GetEnemies()->GetFirst(&iter); pEMemory != NULL; pEMemory = GetEnemies()->GetNext(&iter) ) + { + if ( IRelationType( pEMemory->hEnemy ) != D_NU && IRelationType( pEMemory->hEnemy ) != D_LI && pEMemory->hEnemy->GetAbsOrigin().DistToSqr(GetAbsOrigin()) <= COMPANION_MIN_CONSIDER_DIST ) + { + if( pEMemory->hEnemy && pEMemory->hEnemy->IsAlive() && gpGlobals->curtime - pEMemory->timeLastSeen <= 0.5f && pEMemory->hEnemy->Classify() != CLASS_BULLSEYE ) + { + if( pEMemory->hEnemy->GetAbsOrigin().DistToSqr(GetAbsOrigin()) <= COMPANION_MIN_MOB_DIST_SQR ) + { + closeEnemiesScore += 1.0f; + } + else + { + visibleEnemiesScore += 1.0f; + } + } + } + } + + if( closeEnemiesScore > 2 ) + { + SetCondition( COND_MOBBED_BY_ENEMIES ); + + // mark anyone in the mob as having mobbed me + for ( AI_EnemyInfo_t *pEMemory = GetEnemies()->GetFirst(&iter); pEMemory != NULL; pEMemory = GetEnemies()->GetNext(&iter) ) + { + if ( pEMemory->bMobbedMe ) + continue; + + if ( IRelationType( pEMemory->hEnemy ) != D_NU && IRelationType( pEMemory->hEnemy ) != D_LI && pEMemory->hEnemy->GetAbsOrigin().DistToSqr(GetAbsOrigin()) <= COMPANION_MIN_CONSIDER_DIST ) + { + if( pEMemory->hEnemy && pEMemory->hEnemy->IsAlive() && gpGlobals->curtime - pEMemory->timeLastSeen <= 0.5f && pEMemory->hEnemy->Classify() != CLASS_BULLSEYE ) + { + if( pEMemory->hEnemy->GetAbsOrigin().DistToSqr(GetAbsOrigin()) <= COMPANION_MIN_MOB_DIST_SQR ) + { + pEMemory->bMobbedMe = true; + } + } + } + } + } + else + { + ClearCondition( COND_MOBBED_BY_ENEMIES ); + } + + // Say a combat thing + if( HasCondition( COND_MOBBED_BY_ENEMIES ) ) + { + SpeakIfAllowed( TLK_MOBBED ); + } + else if( visibleEnemiesScore > 4 ) + { + SpeakIfAllowed( TLK_MANY_ENEMIES ); + } + */ +} +#endif + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- bool CNPC_PlayerCompanion::IsNavigationUrgent( void ) @@ -3712,10 +4351,20 @@ AI_BEGIN_CUSTOM_NPC( player_companion_base, CNPC_PlayerCompanion ) DECLARE_TASK( TASK_PC_WAITOUT_MORTAR ) DECLARE_TASK( TASK_PC_GET_PATH_OFF_COMPANION ) +#ifdef MAPBASE + DECLARE_TASK( TASK_PC_PLAY_SEQUENCE_FACE_ALTFIRE_TARGET ) + DECLARE_TASK( TASK_PC_GET_PATH_TO_FORCED_GREN_LOS ) + DECLARE_TASK( TASK_PC_DEFER_SQUAD_GRENADES ) + DECLARE_TASK( TASK_PC_FACE_TOSS_DIR ) +#endif DECLARE_ANIMEVENT( AE_COMPANION_PRODUCE_FLARE ) DECLARE_ANIMEVENT( AE_COMPANION_LIGHT_FLARE ) DECLARE_ANIMEVENT( AE_COMPANION_RELEASE_FLARE ) +#ifdef MAPBASE + DECLARE_ANIMEVENT( COMBINE_AE_BEGIN_ALTFIRE ) + DECLARE_ANIMEVENT( COMBINE_AE_ALTFIRE ) +#endif //========================================================= // > TakeCoverFromBestSound @@ -3845,6 +4494,107 @@ AI_BEGIN_CUSTOM_NPC( player_companion_base, CNPC_PlayerCompanion ) "" ) +#ifdef COMPANION_MELEE_ATTACK + DEFINE_SCHEDULE + ( + SCHED_PC_MELEE_AND_MOVE_AWAY, + + " Tasks" + " TASK_STOP_MOVING 0" + " TASK_FACE_ENEMY 0" + " TASK_ANNOUNCE_ATTACK 1" // 1 = primary attack + " TASK_MELEE_ATTACK1 0" + " TASK_SET_SCHEDULE SCHEDULE:SCHED_MOVE_AWAY_FROM_ENEMY" + "" + " Interrupts" + " COND_NEW_ENEMY" + " COND_ENEMY_DEAD" + //" COND_LIGHT_DAMAGE" + " COND_HEAVY_DAMAGE" + " COND_ENEMY_OCCLUDED" + ) +#endif + +#ifdef MAPBASE + //========================================================= + // AR2 Alt Fire Attack + //========================================================= + DEFINE_SCHEDULE + ( + SCHED_PC_AR2_ALTFIRE, + + " Tasks" + " TASK_STOP_MOVING 0" + " TASK_ANNOUNCE_ATTACK 1" + " TASK_PC_PLAY_SEQUENCE_FACE_ALTFIRE_TARGET ACTIVITY:ACT_COMBINE_AR2_ALTFIRE" + "" + " Interrupts" + " COND_TOO_CLOSE_TO_ATTACK" + ) + + //========================================================= + // Move to LOS of the mapmaker's forced grenade throw target + //========================================================= + DEFINE_SCHEDULE + ( + SCHED_PC_MOVE_TO_FORCED_GREN_LOS, + + " Tasks " + " TASK_SET_TOLERANCE_DISTANCE 48" + " TASK_PC_GET_PATH_TO_FORCED_GREN_LOS 0" + " TASK_SPEAK_SENTENCE 1" + " TASK_RUN_PATH 0" + " TASK_WAIT_FOR_MOVEMENT 0" + " " + " Interrupts " + " COND_NEW_ENEMY" + " COND_ENEMY_DEAD" + " COND_CAN_MELEE_ATTACK1" + " COND_CAN_MELEE_ATTACK2" + " COND_HEAR_DANGER" + " COND_HEAR_MOVE_AWAY" + " COND_HEAVY_DAMAGE" + ) + + //========================================================= + // Mapmaker forced grenade throw + //========================================================= + DEFINE_SCHEDULE + ( + SCHED_PC_FORCED_GRENADE_THROW, + + " Tasks" + " TASK_STOP_MOVING 0" + " TASK_PC_FACE_TOSS_DIR 0" + " TASK_ANNOUNCE_ATTACK 2" // 2 = grenade + " TASK_PLAY_SEQUENCE ACTIVITY:ACT_RANGE_ATTACK2" + " TASK_PC_DEFER_SQUAD_GRENADES 0" + "" + " Interrupts" + ) + + //========================================================= + // SCHED_PC_RANGE_ATTACK2 + // + // secondary range attack. Overriden because base class stops attacking when the enemy is occluded. + // combines's grenade toss requires the enemy be occluded. + //========================================================= + DEFINE_SCHEDULE + ( + SCHED_PC_RANGE_ATTACK2, + + " Tasks" + " TASK_STOP_MOVING 0" + " TASK_PC_FACE_TOSS_DIR 0" + " TASK_ANNOUNCE_ATTACK 2" // 2 = grenade + " TASK_PLAY_SEQUENCE ACTIVITY:ACT_RANGE_ATTACK2" + " TASK_PC_DEFER_SQUAD_GRENADES 0" + " TASK_SET_SCHEDULE SCHEDULE:SCHED_HIDE_AND_RELOAD" // don't run immediately after throwing grenade. + "" + " Interrupts" + ) +#endif + AI_END_CUSTOM_NPC() diff --git a/sp/src/game/server/hl2/npc_playercompanion.h b/sp/src/game/server/hl2/npc_playercompanion.h index f1c3b1f3..2165db1c 100644 --- a/sp/src/game/server/hl2/npc_playercompanion.h +++ b/sp/src/game/server/hl2/npc_playercompanion.h @@ -22,6 +22,10 @@ #include "ai_behavior_passenger_companion.h" #endif +#ifdef MAPBASE +#include "mapbase/ai_grenade.h" +#endif + #if defined( _WIN32 ) #pragma once #endif @@ -85,15 +89,25 @@ public: class CPhysicsProp; +#ifdef MAPBASE +// If you think about it, this is really unnecessary. +//#define COMPANION_MELEE_ATTACK 1 +#endif + //----------------------------------------------------------------------------- // // CLASS: CNPC_PlayerCompanion // //----------------------------------------------------------------------------- - +#ifdef MAPBASE +class CNPC_PlayerCompanion : public CAI_GrenadeUser +{ + DECLARE_CLASS( CNPC_PlayerCompanion, CAI_GrenadeUser ); +#else class CNPC_PlayerCompanion : public CAI_PlayerAlly { DECLARE_CLASS( CNPC_PlayerCompanion, CAI_PlayerAlly ); +#endif public: //--------------------------------- @@ -189,7 +203,9 @@ public: virtual void ReadinessLevelChanged( int iPriorLevel ) { } +#ifndef MAPBASE void InputGiveWeapon( inputdata_t &inputdata ); +#endif #ifdef HL2_EPISODIC //--------------------------------- @@ -217,6 +233,13 @@ public: public: virtual void OnPlayerKilledOther( CBaseEntity *pVictim, const CTakeDamageInfo &info ); +#ifdef MAPBASE + // This is just here to overwrite ai_playerally's TLK_ENEMY_DEAD + virtual void OnKilledNPC(CBaseCombatCharacter *pKilled) {} + + virtual void Event_KilledOther( CBaseEntity *pVictim, const CTakeDamageInfo &info ); + virtual void DoCustomCombatAI( void ); +#endif //--------------------------------- //--------------------------------- @@ -256,6 +279,11 @@ public: bool Weapon_CanUse( CBaseCombatWeapon *pWeapon ); void Weapon_Equip( CBaseCombatWeapon *pWeapon ); void PickupWeapon( CBaseCombatWeapon *pWeapon ); + +#if COMPANION_MELEE_ATTACK + bool KeyValue( const char *szKeyName, const char *szValue ); + int MeleeAttack1Conditions( float flDot, float flDist ); +#endif bool FindCoverPos( CBaseEntity *pEntity, Vector *pResult); bool FindCoverPosInRadius( CBaseEntity *pEntity, const Vector &goalPos, float coverRadius, Vector *pResult ); @@ -308,6 +336,22 @@ public: bool AllowReadinessValueChange( void ); +#ifdef MAPBASE + virtual bool IsAltFireCapable() { return (m_iGrenadeCapabilities & GRENCAP_ALTFIRE) != 0; } + virtual bool IsGrenadeCapable() { return (m_iGrenadeCapabilities & GRENCAP_GRENADE) != 0; } + +private: + + enum eGrenadeCapabilities + { + GRENCAP_GRENADE = (1 << 0), + GRENCAP_ALTFIRE = (1 << 1), + }; + + // Determines whether this NPC is allowed to use grenades or alt-fire stuff. + eGrenadeCapabilities m_iGrenadeCapabilities; +#endif + protected: //----------------------------------------------------- // Conditions, Schedules, Tasks @@ -326,10 +370,25 @@ protected: SCHED_PC_FAIL_TAKE_COVER_TURRET, SCHED_PC_FAKEOUT_MORTAR, SCHED_PC_GET_OFF_COMPANION, +#ifdef COMPANION_MELEE_ATTACK + SCHED_PC_MELEE_AND_MOVE_AWAY, +#endif +#ifdef MAPBASE + SCHED_PC_AR2_ALTFIRE, + SCHED_PC_MOVE_TO_FORCED_GREN_LOS, + SCHED_PC_FORCED_GRENADE_THROW, + SCHED_PC_RANGE_ATTACK2, // Grenade throw +#endif NEXT_SCHEDULE, TASK_PC_WAITOUT_MORTAR = BaseClass::NEXT_TASK, TASK_PC_GET_PATH_OFF_COMPANION, +#ifdef MAPBASE + TASK_PC_PLAY_SEQUENCE_FACE_ALTFIRE_TARGET, + TASK_PC_GET_PATH_TO_FORCED_GREN_LOS, + TASK_PC_DEFER_SQUAD_GRENADES, + TASK_PC_FACE_TOSS_DIR, +#endif NEXT_TASK, }; @@ -406,11 +465,25 @@ protected: //----------------------------------------------------- +#ifdef MAPBASE + static string_t gm_iszMortarClassname; + #define gm_iszFloorTurretClassname gm_isz_class_FloorTurret + static string_t gm_iszGroundTurretClassname; + #define gm_iszShotgunClassname gm_isz_class_Shotgun + static string_t gm_iszRollerMineClassname; + #define gm_iszSMG1Classname gm_isz_class_SMG1 + #define gm_iszAR2Classname gm_isz_class_AR2 +#else static string_t gm_iszMortarClassname; static string_t gm_iszFloorTurretClassname; static string_t gm_iszGroundTurretClassname; static string_t gm_iszShotgunClassname; static string_t gm_iszRollerMineClassname; +#ifdef MAPBASE + static string_t gm_iszSMG1Classname; + static string_t gm_iszAR2Classname; +#endif +#endif //----------------------------------------------------- @@ -424,6 +497,10 @@ protected: COutputEvent m_OnWeaponPickup; +#if COMPANION_MELEE_ATTACK + int m_nMeleeDamage; +#endif + CStopwatch m_SpeechWatch_PlayerLooking; DECLARE_DATADESC(); diff --git a/sp/src/game/server/hl2/npc_rollermine.cpp b/sp/src/game/server/hl2/npc_rollermine.cpp index d850fe2c..ec9be919 100644 --- a/sp/src/game/server/hl2/npc_rollermine.cpp +++ b/sp/src/game/server/hl2/npc_rollermine.cpp @@ -388,7 +388,11 @@ BEGIN_DATADESC( CNPC_RollerMine ) DEFINE_FIELD( m_bBuried, FIELD_BOOLEAN ), DEFINE_FIELD( m_wakeUp, FIELD_BOOLEAN ), DEFINE_FIELD( m_bEmbedOnGroundImpact, FIELD_BOOLEAN ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bHackedByAlyx, FIELD_BOOLEAN, "Hacked" ), +#else DEFINE_FIELD( m_bHackedByAlyx, FIELD_BOOLEAN ), +#endif DEFINE_FIELD( m_bPowerDown, FIELD_BOOLEAN ), DEFINE_FIELD( m_flPowerDownTime, FIELD_TIME ), @@ -543,6 +547,9 @@ void CNPC_RollerMine::Spawn( void ) BaseClass::Spawn(); AddEFlags( EFL_NO_DISSOLVE ); +#ifdef MAPBASE + AddEFlags( EFL_NO_MEGAPHYSCANNON_RAGDOLL ); +#endif CapabilitiesClear(); CapabilitiesAdd( bits_CAP_MOVE_GROUND | bits_CAP_INNATE_RANGE_ATTACK1 | bits_CAP_SQUAD ); @@ -1957,6 +1964,10 @@ void CNPC_RollerMine::NotifyInteraction( CAI_BaseNPC *pUser ) // Force the rollermine open here. At very least, this ensures that the // correct, smaller bounding box is recomputed around it. Open(); + +#ifdef MAPBASE + m_OnHacked.FireOutput(pUser, this); +#endif } //----------------------------------------------------------------------------- diff --git a/sp/src/game/server/hl2/npc_scanner.cpp b/sp/src/game/server/hl2/npc_scanner.cpp index 031ce6d9..0a64dbba 100644 --- a/sp/src/game/server/hl2/npc_scanner.cpp +++ b/sp/src/game/server/hl2/npc_scanner.cpp @@ -179,6 +179,11 @@ BEGIN_DATADESC( CNPC_CScanner ) DEFINE_INPUTFUNC( FIELD_STRING, "DeployMine", InputDeployMine ), DEFINE_INPUTFUNC( FIELD_STRING, "EquipMine", InputEquipMine ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "DisablePhotos", InputDisablePhotos ), + DEFINE_INPUTFUNC( FIELD_VOID, "EnablePhotos", InputEnablePhotos ), +#endif + DEFINE_OUTPUT( m_OnPhotographPlayer, "OnPhotographPlayer" ), DEFINE_OUTPUT( m_OnPhotographNPC, "OnPhotographNPC" ), @@ -217,6 +222,10 @@ CNPC_CScanner::CNPC_CScanner() { m_bIsClawScanner = false; } + +#ifdef MAPBASE + CapabilitiesAdd( bits_CAP_INNATE_MELEE_ATTACK1 ); +#endif } //----------------------------------------------------------------------------- @@ -289,7 +298,9 @@ void CNPC_CScanner::Spawn(void) // -------------------------------------------- +#ifndef MAPBASE // Moved to constructor so keyvalue works CapabilitiesAdd( bits_CAP_INNATE_MELEE_ATTACK1 ); +#endif m_bPhotoTaken = false; @@ -319,6 +330,27 @@ void CNPC_CScanner::Activate() m_pEyeFlash->SetScale( 1.4 ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Cache user entity field values until spawn is called. +// Input : szKeyName - Key to handle. +// szValue - Value for key. +// Output : Returns true if the key was handled, false if not. +//----------------------------------------------------------------------------- +bool CNPC_CScanner::KeyValue( const char *szKeyName, const char *szValue ) +{ + // Any "Counter" outputs are changed to "OutCounter" before spawning. + if (FStrEq(szKeyName, "DisablePhotos") && FStrEq(szValue, "1")) + { + CapabilitiesRemove(bits_CAP_INNATE_MELEE_ATTACK1); + } + else + return BaseClass::KeyValue( szKeyName, szValue ); + + return true; +} +#endif + //------------------------------------------------------------------------------ // Purpose: Override to split in two when attacked //------------------------------------------------------------------------------ @@ -1034,6 +1066,24 @@ void CNPC_CScanner::InputEquipMine(inputdata_t &inputdata) pEnt->Spawn(); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CNPC_CScanner::InputDisablePhotos( inputdata_t &inputdata ) +{ + CapabilitiesRemove(bits_CAP_INNATE_MELEE_ATTACK1); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CNPC_CScanner::InputEnablePhotos( inputdata_t &inputdata ) +{ + CapabilitiesAdd(bits_CAP_INNATE_MELEE_ATTACK1); +} +#endif + //----------------------------------------------------------------------------- // Purpose: Tells the scanner to go photograph an entity. @@ -1450,6 +1500,10 @@ int CNPC_CScanner::SelectSchedule(void) return SCHED_CSCANNER_SPOTLIGHT_HOVER; // Melee attack if possible +#ifdef MAPBASE + if ( CapabilitiesGet() & bits_CAP_INNATE_MELEE_ATTACK1 ) + { +#endif if ( HasCondition( COND_CAN_MELEE_ATTACK1 ) ) { if ( random->RandomInt(0,1) ) @@ -1458,6 +1512,13 @@ int CNPC_CScanner::SelectSchedule(void) // TODO: a schedule where he makes an alarm sound? return SCHED_SCANNER_CHASE_ENEMY; } +#ifdef MAPBASE + } + else + { + return SCHED_CSCANNER_SPOTLIGHT_HOVER; + } +#endif // If I'm far from the enemy, stay up high and approach in spotlight mode float fAttack2DDist = ( GetEnemyLKP() - GetAbsOrigin() ).Length2D(); @@ -1866,6 +1927,15 @@ void CNPC_CScanner::UpdateOnRemove( void ) //------------------------------------------------------------------------------ void CNPC_CScanner::TakePhoto(void) { +#ifdef MAPBASE + // Only take photos if we're allowed + if (!(CapabilitiesGet() & bits_CAP_INNATE_MELEE_ATTACK1)) + { + m_bPhotoTaken = true; + return; + } +#endif + ScannerEmitSound( "TakePhoto" ); m_pEyeFlash->SetScale( 1.4 ); diff --git a/sp/src/game/server/hl2/npc_scanner.h b/sp/src/game/server/hl2/npc_scanner.h index f34eba35..109b2a7d 100644 --- a/sp/src/game/server/hl2/npc_scanner.h +++ b/sp/src/game/server/hl2/npc_scanner.h @@ -51,6 +51,9 @@ public: virtual char *GetScannerSoundPrefix( void ); void Spawn(void); void Activate(); +#ifdef MAPBASE + bool KeyValue( const char *szKeyName, const char *szValue ); +#endif void StartTask( const Task_t *pTask ); void UpdateOnRemove( void ); void DeployMine(); @@ -67,6 +70,10 @@ public: void InputInspectTargetSpotlight( inputdata_t &inputdata ); void InputDeployMine( inputdata_t &inputdata ); void InputEquipMine( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputDisablePhotos( inputdata_t &inputdata ); + void InputEnablePhotos( inputdata_t &inputdata ); +#endif void InputShouldInspect( inputdata_t &inputdata ); void InspectTarget( inputdata_t &inputdata, ScannerFlyMode_t eFlyMode ); diff --git a/sp/src/game/server/hl2/npc_stalker.cpp b/sp/src/game/server/hl2/npc_stalker.cpp index 204d7a55..0165c29d 100644 --- a/sp/src/game/server/hl2/npc_stalker.cpp +++ b/sp/src/game/server/hl2/npc_stalker.cpp @@ -126,7 +126,14 @@ BEGIN_DATADESC( CNPC_Stalker ) DEFINE_FIELD( m_flNextBreatheSoundTime, FIELD_TIME ), DEFINE_FIELD( m_flNextScrambleSoundTime, FIELD_TIME ), DEFINE_FIELD( m_nextSmokeTime, FIELD_TIME ), +#ifdef MAPBASE + // Funnily enough, we can very easily treat this as a boolean value in Hammer + // since "0" means don't attack and "1" means attack. There is no unique behavior beyond 1. + DEFINE_KEYFIELD( m_iPlayerAggression, FIELD_INTEGER, "Aggression" ), + DEFINE_KEYFIELD( m_bBleed, FIELD_BOOLEAN, "Bleed" ), +#else DEFINE_FIELD( m_iPlayerAggression, FIELD_INTEGER ), +#endif DEFINE_FIELD( m_flNextScreamTime, FIELD_TIME ), // Function Pointers @@ -300,7 +307,9 @@ void CNPC_Stalker::Spawn( void ) m_flDistTooFar = MAX_STALKER_FIRE_RANGE; +#ifndef MAPBASE m_iPlayerAggression = 0; +#endif GetSenses()->SetDistLook(MAX_STALKER_FIRE_RANGE - 1); } @@ -329,6 +338,11 @@ void CNPC_Stalker::Precache( void ) PrecacheScriptSound( "NPC_Stalker.Pain" ); PrecacheScriptSound( "NPC_Stalker.Die" ); +#ifdef MAPBASE + if (m_bBleed) + PrecacheParticleSystem( "blood_impact_synth_01" ); +#endif + BaseClass::Precache(); } @@ -389,6 +403,33 @@ void CNPC_Stalker::Event_Killed( const CTakeDamageInfo &info ) BaseClass::Event_Killed( info ); } +#ifdef MAPBASE +extern void DispatchParticleEffect( const char *pszParticleName, Vector vecOrigin, QAngle vecAngles, CBaseEntity *pEntity = NULL ); + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CNPC_Stalker::TraceAttack( const CTakeDamageInfo &inputInfo, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator ) +{ + // Is it insane to desire for stalkers to bleed? No. + // Is it insane to port the hunter's blood particle system because + // it fits with the fact stalkers probably don't run on regular blood anymore? Maybe. + if (m_bBleed) + { + if ( ( inputInfo.GetDamageType() & DMG_BULLET ) || + ( inputInfo.GetDamageType() & DMG_BUCKSHOT ) || + ( inputInfo.GetDamageType() & DMG_CLUB ) || + ( inputInfo.GetDamageType() & DMG_NEVERGIB ) ) + { + QAngle vecAngles; + VectorAngles( ptr->plane.normal, vecAngles ); + DispatchParticleEffect( "blood_impact_synth_01", ptr->endpos, vecAngles ); + } + } + + BaseClass::TraceAttack( inputInfo, vecDir, ptr, pAccumulator ); +} +#endif + //----------------------------------------------------------------------------- // Purpose: // Input : @@ -1106,6 +1147,30 @@ void CNPC_Stalker::DrawAttackBeam(void) */ } +#ifdef MAPBASE +//------------------------------------------------------------------------------ +// Purpose: Fixes stalker beam cleanup not working correctly +//------------------------------------------------------------------------------ +void CNPC_Stalker::UpdateOnRemove( void ) +{ + if (m_pBeam) + { + StopSound(m_pBeam->entindex(), "NPC_Stalker.BurnWall" ); + StopSound(m_pBeam->entindex(), "NPC_Stalker.BurnFlesh" ); + + UTIL_Remove( m_pLightGlow ); + UTIL_Remove( m_pBeam); + m_pBeam = NULL; + m_bPlayingHitWall = false; + m_bPlayingHitFlesh = false; + + SetThink(NULL); + } + + BaseClass::UpdateOnRemove(); +} +#endif + //------------------------------------------------------------------------------ // Purpose : Draw attack beam and do damage / decals // Input : @@ -1168,7 +1233,11 @@ bool CNPC_Stalker::InnateWeaponLOSCondition( const Vector &ownerPos, const Vecto } else if (pBCC) { +#ifdef MAPBASE + if (IRelationType( pBCC ) <= D_FR) +#else if (IRelationType( pBCC ) == D_HT) +#endif { return true; } diff --git a/sp/src/game/server/hl2/npc_stalker.h b/sp/src/game/server/hl2/npc_stalker.h index dc2c08e5..206d199d 100644 --- a/sp/src/game/server/hl2/npc_stalker.h +++ b/sp/src/game/server/hl2/npc_stalker.h @@ -46,9 +46,19 @@ public: float m_bPlayingHitFlesh; CBeam* m_pBeam; CSprite* m_pLightGlow; +#ifdef MAPBASE + // This is a keyvalue now, so we have to initialize the value through somewhere that isn't Spawn() + int m_iPlayerAggression = 0; + bool m_bBleed; +#else int m_iPlayerAggression; +#endif float m_flNextScreamTime; +#ifdef MAPBASE + void UpdateOnRemove( void ); +#endif + void KillAttackBeam(void); void DrawAttackBeam(void); void CalcBeamPosition(void); @@ -97,6 +107,9 @@ public: void PainSound( const CTakeDamageInfo &info ); void Event_Killed( const CTakeDamageInfo &info ); +#ifdef MAPBASE + void TraceAttack( const CTakeDamageInfo &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator ); +#endif void DoSmokeEffect( const Vector &position ); void AddZigZagToPath(void); diff --git a/sp/src/game/server/hl2/npc_strider.cpp b/sp/src/game/server/hl2/npc_strider.cpp index 60d37cdf..4d762783 100644 --- a/sp/src/game/server/hl2/npc_strider.cpp +++ b/sp/src/game/server/hl2/npc_strider.cpp @@ -54,6 +54,10 @@ #include "filters.h" #include "saverestore_utlvector.h" #include "eventqueue.h" +#ifdef MAPBASE +#include "npc_basescanner.h" +#include "mapbase/GlobalStrings.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -328,6 +332,11 @@ BEGIN_DATADESC( CNPC_Strider ) DEFINE_FIELD( m_hCannonTarget, FIELD_EHANDLE ), DEFINE_EMBEDDED( m_AttemptCannonLOSTimer ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_strStompFilter, FIELD_STRING, "stompfilter" ), + DEFINE_FIELD( m_hStompFilter, FIELD_EHANDLE ), +#endif + DEFINE_FIELD( m_flSpeedScale, FIELD_FLOAT ), DEFINE_FIELD( m_flTargetSpeedScale, FIELD_FLOAT ), @@ -392,6 +401,10 @@ BEGIN_DATADESC( CNPC_Strider ) DEFINE_INPUTFUNC( FIELD_VOID, "Explode", InputExplode ), DEFINE_INPUTFUNC( FIELD_FLOAT, "ScaleGroundSpeed", InputScaleGroundSpeed ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_STRING, "SetStompFilter", InputSetStompFilter ), +#endif + // Function Pointers // DEFINE_FUNCTION( JumpTouch ), DEFINE_THINKFUNC( CarriedThink ), @@ -1105,7 +1118,11 @@ void CNPC_Strider::GatherConditions() // Don't switch targets if shooting at a bullseye! Level designers depend on bullseyes. if( GetEnemy() && m_pMinigun->IsShooting() && GetTimeEnemyAcquired() != gpGlobals->curtime ) { +#ifdef MAPBASE + if( m_pMinigun->IsOnTarget( 3 ) && !EntIsClass( GetEnemy(), gm_isz_class_Bullseye ) ) +#else if( m_pMinigun->IsOnTarget( 3 ) && !FClassnameIs( GetEnemy(), "npc_bullseye" ) ) +#endif { if( m_iVisibleEnemies > 1 ) { @@ -1993,7 +2010,11 @@ Disposition_t CNPC_Strider::IRelationType( CBaseEntity *pTarget ) //--------------------------------------------------------- void CNPC_Strider::AddEntityRelationship( CBaseEntity *pEntity, Disposition_t nDisposition, int nPriority ) { +#ifdef MAPBASE + if ( nDisposition == D_HT && EntIsClass(pEntity, gm_isz_class_Bullseye) ) +#else if ( nDisposition == D_HT && pEntity->ClassMatches("npc_bullseye") ) +#endif UpdateEnemyMemory( pEntity, pEntity->GetAbsOrigin() ); BaseClass::AddEntityRelationship( pEntity, nDisposition, nPriority ); } @@ -2361,6 +2382,16 @@ void CNPC_Strider::InputScaleGroundSpeed( inputdata_t &inputdata ) m_flTargetSpeedScale = inputdata.value.Float(); } +#ifdef MAPBASE +//--------------------------------------------------------- +//--------------------------------------------------------- +void CNPC_Strider::InputSetStompFilter( inputdata_t &inputdata ) +{ + m_strStompFilter = inputdata.value.StringID(); + m_hStompFilter = NULL; +} +#endif + //--------------------------------------------------------- //--------------------------------------------------------- bool CNPC_Strider::FVisible( CBaseEntity *pEntity, int traceMask, CBaseEntity **ppBlocker ) @@ -2426,7 +2457,11 @@ bool CNPC_Strider::IsValidEnemy( CBaseEntity *pTarget ) //--------------------------------------------------------- bool CNPC_Strider::UpdateEnemyMemory( CBaseEntity *pEnemy, const Vector &position, CBaseEntity *pInformer ) { +#ifdef MAPBASE + if (dynamic_cast(pInformer)) +#else if( pInformer && FClassnameIs( pInformer, "npc_cscanner" ) ) +#endif { EmitSound( "NPC_Strider.Alert" ); // Move Strider's focus to this location and make strider mad at it @@ -2557,6 +2592,14 @@ int CNPC_Strider::MeleeAttack1Conditions( float flDot, float flDist ) return COND_NONE; } +#ifdef MAPBASE + if (GetStompFilter()) + { + if (!GetStompFilter()->PassesFilter(this, pEnemy)) + return COND_NONE; + } +#endif + // recompute this because the base class function does not work for the strider flDist = StriderEnemyDistance( pEnemy ); @@ -4378,6 +4421,35 @@ void CNPC_Strider::StompHit( int followerBoneIndex ) } } +#ifdef MAPBASE +//--------------------------------------------------------- +//--------------------------------------------------------- +CBaseFilter *CNPC_Strider::GetStompFilter() +{ + if (m_hStompFilter) + return m_hStompFilter; + + if (m_strStompFilter != NULL_STRING) + { + CBaseEntity *pEntity = gEntList.FindEntityByName(NULL, m_strStompFilter); + if (pEntity) + { + m_hStompFilter = dynamic_cast(pEntity); + if (m_hStompFilter) + return m_hStompFilter; + else + Warning("%s stomp filter %s not a filter!", GetDebugName(), STRING(m_strStompFilter)); + } + else + { + Warning("%s stomp filter not found!", GetDebugName(), STRING(m_strStompFilter)); + } + } + + return NULL; +} +#endif + //--------------------------------------------------------- //--------------------------------------------------------- void CNPC_Strider::FootFX( const Vector &origin ) diff --git a/sp/src/game/server/hl2/npc_strider.h b/sp/src/game/server/hl2/npc_strider.h index dd645781..a9074599 100644 --- a/sp/src/game/server/hl2/npc_strider.h +++ b/sp/src/game/server/hl2/npc_strider.h @@ -14,6 +14,9 @@ #include "smoke_trail.h" #include "physics_bone_follower.h" #include "physics_prop_ragdoll.h" +#ifdef MAPBASE +#include "filters.h" +#endif #if defined( _WIN32 ) #pragma once @@ -172,6 +175,10 @@ public: void InputExplode( inputdata_t &inputdata ); void InputScaleGroundSpeed( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetStompFilter( inputdata_t &inputdata ); +#endif + //--------------------------------- // Combat //--------------------------------- @@ -356,6 +363,10 @@ public: Vector BackFootHit( float eventtime ); void StompHit( int followerBoneIndex ); +#ifdef MAPBASE + CBaseFilter *GetStompFilter(); +#endif + void FootFX( const Vector &origin ); Vector CalculateStompHitPosition( CBaseEntity *pEnemy ); bool IsLegBoneFollower( CBoneFollower *pFollower ); @@ -452,6 +463,11 @@ private: EHANDLE m_hCannonTarget; CSimpleSimTimer m_AttemptCannonLOSTimer; +#ifdef MAPBASE + string_t m_strStompFilter; + CHandle m_hStompFilter; +#endif + float m_flSpeedScale; float m_flTargetSpeedScale; diff --git a/sp/src/game/server/hl2/npc_turret_ceiling.cpp b/sp/src/game/server/hl2/npc_turret_ceiling.cpp index ec8b4207..145db33a 100644 --- a/sp/src/game/server/hl2/npc_turret_ceiling.cpp +++ b/sp/src/game/server/hl2/npc_turret_ceiling.cpp @@ -26,7 +26,11 @@ //Debug visualization ConVar g_debug_turret_ceiling( "g_debug_turret_ceiling", "0" ); +#ifdef MAPBASE +#define CEILING_TURRET_MODEL GetTurretModel() +#else #define CEILING_TURRET_MODEL "models/combine_turrets/ceiling_turret.mdl" +#endif #define CEILING_TURRET_GLOW_SPRITE "sprites/glow1.vmt" /* // we now inherit these from the ai_basenpc baseclass #define CEILING_TURRET_BC_YAW "aim_yaw" @@ -49,6 +53,9 @@ ConVar g_debug_turret_ceiling( "g_debug_turret_ceiling", "0" ); #define SF_CEILING_TURRET_STARTINACTIVE 0x00000040 #define SF_CEILING_TURRET_NEVERRETIRE 0x00000080 #define SF_CEILING_TURRET_OUT_OF_AMMO 0x00000100 +#ifdef MAPBASE +#define SF_CEILING_TURRET_NO_SPRITE 0x00000400 +#endif //Heights #define CEILING_TURRET_RETRACT_HEIGHT 24 @@ -110,6 +117,14 @@ public: void InputToggle( inputdata_t &inputdata ); void InputEnable( inputdata_t &inputdata ); void InputDisable( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputDepleteAmmo( inputdata_t &inputdata ); + void InputRestoreAmmo( inputdata_t &inputdata ); + void InputCreateSprite( inputdata_t &inputdata ); + void InputDestroySprite( inputdata_t &inputdata ); + + virtual void StopLoopingSounds( void ) { StopSound(GetMoveSound()); } +#endif void SetLastSightTime(); @@ -147,8 +162,29 @@ public: } protected: + +#ifdef MAPBASE + virtual const char *GetTurretModel() { return "models/combine_turrets/ceiling_turret.mdl"; } + + virtual const char *GetRetireSound() { return "NPC_CeilingTurret.Retire"; } + virtual const char *GetDeploySound() { return "NPC_CeilingTurret.Deploy"; } + virtual const char *GetMoveSound() { return "NPC_CeilingTurret.Move"; } + virtual const char *GetActiveSound() { return "NPC_CeilingTurret.Active"; } + virtual const char *GetAlertSound() { return "NPC_CeilingTurret.Alert"; } + virtual const char *GetShootSound() { return "NPC_CeilingTurret.ShotSounds"; } + virtual const char *GetPingSound() { return "NPC_CeilingTurret.Ping"; } + virtual const char *GetDieSound() { return "NPC_CeilingTurret.Die"; } + + virtual float GetFireRate(bool bFightingPlayer = false) { return bFightingPlayer ? 0.5f : 0.1f; } +#endif +#ifdef MAPBASE + virtual bool PreThink( turretState_e state ); + void DryFire( void ); + const char *GetTracerType( void ) { return "AR2Tracer"; } +#else bool PreThink( turretState_e state ); +#endif void Shoot( const Vector &vecSrc, const Vector &vecDirToEnemy ); void SetEyeState( eyeState_t state ); void Ping( void ); @@ -157,8 +193,14 @@ protected: void Disable( void ); void SpinUp( void ); void SpinDown( void ); +#ifdef MAPBASE + virtual +#endif void SetHeight( float height ); +#ifdef MAPBASE + virtual +#endif bool UpdateFacing( void ); int m_iAmmoType; @@ -179,7 +221,9 @@ protected: COutputEvent m_OnDeploy; COutputEvent m_OnRetire; +#ifndef MAPBASE COutputEvent m_OnTipped; +#endif DECLARE_DATADESC(); }; @@ -198,6 +242,9 @@ BEGIN_DATADESC( CNPC_CeilingTurret ) DEFINE_FIELD( m_flPingTime, FIELD_TIME ), DEFINE_FIELD( m_vecGoalAngles, FIELD_VECTOR ), DEFINE_FIELD( m_pEyeGlow, FIELD_CLASSPTR ), +#ifdef MAPBASE + DEFINE_INPUT( m_flFieldOfView, FIELD_FLOAT, "FieldOfView" ), +#endif DEFINE_THINKFUNC( Retire ), DEFINE_THINKFUNC( Deploy ), @@ -210,10 +257,18 @@ BEGIN_DATADESC( CNPC_CeilingTurret ) DEFINE_INPUTFUNC( FIELD_VOID, "Toggle", InputToggle ), DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "DepleteAmmo", InputDepleteAmmo ), + DEFINE_INPUTFUNC( FIELD_VOID, "RestoreAmmo", InputRestoreAmmo ), + DEFINE_INPUTFUNC( FIELD_VOID, "CreateSprite", InputCreateSprite ), + DEFINE_INPUTFUNC( FIELD_VOID, "DestroySprite", InputDestroySprite ), +#endif DEFINE_OUTPUT( m_OnDeploy, "OnDeploy" ), DEFINE_OUTPUT( m_OnRetire, "OnRetire" ), +#ifndef MAPBASE DEFINE_OUTPUT( m_OnTipped, "OnTipped" ), +#endif END_DATADESC() @@ -258,6 +313,16 @@ void CNPC_CeilingTurret::Precache( void ) ADD_CUSTOM_ACTIVITY( CNPC_CeilingTurret, ACT_CEILING_TURRET_FIRE ); ADD_CUSTOM_ACTIVITY( CNPC_CeilingTurret, ACT_CEILING_TURRET_DRYFIRE ); +#ifdef MAPBASE + PrecacheScriptSound( GetRetireSound() ); + PrecacheScriptSound( GetDeploySound() ); + PrecacheScriptSound( GetMoveSound() ); + PrecacheScriptSound( GetActiveSound() ); + PrecacheScriptSound( GetAlertSound() ); + PrecacheScriptSound( GetShootSound() ); + PrecacheScriptSound( GetPingSound() ); + PrecacheScriptSound( GetDieSound() ); +#else PrecacheScriptSound( "NPC_CeilingTurret.Retire" ); PrecacheScriptSound( "NPC_CeilingTurret.Deploy" ); PrecacheScriptSound( "NPC_CeilingTurret.Move" ); @@ -266,6 +331,7 @@ void CNPC_CeilingTurret::Precache( void ) PrecacheScriptSound( "NPC_CeilingTurret.ShotSounds" ); PrecacheScriptSound( "NPC_CeilingTurret.Ping" ); PrecacheScriptSound( "NPC_CeilingTurret.Die" ); +#endif PrecacheScriptSound( "NPC_FloorTurret.DryFire" ); @@ -285,9 +351,16 @@ void CNPC_CeilingTurret::Spawn( void ) m_HackedGunPos = Vector( 0, 0, 12.75 ); SetViewOffset( EyeOffset( ACT_IDLE ) ); +#ifndef MAPBASE // We use this as a keyvalue now. m_flFieldOfView = 0.0f; +#endif m_takedamage = DAMAGE_YES; +#ifdef MAPBASE + if (m_iHealth == 0) + m_iHealth = 1000; +#else m_iHealth = 1000; +#endif m_bloodColor = BLOOD_COLOR_MECH; SetSolid( SOLID_BBOX ); @@ -304,9 +377,16 @@ void CNPC_CeilingTurret::Spawn( void ) m_iAmmoType = GetAmmoDef()->Index( "AR2" ); //Create our eye sprite +#ifdef MAPBASE + if (!HasSpawnFlags(SF_CEILING_TURRET_NO_SPRITE)) + { +#endif m_pEyeGlow = CSprite::SpriteCreate( CEILING_TURRET_GLOW_SPRITE, GetLocalOrigin(), false ); m_pEyeGlow->SetTransparency( kRenderTransAdd, 255, 0, 0, 128, kRenderFxNoDissipation ); m_pEyeGlow->SetAttachment( this, 2 ); +#ifdef MAPBASE + } +#endif //Set our autostart state m_bAutoStart = !!( m_spawnflags & SF_CEILING_TURRET_AUTOACTIVATE ); @@ -361,7 +441,11 @@ int CNPC_CeilingTurret::OnTakeDamage( const CTakeDamageInfo &inputInfo ) ExplosionCreate( GetAbsOrigin(), GetLocalAngles(), this, 100, 100, false ); SetThink( &CNPC_CeilingTurret::DeathThink ); +#ifdef MAPBASE + StopSound( GetAlertSound() ); +#else StopSound( "NPC_CeilingTurret.Alert" ); +#endif m_OnDamaged.FireOutput( info.GetInflictor(), this ); @@ -397,7 +481,11 @@ void CNPC_CeilingTurret::Retire( void ) if ( UpdateFacing() == false ) { SetActivity( (Activity) ACT_CEILING_TURRET_CLOSE ); +#ifdef MAPBASE + EmitSound( GetRetireSound() ); +#else EmitSound( "NPC_CeilingTurret.Retire" ); +#endif //Notify of the retraction m_OnRetire.FireOutput( NULL, this ); @@ -424,6 +512,10 @@ void CNPC_CeilingTurret::Retire( void ) SetEyeState( TURRET_EYE_DISABLED ); SetThink( &CNPC_CeilingTurret::SUB_DoNothing ); } + +#ifdef MAPBASE + StopLoopingSounds(); +#endif } } @@ -447,10 +539,18 @@ void CNPC_CeilingTurret::Deploy( void ) { m_bActive = true; SetActivity( (Activity) ACT_CEILING_TURRET_OPEN ); +#ifdef MAPBASE + EmitSound( GetDeploySound() ); +#else EmitSound( "NPC_CeilingTurret.Deploy" ); +#endif //Notify we're deploying +#ifdef MAPBASE + m_OnDeploy.FireOutput( GetEnemy(), this ); +#else m_OnDeploy.FireOutput( NULL, this ); +#endif } //If we're done, then start searching @@ -465,7 +565,11 @@ void CNPC_CeilingTurret::Deploy( void ) m_flPlaybackRate = 0; SetThink( &CNPC_CeilingTurret::SearchThink ); +#ifdef MAPBASE + EmitSound( GetMoveSound() ); +#else EmitSound( "NPC_CeilingTurret.Move" ); +#endif } SetLastSightTime(); @@ -525,6 +629,15 @@ bool CNPC_CeilingTurret::UpdateFacing( void ) NDebugOverlay::Cross3D( vecMuzzle, -Vector(2,2,2), Vector(2,2,2), 255, 0, 0, false, 0.05 ); NDebugOverlay::Cross3D( vecMuzzle+(vecGoalDir*256), -Vector(2,2,2), Vector(2,2,2), 255, 0, 0, false, 0.05 ); NDebugOverlay::Line( vecMuzzle, vecMuzzle+(vecGoalDir*256), 255, 0, 0, false, 0.05 ); + +#ifdef MAPBASE + NDebugOverlay::Cross3D( vecMuzzle, -Vector(2,2,2), Vector(2,2,2), 0, 255, 0, false, 0.05 ); + NDebugOverlay::Cross3D( vecMuzzle+(vecGoalLocalDir*256), -Vector(2,2,2), Vector(2,2,2), 0, 255, 0, false, 0.05 ); + NDebugOverlay::Line( vecMuzzle, vecMuzzle+(vecGoalLocalDir*256), 0, 255, 0, false, 0.05 ); + + DevMsg("Pitch: %f, Yaw: %f\n", GetPoseParameter( m_poseAim_Pitch ), GetPoseParameter( m_poseAim_Yaw )); + DevMsg("Goal Angles: [%f, %f, %f]\n", m_vecGoalAngles.x, m_vecGoalAngles.y, m_vecGoalAngles.z); +#endif } QAngle vecGoalLocalAngles; @@ -532,6 +645,10 @@ bool CNPC_CeilingTurret::UpdateFacing( void ) // Update pitch float flDiff = AngleNormalize( UTIL_ApproachAngle( vecGoalLocalAngles.x, 0.0, 0.1f * MaxYawSpeed() ) ); + +#ifdef MAPBASE + DevMsg("flDiff = %f\n", flDiff); +#endif SetPoseParameter( m_poseAim_Pitch, GetPoseParameter( m_poseAim_Pitch ) + ( flDiff / 1.5f ) ); @@ -540,6 +657,10 @@ bool CNPC_CeilingTurret::UpdateFacing( void ) bMoved = true; } +#ifdef MAPBASE + DevMsg("flDiff Yaw = %f\n\n", flDiff); +#endif + // Update yaw flDiff = AngleNormalize( UTIL_ApproachAngle( vecGoalLocalAngles.y, 0.0, 0.1f * MaxYawSpeed() ) ); @@ -569,7 +690,11 @@ bool CNPC_CeilingTurret::FVisible( CBaseEntity *pEntity, int traceMask, CBaseEnt // If we hit something that's okay to hit anyway, still fire if ( pHitEntity && pHitEntity->MyCombatCharacterPointer() ) { +#ifdef MAPBASE + if (IRelationType(pHitEntity) <= D_FR) +#else if (IRelationType(pHitEntity) == D_HT) +#endif return true; } @@ -671,6 +796,20 @@ void CNPC_CeilingTurret::ActiveThink( void ) //Fire the gun if ( DotProduct( vecDirToEnemy, vecMuzzleDir ) >= 0.9848 ) // 10 degree slop { +#ifdef MAPBASE + if ( m_spawnflags & SF_CEILING_TURRET_OUT_OF_AMMO ) + { + ResetActivity(); + SetActivity( (Activity) ACT_CEILING_TURRET_DRYFIRE ); + DryFire(); + } + else + { + ResetActivity(); + SetActivity( (Activity) ACT_CEILING_TURRET_FIRE ); + Shoot( vecMuzzle, vecMuzzleDir ); + } +#else if ( m_spawnflags & SF_CEILING_TURRET_OUT_OF_AMMO ) { SetActivity( (Activity) ACT_CEILING_TURRET_DRYFIRE ); @@ -682,6 +821,7 @@ void CNPC_CeilingTurret::ActiveThink( void ) //Fire the weapon Shoot( vecMuzzle, vecMuzzleDir ); +#endif } } else @@ -733,6 +873,9 @@ void CNPC_CeilingTurret::SearchThink( void ) //If we've found a target, spin up the barrel and start to attack if ( GetEnemy() != NULL ) { +#ifdef MAPBASE + m_flShotTime = gpGlobals->curtime + GetFireRate( GetEnemy()->IsPlayer() ); +#else //Give players a grace period if ( GetEnemy()->IsPlayer() ) { @@ -742,13 +885,18 @@ void CNPC_CeilingTurret::SearchThink( void ) { m_flShotTime = gpGlobals->curtime + 0.1f; } +#endif m_flLastSight = 0; SetThink( &CNPC_CeilingTurret::ActiveThink ); SetEyeState( TURRET_EYE_SEE_TARGET ); SpinUp(); +#ifdef MAPBASE + EmitSound( GetActiveSound() ); +#else EmitSound( "NPC_CeilingTurret.Active" ); +#endif return; } @@ -799,10 +947,76 @@ void CNPC_CeilingTurret::AutoSearchThink( void ) if ( GetEnemy() != NULL ) { SetThink( &CNPC_CeilingTurret::Deploy ); +#ifdef MAPBASE + EmitSound( GetAlertSound() ); +#else EmitSound( "NPC_CeilingTurret.Alert" ); +#endif } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// I decided to move dry firing to its own function instead of keeping it in Shoot, similar to npc_turret_floor +//----------------------------------------------------------------------------- +void CNPC_CeilingTurret::DryFire( void ) +{ + EmitSound( "NPC_FloorTurret.DryFire"); + EmitSound( GetActiveSound() ); + + if ( RandomFloat( 0, 1 ) > 0.7 ) + { + m_flShotTime = gpGlobals->curtime + random->RandomFloat( 0.5, 1.5 ); + } + else + { + m_flShotTime = gpGlobals->curtime; + } +} + +//----------------------------------------------------------------------------- +// Purpose: Fire! +//----------------------------------------------------------------------------- +void CNPC_CeilingTurret::Shoot( const Vector &vecSrc, const Vector &vecDirToEnemy ) +{ + FireBulletsInfo_t info; + + if ( GetEnemy() != NULL ) + { + Vector vecDir = GetActualShootTrajectory( vecSrc ); + + info.m_vecSrc = vecSrc; + info.m_vecDirShooting = vecDir; + info.m_iTracerFreq = 1; + info.m_iShots = 1; + info.m_pAttacker = this; + info.m_vecSpread = VECTOR_CONE_PRECALCULATED; + info.m_flDistance = MAX_COORD_RANGE; + info.m_iAmmoType = m_iAmmoType; + } + else + { + // Just shoot where you're facing! + + info.m_vecSrc = vecSrc; + info.m_vecDirShooting = vecDirToEnemy; + info.m_iTracerFreq = 1; + info.m_iShots = 1; + info.m_pAttacker = this; + info.m_vecSpread = GetAttackSpread( NULL, NULL ); + info.m_flDistance = MAX_COORD_RANGE; + info.m_iAmmoType = m_iAmmoType; + } + + FireBullets( info ); +#ifdef MAPBASE + EmitSound( GetShootSound() ); +#else + EmitSound( "NPC_CeilingTurret.ShotSounds" ); +#endif + DoMuzzleFlash(); +} +#else //----------------------------------------------------------------------------- // Purpose: Fire! //----------------------------------------------------------------------------- @@ -859,6 +1073,7 @@ void CNPC_CeilingTurret::Shoot( const Vector &vecSrc, const Vector &vecDirToEnem EmitSound( "NPC_CeilingTurret.ShotSounds" ); DoMuzzleFlash(); } +#endif //----------------------------------------------------------------------------- // Purpose: Allows a generic think function before the others are called @@ -946,7 +1161,11 @@ void CNPC_CeilingTurret::Ping( void ) return; //Ping! +#ifdef MAPBASE + EmitSound( GetPingSound() ); +#else EmitSound( "NPC_CeilingTurret.Ping" ); +#endif SetEyeState( TURRET_EYE_SEEKING_TARGET ); @@ -1023,6 +1242,52 @@ void CNPC_CeilingTurret::InputDisable( inputdata_t &inputdata ) Disable(); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Stops the turret from firing live rounds (still attempts to though) +//----------------------------------------------------------------------------- +void CNPC_CeilingTurret::InputDepleteAmmo( inputdata_t &inputdata ) +{ + AddSpawnFlags( SF_CEILING_TURRET_OUT_OF_AMMO ); +} + +//----------------------------------------------------------------------------- +// Purpose: Allows the turret to fire live rounds again +//----------------------------------------------------------------------------- +void CNPC_CeilingTurret::InputRestoreAmmo( inputdata_t &inputdata ) +{ + RemoveSpawnFlags( SF_CEILING_TURRET_OUT_OF_AMMO ); +} + +//----------------------------------------------------------------------------- +// Purpose: Creates the sprite if it has been destroyed +//----------------------------------------------------------------------------- +void CNPC_CeilingTurret::InputCreateSprite( inputdata_t &inputdata ) +{ + if (m_pEyeGlow) + return; + + m_pEyeGlow = CSprite::SpriteCreate( CEILING_TURRET_GLOW_SPRITE, GetLocalOrigin(), false ); + m_pEyeGlow->SetTransparency( kRenderTransAdd, 255, 0, 0, 128, kRenderFxNoDissipation ); + m_pEyeGlow->SetAttachment( this, 2 ); + + RemoveSpawnFlags(SF_CEILING_TURRET_NO_SPRITE); +} + +//----------------------------------------------------------------------------- +// Purpose: Destroys the sprite +//----------------------------------------------------------------------------- +void CNPC_CeilingTurret::InputDestroySprite( inputdata_t &inputdata ) +{ + if (!m_pEyeGlow) + return; + + UTIL_Remove(m_pEyeGlow); + m_pEyeGlow = NULL; + AddSpawnFlags(SF_CEILING_TURRET_NO_SPRITE); +} +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -1055,7 +1320,15 @@ void CNPC_CeilingTurret::DeathThink( void ) { m_lifeState = LIFE_DEAD; +#ifdef MAPBASE + StopLoopingSounds(); +#endif + +#ifdef MAPBASE + EmitSound( GetDieSound() ); +#else EmitSound( "NPC_CeilingTurret.Die" ); +#endif SetActivity( (Activity) ACT_CEILING_TURRET_CLOSE ); } @@ -1124,4 +1397,348 @@ bool CNPC_CeilingTurret::CanBeAnEnemyOf( CBaseEntity *pEnemy ) } return BaseClass::CanBeAnEnemyOf( pEnemy ); -} \ No newline at end of file +} + + + +#ifdef MAPBASE +// +// Eli's Lab Turret +// + +//#define LAB_TURRET_MANUAL_YAW 1 + +int ACT_CEILING_TURRET_MIRROR_CLOSED_IDLE; +int ACT_CEILING_TURRET_MIRROR_OPEN; +int ACT_CEILING_TURRET_MIRROR_CLOSE; + +class CNPC_LabTurret : public CNPC_CeilingTurret +{ + DECLARE_CLASS( CNPC_LabTurret, CNPC_CeilingTurret ); +public: + CNPC_LabTurret(); + + Class_T Classify( void ) + { + if( m_bEnabled ) + return CLASS_PLAYER_ALLY; + + return CLASS_NONE; + } + + const char *GetTracerType( void ) { return "Tracer"; } + bool PreThink( turretState_e state ); + + void Precache( void ); + void Spawn(); + Activity NPC_TranslateActivity( Activity activity ); + +#ifdef LAB_TURRET_MANUAL_YAW + void SetArmYaw( float flYaw ); + void ArmYawThink(); + + void InputSetArmYaw( inputdata_t &inputdata ); +#else + inline void SetArmYaw( float flYaw ) { SetPoseParameter( m_poseMove_Yaw, flYaw ); } +#endif + + void StopLoopingSounds( void ) { StopSound(GetMoveSound()); } + +protected: + + const char *GetTurretModel() { return "models/props_lab/labturret_npc.mdl"; } + + const char *GetRetireSound() { return "NPC_LabTurret.Retire"; } + const char *GetDeploySound() { return "NPC_LabTurret.Deploy"; } + const char *GetMoveSound() { return "NPC_LabTurret.Move"; } + const char *GetActiveSound() { return "NPC_LabTurret.Active"; } + const char *GetAlertSound() { return "NPC_LabTurret.Alert"; } + const char *GetShootSound() { return "NPC_LabTurret.ShotSounds"; } + const char *GetPingSound() { return "NPC_LabTurret.Ping"; } + const char *GetDieSound() { return "NPC_LabTurret.Die"; } + + float GetFireRate(bool bFightingPlayer = false) { return 1.0f; } + + void SetHeight( float height ); + + bool UpdateFacing( void ); + + bool m_bManualArmYaw; + +#ifdef LAB_TURRET_MANUAL_YAW + // The arm must reset each retire and be restored each deploy + float m_flStoredArmYaw; + float m_flGoalArmYaw; +#endif + + bool m_bMirrored; + + DECLARE_DATADESC(); +}; + +BEGIN_DATADESC( CNPC_LabTurret ) + + DEFINE_KEYFIELD( m_bManualArmYaw, FIELD_BOOLEAN, "ManualArmYaw" ), +#ifdef LAB_TURRET_MANUAL_YAW + DEFINE_KEYFIELD( m_flStoredArmYaw, FIELD_FLOAT, "ArmYaw" ), + DEFINE_FIELD( m_flGoalArmYaw, FIELD_FLOAT ), +#endif + DEFINE_KEYFIELD( m_bMirrored, FIELD_BOOLEAN, "Mirrored" ), + +#ifdef LAB_TURRET_MANUAL_YAW + DEFINE_THINKFUNC( ArmYawThink ), +#endif + + // Inputs +#ifdef LAB_TURRET_MANUAL_YAW + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetArmYaw", InputSetArmYaw ), +#endif + +END_DATADESC() + +LINK_ENTITY_TO_CLASS( npc_turret_lab, CNPC_LabTurret ); + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CNPC_LabTurret::CNPC_LabTurret() +{ + // Lab turrets can rotate much more, so they can see from more angles than regular turrets. + m_flFieldOfView = -0.5; +} + +//----------------------------------------------------------------------------- +// Purpose: Precache +//----------------------------------------------------------------------------- +void CNPC_LabTurret::Precache( void ) +{ + BaseClass::Precache(); + + // Activities + ADD_CUSTOM_ACTIVITY( CNPC_LabTurret, ACT_CEILING_TURRET_MIRROR_CLOSED_IDLE ); + ADD_CUSTOM_ACTIVITY( CNPC_LabTurret, ACT_CEILING_TURRET_MIRROR_OPEN ); + ADD_CUSTOM_ACTIVITY( CNPC_LabTurret, ACT_CEILING_TURRET_MIRROR_CLOSE ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CNPC_LabTurret::Spawn( void ) +{ + BaseClass::Spawn(); + + if (m_bMirrored) + SetActivity((Activity)ACT_CEILING_TURRET_MIRROR_CLOSED_IDLE); + + SetPoseParameter( m_poseMove_Yaw, 0 ); +} + +//----------------------------------------------------------------------------- +// Purpose: Override base class activiites +//----------------------------------------------------------------------------- +Activity CNPC_LabTurret::NPC_TranslateActivity( Activity activity ) +{ + if (m_bMirrored) + { + if (activity == ACT_CEILING_TURRET_CLOSED_IDLE) + return (Activity)ACT_CEILING_TURRET_MIRROR_CLOSED_IDLE; + if (activity == ACT_CEILING_TURRET_OPEN) + return (Activity)ACT_CEILING_TURRET_MIRROR_OPEN; + if (activity == ACT_CEILING_TURRET_CLOSE) + return (Activity)ACT_CEILING_TURRET_MIRROR_CLOSE; + } + + return BaseClass::NPC_TranslateActivity(activity); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CNPC_LabTurret::PreThink( turretState_e state ) +{ + if (state == TURRET_RETIRING || state == TURRET_DEAD) + { +#ifdef LAB_TURRET_MANUAL_YAW + if (m_bManualArmYaw) + m_flStoredArmYaw = GetPoseParameter(m_poseMove_Yaw); +#endif + + SetArmYaw( 0 ); + } +#ifdef LAB_TURRET_MANUAL_YAW + else if (state == TURRET_DEPLOYING) + { + if (m_bManualArmYaw) + SetArmYaw( m_flStoredArmYaw ); + } +#endif + + return BaseClass::PreThink(state); +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : height - +//----------------------------------------------------------------------------- +void CNPC_LabTurret::SetHeight( float height ) +{ + Vector forward, right, up; + AngleVectors( GetLocalAngles(), &forward, &right, &up ); + + height /= 2; + + Vector mins = ( forward * -8.0f ) + ( right * -height ) + ( up * -8.0f ); + Vector maxs = ( forward * height ) + ( right * height ) + ( up * CEILING_TURRET_RETRACT_HEIGHT ); + + if ( mins.x > maxs.x ) + { + V_swap( mins.x, maxs.x ); + } + + if ( mins.y > maxs.y ) + { + V_swap( mins.y, maxs.y ); + } + + if ( mins.z > maxs.z ) + { + V_swap( mins.z, maxs.z ); + } + + SetCollisionBounds( mins, maxs ); +} + +//----------------------------------------------------------------------------- +// Purpose: Causes the turret to face its desired angles +//----------------------------------------------------------------------------- +bool CNPC_LabTurret::UpdateFacing( void ) +{ + bool bMoved = false; + + matrix3x4_t localToWorld; + + GetAttachment( LookupAttachment( "eyes" ), localToWorld ); + + Vector vecGoalDir; + AngleVectors( m_vecGoalAngles, &vecGoalDir ); + + Vector vecGoalLocalDir; + VectorIRotate( vecGoalDir, localToWorld, vecGoalLocalDir ); + + if ( g_debug_turret_ceiling.GetBool() ) + { + Vector vecMuzzle, vecMuzzleDir; + QAngle vecMuzzleAng; + + GetAttachment( "eyes", vecMuzzle, vecMuzzleAng ); + AngleVectors( vecMuzzleAng, &vecMuzzleDir ); + + NDebugOverlay::Cross3D( vecMuzzle, -Vector(2,2,2), Vector(2,2,2), 255, 255, 0, false, 0.05 ); + NDebugOverlay::Cross3D( vecMuzzle+(vecMuzzleDir*256), -Vector(2,2,2), Vector(2,2,2), 255, 255, 0, false, 0.05 ); + NDebugOverlay::Line( vecMuzzle, vecMuzzle+(vecMuzzleDir*256), 255, 255, 0, false, 0.05 ); + + NDebugOverlay::Cross3D( vecMuzzle, -Vector(2,2,2), Vector(2,2,2), 255, 0, 0, false, 0.05 ); + NDebugOverlay::Cross3D( vecMuzzle+(vecGoalDir*256), -Vector(2,2,2), Vector(2,2,2), 255, 0, 0, false, 0.05 ); + NDebugOverlay::Line( vecMuzzle, vecMuzzle+(vecGoalDir*256), 255, 0, 0, false, 0.05 ); + } + + QAngle vecGoalLocalAngles; + VectorAngles( vecGoalLocalDir, vecGoalLocalAngles ); + +#ifdef LAB_TURRET_MANUAL_YAW + if ( !m_bManualArmYaw && m_flGoalArmYaw == 0.0f ) +#else + if ( !m_bManualArmYaw ) +#endif + { + // Update yaw + float flDiff = AngleNormalize( UTIL_ApproachAngle( vecGoalLocalAngles.y, 0.0, 0.1f * MaxYawSpeed() ) ); + +#ifdef MAPBASE + DevMsg("Arm Yaw = %f, Diff: %f\n", GetPoseParameter( m_poseMove_Yaw ), flDiff); +#endif + + SetPoseParameter( m_poseMove_Yaw, GetPoseParameter( m_poseMove_Yaw ) + ( flDiff / 1.5f ) * 0.5f ); + + // Recalculate muzzle + GetAttachment( LookupAttachment( "eyes" ), localToWorld ); + VectorIRotate( vecGoalDir, localToWorld, vecGoalLocalDir ); + VectorAngles( vecGoalLocalDir, vecGoalLocalAngles ); + + if ( fabs( flDiff ) > 0.1f ) + { + bMoved = true; + } + } + + // Update pitch + // Pitch is faster than the others, but it also kind of jiggles when targetting. + float flDiff = AngleNormalize( UTIL_ApproachAngle( vecGoalLocalAngles.x, 0.0, 0.15f * MaxYawSpeed() ) ); + + SetPoseParameter( m_poseAim_Pitch, GetPoseParameter( m_poseAim_Pitch ) + ( flDiff * 2.0f ) ); + + if ( fabs( flDiff ) > 0.1f ) + { + bMoved = true; + } + + // Update yaw + flDiff = AngleNormalize( UTIL_ApproachAngle( vecGoalLocalAngles.y, 0.0, 0.1f * MaxYawSpeed() ) ); + + SetPoseParameter( m_poseAim_Yaw, GetPoseParameter( m_poseAim_Yaw ) + ( flDiff / 1.5f ) ); + + if ( fabs( flDiff ) > 0.1f ) + { + bMoved = true; + } + + InvalidateBoneCache(); + + return bMoved; +} + +#ifdef LAB_TURRET_MANUAL_YAW +//----------------------------------------------------------------------------- +// Purpose: Change move yaw +//----------------------------------------------------------------------------- +void CNPC_LabTurret::SetArmYaw( float flYaw ) +{ + m_flGoalArmYaw = flYaw; + + SetContextThink(&CNPC_LabTurret::ArmYawThink, gpGlobals->curtime, "SetArmYaw"); +} + +//----------------------------------------------------------------------------- +// Purpose: Change move yaw +//----------------------------------------------------------------------------- +void CNPC_LabTurret::ArmYawThink() +{ + //GetBoneTransform( LookupBone( "eyes" ), localToWorld ); + + // Update yaw + float flDiff = AngleNormalize( UTIL_ApproachAngle( m_flGoalArmYaw, GetPoseParameter( m_poseMove_Yaw ), 0.05f * MaxYawSpeed() ) ); + + SetPoseParameter( m_poseMove_Yaw, GetPoseParameter( m_poseAim_Pitch ) + ( flDiff / 1.5f ) ); + + InvalidateBoneCache(); + + if ( fabs( flDiff ) > 0.1f ) + { + SetNextThink(gpGlobals->curtime, "SetArmYaw"); + } + else + { + m_flGoalArmYaw = 0.0f; + SetContextThink(NULL, gpGlobals->curtime, "SetArmYaw"); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Change move yaw +//----------------------------------------------------------------------------- +void CNPC_LabTurret::InputSetArmYaw( inputdata_t &inputdata ) +{ + SetArmYaw( inputdata.value.Float() ); +} +#endif +#endif diff --git a/sp/src/game/server/hl2/npc_turret_floor.cpp b/sp/src/game/server/hl2/npc_turret_floor.cpp index d934e72d..8698e742 100644 --- a/sp/src/game/server/hl2/npc_turret_floor.cpp +++ b/sp/src/game/server/hl2/npc_turret_floor.cpp @@ -40,6 +40,15 @@ ConVar g_debug_turret( "g_debug_turret", "0" ); extern ConVar physcannon_tracelength; +#if defined(MAPBASE) && defined(HL2_EPISODIC) +extern ConVar npc_alyx_interact_turrets; +#endif + +#ifdef MAPBASE +// m_iKeySkin has been replaced with the original m_nSkin so we can make it show up in Hammer, etc. +#define m_iKeySkin m_nSkin +#endif + // Interactions int g_interactionTurretStillStanding = 0; @@ -132,6 +141,10 @@ BEGIN_DATADESC( CNPC_FloorTurret ) DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), DEFINE_INPUTFUNC( FIELD_VOID, "DepleteAmmo", InputDepleteAmmo ), DEFINE_INPUTFUNC( FIELD_VOID, "RestoreAmmo", InputRestoreAmmo ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "CreateSprite", InputCreateSprite ), + DEFINE_INPUTFUNC( FIELD_VOID, "DestroySprite", InputDestroySprite ), +#endif DEFINE_INPUTFUNC( FIELD_VOID, "SelfDestruct", InputSelfDestruct ), DEFINE_OUTPUT( m_OnDeploy, "OnDeploy" ), @@ -288,10 +301,12 @@ void CNPC_FloorTurret::Spawn( void ) // add one mod 4 nextSkin = (nextSkin + 1) & 0x03; } +#ifndef MAPBASE else { // at least make sure that it's in the right range m_nSkin = clamp(m_iKeySkin,1,4); } +#endif } BaseClass::Spawn(); @@ -1545,7 +1560,11 @@ bool CNPC_FloorTurret::PreThink( turretState_e state ) void CNPC_FloorTurret::SetEyeState( eyeState_t state ) { // Must have a valid eye to affect +#ifdef MAPBASE + if ( !m_hEyeGlow && !HasSpawnFlags(SF_FLOOR_TURRET_NO_SPRITE) ) +#else if ( !m_hEyeGlow ) +#endif { // Create our eye sprite m_hEyeGlow = CSprite::SpriteCreate( FLOOR_TURRET_GLOW_SPRITE, GetLocalOrigin(), false ); @@ -1775,6 +1794,39 @@ void CNPC_FloorTurret::InputRestoreAmmo( inputdata_t &inputdata ) RemoveSpawnFlags( SF_FLOOR_TURRET_OUT_OF_AMMO ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Creates the sprite if it has been destroyed +//----------------------------------------------------------------------------- +void CNPC_FloorTurret::InputCreateSprite( inputdata_t &inputdata ) +{ + if (m_hEyeGlow) + return; + + m_hEyeGlow = CSprite::SpriteCreate( FLOOR_TURRET_GLOW_SPRITE, GetLocalOrigin(), false ); + if ( !m_hEyeGlow ) + return; + + m_hEyeGlow->SetTransparency( kRenderWorldGlow, 255, 0, 0, 128, kRenderFxNoDissipation ); + m_hEyeGlow->SetAttachment( this, m_iEyeAttachment ); + + RemoveSpawnFlags(SF_FLOOR_TURRET_NO_SPRITE); +} + +//----------------------------------------------------------------------------- +// Purpose: Destroys the sprite +//----------------------------------------------------------------------------- +void CNPC_FloorTurret::InputDestroySprite( inputdata_t &inputdata ) +{ + if (!m_hEyeGlow) + return; + + UTIL_Remove(m_hEyeGlow); + m_hEyeGlow = NULL; + AddSpawnFlags(SF_FLOOR_TURRET_NO_SPRITE); +} +#endif + //----------------------------------------------------------------------------- // Purpose: Allow players and npc's to turn the turret on and off //----------------------------------------------------------------------------- @@ -1994,6 +2046,20 @@ int CNPC_FloorTurret::DrawDebugTextOverlays( void ) return text_offset; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Option to restore Alyx's interactions with non-rollermines +//----------------------------------------------------------------------------- +bool CNPC_FloorTurret::CanInteractWith( CAI_BaseNPC *pUser ) +{ +#ifdef HL2_EPISODIC + return npc_alyx_interact_turrets.GetBool(); +#else + return false; +#endif +} +#endif + void CNPC_FloorTurret::UpdateMuzzleMatrix() { if ( gpGlobals->tickcount != m_muzzleToWorldTick ) diff --git a/sp/src/game/server/hl2/npc_turret_floor.h b/sp/src/game/server/hl2/npc_turret_floor.h index 53c54b0c..8600e13a 100644 --- a/sp/src/game/server/hl2/npc_turret_floor.h +++ b/sp/src/game/server/hl2/npc_turret_floor.h @@ -43,6 +43,9 @@ enum eyeState_t #define SF_FLOOR_TURRET_FASTRETIRE 0x00000080 #define SF_FLOOR_TURRET_OUT_OF_AMMO 0x00000100 #define SF_FLOOR_TURRET_CITIZEN 0x00000200 // Citizen modified turret +#ifdef MAPBASE +#define SF_FLOOR_TURRET_NO_SPRITE 0x00000400 +#endif class CTurretTipController; class CBeam; @@ -131,6 +134,11 @@ public: void InputDepleteAmmo( inputdata_t &inputdata ); void InputRestoreAmmo( inputdata_t &inputdata ); void InputSelfDestruct( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputCreateSprite( inputdata_t &inputdata ); + void InputDestroySprite( inputdata_t &inputdata ); + void InputPowerdown( inputdata_t &inputdata ) { InputSelfDestruct(inputdata); } +#endif virtual bool IsValidEnemy( CBaseEntity *pEnemy ); bool CanBeAnEnemyOf( CBaseEntity *pEnemy ); @@ -168,13 +176,20 @@ public: int DrawDebugTextOverlays( void ); // INPCInteractive Functions +#ifdef MAPBASE + virtual bool CanInteractWith( CAI_BaseNPC *pUser ); +#else virtual bool CanInteractWith( CAI_BaseNPC *pUser ) { return false; } // Disabled for now (sjb) +#endif virtual bool HasBeenInteractedWith() { return m_bHackedByAlyx; } virtual void NotifyInteraction( CAI_BaseNPC *pUser ) { // For now, turn green so we can tell who is hacked. SetRenderColor( 0, 255, 0 ); m_bHackedByAlyx = true; +#ifdef MAPBASE + m_OnHacked.FireOutput(pUser, this); +#endif } static float fMaxTipControllerVelocity; @@ -220,7 +235,9 @@ protected: bool m_bCarriedByPlayer; bool m_bUseCarryAngles; float m_flPlayerDropTime; +#ifndef MAPBASE // Replaced with m_nSkin. int m_iKeySkin; +#endif CHandle m_hLastNPCToKickMe; // Stores the last NPC who tried to knock me over float m_flKnockOverFailedTime; // Time at which we should tell the NPC that he failed to knock me over diff --git a/sp/src/game/server/hl2/npc_turret_ground.cpp b/sp/src/game/server/hl2/npc_turret_ground.cpp index bacaac0a..de35097b 100644 --- a/sp/src/game/server/hl2/npc_turret_ground.cpp +++ b/sp/src/game/server/hl2/npc_turret_ground.cpp @@ -130,7 +130,9 @@ void CNPC_GroundTurret::Spawn( void ) if( !GetParent() ) { DevMsg("ERROR! npc_ground_turret with no parent!\n"); +#ifndef MAPBASE UTIL_Remove(this); +#endif return; } diff --git a/sp/src/game/server/hl2/npc_vortigaunt_episodic.cpp b/sp/src/game/server/hl2/npc_vortigaunt_episodic.cpp index 3337a65b..8dffd6db 100644 --- a/sp/src/game/server/hl2/npc_vortigaunt_episodic.cpp +++ b/sp/src/game/server/hl2/npc_vortigaunt_episodic.cpp @@ -581,6 +581,28 @@ bool CNPC_Vortigaunt::InnateWeaponLOSCondition( const Vector &ownerPos, const Ve UTIL_PredictedPosition( this, flTimeDelta, &vecNewOwnerPos ); UTIL_PredictedPosition( GetEnemy(), flTimeDelta, &vecNewTargetPos ); +#ifdef MAPBASE + // This fix was created by DKY. + // His original comment is below. + + /* + + Fix for LOS test failures when the Vort is attempting to find a viable + shoot position-- Valve's "predict where we'll be in a moment" hack (as + described above) completely breaks SCHED_ESTABLISH_LINE_OF_FIRE because it + causes all LOS checks to fail for every node if the Vort's current position + is not a valid shooting position. + - Thank you, dky.tehkingd.u! + + */ + + // Determine the Vort's predicted position delta + Vector ownerDelta = vecNewOwnerPos - GetAbsOrigin(); + + // Offset our requested LOS check location by the predicted delta. + vecNewOwnerPos = ownerPos + ownerDelta; +#endif + Vector vecDelta = vecNewTargetPos - GetEnemy()->GetAbsOrigin(); Vector vecFinalTargetPos = GetEnemy()->BodyTarget( vecNewOwnerPos ) + vecDelta; @@ -2776,7 +2798,12 @@ bool CNPC_Vortigaunt::CanFlinch( void ) if ( IsCurSchedule( SCHED_VORTIGAUNT_DISPEL_ANTLIONS ) || IsCurSchedule( SCHED_RANGE_ATTACK1 ) ) return false; +#ifdef MAPBASE + // This skips CAI_PlayerAlly's CanFlinch() function since Episodic vorts can flinch to begin with. + return CAI_BaseActor::CanFlinch(); +#else return BaseClass::CanFlinch(); +#endif } //----------------------------------------------------------------------------- diff --git a/sp/src/game/server/hl2/npc_zombie.cpp b/sp/src/game/server/hl2/npc_zombie.cpp index 6762c45c..d40c8cc6 100644 --- a/sp/src/game/server/hl2/npc_zombie.cpp +++ b/sp/src/game/server/hl2/npc_zombie.cpp @@ -17,6 +17,9 @@ #include "soundenvelope.h" #include "engine/IEngineSound.h" #include "ammodef.h" +#ifdef MAPBASE +#include "AI_ResponseSystem.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -75,6 +78,18 @@ envelopePoint_t envZombieMoanIgnited[] = }, }; +#ifdef MAPBASE +//------------------------------------------------------------------------------ +// Move these to CNPC_BaseZombie if other zombies end up using the response system +//------------------------------------------------------------------------------ +#define TLK_ZOMBIE_PAIN "TLK_WOUND" +#define TLK_ZOMBIE_DEATH "TLK_DEATH" +#define TLK_ZOMBIE_ALERT "TLK_STARTCOMBAT" +#define TLK_ZOMBIE_IDLE "TLK_QUESTION" +#define TLK_ZOMBIE_ATTACK "TLK_MELEE" +#define TLK_ZOMBIE_MOAN "TLK_MOAN" +#endif + //============================================================================= //============================================================================= @@ -263,6 +278,17 @@ void CZombie::Spawn( void ) { Precache(); +#ifdef MAPBASE + if( Q_strstr( GetClassname(), "torso" ) ) + { + // This was placed as an npc_zombie_torso + m_fIsTorso = true; + } + else + { + m_fIsTorso = false; + } +#else if( FClassnameIs( this, "npc_zombie" ) ) { m_fIsTorso = false; @@ -274,6 +300,7 @@ void CZombie::Spawn( void ) } m_fIsHeadless = false; +#endif #ifdef HL2_EPISODIC SetBloodColor( BLOOD_COLOR_ZOMBIE ); @@ -999,3 +1026,284 @@ AI_BEGIN_CUSTOM_NPC( npc_zombie, CZombie ) AI_END_CUSTOM_NPC() //============================================================================= + +#ifdef MAPBASE +class CZombieCustom : public CZombie +{ + DECLARE_DATADESC(); + DECLARE_CLASS( CZombieCustom, CZombie ); + +public: + CZombieCustom(); + + void Spawn( void ); + void Precache( void ); + +#ifdef EXPANDED_RESPONSE_SYSTEM_USAGE + DeclareResponseSystem() + void SpeakIfAllowed(const char *concept); + void ModifyOrAppendCriteria( AI_CriteriaSet& set ); + + void PainSound( const CTakeDamageInfo &info ); + void DeathSound( const CTakeDamageInfo &info ); + void AlertSound( void ); + void IdleSound( void ); + void AttackSound( void ); + + const char *GetMoanSound( int nSound ); +#endif + + void SetZombieModel( void ); + + virtual const char *GetLegsModel( void ) { return STRING(m_iszLegsModel); } + virtual const char *GetTorsoModel( void ) { return STRING(m_iszTorsoModel); } + virtual const char *GetHeadcrabClassname( void ) { return STRING(m_iszHeadcrabClassname); } + virtual const char *GetHeadcrabModel( void ) { return STRING(m_iszHeadcrabModel); } + + string_t m_iszLegsModel; + string_t m_iszTorsoModel; + string_t m_iszHeadcrabClassname; + string_t m_iszHeadcrabModel; +}; + +BEGIN_DATADESC( CZombieCustom ) + + DEFINE_KEYFIELD( m_iszLegsModel, FIELD_STRING, "LegsModel" ), + DEFINE_KEYFIELD( m_iszTorsoModel, FIELD_STRING, "TorsoModel" ), + DEFINE_KEYFIELD( m_iszHeadcrabClassname, FIELD_STRING, "HeadcrabClassname" ), + DEFINE_KEYFIELD( m_iszHeadcrabModel, FIELD_STRING, "HeadcrabModel" ), + +END_DATADESC() + +LINK_ENTITY_TO_CLASS( npc_zombie_custom, CZombieCustom ); +LINK_ENTITY_TO_CLASS( npc_zombie_custom_torso, CZombieCustom ); + + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CZombieCustom::CZombieCustom() +{ + m_iszLegsModel = AllocPooledString( CZombie::GetLegsModel() ); + m_iszTorsoModel = AllocPooledString( CZombie::GetTorsoModel() ); + m_iszHeadcrabClassname = AllocPooledString( CZombie::GetHeadcrabClassname() ); + m_iszHeadcrabModel = AllocPooledString( CZombie::GetHeadcrabModel() ); + + SetModelName( AllocPooledString("models/zombie/classic.mdl") ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CZombieCustom::Spawn( void ) +{ + int iHealth = m_iHealth; + + BaseClass::Spawn(); + + if (iHealth > 0) + { + m_iMaxHealth = iHealth; + m_iHealth = iHealth; + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CZombieCustom::Precache( void ) +{ + BaseClass::Precache(); + + PrecacheModel(STRING(GetModelName())); + + if (m_iszLegsModel != NULL_STRING) + PrecacheModel( STRING(m_iszLegsModel) ); + + if (m_iszTorsoModel != NULL_STRING) + PrecacheModel( STRING(m_iszTorsoModel) ); + + if (m_iszHeadcrabClassname != NULL_STRING) + UTIL_PrecacheOther( STRING(m_iszHeadcrabClassname) ); + + if (m_iszHeadcrabModel != NULL_STRING) + PrecacheModel( STRING(m_iszHeadcrabModel) ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CZombieCustom::SetZombieModel( void ) +{ + Hull_t lastHull = GetHullType(); + + if ( m_fIsTorso ) + { + SetModel( GetTorsoModel() ); + SetHullType( HULL_TINY ); + } + else + { + SetModel( STRING(GetModelName()) ); + SetHullType( HULL_HUMAN ); + } + + SetBodygroup( ZOMBIE_BODYGROUP_HEADCRAB, !m_fIsHeadless ); + + SetHullSizeNormal( true ); + SetDefaultEyeOffset(); + SetActivity( ACT_IDLE ); + + // hull changed size, notify vphysics + // UNDONE: Solve this generally, systematically so other + // NPCs can change size + if ( lastHull != GetHullType() ) + { + if ( VPhysicsGetObject() ) + { + SetupVPhysicsHull(); + } + } +} + +#ifdef EXPANDED_RESPONSE_SYSTEM_USAGE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CZombieCustom::PainSound( const CTakeDamageInfo &info ) +{ + SpeakIfAllowed( TLK_ZOMBIE_PAIN ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CZombieCustom::DeathSound( const CTakeDamageInfo &info ) +{ + SpeakIfAllowed( TLK_ZOMBIE_DEATH ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CZombieCustom::AlertSound( void ) +{ + SpeakIfAllowed( TLK_ZOMBIE_ALERT ); + + // Don't let a moan sound cut off the alert sound. + m_flNextMoanSound += random->RandomFloat( 2.0, 4.0 ); +} + +//----------------------------------------------------------------------------- +// Purpose: Returns a moan sound for this class of zombie. +//----------------------------------------------------------------------------- +const char *CZombieCustom::GetMoanSound( int nSound ) +{ + // This whole thing is really complicated and largely a copy-paste of CBaseEntity::DispatchResponse(). + + AddContext( "moansound", UTIL_VarArgs("%i", nSound & 4), 5.0f ); + + IResponseSystem *rs = GetResponseSystem(); + if ( !rs ) + return "NPC_BaseZombie.Moan1"; + + AI_CriteriaSet set; + set.AppendCriteria( "concept", TLK_ZOMBIE_MOAN, CONCEPT_WEIGHT ); + ModifyOrAppendCriteria( set ); + CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); + if( pPlayer ) + pPlayer->ModifyOrAppendPlayerCriteria( set ); + ReAppendContextCriteria( set ); + + AI_Response result; + rs->FindBestResponse(set, result); + + // Get the response and turn it into something we can use + char response[256]; + result.GetResponse(response, sizeof(response)); + switch (result.GetType()) + { + case RESPONSE_SENTENCE: + { + if (response[0] != '!') + { + SENTENCEG_PlayRndSz( edict(), response, 1, result.GetSoundLevel(), 0, PITCH_NORM ); + break; + } + int sentenceIndex = SENTENCEG_Lookup( response ); + if( sentenceIndex == -1 ) + { + // sentence not found + break; + } + + // Not sure how else to get around this + CPASAttenuationFilter filter( this ); + CBaseEntity::EmitSentenceByIndex( filter, entindex(), CHAN_VOICE, sentenceIndex, 1, result.GetSoundLevel(), 0, PITCH_NORM ); + return "AI_BaseNPC.SentenceStop"; + } + break; + case RESPONSE_SCENE: + { + extern const char *GetFirstSoundInScene(const char *pszScene); + + // Expand gender string + GenderExpandString( response, response, sizeof( response ) ); + + // Trust that it's been precached + Q_strncpy(response, GetFirstSoundInScene(response), sizeof(response)); + } + break; + } + + const char *szSound = response; + return szSound; +} + +//----------------------------------------------------------------------------- +// Purpose: Play a random idle sound. +//----------------------------------------------------------------------------- +void CZombieCustom::IdleSound( void ) +{ + if( GetState() == NPC_STATE_IDLE && random->RandomFloat( 0, 1 ) == 0 ) + { + // Moan infrequently in IDLE state. + return; + } + + SpeakIfAllowed( TLK_ZOMBIE_IDLE ); + MakeAISpookySound( 360.0f ); +} + +//----------------------------------------------------------------------------- +// Purpose: Play a random attack sound. +//----------------------------------------------------------------------------- +void CZombieCustom::AttackSound( void ) +{ + SpeakIfAllowed( TLK_ZOMBIE_ATTACK ); +} + +//----------------------------------------------------------------------------- +// Purpose: Speak concept +//----------------------------------------------------------------------------- +void CZombieCustom::SpeakIfAllowed(const char *concept) +{ + DispatchResponse(concept); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CZombieCustom::ModifyOrAppendCriteria( AI_CriteriaSet& set ) +{ + BaseClass::ModifyOrAppendCriteria( set ); + + set.AppendCriteria( "slumped", IsSlumped() ? "1" : "0" ); + + // Does this or a name already exist? + set.AppendCriteria( "onfire", IsOnFire() ? "1" : "0" ); + + // Custom zombies (and zombie torsos) must make zombie sounds. + // This can be overridden with response contexts. + set.AppendCriteria( "classname", "npc_zombie" ); +} +#endif +#endif diff --git a/sp/src/game/server/hl2/npc_zombine.cpp b/sp/src/game/server/hl2/npc_zombine.cpp index 479d220b..c25104d2 100644 --- a/sp/src/game/server/hl2/npc_zombine.cpp +++ b/sp/src/game/server/hl2/npc_zombine.cpp @@ -167,8 +167,15 @@ private: float m_flSuperFastAttackTime; float m_flGrenadePullTime; +#ifdef MAPBASE + int m_iGrenadeCount = ZOMBINE_MAX_GRENADES; +#else int m_iGrenadeCount; +#endif +#ifdef MAPBASE + COutputEHANDLE m_OnGrenade; +#endif EHANDLE m_hGrenade; protected: @@ -184,7 +191,12 @@ BEGIN_DATADESC( CNPC_Zombine ) DEFINE_FIELD( m_flSuperFastAttackTime, FIELD_TIME ), DEFINE_FIELD( m_hGrenade, FIELD_EHANDLE ), DEFINE_FIELD( m_flGrenadePullTime, FIELD_TIME ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_iGrenadeCount, FIELD_INTEGER, "NumGrenades" ), + DEFINE_OUTPUT( m_OnGrenade, "OnPullGrenade" ), +#else DEFINE_FIELD( m_iGrenadeCount, FIELD_INTEGER ), +#endif DEFINE_INPUTFUNC( FIELD_VOID, "StartSprint", InputStartSprint ), DEFINE_INPUTFUNC( FIELD_VOID, "PullGrenade", InputPullGrenade ), END_DATADESC() @@ -201,7 +213,9 @@ void CNPC_Zombine::Spawn( void ) Precache(); m_fIsTorso = false; +#ifndef MAPBASE // Controlled by KV m_fIsHeadless = false; +#endif #ifdef HL2_EPISODIC SetBloodColor( BLOOD_COLOR_ZOMBIE ); @@ -226,7 +240,9 @@ void CNPC_Zombine::Spawn( void ) g_flZombineGrenadeTimes = gpGlobals->curtime; m_flGrenadePullTime = gpGlobals->curtime; +#ifndef MAPBASE m_iGrenadeCount = ZOMBINE_MAX_GRENADES; +#endif } void CNPC_Zombine::Precache( void ) @@ -560,6 +576,9 @@ void CNPC_Zombine::HandleAnimEvent( animevent_t *pEvent ) pGrenade->SetParent( this, iAttachment ); pGrenade->SetDamage( 200.0f ); +#ifdef MAPBASE + m_OnGrenade.Set(pGrenade, pGrenade, this); +#endif m_hGrenade = pGrenade; EmitSound( "Zombine.ReadyGrenade" ); diff --git a/sp/src/game/server/hl2/prop_combine_ball.cpp b/sp/src/game/server/hl2/prop_combine_ball.cpp index b9370349..e94d2bc4 100644 --- a/sp/src/game/server/hl2/prop_combine_ball.cpp +++ b/sp/src/game/server/hl2/prop_combine_ball.cpp @@ -227,6 +227,10 @@ BEGIN_DATADESC( CPropCombineBall ) DEFINE_INPUTFUNC( FIELD_VOID, "FadeAndRespawn", InputFadeAndRespawn ), DEFINE_INPUTFUNC( FIELD_VOID, "Kill", InputKill ), DEFINE_INPUTFUNC( FIELD_VOID, "Socketed", InputSocketed ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetLifetime", InputSetLifetime ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "AddLifetime", InputAddLifetime ), +#endif END_DATADESC() @@ -566,6 +570,10 @@ void CPropCombineBall::InputKill( inputdata_t &inputdata ) SetOwnerEntity( NULL ); } +#ifdef MAPBASE + m_OnKilled.FireOutput( inputdata.pActivator, this ); +#endif + UTIL_Remove( this ); NotifySpawnerOfRemoval(); @@ -596,6 +604,86 @@ void CPropCombineBall::InputSocketed( inputdata_t &inputdata ) NotifySpawnerOfRemoval(); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPropCombineBall::InputSetLifetime( inputdata_t &inputdata ) +{ + if (m_bHeld) + { + // Special handling when held + float dt = inputdata.value.Float(); + float flSoundRampTime = GetBallHoldDissolveTime() - GetBallHoldSoundRampTime(); + + if (dt > flSoundRampTime) + { + if ( m_pHoldingSound ) + { + // Reset holding sound to regular pitch + CSoundEnvelopeController &controller = CSoundEnvelopeController::GetController(); + controller.SoundChangePitch( m_pHoldingSound, 100, flSoundRampTime ); + } + + SetContextThink( &CPropCombineBall::DissolveRampSoundThink, gpGlobals->curtime + dt - flSoundRampTime, s_pHoldDissolveContext ); + } + else + { + if ( m_pHoldingSound ) + { + // Do pitch ramp based on our custom time, which is less than the normal pitch ramp time + CSoundEnvelopeController &controller = CSoundEnvelopeController::GetController(); + controller.SoundChangePitch( m_pHoldingSound, 150, dt ); + } + SetContextThink( &CPropCombineBall::DissolveThink, gpGlobals->curtime + dt, s_pHoldDissolveContext ); + } + } + else + { + SetContextThink( &CPropCombineBall::ExplodeThink, gpGlobals->curtime + inputdata.value.Float(), s_pExplodeTimerContext ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPropCombineBall::InputAddLifetime( inputdata_t &inputdata ) +{ + if (m_bHeld) + { + // Special handling when held + float dt = (GetNextThink( s_pHoldDissolveContext ) - gpGlobals->curtime + inputdata.value.Float()); + float flSoundRampTime = GetBallHoldDissolveTime() - GetBallHoldSoundRampTime(); + + if (dt > flSoundRampTime) + { + if ( m_pHoldingSound ) + { + // Reset holding sound to regular pitch + CSoundEnvelopeController &controller = CSoundEnvelopeController::GetController(); + controller.SoundChangePitch( m_pHoldingSound, 100, flSoundRampTime ); + } + + SetContextThink( &CPropCombineBall::DissolveRampSoundThink, gpGlobals->curtime + dt - flSoundRampTime, s_pHoldDissolveContext ); + } + else + { + if ( m_pHoldingSound ) + { + // Do pitch ramp based on our custom time, which is less than the normal pitch ramp time + CSoundEnvelopeController &controller = CSoundEnvelopeController::GetController(); + controller.SoundChangePitch( m_pHoldingSound, 150, dt ); + } + SetContextThink( &CPropCombineBall::DissolveThink, gpGlobals->curtime + dt, s_pHoldDissolveContext ); + } + } + else + { + SetContextThink( &CPropCombineBall::ExplodeThink, gpGlobals->curtime + (GetNextThink( s_pExplodeTimerContext ) + inputdata.value.Float()), s_pExplodeTimerContext ); + } +} +#endif + //----------------------------------------------------------------------------- // Cleanup. //----------------------------------------------------------------------------- @@ -1245,6 +1333,12 @@ void CPropCombineBall::OnHitEntity( CBaseEntity *pHitEntity, float flSpeed, int m_flNextDamageTime = gpGlobals->curtime + 0.1f; } +#ifdef MAPBASE + // Damage forces for NPC balls. + info.SetDamagePosition( GetAbsOrigin() ); + info.SetDamageForce( GetAbsVelocity() ); +#endif + pHitEntity->TakeDamage( info ); } } diff --git a/sp/src/game/server/hl2/prop_combine_ball.h b/sp/src/game/server/hl2/prop_combine_ball.h index 1de4390d..d750d6ad 100644 --- a/sp/src/game/server/hl2/prop_combine_ball.h +++ b/sp/src/game/server/hl2/prop_combine_ball.h @@ -65,6 +65,10 @@ public: void InputFadeAndRespawn( inputdata_t &inputdata ); void InputKill( inputdata_t &inputdata ); void InputSocketed( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetLifetime( inputdata_t &inputdata ); + void InputAddLifetime( inputdata_t &inputdata ); +#endif enum { diff --git a/sp/src/game/server/hl2/proto_sniper.cpp b/sp/src/game/server/hl2/proto_sniper.cpp index fe9844eb..847f961a 100644 --- a/sp/src/game/server/hl2/proto_sniper.cpp +++ b/sp/src/game/server/hl2/proto_sniper.cpp @@ -33,6 +33,13 @@ #include "effect_color_tables.h" #include "npc_rollermine.h" #include "eventqueue.h" +#ifdef MAPBASE +#include "CRagdollMagnet.h" +#endif +#ifdef EXPANDED_RESPONSE_SYSTEM_USAGE +#include "mapbase/expandedrs_combine.h" +#include "ai_speech.h" +#endif #include "effect_dispatch_data.h" #include "te_effect_dispatch.h" @@ -62,6 +69,9 @@ extern ConVar sk_dmg_sniper_penetrate_npc; #define SF_SNIPER_STARTDISABLED (1 << 19) #define SF_SNIPER_FAST (1 << 20) ///< This is faster-shooting sniper. Paint time is decreased 25%. Bullet speed increases 150%. #define SF_SNIPER_NOSWEEP (1 << 21) ///< This sniper doesn't sweep to the target or use decoys. +#ifdef MAPBASE +#define SF_SNIPER_DIE_ON_FIRE (1 << 22) // This sniper dies on fire. +#endif // If the last time I fired at someone was between 0 and this many seconds, draw // a bead on them much faster. (use subsequent paint time) @@ -194,9 +204,15 @@ private: //========================================================= //========================================================= +#ifdef EXPANDED_RESPONSE_SYSTEM_USAGE +class CProtoSniper : public CAI_ExpresserHost +{ + DECLARE_CLASS( CProtoSniper, CAI_ExpresserHost ); +#else class CProtoSniper : public CAI_BaseNPC { DECLARE_CLASS( CProtoSniper, CAI_BaseNPC ); +#endif public: CProtoSniper( void ); @@ -262,7 +278,21 @@ public: void NotifyShotMissedTarget(); +#ifdef EXPANDED_RESPONSE_SYSTEM_USAGE + //DeclareResponseSystem() + bool SpeakIfAllowed(const char *concept, const char *modifiers = NULL); + void ModifyOrAppendCriteria( AI_CriteriaSet& set ); + + virtual CAI_Expresser *CreateExpresser( void ); + virtual CAI_Expresser *GetExpresser() { return m_pExpresser; } + virtual void PostConstructor( const char *szClassname ); +#endif + private: + +#ifdef EXPANDED_RESPONSE_SYSTEM_USAGE + CAI_Expresser * m_pExpresser; +#endif bool ShouldSnapShot( void ); void ClearTargetGroup( void ); @@ -363,6 +393,11 @@ private: bool m_bKilledPlayer; bool m_bShootZombiesInChest; ///< if true, do not try to shoot zombies in the headcrab +#ifdef MAPBASE + string_t m_iszBeamName; // Custom beam texture + color32 m_BeamColor; // Custom beam color +#endif + COutputEvent m_OnShotFired; DEFINE_CUSTOM_AI; @@ -440,6 +475,11 @@ BEGIN_DATADESC( CProtoSniper ) DEFINE_FIELD( m_bWarnedTargetEntity, FIELD_BOOLEAN ), DEFINE_FIELD( m_flTimeLastShotMissed, FIELD_TIME ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_iszBeamName, FIELD_STRING, "BeamName" ), + DEFINE_KEYFIELD( m_BeamColor, FIELD_COLOR32, "BeamColor" ), +#endif + // Inputs DEFINE_INPUTFUNC( FIELD_VOID, "EnableSniper", InputEnableSniper ), DEFINE_INPUTFUNC( FIELD_VOID, "DisableSniper", InputDisableSniper ), @@ -496,6 +536,10 @@ enum Sniper_Conds COND_SNIPER_FRUSTRATED, COND_SNIPER_SWEEP_TARGET, COND_SNIPER_NO_SHOT, +#ifdef MAPBASE + // Using COND_ENEMY_DEAD made us take credit for other people's kills + COND_SNIPER_KILLED_ENEMY, +#endif }; @@ -557,7 +601,11 @@ CProtoSniper::CProtoSniper( void ) : m_flKeyfieldPaintTime(SNIPER_DEFAULT_PAINT_ bool CProtoSniper::QuerySeeEntity( CBaseEntity *pEntity, bool bOnlyHateOrFearIfNPC ) { Disposition_t disp = IRelationType(pEntity); +#ifdef MAPBASE + if( disp <= D_FR ) +#else if( disp != D_HT ) +#endif { // Don't bother with anything I wouldn't shoot. return false; @@ -643,8 +691,13 @@ void CProtoSniper::LaserOn( const Vector &vecTarget, const Vector &vecDeviance ) { if (!m_pBeam) { +#ifdef MAPBASE + m_pBeam = CBeam::BeamCreate( STRING(m_iszBeamName), 1.0f ); + m_pBeam->SetColor( m_BeamColor.r, m_BeamColor.g, m_BeamColor.b ); +#else m_pBeam = CBeam::BeamCreate( "effects/bluelaser1.vmt", 1.0f ); m_pBeam->SetColor( 0, 100, 255 ); +#endif } else { @@ -904,10 +957,40 @@ LINK_ENTITY_TO_CLASS( sniperbullet, CSniperBullet ); //----------------------------------------------------------------------------- void CProtoSniper::Precache( void ) { +#ifdef MAPBASE + if (GetModelName() == NULL_STRING) + SetModelName(AllocPooledString("models/combine_soldier.mdl")); + + PrecacheModel(STRING(GetModelName())); + + // Should we bother to make these customizable? These are static, too. + sHaloSprite = PrecacheModel("sprites/light_glow03.vmt"); + sFlashSprite = PrecacheModel( "sprites/muzzleflash1.vmt" ); + + if (m_iszBeamName == NULL_STRING) + { + m_iszBeamName = AllocPooledString("effects/bluelaser1.vmt"); + m_BeamColor.r = 0; + m_BeamColor.g = 100; + m_BeamColor.b = 255; + } + else if (Q_GetFileExtension(STRING(m_iszBeamName)) == NULL) + { + // The path doesn't have a .vmt. Fix this or we crash! + // + // I know I warn against using .vmt even though this code ultimately ensures there is no consequence other than a warning, + // but it's bad practice and remember: That old string without the .vmt would likely be floating around somewhere doing nothing. + Warning("%s beam name \"%s\" lacks .vmt!\n", GetDebugName(), STRING(m_iszBeamName)); + m_iszBeamName = AllocPooledString(UTIL_VarArgs("%s.vmt", STRING(m_iszBeamName))); + } + + PrecacheModel(STRING(m_iszBeamName)); +#else PrecacheModel("models/combine_soldier.mdl"); sHaloSprite = PrecacheModel("sprites/light_glow03.vmt"); sFlashSprite = PrecacheModel( "sprites/muzzleflash1.vmt" ); PrecacheModel("effects/bluelaser1.vmt"); +#endif UTIL_PrecacheOther( "sniperbullet" ); @@ -931,8 +1014,12 @@ void CProtoSniper::Spawn( void ) { Precache(); +#ifdef MAPBASE + SetModel( STRING(GetModelName()) ); +#else /// HACK: SetModel( "models/combine_soldier.mdl" ); +#endif //m_hBullet = (CSniperBullet *)Create( "sniperbullet", GetBulletOrigin(), GetLocalAngles(), NULL ); @@ -1327,11 +1414,32 @@ void CProtoSniper::Event_Killed( const CTakeDamageInfo &info ) { if( !(m_spawnflags & SF_SNIPER_NOCORPSE) ) { +#ifdef MAPBASE + Vector vecForce; + + // See if there's a ragdoll magnet that should influence our force. + // However, to avoid conflicts with existing maps, only allow magnets that have us as their target. + CRagdollMagnet *pMagnet = CRagdollMagnet::FindBestMagnet( this ); + if( pMagnet && pMagnet->m_target == GetEntityName() ) + { + vecForce = pMagnet->GetForceVector( this ); + pMagnet->m_OnUsed.Set(vecForce, this, pMagnet); + } + else + { + Vector vecForward; + AngleVectors( GetLocalAngles(), &vecForward ); + float flForce = random->RandomFloat( 500, 700 ) * 10; + + vecForce = (vecForward * flForce) + Vector(0, 0, 600); + } +#else Vector vecForward; float flForce = random->RandomFloat( 500, 700 ) * 10; AngleVectors( GetLocalAngles(), &vecForward ); +#endif float flFadeTime = 0.0; @@ -1341,8 +1449,13 @@ void CProtoSniper::Event_Killed( const CTakeDamageInfo &info ) } CBaseEntity *pGib; +#ifdef MAPBASE + bool bShouldIgnite = IsOnFire() || HasSpawnFlags(SF_SNIPER_DIE_ON_FIRE); + pGib = CreateRagGib( STRING(GetModelName()), GetLocalOrigin(), GetLocalAngles(), vecForce, flFadeTime, bShouldIgnite ); +#else bool bShouldIgnite = IsOnFire() || hl2_episodic.GetBool(); pGib = CreateRagGib( "models/combine_soldier.mdl", GetLocalOrigin(), GetLocalAngles(), (vecForward * flForce) + Vector(0, 0, 600), flFadeTime, bShouldIgnite ); +#endif } @@ -1357,7 +1470,11 @@ void CProtoSniper::Event_Killed( const CTakeDamageInfo &info ) LaserOff(); +#ifdef EXPANDED_RESPONSE_SYSTEM_USAGE + SpeakIfAllowed( TLK_SNIPER_DIE ); +#else EmitSound( "NPC_Sniper.Die" ); +#endif UTIL_Remove( this ); } @@ -1366,6 +1483,11 @@ void CProtoSniper::Event_Killed( const CTakeDamageInfo &info ) //--------------------------------------------------------- void CProtoSniper::Event_KilledOther( CBaseEntity *pVictim, const CTakeDamageInfo &info ) { +#ifdef MAPBASE + if (pVictim == GetEnemy()) + SetCondition(COND_SNIPER_KILLED_ENEMY); +#endif + if( pVictim && pVictim->IsPlayer() ) { m_bKilledPlayer = true; @@ -1384,10 +1506,18 @@ void CProtoSniper::UpdateOnRemove( void ) //--------------------------------------------------------- int CProtoSniper::SelectSchedule ( void ) { +#ifdef EXPANDED_RESPONSE_SYSTEM_USAGE + if (HasCondition(COND_SNIPER_KILLED_ENEMY)) + { + SpeakIfAllowed(TLK_SNIPER_TARGETDESTROYED); + ClearCondition(COND_SNIPER_KILLED_ENEMY); + } +#else if( HasCondition(COND_ENEMY_DEAD) && sniperspeak.GetBool() ) { EmitSound( "NPC_Sniper.TargetDestroyed" ); } +#endif if( !m_fWeaponLoaded ) { @@ -1420,10 +1550,14 @@ int CProtoSniper::SelectSchedule ( void ) // probably won't harm him. // Also, don't play the sound effect if we're an ally. +#ifdef EXPANDED_RESPONSE_SYSTEM_USAGE + SpeakIfAllowed(TLK_SNIPER_DANGER); +#else if ( IsPlayerAllySniper() == false ) { EmitSound( "NPC_Sniper.HearDanger" ); } +#endif } return SCHED_PSNIPER_SUPPRESSED; @@ -2901,6 +3035,52 @@ void CProtoSniper::NotifyShotMissedTarget() // in these NPCs' walk and run animations. } +#ifdef EXPANDED_RESPONSE_SYSTEM_USAGE +//----------------------------------------------------------------------------- +// Purpose: Speak concept +//----------------------------------------------------------------------------- +bool CProtoSniper::SpeakIfAllowed(const char *concept, const char *modifiers) +{ + if (!GetExpresser()->CanSpeakConcept(concept)) + return false; + + return Speak(concept, modifiers); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CProtoSniper::ModifyOrAppendCriteria( AI_CriteriaSet& set ) +{ + BaseClass::ModifyOrAppendCriteria( set ); + + // We still need this + set.AppendCriteria( "sniperspeak", UTIL_VarArgs("%i", sniperspeak.GetInt()) ); + set.AppendCriteria( "playerally", UTIL_VarArgs("%d", IsPlayerAllySniper()) ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CAI_Expresser *CProtoSniper::CreateExpresser( void ) +{ + m_pExpresser = new CAI_Expresser(this); + if (!m_pExpresser) + return NULL; + + m_pExpresser->Connect(this); + return m_pExpresser; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CProtoSniper::PostConstructor(const char *szClassname) +{ + BaseClass::PostConstructor(szClassname); + CreateExpresser(); +} +#endif + //----------------------------------------------------------------------------- // // Schedules @@ -2916,6 +3096,9 @@ AI_BEGIN_CUSTOM_NPC( proto_sniper, CProtoSniper ) DECLARE_CONDITION( COND_SNIPER_FRUSTRATED ); DECLARE_CONDITION( COND_SNIPER_SWEEP_TARGET ); DECLARE_CONDITION( COND_SNIPER_NO_SHOT ); +#ifdef MAPBASE + DECLARE_CONDITION( COND_SNIPER_KILLED_ENEMY ); +#endif DECLARE_TASK( TASK_SNIPER_FRUSTRATED_ATTACK ); DECLARE_TASK( TASK_SNIPER_PAINT_ENEMY ); diff --git a/sp/src/game/server/hl2/script_intro.cpp b/sp/src/game/server/hl2/script_intro.cpp index 2798af2c..fd86edeb 100644 --- a/sp/src/game/server/hl2/script_intro.cpp +++ b/sp/src/game/server/hl2/script_intro.cpp @@ -46,6 +46,11 @@ BEGIN_DATADESC(CScriptIntro) DEFINE_KEYFIELD( m_bAlternateFOV, FIELD_BOOLEAN, "alternatefovchange" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bDrawSky, FIELD_BOOLEAN, "DrawSky" ), + DEFINE_KEYFIELD( m_bDrawSky2, FIELD_BOOLEAN, "DrawSky2" ), +#endif + // Inputs DEFINE_INPUTFUNC(FIELD_STRING, "SetCameraViewEntity", InputSetCameraViewEntity ), DEFINE_INPUTFUNC(FIELD_INTEGER, "SetBlendMode", InputSetBlendMode ), @@ -58,6 +63,10 @@ BEGIN_DATADESC(CScriptIntro) DEFINE_INPUTFUNC(FIELD_VOID, "Deactivate", InputDeactivate ), DEFINE_INPUTFUNC(FIELD_STRING, "FadeTo", InputFadeTo ), DEFINE_INPUTFUNC(FIELD_STRING, "SetFadeColor", InputSetFadeColor ), +#ifdef MAPBASE + DEFINE_INPUTFUNC(FIELD_BOOLEAN, "SetDrawSky", InputSetDrawSky ), + DEFINE_INPUTFUNC(FIELD_BOOLEAN, "SetDrawSky2", InputSetDrawSky2 ), +#endif DEFINE_THINKFUNC( BlendComplete ), @@ -71,7 +80,10 @@ IMPLEMENT_SERVERCLASS_ST( CScriptIntro, DT_ScriptIntro ) SendPropFloat( SENDINFO( m_flNextBlendTime ), 10 ), SendPropFloat( SENDINFO( m_flBlendStartTime ), 10 ), SendPropBool( SENDINFO( m_bActive ) ), - +#ifdef MAPBASE + SendPropBool( SENDINFO( m_bDrawSky ) ), + SendPropBool( SENDINFO( m_bDrawSky2 ) ), +#endif // Fov & fov blends SendPropInt( SENDINFO( m_iFOV ), 9 ), diff --git a/sp/src/game/server/hl2/script_intro.h b/sp/src/game/server/hl2/script_intro.h index 5e59fa33..d5be4da2 100644 --- a/sp/src/game/server/hl2/script_intro.h +++ b/sp/src/game/server/hl2/script_intro.h @@ -44,6 +44,11 @@ public: void InputFadeTo( inputdata_t &inputdata ); void InputSetFadeColor( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetDrawSky( inputdata_t &inputdata ) { m_bDrawSky = inputdata.value.Bool(); } + void InputSetDrawSky2( inputdata_t &inputdata ) { m_bDrawSky2 = inputdata.value.Bool(); } +#endif + bool GetIncludedPVSOrigin( Vector *pOrigin, CBaseEntity **ppCamera ); private: @@ -61,6 +66,10 @@ private: CNetworkVar( float, m_flBlendStartTime ); CNetworkVar( int, m_iStartFOV ); CNetworkVar( bool, m_bActive ); +#ifdef MAPBASE + CNetworkVar( bool, m_bDrawSky ); + CNetworkVar( bool, m_bDrawSky2 ); +#endif // Fov & fov blends CNetworkVar( int, m_iNextFOV ); diff --git a/sp/src/game/server/hl2/vehicle_jeep.cpp b/sp/src/game/server/hl2/vehicle_jeep.cpp index 80eb1368..ad3ddd00 100644 --- a/sp/src/game/server/hl2/vehicle_jeep.cpp +++ b/sp/src/game/server/hl2/vehicle_jeep.cpp @@ -135,6 +135,10 @@ BEGIN_DATADESC( CPropJeep ) DEFINE_INPUTFUNC( FIELD_VOID, "ShowHudHint", InputShowHudHint ), DEFINE_INPUTFUNC( FIELD_VOID, "StartRemoveTauCannon", InputStartRemoveTauCannon ), DEFINE_INPUTFUNC( FIELD_VOID, "FinishRemoveTauCannon", InputFinishRemoveTauCannon ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "DisablePhysGun", InputDisablePhysGun ), + DEFINE_INPUTFUNC( FIELD_VOID, "EnablePhysGun", InputEnablePhysGun ), +#endif DEFINE_THINKFUNC( JeepSeagullThink ), END_DATADESC() @@ -148,6 +152,11 @@ END_SEND_TABLE(); LINK_ENTITY_TO_CLASS( prop_vehicle_jeep, CPropJeep ); #endif +#ifdef MAPBASE +// Shortcut to old jeep for those who want to use the scout car in Episodic +LINK_ENTITY_TO_CLASS( prop_vehicle_jeep_old, CPropJeep ); +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -168,6 +177,12 @@ CPropJeep::CPropJeep( void ) m_bUnableToFire = true; m_flAmmoCrateCloseTime = 0; + +#ifdef MAPBASE + // Turn prop_vehicle_jeep_olds into prop_vehicle_jeeps + if (FStrEq(GetClassname(), "prop_vehicle_jeep_old")) + SetClassname("prop_vehicle_jeep"); +#endif } //----------------------------------------------------------------------------- @@ -1674,6 +1689,23 @@ void CPropJeep::InputFinishRemoveTauCannon( inputdata_t &inputdata ) m_bHasGun = false; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Stop players punting the car around. +//----------------------------------------------------------------------------- +void CPropJeep::InputDisablePhysGun( inputdata_t &data ) +{ + AddEFlags( EFL_NO_PHYSCANNON_INTERACTION ); +} +//----------------------------------------------------------------------------- +// Purpose: Return to normal +//----------------------------------------------------------------------------- +void CPropJeep::InputEnablePhysGun( inputdata_t &data ) +{ + RemoveEFlags( EFL_NO_PHYSCANNON_INTERACTION ); +} +#endif + //======================================================================================================================================== // JEEP FOUR WHEEL PHYSICS VEHICLE SERVER VEHICLE //======================================================================================================================================== diff --git a/sp/src/game/server/hl2/vehicle_jeep.h b/sp/src/game/server/hl2/vehicle_jeep.h index ba08c2c4..982ee6db 100644 --- a/sp/src/game/server/hl2/vehicle_jeep.h +++ b/sp/src/game/server/hl2/vehicle_jeep.h @@ -118,6 +118,10 @@ private: void InputShowHudHint( inputdata_t &inputdata ); void InputStartRemoveTauCannon( inputdata_t &inputdata ); void InputFinishRemoveTauCannon( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputDisablePhysGun( inputdata_t &data ); + void InputEnablePhysGun( inputdata_t &data ); +#endif protected: diff --git a/sp/src/game/server/hl2/vehicle_prisoner_pod.cpp b/sp/src/game/server/hl2/vehicle_prisoner_pod.cpp index 1288e082..3b44f4a8 100644 --- a/sp/src/game/server/hl2/vehicle_prisoner_pod.cpp +++ b/sp/src/game/server/hl2/vehicle_prisoner_pod.cpp @@ -115,8 +115,10 @@ public: void HandleAnimEvent( animevent_t *pEvent ); // Inputs +#ifndef MAPBASE void InputEnterVehicleImmediate( inputdata_t &inputdata ); void InputEnterVehicle( inputdata_t &inputdata ); +#endif void InputExitVehicle( inputdata_t &inputdata ); void InputLock( inputdata_t &inputdata ); void InputUnlock( inputdata_t &inputdata ); @@ -188,8 +190,10 @@ BEGIN_DATADESC( CPropVehiclePrisonerPod ) // Inputs DEFINE_INPUTFUNC( FIELD_VOID, "Lock", InputLock ), DEFINE_INPUTFUNC( FIELD_VOID, "Unlock", InputUnlock ), +#ifndef MAPBASE DEFINE_INPUTFUNC( FIELD_VOID, "EnterVehicle", InputEnterVehicle ), DEFINE_INPUTFUNC( FIELD_VOID, "EnterVehicleImmediate", InputEnterVehicleImmediate ), +#endif DEFINE_INPUTFUNC( FIELD_VOID, "ExitVehicle", InputExitVehicle ), DEFINE_INPUTFUNC( FIELD_VOID, "Open", InputOpen ), DEFINE_INPUTFUNC( FIELD_VOID, "Close", InputClose ), @@ -583,6 +587,7 @@ void CPropVehiclePrisonerPod::InputUnlock( inputdata_t &inputdata ) } +#ifndef MAPBASE //----------------------------------------------------------------------------- // Purpose: Force the player to enter the vehicle. //----------------------------------------------------------------------------- @@ -645,6 +650,7 @@ void CPropVehiclePrisonerPod::InputEnterVehicleImmediate( inputdata_t &inputdata Assert( 0 ); } } +#endif //----------------------------------------------------------------------------- // Purpose: Force the player to exit the vehicle. diff --git a/sp/src/game/server/hl2/weapon_357.cpp b/sp/src/game/server/hl2/weapon_357.cpp index 2b3a3a12..acba33c5 100644 --- a/sp/src/game/server/hl2/weapon_357.cpp +++ b/sp/src/game/server/hl2/weapon_357.cpp @@ -39,8 +39,43 @@ public: float WeaponAutoAimScale() { return 0.6f; } +#ifdef MAPBASE + int CapabilitiesGet( void ) { return bits_CAP_WEAPON_RANGE_ATTACK1; } + + virtual int GetMinBurst() { return 1; } + virtual int GetMaxBurst() { return 1; } + virtual float GetMinRestTime( void ) { return 1.0f; } + virtual float GetMaxRestTime( void ) { return 2.5f; } + + virtual float GetFireRate( void ) { return 1.0f; } + + virtual const Vector& GetBulletSpread( void ) + { + static Vector cone = VECTOR_CONE_15DEGREES; + if (!GetOwner() || !GetOwner()->IsNPC()) + return cone; + + static Vector AllyCone = VECTOR_CONE_2DEGREES; + static Vector NPCCone = VECTOR_CONE_5DEGREES; + + if( GetOwner()->MyNPCPointer()->IsPlayerAlly() ) + { + // 357 allies should be cooler + return AllyCone; + } + + return NPCCone; + } + + void FireNPCPrimaryAttack( CBaseCombatCharacter *pOperator, Vector &vecShootOrigin, Vector &vecShootDir ); + void Operator_ForceNPCFire( CBaseCombatCharacter *pOperator, bool bSecondary ); +#endif + DECLARE_SERVERCLASS(); DECLARE_DATADESC(); +#ifdef MAPBASE + DECLARE_ACTTABLE(); +#endif }; LINK_ENTITY_TO_CLASS( weapon_357, CWeapon357 ); @@ -53,6 +88,29 @@ END_SEND_TABLE() BEGIN_DATADESC( CWeapon357 ) END_DATADESC() +#ifdef MAPBASE +acttable_t CWeapon357::m_acttable[] = +{ + { ACT_IDLE, ACT_IDLE_PISTOL, true }, + { ACT_IDLE_ANGRY, ACT_IDLE_ANGRY_PISTOL, true }, + { ACT_RANGE_ATTACK1, ACT_RANGE_ATTACK_PISTOL, true }, + { ACT_RELOAD, ACT_RELOAD_PISTOL, true }, + { ACT_WALK_AIM, ACT_WALK_AIM_PISTOL, true }, + { ACT_RUN_AIM, ACT_RUN_AIM_PISTOL, true }, + { ACT_GESTURE_RANGE_ATTACK1, ACT_GESTURE_RANGE_ATTACK_PISTOL,true }, + { ACT_RELOAD_LOW, ACT_RELOAD_PISTOL_LOW, false }, + { ACT_RANGE_ATTACK1_LOW, ACT_RANGE_ATTACK_PISTOL_LOW, false }, + { ACT_COVER_LOW, ACT_COVER_PISTOL_LOW, false }, + { ACT_RANGE_AIM_LOW, ACT_RANGE_AIM_PISTOL_LOW, false }, + { ACT_GESTURE_RELOAD, ACT_GESTURE_RELOAD_PISTOL, false }, + { ACT_WALK, ACT_WALK_PISTOL, false }, + { ACT_RUN, ACT_RUN_PISTOL, false }, +}; + + +IMPLEMENT_ACTTABLE( CWeapon357 ); +#endif + //----------------------------------------------------------------------------- // Purpose: Constructor //----------------------------------------------------------------------------- @@ -60,6 +118,13 @@ CWeapon357::CWeapon357( void ) { m_bReloadsSingly = false; m_bFiresUnderwater = false; + +#ifdef MAPBASE + m_fMinRange1 = 24; + m_fMaxRange1 = 1000; + m_fMinRange2 = 24; + m_fMaxRange2 = 200; +#endif } //----------------------------------------------------------------------------- @@ -87,9 +152,57 @@ void CWeapon357::Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatChara break; } +#ifdef MAPBASE + case EVENT_WEAPON_PISTOL_FIRE: + { + Vector vecShootOrigin, vecShootDir; + vecShootOrigin = pOperator->Weapon_ShootPosition(); + + CAI_BaseNPC *npc = pOperator->MyNPCPointer(); + ASSERT( npc != NULL ); + + vecShootDir = npc->GetActualShootTrajectory( vecShootOrigin ); + + FireNPCPrimaryAttack( pOperator, vecShootOrigin, vecShootDir ); + } + break; + default: + BaseClass::Operator_HandleAnimEvent( pEvent, pOperator ); + break; +#endif } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CWeapon357::FireNPCPrimaryAttack( CBaseCombatCharacter *pOperator, Vector &vecShootOrigin, Vector &vecShootDir ) +{ + CSoundEnt::InsertSound( SOUND_COMBAT|SOUND_CONTEXT_GUNFIRE, pOperator->GetAbsOrigin(), SOUNDENT_VOLUME_PISTOL, 0.2, pOperator, SOUNDENT_CHANNEL_WEAPON, pOperator->GetEnemy() ); + + WeaponSound( SINGLE_NPC ); + pOperator->FireBullets( 1, vecShootOrigin, vecShootDir, VECTOR_CONE_PRECALCULATED, MAX_TRACE_LENGTH, m_iPrimaryAmmoType, 0 ); + pOperator->DoMuzzleFlash(); + m_iClip1 = m_iClip1 - 1; +} + +//----------------------------------------------------------------------------- +// Purpose: Some things need this. (e.g. the new Force(X)Fire inputs or blindfire actbusy) +//----------------------------------------------------------------------------- +void CWeapon357::Operator_ForceNPCFire( CBaseCombatCharacter *pOperator, bool bSecondary ) +{ + // Ensure we have enough rounds in the clip + m_iClip1++; + + Vector vecShootOrigin, vecShootDir; + QAngle angShootDir; + GetAttachment( LookupAttachment( "muzzle" ), vecShootOrigin, angShootDir ); + AngleVectors( angShootDir, &vecShootDir ); + FireNPCPrimaryAttack( pOperator, vecShootOrigin, vecShootDir ); +} +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- diff --git a/sp/src/game/server/hl2/weapon_annabelle.cpp b/sp/src/game/server/hl2/weapon_annabelle.cpp index 94a8a1a8..47ee9e39 100644 --- a/sp/src/game/server/hl2/weapon_annabelle.cpp +++ b/sp/src/game/server/hl2/weapon_annabelle.cpp @@ -82,6 +82,9 @@ END_DATADESC() acttable_t CWeaponAnnabelle::m_acttable[] = { +#ifdef MAPBASE + { ACT_IDLE, ACT_IDLE_SMG1, false }, +#endif { ACT_IDLE_ANGRY, ACT_IDLE_ANGRY_SMG1, true }, { ACT_RANGE_ATTACK1, ACT_RANGE_ATTACK_SHOTGUN, true }, { ACT_RELOAD, ACT_RELOAD_SMG1, true }, diff --git a/sp/src/game/server/hl2/weapon_ar2.cpp b/sp/src/game/server/hl2/weapon_ar2.cpp index d9c7ec25..89a16700 100644 --- a/sp/src/game/server/hl2/weapon_ar2.cpp +++ b/sp/src/game/server/hl2/weapon_ar2.cpp @@ -27,6 +27,9 @@ #include "npc_combine.h" #include "rumble_shared.h" #include "gamestats.h" +#ifdef MAPBASE +#include "npc_playercompanion.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -35,6 +38,10 @@ ConVar sk_weapon_ar2_alt_fire_radius( "sk_weapon_ar2_alt_fire_radius", "10" ); ConVar sk_weapon_ar2_alt_fire_duration( "sk_weapon_ar2_alt_fire_duration", "2" ); ConVar sk_weapon_ar2_alt_fire_mass( "sk_weapon_ar2_alt_fire_mass", "150" ); +#ifdef MAPBASE +extern acttable_t *GetSMG1Acttable(); +#endif + //========================================================= //========================================================= @@ -54,6 +61,56 @@ PRECACHE_WEAPON_REGISTER(weapon_ar2); acttable_t CWeaponAR2::m_acttable[] = { +#if AR2_ACTIVITY_FIX == 1 + { ACT_RANGE_ATTACK1, ACT_RANGE_ATTACK_AR2, true }, + { ACT_RELOAD, ACT_RELOAD_AR2, true }, + { ACT_IDLE, ACT_IDLE_AR2, true }, + { ACT_IDLE_ANGRY, ACT_IDLE_ANGRY_AR2, false }, + + { ACT_WALK, ACT_WALK_AR2, true }, + +// Readiness activities (not aiming) + { ACT_IDLE_RELAXED, ACT_IDLE_AR2_RELAXED, false },//never aims + { ACT_IDLE_STIMULATED, ACT_IDLE_AR2_STIMULATED, false }, + { ACT_IDLE_AGITATED, ACT_IDLE_ANGRY_AR2, false },//always aims + + { ACT_WALK_RELAXED, ACT_WALK_AR2_RELAXED, false },//never aims + { ACT_WALK_STIMULATED, ACT_WALK_AR2_STIMULATED, false }, + { ACT_WALK_AGITATED, ACT_WALK_AIM_AR2, false },//always aims + + { ACT_RUN_RELAXED, ACT_RUN_AR2_RELAXED, false },//never aims + { ACT_RUN_STIMULATED, ACT_RUN_AR2_STIMULATED, false }, + { ACT_RUN_AGITATED, ACT_RUN_AIM_RIFLE, false },//always aims + +// Readiness activities (aiming) + { ACT_IDLE_AIM_RELAXED, ACT_IDLE_AR2_RELAXED, false },//never aims + { ACT_IDLE_AIM_STIMULATED, ACT_IDLE_AIM_AR2_STIMULATED, false }, + { ACT_IDLE_AIM_AGITATED, ACT_IDLE_ANGRY_AR2, false },//always aims + + { ACT_WALK_AIM_RELAXED, ACT_WALK_AR2_RELAXED, false },//never aims + { ACT_WALK_AIM_STIMULATED, ACT_WALK_AIM_AR2_STIMULATED, false }, + { ACT_WALK_AIM_AGITATED, ACT_WALK_AIM_AR2, false },//always aims + + { ACT_RUN_AIM_RELAXED, ACT_RUN_AR2_RELAXED, false },//never aims + { ACT_RUN_AIM_STIMULATED, ACT_RUN_AIM_AR2_STIMULATED, false }, + { ACT_RUN_AIM_AGITATED, ACT_RUN_AIM_RIFLE, false },//always aims +//End readiness activities + + { ACT_WALK_AIM, ACT_WALK_AIM_AR2, true }, + { ACT_WALK_CROUCH, ACT_WALK_CROUCH_RIFLE, true }, + { ACT_WALK_CROUCH_AIM, ACT_WALK_CROUCH_AIM_RIFLE, true }, + { ACT_RUN, ACT_RUN_AR2, true }, + { ACT_RUN_AIM, ACT_RUN_AIM_RIFLE, true }, + { ACT_RUN_CROUCH, ACT_RUN_CROUCH_RIFLE, true }, + { ACT_RUN_CROUCH_AIM, ACT_RUN_CROUCH_AIM_RIFLE, true }, + { ACT_GESTURE_RANGE_ATTACK1, ACT_GESTURE_RANGE_ATTACK_AR2, false }, + { ACT_COVER_LOW, ACT_COVER_SMG1_LOW, false }, + { ACT_RANGE_AIM_LOW, ACT_RANGE_AIM_AR2_LOW, false }, + { ACT_RANGE_ATTACK1_LOW, ACT_RANGE_ATTACK_AR2_LOW, false }, + { ACT_RELOAD_LOW, ACT_RELOAD_SMG1_LOW, false }, + { ACT_GESTURE_RELOAD, ACT_GESTURE_RELOAD_AR2, true }, +// { ACT_RANGE_ATTACK2, ACT_RANGE_ATTACK_AR2_GRENADE, true }, +#else { ACT_RANGE_ATTACK1, ACT_RANGE_ATTACK_AR2, true }, { ACT_RELOAD, ACT_RELOAD_SMG1, true }, // FIXME: hook to AR2 unique { ACT_IDLE, ACT_IDLE_SMG1, true }, // FIXME: hook to AR2 unique @@ -102,6 +159,7 @@ acttable_t CWeaponAR2::m_acttable[] = { ACT_RELOAD_LOW, ACT_RELOAD_SMG1_LOW, false }, { ACT_GESTURE_RELOAD, ACT_GESTURE_RELOAD_SMG1, true }, // { ACT_RANGE_ATTACK2, ACT_RANGE_ATTACK_AR2_GRENADE, true }, +#endif }; IMPLEMENT_ACTTABLE(CWeaponAR2); @@ -382,6 +440,10 @@ void CWeaponAR2::FireNPCSecondaryAttack( CBaseCombatCharacter *pOperator, bool b Vector vecTarget; +#ifdef MAPBASE + // It's shared across all NPCs now that it's available on more than just soldiers on more than just the AR2. + vecTarget = pNPC->GetAltFireTarget(); +#else CNPC_Combine *pSoldier = dynamic_cast( pNPC ); if ( pSoldier ) { @@ -389,6 +451,13 @@ void CWeaponAR2::FireNPCSecondaryAttack( CBaseCombatCharacter *pOperator, bool b // Therefore, we must ask them specifically what direction they are shooting. vecTarget = pSoldier->GetAltFireTarget(); } +#ifdef MAPBASE + else if ( CNPC_PlayerCompanion *pCompanion = dynamic_cast( pNPC ) ) + { + // Companions can use energy balls now. Isn't that lovely? + vecTarget = pCompanion->GetAltFireTarget(); + } +#endif else { // All other users of the AR2 alt-fire shoot directly at their enemy. @@ -397,6 +466,7 @@ void CWeaponAR2::FireNPCSecondaryAttack( CBaseCombatCharacter *pOperator, bool b vecTarget = pNPC->GetEnemy()->BodyTarget( vecSrc ); } +#endif vecAiming = vecTarget - vecSrc; VectorNormalize( vecAiming ); @@ -412,12 +482,25 @@ void CWeaponAR2::FireNPCSecondaryAttack( CBaseCombatCharacter *pOperator, bool b Vector vecVelocity = vecAiming * 1000.0f; // Fire the combine ball +#ifdef MAPBASE + CBaseEntity *pBall = CreateCombineBall( vecSrc, + vecVelocity, + flRadius, + sk_weapon_ar2_alt_fire_mass.GetFloat(), + flDuration, + pNPC ); + + variant_t var; + var.SetEntity(pBall); + pNPC->FireNamedOutput("OnThrowGrenade", var, pBall, pNPC); +#else CreateCombineBall( vecSrc, vecVelocity, flRadius, sk_weapon_ar2_alt_fire_mass.GetFloat(), flDuration, pNPC ); +#endif } //----------------------------------------------------------------------------- diff --git a/sp/src/game/server/hl2/weapon_bugbait.cpp b/sp/src/game/server/hl2/weapon_bugbait.cpp index 38c02239..612fe142 100644 --- a/sp/src/game/server/hl2/weapon_bugbait.cpp +++ b/sp/src/game/server/hl2/weapon_bugbait.cpp @@ -349,6 +349,14 @@ void CWeaponBugBait::ItemPostFrame( void ) if ( pOwner == NULL ) return; +#ifdef MAPBASE + if (pOwner->HasSpawnFlags( SF_PLAYER_SUPPRESS_FIRING )) + { + WeaponIdle(); + return; + } +#endif + // See if we're cocked and ready to throw if ( m_bDrawBackFinished ) { diff --git a/sp/src/game/server/hl2/weapon_cguard.cpp b/sp/src/game/server/hl2/weapon_cguard.cpp index 572a90c5..4b8a67d4 100644 --- a/sp/src/game/server/hl2/weapon_cguard.cpp +++ b/sp/src/game/server/hl2/weapon_cguard.cpp @@ -86,6 +86,10 @@ void TE_ConcussiveExplosion( IRecipientFilter& filter, float delay, //Temp ent for the blast +#ifdef MAPBASE +#define SF_CONCUSSIVEBLAST_REPEATABLE 0x00000001 +#endif + class CConcussiveBlast : public CBaseEntity { DECLARE_DATADESC(); @@ -94,6 +98,13 @@ public: int m_spriteTexture; +#ifdef MAPBASE + float m_flDamage = 200; + float m_flRadius = 256; + float m_flMagnitude = 1.0; + string_t m_iszSoundName; +#endif + CConcussiveBlast( void ) {} //----------------------------------------------------------------------------- @@ -104,6 +115,11 @@ public: { m_spriteTexture = PrecacheModel( "sprites/lgtning.vmt" ); +#ifdef MAPBASE + if (m_iszSoundName != NULL_STRING) + PrecacheScriptSound(STRING(m_iszSoundName)); +#endif + BaseClass::Precache(); } @@ -150,10 +166,32 @@ public: ); //Do the radius damage +#ifdef MAPBASE + RadiusDamage( CTakeDamageInfo( this, GetOwnerEntity(), m_flDamage, DMG_BLAST|DMG_DISSOLVE ), GetAbsOrigin(), m_flRadius, CLASS_NONE, NULL ); +#else RadiusDamage( CTakeDamageInfo( this, GetOwnerEntity(), 200, DMG_BLAST|DMG_DISSOLVE ), GetAbsOrigin(), 256, CLASS_NONE, NULL ); +#endif +#ifdef MAPBASE + if (m_iszSoundName != NULL_STRING) + EmitSound(STRING(m_iszSoundName)); + + if (!HasSpawnFlags(SF_CONCUSSIVEBLAST_REPEATABLE)) +#endif UTIL_Remove( this ); } + +#ifdef MAPBASE + void InputExplode( inputdata_t &inputdata ) + { + Explode(m_flMagnitude); + } + + void InputExplodeWithMagnitude( inputdata_t &inputdata ) + { + Explode(inputdata.value.Int()); + } +#endif }; LINK_ENTITY_TO_CLASS( concussiveblast, CConcussiveBlast ); @@ -165,6 +203,16 @@ BEGIN_DATADESC( CConcussiveBlast ) // DEFINE_FIELD( m_spriteTexture, FIELD_INTEGER ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_flDamage, FIELD_FLOAT, "damage" ), + DEFINE_KEYFIELD( m_flRadius, FIELD_FLOAT, "radius" ), + DEFINE_KEYFIELD( m_flMagnitude, FIELD_FLOAT, "magnitude" ), + DEFINE_KEYFIELD( m_iszSoundName, FIELD_SOUNDNAME, "soundname" ), + + DEFINE_INPUTFUNC( FIELD_VOID, "Explode", InputExplode ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "ExplodeWithMagnitude", InputExplodeWithMagnitude ), +#endif + END_DATADESC() diff --git a/sp/src/game/server/hl2/weapon_crossbow.cpp b/sp/src/game/server/hl2/weapon_crossbow.cpp index badd50d8..50a51b74 100644 --- a/sp/src/game/server/hl2/weapon_crossbow.cpp +++ b/sp/src/game/server/hl2/weapon_crossbow.cpp @@ -54,7 +54,11 @@ class CCrossbowBolt : public CBaseCombatCharacter DECLARE_CLASS( CCrossbowBolt, CBaseCombatCharacter ); public: +#ifdef MAPBASE + CCrossbowBolt(); +#else CCrossbowBolt() { }; +#endif ~CCrossbowBolt(); Class_T Classify( void ) { return CLASS_NONE; } @@ -66,7 +70,16 @@ public: void BoltTouch( CBaseEntity *pOther ); bool CreateVPhysics( void ); unsigned int PhysicsSolidMaskForEntity() const; +#ifdef MAPBASE + static CCrossbowBolt *BoltCreate( const Vector &vecOrigin, const QAngle &angAngles, CBaseCombatCharacter *pentOwner = NULL ); + + void InputSetDamage( inputdata_t &inputdata ); + float m_flDamage; + + virtual void SetDamage(float flDamage) { m_flDamage = flDamage; } +#else static CCrossbowBolt *BoltCreate( const Vector &vecOrigin, const QAngle &angAngles, CBasePlayer *pentOwner = NULL ); +#endif protected: @@ -89,12 +102,23 @@ BEGIN_DATADESC( CCrossbowBolt ) DEFINE_FIELD( m_pGlowSprite, FIELD_EHANDLE ), //DEFINE_FIELD( m_pGlowTrail, FIELD_EHANDLE ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_flDamage, FIELD_FLOAT, "Damage" ), + + // Inputs + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetDamage", InputSetDamage ), +#endif + END_DATADESC() IMPLEMENT_SERVERCLASS_ST( CCrossbowBolt, DT_CrossbowBolt ) END_SEND_TABLE() +#ifdef MAPBASE +CCrossbowBolt *CCrossbowBolt::BoltCreate( const Vector &vecOrigin, const QAngle &angAngles, CBaseCombatCharacter *pentOwner ) +#else CCrossbowBolt *CCrossbowBolt::BoltCreate( const Vector &vecOrigin, const QAngle &angAngles, CBasePlayer *pentOwner ) +#endif { // Create a new entity with CCrossbowBolt private data CCrossbowBolt *pBolt = (CCrossbowBolt *)CreateEntityByName( "crossbow_bolt" ); @@ -102,10 +126,27 @@ CCrossbowBolt *CCrossbowBolt::BoltCreate( const Vector &vecOrigin, const QAngle pBolt->SetAbsAngles( angAngles ); pBolt->Spawn(); pBolt->SetOwnerEntity( pentOwner ); +#ifdef MAPBASE + if (pentOwner && pentOwner->IsNPC()) + pBolt->m_flDamage = sk_npc_dmg_crossbow.GetFloat(); + //else + // pBolt->m_flDamage = sk_plr_dmg_crossbow.GetFloat(); +#endif return pBolt; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CCrossbowBolt::CCrossbowBolt( void ) +{ + // Independent bolts without m_flDamage set need damage + m_flDamage = sk_plr_dmg_crossbow.GetFloat(); +} +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -194,6 +235,16 @@ void CCrossbowBolt::Precache( void ) PrecacheModel( "sprites/light_glow02_noz.vmt" ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CCrossbowBolt::InputSetDamage( inputdata_t &inputdata ) +{ + m_flDamage = inputdata.value.Float(); +} +#endif + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void CCrossbowBolt::BoltTouch( CBaseEntity *pOther ) @@ -201,7 +252,19 @@ void CCrossbowBolt::BoltTouch( CBaseEntity *pOther ) if ( pOther->IsSolidFlagSet(FSOLID_VOLUME_CONTENTS | FSOLID_TRIGGER) ) { // Some NPCs are triggers that can take damage (like antlion grubs). We should hit them. +#ifdef MAPBASE + // But some physics objects that are also triggers (like weapons) shouldn't go through this check. + // + // Note: rpg_missile has the same code, except it properly accounts for weapons in a different way. + // This was discovered after I implemented this and both work fine, but if this ever causes problems, + // use rpg_missile's implementation: + // + // if ( pOther->IsSolidFlagSet(FSOLID_TRIGGER|FSOLID_VOLUME_CONTENTS) && pOther->GetCollisionGroup() != COLLISION_GROUP_WEAPON ) + // + if ( pOther->GetMoveType() == MOVETYPE_NONE && (( pOther->m_takedamage == DAMAGE_NO ) || ( pOther->m_takedamage == DAMAGE_EVENTS_ONLY )) ) +#else if ( ( pOther->m_takedamage == DAMAGE_NO ) || ( pOther->m_takedamage == DAMAGE_EVENTS_ONLY ) ) +#endif return; } @@ -228,7 +291,11 @@ void CCrossbowBolt::BoltTouch( CBaseEntity *pOther ) if( GetOwnerEntity() && GetOwnerEntity()->IsPlayer() && pOther->IsNPC() ) { +#ifdef MAPBASE + CTakeDamageInfo dmgInfo( this, GetOwnerEntity(), m_flDamage, DMG_NEVERGIB ); +#else CTakeDamageInfo dmgInfo( this, GetOwnerEntity(), sk_plr_dmg_crossbow.GetFloat(), DMG_NEVERGIB ); +#endif dmgInfo.AdjustPlayerDamageInflictedForSkillLevel(); CalculateMeleeDamageForce( &dmgInfo, vecNormalizedVel, tr.endpos, 0.7f ); dmgInfo.SetDamagePosition( tr.endpos ); @@ -243,7 +310,11 @@ void CCrossbowBolt::BoltTouch( CBaseEntity *pOther ) } else { +#ifdef MAPBASE + CTakeDamageInfo dmgInfo( this, GetOwnerEntity(), m_flDamage, DMG_BULLET | DMG_NEVERGIB ); +#else CTakeDamageInfo dmgInfo( this, GetOwnerEntity(), sk_plr_dmg_crossbow.GetFloat(), DMG_BULLET | DMG_NEVERGIB ); +#endif CalculateMeleeDamageForce( &dmgInfo, vecNormalizedVel, tr.endpos, 0.7f ); dmgInfo.SetDamagePosition( tr.endpos ); pOther->DispatchTraceAttack( dmgInfo, vecNormalizedVel, &tr ); @@ -434,17 +505,48 @@ public: virtual void Drop( const Vector &vecVelocity ); virtual bool Holster( CBaseCombatWeapon *pSwitchingTo = NULL ); virtual bool Reload( void ); +#ifdef MAPBASE + virtual void Reload_NPC( void ); +#endif virtual void ItemPostFrame( void ); virtual void ItemBusyFrame( void ); virtual void Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCharacter *pOperator ); +#ifdef MAPBASE + virtual void Operator_ForceNPCFire( CBaseCombatCharacter *pOperator, bool bSecondary ); +#endif virtual bool SendWeaponAnim( int iActivity ); virtual bool IsWeaponZoomed() { return m_bInZoom; } bool ShouldDisplayHUDHint() { return true; } +#ifdef MAPBASE + int CapabilitiesGet( void ) { return bits_CAP_WEAPON_RANGE_ATTACK1; } + + virtual int GetMinBurst() { return 1; } + virtual int GetMaxBurst() { return 1; } + + virtual float GetMinRestTime( void ) { return 3.0f; } // 1.5f + virtual float GetMaxRestTime( void ) { return 3.0f; } // 2.0f + + virtual float GetFireRate( void ) { return 5.0f; } + + virtual const Vector& GetBulletSpread( void ) + { + static Vector cone = VECTOR_CONE_15DEGREES; + if (!GetOwner() || !GetOwner()->IsNPC()) + return cone; + + static Vector NPCCone = VECTOR_CONE_5DEGREES; + + return NPCCone; + } +#endif DECLARE_SERVERCLASS(); DECLARE_DATADESC(); +#ifdef MAPBASE + DECLARE_ACTTABLE(); +#endif private: @@ -452,6 +554,9 @@ private: void SetSkin( int skinNum ); void CheckZoomToggle( void ); void FireBolt( void ); +#ifdef MAPBASE + void FireNPCBolt( CAI_BaseNPC *pOwner, Vector &vecShootOrigin, Vector &vecShootDir ); +#endif void ToggleZoom( void ); // Various states for the crossbow's charger @@ -494,6 +599,62 @@ BEGIN_DATADESC( CWeaponCrossbow ) END_DATADESC() +#ifdef MAPBASE +acttable_t CWeaponCrossbow::m_acttable[] = +{ + { ACT_RANGE_ATTACK1, ACT_RANGE_ATTACK_SMG1, true }, + { ACT_RELOAD, ACT_RELOAD_SMG1, true }, + { ACT_IDLE, ACT_IDLE_SMG1, true }, + { ACT_IDLE_ANGRY, ACT_IDLE_ANGRY_SMG1, true }, + + { ACT_WALK, ACT_WALK_RIFLE, true }, + { ACT_WALK_AIM, ACT_WALK_AIM_RIFLE, true }, + +// Readiness activities (not aiming) + { ACT_IDLE_RELAXED, ACT_IDLE_SMG1_RELAXED, false },//never aims + { ACT_IDLE_STIMULATED, ACT_IDLE_SMG1_STIMULATED, false }, + { ACT_IDLE_AGITATED, ACT_IDLE_ANGRY_SMG1, false },//always aims + + { ACT_WALK_RELAXED, ACT_WALK_RIFLE_RELAXED, false },//never aims + { ACT_WALK_STIMULATED, ACT_WALK_RIFLE_STIMULATED, false }, + { ACT_WALK_AGITATED, ACT_WALK_AIM_RIFLE, false },//always aims + + { ACT_RUN_RELAXED, ACT_RUN_RIFLE_RELAXED, false },//never aims + { ACT_RUN_STIMULATED, ACT_RUN_RIFLE_STIMULATED, false }, + { ACT_RUN_AGITATED, ACT_RUN_AIM_RIFLE, false },//always aims + +// Readiness activities (aiming) + { ACT_IDLE_AIM_RELAXED, ACT_IDLE_SMG1_RELAXED, false },//never aims + { ACT_IDLE_AIM_STIMULATED, ACT_IDLE_AIM_RIFLE_STIMULATED, false }, + { ACT_IDLE_AIM_AGITATED, ACT_IDLE_ANGRY_SMG1, false },//always aims + + { ACT_WALK_AIM_RELAXED, ACT_WALK_RIFLE_RELAXED, false },//never aims + { ACT_WALK_AIM_STIMULATED, ACT_WALK_AIM_RIFLE_STIMULATED, false }, + { ACT_WALK_AIM_AGITATED, ACT_WALK_AIM_RIFLE, false },//always aims + + { ACT_RUN_AIM_RELAXED, ACT_RUN_RIFLE_RELAXED, false },//never aims + { ACT_RUN_AIM_STIMULATED, ACT_RUN_AIM_RIFLE_STIMULATED, false }, + { ACT_RUN_AIM_AGITATED, ACT_RUN_AIM_RIFLE, false },//always aims +//End readiness activities + + { ACT_WALK_AIM, ACT_WALK_AIM_RIFLE, true }, + { ACT_WALK_CROUCH, ACT_WALK_CROUCH_RIFLE, true }, + { ACT_WALK_CROUCH_AIM, ACT_WALK_CROUCH_AIM_RIFLE, true }, + { ACT_RUN, ACT_RUN_RIFLE, true }, + { ACT_RUN_AIM, ACT_RUN_AIM_RIFLE, true }, + { ACT_RUN_CROUCH, ACT_RUN_CROUCH_RIFLE, true }, + { ACT_RUN_CROUCH_AIM, ACT_RUN_CROUCH_AIM_RIFLE, true }, + { ACT_GESTURE_RANGE_ATTACK1, ACT_GESTURE_RANGE_ATTACK_SMG1, true }, + { ACT_RANGE_ATTACK1_LOW, ACT_RANGE_ATTACK_SMG1_LOW, true }, + { ACT_COVER_LOW, ACT_COVER_SMG1_LOW, false }, + { ACT_RANGE_AIM_LOW, ACT_RANGE_AIM_SMG1_LOW, false }, + { ACT_RELOAD_LOW, ACT_RELOAD_SMG1_LOW, false }, + { ACT_GESTURE_RELOAD, ACT_GESTURE_RELOAD_SMG1, true }, +}; + +IMPLEMENT_ACTTABLE(CWeaponCrossbow); +#endif + //----------------------------------------------------------------------------- // Purpose: Constructor //----------------------------------------------------------------------------- @@ -504,6 +665,13 @@ CWeaponCrossbow::CWeaponCrossbow( void ) m_bAltFiresUnderwater = true; m_bInZoom = false; m_bMustReload = false; + +#ifdef MAPBASE + m_fMinRange1 = 24; + m_fMaxRange1 = 5000; + m_fMinRange2 = 24; + m_fMaxRange2 = 5000; +#endif } #define CROSSBOW_GLOW_SPRITE "sprites/light_glow02_noz.vmt" @@ -577,6 +745,18 @@ bool CWeaponCrossbow::Reload( void ) return false; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CWeaponCrossbow::Reload_NPC( void ) +{ + BaseClass::Reload_NPC(); + + m_nSkin = 0; +} +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -699,6 +879,44 @@ void CWeaponCrossbow::FireBolt( void ) SetChargerState( CHARGER_STATE_DISCHARGE ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CWeaponCrossbow::FireNPCBolt( CAI_BaseNPC *pOwner, Vector &vecShootOrigin, Vector &vecShootDir ) +{ + Assert(pOwner); + + QAngle angAiming; + VectorAngles( vecShootDir, angAiming ); + + CCrossbowBolt *pBolt = CCrossbowBolt::BoltCreate( vecShootOrigin, angAiming, pOwner ); + + if ( pOwner->GetWaterLevel() == 3 ) + { + pBolt->SetAbsVelocity( vecShootDir * BOLT_WATER_VELOCITY ); + } + else + { + pBolt->SetAbsVelocity( vecShootDir * BOLT_AIR_VELOCITY ); + } + + m_iClip1--; + + m_nSkin = 1; + + WeaponSound( SINGLE_NPC ); + WeaponSound( SPECIAL2 ); + + CSoundEnt::InsertSound( SOUND_COMBAT, GetAbsOrigin(), 200, 0.2 ); + + m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->curtime + 2.5f; + + SetSkin( BOLT_SKIN_GLOW ); + SetChargerState( CHARGER_STATE_DISCHARGE ); +} +#endif + //----------------------------------------------------------------------------- // Purpose: // Output : Returns true on success, false on failure. @@ -761,7 +979,11 @@ void CWeaponCrossbow::CreateChargerEffects( void ) { CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); +#ifdef MAPBASE + if ( m_hChargerSprite != NULL || pOwner == NULL ) +#else if ( m_hChargerSprite != NULL ) +#endif return; m_hChargerSprite = CSprite::SpriteCreate( CROSSBOW_GLOW_SPRITE, GetAbsOrigin(), false ); @@ -933,12 +1155,46 @@ void CWeaponCrossbow::Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombat SetChargerState( CHARGER_STATE_READY ); break; +#ifdef MAPBASE + case EVENT_WEAPON_SMG1: + { + CAI_BaseNPC *pNPC = pOperator->MyNPCPointer(); + Assert(pNPC); + + Vector vecSrc = pNPC->Weapon_ShootPosition(); + Vector vecAiming = pNPC->GetActualShootTrajectory( vecSrc ); + + FireNPCBolt( pNPC, vecSrc, vecAiming ); + //m_bMustReload = true; + } + break; +#endif + default: BaseClass::Operator_HandleAnimEvent( pEvent, pOperator ); break; } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CWeaponCrossbow::Operator_ForceNPCFire( CBaseCombatCharacter *pOperator, bool bSecondary ) +{ + // Ensure we have enough rounds in the clip + m_iClip1++; + + Vector vecShootOrigin, vecShootDir; + QAngle angShootDir; + GetAttachment( LookupAttachment( "muzzle" ), vecShootOrigin, angShootDir ); + AngleVectors( angShootDir, &vecShootDir ); + FireNPCBolt( pOperator->MyNPCPointer(), vecShootOrigin, vecShootDir ); + + //m_bMustReload = true; +} +#endif + //----------------------------------------------------------------------------- // Purpose: Set the desired activity for the weapon and its viewmodel counterpart // Input : iActivity - activity to play diff --git a/sp/src/game/server/hl2/weapon_flaregun.cpp b/sp/src/game/server/hl2/weapon_flaregun.cpp index d3fd6b15..110f5c66 100644 --- a/sp/src/game/server/hl2/weapon_flaregun.cpp +++ b/sp/src/game/server/hl2/weapon_flaregun.cpp @@ -19,6 +19,7 @@ #include "tier0/memdbgon.h" +#ifndef MAPBASE /******************************************************************** NOTE: if you are looking at this file becase you would like flares to be considered as fires (and thereby trigger gas traps), be aware @@ -37,6 +38,13 @@ For some partial work towards this end, see changelist 192474. ********************************************************************/ +#else +// ================================================================ // +// I've fixed this...more or less. env_firesensor detects flares now. +// I tried to integrate it with the greater fire system, but I found that too difficult. +// I probably didn't try hard enough. You could fix this yourself if you think it's a big issue. +// ================================================================ // +#endif #define FLARE_LAUNCH_SPEED 1500 @@ -120,6 +128,21 @@ void KillFlare( CBaseEntity *pOwnerEntity, CBaseEntity *pEntity, float flKillTim } } +#ifdef MAPBASE +// For prop_flare debugging. +float GetEnvFlareLifetime( CBaseEntity *pEntity ) +{ + CFlare *pFlare = static_cast< CFlare *>( pEntity ); + + if ( pFlare ) + { + return pFlare->m_flTimeBurnOut - gpGlobals->curtime; + } + + return 0.0f; +} +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- diff --git a/sp/src/game/server/hl2/weapon_physcannon.cpp b/sp/src/game/server/hl2/weapon_physcannon.cpp index 7e49b7f4..6b82136e 100644 --- a/sp/src/game/server/hl2/weapon_physcannon.cpp +++ b/sp/src/game/server/hl2/weapon_physcannon.cpp @@ -40,6 +40,9 @@ #include "ai_interactions.h" #include "rumble_shared.h" #include "gamestats.h" +#ifdef MAPBASE +#include "mapbase/GlobalStrings.h" +#endif // NVNT haptic utils #include "haptics/haptic_utils.h" @@ -141,6 +144,10 @@ public: // Handle grate entities differently if ( HasContentsGrate( pEntity ) ) { +#ifdef MAPBASE + if (pEntity->CanBePickedUpByPhyscannon()) + return true; +#else // See if it's a grabbable physics prop CPhysicsProp *pPhysProp = dynamic_cast(pEntity); if ( pPhysProp != NULL ) @@ -166,6 +173,7 @@ public: // Somehow had a classname that didn't match the class! Assert(0); } +#endif // Don't bother with any other sort of grated entity return false; @@ -438,10 +446,12 @@ static void ComputePlayerMatrix( CBasePlayer *pPlayer, matrix3x4_t &out ) // Purpose: //----------------------------------------------------------------------------- // derive from this so we can add save/load data to it +#ifndef MAPBASE // Moved to weapon_physcannon.h for point_physics_control struct game_shadowcontrol_params_t : public hlshadowcontrol_params_t { DECLARE_SIMPLE_DATADESC(); }; +#endif BEGIN_SIMPLE_DATADESC( game_shadowcontrol_params_t ) @@ -808,7 +818,14 @@ void CGrabController::AttachEntity( CBasePlayer *pPlayer, CBaseEntity *pEntity, CPhysicsProp *pProp = dynamic_cast(pEntity); if ( pProp ) { +#ifdef MAPBASE + // If the prop has custom carry angles, don't override them + // (regular PreferredCarryAngles() code should cover it) + if (!pProp->m_bUsesCustomCarryAngles) + m_bHasPreferredCarryAngles = pProp->GetPropDataAngles( "preferred_carryangles", m_vecPreferredCarryAngles ); +#else m_bHasPreferredCarryAngles = pProp->GetPropDataAngles( "preferred_carryangles", m_vecPreferredCarryAngles ); +#endif m_flDistanceOffset = pProp->GetCarryDistanceOffset(); } else @@ -2084,6 +2101,10 @@ bool CWeaponPhysCannon::EntityAllowsPunts( CBaseEntity *pEntity ) if ( pEntity->HasSpawnFlags( SF_WEAPON_NO_PHYSCANNON_PUNT ) ) { +#ifdef MAPBASE + if (pEntity->IsBaseCombatWeapon() || pEntity->IsCombatItem()) + return false; +#else CBaseCombatWeapon *pWeapon = dynamic_cast(pEntity); if ( pWeapon != NULL ) @@ -2093,6 +2114,7 @@ bool CWeaponPhysCannon::EntityAllowsPunts( CBaseEntity *pEntity ) return false; } } +#endif } return true; @@ -2448,7 +2470,11 @@ bool CWeaponPhysCannon::AttachObject( CBaseEntity *pObject, const Vector &vPosit } #if defined(HL2_DLL) +#ifdef MAPBASE + if( physcannon_right_turrets.GetBool() && EntIsClass(pObject, gm_isz_class_FloorTurret) ) +#else if( physcannon_right_turrets.GetBool() && pObject->ClassMatches("npc_turret_floor") ) +#endif { // We just picked up a turret. Is it already upright? Vector vecUp; @@ -3287,6 +3313,15 @@ void CWeaponPhysCannon::ItemPostFrame() return; } +#ifdef MAPBASE + if (pOwner->HasSpawnFlags( SF_PLAYER_SUPPRESS_FIRING )) + { + m_nAttack2Debounce = 0; + WeaponIdle(); + return; + } +#endif + //Check for object in pickup range if ( m_bActive == false ) { @@ -3459,6 +3494,12 @@ bool CWeaponPhysCannon::CanPickupObject( CBaseEntity *pTarget ) if ( pOwner && pOwner->GetGroundEntity() == pTarget ) return false; +#ifdef MAPBASE + // The gravity gun can't pick up vehicles. + if ( pTarget->GetServerVehicle() ) + return false; +#endif + if ( !IsMegaPhysCannon() ) { if ( pTarget->VPhysicsIsFlesh( ) ) diff --git a/sp/src/game/server/hl2/weapon_physcannon.h b/sp/src/game/server/hl2/weapon_physcannon.h index d7ce48ee..01356d26 100644 --- a/sp/src/game/server/hl2/weapon_physcannon.h +++ b/sp/src/game/server/hl2/weapon_physcannon.h @@ -30,4 +30,11 @@ CBaseEntity *GetPlayerHeldEntity( CBasePlayer *pPlayer ); bool PhysCannonAccountableForObject( CBaseCombatWeapon *pPhysCannon, CBaseEntity *pObject ); +#ifdef MAPBASE // Moved here so point_physics_control can access, datadesc is still in weapon_physcannon.cpp +struct game_shadowcontrol_params_t : public hlshadowcontrol_params_t +{ + DECLARE_SIMPLE_DATADESC(); +}; +#endif + #endif // WEAPON_PHYSCANNON_H diff --git a/sp/src/game/server/hl2/weapon_pistol.cpp b/sp/src/game/server/hl2/weapon_pistol.cpp index d0a25412..80bb5090 100644 --- a/sp/src/game/server/hl2/weapon_pistol.cpp +++ b/sp/src/game/server/hl2/weapon_pistol.cpp @@ -52,6 +52,10 @@ public: void AddViewKick( void ); void DryFire( void ); void Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCharacter *pOperator ); +#ifdef MAPBASE + void FireNPCPrimaryAttack( CBaseCombatCharacter *pOperator, Vector &vecShootOrigin, Vector &vecShootDir ); + void Operator_ForceNPCFire( CBaseCombatCharacter *pOperator, bool bSecondary ); +#endif void UpdatePenaltyTime( void ); @@ -193,12 +197,16 @@ void CWeaponPistol::Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCh vecShootDir = npc->GetActualShootTrajectory( vecShootOrigin ); +#ifdef MAPBASE + FireNPCPrimaryAttack( pOperator, vecShootOrigin, vecShootDir ); +#else CSoundEnt::InsertSound( SOUND_COMBAT|SOUND_CONTEXT_GUNFIRE, pOperator->GetAbsOrigin(), SOUNDENT_VOLUME_PISTOL, 0.2, pOperator, SOUNDENT_CHANNEL_WEAPON, pOperator->GetEnemy() ); WeaponSound( SINGLE_NPC ); pOperator->FireBullets( 1, vecShootOrigin, vecShootDir, VECTOR_CONE_PRECALCULATED, MAX_TRACE_LENGTH, m_iPrimaryAmmoType, 2 ); pOperator->DoMuzzleFlash(); m_iClip1 = m_iClip1 - 1; +#endif } break; default: @@ -207,6 +215,36 @@ void CWeaponPistol::Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCh } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CWeaponPistol::FireNPCPrimaryAttack( CBaseCombatCharacter *pOperator, Vector &vecShootOrigin, Vector &vecShootDir ) +{ + CSoundEnt::InsertSound( SOUND_COMBAT|SOUND_CONTEXT_GUNFIRE, pOperator->GetAbsOrigin(), SOUNDENT_VOLUME_PISTOL, 0.2, pOperator, SOUNDENT_CHANNEL_WEAPON, pOperator->GetEnemy() ); + + WeaponSound( SINGLE_NPC ); + pOperator->FireBullets( 1, vecShootOrigin, vecShootDir, VECTOR_CONE_PRECALCULATED, MAX_TRACE_LENGTH, m_iPrimaryAmmoType, 2 ); + pOperator->DoMuzzleFlash(); + m_iClip1 = m_iClip1 - 1; +} + +//----------------------------------------------------------------------------- +// Purpose: Some things need this. (e.g. the new Force(X)Fire inputs or blindfire actbusy) +//----------------------------------------------------------------------------- +void CWeaponPistol::Operator_ForceNPCFire( CBaseCombatCharacter *pOperator, bool bSecondary ) +{ + // Ensure we have enough rounds in the clip + m_iClip1++; + + Vector vecShootOrigin, vecShootDir; + QAngle angShootDir; + GetAttachment( LookupAttachment( "muzzle" ), vecShootOrigin, angShootDir ); + AngleVectors( angShootDir, &vecShootDir ); + FireNPCPrimaryAttack( pOperator, vecShootOrigin, vecShootDir ); +} +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- diff --git a/sp/src/game/server/hl2/weapon_rpg.cpp b/sp/src/game/server/hl2/weapon_rpg.cpp index e6278593..b53b47b7 100644 --- a/sp/src/game/server/hl2/weapon_rpg.cpp +++ b/sp/src/game/server/hl2/weapon_rpg.cpp @@ -43,6 +43,9 @@ static ConVar sk_apc_missile_damage("sk_apc_missile_damage", "15"); ConVar rpg_missle_use_custom_detonators( "rpg_missle_use_custom_detonators", "1" ); +#ifdef MAPBASE +ConVar weapon_rpg_use_old_behavior("weapon_rpg_use_old_behavior", "0"); +#endif #define APC_MISSILE_DAMAGE sk_apc_missile_damage.GetFloat() @@ -2039,7 +2042,20 @@ bool CWeaponRPG::WeaponLOSCondition( const Vector &ownerPos, const Vector &targe Vector vecShootDir = npcOwner->GetActualShootTrajectory( vecMuzzle ); // Make sure I have a good 10 feet of wide clearance in front, or I'll blow my teeth out. +#ifdef MAPBASE + // Oh, and don't collide with ourselves or our owner. That would be stupid. + if (!weapon_rpg_use_old_behavior.GetBool()) + { + CTraceFilterSkipTwoEntities pTraceFilter( this, GetOwner(), COLLISION_GROUP_NONE ); + AI_TraceHull( vecMuzzle, vecMuzzle + vecShootDir * (10.0f*12.0f), Vector( -24, -24, -24 ), Vector( 24, 24, 24 ), MASK_NPCSOLID, &pTraceFilter, &tr ); + } + else + { +#endif AI_TraceHull( vecMuzzle, vecMuzzle + vecShootDir * (10.0f*12.0f), Vector( -24, -24, -24 ), Vector( 24, 24, 24 ), MASK_NPCSOLID, NULL, &tr ); +#ifdef MAPBASE + } +#endif if( tr.fraction != 1.0f ) bResult = false; @@ -2089,7 +2105,20 @@ int CWeaponRPG::WeaponRangeAttack1Condition( float flDot, float flDist ) Vector vecShootDir = pOwner->GetActualShootTrajectory( vecMuzzle ); // Make sure I have a good 10 feet of wide clearance in front, or I'll blow my teeth out. +#ifdef MAPBASE + // Oh, and don't collide with ourselves or our owner. That would be stupid. + if (!weapon_rpg_use_old_behavior.GetBool()) + { + CTraceFilterSkipTwoEntities pTraceFilter( this, GetOwner(), COLLISION_GROUP_NONE ); + AI_TraceHull( vecMuzzle, vecMuzzle + vecShootDir * (10.0f*12.0f), Vector( -24, -24, -24 ), Vector( 24, 24, 24 ), MASK_NPCSOLID, &pTraceFilter, &tr ); + } + else + { +#endif AI_TraceHull( vecMuzzle, vecMuzzle + vecShootDir * (10.0f*12.0f), Vector( -24, -24, -24 ), Vector( 24, 24, 24 ), MASK_NPCSOLID, NULL, &tr ); +#ifdef MAPBASE + } +#endif if( tr.fraction != 1.0 ) { @@ -2213,6 +2242,23 @@ void CWeaponRPG::UpdateLaserEffects( void ) } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CWeaponRPG::SupportsBackupActivity(Activity activity) +{ + // NPCs shouldn't use their SMG activities to aim and fire RPGs while running. + if (activity == ACT_RUN_AIM || + activity == ACT_WALK_AIM || + activity == ACT_RUN_CROUCH_AIM || + activity == ACT_WALK_CROUCH_AIM) + return false; + + return true; +} +#endif + //============================================================================= // Laser Dot //============================================================================= diff --git a/sp/src/game/server/hl2/weapon_rpg.h b/sp/src/game/server/hl2/weapon_rpg.h index b8ca99af..aceb8a35 100644 --- a/sp/src/game/server/hl2/weapon_rpg.h +++ b/sp/src/game/server/hl2/weapon_rpg.h @@ -196,6 +196,10 @@ public: virtual void Drop( const Vector &vecVelocity ); +#ifdef MAPBASE + bool SupportsBackupActivity(Activity activity); +#endif + int GetMinBurst() { return 1; } int GetMaxBurst() { return 1; } float GetMinRestTime() { return 4.0; } diff --git a/sp/src/game/server/hl2/weapon_smg1.cpp b/sp/src/game/server/hl2/weapon_smg1.cpp index cc9934a4..97b0e89e 100644 --- a/sp/src/game/server/hl2/weapon_smg1.cpp +++ b/sp/src/game/server/hl2/weapon_smg1.cpp @@ -22,6 +22,9 @@ #include "tier0/memdbgon.h" extern ConVar sk_plr_dmg_smg1_grenade; +#ifdef MAPBASE +extern ConVar sk_npc_dmg_smg1_grenade; +#endif class CWeaponSMG1 : public CHLSelectFireMachineGun { @@ -135,6 +138,19 @@ acttable_t CWeaponSMG1::m_acttable[] = IMPLEMENT_ACTTABLE(CWeaponSMG1); +#ifdef MAPBASE +// Allows Weapon_BackupActivity() to access the SMG1's activity table. +acttable_t *GetSMG1Acttable() +{ + return CWeaponSMG1::m_acttable; +} + +int GetSMG1ActtableCount() +{ + return ARRAYSIZE(CWeaponSMG1::m_acttable); +} +#endif + //========================================================= CWeaponSMG1::CWeaponSMG1( ) { @@ -202,6 +218,10 @@ void CWeaponSMG1::Operator_ForceNPCFire( CBaseCombatCharacter *pOperator, bool b FireNPCPrimaryAttack( pOperator, vecShootOrigin, vecShootDir ); } +#ifdef MAPBASE +float GetCurrentGravity( void ); +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -228,6 +248,56 @@ void CWeaponSMG1::Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatChar } break; +#ifdef MAPBASE + case EVENT_WEAPON_AR2_ALTFIRE: + { + WeaponSound( WPN_DOUBLE ); + + CAI_BaseNPC *npc = pOperator->MyNPCPointer(); + if (!npc) + return; + + Vector vecShootOrigin, vecShootDir; + vecShootOrigin = pOperator->Weapon_ShootPosition(); + vecShootDir = npc->GetShootEnemyDir( vecShootOrigin ); + + Vector vecTarget = npc->GetAltFireTarget(); + Vector vecThrow; + if (vecTarget == vec3_origin) + AngleVectors( npc->EyeAngles(), &vecThrow ); // Not much else to do, unfortunately + else + { + // Because this is happening right now, we can't "VecCheckThrow" and can only "VecDoThrow", you know what I mean? + // ...Anyway, this borrows from that so we'll never return vec3_origin. + //vecThrow = VecCheckThrow( this, vecShootOrigin, vecTarget, 600.0, 0.5 ); + + vecThrow = (vecTarget - vecShootOrigin); + + // throw at a constant time + float time = vecThrow.Length() / 600.0; + vecThrow = vecThrow * (1.0 / time); + + // adjust upward toss to compensate for gravity loss + vecThrow.z += (GetCurrentGravity() * 0.5) * time * 0.5; + } + + CGrenadeAR2 *pGrenade = (CGrenadeAR2*)Create( "grenade_ar2", vecShootOrigin, vec3_angle, npc ); + pGrenade->SetAbsVelocity( vecThrow ); + pGrenade->SetLocalAngularVelocity( QAngle( 0, 400, 0 ) ); + pGrenade->SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE ); + + pGrenade->SetThrower( npc ); + + pGrenade->SetGravity(0.5); // lower gravity since grenade is aerodynamic and engine doesn't know it. + + pGrenade->SetDamage(sk_npc_dmg_smg1_grenade.GetFloat()); + + variant_t var; + var.SetEntity(pGrenade); + npc->FireNamedOutput("OnThrowGrenade", var, pGrenade, npc); + } + break; +#else /*//FIXME: Re-enable case EVENT_WEAPON_AR2_GRENADE: { @@ -254,6 +324,7 @@ void CWeaponSMG1::Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatChar } break; */ +#endif default: BaseClass::Operator_HandleAnimEvent( pEvent, pOperator ); diff --git a/sp/src/game/server/hl2/weapon_stunstick.h b/sp/src/game/server/hl2/weapon_stunstick.h index 901b4721..9d3942c8 100644 --- a/sp/src/game/server/hl2/weapon_stunstick.h +++ b/sp/src/game/server/hl2/weapon_stunstick.h @@ -4,6 +4,13 @@ // //=============================================================================// +#ifdef MAPBASE + +// Redirect to HL2:DM's stunstick. +// It has NPC support now. +#include "hl2mp/weapon_stunstick.h" + +#else #ifndef WEAPON_STUNSTICK_H #define WEAPON_STUNSTICK_H #ifdef _WIN32 @@ -13,7 +20,12 @@ #include "basebludgeonweapon.h" #define STUNSTICK_RANGE 75.0f +#ifdef MAPBASE +// MP refire +#define STUNSTICK_REFIRE 0.8f +#else #define STUNSTICK_REFIRE 0.6f +#endif class CWeaponStunStick : public CBaseHLBludgeonWeapon { @@ -56,3 +68,4 @@ private: }; #endif // WEAPON_STUNSTICK_H +#endif diff --git a/sp/src/game/server/hl2mp/grenade_tripmine.cpp b/sp/src/game/server/hl2mp/grenade_tripmine.cpp index e14a929d..39918869 100644 --- a/sp/src/game/server/hl2mp/grenade_tripmine.cpp +++ b/sp/src/game/server/hl2mp/grenade_tripmine.cpp @@ -34,6 +34,18 @@ BEGIN_DATADESC( CTripmineGrenade ) DEFINE_FIELD( m_pBeam, FIELD_CLASSPTR ), DEFINE_FIELD( m_posOwner, FIELD_POSITION_VECTOR ), DEFINE_FIELD( m_angleOwner, FIELD_VECTOR ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_flPowerUpTime, FIELD_FLOAT, "PowerUpTime" ), + DEFINE_FIELD( m_hAttacker, FIELD_EHANDLE ), + + // Inputs + DEFINE_INPUTFUNC( FIELD_VOID, "Activate", InputActivate ), + DEFINE_INPUTFUNC( FIELD_VOID, "Deactivate", InputDeactivate ), + DEFINE_INPUTFUNC( FIELD_EHANDLE, "SetOwner", InputSetOwner ), + + // Outputs + DEFINE_OUTPUT( m_OnExplode, "OnExplode" ), +#endif // Function Pointers DEFINE_THINKFUNC( WarningThink ), @@ -49,6 +61,10 @@ CTripmineGrenade::CTripmineGrenade() m_vecEnd.Init(); m_posOwner.Init(); m_angleOwner.Init(); + +#ifdef MAPBASE + m_flPowerUpTime = 2.0; +#endif } void CTripmineGrenade::Spawn( void ) @@ -65,18 +81,46 @@ void CTripmineGrenade::Spawn( void ) SetCycle( 0.0f ); m_nBody = 3; +#ifdef MAPBASE + if (m_flDamage == 0) + m_flDamage = sk_plr_dmg_tripmine.GetFloat(); + if (m_DmgRadius == 0) + m_DmgRadius = sk_tripmine_radius.GetFloat(); +#else m_flDamage = sk_plr_dmg_tripmine.GetFloat(); m_DmgRadius = sk_tripmine_radius.GetFloat(); +#endif ResetSequenceInfo( ); m_flPlaybackRate = 0; UTIL_SetSize(this, Vector( -4, -4, -2), Vector(4, 4, 2)); +#ifdef MAPBASE + if (!HasSpawnFlags(SF_TRIPMINE_START_INACTIVE)) + { + if (m_flPowerUpTime > 0) + { + m_flPowerUp = gpGlobals->curtime + m_flPowerUpTime; + + SetThink( &CTripmineGrenade::PowerupThink ); + SetNextThink( gpGlobals->curtime + 0.2 ); + } + else + { + MakeBeam( ); + RemoveSolidFlags( FSOLID_NOT_SOLID ); + m_bIsLive = true; + + //EmitSound( "TripmineGrenade.Activate" ); + } + } +#else m_flPowerUp = gpGlobals->curtime + 2.0; SetThink( &CTripmineGrenade::PowerupThink ); SetNextThink( gpGlobals->curtime + 0.2 ); +#endif m_takedamage = DAMAGE_YES; @@ -222,7 +266,11 @@ void CTripmineGrenade::BeamBreakThink( void ) if (pBCC || fabs( m_flBeamLength - tr.fraction ) > 0.001) { m_iHealth = 0; +#ifdef MAPBASE + Event_Killed( CTakeDamageInfo( (CBaseEntity*)m_hOwner, pEntity, 100, GIB_NORMAL ) ); +#else Event_Killed( CTakeDamageInfo( (CBaseEntity*)m_hOwner, this, 100, GIB_NORMAL ) ); +#endif return; } @@ -254,6 +302,10 @@ void CTripmineGrenade::Event_Killed( const CTakeDamageInfo &info ) { m_takedamage = DAMAGE_NO; +#ifdef MAPBASE + m_hAttacker = info.GetAttacker(); +#endif + SetThink( &CTripmineGrenade::DelayDeathThink ); SetNextThink( gpGlobals->curtime + 0.25 ); @@ -271,6 +323,48 @@ void CTripmineGrenade::DelayDeathThink( void ) ExplosionCreate( GetAbsOrigin() + m_vecDir * 8, GetAbsAngles(), m_hOwner, GetDamage(), 200, SF_ENVEXPLOSION_NOSPARKS | SF_ENVEXPLOSION_NODLIGHTS | SF_ENVEXPLOSION_NOSMOKE, 0.0f, this); +#ifdef MAPBASE + m_OnExplode.FireOutput(m_hAttacker.Get(), this); +#endif + UTIL_Remove( this ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +// Input : +// Output : +//----------------------------------------------------------------------------- +void CTripmineGrenade::InputActivate( inputdata_t &inputdata ) +{ + if (m_flPowerUpTime > 0) + { + m_flPowerUp = gpGlobals->curtime + m_flPowerUpTime; + + SetThink( &CTripmineGrenade::PowerupThink ); + SetNextThink( gpGlobals->curtime + 0.2 ); + } + else + { + MakeBeam( ); + RemoveSolidFlags( FSOLID_NOT_SOLID ); + m_bIsLive = true; + + //EmitSound( "TripmineGrenade.Activate" ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : +// Output : +//----------------------------------------------------------------------------- +void CTripmineGrenade::InputDeactivate( inputdata_t &inputdata ) +{ + KillBeam( ); + //AddSolidFlags( FSOLID_NOT_SOLID ); + m_bIsLive = false; +} +#endif + diff --git a/sp/src/game/server/hl2mp/grenade_tripmine.h b/sp/src/game/server/hl2mp/grenade_tripmine.h index e1887096..9ec9e726 100644 --- a/sp/src/game/server/hl2mp/grenade_tripmine.h +++ b/sp/src/game/server/hl2mp/grenade_tripmine.h @@ -15,6 +15,9 @@ class CBeam; +#ifdef MAPBASE +#define SF_TRIPMINE_START_INACTIVE (1 << 0) +#endif class CTripmineGrenade : public CBaseGrenade { @@ -37,9 +40,24 @@ public: void MakeBeam( void ); void KillBeam( void ); +#ifdef MAPBASE + void PowerUp(); + + void InputActivate( inputdata_t &inputdata ); + void InputDeactivate( inputdata_t &inputdata ); + void InputSetOwner( inputdata_t &inputdata ) { m_hOwner = inputdata.value.Entity(); } + + COutputEvent m_OnExplode; +#endif + public: EHANDLE m_hOwner; +#ifdef MAPBASE + float m_flPowerUpTime; + EHANDLE m_hAttacker; +#endif + private: float m_flPowerUp; Vector m_vecDir; diff --git a/sp/src/game/server/item_world.cpp b/sp/src/game/server/item_world.cpp index e4233172..1cad6c3b 100644 --- a/sp/src/game/server/item_world.cpp +++ b/sp/src/game/server/item_world.cpp @@ -103,6 +103,14 @@ BEGIN_DATADESC( CItem ) DEFINE_THINKFUNC( FallThink ), #endif +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "EnablePlayerPickup", InputEnablePlayerPickup ), + DEFINE_INPUTFUNC( FIELD_VOID, "DisablePlayerPickup", InputDisablePlayerPickup ), + DEFINE_INPUTFUNC( FIELD_VOID, "EnableNPCPickup", InputEnableNPCPickup ), + DEFINE_INPUTFUNC( FIELD_VOID, "DisableNPCPickup", InputDisableNPCPickup ), + DEFINE_INPUTFUNC( FIELD_VOID, "BreakConstraint", InputBreakConstraint ), +#endif + // Outputs DEFINE_OUTPUT( m_OnPlayerTouch, "OnPlayerTouch" ), DEFINE_OUTPUT( m_OnCacheInteraction, "OnCacheInteraction" ), @@ -344,6 +352,14 @@ bool UTIL_ItemCanBeTouchedByPlayer( CBaseEntity *pItem, CBasePlayer *pPlayer ) if ( pItem == NULL || pPlayer == NULL ) return false; +#ifdef MAPBASE + // Weapons go through this, but this is identical to SF_WEAPON_NO_PLAYER_PICKUP and that would be a convenient coincidence, + // but OnCacheInteraction worked with "No player pickup" before and SF_WEAPON_NO_PLAYER_PICKUP is often checked after this, + // so we have to make sure we're not dealing with a weapon for this check after all. + if (pItem->HasSpawnFlags(SF_ITEM_NO_PLAYER_PICKUP) && !pItem->IsBaseCombatWeapon()) + return false; +#endif + // For now, always allow a vehicle riding player to pick up things they're driving over if ( pPlayer->IsInAVehicle() ) return true; @@ -545,3 +561,49 @@ void CItem::OnPhysGunDrop( CBasePlayer *pPhysGunUser, PhysGunDrop_t reason ) // Restore the pickup box to the original CollisionProp()->UseTriggerBounds( true, ITEM_PICKUP_BOX_BLOAT ); } + +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CItem::InputEnablePlayerPickup( inputdata_t &inputdata ) +{ + RemoveSpawnFlags(SF_ITEM_NO_PLAYER_PICKUP); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CItem::InputDisablePlayerPickup( inputdata_t &inputdata ) +{ + AddSpawnFlags(SF_ITEM_NO_PLAYER_PICKUP); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CItem::InputEnableNPCPickup( inputdata_t &inputdata ) +{ + RemoveSpawnFlags(SF_ITEM_NO_NPC_PICKUP); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CItem::InputDisableNPCPickup( inputdata_t &inputdata ) +{ + AddSpawnFlags(SF_ITEM_NO_NPC_PICKUP); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CItem::InputBreakConstraint( inputdata_t &inputdata ) +{ + if ( m_pConstraint != NULL ) + { + physenv->DestroyConstraint( m_pConstraint ); + m_pConstraint = NULL; + } +} +#endif diff --git a/sp/src/game/server/items.h b/sp/src/game/server/items.h index 5e7672c6..39295cef 100644 --- a/sp/src/game/server/items.h +++ b/sp/src/game/server/items.h @@ -36,6 +36,13 @@ #define SIZE_AMMO_AR2_ALTFIRE 1 #define SF_ITEM_START_CONSTRAINED 0x00000001 +#ifdef MAPBASE +// Copied from CBaseCombatWeapon's flags, including any additions we made to those. +// I really, REALLY hope no item uses their own spawnflags either. +#define SF_ITEM_NO_PLAYER_PICKUP (1<<1) +#define SF_ITEM_NO_PHYSCANNON_PUNT (1<<2) +#define SF_ITEM_NO_NPC_PICKUP (1<<3) +#endif class CItem : public CBaseAnimating, public CDefaultPlayerPickupVPhysics @@ -79,6 +86,18 @@ public: float m_flNextResetCheckTime; #endif +#ifdef MAPBASE + // This is in CBaseEntity, but I can't find a use for it anywhere. + // Must not have been fully implemented. Please remove this if it turns out to be something important. + virtual bool IsCombatItem() { return true; } + + void InputEnablePlayerPickup( inputdata_t &inputdata ); + void InputDisablePlayerPickup( inputdata_t &inputdata ); + void InputEnableNPCPickup( inputdata_t &inputdata ); + void InputDisableNPCPickup( inputdata_t &inputdata ); + void InputBreakConstraint( inputdata_t &inputdata ); +#endif + DECLARE_DATADESC(); protected: virtual void ComeToRest( void ); diff --git a/sp/src/game/server/lightglow.cpp b/sp/src/game/server/lightglow.cpp index 59d0505d..d941f033 100644 --- a/sp/src/game/server/lightglow.cpp +++ b/sp/src/game/server/lightglow.cpp @@ -33,6 +33,10 @@ public: virtual int UpdateTransmitState( void ); void InputColor(inputdata_t &data); +#ifdef MAPBASE + void InputEnable( inputdata_t &data ) { m_bDisabled = false; } + void InputDisable( inputdata_t &data ) { m_bDisabled = true; } +#endif public: CNetworkVar( int, m_nHorizontalSize ); @@ -43,6 +47,10 @@ public: CNetworkVar( float, m_flGlowProxySize ); CNetworkVar( float, m_flHDRColorScale ); + +#ifdef MAPBASE + CNetworkVar( bool, m_bDisabled ); +#endif }; extern void SendProxy_Angles( const SendProp *pProp, const void *pStruct, const void *pData, DVariant *pOut, int iElement, int objectID ); @@ -60,6 +68,9 @@ IMPLEMENT_SERVERCLASS_ST_NOBASE( CLightGlow, DT_LightGlow ) SendPropEHandle (SENDINFO_NAME(m_hMoveParent, moveparent)), SendPropFloat( SENDINFO(m_flGlowProxySize ), 6, SPROP_ROUNDUP, 0.0f, 64.0f ), SendPropFloat( SENDINFO_NAME( m_flHDRColorScale, HDRColorScale ), 0, SPROP_NOSCALE, 0.0f, 100.0f ), +#ifdef MAPBASE + SendPropBool( SENDINFO( m_bDisabled ) ), +#endif END_SEND_TABLE() LINK_ENTITY_TO_CLASS( env_lightglow, CLightGlow ); @@ -73,6 +84,11 @@ BEGIN_DATADESC( CLightGlow ) DEFINE_KEYFIELD( m_nOuterMaxDist, FIELD_INTEGER, "OuterMaxDist" ), DEFINE_KEYFIELD( m_flGlowProxySize, FIELD_FLOAT, "GlowProxySize" ), DEFINE_KEYFIELD( m_flHDRColorScale, FIELD_FLOAT, "HDRColorScale" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bDisabled, FIELD_BOOLEAN, "StartDisabled" ), + DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), + DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), +#endif DEFINE_INPUTFUNC( FIELD_COLOR32, "Color", InputColor ), END_DATADESC() diff --git a/sp/src/game/server/logic_measure_movement.cpp b/sp/src/game/server/logic_measure_movement.cpp index bf074bd0..17d19843 100644 --- a/sp/src/game/server/logic_measure_movement.cpp +++ b/sp/src/game/server/logic_measure_movement.cpp @@ -7,10 +7,28 @@ #include "cbase.h" #include "baseentity.h" +#ifdef MAPBASE +#include "filters.h" +#include "ai_basenpc.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" +#ifdef MAPBASE +// These spawnflags were originally only on logic_measure_direction. +#define SF_LOGIC_MEASURE_MOVEMENT_IGNORE_X ( 1 << 0 ) +#define SF_LOGIC_MEASURE_MOVEMENT_IGNORE_Y ( 1 << 1 ) +#define SF_LOGIC_MEASURE_MOVEMENT_IGNORE_Z ( 1 << 2 ) + +// Uses the "Ignore X/Y/Z" flags for the origin instead of the angles. +// logic_measure_direction uses this flag to control trace direction. +#define SF_LOGIC_MEASURE_MOVEMENT_USE_IGNORE_FLAGS_FOR_ORIGIN ( 1 << 3 ) + +// Uses "Teleport" instead of "SetAbsOrigin" for smoother movement +#define SF_LOGIC_MEASURE_MOVEMENT_TELEPORT ( 1 << 4 ) +#endif + //----------------------------------------------------------------------------- // This will measure the movement of a target entity and move // another entity to match the movement of the first. @@ -23,7 +41,11 @@ class CLogicMeasureMovement : public CLogicalEntity public: virtual void Activate(); +#ifdef MAPBASE +public: +#else private: +#endif void SetMeasureTarget( const char *pName ); void SetMeasureReference( const char *pName ); void SetTarget( const char *pName ); @@ -37,13 +59,30 @@ private: void InputEnable( inputdata_t &inputdata ); void InputDisable( inputdata_t &inputdata ); +#ifdef MAPBASE + // Allows for derived class trickery + void MeasureThink(); //{ DoMeasure(); } + + // Allows for InputGetPosition(), etc. + virtual void DoMeasure(Vector &vecOrigin, QAngle &angAngles); + void HandleIgnoreFlags( float *vec ); + + void InputSetMeasureAttachment( inputdata_t &inputdata ); + void InputSetMeasureType( inputdata_t &inputdata ) { m_nMeasureType = inputdata.value.Int(); } + void InputGetPosition( inputdata_t &inputdata ); +#else void MeasureThink(); private: +#endif enum { MEASURE_POSITION = 0, MEASURE_EYE_POSITION, +#ifdef MAPBASE + MEASURE_ATTACHMENT, + //MEASURE_BARREL_POSITION, +#endif }; string_t m_strMeasureTarget; @@ -55,6 +94,16 @@ private: EHANDLE m_hTarget; EHANDLE m_hTargetReference; +#ifdef MAPBASE + string_t m_strAttachment; + int m_iAttachment; + + bool m_bOutputPosition; + + COutputVector m_OutPosition; + COutputVector m_OutAngles; +#endif + float m_flScale; int m_nMeasureType; }; @@ -70,6 +119,17 @@ BEGIN_DATADESC( CLogicMeasureMovement ) DEFINE_KEYFIELD( m_strTargetReference, FIELD_STRING, "TargetReference" ), DEFINE_KEYFIELD( m_flScale, FIELD_FLOAT, "TargetScale" ), DEFINE_KEYFIELD( m_nMeasureType, FIELD_INTEGER, "MeasureType" ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetMeasureType", InputSetMeasureType ), + + DEFINE_KEYFIELD( m_strAttachment, FIELD_STRING, "MeasureAttachment" ), + DEFINE_FIELD( m_iAttachment, FIELD_EHANDLE ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetMeasureAttachment", InputSetMeasureAttachment ), + + DEFINE_INPUT( m_bOutputPosition, FIELD_BOOLEAN, "ShouldOutputPosition" ), + + DEFINE_INPUTFUNC( FIELD_VOID, "GetPosition", InputGetPosition ), +#endif DEFINE_FIELD( m_hMeasureTarget, FIELD_EHANDLE ), DEFINE_FIELD( m_hMeasureReference, FIELD_EHANDLE ), @@ -79,12 +139,20 @@ BEGIN_DATADESC( CLogicMeasureMovement ) DEFINE_INPUTFUNC( FIELD_STRING, "SetMeasureTarget", InputSetMeasureTarget ), DEFINE_INPUTFUNC( FIELD_STRING, "SetMeasureReference", InputSetMeasureReference ), DEFINE_INPUTFUNC( FIELD_STRING, "SetTarget", InputSetTarget ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_STRING, "Target", InputSetTarget ), // For legacy support...even though that name was broken before. +#endif DEFINE_INPUTFUNC( FIELD_STRING, "SetTargetReference", InputSetTargetReference ), DEFINE_INPUTFUNC( FIELD_FLOAT, "SetTargetScale", InputSetTargetScale ), DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OutPosition, "OutPosition" ), + DEFINE_OUTPUT( m_OutAngles, "OutAngles" ), +#endif + DEFINE_THINKFUNC( MeasureThink ), END_DATADESC() @@ -112,40 +180,75 @@ void CLogicMeasureMovement::Activate() //----------------------------------------------------------------------------- void CLogicMeasureMovement::SetMeasureTarget( const char *pName ) { +#ifdef MAPBASE + m_hMeasureTarget = gEntList.FindEntityByName( NULL, pName, this ); +#else m_hMeasureTarget = gEntList.FindEntityByName( NULL, pName ); +#endif if ( !m_hMeasureTarget ) { if ( Q_strnicmp( STRING(m_strMeasureTarget), "!player", 8 ) ) { +#ifdef MAPBASE + Warning( "%s: Unable to find measure target entity %s\n", GetDebugName(), pName ); +#else Warning("logic_measure_movement: Unable to find measure target entity %s\n", pName ); +#endif } } +#ifdef MAPBASE + m_iAttachment = 0; +#endif } void CLogicMeasureMovement::SetMeasureReference( const char *pName ) { +#ifdef MAPBASE + m_hMeasureReference = gEntList.FindEntityByName( NULL, pName, this ); +#else m_hMeasureReference = gEntList.FindEntityByName( NULL, pName ); +#endif if ( !m_hMeasureReference ) { +#ifdef MAPBASE + Warning( "%s: Unable to find measure reference entity %s\n", GetDebugName(), pName ); +#else Warning("logic_measure_movement: Unable to find measure reference entity %s\n", pName ); +#endif } } void CLogicMeasureMovement::SetTarget( const char *pName ) { +#ifdef MAPBASE + m_hTarget = gEntList.FindEntityByName( NULL, pName, this ); +#else m_hTarget = gEntList.FindEntityByName( NULL, pName ); +#endif if ( !m_hTarget ) { +#ifdef MAPBASE + Warning( "%s: Unable to find movement target entity %s\n", GetDebugName(), pName ); +#else Warning("logic_measure_movement: Unable to find movement target entity %s\n", pName ); +#endif } } void CLogicMeasureMovement::SetTargetReference( const char *pName ) { +#ifdef MAPBASE + m_hTargetReference = gEntList.FindEntityByName( NULL, pName, this ); +#else m_hTargetReference = gEntList.FindEntityByName( NULL, pName ); +#endif if ( !m_hTargetReference ) { +#ifdef MAPBASE + Warning( "%s: Unable to find movement reference entity %s\n", GetDebugName(), pName ); +#else Warning("logic_measure_movement: Unable to find movement reference entity %s\n", pName ); +#endif } } @@ -165,6 +268,27 @@ void CLogicMeasureMovement::MeasureThink( ) // Make sure all entities are valid if ( m_hMeasureTarget.Get() && m_hMeasureReference.Get() && m_hTarget.Get() && m_hTargetReference.Get() ) { +#ifdef MAPBASE + Vector vecNewOrigin; + QAngle vecNewAngles; + DoMeasure(vecNewOrigin, vecNewAngles); + + if (m_bOutputPosition) + { + m_OutPosition.Set(vecNewOrigin, m_hTarget.Get(), this); + m_OutAngles.Set(Vector(vecNewAngles.x, vecNewAngles.y, vecNewAngles.z), m_hTarget.Get(), this); + } + + if (HasSpawnFlags( SF_LOGIC_MEASURE_MOVEMENT_TELEPORT )) + { + m_hTarget->Teleport( &vecNewOrigin, &vecNewAngles, NULL ); + } + else + { + m_hTarget->SetAbsOrigin( vecNewOrigin ); + m_hTarget->SetAbsAngles( vecNewAngles ); + } +#else matrix3x4_t matRefToMeasure, matWorldToMeasure; switch( m_nMeasureType ) { @@ -175,7 +299,6 @@ void CLogicMeasureMovement::MeasureThink( ) case MEASURE_EYE_POSITION: AngleIMatrix( m_hMeasureTarget->EyeAngles(), m_hMeasureTarget->EyePosition(), matWorldToMeasure ); break; - // FIXME: Could add attachment point measurement here easily } @@ -201,11 +324,110 @@ void CLogicMeasureMovement::MeasureThink( ) MatrixAngles( matNewTargetToWorld, vecNewAngles, vecNewOrigin ); m_hTarget->SetAbsOrigin( vecNewOrigin ); m_hTarget->SetAbsAngles( vecNewAngles ); +#endif } SetNextThink( gpGlobals->curtime + TICK_INTERVAL ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Moves logic_measure_movement's movement measurements to its own function, +// primarily to allow for the GetPosition input without any hacks. +// Also helps with derivative entities that would otherwise have to find a way to re-define the think function. +// Warning: Doesn't account for whether these handles are null! +//----------------------------------------------------------------------------- +void CLogicMeasureMovement::DoMeasure( Vector &vecOrigin, QAngle &angAngles ) +{ + matrix3x4_t matRefToMeasure, matWorldToMeasure; + switch( m_nMeasureType ) + { + case MEASURE_POSITION: + MatrixInvert( m_hMeasureTarget->EntityToWorldTransform(), matWorldToMeasure ); + break; + + case MEASURE_EYE_POSITION: + AngleIMatrix( m_hMeasureTarget->EyeAngles(), m_hMeasureTarget->EyePosition(), matWorldToMeasure ); + break; + + case MEASURE_ATTACHMENT: + if (CBaseAnimating *pAnimating = m_hMeasureTarget->GetBaseAnimating()) + { + if (m_iAttachment <= 0) + m_iAttachment = m_hMeasureTarget->GetBaseAnimating()->LookupAttachment(STRING(m_strAttachment)); + + if (m_iAttachment == -1) + Warning("WARNING: %s requesting invalid attachment %s on %s!\n", GetDebugName(), STRING(m_strAttachment), m_hMeasureTarget->GetDebugName()); + else + pAnimating->GetAttachment(m_iAttachment, matWorldToMeasure); + } + else + { + Warning("WARNING: %s requesting attachment point on non-animating entity %s!\n", GetDebugName(), m_hMeasureTarget->GetDebugName()); + } + break; + } + + ConcatTransforms( matWorldToMeasure, m_hMeasureReference->EntityToWorldTransform(), matRefToMeasure ); + + // If we have spawn flags, we might be supposed to ignore something + if (GetSpawnFlags() > 0) + { + if (HasSpawnFlags( SF_LOGIC_MEASURE_MOVEMENT_USE_IGNORE_FLAGS_FOR_ORIGIN )) + { + // Get the position from the matrix's column directly and re-assign it + Vector vecPosition; + MatrixGetColumn( matRefToMeasure, 3, vecPosition ); + + HandleIgnoreFlags( vecPosition.Base() ); + + MatrixSetColumn( vecPosition, 3, matRefToMeasure ); + } + else + { + // Get the angles from the matrix and re-assign it + QAngle angMod; + MatrixAngles( matWorldToMeasure, angMod ); + + HandleIgnoreFlags( angMod.Base() ); + + AngleMatrix( angMod, matWorldToMeasure ); + } + } + + // Apply the scale factor + if ( ( m_flScale != 0.0f ) && ( m_flScale != 1.0f ) ) + { + Vector vecTranslation; + MatrixGetColumn( matRefToMeasure, 3, vecTranslation ); + vecTranslation /= m_flScale; + MatrixSetColumn( vecTranslation, 3, matRefToMeasure ); + } + + // Now apply the new matrix to the new reference point + matrix3x4_t matMeasureToRef, matNewTargetToWorld; + MatrixInvert( matRefToMeasure, matMeasureToRef ); + + ConcatTransforms( m_hTargetReference->EntityToWorldTransform(), matMeasureToRef, matNewTargetToWorld ); + + MatrixAngles( matNewTargetToWorld, angAngles, vecOrigin ); +} + + +//----------------------------------------------------------------------------- +// Purpose: Handles logic_measure_movement's ignore flags on the specified Vector/QAngle +//----------------------------------------------------------------------------- +FORCEINLINE void CLogicMeasureMovement::HandleIgnoreFlags( float *vec ) +{ + if (HasSpawnFlags( SF_LOGIC_MEASURE_MOVEMENT_IGNORE_X )) + vec[0] = 0.0f; + if (HasSpawnFlags( SF_LOGIC_MEASURE_MOVEMENT_IGNORE_Y )) + vec[1] = 0.0f; + if (HasSpawnFlags( SF_LOGIC_MEASURE_MOVEMENT_IGNORE_Z )) + vec[2] = 0.0f; +} +#endif + //----------------------------------------------------------------------------- // Enable, disable @@ -225,6 +447,84 @@ void CLogicMeasureMovement::InputDisable( inputdata_t &inputdata ) //----------------------------------------------------------------------------- // Methods to change various targets //----------------------------------------------------------------------------- +#ifdef MAPBASE + +// +// Inputs work differently now so they could take !activator, etc. +// + +void CLogicMeasureMovement::InputSetMeasureTarget( inputdata_t &inputdata ) +{ + m_strMeasureTarget = inputdata.value.StringID(); + m_hMeasureTarget = gEntList.FindEntityByName( NULL, STRING(m_strMeasureTarget), this, inputdata.pActivator, inputdata.pCaller ); + if ( !m_hMeasureTarget ) + { + if ( Q_strnicmp( STRING(m_strMeasureTarget), "!player", 8 ) ) + { + Warning( "%s: Unable to find measure target entity %s\n", GetDebugName(), STRING(m_strMeasureTarget) ); + } + } + + m_iAttachment = 0; + + if (!m_hTarget) + SetTarget( STRING(m_target) ); + if (!m_hTargetReference) + SetTargetReference( STRING(m_strTargetReference) ); +} + +void CLogicMeasureMovement::InputSetMeasureReference( inputdata_t &inputdata ) +{ + m_strMeasureReference = inputdata.value.StringID(); + m_hMeasureReference = gEntList.FindEntityByName( NULL, STRING(m_strMeasureReference), this, inputdata.pActivator, inputdata.pCaller ); + if ( !m_hMeasureReference ) + { + Warning( "%s: Unable to find measure reference entity %s\n", GetDebugName(), STRING(m_strMeasureReference) ); + } +} + +void CLogicMeasureMovement::InputSetTarget( inputdata_t &inputdata ) +{ + m_target = inputdata.value.StringID(); + m_hTarget = gEntList.FindEntityByName( NULL, STRING(m_target), this, inputdata.pActivator, inputdata.pCaller ); + if ( !m_hTarget ) + { + Warning( "%s: Unable to find movement target entity %s\n", GetDebugName(), STRING(m_target) ); + } +} + +void CLogicMeasureMovement::InputSetTargetReference( inputdata_t &inputdata ) +{ + m_strTargetReference = inputdata.value.StringID(); + m_hTargetReference = gEntList.FindEntityByName( NULL, STRING(m_strTargetReference), this, inputdata.pActivator, inputdata.pCaller ); + if ( !m_hTargetReference ) + { + Warning( "%s: Unable to find movement reference entity %s\n", GetDebugName(), STRING(m_strTargetReference) ); + } +} + +void CLogicMeasureMovement::InputSetMeasureAttachment( inputdata_t &inputdata ) +{ + m_strAttachment = inputdata.value.StringID(); + m_iAttachment = 0; +} + +// Just gets the position once and fires outputs without moving anything. +// We don't even need a target for this. +void CLogicMeasureMovement::InputGetPosition( inputdata_t &inputdata ) +{ + if ( !m_hMeasureTarget.Get() || !m_hMeasureReference.Get() || !m_hTargetReference.Get() ) + return; + + Vector vecNewOrigin; + QAngle vecNewAngles; + DoMeasure(vecNewOrigin, vecNewAngles); + + // m_bOutputPosition has been repurposed here to toggle between using the target or the input activator as the activator. + m_OutPosition.Set(vecNewOrigin, m_bOutputPosition ? m_hTarget.Get() : inputdata.pActivator, this); + m_OutAngles.Set(Vector(vecNewAngles.x, vecNewAngles.y, vecNewAngles.z), m_bOutputPosition ? m_hTarget.Get() : inputdata.pActivator, this); +} +#else void CLogicMeasureMovement::InputSetMeasureTarget( inputdata_t &inputdata ) { m_strMeasureTarget = MAKE_STRING( inputdata.value.String() ); @@ -250,8 +550,275 @@ void CLogicMeasureMovement::InputSetTargetReference( inputdata_t &inputdata ) m_strTargetReference = MAKE_STRING( inputdata.value.String() ); SetTargetReference( inputdata.value.String() ); } +#endif void CLogicMeasureMovement::InputSetTargetScale( inputdata_t &inputdata ) { m_flScale = inputdata.value.Float(); } + +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// This will measure the direction of a target entity and move +// another entity to where the target entity is facing. +// +// m_hMeasureTarget; // Whose direction is measured +// m_hMeasureReference; // Position where direction is measured +// m_hTarget; // Target whose origin is applied +// m_hTargetReference; // From where the target's origin is applied +//----------------------------------------------------------------------------- +class CLogicMeasureDirection : public CLogicMeasureMovement +{ + DECLARE_DATADESC(); + DECLARE_CLASS( CLogicMeasureDirection, CLogicMeasureMovement ); + +public: + + virtual void DoMeasure(Vector &vecOrigin, QAngle &angAngles); + + CBaseFilter *GetTraceFilter(); + //void InputSetTraceFilter( inputdata_t &inputdata ) { InputSetDamageFilter(inputdata); } + +private: + + float m_flTraceDistance; + int m_iMask; + int m_iCollisionGroup; + bool m_bHitIfPassed; + //string_t m_iszTraceFilter; + //CHandle m_hTraceFilter; + + bool m_bTraceTargetReference; + +}; + + +LINK_ENTITY_TO_CLASS( logic_measure_direction, CLogicMeasureDirection ); + + +BEGIN_DATADESC( CLogicMeasureDirection ) + + DEFINE_KEYFIELD( m_flTraceDistance, FIELD_FLOAT, "TraceDistance" ), + DEFINE_KEYFIELD( m_iMask, FIELD_INTEGER, "Mask" ), + DEFINE_KEYFIELD( m_iCollisionGroup, FIELD_INTEGER, "CollisionGroup" ), + DEFINE_KEYFIELD( m_bHitIfPassed, FIELD_BOOLEAN, "HitIfPassed" ), + DEFINE_KEYFIELD( m_bTraceTargetReference, FIELD_BOOLEAN, "TraceTargetReference" ), + + DEFINE_INPUTFUNC( FIELD_STRING, "SetTraceFilter", InputSetDamageFilter ), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: Gets our "trace filter". +//----------------------------------------------------------------------------- +inline CBaseFilter *CLogicMeasureDirection::GetTraceFilter() +{ + return static_cast(m_hDamageFilter.Get()); // pranked +} + +//----------------------------------------------------------------------------- +// Purpose: Does measure. +//----------------------------------------------------------------------------- +void CLogicMeasureDirection::DoMeasure( Vector &vecOrigin, QAngle &angAngles ) +{ + trace_t tr; + Vector vecStart, vecDir; + QAngle angStart; + switch( m_nMeasureType ) + { + case MEASURE_POSITION: + vecStart = m_hMeasureReference->GetAbsOrigin(); + angStart = m_hMeasureTarget->GetAbsAngles(); + break; + + case MEASURE_EYE_POSITION: + vecStart = m_hMeasureReference->EyePosition(); + angStart = m_hMeasureTarget->EyeAngles(); + break; + + case MEASURE_ATTACHMENT: + CBaseAnimating *pAnimating = m_hMeasureTarget->GetBaseAnimating(); + if (pAnimating) + { + if (m_iAttachment <= 0) + m_iAttachment = m_hMeasureTarget->GetBaseAnimating()->LookupAttachment(STRING(m_strAttachment)); + + if (m_iAttachment == -1) + Warning("WARNING: %s requesting invalid attachment %s on %s!\n", GetDebugName(), STRING(m_strAttachment), m_hMeasureTarget->GetDebugName()); + else + { + pAnimating->GetAttachment(m_iAttachment, vecStart, angStart); + } + } + else + { + Warning("WARNING: %s requesting attachment point on non-animating entity %s!\n", GetDebugName(), m_hMeasureTarget->GetDebugName()); + } + break; + } + + // If we have spawn flags, we might be supposed to ignore something + if (GetSpawnFlags() > 0) + { + if (!HasSpawnFlags(SF_LOGIC_MEASURE_MOVEMENT_USE_IGNORE_FLAGS_FOR_ORIGIN)) + AngleVectors(angStart, &vecDir); + + HandleIgnoreFlags( angStart.Base() ); + + if (HasSpawnFlags(SF_LOGIC_MEASURE_MOVEMENT_USE_IGNORE_FLAGS_FOR_ORIGIN)) + AngleVectors(angStart, &vecDir); + } + else + { + AngleVectors(angStart, &vecDir); + } + + CTraceFilterEntityFilter traceFilter(m_hMeasureReference, m_iCollisionGroup); + traceFilter.m_pFilter = GetTraceFilter(); + traceFilter.m_bHitIfPassed = m_bHitIfPassed; + UTIL_TraceLine( vecStart, vecStart + vecDir * (m_flTraceDistance != 0 ? m_flTraceDistance : MAX_TRACE_LENGTH), m_iMask, &traceFilter, &tr ); //MASK_BLOCKLOS_AND_NPCS + + Vector vecEnd = tr.endpos; + + // Apply the scale factor + float flScale = m_flScale; + if ( ( flScale != 0.0f ) && ( flScale != 1.0f ) ) + { + vecEnd = (vecStart + ((vecEnd - vecStart) / flScale)); + } + + Vector refPos = m_hTargetReference->GetAbsOrigin(); + Vector vecPos = refPos + (vecEnd - vecStart); + + if (m_bTraceTargetReference) + { + // Make sure we can go the whole distance there + UTIL_TraceLine( refPos, vecPos, m_iMask, &traceFilter, &tr ); + vecPos = tr.endpos; + } + + vecOrigin = vecPos; + angAngles = angStart; +} + + + +//----------------------------------------------------------------------------- +// The unused, "forgotten" entity brought back to life. +// Mirrors an entity's movement across a reference. +// It derives from logic_measure_movement now so it could use its features. +// This is unfinished and I'm still figuring out how it works. +// +// m_hMeasureTarget; // Whose position is mirrored (m_hRemoteTarget) +// m_hMeasureReference; // Position where position is mirrored (m_hMirrorRelative) +// m_hTarget; // Target whose origin is mirrored (m_hMovementTarget) +// m_hTargetReference; // From where the target's origin is mirrored (m_hMirrorTarget) +//----------------------------------------------------------------------------- +class CLogicMirrorMovement : public CLogicMeasureMovement +{ + DECLARE_DATADESC(); + DECLARE_CLASS( CLogicMirrorMovement, CLogicMeasureMovement ); + +public: + virtual void DoMeasure(Vector &vecOrigin, QAngle &angAngles); +}; + + +LINK_ENTITY_TO_CLASS( logic_mirror_movement, CLogicMirrorMovement ); + +BEGIN_DATADESC( CLogicMirrorMovement ) +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: Does measure. +//----------------------------------------------------------------------------- +void CLogicMirrorMovement::DoMeasure( Vector &vecOrigin, QAngle &angAngles ) +{ + VMatrix matPortal1ToWorldInv, matPortal2ToWorld; + MatrixInverseGeneral( m_hMeasureReference->EntityToWorldTransform(), matPortal1ToWorldInv ); + switch( m_nMeasureType ) + { + case MEASURE_POSITION: + matPortal2ToWorld = m_hMeasureTarget->EntityToWorldTransform(); + break; + + case MEASURE_EYE_POSITION: + matPortal2ToWorld.SetupMatrixOrgAngles( m_hMeasureTarget->EyePosition(), m_hMeasureTarget->EyeAngles() ); + break; + + case MEASURE_ATTACHMENT: + CBaseAnimating *pAnimating = m_hMeasureTarget->GetBaseAnimating(); + if (pAnimating) + { + if (m_iAttachment <= 0) + m_iAttachment = m_hMeasureTarget->GetBaseAnimating()->LookupAttachment(STRING(m_strAttachment)); + + if (m_iAttachment == -1) + Warning("WARNING: %s requesting invalid attachment %s on %s!\n", GetDebugName(), STRING(m_strAttachment), m_hMeasureTarget->GetDebugName()); + else + { + pAnimating->GetAttachment( m_iAttachment, matPortal2ToWorld.As3x4() ); + } + } + else + { + Warning("WARNING: %s requesting attachment point on non-animating entity %s!\n", GetDebugName(), m_hMeasureTarget->GetDebugName()); + } + break; + } + + // If we have spawn flags, we might be supposed to ignore something + if (GetSpawnFlags() > 0) + { + if (HasSpawnFlags( SF_LOGIC_MEASURE_MOVEMENT_USE_IGNORE_FLAGS_FOR_ORIGIN )) + { + // Get the position from the matrix's column directly and re-assign it + Vector vecPosition; + MatrixGetColumn( matPortal2ToWorld, 3, &vecPosition ); + + HandleIgnoreFlags( vecPosition.Base() ); + + MatrixSetColumn( matPortal2ToWorld, 3, vecPosition ); + } + else + { + // Get the angles from the matrix and re-assign it + QAngle angAngles; + MatrixToAngles( matPortal2ToWorld, angAngles ); + + HandleIgnoreFlags( angAngles.Base() ); + + matPortal2ToWorld.SetupMatrixAngles( angAngles ); + } + } + + // Apply the scale factor + if ( ( m_flScale != 0.0f ) && ( m_flScale != 1.0f ) ) + { + Vector vecTranslation; + MatrixGetColumn( matPortal2ToWorld.As3x4(), 3, vecTranslation ); + vecTranslation /= m_flScale; + MatrixSetColumn( vecTranslation, 3, matPortal2ToWorld.As3x4() ); + } + + // Get our scene camera's current orientation + Vector ptCameraPosition, vCameraLook, vCameraRight, vCameraUp; + ptCameraPosition = m_hTargetReference->EyePosition(); + m_hTargetReference->GetVectors( &vCameraLook, &vCameraRight, &vCameraUp ); + + // map this position and orientation to the remote portal, mirrored (invert the result) + Vector ptNewPosition, vNewLook; + ptNewPosition = matPortal1ToWorldInv * ptCameraPosition; + ptNewPosition = matPortal2ToWorld*(Vector( -ptNewPosition.x, -ptNewPosition.y, ptNewPosition.z )); + + vNewLook = matPortal1ToWorldInv.ApplyRotation( vCameraLook ); + vNewLook = matPortal2ToWorld.ApplyRotation( Vector( -vNewLook.x, -vNewLook.y, vNewLook.z ) ); + + // Set the point camera to the new location/orientation + QAngle qNewAngles; + VectorAngles( vNewLook, qNewAngles ); + + vecOrigin = ptNewPosition; + angAngles = qNewAngles; +} +#endif diff --git a/sp/src/game/server/logic_random_outputs.cpp b/sp/src/game/server/logic_random_outputs.cpp new file mode 100644 index 00000000..b5c9f64b --- /dev/null +++ b/sp/src/game/server/logic_random_outputs.cpp @@ -0,0 +1,221 @@ +//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ==== +// +// When triggered, will attempt to fire off each of its outputs. Each output +// has its own chance of firing. +// +//============================================================================= + +#include "cbase.h" +#include "entityinput.h" +#include "entityoutput.h" +#include "eventqueue.h" +#include "soundent.h" +#include "logic_random_outputs.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +const int SF_REMOVE_ON_FIRE = 0x001; // Relay will remove itself after being triggered. +const int SF_ALLOW_FAST_RETRIGGER = 0x002; // Unless set, entity will disable itself until the last output is sent. + +LINK_ENTITY_TO_CLASS(logic_random_outputs, CLogicRandomOutputs); + + +BEGIN_DATADESC( CLogicRandomOutputs ) + + DEFINE_FIELD(m_bWaitForRefire, FIELD_BOOLEAN), + DEFINE_KEYFIELD(m_bDisabled, FIELD_BOOLEAN, "StartDisabled"), + + DEFINE_AUTO_ARRAY( m_flOnTriggerChance, FIELD_FLOAT ), + + // Inputs + DEFINE_INPUTFUNC(FIELD_VOID, "Enable", InputEnable), + DEFINE_INPUTFUNC(FIELD_VOID, "EnableRefire", InputEnableRefire), + DEFINE_INPUTFUNC(FIELD_VOID, "Disable", InputDisable), + DEFINE_INPUTFUNC(FIELD_VOID, "Toggle", InputToggle), + DEFINE_INPUTFUNC(FIELD_VOID, "Trigger", InputTrigger), + DEFINE_INPUTFUNC(FIELD_VOID, "CancelPending", InputCancelPending), + + // Outputs + DEFINE_OUTPUT(m_OnSpawn, "OnSpawn"), + DEFINE_OUTPUT(m_Output[0], "OnTrigger1"), + DEFINE_OUTPUT(m_Output[1], "OnTrigger2"), + DEFINE_OUTPUT(m_Output[2], "OnTrigger3"), + DEFINE_OUTPUT(m_Output[3], "OnTrigger4"), + DEFINE_OUTPUT(m_Output[4], "OnTrigger5"), + DEFINE_OUTPUT(m_Output[5], "OnTrigger6"), + DEFINE_OUTPUT(m_Output[6], "OnTrigger7"), + DEFINE_OUTPUT(m_Output[7], "OnTrigger8"), + +END_DATADESC() + + + +//----------------------------------------------------------------------------- +// Purpose: Constructor. +//----------------------------------------------------------------------------- +CLogicRandomOutputs::CLogicRandomOutputs(void) +{ +} + +//----------------------------------------------------------------------------- +// Purpose: Read in the chance of firing each output +//----------------------------------------------------------------------------- +bool CLogicRandomOutputs::KeyValue( const char *szKeyName, const char *szValue ) +{ + if ( szValue && szValue[0] ) + { + for ( int i=0; i < NUM_RANDOM_OUTPUTS; i++ ) + { + if ( FStrEq( szKeyName, UTIL_VarArgs( "OnTriggerChance%d", i ) ) ) + { + m_flOnTriggerChance[i] = atof( szValue ); + return true; + } + } + } + + return BaseClass::KeyValue( szKeyName, szValue ); +} + +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Give out the chance of firing each output +//----------------------------------------------------------------------------- +bool CLogicRandomOutputs::GetKeyValue( const char *szKeyName, char *szValue, int iMaxLen ) +{ + if ( !Q_strnicmp(szKeyName, "OnTriggerChance", 15) ) + { + for ( int i=0; i < NUM_RANDOM_OUTPUTS; i++ ) + { + if ( FStrEq( szKeyName, UTIL_VarArgs( "OnTriggerChance%d", i ) ) ) + { + Q_snprintf( szValue, iMaxLen, "%f", m_flOnTriggerChance[i] ); + return true; + } + } + } + + return BaseClass::GetKeyValue( szKeyName, szValue, iMaxLen ); +} +#endif + +//------------------------------------------------------------------------------ +// Kickstarts a think if we have OnSpawn connections. +//------------------------------------------------------------------------------ +void CLogicRandomOutputs::Activate() +{ + BaseClass::Activate(); + + if ( m_OnSpawn.NumberOfElements() > 0) + { + SetNextThink( gpGlobals->curtime + 0.01 ); + } +} + + +//----------------------------------------------------------------------------- +// If we have OnSpawn connections, this is called shortly after spawning to +// fire the OnSpawn output. +//----------------------------------------------------------------------------- +void CLogicRandomOutputs::Think() +{ + // Fire an output when we spawn. This is used for self-starting an entity + // template -- since the logic_random_outputs is inside the template, it gets all the + // name and I/O connection fixup, so can target other entities in the template. + m_OnSpawn.FireOutput( this, this ); + + // We only get here if we had OnSpawn connections, so this is safe. + if ( m_spawnflags & SF_REMOVE_ON_FIRE ) + { + UTIL_Remove(this); + } +} + + +//------------------------------------------------------------------------------ +// Purpose: Turns on the entity, allowing it to fire outputs. +//------------------------------------------------------------------------------ +void CLogicRandomOutputs::InputEnable( inputdata_t &inputdata ) +{ + m_bDisabled = false; +} + +//------------------------------------------------------------------------------ +// Purpose: Enables us to fire again. This input is only posted from our Trigger +// function to prevent rapid refire. +//------------------------------------------------------------------------------ +void CLogicRandomOutputs::InputEnableRefire( inputdata_t &inputdata ) +{ + Msg(" now enabling refire\n" ); + m_bWaitForRefire = false; +} + + +//------------------------------------------------------------------------------ +// Purpose: Cancels any I/O events in the queue that were fired by us. +//------------------------------------------------------------------------------ +void CLogicRandomOutputs::InputCancelPending( inputdata_t &inputdata ) +{ + g_EventQueue.CancelEvents( this ); + + // Stop waiting; allow another Trigger. + m_bWaitForRefire = false; +} + + +//------------------------------------------------------------------------------ +// Purpose: Turns off the entity, preventing it from firing outputs. +//------------------------------------------------------------------------------ +void CLogicRandomOutputs::InputDisable( inputdata_t &inputdata ) +{ + m_bDisabled = true; +} + + +//------------------------------------------------------------------------------ +// Purpose: Toggles the enabled/disabled state of the entity. +//------------------------------------------------------------------------------ +void CLogicRandomOutputs::InputToggle( inputdata_t &inputdata ) +{ + m_bDisabled = !m_bDisabled; +} + + +//----------------------------------------------------------------------------- +// Purpose: Input handler that triggers the logic_random_outputs. +//----------------------------------------------------------------------------- +void CLogicRandomOutputs::InputTrigger( inputdata_t &inputdata ) +{ + if ((!m_bDisabled) && (!m_bWaitForRefire)) + { + for ( int i=0 ; i < NUM_RANDOM_OUTPUTS ; i++ ) + { + if ( RandomFloat() <= m_flOnTriggerChance[i] ) + { + m_Output[i].FireOutput( inputdata.pActivator, this ); + } + } + + if (m_spawnflags & SF_REMOVE_ON_FIRE) + { + UTIL_Remove(this); + } + else if (!(m_spawnflags & SF_ALLOW_FAST_RETRIGGER)) + { + // find the max delay from all our outputs + float fMaxDelay = 0; + for ( int i=0 ; i < NUM_RANDOM_OUTPUTS ; i++ ) + { + fMaxDelay = MAX( fMaxDelay, m_Output[i].GetMaxDelay() ); + } + if ( fMaxDelay > 0 ) + { + // Disable the relay so that it cannot be refired until after the last output + // has been fired and post an input to re-enable ourselves. + m_bWaitForRefire = true; + g_EventQueue.AddEvent(this, "EnableRefire", fMaxDelay + 0.001, this, this); + } + } + } +} diff --git a/sp/src/game/server/logic_random_outputs.h b/sp/src/game/server/logic_random_outputs.h new file mode 100644 index 00000000..aeb60bff --- /dev/null +++ b/sp/src/game/server/logic_random_outputs.h @@ -0,0 +1,54 @@ +//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// +#ifndef LOGICRANDOMOUTPUTS_H +#define LOGICRANDOMOUTPUTS_H + +#include "cbase.h" +#include "entityinput.h" +#include "entityoutput.h" +#include "eventqueue.h" + +#define NUM_RANDOM_OUTPUTS 8 + +class CLogicRandomOutputs : public CLogicalEntity +{ +public: + DECLARE_CLASS( CLogicRandomOutputs, CLogicalEntity ); + + CLogicRandomOutputs(); + + void Activate(); + void Think(); + virtual bool KeyValue( const char *szKeyName, const char *szValue ); +#ifdef MAPBASE + virtual bool GetKeyValue( const char *szKeyName, char *szValue, int iMaxLen ); +#endif + + // Input handlers + void InputEnable( inputdata_t &inputdata ); + void InputEnableRefire( inputdata_t &inputdata ); // Private input handler, not in FGD + void InputDisable( inputdata_t &inputdata ); + void InputToggle( inputdata_t &inputdata ); + void InputTrigger( inputdata_t &inputdata ); + void InputCancelPending( inputdata_t &inputdata ); + + DECLARE_DATADESC(); + + // Outputs + COutputEvent m_Output[ NUM_RANDOM_OUTPUTS ]; + COutputEvent m_OnSpawn; + + float m_flOnTriggerChance[ NUM_RANDOM_OUTPUTS ]; + +private: + + bool m_bDisabled; + bool m_bWaitForRefire; // Set to disallow a refire while we are waiting for our outputs to finish firing. +}; + +#endif //LOGICRANDOMOUTPUTS_H diff --git a/sp/src/game/server/logicentities.cpp b/sp/src/game/server/logicentities.cpp index cc8e6b73..2b78a3eb 100644 --- a/sp/src/game/server/logicentities.cpp +++ b/sp/src/game/server/logicentities.cpp @@ -14,6 +14,11 @@ #include "saverestore_utlvector.h" #include "vstdlib/random.h" #include "gameinterface.h" +#ifdef MAPBASE +#include "mapbase/variant_tools.h" +#include "mapbase/matchers.h" +#include "mapbase/datadesc_mod.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -32,12 +37,24 @@ public: DECLARE_CLASS( CLogicCompareInteger, CLogicalEntity ); // outputs +#ifdef MAPBASE + COutputVariant m_OnEqual; + COutputVariant m_OnNotEqual; +#else COutputEvent m_OnEqual; COutputEvent m_OnNotEqual; +#endif // data +#ifdef MAPBASE + variant_t m_iValue; + bool m_iShouldCompareToValue; + bool m_bStrLenAllowed = true; + int DrawDebugTextOverlays(void); +#else int m_iIntegerValue; int m_iShouldCompareToValue; +#endif DECLARE_DATADESC(); @@ -45,6 +62,10 @@ public: // Input handlers void InputValue( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputValueNoFire( inputdata_t &inputdata ); + void InputSetIntegerValue( inputdata_t &inputdata ); +#endif void InputCompareValues( inputdata_t &inputdata ); }; @@ -57,12 +78,22 @@ BEGIN_DATADESC( CLogicCompareInteger ) DEFINE_OUTPUT( m_OnEqual, "OnEqual" ), DEFINE_OUTPUT( m_OnNotEqual, "OnNotEqual" ), +#ifdef MAPBASE + DEFINE_KEYVARIANT( m_iValue, "IntegerValue" ), + DEFINE_KEYFIELD( m_iShouldCompareToValue, FIELD_BOOLEAN, "ShouldComparetoValue" ), + DEFINE_KEYFIELD( m_bStrLenAllowed, FIELD_BOOLEAN, "StrLenAllowed" ), +#else DEFINE_KEYFIELD( m_iIntegerValue, FIELD_INTEGER, "IntegerValue" ), DEFINE_KEYFIELD( m_iShouldCompareToValue, FIELD_INTEGER, "ShouldComparetoValue" ), +#endif DEFINE_FIELD( m_AllIntCompares, FIELD_INPUT ), DEFINE_INPUTFUNC( FIELD_INPUT, "InputValue", InputValue ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_INPUT, "InputValueNoFire", InputValueNoFire ), + DEFINE_INPUTFUNC( FIELD_INPUT, "SetReferenceValue", InputSetIntegerValue ), +#endif DEFINE_INPUTFUNC( FIELD_INPUT, "CompareValues", InputCompareValues ), END_DATADESC() @@ -75,9 +106,14 @@ END_DATADESC() //----------------------------------------------------------------------------- void CLogicCompareInteger::InputValue( inputdata_t &inputdata ) { +#ifdef MAPBASE + // Parse the input value, regardless of field type + inputdata.value = Variant_ParseInput(inputdata); +#else // make sure it's an int, if it can't be converted just throw it away if ( !inputdata.value.Convert(FIELD_INTEGER) ) return; +#endif // update the value list with the new value m_AllIntCompares.AddValue( inputdata.value, inputdata.nOutputID ); @@ -85,12 +121,38 @@ void CLogicCompareInteger::InputValue( inputdata_t &inputdata ) // if we haven't already this frame, send a message to ourself to update and fire if ( !m_AllIntCompares.m_bUpdatedThisFrame ) { +#ifdef MAPBASE + // Need to wait for all inputs to arrive + g_EventQueue.AddEvent( this, "CompareValues", 0.01, inputdata.pActivator, this, inputdata.nOutputID ); +#else // TODO: need to add this event with a lower priority, so it gets called after all inputs have arrived g_EventQueue.AddEvent( this, "CompareValues", 0, inputdata.pActivator, this, inputdata.nOutputID ); +#endif m_AllIntCompares.m_bUpdatedThisFrame = TRUE; } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Adds to the list of compared values without firing +//----------------------------------------------------------------------------- +void CLogicCompareInteger::InputValueNoFire( inputdata_t &inputdata ) +{ + // Parse the input value, regardless of field type + inputdata.value = Variant_ParseInput(inputdata); + + // update the value list with the new value + m_AllIntCompares.AddValue( inputdata.value, inputdata.nOutputID ); +} + +//----------------------------------------------------------------------------- +// Purpose: Sets our reference value +//----------------------------------------------------------------------------- +void CLogicCompareInteger::InputSetIntegerValue( inputdata_t &inputdata ) +{ + m_iValue = Variant_ParseInput(inputdata); +} +#endif //----------------------------------------------------------------------------- // Purpose: Forces a recompare @@ -100,6 +162,30 @@ void CLogicCompareInteger::InputCompareValues( inputdata_t &inputdata ) m_AllIntCompares.m_bUpdatedThisFrame = FALSE; // loop through all the values comparing them +#ifdef MAPBASE + variant_t value = m_iValue; + CMultiInputVar::inputitem_t *input = m_AllIntCompares.m_InputList; + + if ( !m_iShouldCompareToValue && input ) + { + value = input->value; + } + + while ( input ) + { + if ( !Variant_Equal(value, input->value, m_bStrLenAllowed) ) + { + // false + m_OnNotEqual.Set( input->value, inputdata.pActivator, this ); + return; + } + + input = input->next; + } + + // true! all values equal + m_OnEqual.Set( value, inputdata.pActivator, this ); +#else int value = m_iIntegerValue; CMultiInputVar::inputitem_t *input = m_AllIntCompares.m_InputList; @@ -122,8 +208,42 @@ void CLogicCompareInteger::InputCompareValues( inputdata_t &inputdata ) // true! all values equal m_OnEqual.FireOutput( inputdata.pActivator, this ); +#endif } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Draw any debug text overlays +// Output : Current text offset from the top +//----------------------------------------------------------------------------- +int CLogicCompareInteger::DrawDebugTextOverlays( void ) +{ + int text_offset = BaseClass::DrawDebugTextOverlays(); + + if (m_debugOverlays & OVERLAY_TEXT_BIT) + { + char tempstr[512]; + + Q_snprintf(tempstr, sizeof(tempstr), " Reference Value: %s", m_iValue.GetDebug()); + EntityText(text_offset, tempstr, 0); + text_offset++; + + int count = 1; + CMultiInputVar::inputitem_t *input = m_AllIntCompares.m_InputList; + while ( input ) + { + Q_snprintf(tempstr, sizeof(tempstr), " Value %i: %s", count, input->value.GetDebug()); + EntityText(text_offset, tempstr, 0); + text_offset++; + + count++; + input = input->next; + } + } + return text_offset; +} +#endif + //----------------------------------------------------------------------------- // Purpose: Timer entity. Fires an output at regular or random intervals. @@ -844,6 +964,39 @@ void CC_Global_Set( const CCommand &args ) static ConCommand global_set( "global_set", CC_Global_Set, "global_set : Sets the state of the given env_global (0 = OFF, 1 = ON, 2 = DEAD).", FCVAR_CHEAT ); +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Console command to set the counter of a global +//----------------------------------------------------------------------------- +void CC_Global_Counter( const CCommand &args ) +{ + const char *szGlobal = args[1]; + const char *szCounter = args[2]; + + if ( szGlobal == NULL || szCounter == NULL ) + { + Msg( "Usage: global_counter : Sets the counter of the given env_global.\n" ); + return; + } + + int nCounter = atoi( szCounter ); + + int nIndex = GlobalEntity_GetIndex( szGlobal ); + + if ( nIndex >= 0 ) + { + GlobalEntity_SetCounter( nIndex, nCounter ); + } + else + { + nIndex = GlobalEntity_Add( szGlobal, STRING( gpGlobals->mapname ), GLOBAL_ON ); + GlobalEntity_SetCounter( nIndex, nCounter ); + } +} + +static ConCommand global_counter( "global_counter", CC_Global_Counter, "global_counter : Sets the counter of the given env_global.", FCVAR_CHEAT ); +#endif + //----------------------------------------------------------------------------- // Purpose: Holds a global state that can be queried by other entities to change @@ -858,6 +1011,10 @@ public: void Spawn( void ); +#ifdef MAPBASE + bool KeyValue( const char *szKeyName, const char *szValue ); +#endif + // Input handlers void InputTurnOn( inputdata_t &inputdata ); void InputTurnOff( inputdata_t &inputdata ); @@ -897,7 +1054,11 @@ BEGIN_DATADESC( CEnvGlobal ) DEFINE_INPUTFUNC( FIELD_INTEGER, "AddToCounter", InputAddToCounter ), DEFINE_INPUTFUNC( FIELD_VOID, "GetCounter", InputGetCounter ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_outCounter, "OutCounter" ), +#else DEFINE_OUTPUT( m_outCounter, "Counter" ), +#endif END_DATADESC() @@ -938,6 +1099,24 @@ void CEnvGlobal::Spawn( void ) } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Cache user entity field values until spawn is called. +// Input : szKeyName - Key to handle. +// szValue - Value for key. +// Output : Returns true if the key was handled, false if not. +//----------------------------------------------------------------------------- +bool CEnvGlobal::KeyValue( const char *szKeyName, const char *szValue ) +{ + // Any "Counter" outputs are changed to "OutCounter" before spawning. + if (FStrEq(szKeyName, "Counter") && strchr(szValue, ',')) + { + return BaseClass::KeyValue( "OutCounter", szValue ); + } + + return BaseClass::KeyValue( szKeyName, szValue ); +} +#endif //------------------------------------------------------------------------------ // Purpose: @@ -1297,7 +1476,11 @@ void CMultiSource::Register(void) class CMathCounter : public CLogicalEntity { DECLARE_CLASS( CMathCounter, CLogicalEntity ); +#ifdef MAPBASE +protected: +#else private: +#endif float m_flMin; // Minimum clamp value. If min and max are BOTH zero, no clamping is done. float m_flMax; // Maximum clamp value. bool m_bHitMin; // Set when we reach or go below our minimum value, cleared if we go above it again. @@ -1310,6 +1493,9 @@ private: int DrawDebugTextOverlays(void); +#ifdef MAPBASE + virtual +#endif void UpdateOutValue(CBaseEntity *pActivator, float fNewValue); // Inputs @@ -1324,12 +1510,20 @@ private: void InputGetValue( inputdata_t &inputdata ); void InputEnable( inputdata_t &inputdata ); void InputDisable( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetMinValueNoFire( inputdata_t &inputdata ); + void InputSetMaxValueNoFire( inputdata_t &inputdata ); +#endif // Outputs COutputFloat m_OutValue; COutputFloat m_OnGetValue; // Used for polling the counter value. COutputEvent m_OnHitMin; COutputEvent m_OnHitMax; +#ifdef MAPBASE + COutputEvent m_OnChangedFromMin; + COutputEvent m_OnChangedFromMax; +#endif DECLARE_DATADESC(); }; @@ -1360,12 +1554,20 @@ BEGIN_DATADESC( CMathCounter ) DEFINE_INPUTFUNC(FIELD_VOID, "GetValue", InputGetValue), DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetMaxValueNoFire", InputSetMaxValueNoFire ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetMinValueNoFire", InputSetMinValueNoFire ), +#endif // Outputs DEFINE_OUTPUT(m_OutValue, "OutValue"), DEFINE_OUTPUT(m_OnHitMin, "OnHitMin"), DEFINE_OUTPUT(m_OnHitMax, "OnHitMax"), DEFINE_OUTPUT(m_OnGetValue, "OnGetValue"), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OnChangedFromMin, "OnChangedFromMin" ), + DEFINE_OUTPUT( m_OnChangedFromMax, "OnChangedFromMax" ), +#endif END_DATADESC() @@ -1382,7 +1584,11 @@ bool CMathCounter::KeyValue(const char *szKeyName, const char *szValue) // if (!stricmp(szKeyName, "startvalue")) { +#ifdef MAPBASE + m_OutValue.Init(atof(szValue)); +#else m_OutValue.Init(atoi(szValue)); +#endif return(true); } @@ -1478,6 +1684,29 @@ void CMathCounter::InputSetHitMin( inputdata_t &inputdata ) UpdateOutValue( inputdata.pActivator, m_OutValue.Get() ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Change min/max +//----------------------------------------------------------------------------- +void CMathCounter::InputSetMaxValueNoFire( inputdata_t &inputdata ) +{ + m_flMax = inputdata.value.Float(); + if ( m_flMax < m_flMin ) + { + m_flMin = m_flMax; + } +} + +void CMathCounter::InputSetMinValueNoFire( inputdata_t &inputdata ) +{ + m_flMin = inputdata.value.Float(); + if ( m_flMax < m_flMin ) + { + m_flMax = m_flMin; + } +} +#endif + //----------------------------------------------------------------------------- // Purpose: Input handler for adding to the accumulator value. @@ -1636,6 +1865,14 @@ void CMathCounter::UpdateOutValue(CBaseEntity *pActivator, float fNewValue) } else { +#ifdef MAPBASE + // Fire an output if we just changed from the maximum value + if ( m_OutValue.Get() == m_flMax ) + { + m_OnChangedFromMax.FireOutput( pActivator, this ); + } +#endif + m_bHitMax = false; } @@ -1652,6 +1889,13 @@ void CMathCounter::UpdateOutValue(CBaseEntity *pActivator, float fNewValue) } else { +#ifdef MAPBASE + // Fire an output if we just changed from the maximum value + if ( m_OutValue.Get() == m_flMin ) + { + m_OnChangedFromMin.FireOutput( pActivator, this ); + } +#endif m_bHitMin = false; } @@ -1662,6 +1906,409 @@ void CMathCounter::UpdateOutValue(CBaseEntity *pActivator, float fNewValue) } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Advanced math_counter with advanced calculation capabilities. +//----------------------------------------------------------------------------- +class CMathCounterAdvanced : public CMathCounter +{ + DECLARE_CLASS( CMathCounterAdvanced, CMathCounter ); +private: + + bool m_bPreserveValue; + bool m_bAlwaysOutputAsInt; + + void UpdateOutValue(CBaseEntity *pActivator, float fNewValue); + + void InputSetValueToPi( inputdata_t &inputdata ); + + void InputPower( inputdata_t &inputdata ); + void InputSquareRoot( inputdata_t &inputdata ); + + void InputRound( inputdata_t &inputdata ); + void InputFloor( inputdata_t &inputdata ); + void InputCeiling( inputdata_t &inputdata ); + void InputTrunc( inputdata_t &inputdata ); + + void InputSine( inputdata_t &inputdata ); + void InputCosine( inputdata_t &inputdata ); + void InputTangent( inputdata_t &inputdata ); + + void InputRandomInt( inputdata_t &inputdata ); + void InputRandomFloat( inputdata_t &inputdata ); + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(math_counter_advanced, CMathCounterAdvanced); + + +BEGIN_DATADESC( CMathCounterAdvanced ) + + // Keys + DEFINE_INPUT(m_bPreserveValue, FIELD_BOOLEAN, "PreserveValue"), + DEFINE_INPUT(m_bAlwaysOutputAsInt, FIELD_BOOLEAN, "AlwaysOutputAsInt"), + + // Inputs + DEFINE_INPUTFUNC(FIELD_VOID, "SetValueToPi", InputSetValueToPi), + + DEFINE_INPUTFUNC(FIELD_VOID, "SquareRoot", InputSquareRoot), + DEFINE_INPUTFUNC(FIELD_INTEGER, "Power", InputPower), + + DEFINE_INPUTFUNC(FIELD_INTEGER, "Round", InputRound), + DEFINE_INPUTFUNC(FIELD_INTEGER, "Floor", InputFloor), + DEFINE_INPUTFUNC(FIELD_INTEGER, "Ceil", InputCeiling), + DEFINE_INPUTFUNC(FIELD_INTEGER, "Trunc", InputTrunc), + + DEFINE_INPUTFUNC(FIELD_VOID, "Sin", InputSine), + DEFINE_INPUTFUNC(FIELD_VOID, "Cos", InputCosine), + DEFINE_INPUTFUNC(FIELD_VOID, "Tan", InputTangent), + + DEFINE_INPUTFUNC(FIELD_STRING, "RandomInt", InputRandomInt), + DEFINE_INPUTFUNC(FIELD_STRING, "RandomFloat", InputRandomFloat), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: Input handler for setting the current value to pi. +//----------------------------------------------------------------------------- +void CMathCounterAdvanced::InputSetValueToPi( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Counter %s ignoring SET TO PI because it is disabled\n", GetDebugName() ); + return; + } + + float fNewValue = M_PI; + UpdateOutValue( inputdata.pActivator, fNewValue ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for calculating the square root of the current value. +//----------------------------------------------------------------------------- +void CMathCounterAdvanced::InputSquareRoot( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Counter %s ignoring SQUARE ROOT because it is disabled\n", GetDebugName() ); + return; + } + + float fNewValue = sqrt(m_OutValue.Get()); + UpdateOutValue( inputdata.pActivator, fNewValue ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for exponentiation of the current value. Use 2 to square it. +// Input : Integer value to raise the current value's power. +//----------------------------------------------------------------------------- +void CMathCounterAdvanced::InputPower( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Counter %s ignoring POWER!!! because it is disabled\n", GetDebugName() ); + return; + } + + float fNewValue = pow(m_OutValue.Get(), inputdata.value.Int()); + UpdateOutValue( inputdata.pActivator, fNewValue ); +} + +// +// For some reason, I had trouble finding the original math functions at first. +// Then I just randomly stumbled upon them, bright as day. +// Oh well. These might be faster anyway. +// +FORCEINLINE int RoundToNumber(int input, int number) +{ + (input < 0 && number > 0) ? number *= -1 : 0; + int result = (input + (number / 2)); + result -= (result % number); + return result; +} + +// Warning: Negative numbers should be ceiled +FORCEINLINE int FloorToNumber(int input, int number) +{ + return (input - (input % number)); +} + +FORCEINLINE int CeilToNumber(int input, int number) +{ + (input < 0 && number > 0) ? number *= -1 : 0; + int result = (input - (input % number)); + return result != input ? result + number : result; +} + +FORCEINLINE int TruncToNumber(int input, int number) +{ + //(input < 0 && number > 0) ? number *= -1 : 0; + return (input - (input % number)); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for rounding an integer to the specified number. (e.g. 126 rounding to 10 = 130, 1523 rounding to 5 = 1525) +// Input : Integer value to round the current value to. +//----------------------------------------------------------------------------- +void CMathCounterAdvanced::InputRound( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Counter %s ignoring ROUND because it is disabled\n", GetDebugName() ); + return; + } + + int iMultiple = inputdata.value.Int(); + int iNewValue; + if (iMultiple != 0) + { + // Round to the nearest input number. + iNewValue = RoundToNumber(m_OutValue.Get(), iMultiple); + } + else + { + // 0 just rounds floats. + iNewValue = static_cast(m_OutValue.Get() + 0.5f); + } + + UpdateOutValue( inputdata.pActivator, iNewValue ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for flooring an integer to the specified number. (e.g. 126 flooring to 10 = 120, 1528 flooring to 5 = 1525) +// Input : Integer value to floor the current value to. +//----------------------------------------------------------------------------- +void CMathCounterAdvanced::InputFloor( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Counter %s ignoring FLOOR because it is disabled\n", GetDebugName() ); + return; + } + + int iMultiple = inputdata.value.Int(); + int iNewValue; + if (iMultiple != 0) + { + iNewValue = m_OutValue.Get(); + if (iNewValue >= 0) + { + // Floor to the nearest input number. + iNewValue = FloorToNumber(m_OutValue.Get(), iMultiple); + } + else + { + // We have to do it differently for negatives. + iNewValue = CeilToNumber(m_OutValue.Get(), iMultiple); + } + } + else + { + // 0 just floors floats. + iNewValue = static_cast(m_OutValue.Get()); + } + + UpdateOutValue( inputdata.pActivator, iNewValue ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for ceiling an integer to the specified number. (e.g. 126 ceiling to 10 = 130, 1523 ceiling to 50 = 1550) +// Input : Integer value to ceil the current value to. +//----------------------------------------------------------------------------- +void CMathCounterAdvanced::InputCeiling( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Counter %s ignoring CEIL because it is disabled\n", GetDebugName() ); + return; + } + + int iMultiple = inputdata.value.Int(); + int iNewValue; + if (iMultiple != 0) + { + // Ceil to the nearest input number. + iNewValue = CeilToNumber(m_OutValue.Get(), iMultiple); + } + else + { + // 0 just ceils floats. + iNewValue = static_cast(m_OutValue.Get()) + (m_OutValue.Get() != 0 ? 1 : 0); + } + + UpdateOutValue( inputdata.pActivator, iNewValue ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for truncating an integer to the specified number. (e.g. 126 rounding to 10 = 120, -1523 rounding to 5 = 1520) +// Input : Integer value to truncate the current value to. +//----------------------------------------------------------------------------- +void CMathCounterAdvanced::InputTrunc( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Counter %s ignoring TRUNC because it is disabled\n", GetDebugName() ); + return; + } + + int iMultiple = inputdata.value.Int(); + int iNewValue; + if (iMultiple != 0) + { + // Floor always truncates negative numbers if we don't tell it not to + iNewValue = FloorToNumber(m_OutValue.Get(), iMultiple); + } + else + { + // 0 just ceils floats. + iNewValue = static_cast(m_OutValue.Get()); + if (iNewValue < 0) + iNewValue += 1; + } + + UpdateOutValue( inputdata.pActivator, iNewValue ); +} + + +//----------------------------------------------------------------------------- +// Purpose: Input handler for applying sine to the current value. +//----------------------------------------------------------------------------- +void CMathCounterAdvanced::InputSine( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Counter %s ignoring SINE because it is disabled\n", GetDebugName() ); + return; + } + + float fNewValue = sin(m_OutValue.Get()); + UpdateOutValue( inputdata.pActivator, fNewValue ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for applying cosine to the current value. +//----------------------------------------------------------------------------- +void CMathCounterAdvanced::InputCosine( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Counter %s ignoring SINE because it is disabled\n", GetDebugName() ); + return; + } + + float fNewValue = cos(m_OutValue.Get()); + UpdateOutValue( inputdata.pActivator, fNewValue ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for applying tangent to the current value. +//----------------------------------------------------------------------------- +void CMathCounterAdvanced::InputTangent( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Counter %s ignoring SINE because it is disabled\n", GetDebugName() ); + return; + } + + float fNewValue = tan(m_OutValue.Get()); + UpdateOutValue( inputdata.pActivator, fNewValue ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for random int generation. +//----------------------------------------------------------------------------- +void CMathCounterAdvanced::InputRandomInt( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Counter %s ignoring RANDOMINT because it is disabled\n", GetDebugName() ); + return; + } + + int i1 = 0; + int i2 = 0; + + char szInput[128]; + Q_strncpy( szInput, inputdata.value.String(), sizeof(szInput) ); + char *sSpace = strchr( szInput, ' ' ); + if ( sSpace ) + { + i1 = atoi(szInput); + i2 = atoi(sSpace+1); + } + else + { + // No space, assume anything from 0 to X + i2 = atoi(szInput); + } + + float fNewValue = RandomInt(i1, i2); + UpdateOutValue( inputdata.pActivator, fNewValue ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for random float generation. +//----------------------------------------------------------------------------- +void CMathCounterAdvanced::InputRandomFloat( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Counter %s ignoring RANDOMFLOAT because it is disabled\n", GetDebugName() ); + return; + } + + float f1 = 0; + float f2 = 0; + + char szInput[128]; + Q_strncpy( szInput, inputdata.value.String(), sizeof(szInput) ); + char *sSpace = strchr( szInput, ' ' ); + if ( sSpace ) + { + f1 = atof(szInput); + f2 = atof(sSpace+1); + } + else + { + // No space, assume anything from 0 to X + f2 = atof(szInput); + } + + float fNewValue = RandomFloat(f1, f2); + UpdateOutValue( inputdata.pActivator, fNewValue ); +} + +//----------------------------------------------------------------------------- +// Purpose: Sets the value to the new value, clamping and firing the output value. +// Input : fNewValue - Value to set. +//----------------------------------------------------------------------------- +void CMathCounterAdvanced::UpdateOutValue(CBaseEntity *pActivator, float fNewValue) +{ + if (m_bAlwaysOutputAsInt) + fNewValue = roundf(fNewValue); + + if (m_bPreserveValue) + { + //float fOriginal = m_OutValue.Get(); + //DevMsg("Preserve Before: %f\n", fOriginal); + //BaseClass::UpdateOutValue(pActivator, fNewValue); + //DevMsg("Preserve After: %f\n", fOriginal); + //m_OutValue.Init(fOriginal); + + variant_t var; + var.SetFloat(fNewValue); + m_OutValue.FireOutput( var, pActivator, this ); + } + else + { + BaseClass::UpdateOutValue(pActivator, fNewValue); + } +} +#endif + + //----------------------------------------------------------------------------- // Purpose: Compares a single string input to up to 16 case values, firing an @@ -1678,6 +2325,10 @@ class CLogicCase : public CLogicalEntity private: string_t m_nCase[MAX_LOGIC_CASES]; +#ifdef MAPBASE + bool m_bMultipleCasesAllowed; +#endif + int m_nShuffleCases; int m_nLastShuffleCase; unsigned char m_uchShuffleCaseMap[MAX_LOGIC_CASES]; @@ -1694,6 +2345,9 @@ private: // Outputs COutputEvent m_OnCase[MAX_LOGIC_CASES]; // Fired when the input value matches one of the case values. COutputVariant m_OnDefault; // Fired when no match was found. +#ifdef MAPBASE + COutputVariant m_OnUsed; // Fired when this entity receives any input at all. +#endif DECLARE_DATADESC(); }; @@ -1723,6 +2377,10 @@ BEGIN_DATADESC( CLogicCase ) DEFINE_KEYFIELD(m_nCase[13], FIELD_STRING, "Case14"), DEFINE_KEYFIELD(m_nCase[14], FIELD_STRING, "Case15"), DEFINE_KEYFIELD(m_nCase[15], FIELD_STRING, "Case16"), + +#ifdef MAPBASE + DEFINE_KEYFIELD(m_bMultipleCasesAllowed, FIELD_BOOLEAN, "MultipleCasesAllowed"), +#endif DEFINE_FIELD( m_nShuffleCases, FIELD_INTEGER ), DEFINE_FIELD( m_nLastShuffleCase, FIELD_INTEGER ), @@ -1752,6 +2410,9 @@ BEGIN_DATADESC( CLogicCase ) DEFINE_OUTPUT(m_OnCase[15], "OnCase16"), DEFINE_OUTPUT(m_OnDefault, "OnDefault"), +#ifdef MAPBASE + DEFINE_OUTPUT(m_OnUsed, "OnUsed"), +#endif END_DATADESC() @@ -1775,16 +2436,35 @@ void CLogicCase::Spawn( void ) //----------------------------------------------------------------------------- void CLogicCase::InputValue( inputdata_t &inputdata ) { +#ifdef MAPBASE + m_OnUsed.Set(inputdata.value, inputdata.pActivator, this); + bool bFoundCase = false; +#endif const char *pszValue = inputdata.value.String(); for (int i = 0; i < MAX_LOGIC_CASES; i++) { +#ifdef MAPBASE + if ((m_nCase[i] != NULL_STRING) && Matcher_Compare(STRING(m_nCase[i]), pszValue)) + { + m_OnCase[i].FireOutput( inputdata.pActivator, this ); + + if (!m_bMultipleCasesAllowed) + return; + else if (!bFoundCase) + bFoundCase = true; + } +#else if ((m_nCase[i] != NULL_STRING) && !stricmp(STRING(m_nCase[i]), pszValue)) { m_OnCase[i].FireOutput( inputdata.pActivator, this ); return; } +#endif } +#ifdef MAPBASE + if (!bFoundCase) +#endif m_OnDefault.Set( inputdata.value, inputdata.pActivator, this ); } @@ -1916,23 +2596,50 @@ class CLogicCompare : public CLogicalEntity public: int DrawDebugTextOverlays(void); +#ifdef MAPBASE + void Spawn(); +#endif + private: // Inputs void InputSetValue( inputdata_t &inputdata ); void InputSetValueCompare( inputdata_t &inputdata ); void InputSetCompareValue( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetCompareValueCompare( inputdata_t &inputdata ); +#endif void InputCompare( inputdata_t &inputdata ); +#ifdef MAPBASE + void DoCompare(CBaseEntity *pActivator, variant_t value); +#else void DoCompare(CBaseEntity *pActivator, float flInValue); +#endif +#ifdef MAPBASE + bool m_bStrLenAllowed = true; + bool m_bGreaterThanOrEqual; + variant_t m_InValue; // Place to hold the last input value for a recomparison. + variant_t m_CompareValue; // The value to compare the input value against. +#else float m_flInValue; // Place to hold the last input value for a recomparison. float m_flCompareValue; // The value to compare the input value against. +#endif // Outputs +#ifdef MAPBASE + COutputVariant m_OnLessThan; // Fired when the input value is less than the compare value. + COutputVariant m_OnEqualTo; // Fired when the input value is equal to the compare value. + COutputVariant m_OnNotEqualTo; // Fired when the input value is not equal to the compare value. + COutputVariant m_OnGreaterThan; // Fired when the input value is greater than the compare value. + COutputVariant m_OnLessThanOrEqualTo; // Fired when the input value is less than or equal to the compare value. + COutputVariant m_OnGreaterThanOrEqualTo; // Fired when the input value is greater than or equal to the compare value. +#else COutputFloat m_OnLessThan; // Fired when the input value is less than the compare value. COutputFloat m_OnEqualTo; // Fired when the input value is equal to the compare value. COutputFloat m_OnNotEqualTo; // Fired when the input value is not equal to the compare value. COutputFloat m_OnGreaterThan; // Fired when the input value is greater than the compare value. +#endif DECLARE_DATADESC(); }; @@ -1943,13 +2650,26 @@ LINK_ENTITY_TO_CLASS(logic_compare, CLogicCompare); BEGIN_DATADESC( CLogicCompare ) // Keys +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bStrLenAllowed, FIELD_BOOLEAN, "StrLenAllowed" ), + DEFINE_KEYVARIANT(m_CompareValue, "CompareValue"), + DEFINE_KEYVARIANT(m_InValue, "InitialValue"), +#else DEFINE_KEYFIELD(m_flCompareValue, FIELD_FLOAT, "CompareValue"), DEFINE_KEYFIELD(m_flInValue, FIELD_FLOAT, "InitialValue"), +#endif // Inputs +#ifdef MAPBASE + DEFINE_INPUTFUNC(FIELD_INPUT, "SetValue", InputSetValue), + DEFINE_INPUTFUNC(FIELD_INPUT, "SetValueCompare", InputSetValueCompare), + DEFINE_INPUTFUNC(FIELD_INPUT, "SetCompareValue", InputSetCompareValue), + DEFINE_INPUTFUNC(FIELD_INPUT, "SetCompareValueCompare", InputSetCompareValueCompare), +#else DEFINE_INPUTFUNC(FIELD_FLOAT, "SetValue", InputSetValue), DEFINE_INPUTFUNC(FIELD_FLOAT, "SetValueCompare", InputSetValueCompare), DEFINE_INPUTFUNC(FIELD_FLOAT, "SetCompareValue", InputSetCompareValue), +#endif DEFINE_INPUTFUNC(FIELD_VOID, "Compare", InputCompare), // Outputs @@ -1957,18 +2677,40 @@ BEGIN_DATADESC( CLogicCompare ) DEFINE_OUTPUT(m_OnNotEqualTo, "OnNotEqualTo"), DEFINE_OUTPUT(m_OnGreaterThan, "OnGreaterThan"), DEFINE_OUTPUT(m_OnLessThan, "OnLessThan"), +#ifdef MAPBASE + DEFINE_OUTPUT(m_OnGreaterThanOrEqualTo, "OnGreaterThanOrEqualTo"), + DEFINE_OUTPUT(m_OnLessThanOrEqualTo, "OnLessThanOrEqualTo"), +#endif END_DATADESC() +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Input handler for a new input value without performing a comparison. +//----------------------------------------------------------------------------- +void CLogicCompare::Spawn() +{ + // Empty initial values are equivalent to 0 + if (m_InValue.FieldType() == FIELD_STRING && m_InValue.String()[0] == '\0') + m_InValue.SetInt( 0 ); + + BaseClass::Spawn(); +} +#endif + //----------------------------------------------------------------------------- // Purpose: Input handler for a new input value without performing a comparison. //----------------------------------------------------------------------------- void CLogicCompare::InputSetValue( inputdata_t &inputdata ) { +#ifdef MAPBASE + m_InValue = Variant_ParseInput(inputdata); +#else m_flInValue = inputdata.value.Float(); +#endif } @@ -1977,8 +2719,13 @@ void CLogicCompare::InputSetValue( inputdata_t &inputdata ) //----------------------------------------------------------------------------- void CLogicCompare::InputSetValueCompare( inputdata_t &inputdata ) { +#ifdef MAPBASE + m_InValue = Variant_ParseInput(inputdata); + DoCompare( inputdata.pActivator, m_InValue ); +#else m_flInValue = inputdata.value.Float(); DoCompare( inputdata.pActivator, m_flInValue ); +#endif } //----------------------------------------------------------------------------- @@ -1986,15 +2733,34 @@ void CLogicCompare::InputSetValueCompare( inputdata_t &inputdata ) //----------------------------------------------------------------------------- void CLogicCompare::InputSetCompareValue( inputdata_t &inputdata ) { +#ifdef MAPBASE + m_CompareValue = Variant_ParseInput(inputdata); +#else m_flCompareValue = inputdata.value.Float(); +#endif } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Input handler for a new input value and doing the comparison. +//----------------------------------------------------------------------------- +void CLogicCompare::InputSetCompareValueCompare( inputdata_t &inputdata ) +{ + m_CompareValue = Variant_ParseInput(inputdata); + DoCompare( inputdata.pActivator, m_InValue ); +} +#endif + //----------------------------------------------------------------------------- // Purpose: Input handler for forcing a recompare of the last input value. //----------------------------------------------------------------------------- void CLogicCompare::InputCompare( inputdata_t &inputdata ) { +#ifdef MAPBASE + DoCompare( inputdata.pActivator, m_InValue ); +#else DoCompare( inputdata.pActivator, m_flInValue ); +#endif } @@ -2003,6 +2769,33 @@ void CLogicCompare::InputCompare( inputdata_t &inputdata ) // output(s) based on the comparison result. // Input : flInValue - Value to compare against the comparison value. //----------------------------------------------------------------------------- +#ifdef MAPBASE +void CLogicCompare::DoCompare(CBaseEntity *pActivator, variant_t value) +{ + if (Variant_Equal(value, m_CompareValue, m_bStrLenAllowed)) + { + m_OnEqualTo.Set(value, pActivator, this); + + m_OnLessThanOrEqualTo.Set(value, pActivator, this); + m_OnGreaterThanOrEqualTo.Set(value, pActivator, this); + } + else + { + m_OnNotEqualTo.Set(value, pActivator, this); + + if (Variant_Greater(m_InValue, m_CompareValue, m_bStrLenAllowed)) + { + m_OnGreaterThan.Set(value, pActivator, this); + m_OnGreaterThanOrEqualTo.Set(value, pActivator, this); + } + else + { + m_OnLessThan.Set(value, pActivator, this); + m_OnLessThanOrEqualTo.Set(value, pActivator, this); + } + } +} +#else void CLogicCompare::DoCompare(CBaseEntity *pActivator, float flInValue) { if (flInValue == m_flCompareValue) @@ -2023,6 +2816,7 @@ void CLogicCompare::DoCompare(CBaseEntity *pActivator, float flInValue) } } } +#endif //----------------------------------------------------------------------------- // Purpose: Draw any debug text overlays @@ -2037,12 +2831,20 @@ int CLogicCompare::DrawDebugTextOverlays( void ) char tempstr[512]; // print duration +#ifdef MAPBASE + Q_snprintf(tempstr,sizeof(tempstr)," Initial Value: %s", m_InValue.GetDebug()); +#else Q_snprintf(tempstr,sizeof(tempstr)," Initial Value: %f", m_flInValue); +#endif EntityText(text_offset,tempstr,0); text_offset++; // print hold time +#ifdef MAPBASE + Q_snprintf(tempstr,sizeof(tempstr)," Compare Value: %s", m_CompareValue.GetDebug()); +#else Q_snprintf(tempstr,sizeof(tempstr)," Compare Value: %f", m_flCompareValue); +#endif EntityText(text_offset,tempstr,0); text_offset++; } @@ -2746,3 +3548,2903 @@ int CLogicBranchList::DrawDebugTextOverlays( void ) return text_offset; } + +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Prints messages to the console. +//----------------------------------------------------------------------------- +class CLogicConsole : public CLogicalEntity +{ +public: + + DECLARE_CLASS( CLogicConsole, CLogicalEntity ); + + // Keys + int m_iDevLevel = 1; + Color m_MsgColor = Color(210, 250, 255, 255); + Color m_WarningColor = Color(255, 210, 210, 255); + bool m_bNewLineNotAuto = false; + + // TODO: Replace "append" with variable arguments? + inline void LCMsg(const char *msg, const char *append = NULL) { ConColorMsg(m_MsgColor, msg, append); } + inline void LCDevMsg(int lvl, const char *msg, const char *append = NULL) { developer.GetInt() >= lvl ? ConColorMsg(m_MsgColor, msg, append) : 0; } + inline void LCWarning(const char *msg, const char *append = NULL) { ConColorMsg(m_WarningColor, msg, append); } + inline void LCDevWarning(int lvl, const char *msg, const char *append = NULL) { developer.GetInt() >= lvl ? ConColorMsg(m_WarningColor, msg, append) : 0; } + + //inline void LCMsg(const char *msg, const char *append = NULL) { ColorSpewMessage(SPEW_MESSAGE, &m_MsgColor, msg, append); } + //inline void LCDevMsg(int lvl, const char *msg, const char *append = NULL) { developer.GetInt() >= lvl ? ColorSpewMessage(SPEW_MESSAGE, &m_MsgColor, msg, append) : 0; } + //inline void LCWarning(const char *msg, const char *append = NULL) { ColorSpewMessage(SPEW_MESSAGE, &m_WarningColor, msg, append); } + //inline void LCDevWarning(int lvl, const char *msg, const char *append = NULL) { developer.GetInt() >= lvl ? ColorSpewMessage(SPEW_MESSAGE, &m_WarningColor, msg, append) : 0; } + + // Inputs + void InputSendMsg( inputdata_t &inputdata ) { !m_bNewLineNotAuto ? LCMsg("%s\n", inputdata.value.String()) : LCMsg("%s", inputdata.value.String()); } + void InputSendWarning( inputdata_t &inputdata ) { !m_bNewLineNotAuto ? LCWarning("%s\n", inputdata.value.String()) : LCWarning("%s", inputdata.value.String()); } + void InputSendDevMsg( inputdata_t &inputdata ) { !m_bNewLineNotAuto ? LCDevMsg(m_iDevLevel, "%s\n", inputdata.value.String()) : LCDevMsg(m_iDevLevel, "%s", inputdata.value.String()); } + void InputSendDevWarning( inputdata_t &inputdata ) { !m_bNewLineNotAuto ? LCDevWarning(m_iDevLevel, "%s\n", inputdata.value.String()) : LCDevWarning(m_iDevLevel, "%s", inputdata.value.String()); } + + void InputNewLine( inputdata_t &inputdata ) { LCMsg("\n"); } + void InputDevNewLine( inputdata_t &inputdata ) { LCDevMsg(m_iDevLevel, "\n"); } + + void InputClearConsole( inputdata_t &inputdata ) { engine->ServerCommand("clear"); } + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(logic_console, CLogicConsole); + + +BEGIN_DATADESC( CLogicConsole ) + + DEFINE_INPUT( m_iDevLevel, FIELD_INTEGER, "SetDevLvl" ), + DEFINE_INPUT( m_MsgColor, FIELD_COLOR32, "SetMsgColor" ), + DEFINE_INPUT( m_WarningColor, FIELD_COLOR32, "SetWarningColor" ), + DEFINE_INPUT( m_bNewLineNotAuto, FIELD_BOOLEAN, "SetNewLineNotAuto" ), + + DEFINE_INPUTFUNC( FIELD_STRING, "SendMsg", InputSendMsg ), + DEFINE_INPUTFUNC( FIELD_STRING, "SendWarning", InputSendWarning ), + DEFINE_INPUTFUNC( FIELD_STRING, "SendDevMsg", InputSendDevMsg ), + DEFINE_INPUTFUNC( FIELD_STRING, "SendDevWarning", InputSendDevWarning ), + + DEFINE_INPUTFUNC( FIELD_VOID, "NewLine", InputNewLine ), + DEFINE_INPUTFUNC( FIELD_VOID, "DevNewLine", InputDevNewLine ), + +END_DATADESC() + +ConVar sv_allow_logic_convar("sv_allow_logic_convar", "1"); +//----------------------------------------------------------------------------- +// Purpose: Gets console variables for the evil mapper. +//----------------------------------------------------------------------------- +class CLogicConvar : public CLogicalEntity +{ +public: + + DECLARE_CLASS( CLogicConvar, CLogicalEntity ); + + // Keys + string_t m_iszConVar; + string_t m_iszCompareValue; + + const char *GetConVarString( inputdata_t &inputdata ); + + // Inputs + void InputGetValue( inputdata_t &inputdata ); + void InputTest( inputdata_t &inputdata ); + + // Outputs + COutputEvent m_OnTrue; + COutputEvent m_OnFalse; + COutputString m_OutValue; + COutputEvent m_OnDenied; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(logic_convar, CLogicConvar); + + +BEGIN_DATADESC( CLogicConvar ) + + DEFINE_INPUT( m_iszConVar, FIELD_STRING, "SetConVar" ), + DEFINE_INPUT( m_iszCompareValue, FIELD_STRING, "SetTestValue" ), + + DEFINE_INPUTFUNC( FIELD_VOID, "GetValue", InputGetValue ), + DEFINE_INPUTFUNC( FIELD_VOID, "Test", InputTest ), + + DEFINE_OUTPUT(m_OnTrue, "OnTrue"), + DEFINE_OUTPUT(m_OnFalse, "OnFalse"), + DEFINE_OUTPUT(m_OutValue, "OutValue"), + DEFINE_OUTPUT(m_OnDenied, "OnDenied"), + +END_DATADESC() + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +const char *CLogicConvar::GetConVarString( inputdata_t &inputdata ) +{ + if (!sv_allow_logic_convar.GetBool()) + { + m_OnDenied.FireOutput(this, this); + + //return ConVarRef("", true); + return NULL; + } + + ConVarRef pCVar = ConVarRef(STRING(m_iszConVar), true); + if (!pCVar.IsValid()) + { + // It's not a convar, so check if it's a common cheat command a player might be using + CBasePlayer *pPlayer = ToBasePlayer( inputdata.pActivator ); + if (!pPlayer && AI_IsSinglePlayer()) + pPlayer = UTIL_PlayerByIndex( 1 ); + + if (pPlayer) + { + const char *pszCVar = STRING( m_iszConVar ); + if (FStrEq( pszCVar, "god" )) + return (pPlayer->GetFlags() & FL_GODMODE) ? "1" : "0"; + if (FStrEq( pszCVar, "notarget" )) + return (pPlayer->GetFlags() & FL_NOTARGET) ? "1" : "0"; + if (FStrEq( pszCVar, "noclip" )) + return (pPlayer->IsEFlagSet(EFL_NOCLIP_ACTIVE)) ? "1" : "0"; + } + + Warning("Warning: %s has invalid convar \"%s\"\n", GetDebugName(), STRING(m_iszConVar)); + } + + return pCVar.GetString(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CLogicConvar::InputGetValue( inputdata_t &inputdata ) +{ + const char *pCVarString = GetConVarString(inputdata); + if (pCVarString != NULL) + m_OutValue.Set( AllocPooledString( pCVarString ), inputdata.pActivator, this ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CLogicConvar::InputTest( inputdata_t &inputdata ) +{ + const char *pCVarString = GetConVarString(inputdata); + if (pCVarString) + { + if (Matcher_Compare( STRING( m_iszCompareValue ), pCVarString )) + { + m_OnTrue.FireOutput(inputdata.pActivator, this); + } + else + { + m_OnFalse.FireOutput(inputdata.pActivator, this); + } + } +} + +#define MAX_LOGIC_FORMAT_PARAMETERS 8 +//----------------------------------------------------------------------------- +// Purpose: Takes a string and a bunch of parameters and spits out a formatted string. +//----------------------------------------------------------------------------- +class CLogicFormat : public CLogicalEntity +{ +public: + + DECLARE_CLASS( CLogicFormat, CLogicalEntity ); + + // Keys + string_t m_iszInput; + string_t m_iszParameter[MAX_LOGIC_FORMAT_PARAMETERS]; + string_t m_iszBackupParameter; + + void FormatString(const char *szStringToFormat, char *szOutput, int outputlen); + + // Inputs + void InputGetFormattedString( inputdata_t &inputdata ); + + // Outputs + COutputString m_OutFormattedString; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(logic_format, CLogicFormat); + + +BEGIN_DATADESC( CLogicFormat ) + + DEFINE_INPUT( m_iszInput, FIELD_STRING, "SetInputValue" ), + DEFINE_INPUT( m_iszParameter[0], FIELD_STRING, "SetParameter0" ), + DEFINE_INPUT( m_iszParameter[1], FIELD_STRING, "SetParameter1" ), + DEFINE_INPUT( m_iszParameter[2], FIELD_STRING, "SetParameter2" ), + DEFINE_INPUT( m_iszParameter[3], FIELD_STRING, "SetParameter3" ), + DEFINE_INPUT( m_iszParameter[4], FIELD_STRING, "SetParameter4" ), + DEFINE_INPUT( m_iszParameter[5], FIELD_STRING, "SetParameter5" ), + DEFINE_INPUT( m_iszParameter[6], FIELD_STRING, "SetParameter6" ), + DEFINE_INPUT( m_iszParameter[7], FIELD_STRING, "SetParameter7" ), + DEFINE_INPUT( m_iszBackupParameter, FIELD_STRING, "SetBackupParameter" ), + + DEFINE_INPUTFUNC( FIELD_VOID, "GetFormattedValue", InputGetFormattedString ), + + DEFINE_OUTPUT(m_OutFormattedString, "OutFormattedValue"), + +END_DATADESC() + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CLogicFormat::InputGetFormattedString( inputdata_t &inputdata ) +{ + char szFormatted[256]; + if (m_iszInput != NULL_STRING) + { + FormatString(STRING(m_iszInput), szFormatted, sizeof(szFormatted)); + m_OutFormattedString.Set(AllocPooledString(szFormatted), inputdata.pActivator, this); + } +} + +//----------------------------------------------------------------------------- +// I'm bad at coding. +//----------------------------------------------------------------------------- +void CLogicFormat::FormatString(const char *szStringToFormat, char *szOutput, int outputlen) +{ + const char *szParameters[MAX_LOGIC_FORMAT_PARAMETERS]; + for (int i = 0; i < MAX_LOGIC_FORMAT_PARAMETERS; i++) + { + if (m_iszParameter[i] != NULL_STRING) + { + szParameters[i] = STRING(m_iszParameter[i]); + } + else if (m_iszBackupParameter != NULL_STRING) + { + szParameters[i] = STRING(m_iszBackupParameter); + } + else + { + szParameters[i] = ""; + } + } + + char szFormatted[256] = { 0 }; // Needed so garbage isn't spewed at the beginning + //Q_snprintf(szFormatted, sizeof(szFormatted), szInput, szParameters); + + char szInput[256]; + Q_strncpy(szInput, szStringToFormat, sizeof(szInput)); + + bool inparam = (szInput[0] == '{'); + int curparam = 0; + char *szToken = strtok(szInput, "{"); + while (szToken != NULL) + { + if (inparam) + { + curparam = atoi(szToken); + if (curparam < MAX_LOGIC_FORMAT_PARAMETERS /*&& szParameters[curparam] != NULL*/) //if (curparam < MAX_FORMAT_PARAMETERS) + { + Q_snprintf(szFormatted, sizeof(szFormatted), "%s%s", szFormatted, szParameters[curparam]); + } + else + { + Warning("Warning: Parameter %i out of bounds in \"%s\"\n", curparam, szStringToFormat); + + // This might not be the best way to do this, but + // reaching it is supposed to be the result of a mistake anyway. + m_iszBackupParameter != NULL_STRING ? + Q_snprintf(szFormatted, sizeof(szFormatted), "%s%s", szFormatted, STRING(m_iszBackupParameter)) : + Q_snprintf(szFormatted, sizeof(szFormatted), "%s", szFormatted); + } + + inparam = false; + szToken = strtok(NULL, "{"); + } + else + { + Q_snprintf(szFormatted, sizeof(szFormatted), "%s%s", szFormatted, szToken); + + inparam = true; + szToken = strtok(NULL, "}"); + } + } + + Q_strncpy(szOutput, szFormatted, outputlen); +} + + +//----------------------------------------------------------------------------- +// Purpose: Accesses a keyvalue from a specific entity +// Mostly ported from Half-Laugh. +//----------------------------------------------------------------------------- +class CLogicKeyfieldAccessor : public CLogicalEntity +{ + DECLARE_CLASS(CLogicKeyfieldAccessor, CLogicalEntity); + +protected: + CBaseEntity *GetTarget(CBaseEntity *pCaller, CBaseEntity *pActivator); + + virtual bool TestKey(CBaseEntity *pTarget, const char *szKeyName); + virtual bool SetKeyValue(CBaseEntity *pTarget, const char *szKeyName, const char *szValue); + virtual bool SetKeyValueBits(CBaseEntity *pTarget, const char *szKeyName, int iValue, bool bRemove = false); + + // Inputs + void InputTest(inputdata_t &inputdata); + void InputTestKey(inputdata_t &inputdata); + void InputTestTarget(inputdata_t &inputdata); + + void InputSetKey(inputdata_t &inputdata); + + void InputSetValue(inputdata_t &inputdata); + void InputAddBits(inputdata_t &inputdata); + void InputRemoveBits(inputdata_t &inputdata); + + //bool ReadUnregisteredKeyfields(CBaseEntity *pTarget, const char *szKeyName, variant_t *variant); + + COutputVariant m_OutValue; + COutputEvent m_OnFailed; + + string_t m_iszKey; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(logic_keyfield, CLogicKeyfieldAccessor); + + +BEGIN_DATADESC(CLogicKeyfieldAccessor) + +DEFINE_KEYFIELD( m_iszKey, FIELD_STRING, "keyname" ), + +// Inputs +DEFINE_INPUTFUNC(FIELD_VOID, "Test", InputTest), +DEFINE_INPUTFUNC(FIELD_STRING, "TestKey", InputTestKey), +DEFINE_INPUTFUNC(FIELD_STRING, "TestTarget", InputTestTarget), +DEFINE_INPUTFUNC(FIELD_STRING, "SetKey", InputSetKey), + +DEFINE_INPUTFUNC(FIELD_STRING, "SetValue", InputSetValue), +DEFINE_INPUTFUNC(FIELD_INTEGER, "AddBits", InputAddBits), +DEFINE_INPUTFUNC(FIELD_INTEGER, "RemoveBits", InputRemoveBits), + +DEFINE_OUTPUT( m_OutValue, "OutValue" ), +DEFINE_OUTPUT( m_OnFailed, "OnFailed" ), + +END_DATADESC() + + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +inline CBaseEntity *CLogicKeyfieldAccessor::GetTarget(CBaseEntity *pCaller, CBaseEntity *pActivator) +{ + return gEntList.FindEntityByName(NULL, m_target, this, pActivator, pCaller); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CLogicKeyfieldAccessor::TestKey(CBaseEntity *pTarget, const char *szKeyName) +{ + variant_t variant; + if (pTarget->ReadKeyField(szKeyName, &variant) || ReadUnregisteredKeyfields(pTarget, szKeyName, &variant)) + { + m_OutValue.Set(variant, pTarget, this); + return true; + } + else + { + m_OnFailed.FireOutput(pTarget, this); + return false; + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CLogicKeyfieldAccessor::SetKeyValue(CBaseEntity *pTarget, const char *szKeyName, const char *szValue) +{ + if (pTarget->KeyValue(szKeyName, szValue)) + { + // We'll still fire OutValue + variant_t variant; + if (!pTarget->ReadKeyField(szKeyName, &variant)) + ReadUnregisteredKeyfields(pTarget, szKeyName, &variant); + + m_OutValue.Set(variant, pTarget, this); + return true; + } + else + { + m_OnFailed.FireOutput(pTarget, this); + return false; + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CLogicKeyfieldAccessor::SetKeyValueBits(CBaseEntity *pTarget, const char *szKeyName, int iValue, bool bRemove) +{ + variant_t variant; + if ((pTarget->ReadKeyField(szKeyName, &variant) || ReadUnregisteredKeyfields(pTarget, szKeyName, &variant)) && variant.FieldType() == FIELD_INTEGER) + { + if (bRemove) + variant.SetInt(variant.Int() & ~iValue); + else + variant.SetInt(variant.Int() | iValue); + + pTarget->KeyValue(szKeyName, UTIL_VarArgs("%i", variant.Int())); + + m_OutValue.Set(variant, pTarget, this); + return true; + } + else + { + m_OnFailed.FireOutput(pTarget, this); + return false; + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicKeyfieldAccessor::InputTest(inputdata_t &inputdata) +{ + CBaseEntity *pTarget = GetTarget(inputdata.pCaller, inputdata.pActivator); + if (pTarget && m_iszKey != NULL_STRING) + { + TestKey(pTarget, STRING(m_iszKey)); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicKeyfieldAccessor::InputTestKey(inputdata_t &inputdata) +{ + const char *input = inputdata.value.String(); + CBaseEntity *pTarget = GetTarget(inputdata.pCaller, inputdata.pActivator); + if (input && pTarget) + { + TestKey(pTarget, input); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicKeyfieldAccessor::InputTestTarget(inputdata_t &inputdata) +{ + m_target = inputdata.value.StringID(); + CBaseEntity *pTarget = gEntList.FindEntityByName(NULL, inputdata.value.StringID(), this, inputdata.pCaller, inputdata.pActivator); + if (pTarget && m_iszKey != NULL_STRING) + { + TestKey(pTarget, STRING(m_iszKey)); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicKeyfieldAccessor::InputSetKey(inputdata_t &inputdata) +{ + m_iszKey = inputdata.value.StringID(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicKeyfieldAccessor::InputSetValue(inputdata_t &inputdata) +{ + const char *input = inputdata.value.String(); + CBaseEntity *pTarget = GetTarget(inputdata.pCaller, inputdata.pActivator); + if (input && pTarget) + { + SetKeyValue(pTarget, STRING(m_iszKey), input); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicKeyfieldAccessor::InputAddBits(inputdata_t &inputdata) +{ + int input = inputdata.value.Int(); + CBaseEntity *pTarget = GetTarget(inputdata.pCaller, inputdata.pActivator); + if (input && pTarget) + { + SetKeyValueBits(pTarget, STRING(m_iszKey), input, false); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicKeyfieldAccessor::InputRemoveBits(inputdata_t &inputdata) +{ + int input = inputdata.value.Int(); + CBaseEntity *pTarget = GetTarget(inputdata.pCaller, inputdata.pActivator); + if (input && pTarget) + { + SetKeyValueBits(pTarget, STRING(m_iszKey), input, true); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Clamps the input value between two values +//----------------------------------------------------------------------------- +class CMathClamp : public CLogicalEntity +{ +public: + + DECLARE_CLASS( CMathClamp, CLogicalEntity ); + + // Keys + variant_t m_Max; + variant_t m_Min; + + // Inputs + void InputClampValue( inputdata_t &inputdata ); + + float ClampValue(float input, float min, float max, int *bounds); + void ClampValue(variant_t var, inputdata_t *inputdata); + + // Outputs + COutputVariant m_OutValue; + COutputVariant m_OnBeforeMin; + COutputVariant m_OnBeyondMax; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(math_clamp, CMathClamp); + + +BEGIN_DATADESC( CMathClamp ) + + DEFINE_INPUT( m_Max, FIELD_INPUT, "SetMax" ), + DEFINE_INPUT( m_Min, FIELD_INPUT, "SetMin" ), + + DEFINE_INPUTFUNC( FIELD_INPUT, "ClampValue", InputClampValue ), + + DEFINE_OUTPUT(m_OutValue, "OutValue"), + DEFINE_OUTPUT(m_OnBeforeMin, "OnBeforeMin"), + DEFINE_OUTPUT(m_OnBeyondMax, "OnBeyondMax"), + +END_DATADESC() + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathClamp::InputClampValue( inputdata_t &inputdata ) +{ + ClampValue(inputdata.value, &inputdata); +} + +//----------------------------------------------------------------------------- +// "bounds" returns 1 if the number was less than min, 2 if more than max. Must not be NULL +//----------------------------------------------------------------------------- +inline float CMathClamp::ClampValue(float input, float min, float max, int *bounds) +{ + if ( max < min ) + { + Warning("WARNING: Max value (%i) less than min value (%i) in %s!\n", max, min, GetDebugName()); + return max; + } + else if( input < min ) + { + *bounds = 1; + return min; + } + else if( input > max ) + { + *bounds = 2; + return max; + } + else + return input; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathClamp::ClampValue(variant_t var, inputdata_t *inputdata) +{ + // Don't convert up here in case of invalid type + + int nBounds; + + switch (var.FieldType()) + { + case FIELD_FLOAT: + { + m_Max.Convert(var.FieldType()); + m_Min.Convert(var.FieldType()); + + var.SetFloat(ClampValue(var.Float(), m_Max.Float(), m_Min.Float(), &nBounds)); + } break; + case FIELD_INTEGER: + { + m_Max.Convert(var.FieldType()); + m_Min.Convert(var.FieldType()); + + var.SetInt(ClampValue(var.Int(), m_Max.Int(), m_Min.Int(), &nBounds)); + } break; + case FIELD_VECTOR: + { + m_Max.Convert(var.FieldType()); + m_Min.Convert(var.FieldType()); + + Vector min; + Vector max; + m_Min.Vector3D(min); + m_Max.Vector3D(max); + + Vector vec; + var.Vector3D(vec); + + vec.x = ClampValue(vec.x, min.x, max.x, &nBounds); + vec.y = ClampValue(vec.y, min.y, max.y, &nBounds); + vec.z = ClampValue(vec.z, min.z, max.z, &nBounds); + + var.SetVector3D(vec); + } break; + default: + { + Warning("Error: Unsupported value %s in math_clamp %s\n", var.GetDebug(), STRING(GetEntityName())); + return; + } + } + + if (inputdata) + { + m_OutValue.Set(var, inputdata->pActivator, this); + if (nBounds == 1) + m_OnBeforeMin.Set(var, inputdata->pActivator, this); + else if (nBounds == 2) + m_OnBeyondMax.Set(var, inputdata->pActivator, this); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Bits calculations. +//----------------------------------------------------------------------------- +class CMathBits : public CLogicalEntity +{ + DECLARE_CLASS( CMathBits, CLogicalEntity ); +private: + + bool m_bDisabled; + + bool KeyValue(const char *szKeyName, const char *szValue); + + void UpdateOutValue(CBaseEntity *pActivator, int iNewValue); + + int DrawDebugTextOverlays(void); + + // Inputs + void InputAdd( inputdata_t &inputdata ); + void InputSubtract( inputdata_t &inputdata ); + void InputShiftLeft( inputdata_t &inputdata ); + void InputShiftRight( inputdata_t &inputdata ); + void InputApplyAnd( inputdata_t &inputdata ); + void InputApplyOr( inputdata_t &inputdata ); + void InputSetValue( inputdata_t &inputdata ); + void InputSetValueNoFire( inputdata_t &inputdata ); + void InputGetValue( inputdata_t &inputdata ); + void InputEnable( inputdata_t &inputdata ); + void InputDisable( inputdata_t &inputdata ); + void InputContainsBits( inputdata_t &inputdata ); + void InputContainsAllBits( inputdata_t &inputdata ); + + // Outputs + COutputInt m_OutValue; + COutputInt m_OnGetValue; + COutputEvent m_OnTrue; + COutputEvent m_OnFalse; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(math_bits, CMathBits); + + +BEGIN_DATADESC( CMathBits ) + + // Keys + DEFINE_KEYFIELD(m_bDisabled, FIELD_BOOLEAN, "StartDisabled" ), + + // Inputs + DEFINE_INPUTFUNC(FIELD_INTEGER, "Add", InputAdd), + DEFINE_INPUTFUNC(FIELD_INTEGER, "Subtract", InputSubtract), + DEFINE_INPUTFUNC(FIELD_INTEGER, "ShiftLeft", InputShiftLeft), + DEFINE_INPUTFUNC(FIELD_INTEGER, "ShiftRight", InputShiftRight), + DEFINE_INPUTFUNC(FIELD_INTEGER, "ApplyAnd", InputApplyAnd), + DEFINE_INPUTFUNC(FIELD_INTEGER, "ApplyOr", InputApplyOr), + DEFINE_INPUTFUNC(FIELD_INTEGER, "SetValue", InputSetValue), + DEFINE_INPUTFUNC(FIELD_INTEGER, "SetValueNoFire", InputSetValueNoFire), + DEFINE_INPUTFUNC(FIELD_VOID, "GetValue", InputGetValue), + DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), + DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), + DEFINE_INPUTFUNC(FIELD_INTEGER, "ContainsBits", InputContainsBits), + DEFINE_INPUTFUNC(FIELD_INTEGER, "ContainsAllBits", InputContainsAllBits), + + // Outputs + DEFINE_OUTPUT(m_OutValue, "OutValue"), + DEFINE_OUTPUT(m_OnGetValue, "OnGetValue"), + DEFINE_OUTPUT(m_OnTrue, "OnTrue"), + DEFINE_OUTPUT(m_OnFalse, "OnFalse"), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: Handles key values from the BSP before spawn is called. +//----------------------------------------------------------------------------- +bool CMathBits::KeyValue(const char *szKeyName, const char *szValue) +{ + // + // Set the initial value of the counter. + // + if (!stricmp(szKeyName, "startvalue")) + { + m_OutValue.Init(atoi(szValue)); + return(true); + } + + return(BaseClass::KeyValue(szKeyName, szValue)); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for adding to the accumulator value. +// Input : Bit value to add. +//----------------------------------------------------------------------------- +void CMathBits::InputAdd( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Bits %s ignoring ADD because it is disabled\n", GetDebugName() ); + return; + } + + int iNewValue = m_OutValue.Get() | inputdata.value.Int(); + UpdateOutValue( inputdata.pActivator, iNewValue ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for subtracting from the current value. +// Input : Bit value to subtract. +//----------------------------------------------------------------------------- +void CMathBits::InputSubtract( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Bits %s ignoring SUBTRACT because it is disabled\n", GetDebugName() ); + return; + } + + int iNewValue = m_OutValue.Get() & ~inputdata.value.Int(); + UpdateOutValue( inputdata.pActivator, iNewValue ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for shifting from the current value. +// Input : Bit value to shift by. +//----------------------------------------------------------------------------- +void CMathBits::InputShiftLeft( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Bits %s ignoring SHIFTLEFT because it is disabled\n", GetDebugName() ); + return; + } + + int iNewValue = m_OutValue.Get() << inputdata.value.Int(); + UpdateOutValue( inputdata.pActivator, iNewValue ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for shifting from the current value. +// Input : Bit value to shift by. +//----------------------------------------------------------------------------- +void CMathBits::InputShiftRight( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Bits %s ignoring SHIFTRIGHT because it is disabled\n", GetDebugName() ); + return; + } + + int iNewValue = m_OutValue.Get() >> inputdata.value.Int(); + UpdateOutValue( inputdata.pActivator, iNewValue ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for applying & to the current value. +// Input : Bit value to shift by. +//----------------------------------------------------------------------------- +void CMathBits::InputApplyAnd( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Bits %s ignoring APPLYAND because it is disabled\n", GetDebugName() ); + return; + } + + int iNewValue = m_OutValue.Get() & inputdata.value.Int(); + UpdateOutValue( inputdata.pActivator, iNewValue ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for applying | to the current value. +// Input : Bit value to shift by. +//----------------------------------------------------------------------------- +void CMathBits::InputApplyOr( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Bits %s ignoring APPLYOR because it is disabled\n", GetDebugName() ); + return; + } + + int iNewValue = m_OutValue.Get() | inputdata.value.Int(); + UpdateOutValue( inputdata.pActivator, iNewValue ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for updating the value. +// Input : Bit value to set. +//----------------------------------------------------------------------------- +void CMathBits::InputSetValue( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Bits %s ignoring SETVALUE because it is disabled\n", GetDebugName() ); + return; + } + + UpdateOutValue( inputdata.pActivator, inputdata.value.Int() ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for updating the value. +// Input : Bit value to set. +//----------------------------------------------------------------------------- +void CMathBits::InputSetValueNoFire( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Bits %s ignoring SETVALUENOFIRE because it is disabled\n", GetDebugName() ); + return; + } + + m_OutValue.Init( inputdata.value.Int() ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathBits::InputGetValue( inputdata_t &inputdata ) +{ + int iOutValue = m_OutValue.Get(); + m_OnGetValue.Set( iOutValue, inputdata.pActivator, inputdata.pCaller ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for checking whether a bit is stored. +// Input : Bit value to check. +//----------------------------------------------------------------------------- +void CMathBits::InputContainsBits( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Bits %s ignoring CONTAINS BITS because it is disabled\n", GetDebugName() ); + return; + } + + if (m_OutValue.Get() & inputdata.value.Int()) + m_OnTrue.FireOutput(inputdata.pActivator, this); + else + m_OnFalse.FireOutput(inputdata.pActivator, this); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for checking whether all of the specified bits are stored. +// Input : Bit value to check. +//----------------------------------------------------------------------------- +void CMathBits::InputContainsAllBits( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Bits %s ignoring CONTAINS ALL BITS because it is disabled\n", GetDebugName() ); + return; + } + + bool bResult = false; + int iInput = inputdata.value.Int(); + int iValue = m_OutValue.Get(); + + for (int i = 1, n = 0; n < 32; (i <<= 1), n++) + { + DevMsg("%i\n", i); + if (iInput & i) + { + if (!(iValue & i)) + { + DevMsg("%i does not go into %i\n", i, iValue); + bResult = false; + break; + } + else if (!bResult) + { + bResult = true; + } + } + } + + if (bResult) + m_OnTrue.FireOutput(inputdata.pActivator, this); + else + m_OnFalse.FireOutput(inputdata.pActivator, this); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathBits::InputEnable( inputdata_t &inputdata ) +{ + m_bDisabled = false; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathBits::InputDisable( inputdata_t &inputdata ) +{ + m_bDisabled = true; +} + +//----------------------------------------------------------------------------- +// Purpose: Sets the value to the new value, firing the output value. +// Input : iNewValue - Value to set. +//----------------------------------------------------------------------------- +void CMathBits::UpdateOutValue(CBaseEntity *pActivator, int iNewValue) +{ + m_OutValue.Set(iNewValue, pActivator, this); +} + +//----------------------------------------------------------------------------- +// Purpose: Draw any debug text overlays +// Input : +// Output : Current text offset from the top +//----------------------------------------------------------------------------- +int CMathBits::DrawDebugTextOverlays( void ) +{ + int text_offset = BaseClass::DrawDebugTextOverlays(); + + if (m_debugOverlays & OVERLAY_TEXT_BIT) + { + char tempstr[512]; + + Q_snprintf(tempstr,sizeof(tempstr),"current value: %i", m_OutValue.Get()); + EntityText(text_offset,tempstr,0); + text_offset++; + + if( m_bDisabled ) + { + Q_snprintf(tempstr,sizeof(tempstr),"*DISABLED*"); + } + else + { + Q_snprintf(tempstr,sizeof(tempstr),"Enabled."); + } + EntityText(text_offset,tempstr,0); + text_offset++; + + } + return text_offset; +} + +//----------------------------------------------------------------------------- +// Purpose: Vector calculations. +//----------------------------------------------------------------------------- +class CMathVector : public CLogicalEntity +{ + DECLARE_CLASS( CMathVector, CLogicalEntity ); +private: + + bool m_bDisabled; + + bool KeyValue(const char *szKeyName, const char *szValue); + bool KeyValue( const char *szKeyName, const Vector &vecValue ); + + void UpdateOutValue(CBaseEntity *pActivator, Vector &vecNewValue); + + int DrawDebugTextOverlays(void); + + // Inputs + void InputAdd( inputdata_t &inputdata ); + void InputSubtract( inputdata_t &inputdata ); + void InputDivide( inputdata_t &inputdata ); + void InputMultiply( inputdata_t &inputdata ); + void InputSetValue( inputdata_t &inputdata ); + void InputSetValueNoFire( inputdata_t &inputdata ); + void InputGetValue( inputdata_t &inputdata ); + void InputEnable( inputdata_t &inputdata ); + void InputDisable( inputdata_t &inputdata ); + + void InputNormalize( inputdata_t &inputdata ); + + void SetCoordinate(float value, char coord, CBaseEntity *pActivator); + void GetCoordinate(char coord, CBaseEntity *pActivator); + void AddCoordinate(float value, char coord, CBaseEntity *pActivator); + void SubtractCoordinate(float value, char coord, CBaseEntity *pActivator); + + void InputSetX( inputdata_t &inputdata ) { SetCoordinate(inputdata.value.Float(), 'X', inputdata.pActivator); } + void InputSetY( inputdata_t &inputdata ) { SetCoordinate(inputdata.value.Float(), 'Y', inputdata.pActivator); } + void InputSetZ( inputdata_t &inputdata ) { SetCoordinate(inputdata.value.Float(), 'Z', inputdata.pActivator); } + void InputGetX( inputdata_t &inputdata ) { GetCoordinate('X', inputdata.pActivator); } + void InputGetY( inputdata_t &inputdata ) { GetCoordinate('Y', inputdata.pActivator); } + void InputGetZ( inputdata_t &inputdata ) { GetCoordinate('Z', inputdata.pActivator); } + void InputAddX( inputdata_t &inputdata ) { AddCoordinate(inputdata.value.Float(), 'X', inputdata.pActivator); } + void InputAddY( inputdata_t &inputdata ) { AddCoordinate(inputdata.value.Float(), 'Y', inputdata.pActivator); } + void InputAddZ( inputdata_t &inputdata ) { AddCoordinate(inputdata.value.Float(), 'Z', inputdata.pActivator); } + void InputSubtractX( inputdata_t &inputdata ) { SubtractCoordinate(inputdata.value.Float(), 'X', inputdata.pActivator); } + void InputSubtractY( inputdata_t &inputdata ) { SubtractCoordinate(inputdata.value.Float(), 'Y', inputdata.pActivator); } + void InputSubtractZ( inputdata_t &inputdata ) { SubtractCoordinate(inputdata.value.Float(), 'Z', inputdata.pActivator); } + + // Outputs + COutputVector m_OutValue; + COutputFloat m_OutX; + COutputFloat m_OutY; + COutputFloat m_OutZ; + + COutputVector m_OnGetValue; + COutputFloat m_OnGetX; + COutputFloat m_OnGetY; + COutputFloat m_OnGetZ; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(math_vector, CMathVector); + + +BEGIN_DATADESC( CMathVector ) + + // Keys + DEFINE_KEYFIELD(m_bDisabled, FIELD_BOOLEAN, "StartDisabled" ), + + // Inputs + DEFINE_INPUTFUNC(FIELD_VECTOR, "Add", InputAdd), + DEFINE_INPUTFUNC(FIELD_VECTOR, "Subtract", InputSubtract), + DEFINE_INPUTFUNC(FIELD_VECTOR, "Divide", InputDivide), + DEFINE_INPUTFUNC(FIELD_VECTOR, "Multiply", InputMultiply), + DEFINE_INPUTFUNC(FIELD_VECTOR, "SetValue", InputSetValue), + DEFINE_INPUTFUNC(FIELD_VECTOR, "SetValueNoFire", InputSetValueNoFire), + DEFINE_INPUTFUNC(FIELD_VOID, "GetValue", InputGetValue), + DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), + DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), + + DEFINE_INPUTFUNC(FIELD_VOID, "Normalize", InputNormalize), + + DEFINE_INPUTFUNC(FIELD_FLOAT, "SetX", InputSetX), + DEFINE_INPUTFUNC(FIELD_FLOAT, "SetY", InputSetY), + DEFINE_INPUTFUNC(FIELD_FLOAT, "SetZ", InputSetZ), + DEFINE_INPUTFUNC(FIELD_VOID, "GetX", InputGetX), + DEFINE_INPUTFUNC(FIELD_VOID, "GetY", InputGetY), + DEFINE_INPUTFUNC(FIELD_VOID, "GetZ", InputGetZ), + DEFINE_INPUTFUNC(FIELD_FLOAT, "AddX", InputAddX), + DEFINE_INPUTFUNC(FIELD_FLOAT, "AddY", InputAddY), + DEFINE_INPUTFUNC(FIELD_FLOAT, "AddZ", InputAddZ), + DEFINE_INPUTFUNC(FIELD_FLOAT, "SubtractX", InputSubtractX), + DEFINE_INPUTFUNC(FIELD_FLOAT, "SubtractY", InputSubtractY), + DEFINE_INPUTFUNC(FIELD_FLOAT, "SubtractZ", InputSubtractZ), + + // Outputs + DEFINE_OUTPUT(m_OutValue, "OutValue"), + DEFINE_OUTPUT(m_OutX, "OutX"), + DEFINE_OUTPUT(m_OutY, "OutY"), + DEFINE_OUTPUT(m_OutZ, "OutZ"), + + DEFINE_OUTPUT(m_OnGetValue, "OnGetValue"), + DEFINE_OUTPUT(m_OnGetX, "OnGetX"), + DEFINE_OUTPUT(m_OnGetY, "OnGetY"), + DEFINE_OUTPUT(m_OnGetZ, "OnGetZ"), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: Handles key values from the BSP before spawn is called. +//----------------------------------------------------------------------------- +bool CMathVector::KeyValue(const char *szKeyName, const char *szValue) +{ + // + // Set the initial value of the counter. + // + if (!stricmp(szKeyName, "startvalue")) + { + Vector vec; + UTIL_StringToVector( vec.Base(), szValue ); + m_OutValue.Init(vec); + return(true); + } + + return(BaseClass::KeyValue(szKeyName, szValue)); +} + +//----------------------------------------------------------------------------- +// Purpose: Handles key values from the BSP before spawn is called. +//----------------------------------------------------------------------------- +bool CMathVector::KeyValue( const char *szKeyName, const Vector &vecValue ) +{ + // + // Set the initial value of the counter. + // + if (!stricmp(szKeyName, "startvalue")) + { + m_OutValue.Init(vecValue); + return true; + } + + // So, CLogicalEntity descends from CBaseEntity... + // Yup. + // ...and CBaseEntity has a version of KeyValue that takes vectors. + // Yup. + // Since it's virtual, I could easily override it just like I could with a KeyValue that takes strings, right? + // Sounds right to me. + // So let me override it. + // *No suitable function exists* + return CBaseEntity::KeyValue(szKeyName, vecValue); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for adding to the accumulator value. +// Input : Bit value to add. +//----------------------------------------------------------------------------- +void CMathVector::InputAdd( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Vector %s ignoring ADD because it is disabled\n", GetDebugName() ); + return; + } + + Vector vec; + inputdata.value.Vector3D(vec); + Vector cur; + m_OutValue.Get(cur); + UpdateOutValue( inputdata.pActivator, cur + vec ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for subtracting from the current value. +// Input : Bit value to subtract. +//----------------------------------------------------------------------------- +void CMathVector::InputSubtract( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Vector %s ignoring SUBTRACT because it is disabled\n", GetDebugName() ); + return; + } + + Vector vec; + inputdata.value.Vector3D(vec); + Vector cur; + m_OutValue.Get(cur); + UpdateOutValue( inputdata.pActivator, cur - vec ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for multiplying the current value. +// Input : Float value to multiply the value by. +//----------------------------------------------------------------------------- +void CMathVector::InputDivide( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Vector %s ignoring DIVIDE because it is disabled\n", GetDebugName() ); + return; + } + + Vector vec; + inputdata.value.Vector3D(vec); + Vector cur; + m_OutValue.Get(cur); + + if (vec.x != 0) + cur.x /= vec.x; + if (vec.y != 0) + cur.y /= vec.y; + if (vec.z != 0) + cur.z /= vec.z; + + UpdateOutValue( inputdata.pActivator, cur ); + + //if (vec.x != 0 && vec.y != 0 && vec.z != 0) + //{ + // UpdateOutValue( inputdata.pActivator, cur / vec ); + //} + //else + //{ + // DevMsg( 1, "LEVEL DESIGN ERROR: Divide by zero in math_vector\n" ); + // UpdateOutValue( inputdata.pActivator, cur ); + //} +} + + +//----------------------------------------------------------------------------- +// Purpose: Input handler for multiplying the current value. +// Input : Float value to multiply the value by. +//----------------------------------------------------------------------------- +void CMathVector::InputMultiply( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Vector %s ignoring MULTIPLY because it is disabled\n", GetDebugName() ); + return; + } + + Vector vec; + inputdata.value.Vector3D(vec); + Vector cur; + m_OutValue.Get(cur); + UpdateOutValue( inputdata.pActivator, cur * vec ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for updating the value. +// Input : Bit value to set. +//----------------------------------------------------------------------------- +void CMathVector::InputSetValue( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Vector %s ignoring SETVALUE because it is disabled\n", GetDebugName() ); + return; + } + + Vector vec; + inputdata.value.Vector3D(vec); + UpdateOutValue( inputdata.pActivator, vec ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for updating the value. +// Input : Bit value to set. +//----------------------------------------------------------------------------- +void CMathVector::InputSetValueNoFire( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Vector %s ignoring SETVALUENOFIRE because it is disabled\n", GetDebugName() ); + return; + } + + Vector vec; + inputdata.value.Vector3D(vec); + m_OutValue.Init( vec ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathVector::InputGetValue( inputdata_t &inputdata ) +{ + Vector cur; + m_OutValue.Get(cur); + m_OnGetValue.Set( cur, inputdata.pActivator, inputdata.pCaller ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathVector::InputEnable( inputdata_t &inputdata ) +{ + m_bDisabled = false; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathVector::InputDisable( inputdata_t &inputdata ) +{ + m_bDisabled = true; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathVector::InputNormalize( inputdata_t &inputdata ) +{ + if( m_bDisabled ) + { + DevMsg("Math Vector %s ignoring NORMALIZE because it is disabled\n", GetDebugName() ); + return; + } + + Vector cur; + m_OutValue.Get(cur); + VectorNormalize(cur); + UpdateOutValue( inputdata.pActivator, cur ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathVector::SetCoordinate(float value, char coord, CBaseEntity *pActivator) +{ + if( m_bDisabled ) + { + DevMsg("Math Vector %s ignoring SET%c because it is disabled\n", GetDebugName(), coord ); + return; + } + + Vector vec; + m_OutValue.Get(vec); + switch (coord) + { + case 'X': vec.x = value; break; + case 'Y': vec.y = value; break; + case 'Z': vec.z = value; break; + } + UpdateOutValue( pActivator, vec ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathVector::GetCoordinate(char coord, CBaseEntity *pActivator) +{ + if( m_bDisabled ) + { + DevMsg("Math Vector %s ignoring SET%c because it is disabled\n", GetDebugName(), coord ); + return; + } + + Vector vec; + m_OutValue.Get(vec); + switch (coord) + { + case 'X': m_OnGetX.Set(vec.x, pActivator, this); break; + case 'Y': m_OnGetY.Set(vec.y, pActivator, this); break; + case 'Z': m_OnGetZ.Set(vec.z, pActivator, this); break; + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathVector::AddCoordinate(float value, char coord, CBaseEntity *pActivator) +{ + if( m_bDisabled ) + { + DevMsg("Math Vector %s ignoring ADD%c because it is disabled\n", GetDebugName(), coord ); + return; + } + + Vector vec; + m_OutValue.Get(vec); + switch (coord) + { + case 'X': vec.x += value; break; + case 'Y': vec.y += value; break; + case 'Z': vec.z += value; break; + } + UpdateOutValue( pActivator, vec ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathVector::SubtractCoordinate(float value, char coord, CBaseEntity *pActivator) +{ + if( m_bDisabled ) + { + DevMsg("Math Vector %s ignoring SUBTRACT%c because it is disabled\n", GetDebugName(), coord ); + return; + } + + Vector vec; + m_OutValue.Get(vec); + switch (coord) + { + case 'X': vec.x += value; break; + case 'Y': vec.y += value; break; + case 'Z': vec.z += value; break; + } + UpdateOutValue( pActivator, vec ); +} + +//----------------------------------------------------------------------------- +// Purpose: Sets the value to the new value, firing the output value. +// Input : vecNewValue - Value to set. +//----------------------------------------------------------------------------- +void CMathVector::UpdateOutValue(CBaseEntity *pActivator, Vector &vecNewValue) +{ + m_OutValue.Set(vecNewValue, pActivator, this); + + m_OutX.Set(vecNewValue.x, pActivator, this); + m_OutY.Set(vecNewValue.y, pActivator, this); + m_OutZ.Set(vecNewValue.z, pActivator, this); +} + +//----------------------------------------------------------------------------- +// Purpose: Draw any debug text overlays +// Input : +// Output : Current text offset from the top +//----------------------------------------------------------------------------- +int CMathVector::DrawDebugTextOverlays( void ) +{ + int text_offset = BaseClass::DrawDebugTextOverlays(); + + if (m_debugOverlays & OVERLAY_TEXT_BIT) + { + char tempstr[512]; + Vector cur; + m_OutValue.Get(cur); + + Q_snprintf(tempstr, sizeof(tempstr), "current value: [%g %g %g]", (double)cur[0], (double)cur[1], (double)cur[2]); + EntityText(text_offset,tempstr,0); + text_offset++; + + if( m_bDisabled ) + { + Q_snprintf(tempstr,sizeof(tempstr),"*DISABLED*"); + } + else + { + Q_snprintf(tempstr,sizeof(tempstr),"Enabled."); + } + EntityText(text_offset,tempstr,0); + text_offset++; + + } + return text_offset; +} + +//----------------------------------------------------------------------------- +// Purpose: Accesses/modifies any field in a datadesc based on its internal name. +// Oh boy. +//----------------------------------------------------------------------------- +class CLogicFieldAccessor : public CLogicKeyfieldAccessor +{ + DECLARE_CLASS(CLogicFieldAccessor, CLogicKeyfieldAccessor); + +private: + bool TestKey(CBaseEntity *pTarget, const char *szKeyName); + bool SetKeyValue(CBaseEntity *pTarget, const char *szKeyName, const char *szValue); + bool SetKeyValueBits(CBaseEntity *pTarget, const char *szKeyName, int iValue, bool bRemove = false); + + //DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(logic_datadesc_accessor, CLogicFieldAccessor); + + +//BEGIN_DATADESC(CLogicFieldAccessor) + +//END_DATADESC() + + + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CLogicFieldAccessor::TestKey(CBaseEntity *pTarget, const char *szKeyName) +{ + variant_t var; + for ( datamap_t *dmap = pTarget->GetDataDescMap(); dmap != NULL; dmap = dmap->baseMap ) + { + // search through all the readable fields in the data description, looking for a match + for ( int i = 0; i < dmap->dataNumFields; i++ ) + { + if ( dmap->dataDesc[i].flags & (FTYPEDESC_SAVE | FTYPEDESC_KEY) ) + { + DevMsg("Field Name: %s,\n", dmap->dataDesc[i].fieldName); + if ( Matcher_NamesMatch(szKeyName, dmap->dataDesc[i].fieldName) ) + { + fieldtype_t fieldtype = dmap->dataDesc[i].fieldType; + switch (fieldtype) + { + case FIELD_TIME: fieldtype = FIELD_FLOAT; break; + case FIELD_MODELNAME: fieldtype = FIELD_STRING; break; + case FIELD_SOUNDNAME: fieldtype = FIELD_STRING; break; + // There's definitely more of them. Add when demand becomes prevalent + } + + var.Set( fieldtype, ((char*)pTarget) + dmap->dataDesc[i].fieldOffset[ TD_OFFSET_NORMAL ] ); + DevMsg("FIELD TYPE: %i\n", fieldtype); + m_OutValue.Set(var, pTarget, this); + return true; + } + } + } + } + + m_OnFailed.FireOutput(pTarget, this); + return false; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CLogicFieldAccessor::SetKeyValue(CBaseEntity *pTarget, const char *szKeyName, const char *szValue) +{ + for ( datamap_t *dmap = pTarget->GetDataDescMap(); dmap != NULL; dmap = dmap->baseMap ) + { + // search through all the readable fields in the data description, looking for a match + for ( int i = 0; i < dmap->dataNumFields; i++ ) + { + if ( dmap->dataDesc[i].flags & (FTYPEDESC_SAVE | FTYPEDESC_KEY) ) + { + DevMsg("Field Name: %s,\n", dmap->dataDesc[i].fieldName); + if ( Matcher_NamesMatch(szKeyName, dmap->dataDesc[i].fieldName) ) + { + // Copied from ::ParseKeyvalue... + fieldtype_t fieldtype = FIELD_VOID; + typedescription_t *pField = &dmap->dataDesc[i]; + char *data = Datadesc_SetFieldString( szValue, pTarget, pField, &fieldtype ); + + if (!data) + { + Warning( "%s cannot set field of type %i.\n", GetDebugName(), dmap->dataDesc[i].fieldType ); + } + else if (fieldtype != FIELD_VOID) + { + variant_t var; + var.Set(fieldtype, data); + m_OutValue.Set(var, pTarget, this); + return true; + } + } + } + } + } + + m_OnFailed.FireOutput(pTarget, this); + return false; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CLogicFieldAccessor::SetKeyValueBits(CBaseEntity *pTarget, const char *szKeyName, int iValue, bool bRemove) +{ + variant_t var; + for ( datamap_t *dmap = pTarget->GetDataDescMap(); dmap != NULL; dmap = dmap->baseMap ) + { + // search through all the readable fields in the data description, looking for a match + for ( int i = 0; i < dmap->dataNumFields; i++ ) + { + if ( dmap->dataDesc[i].flags & (FTYPEDESC_SAVE | FTYPEDESC_KEY) ) + { + DevMsg("Field Name: %s,\n", dmap->dataDesc[i].fieldName); + if ( Matcher_NamesMatch(szKeyName, dmap->dataDesc[i].fieldName) ) + { + fieldtype_t fieldtype = dmap->dataDesc[i].fieldType; + if (fieldtype != FIELD_INTEGER) + break; + + var.Set( fieldtype, ((char*)pTarget) + dmap->dataDesc[i].fieldOffset[ TD_OFFSET_NORMAL ] ); + + if (bRemove) + var.SetInt(var.Int() & ~iValue); + else + var.SetInt(var.Int() | iValue); + + DevMsg("FIELD TYPE: %i\n", fieldtype); + m_OutValue.Set(var, pTarget, this); + return true; + } + } + } + } + + m_OnFailed.FireOutput(pTarget, this); + return false; +} + +//----------------------------------------------------------------------------- +// Purpose: Passes global variables, like curtime. +//----------------------------------------------------------------------------- +class CGameGlobalVars : public CLogicalEntity +{ + DECLARE_CLASS( CGameGlobalVars, CLogicalEntity ); +private: + + // Inputs + void InputGetCurtime( inputdata_t &inputdata ) { m_OutCurtime.Set(gpGlobals->curtime, inputdata.pActivator, this); } + void InputGetFrameCount( inputdata_t &inputdata ) { m_OutFrameCount.Set(gpGlobals->framecount, inputdata.pActivator, this); } + void InputGetFrametime( inputdata_t &inputdata ) { m_OutFrametime.Set(gpGlobals->frametime, inputdata.pActivator, this); } + void InputGetTickCount( inputdata_t &inputdata ) { m_OutTickCount.Set(gpGlobals->tickcount, inputdata.pActivator, this); } + void InputGetIntervalPerTick( inputdata_t &inputdata ) { m_OutIntervalPerTick.Set(gpGlobals->interval_per_tick, inputdata.pActivator, this); } + + // Outputs + COutputFloat m_OutCurtime; + COutputInt m_OutFrameCount; + COutputFloat m_OutFrametime; + COutputInt m_OutTickCount; + COutputInt m_OutIntervalPerTick; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(game_globalvars, CGameGlobalVars); + + +BEGIN_DATADESC( CGameGlobalVars ) + + // Inputs + DEFINE_INPUTFUNC( FIELD_VOID, "GetCurtime", InputGetCurtime ), + DEFINE_INPUTFUNC( FIELD_VOID, "GetFrameCount", InputGetFrameCount ), + DEFINE_INPUTFUNC( FIELD_VOID, "GetFrametime", InputGetFrametime ), + DEFINE_INPUTFUNC( FIELD_VOID, "GetTickCount", InputGetTickCount ), + DEFINE_INPUTFUNC( FIELD_VOID, "GetIntervalPerTick", InputGetIntervalPerTick ), + + // Outputs + DEFINE_OUTPUT(m_OutCurtime, "OutCurtime"), + DEFINE_OUTPUT(m_OutFrameCount, "OutFrameCount"), + DEFINE_OUTPUT(m_OutFrametime, "OutFrametime"), + DEFINE_OUTPUT(m_OutTickCount, "OutTickCount"), + DEFINE_OUTPUT(m_OutIntervalPerTick, "OutIntervalPerTick"), + +END_DATADESC() + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//void CGameGlobalVars::InputGetCurtime( inputdata_t &inputdata ) +//{ +// m_OutCurtime.Set(gpGlobals->curtime, inputdata.pActivator, this); +//} + + +#define MathModCalc(val1, val2, op) \ + switch (op) \ + { \ + case '+': val1 += val2; break; \ + case '-': val1 -= val2; break; \ + case '*': val1 *= val2; break; \ + case '/': val1 /= val2; break; \ + } \ + +//----------------------------------------------------------------------------- +// Purpose: Modifies values on the fly. +//----------------------------------------------------------------------------- +class CMathMod : public CLogicalEntity +{ + DECLARE_CLASS( CMathMod, CLogicalEntity ); +private: + + bool KeyValue(const char *szKeyName, const char *szValue); + + // Inputs + void InputSetMod( inputdata_t &inputdata ); + void InputSetOperator( inputdata_t &inputdata ); + + void InputModInt( inputdata_t &inputdata ); + void InputModFloat( inputdata_t &inputdata ); + void InputModVector( inputdata_t &inputdata ); + + // Outputs + COutputInt m_OutInt; + COutputFloat m_OutFloat; + COutputVector m_OutVector; + + int m_Operator; + + variant_t m_Mod; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(math_mod, CMathMod); + + +BEGIN_DATADESC( CMathMod ) + + DEFINE_KEYFIELD( m_Operator, FIELD_INTEGER, "SetOperator" ), + + // Inputs + DEFINE_INPUTFUNC( FIELD_INPUT, "SetMod", InputSetMod ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetOperator", InputSetOperator ), + + DEFINE_INPUTFUNC( FIELD_INTEGER, "ModInt", InputModInt ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "ModFloat", InputModFloat ), + DEFINE_INPUTFUNC( FIELD_VECTOR, "ModVector", InputModVector ), + + // Outputs + DEFINE_OUTPUT(m_OutInt, "OutInt"), + DEFINE_OUTPUT(m_OutFloat, "OutFloat"), + DEFINE_OUTPUT(m_OutVector, "OutVector"), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: Handles key values from the BSP before spawn is called. +//----------------------------------------------------------------------------- +bool CMathMod::KeyValue(const char *szKeyName, const char *szValue) +{ + if (!stricmp(szKeyName, "startvalue")) + { + // It converts later anyway + m_Mod.SetString(AllocPooledString(szValue)); + return true; + } + + return BaseClass::KeyValue(szKeyName, szValue); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathMod::InputSetMod( inputdata_t &inputdata ) +{ + m_Mod = inputdata.value; + //if (inputdata.value.FieldType() == FIELD_STRING) + // m_Mod = Variant_Parse(inputdata.value.String()); + //else + // m_Mod = inputdata.value; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathMod::InputSetOperator( inputdata_t &inputdata ) +{ + m_Operator = inputdata.value.String()[0]; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathMod::InputModInt( inputdata_t &inputdata ) +{ + m_Mod.Convert(FIELD_INTEGER); + + DevMsg("Operator is %c you see\n", m_Operator); + + int out = inputdata.value.Int(); + MathModCalc(out, m_Mod.Int(), m_Operator); + + m_OutInt.Set( out, inputdata.pActivator, this ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathMod::InputModFloat( inputdata_t &inputdata ) +{ + m_Mod.Convert(FIELD_FLOAT); + + float out = inputdata.value.Float(); + MathModCalc(out, m_Mod.Float(), m_Operator); + + m_OutFloat.Set( out, inputdata.pActivator, this ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathMod::InputModVector( inputdata_t &inputdata ) +{ + m_Mod.Convert(FIELD_VECTOR); + + Vector out; + inputdata.value.Vector3D(out); + Vector mod; + m_Mod.Vector3D(mod); + MathModCalc(out, mod, m_Operator); + + m_OutVector.Set( out, inputdata.pActivator, this ); +} + +//----------------------------------------------------------------------------- +// Purpose: Gets an entity's model information. +//----------------------------------------------------------------------------- +class CLogicModelInfo : public CLogicalEntity +{ + DECLARE_CLASS( CLogicModelInfo, CLogicalEntity ); +private: + + CBaseAnimating *GetTarget(inputdata_t &inputdata); + + // Inputs + //void InputSetTarget( inputdata_t &inputdata ) { BaseClass::InputSetTarget(inputdata); m_hTarget = NULL; } + void InputGetNumSkins( inputdata_t &inputdata ); + void InputLookupSequence( inputdata_t &inputdata ); + + // Outputs + COutputInt m_OutNumSkins; + COutputInt m_OnHasSequence; + COutputEvent m_OnLacksSequence; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(logic_modelinfo, CLogicModelInfo); + + +BEGIN_DATADESC( CLogicModelInfo ) + + // Inputs + DEFINE_INPUTFUNC( FIELD_VOID, "GetNumSkins", InputGetNumSkins ), + DEFINE_INPUTFUNC( FIELD_STRING, "LookupSequence", InputLookupSequence ), + + // Outputs + DEFINE_OUTPUT(m_OutNumSkins, "OutNumSkins"), + DEFINE_OUTPUT(m_OnHasSequence, "OnHasSequence"), + DEFINE_OUTPUT(m_OnLacksSequence, "OnLacksSequence"), + +END_DATADESC() + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline CBaseAnimating *CLogicModelInfo::GetTarget(inputdata_t &inputdata) +{ + CBaseEntity *pEntity = gEntList.FindEntityByName(NULL, STRING(m_target), this, inputdata.pActivator, inputdata.pCaller); + if (!pEntity || !pEntity->GetBaseAnimating()) + return NULL; + return pEntity->GetBaseAnimating(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CLogicModelInfo::InputGetNumSkins( inputdata_t &inputdata ) +{ + CBaseAnimating *pAnimating = GetTarget(inputdata); + if (pAnimating && pAnimating->GetModelPtr()) + { + m_OutNumSkins.Set(pAnimating->GetModelPtr()->numskinfamilies(), pAnimating, this); + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CLogicModelInfo::InputLookupSequence( inputdata_t &inputdata ) +{ + CBaseAnimating *pAnimating = GetTarget(inputdata); + if (pAnimating && pAnimating->GetModelPtr()) + { + int index = pAnimating->LookupSequence(inputdata.value.String()); + + if (index != ACT_INVALID) + m_OnHasSequence.Set(index, pAnimating, this); + else + m_OnLacksSequence.FireOutput(pAnimating, this); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Checks and calculates an entity's position. +//----------------------------------------------------------------------------- +class CLogicEntityPosition : public CLogicalEntity +{ + DECLARE_CLASS( CLogicEntityPosition, CLogicalEntity ); +private: + EHANDLE m_hTarget; + + int m_iPositionType; + enum + { + POSITION_ORIGIN = 0, + POSITION_LOCAL, + POSITION_BBOX, + POSITION_EYES, + POSITION_EARS, + POSITION_ATTACHMENT, + }; + + // Something that accompanies the position type, like an attachment name. + string_t m_iszPositionParameter; + + CBaseEntity *GetTarget(CBaseEntity *pActivator, CBaseEntity *pCaller); + + Vector GetPosition(CBaseEntity *pEntity); + + // Inputs + void InputGetPosition( inputdata_t &inputdata ); + void InputSetPosition( inputdata_t &inputdata ); + void InputPredictPosition( inputdata_t &inputdata ); + + void InputSetTarget( inputdata_t &inputdata ) { BaseClass::InputSetTarget(inputdata); m_hTarget = NULL; } + + // Outputs + COutputVector m_OutPosition; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(logic_entity_position, CLogicEntityPosition); + +BEGIN_DATADESC( CLogicEntityPosition ) + + // Keys + DEFINE_FIELD( m_hTarget, FIELD_EHANDLE ), + DEFINE_KEYFIELD( m_iPositionType, FIELD_INTEGER, "PositionType" ), + DEFINE_KEYFIELD( m_iszPositionParameter, FIELD_STRING, "PositionParameter" ), + + // Inputs + DEFINE_INPUTFUNC( FIELD_VOID, "GetPosition", InputGetPosition ), + DEFINE_INPUTFUNC( FIELD_VECTOR, "SetPosition", InputSetPosition ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "PredictPosition", InputPredictPosition ), + + // Outputs + DEFINE_OUTPUT(m_OutPosition, "OutPosition"), + +END_DATADESC() + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline CBaseEntity *CLogicEntityPosition::GetTarget(CBaseEntity *pActivator, CBaseEntity *pCaller) +{ + // Always reset with procedurals + if (!m_hTarget || STRING(m_target)[0] == '!') + m_hTarget = gEntList.FindEntityByName(NULL, STRING(m_target), this, pActivator, pCaller); + return m_hTarget.Get(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +Vector CLogicEntityPosition::GetPosition(CBaseEntity *pEntity) +{ + Vector vecPosition = vec3_origin; + switch (m_iPositionType) + { + case POSITION_ORIGIN: vecPosition = pEntity->GetAbsOrigin(); break; + case POSITION_LOCAL: vecPosition = pEntity->GetLocalOrigin(); break; + case POSITION_BBOX: vecPosition = pEntity->WorldSpaceCenter(); break; + case POSITION_EYES: vecPosition = pEntity->EyePosition(); break; + case POSITION_EARS: vecPosition = pEntity->EarPosition(); break; + case POSITION_ATTACHMENT: + { + CBaseAnimating *pAnimating = pEntity->GetBaseAnimating(); + if (!pAnimating) + { + Warning("%s wants to measure one of %s's attachments, but %s doesn't support them!\n", GetDebugName(), pEntity->GetDebugName(), pEntity->GetDebugName()); + break; + } + + pAnimating->GetAttachment(STRING(m_iszPositionParameter), vecPosition); + } break; + } + return vecPosition; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CLogicEntityPosition::InputGetPosition( inputdata_t &inputdata ) +{ + CBaseEntity *pEntity = GetTarget(inputdata.pActivator, inputdata.pCaller); + if (!pEntity) + m_OutPosition.Set(vec3_origin, NULL, this); + + m_OutPosition.Set(GetPosition(pEntity), pEntity, this); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CLogicEntityPosition::InputSetPosition( inputdata_t &inputdata ) +{ + CBaseEntity *pEntity = GetTarget(inputdata.pActivator, inputdata.pCaller); + if (!pEntity) + { + Warning("%s can't find entity %s for SetPosition!\n", GetDebugName(), STRING(m_target)); + return; + } + + Vector vec; + inputdata.value.Vector3D(vec); + + // If the position is local, they might want to move local origin instead + if (m_iPositionType == POSITION_LOCAL) + pEntity->SetLocalOrigin(vec); + else + pEntity->SetAbsOrigin(vec); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CLogicEntityPosition::InputPredictPosition( inputdata_t &inputdata ) +{ + CBaseEntity *pEntity = GetTarget(inputdata.pActivator, inputdata.pCaller); + if (!pEntity) + m_OutPosition.Set(vec3_origin, NULL, this); + + Vector vecPosition; + UTIL_PredictedPosition(pEntity, GetPosition(pEntity), inputdata.value.Float(), &vecPosition); + + m_OutPosition.Set(vecPosition, pEntity, this); +} + +//----------------------------------------------------------------------------- +// Purpose: Accesses context values +//----------------------------------------------------------------------------- +class CLogicContextAccessor : public CLogicalEntity +{ + DECLARE_CLASS(CLogicContextAccessor, CLogicalEntity); + +public: + CBaseEntity *GetTarget(CBaseEntity *pCaller, CBaseEntity *pActivator); + + bool TestContext(CBaseEntity *pTarget, const char *szKeyName); + void SetContext(CBaseEntity *pTarget, const char *szKeyName, string_t szValue); + + // Inputs + void InputTest(inputdata_t &inputdata); + void InputTestContext(inputdata_t &inputdata); + void InputTestTarget(inputdata_t &inputdata); + + void InputSetContext(inputdata_t &inputdata); + + void InputSetValue(inputdata_t &inputdata); + + //bool ReadUnregisteredKeyfields(CBaseEntity *pTarget, const char *szKeyName, variant_t *variant); + + COutputString m_OutValue; + COutputEvent m_OnFailed; + + string_t m_iszContext; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(logic_context_accessor, CLogicContextAccessor); + + +BEGIN_DATADESC(CLogicContextAccessor) + +DEFINE_KEYFIELD( m_iszContext, FIELD_STRING, "context" ), + +// Inputs +DEFINE_INPUTFUNC(FIELD_VOID, "Test", InputTest), +DEFINE_INPUTFUNC(FIELD_STRING, "TestContext", InputTestContext), +DEFINE_INPUTFUNC(FIELD_STRING, "TestTarget", InputTestTarget), +DEFINE_INPUTFUNC(FIELD_STRING, "SetContext", InputSetContext), +DEFINE_INPUTFUNC(FIELD_STRING, "SetValue", InputSetValue), + +DEFINE_OUTPUT( m_OutValue, "OutValue" ), +DEFINE_OUTPUT( m_OnFailed, "OnFailed" ), + +END_DATADESC() + + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +inline CBaseEntity *CLogicContextAccessor::GetTarget(CBaseEntity *pCaller, CBaseEntity *pActivator) +{ + return gEntList.FindEntityByName(NULL, m_target, this, pActivator, pCaller); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CLogicContextAccessor::TestContext(CBaseEntity *pTarget, const char *szKeyName) +{ + int idx = pTarget->FindContextByName( szKeyName ); + if ( idx != -1 ) + { + m_OutValue.Set(FindPooledString(pTarget->GetContextValue(idx)), pTarget, this); + return true; + } + else + { + m_OnFailed.FireOutput(pTarget, this); + return false; + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicContextAccessor::SetContext(CBaseEntity *pTarget, const char *szKeyName, string_t szValue) +{ + pTarget->AddContext(szKeyName, STRING(szValue)); + + m_OutValue.Set(szValue, pTarget, this); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicContextAccessor::InputTest(inputdata_t &inputdata) +{ + CBaseEntity *pTarget = GetTarget(inputdata.pCaller, inputdata.pActivator); + if (pTarget && m_iszContext != NULL_STRING) + { + TestContext(pTarget, STRING(m_iszContext)); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicContextAccessor::InputTestContext(inputdata_t &inputdata) +{ + const char *input = inputdata.value.String(); + CBaseEntity *pTarget = GetTarget(inputdata.pCaller, inputdata.pActivator); + if (input && pTarget) + { + TestContext(pTarget, input); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicContextAccessor::InputTestTarget(inputdata_t &inputdata) +{ + m_target = inputdata.value.StringID(); + CBaseEntity *pTarget = gEntList.FindEntityByName(NULL, inputdata.value.StringID(), this, inputdata.pCaller, inputdata.pActivator); + if (pTarget && m_iszContext != NULL_STRING) + { + TestContext(pTarget, STRING(m_iszContext)); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicContextAccessor::InputSetContext(inputdata_t &inputdata) +{ + m_iszContext = inputdata.value.StringID(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicContextAccessor::InputSetValue(inputdata_t &inputdata) +{ + CBaseEntity *pTarget = GetTarget(inputdata.pCaller, inputdata.pActivator); + if (pTarget) + { + SetContext(pTarget, STRING(m_iszContext), inputdata.value.StringID()); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Replicates light pattern functionality. +//----------------------------------------------------------------------------- +class CMathLightPattern : public CLogicalEntity +{ + DECLARE_CLASS( CMathLightPattern, CLogicalEntity ); +private: + + + string_t m_iszPattern; + + bool m_bDisabled; + + void Spawn(); + bool KeyValue( const char *szKeyName, const char *szValue ); + + void OutputCurPattern(); + + void StartPatternThink(); + void PatternThink(); + unsigned char m_NextLetter = 0; + + // How fast the pattern should be + float m_flPatternSpeed = 0.1f; + + inline bool VerifyPatternValid() { return (m_iszPattern != NULL_STRING && STRING( m_iszPattern )[0] != '\0'); } + + // Inputs + void InputSetStyle( inputdata_t &inputdata ); + void InputSetPattern( inputdata_t &inputdata ); + void InputEnable( inputdata_t &inputdata ); + void InputDisable( inputdata_t &inputdata ); + void InputToggle( inputdata_t &inputdata ); + + // Outputs + COutputFloat m_OutValue; + COutputString m_OutLetter; + COutputEvent m_OnLightOn; + COutputEvent m_OnLightOff; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS( math_lightpattern, CMathLightPattern ); + +BEGIN_DATADESC( CMathLightPattern ) + + // Keys + DEFINE_KEYFIELD(m_iszPattern, FIELD_STRING, "pattern"), + DEFINE_KEYFIELD(m_bDisabled, FIELD_BOOLEAN, "StartDisabled" ), + DEFINE_KEYFIELD(m_flPatternSpeed, FIELD_FLOAT, "PatternSpeed"), + + // Inputs + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetStyle", InputSetStyle ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetPattern", InputSetPattern ), + DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), + DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), + DEFINE_INPUTFUNC( FIELD_VOID, "Toggle", InputToggle ), + + // Outputs + DEFINE_OUTPUT(m_OutValue, "OutValue"), + DEFINE_OUTPUT(m_OutLetter, "OutLetter"), + DEFINE_OUTPUT(m_OnLightOn, "OnLightOn"), + DEFINE_OUTPUT(m_OnLightOff, "OnLightOff"), + + DEFINE_THINKFUNC( PatternThink ), + DEFINE_FIELD( m_NextLetter, FIELD_CHARACTER ), + +END_DATADESC() + +extern const char *GetDefaultLightstyleString( int styleIndex ); + +static const char *s_pLightPatternContext = "PatternContext"; + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CMathLightPattern::Spawn() +{ + BaseClass::Spawn(); + + if (!m_bDisabled && VerifyPatternValid()) + StartPatternThink(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CMathLightPattern::OutputCurPattern() +{ + // This code looks messy, but it does what it's supposed to and is safe enough. + // First, we get the next letter in the pattern sequence. + // Next, we calculate its integral proximity to the character 'a' (fully dark) + // and calculate its approximate brightness by dividing it by the number of letters in the alphabet other than a. + // We output that brightness value for things like projected textures and other custom intensity values + // so they could replicate the patterns of their corresponding vrad lights. + char cLetter = STRING(m_iszPattern)[m_NextLetter]; + int iValue = (cLetter - 'a'); + float flResult = iValue != 0 ? ((float)iValue / 25.0f) : 0.0f; + m_OutValue.Set(flResult, this, this); + + // User-friendly "Light on, light off" outputs + if (flResult > 0) + m_OnLightOn.FireOutput(this, this); + else + m_OnLightOff.FireOutput(this, this); + + // Create a string with cLetter and a null terminator. + char szLetter[2] = { cLetter, '\0' }; + m_OutLetter.Set( AllocPooledString(szLetter), this, this ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CMathLightPattern::StartPatternThink() +{ + // Output our current/next one immediately. + OutputCurPattern(); + + // Start thinking now. + SetContextThink( &CMathLightPattern::PatternThink, gpGlobals->curtime, s_pLightPatternContext ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CMathLightPattern::PatternThink() +{ + // Output our current/next one + OutputCurPattern(); + + // Increment + m_NextLetter++; + if (STRING(m_iszPattern)[m_NextLetter] == '\0') + m_NextLetter = 0; + + //m_OutLetter.Set(AllocPooledString(UTIL_VarArgs("%c", m_NextLetter)), this, this); + + SetNextThink( gpGlobals->curtime + m_flPatternSpeed, s_pLightPatternContext ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CMathLightPattern::KeyValue( const char *szKeyName, const char *szValue ) +{ + if ( FStrEq( szKeyName, "style" ) ) + { + m_iszPattern = AllocPooledString(GetDefaultLightstyleString(atoi(szValue))); + } + else + return BaseClass::KeyValue( szKeyName, szValue ); + + return true; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CMathLightPattern::InputSetStyle( inputdata_t &inputdata ) +{ + m_iszPattern = AllocPooledString(GetDefaultLightstyleString(inputdata.value.Int())); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CMathLightPattern::InputSetPattern( inputdata_t &inputdata ) +{ + m_iszPattern = inputdata.value.StringID(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CMathLightPattern::InputEnable( inputdata_t &inputdata ) +{ + if (VerifyPatternValid()) + StartPatternThink(); + else + Warning("%s tried to enable without valid pattern\n", GetDebugName()); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CMathLightPattern::InputDisable( inputdata_t &inputdata ) +{ + SetContextThink( NULL, TICK_NEVER_THINK, s_pLightPatternContext ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CMathLightPattern::InputToggle( inputdata_t &inputdata ) +{ + if (GetNextThink(s_pLightPatternContext) != TICK_NEVER_THINK) + InputDisable(inputdata); + else + InputEnable(inputdata); +} + +//----------------------------------------------------------------------------- +// Purpose: Sequences for keypads, etc. +//----------------------------------------------------------------------------- +#define MAX_SEQUENCE_CASES 16 + +class CLogicSequence : public CLogicalEntity +{ + DECLARE_CLASS( CLogicSequence, CLogicalEntity ); +public: + CLogicSequence(); + + void Activate(); + + bool KeyValue( const char *szKeyName, const char *szValue ); + + void TestCase( int iCase, string_t iszValue, CBaseEntity *pActivator ); + void SequenceComplete( string_t iszValue, CBaseEntity *pActivator ); + +private: + string_t m_iszCase[MAX_SEQUENCE_CASES]; + int m_iNumCases; + + bool m_bDisabled; + + bool m_bDontIncrementOnPass; + + // Inputs + void InputEnable( inputdata_t &inputdata ); + void InputDisable( inputdata_t &inputdata ); + void InputToggle( inputdata_t &inputdata ); + void InputInValue( inputdata_t &inputdata ); + void InputSetCurrentCase( inputdata_t &inputdata ); + void InputSetCurrentCaseNoFire( inputdata_t &inputdata ); + void InputIncrementSequence( inputdata_t &inputdata ); + void InputResetSequence( inputdata_t &inputdata ); + + // Outputs + COutputInt m_CurCase; + COutputString m_OnCasePass; + COutputString m_OnCaseFail; + COutputString m_OnSequenceComplete; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS( logic_sequence, CLogicSequence ); + + +BEGIN_DATADESC( CLogicSequence ) + + // Keys + DEFINE_KEYFIELD( m_iszCase[0], FIELD_STRING, "Case01" ), + DEFINE_KEYFIELD( m_iszCase[1], FIELD_STRING, "Case02" ), + DEFINE_KEYFIELD( m_iszCase[2], FIELD_STRING, "Case03" ), + DEFINE_KEYFIELD( m_iszCase[3], FIELD_STRING, "Case04" ), + DEFINE_KEYFIELD( m_iszCase[4], FIELD_STRING, "Case05" ), + DEFINE_KEYFIELD( m_iszCase[5], FIELD_STRING, "Case06" ), + DEFINE_KEYFIELD( m_iszCase[6], FIELD_STRING, "Case07" ), + DEFINE_KEYFIELD( m_iszCase[7], FIELD_STRING, "Case08" ), + DEFINE_KEYFIELD( m_iszCase[8], FIELD_STRING, "Case09" ), + DEFINE_KEYFIELD( m_iszCase[9], FIELD_STRING, "Case10" ), + DEFINE_KEYFIELD( m_iszCase[10], FIELD_STRING, "Case11" ), + DEFINE_KEYFIELD( m_iszCase[11], FIELD_STRING, "Case12" ), + DEFINE_KEYFIELD( m_iszCase[12], FIELD_STRING, "Case13" ), + DEFINE_KEYFIELD( m_iszCase[13], FIELD_STRING, "Case14" ), + DEFINE_KEYFIELD( m_iszCase[14], FIELD_STRING, "Case15" ), + DEFINE_KEYFIELD( m_iszCase[15], FIELD_STRING, "Case16" ), + + // This doesn't need to be saved, it can be assigned every Activate() + //DEFINE_FIELD( m_iNumCases, FIELD_INTEGER ), + + DEFINE_KEYFIELD( m_bDisabled, FIELD_BOOLEAN, "StartDisabled" ), + + DEFINE_KEYFIELD( m_bDontIncrementOnPass, FIELD_BOOLEAN, "DontIncrementOnPass" ), + + // Inputs + DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), + DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), + DEFINE_INPUTFUNC( FIELD_VOID, "Toggle", InputToggle ), + DEFINE_INPUTFUNC( FIELD_STRING, "InValue", InputInValue ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetCurrentCase", InputSetCurrentCase ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetCurrentCaseNoFire", InputSetCurrentCaseNoFire ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "IncrementSequence", InputIncrementSequence ), + DEFINE_INPUTFUNC( FIELD_VOID, "ResetSequence", InputResetSequence ), + + // Outputs + DEFINE_OUTPUT( m_CurCase, "OutCurCase" ), + DEFINE_OUTPUT( m_OnCasePass, "OnCasePass" ), + DEFINE_OUTPUT( m_OnCaseFail, "OnCaseFail" ), + DEFINE_OUTPUT( m_OnSequenceComplete, "OnSequenceComplete" ), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CLogicSequence::CLogicSequence() +{ + m_CurCase.Init( 1 ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicSequence::Activate( void ) +{ + BaseClass::Activate(); + + // Count number of cases + for (m_iNumCases = 0; m_iNumCases < MAX_SEQUENCE_CASES; m_iNumCases++) + { + if (m_iszCase[m_iNumCases] == NULL_STRING) + break; + } +} + +//----------------------------------------------------------------------------- +// Purpose: Cache user entity field values until spawn is called. +// Input : szKeyName - Key to handle. +// szValue - Value for key. +// Output : Returns true if the key was handled, false if not. +//----------------------------------------------------------------------------- +bool CLogicSequence::KeyValue( const char *szKeyName, const char *szValue ) +{ + if (FStrEq( szKeyName, "StartCase" )) + { + m_CurCase.Init( atoi(szValue) ); + } + else + return BaseClass::KeyValue( szKeyName, szValue ); + + return true; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicSequence::TestCase( int iCase, string_t iszValue, CBaseEntity *pActivator ) +{ + if (m_bDisabled) + { + DevMsg("%s ignoring case test because it is disabled\n", GetDebugName()); + return; + } + + // Arrays are 0-based, so the index is (iCase - 1) + int iIndex = iCase - 1; + if (iIndex >= m_iNumCases) + { + DevMsg("%s ignoring case test because the current case %i is greater than or equal to the number of cases %i\n", GetDebugName(), iCase, m_iNumCases); + return; + } + + if (Matcher_Match( STRING( m_iszCase[iIndex] ), STRING(iszValue) )) + { + m_OnCasePass.Set( iszValue, pActivator, this ); + + if (!m_bDontIncrementOnPass) + { + m_CurCase.Set(iCase + 1, pActivator, this); + + if (m_CurCase.Get() > m_iNumCases) + { + // Sequence complete! + SequenceComplete(iszValue, pActivator); + } + } + else + { + m_CurCase.Set(iCase, pActivator, this); + } + } + else + { + m_OnCaseFail.Set( iszValue, pActivator, this ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicSequence::SequenceComplete( string_t iszValue, CBaseEntity *pActivator ) +{ + m_OnSequenceComplete.Set( iszValue, pActivator, this ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicSequence::InputEnable( inputdata_t &inputdata ) +{ + m_bDisabled = false; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicSequence::InputDisable( inputdata_t &inputdata ) +{ + m_bDisabled = true; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicSequence::InputToggle( inputdata_t &inputdata ) +{ + m_bDisabled = (m_bDisabled == false); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicSequence::InputInValue( inputdata_t &inputdata ) +{ + TestCase( m_CurCase.Get(), inputdata.value.StringID(), inputdata.pActivator ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicSequence::InputSetCurrentCase( inputdata_t &inputdata ) +{ + m_CurCase.Set( inputdata.value.Int(), inputdata.pActivator, this ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicSequence::InputSetCurrentCaseNoFire( inputdata_t &inputdata ) +{ + m_CurCase.Init( inputdata.value.Int() ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicSequence::InputIncrementSequence( inputdata_t &inputdata ) +{ + int iInc = inputdata.value.Int(); + m_CurCase.Set( m_CurCase.Get() + (iInc != 0 ? iInc : 1), inputdata.pActivator, this ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicSequence::InputResetSequence( inputdata_t &inputdata ) +{ + m_CurCase.Set( 1, inputdata.pActivator, this ); +} + +//----------------------------------------------------------------------------- +// Purpose: Generates various types of numbers based on existing material proxies +//----------------------------------------------------------------------------- +class CMathGenerate : public CLogicalEntity +{ +public: + DECLARE_CLASS( CMathGenerate, CLogicalEntity ); + CMathGenerate(); + + enum GenerateType_t + { + GENERATE_SINE_WAVE, + GENERATE_LINEAR_RAMP, + GENERATE_UNIFORM_NOISE, + GENERATE_GAUSSIAN_NOISE, + GENERATE_EXPONENTIAL, + }; + + // Keys + float m_flMax; + float m_flMin; + + float m_flParam1; + float m_flParam2; + + bool m_bDisabled; + + GenerateType_t m_iGenerateType; + + // Inputs + void InputSetValue( inputdata_t &inputdata ); + void InputSetValueNoFire( inputdata_t &inputdata ); + void InputSetGenerateType( inputdata_t &inputdata ); + + void InputEnable( inputdata_t &inputdata ); + void InputDisable( inputdata_t &inputdata ); + void InputToggle( inputdata_t &inputdata ); + + // Basic functions + void Spawn(); + bool KeyValue( const char *szKeyName, const char *szValue ); + + void StartGenerating(); + void StopGenerating(); + + // Number generation functions + void GenerateSineWave(); + void GenerateLinearRamp(); + void GenerateUniformNoise(); + void GenerateGaussianNoise(); + void GenerateExponential(); + + // The gaussian stream normally only exists on the client, so we use our own. + static CGaussianRandomStream m_GaussianStream; + + // Outputs + COutputFloat m_Value; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS( math_generate, CMathGenerate ); + + +BEGIN_DATADESC( CMathGenerate ) + + DEFINE_INPUT( m_flMax, FIELD_FLOAT, "SetHitMax" ), + DEFINE_INPUT( m_flMin, FIELD_FLOAT, "SetHitMin" ), + DEFINE_INPUT( m_flParam1, FIELD_FLOAT, "SetParam1" ), + DEFINE_INPUT( m_flParam2, FIELD_FLOAT, "SetParam2" ), + DEFINE_KEYFIELD( m_bDisabled, FIELD_BOOLEAN, "StartDisabled" ), + + DEFINE_KEYFIELD( m_iGenerateType, FIELD_INTEGER, "GenerateType" ), + + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetValue", InputSetValue ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetValueNoFire", InputSetValueNoFire ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetGenerateType", InputSetGenerateType ), + + DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), + DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), + DEFINE_INPUTFUNC( FIELD_VOID, "Toggle", InputToggle ), + + DEFINE_OUTPUT( m_Value, "OutValue" ), + + DEFINE_THINKFUNC( GenerateSineWave ), + DEFINE_THINKFUNC( GenerateLinearRamp ), + DEFINE_THINKFUNC( GenerateUniformNoise ), + DEFINE_THINKFUNC( GenerateGaussianNoise ), + DEFINE_THINKFUNC( GenerateExponential ), + +END_DATADESC() + +CGaussianRandomStream CMathGenerate::m_GaussianStream; + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CMathGenerate::CMathGenerate() +{ + m_GaussianStream.AttachToStream( random ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CMathGenerate::Spawn() +{ + BaseClass::Spawn(); + + if (!m_bDisabled) + StartGenerating(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CMathGenerate::KeyValue( const char *szKeyName, const char *szValue ) +{ + if (FStrEq( szKeyName, "InitialValue" )) + { + m_Value.Init( atof(szValue) ); + } + else + return BaseClass::KeyValue( szKeyName, szValue ); + + return true; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathGenerate::InputSetValue( inputdata_t &inputdata ) +{ + m_Value.Set(inputdata.value.Float(), inputdata.pActivator, this); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathGenerate::InputSetValueNoFire( inputdata_t &inputdata ) +{ + m_Value.Init(inputdata.value.Float()); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathGenerate::InputSetGenerateType( inputdata_t &inputdata ) +{ + m_iGenerateType = (GenerateType_t)inputdata.value.Int(); + + if (GetNextThink() != TICK_NEVER_THINK) + { + // Change our generation function if we're already generating. + // StartGenerating() should set to the new function. + StartGenerating(); + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathGenerate::InputEnable( inputdata_t &inputdata ) +{ + m_bDisabled = false; + StartGenerating(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathGenerate::InputDisable( inputdata_t &inputdata ) +{ + m_bDisabled = true; + StopGenerating(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathGenerate::InputToggle( inputdata_t &inputdata ) +{ + m_bDisabled ? InputEnable(inputdata) : InputDisable(inputdata); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathGenerate::StartGenerating() +{ + // Correct any min/max quirks here + if (m_flMin > m_flMax) + { + float flTemp = m_flMin; + m_flMin = m_flMax; + m_flMax = flTemp; + } + + switch (m_iGenerateType) + { + case GENERATE_SINE_WAVE: + SetThink( &CMathGenerate::GenerateSineWave ); + break; + case GENERATE_LINEAR_RAMP: + SetThink( &CMathGenerate::GenerateLinearRamp ); + break; + case GENERATE_UNIFORM_NOISE: + SetThink( &CMathGenerate::GenerateUniformNoise ); + break; + case GENERATE_GAUSSIAN_NOISE: + SetThink( &CMathGenerate::GenerateGaussianNoise ); + break; + case GENERATE_EXPONENTIAL: + SetThink( &CMathGenerate::GenerateExponential ); + break; + + default: + Warning("%s is set to invalid generation type %i! It won't do anything now.\n", GetDebugName(), m_iGenerateType); + StopGenerating(); + return; + } + + // All valid types should fall through to this + SetNextThink( gpGlobals->curtime + TICK_INTERVAL ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathGenerate::StopGenerating() +{ + SetThink(NULL); + SetNextThink( TICK_NEVER_THINK ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathGenerate::GenerateSineWave() +{ + // CSineProxy in mathproxy.cpp + float flSineTimeOffset = m_flParam2; + float flSinePeriod = m_flParam1; + float flValue; + + if (flSinePeriod == 0) + flSinePeriod = 1; + + // get a value in [0,1] + flValue = ( sin( 2.0f * M_PI * (gpGlobals->curtime - flSineTimeOffset) / flSinePeriod ) * 0.5f ) + 0.5f; + // get a value in [min,max] + flValue = ( m_flMax - m_flMin ) * flValue + m_flMin; + + m_Value.Set( flValue, NULL, this ); + + SetNextThink( gpGlobals->curtime + TICK_INTERVAL ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathGenerate::GenerateLinearRamp() +{ + // CLinearRampProxy in mathproxy.cpp + + // Param1 = rate + m_Value.Set( m_flParam1 * gpGlobals->curtime + m_Value.Get(), NULL, this ); + + SetNextThink( gpGlobals->curtime + TICK_INTERVAL ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathGenerate::GenerateUniformNoise() +{ + // CUniformNoiseProxy in mathproxy.cpp + + m_Value.Set( random->RandomFloat( m_flMin, m_flMax ), NULL, this ); + + SetNextThink( gpGlobals->curtime + TICK_INTERVAL ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathGenerate::GenerateGaussianNoise() +{ + // CGaussianNoiseProxy in mathproxy.cpp + + float flMean = m_flParam1; + float flStdDev = m_flParam2; + float flVal = m_GaussianStream.RandomFloat( flMean, flStdDev ); + + // clamp + if (flVal < m_flMin) + flVal = m_flMin; + else if (flVal > m_flMax) + flVal = m_flMax; + + m_Value.Set( flVal, NULL, this ); + + SetNextThink( gpGlobals->curtime + TICK_INTERVAL ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMathGenerate::GenerateExponential() +{ + // CExponentialProxy in mathproxy.cpp + + // Param1 = scale + // Param2 = offset + float flVal = m_flParam1 * exp( m_Value.Get() + m_flParam2 ); + + // clamp + if (flVal < m_flMin) + flVal = m_flMin; + else if (flVal > m_flMax) + flVal = m_flMax; + + m_Value.Set( flVal, NULL, this ); + + SetNextThink( gpGlobals->curtime + TICK_INTERVAL ); +} +#endif diff --git a/sp/src/game/server/logicrelay.cpp b/sp/src/game/server/logicrelay.cpp index b556ec04..6daa15f4 100644 --- a/sp/src/game/server/logicrelay.cpp +++ b/sp/src/game/server/logicrelay.cpp @@ -15,6 +15,10 @@ #include "eventqueue.h" #include "soundent.h" #include "logicrelay.h" +#ifdef MAPBASE +#include "mapbase/variant_tools.h" +#include "saverestore_utlvector.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -29,6 +33,11 @@ BEGIN_DATADESC( CLogicRelay ) DEFINE_FIELD(m_bWaitForRefire, FIELD_BOOLEAN), DEFINE_KEYFIELD(m_bDisabled, FIELD_BOOLEAN, "StartDisabled"), +#if RELAY_QUEUE_SYSTEM + DEFINE_KEYFIELD(m_bQueueTrigger, FIELD_BOOLEAN, "QueueDisabledTrigger"), + DEFINE_FIELD(m_bQueueWaiting, FIELD_BOOLEAN), + DEFINE_FIELD(m_flRefireTime, FIELD_TIME), +#endif // Inputs DEFINE_INPUTFUNC(FIELD_VOID, "Enable", InputEnable), @@ -36,10 +45,16 @@ BEGIN_DATADESC( CLogicRelay ) DEFINE_INPUTFUNC(FIELD_VOID, "Disable", InputDisable), DEFINE_INPUTFUNC(FIELD_VOID, "Toggle", InputToggle), DEFINE_INPUTFUNC(FIELD_VOID, "Trigger", InputTrigger), +#ifdef MAPBASE + DEFINE_INPUTFUNC(FIELD_INPUT, "TriggerWithParameter", InputTriggerWithParameter), +#endif DEFINE_INPUTFUNC(FIELD_VOID, "CancelPending", InputCancelPending), // Outputs DEFINE_OUTPUT(m_OnTrigger, "OnTrigger"), +#ifdef MAPBASE + DEFINE_OUTPUT(m_OnTriggerParameter, "OnTriggerParameter"), +#endif DEFINE_OUTPUT(m_OnSpawn, "OnSpawn"), END_DATADESC() @@ -93,6 +108,11 @@ void CLogicRelay::Think() void CLogicRelay::InputEnable( inputdata_t &inputdata ) { m_bDisabled = false; + +#if RELAY_QUEUE_SYSTEM + if (m_bQueueWaiting) + m_OnTrigger.FireOutput( inputdata.pActivator, this ); +#endif } //------------------------------------------------------------------------------ @@ -132,6 +152,11 @@ void CLogicRelay::InputDisable( inputdata_t &inputdata ) void CLogicRelay::InputToggle( inputdata_t &inputdata ) { m_bDisabled = !m_bDisabled; + +#if RELAY_QUEUE_SYSTEM + if (m_bQueueWaiting) + m_OnTrigger.FireOutput( inputdata.pActivator, this ); +#endif } @@ -144,6 +169,45 @@ void CLogicRelay::InputTrigger( inputdata_t &inputdata ) { m_OnTrigger.FireOutput( inputdata.pActivator, this ); + if (m_spawnflags & SF_REMOVE_ON_FIRE) + { + UTIL_Remove(this); + } + else if (!(m_spawnflags & SF_ALLOW_FAST_RETRIGGER)) + { + // + // Disable the relay so that it cannot be refired until after the last output + // has been fired and post an input to re-enable ourselves. + // + m_bWaitForRefire = true; + g_EventQueue.AddEvent(this, "EnableRefire", m_OnTrigger.GetMaxDelay() + 0.001, this, this); +#if RELAY_QUEUE_SYSTEM + if (m_bQueueTrigger) + m_flRefireTime = gpGlobals->curtime + m_OnTrigger.GetMaxDelay() + 0.002; +#endif + } + } +#if RELAY_QUEUE_SYSTEM + else if (m_bQueueTrigger) + { + if (m_bDisabled) + m_bQueueWaiting = true; + else // m_bWaitForRefire + m_OnTrigger.FireOutput( inputdata.pActivator, this, (gpGlobals->curtime - m_flRefireTime) ); + } +#endif +} + +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Input handler that triggers the relay. +//----------------------------------------------------------------------------- +void CLogicRelay::InputTriggerWithParameter( inputdata_t &inputdata ) +{ + if ((!m_bDisabled) && (!m_bWaitForRefire)) + { + m_OnTriggerParameter.Set( inputdata.value, inputdata.pActivator, this ); + if (m_spawnflags & SF_REMOVE_ON_FIRE) { UTIL_Remove(this); @@ -159,4 +223,258 @@ void CLogicRelay::InputTrigger( inputdata_t &inputdata ) } } } +#endif + +#ifdef MAPBASE + +BEGIN_SIMPLE_DATADESC( LogicRelayQueueInfo_t ) + + DEFINE_FIELD( TriggerWithParameter, FIELD_BOOLEAN ), + DEFINE_FIELD( pActivator, FIELD_CLASSPTR ), + DEFINE_VARIANT( value ), + DEFINE_FIELD( outputID, FIELD_INTEGER ), + +END_DATADESC() + +LINK_ENTITY_TO_CLASS(logic_relay_queue, CLogicRelayQueue); + + +BEGIN_DATADESC( CLogicRelayQueue ) + + DEFINE_FIELD(m_bWaitForRefire, FIELD_BOOLEAN), + DEFINE_KEYFIELD(m_bDisabled, FIELD_BOOLEAN, "StartDisabled"), + + DEFINE_INPUT(m_iMaxQueueItems, FIELD_INTEGER, "SetMaxQueueItems"), + DEFINE_KEYFIELD(m_bDontQueueWhenDisabled, FIELD_BOOLEAN, "DontQueueWhenDisabled"), + + // Inputs + DEFINE_INPUTFUNC(FIELD_VOID, "Enable", InputEnable), + DEFINE_INPUTFUNC(FIELD_VOID, "EnableRefire", InputEnableRefire), + DEFINE_INPUTFUNC(FIELD_VOID, "Disable", InputDisable), + DEFINE_INPUTFUNC(FIELD_VOID, "Toggle", InputToggle), + DEFINE_INPUTFUNC(FIELD_VOID, "Trigger", InputTrigger), + DEFINE_INPUTFUNC(FIELD_INPUT, "TriggerWithParameter", InputTriggerWithParameter), + DEFINE_INPUTFUNC(FIELD_VOID, "CancelPending", InputCancelPending), + DEFINE_INPUTFUNC(FIELD_VOID, "ClearQueue", InputClearQueue), + + // Outputs + DEFINE_OUTPUT(m_OnTrigger, "OnTrigger"), + DEFINE_OUTPUT(m_OnTriggerParameter, "OnTriggerParameter"), + + DEFINE_UTLVECTOR(m_QueueItems, FIELD_EMBEDDED), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: Constructor. +//----------------------------------------------------------------------------- +CLogicRelayQueue::CLogicRelayQueue(void) +{ +} + + +//------------------------------------------------------------------------------ +// Purpose: Turns on the relay, allowing it to fire outputs. +//------------------------------------------------------------------------------ +void CLogicRelayQueue::InputEnable( inputdata_t &inputdata ) +{ + m_bDisabled = false; + + if (!m_bWaitForRefire && m_QueueItems.Count() > 0) + HandleNextQueueItem(); +} + +//------------------------------------------------------------------------------ +// Purpose: Enables us to fire again. This input is only posted from our Trigger +// function to prevent rapid refire. +//------------------------------------------------------------------------------ +void CLogicRelayQueue::InputEnableRefire( inputdata_t &inputdata ) +{ + m_bWaitForRefire = false; + + if (!m_bDisabled && m_QueueItems.Count() > 0) + HandleNextQueueItem(); +} + + +//------------------------------------------------------------------------------ +// Purpose: Cancels any I/O events in the queue that were fired by us. +//------------------------------------------------------------------------------ +void CLogicRelayQueue::InputCancelPending( inputdata_t &inputdata ) +{ + g_EventQueue.CancelEvents( this ); + + // Stop waiting; allow another Trigger. + m_bWaitForRefire = false; + + if (!m_bDisabled && m_QueueItems.Count() > 0) + HandleNextQueueItem(); +} + + +//------------------------------------------------------------------------------ +// Purpose: Clears the queue. +//------------------------------------------------------------------------------ +void CLogicRelayQueue::InputClearQueue( inputdata_t &inputdata ) +{ + m_QueueItems.RemoveAll(); +} + + +//------------------------------------------------------------------------------ +// Purpose: Turns off the relay, preventing it from firing outputs. +//------------------------------------------------------------------------------ +void CLogicRelayQueue::InputDisable( inputdata_t &inputdata ) +{ + m_bDisabled = true; +} + + +//------------------------------------------------------------------------------ +// Purpose: Toggles the enabled/disabled state of the relay. +//------------------------------------------------------------------------------ +void CLogicRelayQueue::InputToggle( inputdata_t &inputdata ) +{ + m_bDisabled = !m_bDisabled; + + if (!m_bDisabled && !m_bWaitForRefire && m_QueueItems.Count() > 0) + HandleNextQueueItem(); +} + + +//----------------------------------------------------------------------------- +// Purpose: Input handler that triggers the relay. +//----------------------------------------------------------------------------- +void CLogicRelayQueue::InputTrigger( inputdata_t &inputdata ) +{ + if ((!m_bDisabled) && (!m_bWaitForRefire)) + { + m_OnTrigger.FireOutput( inputdata.pActivator, this ); + + // + // Disable the relay so that it cannot be refired until after the last output + // has been fired and post an input to re-enable ourselves. + // + m_bWaitForRefire = true; + g_EventQueue.AddEvent(this, "EnableRefire", m_OnTrigger.GetMaxDelay() + 0.001, this, this); + } + else if ( (!m_bDisabled || !m_bDontQueueWhenDisabled) && (m_QueueItems.Count() < m_iMaxQueueItems) ) + { + AddQueueItem(inputdata.pActivator, inputdata.nOutputID); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler that triggers the relay. +//----------------------------------------------------------------------------- +void CLogicRelayQueue::InputTriggerWithParameter( inputdata_t &inputdata ) +{ + if ((!m_bDisabled) && (!m_bWaitForRefire)) + { + m_OnTriggerParameter.Set( inputdata.value, inputdata.pActivator, this ); + + // + // Disable the relay so that it cannot be refired until after the last output + // has been fired and post an input to re-enable ourselves. + // + m_bWaitForRefire = true; + g_EventQueue.AddEvent(this, "EnableRefire", m_OnTrigger.GetMaxDelay() + 0.001, this, this); + } + else if ( (!m_bDisabled || !m_bDontQueueWhenDisabled) && (m_QueueItems.Count() < m_iMaxQueueItems) ) + { + AddQueueItem(inputdata.pActivator, inputdata.nOutputID, inputdata.value); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Handles next queue item. +//----------------------------------------------------------------------------- +void CLogicRelayQueue::HandleNextQueueItem() +{ + LogicRelayQueueInfo_t info = m_QueueItems.Element(0); + + //if (!info.TriggerWithParameter) + //{ + // m_OnTrigger.FireOutput(info.pActivator, this); + //} + //else + //{ + // m_OnTriggerParameter.Set(info.value, info.pActivator, this); + //} + + AcceptInput(info.TriggerWithParameter ? "TriggerWithParameter" : "Trigger", info.pActivator, this, info.value, info.outputID); + + m_QueueItems.Remove(0); +} + +//----------------------------------------------------------------------------- +// Purpose: Adds a queue item. +//----------------------------------------------------------------------------- +void CLogicRelayQueue::AddQueueItem(CBaseEntity *pActivator, int outputID, variant_t &value) +{ + LogicRelayQueueInfo_t info; + info.pActivator = pActivator; + info.outputID = outputID; + + info.value = value; + info.TriggerWithParameter = true; + + m_QueueItems.AddToTail(info); +} + +//----------------------------------------------------------------------------- +// Purpose: Adds a queue item without a parameter. +//----------------------------------------------------------------------------- +void CLogicRelayQueue::AddQueueItem(CBaseEntity *pActivator, int outputID) +{ + LogicRelayQueueInfo_t info; + info.pActivator = pActivator; + info.outputID = outputID; + + info.TriggerWithParameter = false; + + m_QueueItems.AddToTail(info); +} + +//----------------------------------------------------------------------------- +// Purpose: Draw any debug text overlays +// Output : Current text offset from the top +//----------------------------------------------------------------------------- +int CLogicRelayQueue::DrawDebugTextOverlays(void) +{ + int text_offset = BaseClass::DrawDebugTextOverlays(); + + if (m_debugOverlays & OVERLAY_TEXT_BIT) + { + // -------------- + // Print Target + // -------------- + char tempstr[255]; + + if (m_QueueItems.Count() > 0) + { + Q_snprintf(tempstr, sizeof(tempstr), "Queue Items: %i (%i)", m_QueueItems.Count(), m_iMaxQueueItems); + EntityText(text_offset, tempstr, 0); + text_offset++; + + for (int i = 0; i < m_QueueItems.Count(); i++) + { + Q_snprintf(tempstr, sizeof(tempstr), " Input: %s, Activator: %s, Output ID: %i", + m_QueueItems[i].TriggerWithParameter ? "TriggerWithParameter" : "Trigger", + m_QueueItems[i].pActivator ? m_QueueItems[i].pActivator->GetDebugName() : "None", + m_QueueItems[i].outputID); + EntityText(text_offset, tempstr, 0); + text_offset++; + } + } + else + { + Q_snprintf(tempstr, sizeof(tempstr), "Queue Items: 0 (%i)", m_iMaxQueueItems); + EntityText(text_offset, tempstr, 0); + text_offset++; + } + } + return text_offset; +} +#endif diff --git a/sp/src/game/server/logicrelay.h b/sp/src/game/server/logicrelay.h index 8d082acc..00791579 100644 --- a/sp/src/game/server/logicrelay.h +++ b/sp/src/game/server/logicrelay.h @@ -13,6 +13,13 @@ #include "entityoutput.h" #include "eventqueue.h" +#ifdef MAPBASE + +// I was originally going to add something similar to that queue thing to logic_relay directly, but I later decided to relegate it to a derivative entity. +#define RELAY_QUEUE_SYSTEM 0 + +#endif + class CLogicRelay : public CLogicalEntity { public: @@ -25,16 +32,26 @@ public: // Input handlers void InputEnable( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputEnableRefire( inputdata_t &inputdata ); +#else void InputEnableRefire( inputdata_t &inputdata ); // Private input handler, not in FGD +#endif void InputDisable( inputdata_t &inputdata ); void InputToggle( inputdata_t &inputdata ); void InputTrigger( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputTriggerWithParameter( inputdata_t &inputdata ); +#endif void InputCancelPending( inputdata_t &inputdata ); DECLARE_DATADESC(); // Outputs COutputEvent m_OnTrigger; +#ifdef MAPBASE + COutputVariant m_OnTriggerParameter; +#endif COutputEvent m_OnSpawn; bool IsDisabled( void ){ return m_bDisabled; } @@ -43,6 +60,66 @@ private: bool m_bDisabled; bool m_bWaitForRefire; // Set to disallow a refire while we are waiting for our outputs to finish firing. +#if RELAY_QUEUE_SYSTEM + bool m_bQueueTrigger; + bool m_bQueueWaiting; + float m_flRefireTime; +#endif }; +#ifdef MAPBASE +struct LogicRelayQueueInfo_t +{ + DECLARE_SIMPLE_DATADESC(); + + bool TriggerWithParameter; + CBaseEntity *pActivator; + variant_t value; + int outputID; +}; + +//#define LOGIC_RELAY_QUEUE_LIMIT 16 + +class CLogicRelayQueue : public CLogicalEntity +{ +public: + DECLARE_CLASS( CLogicRelayQueue, CLogicalEntity ); + + CLogicRelayQueue(); + + // Input handlers + void InputEnable( inputdata_t &inputdata ); + void InputEnableRefire( inputdata_t &inputdata ); + void InputDisable( inputdata_t &inputdata ); + void InputToggle( inputdata_t &inputdata ); + void InputTrigger( inputdata_t &inputdata ); + void InputTriggerWithParameter( inputdata_t &inputdata ); + void InputCancelPending( inputdata_t &inputdata ); + void InputClearQueue( inputdata_t &inputdata ); + + DECLARE_DATADESC(); + + // Outputs + COutputEvent m_OnTrigger; + COutputVariant m_OnTriggerParameter; + + bool IsDisabled( void ){ return m_bDisabled; } + + void HandleNextQueueItem(); + void AddQueueItem(CBaseEntity *pActivator, int outputID, variant_t &value); + void AddQueueItem(CBaseEntity *pActivator, int outputID); + + int DrawDebugTextOverlays( void ); + +private: + + bool m_bDisabled; + bool m_bWaitForRefire; // Set to disallow a refire while we are waiting for our outputs to finish firing. + + int m_iMaxQueueItems; + bool m_bDontQueueWhenDisabled; // Don't add to queue while disabled, only when waiting for refire + CUtlVector m_QueueItems; +}; +#endif + #endif //LOGICRELAY_H diff --git a/sp/src/game/server/mapbase/GlobalStrings.cpp b/sp/src/game/server/mapbase/GlobalStrings.cpp new file mode 100644 index 00000000..665e2811 --- /dev/null +++ b/sp/src/game/server/mapbase/GlobalStrings.cpp @@ -0,0 +1,123 @@ +//========= Copyright Valve Corporation, All rights reserved. ================== +// +// Purpose: See GlobalStrings.h for more information. +// +// $NoKeywords: $ +//============================================================================= + +#include "cbase.h" +#include "GlobalStrings.h" + + +// Global strings must be initially declared here. +// Be sure to sync them with the externs in GlobalStrings.h. + +// ------------------------------------------------------------- +// +// Classnames +// +// ------------------------------------------------------------- + +#ifdef HL2_DLL +string_t gm_isz_class_Shotgun; +string_t gm_isz_class_SMG1; +string_t gm_isz_class_AR2; +string_t gm_isz_class_Pistol; +string_t gm_isz_class_Stunstick; +string_t gm_isz_class_Crowbar; +string_t gm_isz_class_RPG; +string_t gm_isz_class_357; +string_t gm_isz_class_Grenade; +string_t gm_isz_class_Physcannon; +string_t gm_isz_class_Crossbow; + +string_t gm_isz_class_Strider; +string_t gm_isz_class_Gunship; +string_t gm_isz_class_Dropship; +string_t gm_isz_class_FloorTurret; +string_t gm_isz_class_CScanner; +string_t gm_isz_class_ClawScanner; +#endif + +string_t gm_isz_class_Bullseye; + +string_t gm_isz_class_PropPhysics; +string_t gm_isz_class_PropPhysicsOverride; +string_t gm_isz_class_FuncPhysbox; +string_t gm_isz_class_EnvFire; + +// ------------------------------------------------------------- + +string_t gm_isz_name_player; +string_t gm_isz_name_activator; + +// ------------------------------------------------------------- + +// ------------------------------------------------------------- + +// Does the classname of this entity match the string_t? +// +// This function is for comparing global strings and allows us to change how we compare them quickly. +inline bool EntIsClass( CBaseEntity *ent, string_t str2 ) +{ + //return ent->ClassMatches(str2); + + // Since classnames are pooled, the global string and the entity's classname should point to the same string in memory. + // As long as this rule is preserved, we only need a pointer comparison. A string comparison isn't necessary. + // Feel free to correct me if I'm disastrously wrong. + return ent->m_iClassname == str2; +} + +inline void SetGlobalString( string_t &string, const char *text ) +{ + //string = AllocPooledString(text); + + // Entities usually allocate global strings every time one of them spawns, meaning the string could've already been allocated either + // by the same type of entity already being spawned or some other means. + // If it's already allocated, we could easily just use "Find" instead of "Alloc". There's a fallback if we don't find it in the string pool. + string = FindPooledString( text ); + if (string == NULL_STRING) + string = AllocPooledString( text ); +} + +// We know it hasn't been allocated yet +#define INITIALIZE_GLOBAL_STRING(string, text) string = AllocPooledString(text) //SetGlobalString(string, text) + +void InitGlobalStrings() +{ +#ifdef HL2_DLL + INITIALIZE_GLOBAL_STRING(gm_isz_class_Shotgun, "weapon_shotgun"); + INITIALIZE_GLOBAL_STRING(gm_isz_class_SMG1, "weapon_smg1"); + INITIALIZE_GLOBAL_STRING(gm_isz_class_AR2, "weapon_ar2"); + INITIALIZE_GLOBAL_STRING(gm_isz_class_Pistol, "weapon_pistol"); + INITIALIZE_GLOBAL_STRING(gm_isz_class_Stunstick, "weapon_stunstick"); + INITIALIZE_GLOBAL_STRING(gm_isz_class_Crowbar, "weapon_crowbar"); + INITIALIZE_GLOBAL_STRING(gm_isz_class_RPG, "weapon_rpg"); + INITIALIZE_GLOBAL_STRING(gm_isz_class_357, "weapon_357"); + INITIALIZE_GLOBAL_STRING(gm_isz_class_Grenade, "weapon_frag"); + INITIALIZE_GLOBAL_STRING(gm_isz_class_Physcannon, "weapon_physcannon"); + INITIALIZE_GLOBAL_STRING(gm_isz_class_Crossbow, "weapon_crossbow"); + + INITIALIZE_GLOBAL_STRING(gm_isz_class_Strider, "npc_strider"); + INITIALIZE_GLOBAL_STRING(gm_isz_class_Gunship, "npc_combinegunship"); + INITIALIZE_GLOBAL_STRING(gm_isz_class_Dropship, "npc_combinedropship"); + INITIALIZE_GLOBAL_STRING(gm_isz_class_FloorTurret, "npc_turret_floor"); + INITIALIZE_GLOBAL_STRING(gm_isz_class_CScanner, "npc_cscanner"); + INITIALIZE_GLOBAL_STRING(gm_isz_class_ClawScanner, "npc_clawscanner"); +#endif + + INITIALIZE_GLOBAL_STRING(gm_isz_class_Bullseye, "npc_bullseye"); + + INITIALIZE_GLOBAL_STRING(gm_isz_class_PropPhysics, "prop_physics"); + INITIALIZE_GLOBAL_STRING(gm_isz_class_PropPhysicsOverride, "prop_physics_override"); + INITIALIZE_GLOBAL_STRING(gm_isz_class_FuncPhysbox, "func_physbox"); + INITIALIZE_GLOBAL_STRING(gm_isz_class_EnvFire, "env_fire"); + + INITIALIZE_GLOBAL_STRING(gm_isz_name_player, "!player"); + INITIALIZE_GLOBAL_STRING(gm_isz_name_activator, "!activator"); +} + +// ------------------------------------------------------------- + + + diff --git a/sp/src/game/server/mapbase/GlobalStrings.h b/sp/src/game/server/mapbase/GlobalStrings.h new file mode 100644 index 00000000..2dadb5d4 --- /dev/null +++ b/sp/src/game/server/mapbase/GlobalStrings.h @@ -0,0 +1,77 @@ +//========= Copyright Valve Corporation, All rights reserved. ================== +// +// Purpose: Shared global string library. +// +// $NoKeywords: $ +//============================================================================= + +#include "cbase.h" + +// ------------------------------------------------------------- +// +// Valve uses global pooled strings in various parts of the code, particularly Episodic code, +// so they could get away with integer/pointer comparisons instead of string comparisons. +// +// While developing Mapbase, I thought of what it would be like if that system was more uniform and more widely used. +// My OCD ended up taking me over and that thought became real, even though on today's machines these are (for the most part) micro-optimizations +// that just clutter the code. +// +// It was fun and satisfying to do this and I hope you are not judging me for my strange ways. +// I wanted to toggle them via a preprocessor so you could turn them off at will, but that just made things messier. +// I hope this doesn't cause problems for anyone. +// +// ------------------------------------------------------------- + +// ------------------------------------------------------------- +// +// Classnames +// +// ------------------------------------------------------------- + +#ifdef HL2_DLL +extern string_t gm_isz_class_Shotgun; +extern string_t gm_isz_class_SMG1; +extern string_t gm_isz_class_AR2; +extern string_t gm_isz_class_Pistol; +extern string_t gm_isz_class_Stunstick; +extern string_t gm_isz_class_Crowbar; +extern string_t gm_isz_class_RPG; +extern string_t gm_isz_class_357; +extern string_t gm_isz_class_Grenade; +extern string_t gm_isz_class_Physcannon; +extern string_t gm_isz_class_Crossbow; + +extern string_t gm_isz_class_Strider; +extern string_t gm_isz_class_Gunship; +extern string_t gm_isz_class_Dropship; +extern string_t gm_isz_class_FloorTurret; +extern string_t gm_isz_class_CScanner; +extern string_t gm_isz_class_ClawScanner; +#endif + +extern string_t gm_isz_class_Bullseye; + +extern string_t gm_isz_class_PropPhysics; +extern string_t gm_isz_class_PropPhysicsOverride; +extern string_t gm_isz_class_FuncPhysbox; +extern string_t gm_isz_class_EnvFire; + +// ------------------------------------------------------------- + +extern string_t gm_isz_name_player; +extern string_t gm_isz_name_activator; + +// ------------------------------------------------------------- + +// Does the classname of this entity match the string_t? +// +// This function is for comparing global strings and allows us to change how we compare them quickly. +extern bool EntIsClass( CBaseEntity *ent, string_t str2 ); + +extern void SetGlobalString( string_t &string, const char *text ); + +// ------------------------------------------------------------- + +extern void InitGlobalStrings(); + +// ------------------------------------------------------------- diff --git a/sp/src/game/server/mapbase/SystemConvarMod.cpp b/sp/src/game/server/mapbase/SystemConvarMod.cpp new file mode 100644 index 00000000..4517eea6 --- /dev/null +++ b/sp/src/game/server/mapbase/SystemConvarMod.cpp @@ -0,0 +1,293 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Mostly just Mapbase's convar mod code. +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" +#include "saverestore_utlvector.h" +#include "SystemConvarMod.h" + + +BEGIN_SIMPLE_DATADESC( modifiedconvars_t ) + DEFINE_ARRAY( pszConvar, FIELD_CHARACTER, MAX_MODIFIED_CONVAR_STRING ), + DEFINE_ARRAY( pszCurrentValue, FIELD_CHARACTER, MAX_MODIFIED_CONVAR_STRING ), + DEFINE_ARRAY( pszOrgValue, FIELD_CHARACTER, MAX_MODIFIED_CONVAR_STRING ), +END_DATADESC() + + +// ====================================================================== +// +// Everything below here is for the Mapbase convar mod system. +// ...which is based off of the Commentary convar mod system. +// +// ====================================================================== + +#define MAX_CONVARMOD_STRING_SIZE 512 + +CHandle m_hConvarsChanging; +CMapbaseCVarModEntity *ChangingCVars( void ) { return m_hConvarsChanging.Get(); } +void SetChangingCVars( CMapbaseCVarModEntity *hEnt ) { m_hConvarsChanging = hEnt; } + +CUtlVector< CHandle > m_ModEntities; +bool m_bModActive; + +void ConvarChanged( IConVar *pConVar, const char *pOldString, float flOldValue ) +{ + ConVarRef var( pConVar ); + CMapbaseCVarModEntity *modent = ChangingCVars(); + + for ( int i = 0; i < m_ModEntities.Count(); i++ ) + { + if (!m_ModEntities[i]) + { + Warning("NULL mod entity at %i\n", i); + continue; + } + + if (m_ModEntities[i].Get()->NewCVar(&var, pOldString, modent)) + break; + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CV_GlobalChange_Mapbase( IConVar *var, const char *pOldString, float flOldValue ) +{ + if ( !ChangingCVars() ) + { + // A convar has changed, but not due to Mapbase systems. Ignore it. + return; + } + + ConvarChanged( var, pOldString, flOldValue ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CC_MapbaseNotChangingCVars( void ) +{ + SetChangingCVars( false ); +} +static ConCommand mapbase_cvarsnotchanging("mapbase_cvarsnotchanging", CC_MapbaseNotChangingCVars, "An internal command used for ConVar modification.", FCVAR_HIDDEN); + +// ------------------------------------------------------------------------ + +void CV_InitMod() +{ + if (!m_bModActive) + { + cvar->InstallGlobalChangeCallback( CV_GlobalChange_Mapbase ); + m_bModActive = true; + } +} + +// ------------------------------------------------------------------------ + +void CVEnt_Precache(CMapbaseCVarModEntity *modent) +{ + // Maybe add some security/notification stuff here later + CV_InitMod(); +} +void CVEnt_Activate(CMapbaseCVarModEntity *modent, CBaseEntity *pActivator = UTIL_GetLocalPlayer()) +{ + edict_t *edict = pActivator ? pActivator->edict() : NULL; + if (!edict) + return; + + SetChangingCVars( modent ); + + if (m_ModEntities.Find(modent) == m_ModEntities.InvalidIndex()) + m_ModEntities.AddToTail(modent); + + const char *pszCommands = STRING( modent->m_target ); + if ( Q_strnchr(pszCommands, '^', MAX_CONVARMOD_STRING_SIZE) ) + { + // Just like the commentary system, we convert ^s to "s here. + char szTmp[MAX_CONVARMOD_STRING_SIZE]; + Q_strncpy( szTmp, pszCommands, MAX_CONVARMOD_STRING_SIZE ); + int len = Q_strlen( szTmp ); + for ( int i = 0; i < len; i++ ) + { + if ( szTmp[i] == '^' ) + { + szTmp[i] = '"'; + } + } + + pszCommands = szTmp; + } + + engine->ClientCommand( edict, pszCommands ); + engine->ClientCommand( edict, "mapbase_cvarsnotchanging\n" ); +} +void CVEnt_Deactivate(CMapbaseCVarModEntity *modent) +{ + // Remove our global convar callback + cvar->RemoveGlobalChangeCallback( CV_GlobalChange_Mapbase ); + + // Reset any convars that have been changed by the commentary + for ( int i = 0; i < modent->m_ModifiedConvars.Count(); i++ ) + { + ConVar *pConVar = (ConVar *)cvar->FindVar( modent->m_ModifiedConvars[i].pszConvar ); + if ( pConVar ) + { + pConVar->SetValue( modent->m_ModifiedConvars[i].pszOrgValue ); + } + } + + if (m_bModActive) + { + m_ModEntities.FindAndRemove(modent); + + if (m_ModEntities.Count() == 0) + { + // No more mod entities + m_bModActive = false; + } + else + { + // We're done and we're still active, install our callback again + cvar->InstallGlobalChangeCallback( CV_GlobalChange_Mapbase ); + } + } +} +void CVEnt_Restore(CMapbaseCVarModEntity *modent) +{ + m_ModEntities.AddToTail(modent); +} + +// ------------------------------------------------------------------------ + + +LINK_ENTITY_TO_CLASS( game_convar_mod, CMapbaseCVarModEntity ); + +// This classname should be phased out after beta +LINK_ENTITY_TO_CLASS( mapbase_convar_mod, CMapbaseCVarModEntity ); + +BEGIN_DATADESC( CMapbaseCVarModEntity ) + + DEFINE_UTLVECTOR( m_ModifiedConvars, FIELD_EMBEDDED ), + + // Inputs + DEFINE_INPUTFUNC( FIELD_VOID, "Activate", InputActivate ), + DEFINE_INPUTFUNC( FIELD_VOID, "Deactivate", InputDeactivate ), + +END_DATADESC() + + +void CMapbaseCVarModEntity::UpdateOnRemove() +{ + BaseClass::UpdateOnRemove(); + + CVEnt_Deactivate(this); +} + +void CMapbaseCVarModEntity::Precache( void ) +{ + BaseClass::Precache(); + + CVEnt_Precache(this); +} + +void CMapbaseCVarModEntity::Spawn( void ) +{ + BaseClass::Spawn(); + + if (m_target == NULL_STRING) + { + Warning("WARNING: %s has no cvars specified! Removing...\n", GetDebugName()); + UTIL_Remove(this); + return; + } + + Precache(); + + if (HasSpawnFlags(SF_CVARMOD_START_ACTIVATED)) + { + CVEnt_Activate(this); + } +} + +void CMapbaseCVarModEntity::OnRestore( void ) +{ + BaseClass::OnRestore(); + + // Set any convars that have already been changed by the mapper before the save + if (m_ModifiedConvars.Count() > 0) + { + for ( int i = 0; i < m_ModifiedConvars.Count(); i++ ) + { + ConVar *pConVar = (ConVar *)cvar->FindVar( m_ModifiedConvars[i].pszConvar ); + if ( pConVar ) + { + //Msg(" %s Restoring Convar %s: value %s (org %s)\n", GetDebugName(), m_ModifiedConvars[i].pszConvar, m_ModifiedConvars[i].pszCurrentValue, m_ModifiedConvars[i].pszOrgValue ); + pConVar->SetValue( m_ModifiedConvars[i].pszCurrentValue ); + } + } + + CVEnt_Restore(this); + } +} + +void CMapbaseCVarModEntity::InputActivate(inputdata_t &inputdata) +{ + CVEnt_Activate(this); +} + +void CMapbaseCVarModEntity::InputDeactivate(inputdata_t &inputdata) +{ + CVEnt_Deactivate(this); +} + +bool CMapbaseCVarModEntity::NewCVar( ConVarRef *var, const char *pOldString, CBaseEntity *modent ) +{ + for (int i = 0; i < m_ModifiedConvars.Count(); i++) + { + // If we find it, just update the current value + modifiedconvars_t modvar = m_ModifiedConvars[i]; + if ( !Q_strncmp( var->GetName(), modvar.pszConvar, MAX_MODIFIED_CONVAR_STRING ) ) + { + if (modent == this) + { + Q_strncpy( modvar.pszCurrentValue, var->GetString(), MAX_MODIFIED_CONVAR_STRING ); + //Msg(" %s Updating Convar %s: value %s (org %s)\n", GetDebugName(), modvar.pszConvar, modvar.pszCurrentValue, modvar.pszOrgValue ); + return true; + } + else + { + // A different entity is using this CVar now, remove ours + m_ModifiedConvars.Remove(i); + //Msg(" %s Removing Convar %s: value %s (org %s)\n", GetDebugName(), modvar.pszConvar, modvar.pszCurrentValue, modvar.pszOrgValue ); + return false; + } + } + } + + // Did I do that? + if (modent == this) + { + // Add the CVar to our list. + modifiedconvars_t newConvar; + Q_strncpy( newConvar.pszConvar, var->GetName(), MAX_MODIFIED_CONVAR_STRING ); + Q_strncpy( newConvar.pszCurrentValue, var->GetString(), MAX_MODIFIED_CONVAR_STRING ); + Q_strncpy( newConvar.pszOrgValue, pOldString, MAX_MODIFIED_CONVAR_STRING ); + m_ModifiedConvars.AddToTail( newConvar ); + + /* + Msg(" %s changed '%s' to '%s' (was '%s')\n", GetDebugName(), var->GetName(), var->GetString(), pOldString ); + Msg(" Convars stored: %d\n", m_ModifiedConvars.Count() ); + for ( int i = 0; i < m_ModifiedConvars.Count(); i++ ) + { + Msg(" Convar %d: %s, value %s (org %s)\n", i, m_ModifiedConvars[i].pszConvar, m_ModifiedConvars[i].pszCurrentValue, m_ModifiedConvars[i].pszOrgValue ); + } + */ + + return true; + } + + return false; +} diff --git a/sp/src/game/server/mapbase/SystemConvarMod.h b/sp/src/game/server/mapbase/SystemConvarMod.h new file mode 100644 index 00000000..f33a7471 --- /dev/null +++ b/sp/src/game/server/mapbase/SystemConvarMod.h @@ -0,0 +1,47 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: modifiedconvarts_t from CommentarySystem.cpp moved to a header file so Mapbase can use it. +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" + + +// Convar restoration save/restore +#define MAX_MODIFIED_CONVAR_STRING 128 +struct modifiedconvars_t +{ + DECLARE_SIMPLE_DATADESC(); + + char pszConvar[MAX_MODIFIED_CONVAR_STRING]; + char pszCurrentValue[MAX_MODIFIED_CONVAR_STRING]; + char pszOrgValue[MAX_MODIFIED_CONVAR_STRING]; +}; + +// --------------------------------------------------------------------- + +#define SF_CVARMOD_START_ACTIVATED (1 << 0) + +class CMapbaseCVarModEntity : public CPointEntity +{ +public: + DECLARE_CLASS( CMapbaseCVarModEntity, CPointEntity ); + + void UpdateOnRemove(); + + void Precache( void ); + + void Spawn( void ); + + void OnRestore( void ); + + void InputActivate(inputdata_t &inputdata); + void InputDeactivate(inputdata_t &inputdata); + + bool NewCVar( ConVarRef *var, const char *pOldString, CBaseEntity *modent ); + + CUtlVector< modifiedconvars_t > m_ModifiedConvars; + + DECLARE_DATADESC(); +}; diff --git a/sp/src/game/server/mapbase/ai_grenade.cpp b/sp/src/game/server/mapbase/ai_grenade.cpp new file mode 100644 index 00000000..387a45fb --- /dev/null +++ b/sp/src/game/server/mapbase/ai_grenade.cpp @@ -0,0 +1,13 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#include "cbase.h" + +#include "ai_grenade.h" + + +int COMBINE_AE_BEGIN_ALTFIRE; +int COMBINE_AE_ALTFIRE; diff --git a/sp/src/game/server/mapbase/ai_grenade.h b/sp/src/game/server/mapbase/ai_grenade.h new file mode 100644 index 00000000..1816ad95 --- /dev/null +++ b/sp/src/game/server/mapbase/ai_grenade.h @@ -0,0 +1,602 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#ifndef AI_GRENADE_H +#define AI_GRENADE_H +#ifdef _WIN32 +#pragma once +#endif + +// I wish I didn't have to #include all this, but I don't really have a choice. +// I guess something similar to CAI_BehaviorHost's backbridges could be tried. +#include "cbase.h" +#include "ai_basenpc.h" +#include "npcevent.h" +#include "grenade_frag.h" +#include "basegrenade_shared.h" +#include "ai_squad.h" +#include "GlobalStrings.h" + +#define COMBINE_AE_GREN_TOSS ( 7 ) + +#define COMBINE_GRENADE_THROW_SPEED 650 +#define COMBINE_GRENADE_TIMER 3.5 +#define COMBINE_GRENADE_FLUSH_TIME 3.0 // Don't try to flush an enemy who has been out of sight for longer than this. +#define COMBINE_GRENADE_FLUSH_DIST 256.0 // Don't try to flush an enemy who has moved farther than this distance from the last place I saw him. + +#define COMBINE_MIN_GRENADE_CLEAR_DIST 250 + +#define DEFINE_AIGRENADE_DATADESC() \ + DEFINE_KEYFIELD( m_iNumGrenades, FIELD_INTEGER, "NumGrenades" ), \ + DEFINE_FIELD( m_flNextGrenadeCheck, FIELD_TIME ), \ + DEFINE_FIELD( m_hForcedGrenadeTarget, FIELD_EHANDLE ), \ + DEFINE_FIELD( m_flNextAltFireTime, FIELD_TIME ), \ + DEFINE_FIELD( m_vecAltFireTarget, FIELD_VECTOR ), \ + DEFINE_FIELD( m_vecTossVelocity, FIELD_VECTOR ), \ + DEFINE_INPUTFUNC( FIELD_STRING, "ThrowGrenadeAtTarget", InputThrowGrenadeAtTarget ), \ + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetGrenades", InputSetGrenades ), \ + DEFINE_INPUTFUNC( FIELD_INTEGER, "AddGrenades", InputAddGrenades ), \ + DEFINE_OUTPUT(m_OnThrowGrenade, "OnThrowGrenade"), \ + DEFINE_OUTPUT(m_OnOutOfGrenades, "OnOutOfGrenades"), \ + +// Use extern float GetCurrentGravity( void ); +#define SMGGrenadeArc(shootpos, targetpos) \ + Vector vecShootPos = shootpos; \ + Vector vecThrow = (targetpos - vecShootPos); \ + float time = vecThrow.Length() / 600.0; \ + vecThrow = vecThrow * (1.0 / time); \ + vecThrow.z += (GetCurrentGravity() * 0.5) * time * 0.5; \ + Vector vecFace = vecShootPos + (vecThrow * 0.5); \ + AddFacingTarget(vecFace, 1.0, 0.5); \ + +// Mask used for Combine ball hull traces. +// This used MASK_SHOT before, but this has been changed to MASK_SHOT_HULL. +// Hopefully this doesn't have any major consequences... +#define MASK_COMBINE_BALL_LOS MASK_SHOT_HULL + +extern int COMBINE_AE_BEGIN_ALTFIRE; +extern int COMBINE_AE_ALTFIRE; + +//----------------------------------------------------------------------------- +// +// Template class for NPCs using grenades or weapon alt-fire stuff. +// You'll still have to use DEFINE_AIGRENADE_DATADESC() in your derived class's datadesc. +// +// I wanted to have these functions defined in a CPP file, but template class definitions must be in the header. +// Please excuse the bloat below the class definition. +// +//----------------------------------------------------------------------------- +template +class CAI_GrenadeUser : public BASE_NPC +{ + DECLARE_CLASS_NOFRIEND( CAI_GrenadeUser, BASE_NPC ); +public: + void AddGrenades( int inc, CBaseEntity *pLastGrenade = NULL ) + { + m_iNumGrenades += inc; + if (m_iNumGrenades <= 0) + m_OnOutOfGrenades.Set( pLastGrenade, pLastGrenade, this ); + } + + virtual bool IsAltFireCapable() { return false; } + virtual bool IsGrenadeCapable() { return true; } + inline bool HasGrenades() { return m_iNumGrenades > 0; } + + void InputSetGrenades( inputdata_t &inputdata ) { AddGrenades( inputdata.value.Int() - m_iNumGrenades ); } + void InputAddGrenades( inputdata_t &inputdata ) { AddGrenades( inputdata.value.Int() ); } + void InputThrowGrenadeAtTarget( inputdata_t &inputdata ); + + virtual void DelayGrenadeCheck( float delay ) { m_flNextGrenadeCheck = gpGlobals->curtime + delay; } + + void HandleAnimEvent( animevent_t *pEvent ); + + // Soldiers use "lefthand", cops use "LHand", and citizens use "anim_attachment_LH" + virtual const char* GetGrenadeAttachment() { return "anim_attachment_LH"; } + + Vector GetAltFireTarget() { return m_vecAltFireTarget; } + virtual bool CanAltFireEnemy( bool bUseFreeKnowledge ); + void DelayAltFireAttack( float flDelay ); + void DelaySquadAltFireAttack( float flDelay ); + + virtual bool CanGrenadeEnemy( bool bUseFreeKnowledge = true ); + bool CanThrowGrenade( const Vector &vecTarget ); + bool CheckCanThrowGrenade( const Vector &vecTarget ); + +protected: + + void StartTask_FaceAltFireTarget( const Task_t *pTask ); + void StartTask_GetPathToForced( const Task_t *pTask ); + void StartTask_DeferSquad( const Task_t *pTask ); + + void RunTask_FaceAltFireTarget( const Task_t *pTask ); + void RunTask_GetPathToForced( const Task_t *pTask ); + void RunTask_FaceTossDir( const Task_t *pTask ); + +protected: // We can't have any private saved variables because only derived classes use the datadescs + + int m_iNumGrenades; + float m_flNextGrenadeCheck; + EHANDLE m_hForcedGrenadeTarget; + + float m_flNextAltFireTime; + Vector m_vecAltFireTarget; + Vector m_vecTossVelocity; + + COutputEHANDLE m_OnThrowGrenade; + COutputEHANDLE m_OnOutOfGrenades; +}; + +//------------------------------------------------------------------------------ +// Purpose: Handle animation events +//------------------------------------------------------------------------------ +template +void CAI_GrenadeUser::HandleAnimEvent( animevent_t *pEvent ) +{ + if ( pEvent->event == COMBINE_AE_BEGIN_ALTFIRE ) + { + EmitSound( "Weapon_CombineGuard.Special1" ); + //SpeakIfAllowed( TLK_CMB_THROWGRENADE, "altfire:1" ); + return; + } + if ( pEvent->event == COMBINE_AE_ALTFIRE ) + { + animevent_t fakeEvent; + + fakeEvent.pSource = this; + fakeEvent.event = EVENT_WEAPON_AR2_ALTFIRE; + GetActiveWeapon()->Operator_HandleAnimEvent( &fakeEvent, this ); + + // Stop other squad members from combine balling for a while. + DelaySquadAltFireAttack( 10.0f ); + + AddGrenades(-1); + + return; + } + + if ( pEvent->event == COMBINE_AE_GREN_TOSS ) + { + Vector vecSpin; + vecSpin.x = random->RandomFloat( -1000.0, 1000.0 ); + vecSpin.y = random->RandomFloat( -1000.0, 1000.0 ); + vecSpin.z = random->RandomFloat( -1000.0, 1000.0 ); + + Vector vecStart; + GetAttachment( GetGrenadeAttachment(), vecStart ); + + if( m_NPCState == NPC_STATE_SCRIPT ) + { + // Use a fixed velocity for grenades thrown in scripted state. + // Grenades thrown from a script do not count against grenades remaining for the AI to use. + Vector forward, up, vecThrow; + + GetVectors( &forward, NULL, &up ); + vecThrow = forward * 750 + up * 175; + + CBaseEntity *pGrenade = Fraggrenade_Create( vecStart, vec3_angle, vecThrow, vecSpin, this, COMBINE_GRENADE_TIMER, true ); + m_OnThrowGrenade.Set(pGrenade, pGrenade, this); + } + else + { + // Use the Velocity that AI gave us. + CBaseEntity *pGrenade = Fraggrenade_Create( vecStart, vec3_angle, m_vecTossVelocity, vecSpin, this, COMBINE_GRENADE_TIMER, true ); + m_OnThrowGrenade.Set(pGrenade, pGrenade, this); + AddGrenades(-1, pGrenade); + } + + // wait six seconds before even looking again to see if a grenade can be thrown. + m_flNextGrenadeCheck = gpGlobals->curtime + 6; + return; + } + + BaseClass::HandleAnimEvent( pEvent ); +} + +//----------------------------------------------------------------------------- +// Purpose: Force the combine soldier to throw a grenade at the target +// If I'm a combine elite, fire my combine ball at the target instead. +// Input : &inputdata - +//----------------------------------------------------------------------------- +template +void CAI_GrenadeUser::InputThrowGrenadeAtTarget( inputdata_t &inputdata ) +{ + // Ignore if we're inside a scripted sequence + if ( m_NPCState == NPC_STATE_SCRIPT && m_hCine ) + return; + + CBaseEntity *pEntity = gEntList.FindEntityByName( NULL, inputdata.value.String(), this, inputdata.pActivator, inputdata.pCaller ); + if ( !pEntity ) + { + DevMsg("%s (%s) received ThrowGrenadeAtTarget input, but couldn't find target entity '%s'\n", GetClassname(), GetDebugName(), inputdata.value.String() ); + return; + } + + m_hForcedGrenadeTarget = pEntity; + m_flNextGrenadeCheck = 0; + + ClearSchedule( "Told to throw grenade via input" ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +template +bool CAI_GrenadeUser::CanAltFireEnemy( bool bUseFreeKnowledge ) +{ + if (!HasGrenades()) + return false; + + if (!IsAltFireCapable()) + return false; + + if (!GetActiveWeapon()) + return false; + + if (IsCrouching()) + return false; + + if ( gpGlobals->curtime < m_flNextAltFireTime || gpGlobals->curtime < m_flNextGrenadeCheck ) + return false; + + if( !GetEnemy() ) + return false; + + if (!EntIsClass(GetActiveWeapon(), gm_isz_class_AR2) && !EntIsClass(GetActiveWeapon(), gm_isz_class_SMG1)) + return false; + + CBaseEntity *pEnemy = GetEnemy(); + + Vector vecTarget; + + // Determine what point we're shooting at + if( bUseFreeKnowledge ) + { + vecTarget = GetEnemies()->LastKnownPosition( pEnemy ) + (pEnemy->GetViewOffset()*0.75);// approximates the chest + } + else + { + vecTarget = GetEnemies()->LastSeenPosition( pEnemy ) + (pEnemy->GetViewOffset()*0.75);// approximates the chest + } + + // Trace a hull about the size of the combine ball (don't shoot through grates!) + trace_t tr; + + Vector mins( -12, -12, -12 ); + Vector maxs( 12, 12, 12 ); + + Vector vShootPosition = EyePosition(); + + if ( GetActiveWeapon() ) + { + GetActiveWeapon()->GetAttachment( "muzzle", vShootPosition ); + } + + // Trace a hull about the size of the combine ball. + UTIL_TraceHull( vShootPosition, vecTarget, mins, maxs, MASK_COMBINE_BALL_LOS, this, COLLISION_GROUP_NONE, &tr ); + + float flLength = (vShootPosition - vecTarget).Length(); + + flLength *= tr.fraction; + + // If the ball can travel at least 65% of the distance to the player then let the NPC shoot it. + // (unless it hit the world) + if( tr.fraction >= 0.65 && (!tr.m_pEnt || !tr.m_pEnt->IsWorld()) && flLength > 128.0f ) + { + // Target is valid + m_vecAltFireTarget = vecTarget; + return true; + } + + + // Check again later + m_vecAltFireTarget = vec3_origin; + m_flNextGrenadeCheck = gpGlobals->curtime + 1.0f; + return false; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +template +void CAI_GrenadeUser::DelayAltFireAttack( float flDelay ) +{ + float flNextAltFire = gpGlobals->curtime + flDelay; + + if( flNextAltFire > m_flNextAltFireTime ) + { + // Don't let this delay order preempt a previous request to wait longer. + m_flNextAltFireTime = flNextAltFire; + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +template +void CAI_GrenadeUser::DelaySquadAltFireAttack( float flDelay ) +{ + // Make sure to delay my own alt-fire attack. + DelayAltFireAttack( flDelay ); + + AISquadIter_t iter; + CAI_BaseNPC *pSquadmate = m_pSquad ? m_pSquad->GetFirstMember( &iter ) : NULL; + while ( pSquadmate ) + { + CAI_GrenadeUser *pUser = dynamic_cast(pSquadmate); + if( pUser && pUser->IsAltFireCapable() ) + { + pUser->DelayAltFireAttack( flDelay ); + } + + pSquadmate = m_pSquad->GetNextMember( &iter ); + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +template +bool CAI_GrenadeUser::CanGrenadeEnemy( bool bUseFreeKnowledge ) +{ + CBaseEntity *pEnemy = GetEnemy(); + + Assert( pEnemy != NULL ); + + if( pEnemy ) + { + // I'm not allowed to throw grenades during dustoff + if ( IsCurSchedule(SCHED_DROPSHIP_DUSTOFF) ) + return false; + + if( bUseFreeKnowledge ) + { + // throw to where we think they are. + return CanThrowGrenade( GetEnemies()->LastKnownPosition( pEnemy ) ); + } + else + { + // hafta throw to where we last saw them. + return CanThrowGrenade( GetEnemies()->LastSeenPosition( pEnemy ) ); + } + } + + return false; +} + +//----------------------------------------------------------------------------- +// Purpose: Return true if the combine has grenades, hasn't checked lately, and +// can throw a grenade at the target point. +// Input : &vecTarget - +// Output : Returns true on success, false on failure. +//----------------------------------------------------------------------------- +template +bool CAI_GrenadeUser::CanThrowGrenade( const Vector &vecTarget ) +{ + if( m_iNumGrenades < 1 ) + { + // Out of grenades! + return false; + } + + if (!IsGrenadeCapable()) + { + // Must be capable of throwing grenades + return false; + } + + if ( gpGlobals->curtime < m_flNextGrenadeCheck ) + { + // Not allowed to throw another grenade right now. + return false; + } + + float flDist; + flDist = ( vecTarget - GetAbsOrigin() ).Length(); + + if( flDist > 1024 || flDist < 128 ) + { + // Too close or too far! + m_flNextGrenadeCheck = gpGlobals->curtime + 1; // one full second. + return false; + } + + // ----------------------- + // If moving, don't check. + // ----------------------- + if ( m_flGroundSpeed != 0 ) + return false; + + // --------------------------------------------------------------------- + // Are any of my squad members near the intended grenade impact area? + // --------------------------------------------------------------------- + if ( m_pSquad ) + { + if (m_pSquad->SquadMemberInRange( vecTarget, COMBINE_MIN_GRENADE_CLEAR_DIST )) + { + // crap, I might blow my own guy up. Don't throw a grenade and don't check again for a while. + m_flNextGrenadeCheck = gpGlobals->curtime + 1; // one full second. + + // Tell my squad members to clear out so I can get a grenade in + // Mapbase uses a new context here that gets all nondescript allies away since this code is shared between Combine and non-Combine now. + CSoundEnt::InsertSound( SOUND_MOVE_AWAY | SOUND_CONTEXT_OWNER_ALLIES, vecTarget, COMBINE_MIN_GRENADE_CLEAR_DIST, 0.1, this ); + return false; + } + } + + return CheckCanThrowGrenade( vecTarget ); +} + +//----------------------------------------------------------------------------- +// Purpose: Returns true if the combine can throw a grenade at the specified target point +// Input : &vecTarget - +// Output : Returns true on success, false on failure. +//----------------------------------------------------------------------------- +template +bool CAI_GrenadeUser::CheckCanThrowGrenade( const Vector &vecTarget ) +{ + //NDebugOverlay::Line( EyePosition(), vecTarget, 0, 255, 0, false, 5 ); + + // --------------------------------------------------------------------- + // Check that throw is legal and clear + // --------------------------------------------------------------------- + // FIXME: this is only valid for hand grenades, not RPG's + Vector vecToss; + Vector vecMins = -Vector(4,4,4); + Vector vecMaxs = Vector(4,4,4); + if( FInViewCone( vecTarget ) && CBaseEntity::FVisible( vecTarget ) ) + { + vecToss = VecCheckThrow( this, EyePosition(), vecTarget, COMBINE_GRENADE_THROW_SPEED, 1.0, &vecMins, &vecMaxs ); + } + else + { + // Have to try a high toss. Do I have enough room? + trace_t tr; + AI_TraceLine( EyePosition(), EyePosition() + Vector( 0, 0, 64 ), MASK_SHOT, this, COLLISION_GROUP_NONE, &tr ); + if( tr.fraction != 1.0 ) + { + return false; + } + + vecToss = VecCheckToss( this, EyePosition(), vecTarget, -1, 1.0, true, &vecMins, &vecMaxs ); + } + + if ( vecToss != vec3_origin ) + { + m_vecTossVelocity = vecToss; + + // don't check again for a while. + m_flNextGrenadeCheck = gpGlobals->curtime + 1; // 1/3 second. + return true; + } + else + { + // don't check again for a while. + m_flNextGrenadeCheck = gpGlobals->curtime + 1; // one full second. + return false; + } +} + +//----------------------------------------------------------------------------- +// Purpose: Task helpers +//----------------------------------------------------------------------------- +template +void CAI_GrenadeUser::StartTask_FaceAltFireTarget( const Task_t *pTask ) +{ + SetIdealActivity( (Activity)(int)pTask->flTaskData ); + GetMotor()->SetIdealYawToTargetAndUpdate( m_vecAltFireTarget, AI_KEEP_YAW_SPEED ); +} + +template +void CAI_GrenadeUser::StartTask_GetPathToForced( const Task_t *pTask ) +{ + if ( !m_hForcedGrenadeTarget ) + { + TaskFail(FAIL_NO_ENEMY); + return; + } + + float flMaxRange = 2000; + float flMinRange = 0; + + Vector vecEnemy = m_hForcedGrenadeTarget->GetAbsOrigin(); + Vector vecEnemyEye = vecEnemy + m_hForcedGrenadeTarget->GetViewOffset(); + + Vector posLos; + bool found = false; + + if ( GetTacticalServices()->FindLateralLos( vecEnemyEye, &posLos ) ) + { + float dist = ( posLos - vecEnemyEye ).Length(); + if ( dist < flMaxRange && dist > flMinRange ) + found = true; + } + + if ( !found && GetTacticalServices()->FindLos( vecEnemy, vecEnemyEye, flMinRange, flMaxRange, 1.0, &posLos ) ) + { + found = true; + } + + if ( !found ) + { + TaskFail( FAIL_NO_SHOOT ); + } + else + { + // else drop into run task to offer an interrupt + m_vInterruptSavePosition = posLos; + } +} + +template +void CAI_GrenadeUser::StartTask_DeferSquad( const Task_t *pTask ) +{ + if ( m_pSquad ) + { + // iterate my squad and stop everyone from throwing grenades for a little while. + AISquadIter_t iter; + + CAI_BaseNPC *pSquadmate = m_pSquad ? m_pSquad->GetFirstMember( &iter ) : NULL; + while ( pSquadmate ) + { + pSquadmate->DelayGrenadeCheck(5); + + pSquadmate = m_pSquad->GetNextMember( &iter ); + } + } + + TaskComplete(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +template +void CAI_GrenadeUser::RunTask_FaceAltFireTarget( const Task_t *pTask ) +{ + GetMotor()->SetIdealYawToTargetAndUpdate( m_vecAltFireTarget, AI_KEEP_YAW_SPEED ); + + // New Mapbase thing that fixes forced alt-fires not changing weapon yaw/pitch + SetAim( m_vecAltFireTarget - Weapon_ShootPosition() ); + + if (IsActivityFinished()) + { + TaskComplete(); + } +} + +template +void CAI_GrenadeUser::RunTask_GetPathToForced( const Task_t *pTask ) +{ + if ( !m_hForcedGrenadeTarget ) + { + TaskFail(FAIL_NO_ENEMY); + return; + } + + if ( GetTaskInterrupt() > 0 ) + { + ClearTaskInterrupt(); + + Vector vecEnemy = m_hForcedGrenadeTarget->GetAbsOrigin(); + AI_NavGoal_t goal( m_vInterruptSavePosition, ACT_RUN, AIN_HULL_TOLERANCE ); + + GetNavigator()->SetGoal( goal, AIN_CLEAR_TARGET ); + GetNavigator()->SetArrivalDirection( vecEnemy - goal.dest ); + } + else + { + TaskInterrupt(); + } +} + +template +void CAI_GrenadeUser::RunTask_FaceTossDir( const Task_t *pTask ) +{ + // project a point along the toss vector and turn to face that point. + GetMotor()->SetIdealYawToTargetAndUpdate( GetLocalOrigin() + m_vecTossVelocity * 64, AI_KEEP_YAW_SPEED ); + + if ( FacingIdeal() ) + { + TaskComplete( true ); + } +} + +#endif diff --git a/sp/src/game/server/mapbase/ai_monitor.cpp b/sp/src/game/server/mapbase/ai_monitor.cpp new file mode 100644 index 00000000..fe6120ec --- /dev/null +++ b/sp/src/game/server/mapbase/ai_monitor.cpp @@ -0,0 +1,733 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: An entity that watches an NPC for certain things. +// +//============================================================================= + +#include "cbase.h" +#include "ai_schedule.h" +#include "ai_hint.h" +#include "ai_route.h" +#include "ai_basenpc.h" +#include "saverestore_utlvector.h" + + +//#define AI_MONITOR_MAX_TARGETS 16 + +// Uses a CUtlVector instead of a CBitVec for conditions/schedules. +// Using a CUtlVector makes this a lot easier, if you ask me. Please note that the CBitVec version is incomplete. +#define AI_MONITOR_USE_UTLVECTOR 1 + +//----------------------------------------------------------------------------- +// Purpose: AI monitoring. Probably bad. +//----------------------------------------------------------------------------- +class CAI_Monitor : public CLogicalEntity +{ + DECLARE_CLASS( CAI_Monitor, CLogicalEntity ); +public: + CAI_Monitor(); + + void Spawn(); + void Activate( void ); + + virtual int Save( ISave &save ); + virtual int Restore( IRestore &restore ); +#if !AI_MONITOR_USE_UTLVECTOR + void SaveConditions( ISave &save, const CAI_ScheduleBits &conditions ); + void RestoreConditions( IRestore &restore, CAI_ScheduleBits *pConditions ); +#endif + + virtual bool KeyValue( const char *szKeyName, const char *szValue ); + //virtual bool GetKeyValue( const char *szKeyName, char *szValue, int iMaxLen ); + + // Populates our NPC list. + void PopulateNPCs(inputdata_t *inputdata); + + // Does evaluation, fires outputs, etc. + bool NPCDoEval(CAI_BaseNPC *pNPC); + + // Thinks. + void MonitorThink(); + + CAI_BaseNPC *GetFirstTarget(); + + void InputEnable( inputdata_t &inputdata ); + void InputDisable( inputdata_t &inputdata ); + void InputSetTarget( inputdata_t &inputdata ) { BaseClass::InputSetTarget(inputdata); PopulateNPCs(&inputdata); } + void InputPopulateNPCs( inputdata_t &inputdata ); + void InputTest( inputdata_t &inputdata ); + void InputTestNPC( inputdata_t &inputdata ); + + // Allows mappers to get condition/schedule names from ID + void InputGetConditionName( inputdata_t &inputdata ) { m_OutConditionName.Set(AllocPooledString(ConditionName(inputdata.value.Int())), inputdata.pActivator, this); } + void InputGetScheduleName( inputdata_t &inputdata ) { m_OutScheduleName.Set(AllocPooledString(ScheduleName(inputdata.value.Int())), inputdata.pActivator, this); } + COutputString m_OutConditionName; + COutputString m_OutScheduleName; + + void InputSetCondition( inputdata_t &inputdata ) { SetCondition(TranslateConditionString(inputdata.value.String())); } + void InputClearCondition( inputdata_t &inputdata ) { ClearCondition(TranslateConditionString(inputdata.value.String())); } +#if AI_MONITOR_USE_UTLVECTOR + void InputClearAllConditions( inputdata_t &inputdata ) { m_Conditions.RemoveAll(); } +#else + void InputClearAllConditions( inputdata_t &inputdata ) { m_Conditions.ClearAll(); } +#endif + + void InputSetSchedule( inputdata_t &inputdata ) { SetSchedule(TranslateScheduleString(inputdata.value.String())); } + void InputClearSchedule( inputdata_t &inputdata ) { ClearSchedule(TranslateScheduleString(inputdata.value.String())); } +#if AI_MONITOR_USE_UTLVECTOR + void InputClearAllSchedules( inputdata_t &inputdata ) { m_Schedules.RemoveAll(); } +#else + void InputClearAllSchedules( inputdata_t &inputdata ) { m_Schedules.ClearAll(); } +#endif + + void InputSetHint( inputdata_t &inputdata ) { SetHint(inputdata.value.Int()); } + void InputClearHint( inputdata_t &inputdata ) { ClearHint(inputdata.value.Int()); } + void InputClearAllHints( inputdata_t &inputdata ) { m_Hints.RemoveAll(); } + +public: + + bool m_bStartDisabled; + + // The NPCs. + CUtlVector pNPCs; + int m_iMaxEnts; + + // Stop and engage cooldown at first successful pass + bool m_bCooldownAtFirstSuccess; + + // Interval between monitors + float m_flThinkTime; + #define GetThinkTime() (m_flThinkTime != 0 ? m_flThinkTime : TICK_INTERVAL) + + // Cooldown after something is satisfied + float m_flCooldownTime; + #define GetCooldownTime() (m_flCooldownTime != -1 ? m_flCooldownTime : GetThinkTime()) + + // ------------------------------ + // Conditions + // ------------------------------ +#if AI_MONITOR_USE_UTLVECTOR + CUtlVector m_Conditions; +#else + CAI_ScheduleBits m_Conditions; +#endif + + COutputInt m_OnNPCHasCondition; + COutputInt m_OnNPCLacksCondition; + + // Condition functions, most of these are from CAI_BaseNPC. +#if AI_MONITOR_USE_UTLVECTOR + inline void SetCondition( int iCondition ) { m_Conditions.HasElement(iCondition) ? NULL : m_Conditions.AddToTail(iCondition); } + inline void ClearCondition( int iCondition ) { m_Conditions.FindAndRemove(iCondition); } + inline bool HasCondition( int iCondition ) { m_Conditions.HasElement(iCondition); } +#else + inline void SetCondition( int iCondition ) { m_Conditions.Set(iCondition); } + inline void ClearCondition( int iCondition ) { m_Conditions.Clear(iCondition); } + inline bool HasCondition( int iCondition ) { m_Conditions.IsBitSet(iCondition); } +#endif + + static int GetConditionID(const char* condName) { return CAI_BaseNPC::GetSchedulingSymbols()->ConditionSymbolToId(condName); } + const char *ConditionName(int conditionID); + + int TranslateConditionString(const char *condName); + inline int ConditionLocalToGlobal(CAI_BaseNPC *pTarget, int conditionID) { return pTarget->GetClassScheduleIdSpace()->ConditionLocalToGlobal(conditionID); } + + // ------------------------------ + // Schedules + // ------------------------------ +#if AI_MONITOR_USE_UTLVECTOR + CUtlVector m_Schedules; +#else + CAI_ScheduleBits m_Schedules; +#endif + + bool m_bTranslateSchedules; + + COutputInt m_OnNPCRunningSchedule; + COutputInt m_OnNPCNotRunningSchedule; + + // Schedule functions, some of these are from CAI_BaseNPC. +#if AI_MONITOR_USE_UTLVECTOR + inline void SetSchedule( int iSchedule ) { m_Schedules.HasElement(iSchedule) ? NULL : m_Schedules.AddToTail(iSchedule); } + inline void ClearSchedule( int iSchedule ) { m_Schedules.FindAndRemove(iSchedule); } + inline bool HasSchedule( int iSchedule ) { m_Schedules.HasElement(iSchedule); } +#else + inline void SetSchedule( int iSchedule ) { m_Schedules.Set(iSchedule); } + inline void ClearSchedule( int iSchedule ) { m_Schedules.Clear(iSchedule); } + inline bool HasSchedule( int iSchedule ) { m_Schedules.IsBitSet(iSchedule); } +#endif + + static int GetScheduleID(const char* schedName) { return CAI_BaseNPC::GetSchedulingSymbols()->ScheduleSymbolToId(schedName); } + const char *ScheduleName(int scheduleID); + + int TranslateScheduleString(const char *schedName); + inline int ScheduleLocalToGlobal(CAI_BaseNPC *pTarget, int scheduleID) { return pTarget->GetClassScheduleIdSpace()->ScheduleLocalToGlobal(scheduleID); } + + // ------------------------------ + // Tasks + // ------------------------------ + + // TODO + + // ------------------------------ + // Hints + // ------------------------------ + CUtlVector m_Hints; + + COutputInt m_OnNPCUsingHint; + COutputInt m_OnNPCNotUsingHint; + + inline void SetHint( int iHint ) { m_Hints.HasElement(iHint) ? NULL : m_Hints.AddToTail(iHint); } + inline void ClearHint( int iHint ) { m_Hints.FindAndRemove(iHint); } + inline bool HasHint( int iHint ) { m_Hints.HasElement(iHint); } + + // Only register a hint as "being used" when the NPC is this distance away or less + float m_flDistanceFromHint; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS( ai_monitor, CAI_Monitor ); + + +BEGIN_DATADESC( CAI_Monitor ) + +#if AI_MONITOR_USE_UTLVECTOR + DEFINE_UTLVECTOR( m_Conditions, FIELD_INTEGER ), + DEFINE_UTLVECTOR( m_Schedules, FIELD_INTEGER ), +#endif + DEFINE_UTLVECTOR( m_Hints, FIELD_INTEGER ), + + // Keys + DEFINE_KEYFIELD( m_bStartDisabled, FIELD_BOOLEAN, "StartDisabled" ), + DEFINE_INPUT( m_flThinkTime, FIELD_FLOAT, "SetMonitorInterval" ), + DEFINE_INPUT( m_flCooldownTime, FIELD_FLOAT, "SetCooldownTime" ), + DEFINE_KEYFIELD( m_bCooldownAtFirstSuccess, FIELD_BOOLEAN, "CooldownAt" ), + + DEFINE_KEYFIELD( m_iMaxEnts, FIELD_INTEGER, "MaxEnts" ), + + DEFINE_KEYFIELD( m_bTranslateSchedules, FIELD_BOOLEAN, "TranslateSchedules" ), + + DEFINE_KEYFIELD( m_flDistanceFromHint, FIELD_FLOAT, "HintDistance" ), + + // Inputs + DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), + DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), + DEFINE_INPUTFUNC( FIELD_VOID, "UpdateActors", InputPopulateNPCs ), + DEFINE_INPUTFUNC( FIELD_VOID, "Test", InputTest ), + DEFINE_INPUTFUNC( FIELD_EHANDLE, "TestNPC", InputTestNPC ), + + DEFINE_INPUTFUNC( FIELD_INTEGER, "GetConditionName", InputGetConditionName ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "GetScheduleName", InputGetScheduleName ), + + DEFINE_INPUTFUNC( FIELD_STRING, "SetCondition", InputSetCondition ), + DEFINE_INPUTFUNC( FIELD_STRING, "ClearCondition", InputClearCondition ), + DEFINE_INPUTFUNC( FIELD_STRING, "ClearAllConditions", InputClearAllConditions ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetSchedule", InputSetSchedule ), + DEFINE_INPUTFUNC( FIELD_STRING, "ClearSchedule", InputClearSchedule ), + DEFINE_INPUTFUNC( FIELD_STRING, "ClearAllSchedules", InputClearAllSchedules ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetHint", InputSetHint ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "ClearHint", InputClearHint ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "ClearAllHints", InputClearAllHints ), + + // Outputs + DEFINE_OUTPUT(m_OutConditionName, "OutConditionName"), + DEFINE_OUTPUT(m_OutScheduleName, "OutScheduleName"), + DEFINE_OUTPUT(m_OnNPCHasCondition, "OnNPCHasCondition"), + DEFINE_OUTPUT(m_OnNPCLacksCondition, "OnNPCLacksCondition"), + DEFINE_OUTPUT(m_OnNPCRunningSchedule, "OnNPCRunningSchedule"), + DEFINE_OUTPUT(m_OnNPCNotRunningSchedule, "OnNPCNotRunningSchedule"), + DEFINE_OUTPUT(m_OnNPCUsingHint, "OnNPCUsingHint"), + DEFINE_OUTPUT(m_OnNPCNotUsingHint, "OnNPCNotUsingHint"), + + DEFINE_THINKFUNC( MonitorThink ), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CAI_Monitor::CAI_Monitor() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CAI_Monitor::Spawn() +{ + BaseClass::Spawn(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CAI_Monitor::Activate( void ) +{ + BaseClass::Activate(); + + if (!m_bStartDisabled) + { + SetThink(&CAI_Monitor::MonitorThink); + SetNextThink(gpGlobals->curtime + GetThinkTime()); + } + + PopulateNPCs(NULL); +} + +//----------------------------------------------------------------------------- +// Enable, disable +//----------------------------------------------------------------------------- +void CAI_Monitor::InputEnable( inputdata_t &inputdata ) +{ + PopulateNPCs(&inputdata); + + SetThink( &CAI_Monitor::MonitorThink ); + SetNextThink( gpGlobals->curtime + GetThinkTime() ); +} + +void CAI_Monitor::InputDisable( inputdata_t &inputdata ) +{ + SetThink( NULL ); +} + +void CAI_Monitor::InputPopulateNPCs( inputdata_t &inputdata ) +{ + PopulateNPCs(&inputdata); +} + +void CAI_Monitor::InputTest( inputdata_t &inputdata ) +{ + bool bFoundResults = false; + for (int i = 0; i < pNPCs.Count(); i++) + { + if (pNPCs[i] != NULL) + { + if (!bFoundResults) + bFoundResults = NPCDoEval(pNPCs[i]); + else if (!m_bCooldownAtFirstSuccess) + NPCDoEval(pNPCs[i]); + else + break; + } + else + { + // If we have a null NPC, we should probably update. + // This could probably go wrong in more than one way... + PopulateNPCs(NULL); + i--; + } + } +} + +void CAI_Monitor::InputTestNPC( inputdata_t &inputdata ) +{ + CAI_BaseNPC *pNPC = inputdata.value.Entity()->MyNPCPointer(); + if (!inputdata.value.Entity() || !pNPC) + return; + + NPCDoEval(pNPC); +} + +//----------------------------------------------------------------------------- +// Purpose: Save/restore stuff from CAI_BaseNPC +//----------------------------------------------------------------------------- +int CAI_Monitor::Save( ISave &save ) +{ +#if !AI_MONITOR_USE_UTLVECTOR + save.StartBlock(); + SaveConditions( save, m_Conditions ); + SaveConditions( save, m_Schedules ); + save.EndBlock(); +#endif + + return BaseClass::Save(save); +} + +int CAI_Monitor::Restore( IRestore &restore ) +{ +#if !AI_MONITOR_USE_UTLVECTOR + restore.StartBlock(); + RestoreConditions( restore, &m_Conditions ); + RestoreConditions( restore, &m_Schedules ); + restore.EndBlock(); +#endif + + return BaseClass::Restore(restore); +} + +#if !AI_MONITOR_USE_UTLVECTOR +void CAI_Monitor::SaveConditions( ISave &save, const CAI_ScheduleBits &conditions ) +{ + for (int i = 0; i < MAX_CONDITIONS; i++) + { + if (conditions.IsBitSet(i)) + { + const char *pszConditionName = ConditionName(AI_RemapToGlobal(i)); + if ( !pszConditionName ) + break; + save.WriteString( pszConditionName ); + } + } + save.WriteString( "" ); +} + +//------------------------------------- + +void CAI_Monitor::RestoreConditions( IRestore &restore, CAI_ScheduleBits *pConditions ) +{ + pConditions->ClearAll(); + char szCondition[256]; + for (;;) + { + restore.ReadString( szCondition, sizeof(szCondition), 0 ); + if ( !szCondition[0] ) + break; + int iCondition = GetConditionID( szCondition ); + if ( iCondition != -1 ) + pConditions->Set( AI_RemapFromGlobal( iCondition ) ); + } +} +#endif + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CAI_Monitor::PopulateNPCs(inputdata_t *inputdata) +{ + // pNPCs[i] != NULL && !pNPCs[i]->IsMarkedForDeletion() && !pNPCs[i]->GetState() != NPC_STATE_DEAD + //pNPCs = CUtlVector>(); + pNPCs.RemoveAll(); + + CBaseEntity *pActivator = inputdata ? inputdata->pActivator : NULL; + CBaseEntity *pCaller = inputdata ? inputdata->pCaller : NULL; + + CBaseEntity *pEnt = gEntList.FindEntityGeneric(NULL, STRING(m_target), this, pActivator, pCaller); + while (pEnt) + { + if (pEnt->IsNPC()) + { + pNPCs.AddToTail(pEnt->MyNPCPointer()); + DevMsg("Added %s to element %i\n", pEnt->GetDebugName(), pNPCs.Count()); + + // 0 = no limit because the list would already have at least one element by the time this is checked. + if (pNPCs.Count() == m_iMaxEnts) + break; + } + + pEnt = gEntList.FindEntityGeneric(pEnt, STRING(m_target), this, pActivator, pCaller); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CAI_BaseNPC *CAI_Monitor::GetFirstTarget() +{ + for (int i = 0; i < pNPCs.Count(); i++) + { + if (pNPCs[i] != NULL) + return pNPCs[i]; + } + + return NULL; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CAI_Monitor::NPCDoEval(CAI_BaseNPC *pNPC) +{ + // Because we return based on this + m_OnNPCHasCondition.Init(0); + m_OnNPCRunningSchedule.Init(0); + m_OnNPCUsingHint.Init(0); + + + // ---------- + // Conditions + // ---------- +#if AI_MONITOR_USE_UTLVECTOR + for (int cond = 0; cond < m_Conditions.Count(); cond++) +#else + for (int cond = 0; cond < m_Conditions.GetNumBits(); cond++) +#endif + { + if (pNPC->HasCondition(m_Conditions[cond])) + { + DevMsg("NPC has condition %i, index %i, name %s\n", m_Conditions[cond], cond, ConditionName(m_Conditions[cond])); + m_OnNPCHasCondition.Set(m_Conditions[cond], pNPC, this); + m_OutConditionName.Set(MAKE_STRING(ConditionName(m_Conditions[cond])), pNPC, this); + } + else + { + DevMsg("NPC does not have condition %i, index %i, name %s\n", m_Conditions[cond], cond, ConditionName(m_Conditions[cond])); + m_OnNPCLacksCondition.Set(m_Conditions[cond], pNPC, this); + m_OutConditionName.Set(MAKE_STRING(ConditionName(m_Conditions[cond])), pNPC, this); + } + /* + bool bDecisive = false; + switch (m_ConditionsOp) + { + case AIMONITOR_CONDITIONAL_NOR: + bConditionsTrue = true; + case AIMONITOR_CONDITIONAL_OR: + { + if (pNPC->HasCondition(m_Conditions[cond])) + { + // One is valid, pass conditions + bConditionsTrue = !bConditionsTrue; + bDecisive = true; + break; + } + } break; + case AIMONITOR_CONDITIONAL_NAND: + bConditionsTrue = true; + case AIMONITOR_CONDITIONAL_AND: + { + if (!pNPCs[i]->HasCondition(m_Conditions[cond])) + { + // One is invalid, don't pass conditions + bConditionsTrue = !bConditionsTrue; + bDecisive = true; + break; + } + } break; + } + + if (bDecisive) + break; + */ + } + + // ---------- + // Schedules + // ---------- +#if AI_MONITOR_USE_UTLVECTOR + for (int sched = 0; sched < m_Schedules.Count(); sched++) +#else + for (int sched = 0; sched < m_Schedules.GetNumBits(); sched++) +#endif + { + if (pNPC->IsCurSchedule(m_bTranslateSchedules ? pNPC->TranslateSchedule(m_Schedules[sched]) : m_Schedules[sched])) + { + DevMsg("NPC is running schedule %i, index %i, name %s\n", m_Schedules[sched], sched, ScheduleName(m_Schedules[sched])); + m_OnNPCRunningSchedule.Set(m_Schedules[sched], pNPC, this); + m_OutScheduleName.Set(AllocPooledString(ScheduleName(m_Schedules[sched])), pNPC, this); + } + else + { + DevMsg("NPC is not running schedule %i, index %i, name %s\n", m_Schedules[sched], sched, ScheduleName(m_Schedules[sched])); + m_OnNPCNotRunningSchedule.Set(m_Schedules[sched], pNPC, this); + m_OutScheduleName.Set(AllocPooledString(ScheduleName(m_Schedules[sched])), pNPC, this); + } + } + + // ---------- + // Hints + // ---------- + CAI_Hint *pHint = pNPC->GetHintNode(); + if (m_Hints.Count() > 0) + { + if (!pHint || (m_flDistanceFromHint > 0 && pHint->GetLocalOrigin().DistTo(pNPC->GetLocalOrigin()) > m_flDistanceFromHint)) + { + for (int hint = 0; hint < m_Hints.Count(); hint++) + { + m_OnNPCNotUsingHint.Set(m_Hints[hint], pNPC, this); + } + } + else + { + for (int hint = 0; hint < m_Hints.Count(); hint++) + { + if (pHint->HintType() == m_Hints[hint]) + { + DevMsg("NPC is using hint %i, index %i\n", m_Hints[hint], hint); + m_OnNPCUsingHint.Set(m_Hints[hint], pNPC, this); + } + else + { + DevMsg("NPC is not using hint %i, index %i\n", m_Hints[hint], hint); + m_OnNPCNotUsingHint.Set(m_Hints[hint], pNPC, this); + } + } + } + } + + + // Return whether any of our "valid" outputs fired. + return (m_OnNPCHasCondition.Get() != 0 + || m_OnNPCRunningSchedule.Get() != 0 + || m_OnNPCUsingHint.Get() != 0 + ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CAI_Monitor::MonitorThink() +{ + bool bMonitorFoundResults = false; + for (int i = 0; i < pNPCs.Count(); i++) + { + if (pNPCs[i] != NULL) + { + if (!bMonitorFoundResults) + bMonitorFoundResults = NPCDoEval(pNPCs[i]); + else if (!m_bCooldownAtFirstSuccess) + NPCDoEval(pNPCs[i]); + else + break; + } + else + { + // If we have a null NPC, we should probably update. + // This could probably go wrong in more than one way... + PopulateNPCs(NULL); + i--; + } + } + + if (bMonitorFoundResults) + SetNextThink(gpGlobals->curtime + GetCooldownTime()); + else + SetNextThink(gpGlobals->curtime + GetThinkTime()); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +const char *CAI_Monitor::ConditionName(int conditionID) +{ + if ( AI_IdIsLocal( conditionID ) ) + { + // Get our first target and find a local condition + CAI_BaseNPC *pTarget = GetFirstTarget(); + if (!pTarget) + return NULL; + + conditionID = ConditionLocalToGlobal(pTarget, conditionID); + } + + return CAI_BaseNPC::GetSchedulingSymbols()->ConditionIdToSymbol(conditionID); +} + +const char *CAI_Monitor::ScheduleName(int scheduleID) +{ + if ( AI_IdIsLocal( scheduleID ) ) + { + // Get our first target and find a local condition + CAI_BaseNPC *pTarget = GetFirstTarget(); + if (!pTarget) + return NULL; + + scheduleID = ScheduleLocalToGlobal(pTarget, scheduleID); + } + + return CAI_BaseNPC::GetSchedulingSymbols()->ScheduleIdToSymbol(scheduleID); +} + +int CAI_Monitor::TranslateConditionString(const char *condName) +{ + if (condName[0] == 'C') + { + // String + int cond = GetConditionID(condName); + if (cond > -1) + { + DevMsg("Setting condition %i from %s\n", cond, condName); + return cond; + } + } + else + { + // Int + DevMsg("Setting condition %s\n", condName); + + // Assume the mapper didn't compensate for global ID stuff. + // (as if either of us understand it) + return atoi(condName) + GLOBAL_IDS_BASE; + } + return 0; +} + +int CAI_Monitor::TranslateScheduleString(const char *schedName) +{ + if (schedName[0] == 'S') + { + // String + int sched = GetScheduleID(schedName); + if (sched > -1) + { + DevMsg("Setting schedule %i from %s\n", sched, schedName); + return sched; + } + } + else + { + // Int + DevMsg("Setting schedule %s\n", schedName); + return atoi(schedName); + } + return 0; +} + +//----------------------------------------------------------------------------- +// Purpose: Cache user entity field values until spawn is called. +// Input : szKeyName - Key to handle. +// szValue - Value for key. +// Output : Returns true if the key was handled, false if not. +//----------------------------------------------------------------------------- +bool CAI_Monitor::KeyValue( const char *szKeyName, const char *szValue ) +{ + if (FStrEq(szKeyName, "ConditionsSimple")) + { + // Hammer SmartEdit helper that shouldn't be overridden. + // It's not supposed to be overridden. + SetCondition(atoi(szValue)); + } + else if (FStrEq(szKeyName, "Conditions")) + { + char *token = strtok(strdup(szValue), ":"); + while (token) + { + SetCondition(TranslateConditionString(token)); + + token = strtok(NULL, ":"); + } + } + else if (FStrEq(szKeyName, "SchedulesSimple")) + { + // Hammer SmartEdit helper that shouldn't be overridden. + SetCondition(atoi(szValue)); + } + else if (FStrEq(szKeyName, "Schedules")) + { + char *token = strtok(strdup(szValue), ":"); + while (token) + { + SetSchedule(TranslateScheduleString(token)); + + token = strtok(NULL, ":"); + } + } + else if (FStrEq(szKeyName, "HintsSimple")) + { + // Hammer SmartEdit helper that shouldn't be overridden. + SetHint(atoi(szValue)); + } + else if (FStrEq(szKeyName, "Hints")) + { + char *token = strtok(strdup(szValue), ":"); + while (token) + { + SetHint(atoi(szValue)); + + token = strtok(NULL, ":"); + } + } + else + return CBaseEntity::KeyValue( szKeyName, szValue ); + + return true; +} diff --git a/sp/src/game/server/mapbase/ai_weaponmodifier.cpp b/sp/src/game/server/mapbase/ai_weaponmodifier.cpp new file mode 100644 index 00000000..bc7eee10 --- /dev/null +++ b/sp/src/game/server/mapbase/ai_weaponmodifier.cpp @@ -0,0 +1,250 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Be warned, because this entity is TERRIBLE! +// +//============================================================================= + +#include "cbase.h" +#include "ai_basenpc.h" +#include "saverestore_utlvector.h" + + + +//----------------------------------------------------------------------------- +// Purpose: A special CAI_ShotRegulator class designed to be used with ai_weaponmodifier. +// I'm too chicken to do anything fun with it. +//----------------------------------------------------------------------------- +typedef CAI_ShotRegulator CAI_CustomShotRegulator; +/* +class CAI_CustomShotRegulator : public CAI_ShotRegulator +{ + DECLARE_CLASS( CAI_CustomShotRegulator, CAI_ShotRegulator ); +public: + void SetMinBurstInterval( float flMinBurstInterval ) { m_flMinBurstInterval = flMinBurstInterval; } + void SetMaxBurstInterval( float flMaxBurstInterval ) { m_flMaxBurstInterval = flMaxBurstInterval; } +}; +*/ + +// A lot of functions can't set each range individually, so we have to do this for a lot of them. +// (again, too chicken to do something useful with CAI_CustomShotRegulator) +#define WeaponModifierSetRange(string, function) float minimum = 0; \ + float maximum = 0; \ + if (sscanf(string, "%f:%f", &minimum, &maximum)) \ + function(minimum, maximum); + +#define WEAPONMODIFIER_MAX_NPCS 16 + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +class CAI_WeaponModifier : public CLogicalEntity +{ + DECLARE_CLASS( CAI_WeaponModifier, CLogicalEntity ); + DECLARE_DATADESC(); +public: + + void Spawn(); + + virtual int Save( ISave &save ); + virtual int Restore( IRestore &restore ); + + bool KeyValue(const char *szKeyName, const char *szValue); + + void EnableOnNPC(CAI_BaseNPC *pNPC); + void DisableOnNPC(CAI_BaseNPC *pNPC); + + // Inputs + void InputEnable( inputdata_t &inputdata ); + void InputDisable( inputdata_t &inputdata ); + void InputEnableOnNPC( inputdata_t &inputdata ); + void InputDisableOnNPC( inputdata_t &inputdata ); + + void InputSetBurstInterval( inputdata_t &inputdata ) { WeaponModifierSetRange(inputdata.value.String(), m_ModdedRegulator.SetBurstInterval); } + void InputSetRestInterval( inputdata_t &inputdata ) { WeaponModifierSetRange(inputdata.value.String(), m_ModdedRegulator.SetRestInterval); } + void InputSetBurstShotCountRange( inputdata_t &inputdata ) { WeaponModifierSetRange(inputdata.value.String(), m_ModdedRegulator.SetBurstShotCountRange); } + void InputSetBurstShotsRemaining( inputdata_t &inputdata ) { m_ModdedRegulator.SetBurstShotsRemaining(inputdata.value.Int()); } + + void InputEnableShooting( inputdata_t &inputdata ) { m_ModdedRegulator.EnableShooting(); } + void InputDisableShooting( inputdata_t &inputdata ) { m_ModdedRegulator.DisableShooting(); } + void InputFireNoEarlierThan( inputdata_t &inputdata ) { m_ModdedRegulator.FireNoEarlierThan(gpGlobals->curtime + inputdata.value.Float()); } + void InputReset( inputdata_t &inputdata ) { m_ModdedRegulator.Reset(inputdata.value.Bool()); } + + // The NPCs and their original regulators. + AIHANDLE m_hNPCs[WEAPONMODIFIER_MAX_NPCS]; + CAI_ShotRegulator m_StoredRegulators[WEAPONMODIFIER_MAX_NPCS]; + + CAI_CustomShotRegulator m_ModdedRegulator; + + bool m_bDisabled; +}; + +LINK_ENTITY_TO_CLASS(ai_weaponmodifier, CAI_WeaponModifier); + +BEGIN_DATADESC( CAI_WeaponModifier ) + + DEFINE_EMBEDDED( m_ModdedRegulator ), + + DEFINE_ARRAY( m_hNPCs, FIELD_EHANDLE, WEAPONMODIFIER_MAX_NPCS ), + DEFINE_EMBEDDED_ARRAY( m_StoredRegulators, WEAPONMODIFIER_MAX_NPCS ), + + DEFINE_KEYFIELD( m_bDisabled, FIELD_BOOLEAN, "StartDisabled" ), + + // Inputs + DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), + DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), + DEFINE_INPUTFUNC( FIELD_EHANDLE, "EnableOnNPC", InputEnableOnNPC ), + DEFINE_INPUTFUNC( FIELD_EHANDLE, "DisableOnNPC", InputDisableOnNPC ), + + DEFINE_INPUTFUNC( FIELD_STRING, "SetBurstInterval", InputSetBurstInterval ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetRestInterval", InputSetRestInterval ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetBurstShotCountRange", InputSetBurstShotCountRange ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetBurstShotsRemaining", InputSetBurstShotsRemaining ), + + DEFINE_INPUTFUNC( FIELD_VOID, "EnableShooting", InputEnableShooting ), + DEFINE_INPUTFUNC( FIELD_VOID, "DisableShooting", InputDisableShooting ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "FireNoEarlierThan", InputFireNoEarlierThan ), + DEFINE_INPUTFUNC( FIELD_BOOLEAN, "Reset", InputReset ), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CAI_WeaponModifier::Spawn() +{ + if (!m_bDisabled) + { + inputdata_t inputdata; + InputEnable(inputdata); + } + + BaseClass::Spawn(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +int CAI_WeaponModifier::Save( ISave &save ) +{ + return BaseClass::Save(save); +} + +int CAI_WeaponModifier::Restore( IRestore &restore ) +{ + return BaseClass::Restore(restore); +} + +//----------------------------------------------------------------------------- +// Purpose: Handles key values from the BSP before spawn is called. +//----------------------------------------------------------------------------- +bool CAI_WeaponModifier::KeyValue( const char *szKeyName, const char *szValue ) +{ + if (FStrEq(szKeyName, "BurstInterval")) + { + WeaponModifierSetRange(szValue, m_ModdedRegulator.SetBurstInterval); + } + else if (FStrEq(szKeyName, "RestInterval")) + { + WeaponModifierSetRange(szValue, m_ModdedRegulator.SetRestInterval); + } + else if (FStrEq(szKeyName, "BurstShotCountRange")) + { + WeaponModifierSetRange(szValue, m_ModdedRegulator.SetBurstShotCountRange); + } + else if (FStrEq(szKeyName, "BurstShotsRemaining")) + { + m_ModdedRegulator.SetBurstShotsRemaining(atoi(szValue)); + } + else + return BaseClass::KeyValue(szKeyName, szValue); + + return true; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CAI_WeaponModifier::EnableOnNPC( CAI_BaseNPC *pNPC ) +{ + for (int i = 0; i < WEAPONMODIFIER_MAX_NPCS; i++) + { + if (m_hNPCs[i] == NULL) + { + m_hNPCs[i] = pNPC; + m_StoredRegulators[i] = *pNPC->GetShotRegulator(); + + pNPC->SetShotRegulator(m_ModdedRegulator); + } + else if (m_hNPCs[i] == pNPC) + { + // We're already in it + return; + } + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CAI_WeaponModifier::DisableOnNPC( CAI_BaseNPC *pNPC ) +{ + for (int i = 0; i < WEAPONMODIFIER_MAX_NPCS; i++) + { + if (m_hNPCs[i] == pNPC) + { + pNPC->SetShotRegulator(m_StoredRegulators[i]); + m_hNPCs[i] = NULL; + + // Just reset it to our modded one + m_StoredRegulators[i] = m_ModdedRegulator; + } + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CAI_WeaponModifier::InputEnable( inputdata_t &inputdata ) +{ + CBaseEntity *pEntity = gEntList.FindEntityByName(NULL, STRING(m_target), this, inputdata.pActivator, inputdata.pCaller); + while (pEntity) + { + if (pEntity->IsNPC()) + { + EnableOnNPC(pEntity->MyNPCPointer()); + } + + pEntity = gEntList.FindEntityByName(pEntity, STRING(m_target), this, inputdata.pActivator, inputdata.pCaller); + } +} + +void CAI_WeaponModifier::InputDisable( inputdata_t &inputdata ) +{ + for (int i = 0; i < WEAPONMODIFIER_MAX_NPCS; i++) + { + m_hNPCs[i]->SetShotRegulator(m_StoredRegulators[i]); + m_hNPCs[i] = NULL; + + // Just reset it to our modded one + m_StoredRegulators[i] = m_ModdedRegulator; + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CAI_WeaponModifier::InputEnableOnNPC( inputdata_t &inputdata ) +{ + if (inputdata.value.Entity() && inputdata.value.Entity()->IsNPC()) + { + EnableOnNPC(inputdata.value.Entity()->MyNPCPointer()); + } +} + +void CAI_WeaponModifier::InputDisableOnNPC( inputdata_t &inputdata ) +{ + if (inputdata.value.Entity() && inputdata.value.Entity()->IsNPC()) + { + DisableOnNPC(inputdata.value.Entity()->MyNPCPointer()); + } +} diff --git a/sp/src/game/server/mapbase/closecaption_entity.cpp b/sp/src/game/server/mapbase/closecaption_entity.cpp new file mode 100644 index 00000000..dfb33381 --- /dev/null +++ b/sp/src/game/server/mapbase/closecaption_entity.cpp @@ -0,0 +1,81 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "cbase.h" + + +class CEnvCloseCaption : public CBaseEntity +{ + DECLARE_CLASS( CEnvCloseCaption, CBaseEntity ); +public: + + bool AllPlayers() { return true; } + + void InputSend( inputdata_t &inputdata ); + + //bool m_bCustom; + int m_iFlags; + float m_flDuration; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS( env_closecaption, CEnvCloseCaption ); + +BEGIN_DATADESC( CEnvCloseCaption ) + + //DEFINE_KEYFIELD( m_bCustom, FIELD_BOOLEAN, "custom" ), + DEFINE_KEYFIELD( m_iFlags, FIELD_INTEGER, "flags" ), + DEFINE_INPUT( m_flDuration, FIELD_FLOAT, "SetDuration" ), + + // Inputs + DEFINE_INPUTFUNC( FIELD_STRING, "Send", InputSend ), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CEnvCloseCaption::InputSend( inputdata_t &inputdata ) +{ + char szCC[512]; + Q_strncpy(szCC, inputdata.value.String(), sizeof(szCC)); + + byte byteflags = m_iFlags; + if ( AllPlayers() ) + { + CReliableBroadcastRecipientFilter user; + UserMessageBegin( user, "CloseCaption" ); + WRITE_STRING( szCC ); + WRITE_SHORT( MIN( 255, (int)( m_flDuration * 10.0f ) ) ), + WRITE_BYTE( byteflags ), + MessageEnd(); + } + else + { + CBaseEntity *pPlayer = NULL; + + if ( inputdata.pActivator && inputdata.pActivator->IsPlayer() ) + { + pPlayer = inputdata.pActivator; + } + else + { + pPlayer = UTIL_GetLocalPlayer(); + } + + if ( !pPlayer || !pPlayer->IsNetClient() ) + return; + + CSingleUserRecipientFilter user( (CBasePlayer *)pPlayer ); + user.MakeReliable(); + UserMessageBegin( user, "CloseCaption" ); + WRITE_STRING( szCC ); + WRITE_SHORT( MIN( 255, (int)( m_flDuration * 10.0f ) ) ), + WRITE_BYTE( byteflags ), + MessageEnd(); + } +} diff --git a/sp/src/game/server/mapbase/datadesc_mod.cpp b/sp/src/game/server/mapbase/datadesc_mod.cpp new file mode 100644 index 00000000..45baeb49 --- /dev/null +++ b/sp/src/game/server/mapbase/datadesc_mod.cpp @@ -0,0 +1,199 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#include "cbase.h" +#include "datadesc_mod.h" +#include "saverestore.h" + + +// Sets a field's value to a specific string. +char *Datadesc_SetFieldString( const char *szValue, CBaseEntity *pObject, typedescription_t *pField, fieldtype_t *pFieldType ) +{ + // Copied from ::ParseKeyvalue... + fieldtype_t fieldtype = FIELD_VOID; + int fieldOffset = pField->fieldOffset[ TD_OFFSET_NORMAL ]; + switch( pField->fieldType ) + { + case FIELD_MODELNAME: + case FIELD_SOUNDNAME: + case FIELD_STRING: + (*(string_t *)((char *)pObject + fieldOffset)) = AllocPooledString( szValue ); + fieldtype = FIELD_STRING; + break; + + case FIELD_TIME: + case FIELD_FLOAT: + (*(float *)((char *)pObject + fieldOffset)) = atof( szValue ); + fieldtype = FIELD_FLOAT; + break; + + case FIELD_BOOLEAN: + (*(bool *)((char *)pObject + fieldOffset)) = (bool)(atoi( szValue ) != 0); + fieldtype = FIELD_BOOLEAN; + break; + + case FIELD_CHARACTER: + (*(char *)((char *)pObject + fieldOffset)) = (char)atoi( szValue ); + fieldtype = FIELD_CHARACTER; + break; + + case FIELD_SHORT: + (*(short *)((char *)pObject + fieldOffset)) = (short)atoi( szValue ); + fieldtype = FIELD_SHORT; + break; + + case FIELD_INTEGER: + case FIELD_TICK: + (*(int *)((char *)pObject + fieldOffset)) = atoi( szValue ); + fieldtype = FIELD_INTEGER; + break; + + case FIELD_POSITION_VECTOR: + case FIELD_VECTOR: + UTIL_StringToVector( (float *)((char *)pObject + fieldOffset), szValue ); + fieldtype = FIELD_VECTOR; + break; + + case FIELD_VMATRIX: + case FIELD_VMATRIX_WORLDSPACE: + UTIL_StringToFloatArray( (float *)((char *)pObject + fieldOffset), 16, szValue ); + fieldtype = FIELD_VMATRIX; // ??? + break; + + case FIELD_MATRIX3X4_WORLDSPACE: + UTIL_StringToFloatArray( (float *)((char *)pObject + fieldOffset), 12, szValue ); + fieldtype = FIELD_VMATRIX; // ??? + break; + + case FIELD_COLOR32: + UTIL_StringToColor32( (color32 *) ((char *)pObject + fieldOffset), szValue ); + fieldtype = FIELD_COLOR32; + break; + + case FIELD_CUSTOM: + { + SaveRestoreFieldInfo_t fieldInfo = + { + (char *)pObject + fieldOffset, + pObject, + pField + }; + pField->pSaveRestoreOps->Parse( fieldInfo, szValue ); + fieldtype = FIELD_STRING; + break; + } + + default: + case FIELD_INTERVAL: + case FIELD_CLASSPTR: + case FIELD_MODELINDEX: + case FIELD_MATERIALINDEX: + case FIELD_EDICT: + return NULL; + //Warning( "%s cannot set field of type %i.\n", GetDebugName(), dmap->dataDesc[i].fieldType ); + break; + } + + if (pFieldType) + *pFieldType = fieldtype; + + return ((char*)pObject) + fieldOffset; +} + +//----------------------------------------------------------------------------- +// Purpose: ReadUnregisteredKeyfields() was a feeble attempt to obtain non-keyfield keyvalues from KeyValue() with variant_t. +// +// I didn't know about GetKeyValue() until 9/29/2018. +// I don't remember why I decided to write down the date I found out about it. Maybe I considered that monumental of a discovery. +// +// However, we still use ReadUnregisteredKeyfields() since GetKeyValue() only supports a string while this function was used for entire variant_ts. +// It now calls GetKeyValue() and returns it as an allocated string. +//----------------------------------------------------------------------------- +bool ReadUnregisteredKeyfields(CBaseEntity *pTarget, const char *szKeyName, variant_t *variant) +{ + if (!pTarget) + return false; + + char szValue[256]; + if (pTarget->GetKeyValue(szKeyName, szValue, sizeof(szValue))) + { + variant->SetString(AllocPooledString(szValue)); // MAKE_STRING causes badness, must pool + return true; + } + +#if 0 + if ( FStrEq( szKeyName, "targetname" ) ) + { + variant->SetString(pTarget->GetEntityName()); + return true; + } + + if( FStrEq( szKeyName, "origin" ) ) + { + variant->SetPositionVector3D(pTarget->GetAbsOrigin()); + return true; + } + + if( FStrEq( szKeyName, "angles" ) /*|| FStrEq( szKeyName, "angle" )*/ ) + { + Vector angles; + AngleVectors(pTarget->GetAbsAngles(), &angles); + variant->SetVector3D(angles); + return true; + } + + if ( FStrEq( szKeyName, "rendercolor" ) || FStrEq( szKeyName, "rendercolor32" )) + { + // Copy it over since we're not going to use the alpha + color32 theircolor = pTarget->GetRenderColor(); + color32 color; + color.r = theircolor.r; + color.g = theircolor.g; + color.b = theircolor.b; + variant->SetColor32(color); + return true; + } + + if ( FStrEq( szKeyName, "renderamt" ) ) + { + char szAlpha = pTarget->GetRenderColor().a; + variant->SetString(MAKE_STRING(&szAlpha)); + return true; + } + + if ( FStrEq( szKeyName, "disableshadows" )) + { + variant->SetBool((pTarget->GetEffects() & EF_NOSHADOW) != NULL); + return true; + } + + if ( FStrEq( szKeyName, "mins" )) + { + variant->SetVector3D(pTarget->CollisionProp()->OBBMinsPreScaled()); + return true; + } + + if ( FStrEq( szKeyName, "maxs" )) + { + variant->SetVector3D(pTarget->CollisionProp()->OBBMaxsPreScaled()); + return true; + } + + if ( FStrEq( szKeyName, "disablereceiveshadows" )) + { + variant->SetBool((pTarget->GetEffects() & EF_NORECEIVESHADOW) != NULL); + return true; + } + + if ( FStrEq( szKeyName, "nodamageforces" )) + { + variant->SetBool((pTarget->GetEFlags() & EFL_NO_DAMAGE_FORCES) != NULL); + return true; + } +#endif + + return false; +} diff --git a/sp/src/game/server/mapbase/datadesc_mod.h b/sp/src/game/server/mapbase/datadesc_mod.h new file mode 100644 index 00000000..8d1d2979 --- /dev/null +++ b/sp/src/game/server/mapbase/datadesc_mod.h @@ -0,0 +1,11 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#include "cbase.h" + +char *Datadesc_SetFieldString( const char *szValue, CBaseEntity *pObject, typedescription_t *pField, fieldtype_t *pFieldType = NULL ); + +bool ReadUnregisteredKeyfields( CBaseEntity *pTarget, const char *szKeyName, variant_t *variant ); diff --git a/sp/src/game/server/mapbase/expandedrs_combine.h b/sp/src/game/server/mapbase/expandedrs_combine.h new file mode 100644 index 00000000..5179a7f5 --- /dev/null +++ b/sp/src/game/server/mapbase/expandedrs_combine.h @@ -0,0 +1,173 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Response system properties (concepts, etc.) shared by npc_combine_s and npc_metropolice +// +//=============================================================================// + +#ifndef EXPANDEDRS_COMBINE_H +#define EXPANDEDRS_COMBINE_H + +#ifdef _WIN32 +#pragma once +#endif + +#if 0 +#include "ai_component.h" +#include "ai_basenpc.h" +#include "ai_sentence.h" +#endif + +// +// Concepts +// +// These should be consistent with player allies and each other. +// + +// +// Combine Soldiers +// +#define TLK_CMB_ANNOUNCE "TLK_ANNOUNCE" +#define TLK_CMB_THROWGRENADE "TLK_THROWGRENADE" +#define TLK_CMB_PLAYERHIT "TLK_PLAYERHIT" +#define TLK_CMB_ASSAULT "TLK_ASSAULT" +#define TLK_CMB_ENEMY "TLK_STARTCOMBAT" +#define TLK_CMB_KILLENEMY "TLK_ENEMY_DEAD" +#define TLK_CMB_DANGER "TLK_DANGER" +#define TLK_CMB_KICK "TLK_KICK" +#define TLK_CMB_FLANK "TLK_FLANK" +#define TLK_CMB_PAIN "TLK_WOUND" +#define TLK_CMB_LOSTENEMY "TLK_LOSTENEMY" +#define TLK_CMB_REFINDENEMY "TLK_REFINDENEMY" +#define TLK_CMB_GOALERT "TLK_GOALERT" +//#define TLK_CMB_LASTOFSQUAD "TLK_LASTOFSQUAD" +#define TLK_CMB_MANDOWN "TLK_ALLY_KILLED" +#define TLK_CMB_DIE "TLK_DEATH" +#define TLK_CMB_QUESTION "TLK_QUESTION" +#define TLK_CMB_ANSWER "TLK_ANSWER" + +// +// Metrocops +// +#define TLK_COP_MANHACKKILLED "TLK_ALLY_KILLED" +#define TLK_COP_MANDOWN "TLK_ALLY_KILLED" +#define TLK_COP_GO_ALERT "TLK_GOALERT" +#define TLK_COP_FREEZE "TLK_FREEZE" +#define TLK_COP_OVER_HERE "TLK_OVER_HERE" +#define TLK_COP_HES_RUNNING "TLK_HES_RUNNING" +#define TLK_COP_TAKE_HIM_DOWN "TLK_TAKE_HIM_DOWN" +#define TLK_COP_ARREST_IN_POS "TLK_ARREST_IN_POS" +#define TLK_COP_DEPLOY_MANHACK "TLK_DEPLOY_MANHACK" +#define TLK_COP_PLAYERHIT "TLK_PLAYERHIT" +#define TLK_COP_FLANK "TLK_FLANK" +#define TLK_COP_HEARD_SOMETHING "TLK_DARKNESS_HEARDSOUND" +#define TLK_COP_ENEMY "TLK_STARTCOMBAT" +#define TLK_COP_KILLENEMY "TLK_ENEMY_DEAD" +#define TLK_COP_NOAMMO "TLK_NOAMMO" +#define TLK_COP_LOWAMMO "TLK_LOWAMMO" +#define TLK_COP_DANGER "TLK_DANGER" +#define TLK_COP_DIE "TLK_DEATH" +#define TLK_COP_LOSTENEMY "TLK_LOSTENEMY" +#define TLK_COP_REFINDENEMY "TLK_REFINDENEMY" +#define TLK_COP_HARASS "TLK_STARE" +#define TLK_COP_IDLE "TLK_IDLE" +#define TLK_COP_QUESTION "TLK_QUESTION" +#define TLK_COP_ANSWER "TLK_ANSWER" +#define TLK_COP_PAIN "TLK_WOUND" +#define TLK_COP_COVER_HEAVY_DAMAGE "TLK_HEAVYDAMAGE" +#define TLK_COP_SHOOTCOVER "TLK_SHOOTCOVER" +#define TLK_COP_BACK_UP "TLK_BACK_UP" +#define TLK_COP_ON_FIRE "TLK_WOUND" +#define TLK_COP_HIT_BY_PHYSOBJ "TLK_PLYR_PHYSATK" +#define TLK_COP_THROWGRENADE "TLK_THROWGRENADE" +#define TLK_COP_ACTIVATE_BATON "TLK_ACTIVATE_BATON" +#define TLK_COP_DEACTIVATE_BATON "TLK_DEACTIVATE_BATON" + +#define TLK_COP_MOVE_ALONG "TLK_MOVE_ALONG" + +#define TLK_COP_FT_APPROACH "TLK_FT_APPROACH" +#define TLK_COP_FT_MOUNT "TLK_FT_MOUNT" +#define TLK_COP_FT_SCAN "TLK_FT_SCAN" +#define TLK_COP_FT_DISMOUNT "TLK_FT_DISMOUNT" +#define TLK_COP_SO_BEGIN "TLK_SO_BEGIN" +#define TLK_COP_SO_END "TLK_SO_END" +#define TLK_COP_SO_FORCE_COVER "TLK_SO_FORCE_COVER" +#define TLK_COP_SO_PEEK "TLK_SO_PEEK" +#define TLK_COP_AS_HIT_RALLY "TLK_AS_HIT_RALLY" +#define TLK_COP_AS_HIT_ASSAULT "TLK_AS_HIT_ASSAULT" +#define TLK_COP_AS_ADV_RALLY "TLK_AS_ADV_RALLY" +#define TLK_COP_AS_ADV_ASSAULT "TLK_AS_ADV_ASSAULT" + +// +// Snipers +// +#define TLK_SNIPER_DIE "TLK_DEATH" +#define TLK_SNIPER_TARGETDESTROYED "TLK_ENEMY_DEAD" +#define TLK_SNIPER_DANGER "TLK_DANGER" + + +#if 0 +static void FixupSentence(const char **ppSentence, const char **ppPrefix); + +//----------------------------------------------------------------------------- +// This is the met of the class +//----------------------------------------------------------------------------- +template< class NPC_CLASS > +class CAI_SentenceTalker : public CAI_Component +{ + DECLARE_CLASS_NOBASE( CAI_SentenceTalker ); + DECLARE_SIMPLE_DATADESC(); + +public: + //CAI_SentenceTalker(); + + void Init( NPC_CLASS *pOuter, const char *pGameSound = NULL ); + + // Check for queued-up-sentences + speak them + //void UpdateSentenceQueue(); + + // Returns the sentence index played, which can be used to determine + // the sentence length of time using engine->SentenceLength + int Speak( const char *pSentence, SentencePriority_t nSoundPriority = SENTENCE_PRIORITY_NORMAL, SentenceCriteria_t nCriteria = SENTENCE_CRITERIA_IN_SQUAD ); + + // Returns the sentence index played, which can be used to determine + // the sentence length of time using engine->SentenceLength. If the sentence + // was queued, then -1 is returned, which is the same result as if the sound wasn't played + //int SpeakQueued( const char *pSentence, SentencePriority_t nSoundPriority = SENTENCE_PRIORITY_NORMAL, SentenceCriteria_t nCriteria = SENTENCE_CRITERIA_IN_SQUAD ); + + // Clears the sentence queue + //void ClearQueue(); + +protected: + virtual float GetVolume() = 0; + virtual soundlevel_t GetSoundLevel() = 0; + +private: + // Speech criteria + bool ShouldSpeak( SentencePriority_t nSoundPriority, SentenceCriteria_t nCriteria ); + bool MatchesCriteria( SentenceCriteria_t nCriteria ); + + // Play the actual sentence + //int PlaySentence( const char *pSentence ); + + // Debug output + void SentenceMsg( const char *pStatus, const char *pSentence ); + + int m_voicePitch; + int m_nQueuedSentenceIndex; + float m_flQueueTimeout; + int m_nQueueSoundPriority; + + SentencePriority_t m_LastPriority; + +public: + string_t m_iRemovePrefix; +}; + +template< class NPC_CLASS > +void CAI_SentenceTalker< NPC_CLASS >::Init( NPC_CLASS *pOuter, const char *pGameSound ) +{ + SetOuter( pOuter ); +} +#endif + +#endif \ No newline at end of file diff --git a/sp/src/game/server/mapbase/func_clientclip.cpp b/sp/src/game/server/mapbase/func_clientclip.cpp new file mode 100644 index 00000000..e3fbe58e --- /dev/null +++ b/sp/src/game/server/mapbase/func_clientclip.cpp @@ -0,0 +1,191 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: A special brush that collides with clientside entities, primarily ragdolls. +// +//=============================================================================// + +#include "cbase.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + + +//----------------------------------------------------------------------------- +// Purpose: basic solid geometry +// enabled state: brush is visible +// disabled staute: brush not visible +//----------------------------------------------------------------------------- +class CFuncClientClip : public CBaseEntity +{ +public: + DECLARE_CLASS( CFuncClientClip, CBaseEntity ); + DECLARE_SERVERCLASS(); + + virtual void Spawn( void ); + bool CreateVPhysics( void ); + + virtual int DrawDebugTextOverlays( void ); + + void TurnOff( void ); + void TurnOn( void ); + + // Input handlers + void InputTurnOff( inputdata_t &inputdata ); + void InputTurnOn( inputdata_t &inputdata ); + void InputToggle( inputdata_t &inputdata ); + + CNetworkVar( bool, m_bDisabled ); + + DECLARE_DATADESC(); + + virtual bool IsOn( void ); + + int UpdateTransmitState() // always send to all clients + { + return SetTransmitState( FL_EDICT_ALWAYS ); + } +}; + +LINK_ENTITY_TO_CLASS( func_clip_client, CFuncClientClip ); + +BEGIN_DATADESC( CFuncClientClip ) + + DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputTurnOn ), + DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputTurnOff ), + DEFINE_INPUTFUNC( FIELD_VOID, "Toggle", InputToggle ), + DEFINE_KEYFIELD( m_bDisabled, FIELD_BOOLEAN, "StartDisabled" ), + +END_DATADESC() + +IMPLEMENT_SERVERCLASS_ST( CFuncClientClip, DT_FuncClientClip ) + SendPropBool( SENDINFO( m_bDisabled ) ), +END_SEND_TABLE() + + +void CFuncClientClip::Spawn( void ) +{ + SetMoveType( MOVETYPE_PUSH ); // so it doesn't get pushed by anything + + SetSolid( GetParent() ? SOLID_VPHYSICS : SOLID_BSP ); + AddEFlags( EFL_USE_PARTITION_WHEN_NOT_SOLID ); + + AddSolidFlags( FSOLID_NOT_SOLID ); + + SetModel( STRING( GetModelName() ) ); + + if ( m_bDisabled ) + TurnOff(); + + // If it can't move/go away, it's really part of the world + if ( !GetEntityName() || !m_iParent ) + AddFlag( FL_WORLDBRUSH ); + + CreateVPhysics(); +} + +//----------------------------------------------------------------------------- + +bool CFuncClientClip::CreateVPhysics( void ) +{ + // NOTE: Don't init this static. It's pretty common for these to be constrained + // and dynamically parented. Initing shadow avoids having to destroy the physics + // object later and lose the constraints. + IPhysicsObject *pPhys = VPhysicsInitShadow(false, false); + if ( pPhys ) + { + int contents = modelinfo->GetModelContents( GetModelIndex() ); + if ( ! (contents & (MASK_SOLID|MASK_PLAYERSOLID|MASK_NPCSOLID)) ) + { + // leave the physics shadow there in case it has crap constrained to it + // but disable collisions with it + pPhys->EnableCollisions( false ); + } + } + return true; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +int CFuncClientClip::DrawDebugTextOverlays( void ) +{ + int nOffset = BaseClass::DrawDebugTextOverlays(); + + if (m_debugOverlays & OVERLAY_TEXT_BIT) + { + char tempstr[512]; + Q_snprintf( tempstr,sizeof(tempstr), "angles: %g %g %g", (double)GetLocalAngles()[PITCH], (double)GetLocalAngles()[YAW], (double)GetLocalAngles()[ROLL] ); + EntityText( nOffset, tempstr, 0 ); + nOffset++; + + Q_snprintf(tempstr, sizeof(tempstr), " enabled: %d", !m_bDisabled); + EntityText(nOffset, tempstr, 0); + nOffset++; + } + + return nOffset; +} + + +//----------------------------------------------------------------------------- +// Purpose: Input handler for toggling the hidden/shown state of the brush. +//----------------------------------------------------------------------------- +void CFuncClientClip::InputToggle( inputdata_t &inputdata ) +{ + if ( IsOn() ) + { + TurnOff(); + return; + } + + TurnOn(); +} + + +//----------------------------------------------------------------------------- +// Purpose: Input handler for hiding the brush. +//----------------------------------------------------------------------------- +void CFuncClientClip::InputTurnOff( inputdata_t &inputdata ) +{ + TurnOff(); +} + + +//----------------------------------------------------------------------------- +// Purpose: Input handler for showing the brush. +//----------------------------------------------------------------------------- +void CFuncClientClip::InputTurnOn( inputdata_t &inputdata ) +{ + TurnOn(); +} + +//----------------------------------------------------------------------------- +// Purpose: Hides the brush. +//----------------------------------------------------------------------------- +void CFuncClientClip::TurnOff( void ) +{ + if ( !IsOn() ) + return; + + AddEffects( EF_NODRAW ); + m_bDisabled = true; +} + + +//----------------------------------------------------------------------------- +// Purpose: Shows the brush. +//----------------------------------------------------------------------------- +void CFuncClientClip::TurnOn( void ) +{ + if ( IsOn() ) + return; + + RemoveEffects( EF_NODRAW ); + m_bDisabled = false; +} + + +inline bool CFuncClientClip::IsOn( void ) +{ + return !m_bDisabled; +} diff --git a/sp/src/game/server/mapbase/logic_eventlistener.cpp b/sp/src/game/server/mapbase/logic_eventlistener.cpp new file mode 100644 index 00000000..4935b80e --- /dev/null +++ b/sp/src/game/server/mapbase/logic_eventlistener.cpp @@ -0,0 +1,270 @@ +//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ==== +// +// Attempts to replicate logic_eventlistener from Portal 2. +// +// This is, in fact, a RECREATION! This is not an actual port. +// +//============================================================================= + +#include "cbase.h" +#include "GameEventListener.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +class CLogicEventListener : public CPointEntity, + public CGameEventListener +{ +public: + DECLARE_CLASS( CLogicEventListener, CPointEntity ); + + CLogicEventListener(); + + void Activate(); + virtual void ListenForEvents(); + + bool KeyValue(const char *szKeyName, const char *szValue); + + virtual void FireGameEvent( IGameEvent *event ); + + // Input handlers + void InputEnable( inputdata_t &inputdata ); + void InputDisable( inputdata_t &inputdata ); + void InputToggle( inputdata_t &inputdata ); + + DECLARE_DATADESC(); + + string_t m_iszEventName; + + // Outputs + COutputEvent m_OnEventFired; + +protected: + + bool m_bDisabled; +}; + +LINK_ENTITY_TO_CLASS(logic_eventlistener, CLogicEventListener); + + +BEGIN_DATADESC( CLogicEventListener ) + + DEFINE_KEYFIELD(m_iszEventName, FIELD_STRING, "EventName"), + DEFINE_KEYFIELD(m_bDisabled, FIELD_BOOLEAN, "StartDisabled"), + + // Inputs + DEFINE_INPUTFUNC(FIELD_VOID, "Enable", InputEnable), + DEFINE_INPUTFUNC(FIELD_VOID, "Disable", InputDisable), + DEFINE_INPUTFUNC(FIELD_VOID, "Toggle", InputToggle), + + // Outputs + DEFINE_OUTPUT(m_OnEventFired, "OnEventFired"), + +END_DATADESC() + + + +//----------------------------------------------------------------------------- +// Purpose: Constructor. +//----------------------------------------------------------------------------- +CLogicEventListener::CLogicEventListener(void) +{ +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicEventListener::Activate() +{ + BaseClass::Activate(); + ListenForEvents(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicEventListener::ListenForEvents() +{ + ListenForGameEvent(STRING(m_iszEventName)); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CLogicEventListener::KeyValue(const char *szKeyName, const char *szValue) +{ + if (FStrEq(szKeyName, "IsEnabled")) + { + m_bDisabled = !FStrEq(szValue, "0"); + } + else + return BaseClass::KeyValue(szKeyName, szValue); + + return true; +} + +//----------------------------------------------------------------------------- +// Purpose: called when a game event is fired +//----------------------------------------------------------------------------- +void CLogicEventListener::FireGameEvent( IGameEvent *event ) +{ + DevMsg("Heard Event\n"); + + if (m_bDisabled) + return; + + m_OnEventFired.FireOutput(this, this); +} + +//------------------------------------------------------------------------------ +// Purpose: Turns on the entity, allowing it to fire outputs. +//------------------------------------------------------------------------------ +void CLogicEventListener::InputEnable( inputdata_t &inputdata ) +{ + m_bDisabled = false; +} + +//------------------------------------------------------------------------------ +// Purpose: Turns off the entity, preventing it from firing outputs. +//------------------------------------------------------------------------------ +void CLogicEventListener::InputDisable( inputdata_t &inputdata ) +{ + m_bDisabled = true; +} + +//------------------------------------------------------------------------------ +// Purpose: Toggles the enabled/disabled state of the entity. +//------------------------------------------------------------------------------ +void CLogicEventListener::InputToggle( inputdata_t &inputdata ) +{ + m_bDisabled = !m_bDisabled; +} + + +#define POINT_EVENT_NUM_VALUES 8 + +class CPointEvent : public CLogicEventListener +{ +public: + DECLARE_CLASS( CPointEvent, CLogicEventListener ); + + CPointEvent(); + + string_t m_KeyNames[POINT_EVENT_NUM_VALUES]; + + void ListenForEvents(); + + void FireGameEvent( IGameEvent *event ); + + // Input handlers + void InputSetAllEvents( inputdata_t &inputdata ); + void InputAddEvent( inputdata_t &inputdata ); + //void InputRemoveEvent( inputdata_t &inputdata ); + + DECLARE_DATADESC(); + + // Outputs + COutputString m_OutEventName; + COutputString m_OutValue[POINT_EVENT_NUM_VALUES]; +}; + +LINK_ENTITY_TO_CLASS(point_event, CPointEvent); + + +BEGIN_DATADESC( CPointEvent ) + + DEFINE_KEYFIELD(m_KeyNames[0], FIELD_STRING, "KeyName01"), + DEFINE_KEYFIELD(m_KeyNames[1], FIELD_STRING, "KeyName02"), + DEFINE_KEYFIELD(m_KeyNames[2], FIELD_STRING, "KeyName03"), + DEFINE_KEYFIELD(m_KeyNames[3], FIELD_STRING, "KeyName04"), + DEFINE_KEYFIELD(m_KeyNames[4], FIELD_STRING, "KeyName05"), + DEFINE_KEYFIELD(m_KeyNames[5], FIELD_STRING, "KeyName06"), + DEFINE_KEYFIELD(m_KeyNames[6], FIELD_STRING, "KeyName07"), + DEFINE_KEYFIELD(m_KeyNames[7], FIELD_STRING, "KeyName08"), + + // Inputs + DEFINE_INPUTFUNC(FIELD_STRING, "SetAllEvents", InputSetAllEvents), + DEFINE_INPUTFUNC(FIELD_STRING, "AddEvent", InputAddEvent), + //DEFINE_INPUTFUNC(FIELD_STRING, "RemoveEvent", InputRemoveEvent), + + // Outputs + DEFINE_OUTPUT(m_OutEventName, "OutEventName"), + DEFINE_OUTPUT(m_OutValue[0], "OutValue01"), + DEFINE_OUTPUT(m_OutValue[1], "OutValue02"), + DEFINE_OUTPUT(m_OutValue[2], "OutValue03"), + DEFINE_OUTPUT(m_OutValue[3], "OutValue04"), + DEFINE_OUTPUT(m_OutValue[4], "OutValue05"), + DEFINE_OUTPUT(m_OutValue[5], "OutValue06"), + DEFINE_OUTPUT(m_OutValue[6], "OutValue07"), + DEFINE_OUTPUT(m_OutValue[7], "OutValue08"), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: Constructor. +//----------------------------------------------------------------------------- +CPointEvent::CPointEvent(void) +{ +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointEvent::ListenForEvents() +{ + // Could easily do this with strtok... + // Oh well. I don't know the performance difference. + CUtlStringList vecEvents; + Q_SplitString(STRING(m_iszEventName), ":", vecEvents); + FOR_EACH_VEC(vecEvents, i) + { + ListenForGameEvent(vecEvents[i]); + } +} + +//----------------------------------------------------------------------------- +// Purpose: called when a game event is fired +//----------------------------------------------------------------------------- +void CPointEvent::FireGameEvent( IGameEvent *event ) +{ + if (m_bDisabled) + return; + + BaseClass::FireGameEvent(event); + m_OutEventName.Set(AllocPooledString(event->GetName()), this, this); + + for (int i = 0; i < POINT_EVENT_NUM_VALUES; i++) + { + const char *szValue = event->GetString(STRING(m_KeyNames[i]), NULL); + if (szValue != NULL) + { + m_OutValue[i].Set(AllocPooledString(szValue), this, this); + } + } +} + +//------------------------------------------------------------------------------ +// Purpose: +//------------------------------------------------------------------------------ +void CPointEvent::InputSetAllEvents( inputdata_t &inputdata ) +{ + StopListeningForAllEvents(); + + if (inputdata.value.StringID() != NULL_STRING) + { + CUtlStringList vecEvents; + Q_SplitString(inputdata.value.String(), ":", vecEvents); + FOR_EACH_VEC(vecEvents, i) + { + ListenForGameEvent(vecEvents[i]); + } + } +} + +//------------------------------------------------------------------------------ +// Purpose: +//------------------------------------------------------------------------------ +void CPointEvent::InputAddEvent( inputdata_t &inputdata ) +{ + ListenForGameEvent(inputdata.value.String()); +} diff --git a/sp/src/game/server/mapbase/logic_externaldata.cpp b/sp/src/game/server/mapbase/logic_externaldata.cpp new file mode 100644 index 00000000..56f9fe39 --- /dev/null +++ b/sp/src/game/server/mapbase/logic_externaldata.cpp @@ -0,0 +1,240 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#include "cbase.h" +#include "filesystem.h" +#include "KeyValues.h" + + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +class CLogicExternalData : public CLogicalEntity +{ + DECLARE_CLASS( CLogicExternalData, CLogicalEntity ); + DECLARE_DATADESC(); + +public: + ~CLogicExternalData(); + + void LoadFile(); + void SaveFile(); + void SetBlock(string_t iszNewTarget, CBaseEntity *pActivator = NULL, CBaseEntity *pCaller = NULL); + + void Activate(); + + // Inputs + void InputWriteKeyValue( inputdata_t &inputdata ); + void InputRemoveKeyValue( inputdata_t &inputdata ); + void InputReadKey( inputdata_t &inputdata ); + void InputSetBlock( inputdata_t &inputdata ); + void InputSave( inputdata_t &inputdata ); + void InputReload( inputdata_t &inputdata ); + + char m_iszFile[MAX_PATH]; + + // Root file + KeyValues *m_pRoot; + + // Our specific block + KeyValues *m_pBlock; + //string_t m_iszBlock; // Use m_target + + bool m_bSaveEachChange; + bool m_bReloadBeforeEachAction; + + COutputString m_OutValue; +}; + +LINK_ENTITY_TO_CLASS(logic_externaldata, CLogicExternalData); + +BEGIN_DATADESC( CLogicExternalData ) + + // Keys + //DEFINE_KEYFIELD( m_iszBlock, FIELD_STRING, "Block" ), + DEFINE_KEYFIELD( m_bSaveEachChange, FIELD_BOOLEAN, "SaveEachChange" ), + DEFINE_KEYFIELD( m_bReloadBeforeEachAction, FIELD_BOOLEAN, "ReloadBeforeEachAction" ), + + // This should be cached each load + //DEFINE_ARRAY( m_iszFile, FIELD_CHARACTER, MAX_PATH ), + + // Inputs + DEFINE_INPUTFUNC( FIELD_STRING, "WriteKeyValue", InputWriteKeyValue ), + DEFINE_INPUTFUNC( FIELD_STRING, "RemoveKeyValue", InputRemoveKeyValue ), + DEFINE_INPUTFUNC( FIELD_STRING, "ReadKey", InputReadKey ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetBlock", InputSetBlock ), + DEFINE_INPUTFUNC( FIELD_VOID, "Save", InputSave ), + DEFINE_INPUTFUNC( FIELD_VOID, "Reload", InputReload ), + + // Outputs + DEFINE_OUTPUT(m_OutValue, "OutValue"), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CLogicExternalData::~CLogicExternalData() +{ + if (m_pRoot) + m_pRoot->deleteThis(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicExternalData::LoadFile() +{ + if (m_pRoot) + m_pRoot->deleteThis(); + + m_pRoot = new KeyValues( m_iszFile ); + m_pRoot->LoadFromFile(g_pFullFileSystem, m_iszFile, "MOD"); + + // This shold work even if the file didn't load. + if (m_target != NULL_STRING) + { + m_pBlock = m_pRoot->FindKey(STRING(m_target), true); + } + else + { + // Just do things from root + m_pBlock = m_pRoot; + } + + if (!m_pBlock) + { + Warning("WARNING! %s has NULL m_pBlock! Removing...\n", GetDebugName()); + UTIL_Remove(this); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicExternalData::SaveFile() +{ + DevMsg("Saving to %s...\n", m_iszFile); + m_pRoot->SaveToFile(g_pFullFileSystem, m_iszFile, "MOD", false, true); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicExternalData::SetBlock(string_t iszNewTarget, CBaseEntity *pActivator, CBaseEntity *pCaller) +{ + if (STRING(iszNewTarget)[0] == '!') + { + if (FStrEq(STRING(iszNewTarget), "!self")) + iszNewTarget = GetEntityName(); + else if (pActivator && FStrEq(STRING(iszNewTarget), "!activator")) + iszNewTarget = pActivator->GetEntityName(); + else if (pCaller && FStrEq(STRING(iszNewTarget), "!caller")) + iszNewTarget = pCaller->GetEntityName(); + } + + m_target = iszNewTarget; + LoadFile(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicExternalData::Activate() +{ + BaseClass::Activate(); + + Q_snprintf(m_iszFile, sizeof(m_iszFile), "maps/%s_externaldata.txt", gpGlobals->mapname); + DevMsg("LOGIC_EXTERNALDATA: %s\n", m_iszFile); + + // This handles !self, etc. even though the end result could just be assigning to itself. + // Also calls LoadFile() for initial load. + SetBlock(m_target); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicExternalData::InputWriteKeyValue( inputdata_t &inputdata ) +{ + const char *szValue = inputdata.value.String(); + char key[256]; + char value[256]; + + // Separate key from value + char *delimiter = Q_strstr(szValue, " "); + if (delimiter) + { + Q_strncpy(key, szValue, MIN((delimiter - szValue) + 1, sizeof(key))); + Q_strncpy(value, delimiter + 1, sizeof(value)); + } + else + { + // Assume the value is just supposed to be null + Q_strncpy(key, szValue, sizeof(key)); + } + + if (m_bReloadBeforeEachAction) + LoadFile(); + + m_pBlock->SetString(key, value); + + if (m_bSaveEachChange) + SaveFile(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicExternalData::InputRemoveKeyValue( inputdata_t &inputdata ) +{ + if (m_bReloadBeforeEachAction) + LoadFile(); + + KeyValues *pKV = m_pBlock->FindKey(inputdata.value.String()); + if (pKV) + { + m_pBlock->RemoveSubKey(pKV); + + if (m_bSaveEachChange) + SaveFile(); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicExternalData::InputReadKey( inputdata_t &inputdata ) +{ + if (m_bReloadBeforeEachAction) + LoadFile(); + + m_OutValue.Set(AllocPooledString(m_pBlock->GetString(inputdata.value.String())), inputdata.pActivator, this); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicExternalData::InputSetBlock( inputdata_t &inputdata ) +{ + SetBlock(inputdata.value.StringID(), inputdata.pActivator, inputdata.pCaller); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicExternalData::InputSave( inputdata_t &inputdata ) +{ + SaveFile(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicExternalData::InputReload( inputdata_t &inputdata ) +{ + LoadFile(); +} diff --git a/sp/src/game/server/mapbase/logic_register_activator.cpp b/sp/src/game/server/mapbase/logic_register_activator.cpp new file mode 100644 index 00000000..dac37423 --- /dev/null +++ b/sp/src/game/server/mapbase/logic_register_activator.cpp @@ -0,0 +1,143 @@ +//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ==== +// +// Attempts to replicate logic_register_activator from Portal 2. +// +// This is, in fact, a RECREATION! This is not an actual port. +// +//============================================================================= + +#include "cbase.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +class CLogicRegisterActivator : public CLogicalEntity +{ +public: + DECLARE_CLASS( CLogicRegisterActivator, CLogicalEntity ); + + CLogicRegisterActivator(); + + // Input handlers + void InputEnable( inputdata_t &inputdata ); + void InputDisable( inputdata_t &inputdata ); + void InputToggle( inputdata_t &inputdata ); + + void InputFireRegisteredAsActivator1( inputdata_t &inputdata ); + void InputFireRegisteredAsActivator2( inputdata_t &inputdata ); + void InputFireRegisteredAsActivator3( inputdata_t &inputdata ); + void InputFireRegisteredAsActivator4( inputdata_t &inputdata ); + void InputRegisterEntity( inputdata_t &inputdata ); + + DECLARE_DATADESC(); + + // Outputs + COutputEvent m_OnRegisteredActivate[ 4 ]; + + EHANDLE m_hActivator; + +private: + + bool m_bDisabled; +}; + +LINK_ENTITY_TO_CLASS(logic_register_activator, CLogicRegisterActivator); + + +BEGIN_DATADESC( CLogicRegisterActivator ) + + DEFINE_KEYFIELD(m_bDisabled, FIELD_BOOLEAN, "StartDisabled"), + + DEFINE_FIELD( m_hActivator, FIELD_EHANDLE ), + + // Inputs + DEFINE_INPUTFUNC(FIELD_VOID, "Enable", InputEnable), + DEFINE_INPUTFUNC(FIELD_VOID, "Disable", InputDisable), + DEFINE_INPUTFUNC(FIELD_VOID, "Toggle", InputToggle), + DEFINE_INPUTFUNC(FIELD_VOID, "FireRegisteredAsActivator1", InputFireRegisteredAsActivator1), + DEFINE_INPUTFUNC(FIELD_VOID, "FireRegisteredAsActivator2", InputFireRegisteredAsActivator2), + DEFINE_INPUTFUNC(FIELD_VOID, "FireRegisteredAsActivator3", InputFireRegisteredAsActivator3), + DEFINE_INPUTFUNC(FIELD_VOID, "FireRegisteredAsActivator4", InputFireRegisteredAsActivator4), + DEFINE_INPUTFUNC(FIELD_EHANDLE, "RegisterEntity", InputRegisterEntity), + + // Outputs + DEFINE_OUTPUT(m_OnRegisteredActivate[0], "OnRegisteredActivate1"), + DEFINE_OUTPUT(m_OnRegisteredActivate[1], "OnRegisteredActivate2"), + DEFINE_OUTPUT(m_OnRegisteredActivate[2], "OnRegisteredActivate3"), + DEFINE_OUTPUT(m_OnRegisteredActivate[3], "OnRegisteredActivate4"), + +END_DATADESC() + + + +//----------------------------------------------------------------------------- +// Purpose: Constructor. +//----------------------------------------------------------------------------- +CLogicRegisterActivator::CLogicRegisterActivator(void) +{ +} + +//------------------------------------------------------------------------------ +// Purpose: Turns on the entity, allowing it to fire outputs. +//------------------------------------------------------------------------------ +void CLogicRegisterActivator::InputEnable( inputdata_t &inputdata ) +{ + m_bDisabled = false; +} + +//------------------------------------------------------------------------------ +// Purpose: Turns off the entity, preventing it from firing outputs. +//------------------------------------------------------------------------------ +void CLogicRegisterActivator::InputDisable( inputdata_t &inputdata ) +{ + m_bDisabled = true; +} + +//------------------------------------------------------------------------------ +// Purpose: Toggles the enabled/disabled state of the entity. +//------------------------------------------------------------------------------ +void CLogicRegisterActivator::InputToggle( inputdata_t &inputdata ) +{ + m_bDisabled = !m_bDisabled; +} + + +//----------------------------------------------------------------------------- +// Purpose: Input handler that fires its respective OnRegisteredActivate with the stored activator. +//----------------------------------------------------------------------------- +void CLogicRegisterActivator::InputFireRegisteredAsActivator1( inputdata_t &inputdata ) +{ + m_OnRegisteredActivate[0].FireOutput(m_hActivator, this); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler that fires its respective OnRegisteredActivate with the stored activator. +//----------------------------------------------------------------------------- +void CLogicRegisterActivator::InputFireRegisteredAsActivator2( inputdata_t &inputdata ) +{ + m_OnRegisteredActivate[1].FireOutput(m_hActivator, this); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler that fires its respective OnRegisteredActivate with the stored activator. +//----------------------------------------------------------------------------- +void CLogicRegisterActivator::InputFireRegisteredAsActivator3( inputdata_t &inputdata ) +{ + m_OnRegisteredActivate[2].FireOutput(m_hActivator, this); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler that fires its respective OnRegisteredActivate with the stored activator. +//----------------------------------------------------------------------------- +void CLogicRegisterActivator::InputFireRegisteredAsActivator4( inputdata_t &inputdata ) +{ + m_OnRegisteredActivate[3].FireOutput(m_hActivator, this); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler that stores an entity as the activator. +//----------------------------------------------------------------------------- +void CLogicRegisterActivator::InputRegisterEntity( inputdata_t &inputdata ) +{ + m_hActivator = inputdata.value.Entity(); +} diff --git a/sp/src/game/server/mapbase/logic_skill.cpp b/sp/src/game/server/mapbase/logic_skill.cpp new file mode 100644 index 00000000..6454b6b0 --- /dev/null +++ b/sp/src/game/server/mapbase/logic_skill.cpp @@ -0,0 +1,66 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Controls and detects difficulty level changes +// +//============================================================================= + +#include "cbase.h" + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +class CLogicSkill : public CLogicalEntity +{ + DECLARE_CLASS( CLogicSkill, CLogicalEntity ); + +private: + // Inputs + void InputTest( inputdata_t &inputdata ); + void InputStartListening( inputdata_t &inputdata ) {m_bListeningForSkillChanges = true;} + void InputStopListening( inputdata_t &inputdata ) {m_bListeningForSkillChanges = false;} + + // Used by gamerules to fire OnSkillChanged. + // Passes the level it changed to as well. + void InputSkillLevelChanged(inputdata_t &inputdata) { m_bListeningForSkillChanges ? m_OnSkillChanged.Set(inputdata.value.Int(), inputdata.pActivator, this) : 0; } + + COutputInt m_OnSkillChanged; + COutputEvent m_OnEasy; + COutputEvent m_OnMedium; + COutputEvent m_OnHard; + + bool m_bListeningForSkillChanges; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(logic_skill, CLogicSkill); + +BEGIN_DATADESC( CLogicSkill ) + + DEFINE_KEYFIELD( m_bListeningForSkillChanges, FIELD_BOOLEAN, "ListenForSkillChange" ), + + // Inputs + DEFINE_INPUTFUNC( FIELD_VOID, "Test", InputTest ), + DEFINE_INPUTFUNC( FIELD_VOID, "StartListening", InputStartListening ), + DEFINE_INPUTFUNC( FIELD_VOID, "StopListening", InputStopListening ), + + DEFINE_INPUTFUNC( FIELD_INTEGER, "SkillLevelChanged", InputSkillLevelChanged ), + + DEFINE_OUTPUT( m_OnSkillChanged, "OnSkillChanged" ), + DEFINE_OUTPUT( m_OnEasy, "OnEasy" ), + DEFINE_OUTPUT( m_OnMedium, "OnNormal" ), + DEFINE_OUTPUT( m_OnHard, "OnHard" ), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CLogicSkill::InputTest( inputdata_t &inputdata ) +{ + switch (g_pGameRules->GetSkillLevel()) + { + case SKILL_EASY: m_OnEasy.FireOutput(this, this); break; + case SKILL_MEDIUM: m_OnMedium.FireOutput(this, this); break; + case SKILL_HARD: m_OnHard.FireOutput(this, this); break; + } +} diff --git a/sp/src/game/server/mapbase/matchers.h b/sp/src/game/server/mapbase/matchers.h new file mode 100644 index 00000000..eb0bd6ad --- /dev/null +++ b/sp/src/game/server/mapbase/matchers.h @@ -0,0 +1,160 @@ +//========= Copyright Valve Corporation, All rights reserved. ================= +// +// Purpose: General matching functions for things like wildcards and !=. +// +// $NoKeywords: $ +//============================================================================= + +#define MAPBASE_MATCHERS 1 + +extern bool ResponseSystemCompare(const char *criterion, const char *value); +//extern const char *ResponseSystemCompare(const char *criterion, const char *value, bool bReturnToken); + +//============================================================================= +// These are the "matchers" that compare with wildcards (any*) and operators (<3). +// +// Matcher_Match - Supports operators and wildcards. +// Matcher_NamesMatch - Only supports wildcards. +// Matcher_Compare - Long story short, Matcher_Match didn't support wildcards before. +// This was used to support both matchers and wildcards. +// Now it just redirects to Matcher_Match. +// +// AppearsToBeANumber - Checks if the string might be a number. +// Stolen from the Response System, just like the other matchers. +//============================================================================= + +// Compares with != and the like. Basically hijacks the response system matching. +// Now supports trailing wildcards (query* == querything) +// pszQuery = The value that should have the operator(s) at the beginning +// szValue = The value tested against the criterion +inline bool Matcher_Match(const char *pszQuery, const char *szValue) +{ + // I wasn't kidding when I said all this did was hijack response system matching. + return ResponseSystemCompare(pszQuery, szValue); + // (pszQuery && szValue) ? ResponseSystemCompare(pszQuery, szValue, pass) : FStrEq(pszQuery, szValue); +} + +inline bool Matcher_Match(const char *pszQuery, int iValue) +{ + return Matcher_Match(pszQuery, UTIL_VarArgs("%i", iValue)); +} + +// Compares two strings with trailing wildcards. Nothing more. Use Matcher_Match if you want <, !=, etc. +// pszQuery = The value that should have the wildcard. +// szValue = The value tested against the query. +// It's basically just baseentity.cpp's NamesMatch(). +FORCEINLINE bool Matcher_NamesMatch(const char *pszQuery, const char *szValue) +{ + if ( szValue == NULL ) + return (!pszQuery || *pszQuery == 0 || *pszQuery == '*'); + + // If the pointers are identical, we're identical + if ( szValue == pszQuery ) + return true; + + while ( *szValue && *pszQuery ) + { + unsigned char cName = *szValue; + unsigned char cQuery = *pszQuery; + // simple ascii case conversion + if ( cName == cQuery ) + ; + else if ( cName - 'A' <= (unsigned char)'Z' - 'A' && cName - 'A' + 'a' == cQuery ) + ; + else if ( cName - 'a' <= (unsigned char)'z' - 'a' && cName - 'a' + 'A' == cQuery ) + ; + else + break; + ++szValue; + ++pszQuery; + } + + if ( *pszQuery == 0 && *szValue == 0 ) + return true; + + // @TODO (toml 03-18-03): Perhaps support real wildcards. Right now, only thing supported is trailing * + if ( *pszQuery == '*' ) + return true; + + return false; +} + +// Identical to Matcher_NamesMatch(), but either value could use a wildcard. +// pszQuery = The value that serves as the query. This value can use wildcards. +// szValue = The value tested against the query. This value can use wildcards as well. +FORCEINLINE bool Matcher_NamesMatch_MutualWildcard(const char *pszQuery, const char *szValue) +{ + if ( szValue == NULL ) + return (!pszQuery || *pszQuery == 0 || *pszQuery == '*'); + + if ( pszQuery == NULL ) + return (!szValue || *szValue == 0 || *szValue == '*'); + + // If the pointers are identical, we're identical + if ( szValue == pszQuery ) + return true; + + while ( *szValue && *pszQuery ) + { + unsigned char cName = *szValue; + unsigned char cQuery = *pszQuery; + // simple ascii case conversion + if ( cName == cQuery ) + ; + else if ( cName - 'A' <= (unsigned char)'Z' - 'A' && cName - 'A' + 'a' == cQuery ) + ; + else if ( cName - 'a' <= (unsigned char)'z' - 'a' && cName - 'a' + 'A' == cQuery ) + ; + else + break; + ++szValue; + ++pszQuery; + } + + if ( *pszQuery == 0 && *szValue == 0 ) + return true; + + // @TODO (toml 03-18-03): Perhaps support real wildcards. Right now, only thing supported is trailing * + if ( *pszQuery == '*' || *szValue == '*' ) + return true; + + return false; +} + +// While Matcher_Match didn't support wildcards, +// this was used to match with both matchers and wildcards. +// Now that Matcher_Match supports wildcards, it just redirects to that, +// but I use this anyway for consistency purposes and force-of-habit. +// pszQuery = The value that should have the operator or wildcard +// szValue = The value tested against the criterion +inline bool Matcher_Compare(const char *pszQuery, const char *szValue) +{ + return Matcher_Match(pszQuery, szValue); +#if 0 + // I have to do this so wildcards could test *before* the response system comparison. + // I know it removes the operators twice, but I won't worry about it. + bool match = Matcher_NamesMatch(Matcher_RemoveOperators(pszQuery), szValue); + if (match) + return Matcher_Match(pszQuery, szValue); + return false; +#endif +} + +// Yeeted right out of the Response System. +// Checks if the specified string appears to be a number of some sort. +static bool AppearsToBeANumber( char const *token ) +{ + if ( atof( token ) != 0.0f ) + return true; + + char const *p = token; + while ( *p ) + { + if ( *p != '0' ) + return false; + + p++; + } + + return true; +} diff --git a/sp/src/game/server/mapbase/point_advanced_finder.cpp b/sp/src/game/server/mapbase/point_advanced_finder.cpp new file mode 100644 index 00000000..760df597 --- /dev/null +++ b/sp/src/game/server/mapbase/point_advanced_finder.cpp @@ -0,0 +1,393 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: A ballsier version of point_entity_finder. +// Originally called logic_entityfinder because a lot of this was written +// before I knew about point_entity_finder in the first place. +// +//============================================================================= + +#include "cbase.h" +#include "eventqueue.h" +#include "filters.h" +#include "saverestore_utlvector.h" + +// Uses a CUtlVector instead of an array. +#define ENTITYFINDER_UTLVECTOR 1 + +// Delays outputs directly instead of relying on an input. +#define ENTITYFINDER_OUTPUT_DELAY 1 + +#if !ENTITYFINDER_STATIC_ARRAY +#define ENTITYFINDER_MAX_STORED_ENTITIES 64 +#endif + +//----------------------------------------------------------------------------- +// Purpose: Entity finder that uses filters and other criteria to search the level for a specific entity. +//----------------------------------------------------------------------------- +class CPointAdvancedFinder : public CLogicalEntity +{ + DECLARE_CLASS(CPointAdvancedFinder, CLogicalEntity); + +private: + // Inputs + void InputSearch(inputdata_t &inputdata); + void InputSetSearchFilter(inputdata_t &inputdata); + void InputSetSearchPoint(inputdata_t &inputdata); + void InputSetRadius(inputdata_t &inputdata) { m_flRadius = inputdata.value.Float(); } + void InputSetMaxResults(inputdata_t &inputdata) { m_iNumSearches = inputdata.value.Int(); } + void InputSetOutputDelay(inputdata_t &inputdata) { m_flOutputDelay = inputdata.value.Float(); } + void InputSetFiringMethod(inputdata_t &inputdata) { m_iFiringMethod = inputdata.value.Int(); } +#ifndef ENTITYFINDER_OUTPUT_DELAY + void InputFoundEntity(inputdata_t &inputdata); +#endif + + void Spawn(); + + Vector GetSearchOrigin(); + bool SearchForEntities(inputdata_t &inputdata); + void FoundEntity(CBaseEntity *pEntity, inputdata_t &inputdata); + + + string_t m_iszSearchFilter; + CHandle m_hSearchFilter; + + string_t m_iszSearchPoint; + EHANDLE m_hSearchPoint; + + float m_flRadius; + int m_iNumSearches; + int m_iFiringMethod; + enum + { + FIRINGMETHOD_NONE = -1, // -1 for point_entity_finder compatibility + FIRINGMETHOD_NEAREST, + FIRINGMETHOD_FARTHEST, + FIRINGMETHOD_RANDOM, + }; + + float m_flOutputDelay; + float m_flLastOutputDelay = 0.0f; + +#if ENTITYFINDER_UTLVECTOR + CUtlVector m_StoredEntities; +#else + CBaseEntity *m_StoredEntities[ENTITYFINDER_MAX_STORED_ENTITIES]; +#endif + + // Outputs + COutputEHANDLE m_OnFoundEntity; + COutputEvent m_OnSearchFailed; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(point_advanced_finder, CPointAdvancedFinder); + + +BEGIN_DATADESC(CPointAdvancedFinder) + + // Keys + DEFINE_KEYFIELD(m_iszSearchFilter, FIELD_STRING, "SearchFilter"), + DEFINE_FIELD(m_hSearchFilter, FIELD_EHANDLE), + DEFINE_KEYFIELD(m_iszSearchPoint, FIELD_STRING, "SearchPoint"), + DEFINE_FIELD(m_hSearchPoint, FIELD_EHANDLE), + DEFINE_KEYFIELD(m_flRadius, FIELD_FLOAT, "radius"), + DEFINE_KEYFIELD(m_iNumSearches, FIELD_INTEGER, "NumberOfEntities"), + DEFINE_KEYFIELD(m_flOutputDelay, FIELD_FLOAT, "OutputDelay"), + DEFINE_KEYFIELD(m_iFiringMethod, FIELD_INTEGER, "Method"), +#if ENTITYFINDER_UTLVECTOR + DEFINE_UTLVECTOR( m_StoredEntities, FIELD_CLASSPTR ), +#else + DEFINE_ARRAY(m_StoredEntities, FIELD_CLASSPTR, ENTITYFINDER_MAX_STORED_ENTITIES), +#endif + DEFINE_FIELD(m_flLastOutputDelay, FIELD_FLOAT), + + // Inputs + DEFINE_INPUTFUNC(FIELD_VOID, "BeginSearch", InputSearch), + DEFINE_INPUTFUNC(FIELD_STRING, "SetSearchFilter", InputSetSearchFilter), + DEFINE_INPUTFUNC(FIELD_STRING, "SetSearchPoint", InputSetSearchPoint), + DEFINE_INPUTFUNC(FIELD_FLOAT, "SetRadius", InputSetRadius), + DEFINE_INPUTFUNC(FIELD_INTEGER, "SetMaxResults", InputSetMaxResults), + DEFINE_INPUTFUNC(FIELD_FLOAT, "SetOutputDelay", InputSetOutputDelay), + DEFINE_INPUTFUNC(FIELD_INTEGER, "SetFiringMethod", InputSetFiringMethod), +#ifndef ENTITYFINDER_OUTPUT_DELAY + DEFINE_INPUTFUNC(FIELD_EHANDLE, "FoundEntity", InputFoundEntity), +#endif + + // Outputs + DEFINE_OUTPUT(m_OnFoundEntity, "OnFoundEntity"), + DEFINE_OUTPUT(m_OnSearchFailed, "OnSearchFailed"), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointAdvancedFinder::Spawn() +{ + if (m_iszSearchFilter == NULL_STRING) + { + Warning("%s (%s) has no search filter!\n", GetClassname(), GetDebugName()); + UTIL_Remove(this); + return; + } + + m_hSearchFilter = dynamic_cast(gEntList.FindEntityByName( NULL, m_iszSearchFilter, this )); + + m_hSearchPoint = gEntList.FindEntityByName( NULL, m_iszSearchPoint, this ); + + BaseClass::Spawn(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointAdvancedFinder::InputSearch(inputdata_t &inputdata) +{ + SearchForEntities(inputdata); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointAdvancedFinder::InputSetSearchFilter(inputdata_t &inputdata) +{ + m_iszSearchFilter = inputdata.value.StringID(); + m_hSearchFilter = dynamic_cast(gEntList.FindEntityByName( NULL, m_iszSearchFilter, this, inputdata.pActivator, inputdata.pCaller )); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointAdvancedFinder::InputSetSearchPoint(inputdata_t &inputdata) +{ + m_iszSearchPoint = inputdata.value.StringID(); + m_hSearchPoint = gEntList.FindEntityByName( NULL, m_iszSearchPoint, this, inputdata.pActivator, inputdata.pCaller ); +} + +#ifndef ENTITYFINDER_OUTPUT_DELAY +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointAdvancedFinder::InputFoundEntity(inputdata_t &inputdata) +{ + CBaseEntity *pEntity = inputdata.value.Entity(); + if (!pEntity) + return; + + m_OnFoundEntity.Set(pEntity, pEntity, inputdata.pCaller); +} +#endif + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +inline Vector CPointAdvancedFinder::GetSearchOrigin() +{ + if (m_hSearchPoint == NULL) + m_hSearchPoint = this; + + return m_hSearchPoint->GetAbsOrigin(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CPointAdvancedFinder::SearchForEntities(inputdata_t &inputdata) +{ + if ( !m_hSearchFilter ) + return false; + + m_flLastOutputDelay = 0.0f; + + int iNumResults = 0; + + float flRadius = m_flRadius * m_flRadius; + + bool bShouldStoreEntities = (m_iFiringMethod > FIRINGMETHOD_NONE || m_flOutputDelay > 0); +#if !ENTITYFINDER_UTLVECTOR + if (bShouldStoreEntities) + { + if (m_iNumSearches > ENTITYFINDER_MAX_STORED_ENTITIES) + { + Warning("%s (%s) needs to store entities, but we're asked to look for more than the maximum, %i, with %i! Reducing to max...\n", GetClassname(), GetDebugName(), ENTITYFINDER_MAX_STORED_ENTITIES, m_iNumSearches); + m_iNumSearches = ENTITYFINDER_MAX_STORED_ENTITIES; + } + else if (m_iNumSearches == 0) + { + m_iNumSearches = ENTITYFINDER_MAX_STORED_ENTITIES; + } + } + else +#endif + if (m_iNumSearches == 0) + { + m_iNumSearches = MAX_EDICTS; + } + + const CEntInfo *pInfo = gEntList.FirstEntInfo(); + + for ( ;pInfo; pInfo = pInfo->m_pNext ) + { + CBaseEntity *ent = (CBaseEntity *)pInfo->m_pEntity; + if ( !ent ) + { + DevWarning( "NULL entity in global entity list!\n" ); + continue; + } + + if (iNumResults >= m_iNumSearches) + break; + + if ( m_hSearchFilter && !m_hSearchFilter->PassesFilter( this, ent ) ) + continue; + + if (flRadius > 0 && (ent->GetAbsOrigin() - GetSearchOrigin()).LengthSqr() > flRadius) + continue; + + if ( bShouldStoreEntities ) + { + // Fire it later +#if ENTITYFINDER_UTLVECTOR + m_StoredEntities.AddToTail(ent); +#else + m_StoredEntities[ iNumResults ] = ent; +#endif + } + else + { + // Fire it now + FoundEntity(ent, inputdata); + } + + iNumResults++; + } + + if (iNumResults > 0) + { + if (bShouldStoreEntities) + { + if (m_iFiringMethod == FIRINGMETHOD_NEAREST || m_iFiringMethod == FIRINGMETHOD_FARTHEST) + { + bool bNotFarthest = m_iFiringMethod != FIRINGMETHOD_FARTHEST; + float flMaxDist = m_flRadius; + float flMinDist = 0; + + if (flMaxDist == 0) + flMaxDist = MAX_TRACE_LENGTH; + + for (int iCur = 0; iCur < iNumResults; iCur++) + { + float flClosest = bNotFarthest ? flMaxDist : 0; + float flDistance = 0; + CBaseEntity *pClosest = NULL; + for (int i = 0; i < iNumResults; i++) + { + if (!m_StoredEntities[i]) + continue; + + flDistance = (m_StoredEntities[i]->GetAbsOrigin() - GetSearchOrigin()).Length(); + if (flDistance < flMaxDist && flDistance > flMinDist) + { + if (bNotFarthest ? (flDistance < flClosest) : (flDistance > flClosest)) + { + pClosest = m_StoredEntities[i]; + flClosest = flDistance; + } + } + } + + if (pClosest) + { + bNotFarthest ? flMinDist = flClosest : flMaxDist = flClosest; + FoundEntity(pClosest, inputdata); + } + else + { + DevWarning("%s (%s): NO CLOSEST!!!\n", GetClassname(), GetDebugName()); + } + } + } + else if (m_iFiringMethod == FIRINGMETHOD_RANDOM) + { + // This could probaly be better... + CUtlVector iResultIndices; + for (int i = 0; i < iNumResults; i++) + iResultIndices.AddToTail(i); + + while (iResultIndices.Count() > 0) + { + int index = iResultIndices[RandomInt(0, iResultIndices.Count() - 1)]; + + if (m_StoredEntities[index]) + { + FoundEntity(m_StoredEntities[index], inputdata); + } + else + { + DevWarning("%s (%s): Found entity is null: %i\n", GetClassname(), GetDebugName(), index); + } + + iResultIndices.FindAndRemove(index); + } + } + else if (m_iFiringMethod == FIRINGMETHOD_NONE) + { + for (int i = 0; i < iNumResults; i++) + { + if (m_StoredEntities[i]) + { + FoundEntity(m_StoredEntities[i], inputdata); + } + else + { + DevWarning("%s (%s): Found entity is null: %i\n", GetClassname(), GetDebugName(), i); + } + } + } + + m_StoredEntities.RemoveAll(); + } + return true; + } + else + { + m_OnSearchFailed.FireOutput(inputdata.pActivator, inputdata.pCaller); + return false; + } + + return false; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointAdvancedFinder::FoundEntity(CBaseEntity *pEntity, inputdata_t &inputdata) +{ +#ifdef ENTITYFINDER_OUTPUT_DELAY + variant_t variant; + variant.SetEntity(pEntity); + + DevMsg("%s (%s): Firing entity output in %f, added from %f\n", GetClassname(), GetDebugName(), m_flLastOutputDelay, m_flOutputDelay); + m_OnFoundEntity.FireOutput(variant, pEntity, this, m_flLastOutputDelay); +#else + if (m_flOutputDelay == 0) + { + // Just fire it now + m_OnFoundEntity.Set(pEntity, pEntity, inputdata.pCaller); + DevMsg("%s (%s): Delay 0, firing now\n", GetClassname(), GetDebugName()); + return; + } + + //if (m_flLastOutputDelay == 0) + //m_flLastOutputDelay = gpGlobals->curtime; + + variant_t variant; + variant.SetEntity(pEntity); + + DevMsg("%s (%s): Firing entity output in %f, added from %f\n", GetClassname(), GetDebugName(), m_flLastOutputDelay, m_flOutputDelay); + g_EventQueue.AddEvent(this, "FoundEntity", variant, m_flLastOutputDelay, inputdata.pActivator, inputdata.pCaller); +#endif + + m_flLastOutputDelay += m_flOutputDelay; +} diff --git a/sp/src/game/server/mapbase/point_copy_size.cpp b/sp/src/game/server/mapbase/point_copy_size.cpp new file mode 100644 index 00000000..a79be2bf --- /dev/null +++ b/sp/src/game/server/mapbase/point_copy_size.cpp @@ -0,0 +1,143 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Copies size. +// +//============================================================================= + +#include "cbase.h" + + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +class CPointCopySize : public CLogicalEntity +{ + DECLARE_CLASS( CPointCopySize, CLogicalEntity ); +private: + // The entity to copy the size from. + // m_target is the target that receives it. + string_t m_iszSizeSource; + EHANDLE m_hSizeSource; + EHANDLE m_hTarget; + + float m_flScale; + + void CopySize(CBaseEntity *pSource, CBaseEntity *pTarget); + + // Inputs + void InputCopySize( inputdata_t &inputdata ); + void InputCopySizeToEntity( inputdata_t &inputdata ); + void InputCopySizeFromEntity( inputdata_t &inputdata ); + + void InputSetTarget( inputdata_t &inputdata ) { BaseClass::InputSetTarget(inputdata); m_hTarget = NULL; } + void InputSetSource( inputdata_t &inputdata ) { m_iszSizeSource = inputdata.value.StringID(); m_hSizeSource = NULL; } + + // Outputs + COutputEvent m_OnCopy; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS(point_copy_size, CPointCopySize); + + +BEGIN_DATADESC( CPointCopySize ) + + // Keys + DEFINE_KEYFIELD(m_iszSizeSource, FIELD_STRING, "source"), + DEFINE_FIELD(m_hSizeSource, FIELD_EHANDLE), + DEFINE_FIELD(m_hTarget, FIELD_EHANDLE), + + DEFINE_INPUT(m_flScale, FIELD_FLOAT, "SetScale"), + + // Inputs + DEFINE_INPUTFUNC( FIELD_VOID, "CopySize", InputCopySize ), + DEFINE_INPUTFUNC( FIELD_EHANDLE, "CopySizeToEntity", InputCopySizeToEntity ), + DEFINE_INPUTFUNC( FIELD_EHANDLE, "CopySizeFromEntity", InputCopySizeFromEntity ), + + DEFINE_INPUTFUNC( FIELD_STRING, "SetSource", InputSetSource ), + + // Outputs + DEFINE_OUTPUT(m_OnCopy, "OnCopy"), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointCopySize::CopySize(CBaseEntity *pSource, CBaseEntity *pTarget) +{ + const Vector cvecAlignMins = pSource->WorldAlignMins(); + const Vector cvecAlignMaxs = pSource->WorldAlignMaxs(); + + Vector vecAlignMins = Vector(cvecAlignMins); + Vector vecAlignMaxs = Vector(cvecAlignMaxs); + + if (m_flScale != 0.0f && m_flScale != 1.0f) + { + vecAlignMins *= m_flScale; + vecAlignMaxs *= m_flScale; + } + + pTarget->SetCollisionBounds(vecAlignMins, vecAlignMins); + m_OnCopy.FireOutput(pTarget, this); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointCopySize::InputCopySize( inputdata_t &inputdata ) +{ + if (!m_hSizeSource) + m_hSizeSource = gEntList.FindEntityByName(NULL, STRING(m_iszSizeSource), this, inputdata.pActivator, inputdata.pCaller); + if (!m_hTarget) + m_hTarget = gEntList.FindEntityByName(NULL, STRING(m_target), this, inputdata.pActivator, inputdata.pCaller); + + if (!m_hSizeSource || !m_hTarget) + { + Warning("%s (%s): Could not find %s\n", GetClassname(), GetDebugName(), !m_hSizeSource ? "size source" : "target to copy size to"); + return; + } + + CopySize(m_hSizeSource, m_hTarget); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointCopySize::InputCopySizeToEntity( inputdata_t &inputdata ) +{ + if (!m_hSizeSource) + m_hSizeSource = gEntList.FindEntityByName(NULL, STRING(m_iszSizeSource), this, inputdata.pActivator, inputdata.pCaller); + + if (!m_hSizeSource) + { + Warning("%s (%s): Could not find size source\n", GetClassname(), GetDebugName()); + return; + } + + if (!inputdata.value.Entity()) + return; + + CopySize(m_hSizeSource, inputdata.value.Entity()); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointCopySize::InputCopySizeFromEntity( inputdata_t &inputdata ) +{ + if (!m_hTarget) + m_hTarget = gEntList.FindEntityByName(NULL, STRING(m_target), this, inputdata.pActivator, inputdata.pCaller); + + if (!m_hTarget) + { + Warning("%s (%s): Could not find target to copy size to\n", GetClassname(), GetDebugName()); + return; + } + + if (!inputdata.value.Entity()) + return; + + CopySize(inputdata.value.Entity(), m_hTarget); +} diff --git a/sp/src/game/server/mapbase/point_damageinfo.cpp b/sp/src/game/server/mapbase/point_damageinfo.cpp new file mode 100644 index 00000000..7b0e91c0 --- /dev/null +++ b/sp/src/game/server/mapbase/point_damageinfo.cpp @@ -0,0 +1,396 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: A special entity for afflicting damage as specific as possible. +// +//============================================================================= + +#include "cbase.h" + + +//----------------------------------------------------------------------------- +// Purpose: Advanced damage information afflicting. +//----------------------------------------------------------------------------- +class CPointDamageInfo : public CLogicalEntity +{ + DECLARE_CLASS( CPointDamageInfo, CLogicalEntity ); + DECLARE_DATADESC(); + + virtual bool KeyValue( const char *szKeyName, const char *szValue ); + virtual bool KeyValue( const char *szKeyName, const Vector &vecValue ); + virtual bool GetKeyValue( const char *szKeyName, char *szValue, int iMaxLen ); + +public: + CPointDamageInfo(); + + CTakeDamageInfo m_info; + + // The actual inflictor, attacker, and weapon in CTakeDamageInfo are direct entity pointers. + // This is needed to ensure !activator functionality, entities that might not exist yet, etc. + string_t m_iszInflictor; + string_t m_iszAttacker; + string_t m_iszWeapon; + + // The maximum number of entities to be damaged if they share m_target's targetname or classname. + int m_iMaxEnts; + + // Suppresses death sounds in the best way we possibly can. + bool m_bSuppressDeathSound; + + //bool m_bDisabled; + + // Inputs + void InputSetInflictor( inputdata_t &inputdata ) { m_iszInflictor = inputdata.value.StringID(); } //{ m_info.SetInflictor(inputdata.value.Entity()); } + void InputSetAttacker( inputdata_t &inputdata ) { m_iszAttacker = inputdata.value.StringID(); } //{ m_info.SetAttacker(inputdata.value.Entity()); } + void InputSetWeapon( inputdata_t &inputdata ) { m_iszWeapon = inputdata.value.StringID(); } //{ m_info.SetWeapon(inputdata.value.Entity()); } + + void InputSetDamage( inputdata_t &inputdata ) { m_info.SetDamage(inputdata.value.Float()); } + void InputSetMaxDamage( inputdata_t &inputdata ) { m_info.SetMaxDamage(inputdata.value.Float()); } + //void InputSetDamageBonus( inputdata_t &inputdata ) { m_info.SetDamageBonus(inputdata.value.Float()); } + + void InputSetDamageType( inputdata_t &inputdata ) { m_info.SetDamageType(inputdata.value.Int()); } + void InputSetDamageCustom( inputdata_t &inputdata ) { m_info.SetDamageCustom(inputdata.value.Int()); } + //void InputSetDamageStats( inputdata_t &inputdata ) { m_info.SetDamageStats(inputdata.value.Int()); } + void InputSetForceFriendlyFire( inputdata_t &inputdata ) { m_info.SetForceFriendlyFire(inputdata.value.Bool()); } + + void InputSetAmmoType( inputdata_t &inputdata ) { m_info.SetAmmoType(inputdata.value.Int()); } + + void InputSetDamageForce( inputdata_t &inputdata ) { Vector vec; inputdata.value.Vector3D(vec); m_info.SetDamageForce(vec); } + void InputSetDamagePosition( inputdata_t &inputdata ) { Vector vec; inputdata.value.Vector3D(vec); m_info.SetDamagePosition(vec); } + void InputSetReportedPosition( inputdata_t &inputdata ) { Vector vec; inputdata.value.Vector3D(vec); m_info.SetReportedPosition(vec); } + + void HandleDamage(CBaseEntity *pTarget); + + void ApplyDamage( const char *target, inputdata_t &inputdata ); + void ApplyDamage( CBaseEntity *target, inputdata_t &inputdata ); + + void InputApplyDamage( inputdata_t &inputdata ); + void InputApplyDamageToEntity( inputdata_t &inputdata ); + + // Outputs + COutputEvent m_OnApplyDamage; + COutputEvent m_OnApplyDeath; +}; + +LINK_ENTITY_TO_CLASS(point_damageinfo, CPointDamageInfo); + + +BEGIN_DATADESC( CPointDamageInfo ) + + DEFINE_EMBEDDED( m_info ), + + // Keys + DEFINE_KEYFIELD( m_iszInflictor, FIELD_STRING, "Inflictor" ), + DEFINE_KEYFIELD( m_iszAttacker, FIELD_STRING, "Attacker" ), + DEFINE_KEYFIELD( m_iszWeapon, FIELD_STRING, "Weapon" ), + + DEFINE_KEYFIELD( m_iMaxEnts, FIELD_INTEGER, "MaxEnts" ), + DEFINE_KEYFIELD( m_bSuppressDeathSound, FIELD_BOOLEAN, "SuppressDeathSound" ), + + // Inputs + DEFINE_INPUTFUNC( FIELD_STRING, "SetInflictor", InputSetInflictor ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetAttacker", InputSetAttacker ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetWeapon", InputSetWeapon ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetDamage", InputSetDamage ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetMaxDamage", InputSetMaxDamage ), + //DEFINE_INPUTFUNC( FIELD_FLOAT, "SetDamageBonus", InputSetDamageBonus ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetDamageType", InputSetDamageType ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetDamageCustom", InputSetDamageCustom ), + //DEFINE_INPUTFUNC( FIELD_INTEGER, "SetDamageStats", InputSetDamageStats ), + DEFINE_INPUTFUNC( FIELD_BOOLEAN, "SetForceFriendlyFire", InputSetForceFriendlyFire ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetAmmoType", InputSetAmmoType ), + DEFINE_INPUTFUNC( FIELD_VECTOR, "SetDamageForce", InputSetDamageForce ), + DEFINE_INPUTFUNC( FIELD_VECTOR, "SetDamagePosition", InputSetDamagePosition ), + DEFINE_INPUTFUNC( FIELD_VECTOR, "SetReportedPosition", InputSetReportedPosition ), + + DEFINE_INPUTFUNC( FIELD_VOID, "ApplyDamage", InputApplyDamage ), + DEFINE_INPUTFUNC( FIELD_EHANDLE, "ApplyDamageToEntity", InputApplyDamageToEntity ), + + // Outputs + DEFINE_OUTPUT(m_OnApplyDamage, "OnApplyDamage"), + DEFINE_OUTPUT(m_OnApplyDeath, "OnApplyDeath"), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CPointDamageInfo::CPointDamageInfo() +{ + m_info = CTakeDamageInfo(this, this, 24, DMG_GENERIC); + m_iMaxEnts = 1; +} + +//----------------------------------------------------------------------------- +// Purpose: Cache user entity field values until spawn is called. +// Input : szKeyName - Key to handle. +// szValue - Value for key. +// Output : Returns true if the key was handled, false if not. +//----------------------------------------------------------------------------- +bool CPointDamageInfo::KeyValue( const char *szKeyName, const char *szValue ) +{ + /*if (FStrEq(szKeyName, "Inflictor")) + m_info.SetInflictor(gEntList.FindEntityByName(NULL, szValue, this, NULL, NULL)); + else if (FStrEq(szKeyName, "Attacker")) + m_info.SetAttacker(gEntList.FindEntityByName(NULL, szValue, this, NULL, NULL)); + else if (FStrEq(szKeyName, "Weapon")) + m_info.SetWeapon(gEntList.FindEntityByName(NULL, szValue, this, NULL, NULL)); + + else*/ if (FStrEq(szKeyName, "Damage")) + m_info.SetDamage(atof(szValue)); + else if (FStrEq(szKeyName, "MaxDamage")) + m_info.SetMaxDamage(atof(szValue)); + //else if (FStrEq(szKeyName, "DamageBonus")) + // m_info.SetDamageBonus(atof(szValue)); + + else if (FStrEq(szKeyName, "DamageType")) + m_info.AddDamageType(atoi(szValue)); + else if (FStrEq(szKeyName, "DamageOr")) + m_info.AddDamageType(atoi(szValue)); + else if (FStrEq(szKeyName, "DamageCustom")) + m_info.SetDamageCustom(atoi(szValue)); + //else if (FStrEq(szKeyName, "DamageStats")) + // m_info.SetDamageStats(atoi(szValue)); + else if (FStrEq(szKeyName, "ForceFriendlyFire")) + m_info.SetForceFriendlyFire(FStrEq(szValue, "1")); + + else if (FStrEq(szKeyName, "AmmoType")) + m_info.SetAmmoType(atoi(szValue)); + + /* + else if (FStrEq(szKeyName, "PlayerPenetrationCount")) + m_info.SetPlayerPenetrationCount(atoi(szValue)); + else if (FStrEq(szKeyName, "DamagedOtherPlayers")) + m_info.SetDamagedOtherPlayers(atoi(szValue)); + */ + + else + { + if (!BaseClass::KeyValue(szKeyName, szValue)) + { + // Ripped from variant_t::Convert()... + Vector tmpVec = vec3_origin; + if (sscanf(szValue, "[%f %f %f]", &tmpVec[0], &tmpVec[1], &tmpVec[2]) == 0) + { + // Try sucking out 3 floats with no []s + sscanf(szValue, "%f %f %f", &tmpVec[0], &tmpVec[1], &tmpVec[2]); + } + return KeyValue(szKeyName, tmpVec); + } + } + + return true; +} + +bool CPointDamageInfo::KeyValue( const char *szKeyName, const Vector &vecValue ) +{ + if (FStrEq(szKeyName, "DamageForce")) + m_info.SetDamageForce(vecValue); + else if (FStrEq(szKeyName, "DamagePosition")) + m_info.SetDamagePosition(vecValue); + else if (FStrEq(szKeyName, "ReportedPosition")) + m_info.SetReportedPosition(vecValue); + else + return CBaseEntity::KeyValue( szKeyName, vecValue ); + + return true; +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : +// Output : +//----------------------------------------------------------------------------- +bool CPointDamageInfo::GetKeyValue( const char *szKeyName, char *szValue, int iMaxLen ) +{ + /* + if (FStrEq(szKeyName, "Inflictor")) + Q_snprintf(szValue, iMaxLen, "%s", m_info.GetInflictor() ? "" : m_info.GetInflictor()->GetDebugName()); + else if (FStrEq(szKeyName, "Attacker")) + Q_snprintf(szValue, iMaxLen, "%s", m_info.GetAttacker() ? "" : m_info.GetAttacker()->GetDebugName()); + else if (FStrEq(szKeyName, "Weapon")) + Q_snprintf(szValue, iMaxLen, "%s", m_info.GetWeapon() ? "" : m_info.GetWeapon()->GetDebugName()); + + else*/ if (FStrEq(szKeyName, "Damage")) + Q_snprintf(szValue, iMaxLen, "%f", m_info.GetDamage()); + else if (FStrEq(szKeyName, "MaxDamage")) + Q_snprintf(szValue, iMaxLen, "%f", m_info.GetMaxDamage()); + //else if (FStrEq(szKeyName, "DamageBonus")) + // Q_snprintf(szValue, iMaxLen, "%f", m_info.GetDamageBonus()); + + else if (FStrEq(szKeyName, "DamageType")) + Q_snprintf(szValue, iMaxLen, "%i", m_info.GetDamageType()); + else if (FStrEq(szKeyName, "DamageCustom")) + Q_snprintf(szValue, iMaxLen, "%i", m_info.GetDamageCustom()); + //else if (FStrEq(szKeyName, "DamageStats")) + // Q_snprintf(szValue, iMaxLen, "%i", m_info.GetDamageStats()); + else if (FStrEq(szKeyName, "ForceFriendlyFire")) + Q_snprintf(szValue, iMaxLen, "%s", m_info.IsForceFriendlyFire() ? "1" : "0"); + + else if (FStrEq(szKeyName, "AmmoType")) + Q_snprintf(szValue, iMaxLen, "%i", m_info.GetAmmoType()); + + /* + else if (FStrEq(szKeyName, "PlayerPenetrationCount")) + Q_snprintf(szValue, iMaxLen, "%i", m_info.GetPlayerPenetrationCount()); + else if (FStrEq(szKeyName, "DamagedOtherPlayers")) + Q_snprintf(szValue, iMaxLen, "%i", m_info.GetDamagedOtherPlayers()); + */ + + else if (FStrEq(szKeyName, "DamageForce")) + Q_snprintf(szValue, iMaxLen, "%f %f %f", m_info.GetDamageForce().x, m_info.GetDamageForce().y, m_info.GetDamageForce().z); + else if (FStrEq(szKeyName, "DamagePosition")) + Q_snprintf(szValue, iMaxLen, "%f %f %f", m_info.GetDamagePosition().x, m_info.GetDamagePosition().y, m_info.GetDamagePosition().z); + else if (FStrEq(szKeyName, "ReportedPosition")) + Q_snprintf(szValue, iMaxLen, "%f %f %f", m_info.GetReportedPosition().x, m_info.GetReportedPosition().y, m_info.GetReportedPosition().z); + else + return BaseClass::GetKeyValue(szKeyName, szValue, iMaxLen); + + return true; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointDamageInfo::HandleDamage( CBaseEntity *pTarget ) +{ + pTarget->TakeDamage(m_info); + m_OnApplyDamage.FireOutput(pTarget, this); + if (pTarget->m_lifeState == LIFE_DYING) + m_OnApplyDeath.FireOutput(pTarget, this); + + // This is the best we could do, as nodeathsound is exclusive to response system NPCs + if (m_bSuppressDeathSound) + pTarget->EmitSound("AI_BaseNPC.SentenceStop"); +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : +// Output : +//----------------------------------------------------------------------------- +void CPointDamageInfo::ApplyDamage( const char *target, inputdata_t &inputdata ) +{ + if (m_iszAttacker != NULL_STRING) + m_info.SetAttacker( gEntList.FindEntityByName(NULL, STRING(m_iszAttacker), this, inputdata.pActivator, inputdata.pCaller) ); + else + m_info.SetAttacker( this ); + + if (m_iszInflictor != NULL_STRING) + m_info.SetInflictor( gEntList.FindEntityByName(NULL, STRING(m_iszInflictor), this, inputdata.pActivator, inputdata.pCaller) ); + else + { + CBaseCombatCharacter *pBCC = ToBaseCombatCharacter(m_info.GetAttacker()); + if (pBCC != NULL && pBCC->GetActiveWeapon()) + { + m_info.SetInflictor(pBCC->GetActiveWeapon()); + } + else + m_info.SetInflictor(this); + } + + if (m_iszWeapon != NULL_STRING) + m_info.SetWeapon( gEntList.FindEntityByName(NULL, STRING(m_iszWeapon), this, inputdata.pActivator, inputdata.pCaller) ); + else + { + CBaseCombatCharacter *pBCC = ToBaseCombatCharacter(m_info.GetAttacker()); + if (pBCC != NULL && pBCC->GetActiveWeapon()) + { + m_info.SetWeapon(pBCC->GetActiveWeapon()); + } + else + m_info.SetWeapon(this); + } + + CBaseEntity *pTarget = NULL; + if (m_iMaxEnts > 0) + { + for (int i = 0; i < m_iMaxEnts; i++) + { + pTarget = gEntList.FindEntityGeneric(pTarget, target, this, inputdata.pActivator, inputdata.pCaller); + if (pTarget) + { + pTarget->TakeDamage(m_info); + m_OnApplyDamage.FireOutput(pTarget, this); + if (pTarget->m_lifeState == LIFE_DYING) + m_OnApplyDeath.FireOutput(pTarget, this); + } + } + } + else + { + pTarget = gEntList.FindEntityGeneric(NULL, target, this, inputdata.pActivator, inputdata.pCaller); + while (pTarget) + { + pTarget->TakeDamage(m_info); + m_OnApplyDamage.FireOutput(pTarget, this); + if (pTarget->m_lifeState == LIFE_DYING) + m_OnApplyDeath.FireOutput(pTarget, this); + pTarget = gEntList.FindEntityGeneric(pTarget, target, this, inputdata.pActivator, inputdata.pCaller); + } + } +} + +//----------------------------------------------------------------------------- +// Purpose: Applies damage to a specific entity +// Input : +// Output : +//----------------------------------------------------------------------------- +void CPointDamageInfo::ApplyDamage( CBaseEntity *target, inputdata_t &inputdata ) +{ + if (!target) + return; + + if (m_iszAttacker != NULL_STRING) + m_info.SetAttacker( gEntList.FindEntityByName(NULL, STRING(m_iszAttacker), this, inputdata.pActivator, inputdata.pCaller) ); + else + m_info.SetAttacker( this ); + + if (m_iszInflictor != NULL_STRING) + m_info.SetInflictor( gEntList.FindEntityByName(NULL, STRING(m_iszInflictor), this, inputdata.pActivator, inputdata.pCaller) ); + else + { + CBaseCombatCharacter *pBCC = ToBaseCombatCharacter(m_info.GetAttacker()); + if (pBCC != NULL && pBCC->GetActiveWeapon()) + { + m_info.SetInflictor(pBCC->GetActiveWeapon()); + } + else + m_info.SetInflictor(this); + } + + if (m_iszWeapon != NULL_STRING) + m_info.SetWeapon( gEntList.FindEntityByName(NULL, STRING(m_iszWeapon), this, inputdata.pActivator, inputdata.pCaller) ); + else + { + CBaseCombatCharacter *pBCC = ToBaseCombatCharacter(m_info.GetAttacker()); + if (pBCC != NULL && pBCC->GetActiveWeapon()) + { + m_info.SetWeapon(pBCC->GetActiveWeapon()); + } + else + m_info.SetWeapon(this); + } + + target->TakeDamage(m_info); + m_OnApplyDamage.FireOutput(target, this); +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : +// Output : +//----------------------------------------------------------------------------- +void CPointDamageInfo::InputApplyDamage( inputdata_t &inputdata ) +{ + ApplyDamage(STRING(m_target), inputdata); +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : +// Output : +//----------------------------------------------------------------------------- +void CPointDamageInfo::InputApplyDamageToEntity( inputdata_t &inputdata ) +{ + ApplyDamage(inputdata.value.Entity(), inputdata); +} diff --git a/sp/src/game/server/mapbase/point_entity_replace.cpp b/sp/src/game/server/mapbase/point_entity_replace.cpp new file mode 100644 index 00000000..3452c11f --- /dev/null +++ b/sp/src/game/server/mapbase/point_entity_replace.cpp @@ -0,0 +1,473 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Replaces a thing with another thing. +// +//============================================================================= + +#include "cbase.h" +#include "TemplateEntities.h" +#include "point_template.h" +#include "saverestore_utlvector.h" +#include "datadesc_mod.h" + + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +class CPointEntityReplace : public CLogicalEntity +{ + DECLARE_CLASS( CPointEntityReplace, CLogicalEntity ); + DECLARE_DATADESC(); + +public: + + // The entity that will replace the target. + string_t m_iszReplacementEntity; + + // Only used with certain replacement types + EHANDLE m_hReplacementEntity; + + // How we should get the replacement entity. + int m_iReplacementType; + enum + { + REPLACEMENTTYPE_TARGET_TELEPORT, // Replace with target entity + REPLACEMENTTYPE_CLASSNAME, // Replace with entity of specified classname + REPLACEMENTTYPE_TEMPLATE, // Replace with a point_template's contents + REPLACEMENTTYPE_TEMPLATE_RELATIVE, // Replace with a point_template's contents, maintaining relative position + }; + + // Where the replacement entit(ies) should replace at. + int m_iReplacementLocation; + enum + { + REPLACEMENTLOC_ABSOLUTEORIGIN, + REPLACEMENTLOC_WORLDSPACECENTER, + }; + + // Do we actually replace the target entity or just function as a glorified point_teleport? + bool m_bRemoveOriginalEntity; + + // What stuff we should take. + int m_iTakeStuff; + enum + { + REPLACEMENTTAKE_NAME = (1 << 0), // Takes the target's name + REPLACEMENTTAKE_PARENT = (1 << 1), // Takes parent and transfers children + REPLACEMENTTAKE_OWNER = (1 << 2), // Takes owner entity + REPLACEMENTTAKE_MODELSTUFF = (1 << 3), // Takes model stuff + }; + + // Used to cause it to take other fields, most of that has been moved to m_bTakeModelStuff and m_iszOtherTakes + //bool m_bTakeStuff; + + // Other keyvalues to copy. + CUtlVector m_iszOtherTakes; + + // Fire OnReplace with the original entity as the caller. + bool m_bFireOriginalEntityAsCaller; + + bool KeyValue(const char *szKeyName, const char *szValue); + + void HandleReplacement(CBaseEntity *pEntity, CBaseEntity *pReplacement); + + CBaseEntity *GetReplacementEntity(inputdata_t *inputdata); + + void ReplaceEntity(CBaseEntity *pEntity, inputdata_t &inputdata); + + // Inputs + void InputReplace( inputdata_t &inputdata ); + void InputReplaceEntity( inputdata_t &inputdata ); + + void InputSetReplacementEntity( inputdata_t &inputdata ); + + COutputEHANDLE m_OnReplace; // Passes the entity we replaced the target with, fired multiple times if REPLACEMENTTYPE_TEMPLATE created multiple entities +}; + +LINK_ENTITY_TO_CLASS(point_entity_replace, CPointEntityReplace); + +BEGIN_DATADESC( CPointEntityReplace ) + + // Keys + DEFINE_KEYFIELD( m_iszReplacementEntity, FIELD_STRING, "ReplacementEntity" ), + DEFINE_FIELD( m_hReplacementEntity, FIELD_EHANDLE ), + DEFINE_KEYFIELD( m_iReplacementType, FIELD_INTEGER, "ReplacementType" ), + DEFINE_KEYFIELD( m_iReplacementLocation, FIELD_INTEGER, "ReplacementLocation" ), + DEFINE_KEYFIELD( m_bRemoveOriginalEntity, FIELD_BOOLEAN, "RemoveOriginalEntity" ), + DEFINE_FIELD( m_iTakeStuff, FIELD_INTEGER ), + DEFINE_UTLVECTOR( m_iszOtherTakes, FIELD_STRING ), + DEFINE_KEYFIELD( m_bFireOriginalEntityAsCaller, FIELD_BOOLEAN, "TargetIsCaller" ), + + // Inputs + DEFINE_INPUTFUNC( FIELD_VOID, "Replace", InputReplace ), + DEFINE_INPUTFUNC( FIELD_EHANDLE, "ReplaceEntity", InputReplaceEntity ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetReplacementEntity", InputSetReplacementEntity ), + + // Outputs + DEFINE_OUTPUT(m_OnReplace, "OnReplace"), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: Handles key values from the BSP before spawn is called. +//----------------------------------------------------------------------------- +bool CPointEntityReplace::KeyValue( const char *szKeyName, const char *szValue ) +{ + if (!stricmp(szKeyName, "OtherStuff")) + { + if (szValue && szValue[0] != '\0') + { + CUtlStringList vecKeyList; + Q_SplitString(szValue, ",", vecKeyList); + FOR_EACH_VEC(vecKeyList, i) + { + m_iszOtherTakes.AddToTail(AllocPooledString(vecKeyList[i])); + } + } + return true; + } + else if (strnicmp(szKeyName, "Take", 4) == 0) + { + const char *subject = (szKeyName + 4); + int flag = 0; + if (FStrEq(subject, "Targetname")) + flag |= REPLACEMENTTAKE_NAME; + else if (FStrEq(subject, "Parent")) + flag |= REPLACEMENTTAKE_PARENT; + else if (FStrEq(subject, "Owner")) + flag |= REPLACEMENTTAKE_OWNER; + else if (FStrEq(subject, "ModelStuff")) + flag |= REPLACEMENTTAKE_MODELSTUFF; + else + return BaseClass::KeyValue(szKeyName, szValue); + + // Remove the flag if 0, add the flag if not 0 + !FStrEq(szValue, "0") ? (m_iTakeStuff |= flag) : (m_iTakeStuff &= ~flag); + + return true; + } + + return BaseClass::KeyValue(szKeyName, szValue); +} + +//----------------------------------------------------------------------------- +// Purpose: Takes targetname, fields, etc. Keep in mind neither are checked for null! +//----------------------------------------------------------------------------- +void CPointEntityReplace::HandleReplacement(CBaseEntity *pEntity, CBaseEntity *pReplacement) +{ + if (m_iTakeStuff & REPLACEMENTTAKE_NAME) + pReplacement->SetName(pEntity->GetEntityName()); + + if (m_iTakeStuff & REPLACEMENTTAKE_PARENT) + { + if (pEntity->GetParent()) + pReplacement->SetParent(pEntity->GetParent(), pEntity->GetParentAttachment()); + + TransferChildren(pEntity, pReplacement); + } + + if (m_iTakeStuff & REPLACEMENTTAKE_OWNER) + { + if (pEntity->GetOwnerEntity()) + pReplacement->SetOwnerEntity(pEntity->GetOwnerEntity()); + } + + if (m_iTakeStuff & REPLACEMENTTAKE_MODELSTUFF) + { + pReplacement->m_nRenderMode = pEntity->m_nRenderMode; + pReplacement->m_nRenderFX = pEntity->m_nRenderFX; + const color32 rclr = pEntity->GetRenderColor(); + pReplacement->SetRenderColor(rclr.r, rclr.g, rclr.b, rclr.a); + if (pEntity->GetBaseAnimating() && pReplacement->GetBaseAnimating()) + { + CBaseAnimating *pEntityAnimating = pEntity->GetBaseAnimating(); + CBaseAnimating *pReplacementAnimating = pReplacement->GetBaseAnimating(); + + pReplacementAnimating->CopyAnimationDataFrom(pEntityAnimating); + + //pReplacementAnimating->SetCycle(pEntityAnimating->GetCycle()); + //pReplacementAnimating->IncrementInterpolationFrame(); + //pReplacementAnimating->SetSequence(pEntityAnimating->GetSequence()); + //pReplacementAnimating->m_flAnimTime = pEntityAnimating->m_flAnimTime; + //pReplacementAnimating->m_nBody = pEntityAnimating->m_nBody; + //pReplacementAnimating->m_nSkin = pEntityAnimating->m_nSkin; + if (pEntityAnimating->GetModelScale() != pReplacementAnimating->GetModelScale()) + pReplacementAnimating->SetModelScale(pEntityAnimating->GetModelScale()); + + for ( int iPose = 0; iPose < MAXSTUDIOPOSEPARAM; ++iPose ) + { + pReplacementAnimating->SetPoseParameter( iPose, pEntityAnimating->GetPoseParameter( iPose ) ); + } + } + } + + if (m_iszOtherTakes.Count() > 0) + { + CUtlVector szValues; + szValues.AddMultipleToTail( m_iszOtherTakes.Count() ); + + for ( datamap_t *dmap = pEntity->GetDataDescMap(); dmap != NULL; dmap = dmap->baseMap ) + { + // search through all the readable fields in the data description, looking for a match + for ( int i = 0; i < dmap->dataNumFields; i++ ) + { + if ( dmap->dataDesc[i].flags & (FTYPEDESC_SAVE | FTYPEDESC_KEY) && dmap->dataDesc[i].fieldName ) + { + DevMsg("Target Field Name: %s,\n", dmap->dataDesc[i].fieldName); + for (int i2 = 0; i2 < m_iszOtherTakes.Count(); i2++) + { + if ( FStrEq(dmap->dataDesc[i].fieldName, STRING(m_iszOtherTakes[i2])) ) + { + //szValues[i2] = (((char *)pEntity) + dmap->dataDesc[i].fieldOffset[ TD_OFFSET_NORMAL ]); + szValues[i2].Set( dmap->dataDesc[i].fieldType, ((char*)pEntity) + dmap->dataDesc[i].fieldOffset[TD_OFFSET_NORMAL] ); + break; + } + } + } + } + } + + for ( datamap_t *dmap = pReplacement->GetDataDescMap(); dmap != NULL; dmap = dmap->baseMap ) + { + // search through all the readable fields in the data description, looking for a match + for ( int i = 0; i < dmap->dataNumFields; i++ ) + { + if ( dmap->dataDesc[i].flags & (FTYPEDESC_SAVE | FTYPEDESC_KEY) && dmap->dataDesc[i].fieldName ) + { + DevMsg("Replacement Field Name: %s,\n", dmap->dataDesc[i].fieldName); + for (int i2 = 0; i2 < m_iszOtherTakes.Count(); i2++) + { + if ( FStrEq(dmap->dataDesc[i].fieldName, STRING(m_iszOtherTakes[i2])) ) + { + //(void*)(((char *)pReplacement) + dmap->dataDesc[i].fieldOffset[ TD_OFFSET_NORMAL ]) = szValues[i2]; + + //char *data = (((char *)pReplacement) + dmap->dataDesc[i].fieldOffset[TD_OFFSET_NORMAL]); + //memcpy(data, szValues[i2], sizeof(*data)); + + //Datadesc_SetFieldString( szValues[i2], pReplacement, &dmap->dataDesc[i] ); + + szValues[i2].SetOther( (((char *)pReplacement) + dmap->dataDesc[i].fieldOffset[TD_OFFSET_NORMAL]) ); + break; + } + } + } + } + } + } + + /* + // This is largely duplicated from phys_convert + if (m_bTakeStuff) + { + pReplacement->m_nRenderMode = pEntity->m_nRenderMode; + pReplacement->m_nRenderFX = pEntity->m_nRenderFX; + const color32 rclr = pEntity->GetRenderColor(); + pReplacement->SetRenderColor(rclr.r, rclr.g, rclr.b, rclr.a); + if (pEntity->GetBaseAnimating() && pReplacement->GetBaseAnimating()) + { + CBaseAnimating *pEntityAnimating = pEntity->GetBaseAnimating(); + CBaseAnimating *pReplacementAnimating = pReplacement->GetBaseAnimating(); + + pReplacementAnimating->CopyAnimationDataFrom(pEntityAnimating); + + //pReplacementAnimating->SetCycle(pEntityAnimating->GetCycle()); + //pReplacementAnimating->IncrementInterpolationFrame(); + //pReplacementAnimating->SetSequence(pEntityAnimating->GetSequence()); + //pReplacementAnimating->m_flAnimTime = pEntityAnimating->m_flAnimTime; + //pReplacementAnimating->m_nBody = pEntityAnimating->m_nBody; + //pReplacementAnimating->m_nSkin = pEntityAnimating->m_nSkin; + //pReplacementAnimating->SetModelScale(pEntityAnimating->GetModelScale()); + } + + UTIL_TransferPoseParameters(pEntity, pReplacement); + TransferChildren(pEntity, pReplacement); + } + */ +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +inline CBaseEntity *CPointEntityReplace::GetReplacementEntity(inputdata_t *inputdata) +{ + if (!m_hReplacementEntity) + m_hReplacementEntity.Set(gEntList.FindEntityByName(NULL, STRING(m_iszReplacementEntity), this, inputdata ? inputdata->pActivator : NULL, inputdata ? inputdata->pCaller : NULL)); + return m_hReplacementEntity; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointEntityReplace::ReplaceEntity(CBaseEntity *pEntity, inputdata_t &inputdata) +{ + Vector vecOrigin; + if (m_iReplacementLocation == REPLACEMENTLOC_WORLDSPACECENTER) + vecOrigin = pEntity->WorldSpaceCenter(); + else + vecOrigin = pEntity->GetAbsOrigin(); + + QAngle angAngles = pEntity->GetAbsAngles(); + Vector vecVelocity; + QAngle angVelocity; + if (pEntity->VPhysicsGetObject()) + { + AngularImpulse angImpulse; + pEntity->VPhysicsGetObject()->GetVelocity(&vecVelocity, &angImpulse); + AngularImpulseToQAngle(angImpulse, angVelocity); + } + else + { + vecVelocity = pEntity->GetAbsVelocity(); + angVelocity = pEntity->GetLocalAngularVelocity(); + } + + // No conflicts with the replacement entity until we're finished + if (m_bRemoveOriginalEntity && !(m_iTakeStuff & REPLACEMENTTAKE_MODELSTUFF)) + { + pEntity->AddSolidFlags( FSOLID_NOT_SOLID ); + pEntity->AddEffects( EF_NODRAW ); + } + + CBaseEntity *pCaller = m_bFireOriginalEntityAsCaller ? pEntity : this; + + switch (m_iReplacementType) + { + case REPLACEMENTTYPE_TARGET_TELEPORT: + { + CBaseEntity *pReplacementEntity = GetReplacementEntity(&inputdata); + if (pReplacementEntity) + { + HandleReplacement(pEntity, pReplacementEntity); + pReplacementEntity->Teleport(&vecOrigin, &angAngles, &vecVelocity); + + if (pReplacementEntity->VPhysicsGetObject()) + { + AngularImpulse angImpulse; + QAngleToAngularImpulse(angAngles, angImpulse); + pReplacementEntity->VPhysicsGetObject()->SetVelocityInstantaneous(&vecVelocity, &angImpulse); + } + else + { + pReplacementEntity->SetAbsVelocity(vecVelocity); + pReplacementEntity->SetBaseVelocity( vec3_origin ); + pReplacementEntity->SetLocalAngularVelocity(angVelocity); + } + + m_OnReplace.Set(pReplacementEntity, pReplacementEntity, pCaller); + } + } break; + case REPLACEMENTTYPE_CLASSNAME: + { + CBaseEntity *pReplacementEntity = CreateNoSpawn(STRING(m_iszReplacementEntity), vecOrigin, angAngles); + if (pReplacementEntity) + { + HandleReplacement(pEntity, pReplacementEntity); + + DispatchSpawn(pReplacementEntity); + + if (pReplacementEntity->VPhysicsGetObject()) + { + IPhysicsObject *pPhys = pReplacementEntity->VPhysicsGetObject(); + AngularImpulse angImpulse; + QAngleToAngularImpulse(angAngles, angImpulse); + pPhys->SetVelocityInstantaneous(&vecVelocity, &angImpulse); + } + else + { + pReplacementEntity->SetAbsVelocity(vecVelocity); + pReplacementEntity->SetBaseVelocity( vec3_origin ); + pReplacementEntity->SetLocalAngularVelocity(angVelocity); + } + + m_OnReplace.Set(pReplacementEntity, pReplacementEntity, pCaller); + } + } break; + case REPLACEMENTTYPE_TEMPLATE: + case REPLACEMENTTYPE_TEMPLATE_RELATIVE: + { + CPointTemplate *pTemplate = dynamic_cast(GetReplacementEntity(&inputdata)); + if (!pTemplate) + { + Warning("%s unable to retrieve entity %s. It either does not exist or is not a point_template.\n", GetDebugName(), STRING(m_iszReplacementEntity)); + return; + } + + CUtlVector hNewEntities; + if ( !pTemplate->CreateInstance( vecOrigin, angAngles, &hNewEntities ) || hNewEntities.Count() == 0 ) + return; + + CBaseEntity *pTemplateEntity = NULL; + for (int i = 0; i < hNewEntities.Count(); i++) + { + pTemplateEntity = hNewEntities[i]; + if (pTemplateEntity) + { + HandleReplacement(pEntity, pTemplateEntity); + + if (m_iReplacementType != REPLACEMENTTYPE_TEMPLATE_RELATIVE) + { + // We have to do this again. + //pTemplateEntity->SetAbsOrigin( vecOrigin ); + //pTemplateEntity->SetAbsAngles( angAngles ); + pTemplateEntity->Teleport( &vecOrigin, &angAngles, &vecVelocity ); + } + + if (pTemplateEntity->VPhysicsGetObject()) + { + AngularImpulse angImpulse; + QAngleToAngularImpulse(angAngles, angImpulse); + pTemplateEntity->VPhysicsGetObject()->SetVelocityInstantaneous(&vecVelocity, &angImpulse); + } + else + { + pTemplateEntity->SetAbsVelocity(vecVelocity); + pTemplateEntity->SetBaseVelocity( vec3_origin ); + pTemplateEntity->SetLocalAngularVelocity(angVelocity); + } + + m_OnReplace.Set(pTemplateEntity, pTemplateEntity, pCaller); + } + } + + // Templates with only one entity probably need to stay in the specified position. + if (hNewEntities.Count() == 1) + { + hNewEntities[0]->SetAbsOrigin( vecOrigin ); + hNewEntities[0]->SetAbsAngles( angAngles ); + } + } break; + } + + if (m_bRemoveOriginalEntity) + UTIL_Remove(pEntity); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointEntityReplace::InputReplace( inputdata_t &inputdata ) +{ + CBaseEntity *pEntity = gEntList.FindEntityByName(NULL, STRING(m_target), this, inputdata.pActivator, inputdata.pCaller); + if (pEntity) + ReplaceEntity(pEntity, inputdata); + else + Warning("%s unable to find replacement target %s.\n", GetDebugName(), STRING(m_target)); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointEntityReplace::InputReplaceEntity( inputdata_t &inputdata ) +{ + if (inputdata.value.Entity()) + ReplaceEntity(inputdata.value.Entity(), inputdata); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointEntityReplace::InputSetReplacementEntity( inputdata_t &inputdata ) +{ + m_iszReplacementEntity = inputdata.value.StringID(); + m_hReplacementEntity = NULL; +} diff --git a/sp/src/game/server/mapbase/point_projectile.cpp b/sp/src/game/server/mapbase/point_projectile.cpp new file mode 100644 index 00000000..9a32176d --- /dev/null +++ b/sp/src/game/server/mapbase/point_projectile.cpp @@ -0,0 +1,197 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Fires projectiles. What else is there to say? +// +//============================================================================= + +#include "cbase.h" + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +class CPointProjectile : public CBaseEntity +{ + DECLARE_CLASS( CPointProjectile, CBaseEntity ); + DECLARE_DATADESC(); + +public: + + void Precache(); + void Spawn(); + + // m_target is projectile class + + // Owner + // Handle is m_hOwnerEntity + string_t m_iszOwner; + + // Damage + float m_flDamage; + + // Speed + float m_flSpeed; + + bool m_bFireProjectilesFromOwner; + + CBaseEntity *CalculateOwner( CBaseEntity *pActivator, CBaseEntity *pCaller ); + + CBaseEntity *CreateProjectile( Vector &vecOrigin, QAngle &angAngles, Vector &vecDir, CBaseEntity *pOwner ); + + // Inputs + void InputFire( inputdata_t &inputdata ); + void InputFireAtEntity( inputdata_t &inputdata ); + void InputFireAtPosition( inputdata_t &inputdata ); + + void InputSetDamage( inputdata_t &inputdata ) { m_flDamage = inputdata.value.Float(); } + void InputSetOwner( inputdata_t &inputdata ) { m_iszOwner = inputdata.value.StringID(); SetOwnerEntity(NULL); } + void InputSetSpeed( inputdata_t &inputdata ) { m_flSpeed = inputdata.value.Float(); } + + void InputSetTarget( inputdata_t &inputdata ) { BaseClass::InputSetTarget(inputdata); UTIL_PrecacheOther(inputdata.value.String()); } + + COutputEHANDLE m_OnFire; +}; + +LINK_ENTITY_TO_CLASS(point_projectile, CPointProjectile); + +BEGIN_DATADESC( CPointProjectile ) + + // Keys + DEFINE_KEYFIELD( m_iszOwner, FIELD_STRING, "Owner" ), + DEFINE_KEYFIELD( m_flDamage, FIELD_FLOAT, "Damage" ), + DEFINE_KEYFIELD( m_flSpeed, FIELD_FLOAT, "Speed" ), + DEFINE_KEYFIELD( m_bFireProjectilesFromOwner, FIELD_BOOLEAN, "FireFromOwner" ), + + // Inputs + DEFINE_INPUTFUNC( FIELD_VOID, "Fire", InputFire ), + DEFINE_INPUTFUNC( FIELD_EHANDLE, "FireAtEntity", InputFireAtEntity ), + DEFINE_INPUTFUNC( FIELD_VECTOR, "FireAtPosition", InputFireAtPosition ), + + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetDamage", InputSetDamage ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetOwnerEntity", InputSetOwner ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetSpeed", InputSetSpeed ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetProjectileClass", InputSetTarget ), + + // Outputs + DEFINE_OUTPUT(m_OnFire, "OnFire"), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointProjectile::Precache() +{ + UTIL_PrecacheOther(STRING(m_target)); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointProjectile::Spawn() +{ + Precache(); + + BaseClass::Spawn(); +} + +//----------------------------------------------------------------------------- +// Purpose: Calculates owner entity +//----------------------------------------------------------------------------- +inline CBaseEntity *CPointProjectile::CalculateOwner( CBaseEntity *pActivator, CBaseEntity *pCaller ) +{ + if (m_iszOwner != NULL_STRING && !GetOwnerEntity()) + { + CBaseEntity *pOwner = gEntList.FindEntityByName(NULL, STRING(m_iszOwner), this, pActivator, pCaller); + if (pOwner) + SetOwnerEntity(pOwner); + } + + return GetOwnerEntity() ? GetOwnerEntity() : this; +} + +//----------------------------------------------------------------------------- +// Purpose: Fires projectile and output +//----------------------------------------------------------------------------- +inline CBaseEntity *CPointProjectile::CreateProjectile( Vector &vecOrigin, QAngle &angAngles, Vector &vecDir, CBaseEntity *pOwner ) +{ + CBaseEntity *pProjectile = CreateNoSpawn(STRING(m_target), vecOrigin, angAngles, pOwner); + if (!pProjectile) + { + Warning("WARNING: %s unable to create projectile class %s!\n", GetDebugName(), STRING(m_target)); + return NULL; + } + + pProjectile->SetAbsVelocity(vecDir * m_flSpeed); + DispatchSpawn(pProjectile); + + pProjectile->SetDamage(m_flDamage); + + m_OnFire.Set(pProjectile, pProjectile, pOwner); + + return pProjectile; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointProjectile::InputFire( inputdata_t &inputdata ) +{ + Vector vecOrigin = GetAbsOrigin(); + QAngle angAngles = GetAbsAngles(); + + CBaseEntity *pOwner = CalculateOwner(inputdata.pActivator, inputdata.pCaller); + if (pOwner && m_bFireProjectilesFromOwner) + vecOrigin = pOwner->GetAbsOrigin(); + + Vector vecDir; + AngleVectors(angAngles, &vecDir); + + CreateProjectile(vecOrigin, angAngles, vecDir, pOwner); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointProjectile::InputFireAtEntity( inputdata_t &inputdata ) +{ + CBaseEntity *pTarget = inputdata.value.Entity(); + if (!pTarget) + return; + + Vector vecOrigin = GetAbsOrigin(); + + CBaseEntity *pOwner = CalculateOwner(inputdata.pActivator, inputdata.pCaller); + if (pOwner && m_bFireProjectilesFromOwner) + vecOrigin = pOwner->GetAbsOrigin(); + + Vector vecDir = (pTarget->WorldSpaceCenter() - vecOrigin); + VectorNormalize(vecDir); + + QAngle angAngles; + VectorAngles(vecDir, angAngles); + + CreateProjectile(vecOrigin, angAngles, vecDir, pOwner); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointProjectile::InputFireAtPosition( inputdata_t &inputdata ) +{ + Vector vecInput; + inputdata.value.Vector3D(vecInput); + + Vector vecOrigin = GetAbsOrigin(); + + CBaseEntity *pOwner = CalculateOwner(inputdata.pActivator, inputdata.pCaller); + if (pOwner && m_bFireProjectilesFromOwner) + vecOrigin = pOwner->GetAbsOrigin(); + + Vector vecDir = (vecInput - vecOrigin); + VectorNormalize(vecDir); + + QAngle angAngles; + VectorAngles(vecDir, angAngles); + + CreateProjectile(vecOrigin, angAngles, vecDir, pOwner); +} diff --git a/sp/src/game/server/mapbase/point_radiation_source.cpp b/sp/src/game/server/mapbase/point_radiation_source.cpp new file mode 100644 index 00000000..fca0f1b3 --- /dev/null +++ b/sp/src/game/server/mapbase/point_radiation_source.cpp @@ -0,0 +1,136 @@ +//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ==== +// +// An entity that triggers the player's geiger counter. +// +// Doesn't cause any actual damage. Should be parentable. +// +//============================================================================= + +#include "cbase.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + + + +class CPointRadiationSource : public CPointEntity +{ +public: + DECLARE_CLASS( CPointRadiationSource, CPointEntity ); + DECLARE_DATADESC(); + + void Spawn(); + + void RadiationThink(); + + void InputEnable( inputdata_t &inputdata ); + void InputDisable( inputdata_t &inputdata ); + + bool m_bTestPVS; + float m_flRadius; + float m_flIntensity = 1.0f; + + bool m_bDisabled; +}; + +BEGIN_DATADESC( CPointRadiationSource ) + + // Function Pointers + DEFINE_FUNCTION( RadiationThink ), + + // Fields + DEFINE_KEYFIELD( m_bTestPVS, FIELD_BOOLEAN, "TestPVS" ), + DEFINE_INPUT( m_flRadius, FIELD_FLOAT, "SetRadius" ), + DEFINE_INPUT( m_flIntensity, FIELD_FLOAT, "SetIntensity" ), + DEFINE_KEYFIELD( m_bDisabled, FIELD_BOOLEAN, "StartDisabled" ), + + // Inputs + DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), + DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), + +END_DATADESC() + + +LINK_ENTITY_TO_CLASS( point_radiation_source, CPointRadiationSource ); + + +//----------------------------------------------------------------------------- +// Purpose: Called when spawning, after keyvalues have been handled. +//----------------------------------------------------------------------------- +void CPointRadiationSource::Spawn( void ) +{ + BaseClass::Spawn(); + + if (!m_bDisabled) + { + SetThink( &CPointRadiationSource::RadiationThink ); + SetNextThink( gpGlobals->curtime + random->RandomFloat(0.0, 0.5) ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointRadiationSource::InputEnable( inputdata_t &inputdata ) +{ + m_bDisabled = false; + + SetThink( &CPointRadiationSource::RadiationThink ); + SetNextThink( gpGlobals->curtime ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointRadiationSource::InputDisable( inputdata_t &inputdata ) +{ + m_bDisabled = true; + + SetThink( NULL ); + SetNextThink( TICK_NEVER_THINK ); + + // Must update player + //CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); + //if (pPlayer) + //{ + // pPlayer->NotifyNearbyRadiationSource(1000); + //} +} + +//----------------------------------------------------------------------------- +// Purpose: Trigger hurt that causes radiation will do a radius check and set +// the player's geiger counter level according to distance from center +// of trigger. +//----------------------------------------------------------------------------- +void CPointRadiationSource::RadiationThink( void ) +{ + CBasePlayer *pPlayer = NULL; + if (m_bTestPVS) + { + CBaseEntity *pPVSPlayer = CBaseEntity::Instance(UTIL_FindClientInPVS(edict())); + if (pPVSPlayer) + { + pPlayer = static_cast(pPVSPlayer); + } + } + else + { + pPlayer = UTIL_GetLocalPlayer(); + } + + if (pPlayer) + { + // get range to player; + float flRange = pPlayer->GetAbsOrigin().DistTo((GetAbsOrigin())); + if (m_flRadius <= 0 || flRange < m_flRadius) + { + Assert( m_flIntensity > 0 ); + + //flRange *= 3.0f; + flRange /= m_flIntensity; + pPlayer->NotifyNearbyRadiationSource(flRange); + } + } + + SetNextThink( gpGlobals->curtime + 0.25 ); +} diff --git a/sp/src/game/server/mapbase/variant_tools.h b/sp/src/game/server/mapbase/variant_tools.h new file mode 100644 index 00000000..358b232d --- /dev/null +++ b/sp/src/game/server/mapbase/variant_tools.h @@ -0,0 +1,43 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef VARIANT_TOOLS_H +#define VARIANT_TOOLS_H +#ifdef _WIN32 +#pragma once +#endif + +#include "cbase.h" + +// Quick way to define variants in a datadesc. +extern ISaveRestoreOps *variantFuncs; +#define DEFINE_VARIANT(name) { FIELD_CUSTOM, #name, { offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, NULL, variantFuncs, NULL } +#define DEFINE_KEYVARIANT(name,mapname) { FIELD_CUSTOM, #name, { offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE | FTYPEDESC_KEY, mapname, variantFuncs, NULL } + +// Most of these are defined in variant_t.cpp. + +// Creates a variant_t from the given string. +// It could return as a String or a Float. +variant_t Variant_Parse(const char *szValue); + +// Intended to convert FIELD_INPUT I/O parameters to other values, like integers, floats, or even entities. +// This only changes FIELD_STRING variants. Other data like FIELD_EHANDLE or FIELD_INTEGER are not affected. +variant_t Variant_ParseInput(inputdata_t inputdata); + +// A simpler version of Variant_ParseInput that does not allow FIELD_EHANDLE. +variant_t Variant_ParseString(variant_t value); + +// val1 == val2 +bool Variant_Equal(variant_t val1, variant_t val2, bool bLenAllowed = true); + +// val1 > val2 +bool Variant_Greater(variant_t val1, variant_t val2, bool bLenAllowed = true); + +// val1 >= val2 +bool Variant_GreaterOrEqual(variant_t val1, variant_t val2, bool bLenAllowed = true); + +#endif \ No newline at end of file diff --git a/sp/src/game/server/maprules.cpp b/sp/src/game/server/maprules.cpp index 64001b57..da69aab7 100644 --- a/sp/src/game/server/maprules.cpp +++ b/sp/src/game/server/maprules.cpp @@ -12,6 +12,9 @@ #include "entitylist.h" #include "ai_hull.h" #include "entityoutput.h" +#ifdef MAPBASE +#include "eventqueue.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -224,6 +227,9 @@ public: DECLARE_DATADESC(); void InputGameEnd( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputGameEndSP( inputdata_t &inputdata ); +#endif void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); private: }; @@ -232,6 +238,9 @@ BEGIN_DATADESC( CGameEnd ) // inputs DEFINE_INPUTFUNC( FIELD_VOID, "EndGame", InputGameEnd ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_STRING, "EndGameSP", InputGameEndSP ), +#endif END_DATADESC() @@ -243,6 +252,16 @@ void CGameEnd::InputGameEnd( inputdata_t &inputdata ) g_pGameRules->EndMultiplayerGame(); } +#ifdef MAPBASE +void CGameEnd::InputGameEndSP( inputdata_t &inputdata ) +{ + // Things like mapping competitions should operate with given strings for specific endings (e.g. background maps). + CBasePlayer *pPlayer = AI_GetSinglePlayer(); + if (pPlayer) + engine->ClientCommand(pPlayer->edict(), "startupmenu force"); +} +#endif + void CGameEnd::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if ( !CanFireForActivator( pActivator ) ) @@ -274,6 +293,10 @@ public: void InputDisplay( inputdata_t &inputdata ); void Display( CBaseEntity *pActivator ); +#ifdef MAPBASE + void InputSetText ( inputdata_t &inputdata ); + void SetText( const char* pszStr ); +#endif void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { @@ -307,6 +330,9 @@ BEGIN_DATADESC( CGameText ) // Inputs DEFINE_INPUTFUNC( FIELD_VOID, "Display", InputDisplay ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_STRING, "SetText", InputSetText ), +#endif END_DATADESC() @@ -332,6 +358,13 @@ bool CGameText::KeyValue( const char *szKeyName, const char *szValue ) m_textParms.b2 = color[2]; m_textParms.a2 = color[3]; } +#ifdef MAPBASE + else if (FStrEq( szKeyName, "message" )) + { + // Needed for newline support + SetText( szValue ); + } +#endif else return BaseClass::KeyValue( szKeyName, szValue ); @@ -369,6 +402,36 @@ void CGameText::Display( CBaseEntity *pActivator ) } } +#ifdef MAPBASE +void CGameText::InputSetText( inputdata_t &inputdata ) +{ + SetText( inputdata.value.String() ); +} + +void CGameText::SetText( const char* pszStr ) +{ + // Replace /n with \n + if (Q_strstr( pszStr, "/n" )) + { + CUtlStringList vecLines; + Q_SplitString( pszStr, "/n", vecLines ); + + char szMsg[256]; + Q_strncpy( szMsg, vecLines[0], sizeof( szMsg ) ); + + for (int i = 1; i < vecLines.Count(); i++) + { + Q_snprintf( szMsg, sizeof( szMsg ), "%s\n%s", szMsg, vecLines[i] ); + } + m_iszMessage = AllocPooledString( szMsg ); + } + else + { + m_iszMessage = AllocPooledString( pszStr ); + } +} +#endif + /* TODO: Replace with an entity I/O version // diff --git a/sp/src/game/server/message_entity.cpp b/sp/src/game/server/message_entity.cpp index e5bb114b..903947c1 100644 --- a/sp/src/game/server/message_entity.cpp +++ b/sp/src/game/server/message_entity.cpp @@ -17,6 +17,12 @@ #include "vstdlib/random.h" #include "engine/IEngineSound.h" #include "game.h" +#ifdef MAPBASE +#include +#include +#include "utlbuffer.h" +#include "saverestore_utlvector.h" +#endif #include "player.h" #include "entitylist.h" @@ -38,12 +44,18 @@ public: void Spawn( void ); void Activate( void ); void Think( void ); +#ifdef MAPBASE + virtual +#endif void DrawOverlays(void); virtual void UpdateOnRemove(); void InputEnable( inputdata_t &inputdata ); void InputDisable( inputdata_t &inputdata ); +#ifdef MAPBASE + virtual void InputSetMessage( inputdata_t &inputdata ); +#endif DECLARE_DATADESC(); @@ -68,6 +80,9 @@ BEGIN_DATADESC( CMessageEntity ) // Inputs DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_STRING, "SetMessage", InputSetMessage ), +#endif END_DATADESC() @@ -172,6 +187,19 @@ void CMessageEntity::InputDisable( inputdata_t &inputdata ) m_bEnabled = false; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CMessageEntity::InputSetMessage( inputdata_t &inputdata ) +{ + char newmessage[256]; + Q_strncpy(newmessage, inputdata.value.String(), sizeof(newmessage)); + + m_messageText = AllocPooledString(newmessage); +} +#endif + // This is a hack to make point_message stuff appear in developer 0 release builds // for now void DrawMessageEntities() @@ -189,3 +217,124 @@ void DrawMessageEntities() me->DrawOverlays(); } } + +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +class CMessageEntityLocalized : public CMessageEntity +{ + DECLARE_CLASS( CMessageEntityLocalized, CMessageEntity ); + +public: + bool KeyValue(const char *szKeyName, const char *szValue); + void SetMessage(const char *szValue); + void DrawOverlays(void); + void InputSetMessage( inputdata_t &inputdata ); + + CUtlVector m_messageLines; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS( point_message_localized, CMessageEntityLocalized ); + +BEGIN_DATADESC( CMessageEntityLocalized ) + + DEFINE_UTLVECTOR( m_messageLines, FIELD_STRING ), + + //DEFINE_INPUTFUNC( FIELD_STRING, "SetMessage", InputSetMessage ), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: Handles key values from the BSP before spawn is called. +//----------------------------------------------------------------------------- +bool CMessageEntityLocalized::KeyValue(const char *szKeyName, const char *szValue) +{ + if (FStrEq(szKeyName, "message")) + { + SetMessage(szValue); + return true; + } + + return BaseClass::KeyValue(szKeyName, szValue); +} + +// I would use "\\n", but Hammer doesn't let you use back slashes. +#define CONVERSION_CHAR "/n" + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CMessageEntityLocalized::SetMessage(const char *szValue) +{ + // Find a localization token matching this string + wchar_t *pszMessage = g_pVGuiLocalize->Find(szValue); + + // If this is a localized string, convert it back to char. + // If it isn't, just copy it right into this. + char szBackToChar[256]; + if (pszMessage) + g_pVGuiLocalize->ConvertUnicodeToANSI(pszMessage, szBackToChar, sizeof(szBackToChar)); + else + Q_strncpy(szBackToChar, szValue, sizeof(szBackToChar)); + + // szTemp is used to turn \n from localized strings into /n. + char szTemp[256]; + if (Q_strstr(szBackToChar, "\n")) + { + char *token = strtok(szBackToChar, "\n"); + while (token) + { + Q_snprintf(szTemp, sizeof(szTemp), "%s%s%s", szTemp, token, CONVERSION_CHAR); + token = strtok(NULL, "\n"); + } + } + else + { + Q_strncpy(szTemp, szBackToChar, sizeof(szTemp)); + } + + m_messageLines.RemoveAll(); + + CUtlStringList vecLines; + Q_SplitString(szTemp, CONVERSION_CHAR, vecLines); + FOR_EACH_VEC( vecLines, i ) + { + m_messageLines.AddToTail( AllocPooledString(vecLines[i]) ); + } + + vecLines.PurgeAndDeleteElements(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CMessageEntityLocalized::InputSetMessage( inputdata_t &inputdata ) +{ + SetMessage(inputdata.value.String()); +} + +//------------------------------------------- +//------------------------------------------- +void CMessageEntityLocalized::DrawOverlays(void) +{ + if ( !m_drawText ) + return; + + if ( m_bDeveloperOnly && !g_pDeveloper->GetInt() ) + return; + + if ( !m_bEnabled ) + return; + + // display text if they are within range + int offset = 0; + FOR_EACH_VEC( m_messageLines, i ) + { + EntityText( offset, STRING(m_messageLines[i]), 0 ); + offset++; + } +} +#endif diff --git a/sp/src/game/server/npc_talker.cpp b/sp/src/game/server/npc_talker.cpp index a04c9ff3..ebb94583 100644 --- a/sp/src/game/server/npc_talker.cpp +++ b/sp/src/game/server/npc_talker.cpp @@ -373,7 +373,11 @@ void CNPCSimpleTalker::AlertFriends( CBaseEntity *pKiller ) } else { +#ifdef MAPBASE + if( IRelationType(pKiller) <= D_FR) +#else if( IRelationType(pKiller) == D_HT) +#endif { // Killed by an enemy!!! CNPCSimpleTalker *pAlly = (CNPCSimpleTalker *)pNPC; diff --git a/sp/src/game/server/npc_vehicledriver.cpp b/sp/src/game/server/npc_vehicledriver.cpp index 45da78dd..8e38d769 100644 --- a/sp/src/game/server/npc_vehicledriver.cpp +++ b/sp/src/game/server/npc_vehicledriver.cpp @@ -721,7 +721,13 @@ bool CNPC_VehicleDriver::OverridePathMove( float flInterval ) // Have we reached our target? See if we've passed the current waypoint's plane. Vector vecAbsMins, vecAbsMaxs; +#ifdef MAPBASE + vecAbsMins = m_hVehicleEntity->CollisionProp()->OBBMins(); + vecAbsMaxs = m_hVehicleEntity->CollisionProp()->OBBMaxs(); + m_hVehicleEntity->CollisionProp()->WorldSpaceAABB( &vecAbsMins, &vecAbsMaxs ); +#else CollisionProp()->WorldSpaceAABB( &vecAbsMins, &vecAbsMaxs ); +#endif if ( BoxOnPlaneSide( vecAbsMins, vecAbsMaxs, &m_pCurrentWaypoint->planeWaypoint ) == 3 ) { if ( WaypointReached() ) diff --git a/sp/src/game/server/particle_system.cpp b/sp/src/game/server/particle_system.cpp index 33fcd322..6ec0cb96 100644 --- a/sp/src/game/server/particle_system.cpp +++ b/sp/src/game/server/particle_system.cpp @@ -25,6 +25,9 @@ IMPLEMENT_SERVERCLASS_ST_NOBASE(CParticleSystem, DT_ParticleSystem) SendPropInt( SENDINFO(m_iEffectIndex), MAX_PARTICLESYSTEMS_STRING_BITS, SPROP_UNSIGNED ), SendPropBool( SENDINFO(m_bActive) ), +#ifdef MAPBASE + SendPropBool( SENDINFO(m_bDestroyImmediately) ), +#endif SendPropFloat( SENDINFO(m_flStartTime) ), SendPropArray3( SENDINFO_ARRAY3(m_hControlPointEnts), SendPropEHandle( SENDINFO_ARRAY(m_hControlPointEnts) ) ), @@ -36,6 +39,9 @@ BEGIN_DATADESC( CParticleSystem ) DEFINE_KEYFIELD( m_bStartActive, FIELD_BOOLEAN, "start_active" ), DEFINE_KEYFIELD( m_bWeatherEffect, FIELD_BOOLEAN, "flag_as_weather" ), DEFINE_FIELD( m_bActive, FIELD_BOOLEAN ), +#ifdef MAPBASE + DEFINE_FIELD( m_bDestroyImmediately, FIELD_BOOLEAN ), +#endif DEFINE_FIELD( m_flStartTime, FIELD_TIME ), DEFINE_KEYFIELD( m_iszEffectName, FIELD_STRING, "effect_name" ), //DEFINE_FIELD( m_iEffectIndex, FIELD_INTEGER ), // Don't save. Refind after loading. @@ -116,6 +122,9 @@ BEGIN_DATADESC( CParticleSystem ) DEFINE_INPUTFUNC( FIELD_VOID, "Start", InputStart ), DEFINE_INPUTFUNC( FIELD_VOID, "Stop", InputStop ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "DestroyImmediately", InputDestroyImmediately ), +#endif DEFINE_THINKFUNC( StartParticleSystemThink ), @@ -199,6 +208,9 @@ void CParticleSystem::StartParticleSystem( void ) { m_flStartTime = gpGlobals->curtime; m_bActive = true; +#ifdef MAPBASE + m_bDestroyImmediately = false; +#endif // Setup our control points at this time (in case our targets weren't around at spawn time) ReadControlPointEnts(); @@ -229,6 +241,17 @@ void CParticleSystem::InputStop( inputdata_t &inputdata ) StopParticleSystem(); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CParticleSystem::InputDestroyImmediately( inputdata_t &inputdata ) +{ + m_bDestroyImmediately = true; + StopParticleSystem(); +} +#endif + //----------------------------------------------------------------------------- // Purpose: Find each entity referred to by m_iszControlPointNames and // resolve it into the corresponding slot in m_hControlPointEnts diff --git a/sp/src/game/server/particle_system.h b/sp/src/game/server/particle_system.h index ecf758c2..6ce9a9c9 100644 --- a/sp/src/game/server/particle_system.h +++ b/sp/src/game/server/particle_system.h @@ -34,6 +34,9 @@ public: void InputStart( inputdata_t &inputdata ); void InputStop( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputDestroyImmediately( inputdata_t &inputdata ); +#endif void StartParticleSystemThink( void ); enum { kMAXCONTROLPOINTS = 63 }; ///< actually one less than the total number of cpoints since 0 is assumed to be me @@ -47,6 +50,9 @@ protected: string_t m_iszEffectName; CNetworkVar( bool, m_bActive ); +#ifdef MAPBASE + CNetworkVar( bool, m_bDestroyImmediately ); +#endif CNetworkVar( int, m_iEffectIndex ) CNetworkVar( float, m_flStartTime ); // Time at which this effect was started. This is used after restoring an active effect. diff --git a/sp/src/game/server/physics_prop_ragdoll.cpp b/sp/src/game/server/physics_prop_ragdoll.cpp index 72635ea8..21ca0012 100644 --- a/sp/src/game/server/physics_prop_ragdoll.cpp +++ b/sp/src/game/server/physics_prop_ragdoll.cpp @@ -20,10 +20,18 @@ #include "AI_Criteria.h" #include "ragdoll_shared.h" #include "hierarchy.h" +#ifdef MAPBASE +#include "decals.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" +#ifdef MAPBASE +ConVar ragdoll_autointeractions("ragdoll_autointeractions", "1", FCVAR_NONE, "Controls whether we should rely on hardcoded keyvalues or automatic flesh checks for ragdoll physgun interactions."); +#define IsBody() VPhysicsIsFlesh() +#endif + //----------------------------------------------------------------------------- // Forward declarations //----------------------------------------------------------------------------- @@ -83,9 +91,17 @@ BEGIN_DATADESC(CRagdollProp) DEFINE_KEYFIELD( m_bStartDisabled, FIELD_BOOLEAN, "StartDisabled" ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_FLOAT, "StartRagdollBoogie", InputStartRadgollBoogie ), +#else DEFINE_INPUTFUNC( FIELD_VOID, "StartRagdollBoogie", InputStartRadgollBoogie ), +#endif DEFINE_INPUTFUNC( FIELD_VOID, "EnableMotion", InputEnableMotion ), DEFINE_INPUTFUNC( FIELD_VOID, "DisableMotion", InputDisableMotion ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "Wake", InputWake ), + DEFINE_INPUTFUNC( FIELD_VOID, "Sleep", InputSleep ), +#endif DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputTurnOn ), DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputTurnOff ), DEFINE_INPUTFUNC( FIELD_FLOAT, "FadeAndRemove", InputFadeAndRemove ), @@ -359,7 +375,11 @@ void CRagdollProp::OnPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t r } m_bHasBeenPhysgunned = true; +#ifdef MAPBASE + if( (ragdoll_autointeractions.GetBool() == true && IsBody()) || HasPhysgunInteraction( "onpickup", "boogie" ) ) +#else if( HasPhysgunInteraction( "onpickup", "boogie" ) ) +#endif { if ( reason == PUNTED_BY_CANNON ) { @@ -397,7 +417,11 @@ void CRagdollProp::OnPhysGunDrop( CBasePlayer *pPhysGunUser, PhysGunDrop_t Reaso m_hPhysicsAttacker = pPhysGunUser; m_flLastPhysicsInfluenceTime = gpGlobals->curtime; +#ifdef MAPBASE + if( (ragdoll_autointeractions.GetBool() == true && IsBody()) || HasPhysgunInteraction( "onpickup", "boogie" ) ) +#else if( HasPhysgunInteraction( "onpickup", "boogie" ) ) +#endif { CRagdollBoogie::Create( this, 150, gpGlobals->curtime, 3.0f, SF_RAGDOLL_BOOGIE_ELECTRICAL ); } @@ -416,7 +440,11 @@ void CRagdollProp::OnPhysGunDrop( CBasePlayer *pPhysGunUser, PhysGunDrop_t Reaso if ( Reason != LAUNCHED_BY_CANNON ) return; +#ifdef MAPBASE + if( (ragdoll_autointeractions.GetBool() == true && IsBody()) || HasPhysgunInteraction( "onlaunch", "spin_zaxis" ) ) +#else if( HasPhysgunInteraction( "onlaunch", "spin_zaxis" ) ) +#endif { Vector vecAverageCenter( 0, 0, 0 ); @@ -615,8 +643,21 @@ void CRagdollProp::HandleFirstCollisionInteractions( int index, gamevcollisionev } } +#ifdef MAPBASE + int iVPhysicsFlesh = VPhysicsGetFlesh(); + bool bRagdollAutoInt = (ragdoll_autointeractions.GetBool() == true && iVPhysicsFlesh); + bool bAlienBloodSplat = HasPhysgunInteraction( "onfirstimpact", "alienbloodsplat" ); + if (bRagdollAutoInt && !bAlienBloodSplat) + { + // Alien blood? + bAlienBloodSplat = (iVPhysicsFlesh == CHAR_TEX_ALIENFLESH || iVPhysicsFlesh == CHAR_TEX_ANTLION); + } + + if( bRagdollAutoInt || bAlienBloodSplat || HasPhysgunInteraction( "onfirstimpact", "bloodsplat" ) ) +#else bool bAlienBloodSplat = HasPhysgunInteraction( "onfirstimpact", "alienbloodsplat" ); if( bAlienBloodSplat || HasPhysgunInteraction( "onfirstimpact", "bloodsplat" ) ) +#endif { IPhysicsObject *pObj = VPhysicsGetObject(); @@ -646,7 +687,11 @@ void CRagdollProp::ClearFlagsThink( void ) //----------------------------------------------------------------------------- AngularImpulse CRagdollProp::PhysGunLaunchAngularImpulse() { +#ifdef MAPBASE + if( (ragdoll_autointeractions.GetBool() == true && IsBody()) || HasPhysgunInteraction( "onlaunch", "spin_zaxis" ) ) +#else if( HasPhysgunInteraction( "onlaunch", "spin_zaxis" ) ) +#endif { // Don't add in random angular impulse if this object is supposed to spin in a specific way. AngularImpulse ang( 0, 0, 0 ); @@ -1069,6 +1114,23 @@ int CRagdollProp::VPhysicsGetObjectList( IPhysicsObject **pList, int listMax ) return m_ragdoll.listCount; } +#ifdef MAPBASE +int CRagdollProp::VPhysicsGetFlesh() +{ + IPhysicsObject *pList[VPHYSICS_MAX_OBJECT_LIST_COUNT]; + int count = VPhysicsGetObjectList( pList, ARRAYSIZE(pList) ); + for ( int i = 0; i < count; i++ ) + { + int material = pList[i]->GetMaterialIndex(); + const surfacedata_t *pSurfaceData = physprops->GetSurfaceData( material ); + // Is flesh ?, don't allow pickup + if ( pSurfaceData->game.material == CHAR_TEX_ANTLION || pSurfaceData->game.material == CHAR_TEX_FLESH || pSurfaceData->game.material == CHAR_TEX_BLOODYFLESH || pSurfaceData->game.material == CHAR_TEX_ALIENFLESH ) + return pSurfaceData->game.material; + } + return 0; +} +#endif + void CRagdollProp::UpdateNetworkDataFromVPhysics( IPhysicsObject *pPhysics, int index ) { Assert(index < m_ragdoll.listCount); @@ -1441,6 +1503,12 @@ CBaseEntity *CreateServerRagdoll( CBaseAnimating *pAnimating, int forceBone, con maxs = pAnimating->CollisionProp()->OBBMaxs(); pRagdoll->CollisionProp()->SetCollisionBounds( mins, maxs ); +#ifdef MAPBASE + variant_t variant; + variant.SetEntity(pRagdoll); + pAnimating->FireNamedOutput("OnServerRagdoll", variant, pRagdoll, pAnimating); +#endif + return pRagdoll; } @@ -1683,6 +1751,38 @@ void CRagdollProp::InputDisableMotion( inputdata_t &inputdata ) DisableMotion(); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Input handler to start the physics prop simulating. +//----------------------------------------------------------------------------- +void CRagdollProp::InputWake( inputdata_t &inputdata ) +{ + for ( int iRagdoll = 0; iRagdoll < m_ragdoll.listCount; ++iRagdoll ) + { + IPhysicsObject *pPhysicsObject = m_ragdoll.list[ iRagdoll ].pObject; + if ( pPhysicsObject != NULL ) + { + pPhysicsObject->Wake(); + } + } +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler to stop the physics prop simulating. +//----------------------------------------------------------------------------- +void CRagdollProp::InputSleep( inputdata_t &inputdata ) +{ + for ( int iRagdoll = 0; iRagdoll < m_ragdoll.listCount; ++iRagdoll ) + { + IPhysicsObject *pPhysicsObject = m_ragdoll.list[ iRagdoll ].pObject; + if ( pPhysicsObject != NULL ) + { + pPhysicsObject->Sleep(); + } + } +} +#endif + void CRagdollProp::InputTurnOn( inputdata_t &inputdata ) { RemoveEffects( EF_NODRAW ); diff --git a/sp/src/game/server/physics_prop_ragdoll.h b/sp/src/game/server/physics_prop_ragdoll.h index 7c24b47e..5f33dd0c 100644 --- a/sp/src/game/server/physics_prop_ragdoll.h +++ b/sp/src/game/server/physics_prop_ragdoll.h @@ -49,6 +49,9 @@ public: virtual void SetupBones( matrix3x4_t *pBoneToWorld, int boneMask ); virtual void VPhysicsUpdate( IPhysicsObject *pPhysics ); virtual int VPhysicsGetObjectList( IPhysicsObject **pList, int listMax ); +#ifdef MAPBASE + int VPhysicsGetFlesh(); +#endif virtual int DrawDebugTextOverlays(void); @@ -101,6 +104,10 @@ public: void InputStartRadgollBoogie( inputdata_t &inputdata ); void InputEnableMotion( inputdata_t &inputdata ); void InputDisableMotion( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputWake( inputdata_t &inputdata ); + void InputSleep( inputdata_t &inputdata ); +#endif void InputTurnOn( inputdata_t &inputdata ); void InputTurnOff( inputdata_t &inputdata ); void InputFadeAndRemove( inputdata_t &inputdata ); diff --git a/sp/src/game/server/physobj.cpp b/sp/src/game/server/physobj.cpp index efaffd07..8bb78cbd 100644 --- a/sp/src/game/server/physobj.cpp +++ b/sp/src/game/server/physobj.cpp @@ -387,6 +387,9 @@ BEGIN_DATADESC( CPhysBox ) DEFINE_INPUTFUNC( FIELD_VOID, "DisableMotion", InputDisableMotion ), DEFINE_INPUTFUNC( FIELD_VOID, "ForceDrop", InputForceDrop ), DEFINE_INPUTFUNC( FIELD_VOID, "DisableFloating", InputDisableFloating ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_BOOLEAN, "SetDebris", InputSetDebris ), +#endif // Function pointers DEFINE_ENTITYFUNC( BreakTouch ), @@ -689,6 +692,25 @@ void CPhysBox::InputDisableFloating( inputdata_t &inputdata ) PhysEnableFloating( VPhysicsGetObject(), false ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Adds or removes the debris spawnflag. +//----------------------------------------------------------------------------- +void CPhysBox::InputSetDebris( inputdata_t &inputdata ) +{ + if (inputdata.value.Bool()) + { + AddSpawnFlags(SF_PHYSBOX_DEBRIS); + SetCollisionGroup(COLLISION_GROUP_DEBRIS); + } + else + { + RemoveSpawnFlags(SF_PHYSBOX_DEBRIS); + SetCollisionGroup(COLLISION_GROUP_INTERACTIVE); // Is this the default collision group? + } +} +#endif + //----------------------------------------------------------------------------- // Purpose: If we're being held by the player's hand/physgun, force it to drop us //----------------------------------------------------------------------------- @@ -871,6 +893,9 @@ BEGIN_DATADESC( CPhysExplosion ) // Inputs DEFINE_INPUTFUNC( FIELD_VOID, "Explode", InputExplode ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "ExplodeAndRemove", InputExplodeAndRemove ), +#endif // Outputs DEFINE_OUTPUT( m_OnPushedPlayer, "OnPushedPlayer" ), @@ -888,10 +913,19 @@ void CPhysExplosion::Spawn( void ) float CPhysExplosion::GetRadius( void ) { float radius = m_radius; +#ifdef MAPBASE + if ( radius == 0 ) +#else if ( radius <= 0 ) +#endif { // Use the same radius as combat radius = m_damage * 2.5; + +#ifdef MAPBASE + if (radius < 0) + radius *= -1; +#endif } return radius; @@ -924,6 +958,17 @@ void CPhysExplosion::InputExplode( inputdata_t &inputdata ) Explode( inputdata.pActivator, inputdata.pCaller ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPhysExplosion::InputExplodeAndRemove( inputdata_t &inputdata ) +{ + Explode( inputdata.pActivator, inputdata.pCaller ); + UTIL_Remove(this); +} +#endif + //----------------------------------------------------------------------------- // Purpose: @@ -936,6 +981,13 @@ void CPhysExplosion::Explode( CBaseEntity *pActivator, CBaseEntity *pCaller ) falloff = 1.0 / 2.5; +#ifdef MAPBASE + // For negative damage handling + float damage = m_damage; + if (damage < 0) + damage *= -1.0f; +#endif + // iterate on all entities in the vicinity. // I've removed the traceline heuristic from phys explosions. SO right now they will // affect entities through walls. (sjb) @@ -986,7 +1038,11 @@ void CPhysExplosion::Explode( CBaseEntity *pActivator, CBaseEntity *pCaller ) } adjustedDamage = flDist * falloff; +#ifdef MAPBASE + adjustedDamage = damage - adjustedDamage; +#else adjustedDamage = m_damage - adjustedDamage; +#endif if ( adjustedDamage < 1 ) { @@ -994,7 +1050,19 @@ void CPhysExplosion::Explode( CBaseEntity *pActivator, CBaseEntity *pCaller ) } CTakeDamageInfo info( this, this, adjustedDamage, DMG_BLAST ); +#ifdef MAPBASE + // Negative damage handling + Vector vecDir = (vecSpot - vecOrigin); + if (m_damage < 0) + { + vecDir *= -1.0f; + vecOrigin += vecDir; + NDebugOverlay::Cross3D(vecOrigin, 2.0f, 255, 255, 0, true, 1.0f); + } + CalculateExplosiveDamageForce( &info, vecDir, vecOrigin ); +#else CalculateExplosiveDamageForce( &info, (vecSpot - vecOrigin), vecOrigin ); +#endif if ( HasSpawnFlags( SF_PHYSEXPLOSION_PUSH_PLAYER ) ) { @@ -1019,7 +1087,11 @@ void CPhysExplosion::Explode( CBaseEntity *pActivator, CBaseEntity *pCaller ) pEntity->ViewPunch( vecDeltaAngles ); } +#ifdef MAPBASE + Vector vecPush = (vecPushDir*damage*flFalloff*2.0f); +#else Vector vecPush = (vecPushDir*m_damage*flFalloff*2.0f); +#endif if ( pEntity->GetFlags() & FL_BASEVELOCITY ) { vecPush = vecPush + pEntity->GetBaseVelocity(); @@ -1242,6 +1314,16 @@ public: SetMoveType( MOVETYPE_VPHYSICS ); SetSolid( SOLID_VPHYSICS ); m_takedamage = DAMAGE_EVENTS_ONLY; + +#ifdef MAPBASE + // If we don't have an owner entity, it means this wasn't spawned by a phys_convert and this is safe. + if ( !GetOwnerEntity() ) + { + VPhysicsInitNormal( SOLID_VPHYSICS, 0, HasSpawnFlags(SF_PHYSBOX_DEBRIS) ); + if ( HasSpawnFlags(SF_PHYSBOX_ASLEEP) ) + SetCollisionGroup( COLLISION_GROUP_DEBRIS ); + } +#endif } }; @@ -1258,6 +1340,16 @@ public: SetMoveType( MOVETYPE_VPHYSICS ); SetSolid( SOLID_VPHYSICS ); m_takedamage = DAMAGE_EVENTS_ONLY; + +#ifdef MAPBASE + // If we don't have an owner entity, it means this wasn't spawned by a phys_convert and this is safe. + if ( !GetOwnerEntity() ) + { + VPhysicsInitNormal( SOLID_VPHYSICS, 0, HasSpawnFlags(SF_PHYSPROP_DEBRIS) ); + if ( HasSpawnFlags(SF_PHYSPROP_START_ASLEEP) ) + SetCollisionGroup( COLLISION_GROUP_DEBRIS ); + } +#endif } int ObjectCaps() @@ -1333,6 +1425,10 @@ static CBaseEntity *CreateSimplePhysicsObject( CBaseEntity *pEntity, bool create pPhysEntity->KeyValue( "model", STRING(pEntity->GetModelName()) ); pPhysEntity->SetAbsOrigin( pEntity->GetAbsOrigin() ); pPhysEntity->SetAbsAngles( pEntity->GetAbsAngles() ); +#ifdef MAPBASE + // So the entity knows it's being spawned by a phys_convert + pPhysEntity->SetOwnerEntity( pEntity ); +#endif pPhysEntity->Spawn(); if ( !TransferPhysicsObject( pEntity, pPhysEntity, !createAsleep ) ) { @@ -1343,6 +1439,36 @@ static CBaseEntity *CreateSimplePhysicsObject( CBaseEntity *pEntity, bool create return pPhysEntity; } +#ifdef MAPBASE +// Creates func_brush and prop_physics instead, because why not? +static CBaseEntity *CreateConventionalPhysicsObject( CBaseEntity *pEntity, bool createAsleep, bool createAsDebris ) +{ + CBaseEntity *pPhysEntity = NULL; + int modelindex = pEntity->GetModelIndex(); + const model_t *model = modelinfo->GetModel( modelindex ); + if ( model && modelinfo->GetModelType(model) == mod_brush ) + { + pPhysEntity = CreateEntityByName( "func_physbox" ); + } + else + { + pPhysEntity = CreateEntityByName( "prop_physics_override" ); + } + + pPhysEntity->KeyValue( "model", STRING(pEntity->GetModelName()) ); + pPhysEntity->SetAbsOrigin( pEntity->GetAbsOrigin() ); + pPhysEntity->SetAbsAngles( pEntity->GetAbsAngles() ); + pPhysEntity->Spawn(); + if ( !TransferPhysicsObject( pEntity, pPhysEntity, !createAsleep ) ) + { + pPhysEntity->VPhysicsInitNormal( SOLID_VPHYSICS, 0, createAsleep ); + if ( createAsDebris ) + pPhysEntity->SetCollisionGroup( COLLISION_GROUP_DEBRIS ); + } + return pPhysEntity; +} +#endif + #define SF_CONVERT_ASLEEP 0x0001 #define SF_CONVERT_AS_DEBRIS 0x0002 @@ -1357,11 +1483,22 @@ public: // Input handlers void InputConvertTarget( inputdata_t &inputdata ); +#ifdef MAPBASE + enum + { + CONVERT_ENTITYTYPE_SIMPLE, // simple_physics_prop, simple_physics_brush, etc. + CONVERT_ENTITYTYPE_CONVENTIONAL, // prop_physics, func_physbox, etc. + }; +#endif + DECLARE_DATADESC(); private: string_t m_swapModel; float m_flMassOverride; +#ifdef MAPBASE + int m_iPhysicsEntityType = CONVERT_ENTITYTYPE_SIMPLE; +#endif }; LINK_ENTITY_TO_CLASS( phys_convert, CPhysConvert ); @@ -1370,6 +1507,9 @@ BEGIN_DATADESC( CPhysConvert ) DEFINE_KEYFIELD( m_swapModel, FIELD_STRING, "swapmodel" ), DEFINE_KEYFIELD( m_flMassOverride, FIELD_FLOAT, "massoverride" ), +#ifdef MAPBASE + DEFINE_INPUT( m_iPhysicsEntityType, FIELD_INTEGER, "SetConversionType" ), +#endif // Inputs DEFINE_INPUTFUNC( FIELD_VOID, "ConvertTarget", InputConvertTarget ), @@ -1432,7 +1572,16 @@ void CPhysConvert::InputConvertTarget( inputdata_t &inputdata ) } // created phys object, now move hierarchy over +#ifdef MAPBASE + CBaseEntity *pPhys; + switch (m_iPhysicsEntityType) + { + case CONVERT_ENTITYTYPE_CONVENTIONAL: pPhys = CreateConventionalPhysicsObject( pEntity, createAsleep, createAsDebris ); break; + default: pPhys = CreateSimplePhysicsObject( pEntity, createAsleep, createAsDebris ); break; + } +#else CBaseEntity *pPhys = CreateSimplePhysicsObject( pEntity, createAsleep, createAsDebris ); +#endif if ( pPhys ) { // Override the mass if specified @@ -1445,6 +1594,22 @@ void CPhysConvert::InputConvertTarget( inputdata_t &inputdata ) } } +#ifdef MAPBASE + pPhys->m_nRenderMode = pEntity->m_nRenderMode; + pPhys->m_nRenderFX = pEntity->m_nRenderFX; + const color32 rclr = pEntity->GetRenderColor(); + pPhys->SetRenderColor(rclr.r, rclr.g, rclr.b, rclr.a); + if (pEntity->GetBaseAnimating() /*&& pPhys->GetBaseAnimating()*/) + { + CBaseAnimating *pEntityAnimating = pEntity->GetBaseAnimating(); + CBaseAnimating *pPhysAnimating = pPhys->GetBaseAnimating(); + + pPhysAnimating->m_nSkin = pEntityAnimating->m_nSkin; + pPhysAnimating->m_nBody = pEntityAnimating->m_nBody; + pPhysAnimating->SetModelScale(pEntityAnimating->GetModelScale()); + } +#endif + pPhys->SetName( pEntity->GetEntityName() ); UTIL_TransferPoseParameters( pEntity, pPhys ); TransferChildren( pEntity, pPhys ); @@ -1463,6 +1628,9 @@ void CPhysConvert::InputConvertTarget( inputdata_t &inputdata ) #define SF_MAGNET_SUCK 0x0004 #define SF_MAGNET_ALLOWROTATION 0x0008 #define SF_MAGNET_COAST_HACK 0x0010 +#ifdef MAPBASE +#define SF_MAGNET_PREVENT_PICKUP 0x0020 +#endif LINK_ENTITY_TO_CLASS( phys_magnet, CPhysMagnet ); @@ -1559,6 +1727,16 @@ CPhysMagnet::~CPhysMagnet( void ) //----------------------------------------------------------------------------- void CPhysMagnet::Spawn( void ) { +#ifdef MAPBASE + // Crashes otherwise + if (GetModelName() == NULL_STRING) + { + Warning("WARNING: %s spawned with no model name\n", GetDebugName()); + UTIL_Remove(this); + return; + } +#endif + Precache(); SetMoveType( MOVETYPE_NONE ); @@ -1587,6 +1765,13 @@ void CPhysMagnet::Spawn( void ) VPhysicsGetObject()->EnableMotion( false ); } +#ifdef MAPBASE + if ( HasSpawnFlags(SF_MAGNET_PREVENT_PICKUP) ) + { + PhysSetGameFlags(VPhysicsGetObject(), FVPHYSICS_NO_PLAYER_PICKUP); + } +#endif + m_bActive = true; m_pConstraintGroup = NULL; m_flTotalMass = 0; @@ -1741,6 +1926,20 @@ void CPhysMagnet::VPhysicsCollision( int index, gamevcollisionevent_t *pEvent ) BaseClass::VPhysicsCollision( index, pEvent ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +// Output : Returns true on success, false on failure. +//----------------------------------------------------------------------------- +bool CPhysMagnet::CanBePickedUpByPhyscannon( void ) +{ + if ( HasSpawnFlags( SF_MAGNET_PREVENT_PICKUP ) ) + return false; + + return true; +} +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- diff --git a/sp/src/game/server/physobj.h b/sp/src/game/server/physobj.h index a6e9e5a5..4c95c28c 100644 --- a/sp/src/game/server/physobj.h +++ b/sp/src/game/server/physobj.h @@ -76,6 +76,9 @@ public: void InputDisableMotion( inputdata_t &inputdata ); void InputForceDrop( inputdata_t &inputdata ); void InputDisableFloating( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetDebris( inputdata_t &inputdata ); +#endif DECLARE_DATADESC(); @@ -120,6 +123,9 @@ public: // Input handlers void InputExplode( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputExplodeAndRemove( inputdata_t &inputdata ); +#endif DECLARE_DATADESC(); private: @@ -187,6 +193,9 @@ public: void Precache( void ); void Touch( CBaseEntity *pOther ); void VPhysicsCollision( int index, gamevcollisionevent_t *pEvent ); +#ifdef MAPBASE + bool CanBePickedUpByPhyscannon( void ); +#endif void DoMagnetSuck( CBaseEntity *pOther ); void SetConstraintGroup( IPhysicsConstraintGroup *pGroup ); diff --git a/sp/src/game/server/player.cpp b/sp/src/game/server/player.cpp index 0538f90a..026b3ea3 100644 --- a/sp/src/game/server/player.cpp +++ b/sp/src/game/server/player.cpp @@ -80,6 +80,9 @@ #ifdef HL2_DLL #include "combine_mine.h" #include "weapon_physcannon.h" +#ifdef MAPBASE +#include "mapbase/GlobalStrings.h" +#endif #endif ConVar autoaim_max_dist( "autoaim_max_dist", "2160" ); // 2160 = 180 feet @@ -435,6 +438,12 @@ BEGIN_DATADESC( CBasePlayer ) DEFINE_FIELD( m_autoKickDisabled, FIELD_BOOLEAN ), +#ifdef MAPBASE + DEFINE_FIELD( m_bInTriggerFall, FIELD_BOOLEAN ), + + DEFINE_FIELD( m_bDrawPlayerModelExternally, FIELD_BOOLEAN ), +#endif + // Function Pointers DEFINE_FUNCTION( PlayerDeathThink ), @@ -443,6 +452,9 @@ BEGIN_DATADESC( CBasePlayer ) DEFINE_INPUTFUNC( FIELD_BOOLEAN, "SetHUDVisibility", InputSetHUDVisibility ), DEFINE_INPUTFUNC( FIELD_STRING, "SetFogController", InputSetFogController ), DEFINE_INPUTFUNC( FIELD_STRING, "HandleMapEvent", InputHandleMapEvent ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_BOOLEAN, "SetSuppressAttacks", InputSetSuppressAttacks ), +#endif DEFINE_FIELD( m_nNumCrouches, FIELD_INTEGER ), DEFINE_FIELD( m_bDuckToggled, FIELD_BOOLEAN ), @@ -527,6 +539,30 @@ void CBasePlayer::DestroyViewModels( void ) } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBasePlayer::CreateHandModel(int index, int iOtherVm) +{ + Assert(index >= 0 && index < MAX_VIEWMODELS && iOtherVm >= 0 && iOtherVm < MAX_VIEWMODELS ); + + if (GetViewModel(index)) + return; + + CBaseViewModel *vm = (CBaseViewModel *)CreateEntityByName("hand_viewmodel"); + if (vm) + { + vm->SetAbsOrigin(GetAbsOrigin()); + vm->SetOwner(this); + vm->SetIndex(index); + DispatchSpawn(vm); + vm->FollowEntity(GetViewModel(iOtherVm), true); + m_hViewModel.Set(index, vm); + } +} +#endif + //----------------------------------------------------------------------------- // Purpose: Static member function to create a player of the specified class // Input : *className - @@ -906,7 +942,11 @@ void CBasePlayer::TraceAttack( const CTakeDamageInfo &inputInfo, const Vector &v // If an NPC check if friendly fire is disallowed // -------------------------------------------------- CAI_BaseNPC *pNPC = info.GetAttacker()->MyNPCPointer(); +#ifdef MAPBASE + if ( pNPC && (pNPC->CapabilitiesGet() & bits_CAP_NO_HIT_PLAYER) && pNPC->IRelationType( this ) <= D_FR ) +#else if ( pNPC && (pNPC->CapabilitiesGet() & bits_CAP_NO_HIT_PLAYER) && pNPC->IRelationType( this ) != D_HT ) +#endif return; // Prevent team damage here so blood doesn't appear @@ -945,10 +985,22 @@ void CBasePlayer::TraceAttack( const CTakeDamageInfo &inputInfo, const Vector &v break; } +#ifdef MAPBASE + + // Damage filter bleed control needs to exist on all DLLs + bool bShouldBleed = +#ifdef HL2_EPISODIC + !g_pGameRules->Damage_ShouldNotBleed( info.GetDamageType() ) && +#endif + DamageFilterAllowsBlood( info ); + + if ( bShouldBleed ) +#else #ifdef HL2_EPISODIC // If this damage type makes us bleed, then do so bool bShouldBleed = !g_pGameRules->Damage_ShouldNotBleed( info.GetDamageType() ); if ( bShouldBleed ) +#endif #endif { SpawnBlood(ptr->endpos, vecDir, BloodColor(), info.GetDamage());// a little surface blood. @@ -4026,6 +4078,12 @@ void CBasePlayer::CheckTimeBasedDamage() case itbd_Acid: // OnTakeDamage(pev, pev, ACID_DAMAGE, DMG_GENERIC); bDuration = ACID_DURATION; +#ifdef MAPBASE + // Prevents ant workers from inducing the Flash Plague, flashing the player's screen every time they take damage henceforth. + // I think people came up with a different name, but I can't bother to look for it right now. + // This fix might prevent other acid damage stuff as well, so it's not episodic-exclusive. + m_bitsDamageType &= ~(DMG_ACID); +#endif break; case itbd_SlowBurn: // OnTakeDamage(pev, pev, SLOWBURN_DAMAGE, DMG_GENERIC); @@ -4146,6 +4204,12 @@ void CBasePlayer::UpdateGeigerCounter( void ) range = clamp( (int)range * 4, 0, 255 ); } +#ifdef MAPBASE + // If the geiger is disabled, just use 255 + if (HasSpawnFlags(SF_PLAYER_NO_GEIGER)) + range = 255; +#endif + if (range != m_igeigerRangePrev) { m_igeigerRangePrev = range; @@ -4983,6 +5047,9 @@ void CBasePlayer::Spawn( void ) enginesound->SetPlayerDSP( user, 0, false ); CreateViewModel(); +#ifdef MAPBASE + CreateHandModel(); +#endif SetCollisionGroup( COLLISION_GROUP_PLAYER ); @@ -5890,6 +5957,10 @@ void CBasePlayer::ImpulseCommands( ) CBaseCombatWeapon *pWeapon; pWeapon = GetActiveWeapon(); +#ifdef MAPBASE + if (!pWeapon) + return; +#endif if( pWeapon->IsEffectActive( EF_NODRAW ) ) { @@ -6017,7 +6088,11 @@ static void CreateJeep( CBasePlayer *pPlayer ) // Cheat to create a jeep in front of the player Vector vecForward; AngleVectors( pPlayer->EyeAngles(), &vecForward ); +#if defined(HL2_EPISODIC) && defined(MAPBASE) + CBaseEntity *pJeep = (CBaseEntity *)CreateEntityByName( "prop_vehicle_jeep_old" ); +#else CBaseEntity *pJeep = (CBaseEntity *)CreateEntityByName( "prop_vehicle_jeep" ); +#endif if ( pJeep ) { Vector vecOrigin = pPlayer->GetAbsOrigin() + vecForward * 256 + Vector(0,0,64); @@ -6519,7 +6594,22 @@ bool CBasePlayer::ClientCommand( const CCommand &args ) angle.y = atof( args[5] ); angle.z = 0.0f; +#ifdef MAPBASE + #define SPECGOTO_MAX_VALUE 0xFFFF/2.0f + + // This could crash the game somehow if not checked.. Thanks to Nairda. + if (abs(angle.x) <= 360.0f && abs(angle.y) <= 360.0f && abs(origin.x) < SPECGOTO_MAX_VALUE && + abs(origin.y) < SPECGOTO_MAX_VALUE && abs(origin.z) < SPECGOTO_MAX_VALUE) + { + JumptoPosition(origin, angle); + } + else + { + engine->ClientPrintf(edict(), "spec_goto: Out-of-bounds"); + } +#else JumptoPosition( origin, angle ); +#endif } return true; @@ -6594,7 +6684,11 @@ bool CBasePlayer::BumpWeapon( CBaseCombatWeapon *pWeapon ) if( Weapon_EquipAmmoOnly( pWeapon ) ) { // Only remove me if I have no ammo left +#ifdef MAPBASE + if ( pWeapon->HasPrimaryAmmo() || pWeapon->HasSecondaryAmmo() ) +#else if ( pWeapon->HasPrimaryAmmo() ) +#endif return false; UTIL_Remove( pWeapon ); @@ -6605,10 +6699,56 @@ bool CBasePlayer::BumpWeapon( CBaseCombatWeapon *pWeapon ) return false; } } +#ifdef MAPBASE + // -------------------------------------------------------------------------------- + // If we own a weapon in the same position take the ammo but leave the weapon behind + // -------------------------------------------------------------------------------- + if (!pWeapon->HasSpawnFlags(SF_WEAPON_USED)) // Make sure we're being used and not being bumped + { + for (int i=0;iGetSlot() == m_hMyWeapons[i]->GetSlot() && + pWeapon->GetPosition() == m_hMyWeapons[i]->GetPosition()) + { + //Weapon_EquipAmmoOnly( pWeapon ); + + // I'm too lazy to make my own version of Weapon_EquipAmmoOnly that doesn't check if we already have the weapon first + int primaryGiven = (pWeapon->UsesClipsForAmmo1()) ? pWeapon->m_iClip1 : pWeapon->GetPrimaryAmmoCount(); + int secondaryGiven = (pWeapon->UsesClipsForAmmo2()) ? pWeapon->m_iClip2 : pWeapon->GetSecondaryAmmoCount(); + + int takenPrimary = GiveAmmo( primaryGiven, pWeapon->m_iPrimaryAmmoType); + int takenSecondary = GiveAmmo( secondaryGiven, pWeapon->m_iSecondaryAmmoType); + + if( pWeapon->UsesClipsForAmmo1() ) + { + pWeapon->m_iClip1 -= takenPrimary; + } + else + { + pWeapon->SetPrimaryAmmoCount( pWeapon->GetPrimaryAmmoCount() - takenPrimary ); + } + + if( pWeapon->UsesClipsForAmmo2() ) + { + pWeapon->m_iClip2 -= takenSecondary; + } + else + { + pWeapon->SetSecondaryAmmoCount( pWeapon->GetSecondaryAmmoCount() - takenSecondary ); + } + + return false; + } + } + } +#endif // ------------------------- // Otherwise take the weapon // ------------------------- +#ifndef MAPBASE else +#endif { pWeapon->CheckRespawn(); @@ -6631,6 +6771,7 @@ bool CBasePlayer::BumpWeapon( CBaseCombatWeapon *pWeapon ) UTIL_HudHintText( this, hint.Access() ); } +#ifndef MAPBASE // See CBasePlayer::Weapon_Equip. // Always switch to a newly-picked up weapon if ( !PlayerHasMegaPhysCannon() ) { @@ -6642,6 +6783,7 @@ bool CBasePlayer::BumpWeapon( CBaseCombatWeapon *pWeapon ) Weapon_Switch( pWeapon ); } +#endif #endif } return true; @@ -7328,6 +7470,24 @@ void CBasePlayer::Weapon_Equip( CBaseCombatWeapon *pWeapon ) { BaseClass::Weapon_Equip( pWeapon ); +#ifdef MAPBASE + // So, I discovered that BumpWeapon seems to have some deprecated code. + // It automatically switches the player to all new weapons. Sounds normal, right? + // Except that's *also* handled here. Since the BumpWeapon code implied the player could pick up weapons while carrying the mega physcannon, + // I assumed it was some old, deprecated code and, since I needed to remove a piece of (also deprecated) code in it, I decided to remove it entirely + // and hand weapon switching to this alone. Seems straightforward, right? + // + // Well, it turns out, this code was more complicated than I thought and used various weights and stuff to determine if a weapon was worth automatically switching to. + // It doesn't automatically switch to most of the weapons. Even though I seem to be right about that old code being deprecated, + // I got irritated and...uh...replaced the correct Weapon_Equip code with the old deprecated code from BumpWeapon. + // + // Trust me. It was hard and pointless to get used to. You'll thank me later. + + if ( !PlayerHasMegaPhysCannon() ) + { + Weapon_Switch( pWeapon ); + } +#else bool bShouldSwitch = g_pGameRules->FShouldSwitchWeapon( this, pWeapon ); #ifdef HL2_DLL @@ -7343,8 +7503,51 @@ void CBasePlayer::Weapon_Equip( CBaseCombatWeapon *pWeapon ) { Weapon_Switch( pWeapon ); } +#endif } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +Activity CBasePlayer::Weapon_TranslateActivity( Activity baseAct, bool *pRequired ) +{ +#ifdef HL2_DLL + // HAAAAAAAAAAAAAACKS! + if (GetActiveWeapon()) + { + int translated = baseAct; + int iActOffset = (baseAct - ACT_HL2MP_IDLE); + + string_t iszClassname = GetActiveWeapon()->m_iClassname; + if (iszClassname == gm_isz_class_Pistol || iszClassname == gm_isz_class_357) + translated = (ACT_HL2MP_IDLE_PISTOL + iActOffset); + else if (iszClassname == gm_isz_class_SMG1) + translated = (ACT_HL2MP_IDLE_SMG1 + iActOffset); + else if (iszClassname == gm_isz_class_AR2) + translated = (ACT_HL2MP_IDLE_AR2 + iActOffset); + else if (iszClassname == gm_isz_class_Shotgun) + translated = (ACT_HL2MP_IDLE_SHOTGUN + iActOffset); + else if (iszClassname == gm_isz_class_RPG) + translated = (ACT_HL2MP_IDLE_RPG + iActOffset); + else if (iszClassname == gm_isz_class_Grenade) + translated = (ACT_HL2MP_IDLE_GRENADE + iActOffset); + else if (iszClassname == gm_isz_class_Physcannon) + translated = (ACT_HL2MP_IDLE_PHYSGUN + iActOffset); + else if (iszClassname == gm_isz_class_Crossbow) + translated = (ACT_HL2MP_IDLE_CROSSBOW + iActOffset); + else if (iszClassname == gm_isz_class_Crowbar || iszClassname == gm_isz_class_Stunstick) + translated = (ACT_HL2MP_IDLE_MELEE + iActOffset); + + if (translated != baseAct) + return (Activity)translated; + } +#endif + + return BaseClass::Weapon_TranslateActivity( baseAct, pRequired ); +} +#endif + //========================================================= // HasNamedPlayerItem Does the player already have this item? @@ -7764,6 +7967,11 @@ void CRevertSaved::LoadThink( void ) #define SF_SPEED_MOD_SUPPRESS_SPEED (1<<5) #define SF_SPEED_MOD_SUPPRESS_ATTACK (1<<6) #define SF_SPEED_MOD_SUPPRESS_ZOOM (1<<7) +#ifdef MAPBASE +// Needs to be inverse because suppressing the flashlight is already default behavior +// and we don't want to break compatibility for existing speedmods +#define SF_SPEED_MOD_DONT_SUPPRESS_FLASHLIGHT (1<<8) +#endif class CMovementSpeedMod : public CPointEntity { @@ -7771,6 +7979,11 @@ class CMovementSpeedMod : public CPointEntity public: void InputSpeedMod(inputdata_t &data); +#ifdef MAPBASE + void InputEnable(inputdata_t &data); + void InputDisable(inputdata_t &data); +#endif + private: int GetDisabledButtonMask( void ); @@ -7781,6 +7994,10 @@ LINK_ENTITY_TO_CLASS( player_speedmod, CMovementSpeedMod ); BEGIN_DATADESC( CMovementSpeedMod ) DEFINE_INPUTFUNC( FIELD_FLOAT, "ModifySpeed", InputSpeedMod ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), + DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), +#endif END_DATADESC() int CMovementSpeedMod::GetDisabledButtonMask( void ) @@ -7850,6 +8067,10 @@ void CMovementSpeedMod::InputSpeedMod(inputdata_t &data) pPlayer->HideViewModels(); } +#ifdef MAPBASE + if ( !HasSpawnFlags( SF_SPEED_MOD_DONT_SUPPRESS_FLASHLIGHT ) ) + { +#endif // Turn off the flashlight if ( pPlayer->FlashlightIsOn() ) { @@ -7858,6 +8079,9 @@ void CMovementSpeedMod::InputSpeedMod(inputdata_t &data) // Disable the flashlight's further use pPlayer->SetFlashlightEnabled( false ); +#ifdef MAPBASE + } +#endif pPlayer->DisableButtons( GetDisabledButtonMask() ); // Hide the HUD @@ -7893,6 +8117,91 @@ void CMovementSpeedMod::InputSpeedMod(inputdata_t &data) } } +#ifdef MAPBASE +void CMovementSpeedMod::InputEnable(inputdata_t &data) +{ + CBasePlayer *pPlayer = NULL; + + if ( data.pActivator && data.pActivator->IsPlayer() ) + { + pPlayer = (CBasePlayer *)data.pActivator; + } + else if ( !g_pGameRules->IsDeathmatch() ) + { + pPlayer = UTIL_GetLocalPlayer(); + } + + if ( pPlayer ) + { + // Holster weapon immediately, to allow it to cleanup + if ( HasSpawnFlags( SF_SPEED_MOD_SUPPRESS_WEAPONS ) ) + { + if ( pPlayer->GetActiveWeapon() ) + { + pPlayer->Weapon_SetLast( pPlayer->GetActiveWeapon() ); + pPlayer->GetActiveWeapon()->Holster(); + pPlayer->ClearActiveWeapon(); + } + + pPlayer->HideViewModels(); + } + + // Turn off the flashlight + if ( pPlayer->FlashlightIsOn() ) + { + pPlayer->FlashlightTurnOff(); + } + + // Disable the flashlight's further use + pPlayer->SetFlashlightEnabled( false ); + pPlayer->DisableButtons( GetDisabledButtonMask() ); + + // Hide the HUD + if ( HasSpawnFlags( SF_SPEED_MOD_SUPPRESS_HUD ) ) + { + pPlayer->m_Local.m_iHideHUD |= HIDEHUD_ALL; + } + } +} + +void CMovementSpeedMod::InputDisable(inputdata_t &data) +{ + CBasePlayer *pPlayer = NULL; + + if ( data.pActivator && data.pActivator->IsPlayer() ) + { + pPlayer = (CBasePlayer *)data.pActivator; + } + else if ( !g_pGameRules->IsDeathmatch() ) + { + pPlayer = UTIL_GetLocalPlayer(); + } + + if ( pPlayer ) + { + // Bring the weapon back + if ( HasSpawnFlags( SF_SPEED_MOD_SUPPRESS_WEAPONS ) && pPlayer->GetActiveWeapon() == NULL ) + { + pPlayer->SetActiveWeapon( pPlayer->Weapon_GetLast() ); + if ( pPlayer->GetActiveWeapon() ) + { + pPlayer->GetActiveWeapon()->Deploy(); + } + } + + // Allow the flashlight again + pPlayer->SetFlashlightEnabled( true ); + pPlayer->EnableButtons( GetDisabledButtonMask() ); + + // Restore the HUD + if ( HasSpawnFlags( SF_SPEED_MOD_SUPPRESS_HUD ) ) + { + pPlayer->m_Local.m_iHideHUD &= ~HIDEHUD_ALL; + } + } +} +#endif + void SendProxy_CropFlagsToPlayerFlagBitsLength( const SendProp *pProp, const void *pStruct, const void *pVarData, DVariant *pOut, int iElement, int objectID) { @@ -7957,6 +8266,14 @@ void SendProxy_CropFlagsToPlayerFlagBitsLength( const SendProp *pProp, const voi SendPropInt ( SENDINFO( m_nWaterLevel ), 2, SPROP_UNSIGNED ), SendPropFloat ( SENDINFO( m_flLaggedMovementValue ), 0, SPROP_NOSCALE ), +#ifdef MAPBASE + // Transmitted from the server for internal player spawnflags. + // See baseplayer_shared.h for more details. + SendPropInt ( SENDINFO( m_spawnflags ), 3, SPROP_UNSIGNED ), + + SendPropBool ( SENDINFO( m_bDrawPlayerModelExternally ) ), +#endif + END_SEND_TABLE() @@ -8676,6 +8993,19 @@ void CBasePlayer::InputSetHUDVisibility( inputdata_t &inputdata ) } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CBasePlayer::InputSetSuppressAttacks( inputdata_t &inputdata ) +{ + inputdata.value.Bool() ? + AddSpawnFlags( SF_PLAYER_SUPPRESS_FIRING ) : + RemoveSpawnFlags( SF_PLAYER_SUPPRESS_FIRING ); +} +#endif + //----------------------------------------------------------------------------- // Purpose: Set the fog controller data per player. // Input : &inputdata - diff --git a/sp/src/game/server/player.h b/sp/src/game/server/player.h index ddbd4416..7d487747 100644 --- a/sp/src/game/server/player.h +++ b/sp/src/game/server/player.h @@ -233,7 +233,6 @@ private: CBasePlayer *m_pParent; }; - class CBasePlayer : public CBaseCombatCharacter { public: @@ -265,6 +264,10 @@ public: void HideViewModels( void ); void DestroyViewModels( void ); +#ifdef MAPBASE + virtual void CreateHandModel( int viewmodelindex = 1, int iOtherVm = 0 ); +#endif + CPlayerState *PlayerData( void ) { return &pl; } int RequiredEdictIndex( void ) { return ENTINDEX(edict()); } @@ -416,6 +419,9 @@ public: virtual bool Weapon_ShouldSelectItem( CBaseCombatWeapon *pWeapon ); void Weapon_DropSlot( int weaponSlot ); CBaseCombatWeapon *Weapon_GetLast( void ) { return m_hLastWeapon.Get(); } +#ifdef MAPBASE + virtual Activity Weapon_TranslateActivity( Activity baseAct, bool *pRequired = NULL ); +#endif virtual void OnMyWeaponFired( CBaseCombatWeapon *weapon ); // call this when this player fires a weapon to allow other systems to react virtual float GetTimeSinceWeaponFired( void ) const; // returns the time, in seconds, since this player fired a weapon @@ -766,6 +772,9 @@ public: void InputSetHealth( inputdata_t &inputdata ); void InputSetHUDVisibility( inputdata_t &inputdata ); void InputHandleMapEvent( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetSuppressAttacks( inputdata_t &inputdata ); +#endif surfacedata_t *GetSurfaceData( void ) { return m_pSurfaceData; } void SetLadderNormal( Vector vecLadderNormal ) { m_vecLadderNormal = vecLadderNormal; } @@ -892,6 +901,10 @@ public: int GetNumWearables( void ) { return m_hMyWearables.Count(); } #endif +#ifdef MAPBASE + bool m_bInTriggerFall; +#endif + private: Activity m_Activity; @@ -1092,6 +1105,10 @@ public: float m_flSideMove; int m_nNumCrateHudHints; +#ifdef MAPBASE + CNetworkVar( bool, m_bDrawPlayerModelExternally ); +#endif + private: // Used in test code to teleport the player to random locations in the map. diff --git a/sp/src/game/server/player_command.cpp b/sp/src/game/server/player_command.cpp index b607bbab..9cdbfdcf 100644 --- a/sp/src/game/server/player_command.cpp +++ b/sp/src/game/server/player_command.cpp @@ -18,6 +18,13 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" +#ifdef MAPBASE +// This turned out to be causing major issues with VPhysics collision. +// It's deactivated until a fix is found. +// See prediction.cpp as well. +//#define PLAYER_COMMAND_FIX 1 +#endif + extern IGameMovement *g_pGameMovement; extern CMoveData *g_pMoveData; // This is a global because it is subclassed by each game. extern ConVar sv_noclipduringpause; @@ -417,6 +424,13 @@ void CPlayerMove::RunCommand ( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper player->pl.v_angle = ucmd->viewangles + player->pl.anglechange; } +#ifdef PLAYER_COMMAND_FIX + // Let server invoke any needed impact functions + VPROF_SCOPE_BEGIN( "moveHelper->ProcessImpacts" ); + moveHelper->ProcessImpacts(); + VPROF_SCOPE_END(); +#endif + // Call standard client pre-think RunPreThink( player ); @@ -438,16 +452,22 @@ void CPlayerMove::RunCommand ( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper VPROF( "pVehicle->ProcessMovement()" ); pVehicle->ProcessMovement( player, g_pMoveData ); } + +#ifdef PLAYER_COMMAND_FIX + RunPostThink( player ); +#endif // Copy output FinishMove( player, ucmd, g_pMoveData ); +#ifndef PLAYER_COMMAND_FIX // Let server invoke any needed impact functions VPROF_SCOPE_BEGIN( "moveHelper->ProcessImpacts" ); moveHelper->ProcessImpacts(); VPROF_SCOPE_END(); RunPostThink( player ); +#endif g_pGameMovement->FinishTrackPredictionErrors( player ); diff --git a/sp/src/game/server/playerlocaldata.cpp b/sp/src/game/server/playerlocaldata.cpp index ac7cf5e9..363db9f3 100644 --- a/sp/src/game/server/playerlocaldata.cpp +++ b/sp/src/game/server/playerlocaldata.cpp @@ -59,6 +59,10 @@ BEGIN_SEND_TABLE_NOBASE( CPlayerLocalData, DT_Local ) // 3d skybox data SendPropInt(SENDINFO_STRUCTELEM(m_skybox3d.scale), 12), SendPropVector (SENDINFO_STRUCTELEM(m_skybox3d.origin), -1, SPROP_COORD), +#ifdef MAPBASE + SendPropVector (SENDINFO_STRUCTELEM(m_skybox3d.angles), -1, SPROP_COORD), + SendPropInt (SENDINFO_STRUCTELEM(m_skybox3d.skycolor), 32, (SPROP_COORD|SPROP_UNSIGNED), SendProxy_Color32ToInt), +#endif SendPropInt (SENDINFO_STRUCTELEM(m_skybox3d.area), 8, SPROP_UNSIGNED ), SendPropInt( SENDINFO_STRUCTELEM( m_skybox3d.fog.enable ), 1, SPROP_UNSIGNED ), SendPropInt( SENDINFO_STRUCTELEM( m_skybox3d.fog.blend ), 1, SPROP_UNSIGNED ), @@ -68,6 +72,9 @@ BEGIN_SEND_TABLE_NOBASE( CPlayerLocalData, DT_Local ) SendPropFloat( SENDINFO_STRUCTELEM( m_skybox3d.fog.start ), 0, SPROP_NOSCALE ), SendPropFloat( SENDINFO_STRUCTELEM( m_skybox3d.fog.end ), 0, SPROP_NOSCALE ), SendPropFloat( SENDINFO_STRUCTELEM( m_skybox3d.fog.maxdensity ), 0, SPROP_NOSCALE ), +#ifdef MAPBASE + SendPropFloat( SENDINFO_STRUCTELEM( m_skybox3d.fog.farz ), 0, SPROP_NOSCALE ), +#endif SendPropEHandle( SENDINFO_STRUCTELEM( m_PlayerFog.m_hCtrl ) ), @@ -119,6 +126,10 @@ BEGIN_SIMPLE_DATADESC( sky3dparams_t ) DEFINE_FIELD( scale, FIELD_INTEGER ), DEFINE_FIELD( origin, FIELD_VECTOR ), +#ifdef MAPBASE + DEFINE_FIELD( angles, FIELD_VECTOR ), + DEFINE_FIELD( skycolor, FIELD_COLOR32 ), +#endif DEFINE_FIELD( area, FIELD_INTEGER ), DEFINE_EMBEDDED( fog ), @@ -223,6 +234,18 @@ void ClientData_Update( CBasePlayer *pl ) // HACKHACK: for 3d skybox // UNDONE: Support multiple sky cameras? CSkyCamera *pSkyCamera = GetCurrentSkyCamera(); +#ifdef MAPBASE + // Needs null protection now that the sky can go from valid to null + if ( !pSkyCamera ) + { + pl->m_Local.m_skybox3d.area = 255; + } + else if ( pSkyCamera != pl->m_Local.m_pOldSkyCamera ) + { + pl->m_Local.m_pOldSkyCamera = pSkyCamera; + pl->m_Local.m_skybox3d.CopyFrom(pSkyCamera->m_skyboxData); + } +#else if ( pSkyCamera != pl->m_Local.m_pOldSkyCamera ) { pl->m_Local.m_pOldSkyCamera = pSkyCamera; @@ -232,6 +255,7 @@ void ClientData_Update( CBasePlayer *pl ) { pl->m_Local.m_skybox3d.area = 255; } +#endif } diff --git a/sp/src/game/server/point_camera.cpp b/sp/src/game/server/point_camera.cpp index df4338b5..a4b4d1fa 100644 --- a/sp/src/game/server/point_camera.cpp +++ b/sp/src/game/server/point_camera.cpp @@ -51,6 +51,11 @@ CPointCamera::CPointCamera() m_bFogEnable = false; +#ifdef MAPBASE + // Equivalent to SKYBOX_2DSKYBOX_VISIBLE, the original sky setting + m_iSkyMode = 2; +#endif + g_PointCameraList.Insert( this ); } @@ -222,6 +227,9 @@ BEGIN_DATADESC( CPointCamera ) DEFINE_KEYFIELD( m_flFogEnd, FIELD_FLOAT, "fogEnd" ), DEFINE_KEYFIELD( m_flFogMaxDensity, FIELD_FLOAT, "fogMaxDensity" ), DEFINE_KEYFIELD( m_bUseScreenAspectRatio, FIELD_BOOLEAN, "UseScreenAspectRatio" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_iSkyMode, FIELD_INTEGER, "SkyMode" ), +#endif DEFINE_FIELD( m_bActive, FIELD_BOOLEAN ), DEFINE_FIELD( m_bIsOn, FIELD_BOOLEAN ), @@ -237,6 +245,9 @@ BEGIN_DATADESC( CPointCamera ) DEFINE_INPUTFUNC( FIELD_VOID, "SetOnAndTurnOthersOff", InputSetOnAndTurnOthersOff ), DEFINE_INPUTFUNC( FIELD_VOID, "SetOn", InputSetOn ), DEFINE_INPUTFUNC( FIELD_VOID, "SetOff", InputSetOff ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetSkyMode", InputSetSkyMode ), +#endif END_DATADESC() @@ -250,4 +261,216 @@ IMPLEMENT_SERVERCLASS_ST( CPointCamera, DT_PointCamera ) SendPropFloat( SENDINFO( m_flFogMaxDensity ), 0, SPROP_NOSCALE ), SendPropInt( SENDINFO( m_bActive ), 1, SPROP_UNSIGNED ), SendPropInt( SENDINFO( m_bUseScreenAspectRatio ), 1, SPROP_UNSIGNED ), +#ifdef MAPBASE + SendPropInt( SENDINFO( m_iSkyMode ) ), +#endif END_SEND_TABLE() + +#ifdef MAPBASE + +//============================================================================= +// Orthographic point_camera +//============================================================================= + +BEGIN_DATADESC( CPointCameraOrtho ) + + DEFINE_KEYFIELD( m_bOrtho, FIELD_BOOLEAN, "IsOrtho" ), + DEFINE_ARRAY( m_OrthoDimensions, FIELD_FLOAT, CPointCameraOrtho::NUM_ORTHO_DIMENSIONS ), + + DEFINE_ARRAY( m_TargetOrtho, FIELD_FLOAT, CPointCameraOrtho::NUM_ORTHO_DIMENSIONS ), + DEFINE_FIELD( m_TargetOrthoDPS, FIELD_FLOAT ), + + DEFINE_FUNCTION( ChangeOrthoThink ), + + // Input + DEFINE_INPUTFUNC( FIELD_BOOLEAN, "SetOrthoEnabled", InputSetOrthoEnabled ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_STRING, "ScaleOrtho", InputScaleOrtho ), +#endif + DEFINE_INPUTFUNC( FIELD_STRING, "SetOrthoTop", InputSetOrthoTop ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetOrthoBottom", InputSetOrthoBottom ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetOrthoLeft", InputSetOrthoLeft ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetOrthoRight", InputSetOrthoRight ), + +END_DATADESC() + +IMPLEMENT_SERVERCLASS_ST( CPointCameraOrtho, DT_PointCameraOrtho ) + SendPropInt( SENDINFO( m_bOrtho ), 1, SPROP_UNSIGNED ), + SendPropArray( SendPropFloat(SENDINFO_ARRAY(m_OrthoDimensions), CPointCameraOrtho::NUM_ORTHO_DIMENSIONS, SPROP_NOSCALE ), m_OrthoDimensions ), +END_SEND_TABLE() + +LINK_ENTITY_TO_CLASS( point_camera_ortho, CPointCameraOrtho ); + +CPointCameraOrtho::~CPointCameraOrtho() +{ +} + +CPointCameraOrtho::CPointCameraOrtho() +{ +} + +void CPointCameraOrtho::Spawn( void ) +{ + BaseClass::Spawn(); + + // If 0, get the FOV + if (m_OrthoDimensions[ORTHO_TOP] == 0.0f) + m_OrthoDimensions.Set( ORTHO_TOP, GetFOV() ); + + // If 0, get the negative top ortho + if (m_OrthoDimensions[ORTHO_BOTTOM] == 0.0f) + m_OrthoDimensions.Set( ORTHO_BOTTOM, -m_OrthoDimensions[ORTHO_TOP] ); + + // If 0, get the top ortho + if (m_OrthoDimensions[ORTHO_LEFT] == 0.0f) + m_OrthoDimensions.Set( ORTHO_LEFT, m_OrthoDimensions[ORTHO_TOP] ); + + // If 0, get the negative left ortho + if (m_OrthoDimensions[ORTHO_RIGHT] == 0.0f) + m_OrthoDimensions.Set( ORTHO_RIGHT, -m_OrthoDimensions[ORTHO_LEFT] ); +} + +bool CPointCameraOrtho::KeyValue( const char *szKeyName, const char *szValue ) +{ + if ( strncmp( szKeyName, "Ortho", 5 ) == 0 ) + { + int iOrtho = atoi(szKeyName + 5); + m_OrthoDimensions.Set( iOrtho, atof( szValue ) ); + } + else + return BaseClass::KeyValue( szKeyName, szValue ); + + return true; +} + +bool CPointCameraOrtho::GetKeyValue( const char *szKeyName, char *szValue, int iMaxLen ) +{ + if ( strncmp( szKeyName, "Ortho", 5 ) ) + { + int iOrtho = atoi(szKeyName + 5); + Q_snprintf( szValue, iMaxLen, "%f", m_OrthoDimensions[iOrtho] ); + } + else + return BaseClass::GetKeyValue( szKeyName, szValue, iMaxLen ); + + return true; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointCameraOrtho::ChangeOrtho( int iType, const char *szChange ) +{ + // Parse the keyvalue data + char parseString[255]; + Q_strncpy( parseString, szChange, sizeof( parseString ) ); + + // Get Ortho + char *pszParam = strtok( parseString, " " ); + if (pszParam) + { + m_TargetOrtho[iType] = atof( pszParam ); + } + else + { + // Assume no change + m_TargetOrtho[iType] = m_OrthoDimensions[iType]; + } + + // Get Time + float flChangeTime; + pszParam = strtok( NULL, " " ); + if (pszParam) + { + flChangeTime = atof( pszParam ); + } + else + { + // Assume 1 second + flChangeTime = 1.0; + } + + m_TargetOrthoDPS = ( m_TargetOrtho[iType] - m_OrthoDimensions[iType] ) / flChangeTime; + + SetThink( &CPointCameraOrtho::ChangeOrthoThink ); + SetNextThink( gpGlobals->curtime ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointCameraOrtho::InputScaleOrtho( inputdata_t &inputdata ) +{ + // Parse the keyvalue data + char parseString[255]; + Q_strncpy( parseString, inputdata.value.String(), sizeof( parseString ) ); + + // Get Scale + float flScale = 1.0f; + char *pszParam = strtok( parseString, " " ); + if (pszParam) + { + flScale = atof( pszParam ); + } + + // Get Time + float flChangeTime = 1.0f; + pszParam = strtok( NULL, " " ); + if (pszParam) + { + flChangeTime = atof( pszParam ); + } + + int iLargest = 0; + for (int i = 0; i < NUM_ORTHO_DIMENSIONS; i++) + { + m_TargetOrtho[i] = flScale * m_OrthoDimensions[i]; + + if (m_TargetOrtho[iLargest] <= m_TargetOrtho[i]) + iLargest = i; + } + + m_TargetOrthoDPS = (m_TargetOrtho[iLargest] - m_OrthoDimensions[iLargest]) / flChangeTime; + + SetThink( &CPointCameraOrtho::ChangeOrthoThink ); + SetNextThink( gpGlobals->curtime ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPointCameraOrtho::ChangeOrthoThink( void ) +{ + SetNextThink( gpGlobals->curtime + CAM_THINK_INTERVAL ); + + int iChanging = 0; + for (int i = 0; i < NUM_ORTHO_DIMENSIONS; i++) + { + float newDim = m_OrthoDimensions[i]; + if (newDim == m_TargetOrtho[i]) + continue; + + newDim += m_TargetOrthoDPS * CAM_THINK_INTERVAL; + + if (m_TargetOrthoDPS < 0) + { + if (newDim <= m_TargetOrtho[i]) + { + newDim = m_TargetOrtho[i]; + } + } + else + { + if (newDim >= m_TargetOrtho[i]) + { + newDim = m_TargetOrtho[i]; + } + } + + m_OrthoDimensions.Set(i, newDim); + } + + if (iChanging == 0) + SetThink( NULL ); +} +#endif diff --git a/sp/src/game/server/point_camera.h b/sp/src/game/server/point_camera.h index 499b3a36..4056190e 100644 --- a/sp/src/game/server/point_camera.h +++ b/sp/src/game/server/point_camera.h @@ -37,6 +37,11 @@ public: void InputSetOnAndTurnOthersOff( inputdata_t &inputdata ); void InputSetOn( inputdata_t &inputdata ); void InputSetOff( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetSkyMode( inputdata_t &inputdata ) { m_iSkyMode = inputdata.value.Int(); } + + float GetFOV() const { return m_FOV; } +#endif private: float m_TargetFOV; @@ -51,6 +56,9 @@ private: CNetworkVar( float, m_flFogMaxDensity ); CNetworkVar( bool, m_bActive ); CNetworkVar( bool, m_bUseScreenAspectRatio ); +#ifdef MAPBASE + CNetworkVar( int, m_iSkyMode ); +#endif // Allows the mapmaker to control whether a camera is active or not bool m_bIsOn; @@ -59,5 +67,52 @@ public: CPointCamera *m_pNext; }; +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +class CPointCameraOrtho : public CPointCamera +{ +public: + DECLARE_CLASS( CPointCameraOrtho, CPointCamera ); + DECLARE_SERVERCLASS(); + DECLARE_DATADESC(); + CPointCameraOrtho(); + ~CPointCameraOrtho(); + + enum + { + ORTHO_TOP, + ORTHO_BOTTOM, + ORTHO_LEFT, + ORTHO_RIGHT, + + NUM_ORTHO_DIMENSIONS + }; + + void Spawn( void ); + + bool KeyValue( const char *szKeyName, const char *szValue ); + bool GetKeyValue( const char *szKeyName, char *szValue, int iMaxLen ); + + void ChangeOrtho( int iType, const char *szChange ); + void ChangeOrthoThink( void ); + + void InputSetOrthoEnabled( inputdata_t &inputdata ) { m_bOrtho = inputdata.value.Bool(); } + void InputScaleOrtho( inputdata_t &inputdata ); + void InputSetOrthoTop( inputdata_t &inputdata ) { ChangeOrtho(ORTHO_TOP, inputdata.value.String()); } + void InputSetOrthoBottom( inputdata_t &inputdata ) { ChangeOrtho( ORTHO_BOTTOM, inputdata.value.String() ); } + void InputSetOrthoLeft( inputdata_t &inputdata ) { ChangeOrtho( ORTHO_LEFT, inputdata.value.String() ); } + void InputSetOrthoRight( inputdata_t &inputdata ) { ChangeOrtho( ORTHO_RIGHT, inputdata.value.String() ); } + +private: + float m_TargetOrtho[NUM_ORTHO_DIMENSIONS]; + float m_TargetOrthoDPS; + + CNetworkVar( bool, m_bOrtho ); + CNetworkArray( float, m_OrthoDimensions, NUM_ORTHO_DIMENSIONS ); +}; +#endif + CPointCamera *GetPointCameraList(); #endif // CAMERA_H diff --git a/sp/src/game/server/point_devshot_camera.cpp b/sp/src/game/server/point_devshot_camera.cpp index 3e2e2dbd..fdcefa25 100644 --- a/sp/src/game/server/point_devshot_camera.cpp +++ b/sp/src/game/server/point_devshot_camera.cpp @@ -245,6 +245,10 @@ public: } } +#ifdef MAPBASE // VDC Memory Leak Fixes + pkvMapCameras->deleteThis(); +#endif + if ( !g_iDevShotCameraCount ) { Warning( "Devshots: No point_devshot_camera in %s. Moving to next map.\n", STRING( gpGlobals->mapname ) ); diff --git a/sp/src/game/server/point_entity_finder.cpp b/sp/src/game/server/point_entity_finder.cpp new file mode 100644 index 00000000..d26b71f4 --- /dev/null +++ b/sp/src/game/server/point_entity_finder.cpp @@ -0,0 +1,207 @@ +//----------------------------------------------------------------------------- +// class CPointEntityFinder +// +// Purpose: Finds an entity using a specified heuristic and outputs it as !caller +// with the OnFoundEntity output. +//----------------------------------------------------------------------------- + +#include "cbase.h" +#include "filters.h" + +// NOTE: This has to be the last file included! +#include "tier0/memdbgon.h" + + +enum EntFinderMethod_t +{ + ENT_FIND_METHOD_NEAREST = 0, + ENT_FIND_METHOD_FARTHEST, + ENT_FIND_METHOD_RANDOM, +}; + +class CPointEntityFinder : public CBaseEntity +{ + void Activate( void ); + + DECLARE_CLASS( CPointEntityFinder, CBaseEntity ); + +private: + + EHANDLE m_hEntity; + string_t m_iFilterName; + CHandle m_hFilter; + string_t m_iRefName; + EHANDLE m_hReference; + + EntFinderMethod_t m_FindMethod; + + void FindEntity( void ); + void FindByDistance( void ); + void FindByRandom( void ); + + // Input handlers + void InputFindEntity( inputdata_t &inputdata ); + + // Output handlers + COutputEvent m_OnFoundEntity; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS( point_entity_finder, CPointEntityFinder ); + +BEGIN_DATADESC( CPointEntityFinder ) + + DEFINE_KEYFIELD( m_FindMethod, FIELD_INTEGER, "method" ), + DEFINE_KEYFIELD( m_iFilterName, FIELD_STRING, "filtername" ), + DEFINE_FIELD( m_hFilter, FIELD_EHANDLE ), + DEFINE_KEYFIELD( m_iRefName, FIELD_STRING, "referencename" ), + DEFINE_FIELD( m_hReference, FIELD_EHANDLE ), + + DEFINE_OUTPUT( m_OnFoundEntity, "OnFoundEntity" ), + + //--------------------------------- + + DEFINE_INPUTFUNC( FIELD_VOID, "FindEntity", InputFindEntity ), + +END_DATADESC() + + +void CPointEntityFinder::Activate( void ) +{ + // Get the filter, if it exists. + if (m_iFilterName != NULL_STRING) + { + m_hFilter = dynamic_cast(gEntList.FindEntityByName( NULL, m_iFilterName )); + } + + BaseClass::Activate(); +} + + +void CPointEntityFinder::FindEntity( void ) +{ + // Get the reference entity, if it exists. + if (m_iRefName != NULL_STRING) + { + m_hReference = gEntList.FindEntityByName( NULL, m_iRefName ); + } + + switch ( m_FindMethod ) + { + + case ( ENT_FIND_METHOD_NEAREST ): + FindByDistance(); + break; + case ( ENT_FIND_METHOD_FARTHEST ): + FindByDistance(); + break; + case ( ENT_FIND_METHOD_RANDOM ): + FindByRandom(); + break; + } +} + +void CPointEntityFinder::FindByDistance( void ) +{ + m_hEntity = NULL; + CBaseFilter *pFilter = m_hFilter.Get(); + +// go through each entity and determine whether it's closer or farther from the current entity. Pick according to Method selected. + + float flBestDist = 0; + CBaseEntity *pEntity = gEntList.FirstEnt(); + while ( pEntity ) + { + if ( FStrEq( STRING( pEntity->m_iClassname ), "worldspawn" ) + || FStrEq( STRING( pEntity->m_iClassname ), "soundent" ) + || FStrEq( STRING( pEntity->m_iClassname ), "player_manager" ) + || FStrEq( STRING( pEntity->m_iClassname ), "bodyque" ) + || FStrEq( STRING( pEntity->m_iClassname ), "ai_network" ) + || pEntity == this + || ( pFilter && !( pFilter->PassesFilter( this, pEntity ) ) ) ) + { + pEntity = gEntList.NextEnt( pEntity ); + continue; + } + + // if we have a reference entity, use that, otherwise, check against 'this' + Vector vecStart; + if ( m_hReference ) + { + vecStart = m_hReference->GetAbsOrigin(); + } + else + { + vecStart = GetAbsOrigin(); + } + + // init m_hEntity with a valid entity. + if (m_hEntity == NULL ) + { + m_hEntity = pEntity; + flBestDist = ( pEntity->GetAbsOrigin() - vecStart ).LengthSqr(); + } + + float flNewDist = ( pEntity->GetAbsOrigin() - vecStart ).LengthSqr(); + + switch ( m_FindMethod ) + { + + case ( ENT_FIND_METHOD_NEAREST ): + if ( flNewDist < flBestDist ) + { + m_hEntity = pEntity; + flBestDist = flNewDist; + } + break; + + case ( ENT_FIND_METHOD_FARTHEST ): + if ( flNewDist > flBestDist ) + { + m_hEntity = pEntity; + flBestDist = flNewDist; + } + break; + + default: + Assert( false ); + break; + } + + pEntity = gEntList.NextEnt( pEntity ); + } +} + +void CPointEntityFinder::FindByRandom( void ) +{ + // TODO: optimize the case where there is no filter + m_hEntity = NULL; + CBaseFilter *pFilter = m_hFilter.Get(); + CUtlVector ValidEnts; + + CBaseEntity *pEntity = gEntList.FirstEnt(); + do // note all valid entities. + { + if ( pFilter && pFilter->PassesFilter( this, pEntity ) ) + { + ValidEnts.AddToTail( pEntity ); + } + + pEntity = gEntList.NextEnt( pEntity ); + + } while ( pEntity ); + + // pick one at random + if ( ValidEnts.Count() != 0 ) + { + m_hEntity = ValidEnts[ RandomInt( 0, ValidEnts.Count() - 1 )]; + } +} + +void CPointEntityFinder::InputFindEntity( inputdata_t &inputdata ) +{ + FindEntity(); + + m_OnFoundEntity.FireOutput( inputdata.pActivator, m_hEntity ); +} \ No newline at end of file diff --git a/sp/src/game/server/point_spotlight.cpp b/sp/src/game/server/point_spotlight.cpp index 9ff28cf6..8af30ff8 100644 --- a/sp/src/game/server/point_spotlight.cpp +++ b/sp/src/game/server/point_spotlight.cpp @@ -26,6 +26,9 @@ public: DECLARE_DATADESC(); CPointSpotlight(); +#ifdef MAPBASE + ~CPointSpotlight(); +#endif void Precache(void); void Spawn(void); @@ -120,6 +123,16 @@ CPointSpotlight::CPointSpotlight() m_nMinDXLevel = 0; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CPointSpotlight::~CPointSpotlight() +{ + SpotlightDestroy(); +} +#endif + //----------------------------------------------------------------------------- // Purpose: diff --git a/sp/src/game/server/point_template.cpp b/sp/src/game/server/point_template.cpp index b933bd2d..1599de7b 100644 --- a/sp/src/game/server/point_template.cpp +++ b/sp/src/game/server/point_template.cpp @@ -60,9 +60,15 @@ BEGIN_DATADESC( CPointTemplate ) // Inputs DEFINE_INPUTFUNC( FIELD_VOID, "ForceSpawn", InputForceSpawn ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "ForceSpawnRandomTemplate", InputForceSpawnRandomTemplate ), +#endif // Outputs DEFINE_OUTPUT( m_pOutputOnSpawned, "OnEntitySpawned" ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_pOutputOutEntity, "OutSpawnedEntity" ), +#endif END_DATADESC() @@ -406,4 +412,75 @@ void CPointTemplate::InputForceSpawn( inputdata_t &inputdata ) // Fire our output m_pOutputOnSpawned.FireOutput( this, this ); + +#ifdef MAPBASE + for ( int i = 0; i < hNewEntities.Count(); i++ ) + { + m_pOutputOutEntity.Set(hNewEntities[i], hNewEntities[i], this); + } +#endif } + +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Randomly spawns one of our templates. +// This is copied from CreateInstance(). +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CPointTemplate::InputForceSpawnRandomTemplate( inputdata_t &inputdata ) +{ + CBaseEntity *pEntity = NULL; + char *pMapData; + + // Index for our m_hTemplates + int iIndex = RandomInt(0, GetNumTemplates() - 1); + + // Index for the template itself in the global template list + int iTemplateIndex = m_hTemplates[iIndex].iTemplateIndex; + + // Some templates have Entity I/O connecting the entities within the template. + // Unique versions of these templates need to be created whenever they're instanced. + if ( AllowNameFixup() && Templates_IndexRequiresEntityIOFixup( iTemplateIndex ) ) + { + // This template requires instancing. + // Create a new mapdata block and ask the template system to fill it in with + // a unique version (with fixed Entity I/O connections). + pMapData = Templates_GetEntityIOFixedMapData( iTemplateIndex ); + } + else + { + // Use the unmodified mapdata + pMapData = (char*)STRING( Templates_FindByIndex( iTemplateIndex ) ); + } + + // Create the entity from the mapdata + MapEntity_ParseEntity( pEntity, pMapData, NULL ); + if ( pEntity == NULL ) + { + Msg("Failed to initialize templated entity with mapdata: %s\n", pMapData ); + return; + } + + // Get a matrix that'll convert from world to the new local space + VMatrix matNewTemplateToWorld, matStoredLocalToWorld; + matNewTemplateToWorld.SetupMatrixOrgAngles( GetAbsOrigin(), GetAbsAngles() ); + MatrixMultiply( matNewTemplateToWorld, m_hTemplates[iIndex].matEntityToTemplate, matStoredLocalToWorld ); + + // Get the world origin & angles from the stored local coordinates + Vector vecNewOrigin; + QAngle vecNewAngles; + vecNewOrigin = matStoredLocalToWorld.GetTranslation(); + MatrixToAngles( matStoredLocalToWorld, vecNewAngles ); + + // Set its origin & angles + pEntity->SetAbsOrigin( vecNewOrigin ); + pEntity->SetAbsAngles( vecNewAngles ); + + // Spawn it + DispatchSpawn(pEntity); + + // Fire our output + m_pOutputOnSpawned.FireOutput( this, this ); + m_pOutputOutEntity.Set(pEntity, pEntity, this); +} +#endif diff --git a/sp/src/game/server/point_template.h b/sp/src/game/server/point_template.h index 94e37424..73480ee0 100644 --- a/sp/src/game/server/point_template.h +++ b/sp/src/game/server/point_template.h @@ -52,6 +52,9 @@ public: // Inputs void InputForceSpawn( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputForceSpawnRandomTemplate( inputdata_t &inputdata ); +#endif virtual void PerformPrecache(); @@ -67,6 +70,9 @@ private: CUtlVector< template_t > m_hTemplates; COutputEvent m_pOutputOnSpawned; +#ifdef MAPBASE + COutputEHANDLE m_pOutputOutEntity; +#endif }; #endif // POINT_TEMPLATE_H diff --git a/sp/src/game/server/pointhurt.cpp b/sp/src/game/server/pointhurt.cpp index 137f0432..ce103e86 100644 --- a/sp/src/game/server/pointhurt.cpp +++ b/sp/src/game/server/pointhurt.cpp @@ -30,6 +30,10 @@ public: void InputTurnOff(inputdata_t &inputdata); void InputToggle(inputdata_t &inputdata); void InputHurt(inputdata_t &inputdata); + +#ifdef MAPBASE + bool KeyValue( const char *szKeyName, const char *szValue ); +#endif DECLARE_DATADESC(); @@ -180,3 +184,21 @@ void CPointHurt::InputHurt( inputdata_t &data ) HurtThink(); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CPointHurt::KeyValue( const char *szKeyName, const char *szValue ) +{ + // Additional OR flags + if (FStrEq( szKeyName, "damageor" ) || FStrEq( szKeyName, "damagepresets" )) + { + m_bitsDamageType |= atoi(szValue); + } + else + return BaseClass::KeyValue( szKeyName, szValue ); + + return true; +} +#endif + diff --git a/sp/src/game/server/pointteleport.cpp b/sp/src/game/server/pointteleport.cpp index 171ee780..e79f6fc3 100644 --- a/sp/src/game/server/pointteleport.cpp +++ b/sp/src/game/server/pointteleport.cpp @@ -23,7 +23,15 @@ class CPointTeleport : public CBaseEntity public: void Activate( void ); +#ifdef MAPBASE + void TeleportEntity( CBaseEntity *pTarget, const Vector &vecPosition, const QAngle &angAngles ); +#endif + void InputTeleport( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputTeleportEntity( inputdata_t &inputdata ); + void InputTeleportToCurrentPos( inputdata_t &inputdata ); +#endif private: @@ -45,6 +53,10 @@ BEGIN_DATADESC( CPointTeleport ) DEFINE_FIELD( m_vSaveAngles, FIELD_VECTOR ), DEFINE_INPUTFUNC( FIELD_VOID, "Teleport", InputTeleport ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_EHANDLE, "TeleportEntity", InputTeleportEntity ), + DEFINE_INPUTFUNC( FIELD_VOID, "TeleportToCurrentPos", InputTeleportToCurrentPos ), +#endif END_DATADESC() @@ -107,6 +119,34 @@ void CPointTeleport::Activate( void ) BaseClass::Activate(); } +#ifdef MAPBASE +//------------------------------------------------------------------------------ +// Purpose: +//------------------------------------------------------------------------------ +void CPointTeleport::TeleportEntity( CBaseEntity *pTarget, const Vector &vecPosition, const QAngle &angAngles ) +{ + // in episodic, we have a special spawn flag that forces Gordon into a duck +#ifdef HL2_EPISODIC + if ( (m_spawnflags & SF_TELEPORT_INTO_DUCK) && pTarget->IsPlayer() ) + { + CBasePlayer *pPlayer = ToBasePlayer( pTarget ); + if ( pPlayer != NULL ) + { + pPlayer->m_nButtons |= IN_DUCK; + pPlayer->AddFlag( FL_DUCKING ); + pPlayer->m_Local.m_bDucked = true; + pPlayer->m_Local.m_bDucking = true; + pPlayer->m_Local.m_flDucktime = 0.0f; + pPlayer->SetViewOffset( VEC_DUCK_VIEW_SCALED( pPlayer ) ); + pPlayer->SetCollisionBounds( VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX ); + } + } +#endif + + pTarget->Teleport( &vecPosition, &angAngles, NULL ); +} +#endif + //------------------------------------------------------------------------------ // Purpose: //------------------------------------------------------------------------------ @@ -124,6 +164,9 @@ void CPointTeleport::InputTeleport( inputdata_t &inputdata ) return; } +#ifdef MAPBASE + TeleportEntity( pTarget, m_vSaveOrigin, m_vSaveAngles ); +#else // in episodic, we have a special spawn flag that forces Gordon into a duck #ifdef HL2_EPISODIC if ( (m_spawnflags & SF_TELEPORT_INTO_DUCK) && pTarget->IsPlayer() ) @@ -143,5 +186,49 @@ void CPointTeleport::InputTeleport( inputdata_t &inputdata ) #endif pTarget->Teleport( &m_vSaveOrigin, &m_vSaveAngles, NULL ); +#endif } +#ifdef MAPBASE +//------------------------------------------------------------------------------ +// Purpose: +//------------------------------------------------------------------------------ +void CPointTeleport::InputTeleportEntity( inputdata_t &inputdata ) +{ + if ( !inputdata.value.Entity() ) + { + Warning( "%s unable to find entity from TeleportEntity\n", GetDebugName() ); + return; + } + + // If teleport object is in a movement hierarchy, remove it first + if ( EntityMayTeleport( inputdata.value.Entity() ) == false ) + { + Warning("ERROR: (%s) can't teleport object (%s) as it has a parent (%s)!\n",GetDebugName(),inputdata.value.Entity()->GetDebugName(),inputdata.value.Entity()->GetMoveParent()->GetDebugName()); + return; + } + + TeleportEntity( inputdata.value.Entity(), m_vSaveOrigin, m_vSaveAngles ); +} + +//------------------------------------------------------------------------------ +// Purpose: +//------------------------------------------------------------------------------ +void CPointTeleport::InputTeleportToCurrentPos( inputdata_t &inputdata ) +{ + // Attempt to find the entity in question + CBaseEntity *pTarget = gEntList.FindEntityByName( NULL, m_target, this, inputdata.pActivator, inputdata.pCaller ); + if ( pTarget == NULL ) + return; + + // If teleport object is in a movement hierarchy, remove it first + if ( EntityMayTeleport( pTarget ) == false ) + { + Warning("ERROR: (%s) can't teleport object (%s) as it has a parent (%s)!\n",GetDebugName(),pTarget->GetDebugName(),pTarget->GetMoveParent()->GetDebugName()); + return; + } + + TeleportEntity( pTarget, GetAbsOrigin(), GetAbsAngles() ); +} +#endif + diff --git a/sp/src/game/server/props.cpp b/sp/src/game/server/props.cpp index 648191db..878046af 100644 --- a/sp/src/game/server/props.cpp +++ b/sp/src/game/server/props.cpp @@ -41,6 +41,9 @@ #include "physics_collisionevent.h" #include "gamestats.h" #include "vehicle_base.h" +#ifdef MAPBASE +#include "mapbase/GlobalStrings.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -79,8 +82,17 @@ ConVar func_breakdmg_explosive( "func_breakdmg_explosive", "1.25" ); ConVar sv_turbophysics( "sv_turbophysics", "0", FCVAR_REPLICATED, "Turns on turbo physics" ); +#ifdef MAPBASE +ConVar mapbase_prop_consistency_noremove("mapbase_prop_consistency_noremove", "1", FCVAR_NONE, "Prevents the removal of props when their classes do not match up with their models' propdata."); +#endif + #ifdef HL2_EPISODIC +#ifdef MAPBASE + #define PROP_FLARE_LIFETIME GetFlareLifetime() + float GetEnvFlareLifetime( CBaseEntity *pEntity ); +#else #define PROP_FLARE_LIFETIME 30.0f +#endif #define PROP_FLARE_IGNITE_SUBSTRACT 5.0f CBaseEntity *CreateFlare( Vector vOrigin, QAngle Angles, CBaseEntity *pOwner, float flDuration ); void KillFlare( CBaseEntity *pOwnerEntity, CBaseEntity *pEntity, float flKillTime ); @@ -193,6 +205,35 @@ void CBaseProp::Spawn( void ) int iResult = ParsePropData(); if ( !OverridePropdata() ) { +#ifdef MAPBASE + if (mapbase_prop_consistency_noremove.GetBool()) + { + switch (iResult) + { + case PARSE_FAILED_BAD_DATA: + Warning("%s at %.0f %.0f %0.f uses model %s, which has an invalid prop_data type. Not deleted due to mapbase_prop_consistency_noremove.\n", GetClassname(), GetAbsOrigin().x, GetAbsOrigin().y, GetAbsOrigin().z, szModel); + break; + case PARSE_FAILED_NO_DATA: + { + if ( FClassnameIs( this, "prop_physics" ) ) + { + Warning("%s at %.0f %.0f %0.f uses model %s, which has no propdata which means it should be used on a prop_static. Not deleted due to mapbase_prop_consistency_noremove.\n", GetClassname(), GetAbsOrigin().x, GetAbsOrigin().y, GetAbsOrigin().z, szModel); + } + } break; + case PARSE_SUCCEEDED: + { + if (!IsPropPhysics()) + { + Warning( "%s at %.0f %.0f %0.f uses model %s, which has propdata which means that it should be used on a prop_physics. Not deleted due to mapbase_prop_consistency_noremove.\n", GetClassname(), GetAbsOrigin().x, GetAbsOrigin().y, GetAbsOrigin().z, szModel ); + } + } + } + } + else + { + // No comment. + #define DevWarning Warning +#endif if ( iResult == PARSE_FAILED_BAD_DATA ) { DevWarning( "%s at %.0f %.0f %0.f uses model %s, which has an invalid prop_data type. DELETED.\n", GetClassname(), GetAbsOrigin().x, GetAbsOrigin().y, GetAbsOrigin().z, szModel ); @@ -212,13 +253,21 @@ void CBaseProp::Spawn( void ) else if ( iResult == PARSE_SUCCEEDED ) { // If we have data, and we're not a physics prop, fail +#ifdef MAPBASE + if ( !IsPropPhysics() ) +#else if ( !dynamic_cast(this) ) +#endif { DevWarning( "%s at %.0f %.0f %0.f uses model %s, which has propdata which means that it be used on a prop_physics. DELETED.\n", GetClassname(), GetAbsOrigin().x, GetAbsOrigin().y, GetAbsOrigin().z, szModel ); UTIL_Remove( this ); return; } } +#ifdef MAPBASE + #undef DevWarning + } +#endif } SetMoveType( MOVETYPE_PUSH ); @@ -275,7 +324,11 @@ bool CBaseProp::KeyValue( const char *szKeyName, const char *szValue ) if ( FStrEq(szKeyName, "health") ) { // Only override props are allowed to override health. +#ifdef MAPBASE + if ( OverridePropdata() && !FStrEq(szValue, "-1") ) +#else if ( FClassnameIs( this, "prop_physics_override" ) || FClassnameIs( this, "prop_dynamic_override" ) ) +#endif return BaseClass::KeyValue( szKeyName, szValue ); return true; @@ -759,6 +812,9 @@ BEGIN_DATADESC( CBreakableProp ) DEFINE_KEYFIELD( m_flPressureDelay, FIELD_FLOAT, "PressureDelay" ), DEFINE_FIELD( m_preferredCarryAngles, FIELD_VECTOR ), +#ifdef MAPBASE + DEFINE_FIELD( m_bUsesCustomCarryAngles, FIELD_BOOLEAN ), +#endif DEFINE_FIELD( m_flDefaultFadeScale, FIELD_FLOAT ), DEFINE_FIELD( m_bUsePuntSound, FIELD_BOOLEAN ), // DEFINE_FIELD( m_mpBreakMode, mp_break_t ), @@ -768,6 +824,10 @@ BEGIN_DATADESC( CBreakableProp ) DEFINE_INPUTFUNC( FIELD_INTEGER, "SetHealth", InputSetHealth ), DEFINE_INPUTFUNC( FIELD_INTEGER, "AddHealth", InputAddHealth ), DEFINE_INPUTFUNC( FIELD_INTEGER, "RemoveHealth", InputRemoveHealth ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetInteraction", InputSetInteraction ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "RemoveInteraction", InputRemoveInteraction ), +#endif DEFINE_INPUT( m_impactEnergyScale, FIELD_FLOAT, "physdamagescale" ), DEFINE_INPUTFUNC( FIELD_VOID, "EnablePhyscannonPickup", InputEnablePhyscannonPickup ), DEFINE_INPUTFUNC( FIELD_VOID, "DisablePhyscannonPickup", InputDisablePhyscannonPickup ), @@ -899,6 +959,9 @@ void CBreakableProp::Spawn() m_impactEnergyScale = 0.1f; } +#ifdef MAPBASE + if (!m_bUsesCustomCarryAngles) +#endif m_preferredCarryAngles = QAngle( -5, 0, 0 ); // The presence of this activity causes us to have to detach it before it can be grabbed. @@ -922,6 +985,57 @@ void CBreakableProp::Spawn() SetTouch( &CBreakableProp::BreakablePropTouch ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Handles keyvalues from the BSP. Called before spawning. +//----------------------------------------------------------------------------- +bool CBreakableProp::KeyValue( const char *szKeyName, const char *szValue ) +{ + if ( OverridePropdata() ) + { + if ( FStrEq(szKeyName, "InitialInteractions") ) + { + // Only override props are allowed to override interactions. + if (strchr(szValue, ' ')) + { + // How many interactions could there possibly be? + char szInteractions[64]; + Q_strncpy(szInteractions, szValue, sizeof(szInteractions)); + + char *token = strtok(szInteractions, " ,"); + while (token) + { + SetInteraction((propdata_interactions_t)atoi(token)); + token = strtok(token, " ,"); + } + } + else + SetInteraction((propdata_interactions_t)atoi(szValue)); + } + else if ( FStrEq(szKeyName, "preferredcarryangles") ) + { + // Only detect as custom if it's non-zero + if (!FStrEq( szValue, "0" )) + { + QAngle angCarryAngles; + UTIL_StringToVector( angCarryAngles.Base(), szValue ); + + m_preferredCarryAngles = angCarryAngles; + m_bUsesCustomCarryAngles = true; + } + } + else + return BaseClass::KeyValue( szKeyName, szValue ); + } + else + { + return BaseClass::KeyValue( szKeyName, szValue ); + } + + return true; +} +#endif + //----------------------------------------------------------------------------- // Disable auto fading under dx7 or when level fades are specified @@ -1218,6 +1332,25 @@ void CBreakableProp::InputSetHealth( inputdata_t &inputdata ) } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Input handler for setting interactions. +//----------------------------------------------------------------------------- +void CBreakableProp::InputSetInteraction( inputdata_t &inputdata ) +{ + SetInteraction( (propdata_interactions_t)inputdata.value.Int() ); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler for Adding interactions. +//----------------------------------------------------------------------------- +void CBreakableProp::InputRemoveInteraction( inputdata_t &inputdata ) +{ + RemoveInteraction( (propdata_interactions_t)inputdata.value.Int() ); +} +#endif + + //----------------------------------------------------------------------------- // Purpose: Choke point for changes to breakable health. Ensures outputs are fired. // Input : iNewHealth - @@ -1485,7 +1618,12 @@ void CBreakableProp::CreateFlare( float flLifetime ) int iAttachment = LookupAttachment( "fuse" ); Vector vOrigin; +#ifdef MAPBASE + if (!GetAttachment( iAttachment, vOrigin )) + vOrigin = GetLocalOrigin(); +#else GetAttachment( iAttachment, vOrigin ); +#endif pFlare->SetMoveType( MOVETYPE_NONE ); pFlare->SetSolid( SOLID_NONE ); @@ -2401,6 +2539,199 @@ void COrnamentProp::InputDetach( inputdata_t &inputdata ) DetachFromOwner(); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Button prop for +USEable dynamic props +//----------------------------------------------------------------------------- +class CButtonProp : public CDynamicProp +{ + DECLARE_CLASS( CButtonProp, CDynamicProp ); +public: + DECLARE_DATADESC(); + + // Remember to precache + //void Spawn(); + //void Activate(); + + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + + void SetPushSequence(int iSequence); + void PushThink(); + + // Input handlers + void InputLock( inputdata_t &inputdata ); + void InputUnlock( inputdata_t &inputdata ); + + COutputEvent m_OnPressed; + COutputEvent m_OnLockedUse; + COutputEvent m_OnIn; + COutputEvent m_OnOut; + + bool m_bLocked; + + float m_flCooldown; + +private: + float m_flCooldownTime; + bool m_bOutting; // Currently in out sequence + + string_t m_iszPressedSound; + string_t m_iszLockedSound; + + string_t m_iszInSequence; + string_t m_iszOutSequence; +}; + +LINK_ENTITY_TO_CLASS( prop_button, CButtonProp ); + +BEGIN_DATADESC( CButtonProp ) + + DEFINE_KEYFIELD( m_bLocked, FIELD_BOOLEAN, "Locked" ), + DEFINE_INPUT( m_flCooldown, FIELD_FLOAT, "SetCooldown" ), + DEFINE_FIELD( m_flCooldownTime, FIELD_TIME ), + DEFINE_FIELD( m_bOutting, FIELD_BOOLEAN ), + + DEFINE_KEYFIELD( m_iszPressedSound, FIELD_STRING, "PressedSound" ), + DEFINE_KEYFIELD( m_iszLockedSound, FIELD_STRING, "LockedSound" ), + DEFINE_KEYFIELD( m_iszInSequence, FIELD_STRING, "InSequence" ), + DEFINE_KEYFIELD( m_iszOutSequence, FIELD_STRING, "OutSequence" ), + + // Inputs + DEFINE_INPUTFUNC( FIELD_VOID, "Lock", InputLock ), + DEFINE_INPUTFUNC( FIELD_VOID, "Unlock", InputUnlock ), + + DEFINE_OUTPUT( m_OnPressed, "OnPressed" ), + DEFINE_OUTPUT( m_OnLockedUse, "OnLockedUse" ), + DEFINE_OUTPUT( m_OnIn, "OnIn" ), + DEFINE_OUTPUT( m_OnOut, "OnOut" ), + + DEFINE_THINKFUNC( PushThink ), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: +// Input : *pActivator - +// *pCaller - +// useType - +// value - +//----------------------------------------------------------------------------- +void CButtonProp::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +{ + if (m_flCooldownTime > gpGlobals->curtime) + return; + + if (m_bLocked) + { + m_OnLockedUse.FireOutput( pActivator, this ); + EmitSound(STRING(m_iszLockedSound)); + return; + } + + m_OnPressed.FireOutput( pActivator, this ); + EmitSound(STRING(m_iszPressedSound)); + + int nSequence = LookupSequence( STRING(m_iszInSequence) ); + + if ( nSequence > ACTIVITY_NOT_AVAILABLE ) + { + SetPushSequence(nSequence); + + // We still fire our inherited animation outputs + m_pOutputAnimBegun.FireOutput( pActivator, this ); + } + + m_flCooldownTime = gpGlobals->curtime + m_flCooldown; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CButtonProp::InputLock( inputdata_t &inputdata ) +{ + m_bLocked = true; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CButtonProp::InputUnlock( inputdata_t &inputdata ) +{ + m_bLocked = false; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CButtonProp::SetPushSequence(int iSequence) +{ + m_iGoalSequence = iSequence; + + int nNextSequence; + float nextCycle; + float flInterval = 0.1f; + + if (GotoSequence( GetSequence(), GetCycle(), GetPlaybackRate(), m_iGoalSequence, nNextSequence, nextCycle, m_iTransitionDirection )) + { + FinishSetSequence( nNextSequence ); + } + + SetThink( &CButtonProp::PushThink ); + if ( GetNextThink() <= gpGlobals->curtime ) + SetNextThink( gpGlobals->curtime + flInterval ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CButtonProp::PushThink() +{ + if ( m_nPendingSequence != -1 ) + { + FinishSetSequence( m_nPendingSequence ); + m_nPendingSequence = -1; + } + + if ( ((m_iTransitionDirection > 0 && GetCycle() >= 0.999f) || (m_iTransitionDirection < 0 && GetCycle() <= 0.0f)) && !SequenceLoops() ) + { + if (!SequenceLoops()) + { + // We still fire our inherited animation outputs + m_pOutputAnimOver.FireOutput(NULL, this); + } + + if (m_bOutting) + { + m_OnOut.FireOutput( NULL, this ); + } + else + { + m_OnIn.FireOutput( NULL, this ); + } + } + else + { + SetNextThink( gpGlobals->curtime + 0.1f ); + } + + StudioFrameAdvance(); + DispatchAnimEvents(this); + m_BoneFollowerManager.UpdateBoneFollowers(this); + + if (m_flCooldownTime < gpGlobals->curtime && !m_bOutting) + { + int nSequence = LookupSequence( STRING(m_iszOutSequence) ); + if ( nSequence > ACTIVITY_NOT_AVAILABLE ) + { + SetPushSequence(nSequence); + + // We still fire our inherited animation outputs + m_pOutputAnimBegun.FireOutput( NULL, this ); + } + } +} +#endif + //============================================================================= // PHYSICS PROPS @@ -2416,6 +2747,9 @@ BEGIN_DATADESC( CPhysicsProp ) DEFINE_INPUTFUNC( FIELD_VOID, "Wake", InputWake ), DEFINE_INPUTFUNC( FIELD_VOID, "Sleep", InputSleep ), DEFINE_INPUTFUNC( FIELD_VOID, "DisableFloating", InputDisableFloating ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_BOOLEAN, "SetDebris", InputSetDebris ), +#endif DEFINE_FIELD( m_bAwake, FIELD_BOOLEAN ), @@ -2480,10 +2814,15 @@ void CPhysicsProp::Spawn( ) { g_ActiveGibCount++; } + // Condense classname's to one, except for "prop_physics_override" if ( FClassnameIs( this, "physics_prop" ) ) { +#ifdef MAPBASE + m_iClassname = gm_isz_class_PropPhysics; +#else SetClassname( "prop_physics" ); +#endif } BaseClass::Spawn(); @@ -2492,10 +2831,17 @@ void CPhysicsProp::Spawn( ) return; // Now condense all classnames to one +#ifdef MAPBASE + if ( EntIsClass( this, gm_isz_class_PropPhysicsOverride ) ) + { + m_iClassname = gm_isz_class_PropPhysics; + } +#else if ( FClassnameIs( this, "prop_physics_override") ) { SetClassname( "prop_physics" ); } +#endif if ( HasSpawnFlags( SF_PHYSPROP_DEBRIS ) || HasInteraction( PROPINTER_PHYSGUN_CREATE_FLARE ) ) { @@ -2645,7 +2991,11 @@ bool CPhysicsProp::CanBePickedUpByPhyscannon( void ) //----------------------------------------------------------------------------- bool CPhysicsProp::OverridePropdata( void ) { +#ifdef MAPBASE + return EntIsClass(this, gm_isz_class_PropPhysicsOverride); +#else return ( FClassnameIs(this, "prop_physics_override" ) ); +#endif } //----------------------------------------------------------------------------- @@ -2698,6 +3048,25 @@ void CPhysicsProp::InputDisableFloating( inputdata_t &inputdata ) PhysEnableFloating( VPhysicsGetObject(), false ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Adds or removes the debris spawnflag. +//----------------------------------------------------------------------------- +void CPhysicsProp::InputSetDebris( inputdata_t &inputdata ) +{ + if (inputdata.value.Bool()) + { + AddSpawnFlags(SF_PHYSPROP_DEBRIS); + SetCollisionGroup(HasSpawnFlags(SF_PHYSPROP_FORCE_TOUCH_TRIGGERS) ? COLLISION_GROUP_DEBRIS_TRIGGER : COLLISION_GROUP_DEBRIS); + } + else + { + RemoveSpawnFlags(SF_PHYSPROP_DEBRIS); + SetCollisionGroup(COLLISION_GROUP_INTERACTIVE); // Is this the default collision group? + } +} +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -3559,6 +3928,10 @@ BEGIN_DATADESC(CBasePropDoor) DEFINE_INPUTFUNC(FIELD_VOID, "Toggle", InputToggle), DEFINE_INPUTFUNC(FIELD_VOID, "Lock", InputLock), DEFINE_INPUTFUNC(FIELD_VOID, "Unlock", InputUnlock), +#ifdef MAPBASE + DEFINE_INPUTFUNC(FIELD_VOID, "AllowPlayerUse", InputAllowPlayerUse), + DEFINE_INPUTFUNC(FIELD_VOID, "DisallowPlayerUse", InputDisallowPlayerUse), +#endif DEFINE_OUTPUT(m_OnBlockedOpening, "OnBlockedOpening"), DEFINE_OUTPUT(m_OnBlockedClosing, "OnBlockedClosing"), @@ -3841,7 +4214,12 @@ void CBasePropDoor::UpdateAreaPortals(bool isOpen) return; CBaseEntity *pPortal = NULL; +#ifdef MAPBASE + // For func_areaportal_oneway. + while ((pPortal = gEntList.FindEntityByClassname(pPortal, "func_areaportal*")) != NULL) +#else while ((pPortal = gEntList.FindEntityByClassname(pPortal, "func_areaportal")) != NULL) +#endif { if (pPortal->HasTarget(name)) { @@ -4034,6 +4412,25 @@ void CBasePropDoor::InputUnlock(inputdata_t &inputdata) } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Input handler that makes the door usable for players. +//----------------------------------------------------------------------------- +void CBasePropDoor::InputAllowPlayerUse(inputdata_t &inputdata) +{ + RemoveSpawnFlags(SF_DOOR_IGNORE_USE); +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler that makes the door unusable for players. +//----------------------------------------------------------------------------- +void CBasePropDoor::InputDisallowPlayerUse(inputdata_t &inputdata) +{ + AddSpawnFlags(SF_DOOR_IGNORE_USE); +} +#endif + + //----------------------------------------------------------------------------- // Purpose: Locks the door so that it cannot be opened. //----------------------------------------------------------------------------- @@ -4622,6 +5019,12 @@ public: if ( pPhysics->IsMoveable() && pPhysics->GetMass() < 32 ) return false; } + +#ifdef MAPBASE + // They're children, for goodness sake! + if (pEntity->GetParent() == EntityFromEntityHandle(m_pDoor)) + return false; +#endif } return true; @@ -4644,6 +5047,11 @@ inline void TraceHull_Door( const CBasePropDoor *pDoor, const Vector &vecAbsStar enginetrace->TraceRay( ray, mask, &traceFilter, ptr ); } +#ifdef MAPBASE +// This was still broken when it was scrapped. +//#define DOOR_BREAKING_STUFF 1 +#endif + // Check directions for door movement enum doorCheck_e { @@ -4668,6 +5076,15 @@ enum PropDoorRotatingOpenDirection_e DOOR_ROTATING_OPEN_BACKWARD, }; +#ifdef DOOR_BREAKING_STUFF +enum PropDoorRotatingBreakType_e +{ + DOOR_ROTATING_BREAK_NORMAL = 0, // Base behavior. + DOOR_ROTATING_BREAK_PHYS, // Turn into a physics prop via phys_conversion. + DOOR_ROTATING_BREAK_PHYS_HINGE, // Same as above, but use a phys_hinge. +}; +#endif + //=============================================== // Rotating prop door //=============================================== @@ -4708,6 +5125,15 @@ public: void InputSetSpeed(inputdata_t &inputdata); +#ifdef DOOR_BREAKING_STUFF + void Break( CBaseEntity *pBreaker, const CTakeDamageInfo &info ); +#endif + +#ifdef MAPBASE + // Filters don't work well with the way doors are considered obstructions, so it's just a spawnflag that stops all NPCs for now. + virtual bool PassesDoorFilter(CBaseEntity *pEntity) { return !HasSpawnFlags(SF_DOOR_NONPCS); } +#endif + DECLARE_DATADESC(); private: @@ -4730,6 +5156,9 @@ private: PropDoorRotatingSpawnPos_t m_eSpawnPosition; PropDoorRotatingOpenDirection_e m_eOpenDirection; +#ifdef DOOR_BREAKING_STUFF + PropDoorRotatingBreakType_e m_eBreakType; +#endif QAngle m_angRotationAjar; // Angles to spawn at if we are set to spawn ajar. QAngle m_angRotationClosed; // Our angles when we are fully closed. @@ -4750,6 +5179,9 @@ private: BEGIN_DATADESC(CPropDoorRotating) DEFINE_KEYFIELD(m_eSpawnPosition, FIELD_INTEGER, "spawnpos"), DEFINE_KEYFIELD(m_eOpenDirection, FIELD_INTEGER, "opendir" ), +#ifdef DOOR_BREAKING_STUFF + DEFINE_KEYFIELD(m_eBreakType, FIELD_INTEGER, "breaktype" ), +#endif DEFINE_KEYFIELD(m_vecAxis, FIELD_VECTOR, "axis"), DEFINE_KEYFIELD(m_flDistance, FIELD_FLOAT, "distance"), DEFINE_KEYFIELD( m_angRotationAjar, FIELD_VECTOR, "ajarangles" ), @@ -5427,19 +5859,133 @@ void CPropDoorRotating::InputSetRotationDistance( inputdata_t &inputdata ) CalculateDoorVolume( GetLocalAngles(), m_angRotationOpenBack, &m_vecBackBoundsMin, &m_vecBackBoundsMax ); } +#ifdef DOOR_BREAKING_STUFF +//extern bool TransferPhysicsObject( CBaseEntity *pFrom, CBaseEntity *pTo, bool wakeUp ); +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPropDoorRotating::Break( CBaseEntity *pBreaker, const CTakeDamageInfo &info ) +{ + if (m_eBreakType == DOOR_ROTATING_BREAK_NORMAL) + return BaseClass::Break( pBreaker, info ); + + if (m_eBreakType == DOOR_ROTATING_BREAK_PHYS || m_eBreakType == DOOR_ROTATING_BREAK_PHYS_HINGE) + { + DevMsg("Should break into physics\n"); + UnlinkFromParent( this ); + + CBaseEntity *pPhys = CreateNoSpawn( "prop_physics", GetLocalOrigin(), GetLocalAngles() ); + if ( pPhys ) + { + pPhys->SetModelName( GetModelName() ); + + pPhys->m_nRenderMode = m_nRenderMode; + pPhys->m_nRenderFX = m_nRenderFX; + const color32 rclr = GetRenderColor(); + pPhys->SetRenderColor(rclr.r, rclr.g, rclr.b, rclr.a); + + CBaseAnimating *pPhysAnimating = pPhys->GetBaseAnimating(); + + pPhysAnimating->m_nSkin = m_nSkin; + pPhysAnimating->m_nBody = m_nBody; + pPhysAnimating->SetModelScale(GetModelScale()); + + pPhys->SetName( GetEntityName() ); + + UTIL_TransferPoseParameters( this, pPhys ); + TransferChildren( this, pPhys ); + + AddSolidFlags( FSOLID_NOT_SOLID ); + AddEffects( EF_NODRAW ); + + + PhysBreakSound( this, VPhysicsGetObject(), WorldSpaceCenter() ); + + DispatchSpawn(pPhys); + + // Transferring the physics object in this case has proven to be buggy. + if (pPhys->VPhysicsGetObject()) //if ( !TransferPhysicsObject( this, pPhys, true ) ) + { + //pPhys->VPhysicsInitNormal( SOLID_VPHYSICS, 0, false ); + + pPhys->VPhysicsGetObject()->SetMaterialIndex( VPhysicsGetObject()->GetMaterialIndex() ); + } + + if (m_eBreakType == DOOR_ROTATING_BREAK_PHYS_HINGE) + { + DevMsg("Should break with hinge\n"); + // This is the point where names get a little weird. + if (GetEntityName() != NULL_STRING) + SetName(NULL_STRING); + else + { + // Since we don't have a name, but the designer wants a hinge, give the new prop a name for the hinge to target. + pPhys->SetName(AllocPooledString(UTIL_VarArgs("_physdoor%i", entindex()))); + } + + CBaseEntity *pHinge = CreateNoSpawn("phys_hinge", GetLocalOrigin(), GetLocalAngles()); + pHinge->SetName(AllocPooledString(UTIL_VarArgs("%s_createdhinge", STRING(pPhys->GetEntityName())))); + pHinge->KeyValue("attach1", STRING(pPhys->GetEntityName())); + pHinge->KeyValue("hingeaxis", m_vecAxis); + pHinge->KeyValue("breaksound", "Metal_Box.BulletImpact"); + + DispatchSpawn(pHinge); + } + + BaseClass::Break( pBreaker, info ); + + //UTIL_Remove( this ); + + pPhys->VPhysicsTakeDamage(info); + + //if (pPhys->VPhysicsGetObject()) + // pPhys->VPhysicsGetObject()->ApplyForceOffset(info.GetDamageForce(), info.GetDamagePosition()); + } + else + { + BaseClass::Break( pBreaker, info ); + } + } +} +#endif + +#ifdef MAPBASE +void CPropDoorRotating::InputSetSpeed(inputdata_t &inputdata) +{ + AssertMsg1(inputdata.value.Float() > 0.0f, "InputSetSpeed on %s called with negative parameter!", GetDebugName() ); + m_flSpeed = inputdata.value.Float(); + DoorResume(); +} +#endif + // Debug sphere class CPhysSphere : public CPhysicsProp { DECLARE_CLASS( CPhysSphere, CPhysicsProp ); +#ifdef MAPBASE + DECLARE_DATADESC(); +#endif public: +#ifdef MAPBASE + float m_fRadius; +#else virtual bool OverridePropdata() { return true; } +#endif bool CreateVPhysics() { SetSolid( SOLID_BBOX ); +#ifdef MAPBASE + SetCollisionBounds( -Vector(m_fRadius), Vector(m_fRadius) ); +#else SetCollisionBounds( -Vector(12,12,12), Vector(12,12,12) ); +#endif objectparams_t params = g_PhysDefaultObjectParams; params.pGameData = static_cast(this); +#ifdef MAPBASE + IPhysicsObject *pPhysicsObject = physenv->CreateSphereObject( m_fRadius, GetModelPtr()->GetRenderHdr()->textureindex, GetAbsOrigin(), GetAbsAngles(), ¶ms, false ); +#else IPhysicsObject *pPhysicsObject = physenv->CreateSphereObject( 12, 0, GetAbsOrigin(), GetAbsAngles(), ¶ms, false ); +#endif if ( pPhysicsObject ) { VPhysicsSetObject( pPhysicsObject ); @@ -5451,16 +5997,144 @@ public: } }; +#ifdef MAPBASE +BEGIN_DATADESC( CPhysSphere ) + DEFINE_KEYFIELD( m_fRadius, FIELD_FLOAT, "radius"), +END_DATADESC() +#endif + +#ifndef MAPBASE // Yes, all I'm doing is moving this up a few lines and I'm still using the preprocessor. void CPropDoorRotating::InputSetSpeed(inputdata_t &inputdata) { AssertMsg1(inputdata.value.Float() > 0.0f, "InputSetSpeed on %s called with negative parameter!", GetDebugName() ); m_flSpeed = inputdata.value.Float(); DoorResume(); } +#endif LINK_ENTITY_TO_CLASS( prop_sphere, CPhysSphere ); +#if defined(MAPBASE) && defined(HL2_EPISODIC) +// ------------------------------------------------------------------------------------------ // +// Flare class for higher interaction possibilities, inspired by Black Mesa +// ------------------------------------------------------------------------------------------ // +class CPropFlare : public CPhysicsProp +{ + DECLARE_CLASS( CPropFlare, CPhysicsProp ); + DECLARE_DATADESC(); +public: + + void Precache() + { + BaseClass::Precache(); + + if (GetModelName() != NULL_STRING) + { + PrecacheModel(STRING(GetModelName())); + } + else + { + PrecacheModel("models/props_junk/flare.mdl"); + } + } + + void Spawn() + { + if (GetModelName() == NULL_STRING) + { + // Must've been spawned with ent_create or something + SetModelName(AllocPooledString("models/props_junk/flare.mdl")); + //SetModel("models/props_junk/flare.mdl"); + } + + if (!HasInteraction(PROPINTER_PHYSGUN_CREATE_FLARE)) + { + SetInteraction(PROPINTER_PHYSGUN_CREATE_FLARE); + } + + SetClassname( "prop_physics" ); + + return BaseClass::Spawn(); + } + + bool OverridePropdata( void ) { return true; } + + virtual float GetFlareLifetime() { return m_flFlareLifetime; } + + void InputStartFlare( inputdata_t &inputdata ) + { + CreateFlare( PROP_FLARE_LIFETIME ); + } + void InputStopFlare( inputdata_t &inputdata ) + { + KillFlare( this, m_hFlareEnt, PROP_FLARE_IGNITE_SUBSTRACT ); + } + + void InputAddFlareLifetime( inputdata_t &inputdata ) + { + if (m_hFlareEnt) + { + KillFlare( this, m_hFlareEnt, (inputdata.value.Float() * -1) ); + } + else + { + CreateFlare( inputdata.value.Float() ); + } + } + + void InputRemoveFlare( inputdata_t &inputdata ) + { + UTIL_Remove(m_hFlareEnt); + m_nSkin = 1; + } + + void InputRestoreFlare( inputdata_t &inputdata ) + { + if (!HasInteraction(PROPINTER_PHYSGUN_CREATE_FLARE) && !m_hFlareEnt) + { + SetInteraction(PROPINTER_PHYSGUN_CREATE_FLARE); + m_OnRestored.FireOutput(inputdata.pActivator, inputdata.pCaller); + m_nSkin = 0; + } + } + + int DrawDebugTextOverlays(void) + { + int text_offset = BaseClass::DrawDebugTextOverlays(); + + if (m_debugOverlays & OVERLAY_TEXT_BIT) + { + char tempstr[512]; + Q_snprintf(tempstr, sizeof(tempstr), "Flare Duration: %d", GetEnvFlareLifetime(m_hFlareEnt)); + EntityText(text_offset, tempstr, 0); + text_offset++; + } + + return text_offset; + } + + COutputEvent m_OnRestored; + float m_flFlareLifetime = 30.0f; +}; + +LINK_ENTITY_TO_CLASS( prop_flare, CPropFlare ); + +BEGIN_DATADESC( CPropFlare ) + + DEFINE_KEYFIELD( m_flFlareLifetime, FIELD_FLOAT, "FlareLifetime" ), + + DEFINE_INPUTFUNC( FIELD_VOID, "StartFlare", InputStartFlare ), + DEFINE_INPUTFUNC( FIELD_VOID, "StopFlare", InputStopFlare ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "AddFlareLifetime", InputAddFlareLifetime ), + DEFINE_INPUTFUNC( FIELD_VOID, "RemoveFlare", InputRemoveFlare ), + DEFINE_INPUTFUNC( FIELD_VOID, "RestoreFlare", InputRestoreFlare ), + DEFINE_OUTPUT( m_OnRestored, "OnRestored" ), + +END_DATADESC() +#endif + + // ------------------------------------------------------------------------------------------ // // Special version of func_physbox. // ------------------------------------------------------------------------------------------ // diff --git a/sp/src/game/server/props.h b/sp/src/game/server/props.h index 8db20f2f..844c1f6c 100644 --- a/sp/src/game/server/props.h +++ b/sp/src/game/server/props.h @@ -39,6 +39,11 @@ public: // Don't treat as a live target virtual bool IsAlive( void ) { return false; } virtual bool OverridePropdata() { return true; } + +#ifdef MAPBASE + // Attempt to replace a dynamic_cast + virtual bool IsPropPhysics() { return false; } +#endif }; @@ -58,10 +63,18 @@ public: virtual void Precache(); virtual float GetAutoAimRadius() { return 24.0f; } +#ifdef MAPBASE + virtual bool KeyValue( const char *szKeyName, const char *szValue ); +#endif + void BreakablePropTouch( CBaseEntity *pOther ); virtual int OnTakeDamage( const CTakeDamageInfo &info ); void Event_Killed( const CTakeDamageInfo &info ); +#ifdef MAPBASE + // Marks Break() as virtual + virtual +#endif void Break( CBaseEntity *pBreaker, const CTakeDamageInfo &info ); void BreakThink( void ); void AnimateThink( void ); @@ -72,6 +85,10 @@ public: void InputAddHealth( inputdata_t &inputdata ); void InputRemoveHealth( inputdata_t &inputdata ); void InputSetHealth( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetInteraction( inputdata_t &inputdata ); + void InputRemoveInteraction( inputdata_t &inputdata ); +#endif int GetNumBreakableChunks( void ) { return m_iNumBreakableChunks; } @@ -86,6 +103,11 @@ public: if ( HasInteraction( PROPINTER_PHYSGUN_LAUNCH_SPIN_Z ) ) return true; +#ifdef MAPBASE + if ( m_bUsesCustomCarryAngles ) + return true; +#endif + return false; } @@ -111,6 +133,10 @@ public: int m_iMinHealthDmg; QAngle m_preferredCarryAngles; +#ifdef MAPBASE + // Indicates whether the prop is using the keyvalue carry angles. + bool m_bUsesCustomCarryAngles; +#endif public: // IBreakableWithPropData @@ -196,6 +222,9 @@ public: virtual CBasePlayer *HasPhysicsAttacker( float dt ); #ifdef HL2_EPISODIC +#ifdef MAPBASE + virtual float GetFlareLifetime() { return 30.0f; } +#endif void CreateFlare( float flLifetime ); #endif //HL2_EPISODIC @@ -243,7 +272,14 @@ private: mp_break_t m_mpBreakMode; EHANDLE m_hLastAttacker; // Last attacker that harmed me. +#ifdef MAPBASE +protected: + // Needs to be protected for prop_flare entity usage EHANDLE m_hFlareEnt; +private: +#else + EHANDLE m_hFlareEnt; +#endif string_t m_iszPuntSound; bool m_bUsePuntSound; }; @@ -343,6 +379,11 @@ public: bool CreateVPhysics( void ); bool OverridePropdata( void ); +#ifdef MAPBASE + // Attempt to replace a dynamic_cast + virtual bool IsPropPhysics() { return true; } +#endif + virtual void VPhysicsUpdate( IPhysicsObject *pPhysics ); virtual void VPhysicsCollision( int index, gamevcollisionevent_t *pEvent ); @@ -351,6 +392,9 @@ public: void InputEnableMotion( inputdata_t &inputdata ); void InputDisableMotion( inputdata_t &inputdata ); void InputDisableFloating( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetDebris( inputdata_t &inputdata ); +#endif void EnableMotion( void ); bool CanBePickedUpByPhyscannon( void ); diff --git a/sp/src/game/server/rope.cpp b/sp/src/game/server/rope.cpp index 7ca53298..dd8c3bbe 100644 --- a/sp/src/game/server/rope.cpp +++ b/sp/src/game/server/rope.cpp @@ -37,6 +37,9 @@ IMPLEMENT_SERVERCLASS_ST_NOBASE( CRopeKeyframe, DT_RopeKeyframe ) SendPropInt( SENDINFO(m_Slack), 12 ), SendPropInt( SENDINFO(m_RopeLength), 15 ), SendPropInt( SENDINFO(m_fLockedPoints), 4, SPROP_UNSIGNED ), +#ifdef MAPBASE + SendPropInt( SENDINFO(m_nChangeCount), 8, SPROP_UNSIGNED ), +#endif SendPropInt( SENDINFO(m_RopeFlags), ROPE_NUMFLAGS, SPROP_UNSIGNED ), SendPropInt( SENDINFO(m_nSegments), 4, SPROP_UNSIGNED ), SendPropBool( SENDINFO(m_bConstrainBetweenEndpoints) ), @@ -86,6 +89,11 @@ BEGIN_DATADESC( CRopeKeyframe ) DEFINE_INPUTFUNC( FIELD_VECTOR, "SetForce", InputSetForce ), DEFINE_INPUTFUNC( FIELD_VOID, "Break", InputBreak ), +#ifdef MAPBASE + // Outputs + DEFINE_OUTPUT( m_OnBreak, "OnBreak" ), +#endif + END_DATADESC() @@ -109,7 +117,12 @@ CRopeKeyframe::CRopeKeyframe() m_RopeLength = 20; m_fLockedPoints = (int) (ROPE_LOCK_START_POINT | ROPE_LOCK_END_POINT); // by default, both points are locked m_flScrollSpeed = 0; +#ifdef MAPBASE + // Because of the keyvalue switch + m_RopeFlags = ROPE_SIMULATE | ROPE_INITIAL_HANG | ROPE_USE_WIND; +#else m_RopeFlags = ROPE_SIMULATE | ROPE_INITIAL_HANG; +#endif m_iRopeMaterialModelIndex = -1; m_Subdiv = 2; @@ -201,10 +214,19 @@ CRopeKeyframe* CRopeKeyframe::Create( int iEndAttachment, int ropeWidth, const char *pMaterialName, +#ifdef MAPBASE + int numSegments, + const char *pClassName +#else int numSegments +#endif ) { +#ifdef MAPBASE + CRopeKeyframe *pRet = (CRopeKeyframe*)CreateEntityByName( pClassName ); +#else CRopeKeyframe *pRet = (CRopeKeyframe*)CreateEntityByName( "keyframe_rope" ); +#endif if( !pRet ) return NULL; @@ -218,6 +240,9 @@ CRopeKeyframe* CRopeKeyframe::Create( pRet->SetMaterial( pMaterialName ); pRet->m_Width = ropeWidth; pRet->m_nSegments = clamp( numSegments, 2, ROPE_MAX_SEGMENTS ); +#ifdef MAPBASE + pRet->Spawn(); +#endif return pRet; } @@ -230,10 +255,19 @@ CRopeKeyframe* CRopeKeyframe::CreateWithSecondPointDetached( int ropeWidth, const char *pMaterialName, int numSegments, +#ifdef MAPBASE + bool bInitialHang, + const char *pClassName +#else bool bInitialHang +#endif ) { +#ifdef MAPBASE + CRopeKeyframe *pRet = (CRopeKeyframe*)CreateEntityByName( pClassName ); +#else CRopeKeyframe *pRet = (CRopeKeyframe*)CreateEntityByName( "keyframe_rope" ); +#endif if( !pRet ) return NULL; @@ -329,6 +363,26 @@ void CRopeKeyframe::Init() m_bStartPointValid = (m_hStartPoint.Get() != NULL); m_bEndPointValid = (m_hEndPoint.Get() != NULL); + +#ifdef MAPBASE + // Sanity-check the rope texture scale before it goes over the wire + if ( m_TextureScale < 0.1f ) + { + Vector origin = GetAbsOrigin(); + GetEndPointPos( 0, origin ); + DevMsg( "move_rope has TextureScale less than 0.1 at (%2.2f, %2.2f, %2.2f)\n", + origin.x, origin.y, origin.z ); + m_TextureScale = 0.1f; + } + else if ( m_TextureScale > 10.0f ) + { + Vector origin = GetAbsOrigin(); + GetEndPointPos( 0, origin ); + DevMsg( "move_rope has TextureScale greater than 10 at (%2.2f, %2.2f, %2.2f)\n", + origin.x, origin.y, origin.z ); + m_TextureScale = 10.0f; + } +#endif } @@ -552,17 +606,29 @@ void CRopeKeyframe::InputSetForce( inputdata_t &inputdata ) void CRopeKeyframe::InputBreak( inputdata_t &inputdata ) { //Route through the damage code +#ifdef MAPBASE + Break(inputdata.pActivator); +#else Break(); +#endif } //----------------------------------------------------------------------------- // Purpose: Breaks the rope // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- +#ifdef MAPBASE +bool CRopeKeyframe::Break( CBaseEntity *pActivator ) +#else bool CRopeKeyframe::Break( void ) +#endif { DetachPoint( 0 ); +#ifdef MAPBASE + m_OnBreak.FireOutput(pActivator ? pActivator : this, this); +#endif + // Find whoever references us and detach us from them. // UNDONE: PERFORMANCE: This is very slow!!! CRopeKeyframe *pTest = NULL; @@ -585,6 +651,10 @@ bool CRopeKeyframe::Break( void ) //----------------------------------------------------------------------------- void CRopeKeyframe::NotifyPositionChanged( CBaseEntity *pEntity ) { +#ifdef MAPBASE + ++m_nChangeCount; +#endif + // Update our bbox? UpdateBBox( false ); @@ -619,7 +689,11 @@ int CRopeKeyframe::OnTakeDamage( const CTakeDamageInfo &info ) if( !(m_RopeFlags & ROPE_BREAKABLE) ) return false; +#ifdef MAPBASE + Break(info.GetAttacker()); +#else Break(); +#endif return 0; } @@ -630,6 +704,14 @@ void CRopeKeyframe::Precache() BaseClass::Precache(); } +#ifdef MAPBASE +void CRopeKeyframe::Spawn( void ) +{ + BaseClass::Spawn(); + Precache(); +} +#endif + void CRopeKeyframe::DetachPoint( int iPoint ) { @@ -650,10 +732,17 @@ void CRopeKeyframe::EnableCollision() void CRopeKeyframe::EnableWind( bool bEnable ) { int flag = 0; +#ifdef MAPBASE + if ( bEnable ) + flag |= ROPE_USE_WIND; + + if ( (m_RopeFlags & ROPE_USE_WIND) != flag ) +#else if ( !bEnable ) flag |= ROPE_NO_WIND; if ( (m_RopeFlags & ROPE_NO_WIND) != flag ) +#endif { m_RopeFlags |= flag; } @@ -698,6 +787,20 @@ bool CRopeKeyframe::KeyValue( const char *szKeyName, const char *szValue ) { // Legacy support for the RopeShader parameter. int iShader = atoi( szValue ); +#ifdef MAPBASE + if ( iShader == 0 ) + { + m_strRopeMaterialModel = AllocPooledString( "cable/cable.vmt" ); + } + else if ( iShader == 1 ) + { + m_strRopeMaterialModel = AllocPooledString( "cable/rope.vmt" ); + } + else + { + m_strRopeMaterialModel = AllocPooledString( "cable/chain.vmt" ); + } +#else if ( iShader == 0 ) { m_iRopeMaterialModelIndex = PrecacheModel( "cable/cable.vmt" ); @@ -710,6 +813,7 @@ bool CRopeKeyframe::KeyValue( const char *szKeyName, const char *szValue ) { m_iRopeMaterialModelIndex = PrecacheModel( "cable/chain.vmt" ); } +#endif } else if ( stricmp( szKeyName, "RopeMaterial" ) == 0 ) { @@ -725,12 +829,28 @@ bool CRopeKeyframe::KeyValue( const char *szKeyName, const char *szValue ) SetMaterial( str ); } } +#ifdef MAPBASE + else if( stricmp( szKeyName, "UseWind" ) == 0 ) + { + if( atoi( szValue ) == 1 ) + m_RopeFlags |= ROPE_USE_WIND; + else + m_RopeFlags &= ~ROPE_USE_WIND; + } +#endif else if ( stricmp( szKeyName, "NoWind" ) == 0 ) { +#ifdef MAPBASE + if ( atoi( szValue ) != 1 ) + { + m_RopeFlags |= ROPE_USE_WIND; + } +#else if ( atoi( szValue ) == 1 ) { m_RopeFlags |= ROPE_NO_WIND; } +#endif } return BaseClass::KeyValue( szKeyName, szValue ); @@ -749,7 +869,9 @@ void CRopeKeyframe::InputSetScrollSpeed( inputdata_t &inputdata ) void CRopeKeyframe::SetMaterial( const char *pName ) { m_strRopeMaterialModel = AllocPooledString( pName ); +#ifndef MAPBASE m_iRopeMaterialModelIndex = PrecacheModel( STRING( m_strRopeMaterialModel ) ); +#endif } int CRopeKeyframe::UpdateTransmitState() diff --git a/sp/src/game/server/rope.h b/sp/src/game/server/rope.h index 7ab96044..74037800 100644 --- a/sp/src/game/server/rope.h +++ b/sp/src/game/server/rope.h @@ -37,7 +37,12 @@ public: const char *pMaterialName = "cable/cable.vmt", // Note: whoever creates the rope must // use PrecacheModel for whatever material // it specifies here. +#ifdef MAPBASE + int numSegments = 5, + const char *pClassName = "keyframe_rope" +#else int numSegments = 5 +#endif ); static CRopeKeyframe* CreateWithSecondPointDetached( @@ -49,7 +54,12 @@ public: // use PrecacheModel for whatever material // it specifies here. int numSegments = 5, +#ifdef MAPBASE + bool bInitialHang = false, + const char *pClassName = "keyframe_rope" +#else bool bInitialHang = false +#endif ); bool SetupHangDistance( float flHangDist ); @@ -68,6 +78,9 @@ public: virtual int ObjectCaps( void ) { return BaseClass::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } virtual void Activate(); virtual void Precache(); +#ifdef MAPBASE + virtual void Spawn(); +#endif virtual int OnTakeDamage( const CTakeDamageInfo &info ); virtual bool KeyValue( const char *szKeyName, const char *szValue ); @@ -92,7 +105,11 @@ public: public: +#ifdef MAPBASE + bool Break( CBaseEntity *pActivator = NULL ); +#else bool Break( void ); +#endif void DetachPoint( int iPoint ); void EndpointsChanged(); @@ -103,12 +120,21 @@ public: // Toggle wind. void EnableWind( bool bEnable ); +#ifdef MAPBASE + CBaseEntity* GetStartPoint() { return m_hStartPoint.Get(); } + int GetStartAttachment() { return m_iStartAttachment; }; +#else // Unless this is called during initialization, the caller should have done // PrecacheModel on whatever material they specify in here. void SetMaterial( const char *pName ); +#endif CBaseEntity* GetEndPoint() { return m_hEndPoint.Get(); } +#ifdef MAPBASE + int GetEndAttachment() { return m_iEndAttachment; }; +#else int GetEndAttachment() { return m_iStartAttachment; }; +#endif void SetStartPoint( CBaseEntity *pStartPoint, int attachment = 0 ); void SetEndPoint( CBaseEntity *pEndPoint, int attachment = 0 ); @@ -122,11 +148,25 @@ public: private: +#ifdef MAPBASE + // Unless this is called during initialization, the caller should have done + // PrecacheModel on whatever material they specify in here. + void SetMaterial( const char *pName ); + +protected: +#endif + void SetAttachmentPoint( CBaseHandle &hOutEnt, short &iOutAttachment, CBaseEntity *pEnt, int iAttachment ); // This is normally called by Activate but if you create the rope at runtime, // you must call it after you have setup its variables. +#ifdef MAPBASE + virtual void Init(); + +private: +#else void Init(); +#endif // These work just like the client-side versions. bool GetEndPointPos2( CBaseEntity *pEnt, int iAttachment, Vector &v ); @@ -151,6 +191,11 @@ public: // Number of subdivisions in between segments. CNetworkVar( int, m_Subdiv ); + +#ifdef MAPBASE + // Used simply to wake up rope on the client side if it has gone to sleep + CNetworkVar( unsigned char, m_nChangeCount ); +#endif //EHANDLE m_hNextLink; @@ -171,6 +216,10 @@ private: CNetworkHandle( CBaseEntity, m_hEndPoint ); CNetworkVar( short, m_iStartAttachment ); // StartAttachment/EndAttachment are attachment points. CNetworkVar( short, m_iEndAttachment ); + +#ifdef MAPBASE + COutputEvent m_OnBreak; +#endif }; diff --git a/sp/src/game/server/saverestore_gamedll.cpp b/sp/src/game/server/saverestore_gamedll.cpp index 768262e1..a1f9505d 100644 --- a/sp/src/game/server/saverestore_gamedll.cpp +++ b/sp/src/game/server/saverestore_gamedll.cpp @@ -93,6 +93,17 @@ bool ParseKeyvalue( void *pObject, typedescription_t *pFields, int iNumFields, c UTIL_StringToColor32( (color32 *) ((char *)pObject + fieldOffset), szValue ); return true; +#ifdef MAPBASE + case FIELD_EHANDLE: + ((CBaseHandle*)((char*)pObject + fieldOffset))->Set(gEntList.FindEntityByName(NULL, szValue)); + return true; + + case FIELD_INTERVAL: + extern interval_t ReadInterval( const char *pString ); + (*(interval_t*)((char *)pObject + fieldOffset)) = ReadInterval( szValue ); + return true; +#endif + case FIELD_CUSTOM: { SaveRestoreFieldInfo_t fieldInfo = @@ -106,7 +117,9 @@ bool ParseKeyvalue( void *pObject, typedescription_t *pFields, int iNumFields, c } default: +#ifndef MAPBASE case FIELD_INTERVAL: // Fixme, could write this if needed +#endif case FIELD_CLASSPTR: case FIELD_MODELINDEX: case FIELD_MATERIALINDEX: diff --git a/sp/src/game/server/sceneentity.cpp b/sp/src/game/server/sceneentity.cpp index 495aa004..4dc00f69 100644 --- a/sp/src/game/server/sceneentity.cpp +++ b/sp/src/game/server/sceneentity.cpp @@ -481,6 +481,18 @@ public: string_t m_iszTarget7; string_t m_iszTarget8; +#ifdef MAPBASE + void SetTarget(int nTarget, string_t pTargetName, CBaseEntity *pActivator = NULL, CBaseEntity *pCaller = NULL); + void InputSetTarget1(inputdata_t &inputdata); + void InputSetTarget2(inputdata_t &inputdata); + void InputSetTarget3(inputdata_t &inputdata); + void InputSetTarget4(inputdata_t &inputdata); + void InputSetTarget5(inputdata_t &inputdata); + void InputSetTarget6(inputdata_t &inputdata); + void InputSetTarget7(inputdata_t &inputdata); + void InputSetTarget8(inputdata_t &inputdata); +#endif + EHANDLE m_hTarget1; EHANDLE m_hTarget2; EHANDLE m_hTarget3; @@ -710,6 +722,17 @@ BEGIN_DATADESC( CSceneEntity ) DEFINE_INPUTFUNC( FIELD_VOID, "StopWaitingForActor", InputStopWaitingForActor ), DEFINE_INPUTFUNC( FIELD_INTEGER, "Trigger", InputTriggerEvent ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_STRING, "SetTarget1", InputSetTarget1 ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetTarget2", InputSetTarget2 ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetTarget3", InputSetTarget3 ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetTarget4", InputSetTarget4 ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetTarget5", InputSetTarget5 ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetTarget6", InputSetTarget6 ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetTarget7", InputSetTarget7 ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetTarget8", InputSetTarget8 ), +#endif + DEFINE_KEYFIELD( m_iPlayerDeathBehavior, FIELD_INTEGER, "onplayerdeath" ), DEFINE_INPUTFUNC( FIELD_VOID, "ScriptPlayerDeath", InputScriptPlayerDeath ), @@ -915,6 +938,68 @@ float CSceneEntity::GetSoundSystemLatency( void ) // Assume 100 msec sound system latency return SOUND_SYSTEM_LATENCY_DEFAULT; } + +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// I copied CSceneEntity's PrecacheScene to a unique static function so PrecacheInstancedScene() +// can precache loose scene files without having to use a CSceneEntity. +//----------------------------------------------------------------------------- +void PrecacheChoreoScene( CChoreoScene *scene ) +{ + Assert( scene ); + + // Iterate events and precache necessary resources + for ( int i = 0; i < scene->GetNumEvents(); i++ ) + { + CChoreoEvent *event = scene->GetEvent( i ); + if ( !event ) + continue; + + // load any necessary data + switch (event->GetType() ) + { + default: + break; + case CChoreoEvent::SPEAK: + { + // Defined in SoundEmitterSystem.cpp + // NOTE: The script entries associated with .vcds are forced to preload to avoid + // loading hitches during triggering + CBaseEntity::PrecacheScriptSound( event->GetParameters() ); + + if ( event->GetCloseCaptionType() == CChoreoEvent::CC_MASTER && + event->GetNumSlaves() > 0 ) + { + char tok[ CChoreoEvent::MAX_CCTOKEN_STRING ]; + if ( event->GetPlaybackCloseCaptionToken( tok, sizeof( tok ) ) ) + { + CBaseEntity::PrecacheScriptSound( tok ); + } + } + } + break; + case CChoreoEvent::SUBSCENE: + { + // Only allow a single level of subscenes for now + if ( !scene->IsSubScene() ) + { + CChoreoScene *subscene = event->GetSubScene(); + if ( !subscene ) + { + subscene = ChoreoLoadScene( event->GetParameters(), NULL, &g_TokenProcessor, LocalScene_Printf ); + subscene->SetSubScene( true ); + event->SetSubScene( subscene ); + + // Now precache it's resources, if any + PrecacheChoreoScene( subscene ); + } + } + } + break; + } + } +} +#endif //----------------------------------------------------------------------------- // Purpose: @@ -2109,7 +2194,11 @@ void CSceneEntity::InputPitchShiftPlayback( inputdata_t &inputdata ) void CSceneEntity::InputTriggerEvent( inputdata_t &inputdata ) { +#ifdef MAPBASE + CBaseEntity *pActivator = inputdata.pActivator; +#else CBaseEntity *pActivator = this; // at some point, find this from the inputdata +#endif switch ( inputdata.value.Int() ) { case 1: @@ -2267,6 +2356,107 @@ void CSceneEntity::InputInterjectResponse( inputdata_t &inputdata ) } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CSceneEntity::SetTarget( int nTarget, string_t pTargetName, CBaseEntity *pActivator, CBaseEntity *pCaller ) +{ + if (/*m_bIsPlayingBack ||*/ !nTarget) + { + return; + } + + switch (nTarget) + { + case 1: m_iszTarget1 = pTargetName; break; + case 2: m_iszTarget2 = pTargetName; break; + case 3: m_iszTarget3 = pTargetName; break; + case 4: m_iszTarget4 = pTargetName; break; + case 5: m_iszTarget5 = pTargetName; break; + case 6: m_iszTarget6 = pTargetName; break; + case 7: m_iszTarget7 = pTargetName; break; + case 8: m_iszTarget8 = pTargetName; break; + } + + // Reset our handle. + // Internal functions set them when they're null anyway. + switch (nTarget) + { + case 1: m_hTarget1 = NULL; break; + case 2: m_hTarget2 = NULL; break; + case 3: m_hTarget3 = NULL; break; + case 4: m_hTarget4 = NULL; break; + case 5: m_hTarget5 = NULL; break; + case 6: m_hTarget6 = NULL; break; + case 7: m_hTarget7 = NULL; break; + case 8: m_hTarget8 = NULL; break; + } + + //CBaseEntity *pTarget = gEntList.FindEntityByName(NULL, pTargetName, this, pActivator, pCaller); + //if (!pTarget) + //{ + // DevWarning("%s (%s) could not find SetTarget entity %s!\n", GetClassname(), GetDebugName(), pTargetName); + // return; + //} + + /* + switch (nTarget) + { + case 1: m_hTarget1 = pTarget; break; + case 2: m_hTarget2 = pTarget; break; + case 3: m_hTarget3 = pTarget; break; + case 4: m_hTarget4 = pTarget; break; + case 5: m_hTarget5 = pTarget; break; + case 6: m_hTarget6 = pTarget; break; + case 7: m_hTarget7 = pTarget; break; + case 8: m_hTarget8 = pTarget; break; + } + */ +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CSceneEntity::InputSetTarget1( inputdata_t &inputdata ) +{ + SetTarget(1, inputdata.value.StringID(), inputdata.pActivator, inputdata.pCaller); +} + +void CSceneEntity::InputSetTarget2( inputdata_t &inputdata ) +{ + SetTarget(2, inputdata.value.StringID(), inputdata.pActivator, inputdata.pCaller); +} + +void CSceneEntity::InputSetTarget3( inputdata_t &inputdata ) +{ + SetTarget(3, inputdata.value.StringID(), inputdata.pActivator, inputdata.pCaller); +} + +void CSceneEntity::InputSetTarget4( inputdata_t &inputdata ) +{ + SetTarget(4, inputdata.value.StringID(), inputdata.pActivator, inputdata.pCaller); +} + +void CSceneEntity::InputSetTarget5( inputdata_t &inputdata ) +{ + SetTarget(5, inputdata.value.StringID(), inputdata.pActivator, inputdata.pCaller); +} + +void CSceneEntity::InputSetTarget6( inputdata_t &inputdata ) +{ + SetTarget(6, inputdata.value.StringID(), inputdata.pActivator, inputdata.pCaller); +} + +void CSceneEntity::InputSetTarget7( inputdata_t &inputdata ) +{ + SetTarget(7, inputdata.value.StringID(), inputdata.pActivator, inputdata.pCaller); +} + +void CSceneEntity::InputSetTarget8( inputdata_t &inputdata ) +{ + SetTarget(8, inputdata.value.StringID(), inputdata.pActivator, inputdata.pCaller); +} +#endif + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void CSceneEntity::InputStopWaitingForActor( inputdata_t &inputdata ) @@ -3354,6 +3544,44 @@ CChoreoScene *CSceneEntity::LoadScene( const char *filename, IChoreoEventCallbac // binary compiled vcd void *pBuffer; +#ifdef MAPBASE + // + // Raw scene file support + // + CChoreoScene *pScene; + int fileSize; + + // First, check if it's in scenes.image... + if ( CopySceneFileIntoMemory( loadfile, &pBuffer, &fileSize ) ) + { + pScene = new CChoreoScene( NULL ); + CUtlBuffer buf( pBuffer, fileSize, CUtlBuffer::READ_ONLY ); + if ( !pScene->RestoreFromBinaryBuffer( buf, loadfile, &g_ChoreoStringPool ) ) + { + Warning( "CSceneEntity::LoadScene: Unable to load binary scene '%s'\n", loadfile ); + delete pScene; + pScene = NULL; + } + } + // Next, check if it's a loose file... + else if (filesystem->ReadFileEx( loadfile, "MOD", &pBuffer, true )) + { + g_TokenProcessor.SetBuffer((char*)pBuffer); + pScene = ChoreoLoadScene( loadfile, NULL, &g_TokenProcessor, LocalScene_Printf ); + } + // Okay, it's definitely missing. + else + { + MissingSceneWarning( loadfile ); + return NULL; + } + + if (pScene) + { + pScene->SetPrintFunc( LocalScene_Printf ); + pScene->SetEventCallbackInterface( pCallback ); + } +#else int fileSize; if ( !CopySceneFileIntoMemory( loadfile, &pBuffer, &fileSize ) ) { @@ -3374,6 +3602,7 @@ CChoreoScene *CSceneEntity::LoadScene( const char *filename, IChoreoEventCallbac pScene->SetPrintFunc( LocalScene_Printf ); pScene->SetEventCallbackInterface( pCallback ); } +#endif FreeSceneFileMemory( pBuffer ); return pScene; @@ -3859,6 +4088,72 @@ CBaseEntity *CSceneEntity::FindNamedEntity( const char *name, CBaseEntity *pActo return entity; } +#ifdef MAPBASE +const char *GetFirstSoundInScene(const char *pszScene) +{ + SceneCachedData_t sceneData; + if ( scenefilecache->GetSceneCachedData( pszScene, &sceneData ) ) + { + if ( sceneData.numSounds > 0 ) + { + // 0 is the first index...right? + short stringId = scenefilecache->GetSceneCachedSound( sceneData.sceneId, 0 ); + + // Trust that it's been precached + return scenefilecache->GetSceneString( stringId ); + } + } + else + { + void *pBuffer = NULL; + if (filesystem->ReadFileEx( pszScene, "MOD", &pBuffer, false, true )) + { + g_TokenProcessor.SetBuffer((char*)pBuffer); + CChoreoScene *pScene = ChoreoLoadScene( pszScene, NULL, &g_TokenProcessor, LocalScene_Printf ); + if (pScene) + { + for (int i = 0; i < pScene->GetNumEvents(); i++) + { + CChoreoEvent *pEvent = pScene->GetEvent(i); + + if (pEvent->GetType() == CChoreoEvent::SPEAK) + return pEvent->GetParameters(); + } + } + } + } + + return NULL; +} + +const char *GetFirstSoundInScene(CChoreoScene *scene) +{ + for ( int i = 0; i < scene->GetNumEvents(); i++ ) + { + CChoreoEvent *pEvent = scene->GetEvent( i ); + + if (pEvent->GetType() == CChoreoEvent::SPEAK) + return pEvent->GetParameters(); + } + + return NULL; +} + +CBaseEntity *UTIL_FindNamedSceneEntity(const char *name, CBaseEntity *pActor, CSceneEntity *scene, bool bBaseFlexOnly, bool bUseClear) +{ + if (scene) + { + CBaseEntity *pEnt = scene->FindNamedEntity(name, pActor, bBaseFlexOnly, bUseClear); + return pEnt; + } + else + { + //Warning("SCENE NOT FOUND!\n"); + return NULL; + } +} +#endif + //----------------------------------------------------------------------------- // Purpose: Search for an actor by name, make sure it can do face poses @@ -4619,9 +4914,42 @@ int GetSceneSpeechCount( char const *pszScene ) { return cachedData.numSounds; } +#ifdef MAPBASE + else + { + void *pBuffer = NULL; + if (filesystem->ReadFileEx( pszScene, "MOD", &pBuffer, false, true )) + { + int iNumSounds = 0; + + g_TokenProcessor.SetBuffer((char*)pBuffer); + CChoreoScene *pScene = ChoreoLoadScene( pszScene, NULL, &g_TokenProcessor, LocalScene_Printf ); + if (pScene) + { + for (int i = 0; i < pScene->GetNumEvents(); i++) + { + CChoreoEvent *pEvent = pScene->GetEvent(i); + + if (pEvent->GetType() == CChoreoEvent::SPEAK) + iNumSounds++; + } + } + + return iNumSounds; + } + } +#endif return 0; } +#ifdef MAPBASE +CON_COMMAND(mapbase_scene_precache, "Just work") +{ + DevMsg("Attempting to precache %s...\n", args[1]); + PrecacheInstancedScene(args[1]); +} +#endif + //----------------------------------------------------------------------------- // Purpose: Used for precaching instanced scenes // Input : *pszScene - @@ -4645,12 +4973,31 @@ void PrecacheInstancedScene( char const *pszScene ) SceneCachedData_t sceneData; if ( !scenefilecache->GetSceneCachedData( pszScene, &sceneData ) ) { +#ifdef MAPBASE + char loadfile[MAX_PATH]; + Q_strncpy( loadfile, pszScene, sizeof( loadfile ) ); + Q_SetExtension( loadfile, ".vcd", sizeof( loadfile ) ); + Q_FixSlashes( loadfile ); + + // Attempt to precache manually + void *pBuffer = NULL; + if (filesystem->ReadFileEx( loadfile, "MOD", &pBuffer, false, true )) + { + g_TokenProcessor.SetBuffer((char*)pBuffer); + CChoreoScene *pScene = ChoreoLoadScene( loadfile, NULL, &g_TokenProcessor, LocalScene_Printf ); + if (pScene) + { + PrecacheChoreoScene(pScene); + } + } +#else // Scenes are sloppy and don't always exist. // A scene that is not in the pre-built cache image, but on disk, is a true error. if ( developer.GetInt() && ( IsX360() && ( g_pFullFileSystem->GetDVDMode() != DVDMODE_STRICT ) && g_pFullFileSystem->FileExists( pszScene, "GAME" ) ) ) { Warning( "PrecacheInstancedScene: Missing scene '%s' from scene image cache.\nRebuild scene image cache!\n", pszScene ); } +#endif } else { @@ -4848,6 +5195,15 @@ void CInstancedSceneEntity::OnLoaded() { BaseClass::OnLoaded(); SetBackground( m_bIsBackground ); + +#ifdef MAPBASE + // It looks like !Target1 in those default NPC scenes was a freaking lie. + if (m_hOwner) + { + m_hTarget1 = m_hOwner; + m_iszTarget1 = m_hOwner->GetEntityName(); + } +#endif } bool g_bClientFlex = true; diff --git a/sp/src/game/server/sceneentity.h b/sp/src/game/server/sceneentity.h index f1580798..5fe6a9f0 100644 --- a/sp/src/game/server/sceneentity.h +++ b/sp/src/game/server/sceneentity.h @@ -44,5 +44,12 @@ void PrecacheInstancedScene( char const *pszScene ); char const *GetSceneFilename( CBaseEntity *ent ); void ReloadSceneFromDisk( CBaseEntity *ent ); +#ifdef MAPBASE +const char *GetFirstSoundInScene(const char *pszScene); +const char *GetFirstSoundInScene(CChoreoScene *scene); + +CBaseEntity *UTIL_FindNamedSceneEntity(const char *name, CBaseEntity *pActor, CSceneEntity *scene, bool bBaseFlexOnly = false, bool bUseClear = false); +#endif + #endif // SCENEENTITY_H diff --git a/sp/src/game/server/scripted.cpp b/sp/src/game/server/scripted.cpp index 6a492708..6c5f0426 100644 --- a/sp/src/game/server/scripted.cpp +++ b/sp/src/game/server/scripted.cpp @@ -100,6 +100,10 @@ BEGIN_DATADESC( CAI_ScriptedSequence ) DEFINE_KEYFIELD( m_iPlayerDeathBehavior, FIELD_INTEGER, "onplayerdeath" ), DEFINE_INPUTFUNC( FIELD_VOID, "ScriptPlayerDeath", InputScriptPlayerDeath ), +#ifdef MAPBASE + DEFINE_FIELD( m_hActivator, FIELD_EHANDLE ), +#endif + // Outputs DEFINE_OUTPUT(m_OnBeginSequence, "OnBeginSequence"), DEFINE_OUTPUT(m_OnEndSequence, "OnEndSequence"), @@ -179,18 +183,31 @@ void CAI_ScriptedSequence::ScriptEntityCancel( CBaseEntity *pentCine, bool bPret if ( bPretendSuccess ) { // We need to pretend that this sequence actually finished fully +#ifdef MAPBASE + pCineTarget->m_OnEndSequence.FireOutput(pEntity, pCineTarget); + pCineTarget->m_OnPostIdleEndSequence.FireOutput(pEntity, pCineTarget); +#else pCineTarget->m_OnEndSequence.FireOutput(NULL, pCineTarget); pCineTarget->m_OnPostIdleEndSequence.FireOutput(NULL, pCineTarget); +#endif } else { // Fire the cancel +#ifdef MAPBASE + pCineTarget->m_OnCancelSequence.FireOutput(pEntity, pCineTarget); +#else pCineTarget->m_OnCancelSequence.FireOutput(NULL, pCineTarget); +#endif if ( pCineTarget->m_startTime == 0 ) { // If start time is 0, this sequence never actually ran. Fire the failed output. +#ifdef MAPBASE + pCineTarget->m_OnCancelFailedSequence.FireOutput(pEntity, pCineTarget); +#else pCineTarget->m_OnCancelFailedSequence.FireOutput(NULL, pCineTarget); +#endif } } } @@ -332,6 +349,18 @@ void CAI_ScriptedSequence::InputMoveToPosition( inputdata_t &inputdata ) } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Sets our target NPC with the generic SetTarget input. +//----------------------------------------------------------------------------- +void CAI_ScriptedSequence::InputSetTarget( inputdata_t &inputdata ) +{ + m_hActivator = inputdata.pActivator; + m_iszEntity = AllocPooledString(inputdata.value.String()); + m_hTargetEnt = NULL; +} +#endif + //----------------------------------------------------------------------------- // Purpose: Input handler that activates the scripted sequence. @@ -343,6 +372,14 @@ void CAI_ScriptedSequence::InputBeginSequence( inputdata_t &inputdata ) // Start the script as soon as possible. m_bWaitForBeginSequence = false; + +#ifdef MAPBASE + m_hActivator = inputdata.pActivator; + + // TODO: Investigate whether this is necessary + //if (FStrEq(STRING(m_iszEntity), "!activator")) + // SetTarget(NULL); +#endif // do I already know who I should use? CBaseEntity *pEntity = GetTarget(); @@ -521,7 +558,11 @@ CAI_BaseNPC *CAI_ScriptedSequence::FindScriptEntity( ) { interrupt = SS_INTERRUPT_BY_NAME; +#ifdef MAPBASE + pEntity = gEntList.FindEntityByNameWithin( m_hLastFoundEntity, STRING( m_iszEntity ), GetAbsOrigin(), m_flRadius, this, m_hActivator ); +#else pEntity = gEntList.FindEntityByNameWithin( m_hLastFoundEntity, STRING( m_iszEntity ), GetAbsOrigin(), m_flRadius ); +#endif if (!pEntity) { pEntity = gEntList.FindEntityByClassnameWithin( m_hLastFoundEntity, STRING( m_iszEntity ), GetAbsOrigin(), m_flRadius ); @@ -792,10 +833,17 @@ void CAI_ScriptedSequence::ScriptThink( void ) // Purpose: Callback for firing the begin sequence output. Called by the NPC that // is running the script as it starts the action seqeunce. //----------------------------------------------------------------------------- +#ifdef MAPBASE +void CAI_ScriptedSequence::OnBeginSequence( CBaseEntity *pActor ) +{ + m_OnBeginSequence.FireOutput( pActor, this ); +} +#else void CAI_ScriptedSequence::OnBeginSequence( void ) { m_OnBeginSequence.FireOutput( this, this ); } +#endif //----------------------------------------------------------------------------- @@ -964,7 +1012,11 @@ void CAI_ScriptedSequence::SequenceDone( CAI_BaseNPC *pNPC ) } } +#ifdef MAPBASE + m_OnEndSequence.FireOutput(pNPC, this); +#else m_OnEndSequence.FireOutput(NULL, this); +#endif } //----------------------------------------------------------------------------- @@ -1576,6 +1628,9 @@ private: // Input handlers void InputStartSchedule( inputdata_t &inputdata ); void InputStopSchedule( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetTarget( inputdata_t &inputdata ); +#endif CAI_BaseNPC *FindScriptEntity( bool bCyclic ); @@ -1898,6 +1953,17 @@ void CAI_ScriptedSchedule::InputStopSchedule( inputdata_t &inputdata ) } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Sets our target NPC with the generic SetTarget input. +//----------------------------------------------------------------------------- +void CAI_ScriptedSchedule::InputSetTarget( inputdata_t &inputdata ) +{ + m_hActivator = inputdata.pActivator; + m_iszEntity = AllocPooledString( inputdata.value.String() ); +} +#endif + //----------------------------------------------------------------------------- // Purpose: If the target entity appears to be running this scripted schedule break it //----------------------------------------------------------------------------- @@ -2221,6 +2287,320 @@ int CAI_ScriptedSentence::StartSentence( CAI_BaseNPC *pTarget ) return sentenceIndex; } +#ifdef MAPBASE +class CAI_ScriptedFace : public CPointEntity +{ +public: + DECLARE_CLASS( CAI_ScriptedFace, CPointEntity ); + + CAI_ScriptedFace(); + + // Input handlers + void InputBeginFacing( inputdata_t &inputdata ); + //void InputCancelFacing( inputdata_t &inputdata ); + + DECLARE_DATADESC(); + + void Begin(CBaseEntity *pActivator, CBaseEntity *pCaller); + +private: + string_t m_iszFaceTarget; + + // False = Entity, True = Position + bool m_bTargetType; + + bool m_bGrabAll; + + float m_flImportance; + float m_flDuration; + + COutputEvent m_OnBeginFace; +}; + + +BEGIN_DATADESC( CAI_ScriptedFace ) + + DEFINE_KEYFIELD( m_iszFaceTarget, FIELD_STRING, "SetFaceTarget" ), + DEFINE_KEYFIELD( m_bTargetType, FIELD_BOOLEAN, "TargetType" ), + DEFINE_KEYFIELD( m_bGrabAll, FIELD_BOOLEAN, "GrabAll" ), + DEFINE_KEYFIELD( m_flImportance, FIELD_FLOAT, "Importance" ), + DEFINE_KEYFIELD( m_flDuration, FIELD_FLOAT, "Duration" ), + + // Inputs + DEFINE_INPUTFUNC(FIELD_VOID, "BeginFacing", InputBeginFacing), + + // Outputs + DEFINE_OUTPUT(m_OnBeginFace, "OnBeginFace"), + +END_DATADESC() + + + +LINK_ENTITY_TO_CLASS( scripted_face, CAI_ScriptedFace ); + +//----------------------------------------------------------------------------- +// Purpose: +// Input : +// Output : +//----------------------------------------------------------------------------- +CAI_ScriptedFace::CAI_ScriptedFace() +{ + m_flDuration = 5.0f; + m_flImportance = 9999; +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : +// Output : +//----------------------------------------------------------------------------- +void CAI_ScriptedFace::Begin(CBaseEntity *pActivator, CBaseEntity *pCaller) +{ + Vector position; + CBaseEntity *pFaceTarget; + + if (m_bTargetType) + UTIL_StringToVector(position.Base(), STRING(m_iszFaceTarget)); + + CBaseEntity *pTarget; + CAI_BaseNPC *pNPC; + if (m_bGrabAll) + { + pTarget = gEntList.FindEntityGeneric(NULL, STRING(m_target), this, pActivator, pCaller); + while (pTarget) + { + pNPC = pTarget->MyNPCPointer(); + if (!pNPC) + { + Warning("%s tried to grab %s, but it is not a NPC!\n", GetDebugName(), pTarget->GetDebugName()); + pTarget = gEntList.FindEntityGeneric(pTarget, STRING(m_target), this, pActivator, pCaller); + continue; + } + + DevMsg("Grabbed one of many\n"); + + if (!m_bTargetType) + { + pFaceTarget = gEntList.FindEntityByNameNearest(STRING(m_iszFaceTarget), pTarget->GetLocalOrigin(), 0, this, pActivator, pCaller); + if (pFaceTarget) + { + pNPC->GetMotor()->AddFacingTarget(pFaceTarget, m_flImportance, m_flDuration); + pNPC->GetMotor()->SetIdealYawToTarget( pFaceTarget->GetAbsOrigin() ); + m_OnBeginFace.FireOutput(pFaceTarget, pTarget); + } + } + else + { + pNPC->GetMotor()->AddFacingTarget(position, m_flImportance, m_flDuration); + } + + pTarget = gEntList.FindEntityGeneric(pTarget, STRING(m_target), this, pActivator, pCaller); + } + } + else + { + pTarget = gEntList.FindEntityGeneric(NULL, STRING(m_target), this, pActivator, pCaller); + if (pTarget) + { + pNPC = pTarget->MyNPCPointer(); + if (!pNPC) + { + Warning("%s tried to grab %s, but it is not a NPC!\n", GetDebugName(), pTarget->GetDebugName()); + pTarget = gEntList.FindEntityGeneric(pTarget, STRING(m_target), this, pActivator, pCaller); + return; + } + + if (!m_bTargetType) + { + pFaceTarget = gEntList.FindEntityByNameNearest(STRING(m_iszFaceTarget), pTarget->GetLocalOrigin(), 0, this, pActivator, pCaller); + if (pFaceTarget) + { + pNPC->GetMotor()->AddFacingTarget(pFaceTarget, m_flImportance, m_flDuration); + m_OnBeginFace.FireOutput(pFaceTarget, pTarget); + } + } + else + { + pNPC->GetMotor()->AddFacingTarget(position, m_flImportance, m_flDuration); + } + } + } +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : +// Output : +//----------------------------------------------------------------------------- +void CAI_ScriptedFace::InputBeginFacing( inputdata_t &inputdata ) +{ + Begin(inputdata.pActivator, inputdata.pCaller); +} + + + +//----------------------------------------------------------------------------- +// This isn't exclusive to NPCs, so it could be moved if needed. +//----------------------------------------------------------------------------- +class CScriptedSound : public CPointEntity +{ +public: + DECLARE_CLASS( CScriptedSound, CPointEntity ); + DECLARE_DATADESC(); + + void Precache(); + + CBaseEntity *GetTarget(inputdata_t &inputdata); + + // Input handlers + void InputPlaySound( inputdata_t &inputdata ); + void InputPlaySoundOnEntity( inputdata_t &inputdata ); + void InputStopSound( inputdata_t &inputdata ); + void InputSetSound( inputdata_t &inputdata ); + +private: + string_t m_message; + + bool m_bGrabAll; +}; + + +BEGIN_DATADESC( CScriptedSound ) + + DEFINE_KEYFIELD( m_message, FIELD_STRING, "message" ), + DEFINE_KEYFIELD( m_bGrabAll, FIELD_BOOLEAN, "GrabAll" ), + + // Inputs + DEFINE_INPUTFUNC(FIELD_VOID, "PlaySound", InputPlaySound), + DEFINE_INPUTFUNC(FIELD_EHANDLE, "PlaySoundOnEntity", InputPlaySoundOnEntity), + DEFINE_INPUTFUNC(FIELD_VOID, "StopSound", InputStopSound), + DEFINE_INPUTFUNC(FIELD_STRING, "SetSound", InputSetSound), + +END_DATADESC() + + + +LINK_ENTITY_TO_CLASS( scripted_sound, CScriptedSound ); + +//----------------------------------------------------------------------------- +// Purpose: +// Input : +// Output : +//----------------------------------------------------------------------------- +void CScriptedSound::Precache() +{ + //PrecacheScriptSound(STRING(m_message)); + + BaseClass::Precache(); +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : +// Output : +//----------------------------------------------------------------------------- +CBaseEntity *CScriptedSound::GetTarget(inputdata_t &inputdata) +{ + CBaseEntity *pEntity = NULL; + if (m_target == NULL_STRING) + { + // Use this as the default source entity + pEntity = this; + m_bGrabAll = false; + } + else + { + pEntity = gEntList.FindEntityGeneric(NULL, STRING(m_target), this, inputdata.pActivator, inputdata.pCaller); + } + + return pEntity; +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : +// Output : +//----------------------------------------------------------------------------- +void CScriptedSound::InputPlaySound( inputdata_t &inputdata ) +{ + PrecacheScriptSound(STRING(m_message)); + + CBaseEntity *pEntity = GetTarget(inputdata); + const char *sound = STRING(m_message); + if (m_bGrabAll) + { + //if (pEntity) + //{ + // pEntity->PrecacheScriptSound(sound); + //} + + while (pEntity) + { + pEntity->EmitSound(sound); + pEntity = gEntList.FindEntityGeneric(pEntity, STRING(m_target), this, inputdata.pActivator, inputdata.pCaller); + } + } + else if (pEntity) + { + //pEntity->PrecacheScriptSound(sound); + pEntity->EmitSound(sound); + } + else + { + Warning("%s unable to find target entity %s!\n", GetDebugName(), STRING(m_target)); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : +// Output : +//----------------------------------------------------------------------------- +void CScriptedSound::InputPlaySoundOnEntity( inputdata_t &inputdata ) +{ + inputdata.value.Entity()->PrecacheScriptSound(STRING(m_message)); + inputdata.value.Entity()->EmitSound(STRING(m_message)); +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : +// Output : +//----------------------------------------------------------------------------- +void CScriptedSound::InputStopSound( inputdata_t &inputdata ) +{ + CBaseEntity *pEntity = GetTarget(inputdata); + const char *sound = STRING(m_message); + if (m_bGrabAll) + { + while (pEntity) + { + pEntity->StopSound(sound); + pEntity = gEntList.FindEntityGeneric(pEntity, STRING(m_target), this, inputdata.pActivator, inputdata.pCaller); + } + } + else if (pEntity) + { + pEntity->StopSound(sound); + } + else + { + Warning("%s unable to find target entity %s!\n", GetDebugName(), STRING(m_target)); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : +// Output : +//----------------------------------------------------------------------------- +void CScriptedSound::InputSetSound( inputdata_t &inputdata ) +{ + PrecacheScriptSound(inputdata.value.String()); + m_message = inputdata.value.StringID(); +} +#endif + // HACKHACK: This is a little expensive with the dynamic_cast<> and all, but it lets us solve diff --git a/sp/src/game/server/scripted.h b/sp/src/game/server/scripted.h index 574fcbd5..50f962f3 100644 --- a/sp/src/game/server/scripted.h +++ b/sp/src/game/server/scripted.h @@ -95,7 +95,11 @@ public: bool FindEntity( void ); void StartScript( void ); void FireScriptEvent( int nEvent ); +#ifdef MAPBASE + void OnBeginSequence( CBaseEntity *pActor ); +#else void OnBeginSequence( void ); +#endif void SetTarget( CBaseEntity *pTarget ) { m_hTargetEnt = pTarget; }; CBaseEntity *GetTarget( void ) { return m_hTargetEnt; }; @@ -104,6 +108,9 @@ public: void InputBeginSequence( inputdata_t &inputdata ); void InputCancelSequence( inputdata_t &inputdata ); void InputMoveToPosition( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetTarget( inputdata_t &inputdata ); +#endif bool IsTimeToStart( void ); bool IsWaitingForBegin( void ); @@ -223,6 +230,11 @@ private: EHANDLE m_hInteractionRelativeEntity; int m_iPlayerDeathBehavior; + +#ifdef MAPBASE + // !activator functionality + EHANDLE m_hActivator; +#endif }; diff --git a/sp/src/game/server/server_base.vpc b/sp/src/game/server/server_base.vpc index f1c3c835..6f3abc5e 100644 --- a/sp/src/game/server/server_base.vpc +++ b/sp/src/game/server/server_base.vpc @@ -18,6 +18,9 @@ $include "$SRCDIR\vpc_scripts\protobuf_builder.vpc" $Include "$SRCDIR\vpc_scripts\source_replay.vpc" [$TF] $Include "$SRCDIR\game\protobuf_include.vpc" +// Mapbase stuff +$Include "$SRCDIR\game\server\server_mapbase.vpc" [$MAPBASE] + $Configuration "Debug" { $General diff --git a/sp/src/game/server/server_episodic.vpc b/sp/src/game/server/server_episodic.vpc index 81c9297b..7c7ca5da 100644 --- a/sp/src/game/server/server_episodic.vpc +++ b/sp/src/game/server/server_episodic.vpc @@ -264,8 +264,8 @@ $Project "Server (Episodic)" $File "hl2\weapon_smg1.cpp" $File "episodic\weapon_striderbuster.cpp" $File "episodic\weapon_striderbuster.h" - $File "hl2\weapon_stunstick.cpp" - $File "hl2\weapon_stunstick.h" + $File "hl2\weapon_stunstick.cpp" [!$MAPBASE] // See server_mapbase.vpc + $File "hl2\weapon_stunstick.h" [!$MAPBASE] // See server_mapbase.vpc $File "episodic\ep1_gamestats.h" $File "episodic\ep2_gamestats.h" $File "episodic\ep1_gamestats.cpp" \ diff --git a/sp/src/game/server/server_hl2.vpc b/sp/src/game/server/server_hl2.vpc index 0fc2e64b..d5b83f45 100644 --- a/sp/src/game/server/server_hl2.vpc +++ b/sp/src/game/server/server_hl2.vpc @@ -247,8 +247,8 @@ $Project "Server (HL2)" $File "hl2\weapon_rpg.h" $File "hl2\weapon_shotgun.cpp" $File "hl2\weapon_smg1.cpp" - $File "hl2\weapon_stunstick.cpp" - $File "hl2\weapon_stunstick.h" + $File "hl2\weapon_stunstick.cpp" [!$MAPBASE] // See server_mapbase.vpc + $File "hl2\weapon_stunstick.h" [!$MAPBASE] // See server_mapbase.vpc $Folder "Unused" { diff --git a/sp/src/game/server/server_mapbase.vpc b/sp/src/game/server/server_mapbase.vpc new file mode 100644 index 00000000..9cc3c160 --- /dev/null +++ b/sp/src/game/server/server_mapbase.vpc @@ -0,0 +1,82 @@ +//----------------------------------------------------------------------------- +// SERVER_MAPBASE.VPC +// +// Project Base Script +//----------------------------------------------------------------------------- + +$Configuration +{ + $Compiler + { + $PreprocessorDefinitions "$BASE;ASW_PROJECTED_TEXTURES;DYNAMIC_RTT_SHADOWS" + } +} + +$Project +{ + $Folder "Source Files" + { + $File "logic_random_outputs.cpp" + $File "point_entity_finder.cpp" + $File "env_projectedtexture.h" + $File "env_global_light.cpp" + $File "skyboxswapper.cpp" + + $Folder "Mapbase" + { + $File "$SRCDIR\game\shared\mapbase\mapbase_shared.cpp" + $File "$SRCDIR\game\shared\mapbase\mapbase_rpc.cpp" + $File "$SRCDIR\game\shared\mapbase\MapEdit.cpp" + $File "$SRCDIR\game\shared\mapbase\MapEdit.h" + + $File "mapbase\ai_grenade.cpp" + $File "mapbase\ai_grenade.h" + $File "mapbase\ai_monitor.cpp" + $File "mapbase\ai_weaponmodifier.cpp" + $File "mapbase\closecaption_entity.cpp" + $File "mapbase\datadesc_mod.cpp" + $File "mapbase\datadesc_mod.h" + $File "mapbase\expandedrs_combine.h" + $File "mapbase\func_clientclip.cpp" + $File "mapbase\GlobalStrings.cpp" + $File "mapbase\GlobalStrings.h" + $File "mapbase\logic_externaldata.cpp" + $File "mapbase\logic_skill.cpp" + $File "mapbase\matchers.h" + $File "mapbase\point_advanced_finder.cpp" + $File "mapbase\point_copy_size.cpp" + $File "mapbase\point_damageinfo.cpp" + $File "mapbase\point_entity_replace.cpp" + //$File "mapbase\point_physics_control.cpp" // Backlogged + $File "mapbase\point_projectile.cpp" + $File "mapbase\point_radiation_source.cpp" + $File "mapbase\SystemConvarMod.cpp" + $File "mapbase\SystemConvarMod.h" + $File "mapbase\variant_tools.h" + + $File "mapbase\logic_eventlistener.cpp" + $File "mapbase\logic_register_activator.cpp" + } + + $Folder "HL2 DLL" + { + // Original stunstick files are conditional'd out in the HL2 VPCs + $File "$SRCDIR\game\shared\hl2mp\weapon_stunstick.cpp" + $File "$SRCDIR\game\shared\hl2mp\weapon_stunstick.h" + } + + $Folder "HL2MP" + { + $Folder "Weapons" + { + $File "hl2mp\grenade_satchel.cpp" + $File "hl2mp\grenade_satchel.h" + $File "hl2mp\grenade_tripmine.cpp" + $File "hl2mp\grenade_tripmine.h" + + $File "$SRCDIR\game\shared\hl2mp\weapon_slam.cpp" + $File "$SRCDIR\game\shared\hl2mp\weapon_slam.h" + } + } + } +} diff --git a/sp/src/game/server/shadowcontrol.cpp b/sp/src/game/server/shadowcontrol.cpp index 36c23c28..8db9665d 100644 --- a/sp/src/game/server/shadowcontrol.cpp +++ b/sp/src/game/server/shadowcontrol.cpp @@ -40,6 +40,9 @@ private: CNetworkColor32( m_shadowColor ); CNetworkVar( float, m_flShadowMaxDist ); CNetworkVar( bool, m_bDisableShadows ); +#ifdef MAPBASE + CNetworkVar( bool, m_bEnableLocalLightShadows ); +#endif }; LINK_ENTITY_TO_CLASS(shadow_control, CShadowControl); @@ -48,12 +51,18 @@ BEGIN_DATADESC( CShadowControl ) DEFINE_KEYFIELD( m_flShadowMaxDist, FIELD_FLOAT, "distance" ), DEFINE_KEYFIELD( m_bDisableShadows, FIELD_BOOLEAN, "disableallshadows" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bEnableLocalLightShadows, FIELD_BOOLEAN, "enableshadowsfromlocallights" ), +#endif // Inputs DEFINE_INPUT( m_shadowColor, FIELD_COLOR32, "color" ), DEFINE_INPUT( m_shadowDirection, FIELD_VECTOR, "direction" ), DEFINE_INPUT( m_flShadowMaxDist, FIELD_FLOAT, "SetDistance" ), DEFINE_INPUT( m_bDisableShadows, FIELD_BOOLEAN, "SetShadowsDisabled" ), +#ifdef MAPBASE + DEFINE_INPUT( m_bEnableLocalLightShadows, FIELD_BOOLEAN, "SetShadowsFromLocalLightsEnabled" ), +#endif DEFINE_INPUTFUNC( FIELD_STRING, "SetAngles", InputSetAngles ), @@ -62,9 +71,17 @@ END_DATADESC() IMPLEMENT_SERVERCLASS_ST_NOBASE(CShadowControl, DT_ShadowControl) SendPropVector(SENDINFO(m_shadowDirection), -1, SPROP_NOSCALE ), +#ifdef MAPBASE + /*SendPropInt(SENDINFO(m_shadowColor), 32, SPROP_UNSIGNED, SendProxy_Color32ToInt32 ),*/ + SendPropInt(SENDINFO(m_shadowColor), 32, SPROP_UNSIGNED, SendProxy_Color32ToInt ), +#else SendPropInt(SENDINFO(m_shadowColor), 32, SPROP_UNSIGNED), +#endif SendPropFloat(SENDINFO(m_flShadowMaxDist), 0, SPROP_NOSCALE ), SendPropBool(SENDINFO(m_bDisableShadows)), +#ifdef MAPBASE + SendPropBool(SENDINFO(m_bEnableLocalLightShadows)), +#endif END_SEND_TABLE() @@ -74,6 +91,9 @@ CShadowControl::CShadowControl() m_flShadowMaxDist = 50.0f; m_shadowColor.Init( 64, 64, 64, 0 ); m_bDisableShadows = false; +#ifdef MAPBASE + m_bEnableLocalLightShadows = false; +#endif } diff --git a/sp/src/game/server/skyboxswapper.cpp b/sp/src/game/server/skyboxswapper.cpp new file mode 100644 index 00000000..16aa4f1f --- /dev/null +++ b/sp/src/game/server/skyboxswapper.cpp @@ -0,0 +1,80 @@ +//=========== Copyright (c) Valve Corporation, All rights reserved. =========== +// +// Simple entity to switch the map's 2D skybox texture when triggered. +// +//============================================================================= + +#include "cbase.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + + +//----------------------------------------------------------------------------- +// CSkyboxSwapper +//----------------------------------------------------------------------------- +class CSkyboxSwapper : public CServerOnlyPointEntity +{ + DECLARE_CLASS( CSkyboxSwapper, CServerOnlyPointEntity ); +public: + DECLARE_DATADESC(); + + virtual void Spawn( void ); + virtual void Precache( void ); + + void InputTrigger( inputdata_t &inputdata ); + +protected: + string_t m_iszSkyboxName; +}; + +LINK_ENTITY_TO_CLASS(skybox_swapper, CSkyboxSwapper); + +BEGIN_DATADESC( CSkyboxSwapper ) + DEFINE_KEYFIELD( m_iszSkyboxName, FIELD_STRING, "SkyboxName" ), + // Inputs + DEFINE_INPUTFUNC(FIELD_VOID, "Trigger", InputTrigger), +END_DATADESC() + + +//----------------------------------------------------------------------------- +// Purpose: not much +//----------------------------------------------------------------------------- +void CSkyboxSwapper::Spawn( void ) +{ + Precache(); +} + +//----------------------------------------------------------------------------- +// Purpose: Precache the skybox materials. +//----------------------------------------------------------------------------- +void CSkyboxSwapper::Precache( void ) +{ + if ( Q_strlen( m_iszSkyboxName.ToCStr() ) == 0 ) + { + Warning( "skybox_swapper (%s) has no skybox specified!\n", GetEntityName() ); + return; + } + + char name[ MAX_PATH ]; + char *skyboxsuffix[ 6 ] = { "rt", "bk", "lf", "ft", "up", "dn" }; + for ( int i = 0; i < 6; i++ ) + { + Q_snprintf( name, sizeof( name ), "skybox/%s%s", m_iszSkyboxName.ToCStr(), skyboxsuffix[i] ); + PrecacheMaterial( name ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Input handler that triggers the skybox swap. +//----------------------------------------------------------------------------- +void CSkyboxSwapper::InputTrigger( inputdata_t &inputdata ) +{ + static ConVarRef skyname( "sv_skyname", false ); + if ( !skyname.IsValid() ) + { + Warning( "skybox_swapper (%s) trigger input failed - cannot find 'sv_skyname' convar!\n", GetEntityName() ); + return; + } + skyname.SetValue( m_iszSkyboxName.ToCStr() ); +} \ No newline at end of file diff --git a/sp/src/game/server/sound.cpp b/sp/src/game/server/sound.cpp index 160ba1c0..19db8076 100644 --- a/sp/src/game/server/sound.cpp +++ b/sp/src/game/server/sound.cpp @@ -182,6 +182,9 @@ public: void InputVolume( inputdata_t &inputdata ); void InputFadeIn( inputdata_t &inputdata ); void InputFadeOut( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetSound( inputdata_t &inputdata ); +#endif DECLARE_DATADESC(); @@ -197,6 +200,10 @@ public: string_t m_sSourceEntName; EHANDLE m_hSoundSource; // entity from which the sound comes int m_nSoundSourceEntIndex; // In case the entity goes away before we finish stopping the sound... + +#ifdef MAPBASE + int m_iSoundFlags; +#endif }; LINK_ENTITY_TO_CLASS( ambient_generic, CAmbientGeneric ); @@ -210,6 +217,10 @@ BEGIN_DATADESC( CAmbientGeneric ) // DEFINE_FIELD( m_hSoundSource, EHANDLE ), // DEFINE_FIELD( m_nSoundSourceEntIndex, FIELD_INTERGER ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_iSoundFlags, FIELD_INTEGER, "soundflags" ), +#endif + DEFINE_FIELD( m_flMaxRadius, FIELD_FLOAT ), DEFINE_FIELD( m_fActive, FIELD_BOOLEAN ), DEFINE_FIELD( m_fLooping, FIELD_BOOLEAN ), @@ -233,6 +244,9 @@ BEGIN_DATADESC( CAmbientGeneric ) DEFINE_INPUTFUNC(FIELD_FLOAT, "Volume", InputVolume ), DEFINE_INPUTFUNC(FIELD_FLOAT, "FadeIn", InputFadeIn ), DEFINE_INPUTFUNC(FIELD_FLOAT, "FadeOut", InputFadeOut ), +#ifdef MAPBASE + DEFINE_INPUTFUNC(FIELD_STRING, "SetSound", InputSetSound ), +#endif END_DATADESC() @@ -419,6 +433,24 @@ void CAmbientGeneric::InputFadeOut( inputdata_t &inputdata ) SetNextThink( gpGlobals->curtime + 0.1f ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CAmbientGeneric::InputSetSound( inputdata_t &inputdata ) +{ + m_iszSound = inputdata.value.StringID(); + if (STRING(m_iszSound)[0] != '!') + { + PrecacheScriptSound(STRING(m_iszSound)); + } + + // Try to refresh the sound + if (m_fActive) + SendSound(SND_NOFLAGS); +} +#endif + void CAmbientGeneric::Precache( void ) { @@ -858,6 +890,19 @@ void CAmbientGeneric::InputPlaySound( inputdata_t &inputdata ) { //Adrian: Stop our current sound before starting a new one! SendSound( SND_STOP ); + +#ifdef MAPBASE + // Procedural handling like !activator + if (STRING(m_sSourceEntName)[0] == '!') + { + CBaseEntity *pEntity = gEntList.FindEntityProcedural(STRING(m_sSourceEntName), this, inputdata.pActivator, inputdata.pCaller); + if (pEntity) + { + m_hSoundSource = pEntity; + m_nSoundSourceEntIndex = pEntity->entindex(); + } + } +#endif ToggleSound(); } @@ -877,6 +922,45 @@ void CAmbientGeneric::InputStopSound( inputdata_t &inputdata ) void CAmbientGeneric::SendSound( SoundFlags_t flags) { +#ifdef MAPBASE + int iFlags = flags != SND_STOP ? ((int)flags | m_iSoundFlags) : flags; + char *szSoundFile = (char *)STRING( m_iszSound ); + CBaseEntity* pSoundSource = m_hSoundSource; + if ( pSoundSource ) + { + if ( iFlags & SND_STOP ) + { + UTIL_EmitAmbientSound(pSoundSource->GetSoundSourceIndex(), pSoundSource->GetAbsOrigin(), szSoundFile, + 0, SNDLVL_NONE, iFlags, 0); + + m_fActive = false; + } + else + { + UTIL_EmitAmbientSound(pSoundSource->GetSoundSourceIndex(), pSoundSource->GetAbsOrigin(), szSoundFile, + (m_dpv.vol * 0.01), m_iSoundLevel, iFlags, m_dpv.pitch); + + // Only mark active if this is a looping sound. If not looping, each + // trigger will cause the sound to play. If the sound is still + // playing from a previous trigger press, it will be shut off + // and then restarted. + + if (m_fLooping) + m_fActive = true; + } + } + else + { + if ( ( iFlags & SND_STOP ) && + ( m_nSoundSourceEntIndex != -1 ) ) + { + UTIL_EmitAmbientSound(m_nSoundSourceEntIndex, GetAbsOrigin(), szSoundFile, + 0, SNDLVL_NONE, iFlags, 0); + + m_fActive = false; + } + } +#else char *szSoundFile = (char *)STRING( m_iszSound ); CBaseEntity* pSoundSource = m_hSoundSource; if ( pSoundSource ) @@ -901,6 +985,7 @@ void CAmbientGeneric::SendSound( SoundFlags_t flags) 0, SNDLVL_NONE, flags, 0); } } +#endif } @@ -909,6 +994,19 @@ void CAmbientGeneric::SendSound( SoundFlags_t flags) //----------------------------------------------------------------------------- void CAmbientGeneric::InputToggleSound( inputdata_t &inputdata ) { +#ifdef MAPBASE + // Procedural handling like !activator + if (STRING(m_sSourceEntName)[0] == '!') + { + CBaseEntity *pEntity = gEntList.FindEntityProcedural(STRING(m_sSourceEntName), this, inputdata.pActivator, inputdata.pCaller); + if (pEntity) + { + m_hSoundSource = pEntity; + m_nSoundSourceEntIndex = pEntity->entindex(); + } + } +#endif + ToggleSound(); } diff --git a/sp/src/game/server/soundent.cpp b/sp/src/game/server/soundent.cpp index 4a735637..571e66d1 100644 --- a/sp/src/game/server/soundent.cpp +++ b/sp/src/game/server/soundent.cpp @@ -769,7 +769,11 @@ void CAISound::InputInsertSound( inputdata_t &inputdata ) if( m_iszProxyEntityName != NULL_STRING ) { +#ifdef MAPBASE + CBaseEntity *pProxy = gEntList.FindEntityByName( NULL, m_iszProxyEntityName, this, inputdata.pActivator, inputdata.pCaller ); +#else CBaseEntity *pProxy = gEntList.FindEntityByName( NULL, m_iszProxyEntityName ); +#endif if( pProxy ) { @@ -781,7 +785,26 @@ void CAISound::InputInsertSound( inputdata_t &inputdata ) } } +#ifdef MAPBASE + EHANDLE hOwner = this; + if (m_target != NULL_STRING) + { + CBaseEntity *pProxy = gEntList.FindEntityByName( NULL, m_target, this, inputdata.pActivator, inputdata.pCaller ); + + if( pProxy ) + { + hOwner = pProxy; + } + else + { + DevWarning("Warning- ai_sound cannot find owner entity named '%s'. Using self.\n", STRING(m_target) ); + } + } + + g_pSoundEnt->InsertSound( m_iSoundType | m_iSoundContext, vecLocation, iVolume, m_flDuration, hOwner ); +#else g_pSoundEnt->InsertSound( m_iSoundType, vecLocation, iVolume, m_flDuration, this ); +#endif } void CAISound::InputEmitAISound( inputdata_t &inputdata ) @@ -790,7 +813,11 @@ void CAISound::InputEmitAISound( inputdata_t &inputdata ) if( m_iszProxyEntityName != NULL_STRING ) { +#ifdef MAPBASE + CBaseEntity *pProxy = gEntList.FindEntityByName( NULL, m_iszProxyEntityName, this, inputdata.pActivator, inputdata.pCaller ); +#else CBaseEntity *pProxy = gEntList.FindEntityByName( NULL, m_iszProxyEntityName ); +#endif if( pProxy ) { @@ -802,7 +829,26 @@ void CAISound::InputEmitAISound( inputdata_t &inputdata ) } } +#ifdef MAPBASE + EHANDLE hOwner = this; + if (m_target != NULL_STRING) + { + CBaseEntity *pProxy = gEntList.FindEntityByName( NULL, m_target, this, inputdata.pActivator, inputdata.pCaller ); + + if( pProxy ) + { + hOwner = pProxy; + } + else + { + DevWarning("Warning- ai_sound cannot find owner entity named '%s'. Using self.\n", STRING(m_target) ); + } + } + + g_pSoundEnt->InsertSound( m_iSoundType | m_iSoundContext, vecLocation, m_iVolume, m_flDuration, hOwner ); +#else g_pSoundEnt->InsertSound( m_iSoundType | m_iSoundContext, vecLocation, m_iVolume, m_flDuration, this ); +#endif } diff --git a/sp/src/game/server/soundent.h b/sp/src/game/server/soundent.h index 4de733f4..670af8b2 100644 --- a/sp/src/game/server/soundent.h +++ b/sp/src/game/server/soundent.h @@ -57,7 +57,19 @@ enum SOUND_CONTEXT_ALLIES_ONLY = 0x10000000, // Only player allies can hear this sound SOUND_CONTEXT_PLAYER_VEHICLE = 0x20000000, // HACK: need this because we're not treating the SOUND_xxx values as true bit values! See switch in OnListened. +#ifdef MAPBASE + // You know, I wouldn't mind this approach of leaving types and contexts on the same int + // since there can be so many CSounds at any given time. + // It's just that there's very little room to expand and a lot of the contexts are very specific and/or useless. + // If this doesn't work, replace SOUND_CONTEXT_PLAYER_VEHICLE with owner server vehicle checks. + + // Only heard by NPCs the owner likes. Needed for shared grenade code. + SOUND_CONTEXT_OWNER_ALLIES = 0x40000000, + + ALL_CONTEXTS = 0x3FF00000, +#else ALL_CONTEXTS = 0xFFF00000, +#endif ALL_SCENTS = SOUND_CARCASS | SOUND_MEAT | SOUND_GARBAGE, diff --git a/sp/src/game/server/soundscape_system.cpp b/sp/src/game/server/soundscape_system.cpp index 29b29402..fc81579f 100644 --- a/sp/src/game/server/soundscape_system.cpp +++ b/sp/src/game/server/soundscape_system.cpp @@ -136,6 +136,16 @@ bool CSoundscapeSystem::Init() mapSoundscapeFilename = UTIL_VarArgs( "scripts/soundscapes_%s.txt", mapname ); } +#ifdef MAPBASE + if (filesystem->FileExists(UTIL_VarArgs("maps/%s_soundscapes.txt", mapname))) + { + // A Mapbase-specific file exists. Load that instead. + // Any additional soundscape files, like the original scripts/soundscapes version, + // could be loaded through #include and/or #base. + mapSoundscapeFilename = UTIL_VarArgs("maps/%s_soundscapes.txt", mapname); + } +#endif + KeyValues *manifest = new KeyValues( SOUNDSCAPE_MANIFEST_FILE ); if ( filesystem->LoadKeyValues( *manifest, IFileSystem::TYPE_SOUNDSCAPE, SOUNDSCAPE_MANIFEST_FILE, "GAME" ) ) { diff --git a/sp/src/game/server/subs.cpp b/sp/src/game/server/subs.cpp index b2bf003f..0a37e4c1 100644 --- a/sp/src/game/server/subs.cpp +++ b/sp/src/game/server/subs.cpp @@ -38,6 +38,11 @@ void CNullEntity::Spawn( void ) } LINK_ENTITY_TO_CLASS(info_null,CNullEntity); +#ifdef MAPBASE +// Eh, good enough. +LINK_ENTITY_TO_CLASS(func_null,CNullEntity); +#endif + class CBaseDMStart : public CPointEntity { public: diff --git a/sp/src/game/server/triggers.cpp b/sp/src/game/server/triggers.cpp index 295e826a..8d0bf729 100644 --- a/sp/src/game/server/triggers.cpp +++ b/sp/src/game/server/triggers.cpp @@ -38,6 +38,10 @@ #include "hl2_player.h" #endif +#ifdef MAPBASE +#include "ai_hint.h" +#endif + // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -102,6 +106,12 @@ BEGIN_DATADESC( CBaseTrigger ) DEFINE_KEYFIELD( m_bDisabled, FIELD_BOOLEAN, "StartDisabled" ), DEFINE_UTLVECTOR( m_hTouchingEntities, FIELD_EHANDLE ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_flWait, FIELD_FLOAT, "wait" ), + DEFINE_FIELD( m_hActivator, FIELD_EHANDLE ), + DEFINE_KEYFIELD( m_sMaster, FIELD_STRING, "master" ), +#endif + // Inputs DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), @@ -265,8 +275,11 @@ void CBaseTrigger::TouchTest( void ) { if ( m_hTouchingEntities.Count() !=0 ) { - +#ifdef MAPBASE + m_OnTouching.FireOutput( m_hTouchingEntities[0], this ); +#else m_OnTouching.FireOutput( this, this ); +#endif } else { @@ -361,6 +374,10 @@ bool CBaseTrigger::PassesTriggerFilters(CBaseEntity *pOther) (HasSpawnFlags(SF_TRIGGER_ALLOW_NPCS) && (pOther->GetFlags() & FL_NPC)) || (HasSpawnFlags(SF_TRIGGER_ALLOW_PUSHABLES) && FClassnameIs(pOther, "func_pushable")) || (HasSpawnFlags(SF_TRIGGER_ALLOW_PHYSICS) && pOther->GetMoveType() == MOVETYPE_VPHYSICS) +#ifdef MAPBASE + || + (HasSpawnFlags(SF_TRIGGER_ALLOW_ITEMS) && pOther->GetMoveType() == MOVETYPE_FLYGRAVITY) +#endif #if defined( HL2_EPISODIC ) || defined( TF_DLL ) || ( HasSpawnFlags(SF_TRIG_TOUCH_DEBRIS) && @@ -643,6 +660,9 @@ BEGIN_DATADESC( CTriggerHurt ) DEFINE_KEYFIELD( m_bitsDamageInflict, FIELD_INTEGER, "damagetype" ), DEFINE_KEYFIELD( m_damageModel, FIELD_INTEGER, "damagemodel" ), DEFINE_KEYFIELD( m_bNoDmgForce, FIELD_BOOLEAN, "nodmgforce" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_flHurtRate, FIELD_FLOAT, "hurtrate" ), +#endif DEFINE_FIELD( m_flLastDmgTime, FIELD_TIME ), DEFINE_FIELD( m_flDmgResetTime, FIELD_TIME ), @@ -704,7 +724,11 @@ void CTriggerHurt::RadiationThink( void ) } float dt = gpGlobals->curtime - m_flLastDmgTime; +#ifdef MAPBASE + if ( dt >= m_flHurtRate ) +#else if ( dt >= 0.5 ) +#endif { HurtAllTouchers( dt ); } @@ -771,7 +795,11 @@ void CTriggerHurt::HurtThink() } else { +#ifdef MAPBASE + SetNextThink( gpGlobals->curtime + m_flHurtRate ); +#else SetNextThink( gpGlobals->curtime + 0.5f ); +#endif } } @@ -866,6 +894,24 @@ void CTriggerHurt::Touch( CBaseEntity *pOther ) } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CTriggerHurt::KeyValue( const char *szKeyName, const char *szValue ) +{ + // Additional OR flags + if (FStrEq( szKeyName, "damageor" ) || FStrEq( szKeyName, "damagepresets" )) + { + m_bitsDamageInflict |= atoi(szValue); + } + else + return BaseClass::KeyValue( szKeyName, szValue ); + + return true; +} +#endif + // ################################################################################## // >> TriggerMultiple @@ -1726,7 +1772,11 @@ struct collidelist_t // NOTE: This routine is relatively slow. If you need to use it for per-frame work, consider that fact. // UNDONE: Expand this to the full matrix of solid types on each side and move into enginetrace +#ifdef MAPBASE // Other files may use this +bool TestEntityTriggerIntersection_Accurate( CBaseEntity *pTrigger, CBaseEntity *pEntity ) +#else static bool TestEntityTriggerIntersection_Accurate( CBaseEntity *pTrigger, CBaseEntity *pEntity ) +#endif { Assert( pTrigger->GetSolid() == SOLID_BSP ); @@ -2414,6 +2464,46 @@ void CTriggerTeleport::Touch( CBaseEntity *pOther ) LINK_ENTITY_TO_CLASS( info_teleport_destination, CPointEntity ); +//----------------------------------------------------------------------------- +// Teleport Relative trigger +//----------------------------------------------------------------------------- +class CTriggerTeleportRelative : public CBaseTrigger +{ +public: + DECLARE_CLASS(CTriggerTeleportRelative, CBaseTrigger); + + virtual void Spawn( void ) OVERRIDE; + virtual void Touch( CBaseEntity *pOther ) OVERRIDE; + + Vector m_TeleportOffset; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS( trigger_teleport_relative, CTriggerTeleportRelative ); +BEGIN_DATADESC( CTriggerTeleportRelative ) + DEFINE_KEYFIELD( m_TeleportOffset, FIELD_VECTOR, "teleportoffset" ) +END_DATADESC() + + +void CTriggerTeleportRelative::Spawn( void ) +{ + InitTrigger(); +} + +void CTriggerTeleportRelative::Touch( CBaseEntity *pOther ) +{ + if ( !PassesTriggerFilters(pOther) ) + { + return; + } + + const Vector finalPos = m_TeleportOffset + WorldSpaceCenter(); + const Vector *momentum = &vec3_origin; + + pOther->Teleport( &finalPos, NULL, momentum ); +} + //----------------------------------------------------------------------------- // Purpose: Saves the game when the player touches the trigger. Can be enabled or disabled //----------------------------------------------------------------------------- @@ -2685,6 +2775,9 @@ private: string_t m_strNewHintGroup; float m_flRadius; bool m_bHintGroupNavLimiting; +#ifdef MAPBASE + bool m_bChangeHints; +#endif }; LINK_ENTITY_TO_CLASS( ai_changehintgroup, CAI_ChangeHintGroup ); @@ -2695,6 +2788,9 @@ BEGIN_DATADESC( CAI_ChangeHintGroup ) DEFINE_KEYFIELD( m_strNewHintGroup, FIELD_STRING, "NewHintGroup" ), DEFINE_KEYFIELD( m_flRadius, FIELD_FLOAT, "Radius" ), DEFINE_KEYFIELD( m_bHintGroupNavLimiting, FIELD_BOOLEAN, "hintlimiting" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bChangeHints, FIELD_BOOLEAN, "changehints" ), +#endif DEFINE_INPUTFUNC( FIELD_VOID, "Activate", InputActivate ), @@ -2751,6 +2847,35 @@ void CAI_ChangeHintGroup::InputActivate( inputdata_t &inputdata ) { pTarget->SetHintGroup( m_strNewHintGroup, m_bHintGroupNavLimiting ); } + +#ifdef MAPBASE + if (m_bChangeHints) + { + AIHintIter_t iter; + CAI_Hint *pHint = CAI_HintManager::GetFirstHint( &iter ); + while ( pHint != NULL ) + { + if ((GetAbsOrigin() - pHint->GetAbsOrigin()).Length() < m_flRadius) + { + bool bValid = false; + switch (m_iSearchType) + { + case 0: { bValid = pHint->NameMatches(STRING(m_strSearchName)); } break; + case 1: { bValid = pHint->ClassMatches(STRING(m_strSearchName)); } break; + + // These should be pooled, so if they're the same hintgroup, they should point to the same string... + case 2: { bValid = pHint->GetGroup() == m_strSearchName; } break; + } + + if (bValid) + pHint->SetGroup(m_strNewHintGroup); + } + + // Move to the next + pHint = CAI_HintManager::GetNextHint( &iter ); + } + } +#endif } @@ -2763,6 +2888,10 @@ void CAI_ChangeHintGroup::InputActivate( inputdata_t &inputdata ) #define SF_CAMERA_PLAYER_SNAP_TO 16 #define SF_CAMERA_PLAYER_NOT_SOLID 32 #define SF_CAMERA_PLAYER_INTERRUPT 64 +#ifdef MAPBASE +#define SF_CAMERA_PLAYER_SETFOV 128 +#define SF_CAMERA_PLAYER_NEW_BEHAVIOR 256 // In case anyone or anything relied on the broken features +#endif //----------------------------------------------------------------------------- @@ -2773,12 +2902,21 @@ class CTriggerCamera : public CBaseEntity public: DECLARE_CLASS( CTriggerCamera, CBaseEntity ); +#ifdef MAPBASE + CTriggerCamera(); + + void UpdateOnRemove(); +#endif + void Spawn( void ); bool KeyValue( const char *szKeyName, const char *szValue ); void Enable( void ); void Disable( void ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void FollowTarget( void ); +#ifdef MAPBASE + void MoveThink( void ); +#endif void Move(void); // Always transmit to clients so they know where to move the view to @@ -2790,6 +2928,11 @@ public: void InputEnable( inputdata_t &inputdata ); void InputDisable( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputSetFOV( inputdata_t &inputdata ); + void InputSetFOVRate( inputdata_t &inputdata ); +#endif + private: EHANDLE m_hPlayer; EHANDLE m_hTarget; @@ -2808,6 +2951,12 @@ private: int m_state; Vector m_vecMoveDir; +#ifdef MAPBASE + float m_fov; + float m_fovSpeed; + + bool m_bDontSetPlayerView; +#endif string_t m_iszTargetAttachment; int m_iAttachmentIndex; @@ -2828,6 +2977,9 @@ private: private: COutputEvent m_OnEndFollow; +#ifdef MAPBASE + COutputEvent m_OnStartFollow; +#endif }; #if HL2_EPISODIC @@ -2864,16 +3016,57 @@ BEGIN_DATADESC( CTriggerCamera ) DEFINE_FIELD( m_nPlayerButtons, FIELD_INTEGER ), DEFINE_FIELD( m_nOldTakeDamage, FIELD_INTEGER ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_fov, FIELD_FLOAT, "fov" ), + DEFINE_KEYFIELD( m_fovSpeed, FIELD_FLOAT, "fov_rate" ), + + DEFINE_KEYFIELD( m_bDontSetPlayerView, FIELD_BOOLEAN, "DontSetPlayerView" ), +#endif + // Inputs DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetFOV", InputSetFOV ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetFOVRate", InputSetFOVRate ), +#endif // Function Pointers +#ifdef MAPBASE + DEFINE_FUNCTION( MoveThink ), +#endif DEFINE_FUNCTION( FollowTarget ), DEFINE_OUTPUT( m_OnEndFollow, "OnEndFollow" ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OnStartFollow, "OnStartFollow" ), +#endif END_DATADESC() +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CTriggerCamera::CTriggerCamera() +{ + m_fov = 90; + m_fovSpeed = 1; +} + +//------------------------------------------------------------------------------ +// Cleanup +//------------------------------------------------------------------------------ +void CTriggerCamera::UpdateOnRemove() +{ + if (m_state == USE_ON && HasSpawnFlags(SF_CAMERA_PLAYER_NEW_BEHAVIOR)) + { + Disable(); + } + + BaseClass::UpdateOnRemove(); +} +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -2958,6 +3151,29 @@ void CTriggerCamera::InputDisable( inputdata_t &inputdata ) Disable(); } +#ifdef MAPBASE +//------------------------------------------------------------------------------ +// Purpose: Input handler to set FOV. +//------------------------------------------------------------------------------ +void CTriggerCamera::InputSetFOV( inputdata_t &inputdata ) +{ + m_fov = inputdata.value.Float(); + + if ( m_state == USE_ON && m_hPlayer ) + { + ((CBasePlayer*)m_hPlayer.Get())->SetFOV( this, m_fov, m_fovSpeed ); + } +} + +//------------------------------------------------------------------------------ +// Purpose: Input handler to set FOV rate. +//------------------------------------------------------------------------------ +void CTriggerCamera::InputSetFOVRate( inputdata_t &inputdata ) +{ + m_fovSpeed = inputdata.value.Float(); +} +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -3034,6 +3250,20 @@ void CTriggerCamera::Enable( void ) m_bSnapToGoal = true; } +#ifdef MAPBASE + if ( HasSpawnFlags( SF_CAMERA_PLAYER_SETFOV ) ) + { + if ( pPlayer ) + { + if ( pPlayer->GetFOVOwner() && (/*FClassnameIs( pPlayer->GetFOVOwner(), "point_viewcontrol_multiplayer" ) ||*/ FClassnameIs( pPlayer->GetFOVOwner(), "point_viewcontrol" )) ) + { + pPlayer->ClearZoomOwner(); + } + pPlayer->SetFOV( this, m_fov, m_fovSpeed ); + } + } +#endif + if ( HasSpawnFlags(SF_CAMERA_PLAYER_TARGET ) ) { m_hTarget = m_hPlayer; @@ -3116,6 +3346,9 @@ void CTriggerCamera::Enable( void ) } +#ifdef MAPBASE + if (!m_bDontSetPlayerView) +#endif pPlayer->SetViewEntity( this ); // Hide the player's viewmodel @@ -3131,6 +3364,18 @@ void CTriggerCamera::Enable( void ) SetThink( &CTriggerCamera::FollowTarget ); SetNextThink( gpGlobals->curtime ); } +#ifdef MAPBASE + else if (m_pPath && HasSpawnFlags(SF_CAMERA_PLAYER_NEW_BEHAVIOR)) + { + // Move if we have a path + SetThink( &CTriggerCamera::MoveThink ); + SetNextThink( gpGlobals->curtime ); + } +#endif + +#ifdef MAPBASE + m_OnStartFollow.FireOutput( pPlayer, this ); +#endif m_moveDistance = 0; Move(); @@ -3143,6 +3388,34 @@ void CTriggerCamera::Enable( void ) //----------------------------------------------------------------------------- void CTriggerCamera::Disable( void ) { +#ifdef MAPBASE + if ( m_hPlayer ) + { + CBasePlayer *pBasePlayer = (CBasePlayer*)m_hPlayer.Get(); + + if ( pBasePlayer->IsAlive() ) + { + if ( HasSpawnFlags( SF_CAMERA_PLAYER_NOT_SOLID ) ) + { + pBasePlayer->RemoveSolidFlags( FSOLID_NOT_SOLID ); + } + + if (!m_bDontSetPlayerView) + pBasePlayer->SetViewEntity( NULL ); + + pBasePlayer->EnableControl(TRUE); + pBasePlayer->m_Local.m_bDrawViewmodel = true; + } + + if ( HasSpawnFlags( SF_CAMERA_PLAYER_SETFOV ) ) + { + pBasePlayer->SetFOV( this, 0, m_fovSpeed ); + } + + //return the player to previous takedamage state + m_hPlayer->m_takedamage = m_nOldTakeDamage; + } +#else if ( m_hPlayer && m_hPlayer->IsAlive() ) { if ( HasSpawnFlags( SF_CAMERA_PLAYER_NOT_SOLID ) ) @@ -3161,6 +3434,7 @@ void CTriggerCamera::Disable( void ) //return the player to previous takedamage state m_hPlayer->m_takedamage = m_nOldTakeDamage; } +#endif m_state = USE_OFF; m_flReturnTime = gpGlobals->curtime; @@ -3283,6 +3557,14 @@ void CTriggerCamera::FollowTarget( ) Move(); } +#ifdef MAPBASE +void CTriggerCamera::MoveThink() +{ + Move(); + SetNextThink( gpGlobals->curtime ); +} +#endif + void CTriggerCamera::Move() { if ( HasSpawnFlags( SF_CAMERA_PLAYER_INTERRUPT ) ) @@ -4384,6 +4666,82 @@ bool CBaseVPhysicsTrigger::PassesTriggerFilters( CBaseEntity *pOther ) if ( pOther->GetMoveType() != MOVETYPE_VPHYSICS && !pOther->IsPlayer() ) return false; +#ifdef MAPBASE + // Copied and pasted code from CBaseTrigger::PassesTriggerFilters(). + if ( HasSpawnFlags(SF_TRIGGER_ALLOW_ALL) || + (HasSpawnFlags(SF_TRIGGER_ALLOW_CLIENTS) && (pOther->GetFlags() & FL_CLIENT)) || + (HasSpawnFlags(SF_TRIGGER_ALLOW_NPCS) && (pOther->GetFlags() & FL_NPC)) || + (HasSpawnFlags(SF_TRIGGER_ALLOW_PUSHABLES) && FClassnameIs(pOther, "func_pushable")) || + (HasSpawnFlags(SF_TRIGGER_ALLOW_PHYSICS) && pOther->GetMoveType() == MOVETYPE_VPHYSICS) || + (HasSpawnFlags(SF_TRIGGER_ALLOW_ITEMS) && pOther->GetMoveType() == MOVETYPE_FLYGRAVITY) +#if defined( HL2_EPISODIC ) || defined( TF_DLL ) + || + ( HasSpawnFlags(SF_TRIG_TOUCH_DEBRIS) && + (pOther->GetCollisionGroup() == COLLISION_GROUP_DEBRIS || + pOther->GetCollisionGroup() == COLLISION_GROUP_DEBRIS_TRIGGER || + pOther->GetCollisionGroup() == COLLISION_GROUP_INTERACTIVE_DEBRIS) + ) +#endif + ) + { + if ( pOther->GetFlags() & FL_NPC ) + { + CAI_BaseNPC *pNPC = pOther->MyNPCPointer(); + + if ( HasSpawnFlags( SF_TRIGGER_ONLY_PLAYER_ALLY_NPCS ) ) + { + if ( !pNPC || !pNPC->IsPlayerAlly() ) + { + return false; + } + } + + if ( HasSpawnFlags( SF_TRIGGER_ONLY_NPCS_IN_VEHICLES ) ) + { + if ( !pNPC || !pNPC->IsInAVehicle() ) + return false; + } + } + + bool bOtherIsPlayer = pOther->IsPlayer(); + + if ( bOtherIsPlayer ) + { + CBasePlayer *pPlayer = (CBasePlayer*)pOther; + if ( !pPlayer->IsAlive() ) + return false; + + if ( HasSpawnFlags(SF_TRIGGER_ONLY_CLIENTS_IN_VEHICLES) ) + { + if ( !pPlayer->IsInAVehicle() ) + return false; + + // Make sure we're also not exiting the vehicle at the moment + IServerVehicle *pVehicleServer = pPlayer->GetVehicle(); + if ( pVehicleServer == NULL ) + return false; + + if ( pVehicleServer->IsPassengerExiting() ) + return false; + } + + if ( HasSpawnFlags(SF_TRIGGER_ONLY_CLIENTS_OUT_OF_VEHICLES) ) + { + if ( pPlayer->IsInAVehicle() ) + return false; + } + + if ( HasSpawnFlags( SF_TRIGGER_DISALLOW_BOTS ) ) + { + if ( pPlayer->IsFakeClient() ) + return false; + } + } + + CBaseFilter *pFilter = m_hFilter.Get(); + return (!pFilter) ? true : pFilter->PassesFilter( this, pOther ); + } +#else // First test spawn flag filters if ( HasSpawnFlags(SF_TRIGGER_ALLOW_ALL) || (HasSpawnFlags(SF_TRIGGER_ALLOW_CLIENTS) && (pOther->GetFlags() & FL_CLIENT)) || @@ -4417,6 +4775,7 @@ bool CBaseVPhysicsTrigger::PassesTriggerFilters( CBaseEntity *pOther ) CBaseFilter *pFilter = m_hFilter.Get(); return (!pFilter) ? true : pFilter->PassesFilter( this, pOther ); } +#endif return false; } @@ -4788,6 +5147,13 @@ void CServerRagdollTrigger::Spawn( void ) { BaseClass::Spawn(); +#ifdef MAPBASE + // This didn't use PassesTriggerFilters() before, so a trigger_serverragdoll could work regardless of flags. + // Because of this, using trigger filters now will break existing trigger_serverragdolls that functioned without the right flags ticked. + // NPCs are going to be using this in almost all circumstances, so SF_TRIGGER_ALLOW_NPCS is pretty much the main flag of concern. + AddSpawnFlags(SF_TRIGGER_ALLOW_NPCS); +#endif + InitTrigger(); } @@ -4798,10 +5164,25 @@ void CServerRagdollTrigger::StartTouch(CBaseEntity *pOther) if ( pOther->IsPlayer() ) return; +#ifdef MAPBASE + // This means base class didn't accept it (trigger filters) + if (m_hTouchingEntities.Find(pOther) == m_hTouchingEntities.InvalidIndex()) + return; +#endif + CBaseCombatCharacter *pCombatChar = pOther->MyCombatCharacterPointer(); if ( pCombatChar ) { +#ifdef MAPBASE + // The mapper or some other force might've changed it themselves. + // Pretend it never touched us... + if (pCombatChar->m_bForceServerRagdoll == true) + { + BaseClass::EndTouch(pOther); + return; + } +#endif pCombatChar->m_bForceServerRagdoll = true; } } @@ -4821,6 +5202,147 @@ void CServerRagdollTrigger::EndTouch(CBaseEntity *pOther) } } +//----------------------------------------------------------------------------- +// Purpose: A trigger that adds impulse to touching entities +//----------------------------------------------------------------------------- +class CTriggerApplyImpulse : public CBaseTrigger +{ +public: + DECLARE_CLASS( CTriggerApplyImpulse, CBaseTrigger ); + DECLARE_DATADESC(); + + CTriggerApplyImpulse(); + + void Spawn( void ); + + void InputApplyImpulse( inputdata_t& ); + +private: + Vector m_vecImpulseDir; + float m_flForce; +}; + + +BEGIN_DATADESC( CTriggerApplyImpulse ) + DEFINE_KEYFIELD( m_vecImpulseDir, FIELD_VECTOR, "impulse_dir" ), + DEFINE_KEYFIELD( m_flForce, FIELD_FLOAT, "force" ), + DEFINE_INPUTFUNC( FIELD_VOID, "ApplyImpulse", InputApplyImpulse ), +END_DATADESC() + + +LINK_ENTITY_TO_CLASS( trigger_apply_impulse, CTriggerApplyImpulse ); + + +CTriggerApplyImpulse::CTriggerApplyImpulse() +{ + m_flForce = 300.f; +} + + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CTriggerApplyImpulse::Spawn() +{ + // Convert pushdir from angles to a vector + Vector vecAbsDir; + QAngle angPushDir = QAngle(m_vecImpulseDir.x, m_vecImpulseDir.y, m_vecImpulseDir.z); + AngleVectors(angPushDir, &vecAbsDir); + + // Transform the vector into entity space + VectorIRotate( vecAbsDir, EntityToWorldTransform(), m_vecImpulseDir ); + + BaseClass::Spawn(); + + InitTrigger(); +} + + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CTriggerApplyImpulse::InputApplyImpulse( inputdata_t& ) +{ + Vector vecImpulse = m_flForce * m_vecImpulseDir; + FOR_EACH_VEC( m_hTouchingEntities, i ) + { + if ( m_hTouchingEntities[i] ) + { + m_hTouchingEntities[i]->ApplyAbsVelocityImpulse( vecImpulse ); + } + } +} + +#ifdef MAPBASE +class CTriggerFall : public CBaseTrigger +{ + DECLARE_CLASS( CTriggerFall, CBaseTrigger ); + +public: + + virtual void StartTouch( CBaseEntity *pOther ); + virtual void EndTouch( CBaseEntity *pOther ); + virtual void Spawn( void ); + + bool m_bStayLethal; + + DECLARE_DATADESC(); +}; + +LINK_ENTITY_TO_CLASS( trigger_fall, CTriggerFall ); + +BEGIN_DATADESC( CTriggerFall ) + + DEFINE_KEYFIELD( m_bStayLethal, FIELD_BOOLEAN, "StayLethal" ), + +END_DATADESC() + +void CTriggerFall::Spawn( void ) +{ + BaseClass::Spawn(); + + InitTrigger(); +} + +void CTriggerFall::StartTouch(CBaseEntity *pOther) +{ + BaseClass::StartTouch( pOther ); + + if ( !pOther->IsPlayer() ) + return; + + static_cast(pOther)->m_bInTriggerFall = true; +} + +void CTriggerFall::EndTouch(CBaseEntity *pOther) +{ + BaseClass::EndTouch( pOther ); + + if ( !pOther->IsPlayer() || m_bStayLethal ) + return; + + static_cast(pOther)->m_bInTriggerFall = false; +} + + + +class CTriggerWorld : public CTriggerMultiple +{ + DECLARE_CLASS( CTriggerWorld, CTriggerMultiple ); + +public: + + virtual bool PassesTriggerFilters(CBaseEntity *pOther); +}; + +LINK_ENTITY_TO_CLASS( trigger_world, CTriggerWorld ); + +bool CTriggerWorld::PassesTriggerFilters( CBaseEntity *pOther ) +{ + return pOther->IsWorld(); +} +#endif + #ifdef HL1_DLL //---------------------------------------------------------------------------------- // func_friction diff --git a/sp/src/game/server/triggers.h b/sp/src/game/server/triggers.h index 7695d08c..9d7c1829 100644 --- a/sp/src/game/server/triggers.h +++ b/sp/src/game/server/triggers.h @@ -11,7 +11,11 @@ #pragma once #endif +#ifdef MAPBASE +#include "baseentity.h" +#else #include "basetoggle.h" +#endif #include "entityoutput.h" // @@ -33,15 +37,24 @@ enum SF_TRIG_TOUCH_DEBRIS = 0x400, // Will touch physics debris objects SF_TRIGGER_ONLY_NPCS_IN_VEHICLES = 0X800, // *if* NPCs can fire this trigger, only NPCs in vehicles do so (respects player ally flag too) SF_TRIGGER_DISALLOW_BOTS = 0x1000, // Bots are not allowed to fire this trigger +#ifdef MAPBASE + SF_TRIGGER_ALLOW_ITEMS = 0x2000, // MOVETYPE_FLYGRAVITY (Weapons, items, flares, etc.) can fire this trigger +#endif }; // DVS TODO: get rid of CBaseToggle //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- +#ifdef MAPBASE +#define CBaseToggle CBaseEntity +#endif class CBaseTrigger : public CBaseToggle { DECLARE_CLASS( CBaseTrigger, CBaseToggle ); +#ifdef MAPBASE +#undef CBaseToggle +#endif public: CBaseTrigger(); @@ -96,6 +109,19 @@ protected: // Entities currently being touched by this trigger CUtlVector< EHANDLE > m_hTouchingEntities; +#ifdef MAPBASE + // We don't descend from CBaseToggle anymore. These have to be defined here now. + EHANDLE m_hActivator; + float m_flWait; + string_t m_sMaster; // If this button has a master switch, this is the targetname. + // A master switch must be of the multisource type. If all + // of the switches in the multisource have been triggered, then + // the button will be allowed to operate. Otherwise, it will be + // deactivated. + + virtual float GetDelay( void ) { return m_flWait; } +#endif + DECLARE_DATADESC(); }; @@ -171,6 +197,10 @@ public: { // This field came along after levels were built so the field defaults to 20 here in the constructor. m_flDamageCap = 20.0f; +#ifdef MAPBASE + // Uh, same here. + m_flHurtRate = 0.5f; +#endif } DECLARE_CLASS( CTriggerHurt, CBaseTrigger ); @@ -183,6 +213,10 @@ public: bool HurtEntity( CBaseEntity *pOther, float damage ); int HurtAllTouchers( float dt ); +#ifdef MAPBASE + bool KeyValue( const char *szKeyName, const char *szValue ); +#endif + DECLARE_DATADESC(); float m_flOriginalDamage; // Damage as specified by the level designer. @@ -193,6 +227,9 @@ public: int m_bitsDamageInflict; // DMG_ damage type that the door or tigger does int m_damageModel; bool m_bNoDmgForce; // Should damage from this trigger impart force on what it's hurting +#ifdef MAPBASE + float m_flHurtRate; +#endif enum { diff --git a/sp/src/game/server/util.cpp b/sp/src/game/server/util.cpp index aba6f327..77e8e45d 100644 --- a/sp/src/game/server/util.cpp +++ b/sp/src/game/server/util.cpp @@ -295,6 +295,14 @@ int UTIL_EntitiesInSphere( const Vector ¢er, float radius, CFlaggedEntitiesE return pEnum->GetCount(); } +#ifdef MAPBASE +int UTIL_EntitiesAtPoint( const Vector &point, CFlaggedEntitiesEnum *pEnum ) +{ + partition->EnumerateElementsAtPoint( PARTITION_ENGINE_NON_STATIC_EDICTS, point, false, pEnum ); + return pEnum->GetCount(); +} +#endif + CEntitySphereQuery::CEntitySphereQuery( const Vector ¢er, float radius, int flagMask ) { m_listIndex = 0; @@ -1290,9 +1298,19 @@ void UTIL_SetModel( CBaseEntity *pEntity, const char *pModelName ) int i = modelinfo->GetModelIndex( pModelName ); if ( i == -1 ) { +#if defined(MAPBASE) && !defined(_DEBUG) + // Throwing a program-terminating error might be a little too much since we could just precache it here. + // If we're not in debug mode, just let it off with a nice warning. + if (int newi = CBaseEntity::PrecacheModel(pModelName)) + { + i = newi; + Warning("%s was not precached\n", pModelName); + } +#else Error("%i/%s - %s: UTIL_SetModel: not precached: %s\n", pEntity->entindex(), STRING( pEntity->GetEntityName() ), pEntity->GetClassname(), pModelName); +#endif } CBaseAnimating *pAnimating = pEntity->GetBaseAnimating(); @@ -1784,6 +1802,40 @@ void UTIL_PrecacheOther( const char *szClassname, const char *modelName ) UTIL_RemoveImmediate( pEntity ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Tests whether this entity exists in the dictionary and if it does, precaches it. (as opposed to complaining when it's missing) +// Input : *szClassname - +// *modelName - +//----------------------------------------------------------------------------- +bool UTIL_TestPrecacheOther( const char *szClassname, const char *modelName ) +{ +#if defined( PRECACHE_OTHER_ONCE ) + // already done this one?, if not, mark as done + if ( !g_PrecacheOtherList.AddOrMarkPrecached( szClassname ) ) + return true; +#endif + + // If we can't create it, it probably does not exist + CBaseEntity *pEntity = CreateEntityByName( szClassname ); + if (!pEntity) + return false; + + // If we have a specified model, set it before calling precache + if ( modelName && modelName[0] ) + { + pEntity->SetModelName( AllocPooledString( modelName ) ); + } + + if (pEntity) + pEntity->Precache( ); + + UTIL_RemoveImmediate( pEntity ); + + return true; +} +#endif + //========================================================= // UTIL_LogPrintf - Prints a logged message to console. // Preceded by LOG: ( timestamp ) < message > @@ -2451,6 +2503,44 @@ void UTIL_PredictedPosition( CBaseEntity *pTarget, float flTimeDelta, Vector *ve (*vecPredictedPosition) = pTarget->GetAbsOrigin() + ( vecPredictedVel * flTimeDelta ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Same as above, except you don't have to use the absolute origin and can use your own position to predict from. +//----------------------------------------------------------------------------- +void UTIL_PredictedPosition( CBaseEntity *pTarget, Vector &vecActualPosition, float flTimeDelta, Vector *vecPredictedPosition ) +{ + if ( ( pTarget == NULL ) || ( vecPredictedPosition == NULL ) ) + return; + + Vector vecPredictedVel; + CBasePlayer *pPlayer = ToBasePlayer( pTarget ); + if ( pPlayer != NULL ) + { + if ( pPlayer->IsInAVehicle() ) + vecPredictedVel = pPlayer->GetVehicleEntity()->GetSmoothedVelocity(); + else + vecPredictedVel = pPlayer->GetSmoothedVelocity(); + } + else + { + CBaseCombatCharacter *pCCTarget = pTarget->MyCombatCharacterPointer(); + if ( pCCTarget != NULL && pCCTarget->IsInAVehicle() ) + vecPredictedVel = pCCTarget->GetVehicleEntity()->GetSmoothedVelocity(); + else + { + CBaseAnimating *pAnimating = dynamic_cast(pTarget); + if ( pAnimating != NULL ) + vecPredictedVel = pAnimating->GetGroundSpeedVelocity(); + else + vecPredictedVel = pTarget->GetSmoothedVelocity(); + } + } + + // Get the result + (*vecPredictedPosition) = vecActualPosition + ( vecPredictedVel * flTimeDelta ); +} +#endif + //----------------------------------------------------------------------------- // Purpose: Points the destination entity at the target entity // Input : *pDest - entity to be pointed at the target diff --git a/sp/src/game/server/util.h b/sp/src/game/server/util.h index a788da6c..4a3d1dad 100644 --- a/sp/src/game/server/util.h +++ b/sp/src/game/server/util.h @@ -187,7 +187,13 @@ extern CGlobalVars *gpGlobals; // Misc useful inline bool FStrEq(const char *sz1, const char *sz2) { +#ifdef MAPBASE + // V_stricmp() already checks if the pointers are equal, so having a pointer comparison here is pointless. + // I'm not sure if this was already automatically phased out by the compiler, but if it wasn't, then this is a very good change. + return ( V_stricmp(sz1, sz2) == 0 ); +#else return ( sz1 == sz2 || V_stricmp(sz1, sz2) == 0 ); +#endif } #if 0 @@ -280,6 +286,9 @@ private: int UTIL_EntitiesInBox( const Vector &mins, const Vector &maxs, CFlaggedEntitiesEnum *pEnum ); int UTIL_EntitiesAlongRay( const Ray_t &ray, CFlaggedEntitiesEnum *pEnum ); int UTIL_EntitiesInSphere( const Vector ¢er, float radius, CFlaggedEntitiesEnum *pEnum ); +#ifdef MAPBASE +int UTIL_EntitiesAtPoint( const Vector &point, CFlaggedEntitiesEnum *pEnum ); +#endif inline int UTIL_EntitiesInBox( CBaseEntity **pList, int listMax, const Vector &mins, const Vector &maxs, int flagMask ) { @@ -299,6 +308,14 @@ inline int UTIL_EntitiesInSphere( CBaseEntity **pList, int listMax, const Vector return UTIL_EntitiesInSphere( center, radius, &sphereEnum ); } +#ifdef MAPBASE +inline int UTIL_EntitiesAtPoint( CBaseEntity **pList, int listMax, const Vector &point, int flagMask ) +{ + CFlaggedEntitiesEnum pointEnum( pList, listMax, flagMask ); + return UTIL_EntitiesAtPoint( point, &pointEnum ); +} +#endif + // marks the entity for deletion so it will get removed next frame void UTIL_Remove( IServerNetworkable *oldObj ); void UTIL_Remove( CBaseEntity *oldObj ); @@ -361,6 +378,9 @@ void UTIL_AxisStringToPointPoint( Vector &start, Vector &end, const char *pStri void UTIL_AxisStringToUnitDir( Vector &dir, const char *pString ); void UTIL_ClipPunchAngleOffset( QAngle &in, const QAngle &punch, const QAngle &clip ); void UTIL_PredictedPosition( CBaseEntity *pTarget, float flTimeDelta, Vector *vecPredictedPosition ); +#ifdef MAPBASE +void UTIL_PredictedPosition( CBaseEntity *pTarget, Vector &vecActualPosition, float flTimeDelta, Vector *vecPredictedPosition ); +#endif void UTIL_Beam( Vector &Start, Vector &End, int nModelIndex, int nHaloIndex, unsigned char FrameStart, unsigned char FrameRate, float Life, unsigned char Width, unsigned char EndWidth, unsigned char FadeLength, unsigned char Noise, unsigned char Red, unsigned char Green, unsigned char Blue, unsigned char Brightness, unsigned char Speed); @@ -392,6 +412,11 @@ void UTIL_BubbleTrail( const Vector& from, const Vector& to, int count ); // allows precacheing of other entities void UTIL_PrecacheOther( const char *szClassname, const char *modelName = NULL ); +#ifdef MAPBASE +// Tests whether this entity exists in the dictionary and if it does, precaches it. (as opposed to complaining when it's missing) +bool UTIL_TestPrecacheOther( const char *szClassname, const char *modelName = NULL ); +#endif + // prints a message to each client void UTIL_ClientPrintAll( int msg_dest, const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL ); inline void UTIL_CenterPrintAll( const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL ) diff --git a/sp/src/game/server/variant_t.cpp b/sp/src/game/server/variant_t.cpp index 82edcfd4..6a4a5f91 100644 --- a/sp/src/game/server/variant_t.cpp +++ b/sp/src/game/server/variant_t.cpp @@ -6,6 +6,10 @@ #include "cbase.h" #include "variant_t.h" +#ifdef MAPBASE +#include "mapbase/variant_tools.h" +#include "mapbase/matchers.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -16,4 +20,238 @@ void variant_t::SetEntity( CBaseEntity *val ) fieldType = FIELD_EHANDLE; } +#ifdef MAPBASE +const char *variant_t::GetDebug() +{ + /* + case FIELD_BOOLEAN: *((bool *)data) = bVal != 0; break; + case FIELD_CHARACTER: *((char *)data) = iVal; break; + case FIELD_SHORT: *((short *)data) = iVal; break; + case FIELD_INTEGER: *((int *)data) = iVal; break; + case FIELD_STRING: *((string_t *)data) = iszVal; break; + case FIELD_FLOAT: *((float *)data) = flVal; break; + case FIELD_COLOR32: *((color32 *)data) = rgbaVal; break; + + case FIELD_VECTOR: + case FIELD_POSITION_VECTOR: + { + ((float *)data)[0] = vecVal[0]; + ((float *)data)[1] = vecVal[1]; + ((float *)data)[2] = vecVal[2]; + break; + } + + case FIELD_EHANDLE: *((EHANDLE *)data) = eVal; break; + case FIELD_CLASSPTR: *((CBaseEntity **)data) = eVal; break; + */ + + const char *fieldtype = "unknown"; + switch (FieldType()) + { + case FIELD_VOID: fieldtype = "Void"; break; + case FIELD_FLOAT: fieldtype = "Float"; break; + case FIELD_STRING: fieldtype = "String"; break; + case FIELD_INTEGER: fieldtype = "Integer"; break; + case FIELD_BOOLEAN: fieldtype = "Boolean"; break; + case FIELD_EHANDLE: fieldtype = "Entity"; break; + case FIELD_CLASSPTR: fieldtype = "EntityPtr"; break; + case FIELD_POSITION_VECTOR: + case FIELD_VECTOR: fieldtype = "Vector"; break; + case FIELD_CHARACTER: fieldtype = "Character"; break; + case FIELD_SHORT: fieldtype = "Short"; break; + case FIELD_COLOR32: fieldtype = "Color32"; break; + default: fieldtype = UTIL_VarArgs("unknown: %i", FieldType()); + } + return UTIL_VarArgs("%s (%s)", String(), fieldtype); +} + +// cmp1 = val1 float +// cmp2 = val2 float +#define VariantToFloat(val1, val2, lenallowed) \ + float cmp1 = val1.Float() ? val1.Float() : val1.Int(); \ + float cmp2 = val2.Float() ? val2.Float() : val2.Int(); \ + if (lenallowed && val2.FieldType() == FIELD_STRING) \ + cmp2 = strlen(val2.String()); + +// Integer parsing has been deactivated for consistency's sake. They now become floats only. +#define INTEGER_PARSING_DEACTIVATED 1 + +// "intchar" is the result of me not knowing where to find a version of isdigit that applies to negative numbers and floats. +#define intchar(c) (c >= '-' && c <= '9') + +// Attempts to determine the field type from whatever is in the string and creates a variant_t with the converted value and resulting field type. +// Right now, Int/Float, String, and Vector are the only fields likely to be used by entities in variant_t parsing, so they're the only ones supported. +// Expand to other fields when necessary. +variant_t Variant_Parse(const char *szValue) +{ +#ifdef INTEGER_PARSING_DEACTIVATED + bool isint = true; + bool isvector = false; + for (size_t i = 0; i < strlen(szValue); i++) + { + if (!intchar(szValue[i])) + { + isint = false; + + if (szValue[i] == ' ') + isvector = true; + else + isvector = false; + } + } + + variant_t var; + + if (isint) + var.SetFloat(atof(szValue)); + else if (isvector) + { + var.SetString(MAKE_STRING(szValue)); + var.Convert(FIELD_VECTOR); + } + else + var.SetString(MAKE_STRING(szValue)); +#else + bool isint = true; + bool isfloat = false; + for (size_t i = 0; i < strlen(szValue); i++) + { + if (szValue[i] == '.') + isfloat = true; + else if (!intchar(szValue[i])) + isint = false; + } + + variant_t var = variant_t(); + + if (isint) + { + if (isfloat) + var.SetFloat(atof(szValue)); + else + var.SetInt(atoi(szValue)); + } + else + var.SetString(MAKE_STRING(szValue)); +#endif + + return var; +} + +// Passes strings to Variant_Parse, uses the other input data for finding procedural entities. +variant_t Variant_ParseInput(inputdata_t inputdata) +{ + if (inputdata.value.FieldType() != FIELD_STRING) + return inputdata.value; + + if (inputdata.value.String()[0] == '!') + { + variant_t var = variant_t(); + var.SetEntity(gEntList.FindEntityProcedural(inputdata.value.String(), inputdata.pCaller, inputdata.pActivator, inputdata.pCaller)); + if (var.Entity()) + return var; + } + + return Variant_Parse(inputdata.value.String()); +} + +// Passes string variants to Variant_Parse +variant_t Variant_ParseString(variant_t value) +{ + if (value.FieldType() != FIELD_STRING) + return value; + + return Variant_Parse(value.String()); +} + +bool Variant_Equal(variant_t val1, variant_t val2, bool bLenAllowed) +{ + //if (!val2.Convert(val1.FieldType())) + // return false; + + // Add more fields if they become necessary + switch (val1.FieldType()) + { + case FIELD_INTEGER: + case FIELD_FLOAT: + { + VariantToFloat(val1, val2, bLenAllowed); + return cmp1 == cmp2; + } + case FIELD_BOOLEAN: return val1.Bool() == val2.Bool(); + case FIELD_EHANDLE: return val1.Entity() == val2.Entity(); + case FIELD_VECTOR: + { + Vector vec1; val1.Vector3D(vec1); + Vector vec2; val2.Vector3D(vec2); + return vec1 == vec2; + } +#ifdef MAPBASE_MATCHERS + // logic_compare allows wildcards on either string + default: return Matcher_NamesMatch_MutualWildcard(val1.String(), val2.String()); +#else + default: return FStrEq(val1.String(), val2.String()); +#endif + } + + return false; +} + +// val1 > val2 +bool Variant_Greater(variant_t val1, variant_t val2, bool bLenAllowed) +{ + //if (!val2.Convert(val1.FieldType())) + // return false; + + // Add more fields if they become necessary + switch (val1.FieldType()) + { + case FIELD_INTEGER: + case FIELD_FLOAT: + { + VariantToFloat(val1, val2, bLenAllowed); + return cmp1 > cmp2; + } + case FIELD_BOOLEAN: return val1.Bool() && !val2.Bool(); + case FIELD_VECTOR: + { + Vector vec1; val1.Vector3D(vec1); + Vector vec2; val2.Vector3D(vec2); + return (vec1.x > vec2.x) && (vec1.y > vec2.y) && (vec1.z > vec2.z); + } + default: return strlen(val1.String()) > strlen(val2.String()); + } + + return false; +} + +// val1 >= val2 +bool Variant_GreaterOrEqual(variant_t val1, variant_t val2, bool bLenAllowed) +{ + //if (!val2.Convert(val1.FieldType())) + // return false; + + // Add more fields if they become necessary + switch (val1.FieldType()) + { + case FIELD_INTEGER: + case FIELD_FLOAT: + { + VariantToFloat(val1, val2, bLenAllowed); + return cmp1 >= cmp2; + } + case FIELD_BOOLEAN: return val1.Bool() >= val2.Bool(); + case FIELD_VECTOR: + { + Vector vec1; val1.Vector3D(vec1); + Vector vec2; val2.Vector3D(vec2); + return (vec1.x >= vec2.x) && (vec1.y >= vec2.y) && (vec1.z >= vec2.z); + } + default: return strlen(val1.String()) >= strlen(val2.String()); + } + + return false; +} +#endif + diff --git a/sp/src/game/server/variant_t.h b/sp/src/game/server/variant_t.h index d5e93ea4..8c37d852 100644 --- a/sp/src/game/server/variant_t.h +++ b/sp/src/game/server/variant_t.h @@ -64,6 +64,13 @@ public: void Set( fieldtype_t ftype, void *data ); void SetOther( void *data ); bool Convert( fieldtype_t newType ); +#ifdef MAPBASE + // Special conversion specifically for FIELD_EHANDLE with !activator, etc. + bool Convert( fieldtype_t newType, CBaseEntity *pSelf, CBaseEntity *pActivator, CBaseEntity *pCaller ); + // Hands over the value + the field type. + // ex: "Otis (String)", "3 (Integer)", or "npc_combine_s (Entity)" + const char *GetDebug(); +#endif static typedescription_t m_SaveBool[]; static typedescription_t m_SaveInt[]; diff --git a/sp/src/game/server/vehicle_base.cpp b/sp/src/game/server/vehicle_base.cpp index f916ba69..d4194d9b 100644 --- a/sp/src/game/server/vehicle_base.cpp +++ b/sp/src/game/server/vehicle_base.cpp @@ -334,6 +334,12 @@ BEGIN_DATADESC( CPropVehicleDriveable ) DEFINE_INPUTFUNC( FIELD_VOID, "Unlock", InputUnlock ), DEFINE_INPUTFUNC( FIELD_VOID, "TurnOn", InputTurnOn ), DEFINE_INPUTFUNC( FIELD_VOID, "TurnOff", InputTurnOff ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "EnterVehicle", InputEnterVehicle ), + DEFINE_INPUTFUNC( FIELD_VOID, "EnterVehicleImmediate", InputEnterVehicleImmediate ), + DEFINE_INPUTFUNC( FIELD_VOID, "ExitVehicle", InputExitVehicle ), + DEFINE_INPUTFUNC( FIELD_VOID, "ExitVehicleImmediate", InputExitVehicleImmediate ), +#endif DEFINE_INPUT( m_bHasGun, FIELD_BOOLEAN, "EnableGun" ), // Outputs @@ -343,6 +349,9 @@ BEGIN_DATADESC( CPropVehicleDriveable ) DEFINE_OUTPUT( m_pressedAttack2, "PressedAttack2" ), DEFINE_OUTPUT( m_attackaxis, "AttackAxis" ), DEFINE_OUTPUT( m_attack2axis, "Attack2Axis" ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OnPlayerUse, "OnPlayerUse" ), +#endif DEFINE_FIELD( m_hPlayer, FIELD_EHANDLE ), DEFINE_EMBEDDEDBYREF( m_pServerVehicle ), @@ -557,6 +566,10 @@ void CPropVehicleDriveable::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, ResetUseKey( pPlayer ); +#ifdef MAPBASE + m_OnPlayerUse.FireOutput(pActivator, this); +#endif + m_pServerVehicle->HandlePassengerEntry( pPlayer, (value>0) ); } @@ -847,6 +860,99 @@ void CPropVehicleDriveable::InputTurnOff( inputdata_t &inputdata ) m_VehiclePhysics.SetDisableEngine( true ); } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPropVehicleDriveable::InputEnterVehicle( inputdata_t &inputdata ) +{ + if ( m_bEnterAnimOn ) + return; + + // Try the activator first & use them if they are a player. + CBaseCombatCharacter *pPassenger = ToBaseCombatCharacter( inputdata.pActivator ); + if ( pPassenger == NULL ) + { + // Activator was not a player, just grab the singleplayer player. + pPassenger = UTIL_PlayerByIndex( 1 ); + if ( pPassenger == NULL ) + return; + } + + // FIXME: I hate code like this. I should really add a parameter to HandlePassengerEntry + // to allow entry into locked vehicles + bool bWasLocked = m_bLocked; + m_bLocked = false; + GetServerVehicle()->HandlePassengerEntry( pPassenger, true ); + m_bLocked = bWasLocked; +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CPropVehicleDriveable::InputEnterVehicleImmediate( inputdata_t &inputdata ) +{ + if ( m_bEnterAnimOn ) + return; + + // Try the activator first & use them if they are a player. + CBaseCombatCharacter *pPassenger = ToBaseCombatCharacter( inputdata.pActivator ); + if ( pPassenger == NULL ) + { + // Activator was not a player, just grab the singleplayer player. + pPassenger = UTIL_PlayerByIndex( 1 ); + if ( pPassenger == NULL ) + return; + } + + CBasePlayer *pPlayer = ToBasePlayer( pPassenger ); + if ( pPlayer != NULL ) + { + if ( pPlayer->IsInAVehicle() ) + { + // Force the player out of whatever vehicle they are in. + pPlayer->LeaveVehicle(); + } + + pPlayer->GetInVehicle( GetServerVehicle(), VEHICLE_ROLE_DRIVER ); + } + else + { + // NPCs are not currently supported - jdw + Assert( 0 ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPropVehicleDriveable::InputExitVehicle( inputdata_t &inputdata ) +{ + if (!GetDriver()) + return; + + if ( CanExitVehicle(GetDriver()) ) + { + GetServerVehicle()->HandlePassengerExit(GetDriver()->MyCombatCharacterPointer()); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CPropVehicleDriveable::InputExitVehicleImmediate( inputdata_t &inputdata ) +{ + if (!GetDriver()) + return; + + if (GetDriver()->IsPlayer()) + { + static_cast(GetDriver())->LeaveVehicle(); + } +} +#endif + //----------------------------------------------------------------------------- // Purpose: Check to see if the engine is on. //----------------------------------------------------------------------------- diff --git a/sp/src/game/server/vehicle_base.h b/sp/src/game/server/vehicle_base.h index ab63005a..1f4b5710 100644 --- a/sp/src/game/server/vehicle_base.h +++ b/sp/src/game/server/vehicle_base.h @@ -192,6 +192,12 @@ public: void InputUnlock( inputdata_t &inputdata ); void InputTurnOn( inputdata_t &inputdata ); void InputTurnOff( inputdata_t &inputdata ); +#ifdef MAPBASE + virtual void InputEnterVehicle( inputdata_t &inputdata ); + virtual void InputEnterVehicleImmediate( inputdata_t &inputdata ); + virtual void InputExitVehicle( inputdata_t &inputdata ); + virtual void InputExitVehicleImmediate( inputdata_t &inputdata ); +#endif // Locals void ResetUseKey( CBasePlayer *pPlayer ); @@ -251,6 +257,10 @@ protected: COutputFloat m_attackaxis; COutputFloat m_attack2axis; +#ifdef MAPBASE + COutputEvent m_OnPlayerUse; +#endif + CNetworkHandle( CBasePlayer, m_hPlayer ); public: diff --git a/sp/src/game/server/vehicle_choreo_generic.cpp b/sp/src/game/server/vehicle_choreo_generic.cpp index b644a7a4..3b3a53f9 100644 --- a/sp/src/game/server/vehicle_choreo_generic.cpp +++ b/sp/src/game/server/vehicle_choreo_generic.cpp @@ -197,6 +197,11 @@ public: // If this is a vehicle, returns the vehicle interface virtual IServerVehicle *GetServerVehicle() { return &m_ServerVehicle; } +#ifdef MAPBASE + virtual bool IsPassengerUsingStandardWeapons( int nRole = VEHICLE_ROLE_DRIVER ) { return m_bAllowStandardWeapons; } + CNetworkVar( bool, m_bAllowStandardWeapons ); +#endif + bool ShouldCollide( int collisionGroup, int contentsMask ) const; bool m_bForcePlayerEyePoint; // Uses player's eyepoint instead of 'vehicle_driver_eyes' attachment @@ -256,6 +261,10 @@ BEGIN_DATADESC( CPropVehicleChoreoGeneric ) DEFINE_KEYFIELD( m_bIgnorePlayerCollisions, FIELD_BOOLEAN, "ignoreplayer" ), DEFINE_KEYFIELD( m_bForcePlayerEyePoint, FIELD_BOOLEAN, "useplayereyes" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bAllowStandardWeapons, FIELD_BOOLEAN, "AllowStandardWeapons" ), +#endif + DEFINE_OUTPUT( m_playerOn, "PlayerOn" ), DEFINE_OUTPUT( m_playerOff, "PlayerOff" ), DEFINE_OUTPUT( m_OnOpen, "OnOpen" ), @@ -281,6 +290,9 @@ IMPLEMENT_SERVERCLASS_ST(CPropVehicleChoreoGeneric, DT_PropVehicleChoreoGeneric) SendPropFloat( SENDINFO_STRUCTELEM( m_vehicleView.flYawMax ) ), SendPropFloat( SENDINFO_STRUCTELEM( m_vehicleView.flPitchMin ) ), SendPropFloat( SENDINFO_STRUCTELEM( m_vehicleView.flPitchMax ) ), +#ifdef MAPBASE + SendPropBool( SENDINFO( m_bAllowStandardWeapons ) ), +#endif END_SEND_TABLE(); diff --git a/sp/src/game/server/wcedit.cpp b/sp/src/game/server/wcedit.cpp index 43307dfc..5a454e6b 100644 --- a/sp/src/game/server/wcedit.cpp +++ b/sp/src/game/server/wcedit.cpp @@ -450,6 +450,19 @@ Vector *g_EntityPositions = NULL; QAngle *g_EntityOrientations = NULL; string_t *g_EntityClassnames = NULL; +#ifdef MAPBASE // VDC Memory Leak Fixes +class GlobalCleanUp : public CAutoGameSystem +{ + void Shutdown() + { + delete [] g_EntityPositions; + delete [] g_EntityOrientations; + delete [] g_EntityClassnames; + delete this; + } +}; +#endif + //----------------------------------------------------------------------------- // Purpose: Saves the entity's position for future communication with Hammer //----------------------------------------------------------------------------- @@ -460,6 +473,9 @@ void NWCEdit::RememberEntityPosition( CBaseEntity *pEntity ) if ( !g_EntityPositions ) { +#ifdef MAPBASE // VDC Memory Leak Fixes + new GlobalCleanUp(); +#endif g_EntityPositions = new Vector[NUM_ENT_ENTRIES]; g_EntityOrientations = new QAngle[NUM_ENT_ENTRIES]; // have to save these too because some entities change the classname on spawn (e.g. prop_physics_override, physics_prop) diff --git a/sp/src/game/shared/SoundEmitterSystem.cpp b/sp/src/game/shared/SoundEmitterSystem.cpp index 6d27fde9..09a568f8 100644 --- a/sp/src/game/shared/SoundEmitterSystem.cpp +++ b/sp/src/game/shared/SoundEmitterSystem.cpp @@ -130,6 +130,10 @@ void Hack_FixEscapeChars( char *str ) Q_strncpy( str, osave, len ); } +#ifdef MAPBASE +static const ConVar *pHostTimescale; +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -323,6 +327,10 @@ public: } } #endif + +#ifdef MAPBASE + pHostTimescale = cvar->FindVar( "host_timescale" ); +#endif } virtual void LevelInitPostEntity() @@ -525,7 +533,11 @@ public: params.volume, (soundlevel_t)params.soundlevel, ep.m_nFlags, +#ifdef MAPBASE + pHostTimescale->GetFloat() != 0.0f ? params.pitch * pHostTimescale->GetFloat() : params.pitch, +#else params.pitch, +#endif ep.m_nSpecialDSP, ep.m_pOrigin, NULL, @@ -604,7 +616,11 @@ public: ep.m_flVolume, ep.m_SoundLevel, ep.m_nFlags, +#ifdef MAPBASE + pHostTimescale->GetFloat() != 0.0f ? ep.m_nPitch * pHostTimescale->GetFloat() : ep.m_nPitch, +#else ep.m_nPitch, +#endif ep.m_nSpecialDSP, ep.m_pOrigin, NULL, @@ -826,6 +842,13 @@ public: params.volume = flVolume; } +#ifdef MAPBASE + if ( pHostTimescale->GetFloat() != 0.0f ) + { + params.pitch *= pHostTimescale->GetFloat(); + } +#endif + #if defined( CLIENT_DLL ) enginesound->EmitAmbientSound( params.soundname, params.volume, params.pitch, iFlags, soundtime ); #else @@ -954,6 +977,13 @@ public: if ( pSample && ( Q_stristr( pSample, ".wav" ) || Q_stristr( pSample, ".mp3" )) ) { +#ifdef MAPBASE + if ( pHostTimescale->GetFloat() != 0.0f ) + { + pitch *= pHostTimescale->GetFloat(); + } +#endif + #if defined( CLIENT_DLL ) enginesound->EmitAmbientSound( pSample, volume, pitch, flags, soundtime ); #else @@ -1420,7 +1450,17 @@ static const char *UTIL_TranslateSoundName( const char *soundname, const char *a void CBaseEntity::GenderExpandString( char const *in, char *out, int maxlen ) { +#ifdef MAPBASE + // This is so models without globalactors.txt declarations can still play scenes. + gender_t gender = soundemitterbase->GetActorGender(STRING(GetModelName())); + + if (gender == GENDER_NONE) + gender = GENDER_MALE; + + soundemitterbase->GenderExpandString(gender, in, out, maxlen); +#else soundemitterbase->GenderExpandString( STRING( GetModelName() ), in, out, maxlen ); +#endif } bool CBaseEntity::GetParametersForSound( const char *soundname, CSoundParameters ¶ms, const char *actormodel ) diff --git a/sp/src/game/shared/achievementmgr.cpp b/sp/src/game/shared/achievementmgr.cpp index ffc95d46..93a7167b 100644 --- a/sp/src/game/shared/achievementmgr.cpp +++ b/sp/src/game/shared/achievementmgr.cpp @@ -1537,7 +1537,11 @@ void CAchievementMgr::OnKillEvent( CBaseEntity *pVictim, CBaseEntity *pAttacker, } CBaseCombatCharacter *pBCC = dynamic_cast( pVictim ); +#ifdef MAPBASE + if ( pBCC && ( D_FR >= pBCC->IRelationType( pLocalPlayer ) ) ) +#else if ( pBCC && ( D_HT == pBCC->IRelationType( pLocalPlayer ) ) ) +#endif { bVictimIsPlayerEnemy = true; } diff --git a/sp/src/game/shared/activitylist.cpp b/sp/src/game/shared/activitylist.cpp index 2b421252..6a6b08b6 100644 --- a/sp/src/game/shared/activitylist.cpp +++ b/sp/src/game/shared/activitylist.cpp @@ -264,6 +264,10 @@ void ActivityList_RegisterSharedActivities( void ) REGISTER_SHARED_ACTIVITY( ACT_RELOAD_LOW ); REGISTER_SHARED_ACTIVITY( ACT_ARM ); REGISTER_SHARED_ACTIVITY( ACT_DISARM ); +#ifdef COMPANION_HOLSTER_WORKAROUND + REGISTER_SHARED_ACTIVITY( ACT_ARM_RIFLE ); + REGISTER_SHARED_ACTIVITY( ACT_DISARM_RIFLE ); +#endif REGISTER_SHARED_ACTIVITY( ACT_DROP_WEAPON ); REGISTER_SHARED_ACTIVITY( ACT_DROP_WEAPON_SHOTGUN ); @@ -507,6 +511,11 @@ void ActivityList_RegisterSharedActivities( void ) REGISTER_SHARED_ACTIVITY( ACT_SMG2_TOAUTO ); REGISTER_SHARED_ACTIVITY( ACT_SMG2_TOBURST ); +#ifdef SHARED_COMBINE_ACTIVITIES + REGISTER_SHARED_ACTIVITY( ACT_COMBINE_THROW_GRENADE ); + REGISTER_SHARED_ACTIVITY( ACT_COMBINE_AR2_ALTFIRE ); +#endif + // Physcannon special activities REGISTER_SHARED_ACTIVITY( ACT_PHYSCANNON_UPGRADE ); @@ -560,6 +569,10 @@ void ActivityList_RegisterSharedActivities( void ) REGISTER_SHARED_ACTIVITY( ACT_IDLE_RIFLE ); REGISTER_SHARED_ACTIVITY( ACT_IDLE_SMG1 ); REGISTER_SHARED_ACTIVITY( ACT_IDLE_ANGRY_SMG1 ); +#if AR2_ACTIVITY_FIX == 1 + REGISTER_SHARED_ACTIVITY( ACT_IDLE_AR2 ); + REGISTER_SHARED_ACTIVITY( ACT_IDLE_ANGRY_AR2 ); +#endif REGISTER_SHARED_ACTIVITY( ACT_IDLE_PISTOL ); REGISTER_SHARED_ACTIVITY( ACT_IDLE_ANGRY_PISTOL ); REGISTER_SHARED_ACTIVITY( ACT_IDLE_ANGRY_SHOTGUN ); @@ -578,10 +591,25 @@ void ActivityList_RegisterSharedActivities( void ) REGISTER_SHARED_ACTIVITY( ACT_WALK_RIFLE_STIMULATED ); REGISTER_SHARED_ACTIVITY( ACT_RUN_RIFLE_STIMULATED ); +#if AR2_ACTIVITY_FIX == 1 + REGISTER_SHARED_ACTIVITY( ACT_IDLE_AR2_RELAXED ); + REGISTER_SHARED_ACTIVITY( ACT_IDLE_AR2_STIMULATED ); + REGISTER_SHARED_ACTIVITY( ACT_WALK_AR2_RELAXED ); + REGISTER_SHARED_ACTIVITY( ACT_RUN_AR2_RELAXED ); + REGISTER_SHARED_ACTIVITY( ACT_WALK_AR2_STIMULATED ); + REGISTER_SHARED_ACTIVITY( ACT_RUN_AR2_STIMULATED ); +#endif + REGISTER_SHARED_ACTIVITY( ACT_IDLE_AIM_RIFLE_STIMULATED ); REGISTER_SHARED_ACTIVITY( ACT_WALK_AIM_RIFLE_STIMULATED ); REGISTER_SHARED_ACTIVITY( ACT_RUN_AIM_RIFLE_STIMULATED ); +#if AR2_ACTIVITY_FIX == 1 + REGISTER_SHARED_ACTIVITY( ACT_IDLE_AIM_AR2_STIMULATED ); + REGISTER_SHARED_ACTIVITY( ACT_WALK_AIM_AR2_STIMULATED ); + REGISTER_SHARED_ACTIVITY( ACT_RUN_AIM_AR2_STIMULATED ); +#endif + REGISTER_SHARED_ACTIVITY( ACT_IDLE_SHOTGUN_RELAXED ); REGISTER_SHARED_ACTIVITY( ACT_IDLE_SHOTGUN_STIMULATED ); REGISTER_SHARED_ACTIVITY( ACT_IDLE_SHOTGUN_AGITATED ); @@ -620,6 +648,13 @@ void ActivityList_RegisterSharedActivities( void ) REGISTER_SHARED_ACTIVITY( ACT_RUN_CROUCH_AIM_RIFLE ); REGISTER_SHARED_ACTIVITY( ACT_RUN_STEALTH_PISTOL ); +#if AR2_ACTIVITY_FIX == 1 + REGISTER_SHARED_ACTIVITY( ACT_WALK_AR2 ); + REGISTER_SHARED_ACTIVITY( ACT_WALK_AIM_AR2 ); + REGISTER_SHARED_ACTIVITY( ACT_RUN_AR2 ); + REGISTER_SHARED_ACTIVITY( ACT_RUN_AIM_AR2 ); +#endif + REGISTER_SHARED_ACTIVITY( ACT_WALK_AIM_SHOTGUN ); REGISTER_SHARED_ACTIVITY( ACT_RUN_AIM_SHOTGUN ); @@ -638,11 +673,18 @@ void ActivityList_RegisterSharedActivities( void ) REGISTER_SHARED_ACTIVITY( ACT_RELOAD_SMG1_LOW ); REGISTER_SHARED_ACTIVITY( ACT_RELOAD_SHOTGUN ); REGISTER_SHARED_ACTIVITY( ACT_RELOAD_SHOTGUN_LOW ); +#if AR2_ACTIVITY_FIX == 1 + REGISTER_SHARED_ACTIVITY( ACT_RELOAD_AR2 ); + //REGISTER_SHARED_ACTIVITY( ACT_RELOAD_AR2_LOW ); +#endif REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RELOAD ); REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RELOAD_PISTOL ); REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RELOAD_SMG1 ); REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RELOAD_SHOTGUN ); +#if AR2_ACTIVITY_FIX == 1 + REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RELOAD_AR2 ); +#endif // Busy animations REGISTER_SHARED_ACTIVITY( ACT_BUSY_LEAN_LEFT ); diff --git a/sp/src/game/shared/ai_activity.h b/sp/src/game/shared/ai_activity.h index fbd10c39..c813b5ae 100644 --- a/sp/src/game/shared/ai_activity.h +++ b/sp/src/game/shared/ai_activity.h @@ -11,6 +11,46 @@ #pragma once #endif +#ifdef MAPBASE + +// Mapbase adds a few shared activities. +// +// These used to be placed in between existing activities, as outside of the code activities are based off of strings. +// This seemed like a bad idea, but no problems arose at the time. +// I later discovered that apparently some things in MP use the direct integers instead of the enum names. +// I retroactively put all custom activities at the bottom of the enum instead. +// Their placements in activitylist.cpp and ai_activity.cpp have not been changed. + +// AR2 ACTIVITY FIX +// You know all of those AR2 activities that citizens and combine soldiers have? +// Yeah, those are unused. It appears Valve forgot to implement them. +// +// What could be 20-40 different animations on two different characters are not even defined in code. +// I didn't even realize they were unused until I saw ACT_RELOAD_AR2, so I don't blame them for never realizing this. +// They work surprisingly well for probably never being tested in-game. +// +// 1 = Add activities directly +// 2 = Add activities as custom activities (todo) +// +// 2 should only be preferable if adding them like this breaks something. +#define AR2_ACTIVITY_FIX 1 + +// COMPANION HOLSTER WORKAROUND +// I introduced a separate holster/unholster animation to male_shared +// and female_shared and I realized it might conflict with Alyx's animation. +// +// I came up with a solution--ACT_ARM_RIFLE and its disarm counterpart--to solve it. +// I didn't think about the fact I could've named them the same as Alyx's so her animations would overwrite it... +// ...so this has been deactivated. +//#define COMPANION_HOLSTER_WORKAROUND 1 + +// SHARED COMBINE ACTIVITIES +// This turns ACT_COMBINE_AR2_ALTFIRE and ACT_COMBINE_THROW_GRENADE into shared activities. +// This is necessary so other NPCs to use them without having to rely on a bunch of custom activities. +#define SHARED_COMBINE_ACTIVITIES 1 + +#endif + #define ACTIVITY_NOT_AVAILABLE -1 typedef enum @@ -2107,6 +2147,42 @@ typedef enum ACT_SPELL_VM_ARM, ACT_SPELL_VM_FIRE, +#if AR2_ACTIVITY_FIX == 1 + ACT_IDLE_AR2, + ACT_IDLE_ANGRY_AR2, + + ACT_IDLE_AR2_RELAXED, + ACT_IDLE_AR2_STIMULATED, + ACT_WALK_AR2_RELAXED, + ACT_RUN_AR2_RELAXED, + ACT_WALK_AR2_STIMULATED, + ACT_RUN_AR2_STIMULATED, + + ACT_IDLE_AIM_AR2_STIMULATED, + ACT_WALK_AIM_AR2_STIMULATED, + ACT_RUN_AIM_AR2_STIMULATED, + + ACT_WALK_AR2, + ACT_WALK_AIM_AR2, + ACT_RUN_AR2, + ACT_RUN_AIM_AR2, + + ACT_RELOAD_AR2, + //ACT_RELOAD_AR2_LOW, + + ACT_GESTURE_RELOAD_AR2, +#endif + +#ifdef SHARED_COMBINE_ACTIVITIES + ACT_COMBINE_THROW_GRENADE, + ACT_COMBINE_AR2_ALTFIRE, +#endif + +#ifdef COMPANION_HOLSTER_WORKAROUND + ACT_ARM_RIFLE, + ACT_DISARM_RIFLE, +#endif + // this is the end of the global activities, private per-monster activities start here. LAST_SHARED_ACTIVITY, } Activity; diff --git a/sp/src/game/shared/basecombatcharacter_shared.cpp b/sp/src/game/shared/basecombatcharacter_shared.cpp index c032cd54..d01c99a4 100644 --- a/sp/src/game/shared/basecombatcharacter_shared.cpp +++ b/sp/src/game/shared/basecombatcharacter_shared.cpp @@ -82,7 +82,11 @@ bool CBaseCombatCharacter::Weapon_CanSwitchTo( CBaseCombatWeapon *pWeapon ) return false; } +#ifdef MAPBASE + if ( !pWeapon->HasAnyAmmo() && !GetAmmoCount( pWeapon->m_iPrimaryAmmoType ) && !pWeapon->HasSpawnFlags(SF_WEAPON_NO_AUTO_SWITCH_WHEN_EMPTY) ) +#else if ( !pWeapon->HasAnyAmmo() && !GetAmmoCount( pWeapon->m_iPrimaryAmmoType ) ) +#endif return false; if ( !pWeapon->CanDeploy() ) @@ -208,6 +212,16 @@ void CBaseCombatCharacter::SetBloodColor( int nBloodColor ) m_bloodColor = nBloodColor; } +#if defined(MAPBASE) && defined(GAME_DLL) +//----------------------------------------------------------------------------- +// Purpose: Sets blood color +//----------------------------------------------------------------------------- +void CBaseCombatCharacter::InputSetBloodColor( inputdata_t &inputdata ) +{ + SetBloodColor(inputdata.value.Int()); +} +#endif + //----------------------------------------------------------------------------- /** The main visibility check. Checks all the entity specific reasons that could diff --git a/sp/src/game/shared/basecombatweapon_shared.cpp b/sp/src/game/shared/basecombatweapon_shared.cpp index 754919d3..215c95ca 100644 --- a/sp/src/game/shared/basecombatweapon_shared.cpp +++ b/sp/src/game/shared/basecombatweapon_shared.cpp @@ -141,6 +141,9 @@ void CBaseCombatWeapon::GiveDefaultAmmo( void ) // If I use clips, set my clips to the default if ( UsesClipsForAmmo1() ) { +#ifdef MAPBASE + if (!HasSpawnFlags(SF_WEAPON_PRESERVE_AMMO)) +#endif m_iClip1 = AutoFiresFullClip() ? 0 : GetDefaultClip1(); } else @@ -150,6 +153,9 @@ void CBaseCombatWeapon::GiveDefaultAmmo( void ) } if ( UsesClipsForAmmo2() ) { +#ifdef MAPBASE + if (!HasSpawnFlags(SF_WEAPON_PRESERVE_AMMO)) +#endif m_iClip2 = GetDefaultClip2(); } else @@ -300,6 +306,64 @@ void CBaseCombatWeapon::Precache( void ) } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Sets ammo based on mapper value +//----------------------------------------------------------------------------- +void CBaseCombatWeapon::SetAmmoFromMapper( float flAmmo, bool bSecondary ) +{ + int iFinalAmmo; + if (flAmmo > 0.0f && flAmmo < 1.0f) + { + // Ratio from max ammo + iFinalAmmo = ((float)(!bSecondary ? GetMaxClip1() : GetMaxClip2()) * flAmmo); + } + else + { + // Actual ammo value + iFinalAmmo = (int)flAmmo; + } + + !bSecondary ? + m_iClip1 = iFinalAmmo : + m_iClip2 = iFinalAmmo; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +bool CBaseCombatWeapon::KeyValue( const char *szKeyName, const char *szValue ) +{ + if ( FStrEq(szKeyName, "SetAmmo1") ) + { + SetAmmoFromMapper(atof(szValue)); + } + if ( FStrEq(szKeyName, "SetAmmo2") ) + { + SetAmmoFromMapper(atof(szValue), true); + } + else if ( FStrEq(szKeyName, "spawnflags") ) + { + m_spawnflags = atoi(szValue); +#ifndef CLIENT_DLL + // Some spawnflags have to be on the client right now + if (m_spawnflags != 0) + DispatchUpdateTransmitState(); +#endif + } + else + return BaseClass::KeyValue( szKeyName, szValue ); + + return true; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +bool CBaseCombatWeapon::GetKeyValue( const char *szKeyName, char *szValue, int iMaxLen ) +{ + return BaseClass::GetKeyValue(szKeyName, szValue, iMaxLen); +} +#endif + //----------------------------------------------------------------------------- // Purpose: Get my data in the file weapon info array //----------------------------------------------------------------------------- @@ -701,6 +765,12 @@ void CBaseCombatWeapon::Drop( const Vector &vecVelocity ) SetOwnerEntity( NULL ); SetOwner( NULL ); +#ifdef MAPBASE + m_bInReload = false; + + m_OnDropped.FireOutput(pOwner, this); +#endif + // If we're not allowing to spawn due to the gamerules, // remove myself when I'm dropped by an NPC. if ( pOwner && pOwner->IsNPC() ) @@ -957,6 +1027,64 @@ void CBaseCombatWeapon::SetPickupTouch( void ) } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +WeaponClass_t CBaseCombatWeapon::WeaponClassify() +{ + // For now, check how we map our "angry idle" activity. + // The function is virtual, so derived weapons can override this. + Activity idleact = ActivityOverride(ACT_IDLE_ANGRY, NULL); + switch (idleact) + { + case ACT_IDLE_ANGRY_PISTOL: return WEPCLASS_HANDGUN; + case ACT_IDLE_ANGRY_SMG1: + case ACT_IDLE_ANGRY_AR2: return WEPCLASS_RIFLE; + case ACT_IDLE_ANGRY_SHOTGUN: return WEPCLASS_SHOTGUN; + case ACT_IDLE_ANGRY_RPG: return WEPCLASS_HEAVY; + + case ACT_IDLE_ANGRY_MELEE: return WEPCLASS_MELEE; + } + return WEPCLASS_INVALID; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +WeaponClass_t CBaseCombatWeapon::WeaponClassFromString(const char *str) +{ + if (FStrEq(str, "WEPCLASS_HANDGUN")) + return WEPCLASS_HANDGUN; + else if (FStrEq(str, "WEPCLASS_RIFLE")) + return WEPCLASS_RIFLE; + else if (FStrEq(str, "WEPCLASS_SHOTGUN")) + return WEPCLASS_SHOTGUN; + else if (FStrEq(str, "WEPCLASS_HEAY")) + return WEPCLASS_HEAVY; + + else if (FStrEq(str, "WEPCLASS_MELEE")) + return WEPCLASS_MELEE; + + return WEPCLASS_INVALID; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CBaseCombatWeapon::SupportsBackupActivity(Activity activity) +{ + // Derived classes should override this. + + // Pistol and melee users should not use SMG animations for missing pistol activities. + if (WeaponClassify() == WEPCLASS_HANDGUN || IsMeleeWeapon()) + return false; + + return true; +} +#endif + + //----------------------------------------------------------------------------- // Purpose: Become a child of the owner (MOVETYPE_FOLLOW) // disables collisions, touch functions, thinking @@ -983,6 +1111,12 @@ void CBaseCombatWeapon::Equip( CBaseCombatCharacter *pOwner ) } #endif +#ifdef MAPBASE + // Ammo may be overridden to 0, in which case we shouldn't autoswitch + if (m_iClip1 <= 0 && m_iClip2 <= 0) + AddSpawnFlags(SF_WEAPON_NO_AUTO_SWITCH_WHEN_EMPTY); +#endif + m_flNextPrimaryAttack = gpGlobals->curtime; m_flNextSecondaryAttack = gpGlobals->curtime; @@ -1351,7 +1485,12 @@ bool CBaseCombatWeapon::ReloadOrSwitchWeapons( void ) if ( !HasAnyAmmo() && m_flNextPrimaryAttack < gpGlobals->curtime && m_flNextSecondaryAttack < gpGlobals->curtime ) { // weapon isn't useable, switch. +#ifdef MAPBASE + // Ammo might be overridden to 0, in which case we shouldn't do this + if ( ( (GetWeaponFlags() & ITEM_FLAG_NOAUTOSWITCHEMPTY) == false ) && !HasSpawnFlags(SF_WEAPON_NO_AUTO_SWITCH_WHEN_EMPTY) && ( g_pGameRules->SwitchToNextBestWeapon( pOwner, this ) ) ) +#else if ( ( (GetWeaponFlags() & ITEM_FLAG_NOAUTOSWITCHEMPTY) == false ) && ( g_pGameRules->SwitchToNextBestWeapon( pOwner, this ) ) ) +#endif { m_flNextPrimaryAttack = gpGlobals->curtime + 0.3; return true; @@ -1497,6 +1636,11 @@ bool CBaseCombatWeapon::Holster( CBaseCombatWeapon *pSwitchingTo ) RescindReloadHudHint(); } +#ifdef MAPBASE + if (HasSpawnFlags(SF_WEAPON_NO_AUTO_SWITCH_WHEN_EMPTY)) + RemoveSpawnFlags(SF_WEAPON_NO_AUTO_SWITCH_WHEN_EMPTY); +#endif + return true; } @@ -1516,6 +1660,134 @@ bool CBaseCombatWeapon::Holster( CBaseCombatWeapon *pSwitchingTo ) } #else + +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBaseCombatWeapon::InputSetAmmo1( inputdata_t &inputdata ) +{ + SetAmmoFromMapper(inputdata.value.Float()); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBaseCombatWeapon::InputSetAmmo2( inputdata_t &inputdata ) +{ + SetAmmoFromMapper(inputdata.value.Float(), true); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBaseCombatWeapon::InputGiveDefaultAmmo( inputdata_t &inputdata ) +{ + GiveDefaultAmmo(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBaseCombatWeapon::InputEnablePlayerPickup( inputdata_t &inputdata ) +{ + RemoveSpawnFlags(SF_WEAPON_NO_PLAYER_PICKUP); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBaseCombatWeapon::InputDisablePlayerPickup( inputdata_t &inputdata ) +{ + AddSpawnFlags(SF_WEAPON_NO_PLAYER_PICKUP); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBaseCombatWeapon::InputEnableNPCPickup( inputdata_t &inputdata ) +{ + RemoveSpawnFlags(SF_WEAPON_NO_NPC_PICKUP); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBaseCombatWeapon::InputDisableNPCPickup( inputdata_t &inputdata ) +{ + AddSpawnFlags(SF_WEAPON_NO_NPC_PICKUP); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBaseCombatWeapon::InputBreakConstraint( inputdata_t &inputdata ) +{ + if ( m_pConstraint != NULL ) + { + physenv->DestroyConstraint( m_pConstraint ); + m_pConstraint = NULL; + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBaseCombatWeapon::InputForceFire( inputdata_t &inputdata, bool bSecondary ) +{ + CBaseCombatCharacter *pOperator = ToBaseCombatCharacter(GetOwnerEntity()); + + if (!pOperator) + { + // No owner. This means they want us to fire while possibly on the floor independent of any NPC...the madmapper! + pOperator = ToBaseCombatCharacter(inputdata.pActivator); + if (pOperator && pOperator->IsNPC()) + { + // Use this guy, I guess + Operator_ForceNPCFire(pOperator, bSecondary); + } + else + { + // Well...I learned this trick from ent_info. If you have any better ideas, be my guest. + pOperator = CreateEntityByName("generic_actor")->MyCombatCharacterPointer(); + pOperator->SetAbsOrigin(GetAbsOrigin()); + pOperator->SetAbsAngles(GetAbsAngles()); + SetOwnerEntity(pOperator); + + Operator_ForceNPCFire(pOperator, bSecondary); + + UTIL_RemoveImmediate(pOperator); + } + } + else if (pOperator->IsPlayer()) + { + // Owner exists and is a player. + bSecondary ? SecondaryAttack() : PrimaryAttack(); + } + else + { + // Owner exists and is a NPC. + Operator_ForceNPCFire(pOperator, bSecondary); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBaseCombatWeapon::InputForcePrimaryFire( inputdata_t &inputdata ) +{ + InputForceFire(inputdata, false); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBaseCombatWeapon::InputForceSecondaryFire( inputdata_t &inputdata ) +{ + InputForceFire(inputdata, true); +} +#endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -1669,6 +1941,14 @@ void CBaseCombatWeapon::ItemPostFrame( void ) // Secondary attack has priority if ((pOwner->m_nButtons & IN_ATTACK2) && (m_flNextSecondaryAttack <= gpGlobals->curtime)) { +#ifdef MAPBASE + if (pOwner->HasSpawnFlags(SF_PLAYER_SUPPRESS_FIRING)) + { + // Don't do anything, just cancel the whole function + return; + } + else +#endif if (UsesSecondaryAmmo() && pOwner->GetAmmoCount(m_iSecondaryAmmoType)<=0 ) { if (m_flNextEmptySoundTime < gpGlobals->curtime) @@ -1714,6 +1994,14 @@ void CBaseCombatWeapon::ItemPostFrame( void ) if ( !bFired && (pOwner->m_nButtons & IN_ATTACK) && (m_flNextPrimaryAttack <= gpGlobals->curtime)) { +#ifdef MAPBASE + if (pOwner->HasSpawnFlags( SF_PLAYER_SUPPRESS_FIRING )) + { + // Don't do anything, just cancel the whole function + return; + } + else +#endif // Clip empty? Or out of ammo on a no-clip weapon? if ( !IsMeleeWeapon() && (( UsesClipsForAmmo1() && m_iClip1 <= 0) || ( !UsesClipsForAmmo1() && pOwner->GetAmmoCount(m_iPrimaryAmmoType)<=0 )) ) @@ -1998,6 +2286,15 @@ bool CBaseCombatWeapon::DefaultReload( int iClipSize1, int iClipSize2, int iActi #endif SendWeaponAnim( iActivity ); +#ifdef MAPBASE + // TEMPTEMP +#ifdef CLIENT_DLL + //DevMsg("Client SF from primary attack: %i\n", m_spawnflags); +#else + //DevMsg("Server SF from primary attack: %i\n", m_spawnflags); +#endif +#endif + // Play the player's reload animation if ( pOwner->IsPlayer() ) { @@ -2647,11 +2944,27 @@ BEGIN_DATADESC( CBaseCombatWeapon ) DEFINE_THINKFUNC( HideThink ), DEFINE_INPUTFUNC( FIELD_VOID, "HideWeapon", InputHideWeapon ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetAmmo1", InputSetAmmo1 ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetAmmo2", InputSetAmmo2 ), + DEFINE_INPUTFUNC( FIELD_VOID, "GiveDefaultAmmo", InputGiveDefaultAmmo ), + DEFINE_INPUTFUNC( FIELD_VOID, "EnablePlayerPickup", InputEnablePlayerPickup ), + DEFINE_INPUTFUNC( FIELD_VOID, "DisablePlayerPickup", InputDisablePlayerPickup ), + DEFINE_INPUTFUNC( FIELD_VOID, "EnableNPCPickup", InputEnableNPCPickup ), + DEFINE_INPUTFUNC( FIELD_VOID, "DisableNPCPickup", InputDisableNPCPickup ), + DEFINE_INPUTFUNC( FIELD_VOID, "BreakConstraint", InputBreakConstraint ), + DEFINE_INPUTFUNC( FIELD_VOID, "ForcePrimaryFire", InputForcePrimaryFire ), + DEFINE_INPUTFUNC( FIELD_VOID, "ForceSecondaryFire", InputForceSecondaryFire ), +#endif + // Outputs DEFINE_OUTPUT( m_OnPlayerUse, "OnPlayerUse"), DEFINE_OUTPUT( m_OnPlayerPickup, "OnPlayerPickup"), DEFINE_OUTPUT( m_OnNPCPickup, "OnNPCPickup"), DEFINE_OUTPUT( m_OnCacheInteraction, "OnCacheInteraction" ), +#ifdef MAPBASE + DEFINE_OUTPUT( m_OnDropped, "OnDropped" ), +#endif END_DATADESC() @@ -2698,6 +3011,16 @@ void* SendProxy_SendLocalWeaponDataTable( const SendProp *pProp, const void *pSt pRecipients->SetOnly( pPlayer->GetClientIndex() ); return (void*)pVarData; } +#ifdef MAPBASE + else if (pWeapon->HasSpawnFlags( SF_WEAPON_PRESERVE_AMMO )) + { + // Ammo values are sent to the client using this proxy. + // Preserved ammo values from the server need to be sent to the client ASAP to avoid HUD issues, etc. + // I've tried many nasty hacks, but this is the one that works well enough and there's not much else we could do. + pRecipients->SetAllRecipients(); + return (void*)pVarData; + } +#endif } return NULL; @@ -2794,6 +3117,11 @@ BEGIN_NETWORK_TABLE(CBaseCombatWeapon, DT_BaseCombatWeapon) SendPropModelIndex( SENDINFO(m_iWorldModelIndex) ), SendPropInt( SENDINFO(m_iState ), 8, SPROP_UNSIGNED ), SendPropEHandle( SENDINFO(m_hOwner) ), + +#ifdef MAPBASE + SendPropInt( SENDINFO(m_spawnflags), 8, SPROP_UNSIGNED ), +#endif + #else RecvPropDataTable("LocalWeaponData", 0, 0, &REFERENCE_RECV_TABLE(DT_LocalWeaponData)), RecvPropDataTable("LocalActiveWeaponData", 0, 0, &REFERENCE_RECV_TABLE(DT_LocalActiveWeaponData)), @@ -2801,5 +3129,10 @@ BEGIN_NETWORK_TABLE(CBaseCombatWeapon, DT_BaseCombatWeapon) RecvPropInt( RECVINFO(m_iWorldModelIndex)), RecvPropInt( RECVINFO(m_iState )), RecvPropEHandle( RECVINFO(m_hOwner ) ), + +#ifdef MAPBASE + RecvPropInt( RECVINFO( m_spawnflags ) ), +#endif + #endif END_NETWORK_TABLE() diff --git a/sp/src/game/shared/basecombatweapon_shared.h b/sp/src/game/shared/basecombatweapon_shared.h index 701403a0..04593691 100644 --- a/sp/src/game/shared/basecombatweapon_shared.h +++ b/sp/src/game/shared/basecombatweapon_shared.h @@ -48,6 +48,25 @@ class CUserCmd; #define SF_WEAPON_START_CONSTRAINED (1<<0) #define SF_WEAPON_NO_PLAYER_PICKUP (1<<1) #define SF_WEAPON_NO_PHYSCANNON_PUNT (1<<2) +#ifdef MAPBASE +// I really, REALLY hope no weapon uses their own spawnflags. +// If you want yours to use spawnflags, start at 16 just to be safe. + +// Prevents NPCs from picking up the weapon. +#define SF_WEAPON_NO_NPC_PICKUP (1<<3) +// Prevents the weapon from filling up to max automatically +// when picked up by the player or dropped. +#define SF_WEAPON_PRESERVE_AMMO (1<<4) + +// ---------------------------------------------- +// Internal Spawnflags +// +// For all of the weapons that show up in-game, I personally feel like +// this beats adding new variables by at least a long shot. +// ---------------------------------------------- +#define SF_WEAPON_NO_AUTO_SWITCH_WHEN_EMPTY (1<<5) // So weapons with ammo preserved at 0 don't switch. +#define SF_WEAPON_USED (1<<6) // Weapon is being +USE'd, not bumped +#endif //Percent #define CLIP_PERC_THRESHOLD 0.75f @@ -91,6 +110,26 @@ namespace vgui2 typedef unsigned long HFont; } +#ifdef MAPBASE +// ------------------ +// Weapon classes +// ------------------ +// I found myself in situations where this is useful. +// Their purpose is similar to Class_T on NPCs. + +enum WeaponClass_t +{ + WEPCLASS_INVALID = 0, + + WEPCLASS_HANDGUN, + WEPCLASS_RIFLE, + WEPCLASS_SHOTGUN, + WEPCLASS_HEAVY, + + WEPCLASS_MELEE, +}; +#endif + // ----------------------------------------- // Vector cones // ----------------------------------------- @@ -173,12 +212,25 @@ public: virtual void Spawn( void ); virtual void Precache( void ); +#ifdef MAPBASE + void SetAmmoFromMapper( float flAmmo, bool bSecondary = false ); + virtual bool KeyValue( const char *szKeyName, const char *szValue ); + virtual bool GetKeyValue( const char *szKeyName, char *szValue, int iMaxLen ); +#endif + void MakeTracer( const Vector &vecTracerSrc, const trace_t &tr, int iTracerType ); // Subtypes are used to manage multiple weapons of the same type on the player. virtual int GetSubType( void ) { return m_iSubType; } virtual void SetSubType( int iType ) { m_iSubType = iType; } +#ifdef MAPBASE + virtual WeaponClass_t WeaponClassify(); + static WeaponClass_t WeaponClassFromString(const char *str); + + virtual bool SupportsBackupActivity(Activity activity); +#endif + virtual void Equip( CBaseCombatCharacter *pOwner ); virtual void Drop( const Vector &vecVelocity ); @@ -264,6 +316,10 @@ public: virtual bool Reload( void ); bool DefaultReload( int iClipSize1, int iClipSize2, int iActivity ); bool ReloadsSingly( void ) const; +#ifdef MAPBASE + // Originally created for the crossbow, can be used to add special NPC reloading behavior + virtual void Reload_NPC( void ) { WeaponSound(RELOAD_NPC); m_iClip1 = GetMaxClip1(); } +#endif virtual bool AutoFiresFullClip( void ) { return false; } virtual bool CanOverload( void ) { return false; } @@ -438,6 +494,19 @@ public: virtual int UpdateTransmitState( void ); +#ifdef MAPBASE + void InputSetAmmo1( inputdata_t &inputdata ); + void InputSetAmmo2( inputdata_t &inputdata ); + void InputGiveDefaultAmmo( inputdata_t &inputdata ); + void InputEnablePlayerPickup( inputdata_t &inputdata ); + void InputDisablePlayerPickup( inputdata_t &inputdata ); + void InputEnableNPCPickup( inputdata_t &inputdata ); + void InputDisableNPCPickup( inputdata_t &inputdata ); + void InputBreakConstraint( inputdata_t &inputdata ); + void InputForceFire( inputdata_t &inputdata, bool bSecondary = false ); + void InputForcePrimaryFire( inputdata_t &inputdata ); + void InputForceSecondaryFire( inputdata_t &inputdata ); +#endif void InputHideWeapon( inputdata_t &inputdata ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); @@ -600,6 +669,18 @@ public: CNetworkVar( bool, m_bFlipViewModel ); +#ifdef MAPBASE +#ifdef CLIENT_DLL + int m_spawnflags; + + inline bool HasSpawnFlags( int flags ) { return (m_spawnflags & flags) != 0; } + inline void RemoveSpawnFlags( int flags ) { m_spawnflags &= ~flags; } + inline void AddSpawnFlags( int flags ) { m_spawnflags |= flags; } +#else + //IMPLEMENT_NETWORK_VAR_FOR_DERIVED(m_spawnflags); +#endif +#endif + IPhysicsConstraint *GetConstraint() { return m_pConstraint; } private: @@ -622,6 +703,9 @@ protected: COutputEvent m_OnPlayerPickup; // Fired when the player picks up the weapon. COutputEvent m_OnNPCPickup; // Fired when an NPC picks up the weapon. COutputEvent m_OnCacheInteraction; // For awarding lambda cache achievements in HL2 on 360. See .FGD file for details +#ifdef MAPBASE + COutputEvent m_OnDropped; +#endif #else // Client .dll only bool m_bJustRestored; diff --git a/sp/src/game/shared/baseentity_shared.cpp b/sp/src/game/shared/baseentity_shared.cpp index 43348cb1..de825fe1 100644 --- a/sp/src/game/shared/baseentity_shared.cpp +++ b/sp/src/game/shared/baseentity_shared.cpp @@ -408,7 +408,11 @@ bool CBaseEntity::KeyValue( const char *szKeyName, const char *szValue ) } // Do this so inherited classes looking for 'angles' don't have to bother with 'angle' +#ifdef MAPBASE + return KeyValue( "angles", szBuf ); +#else return KeyValue( szKeyName, szBuf ); +#endif } // NOTE: Have to do these separate because they set two values instead of one @@ -1668,6 +1672,19 @@ void CBaseEntity::FireBullets( const FireBulletsInfo_t &info ) } #endif // SERVER_DLL +#ifdef MAPBASE + if (info.m_pIgnoreEntList != NULL) + { + for (int i = 0; i < info.m_pIgnoreEntList->Count(); i++) + { + if (info.m_pIgnoreEntList->Element(i)) + { + traceFilter.AddEntityToIgnore(info.m_pIgnoreEntList->Element(i)); + } + } + } +#endif + bool bUnderwaterBullets = ShouldDrawUnderwaterBulletBubbles(); bool bStartedInWater = false; if ( bUnderwaterBullets ) @@ -2138,7 +2155,11 @@ void CBaseEntity::TraceAttack( const CTakeDamageInfo &info, const Vector &vecDir int blood = BloodColor(); +#if defined(MAPBASE) && defined(GAME_DLL) + if ( blood != DONT_BLEED && DamageFilterAllowsBlood( info ) ) +#else if ( blood != DONT_BLEED ) +#endif { SpawnBlood( vecOrigin, vecDir, blood, info.GetDamage() );// a little surface blood. TraceBleed( info.GetDamage(), vecDir, ptr, info.GetDamageType() ); diff --git a/sp/src/game/shared/basegrenade_shared.cpp b/sp/src/game/shared/basegrenade_shared.cpp index b981d078..e471d870 100644 --- a/sp/src/game/shared/basegrenade_shared.cpp +++ b/sp/src/game/shared/basegrenade_shared.cpp @@ -34,13 +34,29 @@ BEGIN_DATADESC( CBaseGrenade ) DEFINE_FIELD( m_hThrower, FIELD_EHANDLE ), // m_fRegisteredSound ??? DEFINE_FIELD( m_bIsLive, FIELD_BOOLEAN ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_DmgRadius, FIELD_FLOAT, "Radius" ), +#else DEFINE_FIELD( m_DmgRadius, FIELD_FLOAT ), +#endif DEFINE_FIELD( m_flDetonateTime, FIELD_TIME ), DEFINE_FIELD( m_flWarnAITime, FIELD_TIME ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_flDamage, FIELD_FLOAT, "Damage" ), +#else DEFINE_FIELD( m_flDamage, FIELD_FLOAT ), +#endif DEFINE_FIELD( m_iszBounceSound, FIELD_STRING ), DEFINE_FIELD( m_bHasWarnedAI, FIELD_BOOLEAN ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetDamage", InputSetDamage ), + DEFINE_INPUTFUNC( FIELD_VOID, "Detonate", InputDetonate ), + + DEFINE_OUTPUT( m_OnDetonate, "OnDetonate" ), + DEFINE_OUTPUT( m_OnDetonate_OutPosition, "OnDetonate_OutPosition" ), +#endif + // Function Pointers DEFINE_THINKFUNC( Smoke ), DEFINE_ENTITYFUNC( BounceTouch ), @@ -180,6 +196,11 @@ void CBaseGrenade::Explode( trace_t *pTrace, int bitsDamageType ) EmitSound( "BaseGrenade.Explode" ); +#ifdef MAPBASE + m_OnDetonate.FireOutput(GetThrower(), this); + m_OnDetonate_OutPosition.Set(GetAbsOrigin(), GetThrower(), this); +#endif + SetThink( &CBaseGrenade::SUB_Remove ); SetTouch( NULL ); SetSolid( SOLID_NONE ); @@ -258,6 +279,25 @@ void CBaseGrenade::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE // Pass up so we still call any custom Use function BaseClass::Use( pActivator, pCaller, useType, value ); } + +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBaseGrenade::InputSetDamage( inputdata_t &inputdata ) +{ + SetDamage( inputdata.value.Float() ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBaseGrenade::InputDetonate( inputdata_t &inputdata ) +{ + Detonate(); +} +#endif + #endif //----------------------------------------------------------------------------- diff --git a/sp/src/game/shared/basegrenade_shared.h b/sp/src/game/shared/basegrenade_shared.h index 38bb684d..ba603d27 100644 --- a/sp/src/game/shared/basegrenade_shared.h +++ b/sp/src/game/shared/basegrenade_shared.h @@ -111,6 +111,12 @@ public: } void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + +#ifdef MAPBASE + void InputSetDamage( inputdata_t &inputdata ); + void InputDetonate( inputdata_t &inputdata ); +#endif + #endif public: @@ -129,6 +135,11 @@ protected: CNetworkVar( float, m_flDamage ); // Damage to inflict. string_t m_iszBounceSound; // The sound to make on bouncing. If not NULL, overrides the BounceSound() function. +#if defined(MAPBASE) && !defined(CLIENT_DLL) + COutputEvent m_OnDetonate; + COutputVector m_OnDetonate_OutPosition; +#endif + private: CNetworkHandle( CBaseEntity, m_hThrower ); // Who threw this grenade EHANDLE m_hOriginalThrower; // Who was the original thrower of this grenade diff --git a/sp/src/game/shared/baseplayer_shared.h b/sp/src/game/shared/baseplayer_shared.h index 8bdc0950..609d82fb 100644 --- a/sp/src/game/shared/baseplayer_shared.h +++ b/sp/src/game/shared/baseplayer_shared.h @@ -53,6 +53,17 @@ enum stepsoundtimes_t void CopySoundNameWithModifierToken( char *pchDest, const char *pchSource, int nMaxLenInChars, const char *pchToken ); +#ifdef MAPBASE +// Internal player spawnflags. +// These are only meant to be used internally or accessed via logic_playerproxy. +// I'm sure this isn't a bad idea whatsoever... +// +// Be sure to update the SendPropInt() entry for m_spawnflags in player.cpp when you add any new spawnflags! +#define SF_PLAYER_NO_GEIGER (1 << 0) +#define SF_PLAYER_HIDE_SQUAD_HUD (1 << 1) +#define SF_PLAYER_SUPPRESS_FIRING (1 << 2) +#endif + // Shared header file for players #if defined( CLIENT_DLL ) #define CBasePlayer C_BasePlayer diff --git a/sp/src/game/shared/baseviewmodel_shared.cpp b/sp/src/game/shared/baseviewmodel_shared.cpp index 20538e8c..d789d3f3 100644 --- a/sp/src/game/shared/baseviewmodel_shared.cpp +++ b/sp/src/game/shared/baseviewmodel_shared.cpp @@ -689,3 +689,35 @@ bool CBaseViewModel::GetAttachmentVelocity( int number, Vector &originVel, Quate } #endif + +#ifdef MAPBASE +#if defined( CLIENT_DLL ) +#define CHandViewModel C_HandViewModel +#endif + +// --------------------------------------- +// OzxyBox's hand viewmodel code. +// All credit goes to him. +// --------------------------------------- +class CHandViewModel : public CBaseViewModel +{ + DECLARE_CLASS( CHandViewModel, CBaseViewModel ); +public: + DECLARE_NETWORKCLASS(); +private: +}; + +LINK_ENTITY_TO_CLASS(hand_viewmodel, CHandViewModel); +IMPLEMENT_NETWORKCLASS_ALIASED(HandViewModel, DT_HandViewModel) + +// for whatever reason the parent doesn't get sent +// I don't really want to mess with the baseviewmodel +// so now it does +BEGIN_NETWORK_TABLE(CHandViewModel, DT_HandViewModel) +#ifndef CLIENT_DLL + SendPropEHandle(SENDINFO_NAME(m_hMoveParent, moveparent)), +#else + RecvPropInt(RECVINFO_NAME(m_hNetworkMoveParent, moveparent), 0, RecvProxy_IntToMoveParent), +#endif +END_NETWORK_TABLE() +#endif diff --git a/sp/src/game/shared/baseviewmodel_shared.h b/sp/src/game/shared/baseviewmodel_shared.h index 15d3be53..7e9c79a6 100644 --- a/sp/src/game/shared/baseviewmodel_shared.h +++ b/sp/src/game/shared/baseviewmodel_shared.h @@ -145,7 +145,11 @@ public: // Should this object receive shadows? virtual bool ShouldReceiveProjectedTextures( int flags ) { +#ifdef MAPBASE + return true; +#else return false; +#endif } // Add entity to visible view models list? diff --git a/sp/src/game/shared/beam_shared.cpp b/sp/src/game/shared/beam_shared.cpp index 77e5d5c2..c3e39af8 100644 --- a/sp/src/game/shared/beam_shared.cpp +++ b/sp/src/game/shared/beam_shared.cpp @@ -773,7 +773,9 @@ void CBeam::BeamDamage( trace_t *ptr ) if ( ptr->fraction != 1.0 && ptr->m_pEnt != NULL ) { CBaseEntity *pHit = ptr->m_pEnt; +#ifndef MAPBASE if ( pHit ) +#endif { ClearMultiDamage(); Vector dir = ptr->endpos - GetAbsOrigin(); diff --git a/sp/src/game/shared/env_wind_shared.cpp b/sp/src/game/shared/env_wind_shared.cpp index 422e9e99..e090e8ec 100644 --- a/sp/src/game/shared/env_wind_shared.cpp +++ b/sp/src/game/shared/env_wind_shared.cpp @@ -77,12 +77,19 @@ //----------------------------------------------------------------------------- // globals //----------------------------------------------------------------------------- +#ifdef MAPBASE +static CUtlLinkedList< CEnvWindShared * > s_windControllers; +#else static Vector s_vecWindVelocity( 0, 0, 0 ); - +#endif CEnvWindShared::CEnvWindShared() : m_WindAveQueue(10), m_WindVariationQueue(10) { m_pWindSound = NULL; +#ifdef MAPBASE + s_windControllers.AddToTail( this ); + m_windRadius = -1.0f; +#endif } CEnvWindShared::~CEnvWindShared() @@ -91,6 +98,9 @@ CEnvWindShared::~CEnvWindShared() { CSoundEnvelopeController::GetController().Shutdown( m_pWindSound ); } +#ifdef MAPBASE + s_windControllers.FindAndRemove( this ); +#endif } void CEnvWindShared::Init( int nEntIndex, int iRandomSeed, float flTime, @@ -103,6 +113,13 @@ void CEnvWindShared::Init( int nEntIndex, int iRandomSeed, float flTime, m_Stream.SetSeed( iRandomSeed ); m_WindVariationStream.SetSeed( iRandomSeed ); m_iWindDir = m_iInitialWindDir = iInitialWindYaw; +#ifdef MAPBASE + // Bound it for networking as a postive integer + m_iInitialWindDir = (int)( anglemod( m_iInitialWindDir ) ); + + if (m_windRadiusInner == 0.0f) + m_windRadiusInner = m_windRadius; +#endif m_flAveWindSpeed = m_flWindSpeed = m_flInitialWindSpeed = flInitialWindSpeed; @@ -218,9 +235,15 @@ float CEnvWindShared::WindThink( float flTime ) // We're about to exit, let's set the wind velocity... QAngle vecWindAngle( 0, m_iWindDir + m_flWindAngleVariation, 0 ); +#ifdef MAPBASE + AngleVectors( vecWindAngle, &m_currentWindVector ); + float flTotalWindSpeed = m_flWindSpeed * m_flWindSpeedVariation; + m_currentWindVector *= flTotalWindSpeed; +#else AngleVectors( vecWindAngle, &s_vecWindVelocity ); float flTotalWindSpeed = m_flWindSpeed * m_flWindSpeedVariation; s_vecWindVelocity *= flTotalWindSpeed; +#endif // If we reached a steady state, we don't need to be called until the switch time // Otherwise, we should be called immediately @@ -278,9 +301,67 @@ float CEnvWindShared::WindThink( float flTime ) //----------------------------------------------------------------------------- void ResetWindspeed() { +#ifdef MAPBASE + FOR_EACH_LL( s_windControllers, it ) + { + s_windControllers[it]->m_currentWindVector.Init( 0, 0, 0 ); + } +#else s_vecWindVelocity.Init( 0, 0, 0 ); +#endif } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// GetWindspeedAtTime was never finished to actually take time in to consideration. We don't need +// features that aren't written, but we do need to have multiple wind controllers on a map, so +// we need to find the one that is affecting the given location and return its speed. +// +// NEW WITH MAPBASE: Inner-radius! +// You can now choose an inner-radius for your wind, which allows for varying intensities at different distances. +// This can mix in with a global wind controller or even other wind controllers. +// (note: wind is additive and does not blend into itself, maybe fix that sometime) +//----------------------------------------------------------------------------- +Vector GetWindspeedAtLocation( const Vector &location ) +{ + Vector wind = Vector( 0, 0, 0 ); + + FOR_EACH_LL( s_windControllers, it ) + { + CEnvWindShared *thisWindController = s_windControllers[it]; + float distance = (thisWindController->m_location - location).Length(); + + if( distance < thisWindController->m_windRadius ) + { + if (distance > thisWindController->m_windRadiusInner) + { + // New with Mapbase: Inner-radius! + wind += thisWindController->m_currentWindVector * + ((distance - thisWindController->m_windRadiusInner) / (thisWindController->m_windRadius - thisWindController->m_windRadiusInner)); + } + else + { + // This location is within our area of influence, so return our computer wind vector + return thisWindController->m_currentWindVector; + } + } + } + + FOR_EACH_LL( s_windControllers, it ) + { + CEnvWindShared *thisWindController = s_windControllers[it]; + + if( thisWindController->m_windRadius == -1.0f ) + { + // We do a second search for a global controller so you don't have to worry about order in the list. + //wind += thisWindController->m_currentWindVector; + wind = VectorLerp( wind, thisWindController->m_currentWindVector, 1.0f ); + } + } + + return wind;// No wind +} +#endif //----------------------------------------------------------------------------- // Method to sample the windspeed at a particular time @@ -289,5 +370,16 @@ void GetWindspeedAtTime( float flTime, Vector &vecVelocity ) { // For now, ignore history and time.. fix later when we use wind to affect // client-side prediction +#ifdef MAPBASE + if ( s_windControllers.Count() == 0 ) + { + vecVelocity.Init( 0, 0, 0 ); + } + else + { + VectorCopy( s_windControllers[ s_windControllers.Head() ]->m_currentWindVector, vecVelocity ); + } +#else VectorCopy( s_vecWindVelocity, vecVelocity ); +#endif } diff --git a/sp/src/game/shared/env_wind_shared.h b/sp/src/game/shared/env_wind_shared.h index e1084e9f..c7e23e12 100644 --- a/sp/src/game/shared/env_wind_shared.h +++ b/sp/src/game/shared/env_wind_shared.h @@ -145,6 +145,10 @@ public: void Init( int iEntIndex, int iRandomSeed, float flTime, int iWindDir, float flInitialWindSpeed ); +#ifdef MAPBASE + void SetLocation( const Vector &location ); +#endif + // Method to update the wind speed // Time passed in here is global time, not delta time // The function returns the time at which it must be called again @@ -157,6 +161,10 @@ public: CNetworkVar( int, m_iMinWind ); // the slowest the wind can normally blow CNetworkVar( int, m_iMaxWind ); // the fastest the wind can normally blow +#ifdef MAPBASE + CNetworkVar( float, m_windRadius ); // the radius this entity affects with its windiness, so a map can have multiple + CNetworkVar( float, m_windRadiusInner ); // the inner-radius for noticable distance fading +#endif CNetworkVar( int, m_iMinGust ); // the slowest that a gust can be CNetworkVar( int, m_iMaxGust ); // the fastest that a gust can be @@ -166,10 +174,17 @@ public: CNetworkVar( float, m_flGustDuration ); // max time between gusts CNetworkVar( int, m_iGustDirChange ); // max number of degrees wind dir changes on gusts. +#ifdef MAPBASE + CNetworkVector( m_location ); // The location of this wind controller +#endif int m_iszGustSound; // name of the wind sound to play for gusts. int m_iWindDir; // wind direction (yaw) float m_flWindSpeed; // the wind speed +#ifdef MAPBASE + Vector m_currentWindVector; // For all the talk of proper prediction, we ended up just storing and returning through a static vector. Now we can have multiple env_wind, so we need this in here. +#endif + CNetworkVar( int, m_iInitialWindDir ); CNetworkVar( float, m_flInitialWindSpeed ); @@ -227,6 +242,19 @@ private: CEnvWindShared( const CEnvWindShared & ); // not defined, not accessible }; +#ifdef MAPBASE +//----------------------------------------------------------------------------- +inline void CEnvWindShared::SetLocation( const Vector &location ) +{ + m_location = location; +} + + +//----------------------------------------------------------------------------- +// Method to sample the wind speed at a particular location +//----------------------------------------------------------------------------- +Vector GetWindspeedAtLocation( const Vector &location ); +#endif //----------------------------------------------------------------------------- // Method to sample the windspeed at a particular time diff --git a/sp/src/game/shared/eventlist.cpp b/sp/src/game/shared/eventlist.cpp index e5b01fed..043293bc 100644 --- a/sp/src/game/shared/eventlist.cpp +++ b/sp/src/game/shared/eventlist.cpp @@ -248,4 +248,9 @@ void EventList_RegisterSharedEvents( void ) REGISTER_SHARED_ANIMEVENT( AE_WPN_UNHIDE, AE_TYPE_CLIENT | AE_TYPE_SERVER ); REGISTER_SHARED_ANIMEVENT( AE_WPN_PLAYWPNSOUND, AE_TYPE_CLIENT | AE_TYPE_SERVER ); + +#ifdef MAPBASE + REGISTER_SHARED_ANIMEVENT( AE_NPC_RESPONSE, AE_TYPE_SERVER ); + REGISTER_SHARED_ANIMEVENT( AE_NPC_RESPONSE_FORCED, AE_TYPE_SERVER ); +#endif } \ No newline at end of file diff --git a/sp/src/game/shared/eventlist.h b/sp/src/game/shared/eventlist.h index 1ce83a4c..ee8b38df 100644 --- a/sp/src/game/shared/eventlist.h +++ b/sp/src/game/shared/eventlist.h @@ -85,6 +85,11 @@ typedef enum AE_WPN_PLAYWPNSOUND, // Play a weapon sound from the weapon script file +#ifdef MAPBASE + AE_NPC_RESPONSE, // Play a response system concept if we're not speaking + AE_NPC_RESPONSE_FORCED, // Always play a response system concept +#endif + LAST_SHARED_ANIMEVENT, } Animevent; diff --git a/sp/src/game/shared/func_ladder.cpp b/sp/src/game/shared/func_ladder.cpp index 05f81571..306ae77d 100644 --- a/sp/src/game/shared/func_ladder.cpp +++ b/sp/src/game/shared/func_ladder.cpp @@ -5,6 +5,9 @@ //=============================================================================// #include "cbase.h" #include "func_ladder.h" +#ifdef MAPBASE +#include "hl_gamemovement.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -13,6 +16,10 @@ /*static*/ ConVar sv_showladders( "sv_showladders", "0", 0, "Show bbox and dismount points for all ladders (must be set before level load.)\n" ); #endif +#if MAPBASE +extern IGameMovement *g_pGameMovement; +#endif + CUtlVector< CFuncLadder * > CFuncLadder::s_Ladders; //----------------------------------------------------------------------------- // Purpose: @@ -105,7 +112,11 @@ void CFuncLadder::Spawn() } // Force geometry overlays on, but only if developer 2 is set... +#ifdef MAPBASE + if ( sv_showladders.GetBool() ) +#else if ( developer.GetInt() > 1 ) +#endif { m_debugOverlays |= OVERLAY_TEXT_BIT; } @@ -385,6 +396,26 @@ void CFuncLadder::InputDisable( inputdata_t &inputdata ) m_bDisabled = true; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CFuncLadder::InputForcePlayerOn( inputdata_t &inputdata ) +{ + static_cast(g_pGameMovement)->ForcePlayerOntoLadder(this); +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CFuncLadder::InputCheckPlayerOn( inputdata_t &inputdata ) +{ + static_cast(g_pGameMovement)->MountPlayerOntoLadder(this); +} +#endif + //----------------------------------------------------------------------------- // Purpose: // Input : *pPlayer - @@ -462,6 +493,10 @@ BEGIN_DATADESC( CFuncLadder ) DEFINE_KEYFIELD( m_surfacePropName,FIELD_STRING, "ladderSurfaceProperties" ), DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "ForcePlayerOn", InputForcePlayerOn ), + DEFINE_INPUTFUNC( FIELD_VOID, "CheckPlayerOn", InputCheckPlayerOn ), +#endif DEFINE_OUTPUT( m_OnPlayerGotOnLadder, "OnPlayerGotOnLadder" ), DEFINE_OUTPUT( m_OnPlayerGotOffLadder, "OnPlayerGotOffLadder" ), diff --git a/sp/src/game/shared/func_ladder.h b/sp/src/game/shared/func_ladder.h index 914389d0..50c76eac 100644 --- a/sp/src/game/shared/func_ladder.h +++ b/sp/src/game/shared/func_ladder.h @@ -59,6 +59,11 @@ public: void InputEnable( inputdata_t &inputdata ); void InputDisable( inputdata_t &inputdata ); +#ifdef MAPBASE + void InputForcePlayerOn( inputdata_t &inputdata ); + void InputCheckPlayerOn( inputdata_t &inputdata ); +#endif + bool IsEnabled() const; void PlayerGotOn( CBasePlayer *pPlayer ); diff --git a/sp/src/game/shared/gamemovement.cpp b/sp/src/game/shared/gamemovement.cpp index 8de6fc32..de12a800 100644 --- a/sp/src/game/shared/gamemovement.cpp +++ b/sp/src/game/shared/gamemovement.cpp @@ -2840,7 +2840,7 @@ inline bool CGameMovement::OnLadder( trace_t &trace ) // HPE_BEGIN // [sbodenbender] make ladders easier to climb in cstrike //============================================================================= -#if defined (CSTRIKE_DLL) +#if defined (CSTRIKE_DLL) || defined(HL2_USES_FUNC_LADDER_CODE) ConVar sv_ladder_dampen ( "sv_ladder_dampen", "0.2", FCVAR_REPLICATED, "Amount to dampen perpendicular movement on a ladder", true, 0.0f, true, 1.0f ); ConVar sv_ladder_angle( "sv_ladder_angle", "-0.707", FCVAR_REPLICATED, "Cos of angle of incidence to ladder perpendicular for applying ladder_dampen", true, -1.0f, true, 1.0f ); #endif @@ -3902,6 +3902,16 @@ void CGameMovement::CheckFalling( void ) if ( player->GetGroundEntity() == NULL || player->m_Local.m_flFallVelocity <= 0 ) return; +#ifdef MAPBASE +#ifdef GAME_DLL // Let's hope we could work without transmitting to the client... + if ( player->m_bInTriggerFall ) + { + // This lets the fall damage functions do their magic without having to change them. + player->m_Local.m_flFallVelocity += (PLAYER_FATAL_FALL_SPEED + PLAYER_LAND_ON_FLOATING_OBJECT); + } +#endif +#endif + if ( !IsDead() && player->m_Local.m_flFallVelocity >= PLAYER_FALL_PUNCH_THRESHOLD ) { bool bAlive = true; diff --git a/sp/src/game/shared/gamemovement.h b/sp/src/game/shared/gamemovement.h index 79c83fc1..1c7a3d0f 100644 --- a/sp/src/game/shared/gamemovement.h +++ b/sp/src/game/shared/gamemovement.h @@ -25,6 +25,13 @@ #define GAMEMOVEMENT_TIME_TO_UNDUCK ( TIME_TO_UNDUCK * 1000.0f ) // ms #define GAMEMOVEMENT_TIME_TO_UNDUCK_INV ( GAMEMOVEMENT_DUCK_TIME - GAMEMOVEMENT_TIME_TO_UNDUCK ) +#ifdef MAPBASE +// reddit.com/r/SourceEngine/comments/8vx53b/how_to_get_brush_ladders_working/ +// +// Implements code that allows func_ladder to be used in HL2. +#define HL2_USES_FUNC_LADDER_CODE 1 +#endif + enum { SPEED_CROPPED_RESET = 0, diff --git a/sp/src/game/shared/gamerules.cpp b/sp/src/game/shared/gamerules.cpp index 81fa7bfa..f604e408 100644 --- a/sp/src/game/shared/gamerules.cpp +++ b/sp/src/game/shared/gamerules.cpp @@ -607,6 +607,22 @@ void CGameRules::EndGameFrame( void ) } } +#ifdef MAPBASE +void CGameRules::OnSkillLevelChanged( int iNewLevel ) +{ + variant_t varNewLevel; + varNewLevel.SetInt(iNewLevel); + + // Iterate through all logic_skill entities and fire them + CBaseEntity *pEntity = gEntList.FindEntityByClassname(NULL, "logic_skill"); + while (pEntity) + { + pEntity->AcceptInput("SkillLevelChanged", UTIL_GetLocalPlayer(), NULL, varNewLevel, 0); + pEntity = gEntList.FindEntityByClassname(pEntity, "logic_skill"); + } +} +#endif + //----------------------------------------------------------------------------- // trace line rules //----------------------------------------------------------------------------- diff --git a/sp/src/game/shared/gamerules.h b/sp/src/game/shared/gamerules.h index 4b2f5124..58c29077 100644 --- a/sp/src/game/shared/gamerules.h +++ b/sp/src/game/shared/gamerules.h @@ -233,7 +233,11 @@ public: virtual bool IsSkillLevel( int iLevel ) { return GetSkillLevel() == iLevel; } virtual int GetSkillLevel() { return g_iSkillLevel; } +#ifdef MAPBASE + virtual void OnSkillLevelChanged( int iNewLevel ); +#else virtual void OnSkillLevelChanged( int iNewLevel ) {}; +#endif virtual void SetSkillLevel( int iLevel ) { int oldLevel = g_iSkillLevel; diff --git a/sp/src/game/shared/gamestringpool.cpp b/sp/src/game/shared/gamestringpool.cpp index f75d4ff9..59670e94 100644 --- a/sp/src/game/shared/gamestringpool.cpp +++ b/sp/src/game/shared/gamestringpool.cpp @@ -12,6 +12,9 @@ #include "igamesystem.h" #endif #include "gamestringpool.h" +#if defined(MAPBASE) && defined(GAME_DLL) +#include "mapbase/GlobalStrings.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -26,6 +29,9 @@ class CGameStringPool : public CBaseGameSystem #endif { virtual char const *Name() { return "CGameStringPool"; } +#if defined(MAPBASE) && defined(GAME_DLL) + virtual void LevelInitPreEntity() { InitGlobalStrings(); } +#endif virtual void LevelShutdownPostEntity() { FreeAll(); } void FreeAll() diff --git a/sp/src/game/shared/hl2/hl2_gamerules.cpp b/sp/src/game/shared/hl2/hl2_gamerules.cpp index bdd5abec..67cd191d 100644 --- a/sp/src/game/shared/hl2/hl2_gamerules.cpp +++ b/sp/src/game/shared/hl2/hl2_gamerules.cpp @@ -38,10 +38,198 @@ BEGIN_NETWORK_TABLE_NOBASE( CHalfLife2, DT_HL2GameRules ) #endif END_NETWORK_TABLE() +#if MAPBASE && GAME_DLL +extern bool g_bUseLegacyFlashlight; +extern bool g_bCacheLegacyFlashlightStatus; + +BEGIN_DATADESC( CHalfLife2Proxy ) + + // These get the gamerules values on save and writes to them on restore + DEFINE_FIELD( m_save_DefaultCitizenType, FIELD_INTEGER ), + DEFINE_FIELD( m_save_LegacyFlashlight, FIELD_CHARACTER ), + DEFINE_FIELD( m_save_PlayerSquadAutosummonDisabled, FIELD_BOOLEAN ), + DEFINE_FIELD( m_save_StunstickPickupBehavior, FIELD_INTEGER ), + + // Inputs + DEFINE_INPUTFUNC( FIELD_VOID, "EpisodicOn", InputEpisodicOn ), + DEFINE_INPUTFUNC( FIELD_VOID, "EpisodicOff", InputEpisodicOff ), + + // These are FIELD_STRING because they call KeyValue() directly + DEFINE_INPUTFUNC( FIELD_STRING, "SetFriendlyFire", InputSetFriendlyFire ), + DEFINE_INPUTFUNC( FIELD_STRING, "DefaultCitizenType", InputSetDefaultCitizenType ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetLegacyFlashlight", InputSetLegacyFlashlight ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetPlayerSquadAutosummon", InputSetPlayerSquadAutosummon ), + DEFINE_INPUTFUNC( FIELD_STRING, "SetStunstickPickupBehavior", InputSetStunstickPickupBehavior ), + +END_DATADESC() +#endif LINK_ENTITY_TO_CLASS( hl2_gamerules, CHalfLife2Proxy ); IMPLEMENT_NETWORKCLASS_ALIASED( HalfLife2Proxy, DT_HalfLife2Proxy ) +#if defined(MAPBASE) && defined(GAME_DLL) +void CHalfLife2Proxy::InputEpisodicOn( inputdata_t &inputdata ) { KeyValue("SetEpisodic", "1"); } +void CHalfLife2Proxy::InputEpisodicOff( inputdata_t &inputdata ) { KeyValue("SetEpisodic", "0"); } +void CHalfLife2Proxy::InputSetFriendlyFire( inputdata_t &inputdata ) { KeyValue("GlobalFriendlyFire", inputdata.value.String()); } +void CHalfLife2Proxy::InputSetDefaultCitizenType( inputdata_t &inputdata ) { KeyValue("DefaultCitizenType", inputdata.value.String()); } +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()); } + +//----------------------------------------------------------------------------- +// Purpose: Cache user entity field values until spawn is called. +// Input : szKeyName - Key to handle. +// szValue - Value for key. +// Output : Returns true if the key was handled, false if not. +//----------------------------------------------------------------------------- +bool CHalfLife2Proxy::KeyValue( const char *szKeyName, const char *szValue ) +{ + if (FStrEq(szKeyName, "DefaultCitizenType")) + { + HL2GameRules()->SetDefaultCitizenType(atoi(szValue)); + } + else if (FStrEq(szKeyName, "GlobalFriendlyFire")) + { + HL2GameRules()->SetGlobalFriendlyFire(TO_THREESTATE(atoi(szValue))); + } + else if (FStrEq(szKeyName, "SetEpisodic") && !FStrEq(szValue, "2")) + { + hl2_episodic.SetValue(!FStrEq(szValue, "0")); + } + else if (FStrEq(szKeyName, "SetLegacyFlashlight")) + { + // Turn off flashlights first + for ( int i = 1; i <= gpGlobals->maxClients; i++ ) + { + CBasePlayer *pPlayer = UTIL_PlayerByIndex( i ); + + if ( pPlayer ) + { + if (pPlayer->FlashlightIsOn()) + pPlayer->FlashlightTurnOff(); + } + } + + g_bUseLegacyFlashlight = !FStrEq(szValue, "0"); + + // We have overridden it, don't test directory + g_bCacheLegacyFlashlightStatus = false; + + // Tell our save/load we've modified it + // 1 = modified, 2 = legacy enabled + m_save_LegacyFlashlight |= 1; + if (g_bUseLegacyFlashlight) + m_save_LegacyFlashlight |= 2; + } + else if (FStrEq(szKeyName, "SetPlayerSquadAutosummon")) + { + HL2GameRules()->SetAutosummonDisabled(FStrEq(szValue, "0")); + } + else if (FStrEq(szKeyName, "SetStunstickPickupBehavior")) + { + HL2GameRules()->SetStunstickPickupBehavior(atoi(szValue)); + } + else + { + return BaseClass::KeyValue( szKeyName, szValue ); + } + + return true; +} + +bool CHalfLife2Proxy::GetKeyValue( const char *szKeyName, char *szValue, int iMaxLen ) +{ + if (FStrEq(szKeyName, "DefaultCitizenType")) + { + Q_snprintf( szValue, iMaxLen, "%i", HL2GameRules()->GetDefaultCitizenType() ); + } + else if (FStrEq(szKeyName, "GlobalFriendlyFire")) + { + Q_snprintf( szValue, iMaxLen, "%i", HL2GameRules()->GlobalFriendlyFire() ); + } + else if (FStrEq(szKeyName, "SetEpisodic") && !FStrEq(szValue, "2")) + { + Q_snprintf( szValue, iMaxLen, "%s", hl2_episodic.GetString() ); + } + else if (FStrEq(szKeyName, "SetLegacyFlashlight")) + { + Q_snprintf( szValue, iMaxLen, "%d", g_bUseLegacyFlashlight ); + } + else if (FStrEq(szKeyName, "SetStunstickPickupBehavior")) + { + Q_snprintf( szValue, iMaxLen, "%i", HL2GameRules()->GetStunstickPickupBehavior() ); + } + else + { + return BaseClass::GetKeyValue( szKeyName, szValue, iMaxLen ); + } + + return true; +} + +//----------------------------------------------------------------------------- +// Purpose: Saves the current object out to disk, by iterating through the objects +// data description hierarchy +// Input : &save - save buffer which the class data is written to +// Output : int - 0 if the save failed, 1 on success +//----------------------------------------------------------------------------- +int CHalfLife2Proxy::Save( ISave &save ) +{ + m_save_DefaultCitizenType = HL2GameRules()->GetDefaultCitizenType(); + m_save_PlayerSquadAutosummonDisabled = HL2GameRules()->AutosummonDisabled(); + + // As a static variable, this is actually kept across save games, but lost when the game exits. + // NOTE: Now set in KeyValue() directly + //m_save_LegacyFlashlight = (g_bUseLegacyFlashlight); + + m_save_StunstickPickupBehavior = HL2GameRules()->GetStunstickPickupBehavior(); + + return BaseClass::Save(save); +} + +//----------------------------------------------------------------------------- +// Purpose: Restores the current object from disk, by iterating through the objects +// data description hierarchy +// Input : &restore - restore buffer which the class data is read from +// Output : int - 0 if the restore failed, 1 on success +//----------------------------------------------------------------------------- +int CHalfLife2Proxy::Restore( IRestore &restore ) +{ + int base = BaseClass::Restore(restore); + + HL2GameRules()->SetDefaultCitizenType(m_save_DefaultCitizenType); + HL2GameRules()->SetAutosummonDisabled(m_save_PlayerSquadAutosummonDisabled); + + // Are we modding the legacy flashlight? + if (m_save_LegacyFlashlight & 1) + { + g_bUseLegacyFlashlight = (m_save_LegacyFlashlight & 2) != 0; + + // If we've got the desired legacy flashlight state saved, don't bother caching. + g_bCacheLegacyFlashlightStatus = false; + } + + HL2GameRules()->SetStunstickPickupBehavior(m_save_StunstickPickupBehavior); + + return base; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CHalfLife2Proxy::UpdateOnRemove() +{ + // Were we modding the legacy flashlight? + if (m_save_LegacyFlashlight & 1) + { + // Restore the default state. + g_bCacheLegacyFlashlightStatus = true; + } + + BaseClass::UpdateOnRemove(); +} +#endif + #ifdef CLIENT_DLL void RecvProxy_HL2GameRules( const RecvProp *pProp, void **pOut, void *pData, int objectID ) @@ -206,7 +394,11 @@ bool CHalfLife2::Damage_IsTimeBased( int iDmgType ) // Damage types that are time-based. #ifdef HL2_EPISODIC // This makes me think EP2 should have its own rules, but they are #ifdef all over in here. +#ifdef MAPBASE + return ( ( iDmgType & ( DMG_PARALYZE | DMG_NERVEGAS | DMG_POISON | DMG_RADIATION | DMG_DROWNRECOVER | DMG_ACID | DMG_SLOWBURN ) ) != 0 ); +#else return ( ( iDmgType & ( DMG_PARALYZE | DMG_NERVEGAS | DMG_POISON | DMG_RADIATION | DMG_DROWNRECOVER | DMG_SLOWBURN ) ) != 0 ); +#endif #else return BaseClass::Damage_IsTimeBased( iDmgType ); #endif @@ -253,6 +445,11 @@ ConVar alyx_darkness_force( "alyx_darkness_force", "0", FCVAR_CHEAT | FCVAR_REP m_flLastHealthDropTime = 0.0f; m_flLastGrenadeDropTime = 0.0f; + +#ifdef MAPBASE + m_DefaultCitizenType = 0; + m_bPlayerSquadAutosummonDisabled = false; +#endif } //----------------------------------------------------------------------------- @@ -1291,6 +1488,10 @@ ConVar alyx_darkness_force( "alyx_darkness_force", "0", FCVAR_CHEAT | FCVAR_REP { case CLASS_NONE: return "CLASS_NONE"; case CLASS_PLAYER: return "CLASS_PLAYER"; +#ifdef MAPBASE + case CLASS_PLAYER_ALLY: return "CLASS_PLAYER_ALLY"; + case CLASS_PLAYER_ALLY_VITAL: return "CLASS_PLAYER_ALLY_VITAL"; +#endif case CLASS_ANTLION: return "CLASS_ANTLION"; case CLASS_BARNACLE: return "CLASS_BARNACLE"; case CLASS_BULLSEYE: return "CLASS_BULLSEYE"; @@ -1314,6 +1515,9 @@ ConVar alyx_darkness_force( "alyx_darkness_force", "0", FCVAR_CHEAT | FCVAR_REP case CLASS_MISSILE: return "CLASS_MISSILE"; case CLASS_FLARE: return "CLASS_FLARE"; case CLASS_EARTH_FAUNA: return "CLASS_EARTH_FAUNA"; +#ifdef MAPBASE + case CLASS_HACKED_ROLLERMINE: return "CLASS_HACKED_ROLLERMINE"; +#endif default: return "MISSING CLASS in ClassifyText()"; } @@ -1400,7 +1604,12 @@ ConVar alyx_darkness_force( "alyx_darkness_force", "0", FCVAR_CHEAT | FCVAR_REP // came from the player's physcannon. CBasePlayer *pPlayer = UTIL_PlayerByIndex(1); +#ifdef MAPBASE + // Friendly fire needs to be handled here. + if ( pPlayer && !pVictim->MyNPCPointer()->FriendlyFireEnabled() ) +#else if( pPlayer ) +#endif { CBaseEntity *pWeapon = pPlayer->HasNamedPlayerItem("weapon_physcannon"); @@ -1769,6 +1978,80 @@ bool CHalfLife2::ShouldBurningPropsEmitLight() } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Gets the default citizen type. +//----------------------------------------------------------------------------- +int CHalfLife2::GetDefaultCitizenType() +{ + return m_DefaultCitizenType; +} + +//----------------------------------------------------------------------------- +// Sets the default citizen type. +//----------------------------------------------------------------------------- +void CHalfLife2::SetDefaultCitizenType(int val) +{ + m_DefaultCitizenType = val; +} + +//----------------------------------------------------------------------------- +// Gets our global friendly fire override. +//----------------------------------------------------------------------------- +ThreeState_t CHalfLife2::GlobalFriendlyFire() +{ + return GlobalEntity_IsInTable(FRIENDLY_FIRE_GLOBALNAME) ? TO_THREESTATE(GlobalEntity_GetState(FRIENDLY_FIRE_GLOBALNAME)) : TRS_NONE; +} + +//----------------------------------------------------------------------------- +// Sets our global friendly fire override. +//----------------------------------------------------------------------------- +void CHalfLife2::SetGlobalFriendlyFire(ThreeState_t val) +{ + GlobalEntity_Add(MAKE_STRING(FRIENDLY_FIRE_GLOBALNAME), gpGlobals->mapname, (GLOBALESTATE)val); +} + +//----------------------------------------------------------------------------- +// Gets our autosummon setting. +//----------------------------------------------------------------------------- +bool CHalfLife2::AutosummonDisabled() +{ + return m_bPlayerSquadAutosummonDisabled; +} + +//----------------------------------------------------------------------------- +// Sets our autosummon setting. +//----------------------------------------------------------------------------- +void CHalfLife2::SetAutosummonDisabled(bool toggle) +{ + m_bPlayerSquadAutosummonDisabled = toggle; +} + +//----------------------------------------------------------------------------- +// Gets our stunstick pickup setting. +//----------------------------------------------------------------------------- +int CHalfLife2::GetStunstickPickupBehavior() +{ + return m_StunstickPickupBehavior; +} + +//----------------------------------------------------------------------------- +// Sets our stunstick pickup setting. +//----------------------------------------------------------------------------- +void CHalfLife2::SetStunstickPickupBehavior(int val) +{ + m_StunstickPickupBehavior = val; +} + +//BEGIN_SIMPLE_DATADESC( CHalfLife2 ) +// +// DEFINE_FIELD( m_DefaultCitizenType, FIELD_INTEGER ), +// DEFINE_FIELD( m_bPlayerSquadAutosummonDisabled, FIELD_BOOLEAN ), +// +//END_DATADESC() +#endif + + #endif//CLIENT_DLL // ------------------------------------------------------------------------------------ // @@ -1868,9 +2151,20 @@ CAmmoDef *GetAmmoDef() def.AddAmmoType("Grenade", DMG_BURN, TRACER_NONE, "sk_plr_dmg_grenade", "sk_npc_dmg_grenade", "sk_max_grenade", 0, 0); #ifdef HL2_EPISODIC def.AddAmmoType("Hopwire", DMG_BLAST, TRACER_NONE, "sk_plr_dmg_grenade", "sk_npc_dmg_grenade", "sk_max_hopwire", 0, 0); +#ifdef MAPBASE + // + // Always gibbing would make it look better on antlions, etc. + // Hopefully this is very good and isn't bad. + // + def.AddAmmoType("CombineHeavyCannon", DMG_BULLET | DMG_ALWAYSGIB, TRACER_LINE, 40, 40, NULL, 10 * 750 * 12, AMMO_FORCE_DROP_IF_CARRIED ); // hit like a 10 kg weight at 750 ft/s +#else def.AddAmmoType("CombineHeavyCannon", DMG_BULLET, TRACER_LINE, 40, 40, NULL, 10 * 750 * 12, AMMO_FORCE_DROP_IF_CARRIED ); // hit like a 10 kg weight at 750 ft/s +#endif def.AddAmmoType("ammo_proto1", DMG_BULLET, TRACER_LINE, 0, 0, 10, 0, 0 ); #endif // HL2_EPISODIC +#ifdef MAPBASE + def.AddAmmoType("slam", DMG_BURN, TRACER_NONE, 0, 0, 5, 0, 0 ); +#endif } return &def; diff --git a/sp/src/game/shared/hl2/hl2_gamerules.h b/sp/src/game/shared/hl2/hl2_gamerules.h index 4f64793f..5951eb43 100644 --- a/sp/src/game/shared/hl2/hl2_gamerules.h +++ b/sp/src/game/shared/hl2/hl2_gamerules.h @@ -19,12 +19,42 @@ #define CHalfLife2Proxy C_HalfLife2Proxy #endif +#if MAPBASE && GAME_DLL +#define FRIENDLY_FIRE_GLOBALNAME "friendly_fire_override" +#endif + class CHalfLife2Proxy : public CGameRulesProxy { public: DECLARE_CLASS( CHalfLife2Proxy, CGameRulesProxy ); DECLARE_NETWORKCLASS(); + +#if defined(MAPBASE) && defined(GAME_DLL) + bool KeyValue( const char *szKeyName, const char *szValue ); + bool GetKeyValue( const char *szKeyName, char *szValue, int iMaxLen ); + + virtual int Save( ISave &save ); + virtual int Restore( IRestore &restore ); + virtual void UpdateOnRemove(); + + // Inputs + void InputEpisodicOn( inputdata_t &inputdata ); + void InputEpisodicOff( inputdata_t &inputdata ); + void InputSetFriendlyFire( inputdata_t &inputdata ); + void InputSetDefaultCitizenType( inputdata_t &inputdata ); + void InputSetLegacyFlashlight( inputdata_t &inputdata ); + void InputSetPlayerSquadAutosummon( inputdata_t &inputdata ); + void InputSetStunstickPickupBehavior( inputdata_t &inputdata ); + + // These are written to from HL2GameRules on save and given to HL2GameRules on restore + int m_save_DefaultCitizenType; + char m_save_LegacyFlashlight; + bool m_save_PlayerSquadAutosummonDisabled; + int m_save_StunstickPickupBehavior; + + DECLARE_DATADESC(); +#endif }; @@ -88,11 +118,31 @@ public: virtual bool IsAlyxInDarknessMode(); +#ifdef MAPBASE + int GetDefaultCitizenType(); + void SetDefaultCitizenType(int val); + + ThreeState_t GlobalFriendlyFire(); + void SetGlobalFriendlyFire(ThreeState_t val); + + bool AutosummonDisabled(); + void SetAutosummonDisabled(bool toggle); + + int GetStunstickPickupBehavior(); + void SetStunstickPickupBehavior(int val); +#endif + private: float m_flLastHealthDropTime; float m_flLastGrenadeDropTime; +#ifdef MAPBASE + int m_DefaultCitizenType; + bool m_bPlayerSquadAutosummonDisabled; + int m_StunstickPickupBehavior; +#endif + void AdjustPlayerDamageTaken( CTakeDamageInfo *pInfo ); float AdjustPlayerDamageInflicted( float damage ); diff --git a/sp/src/game/shared/hl2/hl2_usermessages.cpp b/sp/src/game/shared/hl2/hl2_usermessages.cpp index a5c81329..0ab97330 100644 --- a/sp/src/game/shared/hl2/hl2_usermessages.cpp +++ b/sp/src/game/shared/hl2/hl2_usermessages.cpp @@ -41,7 +41,12 @@ void RegisterUserMessages( void ) usermessages->Register( "KeyHintText", -1 ); // Displays hint text display usermessages->Register( "SquadMemberDied", 0 ); usermessages->Register( "AmmoDenied", 2 ); +#ifdef MAPBASE + // This sends the credits file now + usermessages->Register( "CreditsMsg", -1 ); +#else usermessages->Register( "CreditsMsg", 1 ); +#endif usermessages->Register( "LogoTimeMsg", 4 ); usermessages->Register( "AchievementEvent", -1 ); usermessages->Register( "UpdateJalopyRadar", -1 ); diff --git a/sp/src/game/shared/hl2/hl_gamemovement.cpp b/sp/src/game/shared/hl2/hl_gamemovement.cpp index e7e573ec..6a3fa51a 100644 --- a/sp/src/game/shared/hl2/hl_gamemovement.cpp +++ b/sp/src/game/shared/hl2/hl_gamemovement.cpp @@ -283,7 +283,11 @@ bool CHL2GameMovement::ContinueForcedMove() //----------------------------------------------------------------------------- bool CHL2GameMovement::OnLadder( trace_t &trace ) { +#ifdef HL2_USES_FUNC_LADDER_CODE + return ( GetLadder() != NULL ) ? true : BaseClass::OnLadder(trace); +#else return ( GetLadder() != NULL ) ? true : false; +#endif } //----------------------------------------------------------------------------- @@ -378,6 +382,104 @@ void CHL2GameMovement::Findladder( float maxdist, CFuncLadder **ppLadder, Vector } +#ifdef MAPBASE +bool CHL2GameMovement::ForcePlayerOntoLadder(CFuncLadder *ladder) +{ + Vector topPosition; + Vector bottomPosition; + + ladder->GetTopPosition(topPosition); + ladder->GetBottomPosition(bottomPosition); + + Vector closest; + CalcClosestPointOnLineSegment(mv->GetAbsOrigin(), bottomPosition, topPosition, closest, NULL); + + StartForcedMove( true, player->MaxSpeed(), closest, ladder ); + + return true; +} + +bool CHL2GameMovement::MountPlayerOntoLadder(CFuncLadder *ladder) +{ + Vector topPosition; + Vector bottomPosition; + + ladder->GetTopPosition(topPosition); + ladder->GetBottomPosition(bottomPosition); + + Vector closest; + CalcClosestPointOnLineSegment(mv->GetAbsOrigin(), bottomPosition, topPosition, closest, NULL); + +#if 0 + // Compute parametric distance along ladder vector... + float oldt; + CalcDistanceSqrToLine( mv->GetAbsOrigin(), topPosition, bottomPosition, &oldt ); + + // Perform the move accounting for any base velocity. + VectorAdd (mv->m_vecVelocity, player->GetBaseVelocity(), mv->m_vecVelocity); + TryPlayerMove(); + VectorSubtract (mv->m_vecVelocity, player->GetBaseVelocity(), mv->m_vecVelocity); + + // Pressed buttons are "changed(xor)" and'ed with the mask of currently held buttons + bool pressing_forward_or_side = mv->m_flForwardMove != 0.0f || mv->m_flSideMove != 0.0f; + + Vector ladderVec = topPosition - bottomPosition; + float LadderLength = VectorNormalize( ladderVec ); + // This test is not perfect by any means, but should help a bit + bool moving_along_ladder = false; + if ( pressing_forward_or_side ) + { + float fwdDot = m_vecForward.Dot( ladderVec ); + if ( fabs( fwdDot ) > 0.9f ) + { + moving_along_ladder = true; + } + } + + // Compute parametric distance along ladder vector... + float newt; + CalcDistanceSqrToLine( mv->GetAbsOrigin(), topPosition, bottomPosition, &newt ); + + // Fudge of 2 units + float tolerance = 1.0f / LadderLength; + + bool wouldleaveladder = false; + // Moving pPast top or bottom? + if ( newt < -tolerance ) + { + wouldleaveladder = newt < oldt; + } + else if ( newt > ( 1.0f + tolerance ) ) + { + wouldleaveladder = newt > oldt; + } + + // See if we are near the top or bottom but not moving + float dist1sqr, dist2sqr; + + dist1sqr = ( topPosition - mv->GetAbsOrigin() ).LengthSqr(); + dist2sqr = ( bottomPosition - mv->GetAbsOrigin() ).LengthSqr(); + + float dist = MIN( dist1sqr, dist2sqr ); + bool neardismountnode = ( dist < 16.0f * 16.0f ) ? true : false; + float ladderUnitsPerTick = ( MAX_CLIMB_SPEED * gpGlobals->interval_per_tick ); + bool neardismountnode2 = ( dist < ladderUnitsPerTick * ladderUnitsPerTick ) ? true : false; + + // Really close to node, cvar is set, and pressing a key, then simulate a +USE + bool auto_dismount_use = ( neardismountnode2 && + sv_autoladderdismount.GetBool() && + pressing_forward_or_side && + !moving_along_ladder ); + + bool fully_underwater = ( player->GetWaterLevel() == WL_Eyes ) ? true : false; +#endif + + StartForcedMove( true, player->MaxSpeed(), closest, ladder ); + + return true; +} +#endif + static bool NearbyDismountLessFunc( const NearbyDismount_t& lhs, const NearbyDismount_t& rhs ) { return lhs.distSqr < rhs.distSqr; @@ -527,6 +629,9 @@ void CHL2GameMovement::FullLadderMove() Assert( ladder ); if ( !ladder ) { +#ifdef HL2_USES_FUNC_LADDER_CODE + BaseClass::FullLadderMove(); +#endif return; } @@ -887,7 +992,11 @@ bool CHL2GameMovement::LadderMove( void ) if ( player->GetMoveType() == MOVETYPE_NOCLIP ) { SetLadder( NULL ); +#ifdef HL2_USES_FUNC_LADDER_CODE + return BaseClass::LadderMove(); +#else return false; +#endif } // If being forced to mount/dismount continue to act like we are on the ladder @@ -954,7 +1063,11 @@ bool CHL2GameMovement::LadderMove( void ) } } +#ifdef HL2_USES_FUNC_LADDER_CODE + return BaseClass::LadderMove(); +#else return false; +#endif } if ( !ladder && @@ -968,7 +1081,11 @@ bool CHL2GameMovement::LadderMove( void ) ladder = GetLadder(); if ( !ladder ) { +#ifdef HL2_USES_FUNC_LADDER_CODE + return BaseClass::LadderMove(); +#else return false; +#endif } // Don't play the deny sound @@ -1032,7 +1149,11 @@ bool CHL2GameMovement::LadderMove( void ) { mv->m_vecVelocity.z = mv->m_vecVelocity.z + 50; } +#ifdef HL2_USES_FUNC_LADDER_CODE + return BaseClass::LadderMove(); +#else return false; +#endif } if ( forwardSpeed != 0 || rightSpeed != 0 ) @@ -1064,7 +1185,11 @@ bool CHL2GameMovement::LadderMove( void ) player->SetMoveType( MOVETYPE_WALK ); // Remove from ladder SetLadder( NULL ); +#ifdef HL2_USES_FUNC_LADDER_CODE + return BaseClass::LadderMove(); +#else return false; +#endif } bool ishorizontal = fabs( topPosition.z - bottomPosition.z ) < 64.0f ? true : false; diff --git a/sp/src/game/shared/hl2/hl_gamemovement.h b/sp/src/game/shared/hl2/hl_gamemovement.h index 1e9abefe..6db52350 100644 --- a/sp/src/game/shared/hl2/hl_gamemovement.h +++ b/sp/src/game/shared/hl2/hl_gamemovement.h @@ -44,6 +44,13 @@ public: virtual void SetGroundEntity( trace_t *pm ); virtual bool CanAccelerate( void ); +#ifdef MAPBASE + // Called by mappers who need a player to be on a ladder. + bool ForcePlayerOntoLadder(CFuncLadder *ladder); + // Called by mappers who want a player to be on a ladder. + bool MountPlayerOntoLadder(CFuncLadder *ladder); +#endif + private: // See if we are pressing use near a ladder "mount" point and if so, latch us onto the ladder diff --git a/sp/src/game/shared/hl2mp/weapon_slam.cpp b/sp/src/game/shared/hl2mp/weapon_slam.cpp index bcdec40c..5bdea44f 100644 --- a/sp/src/game/shared/hl2mp/weapon_slam.cpp +++ b/sp/src/game/shared/hl2mp/weapon_slam.cpp @@ -11,9 +11,17 @@ #include "engine/IEngineSound.h" #if defined( CLIENT_DLL ) +#ifdef HL2MP #include "c_hl2mp_player.h" #else + #include "hl2_player_shared.h" +#endif +#else +#ifdef HL2MP #include "hl2mp_player.h" +#else + #include "hl2_player.h" +#endif #include "grenade_tripmine.h" #include "grenade_satchel.h" #include "entitylist.h" @@ -25,6 +33,11 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" +#ifndef HL2MP +#define ToHL2MPPlayer(ent) dynamic_cast(ent) +#define CHL2MP_Player CHL2_Player +#endif + #define SLAM_PRIMARY_VOLUME 450 IMPLEMENT_NETWORKCLASS_ALIASED( Weapon_SLAM, DT_Weapon_SLAM ) @@ -114,7 +127,9 @@ void CWeapon_SLAM::Spawn( ) Precache( ); +#if defined(HL2MP) || !defined(CLIENT_DLL) FallInit();// get ready to fall down +#endif m_tSlamState = (int)SLAM_SATCHEL_THROW; m_flWallSwitchTime = 0; @@ -755,6 +770,14 @@ void CWeapon_SLAM::ItemPostFrame( void ) SLAMThink(); +#ifdef MAPBASE + if (pOwner->HasSpawnFlags( SF_PLAYER_SUPPRESS_FIRING )) + { + WeaponIdle(); + return; + } +#endif + if ((pOwner->m_nButtons & IN_ATTACK2) && (m_flNextSecondaryAttack <= gpGlobals->curtime)) { SecondaryAttack(); diff --git a/sp/src/game/shared/hl2mp/weapon_slam.h b/sp/src/game/shared/hl2mp/weapon_slam.h index 0b59bed7..51a48155 100644 --- a/sp/src/game/shared/hl2mp/weapon_slam.h +++ b/sp/src/game/shared/hl2mp/weapon_slam.h @@ -15,7 +15,11 @@ #define WEAPONSLAM_H #include "basegrenade_shared.h" +#ifdef HL2MP #include "weapon_hl2mpbasehlmpcombatweapon.h" +#else +#include "basehlcombatweapon_shared.h" +#endif enum { @@ -28,6 +32,10 @@ enum #define CWeapon_SLAM C_Weapon_SLAM #endif +#ifndef HL2MP +#define CBaseHL2MPCombatWeapon CBaseHLCombatWeapon +#endif + class CWeapon_SLAM : public CBaseHL2MPCombatWeapon { public: diff --git a/sp/src/game/shared/hl2mp/weapon_stunstick.cpp b/sp/src/game/shared/hl2mp/weapon_stunstick.cpp index 9f706983..4f1dc8d6 100644 --- a/sp/src/game/shared/hl2mp/weapon_stunstick.cpp +++ b/sp/src/game/shared/hl2mp/weapon_stunstick.cpp @@ -7,7 +7,10 @@ #include "cbase.h" #include "npcevent.h" +#include "weapon_stunstick.h" +#ifdef HL2MP #include "weapon_hl2mpbasebasebludgeon.h" +#endif #include "IEffects.h" #include "debugoverlay_shared.h" @@ -26,7 +29,7 @@ #include "fx_quad.h" #include "fx.h" - extern void DrawHalo( IMaterial* pMaterial, const Vector &source, float scale, float const *color, float flHDRColorScale ); + extern void DrawHalo( IMaterial* pMaterial, const Vector &source, float scale, float const *color, float flHDRColorScale = 1.0f ); extern void FormatViewModelAttachment( Vector &vOrigin, bool bInverse ); #endif @@ -36,98 +39,11 @@ extern ConVar metropolice_move_and_melee; -#define STUNSTICK_RANGE 75.0f -#define STUNSTICK_REFIRE 0.8f -#define STUNSTICK_BEAM_MATERIAL "sprites/lgtning.vmt" -#define STUNSTICK_GLOW_MATERIAL "sprites/light_glow02_add" -#define STUNSTICK_GLOW_MATERIAL2 "effects/blueflare1" -#define STUNSTICK_GLOW_MATERIAL_NOZ "sprites/light_glow02_add_noz" - -#ifdef CLIENT_DLL -#define CWeaponStunStick C_WeaponStunStick +#ifdef MAPBASE +ConVar sk_plr_dmg_stunstick ( "sk_plr_dmg_stunstick","0"); +ConVar sk_npc_dmg_stunstick ( "sk_npc_dmg_stunstick","0"); #endif -class CWeaponStunStick : public CBaseHL2MPBludgeonWeapon -{ - DECLARE_CLASS( CWeaponStunStick, CBaseHL2MPBludgeonWeapon ); - -public: - - CWeaponStunStick(); - - DECLARE_NETWORKCLASS(); - DECLARE_PREDICTABLE(); - -#ifndef CLIENT_DLL - DECLARE_ACTTABLE(); -#endif - -#ifdef CLIENT_DLL - virtual int DrawModel( int flags ); - virtual void ClientThink( void ); - virtual void OnDataChanged( DataUpdateType_t updateType ); - virtual RenderGroup_t GetRenderGroup( void ); - virtual void ViewModelDrawn( C_BaseViewModel *pBaseViewModel ); - -#endif - - virtual void Precache(); - - void Spawn(); - - float GetRange( void ) { return STUNSTICK_RANGE; } - float GetFireRate( void ) { return STUNSTICK_REFIRE; } - - - bool Deploy( void ); - bool Holster( CBaseCombatWeapon *pSwitchingTo = NULL ); - - void Drop( const Vector &vecVelocity ); - void ImpactEffect( trace_t &traceHit ); - void SecondaryAttack( void ) {} - void SetStunState( bool state ); - bool GetStunState( void ); - -#ifndef CLIENT_DLL - void Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCharacter *pOperator ); - int WeaponMeleeAttack1Condition( float flDot, float flDist ); -#endif - - float GetDamageForActivity( Activity hitActivity ); - - CWeaponStunStick( const CWeaponStunStick & ); - -private: - -#ifdef CLIENT_DLL - - #define NUM_BEAM_ATTACHMENTS 9 - - struct stunstickBeamInfo_t - { - int IDs[2]; // 0 - top, 1 - bottom - }; - - stunstickBeamInfo_t m_BeamAttachments[NUM_BEAM_ATTACHMENTS]; // Lookup for arc attachment points on the head of the stick - int m_BeamCenterAttachment; // "Core" of the effect (center of the head) - - void SetupAttachmentPoints( void ); - void DrawFirstPersonEffects( void ); - void DrawThirdPersonEffects( void ); - void DrawEffects( void ); - bool InSwing( void ); - - bool m_bSwungLastFrame; - - #define FADE_DURATION 0.25f - - float m_flFadeTime; - -#endif - - CNetworkVar( bool, m_bActive ); -}; - //----------------------------------------------------------------------------- // CWeaponStunStick //----------------------------------------------------------------------------- @@ -153,6 +69,7 @@ PRECACHE_WEAPON_REGISTER( weapon_stunstick ); acttable_t CWeaponStunStick::m_acttable[] = { +#ifdef HL2MP { ACT_RANGE_ATTACK1, ACT_RANGE_ATTACK_SLAM, true }, { ACT_HL2MP_IDLE, ACT_HL2MP_IDLE_MELEE, false }, { ACT_HL2MP_RUN, ACT_HL2MP_RUN_MELEE, false }, @@ -161,6 +78,9 @@ acttable_t CWeaponStunStick::m_acttable[] = { ACT_HL2MP_GESTURE_RANGE_ATTACK, ACT_HL2MP_GESTURE_RANGE_ATTACK_MELEE, false }, { ACT_HL2MP_GESTURE_RELOAD, ACT_HL2MP_GESTURE_RELOAD_MELEE, false }, { ACT_HL2MP_JUMP, ACT_HL2MP_JUMP_MELEE, false }, +#endif + { ACT_MELEE_ATTACK1, ACT_MELEE_ATTACK_SWING, true }, + { ACT_IDLE_ANGRY, ACT_IDLE_ANGRY_MELEE, true }, }; IMPLEMENT_ACTTABLE(CWeaponStunStick); @@ -213,7 +133,14 @@ void CWeaponStunStick::Precache() //----------------------------------------------------------------------------- float CWeaponStunStick::GetDamageForActivity( Activity hitActivity ) { +#ifdef MAPBASE + if ( ( GetOwner() != NULL ) && ( GetOwner()->IsPlayer() ) ) + return sk_plr_dmg_stunstick.GetFloat(); + + return sk_npc_dmg_stunstick.GetFloat(); +#else return 40.0f; +#endif } //----------------------------------------------------------------------------- @@ -474,8 +401,19 @@ void CWeaponStunStick::Drop( const Vector &vecVelocity ) SetStunState( false ); #ifndef CLIENT_DLL +#ifdef MAPBASE +#ifdef HL2MP + if (!GetOwner() || GetOwner()->IsNPC()) + BaseClass::Drop(vecVelocity); + else + UTIL_Remove( this ); +#else + BaseClass::Drop(vecVelocity); +#endif +#else UTIL_Remove( this ); #endif +#endif } @@ -566,7 +504,11 @@ int C_WeaponStunStick::DrawModel( int flags ) return 0; // Only render these on the transparent pass +#ifdef MAPBASE + if ( m_bActive && flags & STUDIO_TRANSPARENCY ) +#else if ( flags & STUDIO_TRANSPARENCY ) +#endif { DrawEffects(); return 1; @@ -842,6 +784,40 @@ void C_WeaponStunStick::DrawFirstPersonEffects( void ) } } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: Draw our special effects +//----------------------------------------------------------------------------- +void C_WeaponStunStick::DrawNPCEffects( void ) +{ + if ( m_bActive ) + { + Vector vecOrigin; + QAngle vecAngles; + float color[3]; + + color[0] = color[1] = color[2] = random->RandomFloat( 0.1f, 0.2f ); + + GetAttachment( 1, vecOrigin, vecAngles ); + + Vector vForward; + AngleVectors( vecAngles, &vForward ); + + Vector vEnd = vecOrigin - vForward * 1.0f; + + IMaterial *pMaterial = materials->FindMaterial( "effects/stunstick", NULL, false ); + + CMatRenderContextPtr pRenderContext( materials ); + pRenderContext->Bind( pMaterial ); + DrawHalo( pMaterial, vEnd, random->RandomFloat( 4.0f, 6.0f ), color ); + + color[0] = color[1] = color[2] = random->RandomFloat( 0.9f, 1.0f ); + + DrawHalo( pMaterial, vEnd, random->RandomFloat( 2.0f, 3.0f ), color ); + } +} +#endif + //----------------------------------------------------------------------------- // Purpose: Draw our special effects //----------------------------------------------------------------------------- @@ -851,6 +827,13 @@ void C_WeaponStunStick::DrawEffects( void ) { DrawFirstPersonEffects(); } +#ifdef MAPBASE + else if ( GetOwner() && GetOwner()->IsNPC() ) + { + // Original HL2 stunstick FX + DrawNPCEffects(); + } +#endif else { DrawThirdPersonEffects(); diff --git a/sp/src/game/shared/hl2mp/weapon_stunstick.h b/sp/src/game/shared/hl2mp/weapon_stunstick.h new file mode 100644 index 00000000..da25999c --- /dev/null +++ b/sp/src/game/shared/hl2mp/weapon_stunstick.h @@ -0,0 +1,122 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: This is technically a Mapbase addition, but it's just weapon_stunstick's class declaration. +// All actual changes are still nested in #ifdef MAPBASE. +// +//=============================================================================// + +#ifndef WEAPON_STUNSTICK_H +#define WEAPON_STUNSTICK_H +#ifdef _WIN32 +#pragma once +#endif + +#ifdef CLIENT_DLL +#include "c_basehlcombatweapon.h" +#else +#include "basebludgeonweapon.h" +#endif + +#define STUNSTICK_RANGE 75.0f +#define STUNSTICK_REFIRE 0.8f +#define STUNSTICK_BEAM_MATERIAL "sprites/lgtning.vmt" +#define STUNSTICK_GLOW_MATERIAL "sprites/light_glow02_add" +#define STUNSTICK_GLOW_MATERIAL2 "effects/blueflare1" +#define STUNSTICK_GLOW_MATERIAL_NOZ "sprites/light_glow02_add_noz" + +#ifdef CLIENT_DLL +#define CWeaponStunStick C_WeaponStunStick +#define CBaseHLBludgeonWeapon C_BaseHLBludgeonWeapon +#endif + +#ifndef HL2MP +class CWeaponStunStick : public CBaseHLBludgeonWeapon +{ + DECLARE_CLASS( CWeaponStunStick, CBaseHLBludgeonWeapon ); +#else +class CWeaponStunStick : public CBaseHL2MPBludgeonWeapon +{ + DECLARE_CLASS( CWeaponStunStick, CBaseHL2MPBludgeonWeapon ); +#endif + +public: + + CWeaponStunStick(); + + DECLARE_NETWORKCLASS(); + DECLARE_PREDICTABLE(); + +#ifndef CLIENT_DLL + DECLARE_ACTTABLE(); +#endif + +#ifdef CLIENT_DLL + virtual int DrawModel( int flags ); + virtual void ClientThink( void ); + virtual void OnDataChanged( DataUpdateType_t updateType ); + virtual RenderGroup_t GetRenderGroup( void ); + virtual void ViewModelDrawn( C_BaseViewModel *pBaseViewModel ); + +#endif + + virtual void Precache(); + + void Spawn(); + + float GetRange( void ) { return STUNSTICK_RANGE; } + float GetFireRate( void ) { return STUNSTICK_REFIRE; } + + + bool Deploy( void ); + bool Holster( CBaseCombatWeapon *pSwitchingTo = NULL ); + + void Drop( const Vector &vecVelocity ); + void ImpactEffect( trace_t &traceHit ); + void SecondaryAttack( void ) {} + void SetStunState( bool state ); + bool GetStunState( void ); + +#ifndef CLIENT_DLL + void Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCharacter *pOperator ); + int WeaponMeleeAttack1Condition( float flDot, float flDist ); +#endif + + float GetDamageForActivity( Activity hitActivity ); + + CWeaponStunStick( const CWeaponStunStick & ); + +private: + +#ifdef CLIENT_DLL + + #define NUM_BEAM_ATTACHMENTS 9 + + struct stunstickBeamInfo_t + { + int IDs[2]; // 0 - top, 1 - bottom + }; + + stunstickBeamInfo_t m_BeamAttachments[NUM_BEAM_ATTACHMENTS]; // Lookup for arc attachment points on the head of the stick + int m_BeamCenterAttachment; // "Core" of the effect (center of the head) + + void SetupAttachmentPoints( void ); + void DrawFirstPersonEffects( void ); + void DrawThirdPersonEffects( void ); +#ifdef MAPBASE + void DrawNPCEffects( void ); +#endif + void DrawEffects( void ); + bool InSwing( void ); + + bool m_bSwungLastFrame; + + #define FADE_DURATION 0.25f + + float m_flFadeTime; + +#endif + + CNetworkVar( bool, m_bActive ); +}; + +#endif // WEAPON_STUNSTICK_H diff --git a/sp/src/game/shared/in_buttons.h b/sp/src/game/shared/in_buttons.h index 32486853..870961f8 100644 --- a/sp/src/game/shared/in_buttons.h +++ b/sp/src/game/shared/in_buttons.h @@ -11,6 +11,11 @@ #pragma once #endif +#ifdef MAPBASE +// That one article on the VDC. +//#define VGUI_SCREEN_FIX 1 +#endif + #define IN_ATTACK (1 << 0) #define IN_JUMP (1 << 1) #define IN_DUCK (1 << 2) @@ -38,4 +43,8 @@ #define IN_GRENADE2 (1 << 24) // grenade 2 #define IN_ATTACK3 (1 << 25) +#ifdef VGUI_SCREEN_FIX +#define IN_VALIDVGUIINPUT (1 << 23) //bitflag for vgui fix +#endif + #endif // IN_BUTTONS_H diff --git a/sp/src/game/shared/mapbase/MapEdit.cpp b/sp/src/game/shared/mapbase/MapEdit.cpp new file mode 100644 index 00000000..0f8170bb --- /dev/null +++ b/sp/src/game/shared/mapbase/MapEdit.cpp @@ -0,0 +1,897 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: The flimsy MapEdit system that was +// heavily inspired by Synergy's MapEdit, completely based on the Commentary System +// and originally used for Lambda Fortress. +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" + +#include "MapEdit.h" +#include "filesystem.h" + +#ifndef CLIENT_DLL +#include +#include "utldict.h" +#include "isaverestore.h" +#include "eventqueue.h" +#include "saverestore_utlvector.h" +#include "ai_basenpc.h" +#include "triggers.h" +#include "mapbase/SystemConvarMod.h" +#endif + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +#ifndef CLIENT_DLL + +#define MAPEDIT_SPAWNED_SEMAPHORE "mapedit_semaphore" +#define MAPEDIT_DEFAULT_FILE UTIL_VarArgs("maps/%s_auto.txt", STRING(gpGlobals->mapname)) + +ConVar mapedit_enabled("mapedit_enabled", "1", FCVAR_ARCHIVE, "Is automatic MapEdit enabled?"); +ConVar mapedit_stack("mapedit_stack", "1", FCVAR_ARCHIVE, "If multiple MapEdit scripts are loaded, should they stack or replace each other?"); +ConVar mapedit_debug("mapedit_debug", "0", FCVAR_NONE, "Should MapEdit give debug messages?"); + +inline void DebugMsg(const tchar *pMsg, ...) +{ + if (mapedit_debug.GetBool() == true) + { + Msg(pMsg); + } +} + +//bool g_bMapEditAvailable; +bool g_bMapEditLoaded = false; +bool IsMapEditLoaded( void ) +{ + return g_bMapEditLoaded; +} + +bool IsAutoMapEditAllowed(void) +{ + return mapedit_enabled.GetBool(); +} + +void CV_GlobalChange_MapEdit( IConVar *var, const char *pOldString, float flOldValue ); + +//----------------------------------------------------------------------------- +// Purpose: Game system for MapEdit stuff +//----------------------------------------------------------------------------- +class CMapEdit : public CAutoGameSystemPerFrame +{ +public: + DECLARE_DATADESC(); + + virtual void LevelInitPreEntity() + { + m_bMapEditConvarsChanging = false; + CalculateAvailableState(); + } + + void CalculateAvailableState( void ) + { + // Set the available cvar if we can find commentary data for this level + char szFullName[512]; + Q_snprintf(szFullName,sizeof(szFullName), "maps/%s_auto.txt", STRING( gpGlobals->mapname) ); + if ( filesystem->FileExists( szFullName ) ) + { + bool bAllowed = IsAutoMapEditAllowed(); + g_bMapEditLoaded = bAllowed; + //if (bAllowed) + // gEntList.AddListenerEntity( this ); + } + else + { + g_bMapEditLoaded = false; + //gEntList.RemoveListenerEntity( this ); + } + } + + virtual void LevelShutdownPreEntity() + { + ShutDownMapEdit(); + } + + void ParseEntKVBlock( CBaseEntity *pNode, KeyValues *pkvNode ) + { + KeyValues *pkvNodeData = pkvNode->GetFirstSubKey(); + while ( pkvNodeData ) + { + // Handle the connections block + if ( !Q_strcmp(pkvNodeData->GetName(), "connections") ) + { + ParseEntKVBlock( pNode, pkvNodeData ); + } + else + { + #define MAPEDIT_STRING_LENGTH_MAX 1024 + + const char *pszValue = pkvNodeData->GetString(); + Assert( Q_strlen(pszValue) < MAPEDIT_STRING_LENGTH_MAX ); + if ( Q_strnchr(pszValue, '^', MAPEDIT_STRING_LENGTH_MAX) ) + { + // We want to support quotes in our strings so that we can specify multiple parameters in + // an output inside our commentary files. We convert ^s to "s here. + char szTmp[MAPEDIT_STRING_LENGTH_MAX]; + Q_strncpy( szTmp, pszValue, MAPEDIT_STRING_LENGTH_MAX ); + int len = Q_strlen( szTmp ); + for ( int i = 0; i < len; i++ ) + { + if ( szTmp[i] == '^' ) + { + szTmp[i] = '"'; + } + } + + pszValue = szTmp; + } + + char cOperatorChar = pszValue[0]; + if (cOperatorChar == '+') + { + pszValue++; + char szExistingValue[MAPEDIT_STRING_LENGTH_MAX]; + if (pNode->GetKeyValue(pkvNodeData->GetName(), szExistingValue, sizeof(szExistingValue) )) + { + // Right now, this only supports adding floats/integers. + // Add Vector support later. + float flResult = atof(szExistingValue) + atof(pszValue); + pszValue = UTIL_VarArgs("%f", flResult); + } + } + else if (cOperatorChar == '-') + { + pszValue++; + char szExistingValue[MAPEDIT_STRING_LENGTH_MAX]; + if (pNode->GetKeyValue(pkvNodeData->GetName(), szExistingValue, sizeof(szExistingValue) )) + { + // Right now, this only supports subtracting floats/integers. + // Add Vector support later. + float flResult = atof(szExistingValue) - atof(pszValue); + pszValue = UTIL_VarArgs("%f", flResult); + } + } + else if (cOperatorChar == '|' /*&& pszValue[1] == '='*/) + { + pszValue++; + char szExistingValue[MAPEDIT_STRING_LENGTH_MAX]; + if (pNode->GetKeyValue(pkvNodeData->GetName(), szExistingValue, sizeof(szExistingValue))) + { + int iResult = atoi(szExistingValue) | atoi(pszValue); + pszValue = UTIL_VarArgs("%i", iResult); + } + } + + pNode->KeyValue(pkvNodeData->GetName(), pszValue); + } + + pkvNodeData = pkvNodeData->GetNextKey(); + } + } + + virtual void LevelInitPostEntity( void ) + { + if ( !IsMapEditLoaded() ) + { + return; + } + + if ( gpGlobals->eLoadType == MapLoad_LoadGame || gpGlobals->eLoadType == MapLoad_Background ) + { + return; + } + + m_bMapEditLoadedMidGame = false; + InitMapEdit(); + + //IGameEvent *event = gameeventmanager->CreateEvent( "playing_mapedit" ); + //gameeventmanager->FireEventClientSide( event ); + } + + bool MapEditConvarsChanging( void ) + { + return m_bMapEditConvarsChanging; + } + + void SetMapEditConvarsChanging( bool bChanging ) + { + m_bMapEditConvarsChanging = bChanging; + } + + void ConvarChanged( IConVar *pConVar, const char *pOldString, float flOldValue ) + { + ConVarRef var( pConVar ); + + // A convar has been changed by a commentary node. We need to store + // the old state. If the engine shuts down, we need to restore any + // convars that the commentary changed to their previous values. + for ( int i = 0; i < m_ModifiedConvars.Count(); i++ ) + { + // If we find it, just update the current value + if ( !Q_strncmp( var.GetName(), m_ModifiedConvars[i].pszConvar, MAX_MODIFIED_CONVAR_STRING ) ) + { + Q_strncpy( m_ModifiedConvars[i].pszCurrentValue, var.GetString(), MAX_MODIFIED_CONVAR_STRING ); + //Msg(" Updating Convar %s: value %s (org %s)\n", m_ModifiedConvars[i].pszConvar, m_ModifiedConvars[i].pszCurrentValue, m_ModifiedConvars[i].pszOrgValue ); + return; + } + } + + // We didn't find it in our list, so add it + modifiedconvars_t newConvar; + Q_strncpy( newConvar.pszConvar, var.GetName(), MAX_MODIFIED_CONVAR_STRING ); + Q_strncpy( newConvar.pszCurrentValue, var.GetString(), MAX_MODIFIED_CONVAR_STRING ); + Q_strncpy( newConvar.pszOrgValue, pOldString, MAX_MODIFIED_CONVAR_STRING ); + m_ModifiedConvars.AddToTail( newConvar ); + + /* + Msg(" Commentary changed '%s' to '%s' (was '%s')\n", var->GetName(), var->GetString(), pOldString ); + Msg(" Convars stored: %d\n", m_ModifiedConvars.Count() ); + for ( int i = 0; i < m_ModifiedConvars.Count(); i++ ) + { + Msg(" Convar %d: %s, value %s (org %s)\n", i, m_ModifiedConvars[i].pszConvar, m_ModifiedConvars[i].pszCurrentValue, m_ModifiedConvars[i].pszOrgValue ); + } + */ + } + + CBaseEntity *FindMapEditEntity( CBaseEntity *pStartEntity, const char *szName, const char *szValue = NULL ) + { + CBaseEntity *pEntity = NULL; + DebugMsg("MapEdit Find Debug: Starting Search, Name: %s, Value: %s\n", szName, szValue); + + // First, find by targetname/classname + pEntity = gEntList.FindEntityGeneric(pStartEntity, szName); + + if (!pEntity) + { + DebugMsg("MapEdit Find Debug: \"%s\" not found as targetname or classname\n", szName); + + if (szValue) + { + if (!Q_strnicmp(szName, "#find_", 6)) + { + const char *pName = szName + 6; + if (!Q_stricmp(pName, "by_keyfield")) + { + char key[64]; + char value[64]; + + // Separate key from value + char *delimiter = Q_strstr(szValue, " "); + if (delimiter) + { + Q_strncpy(key, szValue, MIN((delimiter - szValue) + 1, sizeof(key))); + Q_strncpy(value, delimiter + 1, sizeof(value)); + } + else + { + // Assume the value doesn't matter and we're just looking for the key + Q_strncpy(key, szValue, sizeof(key)); + } + + if (!key) + { + Warning("MapEdit: Possible find_by_keyfield syntax error: key not detected in \"%s\"\n", szValue); + } + + // Find entities with matching keyfield + variant_t variant; + const CEntInfo *pInfo = pStartEntity ? gEntList.GetEntInfoPtr(pStartEntity->GetRefEHandle())->m_pNext : gEntList.FirstEntInfo(); + for (; pInfo; pInfo = pInfo->m_pNext) + { + CBaseEntity *ent = (CBaseEntity *)pInfo->m_pEntity; + if (!ent) + { + DevWarning("NULL entity in global entity list!\n"); + continue; + } + + if (!ent->edict()) + continue; + + if (ent->ReadKeyField(key, &variant)) + { + // Does the value matter? + if (value) + { + if (Q_stricmp(variant.String(), value) == 0) + { + // The entity has the keyfield and it matches the value. + return ent; + } + } + else + { + // The value doesn't matter and the entity has the keyfield. + return ent; + } + } + } + } + else if (!Q_stricmp(pName, "by_origin")) + { + // Find entities at this origin + Vector vecOrigin; + UTIL_StringToVector(vecOrigin.Base(), szValue); + if (vecOrigin.IsValid()) + { + DebugMsg("MapEdit Find Debug: \"%s\" is valid vector\n", szValue); + const CEntInfo *pInfo = pStartEntity ? gEntList.GetEntInfoPtr(pStartEntity->GetRefEHandle())->m_pNext : gEntList.FirstEntInfo(); + for (; pInfo; pInfo = pInfo->m_pNext) + { + CBaseEntity *ent = (CBaseEntity *)pInfo->m_pEntity; + if (!ent) + { + DevWarning("NULL entity in global entity list!\n"); + continue; + } + + if (!ent->edict()) + continue; + + if (ent->GetLocalOrigin() == vecOrigin) + return ent; + } + } + } + } + else if (!pStartEntity) + { + // Try the entity index + int iEntIndex = atoi(szName); + if (!pStartEntity && UTIL_EntityByIndex(iEntIndex)) + { + DebugMsg("MapEdit Find Debug: \"%s\" is valid index\n", szName); + return CBaseEntity::Instance(iEntIndex); + } + } + } + + DebugMsg("MapEdit Find Debug: \"%s\" not found\n", szName); + return NULL; + } + + DebugMsg("MapEdit Find Debug: \"%s\" found as targetname or classname\n", szName); + return pEntity; + } + + void InitMapEdit( const char* pFile = MAPEDIT_DEFAULT_FILE ) + { + // Install the global cvar callback + cvar->InstallGlobalChangeCallback( CV_GlobalChange_MapEdit ); + + + // If we find the commentary semaphore, the commentary entities already exist. + // This occurs when you transition back to a map that has saved commentary nodes in it. + if ( gEntList.FindEntityByName( NULL, MAPEDIT_SPAWNED_SEMAPHORE ) ) + return; + + // Spawn the commentary semaphore entity + CBaseEntity *pSemaphore = CreateEntityByName( "info_target" ); + pSemaphore->SetName( MAKE_STRING(MAPEDIT_SPAWNED_SEMAPHORE) ); + + bool oldLock = engine->LockNetworkStringTables( false ); + + SpawnMapEdit(pFile); + + engine->LockNetworkStringTables( oldLock ); + } + + void LoadFromFormat_Original(KeyValues *pkvFile) + { + KeyValues *pkvNode = pkvFile->GetFirstSubKey(); + while ( pkvNode ) + { + const char *pNodeName = pkvNode->GetName(); + if (FStrEq(pNodeName, "create")) + { + KeyValues *pkvClassname = pkvNode->GetFirstSubKey(); + while (pkvClassname) + { + pNodeName = pkvClassname->GetName(); + + CBaseEntity *pNode = CreateEntityByName(pNodeName); + if (pNode) + { + ParseEntKVBlock(pNode, pkvClassname); + + EHANDLE hHandle; + hHandle = pNode; + m_hSpawnedEntities.AddToTail(hHandle); + DebugMsg("MapEdit Debug: Spawned entity %s\n", pNodeName); + } + else + { + Warning("MapEdit: Failed to spawn mapedit entity, type: '%s'\n", pNodeName); + } + + pkvClassname = pkvClassname->GetNextKey(); + } + pkvClassname->deleteThis(); + } + else if (FStrEq(pNodeName, "edit")) + { + KeyValues *pName = pkvNode->GetFirstSubKey(); + while (pName) + { + pNodeName = pName->GetName(); + + CBaseEntity *pNode = NULL; + + pNode = FindMapEditEntity(NULL, pNodeName, pName->GetString()); + + while (pNode) + { + DebugMsg("MapEdit Debug: Editing %s (%s)\n", pNodeName, pNode->GetDebugName()); + + ParseEntKVBlock(pNode, pName); + pNode = FindMapEditEntity(pNode, pNodeName, pName->GetString()); + } + + pName = pName->GetNextKey(); + } + pName->deleteThis(); + } + else if (FStrEq(pNodeName, "delete")) + { + KeyValues *pName = pkvNode->GetFirstSubKey(); + while (pName) + { + pNodeName = pName->GetName(); + + CBaseEntity *pNode = NULL; + + pNode = FindMapEditEntity(NULL, pNodeName, pName->GetString()); + + while (pNode) + { + DebugMsg("MapEdit Debug: Deleting %s (%s)\n", pNodeName, pNode->GetDebugName()); + + UTIL_Remove(pNode); + pNode = FindMapEditEntity(pNode, pNodeName, pName->GetString()); + } + + pName = pName->GetNextKey(); + } + pName->deleteThis(); + } + else if (FStrEq(pNodeName, "fire")) + { + KeyValues *pName = pkvNode->GetFirstSubKey(); + while (pName) + { + pNodeName = pName->GetName(); + + const char *pInputName = NULL; + variant_t varInputParam; + float flInputDelay = 0.0f; + CBaseEntity *pActivator = NULL; + CBaseEntity *pCaller = NULL; + int iOutputID = 0; + + char *pszValue = strdup(pName->GetString()); + int iter = 0; + char *inputparams = strtok(pszValue, ","); + while (inputparams) + { + switch (iter) + { + // Input name + case 0: + pInputName = inputparams; break; + // Input parameter + case 1: + varInputParam.SetString(AllocPooledString(inputparams)); break; + // Input delay + case 2: + flInputDelay = atof(inputparams); break; + // Activator + case 3: + pActivator = gEntList.FindEntityByName(NULL, inputparams); break; + // Caller + case 4: + pCaller = gEntList.FindEntityByName(NULL, inputparams); break; + // Output ID + case 5: + iOutputID = atoi(inputparams); break; + } + iter++; + inputparams = strtok(NULL, ","); + } + + DebugMsg("MapEdit Debug: Firing input %s on %s\n", pInputName, pNodeName); + g_EventQueue.AddEvent(pNodeName, pInputName, varInputParam, flInputDelay, pActivator, pCaller, iOutputID); + + pName = pName->GetNextKey(); + } + } + else if (FStrEq(pNodeName, "console")) + { + KeyValues *pkvNodeData = pkvNode->GetFirstSubKey(); + const char *pKey; + const char *pValue; + while (pkvNodeData) + { + SetMapEditConvarsChanging(true); + + pKey = pkvNodeData->GetName(); + pValue = pkvNodeData->GetString(); + + engine->ServerCommand(UTIL_VarArgs("%s %s", pKey, pValue)); + engine->ServerCommand("mapedit_cvarsnotchanging\n"); + + pkvNodeData = pkvNodeData->GetNextKey(); + } + pkvNodeData->deleteThis(); + } + + pkvNode = pkvNode->GetNextKey(); + } + pkvNode->deleteThis(); + } + + void SpawnMapEdit(const char *pFile = NULL) + { + // Find the commentary file + char szFullName[512]; + if (pFile == NULL) + { + DebugMsg("MapEdit Debug: NULL file, loading default\n"); + Q_snprintf(szFullName,sizeof(szFullName), "maps/%s_auto.txt", STRING( gpGlobals->mapname )); + } + else + { + DebugMsg("MapEdit Debug: File not NULL, loading %s\n", pFile); + Q_snprintf(szFullName,sizeof(szFullName), pFile); + } + KeyValues *pkvFile = new KeyValues( "MapEdit" ); + if ( pkvFile->LoadFromFile( filesystem, szFullName, "MOD" ) ) + { + Msg( "MapEdit: Loading MapEdit data from %s. \n", szFullName ); + + if (gpGlobals->eLoadType != MapLoad_LoadGame) + { + // Support for multiple formats + const char *szVersion = pkvFile->GetString("version", "original"); + if (FStrEq(szVersion, "original")) + LoadFromFormat_Original(pkvFile); + // TODO: More formats + } + + // Then activate all the entities + for ( int i = 0; i < m_hSpawnedEntities.Count(); i++ ) + { + DispatchSpawn(m_hSpawnedEntities[i]); + } + } + else + { + Msg( "MapEdit: Could not find MapEdit data file '%s'. \n", szFullName ); + } + + pkvFile->deleteThis(); + } + + void ShutDownMapEdit( void ) + { + // Destroy all the entities created by commentary + for ( int i = m_hSpawnedEntities.Count()-1; i >= 0; i-- ) + { + if ( m_hSpawnedEntities[i] ) + { + UTIL_Remove( m_hSpawnedEntities[i] ); + } + } + m_hSpawnedEntities.Purge(); + + // Remove the semaphore + CBaseEntity *pSemaphore = gEntList.FindEntityByName( NULL, MAPEDIT_SPAWNED_SEMAPHORE ); + if ( pSemaphore ) + { + UTIL_Remove( pSemaphore ); + } + + // Remove our global convar callback + cvar->RemoveGlobalChangeCallback( CV_GlobalChange_MapEdit ); + + // Reset any convars that have been changed by the commentary + for ( int i = 0; i < m_ModifiedConvars.Count(); i++ ) + { + ConVar *pConVar = (ConVar *)cvar->FindVar( m_ModifiedConvars[i].pszConvar ); + if ( pConVar ) + { + pConVar->SetValue( m_ModifiedConvars[i].pszOrgValue ); + } + } + m_ModifiedConvars.Purge(); + } + + void SetMapEdit( bool bMapEdit, const char *pFile = NULL ) + { + //g_bMapEditLoaded = bMapEdit; + //CalculateAvailableState(); + + // If we're turning on commentary, create all the entities. + if ( bMapEdit ) + { + if (filesystem->FileExists(pFile) || pFile == NULL) + { + g_bMapEditLoaded = true; + m_bMapEditLoadedMidGame = true; + InitMapEdit(pFile); + } + else + { + Warning("MapEdit: No such file \"%s\"!\n", pFile); + } + } + else + { + ShutDownMapEdit(); + } + } + + void OnRestore( void ) + { + cvar->RemoveGlobalChangeCallback( CV_GlobalChange_MapEdit ); + + if ( !IsMapEditLoaded() ) + return; + + // Set any convars that have already been changed by the commentary before the save + for ( int i = 0; i < m_ModifiedConvars.Count(); i++ ) + { + ConVar *pConVar = (ConVar *)cvar->FindVar( m_ModifiedConvars[i].pszConvar ); + if ( pConVar ) + { + //Msg(" Restoring Convar %s: value %s (org %s)\n", m_ModifiedConvars[i].pszConvar, m_ModifiedConvars[i].pszCurrentValue, m_ModifiedConvars[i].pszOrgValue ); + pConVar->SetValue( m_ModifiedConvars[i].pszCurrentValue ); + } + } + + // Install the global cvar callback + cvar->InstallGlobalChangeCallback( CV_GlobalChange_MapEdit ); + } + + bool MapEditLoadedMidGame( void ) + { + return m_bMapEditLoadedMidGame; + } + +private: + bool m_bMapEditConvarsChanging; + bool m_bMapEditLoadedMidGame; + + CUtlVector< modifiedconvars_t > m_ModifiedConvars; + CUtlVector m_hSpawnedEntities; +}; + +CMapEdit g_MapEdit; + +BEGIN_DATADESC_NO_BASE( CMapEdit ) + + DEFINE_FIELD( m_bMapEditLoadedMidGame, FIELD_BOOLEAN ), + + DEFINE_UTLVECTOR( m_ModifiedConvars, FIELD_EMBEDDED ), + DEFINE_UTLVECTOR( m_hSpawnedEntities, FIELD_EHANDLE ), + + //DEFINE_UTLVECTOR( m_SpawnEditLookup, FIELD_EMBEDDED ), + +END_DATADESC() + +//----------------------------------------------------------------------------- +// Purpose: We need to revert back any convar changes that are made by the +// commentary system during commentary. This code stores convar changes +// made by the commentary system, and reverts them when finished. +//----------------------------------------------------------------------------- +void CV_GlobalChange_MapEdit( IConVar *var, const char *pOldString, float flOldValue ) +{ + if ( !g_MapEdit.MapEditConvarsChanging() ) + { + // A convar has changed, but not due to mapedit. Ignore it. + return; + } + + g_MapEdit.ConvarChanged( var, pOldString, flOldValue ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CC_MapEditNotChanging( void ) +{ + g_MapEdit.SetMapEditConvarsChanging( false ); +} +static ConCommand mapedit_cvarsnotchanging( "mapedit_cvarsnotchanging", CC_MapEditNotChanging, 0 ); + +// ======================================================== +// Static functions that can be accessed from outside +// ======================================================== + +//----------------------------------------------------------------------------- +// Purpose: Reloads automatic MapEdit after cleanup +//----------------------------------------------------------------------------- +void MapEdit_MapReload( void ) +{ + Msg("MapEdit: Map reloading\n"); + + g_MapEdit.ShutDownMapEdit(); + + g_MapEdit.LevelInitPreEntity(); + + g_MapEdit.LevelInitPostEntity(); +} + +//----------------------------------------------------------------------------- +// Purpose: Loads a specific MapEdit file. +//----------------------------------------------------------------------------- +void MapEdit_LoadFile(const char *pFile, bool bStack) +{ + if (!filesystem->FileExists(pFile)) + { + Warning("MapEdit: No such file \"%s\"!\n", pFile); + return; + } + + if (IsMapEditLoaded()) + { + if (bStack) + { + g_MapEdit.SpawnMapEdit(pFile); + return; + } + else + { + g_MapEdit.SetMapEdit(false); + } + } + + g_MapEdit.SetMapEdit(true, pFile); +} + + +//----------------------------------------------------------------------------- +// Purpose: MapEdit specific logic_auto replacement. +// Fires outputs based upon how MapEdit has been activated. +//----------------------------------------------------------------------------- +class CMapEditAuto : public CBaseEntity +{ + DECLARE_CLASS( CMapEditAuto, CBaseEntity ); +public: + DECLARE_DATADESC(); + + void Spawn(void); + void Think(void); + +private: + // fired if loaded due to new map + COutputEvent m_OnMapEditNewGame; + + // fired if loaded in the middle of a map + COutputEvent m_OnMapEditMidGame; +}; + +LINK_ENTITY_TO_CLASS(mapedit_auto, CMapEditAuto); + +BEGIN_DATADESC( CMapEditAuto ) + // Outputs + DEFINE_OUTPUT(m_OnMapEditNewGame, "OnMapEditNewGame"), + DEFINE_OUTPUT(m_OnMapEditMidGame, "OnMapEditMidGame"), +END_DATADESC() + +//------------------------------------------------------------------------------ +// Purpose : Fire my outputs here if I fire on map reload +//------------------------------------------------------------------------------ +void CMapEditAuto::Spawn(void) +{ + BaseClass::Spawn(); + SetNextThink( gpGlobals->curtime + 0.1 ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CMapEditAuto::Think(void) +{ + if ( g_MapEdit.MapEditLoadedMidGame() ) + { + m_OnMapEditMidGame.FireOutput(NULL, this); + } + else + { + m_OnMapEditNewGame.FireOutput(NULL, this); + } +} + +//------------------------------------------------------------------------------ +// Purpose : +// Input : +// Output : +//------------------------------------------------------------------------------ +void CC_MapEdit_Load( const CCommand& args ) +{ + const char *sFile = args[1] ? args[1] : NULL; + + MapEdit_LoadFile(sFile, mapedit_stack.GetBool()); +} +static ConCommand mapedit_load("mapedit_load", CC_MapEdit_Load, "Forces mapedit to load a specific file. If there is no input value, it will load the map's default file.", FCVAR_CHEAT); + +//------------------------------------------------------------------------------ +// Purpose : Unloads all MapEdit entities. Does not undo modifications or deletions. +// Input : +// Output : +//------------------------------------------------------------------------------ +void CC_MapEdit_Unload( const CCommand& args ) +{ + g_MapEdit.SetMapEdit(false); +} +static ConCommand mapedit_unload("mapedit_unload", CC_MapEdit_Unload, "Forces mapedit to unload.", FCVAR_CHEAT); + +#else + +//------------------------------------------------------------------------------ +// Purpose : Prints MapEdit data from a specific file to the console. +// Input : The file to print +// Output : The file's data +//------------------------------------------------------------------------------ +void CC_MapEdit_Print( const CCommand& args ) +{ + const char *szFullName = args[1]; + if (szFullName && filesystem->FileExists(szFullName)) + { + KeyValues *pkvFile = new KeyValues( "MapEdit" ); + if ( pkvFile->LoadFromFile( filesystem, szFullName, "MOD" ) ) + { + Msg( "MapEdit: Printing MapEdit data from %s. \n", szFullName ); + + // Load each commentary block, and spawn the entities + KeyValues *pkvNode = pkvFile->GetFirstSubKey(); + while ( pkvNode ) + { + // Get node name + const char *pNodeName = pkvNode->GetName(); + Msg("- Section Name: %s\n", pNodeName); + + // Skip the trackinfo + if ( !Q_strncmp( pNodeName, "trackinfo", 9 ) ) + { + pkvNode = pkvNode->GetNextKey(); + continue; + } + + KeyValues *pClassname = pkvNode->GetFirstSubKey(); + while (pClassname) + { + // Use the classname instead + pNodeName = pClassname->GetName(); + + Msg(" %s\n", pNodeName); + for ( KeyValues *sub = pClassname->GetFirstSubKey(); sub; sub = sub->GetNextKey() ) + { + if (!Q_strcmp(sub->GetName(), "connections")) + { + Msg("- connections\n"); + for ( KeyValues *sub2 = sub->GetFirstSubKey(); sub2; sub2 = sub2->GetNextKey() ) + { + Msg("- \"%s\", \"%s\"\n", sub2->GetName(), sub2->GetString()); + } + continue; + } + Msg("- %s, %s\n", sub->GetName(), sub->GetString()); + } + + pClassname = pClassname->GetNextKey(); + } + + pkvNode = pkvNode->GetNextKey(); + } + + pkvNode->deleteThis(); + } + } +} +static ConCommand mapedit_print("mapedit_print", CC_MapEdit_Print, "Prints a mapedit file in the console."); + +#endif diff --git a/sp/src/game/shared/mapbase/MapEdit.h b/sp/src/game/shared/mapbase/MapEdit.h new file mode 100644 index 00000000..e832f348 --- /dev/null +++ b/sp/src/game/shared/mapbase/MapEdit.h @@ -0,0 +1,14 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Accessing MapEdit +// +// $NoKeywords: $ +//=============================================================================// + +extern ConVar mapedit_enabled; +extern ConVar mapedit_stack; +extern ConVar mapedit_debug; + +void MapEdit_MapReload( void ); + +void MapEdit_LoadFile( const char *pFile, bool bStack = mapedit_stack.GetBool() ); diff --git a/sp/src/game/shared/mapbase/mapbase_rpc.cpp b/sp/src/game/shared/mapbase/mapbase_rpc.cpp new file mode 100644 index 00000000..2aae5cf3 --- /dev/null +++ b/sp/src/game/shared/mapbase/mapbase_rpc.cpp @@ -0,0 +1,491 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Carries the Mapbase CAutoGameSystem that loads manifest among other things. +// Also includes code that does not fit anywhere else. +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" + +#ifdef CLIENT_DLL + +#ifdef STEAM_RPC +#include "clientsteamcontext.h" +#endif + +#ifdef DISCORD_RPC +#include "discord_rpc.h" +#include +#endif + +#endif + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +// From mapbase_shared.cpp +extern const char *g_MapName; + +// The game's name found in gameinfo.txt. Mostly used for Discord RPC. +extern char g_iszGameName[128]; + +#ifdef MAPBASE_RPC +void MapbaseRPC_CVarToggle( IConVar *var, const char *pOldString, float flOldValue ); + +ConVar mapbase_rpc_enabled("mapbase_rpc_enabled", "1", FCVAR_ARCHIVE, "Controls whether Mapbase's RPC stuff is enabled on this client.", MapbaseRPC_CVarToggle); + +//----------------------------------------------------------------------------- +// RPC Stuff +// +// Mapbase has some special "RPC" integration stuff for things like Discord. +// There's a section that goes into more detail below. +//----------------------------------------------------------------------------- + +void MapbaseRPC_Init(); +void MapbaseRPC_Shutdown(); + +void MapbaseRPC_Update( int iType, const char *pMapName ); +void MapbaseRPC_Update( int iRPCMask, int iType, const char *pMapName ); + +#ifdef STEAM_RPC +void MapbaseRPC_UpdateSteam( int iType, const char *pMapName ); +#endif + +#ifdef DISCORD_RPC +void MapbaseRPC_UpdateDiscord( int iType, const char *pMapName ); +void MapbaseRPC_GetDiscordParameters( DiscordRichPresence &discordPresence, int iType, const char *pMapName ); +#endif + +enum RPCClients_t +{ + RPC_STEAM, + RPC_DISCORD, + + NUM_RPCS, +}; + +static const char *g_pszRPCNames[] = { + "Steam", + "Discord", +}; + +// This is a little dodgy, but it stops us from having to add spawnflag definitions for each RPC. +#define RPCFlag(rpc) (1 << rpc) + +// The global game_metadata entity. +// There can be only one...for each RPC. +static EHANDLE g_Metadata[NUM_RPCS]; + +#define CMapbaseMetadata C_MapbaseMetadata + +// Don't update constantly +#define RPC_UPDATE_COOLDOWN 5.0f + +// How long to wait before updating in case multiple variables are changing +#define RPC_UPDATE_WAIT 0.25f +#endif + +class CMapbaseMetadata : public CBaseEntity +{ +public: + DECLARE_DATADESC(); + DECLARE_NETWORKCLASS(); + DECLARE_CLASS( CMapbaseMetadata, CBaseEntity ); + +#ifdef CLIENT_DLL + ~C_MapbaseMetadata() + { + for (int i = 0; i < NUM_RPCS; i++) + { + if (g_Metadata[i] == this) + { + g_Metadata[i] = NULL; + } + } + } + + void OnDataChanged( DataUpdateType_t updateType ) + { + if (updateType == DATA_UPDATE_CREATED) + { + for (int i = 0; i < NUM_RPCS; i++) + { + // See if we're updating this RPC. + if (m_spawnflags & RPCFlag(i)) + { + if (g_Metadata[i]) + { + Warning("Warning: Metadata entity for %s already exists, replacing with new one\n", g_pszRPCNames[i]); + + // Inherit their update timer + m_flRPCUpdateTimer = static_cast(g_Metadata[i].Get())->m_flRPCUpdateTimer; + + g_Metadata[i].Get()->Remove(); + } + + DevMsg("Becoming metadata entity for %s\n", g_pszRPCNames[i]); + g_Metadata[i] = this; + } + } + } + + // Avoid spamming updates + if (gpGlobals->curtime > (m_flRPCUpdateTimer - RPC_UPDATE_WAIT)) + { + // Multiple variables might be changing, wait until they're probably all finished + m_flRPCUpdateTimer = gpGlobals->curtime + RPC_UPDATE_WAIT; + } + + DevMsg("Metadata changed; updating in %f\n", m_flRPCUpdateTimer - gpGlobals->curtime); + + // Update when the cooldown is over + SetNextClientThink( m_flRPCUpdateTimer ); + } + + void ClientThink() + { + // NOTE: Client thinking should be limited by the update timer! + UpdateRPCThink(); + + // Wait until our data is changed again + SetNextClientThink( CLIENT_THINK_NEVER ); + } + + void UpdateRPCThink() + { + DevMsg("Global metadata entity: %s\n", g_Metadata != NULL ? "Valid" : "Invalid!?"); + + MapbaseRPC_Update(m_spawnflags, RPCSTATE_UPDATE, g_MapName); + + m_flRPCUpdateTimer = gpGlobals->curtime + RPC_UPDATE_COOLDOWN; + } +#else + int UpdateTransmitState() // always send to all clients + { + return SetTransmitState( FL_EDICT_ALWAYS ); + } +#endif + +#ifdef CLIENT_DLL + // Built-in update spam limiter + float m_flRPCUpdateTimer = RPC_UPDATE_COOLDOWN; + + char m_iszRPCState[128]; + char m_iszRPCDetails[128]; + + int m_spawnflags; +#else + CNetworkVar( string_t, m_iszRPCState ); + CNetworkVar( string_t, m_iszRPCDetails ); +#endif + + // TODO: Player-specific control + //CNetworkVar( int, m_iLimitingID ); +}; + +LINK_ENTITY_TO_CLASS( game_metadata, CMapbaseMetadata ); + +IMPLEMENT_NETWORKCLASS_ALIASED(MapbaseMetadata, DT_MapbaseMetadata) + +BEGIN_NETWORK_TABLE_NOBASE(CMapbaseMetadata, DT_MapbaseMetadata) + +#ifdef CLIENT_DLL + RecvPropString(RECVINFO(m_iszRPCState)), + RecvPropString(RECVINFO(m_iszRPCDetails)), + RecvPropInt( RECVINFO( m_spawnflags ) ), +#else + SendPropStringT(SENDINFO(m_iszRPCState) ), + SendPropStringT(SENDINFO(m_iszRPCDetails) ), + SendPropInt( SENDINFO(m_spawnflags), 8, SPROP_UNSIGNED ), +#endif + +END_NETWORK_TABLE() + +BEGIN_DATADESC( CMapbaseMetadata ) + + // Inputs + DEFINE_INPUT( m_iszRPCState, FIELD_STRING, "SetRPCState" ), + DEFINE_INPUT( m_iszRPCDetails, FIELD_STRING, "SetRPCDetails" ), + +END_DATADESC() + +#ifdef MAPBASE_RPC +//----------------------------------------------------------------------------- +// Purpose: Mapbase's special integration with rich presence clients, most notably Discord. +// +// This only has Discord as of writing, but similar/derived implementaton could expand to +// other clients in the future, maybe even Steam. +//----------------------------------------------------------------------------- + +//----------------------------------------- +// !!! FOR MODS !!! +// +// Create your own Discord "application" if you want to change what info/images show up, etc. +// You can find the convar that controls this in cdll_client_int.cpp. +// +// This code automatically shows the mod's title in the details, but it's easy to change if you want things to be chapter-specific, etc. +// +//----------------------------------------- + +static ConVar cl_discord_appid("cl_discord_appid", "582595088719413250", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT); +static int64_t startTimestamp = time(0); + +//----------------------------------------------------------------------------- +// Discord RPC handlers +//----------------------------------------------------------------------------- +static void HandleDiscordReady(const DiscordUser* connectedUser) +{ + DevMsg("Discord: Connected to user %s#%s - %s\n", + connectedUser->username, + connectedUser->discriminator, + connectedUser->userId); +} + +static void HandleDiscordDisconnected(int errcode, const char* message) +{ + DevMsg("Discord: Disconnected (%d: %s)\n", errcode, message); +} + +static void HandleDiscordError(int errcode, const char* message) +{ + DevMsg("Discord: Error (%d: %s)\n", errcode, message); +} + +static void HandleDiscordJoin(const char* secret) +{ + // Not implemented +} + +static void HandleDiscordSpectate(const char* secret) +{ + // Not implemented +} + +static void HandleDiscordJoinRequest(const DiscordUser* request) +{ + // Not implemented +} + +void MapbaseRPC_Init() +{ + // Steam RPC + if (steamapicontext->SteamFriends()) + steamapicontext->SteamFriends()->ClearRichPresence(); + + // Discord RPC + DiscordEventHandlers handlers; + memset(&handlers, 0, sizeof(handlers)); + + handlers.ready = HandleDiscordReady; + handlers.disconnected = HandleDiscordDisconnected; + handlers.errored = HandleDiscordError; + handlers.joinGame = HandleDiscordJoin; + handlers.spectateGame = HandleDiscordSpectate; + handlers.joinRequest = HandleDiscordJoinRequest; + + char appid[255]; + sprintf(appid, "%d", engine->GetAppID()); + Discord_Initialize(cl_discord_appid.GetString(), &handlers, 1, appid); + + if (!g_bTextMode) + { + DiscordRichPresence discordPresence; + memset(&discordPresence, 0, sizeof(discordPresence)); + + MapbaseRPC_GetDiscordParameters(discordPresence, RPCSTATE_INIT, NULL); + + discordPresence.startTimestamp = startTimestamp; + + Discord_UpdatePresence(&discordPresence); + } +} + +void MapbaseRPC_Shutdown() +{ + // Discord RPC + Discord_Shutdown(); + + // Steam RPC + if (steamapicontext->SteamFriends()) + steamapicontext->SteamFriends()->ClearRichPresence(); +} + +void MapbaseRPC_Update( int iType, const char *pMapName ) +{ + // All RPCs + MapbaseRPC_Update( INT_MAX, iType, pMapName ); +} + +void MapbaseRPC_Update( int iRPCMask, int iType, const char *pMapName ) +{ + if (iRPCMask & RPCFlag(RPC_STEAM)) + MapbaseRPC_UpdateSteam(iType, pMapName); + if (iRPCMask & RPCFlag(RPC_DISCORD)) + MapbaseRPC_UpdateDiscord(iType, pMapName); +} + +#ifdef STEAM_RPC +void MapbaseRPC_UpdateSteam( int iType, const char *pMapName ) +{ + if (!steamapicontext->SteamFriends()) + { + DevMsg("No Friends! :(\n"); + } + + const char *pszStatus = NULL; + + if (g_Metadata[RPC_STEAM] != NULL) + { + C_MapbaseMetadata *pMetadata = static_cast(g_Metadata[RPC_STEAM].Get()); + + if (pMetadata->m_iszRPCDetails[0] != NULL) + pszStatus = pMetadata->m_iszRPCDetails; + else if (pMetadata->m_iszRPCState[0] != NULL) + pszStatus = pMetadata->m_iszRPCState; + else + { + if (engine->IsLevelMainMenuBackground()) + pszStatus = VarArgs("Main Menu (%s)", pMapName ? pMapName : "N/A"); + else + pszStatus = VarArgs("Map: %s", pMapName ? pMapName : "N/A"); + } + } + else + { + switch (iType) + { + case RPCSTATE_INIT: + case RPCSTATE_LEVEL_SHUTDOWN: + { + pszStatus = "Main Menu"; + } break; + case RPCSTATE_LEVEL_INIT: + default: + { + // Say we're in the main menu if it's a background map + if (engine->IsLevelMainMenuBackground()) + { + pszStatus = VarArgs("Main Menu (%s)", pMapName ? pMapName : "N/A"); + } + else + { + pszStatus = VarArgs("Map: %s", pMapName ? pMapName : "N/A"); + } + } break; + } + } + + DevMsg("Updating Steam\n"); + if (pszStatus) + { + steamapicontext->SteamFriends()->SetRichPresence( "gamestatus", pszStatus ); + steamapicontext->SteamFriends()->SetRichPresence( "steam_display", "#SteamRPC_Status" ); + } +} +#endif + +#ifdef DISCORD_RPC +// Game-Specfic Image +// These are specific to the Mapbase Discord application, so you'll want to modify this for your own mod. +#if HL2_EPISODIC +#define DISCORD_GAME_IMAGE "mb_logo_episodic" +#define DISCORD_GAME_IMAGE_TEXT "Half-Life 2 Episodic" +#elif HL2_CLIENT_DLL +#define DISCORD_GAME_IMAGE "mb_logo_hl2" +#define DISCORD_GAME_IMAGE_TEXT "Half-Life 2" +#else +#define DISCORD_GAME_IMAGE "mb_logo_general" +#define DISCORD_GAME_IMAGE_TEXT "Mapbase" +#endif + +void MapbaseRPC_GetDiscordParameters( DiscordRichPresence &discordPresence, int iType, const char *pMapName ) +{ + if (g_Metadata[RPC_DISCORD] != NULL) + { + C_MapbaseMetadata *pMetadata = static_cast(g_Metadata[RPC_DISCORD].Get()); + + if (pMetadata->m_iszRPCState[0] != NULL) + discordPresence.state = pMetadata->m_iszRPCState; + else + discordPresence.state = g_iszGameName; + + if (pMetadata->m_iszRPCDetails[0] != NULL) + discordPresence.details = pMetadata->m_iszRPCDetails; + else + { + if (engine->IsLevelMainMenuBackground()) + discordPresence.details = VarArgs("Main Menu (%s)", pMapName ? pMapName : "N/A"); + else + discordPresence.details = VarArgs("Map: %s", pMapName ? pMapName : "N/A"); + } + } + else + { + switch (iType) + { + case RPCSTATE_INIT: + case RPCSTATE_LEVEL_SHUTDOWN: + { + discordPresence.state = g_iszGameName; + discordPresence.details = "Main Menu"; + } break; + case RPCSTATE_LEVEL_INIT: + default: + { + // Say we're in the main menu if it's a background map + if (engine->IsLevelMainMenuBackground()) + { + discordPresence.state = g_iszGameName; + discordPresence.details = VarArgs("Main Menu (%s)", pMapName ? pMapName : "N/A"); + } + else + { + discordPresence.state = g_iszGameName; + discordPresence.details = VarArgs("Map: %s", pMapName ? pMapName : "N/A"); + } + } break; + } + } + + // Generic Mapbase logo. Specific to the Mapbase Discord application. + discordPresence.smallImageKey = "mb_logo_general"; + discordPresence.smallImageText = "Mapbase"; + +#ifdef DISCORD_GAME_IMAGE + discordPresence.largeImageKey = DISCORD_GAME_IMAGE; + discordPresence.largeImageText = DISCORD_GAME_IMAGE_TEXT; +#endif +} + +void MapbaseRPC_UpdateDiscord( int iType, const char *pMapName ) +{ + DiscordRichPresence discordPresence; + memset(&discordPresence, 0, sizeof(discordPresence)); + + DevMsg("Updating Discord\n"); + + discordPresence.startTimestamp = startTimestamp; + + MapbaseRPC_GetDiscordParameters( discordPresence, iType, pMapName ); + + Discord_UpdatePresence(&discordPresence); +} + +void MapbaseRPC_CVarToggle( IConVar *var, const char *pOldString, float flOldValue ) +{ + if (flOldValue <= 0 && mapbase_rpc_enabled.GetInt() > 0) + { + // Turning on + MapbaseRPC_Init(); + MapbaseRPC_Update( g_MapName != NULL ? RPCSTATE_UPDATE : RPCSTATE_INIT, g_MapName ); + } + else if (mapbase_rpc_enabled.GetInt() <= 0) + { + // Turning off + MapbaseRPC_Shutdown(); + } +} +#endif + +#endif diff --git a/sp/src/game/shared/mapbase/mapbase_shared.cpp b/sp/src/game/shared/mapbase/mapbase_shared.cpp new file mode 100644 index 00000000..bd31f4e3 --- /dev/null +++ b/sp/src/game/shared/mapbase/mapbase_shared.cpp @@ -0,0 +1,435 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Carries the Mapbase CAutoGameSystem that loads manifest among other things. +// Also includes code that does not fit anywhere else. +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" + +#include "tier0/icommandline.h" +#include "igamesystem.h" +#include "filesystem.h" +#include +#include +#include "saverestore_utlvector.h" +#include "props_shared.h" +#include "utlbuffer.h" +#ifdef CLIENT_DLL +#include "hud_closecaption.h" +#include "panelmetaclassmgr.h" +#include "c_soundscape.h" +#else +#include "soundscape_system.h" +#include "AI_ResponseSystem.h" +#include "mapbase/SystemConvarMod.h" +#endif + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +#define GENERIC_MANIFEST_FILE "scripts/mapbase_default_manifest.txt" + +#ifdef CLIENT_DLL +#define AUTOLOADED_MANIFEST_FILE VarArgs("maps/%s_manifest.txt", g_MapName) +#else +#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; + +ConVar mapbase_load_default_manifest("mapbase_load_default_manifest", "1", FCVAR_ARCHIVE, "Should we automatically load our default manifest file? (\"maps/%mapname%_manifest.txt\")"); + +ConVar mapbase_load_soundscripts("mapbase_load_soundscripts", "1", FCVAR_ARCHIVE, "Should we load map-specific soundscripts? e.g. \"maps/mapname_level_sounds.txt\""); + +//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 + +#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\""); + +ConVar mapbase_load_talker("mapbase_load_talker", "1", FCVAR_ARCHIVE, "Should we load map-specific talker files? e.g. \"maps/mapname_talker.txt\""); +ConVar mapbase_flush_talker("mapbase_flush_talker", "1", FCVAR_NONE, "Normally, when a map with custom talker files is unloaded, the response system resets to rid itself of the custom file(s). Turn this convar off to prevent that from happening."); + +ConVar mapbase_load_actbusy("mapbase_load_actbusy", "1", FCVAR_ARCHIVE, "Should we load map-specific actbusy files? e.g. \"maps/mapname_actbusy.txt\""); + +#endif + +#ifdef GAME_DLL +extern void ParseCustomActbusyFile(const char *file); + +extern bool LoadResponseSystemFile(const char *scriptfile); +extern void ReloadResponseSystem(); + +// Reloads the response system when the map changes to avoid custom talker leaking +static bool g_bMapContainsCustomTalker; +#endif + +// Indicates this is a core Mapbase mod and not a mod using its code. +static bool g_bMapbaseCore; + +// The game's name found in gameinfo.txt. Mostly used for Discord RPC. +char g_iszGameName[128]; + +enum +{ + MANIFEST_SOUNDSCRIPTS, + //MANIFEST_PROPDATA, +#if MAPBASE_SOUNDSCAPE_SUPPORT + MANIFEST_SOUNDSCAPES, +#endif +#ifdef CLIENT_DLL + //MANIFEST_CLOSECAPTION, + MANIFEST_LOCALIZATION, + MANIFEST_VGUI, +#else + MANIFEST_TALKER, + MANIFEST_SENTENCES, + MANIFEST_ACTBUSY, +#endif + + // Must always be kept below + MANIFEST_NUM_TYPES, +}; + +struct ManifestType_t +{ + //int type; + const char *string; + ConVar *cvar; +}; + +// KEEP THS IN SYNC WITH THE ENUM! +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 +#ifdef CLIENT_DLL + //{ "closecaption", &mapbase_load_cc }, + { "localization", &mapbase_load_localization }, + { "vgui", NULL }, +#else + { "talker", &mapbase_load_talker }, + { "sentences", &mapbase_load_sentences }, + { "actbusy", &mapbase_load_actbusy }, +#endif +}; + +//----------------------------------------------------------------------------- +// Purpose: System used to load map-specific files, etc. +//----------------------------------------------------------------------------- +class CMapbaseSystem : public CAutoGameSystem +{ +public: + DECLARE_DATADESC(); + + CMapbaseSystem() : CAutoGameSystem( "CMapbaseSystem" ) + { + } + + inline bool GetGameInfoKeyValues(KeyValues *pKeyValues) + { + return pKeyValues->LoadFromFile( filesystem, "gameinfo.txt", "GAME" ); + } + + virtual void LevelInitPreEntity() + { +#ifdef GAME_DLL + Msg("Mapbase system loaded\n"); +#endif + + // Checks gameinfo.txt for Mapbase-specific options + KeyValues *gameinfo = new KeyValues("GameInfo"); + if (GetGameInfoKeyValues(gameinfo)) + { + // Indicates this is a core Mapbase mod and not a mod using its code + g_bMapbaseCore = gameinfo->GetBool("mapbase_core", false); + + if (!gameinfo->GetBool("hide_mod_name", false)) + { + // Store the game's name + Q_strncpy(g_iszGameName, gameinfo->GetString("game"), sizeof(g_iszGameName)); + } + } + gameinfo->deleteThis(); + + +#ifdef GAME_DLL + if (g_bMapContainsCustomTalker && mapbase_flush_talker.GetBool()) + { + DevMsg("Mapbase: Reloading response system to flush custom talker\n"); + ReloadResponseSystem(); + g_bMapContainsCustomTalker = false; + } + + g_MapName = STRING(gpGlobals->mapname); +#else + //char mapname[128]; + //Q_StripExtension(MapName(), mapname, sizeof(mapname)); + g_MapName = MapName() - 4; // Removes ".bsp" + + // Shared Mapbase localization file + g_pVGuiLocalize->AddFile( "resource/mapbase_%language%.txt" ); +#endif + // Check for a generic "mapname_manifest.txt" file and load it. + if (filesystem->FileExists(AUTOLOADED_MANIFEST_FILE, "GAME") /*&& !FStrEq(name, "closecaption")*/) + { + AddManifestFile(AUTOLOADED_MANIFEST_FILE); + } + else + { + // Load the generic script instead. + ParseGenericManifest(); + } + } + + virtual void LevelShutdownPreEntity() + { + // How would we make sure they don't last between maps? + // TODO: Investigate ReloadLocalizationFiles() + //g_pVGuiLocalize->RemoveAll(); + //g_pVGuiLocalize->ReloadLocalizationFiles(); + } + + virtual void LevelShutdownPostEntity() + { + g_MapName = NULL; + } + + // Get a generic, hardcoded manifest with hardcoded names. + void ParseGenericManifest() + { + if (!mapbase_load_default_manifest.GetBool()) + return; + + KeyValues *pKV = new KeyValues("DefaultManifest"); + pKV->LoadFromFile(filesystem, GENERIC_MANIFEST_FILE); + + AddManifestFile(pKV/*, true*/); + + pKV->deleteThis(); + } + + void AddManifestFile( const char *file, bool bDontStore = false ) + { + KeyValues *pKV = new KeyValues(file); + if ( !pKV->LoadFromFile( filesystem, file ) ) + { + Warning("Mapbase Manifest: \"%s\" is unreadable or missing (can't load KV, check for syntax errors)\n", file); + pKV->deleteThis(); + return; + } + + DevMsg("===== Mapbase Manifest: Loading manifest file %s =====\n", file); + + AddManifestFile(pKV, false); + + DevMsg("==============================================================================\n"); + + pKV->deleteThis(); + } + + void LoadFromValue( const char *value, int type, bool bDontWarn ) + { + if (!filesystem->FileExists(value, "GAME") /*&& !FStrEq(name, "closecaption")*/) + { + if (!bDontWarn) + { + Warning("Mapbase Manifest: WARNING! \"%s\" does not exist!\n", value); + } + return; + } + + switch (type) + { + case MANIFEST_SOUNDSCRIPTS: { soundemitterbase->AddSoundOverrides(value); } break; + //case MANIFEST_PROPDATA: { g_PropDataSystem.ParsePropDataFile(value); } 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 +#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_SENTENCES: { engine->PrecacheSentenceFile(value); } break; + case MANIFEST_ACTBUSY: { ParseCustomActbusyFile(value); } break; +#endif + } + } + + // This doesn't call deleteThis()! + void AddManifestFile(KeyValues *pKV, bool bDontWarn = false) + { + const char *name; + char value[MAX_PATH]; + char *szToken; + bool inparam = false; + for (KeyValues *pKey = pKV->GetFirstSubKey(); pKey; pKey = pKey->GetNextKey()) + { + name = pKey->GetName(); + + // Parse %mapname%, etc. + inparam = false; + value[0] = '\0'; + szToken = strtok(strdup(pKey->GetString()), "%"); // Was tempvalue + while (szToken != NULL) + { + 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")) + { + char uilanguage[64]; + engine->GetUILanguage(uilanguage, sizeof(uilanguage)); + append = uilanguage; + } +#endif + Q_strncat(value, append, sizeof(value)); + + inparam = false; + } + else + { + Q_strncat(value, szToken, sizeof(value)); + + inparam = true; + } + szToken = strtok(NULL, "%"); + } + + if (FStrEq(name, "NoErrors")) + { + bDontWarn = pKey->GetBool(); + } + + for (int i = 0; i < MANIFEST_NUM_TYPES; i++) + { + if (FStrEq(name, gm_szManifestFileStrings[i].string)) + { + if (!gm_szManifestFileStrings[i].cvar || gm_szManifestFileStrings[i].cvar->GetBool()) + { + LoadFromValue(value, i, bDontWarn); + } + break; + } + } + } + } +}; + +CMapbaseSystem g_MapbaseSystem; + +BEGIN_DATADESC_NO_BASE( CMapbaseSystem ) + + //DEFINE_UTLVECTOR( m_StoredManifestFiles, FIELD_STRING ), + +END_DATADESC() + +#ifdef GAME_DLL +ThreeState_t Flashlight_GetLegacyVersionKey() +{ + KeyValues *gameinfo = new KeyValues( "GameInfo" ); + if (g_MapbaseSystem.GetGameInfoKeyValues( gameinfo )) + { + // -1 = default + int iUseLegacyFlashlight = gameinfo->GetInt( "use_legacy_flashlight", -1 ); + if (iUseLegacyFlashlight > -1) + return iUseLegacyFlashlight != 0 ? TRS_TRUE : TRS_FALSE; + } + gameinfo->deleteThis(); + + return TRS_NONE; +} + +static void CC_Mapbase_LoadManifestFile( const CCommand& args ) +{ + g_MapbaseSystem.AddManifestFile(args[1], args[2]); +} + +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 +{ +public: + DECLARE_DATADESC(); + + DECLARE_CLASS( CMapbaseManifestEntity, CPointEntity ); + + void Spawn( void ) + { + BaseClass::Spawn(); + if (HasSpawnFlags(SF_MANIFEST_START_ACTIVATED)) + { + LoadManifestFile(); + } + } + + void LoadManifestFile( void ) + { + const char *scriptfile = STRING(m_target); + if ( filesystem->FileExists( scriptfile, "GAME" ) ) + { + Msg("Mapbase: Adding manifest file \"%s\"\n", scriptfile); + g_MapbaseSystem.AddManifestFile(scriptfile); + } + else + { + Warning("Mapbase: Manifest file \"%s\" does not exist!", scriptfile); + } + } + + void InputActivate(inputdata_t &inputdata) + { + LoadManifestFile(); + } +}; + +LINK_ENTITY_TO_CLASS( mapbase_manifest, CMapbaseManifestEntity ); + +BEGIN_DATADESC( CMapbaseManifestEntity ) + + // Needs to be set up in the Activate methods of derived classes + //DEFINE_CUSTOM_FIELD( m_pInstancedResponseSystem, responseSystemSaveRestoreOps ), + + // Function Pointers + DEFINE_INPUTFUNC( FIELD_VOID, "Activate", InputActivate ), + +END_DATADESC() +#endif diff --git a/sp/src/game/shared/physics_shared.cpp b/sp/src/game/shared/physics_shared.cpp index ba5e0d2a..2ab9396a 100644 --- a/sp/src/game/shared/physics_shared.cpp +++ b/sp/src/game/shared/physics_shared.cpp @@ -1003,7 +1003,11 @@ void PhysFrictionSound( CBaseEntity *pEntity, IPhysicsObject *pObject, float ene if ( psurf->sounds.scrapeSmooth && phit->audio.roughnessFactor < psurf->audio.roughThreshold ) { soundName = psurf->sounds.scrapeSmooth; +#ifdef MAPBASE + soundHandle = &psurf->soundhandles.scrapeSmooth; +#else soundHandle = &psurf->soundhandles.scrapeRough; +#endif } const char *pSoundName = physprops->GetString( soundName ); diff --git a/sp/src/game/shared/playernet_vars.h b/sp/src/game/shared/playernet_vars.h index ac9f7766..5538d31b 100644 --- a/sp/src/game/shared/playernet_vars.h +++ b/sp/src/game/shared/playernet_vars.h @@ -98,6 +98,13 @@ struct sky3dparams_t // 3d skybox camera data CNetworkVar( int, scale ); CNetworkVector( origin ); +#ifdef MAPBASE + // Skybox angle support + CNetworkQAngle( angles ); + + // Sky clearcolor + CNetworkColor32( skycolor ); +#endif CNetworkVar( int, area ); // 3d skybox fog data diff --git a/sp/src/game/shared/precipitation_shared.h b/sp/src/game/shared/precipitation_shared.h index 791ec29f..b3820aa7 100644 --- a/sp/src/game/shared/precipitation_shared.h +++ b/sp/src/game/shared/precipitation_shared.h @@ -18,6 +18,12 @@ enum PrecipitationType_t PRECIPITATION_TYPE_SNOW, PRECIPITATION_TYPE_ASH, PRECIPITATION_TYPE_SNOWFALL, +#ifdef MAPBASE + PRECIPITATION_TYPE_PARTICLERAIN, + PRECIPITATION_TYPE_PARTICLEASH, + PRECIPITATION_TYPE_PARTICLERAINSTORM, + PRECIPITATION_TYPE_PARTICLESNOW, +#endif NUM_PRECIPITATION_TYPES }; diff --git a/sp/src/game/shared/props_shared.h b/sp/src/game/shared/props_shared.h index c63cb212..87ce823d 100644 --- a/sp/src/game/shared/props_shared.h +++ b/sp/src/game/shared/props_shared.h @@ -32,6 +32,9 @@ #define SF_PHYSPROP_ALWAYS_PICK_UP 0x100000 // Physcannon can always pick this up, no matter what mass or constraints may apply. #define SF_PHYSPROP_NO_COLLISIONS 0x200000 // Don't enable collisions on spawn #define SF_PHYSPROP_IS_GIB 0x400000 // Limit # of active gibs +#ifdef MAPBASE +#define SF_PHYSPROP_NO_ZOMBIE_SWAT 0x800000 // Zombies are not allowed to swat this +#endif // Any barrel farther away than this is ignited rather than exploded. #define PROP_EXPLOSION_IGNITE_RADIUS 32.0f diff --git a/sp/src/game/shared/ragdoll_shared.cpp b/sp/src/game/shared/ragdoll_shared.cpp index e77e9a75..2ebde986 100644 --- a/sp/src/game/shared/ragdoll_shared.cpp +++ b/sp/src/game/shared/ragdoll_shared.cpp @@ -877,6 +877,27 @@ void CRagdollLRURetirement::Update( float frametime ) // EPISODIC VERSION for ( i = m_LRU.Head(); i < m_LRU.InvalidIndex(); i = next ) { +#ifdef MAPBASE + next = m_LRU.Next(i); + + CBaseAnimating *pRagdoll = m_LRU[i].Get(); + + if ( pRagdoll ) + { + IPhysicsObject *pObject = pRagdoll->VPhysicsGetObject(); + if ( pRagdoll->GetEffectEntity() || ( pObject && !pObject->IsAsleep()) ) + continue; + + // float distToPlayer = (pPlayer->GetAbsOrigin() - pRagdoll->GetAbsOrigin()).LengthSqr(); + float distToPlayer = (PlayerOrigin - pRagdoll->GetAbsOrigin()).LengthSqr(); + + if (distToPlayer > furthestDistSq) + { + furthestOne = i; + furthestDistSq = distToPlayer; + } + } +#else CBaseAnimating *pRagdoll = m_LRU[i].Get(); next = m_LRU.Next(i); @@ -895,6 +916,7 @@ void CRagdollLRURetirement::Update( float frametime ) // EPISODIC VERSION furthestDistSq = distToPlayer; } } +#endif else // delete bad rags first. { furthestOne = i; @@ -1007,9 +1029,19 @@ void CRagdollLRURetirement::Update( float frametime ) // Non-episodic version CBaseAnimating *pRagdoll = m_LRU[i].Get(); +#ifdef MAPBASE + if ( pRagdoll ) + { + //Just ignore it until we're done burning/dissolving. + IPhysicsObject *pObject = pRagdoll->VPhysicsGetObject(); + if ( pRagdoll->GetEffectEntity() || ( pObject && !pObject->IsAsleep()) ) + continue; + } +#else //Just ignore it until we're done burning/dissolving. if ( pRagdoll && pRagdoll->GetEffectEntity() ) continue; +#endif #ifdef CLIENT_DLL m_LRU[ i ]->SUB_Remove(); diff --git a/sp/src/game/shared/shareddefs.h b/sp/src/game/shared/shareddefs.h index 842d2f06..349c986c 100644 --- a/sp/src/game/shared/shareddefs.h +++ b/sp/src/game/shared/shareddefs.h @@ -688,6 +688,9 @@ struct FireBulletsInfo_t m_vecDirShooting.Init( VEC_T_NAN, VEC_T_NAN, VEC_T_NAN ); #endif m_bPrimaryAttack = true; +#ifdef MAPBASE + m_pIgnoreEntList = NULL; +#endif } FireBulletsInfo_t( int nShots, const Vector &vecSrc, const Vector &vecDir, const Vector &vecSpread, float flDistance, int nAmmoType, bool bPrimaryAttack = true ) @@ -706,6 +709,9 @@ struct FireBulletsInfo_t m_pAdditionalIgnoreEnt = NULL; m_flDamageForceScale = 1.0f; m_bPrimaryAttack = bPrimaryAttack; +#ifdef MAPBASE + m_pIgnoreEntList = NULL; +#endif } int m_iShots; @@ -722,6 +728,14 @@ struct FireBulletsInfo_t CBaseEntity *m_pAttacker; CBaseEntity *m_pAdditionalIgnoreEnt; bool m_bPrimaryAttack; +#ifdef MAPBASE + // This variable is like m_pAdditionalIgnoreEnt, but it's a list of entities instead of just one. + // Since func_tanks already use m_pAdditionalIgnoreEnt for parents, they needed another way to stop hitting their controllers. + // After much trial and error, I decided to just add more excluded entities to the bullet firing info. + // It could've just been a single entity called "m_pAdditionalIgnoreEnt2", but since these are just pointers, + // I planned ahead and made it a CUtlVector instead. + CUtlVector *m_pIgnoreEntList; +#endif }; //----------------------------------------------------------------------------- diff --git a/sp/src/game/shared/util_shared.cpp b/sp/src/game/shared/util_shared.cpp index 67f46825..920f9ca9 100644 --- a/sp/src/game/shared/util_shared.cpp +++ b/sp/src/game/shared/util_shared.cpp @@ -986,6 +986,57 @@ void UTIL_StringToColor32( color32 *color, const char *pString ) color->a = tmp[3]; } +#ifdef MAPBASE +void UTIL_StringToFloatArray_PreserveArray( float *pVector, int count, const char *pString ) +{ + char *pstr, *pfront, tempString[128]; + int j; + + Q_strncpy( tempString, pString, sizeof(tempString) ); + pstr = pfront = tempString; + + for ( j = 0; j < count; j++ ) // lifted from pr_edict.c + { + pVector[j] = atof( pfront ); + + // skip any leading whitespace + while ( *pstr && *pstr <= ' ' ) + pstr++; + + // skip to next whitespace + while ( *pstr && *pstr > ' ' ) + pstr++; + + if (!*pstr) + break; + + pstr++; + pfront = pstr; + } +} + +void UTIL_StringToIntArray_PreserveArray( int *pVector, int count, const char *pString ) +{ + char *pstr, *pfront, tempString[128]; + int j; + + Q_strncpy( tempString, pString, sizeof(tempString) ); + pstr = pfront = tempString; + + for ( j = 0; j < count; j++ ) // lifted from pr_edict.c + { + pVector[j] = atoi( pfront ); + + while ( *pstr && *pstr != ' ' ) + pstr++; + if (!*pstr) + break; + pstr++; + pfront = pstr; + } +} +#endif + #ifndef _XBOX void UTIL_DecodeICE( unsigned char * buffer, int size, const unsigned char *key) { diff --git a/sp/src/game/shared/util_shared.h b/sp/src/game/shared/util_shared.h index 18f066c3..b24c61fc 100644 --- a/sp/src/game/shared/util_shared.h +++ b/sp/src/game/shared/util_shared.h @@ -358,6 +358,14 @@ void UTIL_StringToIntArray( int *pVector, int count, const char *pString ); void UTIL_StringToFloatArray( float *pVector, int count, const char *pString ); void UTIL_StringToColor32( color32 *color, const char *pString ); +#ifdef MAPBASE +// Version of UTIL_StringToIntArray that doesn't set all untouched array elements to 0. +void UTIL_StringToIntArray_PreserveArray( int *pVector, int count, const char *pString ); + +// Version of UTIL_StringToFloatArray that doesn't set all untouched array elements to 0. +void UTIL_StringToFloatArray_PreserveArray( float *pVector, int count, const char *pString ); +#endif + CBasePlayer *UTIL_PlayerByIndex( int entindex ); //============================================================================= diff --git a/sp/src/game/shared/weapon_proficiency.h b/sp/src/game/shared/weapon_proficiency.h index 6532b79c..e91f67cf 100644 --- a/sp/src/game/shared/weapon_proficiency.h +++ b/sp/src/game/shared/weapon_proficiency.h @@ -19,6 +19,11 @@ struct WeaponProficiencyInfo_t enum WeaponProficiency_t { +#ifdef MAPBASE + // For the override + WEAPON_PROFICIENCY_INVALID = -1, +#endif + WEAPON_PROFICIENCY_POOR = 0, WEAPON_PROFICIENCY_AVERAGE, WEAPON_PROFICIENCY_GOOD, diff --git a/sp/src/lib/public/discord-rpc.lib b/sp/src/lib/public/discord-rpc.lib new file mode 100644 index 00000000..d8b6689f Binary files /dev/null and b/sp/src/lib/public/discord-rpc.lib differ diff --git a/sp/src/lib/public/fgdlib.lib b/sp/src/lib/public/fgdlib.lib index cc4b4d6f..df0540b1 100644 Binary files a/sp/src/lib/public/fgdlib.lib and b/sp/src/lib/public/fgdlib.lib differ diff --git a/sp/src/lib/public/mathlib.lib b/sp/src/lib/public/mathlib.lib index e78a6df8..309a5112 100644 Binary files a/sp/src/lib/public/mathlib.lib and b/sp/src/lib/public/mathlib.lib differ diff --git a/sp/src/lib/public/raytrace.lib b/sp/src/lib/public/raytrace.lib index c080d044..a9fbf646 100644 Binary files a/sp/src/lib/public/raytrace.lib and b/sp/src/lib/public/raytrace.lib differ diff --git a/sp/src/lib/public/tier1.lib b/sp/src/lib/public/tier1.lib index 8b5b14bf..a679ced2 100644 Binary files a/sp/src/lib/public/tier1.lib and b/sp/src/lib/public/tier1.lib differ diff --git a/sp/src/lib/public/vgui_controls.lib b/sp/src/lib/public/vgui_controls.lib index 893264a5..e731a4a8 100644 Binary files a/sp/src/lib/public/vgui_controls.lib and b/sp/src/lib/public/vgui_controls.lib differ diff --git a/sp/src/materialsystem/stdshaders/BaseVSShader.cpp b/sp/src/materialsystem/stdshaders/BaseVSShader.cpp index 31c2e9b2..a44cf766 100644 --- a/sp/src/materialsystem/stdshaders/BaseVSShader.cpp +++ b/sp/src/materialsystem/stdshaders/BaseVSShader.cpp @@ -20,28 +20,30 @@ #endif #if SUPPORT_DX8 -#include "lightmappedgeneric_flashlight_vs11.inc" -#include "flashlight_ps11.inc" +#include "sdk_lightmappedgeneric_flashlight_vs11.inc" +#include "sdk_flashlight_ps11.inc" #endif #ifdef STDSHADER_DX9_DLL_EXPORT -#include "lightmappedgeneric_flashlight_vs20.inc" +#include "sdk_lightmappedgeneric_flashlight_vs20.inc" +#include "sdk_lightmappedgeneric_flashlight_vs30.inc" #endif #ifdef STDSHADER_DX9_DLL_EXPORT -#include "flashlight_ps20.inc" -#include "flashlight_ps20b.inc" +#include "sdk_flashlight_ps20.inc" +#include "sdk_flashlight_ps20b.inc" +#include "sdk_flashlight_ps30.inc" #endif -#include "unlitgeneric_vs11.inc" -#include "VertexLitGeneric_EnvmappedBumpmap_NoLighting_ps14.inc" -#include "VertexLitGeneric_EnvmappedBumpmap_NoLighting.inc" -#include "vertexlitgeneric_flashlight_vs11.inc" -#include "LightmappedGeneric_BaseTexture.inc" -#include "LightmappedGeneric_BumpmappedLightmap_Base_ps14.inc" -#include "LightmappedGeneric_BumpmappedLightmap_Blend_ps14.inc" -#include "lightmappedgeneric_bumpmappedenvmap_ps14.inc" -#include "lightmappedgeneric_bumpmappedenvmap.inc" -#include "lightmappedgeneric_basetextureblend.inc" -#include "lightmappedgeneric_bumpmappedlightmap.inc" +#include "sdk_unlitgeneric_vs11.inc" +#include "sdk_VertexLitGeneric_EnvmappedBumpmap_NoLighting_ps14.inc" +#include "sdk_VertexLitGeneric_EnvmappedBumpmap_NoLighting.inc" +#include "sdk_vertexlitgeneric_flashlight_vs11.inc" +#include "sdk_LightmappedGeneric_BaseTexture.inc" +#include "sdk_LightmappedGeneric_BumpmappedLightmap_Base_ps14.inc" +#include "sdk_LightmappedGeneric_BumpmappedLightmap_Blend_ps14.inc" +#include "sdk_lightmappedgeneric_bumpmappedenvmap_ps14.inc" +#include "sdk_lightmappedgeneric_bumpmappedenvmap.inc" +#include "sdk_lightmappedgeneric_basetextureblend.inc" +#include "sdk_lightmappedgeneric_bumpmappedlightmap.inc" #endif // GAME_SHADER_DLL // memdbgon must be the last include file in a .cpp file!!! @@ -49,6 +51,9 @@ static ConVar mat_fullbright( "mat_fullbright","0", FCVAR_CHEAT ); +// NOTE: This is externed in BaseVSShader.h so it needs to be here +ConVar r_flashlightbrightness( "r_flashlightbrightness", "0.25", FCVAR_CHEAT ); + // These functions are to be called from the shaders. //----------------------------------------------------------------------------- @@ -966,7 +971,7 @@ void CBaseVSShader::VertexShaderUnlitGenericPass( int baseTextureVar, int frameV s_pShaderShadow->SetPixelShader( pshName ); // Compute the vertex shader index. - unlitgeneric_vs11_Static_Index vshIndex; + sdk_unlitgeneric_vs11_Static_Index vshIndex; vshIndex.SetDETAIL( bDetail ); vshIndex.SetENVMAP( bEnvmap ); vshIndex.SetENVMAPCAMERASPACE( bEnvmap && bEnvmapCameraSpace ); @@ -1048,7 +1053,7 @@ void CBaseVSShader::VertexShaderUnlitGenericPass( int baseTextureVar, int frameV s_pShaderAPI->SetPixelShaderConstant( 0, flConsts, 3 ); // Compute the vertex shader index. - unlitgeneric_vs11_Dynamic_Index vshIndex; + sdk_unlitgeneric_vs11_Dynamic_Index vshIndex; vshIndex.SetDOWATERFOG( s_pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); vshIndex.SetSKINNING( s_pShaderAPI->GetCurrentNumBones() > 0 ); s_pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() ); @@ -1068,7 +1073,7 @@ void CBaseVSShader::DrawWorldBaseTexture( int baseTextureVar, int baseTextureTra VERTEX_POSITION, 1, 0, 0 ); s_pShaderShadow->SetPixelShader( "LightmappedGeneric_BaseTexture" ); SetNormalBlendingShadowState(); - lightmappedgeneric_basetexture_Static_Index vshIndex; + sdk_lightmappedgeneric_basetexture_Static_Index vshIndex; s_pShaderShadow->SetVertexShader( "LightmappedGeneric_BaseTexture", vshIndex.GetIndex() ); FogToOOOverbright(); @@ -1087,7 +1092,7 @@ void CBaseVSShader::DrawWorldBaseTexture( int baseTextureVar, int baseTextureTra } SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, baseTextureTransformVar ); SetColorPixelShaderConstant( 0, colorVar, alphaVar ); - lightmappedgeneric_basetexture_Dynamic_Index vshIndex; + sdk_lightmappedgeneric_basetexture_Dynamic_Index vshIndex; vshIndex.SetDOWATERFOG( s_pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); s_pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() ); } @@ -1111,7 +1116,7 @@ void CBaseVSShader::DrawWorldBumpedDiffuseLighting( int bumpmapVar, int bumpFram } s_pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 3, 0, 0 ); - lightmappedgeneric_bumpmappedlightmap_Static_Index vshIndex; + sdk_lightmappedgeneric_bumpmappedlightmap_Static_Index vshIndex; s_pShaderShadow->SetVertexShader( "LightmappedGeneric_BumpmappedLightmap", vshIndex.GetIndex() ); if ( bSSBump ) @@ -1135,7 +1140,7 @@ void CBaseVSShader::DrawWorldBumpedDiffuseLighting( int bumpmapVar, int bumpFram SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, bumpTransformVar ); SetModulationPixelShaderDynamicState( 3 ); - lightmappedgeneric_bumpmappedlightmap_Dynamic_Index vshIndex; + sdk_lightmappedgeneric_bumpmappedlightmap_Dynamic_Index vshIndex; vshIndex.SetDOWATERFOG( s_pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); s_pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() ); } @@ -1155,7 +1160,7 @@ void CBaseVSShader::DrawWorldBumpedDiffuseLighting_Base_ps14( int bumpmapVar, in s_pShaderShadow->EnableTexture( SHADER_SAMPLER4, true ); s_pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 3, 0, 0 ); - lightmappedgeneric_bumpmappedlightmap_base_ps14_Static_Index vshIndex; + sdk_lightmappedgeneric_bumpmappedlightmap_base_ps14_Static_Index vshIndex; s_pShaderShadow->SetVertexShader( "LightmappedGeneric_BumpmappedLightmap_Base_ps14", vshIndex.GetIndex() ); s_pShaderShadow->SetPixelShader( "LightmappedGeneric_BumpmappedLightmap_Base_ps14" ); @@ -1178,7 +1183,7 @@ void CBaseVSShader::DrawWorldBumpedDiffuseLighting_Base_ps14( int bumpmapVar, in SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, baseTextureTransformVar ); SetModulationPixelShaderDynamicState( 3 ); - lightmappedgeneric_bumpmappedlightmap_base_ps14_Dynamic_Index vshIndex; + sdk_lightmappedgeneric_bumpmappedlightmap_base_ps14_Dynamic_Index vshIndex; vshIndex.SetDOWATERFOG( s_pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); s_pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() ); } @@ -1202,7 +1207,7 @@ void CBaseVSShader::DrawWorldBumpedDiffuseLighting_Blend_ps14( int bumpmapVar, i s_pShaderShadow->EnableTexture( SHADER_SAMPLER5, true ); s_pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 3, 0, 0 ); - lightmappedgeneric_bumpmappedlightmap_blend_ps14_Static_Index vshIndex; + sdk_lightmappedgeneric_bumpmappedlightmap_blend_ps14_Static_Index vshIndex; s_pShaderShadow->SetVertexShader( "LightmappedGeneric_BumpmappedLightmap_Blend_ps14", vshIndex.GetIndex() ); s_pShaderShadow->SetPixelShader( "LightmappedGeneric_BumpmappedLightmap_Blend_ps14" ); @@ -1227,7 +1232,7 @@ void CBaseVSShader::DrawWorldBumpedDiffuseLighting_Blend_ps14( int bumpmapVar, i SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_4, baseTextureTransform2Var ); SetModulationPixelShaderDynamicState( 3 ); - lightmappedgeneric_bumpmappedlightmap_blend_ps14_Dynamic_Index vshIndex; + sdk_lightmappedgeneric_bumpmappedlightmap_blend_ps14_Dynamic_Index vshIndex; vshIndex.SetDOWATERFOG( s_pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); s_pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() ); } @@ -1273,7 +1278,7 @@ void CBaseVSShader::DrawWorldBumpedSpecularLighting( int bumpmapVar, int envmapV if( g_pHardwareConfig->SupportsPixelShaders_1_4() ) { - lightmappedgeneric_bumpmappedenvmap_ps14_Static_Index vshIndex; + sdk_lightmappedgeneric_bumpmappedenvmap_ps14_Static_Index vshIndex; s_pShaderShadow->SetVertexShader( "LightmappedGeneric_BumpmappedEnvmap_ps14", vshIndex.GetIndex() ); int nPshIndex = bHasNormalMapAlphaEnvMapMask ? 1 : 0; @@ -1281,7 +1286,7 @@ void CBaseVSShader::DrawWorldBumpedSpecularLighting( int bumpmapVar, int envmapV } else { - lightmappedgeneric_bumpmappedenvmap_Static_Index vshIndex; + sdk_lightmappedgeneric_bumpmappedenvmap_Static_Index vshIndex; s_pShaderShadow->SetVertexShader( "LightmappedGeneric_BumpmappedEnvmap", vshIndex.GetIndex() ); int nPshIndex = bHasNormalMapAlphaEnvMapMask ? 1 : 0; @@ -1300,13 +1305,13 @@ void CBaseVSShader::DrawWorldBumpedSpecularLighting( int bumpmapVar, int envmapV { s_pShaderAPI->BindStandardTexture( SHADER_SAMPLER4, TEXTURE_NORMALIZATION_CUBEMAP ); - lightmappedgeneric_bumpmappedenvmap_ps14_Dynamic_Index vshIndex; + sdk_lightmappedgeneric_bumpmappedenvmap_ps14_Dynamic_Index vshIndex; vshIndex.SetDOWATERFOG( s_pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); s_pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() ); } else { - lightmappedgeneric_bumpmappedenvmap_Dynamic_Index vshIndex; + sdk_lightmappedgeneric_bumpmappedenvmap_Dynamic_Index vshIndex; vshIndex.SetDOWATERFOG( s_pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); s_pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() ); } @@ -1374,7 +1379,7 @@ void CBaseVSShader::DrawModelBumpedSpecularLighting( int bumpMapVar, int bumpMap if( g_pHardwareConfig->SupportsPixelShaders_1_4() ) { - vertexlitgeneric_envmappedbumpmap_nolighting_ps14_Static_Index vshIndex; + sdk_vertexlitgeneric_envmappedbumpmap_nolighting_ps14_Static_Index vshIndex; s_pShaderShadow->SetVertexShader( "VertexLitGeneric_EnvmappedBumpmap_NoLighting_ps14", vshIndex.GetIndex() ); if( bHasNormalMapAlphaEnvMapMask ) { @@ -1387,7 +1392,7 @@ void CBaseVSShader::DrawModelBumpedSpecularLighting( int bumpMapVar, int bumpMap } else { - vertexlitgeneric_envmappedbumpmap_nolighting_Static_Index vshIndex; + sdk_vertexlitgeneric_envmappedbumpmap_nolighting_Static_Index vshIndex; s_pShaderShadow->SetVertexShader( "VertexLitGeneric_EnvmappedBumpmap_NoLighting", vshIndex.GetIndex() ); // This version does not multiply by lighting // NOTE: We don't support multiplying by lighting for bumped specular stuff. @@ -1431,14 +1436,14 @@ void CBaseVSShader::DrawModelBumpedSpecularLighting( int bumpMapVar, int bumpMap if( g_pHardwareConfig->SupportsPixelShaders_1_4() ) { - vertexlitgeneric_envmappedbumpmap_nolighting_ps14_Dynamic_Index vshIndex; + sdk_vertexlitgeneric_envmappedbumpmap_nolighting_ps14_Dynamic_Index vshIndex; vshIndex.SetDOWATERFOG( s_pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); vshIndex.SetSKINNING( s_pShaderAPI->GetCurrentNumBones() > 0 ); s_pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() ); } else { - vertexlitgeneric_envmappedbumpmap_nolighting_Dynamic_Index vshIndex; + sdk_vertexlitgeneric_envmappedbumpmap_nolighting_Dynamic_Index vshIndex; vshIndex.SetDOWATERFOG( s_pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); vshIndex.SetSKINNING( s_pShaderAPI->GetCurrentNumBones() > 0 ); s_pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() ); @@ -1464,7 +1469,7 @@ void CBaseVSShader::DrawBaseTextureBlend( int baseTextureVar, int baseTextureTra s_pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 2, 0, 0 ); - lightmappedgeneric_basetextureblend_Static_Index vshIndex; + sdk_lightmappedgeneric_basetextureblend_Static_Index vshIndex; s_pShaderShadow->SetVertexShader( "lightmappedgeneric_basetextureblend", vshIndex.GetIndex() ); s_pShaderShadow->SetPixelShader( "lightmappedgeneric_basetextureblend", 0 ); @@ -1490,7 +1495,7 @@ void CBaseVSShader::DrawBaseTextureBlend( int baseTextureVar, int baseTextureTra SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, baseTextureTransformVar ); SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, baseTextureTransform2Var ); SetColorPixelShaderConstant( 0, colorVar, alphaVar ); - lightmappedgeneric_basetextureblend_Dynamic_Index vshIndex; + sdk_lightmappedgeneric_basetextureblend_Dynamic_Index vshIndex; vshIndex.SetDOWATERFOG( s_pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); s_pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() ); } @@ -1616,6 +1621,7 @@ void CBaseVSShader::SetFlashlightVertexShaderConstants( bool bBump, int bumpTran atten[1] = flashlightState.m_fLinearAtten; atten[2] = flashlightState.m_fQuadraticAtten; atten[3] = flashlightState.m_FarZ; + /*atten[3] = flashlightState.m_FarZAtten;*/ s_pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_5, atten, 1 ); if ( bDetail ) @@ -1688,7 +1694,7 @@ void CBaseVSShader::DrawFlashlight_dx80( IMaterialVar** params, IShaderDynamicAP if( bLightmappedGeneric ) { bool bUsingVertexColor = IS_FLAG_SET( MATERIAL_VAR_VERTEXCOLOR ); - lightmappedgeneric_flashlight_vs11_Static_Index vshIndex; + sdk_lightmappedgeneric_flashlight_vs11_Static_Index vshIndex; vshIndex.SetNORMALMAP( bBump ); vshIndex.SetWORLDVERTEXTRANSITION( bWorldVertexTransition ); vshIndex.SetVERTEXCOLOR( bUsingVertexColor ); @@ -1707,7 +1713,7 @@ void CBaseVSShader::DrawFlashlight_dx80( IMaterialVar** params, IShaderDynamicAP } else { - vertexlitgeneric_flashlight_vs11_Static_Index vshIndex; + sdk_vertexlitgeneric_flashlight_vs11_Static_Index vshIndex; vshIndex.SetTEETH( bTeeth ); pShaderShadow->SetVertexShader( "vertexlitgeneric_flashlight_vs11", vshIndex.GetIndex() ); @@ -1717,7 +1723,7 @@ void CBaseVSShader::DrawFlashlight_dx80( IMaterialVar** params, IShaderDynamicAP bool bNoCull = IS_FLAG_SET( MATERIAL_VAR_NOCULL ); - flashlight_ps11_Static_Index pshIndex; + sdk_flashlight_ps11_Static_Index pshIndex; pshIndex.SetNORMALMAP( bBump ); pshIndex.SetNOCULL( bNoCull ); pShaderShadow->SetPixelShader( "flashlight_ps11", pshIndex.GetIndex() ); @@ -1759,13 +1765,13 @@ void CBaseVSShader::DrawFlashlight_dx80( IMaterialVar** params, IShaderDynamicAP if( bLightmappedGeneric ) { - lightmappedgeneric_flashlight_vs11_Dynamic_Index vshIndex; + sdk_lightmappedgeneric_flashlight_vs11_Dynamic_Index vshIndex; vshIndex.SetDOWATERFOG( pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() ); } else { - vertexlitgeneric_flashlight_vs11_Dynamic_Index vshIndex; + sdk_vertexlitgeneric_flashlight_vs11_Dynamic_Index vshIndex; vshIndex.SetDOWATERFOG( pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); if( bTeeth ) @@ -1782,7 +1788,7 @@ void CBaseVSShader::DrawFlashlight_dx80( IMaterialVar** params, IShaderDynamicAP pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() ); } - flashlight_ps11_Dynamic_Index pshIndex; + sdk_flashlight_ps11_Dynamic_Index pshIndex; pShaderAPI->SetPixelShaderIndex( pshIndex.GetIndex() ); SetFlashlightVertexShaderConstants( bBump, bumpTransform, false, -1, true ); @@ -1870,12 +1876,24 @@ void CBaseVSShader::DrawFlashlight_dx90( IMaterialVar** params, IShaderDynamicAP if( vars.m_bLightmappedGeneric ) { - lightmappedgeneric_flashlight_vs20_Static_Index vshIndex; - vshIndex.SetWORLDVERTEXTRANSITION( vars.m_bWorldVertexTransition ); - vshIndex.SetNORMALMAP( vars.m_bBump ); - vshIndex.SetSEAMLESS( bSeamless ); - vshIndex.SetDETAIL( bDetail ); - pShaderShadow->SetVertexShader( "lightmappedgeneric_flashlight_vs20", vshIndex.GetIndex() ); + if ( g_pHardwareConfig->SupportsShaderModel_3_0() ) + { + sdk_lightmappedgeneric_flashlight_vs30_Static_Index vshIndex; + vshIndex.SetWORLDVERTEXTRANSITION( vars.m_bWorldVertexTransition ); + vshIndex.SetNORMALMAP( vars.m_bBump ); + vshIndex.SetSEAMLESS( bSeamless ); + vshIndex.SetDETAIL( bDetail ); + pShaderShadow->SetVertexShader( "sdk_lightmappedgeneric_flashlight_vs30", vshIndex.GetIndex() ); + } + else + { + sdk_lightmappedgeneric_flashlight_vs20_Static_Index vshIndex; + vshIndex.SetWORLDVERTEXTRANSITION( vars.m_bWorldVertexTransition ); + vshIndex.SetNORMALMAP( vars.m_bBump ); + vshIndex.SetSEAMLESS( bSeamless ); + vshIndex.SetDETAIL( bDetail ); + pShaderShadow->SetVertexShader( "sdk_lightmappedgeneric_flashlight_vs20", vshIndex.GetIndex() ); + } unsigned int flags = VERTEX_POSITION | VERTEX_NORMAL; if( vars.m_bBump ) @@ -1892,9 +1910,9 @@ void CBaseVSShader::DrawFlashlight_dx90( IMaterialVar** params, IShaderDynamicAP } else { - vertexlitgeneric_flashlight_vs11_Static_Index vshIndex; + sdk_vertexlitgeneric_flashlight_vs11_Static_Index vshIndex; vshIndex.SetTEETH( vars.m_bTeeth ); - pShaderShadow->SetVertexShader( "vertexlitgeneric_flashlight_vs11", vshIndex.GetIndex() ); + pShaderShadow->SetVertexShader( "sdk_vertexlitgeneric_flashlight_vs11", vshIndex.GetIndex() ); unsigned int flags = VERTEX_POSITION | VERTEX_NORMAL; int numTexCoords = 1; @@ -1906,11 +1924,12 @@ void CBaseVSShader::DrawFlashlight_dx90( IMaterialVar** params, IShaderDynamicAP { nBumpMapVariant = ( vars.m_bSSBump ) ? 2 : 1; } - if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + + if ( g_pHardwareConfig->SupportsShaderModel_3_0() && vars.m_bLightmappedGeneric ) { int nShadowFilterMode = g_pHardwareConfig->GetShadowFilterMode(); - flashlight_ps20b_Static_Index pshIndex; + sdk_flashlight_ps30_Static_Index pshIndex; pshIndex.SetNORMALMAP( nBumpMapVariant ); pshIndex.SetNORMALMAP2( bBump2 ); pshIndex.SetWORLDVERTEXTRANSITION( vars.m_bWorldVertexTransition ); @@ -1918,18 +1937,32 @@ void CBaseVSShader::DrawFlashlight_dx90( IMaterialVar** params, IShaderDynamicAP pshIndex.SetDETAILTEXTURE( bDetail ); pshIndex.SetDETAIL_BLEND_MODE( nDetailBlendMode ); pshIndex.SetFLASHLIGHTDEPTHFILTERMODE( nShadowFilterMode ); - pShaderShadow->SetPixelShader( "flashlight_ps20b", pshIndex.GetIndex() ); + pShaderShadow->SetPixelShader( "sdk_flashlight_ps30", pshIndex.GetIndex() ); } - else + else if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - flashlight_ps20_Static_Index pshIndex; + int nShadowFilterMode = g_pHardwareConfig->GetShadowFilterMode(); + + sdk_flashlight_ps20b_Static_Index pshIndex; pshIndex.SetNORMALMAP( nBumpMapVariant ); pshIndex.SetNORMALMAP2( bBump2 ); pshIndex.SetWORLDVERTEXTRANSITION( vars.m_bWorldVertexTransition ); pshIndex.SetSEAMLESS( bSeamless ); pshIndex.SetDETAILTEXTURE( bDetail ); pshIndex.SetDETAIL_BLEND_MODE( nDetailBlendMode ); - pShaderShadow->SetPixelShader( "flashlight_ps20", pshIndex.GetIndex() ); + pshIndex.SetFLASHLIGHTDEPTHFILTERMODE( nShadowFilterMode ); + pShaderShadow->SetPixelShader( "sdk_flashlight_ps20b", pshIndex.GetIndex() ); + } + else + { + sdk_flashlight_ps20_Static_Index pshIndex; + pshIndex.SetNORMALMAP( nBumpMapVariant ); + pshIndex.SetNORMALMAP2( bBump2 ); + pshIndex.SetWORLDVERTEXTRANSITION( vars.m_bWorldVertexTransition ); + pshIndex.SetSEAMLESS( bSeamless ); + pshIndex.SetDETAILTEXTURE( bDetail ); + pshIndex.SetDETAIL_BLEND_MODE( nDetailBlendMode ); + pShaderShadow->SetPixelShader( "sdk_flashlight_ps20", pshIndex.GetIndex() ); } FogToBlack(); } @@ -1939,6 +1972,20 @@ void CBaseVSShader::DrawFlashlight_dx90( IMaterialVar** params, IShaderDynamicAP ITexture *pFlashlightDepthTexture; FlashlightState_t flashlightState = pShaderAPI->GetFlashlightStateEx( worldToTexture, &pFlashlightDepthTexture ); + if ( pFlashlightDepthTexture == NULL ) + { + const int iFlashlightShadowIndex = ( flashlightState.m_nShadowQuality >> 16 ) - 1; + + if ( iFlashlightShadowIndex >= 0 + && iFlashlightShadowIndex <= ( INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_LAST - INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_FIRST ) ) + { + pFlashlightDepthTexture = (ITexture*)pShaderAPI->GetIntRenderingParameter( INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_FIRST + iFlashlightShadowIndex ); + } + } + + float flFlashlightPos[4] = { XYZ( flashlightState.m_vecLightOrigin ) }; + pShaderAPI->SetPixelShaderConstant( PSREG_FRESNEL_SPEC_PARAMS, flFlashlightPos ); + SetFlashLightColorFromState( flashlightState, pShaderAPI ); BindTexture( SHADER_SAMPLER0, flashlightState.m_pSpotlightTexture, flashlightState.m_nSpotlightTextureFrame ); @@ -2002,9 +2049,19 @@ void CBaseVSShader::DrawFlashlight_dx90( IMaterialVar** params, IShaderDynamicAP if( vars.m_bLightmappedGeneric ) { - DECLARE_DYNAMIC_VERTEX_SHADER( lightmappedgeneric_flashlight_vs20 ); - SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); - SET_DYNAMIC_VERTEX_SHADER( lightmappedgeneric_flashlight_vs20 ); + if ( g_pHardwareConfig->SupportsShaderModel_3_0() ) + { + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_lightmappedgeneric_flashlight_vs30 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); + SET_DYNAMIC_VERTEX_SHADER( sdk_lightmappedgeneric_flashlight_vs30 ); + } + else + { + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_lightmappedgeneric_flashlight_vs20 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); + SET_DYNAMIC_VERTEX_SHADER( sdk_lightmappedgeneric_flashlight_vs20 ); + } + if ( bSeamless ) { float const0[4]={ vars.m_fSeamlessScale,0,0,0}; @@ -2030,7 +2087,7 @@ void CBaseVSShader::DrawFlashlight_dx90( IMaterialVar** params, IShaderDynamicAP } else { - vertexlitgeneric_flashlight_vs11_Dynamic_Index vshIndex; + sdk_vertexlitgeneric_flashlight_vs11_Dynamic_Index vshIndex; vshIndex.SetDOWATERFOG( pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); vshIndex.SetSKINNING( pShaderAPI->GetCurrentNumBones() > 0 ); pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() ); @@ -2053,18 +2110,25 @@ void CBaseVSShader::DrawFlashlight_dx90( IMaterialVar** params, IShaderDynamicAP vEyePos_SpecExponent[3] = 0.0f; pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, vEyePos_SpecExponent, 1 ); - if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + if ( g_pHardwareConfig->SupportsShaderModel_3_0() ) { - DECLARE_DYNAMIC_PIXEL_SHADER( flashlight_ps20b ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_flashlight_ps30 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, flashlightState.m_bEnableShadows && ( pFlashlightDepthTexture != NULL ) ); - SET_DYNAMIC_PIXEL_SHADER( flashlight_ps20b ); + SET_DYNAMIC_PIXEL_SHADER( sdk_flashlight_ps30 ); + } + else if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_flashlight_ps20b ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, flashlightState.m_bEnableShadows && ( pFlashlightDepthTexture != NULL ) ); + SET_DYNAMIC_PIXEL_SHADER( sdk_flashlight_ps20b ); } else { - DECLARE_DYNAMIC_PIXEL_SHADER( flashlight_ps20 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_flashlight_ps20 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - SET_DYNAMIC_PIXEL_SHADER( flashlight_ps20 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_flashlight_ps20 ); } float atten[4]; // Set the flashlight attenuation factors @@ -2072,6 +2136,7 @@ void CBaseVSShader::DrawFlashlight_dx90( IMaterialVar** params, IShaderDynamicAP atten[1] = flashlightState.m_fLinearAtten; atten[2] = flashlightState.m_fQuadraticAtten; atten[3] = flashlightState.m_FarZ; + /*atten[3] = flashlightState.m_FarZAtten;*/ s_pShaderAPI->SetPixelShaderConstant( PSREG_FLASHLIGHT_ATTENUATION, atten, 1 ); SetFlashlightVertexShaderConstants( vars.m_bBump, vars.m_nBumpTransform, bDetail, vars.m_nDetailScale, bSeamless ? false : true ); diff --git a/sp/src/materialsystem/stdshaders/BaseVSShader.h b/sp/src/materialsystem/stdshaders/BaseVSShader.h index 1ba6cc43..69c06f4e 100644 --- a/sp/src/materialsystem/stdshaders/BaseVSShader.h +++ b/sp/src/materialsystem/stdshaders/BaseVSShader.h @@ -296,6 +296,9 @@ public: int m_nFlashlightTextureFrameVar; int m_nBaseTexture2Var; int m_nBaseTexture2FrameVar; +#ifdef MAPBASE + int m_nBaseTexture2TransformVar; +#endif int m_nBumpmap2Var; int m_nBumpmap2Frame; int m_nBump2Transform; @@ -336,6 +339,8 @@ private: }; +extern ConVar r_flashlightbrightness; + FORCEINLINE void SetFlashLightColorFromState( FlashlightState_t const &state, IShaderDynamicAPI *pShaderAPI, int nPSRegister=28, bool bFlashlightNoLambert=false ) { // Old code @@ -348,8 +353,7 @@ FORCEINLINE void SetFlashLightColorFromState( FlashlightState_t const &state, IS // flToneMapScale = 1.0f; //float flFlashlightScale = 1.0f / flToneMapScale; - // Force flashlight to 25% bright always - float flFlashlightScale = 0.25f; + float flFlashlightScale = r_flashlightbrightness.GetFloat(); if ( !g_pHardwareConfig->GetHDREnabled() ) { @@ -363,6 +367,9 @@ FORCEINLINE void SetFlashLightColorFromState( FlashlightState_t const &state, IS flFlashlightScale *= 2.5f; // Magic number that works well on the NVIDIA 8800 } + // INSOLENCE: This causes very odd projected texture flickering bugs, so it's commented out for now + /*flFlashlightScale *= state.m_fBrightnessScale;*/ + // Generate pixel shader constant float const *pFlashlightColor = state.m_Color; float vPsConst[4] = { flFlashlightScale * pFlashlightColor[0], flFlashlightScale * pFlashlightColor[1], flFlashlightScale * pFlashlightColor[2], pFlashlightColor[3] }; @@ -385,8 +392,11 @@ FORCEINLINE float ShadowAttenFromState( FlashlightState_t const &state ) FORCEINLINE float ShadowFilterFromState( FlashlightState_t const &state ) { - // We developed shadow maps at 1024, so we expect the penumbra size to have been tuned relative to that - return state.m_flShadowFilterSize / 1024.0f; + //// We developed shadow maps at 1024, so we expect the penumbra size to have been tuned relative to that + //return state.m_flShadowFilterSize / 1024.0f; + + // INSOLENCE: Get the shadow map resolution from the same place we get the shadow filter size + return state.m_flShadowFilterSize / state.m_flShadowMapResolution; } diff --git a/sp/src/materialsystem/stdshaders/SDK_BlurFilter_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_BlurFilter_ps2x.fxc new file mode 100644 index 00000000..bfd082b3 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_BlurFilter_ps2x.fxc @@ -0,0 +1,91 @@ +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] +// STATIC: "APPROX_SRGB_ADAPTER" "0..1" [ps20b] [PC] + +#define HDRTYPE HDR_TYPE_NONE +#include "common_ps_fxc.h" + +sampler TexSampler : register( s0 ); + +struct PS_INPUT +{ + float2 coordTap0 : TEXCOORD0; + float2 coordTap1 : TEXCOORD1; + float2 coordTap2 : TEXCOORD2; + float2 coordTap3 : TEXCOORD3; + float2 coordTap1Neg : TEXCOORD4; + float2 coordTap2Neg : TEXCOORD5; + float2 coordTap3Neg : TEXCOORD6; +}; + +float2 psTapOffs[3] : register( c0 ); +float3 scale_factor : register( c3 ); + +float4 SampleTexture( sampler texSampler, float2 uv ) +{ + float4 cSample = tex2D( texSampler, uv ); + + #if ( APPROX_SRGB_ADAPTER ) + { + cSample.rgb = max( cSample.rgb, float3( 0.00001f, 0.00001f, 0.00001f ) ); // rsqrt doesn't like inputs of zero + + float3 ooSQRT; // + ooSQRT.r = rsqrt( cSample.r ); // + ooSQRT.g = rsqrt( cSample.g ); // Approximate linear-to-sRGB conversion + ooSQRT.b = rsqrt( cSample.b ); // + cSample.rgb *= ooSQRT.rgb; // + } + #endif + + return cSample; +} + +float4 main( PS_INPUT i ) : COLOR +{ + float4 s0, s1, s2, s3, s4, s5, s6, color; + + // Sample taps with coordinates from VS + s0 = SampleTexture( TexSampler, i.coordTap0 ); + s1 = SampleTexture( TexSampler, i.coordTap1 ); + s2 = SampleTexture( TexSampler, i.coordTap2 ); + s3 = SampleTexture( TexSampler, i.coordTap3 ); + s4 = SampleTexture( TexSampler, i.coordTap1Neg ); + s5 = SampleTexture( TexSampler, i.coordTap2Neg ); + s6 = SampleTexture( TexSampler, i.coordTap3Neg ); + + color = s0 * 0.2013f; + color += ( s1 + s4 ) * 0.2185f; + color += ( s2 + s5 ) * 0.0821f; + color += ( s3 + s6 ) * 0.0461f; + + // Compute tex coords for other taps + float2 coordTap4 = i.coordTap0 + psTapOffs[0]; + float2 coordTap5 = i.coordTap0 + psTapOffs[1]; + float2 coordTap6 = i.coordTap0 + psTapOffs[2]; + float2 coordTap4Neg = i.coordTap0 - psTapOffs[0]; + float2 coordTap5Neg = i.coordTap0 - psTapOffs[1]; + float2 coordTap6Neg = i.coordTap0 - psTapOffs[2]; + + // Sample the taps + s1 = SampleTexture( TexSampler, coordTap4 ); + s2 = SampleTexture( TexSampler, coordTap5 ); + s3 = SampleTexture( TexSampler, coordTap6 ); + s4 = SampleTexture( TexSampler, coordTap4Neg ); + s5 = SampleTexture( TexSampler, coordTap5Neg ); + s6 = SampleTexture( TexSampler, coordTap6Neg ); + + color += ( s1 + s4 ) * 0.0262f; + color += ( s2 + s5 ) * 0.0162f; + color += ( s3 + s6 ) * 0.0102f; + color.xyz*=scale_factor.xyz; + + #if ( APPROX_SRGB_ADAPTER ) + { + color.xyz *= color.xyz; // Approximate sRGB-to-linear conversion + } + #endif + + return color; + //return FinalOutput( color, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE ); +} + diff --git a/sp/src/materialsystem/stdshaders/SDK_Eyes_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_Eyes_vs20.fxc new file mode 100644 index 00000000..b055eed7 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_Eyes_vs20.fxc @@ -0,0 +1,145 @@ +//======= Copyright © 1996-2006, Valve Corporation, All rights reserved. ====== +// $SHADER_SPECIFIC_CONST_0 = eyeball origin +// $SHADER_SPECIFIC_CONST_1 = eyeball up * 0.5 +// $SHADER_SPECIFIC_CONST_2 = iris projection U +// $SHADER_SPECIFIC_CONST_3 = iris projection V +// $SHADER_SPECIFIC_CONST_4 = glint projection U +// $SHADER_SPECIFIC_CONST_5 = glint projection V +//============================================================================= + +// STATIC: "INTRO" "0..1" +// STATIC: "HALFLAMBERT" "0..1" +// STATIC: "USE_STATIC_CONTROL_FLOW" "0..1" [vs20] + +// DYNAMIC: "COMPRESSED_VERTS" "0..1" +// DYNAMIC: "SKINNING" "0..1" +// DYNAMIC: "DOWATERFOG" "0..1" +// DYNAMIC: "DYNAMIC_LIGHT" "0..1" +// DYNAMIC: "STATIC_LIGHT" "0..1" +// DYNAMIC: "MORPHING" "0..1" [vs30] +// DYNAMIC: "NUM_LIGHTS" "0..2" [vs20] + +// If using static control flow on Direct3D, we should use the NUM_LIGHTS=0 combo +// SKIP: $USE_STATIC_CONTROL_FLOW && ( $NUM_LIGHTS > 0 ) [vs20] + +#include "vortwarp_vs20_helper.h" + +static const int g_bSkinning = SKINNING ? true : false; +static const int g_FogType = DOWATERFOG; +static const bool g_bHalfLambert = HALFLAMBERT ? true : false; + +const float3 cEyeOrigin : register( SHADER_SPECIFIC_CONST_0 ); +const float3 cHalfEyeballUp : register( SHADER_SPECIFIC_CONST_1 ); +const float4 cIrisProjectionU : register( SHADER_SPECIFIC_CONST_2 ); +const float4 cIrisProjectionV : register( SHADER_SPECIFIC_CONST_3 ); +const float4 cGlintProjectionU : register( SHADER_SPECIFIC_CONST_4 ); +const float4 cGlintProjectionV : register( SHADER_SPECIFIC_CONST_5 ); +#if INTRO +const float4 const4 : register( SHADER_SPECIFIC_CONST_6 ); +#define g_Time const4.w +#define modelOrigin const4.xyz +#endif + +#ifdef SHADER_MODEL_VS_3_0 +// NOTE: cMorphTargetTextureDim.xy = target dimensions, +// cMorphTargetTextureDim.z = 4tuples/morph +const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_7 ); +const float4 cMorphSubrect : register( SHADER_SPECIFIC_CONST_8 ); + +sampler2D morphSampler : register( D3DVERTEXTEXTURESAMPLER0, s0 ); +#endif + +struct VS_INPUT +{ + float4 vPos : POSITION; // Position + float4 vBoneWeights : BLENDWEIGHT; // Skin weights + float4 vBoneIndices : BLENDINDICES; // Skin indices + float4 vTexCoord0 : TEXCOORD0; // Base (sclera) texture coordinates + + float3 vPosFlex : POSITION1; // Delta positions for flexing +#ifdef SHADER_MODEL_VS_3_0 + float vVertexID : POSITION2; +#endif +}; + +struct VS_OUTPUT +{ + float4 projPos : POSITION; // Projection-space position +#if !defined( _X360 ) + float fog : FOG; // Fixed-function fog factor +#endif + float2 baseTC : TEXCOORD0; // Base texture coordinate + float2 irisTC : TEXCOORD1; // Iris texture coordinates + float2 glintTC : TEXCOORD2; // Glint texture coordinates + float3 vColor : TEXCOORD3; // Vertex-lit color + + float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog + +}; + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o; + + bool bDynamicLight = DYNAMIC_LIGHT ? true : false; + bool bStaticLight = STATIC_LIGHT ? true : false; + + float4 vPosition = v.vPos; + float3 dummy = v.vPos.xyz; // dummy values that can't be optimized out + +#if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING + ApplyMorph( v.vPosFlex, vPosition.xyz ); +#else + ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, v.vVertexID, dummy, vPosition.xyz ); +#endif + + // Transform the position and dummy normal (not doing the dummy normal causes invariance issues with the flashlight!) + float3 worldNormal, worldPos; + SkinPositionAndNormal( + g_bSkinning, + vPosition, dummy, + v.vBoneWeights, v.vBoneIndices, + worldPos, worldNormal ); + +#if INTRO + WorldSpaceVertexProcess( g_Time, modelOrigin, worldPos, dummy, dummy, dummy ); +#endif + + // Transform into projection space + float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj ); + o.projPos = vProjPos; + vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ ); + o.worldPos_projPosZ = float4( worldPos.xyz, vProjPos.z ); + +#if !defined( _X360 ) + // Set fixed-function fog factor + o.fog = CalcFog( worldPos, vProjPos, g_FogType ); +#endif + + // Normal = (Pos - Eye origin) - just step on dummy normal created above + worldNormal = worldPos - cEyeOrigin; + + // Normal -= 0.5f * (Normal dot Eye Up) * Eye Up + float normalDotUp = -dot( worldNormal, cHalfEyeballUp) * 0.5f; + worldNormal = normalize(normalDotUp * cHalfEyeballUp + worldNormal); + + // Vertex lighting +#if ( USE_STATIC_CONTROL_FLOW || defined ( SHADER_MODEL_VS_3_0 ) ) + o.vColor = DoLighting( worldPos, worldNormal, float3(0.0f, 0.0f, 0.0f), bStaticLight, bDynamicLight, g_bHalfLambert ); +#else + o.vColor = DoLightingUnrolled( worldPos, worldNormal, float3(0.0f, 0.0f, 0.0f), bStaticLight, bDynamicLight, g_bHalfLambert, NUM_LIGHTS ); +#endif + + // Texture 0 is the base texture + // Texture 1 is a planar projection used for the iris + // Texture 2 is a planar projection used for the glint + o.baseTC = v.vTexCoord0; + o.irisTC.x = dot( cIrisProjectionU, float4(worldPos, 1) ); + o.irisTC.y = dot( cIrisProjectionV, float4(worldPos, 1) ); + o.glintTC.x = dot( cGlintProjectionU, float4(worldPos, 1) ); + o.glintTC.y = dot( cGlintProjectionV, float4(worldPos, 1) ); + + return o; +} + + diff --git a/sp/src/materialsystem/stdshaders/SDK_Refract_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_Refract_vs20.fxc new file mode 100644 index 00000000..698dd192 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_Refract_vs20.fxc @@ -0,0 +1,140 @@ +//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======= +// +// Purpose: +// +//============================================================================= + +// STATIC: "MODEL" "0..1" +// STATIC: "COLORMODULATE" "0..1" + +// DYNAMIC: "COMPRESSED_VERTS" "0..1" +// DYNAMIC: "SKINNING" "0..1" + +#include "common_vs_fxc.h" + +static const bool g_bSkinning = SKINNING ? true : false; +static const bool g_bModel = MODEL ? true : false; + +const float4 cBumpTexCoordTransform[4] : register( SHADER_SPECIFIC_CONST_1 ); + +const float g_flTime : register( SHADER_SPECIFIC_CONST_5 ); + +struct VS_INPUT +{ + float4 vPos : POSITION; + float4 vBoneWeights : BLENDWEIGHT; + float4 vBoneIndices : BLENDINDICES; + float4 vNormal : NORMAL; + float4 vBaseTexCoord : TEXCOORD0; +#if !MODEL + float3 vTangentS : TANGENT; + float3 vTangentT : BINORMAL0; +#else + float4 vUserData : TANGENT; +#endif +#if COLORMODULATE + float4 vColor : COLOR0; +#endif +}; + +struct VS_OUTPUT +{ + float4 vProjPos_POSITION : POSITION; +#if !defined( _X360 ) + float vFog : FOG; +#endif + float4 vBumpTexCoord : TEXCOORD0; + float3 vTangentEyeVect : TEXCOORD1; + float3 vWorldNormal : TEXCOORD2; + float3 vWorldTangent : TEXCOORD3; + float3 vWorldBinormal : TEXCOORD4; + float3 vRefractXYW : TEXCOORD5; + float3 vWorldViewVector : TEXCOORD6; +#if COLORMODULATE + float4 vColor : COLOR0; +#endif + float4 fogFactorW : COLOR1; + + float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog +}; + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + +#if COLORMODULATE + o.vColor = v.vColor; +#endif + + float3 worldNormal, worldPos, worldTangentS, worldTangentT; + + float3 vObjNormal; +#if MODEL + float4 vObjTangent; + DecompressVertex_NormalTangent( v.vNormal, v.vUserData, vObjNormal, vObjTangent ); + + SkinPositionNormalAndTangentSpace( + g_bSkinning, + v.vPos, vObjNormal, vObjTangent, + v.vBoneWeights, v.vBoneIndices, + worldPos, worldNormal, worldTangentS, worldTangentT ); +#else + DecompressVertex_Normal( v.vNormal, vObjNormal ); + + worldPos = mul( v.vPos, cModel[0] ); + worldTangentS = mul( v.vTangentS, ( const float3x3 )cModel[0] ); + worldTangentT = mul( v.vTangentT, ( const float3x3 )cModel[0] ); + worldNormal = mul( vObjNormal, ( float3x3 )cModel[0] ); +#endif + + // World normal + o.vWorldNormal.xyz = normalize( worldNormal.xyz ); + + // Projected position + float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj ); + o.vProjPos_POSITION = vProjPos; + vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ ); + o.worldPos_projPosZ = float4( worldPos.xyz, vProjPos.z ); + //o.projNormal.xyz = mul( worldNormal, cViewProj ); + + // Map projected position to the refraction texture + float2 vRefractPos; + vRefractPos.x = vProjPos.x; + vRefractPos.y = -vProjPos.y; // invert Y + vRefractPos = (vRefractPos + vProjPos.w) * 0.5f; + + // Refraction transform + o.vRefractXYW = float3(vRefractPos.x, vRefractPos.y, vProjPos.w); + + // Compute fog based on the position + float3 vWorldPos = mul( v.vPos, cModel[0] ); + o.fogFactorW = CalcFog( vWorldPos, vProjPos, FOGTYPE_RANGE ); +#if !defined( _X360 ) + o.vFog = o.fogFactorW; +#endif + + // Eye vector + float3 vWorldEyeVect = normalize( cEyePos - vWorldPos ); + o.vWorldViewVector.xyz = -vWorldEyeVect.xyz; + + // Transform to the tangent space + o.vTangentEyeVect.x = dot( vWorldEyeVect, worldTangentS ); + o.vTangentEyeVect.y = dot( vWorldEyeVect, worldTangentT ); + o.vTangentEyeVect.z = dot( vWorldEyeVect, worldNormal ); + + // Tranform bump coordinates + o.vBumpTexCoord.x = dot( v.vBaseTexCoord, cBumpTexCoordTransform[0] ); + o.vBumpTexCoord.y = dot( v.vBaseTexCoord, cBumpTexCoordTransform[1] ); + + // Tranform bump coordinates (note wz, not zw) + o.vBumpTexCoord.w = dot( v.vBaseTexCoord, cBumpTexCoordTransform[2] ); + o.vBumpTexCoord.z = dot( v.vBaseTexCoord, cBumpTexCoordTransform[3] ); + + + // Tangent space transform + o.vWorldNormal.xyz = normalize( worldNormal.xyz ); + o.vWorldTangent.xyz = worldTangentS.xyz; + o.vWorldBinormal.xyz = worldTangentT.xyz; + + return o; +} diff --git a/sp/src/materialsystem/stdshaders/SDK_WaterCheap_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_WaterCheap_ps2x.fxc new file mode 100644 index 00000000..34b9bac3 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_WaterCheap_ps2x.fxc @@ -0,0 +1,151 @@ +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] +// STATIC: "MULTITEXTURE" "0..1" +// STATIC: "FRESNEL" "0..1" +// STATIC: "BLEND" "0..1" +// STATIC: "REFRACTALPHA" "0..1" +// STATIC: "HDRTYPE" "0..2" +// STATIC: "NORMAL_DECODE_MODE" "0..0" [XBOX] +// STATIC: "NORMAL_DECODE_MODE" "0..0" [PC] + +// DYNAMIC: "HDRENABLED" "0..1" +// DYNAMIC: "PIXELFOGTYPE" "0..1" + +#include "common_ps_fxc.h" + +const HALF3 g_WaterFogColor : register( c0 ); +const HALF4 g_CheapWaterParams : register( c1 ); +const HALF4 g_ReflectTint : register( c2 ); +const float4 g_PixelFogParams : register( c3 ); +const float3 g_EyePos : register( c4 ); + +#define g_CheapWaterStart g_CheapWaterParams.x +#define g_CheapWaterEnd g_CheapWaterParams.y +#define g_CheapWaterDeltaRecip g_CheapWaterParams.z +#define g_CheapWaterStartDivDelta g_CheapWaterParams.w + +sampler EnvmapSampler : register( s0 ); +sampler NormalMapSampler : register( s1 ); +#if REFRACTALPHA +sampler RefractSampler : register( s2 ); +#endif +sampler NormalizeSampler : register( s6 ); + +struct PS_INPUT +{ + float2 normalMapTexCoord : TEXCOORD0; + HALF3 worldSpaceEyeVect : TEXCOORD1; + HALF3x3 tangentSpaceTranspose : TEXCOORD2; + float4 vRefract_W_ProjZ : TEXCOORD5; + +#if MULTITEXTURE + float4 vExtraBumpTexCoord : TEXCOORD6; +#endif + float3 vWorldPos : TEXCOORD7; + float4 fogFactorW : COLOR1; +}; + +float4 main( PS_INPUT i ) : COLOR +{ + bool bBlend = BLEND ? true : false; + +#if MULTITEXTURE + float3 vNormal = tex2D( NormalMapSampler, i.normalMapTexCoord ); + float3 vNormal1 = tex2D( NormalMapSampler, i.vExtraBumpTexCoord.xy ); + float3 vNormal2 = tex2D( NormalMapSampler, i.vExtraBumpTexCoord.zw ); + vNormal = 0.33 * ( vNormal + vNormal1 + vNormal2 ); + +#if ( NORMAL_DECODE_MODE == NORM_DECODE_ATI2N ) + vNormal.xy = vNormal.xy * 2.0f - 1.0f; + vNormal.z = sqrt( 1.0f - dot(vNormal.xy, vNormal.xy) ); +#else + vNormal = 2.0 * vNormal - 1.0; +#endif + +#else + float3 vNormal = DecompressNormal( NormalMapSampler, i.normalMapTexCoord, NORMAL_DECODE_MODE ); +#endif + + HALF3 worldSpaceNormal = mul( vNormal, i.tangentSpaceTranspose ); + HALF3 worldSpaceEye; + + HALF flWorldSpaceDist = 1.0f; + +#ifdef NV3X + // for some reason, fxc doesn't convert length( half3 v ) into all _pp opcodes. + if (bBlend) + { + worldSpaceEye = i.worldSpaceEyeVect; + HALF worldSpaceDistSqr = dot( worldSpaceEye, worldSpaceEye ); + HALF rcpWorldSpaceDist = rsqrt( worldSpaceDistSqr ); + worldSpaceEye *= rcpWorldSpaceDist; + flWorldSpaceDist = worldSpaceDistSqr * rcpWorldSpaceDist; + } + else + { + worldSpaceEye = NormalizeWithCubemap( NormalizeSampler, i.worldSpaceEyeVect ); + } +#else // !NV3X + if (bBlend) + { + worldSpaceEye = i.worldSpaceEyeVect; + flWorldSpaceDist = length( worldSpaceEye ); + worldSpaceEye /= flWorldSpaceDist; + } + else + { + worldSpaceEye = NormalizeWithCubemap( NormalizeSampler, i.worldSpaceEyeVect ); + } +#endif + + HALF3 reflectVect = CalcReflectionVectorUnnormalized( worldSpaceNormal, worldSpaceEye ); + HALF3 specularLighting = ENV_MAP_SCALE * texCUBE( EnvmapSampler, reflectVect ); + specularLighting *= g_ReflectTint; + +#if FRESNEL + // FIXME: It's unclear that we want to do this for cheap water + // but the code did this previously and I didn't want to change it + HALF flDotResult = dot( worldSpaceEye, worldSpaceNormal ); + flDotResult = 1.0f - max( 0.0f, flDotResult ); + + HALF flFresnelFactor = flDotResult * flDotResult; + flFresnelFactor *= flFresnelFactor; + flFresnelFactor *= flDotResult; +#else + HALF flFresnelFactor = g_ReflectTint.a; +#endif + + HALF flAlpha; + if (bBlend) + { + HALF flReflectAmount = saturate( flWorldSpaceDist * g_CheapWaterDeltaRecip - g_CheapWaterStartDivDelta ); + flAlpha = saturate( flFresnelFactor + flReflectAmount ); + +#if REFRACTALPHA + // Perform division by W only once + float ooW = 1.0f / i.vRefract_W_ProjZ.z; + float2 unwarpedRefractTexCoord = i.vRefract_W_ProjZ * ooW; + float fogDepthValue = tex2D( RefractSampler, unwarpedRefractTexCoord ).a; + // Fade on the border between the water and land. + flAlpha *= saturate( ( fogDepthValue - .05f ) * 20.0f ); +#endif + } + else + { + flAlpha = 1.0f; +#if HDRTYPE == 0 || HDRENABLED == 0 + specularLighting = lerp( g_WaterFogColor, specularLighting, flFresnelFactor ); +#else + specularLighting = lerp( GammaToLinear( g_WaterFogColor ), specularLighting, flFresnelFactor ); +#endif + } + + // multiply the color by alpha.since we are using alpha blending to blend against dest alpha for borders. +#if (PIXELFOGTYPE == PIXEL_FOG_TYPE_RANGE) + float fogFactor = CalcRangeFogFactorNonFixedFunction( i.vWorldPos, g_EyePos, g_PixelFogParams.z, g_PixelFogParams.x, g_PixelFogParams.w ); +#else + float fogFactor = 0; +#endif + + return FinalOutput( float4( specularLighting, flAlpha ), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR ); +} diff --git a/sp/src/materialsystem/stdshaders/SDK_WaterCheap_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_WaterCheap_vs20.fxc new file mode 100644 index 00000000..4b9086b3 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_WaterCheap_vs20.fxc @@ -0,0 +1,87 @@ +// STATIC: "BLEND" "0..1" +#include "common_vs_fxc.h" + +struct VS_INPUT +{ + float4 vPos : POSITION; + float4 vNormal : NORMAL; + float2 vNormalMapCoord : TEXCOORD0; + float3 vTangentS : TANGENT; + float3 vTangentT : BINORMAL; +}; + +struct VS_OUTPUT +{ + float4 projPos : POSITION; +#if !defined( _X360 ) + float fog : FOG; +#endif + float2 normalMapTexCoord : TEXCOORD0; + float3 worldVertToEyeVector : TEXCOORD1; + float3x3 tangentSpaceTranspose : TEXCOORD2; + float4 vRefract_W_ProjZ : TEXCOORD5; + float4 vExtraBumpTexCoord : TEXCOORD6; + float3 vWorldPos : TEXCOORD7; + float4 fogFactorW : COLOR1; +}; + +const float4 cNormalMapTransform[2] : register( SHADER_SPECIFIC_CONST_0 ); +const float4 TexOffsets : register( SHADER_SPECIFIC_CONST_3 ); + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + + float3 vObjNormal; + DecompressVertex_Normal( v.vNormal, vObjNormal ); + + float4 projPos; + float3 worldPos; + + projPos = mul( v.vPos, cModelViewProj ); + o.projPos = projPos; + +#if BLEND + // Map projected position to the reflection texture + o.vRefract_W_ProjZ.x = projPos.x; + o.vRefract_W_ProjZ.y = -projPos.y; // invert Y + o.vRefract_W_ProjZ.xy = (o.vRefract_W_ProjZ + projPos.w) * 0.5f; + o.vRefract_W_ProjZ.z = projPos.w; +#endif + + o.vRefract_W_ProjZ.w = projPos.z; + + worldPos = mul( v.vPos, cModel[0] ); + + float3 worldTangentS = mul( v.vTangentS, ( const float3x3 )cModel[0] ); + float3 worldTangentT = mul( v.vTangentT, ( const float3x3 )cModel[0] ); + float3 worldNormal = mul( vObjNormal, ( float3x3 )cModel[0] ); + o.tangentSpaceTranspose[0] = worldTangentS; + o.tangentSpaceTranspose[1] = worldTangentT; + o.tangentSpaceTranspose[2] = worldNormal; + + float3 worldVertToEyeVector = VSHADER_VECT_SCALE * (cEyePos - worldPos); + o.worldVertToEyeVector = worldVertToEyeVector; + + // FIXME: need to add a normalMapTransform to all of the water shaders. + //o.normalMapTexCoord.x = dot( v.vNormalMapCoord, cNormalMapTransform[0] ) + cNormalMapTransform[0].w; + //o.normalMapTexCoord.y = dot( v.vNormalMapCoord, cNormalMapTransform[1] ) + cNormalMapTransform[1].w; + o.normalMapTexCoord = v.vNormalMapCoord; + + float f45x=v.vNormalMapCoord.x+v.vNormalMapCoord.y; + float f45y=v.vNormalMapCoord.y-v.vNormalMapCoord.x; + o.vExtraBumpTexCoord.x=f45x*0.1+TexOffsets.x; + o.vExtraBumpTexCoord.y=f45y*0.1+TexOffsets.y; + o.vExtraBumpTexCoord.z=v.vNormalMapCoord.y*0.45+TexOffsets.z; + o.vExtraBumpTexCoord.w=v.vNormalMapCoord.x*0.45+TexOffsets.w; + + o.fogFactorW = CalcFog( worldPos, projPos, FOGTYPE_RANGE ); +#if !defined( _X360 ) + o.fog = o.fogFactorW; +#endif + o.vWorldPos = worldPos; + + return o; +} + + diff --git a/sp/src/materialsystem/stdshaders/SDK_Water_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_Water_vs20.fxc new file mode 100644 index 00000000..bee4aa50 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_Water_vs20.fxc @@ -0,0 +1,118 @@ +// STATIC: "BASETEXTURE" "0..1" +// STATIC: "MULTITEXTURE" "0..1" + +// SKIP: $MULTITEXTURE && $BASETEXTURE + +#include "common_vs_fxc.h" + +const float4 cBumpTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_1 ); +const float4 TexOffsets : register( SHADER_SPECIFIC_CONST_3 ); + +struct VS_INPUT +{ + float4 vPos : POSITION; + float4 vNormal : NORMAL; + float4 vBaseTexCoord : TEXCOORD0; + float2 vLightmapTexCoord : TEXCOORD1; + float2 vLightmapTexCoordOffset : TEXCOORD2; + float3 vTangentS : TANGENT; + float3 vTangentT : BINORMAL0; +}; + +struct VS_OUTPUT +{ + float4 vProjPos_POSITION : POSITION; +#if !defined( _X360 ) + float vFog : FOG; +#endif + float2 vBumpTexCoord : TEXCOORD0; + float3 vTangentEyeVect : TEXCOORD1; + float4 vReflectXY_vRefractYX : TEXCOORD2; + float4 vWorldPos_projPosW : TEXCOORD3; + float4 vProjPos : TEXCOORD4; + float screenCoord : TEXCOORD5; +#if MULTITEXTURE + float4 vExtraBumpTexCoord : TEXCOORD6; +#endif +#if BASETEXTURE + HALF4 lightmapTexCoord1And2 : TEXCOORD6; + HALF4 lightmapTexCoord3 : TEXCOORD7; +#endif + float4 fogFactorW : COLOR1; +}; + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + + float3 vObjNormal; + DecompressVertex_Normal( v.vNormal, vObjNormal ); + + // Projected position + float4 vProjPos = mul( v.vPos, cModelViewProj ); + o.vProjPos = o.vProjPos_POSITION = vProjPos; + + // Project tangent basis + float2 vProjTangentS = mul( v.vTangentS, cViewProj ); + float2 vProjTangentT = mul( v.vTangentT, cViewProj ); + + // Map projected position to the reflection texture + float2 vReflectPos; + vReflectPos = (vProjPos.xy + vProjPos.w) * 0.5f; + + // Map projected position to the refraction texture + float2 vRefractPos; + vRefractPos.x = vProjPos.x; + vRefractPos.y = -vProjPos.y; // invert Y + vRefractPos = (vRefractPos + vProjPos.w) * 0.5f; + + // Reflection transform + o.vReflectXY_vRefractYX = float4( vReflectPos.x, vReflectPos.y, vRefractPos.y, vRefractPos.x ); + o.vWorldPos_projPosW.w = vProjPos.w; + + o.screenCoord = vProjPos.x; + + // Compute fog based on the position + float3 vWorldPos = mul( v.vPos, cModel[0] ); + o.fogFactorW = CalcFog( vWorldPos, vProjPos, FOGTYPE_RANGE ); +#if !defined( _X360 ) + o.vFog = o.fogFactorW; +#endif + o.vWorldPos_projPosW.xyz = vWorldPos; + + // Eye vector + float3 vWorldEyeVect = cEyePos - vWorldPos; + // Transform to the tangent space + o.vTangentEyeVect.x = dot( vWorldEyeVect, v.vTangentS ); + o.vTangentEyeVect.y = dot( vWorldEyeVect, v.vTangentT ); + o.vTangentEyeVect.z = dot( vWorldEyeVect, vObjNormal ); + + // Tranform bump coordinates + o.vBumpTexCoord.x = dot( v.vBaseTexCoord, cBumpTexCoordTransform[0] ); + o.vBumpTexCoord.y = dot( v.vBaseTexCoord, cBumpTexCoordTransform[1] ); + float f45x=v.vBaseTexCoord.x+v.vBaseTexCoord.y; + float f45y=v.vBaseTexCoord.y-v.vBaseTexCoord.x; +#if MULTITEXTURE + o.vExtraBumpTexCoord.x=f45x*0.1+TexOffsets.x; + o.vExtraBumpTexCoord.y=f45y*0.1+TexOffsets.y; + o.vExtraBumpTexCoord.z=v.vBaseTexCoord.y*0.45+TexOffsets.z; + o.vExtraBumpTexCoord.w=v.vBaseTexCoord.x*0.45+TexOffsets.w; +#endif + +#if BASETEXTURE + o.lightmapTexCoord1And2.xy = v.vLightmapTexCoord + v.vLightmapTexCoordOffset; + + float2 lightmapTexCoord2 = o.lightmapTexCoord1And2.xy + v.vLightmapTexCoordOffset; + float2 lightmapTexCoord3 = lightmapTexCoord2 + v.vLightmapTexCoordOffset; + + // reversed component order + o.lightmapTexCoord1And2.w = lightmapTexCoord2.x; + o.lightmapTexCoord1And2.z = lightmapTexCoord2.y; + + o.lightmapTexCoord3.xy = lightmapTexCoord3; +#endif + + return o; +} + + diff --git a/sp/src/materialsystem/stdshaders/SDK_WorldVertexTransition_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_WorldVertexTransition_ps2x.fxc new file mode 100644 index 00000000..f27e870d --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_WorldVertexTransition_ps2x.fxc @@ -0,0 +1,47 @@ +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] +// STATIC: "MACROS" "0..1" + +#define HDRTYPE HDR_TYPE_NONE +#include "common_ps_fxc.h" + + +sampler BaseSampler : register( s0 ); +// NOTE: LightmapSampler is at the same place as the lightmap sampler in lightmappedgeneric so that we have +// generally the same texture state here. +// CENTROID: TEXCOORD1 +sampler LightmapSampler: register( s1 ); +sampler BaseSampler2: register( s2 ); +sampler LightmapAlphaSampler: register( s3 ); +sampler MacrosSampler: register( s4 ); + +struct PS_INPUT +{ + float2 baseCoord : TEXCOORD0; + float2 baseCoord2 : TEXCOORD1; + float2 lightmapCoord : TEXCOORD2; + float2 macrosCoord : TEXCOORD3; +}; + +float4 main( PS_INPUT i ) : COLOR +{ + bool bMacros = MACROS ? true : false; + + float4 base = tex2D( BaseSampler, i.baseCoord ); + float4 base2 = tex2D( BaseSampler2, i.baseCoord2 ); + + float4 lightmap = tex2D( LightmapSampler, i.lightmapCoord ); + float blendFactor = lightmap.a; + + float4 color = 2.0f * lightmap * lerp( base2, base, blendFactor ); + if( bMacros ) + { + float4 macros = tex2D( MacrosSampler, i.macrosCoord ); + + // Not sure what to do with macro alpha + color.rgb *= 2.0f * lerp( macros.a, macros.b, blendFactor ); + } + + return FinalOutput( color, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE ); +} + diff --git a/sp/src/materialsystem/stdshaders/SDK_WorldVertexTransition_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_WorldVertexTransition_vs20.fxc new file mode 100644 index 00000000..f5d88b1e --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_WorldVertexTransition_vs20.fxc @@ -0,0 +1,64 @@ +// DYNAMIC: "DOWATERFOG" "0..1" + +#include "common_vs_fxc.h" + +static const int g_FogType = DOWATERFOG; + +const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 ); +const float4 cBaseTexCoordTransform2[2] : register( SHADER_SPECIFIC_CONST_2 ); +const float4 cMacrosTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_4 ); + +struct VS_INPUT +{ + // This is all of the stuff that we ever use. + float4 vPos : POSITION; + float4 vColor : COLOR0; + float4 vTexCoord0 : TEXCOORD0; + float4 vTexCoord1 : TEXCOORD1; +}; + +struct VS_OUTPUT +{ + float4 projPos : POSITION; +#if !defined( _X360 ) + float fog : FOG; +#endif + float2 baseCoord : TEXCOORD0; + float2 baseCoord2 : TEXCOORD1; + float2 lightmapCoord : TEXCOORD2; + float2 macrosCoord : TEXCOORD3; + float4 color : COLOR0; + float4 fogFactorW : COLOR1; +}; + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + + float3 worldNormal, worldPos; + float2 texCoord; + worldPos = mul( v.vPos, cModel[0] ); + float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj ); + o.projPos = vProjPos; + vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ ); + o.fogFactorW = CalcFog( worldPos, vProjPos, g_FogType ); +#if !defined( _X360 ) + o.fog = o.fogFactorW; +#endif + o.color = v.vColor; + + o.baseCoord.x = dot( v.vTexCoord0, cBaseTexCoordTransform[0] ); + o.baseCoord.y = dot( v.vTexCoord0, cBaseTexCoordTransform[1] ); + + o.baseCoord2.x = dot( v.vTexCoord0, cBaseTexCoordTransform2[0] ); + o.baseCoord2.y = dot( v.vTexCoord0, cBaseTexCoordTransform2[1] ); + + o.lightmapCoord = v.vTexCoord1; + + o.macrosCoord.x = dot( v.vTexCoord0, cMacrosTexCoordTransform[0] ); + o.macrosCoord.y = dot( v.vTexCoord0, cMacrosTexCoordTransform[1] ); + + return o; +} + + diff --git a/sp/src/materialsystem/stdshaders/SDK_cable_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_cable_ps2x.fxc new file mode 100644 index 00000000..2eb0dbf4 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_cable_ps2x.fxc @@ -0,0 +1,54 @@ +// DYNAMIC: "PIXELFOGTYPE" "0..1" +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX] + +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] + +#if defined( SHADER_MODEL_PS_2_0 ) +# define WRITE_DEPTH_TO_DESTALPHA 0 +#endif + +#include "common_ps_fxc.h" +#include "shader_constant_register_map.h" + +sampler NormalSampler : register( s0 ); +sampler BaseTextureSampler : register( s1 ); + +const float4 g_FogParams : register( PSREG_FOG_PARAMS ); +const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT ); + +struct PS_INPUT +{ + float2 vTexCoord0 : TEXCOORD0; + float2 vTexCoord1 : TEXCOORD1; + + float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog + + float4 directionalLightColor : COLOR0; + float4 fogFactorW : COLOR1; +}; + +float4 main( PS_INPUT i ) : COLOR +{ + float3 vNormalMapDir = tex2D( NormalSampler, i.vTexCoord0 ); // Get the 3-vector from the normal map + float4 textureColor = tex2D( BaseTextureSampler, i.vTexCoord1 ); // Interpret tcoord t1 as color data. + + //Expand compacted vectors + //TODO: find if there's a better way to expand a color normal to a full vector ( _bx2 was used in the assembly code ) + vNormalMapDir = (vNormalMapDir - 0.5) * 2.0; + float3 vLightDir = float3( 0.0f, 0.0f, 1.0f ); + + float lightDirDotNormalMap = dot( vNormalMapDir, vLightDir ); //normalMap dot dirLightDir + + // do half-lambert on the dot + lightDirDotNormalMap = lightDirDotNormalMap * 0.5 + 0.5; + lightDirDotNormalMap = lightDirDotNormalMap * lightDirDotNormalMap; + + float4 resultColor; + resultColor.xyz = lightDirDotNormalMap * ( textureColor.rgb * i.directionalLightColor.rgb ); + resultColor.a = textureColor.a * i.directionalLightColor.a; + + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); + return FinalOutput( resultColor, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, (WRITE_DEPTH_TO_DESTALPHA != 0), i.worldPos_projPosZ.w ); +} diff --git a/sp/src/materialsystem/stdshaders/SDK_cable_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_cable_vs20.fxc new file mode 100644 index 00000000..adb3559e --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_cable_vs20.fxc @@ -0,0 +1,80 @@ +// DYNAMIC: "DOWATERFOG" "0..1" + +#include "common_vs_fxc.h" + +static const int g_FogType = DOWATERFOG; + +struct VS_INPUT +{ + float4 vPos : POSITION; + float2 vTexCoord0 : TEXCOORD0; + float2 vTexCoord1 : TEXCOORD1; + + float4 directionalLightColor : COLOR0; + + float3 vTangentS : TANGENT; + float3 vTangentT : BINORMAL; +}; + +struct VS_OUTPUT +{ + float4 vProjPos : POSITION; + float2 vTexCoord0 : TEXCOORD0; + float2 vTexCoord1 : TEXCOORD1; + + float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog + + float4 directionalLightColor : COLOR0; + + float4 fogFactorW : COLOR1; + +#if !defined( _X360 ) + float fog : FOG; +#endif +}; + + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + + float3 worldPos; + worldPos = mul( v.vPos, cModel[0] ); + float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj ); + o.vProjPos = vProjPos; + vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ ); + + o.worldPos_projPosZ = float4( worldPos.xyz, vProjPos.z ); + + o.fogFactorW = CalcFog( worldPos, vProjPos, g_FogType ); +#if !defined( _X360 ) + o.fog = o.fogFactorW; +#endif + + //------------------------------------------------------------------------------ + // Setup the tangent space + //------------------------------------------------------------------------------ + + // Get S crossed with T (call it R) + float3 r = cross( v.vTangentS, v.vTangentT ); + + // Normalize S (into s) + float3 s = normalize( v.vTangentS ); + + // Normalize R (into r) + r = normalize( r ); + + // Regenerate T (into t) + float3 t = cross( r, v.vTangentS ); + + //------------------------------------------------------------------------------ + // Copy texcoords for the normal map and base texture + //------------------------------------------------------------------------------ + o.vTexCoord0 = v.vTexCoord0; + o.vTexCoord1 = v.vTexCoord1; + + // Pass the dirlight color through + o.directionalLightColor = v.directionalLightColor; + + return o; +} \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/SDK_cloak_blended_pass_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_cloak_blended_pass_ps2x.fxc new file mode 100644 index 00000000..3c432132 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_cloak_blended_pass_ps2x.fxc @@ -0,0 +1,106 @@ +//========= Copyright ? 1996-2006, Valve Corporation, All rights reserved. ============// + +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps30][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] +// STATIC: "BUMPMAP" "0..1" + +// Includes ======================================================================================= +#include "common_vertexlitgeneric_dx9.h" + +// Texture Samplers =============================================================================== +sampler g_tRefractionSampler : register( s0 ); +#if BUMPMAP + sampler g_tBumpSampler : register( s1 ); +#endif + +// Shaders Constants and Globals ================================================================== +const float4 g_mViewProj0 : register( c0 ); // 1st row of matrix +const float4 g_mViewProj1 : register( c1 ); // 2nd row of matrix + +const float4 g_vCameraPosition : register( c5 ); +const float4 g_vPackedConst6 : register( c6 ); +#define g_flCloakFactor g_vPackedConst6.x // Default = 1.0f +#define g_flRefractAmount g_vPackedConst6.y // Default = 1.0f + +const float4 g_cCloakColorTint : register( c7 ); + +// 8 2D Poisson offsets (designed to use .xy and .wz swizzles (not .zw) +static const float4 g_vPoissonOffset[4] = { float4 (-0.0876f, 0.9703f, 0.5651f, 0.4802f ), + float4 ( 0.1851f, 0.1580f, -0.0617f, -0.2616f ), + float4 (-0.5477f, -0.6603f, 0.0711f, -0.5325f ), + float4 (-0.0751f, -0.8954f, 0.4054f, 0.6384f ) }; + +// Interpolated values ============================================================================ +struct PS_INPUT +{ + float3 vWorldNormal : TEXCOORD0; // World-space normal + float3 vProjPosForRefract : TEXCOORD1; + float3 vWorldViewVector : TEXCOORD2; + #if BUMPMAP + float3x3 mTangentSpaceTranspose : TEXCOORD3; + // second row : TEXCOORD4; + // third row : TEXCOORD5; + float2 vTexCoord0 : TEXCOORD6; + #endif +}; + +// Main =========================================================================================== +float4 main( PS_INPUT i ) : COLOR +{ + float3 vWorldNormal = normalize( i.vWorldNormal.xyz ); + + #if BUMPMAP + float4 vBumpTexel = tex2D( g_tBumpSampler, i.vTexCoord0.xy ); + float3 vTangentNormal = ( 2.0f * vBumpTexel ) - 1.0f; + vWorldNormal.xyz = mul( i.mTangentSpaceTranspose, vTangentNormal.xyz ); + #endif + + // Transform world space normal into clip space and project + float3 vProjNormal; + vProjNormal.x = dot( vWorldNormal.xyz, g_mViewProj0.xyz ); // 1st row + vProjNormal.y = dot( vWorldNormal.xyz, g_mViewProj1.xyz ); // 2nd row + + // Compute coordinates for sampling refraction + float2 vRefractTexCoordNoWarp = i.vProjPosForRefract.xy / i.vProjPosForRefract.z; + float2 vRefractTexCoord = vProjNormal.xy; + float scale = lerp( g_flRefractAmount, 0.0f, saturate( g_flCloakFactor ) ); + vRefractTexCoord.xy *= scale; + vRefractTexCoord.xy += vRefractTexCoordNoWarp.xy; + + // Blur by scalable Poisson filter + float flBlurAmount = lerp( 0.05f, 0.0f, saturate( g_flCloakFactor ) ); + float3 cRefract = tex2D( g_tRefractionSampler, vRefractTexCoord.xy ); + cRefract += tex2D( g_tRefractionSampler, vRefractTexCoord.xy + ( g_vPoissonOffset[0].xy * flBlurAmount ) ); + cRefract += tex2D( g_tRefractionSampler, vRefractTexCoord.xy + ( g_vPoissonOffset[0].wz * flBlurAmount ) ); + cRefract += tex2D( g_tRefractionSampler, vRefractTexCoord.xy + ( g_vPoissonOffset[1].xy * flBlurAmount ) ); + cRefract += tex2D( g_tRefractionSampler, vRefractTexCoord.xy + ( g_vPoissonOffset[1].wz * flBlurAmount ) ); + cRefract += tex2D( g_tRefractionSampler, vRefractTexCoord.xy + ( g_vPoissonOffset[2].xy * flBlurAmount ) ); + cRefract += tex2D( g_tRefractionSampler, vRefractTexCoord.xy + ( g_vPoissonOffset[2].wz * flBlurAmount ) ); + cRefract += tex2D( g_tRefractionSampler, vRefractTexCoord.xy + ( g_vPoissonOffset[3].xy * flBlurAmount ) ); + cRefract += tex2D( g_tRefractionSampler, vRefractTexCoord.xy + ( g_vPoissonOffset[3].wz * flBlurAmount ) ); + cRefract /= 9.0f; + + // 1-(N.V) for Fresnel term (NOTE: If this math changes, you need to update the C code that mimics this on the CPU) + float flFresnel = 1.0f - saturate( dot( i.vWorldNormal.xyz, normalize( -i.vWorldViewVector.xyz ) ) ); + float flCloakLerpFactor = saturate( lerp( 1.0f, flFresnel - 1.35f, saturate( g_flCloakFactor ) ) ); + flCloakLerpFactor = 1.0f - smoothstep( 0.4f, 0.425f, flCloakLerpFactor ); + + // Slightly dim the facing pixels and brighten the silhouette pixels + cRefract.rgb *= lerp( flFresnel * 0.4 + 0.8, 1.0f, saturate( g_flCloakFactor ) * saturate( g_flCloakFactor ) ); // This gives a scalar in the range [0.8 1.2] + + // Refract color tint + float fColorTintStrength = saturate( ( saturate( g_flCloakFactor ) - 0.75f ) * 4.0f ); + cRefract.rgb *= lerp( g_cCloakColorTint, 1.0f, fColorTintStrength ); + + //===============// + // Combine terms // + //===============// + float4 result; + result.rgb = cRefract.rgb; + + // Set alpha to cloak mask + result.a = flCloakLerpFactor; + + return FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE ); +} \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/SDK_cloak_blended_pass_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_cloak_blended_pass_vs20.fxc new file mode 100644 index 00000000..8f84ef55 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_cloak_blended_pass_vs20.fxc @@ -0,0 +1,132 @@ +//========= Copyright ? 1996-2006, Valve Corporation, All rights reserved. ============// + +// STATIC: "BUMPMAP" "0..1" + +// DYNAMIC: "COMPRESSED_VERTS" "0..1" +// DYNAMIC: "SKINNING" "0..1" +// DYNAMIC: "MORPHING" "0..1" [vs30] + +// Includes +#include "common_vs_fxc.h" + +// Globals +static const bool g_bSkinning = SKINNING ? true : false; +const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 ); + +#ifdef SHADER_MODEL_VS_3_0 +// NOTE: cMorphTargetTextureDim.xy = target dimensions, +// cMorphTargetTextureDim.z = 4tuples/morph +const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_6 ); +const float4 cMorphSubrect : register( SHADER_SPECIFIC_CONST_7 ); + +sampler2D morphSampler : register( D3DVERTEXTEXTURESAMPLER0, s0 ); +#endif + +// Structs +struct VS_INPUT +{ + float4 vPos : POSITION; // Position + float4 vNormal : NORMAL; // Normal + float4 vBoneWeights : BLENDWEIGHT; // Skin weights + float4 vBoneIndices : BLENDINDICES; // Skin indices + float4 vTexCoord0 : TEXCOORD0; // Base texture coordinates + + #if BUMPMAP + float4 vTangent : TANGENT; + #endif + + // Position and normal/tangent deltas + float3 vPosFlex : POSITION1; + float3 vNormalFlex : NORMAL1; + + #ifdef SHADER_MODEL_VS_3_0 + float vVertexID : POSITION2; + #endif +}; + +struct VS_OUTPUT +{ + float4 vProjPosition : POSITION; // Projection-space position + float3 vWorldNormal : TEXCOORD0; // World-space normal + float3 vProjPosForRefract : TEXCOORD1; + float3 vWorldViewVector : TEXCOORD2; + + #if BUMPMAP + float3x3 mTangentSpaceTranspose : TEXCOORD3; + // second row : TEXCOORD4; + // third row : TEXCOORD5; + float2 vTexCoord0 : TEXCOORD6; + #endif +}; + +// Main +VS_OUTPUT main( const VS_INPUT i ) +{ + VS_OUTPUT o; + + // Flexes coming in from a separate stream (contribution masked by cFlexScale.x) + float4 vObjPosition = i.vPos; + float3 vObjNormal; + + #if BUMPMAP + float4 vObjTangent; + DecompressVertex_NormalTangent( i.vNormal, i.vTangent, vObjNormal, vObjTangent ); + + #if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING + ApplyMorph( i.vPosFlex, i.vNormalFlex, vObjPosition.xyz, vObjNormal, vObjTangent.xyz ); + #else + ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, i.vVertexID, float3( 0, 0, 0 ), vObjPosition.xyz, vObjNormal, vObjTangent.xyz ); + #endif + #else // !BUMPMAP + DecompressVertex_Normal( i.vNormal, vObjNormal ); + + #if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING + ApplyMorph( i.vPosFlex, i.vNormalFlex, vObjPosition.xyz, vObjNormal ); + #else + ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, i.vVertexID, float3( 0, 0, 0 ), + vObjPosition.xyz, vObjNormal ); + #endif + #endif + + // Transform the position + float3 vWorldPosition = { 0.0f, 0.0f, 0.0f }; + float3 vWorldNormal = { 0.0f, 0.0f, 0.0f }; + #if BUMPMAP + float3 vWorldTangent = { 0.0f, 0.0f, 0.0f }; + float3 vWorldBinormal = { 0.0f, 0.0f, 0.0f }; + SkinPositionNormalAndTangentSpace( g_bSkinning, vObjPosition, vObjNormal.xyz, vObjTangent.xyzw, i.vBoneWeights, i.vBoneIndices, vWorldPosition, vWorldNormal, vWorldTangent, vWorldBinormal ); + #else + SkinPositionAndNormal( g_bSkinning, vObjPosition, vObjNormal.xyz, i.vBoneWeights, i.vBoneIndices, vWorldPosition, vWorldNormal ); + #endif + o.vWorldNormal.xyz = normalize( vWorldNormal.xyz ); + + // Transform into projection space + float4 vProjPosition = mul( float4( vWorldPosition, 1.0f ), cViewProj ); + o.vProjPosition = vProjPosition; + + // Map projected position to the refraction texture + float2 vRefractPos; + vRefractPos.x = vProjPosition.x; + vRefractPos.y = -vProjPosition.y; // Invert Y + vRefractPos = (vRefractPos + vProjPosition.w) * 0.5f; + o.vProjPosForRefract.xyz = float3(vRefractPos.x, vRefractPos.y, vProjPosition.w); + + // View vector + float3 vWorldViewVector = normalize (vWorldPosition.xyz - cEyePos.xyz); + o.vWorldViewVector.xyz = vWorldViewVector.xyz; + + // Tangent space transform + #if BUMPMAP + o.mTangentSpaceTranspose[0] = float3( vWorldTangent.x, vWorldBinormal.x, vWorldNormal.x ); + o.mTangentSpaceTranspose[1] = float3( vWorldTangent.y, vWorldBinormal.y, vWorldNormal.y ); + o.mTangentSpaceTranspose[2] = float3( vWorldTangent.z, vWorldBinormal.z, vWorldNormal.z ); + #endif + + // Texture coordinates + #if BUMPMAP + o.vTexCoord0.x = dot( i.vTexCoord0.xy, cBaseTexCoordTransform[0] ); + o.vTexCoord0.y = dot( i.vTexCoord0.xy, cBaseTexCoordTransform[1] ); + #endif + + return o; +} \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/SDK_decalmodulate_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_decalmodulate_ps2x.fxc new file mode 100644 index 00000000..1b0518c5 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_decalmodulate_ps2x.fxc @@ -0,0 +1,101 @@ +//========== Copyright (c) Valve Corporation, All rights reserved. ==========// +// paired with "vertexlit_and_unlit_generic_vs##" + +// STATIC: "VERTEXALPHA" "0..1" +// STATIC: "FLASHLIGHT" "0..1" +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps20b] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps30] [PC] + +// DYNAMIC: "PIXELFOGTYPE" "0..1" +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps20b] +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps30] [PC] + +// We don't care about flashlight depth unless the flashlight is on +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps20b] +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps30] + +// Flashlight shadow filter mode is irrelevant if there is no flashlight +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) [ps20b] +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) [ps30] + +#include "common_ps_fxc.h" +#include "common_flashlight_fxc.h" +#include "shader_constant_register_map.h" + +sampler TexSampler : register( s0 ); + +sampler RandRotSampler : register( s6 ); // RandomRotation sampler +sampler FlashlightSampler : register( s7 ); +sampler ShadowDepthSampler : register( s8 ); // Flashlight shadow depth map sampler + +const float4 g_FogParams : register( PSREG_FOG_PARAMS ); +const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT ); +const float4 g_FogTweakParams : register( c0 ); +#define g_fFogExponentTweak g_FogTweakParams.x +#define g_fFogScaleTweak g_FogTweakParams.y + +const float4 g_FlashlightAttenuationFactors : register( c22 ); +const float3 g_FlashlightPos : register( c23 ); +const float4x4 g_FlashlightWorldToTexture : register( c24 ); // through c27 + +struct PS_INPUT +{ + HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate + + float4 worldPos_projPosZ : TEXCOORD1; // Necessary for pixel fog + + float4 color : COLOR1; + +#if FLASHLIGHT + float4 vProjPos : TEXCOORD2; +#endif +}; + +float4 main( PS_INPUT i ) : COLOR +{ + float4 result = tex2D( TexSampler, i.baseTexCoord ); + + // Blend towards grey based on alpha + float flFactor = 1.0; +#if VERTEXALPHA + flFactor *= i.color.w; +#endif + +#if FLASHLIGHT + //if( bFlashlight ) + { + int nShadowSampleLevel = 0; + bool bDoShadows = false; + float2 vProjPos = float2(0, 0); +// On ps_2_b, we can do shadow mapping +#if ( FLASHLIGHTSHADOWS && (defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) ) ) + nShadowSampleLevel = FLASHLIGHTDEPTHFILTERMODE; + bDoShadows = FLASHLIGHTSHADOWS; + vProjPos = i.vProjPos.xy / i.vProjPos.w; // Screen-space position for shadow map noise +#endif + + float4 flashlightSpacePosition = mul( float4( i.worldPos_projPosZ.xyz, 1.0f ), g_FlashlightWorldToTexture ); + + float3 flashlightColor = DoFlashlight( g_FlashlightPos, i.worldPos_projPosZ.xyz, flashlightSpacePosition, + float3( 0.0f, 0.0f, 1.0f ), g_FlashlightAttenuationFactors.xyz, + g_FlashlightAttenuationFactors.w, FlashlightSampler, ShadowDepthSampler, + RandRotSampler, nShadowSampleLevel, bDoShadows, false, vProjPos, false, float4(3/1024.0f, 0.0005f, 0.0f, 0.0f), false ); + + flFactor *= (flashlightColor.x + flashlightColor.y + flashlightColor.z); + + //result.xyz *= flashlightColor.xyz; + + //result.a *= (flashlightColor.x * flashlightColor.y * flashlightColor.z); + } +#endif + + result.xyz = lerp( float3( 0.5, 0.5, 0.5 ), result.xyz, flFactor ); + + // Since we're blending with a mod2x, we need to compensate with this hack + // NOTE: If the fog color (not fog density) is extremely dark, this can makes some decals seem + // a little transparent, but it's better than not doing this + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); + fogFactor = pow( saturate( g_fFogScaleTweak * fogFactor ), g_fFogExponentTweak ); + + return FinalOutput( result, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_NONE ); +} diff --git a/sp/src/materialsystem/stdshaders/SDK_decalmodulate_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_decalmodulate_vs20.fxc new file mode 100644 index 00000000..de31830f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_decalmodulate_vs20.fxc @@ -0,0 +1,155 @@ +// based on vertexlit_and_unlit_generic_vs20.fxc +//========== Copyright (c) Valve Corporation, All rights reserved. ==========// + +// STATIC: "VERTEXCOLOR" "0..1" +// STATIC: "LIGHTING_PREVIEW" "0..1" [PC] +// STATIC: "LIGHTING_PREVIEW" "0..0" [XBOX] +// STATIC: "FLASHLIGHT" "0..1" + +// DYNAMIC: "DOWATERFOG" "0..1" +// DYNAMIC: "COMPRESSED_VERTS" "0..1" +// DYNAMIC: "SKINNING" "0..0" [vs20] +// DYNAMIC: "SKINNING" "0..1" [vs30] + +// DYNAMIC: "MORPHING" "0..1" [vs30] [ = pShaderAPI->IsHWMorphingEnabled() ] + +#include "common_vs_fxc.h" + +static const bool g_bSkinning = SKINNING ? true : false; +static const int g_FogType = DOWATERFOG; +static const bool g_bVertexColor = VERTEXCOLOR ? true : false; +#if ( defined( SHADER_MODEL_VS_3_0 ) && MORPHING ) + #define DECALOFFSET 1 +#else + #define DECALOFFSET 0 +#endif + +const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 ); + +#ifdef SHADER_MODEL_VS_3_0 +// NOTE: cMorphTargetTextureDim.xy = target dimensions, +// cMorphTargetTextureDim.z = 4tuples/morph +const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_10 ); +const float4 cMorphSubrect : register( SHADER_SPECIFIC_CONST_11 ); +sampler2D morphSampler : register( D3DVERTEXTEXTURESAMPLER0, s0 ); +#endif + +struct VS_INPUT +{ + // This is all of the stuff that we ever use. + float4 vPos : POSITION; + float4 vBoneWeights : BLENDWEIGHT; + float4 vBoneIndices : BLENDINDICES; + float4 vNormal : NORMAL; + float4 vColor : COLOR0; + float3 vSpecular : COLOR1; + // make these float2's and stick the [n n 0 1] in the dot math. + float4 vTexCoord0 : TEXCOORD0; + float4 vTexCoord1 : TEXCOORD1; + float4 vTexCoord2 : TEXCOORD2; + float4 vTexCoord3 : TEXCOORD3; + + // Position and normal/tangent deltas + float3 vPosFlex : POSITION1; + float3 vNormalFlex : NORMAL1; +#ifdef SHADER_MODEL_VS_3_0 + float vVertexID : POSITION2; +#endif +}; + + +struct VS_OUTPUT +{ + float4 projPos : POSITION; // Projection-space position +#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 ) + float fog : FOG; +#endif + + HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate + float4 worldPos_ProjPosZ : TEXCOORD1; + float4 color : COLOR1; // Vertex color (from lighting or unlit) + +#if FLASHLIGHT + float4 vProjPos : TEXCOORD2; +#endif +}; + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + + float4 vPosition = v.vPos; + float3 vNormal = 0; + if ( LIGHTING_PREVIEW || DECALOFFSET ) + { + // The vertex only contains valid normals if they are actually needed (fetching them when absent makes D3D complain) + DecompressVertex_Normal( v.vNormal, vNormal ); + } + +#if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING + ApplyMorph( v.vPosFlex, v.vNormalFlex, vPosition.xyz, vNormal ); +#else + ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, + v.vVertexID, v.vTexCoord2, vPosition.xyz, vNormal ); +#endif + + // Perform skinning + float3 worldNormal, worldPos; + SkinPositionAndNormal( + g_bSkinning, + vPosition, vNormal, + v.vBoneWeights, v.vBoneIndices, + worldPos, worldNormal ); + + if ( !g_bVertexColor ) + { + worldNormal = normalize( worldNormal ); + } + +#if defined( SHADER_MODEL_VS_3_0 ) && MORPHING + // Avoid z precision errors + worldPos += worldNormal * 0.05f * v.vTexCoord2.z; +#endif + + // Transform into projection space + float4 projPos = mul( float4( worldPos, 1 ), cViewProj ); + o.projPos = projPos; + +#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 ) + o.fog = CalcFixedFunctionFog( worldPos, g_FogType ); +#endif + +#if FLASHLIGHT + // Transform into projection space + projPos.z = dot( float4( worldPos, 1 ), cViewProjZ ); + + o.vProjPos = projPos; +#endif + + o.worldPos_ProjPosZ.xyz = worldPos.xyz; + o.worldPos_ProjPosZ.w = projPos.z; + + if ( g_bVertexColor ) + { + // Assume that this is unlitgeneric if you are using vertex color. + o.color.rgb = GammaToLinear( v.vColor.rgb ); + o.color.a = v.vColor.a; + } + else + { + o.color = float4( 1.0f, 1.0f, 1.0f, 1.0f ); + } + + // Base texture coordinates + o.baseTexCoord.x = dot( v.vTexCoord0, cBaseTexCoordTransform[0] ); + o.baseTexCoord.y = dot( v.vTexCoord0, cBaseTexCoordTransform[1] ); + +#if LIGHTING_PREVIEW + float dot=0.5+0.5*worldNormal*float3(0.7071,0.7071,0); + o.color.xyz=float3(dot,dot,dot); +#endif + + return o; +} + + diff --git a/sp/src/materialsystem/stdshaders/SDK_depthwrite_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_depthwrite_ps2x.fxc new file mode 100644 index 00000000..1baabcf3 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_depthwrite_ps2x.fxc @@ -0,0 +1,44 @@ +// STATIC: "COLOR_DEPTH" "0..1" + +// DYNAMIC: "ALPHACLIP" "0..1" + +const float g_AlphaThreshold : register( c0 ); + +const float2 g_vNearFarPlanes : register( c1 ); + #define g_flNearPlane g_vNearFarPlanes.x + #define g_flFarPlane g_vNearFarPlanes.y + +struct PS_INPUT +{ +#if ALPHACLIP + float2 texCoord0 : TEXCOORD0; +#endif + +#if COLOR_DEPTH + float4 vWorldPos_projPosZ : TEXCOORD1; +#endif +}; + +sampler BaseTextureSampler : register( s0 ); + +float4 main( PS_INPUT i ) : COLOR +{ + float4 color = float4( 1, 0, 0, 1 ); // opaque alpha....the color doesn't matter for this shader + +#if ALPHACLIP + color = tex2D( BaseTextureSampler, i.texCoord0 ); + + clip( color.a - g_AlphaThreshold ); + +#endif + +#if ( COLOR_DEPTH == 1 ) + + return float4( i.vWorldPos_projPosZ.w / g_flFarPlane, 0.0, 0.0, 1.0 ); + +#else + + return color; + +#endif +} diff --git a/sp/src/materialsystem/stdshaders/SDK_depthwrite_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_depthwrite_vs20.fxc new file mode 100644 index 00000000..f98e40e2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_depthwrite_vs20.fxc @@ -0,0 +1,83 @@ +// STATIC: "ONLY_PROJECT_POSITION" "0..1" [XBOX] +// STATIC: "ONLY_PROJECT_POSITION" "0..0" [PC] +// STATIC: "COLOR_DEPTH" "0..1" + +// DYNAMIC: "COMPRESSED_VERTS" "0..1" +// DYNAMIC: "SKINNING" "0..1" +// DYNAMIC: "MORPHING" "0..1" [vs30] + +#include "common_vs_fxc.h" + +static const bool g_bSkinning = SKINNING ? true : false; + +#ifdef SHADER_MODEL_VS_3_0 +// NOTE: cMorphTargetTextureDim.xy = target dimensions, +// cMorphTargetTextureDim.z = 4tuples/morph +const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_6 ); +const float4 cMorphSubrect : register( SHADER_SPECIFIC_CONST_7 ); + +sampler2D morphSampler : register( D3DVERTEXTEXTURESAMPLER0, s0 ); +#endif + + +struct VS_INPUT +{ + float4 vPos : POSITION; + float2 vTexCoord : TEXCOORD0; + float4 vBoneWeights : BLENDWEIGHT; + float4 vBoneIndices : BLENDINDICES; + + // Position delta stream + float3 vPosFlex : POSITION1; + +#ifdef SHADER_MODEL_VS_3_0 + float vVertexID : POSITION2; +#endif +}; + +struct VS_OUTPUT +{ + float4 vProjPos : POSITION; + +#if (ONLY_PROJECT_POSITION == 0) //360 sometimes runs without the pixel shader component, but has to patch this output if it does. + float2 texCoord : TEXCOORD0; +#endif + +#if COLOR_DEPTH + float4 vWorldPos_projPosZ : TEXCOORD1; +#endif + +}; + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + float3 vWorldPos; + float4 vPosition = v.vPos; + +#if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING + ApplyMorph( v.vPosFlex, vPosition.xyz ); +#else + ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, + v.vVertexID, float3(0, 0, 0), vPosition.xyz ); +#endif + + SkinPosition( g_bSkinning, vPosition, v.vBoneWeights, v.vBoneIndices, vWorldPos ); + + float4 vProjPos = mul( float4( vWorldPos, 1.0f ), cViewProj ); + + o.vProjPos = vProjPos; + +#if (ONLY_PROJECT_POSITION == 0) + o.texCoord = v.vTexCoord; +#endif + +#if ( COLOR_DEPTH && !ONLY_PROJECT_POSITION ) + o.vWorldPos_projPosZ.z = vProjPos.z; + o.vWorldPos_projPosZ.w = vProjPos.w; +#endif + + return o; +} + + diff --git a/sp/src/materialsystem/stdshaders/SDK_emissive_scroll_blended_pass_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_emissive_scroll_blended_pass_ps2x.fxc new file mode 100644 index 00000000..1bae9265 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_emissive_scroll_blended_pass_ps2x.fxc @@ -0,0 +1,51 @@ +//========= Copyright ? 1996-2006, Valve Corporation, All rights reserved. ============// + +// Includes ======================================================================================= +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps30][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] +#include "common_vertexlitgeneric_dx9.h" + +// Texture Samplers =============================================================================== +sampler g_tBaseSampler : register( s0 ); +sampler g_tFlowSampler : register( s1 ); +sampler g_tSelfIllumSampler : register( s2 ); + +// Shaders Constants and Globals ================================================================== +const float4 g_vPackedConst0 : register( c0 ); +#define g_flBlendStrength g_vPackedConst0.x +#define g_flTime g_vPackedConst0.y + +const float2 g_vEmissiveScrollVector : register( c1 ); +const float3 g_cSelfIllumTint : register( c2 ); + +// Interpolated values ============================================================================ +struct PS_INPUT +{ + float2 vTexCoord0 : TEXCOORD0; +}; + +// Main =========================================================================================== +//float4 main( PS_INPUT i ) : COLOR // Non-HDR for debugging +float4 main( PS_INPUT i ) : COLOR +{ + // Color texture + float4 cBaseColor = tex2D( g_tBaseSampler, i.vTexCoord0.xy ); + + // Fetch from dudv map and then fetch from emissive texture with new uv's & scroll + float4 vFlowValue = tex2D( g_tFlowSampler, i.vTexCoord0.xy ); + float2 vEmissiveTexCoord = vFlowValue.xy + ( g_vEmissiveScrollVector.xy * g_flTime ); + float4 cEmissiveColor = tex2D( g_tSelfIllumSampler, vEmissiveTexCoord.xy ); + + //===============// + // Combine terms // + //===============// + float4 result; + result.rgb = cBaseColor.rgb * cEmissiveColor.rgb * g_cSelfIllumTint.rgb; + result.rgb *= g_flBlendStrength; + + // Set alpha to 0.0f so it doesn't change dest alpha (I should probably disable dest alpha writes) + result.a = 0.0f; + + return FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_LINEAR ); +} \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/SDK_emissive_scroll_blended_pass_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_emissive_scroll_blended_pass_vs20.fxc new file mode 100644 index 00000000..80d21659 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_emissive_scroll_blended_pass_vs20.fxc @@ -0,0 +1,68 @@ +//========= Copyright ? 1996-2006, Valve Corporation, All rights reserved. ============// + +// DYNAMIC: "COMPRESSED_VERTS" "0..1" +// DYNAMIC: "SKINNING" "0..1" +// DYNAMIC: "MORPHING" "0..1" [vs30] + +// Includes +#include "common_vs_fxc.h" + +// Globals +static const bool g_bSkinning = SKINNING ? true : false; + +#ifdef SHADER_MODEL_VS_3_0 +// NOTE: cMorphTargetTextureDim.xy = target dimensions, +// cMorphTargetTextureDim.z = 4tuples/morph +const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_6 ); +const float4 cMorphSubrect : register( SHADER_SPECIFIC_CONST_7 ); + +sampler2D morphSampler : register( D3DVERTEXTEXTURESAMPLER0, s0 ); +#endif + +// Structs +struct VS_INPUT +{ + float4 vPos : POSITION; // Position + float4 vBoneWeights : BLENDWEIGHT; // Skin weights + float4 vBoneIndices : BLENDINDICES; // Skin indices + float4 vTexCoord0 : TEXCOORD0; // Base texture coordinates + + float3 vPosFlex : POSITION1; // Delta positions for flexing + +#ifdef SHADER_MODEL_VS_3_0 + float vVertexID : POSITION2; +#endif +}; + +struct VS_OUTPUT +{ + float4 vProjPosition : POSITION; // Projection-space position + float2 vTexCoord0 : TEXCOORD0; +}; + +// Main +VS_OUTPUT main( const VS_INPUT i ) +{ + VS_OUTPUT o; + + float4 vObjPosition = i.vPos; + +#if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING + ApplyMorph( i.vPosFlex, vObjPosition.xyz ); +#else + ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, i.vVertexID, float3( 0, 0, 0 ), vObjPosition.xyz ); +#endif + + // Transform the position + float3 vWorldPosition = { 0.0f, 0.0f, 0.0f }; + SkinPosition( g_bSkinning, vObjPosition, i.vBoneWeights, i.vBoneIndices, vWorldPosition ); + + // Transform into projection space + float4 vProjPosition = mul( float4( vWorldPosition, 1.0f ), cViewProj ); + o.vProjPosition = vProjPosition; + + // Pass through tex coords + o.vTexCoord0.xy = i.vTexCoord0.xy; + + return o; +} \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/SDK_eye_refract_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_eye_refract_ps2x.fxc new file mode 100644 index 00000000..0169c0bf --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_eye_refract_ps2x.fxc @@ -0,0 +1,494 @@ +//====== Copyright © 1996-2007, Valve Corporation, All rights reserved. =========================== + +// STATIC: "FLASHLIGHT" "0..1" +// STATIC: "LIGHTWARPTEXTURE" "0..1" + +// STATIC: "SPHERETEXKILLCOMBO" "0..1" [ps20b] +// STATIC: "SPHERETEXKILLCOMBO" "0..1" [ps30] + +// STATIC: "RAYTRACESPHERE" "0..1" [ps20b] +// STATIC: "RAYTRACESPHERE" "0..1" [ps30] + +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps20b] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps30] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..0" [ps20b] [XBOX] + +// DYNAMIC: "NUM_LIGHTS" "0..2" [ps20] +// DYNAMIC: "NUM_LIGHTS" "0..4" [ps20b] +// DYNAMIC: "NUM_LIGHTS" "0..4" [ps30] + +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps20b] +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps30] + +// We don't use other lights when doing the flashlight +// SKIP: ( $FLASHLIGHT != 0 ) && ( $NUM_LIGHTS > 0 ) + +// We don't care about flashlight depth unless the flashlight is on +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps20b] +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps30] + +// SKIP: ( $RAYTRACESPHERE == 0 ) && ( $SPHERETEXKILLCOMBO == 1 ) [ps30] +// SKIP: ( $RAYTRACESPHERE == 0 ) && ( $SPHERETEXKILLCOMBO == 1 ) [ps20b] + +// Debug 2.0 shader locally +//#ifdef SHADER_MODEL_PS_2_B +//#undef SHADER_MODEL_PS_2_B +//#define SHADER_MODEL_PS_2_0 +//#endif + + +// Includes ======================================================================================= +#include "common_flashlight_fxc.h" +#include "shader_constant_register_map.h" + +// Texture Samplers =============================================================================== +sampler g_tCorneaSampler : register( s0 ); +sampler g_tIrisSampler : register( s1 ); +sampler g_tEyeReflectionCubemapSampler : register( s2 ); +sampler g_tEyeAmbientOcclSampler : register( s3 ); +sampler g_tLightwarpSampler : register( s4 ); // 1D texture for TF NPR lighting + +sampler g_tFlashlightCookieSampler : register( s5 ); +sampler g_tFlashlightDepthSampler : register( s6 ); +sampler g_tRandomRotationSampler : register( s7 ); + +// Shaders Constants and Globals ================================================================== +const float4 g_vPackedConst0 : register( c0 ); +#define g_flDilationFactor g_vPackedConst0.x +#define g_flGlossiness g_vPackedConst0.y +#define g_flAverageAmbient g_vPackedConst0.z +#define g_flCorneaBumpStrength g_vPackedConst0.w + +const float3 g_vEyeOrigin : register( c1 ); +const float4 g_vIrisProjectionU : register( c2 ); +const float4 g_vIrisProjectionV : register( c3 ); +const float4 g_vCameraPosition : register( c4 ); +const float3 g_cAmbientOcclColor : register( c5 ); + +const float4 g_vPackedConst6 : register( c6 ); +#define g_flEyeballRadius g_vPackedConst6.y //0.51f +//#define g_bRaytraceSphere g_vPackedConst6.z //1.0f +#define g_flParallaxStrength g_vPackedConst6.w //0.25f + +// Flashlight constants +const float4 g_vFlashlightAttenuationFactors : register( c7 ); // FarZ in w +const float3 g_vFlashlightPos : register( c8 ); +const float4 g_vShadowTweaks : register( c9 ); +const float4 g_ShaderControls : register( c10 ); +#define g_fPixelFogType g_ShaderControls.x + +const float4 g_FogParams : register( PSREG_FOG_PARAMS ); + +PixelShaderLightInfo g_sLightInfo[3] : register( PSREG_LIGHT_INFO_ARRAY ); // 2 registers each - 6 registers total + +// Interpolated values ============================================================================ +struct PS_INPUT +{ + float4 vAmbientOcclUv_fallbackCorneaUv : TEXCOORD0; + float4 cVertexLight : TEXCOORD1; // w is used for the flashlight pass + float4 vTangentViewVector : TEXCOORD2; // Tangent view vector (Note: w is used for flashlight pass) + float4 vWorldPosition_ProjPosZ : TEXCOORD3; + float3 vWorldNormal : TEXCOORD4; // World-space normal + float3 vWorldTangent : TEXCOORD5; // World-space tangent + float4 vLightFalloffCosine01 : TEXCOORD6; // Light falloff and cosine terms for first two local lights + float4 vLightFalloffCosine23 : TEXCOORD7; // Light falloff and cosine terms for next two local lights + + float3 vWorldBinormal : COLOR0; // World-space normal +}; + +// Ray sphere intersect returns distance along ray to intersection ================================ +float IntersectRaySphere ( float3 cameraPos, float3 ray, float3 sphereCenter, float sphereRadius) +{ + float3 dst = cameraPos.xyz - sphereCenter.xyz; + float B = dot(dst, ray); + float C = dot(dst, dst) - (sphereRadius * sphereRadius); + float D = B*B - C; + return (D > 0) ? (-B - sqrt(D)) : 0; +} + +// Calculate both types of Fog and lerp to get result +float CalcPixelFogFactorConst( float fPixelFogType, const float4 fogParams, const float flEyePosZ, const float flWorldPosZ, const float flProjPosZ ) +{ + float fRangeFog = CalcRangeFog( flProjPosZ, fogParams.x, fogParams.z, fogParams.w ); + float fHeightFog = CalcWaterFogAlpha( fogParams.y, flEyePosZ, flWorldPosZ, flProjPosZ, fogParams.w ); + return lerp( fRangeFog, fHeightFog, fPixelFogType ); +} + +// Blend both types of Fog and lerp to get result +float3 BlendPixelFogConst( const float3 vShaderColor, float pixelFogFactor, const float3 vFogColor, float fPixelFogType ) +{ + pixelFogFactor = saturate( pixelFogFactor ); + float3 fRangeResult = lerp( vShaderColor.rgb, vFogColor.rgb, pixelFogFactor * pixelFogFactor ); //squaring the factor will get the middle range mixing closer to hardware fog + float3 fHeightResult = lerp( vShaderColor.rgb, vFogColor.rgb, saturate( pixelFogFactor ) ); + return lerp( fRangeResult, fHeightResult, fPixelFogType ); +} + +float4 FinalOutputConst( const float4 vShaderColor, float pixelFogFactor, float fPixelFogType, const int iTONEMAP_SCALE_TYPE ) +{ + float4 result = vShaderColor; + if( iTONEMAP_SCALE_TYPE == TONEMAP_SCALE_LINEAR ) + { + result.rgb *= LINEAR_LIGHT_SCALE; + } + else if( iTONEMAP_SCALE_TYPE == TONEMAP_SCALE_GAMMA ) + { + result.rgb *= GAMMA_LIGHT_SCALE; + } + + result.rgb = BlendPixelFogConst( result.rgb, pixelFogFactor, g_LinearFogColor.rgb, fPixelFogType ); + result.rgb = SRGBOutput( result.rgb ); //SRGB in pixel shader conversion + + return result; +} + + +// Main =========================================================================================== +float4 main( PS_INPUT i ) : COLOR +{ + // Set bools to compile out code + bool bFlashlight = ( FLASHLIGHT != 0 ) ? true : false; + bool bDoDiffuseWarp = LIGHTWARPTEXTURE ? true : false; + int nNumLights = FLASHLIGHT ? 1 : NUM_LIGHTS; // Flashlight is considered one light, otherwise, use numlights combo + +#if !defined( SHADER_MODEL_PS_2_0 ) + bool bRayCast = RAYTRACESPHERE ? true : false; + bool bRayCastTexKill = SPHERETEXKILLCOMBO ? true : false; +#endif + + float flFlashlightNDotL = i.vTangentViewVector.w; + float4 vFlashlightTexCoord = { 0.0f, 0.0f, 0.0f, 0.0f }; + if ( bFlashlight ) + { + vFlashlightTexCoord.xyzw = i.cVertexLight.xyzw; // This was hidden in this interpolator + i.cVertexLight.rgba = float4( 0.0f, 0.0f, 0.0f, 0.0f ); + } + + // Interpolated vectors + float3 vWorldNormal = i.vWorldNormal.xyz; + float3 vWorldTangent = i.vWorldTangent.xyz; + float3 vWorldBinormal = ( i.vWorldBinormal.xyz * 2.0f ) - 1.0f; // normalize( cross( vWorldNormal.xyz, vWorldTangent.xyz ) ); + + float3 vTangentViewVector = i.vTangentViewVector.xyz; + + // World position + float3 vWorldPosition = i.vWorldPosition_ProjPosZ.xyz; + + // World view vector to pixel + float3 vWorldViewVector = normalize( vWorldPosition.xyz - g_vCameraPosition.xyz ); + + //=================// + // TF NPR lighting // + //=================// + if ( bDoDiffuseWarp ) + { + // Replace the interpolated vertex light + if ( bFlashlight == true ) + { + // Deal with this below in the flashlight section + } + else + { + if ( nNumLights > 0 ) + { + float3 cWarpedLight = 2.0f * tex1D( g_tLightwarpSampler, i.vLightFalloffCosine01.z ).rgb; + i.cVertexLight.rgb += i.vLightFalloffCosine01.x * PixelShaderGetLightColor( g_sLightInfo, 0 ) * cWarpedLight.rgb; + } + + if ( nNumLights > 1 ) + { + float3 cWarpedLight = 2.0f * tex1D( g_tLightwarpSampler, i.vLightFalloffCosine01.w ).rgb; + i.cVertexLight.rgb += i.vLightFalloffCosine01.y * PixelShaderGetLightColor( g_sLightInfo, 1 ) * cWarpedLight.rgb; + } + + if ( nNumLights > 2 ) + { + float3 cWarpedLight = 2.0f * tex1D( g_tLightwarpSampler, i.vLightFalloffCosine23.z ).rgb; + i.cVertexLight.rgb += i.vLightFalloffCosine23.x * PixelShaderGetLightColor( g_sLightInfo, 2 ) * cWarpedLight.rgb; + } + + if ( nNumLights > 3 ) + { + float3 cWarpedLight = 2.0f * tex1D( g_tLightwarpSampler, i.vLightFalloffCosine23.w ).rgb; + i.cVertexLight.rgb += i.vLightFalloffCosine23.y * PixelShaderGetLightColor( g_sLightInfo, 3 ) * cWarpedLight.rgb; + } + } + } + + //==========================================================================================================// + // Ray cast against sphere representing eyeball to reduce artifacts from non-spherical morphed eye geometry // + //==========================================================================================================// +#if !defined( SHADER_MODEL_PS_2_0 ) + if ( bRayCast ) + { + float fSphereRayCastDistance = IntersectRaySphere( g_vCameraPosition.xyz, vWorldViewVector.xyz, g_vEyeOrigin.xyz, g_flEyeballRadius ); + vWorldPosition.xyz = g_vCameraPosition.xyz + ( vWorldViewVector.xyz * fSphereRayCastDistance ); + if (fSphereRayCastDistance == 0) + { + if ( bRayCastTexKill ) + clip(-1); // texkill to get a better silhouette + vWorldPosition.xyz = g_vEyeOrigin.xyz + ( vWorldNormal.xyz * g_flEyeballRadius ); + } + } +#endif + + //=================================// + // Generate sphere and cornea uv's // + //=================================// +#if !defined( SHADER_MODEL_PS_2_0 ) + float2 vCorneaUv; // Note: Cornea texture is a cropped version of the iris texture + vCorneaUv.x = dot( g_vIrisProjectionU, float4( vWorldPosition, 1.0f ) ); + vCorneaUv.y = dot( g_vIrisProjectionV, float4( vWorldPosition, 1.0f ) ); + float2 vSphereUv = ( vCorneaUv.xy * 0.5f ) + 0.25f; +#else // ps_20 + float2 vCorneaUv = i.vAmbientOcclUv_fallbackCorneaUv.wz; // Note: Cornea texture is a cropped version of the iris texture + float2 vSphereUv = ( vCorneaUv.xy * 0.5f ) + 0.25f; +#endif + + //=================================// + // Hacked parallax mapping on iris // + //=================================// + float fIrisOffset = tex2D( g_tCorneaSampler, vCorneaUv.xy ).b; + +#if !defined( SHADER_MODEL_PS_2_0 ) + float2 vParallaxVector = ( ( vTangentViewVector.xy * fIrisOffset * g_flParallaxStrength ) / ( 1.0f - vTangentViewVector.z ) ); // Note: 0.25 is a magic number + vParallaxVector.x = -vParallaxVector.x; //Need to flip x...not sure why. + //vParallaxVector.x *= -1.0; //Need to flip x...not sure why. + //vParallaxVector = 0.0f; //Disable parallax for debugging +#else // Disable parallax effect in 2.0 version + float2 vParallaxVector = { 0.0f, 0.0f }; +#endif + + float2 vIrisUv = vSphereUv.xy - vParallaxVector.xy; + + // Note: We fetch from this texture twice right now with different uv's for the color and alpha + float2 vCorneaNoiseUv = vSphereUv.xy + ( vParallaxVector.xy * 0.5 ); + float fCorneaNoise = tex2D( g_tIrisSampler, vCorneaNoiseUv.xy ).a; + + //===============// + // Cornea normal // + //===============// + // Sample 2D normal from texture + float3 vCorneaTangentNormal = { 0.0, 0.0, 1.0 }; + float4 vCorneaSample = tex2D( g_tCorneaSampler, vCorneaUv.xy ); + vCorneaTangentNormal.xy = vCorneaSample.rg - 0.5f; // Note: This scales the bump to 50% strength + + // Scale strength of normal + vCorneaTangentNormal.xy *= g_flCorneaBumpStrength; + + // Add in surface noise and imperfections (NOTE: This should be baked into the normal map!) + vCorneaTangentNormal.xy += fCorneaNoise * 0.1f; + + // Normalize tangent vector +#if !defined( SHADER_MODEL_PS_2_0 ) + // Since this isn't used later in 2.0, skip the normalize to save shader instructions + vCorneaTangentNormal.xyz = normalize( vCorneaTangentNormal.xyz ); +#endif + + // Transform into world space + float3 vCorneaWorldNormal = Vec3TangentToWorldNormalized( vCorneaTangentNormal.xyz, vWorldNormal.xyz, vWorldTangent.xyz, vWorldBinormal.xyz ); + + //============// + // Flashlight // + //============// + float3 vFlashlightVector = { 0.0f, 0.0f, 0.0f }; + float3 cFlashlightColorFalloff = { 0.0f, 0.0f, 0.0f }; + if ( bFlashlight == true ) + { + // Flashlight vector + vFlashlightVector.xyz = normalize( g_vFlashlightPos.xyz - i.vWorldPosition_ProjPosZ.xyz ); + + // Distance attenuation for flashlight and to fade out shadow over distance + float3 vDelta = g_vFlashlightPos.xyz - i.vWorldPosition_ProjPosZ.xyz; + float flDistSquared = dot( vDelta, vDelta ); + float flDist = sqrt( flDistSquared ); + float flFlashlightAttenuation = dot( g_vFlashlightAttenuationFactors.xyz, float3( 1.0f, 1.0f/flDist, 1.0f/flDistSquared ) ); + + // Flashlight cookie +#if !defined( SHADER_MODEL_PS_2_0 ) + float3 vProjCoords = vFlashlightTexCoord.xyz / vFlashlightTexCoord.w; + float3 cFlashlightCookieColor = tex2D( g_tFlashlightCookieSampler, vProjCoords ); +#else + float3 cFlashlightCookieColor = tex2Dproj( g_tFlashlightCookieSampler, vFlashlightTexCoord.xyzw ); +#endif + + // Shadow depth map +#if FLASHLIGHTSHADOWS && !defined( SHADER_MODEL_PS_2_0 ) + int nShadowLevel = FLASHLIGHTDEPTHFILTERMODE; + float flShadow = DoFlashlightShadow( g_tFlashlightDepthSampler, g_tRandomRotationSampler, vProjCoords, float2(0,0), nShadowLevel, g_vShadowTweaks, false ); + float flAttenuated = lerp( flShadow, 1.0f, g_vShadowTweaks.y ); // Blend between fully attenuated and not attenuated + flShadow = lerp( flAttenuated, flShadow, flFlashlightAttenuation ); // Blend between shadow and above, according to light attenuation + cFlashlightCookieColor *= flShadow; // Apply shadow term to cookie color +#endif + + // Flashlight color intensity (needs to be multiplied by global flashlight color later) + cFlashlightColorFalloff.rgb = flFlashlightAttenuation * cFlashlightCookieColor.rgb; + + // Add this into the interpolated lighting + if ( bDoDiffuseWarp ) + { + //float3 cWarpedLight = 2.0f * tex1D( g_tLightwarpSampler, flFlashlightNDotL ).rgb; + //i.cVertexLight.rgb += cFlashlightColorFalloff.rgb * cFlashlightColor.rgb * cWarpedLight.rgb; + i.cVertexLight.rgb += cFlashlightColorFalloff.rgb * cFlashlightColor.rgb * flFlashlightNDotL; // No light warp for now + } + else + { + i.cVertexLight.rgb += cFlashlightColorFalloff.rgb * cFlashlightColor.rgb * flFlashlightNDotL; + } + } + + //==============// + // Dilate pupil // + //==============// +#if !defined( SHADER_MODEL_PS_2_0 ) + vIrisUv.xy -= 0.5f; // Center around (0,0) + float fPupilCenterToBorder = saturate( length( vIrisUv.xy ) / 0.2f ); //Note: 0.2 is the uv radius of the iris + float fPupilDilateFactor = g_flDilationFactor; // This value should be between 0-1 + vIrisUv.xy *= lerp (1.0f, fPupilCenterToBorder, saturate( fPupilDilateFactor ) * 2.5f - 1.25f ); + vIrisUv.xy += 0.5f; +#endif + + //============// + // Iris color // + //============// + float4 cIrisColor = tex2D( g_tIrisSampler, vIrisUv.xy ); + + //==========================// + // Iris lighting highlights // + //==========================// + float3 cIrisLighting = float3( 0.0f, 0.0f, 0.0f ); + +#if !defined( SHADER_MODEL_PS_2_0 ) + // Mask off everything but the iris pixels + float fIrisHighlightMask = tex2D( g_tCorneaSampler, vCorneaUv.xy ).a; + + // Generate the normal + float3 vIrisTangentNormal = vCorneaTangentNormal.xyz; + vIrisTangentNormal.xy *= -2.5f; // I'm not normalizing on purpose + + for ( int j=0; j < nNumLights; j++ ) + { + // World light vector + float3 vWorldLightVector; + if ( ( j == 0 ) && ( bFlashlight == true ) ) + vWorldLightVector = vFlashlightVector.xyz; + else + vWorldLightVector = PixelShaderGetLightVector( i.vWorldPosition_ProjPosZ.xyz, g_sLightInfo, j ); + + // Tangent light vector + float3 vTangentLightVector = Vec3WorldToTangent( vWorldLightVector.xyz, vWorldNormal.xyz, vWorldTangent.xyz, vWorldBinormal.xyz ); + + // Adjust the tangent light vector to generate the iris lighting + float3 tmpv = -vTangentLightVector.xyz; + tmpv.xy *= -0.5f; //Flatten tangent view + tmpv.z = max( tmpv.z, 0.5f ); //Clamp z of tangent view to help maintain highlight + tmpv.xyz = normalize( tmpv.xyz ); + + // Core iris lighting math + float fIrisFacing = pow( abs( dot( vIrisTangentNormal.xyz, tmpv.xyz ) ), 6.0f ) * 0.5f; // Yes, 6.0 and 0.5 are magic numbers + + // Cone of darkness to darken iris highlights when light falls behind eyeball past a certain point + float flConeOfDarkness = pow( 1.0f - saturate( ( -vTangentLightVector.z - 0.25f ) / 0.75f ), 4.0f ); + //float flConeOfDarkness = pow( 1.0f - saturate( ( -dot( vIrisTangentNormal.xyz, vTangentLightVector.xyz ) - 0.15f ) / 0.85f ), 8.0f ); + + // Tint by iris color and cone of darkness + float3 cIrisLightingTmp = fIrisFacing * fIrisHighlightMask * flConeOfDarkness; + + // Attenuate by light color and light falloff + if ( ( j == 0 ) && ( bFlashlight == true ) ) + cIrisLightingTmp.rgb *= cFlashlightColorFalloff.rgb * cFlashlightColor.rgb; + else if ( j == 0 ) + cIrisLightingTmp.rgb *= i.vLightFalloffCosine01.x * PixelShaderGetLightColor( g_sLightInfo, 0 ); + else if ( j == 1 ) + cIrisLightingTmp.rgb *= i.vLightFalloffCosine01.y * PixelShaderGetLightColor( g_sLightInfo, 1 ); + else if ( j == 2 ) + cIrisLightingTmp.rgb *= i.vLightFalloffCosine23.x * PixelShaderGetLightColor( g_sLightInfo, 2 ); + else + cIrisLightingTmp.rgb *= i.vLightFalloffCosine23.y * PixelShaderGetLightColor( g_sLightInfo, 3 ); + + // Sum into final variable + cIrisLighting.rgb += cIrisLightingTmp.rgb; + } + + // Add slight view dependent iris lighting based on ambient light intensity to enhance situations with no local lights (0.5f is to help keep it subtle) + cIrisLighting.rgb += saturate( dot( vIrisTangentNormal.xyz, -vTangentViewVector.xyz ) ) * g_flAverageAmbient * fIrisHighlightMask * 0.5f; +#else + // Else, intensify light over cornea to simulate the brightening that happens above + cIrisLighting.rgb += i.cVertexLight.rgb * vCorneaSample.a; +#endif + + //===================// + // Ambient occlusion // + //===================// + float3 cAmbientOcclFromTexture = tex2D( g_tEyeAmbientOcclSampler, i.vAmbientOcclUv_fallbackCorneaUv.xy ).rgb; + float3 cAmbientOcclColor = lerp( g_cAmbientOcclColor, 1.0f, cAmbientOcclFromTexture.rgb ); // Color the ambient occlusion + i.cVertexLight.rgb *= cAmbientOcclColor.rgb; + + //==========================// + // Reflection from cube map // + //==========================// + float3 vCorneaReflectionVector = reflect ( vWorldViewVector.xyz, vCorneaWorldNormal.xyz ); + + //float3 cReflection = ENV_MAP_SCALE * texCUBE( g_tEyeReflectionCubemapSampler, vCorneaReflectionVector.xyz ).rgb; + float3 cReflection = g_flGlossiness * texCUBE( g_tEyeReflectionCubemapSampler, vCorneaReflectionVector.xyz ).rgb; + + // Hack: Only add in half of the env map for the flashlight pass. This looks reasonable. + if ( bFlashlight ) + { + cReflection.rgb *= 0.5f; + } + + //===========================// + // Glint specular highlights // + //===========================// + float3 cSpecularHighlights = 0.0f; + if ( bFlashlight ) + { + cSpecularHighlights.rgb += pow( saturate( dot( vCorneaReflectionVector.xyz, vFlashlightVector.xyz ) ), 128.0f ) * cFlashlightColorFalloff.rgb * cFlashlightColor.rgb; + } + else // no flashlight + { + if ( nNumLights > 0 ) + cSpecularHighlights.rgb += pow( saturate( dot( vCorneaReflectionVector.xyz, PixelShaderGetLightVector( i.vWorldPosition_ProjPosZ.xyz, g_sLightInfo, 0 ) ) ), 128.0f ) * i.vLightFalloffCosine01.x * PixelShaderGetLightColor( g_sLightInfo, 0 ); + + if ( nNumLights > 1 ) + cSpecularHighlights.rgb += pow( saturate( dot( vCorneaReflectionVector.xyz, PixelShaderGetLightVector( i.vWorldPosition_ProjPosZ.xyz, g_sLightInfo, 1 ) ) ), 128.0f ) * i.vLightFalloffCosine01.y * PixelShaderGetLightColor( g_sLightInfo, 1 ); + + if ( nNumLights > 2 ) + cSpecularHighlights.rgb += pow( saturate( dot( vCorneaReflectionVector.xyz, PixelShaderGetLightVector( i.vWorldPosition_ProjPosZ.xyz, g_sLightInfo, 2 ) ) ), 128.0f ) * i.vLightFalloffCosine23.x * PixelShaderGetLightColor( g_sLightInfo, 2 ); + + if ( nNumLights > 3 ) + cSpecularHighlights.rgb += pow( saturate( dot( vCorneaReflectionVector.xyz, PixelShaderGetLightVector( i.vWorldPosition_ProjPosZ.xyz, g_sLightInfo, 3 ) ) ), 128.0f ) * i.vLightFalloffCosine23.y * PixelShaderGetLightColor( g_sLightInfo, 3 ); + } + + //===============// + // Combine terms // + //===============// + float4 result; + + // Unlit iris, pupil, and sclera color + result.rgb = cIrisColor.rgb; + + // Add in slight cornea noise to help define raised cornea layer for close-ups + result.rgb += fCorneaNoise * 0.1f; + + // Diffuse light (Vertex lighting + extra iris caustic lighting) + result.rgb *= i.cVertexLight.rgb + cIrisLighting.rgb; + + // Environment map + result.rgb += cReflection.rgb * i.cVertexLight.rgb; + + // Local light glints + result.rgb += cSpecularHighlights.rgb; + + // Set alpha to 1.0 by default + result.a = 1.0; + +#if !defined( SHADER_MODEL_PS_2_0 ) + float fogFactor = CalcPixelFogFactor( g_fPixelFogType, g_FogParams, g_vCameraPosition.xyz, i.vWorldPosition_ProjPosZ.xyz, i.vWorldPosition_ProjPosZ.w ); + return FinalOutput( result, fogFactor, g_fPixelFogType, TONEMAP_SCALE_LINEAR ); +#else + float fogFactor = CalcPixelFogFactor( PIXEL_FOG_TYPE_NONE, g_FogParams, g_vCameraPosition.xyz, i.vWorldPosition_ProjPosZ.xyz, i.vWorldPosition_ProjPosZ.w ); + return FinalOutput( result, fogFactor, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_LINEAR ); +#endif + +} diff --git a/sp/src/materialsystem/stdshaders/SDK_eye_refract_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_eye_refract_vs20.fxc new file mode 100644 index 00000000..af975f99 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_eye_refract_vs20.fxc @@ -0,0 +1,217 @@ +//========= Copyright © 1996-2006, Valve Corporation, All rights reserved. ============// + +// STATIC: "INTRO" "0..1" +// STATIC: "HALFLAMBERT" "0..1" +// STATIC: "FLASHLIGHT" "0..1" +// STATIC: "LIGHTWARPTEXTURE" "0..1" + +// DYNAMIC: "COMPRESSED_VERTS" "0..1" +// DYNAMIC: "SKINNING" "0..1" +// DYNAMIC: "DOWATERFOG" "0..1" +// DYNAMIC: "DYNAMIC_LIGHT" "0..1" +// DYNAMIC: "STATIC_LIGHT" "0..1" +// DYNAMIC: "NUM_LIGHTS" "0..4" +// DYNAMIC: "MORPHING" "0..1" [vs30] + +#include "vortwarp_vs20_helper.h" + +static const bool g_bSkinning = SKINNING ? true : false; +static const int g_iFogType = DOWATERFOG; +static const bool g_bHalfLambert = HALFLAMBERT ? true : false; + +const float3 g_cEyeOrigin : register( SHADER_SPECIFIC_CONST_0 ); +const float4 g_vIrisProjectionU : register( SHADER_SPECIFIC_CONST_2 ); +const float4 g_vIrisProjectionV : register( SHADER_SPECIFIC_CONST_3 ); +const float4 g_vFlashlightPosition : register( SHADER_SPECIFIC_CONST_4 ); + +#if INTRO +const float4 g_vConst4 : register( SHADER_SPECIFIC_CONST_5 ); +#define g_vModelOrigin g_vConst4.xyz +#define g_flTime g_vConst4.w +#endif + +const float4 g_vFlashlightMatrixRow1 : register( SHADER_SPECIFIC_CONST_6 ); +const float4 g_vFlashlightMatrixRow2 : register( SHADER_SPECIFIC_CONST_7 ); +const float4 g_vFlashlightMatrixRow3 : register( SHADER_SPECIFIC_CONST_8 ); +const float4 g_vFlashlightMatrixRow4 : register( SHADER_SPECIFIC_CONST_9 ); + +#ifdef SHADER_MODEL_VS_3_0 +// NOTE: cMorphTargetTextureDim.xy = target dimensions, +// cMorphTargetTextureDim.z = 4tuples/morph +const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_10 ); +const float4 cMorphSubrect : register( SHADER_SPECIFIC_CONST_11 ); + +sampler2D morphSampler : register( D3DVERTEXTEXTURESAMPLER0, s0 ); +#endif + +struct VS_INPUT +{ + float4 vPos : POSITION; // Position + float4 vBoneWeights : BLENDWEIGHT; // Skin weights + float4 vBoneIndices : BLENDINDICES; // Skin indices + float4 vTexCoord0 : TEXCOORD0; // Base (sclera) texture coordinates + + // Position deltas + float3 vPosFlex : POSITION1; + +#ifdef SHADER_MODEL_VS_3_0 + float vVertexID : POSITION2; +#endif +}; + +struct VS_OUTPUT +{ + float4 projPos : POSITION; // Projection-space position +#if !defined( _X360 ) + float fog : FOG; // Fixed-function fog factor +#endif + float4 vAmbientOcclUv_fallbackCorneaUv : TEXCOORD0; // Base texture coordinate + float4 cVertexLight : TEXCOORD1; // Vertex-lit color (Note: w is used for flashlight pass) + float4 vTangentViewVector : TEXCOORD2; // Tangent view vector (Note: w is used for flashlight pass) + float4 vWorldPosition_ProjPosZ : TEXCOORD3; + float3 vWorldNormal : TEXCOORD4; // World-space normal + float3 vWorldTangent : TEXCOORD5; // World-space tangent + float4 vLightFalloffCosine01 : TEXCOORD6; // Light falloff and cosine terms for first two local lights + float4 vLightFalloffCosine23 : TEXCOORD7; // Light falloff and cosine terms for next two local lights + + float3 vWorldBinormal : COLOR0; // World-space normal +}; + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o; + + bool bDynamicLight = DYNAMIC_LIGHT ? true : false; + bool bStaticLight = STATIC_LIGHT ? true : false; + int nNumLights = NUM_LIGHTS; + + float4 vPosition = v.vPos; + +#if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING + ApplyMorph( v.vPosFlex, vPosition.xyz ); +#else + ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, v.vVertexID, float3( 0, 0, 0 ), vPosition.xyz ); +#endif + + // Transform the position + float3 vWorldPosition; + SkinPosition( g_bSkinning, vPosition, v.vBoneWeights, v.vBoneIndices, vWorldPosition ); + + // Note: I'm relying on the iris projection vector math not changing or this will break + float3 vEyeSocketUpVector = normalize( -g_vIrisProjectionV.xyz ); + float3 vEyeSocketLeftVector = normalize( -g_vIrisProjectionU.xyz ); + +#if INTRO + float3 dummy = float3( 0.0f, 0.0f, 0.0f ); + WorldSpaceVertexProcess( g_flTime, g_vModelOrigin, vWorldPosition, dummy, dummy, dummy ); +#endif + + o.vWorldPosition_ProjPosZ.xyz = vWorldPosition.xyz; + + // Transform into projection space + //vWorldPosition -= ( vWorldPosition - g_cEyeOrigin ) * 0.9; //Debug to visualize eye origin + float4 vProjPos = mul( float4( vWorldPosition, 1.0f ), cViewProj ); + o.projPos = vProjPos; + vProjPos.z = dot( float4( vWorldPosition, 1.0f ), cViewProjZ ); + + + o.vWorldPosition_ProjPosZ.w = vProjPos.z; + +#if !defined( _X360 ) + // Set fixed-function fog factor + o.fog = CalcFog( vWorldPosition, vProjPos, g_iFogType ); +#endif + + // Normal = (Pos - Eye origin) + float3 vWorldNormal = normalize( vWorldPosition.xyz - g_cEyeOrigin.xyz ); + o.vWorldNormal.xyz = vWorldNormal.xyz; + + // Tangent & binormal + /* + float3 vWorldBinormal = normalize( cross( vWorldNormal.xyz, vEyeSocketLeftVector.xyz ) ); + o.vWorldBinormal.xyz = vWorldBinormal.xyz * 0.5f + 0.5f; + + float3 vWorldTangent = normalize( cross( vWorldBinormal.xyz, vWorldNormal.xyz ) ); + o.vWorldTangent.xyz = vWorldTangent.xyz; + //*/ + + //* + float3 vWorldTangent = normalize( cross( vEyeSocketUpVector.xyz, vWorldNormal.xyz ) ); + o.vWorldTangent.xyz = vWorldTangent.xyz; + + float3 vWorldBinormal = normalize( cross( vWorldNormal.xyz, vWorldTangent.xyz ) ); + o.vWorldBinormal.xyz = vWorldBinormal.xyz * 0.5f + 0.5f; + //*/ + + float3 vWorldViewVector = normalize (vWorldPosition.xyz - cEyePos.xyz); + o.vTangentViewVector.xyz = Vec3WorldToTangentNormalized (vWorldViewVector.xyz, vWorldNormal.xyz, vWorldTangent.xyz, vWorldBinormal.xyz); + + // AV - I think this will effectively make the eyeball less rounded left to right to help vertext lighting quality + // AV - Note: This probably won't look good if put on an exposed eyeball + //float vNormalDotSideVec = -dot( vWorldNormal, g_vEyeballUp ) * 0.5f; + float vNormalDotSideVec = -dot( vWorldNormal, vEyeSocketLeftVector) * 0.5f; + float3 vBentWorldNormal = normalize(vNormalDotSideVec * vEyeSocketLeftVector + vWorldNormal); + + // Compute vertex lighting + o.cVertexLight.a = 0.0f; //Only used for flashlight pass + o.cVertexLight.rgb = DoLightingUnrolled( vWorldPosition, vBentWorldNormal, float3(0.0f, 0.0f, 0.0f), bStaticLight, bDynamicLight, g_bHalfLambert, nNumLights ); + + // Only interpolate ambient light for TF NPR lighting + bool bDoDiffuseWarp = LIGHTWARPTEXTURE ? true : false; + if ( bDoDiffuseWarp ) + { + if( bDynamicLight ) + { + o.cVertexLight.rgb = AmbientLight( vBentWorldNormal.xyz ); + } + else + { + o.cVertexLight.rgb = float3( 0.0f, 0.0f, 0.0f ); + } + } + +// NOTE: it appears that o.vLightFalloffCosine01 and o.vLightFalloffCosine23 are filled in even if +// we don't have enough lights, meaning we pass garbage to the pixel shader which then throws it away + + // Light falloff for first two local lights + o.vLightFalloffCosine01.x = VertexAttenInternal( vWorldPosition.xyz, 0 ); + o.vLightFalloffCosine01.y = VertexAttenInternal( vWorldPosition.xyz, 1 ); + o.vLightFalloffCosine01.z = CosineTermInternal( vWorldPosition.xyz, vWorldNormal.xyz, 0, g_bHalfLambert ); + o.vLightFalloffCosine01.w = CosineTermInternal( vWorldPosition.xyz, vWorldNormal.xyz, 1, g_bHalfLambert ); + + // Light falloff for next two local lights + o.vLightFalloffCosine23.x = VertexAttenInternal( vWorldPosition.xyz, 2 ); + o.vLightFalloffCosine23.y = VertexAttenInternal( vWorldPosition.xyz, 3 ); + o.vLightFalloffCosine23.z = CosineTermInternal( vWorldPosition.xyz, vWorldNormal.xyz, 2, g_bHalfLambert ); + o.vLightFalloffCosine23.w = CosineTermInternal( vWorldPosition.xyz, vWorldNormal.xyz, 3, g_bHalfLambert ); + + // Texture coordinates set by artists for ambient occlusion + o.vAmbientOcclUv_fallbackCorneaUv.xy = v.vTexCoord0.xy; + + // Cornea uv for ps.2.0 fallback + float2 vCorneaUv; // Note: Cornea texture is a cropped version of the iris texture + vCorneaUv.x = dot( g_vIrisProjectionU, float4( vWorldPosition, 1.0f ) ); + vCorneaUv.y = dot( g_vIrisProjectionV, float4( vWorldPosition, 1.0f ) ); + float2 vSphereUv = ( vCorneaUv.xy * 0.5f ) + 0.25f; + o.vAmbientOcclUv_fallbackCorneaUv.wz = vCorneaUv.xy; // Note: wz unpacks faster than zw in ps.2.0! + + // Step on the vertex light interpolator for the flashlight tex coords + bool bFlashlight = ( FLASHLIGHT != 0 ) ? true : false; + o.vTangentViewVector.w = 0.0f; + if ( bFlashlight ) + { + o.cVertexLight.x = dot( g_vFlashlightMatrixRow1.xyzw, float4( vWorldPosition, 1.0f ) ); + o.cVertexLight.y = dot( g_vFlashlightMatrixRow2.xyzw, float4( vWorldPosition, 1.0f ) ); + o.cVertexLight.z = dot( g_vFlashlightMatrixRow3.xyzw, float4( vWorldPosition, 1.0f ) ); + o.cVertexLight.w = dot( g_vFlashlightMatrixRow4.xyzw, float4( vWorldPosition, 1.0f ) ); + + o.vTangentViewVector.w = saturate( dot( vBentWorldNormal.xyz, normalize ( g_vFlashlightPosition.xyz - vWorldPosition.xyz ) ) ); // Flashlight N.L with modified normal + + // Half lambert version + //o.cVertexLight.z = dot( vBentWorldNormal.xyz, normalize ( g_vFlashlightPosition.xyz - vWorldPosition.xyz ) ); // Flashlight N.L with modified normal + //o.cVertexLight.z = ( o.cVertexLight.z * 0.5f ) + 0.5f; + //o.cVertexLight.z *= o.cVertexLight.z; + } + + return o; +} diff --git a/sp/src/materialsystem/stdshaders/SDK_eyes_flashlight_inc.fxc b/sp/src/materialsystem/stdshaders/SDK_eyes_flashlight_inc.fxc new file mode 100644 index 00000000..69316a39 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_eyes_flashlight_inc.fxc @@ -0,0 +1,92 @@ +//====== Copyright © 1996-2006, Valve Corporation, All rights reserved. ======= +// +// Purpose: +// +//============================================================================= + +#include "common_flashlight_fxc.h" +#include "shader_constant_register_map.h" + + +const float4 g_vShadowTweaks : register( PSREG_ENVMAP_TINT__SHADOW_TWEAKS ); + +sampler SpotSampler : register( s0 ); +sampler BaseTextureSampler : register( s1 ); +sampler IrisSampler : register( s3 ); + +#if FLASHLIGHTSHADOWS && (!SHADER_MODEL_PS_1_1) && (!SHADER_MODEL_PS_1_4) && (!SHADER_MODEL_PS_2_0) +sampler FlashlightDepthSampler : register( s4 ); +sampler RandomRotationSampler : register( s5 ); +#endif + +#if defined( SHADER_MODEL_PS_1_1 ) || defined ( SHADER_MODEL_PS_1_4 ) + +#else + const float4 g_FogParams : register( PSREG_FOG_PARAMS ); + const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT ); +#endif + +struct PS_INPUT +{ + float4 spotTexCoord : TEXCOORD0; + float2 baseTexCoord : TEXCOORD1; + float2 irisTexCoord : TEXCOORD3; +#if defined( SHADER_MODEL_PS_1_1 ) || defined ( SHADER_MODEL_PS_1_4 ) + float3 vertAtten : COLOR0; +#else + float3 vertAtten : TEXCOORD4; + float3 worldPos : TEXCOORD5; + float3 projPos : TEXCOORD7; +#endif +}; + +float4 main( PS_INPUT i ) : COLOR +{ +#if defined(SHADER_MODEL_PS_2_0) + float3 spotColor = tex2Dproj( SpotSampler, i.spotTexCoord.xyzw ) * cFlashlightColor; +#elif ( defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) ) + float3 vProjCoords = i.spotTexCoord.xyz / i.spotTexCoord.w; + float3 spotColor = tex2D( SpotSampler, vProjCoords ) * cFlashlightColor; +#else + float3 spotColor = tex2D( SpotSampler, i.spotTexCoord ); +#endif + + float4 baseSample = tex2D( BaseTextureSampler, i.baseTexCoord ); + float4 irisSample = tex2D( IrisSampler, i.irisTexCoord ); + + float3 outcolor = float3(1,1,1); + +#if !defined( SHADER_MODEL_PS_1_1 ) && !defined( SHADER_MODEL_PS_1_4 ) + if( i.spotTexCoord.w <= 0.0f ) + { + outcolor = float3(0,0,0); + } +#endif + + // Composite the iris and sclera together +#if defined( SHADER_MODEL_PS_1_1 ) || defined ( SHADER_MODEL_PS_1_4 ) + float3 albedo = lerp( baseSample.xyz, irisSample.xyz, irisSample.a ); +#else + float3 albedo = lerp( baseSample.xyz, irisSample.xyz * 0.5f, irisSample.a ); // dim down the iris in HDR +#endif + + // Do shadow depth mapping... +#if FLASHLIGHTSHADOWS && ( defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) ) + float flShadow = DoFlashlightShadow( FlashlightDepthSampler, RandomRotationSampler, vProjCoords, i.projPos.xy / i.projPos.z, FLASHLIGHTDEPTHFILTERMODE, g_vShadowTweaks, true ); + float flAttenuated = lerp( flShadow, 1.0f, g_vShadowTweaks.y ); // Blend between fully attenuated and not attenuated + flShadow = lerp( flAttenuated, flShadow, dot(i.vertAtten, float3(0.30f, 0.59f, 0.11f) ) ); // Blend between shadow and above, according to light attenuation + outcolor *= flShadow * spotColor * albedo; +#else + outcolor *= spotColor * albedo; +#endif + + // NOTE!! This has to be last to avoid loss of range. + outcolor *= i.vertAtten; +#if defined( SHADER_MODEL_PS_1_1 ) || defined ( SHADER_MODEL_PS_1_4 ) + return float4( outcolor, baseSample.a ); +#else + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, i.worldPos, i.projPos.z ); + return FinalOutput( float4( outcolor, 1.0f ), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR ); +#endif + +} diff --git a/sp/src/materialsystem/stdshaders/SDK_eyes_flashlight_ps11.fxc b/sp/src/materialsystem/stdshaders/SDK_eyes_flashlight_ps11.fxc new file mode 100644 index 00000000..25e0702e --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_eyes_flashlight_ps11.fxc @@ -0,0 +1,9 @@ +//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. ======= +// +// Purpose: +// +//============================================================================= + +#define HDRTYPE HDR_TYPE_NONE + +#include "eyes_flashlight_inc.fxc" diff --git a/sp/src/materialsystem/stdshaders/SDK_eyes_flashlight_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_eyes_flashlight_ps2x.fxc new file mode 100644 index 00000000..eb00fc04 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_eyes_flashlight_ps2x.fxc @@ -0,0 +1,15 @@ +//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. ======= +// +// Purpose: +// +//============================================================================= + +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps20b] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps30] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..0" [ps20b] [XBOX] + +// DYNAMIC: "PIXELFOGTYPE" "0..1" +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps20b] +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps30] + +#include "eyes_flashlight_inc.fxc" diff --git a/sp/src/materialsystem/stdshaders/SDK_eyes_flashlight_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_eyes_flashlight_vs20.fxc new file mode 100644 index 00000000..e2e37dc1 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_eyes_flashlight_vs20.fxc @@ -0,0 +1,145 @@ +// ------------------------------------------------------------------------------ +// $cLight0Pos = world space light position +// $SHADER_SPECIFIC_CONST_1 = spotlight projection +// $SHADER_SPECIFIC_CONST_2 = spotlight projection +// $SHADER_SPECIFIC_CONST_3 = spotlight projection +// $SHADER_SPECIFIC_CONST_4 = spotlight projection +// $SHADER_SPECIFIC_CONST_5 = far z +// $SHADER_SPECIFIC_CONST_6 = eyeball origin +// $SHADER_SPECIFIC_CONST_7 = eyeball up * 0.5 +// $SHADER_SPECIFIC_CONST_8 = iris projection U +// $SHADER_SPECIFIC_CONST_9 = iris projection V +// ------------------------------------------------------------------------------ + +// DYNAMIC: "COMPRESSED_VERTS" "0..1" +// DYNAMIC: "SKINNING" "0..1" +// DYNAMIC: "DOWATERFOG" "0..1" +// DYNAMIC: "MORPHING" "0..1" [vs30] + +#include "common_vs_fxc.h" + +static const bool g_bSkinning = SKINNING ? true : false; +static const int g_FogType = DOWATERFOG; + +const float4 cLightPosition : register( SHADER_SPECIFIC_CONST_0 ); +const float4 cSpotlightProj1 : register( SHADER_SPECIFIC_CONST_1 ); +const float4 cSpotlightProj2 : register( SHADER_SPECIFIC_CONST_2 ); +const float4 cSpotlightProj3 : register( SHADER_SPECIFIC_CONST_3 ); +const float4 cSpotlightProj4 : register( SHADER_SPECIFIC_CONST_4 ); +const float4 cFlashlighAtten : register( SHADER_SPECIFIC_CONST_5 ); // const, linear, quadratic & farZ +const float4 cIrisProjectionU : register( SHADER_SPECIFIC_CONST_8 ); +const float4 cIrisProjectionV : register( SHADER_SPECIFIC_CONST_9 ); + +#ifdef SHADER_MODEL_VS_3_0 +// NOTE: cMorphTargetTextureDim.xy = target dimensions, +// cMorphTargetTextureDim.z = 4tuples/morph +const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_10 ); +const float4 cMorphSubrect : register( SHADER_SPECIFIC_CONST_11 ); + +sampler2D morphSampler : register( D3DVERTEXTEXTURESAMPLER0, s0 ); +#endif + +struct VS_INPUT +{ + float4 vPos : POSITION; // Position + float4 vBoneWeights : BLENDWEIGHT; // Skin weights + float4 vBoneIndices : BLENDINDICES; // Skin indices + float4 vNormal : NORMAL; + float4 vTexCoord0 : TEXCOORD0; // Base (sclera) texture coordinates + + // Position and normal/tangent deltas + float3 vPosFlex : POSITION1; + float3 vNormalFlex : NORMAL1; +#ifdef SHADER_MODEL_VS_3_0 + float vVertexID : POSITION2; +#endif +}; + +struct VS_OUTPUT +{ + float4 projPos : POSITION; // Projection-space position +#if !defined( _X360 ) + float fog : FOG; // Fixed-function fog factor +#endif + float4 spotTexCoord : TEXCOORD0; // Spotlight texture coordinates + float2 baseTexCoord : TEXCOORD1; // Base texture coordinates + float2 irisTexCoord : TEXCOORD3; // Iris texture coordinates + float3 vertAtten : TEXCOORD4; // vertex attenuation + float3 worldPos : TEXCOORD5; + float3 projPosXYZ : TEXCOORD7; +}; + + +float RemapValClamped_01( float val, float A, float B ) +{ + float cVal = (val - A) / (B - A); + cVal = saturate( cVal ); + return cVal; +} + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + + float4 vPosition = v.vPos; + float3 vNormal; + DecompressVertex_Normal( v.vNormal, vNormal ); + +#if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING + ApplyMorph( v.vPosFlex, v.vNormalFlex, vPosition.xyz, vNormal ); +#else + ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, v.vVertexID, float3( 0, 0, 0 ), vPosition.xyz, vNormal ); +#endif + + // Perform skinning + float3 worldNormal, worldPos; + SkinPositionAndNormal( + g_bSkinning, + vPosition, vNormal, + v.vBoneWeights, v.vBoneIndices, + worldPos, worldNormal ); + + worldNormal = normalize( worldNormal ); + + // Transform into projection space + float4 projPos = mul( float4( worldPos, 1 ), cViewProj ); + o.projPos = projPos; + o.projPosXYZ = projPos.xyz; + o.worldPos = worldPos.xyz; + +#if !defined( _X360 ) + // Set fixed-function fog factor + o.fog = CalcFog( worldPos, o.projPos, g_FogType ); +#endif + + // Base texture coordinates + o.baseTexCoord = v.vTexCoord0; + + // Spotlight texture coordinates + o.spotTexCoord.x = dot( cSpotlightProj1, float4(worldPos, 1) ); + o.spotTexCoord.y = dot( cSpotlightProj2, float4(worldPos, 1) ); + o.spotTexCoord.z = dot( cSpotlightProj3, float4(worldPos, 1) ); + o.spotTexCoord.w = dot( cSpotlightProj4, float4(worldPos, 1) ); + + // Compute vector to light + float3 vWorldPosToLightVector = cLightPosition.xyz - worldPos; + + float3 vDistAtten = float3(1, 1, 1); + vDistAtten.z = dot( vWorldPosToLightVector, vWorldPosToLightVector ); // distsquared + vDistAtten.y = rsqrt( vDistAtten.z ); // 1 / dist + + float flDist = vDistAtten.z * vDistAtten.y; // dist + vDistAtten.z = 1.0f / vDistAtten.z; // 1 / distsquared + + float fFarZ = cFlashlighAtten.w; + + float endFalloffFactor = RemapValClamped_01( flDist, fFarZ, 0.6 * fFarZ ); + o.vertAtten.xyz = endFalloffFactor * dot( vDistAtten, cFlashlighAtten.xyz ); + + o.vertAtten *= dot( normalize( vWorldPosToLightVector ), worldNormal ); + + o.irisTexCoord.x = dot( cIrisProjectionU, float4(worldPos, 1) ); + o.irisTexCoord.y = dot( cIrisProjectionV, float4(worldPos, 1) ); + + return o; +} \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/SDK_eyes_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_eyes_ps2x.fxc new file mode 100644 index 00000000..aad7afce --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_eyes_ps2x.fxc @@ -0,0 +1,68 @@ +//====== Copyright © 1996-2006, Valve Corporation, All rights reserved. ======= +// +// Purpose: +// +//============================================================================= + +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps30] +// DYNAMIC: "PIXELFOGTYPE" "0..1" + +#include "common_ps_fxc.h" +#include "shader_constant_register_map.h" + +sampler BaseTextureSampler : register( s0 ); +sampler IrisSampler : register( s1 ); +sampler GlintSampler : register( s2 ); +const float4 cEyeScalars : register( c0 ); // { Dilation, ambient, x, x } + +const float4 g_FogParams : register( PSREG_FOG_PARAMS ); +const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT ); + +struct PS_INPUT +{ + float2 baseTexCoord : TEXCOORD0; + float2 irisTexCoord : TEXCOORD1; + float2 glintTexCoord : TEXCOORD2; + float3 vertAtten : TEXCOORD3; + + float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog +}; + +#define fDilationFactor cEyeScalars.x +#define fGlintDamping cEyeScalars.y + +float4 main( PS_INPUT i ) : COLOR +{ + float4 baseSample = tex2D( BaseTextureSampler, i.baseTexCoord ); + float4 glintSample = tex2D( GlintSampler, i.glintTexCoord ); +/* + // Dilate the pupil/iris texture (1 is max dilation, 0 is none) + float2 biasedCoords = i.irisTexCoord * 2.0f - 1.0f; // -1 to +1 range + float fDilatability = saturate(0.8f - sqrt(dot(biasedCoords, biasedCoords) )); // 1 in the center, fading out to 0 at 0.8 from center, since irises are inset into maps + float2 scaledCoords = biasedCoords * (1 + fDilatability); // Maximal dilation + + // Blend undilated and maximally dilated based upon dilation factor + float2 dilatedCoords = lerp( scaledCoords, biasedCoords, 1.0f-saturate(cDilationFactor.x)); + dilatedCoords = dilatedCoords * 0.5f + 0.5f; // Back to 0..1 range +*/ + + float4 irisSample = tex2D( IrisSampler, i.irisTexCoord ); // Sample the iris map using dilated coordinates + + float4 result; + result.rgb = lerp( baseSample.rgb, irisSample.rgb, irisSample.a ); + result.rgb *= i.vertAtten; + result.rgb += glintSample.rgb * fGlintDamping; + result.a = baseSample.a; + + bool bWriteDepthToAlpha = false; + + // ps_2_b and beyond +#if !(defined(SHADER_MODEL_PS_1_1) || defined(SHADER_MODEL_PS_1_4) || defined(SHADER_MODEL_PS_2_0)) + bWriteDepthToAlpha = WRITE_DEPTH_TO_DESTALPHA != 0; +#endif + + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); + return FinalOutput( result, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, bWriteDepthToAlpha, i.worldPos_projPosZ.w ); +} diff --git a/sp/src/materialsystem/stdshaders/SDK_flashlight_ps11.fxc b/sp/src/materialsystem/stdshaders/SDK_flashlight_ps11.fxc new file mode 100644 index 00000000..07e36a41 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_flashlight_ps11.fxc @@ -0,0 +1,69 @@ +//====== Copyright ? 1996-2004, Valve Corporation, All rights reserved. ======= +// +// Purpose: +// +//============================================================================= + +// STATIC: "NORMALMAP" "0..1" +// STATIC: "NOCULL" "0..1" + +#include "common_ps_fxc.h" + +sampler SpotSampler : register( s0 ); +sampler BaseTextureSampler : register( s1 ); +sampler NormalizingCubemapSampler : register( s2 ); +// use a normalizing cube map here if we aren't normal mapping +#if NORMALMAP +sampler NormalMapSampler : register( s3 ); +#else +sampler NormalizingCubemapSampler2 : register( s3 ); +#endif + +static const HALF g_OverbrightFactor = 2.0f; + +struct PS_INPUT +{ + float4 spotTexCoord : TEXCOORD0; + float2 baseTexCoord : TEXCOORD1; +#if NORMALMAP + float3 tangentPosToLightVector : TEXCOORD2; + float2 normalMapTexCoord : TEXCOORD3; +#else + float3 worldPosToLightVector : TEXCOORD2; + float3 normal : TEXCOORD3; +#endif + float4 vertAtten : COLOR0; +}; + +float4 main( PS_INPUT i ) : COLOR +{ +#if NORMALMAP + float3 normal = tex2D( NormalMapSampler, i.normalMapTexCoord ) * 2.0f - 1.0f; +#else + float3 normal = texCUBE( NormalizingCubemapSampler2, i.normal ) * 2.0f - 1.0f; +#endif + + float3 spotColor = tex2D( SpotSampler, i.spotTexCoord ); + float4 baseSample = tex2D( BaseTextureSampler, i.baseTexCoord ); + float3 baseColor = baseSample.xyz; +#if NORMALMAP + // wrap this! + float3 tangentPosToLightVector = texCUBE( NormalizingCubemapSampler, i.tangentPosToLightVector ) * 2.0f - 1.0f; + float nDotL = saturate( dot( tangentPosToLightVector, normal ) ); +#else + float3 worldPosToLightVector = texCUBE( NormalizingCubemapSampler, i.worldPosToLightVector ) * 2.0f - 1.0f; + float nDotL = saturate( dot( worldPosToLightVector, normal ) ); +#endif + float3 outcolor; + + outcolor = spotColor * baseColor * g_OverbrightFactor; + +#if !NOCULL + outcolor *= nDotL; +#endif + + // NOTE!! This has to be last to avoid loss of range. + outcolor *= i.vertAtten; + + return float4( outcolor.xyz, baseSample.a * i.vertAtten.a ); +} \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/SDK_flashlight_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_flashlight_ps2x.fxc new file mode 100644 index 00000000..0e9d5d9f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_flashlight_ps2x.fxc @@ -0,0 +1,238 @@ +//====== Copyright c 1996-2004, Valve Corporation, All rights reserved. ======= +// +// Purpose: +// +//============================================================================= + + + +// STATIC: "NORMALMAP" "0..2" +// STATIC: "NORMALMAP2" "0..1" +// STATIC: "WORLDVERTEXTRANSITION" "0..1" +// STATIC: "SEAMLESS" "0..1" +// STATIC: "DETAILTEXTURE" "0..1" +// STATIC: "DETAIL_BLEND_MODE" "0..1" +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps20b] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps30] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..0" [ps20b] [XBOX] + +// DYNAMIC: "PIXELFOGTYPE" "0..1" +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps20b] +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps30] + +// SKIP: !$WORLDVERTEXTRANSITION && $NORMALMAP2 +// SKIP: !$NORMALMAP && $NORMALMAP2 +// SKIP: !$DETAILTEXTURE && ( $DETAIL_BLEND_MODE != 0 ) + +#include "shader_constant_register_map.h" +#include "common_flashlight_fxc.h" +#include "common_lightmappedgeneric_fxc.h" + +const float4 g_vShadowTweaks : register( PSREG_ENVMAP_TINT__SHADOW_TWEAKS ); +const float4 g_FogParams : register( PSREG_FOG_PARAMS ); +const float4 g_EyePos : register( PSREG_EYEPOS_SPEC_EXPONENT ); +const float4 g_FlashlightAttenuation : register( PSREG_FLASHLIGHT_ATTENUATION ); +const float4 g_DetailConstants : register( c0 ); +const float3 g_FlashLightPos : register( PSREG_FRESNEL_SPEC_PARAMS ); + +sampler SpotSampler : register( s0 ); +sampler BaseTextureSampler : register( s1 ); +sampler NormalizingCubemapSampler : register( s2 ); + +// use a normalizing cube map here if we aren't normal mapping +sampler BumpMapSampler : register( s3 ); +sampler BaseTextureSampler2 : register( s4 ); + +#ifdef WORLDVERTEXTRANSITION +sampler NormalMap2Sampler : register( s6 ); +#endif + +#if DETAILTEXTURE +sampler DetailSampler : register( s8 ); +#endif + +#if FLASHLIGHTSHADOWS && ( defined( SHADER_MODEL_PS_2_B ) || defined( SHADER_MODEL_PS_3_0 ) ) +sampler RandomRotationSampler : register( s5 ); // Random rotation sampler +sampler FlashlightDepthSampler : register( s7 ); +#endif + +struct PS_INPUT +{ + float4 spotTexCoord : TEXCOORD0; +#if SEAMLESS + float3 SeamlessTexCoord : TEXCOORD1; +#else + float2 baseTexCoord : TEXCOORD1; +#endif +#if NORMALMAP + float3 tangentPosToLightVector : TEXCOORD2; + float2 normalMapTexCoord : TEXCOORD3; +#else + float3 worldPosToLightVector : TEXCOORD2; + float3 normal : TEXCOORD3; +#endif + + float2 detailCoords : TEXCOORD4; + float4 worldPos_worldTransition : TEXCOORD5; + float3 projPos : TEXCOORD6; + float4 fogFactorW : TEXCOORD7; +}; + + + +float4 SampleNormal( sampler s, PS_INPUT i ) +{ +#if SEAMLESS + float4 szy=tex2D( s, i.SeamlessTexCoord.zy ); + float4 sxz=tex2D( s, i.SeamlessTexCoord.xz ); + float4 syx=tex2D( s, i.SeamlessTexCoord.xy ); + return i.fogFactorW.r*szy + i.fogFactorW.g*sxz + i.fogFactorW.b*syx; +#else +#if NORMALMAP + return tex2D( s, i.normalMapTexCoord.xy); +#else + return float4(0,0,1,1); +#endif +#endif + +} + +float4 main( PS_INPUT i ) : COLOR +{ + bool bBase2 = WORLDVERTEXTRANSITION ? true : false; + bool bBump = (NORMALMAP != 0) ? true : false; + + // Do spot stuff early since we can bail out + float3 spotColor = float3(0,0,0); + float3 vProjCoords = i.spotTexCoord.xyz / i.spotTexCoord.w; + +#if ( defined( _X360 ) ) + + float3 ltz = vProjCoords.xyz < float3( 0.0f, 0.0f, 0.0f ); + float3 gto = vProjCoords.xyz > float3( 1.0f, 1.0f, 1.0f ); + + [branch] + if ( dot(ltz + gto, float3(1,1,1)) > 0 ) + { + clip (-1); + return float4(0,0,0,0); + } + else + { + spotColor = tex2D( SpotSampler, vProjCoords ); + + [branch] + if ( dot(spotColor.xyz, float3(1,1,1)) <= 0 ) + { + clip(-1); + return float4(0,0,0,0); + } + else + { +#else + spotColor = tex2D( SpotSampler, vProjCoords ); +#endif + + float4 baseColor = 0.0f; + float4 baseColor2 = 0.0f; + float4 vNormal = float4(0, 0, 1, 1); + float3 baseTexCoords = float3(0,0,0); + +#if SEAMLESS + baseTexCoords = i.SeamlessTexCoord.xyz; +#else + baseTexCoords.xy = i.baseTexCoord.xy; +#endif + + GetBaseTextureAndNormal( BaseTextureSampler, BaseTextureSampler2, BumpMapSampler, bBase2, bBump, baseTexCoords, i.fogFactorW.xyz, baseColor, baseColor2, vNormal ); + +#if WORLDVERTEXTRANSITION + float lerpAlpha = 1-i.worldPos_worldTransition.a; +#endif + +#if ( NORMALMAP == 0 ) + vNormal.xyz = normalize( i.normal.xyz ); +#endif + +#if ( NORMALMAP == 1 ) + vNormal.xyz = vNormal.xyz * 2.0f - 1.0f; // signed + +# if NORMALMAP2 + float3 normal2 = SampleNormal( NormalMap2Sampler, i ) * 2.0f - 1.0f; + vNormal.xyz = lerp( normal2, vNormal.xyz, lerpAlpha ); +# endif +#endif + +// ssbump +#if ( NORMALMAP == 2 ) + +# if NORMALMAP2 + float3 normal2 = SampleNormal( NormalMap2Sampler, i ); + vNormal.xyz = lerp( normal2, vNormal.xyz, lerpAlpha ); +# endif +#else + // Normalize normal after all of the lerps above (including the tri/bilinear texel fetches) + vNormal.xyz = normalize( vNormal.xyz ); +#endif + + spotColor.rgb *= cFlashlightColor.rgb; + + // Compute per-pixel distance attenuation + float3 delta = g_FlashLightPos - i.worldPos_worldTransition.xyz; + float distSquared = dot( delta, delta ); + float dist = sqrt( distSquared ); + float farZ = g_FlashlightAttenuation.w; + float endFalloffFactor = RemapValClamped( dist, farZ, 0.6f * farZ, 0.0f, 1.0f ); + float flAtten = saturate(endFalloffFactor * dot( g_FlashlightAttenuation.xyz, float3( 1.0f, 1.0f/dist, 1.0f/distSquared ) ) ); + +#if FLASHLIGHTSHADOWS && ( defined( SHADER_MODEL_PS_2_B ) || defined( SHADER_MODEL_PS_3_0 ) ) + float flShadow = DoFlashlightShadow( FlashlightDepthSampler, RandomRotationSampler, vProjCoords, i.projPos.xy / i.projPos.z, FLASHLIGHTDEPTHFILTERMODE, g_vShadowTweaks, false ); + float flAttenuated = lerp( flShadow, 1.0f, g_vShadowTweaks.y ); // Blend between fully attenuated and not attenuated + flShadow = saturate(lerp( flAttenuated, flShadow, flAtten )); // Blend between shadow and above, according to light attenuation + spotColor *= flShadow; +#endif + +#if WORLDVERTEXTRANSITION && !defined( SHADER_MODEL_PS_2_0 ) + baseColor.xyz = lerp( baseColor2.xyz, baseColor.xyz, lerpAlpha ); +#endif + +#if DETAILTEXTURE + float4 detailColor = float4( g_DetailConstants.xyz, 1.0f ) * tex2D( DetailSampler, i.detailCoords ); + float4 vBase = TextureCombine( float4(baseColor.xyz, 1.0f), detailColor, DETAIL_BLEND_MODE, g_DetailConstants.w ); + baseColor.xyz = vBase.xyz; +#endif + +#if NORMALMAP == 0 + float3 worldPosToLightVector = texCUBE( NormalizingCubemapSampler, i.worldPosToLightVector ) * 2.0f - 1.0f; + float nDotL = dot( worldPosToLightVector, vNormal.xyz ); +#endif + +#if NORMALMAP == 1 + // flashlightfixme: wrap this! + float3 tangentPosToLightVector = texCUBE( NormalizingCubemapSampler, i.tangentPosToLightVector ) * 2.0f - 1.0f; + float nDotL = dot( tangentPosToLightVector, vNormal.xyz ); +#endif + +#if NORMALMAP == 2 + float3 tangentPosToLightVector = normalize( i.tangentPosToLightVector ); + + float nDotL = + vNormal.x*dot( tangentPosToLightVector, bumpBasis[0]) + + vNormal.y*dot( tangentPosToLightVector, bumpBasis[1]) + + vNormal.z*dot( tangentPosToLightVector, bumpBasis[2]); +#endif + + float3 outColor; + outColor = spotColor * baseColor.xyz * saturate( nDotL ); + outColor *= flAtten; + + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.z, i.worldPos_worldTransition.z, i.projPos.z ); + return FinalOutput( float4(outColor, baseColor.a) , fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR ); + + // so we can jump over all of the above +#if ( defined( _X360 ) ) + } + } +#endif + +} \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/SDK_flesh_interior_blended_pass_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_flesh_interior_blended_pass_ps2x.fxc new file mode 100644 index 00000000..3e288e56 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_flesh_interior_blended_pass_ps2x.fxc @@ -0,0 +1,127 @@ +//========= Copyright © 1996-2006, Valve Corporation, All rights reserved. ============// +// Includes ======================================================================================= +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] +#include "common_vertexlitgeneric_dx9.h" + +// Texture Samplers =============================================================================== +sampler g_tBaseSampler : register( s0 ); +sampler g_tNoiseSampler : register( s1 ); +sampler g_tBorder1DSampler : register( s2 ); +sampler g_tNormalSampler : register( s3 ); +sampler g_tSubsurfaceSampler: register( s4 ); +sampler g_tCubeSampler : register( s5 ); + +// Shaders Constants and Globals ================================================================== +const float3 g_cSubsurfaceTint : register( c0 ); +const float2 g_flBorderWidth : register( c1 ); //{ 1.0f / g_flBorderWidthFromVmt, ( 1.0f / g_flBorderWidthFromVmt ) - 1.0f }; +const float g_flBorderSoftness : register( c2 ); +const float3 g_cBorderTint : register( c3 ); +const float g_flGlobalOpacity : register( c4 ); +const float g_flGlossBrightness : register( c5 ); + +// Interpolated values ============================================================================ +struct PS_INPUT +{ + float2 vTexCoord0 : TEXCOORD0; + float2 flDistanceToEffectCenter_flFresnelEffect : TEXCOORD1; + float4 vNoiseTexCoord : TEXCOORD2; + float3 vTangentViewVector : TEXCOORD3; + float3 cVertexLight : TEXCOORD4; + float3x3 mTangentSpaceTranspose : TEXCOORD5; + // second row : TEXCOORD6; + // third row : TEXCOORD7; +}; + +// Main =========================================================================================== +float4 main( PS_INPUT i ) : COLOR +{ + // Color texture + float4 cBaseColor = tex2D( g_tBaseSampler, i.vTexCoord0.xy ); + float flFleshMaskFromTexture = cBaseColor.a; + + // Subsurface colors + float4 cSubsurfaceColor = tex2D( g_tSubsurfaceSampler, i.vTexCoord0.xy ); + cBaseColor.rgb += cBaseColor.rgb * cSubsurfaceColor.rgb * g_cSubsurfaceTint.rgb; + + // Scroll noise textures to ripple border of opening + float flNoise0 = tex2D( g_tNoiseSampler, i.vNoiseTexCoord.xy ).g; // Use green so we can DXT1 if we want + float flNoise1 = tex2D( g_tNoiseSampler, i.vNoiseTexCoord.wz ).g; // Use green so we can DXT1 if we want + float flNoise = ( flNoise0 + flNoise1 ) * 0.5f; + + // Generate 0-1 mask from distance computed in the VS + float flClampedInputMask = 0.0f; + flClampedInputMask = 1.0f - saturate( i.flDistanceToEffectCenter_flFresnelEffect.x ); + flClampedInputMask *= i.flDistanceToEffectCenter_flFresnelEffect.y; + flClampedInputMask *= flFleshMaskFromTexture; + + // Noise mask - Only apply noise around border of sphere + float flBorderMask = saturate( ( 1.0f - flClampedInputMask ) * g_flBorderWidth.x - g_flBorderWidth.y ); + float flNoiseMask = 1.0f - abs( ( flBorderMask * 2.0f ) - 1.0f ); + + // This is used to lerp in the 1D border texture over the flesh color + float flBorderMaskWithNoise = ( 1.0f - smoothstep( flNoiseMask - g_flBorderSoftness, flNoiseMask + g_flBorderSoftness, flNoise.r ) ) * flNoiseMask; + + // Border color + float vBorderUv = ( sign( flBorderMask - 0.5 ) * (1.0f - pow( flBorderMaskWithNoise, 4.0f )) * 0.5f ) + 0.5f; + float4 cBorderColor = 2.0f * tex2D( g_tBorder1DSampler, vBorderUv ); + cBorderColor.rgb *= g_cBorderTint; + cBorderColor.rgb *= flNoise; + + // Normal map + float4 vNormalMapValue = tex2D( g_tNormalSampler, i.vTexCoord0.xy ); + float3 vTangentNormal = ( vNormalMapValue.xyz * 2.0f ) - 1.0f; + vTangentNormal.xy += ( flNoise * 1.5f ) - 0.75f; // NOTE: This will denormalize the normal. + //float3 vWorldNormal = mul( i.mTangentSpaceTranspose, vTangentNormal.xyz ); + + // Specular gloss layer + float3 vTangentReflectionVector = reflect( i.vTangentViewVector.xyz, vTangentNormal.xyz ); + //vTangentReflectionVector.xy += ( flNoise * 1.5f ) - 0.75f; + float3 vWorldReflectionVector = mul( i.mTangentSpaceTranspose, vTangentReflectionVector.xyz ); + float3 cGlossLayer = ENV_MAP_SCALE * texCUBE( g_tCubeSampler, vWorldReflectionVector.xyz ).rgb; + cGlossLayer.rgb *= g_flGlossBrightness; + + // Gloss mask is just hard-coded fresnel for now + float flGlossMask = pow( saturate( dot( vTangentNormal.xyz, -i.vTangentViewVector.xyz ) ), 8.0f ); + + // Opacity + float flOpacity = 1.0f; + flOpacity = max( flBorderMaskWithNoise, step( flBorderMask, 0.5f ) ); + + // Apply global opacity + flOpacity *= g_flGlobalOpacity; + + //===============// + // Combine terms // + //===============// + float4 result; + result.rgb = cBaseColor.rgb * i.cVertexLight.rgb; + result.rgb += cGlossLayer.rgb * flGlossMask; + result.rgb *= pow( 1.0f - flBorderMaskWithNoise, 2.0f ); // Darken near border + result.rgb = lerp( result.rgb, cBorderColor.rgb, saturate( vBorderUv * 2.0f ) ); // bring in transition 1D texture + + //result.rgb = flClampedInputMask; + //result.rgb = flBorderMask; + //result.rgb = saturate( flClampedInputMask * 2.0f ); + //result.rgb = i.flDistanceToEffectCenter_flFresnelEffect.x;// * i.flDistanceToEffectCenter_flFresnelEffect.y; + //result.rgb = i.flDistanceToEffectCenter_flFresnelEffect.y * g_flBorderWidth.x - g_flBorderWidth.y; + //result.rgb = flNoiseMask; + //result.rgb = flBorderMaskWithNoise; + //result.rgb = flOpacity; + //result.rgb = flBorderUv; + //result.rgb = cBorderColor; + //result.rgb = -i.vTangentViewVector.z; + //result.rgb = vNormalMapValue.xyz; + //result.rgb = vTangentNormal.xyz; + //result.rgb = flGlossLayer; + //result.rgb = i.cVertexLight.rgb; + //result.rgb = texCUBE( g_tCubeSampler, vTangentNormal.xyz ).rgb; + //result.rgb = i.vTangentViewVector.x; + //result.rgb = cGlossLayer.rgb; + + // Set alpha for blending + result.a = flOpacity; + //result.a = 1.0f; + + return FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_LINEAR ); +} diff --git a/sp/src/materialsystem/stdshaders/SDK_flesh_interior_blended_pass_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_flesh_interior_blended_pass_vs20.fxc new file mode 100644 index 00000000..2a361b01 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_flesh_interior_blended_pass_vs20.fxc @@ -0,0 +1,155 @@ +//========= Copyright © 1996-2006, Valve Corporation, All rights reserved. ============// + +// STATIC: "HALFLAMBERT" "0..1" +// STATIC: "USE_STATIC_CONTROL_FLOW" "0..1" [vs20] + +// DYNAMIC: "COMPRESSED_VERTS" "0..1" +// DYNAMIC: "SKINNING" "0..1" +// DYNAMIC: "DOWATERFOG" "0..1" +// DYNAMIC: "DYNAMIC_LIGHT" "0..1" +// DYNAMIC: "STATIC_LIGHT" "0..1" +// DYNAMIC: "NUM_LIGHTS" "0..2" [vs20] + +// If using static control flow on Direct3D, we should use the NUM_LIGHTS=0 combo +// SKIP: $USE_STATIC_CONTROL_FLOW && ( $NUM_LIGHTS > 0 ) [vs20] + +// Includes +#include "common_vs_fxc.h" + +// Globals +static const int g_iFogType = DOWATERFOG; +static const bool g_bHalfLambert = HALFLAMBERT ? true : false; +static const bool g_bSkinning = SKINNING ? true : false; + +const float4 g_vConst0 : register( SHADER_SPECIFIC_CONST_0 ); +#define g_flTime g_vConst0.x +#define g_flNoiseUvScroll g_vConst0.y +#define g_flBorderNoiseScale g_vConst0.z +#define g_flDebugForceFleshOn g_vConst0.w + +const float4 g_vEffectCenterOoRadius1 : register( SHADER_SPECIFIC_CONST_1 ); //= { -295.0f, -5.0f, 40.0f, 1.0f/20.0f }; +const float4 g_vEffectCenterOoRadius2 : register( SHADER_SPECIFIC_CONST_2 ); //= { -295.0f, 15.0f, 40.0f, 1.0f/10.0f }; +const float4 g_vEffectCenterOoRadius3 : register( SHADER_SPECIFIC_CONST_3 ); //= { -295.0f, 35.0f, 40.0f, 1.0f/10.0f }; +const float4 g_vEffectCenterOoRadius4 : register( SHADER_SPECIFIC_CONST_4 ); //= { -295.0f, 55.0f, 40.0f, 1.0f/10.0f }; + +// Structs +struct VS_INPUT +{ + float4 vPos : POSITION; // Position + float4 vNormal : NORMAL; // Normal + float4 vBoneWeights : BLENDWEIGHT; // Skin weights + float4 vBoneIndices : BLENDINDICES; // Skin indices + float4 vTexCoord0 : TEXCOORD0; // Base texture coordinates + float3 vPosFlex : POSITION1; // Delta positions for flexing + float4 vTangent : TANGENT; +}; + +struct VS_OUTPUT +{ + float4 vProjPosition : POSITION; // Projection-space position + float2 vTexCoord0 : TEXCOORD0; + float2 flDistanceToEffectCenter_flFresnelEffect : TEXCOORD1; + float4 vNoiseTexCoord : TEXCOORD2; + float3 vTangentViewVector : TEXCOORD3; + float3 cVertexLight : TEXCOORD4; + float3x3 mTangentSpaceTranspose : TEXCOORD5; + // second row : TEXCOORD6; + // third row : TEXCOORD7; + +}; + +// Main +VS_OUTPUT main( const VS_INPUT i ) +{ + VS_OUTPUT o; + + // Flexes coming in from a separate stream (contribution masked by cFlexScale.x) + float4 vObjPosition = i.vPos; + vObjPosition.xyz += i.vPosFlex.xyz * cFlexScale.x; + + float3 vObjNormal; + float4 vObjTangent; + DecompressVertex_NormalTangent( i.vNormal, i.vTangent, vObjNormal, vObjTangent ); + + // Transform the position + float3 vWorldPosition = { 0.0f, 0.0f, 0.0f }; + float3 vWorldNormal = { 0.0f, 0.0f, 0.0f }; + float3 vWorldTangent = { 0.0f, 0.0f, 0.0f }; + float3 vWorldBinormal = { 0.0f, 0.0f, 0.0f }; + SkinPositionNormalAndTangentSpace( g_bSkinning, vObjPosition, vObjNormal, vObjTangent, i.vBoneWeights, i.vBoneIndices, vWorldPosition, vWorldNormal, vWorldTangent, vWorldBinormal ); + + // Transform into projection space + float4 vProjPosition = mul( float4( vWorldPosition, 1.0f ), cViewProj ); + o.vProjPosition = vProjPosition; + + // Pass through tex coords + o.vTexCoord0.xy = i.vTexCoord0.xy; + + // Store the closest effect intensity + o.flDistanceToEffectCenter_flFresnelEffect.x = 9999.0f; // A very large distance + o.flDistanceToEffectCenter_flFresnelEffect.x = min( o.flDistanceToEffectCenter_flFresnelEffect.x, length( vWorldPosition.xyz - g_vEffectCenterOoRadius1.xyz ) * g_vEffectCenterOoRadius1.w ); + o.flDistanceToEffectCenter_flFresnelEffect.x = min( o.flDistanceToEffectCenter_flFresnelEffect.x, length( vWorldPosition.xyz - g_vEffectCenterOoRadius2.xyz ) * g_vEffectCenterOoRadius2.w ); + o.flDistanceToEffectCenter_flFresnelEffect.x = min( o.flDistanceToEffectCenter_flFresnelEffect.x, length( vWorldPosition.xyz - g_vEffectCenterOoRadius3.xyz ) * g_vEffectCenterOoRadius3.w ); + o.flDistanceToEffectCenter_flFresnelEffect.x = min( o.flDistanceToEffectCenter_flFresnelEffect.x, length( vWorldPosition.xyz - g_vEffectCenterOoRadius4.xyz ) * g_vEffectCenterOoRadius4.w ); + + /* + // Test values for development in Alyx_interior map + o.flDistanceToEffectCenter_flFresnelEffect.x = 9999.0f; // A very large distance + float3 vTestPosition = { -295.0f, -5.0f, 40.0f }; + float flMinY = -5.0f; + float flMaxY = 66.0f; + vTestPosition.y = lerp( flMinY, flMaxY, ( abs( frac( g_flTime / 20.0f ) * 2.0 - 1.0 ) ) ); + //vTestPosition.y = lerp( flMinY, flMaxY, 0.65f ); + + //1.0f - saturate( i.flDistanceToEffectCenter_flFresnelEffect.x * 4.0f - 3.0f ) + + //o.flDistanceToEffectCenter_flFresnelEffect.x = 9999.0f; // A very large distance + + const float g_flInteriorRadius = 20.0f; + if ( g_flInteriorRadius ) + { + o.flDistanceToEffectCenter_flFresnelEffect.x = min( o.flDistanceToEffectCenter_flFresnelEffect.x, length( vWorldPosition.xyz - vTestPosition.xyz ) / g_flInteriorRadius ); + } + + const float g_flInteriorRadius2 = 14.0f; + if ( g_flInteriorRadius2 ) + { + vTestPosition.y = lerp( flMinY, flMaxY, 0.65f ); + //vTestPosition.z = lerp( 37, 45, ( abs( frac( g_flTime / 4.0f ) * 2.0 - 1.0 ) ) ); + o.flDistanceToEffectCenter_flFresnelEffect.x = min( o.flDistanceToEffectCenter_flFresnelEffect.x, length( vWorldPosition.xyz - vTestPosition.xyz ) / g_flInteriorRadius2 ); + } + //*/ + + if ( g_flDebugForceFleshOn ) + { + o.flDistanceToEffectCenter_flFresnelEffect.x = 0.0f; + } + + // Fresnel mask + float3 vWorldViewVector = normalize( vWorldPosition.xyz - cEyePos.xyz ); + o.flDistanceToEffectCenter_flFresnelEffect.y = pow( saturate( dot( -vWorldViewVector.xyz, vWorldNormal.xyz ) ), 1.5f ); + + // Noise UV + o.vNoiseTexCoord.xy = o.vTexCoord0.xy * g_flBorderNoiseScale + g_flNoiseUvScroll; + o.vNoiseTexCoord.zw = o.vTexCoord0.xy * g_flBorderNoiseScale - g_flNoiseUvScroll; // Will fetch as wz to avoid matching layers + + // Tangent view vector + o.vTangentViewVector.xyz = Vec3WorldToTangentNormalized( vWorldViewVector.xyz, vWorldNormal.xyz, vWorldTangent.xyz, vWorldBinormal.xyz ); + + // Compute vertex lighting + bool bDynamicLight = DYNAMIC_LIGHT ? true : false; + bool bStaticLight = STATIC_LIGHT ? true : false; + +#if ( USE_STATIC_CONTROL_FLOW ) || defined ( SHADER_MODEL_VS_3_0 ) + o.cVertexLight.rgb = DoLighting( vWorldPosition, vWorldNormal, float3(0.0f, 0.0f, 0.0f), bStaticLight, bDynamicLight, g_bHalfLambert ); +#else + o.cVertexLight.rgb = DoLightingUnrolled( vWorldPosition, vWorldNormal, float3(0.0f, 0.0f, 0.0f), bStaticLight, bDynamicLight, g_bHalfLambert, NUM_LIGHTS ); +#endif + + // Tangent space transform + o.mTangentSpaceTranspose[0] = float3( vWorldTangent.x, vWorldBinormal.x, vWorldNormal.x ); + o.mTangentSpaceTranspose[1] = float3( vWorldTangent.y, vWorldBinormal.y, vWorldNormal.y ); + o.mTangentSpaceTranspose[2] = float3( vWorldTangent.z, vWorldBinormal.z, vWorldNormal.z ); + + return o; +} diff --git a/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_decal_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_decal_ps2x.fxc new file mode 100644 index 00000000..d6680511 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_decal_ps2x.fxc @@ -0,0 +1,59 @@ +// DYNAMIC: "PIXELFOGTYPE" "0..1" + +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] + +#include "common_ps_fxc.h" +#include "shader_constant_register_map.h" + +sampler BaseTextureSampler : register( s0 ); +sampler LightMap0Sampler : register( s1 ); +sampler LightMap1Sampler : register( s2 ); +sampler LightMap2Sampler : register( s3 ); + +const float4 g_LightMap0Color : register( c0 ); +const float4 g_LightMap1Color : register( c1 ); +const float4 g_LightMap2Color : register( c2 ); +const float4 g_ModulationColor : register( c3 ); + +const float4 g_FogParams : register( PSREG_FOG_PARAMS ); +const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT ); + + +struct PS_INPUT +{ + float4 vProjPos : POSITION; + float2 vTexCoord0 : TEXCOORD0; + float2 vTexCoord1 : TEXCOORD1; + float2 vTexCoord2 : TEXCOORD2; + float2 vTexCoord3 : TEXCOORD3; + float4 worldPos_projPosZ : TEXCOORD4; // Necessary for pixel fog + + float4 vColor : COLOR0; +}; + +float4 main( PS_INPUT i ) : COLOR +{ + float4 resultColor; + + // output = lightmapColor[0] * ( ( N dot basis[0] )^2 ) + + // lightmapColor[1] * ( ( N dot basis[1] )^2 ) + + // lightmapColor[2] * ( ( N dot basis[2] )^2 ) + + resultColor = tex2D( LightMap0Sampler, i.vTexCoord1 ) * g_LightMap0Color; + resultColor = (tex2D( LightMap1Sampler, i.vTexCoord2 ) * g_LightMap1Color) + resultColor; + resultColor = (tex2D( LightMap2Sampler, i.vTexCoord3 ) * g_LightMap2Color) + resultColor; + + // Modulate by decal texture + float4 decalColor = tex2D( BaseTextureSampler, i.vTexCoord0 ); + resultColor.rgb = resultColor * decalColor; + resultColor.a = decalColor.a; + + // Modulate by constant color + resultColor = resultColor * g_ModulationColor; + + // Modulate by per-vertex factor + resultColor = resultColor * i.vColor; + + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); + return FinalOutput( resultColor, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR ); +} diff --git a/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_decal_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_decal_vs20.fxc new file mode 100644 index 00000000..0b7db284 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_decal_vs20.fxc @@ -0,0 +1,74 @@ +// DYNAMIC: "DOWATERFOG" "0..1" + +#include "common_vs_fxc.h" + +static const int g_FogType = DOWATERFOG; + +const float4 cShaderConst0 : register( SHADER_SPECIFIC_CONST_0 ); +const float4 cShaderConst1 : register( SHADER_SPECIFIC_CONST_1 ); + +struct VS_INPUT +{ + float4 vPos : POSITION; + float4 vTexCoord0 : TEXCOORD0; + float4 vTexCoord1 : TEXCOORD1; + float2 vTexCoord2 : TEXCOORD2; + + float4 vColor : COLOR0; +}; + +struct VS_OUTPUT +{ + float4 vProjPos : POSITION; + float2 vTexCoord0 : TEXCOORD0; + float2 vTexCoord1 : TEXCOORD1; + float2 vTexCoord2 : TEXCOORD2; + float2 vTexCoord3 : TEXCOORD3; + + float4 worldPos_projPosZ : TEXCOORD4; // Necessary for pixel fog + + float4 vColor : COLOR0; + + float4 fogFactorW : COLOR1; + +#if !defined( _X360 ) + float fog : FOG; +#endif +}; + + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + + float3 worldPos; + worldPos = mul( v.vPos, cModel[0] ); + float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj ); + o.vProjPos = vProjPos; + vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ ); + + o.worldPos_projPosZ = float4( worldPos.xyz, vProjPos.z ); + + o.fogFactorW = CalcFog( worldPos, vProjPos, g_FogType ); +#if !defined( _X360 ) + o.fog = o.fogFactorW; +#endif + + + // Compute the texture coordinates given the offset between + // each bumped lightmap + float2 offset; + offset.x = v.vTexCoord2.x; + offset.y = 0.0f; + + o.vTexCoord0.x = dot( v.vTexCoord0, cShaderConst0 ); + o.vTexCoord0.y = dot( v.vTexCoord0, cShaderConst1 ); + + o.vTexCoord1 = offset + v.vTexCoord1.xy; + o.vTexCoord2 = (offset * 2.0) + v.vTexCoord1.xy; + o.vTexCoord3 = (offset * 3.0) + v.vTexCoord1.xy; + + o.vColor = v.vColor; + + return o; +} \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_flashlight_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_flashlight_ps2x.fxc new file mode 100644 index 00000000..d8e7e885 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_flashlight_ps2x.fxc @@ -0,0 +1,330 @@ +//====== Copyright c 1996-2004, Valve Corporation, All rights reserved. ======= +// +// Purpose: +// +//============================================================================= + + + +// STATIC: "NORMALMAP" "0..2" +// STATIC: "NORMALMAP2" "0..1" +// STATIC: "WORLDVERTEXTRANSITION" "0..1" +// STATIC: "FANCY_BLENDING" "0..1" +// STATIC: "SEAMLESS" "0..1" +// STATIC: "DETAILTEXTURE" "0..1" +// STATIC: "DETAIL_BLEND_MODE" "0..1" +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps20b] [ps30] [PC] +// STATIC: "PHONG" "0..1" [ps20b] [ps30] +// STATIC: "PHONGMASK" "0..3" [ps20b] [ps30] +// STATIC: "BASETEXTURETRANSFORM2" "0..1" + +// DYNAMIC: "PIXELFOGTYPE" "0..1" +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps20b] [ps30] + +// SKIP: !$WORLDVERTEXTRANSITION && $NORMALMAP2 +// SKIP: !$NORMALMAP && $NORMALMAP2 +// SKIP: !$DETAILTEXTURE && ( $DETAIL_BLEND_MODE != 0 ) +// SKIP: !$PHONG && $PHONGMASK +// SKIP: $BASETEXTURETRANSFORM2 && !$WORLDVERTEXTRANSITION +// SKIP: $BASETEXTURETRANSFORM2 && $SEAMLESS +// SKIP: $BASETEXTURETRANSFORM2 && $PHONG + +#include "shader_constant_register_map.h" +#include "common_flashlight_fxc.h" +#include "common_lightmappedgeneric_fxc.h" + +const float4 g_vShadowTweaks : register( PSREG_ENVMAP_TINT__SHADOW_TWEAKS ); +const float4 g_FogParams : register( PSREG_FOG_PARAMS ); +const float4 g_EyePos : register( PSREG_EYEPOS_SPEC_EXPONENT ); +const float4 g_FlashlightAttenuation : register( PSREG_FLASHLIGHT_ATTENUATION ); +const float4 g_DetailConstants : register( c0 ); +const float4 g_FlashlightPos : register( c1 ); +const float4 g_FresnelSpecParams : register( PSREG_FRESNEL_SPEC_PARAMS ); + +#define g_SpecularExponent g_EyePos.w +#define g_FresnelRanges g_FresnelSpecParams.xyz +#define g_SpecularBoost g_FresnelSpecParams.w + +#define PHONGMASK_BASEALPHA 1 +#define PHONGMASK_NORMALALPHA 2 +#define PHONGMASK_STANDALONE 3 + +sampler SpotSampler : register( s0 ); +sampler BaseTextureSampler : register( s1 ); +sampler NormalizingCubemapSampler : register( s2 ); + +// use a normalizing cube map here if we aren't normal mapping +sampler BumpMapSampler : register( s3 ); +sampler BaseTextureSampler2 : register( s4 ); + +#ifdef WORLDVERTEXTRANSITION +sampler NormalMap2Sampler : register( s6 ); +#endif + +#if DETAILTEXTURE +sampler DetailSampler : register( s8 ); +#endif + +#if FLASHLIGHTSHADOWS && ( defined( SHADER_MODEL_PS_2_B ) || defined( SHADER_MODEL_PS_3_0 ) ) +sampler RandomRotationSampler : register( s5 ); // Random rotation sampler +sampler FlashlightDepthSampler : register( s7 ); +#endif + +#if PHONGMASK == PHONGMASK_STANDALONE +sampler PhongMaskSampler : register( s9 ); +#endif + +#if FANCY_BLENDING +sampler BlendModulationSampler : register( s10 ); +#endif + +struct PS_INPUT +{ + float4 spotTexCoord : TEXCOORD0; +#if SEAMLESS + float3 SeamlessTexCoord : TEXCOORD1; +#else +#if BASETEXTURETRANSFORM2 + // Blixibon - Using two extra floats for $basetexturetransform2 + float4 baseTexCoord : TEXCOORD1; +#else + float2 baseTexCoord : TEXCOORD1; +#endif +#endif +#if NORMALMAP +#if PHONG + float4 tangentPosToLightVector : TEXCOORD2; + float4 normalMapTexCoord : TEXCOORD3; +#else + float3 tangentPosToLightVector : TEXCOORD2; + float2 normalMapTexCoord : TEXCOORD3; +#endif +#else + float3 worldPosToLightVector : TEXCOORD2; + float3 normal : TEXCOORD3; +#endif + + float2 detailCoords : TEXCOORD4; + float4 worldPos_worldTransition : TEXCOORD5; + float3 projPos : TEXCOORD6; + float4 fogFactorW : TEXCOORD7; +}; + + + +float4 SampleNormal( sampler s, PS_INPUT i ) +{ +#if SEAMLESS + float4 szy=tex2D( s, i.SeamlessTexCoord.zy ); + float4 sxz=tex2D( s, i.SeamlessTexCoord.xz ); + float4 syx=tex2D( s, i.SeamlessTexCoord.xy ); + return i.fogFactorW.r*szy + i.fogFactorW.g*sxz + i.fogFactorW.b*syx; +#else +#if NORMALMAP + return tex2D( s, i.normalMapTexCoord.xy); +#else + return float4(0,0,1,1); +#endif +#endif + +} + +float4 main( PS_INPUT i ) : COLOR +{ + bool bBase2 = WORLDVERTEXTRANSITION ? true : false; + bool bBump = (NORMALMAP != 0) ? true : false; + + // Do spot stuff early since we can bail out + float3 spotColor = float3(0,0,0); + float3 vProjCoords = i.spotTexCoord.xyz / i.spotTexCoord.w; + +#if ( defined( _X360 ) ) + + float3 ltz = vProjCoords.xyz < float3( 0.0f, 0.0f, 0.0f ); + float3 gto = vProjCoords.xyz > float3( 1.0f, 1.0f, 1.0f ); + + [branch] + if ( dot(ltz + gto, float3(1,1,1)) > 0 ) + { + clip (-1); + return float4(0,0,0,0); + } + else + { + spotColor = tex2D( SpotSampler, vProjCoords ); + + [branch] + if ( dot(spotColor.xyz, float3(1,1,1)) <= 0 ) + { + clip(-1); + return float4(0,0,0,0); + } + else + { +#else + clip( vProjCoords.xyz ); +#if defined( SHADER_MODEL_PS_2_B ) || defined( SHADER_MODEL_PS_3_0 ) + clip( 1-vProjCoords.xyz ); +#endif + spotColor = tex2D( SpotSampler, vProjCoords ); +#endif + + float4 baseColor = 0.0f; + float4 baseColor2 = 0.0f; + float4 vNormal = float4(0, 0, 1, 1); + float3 baseTexCoords = float3(0,0,0); + +#if SEAMLESS + baseTexCoords = i.SeamlessTexCoord.xyz; +#else + baseTexCoords.xy = i.baseTexCoord.xy; +#endif + +#if BASETEXTURETRANSFORM2 + // Blixibon - Simpler version of GetBaseTextureAndNormal() that supports $basetexturetransform2 + // (This is duplicated in the original shader, but make this its own function in common_lightmappedgeneric_fxc.h if this becomes more widespread) + baseColor = tex2D( BaseTextureSampler, baseTexCoords.xy ); + baseColor2 = tex2D( BaseTextureSampler2, i.baseTexCoord.wz ); + if ( bBump ) + { + vNormal = tex2D( BumpMapSampler, baseTexCoords.xy ); + } +#else + GetBaseTextureAndNormal( BaseTextureSampler, BaseTextureSampler2, BumpMapSampler, bBase2, bBump, baseTexCoords, i.fogFactorW.xyz, baseColor, baseColor2, vNormal ); +#endif + +#if WORLDVERTEXTRANSITION + float lerpAlpha = i.worldPos_worldTransition.a; + + // Blixibon +#if (PIXELFOGTYPE != PIXEL_FOG_TYPE_HEIGHT) && (FANCY_BLENDING) + float4 modt=tex2D(BlendModulationSampler,baseTexCoords); + + float minb=saturate(modt.g-modt.r); + float maxb=saturate(modt.g+modt.r); + lerpAlpha=smoothstep(minb,maxb,lerpAlpha); +#endif + +#endif + +#if ( NORMALMAP == 0 ) + vNormal.xyz = normalize( i.normal.xyz ); +#endif + +#if ( NORMALMAP == 1 ) + vNormal.xyz = vNormal.xyz * 2.0f - 1.0f; // signed + +# if NORMALMAP2 + float3 normal2 = SampleNormal( NormalMap2Sampler, i ) * 2.0f - 1.0f; + vNormal.xyz = lerp( vNormal.xyz, normal2, lerpAlpha ); +# endif +#endif + +// ssbump +#if ( NORMALMAP == 2 ) + +# if NORMALMAP2 + float3 normal2 = SampleNormal( NormalMap2Sampler, i ); + vNormal.xyz = lerp( vNormal.xyz, normal2, lerpAlpha ); +# endif +#else + // Normalize normal after all of the lerps above (including the tri/bilinear texel fetches) + vNormal.xyz = normalize( vNormal.xyz ); +#endif + + spotColor.rgb *= cFlashlightColor.rgb; + + // Compute per-pixel distance attenuation + float3 delta = g_FlashlightPos.xyz - i.worldPos_worldTransition.xyz; + float distSquared = dot( delta, delta ); + float dist = sqrt( distSquared ); + float farZ = g_FlashlightAttenuation.w; + float endFalloffFactor = RemapValClamped( dist, farZ, 0.6f * farZ, 0.0f, 1.0f ); + float flAtten = saturate(endFalloffFactor * dot( g_FlashlightAttenuation.xyz, float3( 1.0f, 1.0f/dist, 1.0f/distSquared ) ) ); + +#if FLASHLIGHTSHADOWS && ( defined( SHADER_MODEL_PS_2_B ) || defined( SHADER_MODEL_PS_3_0 ) ) + float flShadow = DoFlashlightShadow( FlashlightDepthSampler, RandomRotationSampler, vProjCoords, i.projPos.xy / i.projPos.z, FLASHLIGHTDEPTHFILTERMODE, g_vShadowTweaks, false ); + float flAttenuated = lerp( flShadow, 1.0f, g_vShadowTweaks.y ); // Blend between fully attenuated and not attenuated + flShadow = saturate(lerp( flAttenuated, flShadow, flAtten )); // Blend between shadow and above, according to light attenuation + spotColor *= flShadow; +#endif + +#if WORLDVERTEXTRANSITION && !defined( SHADER_MODEL_PS_2_0 ) + baseColor = lerp( baseColor, baseColor2, lerpAlpha ); +#endif + +#if PHONG + float3 vSpecMask = 1; + +# if PHONGMASK == PHONGMASK_BASEALPHA + vSpecMask = baseColor.a; +# elif PHONGMASK == PHONGMASK_NORMALALPHA + vSpecMask = vNormal.a; +# elif PHONGMASK == PHONGMASK_STANDALONE + vSpecMask = tex2D( PhongMaskSampler, baseTexCoords ).rgb; +# endif +#endif + +#if DETAILTEXTURE + float4 detailColor = float4( g_DetailConstants.xyz, 1.0f ) * tex2D( DetailSampler, i.detailCoords ); + float4 vBase = TextureCombine( float4(baseColor.xyz, 1.0f), detailColor, DETAIL_BLEND_MODE, g_DetailConstants.w ); + baseColor.xyz = vBase.xyz; +#endif + +#if NORMALMAP == 0 + float3 worldPosToLightVector = texCUBE( NormalizingCubemapSampler, i.worldPosToLightVector ) * 2.0f - 1.0f; + float nDotL = dot( worldPosToLightVector, vNormal.xyz ); +#endif + +#if NORMALMAP == 1 + // flashlightfixme: wrap this! + float3 tangentPosToLightVector = texCUBE( NormalizingCubemapSampler, i.tangentPosToLightVector.xyz ) * 2.0f - 1.0f; + float nDotL = dot( tangentPosToLightVector, vNormal.xyz ); +#endif + +#if NORMALMAP == 2 + float3 tangentPosToLightVector = texCUBE( NormalizingCubemapSampler, i.tangentPosToLightVector.xyz ) * 2.0f - 1.0f; + + float nDotL = + vNormal.x*dot( tangentPosToLightVector, bumpBasis[0]) + + vNormal.y*dot( tangentPosToLightVector, bumpBasis[1]) + + vNormal.z*dot( tangentPosToLightVector, bumpBasis[2]); +#endif + + float3 outColor; +#if PHONG == 0 + outColor = spotColor * baseColor.xyz * saturate( nDotL ); + outColor *= flAtten; +#else + outColor = spotColor * baseColor.xyz * flAtten; + + // Not using normalizing cubemap here because of pixelated specular appearance. =/ +# if NORMALMAP == 0 + float3 posToLight = normalize( i.worldPosToLightVector ); + float3 posToEye = normalize( g_EyePos.xyz - i.worldPos_worldTransition.xyz); +# else + float3 posToLight = normalize( i.tangentPosToLightVector.xyz ); + float3 posToEye = normalize( float3(i.tangentPosToLightVector.w, i.normalMapTexCoord.zw) ); + +# if NORMALMAP == 2 + vNormal.xyz = bumpBasis[0]*vNormal.x + bumpBasis[1]*vNormal.y + bumpBasis[2]*vNormal.z; + vNormal.xyz = normalize( vNormal.xyz ); +# endif +# endif + + float fFresnel = Fresnel( vNormal.xyz, posToEye, g_FresnelRanges ); + float3 specularColor = outColor * SpecularLight( vNormal.xyz, posToLight, g_SpecularExponent, posToEye, false, SpotSampler, fFresnel ); + outColor *= saturate( nDotL ); + outColor += specularColor * fFresnel * vSpecMask * g_SpecularBoost; +#endif + + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.z, i.worldPos_worldTransition.z, i.projPos.z ); + return FinalOutput( float4(outColor, baseColor.a) , fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR ); + + // so we can jump over all of the above +#if ( defined( _X360 ) ) + } + } +#endif + +} \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_flashlight_vs11.fxc b/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_flashlight_vs11.fxc new file mode 100644 index 00000000..3a0d059d --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_flashlight_vs11.fxc @@ -0,0 +1,122 @@ +//====== Copyright © 1996-2007, Valve Corporation, All rights reserved. ======= +// +// Purpose: +// +//============================================================================= + +// STATIC: "NORMALMAP" "0..1" +// STATIC: "WORLDVERTEXTRANSITION" "0..1" +// STATIC: "VERTEXCOLOR" "0..1" +// DYNAMIC: "DOWATERFOG" "0..1" + +#include "common_vs_fxc.h" + +const float3 g_FlashlightPos : register( SHADER_SPECIFIC_CONST_0 ); +const float4x4 g_FlashlightWorldToTexture : register( SHADER_SPECIFIC_CONST_1 ); +const float4 g_FlashlightAttenuationFactors : register( SHADER_SPECIFIC_CONST_5 ); + +const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_6 ); +const float4 cNormalMapTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_8 ); + +static const int g_FogType = DOWATERFOG; + +struct VS_INPUT +{ + // If this is float4, and the input is float3, the w component default to one. + float4 vPos : POSITION; + float3 vNormal : NORMAL; + float2 vBaseTexCoord : TEXCOORD0; +#if NORMALMAP + float3 vTangentS : TANGENT; + float3 vTangentT : BINORMAL; +#endif + float4 vColor : COLOR0; +}; + +struct VS_OUTPUT +{ + float4 projPos : POSITION; +#if !defined( _X360 ) + float fog : FOG; +#endif + float4 spotTexCoord : TEXCOORD0; + float2 baseTexCoord : TEXCOORD1; +#if NORMALMAP + float3 tangentPosToLightVector : TEXCOORD2; + float2 normalMapTexCoord : TEXCOORD3; +#else + float3 worldPosToLightVector : TEXCOORD2; + float3 normal : TEXCOORD3; +#endif + float4 vertAtten : COLOR0; +}; + +float RemapValClamped( float val, float A, float B ) +{ + float cVal = (val - A) / (B - A); + cVal = saturate( cVal ); + return cVal; +} + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o; + + float4 projPos; + float3 worldPos; + float3 worldNormal; + float3 eyeVector; + + projPos = mul( v.vPos, cModelViewProj ); + o.projPos = projPos; + + worldPos = mul( v.vPos, cModel[0] ); + worldNormal = mul( v.vNormal, ( float3x3 )cModel[0] ); + +#if NORMALMAP + float3 worldTangentS = mul( v.vTangentS, cModel[0] ); + float3 worldTangentT = mul( v.vTangentT, cModel[0] ); +#endif + +#if !defined( _X360 ) + o.fog = CalcFog( worldPos, projPos, g_FogType ); +#endif + + o.baseTexCoord.x = dot( v.vBaseTexCoord, cBaseTexCoordTransform[0] ) + cBaseTexCoordTransform[0].w; + o.baseTexCoord.y = dot( v.vBaseTexCoord, cBaseTexCoordTransform[1] ) + cBaseTexCoordTransform[1].w; + + float4 spotTexCoord = mul( float4( worldPos, 1.0f ), g_FlashlightWorldToTexture ); + o.spotTexCoord = spotTexCoord.xyzw; + + float3 worldPosToLightVector = g_FlashlightPos - worldPos; +#if NORMALMAP + o.normalMapTexCoord.x = dot( v.vBaseTexCoord, cNormalMapTexCoordTransform[0] ) + cNormalMapTexCoordTransform[0].w; + o.normalMapTexCoord.y = dot( v.vBaseTexCoord, cNormalMapTexCoordTransform[1] ) + cNormalMapTexCoordTransform[1].w; + + o.tangentPosToLightVector.x = dot( worldPosToLightVector, worldTangentS ); + o.tangentPosToLightVector.y = dot( worldPosToLightVector, worldTangentT ); + o.tangentPosToLightVector.z = dot( worldPosToLightVector, worldNormal ); +#else + o.worldPosToLightVector = worldPosToLightVector; + o.normal = worldNormal; +#endif + + float3 delta = worldPosToLightVector; + float distSquared = dot( delta, delta ); + float dist = sqrt( distSquared ); + float farZ = g_FlashlightAttenuationFactors.w; + float endFalloffFactor = RemapValClamped( dist, farZ, 0.6 * farZ ); + o.vertAtten.xyz = saturate( endFalloffFactor * dot( g_FlashlightAttenuationFactors, float3( 1.0f, 1.0f/dist, 1.0f/distSquared ) ) ); + +#if WORLDVERTEXTRANSITION + o.vertAtten.w = 1 - v.vColor.w; +#else +#if VERTEXCOLOR + o.vertAtten.w = v.vColor.w; +#else + o.vertAtten.w = 1.0f; +#endif +#endif + + return o; +} diff --git a/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_flashlight_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_flashlight_vs20.fxc new file mode 100644 index 00000000..19afa219 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_flashlight_vs20.fxc @@ -0,0 +1,217 @@ +//====== Copyright ? 1996-2004, Valve Corporation, All rights reserved. ======= +// +// Purpose: +// +//============================================================================= + +// STATIC: "NORMALMAP" "0..1" +// STATIC: "WORLDVERTEXTRANSITION" "0..1" +// STATIC: "SEAMLESS" "0..1" +// STATIC: "DETAIL" "0..1" +// STATIC: "PHONG" "0..1" +// STATIC: "BASETEXTURETRANSFORM2" "0..1" +// DYNAMIC: "DOWATERFOG" "0..1" + +// SKIP: $BASETEXTURETRANSFORM2 && !$WORLDVERTEXTRANSITION +// SKIP: $BASETEXTURETRANSFORM2 && $SEAMLESS +// SKIP: $BASETEXTURETRANSFORM2 && $PHONG + +#include "common_vs_fxc.h" + +const float3 g_FlashlightPos : register( SHADER_SPECIFIC_CONST_0 ); +const float4x4 g_FlashlightWorldToTexture : register( SHADER_SPECIFIC_CONST_1 ); +const float4 g_FlashlightAttenuationFactors : register( SHADER_SPECIFIC_CONST_5 ); + +#if SEAMLESS +const float4 SeamlessScale : register( SHADER_SPECIFIC_CONST_6 ); +#define SEAMLESS_SCALE (SeamlessScale.x) +#endif +const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_6 ); +const float4 cNormalMapOrDetailTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_8 ); +#if PHONG +const float3 g_EyePos : register( SHADER_SPECIFIC_CONST_10 ); +#elif BASETEXTURETRANSFORM2 +const float4 cBaseTexCoordTransform2[2] : register( SHADER_SPECIFIC_CONST_10 ); // Blixibon - Support for $basetexturetransform2 +#endif + +static const int g_FogType = DOWATERFOG; + +struct VS_INPUT +{ + float3 vPos : POSITION; //This HAS to match lightmappedgeneric_vs20.fxc's position input. Otherwise depth fighting errors occur on the 360 + float4 vNormal : NORMAL; + float2 vBaseTexCoord : TEXCOORD0; +#if WORLDVERTEXTRANSITION + float2 vLightmapTexCoord : TEXCOORD1; + float4 vColor : COLOR0; +#endif +#if NORMALMAP + float3 vTangentS : TANGENT; + float3 vTangentT : BINORMAL; +#endif +}; + +struct VS_OUTPUT +{ + float4 projPos : POSITION; +#if !defined( _X360 ) + float fog : FOG; +#endif + + float4 spotTexCoord : TEXCOORD0; + +#if SEAMLESS + float3 SeamlessTexCoord : TEXCOORD1; +#else +#if BASETEXTURETRANSFORM2 + // Blixibon - Using two extra floats for $basetexturetransform2 + float4 baseTexCoord : TEXCOORD1; +#else + float2 baseTexCoord : TEXCOORD1; +#endif +#endif + +#if NORMALMAP +#if PHONG + float4 tangentPosToLightVector : TEXCOORD2; + float4 normalMapTexCoord : TEXCOORD3; +#else + float3 tangentPosToLightVector : TEXCOORD2; + float2 normalMapTexCoord : TEXCOORD3; +#endif +#else + float3 worldPosToLightVector : TEXCOORD2; + float3 normal : TEXCOORD3; +#endif + + float2 detailCoords : TEXCOORD4; + float4 worldPos_worldTransition : TEXCOORD5; + float3 vProjPos : TEXCOORD6; + float4 fogFactorW : TEXCOORD7; +}; + +float RemapValClamped( float val, float A, float B, float C, float D) +{ + float cVal = (val - A) / (B - A); + cVal = saturate( cVal ); + + return C + (D - C) * cVal; +} + + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o; + + float3 vObjNormal; + DecompressVertex_Normal( v.vNormal, vObjNormal ); + + float4 projPos; + float3 worldPos; + float3 worldNormal; + float3 eyeVector; + + //Projection math HAS to match lightmappedgeneric_vs20.fxc's math exactly. Otherwise depth fighting errors occur on the 360 + projPos = mul( float4( v.vPos, 1 ), cModelViewProj ); + o.projPos = projPos; + o.vProjPos.xyz = projPos.xyw; + + worldPos = mul( float4( v.vPos, 1 ), cModel[0] ); + worldNormal = mul( vObjNormal, ( float3x3 )cModel[0] ); + + o.worldPos_worldTransition = float4( worldPos.xyz, 1.0f ); + + o.fogFactorW = CalcFog( worldPos, projPos, g_FogType ); +#if !defined( _X360 ) + o.fog = o.fogFactorW.w; +#endif + +#if NORMALMAP + float3 worldTangentS = mul( v.vTangentS, cModel[0] ); + float3 worldTangentT = mul( v.vTangentT, cModel[0] ); +#endif +#if SEAMLESS + float3 vNormal=normalize( worldNormal ); + o.fogFactorW.xyz = vNormal * vNormal; // sums to 1. + o.SeamlessTexCoord = SEAMLESS_SCALE*worldPos; + + // Generate new tangent and binormal with seamless projection + #if NORMALMAP + // Brute-force for prototype - This must match the projection in the pixel shader! + //float3 vVecX = { 1.0f, 0.0f, 0.0f }; + //float3 vVecY = { 0.0f, 1.0f, 0.0f }; + //float3 vVecZ = { 0.0f, 0.0f, 1.0f }; + //worldTangentS.xyz = normalize( ( o.fogFactorW.x * vVecZ.xyz ) + ( o.fogFactorW.y * vVecX.xyz ) + ( o.fogFactorW.z * vVecX.xyz ) ); + //worldTangentT.xyz = normalize( ( o.fogFactorW.x * vVecY.xyz ) + ( o.fogFactorW.y * vVecZ.xyz ) + ( o.fogFactorW.z * vVecY.xyz ) ); + + // Optimized version - This must match the projection in the pixel shader! + worldTangentS.xyz = normalize( float3( o.fogFactorW.y + o.fogFactorW.z, 0.0f, o.fogFactorW.x ) ); + worldTangentT.xyz = normalize( float3( 0.0f, o.fogFactorW.x + o.fogFactorW.z, o.fogFactorW.y ) ); + #endif +#else +#if (SEAMLESS == 0 ) + o.baseTexCoord.x = dot( v.vBaseTexCoord, cBaseTexCoordTransform[0] ) + cBaseTexCoordTransform[0].w; + o.baseTexCoord.y = dot( v.vBaseTexCoord, cBaseTexCoordTransform[1] ) + cBaseTexCoordTransform[1].w; +#if BASETEXTURETRANSFORM2 + o.baseTexCoord.w = dot( v.vBaseTexCoord, cBaseTexCoordTransform2[0] ) + cBaseTexCoordTransform2[0].w; + o.baseTexCoord.z = dot( v.vBaseTexCoord, cBaseTexCoordTransform2[1] ) + cBaseTexCoordTransform2[1].w; +#endif +#endif +#endif + + float4 spotTexCoord = mul( float4( worldPos, 1.0f ), g_FlashlightWorldToTexture ); + o.spotTexCoord = spotTexCoord.xyzw; + + float3 worldPosToLightVector = g_FlashlightPos - worldPos; +#if NORMALMAP + +#if (DETAIL == 0) + o.normalMapTexCoord.x = dot( v.vBaseTexCoord, cNormalMapOrDetailTexCoordTransform[0] ) + cNormalMapOrDetailTexCoordTransform[0].w; + o.normalMapTexCoord.y = dot( v.vBaseTexCoord, cNormalMapOrDetailTexCoordTransform[1] ) + cNormalMapOrDetailTexCoordTransform[1].w; +#else + +#if SEAMLESS + o.normalMapTexCoord.xy = v.vBaseTexCoord; +#else + o.normalMapTexCoord.xy = o.baseTexCoord.xy; // Blixibon - Had to change this to .xy because BASETEXTURETRANSFORM2 makes this float4 +#endif + +#endif + + o.tangentPosToLightVector.x = dot( worldPosToLightVector, worldTangentS ); + o.tangentPosToLightVector.y = dot( worldPosToLightVector, worldTangentT ); + o.tangentPosToLightVector.z = dot( worldPosToLightVector, worldNormal ); + +#if PHONG + float3 worldPosToEyeVector = g_EyePos - worldPos; + o.tangentPosToLightVector.w = dot( worldPosToEyeVector, worldTangentS ); + o.normalMapTexCoord.z = dot( worldPosToEyeVector, worldTangentT ); + o.normalMapTexCoord.w = dot( worldPosToEyeVector, worldNormal ); +#endif + +#else + o.worldPosToLightVector = worldPosToLightVector; + o.normal = worldNormal; +#endif + +#if DETAIL + o.detailCoords.x = dot( v.vBaseTexCoord, cNormalMapOrDetailTexCoordTransform[0] ) + cNormalMapOrDetailTexCoordTransform[0].w; + o.detailCoords.y = dot( v.vBaseTexCoord, cNormalMapOrDetailTexCoordTransform[1] ) + cNormalMapOrDetailTexCoordTransform[1].w; +#else + o.detailCoords = float2(0,0); +#endif + + //float3 delta = worldPosToLightVector; + //float distSquared = dot( delta, delta ); + //float dist = sqrt( distSquared ); + //float farZ = g_FlashlightAttenuationFactors.w; + //float endFalloffFactor = RemapValClamped( dist, farZ, 0.6f * farZ, 0.0f, 1.0f ); + //o.projPos_atten.w = endFalloffFactor * dot( g_FlashlightAttenuationFactors, float3( 1.0f, 1.0f/dist, 1.0f/distSquared ) ); + //o.projPos_atten.w = saturate( o.projPos_atten.w ); + +#if WORLDVERTEXTRANSITION + o.worldPos_worldTransition.w = v.vColor.w; +#endif + + return o; +} \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_lightingonly_overbright2_ps11.fxc b/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_lightingonly_overbright2_ps11.fxc new file mode 100644 index 00000000..1dbb8b2f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_lightingonly_overbright2_ps11.fxc @@ -0,0 +1,12 @@ +sampler TextureSampler : register( s1 ); + +struct PS_INPUT +{ + float4 vColor0 : COLOR0; + float2 vTexCoord1 : TEXCOORD1; +}; + +float4 main( PS_INPUT i ) : COLOR +{ + return tex2D( TextureSampler, i.vTexCoord1 ); +} \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_lightingonly_vs11.fxc b/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_lightingonly_vs11.fxc new file mode 100644 index 00000000..afee6c9c --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_lightingonly_vs11.fxc @@ -0,0 +1,51 @@ +// DYNAMIC: "DOWATERFOG" "0..1" + +#include "common_vs_fxc.h" + +static const int g_FogType = DOWATERFOG; + +struct VS_INPUT +{ + float4 vPos : POSITION; + float2 vTexCoord1 : TEXCOORD1; +}; + +struct VS_OUTPUT +{ + float4 vProjPos : POSITION; + + float2 vTexCoord0 : TEXCOORD0; + float2 vTexCoord1 : TEXCOORD1; + + float4 vDiffuse : COLOR0; + + float4 fogFactorW : COLOR1; + +#if !defined( _X360 ) + float fog : FOG; +#endif +}; + + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + + float3 worldPos; + worldPos = mul4x3( v.vPos, cModel[0] ); + + o.vProjPos = mul( float4( worldPos, 1 ), cViewProj ); + + o.fogFactorW = CalcFog( worldPos, o.vProjPos, g_FogType ); +#if !defined( _X360 ) + o.fog = o.fogFactorW; +#endif + + // YUCK! This is to make texcoords continuous for mat_softwaretl + o.vTexCoord0 = 0.0f; + o.vTexCoord1 = v.vTexCoord1; + + o.vDiffuse = 1.0f; + + return o; +} \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_ps11.fxc b/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_ps11.fxc new file mode 100644 index 00000000..d5be9e5f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_ps11.fxc @@ -0,0 +1,122 @@ +// STATIC: "BASETEXTURE" "0..1" +// STATIC: "ENVMAP" "0..1" +// STATIC: "ENVMAPMASK" "0..1" +// STATIC: "SELFILLUM" "0..1" +// STATIC: "BASEALPHAENVMAPMASK" "0..1" + +// SKIP: !$ENVMAP && ( $BASEALPHAENVMAPMASK || $ENVMAPMASK ) +// SKIP: !$BASETEXTURE && $BASEALPHAENVMAPMASK +// SKIP: $BASEALPHAENVMAPMASK && $ENVMAPMASK +// SKIP: !$BASETEXTURE && $BASEALPHAENVMAPMASK +// SKIP: $SELFILLUM && $BASEALPHAENVMAPMASK +// SKIP: !$BASETEXTURE && $SELFILLUM + +const float3 g_OverbrightFactor : register( c0 ); +const float3 g_SelfIllumTint : register( c1 ); +const float3 g_EnvmapTint : register( c2 ); + +sampler BaseTextureSampler : register( s0 ); +sampler LightmapSampler : register( s1 ); +sampler EnvmapSampler : register( s2 ); +sampler EnvmapMaskSampler : register( s3 ); + +//sampler DetailSampler : register( s3 ); + +struct PS_INPUT +{ + float2 baseTexCoord : TEXCOORD0; + float2 lightmapTexCoord : TEXCOORD1; + float3 envmapTexCoord : TEXCOORD2; + float2 envmapMaskTexCoord : TEXCOORD3; + float4 vertexColor : COLOR0; +}; + +float4 main( PS_INPUT i ) : COLOR +{ + bool bBaseTexture = BASETEXTURE ? true : false; + bool bEnvmap = ENVMAP ? true : false; + bool bEnvmapMask = ENVMAPMASK ? true : false; + bool bSelfIllum = SELFILLUM ? true : false; + bool bBaseAlphaEnvmapMask = BASEALPHAENVMAPMASK ? true : false; + +#if 1 + float4 baseColor = float4( 1.0f, 1.0f, 1.0f, 1.0f ); + if( bBaseTexture ) + { + baseColor = tex2D( BaseTextureSampler, i.baseTexCoord ); + } + + float3 specularFactor = 1.0f; + + if( bEnvmapMask ) + { + specularFactor *= tex2D( EnvmapMaskSampler, i.envmapMaskTexCoord ).xyz; + } + if( bBaseAlphaEnvmapMask ) + { + specularFactor *= 1.0 - baseColor.a; // this blows! + } + + float3 diffuseLighting = tex2D( LightmapSampler, i.lightmapTexCoord ); + + float3 albedo = float3( 1.0f, 1.0f, 1.0f ); + float alpha = 1.0f; + if( bBaseTexture ) + { + albedo *= baseColor; + if( !bBaseAlphaEnvmapMask && !bSelfIllum ) + { + alpha *= baseColor.a; + } + } + + // The vertex color contains the modulation color + vertex color combined + albedo *= i.vertexColor; + alpha *= i.vertexColor.a; // not sure about this one + + float3 diffuseComponent = ( albedo * diffuseLighting * 2.0f ) * g_OverbrightFactor; + + if( bSelfIllum ) + { + float3 selfIllumComponent = g_SelfIllumTint * albedo; + diffuseComponent = lerp( diffuseComponent, selfIllumComponent, baseColor.a ); + } + + float3 specularLighting = float3( 0.0f, 0.0f, 0.0f ); + + if( bEnvmap ) + { + specularLighting = tex2D( EnvmapSampler, i.envmapTexCoord ); + specularLighting *= specularFactor; + specularLighting *= g_EnvmapTint; + } + + float3 result = diffuseComponent + specularLighting; + return float4( result, alpha ); +#endif + +#if 0 + float4 baseColor = float4( 1.0f, 1.0f, 1.0f, 1.0f ); + float3 diffuseLighting = tex2D( LightmapSampler, i.lightmapTexCoord ); + + float3 albedo = float3( 1.0f, 1.0f, 1.0f ); + float alpha = 1.0f; + albedo *= i.vertexColor; + alpha *= i.vertexColor.a; // not sure about this one + + float3 diffuseComponent = ( albedo * diffuseLighting * 2.0f ) * g_OverbrightFactor; + float3 result = diffuseComponent; + return float4( result, alpha ); +#endif + +#if 0 + float4 result; + + result.rgb = tex2D( LightmapSampler, i.lightmapTexCoord ).rgb * i.vertexColor.rgb; + result.a = i.vertexColor.a; + result.rgb = ( result.rgb * g_OverbrightFactor ) * 2.0f; + return result; +#endif +} + + diff --git a/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_ps20b.fxc b/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_ps20b.fxc new file mode 100644 index 00000000..eaa21997 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_ps20b.fxc @@ -0,0 +1,47 @@ +// STATIC: "MASKEDBLENDING" "0..1" +// STATIC: "BASETEXTURE2" "0..1" +// STATIC: "DETAILTEXTURE" "0..1" +// STATIC: "BUMPMAP" "0..2" +// STATIC: "BUMPMAP2" "0..1" +// STATIC: "CUBEMAP" "0..1" +// STATIC: "ENVMAPMASK" "0..1" +// STATIC: "BASEALPHAENVMAPMASK" "0..1" +// STATIC: "SELFILLUM" "0..1" +// STATIC: "NORMALMAPALPHAENVMAPMASK" "0..1" +// STATIC: "DIFFUSEBUMPMAP" "0..1" +// STATIC: "BASETEXTURENOENVMAP" "0..1" +// STATIC: "BASETEXTURE2NOENVMAP" "0..1" +// STATIC: "WARPLIGHTING" "0..1" +// STATIC: "FANCY_BLENDING" "0..2" +// STATIC: "RELIEF_MAPPING" "0..0" [ps20b] +// STATIC: "SEAMLESS" "0..1" +// STATIC: "NORMAL_DECODE_MODE" "0..0" [XBOX] +// STATIC: "NORMAL_DECODE_MODE" "0..0" [PC] +// STATIC: "NORMALMASK_DECODE_MODE" "0..0" [XBOX] +// STATIC: "NORMALMASK_DECODE_MODE" "0..0" [PC] +// STATIC: "DETAIL_BLEND_MODE" "0..11" +// STATIC: "FLASHLIGHT" "0..1" [ps20b] [XBOX] +// STATIC: "BASETEXTURETRANSFORM2" "0..1" + +// DYNAMIC: "FASTPATHENVMAPCONTRAST" "0..1" +// DYNAMIC: "FASTPATH" "0..1" +// DYNAMIC: "WRITEWATERFOGTODESTALPHA" "0..1" +// DYNAMIC: "PIXELFOGTYPE" "0..1" +// DYNAMIC: "LIGHTING_PREVIEW" "0..2" [PC] +// DYNAMIC: "LIGHTING_PREVIEW" "0..0" [XBOX] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps30] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX] + +// SKIP: $SEAMLESS && $RELIEF_MAPPING [ps20b] + +// SKIP: (! $DETAILTEXTURE) && ( $DETAIL_BLEND_MODE != 0 ) + +// SKIP: ($DETAIL_BLEND_MODE == 2 ) || ($DETAIL_BLEND_MODE == 3 ) || ($DETAIL_BLEND_MODE == 4 ) +// SKIP: ($DETAIL_BLEND_MODE == 5 ) || ($DETAIL_BLEND_MODE == 6 ) || ($DETAIL_BLEND_MODE == 7 ) +// SKIP: ($DETAIL_BLEND_MODE == 8 ) || ($DETAIL_BLEND_MODE == 9 ) +// SKIP ($DETAIL_BLEND_MODE == 10 ) +// SKIP ($DETAIL_BLEND_MODE == 11 ) + +#include "lightmappedgeneric_ps2_3_x.h" + diff --git a/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_vs20.fxc new file mode 100644 index 00000000..763272fb --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_lightmappedgeneric_vs20.fxc @@ -0,0 +1,268 @@ +// STATIC: "ENVMAP_MASK" "0..1" +// STATIC: "TANGENTSPACE" "0..1" +// STATIC: "BUMPMAP" "0..1" +// STATIC: "DIFFUSEBUMPMAP" "0..1" +// STATIC: "VERTEXCOLOR" "0..1" +// STATIC: "VERTEXALPHATEXBLENDFACTOR" "0..1" +// STATIC: "RELIEF_MAPPING" "0..0" +// STATIC: "SEAMLESS" "0..1" +// STATIC: "BUMPMASK" "0..1" +// STATIC: "FLASHLIGHT" "0..1" [XBOX] +// STATIC: "BASETEXTURETRANSFORM2" "0..1" + +// DYNAMIC: "FASTPATH" "0..1" +// DYNAMIC: "DOWATERFOG" "0..1" +// DYNAMIC: "LIGHTING_PREVIEW" "0..1" [PC] +// DYNAMIC: "LIGHTING_PREVIEW" "0..0" [XBOX] + +// SKIP: $SEAMLESS && $BASETEXTURETRANSFORM2 + +// This should not be a combo since I'm a moron with the tangent space and the flashlight. +// SKIP: !$BUMPMAP && $DIFFUSEBUMPMAP +// SKIP: $SEAMLESS && $RELIEF_MAPPING +// SKIP: $BUMPMASK && $RELIEF_MAPPING +// SKIP: $BUMPMASK && $SEAMLESS + +#include "common_vs_fxc.h" + +static const int g_FogType = DOWATERFOG; +static const bool g_UseSeparateEnvmapMask = ENVMAP_MASK; +static const bool g_bTangentSpace = TANGENTSPACE; +static const bool g_bBumpmap = BUMPMAP; +static const bool g_bBumpmapDiffuseLighting = DIFFUSEBUMPMAP; +static const bool g_bVertexColor = VERTEXCOLOR; +static const bool g_bVertexAlphaTexBlendFactor = VERTEXALPHATEXBLENDFACTOR; +static const bool g_BumpMask = BUMPMASK; + +#if SEAMLESS +const float4 SeamlessScale : register( SHADER_SPECIFIC_CONST_0 ); +#define SEAMLESS_SCALE (SeamlessScale.x) +#else +const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 ); +#if BASETEXTURETRANSFORM2 +const float4 cBaseTexCoordTransform2[2] : register( SHADER_SPECIFIC_CONST_8 ); // Blixibon - Support for $basetexturetransform2 +#endif +const float4 cDetailOrBumpTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_2 ); +#endif +// This should be identity if we are bump mapping, otherwise we'll screw up the lightmapTexCoordOffset. +const float4 cEnvmapMaskTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_4 ); +const float4x4 g_FlashlightWorldToTexture : register( SHADER_SPECIFIC_CONST_6 ); +const float4 cBlendMaskTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_10 ); // not contiguous with the rest! + +struct VS_INPUT +{ + float3 vPos : POSITION; + float4 vNormal : NORMAL; + float2 vBaseTexCoord : TEXCOORD0; + float2 vLightmapTexCoord : TEXCOORD1; + float2 vLightmapTexCoordOffset : TEXCOORD2; + float3 vTangentS : TANGENT; + float3 vTangentT : BINORMAL; + float4 vColor : COLOR0; +}; + +struct VS_OUTPUT +{ + float4 projPos : POSITION; +#if !defined( _X360 ) && !defined(SHADER_MODEL_VS_3_0) + float fog : FOG; +#endif + +#if SEAMLESS + float3 SeamlessTexCoord : TEXCOORD0; // x y z + float4 detailOrBumpAndEnvmapMaskTexCoord : TEXCOORD1; // envmap mask +#else +#if BASETEXTURETRANSFORM2 + // Blixibon - Using two extra floats for $basetexturetransform2 + float4 baseTexCoord : TEXCOORD0; +#else + float2 baseTexCoord : TEXCOORD0; +#endif + // detail textures and bumpmaps are mutually exclusive so that we have enough texcoords. +#if RELIEF_MAPPING + float3 TangentSpaceViewRay : TEXCOORD1; +#else + float4 detailOrBumpAndEnvmapMaskTexCoord : TEXCOORD1; +#endif +#endif + float4 lightmapTexCoord1And2 : TEXCOORD2; + float4 lightmapTexCoord3 : TEXCOORD3; // and basetexcoord*mask_scale + float4 worldPos_projPosZ : TEXCOORD4; + +#if TANGENTSPACE || (LIGHTING_PREVIEW) || defined( _X360 ) + float3x3 tangentSpaceTranspose : TEXCOORD5; // and 6 and 7 +#endif + + float4 vertexColor : COLOR; // in seamless, r g b = blend weights + float4 vertexBlendX_fogFactorW : COLOR1; + + // Extra iterators on 360, used in flashlight combo +#if defined( _X360 ) && FLASHLIGHT + float4 flashlightSpacePos : TEXCOORD8; + float4 vProjPos : TEXCOORD9; +#endif + +}; + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + + float3 vObjNormal; + DecompressVertex_Normal( v.vNormal, vObjNormal ); + + float3 worldPos = mul( float4( v.vPos, 1 ), cModel[0] ); + + float4 vProjPos = mul( float4( v.vPos, 1 ), cModelViewProj ); + o.projPos = vProjPos; + vProjPos.z = dot( float4( v.vPos, 1 ), cModelViewProjZ ); + + o.worldPos_projPosZ = float4( worldPos, vProjPos.z ); + + float3 worldNormal = mul( vObjNormal, ( float3x3 )cModel[0] ); + +#if TANGENTSPACE || (LIGHTING_PREVIEW) || defined( _X360 ) + float3 worldTangentS = mul( v.vTangentS, ( const float3x3 )cModel[0] ); + float3 worldTangentT = mul( v.vTangentT, ( const float3x3 )cModel[0] ); + + #if SEAMLESS && BUMPMAP && defined( _X360 ) + float3 n = normalize( worldNormal ); + float3 n2 = n * n; // sums to 1. + + o.tangentSpaceTranspose[0] = normalize( float3( n2.y + n2.z, 0.0f, n2.x ) ); + o.tangentSpaceTranspose[1] = normalize( float3( 0.0f, n2.x + n2.z, n2.y ) ); + o.tangentSpaceTranspose[2] = worldNormal; + #else + o.tangentSpaceTranspose[0] = worldTangentS; + o.tangentSpaceTranspose[1] = worldTangentT; + o.tangentSpaceTranspose[2] = worldNormal; + #endif + +#endif + + float3 worldVertToEyeVector = VSHADER_VECT_SCALE * (cEyePos - worldPos); + +#if SEAMLESS + { + // we need to fill in the texture coordinate projections + o.SeamlessTexCoord = SEAMLESS_SCALE*worldPos; + } +#else + { + if (FASTPATH) + { + o.baseTexCoord.xy = v.vBaseTexCoord; +#if BASETEXTURETRANSFORM2 + o.baseTexCoord.wz = v.vBaseTexCoord; +#endif + } + else + { + o.baseTexCoord.x = dot( v.vBaseTexCoord, cBaseTexCoordTransform[0] ) + cBaseTexCoordTransform[0].w; + o.baseTexCoord.y = dot( v.vBaseTexCoord, cBaseTexCoordTransform[1] ) + cBaseTexCoordTransform[1].w; +#if BASETEXTURETRANSFORM2 + o.baseTexCoord.w = dot( v.vBaseTexCoord, cBaseTexCoordTransform2[0] ) + cBaseTexCoordTransform2[0].w; + o.baseTexCoord.z = dot( v.vBaseTexCoord, cBaseTexCoordTransform2[1] ) + cBaseTexCoordTransform2[1].w; +#endif + } +#if ( RELIEF_MAPPING == 0 ) + { + // calculate detailorbumptexcoord + if ( FASTPATH ) + o.detailOrBumpAndEnvmapMaskTexCoord.xy = v.vBaseTexCoord.xy; + else + { + o.detailOrBumpAndEnvmapMaskTexCoord.x = dot( v.vBaseTexCoord, cDetailOrBumpTexCoordTransform[0] ) + cDetailOrBumpTexCoordTransform[0].w; + o.detailOrBumpAndEnvmapMaskTexCoord.y = dot( v.vBaseTexCoord, cDetailOrBumpTexCoordTransform[1] ) + cDetailOrBumpTexCoordTransform[1].w; + } + } +#endif + } +#endif + if ( FASTPATH ) + { + o.lightmapTexCoord3.zw = v.vBaseTexCoord; + } + else + { + o.lightmapTexCoord3.z = dot( v.vBaseTexCoord, cBlendMaskTexCoordTransform[0] ) + cBlendMaskTexCoordTransform[0].w; + o.lightmapTexCoord3.w = dot( v.vBaseTexCoord, cBlendMaskTexCoordTransform[1] ) + cBlendMaskTexCoordTransform[1].w; + } + + // compute lightmap coordinates + if( g_bBumpmap && g_bBumpmapDiffuseLighting ) + { + o.lightmapTexCoord1And2.xy = v.vLightmapTexCoord + v.vLightmapTexCoordOffset; + + float2 lightmapTexCoord2 = o.lightmapTexCoord1And2.xy + v.vLightmapTexCoordOffset; + float2 lightmapTexCoord3 = lightmapTexCoord2 + v.vLightmapTexCoordOffset; + + // reversed component order + o.lightmapTexCoord1And2.w = lightmapTexCoord2.x; + o.lightmapTexCoord1And2.z = lightmapTexCoord2.y; + + o.lightmapTexCoord3.xy = lightmapTexCoord3; + } + else + { + o.lightmapTexCoord1And2.xy = v.vLightmapTexCoord; + } + +#if ( RELIEF_MAPPING == 0) + if( g_UseSeparateEnvmapMask || g_BumpMask ) + { + // reversed component order +# if FASTPATH + o.detailOrBumpAndEnvmapMaskTexCoord.wz = v.vBaseTexCoord.xy; +# else + o.detailOrBumpAndEnvmapMaskTexCoord.w = dot( v.vBaseTexCoord, cEnvmapMaskTexCoordTransform[0] ) + cEnvmapMaskTexCoordTransform[0].w; + o.detailOrBumpAndEnvmapMaskTexCoord.z = dot( v.vBaseTexCoord, cEnvmapMaskTexCoordTransform[1] ) + cEnvmapMaskTexCoordTransform[1].w; +# endif + } +#endif + + o.vertexBlendX_fogFactorW = CalcFog( worldPos, vProjPos, g_FogType ); +#if !defined( _X360 ) && !defined(SHADER_MODEL_VS_3_0) + o.fog = o.vertexBlendX_fogFactorW; +#endif + + if (!g_bVertexColor) + { + o.vertexColor = float4( 1.0f, 1.0f, 1.0f, cModulationColor.a ); + } + else + { +#if FASTPATH + o.vertexColor = v.vColor; +#else + if ( g_bVertexAlphaTexBlendFactor ) + { + o.vertexColor.rgb = v.vColor.rgb; + o.vertexColor.a = cModulationColor.a; + } + else + { + o.vertexColor = v.vColor; + o.vertexColor.a *= cModulationColor.a; + } +#endif + } +#if SEAMLESS + // compute belnd weights in rgb + float3 vNormal=normalize( worldNormal ); + o.vertexColor.xyz = vNormal * vNormal; // sums to 1. +#endif + +// On 360, we have extra iterators and can fold the flashlight into this shader +#if defined( _X360 ) && FLASHLIGHT + o.flashlightSpacePos = mul( float4( worldPos, 1.0f ), g_FlashlightWorldToTexture ); + o.vProjPos = vProjPos; +#endif + + if ( g_bVertexAlphaTexBlendFactor ) + { + o.vertexBlendX_fogFactorW.r = v.vColor.a; + } + + return o; +} diff --git a/sp/src/materialsystem/stdshaders/SDK_lightmappedreflective_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_lightmappedreflective_ps2x.fxc new file mode 100644 index 00000000..6d844ddd --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_lightmappedreflective_ps2x.fxc @@ -0,0 +1,189 @@ +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] +// STATIC: "BASETEXTURE" "0..1" +// STATIC: "REFLECT" "0..1" +// STATIC: "REFRACT" "0..1" +// STATIC: "ENVMAPMASK" "0..1" + +// DYNAMIC: "PIXELFOGTYPE" "0..1" +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX] + +#if defined( SHADER_MODEL_PS_2_0 ) +# define WRITE_DEPTH_TO_DESTALPHA 0 +#endif + +#include "common_ps_fxc.h" + +sampler RefractSampler : register( s0 ); +sampler BaseTextureSampler : register( s1 ); +sampler ReflectSampler : register( s2 ); +#if BASETEXTURE +sampler LightmapSampler : register( s3 ); +#endif +#if ENVMAPMASK +sampler EnvMapMaskSampler : register( s6 ); +#endif +sampler NormalSampler : register( s4 ); + +const HALF4 vRefractTint : register( c1 ); +const float4 g_FresnelConstants : register( c3 ); +const HALF4 vReflectTint : register( c4 ); +const float4 g_ReflectRefractScale : register( c5 ); // xy - reflect scale, zw - refract scale + +const float4 g_PixelFogParams : register( c8 ); + + +static const bool g_bReflect = REFLECT ? true : false; +static const bool g_bRefract = REFRACT ? true : false; + +struct PS_INPUT +{ + float4 vBumpTexCoordXY_vTexCoordXY : TEXCOORD0; + half3 vTangentEyeVect : TEXCOORD1; + float4 vReflectXY_vRefractYX : TEXCOORD2; + float W : TEXCOORD3; + float4 vProjPos : TEXCOORD4; + float screenCoord : TEXCOORD5; +#if BASETEXTURE +// CENTROID: TEXCOORD6 + HALF4 lightmapTexCoord1And2 : TEXCOORD6; +// CENTROID: TEXCOORD7 + HALF4 lightmapTexCoord3 : TEXCOORD7; +#endif + + float4 fogFactorW : COLOR1; +}; + +float4 main( PS_INPUT i ) : COLOR +{ + // Load normal and expand range + HALF4 vNormalSample = tex2D( NormalSampler, i.vBumpTexCoordXY_vTexCoordXY.xy ); + HALF3 vNormal = normalize( vNormalSample * 2.0 - 1.0 ); + + // Perform division by W only once + float ooW = 1.0f / i.W; + + float2 unwarpedRefractTexCoord = i.vReflectXY_vRefractYX.wz * ooW; + + float4 reflectRefractScale = g_ReflectRefractScale; + + // Compute coordinates for sampling Reflection + float2 vReflectTexCoord; + float2 vRefractTexCoord; + + // vectorize the dependent UV calculations (reflect = .xy, refract = .wz) +#ifdef NV3X + float4 vDependentTexCoords = vNormal.xyxy * vNormalSample.a * reflectRefractScale; +#else + float4 vN; + vN.xy = vNormal.xy; + vN.w = vNormal.x; + vN.z = vNormal.y; + float4 vDependentTexCoords = vN * vNormalSample.a * reflectRefractScale; +#endif + + vDependentTexCoords += ( i.vReflectXY_vRefractYX * ooW ); + vReflectTexCoord = vDependentTexCoords.xy; + vRefractTexCoord = vDependentTexCoords.wz; + + // Sample reflection and refraction + HALF4 vReflectColor = tex2D( ReflectSampler, vReflectTexCoord ); + HALF4 vRefractColor = tex2D( RefractSampler, vRefractTexCoord ); + vReflectColor *= vReflectTint; + vRefractColor *= vRefractTint; + + half3 vEyeVect; + vEyeVect = normalize( i.vTangentEyeVect ); + + // Fresnel term + HALF fNdotV = saturate( dot( vEyeVect, vNormal ) ); + HALF fFresnelScalar = g_FresnelConstants.x * pow( 1.0 - fNdotV, g_FresnelConstants.y ) + g_FresnelConstants.z; + HALF4 fFresnel = HALF4( fFresnelScalar, fFresnelScalar, fFresnelScalar, fFresnelScalar ); + +#if BASETEXTURE + float4 baseSample = tex2D( BaseTextureSampler, i.vBumpTexCoordXY_vTexCoordXY.zw ); + HALF2 bumpCoord1; + HALF2 bumpCoord2; + HALF2 bumpCoord3; + ComputeBumpedLightmapCoordinates( i.lightmapTexCoord1And2, i.lightmapTexCoord3.xy, + bumpCoord1, bumpCoord2, bumpCoord3 ); + + HALF4 lightmapSample1 = tex2D( LightmapSampler, bumpCoord1 ); + HALF3 lightmapColor1 = lightmapSample1.rgb; + HALF3 lightmapColor2 = tex2D( LightmapSampler, bumpCoord2 ); + HALF3 lightmapColor3 = tex2D( LightmapSampler, bumpCoord3 ); + + float3 dp; + dp.x = saturate( dot( vNormal, bumpBasis[0] ) ); + dp.y = saturate( dot( vNormal, bumpBasis[1] ) ); + dp.z = saturate( dot( vNormal, bumpBasis[2] ) ); + dp *= dp; + + float3 diffuseLighting = dp.x * lightmapColor1 + + dp.y * lightmapColor2 + + dp.z * lightmapColor3; + float sum = dot( dp, float3( 1.0f, 1.0f, 1.0f ) ); + diffuseLighting *= LIGHT_MAP_SCALE / sum; + HALF3 diffuseComponent = baseSample.rgb * diffuseLighting; +#endif + + float4 flMask; +#if ENVMAPMASK + flMask = tex2D( EnvMapMaskSampler, i.vBumpTexCoordXY_vTexCoordXY.zw ); +#else + flMask = float4( 1.0f, 1.0f, 1.0f, 1.0f ); +#endif + + // NOTE: the BASETEXTURE path hasn't been tested (or really written for that matter, just copied from water) + // What I think should happen is that the alpha of base texture should be its 'translucency' + // which should indicate how much refraction to use. + // We should add an envmapmask to deal with how much reflection to use + // along with all the focus, etc. features + float4 result; + float flAlpha = 1.0f; + if( g_bReflect && g_bRefract ) + { + result = lerp( vRefractColor, vReflectColor, fFresnel ) * flMask; +#if BASETEXTURE + result += float4( diffuseComponent, 1.0f ); + flAlpha = baseSample.a; +#endif + } + else if( g_bReflect ) + { +#if BASETEXTURE + result = float4( diffuseComponent, 1.0f ) + vReflectColor * flMask; + flAlpha = baseSample.a; +#else + result = vReflectColor; +#endif + } + else if( g_bRefract ) + { +#if BASETEXTURE + result = float4( diffuseComponent, 1.0f ) + vRefractColor * flMask; + flAlpha = baseSample.a; +#else + result = vRefractColor; +#endif + } + else + { +#if BASETEXTURE + result = float4( diffuseComponent, 1.0f ); + flAlpha = baseSample.a; +#else + result = float4( 0.0f, 0.0f, 0.0f, 0.0f ); +#endif + } + + +#if ( PIXELFOGTYPE == PIXEL_FOG_TYPE_RANGE ) + float fogFactor = CalcRangeFog( i.vProjPos.z, g_PixelFogParams.x, g_PixelFogParams.z, g_PixelFogParams.w ); +#else + float fogFactor = 0; +#endif + + return FinalOutput( float4( result.rgb, flAlpha ), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_NONE, (WRITE_DEPTH_TO_DESTALPHA != 0), i.vProjPos.z ); +} diff --git a/sp/src/materialsystem/stdshaders/SDK_lightmappedreflective_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_lightmappedreflective_vs20.fxc new file mode 100644 index 00000000..e7ced40b --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_lightmappedreflective_vs20.fxc @@ -0,0 +1,105 @@ +// STATIC: "BASETEXTURE" "0..1" + +#include "common_vs_fxc.h" + +const float4 cBumpTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_1 ); +const float4 cBaseTextureTransform[2] : register( SHADER_SPECIFIC_CONST_3 ); + +struct VS_INPUT +{ + float4 vPos : POSITION; + float4 vNormal : NORMAL; + float4 vBaseTexCoord : TEXCOORD0; + float2 vLightmapTexCoord : TEXCOORD1; + float2 vLightmapTexCoordOffset : TEXCOORD2; + float3 vTangentS : TANGENT; + float3 vTangentT : BINORMAL0; +}; + +struct VS_OUTPUT +{ + float4 vProjPos_POSITION : POSITION; + float vFog : FOG; + float4 vBumpTexCoordXY_vTexCoordXY : TEXCOORD0; + float3 vTangentEyeVect : TEXCOORD1; + float4 vReflectXY_vRefractYX : TEXCOORD2; + float W : TEXCOORD3; + float4 vProjPos : TEXCOORD4; + float screenCoord : TEXCOORD5; +#if BASETEXTURE + HALF4 lightmapTexCoord1And2 : TEXCOORD6; + HALF4 lightmapTexCoord3 : TEXCOORD7; +#endif + float4 fogFactorW : COLOR1; +}; + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + + float3 vObjNormal; + DecompressVertex_Normal( v.vNormal, vObjNormal ); + + // Projected position + float4 vProjPos = mul( v.vPos, cModelViewProj ); + o.vProjPos = o.vProjPos_POSITION = vProjPos; + + // Project tangent basis + float2 vProjTangentS = mul( v.vTangentS, cViewProj ); + float2 vProjTangentT = mul( v.vTangentT, cViewProj ); + + // Map projected position to the reflection texture + float2 vReflectPos; + vReflectPos.x = -vProjPos.x; + vReflectPos.y = -vProjPos.y; // invert Y + vReflectPos = (vReflectPos + vProjPos.w) * 0.5f; + + // Map projected position to the refraction texture + float2 vRefractPos; + vRefractPos.x = vProjPos.x; + vRefractPos.y = -vProjPos.y; // invert Y + vRefractPos = (vRefractPos + vProjPos.w) * 0.5f; + + // Reflection transform + o.vReflectXY_vRefractYX = float4( vReflectPos.x, vReflectPos.y, vRefractPos.y, vRefractPos.x ); + o.W = vProjPos.w; + + o.screenCoord = vProjPos.x; + + // Compute fog based on the position + float3 vWorldPos = mul( v.vPos, cModel[0] ); + o.fogFactorW = o.vFog = CalcFog( vWorldPos, vProjPos, FOGTYPE_RANGE ); + + // Eye vector + float3 vWorldEyeVect = cEyePos - vWorldPos; + // Transform to the tangent space + o.vTangentEyeVect.x = dot( vWorldEyeVect, v.vTangentS ); + o.vTangentEyeVect.y = dot( vWorldEyeVect, v.vTangentT ); + o.vTangentEyeVect.z = dot( vWorldEyeVect, vObjNormal ); + + // Tranform bump coordinates + o.vBumpTexCoordXY_vTexCoordXY.x = dot( v.vBaseTexCoord, cBumpTexCoordTransform[0] ); + o.vBumpTexCoordXY_vTexCoordXY.y = dot( v.vBaseTexCoord, cBumpTexCoordTransform[1] ); + +#if BASETEXTURE + o.vBumpTexCoordXY_vTexCoordXY.z = dot( v.vBaseTexCoord, cBaseTextureTransform[0] ); + o.vBumpTexCoordXY_vTexCoordXY.w = dot( v.vBaseTexCoord, cBaseTextureTransform[1] ); + + o.lightmapTexCoord1And2.xy = v.vLightmapTexCoord + v.vLightmapTexCoordOffset; + + float2 lightmapTexCoord2 = o.lightmapTexCoord1And2.xy + v.vLightmapTexCoordOffset; + float2 lightmapTexCoord3 = lightmapTexCoord2 + v.vLightmapTexCoordOffset; + + // reversed component order + o.lightmapTexCoord1And2.w = lightmapTexCoord2.x; + o.lightmapTexCoord1And2.z = lightmapTexCoord2.y; + + o.lightmapTexCoord3.xy = lightmapTexCoord3; +#else + o.vBumpTexCoordXY_vTexCoordXY.z = 0.0f; + o.vBumpTexCoordXY_vTexCoordXY.w = 0.0f; +#endif + + return o; +} + diff --git a/sp/src/materialsystem/stdshaders/SDK_refract_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_refract_ps2x.fxc new file mode 100644 index 00000000..0e2c92bf --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_refract_ps2x.fxc @@ -0,0 +1,250 @@ +//====== Copyright © 1996-2007, Valve Corporation, All rights reserved. ======= +// +//============================================================================= + +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] +// STATIC: "BLUR" "0..1" +// STATIC: "FADEOUTONSILHOUETTE" "0..1" +// STATIC: "CUBEMAP" "0..1" +// STATIC: "REFRACTTINTTEXTURE" "0..1" +// STATIC: "MASKED" "0..1" +// STATIC: "COLORMODULATE" "0..1" +// STATIC: "SECONDARY_NORMAL" "0..1" +// STATIC: "NORMAL_DECODE_MODE" "0..0" [XBOX] +// STATIC: "NORMAL_DECODE_MODE" "0..0" [PC] +// STATIC: "SHADER_SRGB_READ" "0..1" [ps20b] + +// DYNAMIC: "PIXELFOGTYPE" "0..1" +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX] + +// SKIP: $MASKED && $BLUR + +#if defined( SHADER_MODEL_PS_2_0 ) +# define WRITE_DEPTH_TO_DESTALPHA 0 +#endif + +#include "common_ps_fxc.h" +#include "shader_constant_register_map.h" + +sampler NormalSampler2 : register( s1 ); +sampler RefractSampler : register( s2 ); +sampler NormalSampler : register( s3 ); +#if CUBEMAP +sampler EnvmapSampler : register( s4 ); +#endif +#if REFRACTTINTTEXTURE +sampler RefractTintSampler : register( s5 ); +#endif + +#if NORMAL_DECODE_MODE == NORM_DECODE_ATI2N_ALPHA +sampler AlphaMapSampler : register( s6 ); // alpha +sampler AlphaMapSampler2 : register( s7 ); +#else +#define AlphaMapSampler2 NormalSampler +#define AlphaMapSampler NormalSampler2 +#endif + +const float3 g_EnvmapTint : register( c0 ); +const float3 g_RefractTint : register( c1 ); +const float3 g_EnvmapContrast : register( c2 ); +const float3 g_EnvmapSaturation : register( c3 ); +const float4 g_c5 : register( c5 ); +#define g_RefractScale g_c5.x +#define g_flTime g_c5.w + +const float4 g_FogParams : register( PSREG_FOG_PARAMS ); +const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT ); + +static const int g_BlurCount = BLUR; +static const float g_BlurFraction = 1.0f / 512.0f; +static const float g_HalfBlurFraction = 0.5 * g_BlurFraction; +static const float4 g_BlurFractionVec = float4( g_BlurFraction, g_HalfBlurFraction, + -g_BlurFraction,-g_HalfBlurFraction ); + +struct PS_INPUT +{ + float4 vBumpTexCoord : TEXCOORD0; // NormalMap1 in xy, NormalMap2 in wz + float3 vTangentVertToEyeVector : TEXCOORD1; + float3 vWorldNormal : TEXCOORD2; + float3 vWorldTangent : TEXCOORD3; + float3 vWorldBinormal : TEXCOORD4; + float3 vRefractXYW : TEXCOORD5; + float3 vWorldViewVector : TEXCOORD6; +#if COLORMODULATE + float4 ColorModulate : COLOR0; +#endif + + float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog + float4 fogFactorW : COLOR1; +}; + +float4 main( PS_INPUT i ) : COLOR +{ + float3 result; + + float pixelFogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); + +#if FADEOUTONSILHOUETTE + //float blend = -i.projNormal.z; + float blend = saturate( dot( -i.vWorldViewVector.xyz, i.vWorldNormal.xyz ) ); + blend = blend * blend * blend; +#else + float blend = 1.0f; +#endif + + // Decompress normal + float4 vNormal = DecompressNormal( NormalSampler, i.vBumpTexCoord.xy, NORMAL_DECODE_MODE, AlphaMapSampler ); + +#if SECONDARY_NORMAL + float3 vNormal2 = DecompressNormal( NormalSampler2, i.vBumpTexCoord.wz, NORMAL_DECODE_MODE, AlphaMapSampler2 ); + vNormal.xyz = normalize( vNormal.xyz + vNormal2.xyz ); +#endif + +#if REFRACTTINTTEXTURE + float3 refractTintColor = 2.0 * g_RefractTint * tex2D( RefractTintSampler, i.vBumpTexCoord.xy ); +#else + float3 refractTintColor = g_RefractTint; +#endif + +#if COLORMODULATE + refractTintColor *= i.ColorModulate.rgb; +#endif + + // Perform division by W only once + float ooW = 1.0f / i.vRefractXYW.z; + + // Compute coordinates for sampling refraction + float2 vRefractTexCoordNoWarp = i.vRefractXYW.xy * ooW; + float2 vRefractTexCoord = vNormal.xy; + float scale = vNormal.a * g_RefractScale; +#if COLORMODULATE + scale *= i.ColorModulate.a; +#endif + vRefractTexCoord *= scale; + vRefractTexCoord += vRefractTexCoordNoWarp; + +#if (BLUR==1) // use polyphase magic to convert 9 lookups into 4 + + // basic principle behind this transformation: + // [ A B C ] + // [ D E F ] + // [ G H I ] + // use bilinear filtering hardware to weight upper 2x2 samples evenly (0.25* [A + B + D + E]). + // scale the upper 2x2 by 4/9 (total area of kernel occupied) + // use bilinear filtering hardware to weight right 1x2 samples evenly (0.5*[C + F]) + // scale right 1x2 by 2/9 + // use bilinear filtering hardware to weight lower 2x1 samples evenly (0.5*[G + H]) + // scale bottom 2x1 by 2/9 + // fetch last sample (I) and scale by 1/9. + + float2 upper_2x2_loc = vRefractTexCoord.xy - float2(g_HalfBlurFraction, g_HalfBlurFraction); + float2 right_1x2_loc = vRefractTexCoord.xy + float2(g_BlurFraction, -g_HalfBlurFraction); + float2 lower_2x1_loc = vRefractTexCoord.xy + float2(-g_HalfBlurFraction, g_BlurFraction); + float2 singleton_loc = vRefractTexCoord.xy + float2(g_BlurFraction, g_BlurFraction); + result = tex2D(RefractSampler, upper_2x2_loc) * 0.4444444; + result += tex2D(RefractSampler, right_1x2_loc) * 0.2222222; + result += tex2D(RefractSampler, lower_2x1_loc) * 0.2222222; + result += tex2D(RefractSampler, singleton_loc) * 0.1111111; + + #if ( SHADER_SRGB_READ == 1 ) + { + // Just do this once rather than after every blur step, which is wrong, but much more efficient + result = GammaToLinear( result ); + } + #endif + + float3 unblurredColor = tex2D(RefractSampler, vRefractTexCoordNoWarp.xy); + #if ( SHADER_SRGB_READ == 1 ) + { + unblurredColor = GammaToLinear( unblurredColor ); + } + #endif + + result = lerp(unblurredColor, result * refractTintColor, blend); + +#elif (BLUR>0) // iteratively step through render target + int x, y; + + result = float3( 0.0f, 0.0f, 0.0f ); + for( x = -g_BlurCount; x <= g_BlurCount; x++ ) + { + for( y = -g_BlurCount; y <= g_BlurCount; y++ ) + { + result += tex2D( RefractSampler, vRefractTexCoord.xy + float2( g_BlurFraction * x, g_BlurFraction * y ) ); + } + } + + int width = g_BlurCount * 2 + 1; + result *= 1.0f / ( width * width ); + + #if ( SHADER_SRGB_READ == 1 ) + { + // Just do this once rather than after every blur step, which is wrong, but much more efficient + result = GammaToLinear( result ); + } + #endif + + // result is the blurred one now. . .now lerp. + float3 unblurredColor = tex2D( RefractSampler, vRefractTexCoordNoWarp.xy ); + #if ( SHADER_SRGB_READ == 1 ) + { + unblurredColor = GammaToLinear( unblurredColor ); + } + #endif + + result = lerp( unblurredColor, result * refractTintColor, blend ); +#else +# if MASKED + float4 fMaskedResult = tex2D( RefractSampler, vRefractTexCoord.xy ); + #if ( SHADER_SRGB_READ == 1 ) + { + fMaskedResult = GammaToLinear( fMaskedResult ); + } + #endif + + return FinalOutput( fMaskedResult, pixelFogFactor, PIXELFOGTYPE, TONEMAP_SCALE_NONE ); +# else + float3 colorWarp = tex2D( RefractSampler, vRefractTexCoord.xy ); + #if ( SHADER_SRGB_READ == 1 ) + { + colorWarp = GammaToLinear( colorWarp ); + } + #endif + float3 colorNoWarp = tex2D( RefractSampler, vRefractTexCoordNoWarp.xy ); + #if ( SHADER_SRGB_READ == 1 ) + { + colorNoWarp = GammaToLinear( colorNoWarp ); + } + #endif + + colorWarp *= refractTintColor; + result = lerp( colorNoWarp, colorWarp, blend ); +# endif +#endif + +#if CUBEMAP + float specularFactor = vNormal.a; + + float3 worldSpaceNormal = Vec3TangentToWorld( vNormal.xyz, i.vWorldNormal, i.vWorldTangent, i.vWorldBinormal ); + + float3 reflectVect = CalcReflectionVectorUnnormalized( worldSpaceNormal, i.vTangentVertToEyeVector ); + float3 specularLighting = texCUBE( EnvmapSampler, reflectVect ); + specularLighting *= specularFactor; + specularLighting *= g_EnvmapTint; + float3 specularLightingSquared = specularLighting * specularLighting; + specularLighting = lerp( specularLighting, specularLightingSquared, g_EnvmapContrast ); + float3 greyScale = dot( specularLighting, float3( 0.299f, 0.587f, 0.114f ) ); + specularLighting = lerp( greyScale, specularLighting, g_EnvmapSaturation ); + result += specularLighting; +#endif + +#if COLORMODULATE + float resultAlpha = i.ColorModulate.a * vNormal.a; +#else + float resultAlpha = vNormal.a; +#endif + + return FinalOutput( float4( result, resultAlpha ), pixelFogFactor, PIXELFOGTYPE, TONEMAP_SCALE_NONE, (WRITE_DEPTH_TO_DESTALPHA != 0), i.worldPos_projPosZ.w ); +} diff --git a/sp/src/materialsystem/stdshaders/SDK_skin_ps20b.fxc b/sp/src/materialsystem/stdshaders/SDK_skin_ps20b.fxc new file mode 100644 index 00000000..5f3bbbbe --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_skin_ps20b.fxc @@ -0,0 +1,378 @@ +//======= Copyright © 1996-2007, Valve Corporation, All rights reserved. ====== +// STATIC: "CONVERT_TO_SRGB" "0..0" +// STATIC: "CUBEMAP" "0..1" +// STATIC: "SELFILLUM" "0..1" +// STATIC: "SELFILLUMFRESNEL" "0..1" +// STATIC: "FLASHLIGHT" "0..1" +// STATIC: "LIGHTWARPTEXTURE" "0..1" +// STATIC: "PHONGWARPTEXTURE" "0..1" +// STATIC: "WRINKLEMAP" "0..1" +// STATIC: "DETAIL_BLEND_MODE" "0..6" +// STATIC: "DETAILTEXTURE" "0..1" +// STATIC: "RIMLIGHT" "0..1" +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps20b] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps30] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..0" [ps20b] [XBOX] +// STATIC: "FASTPATH_NOBUMP" "0..1" +// STATIC: "BLENDTINTBYBASEALPHA" "0..1" +// STATIC: "PHONG_HALFLAMBERT" "0..1" + +// DYNAMIC: "WRITEWATERFOGTODESTALPHA" "0..1" +// DYNAMIC: "PIXELFOGTYPE" "0..1" +// DYNAMIC: "NUM_LIGHTS" "0..4" +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps30] +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps20b] +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps30] + + +// SKIP: ($PIXELFOGTYPE == 0) && ($WRITEWATERFOGTODESTALPHA != 0) + +// blend mode doesn't matter if we only have one texture +// SKIP: (! $DETAILTEXTURE) && ( $DETAIL_BLEND_MODE != 0 ) + +// We don't care about flashlight depth unless the flashlight is on +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) + +// Flashlight shadow filter mode is irrelevant if there is no flashlight +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) [ps20b] +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) [ps30] + +// Only need self illum fresnel when self illum enabled +// SKIP: ( $SELFILLUM == 0 ) && ( $SELFILLUMFRESNEL == 1 ) +// SKIP: ( $FLASHLIGHT == 1 ) && ( $SELFILLUMFRESNEL == 1 ) +// SKIP: ( $FLASHLIGHT == 1 ) && ( $SELFILLUM == 1 ) + +// BlendTintByBaseAlpha and self illum and are opposing meanings for alpha channel +// SKIP: ( $BLENDTINTBYBASEALPHA ) && ( $SELFILLUM ) + +// fastpath means: +// no bumpmap +// basealphaenvmapmask (not inverted) +// no spec expmap +// no spectint +// no specwarp +// no rimlight +// no selfillum +// no detail +// no BlendTintByBaseAlpha + +// SKIP: $FASTPATH_NOBUMP && ( $RIMLIGHT || $DETAILTEXTURE || $PHONGWARPTEXTURE || $SELFILLUM || $BLENDTINTBYBASEALPHA ) + + + +#include "common_flashlight_fxc.h" +#include "shader_constant_register_map.h" + +const float4 g_SelfIllumTint_and_DetailBlendFactor : register( PSREG_SELFILLUMTINT ); +#if ( SELFILLUMFRESNEL == 1 ) +const float4 g_SelfIllumScaleBiasExpBrightness : register( PSREG_SELFILLUM_SCALE_BIAS_EXP ); +#endif +const float4 g_DiffuseModulation : register( PSREG_DIFFUSE_MODULATION ); +const float4 g_EnvmapTint_ShadowTweaks : register( PSREG_ENVMAP_TINT__SHADOW_TWEAKS ); // w controls spec mask +const float3 cAmbientCube[6] : register( PSREG_AMBIENT_CUBE ); +const float4 g_EnvMapFresnel : register( PSREG_ENVMAP_FRESNEL__SELFILLUMMASK ); // x is envmap fresnel ... w is selfillummask control +const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT ); +const float4 g_FogParams : register( PSREG_FOG_PARAMS ); +const float4 g_FlashlightAttenuationFactors_RimMask : register( PSREG_FLASHLIGHT_ATTENUATION ); // On non-flashlight pass, x has rim mask control +const float4 g_FlashlightPos_RimBoost : register( PSREG_FLASHLIGHT_POSITION_RIM_BOOST ); +const float4x4 g_FlashlightWorldToTexture : register( PSREG_FLASHLIGHT_TO_WORLD_TEXTURE ); +const float4 g_FresnelSpecParams : register( PSREG_FRESNEL_SPEC_PARAMS ); // xyz are fresnel, w is specular boost +const float4 g_SpecularRimParams : register( PSREG_SPEC_RIM_PARAMS ); // xyz are specular tint color, w is rim power +PixelShaderLightInfo cLightInfo[3] : register( PSREG_LIGHT_INFO_ARRAY ); // 2 registers each - 6 registers total (4th light spread across w's) + +// TODO: give this a better name. For now, I don't want to touch shader_constant_register_map.h since I don't want to trigger a recompile of everything... +const float4 g_ShaderControls : register( PSREG_CONSTANT_27 ); // x is basemap alpgha phong mask, y is 1 - blendtintbybasealpha, z is tint overlay amount, w controls "INVERTPHONGMASK" +#define g_FlashlightPos g_FlashlightPos_RimBoost.xyz +#define g_fRimBoost g_FlashlightPos_RimBoost.w +#define g_FresnelRanges g_FresnelSpecParams.xyz +#define g_SpecularBoost g_FresnelSpecParams.w +#define g_SpecularTint g_SpecularRimParams.xyz +#define g_RimExponent g_SpecularRimParams.w +#define g_FlashlightAttenuationFactors g_FlashlightAttenuationFactors_RimMask +#define g_RimMaskControl g_FlashlightAttenuationFactors_RimMask.x +#define g_SelfIllumMaskControl g_EnvMapFresnel.w +#define g_fBaseMapAlphaPhongMask g_ShaderControls.x +#define g_fTintReplacementControl g_ShaderControls.z +#define g_fInvertPhongMask g_ShaderControls.w +#define g_fMinLighting g_ShaderControls.y + +sampler BaseTextureSampler : register( s0 ); // Base map, selfillum in alpha +sampler SpecularWarpSampler : register( s1 ); // Specular warp sampler (for iridescence etc) +sampler DiffuseWarpSampler : register( s2 ); // Lighting warp sampler (1D texture for diffuse lighting modification) +sampler NormalMapSampler : register( s3 ); // Normal map, specular mask in alpha +sampler ShadowDepthSampler : register( s4 ); // Flashlight shadow depth map sampler +sampler NormalizeRandRotSampler : register( s5 ); // Normalization / RandomRotation samplers +sampler FlashlightSampler : register( s6 ); // Flashlight cookie +sampler SpecExponentSampler : register( s7 ); // Specular exponent map +sampler EnvmapSampler : register( s8 ); // Cubic environment map + +#if WRINKLEMAP +sampler WrinkleSampler : register( s9 ); // Compression base +sampler StretchSampler : register( s10 ); // Expansion base +sampler NormalWrinkleSampler : register( s11 ); // Compression base +sampler NormalStretchSampler : register( s12 ); // Expansion base +#endif + +#if DETAILTEXTURE +sampler DetailSampler : register( s13 ); // detail texture +#endif + +sampler SelfIllumMaskSampler : register( s14 ); // selfillummask + + +struct PS_INPUT +{ + float4 baseTexCoordDetailTexCoord : TEXCOORD0; // xy=base zw=detail + float3 lightAtten : TEXCOORD1; // Scalar light attenuation factors for FOUR lights + float3 worldVertToEyeVectorXYZ_tangentSpaceVertToEyeVectorZ : TEXCOORD2; + float3x3 tangentSpaceTranspose : TEXCOORD3; + // second row : TEXCOORD4; + // third row : TEXCOORD5; + float4 worldPos_atten3 : TEXCOORD6; + float4 projPos_fWrinkleWeight : TEXCOORD7; +}; + + + +float4 main( PS_INPUT i ) : COLOR +{ + bool bWrinkleMap = WRINKLEMAP ? true : false; + bool bDoDiffuseWarp = LIGHTWARPTEXTURE ? true : false; + bool bDoSpecularWarp = PHONGWARPTEXTURE ? true : false; + bool bDoAmbientOcclusion = false; + bool bFlashlight = (FLASHLIGHT!=0) ? true : false; + bool bSelfIllum = SELFILLUM ? true : false; + bool bDoRimLighting = RIMLIGHT ? true : false; + bool bCubemap = CUBEMAP ? true : false; + bool bBlendTintByBaseAlpha = BLENDTINTBYBASEALPHA ? true : false; + int nNumLights = NUM_LIGHTS; + + // Unpacking for convenience + float fWrinkleWeight = i.projPos_fWrinkleWeight.w; + float3 vProjPos = i.projPos_fWrinkleWeight.xyz; + float3 vWorldPos = i.worldPos_atten3.xyz; + float atten3 = i.worldPos_atten3.w; + + float4 vLightAtten = float4( i.lightAtten, atten3 ); + +#if WRINKLEMAP + float flWrinkleAmount = saturate( -fWrinkleWeight ); // One of these two is zero + float flStretchAmount = saturate( fWrinkleWeight ); // while the other is in the 0..1 range + + float flTextureAmount = 1.0f - flWrinkleAmount - flStretchAmount; // These should sum to one +#endif + + float4 baseColor = tex2D( BaseTextureSampler, i.baseTexCoordDetailTexCoord.xy ); +#if WRINKLEMAP + float4 wrinkleColor = tex2D( WrinkleSampler, i.baseTexCoordDetailTexCoord.xy ); + float4 stretchColor = tex2D( StretchSampler, i.baseTexCoordDetailTexCoord.xy ); + + // Apply wrinkle blend to only RGB. Alpha comes from the base texture + baseColor.rgb = flTextureAmount * baseColor + flWrinkleAmount * wrinkleColor + flStretchAmount * stretchColor; +#endif + +#if DETAILTEXTURE + float4 detailColor = tex2D( DetailSampler, i.baseTexCoordDetailTexCoord.zw ); + baseColor = TextureCombine( baseColor, detailColor, DETAIL_BLEND_MODE, g_SelfIllumTint_and_DetailBlendFactor.w ); +#endif + + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, vWorldPos.xyz, vProjPos.z ); + + float3 vEyeDir = normalize(i.worldVertToEyeVectorXYZ_tangentSpaceVertToEyeVectorZ.xyz); + float3 vRimAmbientCubeColor = PixelShaderAmbientLight(vEyeDir, cAmbientCube); + + float3 worldSpaceNormal, tangentSpaceNormal; + float fSpecMask = 1.0f; + float4 normalTexel = tex2D( NormalMapSampler, i.baseTexCoordDetailTexCoord.xy ); + +#if WRINKLEMAP + float4 wrinkleNormal = tex2D( NormalWrinkleSampler, i.baseTexCoordDetailTexCoord.xy ); + float4 stretchNormal = tex2D( NormalStretchSampler, i.baseTexCoordDetailTexCoord.xy ); + normalTexel = flTextureAmount * normalTexel + flWrinkleAmount * wrinkleNormal + flStretchAmount * stretchNormal; +#endif + +#if (FASTPATH_NOBUMP == 0 ) + tangentSpaceNormal = lerp( 2.0f * normalTexel.xyz - 1.0f, float3(0, 0, 1), g_fBaseMapAlphaPhongMask ); + fSpecMask = lerp( normalTexel.a, baseColor.a, g_fBaseMapAlphaPhongMask ); +#else + tangentSpaceNormal = float3(0, 0, 1); + fSpecMask = baseColor.a; +#endif + + // We need a normal if we're doing any lighting + worldSpaceNormal = normalize( mul( i.tangentSpaceTranspose, tangentSpaceNormal ) ); + + float fFresnelRanges = Fresnel( worldSpaceNormal, vEyeDir, g_FresnelRanges ); + float fRimFresnel = Fresnel4( worldSpaceNormal, vEyeDir ); + + // Break down reflect so that we can share dot(worldSpaceNormal,vEyeDir) with fresnel terms + float3 vReflect = 2 * worldSpaceNormal * dot(worldSpaceNormal, vEyeDir) - vEyeDir; + + float3 diffuseLighting = float3( 1.0f, 1.0f, 1.0f ); + float3 envMapColor = float3( 0.0f, 0.0f, 0.0f ); + if( !bFlashlight ) + { + // Summation of diffuse illumination from all local lights + diffuseLighting = PixelShaderDoLighting( vWorldPos, worldSpaceNormal, + float3( 0.0f, 0.0f, 0.0f ), false, true, vLightAtten, + cAmbientCube, NormalizeRandRotSampler, nNumLights, cLightInfo, PHONG_HALFLAMBERT, + + // These parameters aren't passed by generic shaders: + false, 1.0f, + bDoDiffuseWarp, DiffuseWarpSampler ); + + if( bCubemap ) + { + // Mask is either normal map alpha or base map alpha +#if ( SELFILLUMFRESNEL == 1 ) // This is to match the 2.0 version of vertexlitgeneric + float fEnvMapMask = lerp( baseColor.a, g_fInvertPhongMask, g_EnvmapTint_ShadowTweaks.w ); +#else + float fEnvMapMask = lerp( baseColor.a, fSpecMask, g_EnvmapTint_ShadowTweaks.w ); +#endif + + envMapColor = (ENV_MAP_SCALE * + lerp(1, fFresnelRanges, g_EnvMapFresnel.x) * + lerp(fEnvMapMask, 1-fEnvMapMask, g_fInvertPhongMask)) * + texCUBE( EnvmapSampler, vReflect ) * + g_EnvmapTint_ShadowTweaks.xyz; + } + } + + float3 specularLighting = float3( 0.0f, 0.0f, 0.0f ); + float3 rimLighting = float3( 0.0f, 0.0f, 0.0f ); + + float3 vSpecularTint = 1; + float fRimMask = 0; + float fSpecExp = 1; + +#if ( FASTPATH_NOBUMP == 0 ) + float4 vSpecExpMap = tex2D( SpecExponentSampler, i.baseTexCoordDetailTexCoord.xy ); + + if ( !bFlashlight ) + { + fRimMask = lerp( 1.0f, vSpecExpMap.a, g_RimMaskControl ); // Select rim mask + } + + // If the exponent passed in as a constant is zero, use the value from the map as the exponent +#if defined( _X360 ) + [flatten] +#endif + + fSpecExp = (g_EyePos_SpecExponent.w >= 0.0) ? g_EyePos_SpecExponent.w : (1.0f + 149.0f * vSpecExpMap.r); + + // If constant tint is negative, tint with albedo, based upon scalar tint map +#if defined( _X360 ) + [flatten] +#endif + vSpecularTint = lerp( float3(1.0f, 1.0f, 1.0f), baseColor.rgb, vSpecExpMap.g ); + vSpecularTint = (g_SpecularTint.r >= 0.0) ? g_SpecularTint.rgb : vSpecularTint; + +#else + fSpecExp = max(g_EyePos_SpecExponent.w, 0); +#endif + + float3 albedo = baseColor.rgb; + + if ( !bFlashlight ) + { + // Summation of specular from all local lights besides the flashlight + PixelShaderDoSpecularLighting( vWorldPos, worldSpaceNormal, + fSpecExp, vEyeDir, vLightAtten, + nNumLights, cLightInfo, false, 1.0f, bDoSpecularWarp, + SpecularWarpSampler, fFresnelRanges, bDoRimLighting, g_RimExponent, + + // Outputs + specularLighting, rimLighting ); + } + else + { + float4 flashlightSpacePosition = mul( float4( vWorldPos, 1.0f ), g_FlashlightWorldToTexture ); + + DoSpecularFlashlight( g_FlashlightPos, vWorldPos, flashlightSpacePosition, worldSpaceNormal, + g_FlashlightAttenuationFactors.xyz, g_FlashlightAttenuationFactors.w, + FlashlightSampler, ShadowDepthSampler, NormalizeRandRotSampler, FLASHLIGHTDEPTHFILTERMODE, FLASHLIGHTSHADOWS, true, vProjPos.xy / vProjPos.z, + fSpecExp, vEyeDir, bDoSpecularWarp, SpecularWarpSampler, fFresnelRanges, g_EnvmapTint_ShadowTweaks, + + // These two values are output + diffuseLighting, specularLighting ); + } + + // If we didn't already apply Fresnel to specular warp, modulate the specular + if ( !bDoSpecularWarp ) + fSpecMask *= fFresnelRanges; + + // Modulate with spec mask, boost and tint + specularLighting *= fSpecMask * g_SpecularBoost; + + if (bBlendTintByBaseAlpha) + { + float3 tintedColor = albedo * g_DiffuseModulation.rgb; + tintedColor = lerp(tintedColor, g_DiffuseModulation.rgb, g_fTintReplacementControl); + albedo = lerp(albedo, tintedColor, baseColor.a); + } + else + { + albedo = albedo * g_DiffuseModulation.rgb; + } + +#if FOGTYPE == 2 || FLASHLIGHT != 0 + float3 diffuseComponent = albedo * diffuseLighting; +#else + float flFresnelMinlight = saturate( dot( worldSpaceNormal, vEyeDir ) ); + float3 diffuseComponent = albedo * lerp( diffuseLighting, 1, g_fMinLighting * flFresnelMinlight ); +#endif + + if ( bSelfIllum && !bFlashlight ) + { +#if ( SELFILLUMFRESNEL == 1 ) // To free up the constant register...see top of file + // This will apply a Fresnel term based on the vertex normal (not the per-pixel normal!) to help fake and internal glow look + float3 vVertexNormal = normalize( float3( i.tangentSpaceTranspose[0].z, i.tangentSpaceTranspose[1].z, i.tangentSpaceTranspose[2].z ) ); + float flSelfIllumFresnel = ( pow( saturate( dot( vVertexNormal.xyz, vEyeDir.xyz ) ), g_SelfIllumScaleBiasExpBrightness.z ) * g_SelfIllumScaleBiasExpBrightness.x ) + g_SelfIllumScaleBiasExpBrightness.y; + diffuseComponent = lerp( diffuseComponent, g_SelfIllumTint_and_DetailBlendFactor.rgb * albedo * g_SelfIllumScaleBiasExpBrightness.w, baseColor.a * saturate( flSelfIllumFresnel ) ); +#else + float3 vSelfIllumMask = tex2D( SelfIllumMaskSampler, i.baseTexCoordDetailTexCoord.xy ); + vSelfIllumMask = lerp( baseColor.aaa, vSelfIllumMask, g_SelfIllumMaskControl ); + diffuseComponent = lerp( diffuseComponent, g_SelfIllumTint_and_DetailBlendFactor.rgb * albedo, vSelfIllumMask ); +#endif + + diffuseComponent = max( 0.0f, diffuseComponent ); + } + +#if DETAILTEXTURE + diffuseComponent = TextureCombinePostLighting( diffuseComponent, detailColor, + DETAIL_BLEND_MODE, g_SelfIllumTint_and_DetailBlendFactor.w ); +#endif + + if ( bDoRimLighting && !bFlashlight ) + { + float fRimMultiply = fRimMask * fRimFresnel; // both unit range: [0, 1] + + // Add in rim light modulated with tint, mask and traditional Fresnel (not using Fresnel ranges) + rimLighting *= fRimMultiply; + + // Fold rim lighting into specular term by using the max so that we don't really add light twice... + specularLighting = max( specularLighting, rimLighting ); + + // Add in view-ray lookup from ambient cube + specularLighting += (vRimAmbientCubeColor * g_fRimBoost) * saturate(fRimMultiply * worldSpaceNormal.z); + } + + float3 result = specularLighting*vSpecularTint + envMapColor + diffuseComponent; + +#if WRITEWATERFOGTODESTALPHA && ( PIXELFOGTYPE == PIXEL_FOG_TYPE_HEIGHT ) + float alpha = fogFactor; +#else + float alpha = g_DiffuseModulation.a; + if ( !bSelfIllum && !bBlendTintByBaseAlpha ) + { + alpha = lerp( baseColor.a * alpha, alpha, g_fBaseMapAlphaPhongMask ); + } +#endif + + bool bWriteDepthToAlpha = ( WRITE_DEPTH_TO_DESTALPHA != 0 ) && ( WRITEWATERFOGTODESTALPHA == 0 ); + + //FIXME: need to take dowaterfog into consideration + return FinalOutput( float4( result, alpha ), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, bWriteDepthToAlpha, vProjPos.z ); +} diff --git a/sp/src/materialsystem/stdshaders/SDK_skin_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_skin_vs20.fxc new file mode 100644 index 00000000..9b04b7aa --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_skin_vs20.fxc @@ -0,0 +1,173 @@ +//======= Copyright (c) 1996-2007, Valve Corporation, All rights reserved. ====== + +// STATIC: "DECAL" "0..1" [vs30] +// STATIC: "USE_STATIC_CONTROL_FLOW" "0..1" [vs20] + +// DYNAMIC: "COMPRESSED_VERTS" "0..1" +// DYNAMIC: "DOWATERFOG" "0..1" +// DYNAMIC: "SKINNING" "0..1" +// DYNAMIC: "LIGHTING_PREVIEW" "0..1" [PC] +// DYNAMIC: "LIGHTING_PREVIEW" "0..0" [XBOX] +// DYNAMIC: "MORPHING" "0..1" [vs30] +// DYNAMIC: "NUM_LIGHTS" "0..2" [vs20] + +// If using static control flow on Direct3D, we should use the NUM_LIGHTS=0 combo +// SKIP: $USE_STATIC_CONTROL_FLOW && ( $NUM_LIGHTS > 0 ) [vs20] + +#include "common_vs_fxc.h" + +static const bool g_bSkinning = SKINNING ? true : false; +static const int g_FogType = DOWATERFOG; + +const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 ); +const float4 cDetailTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_4 ); + +#ifdef SHADER_MODEL_VS_3_0 +// NOTE: cMorphTargetTextureDim.xy = target dimensions, +// cMorphTargetTextureDim.z = 4tuples/morph +const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_6 ); +const float4 cMorphSubrect : register( SHADER_SPECIFIC_CONST_7 ); + +sampler2D morphSampler : register( D3DVERTEXTEXTURESAMPLER0, s0 ); +#endif + + +//----------------------------------------------------------------------------- +// Input vertex format +//----------------------------------------------------------------------------- +struct VS_INPUT +{ + // This is all of the stuff that we ever use. + float4 vPos : POSITION; + float4 vBoneWeights : BLENDWEIGHT; + float4 vBoneIndices : BLENDINDICES; + float4 vNormal : NORMAL; + float4 vColor : COLOR0; + float3 vSpecular : COLOR1; + // make these float2's and stick the [n n 0 1] in the dot math. + float4 vTexCoord0 : TEXCOORD0; + float4 vTexCoord1 : TEXCOORD1; + float4 vTexCoord2 : TEXCOORD2; + float4 vTexCoord3 : TEXCOORD3; + float3 vTangentS : TANGENT; + float3 vTangentT : BINORMAL; + float4 vUserData : TANGENT; + + // Position and normal/tangent deltas + float4 vPosFlex : POSITION1; + float4 vNormalFlex : NORMAL1; + +#ifdef SHADER_MODEL_VS_3_0 + float vVertexID : POSITION2; +#endif +}; + +struct VS_OUTPUT +{ + // Stuff that isn't seen by the pixel shader + float4 projPos : POSITION; +#if !defined( _X360 ) + float fog : FOG; +#endif + // Stuff that is seen by the pixel shader + float4 baseTexCoord : TEXCOORD0; // includes detail tex coord + float3 lightAtten : TEXCOORD1; + float3 worldVertToEyeVector : TEXCOORD2; + float3x3 tangentSpaceTranspose : TEXCOORD3; + // second row : TEXCOORD4; + // third row : TEXCOORD5; + float4 worldPos_atten3 : TEXCOORD6; + float4 projPos_fWrinkleWeight : TEXCOORD7; +}; + +//----------------------------------------------------------------------------- +// Main shader entry point +//----------------------------------------------------------------------------- +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + + float4 vPosition = v.vPos; + float3 vNormal; + float4 vTangent; + DecompressVertex_NormalTangent( v.vNormal, v.vUserData, vNormal, vTangent ); + +#if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING + ApplyMorph( v.vPosFlex, v.vNormalFlex, + vPosition.xyz, vNormal, vTangent.xyz, o.projPos_fWrinkleWeight.w ); +#else + ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, v.vVertexID, v.vTexCoord2, + vPosition.xyz, vNormal, vTangent.xyz, o.projPos_fWrinkleWeight.w ); +#endif + + // Perform skinning + float3 worldNormal, worldPos, worldTangentS, worldTangentT; + SkinPositionNormalAndTangentSpace( g_bSkinning, vPosition, vNormal, vTangent, + v.vBoneWeights, v.vBoneIndices, worldPos, + worldNormal, worldTangentS, worldTangentT ); + + // Always normalize since flex path is controlled by runtime + // constant not a shader combo and will always generate the normalization + worldNormal = normalize( worldNormal ); + worldTangentS = normalize( worldTangentS ); + worldTangentT = normalize( worldTangentT ); + +#if defined( SHADER_MODEL_VS_3_0 ) && MORPHING && DECAL + // Avoid z precision errors + worldPos += worldNormal * 0.05f * v.vTexCoord2.z; +#endif + + // Transform into projection space + float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj ); + o.projPos = vProjPos; + vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ ); + + o.projPos_fWrinkleWeight.xyz = vProjPos.xyz; + +#if !defined( _X360 ) + o.fog = CalcFog( worldPos, vProjPos.xyz, g_FogType ); +#endif + // Needed for water fog alpha and diffuse lighting + // FIXME: we shouldn't have to compute this all the time. + o.worldPos_atten3.xyz = worldPos; + + // Needed for specular + o.worldVertToEyeVector = VSHADER_VECT_SCALE * (cEyePos - worldPos); + + // Compute bumped lighting + // FIXME: We shouldn't have to compute this for unlit materials +#if defined ( SHADER_MODEL_VS_2_0 ) && ( !USE_STATIC_CONTROL_FLOW ) + o.lightAtten.xyz = float3(0,0,0); + o.worldPos_atten3.w = 0.0f; + #if ( NUM_LIGHTS > 0 ) + o.lightAtten.x = GetVertexAttenForLight( worldPos, 0, false ); + #endif + #if ( NUM_LIGHTS > 1 ) + o.lightAtten.y = GetVertexAttenForLight( worldPos, 1, false ); + #endif + #if ( NUM_LIGHTS > 2 ) + o.lightAtten.z = GetVertexAttenForLight( worldPos, 2, false ); + #endif + #if ( NUM_LIGHTS > 3 ) + o.worldPos_atten3.w = GetVertexAttenForLight( worldPos, 3, false ); + #endif +#else + o.lightAtten.x = GetVertexAttenForLight( worldPos, 0, true ); + o.lightAtten.y = GetVertexAttenForLight( worldPos, 1, true ); + o.lightAtten.z = GetVertexAttenForLight( worldPos, 2, true ); + o.worldPos_atten3.w = GetVertexAttenForLight( worldPos, 3, true ); +#endif + + // Base texture coordinate transform + o.baseTexCoord.x = dot( v.vTexCoord0, cBaseTexCoordTransform[0] ); + o.baseTexCoord.y = dot( v.vTexCoord0, cBaseTexCoordTransform[1] ); + o.baseTexCoord.z = dot( v.vTexCoord0, cDetailTexCoordTransform[0] ); + o.baseTexCoord.w = dot( v.vTexCoord0, cDetailTexCoordTransform[1] ); + + // Tangent space transform + o.tangentSpaceTranspose[0] = float3( worldTangentS.x, worldTangentT.x, worldNormal.x ); + o.tangentSpaceTranspose[1] = float3( worldTangentS.y, worldTangentT.y, worldNormal.y ); + o.tangentSpaceTranspose[2] = float3( worldTangentS.z, worldTangentT.z, worldNormal.z ); + + return o; +} diff --git a/sp/src/materialsystem/stdshaders/SDK_splinerope_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_splinerope_ps2x.fxc new file mode 100644 index 00000000..174330bf --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_splinerope_ps2x.fxc @@ -0,0 +1,52 @@ +//========== Copyright (c) Valve Corporation, All rights reserved. ==========// + +// STATIC: "SHADER_SRGB_READ" "0..1" [XBOX] +// STATIC: "SHADER_SRGB_READ" "0..0" [PC] +// STATIC: "SHADOWDEPTH" "0..1" +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20] +// DYNAMIC: "PIXELFOGTYPE" "0..1" + +#include "common_ps_fxc.h" + +float4 g_FogParams : register( c0 ); +float3 g_EyePos : register( c1 ); + +// VS_OUTPUT in a common file. +#define PIXELSHADER +#include "common_splinerope_fxc.h" + +sampler BaseTextureSampler : register( s0 ); +sampler NormalSampler : register( s1 ); + +float4 main( PS_INPUT i ) : COLOR +{ + #if ( SHADOWDEPTH == 0 ) + { + float3 vNormalMapDir = tex2D( NormalSampler, i.texCoord.xy ); // Get the 3-vector from the normal map + float4 textureColor = tex2D( BaseTextureSampler, i.texCoord.xy ); + + //Expand compacted vectors + vNormalMapDir = ( vNormalMapDir - 0.5 ) * 2.0; + float3 vLightDir = float3( 0.0f, 0.0f, 1.0f ); + + float lightDirDotNormalMap = dot( vNormalMapDir, vLightDir ); //normalMap dot dirLightDir + + // do half-lambert on the dot + lightDirDotNormalMap = lightDirDotNormalMap * 0.5 + 0.5; + lightDirDotNormalMap = lightDirDotNormalMap * lightDirDotNormalMap; + + float4 resultColor; + resultColor.xyz = lightDirDotNormalMap * ( textureColor.rgb * i.argbcolor.rgb ); + resultColor.a = textureColor.a * i.argbcolor.a; + + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); + return FinalOutput( resultColor, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, (WRITE_DEPTH_TO_DESTALPHA != 0), i.worldPos_projPosZ.w ); + } + #else + { + return float4( 0.0f, 0.0f, 0.0f, 1.0f ); + } + #endif +} diff --git a/sp/src/materialsystem/stdshaders/SDK_splinerope_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_splinerope_vs20.fxc new file mode 100644 index 00000000..dd7c99a1 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_splinerope_vs20.fxc @@ -0,0 +1,78 @@ +//========== Copyright (c) Valve Corporation, All rights reserved. ==========// +// DYNAMIC: "DOWATERFOG" "0..1" + +#include "common_vs_fxc.h" +#include "spline_fxc.h" + +const float4x3 cModelView : register(SHADER_SPECIFIC_CONST_0); +const float4x4 cProj : register(SHADER_SPECIFIC_CONST_3); +const float g_MinPixelSize : register(SHADER_SPECIFIC_CONST_7); + +struct VS_INPUT +{ + // This is all of the stuff that we ever use. + float4 vTint : COLOR; + float4 vParms : POSITION; // T V side_id + float4 vSplinePt0 : TEXCOORD0; // x y z rad + float4 vSplinePt1 : TEXCOORD1; // x y z rad + float4 vSplinePt2 : TEXCOORD2; // x y z rad + float4 vSplinePt3 : TEXCOORD3; // x y z rad +}; + +// VS_OUTPUT in a common file. +#include "common_splinerope_fxc.h" + +#define P0 (v.vSplinePt0) +#define P1 (v.vSplinePt1) +#define P2 (v.vSplinePt2) +#define P3 (v.vSplinePt3) + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o; + + // posrad.xyz is worldspace position and posrad.w is worldspace diameter. + float4 posrad = CatmullRomSpline( P0, P1, P2, P3, v.vParms.x ); + + // calculate projected position here so that we can figure out how much to bloat the diameter to avoid aliasing of the sort where you skip pixels in a segment. + { + // PERF FIXME!! This could be simplified quite a bit if this ever becomes a bottleneck. I feel dirty. + // Get the view-space position for two points that are posrad.w units away from each other horizontally. + float3 viewPos1 = mul4x3( float4( posrad.xyz, 1.0f ), cModelView ); + float3 viewPos2 = viewPos1 + float3( posrad.w, 0.0f, 0.0f ); + + // Project both points. + float4 projPos1 = mul( float4( viewPos1, 1.0f ), cProj ); + float4 projPos2 = mul( float4( viewPos2, 1.0f ), cProj ); + + // Get the distance of the two points from each other in normalized screen space. + float projectedDiameterInPixels = abs( ( projPos1.x / projPos1.w ) - ( projPos2.x / projPos2.w ) ); + + // Compare the distance between the two points to the minimum allowed to keep from skipping pixels and causing aliasing. + if ( projectedDiameterInPixels < g_MinPixelSize ) + { + // Scale the radius in world space so that it is bigger than the required pixel size in screen space. + posrad.w *= ( g_MinPixelSize / projectedDiameterInPixels ); + } + } + + float3 v2p = float3( 0, 0, 1 ); + v2p = posrad.xyz - cEyePos; // screen aligned + + float3 tangent = DCatmullRomSpline3( P0, P1, P2, P3, v.vParms.x ); + float3 ofs = normalize( cross( v2p, normalize( tangent ) ) ); + posrad.xyz += ofs * ( posrad.w * ( v.vParms.z - .5 ) ); + o.projPos = mul( float4(posrad.xyz, 1.0f), cViewProj ); + o.worldPos_projPosZ.xyz = posrad.xyz; + o.worldPos_projPosZ.w = o.projPos.z; + o.texCoord.xy = float2( 1.0f - v.vParms.z, v.vParms.y ); + o.argbcolor = float4( v.vTint.rgb, v.vTint.a ); + + #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 ) + { + o.fog = CalcFixedFunctionFog( posrad.xyz, DOWATERFOG ); + } + #endif + + return o; +} diff --git a/sp/src/materialsystem/stdshaders/SDK_sprite_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_sprite_ps2x.fxc new file mode 100644 index 00000000..79972038 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_sprite_ps2x.fxc @@ -0,0 +1,61 @@ +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] +// STATIC: "VERTEXCOLOR" "0..1" +// STATIC: "CONSTANTCOLOR" "0..1" +// STATIC: "HDRTYPE" "0..2" +// STATIC: "SRGB" "0..1" +// STATIC: "SRGB_OUTPUT_ADAPTER" "0..1" [ps20b] + +// DYNAMIC: "HDRENABLED" "0..1" +// DYNAMIC: "PIXELFOGTYPE" "0..1" + +#include "common_ps_fxc.h" +#include "shader_constant_register_map.h" + +const HALF4 g_Color : register( c0 ); +const float g_HDRColorScale : register( c1 ); + +const float4 g_FogParams : register( PSREG_FOG_PARAMS ); +const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT ); + +sampler TexSampler : register( s0 ); + +struct PS_INPUT +{ + HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate + float4 color : TEXCOORD2; // Vertex color (from lighting or unlit) + + float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog +}; + +float4 main( PS_INPUT i ) : COLOR +{ + float4 result, sample = tex2D( TexSampler, i.baseTexCoord ); + +#if VERTEXCOLOR + sample *= i.color; +#endif + +#if CONSTANTCOLOR + sample *= g_Color; +#endif + +#if HDRTYPE && HDRENABLED + sample.xyz *= g_HDRColorScale; +#endif + + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); +#if SRGB + result = FinalOutput( sample, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR ); +#else + result = FinalOutput( sample, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_GAMMA ); +#endif + + // On Posix, we're being forced through a linear-to-gamma curve but don't want it, so we do the opposite here first +#if SRGB_OUTPUT_ADAPTER + result = GammaToLinear( result ); +#endif + + return result; +} + diff --git a/sp/src/materialsystem/stdshaders/SDK_sprite_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_sprite_vs20.fxc new file mode 100644 index 00000000..5e427c19 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_sprite_vs20.fxc @@ -0,0 +1,65 @@ +// STATIC: "VERTEXCOLOR" "0..1" +// STATIC: "SRGB" "0..1" +// DYNAMIC: "DOWATERFOG" "0..1" + +#include "common_vs_fxc.h" + +static const int g_FogType = DOWATERFOG; +static const bool g_bVertexColor = VERTEXCOLOR ? true : false; + +struct VS_INPUT +{ + // This is all of the stuff that we ever use. + float4 vPos : POSITION; + float4 vColor : COLOR0; + // make these float2's and stick the [n n 0 1] in the dot math. + float4 vTexCoord0 : TEXCOORD0; +}; + +struct VS_OUTPUT +{ + float4 projPos : POSITION; // Projection-space position +#if !defined( _X360 ) + float fog : FOG; +#endif + HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate + float4 color : TEXCOORD2; // Vertex color (from lighting or unlit) + + float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog +}; + + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + + float3 worldPos; + worldPos = mul4x3( v.vPos, cModel[0] ); + + // Transform into projection space + float4 projPos = mul( float4( worldPos, 1 ), cViewProj ); + o.projPos = projPos; + projPos.z = dot( float4( worldPos, 1 ), cViewProjZ ); + + o.worldPos_projPosZ = float4( worldPos.xyz, projPos.z ); + +#if !defined( _X360 ) + o.fog = CalcFog( worldPos, projPos, g_FogType ); +#endif + if ( g_bVertexColor ) + { + // Assume that this is unlitgeneric if you are using vertex color. +#if SRGB + o.color.rgba = GammaToLinear( v.vColor.rgba ); +#else + o.color.rgba = v.vColor.rgba; +#endif + } + + // Base texture coordinates + o.baseTexCoord.xy = v.vTexCoord0.xy; + + return o; +} + + diff --git a/sp/src/materialsystem/stdshaders/SDK_teeth_bump_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_teeth_bump_ps2x.fxc new file mode 100644 index 00000000..fdcb2e42 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_teeth_bump_ps2x.fxc @@ -0,0 +1,101 @@ +//====== Copyright © 1996-2006, Valve Corporation, All rights reserved. ======= + +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps30][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] + +// DYNAMIC: "PIXELFOGTYPE" "0..1" +// DYNAMIC: "NUM_LIGHTS" "0..2" [ps20] +// DYNAMIC: "NUM_LIGHTS" "0..4" [ps20b] +// DYNAMIC: "NUM_LIGHTS" "0..4" [ps30] +// DYNAMIC: "AMBIENT_LIGHT" "0..1" +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps30] + +#if defined( SHADER_MODEL_PS_2_0 ) +# define WRITE_DEPTH_TO_DESTALPHA 0 +#endif + +#include "shader_constant_register_map.h" + +const float3 cAmbientCube[6] : register( PSREG_AMBIENT_CUBE ); +const float4 g_FogParams : register( PSREG_FOG_PARAMS ); +const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT ); +PixelShaderLightInfo cLightInfo[3] : register( PSREG_LIGHT_INFO_ARRAY ); // 2 registers each - 6 registers total + +sampler BaseTextureSampler : register( s0 ); +sampler BumpTextureSampler : register( s1 ); +sampler NormalizeSampler : register( s2 ); + +struct PS_INPUT +{ + float2 baseTexCoord : TEXCOORD0; + float4 worldVertToEyeVector_Darkening : TEXCOORD1; + float3x3 tangentSpaceTranspose : TEXCOORD2; + // second row : TEXCOORD3; + // third row : TEXCOORD4; + float4 worldPos_projPosZ : TEXCOORD5; + float2 lightAtten01 : TEXCOORD6; + float2 lightAtten23 : TEXCOORD7; +}; + + + +#if ((defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0))) + +#define worldVertToEyeVector i.worldVertToEyeVector_Darkening.xyz +#define fDarkening i.worldVertToEyeVector_Darkening.w + +#endif + + + +float4 main( PS_INPUT i ) : COLOR +{ + bool bAmbientLight = AMBIENT_LIGHT ? true : false; + int nNumLights = NUM_LIGHTS; + + float4 vLightAtten = float4( i.lightAtten01, i.lightAtten23 ); + float4 baseSample = tex2D( BaseTextureSampler, i.baseTexCoord ); + + float3 worldSpaceNormal, tangentSpaceNormal = float3(0, 0, 1); + float fSpecExp = g_EyePos_SpecExponent.w; + + float4 normalTexel = tex2D( BumpTextureSampler, i.baseTexCoord ); + tangentSpaceNormal = 2.0f * normalTexel.xyz - 1.0f; + worldSpaceNormal = normalize( mul( i.tangentSpaceTranspose, tangentSpaceNormal ) ); + + // If the exponent passed in as a constant is zero, use the value from the map as the exponent + if ( fSpecExp == 0 ) + fSpecExp = 1.0f * ( 1.0f - normalTexel.w ) + 150.0f * normalTexel.w; + + // Summation of diffuse illumination from all local lights + float3 diffuseLighting = PixelShaderDoLighting( i.worldPos_projPosZ.xyz, worldSpaceNormal, + float3( 0.0f, 0.0f, 0.0f ), false, + bAmbientLight, vLightAtten, + cAmbientCube, NormalizeSampler, nNumLights, cLightInfo, true, + false, 0, false, NormalizeSampler ); + +#if ((defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0))) + + float3 vDummy, specularLighting; + + // Summation of specular from all local lights + PixelShaderDoSpecularLighting( i.worldPos_projPosZ.xyz, worldSpaceNormal, fSpecExp, normalize(worldVertToEyeVector), + vLightAtten, nNumLights, cLightInfo, + false, 1.0f, false, NormalizeSampler, 1.0f, false, 1.0f, + + // Outputs + specularLighting, vDummy ); + + // Specular plus diffuse, all darkened as a function of mouth openness + float3 result = (specularLighting * baseSample.a + baseSample.rgb * diffuseLighting) * fDarkening; + +#else + float3 result = baseSample.rgb * diffuseLighting * i.worldVertToEyeVector_Darkening.w; +#endif + + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); + return FinalOutput( float4(result, 1.0f), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, (WRITE_DEPTH_TO_DESTALPHA != 0), i.worldPos_projPosZ.w ); +} diff --git a/sp/src/materialsystem/stdshaders/SDK_teeth_bump_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_teeth_bump_vs20.fxc new file mode 100644 index 00000000..1dd834b5 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_teeth_bump_vs20.fxc @@ -0,0 +1,152 @@ +//======= Copyright © 1996-2006, Valve Corporation, All rights reserved. ====== + +// STATIC: "INTRO" "0..1" +// STATIC: "USE_STATIC_CONTROL_FLOW" "0..1" [vs20] + +// DYNAMIC: "COMPRESSED_VERTS" "0..1" +// DYNAMIC: "DOWATERFOG" "0..1" +// DYNAMIC: "SKINNING" "0..1" +// DYNAMIC: "STATIC_LIGHT" "0..1" +// DYNAMIC: "MORPHING" "0..1" [vs30] +// DYNAMIC: "NUM_LIGHTS" "0..2" [vs20] + +// If using static control flow on Direct3D, we should use the NUM_LIGHTS=0 combo +// SKIP: $USE_STATIC_CONTROL_FLOW && ( $NUM_LIGHTS > 0 ) [vs20] + +#include "vortwarp_vs20_helper.h" + +static const int g_FogType = DOWATERFOG; +static const bool g_bSkinning = SKINNING ? true : false; + +const float4 cTeethLighting : register( SHADER_SPECIFIC_CONST_0 ); +#if INTRO +const float4 const4 : register( SHADER_SPECIFIC_CONST_1 ); +#define g_Time const4.w +#define modelOrigin const4.xyz +#endif + +#ifdef SHADER_MODEL_VS_3_0 +// NOTE: cMorphTargetTextureDim.xy = target dimensions, +// cMorphTargetTextureDim.z = 4tuples/morph +const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_6 ); +const float4 cMorphSubrect : register( SHADER_SPECIFIC_CONST_7 ); + +sampler2D morphSampler : register( D3DVERTEXTEXTURESAMPLER0, s0 ); +#endif + +struct VS_INPUT +{ + // This is all of the stuff that we ever use. + float4 vPos : POSITION; + float4 vBoneWeights : BLENDWEIGHT; + float4 vBoneIndices : BLENDINDICES; + float4 vNormal : NORMAL; + float2 vTexCoord0 : TEXCOORD0; + float4 vUserData : TANGENT; // Sign for cross product in w + + // Position and normal/tangent deltas + float3 vPosFlex : POSITION1; + float3 vNormalFlex : NORMAL1; +#ifdef SHADER_MODEL_VS_3_0 + float vVertexID : POSITION2; +#endif +}; + +struct VS_OUTPUT +{ + float4 projPos : POSITION; +#if !defined( _X360 ) + float fog : FOG; +#endif + float2 baseTexCoord : TEXCOORD0; + float4 worldVertToEyeVector_Darkening : TEXCOORD1; + float3x3 tangentSpaceTranspose : TEXCOORD2; + // second row : TEXCOORD3; + // third row : TEXCOORD4; + float4 worldPos_projPosZ : TEXCOORD5; + float2 lightAtten01 : TEXCOORD6; + float2 lightAtten23 : TEXCOORD7; +}; + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + + float4 vPosition = v.vPos; + float3 vNormal; + float4 vTangent; + DecompressVertex_NormalTangent( v.vNormal, v.vUserData, vNormal, vTangent ); + +#if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING + ApplyMorph( v.vPosFlex, v.vNormalFlex, vPosition.xyz, vNormal, vTangent.xyz ); +#else + ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, v.vVertexID, float3( 0, 0, 0 ), + vPosition.xyz, vNormal, vTangent.xyz ); +#endif + + // Perform skinning + float3 worldNormal, worldPos, worldTangentS, worldTangentT; + SkinPositionNormalAndTangentSpace( g_bSkinning, vPosition, vNormal, vTangent, + v.vBoneWeights, v.vBoneIndices, worldPos, + worldNormal, worldTangentS, worldTangentT ); + +#if INTRO + WorldSpaceVertexProcess( g_Time, modelOrigin, worldPos, worldNormal, worldTangentS, worldTangentT ); +#endif + + // Always normalize since flex path is controlled by runtime + // constant not a shader combo and will always generate the normalization + worldNormal = normalize( worldNormal ); + worldTangentS = normalize( worldTangentS ); + worldTangentT = normalize( worldTangentT ); + + // Transform into projection space + float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj ); + o.projPos = vProjPos; + vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ ); + + o.worldPos_projPosZ = float4( worldPos, vProjPos.z ); +#if !defined( _X360 ) + // Set fixed-function fog factor + o.fog = CalcFog( worldPos, vProjPos, g_FogType ); +#endif + // Needed for specular + o.worldVertToEyeVector_Darkening.xyz = cEyePos - worldPos; + + // Special darkening of lights for mouth open/close + o.worldVertToEyeVector_Darkening.w = cTeethLighting.w * saturate( dot( worldNormal, cTeethLighting.xyz ) );; + + // Scalar light attenuation (mouth darkening applied in pixel shader) +#if defined( SHADER_MODEL_VS_2_0 ) && ( !USE_STATIC_CONTROL_FLOW ) + o.lightAtten01.xy = float2(0,0); + o.lightAtten23.xy = float2(0,0); + #if ( NUM_LIGHTS > 0 ) + o.lightAtten01.x = GetVertexAttenForLight( worldPos, 0, false ); + #endif + #if ( NUM_LIGHTS > 1 ) + o.lightAtten01.y = GetVertexAttenForLight( worldPos, 1, false ); + #endif + #if ( NUM_LIGHTS > 2 ) + o.lightAtten23.x = GetVertexAttenForLight( worldPos, 2, false ); + #endif + #if ( NUM_LIGHTS > 3 ) + o.lightAtten23.y = GetVertexAttenForLight( worldPos, 3, false ); + #endif +#else + o.lightAtten01.x = GetVertexAttenForLight( worldPos, 0, true ); + o.lightAtten01.y = GetVertexAttenForLight( worldPos, 1, true ); + o.lightAtten23.x = GetVertexAttenForLight( worldPos, 2, true ); + o.lightAtten23.y = GetVertexAttenForLight( worldPos, 3, true ); +#endif + + o.baseTexCoord = v.vTexCoord0; + + // Tangent space transform + o.tangentSpaceTranspose[0] = float3( worldTangentS.x, worldTangentT.x, worldNormal.x ); + o.tangentSpaceTranspose[1] = float3( worldTangentS.y, worldTangentT.y, worldNormal.y ); + o.tangentSpaceTranspose[2] = float3( worldTangentS.z, worldTangentT.z, worldNormal.z ); + + return o; +} + + diff --git a/sp/src/materialsystem/stdshaders/SDK_teeth_flashlight_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_teeth_flashlight_ps2x.fxc new file mode 100644 index 00000000..524a6ba2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_teeth_flashlight_ps2x.fxc @@ -0,0 +1,66 @@ +//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. ======= +// +// Purpose: +// +//============================================================================= + +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps30][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps20b] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps30] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..0" [ps20b] [XBOX] + +// DYNAMIC: "PIXELFOGTYPE" "0..1" +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps20b] +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps30] + +#include "common_flashlight_fxc.h" +#include "shader_constant_register_map.h" + +sampler BaseTextureSampler : register( s0 ); +sampler SpotSampler : register( s1 ); +sampler FlashlightDepthSampler : register( s2 ); +sampler RandomRotationSampler : register( s3 ); + +const float4 g_FogParams : register( PSREG_FOG_PARAMS ); +const float3 g_EyePos : register( PSREG_EYEPOS_SPEC_EXPONENT ); +const float3 g_FlashlightPos : register( PSREG_FLASHLIGHT_POSITION_RIM_BOOST ); +const float4 g_FlashlightAtten : register( PSREG_FLASHLIGHT_ATTENUATION ); +const float4x4 g_FlashlightWorldToTexture : register( PSREG_FLASHLIGHT_TO_WORLD_TEXTURE ); +const float4 g_ShadowTweaks : register( PSREG_ENVMAP_TINT__SHADOW_TWEAKS ); + +struct PS_INPUT +{ + float2 baseTexCoord : TEXCOORD0; // Base texture coordinates + float4 spotTexCoord : TEXCOORD1; // Spotlight texture coordinates + float3 vertAtten : TEXCOORD2; // Distance/spot attenuation + float4 projPos : TEXCOORD3; // Projective space position + float3 worldPos : TEXCOORD4; // Necessary for pixel fog +}; + +float4 main( PS_INPUT i ) : COLOR +{ +#if defined( SHADER_MODEL_PS_2_0 ) + float3 result = tex2Dproj( SpotSampler, i.spotTexCoord.xyzw ); +#else + float3 vProjCoords = i.spotTexCoord.xyz / i.spotTexCoord.w; + float3 result = tex2D( SpotSampler, vProjCoords ); +#endif + + result *= cFlashlightColor.rgb; + +#if FLASHLIGHTSHADOWS && ( defined( SHADER_MODEL_PS_2_B ) || defined( SHADER_MODEL_PS_3_0 ) ) + result *= DoFlashlightShadow( FlashlightDepthSampler, RandomRotationSampler, vProjCoords, i.projPos.xy / i.projPos.z, FLASHLIGHTDEPTHFILTERMODE, g_ShadowTweaks, true ); +#endif + result *= 0.35f; // Without this, unshadowed teeth always seem to glow + + result *= i.vertAtten; // Distance atten, NdotL and forward vector + + float4 baseSample = tex2D( BaseTextureSampler, i.baseTexCoord ); + result *= baseSample.rgb; // Multiply by base map and diffuse + + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.xyz, i.worldPos.xyz, i.projPos.z ); + return FinalOutput( float4( result, baseSample.a ), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR ); +} + diff --git a/sp/src/materialsystem/stdshaders/SDK_teeth_flashlight_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_teeth_flashlight_vs20.fxc new file mode 100644 index 00000000..8c5ce4c5 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_teeth_flashlight_vs20.fxc @@ -0,0 +1,149 @@ +//======= Copyright © 1996-2007, Valve Corporation, All rights reserved. ====== + +// STATIC: "INTRO" "0..1" + +// DYNAMIC: "COMPRESSED_VERTS" "0..1" +// DYNAMIC: "DOWATERFOG" "0..1" +// DYNAMIC: "SKINNING" "0..1" +// DYNAMIC: "MORPHING" "0..1" [vs30] + +#include "vortwarp_vs20_helper.h" + +static const int g_FogType = DOWATERFOG; +static const bool g_bSkinning = SKINNING ? true : false; + +const float4 cFlashlightPosition : register( SHADER_SPECIFIC_CONST_0 ); +const float4 cSpotlightProj1 : register( SHADER_SPECIFIC_CONST_1 ); +const float4 cSpotlightProj2 : register( SHADER_SPECIFIC_CONST_2 ); +const float4 cSpotlightProj3 : register( SHADER_SPECIFIC_CONST_3 ); +const float4 cSpotlightProj4 : register( SHADER_SPECIFIC_CONST_4 ); +const float4 cFlashlighAtten : register( SHADER_SPECIFIC_CONST_5 ); // const, linear, quadratic & farZ + +const float4 cTeethLighting : register( SHADER_SPECIFIC_CONST_8 ); +#if INTRO +const float4 const4 : register( SHADER_SPECIFIC_CONST_9 ); +#define g_Time const4.w +#define modelOrigin const4.xyz +#endif + +#ifdef SHADER_MODEL_VS_3_0 +// NOTE: cMorphTargetTextureDim.xy = target dimensions, +// cMorphTargetTextureDim.z = 4tuples/morph +const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_6 ); +const float4 cMorphSubrect : register( SHADER_SPECIFIC_CONST_7 ); + +sampler2D morphSampler : register( D3DVERTEXTEXTURESAMPLER0, s0 ); +#endif + + +struct VS_INPUT +{ + // This is all of the stuff that we ever use. + float4 vPos : POSITION; + float4 vBoneWeights : BLENDWEIGHT; + float4 vBoneIndices : BLENDINDICES; + float4 vNormal : NORMAL; + float2 vTexCoord0 : TEXCOORD0; + + // Position and normal/tangent deltas + float3 vPosFlex : POSITION1; + float3 vNormalFlex : NORMAL1; +#ifdef SHADER_MODEL_VS_3_0 + float vVertexID : POSITION2; +#endif +}; + +struct VS_OUTPUT +{ + float4 projPos : POSITION; +#if !defined( _X360 ) + float fog : FOG; +#endif + float2 baseTexCoord : TEXCOORD0; // Base texture coordinates + float4 spotTexCoord : TEXCOORD1; // Spotlight texture coordinates + float3 vertAtten : TEXCOORD2; // Distance/spot attenuation + float4 vProjPos : TEXCOORD3; // Projective space position + float3 worldPos : TEXCOORD4; // Necessary for pixel fog +}; + + +float RemapValClamped_01( float val, float A, float B ) +{ + float cVal = (val - A) / (B - A); + cVal = saturate( cVal ); + return cVal; +} + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + + float4 vPosition = v.vPos; + float3 vNormal; + DecompressVertex_Normal( v.vNormal, vNormal ); + +#if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING + ApplyMorph( v.vPosFlex, v.vNormalFlex, vPosition.xyz, vNormal ); +#else + ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, v.vVertexID, float3( 0, 0, 0 ), vPosition.xyz, vNormal ); +#endif + + // Normalize the flexed normal + vNormal.xyz = normalize( vNormal.xyz ); + + // Transform the position + float3 worldPos, worldNormal; + SkinPositionAndNormal( g_bSkinning, vPosition, vNormal, v.vBoneWeights, v.vBoneIndices, worldPos, worldNormal ); + +#if INTRO + float3 dummy = float3( 0.0f, 0.0f, 0.0f ); + WorldSpaceVertexProcess( g_Time, modelOrigin, worldPos, worldNormal, dummy, dummy ); +#endif + + // Transform into projection space + o.projPos = mul( float4( worldPos, 1 ), cViewProj ); + o.worldPos = worldPos.xyz; + o.vProjPos = o.projPos; +#if !defined( _X360 ) + // Set fixed-function fog factor + o.fog = CalcFog( worldPos, o.projPos, g_FogType ); +#endif + // Spotlight texture coordinates + o.spotTexCoord.x = dot( cSpotlightProj1, float4(worldPos, 1) ); + o.spotTexCoord.y = dot( cSpotlightProj2, float4(worldPos, 1) ); + o.spotTexCoord.z = dot( cSpotlightProj3, float4(worldPos, 1) ); + o.spotTexCoord.w = dot( cSpotlightProj4, float4(worldPos, 1) ); + + // Compute vector to light + float3 vWorldPosToLightVector = cFlashlightPosition.xyz - worldPos; + + float3 vDistAtten = float3(1, 1, 1); + vDistAtten.z = dot( vWorldPosToLightVector, vWorldPosToLightVector ); + vDistAtten.y = rsqrt( vDistAtten.z ); + + float flDist = vDistAtten.z * vDistAtten.y; // Distance to light + vDistAtten.z = 1.0f / vDistAtten.z; // 1 / distsquared + + float fFarZ = cFlashlighAtten.w; + + float NdotL = saturate( dot( worldNormal, normalize( vWorldPosToLightVector ) ) ); + + float endFalloffFactor = RemapValClamped_01( flDist, fFarZ, 0.6 * fFarZ ); + o.vertAtten.xyz = endFalloffFactor * dot( vDistAtten, cFlashlighAtten.xyz ); + + // Final attenuation from flashlight only... + float linearAtten = NdotL * dot( vDistAtten, cFlashlighAtten.xyz ) * endFalloffFactor; + + // Forward vector + float3 vForward = cTeethLighting.xyz; + float fIllumFactor = cTeethLighting.w; + + // Modulate flashlight by mouth darkening + o.vertAtten = linearAtten * fIllumFactor * saturate( dot( worldNormal, vForward ) ); + + o.baseTexCoord = v.vTexCoord0; + + return o; +} + + diff --git a/sp/src/materialsystem/stdshaders/SDK_teeth_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_teeth_ps2x.fxc new file mode 100644 index 00000000..5e715a4f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_teeth_ps2x.fxc @@ -0,0 +1,48 @@ +//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. ======= +// +// Purpose: +// +//============================================================================= + +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps30][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] + +// DYNAMIC: "PIXELFOGTYPE" "0..1" +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps30] + + +#if defined( SHADER_MODEL_PS_2_0 ) +# define WRITE_DEPTH_TO_DESTALPHA 0 +#endif + +#include "common_ps_fxc.h" +#include "shader_constant_register_map.h" + +sampler BaseTextureSampler : register( s0 ); + +const float4 g_FogParams : register( PSREG_FOG_PARAMS ); +const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT ); + +struct PS_INPUT +{ + float2 baseTexCoord : TEXCOORD0; + float3 vertAtten : TEXCOORD1; + + float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog +}; + +float4 main( PS_INPUT i ) : COLOR +{ + float4 baseSample = tex2D( BaseTextureSampler, i.baseTexCoord ); + + float4 result; + result.xyz = baseSample.xyz * i.vertAtten; + result.a = baseSample.a; + + + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); + return FinalOutput( result, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, (WRITE_DEPTH_TO_DESTALPHA != 0), i.worldPos_projPosZ.w ); +} diff --git a/sp/src/materialsystem/stdshaders/SDK_teeth_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_teeth_vs20.fxc new file mode 100644 index 00000000..9a9ab045 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_teeth_vs20.fxc @@ -0,0 +1,127 @@ +//======= Copyright © 1996-2006, Valve Corporation, All rights reserved. ====== + +// STATIC: "INTRO" "0..1" +// STATIC: "USE_STATIC_CONTROL_FLOW" "0..1" [vs20] + +// DYNAMIC: "COMPRESSED_VERTS" "0..1" +// DYNAMIC: "DOWATERFOG" "0..1" +// DYNAMIC: "SKINNING" "0..1" +// DYNAMIC: "DYNAMIC_LIGHT" "0..1" +// DYNAMIC: "STATIC_LIGHT" "0..1" +// DYNAMIC: "MORPHING" "0..1" [vs30] +// DYNAMIC: "NUM_LIGHTS" "0..2" [vs20] + +// If using static control flow on Direct3D, we should use the NUM_LIGHTS=0 combo +// SKIP: $USE_STATIC_CONTROL_FLOW && ( $NUM_LIGHTS > 0 ) [vs20] + +#include "vortwarp_vs20_helper.h" + +static const int g_FogType = DOWATERFOG; +static const bool g_bSkinning = SKINNING ? true : false; + +const float4 cTeethLighting : register( SHADER_SPECIFIC_CONST_0 ); +#if INTRO +const float4 const4 : register( SHADER_SPECIFIC_CONST_1 ); +#define g_Time const4.w +#define modelOrigin const4.xyz +#endif + +#ifdef SHADER_MODEL_VS_3_0 +// NOTE: cMorphTargetTextureDim.xy = target dimensions, +// cMorphTargetTextureDim.z = 4tuples/morph +const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_6 ); +const float4 cMorphSubrect : register( SHADER_SPECIFIC_CONST_7 ); + +sampler2D morphSampler : register( D3DVERTEXTEXTURESAMPLER0, s0 ); +#endif + +struct VS_INPUT +{ + // This is all of the stuff that we ever use. + float4 vPos : POSITION; + float4 vBoneWeights : BLENDWEIGHT; + float4 vBoneIndices : BLENDINDICES; + float4 vNormal : NORMAL; + float2 vTexCoord0 : TEXCOORD0; + + // Position and normal/tangent deltas + float3 vPosFlex : POSITION1; + float3 vNormalFlex : NORMAL1; +#ifdef SHADER_MODEL_VS_3_0 + float vVertexID : POSITION2; +#endif +}; + +struct VS_OUTPUT +{ + float4 projPos : POSITION; +#if !defined( _X360 ) + float fog : FOG; +#endif + float2 baseTexCoord : TEXCOORD0; + float3 vertAtten : TEXCOORD1; + + float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog +}; + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + + bool bDynamicLight = DYNAMIC_LIGHT ? true : false; + bool bStaticLight = STATIC_LIGHT ? true : false; + + float4 vPosition = v.vPos; + float3 vNormal; + DecompressVertex_Normal( v.vNormal, vNormal ); + +#if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING + ApplyMorph( v.vPosFlex, v.vNormalFlex, vPosition.xyz, vNormal ); +#else + ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, v.vVertexID, float3( 0, 0, 0 ), vPosition.xyz, vNormal ); +#endif + + // Normalize the flexed normal + vNormal.xyz = normalize( vNormal.xyz ); + + // Transform the position + float3 worldPos, worldNormal; + SkinPositionAndNormal( g_bSkinning, vPosition, vNormal, v.vBoneWeights, v.vBoneIndices, worldPos, worldNormal ); + +#if INTRO + float3 dummy = float3( 0.0f, 0.0f, 0.0f ); + WorldSpaceVertexProcess( g_Time, modelOrigin, worldPos, worldNormal, dummy, dummy ); +#endif + + // Transform into projection space + float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj ); + o.projPos = vProjPos; + vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ ); + + o.worldPos_projPosZ = float4( worldPos.xyz, vProjPos.z ); +#if !defined( _X360 ) + // Set fixed-function fog factor + o.fog = CalcFog( worldPos, vProjPos, g_FogType ); +#endif + + // Compute lighting +#if ( USE_STATIC_CONTROL_FLOW ) || defined ( SHADER_MODEL_VS_3_0 ) + float3 linearColor = DoLighting( worldPos, worldNormal, float3(0.0f, 0.0f, 0.0f), bStaticLight, bDynamicLight, false ); +#else + float3 linearColor = DoLightingUnrolled( worldPos, worldNormal, float3(0.0f, 0.0f, 0.0f), bStaticLight, bDynamicLight, false, NUM_LIGHTS ); +#endif + + // Forward vector + float3 vForward = cTeethLighting.xyz; + float fIllumFactor = cTeethLighting.w; + + // Darken by forward dot normal and illumination factor + linearColor *= fIllumFactor * saturate( dot( worldNormal, vForward ) ); + + o.vertAtten = linearColor; + o.baseTexCoord = v.vTexCoord0; + + return o; +} + + diff --git a/sp/src/materialsystem/stdshaders/SDK_unlitgeneric_ps11.fxc b/sp/src/materialsystem/stdshaders/SDK_unlitgeneric_ps11.fxc new file mode 100644 index 00000000..071d666c --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_unlitgeneric_ps11.fxc @@ -0,0 +1,12 @@ +sampler TextureSampler : register( s0 ); + +struct PS_INPUT +{ + float4 vColor0 : COLOR0; + float2 vTexCoord0 : TEXCOORD0; +}; + +float4 main( PS_INPUT i ) : COLOR +{ + return i.vColor0 * tex2D( TextureSampler, i.vTexCoord0 ); +} \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/SDK_unlitgeneric_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_unlitgeneric_ps2x.fxc new file mode 100644 index 00000000..1620638f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_unlitgeneric_ps2x.fxc @@ -0,0 +1,19 @@ +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] + +#include "common_ps_fxc.h" + +sampler TextureSampler : register( s0 ); + +struct PS_INPUT +{ + float4 vColor0 : COLOR0; + float2 vTexCoord0 : TEXCOORD0; +}; + +float4 main( PS_INPUT i ) : COLOR +{ + float4 result = i.vColor0 * tex2D( TextureSampler, i.vTexCoord0 ); + + return FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE ); +} \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/SDK_unlitgeneric_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_unlitgeneric_vs20.fxc new file mode 100644 index 00000000..37249305 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_unlitgeneric_vs20.fxc @@ -0,0 +1,91 @@ +// STATIC: "VERTEXCOLOR" "0..1" +// DYNAMIC: "COMPRESSED_VERTS" "0..1" +// DYNAMIC: "DOWATERFOG" "0..1" +// DYNAMIC: "SKINNING" "0..1" + +#include "common_vs_fxc.h" + +static const int g_FogType = DOWATERFOG; +static const bool g_bSkinning = SKINNING ? true : false; + +const float4 cBaseTextureTransform[2] : register( SHADER_SPECIFIC_CONST_0 ); +const float4 cMaskTextureTransform[2] : register( SHADER_SPECIFIC_CONST_2 ); +const float4 cDetailTextureTransform[2] : register( SHADER_SPECIFIC_CONST_4 ); +const float4 g_vVertexColor : register( SHADER_SPECIFIC_CONST_6 ); + +struct VS_INPUT +{ + float4 vPos : POSITION; + float4 vBoneWeights : BLENDWEIGHT; + float4 vBoneIndices : BLENDINDICES; + float4 vNormal : NORMAL; + +#if VERTEXCOLOR + float4 vColor : COLOR0; +#endif + + float4 vTexCoord0 : TEXCOORD0; +}; + +struct VS_OUTPUT +{ + float4 vProjPos : POSITION; + float2 vTexCoord0 : TEXCOORD0; + float2 vTexCoord1 : TEXCOORD1; + float2 vTexCoord2 : TEXCOORD2; + float2 vTexCoord3 : TEXCOORD3; + + float4 vColor : COLOR0; + float4 fogFactorW : COLOR1; + +#if !defined( _X360 ) + float fog : FOG; +#endif + + float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog +}; + + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + + float3 worldPos; + float3 worldNormal; + + //------------------------------------------------------------------------------ + // Vertex blending + //------------------------------------------------------------------------------ + SkinPosition( g_bSkinning, v.vPos, v.vBoneWeights, v.vBoneIndices, worldPos ); + + float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj ); + o.vProjPos = vProjPos; + vProjPos = dot( float4( worldPos, 1 ), cViewProjZ ); + o.worldPos_projPosZ = float4( worldPos.xyz, vProjPos.z ); + + //------------------------------------------------------------------------------ + // Fog + //------------------------------------------------------------------------------ + o.fogFactorW = CalcFog( worldPos, vProjPos, g_FogType ); +#if !defined( _X360 ) + o.fog = o.fogFactorW; +#endif + + //------------------------------------------------------------------------------ + // Texture coord transforms + //------------------------------------------------------------------------------ + o.vTexCoord0 = mul( v.vTexCoord0, (float2x4)cBaseTextureTransform ); + o.vTexCoord3 = mul( v.vTexCoord0, (float2x4)cDetailTextureTransform ); + + o.vColor = cModulationColor; + +#if VERTEXCOLOR + // 0 or 1 for g_vVertexColor.x, eliminating a bool + o.vColor = lerp( o.vColor, o.vColor * v.vColor, g_vVertexColor.x ); +#endif + + return o; +} + + + diff --git a/sp/src/materialsystem/stdshaders/SDK_vertexlit_and_unlit_generic_bump_ps20b.fxc b/sp/src/materialsystem/stdshaders/SDK_vertexlit_and_unlit_generic_bump_ps20b.fxc new file mode 100644 index 00000000..1bc6cdad --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_vertexlit_and_unlit_generic_bump_ps20b.fxc @@ -0,0 +1,359 @@ +//======= Copyright © 1996-2008, Valve Corporation, All rights reserved. ====== + +// STATIC: "CUBEMAP" "0..1" +// STATIC: "DIFFUSELIGHTING" "0..1" +// STATIC: "LIGHTWARPTEXTURE" "0..1" +// STATIC: "SELFILLUM" "0..1" +// STATIC: "SELFILLUMFRESNEL" "0..1" +// STATIC: "NORMALMAPALPHAENVMAPMASK" "0..1" +// STATIC: "HALFLAMBERT" "0..1" +// STATIC: "FLASHLIGHT" "0..1" +// STATIC: "DETAILTEXTURE" "0..1" +// STATIC: "DETAIL_BLEND_MODE" "0..6" +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps20b] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps30] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..0" [ps20b] [XBOX] +// STATIC: "BLENDTINTBYBASEALPHA" "0..1" + +// DYNAMIC: "PIXELFOGTYPE" "0..1" [ps20] +// DYNAMIC: "WRITEWATERFOGTODESTALPHA" "0..1" [ps20] +// DYNAMIC: "NUM_LIGHTS" "0..2" [ps20] +// DYNAMIC: "NUM_LIGHTS" "0..4" [ps20b] +// DYNAMIC: "NUM_LIGHTS" "0..4" [ps30] +// DYNAMIC: "AMBIENT_LIGHT" "0..1" +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps20b] +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps30] [PC] + +// We don't use light combos when doing the flashlight +// SKIP: ( $FLASHLIGHT != 0 ) && ( $NUM_LIGHTS > 0 ) [PC] + +// We don't care about flashlight depth unless the flashlight is on +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps20b] +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps30] + +// Flashlight shadow filter mode is irrelevant if there is no flashlight +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) [ps20b] +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) [ps30] + +// SKIP: (! $DETAILTEXTURE) && ( $DETAIL_BLEND_MODE != 0 ) + +// Don't do diffuse warp on flashlight +// SKIP: ( $FLASHLIGHT == 1 ) && ( $LIGHTWARPTEXTURE == 1 ) [PC] + +// Only warp diffuse if we have it at all +// SKIP: ( $DIFFUSELIGHTING == 0 ) && ( $LIGHTWARPTEXTURE == 1 ) + +// Skip this since it blows ps20 instruction limits +// SKIP: ( $SELFILLUMFRESNEL == 1 ) && ( $LIGHTWARPTEXTURE == 1 ) + +// Only need self illum fresnel when self illum enabled +// SKIP: ( $SELFILLUM == 0 ) && ( $SELFILLUMFRESNEL == 1 ) +// SKIP: ( $FLASHLIGHT == 1 ) && ( $SELFILLUMFRESNEL == 1 ) [PC] +// SKIP: ( $FLASHLIGHT == 1 ) && ( $SELFILLUM == 1 ) [PC] +// SKIP: ( $SELFILLUMFRESNEL == 1 ) && ( $DETAILTEXTURE == 1 ) +// SKIP: ( $SELFILLUMFRESNEL == 1 ) && ( $NORMALMAPALPHAENVMAPMASK == 1 ) + +// BlendTintByBaseAlpha is incompatible with other interpretations of alpha +// SKIP: ($BLENDTINTBYBASEALPHA) && ($SELFILLUM) + +// Only _XBOX allows flashlight and cubemap in the current implementation +// SKIP: $FLASHLIGHT && $CUBEMAP [PC] + +// Meaningless combinations +// SKIP: $NORMALMAPALPHAENVMAPMASK && !$CUBEMAP + +#include "common_flashlight_fxc.h" +#include "common_vertexlitgeneric_dx9.h" + +const float4 g_EnvmapTint_TintReplaceFactor : register( c0 ); +const float4 g_DiffuseModulation : register( c1 ); +const float4 g_EnvmapContrast_ShadowTweaks : register( c2 ); +const float3 g_EnvmapSaturation : register( c3 ); +const float4 g_SelfIllumTint_and_BlendFactor : register( c4 ); +#define g_SelfIllumTint ( g_SelfIllumTint_and_BlendFactor.rgb) +#define g_DetailBlendFactor (g_SelfIllumTint_and_BlendFactor.w) + +const float3 cAmbientCube[6] : register( c5 ); + +// 11, 12 not used? +#if ( SELFILLUMFRESNEL == 1 ) + const float4 g_SelfIllumScaleBiasExpBrightness : register( c11 ); +#endif + +const float4 g_ShaderControls : register( c12 ); +#define g_fPixelFogType g_ShaderControls.x +#define g_fWriteDepthToAlpha g_ShaderControls.y +#define g_fWriteWaterFogToDestAlpha g_ShaderControls.z + + +// 2 registers each - 6 registers total +PixelShaderLightInfo cLightInfo[3] : register( c13 ); // through c18 + +const float4 g_EyePos_MinLight : register( c20 ); +#define g_EyePos g_EyePos_MinLight.xyz +#define g_fMinLighting g_EyePos_MinLight.w + +const float4 g_FogParams : register( c21 ); + +const float4 g_FlashlightAttenuationFactors : register( c22 ); +const float3 g_FlashlightPos : register( c23 ); +const float4x4 g_FlashlightWorldToTexture : register( c24 ); // through c27 + +sampler BaseTextureSampler : register( s0 ); +sampler EnvmapSampler : register( s1 ); +sampler DetailSampler : register( s2 ); +sampler BumpmapSampler : register( s3 ); +sampler EnvmapMaskSampler : register( s4 ); +sampler NormalizeSampler : register( s5 ); +sampler RandRotSampler : register( s6 ); // RandomRotation sampler +sampler FlashlightSampler : register( s7 ); +sampler ShadowDepthSampler : register( s8 ); // Flashlight shadow depth map sampler +sampler DiffuseWarpSampler : register( s9 ); // Lighting warp sampler (1D texture for diffuse lighting modification) + +struct PS_INPUT +{ + float4 baseTexCoord2_tangentSpaceVertToEyeVectorXY : TEXCOORD0; + float3 lightAtten : TEXCOORD1; + float4 worldVertToEyeVectorXYZ_tangentSpaceVertToEyeVectorZ : TEXCOORD2; + float3 vWorldNormal : TEXCOORD3; // World-space normal + float4 vWorldTangent : TEXCOORD4; +#if ((defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0))) + float4 vProjPos : TEXCOORD5; +#else + float3 vWorldBinormal : TEXCOORD5; +#endif + float4 worldPos_projPosZ : TEXCOORD6; + float3 detailTexCoord_atten3 : TEXCOORD7; + float4 fogFactorW : COLOR1; + +#if defined( _X360 ) +#if FLASHLIGHT + float4 flashlightSpacePos : TEXCOORD8; +#endif +#endif +}; + +// Calculate both types of Fog and lerp to get result +float CalcPixelFogFactorConst( float fPixelFogType, const float4 fogParams, const float flEyePosZ, const float flWorldPosZ, const float flProjPosZ ) +{ + float fRangeFog = CalcRangeFog( flProjPosZ, fogParams.x, fogParams.z, fogParams.w ); + float fHeightFog = CalcWaterFogAlpha( fogParams.y, flEyePosZ, flWorldPosZ, flProjPosZ, fogParams.w ); + return lerp( fRangeFog, fHeightFog, fPixelFogType ); +} + +// Blend both types of Fog and lerp to get result +float3 BlendPixelFogConst( const float3 vShaderColor, float pixelFogFactor, const float3 vFogColor, float fPixelFogType ) +{ + pixelFogFactor = saturate( pixelFogFactor ); + float3 fRangeResult = lerp( vShaderColor.rgb, vFogColor.rgb, pixelFogFactor * pixelFogFactor ); //squaring the factor will get the middle range mixing closer to hardware fog + float3 fHeightResult = lerp( vShaderColor.rgb, vFogColor.rgb, saturate( pixelFogFactor ) ); + return lerp( fRangeResult, fHeightResult, fPixelFogType ); +} + +float4 FinalOutputConst( const float4 vShaderColor, float pixelFogFactor, float fPixelFogType, const int iTONEMAP_SCALE_TYPE, float fWriteDepthToDestAlpha, const float flProjZ ) +{ + float4 result = vShaderColor; + if( iTONEMAP_SCALE_TYPE == TONEMAP_SCALE_LINEAR ) + { + result.rgb *= LINEAR_LIGHT_SCALE; + } + else if( iTONEMAP_SCALE_TYPE == TONEMAP_SCALE_GAMMA ) + { + result.rgb *= GAMMA_LIGHT_SCALE; + } + + result.a = lerp( result.a, DepthToDestAlpha( flProjZ ), fWriteDepthToDestAlpha ); + + result.rgb = BlendPixelFogConst( result.rgb, pixelFogFactor, g_LinearFogColor.rgb, fPixelFogType ); + result.rgb = SRGBOutput( result.rgb ); //SRGB in pixel shader conversion + + return result; +} + +float4 main( PS_INPUT i ) : COLOR +{ + bool bCubemap = CUBEMAP ? true : false; + bool bDiffuseLighting = DIFFUSELIGHTING ? true : false; + bool bDoDiffuseWarp = LIGHTWARPTEXTURE ? true : false; + bool bSelfIllum = SELFILLUM ? true : false; + bool bSelfIllumFresnel = SELFILLUMFRESNEL ? true : false; + bool bNormalMapAlphaEnvmapMask = NORMALMAPALPHAENVMAPMASK ? true : false; + bool bHalfLambert = HALFLAMBERT ? true : false; + bool bFlashlight = (FLASHLIGHT!=0) ? true : false; + bool bAmbientLight = AMBIENT_LIGHT ? true : false; + bool bDetailTexture = DETAILTEXTURE ? true : false; + bool bBlendTintByBaseAlpha = BLENDTINTBYBASEALPHA ? true : false; + int nNumLights = NUM_LIGHTS; + +#if ((defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0))) + float3 vWorldBinormal = cross( i.vWorldNormal.xyz, i.vWorldTangent.xyz ) * i.vWorldTangent.w; +#else + float3 vWorldBinormal = i.vWorldBinormal; +#endif + + // Unpack four light attenuations + float4 vLightAtten = float4( i.lightAtten, i.detailTexCoord_atten3.z ); + + float4 baseColor = float4( 1.0f, 1.0f, 1.0f, 1.0f ); + baseColor = tex2D( BaseTextureSampler, i.baseTexCoord2_tangentSpaceVertToEyeVectorXY.xy ); + +#if DETAILTEXTURE + float4 detailColor = tex2D( DetailSampler, i.detailTexCoord_atten3.xy ); + baseColor = TextureCombine( baseColor, detailColor, DETAIL_BLEND_MODE, g_DetailBlendFactor ); +#endif + + float specularFactor = 1.0f; + float4 normalTexel = tex2D( BumpmapSampler, i.baseTexCoord2_tangentSpaceVertToEyeVectorXY.xy ); + float3 tangentSpaceNormal = normalTexel * 2.0f - 1.0f; + + if ( bNormalMapAlphaEnvmapMask ) + specularFactor = normalTexel.a; + + float3 diffuseLighting = float3( 1.0f, 1.0f, 1.0f ); + + float3 worldSpaceNormal = Vec3TangentToWorld( tangentSpaceNormal.xyz, i.vWorldNormal, i.vWorldTangent, vWorldBinormal ); + if ( bDiffuseLighting || bFlashlight || bCubemap || bSelfIllumFresnel ) + { +#if ( defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) ) + worldSpaceNormal = normalize( worldSpaceNormal ); +#else + worldSpaceNormal = NormalizeWithCubemap( NormalizeSampler, worldSpaceNormal ); +#endif + } + + if ( bDiffuseLighting ) + { + diffuseLighting = PixelShaderDoLighting( i.worldPos_projPosZ.xyz, worldSpaceNormal, + float3( 0.0f, 0.0f, 0.0f ), false, bAmbientLight, vLightAtten, + cAmbientCube, NormalizeSampler, nNumLights, cLightInfo, bHalfLambert, + false, 1.0f, bDoDiffuseWarp, DiffuseWarpSampler ); + } + + float3 albedo = baseColor; + if (bBlendTintByBaseAlpha) + { + float3 tintedColor = albedo * g_DiffuseModulation.rgb; + tintedColor = lerp(tintedColor, g_DiffuseModulation.rgb, g_EnvmapTint_TintReplaceFactor.w); + albedo = lerp(albedo, tintedColor, baseColor.a); + } + else + { + albedo = albedo * g_DiffuseModulation.rgb; + } + + float alpha = g_DiffuseModulation.a; + if ( !bSelfIllum && !bBlendTintByBaseAlpha ) + { + alpha *= baseColor.a; + } + + +#if FLASHLIGHT + if( bFlashlight ) + { + int nShadowSampleLevel = 0; + bool bDoShadows = false; + float2 vProjPos = float2(0, 0); +// On ps_2_b, we can do shadow mapping +#if ( FLASHLIGHTSHADOWS && (defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) ) ) + nShadowSampleLevel = FLASHLIGHTDEPTHFILTERMODE; + bDoShadows = FLASHLIGHTSHADOWS; + vProjPos = i.vProjPos.xy / i.vProjPos.w; // Screen-space position for shadow map noise +#endif + +#if defined ( _X360 ) + float4 flashlightSpacePosition = i.flashlightSpacePos; +#else + float4 flashlightSpacePosition = mul( float4( i.worldPos_projPosZ.xyz, 1.0f ), g_FlashlightWorldToTexture ); +#endif + + float3 flashlightColor = DoFlashlight( g_FlashlightPos, i.worldPos_projPosZ.xyz, flashlightSpacePosition, + worldSpaceNormal, g_FlashlightAttenuationFactors.xyz, + g_FlashlightAttenuationFactors.w, FlashlightSampler, ShadowDepthSampler, + RandRotSampler, nShadowSampleLevel, bDoShadows, false, vProjPos, false, g_EnvmapContrast_ShadowTweaks ); + +#if defined ( _X360 ) + diffuseLighting += flashlightColor; +#else + diffuseLighting = flashlightColor; +#endif + + } +#endif + + +#if FOGTYPE == 2 || FLASHLIGHT != 0 + float3 diffuseComponent = albedo * diffuseLighting; +#else + float3 vEyeDir = normalize( i.worldVertToEyeVectorXYZ_tangentSpaceVertToEyeVectorZ.xyz ); + float flFresnelMinlight = saturate( dot( worldSpaceNormal, vEyeDir ) ); + + float3 diffuseComponent = albedo * lerp( diffuseLighting, 1, g_fMinLighting * flFresnelMinlight ); +#endif + + +#if !FLASHLIGHT || defined ( _X360 ) + if ( bSelfIllum ) + { + #if ( SELFILLUMFRESNEL == 1 ) // To free up the constant register...see top of file + // This will apply a fresnel term based on the vertex normal (not the per-pixel normal!) to help fake and internal glow look + #if ((defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0))) + float3 vVertexNormal = normalize( i.vWorldNormal.xyz ); + float flSelfIllumFresnel = ( pow( saturate( dot( vVertexNormal.xyz, normalize( i.worldVertToEyeVectorXYZ_tangentSpaceVertToEyeVectorZ.xyz ) ) ), g_SelfIllumScaleBiasExpBrightness.z ) * g_SelfIllumScaleBiasExpBrightness.x ) + g_SelfIllumScaleBiasExpBrightness.y; + + float3 selfIllumComponent = g_SelfIllumTint * albedo * g_SelfIllumScaleBiasExpBrightness.w; + diffuseComponent = lerp( diffuseComponent, selfIllumComponent, baseColor.a * saturate( flSelfIllumFresnel ) ); + #else + float3 vVertexNormal = i.vWorldNormal.xyz; + float flSelfIllumFresnel = ( pow( saturate( dot( vVertexNormal.xyz, ( i.worldVertToEyeVectorXYZ_tangentSpaceVertToEyeVectorZ.xyz ) ) ), g_SelfIllumScaleBiasExpBrightness.z ) * g_SelfIllumScaleBiasExpBrightness.x ) + g_SelfIllumScaleBiasExpBrightness.y; + + float3 selfIllumComponent = g_SelfIllumTint * albedo * g_SelfIllumScaleBiasExpBrightness.w; + diffuseComponent = lerp( diffuseComponent, selfIllumComponent, baseColor.a * saturate( flSelfIllumFresnel ) ); + #endif + #else + float3 selfIllumComponent = g_SelfIllumTint * albedo; + diffuseComponent = lerp( diffuseComponent, selfIllumComponent, baseColor.a ); + #endif + } +#endif + + float3 specularLighting = float3( 0.0f, 0.0f, 0.0f ); +#if !FLASHLIGHT || defined ( _X360 ) + if( bCubemap ) + { + float3 reflectVect = CalcReflectionVectorUnnormalized( worldSpaceNormal, i.worldVertToEyeVectorXYZ_tangentSpaceVertToEyeVectorZ.xyz ); + + specularLighting = ENV_MAP_SCALE * texCUBE( EnvmapSampler, reflectVect ); + specularLighting *= specularFactor; + specularLighting *= g_EnvmapTint_TintReplaceFactor.rgb; + float3 specularLightingSquared = specularLighting * specularLighting; + specularLighting = lerp( specularLighting, specularLightingSquared, g_EnvmapContrast_ShadowTweaks ); + float3 greyScale = dot( specularLighting, float3( 0.299f, 0.587f, 0.114f ) ); + specularLighting = lerp( greyScale, specularLighting, g_EnvmapSaturation ); + } +#endif + + float3 result = diffuseComponent + specularLighting; + +#if defined(SHADER_MODEL_PS_2_0) + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); +#else + float fogFactor = CalcPixelFogFactor( g_fPixelFogType, g_FogParams, g_EyePos.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); +#endif + +#if defined( SHADER_MODEL_PS_2_0 ) + #if WRITEWATERFOGTODESTALPHA && (PIXELFOGTYPE == PIXEL_FOG_TYPE_HEIGHT) + alpha = fogFactor; + #endif +#else // 2b or higher + alpha = lerp( alpha, fogFactor, g_fPixelFogType * g_fWriteWaterFogToDestAlpha ); // Use the fog factor if it's height fog +#endif + +#if defined( SHADER_MODEL_PS_2_0 ) + return FinalOutput( float4( result.rgb, alpha ), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, false, i.worldPos_projPosZ.w ); +#else + return FinalOutput( float4( result.rgb, alpha ), fogFactor, g_fPixelFogType, TONEMAP_SCALE_LINEAR, g_fWriteDepthToAlpha, i.worldPos_projPosZ.w ); +#endif + +} + diff --git a/sp/src/materialsystem/stdshaders/SDK_vertexlit_and_unlit_generic_bump_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_vertexlit_and_unlit_generic_bump_ps2x.fxc new file mode 100644 index 00000000..c0e58fba --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_vertexlit_and_unlit_generic_bump_ps2x.fxc @@ -0,0 +1,350 @@ +//======= Copyright © 1996-2008, Valve Corporation, All rights reserved. ====== + +// STATIC: "CUBEMAP" "0..1" +// STATIC: "DIFFUSELIGHTING" "0..1" +// STATIC: "LIGHTWARPTEXTURE" "0..1" +// STATIC: "SELFILLUM" "0..1" +// STATIC: "SELFILLUMFRESNEL" "0..1" +// STATIC: "NORMALMAPALPHAENVMAPMASK" "0..1" +// STATIC: "HALFLAMBERT" "0..1" +// STATIC: "FLASHLIGHT" "0..1" +// STATIC: "DETAILTEXTURE" "0..1" +// STATIC: "DETAIL_BLEND_MODE" "0..6" +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps20b] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps30] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..0" [ps20b] [XBOX] +// STATIC: "BLENDTINTBYBASEALPHA" "0..1" + +// DYNAMIC: "PIXELFOGTYPE" "0..1" [ps20] +// DYNAMIC: "WRITEWATERFOGTODESTALPHA" "0..1" [ps20] +// DYNAMIC: "NUM_LIGHTS" "0..2" [ps20] +// DYNAMIC: "NUM_LIGHTS" "0..4" [ps20b] +// DYNAMIC: "NUM_LIGHTS" "0..4" [ps30] +// DYNAMIC: "AMBIENT_LIGHT" "0..1" +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps20b] +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps30] [PC] + +// We don't use light combos when doing the flashlight +// SKIP: ( $FLASHLIGHT != 0 ) && ( $NUM_LIGHTS > 0 ) [PC] + +// We don't care about flashlight depth unless the flashlight is on +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps20b] +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps30] + +// Flashlight shadow filter mode is irrelevant if there is no flashlight +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) [ps20b] +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) [ps30] + +// SKIP: (! $DETAILTEXTURE) && ( $DETAIL_BLEND_MODE != 0 ) + +// Don't do diffuse warp on flashlight +// SKIP: ( $FLASHLIGHT == 1 ) && ( $LIGHTWARPTEXTURE == 1 ) [PC] + +// Only warp diffuse if we have it at all +// SKIP: ( $DIFFUSELIGHTING == 0 ) && ( $LIGHTWARPTEXTURE == 1 ) + +// Skip this since it blows ps20 instruction limits +// SKIP: ( $SELFILLUMFRESNEL == 1 ) && ( $LIGHTWARPTEXTURE == 1 ) + +// Only need self illum fresnel when self illum enabled +// SKIP: ( $SELFILLUM == 0 ) && ( $SELFILLUMFRESNEL == 1 ) +// SKIP: ( $FLASHLIGHT == 1 ) && ( $SELFILLUMFRESNEL == 1 ) [PC] +// SKIP: ( $FLASHLIGHT == 1 ) && ( $SELFILLUM == 1 ) [PC] +// SKIP: ( $SELFILLUMFRESNEL == 1 ) && ( $DETAILTEXTURE == 1 ) +// SKIP: ( $SELFILLUMFRESNEL == 1 ) && ( $NORMALMAPALPHAENVMAPMASK == 1 ) + +// BlendTintByBaseAlpha is incompatible with other interpretations of alpha +// SKIP: ($BLENDTINTBYBASEALPHA) && ($SELFILLUM) + +// Only _XBOX allows flashlight and cubemap in the current implementation +// SKIP: $FLASHLIGHT && $CUBEMAP [PC] + +// Meaningless combinations +// SKIP: $NORMALMAPALPHAENVMAPMASK && !$CUBEMAP + +#include "common_flashlight_fxc.h" +#include "common_vertexlitgeneric_dx9.h" + +const float4 g_EnvmapTint_TintReplaceFactor : register( c0 ); +const float4 g_DiffuseModulation : register( c1 ); +const float4 g_EnvmapContrast_ShadowTweaks : register( c2 ); +const float3 g_EnvmapSaturation : register( c3 ); +const float4 g_SelfIllumTint_and_BlendFactor : register( c4 ); +#define g_SelfIllumTint ( g_SelfIllumTint_and_BlendFactor.rgb) +#define g_DetailBlendFactor (g_SelfIllumTint_and_BlendFactor.w) + +const float3 cAmbientCube[6] : register( c5 ); + +// 11, 12 not used? +#if ( SELFILLUMFRESNEL == 1 ) + const float4 g_SelfIllumScaleBiasExpBrightness : register( c11 ); +#endif + +const float4 g_ShaderControls : register( c12 ); +#define g_fPixelFogType g_ShaderControls.x +#define g_fWriteDepthToAlpha g_ShaderControls.y +#define g_fWriteWaterFogToDestAlpha g_ShaderControls.z + + +// 2 registers each - 6 registers total +PixelShaderLightInfo cLightInfo[3] : register( c13 ); // through c18 + +const float3 g_EyePos : register( c20 ); +const float4 g_FogParams : register( c21 ); + +const float4 g_FlashlightAttenuationFactors : register( c22 ); +const float3 g_FlashlightPos : register( c23 ); +const float4x4 g_FlashlightWorldToTexture : register( c24 ); // through c27 + +sampler BaseTextureSampler : register( s0 ); +sampler EnvmapSampler : register( s1 ); +sampler DetailSampler : register( s2 ); +sampler BumpmapSampler : register( s3 ); +sampler EnvmapMaskSampler : register( s4 ); +sampler NormalizeSampler : register( s5 ); +sampler RandRotSampler : register( s6 ); // RandomRotation sampler +sampler FlashlightSampler : register( s7 ); +sampler ShadowDepthSampler : register( s8 ); // Flashlight shadow depth map sampler +sampler DiffuseWarpSampler : register( s9 ); // Lighting warp sampler (1D texture for diffuse lighting modification) + +struct PS_INPUT +{ + float4 baseTexCoord2_tangentSpaceVertToEyeVectorXY : TEXCOORD0; + float3 lightAtten : TEXCOORD1; + float4 worldVertToEyeVectorXYZ_tangentSpaceVertToEyeVectorZ : TEXCOORD2; + float3 vWorldNormal : TEXCOORD3; // World-space normal + float4 vWorldTangent : TEXCOORD4; +#if ((defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0))) + float4 vProjPos : TEXCOORD5; +#else + float3 vWorldBinormal : TEXCOORD5; +#endif + float4 worldPos_projPosZ : TEXCOORD6; + float3 detailTexCoord_atten3 : TEXCOORD7; + float4 fogFactorW : COLOR1; + +#if defined( _X360 ) +#if FLASHLIGHT + float4 flashlightSpacePos : TEXCOORD8; +#endif +#endif +}; + +// Calculate both types of Fog and lerp to get result +float CalcPixelFogFactorConst( float fPixelFogType, const float4 fogParams, const float flEyePosZ, const float flWorldPosZ, const float flProjPosZ ) +{ + float fRangeFog = CalcRangeFog( flProjPosZ, fogParams.x, fogParams.z, fogParams.w ); + float fHeightFog = CalcWaterFogAlpha( fogParams.y, flEyePosZ, flWorldPosZ, flProjPosZ, fogParams.w ); + return lerp( fRangeFog, fHeightFog, fPixelFogType ); +} + +// Blend both types of Fog and lerp to get result +float3 BlendPixelFogConst( const float3 vShaderColor, float pixelFogFactor, const float3 vFogColor, float fPixelFogType ) +{ + pixelFogFactor = saturate( pixelFogFactor ); + float3 fRangeResult = lerp( vShaderColor.rgb, vFogColor.rgb, pixelFogFactor * pixelFogFactor ); //squaring the factor will get the middle range mixing closer to hardware fog + float3 fHeightResult = lerp( vShaderColor.rgb, vFogColor.rgb, saturate( pixelFogFactor ) ); + return lerp( fRangeResult, fHeightResult, fPixelFogType ); +} + +float4 FinalOutputConst( const float4 vShaderColor, float pixelFogFactor, float fPixelFogType, const int iTONEMAP_SCALE_TYPE, float fWriteDepthToDestAlpha, const float flProjZ ) +{ + float4 result = vShaderColor; + if( iTONEMAP_SCALE_TYPE == TONEMAP_SCALE_LINEAR ) + { + result.rgb *= LINEAR_LIGHT_SCALE; + } + else if( iTONEMAP_SCALE_TYPE == TONEMAP_SCALE_GAMMA ) + { + result.rgb *= GAMMA_LIGHT_SCALE; + } + + result.a = lerp( result.a, DepthToDestAlpha( flProjZ ), fWriteDepthToDestAlpha ); + + result.rgb = BlendPixelFogConst( result.rgb, pixelFogFactor, g_LinearFogColor.rgb, fPixelFogType ); + result.rgb = SRGBOutput( result.rgb ); //SRGB in pixel shader conversion + + return result; +} + +float4 main( PS_INPUT i ) : COLOR +{ + bool bCubemap = CUBEMAP ? true : false; + bool bDiffuseLighting = DIFFUSELIGHTING ? true : false; + bool bDoDiffuseWarp = LIGHTWARPTEXTURE ? true : false; + bool bSelfIllum = SELFILLUM ? true : false; + bool bSelfIllumFresnel = SELFILLUMFRESNEL ? true : false; + bool bNormalMapAlphaEnvmapMask = NORMALMAPALPHAENVMAPMASK ? true : false; + bool bHalfLambert = HALFLAMBERT ? true : false; + bool bFlashlight = (FLASHLIGHT!=0) ? true : false; + bool bAmbientLight = AMBIENT_LIGHT ? true : false; + bool bDetailTexture = DETAILTEXTURE ? true : false; + bool bBlendTintByBaseAlpha = BLENDTINTBYBASEALPHA ? true : false; + int nNumLights = NUM_LIGHTS; + +#if ((defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0))) + float3 vWorldBinormal = cross( i.vWorldNormal.xyz, i.vWorldTangent.xyz ) * i.vWorldTangent.w; +#else + float3 vWorldBinormal = i.vWorldBinormal; +#endif + + // Unpack four light attenuations + float4 vLightAtten = float4( i.lightAtten, i.detailTexCoord_atten3.z ); + + float4 baseColor = float4( 1.0f, 1.0f, 1.0f, 1.0f ); + baseColor = tex2D( BaseTextureSampler, i.baseTexCoord2_tangentSpaceVertToEyeVectorXY.xy ); + +#if DETAILTEXTURE + float4 detailColor = tex2D( DetailSampler, i.detailTexCoord_atten3.xy ); + baseColor = TextureCombine( baseColor, detailColor, DETAIL_BLEND_MODE, g_DetailBlendFactor ); +#endif + + float specularFactor = 1.0f; + float4 normalTexel = tex2D( BumpmapSampler, i.baseTexCoord2_tangentSpaceVertToEyeVectorXY.xy ); + float3 tangentSpaceNormal = normalTexel * 2.0f - 1.0f; + + if ( bNormalMapAlphaEnvmapMask ) + specularFactor = normalTexel.a; + + float3 diffuseLighting = float3( 1.0f, 1.0f, 1.0f ); + + float3 worldSpaceNormal = float3( 0.0f, 0.0f, 1.0f ); + if ( bDiffuseLighting || bFlashlight || bCubemap || bSelfIllumFresnel ) + { + worldSpaceNormal = Vec3TangentToWorld( tangentSpaceNormal, i.vWorldNormal, i.vWorldTangent, vWorldBinormal ); +#if ( defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) ) + worldSpaceNormal = normalize( worldSpaceNormal ); +#else + worldSpaceNormal = NormalizeWithCubemap( NormalizeSampler, worldSpaceNormal ); +#endif + } + + if ( bDiffuseLighting ) + { + diffuseLighting = PixelShaderDoLighting( i.worldPos_projPosZ.xyz, worldSpaceNormal, + float3( 0.0f, 0.0f, 0.0f ), false, bAmbientLight, vLightAtten, + cAmbientCube, NormalizeSampler, nNumLights, cLightInfo, bHalfLambert, + false, 1.0f, bDoDiffuseWarp, DiffuseWarpSampler ); + } + + float3 albedo = baseColor; + if (bBlendTintByBaseAlpha) + { + float3 tintedColor = albedo * g_DiffuseModulation.rgb; + tintedColor = lerp(tintedColor, g_DiffuseModulation.rgb, g_EnvmapTint_TintReplaceFactor.w); + albedo = lerp(albedo, tintedColor, baseColor.a); + } + else + { + albedo = albedo * g_DiffuseModulation.rgb; + } + + float alpha = g_DiffuseModulation.a; + if ( !bSelfIllum && !bBlendTintByBaseAlpha ) + { + alpha *= baseColor.a; + } + + +#if FLASHLIGHT + if( bFlashlight ) + { + int nShadowSampleLevel = 0; + bool bDoShadows = false; + float2 vProjPos = float2(0, 0); +// On ps_2_b, we can do shadow mapping +#if ( FLASHLIGHTSHADOWS && (defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) ) ) + nShadowSampleLevel = FLASHLIGHTDEPTHFILTERMODE; + bDoShadows = FLASHLIGHTSHADOWS; + vProjPos = i.vProjPos.xy / i.vProjPos.w; // Screen-space position for shadow map noise +#endif + +#if defined ( _X360 ) + float4 flashlightSpacePosition = i.flashlightSpacePos; +#else + float4 flashlightSpacePosition = mul( float4( i.worldPos_projPosZ.xyz, 1.0f ), g_FlashlightWorldToTexture ); +#endif + + float3 flashlightColor = DoFlashlight( g_FlashlightPos, i.worldPos_projPosZ.xyz, flashlightSpacePosition, + worldSpaceNormal, g_FlashlightAttenuationFactors.xyz, + g_FlashlightAttenuationFactors.w, FlashlightSampler, ShadowDepthSampler, + RandRotSampler, nShadowSampleLevel, bDoShadows, false, vProjPos, false, g_EnvmapContrast_ShadowTweaks ); + +#if defined ( _X360 ) + diffuseLighting += flashlightColor; +#else + diffuseLighting = flashlightColor; +#endif + + } +#endif + + + float3 diffuseComponent = albedo * diffuseLighting; + + +#if !FLASHLIGHT || defined ( _X360 ) + if ( bSelfIllum ) + { + #if ( SELFILLUMFRESNEL == 1 ) // To free up the constant register...see top of file + // This will apply a fresnel term based on the vertex normal (not the per-pixel normal!) to help fake and internal glow look + #if ((defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0))) + float3 vVertexNormal = normalize( i.vWorldNormal.xyz ); + float flSelfIllumFresnel = ( pow( saturate( dot( vVertexNormal.xyz, normalize( i.worldVertToEyeVectorXYZ_tangentSpaceVertToEyeVectorZ.xyz ) ) ), g_SelfIllumScaleBiasExpBrightness.z ) * g_SelfIllumScaleBiasExpBrightness.x ) + g_SelfIllumScaleBiasExpBrightness.y; + + float3 selfIllumComponent = g_SelfIllumTint * albedo * g_SelfIllumScaleBiasExpBrightness.w; + diffuseComponent = lerp( diffuseComponent, selfIllumComponent, baseColor.a * saturate( flSelfIllumFresnel ) ); + #else + float3 vVertexNormal = i.vWorldNormal.xyz; + float flSelfIllumFresnel = ( pow( saturate( dot( vVertexNormal.xyz, ( i.worldVertToEyeVectorXYZ_tangentSpaceVertToEyeVectorZ.xyz ) ) ), g_SelfIllumScaleBiasExpBrightness.z ) * g_SelfIllumScaleBiasExpBrightness.x ) + g_SelfIllumScaleBiasExpBrightness.y; + + float3 selfIllumComponent = g_SelfIllumTint * albedo * g_SelfIllumScaleBiasExpBrightness.w; + diffuseComponent = lerp( diffuseComponent, selfIllumComponent, baseColor.a * saturate( flSelfIllumFresnel ) ); + #endif + #else + float3 selfIllumComponent = g_SelfIllumTint * albedo; + diffuseComponent = lerp( diffuseComponent, selfIllumComponent, baseColor.a ); + #endif + } +#endif + + float3 specularLighting = float3( 0.0f, 0.0f, 0.0f ); +#if !FLASHLIGHT || defined ( _X360 ) + if( bCubemap ) + { + float3 reflectVect = CalcReflectionVectorUnnormalized( worldSpaceNormal, i.worldVertToEyeVectorXYZ_tangentSpaceVertToEyeVectorZ.xyz ); + + specularLighting = ENV_MAP_SCALE * texCUBE( EnvmapSampler, reflectVect ); + specularLighting *= specularFactor; + specularLighting *= g_EnvmapTint_TintReplaceFactor.rgb; + float3 specularLightingSquared = specularLighting * specularLighting; + specularLighting = lerp( specularLighting, specularLightingSquared, g_EnvmapContrast_ShadowTweaks ); + float3 greyScale = dot( specularLighting, float3( 0.299f, 0.587f, 0.114f ) ); + specularLighting = lerp( greyScale, specularLighting, g_EnvmapSaturation ); + } +#endif + + float3 result = diffuseComponent + specularLighting; + +#if defined(SHADER_MODEL_PS_2_0) + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); +#else + float fogFactor = CalcPixelFogFactor( g_fPixelFogType, g_FogParams, g_EyePos.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); +#endif + +#if defined( SHADER_MODEL_PS_2_0 ) + #if WRITEWATERFOGTODESTALPHA && (PIXELFOGTYPE == PIXEL_FOG_TYPE_HEIGHT) + alpha = fogFactor; + #endif +#else // 2b or higher + alpha = lerp( alpha, fogFactor, g_fPixelFogType * g_fWriteWaterFogToDestAlpha ); // Use the fog factor if it's height fog +#endif + +#if defined( SHADER_MODEL_PS_2_0 ) + return FinalOutput( float4( result.rgb, alpha ), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, false, i.worldPos_projPosZ.w ); +#else + return FinalOutput( float4( result.rgb, alpha ), fogFactor, g_fPixelFogType, TONEMAP_SCALE_LINEAR, g_fWriteDepthToAlpha, i.worldPos_projPosZ.w ); +#endif + +} + diff --git a/sp/src/materialsystem/stdshaders/SDK_vertexlit_and_unlit_generic_bump_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_vertexlit_and_unlit_generic_bump_vs20.fxc new file mode 100644 index 00000000..6095be07 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_vertexlit_and_unlit_generic_bump_vs20.fxc @@ -0,0 +1,199 @@ +//======= Copyright (c) 1996-2009, Valve Corporation, All rights reserved. ====== +// STATIC: "HALFLAMBERT" "0..1" +// STATIC: "USE_WITH_2B" "0..1" +// STATIC: "DECAL" "0..1" [vs30] +// STATIC: "FLASHLIGHT" "0..1" [XBOX] +// STATIC: "SM30_VERTEXID" "0..1" [vs30] +// STATIC: "USE_STATIC_CONTROL_FLOW" "0..1" [vs20] + +// DYNAMIC: "COMPRESSED_VERTS" "0..1" +// DYNAMIC: "DOWATERFOG" "0..1" +// DYNAMIC: "SKINNING" "0..1" +// DYNAMIC: "MORPHING" "0..1" [vs30] +// DYNAMIC: "NUM_LIGHTS" "0..2" [vs20] + +// If using static control flow on Direct3D, we should use the NUM_LIGHTS=0 combo +// SKIP: $USE_STATIC_CONTROL_FLOW && ( $NUM_LIGHTS > 0 ) [vs20] + +#include "common_vs_fxc.h" + +static const bool g_bSkinning = SKINNING ? true : false; +static const int g_FogType = DOWATERFOG; + +const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 ); // 0 & 1 +const float4 cDetailTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_4 ); // 4 & 5 +const float4x4 g_FlashlightWorldToTexture : register( SHADER_SPECIFIC_CONST_6 ); // 6, 7, 8, 9 + +#if defined( SHADER_MODEL_VS_3_0 ) && SM30_VERTEXID +// NOTE: cMorphTargetTextureDim.xy = target dimensions, +// cMorphTargetTextureDim.z = 4tuples/morph +const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_10 ); +const float4 cMorphSubrect : register( SHADER_SPECIFIC_CONST_11 ); + +sampler2D morphSampler : register( D3DVERTEXTEXTURESAMPLER0, s0 ); +#endif + + +//----------------------------------------------------------------------------- +// Input vertex format +//----------------------------------------------------------------------------- +struct VS_INPUT +{ + // This is all of the stuff that we ever use. + float4 vPos : POSITION; + float4 vBoneWeights : BLENDWEIGHT; + float4 vBoneIndices : BLENDINDICES; + float4 vNormal : NORMAL; + float4 vColor : COLOR0; + float3 vSpecular : COLOR1; + // make these float2's and stick the [n n 0 1] in the dot math. + float4 vTexCoord0 : TEXCOORD0; + float4 vTexCoord1 : TEXCOORD1; + float4 vTexCoord2 : TEXCOORD2; + float4 vTexCoord3 : TEXCOORD3; + float3 vTangentS : TANGENT; + float3 vTangentT : BINORMAL; + float4 vUserData : TANGENT; + + // Position and normal/tangent deltas + float3 vPosFlex : POSITION1; + float3 vNormalFlex : NORMAL1; +#if defined( SHADER_MODEL_VS_3_0 ) && SM30_VERTEXID + float vVertexID : POSITION2; +#endif +}; + + +//----------------------------------------------------------------------------- +// Output vertex format +//----------------------------------------------------------------------------- +struct VS_OUTPUT +{ + // Stuff that isn't seen by the pixel shader + float4 projPos : POSITION; +#if !defined( _X360 ) + float fog : FOG; +#endif + // Stuff that is seen by the pixel shader + + float4 baseTexCoord2_tangentSpaceVertToEyeVectorXY : TEXCOORD0; + float3 lightAtten : TEXCOORD1; + float4 worldVertToEyeVectorXYZ_tangentSpaceVertToEyeVectorZ : TEXCOORD2; + float3 vWorldNormal : TEXCOORD3; // World-space normal + float4 vWorldTangent : TEXCOORD4; +#if USE_WITH_2B + float4 vProjPos : TEXCOORD5; +#else + float3 vWorldBinormal : TEXCOORD5; +#endif + float4 worldPos_projPosZ : TEXCOORD6; + float3 detailTexCoord_atten3 : TEXCOORD7; + float4 fogFactorW : COLOR1; + +#if defined( _X360 ) && FLASHLIGHT + float4 flashlightSpacePos : TEXCOORD8; +#endif +}; + + +//----------------------------------------------------------------------------- +// Main shader entry point +//----------------------------------------------------------------------------- +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + + float4 vPosition = v.vPos; + float3 vNormal; + float4 vTangent; + DecompressVertex_NormalTangent( v.vNormal, v.vUserData, vNormal, vTangent ); + +#if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING || !SM30_VERTEXID + ApplyMorph( v.vPosFlex, v.vNormalFlex, vPosition.xyz, vNormal, vTangent.xyz ); +#else + ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, + v.vVertexID, v.vTexCoord2, vPosition.xyz, vNormal, vTangent.xyz ); +#endif + + // Perform skinning + float3 worldNormal, worldPos, worldTangentS, worldTangentT; + SkinPositionNormalAndTangentSpace( g_bSkinning, vPosition, vNormal, vTangent, + v.vBoneWeights, v.vBoneIndices, worldPos, + worldNormal, worldTangentS, worldTangentT ); + + // Always normalize since flex path is controlled by runtime + // constant not a shader combo and will always generate the normalization + worldNormal = normalize( worldNormal ); + worldTangentS = normalize( worldTangentS ); + worldTangentT = normalize( worldTangentT ); + +#if defined( SHADER_MODEL_VS_3_0 ) && MORPHING && DECAL && SM30_VERTEXID + // Avoid z precision errors + worldPos += worldNormal * 0.05f * v.vTexCoord2.z; +#endif + + o.vWorldNormal.xyz = worldNormal.xyz; + o.vWorldTangent = float4( worldTangentS.xyz, vTangent.w ); // Propagate binormal sign in world tangent.w + + // Transform into projection space + float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj ); + o.projPos = vProjPos; + vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ ); + +#if USE_WITH_2B + o.vProjPos = vProjPos; +#else + o.vWorldBinormal.xyz = worldTangentT.xyz; +#endif + + o.fogFactorW = CalcFog( worldPos, vProjPos, g_FogType ); +#if !defined( _X360 ) + o.fog = o.fogFactorW; +#endif + + // Needed for water fog alpha and diffuse lighting + // FIXME: we shouldn't have to compute this all the time. + o.worldPos_projPosZ = float4( worldPos, vProjPos.z ); + + // Needed for cubemapping + parallax mapping + // FIXME: We shouldn't have to compute this all the time. + //o.worldVertToEyeVectorXYZ_tangentSpaceVertToEyeVectorZ.xyz = VSHADER_VECT_SCALE * (cEyePos - worldPos); + o.worldVertToEyeVectorXYZ_tangentSpaceVertToEyeVectorZ.xyz = normalize( cEyePos.xyz - worldPos.xyz ); + +#if defined( SHADER_MODEL_VS_2_0 ) && ( !USE_STATIC_CONTROL_FLOW ) + o.lightAtten.xyz = float3(0,0,0); + o.detailTexCoord_atten3.z = 0.0f; + #if ( NUM_LIGHTS > 0 ) + o.lightAtten.x = GetVertexAttenForLight( worldPos, 0, false ); + #endif + #if ( NUM_LIGHTS > 1 ) + o.lightAtten.y = GetVertexAttenForLight( worldPos, 1, false ); + #endif + #if ( NUM_LIGHTS > 2 ) + o.lightAtten.z = GetVertexAttenForLight( worldPos, 2, false ); + #endif + #if ( NUM_LIGHTS > 3 ) + o.detailTexCoord_atten3.z = GetVertexAttenForLight( worldPos, 3, false ); + #endif +#else + // Scalar light attenuation + o.lightAtten.x = GetVertexAttenForLight( worldPos, 0, true ); + o.lightAtten.y = GetVertexAttenForLight( worldPos, 1, true ); + o.lightAtten.z = GetVertexAttenForLight( worldPos, 2, true ); + o.detailTexCoord_atten3.z = GetVertexAttenForLight( worldPos, 3, true ); +#endif + + // Base texture coordinate transform + o.baseTexCoord2_tangentSpaceVertToEyeVectorXY.x = dot( v.vTexCoord0, cBaseTexCoordTransform[0] ); + o.baseTexCoord2_tangentSpaceVertToEyeVectorXY.y = dot( v.vTexCoord0, cBaseTexCoordTransform[1] ); + + // Detail texture coordinate transform + o.detailTexCoord_atten3.x = dot( v.vTexCoord0, cDetailTexCoordTransform[0] ); + o.detailTexCoord_atten3.y = dot( v.vTexCoord0, cDetailTexCoordTransform[1] ); + +#if defined( _X360 ) && FLASHLIGHT + o.flashlightSpacePos = mul( float4( worldPos, 1.0f ), g_FlashlightWorldToTexture ); +#endif + + return o; +} diff --git a/sp/src/materialsystem/stdshaders/SDK_vertexlit_and_unlit_generic_ps20b.fxc b/sp/src/materialsystem/stdshaders/SDK_vertexlit_and_unlit_generic_ps20b.fxc new file mode 100644 index 00000000..d4650f52 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_vertexlit_and_unlit_generic_ps20b.fxc @@ -0,0 +1,498 @@ +//====== Copyright © 1996-2007, Valve Corporation, All rights reserved. =======// +// +//=============================================================================// + + +//#define NEW_SHADOW_FILTERS + +// STATIC: "DETAILTEXTURE" "0..1" +// STATIC: "CUBEMAP" "0..1" +// STATIC: "DIFFUSELIGHTING" "0..1" +// STATIC: "ENVMAPMASK" "0..1" +// STATIC: "BASEALPHAENVMAPMASK" "0..1" +// STATIC: "SELFILLUM" "0..1" +// STATIC: "VERTEXCOLOR" "0..1" +// STATIC: "FLASHLIGHT" "0..1" +// STATIC: "SELFILLUM_ENVMAPMASK_ALPHA" "0..1" +// STATIC: "DETAIL_BLEND_MODE" "0..9" +// STATIC: "SEAMLESS_BASE" "0..1" +// STATIC: "SEAMLESS_DETAIL" "0..1" +// STATIC: "DISTANCEALPHA" "0..1" +// STATIC: "DISTANCEALPHAFROMDETAIL" "0..1" +// STATIC: "SOFT_MASK" "0..1" +// STATIC: "OUTLINE" "0..1" +// STATIC: "OUTER_GLOW" "0..1" +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps20b] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps30] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..0" [ps20b] [XBOX] +// STATIC: "DEPTHBLEND" "0..1" [ps20b] [ps30] +// STATIC: "BLENDTINTBYBASEALPHA" "0..1" +// STATIC: "SRGB_INPUT_ADAPTER" "0..1" [ps20b] +// STATIC: "CUBEMAP_SPHERE_LEGACY" "0..1" + +// DYNAMIC: "PIXELFOGTYPE" "0..1" [ps20] +// DYNAMIC: "LIGHTING_PREVIEW" "0..2" [PC] +// DYNAMIC: "LIGHTING_PREVIEW" "0..0" [XBOX] +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps20b] +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps30] + +// detail blend mode 6 = ps20b only +// SKIP: $DETAIL_BLEND_MODE == 6 [ps20] + +// SKIP: ($DETAILTEXTURE == 0 ) && ( $DETAIL_BLEND_MODE != 0 ) +// SKIP: ($DETAILTEXTURE == 0 ) && ( $SEAMLESS_DETAIL ) +// SKIP: ($ENVMAPMASK || $SELFILLUM_ENVMAPMASK_ALPHA) && ($SEAMLESS_BASE || $SEAMLESS_DETAIL) +// SKIP: $BASEALPHAENVMAPMASK && $ENVMAPMASK +// SKIP: $BASEALPHAENVMAPMASK && $SELFILLUM +// SKIP: $SELFILLUM && $SELFILLUM_ENVMAPMASK_ALPHA +// SKIP: $SELFILLUM_ENVMAPMASK_ALPHA && (! $ENVMAPMASK) +// SKIP: $ENVMAPMASK && ($FLASHLIGHT || $FLASHLIGHTSHADOWS) [PC] +// SKIP: $BASEALPHAENVMAPMASK && ($SEAMLESS_BASE || $SEAMLESS_DETAIL) +// SKIP: ($DISTANCEALPHA == 0) && ($DISTANCEALPHAFROMDETAIL || $SOFT_MASK || $OUTLINE || $OUTER_GLOW) +// SKIP: ($DETAILTEXTURE == 0) && ($DISTANCEALPHAFROMDETAIL) + +// We don't care about flashlight depth unless the flashlight is on +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps20b] +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps30] + +// Flashlight shadow filter mode is irrelevant if there is no flashlight +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) [ps20b] +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) [ps30] + +// DISTANCEALPHA-related skips +// SKIP: ($DISTANCEALPHA) && ($ENVMAPMASK || $BASEALPHAENVMAPMASK || $SELFILLUM || $SELFILLUM_ENVMAPMASK_ALPHA ) +// SKIP: ($DISTANCEALPHA) && ($SEAMLESS_BASE || $SEAMLESS_DETAIL || $CUBEMAP || $LIGHTING_PREVIEW ) +// SKIP: ($DISTANCEALPHA) && ($WRITEWATERFOGTODESTALPHA || $PIXELFOGTYPE || $FLASHLIGHT || $FLASHLIGHTSHADOWS || $SRGB_INPUT_ADAPTER ) + +// SKIP: $SEAMLESS_BASE && $SRGB_INPUT_ADAPTER +// SKIP: $SEAMLESS_BASE && ($BLENDTINTBYBASEALPHA ) + +// BlendTintByBaseAlpha is incompatible with other interpretations of alpha +// SKIP: ($BLENDTINTBYBASEALPHA) && ($SELFILLUM || (($DISTANCEALPHA) && ($DISTANCEALPHAFROMDETAIL == 0)) || $BASEALPHAENVMAPMASK) + +// Only _XBOX allows flashlight and cubemap in the current implementation +// SKIP: $FLASHLIGHT && $CUBEMAP [PC] + +// SKIP: $CUBEMAP_SPHERE_LEGACY && ($CUBEMAP == 0) + +#include "common_flashlight_fxc.h" +#include "common_vertexlitgeneric_dx9.h" + +const float4 g_EnvmapTint_TintReplaceFactor : register( c0 ); +const float4 g_DiffuseModulation : register( c1 ); +const float4 g_EnvmapContrast_ShadowTweaks : register( c2 ); +const float4 g_EnvmapSaturation_SelfIllumMask : register( c3 ); +const float4 g_SelfIllumTint_and_BlendFactor : register( c4 ); + +const float4 g_ShaderControls : register( c12 ); +const float4 g_DepthFeatheringConstants : register( c13 ); + +const float4 g_EyePos_MinLight : register( c20 ); +#define g_EyePos g_EyePos_MinLight.xyz +#define g_fMinLighting g_EyePos_MinLight.w + +const float4 g_FogParams : register( c21 ); + +#define g_SelfIllumTint g_SelfIllumTint_and_BlendFactor.xyz +#define g_DetailBlendFactor g_SelfIllumTint_and_BlendFactor.w +#define g_EnvmapSaturation g_EnvmapSaturation_SelfIllumMask.xyz +#define g_SelfIllumMaskControl g_EnvmapSaturation_SelfIllumMask.w + +const float4 g_FlashlightAttenuationFactors : register( c22 ); +const HALF3 g_FlashlightPos : register( c23 ); +const float4x4 g_FlashlightWorldToTexture : register( c24 ); // through c27 + + +sampler BaseTextureSampler : register( s0 ); +sampler EnvmapSampler : register( s1 ); +sampler DetailSampler : register( s2 ); +sampler EnvmapMaskSampler : register( s4 ); +sampler RandRotSampler : register( s6 ); // RandomRotation sampler +sampler FlashlightSampler : register( s7 ); +sampler ShadowDepthSampler : register( s8 ); // Flashlight shadow depth map sampler +sampler DepthSampler : register( s10 ); //depth buffer sampler for depth blending +sampler SelfIllumMaskSampler : register( s11 ); // selfillummask + +struct PS_INPUT +{ +#if SEAMLESS_BASE + HALF3 baseTexCoord : TEXCOORD0; // Base texture coordinate +#else + HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate +#endif +#if SEAMLESS_DETAIL + HALF3 detailTexCoord : TEXCOORD1; // Seamless texture coordinate +#else + HALF2 detailTexCoord : TEXCOORD1; // Detail texture coordinate +#endif + float4 color : TEXCOORD2; // Vertex color (from lighting or unlit) + float3 worldVertToEyeVector : TEXCOORD3; // Necessary for reflection + float3 worldSpaceNormal : TEXCOORD4; // Necessary for cubemaps and flashlight + +#if defined ( _X360 ) +#if FLASHLIGHT + float4 flashlightSpacePos : TEXCOORD5; +#endif +#endif + + float4 projPos : TEXCOORD6; + float4 worldPos_projPosZ : TEXCOORD7; + float4 fogFactorW : COLOR1; +#if SEAMLESS_BASE || SEAMLESS_DETAIL + float3 SeamlessWeights : COLOR0; // x y z projection weights +#endif +}; + +const float4 g_GlowParameters : register( c5 ); +const float4 g_GlowColor : register( c6 ); +#define GLOW_UV_OFFSET g_GlowParameters.xy +#define OUTER_GLOW_MIN_DVALUE g_GlowParameters.z +#define OUTER_GLOW_MAX_DVALUE g_GlowParameters.w +#define OUTER_GLOW_COLOR g_GlowColor + +#define g_fPixelFogType g_ShaderControls.x +#define g_fWriteDepthToAlpha g_ShaderControls.y +#define g_fWriteWaterFogToDestAlpha g_ShaderControls.z +#define g_fVertexAlpha g_ShaderControls.w + + +const float4 g_DistanceAlphaParams : register( c7 ); +#define SOFT_MASK_MAX g_DistanceAlphaParams.x +#define SOFT_MASK_MIN g_DistanceAlphaParams.y + +const float4 g_OutlineColor : register( c8 ); +#define OUTLINE_COLOR g_OutlineColor + +const float4 g_OutlineParams : register( c9 ); +// these are ordered this way for optimal ps20 swizzling +#define OUTLINE_MIN_VALUE0 g_OutlineParams.x +#define OUTLINE_MAX_VALUE1 g_OutlineParams.y +#define OUTLINE_MAX_VALUE0 g_OutlineParams.z +#define OUTLINE_MIN_VALUE1 g_OutlineParams.w + +#if DETAILTEXTURE +const float3 g_DetailTint : register( c10 ); +#endif + + +// Calculate unified fog +float CalcPixelFogFactorConst( float fPixelFogType, const float4 fogParams, const float flEyePosZ, const float flWorldPosZ, const float flProjPosZ ) +{ + float flDepthBelowWater = fPixelFogType*fogParams.y - flWorldPosZ; // above water = negative, below water = positive + float flDepthBelowEye = fPixelFogType*flEyePosZ - flWorldPosZ; // above eye = negative, below eye = positive + // if fPixelFogType == 0, then flDepthBelowWater == flDepthBelowEye and frac will be 1 + float frac = (flDepthBelowEye == 0) ? 1 : saturate(flDepthBelowWater/flDepthBelowEye); + return saturate( min(fogParams.z, flProjPosZ * fogParams.w * frac - fogParams.x) ); +} + +// Blend both types of Fog and lerp to get result +float3 BlendPixelFogConst( const float3 vShaderColor, float pixelFogFactor, const float3 vFogColor, float fPixelFogType ) +{ + //float3 fRangeResult = lerp( vShaderColor.rgb, vFogColor.rgb, pixelFogFactor * pixelFogFactor ); //squaring the factor will get the middle range mixing closer to hardware fog + //float3 fHeightResult = lerp( vShaderColor.rgb, vFogColor.rgb, saturate( pixelFogFactor ) ); + //return lerp( fRangeResult, fHeightResult, fPixelFogType ); + pixelFogFactor = lerp( pixelFogFactor*pixelFogFactor, pixelFogFactor, fPixelFogType ); + return lerp( vShaderColor.rgb, vFogColor.rgb, pixelFogFactor ); +} + + +float4 FinalOutputConst( const float4 vShaderColor, float pixelFogFactor, float fPixelFogType, const int iTONEMAP_SCALE_TYPE, float fWriteDepthToDestAlpha, const float flProjZ ) +{ + float4 result = vShaderColor; + if( iTONEMAP_SCALE_TYPE == TONEMAP_SCALE_LINEAR ) + { + result.rgb *= LINEAR_LIGHT_SCALE; + } + else if( iTONEMAP_SCALE_TYPE == TONEMAP_SCALE_GAMMA ) + { + result.rgb *= GAMMA_LIGHT_SCALE; + } + + result.a = lerp( result.a, DepthToDestAlpha( flProjZ ), fWriteDepthToDestAlpha ); + + result.rgb = BlendPixelFogConst( result.rgb, pixelFogFactor, g_LinearFogColor.rgb, fPixelFogType ); + result.rgb = SRGBOutput( result.rgb ); //SRGB in pixel shader conversion + + return result; +} + + +#if LIGHTING_PREVIEW == 2 +LPREVIEW_PS_OUT main( PS_INPUT i ) : COLOR +#else +float4 main( PS_INPUT i ) : COLOR +#endif +{ + bool bDetailTexture = DETAILTEXTURE ? true : false; + bool bCubemap = CUBEMAP ? true : false; + bool bDiffuseLighting = DIFFUSELIGHTING ? true : false; + bool bHasNormal = bCubemap || bDiffuseLighting; + bool bEnvmapMask = ENVMAPMASK ? true : false; + bool bBaseAlphaEnvmapMask = BASEALPHAENVMAPMASK ? true : false; + bool bSelfIllum = SELFILLUM ? true : false; + bool bVertexColor = VERTEXCOLOR ? true : false; + bool bFlashlight = FLASHLIGHT ? true : false; + bool bBlendTintByBaseAlpha = BLENDTINTBYBASEALPHA ? true : false; + + HALF4 baseColor = HALF4( 1.0f, 1.0f, 1.0f, 1.0f ); +#if SEAMLESS_BASE + baseColor = + i.SeamlessWeights.x * tex2D( BaseTextureSampler, i.baseTexCoord.yz )+ + i.SeamlessWeights.y * tex2D( BaseTextureSampler, i.baseTexCoord.zx )+ + i.SeamlessWeights.z * tex2D( BaseTextureSampler, i.baseTexCoord.xy ); +#else + baseColor = tex2D( BaseTextureSampler, i.baseTexCoord.xy ); + +#if SRGB_INPUT_ADAPTER + baseColor.rgb = GammaToLinear( baseColor.rgb ); +#endif + +#endif // !SEAMLESS_BASE + + +#if DISTANCEALPHA && (DISTANCEALPHAFROMDETAIL == 0) + float distAlphaMask = baseColor.a; +#endif + + +#if DETAILTEXTURE +#if SEAMLESS_DETAIL + float4 detailColor = + i.SeamlessWeights.x * tex2D( DetailSampler, i.detailTexCoord.yz )+ + i.SeamlessWeights.y * tex2D( DetailSampler, i.detailTexCoord.zx )+ + i.SeamlessWeights.z * tex2D( DetailSampler, i.detailTexCoord.xy ); +#else + float4 detailColor = tex2D( DetailSampler, i.detailTexCoord.xy ); +#endif + detailColor.rgb *= g_DetailTint; + +#if DISTANCEALPHA && (DISTANCEALPHAFROMDETAIL == 1) + float distAlphaMask = detailColor.a; + detailColor.a = 1.0; // make tcombine treat as 1.0 +#endif + baseColor = + TextureCombine( baseColor, detailColor, DETAIL_BLEND_MODE, g_DetailBlendFactor ); +#endif + +#if DISTANCEALPHA + // now, do all distance alpha effects + //if ( OUTLINE && ( distAlphaMask >= OUTLINE_MIN_VALUE0 ) && ( distAlphaMask <= OUTLINE_MAX_VALUE1 ) ) + //{ + // float oFactor=1.0; + // if ( distAlphaMask <= OUTLINE_MIN_VALUE1 ) + // { + // oFactor=smoothstep( OUTLINE_MIN_VALUE0, OUTLINE_MIN_VALUE1, distAlphaMask ); + // } + // else + // { + // oFactor=smoothstep( OUTLINE_MAX_VALUE1, OUTLINE_MAX_VALUE0, distAlphaMask ); + // } + // baseColor = lerp( baseColor, OUTLINE_COLOR, oFactor ); + //} + if ( OUTLINE ) + { + float4 oFactors = smoothstep(g_OutlineParams.xyzw, g_OutlineParams.wzyx, distAlphaMask ); + baseColor = lerp( baseColor, g_OutlineColor, oFactors.x * oFactors.y ); + } + + float mskUsed; + if ( SOFT_MASK ) + { + mskUsed = smoothstep( SOFT_MASK_MIN, SOFT_MASK_MAX, distAlphaMask ); + baseColor.a *= mskUsed; + } + else + { + mskUsed = distAlphaMask >= 0.5; + if (DETAILTEXTURE ) + baseColor.a *= mskUsed; + else + baseColor.a = mskUsed; + } + + + if ( OUTER_GLOW ) + { +#if DISTANCEALPHAFROMDETAIL + float4 glowTexel = tex2D( DetailSampler, i.detailTexCoord.xy+GLOW_UV_OFFSET ); +#else + float4 glowTexel = tex2D( BaseTextureSampler, i.baseTexCoord.xy+GLOW_UV_OFFSET ); +#endif + float4 glowc = OUTER_GLOW_COLOR*smoothstep( OUTER_GLOW_MIN_DVALUE, OUTER_GLOW_MAX_DVALUE, glowTexel.a ); + baseColor = lerp( glowc, baseColor, mskUsed ); + } + +#endif // DISTANCEALPHA + + float3 specularFactor = 1.0f; + float4 envmapMaskTexel; + if( bEnvmapMask ) + { + envmapMaskTexel = tex2D( EnvmapMaskSampler, i.baseTexCoord.xy ); + specularFactor *= envmapMaskTexel.xyz; + } + + if( bBaseAlphaEnvmapMask ) + { + specularFactor *= 1.0 - baseColor.a; // this blows! + } + + float3 diffuseLighting = float3( 1.0f, 1.0f, 1.0f ); + if( bDiffuseLighting || bVertexColor && !( bVertexColor && bDiffuseLighting ) ) + { + diffuseLighting = i.color.rgb; + } + + float3 albedo = baseColor; + if (bBlendTintByBaseAlpha) + { + float3 tintedColor = albedo * g_DiffuseModulation.rgb; + tintedColor = lerp(tintedColor, g_DiffuseModulation.rgb, g_EnvmapTint_TintReplaceFactor.w); + albedo = lerp(albedo, tintedColor, baseColor.a); + } + else + { + albedo = albedo * g_DiffuseModulation.rgb; + } + + float alpha = g_DiffuseModulation.a; + if ( !bBaseAlphaEnvmapMask && !bSelfIllum && !bBlendTintByBaseAlpha ) + { + alpha *= baseColor.a; + } + + + if( bFlashlight ) + { + int nShadowSampleLevel = 0; + bool bDoShadows = false; +// On ps_2_b, we can do shadow mapping +#if ( FLASHLIGHTSHADOWS && (defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) ) ) + nShadowSampleLevel = FLASHLIGHTDEPTHFILTERMODE; + bDoShadows = true; +#endif + +#if defined ( _X360 ) + float4 flashlightSpacePosition = i.flashlightSpacePos; +#else + float4 flashlightSpacePosition = mul( float4( i.worldPos_projPosZ.xyz, 1.0f ), g_FlashlightWorldToTexture ); +#endif + + // We want the N.L to happen on the flashlight pass, but can't afford it on ps20 + bool bUseWorldNormal = true; +#if ( defined( SHADER_MODEL_PS_2_0 ) && ( DETAILTEXTURE ) ) + bUseWorldNormal = false; +#endif + float3 flashlightColor = DoFlashlight( g_FlashlightPos, i.worldPos_projPosZ.xyz, flashlightSpacePosition, + i.worldSpaceNormal, g_FlashlightAttenuationFactors.xyz, + g_FlashlightAttenuationFactors.w, FlashlightSampler, ShadowDepthSampler, + RandRotSampler, nShadowSampleLevel, bDoShadows, false, i.projPos.xy / i.projPos.w, false, g_EnvmapContrast_ShadowTweaks, bUseWorldNormal ); + +#if defined ( _X360 ) + diffuseLighting += flashlightColor; +#else + diffuseLighting = flashlightColor; +#endif + } + + if( bVertexColor && bDiffuseLighting ) + { + albedo *= i.color.rgb; + } + + alpha = lerp( alpha, alpha * i.color.a, g_fVertexAlpha ); + +#if FOGTYPE == 2 || FLASHLIGHT != 0 + float3 diffuseComponent = albedo * diffuseLighting; +#else + float3 vEyeDir = normalize( i.worldVertToEyeVector.xyz ); + float flFresnelMinlight = saturate( dot( i.worldSpaceNormal, vEyeDir ) ); + + float3 diffuseComponent = albedo * lerp( diffuseLighting, 1, g_fMinLighting * flFresnelMinlight ); +#endif + +#if DETAILTEXTURE + diffuseComponent = + TextureCombinePostLighting( diffuseComponent, detailColor, DETAIL_BLEND_MODE, g_DetailBlendFactor ); +#endif + + HALF3 specularLighting = HALF3( 0.0f, 0.0f, 0.0f ); + +#if !FLASHLIGHT || defined ( _X360 ) + #if SELFILLUM_ENVMAPMASK_ALPHA + // range of alpha: + // 0 - 0.125 = lerp(diffuse,selfillum,alpha*8) + // 0.125-1.0 = selfillum*(1+alpha-0.125)*8 (over bright glows) + HALF3 selfIllumComponent = g_SelfIllumTint * albedo; + half Adj_Alpha=8*envmapMaskTexel.a; + diffuseComponent=( max( 0, 1-Adj_Alpha ) * diffuseComponent) + Adj_Alpha * selfIllumComponent; + #else + if ( bSelfIllum ) + { + float3 vSelfIllumMask = tex2D( SelfIllumMaskSampler, i.baseTexCoord.xy ); + vSelfIllumMask = lerp( baseColor.aaa, vSelfIllumMask, g_SelfIllumMaskControl ); + diffuseComponent = lerp( diffuseComponent, g_SelfIllumTint * albedo, vSelfIllumMask ); + } + #endif + + if( bCubemap ) + { +#if CUBEMAP_SPHERE_LEGACY + HALF3 reflectVect = normalize(CalcReflectionVectorUnnormalized( i.worldSpaceNormal, i.worldVertToEyeVector.xyz )); + + specularLighting = 0.5 * tex2D( EnvmapSampler, float2(reflectVect.x, reflectVect.y) ) * g_DiffuseModulation.rgb * diffuseLighting; +#else + HALF3 reflectVect = CalcReflectionVectorUnnormalized( i.worldSpaceNormal, i.worldVertToEyeVector.xyz ); + + specularLighting = ENV_MAP_SCALE * texCUBE( EnvmapSampler, reflectVect ); + specularLighting *= specularFactor; + specularLighting *= g_EnvmapTint_TintReplaceFactor.rgb; + HALF3 specularLightingSquared = specularLighting * specularLighting; + specularLighting = lerp( specularLighting, specularLightingSquared, g_EnvmapContrast_ShadowTweaks ); + HALF3 greyScale = dot( specularLighting, HALF3( 0.299f, 0.587f, 0.114f ) ); + specularLighting = lerp( greyScale, specularLighting, g_EnvmapSaturation ); +#endif + } +#endif + + HALF3 result = diffuseComponent + specularLighting; + +#if LIGHTING_PREVIEW +# if LIGHTING_PREVIEW == 1 + float dotprod=0.7+0.25*dot(i.worldSpaceNormal,normalize(float3(1,2,-.5))); + return FinalOutput( float4( dotprod*albedo.xyz, alpha ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_LINEAR ); +# else + LPREVIEW_PS_OUT ret; + ret.flags=float4(1,1,1,1); + ret.color=float4( albedo.xyz, alpha ); + ret.normal=float4(i.worldSpaceNormal,alpha); + ret.position=float4(i.worldPos_projPosZ.xyz, alpha); + return FinalOutput( ret, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE ); +# endif +#else + +# if (DEPTHBLEND == 1) + { + float2 vScreenPos; + vScreenPos.x = i.projPos.x; + vScreenPos.y = -i.projPos.y; + vScreenPos = (vScreenPos + i.projPos.w) * 0.5f; + alpha *= DepthFeathering( DepthSampler, vScreenPos / i.projPos.w, i.projPos.w - i.projPos.z, i.projPos.w, g_DepthFeatheringConstants ); + } +# endif + +#if defined( SHADER_MODEL_PS_2_0 ) + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.xyz, i.worldPos_projPosZ.xyz, i.projPos.z ); + #if (PIXELFOGTYPE == PIXEL_FOG_TYPE_HEIGHT) + alpha = lerp( alpha, fogFactor, g_fWriteWaterFogToDestAlpha ); + #endif + return FinalOutput( float4( result.rgb, alpha ), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, false, i.projPos.z ); +#else // 2b or higher + float fogFactor = CalcPixelFogFactor( g_fPixelFogType, g_FogParams, g_EyePos.xyz, i.worldPos_projPosZ.xyz, i.projPos.z ); + alpha = lerp( alpha, fogFactor, g_fWriteWaterFogToDestAlpha ); // Use the fog factor if it's height fog + return FinalOutput( float4( result.rgb, alpha ), fogFactor, g_fPixelFogType, TONEMAP_SCALE_LINEAR, g_fWriteDepthToAlpha, i.projPos.z ); +#endif + +#endif +} + diff --git a/sp/src/materialsystem/stdshaders/SDK_vertexlit_and_unlit_generic_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_vertexlit_and_unlit_generic_ps2x.fxc new file mode 100644 index 00000000..f67bc1ca --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_vertexlit_and_unlit_generic_ps2x.fxc @@ -0,0 +1,484 @@ +//====== Copyright © 1996-2007, Valve Corporation, All rights reserved. =======// +// +//=============================================================================// +// STATIC: "DETAILTEXTURE" "0..1" +// STATIC: "CUBEMAP" "0..1" +// STATIC: "DIFFUSELIGHTING" "0..1" +// STATIC: "ENVMAPMASK" "0..1" +// STATIC: "BASEALPHAENVMAPMASK" "0..1" +// STATIC: "SELFILLUM" "0..1" +// STATIC: "VERTEXCOLOR" "0..1" +// STATIC: "FLASHLIGHT" "0..1" +// STATIC: "SELFILLUM_ENVMAPMASK_ALPHA" "0..1" +// STATIC: "DETAIL_BLEND_MODE" "0..9" +// STATIC: "SEAMLESS_BASE" "0..1" +// STATIC: "SEAMLESS_DETAIL" "0..1" +// STATIC: "DISTANCEALPHA" "0..1" +// STATIC: "DISTANCEALPHAFROMDETAIL" "0..1" +// STATIC: "SOFT_MASK" "0..1" +// STATIC: "OUTLINE" "0..1" +// STATIC: "OUTER_GLOW" "0..1" +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps20b] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps30] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..0" [ps20b] [XBOX] +// STATIC: "DEPTHBLEND" "0..1" [ps20b] [ps30] +// STATIC: "BLENDTINTBYBASEALPHA" "0..1" +// STATIC: "SRGB_INPUT_ADAPTER" "0..1" [ps20b] +// STATIC: "CUBEMAP_SPHERE_LEGACY" "0..1" + +// DYNAMIC: "PIXELFOGTYPE" "0..1" [ps20] +// DYNAMIC: "LIGHTING_PREVIEW" "0..2" [PC] +// DYNAMIC: "LIGHTING_PREVIEW" "0..0" [XBOX] +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps20b] +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps30] + +// detail blend mode 6 = ps20b only +// SKIP: $DETAIL_BLEND_MODE == 6 [ps20] + +// SKIP: ($DETAILTEXTURE == 0 ) && ( $DETAIL_BLEND_MODE != 0 ) +// SKIP: ($DETAILTEXTURE == 0 ) && ( $SEAMLESS_DETAIL ) +// SKIP: ($ENVMAPMASK || $SELFILLUM_ENVMAPMASK_ALPHA) && ($SEAMLESS_BASE || $SEAMLESS_DETAIL) +// SKIP: $BASEALPHAENVMAPMASK && $ENVMAPMASK +// SKIP: $BASEALPHAENVMAPMASK && $SELFILLUM +// SKIP: $SELFILLUM && $SELFILLUM_ENVMAPMASK_ALPHA +// SKIP: $SELFILLUM_ENVMAPMASK_ALPHA && (! $ENVMAPMASK) +// SKIP: $ENVMAPMASK && ($FLASHLIGHT || $FLASHLIGHTSHADOWS) [PC] +// SKIP: $BASEALPHAENVMAPMASK && ($SEAMLESS_BASE || $SEAMLESS_DETAIL) +// SKIP: ($DISTANCEALPHA == 0) && ($DISTANCEALPHAFROMDETAIL || $SOFT_MASK || $OUTLINE || $OUTER_GLOW) +// SKIP: ($DETAILTEXTURE == 0) && ($DISTANCEALPHAFROMDETAIL) + +// We don't care about flashlight depth unless the flashlight is on +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps20b] +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps30] + +// Flashlight shadow filter mode is irrelevant if there is no flashlight +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) [ps20b] +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) [ps30] + +// DISTANCEALPHA-related skips +// SKIP: ($DISTANCEALPHA) && ($ENVMAPMASK || $BASEALPHAENVMAPMASK || $SELFILLUM || $SELFILLUM_ENVMAPMASK_ALPHA ) +// SKIP: ($DISTANCEALPHA) && ($SEAMLESS_BASE || $SEAMLESS_DETAIL || $CUBEMAP || $LIGHTING_PREVIEW ) +// SKIP: ($DISTANCEALPHA) && ($WRITEWATERFOGTODESTALPHA || $PIXELFOGTYPE || $FLASHLIGHT || $FLASHLIGHTSHADOWS || $SRGB_INPUT_ADAPTER ) + +// SKIP: $SEAMLESS_BASE && $SRGB_INPUT_ADAPTER +// SKIP: $SEAMLESS_BASE && ($BLENDTINTBYBASEALPHA ) + +// BlendTintByBaseAlpha is incompatible with other interpretations of alpha +// SKIP: ($BLENDTINTBYBASEALPHA) && ($SELFILLUM || (($DISTANCEALPHA) && ($DISTANCEALPHAFROMDETAIL == 0)) || $BASEALPHAENVMAPMASK) + +// Only _XBOX allows flashlight and cubemap in the current implementation +// SKIP: $FLASHLIGHT && $CUBEMAP [PC] + +// SKIP: $CUBEMAP_SPHERE_LEGACY && ($CUBEMAP == 0) + +#include "common_flashlight_fxc.h" +#include "common_vertexlitgeneric_dx9.h" + +const float4 g_EnvmapTint_TintReplaceFactor : register( c0 ); +const float4 g_DiffuseModulation : register( c1 ); +const float4 g_EnvmapContrast_ShadowTweaks : register( c2 ); +const float4 g_EnvmapSaturation_SelfIllumMask : register( c3 ); +const float4 g_SelfIllumTint_and_BlendFactor : register( c4 ); + +const float4 g_ShaderControls : register( c12 ); +const float4 g_DepthFeatheringConstants : register( c13 ); + +const float4 g_EyePos : register( c20 ); +const float4 g_FogParams : register( c21 ); + +#define g_SelfIllumTint g_SelfIllumTint_and_BlendFactor.xyz +#define g_DetailBlendFactor g_SelfIllumTint_and_BlendFactor.w +#define g_EnvmapSaturation g_EnvmapSaturation_SelfIllumMask.xyz +#define g_SelfIllumMaskControl g_EnvmapSaturation_SelfIllumMask.w + +const float4 g_FlashlightAttenuationFactors : register( c22 ); +const HALF3 g_FlashlightPos : register( c23 ); +const float4x4 g_FlashlightWorldToTexture : register( c24 ); // through c27 + + +sampler BaseTextureSampler : register( s0 ); +sampler EnvmapSampler : register( s1 ); +sampler DetailSampler : register( s2 ); +sampler EnvmapMaskSampler : register( s4 ); +sampler RandRotSampler : register( s6 ); // RandomRotation sampler +sampler FlashlightSampler : register( s7 ); +sampler ShadowDepthSampler : register( s8 ); // Flashlight shadow depth map sampler +sampler DepthSampler : register( s10 ); //depth buffer sampler for depth blending +sampler SelfIllumMaskSampler : register( s11 ); // selfillummask + +struct PS_INPUT +{ +#if SEAMLESS_BASE + HALF3 baseTexCoord : TEXCOORD0; // Base texture coordinate +#else + HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate +#endif +#if SEAMLESS_DETAIL + HALF3 detailTexCoord : TEXCOORD1; // Seamless texture coordinate +#else + HALF2 detailTexCoord : TEXCOORD1; // Detail texture coordinate +#endif + float4 color : TEXCOORD2; // Vertex color (from lighting or unlit) + float3 worldVertToEyeVector : TEXCOORD3; // Necessary for reflection + float3 worldSpaceNormal : TEXCOORD4; // Necessary for cubemaps and flashlight + +#if defined ( _X360 ) +#if FLASHLIGHT + float4 flashlightSpacePos : TEXCOORD5; +#endif +#endif + + float4 projPos : TEXCOORD6; + float4 worldPos_projPosZ : TEXCOORD7; + float4 fogFactorW : COLOR1; +#if SEAMLESS_BASE || SEAMLESS_DETAIL + float3 SeamlessWeights : COLOR0; // x y z projection weights +#endif +}; + +const float4 g_GlowParameters : register( c5 ); +const float4 g_GlowColor : register( c6 ); +#define GLOW_UV_OFFSET g_GlowParameters.xy +#define OUTER_GLOW_MIN_DVALUE g_GlowParameters.z +#define OUTER_GLOW_MAX_DVALUE g_GlowParameters.w +#define OUTER_GLOW_COLOR g_GlowColor + +#define g_fPixelFogType g_ShaderControls.x +#define g_fWriteDepthToAlpha g_ShaderControls.y +#define g_fWriteWaterFogToDestAlpha g_ShaderControls.z +#define g_fVertexAlpha g_ShaderControls.w + + +const float4 g_DistanceAlphaParams : register( c7 ); +#define SOFT_MASK_MAX g_DistanceAlphaParams.x +#define SOFT_MASK_MIN g_DistanceAlphaParams.y + +const float4 g_OutlineColor : register( c8 ); +#define OUTLINE_COLOR g_OutlineColor + +const float4 g_OutlineParams : register( c9 ); +// these are ordered this way for optimal ps20 swizzling +#define OUTLINE_MIN_VALUE0 g_OutlineParams.x +#define OUTLINE_MAX_VALUE1 g_OutlineParams.y +#define OUTLINE_MAX_VALUE0 g_OutlineParams.z +#define OUTLINE_MIN_VALUE1 g_OutlineParams.w + +#if DETAILTEXTURE +const float3 g_DetailTint : register( c10 ); +#endif + + +// Calculate unified fog +float CalcPixelFogFactorConst( float fPixelFogType, const float4 fogParams, const float flEyePosZ, const float flWorldPosZ, const float flProjPosZ ) +{ + float flDepthBelowWater = fPixelFogType*fogParams.y - flWorldPosZ; // above water = negative, below water = positive + float flDepthBelowEye = fPixelFogType*flEyePosZ - flWorldPosZ; // above eye = negative, below eye = positive + // if fPixelFogType == 0, then flDepthBelowWater == flDepthBelowEye and frac will be 1 + float frac = (flDepthBelowEye == 0) ? 1 : saturate(flDepthBelowWater/flDepthBelowEye); + return saturate( min(fogParams.z, flProjPosZ * fogParams.w * frac - fogParams.x) ); +} + +// Blend both types of Fog and lerp to get result +float3 BlendPixelFogConst( const float3 vShaderColor, float pixelFogFactor, const float3 vFogColor, float fPixelFogType ) +{ + //float3 fRangeResult = lerp( vShaderColor.rgb, vFogColor.rgb, pixelFogFactor * pixelFogFactor ); //squaring the factor will get the middle range mixing closer to hardware fog + //float3 fHeightResult = lerp( vShaderColor.rgb, vFogColor.rgb, saturate( pixelFogFactor ) ); + //return lerp( fRangeResult, fHeightResult, fPixelFogType ); + pixelFogFactor = lerp( pixelFogFactor*pixelFogFactor, pixelFogFactor, fPixelFogType ); + return lerp( vShaderColor.rgb, vFogColor.rgb, pixelFogFactor ); +} + + +float4 FinalOutputConst( const float4 vShaderColor, float pixelFogFactor, float fPixelFogType, const int iTONEMAP_SCALE_TYPE, float fWriteDepthToDestAlpha, const float flProjZ ) +{ + float4 result = vShaderColor; + if( iTONEMAP_SCALE_TYPE == TONEMAP_SCALE_LINEAR ) + { + result.rgb *= LINEAR_LIGHT_SCALE; + } + else if( iTONEMAP_SCALE_TYPE == TONEMAP_SCALE_GAMMA ) + { + result.rgb *= GAMMA_LIGHT_SCALE; + } + + result.a = lerp( result.a, DepthToDestAlpha( flProjZ ), fWriteDepthToDestAlpha ); + + result.rgb = BlendPixelFogConst( result.rgb, pixelFogFactor, g_LinearFogColor.rgb, fPixelFogType ); + result.rgb = SRGBOutput( result.rgb ); //SRGB in pixel shader conversion + + return result; +} + + +#if LIGHTING_PREVIEW == 2 +LPREVIEW_PS_OUT main( PS_INPUT i ) : COLOR +#else +float4 main( PS_INPUT i ) : COLOR +#endif +{ + bool bDetailTexture = DETAILTEXTURE ? true : false; + bool bCubemap = CUBEMAP ? true : false; + bool bDiffuseLighting = DIFFUSELIGHTING ? true : false; + bool bHasNormal = bCubemap || bDiffuseLighting; + bool bEnvmapMask = ENVMAPMASK ? true : false; + bool bBaseAlphaEnvmapMask = BASEALPHAENVMAPMASK ? true : false; + bool bSelfIllum = SELFILLUM ? true : false; + bool bVertexColor = VERTEXCOLOR ? true : false; + bool bFlashlight = FLASHLIGHT ? true : false; + bool bBlendTintByBaseAlpha = BLENDTINTBYBASEALPHA ? true : false; + + HALF4 baseColor = HALF4( 1.0f, 1.0f, 1.0f, 1.0f ); +#if SEAMLESS_BASE + baseColor = + i.SeamlessWeights.x * tex2D( BaseTextureSampler, i.baseTexCoord.yz )+ + i.SeamlessWeights.y * tex2D( BaseTextureSampler, i.baseTexCoord.zx )+ + i.SeamlessWeights.z * tex2D( BaseTextureSampler, i.baseTexCoord.xy ); +#else + baseColor = tex2D( BaseTextureSampler, i.baseTexCoord.xy ); + +#if SRGB_INPUT_ADAPTER + baseColor.rgb = GammaToLinear( baseColor.rgb ); +#endif + +#endif // !SEAMLESS_BASE + + +#if DISTANCEALPHA && (DISTANCEALPHAFROMDETAIL == 0) + float distAlphaMask = baseColor.a; +#endif + + +#if DETAILTEXTURE +#if SEAMLESS_DETAIL + float4 detailColor = + i.SeamlessWeights.x * tex2D( DetailSampler, i.detailTexCoord.yz )+ + i.SeamlessWeights.y * tex2D( DetailSampler, i.detailTexCoord.zx )+ + i.SeamlessWeights.z * tex2D( DetailSampler, i.detailTexCoord.xy ); +#else + float4 detailColor = tex2D( DetailSampler, i.detailTexCoord.xy ); +#endif + detailColor.rgb *= g_DetailTint; + +#if DISTANCEALPHA && (DISTANCEALPHAFROMDETAIL == 1) + float distAlphaMask = detailColor.a; + detailColor.a = 1.0; // make tcombine treat as 1.0 +#endif + baseColor = + TextureCombine( baseColor, detailColor, DETAIL_BLEND_MODE, g_DetailBlendFactor ); +#endif + +#if DISTANCEALPHA + // now, do all distance alpha effects + //if ( OUTLINE && ( distAlphaMask >= OUTLINE_MIN_VALUE0 ) && ( distAlphaMask <= OUTLINE_MAX_VALUE1 ) ) + //{ + // float oFactor=1.0; + // if ( distAlphaMask <= OUTLINE_MIN_VALUE1 ) + // { + // oFactor=smoothstep( OUTLINE_MIN_VALUE0, OUTLINE_MIN_VALUE1, distAlphaMask ); + // } + // else + // { + // oFactor=smoothstep( OUTLINE_MAX_VALUE1, OUTLINE_MAX_VALUE0, distAlphaMask ); + // } + // baseColor = lerp( baseColor, OUTLINE_COLOR, oFactor ); + //} + if ( OUTLINE ) + { + float4 oFactors = smoothstep(g_OutlineParams.xyzw, g_OutlineParams.wzyx, distAlphaMask ); + baseColor = lerp( baseColor, g_OutlineColor, oFactors.x * oFactors.y ); + } + + float mskUsed; + if ( SOFT_MASK ) + { + mskUsed = smoothstep( SOFT_MASK_MIN, SOFT_MASK_MAX, distAlphaMask ); + baseColor.a *= mskUsed; + } + else + { + mskUsed = distAlphaMask >= 0.5; + if (DETAILTEXTURE ) + baseColor.a *= mskUsed; + else + baseColor.a = mskUsed; + } + + + if ( OUTER_GLOW ) + { +#if DISTANCEALPHAFROMDETAIL + float4 glowTexel = tex2D( DetailSampler, i.detailTexCoord.xy+GLOW_UV_OFFSET ); +#else + float4 glowTexel = tex2D( BaseTextureSampler, i.baseTexCoord.xy+GLOW_UV_OFFSET ); +#endif + float4 glowc = OUTER_GLOW_COLOR*smoothstep( OUTER_GLOW_MIN_DVALUE, OUTER_GLOW_MAX_DVALUE, glowTexel.a ); + baseColor = lerp( glowc, baseColor, mskUsed ); + } + +#endif // DISTANCEALPHA + + float3 specularFactor = 1.0f; + float4 envmapMaskTexel; + if( bEnvmapMask ) + { + envmapMaskTexel = tex2D( EnvmapMaskSampler, i.baseTexCoord.xy ); + specularFactor *= envmapMaskTexel.xyz; + } + + if( bBaseAlphaEnvmapMask ) + { + specularFactor *= 1.0 - baseColor.a; // this blows! + } + + float3 diffuseLighting = float3( 1.0f, 1.0f, 1.0f ); + if( bDiffuseLighting || bVertexColor && !( bVertexColor && bDiffuseLighting ) ) + { + diffuseLighting = i.color.rgb; + } + + float3 albedo = baseColor; + if (bBlendTintByBaseAlpha) + { + float3 tintedColor = albedo * g_DiffuseModulation.rgb; + tintedColor = lerp(tintedColor, g_DiffuseModulation.rgb, g_EnvmapTint_TintReplaceFactor.w); + albedo = lerp(albedo, tintedColor, baseColor.a); + } + else + { + albedo = albedo * g_DiffuseModulation.rgb; + } + + float alpha = g_DiffuseModulation.a; + if ( !bBaseAlphaEnvmapMask && !bSelfIllum && !bBlendTintByBaseAlpha ) + { + alpha *= baseColor.a; + } + + + if( bFlashlight ) + { + int nShadowSampleLevel = 0; + bool bDoShadows = false; +// On ps_2_b, we can do shadow mapping +#if ( FLASHLIGHTSHADOWS && (defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) ) ) + nShadowSampleLevel = FLASHLIGHTDEPTHFILTERMODE; + bDoShadows = true; +#endif + +#if defined ( _X360 ) + float4 flashlightSpacePosition = i.flashlightSpacePos; +#else + float4 flashlightSpacePosition = mul( float4( i.worldPos_projPosZ.xyz, 1.0f ), g_FlashlightWorldToTexture ); +#endif + + // We want the N.L to happen on the flashlight pass, but can't afford it on ps20 + bool bUseWorldNormal = true; +#if ( defined( SHADER_MODEL_PS_2_0 ) && ( DETAILTEXTURE ) ) + bUseWorldNormal = false; +#endif + float3 flashlightColor = DoFlashlight( g_FlashlightPos, i.worldPos_projPosZ.xyz, flashlightSpacePosition, + i.worldSpaceNormal, g_FlashlightAttenuationFactors.xyz, + g_FlashlightAttenuationFactors.w, FlashlightSampler, ShadowDepthSampler, + RandRotSampler, nShadowSampleLevel, bDoShadows, false, i.projPos.xy / i.projPos.w, false, g_EnvmapContrast_ShadowTweaks, bUseWorldNormal ); + +#if defined ( _X360 ) + diffuseLighting += flashlightColor; +#else + diffuseLighting = flashlightColor; +#endif + } + + if( bVertexColor && bDiffuseLighting ) + { + albedo *= i.color.rgb; + } + + alpha = lerp( alpha, alpha * i.color.a, g_fVertexAlpha ); + + float3 diffuseComponent = albedo * diffuseLighting; + +#if DETAILTEXTURE + diffuseComponent = + TextureCombinePostLighting( diffuseComponent, detailColor, DETAIL_BLEND_MODE, g_DetailBlendFactor ); +#endif + + HALF3 specularLighting = HALF3( 0.0f, 0.0f, 0.0f ); + +#if !FLASHLIGHT || defined ( _X360 ) + #if SELFILLUM_ENVMAPMASK_ALPHA + // range of alpha: + // 0 - 0.125 = lerp(diffuse,selfillum,alpha*8) + // 0.125-1.0 = selfillum*(1+alpha-0.125)*8 (over bright glows) + HALF3 selfIllumComponent = g_SelfIllumTint * albedo; + half Adj_Alpha=8*envmapMaskTexel.a; + diffuseComponent=( max( 0, 1-Adj_Alpha ) * diffuseComponent) + Adj_Alpha * selfIllumComponent; + #else + if ( bSelfIllum ) + { + float3 vSelfIllumMask = tex2D( SelfIllumMaskSampler, i.baseTexCoord.xy ); + vSelfIllumMask = lerp( baseColor.aaa, vSelfIllumMask, g_SelfIllumMaskControl ); + diffuseComponent = lerp( diffuseComponent, g_SelfIllumTint * albedo, vSelfIllumMask ); + } + #endif + + if( bCubemap ) + { +#if CUBEMAP_SPHERE_LEGACY + HALF3 reflectVect = normalize(CalcReflectionVectorUnnormalized( i.worldSpaceNormal, i.worldVertToEyeVector.xyz )); + + specularLighting = 0.5 * tex2D( EnvmapSampler, float2(reflectVect.x, reflectVect.y) ) * g_DiffuseModulation.rgb * diffuseLighting; +#else + HALF3 reflectVect = CalcReflectionVectorUnnormalized( i.worldSpaceNormal, i.worldVertToEyeVector.xyz ); + + specularLighting = ENV_MAP_SCALE * texCUBE( EnvmapSampler, reflectVect ); + specularLighting *= specularFactor; + specularLighting *= g_EnvmapTint_TintReplaceFactor.rgb; + HALF3 specularLightingSquared = specularLighting * specularLighting; + specularLighting = lerp( specularLighting, specularLightingSquared, g_EnvmapContrast_ShadowTweaks ); + HALF3 greyScale = dot( specularLighting, HALF3( 0.299f, 0.587f, 0.114f ) ); + specularLighting = lerp( greyScale, specularLighting, g_EnvmapSaturation ); +#endif + } +#endif + + HALF3 result = diffuseComponent + specularLighting; + +#if LIGHTING_PREVIEW +# if LIGHTING_PREVIEW == 1 + float dotprod=0.7+0.25*dot(i.worldSpaceNormal,normalize(float3(1,2,-.5))); + return FinalOutput( float4( dotprod*albedo.xyz, alpha ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_LINEAR ); +# else + LPREVIEW_PS_OUT ret; + ret.flags=float4(1,1,1,1); + ret.color=float4( albedo.xyz, alpha ); + ret.normal=float4(i.worldSpaceNormal,alpha); + ret.position=float4(i.worldPos_projPosZ.xyz, alpha); + return FinalOutput( ret, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE ); +# endif +#else + +# if (DEPTHBLEND == 1) + { + float2 vScreenPos; + vScreenPos.x = i.projPos.x; + vScreenPos.y = -i.projPos.y; + vScreenPos = (vScreenPos + i.projPos.w) * 0.5f; + alpha *= DepthFeathering( DepthSampler, vScreenPos / i.projPos.w, i.projPos.w - i.projPos.z, i.projPos.w, g_DepthFeatheringConstants ); + } +# endif + +#if defined( SHADER_MODEL_PS_2_0 ) + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.xyz, i.worldPos_projPosZ.xyz, i.projPos.z ); + #if (PIXELFOGTYPE == PIXEL_FOG_TYPE_HEIGHT) + alpha = lerp( alpha, fogFactor, g_fWriteWaterFogToDestAlpha ); + #endif + return FinalOutput( float4( result.rgb, alpha ), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, false, i.projPos.z ); +#else // 2b or higher + float fogFactor = CalcPixelFogFactor( g_fPixelFogType, g_FogParams, g_EyePos.xyz, i.worldPos_projPosZ.xyz, i.projPos.z ); + alpha = lerp( alpha, fogFactor, g_fWriteWaterFogToDestAlpha ); // Use the fog factor if it's height fog + return FinalOutputConst( float4( result.rgb, alpha ), fogFactor, g_fPixelFogType, TONEMAP_SCALE_LINEAR, g_fWriteDepthToAlpha, i.projPos.z ); +#endif + +#endif +} + diff --git a/sp/src/materialsystem/stdshaders/SDK_vertexlit_and_unlit_generic_vs20.fxc b/sp/src/materialsystem/stdshaders/SDK_vertexlit_and_unlit_generic_vs20.fxc new file mode 100644 index 00000000..e42d254e --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_vertexlit_and_unlit_generic_vs20.fxc @@ -0,0 +1,250 @@ +//======= Copyright © 1996-2007, Valve Corporation, All rights reserved. ====== + +// STATIC: "VERTEXCOLOR" "0..1" +// STATIC: "CUBEMAP" "0..1" +// STATIC: "HALFLAMBERT" "0..1" +// STATIC: "FLASHLIGHT" "0..1" +// STATIC: "SEAMLESS_BASE" "0..1" +// STATIC: "SEAMLESS_DETAIL" "0..1" +// STATIC: "SEPARATE_DETAIL_UVS" "0..1" +// STATIC: "DECAL" "0..1" [vs30] +// STATIC: "SM30_VERTEXID" "0..1" [vs30] +// STATIC: "USE_STATIC_CONTROL_FLOW" "0..1" [vs20] +// STATIC: "DONT_GAMMA_CONVERT_VERTEX_COLOR" "0..1" +// DYNAMIC: "COMPRESSED_VERTS" "0..1" +// DYNAMIC: "DYNAMIC_LIGHT" "0..1" +// DYNAMIC: "STATIC_LIGHT" "0..1" +// DYNAMIC: "DOWATERFOG" "0..1" +// DYNAMIC: "SKINNING" "0..1" +// DYNAMIC: "LIGHTING_PREVIEW" "0..1" [PC] +// DYNAMIC: "LIGHTING_PREVIEW" "0..0" [XBOX] +// DYNAMIC: "MORPHING" "0..1" [vs30] +// DYNAMIC: "NUM_LIGHTS" "0..2" [vs20] + +// If using static control flow on Direct3D, we should use the NUM_LIGHTS=0 combo +// SKIP: $USE_STATIC_CONTROL_FLOW && ( $NUM_LIGHTS > 0 ) [vs20] +// SKIP: ($SEPARATE_DETAIL_UVS) && ($SEAMLESS_DETAIL) +// SKIP: ($DONT_GAMMA_CONVERT_VERTEX_COLOR && ( ! $VERTEXCOLOR ) ) +#include "common_vs_fxc.h" + +static const bool g_bSkinning = SKINNING ? true : false; +static const int g_FogType = DOWATERFOG; +static const bool g_bVertexColor = VERTEXCOLOR ? true : false; +static const bool g_bCubemap = CUBEMAP ? true : false; +static const bool g_bFlashlight = FLASHLIGHT ? true : false; +static const bool g_bHalfLambert = HALFLAMBERT ? true : false; +#if (defined( SHADER_MODEL_VS_3_0 ) && MORPHING && DECAL && SM30_VERTEXID) +static const bool g_bDecalOffset = true; +#else +static const bool g_bDecalOffset = false; +#endif + +const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 ); +#if SEAMLESS_DETAIL || SEAMLESS_BASE +const float cSeamlessScale : register( SHADER_SPECIFIC_CONST_2); +#define SEAMLESS_SCALE cSeamlessScale.x +#endif + +const float4 cDetailTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_4 ); + +#if defined ( _X360 ) +const float4x4 g_FlashlightWorldToTexture : register( SHADER_SPECIFIC_CONST_6 ); // 6, 7, 8, 9 +#endif + +#if defined( SHADER_MODEL_VS_3_0 ) && SM30_VERTEXID +// NOTE: cMorphTargetTextureDim.xy = target dimensions, +// cMorphTargetTextureDim.z = 4tuples/morph +const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_10 ); +const float4 cMorphSubrect : register( SHADER_SPECIFIC_CONST_11 ); +sampler2D morphSampler : register( D3DVERTEXTEXTURESAMPLER0, s0 ); +#endif + +struct VS_INPUT +{ + // This is all of the stuff that we ever use. + float4 vPos : POSITION; + float4 vBoneWeights : BLENDWEIGHT; + float4 vBoneIndices : BLENDINDICES; + float4 vNormal : NORMAL; + float4 vColor : COLOR0; + float3 vSpecular : COLOR1; + // make these float2's and stick the [n n 0 1] in the dot math. + float4 vTexCoord0 : TEXCOORD0; + float4 vTexCoord1 : TEXCOORD1; + float4 vTexCoord2 : TEXCOORD2; + float4 vTexCoord3 : TEXCOORD3; + + // Position and normal/tangent deltas + float3 vPosFlex : POSITION1; + float3 vNormalFlex : NORMAL1; +#if defined( SHADER_MODEL_VS_3_0 ) && SM30_VERTEXID + float vVertexID : POSITION2; +#endif +}; + + +struct VS_OUTPUT +{ + float4 projPos : POSITION; // Projection-space position +#if !defined( _X360 ) + float fog : FOG; +#endif + +#if SEAMLESS_BASE + HALF3 SeamlessTexCoord : TEXCOORD0; // Base texture x/y/z (indexed by swizzle) +#else + HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate +#endif +#if SEAMLESS_DETAIL + HALF3 SeamlessDetailTexCoord : TEXCOORD1; // Detail texture coordinate +#else + HALF2 detailTexCoord : TEXCOORD1; // Detail texture coordinate +#endif + float4 color : TEXCOORD2; // Vertex color (from lighting or unlit) + +#if 1 //CUBEMAP || _X360 + float3 worldVertToEyeVector : TEXCOORD3; // Necessary for cubemaps +#endif + + float3 worldSpaceNormal : TEXCOORD4; // Necessary for cubemaps and flashlight + +#if defined ( _X360 ) && FLASHLIGHT + float4 flashlightSpacePos : TEXCOORD5; +#endif + + float4 vProjPos : TEXCOORD6; + float4 worldPos_ProjPosZ : TEXCOORD7; + float4 fogFactorW : COLOR1; +#if SEAMLESS_DETAIL || SEAMLESS_BASE + float3 SeamlessWeights : COLOR0; // x y z projection weights +#endif + +}; + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + + bool bDynamicLight = DYNAMIC_LIGHT ? true : false; + bool bStaticLight = STATIC_LIGHT ? true : false; + bool bDoLighting = !g_bVertexColor && (bDynamicLight || bStaticLight); + + float4 vPosition = v.vPos; + float3 vNormal = 0; + if ( bDoLighting || FLASHLIGHT || SEAMLESS_BASE || SEAMLESS_DETAIL || LIGHTING_PREVIEW || g_bDecalOffset || CUBEMAP ) + { + // The vertex only contains valid normals if they are actually needed (fetching them when absent makes D3D complain) + DecompressVertex_Normal( v.vNormal, vNormal ); + } + +#if SEAMLESS_BASE || SEAMLESS_DETAIL + // compute blend weights in rgb + float3 NNormal=normalize( vNormal ); + o.SeamlessWeights.xyz = NNormal * NNormal; // sums to 1. +#endif + +#if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING || !SM30_VERTEXID + ApplyMorph( v.vPosFlex, v.vNormalFlex, vPosition.xyz, vNormal ); +#else + ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, + v.vVertexID, v.vTexCoord2, vPosition.xyz, vNormal ); +#endif + + // Perform skinning + float3 worldNormal, worldPos; + SkinPositionAndNormal( + g_bSkinning, + vPosition, vNormal, + v.vBoneWeights, v.vBoneIndices, + worldPos, worldNormal ); + + if ( !g_bVertexColor ) + { + worldNormal = normalize( worldNormal ); + } + +#if defined( SHADER_MODEL_VS_3_0 ) && MORPHING && DECAL && SM30_VERTEXID + // Avoid z precision errors + worldPos += worldNormal * 0.05f * v.vTexCoord2.z; +#endif + + o.worldSpaceNormal = worldNormal; + + // Transform into projection space + float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj ); + o.projPos = vProjPos; + vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ ); + + o.vProjPos = vProjPos; + o.fogFactorW.w = CalcFog( worldPos, vProjPos, g_FogType ); +#if !defined( _X360 ) + o.fog = o.fogFactorW.w; +#endif + o.worldPos_ProjPosZ.xyz = worldPos.xyz; + o.worldPos_ProjPosZ.w = vProjPos.z; + + // Needed for cubemaps +#if 1 //CUBEMAP + o.worldVertToEyeVector.xyz = VSHADER_VECT_SCALE * (cEyePos - worldPos); +#endif + +#if !defined (_X360) && FLASHLIGHT + o.color = float4( 0.0f, 0.0f, 0.0f, 0.0f ); +#else + if ( g_bVertexColor ) + { + // Assume that this is unlitgeneric if you are using vertex color. + o.color.rgb = ( DONT_GAMMA_CONVERT_VERTEX_COLOR ) ? v.vColor.rgb : GammaToLinear( v.vColor.rgb ); + o.color.a = v.vColor.a; + } + else + { + #if ( ( USE_STATIC_CONTROL_FLOW ) || defined ( SHADER_MODEL_VS_3_0 ) ) + { + o.color.xyz = DoLighting( worldPos, worldNormal, v.vSpecular, bStaticLight, bDynamicLight, g_bHalfLambert ); + } + #else + { + o.color.xyz = DoLightingUnrolled( worldPos, worldNormal, v.vSpecular, bStaticLight, bDynamicLight, g_bHalfLambert, NUM_LIGHTS ); + } + #endif + } +#endif + + +#if SEAMLESS_BASE + o.SeamlessTexCoord.xyz = SEAMLESS_SCALE * v.vPos.xyz; +#else + // Base texture coordinates + o.baseTexCoord.x = dot( v.vTexCoord0, cBaseTexCoordTransform[0] ); + o.baseTexCoord.y = dot( v.vTexCoord0, cBaseTexCoordTransform[1] ); +#endif + +#if SEAMLESS_DETAIL + // FIXME: detail texcoord as a 2d xform doesn't make much sense here, so I just do enough so + // that scale works. More smartness could allow 3d xform. + o.SeamlessDetailTexCoord.xyz = (SEAMLESS_SCALE*cDetailTexCoordTransform[0].x) * v.vPos.xyz; +#else + // Detail texture coordinates + // FIXME: This shouldn't have to be computed all the time. + o.detailTexCoord.x = dot( v.vTexCoord0, cDetailTexCoordTransform[0] ); + o.detailTexCoord.y = dot( v.vTexCoord0, cDetailTexCoordTransform[1] ); +#endif + +#if SEPARATE_DETAIL_UVS + o.detailTexCoord.xy = v.vTexCoord1.xy; +#endif + +#if LIGHTING_PREVIEW + float dot=0.5+0.5*worldNormal*float3(0.7071,0.7071,0); + o.color.xyz=float3(dot,dot,dot); +#endif + +#if defined ( _X360 ) && FLASHLIGHT + o.flashlightSpacePos = mul( float4( worldPos, 1.0f ), g_FlashlightWorldToTexture ); +#endif + + return o; +} + + diff --git a/sp/src/materialsystem/stdshaders/SDK_vertexlit_lighting_only_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_vertexlit_lighting_only_ps2x.fxc new file mode 100644 index 00000000..52812637 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_vertexlit_lighting_only_ps2x.fxc @@ -0,0 +1,68 @@ +//======= Copyright © 1996-2006, Valve Corporation, All rights reserved. ====== + +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] +// STATIC: "DIFFUSELIGHTING" "0..1" +// STATIC: "HALFLAMBERT" "0..1" + +// DYNAMIC: "AMBIENT_LIGHT" "0..1" +// DYNAMIC: "NUM_LIGHTS" "0..2" [ps20] +// DYNAMIC: "NUM_LIGHTS" "0..4" [ps20b] + +#define HDRTYPE HDR_TYPE_NONE +#include "common_vertexlitgeneric_dx9.h" + +const float4 g_OverbrightFactor : register( c4 ); +const float3 cAmbientCube[6] : register( c6 ); + +PixelShaderLightInfo cLightInfo[3] : register(c13); + +sampler BumpmapSampler : register( s0 ); +sampler NormalizeSampler : register( s1 ); + +struct PS_INPUT +{ + float2 baseTexCoord : TEXCOORD0; + // detail textures and bumpmaps are mutually exclusive so that we have enough texcoords. + float2 detailOrBumpTexCoord : TEXCOORD1; + // bump mapping and a separate envmap mask texture are mutually exclusive. + float2 envmapMaskTexCoord : TEXCOORD2; + float3 worldVertToEyeVector : TEXCOORD3; + float3x3 tangentSpaceTranspose : TEXCOORD4; + float4 worldPos_projPosZ : TEXCOORD5; + float2 lightAtten01 : TEXCOORD6; + float2 lightAtten23 : TEXCOORD7; +}; + +float4 main( PS_INPUT i ) : COLOR +{ + bool bDiffuseLighting = DIFFUSELIGHTING ? true : false; + bool bHalfLambert = HALFLAMBERT ? true : false; + bool bAmbientLight = AMBIENT_LIGHT ? true : false; + int nNumLights = NUM_LIGHTS; + + float4 vLightAtten = float4( i.lightAtten01, i.lightAtten23 ); + + float3 tangentSpaceNormal = float3( 0.0f, 0.0f, 1.0f ); + float4 normalTexel = 1.0f; + float4 baseColor = float4( 1.0f, 1.0f, 1.0f, 1.0f ); + + normalTexel = tex2D( BumpmapSampler, i.detailOrBumpTexCoord ); + tangentSpaceNormal = 2.0f * normalTexel - 1.0f; + + float3 diffuseLighting = float3( 1.0f, 1.0f, 1.0f ); + if( bDiffuseLighting ) + { + float3 worldSpaceNormal = mul( i.tangentSpaceTranspose, tangentSpaceNormal ); + float3 staticLightingColor = float3( 0.0f, 0.0f, 0.0f ); + diffuseLighting = PixelShaderDoLighting( i.worldPos_projPosZ.xyz, worldSpaceNormal, + float3( 0.0f, 0.0f, 0.0f ), false, bAmbientLight, + vLightAtten, cAmbientCube, NormalizeSampler, nNumLights, cLightInfo, bHalfLambert, + false, 0, false, NormalizeSampler ); + // multiply by .5 since we want a 50% (in gamma space) reflective surface) + diffuseLighting *= pow( 0.5f, 2.2f ); + } + + return FinalOutput( float4( diffuseLighting, 1.0f ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE ); +} + diff --git a/sp/src/materialsystem/stdshaders/SDK_vertexlitgeneric_lightingonly_overbright2_ps11.fxc b/sp/src/materialsystem/stdshaders/SDK_vertexlitgeneric_lightingonly_overbright2_ps11.fxc new file mode 100644 index 00000000..70ad7094 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_vertexlitgeneric_lightingonly_overbright2_ps11.fxc @@ -0,0 +1,9 @@ +struct PS_INPUT +{ + float3 vColor0 : COLOR0; +}; + +float4 main( PS_INPUT i ) : COLOR +{ + return float4( i.vColor0, 1.0 ); +} diff --git a/sp/src/materialsystem/stdshaders/SDK_water_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_water_ps2x.fxc new file mode 100644 index 00000000..adc42f36 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_water_ps2x.fxc @@ -0,0 +1,113 @@ +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b] [= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] +// STATIC: "BASETEXTURE" "0..1" +// STATIC: "MULTITEXTURE" "0..1" +// STATIC: "REFLECT" "0..1" +// STATIC: "REFRACT" "0..1" +// STATIC: "ABOVEWATER" "0..1" +// STATIC: "BLURRY_REFRACT" "0..1" [ps20b] + +// When we turn NORMAL_DECODE_MODE on, this shader only needs 0..1, not 0..2 +// STATIC: "NORMAL_DECODE_MODE" "0..0" [XBOX] +// STATIC: "NORMAL_DECODE_MODE" "0..0" [PC] + +// DYNAMIC: "PIXELFOGTYPE" "0..1" +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX] + +// SKIP: $MULTITEXTURE && $BASETEXTURE + +#if defined(SHADER_MODEL_PS_2_0) +# define BLURRY_REFRACT 0 +# define WRITE_DEPTH_TO_DESTALPHA 0 +#endif + +#include "water_ps2x_helper.h" + + +sampler RefractSampler : register( s0 ); +#if BASETEXTURE +sampler BaseTextureSampler : register( s1 ); +#endif +sampler ReflectSampler : register( s2 ); +#if BASETEXTURE +sampler LightmapSampler : register( s3 ); +#endif +sampler NormalSampler : register( s4 ); + +const HALF4 vRefractTint : register( c1 ); +const HALF4 vReflectTint : register( c4 ); +const float4 g_ReflectRefractScale : register( c5 ); // xy - reflect scale, zw - refract scale +const HALF4 g_WaterFogColor : register( c6 ); +const HALF4 g_WaterFogParams : register( c7 ); + +const float4 g_PixelFogParams : register( c8 ); + +const float3 g_EyePos : register( c9 ); + +#define g_WaterFogStart g_WaterFogParams.x +#define g_WaterFogEndMinusStart g_WaterFogParams.y +#define g_Reflect_OverBright g_WaterFogParams.z + +struct PS_INPUT +{ + float2 vBumpTexCoord : TEXCOORD0; + half3 vTangentEyeVect : TEXCOORD1; + float4 vReflectXY_vRefractYX : TEXCOORD2; + float4 vWorldPos_projPosW : TEXCOORD3; + float4 vProjPos : TEXCOORD4; + float screenCoord : TEXCOORD5; +#if MULTITEXTURE + float4 vExtraBumpTexCoord : TEXCOORD6; +#endif +#if BASETEXTURE +// CENTROID: TEXCOORD6 + HALF4 lightmapTexCoord1And2 : TEXCOORD6; +// CENTROID: TEXCOORD7 + HALF4 lightmapTexCoord3 : TEXCOORD7; +#endif + + float4 fogFactorW : COLOR1; +}; + +float4 main( PS_INPUT i ) : COLOR +{ + DrawWater_params_t params; + + params.vBumpTexCoord = i.vBumpTexCoord; +#if MULTITEXTURE + params.vExtraBumpTexCoord = i.vExtraBumpTexCoord; +#endif + params.vReflectXY_vRefractYX = i.vReflectXY_vRefractYX; + params.w = i.vWorldPos_projPosW.w; + params.vReflectRefractScale = g_ReflectRefractScale; + params.fReflectOverbright = g_Reflect_OverBright; + params.vReflectTint = vReflectTint; + params.vRefractTint = vRefractTint; + params.vTangentEyeVect = i.vTangentEyeVect; + params.waterFogColor = g_WaterFogColor; +#if BASETEXTURE + params.lightmapTexCoord1And2 = i.lightmapTexCoord1And2; + params.lightmapTexCoord3 = i.lightmapTexCoord3; +#endif + params.vProjPos = i.vProjPos; + params.pixelFogParams = g_PixelFogParams; + params.fWaterFogStart = g_WaterFogStart; + params.fWaterFogEndMinusStart = g_WaterFogEndMinusStart; + params.vEyePos = g_EyePos; + params.vWorldPos = i.vWorldPos_projPosW.xyz; + + float4 result; + float fogFactor; + DrawWater( params, + // yay. . can't put sampler in a struct. +#if BASETEXTURE + BaseTextureSampler, + LightmapSampler, +#endif + NormalSampler, RefractSampler, ReflectSampler, + result, fogFactor ); + + return FinalOutput( float4( result.rgb, 1.0f ), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_NONE, (WRITE_DEPTH_TO_DESTALPHA != 0), i.vProjPos.z ); +} + diff --git a/sp/src/materialsystem/stdshaders/SDK_worldtwotextureblend_ps2x.fxc b/sp/src/materialsystem/stdshaders/SDK_worldtwotextureblend_ps2x.fxc new file mode 100644 index 00000000..6da0b286 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/SDK_worldtwotextureblend_ps2x.fxc @@ -0,0 +1,217 @@ +//====== Copyright © 1996-2007, Valve Corporation, All rights reserved. =======// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// +// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] +// STATIC: "DETAILTEXTURE" "0..1" +// STATIC: "BUMPMAP" "0..1" +// STATIC: "VERTEXCOLOR" "0..1" +// STATIC: "SELFILLUM" "0..1" +// STATIC: "DIFFUSEBUMPMAP" "0..1" +// STATIC: "DETAIL_ALPHA_MASK_BASE_TEXTURE" "0..1" +// STATIC: "FLASHLIGHT" "0..1" +// STATIC: "SEAMLESS" "0..1" +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps20b] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..0" [ps20b] [XBOX] + +// DYNAMIC: "WRITEWATERFOGTODESTALPHA" "0..1" +// DYNAMIC: "PIXELFOGTYPE" "0..1" +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX] +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps20b] + +// SKIP: $DETAILTEXTURE && ( $BUMPMAP && !$DETAIL_ALPHA_MASK_BASE_TEXTURE ) +// SKIP: !$BUMPMAP && $DIFFUSEBUMPMAP +// SKIP: $VERTEXCOLOR && $BUMPMAP +// SKIP: FLASHLIGHT && $SELFILLUM +// SKIP: FLASHLIGHT && $DETAIL_ALPHA_MASK_BASE_TEXTURE +// SKIP: FLASHLIGHT && ($BUMPMAP || $DIFFUSEBUMPMAP) + +// We don't care about flashlight depth unless the flashlight is on +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps20b] + +#if defined( SHADER_MODEL_PS_2_0 ) +# define WRITE_DEPTH_TO_DESTALPHA 0 +#endif + + +#define HDRTYPE HDR_TYPE_NONE +#include "common_flashlight_fxc.h" +#include "common_ps_fxc.h" + +const HALF4 g_SelfIllumTint : register( c7 ); +static const HALF g_OverbrightFactor = 2.0f; + +const HALF3 g_EyePos : register( c10 ); +const HALF4 g_FogParams : register( c11 ); + +const HALF3 g_FlashlightPos : register( c15 ); +// flashlightfixme: Move this math into the vertex shader. +const float4x4 g_FlashlightWorldToTexture : register( c16 ); + +const float4 g_FlashlightAttenuationFactors : register( c20 ); + +sampler BaseTextureSampler : register( s0 ); +sampler LightmapSampler : register( s1 ); +sampler FlashlightSampler : register( s2 ); +sampler DetailSampler : register( s3 ); +sampler BumpmapSampler : register( s4 ); +sampler NormalizeSampler : register( s6 ); + +struct PS_INPUT +{ + HALF2 baseTexCoord : TEXCOORD0; + HALF4 detailOrBumpTexCoord : TEXCOORD1; + HALF4 lightmapTexCoord1And2 : TEXCOORD2; // CENTROID: TEXCOORD2 + HALF2 lightmapTexCoord3 : TEXCOORD3; // CENTROID: TEXCOORD3 + HALF4 worldPos_projPosZ : TEXCOORD4; + HALF3x3 tangentSpaceTranspose : TEXCOORD5; + // tangentSpaceTranspose : TEXCOORD6; + // tangentSpaceTranspose : TEXCOORD7; + HALF4 vertexColor : COLOR; +}; + + +float4 main( PS_INPUT i ) : COLOR +{ + bool bDetailTexture = DETAILTEXTURE ? true : false; + bool bBumpmap = BUMPMAP ? true : false; + bool bDiffuseBumpmap = DIFFUSEBUMPMAP ? true : false; + bool bVertexColor = VERTEXCOLOR ? true : false; + bool bSelfIllum = SELFILLUM ? true : false; + bool bDetailAlphaMaskBaseTexture = DETAIL_ALPHA_MASK_BASE_TEXTURE ? true : false; + bool bFlashlight = FLASHLIGHT ? true : false; + + HALF3 lightmapColor1 = HALF3( 1.0f, 1.0f, 1.0f ); + HALF3 lightmapColor2 = HALF3( 1.0f, 1.0f, 1.0f ); + HALF3 lightmapColor3 = HALF3( 1.0f, 1.0f, 1.0f ); + if( bBumpmap && bDiffuseBumpmap ) + { + HALF2 bumpCoord1; + HALF2 bumpCoord2; + HALF2 bumpCoord3; + ComputeBumpedLightmapCoordinates( i.lightmapTexCoord1And2, i.lightmapTexCoord3.xy, + bumpCoord1, bumpCoord2, bumpCoord3 ); + + HALF4 lightmapSample1 = tex2D( LightmapSampler, bumpCoord1 ); + lightmapColor1 = lightmapSample1.rgb; + lightmapColor2 = tex2D( LightmapSampler, bumpCoord2 ); + lightmapColor3 = tex2D( LightmapSampler, bumpCoord3 ); + } + else + { + if( !bFlashlight ) + { + HALF2 bumpCoord1 = ComputeLightmapCoordinates( i.lightmapTexCoord1And2, i.lightmapTexCoord3.xy ); + HALF4 lightmapSample1 = tex2D( LightmapSampler, bumpCoord1 ); + lightmapColor1 = lightmapSample1.rgb; + } + } + + HALF4 detailColor = HALF4( 1.0f, 1.0f, 1.0f, 1.0f ); + if( bDetailTexture ) + { + detailColor = tex2D( DetailSampler, i.detailOrBumpTexCoord.xy ); + } + + HALF4 baseColor = HALF4( 1.0f, 1.0f, 1.0f, 1.0f ); + baseColor = tex2D( BaseTextureSampler, i.baseTexCoord ); + if ( bDetailAlphaMaskBaseTexture ) + { + // This is what WorldTwoTextureBlend_DX6 does. + baseColor.rgb = saturate( saturate( baseColor * 2 ) * detailColor.a + (1 - detailColor.a) ); + baseColor.rgb *= detailColor; + } + else + { + baseColor.rgb = lerp( baseColor, detailColor, detailColor.a ); + } + + HALF3 normal = HALF3( 0.0f, 0.0f, 1.0f ); + if( bBumpmap ) + { + HALF3 normalTexel; + normalTexel = tex2D( BumpmapSampler, i.detailOrBumpTexCoord.xy ); + normal = 2.0 * normalTexel - 1.0; + } + + HALF3 albedo = HALF3( 1.0f, 1.0f, 1.0f ); + HALF alpha = 1.0f; + albedo *= baseColor; + if( !bSelfIllum ) + { + alpha *= baseColor.a; + } + + // The vertex color contains the modulation color + vertex color combined + albedo *= i.vertexColor; + alpha *= i.vertexColor.a; // not sure about this one + + HALF3 diffuseLighting; + if( bFlashlight ) + { + float3 worldSpaceNormal; + // Make the unbumped version not so fucking stupid and not need tangentSpaceTranspose you knob. + worldSpaceNormal = mul( normal, i.tangentSpaceTranspose ); + + int nShadowSampleLevel = 0; + bool bDoShadows = false; +// On ps_2_b, we can do shadow mapping +#if ( FLASHLIGHTSHADOWS && (defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) ) ) + nShadowSampleLevel = FLASHLIGHTDEPTHFILTERMODE; + bDoShadows = true; +#endif + float4 flashlightSpacePosition = mul( float4( i.worldPos_projPosZ.xyz, 1.0f ), g_FlashlightWorldToTexture ); + + diffuseLighting = DoFlashlight( g_FlashlightPos, i.worldPos_projPosZ.xyz, flashlightSpacePosition, + worldSpaceNormal, g_FlashlightAttenuationFactors.xyz, + g_FlashlightAttenuationFactors.w, FlashlightSampler, FlashlightSampler, NormalizeSampler, + nShadowSampleLevel, bDoShadows, false, float2(0, 0), false ); + } + else + { + if( bBumpmap && bDiffuseBumpmap ) + { + float dot1 = saturate( dot( normal, bumpBasis[0] ) ); + float dot2 = saturate( dot( normal, bumpBasis[1] ) ); + float dot3 = saturate( dot( normal, bumpBasis[2] ) ); + + float sum = dot1 + dot2 + dot3; + diffuseLighting = dot1 * lightmapColor1 + + dot2 * lightmapColor2 + + dot3 * lightmapColor3; + diffuseLighting *= 1.0f / sum; + } + else + { + diffuseLighting = lightmapColor1; + } + + // Only scale here since the flashlight will already be scaled properly + diffuseLighting *= g_OverbrightFactor; + } + + HALF3 diffuseComponent = albedo * diffuseLighting; + + if( bSelfIllum ) + { + HALF3 selfIllumComponent = g_SelfIllumTint * albedo; + diffuseComponent = lerp( diffuseComponent, selfIllumComponent, baseColor.a ); + } + + HALF3 specularLighting = HALF3( 0.0f, 0.0f, 0.0f ); + HALF3 result = diffuseComponent + specularLighting; + + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); + +#if WRITEWATERFOGTODESTALPHA && (PIXELFOGTYPE == PIXEL_FOG_TYPE_HEIGHT) + alpha = fogFactor; +#endif + + return FinalOutput( float4( result, alpha ), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, (WRITE_DEPTH_TO_DESTALPHA != 0), i.worldPos_projPosZ.w ); +} + diff --git a/sp/src/materialsystem/stdshaders/buildepisodicshaders.bat b/sp/src/materialsystem/stdshaders/buildepisodicshaders.bat index 3df0b345..87a1afac 100755 --- a/sp/src/materialsystem/stdshaders/buildepisodicshaders.bat +++ b/sp/src/materialsystem/stdshaders/buildepisodicshaders.bat @@ -8,7 +8,7 @@ rem == Set the absolute path to your mod's game directory here == set GAMEDIR=%cd%\..\..\..\game\mod_episodic rem == Set the relative or absolute path to Source SDK Base 2013 Singleplayer\bin == -set SDKBINDIR=D:\SteamBeta\SteamApps\common\Source SDK Base 2013 Singleplayer\bin +set SDKBINDIR=C:\Program Files (x86)\Steam\SteamApps\common\Source SDK Base 2013 Singleplayer\bin rem == Set the Path to your mod's root source code == rem This should already be correct, accepts relative paths only! @@ -19,3 +19,6 @@ rem ==================================== call buildsdkshaders.bat + +@echo Finished building shaders +@pause diff --git a/sp/src/materialsystem/stdshaders/buildhl2shaders.bat b/sp/src/materialsystem/stdshaders/buildhl2shaders.bat index 797e906a..4ba77e45 100755 --- a/sp/src/materialsystem/stdshaders/buildhl2shaders.bat +++ b/sp/src/materialsystem/stdshaders/buildhl2shaders.bat @@ -8,7 +8,7 @@ rem == Set the absolute path to your mod's game directory here == set GAMEDIR=%cd%\..\..\..\game\mod_hl2 rem == Set the relative or absolute path to Source SDK Base 2013 Singleplayer\bin == -set SDKBINDIR=D:\SteamBeta\SteamApps\common\Source SDK Base 2013 Singleplayer\bin +set SDKBINDIR=C:\Program Files (x86)\Steam\SteamApps\common\Source SDK Base 2013 Singleplayer\bin rem == Set the Path to your mod's root source code == rem This should already be correct, accepts relative paths only! @@ -19,3 +19,6 @@ rem ==================================== call buildsdkshaders.bat + +@echo Finished building shaders +@pause diff --git a/sp/src/materialsystem/stdshaders/buildsdkshaders.bat b/sp/src/materialsystem/stdshaders/buildsdkshaders.bat index 22624938..6e287de3 100755 --- a/sp/src/materialsystem/stdshaders/buildsdkshaders.bat +++ b/sp/src/materialsystem/stdshaders/buildsdkshaders.bat @@ -4,7 +4,7 @@ setlocal rem Use dynamic shaders to build .inc files only rem set dynamic_shaders=1 rem == Setup path to nmake.exe, from vc 2005 common tools directory == -call "%VS100COMNTOOLS%vsvars32.bat" +call "%VS120COMNTOOLS%vsvars32.bat" set TTEXE=..\..\devtools\bin\timeprecise.exe diff --git a/sp/src/materialsystem/stdshaders/buildshaders.bat b/sp/src/materialsystem/stdshaders/buildshaders.bat index ad9b1852..cb2cb390 100755 --- a/sp/src/materialsystem/stdshaders/buildshaders.bat +++ b/sp/src/materialsystem/stdshaders/buildshaders.bat @@ -71,7 +71,7 @@ REM **************** :set_mod_args if not exist "%SDKBINDIR%\shadercompile.exe" goto NoShaderCompile -set ChangeToDir=%SDKBINDIR% +set ChangeToDir="%SDKBINDIR%" if /i "%4" NEQ "-source" goto NoSourceDirSpecified set SrcDirBase=%~5 diff --git a/sp/src/materialsystem/stdshaders/cable_dx9.cpp b/sp/src/materialsystem/stdshaders/cable_dx9.cpp index 5b25ed61..e1a7635e 100644 --- a/sp/src/materialsystem/stdshaders/cable_dx9.cpp +++ b/sp/src/materialsystem/stdshaders/cable_dx9.cpp @@ -8,9 +8,9 @@ #include "BaseVSShader.h" -#include "cable_vs20.inc" -#include "cable_ps20.inc" -#include "cable_ps20b.inc" +#include "sdk_cable_vs20.inc" +#include "sdk_cable_ps20.inc" +#include "sdk_cable_ps20b.inc" #include "cpp_shader_constant_register_map.h" // memdbgon must be the last include file in a .cpp file!!! @@ -18,10 +18,10 @@ extern ConVar mat_fullbright; -DEFINE_FALLBACK_SHADER( Cable, Cable_DX9 ) +DEFINE_FALLBACK_SHADER( SDK_Cable, SDK_Cable_DX9 ) -BEGIN_VS_SHADER( Cable_DX9, - "Help for Cable shader" ) +BEGIN_VS_SHADER( SDK_Cable_DX9, + "Help for SDK_Cable shader" ) BEGIN_SHADER_PARAMS SHADER_PARAM( BUMPMAP, SHADER_PARAM_TYPE_TEXTURE, "cable/cablenormalmap", "bumpmap texture" ) SHADER_PARAM( MINLIGHT, SHADER_PARAM_TYPE_FLOAT, "0.1", "Minimum amount of light (0-1 value)" ) @@ -73,18 +73,18 @@ BEGIN_VS_SHADER( Cable_DX9, VERTEX_POSITION | VERTEX_COLOR | VERTEX_TANGENT_S | VERTEX_TANGENT_T, 2, tCoordDimensions, 0 ); - DECLARE_STATIC_VERTEX_SHADER( cable_vs20 ); - SET_STATIC_VERTEX_SHADER( cable_vs20 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_cable_vs20 ); + SET_STATIC_VERTEX_SHADER( sdk_cable_vs20 ); if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_STATIC_PIXEL_SHADER( cable_ps20b ); - SET_STATIC_PIXEL_SHADER( cable_ps20b ); + DECLARE_STATIC_PIXEL_SHADER( sdk_cable_ps20b ); + SET_STATIC_PIXEL_SHADER( sdk_cable_ps20b ); } else { - DECLARE_STATIC_PIXEL_SHADER( cable_ps20 ); - SET_STATIC_PIXEL_SHADER( cable_ps20 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_cable_ps20 ); + SET_STATIC_PIXEL_SHADER( sdk_cable_ps20 ); } // we are writing linear values from this shader. @@ -118,22 +118,22 @@ BEGIN_VS_SHADER( Cable_DX9, vEyePos_SpecExponent[3] = 0.0f; pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, vEyePos_SpecExponent, 1 ); - DECLARE_DYNAMIC_VERTEX_SHADER( cable_vs20 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_cable_vs20 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); - SET_DYNAMIC_VERTEX_SHADER( cable_vs20 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_cable_vs20 ); if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_DYNAMIC_PIXEL_SHADER( cable_ps20b ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_cable_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, bFullyOpaque && pShaderAPI->ShouldWriteDepthToDestAlpha() ); - SET_DYNAMIC_PIXEL_SHADER( cable_ps20b ); + SET_DYNAMIC_PIXEL_SHADER( sdk_cable_ps20b ); } else { - DECLARE_DYNAMIC_PIXEL_SHADER( cable_ps20 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_cable_ps20 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - SET_DYNAMIC_PIXEL_SHADER( cable_ps20 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_cable_ps20 ); } } Draw(); diff --git a/sp/src/materialsystem/stdshaders/cloak_blended_pass_helper.cpp b/sp/src/materialsystem/stdshaders/cloak_blended_pass_helper.cpp new file mode 100644 index 00000000..7e494d6a --- /dev/null +++ b/sp/src/materialsystem/stdshaders/cloak_blended_pass_helper.cpp @@ -0,0 +1,358 @@ +//========= Copyright � 1996-2006, Valve Corporation, All rights reserved. ============// + +/* Example how to plug this into an existing shader: + + In the VMT: + // Cloak Pass + "$cloakPassEnabled" "1" + + #include "cloak_blended_pass_helper.h" + + In BEGIN_SHADER_PARAMS: + // Cloak Pass + SHADER_PARAM( CLOAKPASSENABLED, SHADER_PARAM_TYPE_BOOL, "0", "Enables cloak render in a second pass" ) + SHADER_PARAM( CLOAKFACTOR, SHADER_PARAM_TYPE_FLOAT, "0.0", "" ) + SHADER_PARAM( CLOAKCOLORTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "Cloak color tint" ) + SHADER_PARAM( REFRACTAMOUNT, SHADER_PARAM_TYPE_FLOAT, "2", "" ) + + // This should already exist + //SHADER_PARAM( BUMPMAP, SHADER_PARAM_TYPE_TEXTURE, "models/shadertest/shader1_normal", "bump map" ) + //SHADER_PARAM( BUMPFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for $bumpmap" ) + //SHADER_PARAM( BUMPTRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "$bumpmap texcoord transform" ) + + Add this above SHADER_INIT_PARAMS() + // Cloak Pass + void SetupVarsCloakBlendedPass( CloakBlendedPassVars_t &info ) + { + info.m_nCloakFactor = CLOAKFACTOR; + info.m_nCloakColorTint = CLOAKCOLORTINT; + info.m_nRefractAmount = REFRACTAMOUNT; + + // Delete these lines if not bump mapping! + info.m_nBumpmap = BUMPMAP; + info.m_nBumpFrame = BUMPFRAME; + info.m_nBumpTransform = BUMPTRANSFORM; + } + + bool NeedsPowerOfTwoFrameBufferTexture( IMaterialVar **params, bool bCheckSpecificToThisFrame ) const + { + if ( params[CLOAKPASSENABLED]->GetIntValue() ) // If material supports cloaking + { + if ( bCheckSpecificToThisFrame == false ) // For setting model flag at load time + return true; + else if ( ( params[CLOAKFACTOR]->GetFloatValue() > 0.0f ) && ( params[CLOAKFACTOR]->GetFloatValue() < 1.0f ) ) // Per-frame check + return true; + // else, not cloaking this frame, so check flag2 in case the base material still needs it + } + + // Check flag2 if not drawing cloak pass + return IS_FLAG2_SET( MATERIAL_VAR2_NEEDS_POWER_OF_TWO_FRAME_BUFFER_TEXTURE ); + } + + bool IsTranslucent( IMaterialVar **params ) const + { + if ( params[CLOAKPASSENABLED]->GetIntValue() ) // If material supports cloaking + { + if ( ( params[CLOAKFACTOR]->GetFloatValue() > 0.0f ) && ( params[CLOAKFACTOR]->GetFloatValue() < 1.0f ) ) // Per-frame check + return true; + // else, not cloaking this frame, so check flag in case the base material still needs it + } + + // Check flag if not drawing cloak pass + return IS_FLAG_SET( MATERIAL_VAR_TRANSLUCENT ); + } + + In SHADER_INIT_PARAMS() + // Cloak Pass + if ( !params[CLOAKPASSENABLED]->IsDefined() ) + { + params[CLOAKPASSENABLED]->SetIntValue( 0 ); + } + else if ( params[CLOAKPASSENABLED]->GetIntValue() ) + { + CloakBlendedPassVars_t info; + SetupVarsCloakBlendedPass( info ); + InitParamsCloakBlendedPass( this, params, pMaterialName, info ); + } + + In SHADER_INIT + // Cloak Pass + if ( params[CLOAKPASSENABLED]->GetIntValue() ) + { + CloakBlendedPassVars_t info; + SetupVarsCloakBlendedPass( info ); + InitCloakBlendedPass( this, params, info ); + } + + Modify SHADER_DRAW to look something like this: + // Skip the standard rendering if cloak pass is fully opaque + bool bDrawStandardPass = true; + if ( params[CLOAKPASSENABLED]->GetIntValue() && ( pShaderShadow == NULL ) ) // && not snapshotting + { + CloakBlendedPassVars_t info; + SetupVarsCloakBlendedPass( info ); + if ( CloakBlendedPassIsFullyOpaque( params, info ) ) + { + bDrawStandardPass = false; + } + } + + // Standard rendering pass + if ( bDrawStandardPass ) + { + Eye_Refract_Vars_t info; + SetupVarsEyeRefract( info ); + Draw_Eyes_Refract( this, params, pShaderAPI, pShaderShadow, info ); + } + else + { + // Skip this pass! + Draw( false ); + } + + // Cloak Pass + if ( params[CLOAKPASSENABLED]->GetIntValue() ) + { + // If ( snapshotting ) or ( we need to draw this frame ) + if ( ( pShaderShadow != NULL ) || ( ( params[CLOAKFACTOR]->GetFloatValue() > 0.0f ) && ( params[CLOAKFACTOR]->GetFloatValue() < 1.0f ) ) ) + { + CloakBlendedPassVars_t info; + SetupVarsCloakBlendedPass( info ); + DrawCloakBlendedPass( this, params, pShaderAPI, pShaderShadow, info ); + } + else // We're not snapshotting and we don't need to draw this frame + { + // Skip this pass! + Draw( false ); + } + } + +==================================================================================================== */ + +#include "BaseVSShader.h" +#include "mathlib/VMatrix.h" +#include "cloak_blended_pass_helper.h" +#include "convar.h" + +// Auto generated inc files +#include "SDK_cloak_blended_pass_vs20.inc" +#include "SDK_cloak_blended_pass_ps20.inc" +#include "SDK_cloak_blended_pass_ps20b.inc" + +#ifndef _X360 +#include "SDK_cloak_blended_pass_vs30.inc" +#include "SDK_cloak_blended_pass_ps30.inc" +#endif + +void InitParamsCloakBlendedPass( CBaseVSShader *pShader, IMaterialVar** params, const char *pMaterialName, CloakBlendedPassVars_t &info ) +{ + // Set material flags + SET_FLAGS2( MATERIAL_VAR2_SUPPORTS_HW_SKINNING ); + SET_FLAGS( MATERIAL_VAR_MODEL ); + SET_FLAGS2( MATERIAL_VAR2_NEEDS_TANGENT_SPACES ); + + // Set material parameter default values + if ( ( info.m_nCloakFactor != -1 ) && ( !params[info.m_nCloakFactor]->IsDefined() ) ) + { + params[info.m_nCloakFactor]->SetFloatValue( kDefaultCloakFactor ); + } + + if ( ( info.m_nRefractAmount != -1 ) && ( !params[info.m_nRefractAmount]->IsDefined() ) ) + { + params[info.m_nRefractAmount]->SetFloatValue( kDefaultRefractAmount ); + } + + if ( ( info.m_nCloakColorTint != -1 ) && ( !params[info.m_nCloakColorTint]->IsDefined() ) ) + { + params[info.m_nCloakColorTint]->SetVecValue( kDefaultCloakColorTint[0], kDefaultCloakColorTint[1], kDefaultCloakColorTint[2], kDefaultCloakColorTint[3] ); + } + + if( (info.m_nBumpFrame != -1 ) && !params[info.m_nBumpFrame]->IsDefined() ) + { + params[info.m_nBumpFrame]->SetIntValue( 0 ); + } +} + +void InitCloakBlendedPass( CBaseVSShader *pShader, IMaterialVar** params, CloakBlendedPassVars_t &info ) +{ + // Load textures + if ( g_pConfig->UseBumpmapping() ) + { + if ( (info.m_nBumpmap != -1) && params[info.m_nBumpmap]->IsDefined() ) + { + pShader->LoadTexture( info.m_nBumpmap ); + } + } +} + +void DrawCloakBlendedPass( CBaseVSShader *pShader, IMaterialVar** params, IShaderDynamicAPI *pShaderAPI, + IShaderShadow* pShaderShadow, CloakBlendedPassVars_t &info, VertexCompressionType_t vertexCompression ) +{ + bool bBumpMapping = ( !g_pConfig->UseBumpmapping() ) || ( info.m_nBumpmap == -1 ) || !params[info.m_nBumpmap]->IsTexture() ? 0 : 1; + + SHADOW_STATE + { + // Reset shadow state manually since we're drawing from two materials + pShader->SetInitialShadowState( ); + + // Set stream format (note that this shader supports compression) + unsigned int flags = VERTEX_POSITION | VERTEX_NORMAL | VERTEX_FORMAT_COMPRESSED; + int nTexCoordCount = 1; + int userDataSize = 0; + pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, NULL, userDataSize ); + +#ifndef _X360 + if ( !g_pHardwareConfig->HasFastVertexTextures() ) +#endif + { + // Vertex Shader + DECLARE_STATIC_VERTEX_SHADER( sdk_cloak_blended_pass_vs20 ); + SET_STATIC_VERTEX_SHADER_COMBO( BUMPMAP, bBumpMapping ? 1 : 0 ); + SET_STATIC_VERTEX_SHADER( sdk_cloak_blended_pass_vs20 ); + + // Pixel Shader + if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + DECLARE_STATIC_PIXEL_SHADER( sdk_cloak_blended_pass_ps20b ); + SET_STATIC_PIXEL_SHADER_COMBO( BUMPMAP, bBumpMapping ? 1 : 0 ); + SET_STATIC_PIXEL_SHADER( sdk_cloak_blended_pass_ps20b ); + } + else + { + DECLARE_STATIC_PIXEL_SHADER( sdk_cloak_blended_pass_ps20 ); + SET_STATIC_PIXEL_SHADER_COMBO( BUMPMAP, bBumpMapping ? 1 : 0 ); + SET_STATIC_PIXEL_SHADER( sdk_cloak_blended_pass_ps20 ); + } + } +#ifndef _X360 + else + { + // The vertex shader uses the vertex id stream + SET_FLAGS2( MATERIAL_VAR2_USES_VERTEXID ); + + // Vertex Shader + DECLARE_STATIC_VERTEX_SHADER( sdk_cloak_blended_pass_vs30 ); + SET_STATIC_VERTEX_SHADER_COMBO( BUMPMAP, bBumpMapping ? 1 : 0 ); + SET_STATIC_VERTEX_SHADER( sdk_cloak_blended_pass_vs30 ); + + // Pixel Shader + DECLARE_STATIC_PIXEL_SHADER( sdk_cloak_blended_pass_ps30 ); + SET_STATIC_PIXEL_SHADER_COMBO( BUMPMAP, bBumpMapping ? 1 : 0 ); + SET_STATIC_PIXEL_SHADER( sdk_cloak_blended_pass_ps30 ); + } +#endif + + // Textures + pShaderShadow->EnableTexture( SHADER_SAMPLER0, true ); // Refraction texture + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, true ); + if ( bBumpMapping ) + { + pShaderShadow->EnableTexture( SHADER_SAMPLER1, true ); // Bump + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, false ); // Not sRGB + } + pShaderShadow->EnableSRGBWrite( true ); + + // Blending + pShader->EnableAlphaBlending( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE_MINUS_SRC_ALPHA ); + pShaderShadow->EnableAlphaWrites( false ); + + // !!! We need to turn this back on because EnableAlphaBlending() above disables it! + pShaderShadow->EnableDepthWrites( true ); + } + DYNAMIC_STATE + { + // Reset render state manually since we're drawing from two materials + pShaderAPI->SetDefaultState(); + + // Set Vertex Shader Constants + if ( ( bBumpMapping ) && ( info.m_nBumpTransform != -1 ) ) + { + pShader->SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, info.m_nBumpTransform ); + } + +#ifndef _X360 + if ( !g_pHardwareConfig->HasFastVertexTextures() ) +#endif + { + // Set Vertex Shader Combos + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_cloak_blended_pass_vs20 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); + SET_DYNAMIC_VERTEX_SHADER( sdk_cloak_blended_pass_vs20 ); + + // Set Pixel Shader Combos + if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_cloak_blended_pass_ps20b ); + SET_DYNAMIC_PIXEL_SHADER( sdk_cloak_blended_pass_ps20b ); + } + else + { + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_cloak_blended_pass_ps20 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_cloak_blended_pass_ps20 ); + } + } +#ifndef _X360 + else + { + pShader->SetHWMorphVertexShaderState( VERTEX_SHADER_SHADER_SPECIFIC_CONST_6, VERTEX_SHADER_SHADER_SPECIFIC_CONST_7, SHADER_VERTEXTEXTURE_SAMPLER0 ); + + // Set Vertex Shader Combos + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_cloak_blended_pass_vs30 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( MORPHING, pShaderAPI->IsHWMorphingEnabled() ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); + SET_DYNAMIC_VERTEX_SHADER( sdk_cloak_blended_pass_vs30 ); + + // Set Pixel Shader Combos + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_cloak_blended_pass_ps30 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_cloak_blended_pass_ps30 ); + } +#endif + + // Bind textures + pShaderAPI->BindStandardTexture( SHADER_SAMPLER0, TEXTURE_FRAME_BUFFER_FULL_TEXTURE_0 ); // Refraction Map + if ( bBumpMapping ) + { + pShader->BindTexture( SHADER_SAMPLER1, info.m_nBumpmap, info.m_nBumpFrame ); + } + + // Set Pixel Shader Constants + float vEyePos[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + pShaderAPI->GetWorldSpaceCameraPosition( vEyePos ); + pShaderAPI->SetPixelShaderConstant( 5, vEyePos, 1 ); + + float vPackedConst1[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + vPackedConst1[0] = IS_PARAM_DEFINED( info.m_nCloakFactor ) ? params[info.m_nCloakFactor]->GetFloatValue() : kDefaultCloakFactor; + vPackedConst1[1] = IS_PARAM_DEFINED( info.m_nRefractAmount ) ? params[info.m_nRefractAmount]->GetFloatValue() : kDefaultRefractAmount; + pShaderAPI->SetPixelShaderConstant( 6, vPackedConst1, 1 ); + + // Refract color tint + pShaderAPI->SetPixelShaderConstant( 7, IS_PARAM_DEFINED( info.m_nCloakColorTint ) ? params[info.m_nCloakColorTint]->GetVecValue() : kDefaultCloakColorTint, 1 ); + + // Set c0 and c1 to contain first two rows of ViewProj matrix + VMatrix mView, mProj; + pShaderAPI->GetMatrix( MATERIAL_VIEW, mView.m[0] ); + pShaderAPI->GetMatrix( MATERIAL_PROJECTION, mProj.m[0] ); + VMatrix mViewProj = mView * mProj; + mViewProj = mViewProj.Transpose3x3(); + pShaderAPI->SetPixelShaderConstant( 0, mViewProj.m[0], 2 ); + } + pShader->Draw(); +} + +bool CloakBlendedPassIsFullyOpaque ( IMaterialVar** params, CloakBlendedPassVars_t &info ) +{ + float flCloakFactor = IS_PARAM_DEFINED( info.m_nCloakFactor ) ? params[info.m_nCloakFactor]->GetFloatValue() : kDefaultCloakFactor; + //float flRefractAmount = IS_PARAM_DEFINED( info.m_nRefractAmount ) ? params[info.m_nRefractAmount]->GetFloatValue() : kDefaultRefractAmount; + + // NOTE: If this math changes, you need to update the pixel shader code! + float flFresnel = 1.0f - ( 0.0f ); // Assume V.N = 0.0f; + float flCloakLerpFactor = clamp( Lerp( clamp( flCloakFactor, 0.0f, 1.0f ), 1.0f, flFresnel - 1.35f ), 0.0f, 1.0f ); + //flCloakLerpFactor = 1.0f - smoothstep( 0.4f, 0.425f, flCloakLerpFactor ); + + if ( flCloakLerpFactor <= 0.4f ) + return true; + + return false; +} \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/cloak_blended_pass_helper.h b/sp/src/materialsystem/stdshaders/cloak_blended_pass_helper.h new file mode 100644 index 00000000..2d566a66 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/cloak_blended_pass_helper.h @@ -0,0 +1,46 @@ +//========= Copyright ? 1996-2006, Valve Corporation, All rights reserved. ============// + +#ifndef CLOAK_BLENDED_PASS_HELPER_H +#define CLOAK_BLENDED_PASS_HELPER_H +#ifdef _WIN32 +#pragma once +#endif + +#include + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +class CBaseVSShader; +class IMaterialVar; +class IShaderDynamicAPI; +class IShaderShadow; + +//----------------------------------------------------------------------------- +// Init params/ init/ draw methods +//----------------------------------------------------------------------------- +struct CloakBlendedPassVars_t +{ + CloakBlendedPassVars_t() { memset( this, 0xFF, sizeof(CloakBlendedPassVars_t) ); } + + int m_nCloakFactor; + int m_nCloakColorTint; + int m_nRefractAmount; + + int m_nBumpmap; + int m_nBumpFrame; + int m_nBumpTransform; +}; + +// Default values (Arrays should only be vec[4]) +static const float kDefaultCloakFactor = 0.0f; +static const float kDefaultCloakColorTint[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; +static const float kDefaultRefractAmount = 0.1f; + +void InitParamsCloakBlendedPass( CBaseVSShader *pShader, IMaterialVar** params, const char *pMaterialName, CloakBlendedPassVars_t &info ); +void InitCloakBlendedPass( CBaseVSShader *pShader, IMaterialVar** params, CloakBlendedPassVars_t &info ); +void DrawCloakBlendedPass( CBaseVSShader *pShader, IMaterialVar** params, IShaderDynamicAPI *pShaderAPI, + IShaderShadow* pShaderShadow, CloakBlendedPassVars_t &info, VertexCompressionType_t vertexCompression ); +bool CloakBlendedPassIsFullyOpaque ( IMaterialVar** params, CloakBlendedPassVars_t &info ); + +#endif // CLOAK_BLENDED_PASS_HELPER_H \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/common_flashlight_fxc.h b/sp/src/materialsystem/stdshaders/common_flashlight_fxc.h index 098f1848..6f56f966 100644 --- a/sp/src/materialsystem/stdshaders/common_flashlight_fxc.h +++ b/sp/src/materialsystem/stdshaders/common_flashlight_fxc.h @@ -10,6 +10,9 @@ #include "common_ps_fxc.h" +#if defined(SHADER_MODEL_PS_3_0) +#define NEW_SHADOW_FILTERS // Comment if you want to enable retail shadow filter. +#endif // JasonM - TODO: remove this simpleton version float DoShadow( sampler DepthSampler, float4 texCoord ) @@ -100,12 +103,16 @@ float DoShadowNvidiaCheap( sampler DepthSampler, const float4 shadowMapPos ) return dot(vTaps, float4(0.25, 0.25, 0.25, 0.25)); } +#if defined( NEW_SHADOW_FILTERS ) +float DoShadowNvidiaPCF3x3Box( sampler DepthSampler, const float3 shadowMapPos ) +#else float DoShadowNvidiaPCF3x3Box( sampler DepthSampler, const float4 shadowMapPos ) +#endif { - float fTexelEpsilon = 1.0f / 1024.0f; + float fTexelEpsilon = 1.0f / 512.0f; - float ooW = 1.0f / shadowMapPos.w; // 1 / w - float3 shadowMapCenter_objDepth = shadowMapPos.xyz * ooW; // Do both projections at once + //float ooW = 1.0f; //1.0f / shadowMapPos.w; // 1 / w + float3 shadowMapCenter_objDepth = shadowMapPos.xyz; // * ooW; // Do both projections at once float2 shadowMapCenter = shadowMapCenter_objDepth.xy; // Center of shadow filter float objDepth = shadowMapCenter_objDepth.z; // Object depth in shadow space @@ -138,61 +145,80 @@ float DoShadowNvidiaPCF3x3Box( sampler DepthSampler, const float4 shadowMapPos ) // 4 20 33 20 4 // 1 4 7 4 1 // +#if defined( NEW_SHADOW_FILTERS ) +float DoShadowNvidiaPCF5x5Gaussian( sampler DepthSampler, const float3 shadowMapPos, const float2 vShadowTweaks ) +#else float DoShadowNvidiaPCF5x5Gaussian( sampler DepthSampler, const float4 shadowMapPos ) +#endif { - float fEpsilon = 1.0f / 512.0f; - float fTwoEpsilon = 2.0f * fEpsilon; +#if defined( NEW_SHADOW_FILTERS ) + float fEpsilonX = vShadowTweaks.x; + float fTwoEpsilonX = 2.0f * fEpsilonX; + float fEpsilonY = vShadowTweaks.y; + float fTwoEpsilonY = 2.0f * fEpsilonY; +#else + float fEpsilonX = 1.0 / 512.0; + float fTwoEpsilonX = 2.0f * fEpsilonX; + float fEpsilonY = fEpsilonX; + float fTwoEpsilonY = fTwoEpsilonX; +#endif +#if defined( NEW_SHADOW_FILTERS ) + // I guess we don't need this one. + // float ooW = 1.0f / shadowMapPos.w; // 1 / w + float3 shadowMapCenter_objDepth = shadowMapPos; // Do both projections at once +#else float ooW = 1.0f / shadowMapPos.w; // 1 / w float3 shadowMapCenter_objDepth = shadowMapPos.xyz * ooW; // Do both projections at once +#endif float2 shadowMapCenter = shadowMapCenter_objDepth.xy; // Center of shadow filter float objDepth = shadowMapCenter_objDepth.z; // Object depth in shadow space float4 vOneTaps; - vOneTaps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilon, fTwoEpsilon ), objDepth, 1 ) ).x; - vOneTaps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilon, fTwoEpsilon ), objDepth, 1 ) ).x; - vOneTaps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilon, -fTwoEpsilon ), objDepth, 1 ) ).x; - vOneTaps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilon, -fTwoEpsilon ), objDepth, 1 ) ).x; + vOneTaps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilonX, fTwoEpsilonY ), objDepth, 1 ) ).x; + vOneTaps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilonX, fTwoEpsilonY ), objDepth, 1 ) ).x; + vOneTaps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilonX, -fTwoEpsilonY ), objDepth, 1 ) ).x; + vOneTaps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilonX, -fTwoEpsilonY ), objDepth, 1 ) ).x; float flOneTaps = dot( vOneTaps, float4(1.0f / 331.0f, 1.0f / 331.0f, 1.0f / 331.0f, 1.0f / 331.0f)); float4 vSevenTaps; - vSevenTaps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilon, 0 ), objDepth, 1 ) ).x; - vSevenTaps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilon, 0 ), objDepth, 1 ) ).x; - vSevenTaps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, -fTwoEpsilon ), objDepth, 1 ) ).x; - vSevenTaps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, -fTwoEpsilon ), objDepth, 1 ) ).x; + vSevenTaps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilonX, 0 ), objDepth, 1 ) ).x; + vSevenTaps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilonX, 0 ), objDepth, 1 ) ).x; + vSevenTaps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, fTwoEpsilonY ), objDepth, 1 ) ).x; + vSevenTaps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, -fTwoEpsilonY ), objDepth, 1 ) ).x; float flSevenTaps = dot( vSevenTaps, float4( 7.0f / 331.0f, 7.0f / 331.0f, 7.0f / 331.0f, 7.0f / 331.0f ) ); float4 vFourTapsA, vFourTapsB; - vFourTapsA.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilon, fEpsilon ), objDepth, 1 ) ).x; - vFourTapsA.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilon, fTwoEpsilon ), objDepth, 1 ) ).x; - vFourTapsA.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilon, fTwoEpsilon ), objDepth, 1 ) ).x; - vFourTapsA.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilon, fEpsilon ), objDepth, 1 ) ).x; - vFourTapsB.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilon, -fEpsilon ), objDepth, 1 ) ).x; - vFourTapsB.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilon, -fTwoEpsilon ), objDepth, 1 ) ).x; - vFourTapsB.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilon, -fTwoEpsilon ), objDepth, 1 ) ).x; - vFourTapsB.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilon, -fEpsilon ), objDepth, 1 ) ).x; + vFourTapsA.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilonX, fEpsilonY ), objDepth, 1 ) ).x; + vFourTapsA.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilonX, fTwoEpsilonY ), objDepth, 1 ) ).x; + vFourTapsA.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilonX, fTwoEpsilonY ), objDepth, 1 ) ).x; + vFourTapsA.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilonX, fEpsilonY ), objDepth, 1 ) ).x; + vFourTapsB.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilonX, -fEpsilonY ), objDepth, 1 ) ).x; + vFourTapsB.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilonX, -fTwoEpsilonY ), objDepth, 1 ) ).x; + vFourTapsB.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilonX, -fTwoEpsilonY ), objDepth, 1 ) ).x; + vFourTapsB.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilonX, -fEpsilonY ), objDepth, 1 ) ).x; float flFourTapsA = dot( vFourTapsA, float4( 4.0f / 331.0f, 4.0f / 331.0f, 4.0f / 331.0f, 4.0f / 331.0f ) ); float flFourTapsB = dot( vFourTapsB, float4( 4.0f / 331.0f, 4.0f / 331.0f, 4.0f / 331.0f, 4.0f / 331.0f ) ); float4 v20Taps; - v20Taps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilon, fEpsilon ), objDepth, 1 ) ).x; - v20Taps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilon, fEpsilon ), objDepth, 1 ) ).x; - v20Taps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilon, -fEpsilon ), objDepth, 1 ) ).x; - v20Taps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilon, -fEpsilon ), objDepth, 1 ) ).x; + v20Taps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilonX, fEpsilonY ), objDepth, 1 ) ).x; + v20Taps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilonX, fEpsilonY ), objDepth, 1 ) ).x; + v20Taps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilonX, -fEpsilonY ), objDepth, 1 ) ).x; + v20Taps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilonX, -fEpsilonY ), objDepth, 1 ) ).x; float fl20Taps = dot( v20Taps, float4(20.0f / 331.0f, 20.0f / 331.0f, 20.0f / 331.0f, 20.0f / 331.0f)); float4 v33Taps; - v33Taps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilon, 0 ), objDepth, 1 ) ).x; - v33Taps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilon, 0 ), objDepth, 1 ) ).x; - v33Taps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, -fEpsilon ), objDepth, 1 ) ).x; - v33Taps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, -fEpsilon ), objDepth, 1 ) ).x; + v33Taps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilonX, 0 ), objDepth, 1 ) ).x; + v33Taps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilonX, 0 ), objDepth, 1 ) ).x; + v33Taps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, fEpsilonY ), objDepth, 1 ) ).x; + v33Taps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, -fEpsilonY ), objDepth, 1 ) ).x; float fl33Taps = dot( v33Taps, float4(33.0f / 331.0f, 33.0f / 331.0f, 33.0f / 331.0f, 33.0f / 331.0f)); float flCenterTap = tex2Dproj( DepthSampler, float4( shadowMapCenter, objDepth, 1 ) ).x * (55.0f / 331.0f); // Sum all 25 Taps - return flOneTaps + flSevenTaps + +flFourTapsA + flFourTapsB + fl20Taps + fl33Taps + flCenterTap; + return flOneTaps + flSevenTaps + flFourTapsA + flFourTapsB + fl20Taps + fl33Taps + flCenterTap; } @@ -601,7 +627,12 @@ float DoFlashlightShadow( sampler DepthSampler, sampler RandomRotationSampler, f #if !defined( _X360 ) //PC if( nShadowLevel == NVIDIA_PCF_POISSON ) +#if defined( NEW_SHADOW_FILTERS ) && defined( SHADER_MODEL_PS_3_0 ) + // Let's replace noise filter with gaussian blur, like in Portal 2. + flShadow = DoShadowNvidiaPCF5x5Gaussian( DepthSampler, vProjCoords, float2( 1.0 / 2048.0, 1.0 / 2048.0 ) ); +#else flShadow = DoShadowPoisson16Sample( DepthSampler, RandomRotationSampler, vProjCoords, vScreenPos, vShadowTweaks, true, false ); +#endif else if( nShadowLevel == ATI_NOPCF ) flShadow = DoShadowPoisson16Sample( DepthSampler, RandomRotationSampler, vProjCoords, vScreenPos, vShadowTweaks, false, false ); else if( nShadowLevel == ATI_NO_PCF_FETCH4 ) @@ -660,6 +691,12 @@ void DoSpecularFlashlight( float3 flashlightPos, float3 worldPos, float4 flashli { float3 vProjCoords = flashlightSpacePosition.xyz / flashlightSpacePosition.w; float3 flashlightColor = float3(1,1,1); + + // Blixibon - Fix for flashlight textures without Clamp S/T +#if defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) + clip( vProjCoords.xyz ); + clip( 1-vProjCoords.xyz ); +#endif #if ( defined( _X360 ) ) @@ -691,6 +728,7 @@ void DoSpecularFlashlight( float3 flashlightPos, float3 worldPos, float4 flashli #if defined(SHADER_MODEL_PS_2_0) || defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) + flashlightColor *= flashlightSpacePosition.w > 0; flashlightColor *= cFlashlightColor.xyz; // Flashlight color #endif @@ -702,7 +740,7 @@ void DoSpecularFlashlight( float3 flashlightPos, float3 worldPos, float4 flashli float endFalloffFactor = RemapValClamped( dist, farZ, 0.6f * farZ, 0.0f, 1.0f ); // Attenuation for light and to fade out shadow over distance - float fAtten = saturate( dot( attenuationFactors, float3( 1.0f, 1.0f/dist, 1.0f/distSquared ) ) ); + float fAtten = saturate( endFalloffFactor * dot( attenuationFactors, float3( 1.0f, 1.0f/dist, 1.0f/distSquared ) ) ); // Shadowing and coloring terms #if (defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0)) @@ -722,7 +760,9 @@ void DoSpecularFlashlight( float3 flashlightPos, float3 worldPos, float4 flashli diffuseLighting *= saturate( dot( L.xyz, worldNormal.xyz ) ); // Lambertian (not Half-Lambert) term #endif diffuseLighting *= flashlightColor; - diffuseLighting *= endFalloffFactor; + + // Blixibon - Now calculating endFalloffFactor directly from fAtten + //diffuseLighting *= endFalloffFactor; // Specular term (masked by diffuse) specularLighting = diffuseLighting * SpecularLight ( worldNormal, L, fSpecularExponent, vEyeDir, bDoSpecularWarp, specularWarpSampler, fFresnel ); @@ -734,29 +774,28 @@ float3 DoFlashlight( float3 flashlightPos, float3 worldPos, float4 flashlightSpa sampler RandomRotationSampler, int nShadowLevel, bool bDoShadows, bool bAllowHighQuality, const float2 vScreenPos, bool bClip, float4 vShadowTweaks = float4(3/1024.0f, 0.0005f, 0.0f, 0.0f), bool bHasNormal = true ) { - float3 vProjCoords = flashlightSpacePosition.xyz / flashlightSpacePosition.w; - float3 flashlightColor = float3(1,1,1); - -#if ( defined( _X360 ) ) - - float3 ltz = vProjCoords.xyz < float3( 0.0f, 0.0f, 0.0f ); - float3 gto = vProjCoords.xyz > float3( 1.0f, 1.0f, 1.0f ); - - [branch] - if ( dot(ltz + gto, float3(1,1,1)) > 0 ) + if ( flashlightSpacePosition.w < 0 ) { - if ( bClip ) - { - clip(-1); - } return float3(0,0,0); } else { - flashlightColor = tex2D( FlashlightSampler, vProjCoords ); + float3 vProjCoords = flashlightSpacePosition.xyz / flashlightSpacePosition.w; + float3 flashlightColor = float3(1,1,1); + + // Blixibon - Fix for flashlight textures without Clamp S/T +#if defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) + clip( vProjCoords.xyz ); + clip( 1-vProjCoords.xyz ); +#endif + +#if ( defined( _X360 ) ) + + float3 ltz = vProjCoords.xyz < float3( 0.0f, 0.0f, 0.0f ); + float3 gto = vProjCoords.xyz > float3( 1.0f, 1.0f, 1.0f ); [branch] - if ( dot(flashlightColor.xyz, float3(1,1,1)) <= 0 ) + if ( dot(ltz + gto, float3(1,1,1)) > 0 ) { if ( bClip ) { @@ -764,58 +803,74 @@ float3 DoFlashlight( float3 flashlightPos, float3 worldPos, float4 flashlightSpa } return float3(0,0,0); } - } + else + { + flashlightColor = tex2D( FlashlightSampler, vProjCoords ); + + [branch] + if ( dot(flashlightColor.xyz, float3(1,1,1)) <= 0 ) + { + if ( bClip ) + { + clip(-1); + } + return float3(0,0,0); + } + } #else - flashlightColor = tex2D( FlashlightSampler, vProjCoords ); + flashlightColor = tex2D( FlashlightSampler, vProjCoords ); #endif #if defined(SHADER_MODEL_PS_2_0) || defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) - flashlightColor *= cFlashlightColor.xyz; // Flashlight color + flashlightColor *= cFlashlightColor.xyz; // Flashlight color #endif - float3 delta = flashlightPos - worldPos; - float3 L = normalize( delta ); - float distSquared = dot( delta, delta ); - float dist = sqrt( distSquared ); + float3 delta = flashlightPos - worldPos; + float3 L = normalize( delta ); + float distSquared = dot( delta, delta ); + float dist = sqrt( distSquared ); - float endFalloffFactor = RemapValClamped( dist, farZ, 0.6f * farZ, 0.0f, 1.0f ); + float endFalloffFactor = RemapValClamped( dist, farZ, 0.6f * farZ, 0.0f, 1.0f ); - // Attenuation for light and to fade out shadow over distance - float fAtten = saturate( dot( attenuationFactors, float3( 1.0f, 1.0f/dist, 1.0f/distSquared ) ) ); + // Attenuation for light and to fade out shadow over distance + float fAtten = saturate( endFalloffFactor * dot( attenuationFactors, float3( 1.0f, 1.0f/dist, 1.0f/distSquared ) ) ); - // Shadowing and coloring terms + // Shadowing and coloring terms #if (defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0)) - if ( bDoShadows ) - { - float flShadow = DoFlashlightShadow( FlashlightDepthSampler, RandomRotationSampler, vProjCoords, vScreenPos, nShadowLevel, vShadowTweaks, bAllowHighQuality ); - float flAttenuated = lerp( flShadow, 1.0f, vShadowTweaks.y ); // Blend between fully attenuated and not attenuated - flShadow = saturate( lerp( flAttenuated, flShadow, fAtten ) ); // Blend between shadow and above, according to light attenuation - flashlightColor *= flShadow; // Shadow term - } + if ( bDoShadows ) + { + float flShadow = DoFlashlightShadow( FlashlightDepthSampler, RandomRotationSampler, vProjCoords, vScreenPos, nShadowLevel, vShadowTweaks, bAllowHighQuality ); + float flAttenuated = lerp( flShadow, 1.0f, vShadowTweaks.y ); // Blend between fully attenuated and not attenuated + flShadow = saturate( lerp( flAttenuated, flShadow, fAtten ) ); // Blend between shadow and above, according to light attenuation + flashlightColor *= flShadow; // Shadow term + } #endif - float3 diffuseLighting = fAtten; + float3 diffuseLighting = fAtten; - float flLDotWorldNormal; - if ( bHasNormal ) - { - flLDotWorldNormal = dot( L.xyz, worldNormal.xyz ); - } - else - { - flLDotWorldNormal = 1.0f; - } + float flLDotWorldNormal; + if ( bHasNormal ) + { + flLDotWorldNormal = dot( L.xyz, worldNormal.xyz ); + } + else + { + flLDotWorldNormal = 1.0f; + } #if defined(SHADER_MODEL_PS_2_0) || defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) - diffuseLighting *= saturate( flLDotWorldNormal + flFlashlightNoLambertValue ); // Lambertian term + diffuseLighting *= saturate( flLDotWorldNormal + flFlashlightNoLambertValue ); // Lambertian term #else - diffuseLighting *= saturate( flLDotWorldNormal ); // Lambertian (not Half-Lambert) term + diffuseLighting *= saturate( flLDotWorldNormal ); // Lambertian (not Half-Lambert) term #endif - diffuseLighting *= flashlightColor; - diffuseLighting *= endFalloffFactor; + diffuseLighting *= flashlightColor; + + // Blixibon - Now calculating endFalloffFactor directly from fAtten + //diffuseLighting *= endFalloffFactor; - return diffuseLighting; + return diffuseLighting; + } } -#endif //#ifndef COMMON_FLASHLIGHT_FXC_H_ +#endif //#ifndef COMMON_FLASHLIGHT_FXC_H_ \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/common_fxc.h b/sp/src/materialsystem/stdshaders/common_fxc.h index 2103b3f9..65f0802d 100644 --- a/sp/src/materialsystem/stdshaders/common_fxc.h +++ b/sp/src/materialsystem/stdshaders/common_fxc.h @@ -323,4 +323,18 @@ float3 Vec3TangentToWorldNormalized( float3 iTangentVector, float3 iWorldNormal, return normalize( Vec3TangentToWorld( iTangentVector, iWorldNormal, iWorldTangent, iWorldBinormal ) ); } +// returns 1.0f for no fog, 0.0f for fully fogged +float CalcRangeFogFactorFixedFunction( float3 worldPos, float3 eyePos, float flFogMaxDensity, float flFogEndOverRange, float flFogOORange ) +{ + float dist = distance( eyePos.xyz, worldPos.xyz ); + return max( flFogMaxDensity, ( -dist * flFogOORange ) + flFogEndOverRange ); +} + +// returns 0.0f for no fog, 1.0f for fully fogged which is opposite of what fixed function fog expects so that we don't have to do a "1-x" in the pixel shader. +float CalcRangeFogFactorNonFixedFunction( float3 worldPos, float3 eyePos, float flFogMaxDensity, float flFogEndOverRange, float flFogOORange ) +{ + float dist = distance( eyePos.xyz, worldPos.xyz ); + return min( flFogMaxDensity, saturate( ( dist * flFogOORange ) - flFogEndOverRange ) ); +} + #endif //#ifndef COMMON_FXC_H_ diff --git a/sp/src/materialsystem/stdshaders/common_ps_fxc.h b/sp/src/materialsystem/stdshaders/common_ps_fxc.h index fca6511f..330edd36 100644 --- a/sp/src/materialsystem/stdshaders/common_ps_fxc.h +++ b/sp/src/materialsystem/stdshaders/common_ps_fxc.h @@ -211,6 +211,8 @@ HALF4 EnvReflect( sampler envmapSampler, float CalcWaterFogAlpha( const float flWaterZ, const float flEyePosZ, const float flWorldPosZ, const float flProjPosZ, const float flFogOORange ) { +#if 0 + // This version is what you use if you want a line-integral throught he water for water fog. // float flDepthFromWater = flWaterZ - flWorldPosZ + 2.0f; // hackity hack . .this is for the DF_FUDGE_UP in view_scene.cpp float flDepthFromWater = flWaterZ - flWorldPosZ; @@ -226,6 +228,13 @@ float CalcWaterFogAlpha( const float flWaterZ, const float flEyePosZ, const floa // $tmp.w is now the distance that we see through water. return saturate(f * flProjPosZ * flFogOORange); +#else + // This version is simply using the depth of the water to determine fog factor, + // which is cheaper than doing the line integral and also fixes some problems with having + // a hard line on the shore when the water surface is viewed tangentially. + // hackity hack . .the 2.0 is for the DF_FUDGE_UP in view_scene.cpp + return saturate( ( flWaterZ - flWorldPosZ - 2.0f ) * flFogOORange ); +#endif } float CalcRangeFog( const float flProjPosZ, const float flFogStartOverRange, const float flFogMaxDensity, const float flFogOORange ) @@ -237,20 +246,24 @@ float CalcRangeFog( const float flProjPosZ, const float flFogStartOverRange, con #endif } -float CalcPixelFogFactor( int iPIXELFOGTYPE, const float4 fogParams, const float flEyePosZ, const float flWorldPosZ, const float flProjPosZ ) +float CalcPixelFogFactor( int iPIXELFOGTYPE, const float4 fogParams, const float3 vEyePos, const float3 vWorldPos, const float flProjPosZ ) { - float retVal; - if ( iPIXELFOGTYPE == PIXEL_FOG_TYPE_NONE ) + float retVal = 0; + /*if ( iPIXELFOGTYPE == PIXEL_FOG_TYPE_NONE ) { retVal = 0.0f; - } + }*/ if ( iPIXELFOGTYPE == PIXEL_FOG_TYPE_RANGE ) //range fog, or no fog depending on fog parameters { - retVal = CalcRangeFog( flProjPosZ, fogParams.x, fogParams.z, fogParams.w ); + //retVal = CalcRangeFog( flProjPosZ, fogParams.x, fogParams.z, fogParams.w ); + float flFogMaxDensity = fogParams.z; + float flFogEndOverRange = fogParams.x; + float flFogOORange = fogParams.w; + retVal = CalcRangeFogFactorNonFixedFunction( vWorldPos, vEyePos, flFogMaxDensity, flFogEndOverRange, flFogOORange ); } else if ( iPIXELFOGTYPE == PIXEL_FOG_TYPE_HEIGHT ) //height fog { - retVal = CalcWaterFogAlpha( fogParams.y, flEyePosZ, flWorldPosZ, flProjPosZ, fogParams.w ); + retVal = CalcWaterFogAlpha( fogParams.y, vEyePos.z, vWorldPos.z, flProjPosZ, fogParams.w ); } return retVal; @@ -264,23 +277,25 @@ float CalcPixelFogFactor( int iPIXELFOGTYPE, const float4 fogParams, const float float3 BlendPixelFog( const float3 vShaderColor, float pixelFogFactor, const float3 vFogColor, const int iPIXELFOGTYPE ) { + float3 flRet = 0; if( iPIXELFOGTYPE == PIXEL_FOG_TYPE_RANGE ) //either range fog or no fog depending on fog parameters and whether this is ps20 or ps2b { # if !(defined(SHADER_MODEL_PS_1_1) || defined(SHADER_MODEL_PS_1_4) || defined(SHADER_MODEL_PS_2_0)) //Minimum requirement of ps2b pixelFogFactor = saturate( pixelFogFactor ); - return lerp( vShaderColor.rgb, vFogColor.rgb, pixelFogFactor * pixelFogFactor ); //squaring the factor will get the middle range mixing closer to hardware fog + flRet = lerp( vShaderColor.rgb, vFogColor.rgb, pixelFogFactor * pixelFogFactor ); //squaring the factor will get the middle range mixing closer to hardware fog # else - return vShaderColor; + flRet = vShaderColor; # endif } else if( iPIXELFOGTYPE == PIXEL_FOG_TYPE_HEIGHT ) { - return lerp( vShaderColor.rgb, vFogColor.rgb, saturate( pixelFogFactor ) ); + flRet = lerp( vShaderColor.rgb, vFogColor.rgb, saturate( pixelFogFactor ) ); } else if( iPIXELFOGTYPE == PIXEL_FOG_TYPE_NONE ) { - return vShaderColor; + flRet = vShaderColor; } + return flRet; } diff --git a/sp/src/materialsystem/stdshaders/common_splinerope_fxc.h b/sp/src/materialsystem/stdshaders/common_splinerope_fxc.h new file mode 100644 index 00000000..0893d1d2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/common_splinerope_fxc.h @@ -0,0 +1,26 @@ +//========== Copyright (c) Valve Corporation, All rights reserved. ==========// + +#ifdef PIXELSHADER + #define VS_OUTPUT PS_INPUT +#endif + +struct VS_OUTPUT +{ +#ifndef PIXELSHADER + float4 projPos : POSITION; +#endif + + float2 texCoord : TEXCOORD0; + float4 worldPos_projPosZ : TEXCOORD1; + float4 argbcolor : COLOR; + +#ifndef PIXELSHADER + #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 ) + float fog : FOG; + #endif +#endif +}; + +#ifdef PIXELSHADER + #undef VS_OUTPUT +#endif diff --git a/sp/src/materialsystem/stdshaders/common_vs_fxc.h b/sp/src/materialsystem/stdshaders/common_vs_fxc.h index ac966b68..291118a4 100644 --- a/sp/src/materialsystem/stdshaders/common_vs_fxc.h +++ b/sp/src/materialsystem/stdshaders/common_vs_fxc.h @@ -91,8 +91,8 @@ const float4 cViewProjZ : register(c13); const float4 cFogParams : register(c16); #define cFogEndOverFogRange cFogParams.x -#define cFogOne cFogParams.y -#define cFogMaxDensity cFogParams.z +// cFogParams.y unused +#define cRadialFogMaxDensity cFogParams.z //radial fog max density in fractional portion. height fog max density stored in integer portion and is multiplied by 1e10 #define cOOFogRange cFogParams.w const float4x4 cViewModel : register(c17); @@ -519,8 +519,41 @@ bool ApplyMorph( sampler2D morphSampler, const float3 vMorphTargetTextureDim, co #endif // SHADER_MODEL_VS_3_0 +float CalcFixedFunctionFog( const float3 worldPos, const bool bWaterFog ) +{ + if( !bWaterFog ) + { + return CalcRangeFogFactorFixedFunction( worldPos, cEyePos, cRadialFogMaxDensity, cFogEndOverFogRange, cOOFogRange ); + } + else + { + return 0.0f; //all done in the pixel shader as of ps20 (current min-spec) + } +} -float RangeFog( const float3 projPos ) +float CalcFixedFunctionFog( const float3 worldPos, const int fogType ) +{ + return CalcFixedFunctionFog( worldPos, fogType != FOGTYPE_RANGE ); +} + +float CalcNonFixedFunctionFog( const float3 worldPos, const bool bWaterFog ) +{ + if( !bWaterFog ) + { + return CalcRangeFogFactorNonFixedFunction( worldPos, cEyePos, cRadialFogMaxDensity, cFogEndOverFogRange, cOOFogRange ); + } + else + { + return 0.0f; //all done in the pixel shader as of ps20 (current min-spec) + } +} + +float CalcNonFixedFunctionFog( const float3 worldPos, const int fogType ) +{ + return CalcNonFixedFunctionFog( worldPos, fogType != FOGTYPE_RANGE ); +} + +/*float RangeFog( const float3 projPos ) { return max( cFogMaxDensity, ( -projPos.z * cOOFogRange + cFogEndOverFogRange ) ); } @@ -547,11 +580,11 @@ float WaterFog( const float3 worldPos, const float3 projPos ) // $tmp.w is now the distance that we see through water. return max( cFogMaxDensity, ( -tmp.w * cOOFogRange + cFogOne ) ); -} +}*/ float CalcFog( const float3 worldPos, const float3 projPos, const int fogType ) { -#if defined( _X360 ) +/*#if defined( _X360 ) // 360 only does pixel fog return 1.0f; #endif @@ -568,12 +601,13 @@ float CalcFog( const float3 worldPos, const float3 projPos, const int fogType ) #else return WaterFog( worldPos, projPos ); #endif - } + }*/ + return CalcFixedFunctionFog( worldPos, fogType ); } float CalcFog( const float3 worldPos, const float3 projPos, const bool bWaterFog ) { -#if defined( _X360 ) +/*#if defined( _X360 ) // 360 only does pixel fog return 1.0f; #endif @@ -593,7 +627,8 @@ float CalcFog( const float3 worldPos, const float3 projPos, const bool bWaterFog #endif } - return flFog; + return flFog;*/ + return CalcFixedFunctionFog( worldPos, bWaterFog ); } float4 DecompressBoneWeights( const float4 weights ) diff --git a/sp/src/materialsystem/stdshaders/decalmodulate.cpp b/sp/src/materialsystem/stdshaders/decalmodulate.cpp new file mode 100644 index 00000000..6dd829b1 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/decalmodulate.cpp @@ -0,0 +1,63 @@ +//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $Header: $ +// $NoKeywords: $ +//=============================================================================// + +#include "shaderlib/CShader.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +DEFINE_FALLBACK_SHADER( DecalModulate, DecalModulate_DX6 ) + +BEGIN_SHADER( DecalModulate_dx6, + "Help for DecalModulate_dx6" ) + + BEGIN_SHADER_PARAMS + END_SHADER_PARAMS + + SHADER_INIT_PARAMS() + { + SET_FLAGS( MATERIAL_VAR_NO_DEBUG_OVERRIDE ); + } + + SHADER_INIT + { + LoadTexture( BASETEXTURE ); + } + + SHADER_DRAW + { + SHADOW_STATE + { + pShaderShadow->EnableAlphaTest( true ); + pShaderShadow->AlphaFunc( SHADER_ALPHAFUNC_GREATER, 0.0f ); + pShaderShadow->EnableDepthWrites( false ); + pShaderShadow->EnablePolyOffset( SHADER_POLYOFFSET_DECAL ); + pShaderShadow->EnableTexture( SHADER_SAMPLER0, true ); + pShaderShadow->EnableBlending( true ); + pShaderShadow->BlendFunc( SHADER_BLEND_DST_COLOR, SHADER_BLEND_SRC_COLOR ); + pShaderShadow->DrawFlags( SHADER_DRAW_POSITION | SHADER_DRAW_TEXCOORD0 ); + FogToGrey(); + } + DYNAMIC_STATE + { + // This is kinda gross. We really don't want to render anything here for the flashlight + // pass since we are multiplying by what is already flashlight lit in the framebuffer. + // There is no easy way to draw nothing conditionally, so I'll bind grey and multiply + // which shouldn't change the contents of the framebuffer much. + if( pShaderAPI->InFlashlightMode() ) + { + pShaderAPI->BindStandardTexture( SHADER_SAMPLER0, TEXTURE_GREY ); + } + else + { + BindTexture( SHADER_SAMPLER0, BASETEXTURE, FRAME ); + } + } + Draw( ); + } +END_SHADER diff --git a/sp/src/materialsystem/stdshaders/decalmodulate_dx9.cpp b/sp/src/materialsystem/stdshaders/decalmodulate_dx9.cpp new file mode 100644 index 00000000..a48793cd --- /dev/null +++ b/sp/src/materialsystem/stdshaders/decalmodulate_dx9.cpp @@ -0,0 +1,332 @@ +//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======// +// +// Purpose: +// +// $Header: $ +// $NoKeywords: $ +//===========================================================================// + +#include "BaseVSShader.h" +#include "cpp_shader_constant_register_map.h" + +#include "sdk_decalmodulate_vs20.inc" +#include "sdk_decalmodulate_ps20.inc" +#include "sdk_decalmodulate_ps20b.inc" + +#ifndef _X360 +#include "sdk_decalmodulate_vs30.inc" +#include "sdk_decalmodulate_ps30.inc" +#endif + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +#ifdef MAPBASE +ConVar mat_decalmodulate_noflashdraw( "mat_decalmodulate_noflashdraw", "0" ); +#endif + +DEFINE_FALLBACK_SHADER( SDK_DecalModulate, SDK_DecalModulate_DX9 ) + +BEGIN_VS_SHADER( SDK_DecalModulate_dx9, + "Help for SDK_DecalModulate_dx9" ) + + BEGIN_SHADER_PARAMS + SHADER_PARAM( FOGEXPONENT, SHADER_PARAM_TYPE_FLOAT, "0.4", "exponent to tweak fog fade" ) + SHADER_PARAM( FOGSCALE, SHADER_PARAM_TYPE_FLOAT, "1.0", "scale to tweak fog fade" ) + END_SHADER_PARAMS + + SHADER_FALLBACK + { + return 0; + } + + SHADER_INIT_PARAMS() + { + if( !params[ FOGEXPONENT ]->IsDefined() ) + { + params[ FOGEXPONENT ]->SetFloatValue( 0.4f ); + } + + if( !params[ FOGSCALE ]->IsDefined() ) + { + params[ FOGSCALE ]->SetFloatValue( 1.0f ); + } + + SET_FLAGS( MATERIAL_VAR_NO_DEBUG_OVERRIDE ); + +#ifndef _X360 + if ( g_pHardwareConfig->HasFastVertexTextures() ) + { + // The vertex shader uses the vertex id stream + SET_FLAGS2( MATERIAL_VAR2_USES_VERTEXID ); + SET_FLAGS2( MATERIAL_VAR2_SUPPORTS_HW_SKINNING ); + } +#endif + } + + SHADER_INIT + { + LoadTexture( BASETEXTURE ); + } + + SHADER_DRAW + { +#ifdef MAPBASE + // TEST 1 - Check game DLL stuff since the issue is that mod2x is modding flashlight brightness because it's not gray + // + // NOTE: Maybe the decals not appearing is a SORTING issue! + // The flashlight part is transparent and overlaid on top of the decal! + // + bool bHasFlashlight = UsingFlashlight( params ); +#endif + SHADOW_STATE + { + pShaderShadow->EnableAlphaTest( true ); + pShaderShadow->AlphaFunc( SHADER_ALPHAFUNC_GREATER, 0.0f ); + pShaderShadow->EnableDepthWrites( false ); + pShaderShadow->EnablePolyOffset( SHADER_POLYOFFSET_DECAL ); + pShaderShadow->EnableTexture( SHADER_SAMPLER0, true ); + + // Be sure not to write to dest alpha + pShaderShadow->EnableAlphaWrites( false ); + + //SRGB conversions hose the blend on some hardware, so keep everything in gamma space. + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, false ); + pShaderShadow->EnableSRGBWrite( false ); + + pShaderShadow->EnableBlending( true ); + pShaderShadow->BlendFunc( SHADER_BLEND_DST_COLOR, SHADER_BLEND_SRC_COLOR ); + pShaderShadow->DisableFogGammaCorrection( true ); //fog should stay exactly middle grey + FogToGrey(); + +#ifdef MAPBASE + int userDataSize = 0; + int nShadowFilterMode = 0; + if ( bHasFlashlight ) + { + pShaderShadow->EnableTexture( SHADER_SAMPLER8, true ); // Depth texture + pShaderShadow->SetShadowDepthFiltering( SHADER_SAMPLER8 ); + pShaderShadow->EnableTexture( SHADER_SAMPLER6, true ); // Noise map + pShaderShadow->EnableTexture( SHADER_SAMPLER7, true ); // Flashlight cookie + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER7, true ); + userDataSize = 4; // tangent S + + if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + nShadowFilterMode = g_pHardwareConfig->GetShadowFilterMode(); // Based upon vendor and device dependent formats + } + } +#endif + + bool bHasVertexAlpha = IS_FLAG_SET( MATERIAL_VAR_VERTEXCOLOR ) && IS_FLAG_SET( MATERIAL_VAR_VERTEXALPHA ); + +#ifndef _X360 + if ( !g_pHardwareConfig->HasFastVertexTextures() ) +#endif + { + DECLARE_STATIC_VERTEX_SHADER( sdk_decalmodulate_vs20 ); + SET_STATIC_VERTEX_SHADER_COMBO( VERTEXCOLOR, bHasVertexAlpha ); + SET_STATIC_VERTEX_SHADER_COMBO( LIGHTING_PREVIEW, false ); +#ifdef MAPBASE + SET_STATIC_VERTEX_SHADER_COMBO( FLASHLIGHT, bHasFlashlight ); +#endif + SET_STATIC_VERTEX_SHADER( sdk_decalmodulate_vs20 ); + + if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + DECLARE_STATIC_PIXEL_SHADER( sdk_decalmodulate_ps20b ); + SET_STATIC_PIXEL_SHADER_COMBO( VERTEXALPHA, bHasVertexAlpha ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHT, bHasFlashlight ); + SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, nShadowFilterMode ); +#endif + SET_STATIC_PIXEL_SHADER( sdk_decalmodulate_ps20b ); + } + else + { + DECLARE_STATIC_PIXEL_SHADER( sdk_decalmodulate_ps20 ); + SET_STATIC_PIXEL_SHADER_COMBO( VERTEXALPHA, bHasVertexAlpha ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHT, bHasFlashlight ); +#endif + SET_STATIC_PIXEL_SHADER( sdk_decalmodulate_ps20 ); + } + } +#ifndef _X360 + else + { + DECLARE_STATIC_VERTEX_SHADER( sdk_decalmodulate_vs30 ); + SET_STATIC_VERTEX_SHADER_COMBO( VERTEXCOLOR, bHasVertexAlpha ); + SET_STATIC_VERTEX_SHADER_COMBO( LIGHTING_PREVIEW, false ); +#ifdef MAPBASE + SET_STATIC_VERTEX_SHADER_COMBO( FLASHLIGHT, bHasFlashlight ); +#endif + SET_STATIC_VERTEX_SHADER( sdk_decalmodulate_vs30 ); + + DECLARE_STATIC_PIXEL_SHADER( sdk_decalmodulate_ps30 ); + SET_STATIC_PIXEL_SHADER_COMBO( VERTEXALPHA, bHasVertexAlpha ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHT, bHasFlashlight ); + SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, nShadowFilterMode ); +#endif + SET_STATIC_PIXEL_SHADER( sdk_decalmodulate_ps30 ); + } +#endif + + // Set stream format (note that this shader supports compression) + unsigned int flags = VERTEX_POSITION | VERTEX_FORMAT_COMPRESSED; + + if ( bHasVertexAlpha ) + { + flags |= VERTEX_COLOR; + } + +#ifndef _X360 + // The VS30 shader offsets decals along the normal (for morphed geom) + flags |= g_pHardwareConfig->HasFastVertexTextures() ? VERTEX_NORMAL : 0; +#endif + int pTexCoordDim[3] = { 2, 0, 3 }; + int nTexCoordCount = 1; +#ifndef MAPBASE + int userDataSize = 0; +#endif + +#ifndef _X360 + if ( g_pHardwareConfig->HasFastVertexTextures() ) + { +#ifdef MAPBASE + if (nTexCoordCount == 0) + nTexCoordCount = 3; +#else + nTexCoordCount = 3; +#endif + } +#endif + + pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, pTexCoordDim, userDataSize ); + } + DYNAMIC_STATE + { +#ifdef MAPBASE // This fixes blood decals, etc. not showing up under flashlights. + //bHasFlashlight = pShaderAPI->InFlashlightMode(); + bool bFlashlightShadows = false; + if ( bHasFlashlight ) + { + VMatrix worldToTexture; + ITexture *pFlashlightDepthTexture; + FlashlightState_t state = pShaderAPI->GetFlashlightStateEx( worldToTexture, &pFlashlightDepthTexture ); + bFlashlightShadows = state.m_bEnableShadows && ( pFlashlightDepthTexture != NULL ); + + if( pFlashlightDepthTexture && g_pConfig->ShadowDepthTexture() && state.m_bEnableShadows ) + { + BindTexture( SHADER_SAMPLER8, pFlashlightDepthTexture, 0 ); + pShaderAPI->BindStandardTexture( SHADER_SAMPLER6, TEXTURE_SHADOW_NOISE_2D ); + } + + SetFlashLightColorFromState( state, pShaderAPI, 28 ); + + Assert( info.m_nFlashlightTexture >= 0 && info.m_nFlashlightTextureFrame >= 0 ); + BindTexture( SHADER_SAMPLER7, state.m_pSpotlightTexture, state.m_nSpotlightTextureFrame ); + + float atten_pos[8]; + atten_pos[0] = state.m_fConstantAtten; // Set the flashlight attenuation factors + atten_pos[1] = state.m_fLinearAtten; + atten_pos[2] = state.m_fQuadraticAtten; + atten_pos[3] = state.m_FarZ; + atten_pos[4] = state.m_vecLightOrigin[0]; // Set the flashlight origin + atten_pos[5] = state.m_vecLightOrigin[1]; + atten_pos[6] = state.m_vecLightOrigin[2]; + atten_pos[7] = 1.0f; + pShaderAPI->SetPixelShaderConstant( 22, atten_pos, 2 ); + + pShaderAPI->SetPixelShaderConstant( 24, worldToTexture.Base(), 4 ); + } + + //if ( pShaderAPI->InFlashlightMode() && mat_decalmodulate_noflashdraw.GetBool() ) +#else + if ( pShaderAPI->InFlashlightMode() && !IsX360() ) + { + // Don't draw anything for the flashlight pass + Draw( false ); + return; + } +#endif + + BindTexture( SHADER_SAMPLER0, BASETEXTURE, FRAME ); + + // Set an identity base texture transformation + Vector4D transformation[2]; + transformation[0].Init( 1.0f, 0.0f, 0.0f, 0.0f ); + transformation[1].Init( 0.0f, 1.0f, 0.0f, 0.0f ); + pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, transformation[0].Base(), 2 ); + + pShaderAPI->SetPixelShaderFogParams( PSREG_FOG_PARAMS ); + + float vEyePos_SpecExponent[4]; + pShaderAPI->GetWorldSpaceCameraPosition( vEyePos_SpecExponent ); + vEyePos_SpecExponent[3] = 0.0f; + pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, vEyePos_SpecExponent, 1 ); + + // fog tweaks + float fConsts[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + fConsts[0] = params[ FOGEXPONENT ]->GetFloatValue(); + fConsts[1] = params[ FOGSCALE ]->GetFloatValue(); + pShaderAPI->SetPixelShaderConstant( 0, fConsts ); + + MaterialFogMode_t fogType = pShaderAPI->GetSceneFogMode(); + +#ifndef _X360 + if ( !g_pHardwareConfig->HasFastVertexTextures() ) +#endif + { + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_decalmodulate_vs20 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, 0 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); +// SET_DYNAMIC_VERTEX_SHADER_COMBO( TESSELLATION, 0 ); // JasonM TODO: set this appropriately when we care about decals on subds + SET_DYNAMIC_VERTEX_SHADER( sdk_decalmodulate_vs20 ); + + if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_decalmodulate_ps20b ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); +#ifdef MAPBASE + SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, bFlashlightShadows ); +#endif + SET_DYNAMIC_PIXEL_SHADER( sdk_decalmodulate_ps20b ); + } + else + { + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_decalmodulate_ps20 ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); + SET_DYNAMIC_PIXEL_SHADER( sdk_decalmodulate_ps20 ); + } + } +#ifndef _X360 + else + { + SetHWMorphVertexShaderState( VERTEX_SHADER_SHADER_SPECIFIC_CONST_6, VERTEX_SHADER_SHADER_SPECIFIC_CONST_7, SHADER_VERTEXTEXTURE_SAMPLER0 ); + + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_decalmodulate_vs30 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( MORPHING, pShaderAPI->IsHWMorphingEnabled() ); +// SET_DYNAMIC_VERTEX_SHADER_COMBO( TESSELLATION, 0 ); // JasonM TODO: set this appropriately when we care about decals on subds + SET_DYNAMIC_VERTEX_SHADER( sdk_decalmodulate_vs30 ); + + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_decalmodulate_ps30 ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); +#ifdef MAPBASE + SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, bFlashlightShadows ); +#endif + SET_DYNAMIC_PIXEL_SHADER( sdk_decalmodulate_ps30 ); + + bool bUnusedTexCoords[3] = { false, false, !pShaderAPI->IsHWMorphingEnabled() }; + pShaderAPI->MarkUnusedVertexFields( 0, 3, bUnusedTexCoords ); + } +#endif + } + Draw( ); + } +END_SHADER diff --git a/sp/src/materialsystem/stdshaders/depthwrite.cpp b/sp/src/materialsystem/stdshaders/depthwrite.cpp index 06d7690f..fecaf42b 100644 --- a/sp/src/materialsystem/stdshaders/depthwrite.cpp +++ b/sp/src/materialsystem/stdshaders/depthwrite.cpp @@ -8,16 +8,16 @@ #include "BaseVSShader.h" -#include "depthwrite_ps20.inc" -#include "depthwrite_ps20b.inc" -#include "depthwrite_vs20.inc" +#include "sdk_depthwrite_ps20.inc" +#include "sdk_depthwrite_ps20b.inc" +#include "sdk_depthwrite_vs20.inc" #if !defined( _X360 ) -#include "depthwrite_ps30.inc" -#include "depthwrite_vs30.inc" +#include "sdk_depthwrite_ps30.inc" +#include "sdk_depthwrite_vs30.inc" #endif -BEGIN_VS_SHADER_FLAGS( DepthWrite, "Help for Depth Write", SHADER_NOT_EDITABLE ) +BEGIN_VS_SHADER_FLAGS( SDK_DepthWrite, "Help for Depth Write", SHADER_NOT_EDITABLE ) BEGIN_SHADER_PARAMS SHADER_PARAM( ALPHATESTREFERENCE, SHADER_PARAM_TYPE_FLOAT, "", "Alpha reference value" ) @@ -76,10 +76,10 @@ BEGIN_VS_SHADER_FLAGS( DepthWrite, "Help for Depth Write", SHADER_NOT_EDITABLE ) if ( !g_pHardwareConfig->HasFastVertexTextures() ) #endif { - DECLARE_STATIC_VERTEX_SHADER( depthwrite_vs20 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_depthwrite_vs20 ); SET_STATIC_VERTEX_SHADER_COMBO( ONLY_PROJECT_POSITION, !bAlphaClip && IsX360() && !nColorDepth ); //360 needs to know if it *shouldn't* output texture coordinates to avoid shader patches SET_STATIC_VERTEX_SHADER_COMBO( COLOR_DEPTH, nColorDepth ); - SET_STATIC_VERTEX_SHADER( depthwrite_vs20 ); + SET_STATIC_VERTEX_SHADER( sdk_depthwrite_vs20 ); if ( bAlphaClip || g_pHardwareConfig->PlatformRequiresNonNullPixelShaders() || nColorDepth ) { @@ -91,15 +91,15 @@ BEGIN_VS_SHADER_FLAGS( DepthWrite, "Help for Depth Write", SHADER_NOT_EDITABLE ) if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_STATIC_PIXEL_SHADER( depthwrite_ps20b ); + DECLARE_STATIC_PIXEL_SHADER( sdk_depthwrite_ps20b ); SET_STATIC_PIXEL_SHADER_COMBO( COLOR_DEPTH, nColorDepth ); - SET_STATIC_PIXEL_SHADER( depthwrite_ps20b ); + SET_STATIC_PIXEL_SHADER( sdk_depthwrite_ps20b ); } else { - DECLARE_STATIC_PIXEL_SHADER( depthwrite_ps20 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_depthwrite_ps20 ); SET_STATIC_PIXEL_SHADER_COMBO( COLOR_DEPTH, nColorDepth ); - SET_STATIC_PIXEL_SHADER( depthwrite_ps20 ); + SET_STATIC_PIXEL_SHADER( sdk_depthwrite_ps20 ); } } } @@ -108,17 +108,17 @@ BEGIN_VS_SHADER_FLAGS( DepthWrite, "Help for Depth Write", SHADER_NOT_EDITABLE ) { SET_FLAGS2( MATERIAL_VAR2_USES_VERTEXID ); - DECLARE_STATIC_VERTEX_SHADER( depthwrite_vs30 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_depthwrite_vs30 ); SET_STATIC_VERTEX_SHADER_COMBO( ONLY_PROJECT_POSITION, 0 ); //360 only combo, and this is a PC path SET_STATIC_VERTEX_SHADER_COMBO( COLOR_DEPTH, nColorDepth ); - SET_STATIC_VERTEX_SHADER( depthwrite_vs30 ); + SET_STATIC_VERTEX_SHADER( sdk_depthwrite_vs30 ); pShaderShadow->EnableTexture( SHADER_SAMPLER0, true ); pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, true ); - DECLARE_STATIC_PIXEL_SHADER( depthwrite_ps30 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_depthwrite_ps30 ); SET_STATIC_PIXEL_SHADER_COMBO( COLOR_DEPTH, nColorDepth ); - SET_STATIC_PIXEL_SHADER( depthwrite_ps30 ); + SET_STATIC_PIXEL_SHADER( sdk_depthwrite_ps30 ); } #endif } @@ -129,7 +129,7 @@ BEGIN_VS_SHADER_FLAGS( DepthWrite, "Help for Depth Write", SHADER_NOT_EDITABLE ) if ( !g_pHardwareConfig->HasFastVertexTextures() ) #endif { - depthwrite_vs20_Dynamic_Index vshIndex; + sdk_depthwrite_vs20_Dynamic_Index vshIndex; vshIndex.SetSKINNING( pShaderAPI->GetCurrentNumBones() > 0 ); vshIndex.SetCOMPRESSED_VERTS( (int)vertexCompression ); pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() ); @@ -149,15 +149,15 @@ BEGIN_VS_SHADER_FLAGS( DepthWrite, "Help for Depth Write", SHADER_NOT_EDITABLE ) if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_DYNAMIC_PIXEL_SHADER( depthwrite_ps20b ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_depthwrite_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( ALPHACLIP, bAlphaClip ); - SET_DYNAMIC_PIXEL_SHADER( depthwrite_ps20b ); + SET_DYNAMIC_PIXEL_SHADER( sdk_depthwrite_ps20b ); } else { - DECLARE_DYNAMIC_PIXEL_SHADER( depthwrite_ps20 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_depthwrite_ps20 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( ALPHACLIP, bAlphaClip ); - SET_DYNAMIC_PIXEL_SHADER( depthwrite_ps20 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_depthwrite_ps20 ); } } #ifndef _X360 @@ -165,7 +165,7 @@ BEGIN_VS_SHADER_FLAGS( DepthWrite, "Help for Depth Write", SHADER_NOT_EDITABLE ) { SetHWMorphVertexShaderState( VERTEX_SHADER_SHADER_SPECIFIC_CONST_6, VERTEX_SHADER_SHADER_SPECIFIC_CONST_7, SHADER_VERTEXTEXTURE_SAMPLER0 ); - depthwrite_vs30_Dynamic_Index vshIndex; + sdk_depthwrite_vs30_Dynamic_Index vshIndex; vshIndex.SetSKINNING( pShaderAPI->GetCurrentNumBones() > 0 ); vshIndex.SetMORPHING( pShaderAPI->IsHWMorphingEnabled() ); vshIndex.SetCOMPRESSED_VERTS( (int)vertexCompression ); @@ -184,9 +184,9 @@ BEGIN_VS_SHADER_FLAGS( DepthWrite, "Help for Depth Write", SHADER_NOT_EDITABLE ) pShaderAPI->SetPixelShaderConstant( 0, vAlphaThreshold, 1 ); } - DECLARE_DYNAMIC_PIXEL_SHADER( depthwrite_ps30 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_depthwrite_ps30 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( ALPHACLIP, bAlphaClip ); - SET_DYNAMIC_PIXEL_SHADER( depthwrite_ps30 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_depthwrite_ps30 ); } #endif diff --git a/sp/src/materialsystem/stdshaders/emissive_scroll_blended_pass_helper.cpp b/sp/src/materialsystem/stdshaders/emissive_scroll_blended_pass_helper.cpp new file mode 100644 index 00000000..86c0e6c8 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/emissive_scroll_blended_pass_helper.cpp @@ -0,0 +1,278 @@ +//========= Copyright � 1996-2006, Valve Corporation, All rights reserved. ============// + +/* Example how to plug this into an existing shader: + + In the VMT: + // Emissive Scroll Pass + "$emissiveBlendEnabled" "1" // Enables effect + "$emissiveBlendTexture" "models/vortigaunt/vortigaunt_illum" + "$emissiveBlendBaseTexture" "Models/Vortigaunt/vortigaunt_blue" + "$emissiveBlendFlowTexture" "models/vortigaunt/vortigaunt_flow" + "$emissiveBlendTint" "[10 10 10]" + "$emissiveBlendStrength" "1.0" // Set by game code + "$emissiveBlendScrollVector" "[0.11 0.124]" + "Proxies" + { + "VortEmissive" // For setting $selfillumstrength + { + } + } + + #include "emissive_scroll_blended_pass_helper.h" + + In BEGIN_SHADER_PARAMS: + // Emissive Scroll Pass + SHADER_PARAM( EMISSIVEBLENDENABLED, SHADER_PARAM_TYPE_BOOL, "0", "Enable emissive blend pass" ) + SHADER_PARAM( EMISSIVEBLENDBASETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "self-illumination map" ) + SHADER_PARAM( EMISSIVEBLENDSCROLLVECTOR, SHADER_PARAM_TYPE_VEC2, "[0.11 0.124]", "Emissive scroll vec" ) + SHADER_PARAM( EMISSIVEBLENDSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "1.0", "Emissive blend strength" ) + SHADER_PARAM( EMISSIVEBLENDTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "self-illumination map" ) + SHADER_PARAM( EMISSIVEBLENDTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "Self-illumination tint" ) + SHADER_PARAM( EMISSIVEBLENDFLOWTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "flow map" ) + + Add this above SHADER_INIT_PARAMS() + // Emissive Scroll Pass + void SetupVarsEmissiveScrollBlendedPass( EmissiveScrollBlendedPassVars_t &info ) + { + info.m_nBlendStrength = EMISSIVEBLENDSTRENGTH; + info.m_nBaseTexture = EMISSIVEBLENDBASETEXTURE; + info.m_nFlowTexture = EMISSIVEBLENDFLOWTEXTURE; + info.m_nEmissiveTexture = EMISSIVEBLENDTEXTURE; + info.m_nEmissiveTint = EMISSIVEBLENDTINT; + info.m_nEmissiveScrollVector = EMISSIVEBLENDSCROLLVECTOR; + } + + In SHADER_INIT_PARAMS() + // Emissive Scroll Pass + if ( !params[EMISSIVEBLENDENABLED]->IsDefined() ) + { + params[EMISSIVEBLENDENABLED]->SetIntValue( 0 ); + } + else if ( params[EMISSIVEBLENDENABLED]->GetIntValue() ) + { + EmissiveScrollBlendedPassVars_t info; + SetupVarsEmissiveScrollBlendedPass( info ); + InitParamsEmissiveScrollBlendedPass( this, params, pMaterialName, info ); + } + + In SHADER_INIT + // Emissive Scroll Pass + if ( params[EMISSIVEBLENDENABLED]->GetIntValue() ) + { + EmissiveScrollBlendedPassVars_t info; + SetupVarsEmissiveScrollBlendedPass( info ); + InitEmissiveScrollBlendedPass( this, params, info ); + } + + At the very end of SHADER_DRAW + // Emissive Scroll Pass + if ( params[EMISSIVEBLENDENABLED]->GetIntValue() ) + { + // If ( snapshotting ) or ( we need to draw this frame ) + if ( ( pShaderShadow != NULL ) || ( params[EMISSIVEBLENDSTRENGTH]->GetFloatValue() > 0.0f ) ) + { + EmissiveScrollBlendedPassVars_t info; + SetupVarsEmissiveScrollBlendedPass( info ); + DrawEmissiveScrollBlendedPass( this, params, pShaderAPI, pShaderShadow, info ); + } + else // We're not snapshotting and we don't need to draw this frame + { + // Skip this pass! + Draw( false ); + } + } + +==================================================================================================== */ + +#include "BaseVSShader.h" +#include "mathlib/VMatrix.h" +#include "emissive_scroll_blended_pass_helper.h" +#include "convar.h" + +// Auto generated inc files +#include "SDK_emissive_scroll_blended_pass_vs20.inc" +#include "SDK_emissive_scroll_blended_pass_ps20.inc" +#include "SDK_emissive_scroll_blended_pass_ps20b.inc" + +#ifndef _X360 +#include "SDK_emissive_scroll_blended_pass_vs30.inc" +#include "SDK_emissive_scroll_blended_pass_ps30.inc" +#endif + +void InitParamsEmissiveScrollBlendedPass( CBaseVSShader *pShader, IMaterialVar** params, const char *pMaterialName, EmissiveScrollBlendedPassVars_t &info ) +{ + SET_FLAGS2( MATERIAL_VAR2_SUPPORTS_HW_SKINNING ); + + if ( ( info.m_nEmissiveScrollVector != -1 ) && ( !params[info.m_nEmissiveScrollVector]->IsDefined() ) ) + { + params[info.m_nEmissiveScrollVector]->SetVecValue( kDefaultEmissiveScrollVector, 4 ); + } + + if ( ( info.m_nBlendStrength != -1 ) && ( !params[info.m_nBlendStrength]->IsDefined() ) ) + { + params[info.m_nBlendStrength]->SetFloatValue( kDefaultEmissiveBlendStrength ); + } + + if ( ( info.m_nEmissiveTint != -1 ) && ( !params[info.m_nEmissiveTint]->IsDefined() ) ) + { + params[info.m_nEmissiveTint]->SetVecValue( kDefaultEmissiveTint, 4 ); + } + + SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nTime, 0.0f ); +} + +void InitEmissiveScrollBlendedPass( CBaseVSShader *pShader, IMaterialVar** params, EmissiveScrollBlendedPassVars_t &info ) +{ + // Load textures + pShader->LoadTexture( info.m_nBaseTexture ); + pShader->LoadTexture( info.m_nFlowTexture ); + pShader->LoadTexture( info.m_nEmissiveTexture ); +} + +void DrawEmissiveScrollBlendedPass( CBaseVSShader *pShader, IMaterialVar** params, IShaderDynamicAPI *pShaderAPI, + IShaderShadow* pShaderShadow, EmissiveScrollBlendedPassVars_t &info, VertexCompressionType_t vertexCompression ) +{ + SHADOW_STATE + { + // Reset shadow state manually since we're drawing from two materials + pShader->SetInitialShadowState(); + + // Set stream format (note that this shader supports compression) + unsigned int flags = VERTEX_POSITION | VERTEX_NORMAL | VERTEX_FORMAT_COMPRESSED; + int nTexCoordCount = 1; + int userDataSize = 0; + pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, NULL, userDataSize ); + +#ifndef _X360 + if ( !g_pHardwareConfig->HasFastVertexTextures() ) +#endif + { + // Vertex Shader + DECLARE_STATIC_VERTEX_SHADER( sdk_emissive_scroll_blended_pass_vs20 ); + SET_STATIC_VERTEX_SHADER( sdk_emissive_scroll_blended_pass_vs20 ); + + // Pixel Shader + if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + DECLARE_STATIC_PIXEL_SHADER( sdk_emissive_scroll_blended_pass_ps20b ); + SET_STATIC_PIXEL_SHADER( sdk_emissive_scroll_blended_pass_ps20b ); + } + else + { + DECLARE_STATIC_PIXEL_SHADER( sdk_emissive_scroll_blended_pass_ps20 ); + SET_STATIC_PIXEL_SHADER( sdk_emissive_scroll_blended_pass_ps20 ); + } + } +#ifndef _X360 + else + { + // The vertex shader uses the vertex id stream + SET_FLAGS2( MATERIAL_VAR2_USES_VERTEXID ); + + DECLARE_STATIC_VERTEX_SHADER( sdk_emissive_scroll_blended_pass_vs30 ); + SET_STATIC_VERTEX_SHADER( sdk_emissive_scroll_blended_pass_vs30 ); + + DECLARE_STATIC_PIXEL_SHADER( sdk_emissive_scroll_blended_pass_ps30 ); + SET_STATIC_PIXEL_SHADER( sdk_emissive_scroll_blended_pass_ps30 ); + } +#endif + + // Textures + pShaderShadow->EnableTexture( SHADER_SAMPLER0, true ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, true ); + pShaderShadow->EnableTexture( SHADER_SAMPLER1, true ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, false ); // Flow texture not sRGB + pShaderShadow->EnableTexture( SHADER_SAMPLER2, true ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER2, true ); + pShaderShadow->EnableSRGBWrite( true ); + + // Blending + pShader->EnableAlphaBlending( SHADER_BLEND_ONE, SHADER_BLEND_ONE ); + pShaderShadow->EnableAlphaWrites( false ); + } + DYNAMIC_STATE + { + // Reset render state manually since we're drawing from two materials + pShaderAPI->SetDefaultState(); + +#ifndef _X360 + if ( !g_pHardwareConfig->HasFastVertexTextures() ) +#endif + { + // Set Vertex Shader Combos + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_emissive_scroll_blended_pass_vs20 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); + SET_DYNAMIC_VERTEX_SHADER( sdk_emissive_scroll_blended_pass_vs20 ); + + // Set Vertex Shader Constants + // None? + + // Set Pixel Shader Combos + if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_emissive_scroll_blended_pass_ps20b ); + SET_DYNAMIC_PIXEL_SHADER( sdk_emissive_scroll_blended_pass_ps20b ); + } + else + { + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_emissive_scroll_blended_pass_ps20 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_emissive_scroll_blended_pass_ps20 ); + } + } +#ifndef _X360 + else + { + pShader->SetHWMorphVertexShaderState( VERTEX_SHADER_SHADER_SPECIFIC_CONST_6, VERTEX_SHADER_SHADER_SPECIFIC_CONST_7, SHADER_VERTEXTEXTURE_SAMPLER0 ); + + // Set Vertex Shader Combos + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_emissive_scroll_blended_pass_vs30 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( MORPHING, pShaderAPI->IsHWMorphingEnabled() ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); + SET_DYNAMIC_VERTEX_SHADER( sdk_emissive_scroll_blended_pass_vs30 ); + + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_emissive_scroll_blended_pass_ps30 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_emissive_scroll_blended_pass_ps30 ); + } +#endif + + // Bind textures + pShader->BindTexture( SHADER_SAMPLER0, info.m_nBaseTexture ); + pShader->BindTexture( SHADER_SAMPLER1, info.m_nFlowTexture ); + pShader->BindTexture( SHADER_SAMPLER2, info.m_nEmissiveTexture ); + + // Set Pixel Shader Constants + //float vConstZero[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + + // This brings in the electricity and the second base texture when the second base texture is present + float vPsConst0[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + if (1) + { + // Overall blend strength + vPsConst0[0] = IS_PARAM_DEFINED( info.m_nBlendStrength ) ? params[info.m_nBlendStrength]->GetFloatValue() : kDefaultEmissiveBlendStrength; + if ( vPsConst0[0] < 0.0f ) + vPsConst0[0] = 0.0f; + if ( vPsConst0[0] > 1.0f ) + vPsConst0[0] = 1.0f; + + // Time % 1000 for scrolling + vPsConst0[1] = IS_PARAM_DEFINED( info.m_nTime ) && params[info.m_nTime]->GetFloatValue() > 0.0f ? params[info.m_nTime]->GetFloatValue() : pShaderAPI->CurrentTime(); + vPsConst0[1] -= (float)( (int)( vPsConst0[1] / 1000.0f ) ) * 1000.0f; + + // Dest alpha value for warping mask - NOTE: If we want to use this, we have to modify the blending mode above! + //if ( ( params[info.m_nWarpParam]->GetFloatValue() > 0.0f ) && ( params[info.m_nWarpParam]->GetFloatValue() < 1.0f ) ) + // tmpVec[2] = 1.0f; + //else + // tmpVec[2] = 0.0f; + } + pShaderAPI->SetPixelShaderConstant( 0, vPsConst0, 1 ); + + // Scroll vector + pShaderAPI->SetPixelShaderConstant( 1, IS_PARAM_DEFINED( info.m_nEmissiveScrollVector ) ? params[info.m_nEmissiveScrollVector]->GetVecValue() : kDefaultEmissiveScrollVector, 1 ); + + // Self illum tint + pShaderAPI->SetPixelShaderConstant( 2, IS_PARAM_DEFINED( info.m_nEmissiveTint ) ? params[info.m_nEmissiveTint]->GetVecValue() : kDefaultEmissiveTint, 1 ); + } + pShader->Draw(); +} \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/emissive_scroll_blended_pass_helper.h b/sp/src/materialsystem/stdshaders/emissive_scroll_blended_pass_helper.h new file mode 100644 index 00000000..8617fa6a --- /dev/null +++ b/sp/src/materialsystem/stdshaders/emissive_scroll_blended_pass_helper.h @@ -0,0 +1,45 @@ +//========= Copyright ? 1996-2006, Valve Corporation, All rights reserved. ============// + +#ifndef EMISSIVE_SCROLL_BLENDED_PASS_HELPER_H +#define EMISSIVE_SCROLL_BLENDED_PASS_HELPER_H +#ifdef _WIN32 +#pragma once +#endif + +#include + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +class CBaseVSShader; +class IMaterialVar; +class IShaderDynamicAPI; +class IShaderShadow; + +//----------------------------------------------------------------------------- +// Init params/ init/ draw methods +//----------------------------------------------------------------------------- +struct EmissiveScrollBlendedPassVars_t +{ + EmissiveScrollBlendedPassVars_t() { memset( this, 0xFF, sizeof(EmissiveScrollBlendedPassVars_t) ); } + + int m_nBlendStrength; // Amount this layer is blended in globally + int m_nBaseTexture; + int m_nFlowTexture; + int m_nEmissiveTexture; + int m_nEmissiveTint; + int m_nEmissiveScrollVector; + int m_nTime; +}; + +// Default values (Arrays should only be vec[4]) +static const float kDefaultEmissiveBlendStrength = 0.0f; +static const float kDefaultEmissiveTint[4] = { 1.0f, 1.0f, 1.0f, 0.0f } ; +static const float kDefaultEmissiveScrollVector[4] = { 0.11f, 0.124f, 0.0f, 0.0f } ; + +void InitParamsEmissiveScrollBlendedPass( CBaseVSShader *pShader, IMaterialVar** params, const char *pMaterialName, EmissiveScrollBlendedPassVars_t &info ); +void InitEmissiveScrollBlendedPass( CBaseVSShader *pShader, IMaterialVar** params, EmissiveScrollBlendedPassVars_t &info ); +void DrawEmissiveScrollBlendedPass( CBaseVSShader *pShader, IMaterialVar** params, IShaderDynamicAPI *pShaderAPI, + IShaderShadow* pShaderShadow, EmissiveScrollBlendedPassVars_t &info, VertexCompressionType_t vertexCompression ); + +#endif // EMISSIVE_SCROLL_BLENDED_PASS_HELPER_H \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/example_model_ps20b.fxc b/sp/src/materialsystem/stdshaders/example_model_ps20b.fxc index 29ed629a..00ff3499 100644 --- a/sp/src/materialsystem/stdshaders/example_model_ps20b.fxc +++ b/sp/src/materialsystem/stdshaders/example_model_ps20b.fxc @@ -80,7 +80,7 @@ float4 main( PS_INPUT i ) : COLOR float3 result = baseColor.rgb * g_DiffuseModulation.rgb * diffuseLighting; float alpha = g_DiffuseModulation.a * baseColor.a; - float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.z, i.worldPos.z, i.projPos.z ); + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.xyz, i.worldPos, i.projPos.z ); #if WRITEWATERFOGTODESTALPHA && ( PIXELFOGTYPE == PIXEL_FOG_TYPE_HEIGHT ) alpha = fogFactor; diff --git a/sp/src/materialsystem/stdshaders/eye_refract.cpp b/sp/src/materialsystem/stdshaders/eye_refract.cpp index 87528028..9e1e870c 100644 --- a/sp/src/materialsystem/stdshaders/eye_refract.cpp +++ b/sp/src/materialsystem/stdshaders/eye_refract.cpp @@ -8,8 +8,8 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" -DEFINE_FALLBACK_SHADER( EyeRefract, EyeRefract_dx9 ) -BEGIN_VS_SHADER( EyeRefract_dx9, "Help for Eyes" ) +DEFINE_FALLBACK_SHADER( SDK_EyeRefract, SDK_EyeRefract_dx9 ) +BEGIN_VS_SHADER( SDK_EyeRefract_dx9, "Help for SDK_EyeRefract" ) BEGIN_SHADER_PARAMS SHADER_PARAM( IRIS, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "iris texture" ) SHADER_PARAM( IRISFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "frame for the iris texture" ) diff --git a/sp/src/materialsystem/stdshaders/eye_refract_helper.cpp b/sp/src/materialsystem/stdshaders/eye_refract_helper.cpp index af4d2c08..605155e7 100644 --- a/sp/src/materialsystem/stdshaders/eye_refract_helper.cpp +++ b/sp/src/materialsystem/stdshaders/eye_refract_helper.cpp @@ -6,16 +6,16 @@ #include "cpp_shader_constant_register_map.h" -#include "eyes_flashlight_vs11.inc" -#include "eyes_flashlight_ps11.inc" +//#include "eyes_flashlight_vs11.inc" +//#include "eyes_flashlight_ps11.inc" -#include "eye_refract_vs20.inc" -#include "eye_refract_ps20.inc" -#include "eye_refract_ps20b.inc" +#include "sdk_eye_refract_vs20.inc" +#include "sdk_eye_refract_ps20.inc" +#include "sdk_eye_refract_ps20b.inc" #ifndef _X360 -#include "eye_refract_vs30.inc" -#include "eye_refract_ps30.inc" +#include "sdk_eye_refract_vs30.inc" +#include "sdk_eye_refract_ps30.inc" #endif #include "convar.h" @@ -145,25 +145,25 @@ void Draw_Eyes_Refract_Internal( CBaseVSShader *pShader, IMaterialVar** params, if ( !g_pHardwareConfig->HasFastVertexTextures() ) #endif { - DECLARE_STATIC_VERTEX_SHADER( eye_refract_vs20 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_eye_refract_vs20 ); SET_STATIC_VERTEX_SHADER_COMBO( HALFLAMBERT, IS_FLAG_SET( MATERIAL_VAR_HALFLAMBERT ) ); SET_STATIC_VERTEX_SHADER_COMBO( INTRO, bIntro ? 1 : 0 ); SET_STATIC_VERTEX_SHADER_COMBO( FLASHLIGHT, bDrawFlashlightAdditivePass ? 1 : 0 ); SET_STATIC_VERTEX_SHADER_COMBO( LIGHTWARPTEXTURE, bDiffuseWarp ? 1 : 0 ); - SET_STATIC_VERTEX_SHADER( eye_refract_vs20 ); + SET_STATIC_VERTEX_SHADER( sdk_eye_refract_vs20 ); if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { bool bSphereTexKillCombo = IS_PARAM_DEFINED( info.m_nSphereTexKillCombo ) ? ( params[info.m_nSphereTexKillCombo]->GetIntValue() ? true : false ) : ( kDefaultSphereTexKillCombo ? true : false ); bool bRayTraceSphere = IS_PARAM_DEFINED( info.m_nRaytraceSphere ) ? ( params[info.m_nRaytraceSphere]->GetIntValue() ? true : false ) : ( kDefaultRaytraceSphere ? true : false ); - DECLARE_STATIC_PIXEL_SHADER( eye_refract_ps20b ); + DECLARE_STATIC_PIXEL_SHADER( sdk_eye_refract_ps20b ); SET_STATIC_PIXEL_SHADER_COMBO( SPHERETEXKILLCOMBO, bSphereTexKillCombo ? 1 : 0 ); SET_STATIC_PIXEL_SHADER_COMBO( RAYTRACESPHERE, bRayTraceSphere ? 1 : 0 ); SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHT, bDrawFlashlightAdditivePass ? 1 : 0 ); SET_STATIC_PIXEL_SHADER_COMBO( LIGHTWARPTEXTURE, bDiffuseWarp ? 1 : 0 ); SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, nShadowFilterMode ); - SET_STATIC_PIXEL_SHADER( eye_refract_ps20b ); + SET_STATIC_PIXEL_SHADER( sdk_eye_refract_ps20b ); if ( bDrawFlashlightAdditivePass == true ) { @@ -174,10 +174,10 @@ void Draw_Eyes_Refract_Internal( CBaseVSShader *pShader, IMaterialVar** params, } else { - DECLARE_STATIC_PIXEL_SHADER( eye_refract_ps20 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_eye_refract_ps20 ); SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHT, bDrawFlashlightAdditivePass ? 1 : 0 ); SET_STATIC_PIXEL_SHADER_COMBO( LIGHTWARPTEXTURE, bDiffuseWarp ? 1 : 0 ); - SET_STATIC_PIXEL_SHADER( eye_refract_ps20 ); + SET_STATIC_PIXEL_SHADER( sdk_eye_refract_ps20 ); } } #ifndef _X360 @@ -186,23 +186,23 @@ void Draw_Eyes_Refract_Internal( CBaseVSShader *pShader, IMaterialVar** params, // The vertex shader uses the vertex id stream SET_FLAGS2( MATERIAL_VAR2_USES_VERTEXID ); - DECLARE_STATIC_VERTEX_SHADER( eye_refract_vs30 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_eye_refract_vs30 ); SET_STATIC_VERTEX_SHADER_COMBO( HALFLAMBERT, IS_FLAG_SET( MATERIAL_VAR_HALFLAMBERT ) ); SET_STATIC_VERTEX_SHADER_COMBO( INTRO, bIntro ? 1 : 0 ); SET_STATIC_VERTEX_SHADER_COMBO( FLASHLIGHT, bDrawFlashlightAdditivePass ? 1 : 0 ); SET_STATIC_VERTEX_SHADER_COMBO( LIGHTWARPTEXTURE, bDiffuseWarp ? 1 : 0 ); - SET_STATIC_VERTEX_SHADER( eye_refract_vs30 ); + SET_STATIC_VERTEX_SHADER( sdk_eye_refract_vs30 ); bool bSphereTexKillCombo = IS_PARAM_DEFINED( info.m_nSphereTexKillCombo ) ? ( params[info.m_nSphereTexKillCombo]->GetIntValue() ? true : false ) : ( kDefaultSphereTexKillCombo ? true : false ); bool bRayTraceSphere = IS_PARAM_DEFINED( info.m_nRaytraceSphere ) ? ( params[info.m_nRaytraceSphere]->GetIntValue() ? true : false ) : ( kDefaultRaytraceSphere ? true : false ); - DECLARE_STATIC_PIXEL_SHADER( eye_refract_ps30 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_eye_refract_ps30 ); SET_STATIC_PIXEL_SHADER_COMBO( SPHERETEXKILLCOMBO, bSphereTexKillCombo ? 1 : 0 ); SET_STATIC_PIXEL_SHADER_COMBO( RAYTRACESPHERE, bRayTraceSphere ? 1 : 0 ); SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHT, bDrawFlashlightAdditivePass ? 1 : 0 ); SET_STATIC_PIXEL_SHADER_COMBO( LIGHTWARPTEXTURE, bDiffuseWarp ? 1 : 0 ); SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, nShadowFilterMode ); - SET_STATIC_PIXEL_SHADER( eye_refract_ps30 ); + SET_STATIC_PIXEL_SHADER( sdk_eye_refract_ps30 ); if ( bDrawFlashlightAdditivePass == true ) { @@ -284,21 +284,21 @@ void Draw_Eyes_Refract_Internal( CBaseVSShader *pShader, IMaterialVar** params, if ( !g_pHardwareConfig->HasFastVertexTextures() ) #endif { - DECLARE_DYNAMIC_VERTEX_SHADER( eye_refract_vs20 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_eye_refract_vs20 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DYNAMIC_LIGHT, lightState.HasDynamicLight() ); SET_DYNAMIC_VERTEX_SHADER_COMBO( STATIC_LIGHT, lightState.m_bStaticLight ? 1 : 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( NUM_LIGHTS, lightState.m_nNumLights ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); - SET_DYNAMIC_VERTEX_SHADER( eye_refract_vs20 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_eye_refract_vs20 ); } #ifndef _X360 else { pShader->SetHWMorphVertexShaderState( VERTEX_SHADER_SHADER_SPECIFIC_CONST_10, VERTEX_SHADER_SHADER_SPECIFIC_CONST_11, SHADER_VERTEXTEXTURE_SAMPLER0 ); - DECLARE_DYNAMIC_VERTEX_SHADER( eye_refract_vs30 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_eye_refract_vs30 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DYNAMIC_LIGHT, lightState.HasDynamicLight() ); @@ -306,7 +306,7 @@ void Draw_Eyes_Refract_Internal( CBaseVSShader *pShader, IMaterialVar** params, SET_DYNAMIC_VERTEX_SHADER_COMBO( NUM_LIGHTS, lightState.m_nNumLights ); SET_DYNAMIC_VERTEX_SHADER_COMBO( MORPHING, pShaderAPI->IsHWMorphingEnabled() ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); - SET_DYNAMIC_VERTEX_SHADER( eye_refract_vs30 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_eye_refract_vs30 ); } #endif @@ -361,25 +361,25 @@ void Draw_Eyes_Refract_Internal( CBaseVSShader *pShader, IMaterialVar** params, { if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_DYNAMIC_PIXEL_SHADER( eye_refract_ps20b ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_eye_refract_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( NUM_LIGHTS, lightState.m_nNumLights ); SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, bFlashlightShadows ); - SET_DYNAMIC_PIXEL_SHADER( eye_refract_ps20b ); + SET_DYNAMIC_PIXEL_SHADER( sdk_eye_refract_ps20b ); } else // ps.2.0 { - DECLARE_DYNAMIC_PIXEL_SHADER( eye_refract_ps20 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_eye_refract_ps20 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( NUM_LIGHTS, lightState.m_nNumLights ); - SET_DYNAMIC_PIXEL_SHADER( eye_refract_ps20 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_eye_refract_ps20 ); } } #ifndef _X360 else { - DECLARE_DYNAMIC_PIXEL_SHADER( eye_refract_ps30 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_eye_refract_ps30 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( NUM_LIGHTS, lightState.m_nNumLights ); SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, bFlashlightShadows ); - SET_DYNAMIC_PIXEL_SHADER( eye_refract_ps30 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_eye_refract_ps30 ); } #endif diff --git a/sp/src/materialsystem/stdshaders/eyeball.cpp b/sp/src/materialsystem/stdshaders/eyeball.cpp index 7113585d..f1ec2117 100644 --- a/sp/src/materialsystem/stdshaders/eyeball.cpp +++ b/sp/src/materialsystem/stdshaders/eyeball.cpp @@ -9,7 +9,7 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" -BEGIN_VS_SHADER( Eyeball, "Help for EyeBall" ) +BEGIN_VS_SHADER( SDK_Eyeball, "Help for SDK_EyeBall" ) BEGIN_SHADER_PARAMS SHADER_PARAM_OVERRIDE( BASETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "models/alyx/pupil_l", "iris texture", 0 ) diff --git a/sp/src/materialsystem/stdshaders/eyeglint_dx9.cpp b/sp/src/materialsystem/stdshaders/eyeglint_dx9.cpp index d2662e6d..ffdd46a1 100644 --- a/sp/src/materialsystem/stdshaders/eyeglint_dx9.cpp +++ b/sp/src/materialsystem/stdshaders/eyeglint_dx9.cpp @@ -9,12 +9,12 @@ #include "BaseVSShader.h" #include "shaderlib/cshader.h" -#include "eyeglint_vs20.inc" -#include "eyeglint_ps20.inc" -#include "eyeglint_ps20b.inc" +#include "sdk_eyeglint_vs20.inc" +#include "sdk_eyeglint_ps20.inc" +#include "sdk_eyeglint_ps20b.inc" -DEFINE_FALLBACK_SHADER( EyeGlint, EyeGlint_dx9 ) -BEGIN_VS_SHADER( EyeGlint_dx9, "Help for EyeGlint" ) +DEFINE_FALLBACK_SHADER( SDK_EyeGlint, SDK_EyeGlint_dx9 ) +BEGIN_VS_SHADER( SDK_EyeGlint_dx9, "Help for SDK_EyeGlint" ) BEGIN_SHADER_PARAMS END_SHADER_PARAMS @@ -48,18 +48,18 @@ SHADER_DRAW pShaderShadow->EnableSRGBWrite( false ); // linear texture - DECLARE_STATIC_VERTEX_SHADER( eyeglint_vs20 ); - SET_STATIC_VERTEX_SHADER( eyeglint_vs20 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_eyeglint_vs20 ); + SET_STATIC_VERTEX_SHADER( sdk_eyeglint_vs20 ); - SET_STATIC_PS2X_PIXEL_SHADER_NO_COMBOS( eyeglint ); + SET_STATIC_PS2X_PIXEL_SHADER_NO_COMBOS( sdk_eyeglint ); } DYNAMIC_STATE { - DECLARE_DYNAMIC_VERTEX_SHADER( eyeglint_vs20 ); - SET_DYNAMIC_VERTEX_SHADER( eyeglint_vs20 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_eyeglint_vs20 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_eyeglint_vs20 ); - SET_DYNAMIC_PS2X_PIXEL_SHADER_NO_COMBOS( eyeglint ); + SET_DYNAMIC_PS2X_PIXEL_SHADER_NO_COMBOS( sdk_eyeglint ); } Draw(); } diff --git a/sp/src/materialsystem/stdshaders/eyes.cpp b/sp/src/materialsystem/stdshaders/eyes.cpp index 7aa4738f..2a0c5908 100644 --- a/sp/src/materialsystem/stdshaders/eyes.cpp +++ b/sp/src/materialsystem/stdshaders/eyes.cpp @@ -13,10 +13,10 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" -DEFINE_FALLBACK_SHADER( eyes, Eyes_dx8 ) +DEFINE_FALLBACK_SHADER( SDK_Eyes, SDK_Eyes_dx8 ) -BEGIN_VS_SHADER( Eyes_dx8, - "Help for Eyes" ) +BEGIN_VS_SHADER( SDK_Eyes_dx8, + "Help for SDK_Eyes" ) BEGIN_SHADER_PARAMS SHADER_PARAM_OVERRIDE( BASETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "models/alyx/eyeball_l", "iris texture", 0 ) diff --git a/sp/src/materialsystem/stdshaders/eyes_dx8_dx9_helper.cpp b/sp/src/materialsystem/stdshaders/eyes_dx8_dx9_helper.cpp index 97e6ed32..618f55ae 100644 --- a/sp/src/materialsystem/stdshaders/eyes_dx8_dx9_helper.cpp +++ b/sp/src/materialsystem/stdshaders/eyes_dx8_dx9_helper.cpp @@ -9,24 +9,24 @@ #include "mathlib/vmatrix.h" #include "eyes_dx8_dx9_helper.h" #include "cpp_shader_constant_register_map.h" -#include "Eyes.inc" -#include "eyes_flashlight_vs11.inc" -#include "eyes_flashlight_ps11.inc" +#include "SDK_Eyes.inc" +#include "sdk_eyes_flashlight_vs11.inc" +#include "sdk_eyes_flashlight_ps11.inc" #ifdef STDSHADER_DX9_DLL_EXPORT -#include "eyes_vs20.inc" -#include "eyes_ps20.inc" -#include "eyes_ps20b.inc" -#include "eyes_flashlight_vs20.inc" -#include "eyes_flashlight_ps20.inc" -#include "eyes_flashlight_ps20b.inc" +#include "sdk_eyes_vs20.inc" +#include "sdk_eyes_ps20.inc" +#include "sdk_eyes_ps20b.inc" +#include "sdk_eyes_flashlight_vs20.inc" +#include "sdk_eyes_flashlight_ps20.inc" +#include "sdk_eyes_flashlight_ps20b.inc" #ifndef _X360 -#include "eyes_vs30.inc" -#include "eyes_ps30.inc" -#include "eyes_flashlight_vs30.inc" -#include "eyes_flashlight_ps30.inc" +#include "sdk_eyes_vs30.inc" +#include "sdk_eyes_ps30.inc" +#include "sdk_eyes_flashlight_vs30.inc" +#include "sdk_eyes_flashlight_ps30.inc" #endif #endif @@ -137,19 +137,19 @@ static void DrawFlashlight( bool bDX9, CBaseVSShader *pShader, IMaterialVar** pa if ( !g_pHardwareConfig->HasFastVertexTextures() ) #endif { - DECLARE_STATIC_VERTEX_SHADER( eyes_flashlight_vs20 ); - SET_STATIC_VERTEX_SHADER( eyes_flashlight_vs20 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_eyes_flashlight_vs20 ); + SET_STATIC_VERTEX_SHADER( sdk_eyes_flashlight_vs20 ); if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_STATIC_PIXEL_SHADER( eyes_flashlight_ps20b ); + DECLARE_STATIC_PIXEL_SHADER( sdk_eyes_flashlight_ps20b ); SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, nShadowFilterMode ); - SET_STATIC_PIXEL_SHADER( eyes_flashlight_ps20b ); + SET_STATIC_PIXEL_SHADER( sdk_eyes_flashlight_ps20b ); } else { - DECLARE_STATIC_PIXEL_SHADER( eyes_flashlight_ps20 ); - SET_STATIC_PIXEL_SHADER( eyes_flashlight_ps20 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_eyes_flashlight_ps20 ); + SET_STATIC_PIXEL_SHADER( sdk_eyes_flashlight_ps20 ); } } #ifndef _X360 @@ -158,12 +158,12 @@ static void DrawFlashlight( bool bDX9, CBaseVSShader *pShader, IMaterialVar** pa // The vertex shader uses the vertex id stream SET_FLAGS2( MATERIAL_VAR2_USES_VERTEXID ); - DECLARE_STATIC_VERTEX_SHADER( eyes_flashlight_vs30 ); - SET_STATIC_VERTEX_SHADER( eyes_flashlight_vs30 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_eyes_flashlight_vs30 ); + SET_STATIC_VERTEX_SHADER( sdk_eyes_flashlight_vs30 ); - DECLARE_STATIC_PIXEL_SHADER( eyes_flashlight_ps30 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_eyes_flashlight_ps30 ); SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, nShadowFilterMode ); - SET_STATIC_PIXEL_SHADER( eyes_flashlight_ps30 ); + SET_STATIC_PIXEL_SHADER( sdk_eyes_flashlight_ps30 ); } #endif @@ -184,11 +184,11 @@ static void DrawFlashlight( bool bDX9, CBaseVSShader *pShader, IMaterialVar** pa #endif { // DX8 uses old asm shaders - eyes_flashlight_vs11_Static_Index vshIndex; - pShaderShadow->SetVertexShader( "eyes_flashlight_vs11", vshIndex.GetIndex() ); + sdk_eyes_flashlight_vs11_Static_Index vshIndex; + pShaderShadow->SetVertexShader( "sdk_eyes_flashlight_vs11", vshIndex.GetIndex() ); - eyes_flashlight_ps11_Static_Index pshIndex; - pShaderShadow->SetPixelShader( "eyes_flashlight_ps11", pshIndex.GetIndex() ); + sdk_eyes_flashlight_ps11_Static_Index pshIndex; + pShaderShadow->SetPixelShader( "sdk_eyes_flashlight_ps11", pshIndex.GetIndex() ); } pShader->FogToBlack(); @@ -220,23 +220,23 @@ static void DrawFlashlight( bool bDX9, CBaseVSShader *pShader, IMaterialVar** pa if ( !g_pHardwareConfig->HasFastVertexTextures() ) #endif { - DECLARE_DYNAMIC_VERTEX_SHADER( eyes_flashlight_vs20 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_eyes_flashlight_vs20 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); - SET_DYNAMIC_VERTEX_SHADER( eyes_flashlight_vs20 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_eyes_flashlight_vs20 ); } #ifndef _X360 else { pShader->SetHWMorphVertexShaderState( VERTEX_SHADER_SHADER_SPECIFIC_CONST_10, VERTEX_SHADER_SHADER_SPECIFIC_CONST_11, SHADER_VERTEXTEXTURE_SAMPLER0 ); - DECLARE_DYNAMIC_VERTEX_SHADER( eyes_flashlight_vs30 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_eyes_flashlight_vs30 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( MORPHING, pShaderAPI->IsHWMorphingEnabled() ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); - SET_DYNAMIC_VERTEX_SHADER( eyes_flashlight_vs30 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_eyes_flashlight_vs30 ); } #endif @@ -267,27 +267,27 @@ static void DrawFlashlight( bool bDX9, CBaseVSShader *pShader, IMaterialVar** pa { if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_DYNAMIC_PIXEL_SHADER( eyes_flashlight_ps20b ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_eyes_flashlight_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, flashlightState.m_bEnableShadows && ( pFlashlightDepthTexture != NULL ) ); - SET_DYNAMIC_PIXEL_SHADER( eyes_flashlight_ps20b ); + SET_DYNAMIC_PIXEL_SHADER( sdk_eyes_flashlight_ps20b ); SetDepthFlashlightParams( pShader, pShaderAPI, worldToTexture, flashlightState ); } else { - DECLARE_DYNAMIC_PIXEL_SHADER( eyes_flashlight_ps20 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_eyes_flashlight_ps20 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - SET_DYNAMIC_PIXEL_SHADER( eyes_flashlight_ps20 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_eyes_flashlight_ps20 ); } } #ifndef _X360 else { - DECLARE_DYNAMIC_PIXEL_SHADER( eyes_flashlight_ps30 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_eyes_flashlight_ps30 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, flashlightState.m_bEnableShadows && ( pFlashlightDepthTexture != NULL ) ); - SET_DYNAMIC_PIXEL_SHADER( eyes_flashlight_ps30 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_eyes_flashlight_ps30 ); SetDepthFlashlightParams( pShader, pShaderAPI, worldToTexture, flashlightState ); } @@ -296,12 +296,12 @@ static void DrawFlashlight( bool bDX9, CBaseVSShader *pShader, IMaterialVar** pa else // older asm shaders for DX8 #endif { - eyes_flashlight_vs11_Dynamic_Index vshIndex; + sdk_eyes_flashlight_vs11_Dynamic_Index vshIndex; vshIndex.SetDOWATERFOG( pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); vshIndex.SetSKINNING( pShaderAPI->GetCurrentNumBones() > 0 ); pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() ); - eyes_flashlight_ps11_Dynamic_Index pshIndex; + sdk_eyes_flashlight_ps11_Dynamic_Index pshIndex; pShaderAPI->SetPixelShaderIndex( pshIndex.GetIndex() ); } @@ -343,21 +343,21 @@ static void DrawUsingVertexShader( bool bDX9, CBaseVSShader *pShader, IMaterialV { bool bUseStaticControlFlow = g_pHardwareConfig->SupportsStaticControlFlow(); - DECLARE_STATIC_VERTEX_SHADER( eyes_vs20 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_eyes_vs20 ); SET_STATIC_VERTEX_SHADER_COMBO( HALFLAMBERT, IS_FLAG_SET( MATERIAL_VAR_HALFLAMBERT ) ); SET_STATIC_VERTEX_SHADER_COMBO( INTRO, params[info.m_nIntro]->GetIntValue() ? 1 : 0 ); SET_STATIC_VERTEX_SHADER_COMBO( USE_STATIC_CONTROL_FLOW, bUseStaticControlFlow ); - SET_STATIC_VERTEX_SHADER( eyes_vs20 ); + SET_STATIC_VERTEX_SHADER( sdk_eyes_vs20 ); if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_STATIC_PIXEL_SHADER( eyes_ps20b ); - SET_STATIC_PIXEL_SHADER( eyes_ps20b ); + DECLARE_STATIC_PIXEL_SHADER( sdk_eyes_ps20b ); + SET_STATIC_PIXEL_SHADER( sdk_eyes_ps20b ); } else { - DECLARE_STATIC_PIXEL_SHADER( eyes_ps20 ); - SET_STATIC_PIXEL_SHADER( eyes_ps20 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_eyes_ps20 ); + SET_STATIC_PIXEL_SHADER( sdk_eyes_ps20 ); } } #ifndef _X360 @@ -366,13 +366,13 @@ static void DrawUsingVertexShader( bool bDX9, CBaseVSShader *pShader, IMaterialV // The vertex shader uses the vertex id stream SET_FLAGS2( MATERIAL_VAR2_USES_VERTEXID ); - DECLARE_STATIC_VERTEX_SHADER( eyes_vs30 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_eyes_vs30 ); SET_STATIC_VERTEX_SHADER_COMBO( HALFLAMBERT, IS_FLAG_SET( MATERIAL_VAR_HALFLAMBERT ) ); SET_STATIC_VERTEX_SHADER_COMBO( INTRO, params[info.m_nIntro]->GetIntValue() ? 1 : 0 ); - SET_STATIC_VERTEX_SHADER( eyes_vs30 ); + SET_STATIC_VERTEX_SHADER( sdk_eyes_vs30 ); - DECLARE_STATIC_PIXEL_SHADER( eyes_ps30 ); - SET_STATIC_PIXEL_SHADER( eyes_ps30 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_eyes_ps30 ); + SET_STATIC_PIXEL_SHADER( sdk_eyes_ps30 ); } #endif // On DX9, get the gamma read and write correct @@ -383,7 +383,7 @@ static void DrawUsingVertexShader( bool bDX9, CBaseVSShader *pShader, IMaterialV else #endif { - eyes_Static_Index vshIndex; + sdk_eyes_Static_Index vshIndex; vshIndex.SetHALF_LAMBERT( IS_FLAG_SET( MATERIAL_VAR_HALFLAMBERT ) ); pShaderShadow->SetVertexShader( "Eyes", vshIndex.GetIndex() ); @@ -417,28 +417,28 @@ static void DrawUsingVertexShader( bool bDX9, CBaseVSShader *pShader, IMaterialV { bool bUseStaticControlFlow = g_pHardwareConfig->SupportsStaticControlFlow(); - DECLARE_DYNAMIC_VERTEX_SHADER( eyes_vs20 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_eyes_vs20 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DYNAMIC_LIGHT, lightState.HasDynamicLight() ); SET_DYNAMIC_VERTEX_SHADER_COMBO( STATIC_LIGHT, lightState.m_bStaticLight ? 1 : 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); SET_DYNAMIC_VERTEX_SHADER_COMBO( NUM_LIGHTS, bUseStaticControlFlow ? 0 : lightState.m_nNumLights ); - SET_DYNAMIC_VERTEX_SHADER( eyes_vs20 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_eyes_vs20 ); } #ifndef _X360 else { pShader->SetHWMorphVertexShaderState( VERTEX_SHADER_SHADER_SPECIFIC_CONST_7, VERTEX_SHADER_SHADER_SPECIFIC_CONST_8, SHADER_VERTEXTEXTURE_SAMPLER0 ); - DECLARE_DYNAMIC_VERTEX_SHADER( eyes_vs30 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_eyes_vs30 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DYNAMIC_LIGHT, lightState.HasDynamicLight() ); SET_DYNAMIC_VERTEX_SHADER_COMBO( STATIC_LIGHT, lightState.m_bStaticLight ? 1 : 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( MORPHING, pShaderAPI->IsHWMorphingEnabled() ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); - SET_DYNAMIC_VERTEX_SHADER( eyes_vs30 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_eyes_vs30 ); } #endif @@ -469,25 +469,25 @@ static void DrawUsingVertexShader( bool bDX9, CBaseVSShader *pShader, IMaterialV { if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_DYNAMIC_PIXEL_SHADER( eyes_ps20b ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_eyes_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, pShaderAPI->ShouldWriteDepthToDestAlpha() ); - SET_DYNAMIC_PIXEL_SHADER( eyes_ps20b ); + SET_DYNAMIC_PIXEL_SHADER( sdk_eyes_ps20b ); } else { - DECLARE_DYNAMIC_PIXEL_SHADER( eyes_ps20 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_eyes_ps20 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - SET_DYNAMIC_PIXEL_SHADER( eyes_ps20 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_eyes_ps20 ); } } #ifndef _X360 else { - DECLARE_DYNAMIC_PIXEL_SHADER( eyes_ps30 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_eyes_ps30 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, pShaderAPI->ShouldWriteDepthToDestAlpha() ); - SET_DYNAMIC_PIXEL_SHADER( eyes_ps30 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_eyes_ps30 ); } #endif @@ -498,13 +498,13 @@ static void DrawUsingVertexShader( bool bDX9, CBaseVSShader *pShader, IMaterialV float timeVec[4] = { 0.0f, 0.0f, 0.0f, curTime }; Assert( params[info.m_nEntityOrigin]->IsDefined() ); params[info.m_nEntityOrigin]->GetVecValue( timeVec, 3 ); - pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_6, timeVec, 1 ); + pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_5, timeVec, 1 ); } } else #endif { - eyes_Dynamic_Index vshIndex; + sdk_eyes_Dynamic_Index vshIndex; vshIndex.SetDOWATERFOG( pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); vshIndex.SetSKINNING( pShaderAPI->GetCurrentNumBones() > 0 ); vshIndex.SetLIGHT_COMBO( pShaderAPI->GetCurrentLightCombo() ); diff --git a/sp/src/materialsystem/stdshaders/eyes_dx9.cpp b/sp/src/materialsystem/stdshaders/eyes_dx9.cpp index b33ec804..a032ef69 100644 --- a/sp/src/materialsystem/stdshaders/eyes_dx9.cpp +++ b/sp/src/materialsystem/stdshaders/eyes_dx9.cpp @@ -12,9 +12,9 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" -DEFINE_FALLBACK_SHADER( eyes, Eyes_dx9 ) +DEFINE_FALLBACK_SHADER( SDK_Eyes, SDK_Eyes_dx9 ) -BEGIN_VS_SHADER( Eyes_dx9, "Help for Eyes" ) +BEGIN_VS_SHADER( SDK_Eyes_dx9, "Help for SDK_Eyes" ) BEGIN_SHADER_PARAMS SHADER_PARAM( IRIS, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "iris texture" ) diff --git a/sp/src/materialsystem/stdshaders/flesh_interior_blended_pass_helper.cpp b/sp/src/materialsystem/stdshaders/flesh_interior_blended_pass_helper.cpp index 03ae509d..b905ddf9 100644 --- a/sp/src/materialsystem/stdshaders/flesh_interior_blended_pass_helper.cpp +++ b/sp/src/materialsystem/stdshaders/flesh_interior_blended_pass_helper.cpp @@ -124,9 +124,9 @@ #include "flesh_interior_blended_pass_helper.h" // Auto generated inc files -#include "flesh_interior_blended_pass_vs20.inc" -#include "flesh_interior_blended_pass_ps20.inc" -#include "flesh_interior_blended_pass_ps20b.inc" +#include "sdk_flesh_interior_blended_pass_vs20.inc" +#include "sdk_flesh_interior_blended_pass_ps20.inc" +#include "sdk_flesh_interior_blended_pass_ps20b.inc" void InitParamsFleshInteriorBlendedPass( CBaseVSShader *pShader, IMaterialVar** params, const char *pMaterialName, FleshInteriorBlendedPassVars_t &info ) { @@ -177,21 +177,21 @@ void DrawFleshInteriorBlendedPass( CBaseVSShader *pShader, IMaterialVar** params bool bUseStaticControlFlow = g_pHardwareConfig->SupportsStaticControlFlow(); // Vertex Shader - DECLARE_STATIC_VERTEX_SHADER( flesh_interior_blended_pass_vs20 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_flesh_interior_blended_pass_vs20 ); SET_STATIC_VERTEX_SHADER_COMBO( HALFLAMBERT, IS_FLAG_SET( MATERIAL_VAR_HALFLAMBERT ) ); SET_STATIC_VERTEX_SHADER_COMBO( USE_STATIC_CONTROL_FLOW, bUseStaticControlFlow ); - SET_STATIC_VERTEX_SHADER( flesh_interior_blended_pass_vs20 ); + SET_STATIC_VERTEX_SHADER( sdk_flesh_interior_blended_pass_vs20 ); // Pixel Shader if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_STATIC_PIXEL_SHADER( flesh_interior_blended_pass_ps20b ); - SET_STATIC_PIXEL_SHADER( flesh_interior_blended_pass_ps20b ); + DECLARE_STATIC_PIXEL_SHADER( sdk_flesh_interior_blended_pass_ps20b ); + SET_STATIC_PIXEL_SHADER( sdk_flesh_interior_blended_pass_ps20b ); } else { - DECLARE_STATIC_PIXEL_SHADER( flesh_interior_blended_pass_ps20 ); - SET_STATIC_PIXEL_SHADER( flesh_interior_blended_pass_ps20 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_flesh_interior_blended_pass_ps20 ); + SET_STATIC_PIXEL_SHADER( sdk_flesh_interior_blended_pass_ps20 ); } // Textures @@ -224,14 +224,14 @@ void DrawFleshInteriorBlendedPass( CBaseVSShader *pShader, IMaterialVar** params // Set Vertex Shader Combos LightState_t lightState = { 0, false, false }; pShaderAPI->GetDX9LightState( &lightState ); - DECLARE_DYNAMIC_VERTEX_SHADER( flesh_interior_blended_pass_vs20 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_flesh_interior_blended_pass_vs20 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DYNAMIC_LIGHT, lightState.HasDynamicLight() ); SET_DYNAMIC_VERTEX_SHADER_COMBO( STATIC_LIGHT, lightState.m_bStaticLight ? 1 : 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); SET_DYNAMIC_VERTEX_SHADER_COMBO( NUM_LIGHTS, bUseStaticControlFlow ? 0 : lightState.m_nNumLights ); - SET_DYNAMIC_VERTEX_SHADER( flesh_interior_blended_pass_vs20 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_flesh_interior_blended_pass_vs20 ); // Set Vertex Shader Constants pShader->SetAmbientCubeDynamicStateVertexShader(); @@ -300,13 +300,13 @@ void DrawFleshInteriorBlendedPass( CBaseVSShader *pShader, IMaterialVar** params // Set Pixel Shader Combos if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_DYNAMIC_PIXEL_SHADER( flesh_interior_blended_pass_ps20b ); - SET_DYNAMIC_PIXEL_SHADER( flesh_interior_blended_pass_ps20b ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_flesh_interior_blended_pass_ps20b ); + SET_DYNAMIC_PIXEL_SHADER( sdk_flesh_interior_blended_pass_ps20b ); } else { - DECLARE_DYNAMIC_PIXEL_SHADER( flesh_interior_blended_pass_ps20 ); - SET_DYNAMIC_PIXEL_SHADER( flesh_interior_blended_pass_ps20 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_flesh_interior_blended_pass_ps20 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_flesh_interior_blended_pass_ps20 ); } // Bind textures diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_Refract_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_Refract_vs20.inc new file mode 100644 index 00000000..58adb397 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_Refract_vs20.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_refract_vs20_Static_Index +{ +private: + int m_nMODEL; +#ifdef _DEBUG + bool m_bMODEL; +#endif +public: + void SetMODEL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMODEL = i; +#ifdef _DEBUG + m_bMODEL = true; +#endif + } + void SetMODEL( bool i ) + { + m_nMODEL = i ? 1 : 0; +#ifdef _DEBUG + m_bMODEL = true; +#endif + } +private: + int m_nCOLORMODULATE; +#ifdef _DEBUG + bool m_bCOLORMODULATE; +#endif +public: + void SetCOLORMODULATE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOLORMODULATE = i; +#ifdef _DEBUG + m_bCOLORMODULATE = true; +#endif + } + void SetCOLORMODULATE( bool i ) + { + m_nCOLORMODULATE = i ? 1 : 0; +#ifdef _DEBUG + m_bCOLORMODULATE = true; +#endif + } +public: + sdk_refract_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bMODEL = false; +#endif // _DEBUG + m_nMODEL = 0; +#ifdef _DEBUG + m_bCOLORMODULATE = false; +#endif // _DEBUG + m_nCOLORMODULATE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bMODEL && m_bCOLORMODULATE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nMODEL ) + ( 8 * m_nCOLORMODULATE ) + 0; + } +}; +#define shaderStaticTest_sdk_refract_vs20 vsh_forgot_to_set_static_MODEL + vsh_forgot_to_set_static_COLORMODULATE + 0 +class sdk_refract_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_refract_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + 0; + } +}; +#define shaderDynamicTest_sdk_refract_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_WaterCheap_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_WaterCheap_ps20.inc new file mode 100644 index 00000000..49475ba9 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_WaterCheap_ps20.inc @@ -0,0 +1,237 @@ +#include "shaderlib/cshader.h" +class sdk_watercheap_ps20_Static_Index +{ +private: + int m_nMULTITEXTURE; +#ifdef _DEBUG + bool m_bMULTITEXTURE; +#endif +public: + void SetMULTITEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMULTITEXTURE = i; +#ifdef _DEBUG + m_bMULTITEXTURE = true; +#endif + } + void SetMULTITEXTURE( bool i ) + { + m_nMULTITEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bMULTITEXTURE = true; +#endif + } +private: + int m_nFRESNEL; +#ifdef _DEBUG + bool m_bFRESNEL; +#endif +public: + void SetFRESNEL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFRESNEL = i; +#ifdef _DEBUG + m_bFRESNEL = true; +#endif + } + void SetFRESNEL( bool i ) + { + m_nFRESNEL = i ? 1 : 0; +#ifdef _DEBUG + m_bFRESNEL = true; +#endif + } +private: + int m_nBLEND; +#ifdef _DEBUG + bool m_bBLEND; +#endif +public: + void SetBLEND( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLEND = i; +#ifdef _DEBUG + m_bBLEND = true; +#endif + } + void SetBLEND( bool i ) + { + m_nBLEND = i ? 1 : 0; +#ifdef _DEBUG + m_bBLEND = true; +#endif + } +private: + int m_nREFRACTALPHA; +#ifdef _DEBUG + bool m_bREFRACTALPHA; +#endif +public: + void SetREFRACTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFRACTALPHA = i; +#ifdef _DEBUG + m_bREFRACTALPHA = true; +#endif + } + void SetREFRACTALPHA( bool i ) + { + m_nREFRACTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bREFRACTALPHA = true; +#endif + } +private: + int m_nHDRTYPE; +#ifdef _DEBUG + bool m_bHDRTYPE; +#endif +public: + void SetHDRTYPE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nHDRTYPE = i; +#ifdef _DEBUG + m_bHDRTYPE = true; +#endif + } + void SetHDRTYPE( bool i ) + { + m_nHDRTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bHDRTYPE = true; +#endif + } +private: + int m_nNORMAL_DECODE_MODE; +#ifdef _DEBUG + bool m_bNORMAL_DECODE_MODE; +#endif +public: + void SetNORMAL_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMAL_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } + void SetNORMAL_DECODE_MODE( bool i ) + { + m_nNORMAL_DECODE_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } +public: + sdk_watercheap_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bMULTITEXTURE = false; +#endif // _DEBUG + m_nMULTITEXTURE = 0; +#ifdef _DEBUG + m_bFRESNEL = false; +#endif // _DEBUG + m_nFRESNEL = 0; +#ifdef _DEBUG + m_bBLEND = false; +#endif // _DEBUG + m_nBLEND = 0; +#ifdef _DEBUG + m_bREFRACTALPHA = false; +#endif // _DEBUG + m_nREFRACTALPHA = 0; +#ifdef _DEBUG + m_bHDRTYPE = false; +#endif // _DEBUG + m_nHDRTYPE = 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = false; +#endif // _DEBUG + m_nNORMAL_DECODE_MODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bMULTITEXTURE && m_bFRESNEL && m_bBLEND && m_bREFRACTALPHA && m_bHDRTYPE && m_bNORMAL_DECODE_MODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nMULTITEXTURE ) + ( 8 * m_nFRESNEL ) + ( 16 * m_nBLEND ) + ( 32 * m_nREFRACTALPHA ) + ( 64 * m_nHDRTYPE ) + ( 192 * m_nNORMAL_DECODE_MODE ) + 0; + } +}; +#define shaderStaticTest_sdk_watercheap_ps20 psh_forgot_to_set_static_MULTITEXTURE + psh_forgot_to_set_static_FRESNEL + psh_forgot_to_set_static_BLEND + psh_forgot_to_set_static_REFRACTALPHA + psh_forgot_to_set_static_HDRTYPE + psh_forgot_to_set_static_NORMAL_DECODE_MODE + 0 +class sdk_watercheap_ps20_Dynamic_Index +{ +private: + int m_nHDRENABLED; +#ifdef _DEBUG + bool m_bHDRENABLED; +#endif +public: + void SetHDRENABLED( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHDRENABLED = i; +#ifdef _DEBUG + m_bHDRENABLED = true; +#endif + } + void SetHDRENABLED( bool i ) + { + m_nHDRENABLED = i ? 1 : 0; +#ifdef _DEBUG + m_bHDRENABLED = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_watercheap_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bHDRENABLED = false; +#endif // _DEBUG + m_nHDRENABLED = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bHDRENABLED && m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nHDRENABLED ) + ( 2 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_watercheap_ps20 psh_forgot_to_set_dynamic_HDRENABLED + psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_WaterCheap_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_WaterCheap_ps20b.inc new file mode 100644 index 00000000..6ddfc76f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_WaterCheap_ps20b.inc @@ -0,0 +1,262 @@ +#include "shaderlib/cshader.h" +class sdk_watercheap_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nMULTITEXTURE; +#ifdef _DEBUG + bool m_bMULTITEXTURE; +#endif +public: + void SetMULTITEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMULTITEXTURE = i; +#ifdef _DEBUG + m_bMULTITEXTURE = true; +#endif + } + void SetMULTITEXTURE( bool i ) + { + m_nMULTITEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bMULTITEXTURE = true; +#endif + } +private: + int m_nFRESNEL; +#ifdef _DEBUG + bool m_bFRESNEL; +#endif +public: + void SetFRESNEL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFRESNEL = i; +#ifdef _DEBUG + m_bFRESNEL = true; +#endif + } + void SetFRESNEL( bool i ) + { + m_nFRESNEL = i ? 1 : 0; +#ifdef _DEBUG + m_bFRESNEL = true; +#endif + } +private: + int m_nBLEND; +#ifdef _DEBUG + bool m_bBLEND; +#endif +public: + void SetBLEND( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLEND = i; +#ifdef _DEBUG + m_bBLEND = true; +#endif + } + void SetBLEND( bool i ) + { + m_nBLEND = i ? 1 : 0; +#ifdef _DEBUG + m_bBLEND = true; +#endif + } +private: + int m_nREFRACTALPHA; +#ifdef _DEBUG + bool m_bREFRACTALPHA; +#endif +public: + void SetREFRACTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFRACTALPHA = i; +#ifdef _DEBUG + m_bREFRACTALPHA = true; +#endif + } + void SetREFRACTALPHA( bool i ) + { + m_nREFRACTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bREFRACTALPHA = true; +#endif + } +private: + int m_nHDRTYPE; +#ifdef _DEBUG + bool m_bHDRTYPE; +#endif +public: + void SetHDRTYPE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nHDRTYPE = i; +#ifdef _DEBUG + m_bHDRTYPE = true; +#endif + } + void SetHDRTYPE( bool i ) + { + m_nHDRTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bHDRTYPE = true; +#endif + } +private: + int m_nNORMAL_DECODE_MODE; +#ifdef _DEBUG + bool m_bNORMAL_DECODE_MODE; +#endif +public: + void SetNORMAL_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMAL_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } + void SetNORMAL_DECODE_MODE( bool i ) + { + m_nNORMAL_DECODE_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } +public: + sdk_watercheap_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bMULTITEXTURE = false; +#endif // _DEBUG + m_nMULTITEXTURE = 0; +#ifdef _DEBUG + m_bFRESNEL = false; +#endif // _DEBUG + m_nFRESNEL = 0; +#ifdef _DEBUG + m_bBLEND = false; +#endif // _DEBUG + m_nBLEND = 0; +#ifdef _DEBUG + m_bREFRACTALPHA = false; +#endif // _DEBUG + m_nREFRACTALPHA = 0; +#ifdef _DEBUG + m_bHDRTYPE = false; +#endif // _DEBUG + m_nHDRTYPE = 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = false; +#endif // _DEBUG + m_nNORMAL_DECODE_MODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bMULTITEXTURE && m_bFRESNEL && m_bBLEND && m_bREFRACTALPHA && m_bHDRTYPE && m_bNORMAL_DECODE_MODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nCONVERT_TO_SRGB ) + ( 8 * m_nMULTITEXTURE ) + ( 16 * m_nFRESNEL ) + ( 32 * m_nBLEND ) + ( 64 * m_nREFRACTALPHA ) + ( 128 * m_nHDRTYPE ) + ( 384 * m_nNORMAL_DECODE_MODE ) + 0; + } +}; +#define shaderStaticTest_sdk_watercheap_ps20b psh_forgot_to_set_static_MULTITEXTURE + psh_forgot_to_set_static_FRESNEL + psh_forgot_to_set_static_BLEND + psh_forgot_to_set_static_REFRACTALPHA + psh_forgot_to_set_static_HDRTYPE + psh_forgot_to_set_static_NORMAL_DECODE_MODE + 0 +class sdk_watercheap_ps20b_Dynamic_Index +{ +private: + int m_nHDRENABLED; +#ifdef _DEBUG + bool m_bHDRENABLED; +#endif +public: + void SetHDRENABLED( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHDRENABLED = i; +#ifdef _DEBUG + m_bHDRENABLED = true; +#endif + } + void SetHDRENABLED( bool i ) + { + m_nHDRENABLED = i ? 1 : 0; +#ifdef _DEBUG + m_bHDRENABLED = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_watercheap_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bHDRENABLED = false; +#endif // _DEBUG + m_nHDRENABLED = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bHDRENABLED && m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nHDRENABLED ) + ( 2 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_watercheap_ps20b psh_forgot_to_set_dynamic_HDRENABLED + psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_WaterCheap_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_WaterCheap_vs20.inc new file mode 100644 index 00000000..49244f88 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_WaterCheap_vs20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_watercheap_vs20_Static_Index +{ +private: + int m_nBLEND; +#ifdef _DEBUG + bool m_bBLEND; +#endif +public: + void SetBLEND( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLEND = i; +#ifdef _DEBUG + m_bBLEND = true; +#endif + } + void SetBLEND( bool i ) + { + m_nBLEND = i ? 1 : 0; +#ifdef _DEBUG + m_bBLEND = true; +#endif + } +public: + sdk_watercheap_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bBLEND = false; +#endif // _DEBUG + m_nBLEND = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bBLEND; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nBLEND ) + 0; + } +}; +#define shaderStaticTest_sdk_watercheap_vs20 vsh_forgot_to_set_static_BLEND + 0 +class sdk_watercheap_vs20_Dynamic_Index +{ +public: + sdk_watercheap_vs20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_watercheap_vs20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_Water_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_Water_ps20.inc new file mode 100644 index 00000000..4929b59c --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_Water_ps20.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_water_ps20_Static_Index +{ +private: + int m_nBASETEXTURE; +#ifdef _DEBUG + bool m_bBASETEXTURE; +#endif +public: + void SetBASETEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE = i; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } + void SetBASETEXTURE( bool i ) + { + m_nBASETEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } +private: + int m_nMULTITEXTURE; +#ifdef _DEBUG + bool m_bMULTITEXTURE; +#endif +public: + void SetMULTITEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMULTITEXTURE = i; +#ifdef _DEBUG + m_bMULTITEXTURE = true; +#endif + } + void SetMULTITEXTURE( bool i ) + { + m_nMULTITEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bMULTITEXTURE = true; +#endif + } +private: + int m_nREFLECT; +#ifdef _DEBUG + bool m_bREFLECT; +#endif +public: + void SetREFLECT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFLECT = i; +#ifdef _DEBUG + m_bREFLECT = true; +#endif + } + void SetREFLECT( bool i ) + { + m_nREFLECT = i ? 1 : 0; +#ifdef _DEBUG + m_bREFLECT = true; +#endif + } +private: + int m_nREFRACT; +#ifdef _DEBUG + bool m_bREFRACT; +#endif +public: + void SetREFRACT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFRACT = i; +#ifdef _DEBUG + m_bREFRACT = true; +#endif + } + void SetREFRACT( bool i ) + { + m_nREFRACT = i ? 1 : 0; +#ifdef _DEBUG + m_bREFRACT = true; +#endif + } +private: + int m_nABOVEWATER; +#ifdef _DEBUG + bool m_bABOVEWATER; +#endif +public: + void SetABOVEWATER( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nABOVEWATER = i; +#ifdef _DEBUG + m_bABOVEWATER = true; +#endif + } + void SetABOVEWATER( bool i ) + { + m_nABOVEWATER = i ? 1 : 0; +#ifdef _DEBUG + m_bABOVEWATER = true; +#endif + } +private: + int m_nNORMAL_DECODE_MODE; +#ifdef _DEBUG + bool m_bNORMAL_DECODE_MODE; +#endif +public: + void SetNORMAL_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMAL_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } + void SetNORMAL_DECODE_MODE( bool i ) + { + m_nNORMAL_DECODE_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } +public: + sdk_water_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bBASETEXTURE = false; +#endif // _DEBUG + m_nBASETEXTURE = 0; +#ifdef _DEBUG + m_bMULTITEXTURE = false; +#endif // _DEBUG + m_nMULTITEXTURE = 0; +#ifdef _DEBUG + m_bREFLECT = false; +#endif // _DEBUG + m_nREFLECT = 0; +#ifdef _DEBUG + m_bREFRACT = false; +#endif // _DEBUG + m_nREFRACT = 0; +#ifdef _DEBUG + m_bABOVEWATER = false; +#endif // _DEBUG + m_nABOVEWATER = 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = false; +#endif // _DEBUG + m_nNORMAL_DECODE_MODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bBASETEXTURE && m_bMULTITEXTURE && m_bREFLECT && m_bREFRACT && m_bABOVEWATER && m_bNORMAL_DECODE_MODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nBASETEXTURE ) + ( 4 * m_nMULTITEXTURE ) + ( 8 * m_nREFLECT ) + ( 16 * m_nREFRACT ) + ( 32 * m_nABOVEWATER ) + ( 64 * m_nNORMAL_DECODE_MODE ) + 0; + } +}; +#define shaderStaticTest_sdk_water_ps20 psh_forgot_to_set_static_BASETEXTURE + psh_forgot_to_set_static_MULTITEXTURE + psh_forgot_to_set_static_REFLECT + psh_forgot_to_set_static_REFRACT + psh_forgot_to_set_static_ABOVEWATER + psh_forgot_to_set_static_NORMAL_DECODE_MODE + 0 +class sdk_water_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_water_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_water_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_Water_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_Water_ps20b.inc new file mode 100644 index 00000000..675efa7a --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_Water_ps20b.inc @@ -0,0 +1,287 @@ +#include "shaderlib/cshader.h" +class sdk_water_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nBASETEXTURE; +#ifdef _DEBUG + bool m_bBASETEXTURE; +#endif +public: + void SetBASETEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE = i; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } + void SetBASETEXTURE( bool i ) + { + m_nBASETEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } +private: + int m_nMULTITEXTURE; +#ifdef _DEBUG + bool m_bMULTITEXTURE; +#endif +public: + void SetMULTITEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMULTITEXTURE = i; +#ifdef _DEBUG + m_bMULTITEXTURE = true; +#endif + } + void SetMULTITEXTURE( bool i ) + { + m_nMULTITEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bMULTITEXTURE = true; +#endif + } +private: + int m_nREFLECT; +#ifdef _DEBUG + bool m_bREFLECT; +#endif +public: + void SetREFLECT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFLECT = i; +#ifdef _DEBUG + m_bREFLECT = true; +#endif + } + void SetREFLECT( bool i ) + { + m_nREFLECT = i ? 1 : 0; +#ifdef _DEBUG + m_bREFLECT = true; +#endif + } +private: + int m_nREFRACT; +#ifdef _DEBUG + bool m_bREFRACT; +#endif +public: + void SetREFRACT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFRACT = i; +#ifdef _DEBUG + m_bREFRACT = true; +#endif + } + void SetREFRACT( bool i ) + { + m_nREFRACT = i ? 1 : 0; +#ifdef _DEBUG + m_bREFRACT = true; +#endif + } +private: + int m_nABOVEWATER; +#ifdef _DEBUG + bool m_bABOVEWATER; +#endif +public: + void SetABOVEWATER( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nABOVEWATER = i; +#ifdef _DEBUG + m_bABOVEWATER = true; +#endif + } + void SetABOVEWATER( bool i ) + { + m_nABOVEWATER = i ? 1 : 0; +#ifdef _DEBUG + m_bABOVEWATER = true; +#endif + } +private: + int m_nBLURRY_REFRACT; +#ifdef _DEBUG + bool m_bBLURRY_REFRACT; +#endif +public: + void SetBLURRY_REFRACT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLURRY_REFRACT = i; +#ifdef _DEBUG + m_bBLURRY_REFRACT = true; +#endif + } + void SetBLURRY_REFRACT( bool i ) + { + m_nBLURRY_REFRACT = i ? 1 : 0; +#ifdef _DEBUG + m_bBLURRY_REFRACT = true; +#endif + } +private: + int m_nNORMAL_DECODE_MODE; +#ifdef _DEBUG + bool m_bNORMAL_DECODE_MODE; +#endif +public: + void SetNORMAL_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMAL_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } + void SetNORMAL_DECODE_MODE( bool i ) + { + m_nNORMAL_DECODE_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } +public: + sdk_water_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bBASETEXTURE = false; +#endif // _DEBUG + m_nBASETEXTURE = 0; +#ifdef _DEBUG + m_bMULTITEXTURE = false; +#endif // _DEBUG + m_nMULTITEXTURE = 0; +#ifdef _DEBUG + m_bREFLECT = false; +#endif // _DEBUG + m_nREFLECT = 0; +#ifdef _DEBUG + m_bREFRACT = false; +#endif // _DEBUG + m_nREFRACT = 0; +#ifdef _DEBUG + m_bABOVEWATER = false; +#endif // _DEBUG + m_nABOVEWATER = 0; +#ifdef _DEBUG + m_bBLURRY_REFRACT = false; +#endif // _DEBUG + m_nBLURRY_REFRACT = 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = false; +#endif // _DEBUG + m_nNORMAL_DECODE_MODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bBASETEXTURE && m_bMULTITEXTURE && m_bREFLECT && m_bREFRACT && m_bABOVEWATER && m_bBLURRY_REFRACT && m_bNORMAL_DECODE_MODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nCONVERT_TO_SRGB ) + ( 8 * m_nBASETEXTURE ) + ( 16 * m_nMULTITEXTURE ) + ( 32 * m_nREFLECT ) + ( 64 * m_nREFRACT ) + ( 128 * m_nABOVEWATER ) + ( 256 * m_nBLURRY_REFRACT ) + ( 512 * m_nNORMAL_DECODE_MODE ) + 0; + } +}; +#define shaderStaticTest_sdk_water_ps20b psh_forgot_to_set_static_BASETEXTURE + psh_forgot_to_set_static_MULTITEXTURE + psh_forgot_to_set_static_REFLECT + psh_forgot_to_set_static_REFRACT + psh_forgot_to_set_static_ABOVEWATER + psh_forgot_to_set_static_BLURRY_REFRACT + psh_forgot_to_set_static_NORMAL_DECODE_MODE + 0 +class sdk_water_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +public: + sdk_water_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bWRITE_DEPTH_TO_DESTALPHA; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + } +}; +#define shaderDynamicTest_sdk_water_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_Water_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_Water_vs20.inc new file mode 100644 index 00000000..67e8f134 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_Water_vs20.inc @@ -0,0 +1,85 @@ +#include "shaderlib/cshader.h" +class sdk_water_vs20_Static_Index +{ +private: + int m_nBASETEXTURE; +#ifdef _DEBUG + bool m_bBASETEXTURE; +#endif +public: + void SetBASETEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE = i; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } + void SetBASETEXTURE( bool i ) + { + m_nBASETEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } +private: + int m_nMULTITEXTURE; +#ifdef _DEBUG + bool m_bMULTITEXTURE; +#endif +public: + void SetMULTITEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMULTITEXTURE = i; +#ifdef _DEBUG + m_bMULTITEXTURE = true; +#endif + } + void SetMULTITEXTURE( bool i ) + { + m_nMULTITEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bMULTITEXTURE = true; +#endif + } +public: + sdk_water_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bBASETEXTURE = false; +#endif // _DEBUG + m_nBASETEXTURE = 0; +#ifdef _DEBUG + m_bMULTITEXTURE = false; +#endif // _DEBUG + m_nMULTITEXTURE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bBASETEXTURE && m_bMULTITEXTURE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nBASETEXTURE ) + ( 2 * m_nMULTITEXTURE ) + 0; + } +}; +#define shaderStaticTest_sdk_water_vs20 vsh_forgot_to_set_static_BASETEXTURE + vsh_forgot_to_set_static_MULTITEXTURE + 0 +class sdk_water_vs20_Dynamic_Index +{ +public: + sdk_water_vs20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_water_vs20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_WorldVertexTransition_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_WorldVertexTransition_ps20.inc new file mode 100644 index 00000000..67613947 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_WorldVertexTransition_ps20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_worldvertextransition_ps20_Static_Index +{ +private: + int m_nMACROS; +#ifdef _DEBUG + bool m_bMACROS; +#endif +public: + void SetMACROS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMACROS = i; +#ifdef _DEBUG + m_bMACROS = true; +#endif + } + void SetMACROS( bool i ) + { + m_nMACROS = i ? 1 : 0; +#ifdef _DEBUG + m_bMACROS = true; +#endif + } +public: + sdk_worldvertextransition_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bMACROS = false; +#endif // _DEBUG + m_nMACROS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bMACROS; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nMACROS ) + 0; + } +}; +#define shaderStaticTest_sdk_worldvertextransition_ps20 psh_forgot_to_set_static_MACROS + 0 +class sdk_worldvertextransition_ps20_Dynamic_Index +{ +public: + sdk_worldvertextransition_ps20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_worldvertextransition_ps20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_WorldVertexTransition_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_WorldVertexTransition_ps20b.inc new file mode 100644 index 00000000..cd00eaf5 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_WorldVertexTransition_ps20b.inc @@ -0,0 +1,85 @@ +#include "shaderlib/cshader.h" +class sdk_worldvertextransition_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nMACROS; +#ifdef _DEBUG + bool m_bMACROS; +#endif +public: + void SetMACROS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMACROS = i; +#ifdef _DEBUG + m_bMACROS = true; +#endif + } + void SetMACROS( bool i ) + { + m_nMACROS = i ? 1 : 0; +#ifdef _DEBUG + m_bMACROS = true; +#endif + } +public: + sdk_worldvertextransition_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bMACROS = false; +#endif // _DEBUG + m_nMACROS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bMACROS; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCONVERT_TO_SRGB ) + ( 2 * m_nMACROS ) + 0; + } +}; +#define shaderStaticTest_sdk_worldvertextransition_ps20b psh_forgot_to_set_static_MACROS + 0 +class sdk_worldvertextransition_ps20b_Dynamic_Index +{ +public: + sdk_worldvertextransition_ps20b_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_worldvertextransition_ps20b 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_WorldVertexTransition_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_WorldVertexTransition_vs20.inc new file mode 100644 index 00000000..fbf30e08 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_WorldVertexTransition_vs20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_worldvertextransition_vs20_Static_Index +{ +public: + sdk_worldvertextransition_vs20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_worldvertextransition_vs20 0 +class sdk_worldvertextransition_vs20_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_worldvertextransition_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_worldvertextransition_vs20 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cable_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cable_ps20.inc new file mode 100644 index 00000000..6d6f0122 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cable_ps20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_cable_ps20_Static_Index +{ +public: + sdk_cable_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_cable_ps20 0 +class sdk_cable_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_cable_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_cable_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cable_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cable_ps20b.inc new file mode 100644 index 00000000..0e73dbdf --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cable_ps20b.inc @@ -0,0 +1,112 @@ +#include "shaderlib/cshader.h" +class sdk_cable_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_cable_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_cable_ps20b 0 +class sdk_cable_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +public: + sdk_cable_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bWRITE_DEPTH_TO_DESTALPHA; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + } +}; +#define shaderDynamicTest_sdk_cable_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cable_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cable_vs20.inc new file mode 100644 index 00000000..d2ef4642 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cable_vs20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_cable_vs20_Static_Index +{ +public: + sdk_cable_vs20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_cable_vs20 0 +class sdk_cable_vs20_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_cable_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_cable_vs20 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cloak_blended_pass_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cloak_blended_pass_ps20.inc new file mode 100644 index 00000000..5d52f92f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cloak_blended_pass_ps20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_cloak_blended_pass_ps20_Static_Index +{ +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +public: + sdk_cloak_blended_pass_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bBUMPMAP; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nBUMPMAP ) + 0; + } +}; +#define shaderStaticTest_sdk_cloak_blended_pass_ps20 psh_forgot_to_set_static_BUMPMAP + 0 +class sdk_cloak_blended_pass_ps20_Dynamic_Index +{ +public: + sdk_cloak_blended_pass_ps20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_cloak_blended_pass_ps20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cloak_blended_pass_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cloak_blended_pass_ps20b.inc new file mode 100644 index 00000000..c724bbd2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cloak_blended_pass_ps20b.inc @@ -0,0 +1,85 @@ +#include "shaderlib/cshader.h" +class sdk_cloak_blended_pass_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +public: + sdk_cloak_blended_pass_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bBUMPMAP; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCONVERT_TO_SRGB ) + ( 2 * m_nBUMPMAP ) + 0; + } +}; +#define shaderStaticTest_sdk_cloak_blended_pass_ps20b psh_forgot_to_set_static_BUMPMAP + 0 +class sdk_cloak_blended_pass_ps20b_Dynamic_Index +{ +public: + sdk_cloak_blended_pass_ps20b_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_cloak_blended_pass_ps20b 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cloak_blended_pass_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cloak_blended_pass_ps30.inc new file mode 100644 index 00000000..778aaf04 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cloak_blended_pass_ps30.inc @@ -0,0 +1,85 @@ +#include "shaderlib/cshader.h" +class sdk_cloak_blended_pass_ps30_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +public: + sdk_cloak_blended_pass_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bBUMPMAP; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCONVERT_TO_SRGB ) + ( 2 * m_nBUMPMAP ) + 0; + } +}; +#define shaderStaticTest_sdk_cloak_blended_pass_ps30 psh_forgot_to_set_static_BUMPMAP + 0 +class sdk_cloak_blended_pass_ps30_Dynamic_Index +{ +public: + sdk_cloak_blended_pass_ps30_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_cloak_blended_pass_ps30 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cloak_blended_pass_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cloak_blended_pass_vs20.inc new file mode 100644 index 00000000..7f431299 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cloak_blended_pass_vs20.inc @@ -0,0 +1,112 @@ +#include "shaderlib/cshader.h" +class sdk_cloak_blended_pass_vs20_Static_Index +{ +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +public: + sdk_cloak_blended_pass_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bBUMPMAP; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nBUMPMAP ) + 0; + } +}; +#define shaderStaticTest_sdk_cloak_blended_pass_vs20 vsh_forgot_to_set_static_BUMPMAP + 0 +class sdk_cloak_blended_pass_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_cloak_blended_pass_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + 0; + } +}; +#define shaderDynamicTest_sdk_cloak_blended_pass_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cloak_blended_pass_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cloak_blended_pass_vs30.inc new file mode 100644 index 00000000..f3121788 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_cloak_blended_pass_vs30.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_cloak_blended_pass_vs30_Static_Index +{ +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +public: + sdk_cloak_blended_pass_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bBUMPMAP; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 8 * m_nBUMPMAP ) + 0; + } +}; +#define shaderStaticTest_sdk_cloak_blended_pass_vs30 vsh_forgot_to_set_static_BUMPMAP + 0 +class sdk_cloak_blended_pass_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_cloak_blended_pass_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_cloak_blended_pass_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_decalmodulate_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_decalmodulate_ps20.inc new file mode 100644 index 00000000..cc1e6113 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_decalmodulate_ps20.inc @@ -0,0 +1,112 @@ +#include "shaderlib/cshader.h" +class sdk_decalmodulate_ps20_Static_Index +{ +private: + int m_nVERTEXALPHA; +#ifdef _DEBUG + bool m_bVERTEXALPHA; +#endif +public: + void SetVERTEXALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXALPHA = i; +#ifdef _DEBUG + m_bVERTEXALPHA = true; +#endif + } + void SetVERTEXALPHA( bool i ) + { + m_nVERTEXALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXALPHA = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +public: + sdk_decalmodulate_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bVERTEXALPHA = false; +#endif // _DEBUG + m_nVERTEXALPHA = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bVERTEXALPHA && m_bFLASHLIGHT; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nVERTEXALPHA ) + ( 4 * m_nFLASHLIGHT ) + 0; + } +}; +#define shaderStaticTest_sdk_decalmodulate_ps20 psh_forgot_to_set_static_VERTEXALPHA + psh_forgot_to_set_static_FLASHLIGHT + 0 +class sdk_decalmodulate_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_decalmodulate_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_decalmodulate_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_decalmodulate_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_decalmodulate_ps20b.inc new file mode 100644 index 00000000..e35c8a54 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_decalmodulate_ps20b.inc @@ -0,0 +1,162 @@ +#include "shaderlib/cshader.h" +class sdk_decalmodulate_ps20b_Static_Index +{ +private: + int m_nVERTEXALPHA; +#ifdef _DEBUG + bool m_bVERTEXALPHA; +#endif +public: + void SetVERTEXALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXALPHA = i; +#ifdef _DEBUG + m_bVERTEXALPHA = true; +#endif + } + void SetVERTEXALPHA( bool i ) + { + m_nVERTEXALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXALPHA = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_decalmodulate_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bVERTEXALPHA = false; +#endif // _DEBUG + m_nVERTEXALPHA = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bVERTEXALPHA && m_bFLASHLIGHT && m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nVERTEXALPHA ) + ( 8 * m_nFLASHLIGHT ) + ( 16 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_decalmodulate_ps20b psh_forgot_to_set_static_VERTEXALPHA + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_decalmodulate_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_decalmodulate_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_decalmodulate_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_decalmodulate_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_decalmodulate_ps30.inc new file mode 100644 index 00000000..db6747a2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_decalmodulate_ps30.inc @@ -0,0 +1,162 @@ +#include "shaderlib/cshader.h" +class sdk_decalmodulate_ps30_Static_Index +{ +private: + int m_nVERTEXALPHA; +#ifdef _DEBUG + bool m_bVERTEXALPHA; +#endif +public: + void SetVERTEXALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXALPHA = i; +#ifdef _DEBUG + m_bVERTEXALPHA = true; +#endif + } + void SetVERTEXALPHA( bool i ) + { + m_nVERTEXALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXALPHA = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_decalmodulate_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bVERTEXALPHA = false; +#endif // _DEBUG + m_nVERTEXALPHA = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bVERTEXALPHA && m_bFLASHLIGHT && m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nVERTEXALPHA ) + ( 8 * m_nFLASHLIGHT ) + ( 16 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_decalmodulate_ps30 psh_forgot_to_set_static_VERTEXALPHA + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_decalmodulate_ps30_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_decalmodulate_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_decalmodulate_ps30 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_decalmodulate_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_decalmodulate_vs20.inc new file mode 100644 index 00000000..0f571fd7 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_decalmodulate_vs20.inc @@ -0,0 +1,187 @@ +#include "shaderlib/cshader.h" +class sdk_decalmodulate_vs20_Static_Index +{ +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +public: + sdk_decalmodulate_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bVERTEXCOLOR && m_bLIGHTING_PREVIEW && m_bFLASHLIGHT; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nVERTEXCOLOR ) + ( 8 * m_nLIGHTING_PREVIEW ) + ( 16 * m_nFLASHLIGHT ) + 0; + } +}; +#define shaderStaticTest_sdk_decalmodulate_vs20 vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_LIGHTING_PREVIEW + vsh_forgot_to_set_static_FLASHLIGHT + 0 +class sdk_decalmodulate_vs20_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_decalmodulate_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG && m_bCOMPRESSED_VERTS && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + ( 2 * m_nCOMPRESSED_VERTS ) + ( 4 * m_nSKINNING ) + 0; + } +}; +#define shaderDynamicTest_sdk_decalmodulate_vs20 vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_decalmodulate_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_decalmodulate_vs30.inc new file mode 100644 index 00000000..38617b8c --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_decalmodulate_vs30.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_decalmodulate_vs30_Static_Index +{ +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +public: + sdk_decalmodulate_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bVERTEXCOLOR && m_bLIGHTING_PREVIEW && m_bFLASHLIGHT; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 16 * m_nVERTEXCOLOR ) + ( 32 * m_nLIGHTING_PREVIEW ) + ( 64 * m_nFLASHLIGHT ) + 0; + } +}; +#define shaderStaticTest_sdk_decalmodulate_vs30 vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_LIGHTING_PREVIEW + vsh_forgot_to_set_static_FLASHLIGHT + 0 +class sdk_decalmodulate_vs30_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_decalmodulate_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG && m_bCOMPRESSED_VERTS && m_bSKINNING && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + ( 2 * m_nCOMPRESSED_VERTS ) + ( 4 * m_nSKINNING ) + ( 8 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_decalmodulate_vs30 vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_depthwrite_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_depthwrite_ps20.inc new file mode 100644 index 00000000..938ab9bd --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_depthwrite_ps20.inc @@ -0,0 +1,87 @@ +#include "shaderlib/cshader.h" +class sdk_depthwrite_ps20_Static_Index +{ +private: + int m_nCOLOR_DEPTH; +#ifdef _DEBUG + bool m_bCOLOR_DEPTH; +#endif +public: + void SetCOLOR_DEPTH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOLOR_DEPTH = i; +#ifdef _DEBUG + m_bCOLOR_DEPTH = true; +#endif + } + void SetCOLOR_DEPTH( bool i ) + { + m_nCOLOR_DEPTH = i ? 1 : 0; +#ifdef _DEBUG + m_bCOLOR_DEPTH = true; +#endif + } +public: + sdk_depthwrite_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bCOLOR_DEPTH = false; +#endif // _DEBUG + m_nCOLOR_DEPTH = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCOLOR_DEPTH; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nCOLOR_DEPTH ) + 0; + } +}; +#define shaderStaticTest_sdk_depthwrite_ps20 psh_forgot_to_set_static_COLOR_DEPTH + 0 +class sdk_depthwrite_ps20_Dynamic_Index +{ +private: + int m_nALPHACLIP; +#ifdef _DEBUG + bool m_bALPHACLIP; +#endif +public: + void SetALPHACLIP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nALPHACLIP = i; +#ifdef _DEBUG + m_bALPHACLIP = true; +#endif + } + void SetALPHACLIP( bool i ) + { + m_nALPHACLIP = i ? 1 : 0; +#ifdef _DEBUG + m_bALPHACLIP = true; +#endif + } +public: + sdk_depthwrite_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bALPHACLIP = false; +#endif // _DEBUG + m_nALPHACLIP = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bALPHACLIP; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nALPHACLIP ) + 0; + } +}; +#define shaderDynamicTest_sdk_depthwrite_ps20 psh_forgot_to_set_dynamic_ALPHACLIP + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_depthwrite_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_depthwrite_ps20b.inc new file mode 100644 index 00000000..fc639347 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_depthwrite_ps20b.inc @@ -0,0 +1,87 @@ +#include "shaderlib/cshader.h" +class sdk_depthwrite_ps20b_Static_Index +{ +private: + int m_nCOLOR_DEPTH; +#ifdef _DEBUG + bool m_bCOLOR_DEPTH; +#endif +public: + void SetCOLOR_DEPTH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOLOR_DEPTH = i; +#ifdef _DEBUG + m_bCOLOR_DEPTH = true; +#endif + } + void SetCOLOR_DEPTH( bool i ) + { + m_nCOLOR_DEPTH = i ? 1 : 0; +#ifdef _DEBUG + m_bCOLOR_DEPTH = true; +#endif + } +public: + sdk_depthwrite_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCOLOR_DEPTH = false; +#endif // _DEBUG + m_nCOLOR_DEPTH = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCOLOR_DEPTH; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nCOLOR_DEPTH ) + 0; + } +}; +#define shaderStaticTest_sdk_depthwrite_ps20b psh_forgot_to_set_static_COLOR_DEPTH + 0 +class sdk_depthwrite_ps20b_Dynamic_Index +{ +private: + int m_nALPHACLIP; +#ifdef _DEBUG + bool m_bALPHACLIP; +#endif +public: + void SetALPHACLIP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nALPHACLIP = i; +#ifdef _DEBUG + m_bALPHACLIP = true; +#endif + } + void SetALPHACLIP( bool i ) + { + m_nALPHACLIP = i ? 1 : 0; +#ifdef _DEBUG + m_bALPHACLIP = true; +#endif + } +public: + sdk_depthwrite_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bALPHACLIP = false; +#endif // _DEBUG + m_nALPHACLIP = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bALPHACLIP; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nALPHACLIP ) + 0; + } +}; +#define shaderDynamicTest_sdk_depthwrite_ps20b psh_forgot_to_set_dynamic_ALPHACLIP + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_depthwrite_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_depthwrite_ps30.inc new file mode 100644 index 00000000..7ebec65d --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_depthwrite_ps30.inc @@ -0,0 +1,87 @@ +#include "shaderlib/cshader.h" +class sdk_depthwrite_ps30_Static_Index +{ +private: + int m_nCOLOR_DEPTH; +#ifdef _DEBUG + bool m_bCOLOR_DEPTH; +#endif +public: + void SetCOLOR_DEPTH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOLOR_DEPTH = i; +#ifdef _DEBUG + m_bCOLOR_DEPTH = true; +#endif + } + void SetCOLOR_DEPTH( bool i ) + { + m_nCOLOR_DEPTH = i ? 1 : 0; +#ifdef _DEBUG + m_bCOLOR_DEPTH = true; +#endif + } +public: + sdk_depthwrite_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bCOLOR_DEPTH = false; +#endif // _DEBUG + m_nCOLOR_DEPTH = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCOLOR_DEPTH; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nCOLOR_DEPTH ) + 0; + } +}; +#define shaderStaticTest_sdk_depthwrite_ps30 psh_forgot_to_set_static_COLOR_DEPTH + 0 +class sdk_depthwrite_ps30_Dynamic_Index +{ +private: + int m_nALPHACLIP; +#ifdef _DEBUG + bool m_bALPHACLIP; +#endif +public: + void SetALPHACLIP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nALPHACLIP = i; +#ifdef _DEBUG + m_bALPHACLIP = true; +#endif + } + void SetALPHACLIP( bool i ) + { + m_nALPHACLIP = i ? 1 : 0; +#ifdef _DEBUG + m_bALPHACLIP = true; +#endif + } +public: + sdk_depthwrite_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bALPHACLIP = false; +#endif // _DEBUG + m_nALPHACLIP = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bALPHACLIP; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nALPHACLIP ) + 0; + } +}; +#define shaderDynamicTest_sdk_depthwrite_ps30 psh_forgot_to_set_dynamic_ALPHACLIP + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_depthwrite_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_depthwrite_vs20.inc new file mode 100644 index 00000000..25256cd7 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_depthwrite_vs20.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_depthwrite_vs20_Static_Index +{ +private: + int m_nONLY_PROJECT_POSITION; +#ifdef _DEBUG + bool m_bONLY_PROJECT_POSITION; +#endif +public: + void SetONLY_PROJECT_POSITION( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nONLY_PROJECT_POSITION = i; +#ifdef _DEBUG + m_bONLY_PROJECT_POSITION = true; +#endif + } + void SetONLY_PROJECT_POSITION( bool i ) + { + m_nONLY_PROJECT_POSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bONLY_PROJECT_POSITION = true; +#endif + } +private: + int m_nCOLOR_DEPTH; +#ifdef _DEBUG + bool m_bCOLOR_DEPTH; +#endif +public: + void SetCOLOR_DEPTH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOLOR_DEPTH = i; +#ifdef _DEBUG + m_bCOLOR_DEPTH = true; +#endif + } + void SetCOLOR_DEPTH( bool i ) + { + m_nCOLOR_DEPTH = i ? 1 : 0; +#ifdef _DEBUG + m_bCOLOR_DEPTH = true; +#endif + } +public: + sdk_depthwrite_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bONLY_PROJECT_POSITION = false; +#endif // _DEBUG + m_nONLY_PROJECT_POSITION = 0; +#ifdef _DEBUG + m_bCOLOR_DEPTH = false; +#endif // _DEBUG + m_nCOLOR_DEPTH = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bONLY_PROJECT_POSITION && m_bCOLOR_DEPTH; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nONLY_PROJECT_POSITION ) + ( 4 * m_nCOLOR_DEPTH ) + 0; + } +}; +#define shaderStaticTest_sdk_depthwrite_vs20 vsh_forgot_to_set_static_ONLY_PROJECT_POSITION + vsh_forgot_to_set_static_COLOR_DEPTH + 0 +class sdk_depthwrite_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_depthwrite_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + 0; + } +}; +#define shaderDynamicTest_sdk_depthwrite_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_depthwrite_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_depthwrite_vs30.inc new file mode 100644 index 00000000..b009bec2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_depthwrite_vs30.inc @@ -0,0 +1,162 @@ +#include "shaderlib/cshader.h" +class sdk_depthwrite_vs30_Static_Index +{ +private: + int m_nONLY_PROJECT_POSITION; +#ifdef _DEBUG + bool m_bONLY_PROJECT_POSITION; +#endif +public: + void SetONLY_PROJECT_POSITION( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nONLY_PROJECT_POSITION = i; +#ifdef _DEBUG + m_bONLY_PROJECT_POSITION = true; +#endif + } + void SetONLY_PROJECT_POSITION( bool i ) + { + m_nONLY_PROJECT_POSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bONLY_PROJECT_POSITION = true; +#endif + } +private: + int m_nCOLOR_DEPTH; +#ifdef _DEBUG + bool m_bCOLOR_DEPTH; +#endif +public: + void SetCOLOR_DEPTH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOLOR_DEPTH = i; +#ifdef _DEBUG + m_bCOLOR_DEPTH = true; +#endif + } + void SetCOLOR_DEPTH( bool i ) + { + m_nCOLOR_DEPTH = i ? 1 : 0; +#ifdef _DEBUG + m_bCOLOR_DEPTH = true; +#endif + } +public: + sdk_depthwrite_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bONLY_PROJECT_POSITION = false; +#endif // _DEBUG + m_nONLY_PROJECT_POSITION = 0; +#ifdef _DEBUG + m_bCOLOR_DEPTH = false; +#endif // _DEBUG + m_nCOLOR_DEPTH = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bONLY_PROJECT_POSITION && m_bCOLOR_DEPTH; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 8 * m_nONLY_PROJECT_POSITION ) + ( 8 * m_nCOLOR_DEPTH ) + 0; + } +}; +#define shaderStaticTest_sdk_depthwrite_vs30 vsh_forgot_to_set_static_ONLY_PROJECT_POSITION + vsh_forgot_to_set_static_COLOR_DEPTH + 0 +class sdk_depthwrite_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_depthwrite_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_depthwrite_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_emissive_scroll_blended_pass_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_emissive_scroll_blended_pass_ps20.inc new file mode 100644 index 00000000..c415f0a5 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_emissive_scroll_blended_pass_ps20.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_emissive_scroll_blended_pass_ps20_Static_Index +{ +public: + sdk_emissive_scroll_blended_pass_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_emissive_scroll_blended_pass_ps20 0 +class sdk_emissive_scroll_blended_pass_ps20_Dynamic_Index +{ +public: + sdk_emissive_scroll_blended_pass_ps20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_emissive_scroll_blended_pass_ps20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_emissive_scroll_blended_pass_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_emissive_scroll_blended_pass_ps20b.inc new file mode 100644 index 00000000..42dd5742 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_emissive_scroll_blended_pass_ps20b.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_emissive_scroll_blended_pass_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_emissive_scroll_blended_pass_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_emissive_scroll_blended_pass_ps20b 0 +class sdk_emissive_scroll_blended_pass_ps20b_Dynamic_Index +{ +public: + sdk_emissive_scroll_blended_pass_ps20b_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_emissive_scroll_blended_pass_ps20b 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_emissive_scroll_blended_pass_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_emissive_scroll_blended_pass_ps30.inc new file mode 100644 index 00000000..f0e08917 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_emissive_scroll_blended_pass_ps30.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_emissive_scroll_blended_pass_ps30_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_emissive_scroll_blended_pass_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_emissive_scroll_blended_pass_ps30 0 +class sdk_emissive_scroll_blended_pass_ps30_Dynamic_Index +{ +public: + sdk_emissive_scroll_blended_pass_ps30_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_emissive_scroll_blended_pass_ps30 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_emissive_scroll_blended_pass_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_emissive_scroll_blended_pass_vs20.inc new file mode 100644 index 00000000..a7f2793f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_emissive_scroll_blended_pass_vs20.inc @@ -0,0 +1,85 @@ +#include "shaderlib/cshader.h" +class sdk_emissive_scroll_blended_pass_vs20_Static_Index +{ +public: + sdk_emissive_scroll_blended_pass_vs20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_emissive_scroll_blended_pass_vs20 0 +class sdk_emissive_scroll_blended_pass_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_emissive_scroll_blended_pass_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + 0; + } +}; +#define shaderDynamicTest_sdk_emissive_scroll_blended_pass_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_emissive_scroll_blended_pass_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_emissive_scroll_blended_pass_vs30.inc new file mode 100644 index 00000000..5abcbad5 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_emissive_scroll_blended_pass_vs30.inc @@ -0,0 +1,110 @@ +#include "shaderlib/cshader.h" +class sdk_emissive_scroll_blended_pass_vs30_Static_Index +{ +public: + sdk_emissive_scroll_blended_pass_vs30_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_emissive_scroll_blended_pass_vs30 0 +class sdk_emissive_scroll_blended_pass_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_emissive_scroll_blended_pass_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_emissive_scroll_blended_pass_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eye_refract_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eye_refract_ps20.inc new file mode 100644 index 00000000..850964b3 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eye_refract_ps20.inc @@ -0,0 +1,112 @@ +#include "shaderlib/cshader.h" +class sdk_eye_refract_ps20_Static_Index +{ +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nLIGHTWARPTEXTURE; +#ifdef _DEBUG + bool m_bLIGHTWARPTEXTURE; +#endif +public: + void SetLIGHTWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTWARPTEXTURE = i; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } + void SetLIGHTWARPTEXTURE( bool i ) + { + m_nLIGHTWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } +public: + sdk_eye_refract_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = false; +#endif // _DEBUG + m_nLIGHTWARPTEXTURE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bFLASHLIGHT && m_bLIGHTWARPTEXTURE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 3 * m_nFLASHLIGHT ) + ( 6 * m_nLIGHTWARPTEXTURE ) + 0; + } +}; +#define shaderStaticTest_sdk_eye_refract_ps20 psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_LIGHTWARPTEXTURE + 0 +class sdk_eye_refract_ps20_Dynamic_Index +{ +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_eye_refract_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_eye_refract_ps20 psh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eye_refract_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eye_refract_ps20b.inc new file mode 100644 index 00000000..93308c81 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eye_refract_ps20b.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_eye_refract_ps20b_Static_Index +{ +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nLIGHTWARPTEXTURE; +#ifdef _DEBUG + bool m_bLIGHTWARPTEXTURE; +#endif +public: + void SetLIGHTWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTWARPTEXTURE = i; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } + void SetLIGHTWARPTEXTURE( bool i ) + { + m_nLIGHTWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } +private: + int m_nSPHERETEXKILLCOMBO; +#ifdef _DEBUG + bool m_bSPHERETEXKILLCOMBO; +#endif +public: + void SetSPHERETEXKILLCOMBO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSPHERETEXKILLCOMBO = i; +#ifdef _DEBUG + m_bSPHERETEXKILLCOMBO = true; +#endif + } + void SetSPHERETEXKILLCOMBO( bool i ) + { + m_nSPHERETEXKILLCOMBO = i ? 1 : 0; +#ifdef _DEBUG + m_bSPHERETEXKILLCOMBO = true; +#endif + } +private: + int m_nRAYTRACESPHERE; +#ifdef _DEBUG + bool m_bRAYTRACESPHERE; +#endif +public: + void SetRAYTRACESPHERE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nRAYTRACESPHERE = i; +#ifdef _DEBUG + m_bRAYTRACESPHERE = true; +#endif + } + void SetRAYTRACESPHERE( bool i ) + { + m_nRAYTRACESPHERE = i ? 1 : 0; +#ifdef _DEBUG + m_bRAYTRACESPHERE = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_eye_refract_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = false; +#endif // _DEBUG + m_nLIGHTWARPTEXTURE = 0; +#ifdef _DEBUG + m_bSPHERETEXKILLCOMBO = false; +#endif // _DEBUG + m_nSPHERETEXKILLCOMBO = 0; +#ifdef _DEBUG + m_bRAYTRACESPHERE = false; +#endif // _DEBUG + m_nRAYTRACESPHERE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bFLASHLIGHT && m_bLIGHTWARPTEXTURE && m_bSPHERETEXKILLCOMBO && m_bRAYTRACESPHERE && m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 10 * m_nFLASHLIGHT ) + ( 20 * m_nLIGHTWARPTEXTURE ) + ( 40 * m_nSPHERETEXKILLCOMBO ) + ( 80 * m_nRAYTRACESPHERE ) + ( 160 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_eye_refract_ps20b psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_SPHERETEXKILLCOMBO + psh_forgot_to_set_static_RAYTRACESPHERE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_eye_refract_ps20b_Dynamic_Index +{ +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_eye_refract_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bNUM_LIGHTS && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nNUM_LIGHTS ) + ( 5 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_eye_refract_ps20b psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eye_refract_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eye_refract_ps30.inc new file mode 100644 index 00000000..76c39918 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eye_refract_ps30.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_eye_refract_ps30_Static_Index +{ +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nLIGHTWARPTEXTURE; +#ifdef _DEBUG + bool m_bLIGHTWARPTEXTURE; +#endif +public: + void SetLIGHTWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTWARPTEXTURE = i; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } + void SetLIGHTWARPTEXTURE( bool i ) + { + m_nLIGHTWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } +private: + int m_nSPHERETEXKILLCOMBO; +#ifdef _DEBUG + bool m_bSPHERETEXKILLCOMBO; +#endif +public: + void SetSPHERETEXKILLCOMBO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSPHERETEXKILLCOMBO = i; +#ifdef _DEBUG + m_bSPHERETEXKILLCOMBO = true; +#endif + } + void SetSPHERETEXKILLCOMBO( bool i ) + { + m_nSPHERETEXKILLCOMBO = i ? 1 : 0; +#ifdef _DEBUG + m_bSPHERETEXKILLCOMBO = true; +#endif + } +private: + int m_nRAYTRACESPHERE; +#ifdef _DEBUG + bool m_bRAYTRACESPHERE; +#endif +public: + void SetRAYTRACESPHERE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nRAYTRACESPHERE = i; +#ifdef _DEBUG + m_bRAYTRACESPHERE = true; +#endif + } + void SetRAYTRACESPHERE( bool i ) + { + m_nRAYTRACESPHERE = i ? 1 : 0; +#ifdef _DEBUG + m_bRAYTRACESPHERE = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_eye_refract_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = false; +#endif // _DEBUG + m_nLIGHTWARPTEXTURE = 0; +#ifdef _DEBUG + m_bSPHERETEXKILLCOMBO = false; +#endif // _DEBUG + m_nSPHERETEXKILLCOMBO = 0; +#ifdef _DEBUG + m_bRAYTRACESPHERE = false; +#endif // _DEBUG + m_nRAYTRACESPHERE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bFLASHLIGHT && m_bLIGHTWARPTEXTURE && m_bSPHERETEXKILLCOMBO && m_bRAYTRACESPHERE && m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 10 * m_nFLASHLIGHT ) + ( 20 * m_nLIGHTWARPTEXTURE ) + ( 40 * m_nSPHERETEXKILLCOMBO ) + ( 80 * m_nRAYTRACESPHERE ) + ( 160 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_eye_refract_ps30 psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_SPHERETEXKILLCOMBO + psh_forgot_to_set_static_RAYTRACESPHERE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_eye_refract_ps30_Dynamic_Index +{ +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_eye_refract_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bNUM_LIGHTS && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nNUM_LIGHTS ) + ( 5 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_eye_refract_ps30 psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eye_refract_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eye_refract_vs20.inc new file mode 100644 index 00000000..ec10825b --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eye_refract_vs20.inc @@ -0,0 +1,287 @@ +#include "shaderlib/cshader.h" +class sdk_eye_refract_vs20_Static_Index +{ +private: + int m_nINTRO; +#ifdef _DEBUG + bool m_bINTRO; +#endif +public: + void SetINTRO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nINTRO = i; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } + void SetINTRO( bool i ) + { + m_nINTRO = i ? 1 : 0; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nLIGHTWARPTEXTURE; +#ifdef _DEBUG + bool m_bLIGHTWARPTEXTURE; +#endif +public: + void SetLIGHTWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTWARPTEXTURE = i; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } + void SetLIGHTWARPTEXTURE( bool i ) + { + m_nLIGHTWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } +public: + sdk_eye_refract_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bINTRO = false; +#endif // _DEBUG + m_nINTRO = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = false; +#endif // _DEBUG + m_nLIGHTWARPTEXTURE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bINTRO && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bLIGHTWARPTEXTURE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 160 * m_nINTRO ) + ( 320 * m_nHALFLAMBERT ) + ( 640 * m_nFLASHLIGHT ) + ( 1280 * m_nLIGHTWARPTEXTURE ) + 0; + } +}; +#define shaderStaticTest_sdk_eye_refract_vs20 vsh_forgot_to_set_static_INTRO + vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_FLASHLIGHT + vsh_forgot_to_set_static_LIGHTWARPTEXTURE + 0 +class sdk_eye_refract_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nDYNAMIC_LIGHT; +#ifdef _DEBUG + bool m_bDYNAMIC_LIGHT; +#endif +public: + void SetDYNAMIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDYNAMIC_LIGHT = i; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } + void SetDYNAMIC_LIGHT( bool i ) + { + m_nDYNAMIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_eye_refract_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = false; +#endif // _DEBUG + m_nDYNAMIC_LIGHT = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bDOWATERFOG && m_bDYNAMIC_LIGHT && m_bSTATIC_LIGHT && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nDOWATERFOG ) + ( 8 * m_nDYNAMIC_LIGHT ) + ( 16 * m_nSTATIC_LIGHT ) + ( 32 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_eye_refract_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_DYNAMIC_LIGHT + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eye_refract_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eye_refract_vs30.inc new file mode 100644 index 00000000..4729f2ab --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eye_refract_vs30.inc @@ -0,0 +1,312 @@ +#include "shaderlib/cshader.h" +class sdk_eye_refract_vs30_Static_Index +{ +private: + int m_nINTRO; +#ifdef _DEBUG + bool m_bINTRO; +#endif +public: + void SetINTRO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nINTRO = i; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } + void SetINTRO( bool i ) + { + m_nINTRO = i ? 1 : 0; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nLIGHTWARPTEXTURE; +#ifdef _DEBUG + bool m_bLIGHTWARPTEXTURE; +#endif +public: + void SetLIGHTWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTWARPTEXTURE = i; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } + void SetLIGHTWARPTEXTURE( bool i ) + { + m_nLIGHTWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } +public: + sdk_eye_refract_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bINTRO = false; +#endif // _DEBUG + m_nINTRO = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = false; +#endif // _DEBUG + m_nLIGHTWARPTEXTURE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bINTRO && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bLIGHTWARPTEXTURE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 320 * m_nINTRO ) + ( 640 * m_nHALFLAMBERT ) + ( 1280 * m_nFLASHLIGHT ) + ( 2560 * m_nLIGHTWARPTEXTURE ) + 0; + } +}; +#define shaderStaticTest_sdk_eye_refract_vs30 vsh_forgot_to_set_static_INTRO + vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_FLASHLIGHT + vsh_forgot_to_set_static_LIGHTWARPTEXTURE + 0 +class sdk_eye_refract_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nDYNAMIC_LIGHT; +#ifdef _DEBUG + bool m_bDYNAMIC_LIGHT; +#endif +public: + void SetDYNAMIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDYNAMIC_LIGHT = i; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } + void SetDYNAMIC_LIGHT( bool i ) + { + m_nDYNAMIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_eye_refract_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = false; +#endif // _DEBUG + m_nDYNAMIC_LIGHT = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bDOWATERFOG && m_bDYNAMIC_LIGHT && m_bSTATIC_LIGHT && m_bNUM_LIGHTS && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nDOWATERFOG ) + ( 8 * m_nDYNAMIC_LIGHT ) + ( 16 * m_nSTATIC_LIGHT ) + ( 32 * m_nNUM_LIGHTS ) + ( 160 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_eye_refract_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_DYNAMIC_LIGHT + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_NUM_LIGHTS + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyeglint_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyeglint_ps20.inc new file mode 100644 index 00000000..3c83a6ca --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyeglint_ps20.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_eyeglint_ps20_Static_Index +{ +public: + sdk_eyeglint_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_eyeglint_ps20 0 +class sdk_eyeglint_ps20_Dynamic_Index +{ +public: + sdk_eyeglint_ps20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_eyeglint_ps20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyeglint_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyeglint_ps20b.inc new file mode 100644 index 00000000..2dbb669b --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyeglint_ps20b.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_eyeglint_ps20b_Static_Index +{ +public: + sdk_eyeglint_ps20b_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_eyeglint_ps20b 0 +class sdk_eyeglint_ps20b_Dynamic_Index +{ +public: + sdk_eyeglint_ps20b_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_eyeglint_ps20b 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyeglint_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyeglint_vs20.inc new file mode 100644 index 00000000..05087222 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyeglint_vs20.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_eyeglint_vs20_Static_Index +{ +public: + sdk_eyeglint_vs20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_eyeglint_vs20 0 +class sdk_eyeglint_vs20_Dynamic_Index +{ +public: + sdk_eyeglint_vs20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_eyeglint_vs20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_flashlight_ps11.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_flashlight_ps11.inc new file mode 100644 index 00000000..721122e3 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_flashlight_ps11.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_flashlight_ps11_Static_Index +{ +public: + sdk_eyes_flashlight_ps11_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_eyes_flashlight_ps11 0 +class sdk_eyes_flashlight_ps11_Dynamic_Index +{ +public: + sdk_eyes_flashlight_ps11_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_eyes_flashlight_ps11 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_flashlight_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_flashlight_ps20.inc new file mode 100644 index 00000000..9e576f91 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_flashlight_ps20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_flashlight_ps20_Static_Index +{ +public: + sdk_eyes_flashlight_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_eyes_flashlight_ps20 0 +class sdk_eyes_flashlight_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_eyes_flashlight_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_eyes_flashlight_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_flashlight_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_flashlight_ps20b.inc new file mode 100644 index 00000000..d156ca25 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_flashlight_ps20b.inc @@ -0,0 +1,112 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_flashlight_ps20b_Static_Index +{ +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_eyes_flashlight_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_eyes_flashlight_ps20b psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_eyes_flashlight_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_eyes_flashlight_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_eyes_flashlight_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_flashlight_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_flashlight_ps30.inc new file mode 100644 index 00000000..57ddecae --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_flashlight_ps30.inc @@ -0,0 +1,112 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_flashlight_ps30_Static_Index +{ +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_eyes_flashlight_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_eyes_flashlight_ps30 psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_eyes_flashlight_ps30_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_eyes_flashlight_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_eyes_flashlight_ps30 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_flashlight_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_flashlight_vs20.inc new file mode 100644 index 00000000..c93c72de --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_flashlight_vs20.inc @@ -0,0 +1,110 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_flashlight_vs20_Static_Index +{ +public: + sdk_eyes_flashlight_vs20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_eyes_flashlight_vs20 0 +class sdk_eyes_flashlight_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_eyes_flashlight_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_eyes_flashlight_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_flashlight_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_flashlight_vs30.inc new file mode 100644 index 00000000..1244088b --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_flashlight_vs30.inc @@ -0,0 +1,135 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_flashlight_vs30_Static_Index +{ +public: + sdk_eyes_flashlight_vs30_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_eyes_flashlight_vs30 0 +class sdk_eyes_flashlight_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_eyes_flashlight_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bDOWATERFOG && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nDOWATERFOG ) + ( 8 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_eyes_flashlight_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_ps20.inc new file mode 100644 index 00000000..cbbb103d --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_ps20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_ps20_Static_Index +{ +public: + sdk_eyes_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_eyes_ps20 0 +class sdk_eyes_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_eyes_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_eyes_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_ps20b.inc new file mode 100644 index 00000000..f10f16d4 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_ps20b.inc @@ -0,0 +1,85 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_ps20b_Static_Index +{ +public: + sdk_eyes_ps20b_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_eyes_ps20b 0 +class sdk_eyes_ps20b_Dynamic_Index +{ +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_eyes_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bWRITE_DEPTH_TO_DESTALPHA && m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_eyes_ps20b psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_ps30.inc new file mode 100644 index 00000000..2353f65d --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_ps30.inc @@ -0,0 +1,85 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_ps30_Static_Index +{ +public: + sdk_eyes_ps30_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_eyes_ps30 0 +class sdk_eyes_ps30_Dynamic_Index +{ +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_eyes_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bWRITE_DEPTH_TO_DESTALPHA && m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_eyes_ps30 psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_vs20.inc new file mode 100644 index 00000000..5b896790 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_vs20.inc @@ -0,0 +1,262 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_vs20_Static_Index +{ +private: + int m_nINTRO; +#ifdef _DEBUG + bool m_bINTRO; +#endif +public: + void SetINTRO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nINTRO = i; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } + void SetINTRO( bool i ) + { + m_nINTRO = i ? 1 : 0; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nUSE_STATIC_CONTROL_FLOW; +#ifdef _DEBUG + bool m_bUSE_STATIC_CONTROL_FLOW; +#endif +public: + void SetUSE_STATIC_CONTROL_FLOW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nUSE_STATIC_CONTROL_FLOW = i; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } + void SetUSE_STATIC_CONTROL_FLOW( bool i ) + { + m_nUSE_STATIC_CONTROL_FLOW = i ? 1 : 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } +public: + sdk_eyes_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bINTRO = false; +#endif // _DEBUG + m_nINTRO = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = false; +#endif // _DEBUG + m_nUSE_STATIC_CONTROL_FLOW = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bINTRO && m_bHALFLAMBERT && m_bUSE_STATIC_CONTROL_FLOW; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 96 * m_nINTRO ) + ( 192 * m_nHALFLAMBERT ) + ( 384 * m_nUSE_STATIC_CONTROL_FLOW ) + 0; + } +}; +#define shaderStaticTest_sdk_eyes_vs20 vsh_forgot_to_set_static_INTRO + vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + 0 +class sdk_eyes_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nDYNAMIC_LIGHT; +#ifdef _DEBUG + bool m_bDYNAMIC_LIGHT; +#endif +public: + void SetDYNAMIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDYNAMIC_LIGHT = i; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } + void SetDYNAMIC_LIGHT( bool i ) + { + m_nDYNAMIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_eyes_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = false; +#endif // _DEBUG + m_nDYNAMIC_LIGHT = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bDOWATERFOG && m_bDYNAMIC_LIGHT && m_bSTATIC_LIGHT && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nDOWATERFOG ) + ( 8 * m_nDYNAMIC_LIGHT ) + ( 16 * m_nSTATIC_LIGHT ) + ( 32 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_eyes_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_DYNAMIC_LIGHT + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_vs30.inc new file mode 100644 index 00000000..d14fa273 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_eyes_vs30.inc @@ -0,0 +1,237 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_vs30_Static_Index +{ +private: + int m_nINTRO; +#ifdef _DEBUG + bool m_bINTRO; +#endif +public: + void SetINTRO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nINTRO = i; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } + void SetINTRO( bool i ) + { + m_nINTRO = i ? 1 : 0; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +public: + sdk_eyes_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bINTRO = false; +#endif // _DEBUG + m_nINTRO = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bINTRO && m_bHALFLAMBERT; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 64 * m_nINTRO ) + ( 128 * m_nHALFLAMBERT ) + 0; + } +}; +#define shaderStaticTest_sdk_eyes_vs30 vsh_forgot_to_set_static_INTRO + vsh_forgot_to_set_static_HALFLAMBERT + 0 +class sdk_eyes_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nDYNAMIC_LIGHT; +#ifdef _DEBUG + bool m_bDYNAMIC_LIGHT; +#endif +public: + void SetDYNAMIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDYNAMIC_LIGHT = i; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } + void SetDYNAMIC_LIGHT( bool i ) + { + m_nDYNAMIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_eyes_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = false; +#endif // _DEBUG + m_nDYNAMIC_LIGHT = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bDOWATERFOG && m_bDYNAMIC_LIGHT && m_bSTATIC_LIGHT && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nDOWATERFOG ) + ( 8 * m_nDYNAMIC_LIGHT ) + ( 16 * m_nSTATIC_LIGHT ) + ( 32 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_eyes_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_DYNAMIC_LIGHT + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flashlight_ps11.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flashlight_ps11.inc new file mode 100644 index 00000000..fc6f849d --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flashlight_ps11.inc @@ -0,0 +1,85 @@ +#include "shaderlib/cshader.h" +class sdk_flashlight_ps11_Static_Index +{ +private: + int m_nNORMALMAP; +#ifdef _DEBUG + bool m_bNORMALMAP; +#endif +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } + void SetNORMALMAP( bool i ) + { + m_nNORMALMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } +private: + int m_nNOCULL; +#ifdef _DEBUG + bool m_bNOCULL; +#endif +public: + void SetNOCULL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNOCULL = i; +#ifdef _DEBUG + m_bNOCULL = true; +#endif + } + void SetNOCULL( bool i ) + { + m_nNOCULL = i ? 1 : 0; +#ifdef _DEBUG + m_bNOCULL = true; +#endif + } +public: + sdk_flashlight_ps11_Static_Index( ) + { +#ifdef _DEBUG + m_bNORMALMAP = false; +#endif // _DEBUG + m_nNORMALMAP = 0; +#ifdef _DEBUG + m_bNOCULL = false; +#endif // _DEBUG + m_nNOCULL = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bNORMALMAP && m_bNOCULL; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nNORMALMAP ) + ( 2 * m_nNOCULL ) + 0; + } +}; +#define shaderStaticTest_sdk_flashlight_ps11 psh_forgot_to_set_static_NORMALMAP + psh_forgot_to_set_static_NOCULL + 0 +class sdk_flashlight_ps11_Dynamic_Index +{ +public: + sdk_flashlight_ps11_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_flashlight_ps11 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flashlight_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flashlight_ps20.inc new file mode 100644 index 00000000..3d25ff86 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flashlight_ps20.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_flashlight_ps20_Static_Index +{ +private: + int m_nNORMALMAP; +#ifdef _DEBUG + bool m_bNORMALMAP; +#endif +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } + void SetNORMALMAP( bool i ) + { + m_nNORMALMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } +private: + int m_nNORMALMAP2; +#ifdef _DEBUG + bool m_bNORMALMAP2; +#endif +public: + void SetNORMALMAP2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP2 = i; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } + void SetNORMALMAP2( bool i ) + { + m_nNORMALMAP2 = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } +private: + int m_nWORLDVERTEXTRANSITION; +#ifdef _DEBUG + bool m_bWORLDVERTEXTRANSITION; +#endif +public: + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } + void SetWORLDVERTEXTRANSITION( bool i ) + { + m_nWORLDVERTEXTRANSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +public: + sdk_flashlight_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bNORMALMAP = false; +#endif // _DEBUG + m_nNORMALMAP = 0; +#ifdef _DEBUG + m_bNORMALMAP2 = false; +#endif // _DEBUG + m_nNORMALMAP2 = 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = false; +#endif // _DEBUG + m_nWORLDVERTEXTRANSITION = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bNORMALMAP && m_bNORMALMAP2 && m_bWORLDVERTEXTRANSITION && m_bSEAMLESS && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nNORMALMAP ) + ( 6 * m_nNORMALMAP2 ) + ( 12 * m_nWORLDVERTEXTRANSITION ) + ( 24 * m_nSEAMLESS ) + ( 48 * m_nDETAILTEXTURE ) + ( 96 * m_nDETAIL_BLEND_MODE ) + 0; + } +}; +#define shaderStaticTest_sdk_flashlight_ps20 psh_forgot_to_set_static_NORMALMAP + psh_forgot_to_set_static_NORMALMAP2 + psh_forgot_to_set_static_WORLDVERTEXTRANSITION + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + 0 +class sdk_flashlight_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_flashlight_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_flashlight_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flashlight_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flashlight_ps20b.inc new file mode 100644 index 00000000..0e2bf822 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flashlight_ps20b.inc @@ -0,0 +1,262 @@ +#include "shaderlib/cshader.h" +class sdk_flashlight_ps20b_Static_Index +{ +private: + int m_nNORMALMAP; +#ifdef _DEBUG + bool m_bNORMALMAP; +#endif +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } + void SetNORMALMAP( bool i ) + { + m_nNORMALMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } +private: + int m_nNORMALMAP2; +#ifdef _DEBUG + bool m_bNORMALMAP2; +#endif +public: + void SetNORMALMAP2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP2 = i; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } + void SetNORMALMAP2( bool i ) + { + m_nNORMALMAP2 = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } +private: + int m_nWORLDVERTEXTRANSITION; +#ifdef _DEBUG + bool m_bWORLDVERTEXTRANSITION; +#endif +public: + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } + void SetWORLDVERTEXTRANSITION( bool i ) + { + m_nWORLDVERTEXTRANSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_flashlight_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bNORMALMAP = false; +#endif // _DEBUG + m_nNORMALMAP = 0; +#ifdef _DEBUG + m_bNORMALMAP2 = false; +#endif // _DEBUG + m_nNORMALMAP2 = 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = false; +#endif // _DEBUG + m_nWORLDVERTEXTRANSITION = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bNORMALMAP && m_bNORMALMAP2 && m_bWORLDVERTEXTRANSITION && m_bSEAMLESS && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nNORMALMAP ) + ( 12 * m_nNORMALMAP2 ) + ( 24 * m_nWORLDVERTEXTRANSITION ) + ( 48 * m_nSEAMLESS ) + ( 96 * m_nDETAILTEXTURE ) + ( 192 * m_nDETAIL_BLEND_MODE ) + ( 384 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_flashlight_ps20b psh_forgot_to_set_static_NORMALMAP + psh_forgot_to_set_static_NORMALMAP2 + psh_forgot_to_set_static_WORLDVERTEXTRANSITION + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_flashlight_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_flashlight_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_flashlight_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flashlight_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flashlight_ps30.inc new file mode 100644 index 00000000..88331a5b --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flashlight_ps30.inc @@ -0,0 +1,262 @@ +#include "shaderlib/cshader.h" +class sdk_flashlight_ps30_Static_Index +{ +private: + int m_nNORMALMAP; +#ifdef _DEBUG + bool m_bNORMALMAP; +#endif +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } + void SetNORMALMAP( bool i ) + { + m_nNORMALMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } +private: + int m_nNORMALMAP2; +#ifdef _DEBUG + bool m_bNORMALMAP2; +#endif +public: + void SetNORMALMAP2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP2 = i; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } + void SetNORMALMAP2( bool i ) + { + m_nNORMALMAP2 = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } +private: + int m_nWORLDVERTEXTRANSITION; +#ifdef _DEBUG + bool m_bWORLDVERTEXTRANSITION; +#endif +public: + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } + void SetWORLDVERTEXTRANSITION( bool i ) + { + m_nWORLDVERTEXTRANSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_flashlight_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bNORMALMAP = false; +#endif // _DEBUG + m_nNORMALMAP = 0; +#ifdef _DEBUG + m_bNORMALMAP2 = false; +#endif // _DEBUG + m_nNORMALMAP2 = 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = false; +#endif // _DEBUG + m_nWORLDVERTEXTRANSITION = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bNORMALMAP && m_bNORMALMAP2 && m_bWORLDVERTEXTRANSITION && m_bSEAMLESS && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nNORMALMAP ) + ( 12 * m_nNORMALMAP2 ) + ( 24 * m_nWORLDVERTEXTRANSITION ) + ( 48 * m_nSEAMLESS ) + ( 96 * m_nDETAILTEXTURE ) + ( 192 * m_nDETAIL_BLEND_MODE ) + ( 384 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_flashlight_ps30 psh_forgot_to_set_static_NORMALMAP + psh_forgot_to_set_static_NORMALMAP2 + psh_forgot_to_set_static_WORLDVERTEXTRANSITION + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_flashlight_ps30_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_flashlight_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_flashlight_ps30 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flesh_interior_blended_pass_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flesh_interior_blended_pass_ps20.inc new file mode 100644 index 00000000..0b73f03b --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flesh_interior_blended_pass_ps20.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_flesh_interior_blended_pass_ps20_Static_Index +{ +public: + sdk_flesh_interior_blended_pass_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_flesh_interior_blended_pass_ps20 0 +class sdk_flesh_interior_blended_pass_ps20_Dynamic_Index +{ +public: + sdk_flesh_interior_blended_pass_ps20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_flesh_interior_blended_pass_ps20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flesh_interior_blended_pass_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flesh_interior_blended_pass_ps20b.inc new file mode 100644 index 00000000..dd85606f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flesh_interior_blended_pass_ps20b.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_flesh_interior_blended_pass_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_flesh_interior_blended_pass_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_flesh_interior_blended_pass_ps20b 0 +class sdk_flesh_interior_blended_pass_ps20b_Dynamic_Index +{ +public: + sdk_flesh_interior_blended_pass_ps20b_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_flesh_interior_blended_pass_ps20b 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flesh_interior_blended_pass_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flesh_interior_blended_pass_vs20.inc new file mode 100644 index 00000000..e2241b31 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_flesh_interior_blended_pass_vs20.inc @@ -0,0 +1,237 @@ +#include "shaderlib/cshader.h" +class sdk_flesh_interior_blended_pass_vs20_Static_Index +{ +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nUSE_STATIC_CONTROL_FLOW; +#ifdef _DEBUG + bool m_bUSE_STATIC_CONTROL_FLOW; +#endif +public: + void SetUSE_STATIC_CONTROL_FLOW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nUSE_STATIC_CONTROL_FLOW = i; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } + void SetUSE_STATIC_CONTROL_FLOW( bool i ) + { + m_nUSE_STATIC_CONTROL_FLOW = i ? 1 : 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } +public: + sdk_flesh_interior_blended_pass_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = false; +#endif // _DEBUG + m_nUSE_STATIC_CONTROL_FLOW = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bHALFLAMBERT && m_bUSE_STATIC_CONTROL_FLOW; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 96 * m_nHALFLAMBERT ) + ( 192 * m_nUSE_STATIC_CONTROL_FLOW ) + 0; + } +}; +#define shaderStaticTest_sdk_flesh_interior_blended_pass_vs20 vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + 0 +class sdk_flesh_interior_blended_pass_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nDYNAMIC_LIGHT; +#ifdef _DEBUG + bool m_bDYNAMIC_LIGHT; +#endif +public: + void SetDYNAMIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDYNAMIC_LIGHT = i; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } + void SetDYNAMIC_LIGHT( bool i ) + { + m_nDYNAMIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_flesh_interior_blended_pass_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = false; +#endif // _DEBUG + m_nDYNAMIC_LIGHT = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bDOWATERFOG && m_bDYNAMIC_LIGHT && m_bSTATIC_LIGHT && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nDOWATERFOG ) + ( 8 * m_nDYNAMIC_LIGHT ) + ( 16 * m_nSTATIC_LIGHT ) + ( 32 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_flesh_interior_blended_pass_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_DYNAMIC_LIGHT + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_decal_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_decal_ps20.inc new file mode 100644 index 00000000..91c81ef9 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_decal_ps20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_decal_ps20_Static_Index +{ +public: + sdk_lightmappedgeneric_decal_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_decal_ps20 0 +class sdk_lightmappedgeneric_decal_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_lightmappedgeneric_decal_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_decal_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_decal_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_decal_ps20b.inc new file mode 100644 index 00000000..e11d31ca --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_decal_ps20b.inc @@ -0,0 +1,87 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_decal_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_lightmappedgeneric_decal_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_decal_ps20b 0 +class sdk_lightmappedgeneric_decal_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_lightmappedgeneric_decal_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_decal_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_decal_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_decal_vs20.inc new file mode 100644 index 00000000..a53c8769 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_decal_vs20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_decal_vs20_Static_Index +{ +public: + sdk_lightmappedgeneric_decal_vs20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_decal_vs20 0 +class sdk_lightmappedgeneric_decal_vs20_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_lightmappedgeneric_decal_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_decal_vs20 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_flashlight_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_flashlight_ps20.inc new file mode 100644 index 00000000..e24bcc01 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_flashlight_ps20.inc @@ -0,0 +1,262 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_flashlight_ps20_Static_Index +{ +private: + int m_nNORMALMAP; +#ifdef _DEBUG + bool m_bNORMALMAP; +#endif +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } + void SetNORMALMAP( bool i ) + { + m_nNORMALMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } +private: + int m_nNORMALMAP2; +#ifdef _DEBUG + bool m_bNORMALMAP2; +#endif +public: + void SetNORMALMAP2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP2 = i; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } + void SetNORMALMAP2( bool i ) + { + m_nNORMALMAP2 = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } +private: + int m_nWORLDVERTEXTRANSITION; +#ifdef _DEBUG + bool m_bWORLDVERTEXTRANSITION; +#endif +public: + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } + void SetWORLDVERTEXTRANSITION( bool i ) + { + m_nWORLDVERTEXTRANSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } +private: + int m_nFANCY_BLENDING; +#ifdef _DEBUG + bool m_bFANCY_BLENDING; +#endif +public: + void SetFANCY_BLENDING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFANCY_BLENDING = i; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif + } + void SetFANCY_BLENDING( bool i ) + { + m_nFANCY_BLENDING = i ? 1 : 0; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nBASETEXTURETRANSFORM2; +#ifdef _DEBUG + bool m_bBASETEXTURETRANSFORM2; +#endif +public: + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } + void SetBASETEXTURETRANSFORM2( bool i ) + { + m_nBASETEXTURETRANSFORM2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bNORMALMAP = false; +#endif // _DEBUG + m_nNORMALMAP = 0; +#ifdef _DEBUG + m_bNORMALMAP2 = false; +#endif // _DEBUG + m_nNORMALMAP2 = 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = false; +#endif // _DEBUG + m_nWORLDVERTEXTRANSITION = 0; +#ifdef _DEBUG + m_bFANCY_BLENDING = false; +#endif // _DEBUG + m_nFANCY_BLENDING = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + m_nBASETEXTURETRANSFORM2 = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bNORMALMAP && m_bNORMALMAP2 && m_bWORLDVERTEXTRANSITION && m_bFANCY_BLENDING && m_bSEAMLESS && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bBASETEXTURETRANSFORM2; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nNORMALMAP ) + ( 6 * m_nNORMALMAP2 ) + ( 12 * m_nWORLDVERTEXTRANSITION ) + ( 24 * m_nFANCY_BLENDING ) + ( 48 * m_nSEAMLESS ) + ( 96 * m_nDETAILTEXTURE ) + ( 192 * m_nDETAIL_BLEND_MODE ) + ( 384 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_flashlight_ps20 psh_forgot_to_set_static_NORMALMAP + psh_forgot_to_set_static_NORMALMAP2 + psh_forgot_to_set_static_WORLDVERTEXTRANSITION + psh_forgot_to_set_static_FANCY_BLENDING + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_BASETEXTURETRANSFORM2 + 0 +class sdk_lightmappedgeneric_flashlight_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_flashlight_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_flashlight_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_flashlight_ps20b.inc new file mode 100644 index 00000000..e4ba14aa --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_flashlight_ps20b.inc @@ -0,0 +1,362 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_flashlight_ps20b_Static_Index +{ +private: + int m_nNORMALMAP; +#ifdef _DEBUG + bool m_bNORMALMAP; +#endif +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } + void SetNORMALMAP( bool i ) + { + m_nNORMALMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } +private: + int m_nNORMALMAP2; +#ifdef _DEBUG + bool m_bNORMALMAP2; +#endif +public: + void SetNORMALMAP2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP2 = i; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } + void SetNORMALMAP2( bool i ) + { + m_nNORMALMAP2 = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } +private: + int m_nWORLDVERTEXTRANSITION; +#ifdef _DEBUG + bool m_bWORLDVERTEXTRANSITION; +#endif +public: + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } + void SetWORLDVERTEXTRANSITION( bool i ) + { + m_nWORLDVERTEXTRANSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } +private: + int m_nFANCY_BLENDING; +#ifdef _DEBUG + bool m_bFANCY_BLENDING; +#endif +public: + void SetFANCY_BLENDING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFANCY_BLENDING = i; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif + } + void SetFANCY_BLENDING( bool i ) + { + m_nFANCY_BLENDING = i ? 1 : 0; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +private: + int m_nPHONG; +#ifdef _DEBUG + bool m_bPHONG; +#endif +public: + void SetPHONG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONG = i; +#ifdef _DEBUG + m_bPHONG = true; +#endif + } + void SetPHONG( bool i ) + { + m_nPHONG = i ? 1 : 0; +#ifdef _DEBUG + m_bPHONG = true; +#endif + } +private: + int m_nPHONGMASK; +#ifdef _DEBUG + bool m_bPHONGMASK; +#endif +public: + void SetPHONGMASK( int i ) + { + Assert( i >= 0 && i <= 3 ); + m_nPHONGMASK = i; +#ifdef _DEBUG + m_bPHONGMASK = true; +#endif + } + void SetPHONGMASK( bool i ) + { + m_nPHONGMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bPHONGMASK = true; +#endif + } +private: + int m_nBASETEXTURETRANSFORM2; +#ifdef _DEBUG + bool m_bBASETEXTURETRANSFORM2; +#endif +public: + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } + void SetBASETEXTURETRANSFORM2( bool i ) + { + m_nBASETEXTURETRANSFORM2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bNORMALMAP = false; +#endif // _DEBUG + m_nNORMALMAP = 0; +#ifdef _DEBUG + m_bNORMALMAP2 = false; +#endif // _DEBUG + m_nNORMALMAP2 = 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = false; +#endif // _DEBUG + m_nWORLDVERTEXTRANSITION = 0; +#ifdef _DEBUG + m_bFANCY_BLENDING = false; +#endif // _DEBUG + m_nFANCY_BLENDING = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; +#ifdef _DEBUG + m_bPHONG = false; +#endif // _DEBUG + m_nPHONG = 0; +#ifdef _DEBUG + m_bPHONGMASK = false; +#endif // _DEBUG + m_nPHONGMASK = 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + m_nBASETEXTURETRANSFORM2 = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bNORMALMAP && m_bNORMALMAP2 && m_bWORLDVERTEXTRANSITION && m_bFANCY_BLENDING && m_bSEAMLESS && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bFLASHLIGHTDEPTHFILTERMODE && m_bPHONG && m_bPHONGMASK && m_bBASETEXTURETRANSFORM2; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nNORMALMAP ) + ( 12 * m_nNORMALMAP2 ) + ( 24 * m_nWORLDVERTEXTRANSITION ) + ( 48 * m_nFANCY_BLENDING ) + ( 96 * m_nSEAMLESS ) + ( 192 * m_nDETAILTEXTURE ) + ( 384 * m_nDETAIL_BLEND_MODE ) + ( 768 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 2304 * m_nPHONG ) + ( 4608 * m_nPHONGMASK ) + ( 18432 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_flashlight_ps20b psh_forgot_to_set_static_NORMALMAP + psh_forgot_to_set_static_NORMALMAP2 + psh_forgot_to_set_static_WORLDVERTEXTRANSITION + psh_forgot_to_set_static_FANCY_BLENDING + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_PHONG + psh_forgot_to_set_static_PHONGMASK + psh_forgot_to_set_static_BASETEXTURETRANSFORM2 + 0 +class sdk_lightmappedgeneric_flashlight_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_flashlight_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_flashlight_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_flashlight_ps30.inc new file mode 100644 index 00000000..a9734f15 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_flashlight_ps30.inc @@ -0,0 +1,362 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_flashlight_ps30_Static_Index +{ +private: + int m_nNORMALMAP; +#ifdef _DEBUG + bool m_bNORMALMAP; +#endif +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } + void SetNORMALMAP( bool i ) + { + m_nNORMALMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } +private: + int m_nNORMALMAP2; +#ifdef _DEBUG + bool m_bNORMALMAP2; +#endif +public: + void SetNORMALMAP2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP2 = i; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } + void SetNORMALMAP2( bool i ) + { + m_nNORMALMAP2 = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } +private: + int m_nWORLDVERTEXTRANSITION; +#ifdef _DEBUG + bool m_bWORLDVERTEXTRANSITION; +#endif +public: + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } + void SetWORLDVERTEXTRANSITION( bool i ) + { + m_nWORLDVERTEXTRANSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } +private: + int m_nFANCY_BLENDING; +#ifdef _DEBUG + bool m_bFANCY_BLENDING; +#endif +public: + void SetFANCY_BLENDING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFANCY_BLENDING = i; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif + } + void SetFANCY_BLENDING( bool i ) + { + m_nFANCY_BLENDING = i ? 1 : 0; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +private: + int m_nPHONG; +#ifdef _DEBUG + bool m_bPHONG; +#endif +public: + void SetPHONG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONG = i; +#ifdef _DEBUG + m_bPHONG = true; +#endif + } + void SetPHONG( bool i ) + { + m_nPHONG = i ? 1 : 0; +#ifdef _DEBUG + m_bPHONG = true; +#endif + } +private: + int m_nPHONGMASK; +#ifdef _DEBUG + bool m_bPHONGMASK; +#endif +public: + void SetPHONGMASK( int i ) + { + Assert( i >= 0 && i <= 3 ); + m_nPHONGMASK = i; +#ifdef _DEBUG + m_bPHONGMASK = true; +#endif + } + void SetPHONGMASK( bool i ) + { + m_nPHONGMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bPHONGMASK = true; +#endif + } +private: + int m_nBASETEXTURETRANSFORM2; +#ifdef _DEBUG + bool m_bBASETEXTURETRANSFORM2; +#endif +public: + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } + void SetBASETEXTURETRANSFORM2( bool i ) + { + m_nBASETEXTURETRANSFORM2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bNORMALMAP = false; +#endif // _DEBUG + m_nNORMALMAP = 0; +#ifdef _DEBUG + m_bNORMALMAP2 = false; +#endif // _DEBUG + m_nNORMALMAP2 = 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = false; +#endif // _DEBUG + m_nWORLDVERTEXTRANSITION = 0; +#ifdef _DEBUG + m_bFANCY_BLENDING = false; +#endif // _DEBUG + m_nFANCY_BLENDING = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; +#ifdef _DEBUG + m_bPHONG = false; +#endif // _DEBUG + m_nPHONG = 0; +#ifdef _DEBUG + m_bPHONGMASK = false; +#endif // _DEBUG + m_nPHONGMASK = 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + m_nBASETEXTURETRANSFORM2 = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bNORMALMAP && m_bNORMALMAP2 && m_bWORLDVERTEXTRANSITION && m_bFANCY_BLENDING && m_bSEAMLESS && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bFLASHLIGHTDEPTHFILTERMODE && m_bPHONG && m_bPHONGMASK && m_bBASETEXTURETRANSFORM2; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nNORMALMAP ) + ( 12 * m_nNORMALMAP2 ) + ( 24 * m_nWORLDVERTEXTRANSITION ) + ( 48 * m_nFANCY_BLENDING ) + ( 96 * m_nSEAMLESS ) + ( 192 * m_nDETAILTEXTURE ) + ( 384 * m_nDETAIL_BLEND_MODE ) + ( 768 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 2304 * m_nPHONG ) + ( 4608 * m_nPHONGMASK ) + ( 18432 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_flashlight_ps30 psh_forgot_to_set_static_NORMALMAP + psh_forgot_to_set_static_NORMALMAP2 + psh_forgot_to_set_static_WORLDVERTEXTRANSITION + psh_forgot_to_set_static_FANCY_BLENDING + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_PHONG + psh_forgot_to_set_static_PHONGMASK + psh_forgot_to_set_static_BASETEXTURETRANSFORM2 + 0 +class sdk_lightmappedgeneric_flashlight_ps30_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_flashlight_ps30 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_flashlight_vs11.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_flashlight_vs11.inc new file mode 100644 index 00000000..94142c09 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_flashlight_vs11.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_flashlight_vs11_Static_Index +{ +private: + int m_nNORMALMAP; +#ifdef _DEBUG + bool m_bNORMALMAP; +#endif +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } + void SetNORMALMAP( bool i ) + { + m_nNORMALMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } +private: + int m_nWORLDVERTEXTRANSITION; +#ifdef _DEBUG + bool m_bWORLDVERTEXTRANSITION; +#endif +public: + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } + void SetWORLDVERTEXTRANSITION( bool i ) + { + m_nWORLDVERTEXTRANSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_vs11_Static_Index( ) + { +#ifdef _DEBUG + m_bNORMALMAP = false; +#endif // _DEBUG + m_nNORMALMAP = 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = false; +#endif // _DEBUG + m_nWORLDVERTEXTRANSITION = 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bNORMALMAP && m_bWORLDVERTEXTRANSITION && m_bVERTEXCOLOR; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nNORMALMAP ) + ( 4 * m_nWORLDVERTEXTRANSITION ) + ( 8 * m_nVERTEXCOLOR ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_flashlight_vs11 vsh_forgot_to_set_static_NORMALMAP + vsh_forgot_to_set_static_WORLDVERTEXTRANSITION + vsh_forgot_to_set_static_VERTEXCOLOR + 0 +class sdk_lightmappedgeneric_flashlight_vs11_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_vs11_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_flashlight_vs11 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_flashlight_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_flashlight_vs20.inc new file mode 100644 index 00000000..95edefe2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_flashlight_vs20.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_flashlight_vs20_Static_Index +{ +private: + int m_nNORMALMAP; +#ifdef _DEBUG + bool m_bNORMALMAP; +#endif +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } + void SetNORMALMAP( bool i ) + { + m_nNORMALMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } +private: + int m_nWORLDVERTEXTRANSITION; +#ifdef _DEBUG + bool m_bWORLDVERTEXTRANSITION; +#endif +public: + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } + void SetWORLDVERTEXTRANSITION( bool i ) + { + m_nWORLDVERTEXTRANSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nDETAIL; +#ifdef _DEBUG + bool m_bDETAIL; +#endif +public: + void SetDETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL = i; +#ifdef _DEBUG + m_bDETAIL = true; +#endif + } + void SetDETAIL( bool i ) + { + m_nDETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL = true; +#endif + } +private: + int m_nPHONG; +#ifdef _DEBUG + bool m_bPHONG; +#endif +public: + void SetPHONG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONG = i; +#ifdef _DEBUG + m_bPHONG = true; +#endif + } + void SetPHONG( bool i ) + { + m_nPHONG = i ? 1 : 0; +#ifdef _DEBUG + m_bPHONG = true; +#endif + } +private: + int m_nBASETEXTURETRANSFORM2; +#ifdef _DEBUG + bool m_bBASETEXTURETRANSFORM2; +#endif +public: + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } + void SetBASETEXTURETRANSFORM2( bool i ) + { + m_nBASETEXTURETRANSFORM2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bNORMALMAP = false; +#endif // _DEBUG + m_nNORMALMAP = 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = false; +#endif // _DEBUG + m_nWORLDVERTEXTRANSITION = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bDETAIL = false; +#endif // _DEBUG + m_nDETAIL = 0; +#ifdef _DEBUG + m_bPHONG = false; +#endif // _DEBUG + m_nPHONG = 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + m_nBASETEXTURETRANSFORM2 = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bNORMALMAP && m_bWORLDVERTEXTRANSITION && m_bSEAMLESS && m_bDETAIL && m_bPHONG && m_bBASETEXTURETRANSFORM2; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nNORMALMAP ) + ( 4 * m_nWORLDVERTEXTRANSITION ) + ( 8 * m_nSEAMLESS ) + ( 16 * m_nDETAIL ) + ( 32 * m_nPHONG ) + ( 64 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_flashlight_vs20 vsh_forgot_to_set_static_NORMALMAP + vsh_forgot_to_set_static_WORLDVERTEXTRANSITION + vsh_forgot_to_set_static_SEAMLESS + vsh_forgot_to_set_static_DETAIL + vsh_forgot_to_set_static_PHONG + vsh_forgot_to_set_static_BASETEXTURETRANSFORM2 + 0 +class sdk_lightmappedgeneric_flashlight_vs20_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_flashlight_vs20 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_flashlight_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_flashlight_vs30.inc new file mode 100644 index 00000000..376110e3 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_flashlight_vs30.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_flashlight_vs30_Static_Index +{ +private: + int m_nNORMALMAP; +#ifdef _DEBUG + bool m_bNORMALMAP; +#endif +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } + void SetNORMALMAP( bool i ) + { + m_nNORMALMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } +private: + int m_nWORLDVERTEXTRANSITION; +#ifdef _DEBUG + bool m_bWORLDVERTEXTRANSITION; +#endif +public: + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } + void SetWORLDVERTEXTRANSITION( bool i ) + { + m_nWORLDVERTEXTRANSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nDETAIL; +#ifdef _DEBUG + bool m_bDETAIL; +#endif +public: + void SetDETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL = i; +#ifdef _DEBUG + m_bDETAIL = true; +#endif + } + void SetDETAIL( bool i ) + { + m_nDETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL = true; +#endif + } +private: + int m_nPHONG; +#ifdef _DEBUG + bool m_bPHONG; +#endif +public: + void SetPHONG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONG = i; +#ifdef _DEBUG + m_bPHONG = true; +#endif + } + void SetPHONG( bool i ) + { + m_nPHONG = i ? 1 : 0; +#ifdef _DEBUG + m_bPHONG = true; +#endif + } +private: + int m_nBASETEXTURETRANSFORM2; +#ifdef _DEBUG + bool m_bBASETEXTURETRANSFORM2; +#endif +public: + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } + void SetBASETEXTURETRANSFORM2( bool i ) + { + m_nBASETEXTURETRANSFORM2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bNORMALMAP = false; +#endif // _DEBUG + m_nNORMALMAP = 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = false; +#endif // _DEBUG + m_nWORLDVERTEXTRANSITION = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bDETAIL = false; +#endif // _DEBUG + m_nDETAIL = 0; +#ifdef _DEBUG + m_bPHONG = false; +#endif // _DEBUG + m_nPHONG = 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + m_nBASETEXTURETRANSFORM2 = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bNORMALMAP && m_bWORLDVERTEXTRANSITION && m_bSEAMLESS && m_bDETAIL && m_bPHONG && m_bBASETEXTURETRANSFORM2; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nNORMALMAP ) + ( 4 * m_nWORLDVERTEXTRANSITION ) + ( 8 * m_nSEAMLESS ) + ( 16 * m_nDETAIL ) + ( 32 * m_nPHONG ) + ( 64 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_flashlight_vs30 vsh_forgot_to_set_static_NORMALMAP + vsh_forgot_to_set_static_WORLDVERTEXTRANSITION + vsh_forgot_to_set_static_SEAMLESS + vsh_forgot_to_set_static_DETAIL + vsh_forgot_to_set_static_PHONG + vsh_forgot_to_set_static_BASETEXTURETRANSFORM2 + 0 +class sdk_lightmappedgeneric_flashlight_vs30_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_flashlight_vs30 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_lightingonly_overbright2_ps11.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_lightingonly_overbright2_ps11.inc new file mode 100644 index 00000000..d11eaeb9 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_lightingonly_overbright2_ps11.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_lightingonly_overbright2_ps11_Static_Index +{ +public: + sdk_lightmappedgeneric_lightingonly_overbright2_ps11_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_lightingonly_overbright2_ps11 0 +class sdk_lightmappedgeneric_lightingonly_overbright2_ps11_Dynamic_Index +{ +public: + sdk_lightmappedgeneric_lightingonly_overbright2_ps11_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_lightingonly_overbright2_ps11 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_lightingonly_vs11.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_lightingonly_vs11.inc new file mode 100644 index 00000000..5bb3dc94 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_lightingonly_vs11.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_lightingonly_vs11_Static_Index +{ +public: + sdk_lightmappedgeneric_lightingonly_vs11_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_lightingonly_vs11 0 +class sdk_lightmappedgeneric_lightingonly_vs11_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_lightmappedgeneric_lightingonly_vs11_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_lightingonly_vs11 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_ps11.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_ps11.inc new file mode 100644 index 00000000..30f358a1 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_ps11.inc @@ -0,0 +1,160 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_ps11_Static_Index +{ +private: + int m_nBASETEXTURE; +#ifdef _DEBUG + bool m_bBASETEXTURE; +#endif +public: + void SetBASETEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE = i; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } + void SetBASETEXTURE( bool i ) + { + m_nBASETEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } +private: + int m_nENVMAP; +#ifdef _DEBUG + bool m_bENVMAP; +#endif +public: + void SetENVMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAP = i; +#ifdef _DEBUG + m_bENVMAP = true; +#endif + } + void SetENVMAP( bool i ) + { + m_nENVMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAP = true; +#endif + } +private: + int m_nENVMAPMASK; +#ifdef _DEBUG + bool m_bENVMAPMASK; +#endif +public: + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } + void SetENVMAPMASK( bool i ) + { + m_nENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nBASEALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bBASEALPHAENVMAPMASK; +#endif +public: + void SetBASEALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASEALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } + void SetBASEALPHAENVMAPMASK( bool i ) + { + m_nBASEALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } +public: + sdk_lightmappedgeneric_ps11_Static_Index( ) + { +#ifdef _DEBUG + m_bBASETEXTURE = false; +#endif // _DEBUG + m_nBASETEXTURE = 0; +#ifdef _DEBUG + m_bENVMAP = false; +#endif // _DEBUG + m_nENVMAP = 0; +#ifdef _DEBUG + m_bENVMAPMASK = false; +#endif // _DEBUG + m_nENVMAPMASK = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nBASEALPHAENVMAPMASK = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bBASETEXTURE && m_bENVMAP && m_bENVMAPMASK && m_bSELFILLUM && m_bBASEALPHAENVMAPMASK; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nBASETEXTURE ) + ( 2 * m_nENVMAP ) + ( 4 * m_nENVMAPMASK ) + ( 8 * m_nSELFILLUM ) + ( 16 * m_nBASEALPHAENVMAPMASK ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_ps11 psh_forgot_to_set_static_BASETEXTURE + psh_forgot_to_set_static_ENVMAP + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + 0 +class sdk_lightmappedgeneric_ps11_Dynamic_Index +{ +public: + sdk_lightmappedgeneric_ps11_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_ps11 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_ps20b.inc new file mode 100644 index 00000000..0a321f16 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_ps20b.inc @@ -0,0 +1,712 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_ps20b_Static_Index +{ +private: + int m_nMASKEDBLENDING; +#ifdef _DEBUG + bool m_bMASKEDBLENDING; +#endif +public: + void SetMASKEDBLENDING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMASKEDBLENDING = i; +#ifdef _DEBUG + m_bMASKEDBLENDING = true; +#endif + } + void SetMASKEDBLENDING( bool i ) + { + m_nMASKEDBLENDING = i ? 1 : 0; +#ifdef _DEBUG + m_bMASKEDBLENDING = true; +#endif + } +private: + int m_nBASETEXTURE2; +#ifdef _DEBUG + bool m_bBASETEXTURE2; +#endif +public: + void SetBASETEXTURE2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE2 = i; +#ifdef _DEBUG + m_bBASETEXTURE2 = true; +#endif + } + void SetBASETEXTURE2( bool i ) + { + m_nBASETEXTURE2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE2 = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +private: + int m_nBUMPMAP2; +#ifdef _DEBUG + bool m_bBUMPMAP2; +#endif +public: + void SetBUMPMAP2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP2 = i; +#ifdef _DEBUG + m_bBUMPMAP2 = true; +#endif + } + void SetBUMPMAP2( bool i ) + { + m_nBUMPMAP2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP2 = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nENVMAPMASK; +#ifdef _DEBUG + bool m_bENVMAPMASK; +#endif +public: + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } + void SetENVMAPMASK( bool i ) + { + m_nENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } +private: + int m_nBASEALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bBASEALPHAENVMAPMASK; +#endif +public: + void SetBASEALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASEALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } + void SetBASEALPHAENVMAPMASK( bool i ) + { + m_nBASEALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nNORMALMAPALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bNORMALMAPALPHAENVMAPMASK; +#endif +public: + void SetNORMALMAPALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAPALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif + } + void SetNORMALMAPALPHAENVMAPMASK( bool i ) + { + m_nNORMALMAPALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif + } +private: + int m_nDIFFUSEBUMPMAP; +#ifdef _DEBUG + bool m_bDIFFUSEBUMPMAP; +#endif +public: + void SetDIFFUSEBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSEBUMPMAP = i; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } + void SetDIFFUSEBUMPMAP( bool i ) + { + m_nDIFFUSEBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } +private: + int m_nBASETEXTURENOENVMAP; +#ifdef _DEBUG + bool m_bBASETEXTURENOENVMAP; +#endif +public: + void SetBASETEXTURENOENVMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURENOENVMAP = i; +#ifdef _DEBUG + m_bBASETEXTURENOENVMAP = true; +#endif + } + void SetBASETEXTURENOENVMAP( bool i ) + { + m_nBASETEXTURENOENVMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURENOENVMAP = true; +#endif + } +private: + int m_nBASETEXTURE2NOENVMAP; +#ifdef _DEBUG + bool m_bBASETEXTURE2NOENVMAP; +#endif +public: + void SetBASETEXTURE2NOENVMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE2NOENVMAP = i; +#ifdef _DEBUG + m_bBASETEXTURE2NOENVMAP = true; +#endif + } + void SetBASETEXTURE2NOENVMAP( bool i ) + { + m_nBASETEXTURE2NOENVMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE2NOENVMAP = true; +#endif + } +private: + int m_nWARPLIGHTING; +#ifdef _DEBUG + bool m_bWARPLIGHTING; +#endif +public: + void SetWARPLIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWARPLIGHTING = i; +#ifdef _DEBUG + m_bWARPLIGHTING = true; +#endif + } + void SetWARPLIGHTING( bool i ) + { + m_nWARPLIGHTING = i ? 1 : 0; +#ifdef _DEBUG + m_bWARPLIGHTING = true; +#endif + } +private: + int m_nFANCY_BLENDING; +#ifdef _DEBUG + bool m_bFANCY_BLENDING; +#endif +public: + void SetFANCY_BLENDING( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFANCY_BLENDING = i; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif + } + void SetFANCY_BLENDING( bool i ) + { + m_nFANCY_BLENDING = i ? 1 : 0; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif + } +private: + int m_nRELIEF_MAPPING; +#ifdef _DEBUG + bool m_bRELIEF_MAPPING; +#endif +public: + void SetRELIEF_MAPPING( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nRELIEF_MAPPING = i; +#ifdef _DEBUG + m_bRELIEF_MAPPING = true; +#endif + } + void SetRELIEF_MAPPING( bool i ) + { + m_nRELIEF_MAPPING = i ? 1 : 0; +#ifdef _DEBUG + m_bRELIEF_MAPPING = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nNORMAL_DECODE_MODE; +#ifdef _DEBUG + bool m_bNORMAL_DECODE_MODE; +#endif +public: + void SetNORMAL_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMAL_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } + void SetNORMAL_DECODE_MODE( bool i ) + { + m_nNORMAL_DECODE_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } +private: + int m_nNORMALMASK_DECODE_MODE; +#ifdef _DEBUG + bool m_bNORMALMASK_DECODE_MODE; +#endif +public: + void SetNORMALMASK_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMALMASK_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMALMASK_DECODE_MODE = true; +#endif + } + void SetNORMALMASK_DECODE_MODE( bool i ) + { + m_nNORMALMASK_DECODE_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMASK_DECODE_MODE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 11 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nBASETEXTURETRANSFORM2; +#ifdef _DEBUG + bool m_bBASETEXTURETRANSFORM2; +#endif +public: + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } + void SetBASETEXTURETRANSFORM2( bool i ) + { + m_nBASETEXTURETRANSFORM2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } +public: + sdk_lightmappedgeneric_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bMASKEDBLENDING = false; +#endif // _DEBUG + m_nMASKEDBLENDING = 0; +#ifdef _DEBUG + m_bBASETEXTURE2 = false; +#endif // _DEBUG + m_nBASETEXTURE2 = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; +#ifdef _DEBUG + m_bBUMPMAP2 = false; +#endif // _DEBUG + m_nBUMPMAP2 = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bENVMAPMASK = false; +#endif // _DEBUG + m_nENVMAPMASK = 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nBASEALPHAENVMAPMASK = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nNORMALMAPALPHAENVMAPMASK = 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = false; +#endif // _DEBUG + m_nDIFFUSEBUMPMAP = 0; +#ifdef _DEBUG + m_bBASETEXTURENOENVMAP = false; +#endif // _DEBUG + m_nBASETEXTURENOENVMAP = 0; +#ifdef _DEBUG + m_bBASETEXTURE2NOENVMAP = false; +#endif // _DEBUG + m_nBASETEXTURE2NOENVMAP = 0; +#ifdef _DEBUG + m_bWARPLIGHTING = false; +#endif // _DEBUG + m_nWARPLIGHTING = 0; +#ifdef _DEBUG + m_bFANCY_BLENDING = false; +#endif // _DEBUG + m_nFANCY_BLENDING = 0; +#ifdef _DEBUG + m_bRELIEF_MAPPING = false; +#endif // _DEBUG + m_nRELIEF_MAPPING = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = false; +#endif // _DEBUG + m_nNORMAL_DECODE_MODE = 0; +#ifdef _DEBUG + m_bNORMALMASK_DECODE_MODE = false; +#endif // _DEBUG + m_nNORMALMASK_DECODE_MODE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + m_nBASETEXTURETRANSFORM2 = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bMASKEDBLENDING && m_bBASETEXTURE2 && m_bDETAILTEXTURE && m_bBUMPMAP && m_bBUMPMAP2 && m_bCUBEMAP && m_bENVMAPMASK && m_bBASEALPHAENVMAPMASK && m_bSELFILLUM && m_bNORMALMAPALPHAENVMAPMASK && m_bDIFFUSEBUMPMAP && m_bBASETEXTURENOENVMAP && m_bBASETEXTURE2NOENVMAP && m_bWARPLIGHTING && m_bFANCY_BLENDING && m_bRELIEF_MAPPING && m_bSEAMLESS && m_bNORMAL_DECODE_MODE && m_bNORMALMASK_DECODE_MODE && m_bDETAIL_BLEND_MODE && m_bBASETEXTURETRANSFORM2; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 96 * m_nMASKEDBLENDING ) + ( 192 * m_nBASETEXTURE2 ) + ( 384 * m_nDETAILTEXTURE ) + ( 768 * m_nBUMPMAP ) + ( 2304 * m_nBUMPMAP2 ) + ( 4608 * m_nCUBEMAP ) + ( 9216 * m_nENVMAPMASK ) + ( 18432 * m_nBASEALPHAENVMAPMASK ) + ( 36864 * m_nSELFILLUM ) + ( 73728 * m_nNORMALMAPALPHAENVMAPMASK ) + ( 147456 * m_nDIFFUSEBUMPMAP ) + ( 294912 * m_nBASETEXTURENOENVMAP ) + ( 589824 * m_nBASETEXTURE2NOENVMAP ) + ( 1179648 * m_nWARPLIGHTING ) + ( 2359296 * m_nFANCY_BLENDING ) + ( 7077888 * m_nRELIEF_MAPPING ) + ( 7077888 * m_nSEAMLESS ) + ( 14155776 * m_nNORMAL_DECODE_MODE ) + ( 14155776 * m_nNORMALMASK_DECODE_MODE ) + ( 14155776 * m_nDETAIL_BLEND_MODE ) + ( 169869312 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_ps20b psh_forgot_to_set_static_MASKEDBLENDING + psh_forgot_to_set_static_BASETEXTURE2 + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_BUMPMAP + psh_forgot_to_set_static_BUMPMAP2 + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_DIFFUSEBUMPMAP + psh_forgot_to_set_static_BASETEXTURENOENVMAP + psh_forgot_to_set_static_BASETEXTURE2NOENVMAP + psh_forgot_to_set_static_WARPLIGHTING + psh_forgot_to_set_static_FANCY_BLENDING + psh_forgot_to_set_static_RELIEF_MAPPING + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_NORMAL_DECODE_MODE + psh_forgot_to_set_static_NORMALMASK_DECODE_MODE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_BASETEXTURETRANSFORM2 + 0 +class sdk_lightmappedgeneric_ps20b_Dynamic_Index +{ +private: + int m_nFASTPATHENVMAPCONTRAST; +#ifdef _DEBUG + bool m_bFASTPATHENVMAPCONTRAST; +#endif +public: + void SetFASTPATHENVMAPCONTRAST( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFASTPATHENVMAPCONTRAST = i; +#ifdef _DEBUG + m_bFASTPATHENVMAPCONTRAST = true; +#endif + } + void SetFASTPATHENVMAPCONTRAST( bool i ) + { + m_nFASTPATHENVMAPCONTRAST = i ? 1 : 0; +#ifdef _DEBUG + m_bFASTPATHENVMAPCONTRAST = true; +#endif + } +private: + int m_nFASTPATH; +#ifdef _DEBUG + bool m_bFASTPATH; +#endif +public: + void SetFASTPATH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFASTPATH = i; +#ifdef _DEBUG + m_bFASTPATH = true; +#endif + } + void SetFASTPATH( bool i ) + { + m_nFASTPATH = i ? 1 : 0; +#ifdef _DEBUG + m_bFASTPATH = true; +#endif + } +private: + int m_nWRITEWATERFOGTODESTALPHA; +#ifdef _DEBUG + bool m_bWRITEWATERFOGTODESTALPHA; +#endif +public: + void SetWRITEWATERFOGTODESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITEWATERFOGTODESTALPHA = i; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } + void SetWRITEWATERFOGTODESTALPHA( bool i ) + { + m_nWRITEWATERFOGTODESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +public: + sdk_lightmappedgeneric_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bFASTPATHENVMAPCONTRAST = false; +#endif // _DEBUG + m_nFASTPATHENVMAPCONTRAST = 0; +#ifdef _DEBUG + m_bFASTPATH = false; +#endif // _DEBUG + m_nFASTPATH = 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = false; +#endif // _DEBUG + m_nWRITEWATERFOGTODESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bFASTPATHENVMAPCONTRAST && m_bFASTPATH && m_bWRITEWATERFOGTODESTALPHA && m_bPIXELFOGTYPE && m_bLIGHTING_PREVIEW && m_bWRITE_DEPTH_TO_DESTALPHA; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nFASTPATHENVMAPCONTRAST ) + ( 2 * m_nFASTPATH ) + ( 4 * m_nWRITEWATERFOGTODESTALPHA ) + ( 8 * m_nPIXELFOGTYPE ) + ( 16 * m_nLIGHTING_PREVIEW ) + ( 48 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_ps20b psh_forgot_to_set_dynamic_FASTPATHENVMAPCONTRAST + psh_forgot_to_set_dynamic_FASTPATH + psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_LIGHTING_PREVIEW + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_ps30.inc new file mode 100644 index 00000000..c291836f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_ps30.inc @@ -0,0 +1,687 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_ps30_Static_Index +{ +private: + int m_nMASKEDBLENDING; +#ifdef _DEBUG + bool m_bMASKEDBLENDING; +#endif +public: + void SetMASKEDBLENDING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMASKEDBLENDING = i; +#ifdef _DEBUG + m_bMASKEDBLENDING = true; +#endif + } + void SetMASKEDBLENDING( bool i ) + { + m_nMASKEDBLENDING = i ? 1 : 0; +#ifdef _DEBUG + m_bMASKEDBLENDING = true; +#endif + } +private: + int m_nBASETEXTURE2; +#ifdef _DEBUG + bool m_bBASETEXTURE2; +#endif +public: + void SetBASETEXTURE2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE2 = i; +#ifdef _DEBUG + m_bBASETEXTURE2 = true; +#endif + } + void SetBASETEXTURE2( bool i ) + { + m_nBASETEXTURE2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE2 = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +private: + int m_nBUMPMAP2; +#ifdef _DEBUG + bool m_bBUMPMAP2; +#endif +public: + void SetBUMPMAP2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP2 = i; +#ifdef _DEBUG + m_bBUMPMAP2 = true; +#endif + } + void SetBUMPMAP2( bool i ) + { + m_nBUMPMAP2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP2 = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nENVMAPMASK; +#ifdef _DEBUG + bool m_bENVMAPMASK; +#endif +public: + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } + void SetENVMAPMASK( bool i ) + { + m_nENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } +private: + int m_nBASEALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bBASEALPHAENVMAPMASK; +#endif +public: + void SetBASEALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASEALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } + void SetBASEALPHAENVMAPMASK( bool i ) + { + m_nBASEALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nNORMALMAPALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bNORMALMAPALPHAENVMAPMASK; +#endif +public: + void SetNORMALMAPALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAPALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif + } + void SetNORMALMAPALPHAENVMAPMASK( bool i ) + { + m_nNORMALMAPALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif + } +private: + int m_nDIFFUSEBUMPMAP; +#ifdef _DEBUG + bool m_bDIFFUSEBUMPMAP; +#endif +public: + void SetDIFFUSEBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSEBUMPMAP = i; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } + void SetDIFFUSEBUMPMAP( bool i ) + { + m_nDIFFUSEBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } +private: + int m_nBASETEXTURENOENVMAP; +#ifdef _DEBUG + bool m_bBASETEXTURENOENVMAP; +#endif +public: + void SetBASETEXTURENOENVMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURENOENVMAP = i; +#ifdef _DEBUG + m_bBASETEXTURENOENVMAP = true; +#endif + } + void SetBASETEXTURENOENVMAP( bool i ) + { + m_nBASETEXTURENOENVMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURENOENVMAP = true; +#endif + } +private: + int m_nBASETEXTURE2NOENVMAP; +#ifdef _DEBUG + bool m_bBASETEXTURE2NOENVMAP; +#endif +public: + void SetBASETEXTURE2NOENVMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE2NOENVMAP = i; +#ifdef _DEBUG + m_bBASETEXTURE2NOENVMAP = true; +#endif + } + void SetBASETEXTURE2NOENVMAP( bool i ) + { + m_nBASETEXTURE2NOENVMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE2NOENVMAP = true; +#endif + } +private: + int m_nWARPLIGHTING; +#ifdef _DEBUG + bool m_bWARPLIGHTING; +#endif +public: + void SetWARPLIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWARPLIGHTING = i; +#ifdef _DEBUG + m_bWARPLIGHTING = true; +#endif + } + void SetWARPLIGHTING( bool i ) + { + m_nWARPLIGHTING = i ? 1 : 0; +#ifdef _DEBUG + m_bWARPLIGHTING = true; +#endif + } +private: + int m_nFANCY_BLENDING; +#ifdef _DEBUG + bool m_bFANCY_BLENDING; +#endif +public: + void SetFANCY_BLENDING( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFANCY_BLENDING = i; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif + } + void SetFANCY_BLENDING( bool i ) + { + m_nFANCY_BLENDING = i ? 1 : 0; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nNORMAL_DECODE_MODE; +#ifdef _DEBUG + bool m_bNORMAL_DECODE_MODE; +#endif +public: + void SetNORMAL_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMAL_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } + void SetNORMAL_DECODE_MODE( bool i ) + { + m_nNORMAL_DECODE_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } +private: + int m_nNORMALMASK_DECODE_MODE; +#ifdef _DEBUG + bool m_bNORMALMASK_DECODE_MODE; +#endif +public: + void SetNORMALMASK_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMALMASK_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMALMASK_DECODE_MODE = true; +#endif + } + void SetNORMALMASK_DECODE_MODE( bool i ) + { + m_nNORMALMASK_DECODE_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMASK_DECODE_MODE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 11 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nBASETEXTURETRANSFORM2; +#ifdef _DEBUG + bool m_bBASETEXTURETRANSFORM2; +#endif +public: + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } + void SetBASETEXTURETRANSFORM2( bool i ) + { + m_nBASETEXTURETRANSFORM2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } +public: + sdk_lightmappedgeneric_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bMASKEDBLENDING = false; +#endif // _DEBUG + m_nMASKEDBLENDING = 0; +#ifdef _DEBUG + m_bBASETEXTURE2 = false; +#endif // _DEBUG + m_nBASETEXTURE2 = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; +#ifdef _DEBUG + m_bBUMPMAP2 = false; +#endif // _DEBUG + m_nBUMPMAP2 = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bENVMAPMASK = false; +#endif // _DEBUG + m_nENVMAPMASK = 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nBASEALPHAENVMAPMASK = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nNORMALMAPALPHAENVMAPMASK = 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = false; +#endif // _DEBUG + m_nDIFFUSEBUMPMAP = 0; +#ifdef _DEBUG + m_bBASETEXTURENOENVMAP = false; +#endif // _DEBUG + m_nBASETEXTURENOENVMAP = 0; +#ifdef _DEBUG + m_bBASETEXTURE2NOENVMAP = false; +#endif // _DEBUG + m_nBASETEXTURE2NOENVMAP = 0; +#ifdef _DEBUG + m_bWARPLIGHTING = false; +#endif // _DEBUG + m_nWARPLIGHTING = 0; +#ifdef _DEBUG + m_bFANCY_BLENDING = false; +#endif // _DEBUG + m_nFANCY_BLENDING = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = false; +#endif // _DEBUG + m_nNORMAL_DECODE_MODE = 0; +#ifdef _DEBUG + m_bNORMALMASK_DECODE_MODE = false; +#endif // _DEBUG + m_nNORMALMASK_DECODE_MODE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + m_nBASETEXTURETRANSFORM2 = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bMASKEDBLENDING && m_bBASETEXTURE2 && m_bDETAILTEXTURE && m_bBUMPMAP && m_bBUMPMAP2 && m_bCUBEMAP && m_bENVMAPMASK && m_bBASEALPHAENVMAPMASK && m_bSELFILLUM && m_bNORMALMAPALPHAENVMAPMASK && m_bDIFFUSEBUMPMAP && m_bBASETEXTURENOENVMAP && m_bBASETEXTURE2NOENVMAP && m_bWARPLIGHTING && m_bFANCY_BLENDING && m_bSEAMLESS && m_bNORMAL_DECODE_MODE && m_bNORMALMASK_DECODE_MODE && m_bDETAIL_BLEND_MODE && m_bBASETEXTURETRANSFORM2; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 96 * m_nMASKEDBLENDING ) + ( 192 * m_nBASETEXTURE2 ) + ( 384 * m_nDETAILTEXTURE ) + ( 768 * m_nBUMPMAP ) + ( 2304 * m_nBUMPMAP2 ) + ( 4608 * m_nCUBEMAP ) + ( 9216 * m_nENVMAPMASK ) + ( 18432 * m_nBASEALPHAENVMAPMASK ) + ( 36864 * m_nSELFILLUM ) + ( 73728 * m_nNORMALMAPALPHAENVMAPMASK ) + ( 147456 * m_nDIFFUSEBUMPMAP ) + ( 294912 * m_nBASETEXTURENOENVMAP ) + ( 589824 * m_nBASETEXTURE2NOENVMAP ) + ( 1179648 * m_nWARPLIGHTING ) + ( 2359296 * m_nFANCY_BLENDING ) + ( 7077888 * m_nSEAMLESS ) + ( 14155776 * m_nNORMAL_DECODE_MODE ) + ( 14155776 * m_nNORMALMASK_DECODE_MODE ) + ( 14155776 * m_nDETAIL_BLEND_MODE ) + ( 169869312 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_ps30 psh_forgot_to_set_static_MASKEDBLENDING + psh_forgot_to_set_static_BASETEXTURE2 + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_BUMPMAP + psh_forgot_to_set_static_BUMPMAP2 + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_DIFFUSEBUMPMAP + psh_forgot_to_set_static_BASETEXTURENOENVMAP + psh_forgot_to_set_static_BASETEXTURE2NOENVMAP + psh_forgot_to_set_static_WARPLIGHTING + psh_forgot_to_set_static_FANCY_BLENDING + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_NORMAL_DECODE_MODE + psh_forgot_to_set_static_NORMALMASK_DECODE_MODE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_BASETEXTURETRANSFORM2 + 0 +class sdk_lightmappedgeneric_ps30_Dynamic_Index +{ +private: + int m_nFASTPATHENVMAPCONTRAST; +#ifdef _DEBUG + bool m_bFASTPATHENVMAPCONTRAST; +#endif +public: + void SetFASTPATHENVMAPCONTRAST( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFASTPATHENVMAPCONTRAST = i; +#ifdef _DEBUG + m_bFASTPATHENVMAPCONTRAST = true; +#endif + } + void SetFASTPATHENVMAPCONTRAST( bool i ) + { + m_nFASTPATHENVMAPCONTRAST = i ? 1 : 0; +#ifdef _DEBUG + m_bFASTPATHENVMAPCONTRAST = true; +#endif + } +private: + int m_nFASTPATH; +#ifdef _DEBUG + bool m_bFASTPATH; +#endif +public: + void SetFASTPATH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFASTPATH = i; +#ifdef _DEBUG + m_bFASTPATH = true; +#endif + } + void SetFASTPATH( bool i ) + { + m_nFASTPATH = i ? 1 : 0; +#ifdef _DEBUG + m_bFASTPATH = true; +#endif + } +private: + int m_nWRITEWATERFOGTODESTALPHA; +#ifdef _DEBUG + bool m_bWRITEWATERFOGTODESTALPHA; +#endif +public: + void SetWRITEWATERFOGTODESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITEWATERFOGTODESTALPHA = i; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } + void SetWRITEWATERFOGTODESTALPHA( bool i ) + { + m_nWRITEWATERFOGTODESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +public: + sdk_lightmappedgeneric_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bFASTPATHENVMAPCONTRAST = false; +#endif // _DEBUG + m_nFASTPATHENVMAPCONTRAST = 0; +#ifdef _DEBUG + m_bFASTPATH = false; +#endif // _DEBUG + m_nFASTPATH = 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = false; +#endif // _DEBUG + m_nWRITEWATERFOGTODESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bFASTPATHENVMAPCONTRAST && m_bFASTPATH && m_bWRITEWATERFOGTODESTALPHA && m_bPIXELFOGTYPE && m_bLIGHTING_PREVIEW && m_bWRITE_DEPTH_TO_DESTALPHA; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nFASTPATHENVMAPCONTRAST ) + ( 2 * m_nFASTPATH ) + ( 4 * m_nWRITEWATERFOGTODESTALPHA ) + ( 8 * m_nPIXELFOGTYPE ) + ( 16 * m_nLIGHTING_PREVIEW ) + ( 48 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_ps30 psh_forgot_to_set_dynamic_FASTPATHENVMAPCONTRAST + psh_forgot_to_set_dynamic_FASTPATH + psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_LIGHTING_PREVIEW + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_vs20.inc new file mode 100644 index 00000000..90c3dbb9 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_vs20.inc @@ -0,0 +1,362 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_vs20_Static_Index +{ +private: + int m_nENVMAP_MASK; +#ifdef _DEBUG + bool m_bENVMAP_MASK; +#endif +public: + void SetENVMAP_MASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAP_MASK = i; +#ifdef _DEBUG + m_bENVMAP_MASK = true; +#endif + } + void SetENVMAP_MASK( bool i ) + { + m_nENVMAP_MASK = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAP_MASK = true; +#endif + } +private: + int m_nTANGENTSPACE; +#ifdef _DEBUG + bool m_bTANGENTSPACE; +#endif +public: + void SetTANGENTSPACE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nTANGENTSPACE = i; +#ifdef _DEBUG + m_bTANGENTSPACE = true; +#endif + } + void SetTANGENTSPACE( bool i ) + { + m_nTANGENTSPACE = i ? 1 : 0; +#ifdef _DEBUG + m_bTANGENTSPACE = true; +#endif + } +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +private: + int m_nDIFFUSEBUMPMAP; +#ifdef _DEBUG + bool m_bDIFFUSEBUMPMAP; +#endif +public: + void SetDIFFUSEBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSEBUMPMAP = i; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } + void SetDIFFUSEBUMPMAP( bool i ) + { + m_nDIFFUSEBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nVERTEXALPHATEXBLENDFACTOR; +#ifdef _DEBUG + bool m_bVERTEXALPHATEXBLENDFACTOR; +#endif +public: + void SetVERTEXALPHATEXBLENDFACTOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXALPHATEXBLENDFACTOR = i; +#ifdef _DEBUG + m_bVERTEXALPHATEXBLENDFACTOR = true; +#endif + } + void SetVERTEXALPHATEXBLENDFACTOR( bool i ) + { + m_nVERTEXALPHATEXBLENDFACTOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXALPHATEXBLENDFACTOR = true; +#endif + } +private: + int m_nRELIEF_MAPPING; +#ifdef _DEBUG + bool m_bRELIEF_MAPPING; +#endif +public: + void SetRELIEF_MAPPING( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nRELIEF_MAPPING = i; +#ifdef _DEBUG + m_bRELIEF_MAPPING = true; +#endif + } + void SetRELIEF_MAPPING( bool i ) + { + m_nRELIEF_MAPPING = i ? 1 : 0; +#ifdef _DEBUG + m_bRELIEF_MAPPING = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nBUMPMASK; +#ifdef _DEBUG + bool m_bBUMPMASK; +#endif +public: + void SetBUMPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMASK = i; +#ifdef _DEBUG + m_bBUMPMASK = true; +#endif + } + void SetBUMPMASK( bool i ) + { + m_nBUMPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMASK = true; +#endif + } +private: + int m_nBASETEXTURETRANSFORM2; +#ifdef _DEBUG + bool m_bBASETEXTURETRANSFORM2; +#endif +public: + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } + void SetBASETEXTURETRANSFORM2( bool i ) + { + m_nBASETEXTURETRANSFORM2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } +public: + sdk_lightmappedgeneric_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bENVMAP_MASK = false; +#endif // _DEBUG + m_nENVMAP_MASK = 0; +#ifdef _DEBUG + m_bTANGENTSPACE = false; +#endif // _DEBUG + m_nTANGENTSPACE = 0; +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = false; +#endif // _DEBUG + m_nDIFFUSEBUMPMAP = 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bVERTEXALPHATEXBLENDFACTOR = false; +#endif // _DEBUG + m_nVERTEXALPHATEXBLENDFACTOR = 0; +#ifdef _DEBUG + m_bRELIEF_MAPPING = false; +#endif // _DEBUG + m_nRELIEF_MAPPING = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bBUMPMASK = false; +#endif // _DEBUG + m_nBUMPMASK = 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + m_nBASETEXTURETRANSFORM2 = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bENVMAP_MASK && m_bTANGENTSPACE && m_bBUMPMAP && m_bDIFFUSEBUMPMAP && m_bVERTEXCOLOR && m_bVERTEXALPHATEXBLENDFACTOR && m_bRELIEF_MAPPING && m_bSEAMLESS && m_bBUMPMASK && m_bBASETEXTURETRANSFORM2; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 8 * m_nENVMAP_MASK ) + ( 16 * m_nTANGENTSPACE ) + ( 32 * m_nBUMPMAP ) + ( 64 * m_nDIFFUSEBUMPMAP ) + ( 128 * m_nVERTEXCOLOR ) + ( 256 * m_nVERTEXALPHATEXBLENDFACTOR ) + ( 512 * m_nRELIEF_MAPPING ) + ( 512 * m_nSEAMLESS ) + ( 1024 * m_nBUMPMASK ) + ( 2048 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_vs20 vsh_forgot_to_set_static_ENVMAP_MASK + vsh_forgot_to_set_static_TANGENTSPACE + vsh_forgot_to_set_static_BUMPMAP + vsh_forgot_to_set_static_DIFFUSEBUMPMAP + vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_VERTEXALPHATEXBLENDFACTOR + vsh_forgot_to_set_static_RELIEF_MAPPING + vsh_forgot_to_set_static_SEAMLESS + vsh_forgot_to_set_static_BUMPMASK + vsh_forgot_to_set_static_BASETEXTURETRANSFORM2 + 0 +class sdk_lightmappedgeneric_vs20_Dynamic_Index +{ +private: + int m_nFASTPATH; +#ifdef _DEBUG + bool m_bFASTPATH; +#endif +public: + void SetFASTPATH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFASTPATH = i; +#ifdef _DEBUG + m_bFASTPATH = true; +#endif + } + void SetFASTPATH( bool i ) + { + m_nFASTPATH = i ? 1 : 0; +#ifdef _DEBUG + m_bFASTPATH = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +public: + sdk_lightmappedgeneric_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bFASTPATH = false; +#endif // _DEBUG + m_nFASTPATH = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bFASTPATH && m_bDOWATERFOG && m_bLIGHTING_PREVIEW; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nFASTPATH ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nLIGHTING_PREVIEW ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_vs20 vsh_forgot_to_set_dynamic_FASTPATH + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_LIGHTING_PREVIEW + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_vs30.inc new file mode 100644 index 00000000..5fda5413 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedgeneric_vs30.inc @@ -0,0 +1,362 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_vs30_Static_Index +{ +private: + int m_nENVMAP_MASK; +#ifdef _DEBUG + bool m_bENVMAP_MASK; +#endif +public: + void SetENVMAP_MASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAP_MASK = i; +#ifdef _DEBUG + m_bENVMAP_MASK = true; +#endif + } + void SetENVMAP_MASK( bool i ) + { + m_nENVMAP_MASK = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAP_MASK = true; +#endif + } +private: + int m_nTANGENTSPACE; +#ifdef _DEBUG + bool m_bTANGENTSPACE; +#endif +public: + void SetTANGENTSPACE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nTANGENTSPACE = i; +#ifdef _DEBUG + m_bTANGENTSPACE = true; +#endif + } + void SetTANGENTSPACE( bool i ) + { + m_nTANGENTSPACE = i ? 1 : 0; +#ifdef _DEBUG + m_bTANGENTSPACE = true; +#endif + } +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +private: + int m_nDIFFUSEBUMPMAP; +#ifdef _DEBUG + bool m_bDIFFUSEBUMPMAP; +#endif +public: + void SetDIFFUSEBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSEBUMPMAP = i; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } + void SetDIFFUSEBUMPMAP( bool i ) + { + m_nDIFFUSEBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nVERTEXALPHATEXBLENDFACTOR; +#ifdef _DEBUG + bool m_bVERTEXALPHATEXBLENDFACTOR; +#endif +public: + void SetVERTEXALPHATEXBLENDFACTOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXALPHATEXBLENDFACTOR = i; +#ifdef _DEBUG + m_bVERTEXALPHATEXBLENDFACTOR = true; +#endif + } + void SetVERTEXALPHATEXBLENDFACTOR( bool i ) + { + m_nVERTEXALPHATEXBLENDFACTOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXALPHATEXBLENDFACTOR = true; +#endif + } +private: + int m_nRELIEF_MAPPING; +#ifdef _DEBUG + bool m_bRELIEF_MAPPING; +#endif +public: + void SetRELIEF_MAPPING( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nRELIEF_MAPPING = i; +#ifdef _DEBUG + m_bRELIEF_MAPPING = true; +#endif + } + void SetRELIEF_MAPPING( bool i ) + { + m_nRELIEF_MAPPING = i ? 1 : 0; +#ifdef _DEBUG + m_bRELIEF_MAPPING = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nBUMPMASK; +#ifdef _DEBUG + bool m_bBUMPMASK; +#endif +public: + void SetBUMPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMASK = i; +#ifdef _DEBUG + m_bBUMPMASK = true; +#endif + } + void SetBUMPMASK( bool i ) + { + m_nBUMPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMASK = true; +#endif + } +private: + int m_nBASETEXTURETRANSFORM2; +#ifdef _DEBUG + bool m_bBASETEXTURETRANSFORM2; +#endif +public: + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } + void SetBASETEXTURETRANSFORM2( bool i ) + { + m_nBASETEXTURETRANSFORM2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } +public: + sdk_lightmappedgeneric_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bENVMAP_MASK = false; +#endif // _DEBUG + m_nENVMAP_MASK = 0; +#ifdef _DEBUG + m_bTANGENTSPACE = false; +#endif // _DEBUG + m_nTANGENTSPACE = 0; +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = false; +#endif // _DEBUG + m_nDIFFUSEBUMPMAP = 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bVERTEXALPHATEXBLENDFACTOR = false; +#endif // _DEBUG + m_nVERTEXALPHATEXBLENDFACTOR = 0; +#ifdef _DEBUG + m_bRELIEF_MAPPING = false; +#endif // _DEBUG + m_nRELIEF_MAPPING = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bBUMPMASK = false; +#endif // _DEBUG + m_nBUMPMASK = 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + m_nBASETEXTURETRANSFORM2 = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bENVMAP_MASK && m_bTANGENTSPACE && m_bBUMPMAP && m_bDIFFUSEBUMPMAP && m_bVERTEXCOLOR && m_bVERTEXALPHATEXBLENDFACTOR && m_bRELIEF_MAPPING && m_bSEAMLESS && m_bBUMPMASK && m_bBASETEXTURETRANSFORM2; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 8 * m_nENVMAP_MASK ) + ( 16 * m_nTANGENTSPACE ) + ( 32 * m_nBUMPMAP ) + ( 64 * m_nDIFFUSEBUMPMAP ) + ( 128 * m_nVERTEXCOLOR ) + ( 256 * m_nVERTEXALPHATEXBLENDFACTOR ) + ( 512 * m_nRELIEF_MAPPING ) + ( 512 * m_nSEAMLESS ) + ( 1024 * m_nBUMPMASK ) + ( 2048 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_vs30 vsh_forgot_to_set_static_ENVMAP_MASK + vsh_forgot_to_set_static_TANGENTSPACE + vsh_forgot_to_set_static_BUMPMAP + vsh_forgot_to_set_static_DIFFUSEBUMPMAP + vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_VERTEXALPHATEXBLENDFACTOR + vsh_forgot_to_set_static_RELIEF_MAPPING + vsh_forgot_to_set_static_SEAMLESS + vsh_forgot_to_set_static_BUMPMASK + vsh_forgot_to_set_static_BASETEXTURETRANSFORM2 + 0 +class sdk_lightmappedgeneric_vs30_Dynamic_Index +{ +private: + int m_nFASTPATH; +#ifdef _DEBUG + bool m_bFASTPATH; +#endif +public: + void SetFASTPATH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFASTPATH = i; +#ifdef _DEBUG + m_bFASTPATH = true; +#endif + } + void SetFASTPATH( bool i ) + { + m_nFASTPATH = i ? 1 : 0; +#ifdef _DEBUG + m_bFASTPATH = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +public: + sdk_lightmappedgeneric_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bFASTPATH = false; +#endif // _DEBUG + m_nFASTPATH = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bFASTPATH && m_bDOWATERFOG && m_bLIGHTING_PREVIEW; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nFASTPATH ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nLIGHTING_PREVIEW ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_vs30 vsh_forgot_to_set_dynamic_FASTPATH + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_LIGHTING_PREVIEW + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedreflective_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedreflective_ps20.inc new file mode 100644 index 00000000..469d8062 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedreflective_ps20.inc @@ -0,0 +1,162 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedreflective_ps20_Static_Index +{ +private: + int m_nBASETEXTURE; +#ifdef _DEBUG + bool m_bBASETEXTURE; +#endif +public: + void SetBASETEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE = i; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } + void SetBASETEXTURE( bool i ) + { + m_nBASETEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } +private: + int m_nREFLECT; +#ifdef _DEBUG + bool m_bREFLECT; +#endif +public: + void SetREFLECT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFLECT = i; +#ifdef _DEBUG + m_bREFLECT = true; +#endif + } + void SetREFLECT( bool i ) + { + m_nREFLECT = i ? 1 : 0; +#ifdef _DEBUG + m_bREFLECT = true; +#endif + } +private: + int m_nREFRACT; +#ifdef _DEBUG + bool m_bREFRACT; +#endif +public: + void SetREFRACT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFRACT = i; +#ifdef _DEBUG + m_bREFRACT = true; +#endif + } + void SetREFRACT( bool i ) + { + m_nREFRACT = i ? 1 : 0; +#ifdef _DEBUG + m_bREFRACT = true; +#endif + } +private: + int m_nENVMAPMASK; +#ifdef _DEBUG + bool m_bENVMAPMASK; +#endif +public: + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } + void SetENVMAPMASK( bool i ) + { + m_nENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } +public: + sdk_lightmappedreflective_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bBASETEXTURE = false; +#endif // _DEBUG + m_nBASETEXTURE = 0; +#ifdef _DEBUG + m_bREFLECT = false; +#endif // _DEBUG + m_nREFLECT = 0; +#ifdef _DEBUG + m_bREFRACT = false; +#endif // _DEBUG + m_nREFRACT = 0; +#ifdef _DEBUG + m_bENVMAPMASK = false; +#endif // _DEBUG + m_nENVMAPMASK = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bBASETEXTURE && m_bREFLECT && m_bREFRACT && m_bENVMAPMASK; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nBASETEXTURE ) + ( 4 * m_nREFLECT ) + ( 8 * m_nREFRACT ) + ( 16 * m_nENVMAPMASK ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedreflective_ps20 psh_forgot_to_set_static_BASETEXTURE + psh_forgot_to_set_static_REFLECT + psh_forgot_to_set_static_REFRACT + psh_forgot_to_set_static_ENVMAPMASK + 0 +class sdk_lightmappedreflective_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_lightmappedreflective_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedreflective_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedreflective_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedreflective_ps20b.inc new file mode 100644 index 00000000..e5a00725 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedreflective_ps20b.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedreflective_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nBASETEXTURE; +#ifdef _DEBUG + bool m_bBASETEXTURE; +#endif +public: + void SetBASETEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE = i; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } + void SetBASETEXTURE( bool i ) + { + m_nBASETEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } +private: + int m_nREFLECT; +#ifdef _DEBUG + bool m_bREFLECT; +#endif +public: + void SetREFLECT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFLECT = i; +#ifdef _DEBUG + m_bREFLECT = true; +#endif + } + void SetREFLECT( bool i ) + { + m_nREFLECT = i ? 1 : 0; +#ifdef _DEBUG + m_bREFLECT = true; +#endif + } +private: + int m_nREFRACT; +#ifdef _DEBUG + bool m_bREFRACT; +#endif +public: + void SetREFRACT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFRACT = i; +#ifdef _DEBUG + m_bREFRACT = true; +#endif + } + void SetREFRACT( bool i ) + { + m_nREFRACT = i ? 1 : 0; +#ifdef _DEBUG + m_bREFRACT = true; +#endif + } +private: + int m_nENVMAPMASK; +#ifdef _DEBUG + bool m_bENVMAPMASK; +#endif +public: + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } + void SetENVMAPMASK( bool i ) + { + m_nENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } +public: + sdk_lightmappedreflective_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bBASETEXTURE = false; +#endif // _DEBUG + m_nBASETEXTURE = 0; +#ifdef _DEBUG + m_bREFLECT = false; +#endif // _DEBUG + m_nREFLECT = 0; +#ifdef _DEBUG + m_bREFRACT = false; +#endif // _DEBUG + m_nREFRACT = 0; +#ifdef _DEBUG + m_bENVMAPMASK = false; +#endif // _DEBUG + m_nENVMAPMASK = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bBASETEXTURE && m_bREFLECT && m_bREFRACT && m_bENVMAPMASK; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nCONVERT_TO_SRGB ) + ( 8 * m_nBASETEXTURE ) + ( 16 * m_nREFLECT ) + ( 32 * m_nREFRACT ) + ( 64 * m_nENVMAPMASK ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedreflective_ps20b psh_forgot_to_set_static_BASETEXTURE + psh_forgot_to_set_static_REFLECT + psh_forgot_to_set_static_REFRACT + psh_forgot_to_set_static_ENVMAPMASK + 0 +class sdk_lightmappedreflective_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +public: + sdk_lightmappedreflective_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bWRITE_DEPTH_TO_DESTALPHA; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedreflective_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedreflective_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedreflective_vs20.inc new file mode 100644 index 00000000..4321a47b --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_lightmappedreflective_vs20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedreflective_vs20_Static_Index +{ +private: + int m_nBASETEXTURE; +#ifdef _DEBUG + bool m_bBASETEXTURE; +#endif +public: + void SetBASETEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE = i; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } + void SetBASETEXTURE( bool i ) + { + m_nBASETEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } +public: + sdk_lightmappedreflective_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bBASETEXTURE = false; +#endif // _DEBUG + m_nBASETEXTURE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bBASETEXTURE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nBASETEXTURE ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedreflective_vs20 vsh_forgot_to_set_static_BASETEXTURE + 0 +class sdk_lightmappedreflective_vs20_Dynamic_Index +{ +public: + sdk_lightmappedreflective_vs20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedreflective_vs20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_refract_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_refract_ps20.inc new file mode 100644 index 00000000..839d80a2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_refract_ps20.inc @@ -0,0 +1,262 @@ +#include "shaderlib/cshader.h" +class sdk_refract_ps20_Static_Index +{ +private: + int m_nBLUR; +#ifdef _DEBUG + bool m_bBLUR; +#endif +public: + void SetBLUR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLUR = i; +#ifdef _DEBUG + m_bBLUR = true; +#endif + } + void SetBLUR( bool i ) + { + m_nBLUR = i ? 1 : 0; +#ifdef _DEBUG + m_bBLUR = true; +#endif + } +private: + int m_nFADEOUTONSILHOUETTE; +#ifdef _DEBUG + bool m_bFADEOUTONSILHOUETTE; +#endif +public: + void SetFADEOUTONSILHOUETTE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFADEOUTONSILHOUETTE = i; +#ifdef _DEBUG + m_bFADEOUTONSILHOUETTE = true; +#endif + } + void SetFADEOUTONSILHOUETTE( bool i ) + { + m_nFADEOUTONSILHOUETTE = i ? 1 : 0; +#ifdef _DEBUG + m_bFADEOUTONSILHOUETTE = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nREFRACTTINTTEXTURE; +#ifdef _DEBUG + bool m_bREFRACTTINTTEXTURE; +#endif +public: + void SetREFRACTTINTTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFRACTTINTTEXTURE = i; +#ifdef _DEBUG + m_bREFRACTTINTTEXTURE = true; +#endif + } + void SetREFRACTTINTTEXTURE( bool i ) + { + m_nREFRACTTINTTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bREFRACTTINTTEXTURE = true; +#endif + } +private: + int m_nMASKED; +#ifdef _DEBUG + bool m_bMASKED; +#endif +public: + void SetMASKED( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMASKED = i; +#ifdef _DEBUG + m_bMASKED = true; +#endif + } + void SetMASKED( bool i ) + { + m_nMASKED = i ? 1 : 0; +#ifdef _DEBUG + m_bMASKED = true; +#endif + } +private: + int m_nCOLORMODULATE; +#ifdef _DEBUG + bool m_bCOLORMODULATE; +#endif +public: + void SetCOLORMODULATE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOLORMODULATE = i; +#ifdef _DEBUG + m_bCOLORMODULATE = true; +#endif + } + void SetCOLORMODULATE( bool i ) + { + m_nCOLORMODULATE = i ? 1 : 0; +#ifdef _DEBUG + m_bCOLORMODULATE = true; +#endif + } +private: + int m_nSECONDARY_NORMAL; +#ifdef _DEBUG + bool m_bSECONDARY_NORMAL; +#endif +public: + void SetSECONDARY_NORMAL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSECONDARY_NORMAL = i; +#ifdef _DEBUG + m_bSECONDARY_NORMAL = true; +#endif + } + void SetSECONDARY_NORMAL( bool i ) + { + m_nSECONDARY_NORMAL = i ? 1 : 0; +#ifdef _DEBUG + m_bSECONDARY_NORMAL = true; +#endif + } +private: + int m_nNORMAL_DECODE_MODE; +#ifdef _DEBUG + bool m_bNORMAL_DECODE_MODE; +#endif +public: + void SetNORMAL_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMAL_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } + void SetNORMAL_DECODE_MODE( bool i ) + { + m_nNORMAL_DECODE_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } +public: + sdk_refract_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bBLUR = false; +#endif // _DEBUG + m_nBLUR = 0; +#ifdef _DEBUG + m_bFADEOUTONSILHOUETTE = false; +#endif // _DEBUG + m_nFADEOUTONSILHOUETTE = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bREFRACTTINTTEXTURE = false; +#endif // _DEBUG + m_nREFRACTTINTTEXTURE = 0; +#ifdef _DEBUG + m_bMASKED = false; +#endif // _DEBUG + m_nMASKED = 0; +#ifdef _DEBUG + m_bCOLORMODULATE = false; +#endif // _DEBUG + m_nCOLORMODULATE = 0; +#ifdef _DEBUG + m_bSECONDARY_NORMAL = false; +#endif // _DEBUG + m_nSECONDARY_NORMAL = 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = false; +#endif // _DEBUG + m_nNORMAL_DECODE_MODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bBLUR && m_bFADEOUTONSILHOUETTE && m_bCUBEMAP && m_bREFRACTTINTTEXTURE && m_bMASKED && m_bCOLORMODULATE && m_bSECONDARY_NORMAL && m_bNORMAL_DECODE_MODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nBLUR ) + ( 4 * m_nFADEOUTONSILHOUETTE ) + ( 8 * m_nCUBEMAP ) + ( 16 * m_nREFRACTTINTTEXTURE ) + ( 32 * m_nMASKED ) + ( 64 * m_nCOLORMODULATE ) + ( 128 * m_nSECONDARY_NORMAL ) + ( 256 * m_nNORMAL_DECODE_MODE ) + 0; + } +}; +#define shaderStaticTest_sdk_refract_ps20 psh_forgot_to_set_static_BLUR + psh_forgot_to_set_static_FADEOUTONSILHOUETTE + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_REFRACTTINTTEXTURE + psh_forgot_to_set_static_MASKED + psh_forgot_to_set_static_COLORMODULATE + psh_forgot_to_set_static_SECONDARY_NORMAL + psh_forgot_to_set_static_NORMAL_DECODE_MODE + 0 +class sdk_refract_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_refract_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_refract_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_refract_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_refract_ps20b.inc new file mode 100644 index 00000000..3d877ae0 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_refract_ps20b.inc @@ -0,0 +1,337 @@ +#include "shaderlib/cshader.h" +class sdk_refract_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nBLUR; +#ifdef _DEBUG + bool m_bBLUR; +#endif +public: + void SetBLUR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLUR = i; +#ifdef _DEBUG + m_bBLUR = true; +#endif + } + void SetBLUR( bool i ) + { + m_nBLUR = i ? 1 : 0; +#ifdef _DEBUG + m_bBLUR = true; +#endif + } +private: + int m_nFADEOUTONSILHOUETTE; +#ifdef _DEBUG + bool m_bFADEOUTONSILHOUETTE; +#endif +public: + void SetFADEOUTONSILHOUETTE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFADEOUTONSILHOUETTE = i; +#ifdef _DEBUG + m_bFADEOUTONSILHOUETTE = true; +#endif + } + void SetFADEOUTONSILHOUETTE( bool i ) + { + m_nFADEOUTONSILHOUETTE = i ? 1 : 0; +#ifdef _DEBUG + m_bFADEOUTONSILHOUETTE = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nREFRACTTINTTEXTURE; +#ifdef _DEBUG + bool m_bREFRACTTINTTEXTURE; +#endif +public: + void SetREFRACTTINTTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFRACTTINTTEXTURE = i; +#ifdef _DEBUG + m_bREFRACTTINTTEXTURE = true; +#endif + } + void SetREFRACTTINTTEXTURE( bool i ) + { + m_nREFRACTTINTTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bREFRACTTINTTEXTURE = true; +#endif + } +private: + int m_nMASKED; +#ifdef _DEBUG + bool m_bMASKED; +#endif +public: + void SetMASKED( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMASKED = i; +#ifdef _DEBUG + m_bMASKED = true; +#endif + } + void SetMASKED( bool i ) + { + m_nMASKED = i ? 1 : 0; +#ifdef _DEBUG + m_bMASKED = true; +#endif + } +private: + int m_nCOLORMODULATE; +#ifdef _DEBUG + bool m_bCOLORMODULATE; +#endif +public: + void SetCOLORMODULATE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOLORMODULATE = i; +#ifdef _DEBUG + m_bCOLORMODULATE = true; +#endif + } + void SetCOLORMODULATE( bool i ) + { + m_nCOLORMODULATE = i ? 1 : 0; +#ifdef _DEBUG + m_bCOLORMODULATE = true; +#endif + } +private: + int m_nSECONDARY_NORMAL; +#ifdef _DEBUG + bool m_bSECONDARY_NORMAL; +#endif +public: + void SetSECONDARY_NORMAL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSECONDARY_NORMAL = i; +#ifdef _DEBUG + m_bSECONDARY_NORMAL = true; +#endif + } + void SetSECONDARY_NORMAL( bool i ) + { + m_nSECONDARY_NORMAL = i ? 1 : 0; +#ifdef _DEBUG + m_bSECONDARY_NORMAL = true; +#endif + } +private: + int m_nNORMAL_DECODE_MODE; +#ifdef _DEBUG + bool m_bNORMAL_DECODE_MODE; +#endif +public: + void SetNORMAL_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMAL_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } + void SetNORMAL_DECODE_MODE( bool i ) + { + m_nNORMAL_DECODE_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } +private: + int m_nSHADER_SRGB_READ; +#ifdef _DEBUG + bool m_bSHADER_SRGB_READ; +#endif +public: + void SetSHADER_SRGB_READ( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSHADER_SRGB_READ = i; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = true; +#endif + } + void SetSHADER_SRGB_READ( bool i ) + { + m_nSHADER_SRGB_READ = i ? 1 : 0; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = true; +#endif + } +public: + sdk_refract_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bBLUR = false; +#endif // _DEBUG + m_nBLUR = 0; +#ifdef _DEBUG + m_bFADEOUTONSILHOUETTE = false; +#endif // _DEBUG + m_nFADEOUTONSILHOUETTE = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bREFRACTTINTTEXTURE = false; +#endif // _DEBUG + m_nREFRACTTINTTEXTURE = 0; +#ifdef _DEBUG + m_bMASKED = false; +#endif // _DEBUG + m_nMASKED = 0; +#ifdef _DEBUG + m_bCOLORMODULATE = false; +#endif // _DEBUG + m_nCOLORMODULATE = 0; +#ifdef _DEBUG + m_bSECONDARY_NORMAL = false; +#endif // _DEBUG + m_nSECONDARY_NORMAL = 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = false; +#endif // _DEBUG + m_nNORMAL_DECODE_MODE = 0; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = false; +#endif // _DEBUG + m_nSHADER_SRGB_READ = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bBLUR && m_bFADEOUTONSILHOUETTE && m_bCUBEMAP && m_bREFRACTTINTTEXTURE && m_bMASKED && m_bCOLORMODULATE && m_bSECONDARY_NORMAL && m_bNORMAL_DECODE_MODE && m_bSHADER_SRGB_READ; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nCONVERT_TO_SRGB ) + ( 8 * m_nBLUR ) + ( 16 * m_nFADEOUTONSILHOUETTE ) + ( 32 * m_nCUBEMAP ) + ( 64 * m_nREFRACTTINTTEXTURE ) + ( 128 * m_nMASKED ) + ( 256 * m_nCOLORMODULATE ) + ( 512 * m_nSECONDARY_NORMAL ) + ( 1024 * m_nNORMAL_DECODE_MODE ) + ( 1024 * m_nSHADER_SRGB_READ ) + 0; + } +}; +#define shaderStaticTest_sdk_refract_ps20b psh_forgot_to_set_static_BLUR + psh_forgot_to_set_static_FADEOUTONSILHOUETTE + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_REFRACTTINTTEXTURE + psh_forgot_to_set_static_MASKED + psh_forgot_to_set_static_COLORMODULATE + psh_forgot_to_set_static_SECONDARY_NORMAL + psh_forgot_to_set_static_NORMAL_DECODE_MODE + psh_forgot_to_set_static_SHADER_SRGB_READ + 0 +class sdk_refract_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +public: + sdk_refract_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bWRITE_DEPTH_TO_DESTALPHA; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + } +}; +#define shaderDynamicTest_sdk_refract_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_skin_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_skin_ps20b.inc new file mode 100644 index 00000000..6c1e5fea --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_skin_ps20b.inc @@ -0,0 +1,537 @@ +#include "shaderlib/cshader.h" +class sdk_skin_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nSELFILLUMFRESNEL; +#ifdef _DEBUG + bool m_bSELFILLUMFRESNEL; +#endif +public: + void SetSELFILLUMFRESNEL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUMFRESNEL = i; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = true; +#endif + } + void SetSELFILLUMFRESNEL( bool i ) + { + m_nSELFILLUMFRESNEL = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nLIGHTWARPTEXTURE; +#ifdef _DEBUG + bool m_bLIGHTWARPTEXTURE; +#endif +public: + void SetLIGHTWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTWARPTEXTURE = i; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } + void SetLIGHTWARPTEXTURE( bool i ) + { + m_nLIGHTWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } +private: + int m_nPHONGWARPTEXTURE; +#ifdef _DEBUG + bool m_bPHONGWARPTEXTURE; +#endif +public: + void SetPHONGWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONGWARPTEXTURE = i; +#ifdef _DEBUG + m_bPHONGWARPTEXTURE = true; +#endif + } + void SetPHONGWARPTEXTURE( bool i ) + { + m_nPHONGWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bPHONGWARPTEXTURE = true; +#endif + } +private: + int m_nWRINKLEMAP; +#ifdef _DEBUG + bool m_bWRINKLEMAP; +#endif +public: + void SetWRINKLEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRINKLEMAP = i; +#ifdef _DEBUG + m_bWRINKLEMAP = true; +#endif + } + void SetWRINKLEMAP( bool i ) + { + m_nWRINKLEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bWRINKLEMAP = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 6 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nRIMLIGHT; +#ifdef _DEBUG + bool m_bRIMLIGHT; +#endif +public: + void SetRIMLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nRIMLIGHT = i; +#ifdef _DEBUG + m_bRIMLIGHT = true; +#endif + } + void SetRIMLIGHT( bool i ) + { + m_nRIMLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bRIMLIGHT = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +private: + int m_nFASTPATH_NOBUMP; +#ifdef _DEBUG + bool m_bFASTPATH_NOBUMP; +#endif +public: + void SetFASTPATH_NOBUMP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFASTPATH_NOBUMP = i; +#ifdef _DEBUG + m_bFASTPATH_NOBUMP = true; +#endif + } + void SetFASTPATH_NOBUMP( bool i ) + { + m_nFASTPATH_NOBUMP = i ? 1 : 0; +#ifdef _DEBUG + m_bFASTPATH_NOBUMP = true; +#endif + } +private: + int m_nBLENDTINTBYBASEALPHA; +#ifdef _DEBUG + bool m_bBLENDTINTBYBASEALPHA; +#endif +public: + void SetBLENDTINTBYBASEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLENDTINTBYBASEALPHA = i; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } + void SetBLENDTINTBYBASEALPHA( bool i ) + { + m_nBLENDTINTBYBASEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } +private: + int m_nPHONG_HALFLAMBERT; +#ifdef _DEBUG + bool m_bPHONG_HALFLAMBERT; +#endif +public: + void SetPHONG_HALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONG_HALFLAMBERT = i; +#ifdef _DEBUG + m_bPHONG_HALFLAMBERT = true; +#endif + } + void SetPHONG_HALFLAMBERT( bool i ) + { + m_nPHONG_HALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bPHONG_HALFLAMBERT = true; +#endif + } +public: + sdk_skin_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = false; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = false; +#endif // _DEBUG + m_nSELFILLUMFRESNEL = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = false; +#endif // _DEBUG + m_nLIGHTWARPTEXTURE = 0; +#ifdef _DEBUG + m_bPHONGWARPTEXTURE = false; +#endif // _DEBUG + m_nPHONGWARPTEXTURE = 0; +#ifdef _DEBUG + m_bWRINKLEMAP = false; +#endif // _DEBUG + m_nWRINKLEMAP = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bRIMLIGHT = false; +#endif // _DEBUG + m_nRIMLIGHT = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; +#ifdef _DEBUG + m_bFASTPATH_NOBUMP = false; +#endif // _DEBUG + m_nFASTPATH_NOBUMP = 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = false; +#endif // _DEBUG + m_nBLENDTINTBYBASEALPHA = 0; +#ifdef _DEBUG + m_bPHONG_HALFLAMBERT = false; +#endif // _DEBUG + m_nPHONG_HALFLAMBERT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bCUBEMAP && m_bSELFILLUM && m_bSELFILLUMFRESNEL && m_bFLASHLIGHT && m_bLIGHTWARPTEXTURE && m_bPHONGWARPTEXTURE && m_bWRINKLEMAP && m_bDETAIL_BLEND_MODE && m_bDETAILTEXTURE && m_bRIMLIGHT && m_bFLASHLIGHTDEPTHFILTERMODE && m_bFASTPATH_NOBUMP && m_bBLENDTINTBYBASEALPHA && m_bPHONG_HALFLAMBERT; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 80 * m_nCONVERT_TO_SRGB ) + ( 80 * m_nCUBEMAP ) + ( 160 * m_nSELFILLUM ) + ( 320 * m_nSELFILLUMFRESNEL ) + ( 640 * m_nFLASHLIGHT ) + ( 1280 * m_nLIGHTWARPTEXTURE ) + ( 2560 * m_nPHONGWARPTEXTURE ) + ( 5120 * m_nWRINKLEMAP ) + ( 10240 * m_nDETAIL_BLEND_MODE ) + ( 71680 * m_nDETAILTEXTURE ) + ( 143360 * m_nRIMLIGHT ) + ( 286720 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 860160 * m_nFASTPATH_NOBUMP ) + ( 1720320 * m_nBLENDTINTBYBASEALPHA ) + ( 3440640 * m_nPHONG_HALFLAMBERT ) + 0; + } +}; +#define shaderStaticTest_sdk_skin_ps20b psh_forgot_to_set_static_CONVERT_TO_SRGB + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_SELFILLUMFRESNEL + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_PHONGWARPTEXTURE + psh_forgot_to_set_static_WRINKLEMAP + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_RIMLIGHT + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_FASTPATH_NOBUMP + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + psh_forgot_to_set_static_PHONG_HALFLAMBERT + 0 +class sdk_skin_ps20b_Dynamic_Index +{ +private: + int m_nWRITEWATERFOGTODESTALPHA; +#ifdef _DEBUG + bool m_bWRITEWATERFOGTODESTALPHA; +#endif +public: + void SetWRITEWATERFOGTODESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITEWATERFOGTODESTALPHA = i; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } + void SetWRITEWATERFOGTODESTALPHA( bool i ) + { + m_nWRITEWATERFOGTODESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_skin_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = false; +#endif // _DEBUG + m_nWRITEWATERFOGTODESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bWRITEWATERFOGTODESTALPHA && m_bPIXELFOGTYPE && m_bNUM_LIGHTS && m_bWRITE_DEPTH_TO_DESTALPHA && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nWRITEWATERFOGTODESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + ( 4 * m_nNUM_LIGHTS ) + ( 20 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 40 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_skin_ps20b psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_skin_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_skin_ps30.inc new file mode 100644 index 00000000..2405f0b6 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_skin_ps30.inc @@ -0,0 +1,537 @@ +#include "shaderlib/cshader.h" +class sdk_skin_ps30_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nSELFILLUMFRESNEL; +#ifdef _DEBUG + bool m_bSELFILLUMFRESNEL; +#endif +public: + void SetSELFILLUMFRESNEL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUMFRESNEL = i; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = true; +#endif + } + void SetSELFILLUMFRESNEL( bool i ) + { + m_nSELFILLUMFRESNEL = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nLIGHTWARPTEXTURE; +#ifdef _DEBUG + bool m_bLIGHTWARPTEXTURE; +#endif +public: + void SetLIGHTWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTWARPTEXTURE = i; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } + void SetLIGHTWARPTEXTURE( bool i ) + { + m_nLIGHTWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } +private: + int m_nPHONGWARPTEXTURE; +#ifdef _DEBUG + bool m_bPHONGWARPTEXTURE; +#endif +public: + void SetPHONGWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONGWARPTEXTURE = i; +#ifdef _DEBUG + m_bPHONGWARPTEXTURE = true; +#endif + } + void SetPHONGWARPTEXTURE( bool i ) + { + m_nPHONGWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bPHONGWARPTEXTURE = true; +#endif + } +private: + int m_nWRINKLEMAP; +#ifdef _DEBUG + bool m_bWRINKLEMAP; +#endif +public: + void SetWRINKLEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRINKLEMAP = i; +#ifdef _DEBUG + m_bWRINKLEMAP = true; +#endif + } + void SetWRINKLEMAP( bool i ) + { + m_nWRINKLEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bWRINKLEMAP = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 6 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nRIMLIGHT; +#ifdef _DEBUG + bool m_bRIMLIGHT; +#endif +public: + void SetRIMLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nRIMLIGHT = i; +#ifdef _DEBUG + m_bRIMLIGHT = true; +#endif + } + void SetRIMLIGHT( bool i ) + { + m_nRIMLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bRIMLIGHT = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +private: + int m_nFASTPATH_NOBUMP; +#ifdef _DEBUG + bool m_bFASTPATH_NOBUMP; +#endif +public: + void SetFASTPATH_NOBUMP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFASTPATH_NOBUMP = i; +#ifdef _DEBUG + m_bFASTPATH_NOBUMP = true; +#endif + } + void SetFASTPATH_NOBUMP( bool i ) + { + m_nFASTPATH_NOBUMP = i ? 1 : 0; +#ifdef _DEBUG + m_bFASTPATH_NOBUMP = true; +#endif + } +private: + int m_nBLENDTINTBYBASEALPHA; +#ifdef _DEBUG + bool m_bBLENDTINTBYBASEALPHA; +#endif +public: + void SetBLENDTINTBYBASEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLENDTINTBYBASEALPHA = i; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } + void SetBLENDTINTBYBASEALPHA( bool i ) + { + m_nBLENDTINTBYBASEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } +private: + int m_nPHONG_HALFLAMBERT; +#ifdef _DEBUG + bool m_bPHONG_HALFLAMBERT; +#endif +public: + void SetPHONG_HALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONG_HALFLAMBERT = i; +#ifdef _DEBUG + m_bPHONG_HALFLAMBERT = true; +#endif + } + void SetPHONG_HALFLAMBERT( bool i ) + { + m_nPHONG_HALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bPHONG_HALFLAMBERT = true; +#endif + } +public: + sdk_skin_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = false; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = false; +#endif // _DEBUG + m_nSELFILLUMFRESNEL = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = false; +#endif // _DEBUG + m_nLIGHTWARPTEXTURE = 0; +#ifdef _DEBUG + m_bPHONGWARPTEXTURE = false; +#endif // _DEBUG + m_nPHONGWARPTEXTURE = 0; +#ifdef _DEBUG + m_bWRINKLEMAP = false; +#endif // _DEBUG + m_nWRINKLEMAP = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bRIMLIGHT = false; +#endif // _DEBUG + m_nRIMLIGHT = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; +#ifdef _DEBUG + m_bFASTPATH_NOBUMP = false; +#endif // _DEBUG + m_nFASTPATH_NOBUMP = 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = false; +#endif // _DEBUG + m_nBLENDTINTBYBASEALPHA = 0; +#ifdef _DEBUG + m_bPHONG_HALFLAMBERT = false; +#endif // _DEBUG + m_nPHONG_HALFLAMBERT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bCUBEMAP && m_bSELFILLUM && m_bSELFILLUMFRESNEL && m_bFLASHLIGHT && m_bLIGHTWARPTEXTURE && m_bPHONGWARPTEXTURE && m_bWRINKLEMAP && m_bDETAIL_BLEND_MODE && m_bDETAILTEXTURE && m_bRIMLIGHT && m_bFLASHLIGHTDEPTHFILTERMODE && m_bFASTPATH_NOBUMP && m_bBLENDTINTBYBASEALPHA && m_bPHONG_HALFLAMBERT; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 80 * m_nCONVERT_TO_SRGB ) + ( 80 * m_nCUBEMAP ) + ( 160 * m_nSELFILLUM ) + ( 320 * m_nSELFILLUMFRESNEL ) + ( 640 * m_nFLASHLIGHT ) + ( 1280 * m_nLIGHTWARPTEXTURE ) + ( 2560 * m_nPHONGWARPTEXTURE ) + ( 5120 * m_nWRINKLEMAP ) + ( 10240 * m_nDETAIL_BLEND_MODE ) + ( 71680 * m_nDETAILTEXTURE ) + ( 143360 * m_nRIMLIGHT ) + ( 286720 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 860160 * m_nFASTPATH_NOBUMP ) + ( 1720320 * m_nBLENDTINTBYBASEALPHA ) + ( 3440640 * m_nPHONG_HALFLAMBERT ) + 0; + } +}; +#define shaderStaticTest_sdk_skin_ps30 psh_forgot_to_set_static_CONVERT_TO_SRGB + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_SELFILLUMFRESNEL + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_PHONGWARPTEXTURE + psh_forgot_to_set_static_WRINKLEMAP + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_RIMLIGHT + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_FASTPATH_NOBUMP + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + psh_forgot_to_set_static_PHONG_HALFLAMBERT + 0 +class sdk_skin_ps30_Dynamic_Index +{ +private: + int m_nWRITEWATERFOGTODESTALPHA; +#ifdef _DEBUG + bool m_bWRITEWATERFOGTODESTALPHA; +#endif +public: + void SetWRITEWATERFOGTODESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITEWATERFOGTODESTALPHA = i; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } + void SetWRITEWATERFOGTODESTALPHA( bool i ) + { + m_nWRITEWATERFOGTODESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_skin_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = false; +#endif // _DEBUG + m_nWRITEWATERFOGTODESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bWRITEWATERFOGTODESTALPHA && m_bPIXELFOGTYPE && m_bNUM_LIGHTS && m_bWRITE_DEPTH_TO_DESTALPHA && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nWRITEWATERFOGTODESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + ( 4 * m_nNUM_LIGHTS ) + ( 20 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 40 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_skin_ps30 psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_skin_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_skin_vs20.inc new file mode 100644 index 00000000..22a29bf7 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_skin_vs20.inc @@ -0,0 +1,187 @@ +#include "shaderlib/cshader.h" +class sdk_skin_vs20_Static_Index +{ +private: + int m_nUSE_STATIC_CONTROL_FLOW; +#ifdef _DEBUG + bool m_bUSE_STATIC_CONTROL_FLOW; +#endif +public: + void SetUSE_STATIC_CONTROL_FLOW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nUSE_STATIC_CONTROL_FLOW = i; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } + void SetUSE_STATIC_CONTROL_FLOW( bool i ) + { + m_nUSE_STATIC_CONTROL_FLOW = i ? 1 : 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } +public: + sdk_skin_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = false; +#endif // _DEBUG + m_nUSE_STATIC_CONTROL_FLOW = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bUSE_STATIC_CONTROL_FLOW; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 48 * m_nUSE_STATIC_CONTROL_FLOW ) + 0; + } +}; +#define shaderStaticTest_sdk_skin_vs20 vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + 0 +class sdk_skin_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_skin_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bLIGHTING_PREVIEW && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nLIGHTING_PREVIEW ) + ( 16 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_skin_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_LIGHTING_PREVIEW + vsh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_skin_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_skin_vs30.inc new file mode 100644 index 00000000..fb6a1125 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_skin_vs30.inc @@ -0,0 +1,187 @@ +#include "shaderlib/cshader.h" +class sdk_skin_vs30_Static_Index +{ +private: + int m_nDECAL; +#ifdef _DEBUG + bool m_bDECAL; +#endif +public: + void SetDECAL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDECAL = i; +#ifdef _DEBUG + m_bDECAL = true; +#endif + } + void SetDECAL( bool i ) + { + m_nDECAL = i ? 1 : 0; +#ifdef _DEBUG + m_bDECAL = true; +#endif + } +public: + sdk_skin_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bDECAL = false; +#endif // _DEBUG + m_nDECAL = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bDECAL; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 32 * m_nDECAL ) + 0; + } +}; +#define shaderStaticTest_sdk_skin_vs30 vsh_forgot_to_set_static_DECAL + 0 +class sdk_skin_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_skin_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bLIGHTING_PREVIEW && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nLIGHTING_PREVIEW ) + ( 16 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_skin_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_LIGHTING_PREVIEW + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_splinerope_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_splinerope_ps20.inc new file mode 100644 index 00000000..f43cdb2f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_splinerope_ps20.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_splinerope_ps20_Static_Index +{ +private: + int m_nSHADER_SRGB_READ; +#ifdef _DEBUG + bool m_bSHADER_SRGB_READ; +#endif +public: + void SetSHADER_SRGB_READ( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nSHADER_SRGB_READ = i; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = true; +#endif + } + void SetSHADER_SRGB_READ( bool i ) + { + m_nSHADER_SRGB_READ = i ? 1 : 0; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = true; +#endif + } +private: + int m_nSHADOWDEPTH; +#ifdef _DEBUG + bool m_bSHADOWDEPTH; +#endif +public: + void SetSHADOWDEPTH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSHADOWDEPTH = i; +#ifdef _DEBUG + m_bSHADOWDEPTH = true; +#endif + } + void SetSHADOWDEPTH( bool i ) + { + m_nSHADOWDEPTH = i ? 1 : 0; +#ifdef _DEBUG + m_bSHADOWDEPTH = true; +#endif + } +public: + sdk_splinerope_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bSHADER_SRGB_READ = false; +#endif // _DEBUG + m_nSHADER_SRGB_READ = 0; +#ifdef _DEBUG + m_bSHADOWDEPTH = false; +#endif // _DEBUG + m_nSHADOWDEPTH = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bSHADER_SRGB_READ && m_bSHADOWDEPTH; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nSHADER_SRGB_READ ) + ( 2 * m_nSHADOWDEPTH ) + 0; + } +}; +#define shaderStaticTest_sdk_splinerope_ps20 psh_forgot_to_set_static_SHADER_SRGB_READ + psh_forgot_to_set_static_SHADOWDEPTH + 0 +class sdk_splinerope_ps20_Dynamic_Index +{ +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_splinerope_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bWRITE_DEPTH_TO_DESTALPHA && m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_splinerope_ps20 psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_splinerope_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_splinerope_ps20b.inc new file mode 100644 index 00000000..75ce64e9 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_splinerope_ps20b.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_splinerope_ps20b_Static_Index +{ +private: + int m_nSHADER_SRGB_READ; +#ifdef _DEBUG + bool m_bSHADER_SRGB_READ; +#endif +public: + void SetSHADER_SRGB_READ( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nSHADER_SRGB_READ = i; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = true; +#endif + } + void SetSHADER_SRGB_READ( bool i ) + { + m_nSHADER_SRGB_READ = i ? 1 : 0; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = true; +#endif + } +private: + int m_nSHADOWDEPTH; +#ifdef _DEBUG + bool m_bSHADOWDEPTH; +#endif +public: + void SetSHADOWDEPTH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSHADOWDEPTH = i; +#ifdef _DEBUG + m_bSHADOWDEPTH = true; +#endif + } + void SetSHADOWDEPTH( bool i ) + { + m_nSHADOWDEPTH = i ? 1 : 0; +#ifdef _DEBUG + m_bSHADOWDEPTH = true; +#endif + } +public: + sdk_splinerope_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bSHADER_SRGB_READ = false; +#endif // _DEBUG + m_nSHADER_SRGB_READ = 0; +#ifdef _DEBUG + m_bSHADOWDEPTH = false; +#endif // _DEBUG + m_nSHADOWDEPTH = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bSHADER_SRGB_READ && m_bSHADOWDEPTH; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nSHADER_SRGB_READ ) + ( 4 * m_nSHADOWDEPTH ) + 0; + } +}; +#define shaderStaticTest_sdk_splinerope_ps20b psh_forgot_to_set_static_SHADER_SRGB_READ + psh_forgot_to_set_static_SHADOWDEPTH + 0 +class sdk_splinerope_ps20b_Dynamic_Index +{ +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_splinerope_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bWRITE_DEPTH_TO_DESTALPHA && m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_splinerope_ps20b psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_splinerope_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_splinerope_ps30.inc new file mode 100644 index 00000000..6427d06f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_splinerope_ps30.inc @@ -0,0 +1,112 @@ +#include "shaderlib/cshader.h" +class sdk_splinerope_ps30_Static_Index +{ +private: + int m_nSHADER_SRGB_READ; +#ifdef _DEBUG + bool m_bSHADER_SRGB_READ; +#endif +public: + void SetSHADER_SRGB_READ( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nSHADER_SRGB_READ = i; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = true; +#endif + } + void SetSHADER_SRGB_READ( bool i ) + { + m_nSHADER_SRGB_READ = i ? 1 : 0; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = true; +#endif + } +private: + int m_nSHADOWDEPTH; +#ifdef _DEBUG + bool m_bSHADOWDEPTH; +#endif +public: + void SetSHADOWDEPTH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSHADOWDEPTH = i; +#ifdef _DEBUG + m_bSHADOWDEPTH = true; +#endif + } + void SetSHADOWDEPTH( bool i ) + { + m_nSHADOWDEPTH = i ? 1 : 0; +#ifdef _DEBUG + m_bSHADOWDEPTH = true; +#endif + } +public: + sdk_splinerope_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bSHADER_SRGB_READ = false; +#endif // _DEBUG + m_nSHADER_SRGB_READ = 0; +#ifdef _DEBUG + m_bSHADOWDEPTH = false; +#endif // _DEBUG + m_nSHADOWDEPTH = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bSHADER_SRGB_READ && m_bSHADOWDEPTH; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nSHADER_SRGB_READ ) + ( 2 * m_nSHADOWDEPTH ) + 0; + } +}; +#define shaderStaticTest_sdk_splinerope_ps30 psh_forgot_to_set_static_SHADER_SRGB_READ + psh_forgot_to_set_static_SHADOWDEPTH + 0 +class sdk_splinerope_ps30_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_splinerope_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_splinerope_ps30 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_splinerope_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_splinerope_vs20.inc new file mode 100644 index 00000000..ba584299 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_splinerope_vs20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_splinerope_vs20_Static_Index +{ +public: + sdk_splinerope_vs20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_splinerope_vs20 0 +class sdk_splinerope_vs20_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_splinerope_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_splinerope_vs20 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_splinerope_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_splinerope_vs30.inc new file mode 100644 index 00000000..97c31b1b --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_splinerope_vs30.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_splinerope_vs30_Static_Index +{ +public: + sdk_splinerope_vs30_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_splinerope_vs30 0 +class sdk_splinerope_vs30_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_splinerope_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_splinerope_vs30 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_sprite_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_sprite_ps20.inc new file mode 100644 index 00000000..ac161fb8 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_sprite_ps20.inc @@ -0,0 +1,187 @@ +#include "shaderlib/cshader.h" +class sdk_sprite_ps20_Static_Index +{ +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nCONSTANTCOLOR; +#ifdef _DEBUG + bool m_bCONSTANTCOLOR; +#endif +public: + void SetCONSTANTCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONSTANTCOLOR = i; +#ifdef _DEBUG + m_bCONSTANTCOLOR = true; +#endif + } + void SetCONSTANTCOLOR( bool i ) + { + m_nCONSTANTCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bCONSTANTCOLOR = true; +#endif + } +private: + int m_nHDRTYPE; +#ifdef _DEBUG + bool m_bHDRTYPE; +#endif +public: + void SetHDRTYPE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nHDRTYPE = i; +#ifdef _DEBUG + m_bHDRTYPE = true; +#endif + } + void SetHDRTYPE( bool i ) + { + m_nHDRTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bHDRTYPE = true; +#endif + } +private: + int m_nSRGB; +#ifdef _DEBUG + bool m_bSRGB; +#endif +public: + void SetSRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSRGB = i; +#ifdef _DEBUG + m_bSRGB = true; +#endif + } + void SetSRGB( bool i ) + { + m_nSRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bSRGB = true; +#endif + } +public: + sdk_sprite_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bCONSTANTCOLOR = false; +#endif // _DEBUG + m_nCONSTANTCOLOR = 0; +#ifdef _DEBUG + m_bHDRTYPE = false; +#endif // _DEBUG + m_nHDRTYPE = 0; +#ifdef _DEBUG + m_bSRGB = false; +#endif // _DEBUG + m_nSRGB = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bVERTEXCOLOR && m_bCONSTANTCOLOR && m_bHDRTYPE && m_bSRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nVERTEXCOLOR ) + ( 8 * m_nCONSTANTCOLOR ) + ( 16 * m_nHDRTYPE ) + ( 48 * m_nSRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_sprite_ps20 psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_CONSTANTCOLOR + psh_forgot_to_set_static_HDRTYPE + psh_forgot_to_set_static_SRGB + 0 +class sdk_sprite_ps20_Dynamic_Index +{ +private: + int m_nHDRENABLED; +#ifdef _DEBUG + bool m_bHDRENABLED; +#endif +public: + void SetHDRENABLED( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHDRENABLED = i; +#ifdef _DEBUG + m_bHDRENABLED = true; +#endif + } + void SetHDRENABLED( bool i ) + { + m_nHDRENABLED = i ? 1 : 0; +#ifdef _DEBUG + m_bHDRENABLED = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_sprite_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bHDRENABLED = false; +#endif // _DEBUG + m_nHDRENABLED = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bHDRENABLED && m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nHDRENABLED ) + ( 2 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_sprite_ps20 psh_forgot_to_set_dynamic_HDRENABLED + psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_sprite_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_sprite_ps20b.inc new file mode 100644 index 00000000..35d69c88 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_sprite_ps20b.inc @@ -0,0 +1,237 @@ +#include "shaderlib/cshader.h" +class sdk_sprite_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nCONSTANTCOLOR; +#ifdef _DEBUG + bool m_bCONSTANTCOLOR; +#endif +public: + void SetCONSTANTCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONSTANTCOLOR = i; +#ifdef _DEBUG + m_bCONSTANTCOLOR = true; +#endif + } + void SetCONSTANTCOLOR( bool i ) + { + m_nCONSTANTCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bCONSTANTCOLOR = true; +#endif + } +private: + int m_nHDRTYPE; +#ifdef _DEBUG + bool m_bHDRTYPE; +#endif +public: + void SetHDRTYPE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nHDRTYPE = i; +#ifdef _DEBUG + m_bHDRTYPE = true; +#endif + } + void SetHDRTYPE( bool i ) + { + m_nHDRTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bHDRTYPE = true; +#endif + } +private: + int m_nSRGB; +#ifdef _DEBUG + bool m_bSRGB; +#endif +public: + void SetSRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSRGB = i; +#ifdef _DEBUG + m_bSRGB = true; +#endif + } + void SetSRGB( bool i ) + { + m_nSRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bSRGB = true; +#endif + } +private: + int m_nSRGB_OUTPUT_ADAPTER; +#ifdef _DEBUG + bool m_bSRGB_OUTPUT_ADAPTER; +#endif +public: + void SetSRGB_OUTPUT_ADAPTER( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSRGB_OUTPUT_ADAPTER = i; +#ifdef _DEBUG + m_bSRGB_OUTPUT_ADAPTER = true; +#endif + } + void SetSRGB_OUTPUT_ADAPTER( bool i ) + { + m_nSRGB_OUTPUT_ADAPTER = i ? 1 : 0; +#ifdef _DEBUG + m_bSRGB_OUTPUT_ADAPTER = true; +#endif + } +public: + sdk_sprite_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bCONSTANTCOLOR = false; +#endif // _DEBUG + m_nCONSTANTCOLOR = 0; +#ifdef _DEBUG + m_bHDRTYPE = false; +#endif // _DEBUG + m_nHDRTYPE = 0; +#ifdef _DEBUG + m_bSRGB = false; +#endif // _DEBUG + m_nSRGB = 0; +#ifdef _DEBUG + m_bSRGB_OUTPUT_ADAPTER = false; +#endif // _DEBUG + m_nSRGB_OUTPUT_ADAPTER = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bVERTEXCOLOR && m_bCONSTANTCOLOR && m_bHDRTYPE && m_bSRGB && m_bSRGB_OUTPUT_ADAPTER; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nCONVERT_TO_SRGB ) + ( 8 * m_nVERTEXCOLOR ) + ( 16 * m_nCONSTANTCOLOR ) + ( 32 * m_nHDRTYPE ) + ( 96 * m_nSRGB ) + ( 192 * m_nSRGB_OUTPUT_ADAPTER ) + 0; + } +}; +#define shaderStaticTest_sdk_sprite_ps20b psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_CONSTANTCOLOR + psh_forgot_to_set_static_HDRTYPE + psh_forgot_to_set_static_SRGB + psh_forgot_to_set_static_SRGB_OUTPUT_ADAPTER + 0 +class sdk_sprite_ps20b_Dynamic_Index +{ +private: + int m_nHDRENABLED; +#ifdef _DEBUG + bool m_bHDRENABLED; +#endif +public: + void SetHDRENABLED( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHDRENABLED = i; +#ifdef _DEBUG + m_bHDRENABLED = true; +#endif + } + void SetHDRENABLED( bool i ) + { + m_nHDRENABLED = i ? 1 : 0; +#ifdef _DEBUG + m_bHDRENABLED = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_sprite_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bHDRENABLED = false; +#endif // _DEBUG + m_nHDRENABLED = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bHDRENABLED && m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nHDRENABLED ) + ( 2 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_sprite_ps20b psh_forgot_to_set_dynamic_HDRENABLED + psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_sprite_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_sprite_vs20.inc new file mode 100644 index 00000000..25ac196d --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_sprite_vs20.inc @@ -0,0 +1,112 @@ +#include "shaderlib/cshader.h" +class sdk_sprite_vs20_Static_Index +{ +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nSRGB; +#ifdef _DEBUG + bool m_bSRGB; +#endif +public: + void SetSRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSRGB = i; +#ifdef _DEBUG + m_bSRGB = true; +#endif + } + void SetSRGB( bool i ) + { + m_nSRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bSRGB = true; +#endif + } +public: + sdk_sprite_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bSRGB = false; +#endif // _DEBUG + m_nSRGB = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bVERTEXCOLOR && m_bSRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nVERTEXCOLOR ) + ( 4 * m_nSRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_sprite_vs20 vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_SRGB + 0 +class sdk_sprite_vs20_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_sprite_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_sprite_vs20 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_bump_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_bump_ps20.inc new file mode 100644 index 00000000..bd2b6155 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_bump_ps20.inc @@ -0,0 +1,110 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_bump_ps20_Static_Index +{ +public: + sdk_teeth_bump_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_teeth_bump_ps20 0 +class sdk_teeth_bump_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nAMBIENT_LIGHT; +#ifdef _DEBUG + bool m_bAMBIENT_LIGHT; +#endif +public: + void SetAMBIENT_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nAMBIENT_LIGHT = i; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } + void SetAMBIENT_LIGHT( bool i ) + { + m_nAMBIENT_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } +public: + sdk_teeth_bump_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = false; +#endif // _DEBUG + m_nAMBIENT_LIGHT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bNUM_LIGHTS && m_bAMBIENT_LIGHT; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nNUM_LIGHTS ) + ( 6 * m_nAMBIENT_LIGHT ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_bump_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_AMBIENT_LIGHT + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_bump_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_bump_ps20b.inc new file mode 100644 index 00000000..8d774cf4 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_bump_ps20b.inc @@ -0,0 +1,162 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_bump_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_teeth_bump_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 40 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_bump_ps20b 0 +class sdk_teeth_bump_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nAMBIENT_LIGHT; +#ifdef _DEBUG + bool m_bAMBIENT_LIGHT; +#endif +public: + void SetAMBIENT_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nAMBIENT_LIGHT = i; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } + void SetAMBIENT_LIGHT( bool i ) + { + m_nAMBIENT_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +public: + sdk_teeth_bump_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = false; +#endif // _DEBUG + m_nAMBIENT_LIGHT = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bNUM_LIGHTS && m_bAMBIENT_LIGHT && m_bWRITE_DEPTH_TO_DESTALPHA; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nNUM_LIGHTS ) + ( 10 * m_nAMBIENT_LIGHT ) + ( 20 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_bump_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_AMBIENT_LIGHT + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_bump_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_bump_ps30.inc new file mode 100644 index 00000000..b3ae4c8f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_bump_ps30.inc @@ -0,0 +1,162 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_bump_ps30_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_teeth_bump_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 40 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_bump_ps30 0 +class sdk_teeth_bump_ps30_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nAMBIENT_LIGHT; +#ifdef _DEBUG + bool m_bAMBIENT_LIGHT; +#endif +public: + void SetAMBIENT_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nAMBIENT_LIGHT = i; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } + void SetAMBIENT_LIGHT( bool i ) + { + m_nAMBIENT_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +public: + sdk_teeth_bump_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = false; +#endif // _DEBUG + m_nAMBIENT_LIGHT = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bNUM_LIGHTS && m_bAMBIENT_LIGHT && m_bWRITE_DEPTH_TO_DESTALPHA; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nNUM_LIGHTS ) + ( 10 * m_nAMBIENT_LIGHT ) + ( 20 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_bump_ps30 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_AMBIENT_LIGHT + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_bump_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_bump_vs20.inc new file mode 100644 index 00000000..95700dc2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_bump_vs20.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_bump_vs20_Static_Index +{ +private: + int m_nINTRO; +#ifdef _DEBUG + bool m_bINTRO; +#endif +public: + void SetINTRO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nINTRO = i; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } + void SetINTRO( bool i ) + { + m_nINTRO = i ? 1 : 0; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } +private: + int m_nUSE_STATIC_CONTROL_FLOW; +#ifdef _DEBUG + bool m_bUSE_STATIC_CONTROL_FLOW; +#endif +public: + void SetUSE_STATIC_CONTROL_FLOW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nUSE_STATIC_CONTROL_FLOW = i; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } + void SetUSE_STATIC_CONTROL_FLOW( bool i ) + { + m_nUSE_STATIC_CONTROL_FLOW = i ? 1 : 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } +public: + sdk_teeth_bump_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bINTRO = false; +#endif // _DEBUG + m_nINTRO = 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = false; +#endif // _DEBUG + m_nUSE_STATIC_CONTROL_FLOW = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bINTRO && m_bUSE_STATIC_CONTROL_FLOW; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 48 * m_nINTRO ) + ( 96 * m_nUSE_STATIC_CONTROL_FLOW ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_bump_vs20 vsh_forgot_to_set_static_INTRO + vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + 0 +class sdk_teeth_bump_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_teeth_bump_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bSTATIC_LIGHT && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nSTATIC_LIGHT ) + ( 16 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_bump_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_bump_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_bump_vs30.inc new file mode 100644 index 00000000..61d78dbe --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_bump_vs30.inc @@ -0,0 +1,187 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_bump_vs30_Static_Index +{ +private: + int m_nINTRO; +#ifdef _DEBUG + bool m_bINTRO; +#endif +public: + void SetINTRO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nINTRO = i; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } + void SetINTRO( bool i ) + { + m_nINTRO = i ? 1 : 0; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } +public: + sdk_teeth_bump_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bINTRO = false; +#endif // _DEBUG + m_nINTRO = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bINTRO; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 32 * m_nINTRO ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_bump_vs30 vsh_forgot_to_set_static_INTRO + 0 +class sdk_teeth_bump_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_teeth_bump_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bSTATIC_LIGHT && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nSTATIC_LIGHT ) + ( 16 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_bump_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_flashlight_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_flashlight_ps20.inc new file mode 100644 index 00000000..773cf54a --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_flashlight_ps20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_flashlight_ps20_Static_Index +{ +public: + sdk_teeth_flashlight_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_teeth_flashlight_ps20 0 +class sdk_teeth_flashlight_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_teeth_flashlight_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_flashlight_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_flashlight_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_flashlight_ps20b.inc new file mode 100644 index 00000000..209eb19f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_flashlight_ps20b.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_flashlight_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_teeth_flashlight_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nCONVERT_TO_SRGB ) + ( 8 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_flashlight_ps20b psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_teeth_flashlight_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_teeth_flashlight_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_flashlight_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_flashlight_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_flashlight_ps30.inc new file mode 100644 index 00000000..3e08d8f2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_flashlight_ps30.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_flashlight_ps30_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_teeth_flashlight_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nCONVERT_TO_SRGB ) + ( 8 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_flashlight_ps30 psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_teeth_flashlight_ps30_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_teeth_flashlight_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_flashlight_ps30 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_flashlight_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_flashlight_vs20.inc new file mode 100644 index 00000000..b3728827 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_flashlight_vs20.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_flashlight_vs20_Static_Index +{ +private: + int m_nINTRO; +#ifdef _DEBUG + bool m_bINTRO; +#endif +public: + void SetINTRO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nINTRO = i; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } + void SetINTRO( bool i ) + { + m_nINTRO = i ? 1 : 0; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } +public: + sdk_teeth_flashlight_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bINTRO = false; +#endif // _DEBUG + m_nINTRO = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bINTRO; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 8 * m_nINTRO ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_flashlight_vs20 vsh_forgot_to_set_static_INTRO + 0 +class sdk_teeth_flashlight_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_teeth_flashlight_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_flashlight_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_flashlight_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_flashlight_vs30.inc new file mode 100644 index 00000000..e69d95bf --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_flashlight_vs30.inc @@ -0,0 +1,162 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_flashlight_vs30_Static_Index +{ +private: + int m_nINTRO; +#ifdef _DEBUG + bool m_bINTRO; +#endif +public: + void SetINTRO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nINTRO = i; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } + void SetINTRO( bool i ) + { + m_nINTRO = i ? 1 : 0; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } +public: + sdk_teeth_flashlight_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bINTRO = false; +#endif // _DEBUG + m_nINTRO = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bINTRO; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 16 * m_nINTRO ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_flashlight_vs30 vsh_forgot_to_set_static_INTRO + 0 +class sdk_teeth_flashlight_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_teeth_flashlight_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_flashlight_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_ps20.inc new file mode 100644 index 00000000..b7eae9b2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_ps20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_ps20_Static_Index +{ +public: + sdk_teeth_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_teeth_ps20 0 +class sdk_teeth_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_teeth_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_ps20b.inc new file mode 100644 index 00000000..1fcf1c6b --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_ps20b.inc @@ -0,0 +1,112 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_teeth_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_ps20b 0 +class sdk_teeth_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +public: + sdk_teeth_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bWRITE_DEPTH_TO_DESTALPHA; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_ps30.inc new file mode 100644 index 00000000..d2cc52f3 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_ps30.inc @@ -0,0 +1,112 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_ps30_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_teeth_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_ps30 0 +class sdk_teeth_ps30_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +public: + sdk_teeth_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bWRITE_DEPTH_TO_DESTALPHA; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_ps30 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_vs20.inc new file mode 100644 index 00000000..18cc3990 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_vs20.inc @@ -0,0 +1,237 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_vs20_Static_Index +{ +private: + int m_nINTRO; +#ifdef _DEBUG + bool m_bINTRO; +#endif +public: + void SetINTRO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nINTRO = i; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } + void SetINTRO( bool i ) + { + m_nINTRO = i ? 1 : 0; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } +private: + int m_nUSE_STATIC_CONTROL_FLOW; +#ifdef _DEBUG + bool m_bUSE_STATIC_CONTROL_FLOW; +#endif +public: + void SetUSE_STATIC_CONTROL_FLOW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nUSE_STATIC_CONTROL_FLOW = i; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } + void SetUSE_STATIC_CONTROL_FLOW( bool i ) + { + m_nUSE_STATIC_CONTROL_FLOW = i ? 1 : 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } +public: + sdk_teeth_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bINTRO = false; +#endif // _DEBUG + m_nINTRO = 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = false; +#endif // _DEBUG + m_nUSE_STATIC_CONTROL_FLOW = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bINTRO && m_bUSE_STATIC_CONTROL_FLOW; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 96 * m_nINTRO ) + ( 192 * m_nUSE_STATIC_CONTROL_FLOW ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_vs20 vsh_forgot_to_set_static_INTRO + vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + 0 +class sdk_teeth_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nDYNAMIC_LIGHT; +#ifdef _DEBUG + bool m_bDYNAMIC_LIGHT; +#endif +public: + void SetDYNAMIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDYNAMIC_LIGHT = i; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } + void SetDYNAMIC_LIGHT( bool i ) + { + m_nDYNAMIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_teeth_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = false; +#endif // _DEBUG + m_nDYNAMIC_LIGHT = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bDYNAMIC_LIGHT && m_bSTATIC_LIGHT && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nDYNAMIC_LIGHT ) + ( 16 * m_nSTATIC_LIGHT ) + ( 32 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_DYNAMIC_LIGHT + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_vs30.inc new file mode 100644 index 00000000..985f57e8 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_teeth_vs30.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_vs30_Static_Index +{ +private: + int m_nINTRO; +#ifdef _DEBUG + bool m_bINTRO; +#endif +public: + void SetINTRO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nINTRO = i; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } + void SetINTRO( bool i ) + { + m_nINTRO = i ? 1 : 0; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } +public: + sdk_teeth_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bINTRO = false; +#endif // _DEBUG + m_nINTRO = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bINTRO; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 64 * m_nINTRO ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_vs30 vsh_forgot_to_set_static_INTRO + 0 +class sdk_teeth_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nDYNAMIC_LIGHT; +#ifdef _DEBUG + bool m_bDYNAMIC_LIGHT; +#endif +public: + void SetDYNAMIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDYNAMIC_LIGHT = i; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } + void SetDYNAMIC_LIGHT( bool i ) + { + m_nDYNAMIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_teeth_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = false; +#endif // _DEBUG + m_nDYNAMIC_LIGHT = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bDYNAMIC_LIGHT && m_bSTATIC_LIGHT && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nDYNAMIC_LIGHT ) + ( 16 * m_nSTATIC_LIGHT ) + ( 32 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_DYNAMIC_LIGHT + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_unlitgeneric_ps11.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_unlitgeneric_ps11.inc new file mode 100644 index 00000000..30c5c529 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_unlitgeneric_ps11.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_unlitgeneric_ps11_Static_Index +{ +public: + sdk_unlitgeneric_ps11_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_unlitgeneric_ps11 0 +class sdk_unlitgeneric_ps11_Dynamic_Index +{ +public: + sdk_unlitgeneric_ps11_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_unlitgeneric_ps11 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_unlitgeneric_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_unlitgeneric_ps20.inc new file mode 100644 index 00000000..96088dec --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_unlitgeneric_ps20.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_unlitgeneric_ps20_Static_Index +{ +public: + sdk_unlitgeneric_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_unlitgeneric_ps20 0 +class sdk_unlitgeneric_ps20_Dynamic_Index +{ +public: + sdk_unlitgeneric_ps20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_unlitgeneric_ps20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_unlitgeneric_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_unlitgeneric_ps20b.inc new file mode 100644 index 00000000..5f0347a2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_unlitgeneric_ps20b.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_unlitgeneric_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_unlitgeneric_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_unlitgeneric_ps20b 0 +class sdk_unlitgeneric_ps20b_Dynamic_Index +{ +public: + sdk_unlitgeneric_ps20b_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_unlitgeneric_ps20b 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_unlitgeneric_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_unlitgeneric_vs20.inc new file mode 100644 index 00000000..ea58edbc --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_unlitgeneric_vs20.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_unlitgeneric_vs20_Static_Index +{ +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +public: + sdk_unlitgeneric_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bVERTEXCOLOR; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 8 * m_nVERTEXCOLOR ) + 0; + } +}; +#define shaderStaticTest_sdk_unlitgeneric_vs20 vsh_forgot_to_set_static_VERTEXCOLOR + 0 +class sdk_unlitgeneric_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_unlitgeneric_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + 0; + } +}; +#define shaderDynamicTest_sdk_unlitgeneric_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_bump_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_bump_ps20.inc new file mode 100644 index 00000000..a526e689 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_bump_ps20.inc @@ -0,0 +1,412 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_and_unlit_generic_bump_ps20_Static_Index +{ +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nDIFFUSELIGHTING; +#ifdef _DEBUG + bool m_bDIFFUSELIGHTING; +#endif +public: + void SetDIFFUSELIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSELIGHTING = i; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } + void SetDIFFUSELIGHTING( bool i ) + { + m_nDIFFUSELIGHTING = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } +private: + int m_nLIGHTWARPTEXTURE; +#ifdef _DEBUG + bool m_bLIGHTWARPTEXTURE; +#endif +public: + void SetLIGHTWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTWARPTEXTURE = i; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } + void SetLIGHTWARPTEXTURE( bool i ) + { + m_nLIGHTWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nSELFILLUMFRESNEL; +#ifdef _DEBUG + bool m_bSELFILLUMFRESNEL; +#endif +public: + void SetSELFILLUMFRESNEL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUMFRESNEL = i; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = true; +#endif + } + void SetSELFILLUMFRESNEL( bool i ) + { + m_nSELFILLUMFRESNEL = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = true; +#endif + } +private: + int m_nNORMALMAPALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bNORMALMAPALPHAENVMAPMASK; +#endif +public: + void SetNORMALMAPALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAPALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif + } + void SetNORMALMAPALPHAENVMAPMASK( bool i ) + { + m_nNORMALMAPALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 6 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nBLENDTINTBYBASEALPHA; +#ifdef _DEBUG + bool m_bBLENDTINTBYBASEALPHA; +#endif +public: + void SetBLENDTINTBYBASEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLENDTINTBYBASEALPHA = i; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } + void SetBLENDTINTBYBASEALPHA( bool i ) + { + m_nBLENDTINTBYBASEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_bump_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = false; +#endif // _DEBUG + m_nDIFFUSELIGHTING = 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = false; +#endif // _DEBUG + m_nLIGHTWARPTEXTURE = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = false; +#endif // _DEBUG + m_nSELFILLUMFRESNEL = 0; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nNORMALMAPALPHAENVMAPMASK = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = false; +#endif // _DEBUG + m_nBLENDTINTBYBASEALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bLIGHTWARPTEXTURE && m_bSELFILLUM && m_bSELFILLUMFRESNEL && m_bNORMALMAPALPHAENVMAPMASK && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bBLENDTINTBYBASEALPHA; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 24 * m_nCUBEMAP ) + ( 48 * m_nDIFFUSELIGHTING ) + ( 96 * m_nLIGHTWARPTEXTURE ) + ( 192 * m_nSELFILLUM ) + ( 384 * m_nSELFILLUMFRESNEL ) + ( 768 * m_nNORMALMAPALPHAENVMAPMASK ) + ( 1536 * m_nHALFLAMBERT ) + ( 3072 * m_nFLASHLIGHT ) + ( 6144 * m_nDETAILTEXTURE ) + ( 12288 * m_nDETAIL_BLEND_MODE ) + ( 86016 * m_nBLENDTINTBYBASEALPHA ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_bump_ps20 psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_SELFILLUMFRESNEL + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_HALFLAMBERT + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + 0 +class sdk_vertexlit_and_unlit_generic_bump_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nWRITEWATERFOGTODESTALPHA; +#ifdef _DEBUG + bool m_bWRITEWATERFOGTODESTALPHA; +#endif +public: + void SetWRITEWATERFOGTODESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITEWATERFOGTODESTALPHA = i; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } + void SetWRITEWATERFOGTODESTALPHA( bool i ) + { + m_nWRITEWATERFOGTODESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nAMBIENT_LIGHT; +#ifdef _DEBUG + bool m_bAMBIENT_LIGHT; +#endif +public: + void SetAMBIENT_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nAMBIENT_LIGHT = i; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } + void SetAMBIENT_LIGHT( bool i ) + { + m_nAMBIENT_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_bump_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = false; +#endif // _DEBUG + m_nWRITEWATERFOGTODESTALPHA = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = false; +#endif // _DEBUG + m_nAMBIENT_LIGHT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bWRITEWATERFOGTODESTALPHA && m_bNUM_LIGHTS && m_bAMBIENT_LIGHT; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nWRITEWATERFOGTODESTALPHA ) + ( 4 * m_nNUM_LIGHTS ) + ( 12 * m_nAMBIENT_LIGHT ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_and_unlit_generic_bump_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_AMBIENT_LIGHT + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_bump_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_bump_ps20b.inc new file mode 100644 index 00000000..c6da2788 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_bump_ps20b.inc @@ -0,0 +1,412 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_and_unlit_generic_bump_ps20b_Static_Index +{ +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nDIFFUSELIGHTING; +#ifdef _DEBUG + bool m_bDIFFUSELIGHTING; +#endif +public: + void SetDIFFUSELIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSELIGHTING = i; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } + void SetDIFFUSELIGHTING( bool i ) + { + m_nDIFFUSELIGHTING = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } +private: + int m_nLIGHTWARPTEXTURE; +#ifdef _DEBUG + bool m_bLIGHTWARPTEXTURE; +#endif +public: + void SetLIGHTWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTWARPTEXTURE = i; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } + void SetLIGHTWARPTEXTURE( bool i ) + { + m_nLIGHTWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nSELFILLUMFRESNEL; +#ifdef _DEBUG + bool m_bSELFILLUMFRESNEL; +#endif +public: + void SetSELFILLUMFRESNEL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUMFRESNEL = i; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = true; +#endif + } + void SetSELFILLUMFRESNEL( bool i ) + { + m_nSELFILLUMFRESNEL = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = true; +#endif + } +private: + int m_nNORMALMAPALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bNORMALMAPALPHAENVMAPMASK; +#endif +public: + void SetNORMALMAPALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAPALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif + } + void SetNORMALMAPALPHAENVMAPMASK( bool i ) + { + m_nNORMALMAPALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 6 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +private: + int m_nBLENDTINTBYBASEALPHA; +#ifdef _DEBUG + bool m_bBLENDTINTBYBASEALPHA; +#endif +public: + void SetBLENDTINTBYBASEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLENDTINTBYBASEALPHA = i; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } + void SetBLENDTINTBYBASEALPHA( bool i ) + { + m_nBLENDTINTBYBASEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_bump_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = false; +#endif // _DEBUG + m_nDIFFUSELIGHTING = 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = false; +#endif // _DEBUG + m_nLIGHTWARPTEXTURE = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = false; +#endif // _DEBUG + m_nSELFILLUMFRESNEL = 0; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nNORMALMAPALPHAENVMAPMASK = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = false; +#endif // _DEBUG + m_nBLENDTINTBYBASEALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bLIGHTWARPTEXTURE && m_bSELFILLUM && m_bSELFILLUMFRESNEL && m_bNORMALMAPALPHAENVMAPMASK && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bFLASHLIGHTDEPTHFILTERMODE && m_bBLENDTINTBYBASEALPHA; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 20 * m_nCUBEMAP ) + ( 40 * m_nDIFFUSELIGHTING ) + ( 80 * m_nLIGHTWARPTEXTURE ) + ( 160 * m_nSELFILLUM ) + ( 320 * m_nSELFILLUMFRESNEL ) + ( 640 * m_nNORMALMAPALPHAENVMAPMASK ) + ( 1280 * m_nHALFLAMBERT ) + ( 2560 * m_nFLASHLIGHT ) + ( 5120 * m_nDETAILTEXTURE ) + ( 10240 * m_nDETAIL_BLEND_MODE ) + ( 71680 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 215040 * m_nBLENDTINTBYBASEALPHA ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_bump_ps20b psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_SELFILLUMFRESNEL + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_HALFLAMBERT + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + 0 +class sdk_vertexlit_and_unlit_generic_bump_ps20b_Dynamic_Index +{ +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nAMBIENT_LIGHT; +#ifdef _DEBUG + bool m_bAMBIENT_LIGHT; +#endif +public: + void SetAMBIENT_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nAMBIENT_LIGHT = i; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } + void SetAMBIENT_LIGHT( bool i ) + { + m_nAMBIENT_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_bump_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = false; +#endif // _DEBUG + m_nAMBIENT_LIGHT = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bNUM_LIGHTS && m_bAMBIENT_LIGHT && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nNUM_LIGHTS ) + ( 5 * m_nAMBIENT_LIGHT ) + ( 10 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_and_unlit_generic_bump_ps20b psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_AMBIENT_LIGHT + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_bump_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_bump_ps30.inc new file mode 100644 index 00000000..205a2809 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_bump_ps30.inc @@ -0,0 +1,412 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_and_unlit_generic_bump_ps30_Static_Index +{ +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nDIFFUSELIGHTING; +#ifdef _DEBUG + bool m_bDIFFUSELIGHTING; +#endif +public: + void SetDIFFUSELIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSELIGHTING = i; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } + void SetDIFFUSELIGHTING( bool i ) + { + m_nDIFFUSELIGHTING = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } +private: + int m_nLIGHTWARPTEXTURE; +#ifdef _DEBUG + bool m_bLIGHTWARPTEXTURE; +#endif +public: + void SetLIGHTWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTWARPTEXTURE = i; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } + void SetLIGHTWARPTEXTURE( bool i ) + { + m_nLIGHTWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nSELFILLUMFRESNEL; +#ifdef _DEBUG + bool m_bSELFILLUMFRESNEL; +#endif +public: + void SetSELFILLUMFRESNEL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUMFRESNEL = i; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = true; +#endif + } + void SetSELFILLUMFRESNEL( bool i ) + { + m_nSELFILLUMFRESNEL = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = true; +#endif + } +private: + int m_nNORMALMAPALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bNORMALMAPALPHAENVMAPMASK; +#endif +public: + void SetNORMALMAPALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAPALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif + } + void SetNORMALMAPALPHAENVMAPMASK( bool i ) + { + m_nNORMALMAPALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 6 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +private: + int m_nBLENDTINTBYBASEALPHA; +#ifdef _DEBUG + bool m_bBLENDTINTBYBASEALPHA; +#endif +public: + void SetBLENDTINTBYBASEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLENDTINTBYBASEALPHA = i; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } + void SetBLENDTINTBYBASEALPHA( bool i ) + { + m_nBLENDTINTBYBASEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_bump_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = false; +#endif // _DEBUG + m_nDIFFUSELIGHTING = 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = false; +#endif // _DEBUG + m_nLIGHTWARPTEXTURE = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = false; +#endif // _DEBUG + m_nSELFILLUMFRESNEL = 0; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nNORMALMAPALPHAENVMAPMASK = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = false; +#endif // _DEBUG + m_nBLENDTINTBYBASEALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bLIGHTWARPTEXTURE && m_bSELFILLUM && m_bSELFILLUMFRESNEL && m_bNORMALMAPALPHAENVMAPMASK && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bFLASHLIGHTDEPTHFILTERMODE && m_bBLENDTINTBYBASEALPHA; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 20 * m_nCUBEMAP ) + ( 40 * m_nDIFFUSELIGHTING ) + ( 80 * m_nLIGHTWARPTEXTURE ) + ( 160 * m_nSELFILLUM ) + ( 320 * m_nSELFILLUMFRESNEL ) + ( 640 * m_nNORMALMAPALPHAENVMAPMASK ) + ( 1280 * m_nHALFLAMBERT ) + ( 2560 * m_nFLASHLIGHT ) + ( 5120 * m_nDETAILTEXTURE ) + ( 10240 * m_nDETAIL_BLEND_MODE ) + ( 71680 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 215040 * m_nBLENDTINTBYBASEALPHA ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_bump_ps30 psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_SELFILLUMFRESNEL + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_HALFLAMBERT + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + 0 +class sdk_vertexlit_and_unlit_generic_bump_ps30_Dynamic_Index +{ +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nAMBIENT_LIGHT; +#ifdef _DEBUG + bool m_bAMBIENT_LIGHT; +#endif +public: + void SetAMBIENT_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nAMBIENT_LIGHT = i; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } + void SetAMBIENT_LIGHT( bool i ) + { + m_nAMBIENT_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_bump_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = false; +#endif // _DEBUG + m_nAMBIENT_LIGHT = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bNUM_LIGHTS && m_bAMBIENT_LIGHT && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nNUM_LIGHTS ) + ( 5 * m_nAMBIENT_LIGHT ) + ( 10 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_and_unlit_generic_bump_ps30 psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_AMBIENT_LIGHT + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_bump_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_bump_vs20.inc new file mode 100644 index 00000000..7c9fe088 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_bump_vs20.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_and_unlit_generic_bump_vs20_Static_Index +{ +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nUSE_WITH_2B; +#ifdef _DEBUG + bool m_bUSE_WITH_2B; +#endif +public: + void SetUSE_WITH_2B( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nUSE_WITH_2B = i; +#ifdef _DEBUG + m_bUSE_WITH_2B = true; +#endif + } + void SetUSE_WITH_2B( bool i ) + { + m_nUSE_WITH_2B = i ? 1 : 0; +#ifdef _DEBUG + m_bUSE_WITH_2B = true; +#endif + } +private: + int m_nUSE_STATIC_CONTROL_FLOW; +#ifdef _DEBUG + bool m_bUSE_STATIC_CONTROL_FLOW; +#endif +public: + void SetUSE_STATIC_CONTROL_FLOW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nUSE_STATIC_CONTROL_FLOW = i; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } + void SetUSE_STATIC_CONTROL_FLOW( bool i ) + { + m_nUSE_STATIC_CONTROL_FLOW = i ? 1 : 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_bump_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bUSE_WITH_2B = false; +#endif // _DEBUG + m_nUSE_WITH_2B = 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = false; +#endif // _DEBUG + m_nUSE_STATIC_CONTROL_FLOW = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bHALFLAMBERT && m_bUSE_WITH_2B && m_bUSE_STATIC_CONTROL_FLOW; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 24 * m_nHALFLAMBERT ) + ( 48 * m_nUSE_WITH_2B ) + ( 96 * m_nUSE_STATIC_CONTROL_FLOW ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_bump_vs20 vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_USE_WITH_2B + vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + 0 +class sdk_vertexlit_and_unlit_generic_bump_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_bump_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_and_unlit_generic_bump_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_bump_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_bump_vs30.inc new file mode 100644 index 00000000..06841a47 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_bump_vs30.inc @@ -0,0 +1,237 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_and_unlit_generic_bump_vs30_Static_Index +{ +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nUSE_WITH_2B; +#ifdef _DEBUG + bool m_bUSE_WITH_2B; +#endif +public: + void SetUSE_WITH_2B( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nUSE_WITH_2B = i; +#ifdef _DEBUG + m_bUSE_WITH_2B = true; +#endif + } + void SetUSE_WITH_2B( bool i ) + { + m_nUSE_WITH_2B = i ? 1 : 0; +#ifdef _DEBUG + m_bUSE_WITH_2B = true; +#endif + } +private: + int m_nDECAL; +#ifdef _DEBUG + bool m_bDECAL; +#endif +public: + void SetDECAL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDECAL = i; +#ifdef _DEBUG + m_bDECAL = true; +#endif + } + void SetDECAL( bool i ) + { + m_nDECAL = i ? 1 : 0; +#ifdef _DEBUG + m_bDECAL = true; +#endif + } +private: + int m_nSM30_VERTEXID; +#ifdef _DEBUG + bool m_bSM30_VERTEXID; +#endif +public: + void SetSM30_VERTEXID( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSM30_VERTEXID = i; +#ifdef _DEBUG + m_bSM30_VERTEXID = true; +#endif + } + void SetSM30_VERTEXID( bool i ) + { + m_nSM30_VERTEXID = i ? 1 : 0; +#ifdef _DEBUG + m_bSM30_VERTEXID = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_bump_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bUSE_WITH_2B = false; +#endif // _DEBUG + m_nUSE_WITH_2B = 0; +#ifdef _DEBUG + m_bDECAL = false; +#endif // _DEBUG + m_nDECAL = 0; +#ifdef _DEBUG + m_bSM30_VERTEXID = false; +#endif // _DEBUG + m_nSM30_VERTEXID = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bHALFLAMBERT && m_bUSE_WITH_2B && m_bDECAL && m_bSM30_VERTEXID; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 16 * m_nHALFLAMBERT ) + ( 32 * m_nUSE_WITH_2B ) + ( 64 * m_nDECAL ) + ( 128 * m_nSM30_VERTEXID ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_bump_vs30 vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_USE_WITH_2B + vsh_forgot_to_set_static_DECAL + vsh_forgot_to_set_static_SM30_VERTEXID + 0 +class sdk_vertexlit_and_unlit_generic_bump_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_bump_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_and_unlit_generic_bump_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_ps20.inc new file mode 100644 index 00000000..0bf098cd --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_ps20.inc @@ -0,0 +1,562 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_and_unlit_generic_ps20_Static_Index +{ +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nDIFFUSELIGHTING; +#ifdef _DEBUG + bool m_bDIFFUSELIGHTING; +#endif +public: + void SetDIFFUSELIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSELIGHTING = i; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } + void SetDIFFUSELIGHTING( bool i ) + { + m_nDIFFUSELIGHTING = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } +private: + int m_nENVMAPMASK; +#ifdef _DEBUG + bool m_bENVMAPMASK; +#endif +public: + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } + void SetENVMAPMASK( bool i ) + { + m_nENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } +private: + int m_nBASEALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bBASEALPHAENVMAPMASK; +#endif +public: + void SetBASEALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASEALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } + void SetBASEALPHAENVMAPMASK( bool i ) + { + m_nBASEALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nSELFILLUM_ENVMAPMASK_ALPHA; +#ifdef _DEBUG + bool m_bSELFILLUM_ENVMAPMASK_ALPHA; +#endif +public: + void SetSELFILLUM_ENVMAPMASK_ALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM_ENVMAPMASK_ALPHA = i; +#ifdef _DEBUG + m_bSELFILLUM_ENVMAPMASK_ALPHA = true; +#endif + } + void SetSELFILLUM_ENVMAPMASK_ALPHA( bool i ) + { + m_nSELFILLUM_ENVMAPMASK_ALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM_ENVMAPMASK_ALPHA = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 9 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nSEAMLESS_BASE; +#ifdef _DEBUG + bool m_bSEAMLESS_BASE; +#endif +public: + void SetSEAMLESS_BASE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS_BASE = i; +#ifdef _DEBUG + m_bSEAMLESS_BASE = true; +#endif + } + void SetSEAMLESS_BASE( bool i ) + { + m_nSEAMLESS_BASE = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS_BASE = true; +#endif + } +private: + int m_nSEAMLESS_DETAIL; +#ifdef _DEBUG + bool m_bSEAMLESS_DETAIL; +#endif +public: + void SetSEAMLESS_DETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS_DETAIL = i; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = true; +#endif + } + void SetSEAMLESS_DETAIL( bool i ) + { + m_nSEAMLESS_DETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = true; +#endif + } +private: + int m_nDISTANCEALPHA; +#ifdef _DEBUG + bool m_bDISTANCEALPHA; +#endif +public: + void SetDISTANCEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDISTANCEALPHA = i; +#ifdef _DEBUG + m_bDISTANCEALPHA = true; +#endif + } + void SetDISTANCEALPHA( bool i ) + { + m_nDISTANCEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bDISTANCEALPHA = true; +#endif + } +private: + int m_nDISTANCEALPHAFROMDETAIL; +#ifdef _DEBUG + bool m_bDISTANCEALPHAFROMDETAIL; +#endif +public: + void SetDISTANCEALPHAFROMDETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDISTANCEALPHAFROMDETAIL = i; +#ifdef _DEBUG + m_bDISTANCEALPHAFROMDETAIL = true; +#endif + } + void SetDISTANCEALPHAFROMDETAIL( bool i ) + { + m_nDISTANCEALPHAFROMDETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bDISTANCEALPHAFROMDETAIL = true; +#endif + } +private: + int m_nSOFT_MASK; +#ifdef _DEBUG + bool m_bSOFT_MASK; +#endif +public: + void SetSOFT_MASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSOFT_MASK = i; +#ifdef _DEBUG + m_bSOFT_MASK = true; +#endif + } + void SetSOFT_MASK( bool i ) + { + m_nSOFT_MASK = i ? 1 : 0; +#ifdef _DEBUG + m_bSOFT_MASK = true; +#endif + } +private: + int m_nOUTLINE; +#ifdef _DEBUG + bool m_bOUTLINE; +#endif +public: + void SetOUTLINE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nOUTLINE = i; +#ifdef _DEBUG + m_bOUTLINE = true; +#endif + } + void SetOUTLINE( bool i ) + { + m_nOUTLINE = i ? 1 : 0; +#ifdef _DEBUG + m_bOUTLINE = true; +#endif + } +private: + int m_nOUTER_GLOW; +#ifdef _DEBUG + bool m_bOUTER_GLOW; +#endif +public: + void SetOUTER_GLOW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nOUTER_GLOW = i; +#ifdef _DEBUG + m_bOUTER_GLOW = true; +#endif + } + void SetOUTER_GLOW( bool i ) + { + m_nOUTER_GLOW = i ? 1 : 0; +#ifdef _DEBUG + m_bOUTER_GLOW = true; +#endif + } +private: + int m_nBLENDTINTBYBASEALPHA; +#ifdef _DEBUG + bool m_bBLENDTINTBYBASEALPHA; +#endif +public: + void SetBLENDTINTBYBASEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLENDTINTBYBASEALPHA = i; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } + void SetBLENDTINTBYBASEALPHA( bool i ) + { + m_nBLENDTINTBYBASEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } +private: + int m_nCUBEMAP_SPHERE_LEGACY; +#ifdef _DEBUG + bool m_bCUBEMAP_SPHERE_LEGACY; +#endif +public: + void SetCUBEMAP_SPHERE_LEGACY( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP_SPHERE_LEGACY = i; +#ifdef _DEBUG + m_bCUBEMAP_SPHERE_LEGACY = true; +#endif + } + void SetCUBEMAP_SPHERE_LEGACY( bool i ) + { + m_nCUBEMAP_SPHERE_LEGACY = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP_SPHERE_LEGACY = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = false; +#endif // _DEBUG + m_nDIFFUSELIGHTING = 0; +#ifdef _DEBUG + m_bENVMAPMASK = false; +#endif // _DEBUG + m_nENVMAPMASK = 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nBASEALPHAENVMAPMASK = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bSELFILLUM_ENVMAPMASK_ALPHA = false; +#endif // _DEBUG + m_nSELFILLUM_ENVMAPMASK_ALPHA = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bSEAMLESS_BASE = false; +#endif // _DEBUG + m_nSEAMLESS_BASE = 0; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = false; +#endif // _DEBUG + m_nSEAMLESS_DETAIL = 0; +#ifdef _DEBUG + m_bDISTANCEALPHA = false; +#endif // _DEBUG + m_nDISTANCEALPHA = 0; +#ifdef _DEBUG + m_bDISTANCEALPHAFROMDETAIL = false; +#endif // _DEBUG + m_nDISTANCEALPHAFROMDETAIL = 0; +#ifdef _DEBUG + m_bSOFT_MASK = false; +#endif // _DEBUG + m_nSOFT_MASK = 0; +#ifdef _DEBUG + m_bOUTLINE = false; +#endif // _DEBUG + m_nOUTLINE = 0; +#ifdef _DEBUG + m_bOUTER_GLOW = false; +#endif // _DEBUG + m_nOUTER_GLOW = 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = false; +#endif // _DEBUG + m_nBLENDTINTBYBASEALPHA = 0; +#ifdef _DEBUG + m_bCUBEMAP_SPHERE_LEGACY = false; +#endif // _DEBUG + m_nCUBEMAP_SPHERE_LEGACY = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bDETAILTEXTURE && m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bENVMAPMASK && m_bBASEALPHAENVMAPMASK && m_bSELFILLUM && m_bVERTEXCOLOR && m_bFLASHLIGHT && m_bSELFILLUM_ENVMAPMASK_ALPHA && m_bDETAIL_BLEND_MODE && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bDISTANCEALPHA && m_bDISTANCEALPHAFROMDETAIL && m_bSOFT_MASK && m_bOUTLINE && m_bOUTER_GLOW && m_bBLENDTINTBYBASEALPHA && m_bCUBEMAP_SPHERE_LEGACY; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 6 * m_nDETAILTEXTURE ) + ( 12 * m_nCUBEMAP ) + ( 24 * m_nDIFFUSELIGHTING ) + ( 48 * m_nENVMAPMASK ) + ( 96 * m_nBASEALPHAENVMAPMASK ) + ( 192 * m_nSELFILLUM ) + ( 384 * m_nVERTEXCOLOR ) + ( 768 * m_nFLASHLIGHT ) + ( 1536 * m_nSELFILLUM_ENVMAPMASK_ALPHA ) + ( 3072 * m_nDETAIL_BLEND_MODE ) + ( 30720 * m_nSEAMLESS_BASE ) + ( 61440 * m_nSEAMLESS_DETAIL ) + ( 122880 * m_nDISTANCEALPHA ) + ( 245760 * m_nDISTANCEALPHAFROMDETAIL ) + ( 491520 * m_nSOFT_MASK ) + ( 983040 * m_nOUTLINE ) + ( 1966080 * m_nOUTER_GLOW ) + ( 3932160 * m_nBLENDTINTBYBASEALPHA ) + ( 7864320 * m_nCUBEMAP_SPHERE_LEGACY ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_ps20 psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_SELFILLUM_ENVMAPMASK_ALPHA + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_SEAMLESS_BASE + psh_forgot_to_set_static_SEAMLESS_DETAIL + psh_forgot_to_set_static_DISTANCEALPHA + psh_forgot_to_set_static_DISTANCEALPHAFROMDETAIL + psh_forgot_to_set_static_SOFT_MASK + psh_forgot_to_set_static_OUTLINE + psh_forgot_to_set_static_OUTER_GLOW + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + psh_forgot_to_set_static_CUBEMAP_SPHERE_LEGACY + 0 +class sdk_vertexlit_and_unlit_generic_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bLIGHTING_PREVIEW; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nLIGHTING_PREVIEW ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_and_unlit_generic_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_LIGHTING_PREVIEW + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_ps20b.inc new file mode 100644 index 00000000..ee74372c --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_ps20b.inc @@ -0,0 +1,637 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_and_unlit_generic_ps20b_Static_Index +{ +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nDIFFUSELIGHTING; +#ifdef _DEBUG + bool m_bDIFFUSELIGHTING; +#endif +public: + void SetDIFFUSELIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSELIGHTING = i; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } + void SetDIFFUSELIGHTING( bool i ) + { + m_nDIFFUSELIGHTING = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } +private: + int m_nENVMAPMASK; +#ifdef _DEBUG + bool m_bENVMAPMASK; +#endif +public: + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } + void SetENVMAPMASK( bool i ) + { + m_nENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } +private: + int m_nBASEALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bBASEALPHAENVMAPMASK; +#endif +public: + void SetBASEALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASEALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } + void SetBASEALPHAENVMAPMASK( bool i ) + { + m_nBASEALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nSELFILLUM_ENVMAPMASK_ALPHA; +#ifdef _DEBUG + bool m_bSELFILLUM_ENVMAPMASK_ALPHA; +#endif +public: + void SetSELFILLUM_ENVMAPMASK_ALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM_ENVMAPMASK_ALPHA = i; +#ifdef _DEBUG + m_bSELFILLUM_ENVMAPMASK_ALPHA = true; +#endif + } + void SetSELFILLUM_ENVMAPMASK_ALPHA( bool i ) + { + m_nSELFILLUM_ENVMAPMASK_ALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM_ENVMAPMASK_ALPHA = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 9 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nSEAMLESS_BASE; +#ifdef _DEBUG + bool m_bSEAMLESS_BASE; +#endif +public: + void SetSEAMLESS_BASE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS_BASE = i; +#ifdef _DEBUG + m_bSEAMLESS_BASE = true; +#endif + } + void SetSEAMLESS_BASE( bool i ) + { + m_nSEAMLESS_BASE = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS_BASE = true; +#endif + } +private: + int m_nSEAMLESS_DETAIL; +#ifdef _DEBUG + bool m_bSEAMLESS_DETAIL; +#endif +public: + void SetSEAMLESS_DETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS_DETAIL = i; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = true; +#endif + } + void SetSEAMLESS_DETAIL( bool i ) + { + m_nSEAMLESS_DETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = true; +#endif + } +private: + int m_nDISTANCEALPHA; +#ifdef _DEBUG + bool m_bDISTANCEALPHA; +#endif +public: + void SetDISTANCEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDISTANCEALPHA = i; +#ifdef _DEBUG + m_bDISTANCEALPHA = true; +#endif + } + void SetDISTANCEALPHA( bool i ) + { + m_nDISTANCEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bDISTANCEALPHA = true; +#endif + } +private: + int m_nDISTANCEALPHAFROMDETAIL; +#ifdef _DEBUG + bool m_bDISTANCEALPHAFROMDETAIL; +#endif +public: + void SetDISTANCEALPHAFROMDETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDISTANCEALPHAFROMDETAIL = i; +#ifdef _DEBUG + m_bDISTANCEALPHAFROMDETAIL = true; +#endif + } + void SetDISTANCEALPHAFROMDETAIL( bool i ) + { + m_nDISTANCEALPHAFROMDETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bDISTANCEALPHAFROMDETAIL = true; +#endif + } +private: + int m_nSOFT_MASK; +#ifdef _DEBUG + bool m_bSOFT_MASK; +#endif +public: + void SetSOFT_MASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSOFT_MASK = i; +#ifdef _DEBUG + m_bSOFT_MASK = true; +#endif + } + void SetSOFT_MASK( bool i ) + { + m_nSOFT_MASK = i ? 1 : 0; +#ifdef _DEBUG + m_bSOFT_MASK = true; +#endif + } +private: + int m_nOUTLINE; +#ifdef _DEBUG + bool m_bOUTLINE; +#endif +public: + void SetOUTLINE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nOUTLINE = i; +#ifdef _DEBUG + m_bOUTLINE = true; +#endif + } + void SetOUTLINE( bool i ) + { + m_nOUTLINE = i ? 1 : 0; +#ifdef _DEBUG + m_bOUTLINE = true; +#endif + } +private: + int m_nOUTER_GLOW; +#ifdef _DEBUG + bool m_bOUTER_GLOW; +#endif +public: + void SetOUTER_GLOW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nOUTER_GLOW = i; +#ifdef _DEBUG + m_bOUTER_GLOW = true; +#endif + } + void SetOUTER_GLOW( bool i ) + { + m_nOUTER_GLOW = i ? 1 : 0; +#ifdef _DEBUG + m_bOUTER_GLOW = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +private: + int m_nDEPTHBLEND; +#ifdef _DEBUG + bool m_bDEPTHBLEND; +#endif +public: + void SetDEPTHBLEND( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDEPTHBLEND = i; +#ifdef _DEBUG + m_bDEPTHBLEND = true; +#endif + } + void SetDEPTHBLEND( bool i ) + { + m_nDEPTHBLEND = i ? 1 : 0; +#ifdef _DEBUG + m_bDEPTHBLEND = true; +#endif + } +private: + int m_nBLENDTINTBYBASEALPHA; +#ifdef _DEBUG + bool m_bBLENDTINTBYBASEALPHA; +#endif +public: + void SetBLENDTINTBYBASEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLENDTINTBYBASEALPHA = i; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } + void SetBLENDTINTBYBASEALPHA( bool i ) + { + m_nBLENDTINTBYBASEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } +private: + int m_nSRGB_INPUT_ADAPTER; +#ifdef _DEBUG + bool m_bSRGB_INPUT_ADAPTER; +#endif +public: + void SetSRGB_INPUT_ADAPTER( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSRGB_INPUT_ADAPTER = i; +#ifdef _DEBUG + m_bSRGB_INPUT_ADAPTER = true; +#endif + } + void SetSRGB_INPUT_ADAPTER( bool i ) + { + m_nSRGB_INPUT_ADAPTER = i ? 1 : 0; +#ifdef _DEBUG + m_bSRGB_INPUT_ADAPTER = true; +#endif + } +private: + int m_nCUBEMAP_SPHERE_LEGACY; +#ifdef _DEBUG + bool m_bCUBEMAP_SPHERE_LEGACY; +#endif +public: + void SetCUBEMAP_SPHERE_LEGACY( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP_SPHERE_LEGACY = i; +#ifdef _DEBUG + m_bCUBEMAP_SPHERE_LEGACY = true; +#endif + } + void SetCUBEMAP_SPHERE_LEGACY( bool i ) + { + m_nCUBEMAP_SPHERE_LEGACY = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP_SPHERE_LEGACY = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = false; +#endif // _DEBUG + m_nDIFFUSELIGHTING = 0; +#ifdef _DEBUG + m_bENVMAPMASK = false; +#endif // _DEBUG + m_nENVMAPMASK = 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nBASEALPHAENVMAPMASK = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bSELFILLUM_ENVMAPMASK_ALPHA = false; +#endif // _DEBUG + m_nSELFILLUM_ENVMAPMASK_ALPHA = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bSEAMLESS_BASE = false; +#endif // _DEBUG + m_nSEAMLESS_BASE = 0; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = false; +#endif // _DEBUG + m_nSEAMLESS_DETAIL = 0; +#ifdef _DEBUG + m_bDISTANCEALPHA = false; +#endif // _DEBUG + m_nDISTANCEALPHA = 0; +#ifdef _DEBUG + m_bDISTANCEALPHAFROMDETAIL = false; +#endif // _DEBUG + m_nDISTANCEALPHAFROMDETAIL = 0; +#ifdef _DEBUG + m_bSOFT_MASK = false; +#endif // _DEBUG + m_nSOFT_MASK = 0; +#ifdef _DEBUG + m_bOUTLINE = false; +#endif // _DEBUG + m_nOUTLINE = 0; +#ifdef _DEBUG + m_bOUTER_GLOW = false; +#endif // _DEBUG + m_nOUTER_GLOW = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; +#ifdef _DEBUG + m_bDEPTHBLEND = false; +#endif // _DEBUG + m_nDEPTHBLEND = 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = false; +#endif // _DEBUG + m_nBLENDTINTBYBASEALPHA = 0; +#ifdef _DEBUG + m_bSRGB_INPUT_ADAPTER = false; +#endif // _DEBUG + m_nSRGB_INPUT_ADAPTER = 0; +#ifdef _DEBUG + m_bCUBEMAP_SPHERE_LEGACY = false; +#endif // _DEBUG + m_nCUBEMAP_SPHERE_LEGACY = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bDETAILTEXTURE && m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bENVMAPMASK && m_bBASEALPHAENVMAPMASK && m_bSELFILLUM && m_bVERTEXCOLOR && m_bFLASHLIGHT && m_bSELFILLUM_ENVMAPMASK_ALPHA && m_bDETAIL_BLEND_MODE && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bDISTANCEALPHA && m_bDISTANCEALPHAFROMDETAIL && m_bSOFT_MASK && m_bOUTLINE && m_bOUTER_GLOW && m_bFLASHLIGHTDEPTHFILTERMODE && m_bDEPTHBLEND && m_bBLENDTINTBYBASEALPHA && m_bSRGB_INPUT_ADAPTER && m_bCUBEMAP_SPHERE_LEGACY; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 6 * m_nDETAILTEXTURE ) + ( 12 * m_nCUBEMAP ) + ( 24 * m_nDIFFUSELIGHTING ) + ( 48 * m_nENVMAPMASK ) + ( 96 * m_nBASEALPHAENVMAPMASK ) + ( 192 * m_nSELFILLUM ) + ( 384 * m_nVERTEXCOLOR ) + ( 768 * m_nFLASHLIGHT ) + ( 1536 * m_nSELFILLUM_ENVMAPMASK_ALPHA ) + ( 3072 * m_nDETAIL_BLEND_MODE ) + ( 30720 * m_nSEAMLESS_BASE ) + ( 61440 * m_nSEAMLESS_DETAIL ) + ( 122880 * m_nDISTANCEALPHA ) + ( 245760 * m_nDISTANCEALPHAFROMDETAIL ) + ( 491520 * m_nSOFT_MASK ) + ( 983040 * m_nOUTLINE ) + ( 1966080 * m_nOUTER_GLOW ) + ( 3932160 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 11796480 * m_nDEPTHBLEND ) + ( 23592960 * m_nBLENDTINTBYBASEALPHA ) + ( 47185920 * m_nSRGB_INPUT_ADAPTER ) + ( 94371840 * m_nCUBEMAP_SPHERE_LEGACY ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_ps20b psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_SELFILLUM_ENVMAPMASK_ALPHA + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_SEAMLESS_BASE + psh_forgot_to_set_static_SEAMLESS_DETAIL + psh_forgot_to_set_static_DISTANCEALPHA + psh_forgot_to_set_static_DISTANCEALPHAFROMDETAIL + psh_forgot_to_set_static_SOFT_MASK + psh_forgot_to_set_static_OUTLINE + psh_forgot_to_set_static_OUTER_GLOW + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_DEPTHBLEND + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + psh_forgot_to_set_static_SRGB_INPUT_ADAPTER + psh_forgot_to_set_static_CUBEMAP_SPHERE_LEGACY + 0 +class sdk_vertexlit_and_unlit_generic_ps20b_Dynamic_Index +{ +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bLIGHTING_PREVIEW && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nLIGHTING_PREVIEW ) + ( 3 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_and_unlit_generic_ps20b psh_forgot_to_set_dynamic_LIGHTING_PREVIEW + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_ps30.inc new file mode 100644 index 00000000..c5a18611 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_ps30.inc @@ -0,0 +1,612 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_and_unlit_generic_ps30_Static_Index +{ +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nDIFFUSELIGHTING; +#ifdef _DEBUG + bool m_bDIFFUSELIGHTING; +#endif +public: + void SetDIFFUSELIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSELIGHTING = i; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } + void SetDIFFUSELIGHTING( bool i ) + { + m_nDIFFUSELIGHTING = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } +private: + int m_nENVMAPMASK; +#ifdef _DEBUG + bool m_bENVMAPMASK; +#endif +public: + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } + void SetENVMAPMASK( bool i ) + { + m_nENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } +private: + int m_nBASEALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bBASEALPHAENVMAPMASK; +#endif +public: + void SetBASEALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASEALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } + void SetBASEALPHAENVMAPMASK( bool i ) + { + m_nBASEALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nSELFILLUM_ENVMAPMASK_ALPHA; +#ifdef _DEBUG + bool m_bSELFILLUM_ENVMAPMASK_ALPHA; +#endif +public: + void SetSELFILLUM_ENVMAPMASK_ALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM_ENVMAPMASK_ALPHA = i; +#ifdef _DEBUG + m_bSELFILLUM_ENVMAPMASK_ALPHA = true; +#endif + } + void SetSELFILLUM_ENVMAPMASK_ALPHA( bool i ) + { + m_nSELFILLUM_ENVMAPMASK_ALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM_ENVMAPMASK_ALPHA = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 9 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nSEAMLESS_BASE; +#ifdef _DEBUG + bool m_bSEAMLESS_BASE; +#endif +public: + void SetSEAMLESS_BASE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS_BASE = i; +#ifdef _DEBUG + m_bSEAMLESS_BASE = true; +#endif + } + void SetSEAMLESS_BASE( bool i ) + { + m_nSEAMLESS_BASE = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS_BASE = true; +#endif + } +private: + int m_nSEAMLESS_DETAIL; +#ifdef _DEBUG + bool m_bSEAMLESS_DETAIL; +#endif +public: + void SetSEAMLESS_DETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS_DETAIL = i; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = true; +#endif + } + void SetSEAMLESS_DETAIL( bool i ) + { + m_nSEAMLESS_DETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = true; +#endif + } +private: + int m_nDISTANCEALPHA; +#ifdef _DEBUG + bool m_bDISTANCEALPHA; +#endif +public: + void SetDISTANCEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDISTANCEALPHA = i; +#ifdef _DEBUG + m_bDISTANCEALPHA = true; +#endif + } + void SetDISTANCEALPHA( bool i ) + { + m_nDISTANCEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bDISTANCEALPHA = true; +#endif + } +private: + int m_nDISTANCEALPHAFROMDETAIL; +#ifdef _DEBUG + bool m_bDISTANCEALPHAFROMDETAIL; +#endif +public: + void SetDISTANCEALPHAFROMDETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDISTANCEALPHAFROMDETAIL = i; +#ifdef _DEBUG + m_bDISTANCEALPHAFROMDETAIL = true; +#endif + } + void SetDISTANCEALPHAFROMDETAIL( bool i ) + { + m_nDISTANCEALPHAFROMDETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bDISTANCEALPHAFROMDETAIL = true; +#endif + } +private: + int m_nSOFT_MASK; +#ifdef _DEBUG + bool m_bSOFT_MASK; +#endif +public: + void SetSOFT_MASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSOFT_MASK = i; +#ifdef _DEBUG + m_bSOFT_MASK = true; +#endif + } + void SetSOFT_MASK( bool i ) + { + m_nSOFT_MASK = i ? 1 : 0; +#ifdef _DEBUG + m_bSOFT_MASK = true; +#endif + } +private: + int m_nOUTLINE; +#ifdef _DEBUG + bool m_bOUTLINE; +#endif +public: + void SetOUTLINE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nOUTLINE = i; +#ifdef _DEBUG + m_bOUTLINE = true; +#endif + } + void SetOUTLINE( bool i ) + { + m_nOUTLINE = i ? 1 : 0; +#ifdef _DEBUG + m_bOUTLINE = true; +#endif + } +private: + int m_nOUTER_GLOW; +#ifdef _DEBUG + bool m_bOUTER_GLOW; +#endif +public: + void SetOUTER_GLOW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nOUTER_GLOW = i; +#ifdef _DEBUG + m_bOUTER_GLOW = true; +#endif + } + void SetOUTER_GLOW( bool i ) + { + m_nOUTER_GLOW = i ? 1 : 0; +#ifdef _DEBUG + m_bOUTER_GLOW = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +private: + int m_nDEPTHBLEND; +#ifdef _DEBUG + bool m_bDEPTHBLEND; +#endif +public: + void SetDEPTHBLEND( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDEPTHBLEND = i; +#ifdef _DEBUG + m_bDEPTHBLEND = true; +#endif + } + void SetDEPTHBLEND( bool i ) + { + m_nDEPTHBLEND = i ? 1 : 0; +#ifdef _DEBUG + m_bDEPTHBLEND = true; +#endif + } +private: + int m_nBLENDTINTBYBASEALPHA; +#ifdef _DEBUG + bool m_bBLENDTINTBYBASEALPHA; +#endif +public: + void SetBLENDTINTBYBASEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLENDTINTBYBASEALPHA = i; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } + void SetBLENDTINTBYBASEALPHA( bool i ) + { + m_nBLENDTINTBYBASEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } +private: + int m_nCUBEMAP_SPHERE_LEGACY; +#ifdef _DEBUG + bool m_bCUBEMAP_SPHERE_LEGACY; +#endif +public: + void SetCUBEMAP_SPHERE_LEGACY( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP_SPHERE_LEGACY = i; +#ifdef _DEBUG + m_bCUBEMAP_SPHERE_LEGACY = true; +#endif + } + void SetCUBEMAP_SPHERE_LEGACY( bool i ) + { + m_nCUBEMAP_SPHERE_LEGACY = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP_SPHERE_LEGACY = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = false; +#endif // _DEBUG + m_nDIFFUSELIGHTING = 0; +#ifdef _DEBUG + m_bENVMAPMASK = false; +#endif // _DEBUG + m_nENVMAPMASK = 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nBASEALPHAENVMAPMASK = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bSELFILLUM_ENVMAPMASK_ALPHA = false; +#endif // _DEBUG + m_nSELFILLUM_ENVMAPMASK_ALPHA = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bSEAMLESS_BASE = false; +#endif // _DEBUG + m_nSEAMLESS_BASE = 0; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = false; +#endif // _DEBUG + m_nSEAMLESS_DETAIL = 0; +#ifdef _DEBUG + m_bDISTANCEALPHA = false; +#endif // _DEBUG + m_nDISTANCEALPHA = 0; +#ifdef _DEBUG + m_bDISTANCEALPHAFROMDETAIL = false; +#endif // _DEBUG + m_nDISTANCEALPHAFROMDETAIL = 0; +#ifdef _DEBUG + m_bSOFT_MASK = false; +#endif // _DEBUG + m_nSOFT_MASK = 0; +#ifdef _DEBUG + m_bOUTLINE = false; +#endif // _DEBUG + m_nOUTLINE = 0; +#ifdef _DEBUG + m_bOUTER_GLOW = false; +#endif // _DEBUG + m_nOUTER_GLOW = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; +#ifdef _DEBUG + m_bDEPTHBLEND = false; +#endif // _DEBUG + m_nDEPTHBLEND = 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = false; +#endif // _DEBUG + m_nBLENDTINTBYBASEALPHA = 0; +#ifdef _DEBUG + m_bCUBEMAP_SPHERE_LEGACY = false; +#endif // _DEBUG + m_nCUBEMAP_SPHERE_LEGACY = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bDETAILTEXTURE && m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bENVMAPMASK && m_bBASEALPHAENVMAPMASK && m_bSELFILLUM && m_bVERTEXCOLOR && m_bFLASHLIGHT && m_bSELFILLUM_ENVMAPMASK_ALPHA && m_bDETAIL_BLEND_MODE && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bDISTANCEALPHA && m_bDISTANCEALPHAFROMDETAIL && m_bSOFT_MASK && m_bOUTLINE && m_bOUTER_GLOW && m_bFLASHLIGHTDEPTHFILTERMODE && m_bDEPTHBLEND && m_bBLENDTINTBYBASEALPHA && m_bCUBEMAP_SPHERE_LEGACY; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 6 * m_nDETAILTEXTURE ) + ( 12 * m_nCUBEMAP ) + ( 24 * m_nDIFFUSELIGHTING ) + ( 48 * m_nENVMAPMASK ) + ( 96 * m_nBASEALPHAENVMAPMASK ) + ( 192 * m_nSELFILLUM ) + ( 384 * m_nVERTEXCOLOR ) + ( 768 * m_nFLASHLIGHT ) + ( 1536 * m_nSELFILLUM_ENVMAPMASK_ALPHA ) + ( 3072 * m_nDETAIL_BLEND_MODE ) + ( 30720 * m_nSEAMLESS_BASE ) + ( 61440 * m_nSEAMLESS_DETAIL ) + ( 122880 * m_nDISTANCEALPHA ) + ( 245760 * m_nDISTANCEALPHAFROMDETAIL ) + ( 491520 * m_nSOFT_MASK ) + ( 983040 * m_nOUTLINE ) + ( 1966080 * m_nOUTER_GLOW ) + ( 3932160 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 11796480 * m_nDEPTHBLEND ) + ( 23592960 * m_nBLENDTINTBYBASEALPHA ) + ( 47185920 * m_nCUBEMAP_SPHERE_LEGACY ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_ps30 psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_SELFILLUM_ENVMAPMASK_ALPHA + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_SEAMLESS_BASE + psh_forgot_to_set_static_SEAMLESS_DETAIL + psh_forgot_to_set_static_DISTANCEALPHA + psh_forgot_to_set_static_DISTANCEALPHAFROMDETAIL + psh_forgot_to_set_static_SOFT_MASK + psh_forgot_to_set_static_OUTLINE + psh_forgot_to_set_static_OUTER_GLOW + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_DEPTHBLEND + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + psh_forgot_to_set_static_CUBEMAP_SPHERE_LEGACY + 0 +class sdk_vertexlit_and_unlit_generic_ps30_Dynamic_Index +{ +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bLIGHTING_PREVIEW && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nLIGHTING_PREVIEW ) + ( 3 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_and_unlit_generic_ps30 psh_forgot_to_set_dynamic_LIGHTING_PREVIEW + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_vs20.inc new file mode 100644 index 00000000..bfbdd4c7 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_vs20.inc @@ -0,0 +1,437 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_and_unlit_generic_vs20_Static_Index +{ +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nSEAMLESS_BASE; +#ifdef _DEBUG + bool m_bSEAMLESS_BASE; +#endif +public: + void SetSEAMLESS_BASE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS_BASE = i; +#ifdef _DEBUG + m_bSEAMLESS_BASE = true; +#endif + } + void SetSEAMLESS_BASE( bool i ) + { + m_nSEAMLESS_BASE = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS_BASE = true; +#endif + } +private: + int m_nSEAMLESS_DETAIL; +#ifdef _DEBUG + bool m_bSEAMLESS_DETAIL; +#endif +public: + void SetSEAMLESS_DETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS_DETAIL = i; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = true; +#endif + } + void SetSEAMLESS_DETAIL( bool i ) + { + m_nSEAMLESS_DETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = true; +#endif + } +private: + int m_nSEPARATE_DETAIL_UVS; +#ifdef _DEBUG + bool m_bSEPARATE_DETAIL_UVS; +#endif +public: + void SetSEPARATE_DETAIL_UVS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEPARATE_DETAIL_UVS = i; +#ifdef _DEBUG + m_bSEPARATE_DETAIL_UVS = true; +#endif + } + void SetSEPARATE_DETAIL_UVS( bool i ) + { + m_nSEPARATE_DETAIL_UVS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEPARATE_DETAIL_UVS = true; +#endif + } +private: + int m_nUSE_STATIC_CONTROL_FLOW; +#ifdef _DEBUG + bool m_bUSE_STATIC_CONTROL_FLOW; +#endif +public: + void SetUSE_STATIC_CONTROL_FLOW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nUSE_STATIC_CONTROL_FLOW = i; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } + void SetUSE_STATIC_CONTROL_FLOW( bool i ) + { + m_nUSE_STATIC_CONTROL_FLOW = i ? 1 : 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } +private: + int m_nDONT_GAMMA_CONVERT_VERTEX_COLOR; +#ifdef _DEBUG + bool m_bDONT_GAMMA_CONVERT_VERTEX_COLOR; +#endif +public: + void SetDONT_GAMMA_CONVERT_VERTEX_COLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDONT_GAMMA_CONVERT_VERTEX_COLOR = i; +#ifdef _DEBUG + m_bDONT_GAMMA_CONVERT_VERTEX_COLOR = true; +#endif + } + void SetDONT_GAMMA_CONVERT_VERTEX_COLOR( bool i ) + { + m_nDONT_GAMMA_CONVERT_VERTEX_COLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bDONT_GAMMA_CONVERT_VERTEX_COLOR = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bSEAMLESS_BASE = false; +#endif // _DEBUG + m_nSEAMLESS_BASE = 0; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = false; +#endif // _DEBUG + m_nSEAMLESS_DETAIL = 0; +#ifdef _DEBUG + m_bSEPARATE_DETAIL_UVS = false; +#endif // _DEBUG + m_nSEPARATE_DETAIL_UVS = 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = false; +#endif // _DEBUG + m_nUSE_STATIC_CONTROL_FLOW = 0; +#ifdef _DEBUG + m_bDONT_GAMMA_CONVERT_VERTEX_COLOR = false; +#endif // _DEBUG + m_nDONT_GAMMA_CONVERT_VERTEX_COLOR = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bVERTEXCOLOR && m_bCUBEMAP && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bSEPARATE_DETAIL_UVS && m_bUSE_STATIC_CONTROL_FLOW && m_bDONT_GAMMA_CONVERT_VERTEX_COLOR; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 192 * m_nVERTEXCOLOR ) + ( 384 * m_nCUBEMAP ) + ( 768 * m_nHALFLAMBERT ) + ( 1536 * m_nFLASHLIGHT ) + ( 3072 * m_nSEAMLESS_BASE ) + ( 6144 * m_nSEAMLESS_DETAIL ) + ( 12288 * m_nSEPARATE_DETAIL_UVS ) + ( 24576 * m_nUSE_STATIC_CONTROL_FLOW ) + ( 49152 * m_nDONT_GAMMA_CONVERT_VERTEX_COLOR ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_vs20 vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_CUBEMAP + vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_FLASHLIGHT + vsh_forgot_to_set_static_SEAMLESS_BASE + vsh_forgot_to_set_static_SEAMLESS_DETAIL + vsh_forgot_to_set_static_SEPARATE_DETAIL_UVS + vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + vsh_forgot_to_set_static_DONT_GAMMA_CONVERT_VERTEX_COLOR + 0 +class sdk_vertexlit_and_unlit_generic_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDYNAMIC_LIGHT; +#ifdef _DEBUG + bool m_bDYNAMIC_LIGHT; +#endif +public: + void SetDYNAMIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDYNAMIC_LIGHT = i; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } + void SetDYNAMIC_LIGHT( bool i ) + { + m_nDYNAMIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = false; +#endif // _DEBUG + m_nDYNAMIC_LIGHT = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDYNAMIC_LIGHT && m_bSTATIC_LIGHT && m_bDOWATERFOG && m_bSKINNING && m_bLIGHTING_PREVIEW && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDYNAMIC_LIGHT ) + ( 4 * m_nSTATIC_LIGHT ) + ( 8 * m_nDOWATERFOG ) + ( 16 * m_nSKINNING ) + ( 32 * m_nLIGHTING_PREVIEW ) + ( 64 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_and_unlit_generic_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DYNAMIC_LIGHT + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_LIGHTING_PREVIEW + vsh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_vs30.inc new file mode 100644 index 00000000..d0e8ef40 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_and_unlit_generic_vs30.inc @@ -0,0 +1,462 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_and_unlit_generic_vs30_Static_Index +{ +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nSEAMLESS_BASE; +#ifdef _DEBUG + bool m_bSEAMLESS_BASE; +#endif +public: + void SetSEAMLESS_BASE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS_BASE = i; +#ifdef _DEBUG + m_bSEAMLESS_BASE = true; +#endif + } + void SetSEAMLESS_BASE( bool i ) + { + m_nSEAMLESS_BASE = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS_BASE = true; +#endif + } +private: + int m_nSEAMLESS_DETAIL; +#ifdef _DEBUG + bool m_bSEAMLESS_DETAIL; +#endif +public: + void SetSEAMLESS_DETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS_DETAIL = i; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = true; +#endif + } + void SetSEAMLESS_DETAIL( bool i ) + { + m_nSEAMLESS_DETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = true; +#endif + } +private: + int m_nSEPARATE_DETAIL_UVS; +#ifdef _DEBUG + bool m_bSEPARATE_DETAIL_UVS; +#endif +public: + void SetSEPARATE_DETAIL_UVS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEPARATE_DETAIL_UVS = i; +#ifdef _DEBUG + m_bSEPARATE_DETAIL_UVS = true; +#endif + } + void SetSEPARATE_DETAIL_UVS( bool i ) + { + m_nSEPARATE_DETAIL_UVS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEPARATE_DETAIL_UVS = true; +#endif + } +private: + int m_nDECAL; +#ifdef _DEBUG + bool m_bDECAL; +#endif +public: + void SetDECAL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDECAL = i; +#ifdef _DEBUG + m_bDECAL = true; +#endif + } + void SetDECAL( bool i ) + { + m_nDECAL = i ? 1 : 0; +#ifdef _DEBUG + m_bDECAL = true; +#endif + } +private: + int m_nSM30_VERTEXID; +#ifdef _DEBUG + bool m_bSM30_VERTEXID; +#endif +public: + void SetSM30_VERTEXID( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSM30_VERTEXID = i; +#ifdef _DEBUG + m_bSM30_VERTEXID = true; +#endif + } + void SetSM30_VERTEXID( bool i ) + { + m_nSM30_VERTEXID = i ? 1 : 0; +#ifdef _DEBUG + m_bSM30_VERTEXID = true; +#endif + } +private: + int m_nDONT_GAMMA_CONVERT_VERTEX_COLOR; +#ifdef _DEBUG + bool m_bDONT_GAMMA_CONVERT_VERTEX_COLOR; +#endif +public: + void SetDONT_GAMMA_CONVERT_VERTEX_COLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDONT_GAMMA_CONVERT_VERTEX_COLOR = i; +#ifdef _DEBUG + m_bDONT_GAMMA_CONVERT_VERTEX_COLOR = true; +#endif + } + void SetDONT_GAMMA_CONVERT_VERTEX_COLOR( bool i ) + { + m_nDONT_GAMMA_CONVERT_VERTEX_COLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bDONT_GAMMA_CONVERT_VERTEX_COLOR = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bSEAMLESS_BASE = false; +#endif // _DEBUG + m_nSEAMLESS_BASE = 0; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = false; +#endif // _DEBUG + m_nSEAMLESS_DETAIL = 0; +#ifdef _DEBUG + m_bSEPARATE_DETAIL_UVS = false; +#endif // _DEBUG + m_nSEPARATE_DETAIL_UVS = 0; +#ifdef _DEBUG + m_bDECAL = false; +#endif // _DEBUG + m_nDECAL = 0; +#ifdef _DEBUG + m_bSM30_VERTEXID = false; +#endif // _DEBUG + m_nSM30_VERTEXID = 0; +#ifdef _DEBUG + m_bDONT_GAMMA_CONVERT_VERTEX_COLOR = false; +#endif // _DEBUG + m_nDONT_GAMMA_CONVERT_VERTEX_COLOR = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bVERTEXCOLOR && m_bCUBEMAP && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bSEPARATE_DETAIL_UVS && m_bDECAL && m_bSM30_VERTEXID && m_bDONT_GAMMA_CONVERT_VERTEX_COLOR; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 128 * m_nVERTEXCOLOR ) + ( 256 * m_nCUBEMAP ) + ( 512 * m_nHALFLAMBERT ) + ( 1024 * m_nFLASHLIGHT ) + ( 2048 * m_nSEAMLESS_BASE ) + ( 4096 * m_nSEAMLESS_DETAIL ) + ( 8192 * m_nSEPARATE_DETAIL_UVS ) + ( 16384 * m_nDECAL ) + ( 32768 * m_nSM30_VERTEXID ) + ( 65536 * m_nDONT_GAMMA_CONVERT_VERTEX_COLOR ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_vs30 vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_CUBEMAP + vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_FLASHLIGHT + vsh_forgot_to_set_static_SEAMLESS_BASE + vsh_forgot_to_set_static_SEAMLESS_DETAIL + vsh_forgot_to_set_static_SEPARATE_DETAIL_UVS + vsh_forgot_to_set_static_DECAL + vsh_forgot_to_set_static_SM30_VERTEXID + vsh_forgot_to_set_static_DONT_GAMMA_CONVERT_VERTEX_COLOR + 0 +class sdk_vertexlit_and_unlit_generic_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDYNAMIC_LIGHT; +#ifdef _DEBUG + bool m_bDYNAMIC_LIGHT; +#endif +public: + void SetDYNAMIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDYNAMIC_LIGHT = i; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } + void SetDYNAMIC_LIGHT( bool i ) + { + m_nDYNAMIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = false; +#endif // _DEBUG + m_nDYNAMIC_LIGHT = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDYNAMIC_LIGHT && m_bSTATIC_LIGHT && m_bDOWATERFOG && m_bSKINNING && m_bLIGHTING_PREVIEW && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDYNAMIC_LIGHT ) + ( 4 * m_nSTATIC_LIGHT ) + ( 8 * m_nDOWATERFOG ) + ( 16 * m_nSKINNING ) + ( 32 * m_nLIGHTING_PREVIEW ) + ( 64 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_and_unlit_generic_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DYNAMIC_LIGHT + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_LIGHTING_PREVIEW + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_lighting_only_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_lighting_only_ps20.inc new file mode 100644 index 00000000..365fb68e --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_lighting_only_ps20.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_lighting_only_ps20_Static_Index +{ +private: + int m_nDIFFUSELIGHTING; +#ifdef _DEBUG + bool m_bDIFFUSELIGHTING; +#endif +public: + void SetDIFFUSELIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSELIGHTING = i; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } + void SetDIFFUSELIGHTING( bool i ) + { + m_nDIFFUSELIGHTING = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +public: + sdk_vertexlit_lighting_only_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bDIFFUSELIGHTING = false; +#endif // _DEBUG + m_nDIFFUSELIGHTING = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bDIFFUSELIGHTING && m_bHALFLAMBERT; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 6 * m_nDIFFUSELIGHTING ) + ( 12 * m_nHALFLAMBERT ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_lighting_only_ps20 psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_HALFLAMBERT + 0 +class sdk_vertexlit_lighting_only_ps20_Dynamic_Index +{ +private: + int m_nAMBIENT_LIGHT; +#ifdef _DEBUG + bool m_bAMBIENT_LIGHT; +#endif +public: + void SetAMBIENT_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nAMBIENT_LIGHT = i; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } + void SetAMBIENT_LIGHT( bool i ) + { + m_nAMBIENT_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_vertexlit_lighting_only_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bAMBIENT_LIGHT = false; +#endif // _DEBUG + m_nAMBIENT_LIGHT = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bAMBIENT_LIGHT && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nAMBIENT_LIGHT ) + ( 2 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_lighting_only_ps20 psh_forgot_to_set_dynamic_AMBIENT_LIGHT + psh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_lighting_only_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_lighting_only_ps20b.inc new file mode 100644 index 00000000..a9d3beaa --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlit_lighting_only_ps20b.inc @@ -0,0 +1,162 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_lighting_only_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nDIFFUSELIGHTING; +#ifdef _DEBUG + bool m_bDIFFUSELIGHTING; +#endif +public: + void SetDIFFUSELIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSELIGHTING = i; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } + void SetDIFFUSELIGHTING( bool i ) + { + m_nDIFFUSELIGHTING = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +public: + sdk_vertexlit_lighting_only_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bDIFFUSELIGHTING = false; +#endif // _DEBUG + m_nDIFFUSELIGHTING = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bDIFFUSELIGHTING && m_bHALFLAMBERT; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 10 * m_nCONVERT_TO_SRGB ) + ( 20 * m_nDIFFUSELIGHTING ) + ( 40 * m_nHALFLAMBERT ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_lighting_only_ps20b psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_HALFLAMBERT + 0 +class sdk_vertexlit_lighting_only_ps20b_Dynamic_Index +{ +private: + int m_nAMBIENT_LIGHT; +#ifdef _DEBUG + bool m_bAMBIENT_LIGHT; +#endif +public: + void SetAMBIENT_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nAMBIENT_LIGHT = i; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } + void SetAMBIENT_LIGHT( bool i ) + { + m_nAMBIENT_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_vertexlit_lighting_only_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bAMBIENT_LIGHT = false; +#endif // _DEBUG + m_nAMBIENT_LIGHT = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bAMBIENT_LIGHT && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nAMBIENT_LIGHT ) + ( 2 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_lighting_only_ps20b psh_forgot_to_set_dynamic_AMBIENT_LIGHT + psh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlitgeneric_lightingonly_overbright2_ps11.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlitgeneric_lightingonly_overbright2_ps11.inc new file mode 100644 index 00000000..9f9d2b41 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_vertexlitgeneric_lightingonly_overbright2_ps11.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlitgeneric_lightingonly_overbright2_ps11_Static_Index +{ +public: + sdk_vertexlitgeneric_lightingonly_overbright2_ps11_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_vertexlitgeneric_lightingonly_overbright2_ps11 0 +class sdk_vertexlitgeneric_lightingonly_overbright2_ps11_Dynamic_Index +{ +public: + sdk_vertexlitgeneric_lightingonly_overbright2_ps11_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_vertexlitgeneric_lightingonly_overbright2_ps11 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_worldtwotextureblend_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_worldtwotextureblend_ps20.inc new file mode 100644 index 00000000..eeef1cae --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_worldtwotextureblend_ps20.inc @@ -0,0 +1,287 @@ +#include "shaderlib/cshader.h" +class sdk_worldtwotextureblend_ps20_Static_Index +{ +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nDIFFUSEBUMPMAP; +#ifdef _DEBUG + bool m_bDIFFUSEBUMPMAP; +#endif +public: + void SetDIFFUSEBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSEBUMPMAP = i; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } + void SetDIFFUSEBUMPMAP( bool i ) + { + m_nDIFFUSEBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } +private: + int m_nDETAIL_ALPHA_MASK_BASE_TEXTURE; +#ifdef _DEBUG + bool m_bDETAIL_ALPHA_MASK_BASE_TEXTURE; +#endif +public: + void SetDETAIL_ALPHA_MASK_BASE_TEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL_ALPHA_MASK_BASE_TEXTURE = i; +#ifdef _DEBUG + m_bDETAIL_ALPHA_MASK_BASE_TEXTURE = true; +#endif + } + void SetDETAIL_ALPHA_MASK_BASE_TEXTURE( bool i ) + { + m_nDETAIL_ALPHA_MASK_BASE_TEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_ALPHA_MASK_BASE_TEXTURE = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +public: + sdk_worldtwotextureblend_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = false; +#endif // _DEBUG + m_nDIFFUSEBUMPMAP = 0; +#ifdef _DEBUG + m_bDETAIL_ALPHA_MASK_BASE_TEXTURE = false; +#endif // _DEBUG + m_nDETAIL_ALPHA_MASK_BASE_TEXTURE = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bDETAILTEXTURE && m_bBUMPMAP && m_bVERTEXCOLOR && m_bSELFILLUM && m_bDIFFUSEBUMPMAP && m_bDETAIL_ALPHA_MASK_BASE_TEXTURE && m_bFLASHLIGHT && m_bSEAMLESS; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nDETAILTEXTURE ) + ( 8 * m_nBUMPMAP ) + ( 16 * m_nVERTEXCOLOR ) + ( 32 * m_nSELFILLUM ) + ( 64 * m_nDIFFUSEBUMPMAP ) + ( 128 * m_nDETAIL_ALPHA_MASK_BASE_TEXTURE ) + ( 256 * m_nFLASHLIGHT ) + ( 512 * m_nSEAMLESS ) + 0; + } +}; +#define shaderStaticTest_sdk_worldtwotextureblend_ps20 psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_BUMPMAP + psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_DIFFUSEBUMPMAP + psh_forgot_to_set_static_DETAIL_ALPHA_MASK_BASE_TEXTURE + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_SEAMLESS + 0 +class sdk_worldtwotextureblend_ps20_Dynamic_Index +{ +private: + int m_nWRITEWATERFOGTODESTALPHA; +#ifdef _DEBUG + bool m_bWRITEWATERFOGTODESTALPHA; +#endif +public: + void SetWRITEWATERFOGTODESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITEWATERFOGTODESTALPHA = i; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } + void SetWRITEWATERFOGTODESTALPHA( bool i ) + { + m_nWRITEWATERFOGTODESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_worldtwotextureblend_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = false; +#endif // _DEBUG + m_nWRITEWATERFOGTODESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bWRITEWATERFOGTODESTALPHA && m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nWRITEWATERFOGTODESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_worldtwotextureblend_ps20 psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_worldtwotextureblend_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_worldtwotextureblend_ps20b.inc new file mode 100644 index 00000000..5663a738 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_worldtwotextureblend_ps20b.inc @@ -0,0 +1,387 @@ +#include "shaderlib/cshader.h" +class sdk_worldtwotextureblend_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nDIFFUSEBUMPMAP; +#ifdef _DEBUG + bool m_bDIFFUSEBUMPMAP; +#endif +public: + void SetDIFFUSEBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSEBUMPMAP = i; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } + void SetDIFFUSEBUMPMAP( bool i ) + { + m_nDIFFUSEBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } +private: + int m_nDETAIL_ALPHA_MASK_BASE_TEXTURE; +#ifdef _DEBUG + bool m_bDETAIL_ALPHA_MASK_BASE_TEXTURE; +#endif +public: + void SetDETAIL_ALPHA_MASK_BASE_TEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL_ALPHA_MASK_BASE_TEXTURE = i; +#ifdef _DEBUG + m_bDETAIL_ALPHA_MASK_BASE_TEXTURE = true; +#endif + } + void SetDETAIL_ALPHA_MASK_BASE_TEXTURE( bool i ) + { + m_nDETAIL_ALPHA_MASK_BASE_TEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_ALPHA_MASK_BASE_TEXTURE = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_worldtwotextureblend_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = false; +#endif // _DEBUG + m_nDIFFUSEBUMPMAP = 0; +#ifdef _DEBUG + m_bDETAIL_ALPHA_MASK_BASE_TEXTURE = false; +#endif // _DEBUG + m_nDETAIL_ALPHA_MASK_BASE_TEXTURE = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bDETAILTEXTURE && m_bBUMPMAP && m_bVERTEXCOLOR && m_bSELFILLUM && m_bDIFFUSEBUMPMAP && m_bDETAIL_ALPHA_MASK_BASE_TEXTURE && m_bFLASHLIGHT && m_bSEAMLESS && m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 16 * m_nCONVERT_TO_SRGB ) + ( 32 * m_nDETAILTEXTURE ) + ( 64 * m_nBUMPMAP ) + ( 128 * m_nVERTEXCOLOR ) + ( 256 * m_nSELFILLUM ) + ( 512 * m_nDIFFUSEBUMPMAP ) + ( 1024 * m_nDETAIL_ALPHA_MASK_BASE_TEXTURE ) + ( 2048 * m_nFLASHLIGHT ) + ( 4096 * m_nSEAMLESS ) + ( 8192 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_worldtwotextureblend_ps20b psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_BUMPMAP + psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_DIFFUSEBUMPMAP + psh_forgot_to_set_static_DETAIL_ALPHA_MASK_BASE_TEXTURE + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_worldtwotextureblend_ps20b_Dynamic_Index +{ +private: + int m_nWRITEWATERFOGTODESTALPHA; +#ifdef _DEBUG + bool m_bWRITEWATERFOGTODESTALPHA; +#endif +public: + void SetWRITEWATERFOGTODESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITEWATERFOGTODESTALPHA = i; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } + void SetWRITEWATERFOGTODESTALPHA( bool i ) + { + m_nWRITEWATERFOGTODESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_worldtwotextureblend_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = false; +#endif // _DEBUG + m_nWRITEWATERFOGTODESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bWRITEWATERFOGTODESTALPHA && m_bPIXELFOGTYPE && m_bWRITE_DEPTH_TO_DESTALPHA && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nWRITEWATERFOGTODESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + ( 4 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 8 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_worldtwotextureblend_ps20b psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_Bloom_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_Bloom_ps20.inc new file mode 100644 index 00000000..afbca75f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_Bloom_ps20.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_bloom_ps20_Static_Index +{ +public: + sdk_bloom_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_bloom_ps20 0 +class sdk_bloom_ps20_Dynamic_Index +{ +public: + sdk_bloom_ps20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_bloom_ps20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_Bloom_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_Bloom_ps20b.inc new file mode 100644 index 00000000..169870ee --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_Bloom_ps20b.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_bloom_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_bloom_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_bloom_ps20b 0 +class sdk_bloom_ps20b_Dynamic_Index +{ +public: + sdk_bloom_ps20b_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_bloom_ps20b 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_Refract_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_Refract_vs20.inc new file mode 100644 index 00000000..58adb397 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_Refract_vs20.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_refract_vs20_Static_Index +{ +private: + int m_nMODEL; +#ifdef _DEBUG + bool m_bMODEL; +#endif +public: + void SetMODEL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMODEL = i; +#ifdef _DEBUG + m_bMODEL = true; +#endif + } + void SetMODEL( bool i ) + { + m_nMODEL = i ? 1 : 0; +#ifdef _DEBUG + m_bMODEL = true; +#endif + } +private: + int m_nCOLORMODULATE; +#ifdef _DEBUG + bool m_bCOLORMODULATE; +#endif +public: + void SetCOLORMODULATE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOLORMODULATE = i; +#ifdef _DEBUG + m_bCOLORMODULATE = true; +#endif + } + void SetCOLORMODULATE( bool i ) + { + m_nCOLORMODULATE = i ? 1 : 0; +#ifdef _DEBUG + m_bCOLORMODULATE = true; +#endif + } +public: + sdk_refract_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bMODEL = false; +#endif // _DEBUG + m_nMODEL = 0; +#ifdef _DEBUG + m_bCOLORMODULATE = false; +#endif // _DEBUG + m_nCOLORMODULATE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bMODEL && m_bCOLORMODULATE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nMODEL ) + ( 8 * m_nCOLORMODULATE ) + 0; + } +}; +#define shaderStaticTest_sdk_refract_vs20 vsh_forgot_to_set_static_MODEL + vsh_forgot_to_set_static_COLORMODULATE + 0 +class sdk_refract_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_refract_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + 0; + } +}; +#define shaderDynamicTest_sdk_refract_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_WaterCheap_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_WaterCheap_ps20.inc new file mode 100644 index 00000000..49475ba9 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_WaterCheap_ps20.inc @@ -0,0 +1,237 @@ +#include "shaderlib/cshader.h" +class sdk_watercheap_ps20_Static_Index +{ +private: + int m_nMULTITEXTURE; +#ifdef _DEBUG + bool m_bMULTITEXTURE; +#endif +public: + void SetMULTITEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMULTITEXTURE = i; +#ifdef _DEBUG + m_bMULTITEXTURE = true; +#endif + } + void SetMULTITEXTURE( bool i ) + { + m_nMULTITEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bMULTITEXTURE = true; +#endif + } +private: + int m_nFRESNEL; +#ifdef _DEBUG + bool m_bFRESNEL; +#endif +public: + void SetFRESNEL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFRESNEL = i; +#ifdef _DEBUG + m_bFRESNEL = true; +#endif + } + void SetFRESNEL( bool i ) + { + m_nFRESNEL = i ? 1 : 0; +#ifdef _DEBUG + m_bFRESNEL = true; +#endif + } +private: + int m_nBLEND; +#ifdef _DEBUG + bool m_bBLEND; +#endif +public: + void SetBLEND( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLEND = i; +#ifdef _DEBUG + m_bBLEND = true; +#endif + } + void SetBLEND( bool i ) + { + m_nBLEND = i ? 1 : 0; +#ifdef _DEBUG + m_bBLEND = true; +#endif + } +private: + int m_nREFRACTALPHA; +#ifdef _DEBUG + bool m_bREFRACTALPHA; +#endif +public: + void SetREFRACTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFRACTALPHA = i; +#ifdef _DEBUG + m_bREFRACTALPHA = true; +#endif + } + void SetREFRACTALPHA( bool i ) + { + m_nREFRACTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bREFRACTALPHA = true; +#endif + } +private: + int m_nHDRTYPE; +#ifdef _DEBUG + bool m_bHDRTYPE; +#endif +public: + void SetHDRTYPE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nHDRTYPE = i; +#ifdef _DEBUG + m_bHDRTYPE = true; +#endif + } + void SetHDRTYPE( bool i ) + { + m_nHDRTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bHDRTYPE = true; +#endif + } +private: + int m_nNORMAL_DECODE_MODE; +#ifdef _DEBUG + bool m_bNORMAL_DECODE_MODE; +#endif +public: + void SetNORMAL_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMAL_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } + void SetNORMAL_DECODE_MODE( bool i ) + { + m_nNORMAL_DECODE_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } +public: + sdk_watercheap_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bMULTITEXTURE = false; +#endif // _DEBUG + m_nMULTITEXTURE = 0; +#ifdef _DEBUG + m_bFRESNEL = false; +#endif // _DEBUG + m_nFRESNEL = 0; +#ifdef _DEBUG + m_bBLEND = false; +#endif // _DEBUG + m_nBLEND = 0; +#ifdef _DEBUG + m_bREFRACTALPHA = false; +#endif // _DEBUG + m_nREFRACTALPHA = 0; +#ifdef _DEBUG + m_bHDRTYPE = false; +#endif // _DEBUG + m_nHDRTYPE = 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = false; +#endif // _DEBUG + m_nNORMAL_DECODE_MODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bMULTITEXTURE && m_bFRESNEL && m_bBLEND && m_bREFRACTALPHA && m_bHDRTYPE && m_bNORMAL_DECODE_MODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nMULTITEXTURE ) + ( 8 * m_nFRESNEL ) + ( 16 * m_nBLEND ) + ( 32 * m_nREFRACTALPHA ) + ( 64 * m_nHDRTYPE ) + ( 192 * m_nNORMAL_DECODE_MODE ) + 0; + } +}; +#define shaderStaticTest_sdk_watercheap_ps20 psh_forgot_to_set_static_MULTITEXTURE + psh_forgot_to_set_static_FRESNEL + psh_forgot_to_set_static_BLEND + psh_forgot_to_set_static_REFRACTALPHA + psh_forgot_to_set_static_HDRTYPE + psh_forgot_to_set_static_NORMAL_DECODE_MODE + 0 +class sdk_watercheap_ps20_Dynamic_Index +{ +private: + int m_nHDRENABLED; +#ifdef _DEBUG + bool m_bHDRENABLED; +#endif +public: + void SetHDRENABLED( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHDRENABLED = i; +#ifdef _DEBUG + m_bHDRENABLED = true; +#endif + } + void SetHDRENABLED( bool i ) + { + m_nHDRENABLED = i ? 1 : 0; +#ifdef _DEBUG + m_bHDRENABLED = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_watercheap_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bHDRENABLED = false; +#endif // _DEBUG + m_nHDRENABLED = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bHDRENABLED && m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nHDRENABLED ) + ( 2 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_watercheap_ps20 psh_forgot_to_set_dynamic_HDRENABLED + psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_WaterCheap_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_WaterCheap_ps20b.inc new file mode 100644 index 00000000..6ddfc76f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_WaterCheap_ps20b.inc @@ -0,0 +1,262 @@ +#include "shaderlib/cshader.h" +class sdk_watercheap_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nMULTITEXTURE; +#ifdef _DEBUG + bool m_bMULTITEXTURE; +#endif +public: + void SetMULTITEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMULTITEXTURE = i; +#ifdef _DEBUG + m_bMULTITEXTURE = true; +#endif + } + void SetMULTITEXTURE( bool i ) + { + m_nMULTITEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bMULTITEXTURE = true; +#endif + } +private: + int m_nFRESNEL; +#ifdef _DEBUG + bool m_bFRESNEL; +#endif +public: + void SetFRESNEL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFRESNEL = i; +#ifdef _DEBUG + m_bFRESNEL = true; +#endif + } + void SetFRESNEL( bool i ) + { + m_nFRESNEL = i ? 1 : 0; +#ifdef _DEBUG + m_bFRESNEL = true; +#endif + } +private: + int m_nBLEND; +#ifdef _DEBUG + bool m_bBLEND; +#endif +public: + void SetBLEND( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLEND = i; +#ifdef _DEBUG + m_bBLEND = true; +#endif + } + void SetBLEND( bool i ) + { + m_nBLEND = i ? 1 : 0; +#ifdef _DEBUG + m_bBLEND = true; +#endif + } +private: + int m_nREFRACTALPHA; +#ifdef _DEBUG + bool m_bREFRACTALPHA; +#endif +public: + void SetREFRACTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFRACTALPHA = i; +#ifdef _DEBUG + m_bREFRACTALPHA = true; +#endif + } + void SetREFRACTALPHA( bool i ) + { + m_nREFRACTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bREFRACTALPHA = true; +#endif + } +private: + int m_nHDRTYPE; +#ifdef _DEBUG + bool m_bHDRTYPE; +#endif +public: + void SetHDRTYPE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nHDRTYPE = i; +#ifdef _DEBUG + m_bHDRTYPE = true; +#endif + } + void SetHDRTYPE( bool i ) + { + m_nHDRTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bHDRTYPE = true; +#endif + } +private: + int m_nNORMAL_DECODE_MODE; +#ifdef _DEBUG + bool m_bNORMAL_DECODE_MODE; +#endif +public: + void SetNORMAL_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMAL_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } + void SetNORMAL_DECODE_MODE( bool i ) + { + m_nNORMAL_DECODE_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } +public: + sdk_watercheap_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bMULTITEXTURE = false; +#endif // _DEBUG + m_nMULTITEXTURE = 0; +#ifdef _DEBUG + m_bFRESNEL = false; +#endif // _DEBUG + m_nFRESNEL = 0; +#ifdef _DEBUG + m_bBLEND = false; +#endif // _DEBUG + m_nBLEND = 0; +#ifdef _DEBUG + m_bREFRACTALPHA = false; +#endif // _DEBUG + m_nREFRACTALPHA = 0; +#ifdef _DEBUG + m_bHDRTYPE = false; +#endif // _DEBUG + m_nHDRTYPE = 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = false; +#endif // _DEBUG + m_nNORMAL_DECODE_MODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bMULTITEXTURE && m_bFRESNEL && m_bBLEND && m_bREFRACTALPHA && m_bHDRTYPE && m_bNORMAL_DECODE_MODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nCONVERT_TO_SRGB ) + ( 8 * m_nMULTITEXTURE ) + ( 16 * m_nFRESNEL ) + ( 32 * m_nBLEND ) + ( 64 * m_nREFRACTALPHA ) + ( 128 * m_nHDRTYPE ) + ( 384 * m_nNORMAL_DECODE_MODE ) + 0; + } +}; +#define shaderStaticTest_sdk_watercheap_ps20b psh_forgot_to_set_static_MULTITEXTURE + psh_forgot_to_set_static_FRESNEL + psh_forgot_to_set_static_BLEND + psh_forgot_to_set_static_REFRACTALPHA + psh_forgot_to_set_static_HDRTYPE + psh_forgot_to_set_static_NORMAL_DECODE_MODE + 0 +class sdk_watercheap_ps20b_Dynamic_Index +{ +private: + int m_nHDRENABLED; +#ifdef _DEBUG + bool m_bHDRENABLED; +#endif +public: + void SetHDRENABLED( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHDRENABLED = i; +#ifdef _DEBUG + m_bHDRENABLED = true; +#endif + } + void SetHDRENABLED( bool i ) + { + m_nHDRENABLED = i ? 1 : 0; +#ifdef _DEBUG + m_bHDRENABLED = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_watercheap_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bHDRENABLED = false; +#endif // _DEBUG + m_nHDRENABLED = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bHDRENABLED && m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nHDRENABLED ) + ( 2 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_watercheap_ps20b psh_forgot_to_set_dynamic_HDRENABLED + psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_WaterCheap_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_WaterCheap_vs20.inc new file mode 100644 index 00000000..49244f88 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_WaterCheap_vs20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_watercheap_vs20_Static_Index +{ +private: + int m_nBLEND; +#ifdef _DEBUG + bool m_bBLEND; +#endif +public: + void SetBLEND( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLEND = i; +#ifdef _DEBUG + m_bBLEND = true; +#endif + } + void SetBLEND( bool i ) + { + m_nBLEND = i ? 1 : 0; +#ifdef _DEBUG + m_bBLEND = true; +#endif + } +public: + sdk_watercheap_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bBLEND = false; +#endif // _DEBUG + m_nBLEND = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bBLEND; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nBLEND ) + 0; + } +}; +#define shaderStaticTest_sdk_watercheap_vs20 vsh_forgot_to_set_static_BLEND + 0 +class sdk_watercheap_vs20_Dynamic_Index +{ +public: + sdk_watercheap_vs20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_watercheap_vs20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_Water_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_Water_ps20.inc new file mode 100644 index 00000000..4929b59c --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_Water_ps20.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_water_ps20_Static_Index +{ +private: + int m_nBASETEXTURE; +#ifdef _DEBUG + bool m_bBASETEXTURE; +#endif +public: + void SetBASETEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE = i; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } + void SetBASETEXTURE( bool i ) + { + m_nBASETEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } +private: + int m_nMULTITEXTURE; +#ifdef _DEBUG + bool m_bMULTITEXTURE; +#endif +public: + void SetMULTITEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMULTITEXTURE = i; +#ifdef _DEBUG + m_bMULTITEXTURE = true; +#endif + } + void SetMULTITEXTURE( bool i ) + { + m_nMULTITEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bMULTITEXTURE = true; +#endif + } +private: + int m_nREFLECT; +#ifdef _DEBUG + bool m_bREFLECT; +#endif +public: + void SetREFLECT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFLECT = i; +#ifdef _DEBUG + m_bREFLECT = true; +#endif + } + void SetREFLECT( bool i ) + { + m_nREFLECT = i ? 1 : 0; +#ifdef _DEBUG + m_bREFLECT = true; +#endif + } +private: + int m_nREFRACT; +#ifdef _DEBUG + bool m_bREFRACT; +#endif +public: + void SetREFRACT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFRACT = i; +#ifdef _DEBUG + m_bREFRACT = true; +#endif + } + void SetREFRACT( bool i ) + { + m_nREFRACT = i ? 1 : 0; +#ifdef _DEBUG + m_bREFRACT = true; +#endif + } +private: + int m_nABOVEWATER; +#ifdef _DEBUG + bool m_bABOVEWATER; +#endif +public: + void SetABOVEWATER( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nABOVEWATER = i; +#ifdef _DEBUG + m_bABOVEWATER = true; +#endif + } + void SetABOVEWATER( bool i ) + { + m_nABOVEWATER = i ? 1 : 0; +#ifdef _DEBUG + m_bABOVEWATER = true; +#endif + } +private: + int m_nNORMAL_DECODE_MODE; +#ifdef _DEBUG + bool m_bNORMAL_DECODE_MODE; +#endif +public: + void SetNORMAL_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMAL_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } + void SetNORMAL_DECODE_MODE( bool i ) + { + m_nNORMAL_DECODE_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } +public: + sdk_water_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bBASETEXTURE = false; +#endif // _DEBUG + m_nBASETEXTURE = 0; +#ifdef _DEBUG + m_bMULTITEXTURE = false; +#endif // _DEBUG + m_nMULTITEXTURE = 0; +#ifdef _DEBUG + m_bREFLECT = false; +#endif // _DEBUG + m_nREFLECT = 0; +#ifdef _DEBUG + m_bREFRACT = false; +#endif // _DEBUG + m_nREFRACT = 0; +#ifdef _DEBUG + m_bABOVEWATER = false; +#endif // _DEBUG + m_nABOVEWATER = 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = false; +#endif // _DEBUG + m_nNORMAL_DECODE_MODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bBASETEXTURE && m_bMULTITEXTURE && m_bREFLECT && m_bREFRACT && m_bABOVEWATER && m_bNORMAL_DECODE_MODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nBASETEXTURE ) + ( 4 * m_nMULTITEXTURE ) + ( 8 * m_nREFLECT ) + ( 16 * m_nREFRACT ) + ( 32 * m_nABOVEWATER ) + ( 64 * m_nNORMAL_DECODE_MODE ) + 0; + } +}; +#define shaderStaticTest_sdk_water_ps20 psh_forgot_to_set_static_BASETEXTURE + psh_forgot_to_set_static_MULTITEXTURE + psh_forgot_to_set_static_REFLECT + psh_forgot_to_set_static_REFRACT + psh_forgot_to_set_static_ABOVEWATER + psh_forgot_to_set_static_NORMAL_DECODE_MODE + 0 +class sdk_water_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_water_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_water_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_Water_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_Water_ps20b.inc new file mode 100644 index 00000000..675efa7a --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_Water_ps20b.inc @@ -0,0 +1,287 @@ +#include "shaderlib/cshader.h" +class sdk_water_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nBASETEXTURE; +#ifdef _DEBUG + bool m_bBASETEXTURE; +#endif +public: + void SetBASETEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE = i; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } + void SetBASETEXTURE( bool i ) + { + m_nBASETEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } +private: + int m_nMULTITEXTURE; +#ifdef _DEBUG + bool m_bMULTITEXTURE; +#endif +public: + void SetMULTITEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMULTITEXTURE = i; +#ifdef _DEBUG + m_bMULTITEXTURE = true; +#endif + } + void SetMULTITEXTURE( bool i ) + { + m_nMULTITEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bMULTITEXTURE = true; +#endif + } +private: + int m_nREFLECT; +#ifdef _DEBUG + bool m_bREFLECT; +#endif +public: + void SetREFLECT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFLECT = i; +#ifdef _DEBUG + m_bREFLECT = true; +#endif + } + void SetREFLECT( bool i ) + { + m_nREFLECT = i ? 1 : 0; +#ifdef _DEBUG + m_bREFLECT = true; +#endif + } +private: + int m_nREFRACT; +#ifdef _DEBUG + bool m_bREFRACT; +#endif +public: + void SetREFRACT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFRACT = i; +#ifdef _DEBUG + m_bREFRACT = true; +#endif + } + void SetREFRACT( bool i ) + { + m_nREFRACT = i ? 1 : 0; +#ifdef _DEBUG + m_bREFRACT = true; +#endif + } +private: + int m_nABOVEWATER; +#ifdef _DEBUG + bool m_bABOVEWATER; +#endif +public: + void SetABOVEWATER( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nABOVEWATER = i; +#ifdef _DEBUG + m_bABOVEWATER = true; +#endif + } + void SetABOVEWATER( bool i ) + { + m_nABOVEWATER = i ? 1 : 0; +#ifdef _DEBUG + m_bABOVEWATER = true; +#endif + } +private: + int m_nBLURRY_REFRACT; +#ifdef _DEBUG + bool m_bBLURRY_REFRACT; +#endif +public: + void SetBLURRY_REFRACT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLURRY_REFRACT = i; +#ifdef _DEBUG + m_bBLURRY_REFRACT = true; +#endif + } + void SetBLURRY_REFRACT( bool i ) + { + m_nBLURRY_REFRACT = i ? 1 : 0; +#ifdef _DEBUG + m_bBLURRY_REFRACT = true; +#endif + } +private: + int m_nNORMAL_DECODE_MODE; +#ifdef _DEBUG + bool m_bNORMAL_DECODE_MODE; +#endif +public: + void SetNORMAL_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMAL_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } + void SetNORMAL_DECODE_MODE( bool i ) + { + m_nNORMAL_DECODE_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } +public: + sdk_water_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bBASETEXTURE = false; +#endif // _DEBUG + m_nBASETEXTURE = 0; +#ifdef _DEBUG + m_bMULTITEXTURE = false; +#endif // _DEBUG + m_nMULTITEXTURE = 0; +#ifdef _DEBUG + m_bREFLECT = false; +#endif // _DEBUG + m_nREFLECT = 0; +#ifdef _DEBUG + m_bREFRACT = false; +#endif // _DEBUG + m_nREFRACT = 0; +#ifdef _DEBUG + m_bABOVEWATER = false; +#endif // _DEBUG + m_nABOVEWATER = 0; +#ifdef _DEBUG + m_bBLURRY_REFRACT = false; +#endif // _DEBUG + m_nBLURRY_REFRACT = 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = false; +#endif // _DEBUG + m_nNORMAL_DECODE_MODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bBASETEXTURE && m_bMULTITEXTURE && m_bREFLECT && m_bREFRACT && m_bABOVEWATER && m_bBLURRY_REFRACT && m_bNORMAL_DECODE_MODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nCONVERT_TO_SRGB ) + ( 8 * m_nBASETEXTURE ) + ( 16 * m_nMULTITEXTURE ) + ( 32 * m_nREFLECT ) + ( 64 * m_nREFRACT ) + ( 128 * m_nABOVEWATER ) + ( 256 * m_nBLURRY_REFRACT ) + ( 512 * m_nNORMAL_DECODE_MODE ) + 0; + } +}; +#define shaderStaticTest_sdk_water_ps20b psh_forgot_to_set_static_BASETEXTURE + psh_forgot_to_set_static_MULTITEXTURE + psh_forgot_to_set_static_REFLECT + psh_forgot_to_set_static_REFRACT + psh_forgot_to_set_static_ABOVEWATER + psh_forgot_to_set_static_BLURRY_REFRACT + psh_forgot_to_set_static_NORMAL_DECODE_MODE + 0 +class sdk_water_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +public: + sdk_water_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bWRITE_DEPTH_TO_DESTALPHA; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + } +}; +#define shaderDynamicTest_sdk_water_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_Water_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_Water_vs20.inc new file mode 100644 index 00000000..67e8f134 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_Water_vs20.inc @@ -0,0 +1,85 @@ +#include "shaderlib/cshader.h" +class sdk_water_vs20_Static_Index +{ +private: + int m_nBASETEXTURE; +#ifdef _DEBUG + bool m_bBASETEXTURE; +#endif +public: + void SetBASETEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE = i; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } + void SetBASETEXTURE( bool i ) + { + m_nBASETEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } +private: + int m_nMULTITEXTURE; +#ifdef _DEBUG + bool m_bMULTITEXTURE; +#endif +public: + void SetMULTITEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMULTITEXTURE = i; +#ifdef _DEBUG + m_bMULTITEXTURE = true; +#endif + } + void SetMULTITEXTURE( bool i ) + { + m_nMULTITEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bMULTITEXTURE = true; +#endif + } +public: + sdk_water_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bBASETEXTURE = false; +#endif // _DEBUG + m_nBASETEXTURE = 0; +#ifdef _DEBUG + m_bMULTITEXTURE = false; +#endif // _DEBUG + m_nMULTITEXTURE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bBASETEXTURE && m_bMULTITEXTURE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nBASETEXTURE ) + ( 2 * m_nMULTITEXTURE ) + 0; + } +}; +#define shaderStaticTest_sdk_water_vs20 vsh_forgot_to_set_static_BASETEXTURE + vsh_forgot_to_set_static_MULTITEXTURE + 0 +class sdk_water_vs20_Dynamic_Index +{ +public: + sdk_water_vs20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_water_vs20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_WorldVertexTransition_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_WorldVertexTransition_ps20.inc new file mode 100644 index 00000000..67613947 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_WorldVertexTransition_ps20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_worldvertextransition_ps20_Static_Index +{ +private: + int m_nMACROS; +#ifdef _DEBUG + bool m_bMACROS; +#endif +public: + void SetMACROS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMACROS = i; +#ifdef _DEBUG + m_bMACROS = true; +#endif + } + void SetMACROS( bool i ) + { + m_nMACROS = i ? 1 : 0; +#ifdef _DEBUG + m_bMACROS = true; +#endif + } +public: + sdk_worldvertextransition_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bMACROS = false; +#endif // _DEBUG + m_nMACROS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bMACROS; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nMACROS ) + 0; + } +}; +#define shaderStaticTest_sdk_worldvertextransition_ps20 psh_forgot_to_set_static_MACROS + 0 +class sdk_worldvertextransition_ps20_Dynamic_Index +{ +public: + sdk_worldvertextransition_ps20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_worldvertextransition_ps20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_WorldVertexTransition_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_WorldVertexTransition_ps20b.inc new file mode 100644 index 00000000..cd00eaf5 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_WorldVertexTransition_ps20b.inc @@ -0,0 +1,85 @@ +#include "shaderlib/cshader.h" +class sdk_worldvertextransition_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nMACROS; +#ifdef _DEBUG + bool m_bMACROS; +#endif +public: + void SetMACROS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMACROS = i; +#ifdef _DEBUG + m_bMACROS = true; +#endif + } + void SetMACROS( bool i ) + { + m_nMACROS = i ? 1 : 0; +#ifdef _DEBUG + m_bMACROS = true; +#endif + } +public: + sdk_worldvertextransition_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bMACROS = false; +#endif // _DEBUG + m_nMACROS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bMACROS; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCONVERT_TO_SRGB ) + ( 2 * m_nMACROS ) + 0; + } +}; +#define shaderStaticTest_sdk_worldvertextransition_ps20b psh_forgot_to_set_static_MACROS + 0 +class sdk_worldvertextransition_ps20b_Dynamic_Index +{ +public: + sdk_worldvertextransition_ps20b_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_worldvertextransition_ps20b 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_WorldVertexTransition_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_WorldVertexTransition_vs20.inc new file mode 100644 index 00000000..fbf30e08 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_WorldVertexTransition_vs20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_worldvertextransition_vs20_Static_Index +{ +public: + sdk_worldvertextransition_vs20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_worldvertextransition_vs20 0 +class sdk_worldvertextransition_vs20_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_worldvertextransition_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_worldvertextransition_vs20 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_bloomadd_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_bloomadd_ps20.inc new file mode 100644 index 00000000..c0643ebe --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_bloomadd_ps20.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_bloomadd_ps20_Static_Index +{ +public: + sdk_bloomadd_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_bloomadd_ps20 0 +class sdk_bloomadd_ps20_Dynamic_Index +{ +public: + sdk_bloomadd_ps20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_bloomadd_ps20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_bloomadd_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_bloomadd_ps20b.inc new file mode 100644 index 00000000..861e517b --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_bloomadd_ps20b.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_bloomadd_ps20b_Static_Index +{ +public: + sdk_bloomadd_ps20b_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_bloomadd_ps20b 0 +class sdk_bloomadd_ps20b_Dynamic_Index +{ +public: + sdk_bloomadd_ps20b_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_bloomadd_ps20b 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cable_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cable_ps20.inc new file mode 100644 index 00000000..6d6f0122 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cable_ps20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_cable_ps20_Static_Index +{ +public: + sdk_cable_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_cable_ps20 0 +class sdk_cable_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_cable_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_cable_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cable_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cable_ps20b.inc new file mode 100644 index 00000000..0e73dbdf --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cable_ps20b.inc @@ -0,0 +1,112 @@ +#include "shaderlib/cshader.h" +class sdk_cable_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_cable_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_cable_ps20b 0 +class sdk_cable_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +public: + sdk_cable_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bWRITE_DEPTH_TO_DESTALPHA; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + } +}; +#define shaderDynamicTest_sdk_cable_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cable_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cable_vs20.inc new file mode 100644 index 00000000..d2ef4642 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cable_vs20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_cable_vs20_Static_Index +{ +public: + sdk_cable_vs20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_cable_vs20 0 +class sdk_cable_vs20_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_cable_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_cable_vs20 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cloak_blended_pass_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cloak_blended_pass_ps20.inc new file mode 100644 index 00000000..5d52f92f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cloak_blended_pass_ps20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_cloak_blended_pass_ps20_Static_Index +{ +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +public: + sdk_cloak_blended_pass_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bBUMPMAP; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nBUMPMAP ) + 0; + } +}; +#define shaderStaticTest_sdk_cloak_blended_pass_ps20 psh_forgot_to_set_static_BUMPMAP + 0 +class sdk_cloak_blended_pass_ps20_Dynamic_Index +{ +public: + sdk_cloak_blended_pass_ps20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_cloak_blended_pass_ps20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cloak_blended_pass_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cloak_blended_pass_ps20b.inc new file mode 100644 index 00000000..c724bbd2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cloak_blended_pass_ps20b.inc @@ -0,0 +1,85 @@ +#include "shaderlib/cshader.h" +class sdk_cloak_blended_pass_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +public: + sdk_cloak_blended_pass_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bBUMPMAP; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCONVERT_TO_SRGB ) + ( 2 * m_nBUMPMAP ) + 0; + } +}; +#define shaderStaticTest_sdk_cloak_blended_pass_ps20b psh_forgot_to_set_static_BUMPMAP + 0 +class sdk_cloak_blended_pass_ps20b_Dynamic_Index +{ +public: + sdk_cloak_blended_pass_ps20b_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_cloak_blended_pass_ps20b 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cloak_blended_pass_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cloak_blended_pass_ps30.inc new file mode 100644 index 00000000..778aaf04 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cloak_blended_pass_ps30.inc @@ -0,0 +1,85 @@ +#include "shaderlib/cshader.h" +class sdk_cloak_blended_pass_ps30_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +public: + sdk_cloak_blended_pass_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bBUMPMAP; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCONVERT_TO_SRGB ) + ( 2 * m_nBUMPMAP ) + 0; + } +}; +#define shaderStaticTest_sdk_cloak_blended_pass_ps30 psh_forgot_to_set_static_BUMPMAP + 0 +class sdk_cloak_blended_pass_ps30_Dynamic_Index +{ +public: + sdk_cloak_blended_pass_ps30_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_cloak_blended_pass_ps30 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cloak_blended_pass_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cloak_blended_pass_vs20.inc new file mode 100644 index 00000000..7f431299 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cloak_blended_pass_vs20.inc @@ -0,0 +1,112 @@ +#include "shaderlib/cshader.h" +class sdk_cloak_blended_pass_vs20_Static_Index +{ +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +public: + sdk_cloak_blended_pass_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bBUMPMAP; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nBUMPMAP ) + 0; + } +}; +#define shaderStaticTest_sdk_cloak_blended_pass_vs20 vsh_forgot_to_set_static_BUMPMAP + 0 +class sdk_cloak_blended_pass_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_cloak_blended_pass_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + 0; + } +}; +#define shaderDynamicTest_sdk_cloak_blended_pass_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cloak_blended_pass_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cloak_blended_pass_vs30.inc new file mode 100644 index 00000000..f3121788 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_cloak_blended_pass_vs30.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_cloak_blended_pass_vs30_Static_Index +{ +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +public: + sdk_cloak_blended_pass_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bBUMPMAP; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 8 * m_nBUMPMAP ) + 0; + } +}; +#define shaderStaticTest_sdk_cloak_blended_pass_vs30 vsh_forgot_to_set_static_BUMPMAP + 0 +class sdk_cloak_blended_pass_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_cloak_blended_pass_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_cloak_blended_pass_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_decalmodulate_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_decalmodulate_ps20.inc new file mode 100644 index 00000000..cc1e6113 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_decalmodulate_ps20.inc @@ -0,0 +1,112 @@ +#include "shaderlib/cshader.h" +class sdk_decalmodulate_ps20_Static_Index +{ +private: + int m_nVERTEXALPHA; +#ifdef _DEBUG + bool m_bVERTEXALPHA; +#endif +public: + void SetVERTEXALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXALPHA = i; +#ifdef _DEBUG + m_bVERTEXALPHA = true; +#endif + } + void SetVERTEXALPHA( bool i ) + { + m_nVERTEXALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXALPHA = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +public: + sdk_decalmodulate_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bVERTEXALPHA = false; +#endif // _DEBUG + m_nVERTEXALPHA = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bVERTEXALPHA && m_bFLASHLIGHT; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nVERTEXALPHA ) + ( 4 * m_nFLASHLIGHT ) + 0; + } +}; +#define shaderStaticTest_sdk_decalmodulate_ps20 psh_forgot_to_set_static_VERTEXALPHA + psh_forgot_to_set_static_FLASHLIGHT + 0 +class sdk_decalmodulate_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_decalmodulate_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_decalmodulate_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_decalmodulate_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_decalmodulate_ps20b.inc new file mode 100644 index 00000000..e35c8a54 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_decalmodulate_ps20b.inc @@ -0,0 +1,162 @@ +#include "shaderlib/cshader.h" +class sdk_decalmodulate_ps20b_Static_Index +{ +private: + int m_nVERTEXALPHA; +#ifdef _DEBUG + bool m_bVERTEXALPHA; +#endif +public: + void SetVERTEXALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXALPHA = i; +#ifdef _DEBUG + m_bVERTEXALPHA = true; +#endif + } + void SetVERTEXALPHA( bool i ) + { + m_nVERTEXALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXALPHA = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_decalmodulate_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bVERTEXALPHA = false; +#endif // _DEBUG + m_nVERTEXALPHA = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bVERTEXALPHA && m_bFLASHLIGHT && m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nVERTEXALPHA ) + ( 8 * m_nFLASHLIGHT ) + ( 16 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_decalmodulate_ps20b psh_forgot_to_set_static_VERTEXALPHA + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_decalmodulate_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_decalmodulate_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_decalmodulate_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_decalmodulate_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_decalmodulate_ps30.inc new file mode 100644 index 00000000..db6747a2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_decalmodulate_ps30.inc @@ -0,0 +1,162 @@ +#include "shaderlib/cshader.h" +class sdk_decalmodulate_ps30_Static_Index +{ +private: + int m_nVERTEXALPHA; +#ifdef _DEBUG + bool m_bVERTEXALPHA; +#endif +public: + void SetVERTEXALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXALPHA = i; +#ifdef _DEBUG + m_bVERTEXALPHA = true; +#endif + } + void SetVERTEXALPHA( bool i ) + { + m_nVERTEXALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXALPHA = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_decalmodulate_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bVERTEXALPHA = false; +#endif // _DEBUG + m_nVERTEXALPHA = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bVERTEXALPHA && m_bFLASHLIGHT && m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nVERTEXALPHA ) + ( 8 * m_nFLASHLIGHT ) + ( 16 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_decalmodulate_ps30 psh_forgot_to_set_static_VERTEXALPHA + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_decalmodulate_ps30_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_decalmodulate_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_decalmodulate_ps30 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_decalmodulate_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_decalmodulate_vs20.inc new file mode 100644 index 00000000..0f571fd7 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_decalmodulate_vs20.inc @@ -0,0 +1,187 @@ +#include "shaderlib/cshader.h" +class sdk_decalmodulate_vs20_Static_Index +{ +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +public: + sdk_decalmodulate_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bVERTEXCOLOR && m_bLIGHTING_PREVIEW && m_bFLASHLIGHT; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nVERTEXCOLOR ) + ( 8 * m_nLIGHTING_PREVIEW ) + ( 16 * m_nFLASHLIGHT ) + 0; + } +}; +#define shaderStaticTest_sdk_decalmodulate_vs20 vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_LIGHTING_PREVIEW + vsh_forgot_to_set_static_FLASHLIGHT + 0 +class sdk_decalmodulate_vs20_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_decalmodulate_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG && m_bCOMPRESSED_VERTS && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + ( 2 * m_nCOMPRESSED_VERTS ) + ( 4 * m_nSKINNING ) + 0; + } +}; +#define shaderDynamicTest_sdk_decalmodulate_vs20 vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_decalmodulate_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_decalmodulate_vs30.inc new file mode 100644 index 00000000..38617b8c --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_decalmodulate_vs30.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_decalmodulate_vs30_Static_Index +{ +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +public: + sdk_decalmodulate_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bVERTEXCOLOR && m_bLIGHTING_PREVIEW && m_bFLASHLIGHT; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 16 * m_nVERTEXCOLOR ) + ( 32 * m_nLIGHTING_PREVIEW ) + ( 64 * m_nFLASHLIGHT ) + 0; + } +}; +#define shaderStaticTest_sdk_decalmodulate_vs30 vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_LIGHTING_PREVIEW + vsh_forgot_to_set_static_FLASHLIGHT + 0 +class sdk_decalmodulate_vs30_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_decalmodulate_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG && m_bCOMPRESSED_VERTS && m_bSKINNING && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + ( 2 * m_nCOMPRESSED_VERTS ) + ( 4 * m_nSKINNING ) + ( 8 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_decalmodulate_vs30 vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_depthwrite_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_depthwrite_ps20.inc new file mode 100644 index 00000000..938ab9bd --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_depthwrite_ps20.inc @@ -0,0 +1,87 @@ +#include "shaderlib/cshader.h" +class sdk_depthwrite_ps20_Static_Index +{ +private: + int m_nCOLOR_DEPTH; +#ifdef _DEBUG + bool m_bCOLOR_DEPTH; +#endif +public: + void SetCOLOR_DEPTH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOLOR_DEPTH = i; +#ifdef _DEBUG + m_bCOLOR_DEPTH = true; +#endif + } + void SetCOLOR_DEPTH( bool i ) + { + m_nCOLOR_DEPTH = i ? 1 : 0; +#ifdef _DEBUG + m_bCOLOR_DEPTH = true; +#endif + } +public: + sdk_depthwrite_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bCOLOR_DEPTH = false; +#endif // _DEBUG + m_nCOLOR_DEPTH = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCOLOR_DEPTH; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nCOLOR_DEPTH ) + 0; + } +}; +#define shaderStaticTest_sdk_depthwrite_ps20 psh_forgot_to_set_static_COLOR_DEPTH + 0 +class sdk_depthwrite_ps20_Dynamic_Index +{ +private: + int m_nALPHACLIP; +#ifdef _DEBUG + bool m_bALPHACLIP; +#endif +public: + void SetALPHACLIP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nALPHACLIP = i; +#ifdef _DEBUG + m_bALPHACLIP = true; +#endif + } + void SetALPHACLIP( bool i ) + { + m_nALPHACLIP = i ? 1 : 0; +#ifdef _DEBUG + m_bALPHACLIP = true; +#endif + } +public: + sdk_depthwrite_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bALPHACLIP = false; +#endif // _DEBUG + m_nALPHACLIP = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bALPHACLIP; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nALPHACLIP ) + 0; + } +}; +#define shaderDynamicTest_sdk_depthwrite_ps20 psh_forgot_to_set_dynamic_ALPHACLIP + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_depthwrite_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_depthwrite_ps20b.inc new file mode 100644 index 00000000..fc639347 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_depthwrite_ps20b.inc @@ -0,0 +1,87 @@ +#include "shaderlib/cshader.h" +class sdk_depthwrite_ps20b_Static_Index +{ +private: + int m_nCOLOR_DEPTH; +#ifdef _DEBUG + bool m_bCOLOR_DEPTH; +#endif +public: + void SetCOLOR_DEPTH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOLOR_DEPTH = i; +#ifdef _DEBUG + m_bCOLOR_DEPTH = true; +#endif + } + void SetCOLOR_DEPTH( bool i ) + { + m_nCOLOR_DEPTH = i ? 1 : 0; +#ifdef _DEBUG + m_bCOLOR_DEPTH = true; +#endif + } +public: + sdk_depthwrite_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCOLOR_DEPTH = false; +#endif // _DEBUG + m_nCOLOR_DEPTH = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCOLOR_DEPTH; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nCOLOR_DEPTH ) + 0; + } +}; +#define shaderStaticTest_sdk_depthwrite_ps20b psh_forgot_to_set_static_COLOR_DEPTH + 0 +class sdk_depthwrite_ps20b_Dynamic_Index +{ +private: + int m_nALPHACLIP; +#ifdef _DEBUG + bool m_bALPHACLIP; +#endif +public: + void SetALPHACLIP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nALPHACLIP = i; +#ifdef _DEBUG + m_bALPHACLIP = true; +#endif + } + void SetALPHACLIP( bool i ) + { + m_nALPHACLIP = i ? 1 : 0; +#ifdef _DEBUG + m_bALPHACLIP = true; +#endif + } +public: + sdk_depthwrite_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bALPHACLIP = false; +#endif // _DEBUG + m_nALPHACLIP = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bALPHACLIP; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nALPHACLIP ) + 0; + } +}; +#define shaderDynamicTest_sdk_depthwrite_ps20b psh_forgot_to_set_dynamic_ALPHACLIP + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_depthwrite_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_depthwrite_ps30.inc new file mode 100644 index 00000000..7ebec65d --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_depthwrite_ps30.inc @@ -0,0 +1,87 @@ +#include "shaderlib/cshader.h" +class sdk_depthwrite_ps30_Static_Index +{ +private: + int m_nCOLOR_DEPTH; +#ifdef _DEBUG + bool m_bCOLOR_DEPTH; +#endif +public: + void SetCOLOR_DEPTH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOLOR_DEPTH = i; +#ifdef _DEBUG + m_bCOLOR_DEPTH = true; +#endif + } + void SetCOLOR_DEPTH( bool i ) + { + m_nCOLOR_DEPTH = i ? 1 : 0; +#ifdef _DEBUG + m_bCOLOR_DEPTH = true; +#endif + } +public: + sdk_depthwrite_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bCOLOR_DEPTH = false; +#endif // _DEBUG + m_nCOLOR_DEPTH = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCOLOR_DEPTH; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nCOLOR_DEPTH ) + 0; + } +}; +#define shaderStaticTest_sdk_depthwrite_ps30 psh_forgot_to_set_static_COLOR_DEPTH + 0 +class sdk_depthwrite_ps30_Dynamic_Index +{ +private: + int m_nALPHACLIP; +#ifdef _DEBUG + bool m_bALPHACLIP; +#endif +public: + void SetALPHACLIP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nALPHACLIP = i; +#ifdef _DEBUG + m_bALPHACLIP = true; +#endif + } + void SetALPHACLIP( bool i ) + { + m_nALPHACLIP = i ? 1 : 0; +#ifdef _DEBUG + m_bALPHACLIP = true; +#endif + } +public: + sdk_depthwrite_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bALPHACLIP = false; +#endif // _DEBUG + m_nALPHACLIP = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bALPHACLIP; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nALPHACLIP ) + 0; + } +}; +#define shaderDynamicTest_sdk_depthwrite_ps30 psh_forgot_to_set_dynamic_ALPHACLIP + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_depthwrite_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_depthwrite_vs20.inc new file mode 100644 index 00000000..25256cd7 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_depthwrite_vs20.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_depthwrite_vs20_Static_Index +{ +private: + int m_nONLY_PROJECT_POSITION; +#ifdef _DEBUG + bool m_bONLY_PROJECT_POSITION; +#endif +public: + void SetONLY_PROJECT_POSITION( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nONLY_PROJECT_POSITION = i; +#ifdef _DEBUG + m_bONLY_PROJECT_POSITION = true; +#endif + } + void SetONLY_PROJECT_POSITION( bool i ) + { + m_nONLY_PROJECT_POSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bONLY_PROJECT_POSITION = true; +#endif + } +private: + int m_nCOLOR_DEPTH; +#ifdef _DEBUG + bool m_bCOLOR_DEPTH; +#endif +public: + void SetCOLOR_DEPTH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOLOR_DEPTH = i; +#ifdef _DEBUG + m_bCOLOR_DEPTH = true; +#endif + } + void SetCOLOR_DEPTH( bool i ) + { + m_nCOLOR_DEPTH = i ? 1 : 0; +#ifdef _DEBUG + m_bCOLOR_DEPTH = true; +#endif + } +public: + sdk_depthwrite_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bONLY_PROJECT_POSITION = false; +#endif // _DEBUG + m_nONLY_PROJECT_POSITION = 0; +#ifdef _DEBUG + m_bCOLOR_DEPTH = false; +#endif // _DEBUG + m_nCOLOR_DEPTH = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bONLY_PROJECT_POSITION && m_bCOLOR_DEPTH; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nONLY_PROJECT_POSITION ) + ( 4 * m_nCOLOR_DEPTH ) + 0; + } +}; +#define shaderStaticTest_sdk_depthwrite_vs20 vsh_forgot_to_set_static_ONLY_PROJECT_POSITION + vsh_forgot_to_set_static_COLOR_DEPTH + 0 +class sdk_depthwrite_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_depthwrite_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + 0; + } +}; +#define shaderDynamicTest_sdk_depthwrite_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_depthwrite_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_depthwrite_vs30.inc new file mode 100644 index 00000000..b009bec2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_depthwrite_vs30.inc @@ -0,0 +1,162 @@ +#include "shaderlib/cshader.h" +class sdk_depthwrite_vs30_Static_Index +{ +private: + int m_nONLY_PROJECT_POSITION; +#ifdef _DEBUG + bool m_bONLY_PROJECT_POSITION; +#endif +public: + void SetONLY_PROJECT_POSITION( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nONLY_PROJECT_POSITION = i; +#ifdef _DEBUG + m_bONLY_PROJECT_POSITION = true; +#endif + } + void SetONLY_PROJECT_POSITION( bool i ) + { + m_nONLY_PROJECT_POSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bONLY_PROJECT_POSITION = true; +#endif + } +private: + int m_nCOLOR_DEPTH; +#ifdef _DEBUG + bool m_bCOLOR_DEPTH; +#endif +public: + void SetCOLOR_DEPTH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOLOR_DEPTH = i; +#ifdef _DEBUG + m_bCOLOR_DEPTH = true; +#endif + } + void SetCOLOR_DEPTH( bool i ) + { + m_nCOLOR_DEPTH = i ? 1 : 0; +#ifdef _DEBUG + m_bCOLOR_DEPTH = true; +#endif + } +public: + sdk_depthwrite_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bONLY_PROJECT_POSITION = false; +#endif // _DEBUG + m_nONLY_PROJECT_POSITION = 0; +#ifdef _DEBUG + m_bCOLOR_DEPTH = false; +#endif // _DEBUG + m_nCOLOR_DEPTH = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bONLY_PROJECT_POSITION && m_bCOLOR_DEPTH; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 8 * m_nONLY_PROJECT_POSITION ) + ( 8 * m_nCOLOR_DEPTH ) + 0; + } +}; +#define shaderStaticTest_sdk_depthwrite_vs30 vsh_forgot_to_set_static_ONLY_PROJECT_POSITION + vsh_forgot_to_set_static_COLOR_DEPTH + 0 +class sdk_depthwrite_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_depthwrite_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_depthwrite_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_emissive_scroll_blended_pass_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_emissive_scroll_blended_pass_ps20.inc new file mode 100644 index 00000000..c415f0a5 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_emissive_scroll_blended_pass_ps20.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_emissive_scroll_blended_pass_ps20_Static_Index +{ +public: + sdk_emissive_scroll_blended_pass_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_emissive_scroll_blended_pass_ps20 0 +class sdk_emissive_scroll_blended_pass_ps20_Dynamic_Index +{ +public: + sdk_emissive_scroll_blended_pass_ps20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_emissive_scroll_blended_pass_ps20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_emissive_scroll_blended_pass_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_emissive_scroll_blended_pass_ps20b.inc new file mode 100644 index 00000000..42dd5742 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_emissive_scroll_blended_pass_ps20b.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_emissive_scroll_blended_pass_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_emissive_scroll_blended_pass_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_emissive_scroll_blended_pass_ps20b 0 +class sdk_emissive_scroll_blended_pass_ps20b_Dynamic_Index +{ +public: + sdk_emissive_scroll_blended_pass_ps20b_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_emissive_scroll_blended_pass_ps20b 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_emissive_scroll_blended_pass_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_emissive_scroll_blended_pass_ps30.inc new file mode 100644 index 00000000..f0e08917 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_emissive_scroll_blended_pass_ps30.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_emissive_scroll_blended_pass_ps30_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_emissive_scroll_blended_pass_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_emissive_scroll_blended_pass_ps30 0 +class sdk_emissive_scroll_blended_pass_ps30_Dynamic_Index +{ +public: + sdk_emissive_scroll_blended_pass_ps30_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_emissive_scroll_blended_pass_ps30 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_emissive_scroll_blended_pass_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_emissive_scroll_blended_pass_vs20.inc new file mode 100644 index 00000000..a7f2793f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_emissive_scroll_blended_pass_vs20.inc @@ -0,0 +1,85 @@ +#include "shaderlib/cshader.h" +class sdk_emissive_scroll_blended_pass_vs20_Static_Index +{ +public: + sdk_emissive_scroll_blended_pass_vs20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_emissive_scroll_blended_pass_vs20 0 +class sdk_emissive_scroll_blended_pass_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_emissive_scroll_blended_pass_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + 0; + } +}; +#define shaderDynamicTest_sdk_emissive_scroll_blended_pass_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_emissive_scroll_blended_pass_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_emissive_scroll_blended_pass_vs30.inc new file mode 100644 index 00000000..5abcbad5 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_emissive_scroll_blended_pass_vs30.inc @@ -0,0 +1,110 @@ +#include "shaderlib/cshader.h" +class sdk_emissive_scroll_blended_pass_vs30_Static_Index +{ +public: + sdk_emissive_scroll_blended_pass_vs30_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_emissive_scroll_blended_pass_vs30 0 +class sdk_emissive_scroll_blended_pass_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_emissive_scroll_blended_pass_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_emissive_scroll_blended_pass_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eye_refract_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eye_refract_ps20.inc new file mode 100644 index 00000000..850964b3 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eye_refract_ps20.inc @@ -0,0 +1,112 @@ +#include "shaderlib/cshader.h" +class sdk_eye_refract_ps20_Static_Index +{ +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nLIGHTWARPTEXTURE; +#ifdef _DEBUG + bool m_bLIGHTWARPTEXTURE; +#endif +public: + void SetLIGHTWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTWARPTEXTURE = i; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } + void SetLIGHTWARPTEXTURE( bool i ) + { + m_nLIGHTWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } +public: + sdk_eye_refract_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = false; +#endif // _DEBUG + m_nLIGHTWARPTEXTURE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bFLASHLIGHT && m_bLIGHTWARPTEXTURE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 3 * m_nFLASHLIGHT ) + ( 6 * m_nLIGHTWARPTEXTURE ) + 0; + } +}; +#define shaderStaticTest_sdk_eye_refract_ps20 psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_LIGHTWARPTEXTURE + 0 +class sdk_eye_refract_ps20_Dynamic_Index +{ +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_eye_refract_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_eye_refract_ps20 psh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eye_refract_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eye_refract_ps20b.inc new file mode 100644 index 00000000..93308c81 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eye_refract_ps20b.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_eye_refract_ps20b_Static_Index +{ +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nLIGHTWARPTEXTURE; +#ifdef _DEBUG + bool m_bLIGHTWARPTEXTURE; +#endif +public: + void SetLIGHTWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTWARPTEXTURE = i; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } + void SetLIGHTWARPTEXTURE( bool i ) + { + m_nLIGHTWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } +private: + int m_nSPHERETEXKILLCOMBO; +#ifdef _DEBUG + bool m_bSPHERETEXKILLCOMBO; +#endif +public: + void SetSPHERETEXKILLCOMBO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSPHERETEXKILLCOMBO = i; +#ifdef _DEBUG + m_bSPHERETEXKILLCOMBO = true; +#endif + } + void SetSPHERETEXKILLCOMBO( bool i ) + { + m_nSPHERETEXKILLCOMBO = i ? 1 : 0; +#ifdef _DEBUG + m_bSPHERETEXKILLCOMBO = true; +#endif + } +private: + int m_nRAYTRACESPHERE; +#ifdef _DEBUG + bool m_bRAYTRACESPHERE; +#endif +public: + void SetRAYTRACESPHERE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nRAYTRACESPHERE = i; +#ifdef _DEBUG + m_bRAYTRACESPHERE = true; +#endif + } + void SetRAYTRACESPHERE( bool i ) + { + m_nRAYTRACESPHERE = i ? 1 : 0; +#ifdef _DEBUG + m_bRAYTRACESPHERE = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_eye_refract_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = false; +#endif // _DEBUG + m_nLIGHTWARPTEXTURE = 0; +#ifdef _DEBUG + m_bSPHERETEXKILLCOMBO = false; +#endif // _DEBUG + m_nSPHERETEXKILLCOMBO = 0; +#ifdef _DEBUG + m_bRAYTRACESPHERE = false; +#endif // _DEBUG + m_nRAYTRACESPHERE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bFLASHLIGHT && m_bLIGHTWARPTEXTURE && m_bSPHERETEXKILLCOMBO && m_bRAYTRACESPHERE && m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 10 * m_nFLASHLIGHT ) + ( 20 * m_nLIGHTWARPTEXTURE ) + ( 40 * m_nSPHERETEXKILLCOMBO ) + ( 80 * m_nRAYTRACESPHERE ) + ( 160 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_eye_refract_ps20b psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_SPHERETEXKILLCOMBO + psh_forgot_to_set_static_RAYTRACESPHERE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_eye_refract_ps20b_Dynamic_Index +{ +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_eye_refract_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bNUM_LIGHTS && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nNUM_LIGHTS ) + ( 5 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_eye_refract_ps20b psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eye_refract_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eye_refract_ps30.inc new file mode 100644 index 00000000..76c39918 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eye_refract_ps30.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_eye_refract_ps30_Static_Index +{ +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nLIGHTWARPTEXTURE; +#ifdef _DEBUG + bool m_bLIGHTWARPTEXTURE; +#endif +public: + void SetLIGHTWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTWARPTEXTURE = i; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } + void SetLIGHTWARPTEXTURE( bool i ) + { + m_nLIGHTWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } +private: + int m_nSPHERETEXKILLCOMBO; +#ifdef _DEBUG + bool m_bSPHERETEXKILLCOMBO; +#endif +public: + void SetSPHERETEXKILLCOMBO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSPHERETEXKILLCOMBO = i; +#ifdef _DEBUG + m_bSPHERETEXKILLCOMBO = true; +#endif + } + void SetSPHERETEXKILLCOMBO( bool i ) + { + m_nSPHERETEXKILLCOMBO = i ? 1 : 0; +#ifdef _DEBUG + m_bSPHERETEXKILLCOMBO = true; +#endif + } +private: + int m_nRAYTRACESPHERE; +#ifdef _DEBUG + bool m_bRAYTRACESPHERE; +#endif +public: + void SetRAYTRACESPHERE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nRAYTRACESPHERE = i; +#ifdef _DEBUG + m_bRAYTRACESPHERE = true; +#endif + } + void SetRAYTRACESPHERE( bool i ) + { + m_nRAYTRACESPHERE = i ? 1 : 0; +#ifdef _DEBUG + m_bRAYTRACESPHERE = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_eye_refract_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = false; +#endif // _DEBUG + m_nLIGHTWARPTEXTURE = 0; +#ifdef _DEBUG + m_bSPHERETEXKILLCOMBO = false; +#endif // _DEBUG + m_nSPHERETEXKILLCOMBO = 0; +#ifdef _DEBUG + m_bRAYTRACESPHERE = false; +#endif // _DEBUG + m_nRAYTRACESPHERE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bFLASHLIGHT && m_bLIGHTWARPTEXTURE && m_bSPHERETEXKILLCOMBO && m_bRAYTRACESPHERE && m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 10 * m_nFLASHLIGHT ) + ( 20 * m_nLIGHTWARPTEXTURE ) + ( 40 * m_nSPHERETEXKILLCOMBO ) + ( 80 * m_nRAYTRACESPHERE ) + ( 160 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_eye_refract_ps30 psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_SPHERETEXKILLCOMBO + psh_forgot_to_set_static_RAYTRACESPHERE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_eye_refract_ps30_Dynamic_Index +{ +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_eye_refract_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bNUM_LIGHTS && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nNUM_LIGHTS ) + ( 5 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_eye_refract_ps30 psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eye_refract_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eye_refract_vs20.inc new file mode 100644 index 00000000..ec10825b --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eye_refract_vs20.inc @@ -0,0 +1,287 @@ +#include "shaderlib/cshader.h" +class sdk_eye_refract_vs20_Static_Index +{ +private: + int m_nINTRO; +#ifdef _DEBUG + bool m_bINTRO; +#endif +public: + void SetINTRO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nINTRO = i; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } + void SetINTRO( bool i ) + { + m_nINTRO = i ? 1 : 0; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nLIGHTWARPTEXTURE; +#ifdef _DEBUG + bool m_bLIGHTWARPTEXTURE; +#endif +public: + void SetLIGHTWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTWARPTEXTURE = i; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } + void SetLIGHTWARPTEXTURE( bool i ) + { + m_nLIGHTWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } +public: + sdk_eye_refract_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bINTRO = false; +#endif // _DEBUG + m_nINTRO = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = false; +#endif // _DEBUG + m_nLIGHTWARPTEXTURE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bINTRO && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bLIGHTWARPTEXTURE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 160 * m_nINTRO ) + ( 320 * m_nHALFLAMBERT ) + ( 640 * m_nFLASHLIGHT ) + ( 1280 * m_nLIGHTWARPTEXTURE ) + 0; + } +}; +#define shaderStaticTest_sdk_eye_refract_vs20 vsh_forgot_to_set_static_INTRO + vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_FLASHLIGHT + vsh_forgot_to_set_static_LIGHTWARPTEXTURE + 0 +class sdk_eye_refract_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nDYNAMIC_LIGHT; +#ifdef _DEBUG + bool m_bDYNAMIC_LIGHT; +#endif +public: + void SetDYNAMIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDYNAMIC_LIGHT = i; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } + void SetDYNAMIC_LIGHT( bool i ) + { + m_nDYNAMIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_eye_refract_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = false; +#endif // _DEBUG + m_nDYNAMIC_LIGHT = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bDOWATERFOG && m_bDYNAMIC_LIGHT && m_bSTATIC_LIGHT && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nDOWATERFOG ) + ( 8 * m_nDYNAMIC_LIGHT ) + ( 16 * m_nSTATIC_LIGHT ) + ( 32 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_eye_refract_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_DYNAMIC_LIGHT + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eye_refract_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eye_refract_vs30.inc new file mode 100644 index 00000000..4729f2ab --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eye_refract_vs30.inc @@ -0,0 +1,312 @@ +#include "shaderlib/cshader.h" +class sdk_eye_refract_vs30_Static_Index +{ +private: + int m_nINTRO; +#ifdef _DEBUG + bool m_bINTRO; +#endif +public: + void SetINTRO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nINTRO = i; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } + void SetINTRO( bool i ) + { + m_nINTRO = i ? 1 : 0; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nLIGHTWARPTEXTURE; +#ifdef _DEBUG + bool m_bLIGHTWARPTEXTURE; +#endif +public: + void SetLIGHTWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTWARPTEXTURE = i; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } + void SetLIGHTWARPTEXTURE( bool i ) + { + m_nLIGHTWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } +public: + sdk_eye_refract_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bINTRO = false; +#endif // _DEBUG + m_nINTRO = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = false; +#endif // _DEBUG + m_nLIGHTWARPTEXTURE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bINTRO && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bLIGHTWARPTEXTURE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 320 * m_nINTRO ) + ( 640 * m_nHALFLAMBERT ) + ( 1280 * m_nFLASHLIGHT ) + ( 2560 * m_nLIGHTWARPTEXTURE ) + 0; + } +}; +#define shaderStaticTest_sdk_eye_refract_vs30 vsh_forgot_to_set_static_INTRO + vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_FLASHLIGHT + vsh_forgot_to_set_static_LIGHTWARPTEXTURE + 0 +class sdk_eye_refract_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nDYNAMIC_LIGHT; +#ifdef _DEBUG + bool m_bDYNAMIC_LIGHT; +#endif +public: + void SetDYNAMIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDYNAMIC_LIGHT = i; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } + void SetDYNAMIC_LIGHT( bool i ) + { + m_nDYNAMIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_eye_refract_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = false; +#endif // _DEBUG + m_nDYNAMIC_LIGHT = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bDOWATERFOG && m_bDYNAMIC_LIGHT && m_bSTATIC_LIGHT && m_bNUM_LIGHTS && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nDOWATERFOG ) + ( 8 * m_nDYNAMIC_LIGHT ) + ( 16 * m_nSTATIC_LIGHT ) + ( 32 * m_nNUM_LIGHTS ) + ( 160 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_eye_refract_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_DYNAMIC_LIGHT + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_NUM_LIGHTS + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyeglint_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyeglint_ps20.inc new file mode 100644 index 00000000..3c83a6ca --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyeglint_ps20.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_eyeglint_ps20_Static_Index +{ +public: + sdk_eyeglint_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_eyeglint_ps20 0 +class sdk_eyeglint_ps20_Dynamic_Index +{ +public: + sdk_eyeglint_ps20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_eyeglint_ps20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyeglint_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyeglint_ps20b.inc new file mode 100644 index 00000000..2dbb669b --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyeglint_ps20b.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_eyeglint_ps20b_Static_Index +{ +public: + sdk_eyeglint_ps20b_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_eyeglint_ps20b 0 +class sdk_eyeglint_ps20b_Dynamic_Index +{ +public: + sdk_eyeglint_ps20b_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_eyeglint_ps20b 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyeglint_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyeglint_vs20.inc new file mode 100644 index 00000000..05087222 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyeglint_vs20.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_eyeglint_vs20_Static_Index +{ +public: + sdk_eyeglint_vs20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_eyeglint_vs20 0 +class sdk_eyeglint_vs20_Dynamic_Index +{ +public: + sdk_eyeglint_vs20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_eyeglint_vs20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_flashlight_ps11.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_flashlight_ps11.inc new file mode 100644 index 00000000..721122e3 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_flashlight_ps11.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_flashlight_ps11_Static_Index +{ +public: + sdk_eyes_flashlight_ps11_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_eyes_flashlight_ps11 0 +class sdk_eyes_flashlight_ps11_Dynamic_Index +{ +public: + sdk_eyes_flashlight_ps11_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_eyes_flashlight_ps11 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_flashlight_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_flashlight_ps20.inc new file mode 100644 index 00000000..9e576f91 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_flashlight_ps20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_flashlight_ps20_Static_Index +{ +public: + sdk_eyes_flashlight_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_eyes_flashlight_ps20 0 +class sdk_eyes_flashlight_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_eyes_flashlight_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_eyes_flashlight_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_flashlight_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_flashlight_ps20b.inc new file mode 100644 index 00000000..d156ca25 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_flashlight_ps20b.inc @@ -0,0 +1,112 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_flashlight_ps20b_Static_Index +{ +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_eyes_flashlight_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_eyes_flashlight_ps20b psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_eyes_flashlight_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_eyes_flashlight_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_eyes_flashlight_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_flashlight_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_flashlight_ps30.inc new file mode 100644 index 00000000..57ddecae --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_flashlight_ps30.inc @@ -0,0 +1,112 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_flashlight_ps30_Static_Index +{ +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_eyes_flashlight_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_eyes_flashlight_ps30 psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_eyes_flashlight_ps30_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_eyes_flashlight_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_eyes_flashlight_ps30 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_flashlight_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_flashlight_vs20.inc new file mode 100644 index 00000000..c93c72de --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_flashlight_vs20.inc @@ -0,0 +1,110 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_flashlight_vs20_Static_Index +{ +public: + sdk_eyes_flashlight_vs20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_eyes_flashlight_vs20 0 +class sdk_eyes_flashlight_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_eyes_flashlight_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_eyes_flashlight_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_flashlight_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_flashlight_vs30.inc new file mode 100644 index 00000000..1244088b --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_flashlight_vs30.inc @@ -0,0 +1,135 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_flashlight_vs30_Static_Index +{ +public: + sdk_eyes_flashlight_vs30_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_eyes_flashlight_vs30 0 +class sdk_eyes_flashlight_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_eyes_flashlight_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bDOWATERFOG && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nDOWATERFOG ) + ( 8 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_eyes_flashlight_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_ps20.inc new file mode 100644 index 00000000..cbbb103d --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_ps20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_ps20_Static_Index +{ +public: + sdk_eyes_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_eyes_ps20 0 +class sdk_eyes_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_eyes_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_eyes_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_ps20b.inc new file mode 100644 index 00000000..f10f16d4 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_ps20b.inc @@ -0,0 +1,85 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_ps20b_Static_Index +{ +public: + sdk_eyes_ps20b_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_eyes_ps20b 0 +class sdk_eyes_ps20b_Dynamic_Index +{ +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_eyes_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bWRITE_DEPTH_TO_DESTALPHA && m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_eyes_ps20b psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_ps30.inc new file mode 100644 index 00000000..2353f65d --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_ps30.inc @@ -0,0 +1,85 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_ps30_Static_Index +{ +public: + sdk_eyes_ps30_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_eyes_ps30 0 +class sdk_eyes_ps30_Dynamic_Index +{ +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_eyes_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bWRITE_DEPTH_TO_DESTALPHA && m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_eyes_ps30 psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_vs20.inc new file mode 100644 index 00000000..5b896790 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_vs20.inc @@ -0,0 +1,262 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_vs20_Static_Index +{ +private: + int m_nINTRO; +#ifdef _DEBUG + bool m_bINTRO; +#endif +public: + void SetINTRO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nINTRO = i; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } + void SetINTRO( bool i ) + { + m_nINTRO = i ? 1 : 0; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nUSE_STATIC_CONTROL_FLOW; +#ifdef _DEBUG + bool m_bUSE_STATIC_CONTROL_FLOW; +#endif +public: + void SetUSE_STATIC_CONTROL_FLOW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nUSE_STATIC_CONTROL_FLOW = i; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } + void SetUSE_STATIC_CONTROL_FLOW( bool i ) + { + m_nUSE_STATIC_CONTROL_FLOW = i ? 1 : 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } +public: + sdk_eyes_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bINTRO = false; +#endif // _DEBUG + m_nINTRO = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = false; +#endif // _DEBUG + m_nUSE_STATIC_CONTROL_FLOW = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bINTRO && m_bHALFLAMBERT && m_bUSE_STATIC_CONTROL_FLOW; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 96 * m_nINTRO ) + ( 192 * m_nHALFLAMBERT ) + ( 384 * m_nUSE_STATIC_CONTROL_FLOW ) + 0; + } +}; +#define shaderStaticTest_sdk_eyes_vs20 vsh_forgot_to_set_static_INTRO + vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + 0 +class sdk_eyes_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nDYNAMIC_LIGHT; +#ifdef _DEBUG + bool m_bDYNAMIC_LIGHT; +#endif +public: + void SetDYNAMIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDYNAMIC_LIGHT = i; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } + void SetDYNAMIC_LIGHT( bool i ) + { + m_nDYNAMIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_eyes_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = false; +#endif // _DEBUG + m_nDYNAMIC_LIGHT = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bDOWATERFOG && m_bDYNAMIC_LIGHT && m_bSTATIC_LIGHT && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nDOWATERFOG ) + ( 8 * m_nDYNAMIC_LIGHT ) + ( 16 * m_nSTATIC_LIGHT ) + ( 32 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_eyes_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_DYNAMIC_LIGHT + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_vs30.inc new file mode 100644 index 00000000..d14fa273 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_eyes_vs30.inc @@ -0,0 +1,237 @@ +#include "shaderlib/cshader.h" +class sdk_eyes_vs30_Static_Index +{ +private: + int m_nINTRO; +#ifdef _DEBUG + bool m_bINTRO; +#endif +public: + void SetINTRO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nINTRO = i; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } + void SetINTRO( bool i ) + { + m_nINTRO = i ? 1 : 0; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +public: + sdk_eyes_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bINTRO = false; +#endif // _DEBUG + m_nINTRO = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bINTRO && m_bHALFLAMBERT; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 64 * m_nINTRO ) + ( 128 * m_nHALFLAMBERT ) + 0; + } +}; +#define shaderStaticTest_sdk_eyes_vs30 vsh_forgot_to_set_static_INTRO + vsh_forgot_to_set_static_HALFLAMBERT + 0 +class sdk_eyes_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nDYNAMIC_LIGHT; +#ifdef _DEBUG + bool m_bDYNAMIC_LIGHT; +#endif +public: + void SetDYNAMIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDYNAMIC_LIGHT = i; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } + void SetDYNAMIC_LIGHT( bool i ) + { + m_nDYNAMIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_eyes_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = false; +#endif // _DEBUG + m_nDYNAMIC_LIGHT = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bDOWATERFOG && m_bDYNAMIC_LIGHT && m_bSTATIC_LIGHT && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nDOWATERFOG ) + ( 8 * m_nDYNAMIC_LIGHT ) + ( 16 * m_nSTATIC_LIGHT ) + ( 32 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_eyes_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_DYNAMIC_LIGHT + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flashlight_ps11.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flashlight_ps11.inc new file mode 100644 index 00000000..fc6f849d --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flashlight_ps11.inc @@ -0,0 +1,85 @@ +#include "shaderlib/cshader.h" +class sdk_flashlight_ps11_Static_Index +{ +private: + int m_nNORMALMAP; +#ifdef _DEBUG + bool m_bNORMALMAP; +#endif +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } + void SetNORMALMAP( bool i ) + { + m_nNORMALMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } +private: + int m_nNOCULL; +#ifdef _DEBUG + bool m_bNOCULL; +#endif +public: + void SetNOCULL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNOCULL = i; +#ifdef _DEBUG + m_bNOCULL = true; +#endif + } + void SetNOCULL( bool i ) + { + m_nNOCULL = i ? 1 : 0; +#ifdef _DEBUG + m_bNOCULL = true; +#endif + } +public: + sdk_flashlight_ps11_Static_Index( ) + { +#ifdef _DEBUG + m_bNORMALMAP = false; +#endif // _DEBUG + m_nNORMALMAP = 0; +#ifdef _DEBUG + m_bNOCULL = false; +#endif // _DEBUG + m_nNOCULL = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bNORMALMAP && m_bNOCULL; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nNORMALMAP ) + ( 2 * m_nNOCULL ) + 0; + } +}; +#define shaderStaticTest_sdk_flashlight_ps11 psh_forgot_to_set_static_NORMALMAP + psh_forgot_to_set_static_NOCULL + 0 +class sdk_flashlight_ps11_Dynamic_Index +{ +public: + sdk_flashlight_ps11_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_flashlight_ps11 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flashlight_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flashlight_ps20.inc new file mode 100644 index 00000000..3d25ff86 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flashlight_ps20.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_flashlight_ps20_Static_Index +{ +private: + int m_nNORMALMAP; +#ifdef _DEBUG + bool m_bNORMALMAP; +#endif +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } + void SetNORMALMAP( bool i ) + { + m_nNORMALMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } +private: + int m_nNORMALMAP2; +#ifdef _DEBUG + bool m_bNORMALMAP2; +#endif +public: + void SetNORMALMAP2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP2 = i; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } + void SetNORMALMAP2( bool i ) + { + m_nNORMALMAP2 = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } +private: + int m_nWORLDVERTEXTRANSITION; +#ifdef _DEBUG + bool m_bWORLDVERTEXTRANSITION; +#endif +public: + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } + void SetWORLDVERTEXTRANSITION( bool i ) + { + m_nWORLDVERTEXTRANSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +public: + sdk_flashlight_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bNORMALMAP = false; +#endif // _DEBUG + m_nNORMALMAP = 0; +#ifdef _DEBUG + m_bNORMALMAP2 = false; +#endif // _DEBUG + m_nNORMALMAP2 = 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = false; +#endif // _DEBUG + m_nWORLDVERTEXTRANSITION = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bNORMALMAP && m_bNORMALMAP2 && m_bWORLDVERTEXTRANSITION && m_bSEAMLESS && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nNORMALMAP ) + ( 6 * m_nNORMALMAP2 ) + ( 12 * m_nWORLDVERTEXTRANSITION ) + ( 24 * m_nSEAMLESS ) + ( 48 * m_nDETAILTEXTURE ) + ( 96 * m_nDETAIL_BLEND_MODE ) + 0; + } +}; +#define shaderStaticTest_sdk_flashlight_ps20 psh_forgot_to_set_static_NORMALMAP + psh_forgot_to_set_static_NORMALMAP2 + psh_forgot_to_set_static_WORLDVERTEXTRANSITION + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + 0 +class sdk_flashlight_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_flashlight_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_flashlight_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flashlight_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flashlight_ps20b.inc new file mode 100644 index 00000000..0e2bf822 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flashlight_ps20b.inc @@ -0,0 +1,262 @@ +#include "shaderlib/cshader.h" +class sdk_flashlight_ps20b_Static_Index +{ +private: + int m_nNORMALMAP; +#ifdef _DEBUG + bool m_bNORMALMAP; +#endif +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } + void SetNORMALMAP( bool i ) + { + m_nNORMALMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } +private: + int m_nNORMALMAP2; +#ifdef _DEBUG + bool m_bNORMALMAP2; +#endif +public: + void SetNORMALMAP2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP2 = i; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } + void SetNORMALMAP2( bool i ) + { + m_nNORMALMAP2 = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } +private: + int m_nWORLDVERTEXTRANSITION; +#ifdef _DEBUG + bool m_bWORLDVERTEXTRANSITION; +#endif +public: + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } + void SetWORLDVERTEXTRANSITION( bool i ) + { + m_nWORLDVERTEXTRANSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_flashlight_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bNORMALMAP = false; +#endif // _DEBUG + m_nNORMALMAP = 0; +#ifdef _DEBUG + m_bNORMALMAP2 = false; +#endif // _DEBUG + m_nNORMALMAP2 = 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = false; +#endif // _DEBUG + m_nWORLDVERTEXTRANSITION = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bNORMALMAP && m_bNORMALMAP2 && m_bWORLDVERTEXTRANSITION && m_bSEAMLESS && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nNORMALMAP ) + ( 12 * m_nNORMALMAP2 ) + ( 24 * m_nWORLDVERTEXTRANSITION ) + ( 48 * m_nSEAMLESS ) + ( 96 * m_nDETAILTEXTURE ) + ( 192 * m_nDETAIL_BLEND_MODE ) + ( 384 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_flashlight_ps20b psh_forgot_to_set_static_NORMALMAP + psh_forgot_to_set_static_NORMALMAP2 + psh_forgot_to_set_static_WORLDVERTEXTRANSITION + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_flashlight_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_flashlight_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_flashlight_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flashlight_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flashlight_ps30.inc new file mode 100644 index 00000000..88331a5b --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flashlight_ps30.inc @@ -0,0 +1,262 @@ +#include "shaderlib/cshader.h" +class sdk_flashlight_ps30_Static_Index +{ +private: + int m_nNORMALMAP; +#ifdef _DEBUG + bool m_bNORMALMAP; +#endif +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } + void SetNORMALMAP( bool i ) + { + m_nNORMALMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } +private: + int m_nNORMALMAP2; +#ifdef _DEBUG + bool m_bNORMALMAP2; +#endif +public: + void SetNORMALMAP2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP2 = i; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } + void SetNORMALMAP2( bool i ) + { + m_nNORMALMAP2 = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } +private: + int m_nWORLDVERTEXTRANSITION; +#ifdef _DEBUG + bool m_bWORLDVERTEXTRANSITION; +#endif +public: + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } + void SetWORLDVERTEXTRANSITION( bool i ) + { + m_nWORLDVERTEXTRANSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_flashlight_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bNORMALMAP = false; +#endif // _DEBUG + m_nNORMALMAP = 0; +#ifdef _DEBUG + m_bNORMALMAP2 = false; +#endif // _DEBUG + m_nNORMALMAP2 = 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = false; +#endif // _DEBUG + m_nWORLDVERTEXTRANSITION = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bNORMALMAP && m_bNORMALMAP2 && m_bWORLDVERTEXTRANSITION && m_bSEAMLESS && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nNORMALMAP ) + ( 12 * m_nNORMALMAP2 ) + ( 24 * m_nWORLDVERTEXTRANSITION ) + ( 48 * m_nSEAMLESS ) + ( 96 * m_nDETAILTEXTURE ) + ( 192 * m_nDETAIL_BLEND_MODE ) + ( 384 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_flashlight_ps30 psh_forgot_to_set_static_NORMALMAP + psh_forgot_to_set_static_NORMALMAP2 + psh_forgot_to_set_static_WORLDVERTEXTRANSITION + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_flashlight_ps30_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_flashlight_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_flashlight_ps30 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flesh_interior_blended_pass_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flesh_interior_blended_pass_ps20.inc new file mode 100644 index 00000000..0b73f03b --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flesh_interior_blended_pass_ps20.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_flesh_interior_blended_pass_ps20_Static_Index +{ +public: + sdk_flesh_interior_blended_pass_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_flesh_interior_blended_pass_ps20 0 +class sdk_flesh_interior_blended_pass_ps20_Dynamic_Index +{ +public: + sdk_flesh_interior_blended_pass_ps20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_flesh_interior_blended_pass_ps20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flesh_interior_blended_pass_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flesh_interior_blended_pass_ps20b.inc new file mode 100644 index 00000000..dd85606f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flesh_interior_blended_pass_ps20b.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_flesh_interior_blended_pass_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_flesh_interior_blended_pass_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_flesh_interior_blended_pass_ps20b 0 +class sdk_flesh_interior_blended_pass_ps20b_Dynamic_Index +{ +public: + sdk_flesh_interior_blended_pass_ps20b_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_flesh_interior_blended_pass_ps20b 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flesh_interior_blended_pass_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flesh_interior_blended_pass_vs20.inc new file mode 100644 index 00000000..e2241b31 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_flesh_interior_blended_pass_vs20.inc @@ -0,0 +1,237 @@ +#include "shaderlib/cshader.h" +class sdk_flesh_interior_blended_pass_vs20_Static_Index +{ +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nUSE_STATIC_CONTROL_FLOW; +#ifdef _DEBUG + bool m_bUSE_STATIC_CONTROL_FLOW; +#endif +public: + void SetUSE_STATIC_CONTROL_FLOW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nUSE_STATIC_CONTROL_FLOW = i; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } + void SetUSE_STATIC_CONTROL_FLOW( bool i ) + { + m_nUSE_STATIC_CONTROL_FLOW = i ? 1 : 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } +public: + sdk_flesh_interior_blended_pass_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = false; +#endif // _DEBUG + m_nUSE_STATIC_CONTROL_FLOW = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bHALFLAMBERT && m_bUSE_STATIC_CONTROL_FLOW; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 96 * m_nHALFLAMBERT ) + ( 192 * m_nUSE_STATIC_CONTROL_FLOW ) + 0; + } +}; +#define shaderStaticTest_sdk_flesh_interior_blended_pass_vs20 vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + 0 +class sdk_flesh_interior_blended_pass_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nDYNAMIC_LIGHT; +#ifdef _DEBUG + bool m_bDYNAMIC_LIGHT; +#endif +public: + void SetDYNAMIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDYNAMIC_LIGHT = i; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } + void SetDYNAMIC_LIGHT( bool i ) + { + m_nDYNAMIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_flesh_interior_blended_pass_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = false; +#endif // _DEBUG + m_nDYNAMIC_LIGHT = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bDOWATERFOG && m_bDYNAMIC_LIGHT && m_bSTATIC_LIGHT && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nDOWATERFOG ) + ( 8 * m_nDYNAMIC_LIGHT ) + ( 16 * m_nSTATIC_LIGHT ) + ( 32 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_flesh_interior_blended_pass_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_DYNAMIC_LIGHT + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_decal_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_decal_ps20.inc new file mode 100644 index 00000000..91c81ef9 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_decal_ps20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_decal_ps20_Static_Index +{ +public: + sdk_lightmappedgeneric_decal_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_decal_ps20 0 +class sdk_lightmappedgeneric_decal_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_lightmappedgeneric_decal_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_decal_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_decal_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_decal_ps20b.inc new file mode 100644 index 00000000..e11d31ca --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_decal_ps20b.inc @@ -0,0 +1,87 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_decal_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_lightmappedgeneric_decal_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_decal_ps20b 0 +class sdk_lightmappedgeneric_decal_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_lightmappedgeneric_decal_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_decal_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_decal_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_decal_vs20.inc new file mode 100644 index 00000000..a53c8769 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_decal_vs20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_decal_vs20_Static_Index +{ +public: + sdk_lightmappedgeneric_decal_vs20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_decal_vs20 0 +class sdk_lightmappedgeneric_decal_vs20_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_lightmappedgeneric_decal_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_decal_vs20 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_flashlight_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_flashlight_ps20.inc new file mode 100644 index 00000000..e24bcc01 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_flashlight_ps20.inc @@ -0,0 +1,262 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_flashlight_ps20_Static_Index +{ +private: + int m_nNORMALMAP; +#ifdef _DEBUG + bool m_bNORMALMAP; +#endif +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } + void SetNORMALMAP( bool i ) + { + m_nNORMALMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } +private: + int m_nNORMALMAP2; +#ifdef _DEBUG + bool m_bNORMALMAP2; +#endif +public: + void SetNORMALMAP2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP2 = i; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } + void SetNORMALMAP2( bool i ) + { + m_nNORMALMAP2 = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } +private: + int m_nWORLDVERTEXTRANSITION; +#ifdef _DEBUG + bool m_bWORLDVERTEXTRANSITION; +#endif +public: + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } + void SetWORLDVERTEXTRANSITION( bool i ) + { + m_nWORLDVERTEXTRANSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } +private: + int m_nFANCY_BLENDING; +#ifdef _DEBUG + bool m_bFANCY_BLENDING; +#endif +public: + void SetFANCY_BLENDING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFANCY_BLENDING = i; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif + } + void SetFANCY_BLENDING( bool i ) + { + m_nFANCY_BLENDING = i ? 1 : 0; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nBASETEXTURETRANSFORM2; +#ifdef _DEBUG + bool m_bBASETEXTURETRANSFORM2; +#endif +public: + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } + void SetBASETEXTURETRANSFORM2( bool i ) + { + m_nBASETEXTURETRANSFORM2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bNORMALMAP = false; +#endif // _DEBUG + m_nNORMALMAP = 0; +#ifdef _DEBUG + m_bNORMALMAP2 = false; +#endif // _DEBUG + m_nNORMALMAP2 = 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = false; +#endif // _DEBUG + m_nWORLDVERTEXTRANSITION = 0; +#ifdef _DEBUG + m_bFANCY_BLENDING = false; +#endif // _DEBUG + m_nFANCY_BLENDING = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + m_nBASETEXTURETRANSFORM2 = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bNORMALMAP && m_bNORMALMAP2 && m_bWORLDVERTEXTRANSITION && m_bFANCY_BLENDING && m_bSEAMLESS && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bBASETEXTURETRANSFORM2; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nNORMALMAP ) + ( 6 * m_nNORMALMAP2 ) + ( 12 * m_nWORLDVERTEXTRANSITION ) + ( 24 * m_nFANCY_BLENDING ) + ( 48 * m_nSEAMLESS ) + ( 96 * m_nDETAILTEXTURE ) + ( 192 * m_nDETAIL_BLEND_MODE ) + ( 384 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_flashlight_ps20 psh_forgot_to_set_static_NORMALMAP + psh_forgot_to_set_static_NORMALMAP2 + psh_forgot_to_set_static_WORLDVERTEXTRANSITION + psh_forgot_to_set_static_FANCY_BLENDING + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_BASETEXTURETRANSFORM2 + 0 +class sdk_lightmappedgeneric_flashlight_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_flashlight_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_flashlight_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_flashlight_ps20b.inc new file mode 100644 index 00000000..e4ba14aa --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_flashlight_ps20b.inc @@ -0,0 +1,362 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_flashlight_ps20b_Static_Index +{ +private: + int m_nNORMALMAP; +#ifdef _DEBUG + bool m_bNORMALMAP; +#endif +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } + void SetNORMALMAP( bool i ) + { + m_nNORMALMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } +private: + int m_nNORMALMAP2; +#ifdef _DEBUG + bool m_bNORMALMAP2; +#endif +public: + void SetNORMALMAP2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP2 = i; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } + void SetNORMALMAP2( bool i ) + { + m_nNORMALMAP2 = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } +private: + int m_nWORLDVERTEXTRANSITION; +#ifdef _DEBUG + bool m_bWORLDVERTEXTRANSITION; +#endif +public: + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } + void SetWORLDVERTEXTRANSITION( bool i ) + { + m_nWORLDVERTEXTRANSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } +private: + int m_nFANCY_BLENDING; +#ifdef _DEBUG + bool m_bFANCY_BLENDING; +#endif +public: + void SetFANCY_BLENDING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFANCY_BLENDING = i; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif + } + void SetFANCY_BLENDING( bool i ) + { + m_nFANCY_BLENDING = i ? 1 : 0; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +private: + int m_nPHONG; +#ifdef _DEBUG + bool m_bPHONG; +#endif +public: + void SetPHONG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONG = i; +#ifdef _DEBUG + m_bPHONG = true; +#endif + } + void SetPHONG( bool i ) + { + m_nPHONG = i ? 1 : 0; +#ifdef _DEBUG + m_bPHONG = true; +#endif + } +private: + int m_nPHONGMASK; +#ifdef _DEBUG + bool m_bPHONGMASK; +#endif +public: + void SetPHONGMASK( int i ) + { + Assert( i >= 0 && i <= 3 ); + m_nPHONGMASK = i; +#ifdef _DEBUG + m_bPHONGMASK = true; +#endif + } + void SetPHONGMASK( bool i ) + { + m_nPHONGMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bPHONGMASK = true; +#endif + } +private: + int m_nBASETEXTURETRANSFORM2; +#ifdef _DEBUG + bool m_bBASETEXTURETRANSFORM2; +#endif +public: + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } + void SetBASETEXTURETRANSFORM2( bool i ) + { + m_nBASETEXTURETRANSFORM2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bNORMALMAP = false; +#endif // _DEBUG + m_nNORMALMAP = 0; +#ifdef _DEBUG + m_bNORMALMAP2 = false; +#endif // _DEBUG + m_nNORMALMAP2 = 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = false; +#endif // _DEBUG + m_nWORLDVERTEXTRANSITION = 0; +#ifdef _DEBUG + m_bFANCY_BLENDING = false; +#endif // _DEBUG + m_nFANCY_BLENDING = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; +#ifdef _DEBUG + m_bPHONG = false; +#endif // _DEBUG + m_nPHONG = 0; +#ifdef _DEBUG + m_bPHONGMASK = false; +#endif // _DEBUG + m_nPHONGMASK = 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + m_nBASETEXTURETRANSFORM2 = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bNORMALMAP && m_bNORMALMAP2 && m_bWORLDVERTEXTRANSITION && m_bFANCY_BLENDING && m_bSEAMLESS && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bFLASHLIGHTDEPTHFILTERMODE && m_bPHONG && m_bPHONGMASK && m_bBASETEXTURETRANSFORM2; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nNORMALMAP ) + ( 12 * m_nNORMALMAP2 ) + ( 24 * m_nWORLDVERTEXTRANSITION ) + ( 48 * m_nFANCY_BLENDING ) + ( 96 * m_nSEAMLESS ) + ( 192 * m_nDETAILTEXTURE ) + ( 384 * m_nDETAIL_BLEND_MODE ) + ( 768 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 2304 * m_nPHONG ) + ( 4608 * m_nPHONGMASK ) + ( 18432 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_flashlight_ps20b psh_forgot_to_set_static_NORMALMAP + psh_forgot_to_set_static_NORMALMAP2 + psh_forgot_to_set_static_WORLDVERTEXTRANSITION + psh_forgot_to_set_static_FANCY_BLENDING + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_PHONG + psh_forgot_to_set_static_PHONGMASK + psh_forgot_to_set_static_BASETEXTURETRANSFORM2 + 0 +class sdk_lightmappedgeneric_flashlight_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_flashlight_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_flashlight_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_flashlight_ps30.inc new file mode 100644 index 00000000..a9734f15 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_flashlight_ps30.inc @@ -0,0 +1,362 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_flashlight_ps30_Static_Index +{ +private: + int m_nNORMALMAP; +#ifdef _DEBUG + bool m_bNORMALMAP; +#endif +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } + void SetNORMALMAP( bool i ) + { + m_nNORMALMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } +private: + int m_nNORMALMAP2; +#ifdef _DEBUG + bool m_bNORMALMAP2; +#endif +public: + void SetNORMALMAP2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP2 = i; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } + void SetNORMALMAP2( bool i ) + { + m_nNORMALMAP2 = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif + } +private: + int m_nWORLDVERTEXTRANSITION; +#ifdef _DEBUG + bool m_bWORLDVERTEXTRANSITION; +#endif +public: + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } + void SetWORLDVERTEXTRANSITION( bool i ) + { + m_nWORLDVERTEXTRANSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } +private: + int m_nFANCY_BLENDING; +#ifdef _DEBUG + bool m_bFANCY_BLENDING; +#endif +public: + void SetFANCY_BLENDING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFANCY_BLENDING = i; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif + } + void SetFANCY_BLENDING( bool i ) + { + m_nFANCY_BLENDING = i ? 1 : 0; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +private: + int m_nPHONG; +#ifdef _DEBUG + bool m_bPHONG; +#endif +public: + void SetPHONG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONG = i; +#ifdef _DEBUG + m_bPHONG = true; +#endif + } + void SetPHONG( bool i ) + { + m_nPHONG = i ? 1 : 0; +#ifdef _DEBUG + m_bPHONG = true; +#endif + } +private: + int m_nPHONGMASK; +#ifdef _DEBUG + bool m_bPHONGMASK; +#endif +public: + void SetPHONGMASK( int i ) + { + Assert( i >= 0 && i <= 3 ); + m_nPHONGMASK = i; +#ifdef _DEBUG + m_bPHONGMASK = true; +#endif + } + void SetPHONGMASK( bool i ) + { + m_nPHONGMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bPHONGMASK = true; +#endif + } +private: + int m_nBASETEXTURETRANSFORM2; +#ifdef _DEBUG + bool m_bBASETEXTURETRANSFORM2; +#endif +public: + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } + void SetBASETEXTURETRANSFORM2( bool i ) + { + m_nBASETEXTURETRANSFORM2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bNORMALMAP = false; +#endif // _DEBUG + m_nNORMALMAP = 0; +#ifdef _DEBUG + m_bNORMALMAP2 = false; +#endif // _DEBUG + m_nNORMALMAP2 = 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = false; +#endif // _DEBUG + m_nWORLDVERTEXTRANSITION = 0; +#ifdef _DEBUG + m_bFANCY_BLENDING = false; +#endif // _DEBUG + m_nFANCY_BLENDING = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; +#ifdef _DEBUG + m_bPHONG = false; +#endif // _DEBUG + m_nPHONG = 0; +#ifdef _DEBUG + m_bPHONGMASK = false; +#endif // _DEBUG + m_nPHONGMASK = 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + m_nBASETEXTURETRANSFORM2 = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bNORMALMAP && m_bNORMALMAP2 && m_bWORLDVERTEXTRANSITION && m_bFANCY_BLENDING && m_bSEAMLESS && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bFLASHLIGHTDEPTHFILTERMODE && m_bPHONG && m_bPHONGMASK && m_bBASETEXTURETRANSFORM2; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nNORMALMAP ) + ( 12 * m_nNORMALMAP2 ) + ( 24 * m_nWORLDVERTEXTRANSITION ) + ( 48 * m_nFANCY_BLENDING ) + ( 96 * m_nSEAMLESS ) + ( 192 * m_nDETAILTEXTURE ) + ( 384 * m_nDETAIL_BLEND_MODE ) + ( 768 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 2304 * m_nPHONG ) + ( 4608 * m_nPHONGMASK ) + ( 18432 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_flashlight_ps30 psh_forgot_to_set_static_NORMALMAP + psh_forgot_to_set_static_NORMALMAP2 + psh_forgot_to_set_static_WORLDVERTEXTRANSITION + psh_forgot_to_set_static_FANCY_BLENDING + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_PHONG + psh_forgot_to_set_static_PHONGMASK + psh_forgot_to_set_static_BASETEXTURETRANSFORM2 + 0 +class sdk_lightmappedgeneric_flashlight_ps30_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_flashlight_ps30 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_flashlight_vs11.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_flashlight_vs11.inc new file mode 100644 index 00000000..94142c09 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_flashlight_vs11.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_flashlight_vs11_Static_Index +{ +private: + int m_nNORMALMAP; +#ifdef _DEBUG + bool m_bNORMALMAP; +#endif +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } + void SetNORMALMAP( bool i ) + { + m_nNORMALMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } +private: + int m_nWORLDVERTEXTRANSITION; +#ifdef _DEBUG + bool m_bWORLDVERTEXTRANSITION; +#endif +public: + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } + void SetWORLDVERTEXTRANSITION( bool i ) + { + m_nWORLDVERTEXTRANSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_vs11_Static_Index( ) + { +#ifdef _DEBUG + m_bNORMALMAP = false; +#endif // _DEBUG + m_nNORMALMAP = 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = false; +#endif // _DEBUG + m_nWORLDVERTEXTRANSITION = 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bNORMALMAP && m_bWORLDVERTEXTRANSITION && m_bVERTEXCOLOR; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nNORMALMAP ) + ( 4 * m_nWORLDVERTEXTRANSITION ) + ( 8 * m_nVERTEXCOLOR ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_flashlight_vs11 vsh_forgot_to_set_static_NORMALMAP + vsh_forgot_to_set_static_WORLDVERTEXTRANSITION + vsh_forgot_to_set_static_VERTEXCOLOR + 0 +class sdk_lightmappedgeneric_flashlight_vs11_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_vs11_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_flashlight_vs11 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_flashlight_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_flashlight_vs20.inc new file mode 100644 index 00000000..95edefe2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_flashlight_vs20.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_flashlight_vs20_Static_Index +{ +private: + int m_nNORMALMAP; +#ifdef _DEBUG + bool m_bNORMALMAP; +#endif +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } + void SetNORMALMAP( bool i ) + { + m_nNORMALMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } +private: + int m_nWORLDVERTEXTRANSITION; +#ifdef _DEBUG + bool m_bWORLDVERTEXTRANSITION; +#endif +public: + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } + void SetWORLDVERTEXTRANSITION( bool i ) + { + m_nWORLDVERTEXTRANSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nDETAIL; +#ifdef _DEBUG + bool m_bDETAIL; +#endif +public: + void SetDETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL = i; +#ifdef _DEBUG + m_bDETAIL = true; +#endif + } + void SetDETAIL( bool i ) + { + m_nDETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL = true; +#endif + } +private: + int m_nPHONG; +#ifdef _DEBUG + bool m_bPHONG; +#endif +public: + void SetPHONG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONG = i; +#ifdef _DEBUG + m_bPHONG = true; +#endif + } + void SetPHONG( bool i ) + { + m_nPHONG = i ? 1 : 0; +#ifdef _DEBUG + m_bPHONG = true; +#endif + } +private: + int m_nBASETEXTURETRANSFORM2; +#ifdef _DEBUG + bool m_bBASETEXTURETRANSFORM2; +#endif +public: + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } + void SetBASETEXTURETRANSFORM2( bool i ) + { + m_nBASETEXTURETRANSFORM2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bNORMALMAP = false; +#endif // _DEBUG + m_nNORMALMAP = 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = false; +#endif // _DEBUG + m_nWORLDVERTEXTRANSITION = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bDETAIL = false; +#endif // _DEBUG + m_nDETAIL = 0; +#ifdef _DEBUG + m_bPHONG = false; +#endif // _DEBUG + m_nPHONG = 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + m_nBASETEXTURETRANSFORM2 = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bNORMALMAP && m_bWORLDVERTEXTRANSITION && m_bSEAMLESS && m_bDETAIL && m_bPHONG && m_bBASETEXTURETRANSFORM2; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nNORMALMAP ) + ( 4 * m_nWORLDVERTEXTRANSITION ) + ( 8 * m_nSEAMLESS ) + ( 16 * m_nDETAIL ) + ( 32 * m_nPHONG ) + ( 64 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_flashlight_vs20 vsh_forgot_to_set_static_NORMALMAP + vsh_forgot_to_set_static_WORLDVERTEXTRANSITION + vsh_forgot_to_set_static_SEAMLESS + vsh_forgot_to_set_static_DETAIL + vsh_forgot_to_set_static_PHONG + vsh_forgot_to_set_static_BASETEXTURETRANSFORM2 + 0 +class sdk_lightmappedgeneric_flashlight_vs20_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_flashlight_vs20 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_flashlight_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_flashlight_vs30.inc new file mode 100644 index 00000000..376110e3 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_flashlight_vs30.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_flashlight_vs30_Static_Index +{ +private: + int m_nNORMALMAP; +#ifdef _DEBUG + bool m_bNORMALMAP; +#endif +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } + void SetNORMALMAP( bool i ) + { + m_nNORMALMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif + } +private: + int m_nWORLDVERTEXTRANSITION; +#ifdef _DEBUG + bool m_bWORLDVERTEXTRANSITION; +#endif +public: + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } + void SetWORLDVERTEXTRANSITION( bool i ) + { + m_nWORLDVERTEXTRANSITION = i ? 1 : 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nDETAIL; +#ifdef _DEBUG + bool m_bDETAIL; +#endif +public: + void SetDETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL = i; +#ifdef _DEBUG + m_bDETAIL = true; +#endif + } + void SetDETAIL( bool i ) + { + m_nDETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL = true; +#endif + } +private: + int m_nPHONG; +#ifdef _DEBUG + bool m_bPHONG; +#endif +public: + void SetPHONG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONG = i; +#ifdef _DEBUG + m_bPHONG = true; +#endif + } + void SetPHONG( bool i ) + { + m_nPHONG = i ? 1 : 0; +#ifdef _DEBUG + m_bPHONG = true; +#endif + } +private: + int m_nBASETEXTURETRANSFORM2; +#ifdef _DEBUG + bool m_bBASETEXTURETRANSFORM2; +#endif +public: + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } + void SetBASETEXTURETRANSFORM2( bool i ) + { + m_nBASETEXTURETRANSFORM2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bNORMALMAP = false; +#endif // _DEBUG + m_nNORMALMAP = 0; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = false; +#endif // _DEBUG + m_nWORLDVERTEXTRANSITION = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bDETAIL = false; +#endif // _DEBUG + m_nDETAIL = 0; +#ifdef _DEBUG + m_bPHONG = false; +#endif // _DEBUG + m_nPHONG = 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + m_nBASETEXTURETRANSFORM2 = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bNORMALMAP && m_bWORLDVERTEXTRANSITION && m_bSEAMLESS && m_bDETAIL && m_bPHONG && m_bBASETEXTURETRANSFORM2; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nNORMALMAP ) + ( 4 * m_nWORLDVERTEXTRANSITION ) + ( 8 * m_nSEAMLESS ) + ( 16 * m_nDETAIL ) + ( 32 * m_nPHONG ) + ( 64 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_flashlight_vs30 vsh_forgot_to_set_static_NORMALMAP + vsh_forgot_to_set_static_WORLDVERTEXTRANSITION + vsh_forgot_to_set_static_SEAMLESS + vsh_forgot_to_set_static_DETAIL + vsh_forgot_to_set_static_PHONG + vsh_forgot_to_set_static_BASETEXTURETRANSFORM2 + 0 +class sdk_lightmappedgeneric_flashlight_vs30_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_lightmappedgeneric_flashlight_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_flashlight_vs30 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_lightingonly_overbright2_ps11.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_lightingonly_overbright2_ps11.inc new file mode 100644 index 00000000..d11eaeb9 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_lightingonly_overbright2_ps11.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_lightingonly_overbright2_ps11_Static_Index +{ +public: + sdk_lightmappedgeneric_lightingonly_overbright2_ps11_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_lightingonly_overbright2_ps11 0 +class sdk_lightmappedgeneric_lightingonly_overbright2_ps11_Dynamic_Index +{ +public: + sdk_lightmappedgeneric_lightingonly_overbright2_ps11_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_lightingonly_overbright2_ps11 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_lightingonly_vs11.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_lightingonly_vs11.inc new file mode 100644 index 00000000..5bb3dc94 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_lightingonly_vs11.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_lightingonly_vs11_Static_Index +{ +public: + sdk_lightmappedgeneric_lightingonly_vs11_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_lightingonly_vs11 0 +class sdk_lightmappedgeneric_lightingonly_vs11_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_lightmappedgeneric_lightingonly_vs11_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_lightingonly_vs11 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_ps11.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_ps11.inc new file mode 100644 index 00000000..30f358a1 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_ps11.inc @@ -0,0 +1,160 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_ps11_Static_Index +{ +private: + int m_nBASETEXTURE; +#ifdef _DEBUG + bool m_bBASETEXTURE; +#endif +public: + void SetBASETEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE = i; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } + void SetBASETEXTURE( bool i ) + { + m_nBASETEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } +private: + int m_nENVMAP; +#ifdef _DEBUG + bool m_bENVMAP; +#endif +public: + void SetENVMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAP = i; +#ifdef _DEBUG + m_bENVMAP = true; +#endif + } + void SetENVMAP( bool i ) + { + m_nENVMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAP = true; +#endif + } +private: + int m_nENVMAPMASK; +#ifdef _DEBUG + bool m_bENVMAPMASK; +#endif +public: + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } + void SetENVMAPMASK( bool i ) + { + m_nENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nBASEALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bBASEALPHAENVMAPMASK; +#endif +public: + void SetBASEALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASEALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } + void SetBASEALPHAENVMAPMASK( bool i ) + { + m_nBASEALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } +public: + sdk_lightmappedgeneric_ps11_Static_Index( ) + { +#ifdef _DEBUG + m_bBASETEXTURE = false; +#endif // _DEBUG + m_nBASETEXTURE = 0; +#ifdef _DEBUG + m_bENVMAP = false; +#endif // _DEBUG + m_nENVMAP = 0; +#ifdef _DEBUG + m_bENVMAPMASK = false; +#endif // _DEBUG + m_nENVMAPMASK = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nBASEALPHAENVMAPMASK = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bBASETEXTURE && m_bENVMAP && m_bENVMAPMASK && m_bSELFILLUM && m_bBASEALPHAENVMAPMASK; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nBASETEXTURE ) + ( 2 * m_nENVMAP ) + ( 4 * m_nENVMAPMASK ) + ( 8 * m_nSELFILLUM ) + ( 16 * m_nBASEALPHAENVMAPMASK ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_ps11 psh_forgot_to_set_static_BASETEXTURE + psh_forgot_to_set_static_ENVMAP + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + 0 +class sdk_lightmappedgeneric_ps11_Dynamic_Index +{ +public: + sdk_lightmappedgeneric_ps11_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_ps11 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_ps20b.inc new file mode 100644 index 00000000..0a321f16 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_ps20b.inc @@ -0,0 +1,712 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_ps20b_Static_Index +{ +private: + int m_nMASKEDBLENDING; +#ifdef _DEBUG + bool m_bMASKEDBLENDING; +#endif +public: + void SetMASKEDBLENDING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMASKEDBLENDING = i; +#ifdef _DEBUG + m_bMASKEDBLENDING = true; +#endif + } + void SetMASKEDBLENDING( bool i ) + { + m_nMASKEDBLENDING = i ? 1 : 0; +#ifdef _DEBUG + m_bMASKEDBLENDING = true; +#endif + } +private: + int m_nBASETEXTURE2; +#ifdef _DEBUG + bool m_bBASETEXTURE2; +#endif +public: + void SetBASETEXTURE2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE2 = i; +#ifdef _DEBUG + m_bBASETEXTURE2 = true; +#endif + } + void SetBASETEXTURE2( bool i ) + { + m_nBASETEXTURE2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE2 = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +private: + int m_nBUMPMAP2; +#ifdef _DEBUG + bool m_bBUMPMAP2; +#endif +public: + void SetBUMPMAP2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP2 = i; +#ifdef _DEBUG + m_bBUMPMAP2 = true; +#endif + } + void SetBUMPMAP2( bool i ) + { + m_nBUMPMAP2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP2 = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nENVMAPMASK; +#ifdef _DEBUG + bool m_bENVMAPMASK; +#endif +public: + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } + void SetENVMAPMASK( bool i ) + { + m_nENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } +private: + int m_nBASEALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bBASEALPHAENVMAPMASK; +#endif +public: + void SetBASEALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASEALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } + void SetBASEALPHAENVMAPMASK( bool i ) + { + m_nBASEALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nNORMALMAPALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bNORMALMAPALPHAENVMAPMASK; +#endif +public: + void SetNORMALMAPALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAPALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif + } + void SetNORMALMAPALPHAENVMAPMASK( bool i ) + { + m_nNORMALMAPALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif + } +private: + int m_nDIFFUSEBUMPMAP; +#ifdef _DEBUG + bool m_bDIFFUSEBUMPMAP; +#endif +public: + void SetDIFFUSEBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSEBUMPMAP = i; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } + void SetDIFFUSEBUMPMAP( bool i ) + { + m_nDIFFUSEBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } +private: + int m_nBASETEXTURENOENVMAP; +#ifdef _DEBUG + bool m_bBASETEXTURENOENVMAP; +#endif +public: + void SetBASETEXTURENOENVMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURENOENVMAP = i; +#ifdef _DEBUG + m_bBASETEXTURENOENVMAP = true; +#endif + } + void SetBASETEXTURENOENVMAP( bool i ) + { + m_nBASETEXTURENOENVMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURENOENVMAP = true; +#endif + } +private: + int m_nBASETEXTURE2NOENVMAP; +#ifdef _DEBUG + bool m_bBASETEXTURE2NOENVMAP; +#endif +public: + void SetBASETEXTURE2NOENVMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE2NOENVMAP = i; +#ifdef _DEBUG + m_bBASETEXTURE2NOENVMAP = true; +#endif + } + void SetBASETEXTURE2NOENVMAP( bool i ) + { + m_nBASETEXTURE2NOENVMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE2NOENVMAP = true; +#endif + } +private: + int m_nWARPLIGHTING; +#ifdef _DEBUG + bool m_bWARPLIGHTING; +#endif +public: + void SetWARPLIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWARPLIGHTING = i; +#ifdef _DEBUG + m_bWARPLIGHTING = true; +#endif + } + void SetWARPLIGHTING( bool i ) + { + m_nWARPLIGHTING = i ? 1 : 0; +#ifdef _DEBUG + m_bWARPLIGHTING = true; +#endif + } +private: + int m_nFANCY_BLENDING; +#ifdef _DEBUG + bool m_bFANCY_BLENDING; +#endif +public: + void SetFANCY_BLENDING( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFANCY_BLENDING = i; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif + } + void SetFANCY_BLENDING( bool i ) + { + m_nFANCY_BLENDING = i ? 1 : 0; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif + } +private: + int m_nRELIEF_MAPPING; +#ifdef _DEBUG + bool m_bRELIEF_MAPPING; +#endif +public: + void SetRELIEF_MAPPING( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nRELIEF_MAPPING = i; +#ifdef _DEBUG + m_bRELIEF_MAPPING = true; +#endif + } + void SetRELIEF_MAPPING( bool i ) + { + m_nRELIEF_MAPPING = i ? 1 : 0; +#ifdef _DEBUG + m_bRELIEF_MAPPING = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nNORMAL_DECODE_MODE; +#ifdef _DEBUG + bool m_bNORMAL_DECODE_MODE; +#endif +public: + void SetNORMAL_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMAL_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } + void SetNORMAL_DECODE_MODE( bool i ) + { + m_nNORMAL_DECODE_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } +private: + int m_nNORMALMASK_DECODE_MODE; +#ifdef _DEBUG + bool m_bNORMALMASK_DECODE_MODE; +#endif +public: + void SetNORMALMASK_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMALMASK_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMALMASK_DECODE_MODE = true; +#endif + } + void SetNORMALMASK_DECODE_MODE( bool i ) + { + m_nNORMALMASK_DECODE_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMASK_DECODE_MODE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 11 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nBASETEXTURETRANSFORM2; +#ifdef _DEBUG + bool m_bBASETEXTURETRANSFORM2; +#endif +public: + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } + void SetBASETEXTURETRANSFORM2( bool i ) + { + m_nBASETEXTURETRANSFORM2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } +public: + sdk_lightmappedgeneric_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bMASKEDBLENDING = false; +#endif // _DEBUG + m_nMASKEDBLENDING = 0; +#ifdef _DEBUG + m_bBASETEXTURE2 = false; +#endif // _DEBUG + m_nBASETEXTURE2 = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; +#ifdef _DEBUG + m_bBUMPMAP2 = false; +#endif // _DEBUG + m_nBUMPMAP2 = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bENVMAPMASK = false; +#endif // _DEBUG + m_nENVMAPMASK = 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nBASEALPHAENVMAPMASK = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nNORMALMAPALPHAENVMAPMASK = 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = false; +#endif // _DEBUG + m_nDIFFUSEBUMPMAP = 0; +#ifdef _DEBUG + m_bBASETEXTURENOENVMAP = false; +#endif // _DEBUG + m_nBASETEXTURENOENVMAP = 0; +#ifdef _DEBUG + m_bBASETEXTURE2NOENVMAP = false; +#endif // _DEBUG + m_nBASETEXTURE2NOENVMAP = 0; +#ifdef _DEBUG + m_bWARPLIGHTING = false; +#endif // _DEBUG + m_nWARPLIGHTING = 0; +#ifdef _DEBUG + m_bFANCY_BLENDING = false; +#endif // _DEBUG + m_nFANCY_BLENDING = 0; +#ifdef _DEBUG + m_bRELIEF_MAPPING = false; +#endif // _DEBUG + m_nRELIEF_MAPPING = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = false; +#endif // _DEBUG + m_nNORMAL_DECODE_MODE = 0; +#ifdef _DEBUG + m_bNORMALMASK_DECODE_MODE = false; +#endif // _DEBUG + m_nNORMALMASK_DECODE_MODE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + m_nBASETEXTURETRANSFORM2 = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bMASKEDBLENDING && m_bBASETEXTURE2 && m_bDETAILTEXTURE && m_bBUMPMAP && m_bBUMPMAP2 && m_bCUBEMAP && m_bENVMAPMASK && m_bBASEALPHAENVMAPMASK && m_bSELFILLUM && m_bNORMALMAPALPHAENVMAPMASK && m_bDIFFUSEBUMPMAP && m_bBASETEXTURENOENVMAP && m_bBASETEXTURE2NOENVMAP && m_bWARPLIGHTING && m_bFANCY_BLENDING && m_bRELIEF_MAPPING && m_bSEAMLESS && m_bNORMAL_DECODE_MODE && m_bNORMALMASK_DECODE_MODE && m_bDETAIL_BLEND_MODE && m_bBASETEXTURETRANSFORM2; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 96 * m_nMASKEDBLENDING ) + ( 192 * m_nBASETEXTURE2 ) + ( 384 * m_nDETAILTEXTURE ) + ( 768 * m_nBUMPMAP ) + ( 2304 * m_nBUMPMAP2 ) + ( 4608 * m_nCUBEMAP ) + ( 9216 * m_nENVMAPMASK ) + ( 18432 * m_nBASEALPHAENVMAPMASK ) + ( 36864 * m_nSELFILLUM ) + ( 73728 * m_nNORMALMAPALPHAENVMAPMASK ) + ( 147456 * m_nDIFFUSEBUMPMAP ) + ( 294912 * m_nBASETEXTURENOENVMAP ) + ( 589824 * m_nBASETEXTURE2NOENVMAP ) + ( 1179648 * m_nWARPLIGHTING ) + ( 2359296 * m_nFANCY_BLENDING ) + ( 7077888 * m_nRELIEF_MAPPING ) + ( 7077888 * m_nSEAMLESS ) + ( 14155776 * m_nNORMAL_DECODE_MODE ) + ( 14155776 * m_nNORMALMASK_DECODE_MODE ) + ( 14155776 * m_nDETAIL_BLEND_MODE ) + ( 169869312 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_ps20b psh_forgot_to_set_static_MASKEDBLENDING + psh_forgot_to_set_static_BASETEXTURE2 + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_BUMPMAP + psh_forgot_to_set_static_BUMPMAP2 + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_DIFFUSEBUMPMAP + psh_forgot_to_set_static_BASETEXTURENOENVMAP + psh_forgot_to_set_static_BASETEXTURE2NOENVMAP + psh_forgot_to_set_static_WARPLIGHTING + psh_forgot_to_set_static_FANCY_BLENDING + psh_forgot_to_set_static_RELIEF_MAPPING + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_NORMAL_DECODE_MODE + psh_forgot_to_set_static_NORMALMASK_DECODE_MODE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_BASETEXTURETRANSFORM2 + 0 +class sdk_lightmappedgeneric_ps20b_Dynamic_Index +{ +private: + int m_nFASTPATHENVMAPCONTRAST; +#ifdef _DEBUG + bool m_bFASTPATHENVMAPCONTRAST; +#endif +public: + void SetFASTPATHENVMAPCONTRAST( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFASTPATHENVMAPCONTRAST = i; +#ifdef _DEBUG + m_bFASTPATHENVMAPCONTRAST = true; +#endif + } + void SetFASTPATHENVMAPCONTRAST( bool i ) + { + m_nFASTPATHENVMAPCONTRAST = i ? 1 : 0; +#ifdef _DEBUG + m_bFASTPATHENVMAPCONTRAST = true; +#endif + } +private: + int m_nFASTPATH; +#ifdef _DEBUG + bool m_bFASTPATH; +#endif +public: + void SetFASTPATH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFASTPATH = i; +#ifdef _DEBUG + m_bFASTPATH = true; +#endif + } + void SetFASTPATH( bool i ) + { + m_nFASTPATH = i ? 1 : 0; +#ifdef _DEBUG + m_bFASTPATH = true; +#endif + } +private: + int m_nWRITEWATERFOGTODESTALPHA; +#ifdef _DEBUG + bool m_bWRITEWATERFOGTODESTALPHA; +#endif +public: + void SetWRITEWATERFOGTODESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITEWATERFOGTODESTALPHA = i; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } + void SetWRITEWATERFOGTODESTALPHA( bool i ) + { + m_nWRITEWATERFOGTODESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +public: + sdk_lightmappedgeneric_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bFASTPATHENVMAPCONTRAST = false; +#endif // _DEBUG + m_nFASTPATHENVMAPCONTRAST = 0; +#ifdef _DEBUG + m_bFASTPATH = false; +#endif // _DEBUG + m_nFASTPATH = 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = false; +#endif // _DEBUG + m_nWRITEWATERFOGTODESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bFASTPATHENVMAPCONTRAST && m_bFASTPATH && m_bWRITEWATERFOGTODESTALPHA && m_bPIXELFOGTYPE && m_bLIGHTING_PREVIEW && m_bWRITE_DEPTH_TO_DESTALPHA; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nFASTPATHENVMAPCONTRAST ) + ( 2 * m_nFASTPATH ) + ( 4 * m_nWRITEWATERFOGTODESTALPHA ) + ( 8 * m_nPIXELFOGTYPE ) + ( 16 * m_nLIGHTING_PREVIEW ) + ( 48 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_ps20b psh_forgot_to_set_dynamic_FASTPATHENVMAPCONTRAST + psh_forgot_to_set_dynamic_FASTPATH + psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_LIGHTING_PREVIEW + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_ps30.inc new file mode 100644 index 00000000..c291836f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_ps30.inc @@ -0,0 +1,687 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_ps30_Static_Index +{ +private: + int m_nMASKEDBLENDING; +#ifdef _DEBUG + bool m_bMASKEDBLENDING; +#endif +public: + void SetMASKEDBLENDING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMASKEDBLENDING = i; +#ifdef _DEBUG + m_bMASKEDBLENDING = true; +#endif + } + void SetMASKEDBLENDING( bool i ) + { + m_nMASKEDBLENDING = i ? 1 : 0; +#ifdef _DEBUG + m_bMASKEDBLENDING = true; +#endif + } +private: + int m_nBASETEXTURE2; +#ifdef _DEBUG + bool m_bBASETEXTURE2; +#endif +public: + void SetBASETEXTURE2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE2 = i; +#ifdef _DEBUG + m_bBASETEXTURE2 = true; +#endif + } + void SetBASETEXTURE2( bool i ) + { + m_nBASETEXTURE2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE2 = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +private: + int m_nBUMPMAP2; +#ifdef _DEBUG + bool m_bBUMPMAP2; +#endif +public: + void SetBUMPMAP2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP2 = i; +#ifdef _DEBUG + m_bBUMPMAP2 = true; +#endif + } + void SetBUMPMAP2( bool i ) + { + m_nBUMPMAP2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP2 = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nENVMAPMASK; +#ifdef _DEBUG + bool m_bENVMAPMASK; +#endif +public: + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } + void SetENVMAPMASK( bool i ) + { + m_nENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } +private: + int m_nBASEALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bBASEALPHAENVMAPMASK; +#endif +public: + void SetBASEALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASEALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } + void SetBASEALPHAENVMAPMASK( bool i ) + { + m_nBASEALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nNORMALMAPALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bNORMALMAPALPHAENVMAPMASK; +#endif +public: + void SetNORMALMAPALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAPALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif + } + void SetNORMALMAPALPHAENVMAPMASK( bool i ) + { + m_nNORMALMAPALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif + } +private: + int m_nDIFFUSEBUMPMAP; +#ifdef _DEBUG + bool m_bDIFFUSEBUMPMAP; +#endif +public: + void SetDIFFUSEBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSEBUMPMAP = i; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } + void SetDIFFUSEBUMPMAP( bool i ) + { + m_nDIFFUSEBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } +private: + int m_nBASETEXTURENOENVMAP; +#ifdef _DEBUG + bool m_bBASETEXTURENOENVMAP; +#endif +public: + void SetBASETEXTURENOENVMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURENOENVMAP = i; +#ifdef _DEBUG + m_bBASETEXTURENOENVMAP = true; +#endif + } + void SetBASETEXTURENOENVMAP( bool i ) + { + m_nBASETEXTURENOENVMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURENOENVMAP = true; +#endif + } +private: + int m_nBASETEXTURE2NOENVMAP; +#ifdef _DEBUG + bool m_bBASETEXTURE2NOENVMAP; +#endif +public: + void SetBASETEXTURE2NOENVMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE2NOENVMAP = i; +#ifdef _DEBUG + m_bBASETEXTURE2NOENVMAP = true; +#endif + } + void SetBASETEXTURE2NOENVMAP( bool i ) + { + m_nBASETEXTURE2NOENVMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE2NOENVMAP = true; +#endif + } +private: + int m_nWARPLIGHTING; +#ifdef _DEBUG + bool m_bWARPLIGHTING; +#endif +public: + void SetWARPLIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWARPLIGHTING = i; +#ifdef _DEBUG + m_bWARPLIGHTING = true; +#endif + } + void SetWARPLIGHTING( bool i ) + { + m_nWARPLIGHTING = i ? 1 : 0; +#ifdef _DEBUG + m_bWARPLIGHTING = true; +#endif + } +private: + int m_nFANCY_BLENDING; +#ifdef _DEBUG + bool m_bFANCY_BLENDING; +#endif +public: + void SetFANCY_BLENDING( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFANCY_BLENDING = i; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif + } + void SetFANCY_BLENDING( bool i ) + { + m_nFANCY_BLENDING = i ? 1 : 0; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nNORMAL_DECODE_MODE; +#ifdef _DEBUG + bool m_bNORMAL_DECODE_MODE; +#endif +public: + void SetNORMAL_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMAL_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } + void SetNORMAL_DECODE_MODE( bool i ) + { + m_nNORMAL_DECODE_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } +private: + int m_nNORMALMASK_DECODE_MODE; +#ifdef _DEBUG + bool m_bNORMALMASK_DECODE_MODE; +#endif +public: + void SetNORMALMASK_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMALMASK_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMALMASK_DECODE_MODE = true; +#endif + } + void SetNORMALMASK_DECODE_MODE( bool i ) + { + m_nNORMALMASK_DECODE_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMASK_DECODE_MODE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 11 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nBASETEXTURETRANSFORM2; +#ifdef _DEBUG + bool m_bBASETEXTURETRANSFORM2; +#endif +public: + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } + void SetBASETEXTURETRANSFORM2( bool i ) + { + m_nBASETEXTURETRANSFORM2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } +public: + sdk_lightmappedgeneric_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bMASKEDBLENDING = false; +#endif // _DEBUG + m_nMASKEDBLENDING = 0; +#ifdef _DEBUG + m_bBASETEXTURE2 = false; +#endif // _DEBUG + m_nBASETEXTURE2 = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; +#ifdef _DEBUG + m_bBUMPMAP2 = false; +#endif // _DEBUG + m_nBUMPMAP2 = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bENVMAPMASK = false; +#endif // _DEBUG + m_nENVMAPMASK = 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nBASEALPHAENVMAPMASK = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nNORMALMAPALPHAENVMAPMASK = 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = false; +#endif // _DEBUG + m_nDIFFUSEBUMPMAP = 0; +#ifdef _DEBUG + m_bBASETEXTURENOENVMAP = false; +#endif // _DEBUG + m_nBASETEXTURENOENVMAP = 0; +#ifdef _DEBUG + m_bBASETEXTURE2NOENVMAP = false; +#endif // _DEBUG + m_nBASETEXTURE2NOENVMAP = 0; +#ifdef _DEBUG + m_bWARPLIGHTING = false; +#endif // _DEBUG + m_nWARPLIGHTING = 0; +#ifdef _DEBUG + m_bFANCY_BLENDING = false; +#endif // _DEBUG + m_nFANCY_BLENDING = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = false; +#endif // _DEBUG + m_nNORMAL_DECODE_MODE = 0; +#ifdef _DEBUG + m_bNORMALMASK_DECODE_MODE = false; +#endif // _DEBUG + m_nNORMALMASK_DECODE_MODE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + m_nBASETEXTURETRANSFORM2 = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bMASKEDBLENDING && m_bBASETEXTURE2 && m_bDETAILTEXTURE && m_bBUMPMAP && m_bBUMPMAP2 && m_bCUBEMAP && m_bENVMAPMASK && m_bBASEALPHAENVMAPMASK && m_bSELFILLUM && m_bNORMALMAPALPHAENVMAPMASK && m_bDIFFUSEBUMPMAP && m_bBASETEXTURENOENVMAP && m_bBASETEXTURE2NOENVMAP && m_bWARPLIGHTING && m_bFANCY_BLENDING && m_bSEAMLESS && m_bNORMAL_DECODE_MODE && m_bNORMALMASK_DECODE_MODE && m_bDETAIL_BLEND_MODE && m_bBASETEXTURETRANSFORM2; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 96 * m_nMASKEDBLENDING ) + ( 192 * m_nBASETEXTURE2 ) + ( 384 * m_nDETAILTEXTURE ) + ( 768 * m_nBUMPMAP ) + ( 2304 * m_nBUMPMAP2 ) + ( 4608 * m_nCUBEMAP ) + ( 9216 * m_nENVMAPMASK ) + ( 18432 * m_nBASEALPHAENVMAPMASK ) + ( 36864 * m_nSELFILLUM ) + ( 73728 * m_nNORMALMAPALPHAENVMAPMASK ) + ( 147456 * m_nDIFFUSEBUMPMAP ) + ( 294912 * m_nBASETEXTURENOENVMAP ) + ( 589824 * m_nBASETEXTURE2NOENVMAP ) + ( 1179648 * m_nWARPLIGHTING ) + ( 2359296 * m_nFANCY_BLENDING ) + ( 7077888 * m_nSEAMLESS ) + ( 14155776 * m_nNORMAL_DECODE_MODE ) + ( 14155776 * m_nNORMALMASK_DECODE_MODE ) + ( 14155776 * m_nDETAIL_BLEND_MODE ) + ( 169869312 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_ps30 psh_forgot_to_set_static_MASKEDBLENDING + psh_forgot_to_set_static_BASETEXTURE2 + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_BUMPMAP + psh_forgot_to_set_static_BUMPMAP2 + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_DIFFUSEBUMPMAP + psh_forgot_to_set_static_BASETEXTURENOENVMAP + psh_forgot_to_set_static_BASETEXTURE2NOENVMAP + psh_forgot_to_set_static_WARPLIGHTING + psh_forgot_to_set_static_FANCY_BLENDING + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_NORMAL_DECODE_MODE + psh_forgot_to_set_static_NORMALMASK_DECODE_MODE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_BASETEXTURETRANSFORM2 + 0 +class sdk_lightmappedgeneric_ps30_Dynamic_Index +{ +private: + int m_nFASTPATHENVMAPCONTRAST; +#ifdef _DEBUG + bool m_bFASTPATHENVMAPCONTRAST; +#endif +public: + void SetFASTPATHENVMAPCONTRAST( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFASTPATHENVMAPCONTRAST = i; +#ifdef _DEBUG + m_bFASTPATHENVMAPCONTRAST = true; +#endif + } + void SetFASTPATHENVMAPCONTRAST( bool i ) + { + m_nFASTPATHENVMAPCONTRAST = i ? 1 : 0; +#ifdef _DEBUG + m_bFASTPATHENVMAPCONTRAST = true; +#endif + } +private: + int m_nFASTPATH; +#ifdef _DEBUG + bool m_bFASTPATH; +#endif +public: + void SetFASTPATH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFASTPATH = i; +#ifdef _DEBUG + m_bFASTPATH = true; +#endif + } + void SetFASTPATH( bool i ) + { + m_nFASTPATH = i ? 1 : 0; +#ifdef _DEBUG + m_bFASTPATH = true; +#endif + } +private: + int m_nWRITEWATERFOGTODESTALPHA; +#ifdef _DEBUG + bool m_bWRITEWATERFOGTODESTALPHA; +#endif +public: + void SetWRITEWATERFOGTODESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITEWATERFOGTODESTALPHA = i; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } + void SetWRITEWATERFOGTODESTALPHA( bool i ) + { + m_nWRITEWATERFOGTODESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +public: + sdk_lightmappedgeneric_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bFASTPATHENVMAPCONTRAST = false; +#endif // _DEBUG + m_nFASTPATHENVMAPCONTRAST = 0; +#ifdef _DEBUG + m_bFASTPATH = false; +#endif // _DEBUG + m_nFASTPATH = 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = false; +#endif // _DEBUG + m_nWRITEWATERFOGTODESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bFASTPATHENVMAPCONTRAST && m_bFASTPATH && m_bWRITEWATERFOGTODESTALPHA && m_bPIXELFOGTYPE && m_bLIGHTING_PREVIEW && m_bWRITE_DEPTH_TO_DESTALPHA; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nFASTPATHENVMAPCONTRAST ) + ( 2 * m_nFASTPATH ) + ( 4 * m_nWRITEWATERFOGTODESTALPHA ) + ( 8 * m_nPIXELFOGTYPE ) + ( 16 * m_nLIGHTING_PREVIEW ) + ( 48 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_ps30 psh_forgot_to_set_dynamic_FASTPATHENVMAPCONTRAST + psh_forgot_to_set_dynamic_FASTPATH + psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_LIGHTING_PREVIEW + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_vs20.inc new file mode 100644 index 00000000..90c3dbb9 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_vs20.inc @@ -0,0 +1,362 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_vs20_Static_Index +{ +private: + int m_nENVMAP_MASK; +#ifdef _DEBUG + bool m_bENVMAP_MASK; +#endif +public: + void SetENVMAP_MASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAP_MASK = i; +#ifdef _DEBUG + m_bENVMAP_MASK = true; +#endif + } + void SetENVMAP_MASK( bool i ) + { + m_nENVMAP_MASK = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAP_MASK = true; +#endif + } +private: + int m_nTANGENTSPACE; +#ifdef _DEBUG + bool m_bTANGENTSPACE; +#endif +public: + void SetTANGENTSPACE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nTANGENTSPACE = i; +#ifdef _DEBUG + m_bTANGENTSPACE = true; +#endif + } + void SetTANGENTSPACE( bool i ) + { + m_nTANGENTSPACE = i ? 1 : 0; +#ifdef _DEBUG + m_bTANGENTSPACE = true; +#endif + } +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +private: + int m_nDIFFUSEBUMPMAP; +#ifdef _DEBUG + bool m_bDIFFUSEBUMPMAP; +#endif +public: + void SetDIFFUSEBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSEBUMPMAP = i; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } + void SetDIFFUSEBUMPMAP( bool i ) + { + m_nDIFFUSEBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nVERTEXALPHATEXBLENDFACTOR; +#ifdef _DEBUG + bool m_bVERTEXALPHATEXBLENDFACTOR; +#endif +public: + void SetVERTEXALPHATEXBLENDFACTOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXALPHATEXBLENDFACTOR = i; +#ifdef _DEBUG + m_bVERTEXALPHATEXBLENDFACTOR = true; +#endif + } + void SetVERTEXALPHATEXBLENDFACTOR( bool i ) + { + m_nVERTEXALPHATEXBLENDFACTOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXALPHATEXBLENDFACTOR = true; +#endif + } +private: + int m_nRELIEF_MAPPING; +#ifdef _DEBUG + bool m_bRELIEF_MAPPING; +#endif +public: + void SetRELIEF_MAPPING( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nRELIEF_MAPPING = i; +#ifdef _DEBUG + m_bRELIEF_MAPPING = true; +#endif + } + void SetRELIEF_MAPPING( bool i ) + { + m_nRELIEF_MAPPING = i ? 1 : 0; +#ifdef _DEBUG + m_bRELIEF_MAPPING = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nBUMPMASK; +#ifdef _DEBUG + bool m_bBUMPMASK; +#endif +public: + void SetBUMPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMASK = i; +#ifdef _DEBUG + m_bBUMPMASK = true; +#endif + } + void SetBUMPMASK( bool i ) + { + m_nBUMPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMASK = true; +#endif + } +private: + int m_nBASETEXTURETRANSFORM2; +#ifdef _DEBUG + bool m_bBASETEXTURETRANSFORM2; +#endif +public: + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } + void SetBASETEXTURETRANSFORM2( bool i ) + { + m_nBASETEXTURETRANSFORM2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } +public: + sdk_lightmappedgeneric_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bENVMAP_MASK = false; +#endif // _DEBUG + m_nENVMAP_MASK = 0; +#ifdef _DEBUG + m_bTANGENTSPACE = false; +#endif // _DEBUG + m_nTANGENTSPACE = 0; +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = false; +#endif // _DEBUG + m_nDIFFUSEBUMPMAP = 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bVERTEXALPHATEXBLENDFACTOR = false; +#endif // _DEBUG + m_nVERTEXALPHATEXBLENDFACTOR = 0; +#ifdef _DEBUG + m_bRELIEF_MAPPING = false; +#endif // _DEBUG + m_nRELIEF_MAPPING = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bBUMPMASK = false; +#endif // _DEBUG + m_nBUMPMASK = 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + m_nBASETEXTURETRANSFORM2 = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bENVMAP_MASK && m_bTANGENTSPACE && m_bBUMPMAP && m_bDIFFUSEBUMPMAP && m_bVERTEXCOLOR && m_bVERTEXALPHATEXBLENDFACTOR && m_bRELIEF_MAPPING && m_bSEAMLESS && m_bBUMPMASK && m_bBASETEXTURETRANSFORM2; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 8 * m_nENVMAP_MASK ) + ( 16 * m_nTANGENTSPACE ) + ( 32 * m_nBUMPMAP ) + ( 64 * m_nDIFFUSEBUMPMAP ) + ( 128 * m_nVERTEXCOLOR ) + ( 256 * m_nVERTEXALPHATEXBLENDFACTOR ) + ( 512 * m_nRELIEF_MAPPING ) + ( 512 * m_nSEAMLESS ) + ( 1024 * m_nBUMPMASK ) + ( 2048 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_vs20 vsh_forgot_to_set_static_ENVMAP_MASK + vsh_forgot_to_set_static_TANGENTSPACE + vsh_forgot_to_set_static_BUMPMAP + vsh_forgot_to_set_static_DIFFUSEBUMPMAP + vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_VERTEXALPHATEXBLENDFACTOR + vsh_forgot_to_set_static_RELIEF_MAPPING + vsh_forgot_to_set_static_SEAMLESS + vsh_forgot_to_set_static_BUMPMASK + vsh_forgot_to_set_static_BASETEXTURETRANSFORM2 + 0 +class sdk_lightmappedgeneric_vs20_Dynamic_Index +{ +private: + int m_nFASTPATH; +#ifdef _DEBUG + bool m_bFASTPATH; +#endif +public: + void SetFASTPATH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFASTPATH = i; +#ifdef _DEBUG + m_bFASTPATH = true; +#endif + } + void SetFASTPATH( bool i ) + { + m_nFASTPATH = i ? 1 : 0; +#ifdef _DEBUG + m_bFASTPATH = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +public: + sdk_lightmappedgeneric_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bFASTPATH = false; +#endif // _DEBUG + m_nFASTPATH = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bFASTPATH && m_bDOWATERFOG && m_bLIGHTING_PREVIEW; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nFASTPATH ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nLIGHTING_PREVIEW ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_vs20 vsh_forgot_to_set_dynamic_FASTPATH + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_LIGHTING_PREVIEW + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_vs30.inc new file mode 100644 index 00000000..5fda5413 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedgeneric_vs30.inc @@ -0,0 +1,362 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedgeneric_vs30_Static_Index +{ +private: + int m_nENVMAP_MASK; +#ifdef _DEBUG + bool m_bENVMAP_MASK; +#endif +public: + void SetENVMAP_MASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAP_MASK = i; +#ifdef _DEBUG + m_bENVMAP_MASK = true; +#endif + } + void SetENVMAP_MASK( bool i ) + { + m_nENVMAP_MASK = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAP_MASK = true; +#endif + } +private: + int m_nTANGENTSPACE; +#ifdef _DEBUG + bool m_bTANGENTSPACE; +#endif +public: + void SetTANGENTSPACE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nTANGENTSPACE = i; +#ifdef _DEBUG + m_bTANGENTSPACE = true; +#endif + } + void SetTANGENTSPACE( bool i ) + { + m_nTANGENTSPACE = i ? 1 : 0; +#ifdef _DEBUG + m_bTANGENTSPACE = true; +#endif + } +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +private: + int m_nDIFFUSEBUMPMAP; +#ifdef _DEBUG + bool m_bDIFFUSEBUMPMAP; +#endif +public: + void SetDIFFUSEBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSEBUMPMAP = i; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } + void SetDIFFUSEBUMPMAP( bool i ) + { + m_nDIFFUSEBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nVERTEXALPHATEXBLENDFACTOR; +#ifdef _DEBUG + bool m_bVERTEXALPHATEXBLENDFACTOR; +#endif +public: + void SetVERTEXALPHATEXBLENDFACTOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXALPHATEXBLENDFACTOR = i; +#ifdef _DEBUG + m_bVERTEXALPHATEXBLENDFACTOR = true; +#endif + } + void SetVERTEXALPHATEXBLENDFACTOR( bool i ) + { + m_nVERTEXALPHATEXBLENDFACTOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXALPHATEXBLENDFACTOR = true; +#endif + } +private: + int m_nRELIEF_MAPPING; +#ifdef _DEBUG + bool m_bRELIEF_MAPPING; +#endif +public: + void SetRELIEF_MAPPING( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nRELIEF_MAPPING = i; +#ifdef _DEBUG + m_bRELIEF_MAPPING = true; +#endif + } + void SetRELIEF_MAPPING( bool i ) + { + m_nRELIEF_MAPPING = i ? 1 : 0; +#ifdef _DEBUG + m_bRELIEF_MAPPING = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nBUMPMASK; +#ifdef _DEBUG + bool m_bBUMPMASK; +#endif +public: + void SetBUMPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMASK = i; +#ifdef _DEBUG + m_bBUMPMASK = true; +#endif + } + void SetBUMPMASK( bool i ) + { + m_nBUMPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMASK = true; +#endif + } +private: + int m_nBASETEXTURETRANSFORM2; +#ifdef _DEBUG + bool m_bBASETEXTURETRANSFORM2; +#endif +public: + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } + void SetBASETEXTURETRANSFORM2( bool i ) + { + m_nBASETEXTURETRANSFORM2 = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif + } +public: + sdk_lightmappedgeneric_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bENVMAP_MASK = false; +#endif // _DEBUG + m_nENVMAP_MASK = 0; +#ifdef _DEBUG + m_bTANGENTSPACE = false; +#endif // _DEBUG + m_nTANGENTSPACE = 0; +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = false; +#endif // _DEBUG + m_nDIFFUSEBUMPMAP = 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bVERTEXALPHATEXBLENDFACTOR = false; +#endif // _DEBUG + m_nVERTEXALPHATEXBLENDFACTOR = 0; +#ifdef _DEBUG + m_bRELIEF_MAPPING = false; +#endif // _DEBUG + m_nRELIEF_MAPPING = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bBUMPMASK = false; +#endif // _DEBUG + m_nBUMPMASK = 0; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + m_nBASETEXTURETRANSFORM2 = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bENVMAP_MASK && m_bTANGENTSPACE && m_bBUMPMAP && m_bDIFFUSEBUMPMAP && m_bVERTEXCOLOR && m_bVERTEXALPHATEXBLENDFACTOR && m_bRELIEF_MAPPING && m_bSEAMLESS && m_bBUMPMASK && m_bBASETEXTURETRANSFORM2; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 8 * m_nENVMAP_MASK ) + ( 16 * m_nTANGENTSPACE ) + ( 32 * m_nBUMPMAP ) + ( 64 * m_nDIFFUSEBUMPMAP ) + ( 128 * m_nVERTEXCOLOR ) + ( 256 * m_nVERTEXALPHATEXBLENDFACTOR ) + ( 512 * m_nRELIEF_MAPPING ) + ( 512 * m_nSEAMLESS ) + ( 1024 * m_nBUMPMASK ) + ( 2048 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedgeneric_vs30 vsh_forgot_to_set_static_ENVMAP_MASK + vsh_forgot_to_set_static_TANGENTSPACE + vsh_forgot_to_set_static_BUMPMAP + vsh_forgot_to_set_static_DIFFUSEBUMPMAP + vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_VERTEXALPHATEXBLENDFACTOR + vsh_forgot_to_set_static_RELIEF_MAPPING + vsh_forgot_to_set_static_SEAMLESS + vsh_forgot_to_set_static_BUMPMASK + vsh_forgot_to_set_static_BASETEXTURETRANSFORM2 + 0 +class sdk_lightmappedgeneric_vs30_Dynamic_Index +{ +private: + int m_nFASTPATH; +#ifdef _DEBUG + bool m_bFASTPATH; +#endif +public: + void SetFASTPATH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFASTPATH = i; +#ifdef _DEBUG + m_bFASTPATH = true; +#endif + } + void SetFASTPATH( bool i ) + { + m_nFASTPATH = i ? 1 : 0; +#ifdef _DEBUG + m_bFASTPATH = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +public: + sdk_lightmappedgeneric_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bFASTPATH = false; +#endif // _DEBUG + m_nFASTPATH = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bFASTPATH && m_bDOWATERFOG && m_bLIGHTING_PREVIEW; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nFASTPATH ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nLIGHTING_PREVIEW ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedgeneric_vs30 vsh_forgot_to_set_dynamic_FASTPATH + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_LIGHTING_PREVIEW + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedreflective_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedreflective_ps20.inc new file mode 100644 index 00000000..469d8062 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedreflective_ps20.inc @@ -0,0 +1,162 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedreflective_ps20_Static_Index +{ +private: + int m_nBASETEXTURE; +#ifdef _DEBUG + bool m_bBASETEXTURE; +#endif +public: + void SetBASETEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE = i; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } + void SetBASETEXTURE( bool i ) + { + m_nBASETEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } +private: + int m_nREFLECT; +#ifdef _DEBUG + bool m_bREFLECT; +#endif +public: + void SetREFLECT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFLECT = i; +#ifdef _DEBUG + m_bREFLECT = true; +#endif + } + void SetREFLECT( bool i ) + { + m_nREFLECT = i ? 1 : 0; +#ifdef _DEBUG + m_bREFLECT = true; +#endif + } +private: + int m_nREFRACT; +#ifdef _DEBUG + bool m_bREFRACT; +#endif +public: + void SetREFRACT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFRACT = i; +#ifdef _DEBUG + m_bREFRACT = true; +#endif + } + void SetREFRACT( bool i ) + { + m_nREFRACT = i ? 1 : 0; +#ifdef _DEBUG + m_bREFRACT = true; +#endif + } +private: + int m_nENVMAPMASK; +#ifdef _DEBUG + bool m_bENVMAPMASK; +#endif +public: + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } + void SetENVMAPMASK( bool i ) + { + m_nENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } +public: + sdk_lightmappedreflective_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bBASETEXTURE = false; +#endif // _DEBUG + m_nBASETEXTURE = 0; +#ifdef _DEBUG + m_bREFLECT = false; +#endif // _DEBUG + m_nREFLECT = 0; +#ifdef _DEBUG + m_bREFRACT = false; +#endif // _DEBUG + m_nREFRACT = 0; +#ifdef _DEBUG + m_bENVMAPMASK = false; +#endif // _DEBUG + m_nENVMAPMASK = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bBASETEXTURE && m_bREFLECT && m_bREFRACT && m_bENVMAPMASK; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nBASETEXTURE ) + ( 4 * m_nREFLECT ) + ( 8 * m_nREFRACT ) + ( 16 * m_nENVMAPMASK ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedreflective_ps20 psh_forgot_to_set_static_BASETEXTURE + psh_forgot_to_set_static_REFLECT + psh_forgot_to_set_static_REFRACT + psh_forgot_to_set_static_ENVMAPMASK + 0 +class sdk_lightmappedreflective_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_lightmappedreflective_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedreflective_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedreflective_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedreflective_ps20b.inc new file mode 100644 index 00000000..e5a00725 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedreflective_ps20b.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedreflective_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nBASETEXTURE; +#ifdef _DEBUG + bool m_bBASETEXTURE; +#endif +public: + void SetBASETEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE = i; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } + void SetBASETEXTURE( bool i ) + { + m_nBASETEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } +private: + int m_nREFLECT; +#ifdef _DEBUG + bool m_bREFLECT; +#endif +public: + void SetREFLECT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFLECT = i; +#ifdef _DEBUG + m_bREFLECT = true; +#endif + } + void SetREFLECT( bool i ) + { + m_nREFLECT = i ? 1 : 0; +#ifdef _DEBUG + m_bREFLECT = true; +#endif + } +private: + int m_nREFRACT; +#ifdef _DEBUG + bool m_bREFRACT; +#endif +public: + void SetREFRACT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFRACT = i; +#ifdef _DEBUG + m_bREFRACT = true; +#endif + } + void SetREFRACT( bool i ) + { + m_nREFRACT = i ? 1 : 0; +#ifdef _DEBUG + m_bREFRACT = true; +#endif + } +private: + int m_nENVMAPMASK; +#ifdef _DEBUG + bool m_bENVMAPMASK; +#endif +public: + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } + void SetENVMAPMASK( bool i ) + { + m_nENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } +public: + sdk_lightmappedreflective_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bBASETEXTURE = false; +#endif // _DEBUG + m_nBASETEXTURE = 0; +#ifdef _DEBUG + m_bREFLECT = false; +#endif // _DEBUG + m_nREFLECT = 0; +#ifdef _DEBUG + m_bREFRACT = false; +#endif // _DEBUG + m_nREFRACT = 0; +#ifdef _DEBUG + m_bENVMAPMASK = false; +#endif // _DEBUG + m_nENVMAPMASK = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bBASETEXTURE && m_bREFLECT && m_bREFRACT && m_bENVMAPMASK; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nCONVERT_TO_SRGB ) + ( 8 * m_nBASETEXTURE ) + ( 16 * m_nREFLECT ) + ( 32 * m_nREFRACT ) + ( 64 * m_nENVMAPMASK ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedreflective_ps20b psh_forgot_to_set_static_BASETEXTURE + psh_forgot_to_set_static_REFLECT + psh_forgot_to_set_static_REFRACT + psh_forgot_to_set_static_ENVMAPMASK + 0 +class sdk_lightmappedreflective_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +public: + sdk_lightmappedreflective_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bWRITE_DEPTH_TO_DESTALPHA; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedreflective_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedreflective_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedreflective_vs20.inc new file mode 100644 index 00000000..4321a47b --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_lightmappedreflective_vs20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_lightmappedreflective_vs20_Static_Index +{ +private: + int m_nBASETEXTURE; +#ifdef _DEBUG + bool m_bBASETEXTURE; +#endif +public: + void SetBASETEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE = i; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } + void SetBASETEXTURE( bool i ) + { + m_nBASETEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bBASETEXTURE = true; +#endif + } +public: + sdk_lightmappedreflective_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bBASETEXTURE = false; +#endif // _DEBUG + m_nBASETEXTURE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bBASETEXTURE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nBASETEXTURE ) + 0; + } +}; +#define shaderStaticTest_sdk_lightmappedreflective_vs20 vsh_forgot_to_set_static_BASETEXTURE + 0 +class sdk_lightmappedreflective_vs20_Dynamic_Index +{ +public: + sdk_lightmappedreflective_vs20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_lightmappedreflective_vs20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_refract_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_refract_ps20.inc new file mode 100644 index 00000000..839d80a2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_refract_ps20.inc @@ -0,0 +1,262 @@ +#include "shaderlib/cshader.h" +class sdk_refract_ps20_Static_Index +{ +private: + int m_nBLUR; +#ifdef _DEBUG + bool m_bBLUR; +#endif +public: + void SetBLUR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLUR = i; +#ifdef _DEBUG + m_bBLUR = true; +#endif + } + void SetBLUR( bool i ) + { + m_nBLUR = i ? 1 : 0; +#ifdef _DEBUG + m_bBLUR = true; +#endif + } +private: + int m_nFADEOUTONSILHOUETTE; +#ifdef _DEBUG + bool m_bFADEOUTONSILHOUETTE; +#endif +public: + void SetFADEOUTONSILHOUETTE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFADEOUTONSILHOUETTE = i; +#ifdef _DEBUG + m_bFADEOUTONSILHOUETTE = true; +#endif + } + void SetFADEOUTONSILHOUETTE( bool i ) + { + m_nFADEOUTONSILHOUETTE = i ? 1 : 0; +#ifdef _DEBUG + m_bFADEOUTONSILHOUETTE = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nREFRACTTINTTEXTURE; +#ifdef _DEBUG + bool m_bREFRACTTINTTEXTURE; +#endif +public: + void SetREFRACTTINTTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFRACTTINTTEXTURE = i; +#ifdef _DEBUG + m_bREFRACTTINTTEXTURE = true; +#endif + } + void SetREFRACTTINTTEXTURE( bool i ) + { + m_nREFRACTTINTTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bREFRACTTINTTEXTURE = true; +#endif + } +private: + int m_nMASKED; +#ifdef _DEBUG + bool m_bMASKED; +#endif +public: + void SetMASKED( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMASKED = i; +#ifdef _DEBUG + m_bMASKED = true; +#endif + } + void SetMASKED( bool i ) + { + m_nMASKED = i ? 1 : 0; +#ifdef _DEBUG + m_bMASKED = true; +#endif + } +private: + int m_nCOLORMODULATE; +#ifdef _DEBUG + bool m_bCOLORMODULATE; +#endif +public: + void SetCOLORMODULATE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOLORMODULATE = i; +#ifdef _DEBUG + m_bCOLORMODULATE = true; +#endif + } + void SetCOLORMODULATE( bool i ) + { + m_nCOLORMODULATE = i ? 1 : 0; +#ifdef _DEBUG + m_bCOLORMODULATE = true; +#endif + } +private: + int m_nSECONDARY_NORMAL; +#ifdef _DEBUG + bool m_bSECONDARY_NORMAL; +#endif +public: + void SetSECONDARY_NORMAL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSECONDARY_NORMAL = i; +#ifdef _DEBUG + m_bSECONDARY_NORMAL = true; +#endif + } + void SetSECONDARY_NORMAL( bool i ) + { + m_nSECONDARY_NORMAL = i ? 1 : 0; +#ifdef _DEBUG + m_bSECONDARY_NORMAL = true; +#endif + } +private: + int m_nNORMAL_DECODE_MODE; +#ifdef _DEBUG + bool m_bNORMAL_DECODE_MODE; +#endif +public: + void SetNORMAL_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMAL_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } + void SetNORMAL_DECODE_MODE( bool i ) + { + m_nNORMAL_DECODE_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } +public: + sdk_refract_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bBLUR = false; +#endif // _DEBUG + m_nBLUR = 0; +#ifdef _DEBUG + m_bFADEOUTONSILHOUETTE = false; +#endif // _DEBUG + m_nFADEOUTONSILHOUETTE = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bREFRACTTINTTEXTURE = false; +#endif // _DEBUG + m_nREFRACTTINTTEXTURE = 0; +#ifdef _DEBUG + m_bMASKED = false; +#endif // _DEBUG + m_nMASKED = 0; +#ifdef _DEBUG + m_bCOLORMODULATE = false; +#endif // _DEBUG + m_nCOLORMODULATE = 0; +#ifdef _DEBUG + m_bSECONDARY_NORMAL = false; +#endif // _DEBUG + m_nSECONDARY_NORMAL = 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = false; +#endif // _DEBUG + m_nNORMAL_DECODE_MODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bBLUR && m_bFADEOUTONSILHOUETTE && m_bCUBEMAP && m_bREFRACTTINTTEXTURE && m_bMASKED && m_bCOLORMODULATE && m_bSECONDARY_NORMAL && m_bNORMAL_DECODE_MODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nBLUR ) + ( 4 * m_nFADEOUTONSILHOUETTE ) + ( 8 * m_nCUBEMAP ) + ( 16 * m_nREFRACTTINTTEXTURE ) + ( 32 * m_nMASKED ) + ( 64 * m_nCOLORMODULATE ) + ( 128 * m_nSECONDARY_NORMAL ) + ( 256 * m_nNORMAL_DECODE_MODE ) + 0; + } +}; +#define shaderStaticTest_sdk_refract_ps20 psh_forgot_to_set_static_BLUR + psh_forgot_to_set_static_FADEOUTONSILHOUETTE + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_REFRACTTINTTEXTURE + psh_forgot_to_set_static_MASKED + psh_forgot_to_set_static_COLORMODULATE + psh_forgot_to_set_static_SECONDARY_NORMAL + psh_forgot_to_set_static_NORMAL_DECODE_MODE + 0 +class sdk_refract_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_refract_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_refract_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_refract_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_refract_ps20b.inc new file mode 100644 index 00000000..3d877ae0 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_refract_ps20b.inc @@ -0,0 +1,337 @@ +#include "shaderlib/cshader.h" +class sdk_refract_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nBLUR; +#ifdef _DEBUG + bool m_bBLUR; +#endif +public: + void SetBLUR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLUR = i; +#ifdef _DEBUG + m_bBLUR = true; +#endif + } + void SetBLUR( bool i ) + { + m_nBLUR = i ? 1 : 0; +#ifdef _DEBUG + m_bBLUR = true; +#endif + } +private: + int m_nFADEOUTONSILHOUETTE; +#ifdef _DEBUG + bool m_bFADEOUTONSILHOUETTE; +#endif +public: + void SetFADEOUTONSILHOUETTE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFADEOUTONSILHOUETTE = i; +#ifdef _DEBUG + m_bFADEOUTONSILHOUETTE = true; +#endif + } + void SetFADEOUTONSILHOUETTE( bool i ) + { + m_nFADEOUTONSILHOUETTE = i ? 1 : 0; +#ifdef _DEBUG + m_bFADEOUTONSILHOUETTE = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nREFRACTTINTTEXTURE; +#ifdef _DEBUG + bool m_bREFRACTTINTTEXTURE; +#endif +public: + void SetREFRACTTINTTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nREFRACTTINTTEXTURE = i; +#ifdef _DEBUG + m_bREFRACTTINTTEXTURE = true; +#endif + } + void SetREFRACTTINTTEXTURE( bool i ) + { + m_nREFRACTTINTTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bREFRACTTINTTEXTURE = true; +#endif + } +private: + int m_nMASKED; +#ifdef _DEBUG + bool m_bMASKED; +#endif +public: + void SetMASKED( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMASKED = i; +#ifdef _DEBUG + m_bMASKED = true; +#endif + } + void SetMASKED( bool i ) + { + m_nMASKED = i ? 1 : 0; +#ifdef _DEBUG + m_bMASKED = true; +#endif + } +private: + int m_nCOLORMODULATE; +#ifdef _DEBUG + bool m_bCOLORMODULATE; +#endif +public: + void SetCOLORMODULATE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOLORMODULATE = i; +#ifdef _DEBUG + m_bCOLORMODULATE = true; +#endif + } + void SetCOLORMODULATE( bool i ) + { + m_nCOLORMODULATE = i ? 1 : 0; +#ifdef _DEBUG + m_bCOLORMODULATE = true; +#endif + } +private: + int m_nSECONDARY_NORMAL; +#ifdef _DEBUG + bool m_bSECONDARY_NORMAL; +#endif +public: + void SetSECONDARY_NORMAL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSECONDARY_NORMAL = i; +#ifdef _DEBUG + m_bSECONDARY_NORMAL = true; +#endif + } + void SetSECONDARY_NORMAL( bool i ) + { + m_nSECONDARY_NORMAL = i ? 1 : 0; +#ifdef _DEBUG + m_bSECONDARY_NORMAL = true; +#endif + } +private: + int m_nNORMAL_DECODE_MODE; +#ifdef _DEBUG + bool m_bNORMAL_DECODE_MODE; +#endif +public: + void SetNORMAL_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMAL_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } + void SetNORMAL_DECODE_MODE( bool i ) + { + m_nNORMAL_DECODE_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif + } +private: + int m_nSHADER_SRGB_READ; +#ifdef _DEBUG + bool m_bSHADER_SRGB_READ; +#endif +public: + void SetSHADER_SRGB_READ( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSHADER_SRGB_READ = i; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = true; +#endif + } + void SetSHADER_SRGB_READ( bool i ) + { + m_nSHADER_SRGB_READ = i ? 1 : 0; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = true; +#endif + } +public: + sdk_refract_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bBLUR = false; +#endif // _DEBUG + m_nBLUR = 0; +#ifdef _DEBUG + m_bFADEOUTONSILHOUETTE = false; +#endif // _DEBUG + m_nFADEOUTONSILHOUETTE = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bREFRACTTINTTEXTURE = false; +#endif // _DEBUG + m_nREFRACTTINTTEXTURE = 0; +#ifdef _DEBUG + m_bMASKED = false; +#endif // _DEBUG + m_nMASKED = 0; +#ifdef _DEBUG + m_bCOLORMODULATE = false; +#endif // _DEBUG + m_nCOLORMODULATE = 0; +#ifdef _DEBUG + m_bSECONDARY_NORMAL = false; +#endif // _DEBUG + m_nSECONDARY_NORMAL = 0; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = false; +#endif // _DEBUG + m_nNORMAL_DECODE_MODE = 0; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = false; +#endif // _DEBUG + m_nSHADER_SRGB_READ = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bBLUR && m_bFADEOUTONSILHOUETTE && m_bCUBEMAP && m_bREFRACTTINTTEXTURE && m_bMASKED && m_bCOLORMODULATE && m_bSECONDARY_NORMAL && m_bNORMAL_DECODE_MODE && m_bSHADER_SRGB_READ; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nCONVERT_TO_SRGB ) + ( 8 * m_nBLUR ) + ( 16 * m_nFADEOUTONSILHOUETTE ) + ( 32 * m_nCUBEMAP ) + ( 64 * m_nREFRACTTINTTEXTURE ) + ( 128 * m_nMASKED ) + ( 256 * m_nCOLORMODULATE ) + ( 512 * m_nSECONDARY_NORMAL ) + ( 1024 * m_nNORMAL_DECODE_MODE ) + ( 1024 * m_nSHADER_SRGB_READ ) + 0; + } +}; +#define shaderStaticTest_sdk_refract_ps20b psh_forgot_to_set_static_BLUR + psh_forgot_to_set_static_FADEOUTONSILHOUETTE + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_REFRACTTINTTEXTURE + psh_forgot_to_set_static_MASKED + psh_forgot_to_set_static_COLORMODULATE + psh_forgot_to_set_static_SECONDARY_NORMAL + psh_forgot_to_set_static_NORMAL_DECODE_MODE + psh_forgot_to_set_static_SHADER_SRGB_READ + 0 +class sdk_refract_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +public: + sdk_refract_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bWRITE_DEPTH_TO_DESTALPHA; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + } +}; +#define shaderDynamicTest_sdk_refract_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_screenspaceeffect_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_screenspaceeffect_vs20.inc new file mode 100644 index 00000000..607c12cd --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_screenspaceeffect_vs20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_screenspaceeffect_vs20_Static_Index +{ +private: + int m_nX360APPCHOOSER; +#ifdef _DEBUG + bool m_bX360APPCHOOSER; +#endif +public: + void SetX360APPCHOOSER( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nX360APPCHOOSER = i; +#ifdef _DEBUG + m_bX360APPCHOOSER = true; +#endif + } + void SetX360APPCHOOSER( bool i ) + { + m_nX360APPCHOOSER = i ? 1 : 0; +#ifdef _DEBUG + m_bX360APPCHOOSER = true; +#endif + } +public: + sdk_screenspaceeffect_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bX360APPCHOOSER = true; +#endif // _DEBUG + m_nX360APPCHOOSER = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bX360APPCHOOSER; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nX360APPCHOOSER ) + 0; + } +}; +#define shaderStaticTest_sdk_screenspaceeffect_vs20 0 +class sdk_screenspaceeffect_vs20_Dynamic_Index +{ +public: + sdk_screenspaceeffect_vs20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_screenspaceeffect_vs20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_skin_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_skin_ps20b.inc new file mode 100644 index 00000000..6c1e5fea --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_skin_ps20b.inc @@ -0,0 +1,537 @@ +#include "shaderlib/cshader.h" +class sdk_skin_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nSELFILLUMFRESNEL; +#ifdef _DEBUG + bool m_bSELFILLUMFRESNEL; +#endif +public: + void SetSELFILLUMFRESNEL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUMFRESNEL = i; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = true; +#endif + } + void SetSELFILLUMFRESNEL( bool i ) + { + m_nSELFILLUMFRESNEL = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nLIGHTWARPTEXTURE; +#ifdef _DEBUG + bool m_bLIGHTWARPTEXTURE; +#endif +public: + void SetLIGHTWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTWARPTEXTURE = i; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } + void SetLIGHTWARPTEXTURE( bool i ) + { + m_nLIGHTWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } +private: + int m_nPHONGWARPTEXTURE; +#ifdef _DEBUG + bool m_bPHONGWARPTEXTURE; +#endif +public: + void SetPHONGWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONGWARPTEXTURE = i; +#ifdef _DEBUG + m_bPHONGWARPTEXTURE = true; +#endif + } + void SetPHONGWARPTEXTURE( bool i ) + { + m_nPHONGWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bPHONGWARPTEXTURE = true; +#endif + } +private: + int m_nWRINKLEMAP; +#ifdef _DEBUG + bool m_bWRINKLEMAP; +#endif +public: + void SetWRINKLEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRINKLEMAP = i; +#ifdef _DEBUG + m_bWRINKLEMAP = true; +#endif + } + void SetWRINKLEMAP( bool i ) + { + m_nWRINKLEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bWRINKLEMAP = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 6 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nRIMLIGHT; +#ifdef _DEBUG + bool m_bRIMLIGHT; +#endif +public: + void SetRIMLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nRIMLIGHT = i; +#ifdef _DEBUG + m_bRIMLIGHT = true; +#endif + } + void SetRIMLIGHT( bool i ) + { + m_nRIMLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bRIMLIGHT = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +private: + int m_nFASTPATH_NOBUMP; +#ifdef _DEBUG + bool m_bFASTPATH_NOBUMP; +#endif +public: + void SetFASTPATH_NOBUMP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFASTPATH_NOBUMP = i; +#ifdef _DEBUG + m_bFASTPATH_NOBUMP = true; +#endif + } + void SetFASTPATH_NOBUMP( bool i ) + { + m_nFASTPATH_NOBUMP = i ? 1 : 0; +#ifdef _DEBUG + m_bFASTPATH_NOBUMP = true; +#endif + } +private: + int m_nBLENDTINTBYBASEALPHA; +#ifdef _DEBUG + bool m_bBLENDTINTBYBASEALPHA; +#endif +public: + void SetBLENDTINTBYBASEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLENDTINTBYBASEALPHA = i; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } + void SetBLENDTINTBYBASEALPHA( bool i ) + { + m_nBLENDTINTBYBASEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } +private: + int m_nPHONG_HALFLAMBERT; +#ifdef _DEBUG + bool m_bPHONG_HALFLAMBERT; +#endif +public: + void SetPHONG_HALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONG_HALFLAMBERT = i; +#ifdef _DEBUG + m_bPHONG_HALFLAMBERT = true; +#endif + } + void SetPHONG_HALFLAMBERT( bool i ) + { + m_nPHONG_HALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bPHONG_HALFLAMBERT = true; +#endif + } +public: + sdk_skin_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = false; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = false; +#endif // _DEBUG + m_nSELFILLUMFRESNEL = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = false; +#endif // _DEBUG + m_nLIGHTWARPTEXTURE = 0; +#ifdef _DEBUG + m_bPHONGWARPTEXTURE = false; +#endif // _DEBUG + m_nPHONGWARPTEXTURE = 0; +#ifdef _DEBUG + m_bWRINKLEMAP = false; +#endif // _DEBUG + m_nWRINKLEMAP = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bRIMLIGHT = false; +#endif // _DEBUG + m_nRIMLIGHT = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; +#ifdef _DEBUG + m_bFASTPATH_NOBUMP = false; +#endif // _DEBUG + m_nFASTPATH_NOBUMP = 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = false; +#endif // _DEBUG + m_nBLENDTINTBYBASEALPHA = 0; +#ifdef _DEBUG + m_bPHONG_HALFLAMBERT = false; +#endif // _DEBUG + m_nPHONG_HALFLAMBERT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bCUBEMAP && m_bSELFILLUM && m_bSELFILLUMFRESNEL && m_bFLASHLIGHT && m_bLIGHTWARPTEXTURE && m_bPHONGWARPTEXTURE && m_bWRINKLEMAP && m_bDETAIL_BLEND_MODE && m_bDETAILTEXTURE && m_bRIMLIGHT && m_bFLASHLIGHTDEPTHFILTERMODE && m_bFASTPATH_NOBUMP && m_bBLENDTINTBYBASEALPHA && m_bPHONG_HALFLAMBERT; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 80 * m_nCONVERT_TO_SRGB ) + ( 80 * m_nCUBEMAP ) + ( 160 * m_nSELFILLUM ) + ( 320 * m_nSELFILLUMFRESNEL ) + ( 640 * m_nFLASHLIGHT ) + ( 1280 * m_nLIGHTWARPTEXTURE ) + ( 2560 * m_nPHONGWARPTEXTURE ) + ( 5120 * m_nWRINKLEMAP ) + ( 10240 * m_nDETAIL_BLEND_MODE ) + ( 71680 * m_nDETAILTEXTURE ) + ( 143360 * m_nRIMLIGHT ) + ( 286720 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 860160 * m_nFASTPATH_NOBUMP ) + ( 1720320 * m_nBLENDTINTBYBASEALPHA ) + ( 3440640 * m_nPHONG_HALFLAMBERT ) + 0; + } +}; +#define shaderStaticTest_sdk_skin_ps20b psh_forgot_to_set_static_CONVERT_TO_SRGB + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_SELFILLUMFRESNEL + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_PHONGWARPTEXTURE + psh_forgot_to_set_static_WRINKLEMAP + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_RIMLIGHT + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_FASTPATH_NOBUMP + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + psh_forgot_to_set_static_PHONG_HALFLAMBERT + 0 +class sdk_skin_ps20b_Dynamic_Index +{ +private: + int m_nWRITEWATERFOGTODESTALPHA; +#ifdef _DEBUG + bool m_bWRITEWATERFOGTODESTALPHA; +#endif +public: + void SetWRITEWATERFOGTODESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITEWATERFOGTODESTALPHA = i; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } + void SetWRITEWATERFOGTODESTALPHA( bool i ) + { + m_nWRITEWATERFOGTODESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_skin_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = false; +#endif // _DEBUG + m_nWRITEWATERFOGTODESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bWRITEWATERFOGTODESTALPHA && m_bPIXELFOGTYPE && m_bNUM_LIGHTS && m_bWRITE_DEPTH_TO_DESTALPHA && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nWRITEWATERFOGTODESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + ( 4 * m_nNUM_LIGHTS ) + ( 20 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 40 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_skin_ps20b psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_skin_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_skin_ps30.inc new file mode 100644 index 00000000..2405f0b6 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_skin_ps30.inc @@ -0,0 +1,537 @@ +#include "shaderlib/cshader.h" +class sdk_skin_ps30_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nSELFILLUMFRESNEL; +#ifdef _DEBUG + bool m_bSELFILLUMFRESNEL; +#endif +public: + void SetSELFILLUMFRESNEL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUMFRESNEL = i; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = true; +#endif + } + void SetSELFILLUMFRESNEL( bool i ) + { + m_nSELFILLUMFRESNEL = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nLIGHTWARPTEXTURE; +#ifdef _DEBUG + bool m_bLIGHTWARPTEXTURE; +#endif +public: + void SetLIGHTWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTWARPTEXTURE = i; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } + void SetLIGHTWARPTEXTURE( bool i ) + { + m_nLIGHTWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } +private: + int m_nPHONGWARPTEXTURE; +#ifdef _DEBUG + bool m_bPHONGWARPTEXTURE; +#endif +public: + void SetPHONGWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONGWARPTEXTURE = i; +#ifdef _DEBUG + m_bPHONGWARPTEXTURE = true; +#endif + } + void SetPHONGWARPTEXTURE( bool i ) + { + m_nPHONGWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bPHONGWARPTEXTURE = true; +#endif + } +private: + int m_nWRINKLEMAP; +#ifdef _DEBUG + bool m_bWRINKLEMAP; +#endif +public: + void SetWRINKLEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRINKLEMAP = i; +#ifdef _DEBUG + m_bWRINKLEMAP = true; +#endif + } + void SetWRINKLEMAP( bool i ) + { + m_nWRINKLEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bWRINKLEMAP = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 6 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nRIMLIGHT; +#ifdef _DEBUG + bool m_bRIMLIGHT; +#endif +public: + void SetRIMLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nRIMLIGHT = i; +#ifdef _DEBUG + m_bRIMLIGHT = true; +#endif + } + void SetRIMLIGHT( bool i ) + { + m_nRIMLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bRIMLIGHT = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +private: + int m_nFASTPATH_NOBUMP; +#ifdef _DEBUG + bool m_bFASTPATH_NOBUMP; +#endif +public: + void SetFASTPATH_NOBUMP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFASTPATH_NOBUMP = i; +#ifdef _DEBUG + m_bFASTPATH_NOBUMP = true; +#endif + } + void SetFASTPATH_NOBUMP( bool i ) + { + m_nFASTPATH_NOBUMP = i ? 1 : 0; +#ifdef _DEBUG + m_bFASTPATH_NOBUMP = true; +#endif + } +private: + int m_nBLENDTINTBYBASEALPHA; +#ifdef _DEBUG + bool m_bBLENDTINTBYBASEALPHA; +#endif +public: + void SetBLENDTINTBYBASEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLENDTINTBYBASEALPHA = i; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } + void SetBLENDTINTBYBASEALPHA( bool i ) + { + m_nBLENDTINTBYBASEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } +private: + int m_nPHONG_HALFLAMBERT; +#ifdef _DEBUG + bool m_bPHONG_HALFLAMBERT; +#endif +public: + void SetPHONG_HALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONG_HALFLAMBERT = i; +#ifdef _DEBUG + m_bPHONG_HALFLAMBERT = true; +#endif + } + void SetPHONG_HALFLAMBERT( bool i ) + { + m_nPHONG_HALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bPHONG_HALFLAMBERT = true; +#endif + } +public: + sdk_skin_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = false; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = false; +#endif // _DEBUG + m_nSELFILLUMFRESNEL = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = false; +#endif // _DEBUG + m_nLIGHTWARPTEXTURE = 0; +#ifdef _DEBUG + m_bPHONGWARPTEXTURE = false; +#endif // _DEBUG + m_nPHONGWARPTEXTURE = 0; +#ifdef _DEBUG + m_bWRINKLEMAP = false; +#endif // _DEBUG + m_nWRINKLEMAP = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bRIMLIGHT = false; +#endif // _DEBUG + m_nRIMLIGHT = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; +#ifdef _DEBUG + m_bFASTPATH_NOBUMP = false; +#endif // _DEBUG + m_nFASTPATH_NOBUMP = 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = false; +#endif // _DEBUG + m_nBLENDTINTBYBASEALPHA = 0; +#ifdef _DEBUG + m_bPHONG_HALFLAMBERT = false; +#endif // _DEBUG + m_nPHONG_HALFLAMBERT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bCUBEMAP && m_bSELFILLUM && m_bSELFILLUMFRESNEL && m_bFLASHLIGHT && m_bLIGHTWARPTEXTURE && m_bPHONGWARPTEXTURE && m_bWRINKLEMAP && m_bDETAIL_BLEND_MODE && m_bDETAILTEXTURE && m_bRIMLIGHT && m_bFLASHLIGHTDEPTHFILTERMODE && m_bFASTPATH_NOBUMP && m_bBLENDTINTBYBASEALPHA && m_bPHONG_HALFLAMBERT; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 80 * m_nCONVERT_TO_SRGB ) + ( 80 * m_nCUBEMAP ) + ( 160 * m_nSELFILLUM ) + ( 320 * m_nSELFILLUMFRESNEL ) + ( 640 * m_nFLASHLIGHT ) + ( 1280 * m_nLIGHTWARPTEXTURE ) + ( 2560 * m_nPHONGWARPTEXTURE ) + ( 5120 * m_nWRINKLEMAP ) + ( 10240 * m_nDETAIL_BLEND_MODE ) + ( 71680 * m_nDETAILTEXTURE ) + ( 143360 * m_nRIMLIGHT ) + ( 286720 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 860160 * m_nFASTPATH_NOBUMP ) + ( 1720320 * m_nBLENDTINTBYBASEALPHA ) + ( 3440640 * m_nPHONG_HALFLAMBERT ) + 0; + } +}; +#define shaderStaticTest_sdk_skin_ps30 psh_forgot_to_set_static_CONVERT_TO_SRGB + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_SELFILLUMFRESNEL + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_PHONGWARPTEXTURE + psh_forgot_to_set_static_WRINKLEMAP + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_RIMLIGHT + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_FASTPATH_NOBUMP + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + psh_forgot_to_set_static_PHONG_HALFLAMBERT + 0 +class sdk_skin_ps30_Dynamic_Index +{ +private: + int m_nWRITEWATERFOGTODESTALPHA; +#ifdef _DEBUG + bool m_bWRITEWATERFOGTODESTALPHA; +#endif +public: + void SetWRITEWATERFOGTODESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITEWATERFOGTODESTALPHA = i; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } + void SetWRITEWATERFOGTODESTALPHA( bool i ) + { + m_nWRITEWATERFOGTODESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_skin_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = false; +#endif // _DEBUG + m_nWRITEWATERFOGTODESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bWRITEWATERFOGTODESTALPHA && m_bPIXELFOGTYPE && m_bNUM_LIGHTS && m_bWRITE_DEPTH_TO_DESTALPHA && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nWRITEWATERFOGTODESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + ( 4 * m_nNUM_LIGHTS ) + ( 20 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 40 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_skin_ps30 psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_skin_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_skin_vs20.inc new file mode 100644 index 00000000..22a29bf7 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_skin_vs20.inc @@ -0,0 +1,187 @@ +#include "shaderlib/cshader.h" +class sdk_skin_vs20_Static_Index +{ +private: + int m_nUSE_STATIC_CONTROL_FLOW; +#ifdef _DEBUG + bool m_bUSE_STATIC_CONTROL_FLOW; +#endif +public: + void SetUSE_STATIC_CONTROL_FLOW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nUSE_STATIC_CONTROL_FLOW = i; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } + void SetUSE_STATIC_CONTROL_FLOW( bool i ) + { + m_nUSE_STATIC_CONTROL_FLOW = i ? 1 : 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } +public: + sdk_skin_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = false; +#endif // _DEBUG + m_nUSE_STATIC_CONTROL_FLOW = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bUSE_STATIC_CONTROL_FLOW; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 48 * m_nUSE_STATIC_CONTROL_FLOW ) + 0; + } +}; +#define shaderStaticTest_sdk_skin_vs20 vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + 0 +class sdk_skin_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_skin_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bLIGHTING_PREVIEW && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nLIGHTING_PREVIEW ) + ( 16 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_skin_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_LIGHTING_PREVIEW + vsh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_skin_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_skin_vs30.inc new file mode 100644 index 00000000..fb6a1125 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_skin_vs30.inc @@ -0,0 +1,187 @@ +#include "shaderlib/cshader.h" +class sdk_skin_vs30_Static_Index +{ +private: + int m_nDECAL; +#ifdef _DEBUG + bool m_bDECAL; +#endif +public: + void SetDECAL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDECAL = i; +#ifdef _DEBUG + m_bDECAL = true; +#endif + } + void SetDECAL( bool i ) + { + m_nDECAL = i ? 1 : 0; +#ifdef _DEBUG + m_bDECAL = true; +#endif + } +public: + sdk_skin_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bDECAL = false; +#endif // _DEBUG + m_nDECAL = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bDECAL; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 32 * m_nDECAL ) + 0; + } +}; +#define shaderStaticTest_sdk_skin_vs30 vsh_forgot_to_set_static_DECAL + 0 +class sdk_skin_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_skin_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bLIGHTING_PREVIEW && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nLIGHTING_PREVIEW ) + ( 16 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_skin_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_LIGHTING_PREVIEW + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_splinerope_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_splinerope_ps20.inc new file mode 100644 index 00000000..f43cdb2f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_splinerope_ps20.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_splinerope_ps20_Static_Index +{ +private: + int m_nSHADER_SRGB_READ; +#ifdef _DEBUG + bool m_bSHADER_SRGB_READ; +#endif +public: + void SetSHADER_SRGB_READ( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nSHADER_SRGB_READ = i; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = true; +#endif + } + void SetSHADER_SRGB_READ( bool i ) + { + m_nSHADER_SRGB_READ = i ? 1 : 0; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = true; +#endif + } +private: + int m_nSHADOWDEPTH; +#ifdef _DEBUG + bool m_bSHADOWDEPTH; +#endif +public: + void SetSHADOWDEPTH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSHADOWDEPTH = i; +#ifdef _DEBUG + m_bSHADOWDEPTH = true; +#endif + } + void SetSHADOWDEPTH( bool i ) + { + m_nSHADOWDEPTH = i ? 1 : 0; +#ifdef _DEBUG + m_bSHADOWDEPTH = true; +#endif + } +public: + sdk_splinerope_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bSHADER_SRGB_READ = false; +#endif // _DEBUG + m_nSHADER_SRGB_READ = 0; +#ifdef _DEBUG + m_bSHADOWDEPTH = false; +#endif // _DEBUG + m_nSHADOWDEPTH = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bSHADER_SRGB_READ && m_bSHADOWDEPTH; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nSHADER_SRGB_READ ) + ( 2 * m_nSHADOWDEPTH ) + 0; + } +}; +#define shaderStaticTest_sdk_splinerope_ps20 psh_forgot_to_set_static_SHADER_SRGB_READ + psh_forgot_to_set_static_SHADOWDEPTH + 0 +class sdk_splinerope_ps20_Dynamic_Index +{ +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_splinerope_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bWRITE_DEPTH_TO_DESTALPHA && m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_splinerope_ps20 psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_splinerope_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_splinerope_ps20b.inc new file mode 100644 index 00000000..75ce64e9 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_splinerope_ps20b.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_splinerope_ps20b_Static_Index +{ +private: + int m_nSHADER_SRGB_READ; +#ifdef _DEBUG + bool m_bSHADER_SRGB_READ; +#endif +public: + void SetSHADER_SRGB_READ( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nSHADER_SRGB_READ = i; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = true; +#endif + } + void SetSHADER_SRGB_READ( bool i ) + { + m_nSHADER_SRGB_READ = i ? 1 : 0; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = true; +#endif + } +private: + int m_nSHADOWDEPTH; +#ifdef _DEBUG + bool m_bSHADOWDEPTH; +#endif +public: + void SetSHADOWDEPTH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSHADOWDEPTH = i; +#ifdef _DEBUG + m_bSHADOWDEPTH = true; +#endif + } + void SetSHADOWDEPTH( bool i ) + { + m_nSHADOWDEPTH = i ? 1 : 0; +#ifdef _DEBUG + m_bSHADOWDEPTH = true; +#endif + } +public: + sdk_splinerope_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bSHADER_SRGB_READ = false; +#endif // _DEBUG + m_nSHADER_SRGB_READ = 0; +#ifdef _DEBUG + m_bSHADOWDEPTH = false; +#endif // _DEBUG + m_nSHADOWDEPTH = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bSHADER_SRGB_READ && m_bSHADOWDEPTH; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nSHADER_SRGB_READ ) + ( 4 * m_nSHADOWDEPTH ) + 0; + } +}; +#define shaderStaticTest_sdk_splinerope_ps20b psh_forgot_to_set_static_SHADER_SRGB_READ + psh_forgot_to_set_static_SHADOWDEPTH + 0 +class sdk_splinerope_ps20b_Dynamic_Index +{ +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_splinerope_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bWRITE_DEPTH_TO_DESTALPHA && m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_splinerope_ps20b psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_splinerope_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_splinerope_ps30.inc new file mode 100644 index 00000000..6427d06f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_splinerope_ps30.inc @@ -0,0 +1,112 @@ +#include "shaderlib/cshader.h" +class sdk_splinerope_ps30_Static_Index +{ +private: + int m_nSHADER_SRGB_READ; +#ifdef _DEBUG + bool m_bSHADER_SRGB_READ; +#endif +public: + void SetSHADER_SRGB_READ( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nSHADER_SRGB_READ = i; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = true; +#endif + } + void SetSHADER_SRGB_READ( bool i ) + { + m_nSHADER_SRGB_READ = i ? 1 : 0; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = true; +#endif + } +private: + int m_nSHADOWDEPTH; +#ifdef _DEBUG + bool m_bSHADOWDEPTH; +#endif +public: + void SetSHADOWDEPTH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSHADOWDEPTH = i; +#ifdef _DEBUG + m_bSHADOWDEPTH = true; +#endif + } + void SetSHADOWDEPTH( bool i ) + { + m_nSHADOWDEPTH = i ? 1 : 0; +#ifdef _DEBUG + m_bSHADOWDEPTH = true; +#endif + } +public: + sdk_splinerope_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bSHADER_SRGB_READ = false; +#endif // _DEBUG + m_nSHADER_SRGB_READ = 0; +#ifdef _DEBUG + m_bSHADOWDEPTH = false; +#endif // _DEBUG + m_nSHADOWDEPTH = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bSHADER_SRGB_READ && m_bSHADOWDEPTH; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nSHADER_SRGB_READ ) + ( 2 * m_nSHADOWDEPTH ) + 0; + } +}; +#define shaderStaticTest_sdk_splinerope_ps30 psh_forgot_to_set_static_SHADER_SRGB_READ + psh_forgot_to_set_static_SHADOWDEPTH + 0 +class sdk_splinerope_ps30_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_splinerope_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_splinerope_ps30 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_splinerope_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_splinerope_vs20.inc new file mode 100644 index 00000000..ba584299 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_splinerope_vs20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_splinerope_vs20_Static_Index +{ +public: + sdk_splinerope_vs20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_splinerope_vs20 0 +class sdk_splinerope_vs20_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_splinerope_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_splinerope_vs20 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_splinerope_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_splinerope_vs30.inc new file mode 100644 index 00000000..97c31b1b --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_splinerope_vs30.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_splinerope_vs30_Static_Index +{ +public: + sdk_splinerope_vs30_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_splinerope_vs30 0 +class sdk_splinerope_vs30_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_splinerope_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_splinerope_vs30 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_sprite_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_sprite_ps20.inc new file mode 100644 index 00000000..ac161fb8 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_sprite_ps20.inc @@ -0,0 +1,187 @@ +#include "shaderlib/cshader.h" +class sdk_sprite_ps20_Static_Index +{ +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nCONSTANTCOLOR; +#ifdef _DEBUG + bool m_bCONSTANTCOLOR; +#endif +public: + void SetCONSTANTCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONSTANTCOLOR = i; +#ifdef _DEBUG + m_bCONSTANTCOLOR = true; +#endif + } + void SetCONSTANTCOLOR( bool i ) + { + m_nCONSTANTCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bCONSTANTCOLOR = true; +#endif + } +private: + int m_nHDRTYPE; +#ifdef _DEBUG + bool m_bHDRTYPE; +#endif +public: + void SetHDRTYPE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nHDRTYPE = i; +#ifdef _DEBUG + m_bHDRTYPE = true; +#endif + } + void SetHDRTYPE( bool i ) + { + m_nHDRTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bHDRTYPE = true; +#endif + } +private: + int m_nSRGB; +#ifdef _DEBUG + bool m_bSRGB; +#endif +public: + void SetSRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSRGB = i; +#ifdef _DEBUG + m_bSRGB = true; +#endif + } + void SetSRGB( bool i ) + { + m_nSRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bSRGB = true; +#endif + } +public: + sdk_sprite_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bCONSTANTCOLOR = false; +#endif // _DEBUG + m_nCONSTANTCOLOR = 0; +#ifdef _DEBUG + m_bHDRTYPE = false; +#endif // _DEBUG + m_nHDRTYPE = 0; +#ifdef _DEBUG + m_bSRGB = false; +#endif // _DEBUG + m_nSRGB = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bVERTEXCOLOR && m_bCONSTANTCOLOR && m_bHDRTYPE && m_bSRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nVERTEXCOLOR ) + ( 8 * m_nCONSTANTCOLOR ) + ( 16 * m_nHDRTYPE ) + ( 48 * m_nSRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_sprite_ps20 psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_CONSTANTCOLOR + psh_forgot_to_set_static_HDRTYPE + psh_forgot_to_set_static_SRGB + 0 +class sdk_sprite_ps20_Dynamic_Index +{ +private: + int m_nHDRENABLED; +#ifdef _DEBUG + bool m_bHDRENABLED; +#endif +public: + void SetHDRENABLED( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHDRENABLED = i; +#ifdef _DEBUG + m_bHDRENABLED = true; +#endif + } + void SetHDRENABLED( bool i ) + { + m_nHDRENABLED = i ? 1 : 0; +#ifdef _DEBUG + m_bHDRENABLED = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_sprite_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bHDRENABLED = false; +#endif // _DEBUG + m_nHDRENABLED = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bHDRENABLED && m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nHDRENABLED ) + ( 2 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_sprite_ps20 psh_forgot_to_set_dynamic_HDRENABLED + psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_sprite_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_sprite_ps20b.inc new file mode 100644 index 00000000..35d69c88 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_sprite_ps20b.inc @@ -0,0 +1,237 @@ +#include "shaderlib/cshader.h" +class sdk_sprite_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nCONSTANTCOLOR; +#ifdef _DEBUG + bool m_bCONSTANTCOLOR; +#endif +public: + void SetCONSTANTCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONSTANTCOLOR = i; +#ifdef _DEBUG + m_bCONSTANTCOLOR = true; +#endif + } + void SetCONSTANTCOLOR( bool i ) + { + m_nCONSTANTCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bCONSTANTCOLOR = true; +#endif + } +private: + int m_nHDRTYPE; +#ifdef _DEBUG + bool m_bHDRTYPE; +#endif +public: + void SetHDRTYPE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nHDRTYPE = i; +#ifdef _DEBUG + m_bHDRTYPE = true; +#endif + } + void SetHDRTYPE( bool i ) + { + m_nHDRTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bHDRTYPE = true; +#endif + } +private: + int m_nSRGB; +#ifdef _DEBUG + bool m_bSRGB; +#endif +public: + void SetSRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSRGB = i; +#ifdef _DEBUG + m_bSRGB = true; +#endif + } + void SetSRGB( bool i ) + { + m_nSRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bSRGB = true; +#endif + } +private: + int m_nSRGB_OUTPUT_ADAPTER; +#ifdef _DEBUG + bool m_bSRGB_OUTPUT_ADAPTER; +#endif +public: + void SetSRGB_OUTPUT_ADAPTER( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSRGB_OUTPUT_ADAPTER = i; +#ifdef _DEBUG + m_bSRGB_OUTPUT_ADAPTER = true; +#endif + } + void SetSRGB_OUTPUT_ADAPTER( bool i ) + { + m_nSRGB_OUTPUT_ADAPTER = i ? 1 : 0; +#ifdef _DEBUG + m_bSRGB_OUTPUT_ADAPTER = true; +#endif + } +public: + sdk_sprite_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bCONSTANTCOLOR = false; +#endif // _DEBUG + m_nCONSTANTCOLOR = 0; +#ifdef _DEBUG + m_bHDRTYPE = false; +#endif // _DEBUG + m_nHDRTYPE = 0; +#ifdef _DEBUG + m_bSRGB = false; +#endif // _DEBUG + m_nSRGB = 0; +#ifdef _DEBUG + m_bSRGB_OUTPUT_ADAPTER = false; +#endif // _DEBUG + m_nSRGB_OUTPUT_ADAPTER = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bVERTEXCOLOR && m_bCONSTANTCOLOR && m_bHDRTYPE && m_bSRGB && m_bSRGB_OUTPUT_ADAPTER; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nCONVERT_TO_SRGB ) + ( 8 * m_nVERTEXCOLOR ) + ( 16 * m_nCONSTANTCOLOR ) + ( 32 * m_nHDRTYPE ) + ( 96 * m_nSRGB ) + ( 192 * m_nSRGB_OUTPUT_ADAPTER ) + 0; + } +}; +#define shaderStaticTest_sdk_sprite_ps20b psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_CONSTANTCOLOR + psh_forgot_to_set_static_HDRTYPE + psh_forgot_to_set_static_SRGB + psh_forgot_to_set_static_SRGB_OUTPUT_ADAPTER + 0 +class sdk_sprite_ps20b_Dynamic_Index +{ +private: + int m_nHDRENABLED; +#ifdef _DEBUG + bool m_bHDRENABLED; +#endif +public: + void SetHDRENABLED( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHDRENABLED = i; +#ifdef _DEBUG + m_bHDRENABLED = true; +#endif + } + void SetHDRENABLED( bool i ) + { + m_nHDRENABLED = i ? 1 : 0; +#ifdef _DEBUG + m_bHDRENABLED = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_sprite_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bHDRENABLED = false; +#endif // _DEBUG + m_nHDRENABLED = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bHDRENABLED && m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nHDRENABLED ) + ( 2 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_sprite_ps20b psh_forgot_to_set_dynamic_HDRENABLED + psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_sprite_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_sprite_vs20.inc new file mode 100644 index 00000000..25ac196d --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_sprite_vs20.inc @@ -0,0 +1,112 @@ +#include "shaderlib/cshader.h" +class sdk_sprite_vs20_Static_Index +{ +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nSRGB; +#ifdef _DEBUG + bool m_bSRGB; +#endif +public: + void SetSRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSRGB = i; +#ifdef _DEBUG + m_bSRGB = true; +#endif + } + void SetSRGB( bool i ) + { + m_nSRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bSRGB = true; +#endif + } +public: + sdk_sprite_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bSRGB = false; +#endif // _DEBUG + m_nSRGB = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bVERTEXCOLOR && m_bSRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nVERTEXCOLOR ) + ( 4 * m_nSRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_sprite_vs20 vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_SRGB + 0 +class sdk_sprite_vs20_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_sprite_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; +#define shaderDynamicTest_sdk_sprite_vs20 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_bump_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_bump_ps20.inc new file mode 100644 index 00000000..bd2b6155 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_bump_ps20.inc @@ -0,0 +1,110 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_bump_ps20_Static_Index +{ +public: + sdk_teeth_bump_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_teeth_bump_ps20 0 +class sdk_teeth_bump_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nAMBIENT_LIGHT; +#ifdef _DEBUG + bool m_bAMBIENT_LIGHT; +#endif +public: + void SetAMBIENT_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nAMBIENT_LIGHT = i; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } + void SetAMBIENT_LIGHT( bool i ) + { + m_nAMBIENT_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } +public: + sdk_teeth_bump_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = false; +#endif // _DEBUG + m_nAMBIENT_LIGHT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bNUM_LIGHTS && m_bAMBIENT_LIGHT; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nNUM_LIGHTS ) + ( 6 * m_nAMBIENT_LIGHT ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_bump_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_AMBIENT_LIGHT + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_bump_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_bump_ps20b.inc new file mode 100644 index 00000000..8d774cf4 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_bump_ps20b.inc @@ -0,0 +1,162 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_bump_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_teeth_bump_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 40 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_bump_ps20b 0 +class sdk_teeth_bump_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nAMBIENT_LIGHT; +#ifdef _DEBUG + bool m_bAMBIENT_LIGHT; +#endif +public: + void SetAMBIENT_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nAMBIENT_LIGHT = i; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } + void SetAMBIENT_LIGHT( bool i ) + { + m_nAMBIENT_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +public: + sdk_teeth_bump_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = false; +#endif // _DEBUG + m_nAMBIENT_LIGHT = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bNUM_LIGHTS && m_bAMBIENT_LIGHT && m_bWRITE_DEPTH_TO_DESTALPHA; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nNUM_LIGHTS ) + ( 10 * m_nAMBIENT_LIGHT ) + ( 20 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_bump_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_AMBIENT_LIGHT + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_bump_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_bump_ps30.inc new file mode 100644 index 00000000..b3ae4c8f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_bump_ps30.inc @@ -0,0 +1,162 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_bump_ps30_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_teeth_bump_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 40 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_bump_ps30 0 +class sdk_teeth_bump_ps30_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nAMBIENT_LIGHT; +#ifdef _DEBUG + bool m_bAMBIENT_LIGHT; +#endif +public: + void SetAMBIENT_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nAMBIENT_LIGHT = i; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } + void SetAMBIENT_LIGHT( bool i ) + { + m_nAMBIENT_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +public: + sdk_teeth_bump_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = false; +#endif // _DEBUG + m_nAMBIENT_LIGHT = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bNUM_LIGHTS && m_bAMBIENT_LIGHT && m_bWRITE_DEPTH_TO_DESTALPHA; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nNUM_LIGHTS ) + ( 10 * m_nAMBIENT_LIGHT ) + ( 20 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_bump_ps30 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_AMBIENT_LIGHT + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_bump_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_bump_vs20.inc new file mode 100644 index 00000000..95700dc2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_bump_vs20.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_bump_vs20_Static_Index +{ +private: + int m_nINTRO; +#ifdef _DEBUG + bool m_bINTRO; +#endif +public: + void SetINTRO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nINTRO = i; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } + void SetINTRO( bool i ) + { + m_nINTRO = i ? 1 : 0; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } +private: + int m_nUSE_STATIC_CONTROL_FLOW; +#ifdef _DEBUG + bool m_bUSE_STATIC_CONTROL_FLOW; +#endif +public: + void SetUSE_STATIC_CONTROL_FLOW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nUSE_STATIC_CONTROL_FLOW = i; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } + void SetUSE_STATIC_CONTROL_FLOW( bool i ) + { + m_nUSE_STATIC_CONTROL_FLOW = i ? 1 : 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } +public: + sdk_teeth_bump_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bINTRO = false; +#endif // _DEBUG + m_nINTRO = 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = false; +#endif // _DEBUG + m_nUSE_STATIC_CONTROL_FLOW = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bINTRO && m_bUSE_STATIC_CONTROL_FLOW; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 48 * m_nINTRO ) + ( 96 * m_nUSE_STATIC_CONTROL_FLOW ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_bump_vs20 vsh_forgot_to_set_static_INTRO + vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + 0 +class sdk_teeth_bump_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_teeth_bump_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bSTATIC_LIGHT && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nSTATIC_LIGHT ) + ( 16 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_bump_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_bump_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_bump_vs30.inc new file mode 100644 index 00000000..61d78dbe --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_bump_vs30.inc @@ -0,0 +1,187 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_bump_vs30_Static_Index +{ +private: + int m_nINTRO; +#ifdef _DEBUG + bool m_bINTRO; +#endif +public: + void SetINTRO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nINTRO = i; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } + void SetINTRO( bool i ) + { + m_nINTRO = i ? 1 : 0; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } +public: + sdk_teeth_bump_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bINTRO = false; +#endif // _DEBUG + m_nINTRO = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bINTRO; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 32 * m_nINTRO ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_bump_vs30 vsh_forgot_to_set_static_INTRO + 0 +class sdk_teeth_bump_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_teeth_bump_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bSTATIC_LIGHT && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nSTATIC_LIGHT ) + ( 16 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_bump_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_flashlight_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_flashlight_ps20.inc new file mode 100644 index 00000000..773cf54a --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_flashlight_ps20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_flashlight_ps20_Static_Index +{ +public: + sdk_teeth_flashlight_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_teeth_flashlight_ps20 0 +class sdk_teeth_flashlight_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_teeth_flashlight_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_flashlight_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_flashlight_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_flashlight_ps20b.inc new file mode 100644 index 00000000..209eb19f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_flashlight_ps20b.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_flashlight_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_teeth_flashlight_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nCONVERT_TO_SRGB ) + ( 8 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_flashlight_ps20b psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_teeth_flashlight_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_teeth_flashlight_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_flashlight_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_flashlight_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_flashlight_ps30.inc new file mode 100644 index 00000000..3e08d8f2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_flashlight_ps30.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_flashlight_ps30_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_teeth_flashlight_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nCONVERT_TO_SRGB ) + ( 8 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_flashlight_ps30 psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_teeth_flashlight_ps30_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_teeth_flashlight_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_flashlight_ps30 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_flashlight_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_flashlight_vs20.inc new file mode 100644 index 00000000..b3728827 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_flashlight_vs20.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_flashlight_vs20_Static_Index +{ +private: + int m_nINTRO; +#ifdef _DEBUG + bool m_bINTRO; +#endif +public: + void SetINTRO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nINTRO = i; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } + void SetINTRO( bool i ) + { + m_nINTRO = i ? 1 : 0; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } +public: + sdk_teeth_flashlight_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bINTRO = false; +#endif // _DEBUG + m_nINTRO = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bINTRO; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 8 * m_nINTRO ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_flashlight_vs20 vsh_forgot_to_set_static_INTRO + 0 +class sdk_teeth_flashlight_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_teeth_flashlight_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_flashlight_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_flashlight_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_flashlight_vs30.inc new file mode 100644 index 00000000..e69d95bf --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_flashlight_vs30.inc @@ -0,0 +1,162 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_flashlight_vs30_Static_Index +{ +private: + int m_nINTRO; +#ifdef _DEBUG + bool m_bINTRO; +#endif +public: + void SetINTRO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nINTRO = i; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } + void SetINTRO( bool i ) + { + m_nINTRO = i ? 1 : 0; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } +public: + sdk_teeth_flashlight_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bINTRO = false; +#endif // _DEBUG + m_nINTRO = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bINTRO; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 16 * m_nINTRO ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_flashlight_vs30 vsh_forgot_to_set_static_INTRO + 0 +class sdk_teeth_flashlight_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_teeth_flashlight_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_flashlight_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_ps20.inc new file mode 100644 index 00000000..b7eae9b2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_ps20.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_ps20_Static_Index +{ +public: + sdk_teeth_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_teeth_ps20 0 +class sdk_teeth_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_teeth_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_ps20b.inc new file mode 100644 index 00000000..1fcf1c6b --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_ps20b.inc @@ -0,0 +1,112 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_teeth_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_ps20b 0 +class sdk_teeth_ps20b_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +public: + sdk_teeth_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bWRITE_DEPTH_TO_DESTALPHA; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_ps30.inc new file mode 100644 index 00000000..d2cc52f3 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_ps30.inc @@ -0,0 +1,112 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_ps30_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_teeth_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_ps30 0 +class sdk_teeth_ps30_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +public: + sdk_teeth_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bWRITE_DEPTH_TO_DESTALPHA; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_ps30 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_vs20.inc new file mode 100644 index 00000000..18cc3990 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_vs20.inc @@ -0,0 +1,237 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_vs20_Static_Index +{ +private: + int m_nINTRO; +#ifdef _DEBUG + bool m_bINTRO; +#endif +public: + void SetINTRO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nINTRO = i; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } + void SetINTRO( bool i ) + { + m_nINTRO = i ? 1 : 0; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } +private: + int m_nUSE_STATIC_CONTROL_FLOW; +#ifdef _DEBUG + bool m_bUSE_STATIC_CONTROL_FLOW; +#endif +public: + void SetUSE_STATIC_CONTROL_FLOW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nUSE_STATIC_CONTROL_FLOW = i; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } + void SetUSE_STATIC_CONTROL_FLOW( bool i ) + { + m_nUSE_STATIC_CONTROL_FLOW = i ? 1 : 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } +public: + sdk_teeth_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bINTRO = false; +#endif // _DEBUG + m_nINTRO = 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = false; +#endif // _DEBUG + m_nUSE_STATIC_CONTROL_FLOW = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bINTRO && m_bUSE_STATIC_CONTROL_FLOW; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 96 * m_nINTRO ) + ( 192 * m_nUSE_STATIC_CONTROL_FLOW ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_vs20 vsh_forgot_to_set_static_INTRO + vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + 0 +class sdk_teeth_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nDYNAMIC_LIGHT; +#ifdef _DEBUG + bool m_bDYNAMIC_LIGHT; +#endif +public: + void SetDYNAMIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDYNAMIC_LIGHT = i; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } + void SetDYNAMIC_LIGHT( bool i ) + { + m_nDYNAMIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_teeth_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = false; +#endif // _DEBUG + m_nDYNAMIC_LIGHT = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bDYNAMIC_LIGHT && m_bSTATIC_LIGHT && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nDYNAMIC_LIGHT ) + ( 16 * m_nSTATIC_LIGHT ) + ( 32 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_DYNAMIC_LIGHT + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_vs30.inc new file mode 100644 index 00000000..985f57e8 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_teeth_vs30.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_teeth_vs30_Static_Index +{ +private: + int m_nINTRO; +#ifdef _DEBUG + bool m_bINTRO; +#endif +public: + void SetINTRO( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nINTRO = i; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } + void SetINTRO( bool i ) + { + m_nINTRO = i ? 1 : 0; +#ifdef _DEBUG + m_bINTRO = true; +#endif + } +public: + sdk_teeth_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bINTRO = false; +#endif // _DEBUG + m_nINTRO = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bINTRO; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 64 * m_nINTRO ) + 0; + } +}; +#define shaderStaticTest_sdk_teeth_vs30 vsh_forgot_to_set_static_INTRO + 0 +class sdk_teeth_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nDYNAMIC_LIGHT; +#ifdef _DEBUG + bool m_bDYNAMIC_LIGHT; +#endif +public: + void SetDYNAMIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDYNAMIC_LIGHT = i; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } + void SetDYNAMIC_LIGHT( bool i ) + { + m_nDYNAMIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_teeth_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = false; +#endif // _DEBUG + m_nDYNAMIC_LIGHT = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bDYNAMIC_LIGHT && m_bSTATIC_LIGHT && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nDYNAMIC_LIGHT ) + ( 16 * m_nSTATIC_LIGHT ) + ( 32 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_teeth_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_DYNAMIC_LIGHT + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_unlitgeneric_ps11.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_unlitgeneric_ps11.inc new file mode 100644 index 00000000..30c5c529 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_unlitgeneric_ps11.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_unlitgeneric_ps11_Static_Index +{ +public: + sdk_unlitgeneric_ps11_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_unlitgeneric_ps11 0 +class sdk_unlitgeneric_ps11_Dynamic_Index +{ +public: + sdk_unlitgeneric_ps11_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_unlitgeneric_ps11 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_unlitgeneric_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_unlitgeneric_ps20.inc new file mode 100644 index 00000000..96088dec --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_unlitgeneric_ps20.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_unlitgeneric_ps20_Static_Index +{ +public: + sdk_unlitgeneric_ps20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_unlitgeneric_ps20 0 +class sdk_unlitgeneric_ps20_Dynamic_Index +{ +public: + sdk_unlitgeneric_ps20_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_unlitgeneric_ps20 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_unlitgeneric_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_unlitgeneric_ps20b.inc new file mode 100644 index 00000000..5f0347a2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_unlitgeneric_ps20b.inc @@ -0,0 +1,60 @@ +#include "shaderlib/cshader.h" +class sdk_unlitgeneric_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +public: + sdk_unlitgeneric_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCONVERT_TO_SRGB ) + 0; + } +}; +#define shaderStaticTest_sdk_unlitgeneric_ps20b 0 +class sdk_unlitgeneric_ps20b_Dynamic_Index +{ +public: + sdk_unlitgeneric_ps20b_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_unlitgeneric_ps20b 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_unlitgeneric_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_unlitgeneric_vs20.inc new file mode 100644 index 00000000..ea58edbc --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_unlitgeneric_vs20.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_unlitgeneric_vs20_Static_Index +{ +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +public: + sdk_unlitgeneric_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bVERTEXCOLOR; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 8 * m_nVERTEXCOLOR ) + 0; + } +}; +#define shaderStaticTest_sdk_unlitgeneric_vs20 vsh_forgot_to_set_static_VERTEXCOLOR + 0 +class sdk_unlitgeneric_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_unlitgeneric_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + 0; + } +}; +#define shaderDynamicTest_sdk_unlitgeneric_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_bump_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_bump_ps20.inc new file mode 100644 index 00000000..a526e689 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_bump_ps20.inc @@ -0,0 +1,412 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_and_unlit_generic_bump_ps20_Static_Index +{ +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nDIFFUSELIGHTING; +#ifdef _DEBUG + bool m_bDIFFUSELIGHTING; +#endif +public: + void SetDIFFUSELIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSELIGHTING = i; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } + void SetDIFFUSELIGHTING( bool i ) + { + m_nDIFFUSELIGHTING = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } +private: + int m_nLIGHTWARPTEXTURE; +#ifdef _DEBUG + bool m_bLIGHTWARPTEXTURE; +#endif +public: + void SetLIGHTWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTWARPTEXTURE = i; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } + void SetLIGHTWARPTEXTURE( bool i ) + { + m_nLIGHTWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nSELFILLUMFRESNEL; +#ifdef _DEBUG + bool m_bSELFILLUMFRESNEL; +#endif +public: + void SetSELFILLUMFRESNEL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUMFRESNEL = i; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = true; +#endif + } + void SetSELFILLUMFRESNEL( bool i ) + { + m_nSELFILLUMFRESNEL = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = true; +#endif + } +private: + int m_nNORMALMAPALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bNORMALMAPALPHAENVMAPMASK; +#endif +public: + void SetNORMALMAPALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAPALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif + } + void SetNORMALMAPALPHAENVMAPMASK( bool i ) + { + m_nNORMALMAPALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 6 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nBLENDTINTBYBASEALPHA; +#ifdef _DEBUG + bool m_bBLENDTINTBYBASEALPHA; +#endif +public: + void SetBLENDTINTBYBASEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLENDTINTBYBASEALPHA = i; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } + void SetBLENDTINTBYBASEALPHA( bool i ) + { + m_nBLENDTINTBYBASEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_bump_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = false; +#endif // _DEBUG + m_nDIFFUSELIGHTING = 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = false; +#endif // _DEBUG + m_nLIGHTWARPTEXTURE = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = false; +#endif // _DEBUG + m_nSELFILLUMFRESNEL = 0; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nNORMALMAPALPHAENVMAPMASK = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = false; +#endif // _DEBUG + m_nBLENDTINTBYBASEALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bLIGHTWARPTEXTURE && m_bSELFILLUM && m_bSELFILLUMFRESNEL && m_bNORMALMAPALPHAENVMAPMASK && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bBLENDTINTBYBASEALPHA; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 24 * m_nCUBEMAP ) + ( 48 * m_nDIFFUSELIGHTING ) + ( 96 * m_nLIGHTWARPTEXTURE ) + ( 192 * m_nSELFILLUM ) + ( 384 * m_nSELFILLUMFRESNEL ) + ( 768 * m_nNORMALMAPALPHAENVMAPMASK ) + ( 1536 * m_nHALFLAMBERT ) + ( 3072 * m_nFLASHLIGHT ) + ( 6144 * m_nDETAILTEXTURE ) + ( 12288 * m_nDETAIL_BLEND_MODE ) + ( 86016 * m_nBLENDTINTBYBASEALPHA ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_bump_ps20 psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_SELFILLUMFRESNEL + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_HALFLAMBERT + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + 0 +class sdk_vertexlit_and_unlit_generic_bump_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nWRITEWATERFOGTODESTALPHA; +#ifdef _DEBUG + bool m_bWRITEWATERFOGTODESTALPHA; +#endif +public: + void SetWRITEWATERFOGTODESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITEWATERFOGTODESTALPHA = i; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } + void SetWRITEWATERFOGTODESTALPHA( bool i ) + { + m_nWRITEWATERFOGTODESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nAMBIENT_LIGHT; +#ifdef _DEBUG + bool m_bAMBIENT_LIGHT; +#endif +public: + void SetAMBIENT_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nAMBIENT_LIGHT = i; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } + void SetAMBIENT_LIGHT( bool i ) + { + m_nAMBIENT_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_bump_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = false; +#endif // _DEBUG + m_nWRITEWATERFOGTODESTALPHA = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = false; +#endif // _DEBUG + m_nAMBIENT_LIGHT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bWRITEWATERFOGTODESTALPHA && m_bNUM_LIGHTS && m_bAMBIENT_LIGHT; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nWRITEWATERFOGTODESTALPHA ) + ( 4 * m_nNUM_LIGHTS ) + ( 12 * m_nAMBIENT_LIGHT ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_and_unlit_generic_bump_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_AMBIENT_LIGHT + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_bump_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_bump_ps20b.inc new file mode 100644 index 00000000..c6da2788 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_bump_ps20b.inc @@ -0,0 +1,412 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_and_unlit_generic_bump_ps20b_Static_Index +{ +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nDIFFUSELIGHTING; +#ifdef _DEBUG + bool m_bDIFFUSELIGHTING; +#endif +public: + void SetDIFFUSELIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSELIGHTING = i; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } + void SetDIFFUSELIGHTING( bool i ) + { + m_nDIFFUSELIGHTING = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } +private: + int m_nLIGHTWARPTEXTURE; +#ifdef _DEBUG + bool m_bLIGHTWARPTEXTURE; +#endif +public: + void SetLIGHTWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTWARPTEXTURE = i; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } + void SetLIGHTWARPTEXTURE( bool i ) + { + m_nLIGHTWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nSELFILLUMFRESNEL; +#ifdef _DEBUG + bool m_bSELFILLUMFRESNEL; +#endif +public: + void SetSELFILLUMFRESNEL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUMFRESNEL = i; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = true; +#endif + } + void SetSELFILLUMFRESNEL( bool i ) + { + m_nSELFILLUMFRESNEL = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = true; +#endif + } +private: + int m_nNORMALMAPALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bNORMALMAPALPHAENVMAPMASK; +#endif +public: + void SetNORMALMAPALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAPALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif + } + void SetNORMALMAPALPHAENVMAPMASK( bool i ) + { + m_nNORMALMAPALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 6 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +private: + int m_nBLENDTINTBYBASEALPHA; +#ifdef _DEBUG + bool m_bBLENDTINTBYBASEALPHA; +#endif +public: + void SetBLENDTINTBYBASEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLENDTINTBYBASEALPHA = i; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } + void SetBLENDTINTBYBASEALPHA( bool i ) + { + m_nBLENDTINTBYBASEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_bump_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = false; +#endif // _DEBUG + m_nDIFFUSELIGHTING = 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = false; +#endif // _DEBUG + m_nLIGHTWARPTEXTURE = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = false; +#endif // _DEBUG + m_nSELFILLUMFRESNEL = 0; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nNORMALMAPALPHAENVMAPMASK = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = false; +#endif // _DEBUG + m_nBLENDTINTBYBASEALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bLIGHTWARPTEXTURE && m_bSELFILLUM && m_bSELFILLUMFRESNEL && m_bNORMALMAPALPHAENVMAPMASK && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bFLASHLIGHTDEPTHFILTERMODE && m_bBLENDTINTBYBASEALPHA; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 20 * m_nCUBEMAP ) + ( 40 * m_nDIFFUSELIGHTING ) + ( 80 * m_nLIGHTWARPTEXTURE ) + ( 160 * m_nSELFILLUM ) + ( 320 * m_nSELFILLUMFRESNEL ) + ( 640 * m_nNORMALMAPALPHAENVMAPMASK ) + ( 1280 * m_nHALFLAMBERT ) + ( 2560 * m_nFLASHLIGHT ) + ( 5120 * m_nDETAILTEXTURE ) + ( 10240 * m_nDETAIL_BLEND_MODE ) + ( 71680 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 215040 * m_nBLENDTINTBYBASEALPHA ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_bump_ps20b psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_SELFILLUMFRESNEL + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_HALFLAMBERT + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + 0 +class sdk_vertexlit_and_unlit_generic_bump_ps20b_Dynamic_Index +{ +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nAMBIENT_LIGHT; +#ifdef _DEBUG + bool m_bAMBIENT_LIGHT; +#endif +public: + void SetAMBIENT_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nAMBIENT_LIGHT = i; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } + void SetAMBIENT_LIGHT( bool i ) + { + m_nAMBIENT_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_bump_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = false; +#endif // _DEBUG + m_nAMBIENT_LIGHT = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bNUM_LIGHTS && m_bAMBIENT_LIGHT && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nNUM_LIGHTS ) + ( 5 * m_nAMBIENT_LIGHT ) + ( 10 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_and_unlit_generic_bump_ps20b psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_AMBIENT_LIGHT + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_bump_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_bump_ps30.inc new file mode 100644 index 00000000..205a2809 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_bump_ps30.inc @@ -0,0 +1,412 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_and_unlit_generic_bump_ps30_Static_Index +{ +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nDIFFUSELIGHTING; +#ifdef _DEBUG + bool m_bDIFFUSELIGHTING; +#endif +public: + void SetDIFFUSELIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSELIGHTING = i; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } + void SetDIFFUSELIGHTING( bool i ) + { + m_nDIFFUSELIGHTING = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } +private: + int m_nLIGHTWARPTEXTURE; +#ifdef _DEBUG + bool m_bLIGHTWARPTEXTURE; +#endif +public: + void SetLIGHTWARPTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTWARPTEXTURE = i; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } + void SetLIGHTWARPTEXTURE( bool i ) + { + m_nLIGHTWARPTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nSELFILLUMFRESNEL; +#ifdef _DEBUG + bool m_bSELFILLUMFRESNEL; +#endif +public: + void SetSELFILLUMFRESNEL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUMFRESNEL = i; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = true; +#endif + } + void SetSELFILLUMFRESNEL( bool i ) + { + m_nSELFILLUMFRESNEL = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = true; +#endif + } +private: + int m_nNORMALMAPALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bNORMALMAPALPHAENVMAPMASK; +#endif +public: + void SetNORMALMAPALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAPALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif + } + void SetNORMALMAPALPHAENVMAPMASK( bool i ) + { + m_nNORMALMAPALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 6 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +private: + int m_nBLENDTINTBYBASEALPHA; +#ifdef _DEBUG + bool m_bBLENDTINTBYBASEALPHA; +#endif +public: + void SetBLENDTINTBYBASEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLENDTINTBYBASEALPHA = i; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } + void SetBLENDTINTBYBASEALPHA( bool i ) + { + m_nBLENDTINTBYBASEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_bump_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = false; +#endif // _DEBUG + m_nDIFFUSELIGHTING = 0; +#ifdef _DEBUG + m_bLIGHTWARPTEXTURE = false; +#endif // _DEBUG + m_nLIGHTWARPTEXTURE = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bSELFILLUMFRESNEL = false; +#endif // _DEBUG + m_nSELFILLUMFRESNEL = 0; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nNORMALMAPALPHAENVMAPMASK = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = false; +#endif // _DEBUG + m_nBLENDTINTBYBASEALPHA = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bLIGHTWARPTEXTURE && m_bSELFILLUM && m_bSELFILLUMFRESNEL && m_bNORMALMAPALPHAENVMAPMASK && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bFLASHLIGHTDEPTHFILTERMODE && m_bBLENDTINTBYBASEALPHA; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 20 * m_nCUBEMAP ) + ( 40 * m_nDIFFUSELIGHTING ) + ( 80 * m_nLIGHTWARPTEXTURE ) + ( 160 * m_nSELFILLUM ) + ( 320 * m_nSELFILLUMFRESNEL ) + ( 640 * m_nNORMALMAPALPHAENVMAPMASK ) + ( 1280 * m_nHALFLAMBERT ) + ( 2560 * m_nFLASHLIGHT ) + ( 5120 * m_nDETAILTEXTURE ) + ( 10240 * m_nDETAIL_BLEND_MODE ) + ( 71680 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 215040 * m_nBLENDTINTBYBASEALPHA ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_bump_ps30 psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_SELFILLUMFRESNEL + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_HALFLAMBERT + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + 0 +class sdk_vertexlit_and_unlit_generic_bump_ps30_Dynamic_Index +{ +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nAMBIENT_LIGHT; +#ifdef _DEBUG + bool m_bAMBIENT_LIGHT; +#endif +public: + void SetAMBIENT_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nAMBIENT_LIGHT = i; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } + void SetAMBIENT_LIGHT( bool i ) + { + m_nAMBIENT_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_bump_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = false; +#endif // _DEBUG + m_nAMBIENT_LIGHT = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bNUM_LIGHTS && m_bAMBIENT_LIGHT && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nNUM_LIGHTS ) + ( 5 * m_nAMBIENT_LIGHT ) + ( 10 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_and_unlit_generic_bump_ps30 psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_AMBIENT_LIGHT + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_bump_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_bump_vs20.inc new file mode 100644 index 00000000..7c9fe088 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_bump_vs20.inc @@ -0,0 +1,212 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_and_unlit_generic_bump_vs20_Static_Index +{ +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nUSE_WITH_2B; +#ifdef _DEBUG + bool m_bUSE_WITH_2B; +#endif +public: + void SetUSE_WITH_2B( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nUSE_WITH_2B = i; +#ifdef _DEBUG + m_bUSE_WITH_2B = true; +#endif + } + void SetUSE_WITH_2B( bool i ) + { + m_nUSE_WITH_2B = i ? 1 : 0; +#ifdef _DEBUG + m_bUSE_WITH_2B = true; +#endif + } +private: + int m_nUSE_STATIC_CONTROL_FLOW; +#ifdef _DEBUG + bool m_bUSE_STATIC_CONTROL_FLOW; +#endif +public: + void SetUSE_STATIC_CONTROL_FLOW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nUSE_STATIC_CONTROL_FLOW = i; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } + void SetUSE_STATIC_CONTROL_FLOW( bool i ) + { + m_nUSE_STATIC_CONTROL_FLOW = i ? 1 : 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_bump_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bUSE_WITH_2B = false; +#endif // _DEBUG + m_nUSE_WITH_2B = 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = false; +#endif // _DEBUG + m_nUSE_STATIC_CONTROL_FLOW = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bHALFLAMBERT && m_bUSE_WITH_2B && m_bUSE_STATIC_CONTROL_FLOW; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 24 * m_nHALFLAMBERT ) + ( 48 * m_nUSE_WITH_2B ) + ( 96 * m_nUSE_STATIC_CONTROL_FLOW ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_bump_vs20 vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_USE_WITH_2B + vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + 0 +class sdk_vertexlit_and_unlit_generic_bump_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_bump_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_and_unlit_generic_bump_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_bump_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_bump_vs30.inc new file mode 100644 index 00000000..06841a47 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_bump_vs30.inc @@ -0,0 +1,237 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_and_unlit_generic_bump_vs30_Static_Index +{ +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nUSE_WITH_2B; +#ifdef _DEBUG + bool m_bUSE_WITH_2B; +#endif +public: + void SetUSE_WITH_2B( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nUSE_WITH_2B = i; +#ifdef _DEBUG + m_bUSE_WITH_2B = true; +#endif + } + void SetUSE_WITH_2B( bool i ) + { + m_nUSE_WITH_2B = i ? 1 : 0; +#ifdef _DEBUG + m_bUSE_WITH_2B = true; +#endif + } +private: + int m_nDECAL; +#ifdef _DEBUG + bool m_bDECAL; +#endif +public: + void SetDECAL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDECAL = i; +#ifdef _DEBUG + m_bDECAL = true; +#endif + } + void SetDECAL( bool i ) + { + m_nDECAL = i ? 1 : 0; +#ifdef _DEBUG + m_bDECAL = true; +#endif + } +private: + int m_nSM30_VERTEXID; +#ifdef _DEBUG + bool m_bSM30_VERTEXID; +#endif +public: + void SetSM30_VERTEXID( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSM30_VERTEXID = i; +#ifdef _DEBUG + m_bSM30_VERTEXID = true; +#endif + } + void SetSM30_VERTEXID( bool i ) + { + m_nSM30_VERTEXID = i ? 1 : 0; +#ifdef _DEBUG + m_bSM30_VERTEXID = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_bump_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bUSE_WITH_2B = false; +#endif // _DEBUG + m_nUSE_WITH_2B = 0; +#ifdef _DEBUG + m_bDECAL = false; +#endif // _DEBUG + m_nDECAL = 0; +#ifdef _DEBUG + m_bSM30_VERTEXID = false; +#endif // _DEBUG + m_nSM30_VERTEXID = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bHALFLAMBERT && m_bUSE_WITH_2B && m_bDECAL && m_bSM30_VERTEXID; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 16 * m_nHALFLAMBERT ) + ( 32 * m_nUSE_WITH_2B ) + ( 64 * m_nDECAL ) + ( 128 * m_nSM30_VERTEXID ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_bump_vs30 vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_USE_WITH_2B + vsh_forgot_to_set_static_DECAL + vsh_forgot_to_set_static_SM30_VERTEXID + 0 +class sdk_vertexlit_and_unlit_generic_bump_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_bump_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_and_unlit_generic_bump_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_ps20.inc new file mode 100644 index 00000000..0bf098cd --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_ps20.inc @@ -0,0 +1,562 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_and_unlit_generic_ps20_Static_Index +{ +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nDIFFUSELIGHTING; +#ifdef _DEBUG + bool m_bDIFFUSELIGHTING; +#endif +public: + void SetDIFFUSELIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSELIGHTING = i; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } + void SetDIFFUSELIGHTING( bool i ) + { + m_nDIFFUSELIGHTING = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } +private: + int m_nENVMAPMASK; +#ifdef _DEBUG + bool m_bENVMAPMASK; +#endif +public: + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } + void SetENVMAPMASK( bool i ) + { + m_nENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } +private: + int m_nBASEALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bBASEALPHAENVMAPMASK; +#endif +public: + void SetBASEALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASEALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } + void SetBASEALPHAENVMAPMASK( bool i ) + { + m_nBASEALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nSELFILLUM_ENVMAPMASK_ALPHA; +#ifdef _DEBUG + bool m_bSELFILLUM_ENVMAPMASK_ALPHA; +#endif +public: + void SetSELFILLUM_ENVMAPMASK_ALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM_ENVMAPMASK_ALPHA = i; +#ifdef _DEBUG + m_bSELFILLUM_ENVMAPMASK_ALPHA = true; +#endif + } + void SetSELFILLUM_ENVMAPMASK_ALPHA( bool i ) + { + m_nSELFILLUM_ENVMAPMASK_ALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM_ENVMAPMASK_ALPHA = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 9 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nSEAMLESS_BASE; +#ifdef _DEBUG + bool m_bSEAMLESS_BASE; +#endif +public: + void SetSEAMLESS_BASE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS_BASE = i; +#ifdef _DEBUG + m_bSEAMLESS_BASE = true; +#endif + } + void SetSEAMLESS_BASE( bool i ) + { + m_nSEAMLESS_BASE = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS_BASE = true; +#endif + } +private: + int m_nSEAMLESS_DETAIL; +#ifdef _DEBUG + bool m_bSEAMLESS_DETAIL; +#endif +public: + void SetSEAMLESS_DETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS_DETAIL = i; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = true; +#endif + } + void SetSEAMLESS_DETAIL( bool i ) + { + m_nSEAMLESS_DETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = true; +#endif + } +private: + int m_nDISTANCEALPHA; +#ifdef _DEBUG + bool m_bDISTANCEALPHA; +#endif +public: + void SetDISTANCEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDISTANCEALPHA = i; +#ifdef _DEBUG + m_bDISTANCEALPHA = true; +#endif + } + void SetDISTANCEALPHA( bool i ) + { + m_nDISTANCEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bDISTANCEALPHA = true; +#endif + } +private: + int m_nDISTANCEALPHAFROMDETAIL; +#ifdef _DEBUG + bool m_bDISTANCEALPHAFROMDETAIL; +#endif +public: + void SetDISTANCEALPHAFROMDETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDISTANCEALPHAFROMDETAIL = i; +#ifdef _DEBUG + m_bDISTANCEALPHAFROMDETAIL = true; +#endif + } + void SetDISTANCEALPHAFROMDETAIL( bool i ) + { + m_nDISTANCEALPHAFROMDETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bDISTANCEALPHAFROMDETAIL = true; +#endif + } +private: + int m_nSOFT_MASK; +#ifdef _DEBUG + bool m_bSOFT_MASK; +#endif +public: + void SetSOFT_MASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSOFT_MASK = i; +#ifdef _DEBUG + m_bSOFT_MASK = true; +#endif + } + void SetSOFT_MASK( bool i ) + { + m_nSOFT_MASK = i ? 1 : 0; +#ifdef _DEBUG + m_bSOFT_MASK = true; +#endif + } +private: + int m_nOUTLINE; +#ifdef _DEBUG + bool m_bOUTLINE; +#endif +public: + void SetOUTLINE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nOUTLINE = i; +#ifdef _DEBUG + m_bOUTLINE = true; +#endif + } + void SetOUTLINE( bool i ) + { + m_nOUTLINE = i ? 1 : 0; +#ifdef _DEBUG + m_bOUTLINE = true; +#endif + } +private: + int m_nOUTER_GLOW; +#ifdef _DEBUG + bool m_bOUTER_GLOW; +#endif +public: + void SetOUTER_GLOW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nOUTER_GLOW = i; +#ifdef _DEBUG + m_bOUTER_GLOW = true; +#endif + } + void SetOUTER_GLOW( bool i ) + { + m_nOUTER_GLOW = i ? 1 : 0; +#ifdef _DEBUG + m_bOUTER_GLOW = true; +#endif + } +private: + int m_nBLENDTINTBYBASEALPHA; +#ifdef _DEBUG + bool m_bBLENDTINTBYBASEALPHA; +#endif +public: + void SetBLENDTINTBYBASEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLENDTINTBYBASEALPHA = i; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } + void SetBLENDTINTBYBASEALPHA( bool i ) + { + m_nBLENDTINTBYBASEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } +private: + int m_nCUBEMAP_SPHERE_LEGACY; +#ifdef _DEBUG + bool m_bCUBEMAP_SPHERE_LEGACY; +#endif +public: + void SetCUBEMAP_SPHERE_LEGACY( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP_SPHERE_LEGACY = i; +#ifdef _DEBUG + m_bCUBEMAP_SPHERE_LEGACY = true; +#endif + } + void SetCUBEMAP_SPHERE_LEGACY( bool i ) + { + m_nCUBEMAP_SPHERE_LEGACY = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP_SPHERE_LEGACY = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = false; +#endif // _DEBUG + m_nDIFFUSELIGHTING = 0; +#ifdef _DEBUG + m_bENVMAPMASK = false; +#endif // _DEBUG + m_nENVMAPMASK = 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nBASEALPHAENVMAPMASK = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bSELFILLUM_ENVMAPMASK_ALPHA = false; +#endif // _DEBUG + m_nSELFILLUM_ENVMAPMASK_ALPHA = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bSEAMLESS_BASE = false; +#endif // _DEBUG + m_nSEAMLESS_BASE = 0; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = false; +#endif // _DEBUG + m_nSEAMLESS_DETAIL = 0; +#ifdef _DEBUG + m_bDISTANCEALPHA = false; +#endif // _DEBUG + m_nDISTANCEALPHA = 0; +#ifdef _DEBUG + m_bDISTANCEALPHAFROMDETAIL = false; +#endif // _DEBUG + m_nDISTANCEALPHAFROMDETAIL = 0; +#ifdef _DEBUG + m_bSOFT_MASK = false; +#endif // _DEBUG + m_nSOFT_MASK = 0; +#ifdef _DEBUG + m_bOUTLINE = false; +#endif // _DEBUG + m_nOUTLINE = 0; +#ifdef _DEBUG + m_bOUTER_GLOW = false; +#endif // _DEBUG + m_nOUTER_GLOW = 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = false; +#endif // _DEBUG + m_nBLENDTINTBYBASEALPHA = 0; +#ifdef _DEBUG + m_bCUBEMAP_SPHERE_LEGACY = false; +#endif // _DEBUG + m_nCUBEMAP_SPHERE_LEGACY = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bDETAILTEXTURE && m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bENVMAPMASK && m_bBASEALPHAENVMAPMASK && m_bSELFILLUM && m_bVERTEXCOLOR && m_bFLASHLIGHT && m_bSELFILLUM_ENVMAPMASK_ALPHA && m_bDETAIL_BLEND_MODE && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bDISTANCEALPHA && m_bDISTANCEALPHAFROMDETAIL && m_bSOFT_MASK && m_bOUTLINE && m_bOUTER_GLOW && m_bBLENDTINTBYBASEALPHA && m_bCUBEMAP_SPHERE_LEGACY; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 6 * m_nDETAILTEXTURE ) + ( 12 * m_nCUBEMAP ) + ( 24 * m_nDIFFUSELIGHTING ) + ( 48 * m_nENVMAPMASK ) + ( 96 * m_nBASEALPHAENVMAPMASK ) + ( 192 * m_nSELFILLUM ) + ( 384 * m_nVERTEXCOLOR ) + ( 768 * m_nFLASHLIGHT ) + ( 1536 * m_nSELFILLUM_ENVMAPMASK_ALPHA ) + ( 3072 * m_nDETAIL_BLEND_MODE ) + ( 30720 * m_nSEAMLESS_BASE ) + ( 61440 * m_nSEAMLESS_DETAIL ) + ( 122880 * m_nDISTANCEALPHA ) + ( 245760 * m_nDISTANCEALPHAFROMDETAIL ) + ( 491520 * m_nSOFT_MASK ) + ( 983040 * m_nOUTLINE ) + ( 1966080 * m_nOUTER_GLOW ) + ( 3932160 * m_nBLENDTINTBYBASEALPHA ) + ( 7864320 * m_nCUBEMAP_SPHERE_LEGACY ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_ps20 psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_SELFILLUM_ENVMAPMASK_ALPHA + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_SEAMLESS_BASE + psh_forgot_to_set_static_SEAMLESS_DETAIL + psh_forgot_to_set_static_DISTANCEALPHA + psh_forgot_to_set_static_DISTANCEALPHAFROMDETAIL + psh_forgot_to_set_static_SOFT_MASK + psh_forgot_to_set_static_OUTLINE + psh_forgot_to_set_static_OUTER_GLOW + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + psh_forgot_to_set_static_CUBEMAP_SPHERE_LEGACY + 0 +class sdk_vertexlit_and_unlit_generic_ps20_Dynamic_Index +{ +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bPIXELFOGTYPE && m_bLIGHTING_PREVIEW; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nLIGHTING_PREVIEW ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_and_unlit_generic_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_LIGHTING_PREVIEW + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_ps20b.inc new file mode 100644 index 00000000..ee74372c --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_ps20b.inc @@ -0,0 +1,637 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_and_unlit_generic_ps20b_Static_Index +{ +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nDIFFUSELIGHTING; +#ifdef _DEBUG + bool m_bDIFFUSELIGHTING; +#endif +public: + void SetDIFFUSELIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSELIGHTING = i; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } + void SetDIFFUSELIGHTING( bool i ) + { + m_nDIFFUSELIGHTING = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } +private: + int m_nENVMAPMASK; +#ifdef _DEBUG + bool m_bENVMAPMASK; +#endif +public: + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } + void SetENVMAPMASK( bool i ) + { + m_nENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } +private: + int m_nBASEALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bBASEALPHAENVMAPMASK; +#endif +public: + void SetBASEALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASEALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } + void SetBASEALPHAENVMAPMASK( bool i ) + { + m_nBASEALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nSELFILLUM_ENVMAPMASK_ALPHA; +#ifdef _DEBUG + bool m_bSELFILLUM_ENVMAPMASK_ALPHA; +#endif +public: + void SetSELFILLUM_ENVMAPMASK_ALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM_ENVMAPMASK_ALPHA = i; +#ifdef _DEBUG + m_bSELFILLUM_ENVMAPMASK_ALPHA = true; +#endif + } + void SetSELFILLUM_ENVMAPMASK_ALPHA( bool i ) + { + m_nSELFILLUM_ENVMAPMASK_ALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM_ENVMAPMASK_ALPHA = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 9 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nSEAMLESS_BASE; +#ifdef _DEBUG + bool m_bSEAMLESS_BASE; +#endif +public: + void SetSEAMLESS_BASE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS_BASE = i; +#ifdef _DEBUG + m_bSEAMLESS_BASE = true; +#endif + } + void SetSEAMLESS_BASE( bool i ) + { + m_nSEAMLESS_BASE = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS_BASE = true; +#endif + } +private: + int m_nSEAMLESS_DETAIL; +#ifdef _DEBUG + bool m_bSEAMLESS_DETAIL; +#endif +public: + void SetSEAMLESS_DETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS_DETAIL = i; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = true; +#endif + } + void SetSEAMLESS_DETAIL( bool i ) + { + m_nSEAMLESS_DETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = true; +#endif + } +private: + int m_nDISTANCEALPHA; +#ifdef _DEBUG + bool m_bDISTANCEALPHA; +#endif +public: + void SetDISTANCEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDISTANCEALPHA = i; +#ifdef _DEBUG + m_bDISTANCEALPHA = true; +#endif + } + void SetDISTANCEALPHA( bool i ) + { + m_nDISTANCEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bDISTANCEALPHA = true; +#endif + } +private: + int m_nDISTANCEALPHAFROMDETAIL; +#ifdef _DEBUG + bool m_bDISTANCEALPHAFROMDETAIL; +#endif +public: + void SetDISTANCEALPHAFROMDETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDISTANCEALPHAFROMDETAIL = i; +#ifdef _DEBUG + m_bDISTANCEALPHAFROMDETAIL = true; +#endif + } + void SetDISTANCEALPHAFROMDETAIL( bool i ) + { + m_nDISTANCEALPHAFROMDETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bDISTANCEALPHAFROMDETAIL = true; +#endif + } +private: + int m_nSOFT_MASK; +#ifdef _DEBUG + bool m_bSOFT_MASK; +#endif +public: + void SetSOFT_MASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSOFT_MASK = i; +#ifdef _DEBUG + m_bSOFT_MASK = true; +#endif + } + void SetSOFT_MASK( bool i ) + { + m_nSOFT_MASK = i ? 1 : 0; +#ifdef _DEBUG + m_bSOFT_MASK = true; +#endif + } +private: + int m_nOUTLINE; +#ifdef _DEBUG + bool m_bOUTLINE; +#endif +public: + void SetOUTLINE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nOUTLINE = i; +#ifdef _DEBUG + m_bOUTLINE = true; +#endif + } + void SetOUTLINE( bool i ) + { + m_nOUTLINE = i ? 1 : 0; +#ifdef _DEBUG + m_bOUTLINE = true; +#endif + } +private: + int m_nOUTER_GLOW; +#ifdef _DEBUG + bool m_bOUTER_GLOW; +#endif +public: + void SetOUTER_GLOW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nOUTER_GLOW = i; +#ifdef _DEBUG + m_bOUTER_GLOW = true; +#endif + } + void SetOUTER_GLOW( bool i ) + { + m_nOUTER_GLOW = i ? 1 : 0; +#ifdef _DEBUG + m_bOUTER_GLOW = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +private: + int m_nDEPTHBLEND; +#ifdef _DEBUG + bool m_bDEPTHBLEND; +#endif +public: + void SetDEPTHBLEND( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDEPTHBLEND = i; +#ifdef _DEBUG + m_bDEPTHBLEND = true; +#endif + } + void SetDEPTHBLEND( bool i ) + { + m_nDEPTHBLEND = i ? 1 : 0; +#ifdef _DEBUG + m_bDEPTHBLEND = true; +#endif + } +private: + int m_nBLENDTINTBYBASEALPHA; +#ifdef _DEBUG + bool m_bBLENDTINTBYBASEALPHA; +#endif +public: + void SetBLENDTINTBYBASEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLENDTINTBYBASEALPHA = i; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } + void SetBLENDTINTBYBASEALPHA( bool i ) + { + m_nBLENDTINTBYBASEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } +private: + int m_nSRGB_INPUT_ADAPTER; +#ifdef _DEBUG + bool m_bSRGB_INPUT_ADAPTER; +#endif +public: + void SetSRGB_INPUT_ADAPTER( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSRGB_INPUT_ADAPTER = i; +#ifdef _DEBUG + m_bSRGB_INPUT_ADAPTER = true; +#endif + } + void SetSRGB_INPUT_ADAPTER( bool i ) + { + m_nSRGB_INPUT_ADAPTER = i ? 1 : 0; +#ifdef _DEBUG + m_bSRGB_INPUT_ADAPTER = true; +#endif + } +private: + int m_nCUBEMAP_SPHERE_LEGACY; +#ifdef _DEBUG + bool m_bCUBEMAP_SPHERE_LEGACY; +#endif +public: + void SetCUBEMAP_SPHERE_LEGACY( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP_SPHERE_LEGACY = i; +#ifdef _DEBUG + m_bCUBEMAP_SPHERE_LEGACY = true; +#endif + } + void SetCUBEMAP_SPHERE_LEGACY( bool i ) + { + m_nCUBEMAP_SPHERE_LEGACY = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP_SPHERE_LEGACY = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = false; +#endif // _DEBUG + m_nDIFFUSELIGHTING = 0; +#ifdef _DEBUG + m_bENVMAPMASK = false; +#endif // _DEBUG + m_nENVMAPMASK = 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nBASEALPHAENVMAPMASK = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bSELFILLUM_ENVMAPMASK_ALPHA = false; +#endif // _DEBUG + m_nSELFILLUM_ENVMAPMASK_ALPHA = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bSEAMLESS_BASE = false; +#endif // _DEBUG + m_nSEAMLESS_BASE = 0; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = false; +#endif // _DEBUG + m_nSEAMLESS_DETAIL = 0; +#ifdef _DEBUG + m_bDISTANCEALPHA = false; +#endif // _DEBUG + m_nDISTANCEALPHA = 0; +#ifdef _DEBUG + m_bDISTANCEALPHAFROMDETAIL = false; +#endif // _DEBUG + m_nDISTANCEALPHAFROMDETAIL = 0; +#ifdef _DEBUG + m_bSOFT_MASK = false; +#endif // _DEBUG + m_nSOFT_MASK = 0; +#ifdef _DEBUG + m_bOUTLINE = false; +#endif // _DEBUG + m_nOUTLINE = 0; +#ifdef _DEBUG + m_bOUTER_GLOW = false; +#endif // _DEBUG + m_nOUTER_GLOW = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; +#ifdef _DEBUG + m_bDEPTHBLEND = false; +#endif // _DEBUG + m_nDEPTHBLEND = 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = false; +#endif // _DEBUG + m_nBLENDTINTBYBASEALPHA = 0; +#ifdef _DEBUG + m_bSRGB_INPUT_ADAPTER = false; +#endif // _DEBUG + m_nSRGB_INPUT_ADAPTER = 0; +#ifdef _DEBUG + m_bCUBEMAP_SPHERE_LEGACY = false; +#endif // _DEBUG + m_nCUBEMAP_SPHERE_LEGACY = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bDETAILTEXTURE && m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bENVMAPMASK && m_bBASEALPHAENVMAPMASK && m_bSELFILLUM && m_bVERTEXCOLOR && m_bFLASHLIGHT && m_bSELFILLUM_ENVMAPMASK_ALPHA && m_bDETAIL_BLEND_MODE && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bDISTANCEALPHA && m_bDISTANCEALPHAFROMDETAIL && m_bSOFT_MASK && m_bOUTLINE && m_bOUTER_GLOW && m_bFLASHLIGHTDEPTHFILTERMODE && m_bDEPTHBLEND && m_bBLENDTINTBYBASEALPHA && m_bSRGB_INPUT_ADAPTER && m_bCUBEMAP_SPHERE_LEGACY; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 6 * m_nDETAILTEXTURE ) + ( 12 * m_nCUBEMAP ) + ( 24 * m_nDIFFUSELIGHTING ) + ( 48 * m_nENVMAPMASK ) + ( 96 * m_nBASEALPHAENVMAPMASK ) + ( 192 * m_nSELFILLUM ) + ( 384 * m_nVERTEXCOLOR ) + ( 768 * m_nFLASHLIGHT ) + ( 1536 * m_nSELFILLUM_ENVMAPMASK_ALPHA ) + ( 3072 * m_nDETAIL_BLEND_MODE ) + ( 30720 * m_nSEAMLESS_BASE ) + ( 61440 * m_nSEAMLESS_DETAIL ) + ( 122880 * m_nDISTANCEALPHA ) + ( 245760 * m_nDISTANCEALPHAFROMDETAIL ) + ( 491520 * m_nSOFT_MASK ) + ( 983040 * m_nOUTLINE ) + ( 1966080 * m_nOUTER_GLOW ) + ( 3932160 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 11796480 * m_nDEPTHBLEND ) + ( 23592960 * m_nBLENDTINTBYBASEALPHA ) + ( 47185920 * m_nSRGB_INPUT_ADAPTER ) + ( 94371840 * m_nCUBEMAP_SPHERE_LEGACY ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_ps20b psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_SELFILLUM_ENVMAPMASK_ALPHA + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_SEAMLESS_BASE + psh_forgot_to_set_static_SEAMLESS_DETAIL + psh_forgot_to_set_static_DISTANCEALPHA + psh_forgot_to_set_static_DISTANCEALPHAFROMDETAIL + psh_forgot_to_set_static_SOFT_MASK + psh_forgot_to_set_static_OUTLINE + psh_forgot_to_set_static_OUTER_GLOW + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_DEPTHBLEND + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + psh_forgot_to_set_static_SRGB_INPUT_ADAPTER + psh_forgot_to_set_static_CUBEMAP_SPHERE_LEGACY + 0 +class sdk_vertexlit_and_unlit_generic_ps20b_Dynamic_Index +{ +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bLIGHTING_PREVIEW && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nLIGHTING_PREVIEW ) + ( 3 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_and_unlit_generic_ps20b psh_forgot_to_set_dynamic_LIGHTING_PREVIEW + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_ps30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_ps30.inc new file mode 100644 index 00000000..c5a18611 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_ps30.inc @@ -0,0 +1,612 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_and_unlit_generic_ps30_Static_Index +{ +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nDIFFUSELIGHTING; +#ifdef _DEBUG + bool m_bDIFFUSELIGHTING; +#endif +public: + void SetDIFFUSELIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSELIGHTING = i; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } + void SetDIFFUSELIGHTING( bool i ) + { + m_nDIFFUSELIGHTING = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } +private: + int m_nENVMAPMASK; +#ifdef _DEBUG + bool m_bENVMAPMASK; +#endif +public: + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } + void SetENVMAPMASK( bool i ) + { + m_nENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif + } +private: + int m_nBASEALPHAENVMAPMASK; +#ifdef _DEBUG + bool m_bBASEALPHAENVMAPMASK; +#endif +public: + void SetBASEALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASEALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } + void SetBASEALPHAENVMAPMASK( bool i ) + { + m_nBASEALPHAENVMAPMASK = i ? 1 : 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nSELFILLUM_ENVMAPMASK_ALPHA; +#ifdef _DEBUG + bool m_bSELFILLUM_ENVMAPMASK_ALPHA; +#endif +public: + void SetSELFILLUM_ENVMAPMASK_ALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM_ENVMAPMASK_ALPHA = i; +#ifdef _DEBUG + m_bSELFILLUM_ENVMAPMASK_ALPHA = true; +#endif + } + void SetSELFILLUM_ENVMAPMASK_ALPHA( bool i ) + { + m_nSELFILLUM_ENVMAPMASK_ALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM_ENVMAPMASK_ALPHA = true; +#endif + } +private: + int m_nDETAIL_BLEND_MODE; +#ifdef _DEBUG + bool m_bDETAIL_BLEND_MODE; +#endif +public: + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 9 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } + void SetDETAIL_BLEND_MODE( bool i ) + { + m_nDETAIL_BLEND_MODE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif + } +private: + int m_nSEAMLESS_BASE; +#ifdef _DEBUG + bool m_bSEAMLESS_BASE; +#endif +public: + void SetSEAMLESS_BASE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS_BASE = i; +#ifdef _DEBUG + m_bSEAMLESS_BASE = true; +#endif + } + void SetSEAMLESS_BASE( bool i ) + { + m_nSEAMLESS_BASE = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS_BASE = true; +#endif + } +private: + int m_nSEAMLESS_DETAIL; +#ifdef _DEBUG + bool m_bSEAMLESS_DETAIL; +#endif +public: + void SetSEAMLESS_DETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS_DETAIL = i; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = true; +#endif + } + void SetSEAMLESS_DETAIL( bool i ) + { + m_nSEAMLESS_DETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = true; +#endif + } +private: + int m_nDISTANCEALPHA; +#ifdef _DEBUG + bool m_bDISTANCEALPHA; +#endif +public: + void SetDISTANCEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDISTANCEALPHA = i; +#ifdef _DEBUG + m_bDISTANCEALPHA = true; +#endif + } + void SetDISTANCEALPHA( bool i ) + { + m_nDISTANCEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bDISTANCEALPHA = true; +#endif + } +private: + int m_nDISTANCEALPHAFROMDETAIL; +#ifdef _DEBUG + bool m_bDISTANCEALPHAFROMDETAIL; +#endif +public: + void SetDISTANCEALPHAFROMDETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDISTANCEALPHAFROMDETAIL = i; +#ifdef _DEBUG + m_bDISTANCEALPHAFROMDETAIL = true; +#endif + } + void SetDISTANCEALPHAFROMDETAIL( bool i ) + { + m_nDISTANCEALPHAFROMDETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bDISTANCEALPHAFROMDETAIL = true; +#endif + } +private: + int m_nSOFT_MASK; +#ifdef _DEBUG + bool m_bSOFT_MASK; +#endif +public: + void SetSOFT_MASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSOFT_MASK = i; +#ifdef _DEBUG + m_bSOFT_MASK = true; +#endif + } + void SetSOFT_MASK( bool i ) + { + m_nSOFT_MASK = i ? 1 : 0; +#ifdef _DEBUG + m_bSOFT_MASK = true; +#endif + } +private: + int m_nOUTLINE; +#ifdef _DEBUG + bool m_bOUTLINE; +#endif +public: + void SetOUTLINE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nOUTLINE = i; +#ifdef _DEBUG + m_bOUTLINE = true; +#endif + } + void SetOUTLINE( bool i ) + { + m_nOUTLINE = i ? 1 : 0; +#ifdef _DEBUG + m_bOUTLINE = true; +#endif + } +private: + int m_nOUTER_GLOW; +#ifdef _DEBUG + bool m_bOUTER_GLOW; +#endif +public: + void SetOUTER_GLOW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nOUTER_GLOW = i; +#ifdef _DEBUG + m_bOUTER_GLOW = true; +#endif + } + void SetOUTER_GLOW( bool i ) + { + m_nOUTER_GLOW = i ? 1 : 0; +#ifdef _DEBUG + m_bOUTER_GLOW = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +private: + int m_nDEPTHBLEND; +#ifdef _DEBUG + bool m_bDEPTHBLEND; +#endif +public: + void SetDEPTHBLEND( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDEPTHBLEND = i; +#ifdef _DEBUG + m_bDEPTHBLEND = true; +#endif + } + void SetDEPTHBLEND( bool i ) + { + m_nDEPTHBLEND = i ? 1 : 0; +#ifdef _DEBUG + m_bDEPTHBLEND = true; +#endif + } +private: + int m_nBLENDTINTBYBASEALPHA; +#ifdef _DEBUG + bool m_bBLENDTINTBYBASEALPHA; +#endif +public: + void SetBLENDTINTBYBASEALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLENDTINTBYBASEALPHA = i; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } + void SetBLENDTINTBYBASEALPHA( bool i ) + { + m_nBLENDTINTBYBASEALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = true; +#endif + } +private: + int m_nCUBEMAP_SPHERE_LEGACY; +#ifdef _DEBUG + bool m_bCUBEMAP_SPHERE_LEGACY; +#endif +public: + void SetCUBEMAP_SPHERE_LEGACY( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP_SPHERE_LEGACY = i; +#ifdef _DEBUG + m_bCUBEMAP_SPHERE_LEGACY = true; +#endif + } + void SetCUBEMAP_SPHERE_LEGACY( bool i ) + { + m_nCUBEMAP_SPHERE_LEGACY = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP_SPHERE_LEGACY = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_ps30_Static_Index( ) + { +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = false; +#endif // _DEBUG + m_nDIFFUSELIGHTING = 0; +#ifdef _DEBUG + m_bENVMAPMASK = false; +#endif // _DEBUG + m_nENVMAPMASK = 0; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = false; +#endif // _DEBUG + m_nBASEALPHAENVMAPMASK = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bSELFILLUM_ENVMAPMASK_ALPHA = false; +#endif // _DEBUG + m_nSELFILLUM_ENVMAPMASK_ALPHA = 0; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = false; +#endif // _DEBUG + m_nDETAIL_BLEND_MODE = 0; +#ifdef _DEBUG + m_bSEAMLESS_BASE = false; +#endif // _DEBUG + m_nSEAMLESS_BASE = 0; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = false; +#endif // _DEBUG + m_nSEAMLESS_DETAIL = 0; +#ifdef _DEBUG + m_bDISTANCEALPHA = false; +#endif // _DEBUG + m_nDISTANCEALPHA = 0; +#ifdef _DEBUG + m_bDISTANCEALPHAFROMDETAIL = false; +#endif // _DEBUG + m_nDISTANCEALPHAFROMDETAIL = 0; +#ifdef _DEBUG + m_bSOFT_MASK = false; +#endif // _DEBUG + m_nSOFT_MASK = 0; +#ifdef _DEBUG + m_bOUTLINE = false; +#endif // _DEBUG + m_nOUTLINE = 0; +#ifdef _DEBUG + m_bOUTER_GLOW = false; +#endif // _DEBUG + m_nOUTER_GLOW = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; +#ifdef _DEBUG + m_bDEPTHBLEND = false; +#endif // _DEBUG + m_nDEPTHBLEND = 0; +#ifdef _DEBUG + m_bBLENDTINTBYBASEALPHA = false; +#endif // _DEBUG + m_nBLENDTINTBYBASEALPHA = 0; +#ifdef _DEBUG + m_bCUBEMAP_SPHERE_LEGACY = false; +#endif // _DEBUG + m_nCUBEMAP_SPHERE_LEGACY = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bDETAILTEXTURE && m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bENVMAPMASK && m_bBASEALPHAENVMAPMASK && m_bSELFILLUM && m_bVERTEXCOLOR && m_bFLASHLIGHT && m_bSELFILLUM_ENVMAPMASK_ALPHA && m_bDETAIL_BLEND_MODE && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bDISTANCEALPHA && m_bDISTANCEALPHAFROMDETAIL && m_bSOFT_MASK && m_bOUTLINE && m_bOUTER_GLOW && m_bFLASHLIGHTDEPTHFILTERMODE && m_bDEPTHBLEND && m_bBLENDTINTBYBASEALPHA && m_bCUBEMAP_SPHERE_LEGACY; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 6 * m_nDETAILTEXTURE ) + ( 12 * m_nCUBEMAP ) + ( 24 * m_nDIFFUSELIGHTING ) + ( 48 * m_nENVMAPMASK ) + ( 96 * m_nBASEALPHAENVMAPMASK ) + ( 192 * m_nSELFILLUM ) + ( 384 * m_nVERTEXCOLOR ) + ( 768 * m_nFLASHLIGHT ) + ( 1536 * m_nSELFILLUM_ENVMAPMASK_ALPHA ) + ( 3072 * m_nDETAIL_BLEND_MODE ) + ( 30720 * m_nSEAMLESS_BASE ) + ( 61440 * m_nSEAMLESS_DETAIL ) + ( 122880 * m_nDISTANCEALPHA ) + ( 245760 * m_nDISTANCEALPHAFROMDETAIL ) + ( 491520 * m_nSOFT_MASK ) + ( 983040 * m_nOUTLINE ) + ( 1966080 * m_nOUTER_GLOW ) + ( 3932160 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 11796480 * m_nDEPTHBLEND ) + ( 23592960 * m_nBLENDTINTBYBASEALPHA ) + ( 47185920 * m_nCUBEMAP_SPHERE_LEGACY ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_ps30 psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_SELFILLUM_ENVMAPMASK_ALPHA + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_SEAMLESS_BASE + psh_forgot_to_set_static_SEAMLESS_DETAIL + psh_forgot_to_set_static_DISTANCEALPHA + psh_forgot_to_set_static_DISTANCEALPHAFROMDETAIL + psh_forgot_to_set_static_SOFT_MASK + psh_forgot_to_set_static_OUTLINE + psh_forgot_to_set_static_OUTER_GLOW + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_DEPTHBLEND + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + psh_forgot_to_set_static_CUBEMAP_SPHERE_LEGACY + 0 +class sdk_vertexlit_and_unlit_generic_ps30_Dynamic_Index +{ +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_ps30_Dynamic_Index() + { +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bLIGHTING_PREVIEW && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nLIGHTING_PREVIEW ) + ( 3 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_and_unlit_generic_ps30 psh_forgot_to_set_dynamic_LIGHTING_PREVIEW + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_vs20.inc new file mode 100644 index 00000000..bfbdd4c7 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_vs20.inc @@ -0,0 +1,437 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_and_unlit_generic_vs20_Static_Index +{ +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nSEAMLESS_BASE; +#ifdef _DEBUG + bool m_bSEAMLESS_BASE; +#endif +public: + void SetSEAMLESS_BASE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS_BASE = i; +#ifdef _DEBUG + m_bSEAMLESS_BASE = true; +#endif + } + void SetSEAMLESS_BASE( bool i ) + { + m_nSEAMLESS_BASE = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS_BASE = true; +#endif + } +private: + int m_nSEAMLESS_DETAIL; +#ifdef _DEBUG + bool m_bSEAMLESS_DETAIL; +#endif +public: + void SetSEAMLESS_DETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS_DETAIL = i; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = true; +#endif + } + void SetSEAMLESS_DETAIL( bool i ) + { + m_nSEAMLESS_DETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = true; +#endif + } +private: + int m_nSEPARATE_DETAIL_UVS; +#ifdef _DEBUG + bool m_bSEPARATE_DETAIL_UVS; +#endif +public: + void SetSEPARATE_DETAIL_UVS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEPARATE_DETAIL_UVS = i; +#ifdef _DEBUG + m_bSEPARATE_DETAIL_UVS = true; +#endif + } + void SetSEPARATE_DETAIL_UVS( bool i ) + { + m_nSEPARATE_DETAIL_UVS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEPARATE_DETAIL_UVS = true; +#endif + } +private: + int m_nUSE_STATIC_CONTROL_FLOW; +#ifdef _DEBUG + bool m_bUSE_STATIC_CONTROL_FLOW; +#endif +public: + void SetUSE_STATIC_CONTROL_FLOW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nUSE_STATIC_CONTROL_FLOW = i; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } + void SetUSE_STATIC_CONTROL_FLOW( bool i ) + { + m_nUSE_STATIC_CONTROL_FLOW = i ? 1 : 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = true; +#endif + } +private: + int m_nDONT_GAMMA_CONVERT_VERTEX_COLOR; +#ifdef _DEBUG + bool m_bDONT_GAMMA_CONVERT_VERTEX_COLOR; +#endif +public: + void SetDONT_GAMMA_CONVERT_VERTEX_COLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDONT_GAMMA_CONVERT_VERTEX_COLOR = i; +#ifdef _DEBUG + m_bDONT_GAMMA_CONVERT_VERTEX_COLOR = true; +#endif + } + void SetDONT_GAMMA_CONVERT_VERTEX_COLOR( bool i ) + { + m_nDONT_GAMMA_CONVERT_VERTEX_COLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bDONT_GAMMA_CONVERT_VERTEX_COLOR = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_vs20_Static_Index( ) + { +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bSEAMLESS_BASE = false; +#endif // _DEBUG + m_nSEAMLESS_BASE = 0; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = false; +#endif // _DEBUG + m_nSEAMLESS_DETAIL = 0; +#ifdef _DEBUG + m_bSEPARATE_DETAIL_UVS = false; +#endif // _DEBUG + m_nSEPARATE_DETAIL_UVS = 0; +#ifdef _DEBUG + m_bUSE_STATIC_CONTROL_FLOW = false; +#endif // _DEBUG + m_nUSE_STATIC_CONTROL_FLOW = 0; +#ifdef _DEBUG + m_bDONT_GAMMA_CONVERT_VERTEX_COLOR = false; +#endif // _DEBUG + m_nDONT_GAMMA_CONVERT_VERTEX_COLOR = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bVERTEXCOLOR && m_bCUBEMAP && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bSEPARATE_DETAIL_UVS && m_bUSE_STATIC_CONTROL_FLOW && m_bDONT_GAMMA_CONVERT_VERTEX_COLOR; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 192 * m_nVERTEXCOLOR ) + ( 384 * m_nCUBEMAP ) + ( 768 * m_nHALFLAMBERT ) + ( 1536 * m_nFLASHLIGHT ) + ( 3072 * m_nSEAMLESS_BASE ) + ( 6144 * m_nSEAMLESS_DETAIL ) + ( 12288 * m_nSEPARATE_DETAIL_UVS ) + ( 24576 * m_nUSE_STATIC_CONTROL_FLOW ) + ( 49152 * m_nDONT_GAMMA_CONVERT_VERTEX_COLOR ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_vs20 vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_CUBEMAP + vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_FLASHLIGHT + vsh_forgot_to_set_static_SEAMLESS_BASE + vsh_forgot_to_set_static_SEAMLESS_DETAIL + vsh_forgot_to_set_static_SEPARATE_DETAIL_UVS + vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + vsh_forgot_to_set_static_DONT_GAMMA_CONVERT_VERTEX_COLOR + 0 +class sdk_vertexlit_and_unlit_generic_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDYNAMIC_LIGHT; +#ifdef _DEBUG + bool m_bDYNAMIC_LIGHT; +#endif +public: + void SetDYNAMIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDYNAMIC_LIGHT = i; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } + void SetDYNAMIC_LIGHT( bool i ) + { + m_nDYNAMIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = false; +#endif // _DEBUG + m_nDYNAMIC_LIGHT = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDYNAMIC_LIGHT && m_bSTATIC_LIGHT && m_bDOWATERFOG && m_bSKINNING && m_bLIGHTING_PREVIEW && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDYNAMIC_LIGHT ) + ( 4 * m_nSTATIC_LIGHT ) + ( 8 * m_nDOWATERFOG ) + ( 16 * m_nSKINNING ) + ( 32 * m_nLIGHTING_PREVIEW ) + ( 64 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_and_unlit_generic_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DYNAMIC_LIGHT + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_LIGHTING_PREVIEW + vsh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_vs30.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_vs30.inc new file mode 100644 index 00000000..d0e8ef40 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_and_unlit_generic_vs30.inc @@ -0,0 +1,462 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_and_unlit_generic_vs30_Static_Index +{ +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nCUBEMAP; +#ifdef _DEBUG + bool m_bCUBEMAP; +#endif +public: + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } + void SetCUBEMAP( bool i ) + { + m_nCUBEMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nSEAMLESS_BASE; +#ifdef _DEBUG + bool m_bSEAMLESS_BASE; +#endif +public: + void SetSEAMLESS_BASE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS_BASE = i; +#ifdef _DEBUG + m_bSEAMLESS_BASE = true; +#endif + } + void SetSEAMLESS_BASE( bool i ) + { + m_nSEAMLESS_BASE = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS_BASE = true; +#endif + } +private: + int m_nSEAMLESS_DETAIL; +#ifdef _DEBUG + bool m_bSEAMLESS_DETAIL; +#endif +public: + void SetSEAMLESS_DETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS_DETAIL = i; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = true; +#endif + } + void SetSEAMLESS_DETAIL( bool i ) + { + m_nSEAMLESS_DETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = true; +#endif + } +private: + int m_nSEPARATE_DETAIL_UVS; +#ifdef _DEBUG + bool m_bSEPARATE_DETAIL_UVS; +#endif +public: + void SetSEPARATE_DETAIL_UVS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEPARATE_DETAIL_UVS = i; +#ifdef _DEBUG + m_bSEPARATE_DETAIL_UVS = true; +#endif + } + void SetSEPARATE_DETAIL_UVS( bool i ) + { + m_nSEPARATE_DETAIL_UVS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEPARATE_DETAIL_UVS = true; +#endif + } +private: + int m_nDECAL; +#ifdef _DEBUG + bool m_bDECAL; +#endif +public: + void SetDECAL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDECAL = i; +#ifdef _DEBUG + m_bDECAL = true; +#endif + } + void SetDECAL( bool i ) + { + m_nDECAL = i ? 1 : 0; +#ifdef _DEBUG + m_bDECAL = true; +#endif + } +private: + int m_nSM30_VERTEXID; +#ifdef _DEBUG + bool m_bSM30_VERTEXID; +#endif +public: + void SetSM30_VERTEXID( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSM30_VERTEXID = i; +#ifdef _DEBUG + m_bSM30_VERTEXID = true; +#endif + } + void SetSM30_VERTEXID( bool i ) + { + m_nSM30_VERTEXID = i ? 1 : 0; +#ifdef _DEBUG + m_bSM30_VERTEXID = true; +#endif + } +private: + int m_nDONT_GAMMA_CONVERT_VERTEX_COLOR; +#ifdef _DEBUG + bool m_bDONT_GAMMA_CONVERT_VERTEX_COLOR; +#endif +public: + void SetDONT_GAMMA_CONVERT_VERTEX_COLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDONT_GAMMA_CONVERT_VERTEX_COLOR = i; +#ifdef _DEBUG + m_bDONT_GAMMA_CONVERT_VERTEX_COLOR = true; +#endif + } + void SetDONT_GAMMA_CONVERT_VERTEX_COLOR( bool i ) + { + m_nDONT_GAMMA_CONVERT_VERTEX_COLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bDONT_GAMMA_CONVERT_VERTEX_COLOR = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_vs30_Static_Index( ) + { +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bCUBEMAP = false; +#endif // _DEBUG + m_nCUBEMAP = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bSEAMLESS_BASE = false; +#endif // _DEBUG + m_nSEAMLESS_BASE = 0; +#ifdef _DEBUG + m_bSEAMLESS_DETAIL = false; +#endif // _DEBUG + m_nSEAMLESS_DETAIL = 0; +#ifdef _DEBUG + m_bSEPARATE_DETAIL_UVS = false; +#endif // _DEBUG + m_nSEPARATE_DETAIL_UVS = 0; +#ifdef _DEBUG + m_bDECAL = false; +#endif // _DEBUG + m_nDECAL = 0; +#ifdef _DEBUG + m_bSM30_VERTEXID = false; +#endif // _DEBUG + m_nSM30_VERTEXID = 0; +#ifdef _DEBUG + m_bDONT_GAMMA_CONVERT_VERTEX_COLOR = false; +#endif // _DEBUG + m_nDONT_GAMMA_CONVERT_VERTEX_COLOR = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bVERTEXCOLOR && m_bCUBEMAP && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bSEPARATE_DETAIL_UVS && m_bDECAL && m_bSM30_VERTEXID && m_bDONT_GAMMA_CONVERT_VERTEX_COLOR; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 128 * m_nVERTEXCOLOR ) + ( 256 * m_nCUBEMAP ) + ( 512 * m_nHALFLAMBERT ) + ( 1024 * m_nFLASHLIGHT ) + ( 2048 * m_nSEAMLESS_BASE ) + ( 4096 * m_nSEAMLESS_DETAIL ) + ( 8192 * m_nSEPARATE_DETAIL_UVS ) + ( 16384 * m_nDECAL ) + ( 32768 * m_nSM30_VERTEXID ) + ( 65536 * m_nDONT_GAMMA_CONVERT_VERTEX_COLOR ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_vs30 vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_CUBEMAP + vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_FLASHLIGHT + vsh_forgot_to_set_static_SEAMLESS_BASE + vsh_forgot_to_set_static_SEAMLESS_DETAIL + vsh_forgot_to_set_static_SEPARATE_DETAIL_UVS + vsh_forgot_to_set_static_DECAL + vsh_forgot_to_set_static_SM30_VERTEXID + vsh_forgot_to_set_static_DONT_GAMMA_CONVERT_VERTEX_COLOR + 0 +class sdk_vertexlit_and_unlit_generic_vs30_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDYNAMIC_LIGHT; +#ifdef _DEBUG + bool m_bDYNAMIC_LIGHT; +#endif +public: + void SetDYNAMIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDYNAMIC_LIGHT = i; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } + void SetDYNAMIC_LIGHT( bool i ) + { + m_nDYNAMIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = true; +#endif + } +private: + int m_nSTATIC_LIGHT; +#ifdef _DEBUG + bool m_bSTATIC_LIGHT; +#endif +public: + void SetSTATIC_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSTATIC_LIGHT = i; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } + void SetSTATIC_LIGHT( bool i ) + { + m_nSTATIC_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nMORPHING; +#ifdef _DEBUG + bool m_bMORPHING; +#endif +public: + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } + void SetMORPHING( bool i ) + { + m_nMORPHING = i ? 1 : 0; +#ifdef _DEBUG + m_bMORPHING = true; +#endif + } +public: + sdk_vertexlit_and_unlit_generic_vs30_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDYNAMIC_LIGHT = false; +#endif // _DEBUG + m_nDYNAMIC_LIGHT = 0; +#ifdef _DEBUG + m_bSTATIC_LIGHT = false; +#endif // _DEBUG + m_nSTATIC_LIGHT = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bMORPHING = false; +#endif // _DEBUG + m_nMORPHING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDYNAMIC_LIGHT && m_bSTATIC_LIGHT && m_bDOWATERFOG && m_bSKINNING && m_bLIGHTING_PREVIEW && m_bMORPHING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDYNAMIC_LIGHT ) + ( 4 * m_nSTATIC_LIGHT ) + ( 8 * m_nDOWATERFOG ) + ( 16 * m_nSKINNING ) + ( 32 * m_nLIGHTING_PREVIEW ) + ( 64 * m_nMORPHING ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_and_unlit_generic_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DYNAMIC_LIGHT + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_LIGHTING_PREVIEW + vsh_forgot_to_set_dynamic_MORPHING + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_lighting_only_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_lighting_only_ps20.inc new file mode 100644 index 00000000..365fb68e --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_lighting_only_ps20.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_lighting_only_ps20_Static_Index +{ +private: + int m_nDIFFUSELIGHTING; +#ifdef _DEBUG + bool m_bDIFFUSELIGHTING; +#endif +public: + void SetDIFFUSELIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSELIGHTING = i; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } + void SetDIFFUSELIGHTING( bool i ) + { + m_nDIFFUSELIGHTING = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +public: + sdk_vertexlit_lighting_only_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bDIFFUSELIGHTING = false; +#endif // _DEBUG + m_nDIFFUSELIGHTING = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bDIFFUSELIGHTING && m_bHALFLAMBERT; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 6 * m_nDIFFUSELIGHTING ) + ( 12 * m_nHALFLAMBERT ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_lighting_only_ps20 psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_HALFLAMBERT + 0 +class sdk_vertexlit_lighting_only_ps20_Dynamic_Index +{ +private: + int m_nAMBIENT_LIGHT; +#ifdef _DEBUG + bool m_bAMBIENT_LIGHT; +#endif +public: + void SetAMBIENT_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nAMBIENT_LIGHT = i; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } + void SetAMBIENT_LIGHT( bool i ) + { + m_nAMBIENT_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_vertexlit_lighting_only_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bAMBIENT_LIGHT = false; +#endif // _DEBUG + m_nAMBIENT_LIGHT = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bAMBIENT_LIGHT && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nAMBIENT_LIGHT ) + ( 2 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_lighting_only_ps20 psh_forgot_to_set_dynamic_AMBIENT_LIGHT + psh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_lighting_only_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_lighting_only_ps20b.inc new file mode 100644 index 00000000..a9d3beaa --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlit_lighting_only_ps20b.inc @@ -0,0 +1,162 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlit_lighting_only_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nDIFFUSELIGHTING; +#ifdef _DEBUG + bool m_bDIFFUSELIGHTING; +#endif +public: + void SetDIFFUSELIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSELIGHTING = i; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } + void SetDIFFUSELIGHTING( bool i ) + { + m_nDIFFUSELIGHTING = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSELIGHTING = true; +#endif + } +private: + int m_nHALFLAMBERT; +#ifdef _DEBUG + bool m_bHALFLAMBERT; +#endif +public: + void SetHALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALFLAMBERT = i; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } + void SetHALFLAMBERT( bool i ) + { + m_nHALFLAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALFLAMBERT = true; +#endif + } +public: + sdk_vertexlit_lighting_only_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bDIFFUSELIGHTING = false; +#endif // _DEBUG + m_nDIFFUSELIGHTING = 0; +#ifdef _DEBUG + m_bHALFLAMBERT = false; +#endif // _DEBUG + m_nHALFLAMBERT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bDIFFUSELIGHTING && m_bHALFLAMBERT; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 10 * m_nCONVERT_TO_SRGB ) + ( 20 * m_nDIFFUSELIGHTING ) + ( 40 * m_nHALFLAMBERT ) + 0; + } +}; +#define shaderStaticTest_sdk_vertexlit_lighting_only_ps20b psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_HALFLAMBERT + 0 +class sdk_vertexlit_lighting_only_ps20b_Dynamic_Index +{ +private: + int m_nAMBIENT_LIGHT; +#ifdef _DEBUG + bool m_bAMBIENT_LIGHT; +#endif +public: + void SetAMBIENT_LIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nAMBIENT_LIGHT = i; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } + void SetAMBIENT_LIGHT( bool i ) + { + m_nAMBIENT_LIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bAMBIENT_LIGHT = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + sdk_vertexlit_lighting_only_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bAMBIENT_LIGHT = false; +#endif // _DEBUG + m_nAMBIENT_LIGHT = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bAMBIENT_LIGHT && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nAMBIENT_LIGHT ) + ( 2 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_sdk_vertexlit_lighting_only_ps20b psh_forgot_to_set_dynamic_AMBIENT_LIGHT + psh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlitgeneric_lightingonly_overbright2_ps11.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlitgeneric_lightingonly_overbright2_ps11.inc new file mode 100644 index 00000000..9f9d2b41 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_vertexlitgeneric_lightingonly_overbright2_ps11.inc @@ -0,0 +1,33 @@ +#include "shaderlib/cshader.h" +class sdk_vertexlitgeneric_lightingonly_overbright2_ps11_Static_Index +{ +public: + sdk_vertexlitgeneric_lightingonly_overbright2_ps11_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_sdk_vertexlitgeneric_lightingonly_overbright2_ps11 0 +class sdk_vertexlitgeneric_lightingonly_overbright2_ps11_Dynamic_Index +{ +public: + sdk_vertexlitgeneric_lightingonly_overbright2_ps11_Dynamic_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderDynamicTest_sdk_vertexlitgeneric_lightingonly_overbright2_ps11 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_worldtwotextureblend_ps20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_worldtwotextureblend_ps20.inc new file mode 100644 index 00000000..eeef1cae --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_worldtwotextureblend_ps20.inc @@ -0,0 +1,287 @@ +#include "shaderlib/cshader.h" +class sdk_worldtwotextureblend_ps20_Static_Index +{ +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nDIFFUSEBUMPMAP; +#ifdef _DEBUG + bool m_bDIFFUSEBUMPMAP; +#endif +public: + void SetDIFFUSEBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSEBUMPMAP = i; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } + void SetDIFFUSEBUMPMAP( bool i ) + { + m_nDIFFUSEBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } +private: + int m_nDETAIL_ALPHA_MASK_BASE_TEXTURE; +#ifdef _DEBUG + bool m_bDETAIL_ALPHA_MASK_BASE_TEXTURE; +#endif +public: + void SetDETAIL_ALPHA_MASK_BASE_TEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL_ALPHA_MASK_BASE_TEXTURE = i; +#ifdef _DEBUG + m_bDETAIL_ALPHA_MASK_BASE_TEXTURE = true; +#endif + } + void SetDETAIL_ALPHA_MASK_BASE_TEXTURE( bool i ) + { + m_nDETAIL_ALPHA_MASK_BASE_TEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_ALPHA_MASK_BASE_TEXTURE = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +public: + sdk_worldtwotextureblend_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = false; +#endif // _DEBUG + m_nDIFFUSEBUMPMAP = 0; +#ifdef _DEBUG + m_bDETAIL_ALPHA_MASK_BASE_TEXTURE = false; +#endif // _DEBUG + m_nDETAIL_ALPHA_MASK_BASE_TEXTURE = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bDETAILTEXTURE && m_bBUMPMAP && m_bVERTEXCOLOR && m_bSELFILLUM && m_bDIFFUSEBUMPMAP && m_bDETAIL_ALPHA_MASK_BASE_TEXTURE && m_bFLASHLIGHT && m_bSEAMLESS; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nDETAILTEXTURE ) + ( 8 * m_nBUMPMAP ) + ( 16 * m_nVERTEXCOLOR ) + ( 32 * m_nSELFILLUM ) + ( 64 * m_nDIFFUSEBUMPMAP ) + ( 128 * m_nDETAIL_ALPHA_MASK_BASE_TEXTURE ) + ( 256 * m_nFLASHLIGHT ) + ( 512 * m_nSEAMLESS ) + 0; + } +}; +#define shaderStaticTest_sdk_worldtwotextureblend_ps20 psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_BUMPMAP + psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_DIFFUSEBUMPMAP + psh_forgot_to_set_static_DETAIL_ALPHA_MASK_BASE_TEXTURE + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_SEAMLESS + 0 +class sdk_worldtwotextureblend_ps20_Dynamic_Index +{ +private: + int m_nWRITEWATERFOGTODESTALPHA; +#ifdef _DEBUG + bool m_bWRITEWATERFOGTODESTALPHA; +#endif +public: + void SetWRITEWATERFOGTODESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITEWATERFOGTODESTALPHA = i; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } + void SetWRITEWATERFOGTODESTALPHA( bool i ) + { + m_nWRITEWATERFOGTODESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +public: + sdk_worldtwotextureblend_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = false; +#endif // _DEBUG + m_nWRITEWATERFOGTODESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bWRITEWATERFOGTODESTALPHA && m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nWRITEWATERFOGTODESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_sdk_worldtwotextureblend_ps20 psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_worldtwotextureblend_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_worldtwotextureblend_ps20b.inc new file mode 100644 index 00000000..5663a738 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_worldtwotextureblend_ps20b.inc @@ -0,0 +1,387 @@ +#include "shaderlib/cshader.h" +class sdk_worldtwotextureblend_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nDETAILTEXTURE; +#ifdef _DEBUG + bool m_bDETAILTEXTURE; +#endif +public: + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } + void SetDETAILTEXTURE( bool i ) + { + m_nDETAILTEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif + } +private: + int m_nBUMPMAP; +#ifdef _DEBUG + bool m_bBUMPMAP; +#endif +public: + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } + void SetBUMPMAP( bool i ) + { + m_nBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif + } +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nSELFILLUM; +#ifdef _DEBUG + bool m_bSELFILLUM; +#endif +public: + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } + void SetSELFILLUM( bool i ) + { + m_nSELFILLUM = i ? 1 : 0; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif + } +private: + int m_nDIFFUSEBUMPMAP; +#ifdef _DEBUG + bool m_bDIFFUSEBUMPMAP; +#endif +public: + void SetDIFFUSEBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSEBUMPMAP = i; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } + void SetDIFFUSEBUMPMAP( bool i ) + { + m_nDIFFUSEBUMPMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif + } +private: + int m_nDETAIL_ALPHA_MASK_BASE_TEXTURE; +#ifdef _DEBUG + bool m_bDETAIL_ALPHA_MASK_BASE_TEXTURE; +#endif +public: + void SetDETAIL_ALPHA_MASK_BASE_TEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL_ALPHA_MASK_BASE_TEXTURE = i; +#ifdef _DEBUG + m_bDETAIL_ALPHA_MASK_BASE_TEXTURE = true; +#endif + } + void SetDETAIL_ALPHA_MASK_BASE_TEXTURE( bool i ) + { + m_nDETAIL_ALPHA_MASK_BASE_TEXTURE = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL_ALPHA_MASK_BASE_TEXTURE = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nSEAMLESS; +#ifdef _DEBUG + bool m_bSEAMLESS; +#endif +public: + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } + void SetSEAMLESS( bool i ) + { + m_nSEAMLESS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + sdk_worldtwotextureblend_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bDETAILTEXTURE = false; +#endif // _DEBUG + m_nDETAILTEXTURE = 0; +#ifdef _DEBUG + m_bBUMPMAP = false; +#endif // _DEBUG + m_nBUMPMAP = 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bSELFILLUM = false; +#endif // _DEBUG + m_nSELFILLUM = 0; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = false; +#endif // _DEBUG + m_nDIFFUSEBUMPMAP = 0; +#ifdef _DEBUG + m_bDETAIL_ALPHA_MASK_BASE_TEXTURE = false; +#endif // _DEBUG + m_nDETAIL_ALPHA_MASK_BASE_TEXTURE = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bSEAMLESS = false; +#endif // _DEBUG + m_nSEAMLESS = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bDETAILTEXTURE && m_bBUMPMAP && m_bVERTEXCOLOR && m_bSELFILLUM && m_bDIFFUSEBUMPMAP && m_bDETAIL_ALPHA_MASK_BASE_TEXTURE && m_bFLASHLIGHT && m_bSEAMLESS && m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 16 * m_nCONVERT_TO_SRGB ) + ( 32 * m_nDETAILTEXTURE ) + ( 64 * m_nBUMPMAP ) + ( 128 * m_nVERTEXCOLOR ) + ( 256 * m_nSELFILLUM ) + ( 512 * m_nDIFFUSEBUMPMAP ) + ( 1024 * m_nDETAIL_ALPHA_MASK_BASE_TEXTURE ) + ( 2048 * m_nFLASHLIGHT ) + ( 4096 * m_nSEAMLESS ) + ( 8192 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_sdk_worldtwotextureblend_ps20b psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_BUMPMAP + psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_DIFFUSEBUMPMAP + psh_forgot_to_set_static_DETAIL_ALPHA_MASK_BASE_TEXTURE + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class sdk_worldtwotextureblend_ps20b_Dynamic_Index +{ +private: + int m_nWRITEWATERFOGTODESTALPHA; +#ifdef _DEBUG + bool m_bWRITEWATERFOGTODESTALPHA; +#endif +public: + void SetWRITEWATERFOGTODESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITEWATERFOGTODESTALPHA = i; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } + void SetWRITEWATERFOGTODESTALPHA( bool i ) + { + m_nWRITEWATERFOGTODESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + sdk_worldtwotextureblend_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = false; +#endif // _DEBUG + m_nWRITEWATERFOGTODESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bWRITEWATERFOGTODESTALPHA && m_bPIXELFOGTYPE && m_bWRITE_DEPTH_TO_DESTALPHA && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nWRITEWATERFOGTODESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + ( 4 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 8 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_sdk_worldtwotextureblend_ps20b psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/example_model_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/example_model_ps20b.inc new file mode 100644 index 00000000..1d9a37a2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/example_model_ps20b.inc @@ -0,0 +1,237 @@ +#include "shaderlib/cshader.h" +class example_model_ps20b_Static_Index +{ +private: + int m_nCONVERT_TO_SRGB; +#ifdef _DEBUG + bool m_bCONVERT_TO_SRGB; +#endif +public: + void SetCONVERT_TO_SRGB( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nCONVERT_TO_SRGB = i; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } + void SetCONVERT_TO_SRGB( bool i ) + { + m_nCONVERT_TO_SRGB = i ? 1 : 0; +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = true; +#endif + } +private: + int m_nFLASHLIGHT; +#ifdef _DEBUG + bool m_bFLASHLIGHT; +#endif +public: + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } + void SetFLASHLIGHT( bool i ) + { + m_nFLASHLIGHT = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif + } +private: + int m_nFLASHLIGHTDEPTHFILTERMODE; +#ifdef _DEBUG + bool m_bFLASHLIGHTDEPTHFILTERMODE; +#endif +public: + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } + void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + { + m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif + } +public: + example_model_ps20b_Static_Index( ) + { +#ifdef _DEBUG + m_bCONVERT_TO_SRGB = false; +#endif // _DEBUG + m_nCONVERT_TO_SRGB = 0; +#ifdef _DEBUG + m_bFLASHLIGHT = false; +#endif // _DEBUG + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bFLASHLIGHT && m_bFLASHLIGHTDEPTHFILTERMODE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 80 * m_nCONVERT_TO_SRGB ) + ( 80 * m_nFLASHLIGHT ) + ( 160 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + } +}; +#define shaderStaticTest_example_model_ps20b psh_forgot_to_set_static_CONVERT_TO_SRGB + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 +class example_model_ps20b_Dynamic_Index +{ +private: + int m_nWRITEWATERFOGTODESTALPHA; +#ifdef _DEBUG + bool m_bWRITEWATERFOGTODESTALPHA; +#endif +public: + void SetWRITEWATERFOGTODESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITEWATERFOGTODESTALPHA = i; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } + void SetWRITEWATERFOGTODESTALPHA( bool i ) + { + m_nWRITEWATERFOGTODESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif + } +private: + int m_nPIXELFOGTYPE; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE; +#endif +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } + void SetPIXELFOGTYPE( bool i ) + { + m_nPIXELFOGTYPE = i ? 1 : 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +private: + int m_nWRITE_DEPTH_TO_DESTALPHA; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA; +#endif +public: + void SetWRITE_DEPTH_TO_DESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITE_DEPTH_TO_DESTALPHA = i; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } + void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = true; +#endif + } +private: + int m_nFLASHLIGHTSHADOWS; +#ifdef _DEBUG + bool m_bFLASHLIGHTSHADOWS; +#endif +public: + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } + void SetFLASHLIGHTSHADOWS( bool i ) + { + m_nFLASHLIGHTSHADOWS = i ? 1 : 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif + } +public: + example_model_ps20b_Dynamic_Index() + { +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = false; +#endif // _DEBUG + m_nWRITEWATERFOGTODESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + m_nFLASHLIGHTSHADOWS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bWRITEWATERFOGTODESTALPHA && m_bPIXELFOGTYPE && m_bNUM_LIGHTS && m_bWRITE_DEPTH_TO_DESTALPHA && m_bFLASHLIGHTSHADOWS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nWRITEWATERFOGTODESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + ( 4 * m_nNUM_LIGHTS ) + ( 20 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 40 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; +#define shaderDynamicTest_example_model_ps20b psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/example_model_vs20.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/example_model_vs20.inc new file mode 100644 index 00000000..fcd08eb2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/example_model_vs20.inc @@ -0,0 +1,160 @@ +#include "shaderlib/cshader.h" +class example_model_vs20_Static_Index +{ +public: + example_model_vs20_Static_Index( ) + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +#define shaderStaticTest_example_model_vs20 0 +class example_model_vs20_Dynamic_Index +{ +private: + int m_nCOMPRESSED_VERTS; +#ifdef _DEBUG + bool m_bCOMPRESSED_VERTS; +#endif +public: + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } + void SetCOMPRESSED_VERTS( bool i ) + { + m_nCOMPRESSED_VERTS = i ? 1 : 0; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif + } +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +private: + int m_nLIGHTING_PREVIEW; +#ifdef _DEBUG + bool m_bLIGHTING_PREVIEW; +#endif +public: + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } + void SetLIGHTING_PREVIEW( bool i ) + { + m_nLIGHTING_PREVIEW = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif + } +private: + int m_nNUM_LIGHTS; +#ifdef _DEBUG + bool m_bNUM_LIGHTS; +#endif +public: + void SetNUM_LIGHTS( int i ) + { + Assert( i >= 0 && i <= 4 ); + m_nNUM_LIGHTS = i; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } + void SetNUM_LIGHTS( bool i ) + { + m_nNUM_LIGHTS = i ? 1 : 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = true; +#endif + } +public: + example_model_vs20_Dynamic_Index() + { +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = false; +#endif // _DEBUG + m_nCOMPRESSED_VERTS = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bNUM_LIGHTS = false; +#endif // _DEBUG + m_nNUM_LIGHTS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bLIGHTING_PREVIEW && m_bNUM_LIGHTS; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nLIGHTING_PREVIEW ) + ( 16 * m_nNUM_LIGHTS ) + 0; + } +}; +#define shaderDynamicTest_example_model_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_LIGHTING_PREVIEW + vsh_forgot_to_set_dynamic_NUM_LIGHTS + 0 diff --git a/sp/src/materialsystem/stdshaders/game_shader_dx9_base.vpc b/sp/src/materialsystem/stdshaders/game_shader_dx9_base.vpc index b89578e8..5e6c047c 100644 --- a/sp/src/materialsystem/stdshaders/game_shader_dx9_base.vpc +++ b/sp/src/materialsystem/stdshaders/game_shader_dx9_base.vpc @@ -8,6 +8,9 @@ $Macro OUTBINDIR "$SRCDIR\..\game\$GAMENAME\bin" $Include "$SRCDIR\vpc_scripts\source_dll_base.vpc" +// Mapbase shaders +$Include "$SRCDIR\materialsystem\stdshaders\game_shader_dx9_mapbase.vpc" [$MAPBASE] + $Configuration "Debug" { $General @@ -34,7 +37,7 @@ $Configuration $AdditionalIncludeDirectories "$BASE;fxctmp9;vshtmp9;" [$WIN32||$POSIX] // $AdditionalIncludeDirectories "$BASE;..\..\dx9sdk\include" [$WIN32] $AdditionalIncludeDirectories "$BASE;fxctmp9_360;vshtmp9_360" [$X360] - $PreprocessorDefinitions "$BASE;STDSHADER_DX9_DLL_EXPORT;FAST_MATERIALVAR_ACCESS;GAME_SHADER_DLL" + $PreprocessorDefinitions "$BASE;STDSHADER_DX9_DLL_EXPORT;FAST_MATERIALVAR_ACCESS" $PreprocessorDefinitions "$BASE;USE_ACTUAL_DX" [($WIN32||$X360) && !$GL] } diff --git a/sp/src/materialsystem/stdshaders/game_shader_dx9_mapbase.vpc b/sp/src/materialsystem/stdshaders/game_shader_dx9_mapbase.vpc new file mode 100644 index 00000000..37ccb254 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/game_shader_dx9_mapbase.vpc @@ -0,0 +1,54 @@ +//----------------------------------------------------------------------------- +// game_shader_dx9_mapbase.vpc +// +// Project Script for Mapbase shader changes +//----------------------------------------------------------------------------- + +$Project +{ + $Folder "Source Files" + { + $File "cloak_blended_pass_helper.cpp" + $File "emissive_scroll_blended_pass_helper.cpp" + $File "flesh_interior_blended_pass_helper.cpp" + $File "lightmappedgeneric_dx9.cpp" + $File "lightmappedgeneric_dx9_helper.cpp" + $File "lightmappedreflective.cpp" + $File "skin_dx9_helper.cpp" + $File "unlitgeneric_dx9.cpp" + $File "vertexlitgeneric_dx9.cpp" + $File "vertexlitgeneric_dx9_helper.cpp" + + $File "common_flashlight_fxc.h" + $File "lightmappedgeneric_dx9_helper.h" + $File "lightmappedgeneric_ps2_3_x.h" + + $File "worldtwotextureblend.cpp" + $File "worldvertextransition.cpp" + $File "worldvertextransition_dx8_helper.cpp" + $File "refract.cpp" + $File "refract_dx9_helper.cpp" + + $File "water.cpp" + $File "depthwrite.cpp" + //$File "cable_dx9.cpp" + $File "splinerope.cpp" + + //$File "eyes.cpp" + $File "eyes_dx9.cpp" + $File "eyes_dx8_dx9_helper.cpp" + $File "eyeball.cpp" + $File "eyeglint_dx9.cpp" + $File "eye_refract.cpp" + $File "eye_refract_helper.cpp" + $File "teeth.cpp" + + //$File "sprite.cpp" + $File "sprite_dx9.cpp" + + $File "decalmodulate_dx9.cpp" + } + + //$Shaders "mapbase_dx9_20b.txt" + //$Shaders "mapbase_dx9_30.txt" +} diff --git a/sp/src/materialsystem/stdshaders/inclist.txt b/sp/src/materialsystem/stdshaders/inclist.txt new file mode 100644 index 00000000..c79c91bf --- /dev/null +++ b/sp/src/materialsystem/stdshaders/inclist.txt @@ -0,0 +1,31 @@ +fxctmp9_tmp\SDK_skin_ps30.inc +fxctmp9_tmp\SDK_skin_vs30.inc +fxctmp9_tmp\SDK_vertexlit_and_unlit_generic_bump_ps30.inc +fxctmp9_tmp\SDK_vertexlit_and_unlit_generic_bump_vs30.inc +fxctmp9_tmp\SDK_vertexlit_and_unlit_generic_ps30.inc +fxctmp9_tmp\SDK_vertexlit_and_unlit_generic_vs30.inc +fxctmp9_tmp\SDK_cloak_blended_pass_ps30.inc +fxctmp9_tmp\SDK_cloak_blended_pass_vs30.inc +fxctmp9_tmp\SDK_emissive_scroll_blended_pass_ps30.inc +fxctmp9_tmp\SDK_emissive_scroll_blended_pass_vs30.inc +fxctmp9_tmp\SDK_flashlight_ps30.inc +fxctmp9_tmp\SDK_lightmappedgeneric_flashlight_vs30.inc +fxctmp9_tmp\SDK_lightmappedgeneric_flashlight_ps30.inc +fxctmp9_tmp\SDK_lightmappedgeneric_ps30.inc +fxctmp9_tmp\SDK_lightmappedgeneric_vs30.inc +fxctmp9_tmp\SDK_depthwrite_ps30.inc +fxctmp9_tmp\SDK_depthwrite_vs30.inc +fxctmp9_tmp\SDK_eyes_ps30.inc +fxctmp9_tmp\SDK_eyes_vs30.inc +fxctmp9_tmp\SDK_eye_refract_ps30.inc +fxctmp9_tmp\SDK_eye_refract_vs30.inc +fxctmp9_tmp\SDK_eyes_flashlight_ps30.inc +fxctmp9_tmp\SDK_eyes_flashlight_vs30.inc +fxctmp9_tmp\SDK_teeth_ps30.inc +fxctmp9_tmp\SDK_teeth_vs30.inc +fxctmp9_tmp\SDK_teeth_bump_ps30.inc +fxctmp9_tmp\SDK_teeth_bump_vs30.inc +fxctmp9_tmp\SDK_teeth_flashlight_ps30.inc +fxctmp9_tmp\SDK_teeth_flashlight_vs30.inc +fxctmp9_tmp\SDK_decalmodulate_ps30.inc +fxctmp9_tmp\SDK_decalmodulate_vs30.inc diff --git a/sp/src/materialsystem/stdshaders/lightmappedgeneric_dx9.cpp b/sp/src/materialsystem/stdshaders/lightmappedgeneric_dx9.cpp index bac124a8..f157e4fd 100644 --- a/sp/src/materialsystem/stdshaders/lightmappedgeneric_dx9.cpp +++ b/sp/src/materialsystem/stdshaders/lightmappedgeneric_dx9.cpp @@ -9,12 +9,11 @@ #include "BaseVSShader.h" #include "convar.h" #include "lightmappedgeneric_dx9_helper.h" +#include "SDK_lightmappedgeneric_ps20b.inc" +#include "SDK_lightmappedgeneric_vs20.inc" -static LightmappedGeneric_DX9_Vars_t s_info; - - -BEGIN_VS_SHADER( LightmappedGeneric, - "Help for LightmappedGeneric" ) +BEGIN_VS_SHADER( SDK_LightmappedGeneric, + "Help for SDK_LightmappedGeneric" ) BEGIN_SHADER_PARAMS SHADER_PARAM( ALBEDO, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "albedo (Base texture with no baked lighting)" ) @@ -22,8 +21,9 @@ BEGIN_VS_SHADER( LightmappedGeneric, SHADER_PARAM( DETAIL, SHADER_PARAM_TYPE_TEXTURE, "shadertest/detail", "detail texture" ) SHADER_PARAM( DETAILFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for $detail" ) SHADER_PARAM( DETAILSCALE, SHADER_PARAM_TYPE_FLOAT, "4", "scale of the detail texture" ) - - SHADER_PARAM( ALPHA2, SHADER_PARAM_TYPE_FLOAT, "1", "" ) + SHADER_PARAM( TRANSLUCENT, SHADER_PARAM_TYPE_BOOL, "0", "" ) + SHADER_PARAM( ALPHATEST, SHADER_PARAM_TYPE_BOOL, "0", "" ) + SHADER_PARAM( ALPHATESTREFERENCE, SHADER_PARAM_TYPE_FLOAT, "0.5", "" ) // detail (multi-) texturing SHADER_PARAM( DETAILBLENDMODE, SHADER_PARAM_TYPE_INTEGER, "0", "mode for combining detail texture with base. 0=normal, 1= additive, 2=alpha blend detail over base, 3=crossfade" ) @@ -49,6 +49,10 @@ BEGIN_VS_SHADER( LightmappedGeneric, SHADER_PARAM( BUMPMASK, SHADER_PARAM_TYPE_TEXTURE, "models/shadertest/shader3_normal", "bump map" ) SHADER_PARAM( BASETEXTURE2, SHADER_PARAM_TYPE_TEXTURE, "shadertest/lightmappedtexture", "Blended texture" ) SHADER_PARAM( FRAME2, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for $basetexture2" ) +#ifdef MAPBASE + // This needs to be a SHADER_PARAM_TYPE_STRING so it isn't considered "defined" by default. + SHADER_PARAM( BASETEXTURETRANSFORM2, SHADER_PARAM_TYPE_STRING, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "$basetexture2 texcoord transform" ) +#endif SHADER_PARAM( BASETEXTURENOENVMAP, SHADER_PARAM_TYPE_BOOL, "0", "" ) SHADER_PARAM( BASETEXTURE2NOENVMAP, SHADER_PARAM_TYPE_BOOL, "0", "" ) SHADER_PARAM( DETAIL_ALPHA_MASK_BASE_TEXTURE, SHADER_PARAM_TYPE_BOOL, "0", @@ -56,15 +60,10 @@ BEGIN_VS_SHADER( LightmappedGeneric, "detail alpha=1, you get detail*base*lightmap" ) SHADER_PARAM( LIGHTWARPTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "light munging lookup texture" ) SHADER_PARAM( BLENDMODULATETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "texture to use r/g channels for blend range for" ) - SHADER_PARAM( MASKEDBLENDING, SHADER_PARAM_TYPE_INTEGER, "0", "blend using texture with no vertex alpha. For using texture blending on non-displacements" ) SHADER_PARAM( BLENDMASKTRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "$blendmodulatetexture texcoord transform" ) + SHADER_PARAM( MASKEDBLENDING, SHADER_PARAM_TYPE_INTEGER, "0", "blend using texture with no vertex alpha. For using texture blending on non-displacements" ) SHADER_PARAM( SSBUMP, SHADER_PARAM_TYPE_INTEGER, "0", "whether or not to use alternate bumpmap format with height" ) SHADER_PARAM( SEAMLESS_SCALE, SHADER_PARAM_TYPE_FLOAT, "0", "Scale factor for 'seamless' texture mapping. 0 means to use ordinary mapping" ) - SHADER_PARAM( ALPHATESTREFERENCE, SHADER_PARAM_TYPE_FLOAT, "0.0", "" ) - - SHADER_PARAM( SOFTEDGES, SHADER_PARAM_TYPE_BOOL, "0", "Enable soft edges to distance coded textures.") - SHADER_PARAM( EDGESOFTNESSSTART, SHADER_PARAM_TYPE_FLOAT, "0.6", "Start value for soft edges for distancealpha."); - SHADER_PARAM( EDGESOFTNESSEND, SHADER_PARAM_TYPE_FLOAT, "0.5", "End value for soft edges for distancealpha."); SHADER_PARAM( OUTLINE, SHADER_PARAM_TYPE_BOOL, "0", "Enable outline for distance coded textures.") SHADER_PARAM( OUTLINECOLOR, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "color of outline for distance coded images." ) @@ -73,6 +72,15 @@ BEGIN_VS_SHADER( LightmappedGeneric, SHADER_PARAM( OUTLINESTART1, SHADER_PARAM_TYPE_FLOAT, "0.0", "inner start value for outline") SHADER_PARAM( OUTLINEEND0, SHADER_PARAM_TYPE_FLOAT, "0.0", "inner end value for outline") SHADER_PARAM( OUTLINEEND1, SHADER_PARAM_TYPE_FLOAT, "0.0", "outer end value for outline") + + SHADER_PARAM( SOFTEDGES, SHADER_PARAM_TYPE_BOOL, "0", "Enable soft edges to distance coded textures.") + SHADER_PARAM( EDGESOFTNESSSTART, SHADER_PARAM_TYPE_FLOAT, "0.6", "Start value for soft edges for distancealpha.") + SHADER_PARAM( EDGESOFTNESSEND, SHADER_PARAM_TYPE_FLOAT, "0.5", "End value for soft edges for distancealpha.") + + SHADER_PARAM( PHONG, SHADER_PARAM_TYPE_BOOL, "0", "enables phong lighting" ) + SHADER_PARAM( PHONGBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "Phong overbrightening factor (specular mask channel should be authored to account for this)" ) + SHADER_PARAM( PHONGFRESNELRANGES, SHADER_PARAM_TYPE_VEC3, "[0 0.5 1]", "Parameters for remapping fresnel output" ) + SHADER_PARAM( PHONGEXPONENT, SHADER_PARAM_TYPE_FLOAT, "5.0", "Phong exponent for local specular lights" ) END_SHADER_PARAMS void SetupVars( LightmappedGeneric_DX9_Vars_t& info ) @@ -83,8 +91,6 @@ END_SHADER_PARAMS info.m_nAlbedo = ALBEDO; info.m_nSelfIllumTint = SELFILLUMTINT; - info.m_nAlpha2 = ALPHA2; - info.m_nDetail = DETAIL; info.m_nDetailFrame = DETAILFRAME; info.m_nDetailScale = DETAILSCALE; @@ -111,6 +117,9 @@ END_SHADER_PARAMS info.m_nBumpMask = BUMPMASK; info.m_nBaseTexture2 = BASETEXTURE2; info.m_nBaseTexture2Frame = FRAME2; +#ifdef MAPBASE + info.m_nBaseTexture2Transform = BASETEXTURETRANSFORM2; +#endif info.m_nBaseTextureNoEnvmap = BASETEXTURENOENVMAP; info.m_nBaseTexture2NoEnvmap = BASETEXTURE2NOENVMAP; info.m_nDetailAlphaMaskBaseTexture = DETAIL_ALPHA_MASK_BASE_TEXTURE; @@ -134,6 +143,11 @@ END_SHADER_PARAMS info.m_nOutlineStart1 = OUTLINESTART1; info.m_nOutlineEnd0 = OUTLINEEND0; info.m_nOutlineEnd1 = OUTLINEEND1; + + info.m_nPhong = PHONG; + info.m_nPhongBoost = PHONGBOOST; + info.m_nPhongFresnelRanges = PHONGFRESNELRANGES; + info.m_nPhongExponent = PHONGEXPONENT; } SHADER_FALLBACK @@ -147,18 +161,22 @@ END_SHADER_PARAMS // Set up anything that is necessary to make decisions in SHADER_FALLBACK. SHADER_INIT_PARAMS() { - SetupVars( s_info ); - InitParamsLightmappedGeneric_DX9( this, params, pMaterialName, s_info ); + LightmappedGeneric_DX9_Vars_t info; + SetupVars( info ); + InitParamsLightmappedGeneric_DX9( this, params, pMaterialName, info ); } SHADER_INIT { - SetupVars( s_info ); - InitLightmappedGeneric_DX9( this, params, s_info ); + LightmappedGeneric_DX9_Vars_t info; + SetupVars( info ); + InitLightmappedGeneric_DX9( this, params, info ); } SHADER_DRAW { - DrawLightmappedGeneric_DX9( this, params, pShaderAPI, pShaderShadow, s_info, pContextDataPtr ); + LightmappedGeneric_DX9_Vars_t info; + SetupVars( info ); + DrawLightmappedGeneric_DX9( this, params, pShaderAPI, pShaderShadow, info, pContextDataPtr ); } -END_SHADER +END_SHADER \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/lightmappedgeneric_dx9_helper.cpp b/sp/src/materialsystem/stdshaders/lightmappedgeneric_dx9_helper.cpp index 9da6716d..6471f7d8 100644 --- a/sp/src/materialsystem/stdshaders/lightmappedgeneric_dx9_helper.cpp +++ b/sp/src/materialsystem/stdshaders/lightmappedgeneric_dx9_helper.cpp @@ -9,10 +9,19 @@ #include "lightmappedgeneric_dx9_helper.h" #include "BaseVSShader.h" #include "commandbuilder.h" +#include "cpp_shader_constant_register_map.h" #include "convar.h" -#include "lightmappedgeneric_ps20.inc" -#include "lightmappedgeneric_vs20.inc" -#include "lightmappedgeneric_ps20b.inc" +#include "SDK_lightmappedgeneric_ps20b.inc" +#include "SDK_lightmappedgeneric_vs20.inc" +#include "SDK_lightmappedgeneric_ps30.inc" +#include "SDK_lightmappedgeneric_vs30.inc" + +#include "sdk_lightmappedgeneric_flashlight_vs20.inc" +#include "sdk_lightmappedgeneric_flashlight_vs30.inc" +#include "sdk_lightmappedgeneric_flashlight_ps20.inc" +#include "sdk_lightmappedgeneric_flashlight_ps20b.inc" +#include "sdk_lightmappedgeneric_flashlight_ps30.inc" + #include "tier0/memdbgon.h" @@ -20,7 +29,11 @@ ConVar mat_disable_lightwarp( "mat_disable_lightwarp", "0" ); ConVar mat_disable_fancy_blending( "mat_disable_fancy_blending", "0" ); ConVar mat_fullbright( "mat_fullbright","0", FCVAR_CHEAT ); ConVar my_mat_fullbright( "mat_fullbright","0", FCVAR_CHEAT ); -extern ConVar r_flashlight_version2; + +ConVar mat_enable_lightmapped_phong( "mat_enable_lightmapped_phong", "1", FCVAR_ARCHIVE, "If 1, allow phong on world brushes. If 0, disallow. mat_force_lightmapped_phong does not work if this value is 0." ); +ConVar mat_force_lightmapped_phong( "mat_force_lightmapped_phong", "0", FCVAR_CHEAT, "Forces the use of phong on all LightmappedAdv textures, regardless of setting in VMT." ); +ConVar mat_force_lightmapped_phong_boost( "mat_force_lightmapped_phong_boost", "5.0", FCVAR_CHEAT ); +ConVar mat_force_lightmapped_phong_exp( "mat_force_lightmapped_phong_exp", "50.0", FCVAR_CHEAT ); class CLightmappedGeneric_DX9_Context : public CBasePerMaterialContextData { @@ -185,6 +198,44 @@ void InitParamsLightmappedGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** pa InitFloatParam( info.m_nEdgeSoftnessStart, params, 0.5 ); InitFloatParam( info.m_nEdgeSoftnessEnd, params, 0.5 ); InitFloatParam( info.m_nOutlineAlpha, params, 1.0 ); + + if ( !params[info.m_nPhong]->IsDefined() || !mat_enable_lightmapped_phong.GetBool() ) + { + params[info.m_nPhong]->SetIntValue( 0 ); + } + if ( !params[info.m_nPhongBoost]->IsDefined() ) + { + params[info.m_nPhongBoost]->SetFloatValue( 1.0 ); + } + if ( !params[info.m_nPhongFresnelRanges]->IsDefined() ) + { + params[info.m_nPhongFresnelRanges]->SetVecValue( 0.0, 0.5, 1.0 ); + } + if ( !params[info.m_nPhongExponent]->IsDefined() ) + { + params[info.m_nPhongExponent]->SetFloatValue( 5.0 ); + } + + if ( params[info.m_nPhong]->GetIntValue() && mat_enable_lightmapped_phong.GetBool() ) + { + if ( pShader->CanUseEditorMaterials() ) + { + params[info.m_nPhong]->SetIntValue( 0 ); + } + else if ( !params[info.m_nEnvmapMaskTransform]->MatrixIsIdentity() ) + { + Warning( "Warning! material %s: $envmapmasktransform and $phong are mutial exclusive. Disabling phong..\n", pMaterialName ); + params[info.m_nPhong]->SetIntValue( 0 ); + } + } + else if ( mat_force_lightmapped_phong.GetBool() && mat_enable_lightmapped_phong.GetBool() && + params[info.m_nEnvmapMaskTransform]->MatrixIsIdentity() ) + { + params[info.m_nPhong]->SetIntValue( 1 ); + params[info.m_nPhongBoost]->SetFloatValue( mat_force_lightmapped_phong_boost.GetFloat() ); + params[info.m_nPhongFresnelRanges]->SetVecValue( 0.0, 0.5, 1.0 ); + params[info.m_nPhongExponent]->SetFloatValue( mat_force_lightmapped_phong_exp.GetFloat() ); + } } void InitLightmappedGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, LightmappedGeneric_DX9_Vars_t &info ) @@ -277,6 +328,412 @@ void InitLightmappedGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, SET_FLAGS2( MATERIAL_VAR2_NEEDS_TANGENT_SPACES ); } +void DrawLightmappedGenericFlashlight_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShaderDynamicAPI *pShaderAPI, + IShaderShadow* pShaderShadow, LightmappedGenericFlashlight_DX9_Vars_t &vars ) +{ + Assert( vars.m_bLightmappedGeneric ); + + bool bBump2 = vars.m_bWorldVertexTransition && vars.m_bBump && vars.m_nBumpmap2Var != -1 && params[vars.m_nBumpmap2Var]->IsTexture(); + bool bSeamless = vars.m_fSeamlessScale != 0.0; + bool bDetail = (vars.m_nDetailVar != -1) && params[vars.m_nDetailVar]->IsDefined() && (vars.m_nDetailScale != -1); + bool bPhong = (vars.m_nPhong != -1) && (params[vars.m_nPhong]->GetIntValue() != 0); +#ifdef MAPBASE + bool hasBaseTextureTransform2 = (vars.m_nBaseTexture2TransformVar != -1) && params[vars.m_nBaseTexture2TransformVar]->IsDefined() && params[vars.m_nBaseTexture2Var]->IsTexture(); + bool bHasBlendModulateTexture = + (vars.m_nBlendModulateTexture != -1) && + (params[vars.m_nBlendModulateTexture]->IsTexture()); +#endif + + int nDetailBlendMode = 0; + if ( bDetail ) + { + nDetailBlendMode = GetIntParam( vars.m_nDetailTextureCombineMode, params ); + nDetailBlendMode = nDetailBlendMode > 1 ? 1 : nDetailBlendMode; + } + + PhongMaskVariant_t nPhongMaskVariant = PHONGMASK_NONE; + if ( bPhong ) + { + if ( IS_FLAG_SET(MATERIAL_VAR_BASEALPHAENVMAPMASK) ) + { + nPhongMaskVariant = PHONGMASK_BASEALPHA; + } + else if ( IS_FLAG_SET(MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK) ) + { + nPhongMaskVariant = PHONGMASK_NORMALALPHA; + } + else if ( params[vars.m_nPhongMask]->IsDefined() ) + { + nPhongMaskVariant = PHONGMASK_STANDALONE; + } + } + + if( pShaderShadow ) + { + pShader->SetInitialShadowState(); + pShaderShadow->EnableDepthWrites( false ); + pShaderShadow->EnableAlphaWrites( false ); + + // Alpha blend + pShader->SetAdditiveBlendingShadowState( BASETEXTURE, true ); + + // Alpha test + pShaderShadow->EnableAlphaTest( IS_FLAG_SET( MATERIAL_VAR_ALPHATEST ) ); + if ( vars.m_nAlphaTestReference != -1 && params[vars.m_nAlphaTestReference]->GetFloatValue() > 0.0f ) + { + pShaderShadow->AlphaFunc( SHADER_ALPHAFUNC_GEQUAL, params[vars.m_nAlphaTestReference]->GetFloatValue() ); + } + + // Spot sampler + pShaderShadow->EnableTexture( SHADER_SAMPLER0, true ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, true ); + + // Base sampler + pShaderShadow->EnableTexture( SHADER_SAMPLER1, true ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, true ); + + // Normalizing cubemap sampler + pShaderShadow->EnableTexture( SHADER_SAMPLER2, true ); + + // Normalizing cubemap sampler2 or normal map sampler + pShaderShadow->EnableTexture( SHADER_SAMPLER3, true ); + + // RandomRotation sampler + pShaderShadow->EnableTexture( SHADER_SAMPLER5, true ); + + // Flashlight depth sampler + pShaderShadow->EnableTexture( SHADER_SAMPLER7, true ); + pShaderShadow->SetShadowDepthFiltering( SHADER_SAMPLER7 ); + + if( vars.m_bWorldVertexTransition ) + { + // $basetexture2 + pShaderShadow->EnableTexture( SHADER_SAMPLER4, true ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER4, true ); + } + if( bBump2 ) + { + // Normalmap2 sampler + pShaderShadow->EnableTexture( SHADER_SAMPLER6, true ); + } + if( bDetail ) + { + pShaderShadow->EnableTexture( SHADER_SAMPLER8, true ); // detail sampler + if ( nDetailBlendMode != 0 ) //Not Mod2X + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER8, true ); + } + if( nPhongMaskVariant == PHONGMASK_STANDALONE ) + { + // phong mask sampler + pShaderShadow->EnableTexture( SHADER_SAMPLER9, true ); + } + +#ifdef MAPBASE + if ( bHasBlendModulateTexture ) + { + pShaderShadow->EnableTexture( SHADER_SAMPLER10, true ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER10, false ); + } +#endif + + pShaderShadow->EnableSRGBWrite( true ); + + if ( g_pHardwareConfig->SupportsShaderModel_3_0() ) + { + DECLARE_STATIC_VERTEX_SHADER( sdk_lightmappedgeneric_flashlight_vs30 ); + SET_STATIC_VERTEX_SHADER_COMBO( WORLDVERTEXTRANSITION, vars.m_bWorldVertexTransition ); + SET_STATIC_VERTEX_SHADER_COMBO( NORMALMAP, vars.m_bBump ); + SET_STATIC_VERTEX_SHADER_COMBO( SEAMLESS, bSeamless ); + SET_STATIC_VERTEX_SHADER_COMBO( DETAIL, bDetail ); + SET_STATIC_VERTEX_SHADER_COMBO( PHONG, bPhong ); +#ifdef MAPBASE + SET_STATIC_VERTEX_SHADER_COMBO( BASETEXTURETRANSFORM2, hasBaseTextureTransform2 ); +#endif + SET_STATIC_VERTEX_SHADER( sdk_lightmappedgeneric_flashlight_vs30 ); + } + else + { + DECLARE_STATIC_VERTEX_SHADER( sdk_lightmappedgeneric_flashlight_vs20 ); + SET_STATIC_VERTEX_SHADER_COMBO( WORLDVERTEXTRANSITION, vars.m_bWorldVertexTransition ); + SET_STATIC_VERTEX_SHADER_COMBO( NORMALMAP, vars.m_bBump ); + SET_STATIC_VERTEX_SHADER_COMBO( SEAMLESS, bSeamless ); + SET_STATIC_VERTEX_SHADER_COMBO( DETAIL, bDetail ); + SET_STATIC_VERTEX_SHADER_COMBO( PHONG, bPhong ); +#ifdef MAPBASE + SET_STATIC_VERTEX_SHADER_COMBO( BASETEXTURETRANSFORM2, hasBaseTextureTransform2 ); +#endif + SET_STATIC_VERTEX_SHADER( sdk_lightmappedgeneric_flashlight_vs20 ); + } + + unsigned int flags = VERTEX_POSITION | VERTEX_NORMAL; + if( vars.m_bBump ) + { + flags |= VERTEX_TANGENT_S | VERTEX_TANGENT_T; + } + int numTexCoords = 1; + if( vars.m_bWorldVertexTransition ) + { + flags |= VERTEX_COLOR; + numTexCoords = 2; // need lightmap texcoords to get alpha. + } + pShaderShadow->VertexShaderVertexFormat( flags, numTexCoords, 0, 0 ); + + int nBumpMapVariant = 0; + if ( vars.m_bBump ) + { + nBumpMapVariant = ( vars.m_bSSBump ) ? 2 : 1; + } + + if ( g_pHardwareConfig->SupportsShaderModel_3_0() ) + { + DECLARE_STATIC_PIXEL_SHADER( sdk_lightmappedgeneric_flashlight_ps30 ); + SET_STATIC_PIXEL_SHADER_COMBO( NORMALMAP, nBumpMapVariant ); + SET_STATIC_PIXEL_SHADER_COMBO( NORMALMAP2, bBump2 ); + SET_STATIC_PIXEL_SHADER_COMBO( WORLDVERTEXTRANSITION, vars.m_bWorldVertexTransition ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( FANCY_BLENDING, bHasBlendModulateTexture ); +#endif + SET_STATIC_PIXEL_SHADER_COMBO( SEAMLESS, bSeamless ); + SET_STATIC_PIXEL_SHADER_COMBO( DETAILTEXTURE, bDetail ); + SET_STATIC_PIXEL_SHADER_COMBO( DETAIL_BLEND_MODE, nDetailBlendMode ); + SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, g_pHardwareConfig->GetShadowFilterMode() ); + SET_STATIC_PIXEL_SHADER_COMBO( PHONG, bPhong ); + SET_STATIC_PIXEL_SHADER_COMBO( PHONGMASK, nPhongMaskVariant ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURETRANSFORM2, hasBaseTextureTransform2 ); +#endif + SET_STATIC_PIXEL_SHADER( sdk_lightmappedgeneric_flashlight_ps30 ); + } + else if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + DECLARE_STATIC_PIXEL_SHADER( sdk_lightmappedgeneric_flashlight_ps20b ); + SET_STATIC_PIXEL_SHADER_COMBO( NORMALMAP, nBumpMapVariant ); + SET_STATIC_PIXEL_SHADER_COMBO( NORMALMAP2, bBump2 ); + SET_STATIC_PIXEL_SHADER_COMBO( WORLDVERTEXTRANSITION, vars.m_bWorldVertexTransition ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( FANCY_BLENDING, bHasBlendModulateTexture ); +#endif + SET_STATIC_PIXEL_SHADER_COMBO( SEAMLESS, bSeamless ); + SET_STATIC_PIXEL_SHADER_COMBO( DETAILTEXTURE, bDetail ); + SET_STATIC_PIXEL_SHADER_COMBO( DETAIL_BLEND_MODE, nDetailBlendMode ); + SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, g_pHardwareConfig->GetShadowFilterMode() ); + SET_STATIC_PIXEL_SHADER_COMBO( PHONG, bPhong ); + SET_STATIC_PIXEL_SHADER_COMBO( PHONGMASK, nPhongMaskVariant ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURETRANSFORM2, hasBaseTextureTransform2 ); +#endif + SET_STATIC_PIXEL_SHADER( sdk_lightmappedgeneric_flashlight_ps20b ); + } + else + { + DECLARE_STATIC_PIXEL_SHADER( sdk_lightmappedgeneric_flashlight_ps20 ); + SET_STATIC_PIXEL_SHADER_COMBO( NORMALMAP, nBumpMapVariant ); + SET_STATIC_PIXEL_SHADER_COMBO( NORMALMAP2, bBump2 ); + SET_STATIC_PIXEL_SHADER_COMBO( WORLDVERTEXTRANSITION, vars.m_bWorldVertexTransition ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( FANCY_BLENDING, bHasBlendModulateTexture ); +#endif + SET_STATIC_PIXEL_SHADER_COMBO( SEAMLESS, bSeamless ); + SET_STATIC_PIXEL_SHADER_COMBO( DETAILTEXTURE, bDetail ); + SET_STATIC_PIXEL_SHADER_COMBO( DETAIL_BLEND_MODE, nDetailBlendMode ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURETRANSFORM2, hasBaseTextureTransform2 ); +#endif + SET_STATIC_PIXEL_SHADER( sdk_lightmappedgeneric_flashlight_ps20 ); + } + pShader->FogToBlack(); + } + else + { + VMatrix worldToTexture; + ITexture *pFlashlightDepthTexture; + FlashlightState_t flashlightState = pShaderAPI->GetFlashlightStateEx( worldToTexture, &pFlashlightDepthTexture ); + + if ( pFlashlightDepthTexture == NULL ) + { + const int iFlashlightShadowIndex = ( flashlightState.m_nShadowQuality >> 16 ) - 1; + + if ( iFlashlightShadowIndex >= 0 + && iFlashlightShadowIndex <= ( INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_LAST - INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_FIRST ) ) + { + pFlashlightDepthTexture = (ITexture*)pShaderAPI->GetIntRenderingParameter( INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_FIRST + iFlashlightShadowIndex ); + } + } + + SetFlashLightColorFromState( flashlightState, pShaderAPI ); + + pShader->BindTexture( SHADER_SAMPLER0, flashlightState.m_pSpotlightTexture, flashlightState.m_nSpotlightTextureFrame ); + + if( pFlashlightDepthTexture && g_pConfig->ShadowDepthTexture() && flashlightState.m_bEnableShadows ) + { + pShader->BindTexture( SHADER_SAMPLER7, pFlashlightDepthTexture, 0 ); + pShaderAPI->BindStandardTexture( SHADER_SAMPLER5, TEXTURE_SHADOW_NOISE_2D ); + + // Tweaks associated with a given flashlight + float tweaks[4]; + tweaks[0] = ShadowFilterFromState( flashlightState ); + tweaks[1] = ShadowAttenFromState( flashlightState ); + pShader->HashShadow2DJitter( flashlightState.m_flShadowJitterSeed, &tweaks[2], &tweaks[3] ); + pShaderAPI->SetPixelShaderConstant( PSREG_ENVMAP_TINT__SHADOW_TWEAKS, tweaks, 1 ); + + // Dimensions of screen, used for screen-space noise map sampling + float vScreenScale[4] = {1280.0f / 32.0f, 720.0f / 32.0f, 0, 0}; + int nWidth, nHeight; + pShaderAPI->GetBackBufferDimensions( nWidth, nHeight ); + vScreenScale[0] = (float) nWidth / 32.0f; + vScreenScale[1] = (float) nHeight / 32.0f; + pShaderAPI->SetPixelShaderConstant( PSREG_FLASHLIGHT_SCREEN_SCALE, vScreenScale, 1 ); + } + + if( params[BASETEXTURE]->IsTexture() && mat_fullbright.GetInt() != 2 ) + { + pShader->BindTexture( SHADER_SAMPLER1, BASETEXTURE, FRAME ); + } + else + { + pShaderAPI->BindStandardTexture( SHADER_SAMPLER1, TEXTURE_GREY ); + } + if( vars.m_bWorldVertexTransition ) + { + Assert( vars.m_nBaseTexture2Var >= 0 && vars.m_nBaseTexture2FrameVar >= 0 ); + pShader->BindTexture( SHADER_SAMPLER4, vars.m_nBaseTexture2Var, vars.m_nBaseTexture2FrameVar ); + } + pShaderAPI->BindStandardTexture( SHADER_SAMPLER2, TEXTURE_NORMALIZATION_CUBEMAP ); + if( vars.m_bBump ) + { + pShader->BindTexture( SHADER_SAMPLER3, vars.m_nBumpmapVar, vars.m_nBumpmapFrame ); + } + else + { + pShaderAPI->BindStandardTexture( SHADER_SAMPLER3, TEXTURE_NORMALIZATION_CUBEMAP ); + } + + if( bDetail ) + { + pShader->BindTexture( SHADER_SAMPLER8, vars.m_nDetailVar ); + } + + if( bBump2 ) + { + pShader->BindTexture( SHADER_SAMPLER6, vars.m_nBumpmap2Var, vars.m_nBumpmap2Frame ); + } + + if( nPhongMaskVariant == PHONGMASK_STANDALONE ) + { + pShader->BindTexture( SHADER_SAMPLER9, vars.m_nPhongMask, vars.m_nPhongMaskFrame ); + } + +#ifdef MAPBASE + if ( bHasBlendModulateTexture ) + { + pShader->BindTexture( SHADER_SAMPLER10, vars.m_nBlendModulateTexture ); + } +#endif + + if ( g_pHardwareConfig->SupportsShaderModel_3_0() ) + { + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_lightmappedgeneric_flashlight_vs30 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); + SET_DYNAMIC_VERTEX_SHADER( sdk_lightmappedgeneric_flashlight_vs30 ); + } + else + { + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_lightmappedgeneric_flashlight_vs20 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); + SET_DYNAMIC_VERTEX_SHADER( sdk_lightmappedgeneric_flashlight_vs20 ); + } + + if ( bSeamless ) + { + float const0[4]={ vars.m_fSeamlessScale,0,0,0}; + pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_6, const0 ); + } + + if ( bDetail ) + { + float vDetailConstants[4] = {1,1,1,1}; + + if ( vars.m_nDetailTint != -1 ) + { + params[vars.m_nDetailTint]->GetVecValue( vDetailConstants, 3 ); + } + + if ( vars.m_nDetailTextureBlendFactor != -1 ) + { + vDetailConstants[3] = params[vars.m_nDetailTextureBlendFactor]->GetFloatValue(); + } + + pShaderAPI->SetPixelShaderConstant( 0, vDetailConstants, 1 ); + } + + if ( bPhong ) + { + float vEyePos[4]; + pShaderAPI->GetWorldSpaceCameraPosition( vEyePos ); + vEyePos[3] = 0.0f; + pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_10, vEyePos ); + } + +#ifdef MAPBASE + else if ( hasBaseTextureTransform2 ) + { + pShader->SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_10, vars.m_nBaseTexture2TransformVar ); + } +#endif + + pShaderAPI->SetPixelShaderFogParams( PSREG_FOG_PARAMS ); + + float vEyePos_SpecExponent[4]; + pShaderAPI->GetWorldSpaceCameraPosition( vEyePos_SpecExponent ); + vEyePos_SpecExponent[3] = params[vars.m_nPhongExponent]->GetFloatValue(); + pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, vEyePos_SpecExponent, 1 ); + + if ( g_pHardwareConfig->SupportsShaderModel_3_0() ) + { + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_lightmappedgeneric_flashlight_ps30 ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, flashlightState.m_bEnableShadows ); + SET_DYNAMIC_PIXEL_SHADER( sdk_lightmappedgeneric_flashlight_ps30 ); + } + else if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_lightmappedgeneric_flashlight_ps20b ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, flashlightState.m_bEnableShadows ); + SET_DYNAMIC_PIXEL_SHADER( sdk_lightmappedgeneric_flashlight_ps20b ); + } + else + { + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_lightmappedgeneric_flashlight_ps20 ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); + SET_DYNAMIC_PIXEL_SHADER( sdk_lightmappedgeneric_flashlight_ps20 ); + } + + float atten[4]; // Set the flashlight attenuation factors + atten[0] = flashlightState.m_fConstantAtten; + atten[1] = flashlightState.m_fLinearAtten; + atten[2] = flashlightState.m_fQuadraticAtten; + atten[3] = flashlightState.m_FarZ; + /*atten[3] = flashlightState.m_FarZAtten;*/ + pShaderAPI->SetPixelShaderConstant( PSREG_FLASHLIGHT_ATTENUATION, atten, 1 ); + + float lightPos[4]; + lightPos[0] = flashlightState.m_vecLightOrigin[0]; + lightPos[1] = flashlightState.m_vecLightOrigin[1]; + lightPos[2] = flashlightState.m_vecLightOrigin[2]; + lightPos[3] = 1.0f; + pShaderAPI->SetPixelShaderConstant( 1, lightPos, 1 ); + + float specParams[4]; + params[vars.m_nPhongFresnelRanges]->GetVecValue( specParams, 3 ); + specParams[3] = params[vars.m_nPhongBoost]->GetFloatValue(); + pShaderAPI->SetPixelShaderConstant( PSREG_FRESNEL_SPEC_PARAMS, specParams, 1 ); + + pShader->SetFlashlightVertexShaderConstants( vars.m_bBump, vars.m_nBumpTransform, bDetail, vars.m_nDetailScale, bSeamless ? false : true ); + } + pShader->Draw(); +} + void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** params, bool hasFlashlight, IShaderDynamicAPI *pShaderAPI, IShaderShadow* pShaderShadow, LightmappedGeneric_DX9_Vars_t &info, @@ -303,12 +760,13 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** bool hasBump = ( params[info.m_nBumpmap]->IsTexture() ) && ( !g_pHardwareConfig->PreferReducedFillrate() ); bool hasSSBump = hasBump && (info.m_nSelfShadowedBumpFlag != -1) && ( params[info.m_nSelfShadowedBumpFlag]->GetIntValue() ); bool hasBaseTexture2 = hasBaseTexture && params[info.m_nBaseTexture2]->IsTexture(); +#ifdef MAPBASE + bool hasBaseTextureTransform2 = (info.m_nBaseTexture2Transform != -1) && params[info.m_nBaseTexture2Transform]->IsDefined() && hasBaseTexture2; +#endif bool hasLightWarpTexture = params[info.m_nLightWarpTexture]->IsTexture(); bool hasBump2 = hasBump && params[info.m_nBumpmap2]->IsTexture(); bool hasDetailTexture = params[info.m_nDetail]->IsTexture(); bool hasSelfIllum = IS_FLAG_SET( MATERIAL_VAR_SELFILLUM ); - bool hasBumpMask = hasBump && hasBump2 && params[info.m_nBumpMask]->IsTexture() && !hasSelfIllum && - !hasDetailTexture && !hasBaseTexture2 && (params[info.m_nBaseTextureNoEnvmap]->GetIntValue() == 0); bool bHasBlendModulateTexture = (info.m_nBlendModulateTexture != -1) && (params[info.m_nBlendModulateTexture]->IsTexture() ); @@ -317,7 +775,7 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** if ( hasFlashlight && !IsX360() ) { // !!speed!! do this in the caller so we don't build struct every time - CBaseVSShader::DrawFlashlight_dx90_Vars_t vars; + LightmappedGenericFlashlight_DX9_Vars_t vars; vars.m_bBump = hasBump; vars.m_nBumpmapVar = info.m_nBumpmap; vars.m_nBumpmapFrame = info.m_nBumpFrame; @@ -328,6 +786,9 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** vars.m_bWorldVertexTransition = hasBaseTexture2; vars.m_nBaseTexture2Var = info.m_nBaseTexture2; vars.m_nBaseTexture2FrameVar = info.m_nBaseTexture2Frame; +#ifdef MAPBASE + vars.m_nBaseTexture2TransformVar = info.m_nBaseTexture2Transform; +#endif vars.m_nBumpmap2Var = info.m_nBumpmap2; vars.m_nBumpmap2Frame = info.m_nBumpFrame2; vars.m_nBump2Transform = info.m_nBumpTransform2; @@ -343,7 +804,19 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** vars.m_fSeamlessScale = params[info.m_nSeamlessMappingScale]->GetFloatValue(); else vars.m_fSeamlessScale = 0.0; - pShader->DrawFlashlight_dx90( params, pShaderAPI, pShaderShadow, vars ); + + vars.m_nPhong = info.m_nPhong; + vars.m_nPhongBoost = info.m_nPhongBoost; + vars.m_nPhongFresnelRanges = info.m_nPhongFresnelRanges; + vars.m_nPhongExponent = info.m_nPhongExponent; + vars.m_nPhongMask = info.m_nEnvmapMask; + vars.m_nPhongMaskFrame = info.m_nEnvmapMaskFrame; + +#ifdef MAPBASE + vars.m_nBlendModulateTexture = info.m_nBlendModulateTexture; +#endif + + DrawLightmappedGenericFlashlight_DX9_Internal( pShader, params, pShaderAPI, pShaderShadow, vars ); return; } @@ -369,20 +842,22 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** } } } + const bool hasBumpMask = false; //hasBump && hasBump2 && params[info.m_nBumpMask]->IsTexture() && !hasSelfIllum && + //!hasDetailTexture && !hasBaseTexture2 && (params[info.m_nBaseTextureNoEnvmap]->GetIntValue() == 0); int nNormalMaskDecodeMode = 0; - if ( hasBumpMask && g_pHardwareConfig->SupportsNormalMapCompression() && g_pHardwareConfig->SupportsPixelShaders_2_b() ) + /*if ( hasBumpMask && g_pHardwareConfig->SupportsNormalMapCompression() && g_pHardwareConfig->SupportsPixelShaders_2_b() ) { ITexture *pBumpMaskTex = params[info.m_nBumpMask]->GetTextureValue(); if ( pBumpMaskTex ) { nNormalMaskDecodeMode = pBumpMaskTex->GetNormalDecodeMode(); } - } + }*/ - bool bHasOutline = IsBoolSet( info.m_nOutline, params ); + const bool bHasOutline = false; //IsBoolSet( info.m_nOutline, params ); pContextData->m_bPixelShaderForceFastPathBecauseOutline = bHasOutline; - bool bHasSoftEdges = IsBoolSet( info.m_nSoftEdges, params ); + const bool bHasSoftEdges = false; //IsBoolSet( info.m_nSoftEdges, params ); bool hasEnvmapMask = params[info.m_nEnvmapMask]->IsTexture(); @@ -424,7 +899,7 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, params[info.m_nSeamlessMappingScale]->GetFloatValue(),0,0,0 ); } - staticCmdsBuf.StoreEyePosInPixelShaderConstant( 10 ); + //staticCmdsBuf.StoreEyePosInPixelShaderConstant( 10 ); staticCmdsBuf.SetPixelShaderFogParams( 11 ); staticCmdsBuf.End(); // now, copy buf @@ -546,6 +1021,13 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** pShaderShadow->SetShadowDepthFiltering( SHADER_SAMPLER14 ); pShaderShadow->EnableTexture( SHADER_SAMPLER15, true ); } + else if ( !hasFlashlight ) + { + pShaderShadow->EnableTexture( SHADER_SAMPLER14, true ); + pShaderShadow->SetShadowDepthFiltering( SHADER_SAMPLER14 ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER14, false ); + pShaderShadow->EnableTexture( SHADER_SAMPLER15, true ); + } if( hasVertexColor || hasBaseTexture2 || hasBump2 ) { @@ -570,31 +1052,59 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** bool bMaskedBlending=( (info.m_nMaskedBlending != -1) && (params[info.m_nMaskedBlending]->GetIntValue() != 0) ); - DECLARE_STATIC_VERTEX_SHADER( lightmappedgeneric_vs20 ); - SET_STATIC_VERTEX_SHADER_COMBO( ENVMAP_MASK, hasEnvmapMask ); - SET_STATIC_VERTEX_SHADER_COMBO( TANGENTSPACE, params[info.m_nEnvmap]->IsTexture() ); - SET_STATIC_VERTEX_SHADER_COMBO( BUMPMAP, hasBump ); - SET_STATIC_VERTEX_SHADER_COMBO( DIFFUSEBUMPMAP, hasDiffuseBumpmap ); - SET_STATIC_VERTEX_SHADER_COMBO( VERTEXCOLOR, IS_FLAG_SET( MATERIAL_VAR_VERTEXCOLOR ) ); - SET_STATIC_VERTEX_SHADER_COMBO( VERTEXALPHATEXBLENDFACTOR, hasBaseTexture2 || hasBump2 ); - SET_STATIC_VERTEX_SHADER_COMBO( BUMPMASK, hasBumpMask ); - bool bReliefMapping = false; //( bumpmap_variant == 2 ) && ( ! bSeamlessMapping ); - SET_STATIC_VERTEX_SHADER_COMBO( RELIEF_MAPPING, false );//bReliefMapping ); - SET_STATIC_VERTEX_SHADER_COMBO( SEAMLESS, bSeamlessMapping ); -#ifdef _X360 - SET_STATIC_VERTEX_SHADER_COMBO( FLASHLIGHT, hasFlashlight); -#endif - SET_STATIC_VERTEX_SHADER( lightmappedgeneric_vs20 ); - if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + if ( g_pHardwareConfig->SupportsShaderModel_3_0() ) { - DECLARE_STATIC_PIXEL_SHADER( lightmappedgeneric_ps20b ); + DECLARE_STATIC_VERTEX_SHADER( sdk_lightmappedgeneric_vs30 ); + SET_STATIC_VERTEX_SHADER_COMBO( ENVMAP_MASK, hasEnvmapMask ); + SET_STATIC_VERTEX_SHADER_COMBO( TANGENTSPACE, 1 ); // // GSTRINGMIGRATION params[info.m_nEnvmap]->IsTexture() ); + SET_STATIC_VERTEX_SHADER_COMBO( BUMPMAP, hasBump ); + SET_STATIC_VERTEX_SHADER_COMBO( DIFFUSEBUMPMAP, hasDiffuseBumpmap ); + SET_STATIC_VERTEX_SHADER_COMBO( VERTEXCOLOR, IS_FLAG_SET( MATERIAL_VAR_VERTEXCOLOR ) ); + SET_STATIC_VERTEX_SHADER_COMBO( VERTEXALPHATEXBLENDFACTOR, hasBaseTexture2 || hasBump2 ); + SET_STATIC_VERTEX_SHADER_COMBO( BUMPMASK, hasBumpMask ); + SET_STATIC_VERTEX_SHADER_COMBO( RELIEF_MAPPING, false );//bReliefMapping ); + SET_STATIC_VERTEX_SHADER_COMBO( SEAMLESS, bSeamlessMapping ); +#ifdef _X360 + SET_STATIC_VERTEX_SHADER_COMBO( FLASHLIGHT, hasFlashlight); +#endif +#ifdef MAPBASE + SET_STATIC_VERTEX_SHADER_COMBO( BASETEXTURETRANSFORM2, hasBaseTextureTransform2 ); +#endif + SET_STATIC_VERTEX_SHADER( sdk_lightmappedgeneric_vs30 ); + } + else + { + DECLARE_STATIC_VERTEX_SHADER( sdk_lightmappedgeneric_vs20 ); + SET_STATIC_VERTEX_SHADER_COMBO( ENVMAP_MASK, hasEnvmapMask ); + SET_STATIC_VERTEX_SHADER_COMBO( TANGENTSPACE, 1 ); // // GSTRINGMIGRATION params[info.m_nEnvmap]->IsTexture() ); + SET_STATIC_VERTEX_SHADER_COMBO( BUMPMAP, hasBump ); + SET_STATIC_VERTEX_SHADER_COMBO( DIFFUSEBUMPMAP, hasDiffuseBumpmap ); + SET_STATIC_VERTEX_SHADER_COMBO( VERTEXCOLOR, IS_FLAG_SET( MATERIAL_VAR_VERTEXCOLOR ) ); + SET_STATIC_VERTEX_SHADER_COMBO( VERTEXALPHATEXBLENDFACTOR, hasBaseTexture2 || hasBump2 ); + SET_STATIC_VERTEX_SHADER_COMBO( BUMPMASK, hasBumpMask ); + SET_STATIC_VERTEX_SHADER_COMBO( RELIEF_MAPPING, false );//bReliefMapping ); + SET_STATIC_VERTEX_SHADER_COMBO( SEAMLESS, bSeamlessMapping ); +#ifdef _X360 + SET_STATIC_VERTEX_SHADER_COMBO( FLASHLIGHT, hasFlashlight); +#endif +#ifdef MAPBASE + SET_STATIC_VERTEX_SHADER_COMBO( BASETEXTURETRANSFORM2, hasBaseTextureTransform2 ); +#endif + SET_STATIC_VERTEX_SHADER( sdk_lightmappedgeneric_vs20 ); + } + + + //if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + if ( g_pHardwareConfig->SupportsShaderModel_3_0() ) + { + DECLARE_STATIC_PIXEL_SHADER( sdk_lightmappedgeneric_ps30 ); SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURE2, hasBaseTexture2 ); SET_STATIC_PIXEL_SHADER_COMBO( DETAILTEXTURE, hasDetailTexture ); SET_STATIC_PIXEL_SHADER_COMBO( BUMPMAP, bumpmap_variant ); SET_STATIC_PIXEL_SHADER_COMBO( BUMPMAP2, hasBump2 ); - SET_STATIC_PIXEL_SHADER_COMBO( BUMPMASK, hasBumpMask ); + //SET_STATIC_PIXEL_SHADER_COMBO( BUMPMASK, hasBumpMask ); SET_STATIC_PIXEL_SHADER_COMBO( DIFFUSEBUMPMAP, hasDiffuseBumpmap ); SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP, hasEnvmap ); SET_STATIC_PIXEL_SHADER_COMBO( ENVMAPMASK, hasEnvmapMask ); @@ -604,28 +1114,41 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURENOENVMAP, params[info.m_nBaseTextureNoEnvmap]->GetIntValue() ); SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURE2NOENVMAP, params[info.m_nBaseTexture2NoEnvmap]->GetIntValue() ); SET_STATIC_PIXEL_SHADER_COMBO( WARPLIGHTING, hasLightWarpTexture ); +#ifdef MAPBASE + // There's a bug in Hammer that causes $basetexture and $basetexture2 to be swapped. + // Downfall had a hack to swap them back in the editor, but I noticed $blendmodulatetexture showed up in the editor with the new shader. + // Unfortunately, it became inverted in the editor, so I had to clear $blendmodulatetexture in the editor too, but + // I became interested in the idea of seeing it there, as it would greatly assist with editing those kinds of textures. + // So interested, in fact, that I added a setting to FANCY_BLENDING that swaps $blendmodulatetexture, intended to be used with the Downfall hack. + // It only tests whether it's in the editor right now, but you could turn it into an actual shader parameter if you want. + SET_STATIC_PIXEL_SHADER_COMBO( FANCY_BLENDING, bHasBlendModulateTexture ? (pShader->UsingEditor( params ) ? 2 : 1) : 0 ); +#else SET_STATIC_PIXEL_SHADER_COMBO( FANCY_BLENDING, bHasBlendModulateTexture ); +#endif SET_STATIC_PIXEL_SHADER_COMBO( MASKEDBLENDING, bMaskedBlending); - SET_STATIC_PIXEL_SHADER_COMBO( RELIEF_MAPPING, bReliefMapping ); + //SET_STATIC_PIXEL_SHADER_COMBO( RELIEF_MAPPING, bReliefMapping ); SET_STATIC_PIXEL_SHADER_COMBO( SEAMLESS, bSeamlessMapping ); - SET_STATIC_PIXEL_SHADER_COMBO( OUTLINE, bHasOutline ); - SET_STATIC_PIXEL_SHADER_COMBO( SOFTEDGES, bHasSoftEdges ); + //SET_STATIC_PIXEL_SHADER_COMBO( OUTLINE, bHasOutline ); + //SET_STATIC_PIXEL_SHADER_COMBO( SOFTEDGES, bHasSoftEdges ); SET_STATIC_PIXEL_SHADER_COMBO( DETAIL_BLEND_MODE, nDetailBlendMode ); SET_STATIC_PIXEL_SHADER_COMBO( NORMAL_DECODE_MODE, (int) nNormalDecodeMode ); SET_STATIC_PIXEL_SHADER_COMBO( NORMALMASK_DECODE_MODE, (int) nNormalMaskDecodeMode ); #ifdef _X360 SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHT, hasFlashlight); #endif - SET_STATIC_PIXEL_SHADER( lightmappedgeneric_ps20b ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURETRANSFORM2, hasBaseTextureTransform2 ); +#endif + SET_STATIC_PIXEL_SHADER( sdk_lightmappedgeneric_ps30 ); } else { - DECLARE_STATIC_PIXEL_SHADER( lightmappedgeneric_ps20 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_lightmappedgeneric_ps20b ); SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURE2, hasBaseTexture2 ); SET_STATIC_PIXEL_SHADER_COMBO( DETAILTEXTURE, hasDetailTexture ); SET_STATIC_PIXEL_SHADER_COMBO( BUMPMAP, bumpmap_variant ); SET_STATIC_PIXEL_SHADER_COMBO( BUMPMAP2, hasBump2 ); - SET_STATIC_PIXEL_SHADER_COMBO( BUMPMASK, hasBumpMask ); + //SET_STATIC_PIXEL_SHADER_COMBO( BUMPMASK, hasBumpMask ); SET_STATIC_PIXEL_SHADER_COMBO( DIFFUSEBUMPMAP, hasDiffuseBumpmap ); SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP, hasEnvmap ); SET_STATIC_PIXEL_SHADER_COMBO( ENVMAPMASK, hasEnvmapMask ); @@ -635,16 +1158,55 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURENOENVMAP, params[info.m_nBaseTextureNoEnvmap]->GetIntValue() ); SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURE2NOENVMAP, params[info.m_nBaseTexture2NoEnvmap]->GetIntValue() ); SET_STATIC_PIXEL_SHADER_COMBO( WARPLIGHTING, hasLightWarpTexture ); +#ifdef MAPBASE + // See the comment in the 3.0 shader block for more info on this. + SET_STATIC_PIXEL_SHADER_COMBO( FANCY_BLENDING, bHasBlendModulateTexture ? (pShader->UsingEditor( params ) ? 2 : 1) : 0 ); +#else SET_STATIC_PIXEL_SHADER_COMBO( FANCY_BLENDING, bHasBlendModulateTexture ); +#endif SET_STATIC_PIXEL_SHADER_COMBO( MASKEDBLENDING, bMaskedBlending); + SET_STATIC_PIXEL_SHADER_COMBO( RELIEF_MAPPING, bReliefMapping ); SET_STATIC_PIXEL_SHADER_COMBO( SEAMLESS, bSeamlessMapping ); - SET_STATIC_PIXEL_SHADER_COMBO( OUTLINE, bHasOutline ); - SET_STATIC_PIXEL_SHADER_COMBO( SOFTEDGES, bHasSoftEdges ); + //SET_STATIC_PIXEL_SHADER_COMBO( OUTLINE, bHasOutline ); + //SET_STATIC_PIXEL_SHADER_COMBO( SOFTEDGES, bHasSoftEdges ); SET_STATIC_PIXEL_SHADER_COMBO( DETAIL_BLEND_MODE, nDetailBlendMode ); - SET_STATIC_PIXEL_SHADER_COMBO( NORMAL_DECODE_MODE, 0 ); // No normal compression with ps_2_0 (yikes!) - SET_STATIC_PIXEL_SHADER_COMBO( NORMALMASK_DECODE_MODE, 0 ); // No normal compression with ps_2_0 - SET_STATIC_PIXEL_SHADER( lightmappedgeneric_ps20 ); + SET_STATIC_PIXEL_SHADER_COMBO( NORMAL_DECODE_MODE, (int) nNormalDecodeMode ); + SET_STATIC_PIXEL_SHADER_COMBO( NORMALMASK_DECODE_MODE, (int) nNormalMaskDecodeMode ); +#ifdef _X360 + SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHT, hasFlashlight); +#endif +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURETRANSFORM2, hasBaseTextureTransform2 ); +#endif + SET_STATIC_PIXEL_SHADER( sdk_lightmappedgeneric_ps20b ); } + //else + //{ + // DECLARE_STATIC_PIXEL_SHADER( sdk_lightmappedgeneric_ps20 ); + // SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURE2, hasBaseTexture2 ); + // SET_STATIC_PIXEL_SHADER_COMBO( DETAILTEXTURE, hasDetailTexture ); + // SET_STATIC_PIXEL_SHADER_COMBO( BUMPMAP, bumpmap_variant ); + // SET_STATIC_PIXEL_SHADER_COMBO( BUMPMAP2, hasBump2 ); + // SET_STATIC_PIXEL_SHADER_COMBO( BUMPMASK, hasBumpMask ); + // SET_STATIC_PIXEL_SHADER_COMBO( DIFFUSEBUMPMAP, hasDiffuseBumpmap ); + // SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP, hasEnvmap ); + // SET_STATIC_PIXEL_SHADER_COMBO( ENVMAPMASK, hasEnvmapMask ); + // SET_STATIC_PIXEL_SHADER_COMBO( BASEALPHAENVMAPMASK, hasBaseAlphaEnvmapMask ); + // SET_STATIC_PIXEL_SHADER_COMBO( SELFILLUM, hasSelfIllum ); + // SET_STATIC_PIXEL_SHADER_COMBO( NORMALMAPALPHAENVMAPMASK, hasNormalMapAlphaEnvmapMask ); + // SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURENOENVMAP, params[info.m_nBaseTextureNoEnvmap]->GetIntValue() ); + // SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURE2NOENVMAP, params[info.m_nBaseTexture2NoEnvmap]->GetIntValue() ); + // SET_STATIC_PIXEL_SHADER_COMBO( WARPLIGHTING, hasLightWarpTexture ); + // SET_STATIC_PIXEL_SHADER_COMBO( FANCY_BLENDING, bHasBlendModulateTexture ); + // SET_STATIC_PIXEL_SHADER_COMBO( MASKEDBLENDING, bMaskedBlending); + // SET_STATIC_PIXEL_SHADER_COMBO( SEAMLESS, bSeamlessMapping ); + // SET_STATIC_PIXEL_SHADER_COMBO( OUTLINE, bHasOutline ); + // SET_STATIC_PIXEL_SHADER_COMBO( SOFTEDGES, bHasSoftEdges ); + // SET_STATIC_PIXEL_SHADER_COMBO( DETAIL_BLEND_MODE, nDetailBlendMode ); + // SET_STATIC_PIXEL_SHADER_COMBO( NORMAL_DECODE_MODE, 0 ); // No normal compression with ps_2_0 (yikes!) + // SET_STATIC_PIXEL_SHADER_COMBO( NORMALMASK_DECODE_MODE, 0 ); // No normal compression with ps_2_0 + // SET_STATIC_PIXEL_SHADER( sdk_lightmappedgeneric_ps20 ); + //} // HACK HACK HACK - enable alpha writes all the time so that we have them for // underwater stuff and writing depth to dest alpha // But only do it if we're not using the alpha already for translucency @@ -674,6 +1236,9 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** // for the texture transform. bool bHasTextureTransform = !( params[info.m_nBaseTextureTransform]->MatrixIsIdentity() && +#ifdef MAPBASE + (!hasBaseTextureTransform2 || params[info.m_nBaseTexture2Transform]->MatrixIsIdentity()) && +#endif params[info.m_nBumpTransform]->MatrixIsIdentity() && params[info.m_nBumpTransform2]->MatrixIsIdentity() && params[info.m_nEnvmapMaskTransform]->MatrixIsIdentity() ); @@ -712,6 +1277,12 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** { pContextData->m_SemiStaticCmdsOut.SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_4, info.m_nBumpTransform2 ); } +#ifdef MAPBASE + if ( hasBaseTextureTransform2 ) + { + pContextData->m_SemiStaticCmdsOut.SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_8, info.m_nBaseTexture2Transform ); + } +#endif } pContextData->m_SemiStaticCmdsOut.SetEnvMapTintPixelShaderDynamicState( 0, info.m_nEnvmapTint ); // set up shader modulation color @@ -949,14 +1520,29 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** } MaterialFogMode_t fogType = pShaderAPI->GetSceneFogMode(); - DECLARE_DYNAMIC_VERTEX_SHADER( lightmappedgeneric_vs20 ); - SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); - SET_DYNAMIC_VERTEX_SHADER_COMBO( FASTPATH, bVertexShaderFastPath ); - SET_DYNAMIC_VERTEX_SHADER_COMBO( - LIGHTING_PREVIEW, - (nFixedLightingMode)?1:0 - ); - SET_DYNAMIC_VERTEX_SHADER_CMD( DynamicCmdsOut, lightmappedgeneric_vs20 ); + if ( g_pHardwareConfig->SupportsShaderModel_3_0() ) + { + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_lightmappedgeneric_vs30 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( FASTPATH, bVertexShaderFastPath ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( + LIGHTING_PREVIEW, + (nFixedLightingMode)?1:0 + ); + SET_DYNAMIC_VERTEX_SHADER_CMD( DynamicCmdsOut, sdk_lightmappedgeneric_vs30 ); + } + else + { + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_lightmappedgeneric_vs20 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( FASTPATH, bVertexShaderFastPath ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( + LIGHTING_PREVIEW, + (nFixedLightingMode)?1:0 + ); + SET_DYNAMIC_VERTEX_SHADER_CMD( DynamicCmdsOut, sdk_lightmappedgeneric_vs20 ); + } + bool bPixelShaderFastPath = pContextData->m_bPixelShaderFastPath; if( nFixedLightingMode !=0 ) @@ -979,9 +1565,24 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** } float envmapContrast = params[info.m_nEnvmapContrast]->GetFloatValue(); - if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + //if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + if ( g_pHardwareConfig->SupportsShaderModel_3_0() ) { - DECLARE_DYNAMIC_PIXEL_SHADER( lightmappedgeneric_ps20b ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_lightmappedgeneric_ps30 ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( FASTPATH, bPixelShaderFastPath || pContextData->m_bPixelShaderForceFastPathBecauseOutline ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( FASTPATHENVMAPCONTRAST, bPixelShaderFastPath && envmapContrast == 1.0f ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); + + // Don't write fog to alpha if we're using translucency + SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, bWriteDepthToAlpha ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITEWATERFOGTODESTALPHA, bWriteWaterFogToAlpha ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( LIGHTING_PREVIEW, nFixedLightingMode ); + + SET_DYNAMIC_PIXEL_SHADER_CMD( DynamicCmdsOut, sdk_lightmappedgeneric_ps30 ); + } + else + { + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_lightmappedgeneric_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( FASTPATH, bPixelShaderFastPath || pContextData->m_bPixelShaderForceFastPathBecauseOutline ); SET_DYNAMIC_PIXEL_SHADER_COMBO( FASTPATHENVMAPCONTRAST, bPixelShaderFastPath && envmapContrast == 1.0f ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); @@ -991,21 +1592,21 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITEWATERFOGTODESTALPHA, bWriteWaterFogToAlpha ); SET_DYNAMIC_PIXEL_SHADER_COMBO( LIGHTING_PREVIEW, nFixedLightingMode ); - SET_DYNAMIC_PIXEL_SHADER_CMD( DynamicCmdsOut, lightmappedgeneric_ps20b ); - } - else - { - DECLARE_DYNAMIC_PIXEL_SHADER( lightmappedgeneric_ps20 ); - SET_DYNAMIC_PIXEL_SHADER_COMBO( FASTPATH, bPixelShaderFastPath ); - SET_DYNAMIC_PIXEL_SHADER_COMBO( FASTPATHENVMAPCONTRAST, bPixelShaderFastPath && envmapContrast == 1.0f ); - SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - - // Don't write fog to alpha if we're using translucency - SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITEWATERFOGTODESTALPHA, bWriteWaterFogToAlpha ); - SET_DYNAMIC_PIXEL_SHADER_COMBO( LIGHTING_PREVIEW, nFixedLightingMode ); - - SET_DYNAMIC_PIXEL_SHADER_CMD( DynamicCmdsOut, lightmappedgeneric_ps20 ); + SET_DYNAMIC_PIXEL_SHADER_CMD( DynamicCmdsOut, sdk_lightmappedgeneric_ps20b ); } + //else + //{ + // DECLARE_DYNAMIC_PIXEL_SHADER( sdk_lightmappedgeneric_ps20 ); + // SET_DYNAMIC_PIXEL_SHADER_COMBO( FASTPATH, bPixelShaderFastPath ); + // SET_DYNAMIC_PIXEL_SHADER_COMBO( FASTPATHENVMAPCONTRAST, bPixelShaderFastPath && envmapContrast == 1.0f ); + // SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); + // + // // Don't write fog to alpha if we're using translucency + // SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITEWATERFOGTODESTALPHA, bWriteWaterFogToAlpha ); + // SET_DYNAMIC_PIXEL_SHADER_COMBO( LIGHTING_PREVIEW, nFixedLightingMode ); + // + // SET_DYNAMIC_PIXEL_SHADER_CMD( DynamicCmdsOut, sdk_lightmappedgeneric_ps20 ); + //} if( hasFlashlight && IsX360() ) { @@ -1053,6 +1654,11 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** } } + float eyePos[4]; + pShaderAPI->GetWorldSpaceCameraPosition( eyePos ); + eyePos[3] = pShaderAPI->GetFloatRenderingParameter( FLOAT_RENDERPARM_MINIMUMLIGHTING ); + DynamicCmdsOut.SetPixelShaderConstant( 10, eyePos ); + DynamicCmdsOut.End(); pShaderAPI->ExecuteCommandBuffer( DynamicCmdsOut.Base() ); } @@ -1075,6 +1681,9 @@ void DrawLightmappedGeneric_DX9(CBaseVSShader *pShader, IMaterialVar** params, CBasePerMaterialContextData **pContextDataPtr ) { bool hasFlashlight = pShader->UsingFlashlight( params ); + + ConVarRef r_flashlight_version2 = ConVarRef( "r_flashlight_version2" ); + if ( !IsX360() && !r_flashlight_version2.GetInt() ) { DrawLightmappedGeneric_DX9_Internal( pShader, params, hasFlashlight, pShaderAPI, pShaderShadow, info, pContextDataPtr ); @@ -1082,4 +1691,4 @@ void DrawLightmappedGeneric_DX9(CBaseVSShader *pShader, IMaterialVar** params, } DrawLightmappedGeneric_DX9_Internal( pShader, params, hasFlashlight, pShaderAPI, pShaderShadow, info, pContextDataPtr ); -} +} \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/lightmappedgeneric_dx9_helper.h b/sp/src/materialsystem/stdshaders/lightmappedgeneric_dx9_helper.h index 00375b9f..2038d53b 100644 --- a/sp/src/materialsystem/stdshaders/lightmappedgeneric_dx9_helper.h +++ b/sp/src/materialsystem/stdshaders/lightmappedgeneric_dx9_helper.h @@ -62,6 +62,9 @@ struct LightmappedGeneric_DX9_Vars_t int m_nBumpMask; int m_nBaseTexture2; int m_nBaseTexture2Frame; +#ifdef MAPBASE + int m_nBaseTexture2Transform; +#endif int m_nBaseTextureNoEnvmap; int m_nBaseTexture2NoEnvmap; int m_nDetailAlphaMaskBaseTexture; @@ -87,8 +90,46 @@ struct LightmappedGeneric_DX9_Vars_t int m_nOutlineEnd0; int m_nOutlineEnd1; + int m_nPhong; + int m_nPhongBoost; + int m_nPhongFresnelRanges; + int m_nPhongExponent; }; + +enum PhongMaskVariant_t +{ + PHONGMASK_NONE, + PHONGMASK_BASEALPHA, + PHONGMASK_NORMALALPHA, + PHONGMASK_STANDALONE, +}; + +struct LightmappedGenericFlashlight_DX9_Vars_t : public CBaseVSShader::DrawFlashlight_dx90_Vars_t +{ + LightmappedGenericFlashlight_DX9_Vars_t() + : m_nPhong( -1 ) + , m_nPhongBoost( -1 ) + , m_nPhongFresnelRanges( -1 ) + , m_nPhongExponent( -1 ) + , m_nPhongMask( -1 ) + , m_nPhongMaskFrame( -1 ) + { + } + int m_nPhong; + int m_nPhongBoost; + int m_nPhongFresnelRanges; + int m_nPhongExponent; + int m_nPhongMask; + int m_nPhongMaskFrame; + +#ifdef MAPBASE + // Fix for displacements not showing $blendmodulatetexture under a flashlight + int m_nBlendModulateTexture; +#endif +}; + + void InitParamsLightmappedGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, const char *pMaterialName, LightmappedGeneric_DX9_Vars_t &info ); void InitLightmappedGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, LightmappedGeneric_DX9_Vars_t &info ); void DrawLightmappedGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, @@ -96,4 +137,4 @@ void DrawLightmappedGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, LightmappedGeneric_DX9_Vars_t &info, CBasePerMaterialContextData **pContextDataPtr ); -#endif // LIGHTMAPPEDGENERIC_DX9_HELPER_H +#endif // LIGHTMAPPEDGENERIC_DX9_HELPER_H \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/lightmappedgeneric_ps2_3_x.h b/sp/src/materialsystem/stdshaders/lightmappedgeneric_ps2_3_x.h index 585ea1f6..b8265b1a 100644 --- a/sp/src/materialsystem/stdshaders/lightmappedgeneric_ps2_3_x.h +++ b/sp/src/materialsystem/stdshaders/lightmappedgeneric_ps2_3_x.h @@ -23,10 +23,15 @@ // SKIP: !$BUMPMAP && ($NORMAL_DECODE_MODE == 2) // SKIP: !$BUMPMAP && ($NORMALMASK_DECODE_MODE == 1) // SKIP: !$BUMPMAP && ($NORMALMASK_DECODE_MODE == 2) -// NOSKIP: $FANCY_BLENDING && (!$FASTPATH) // 360 compiler craps out on some combo in this family. Content doesn't use blendmode 10 anyway -// SKIP: $FASTPATH && $PIXELFOGTYPE && $BASETEXTURE2 && $DETAILTEXTURE && $CUBEMAP && ($DETAIL_BLEND_MODE == 10 ) [XBOX] +// SKIP: $FASTPATH && $PIXELFOGTYPE && $BASETEXTURE2 && $DETAILTEXTURE && $CUBEMAP && ($DETAIL_BLEND_MODE == 10 ) + +// Too many instructions to do this all at once: +// SKIP: $FANCY_BLENDING && $BUMPMAP && $DETAILTEXTURE + +// SKIP: $BASETEXTURETRANSFORM2 && !$BASETEXTURE2 +// SKIP: $BASETEXTURETRANSFORM2 && $SEAMLESS // debug crap: // NOSKIP: $DETAILTEXTURE @@ -90,7 +95,11 @@ const float4 g_DetailTint_and_BlendFactor : register( c8 ); #define g_DetailTint (g_DetailTint_and_BlendFactor.rgb) #define g_DetailBlendFactor (g_DetailTint_and_BlendFactor.w) -const HALF3 g_EyePos : register( c10 ); +const float4 g_EyePos_MinLight : register( c10 ); +#define g_EyePos g_EyePos_MinLight.xyz +#define g_fMinLighting g_EyePos_MinLight.w + + const HALF4 g_FogParams : register( c11 ); const float4 g_TintValuesAndLightmapScale : register( c12 ); @@ -157,8 +166,13 @@ struct PS_INPUT #if SEAMLESS float3 SeamlessTexCoord : TEXCOORD0; // zy xz float4 detailOrBumpAndEnvmapMaskTexCoord : TEXCOORD1; // envmap mask +#else +#if BASETEXTURETRANSFORM2 + // Blixibon - Using two extra floats for $basetexturetransform2 + HALF4 baseTexCoord : TEXCOORD0; #else HALF2 baseTexCoord : TEXCOORD0; +#endif // detail textures and bumpmaps are mutually exclusive so that we have enough texcoords. #if ( RELIEF_MAPPING == 0 ) HALF4 detailOrBumpAndEnvmapMaskTexCoord : TEXCOORD1; @@ -211,8 +225,23 @@ HALF4 main( PS_INPUT i ) : COLOR baseTexCoords.xy = i.baseTexCoord.xy; #endif +#if BASETEXTURETRANSFORM2 + // Blixibon - Simpler version of GetBaseTextureAndNormal() that supports $basetexturetransform2 + // (make this its own function in common_lightmappedgeneric_fxc.h if this becomes more widespread) + // + // Also, not sure where else to put this, but we're using an entire BASETEXTURETRANSFORM2 combo + // because in DX9, $basetexture2 would update from the original $basetexturetransform, so + // keeping this code separate retains that original behavior. + baseColor = tex2D( BaseTextureSampler, baseTexCoords.xy ); + baseColor2 = tex2D( BaseTextureSampler2, i.baseTexCoord.wz ); + if ( bBumpmap || bNormalMapAlphaEnvmapMask ) + { + vNormal = tex2D( BumpmapSampler, baseTexCoords.xy ); + } +#else GetBaseTextureAndNormal( BaseTextureSampler, BaseTextureSampler2, BumpmapSampler, bBaseTexture2, bBumpmap || bNormalMapAlphaEnvmapMask, baseTexCoords, i.vertexColor.rgb, baseColor, baseColor2, vNormal ); +#endif #if BUMPMAP == 1 // not ssbump vNormal.xyz = vNormal.xyz * 2.0f - 1.0f; // make signed if we're not ssbump @@ -317,20 +346,27 @@ HALF4 main( PS_INPUT i ) : COLOR if( bBaseTexture2 ) { #if (SELFILLUM == 0) && (PIXELFOGTYPE != PIXEL_FOG_TYPE_HEIGHT) && (FANCY_BLENDING) - float4 modt=tex2D(BlendModulationSampler,i.lightmapTexCoord3.zw); + float4 modt=tex2D(BlendModulationSampler,baseTexCoords); #if MASKEDBLENDING - // FXC is unable to optimize this, despite blendfactor=0.5 above - //float minb=modt.g-modt.r; - //float maxb=modt.g+modt.r; - //blendfactor=smoothstep(minb,maxb,blendfactor); - blendfactor=modt.g; + float minb=modt.g-modt.r; + float maxb=modt.g+modt.r; #else - float minb=saturate(modt.g-modt.r); - float maxb=saturate(modt.g+modt.r); + +# if FANCY_BLENDING == 2 + // Blixibon - Accompanies the Downfall hack that swaps textures in the editor, + // allows $blendmodulatetexture to be seen in Hammer + float modtg = 1.0f-modt.g; + float minb=max(0,modtg-modt.r); + float maxb=min(1,modtg+modt.r); +# else + float minb=max(0,modt.g-modt.r); + float maxb=min(1,modt.g+modt.r); +# endif + +#endif blendfactor=smoothstep(minb,maxb,blendfactor); #endif -#endif - baseColor.rgb = lerp( baseColor, baseColor2.rgb, blendfactor ); + baseColor.rgb = lerp( baseColor.rgb, baseColor2.rgb, blendfactor ); blendedAlpha = lerp( baseColor.a, baseColor2.a, blendfactor ); } @@ -424,7 +460,7 @@ HALF4 main( PS_INPUT i ) : COLOR // The vertex color contains the modulation color + vertex color combined #if ( SEAMLESS == 0 ) - albedo.xyz *= i.vertexColor; + albedo.xyz *= i.vertexColor.xyz; #endif alpha *= i.vertexColor.a * g_flAlpha2; // not sure about this one @@ -447,9 +483,9 @@ HALF4 main( PS_INPUT i ) : COLOR vNormal.xyz = normalize( bumpBasis[0]*vNormal.x + bumpBasis[1]*vNormal.y + bumpBasis[2]*vNormal.z); #else float3 dp; - dp.x = saturate( dot( vNormal, bumpBasis[0] ) ); - dp.y = saturate( dot( vNormal, bumpBasis[1] ) ); - dp.z = saturate( dot( vNormal, bumpBasis[2] ) ); + dp.x = saturate( dot( vNormal.xyz, bumpBasis[0] ) ); + dp.y = saturate( dot( vNormal.xyz, bumpBasis[1] ) ); + dp.z = saturate( dot( vNormal.xyz, bumpBasis[2] ) ); dp *= dp; #if ( DETAIL_BLEND_MODE == TCOMBINE_SSBUMP_BUMP ) @@ -475,11 +511,23 @@ HALF4 main( PS_INPUT i ) : COLOR diffuseLighting *= 2.0*tex2D(WarpLightingSampler,float2(len,0)); #endif -#if CUBEMAP || LIGHTING_PREVIEW || ( defined( _X360 ) && FLASHLIGHT ) - float3 worldSpaceNormal = mul( vNormal, i.tangentSpaceTranspose ); +#if 1 //CUBEMAP || LIGHTING_PREVIEW || ( defined( _X360 ) && FLASHLIGHT ) + float3x3 tangentSpaceTranspose = i.tangentSpaceTranspose; + + float3 worldSpaceNormal = mul( vNormal.xyz, i.tangentSpaceTranspose ); #endif + float3 worldVertToEyeVector = g_EyePos - i.worldPos_projPosZ.xyz; + +#if FOGTYPE == 2 || FLASHLIGHT != 0 float3 diffuseComponent = albedo.xyz * diffuseLighting; +#else + float3 vEyeDir = normalize( worldVertToEyeVector ); + float flFresnelMinlight = saturate( dot( worldSpaceNormal, vEyeDir ) ); + + float3 diffuseComponent = albedo.xyz * lerp( diffuseLighting, 1, g_fMinLighting * flFresnelMinlight ); +#endif + #if defined( _X360 ) && FLASHLIGHT @@ -490,9 +538,9 @@ HALF4 main( PS_INPUT i ) : COLOR float3 worldPosToLightVector = g_FlashlightPos - i.worldPos_projPosZ.xyz; float3 tangentPosToLightVector; - tangentPosToLightVector.x = dot( worldPosToLightVector, i.tangentSpaceTranspose[0] ); - tangentPosToLightVector.y = dot( worldPosToLightVector, i.tangentSpaceTranspose[1] ); - tangentPosToLightVector.z = dot( worldPosToLightVector, i.tangentSpaceTranspose[2] ); + tangentPosToLightVector.x = dot( worldPosToLightVector, tangentSpaceTranspose[0] ); + tangentPosToLightVector.y = dot( worldPosToLightVector, tangentSpaceTranspose[1] ); + tangentPosToLightVector.z = dot( worldPosToLightVector, tangentSpaceTranspose[2] ); tangentPosToLightVector = normalize( tangentPosToLightVector ); @@ -514,7 +562,7 @@ HALF4 main( PS_INPUT i ) : COLOR if( bSelfIllum ) { - float3 selfIllumComponent = g_SelfIllumTint * albedo.xyz; + float3 selfIllumComponent = g_SelfIllumTint.xyz * albedo.xyz; diffuseComponent = lerp( diffuseComponent, selfIllumComponent, baseColor.a ); } @@ -522,7 +570,7 @@ HALF4 main( PS_INPUT i ) : COLOR #if CUBEMAP if( bCubemap ) { - float3 worldVertToEyeVector = g_EyePos - i.worldPos_projPosZ.xyz; + //float3 worldVertToEyeVector = g_EyePos - i.worldPos_projPosZ.xyz; float3 reflectVect = CalcReflectionVectorUnnormalized( worldSpaceNormal, worldVertToEyeVector ); // Calc Fresnel factor @@ -534,7 +582,7 @@ HALF4 main( PS_INPUT i ) : COLOR specularLighting = ENV_MAP_SCALE * texCUBE( EnvmapSampler, reflectVect ); specularLighting *= specularFactor; - specularLighting *= g_EnvmapTint; + specularLighting *= g_EnvmapTint.rgb; #if FANCY_BLENDING == 0 HALF3 specularLightingSquared = specularLighting * specularLighting; specularLighting = lerp( specularLighting, specularLightingSquared, g_EnvmapContrast ); @@ -548,7 +596,7 @@ HALF4 main( PS_INPUT i ) : COLOR HALF3 result = diffuseComponent + specularLighting; #if LIGHTING_PREVIEW - worldSpaceNormal = mul( vNormal, i.tangentSpaceTranspose ); + worldSpaceNormal = mul( vNormal, tangentSpaceTranspose ); # if LIGHTING_PREVIEW == 1 float dotprod = 0.7+0.25 * dot( worldSpaceNormal, normalize( float3( 1, 2, -.5 ) ) ); return FinalOutput( HALF4( dotprod*albedo.xyz, alpha ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE ); @@ -570,7 +618,7 @@ HALF4 main( PS_INPUT i ) : COLOR bWriteDepthToAlpha = ( WRITE_DEPTH_TO_DESTALPHA != 0 ) && ( WRITEWATERFOGTODESTALPHA == 0 ); #endif - float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.z, i.worldPos_projPosZ.z, i.worldPos_projPosZ.w ); + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); #if WRITEWATERFOGTODESTALPHA && (PIXELFOGTYPE == PIXEL_FOG_TYPE_HEIGHT) alpha = fogFactor; diff --git a/sp/src/materialsystem/stdshaders/lightmappedreflective.cpp b/sp/src/materialsystem/stdshaders/lightmappedreflective.cpp new file mode 100644 index 00000000..ae7bad2f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/lightmappedreflective.cpp @@ -0,0 +1,282 @@ +//===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======// +// +// Purpose: +// +// $NoKeywords: $ +//===========================================================================// + +#include "BaseVSShader.h" +#include "mathlib/VMatrix.h" +#include "common_hlsl_cpp_consts.h" // hack hack hack! + +#include "SDK_lightmappedreflective_vs20.inc" +#include "SDK_lightmappedreflective_ps20.inc" +#include "SDK_lightmappedreflective_ps20b.inc" + + +DEFINE_FALLBACK_SHADER( SDK_LightmappedReflective, SDK_LightmappedReflective_DX90 ) + +BEGIN_VS_SHADER( SDK_LightmappedReflective_DX90, "Help for SDK_Lightmapped Reflective" ) + + BEGIN_SHADER_PARAMS + SHADER_PARAM( REFRACTTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_WaterRefraction", "" ) + SHADER_PARAM( REFLECTTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_WaterReflection", "" ) + SHADER_PARAM( REFRACTAMOUNT, SHADER_PARAM_TYPE_FLOAT, "0", "" ) + SHADER_PARAM( REFRACTTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "refraction tint" ) + SHADER_PARAM( REFLECTAMOUNT, SHADER_PARAM_TYPE_FLOAT, "0.8", "" ) + SHADER_PARAM( REFLECTTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "reflection tint" ) + SHADER_PARAM( NORMALMAP, SHADER_PARAM_TYPE_TEXTURE, "dev/water_normal", "normal map" ) + SHADER_PARAM( BUMPFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for $bumpmap" ) + SHADER_PARAM( BUMPTRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "$bumpmap texcoord transform" ) + SHADER_PARAM( ENVMAPMASK, SHADER_PARAM_TYPE_TEXTURE, "shadertest/shadertest_envmask", "envmap mask" ) + SHADER_PARAM( ENVMAPMASKFRAME, SHADER_PARAM_TYPE_INTEGER, "", "" ) + SHADER_PARAM( FRESNELPOWER, SHADER_PARAM_TYPE_FLOAT, "5", "" ) + SHADER_PARAM( MAXREFLECTIVITY, SHADER_PARAM_TYPE_FLOAT, "1", "" ) + SHADER_PARAM( MINREFLECTIVITY, SHADER_PARAM_TYPE_FLOAT, "0", "" ) + END_SHADER_PARAMS + + SHADER_INIT_PARAMS() + { + if ( !params[FRESNELPOWER]->IsDefined() ) + { + params[FRESNELPOWER]->SetFloatValue( 5.0f ); + } + if ( !params[MAXREFLECTIVITY]->IsDefined() ) + { + params[MAXREFLECTIVITY]->SetFloatValue( 1.0f ); + } + + SET_FLAGS2( MATERIAL_VAR2_NEEDS_TANGENT_SPACES ); + if ( params[BASETEXTURE]->IsDefined() ) + { + SET_FLAGS2( MATERIAL_VAR2_LIGHTING_LIGHTMAP ); + if( g_pConfig->UseBumpmapping() && params[NORMALMAP]->IsDefined() ) + { + SET_FLAGS2( MATERIAL_VAR2_LIGHTING_BUMPED_LIGHTMAP ); + } + } + } + + SHADER_FALLBACK + { + // FIXME: Create dx8 level fallback if we use this feature out of the SFM + return 0; + } + + SHADER_INIT + { + if( params[REFRACTTEXTURE]->IsDefined() ) + { + LoadTexture( REFRACTTEXTURE ); + } + if( params[REFLECTTEXTURE]->IsDefined() ) + { + LoadTexture( REFLECTTEXTURE ); + } + if ( params[NORMALMAP]->IsDefined() ) + { + LoadBumpMap( NORMALMAP ); + } + if( params[BASETEXTURE]->IsDefined() ) + { + LoadTexture( BASETEXTURE ); + if( params[ENVMAPMASK]->IsDefined() ) + { + LoadTexture( ENVMAPMASK ); + } + } + else + { + params[ENVMAPMASK]->SetUndefined(); + } + } + + inline void DrawReflectionRefraction( IMaterialVar **params, IShaderShadow* pShaderShadow, + IShaderDynamicAPI* pShaderAPI, bool bReflection, bool bRefraction ) + { + BlendType_t nBlendType = EvaluateBlendRequirements( BASETEXTURE, true ); + bool bFullyOpaque = (nBlendType != BT_BLENDADD) && (nBlendType != BT_BLEND) && !IS_FLAG_SET(MATERIAL_VAR_ALPHATEST); //dest alpha is free for special use + + SHADOW_STATE + { + SetInitialShadowState( ); + if( bRefraction ) + { + pShaderShadow->EnableTexture( SHADER_SAMPLER0, true ); + pShaderShadow->EnableTexture( SHADER_SAMPLER1, true ); + if( g_pHardwareConfig->GetHDRType() == HDR_TYPE_INTEGER ) + { + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, true ); + } + } + if( bReflection ) + { + pShaderShadow->EnableTexture( SHADER_SAMPLER2, true ); + pShaderShadow->EnableTexture( SHADER_SAMPLER3, true ); + if( g_pHardwareConfig->GetHDRType() == HDR_TYPE_INTEGER ) + { + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER2, true ); + } + } + if( params[BASETEXTURE]->IsTexture() ) + { + // BASETEXTURE + pShaderShadow->EnableTexture( SHADER_SAMPLER1, true ); + // LIGHTMAP + pShaderShadow->EnableTexture( SHADER_SAMPLER3, true ); + + if ( params[ENVMAPMASK]->IsTexture() ) + { + pShaderShadow->EnableTexture( SHADER_SAMPLER6, true ); + } + } + + // normal map + pShaderShadow->EnableTexture( SHADER_SAMPLER4, true ); + + int fmt = VERTEX_POSITION | VERTEX_NORMAL | VERTEX_TANGENT_S | VERTEX_TANGENT_T; + + // texcoord0 : base texcoord + // texcoord1 : lightmap texcoord + // texcoord2 : lightmap texcoord offset + int numTexCoords = 1; + if( params[BASETEXTURE]->IsTexture() ) + { + numTexCoords = 3; + } + pShaderShadow->VertexShaderVertexFormat( fmt, numTexCoords, 0, 0 ); + + if ( IS_FLAG_SET(MATERIAL_VAR_TRANSLUCENT ) ) + { + EnableAlphaBlending( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE_MINUS_SRC_ALPHA ); + } + + DECLARE_STATIC_VERTEX_SHADER( sdk_lightmappedreflective_vs20 ); + SET_STATIC_VERTEX_SHADER_COMBO( BASETEXTURE, params[BASETEXTURE]->IsTexture() ); + SET_STATIC_VERTEX_SHADER( sdk_lightmappedreflective_vs20 ); + + // "REFLECT" "0..1" + // "REFRACT" "0..1" + + if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + DECLARE_STATIC_PIXEL_SHADER( sdk_lightmappedreflective_ps20b ); + SET_STATIC_PIXEL_SHADER_COMBO( REFLECT, bReflection ); + SET_STATIC_PIXEL_SHADER_COMBO( REFRACT, bRefraction ); + SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURE, params[BASETEXTURE]->IsTexture() ); + SET_STATIC_PIXEL_SHADER_COMBO( ENVMAPMASK, params[ENVMAPMASK]->IsTexture() && params[BASETEXTURE]->IsTexture() ); + SET_STATIC_PIXEL_SHADER( sdk_lightmappedreflective_ps20b ); + } + else + { + DECLARE_STATIC_PIXEL_SHADER( sdk_lightmappedreflective_ps20 ); + SET_STATIC_PIXEL_SHADER_COMBO( REFLECT, bReflection ); + SET_STATIC_PIXEL_SHADER_COMBO( REFRACT, bRefraction ); + SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURE, params[BASETEXTURE]->IsTexture() ); + SET_STATIC_PIXEL_SHADER_COMBO( ENVMAPMASK, params[ENVMAPMASK]->IsTexture() && params[BASETEXTURE]->IsTexture() ); + SET_STATIC_PIXEL_SHADER( sdk_lightmappedreflective_ps20 ); + } + + FogToFogColor(); + + if( g_pHardwareConfig->GetHDRType() != HDR_TYPE_NONE ) + { + // we are writing linear values from this shader. + pShaderShadow->EnableSRGBWrite( true ); + } + + pShaderShadow->EnableAlphaWrites( bFullyOpaque ); + } + DYNAMIC_STATE + { + if( bRefraction ) + { + // HDRFIXME: add comment about binding.. Specify the number of MRTs in the enable + BindTexture( SHADER_SAMPLER0, REFRACTTEXTURE, -1 ); + } + if( bReflection ) + { + BindTexture( SHADER_SAMPLER2, REFLECTTEXTURE, -1 ); + } + BindTexture( SHADER_SAMPLER4, NORMALMAP, BUMPFRAME ); + if( params[BASETEXTURE]->IsTexture() ) + { + BindTexture( SHADER_SAMPLER1, BASETEXTURE, FRAME ); + pShaderAPI->BindStandardTexture( SHADER_SAMPLER3, TEXTURE_LIGHTMAP ); + SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_3, BASETEXTURETRANSFORM ); + + if ( params[ENVMAPMASK]->IsTexture() ) + { + BindTexture( SHADER_SAMPLER6, ENVMAPMASK, ENVMAPMASKFRAME ); + } + } + + // Refraction tint + if( bRefraction ) + { + SetPixelShaderConstantGammaToLinear( 1, REFRACTTINT ); + } + // Reflection tint + if( bReflection ) + { + SetPixelShaderConstantGammaToLinear( 4, REFLECTTINT ); + } + + SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_1, BUMPTRANSFORM ); + + float c0[4] = { 1.0f / 3.0f, 1.0f / 3.0f, 1.0f / 3.0f, 0.0f }; + pShaderAPI->SetPixelShaderConstant( 0, c0, 1 ); + + float c2[4] = { 0.5f, 0.5f, 0.5f, 0.5f }; + pShaderAPI->SetPixelShaderConstant( 2, c2, 1 ); + + // fresnel constants + float flFresnelFactor = params[MAXREFLECTIVITY]->GetFloatValue() - params[MINREFLECTIVITY]->GetFloatValue(); + float c3[4] = { flFresnelFactor, params[FRESNELPOWER]->GetFloatValue(), params[MINREFLECTIVITY]->GetFloatValue(), 0.0f }; + pShaderAPI->SetPixelShaderConstant( 3, c3, 1 ); + + float c5[4] = { params[REFLECTAMOUNT]->GetFloatValue(), params[REFLECTAMOUNT]->GetFloatValue(), + params[REFRACTAMOUNT]->GetFloatValue(), params[REFRACTAMOUNT]->GetFloatValue() }; + pShaderAPI->SetPixelShaderConstant( 5, c5, 1 ); + + pShaderAPI->SetPixelShaderFogParams( 8 ); + + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_lightmappedreflective_vs20 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_lightmappedreflective_vs20 ); + + if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_lightmappedreflective_ps20b ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, bFullyOpaque && pShaderAPI->ShouldWriteDepthToDestAlpha() ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); + SET_DYNAMIC_PIXEL_SHADER( sdk_lightmappedreflective_ps20b ); + } + else + { + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_lightmappedreflective_ps20 ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); + SET_DYNAMIC_PIXEL_SHADER( sdk_lightmappedreflective_ps20 ); + } + } + Draw(); + } + + SHADER_DRAW + { + bool bRefraction = params[REFRACTTEXTURE]->IsTexture(); + bool bReflection = params[REFLECTTEXTURE]->IsTexture(); + bool bDrewSomething = false; + if ( bReflection || bRefraction ) + { + bDrewSomething = true; + DrawReflectionRefraction( params, pShaderShadow, pShaderAPI, bReflection, bRefraction ); + } + + if( !bDrewSomething ) + { + // We are likely here because of the tools. . . draw something so that + // we won't go into wireframe-land. + Draw(); + } + } +END_SHADER diff --git a/sp/src/materialsystem/stdshaders/refract.cpp b/sp/src/materialsystem/stdshaders/refract.cpp index 852e93a5..4ed22b1d 100644 --- a/sp/src/materialsystem/stdshaders/refract.cpp +++ b/sp/src/materialsystem/stdshaders/refract.cpp @@ -9,9 +9,9 @@ #include "convar.h" #include "refract_dx9_helper.h" -DEFINE_FALLBACK_SHADER( Refract, Refract_DX90 ) +DEFINE_FALLBACK_SHADER( SDK_Refract, SDK_Refract_DX90 ) -BEGIN_VS_SHADER( Refract_DX90, "Help for Refract" ) +BEGIN_VS_SHADER( SDK_Refract_DX90, "Help for SDK_Refract" ) BEGIN_SHADER_PARAMS SHADER_PARAM_OVERRIDE( COLOR, SHADER_PARAM_TYPE_COLOR, "{255 255 255}", "unused", SHADER_PARAM_NOT_EDITABLE ) diff --git a/sp/src/materialsystem/stdshaders/refract_dx9_helper.cpp b/sp/src/materialsystem/stdshaders/refract_dx9_helper.cpp index f436e62a..05689c24 100644 --- a/sp/src/materialsystem/stdshaders/refract_dx9_helper.cpp +++ b/sp/src/materialsystem/stdshaders/refract_dx9_helper.cpp @@ -8,9 +8,9 @@ #include "BaseVSShader.h" #include "refract_dx9_helper.h" #include "convar.h" -#include "Refract_vs20.inc" -#include "Refract_ps20.inc" -#include "Refract_ps20b.inc" +#include "sdk_refract_vs20.inc" +#include "SDK_Refract_ps20.inc" +#include "sdk_refract_ps20b.inc" #include "cpp_shader_constant_register_map.h" #define MAXBLUR 1 @@ -206,16 +206,16 @@ void DrawRefract_DX9( CBaseVSShader *pShader, IMaterialVar** params, IShaderDyna pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, NULL, userDataSize ); - DECLARE_STATIC_VERTEX_SHADER( refract_vs20 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_refract_vs20 ); SET_STATIC_VERTEX_SHADER_COMBO( MODEL, bIsModel ); SET_STATIC_VERTEX_SHADER_COMBO( COLORMODULATE, bColorModulate ); - SET_STATIC_VERTEX_SHADER( refract_vs20 ); + SET_STATIC_VERTEX_SHADER( sdk_refract_vs20 ); // We have to do this in the shader on R500 or Leopard bool bShaderSRGBConvert = IsOSX() && ( g_pHardwareConfig->FakeSRGBWrite() || !g_pHardwareConfig->CanDoSRGBReadFromRTs() ); if ( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() ) // always send OpenGL down the ps2b path { - DECLARE_STATIC_PIXEL_SHADER( refract_ps20b ); + DECLARE_STATIC_PIXEL_SHADER( sdk_refract_ps20b ); SET_STATIC_PIXEL_SHADER_COMBO( BLUR, blurAmount ); SET_STATIC_PIXEL_SHADER_COMBO( FADEOUTONSILHOUETTE, bFadeOutOnSilhouette ); SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP, bHasEnvmap ); @@ -225,11 +225,11 @@ void DrawRefract_DX9( CBaseVSShader *pShader, IMaterialVar** params, IShaderDyna SET_STATIC_PIXEL_SHADER_COMBO( SECONDARY_NORMAL, bSecondaryNormal ); SET_STATIC_PIXEL_SHADER_COMBO( NORMAL_DECODE_MODE, (int) nNormalDecodeMode ); SET_STATIC_PIXEL_SHADER_COMBO( SHADER_SRGB_READ, bShaderSRGBConvert ); - SET_STATIC_PIXEL_SHADER( refract_ps20b ); + SET_STATIC_PIXEL_SHADER( sdk_refract_ps20b ); } else { - DECLARE_STATIC_PIXEL_SHADER( refract_ps20 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_refract_ps20 ); SET_STATIC_PIXEL_SHADER_COMBO( BLUR, blurAmount ); SET_STATIC_PIXEL_SHADER_COMBO( FADEOUTONSILHOUETTE, bFadeOutOnSilhouette ); SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP, bHasEnvmap ); @@ -238,7 +238,7 @@ void DrawRefract_DX9( CBaseVSShader *pShader, IMaterialVar** params, IShaderDyna SET_STATIC_PIXEL_SHADER_COMBO( COLORMODULATE, bColorModulate ); SET_STATIC_PIXEL_SHADER_COMBO( SECONDARY_NORMAL, bSecondaryNormal ); SET_STATIC_PIXEL_SHADER_COMBO( NORMAL_DECODE_MODE, (int) nNormalDecodeMode ); - SET_STATIC_PIXEL_SHADER( refract_ps20 ); + SET_STATIC_PIXEL_SHADER( sdk_refract_ps20 ); } pShader->DefaultFog(); if( bMasked ) @@ -293,23 +293,23 @@ void DrawRefract_DX9( CBaseVSShader *pShader, IMaterialVar** params, IShaderDyna pShader->BindTexture( SHADER_SAMPLER5, info.m_nRefractTintTexture, info.m_nRefractTintTextureFrame ); } - DECLARE_DYNAMIC_VERTEX_SHADER( refract_vs20 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_refract_vs20 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); - SET_DYNAMIC_VERTEX_SHADER( refract_vs20 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_refract_vs20 ); if ( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() ) // always send Posix down the ps2b path { - DECLARE_DYNAMIC_PIXEL_SHADER( refract_ps20b ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_refract_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, bWriteZ && bFullyOpaque && pShaderAPI->ShouldWriteDepthToDestAlpha() ); - SET_DYNAMIC_PIXEL_SHADER( refract_ps20b ); + SET_DYNAMIC_PIXEL_SHADER( sdk_refract_ps20b ); } else { - DECLARE_DYNAMIC_PIXEL_SHADER( refract_ps20 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_refract_ps20 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - SET_DYNAMIC_PIXEL_SHADER( refract_ps20 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_refract_ps20 ); } pShader->SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_1, info.m_nBumpTransform ); // 1 & 2 diff --git a/sp/src/materialsystem/stdshaders/sdk_eyeglint_ps2x.fxc b/sp/src/materialsystem/stdshaders/sdk_eyeglint_ps2x.fxc new file mode 100644 index 00000000..bc39f079 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/sdk_eyeglint_ps2x.fxc @@ -0,0 +1,32 @@ +// ======= Copyright © 1996-2007, Valve Corporation, All rights reserved. ====== +// +// Run procedural glint generation inner loop in pixel shader (ps_2_0) +// +// ============================================================================= + +struct PS_INPUT +{ + float2 tc : TEXCOORD0; // Interpolated coordinate of current texel + float2 glintCenter : TEXCOORD1; // Uniform value containing center of glint + float3 glintColor : TEXCOORD2; // Uniform value of color of glint +}; + +float GlintGaussSpotCoefficient( float2 d ) +{ + return saturate( exp( -25.0f * dot(d, d) ) ); +} + +float4 main( PS_INPUT i ) : COLOR +{ + float2 uv = i.tc - i.glintCenter; // This texel relative to glint center + + float intensity = GlintGaussSpotCoefficient( uv + float2(-0.25f, -0.25f) ) + + GlintGaussSpotCoefficient( uv + float2( 0.25f, -0.25f) ) + + 5 * GlintGaussSpotCoefficient( uv ) + + GlintGaussSpotCoefficient( uv + float2(-0.25f, 0.25f) ) + + GlintGaussSpotCoefficient( uv + float2( 0.25f, 0.25f) ); + + intensity *= 4.0f/9.0f; + + return float4( intensity * i.glintColor, 1.0f ); +} \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/sdk_eyeglint_vs20.fxc b/sp/src/materialsystem/stdshaders/sdk_eyeglint_vs20.fxc new file mode 100644 index 00000000..cf1ccb9b --- /dev/null +++ b/sp/src/materialsystem/stdshaders/sdk_eyeglint_vs20.fxc @@ -0,0 +1,38 @@ +//===== Copyright © 1996-2007, Valve Corporation, All rights reserved. ======// +// +// Vertex shader to pass through texcoords needed to run the +// procedural glint generation inner loop in the pixel shader +// +// $Header: $ +// $NoKeywords: $ +//===========================================================================// + +#include "common_vs_fxc.h" + +struct VS_INPUT +{ + float3 vPos : POSITION; + float2 tc : TEXCOORD0; // Interpolated coordinate of current texel in 3x3 quad + float2 glintCenter : TEXCOORD1; // Uniform value containing center of glint in local 3x3 quad + float3 glintColor : TEXCOORD2; // Uniform value of color of glint +}; + +struct VS_OUTPUT +{ + float4 projPos : POSITION; + float2 tc : TEXCOORD0; // Interpolated coordinate of current texel in 3x3 quad + float2 glintCenter : TEXCOORD1; // Uniform value containing center of glint in local 3x3 quad + float3 glintColor : TEXCOORD2; // Uniform value of color of glint +}; + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + o.projPos = float4( v.vPos, 1.0f ); + o.tc = v.tc; + o.glintCenter = v.glintCenter; + o.glintColor = v.glintColor; + return o; +} + + diff --git a/sp/src/materialsystem/stdshaders/skin_dx9_helper.cpp b/sp/src/materialsystem/stdshaders/skin_dx9_helper.cpp index 1e2d30f3..698668e9 100644 --- a/sp/src/materialsystem/stdshaders/skin_dx9_helper.cpp +++ b/sp/src/materialsystem/stdshaders/skin_dx9_helper.cpp @@ -9,13 +9,13 @@ #include "skin_dx9_helper.h" #include "convar.h" #include "cpp_shader_constant_register_map.h" -#include "skin_vs20.inc" -#include "skin_ps20b.inc" +#include "SDK_skin_vs20.inc" +#include "SDK_skin_ps20b.inc" #include "commandbuilder.h" #ifndef _X360 -#include "skin_vs30.inc" -#include "skin_ps30.inc" +#include "SDK_skin_vs30.inc" +#include "SDK_skin_ps30.inc" #endif // memdbgon must be the last include file in a .cpp file!!! @@ -115,6 +115,10 @@ void InitParamsSkin_DX9( CBaseVSShader *pShader, IMaterialVar** params, const ch { params[info.m_nEnvmapFresnel]->SetFloatValue( 0 ); } + +#ifdef MAPBASE + InitIntParam( info.m_nPhongDisableHalfLambert, params, 0 ); +#endif } //----------------------------------------------------------------------------- @@ -270,6 +274,15 @@ void DrawSkin_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShad float flTintReplacementAmount = GetFloatParam( info.m_nTintReplacesBaseColor, params ); +#ifdef MAPBASE + // This option was ported from Alien Swarm for Source 2013's "skin shader" implementation. + // Original comment from Alien Swarm SDK: + // "This is to allow phong materials to disable half lambert. Half lambert has always been forced on in phong, + // so the only safe way to allow artists to disable half lambert is to create this param that disables the + // default behavior of forcing half lambert on." + bool bPhongHalfLambert = IS_PARAM_DEFINED( info.m_nPhongDisableHalfLambert ) ? (params[info.m_nPhongDisableHalfLambert]->GetIntValue() == 0) : true; +#endif + BlendType_t nBlendType= pShader->EvaluateBlendRequirements( bBlendTintByBaseAlpha ? -1 : info.m_nBaseTexture, true ); bool bFullyOpaque = (nBlendType != BT_BLENDADD) && (nBlendType != BT_BLEND) && !bIsAlphaTested && !bHasFlashlight; //dest alpha is free for special use @@ -444,17 +457,17 @@ void DrawSkin_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShad #ifndef _X360 - if ( !g_pHardwareConfig->HasFastVertexTextures() ) + if ( !g_pHardwareConfig->SupportsShaderModel_3_0() ) #endif { bool bUseStaticControlFlow = g_pHardwareConfig->SupportsStaticControlFlow(); - DECLARE_STATIC_VERTEX_SHADER( skin_vs20 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_skin_vs20 ); SET_STATIC_VERTEX_SHADER_COMBO( USE_STATIC_CONTROL_FLOW, bUseStaticControlFlow ); - SET_STATIC_VERTEX_SHADER( skin_vs20 ); + SET_STATIC_VERTEX_SHADER( sdk_skin_vs20 ); // Assume we're only going to get in here if we support 2b - DECLARE_STATIC_PIXEL_SHADER( skin_ps20b ); + DECLARE_STATIC_PIXEL_SHADER( sdk_skin_ps20b ); SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHT, bHasFlashlight ); SET_STATIC_PIXEL_SHADER_COMBO( SELFILLUM, bHasSelfIllum && !bHasFlashlight ); SET_STATIC_PIXEL_SHADER_COMBO( SELFILLUMFRESNEL, bHasSelfIllumFresnel && !bHasFlashlight ); @@ -469,19 +482,25 @@ void DrawSkin_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShad SET_STATIC_PIXEL_SHADER_COMBO( CONVERT_TO_SRGB, 0 ); SET_STATIC_PIXEL_SHADER_COMBO( FASTPATH_NOBUMP, pContextData->m_bFastPath ); SET_STATIC_PIXEL_SHADER_COMBO( BLENDTINTBYBASEALPHA, bBlendTintByBaseAlpha ); - SET_STATIC_PIXEL_SHADER( skin_ps20b ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( PHONG_HALFLAMBERT, bPhongHalfLambert ); +#endif + SET_STATIC_PIXEL_SHADER( sdk_skin_ps20b ); } #ifndef _X360 else { + const bool bFastVertexTextures = g_pHardwareConfig->HasFastVertexTextures(); + // The vertex shader uses the vertex id stream - SET_FLAGS2( MATERIAL_VAR2_USES_VERTEXID ); + if ( bFastVertexTextures ) + SET_FLAGS2( MATERIAL_VAR2_USES_VERTEXID ); - DECLARE_STATIC_VERTEX_SHADER( skin_vs30 ); - SET_STATIC_VERTEX_SHADER_COMBO( DECAL, bIsDecal ); - SET_STATIC_VERTEX_SHADER( skin_vs30 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_skin_vs30 ); + SET_STATIC_VERTEX_SHADER_COMBO( DECAL, bIsDecal && bFastVertexTextures ); + SET_STATIC_VERTEX_SHADER( sdk_skin_vs30 ); - DECLARE_STATIC_PIXEL_SHADER( skin_ps30 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_skin_ps30 ); SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHT, bHasFlashlight ); SET_STATIC_PIXEL_SHADER_COMBO( SELFILLUM, bHasSelfIllum && !bHasFlashlight ); SET_STATIC_PIXEL_SHADER_COMBO( SELFILLUMFRESNEL, bHasSelfIllumFresnel && !bHasFlashlight ); @@ -496,7 +515,10 @@ void DrawSkin_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShad SET_STATIC_PIXEL_SHADER_COMBO( CONVERT_TO_SRGB, 0 ); SET_STATIC_PIXEL_SHADER_COMBO( FASTPATH_NOBUMP, pContextData->m_bFastPath ); SET_STATIC_PIXEL_SHADER_COMBO( BLENDTINTBYBASEALPHA, bBlendTintByBaseAlpha ); - SET_STATIC_PIXEL_SHADER( skin_ps30 ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( PHONG_HALFLAMBERT, bPhongHalfLambert ); +#endif + SET_STATIC_PIXEL_SHADER( sdk_skin_ps30 ); } #endif @@ -657,50 +679,56 @@ void DrawSkin_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShad } #ifndef _X360 - if ( !g_pHardwareConfig->HasFastVertexTextures() ) + if ( !g_pHardwareConfig->SupportsShaderModel_3_0() ) #endif { bool bUseStaticControlFlow = g_pHardwareConfig->SupportsStaticControlFlow(); - DECLARE_DYNAMIC_VERTEX_SHADER( skin_vs20 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_skin_vs20 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogIndex ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, numBones > 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( LIGHTING_PREVIEW, pShaderAPI->GetIntRenderingParameter(INT_RENDERPARM_ENABLE_FIXED_LIGHTING)!=0); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); SET_DYNAMIC_VERTEX_SHADER_COMBO( NUM_LIGHTS, bUseStaticControlFlow ? 0 : lightState.m_nNumLights ); - SET_DYNAMIC_VERTEX_SHADER( skin_vs20 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_skin_vs20 ); - DECLARE_DYNAMIC_PIXEL_SHADER( skin_ps20b ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_skin_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( NUM_LIGHTS, lightState.m_nNumLights ); SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITEWATERFOGTODESTALPHA, bWriteWaterFogToAlpha ); SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, bWriteDepthToAlpha ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, bFlashlightShadows ); - SET_DYNAMIC_PIXEL_SHADER( skin_ps20b ); + SET_DYNAMIC_PIXEL_SHADER( sdk_skin_ps20b ); } #ifndef _X360 else { - pShader->SetHWMorphVertexShaderState( VERTEX_SHADER_SHADER_SPECIFIC_CONST_6, VERTEX_SHADER_SHADER_SPECIFIC_CONST_7, SHADER_VERTEXTEXTURE_SAMPLER0 ); + const bool bFastVertexTextures = g_pHardwareConfig->HasFastVertexTextures(); - DECLARE_DYNAMIC_VERTEX_SHADER( skin_vs30 ); + if ( bFastVertexTextures ) + pShader->SetHWMorphVertexShaderState( VERTEX_SHADER_SHADER_SPECIFIC_CONST_6, VERTEX_SHADER_SHADER_SPECIFIC_CONST_7, SHADER_VERTEXTEXTURE_SAMPLER0 ); + + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_skin_vs30 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogIndex ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, numBones > 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( LIGHTING_PREVIEW, pShaderAPI->GetIntRenderingParameter(INT_RENDERPARM_ENABLE_FIXED_LIGHTING)!=0); SET_DYNAMIC_VERTEX_SHADER_COMBO( MORPHING, pShaderAPI->IsHWMorphingEnabled() ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); - SET_DYNAMIC_VERTEX_SHADER( skin_vs30 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_skin_vs30 ); - DECLARE_DYNAMIC_PIXEL_SHADER( skin_ps30 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_skin_ps30 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( NUM_LIGHTS, lightState.m_nNumLights ); SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITEWATERFOGTODESTALPHA, bWriteWaterFogToAlpha ); SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, bWriteDepthToAlpha ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, bFlashlightShadows ); - SET_DYNAMIC_PIXEL_SHADER( skin_ps30 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_skin_ps30 ); - bool bUnusedTexCoords[3] = { false, false, !pShaderAPI->IsHWMorphingEnabled() || !bIsDecal }; - pShaderAPI->MarkUnusedVertexFields( 0, 3, bUnusedTexCoords ); + if ( bFastVertexTextures ) + { + bool bUnusedTexCoords[3] = { false, false, !pShaderAPI->IsHWMorphingEnabled() || !bIsDecal }; + pShaderAPI->MarkUnusedVertexFields( 0, 3, bUnusedTexCoords ); + } } #endif @@ -731,7 +759,10 @@ void DrawSkin_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShad bool bHasBaseAlphaPhongMask = (info.m_nBaseMapAlphaPhongMask != -1) && ( params[info.m_nBaseMapAlphaPhongMask]->GetIntValue() != 0 ); float fHasBaseAlphaPhongMask = bHasBaseAlphaPhongMask ? 1 : 0; // Controls for lerp-style paths through shader code - float vShaderControls[4] = { fHasBaseAlphaPhongMask, 0.0f/*unused*/, flTintReplacementAmount, fInvertPhongMask }; + + const float flMinLighting = pShaderAPI->GetFloatRenderingParameter( FLOAT_RENDERPARM_MINIMUMLIGHTING ); + + float vShaderControls[4] = { fHasBaseAlphaPhongMask, flMinLighting, flTintReplacementAmount, fInvertPhongMask }; pShaderAPI->SetPixelShaderConstant( PSREG_CONSTANT_27, vShaderControls, 1 ); if ( hasDetailTexture ) @@ -956,14 +987,15 @@ void DrawSkin_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShad //----------------------------------------------------------------------------- // Draws the shader //----------------------------------------------------------------------------- -extern ConVar r_flashlight_version2; void DrawSkin_DX9( CBaseVSShader *pShader, IMaterialVar** params, IShaderDynamicAPI *pShaderAPI, IShaderShadow* pShaderShadow, VertexLitGeneric_DX9_Vars_t &info, VertexCompressionType_t vertexCompression, CBasePerMaterialContextData **pContextDataPtr ) { + ConVarRef r_flashlight_version2 = ConVarRef( "r_flashlight_version2" ); + bool bHasFlashlight = pShader->UsingFlashlight( params ); - if ( bHasFlashlight && ( IsX360() || r_flashlight_version2.GetInt() ) ) + if ( bHasFlashlight && ( IsX360() || r_flashlight_version2.GetBool() ) ) { DrawSkin_DX9_Internal( pShader, params, pShaderAPI, pShaderShadow, false, info, vertexCompression, pContextDataPtr++ ); diff --git a/sp/src/materialsystem/stdshaders/spline_fxc.h b/sp/src/materialsystem/stdshaders/spline_fxc.h new file mode 100644 index 00000000..bc9fb428 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/spline_fxc.h @@ -0,0 +1,19 @@ +//========== Copyright (c) Valve Corporation, All rights reserved. ==========// + +// derivative of catmull rom spline courtesy of calc +float4 DCatmullRomSpline ( float4 a, float4 b, float4 c, float4 d, float t ) +{ + return 0.5 *( c - a + t * ( 2 * a - 5 * b + 4 * c - d + t * (3 * b - a - 3 * c + d ) ) + + t * ( 2 * a - 5 * b + 4 * c - d + 2 * ( t * ( 3 * b - a - 3 * c + d ) ) ) ); +} + +float3 DCatmullRomSpline3 ( float3 a, float3 b, float3 c, float3 d, float t ) +{ + return 0.5 *( c - a + t * ( 2 * a - 5 * b + 4 * c - d + t * (3 * b - a - 3 * c + d ) ) + + t * ( 2 * a - 5 * b + 4 * c - d + 2 * ( t * ( 3 * b - a - 3 * c + d ) ) ) ); +} + +float4 CatmullRomSpline( float4 a, float4 b, float4 c, float4 d, float t ) +{ + return b + 0.5 * t * ( c - a + t * ( 2 * a - 5 * b + 4 * c - d + t * ( -a + 3 * b -3 * c + d ) ) ); +} diff --git a/sp/src/materialsystem/stdshaders/splinerope.cpp b/sp/src/materialsystem/stdshaders/splinerope.cpp new file mode 100644 index 00000000..c7b3853f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/splinerope.cpp @@ -0,0 +1,169 @@ +//===== Copyright © 1996-2008, Valve Corporation, All rights reserved. ======// + +#include "BaseVSShader.h" +#include "convar.h" + +#include "sdk_splinerope_ps20.inc" +#include "sdk_splinerope_ps20b.inc" +#include "sdk_splinerope_vs20.inc" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +static ConVar rope_min_pixel_diameter( "rope_min_pixel_diameter", "2.0", FCVAR_CHEAT ); + +DEFINE_FALLBACK_SHADER( SDK_Cable, SDK_Cable_DX9 ) + +BEGIN_VS_SHADER( SDK_Cable_DX9, "Help for SplineRope" ) + BEGIN_SHADER_PARAMS + SHADER_PARAM( SHADERSRGBREAD360, SHADER_PARAM_TYPE_BOOL, "0", "Simulate srgb read in shader code") + SHADER_PARAM( SHADOWDEPTH, SHADER_PARAM_TYPE_INTEGER, "0", "writing to a shadow depth buffer" ) + SHADER_PARAM( BUMPMAP, SHADER_PARAM_TYPE_TEXTURE, "cable/cablenormalmap", "normal map" ) + END_SHADER_PARAMS + + SHADER_INIT_PARAMS() + { + // srgb read 360 + InitIntParam( SHADERSRGBREAD360, params, 0 ); + InitIntParam( SHADOWDEPTH, params, 0 ); + if ( !params[BUMPMAP]->IsDefined() ) + { + params[BUMPMAP]->SetStringValue( "cable/cablenormalmap" ); + } + SET_FLAGS2( MATERIAL_VAR2_IS_SPRITECARD ); // What's this for? + } + + SHADER_FALLBACK + { + return 0; + } + + SHADER_INIT + { + SET_FLAGS2( MATERIAL_VAR2_LIGHTING_VERTEX_LIT ); + LoadTexture( BASETEXTURE ); + LoadBumpMap( BUMPMAP ); + } + + SHADER_DRAW + { + bool bShaderSrgbRead = ( IsX360() && params[SHADERSRGBREAD360]->GetIntValue() ); + bool bShadowDepth = ( params[SHADOWDEPTH]->GetIntValue() != 0 ); + SHADOW_STATE + { + // draw back-facing because of yaw spin + pShaderShadow->EnableCulling( false ); + + if ( bShadowDepth ) + { + // don't write color and alpha since we only interested in depth for shadow maps. + pShaderShadow->EnableColorWrites( false ); + pShaderShadow->EnableAlphaWrites( false ); + + // polyoffset for shadow maps. + pShaderShadow->EnablePolyOffset( SHADER_POLYOFFSET_SHADOW_BIAS ); + } + else + { + // We need to write to dest alpha for depth feathering. + pShaderShadow->EnableAlphaWrites( true ); + + // base texture + pShaderShadow->EnableTexture( SHADER_SAMPLER0, true ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, !bShaderSrgbRead ); + + // normal map + pShaderShadow->EnableTexture( SHADER_SAMPLER1, true ); + + pShaderShadow->EnableSRGBWrite( true ); + + FogToFogColor(); + } + + static int s_TexCoordSize[]={ 4, // (worldspace xyz) (radius (diameter?) of spline at this point) for first control point + 4, // (worldspace xyz) (radius of spline at this point) for second control point + 4, // (worldspace xyz) (radius of spline at this point) for third control point + 4, // (worldspace xyz) (radius of spline at this point) for fourth control point + }; + + unsigned int flags = VERTEX_POSITION | VERTEX_COLOR; + + int numTexCoords = 4; + pShaderShadow->VertexShaderVertexFormat( flags, numTexCoords, s_TexCoordSize, 0 ); + + DECLARE_STATIC_VERTEX_SHADER( sdk_splinerope_vs20 ); + SET_STATIC_VERTEX_SHADER( sdk_splinerope_vs20 ); + + if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + DECLARE_STATIC_PIXEL_SHADER( sdk_splinerope_ps20b ); + SET_STATIC_PIXEL_SHADER_COMBO( SHADER_SRGB_READ, bShaderSrgbRead ); + SET_STATIC_PIXEL_SHADER_COMBO( SHADOWDEPTH, bShadowDepth ); + SET_STATIC_PIXEL_SHADER( sdk_splinerope_ps20b ); + } + else + { + DECLARE_STATIC_PIXEL_SHADER( sdk_splinerope_ps20 ); + SET_STATIC_PIXEL_SHADER_COMBO( SHADER_SRGB_READ, bShaderSrgbRead ); + SET_STATIC_PIXEL_SHADER_COMBO( SHADOWDEPTH, bShadowDepth ); + SET_STATIC_PIXEL_SHADER( sdk_splinerope_ps20 ); + } + } + DYNAMIC_STATE + { + // We need these only when screen-orienting, which we are always in this shader. + LoadModelViewMatrixIntoVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0 ); + LoadProjectionMatrixIntoVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_3 ); + + // Get viewport and render target dimensions and set shader constant to do a 2D mad + ShaderViewport_t viewport; + pShaderAPI->GetViewports( &viewport, 1 ); + + float c7[4]={ 0.0f, 0.0f, 0.0f, 0.0f }; + if ( !g_pHardwareConfig->IsAAEnabled() ) + { + float flMinPixelDiameter = rope_min_pixel_diameter.GetFloat() / ( float )viewport.m_nWidth; + c7[0]= c7[1] = c7[2] = c7[3] = flMinPixelDiameter; + } + pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_7, c7, 1 ); + + // bind base texture + BindTexture( SHADER_SAMPLER0, BASETEXTURE, FRAME ); + + // normal map + BindTexture( SHADER_SAMPLER1, BUMPMAP ); + + if ( !bShadowDepth ) + { + pShaderAPI->SetPixelShaderFogParams( 0 ); + + float vEyePos[4]; + pShaderAPI->GetWorldSpaceCameraPosition( vEyePos ); + vEyePos[3] = 0.0f; + pShaderAPI->SetPixelShaderConstant( 1, vEyePos, 1 ); + } + + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_splinerope_vs20 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); + SET_DYNAMIC_VERTEX_SHADER( sdk_splinerope_vs20 ); + + if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_splinerope_ps20b ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, pShaderAPI->ShouldWriteDepthToDestAlpha() ); + //SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); + SET_DYNAMIC_PIXEL_SHADER( sdk_splinerope_ps20b ); + } + else + { + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_splinerope_ps20 ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, 0 ); + //SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); + SET_DYNAMIC_PIXEL_SHADER( sdk_splinerope_ps20 ); + } + } + Draw( ); + } +END_SHADER diff --git a/sp/src/materialsystem/stdshaders/sprite_dx9.cpp b/sp/src/materialsystem/stdshaders/sprite_dx9.cpp index 0a0bb9f4..087594b3 100644 --- a/sp/src/materialsystem/stdshaders/sprite_dx9.cpp +++ b/sp/src/materialsystem/stdshaders/sprite_dx9.cpp @@ -15,9 +15,9 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" -#include "sprite_vs20.inc" -#include "sprite_ps20.inc" -#include "sprite_ps20b.inc" +#include "sdk_sprite_vs20.inc" +#include "sdk_sprite_ps20.inc" +#include "sdk_sprite_ps20b.inc" // WARNING! Change these in engine/SpriteGn.h if you change them here! #define SPR_VP_PARALLEL_UPRIGHT 0 @@ -27,9 +27,9 @@ #define SPR_VP_PARALLEL_ORIENTED 4 -DEFINE_FALLBACK_SHADER( Sprite, Sprite_DX9 ) +DEFINE_FALLBACK_SHADER( SDK_Sprite, SDK_Sprite_DX9 ) -BEGIN_VS_SHADER( Sprite_DX9, +BEGIN_VS_SHADER( SDK_Sprite_DX9, "Help for Sprite_DX9" ) BEGIN_SHADER_PARAMS @@ -134,29 +134,29 @@ BEGIN_VS_SHADER( Sprite_DX9, int numTexCoords = 1; s_pShaderShadow->VertexShaderVertexFormat( flags, numTexCoords, 0, 0 ); - DECLARE_STATIC_VERTEX_SHADER( sprite_vs20 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_sprite_vs20 ); SET_STATIC_VERTEX_SHADER_COMBO( VERTEXCOLOR, ( shaderFlags & SHADER_USE_VERTEX_COLOR ) ? true : false ); SET_STATIC_VERTEX_SHADER_COMBO( SRGB, bSRGB ); - SET_STATIC_VERTEX_SHADER( sprite_vs20 ); + SET_STATIC_VERTEX_SHADER( sdk_sprite_vs20 ); if( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() ) // Always send GL down this path { - DECLARE_STATIC_PIXEL_SHADER( sprite_ps20b ); + DECLARE_STATIC_PIXEL_SHADER( sdk_sprite_ps20b ); SET_STATIC_PIXEL_SHADER_COMBO( VERTEXCOLOR, ( shaderFlags & SHADER_USE_VERTEX_COLOR ) ? true : false ); SET_STATIC_PIXEL_SHADER_COMBO( CONSTANTCOLOR, ( shaderFlags & SHADER_USE_CONSTANT_COLOR ) ? true : false ); SET_STATIC_PIXEL_SHADER_COMBO( HDRTYPE, g_pHardwareConfig->GetHDRType() ); SET_STATIC_PIXEL_SHADER_COMBO( SRGB, bSRGB ); SET_STATIC_PIXEL_SHADER_COMBO( SRGB_OUTPUT_ADAPTER, bSRGBOutputAdapter ); - SET_STATIC_PIXEL_SHADER( sprite_ps20b ); + SET_STATIC_PIXEL_SHADER( sdk_sprite_ps20b ); } else { - DECLARE_STATIC_PIXEL_SHADER( sprite_ps20 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_sprite_ps20 ); SET_STATIC_PIXEL_SHADER_COMBO( VERTEXCOLOR, ( shaderFlags & SHADER_USE_VERTEX_COLOR ) ? true : false ); SET_STATIC_PIXEL_SHADER_COMBO( CONSTANTCOLOR, ( shaderFlags & SHADER_USE_CONSTANT_COLOR ) ? true : false ); SET_STATIC_PIXEL_SHADER_COMBO( HDRTYPE, g_pHardwareConfig->GetHDRType() ); SET_STATIC_PIXEL_SHADER_COMBO( SRGB, bSRGB ); - SET_STATIC_PIXEL_SHADER( sprite_ps20 ); + SET_STATIC_PIXEL_SHADER( sdk_sprite_ps20 ); } // OSX always has to sRGB write (don't do this on Linux/Win GL - it causes glow sprites to be way too dark) @@ -172,23 +172,23 @@ BEGIN_VS_SHADER( Sprite_DX9, MaterialFogMode_t fogType = s_pShaderAPI->GetSceneFogMode(); int fogIndex = ( fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ) ? 1 : 0; - DECLARE_DYNAMIC_VERTEX_SHADER( sprite_vs20 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_sprite_vs20 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogIndex ); - SET_DYNAMIC_VERTEX_SHADER( sprite_vs20 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_sprite_vs20 ); if( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() ) // Always send GL down this path { - DECLARE_DYNAMIC_PIXEL_SHADER( sprite_ps20b ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_sprite_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( HDRENABLED, IsHDREnabled() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - SET_DYNAMIC_PIXEL_SHADER( sprite_ps20b ); + SET_DYNAMIC_PIXEL_SHADER( sdk_sprite_ps20b ); } else { - DECLARE_DYNAMIC_PIXEL_SHADER( sprite_ps20 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_sprite_ps20 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( HDRENABLED, IsHDREnabled() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - SET_DYNAMIC_PIXEL_SHADER( sprite_ps20 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_sprite_ps20 ); } pShaderAPI->SetPixelShaderFogParams( PSREG_FOG_PARAMS ); @@ -380,23 +380,23 @@ BEGIN_VS_SHADER( Sprite_DX9, MaterialFogMode_t fogType = s_pShaderAPI->GetSceneFogMode(); int fogIndex = ( fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ) ? 1 : 0; - DECLARE_DYNAMIC_VERTEX_SHADER( sprite_vs20 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_sprite_vs20 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogIndex ); - SET_DYNAMIC_VERTEX_SHADER( sprite_vs20 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_sprite_vs20 ); if( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() ) // Always send GL down this path { - DECLARE_DYNAMIC_PIXEL_SHADER( sprite_ps20b ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_sprite_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( HDRENABLED, IsHDREnabled() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - SET_DYNAMIC_PIXEL_SHADER( sprite_ps20b ); + SET_DYNAMIC_PIXEL_SHADER( sdk_sprite_ps20b ); } else { - DECLARE_DYNAMIC_PIXEL_SHADER( sprite_ps20 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_sprite_ps20 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( HDRENABLED, IsHDREnabled() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - SET_DYNAMIC_PIXEL_SHADER( sprite_ps20 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_sprite_ps20 ); } pShaderAPI->SetPixelShaderFogParams( PSREG_FOG_PARAMS ); @@ -437,23 +437,23 @@ BEGIN_VS_SHADER( Sprite_DX9, MaterialFogMode_t fogType = s_pShaderAPI->GetSceneFogMode(); int fogIndex = ( fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ) ? 1 : 0; - DECLARE_DYNAMIC_VERTEX_SHADER( sprite_vs20 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_sprite_vs20 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogIndex ); - SET_DYNAMIC_VERTEX_SHADER( sprite_vs20 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_sprite_vs20 ); if( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() ) // Always send GL down this path { - DECLARE_DYNAMIC_PIXEL_SHADER( sprite_ps20b ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_sprite_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( HDRENABLED, IsHDREnabled() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - SET_DYNAMIC_PIXEL_SHADER( sprite_ps20b ); + SET_DYNAMIC_PIXEL_SHADER( sdk_sprite_ps20b ); } else { - DECLARE_DYNAMIC_PIXEL_SHADER( sprite_ps20 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_sprite_ps20 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( HDRENABLED, IsHDREnabled() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - SET_DYNAMIC_PIXEL_SHADER( sprite_ps20 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_sprite_ps20 ); } pShaderAPI->SetPixelShaderFogParams( PSREG_FOG_PARAMS ); diff --git a/sp/src/materialsystem/stdshaders/stdshader_dx9_20b.txt b/sp/src/materialsystem/stdshaders/stdshader_dx9_20b.txt index a24577ec..6647a4ad 100644 --- a/sp/src/materialsystem/stdshaders/stdshader_dx9_20b.txt +++ b/sp/src/materialsystem/stdshaders/stdshader_dx9_20b.txt @@ -7,10 +7,83 @@ // _vs20.vcs // -example_model_ps20b.fxc -example_model_vs20.fxc +//example_model_ps20b.fxc +//example_model_vs20.fxc SDK_Bloom_ps2x.fxc SDK_screenspaceeffect_vs20.fxc SDK_bloomadd_ps2x.fxc + +SDK_skin_ps20b.fxc +SDK_skin_vs20.fxc +SDK_vertexlit_and_unlit_generic_bump_ps2x.fxc +SDK_vertexlit_and_unlit_generic_bump_ps20b.fxc +SDK_vertexlit_and_unlit_generic_bump_vs20.fxc +SDK_vertexlit_and_unlit_generic_ps2x.fxc +SDK_vertexlit_and_unlit_generic_ps20b.fxc +SDK_vertexlit_and_unlit_generic_vs20.fxc + +SDK_cloak_blended_pass_ps2x.fxc +SDK_cloak_blended_pass_vs20.fxc +SDK_emissive_scroll_blended_pass_ps2x.fxc +SDK_emissive_scroll_blended_pass_vs20.fxc +SDK_flesh_interior_blended_pass_ps2x.fxc +SDK_flesh_interior_blended_pass_vs20.fxc + +SDK_flashlight_ps2x.fxc +SDK_flashlight_ps11.fxc +SDK_lightmappedgeneric_decal_ps2x.fxc +SDK_lightmappedgeneric_decal_vs20.fxc +SDK_lightmappedgeneric_flashlight_vs11.fxc +SDK_lightmappedgeneric_flashlight_vs20.fxc +SDK_lightmappedgeneric_flashlight_ps2x.fxc +SDK_lightmappedgeneric_lightingonly_overbright2_ps11.fxc +SDK_lightmappedgeneric_lightingonly_vs11.fxc +SDK_lightmappedgeneric_ps20b.fxc +SDK_lightmappedgeneric_ps11.fxc +SDK_lightmappedgeneric_vs20.fxc +SDK_lightmappedreflective_ps2x.fxc +SDK_lightmappedreflective_vs20.fxc +SDK_unlitgeneric_ps2x.fxc +SDK_unlitgeneric_ps11.fxc +SDK_unlitgeneric_vs20.fxc +SDK_vertexlit_lighting_only_ps2x.fxc +SDK_vertexlitgeneric_lightingonly_overbright2_ps11.fxc + +SDK_worldtwotextureblend_ps2x.fxc +SDK_WorldVertexTransition_ps2x.fxc +SDK_WorldVertexTransition_vs20.fxc +SDK_refract_ps2x.fxc +SDK_Refract_vs20.fxc +SDK_Water_ps2x.fxc +SDK_Water_vs20.fxc +SDK_WaterCheap_ps2x.fxc +SDK_WaterCheap_vs20.fxc +SDK_depthwrite_ps2x.fxc +SDK_depthwrite_vs20.fxc +//SDK_cable_ps2x.fxc +//SDK_cable_vs20.fxc +SDK_splinerope_ps2x.fxc +SDK_splinerope_vs20.fxc + +SDK_eye_refract_ps2x.fxc +SDK_eye_refract_vs20.fxc +SDK_eyes_flashlight_vs20.fxc +SDK_eyes_flashlight_ps2x.fxc +SDK_eyes_ps2x.fxc +SDK_eyes_vs20.fxc +SDK_eyeglint_ps2x.fxc +SDK_eyeglint_vs20.fxc +SDK_teeth_ps2x.fxc +SDK_teeth_vs20.fxc +SDK_teeth_bump_ps2x.fxc +SDK_teeth_bump_vs20.fxc +SDK_teeth_flashlight_ps2x.fxc +SDK_teeth_flashlight_vs20.fxc + +SDK_sprite_ps2x.fxc +SDK_sprite_vs20.fxc + +SDK_decalmodulate_ps2x.fxc +SDK_decalmodulate_vs20.fxc \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/stdshader_dx9_30.txt b/sp/src/materialsystem/stdshaders/stdshader_dx9_30.txt index 071b6a1a..d8153f86 100644 --- a/sp/src/materialsystem/stdshaders/stdshader_dx9_30.txt +++ b/sp/src/materialsystem/stdshaders/stdshader_dx9_30.txt @@ -7,4 +7,40 @@ // _vs30.vcs // -// There are no examples of such shaders in the SDK, but add yours here. +SDK_skin_ps20b.fxc +SDK_skin_vs20.fxc +SDK_vertexlit_and_unlit_generic_bump_ps20b.fxc +SDK_vertexlit_and_unlit_generic_bump_vs20.fxc +SDK_vertexlit_and_unlit_generic_ps20b.fxc +SDK_vertexlit_and_unlit_generic_vs20.fxc + +SDK_cloak_blended_pass_ps2x.fxc +SDK_cloak_blended_pass_vs20.fxc +SDK_emissive_scroll_blended_pass_ps2x.fxc +SDK_emissive_scroll_blended_pass_vs20.fxc + +SDK_flashlight_ps2x.fxc +SDK_lightmappedgeneric_flashlight_vs20.fxc +SDK_lightmappedgeneric_flashlight_ps2x.fxc +SDK_lightmappedgeneric_ps20b.fxc +SDK_lightmappedgeneric_vs20.fxc + +SDK_depthwrite_ps2x.fxc +SDK_depthwrite_vs20.fxc + +SDK_eyes_ps2x.fxc +SDK_eyes_vs20.fxc +SDK_eye_refract_ps2x.fxc +SDK_eye_refract_vs20.fxc +SDK_eyes_flashlight_ps2x.fxc +SDK_eyes_flashlight_vs20.fxc + +SDK_teeth_ps2x.fxc +SDK_teeth_vs20.fxc +SDK_teeth_bump_ps2x.fxc +SDK_teeth_bump_vs20.fxc +SDK_teeth_flashlight_ps2x.fxc +SDK_teeth_flashlight_vs20.fxc + +SDK_decalmodulate_ps2x.fxc +SDK_decalmodulate_vs20.fxc \ No newline at end of file diff --git a/sp/src/materialsystem/stdshaders/teeth.cpp b/sp/src/materialsystem/stdshaders/teeth.cpp index a3168822..3004b9f7 100644 --- a/sp/src/materialsystem/stdshaders/teeth.cpp +++ b/sp/src/materialsystem/stdshaders/teeth.cpp @@ -7,32 +7,32 @@ #include "BaseVSShader.h" #include "cpp_shader_constant_register_map.h" -#include "teeth_vs20.inc" -#include "teeth_flashlight_vs20.inc" -#include "teeth_bump_vs20.inc" -#include "teeth_ps20.inc" -#include "teeth_ps20b.inc" -#include "teeth_flashlight_ps20.inc" -#include "teeth_flashlight_ps20b.inc" -#include "teeth_bump_ps20.inc" -#include "teeth_bump_ps20b.inc" +#include "sdk_teeth_vs20.inc" +#include "sdk_teeth_flashlight_vs20.inc" +#include "sdk_teeth_bump_vs20.inc" +#include "sdk_teeth_ps20.inc" +#include "sdk_teeth_ps20b.inc" +#include "sdk_teeth_flashlight_ps20.inc" +#include "sdk_teeth_flashlight_ps20b.inc" +#include "sdk_teeth_bump_ps20.inc" +#include "sdk_teeth_bump_ps20b.inc" #ifndef _X360 -#include "teeth_vs30.inc" -#include "teeth_ps30.inc" -#include "teeth_bump_vs30.inc" -#include "teeth_bump_ps30.inc" -#include "teeth_flashlight_vs30.inc" -#include "teeth_flashlight_ps30.inc" +#include "sdk_teeth_vs30.inc" +#include "sdk_teeth_ps30.inc" +#include "sdk_teeth_bump_vs30.inc" +#include "sdk_teeth_bump_ps30.inc" +#include "sdk_teeth_flashlight_vs30.inc" +#include "sdk_teeth_flashlight_ps30.inc" #endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" -DEFINE_FALLBACK_SHADER( Teeth, Teeth_DX9 ) +DEFINE_FALLBACK_SHADER( SDK_Teeth, SDK_Teeth_DX9 ) extern ConVar r_flashlight_version2; -BEGIN_VS_SHADER( Teeth_DX9, "Help for Teeth_DX9" ) +BEGIN_VS_SHADER( SDK_Teeth_DX9, "Help for SDK_Teeth_DX9" ) BEGIN_SHADER_PARAMS SHADER_PARAM( ILLUMFACTOR, SHADER_PARAM_TYPE_FLOAT, "1", "Amount to darken or brighten the teeth" ) @@ -119,21 +119,21 @@ BEGIN_VS_SHADER( Teeth_DX9, "Help for Teeth_DX9" ) { bool bUseStaticControlFlow = g_pHardwareConfig->SupportsStaticControlFlow(); - DECLARE_STATIC_VERTEX_SHADER( teeth_bump_vs20 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_teeth_bump_vs20 ); SET_STATIC_VERTEX_SHADER_COMBO( INTRO, params[INTRO]->GetIntValue() ? 1 : 0 ); SET_STATIC_VERTEX_SHADER_COMBO( USE_STATIC_CONTROL_FLOW, bUseStaticControlFlow ); - SET_STATIC_VERTEX_SHADER( teeth_bump_vs20 ); + SET_STATIC_VERTEX_SHADER( sdk_teeth_bump_vs20 ); // ps_2_b version which does phong if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_STATIC_PIXEL_SHADER( teeth_bump_ps20b ); - SET_STATIC_PIXEL_SHADER( teeth_bump_ps20b ); + DECLARE_STATIC_PIXEL_SHADER( sdk_teeth_bump_ps20b ); + SET_STATIC_PIXEL_SHADER( sdk_teeth_bump_ps20b ); } else { - DECLARE_STATIC_PIXEL_SHADER( teeth_bump_ps20 ); - SET_STATIC_PIXEL_SHADER( teeth_bump_ps20 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_teeth_bump_ps20 ); + SET_STATIC_PIXEL_SHADER( sdk_teeth_bump_ps20 ); } } #ifndef _X360 @@ -142,12 +142,12 @@ BEGIN_VS_SHADER( Teeth_DX9, "Help for Teeth_DX9" ) // The vertex shader uses the vertex id stream SET_FLAGS2( MATERIAL_VAR2_USES_VERTEXID ); - DECLARE_STATIC_VERTEX_SHADER( teeth_bump_vs30 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_teeth_bump_vs30 ); SET_STATIC_VERTEX_SHADER_COMBO( INTRO, params[INTRO]->GetIntValue() ? 1 : 0 ); - SET_STATIC_VERTEX_SHADER( teeth_bump_vs30 ); + SET_STATIC_VERTEX_SHADER( sdk_teeth_bump_vs30 ); - DECLARE_STATIC_PIXEL_SHADER( teeth_bump_ps30 ); - SET_STATIC_PIXEL_SHADER( teeth_bump_ps30 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_teeth_bump_ps30 ); + SET_STATIC_PIXEL_SHADER( sdk_teeth_bump_ps30 ); } #endif } @@ -159,20 +159,20 @@ BEGIN_VS_SHADER( Teeth_DX9, "Help for Teeth_DX9" ) { bool bUseStaticControlFlow = g_pHardwareConfig->SupportsStaticControlFlow(); - DECLARE_STATIC_VERTEX_SHADER( teeth_vs20 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_teeth_vs20 ); SET_STATIC_VERTEX_SHADER_COMBO( INTRO, params[INTRO]->GetIntValue() ? 1 : 0 ); SET_STATIC_VERTEX_SHADER_COMBO( USE_STATIC_CONTROL_FLOW, bUseStaticControlFlow ); - SET_STATIC_VERTEX_SHADER( teeth_vs20 ); + SET_STATIC_VERTEX_SHADER( sdk_teeth_vs20 ); if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_STATIC_PIXEL_SHADER( teeth_ps20b ); - SET_STATIC_PIXEL_SHADER( teeth_ps20b ); + DECLARE_STATIC_PIXEL_SHADER( sdk_teeth_ps20b ); + SET_STATIC_PIXEL_SHADER( sdk_teeth_ps20b ); } else { - DECLARE_STATIC_PIXEL_SHADER( teeth_ps20 ); - SET_STATIC_PIXEL_SHADER( teeth_ps20 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_teeth_ps20 ); + SET_STATIC_PIXEL_SHADER( sdk_teeth_ps20 ); } } #ifndef _X360 @@ -181,12 +181,12 @@ BEGIN_VS_SHADER( Teeth_DX9, "Help for Teeth_DX9" ) // The vertex shader uses the vertex id stream SET_FLAGS2( MATERIAL_VAR2_USES_VERTEXID ); - DECLARE_STATIC_VERTEX_SHADER( teeth_vs30 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_teeth_vs30 ); SET_STATIC_VERTEX_SHADER_COMBO( INTRO, params[INTRO]->GetIntValue() ? 1 : 0 ); - SET_STATIC_VERTEX_SHADER( teeth_vs30 ); + SET_STATIC_VERTEX_SHADER( sdk_teeth_vs30 ); - DECLARE_STATIC_PIXEL_SHADER( teeth_ps30 ); - SET_STATIC_PIXEL_SHADER( teeth_ps30 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_teeth_ps30 ); + SET_STATIC_PIXEL_SHADER( sdk_teeth_ps30 ); } #endif } @@ -233,13 +233,13 @@ BEGIN_VS_SHADER( Teeth_DX9, "Help for Teeth_DX9" ) { bool bUseStaticControlFlow = g_pHardwareConfig->SupportsStaticControlFlow(); - DECLARE_DYNAMIC_VERTEX_SHADER( teeth_bump_vs20 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_teeth_bump_vs20 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( STATIC_LIGHT, lightState.m_bStaticLight ? 1 : 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); SET_DYNAMIC_VERTEX_SHADER_COMBO( NUM_LIGHTS, bUseStaticControlFlow ? 0 : lightState.m_nNumLights ); - SET_DYNAMIC_VERTEX_SHADER( teeth_bump_vs20 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_teeth_bump_vs20 ); // ps_2_b version which does Phong if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) @@ -249,20 +249,20 @@ BEGIN_VS_SHADER( Teeth_DX9, "Help for Teeth_DX9" ) pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, vSpecExponent.Base(), 1 ); - DECLARE_DYNAMIC_PIXEL_SHADER( teeth_bump_ps20b ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_teeth_bump_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( NUM_LIGHTS, lightState.m_nNumLights ); SET_DYNAMIC_PIXEL_SHADER_COMBO( AMBIENT_LIGHT, lightState.m_bAmbientLight ? 1 : 0 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, bFullyOpaque && pShaderAPI->ShouldWriteDepthToDestAlpha() ); - SET_DYNAMIC_PIXEL_SHADER( teeth_bump_ps20b ); + SET_DYNAMIC_PIXEL_SHADER( sdk_teeth_bump_ps20b ); } else { - DECLARE_DYNAMIC_PIXEL_SHADER( teeth_bump_ps20 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_teeth_bump_ps20 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( NUM_LIGHTS, lightState.m_nNumLights ); SET_DYNAMIC_PIXEL_SHADER_COMBO( AMBIENT_LIGHT, lightState.m_bAmbientLight ? 1 : 0 ); - SET_DYNAMIC_PIXEL_SHADER( teeth_bump_ps20 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_teeth_bump_ps20 ); } } #ifndef _X360 @@ -270,24 +270,24 @@ BEGIN_VS_SHADER( Teeth_DX9, "Help for Teeth_DX9" ) { SetHWMorphVertexShaderState( VERTEX_SHADER_SHADER_SPECIFIC_CONST_6, VERTEX_SHADER_SHADER_SPECIFIC_CONST_7, SHADER_VERTEXTEXTURE_SAMPLER0 ); - DECLARE_DYNAMIC_VERTEX_SHADER( teeth_bump_vs30 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_teeth_bump_vs30 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( STATIC_LIGHT, lightState.m_bStaticLight ? 1 : 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( MORPHING, pShaderAPI->IsHWMorphingEnabled() ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); - SET_DYNAMIC_VERTEX_SHADER( teeth_bump_vs30 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_teeth_bump_vs30 ); Vector4D vSpecExponent; vSpecExponent[3] = params[PHONGEXPONENT]->GetFloatValue(); pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, vSpecExponent.Base(), 1 ); - DECLARE_DYNAMIC_PIXEL_SHADER( teeth_bump_ps30 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_teeth_bump_ps30 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( NUM_LIGHTS, lightState.m_nNumLights ); SET_DYNAMIC_PIXEL_SHADER_COMBO( AMBIENT_LIGHT, lightState.m_bAmbientLight ? 1 : 0 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, bFullyOpaque && pShaderAPI->ShouldWriteDepthToDestAlpha() ); - SET_DYNAMIC_PIXEL_SHADER( teeth_bump_ps30 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_teeth_bump_ps30 ); } #endif } @@ -302,27 +302,27 @@ BEGIN_VS_SHADER( Teeth_DX9, "Help for Teeth_DX9" ) { bool bUseStaticControlFlow = g_pHardwareConfig->SupportsStaticControlFlow(); - DECLARE_DYNAMIC_VERTEX_SHADER( teeth_vs20 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_teeth_vs20 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DYNAMIC_LIGHT, lightState.HasDynamicLight() ); SET_DYNAMIC_VERTEX_SHADER_COMBO( STATIC_LIGHT, lightState.m_bStaticLight ? 1 : 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); SET_DYNAMIC_VERTEX_SHADER_COMBO( NUM_LIGHTS, bUseStaticControlFlow ? 0 : lightState.m_nNumLights ); - SET_DYNAMIC_VERTEX_SHADER( teeth_vs20 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_teeth_vs20 ); if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_DYNAMIC_PIXEL_SHADER( teeth_ps20b ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_teeth_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, bFullyOpaque && pShaderAPI->ShouldWriteDepthToDestAlpha() ); - SET_DYNAMIC_PIXEL_SHADER( teeth_ps20b ); + SET_DYNAMIC_PIXEL_SHADER( sdk_teeth_ps20b ); } else { - DECLARE_DYNAMIC_PIXEL_SHADER( teeth_ps20 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_teeth_ps20 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - SET_DYNAMIC_PIXEL_SHADER( teeth_ps20 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_teeth_ps20 ); } } #ifndef _X360 @@ -330,19 +330,19 @@ BEGIN_VS_SHADER( Teeth_DX9, "Help for Teeth_DX9" ) { SetHWMorphVertexShaderState( VERTEX_SHADER_SHADER_SPECIFIC_CONST_6, VERTEX_SHADER_SHADER_SPECIFIC_CONST_7, SHADER_VERTEXTEXTURE_SAMPLER0 ); - DECLARE_DYNAMIC_VERTEX_SHADER( teeth_vs30 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_teeth_vs30 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DYNAMIC_LIGHT, lightState.HasDynamicLight() ); SET_DYNAMIC_VERTEX_SHADER_COMBO( STATIC_LIGHT, lightState.m_bStaticLight ? 1 : 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( MORPHING, pShaderAPI->IsHWMorphingEnabled() ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); - SET_DYNAMIC_VERTEX_SHADER( teeth_vs30 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_teeth_vs30 ); - DECLARE_DYNAMIC_PIXEL_SHADER( teeth_ps30 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_teeth_ps30 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, bFullyOpaque && pShaderAPI->ShouldWriteDepthToDestAlpha() ); - SET_DYNAMIC_PIXEL_SHADER( teeth_ps30 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_teeth_ps30 ); } #endif } @@ -396,20 +396,20 @@ BEGIN_VS_SHADER( Teeth_DX9, "Help for Teeth_DX9" ) if ( !g_pHardwareConfig->HasFastVertexTextures() ) #endif { - DECLARE_STATIC_VERTEX_SHADER( teeth_flashlight_vs20 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_teeth_flashlight_vs20 ); SET_STATIC_VERTEX_SHADER_COMBO( INTRO, params[INTRO]->GetIntValue() ? 1 : 0 ); - SET_STATIC_VERTEX_SHADER( teeth_flashlight_vs20 ); + SET_STATIC_VERTEX_SHADER( sdk_teeth_flashlight_vs20 ); if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_STATIC_PIXEL_SHADER( teeth_flashlight_ps20b ); + DECLARE_STATIC_PIXEL_SHADER( sdk_teeth_flashlight_ps20b ); SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, nShadowFilterMode ); - SET_STATIC_PIXEL_SHADER( teeth_flashlight_ps20b ); + SET_STATIC_PIXEL_SHADER( sdk_teeth_flashlight_ps20b ); } else { - DECLARE_STATIC_PIXEL_SHADER( teeth_flashlight_ps20 ); - SET_STATIC_PIXEL_SHADER( teeth_flashlight_ps20 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_teeth_flashlight_ps20 ); + SET_STATIC_PIXEL_SHADER( sdk_teeth_flashlight_ps20 ); } } #ifndef _X360 @@ -418,13 +418,13 @@ BEGIN_VS_SHADER( Teeth_DX9, "Help for Teeth_DX9" ) // The vertex shader uses the vertex id stream SET_FLAGS2( MATERIAL_VAR2_USES_VERTEXID ); - DECLARE_STATIC_VERTEX_SHADER( teeth_flashlight_vs30 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_teeth_flashlight_vs30 ); SET_STATIC_VERTEX_SHADER_COMBO( INTRO, params[INTRO]->GetIntValue() ? 1 : 0 ); - SET_STATIC_VERTEX_SHADER( teeth_flashlight_vs30 ); + SET_STATIC_VERTEX_SHADER( sdk_teeth_flashlight_vs30 ); - DECLARE_STATIC_PIXEL_SHADER( teeth_flashlight_ps30 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_teeth_flashlight_ps30 ); SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, nShadowFilterMode ); - SET_STATIC_PIXEL_SHADER( teeth_flashlight_ps30 ); + SET_STATIC_PIXEL_SHADER( sdk_teeth_flashlight_ps30 ); } #endif // On DX9, do sRGB @@ -504,24 +504,24 @@ BEGIN_VS_SHADER( Teeth_DX9, "Help for Teeth_DX9" ) if ( !g_pHardwareConfig->HasFastVertexTextures() ) #endif { - DECLARE_DYNAMIC_VERTEX_SHADER( teeth_flashlight_vs20 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_teeth_flashlight_vs20 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); - SET_DYNAMIC_VERTEX_SHADER( teeth_flashlight_vs20 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_teeth_flashlight_vs20 ); if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_DYNAMIC_PIXEL_SHADER( teeth_flashlight_ps20b ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_teeth_flashlight_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, bFlashlightShadows ); - SET_DYNAMIC_PIXEL_SHADER( teeth_flashlight_ps20b ); + SET_DYNAMIC_PIXEL_SHADER( sdk_teeth_flashlight_ps20b ); } else { - DECLARE_DYNAMIC_PIXEL_SHADER( teeth_flashlight_ps20 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_teeth_flashlight_ps20 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - SET_DYNAMIC_PIXEL_SHADER( teeth_flashlight_ps20 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_teeth_flashlight_ps20 ); } } #ifndef _X360 @@ -529,17 +529,17 @@ BEGIN_VS_SHADER( Teeth_DX9, "Help for Teeth_DX9" ) { SetHWMorphVertexShaderState( VERTEX_SHADER_SHADER_SPECIFIC_CONST_6, VERTEX_SHADER_SHADER_SPECIFIC_CONST_7, SHADER_VERTEXTEXTURE_SAMPLER0 ); - DECLARE_DYNAMIC_VERTEX_SHADER( teeth_flashlight_vs30 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_teeth_flashlight_vs30 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( MORPHING, pShaderAPI->IsHWMorphingEnabled() ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); - SET_DYNAMIC_VERTEX_SHADER( teeth_flashlight_vs30 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_teeth_flashlight_vs30 ); - DECLARE_DYNAMIC_PIXEL_SHADER( teeth_flashlight_ps30 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_teeth_flashlight_ps30 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, bFlashlightShadows ); - SET_DYNAMIC_PIXEL_SHADER( teeth_flashlight_ps30 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_teeth_flashlight_ps30 ); } #endif diff --git a/sp/src/materialsystem/stdshaders/unlitgeneric_dx9.cpp b/sp/src/materialsystem/stdshaders/unlitgeneric_dx9.cpp index b57474a8..1043df5c 100644 --- a/sp/src/materialsystem/stdshaders/unlitgeneric_dx9.cpp +++ b/sp/src/materialsystem/stdshaders/unlitgeneric_dx9.cpp @@ -11,7 +11,7 @@ extern ConVar r_flashlight_version2; -BEGIN_VS_SHADER( UnlitGeneric, "Help for UnlitGeneric" ) +BEGIN_VS_SHADER( SDK_UnlitGeneric, "Help for SDK_UnlitGeneric" ) BEGIN_SHADER_PARAMS SHADER_PARAM( ALBEDO, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "albedo (Base texture with no baked lighting)" ) @@ -186,6 +186,8 @@ BEGIN_VS_SHADER( UnlitGeneric, "Help for UnlitGeneric" ) { VertexLitGeneric_DX9_Vars_t vars; SetupVars( vars ); + + ConVarRef r_flashlight_version2 = ConVarRef( "r_flashlight_version2" ); bool bNewFlashlightPath = IsX360() || ( r_flashlight_version2.GetInt() != 0 ); if ( ( pShaderShadow == NULL ) && ( pShaderAPI != NULL ) && !bNewFlashlightPath && pShaderAPI->InFlashlightMode() ) // Not snapshotting && flashlight pass diff --git a/sp/src/materialsystem/stdshaders/vertexlitgeneric_dx9.cpp b/sp/src/materialsystem/stdshaders/vertexlitgeneric_dx9.cpp index 47105813..b732beba 100644 --- a/sp/src/materialsystem/stdshaders/vertexlitgeneric_dx9.cpp +++ b/sp/src/materialsystem/stdshaders/vertexlitgeneric_dx9.cpp @@ -11,10 +11,13 @@ #include "emissive_scroll_blended_pass_helper.h" #include "cloak_blended_pass_helper.h" #include "flesh_interior_blended_pass_helper.h" + +#ifdef GAME_SHADER_DLL #include "weapon_sheen_pass_helper.h" +#endif -BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" ) +BEGIN_VS_SHADER( SDK_VertexLitGeneric, "Help for SDK_VertexLitGeneric" ) BEGIN_SHADER_PARAMS SHADER_PARAM( ALBEDO, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "albedo (Base texture with no baked lighting)" ) SHADER_PARAM( COMPRESS, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "compression wrinklemap" ) @@ -92,6 +95,7 @@ BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" ) SHADER_PARAM( CLOAKCOLORTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "Cloak color tint" ) SHADER_PARAM( REFRACTAMOUNT, SHADER_PARAM_TYPE_FLOAT, "2", "" ) +#ifdef GAME_SHADER_DLL // Weapon Sheen Pass SHADER_PARAM( SHEENPASSENABLED, SHADER_PARAM_TYPE_BOOL, "0", "Enables weapon sheen render in a second pass" ) SHADER_PARAM( SHEENMAP, SHADER_PARAM_TYPE_TEXTURE, "shadertest/shadertest_env", "sheenmap" ) @@ -104,6 +108,7 @@ BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" ) SHADER_PARAM( SHEENMAPMASKOFFSETY, SHADER_PARAM_TYPE_FLOAT, "0", "Y Offset of the mask relative to model space coords of target" ) SHADER_PARAM( SHEENMAPMASKDIRECTION, SHADER_PARAM_TYPE_INTEGER, "0", "The direction the sheen should move (length direction of weapon) XYZ, 0,1,2" ) SHADER_PARAM( SHEENINDEX, SHADER_PARAM_TYPE_INTEGER, "0", "Index of the Effect Type (Color Additive, Override etc...)" ) +#endif // Flesh Interior Pass SHADER_PARAM( FLESHINTERIORENABLED, SHADER_PARAM_TYPE_BOOL, "0", "Enable Flesh interior blend pass" ) @@ -134,6 +139,10 @@ BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" ) SHADER_PARAM( BLENDTINTBYBASEALPHA, SHADER_PARAM_TYPE_BOOL, "0", "Use the base alpha to blend in the $color modulation") SHADER_PARAM( BLENDTINTCOLOROVERBASE, SHADER_PARAM_TYPE_FLOAT, "0", "blend between tint acting as a multiplication versus a replace" ) + +#ifdef MAPBASE + SHADER_PARAM( PHONGDISABLEHALFLAMBERT, SHADER_PARAM_TYPE_BOOL, "0", "Disable half lambert for phong" ) +#endif END_SHADER_PARAMS void SetupVars( VertexLitGeneric_DX9_Vars_t& info ) @@ -209,6 +218,10 @@ BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" ) info.m_nSelfIllumMask = SELFILLUMMASK; info.m_nBlendTintByBaseAlpha = BLENDTINTBYBASEALPHA; info.m_nTintReplacesBaseColor = BLENDTINTCOLOROVERBASE; + +#ifdef MAPBASE + info.m_nPhongDisableHalfLambert = PHONGDISABLEHALFLAMBERT; +#endif } // Cloak Pass @@ -224,6 +237,7 @@ BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" ) info.m_nBumpTransform = BUMPTRANSFORM; } +#ifdef GAME_SHADER_DLL // Weapon Sheen Pass void SetupVarsWeaponSheenPass( WeaponSheenPassVars_t &info ) { @@ -242,6 +256,7 @@ BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" ) info.m_nBumpFrame = BUMPFRAME; info.m_nBumpTransform = BUMPTRANSFORM; } +#endif bool NeedsPowerOfTwoFrameBufferTexture( IMaterialVar **params, bool bCheckSpecificToThisFrame ) const { @@ -253,8 +268,11 @@ BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" ) return true; // else, not cloaking this frame, so check flag2 in case the base material still needs it } + +#ifdef GAME_SHADER_DLL if ( params[SHEENPASSENABLED]->GetIntValue() ) // If material supports weapon sheen return true; +#endif // Check flag2 if not drawing cloak pass return IS_FLAG2_SET( MATERIAL_VAR2_NEEDS_POWER_OF_TWO_FRAME_BUFFER_TEXTURE ); @@ -331,6 +349,7 @@ BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" ) InitParamsCloakBlendedPass( this, params, pMaterialName, info ); } +#ifdef GAME_SHADER_DLL // Sheen Pass if ( !params[SHEENPASSENABLED]->IsDefined() ) { @@ -342,6 +361,7 @@ BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" ) SetupVarsWeaponSheenPass( info ); InitParamsWeaponSheenPass( this, params, pMaterialName, info ); } +#endif // Emissive Scroll Pass if ( !params[EMISSIVEBLENDENABLED]->IsDefined() ) @@ -396,6 +416,7 @@ BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" ) InitCloakBlendedPass( this, params, info ); } +#ifdef GAME_SHADER_DLL // TODO : Only do this if we're in range of the camera // Weapon Sheen if ( params[SHEENPASSENABLED]->GetIntValue() ) @@ -404,6 +425,7 @@ BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" ) SetupVarsWeaponSheenPass( info ); InitWeaponSheenPass( this, params, info ); } +#endif // Emissive Scroll Pass if ( params[EMISSIVEBLENDENABLED]->GetIntValue() ) @@ -449,6 +471,7 @@ BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" ) Draw( false ); } +#ifdef GAME_SHADER_DLL // Weapon sheen pass // only if doing standard as well (don't do it if cloaked) if ( params[SHEENPASSENABLED]->GetIntValue() ) @@ -465,6 +488,7 @@ BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" ) Draw( false ); } } +#endif // Cloak Pass if ( params[CLOAKPASSENABLED]->GetIntValue() ) diff --git a/sp/src/materialsystem/stdshaders/vertexlitgeneric_dx9_helper.cpp b/sp/src/materialsystem/stdshaders/vertexlitgeneric_dx9_helper.cpp index b1f49eab..7b6e2598 100644 --- a/sp/src/materialsystem/stdshaders/vertexlitgeneric_dx9_helper.cpp +++ b/sp/src/materialsystem/stdshaders/vertexlitgeneric_dx9_helper.cpp @@ -9,19 +9,19 @@ #include "vertexlitgeneric_dx9_helper.h" #include "skin_dx9_helper.h" -#include "VertexLit_and_unlit_Generic_vs20.inc" -#include "VertexLit_and_unlit_Generic_bump_vs20.inc" +#include "SDK_VertexLit_and_unlit_Generic_vs20.inc" +#include "SDK_VertexLit_and_unlit_Generic_bump_vs20.inc" -#include "vertexlit_and_unlit_generic_ps20.inc" -#include "vertexlit_and_unlit_generic_ps20b.inc" -#include "vertexlit_and_unlit_generic_bump_ps20.inc" -#include "vertexlit_and_unlit_generic_bump_ps20b.inc" +//#include "SDK_vertexlit_and_unlit_generic_ps20.inc" +#include "SDK_vertexlit_and_unlit_generic_ps20b.inc" +//#include "SDK_vertexlit_and_unlit_generic_bump_ps20.inc" +#include "SDK_vertexlit_and_unlit_generic_bump_ps20b.inc" #ifndef _X360 -#include "vertexlit_and_unlit_generic_vs30.inc" -#include "vertexlit_and_unlit_generic_ps30.inc" -#include "vertexlit_and_unlit_generic_bump_vs30.inc" -#include "vertexlit_and_unlit_generic_bump_ps30.inc" +#include "SDK_vertexlit_and_unlit_generic_vs30.inc" +#include "SDK_vertexlit_and_unlit_generic_ps30.inc" +#include "SDK_vertexlit_and_unlit_generic_bump_vs30.inc" +#include "SDK_vertexlit_and_unlit_generic_bump_ps30.inc" #endif #include "commandbuilder.h" @@ -663,23 +663,23 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial if ( bHasBump || bHasDiffuseWarp ) { #ifndef _X360 - if ( !g_pHardwareConfig->HasFastVertexTextures() ) + if ( !g_pHardwareConfig->SupportsShaderModel_3_0() ) #endif { bool bUseStaticControlFlow = g_pHardwareConfig->SupportsStaticControlFlow(); - DECLARE_STATIC_VERTEX_SHADER( vertexlit_and_unlit_generic_bump_vs20 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_vertexlit_and_unlit_generic_bump_vs20 ); SET_STATIC_VERTEX_SHADER_COMBO( HALFLAMBERT, bHalfLambert); - SET_STATIC_VERTEX_SHADER_COMBO( USE_WITH_2B, g_pHardwareConfig->SupportsPixelShaders_2_b() ); + SET_STATIC_VERTEX_SHADER_COMBO( USE_WITH_2B, 1 ); #ifdef _X360 SET_STATIC_VERTEX_SHADER_COMBO( FLASHLIGHT, bHasFlashlight ); #endif SET_STATIC_VERTEX_SHADER_COMBO( USE_STATIC_CONTROL_FLOW, bUseStaticControlFlow ); - SET_STATIC_VERTEX_SHADER( vertexlit_and_unlit_generic_bump_vs20 ); + SET_STATIC_VERTEX_SHADER( sdk_vertexlit_and_unlit_generic_bump_vs20 ); - if ( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() ) // Always send GL this way - { - DECLARE_STATIC_PIXEL_SHADER( vertexlit_and_unlit_generic_bump_ps20b ); + //if ( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() ) // Always send GL this way + //{ + DECLARE_STATIC_PIXEL_SHADER( sdk_vertexlit_and_unlit_generic_bump_ps20b ); SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP, bHasEnvmap ); SET_STATIC_PIXEL_SHADER_COMBO( DIFFUSELIGHTING, hasDiffuseLighting ); SET_STATIC_PIXEL_SHADER_COMBO( LIGHTWARPTEXTURE, bHasDiffuseWarp && !bHasSelfIllumFresnel ); @@ -692,38 +692,42 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial SET_STATIC_PIXEL_SHADER_COMBO( DETAIL_BLEND_MODE, nDetailBlendMode ); SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, nShadowFilterMode ); SET_STATIC_PIXEL_SHADER_COMBO( BLENDTINTBYBASEALPHA, bBlendTintByBaseAlpha ); - SET_STATIC_PIXEL_SHADER( vertexlit_and_unlit_generic_bump_ps20b ); - } - else // ps_2_0 - { - DECLARE_STATIC_PIXEL_SHADER( vertexlit_and_unlit_generic_bump_ps20 ); - SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP, bHasEnvmap ); - SET_STATIC_PIXEL_SHADER_COMBO( DIFFUSELIGHTING, hasDiffuseLighting ); - SET_STATIC_PIXEL_SHADER_COMBO( LIGHTWARPTEXTURE, bHasDiffuseWarp && !bHasSelfIllumFresnel ); - SET_STATIC_PIXEL_SHADER_COMBO( SELFILLUM, bHasSelfIllum ); - SET_STATIC_PIXEL_SHADER_COMBO( SELFILLUMFRESNEL, bHasSelfIllumFresnel ); - SET_STATIC_PIXEL_SHADER_COMBO( NORMALMAPALPHAENVMAPMASK, hasNormalMapAlphaEnvmapMask && bHasEnvmap ); - SET_STATIC_PIXEL_SHADER_COMBO( HALFLAMBERT, bHalfLambert); - SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHT, bHasFlashlight ); - SET_STATIC_PIXEL_SHADER_COMBO( DETAILTEXTURE, bHasDetailTexture ); - SET_STATIC_PIXEL_SHADER_COMBO( DETAIL_BLEND_MODE, nDetailBlendMode ); - SET_STATIC_PIXEL_SHADER_COMBO( BLENDTINTBYBASEALPHA, bBlendTintByBaseAlpha ); - SET_STATIC_PIXEL_SHADER( vertexlit_and_unlit_generic_bump_ps20 ); - } + SET_STATIC_PIXEL_SHADER( sdk_vertexlit_and_unlit_generic_bump_ps20b ); + //} + //else // ps_2_0 + //{ + // DECLARE_STATIC_PIXEL_SHADER( sdk_vertexlit_and_unlit_generic_bump_ps20 ); + // SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP, bHasEnvmap ); + // SET_STATIC_PIXEL_SHADER_COMBO( DIFFUSELIGHTING, hasDiffuseLighting ); + // SET_STATIC_PIXEL_SHADER_COMBO( LIGHTWARPTEXTURE, bHasDiffuseWarp && !bHasSelfIllumFresnel ); + // SET_STATIC_PIXEL_SHADER_COMBO( SELFILLUM, bHasSelfIllum ); + // SET_STATIC_PIXEL_SHADER_COMBO( SELFILLUMFRESNEL, bHasSelfIllumFresnel ); + // SET_STATIC_PIXEL_SHADER_COMBO( NORMALMAPALPHAENVMAPMASK, hasNormalMapAlphaEnvmapMask && bHasEnvmap ); + // SET_STATIC_PIXEL_SHADER_COMBO( HALFLAMBERT, bHalfLambert); + // SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHT, bHasFlashlight ); + // SET_STATIC_PIXEL_SHADER_COMBO( DETAILTEXTURE, bHasDetailTexture ); + // SET_STATIC_PIXEL_SHADER_COMBO( DETAIL_BLEND_MODE, nDetailBlendMode ); + // SET_STATIC_PIXEL_SHADER_COMBO( BLENDTINTBYBASEALPHA, bBlendTintByBaseAlpha ); + // SET_STATIC_PIXEL_SHADER( sdk_vertexlit_and_unlit_generic_bump_ps20 ); + //} } #ifndef _X360 else { - // The vertex shader uses the vertex id stream - SET_FLAGS2( MATERIAL_VAR2_USES_VERTEXID ); + const bool bFastVertexTextures = g_pHardwareConfig->HasFastVertexTextures(); - DECLARE_STATIC_VERTEX_SHADER( vertexlit_and_unlit_generic_bump_vs30 ); + // The vertex shader uses the vertex id stream + if ( bFastVertexTextures ) + SET_FLAGS2( MATERIAL_VAR2_USES_VERTEXID ); + + DECLARE_STATIC_VERTEX_SHADER( sdk_vertexlit_and_unlit_generic_bump_vs30 ); SET_STATIC_VERTEX_SHADER_COMBO( HALFLAMBERT, bHalfLambert); SET_STATIC_VERTEX_SHADER_COMBO( USE_WITH_2B, true ); SET_STATIC_VERTEX_SHADER_COMBO( DECAL, bIsDecal ); - SET_STATIC_VERTEX_SHADER( vertexlit_and_unlit_generic_bump_vs30 ); + SET_STATIC_VERTEX_SHADER_COMBO( SM30_VERTEXID, bFastVertexTextures ); + SET_STATIC_VERTEX_SHADER( sdk_vertexlit_and_unlit_generic_bump_vs30 ); - DECLARE_STATIC_PIXEL_SHADER( vertexlit_and_unlit_generic_bump_ps30 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_vertexlit_and_unlit_generic_bump_ps30 ); SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP, bHasEnvmap ); SET_STATIC_PIXEL_SHADER_COMBO( DIFFUSELIGHTING, hasDiffuseLighting ); SET_STATIC_PIXEL_SHADER_COMBO( LIGHTWARPTEXTURE, bHasDiffuseWarp && !bHasSelfIllumFresnel ); @@ -736,7 +740,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial SET_STATIC_PIXEL_SHADER_COMBO( DETAIL_BLEND_MODE, nDetailBlendMode ); SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, nShadowFilterMode ); SET_STATIC_PIXEL_SHADER_COMBO( BLENDTINTBYBASEALPHA, bBlendTintByBaseAlpha ); - SET_STATIC_PIXEL_SHADER( vertexlit_and_unlit_generic_bump_ps30 ); + SET_STATIC_PIXEL_SHADER( sdk_vertexlit_and_unlit_generic_bump_ps30 ); } #endif } @@ -759,12 +763,12 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial } #ifndef _X360 - if ( !g_pHardwareConfig->HasFastVertexTextures() ) + if ( !g_pHardwareConfig->SupportsShaderModel_3_0() ) #endif { bool bUseStaticControlFlow = g_pHardwareConfig->SupportsStaticControlFlow(); - DECLARE_STATIC_VERTEX_SHADER( vertexlit_and_unlit_generic_vs20 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_vertexlit_and_unlit_generic_vs20 ); SET_STATIC_VERTEX_SHADER_COMBO( VERTEXCOLOR, bHasVertexColor || bHasVertexAlpha ); SET_STATIC_VERTEX_SHADER_COMBO( CUBEMAP, bHasEnvmap ); SET_STATIC_VERTEX_SHADER_COMBO( HALFLAMBERT, bHalfLambert ); @@ -774,11 +778,11 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial SET_STATIC_VERTEX_SHADER_COMBO( SEPARATE_DETAIL_UVS, IsBoolSet( info.m_nSeparateDetailUVs, params ) ); SET_STATIC_VERTEX_SHADER_COMBO( USE_STATIC_CONTROL_FLOW, bUseStaticControlFlow ); SET_STATIC_VERTEX_SHADER_COMBO( DONT_GAMMA_CONVERT_VERTEX_COLOR, (! bSRGBWrite ) && bHasVertexColor ); - SET_STATIC_VERTEX_SHADER( vertexlit_and_unlit_generic_vs20 ); + SET_STATIC_VERTEX_SHADER( sdk_vertexlit_and_unlit_generic_vs20 ); - if ( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() ) // Always send Gl this way - { - DECLARE_STATIC_PIXEL_SHADER( vertexlit_and_unlit_generic_ps20b ); + //if ( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() ) // Always send Gl this way + //{ + DECLARE_STATIC_PIXEL_SHADER( sdk_vertexlit_and_unlit_generic_ps20b ); SET_STATIC_PIXEL_SHADER_COMBO( SELFILLUM_ENVMAPMASK_ALPHA, ( hasSelfIllumInEnvMapMask && ( bHasEnvmapMask ) ) ); SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP, bHasEnvmap ); SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP_SPHERE_LEGACY, bHasLegacyEnvSphereMap ); @@ -801,40 +805,43 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial SET_STATIC_PIXEL_SHADER_COMBO( DEPTHBLEND, bDoDepthBlend ); SET_STATIC_PIXEL_SHADER_COMBO( SRGB_INPUT_ADAPTER, bSRGBInputAdapter ? 1 : 0 ); SET_STATIC_PIXEL_SHADER_COMBO( BLENDTINTBYBASEALPHA, bBlendTintByBaseAlpha ); - SET_STATIC_PIXEL_SHADER( vertexlit_and_unlit_generic_ps20b ); - } - else // ps_2_0 - { - DECLARE_STATIC_PIXEL_SHADER( vertexlit_and_unlit_generic_ps20 ); - SET_STATIC_PIXEL_SHADER_COMBO( SELFILLUM_ENVMAPMASK_ALPHA, ( hasSelfIllumInEnvMapMask && ( bHasEnvmapMask ) ) ); - SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP, bHasEnvmap ); - SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP_SPHERE_LEGACY, bHasLegacyEnvSphereMap ); - SET_STATIC_PIXEL_SHADER_COMBO( DIFFUSELIGHTING, hasDiffuseLighting ); - SET_STATIC_PIXEL_SHADER_COMBO( ENVMAPMASK, bHasEnvmapMask ); - SET_STATIC_PIXEL_SHADER_COMBO( BASEALPHAENVMAPMASK, hasBaseAlphaEnvmapMask ); - SET_STATIC_PIXEL_SHADER_COMBO( SELFILLUM, bHasSelfIllum ); - SET_STATIC_PIXEL_SHADER_COMBO( VERTEXCOLOR, bHasVertexColor ); - SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHT, bHasFlashlight ); - SET_STATIC_PIXEL_SHADER_COMBO( DETAILTEXTURE, bHasDetailTexture ); - SET_STATIC_PIXEL_SHADER_COMBO( DETAIL_BLEND_MODE, nDetailBlendMode ); - SET_STATIC_PIXEL_SHADER_COMBO( SEAMLESS_BASE, bSeamlessBase ); - SET_STATIC_PIXEL_SHADER_COMBO( SEAMLESS_DETAIL, bSeamlessDetail ); - SET_STATIC_PIXEL_SHADER_COMBO( DISTANCEALPHA, bDistanceAlpha ); - SET_STATIC_PIXEL_SHADER_COMBO( DISTANCEALPHAFROMDETAIL, bDistanceAlphaFromDetail ); - SET_STATIC_PIXEL_SHADER_COMBO( SOFT_MASK, bSoftMask ); - SET_STATIC_PIXEL_SHADER_COMBO( OUTLINE, bOutline ); - SET_STATIC_PIXEL_SHADER_COMBO( OUTER_GLOW, bGlow ); - SET_STATIC_PIXEL_SHADER_COMBO( BLENDTINTBYBASEALPHA, bBlendTintByBaseAlpha ); - SET_STATIC_PIXEL_SHADER( vertexlit_and_unlit_generic_ps20 ); - } + SET_STATIC_PIXEL_SHADER( sdk_vertexlit_and_unlit_generic_ps20b ); + //} + //else // ps_2_0 + //{ + // DECLARE_STATIC_PIXEL_SHADER( sdk_vertexlit_and_unlit_generic_ps20 ); + // SET_STATIC_PIXEL_SHADER_COMBO( SELFILLUM_ENVMAPMASK_ALPHA, ( hasSelfIllumInEnvMapMask && ( bHasEnvmapMask ) ) ); + // SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP, bHasEnvmap ); + // SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP_SPHERE_LEGACY, bHasLegacyEnvSphereMap ); + // SET_STATIC_PIXEL_SHADER_COMBO( DIFFUSELIGHTING, hasDiffuseLighting ); + // SET_STATIC_PIXEL_SHADER_COMBO( ENVMAPMASK, bHasEnvmapMask ); + // SET_STATIC_PIXEL_SHADER_COMBO( BASEALPHAENVMAPMASK, hasBaseAlphaEnvmapMask ); + // SET_STATIC_PIXEL_SHADER_COMBO( SELFILLUM, bHasSelfIllum ); + // SET_STATIC_PIXEL_SHADER_COMBO( VERTEXCOLOR, bHasVertexColor ); + // SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHT, bHasFlashlight ); + // SET_STATIC_PIXEL_SHADER_COMBO( DETAILTEXTURE, bHasDetailTexture ); + // SET_STATIC_PIXEL_SHADER_COMBO( DETAIL_BLEND_MODE, nDetailBlendMode ); + // SET_STATIC_PIXEL_SHADER_COMBO( SEAMLESS_BASE, bSeamlessBase ); + // SET_STATIC_PIXEL_SHADER_COMBO( SEAMLESS_DETAIL, bSeamlessDetail ); + // SET_STATIC_PIXEL_SHADER_COMBO( DISTANCEALPHA, bDistanceAlpha ); + // SET_STATIC_PIXEL_SHADER_COMBO( DISTANCEALPHAFROMDETAIL, bDistanceAlphaFromDetail ); + // SET_STATIC_PIXEL_SHADER_COMBO( SOFT_MASK, bSoftMask ); + // SET_STATIC_PIXEL_SHADER_COMBO( OUTLINE, bOutline ); + // SET_STATIC_PIXEL_SHADER_COMBO( OUTER_GLOW, bGlow ); + // SET_STATIC_PIXEL_SHADER_COMBO( BLENDTINTBYBASEALPHA, bBlendTintByBaseAlpha ); + // SET_STATIC_PIXEL_SHADER( sdk_vertexlit_and_unlit_generic_ps20 ); + //} } #ifndef _X360 else { - // The vertex shader uses the vertex id stream - SET_FLAGS2( MATERIAL_VAR2_USES_VERTEXID ); + const bool bFastVertexTextures = g_pHardwareConfig->HasFastVertexTextures(); - DECLARE_STATIC_VERTEX_SHADER( vertexlit_and_unlit_generic_vs30 ); + // The vertex shader uses the vertex id stream + if ( bFastVertexTextures ) + SET_FLAGS2( MATERIAL_VAR2_USES_VERTEXID ); + + DECLARE_STATIC_VERTEX_SHADER( sdk_vertexlit_and_unlit_generic_vs30 ); SET_STATIC_VERTEX_SHADER_COMBO( VERTEXCOLOR, bHasVertexColor || bHasVertexAlpha ); SET_STATIC_VERTEX_SHADER_COMBO( CUBEMAP, bHasEnvmap ); SET_STATIC_VERTEX_SHADER_COMBO( HALFLAMBERT, bHalfLambert ); @@ -843,10 +850,11 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial SET_STATIC_VERTEX_SHADER_COMBO( SEAMLESS_DETAIL, bSeamlessDetail ); SET_STATIC_VERTEX_SHADER_COMBO( SEPARATE_DETAIL_UVS, IsBoolSet( info.m_nSeparateDetailUVs, params ) ); SET_STATIC_VERTEX_SHADER_COMBO( DECAL, bIsDecal ); + SET_STATIC_VERTEX_SHADER_COMBO( SM30_VERTEXID, bFastVertexTextures ); SET_STATIC_VERTEX_SHADER_COMBO( DONT_GAMMA_CONVERT_VERTEX_COLOR, bSRGBWrite ? 0 : 1 ); - SET_STATIC_VERTEX_SHADER( vertexlit_and_unlit_generic_vs30 ); + SET_STATIC_VERTEX_SHADER( sdk_vertexlit_and_unlit_generic_vs30 ); - DECLARE_STATIC_PIXEL_SHADER( vertexlit_and_unlit_generic_ps30 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_vertexlit_and_unlit_generic_ps30 ); SET_STATIC_PIXEL_SHADER_COMBO( SELFILLUM_ENVMAPMASK_ALPHA, ( hasSelfIllumInEnvMapMask && ( bHasEnvmapMask ) ) ); SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP, bHasEnvmap ); SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP_SPHERE_LEGACY, bHasLegacyEnvSphereMap ); @@ -868,7 +876,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, nShadowFilterMode ); SET_STATIC_PIXEL_SHADER_COMBO( DEPTHBLEND, bDoDepthBlend ); SET_STATIC_PIXEL_SHADER_COMBO( BLENDTINTBYBASEALPHA, bBlendTintByBaseAlpha ); - SET_STATIC_PIXEL_SHADER( vertexlit_and_unlit_generic_ps30 ); + SET_STATIC_PIXEL_SHADER( sdk_vertexlit_and_unlit_generic_ps30 ); } #endif } @@ -1216,59 +1224,65 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial if ( bHasBump || bHasDiffuseWarp ) { #ifndef _X360 - if ( !g_pHardwareConfig->HasFastVertexTextures() ) + if ( !g_pHardwareConfig->SupportsShaderModel_3_0() ) #endif { bool bUseStaticControlFlow = g_pHardwareConfig->SupportsStaticControlFlow(); - DECLARE_DYNAMIC_VERTEX_SHADER( vertexlit_and_unlit_generic_bump_vs20 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_vertexlit_and_unlit_generic_bump_vs20 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogIndex ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, numBones > 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); SET_DYNAMIC_VERTEX_SHADER_COMBO( NUM_LIGHTS, bUseStaticControlFlow ? 0 : lightState.m_nNumLights ); - SET_DYNAMIC_VERTEX_SHADER_CMD( DynamicCmdsOut, vertexlit_and_unlit_generic_bump_vs20 ); + SET_DYNAMIC_VERTEX_SHADER_CMD( DynamicCmdsOut, sdk_vertexlit_and_unlit_generic_bump_vs20 ); // Bind ps_2_b shader so we can get shadow mapping... - if ( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() ) // Always send GL this way - { - DECLARE_DYNAMIC_PIXEL_SHADER( vertexlit_and_unlit_generic_bump_ps20b ); + //if ( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() ) // Always send GL this way + //{ + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_vertexlit_and_unlit_generic_bump_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( NUM_LIGHTS, lightState.m_nNumLights ); SET_DYNAMIC_PIXEL_SHADER_COMBO( AMBIENT_LIGHT, lightState.m_bAmbientLight ? 1 : 0 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, bFlashlightShadows ); // SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - SET_DYNAMIC_PIXEL_SHADER_CMD( DynamicCmdsOut, vertexlit_and_unlit_generic_bump_ps20b ); - } - else + SET_DYNAMIC_PIXEL_SHADER_CMD( DynamicCmdsOut, sdk_vertexlit_and_unlit_generic_bump_ps20b ); + //} + /*else { - DECLARE_DYNAMIC_PIXEL_SHADER( vertexlit_and_unlit_generic_bump_ps20 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_vertexlit_and_unlit_generic_bump_ps20 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( NUM_LIGHTS, lightState.m_nNumLights ); SET_DYNAMIC_PIXEL_SHADER_COMBO( AMBIENT_LIGHT, lightState.m_bAmbientLight ? 1 : 0 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITEWATERFOGTODESTALPHA, bWriteWaterFogToAlpha ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - SET_DYNAMIC_PIXEL_SHADER_CMD( DynamicCmdsOut, vertexlit_and_unlit_generic_bump_ps20 ); - } + SET_DYNAMIC_PIXEL_SHADER_CMD( DynamicCmdsOut, sdk_vertexlit_and_unlit_generic_bump_ps20 ); + }*/ } #ifndef _X360 else { - pShader->SetHWMorphVertexShaderState( VERTEX_SHADER_SHADER_SPECIFIC_CONST_10, VERTEX_SHADER_SHADER_SPECIFIC_CONST_11, SHADER_VERTEXTEXTURE_SAMPLER0 ); + const bool bFastVertexTextures = g_pHardwareConfig->HasFastVertexTextures(); - DECLARE_DYNAMIC_VERTEX_SHADER( vertexlit_and_unlit_generic_bump_vs30 ); + if ( bFastVertexTextures ) + pShader->SetHWMorphVertexShaderState( VERTEX_SHADER_SHADER_SPECIFIC_CONST_10, VERTEX_SHADER_SHADER_SPECIFIC_CONST_11, SHADER_VERTEXTEXTURE_SAMPLER0 ); + + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_vertexlit_and_unlit_generic_bump_vs30 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogIndex ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, numBones > 0 ); - SET_DYNAMIC_VERTEX_SHADER_COMBO( MORPHING, pShaderAPI->IsHWMorphingEnabled() ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( MORPHING, pShaderAPI->IsHWMorphingEnabled() && bFastVertexTextures ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); - SET_DYNAMIC_VERTEX_SHADER( vertexlit_and_unlit_generic_bump_vs30 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_vertexlit_and_unlit_generic_bump_vs30 ); - DECLARE_DYNAMIC_PIXEL_SHADER( vertexlit_and_unlit_generic_bump_ps30 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_vertexlit_and_unlit_generic_bump_ps30 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( NUM_LIGHTS, lightState.m_nNumLights ); SET_DYNAMIC_PIXEL_SHADER_COMBO( AMBIENT_LIGHT, lightState.m_bAmbientLight ? 1 : 0 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, bFlashlightShadows ); // SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - SET_DYNAMIC_PIXEL_SHADER_CMD( DynamicCmdsOut, vertexlit_and_unlit_generic_bump_ps30 ); + SET_DYNAMIC_PIXEL_SHADER_CMD( DynamicCmdsOut, sdk_vertexlit_and_unlit_generic_bump_ps30 ); - bool bUnusedTexCoords[3] = { false, false, !pShaderAPI->IsHWMorphingEnabled() || !bIsDecal }; - pShaderAPI->MarkUnusedVertexFields( 0, 3, bUnusedTexCoords ); + if ( bFastVertexTextures ) + { + bool bUnusedTexCoords[3] = { false, false, !pShaderAPI->IsHWMorphingEnabled() || !bIsDecal }; + pShaderAPI->MarkUnusedVertexFields( 0, 3, bUnusedTexCoords ); + } } #endif } @@ -1282,12 +1296,12 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial } #ifndef _X360 - if ( !g_pHardwareConfig->HasFastVertexTextures() ) + if ( !g_pHardwareConfig->SupportsShaderModel_3_0() ) #endif { bool bUseStaticControlFlow = g_pHardwareConfig->SupportsStaticControlFlow(); - DECLARE_DYNAMIC_VERTEX_SHADER( vertexlit_and_unlit_generic_vs20 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_vertexlit_and_unlit_generic_vs20 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DYNAMIC_LIGHT, lightState.HasDynamicLight() ); SET_DYNAMIC_VERTEX_SHADER_COMBO( STATIC_LIGHT, lightState.m_bStaticLight ? 1 : 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogIndex ); @@ -1297,55 +1311,61 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial pShaderAPI->GetIntRenderingParameter(INT_RENDERPARM_ENABLE_FIXED_LIGHTING)!=0); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); SET_DYNAMIC_VERTEX_SHADER_COMBO( NUM_LIGHTS, bUseStaticControlFlow ? 0 : lightState.m_nNumLights ); - SET_DYNAMIC_VERTEX_SHADER_CMD( DynamicCmdsOut, vertexlit_and_unlit_generic_vs20 ); + SET_DYNAMIC_VERTEX_SHADER_CMD( DynamicCmdsOut, sdk_vertexlit_and_unlit_generic_vs20 ); // Bind ps_2_b shader so we can get shadow mapping - if ( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() ) // Always send GL this way - { - DECLARE_DYNAMIC_PIXEL_SHADER( vertexlit_and_unlit_generic_ps20b ); + //if ( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() ) // Always send GL this way + //{ + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_vertexlit_and_unlit_generic_ps20b ); // SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, bFlashlightShadows ); SET_DYNAMIC_PIXEL_SHADER_COMBO( LIGHTING_PREVIEW, pShaderAPI->GetIntRenderingParameter(INT_RENDERPARM_ENABLE_FIXED_LIGHTING) ); - SET_DYNAMIC_PIXEL_SHADER_CMD( DynamicCmdsOut, vertexlit_and_unlit_generic_ps20b ); - } - else + SET_DYNAMIC_PIXEL_SHADER_CMD( DynamicCmdsOut, sdk_vertexlit_and_unlit_generic_ps20b ); + //} + /*else { - DECLARE_DYNAMIC_PIXEL_SHADER( vertexlit_and_unlit_generic_ps20 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_vertexlit_and_unlit_generic_ps20 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( LIGHTING_PREVIEW, pShaderAPI->GetIntRenderingParameter(INT_RENDERPARM_ENABLE_FIXED_LIGHTING) ); - SET_DYNAMIC_PIXEL_SHADER_CMD( DynamicCmdsOut, vertexlit_and_unlit_generic_ps20 ); - } + SET_DYNAMIC_PIXEL_SHADER_CMD( DynamicCmdsOut, sdk_vertexlit_and_unlit_generic_ps20 ); + }*/ } #ifndef _X360 else { - pShader->SetHWMorphVertexShaderState( VERTEX_SHADER_SHADER_SPECIFIC_CONST_10, VERTEX_SHADER_SHADER_SPECIFIC_CONST_11, SHADER_VERTEXTEXTURE_SAMPLER0 ); + const bool bFastVertexTextures = g_pHardwareConfig->HasFastVertexTextures(); - DECLARE_DYNAMIC_VERTEX_SHADER( vertexlit_and_unlit_generic_vs30 ); + if ( bFastVertexTextures ) + pShader->SetHWMorphVertexShaderState( VERTEX_SHADER_SHADER_SPECIFIC_CONST_10, VERTEX_SHADER_SHADER_SPECIFIC_CONST_11, SHADER_VERTEXTEXTURE_SAMPLER0 ); + + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_vertexlit_and_unlit_generic_vs30 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DYNAMIC_LIGHT, lightState.HasDynamicLight() ); SET_DYNAMIC_VERTEX_SHADER_COMBO( STATIC_LIGHT, lightState.m_bStaticLight ? 1 : 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogIndex ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, numBones > 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( LIGHTING_PREVIEW, pShaderAPI->GetIntRenderingParameter(INT_RENDERPARM_ENABLE_FIXED_LIGHTING)!=0); - SET_DYNAMIC_VERTEX_SHADER_COMBO( MORPHING, pShaderAPI->IsHWMorphingEnabled() ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( MORPHING, pShaderAPI->IsHWMorphingEnabled() && bFastVertexTextures ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); - SET_DYNAMIC_VERTEX_SHADER_CMD( DynamicCmdsOut, vertexlit_and_unlit_generic_vs30 ); + SET_DYNAMIC_VERTEX_SHADER_CMD( DynamicCmdsOut, sdk_vertexlit_and_unlit_generic_vs30 ); - DECLARE_DYNAMIC_PIXEL_SHADER( vertexlit_and_unlit_generic_ps30 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_vertexlit_and_unlit_generic_ps30 ); // SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, bFlashlightShadows ); SET_DYNAMIC_PIXEL_SHADER_COMBO( LIGHTING_PREVIEW, pShaderAPI->GetIntRenderingParameter(INT_RENDERPARM_ENABLE_FIXED_LIGHTING) ); - SET_DYNAMIC_PIXEL_SHADER_CMD( DynamicCmdsOut, vertexlit_and_unlit_generic_ps30 ); + SET_DYNAMIC_PIXEL_SHADER_CMD( DynamicCmdsOut, sdk_vertexlit_and_unlit_generic_ps30 ); - bool bUnusedTexCoords[3] = { false, false, !pShaderAPI->IsHWMorphingEnabled() || !bIsDecal }; - pShaderAPI->MarkUnusedVertexFields( 0, 3, bUnusedTexCoords ); + if ( bFastVertexTextures ) + { + bool bUnusedTexCoords[3] = { false, false, !pShaderAPI->IsHWMorphingEnabled() || !bIsDecal }; + pShaderAPI->MarkUnusedVertexFields( 0, 3, bUnusedTexCoords ); + } } #endif } @@ -1361,6 +1381,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial float eyePos[4]; pShaderAPI->GetWorldSpaceCameraPosition( eyePos ); + eyePos[3] = pShaderAPI->GetFloatRenderingParameter( FLOAT_RENDERPARM_MINIMUMLIGHTING ); DynamicCmdsOut.SetPixelShaderConstant( 20, eyePos ); // Non-bump case does its own depth feathering work @@ -1415,7 +1436,7 @@ void DrawVertexLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, IS IShaderShadow* pShaderShadow, bool bVertexLitGeneric, VertexLitGeneric_DX9_Vars_t &info, VertexCompressionType_t vertexCompression, CBasePerMaterialContextData **pContextDataPtr ) { - if ( WantsSkinShader( params, info ) && g_pHardwareConfig->SupportsPixelShaders_2_b() && g_pConfig->UseBumpmapping() && g_pConfig->UsePhong() ) + if ( WantsSkinShader( params, info ) /*&& g_pHardwareConfig->SupportsPixelShaders_2_b()*/ && g_pConfig->UseBumpmapping() && g_pConfig->UsePhong() ) { DrawSkin_DX9( pShader, params, pShaderAPI, pShaderShadow, info, vertexCompression, pContextDataPtr ); return; diff --git a/sp/src/materialsystem/stdshaders/vertexlitgeneric_dx9_helper.h b/sp/src/materialsystem/stdshaders/vertexlitgeneric_dx9_helper.h index 0b5b02e4..592e4367 100644 --- a/sp/src/materialsystem/stdshaders/vertexlitgeneric_dx9_helper.h +++ b/sp/src/materialsystem/stdshaders/vertexlitgeneric_dx9_helper.h @@ -131,6 +131,11 @@ struct VertexLitGeneric_DX9_Vars_t int m_nTintReplacesBaseColor; +#ifdef MAPBASE + // Parameter ported from Alien Swarm. See bPhongHalfLambert in DrawSkin_DX9_Internal() for more info. + int m_nPhongDisableHalfLambert; +#endif + }; void InitParamsVertexLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, const char *pMaterialName, bool bVertexLitGeneric, VertexLitGeneric_DX9_Vars_t &info ); diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_Eyes.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_Eyes.inc new file mode 100644 index 00000000..6420be52 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_Eyes.inc @@ -0,0 +1,134 @@ +class sdk_eyes_Static_Index +{ +private: + int m_nHALF_LAMBERT; +#ifdef _DEBUG + bool m_bHALF_LAMBERT; +#endif +public: + void SetHALF_LAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALF_LAMBERT = i; +#ifdef _DEBUG + m_bHALF_LAMBERT = true; +#endif + } + void SetHALF_LAMBERT( bool i ) + { + m_nHALF_LAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALF_LAMBERT = true; +#endif + } +public: + sdk_eyes_Static_Index() + { +#ifdef _DEBUG + m_bHALF_LAMBERT = false; +#endif // _DEBUG + m_nHALF_LAMBERT = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bHALF_LAMBERT; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 88 * m_nHALF_LAMBERT ) + 0; + } +}; +class sdk_eyes_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nLIGHT_COMBO; +#ifdef _DEBUG + bool m_bLIGHT_COMBO; +#endif +public: + void SetLIGHT_COMBO( int i ) + { + Assert( i >= 0 && i <= 21 ); + m_nLIGHT_COMBO = i; +#ifdef _DEBUG + m_bLIGHT_COMBO = true; +#endif + } + void SetLIGHT_COMBO( bool i ) + { + m_nLIGHT_COMBO = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHT_COMBO = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_eyes_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bLIGHT_COMBO = false; +#endif // _DEBUG + m_nLIGHT_COMBO = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG && m_bLIGHT_COMBO && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + ( 2 * m_nLIGHT_COMBO ) + ( 44 * m_nSKINNING ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_LightmappedGeneric_BaseTexture.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_LightmappedGeneric_BaseTexture.inc new file mode 100644 index 00000000..fe6d6921 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_LightmappedGeneric_BaseTexture.inc @@ -0,0 +1,57 @@ +class sdk_lightmappedgeneric_basetexture_Static_Index +{ +public: + sdk_lightmappedgeneric_basetexture_Static_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +class sdk_lightmappedgeneric_basetexture_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_lightmappedgeneric_basetexture_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_LightmappedGeneric_BumpmappedLightmap_Base_ps14.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_LightmappedGeneric_BumpmappedLightmap_Base_ps14.inc new file mode 100644 index 00000000..4b9837cf --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_LightmappedGeneric_BumpmappedLightmap_Base_ps14.inc @@ -0,0 +1,57 @@ +class sdk_lightmappedgeneric_bumpmappedlightmap_base_ps14_Static_Index +{ +public: + sdk_lightmappedgeneric_bumpmappedlightmap_base_ps14_Static_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +class sdk_lightmappedgeneric_bumpmappedlightmap_base_ps14_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_lightmappedgeneric_bumpmappedlightmap_base_ps14_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_LightmappedGeneric_BumpmappedLightmap_Blend_ps14.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_LightmappedGeneric_BumpmappedLightmap_Blend_ps14.inc new file mode 100644 index 00000000..8fa2fdad --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_LightmappedGeneric_BumpmappedLightmap_Blend_ps14.inc @@ -0,0 +1,57 @@ +class sdk_lightmappedgeneric_bumpmappedlightmap_blend_ps14_Static_Index +{ +public: + sdk_lightmappedgeneric_bumpmappedlightmap_blend_ps14_Static_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +class sdk_lightmappedgeneric_bumpmappedlightmap_blend_ps14_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_lightmappedgeneric_bumpmappedlightmap_blend_ps14_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_LightmappedGeneric_Decal.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_LightmappedGeneric_Decal.inc new file mode 100644 index 00000000..a61b6686 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_LightmappedGeneric_Decal.inc @@ -0,0 +1,57 @@ +class sdk_lightmappedgeneric_decal_Static_Index +{ +public: + sdk_lightmappedgeneric_decal_Static_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +class sdk_lightmappedgeneric_decal_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_lightmappedgeneric_decal_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_LightmappedGeneric_LightingOnly.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_LightmappedGeneric_LightingOnly.inc new file mode 100644 index 00000000..ccbc3081 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_LightmappedGeneric_LightingOnly.inc @@ -0,0 +1,57 @@ +class sdk_lightmappedgeneric_lightingonly_Static_Index +{ +public: + sdk_lightmappedgeneric_lightingonly_Static_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +class sdk_lightmappedgeneric_lightingonly_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_lightmappedgeneric_lightingonly_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_UnlitGeneric_LightingOnly.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_UnlitGeneric_LightingOnly.inc new file mode 100644 index 00000000..42974139 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_UnlitGeneric_LightingOnly.inc @@ -0,0 +1,82 @@ +class sdk_unlitgeneric_lightingonly_Static_Index +{ +public: + sdk_unlitgeneric_lightingonly_Static_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +class sdk_unlitgeneric_lightingonly_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_unlitgeneric_lightingonly_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + ( 2 * m_nSKINNING ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_UnlitTwoTexture.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_UnlitTwoTexture.inc new file mode 100644 index 00000000..3959419d --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_UnlitTwoTexture.inc @@ -0,0 +1,82 @@ +class sdk_unlittwotexture_Static_Index +{ +public: + sdk_unlittwotexture_Static_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +class sdk_unlittwotexture_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_unlittwotexture_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + ( 2 * m_nSKINNING ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_VertexLitGeneric_EnvmappedBumpmap_NoLighting.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_VertexLitGeneric_EnvmappedBumpmap_NoLighting.inc new file mode 100644 index 00000000..20696e87 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_VertexLitGeneric_EnvmappedBumpmap_NoLighting.inc @@ -0,0 +1,82 @@ +class sdk_vertexlitgeneric_envmappedbumpmap_nolighting_Static_Index +{ +public: + sdk_vertexlitgeneric_envmappedbumpmap_nolighting_Static_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +class sdk_vertexlitgeneric_envmappedbumpmap_nolighting_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_vertexlitgeneric_envmappedbumpmap_nolighting_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + ( 2 * m_nSKINNING ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_VertexLitGeneric_EnvmappedBumpmap_NoLighting_ps14.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_VertexLitGeneric_EnvmappedBumpmap_NoLighting_ps14.inc new file mode 100644 index 00000000..42fbe392 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_VertexLitGeneric_EnvmappedBumpmap_NoLighting_ps14.inc @@ -0,0 +1,82 @@ +class sdk_vertexlitgeneric_envmappedbumpmap_nolighting_ps14_Static_Index +{ +public: + sdk_vertexlitgeneric_envmappedbumpmap_nolighting_ps14_Static_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +class sdk_vertexlitgeneric_envmappedbumpmap_nolighting_ps14_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_vertexlitgeneric_envmappedbumpmap_nolighting_ps14_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + ( 2 * m_nSKINNING ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_VertexLitGeneric_SelfIllumOnly.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_VertexLitGeneric_SelfIllumOnly.inc new file mode 100644 index 00000000..b8fb4774 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_VertexLitGeneric_SelfIllumOnly.inc @@ -0,0 +1,82 @@ +class sdk_vertexlitgeneric_selfillumonly_Static_Index +{ +public: + sdk_vertexlitgeneric_selfillumonly_Static_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +class sdk_vertexlitgeneric_selfillumonly_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_vertexlitgeneric_selfillumonly_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + ( 2 * m_nSKINNING ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_VertexLitGeneric_vs11.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_VertexLitGeneric_vs11.inc new file mode 100644 index 00000000..77853d4d --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_VertexLitGeneric_vs11.inc @@ -0,0 +1,200 @@ +class sdk_vertexlitgeneric_vs11_Static_Index +{ +private: + int m_nHALF_LAMBERT; +#ifdef _DEBUG + bool m_bHALF_LAMBERT; +#endif +public: + void SetHALF_LAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nHALF_LAMBERT = i; +#ifdef _DEBUG + m_bHALF_LAMBERT = true; +#endif + } + void SetHALF_LAMBERT( bool i ) + { + m_nHALF_LAMBERT = i ? 1 : 0; +#ifdef _DEBUG + m_bHALF_LAMBERT = true; +#endif + } +private: + int m_nENVMAP; +#ifdef _DEBUG + bool m_bENVMAP; +#endif +public: + void SetENVMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAP = i; +#ifdef _DEBUG + m_bENVMAP = true; +#endif + } + void SetENVMAP( bool i ) + { + m_nENVMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAP = true; +#endif + } +private: + int m_nENVMAPCAMERASPACE; +#ifdef _DEBUG + bool m_bENVMAPCAMERASPACE; +#endif +public: + void SetENVMAPCAMERASPACE( int i ) + { + } + void SetENVMAPCAMERASPACE( bool i ) + { + } +private: + int m_nENVMAPSPHERE; +#ifdef _DEBUG + bool m_bENVMAPSPHERE; +#endif +public: + void SetENVMAPSPHERE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPSPHERE = i; +#ifdef _DEBUG + m_bENVMAPSPHERE = true; +#endif + } + void SetENVMAPSPHERE( bool i ) + { + m_nENVMAPSPHERE = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAPSPHERE = true; +#endif + } +public: + sdk_vertexlitgeneric_vs11_Static_Index() + { +#ifdef _DEBUG + m_bHALF_LAMBERT = false; +#endif // _DEBUG + m_nHALF_LAMBERT = 0; +#ifdef _DEBUG + m_bENVMAP = false; +#endif // _DEBUG + m_nENVMAP = 0; +#ifdef _DEBUG + m_bENVMAPCAMERASPACE = true; +#endif // _DEBUG + m_nENVMAPCAMERASPACE = 0; +#ifdef _DEBUG + m_bENVMAPSPHERE = false; +#endif // _DEBUG + m_nENVMAPSPHERE = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bHALF_LAMBERT && m_bENVMAP && m_bENVMAPCAMERASPACE && m_bENVMAPSPHERE; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 88 * m_nHALF_LAMBERT ) + ( 176 * m_nENVMAP ) + ( 352 * m_nENVMAPCAMERASPACE ) + ( 352 * m_nENVMAPSPHERE ) + 0; + } +}; +class sdk_vertexlitgeneric_vs11_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nLIGHT_COMBO; +#ifdef _DEBUG + bool m_bLIGHT_COMBO; +#endif +public: + void SetLIGHT_COMBO( int i ) + { + Assert( i >= 0 && i <= 21 ); + m_nLIGHT_COMBO = i; +#ifdef _DEBUG + m_bLIGHT_COMBO = true; +#endif + } + void SetLIGHT_COMBO( bool i ) + { + m_nLIGHT_COMBO = i ? 1 : 0; +#ifdef _DEBUG + m_bLIGHT_COMBO = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_vertexlitgeneric_vs11_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bLIGHT_COMBO = false; +#endif // _DEBUG + m_nLIGHT_COMBO = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG && m_bLIGHT_COMBO && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + ( 2 * m_nLIGHT_COMBO ) + ( 44 * m_nSKINNING ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_WorldVertexAlpha.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_WorldVertexAlpha.inc new file mode 100644 index 00000000..b1f29af6 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_WorldVertexAlpha.inc @@ -0,0 +1,57 @@ +class sdk_worldvertexalpha_Static_Index +{ +public: + sdk_worldvertexalpha_Static_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +class sdk_worldvertexalpha_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_worldvertexalpha_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_WorldVertexTransition.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_WorldVertexTransition.inc new file mode 100644 index 00000000..6a2424ca --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_WorldVertexTransition.inc @@ -0,0 +1,57 @@ +class sdk_worldvertextransition_Static_Index +{ +public: + sdk_worldvertextransition_Static_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +class sdk_worldvertextransition_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_worldvertextransition_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_WorldVertexTransition_Seamless.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_WorldVertexTransition_Seamless.inc new file mode 100644 index 00000000..8a5cae90 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_WorldVertexTransition_Seamless.inc @@ -0,0 +1,57 @@ +class sdk_worldvertextransition_seamless_Static_Index +{ +public: + sdk_worldvertextransition_seamless_Static_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +class sdk_worldvertextransition_seamless_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_worldvertextransition_seamless_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_WorldVertexTransition_vs14.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_WorldVertexTransition_vs14.inc new file mode 100644 index 00000000..3f468c2e --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_WorldVertexTransition_vs14.inc @@ -0,0 +1,57 @@ +class sdk_worldvertextransition_vs14_Static_Index +{ +public: + sdk_worldvertextransition_vs14_Static_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +class sdk_worldvertextransition_vs14_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_worldvertextransition_vs14_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_emissive_scroll_blended_pass_dx8_vs11.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_emissive_scroll_blended_pass_dx8_vs11.inc new file mode 100644 index 00000000..30cb66d1 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_emissive_scroll_blended_pass_dx8_vs11.inc @@ -0,0 +1,57 @@ +class sdk_emissive_scroll_blended_pass_dx8_vs11_Static_Index +{ +public: + sdk_emissive_scroll_blended_pass_dx8_vs11_Static_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +class sdk_emissive_scroll_blended_pass_dx8_vs11_Dynamic_Index +{ +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_emissive_scroll_blended_pass_dx8_vs11_Dynamic_Index() + { +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nSKINNING ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_eyes_flashlight_vs11.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_eyes_flashlight_vs11.inc new file mode 100644 index 00000000..03cb5fca --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_eyes_flashlight_vs11.inc @@ -0,0 +1,82 @@ +class sdk_eyes_flashlight_vs11_Static_Index +{ +public: + sdk_eyes_flashlight_vs11_Static_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +class sdk_eyes_flashlight_vs11_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_eyes_flashlight_vs11_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + ( 2 * m_nSKINNING ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_lightmappedgeneric_basetextureblend.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_lightmappedgeneric_basetextureblend.inc new file mode 100644 index 00000000..5c067f5a --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_lightmappedgeneric_basetextureblend.inc @@ -0,0 +1,57 @@ +class sdk_lightmappedgeneric_basetextureblend_Static_Index +{ +public: + sdk_lightmappedgeneric_basetextureblend_Static_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +class sdk_lightmappedgeneric_basetextureblend_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_lightmappedgeneric_basetextureblend_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_lightmappedgeneric_bumpmappedenvmap.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_lightmappedgeneric_bumpmappedenvmap.inc new file mode 100644 index 00000000..0a3be2ed --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_lightmappedgeneric_bumpmappedenvmap.inc @@ -0,0 +1,57 @@ +class sdk_lightmappedgeneric_bumpmappedenvmap_Static_Index +{ +public: + sdk_lightmappedgeneric_bumpmappedenvmap_Static_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +class sdk_lightmappedgeneric_bumpmappedenvmap_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_lightmappedgeneric_bumpmappedenvmap_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_lightmappedgeneric_bumpmappedenvmap_ps14.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_lightmappedgeneric_bumpmappedenvmap_ps14.inc new file mode 100644 index 00000000..991951a2 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_lightmappedgeneric_bumpmappedenvmap_ps14.inc @@ -0,0 +1,57 @@ +class sdk_lightmappedgeneric_bumpmappedenvmap_ps14_Static_Index +{ +public: + sdk_lightmappedgeneric_bumpmappedenvmap_ps14_Static_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +class sdk_lightmappedgeneric_bumpmappedenvmap_ps14_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_lightmappedgeneric_bumpmappedenvmap_ps14_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_lightmappedgeneric_bumpmappedlightmap.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_lightmappedgeneric_bumpmappedlightmap.inc new file mode 100644 index 00000000..236d3876 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_lightmappedgeneric_bumpmappedlightmap.inc @@ -0,0 +1,57 @@ +class sdk_lightmappedgeneric_bumpmappedlightmap_Static_Index +{ +public: + sdk_lightmappedgeneric_bumpmappedlightmap_Static_Index() + { + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG +#endif // _DEBUG + return 0; + } +}; +class sdk_lightmappedgeneric_bumpmappedlightmap_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_lightmappedgeneric_bumpmappedlightmap_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_lightmappedgeneric_vs11.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_lightmappedgeneric_vs11.inc new file mode 100644 index 00000000..d9b2a9f3 --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_lightmappedgeneric_vs11.inc @@ -0,0 +1,175 @@ +class sdk_lightmappedgeneric_vs11_Static_Index +{ +private: + int m_nDETAIL; +#ifdef _DEBUG + bool m_bDETAIL; +#endif +public: + void SetDETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL = i; +#ifdef _DEBUG + m_bDETAIL = true; +#endif + } + void SetDETAIL( bool i ) + { + m_nDETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL = true; +#endif + } +private: + int m_nENVMAP; +#ifdef _DEBUG + bool m_bENVMAP; +#endif +public: + void SetENVMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAP = i; +#ifdef _DEBUG + m_bENVMAP = true; +#endif + } + void SetENVMAP( bool i ) + { + m_nENVMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAP = true; +#endif + } +private: + int m_nENVMAPCAMERASPACE; +#ifdef _DEBUG + bool m_bENVMAPCAMERASPACE; +#endif +public: + void SetENVMAPCAMERASPACE( int i ) + { + } + void SetENVMAPCAMERASPACE( bool i ) + { + } +private: + int m_nENVMAPSPHERE; +#ifdef _DEBUG + bool m_bENVMAPSPHERE; +#endif +public: + void SetENVMAPSPHERE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPSPHERE = i; +#ifdef _DEBUG + m_bENVMAPSPHERE = true; +#endif + } + void SetENVMAPSPHERE( bool i ) + { + m_nENVMAPSPHERE = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAPSPHERE = true; +#endif + } +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +public: + sdk_lightmappedgeneric_vs11_Static_Index() + { +#ifdef _DEBUG + m_bDETAIL = false; +#endif // _DEBUG + m_nDETAIL = 0; +#ifdef _DEBUG + m_bENVMAP = false; +#endif // _DEBUG + m_nENVMAP = 0; +#ifdef _DEBUG + m_bENVMAPCAMERASPACE = true; +#endif // _DEBUG + m_nENVMAPCAMERASPACE = 0; +#ifdef _DEBUG + m_bENVMAPSPHERE = false; +#endif // _DEBUG + m_nENVMAPSPHERE = 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bDETAIL && m_bENVMAP && m_bENVMAPCAMERASPACE && m_bENVMAPSPHERE && m_bVERTEXCOLOR; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nDETAIL ) + ( 4 * m_nENVMAP ) + ( 8 * m_nENVMAPCAMERASPACE ) + ( 8 * m_nENVMAPSPHERE ) + ( 16 * m_nVERTEXCOLOR ) + 0; + } +}; +class sdk_lightmappedgeneric_vs11_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +public: + sdk_lightmappedgeneric_vs11_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_unlitgeneric_vs11.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_unlitgeneric_vs11.inc new file mode 100644 index 00000000..78d7d89f --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_unlitgeneric_vs11.inc @@ -0,0 +1,225 @@ +class sdk_unlitgeneric_vs11_Static_Index +{ +private: + int m_nDETAIL; +#ifdef _DEBUG + bool m_bDETAIL; +#endif +public: + void SetDETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL = i; +#ifdef _DEBUG + m_bDETAIL = true; +#endif + } + void SetDETAIL( bool i ) + { + m_nDETAIL = i ? 1 : 0; +#ifdef _DEBUG + m_bDETAIL = true; +#endif + } +private: + int m_nENVMAP; +#ifdef _DEBUG + bool m_bENVMAP; +#endif +public: + void SetENVMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAP = i; +#ifdef _DEBUG + m_bENVMAP = true; +#endif + } + void SetENVMAP( bool i ) + { + m_nENVMAP = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAP = true; +#endif + } +private: + int m_nENVMAPCAMERASPACE; +#ifdef _DEBUG + bool m_bENVMAPCAMERASPACE; +#endif +public: + void SetENVMAPCAMERASPACE( int i ) + { + } + void SetENVMAPCAMERASPACE( bool i ) + { + } +private: + int m_nENVMAPSPHERE; +#ifdef _DEBUG + bool m_bENVMAPSPHERE; +#endif +public: + void SetENVMAPSPHERE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPSPHERE = i; +#ifdef _DEBUG + m_bENVMAPSPHERE = true; +#endif + } + void SetENVMAPSPHERE( bool i ) + { + m_nENVMAPSPHERE = i ? 1 : 0; +#ifdef _DEBUG + m_bENVMAPSPHERE = true; +#endif + } +private: + int m_nVERTEXCOLOR; +#ifdef _DEBUG + bool m_bVERTEXCOLOR; +#endif +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } + void SetVERTEXCOLOR( bool i ) + { + m_nVERTEXCOLOR = i ? 1 : 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif + } +private: + int m_nSEPARATEDETAILUVS; +#ifdef _DEBUG + bool m_bSEPARATEDETAILUVS; +#endif +public: + void SetSEPARATEDETAILUVS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEPARATEDETAILUVS = i; +#ifdef _DEBUG + m_bSEPARATEDETAILUVS = true; +#endif + } + void SetSEPARATEDETAILUVS( bool i ) + { + m_nSEPARATEDETAILUVS = i ? 1 : 0; +#ifdef _DEBUG + m_bSEPARATEDETAILUVS = true; +#endif + } +public: + sdk_unlitgeneric_vs11_Static_Index() + { +#ifdef _DEBUG + m_bDETAIL = false; +#endif // _DEBUG + m_nDETAIL = 0; +#ifdef _DEBUG + m_bENVMAP = false; +#endif // _DEBUG + m_nENVMAP = 0; +#ifdef _DEBUG + m_bENVMAPCAMERASPACE = true; +#endif // _DEBUG + m_nENVMAPCAMERASPACE = 0; +#ifdef _DEBUG + m_bENVMAPSPHERE = false; +#endif // _DEBUG + m_nENVMAPSPHERE = 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = false; +#endif // _DEBUG + m_nVERTEXCOLOR = 0; +#ifdef _DEBUG + m_bSEPARATEDETAILUVS = false; +#endif // _DEBUG + m_nSEPARATEDETAILUVS = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bDETAIL && m_bENVMAP && m_bENVMAPCAMERASPACE && m_bENVMAPSPHERE && m_bVERTEXCOLOR && m_bSEPARATEDETAILUVS; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nDETAIL ) + ( 8 * m_nENVMAP ) + ( 16 * m_nENVMAPCAMERASPACE ) + ( 16 * m_nENVMAPSPHERE ) + ( 32 * m_nVERTEXCOLOR ) + ( 64 * m_nSEPARATEDETAILUVS ) + 0; + } +}; +class sdk_unlitgeneric_vs11_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_unlitgeneric_vs11_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + ( 2 * m_nSKINNING ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/vshtmp9/SDK_vertexlitgeneric_flashlight_vs11.inc b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_vertexlitgeneric_flashlight_vs11.inc new file mode 100644 index 00000000..03b6a0ca --- /dev/null +++ b/sp/src/materialsystem/stdshaders/vshtmp9/SDK_vertexlitgeneric_flashlight_vs11.inc @@ -0,0 +1,109 @@ +class sdk_vertexlitgeneric_flashlight_vs11_Static_Index +{ +private: + int m_nTEETH; +#ifdef _DEBUG + bool m_bTEETH; +#endif +public: + void SetTEETH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nTEETH = i; +#ifdef _DEBUG + m_bTEETH = true; +#endif + } + void SetTEETH( bool i ) + { + m_nTEETH = i ? 1 : 0; +#ifdef _DEBUG + m_bTEETH = true; +#endif + } +public: + sdk_vertexlitgeneric_flashlight_vs11_Static_Index() + { +#ifdef _DEBUG + m_bTEETH = false; +#endif // _DEBUG + m_nTEETH = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllStaticVarsDefined = m_bTEETH; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 4 * m_nTEETH ) + 0; + } +}; +class sdk_vertexlitgeneric_flashlight_vs11_Dynamic_Index +{ +private: + int m_nDOWATERFOG; +#ifdef _DEBUG + bool m_bDOWATERFOG; +#endif +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } + void SetDOWATERFOG( bool i ) + { + m_nDOWATERFOG = i ? 1 : 0; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif + } +private: + int m_nSKINNING; +#ifdef _DEBUG + bool m_bSKINNING; +#endif +public: + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } + void SetSKINNING( bool i ) + { + m_nSKINNING = i ? 1 : 0; +#ifdef _DEBUG + m_bSKINNING = true; +#endif + } +public: + sdk_vertexlitgeneric_flashlight_vs11_Dynamic_Index() + { +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bSKINNING = false; +#endif // _DEBUG + m_nSKINNING = 0; + } + int GetIndex() + { + // Asserts to make sure that we aren't using any skipped combinations. + // Asserts to make sure that we are setting all of the combination vars. +#ifdef _DEBUG + bool bAllDynamicVarsDefined = m_bDOWATERFOG && m_bSKINNING; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nDOWATERFOG ) + ( 2 * m_nSKINNING ) + 0; + } +}; diff --git a/sp/src/materialsystem/stdshaders/water.cpp b/sp/src/materialsystem/stdshaders/water.cpp index 92a26375..74374334 100644 --- a/sp/src/materialsystem/stdshaders/water.cpp +++ b/sp/src/materialsystem/stdshaders/water.cpp @@ -10,21 +10,21 @@ #include "common_hlsl_cpp_consts.h" // hack hack hack! #include "convar.h" -#include "WaterCheap_vs20.inc" -#include "WaterCheap_ps20.inc" -#include "WaterCheap_ps20b.inc" -#include "Water_vs20.inc" -#include "Water_ps20.inc" -#include "water_ps20b.inc" +#include "SDK_WaterCheap_vs20.inc" +#include "SDK_WaterCheap_ps20.inc" +#include "SDK_WaterCheap_ps20b.inc" +#include "sdk_water_vs20.inc" +#include "SDK_Water_ps20.inc" +#include "sdk_water_ps20b.inc" #ifndef _X360 static ConVar r_waterforceexpensive( "r_waterforceexpensive", "0", FCVAR_ARCHIVE ); #endif -DEFINE_FALLBACK_SHADER( Water, Water_DX9_HDR ) +DEFINE_FALLBACK_SHADER( SDK_Water, SDK_Water_DX9_HDR ) -BEGIN_VS_SHADER( Water_DX90, - "Help for Water" ) +BEGIN_VS_SHADER( SDK_Water_DX90, + "Help for SDK_Water" ) BEGIN_SHADER_PARAMS SHADER_PARAM( REFRACTTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_WaterRefraction", "" ) @@ -236,17 +236,17 @@ BEGIN_VS_SHADER( Water_DX90, } } - DECLARE_STATIC_VERTEX_SHADER( water_vs20 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_water_vs20 ); SET_STATIC_VERTEX_SHADER_COMBO( MULTITEXTURE,fabs(Scroll1.x) > 0.0); SET_STATIC_VERTEX_SHADER_COMBO( BASETEXTURE, params[BASETEXTURE]->IsTexture() ); - SET_STATIC_VERTEX_SHADER( water_vs20 ); + SET_STATIC_VERTEX_SHADER( sdk_water_vs20 ); // "REFLECT" "0..1" // "REFRACT" "0..1" if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_STATIC_PIXEL_SHADER( water_ps20b ); + DECLARE_STATIC_PIXEL_SHADER( sdk_water_ps20b ); SET_STATIC_PIXEL_SHADER_COMBO( REFLECT, bReflection ); SET_STATIC_PIXEL_SHADER_COMBO( REFRACT, bRefraction ); SET_STATIC_PIXEL_SHADER_COMBO( ABOVEWATER, params[ABOVEWATER]->GetIntValue() ); @@ -254,18 +254,18 @@ BEGIN_VS_SHADER( Water_DX90, SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURE, params[BASETEXTURE]->IsTexture() ); SET_STATIC_PIXEL_SHADER_COMBO( BLURRY_REFRACT, params[BLURREFRACT]->GetIntValue() ); SET_STATIC_PIXEL_SHADER_COMBO( NORMAL_DECODE_MODE, (int) nNormalDecodeMode ); - SET_STATIC_PIXEL_SHADER( water_ps20b ); + SET_STATIC_PIXEL_SHADER( sdk_water_ps20b ); } else { - DECLARE_STATIC_PIXEL_SHADER( water_ps20 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_water_ps20 ); SET_STATIC_PIXEL_SHADER_COMBO( REFLECT, bReflection ); SET_STATIC_PIXEL_SHADER_COMBO( REFRACT, bRefraction ); SET_STATIC_PIXEL_SHADER_COMBO( ABOVEWATER, params[ABOVEWATER]->GetIntValue() ); SET_STATIC_PIXEL_SHADER_COMBO( MULTITEXTURE,fabs(Scroll1.x) > 0.0); SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURE, params[BASETEXTURE]->IsTexture() ); SET_STATIC_PIXEL_SHADER_COMBO( NORMAL_DECODE_MODE, (int) nNormalDecodeMode ); - SET_STATIC_PIXEL_SHADER( water_ps20 ); + SET_STATIC_PIXEL_SHADER( sdk_water_ps20 ); } FogToFogColor(); @@ -368,21 +368,26 @@ BEGIN_VS_SHADER( Water_DX90, pShaderAPI->SetPixelShaderFogParams( 8 ); - DECLARE_DYNAMIC_VERTEX_SHADER( water_vs20 ); - SET_DYNAMIC_VERTEX_SHADER( water_vs20 ); + float vEyePos[4]; + pShaderAPI->GetWorldSpaceCameraPosition( vEyePos ); + vEyePos[3] = 0.0f; + pShaderAPI->SetPixelShaderConstant( 9, vEyePos ); + + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_water_vs20 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_water_vs20 ); if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_DYNAMIC_PIXEL_SHADER( water_ps20b ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_water_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, pShaderAPI->ShouldWriteDepthToDestAlpha() ); - SET_DYNAMIC_PIXEL_SHADER( water_ps20b ); + SET_DYNAMIC_PIXEL_SHADER( sdk_water_ps20b ); } else { - DECLARE_DYNAMIC_PIXEL_SHADER( water_ps20 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_water_ps20 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - SET_DYNAMIC_PIXEL_SHADER( water_ps20 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_water_ps20 ); } } Draw(); @@ -430,13 +435,13 @@ BEGIN_VS_SHADER( Water_DX90, } } - DECLARE_STATIC_VERTEX_SHADER( watercheap_vs20 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_watercheap_vs20 ); SET_STATIC_VERTEX_SHADER_COMBO( BLEND, bBlend && bRefraction ); - SET_STATIC_VERTEX_SHADER( watercheap_vs20 ); + SET_STATIC_VERTEX_SHADER( sdk_watercheap_vs20 ); if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_STATIC_PIXEL_SHADER( watercheap_ps20b ); + DECLARE_STATIC_PIXEL_SHADER( sdk_watercheap_ps20b ); SET_STATIC_PIXEL_SHADER_COMBO( FRESNEL, params[NOFRESNEL]->GetIntValue() == 0 ); SET_STATIC_PIXEL_SHADER_COMBO( BLEND, bBlend ); SET_STATIC_PIXEL_SHADER_COMBO( REFRACTALPHA, bRefraction ); @@ -445,11 +450,11 @@ BEGIN_VS_SHADER( Water_DX90, params[SCROLL1]->GetVecValue( Scroll1.Base(), 4 ); SET_STATIC_PIXEL_SHADER_COMBO( MULTITEXTURE,fabs(Scroll1.x) > 0.0); SET_STATIC_PIXEL_SHADER_COMBO( NORMAL_DECODE_MODE, (int) nNormalDecodeMode ); - SET_STATIC_PIXEL_SHADER( watercheap_ps20b ); + SET_STATIC_PIXEL_SHADER( sdk_watercheap_ps20b ); } else { - DECLARE_STATIC_PIXEL_SHADER( watercheap_ps20 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_watercheap_ps20 ); SET_STATIC_PIXEL_SHADER_COMBO( FRESNEL, params[NOFRESNEL]->GetIntValue() == 0 ); SET_STATIC_PIXEL_SHADER_COMBO( BLEND, bBlend ); SET_STATIC_PIXEL_SHADER_COMBO( REFRACTALPHA, bRefraction ); @@ -458,7 +463,7 @@ BEGIN_VS_SHADER( Water_DX90, params[SCROLL1]->GetVecValue( Scroll1.Base(), 4 ); SET_STATIC_PIXEL_SHADER_COMBO( MULTITEXTURE,fabs(Scroll1.x) > 0.0); SET_STATIC_PIXEL_SHADER_COMBO( NORMAL_DECODE_MODE, (int) nNormalDecodeMode ); - SET_STATIC_PIXEL_SHADER( watercheap_ps20 ); + SET_STATIC_PIXEL_SHADER( sdk_watercheap_ps20 ); } // HDRFIXME: test cheap water! @@ -495,6 +500,11 @@ BEGIN_VS_SHADER( Water_DX90, }; pShaderAPI->SetPixelShaderConstant( 1, cheapWaterParams ); + float vEyePos[4]; + pShaderAPI->GetWorldSpaceCameraPosition( vEyePos ); + vEyePos[3] = 0.0f; + pShaderAPI->SetPixelShaderConstant( 4, vEyePos ); + if( g_pConfig->bShowSpecular ) { SetPixelShaderConstant( 2, REFLECTTINT, REFLECTBLENDFACTOR ); @@ -521,22 +531,22 @@ BEGIN_VS_SHADER( Water_DX90, pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_3, vc0, 1 ); } - DECLARE_DYNAMIC_VERTEX_SHADER( watercheap_vs20 ); - SET_DYNAMIC_VERTEX_SHADER( watercheap_vs20 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_watercheap_vs20 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_watercheap_vs20 ); if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_DYNAMIC_PIXEL_SHADER( watercheap_ps20b ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_watercheap_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( HDRENABLED, IsHDREnabled() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - SET_DYNAMIC_PIXEL_SHADER( watercheap_ps20b ); + SET_DYNAMIC_PIXEL_SHADER( sdk_watercheap_ps20b ); } else { - DECLARE_DYNAMIC_PIXEL_SHADER( watercheap_ps20 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_watercheap_ps20 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( HDRENABLED, IsHDREnabled() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - SET_DYNAMIC_PIXEL_SHADER( watercheap_ps20 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_watercheap_ps20 ); } } Draw(); @@ -599,14 +609,14 @@ END_SHADER //----------------------------------------------------------------------------- // This allows us to use a block labelled 'Water_DX9_HDR' in the water materials //----------------------------------------------------------------------------- -BEGIN_INHERITED_SHADER( Water_DX9_HDR, Water_DX90, - "Help for Water_DX9_HDR" ) +BEGIN_INHERITED_SHADER( SDK_Water_DX9_HDR, SDK_Water_DX90, + "Help for SDK_Water_DX9_HDR" ) SHADER_FALLBACK { if( g_pHardwareConfig->GetHDRType() == HDR_TYPE_NONE ) { - return "WATER_DX90"; + return "SDK_WATER_DX90"; } return 0; } diff --git a/sp/src/materialsystem/stdshaders/water_ps2x_helper.h b/sp/src/materialsystem/stdshaders/water_ps2x_helper.h index b15b9986..ba5f214b 100644 --- a/sp/src/materialsystem/stdshaders/water_ps2x_helper.h +++ b/sp/src/materialsystem/stdshaders/water_ps2x_helper.h @@ -23,6 +23,8 @@ struct DrawWater_params_t float4 pixelFogParams; float fWaterFogStart; float fWaterFogEndMinusStart; + float3 vEyePos; + float3 vWorldPos; }; void DrawWater( in DrawWater_params_t i, @@ -232,7 +234,7 @@ void DrawWater( in DrawWater_params_t i, } #if (PIXELFOGTYPE == PIXEL_FOG_TYPE_RANGE) - fogFactor = CalcRangeFog( i.vProjPos.z, i.pixelFogParams.x, i.pixelFogParams.z, i.pixelFogParams.w ); + fogFactor = CalcRangeFogFactorNonFixedFunction( i.vWorldPos, i.vEyePos, i.pixelFogParams.z, i.pixelFogParams.x, i.pixelFogParams.w ); #else fogFactor = 0; #endif diff --git a/sp/src/materialsystem/stdshaders/worldtwotextureblend.cpp b/sp/src/materialsystem/stdshaders/worldtwotextureblend.cpp index 542013e0..f90b9662 100644 --- a/sp/src/materialsystem/stdshaders/worldtwotextureblend.cpp +++ b/sp/src/materialsystem/stdshaders/worldtwotextureblend.cpp @@ -10,9 +10,9 @@ #include "convar.h" -#include "lightmappedgeneric_vs20.inc" -#include "WorldTwoTextureBlend_ps20.inc" -#include "WorldTwoTextureBlend_ps20b.inc" +#include "SDK_lightmappedgeneric_vs20.inc" +#include "SDK_WorldTwoTextureBlend_ps20.inc" +#include "SDK_WorldTwoTextureBlend_ps20b.inc" // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -20,8 +20,8 @@ extern ConVar r_flashlight_version2; // FIXME: Need to make a dx9 version so that "CENTROID" works. -BEGIN_VS_SHADER( WorldTwoTextureBlend, - "Help for WorldTwoTextureBlend" ) +BEGIN_VS_SHADER( SDK_WorldTwoTextureBlend, + "Help for SDK_WorldTwoTextureBlend" ) BEGIN_SHADER_PARAMS SHADER_PARAM_OVERRIDE( BASETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/WorldTwoTextureBlend", "iris texture", 0 ) @@ -246,7 +246,7 @@ END_SHADER_PARAMS pShaderShadow->EnableSRGBWrite( true ); - DECLARE_STATIC_VERTEX_SHADER( lightmappedgeneric_vs20 ); + DECLARE_STATIC_VERTEX_SHADER( sdk_lightmappedgeneric_vs20 ); SET_STATIC_VERTEX_SHADER_COMBO( ENVMAP_MASK, false ); SET_STATIC_VERTEX_SHADER_COMBO( BUMPMASK, false ); SET_STATIC_VERTEX_SHADER_COMBO( TANGENTSPACE, hasFlashlight ); @@ -259,11 +259,14 @@ END_SHADER_PARAMS #ifdef _X360 SET_STATIC_VERTEX_SHADER_COMBO( FLASHLIGHT, hasFlashlight ); #endif - SET_STATIC_VERTEX_SHADER( lightmappedgeneric_vs20 ); +#ifdef MAPBASE + SET_STATIC_VERTEX_SHADER_COMBO( BASETEXTURETRANSFORM2, false ); +#endif + SET_STATIC_VERTEX_SHADER( sdk_lightmappedgeneric_vs20 ); if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_STATIC_PIXEL_SHADER( worldtwotextureblend_ps20b ); + DECLARE_STATIC_PIXEL_SHADER( sdk_worldtwotextureblend_ps20b ); SET_STATIC_PIXEL_SHADER_COMBO( DETAILTEXTURE, hasDetailTexture ); SET_STATIC_PIXEL_SHADER_COMBO( BUMPMAP, hasBump ); SET_STATIC_PIXEL_SHADER_COMBO( DIFFUSEBUMPMAP, hasDiffuseBumpmap ); @@ -273,11 +276,11 @@ END_SHADER_PARAMS SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHT, hasFlashlight ); SET_STATIC_PIXEL_SHADER_COMBO( SEAMLESS, bSeamlessMapping ); SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, nShadowFilterMode ); - SET_STATIC_PIXEL_SHADER( worldtwotextureblend_ps20b ); + SET_STATIC_PIXEL_SHADER( sdk_worldtwotextureblend_ps20b ); } else { - DECLARE_STATIC_PIXEL_SHADER( worldtwotextureblend_ps20 ); + DECLARE_STATIC_PIXEL_SHADER( sdk_worldtwotextureblend_ps20 ); SET_STATIC_PIXEL_SHADER_COMBO( DETAILTEXTURE, hasDetailTexture ); SET_STATIC_PIXEL_SHADER_COMBO( BUMPMAP, hasBump ); SET_STATIC_PIXEL_SHADER_COMBO( DIFFUSEBUMPMAP, hasDiffuseBumpmap ); @@ -286,7 +289,7 @@ END_SHADER_PARAMS SET_STATIC_PIXEL_SHADER_COMBO( DETAIL_ALPHA_MASK_BASE_TEXTURE, bHasDetailAlpha ); SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHT, hasFlashlight ); SET_STATIC_PIXEL_SHADER_COMBO( SEAMLESS, bSeamlessMapping ); - SET_STATIC_PIXEL_SHADER( worldtwotextureblend_ps20 ); + SET_STATIC_PIXEL_SHADER( sdk_worldtwotextureblend_ps20 ); } // HACK HACK HACK - enable alpha writes all the time so that we have them for @@ -387,12 +390,12 @@ END_SHADER_PARAMS } MaterialFogMode_t fogType = pShaderAPI->GetSceneFogMode(); - DECLARE_DYNAMIC_VERTEX_SHADER( lightmappedgeneric_vs20 ); + DECLARE_DYNAMIC_VERTEX_SHADER( sdk_lightmappedgeneric_vs20 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); SET_DYNAMIC_VERTEX_SHADER_COMBO( FASTPATH, bVertexShaderFastPath ); SET_DYNAMIC_VERTEX_SHADER_COMBO( LIGHTING_PREVIEW, pShaderAPI->GetIntRenderingParameter(INT_RENDERPARM_ENABLE_FIXED_LIGHTING)!=0); - SET_DYNAMIC_VERTEX_SHADER( lightmappedgeneric_vs20 ); + SET_DYNAMIC_VERTEX_SHADER( sdk_lightmappedgeneric_vs20 ); bool bWriteDepthToAlpha; bool bWriteWaterFogToAlpha; @@ -412,24 +415,24 @@ END_SHADER_PARAMS if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - DECLARE_DYNAMIC_PIXEL_SHADER( worldtwotextureblend_ps20b ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_worldtwotextureblend_ps20b ); // Don't write fog to alpha if we're using translucency SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITEWATERFOGTODESTALPHA, bWriteWaterFogToAlpha ); SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, bWriteDepthToAlpha ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, bFlashlightShadows ); - SET_DYNAMIC_PIXEL_SHADER( worldtwotextureblend_ps20b ); + SET_DYNAMIC_PIXEL_SHADER( sdk_worldtwotextureblend_ps20b ); } else { - DECLARE_DYNAMIC_PIXEL_SHADER( worldtwotextureblend_ps20 ); + DECLARE_DYNAMIC_PIXEL_SHADER( sdk_worldtwotextureblend_ps20 ); // Don't write fog to alpha if we're using translucency SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITEWATERFOGTODESTALPHA, (fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z) && (nBlendType != BT_BLENDADD) && (nBlendType != BT_BLEND) && !bIsAlphaTested ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); - SET_DYNAMIC_PIXEL_SHADER( worldtwotextureblend_ps20 ); + SET_DYNAMIC_PIXEL_SHADER( sdk_worldtwotextureblend_ps20 ); } @@ -484,6 +487,8 @@ END_SHADER_PARAMS SHADER_DRAW { + ConVarRef r_flashlight_version2 = ConVarRef( "r_flashlight_version2" ); + bool bHasFlashlight = UsingFlashlight( params ); if ( bHasFlashlight && ( IsX360() || r_flashlight_version2.GetInt() ) ) { diff --git a/sp/src/materialsystem/stdshaders/worldvertextransition.cpp b/sp/src/materialsystem/stdshaders/worldvertextransition.cpp index e7d6a9ab..b5828837 100644 --- a/sp/src/materialsystem/stdshaders/worldvertextransition.cpp +++ b/sp/src/materialsystem/stdshaders/worldvertextransition.cpp @@ -9,15 +9,17 @@ #include "BaseVSShader.h" #include "convar.h" -#include "worldvertextransition_dx8_helper.h" +//#include "worldvertextransition_dx8_helper.h" #include "lightmappedgeneric_dx9_helper.h" static LightmappedGeneric_DX9_Vars_t s_info; +static LightmappedGeneric_DX9_Vars_t s_info_editor; -DEFINE_FALLBACK_SHADER( WorldVertexTransition, WorldVertexTransition_DX9 ) -BEGIN_VS_SHADER( WorldVertexTransition_DX9, "Help for WorldVertexTransition" ) +DEFINE_FALLBACK_SHADER( SDK_WorldVertexTransition, SDK_WorldVertexTransition_DX9 ) + +BEGIN_VS_SHADER( SDK_WorldVertexTransition_DX9, "Help for SDK_WorldVertexTransition" ) BEGIN_SHADER_PARAMS SHADER_PARAM( ALBEDO, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "albedo (Base texture with no baked lighting)" ) @@ -50,6 +52,10 @@ BEGIN_VS_SHADER( WorldVertexTransition_DX9, "Help for WorldVertexTransition" ) SHADER_PARAM( BUMPMASK, SHADER_PARAM_TYPE_TEXTURE, "models/shadertest/shader1_normal", "bump map" ) SHADER_PARAM( BASETEXTURE2, SHADER_PARAM_TYPE_TEXTURE, "shadertest/detail", "detail texture" ) SHADER_PARAM( FRAME2, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for $basetexture2" ) +#ifdef MAPBASE + // This needs to be a SHADER_PARAM_TYPE_STRING so it isn't considered "defined" by default. + SHADER_PARAM( BASETEXTURETRANSFORM2, SHADER_PARAM_TYPE_STRING, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "$basetexture2 texcoord transform" ) +#endif SHADER_PARAM( BASETEXTURENOENVMAP, SHADER_PARAM_TYPE_BOOL, "0", "" ) SHADER_PARAM( BASETEXTURE2NOENVMAP, SHADER_PARAM_TYPE_BOOL, "0", "" ) SHADER_PARAM( DETAIL_ALPHA_MASK_BASE_TEXTURE, SHADER_PARAM_TYPE_BOOL, "0", @@ -61,17 +67,12 @@ BEGIN_VS_SHADER( WorldVertexTransition_DX9, "Help for WorldVertexTransition" ) SHADER_PARAM( MASKEDBLENDING, SHADER_PARAM_TYPE_INTEGER, "0", "blend using texture with no vertex alpha. For using texture blending on non-displacements" ) SHADER_PARAM( SSBUMP, SHADER_PARAM_TYPE_INTEGER, "0", "whether or not to use alternate bumpmap format with height" ) SHADER_PARAM( SEAMLESS_SCALE, SHADER_PARAM_TYPE_FLOAT, "0", "Scale factor for 'seamless' texture mapping. 0 means to use ordinary mapping" ) - END_SHADER_PARAMS - void SetupVars( WorldVertexTransitionEditor_DX8_Vars_t& info ) - { - info.m_nBaseTextureVar = BASETEXTURE; - info.m_nBaseTextureFrameVar = FRAME; - info.m_nBaseTextureTransformVar = BASETEXTURETRANSFORM; - info.m_nBaseTexture2Var = BASETEXTURE2; - info.m_nBaseTexture2FrameVar = FRAME2; - info.m_nBaseTexture2TransformVar = BASETEXTURETRANSFORM; // FIXME!!!! - } + SHADER_PARAM( PHONG, SHADER_PARAM_TYPE_BOOL, "0", "enables phong lighting" ) + SHADER_PARAM( PHONGBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "Phong overbrightening factor (specular mask channel should be authored to account for this)" ) + SHADER_PARAM( PHONGFRESNELRANGES, SHADER_PARAM_TYPE_VEC3, "[0 0.5 1]", "Parameters for remapping fresnel output" ) + SHADER_PARAM( PHONGEXPONENT, SHADER_PARAM_TYPE_FLOAT, "5.0", "Phong exponent for local specular lights" ) + END_SHADER_PARAMS void SetupVars( LightmappedGeneric_DX9_Vars_t& info ) { @@ -105,6 +106,9 @@ BEGIN_VS_SHADER( WorldVertexTransition_DX9, "Help for WorldVertexTransition" ) info.m_nBumpFrame2 = BUMPFRAME2; info.m_nBaseTexture2 = BASETEXTURE2; info.m_nBaseTexture2Frame = FRAME2; +#ifdef MAPBASE + info.m_nBaseTexture2Transform = BASETEXTURETRANSFORM2; +#endif info.m_nBumpTransform2 = BUMPTRANSFORM2; info.m_nBumpMask = BUMPMASK; info.m_nBaseTextureNoEnvmap = BASETEXTURENOENVMAP; @@ -119,6 +123,11 @@ BEGIN_VS_SHADER( WorldVertexTransition_DX9, "Help for WorldVertexTransition" ) info.m_nSelfShadowedBumpFlag = SSBUMP; info.m_nSeamlessMappingScale = SEAMLESS_SCALE; info.m_nAlphaTestReference = -1; + + info.m_nPhong = PHONG; + info.m_nPhongBoost = PHONGBOOST; + info.m_nPhongFresnelRanges = PHONGFRESNELRANGES; + info.m_nPhongExponent = PHONGEXPONENT; } SHADER_FALLBACK @@ -133,6 +142,8 @@ BEGIN_VS_SHADER( WorldVertexTransition_DX9, "Help for WorldVertexTransition" ) { SetupVars( s_info ); InitParamsLightmappedGeneric_DX9( this, params, pMaterialName, s_info ); + SetupVars( s_info_editor ); + SwapLayers( s_info_editor ); } SHADER_INIT @@ -144,14 +155,29 @@ BEGIN_VS_SHADER( WorldVertexTransition_DX9, "Help for WorldVertexTransition" ) SHADER_DRAW { if ( UsingEditor( params ) ) - { - WorldVertexTransitionEditor_DX8_Vars_t info; - SetupVars( info ); - DrawWorldVertexTransitionEditor_DX8( this, params, pShaderAPI, pShaderShadow, info ); - return; - } + DrawLightmappedGeneric_DX9( this, params, pShaderAPI, pShaderShadow, s_info_editor, pContextDataPtr ); + else + DrawLightmappedGeneric_DX9( this, params, pShaderAPI, pShaderShadow, s_info, pContextDataPtr ); + } - DrawLightmappedGeneric_DX9( this, params, pShaderAPI, pShaderShadow, s_info, pContextDataPtr ); +private: + // This hack is from Half-Life 2: Downfall in order to support WorldVertexTransition in Hammer. + // Original comment: + // "Hack to make hammer display WVT in non-inverted way. + // It worked ok in standard WVT because of special editor-only shader. + // Why Valve just didn't inverted vertex alpha directly in hammer code? oO" + static FORCEINLINE void SwapLayers( LightmappedGeneric_DX9_Vars_t &info ) + { + V_swap( info.m_nBaseTexture, info.m_nBaseTexture2 ); + V_swap( info.m_nBaseTextureFrame, info.m_nBaseTexture2Frame ); + V_swap( info.m_nBaseTextureNoEnvmap, info.m_nBaseTexture2NoEnvmap ); + V_swap( info.m_nBumpmap, info.m_nBumpmap2 ); + V_swap( info.m_nBumpFrame, info.m_nBumpFrame2 ); + V_swap( info.m_nBumpTransform, info.m_nBumpTransform2 ); + + // I added this part myself, but it's no longer needed now that I've extended the hack into the actual shader code. + //info.m_nBlendModulateTexture = 0; + //info.m_nBlendMaskTransform = 0; } END_SHADER diff --git a/sp/src/materialsystem/stdshaders/worldvertextransition_dx8_helper.cpp b/sp/src/materialsystem/stdshaders/worldvertextransition_dx8_helper.cpp index 6a49fd71..cac439cc 100644 --- a/sp/src/materialsystem/stdshaders/worldvertextransition_dx8_helper.cpp +++ b/sp/src/materialsystem/stdshaders/worldvertextransition_dx8_helper.cpp @@ -8,7 +8,7 @@ #include "worldvertextransition_dx8_helper.h" #include "BaseVSShader.h" -#include "WorldVertexTransition.inc" +#include "SDK_WorldVertexTransition.inc" // memdbgon must be the last include file in a .cpp file!!! @@ -45,9 +45,9 @@ void DrawWorldVertexTransitionEditor_DX8( CBaseVSShader *pShader, IMaterialVar** int fmt = VERTEX_POSITION | VERTEX_COLOR; pShaderShadow->VertexShaderVertexFormat( fmt, 2, 0, 0 ); - worldvertextransition_Static_Index vshIndex; - pShaderShadow->SetVertexShader( "WorldVertexTransition", vshIndex.GetIndex() ); - pShaderShadow->SetPixelShader( "WorldVertexTransition_Editor" ); + sdk_worldvertextransition_Static_Index vshIndex; + pShaderShadow->SetVertexShader( "SDK_WorldVertexTransition", vshIndex.GetIndex() ); + pShaderShadow->SetPixelShader( "SDK_WorldVertexTransition_Editor" ); pShader->FogToFogColor(); } @@ -73,7 +73,7 @@ void DrawWorldVertexTransitionEditor_DX8( CBaseVSShader *pShader, IMaterialVar** pShader->SetVertexShaderTextureTransform( nTextureTransformConst, info.m_nBaseTextureTransformVar ); pShader->SetVertexShaderTextureTransform( nTextureTransformConst2, info.m_nBaseTexture2TransformVar ); - worldvertextransition_Dynamic_Index vshIndex; + sdk_worldvertextransition_Dynamic_Index vshIndex; vshIndex.SetDOWATERFOG( pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() ); } diff --git a/sp/src/public/discord_register.h b/sp/src/public/discord_register.h new file mode 100644 index 00000000..16fb42f3 --- /dev/null +++ b/sp/src/public/discord_register.h @@ -0,0 +1,26 @@ +#pragma once + +#if defined(DISCORD_DYNAMIC_LIB) +#if defined(_WIN32) +#if defined(DISCORD_BUILDING_SDK) +#define DISCORD_EXPORT __declspec(dllexport) +#else +#define DISCORD_EXPORT __declspec(dllimport) +#endif +#else +#define DISCORD_EXPORT __attribute__((visibility("default"))) +#endif +#else +#define DISCORD_EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +DISCORD_EXPORT void Discord_Register(const char* applicationId, const char* command); +DISCORD_EXPORT void Discord_RegisterSteamGame(const char* applicationId, const char* steamId); + +#ifdef __cplusplus +} +#endif diff --git a/sp/src/public/discord_rpc.h b/sp/src/public/discord_rpc.h new file mode 100644 index 00000000..3e1441e0 --- /dev/null +++ b/sp/src/public/discord_rpc.h @@ -0,0 +1,87 @@ +#pragma once +#include + +// clang-format off + +#if defined(DISCORD_DYNAMIC_LIB) +# if defined(_WIN32) +# if defined(DISCORD_BUILDING_SDK) +# define DISCORD_EXPORT __declspec(dllexport) +# else +# define DISCORD_EXPORT __declspec(dllimport) +# endif +# else +# define DISCORD_EXPORT __attribute__((visibility("default"))) +# endif +#else +# define DISCORD_EXPORT +#endif + +// clang-format on + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct DiscordRichPresence { + const char* state; /* max 128 bytes */ + const char* details; /* max 128 bytes */ + int64_t startTimestamp; + int64_t endTimestamp; + const char* largeImageKey; /* max 32 bytes */ + const char* largeImageText; /* max 128 bytes */ + const char* smallImageKey; /* max 32 bytes */ + const char* smallImageText; /* max 128 bytes */ + const char* partyId; /* max 128 bytes */ + int partySize; + int partyMax; + const char* matchSecret; /* max 128 bytes */ + const char* joinSecret; /* max 128 bytes */ + const char* spectateSecret; /* max 128 bytes */ + int8_t instance; +} DiscordRichPresence; + +typedef struct DiscordUser { + const char* userId; + const char* username; + const char* discriminator; + const char* avatar; +} DiscordUser; + +typedef struct DiscordEventHandlers { + void (*ready)(const DiscordUser* request); + void (*disconnected)(int errorCode, const char* message); + void (*errored)(int errorCode, const char* message); + void (*joinGame)(const char* joinSecret); + void (*spectateGame)(const char* spectateSecret); + void (*joinRequest)(const DiscordUser* request); +} DiscordEventHandlers; + +#define DISCORD_REPLY_NO 0 +#define DISCORD_REPLY_YES 1 +#define DISCORD_REPLY_IGNORE 2 + +DISCORD_EXPORT void Discord_Initialize(const char* applicationId, + DiscordEventHandlers* handlers, + int autoRegister, + const char* optionalSteamId); +DISCORD_EXPORT void Discord_Shutdown(void); + +/* checks for incoming messages, dispatches callbacks */ +DISCORD_EXPORT void Discord_RunCallbacks(void); + +/* If you disable the lib starting its own io thread, you'll need to call this from your own */ +#ifdef DISCORD_DISABLE_IO_THREAD +DISCORD_EXPORT void Discord_UpdateConnection(void); +#endif + +DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence* presence); +DISCORD_EXPORT void Discord_ClearPresence(void); + +DISCORD_EXPORT void Discord_Respond(const char* userid, /* DISCORD_REPLY_ */ int reply); + +DISCORD_EXPORT void Discord_UpdateHandlers(DiscordEventHandlers* handlers); + +#ifdef __cplusplus +} /* extern "C" */ +#endif diff --git a/sp/src/public/engine/ishadowmgr.h b/sp/src/public/engine/ishadowmgr.h index babac919..5165a8ab 100644 --- a/sp/src/public/engine/ishadowmgr.h +++ b/sp/src/public/engine/ishadowmgr.h @@ -40,6 +40,7 @@ enum ShadowFlags_t { SHADOW_FLAGS_FLASHLIGHT = (1 << 0), SHADOW_FLAGS_SHADOW = (1 << 1), + // Update this if you add flags SHADOW_FLAGS_LAST_FLAG = SHADOW_FLAGS_SHADOW }; diff --git a/sp/src/public/gamebspfile.h b/sp/src/public/gamebspfile.h index f8029bae..373368b7 100644 --- a/sp/src/public/gamebspfile.h +++ b/sp/src/public/gamebspfile.h @@ -139,6 +139,10 @@ enum STATIC_PROP_NO_SELF_SHADOWING = 0x80, // disable self shadowing in vrad +#ifdef MAPBASE + STATIC_PROP_OVERRIDE_PROPDATA = 0x100, +#endif + STATIC_PROP_WC_MASK = 0xd8, // all flags settable in hammer (?) }; diff --git a/sp/src/public/materialsystem/imaterialsystem.h b/sp/src/public/materialsystem/imaterialsystem.h index 812eb262..bd62f627 100644 --- a/sp/src/public/materialsystem/imaterialsystem.h +++ b/sp/src/public/materialsystem/imaterialsystem.h @@ -422,10 +422,22 @@ struct FlashlightState_t { m_bEnableShadows = false; // Provide reasonable defaults for shadow depth mapping parameters m_bDrawShadowFrustum = false; +#ifdef ASW_PROJECTED_TEXTURES + m_flShadowMapResolution = 2048.0f; + m_flShadowFilterSize = 0.5f; + m_flShadowSlopeScaleDepthBias = 16.0f; + m_flShadowDepthBias = 0.0005f; +#elif defined(MAPBASE) + m_flShadowMapResolution = 2048; + m_flShadowFilterSize = 1.0f; + m_flShadowSlopeScaleDepthBias = 4.0f; + m_flShadowDepthBias = 0.00001f; +#else m_flShadowMapResolution = 1024.0f; m_flShadowFilterSize = 3.0f; m_flShadowSlopeScaleDepthBias = 16.0f; m_flShadowDepthBias = 0.0005f; +#endif m_flShadowJitterSeed = 0.0f; m_flShadowAtten = 0.0f; m_bScissor = false; @@ -434,6 +446,16 @@ struct FlashlightState_t m_nRight = -1; m_nBottom = -1; m_nShadowQuality = 0; +#ifdef ASW_PROJECTED_TEXTURES + m_bOrtho = false; + m_fOrthoLeft = -1.0f; + m_fOrthoRight = 1.0f; + m_fOrthoTop = -1.0f; + m_fOrthoBottom = 1.0f; + + m_fBrightnessScale = 1.0f; + m_pSpotlightTexture = NULL; +#endif } Vector m_vecLightOrigin; @@ -460,6 +482,22 @@ struct FlashlightState_t float m_flShadowAtten; int m_nShadowQuality; +#ifdef ASW_PROJECTED_TEXTURES + bool m_bOrtho; + float m_fOrthoLeft; + float m_fOrthoRight; + float m_fOrthoTop; + float m_fOrthoBottom; + + float m_FarZAtten; + float m_fBrightnessScale; + bool m_bGlobalLight; +#endif + +#ifdef MAPBASE + bool m_bAlwaysDraw; +#endif + // Getters for scissor members bool DoScissor() { return m_bScissor; } int GetLeft() { return m_nLeft; } diff --git a/sp/src/public/mathlib/vector4d.h b/sp/src/public/mathlib/vector4d.h index 2b20c882..c5d0699f 100644 --- a/sp/src/public/mathlib/vector4d.h +++ b/sp/src/public/mathlib/vector4d.h @@ -41,9 +41,15 @@ public: Vector4D(void); Vector4D(vec_t X, vec_t Y, vec_t Z, vec_t W); Vector4D(const float *pFloat); +#ifdef MAPBASE + Vector4D(const Vector& vec, vec_t W); +#endif // Initialization void Init(vec_t ix=0.0f, vec_t iy=0.0f, vec_t iz=0.0f, vec_t iw=0.0f); +#ifdef MAPBASE + void Init( const Vector& vec, vec_t W ); +#endif // Got any nasty NAN's? bool IsValid() const; @@ -222,6 +228,14 @@ inline Vector4D::Vector4D(const float *pFloat) Assert( IsValid() ); } +#ifdef MAPBASE +inline Vector4D::Vector4D(const Vector& vec, vec_t W ) +{ + x = vec.x; y = vec.y; z = vec.z; w = W; + Assert( IsValid() ); +} +#endif + //----------------------------------------------------------------------------- // copy constructor @@ -243,6 +257,14 @@ inline void Vector4D::Init( vec_t ix, vec_t iy, vec_t iz, vec_t iw ) Assert( IsValid() ); } +#ifdef MAPBASE +inline void Vector4D::Init( const Vector& vec, vec_t iw ) +{ + x = vec.x; y = vec.y; z = vec.z; w = iw; + Assert( IsValid() ); +} +#endif + inline void Vector4D::Random( vec_t minVal, vec_t maxVal ) { x = minVal + ((vec_t)rand() / VALVE_RAND_MAX) * (maxVal - minVal); diff --git a/sp/src/public/renderparm.h b/sp/src/public/renderparm.h index a473c29b..51d11c6b 100644 --- a/sp/src/public/renderparm.h +++ b/sp/src/public/renderparm.h @@ -52,6 +52,9 @@ enum RenderParamInt_t INT_RENDERPARM_BACK_BUFFER_INDEX, + INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_FIRST, + INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_LAST = INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_FIRST + 4, + MAX_INT_RENDER_PARMS = 20 }; @@ -72,4 +75,9 @@ enum RenderParamTexture_t #define ENABLE_FIXED_LIGHTING_OUTPUTMRTS_FOR_DEFERRED_LIGHTING 2 #define ENABLE_FIXED_LIGHTING_OUTPUTNORMAL_AND_DEPTH 3 +enum RenderParamFloat_t +{ + FLOAT_RENDERPARM_MINIMUMLIGHTING = 0, +}; + #endif // RENDERPARM_H diff --git a/sp/src/public/rope_shared.h b/sp/src/public/rope_shared.h index 54c28829..fe79b6e6 100644 --- a/sp/src/public/rope_shared.h +++ b/sp/src/public/rope_shared.h @@ -28,7 +28,11 @@ #define ROPE_COLLIDE (1<<2) // Collide with the world? #define ROPE_SIMULATE (1<<3) // Is the rope valid? #define ROPE_BREAKABLE (1<<4) // Can the endpoints detach? +#ifdef MAPBASE +#define ROPE_USE_WIND (1<<5) // Wind simulation on this rope. +#else #define ROPE_NO_WIND (1<<5) // No wind simulation on this rope. +#endif #define ROPE_INITIAL_HANG (1<<6) // By default, ropes will simulate for a bit internally when they // are created so they sag, but dynamically created ropes for things // like harpoons don't want this. diff --git a/sp/src/public/stdstring.h b/sp/src/public/stdstring.h index c72320f7..50ed1c29 100644 --- a/sp/src/public/stdstring.h +++ b/sp/src/public/stdstring.h @@ -70,6 +70,15 @@ public: std::string *pString = (std::string *)fieldInfo.pField; return pString->empty(); } + +#ifdef MAPBASE + virtual bool Parse( const SaveRestoreFieldInfo_t &fieldInfo, char const* szValue ) + { + std::string *pString = (std::string *)fieldInfo.pField; + pString->assign(szValue); + return true; + } +#endif }; //------------------------------------- @@ -85,4 +94,9 @@ inline ISaveRestoreOps *GetStdStringDataOps() #define DEFINE_STDSTRING(name) \ { FIELD_CUSTOM, #name, { offsetof(classNameTypedef,name), 0 }, 1, FTYPEDESC_SAVE, NULL, GetStdStringDataOps(), NULL } +#ifdef MAPBASE +#define DEFINE_KEYSTDSTRING(name,mapname) \ + { FIELD_CUSTOM, #name, { offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE | FTYPEDESC_KEY, mapname, GetStdStringDataOps(), NULL } +#endif + #endif // STDSTRING_H diff --git a/sp/src/public/tier0/basetypes.h b/sp/src/public/tier0/basetypes.h index 22ce51bc..e8387b56 100644 --- a/sp/src/public/tier0/basetypes.h +++ b/sp/src/public/tier0/basetypes.h @@ -147,6 +147,11 @@ typedef wchar_t ucs2; // under windows wchar_t is ucs2 typedef unsigned short ucs2; #endif +#ifdef MAPBASE +// I'm using ThreeState_t a lot more now and I'm tired of typing this out so much. +#define TO_THREESTATE(num) static_cast(num) +#endif + enum ThreeState_t { TRS_FALSE, diff --git a/sp/src/public/tier1/utlbuffer.h b/sp/src/public/tier1/utlbuffer.h index 4213dd6a..8ce115a7 100644 --- a/sp/src/public/tier1/utlbuffer.h +++ b/sp/src/public/tier1/utlbuffer.h @@ -586,7 +586,11 @@ inline void CUtlBuffer::GetObject( T *dest ) { if ( CheckGet( sizeof(T) ) ) { +#ifdef MAPBASE + if ( ( sizeof( T ) == 1 ) || !m_Byteswap.IsSwappingBytes() ) +#else if ( !m_Byteswap.IsSwappingBytes() || ( sizeof( T ) == 1 ) ) +#endif { *dest = *(T *)PeekGet(); } @@ -618,7 +622,11 @@ inline void CUtlBuffer::GetTypeBin( T &dest ) { if ( CheckGet( sizeof(T) ) ) { +#ifdef MAPBASE + if ( ( sizeof( T ) == 1 ) || !m_Byteswap.IsSwappingBytes() ) +#else if ( !m_Byteswap.IsSwappingBytes() || ( sizeof( T ) == 1 ) ) +#endif { dest = *(T *)PeekGet(); } @@ -804,7 +812,11 @@ inline void CUtlBuffer::PutObject( T *src ) { if ( CheckPut( sizeof(T) ) ) { +#ifdef MAPBASE + if ( ( sizeof( T ) == 1 ) || !m_Byteswap.IsSwappingBytes() ) +#else if ( !m_Byteswap.IsSwappingBytes() || ( sizeof( T ) == 1 ) ) +#endif { *(T *)PeekPut() = *src; } @@ -833,7 +845,11 @@ inline void CUtlBuffer::PutTypeBin( T src ) { if ( CheckPut( sizeof(T) ) ) { - if ( !m_Byteswap.IsSwappingBytes() || ( sizeof( T ) == 1 ) ) +#ifdef MAPBASE + if ((sizeof(T) == 1) || !m_Byteswap.IsSwappingBytes()) +#else + if (!m_Byteswap.IsSwappingBytes() || (sizeof(T) == 1)) +#endif { *(T *)PeekPut() = src; } diff --git a/sp/src/raytrace/raytrace.cpp b/sp/src/raytrace/raytrace.cpp index 7b951dfb..9816560d 100644 --- a/sp/src/raytrace/raytrace.cpp +++ b/sp/src/raytrace/raytrace.cpp @@ -233,7 +233,9 @@ void CacheOptimizedTriangle::ChangeIntoIntersectionFormat(void) } +#ifndef MAPBASE int n_intersection_calculations=0; +#endif int CacheOptimizedTriangle::ClassifyAgainstAxisSplit(int split_plane, float split_value) { @@ -476,7 +478,9 @@ void RayTracingEnvironment::Trace4Rays(const FourRays &rays, fltx4 TMin, fltx4 T TriIntersectData_t const *tri = &( OptimizedTriangleList[tnum].m_Data.m_IntersectData ); if ( ( mailboxids[mbox_slot] != tnum ) && ( tri->m_nTriangleID != skip_id ) ) { +#ifndef MAPBASE n_intersection_calculations++; +#endif mailboxids[mbox_slot] = tnum; // compute plane intersection diff --git a/sp/src/utils/common/threads.cpp b/sp/src/utils/common/threads.cpp index 74e457a9..28f0894c 100644 --- a/sp/src/utils/common/threads.cpp +++ b/sp/src/utils/common/threads.cpp @@ -19,7 +19,13 @@ #include "threads.h" #include "pacifier.h" +#ifdef MAPBASE +// This was suggested in that Source 2013 pull request that fixed Vrad. +// I trust their judgement on this. +#define MAX_THREADS 32 +#else #define MAX_THREADS 16 +#endif class CRunThreadsData diff --git a/sp/src/utils/common/threads.h b/sp/src/utils/common/threads.h index 0908b67a..7d6beb9f 100644 --- a/sp/src/utils/common/threads.h +++ b/sp/src/utils/common/threads.h @@ -16,9 +16,15 @@ #pragma once +#ifdef MAPBASE +// This was suggested in that Source 2013 pull request that fixed Vrad. +// I trust their judgement on this. +#define MAX_TOOL_THREADS 32 +#else // Arrays that are indexed by thread should always be MAX_TOOL_THREADS+1 // large so THREADINDEX_MAIN can be used from the main thread. #define MAX_TOOL_THREADS 16 +#endif #define THREADINDEX_MAIN (MAX_TOOL_THREADS) diff --git a/sp/src/utils/vbsp/detail.cpp b/sp/src/utils/vbsp/detail.cpp index 840068de..b17917bc 100644 --- a/sp/src/utils/vbsp/detail.cpp +++ b/sp/src/utils/vbsp/detail.cpp @@ -440,6 +440,9 @@ face_t *MakeBrushFace( side_t *originalSide, winding_t *winding ) f->split[0] = f->split[1] = NULL; f->w = CopyWinding( winding ); f->originalface = originalSide; +#ifdef MAPBASE + f->smoothingGroups = originalSide->smoothingGroups; +#endif // // save material info // diff --git a/sp/src/utils/vbsp/manifest.cpp b/sp/src/utils/vbsp/manifest.cpp index c72a9564..5ac98ca9 100644 --- a/sp/src/utils/vbsp/manifest.cpp +++ b/sp/src/utils/vbsp/manifest.cpp @@ -361,7 +361,11 @@ bool CManifest::LoadVMFManifestUserPrefs( const char *pszFileName ) UserNameSize = sizeof( UserName ); if ( GetUserName( UserName, &UserNameSize ) == 0 ) { +#ifdef MAPBASE + strcpy( UserName, "default" ); +#else strcpy( UserPrefsFileName, "default" ); +#endif } sprintf( UserPrefsFileName, "\\%s.vmm_prefs", UserName ); diff --git a/sp/src/utils/vbsp/map.cpp b/sp/src/utils/vbsp/map.cpp index 2221c79f..9dfe7dfc 100644 --- a/sp/src/utils/vbsp/map.cpp +++ b/sp/src/utils/vbsp/map.cpp @@ -2496,7 +2496,13 @@ void CMapFile::MergeEntities( entity_t *pInstanceEntity, CMapFile *Instance, Vec MoveBrushesToWorldGeneral( WorldspawnEnt ); WorldspawnEnt->numbrushes = 0; +#ifdef MAPBASE + char *pIsTopLevel = ValueForKey( pInstanceEntity, "toplevel" ); + if ( strcmp( pIsTopLevel, "1" ) ) + WorldspawnEnt->epairs = NULL; +#else WorldspawnEnt->epairs = NULL; +#endif } diff --git a/sp/src/utils/vbsp/staticprop.cpp b/sp/src/utils/vbsp/staticprop.cpp index b7b9b6cb..75567224 100644 --- a/sp/src/utils/vbsp/staticprop.cpp +++ b/sp/src/utils/vbsp/staticprop.cpp @@ -166,7 +166,11 @@ bool LoadStudioModel( char const* pModelName, char const* pEntityType, CUtlBuffe } isstaticprop_ret isStaticProp = IsStaticProp(pHdr); +#ifdef MAPBASE + if ( isStaticProp != RET_VALID && strcmp(pEntityType, "prop_static_override") != 0 ) +#else if ( isStaticProp != RET_VALID ) +#endif { if ( isStaticProp == RET_FAIL_NOT_MARKED_STATIC_PROP ) { @@ -240,7 +244,11 @@ CPhysCollide* ComputeConvexHull( studiohdr_t* pStudioHdr ) //----------------------------------------------------------------------------- // Add, find collision model in cache //----------------------------------------------------------------------------- +#ifdef MAPBASE +static CPhysCollide* GetCollisionModel( char const* pModelName, bool bOverridePropdata = false ) +#else static CPhysCollide* GetCollisionModel( char const* pModelName ) +#endif { // Convert to a common string char* pTemp = (char*)_alloca(strlen(pModelName) + 1); @@ -263,7 +271,11 @@ static CPhysCollide* GetCollisionModel( char const* pModelName ) // Load the studio model file CUtlBuffer buf; +#ifdef MAPBASE + if (!LoadStudioModel(pModelName, bOverridePropdata ? "prop_static_override" : "prop_static", buf)) +#else if (!LoadStudioModel(pModelName, "prop_static", buf)) +#endif { Warning("Error loading studio model \"%s\"!\n", pModelName ); @@ -474,7 +486,11 @@ static bool ComputeLightingOrigin( StaticPropBuild_t const& build, Vector& light static void AddStaticPropToLump( StaticPropBuild_t const& build ) { // Get the collision model +#ifdef MAPBASE + CPhysCollide* pConvexHull = GetCollisionModel( build.m_pModelName, (build.m_Flags & STATIC_PROP_OVERRIDE_PROPDATA) > 0 ); +#else CPhysCollide* pConvexHull = GetCollisionModel( build.m_pModelName ); +#endif if (!pConvexHull) return; @@ -586,7 +602,11 @@ void EmitStaticProps() for ( i = 0; i < num_entities; ++i) { char* pEntity = ValueForKey(&entities[i], "classname"); +#ifdef MAPBASE + if (!strncmp(pEntity, "prop_static", 11) || !strcmp(pEntity, "static_prop")) +#else if (!strcmp(pEntity, "static_prop") || !strcmp(pEntity, "prop_static")) +#endif { StaticPropBuild_t build; @@ -619,6 +639,14 @@ void EmitStaticProps() build.m_Flags |= STATIC_PROP_SCREEN_SPACE_FADE; } +#ifdef MAPBASE + //if (IntForKey(&entities[i], "override_propdata") == 1) + if (!strcmp(pEntity + 11, "_override")) + { + build.m_Flags |= STATIC_PROP_OVERRIDE_PROPDATA; + } +#endif + const char *pKey = ValueForKey( &entities[i], "fadescale" ); if ( pKey && pKey[0] ) { diff --git a/sp/src/utils/vbsp/vbsp.cpp b/sp/src/utils/vbsp/vbsp.cpp index 97a4df4c..55452170 100644 --- a/sp/src/utils/vbsp/vbsp.cpp +++ b/sp/src/utils/vbsp/vbsp.cpp @@ -56,6 +56,9 @@ bool g_NodrawTriggers = false; bool g_DisableWaterLighting = false; bool g_bAllowDetailCracks = false; bool g_bNoVirtualMesh = false; +#ifdef MAPBASE +bool g_bNoDefaultCubemaps = false; +#endif float g_defaultLuxelSize = DEFAULT_LUXEL_SIZE; float g_luxelScale = 1.0f; @@ -82,6 +85,182 @@ int entity_num; node_t *block_nodes[BLOCKS_SPACE+2][BLOCKS_SPACE+2]; +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Manifest stuff +//----------------------------------------------------------------------------- +CUtlVector g_szManifestFiles; +bool g_bManifestVerbose = true; // Change to false when testing is over + +#define ManifestMsg(msg, ...) g_bManifestVerbose ? Msg(msg, __VA_ARGS__) : NULL +#define ManifestWarning(msg, ...) g_bManifestVerbose ? Warning(msg, __VA_ARGS__) : NULL + +void SetManifestFile(char const *file) +{ + if (g_pFileSystem->FileExists( file )) + { + Msg("Manifest file: %s\n", file); + g_szManifestFiles.AddToTail(file); + } +} + +void ZipDirectory(const char *dir, const char *relative, IZip *package, int *filecount) +{ + ManifestMsg(" MANIFEST: Mounting directory \"%s\"\n", dir); + + FileFindHandle_t handle = NULL; + const char *file = g_pFullFileSystem->FindFirst(dir, &handle); + + // Prevents us from packaging the folder itself + //if (file) + // file = g_pFullFileSystem->FindNext(handle); + + while (file) + { + // Don't use hidden files/folders + if (file[0] != '.') + { + char subdir[MAX_PATH]; + Q_strncpy(subdir, dir, strlen(dir) - 1); // Remove wildcard + Q_ComposeFileName(subdir, file, subdir, sizeof(subdir)); + + char subrelative[MAX_PATH]; + Q_strncpy(subrelative, relative, sizeof(subrelative)); + Q_ComposeFileName(subrelative, file, subrelative, sizeof(subrelative)); + + if (g_pFullFileSystem->FindIsDirectory(handle)) + { + // Append wildcard + Q_ComposeFileName(subdir, "*", subdir, sizeof(subdir)); + + // Mount subdirectory + ZipDirectory(subdir, subrelative, package, filecount); + } + else + { + // Mount file + ManifestMsg(" MANIFEST: File \"%s\" packed into BSP at \"%s\"\n", subdir, subrelative); + *filecount++; + AddFileToPak(package, subrelative, subdir); + } + } + + file = g_pFullFileSystem->FindNext(handle); + } + g_pFullFileSystem->FindClose(handle); +} + +void ParseManifestFile() +{ + if (g_szManifestFiles.Count() == 0) + return; + + Msg("Starting pack manifest with %i files\n", g_szManifestFiles.Count()); + + int totalfilecount = 0; + + for (int i = 0; i < g_szManifestFiles.Count(); i++) + { + FileHandle_t manifestfile = g_pFileSystem->Open( g_szManifestFiles[i], "rb" ); + if (!manifestfile) + { + Warning("Manifest file \"%s\" cannot be read!\n", g_szManifestFiles[i]); + continue; + } + + //FileHandle_t curfile; + bool curfile; + char buf[1024]; + char *scan; + int filecount = 0; + bool fullpath = false; + while ( CmdLib_FGets( buf, sizeof( buf ), manifestfile ) ) + { + scan = buf; + + // Check if it's an actual path or just relative + fullpath = (scan[0] == '#'); + if (fullpath) + scan += 1; + else + { + char file[128]; + Q_strncpy(file, scan, sizeof(file)); + char path[_MAX_PATH]; + Q_ExtractFilePath(source, path, sizeof(path)); + sprintf(scan, "%s%s", path, file); + } + + bool inquotes = (scan[0] == '"'); + int namelength; + if (inquotes) + { + scan += 1; + namelength = strcspn( scan, "\"" ); + } + else + { + namelength = strcspn( scan, " \t" ); + } + + char filename[FILENAME_MAX]; + Q_strncpy(filename, scan, namelength + 1); + + scan += (namelength + inquotes); + scan += strspn(scan, " \t"); + + // Remove any quotes in the internal path. + // The fact they're actually optional in the second path is irrelevant. + if (scan[0] == '"') + { + scan[0] = '\0'; + if (scan[strlen(scan) - 1] == '"') + scan[strlen(scan) - 1] = '\0'; + } + + curfile = g_pFileSystem->FileExists(filename); + if (curfile) + { + // Assume internal file is a directory if no extension + if (Q_GetFileExtension(scan) == NULL) + Q_ComposeFileName(scan, filename, scan, sizeof(filename)); + + ManifestMsg(" MANIFEST: File \"%s\" packed into BSP at \"%s\"\n", filename, scan); + filecount++; + AddFileToPak(GetPakFile(), scan, filename); + } + else if (g_pFullFileSystem->IsDirectory(filename)) + { + // Append wildcard + if (!Q_strstr(filename, "*")) + Q_ComposeFileName(filename, "*", filename, sizeof(filename)); + + // Internal path must be a directory + if (scan[0] == NULL || Q_GetFileExtension(scan) == NULL) + ZipDirectory(filename, scan, GetPakFile(), &filecount); + else + Warning("\n MANIFEST WARNING: Directory \"%s\" tried to pack to a file!\nIf you are not trying to package a directory to the BSP, add an extension to \"%s\".\nIf you are trying to package a directory, remove the extension from \"%s\".\n\n", filename, filename, scan); + } + else + { + Warning(" MANIFEST WARNING: File \"%s\" does not exist!\n", filename); + } + } + + if (filecount > 0) + ManifestMsg("%i file(s) packed from manifest %s\n", filecount, g_szManifestFiles[i]); + else + ManifestWarning("*** No files zipped from manifest %s!\n ***", g_szManifestFiles[i]); + + totalfilecount += filecount; + + g_pFileSystem->Close( manifestfile ); + } + + Msg("%i total file(s) packed from manifests\n", totalfilecount); +} +#endif + //----------------------------------------------------------------------------- // Assign occluder areas (must happen *after* the world model is processed) //----------------------------------------------------------------------------- @@ -668,6 +847,7 @@ void SetOccluderArea( int nOccluder, int nArea, int nEntityNum ) { g_OccluderData[nOccluder].area = nArea; } +#ifndef MAPBASE else if ( (nArea != 0) && (g_OccluderData[nOccluder].area != nArea) ) { const char *pTargetName = ValueForKey( &entities[nEntityNum], "targetname" ); @@ -677,6 +857,7 @@ void SetOccluderArea( int nOccluder, int nArea, int nEntityNum ) } Warning("Occluder \"%s\" straddles multiple areas. This is invalid!\n", pTargetName ); } +#endif } @@ -857,7 +1038,12 @@ void ProcessModels (void) } // Turn the skybox into a cubemap in case we don't build env_cubemap textures. +#ifdef MAPBASE + if (!g_bNoDefaultCubemaps) + Cubemap_CreateDefaultCubemaps(); +#else Cubemap_CreateDefaultCubemaps(); +#endif EndBSPFile (); } @@ -1129,6 +1315,21 @@ int RunVBSP( int argc, char **argv ) { EnableFullMinidumps( true ); } +#ifdef MAPBASE + else if ( !Q_stricmp( argv[i], "-deletecubemaps" ) ) + { + g_bNoDefaultCubemaps = true; + } + else if ( !Q_stricmp( argv[i], "-manifest" ) ) + { + SetManifestFile(argv[i+1]); + i++; + } + else if ( !Q_stricmp( argv[i], "-manifest_verbose" ) ) + { + g_bManifestVerbose = true; + } +#endif else if (argv[i][0] == '-') { Warning("VBSP: Unknown option \"%s\"\n\n", argv[i]); @@ -1244,6 +1445,13 @@ int RunVBSP( int argc, char **argv ) ThreadSetDefault (); numthreads = 1; // multiple threads aren't helping... +#ifdef MAPBASE + // Any additional files to pack? + char ManifestFile[512]; + _snprintf( ManifestFile, sizeof(ManifestFile), "%s_zipmanifest.txt", source ); + SetManifestFile(ManifestFile); +#endif + // Setup the logfile. char logFile[512]; _snprintf( logFile, sizeof(logFile), "%s.log", source ); @@ -1360,6 +1568,11 @@ int RunVBSP( int argc, char **argv ) AddBufferToPak( GetPakFile(), "stale.txt", "stale", strlen( "stale" ) + 1, false ); } +#ifdef MAPBASE + // Is this a good place for this? + ParseManifestFile(); +#endif + LoadMapFile (name); WorldVertexTransitionFixup(); if( ( g_nDXLevel == 0 ) || ( g_nDXLevel >= 70 ) ) diff --git a/sp/src/utils/vbsp/vbsp.vpc b/sp/src/utils/vbsp/vbsp.vpc index 7065f0a5..9737a803 100644 --- a/sp/src/utils/vbsp/vbsp.vpc +++ b/sp/src/utils/vbsp/vbsp.vpc @@ -6,6 +6,7 @@ $Macro SRCDIR "..\.." $Macro OUTBINDIR "$SRCDIR\..\game\bin" +$Macro OUTBINNAME "mapbase_vbsp" $Include "$SRCDIR\vpc_scripts\source_exe_con_base.vpc" diff --git a/sp/src/utils/vrad/vrad_dll.vpc b/sp/src/utils/vrad/vrad_dll.vpc index a1ae67b4..2ff81363 100644 --- a/sp/src/utils/vrad/vrad_dll.vpc +++ b/sp/src/utils/vrad/vrad_dll.vpc @@ -6,6 +6,7 @@ $Macro SRCDIR "..\.." $Macro OUTBINDIR "$SRCDIR\..\game\bin" +$Macro OUTBINNAME "mapbase_vrad_dll" $Include "$SRCDIR\vpc_scripts\source_dll_base.vpc" diff --git a/sp/src/utils/vrad_launcher/vrad_launcher.cpp b/sp/src/utils/vrad_launcher/vrad_launcher.cpp index a4d31834..0afb27d7 100644 --- a/sp/src/utils/vrad_launcher/vrad_launcher.cpp +++ b/sp/src/utils/vrad_launcher/vrad_launcher.cpp @@ -103,6 +103,18 @@ int main(int argc, char* argv[]) if (mode && (! both_arg)) continue; +#ifdef MAPBASE + // Coming through! + if ( !pModule ) + { + // With this, we just load the DLL with our filename. + // This allows for custom DLLs without having to bother with the launcher. + char filename[64]; + Q_FileBase(argv[0], filename, sizeof(filename)); + Q_snprintf(dllName, sizeof(dllName), "%s%s", filename, "_dll.dll"); + pModule = Sys_LoadModule( dllName ); + } +#endif // If it didn't load the module above, then use the if ( !pModule ) diff --git a/sp/src/utils/vrad_launcher/vrad_launcher.vpc b/sp/src/utils/vrad_launcher/vrad_launcher.vpc index 293e5514..ed6fd3cc 100644 --- a/sp/src/utils/vrad_launcher/vrad_launcher.vpc +++ b/sp/src/utils/vrad_launcher/vrad_launcher.vpc @@ -6,7 +6,7 @@ $Macro SRCDIR "..\.." $Macro OUTBINDIR "$SRCDIR\..\game\bin" -$Macro OUTBINNAME "vrad" +$Macro OUTBINNAME "mapbase_vrad" $Include "$SRCDIR\vpc_scripts\source_exe_con_base.vpc" diff --git a/sp/src/utils/vvis/vvis_dll.vpc b/sp/src/utils/vvis/vvis_dll.vpc index 43001443..7b782c56 100644 --- a/sp/src/utils/vvis/vvis_dll.vpc +++ b/sp/src/utils/vvis/vvis_dll.vpc @@ -6,6 +6,7 @@ $Macro SRCDIR "..\.." $Macro OUTBINDIR "$SRCDIR\..\game\bin" +$Macro OUTBINNAME "mapbase_vvis_dll" $Include "$SRCDIR\vpc_scripts\source_dll_base.vpc" diff --git a/sp/src/utils/vvis_launcher/vvis_launcher.cpp b/sp/src/utils/vvis_launcher/vvis_launcher.cpp index edf03d25..ddc2b83f 100644 --- a/sp/src/utils/vvis_launcher/vvis_launcher.cpp +++ b/sp/src/utils/vvis_launcher/vvis_launcher.cpp @@ -45,6 +45,7 @@ char* GetLastErrorString() int main(int argc, char* argv[]) { CommandLine()->CreateCmdLine( argc, argv ); +#ifndef MAPBASE const char *pDLLName = "vvis_dll.dll"; CSysModule *pModule = Sys_LoadModule( pDLLName ); @@ -53,6 +54,31 @@ int main(int argc, char* argv[]) printf( "vvis launcher error: can't load %s\n%s", pDLLName, GetLastErrorString() ); return 1; } +#else + // Coming through! + const char *pDLLName = "vvis_dll.dll"; + + // With this, we just load the DLL with our filename. + // This allows for custom DLLs without having to bother with the launcher. + char filename[128]; + Q_FileBase(argv[0], filename, sizeof(filename)); + Q_snprintf(filename, sizeof(filename), "%s_dll.dll", filename); + pDLLName = filename; + + CSysModule *pModule = Sys_LoadModule( pDLLName ); + if ( !pModule ) + { + // Try loading the default then + pDLLName = "vvis_dll.dll"; + pModule = Sys_LoadModule( pDLLName ); + } + + if ( !pModule ) + { + printf( "vvis launcher error: can't load %s\n%s", pDLLName, GetLastErrorString() ); + return 1; + } +#endif CreateInterfaceFn fn = Sys_GetFactory( pModule ); if( !fn ) diff --git a/sp/src/utils/vvis_launcher/vvis_launcher.vpc b/sp/src/utils/vvis_launcher/vvis_launcher.vpc index f3c5e958..0eb73d22 100644 --- a/sp/src/utils/vvis_launcher/vvis_launcher.vpc +++ b/sp/src/utils/vvis_launcher/vvis_launcher.vpc @@ -6,7 +6,7 @@ $Macro SRCDIR "..\.." $Macro OUTBINDIR "$SRCDIR\..\game\bin" -$Macro OUTBINNAME "vvis" +$Macro OUTBINNAME "mapbase_vvis" $Include "$SRCDIR\vpc_scripts\source_exe_con_base.vpc" diff --git a/sp/src/vpc_scripts/source_base.vpc b/sp/src/vpc_scripts/source_base.vpc index 17de60eb..7f7b24d8 100644 --- a/sp/src/vpc_scripts/source_base.vpc +++ b/sp/src/vpc_scripts/source_base.vpc @@ -15,6 +15,14 @@ // rel/tf_beta branch: //$Conditional TF_BETA "1" +//----------------------------------------------------------------------------- +// Mapbase conditional, equivalent to (and required for) our MAPBASE preprocessor defined below +$Conditional MAPBASE "1" + +// Toggles Mapbase's RPC implementation +$Conditional MAPBASE_RPC "1" +//----------------------------------------------------------------------------- + $Configuration "Debug" { $Compiler @@ -27,6 +35,9 @@ $Configuration "Debug" // Need to revisit the code to make things run with the _RETAIL preprocessor definition // This line was added in the previous check-in, but had previously not been defined in this branch // $PreprocessorDefinitions "$BASE;_RETAIL" [$RETAIL] + + // Mapbase base definitions + $PreprocessorDefinitions "$BASE;MAPBASE" [$MAPBASE] } } @@ -42,5 +53,8 @@ $Configuration "Release" // Need to revisit the code to make things run with the _RETAIL preprocessor definition // This line was added in the previous check-in, but had previously not been defined in this branch // $PreprocessorDefinitions "$BASE;_RETAIL" [$RETAIL] + + // Mapbase base definitions + $PreprocessorDefinitions "$BASE;MAPBASE" [$MAPBASE] } } diff --git a/sp/src/vpc_scripts/source_dll_win32_base.vpc b/sp/src/vpc_scripts/source_dll_win32_base.vpc index cec539ad..4b2a2852 100644 --- a/sp/src/vpc_scripts/source_dll_win32_base.vpc +++ b/sp/src/vpc_scripts/source_dll_win32_base.vpc @@ -138,6 +138,9 @@ $Project $Implib "$LIBPUBLIC\tier0" $Lib "$LIBPUBLIC\tier1" $Implib "$LIBPUBLIC\vstdlib" + + // Discord integration + $Lib "$LIBPUBLIC\discord-rpc" [$MAPBASE_RPC] } }