source-sdk-2013-mapbase/sp/src/game/client/fx_tracer.cpp
Blixibon 63323222fe Mapbase v4.3
- Fixed a crash with multiple trigger_look targets
- Fixed an issue where some zombie submodel server ragdolls are not solid to the world
- Fixed a crash with certain instance classes being loaded in a savegame before the class is registered
- Added some of Tony Sergi's missing Source 2007 fixes (contributed by Kris)
- Added "ClientCommand" hook for VScript to allow handling of unknown console commands
- Added "PlayerRunCommand" hook for VScript to control player movement
- Added new button-related script functions for players (GetButtons, DisableButtons, etc.)
- Added CUserCmd accessor in VScript for the "PlayerRunCommand" hook
- Added "GetWaterLevel" function for VScript
- Exposed "Ignite" to VScript for controlling how a fire starts
- Fixed NPCs being unable to unholster weapons
- Fixed Mapbase crashing when Steam isn't running
- Fixed issues with angled/updating sky_camera save/restore
- Added VBSP "-skyboxcubemap" parameter to enable skybox default cubemaps + "-defaultcubemapres" to control their resolution
- Added ability to disable VScript in a map (and fixed a few potential complications from disabling VScript)
- Made clientside VScript only initialize after world is spawned in order to receive serverside script language in time
- Added tons of VScript functions to CBaseAnimating related to bodygroups, sequences, etc.
- Added VScript functions to players for getting user ID and player name, similar to logic_playerinfo
- Added a few L4D2 script functions missing from the ASW SDK
- Added "Localize" singleton with a single "GetTokenAsUTF8" function for getting localization strings
- Disabled r_hunkalloclightmaps by the request of various users (apparently this completely removes the "Engine hunk overflow" error and allows for really high-res lightmaps)
- Fixed npc_antlionguard NPC_TranslateActivity not hooking into base class (allows for VScript manipulation)
- Added various unused antlion guard activities to npc_antlionguard AI, allowing for usage as registered activities
- Added keyvalue to set LOS mask on combine_mine
- Added +USE bounding box limiter to prop_interactable
2020-07-16 15:43:30 +00:00

172 lines
4.6 KiB
C++

//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "fx.h"
#include "c_te_effect_dispatch.h"
#include "basecombatweapon_shared.h"
#include "baseviewmodel_shared.h"
#include "particles_new.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
#define TRACER_SPEED 5000
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
Vector GetTracerOrigin( const CEffectData &data )
{
Vector vecStart = data.m_vStart;
QAngle vecAngles;
int iAttachment = data.m_nAttachmentIndex;;
// Attachment?
if ( data.m_fFlags & TRACER_FLAG_USEATTACHMENT )
{
C_BaseViewModel *pViewModel = NULL;
// If the entity specified is a weapon being carried by this player, use the viewmodel instead
IClientRenderable *pRenderable = data.GetRenderable();
if ( !pRenderable )
return vecStart;
C_BaseEntity *pEnt = data.GetEntity();
// This check should probably be for all multiplayer games, investigate later
// 10/09/2008: It should.
if ( gpGlobals->maxClients > 1 )
{
if ( pEnt && pEnt->IsDormant() )
return vecStart;
}
C_BaseCombatWeapon *pWpn = dynamic_cast<C_BaseCombatWeapon *>( pEnt );
if ( pWpn && pWpn->ShouldDrawUsingViewModel() )
{
C_BasePlayer *player = ToBasePlayer( pWpn->GetOwner() );
// Use GetRenderedWeaponModel() instead?
pViewModel = player ? player->GetViewModel( 0 ) : NULL;
if ( pViewModel )
{
// Get the viewmodel and use it instead
pRenderable = pViewModel;
}
}
// Get the attachment origin
if ( !pRenderable->GetAttachment( iAttachment, vecStart, vecAngles ) )
{
DevMsg( "GetTracerOrigin: Couldn't find attachment %d on model %s\n", iAttachment,
modelinfo->GetModelName( pRenderable->GetModel() ) );
}
}
return vecStart;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void TracerCallback( const CEffectData &data )
{
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
if ( !player )
return;
// Grab the data
Vector vecStart = GetTracerOrigin( data );
float flVelocity = data.m_flScale;
bool bWhiz = (data.m_fFlags & TRACER_FLAG_WHIZ);
int iEntIndex = data.entindex();
if ( iEntIndex && iEntIndex == player->index )
{
Vector foo = data.m_vStart;
QAngle vangles;
Vector vforward, vright, vup;
engine->GetViewAngles( vangles );
AngleVectors( vangles, &vforward, &vright, &vup );
VectorMA( data.m_vStart, 4, vright, foo );
foo[2] -= 0.5f;
FX_PlayerTracer( foo, (Vector&)data.m_vOrigin );
return;
}
// Use default velocity if none specified
if ( !flVelocity )
{
flVelocity = TRACER_SPEED;
}
// Do tracer effect
FX_Tracer( (Vector&)vecStart, (Vector&)data.m_vOrigin, flVelocity, bWhiz );
}
DECLARE_CLIENT_EFFECT( "Tracer", TracerCallback );
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void ParticleTracerCallback( const CEffectData &data )
{
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
if ( !player )
return;
// Grab the data
Vector vecStart = GetTracerOrigin( data );
Vector vecEnd = data.m_vOrigin;
// Adjust view model tracers
C_BaseEntity *pEntity = data.GetEntity();
if ( data.entindex() && data.entindex() == player->index )
{
QAngle vangles;
Vector vforward, vright, vup;
engine->GetViewAngles( vangles );
AngleVectors( vangles, &vforward, &vright, &vup );
VectorMA( data.m_vStart, 4, vright, vecStart );
vecStart[2] -= 0.5f;
}
// Create the particle effect
QAngle vecAngles;
Vector vecToEnd = vecEnd - vecStart;
VectorNormalize(vecToEnd);
VectorAngles( vecToEnd, vecAngles );
DispatchParticleEffect( data.m_nHitBox, vecStart, vecEnd, vecAngles, pEntity );
if ( data.m_fFlags & TRACER_FLAG_WHIZ )
{
FX_TracerSound( vecStart, vecEnd, TRACER_TYPE_DEFAULT );
}
}
DECLARE_CLIENT_EFFECT( "ParticleTracer", ParticleTracerCallback );
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void TracerSoundCallback( const CEffectData &data )
{
// Grab the data
Vector vecStart = GetTracerOrigin( data );
// Do tracer effect
FX_TracerSound( vecStart, (Vector&)data.m_vOrigin, data.m_fFlags );
}
DECLARE_CLIENT_EFFECT( "TracerSound", TracerSoundCallback );