dlls/player.cpp
646566676869
#include "weapon_physcannon.h"
#endif
#ifdef HL2_DLL
extern ConVar hl2_xbox_aiming;
#define UseXboxAiming() hl2_xbox_aiming.GetBool()
646566676869707172737475767778
#include "weapon_physcannon.h"
#endif
// For the upcast in CommitSuicide
#include "ff_player.h"
// For spectating info scripts
#include "ff_item_flag.h"
// Forward declare
class CFFPlayer;
#ifdef HL2_DLL
extern ConVar hl2_xbox_aiming;
#define UseXboxAiming() hl2_xbox_aiming.GetBool()
303304305306307308
//DEFINE_FIELD( m_lasty, FIELD_INTEGER ),
DEFINE_FIELD( m_iFrags, FIELD_INTEGER ),
DEFINE_FIELD( m_iDeaths, FIELD_INTEGER ),
DEFINE_FIELD( m_flNextDecalTime, FIELD_TIME ),
//DEFINE_AUTO_ARRAY( m_szTeamName, FIELD_STRING ), // mp
312313314315316317318
//DEFINE_FIELD( m_lasty, FIELD_INTEGER ),
DEFINE_FIELD( m_iFrags, FIELD_INTEGER ),
DEFINE_FIELD( m_iFortPoints, FIELD_INTEGER ),
DEFINE_FIELD( m_iDeaths, FIELD_INTEGER ),
DEFINE_FIELD( m_flNextDecalTime, FIELD_TIME ),
//DEFINE_AUTO_ARRAY( m_szTeamName, FIELD_STRING ), // mp
324325326327328329330
DEFINE_FIELD( m_flWaterJumpTime, FIELD_TIME ),
DEFINE_FIELD( m_vecWaterJumpVel, FIELD_VECTOR ),
DEFINE_FIELD( m_nImpulse, FIELD_INTEGER ),
DEFINE_FIELD( m_flStepSoundTime, FIELD_TIME ),
DEFINE_FIELD( m_flSwimSoundTime, FIELD_TIME ),
DEFINE_FIELD( m_vecLadderNormal, FIELD_VECTOR ),
334335336337338339340
DEFINE_FIELD( m_flWaterJumpTime, FIELD_TIME ),
DEFINE_FIELD( m_vecWaterJumpVel, FIELD_VECTOR ),
DEFINE_FIELD( m_nImpulse, FIELD_INTEGER ),
// DEFINE_FIELD( m_flStepSoundTime, FIELD_TIME ), |-- Mirv: Removed to fix footsteps
DEFINE_FIELD( m_flSwimSoundTime, FIELD_TIME ),
DEFINE_FIELD( m_vecLadderNormal, FIELD_VECTOR ),
521522523524525526
m_PlayerInfo.SetParent( this );
ResetObserverMode();
m_surfaceProps = 0;
m_pSurfaceData = NULL;
531532533534535536537
m_PlayerInfo.SetParent( this );
ResetObserverMode();
ResetFortPointsCount();
m_surfaceProps = 0;
m_pSurfaceData = NULL;
536537538539540541
m_nNumCrouches = 0;
m_bDuckToggled = false;
}
CBasePlayer::~CBasePlayer( )
547548549550551552553554555556557
m_nNumCrouches = 0;
m_bDuckToggled = false;
// Mulch:
// -1 = just joined map/need to force spawn once team/class have been chosen
// 0 - x = respawn delay (like when typing "kill" in the console)
m_flNextSpawnDelay = -1.0f;
}
CBasePlayer::~CBasePlayer( )
581582583584585586
int CBasePlayer::UpdateTransmitState()
{
// always call ShouldTransmit() for players
return SetTransmitState( FL_EDICT_FULLCHECK );
}
597598599600601602603604605606607608609610
int CBasePlayer::UpdateTransmitState()
{
// --> FF
#ifdef GAME_DLL
// always transmit if you're an objective
if ( m_ObjectivePlayerRefs.Count() > 0 )
return SetTransmitState( FL_EDICT_ALWAYS );
#endif // GAME_DLL
// <-- FF
// always call ShouldTransmit() for players
return SetTransmitState( FL_EDICT_FULLCHECK );
}
624625626627628629630631632633
bool CBasePlayer::WantsLagCompensationOnEntity( const CBasePlayer *pPlayer, const CUserCmd *pCmd, const CBitVec *pEntityTransmitBits ) const
{
// Team members shouldn't be adjusted unless friendly fire is on.
if ( !friendlyfire.GetInt() && pPlayer->GetTeamNumber() == GetTeamNumber() )
return false;
// If this entity hasn't been transmitted to us and acked, then don't bother lag compensating it.
if ( pEntityTransmitBits && !pEntityTransmitBits->Get( pPlayer->entindex() ) )
return false;
648649650651652653654655656657658
bool CBasePlayer::WantsLagCompensationOnEntity( const CBasePlayer *pPlayer, const CUserCmd *pCmd, const CBitVec *pEntityTransmitBits ) const
{
/* Jiggles: We need to predict team members for our Medpack and Wrench
// Team members shouldn't be adjusted unless friendly fire is on.
if ( !friendlyfire.GetInt() && pPlayer->GetTeamNumber() == GetTeamNumber() )
return false;
*/
// If this entity hasn't been transmitted to us and acked, then don't bother lag compensating it.
if ( pEntityTransmitBits && !pEntityTransmitBits->Get( pPlayer->entindex() ) )
return false;
713714715716717718719720721722723
EmitSound( "Player.Death" );
}
// play one of the suit death alarms
if ( IsSuitEquipped() )
{
UTIL_EmitGroupnameSuit(edict(), "HEV_DEAD");
}
}
// override takehealth
738739740741742743744745746747748749750
EmitSound( "Player.Death" );
}
// --> Mirv: Don't play suit sound'
// play one of the suit death alarms
//if ( IsSuitEquipped() )
//{
// UTIL_EmitGroupnameSuit(edict(), "HEV_DEAD");
//}
// <-- Mirv: Don't play suit sound
}
// override takehealth
773774775776777778779
// --------------------------------------------------
// If an NPC check if friendly fire is disallowed
// --------------------------------------------------
CAI_BaseNPC *pNPC = info.GetAttacker()->MyNPCPointer();
if ( pNPC && (pNPC->CapabilitiesGet() & bits_CAP_NO_HIT_PLAYER) && pNPC->IRelationType( this ) != D_HT )
{
return;
800801802803804805806807
// --------------------------------------------------
// If an NPC check if friendly fire is disallowed
// --------------------------------------------------
// --> Mirv: All this disabled so we can impact friendlies
/* CAI_BaseNPC *pNPC = info.GetAttacker()->MyNPCPointer();
if ( pNPC && (pNPC->CapabilitiesGet() & bits_CAP_NO_HIT_PLAYER) && pNPC->IRelationType( this ) != D_HT )
{
return;
782783784785786787788789790791792793794795
// Prevent team damage here so blood doesn't appear
if ( info.GetAttacker()->IsPlayer() )
{
if ( !g_pGameRules->FPlayerCanTakeDamage( this, info.GetAttacker() ) )
return;
}
SetLastHitGroup( ptr->hitgroup );
switch ( ptr->hitgroup )
{
case HITGROUP_GENERIC:
break;
810811812813814815816817818819820821822823824
// Prevent team damage here so blood doesn't appear
if ( info.GetAttacker()->IsPlayer() )
{
if ( !g_pGameRules->FCanTakeDamage( this, info.GetAttacker() ) )
return;
}*/
// <-- Mirv
SetLastHitGroup( ptr->hitgroup );
// --> Mirv: No location damage please
/* switch ( ptr->hitgroup )
{
case HITGROUP_GENERIC:
break;
812813814815816817818819820821
break;
default:
break;
}
SpawnBlood(ptr->endpos, vecDir, BloodColor(), info.GetDamage());// a little surface blood.
TraceBleed( info.GetDamage(), vecDir, ptr, info.GetDamageType() );
AddMultiDamage( info, this );
}
}
841842843844845846847848849850851852853854855856
break;
default:
break;
}*/
// <-- Mirv: No location damage please
// Fix blood showing for teammates when FF is off.
if ( g_pGameRules->FCanTakeDamage( ToFFPlayer(this), info.GetAttacker()))
{
SpawnBlood(ptr->endpos, vecDir, BloodColor(), info.GetDamage());// a little surface blood.
TraceBleed( info.GetDamage(), vecDir, ptr, info.GetDamageType() );
}
AddMultiDamage( info, this );
}
}
977978979980981982983
// go take the damage first
if ( !g_pGameRules->FPlayerCanTakeDamage( this, info.GetAttacker() ) )
{
// Refuse the damage
return 0;
1012101310141015101610171018
// go take the damage first
if ( !g_pGameRules->FCanTakeDamage( this, info.GetAttacker() ) )
{
// Refuse the damage
return 0;
137113721373137413751376
}
UpdateClientData();
}
bool CBasePlayer::IsDead() const
14061407140814091410141114121413141414151416141714181419
}
UpdateClientData();
IGameEvent *pEvent = gameeventmanager->CreateEvent("player_removeallitems");
if(pEvent)
{
pEvent->SetInt("userid", GetUserID());
gameeventmanager->FireEvent(pEvent, true);
}
}
bool CBasePlayer::IsDead() const
1475147614771478147914801481148214831484
}
// don't let the status bar glitch for players with <0 health.
if (m_iHealth < -99)
{
m_iHealth = 0;
}
// holster the current weapon
if ( GetActiveWeapon() )
15181519152015211522152315241525152615271528152915301531
}
// don't let the status bar glitch for players with <0 health.
// UNDONE: Check status bar in the actual display. We need to
// allow health to go way negative for gibbing
/*
if (m_iHealth < -99)
{
m_iHealth = 0;
}
*/
// holster the current weapon
if ( GetActiveWeapon() )
1488148914901491149214931494
SetAnimation( PLAYER_DIE );
SetViewOffset( VEC_DEAD_VIEWHEIGHT );
m_lifeState = LIFE_DYING;
pl.deadflag = true;
15351536153715381539154015411542
SetAnimation( PLAYER_DIE );
// Jiggles: We're not doing the death view change here now -- see C_FFPlayer::CalcView() instead
//SetViewOffset( VEC_DEAD_VIEWHEIGHT );
m_lifeState = LIFE_DYING;
pl.deadflag = true;
1793179417951796179717981799
if (m_AirFinished < gpGlobals->curtime)
{
EmitSound( "Player.DrownStart" );
}
m_AirFinished = gpGlobals->curtime + AIRTIME;
1841184218431844184518461847184818491850
if (m_AirFinished < gpGlobals->curtime)
{
// --> Mirv: Fix the bubbly spawn start
if( GetTeamNumber() != TEAM_SPECTATOR && GetTeamNumber() != TEAM_UNASSIGNED )
EmitSound( "Player.DrownStart" );
// <-- Mirv: Fix the bubbly spawn start
}
m_AirFinished = gpGlobals->curtime + AIRTIME;
185118521853185418551856
if ( IsPlayerUnderwater() )
{
SetPlayerUnderwater( false );
}
}
else if ( GetWaterLevel() < WL_Waist )
1902190319041905190619071908
if ( IsPlayerUnderwater() )
{
SetPlayerUnderwater( false );
RemoveFlag( FL_INWATER ); // Jiggles: Added for swim animations
}
}
else if ( GetWaterLevel() < WL_Waist )
187118721873187418751876
{
SetPlayerUnderwater( true );
}
return;
}
192319241925192619271928192919301931193219331934
{
SetPlayerUnderwater( true );
}
// Jiggles: Added for swim animations
if (!(GetFlags() & FL_INWATER))
{
AddFlag( FL_INWATER );
}
// END ADD
return;
}
1893189418951896189718981899190019011902190319041905190619071908
}
#endif
if (!(GetFlags() & FL_INWATER))
{
// player enter water sound
if (GetWaterType() == CONTENTS_WATER)
{
EmitSound( "Player.Wade" );
}
AddFlag( FL_INWATER );
}
}
19511952195319541955195619571958195919601961196219631964196519661967
}
#endif
// Jon: this was causing the wade sound to loop while in water, getting rid of all footsteps and just being annoying in general
// if (!(GetFlags() & FL_INWATER))
// {
// // player enter water sound
// if (GetWaterType() == CONTENTS_WATER)
// {
// EmitSound( "Player.Wade" );
// }
// // Jiggles: Removed this line. This line added the INWATER flag right away on player spawn...umm...what?
// //AddFlag( FL_INWATER );
// }
}
2034203520362037203820392040
{
m_lifeState = LIFE_RESPAWNABLE;
}
return;
}
2093209420952096209720982099
{
m_lifeState = LIFE_RESPAWNABLE;
}
return;
}
204120422043204420452046204720482049205020512052205320542055
// if the player has been dead for one second longer than allowed by forcerespawn,
// forcerespawn isn't on. Send the player off to an intermission camera until they
// choose to respawn.
if ( g_pGameRules->IsMultiplayer() && ( gpGlobals->curtime > (m_flDeathTime + DEATH_ANIMATION_TIME) ) && !IsObserver() )
{
// go to dead camera.
StartObserverMode( m_iObserverLastMode );
}
// wait for any button down, or mp_forcerespawn is set and the respawn time is up
if (!fAnyButtonDown
&& !( g_pGameRules->IsMultiplayer() && forcerespawn.GetInt() > 0 && (gpGlobals->curtime > (m_flDeathTime + 5))) )
return;
m_nButtons = 0;
210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153
// if the player has been dead for one second longer than allowed by forcerespawn,
// forcerespawn isn't on. Send the player off to an intermission camera until they
// choose to respawn.
// Bug #0000567: Dying and electing not to respawn results in the spec hud letterbox being displayed
/*
if ( g_pGameRules->IsMultiplayer() && ( gpGlobals->curtime > (m_flDeathTime + DEATH_ANIMATION_TIME) ) && !IsObserver() )
{
// go to dead camera.
StartObserverMode( m_iObserverLastMode );
}
*/
// Bug #0000569: Choosing a team after joining the server causes you to get stuck for a few seconds
// Respawn now because you just changed teams/joined the server/map change etc.
if( m_flNextSpawnDelay == -1 )
{
respawn( this, !IsObserver() );
}
// Bug #0000578: Suiciding using /kill doesn't cause a respawn delay
float fTimeDelta = m_flDeathTime + m_flNextSpawnDelay - gpGlobals->curtime;
// I changed this so that we can display messages to the player when they're dead
// the old version just spammed an empty message at the player when it was time to spawn. -> Defrag
if( fTimeDelta > 0.0f )
{
char szSpawnTime[ 10 ];
Q_snprintf( szSpawnTime, sizeof( szSpawnTime ), "%.2f", m_flDeathTime + m_flNextSpawnDelay - gpGlobals->curtime );
ClientPrint( this, HUD_PRINTCENTER, "#FF_CANTSPAWN", szSpawnTime );
}
// display the ready to spawn message for two seconds after the respawn timer has expired
// but only if there actually was a delay in the first place -> Defrag
else if( fTimeDelta > -2.0f && m_flNextSpawnDelay > 0.01f )
{
ClientPrint( this, HUD_PRINTCENTER, "#FF_READYTOSPAWN" );
}
else
// clear it out
ClientPrint( this, HUD_PRINTCENTER, "" );
// Can't respawn if there's a spawn delay
if( gpGlobals->curtime < ( m_flDeathTime + m_flNextSpawnDelay ) )
{
// Return so we don't allow the player a chance to respawn
return;
}
// wait for any button down, or mp_forcerespawn is set and the respawn time is up
if (!fAnyButtonDown
&& !( g_pGameRules->IsMultiplayer() && forcerespawn.GetInt() > 0 && (gpGlobals->curtime > (m_flDeathTime + 0.5f))) ) // |-- Mirv: No minimum length death time
return;
m_nButtons = 0;
2058205920602061206220632064
//Msg( "Respawn\n");
respawn( this, !IsObserver() );// don't copy a corpse if we're in deathcam.
SetNextThink( TICK_NEVER_THINK );
}
/*
2156215721582159216021612162
//Msg( "Respawn\n");
respawn( this, !IsObserver() );// don't copy a corpse if we're in deathcam.
// SetNextThink( TICK_NEVER_THINK ); // |-- Mirv: Still think because respawn may not be possible
}
/*
2181218221832184218521862187
return true;
}
bool CBasePlayer::SetObserverMode(int mode )
{
if ( mode < OBS_MODE_NONE || mode > OBS_MODE_ROAMING )
return false;
2279228022812282228322842285
return true;
}
bool CBasePlayer::SetObserverMode(int mode)
{
if ( mode < OBS_MODE_NONE || mode > OBS_MODE_ROAMING )
return false;
2229223022312232223322342235
SetViewOffset( vec3_origin );
SetMoveType( MOVETYPE_OBSERVER );
break;
}
CheckObserverSettings();
23272328232923302331233223332334233523362337233823392340
SetViewOffset( vec3_origin );
SetMoveType( MOVETYPE_OBSERVER );
break;
}
// Recenter the eye angles.
if(mode != OBS_MODE_DEATHCAM)
{
QAngle eyeAngles = EyeAngles();
eyeAngles.z = 0.f;
SnapEyeAngles(eyeAngles);
}
CheckObserverSettings();
249724982499250025012502
JumptoPosition( tr.endpos, target->EyeAngles() );
}
return true;
}
26022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636
JumptoPosition( tr.endpos, target->EyeAngles() );
}
// Dexter: always set our conc time to new observer.
// reason is, if we switch obs mode from in eye or to a new target
// update conc status appropriately (remove/update).
CFFPlayer *pFFSelf = ToFFPlayer( this );
if ( pFFSelf )
{
if ( m_iObserverMode == OBS_MODE_IN_EYE )
{
// we are still in eye, so update conc status to match this dude
CFFPlayer *pFFNewSpecTarget = ToFFPlayer( target );
if ( pFFNewSpecTarget )
{
pFFSelf->m_flConcTime = pFFNewSpecTarget->m_flConcTime;
float timeRemaining = pFFNewSpecTarget->m_flConcTime == -1 ? -1 : (pFFNewSpecTarget->m_flConcTime > gpGlobals->curtime ? pFFNewSpecTarget->m_flConcTime - gpGlobals->curtime : 0);
if ( timeRemaining > 0 || timeRemaining == -1 )
pFFSelf->Concuss( timeRemaining, timeRemaining );
else
pFFSelf->UnConcuss( ); // be sure to clear concussion icon
}
}
else
{
// clear conc time if we went to roaming etc
pFFSelf->UnConcuss();
}
}
return true;
}
25072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550
// MOD AUTHORS: Add checks on target here or in derived methode
if ( !target->IsPlayer() ) // only track players
return false;
CBasePlayer * player = ToBasePlayer( target );
/* Don't spec observers or players who haven't picked a class yet
if ( player->IsObserver() )
return false; */
if( player == this )
return false; // We can't observe ourselves.
if ( player->IsEffectActive( EF_NODRAW ) ) // don't watch invisible players
return false;
if ( player->m_lifeState == LIFE_RESPAWNABLE ) // target is dead, waiting for respawn
return false;
if ( player->m_lifeState == LIFE_DEAD || player->m_lifeState == LIFE_DYING )
{
if ( (player->m_flDeathTime + DEATH_ANIMATION_TIME ) < gpGlobals->curtime )
{
return false; // allow watching until 3 seconds after death to see death animation
}
}
// check forcecamera settings for active players
if ( GetTeamNumber() != TEAM_SPECTATOR )
{
switch ( mp_forcecamera.GetInt() )
{
case OBS_ALLOW_ALL : break;
case OBS_ALLOW_TEAM : if ( GetTeamNumber() != target->GetTeamNumber() )
return false;
break;
case OBS_ALLOW_NONE : return false;
}
}
return true; // passed all test
}
2641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698
// MOD AUTHORS: Add checks on target here or in derived methode
if ( target->IsPlayer() ) // track players
{
CBasePlayer * player = ToBasePlayer( target );
/* Don't spec observers or players who haven't picked a class yet
if ( player->IsObserver() )
return false; */
if( player == this )
return false; // We can't observe ourselves.
// gibbed players have EF_NODRAW effect active, so make an exception for LIFE_DEAD players
if ( player->m_lifeState != LIFE_DEAD && player->m_lifeState != LIFE_RESPAWNABLE && player->IsEffectActive( EF_NODRAW ) ) // don't watch invisible players
return false;
// 0001670: Player you are spectating changes when they die
// Commenting out the death check as dead players are actually valid targets (since they respawn almost instantly anyway...)
// Might want to alter this to be controllable by lua in future as certain game types may not allow respawning -> Defrag
//if ( player->m_lifeState == LIFE_RESPAWNABLE ) // target is dead, waiting for respawn
// return false;
if ( player->m_lifeState == LIFE_DEAD || player->m_lifeState == LIFE_DYING )
{
if ( (player->m_flDeathTime + DEATH_ANIMATION_TIME ) < gpGlobals->curtime )
{
return false; // allow watching until 3 seconds after death to see death animation
}
}
// check forcecamera settings for active players
if ( GetTeamNumber() != TEAM_SPECTATOR )
{
switch ( mp_forcecamera.GetInt() )
{
case OBS_ALLOW_ALL : break;
case OBS_ALLOW_TEAM : if ( GetTeamNumber() != target->GetTeamNumber() )
return false;
break;
case OBS_ALLOW_NONE : return false;
}
}
}
else if (target->Classify() == CLASS_INFOSCRIPT) // track info_ff_scripts
{
CFFInfoScript *pInfoScript = static_cast< CFFInfoScript * >( target );
if (pInfoScript->IsRemoved())
return false;
}
else
return false; // not one of the trackable entity types
return true; // passed all test
}
273927402741274227432744274527462747274827492750275127522753
}
}
//
// ID's player as such.
//
Class_T CBasePlayer::Classify ( void )
{
return CLASS_PLAYER;
}
void CBasePlayer::ResetFragCount()
{
m_iFrags = 0;
288728882889289028912892
}
}
void CBasePlayer::ResetFragCount()
{
m_iFrags = 0;
275727582759276027612762276327642765
void CBasePlayer::IncrementFragCount( int nCount )
{
m_iFrags += nCount;
pl.frags = m_iFrags;
}
void CBasePlayer::ResetDeathCount()
{
m_iDeaths = 0;
2896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920
void CBasePlayer::IncrementFragCount( int nCount )
{
m_iFrags += nCount;
m_iFrags = min(m_iFrags, 9999); // |-- Mirv: Added to placate the trepids
pl.frags = m_iFrags;
}
void CBasePlayer::ResetFortPointsCount()
{
m_iFortPoints = 0;
//pl.fortpoints = m_iFortPoints;
}
void CBasePlayer::IncrementFortPointsCount( int nCount )
{
m_iFortPoints += nCount;
m_iFortPoints = min(m_iFortPoints, 9999999); // |-- Mirv: Added to placate the trepids
//pl.fortpoints = m_iFortPoints;
}
void CBasePlayer::ResetDeathCount()
{
m_iDeaths = 0;
279327942795279627972798
pl.frags = m_iFrags;
}
void CBasePlayer::AddPointsToTeam( int score, bool bAllowNegativeScore )
{
if ( GetTeam() )
2948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975
pl.frags = m_iFrags;
}
void CBasePlayer::AddFortPoints( int iFortpoints, const char *szDescription )
{
m_iFortPoints += iFortpoints;
//pl.fortpoints = m_iFortPoints;
//ClientPrint( this, HUD_PRINTTALK, ("You scored " + (char *) fortpoints + " points!") );
//ClientPrint( this, HUD_PRINTTALK, "#FF_SCOREPOINTS", fortpoints );
CSingleUserRecipientFilter filter( this );
filter.MakeReliable();
// set latest score on user HUD
UserMessageBegin( filter, "SetPlayerLatestFortPoints" );
WRITE_STRING( szDescription );
WRITE_SHORT( iFortpoints );
MessageEnd();
// set new total score on user HUD
UserMessageBegin( filter, "SetPlayerTotalFortPoints" );
WRITE_LONG( m_iFortPoints );
MessageEnd();
}
void CBasePlayer::AddPointsToTeam( int score, bool bAllowNegativeScore )
{
if ( GetTeam() )
3124312531263127312831293130
// FIXME: Should this occur after simulation of children so
// that they are in the timespace of the player?
gpGlobals->curtime = savetime;
gpGlobals->frametime = saveframetime;
}
unsigned int CBasePlayer::PhysicsSolidMaskForEntity() const
3301330233033304330533063307330833093310331133123313
// FIXME: Should this occur after simulation of children so
// that they are in the timespace of the player?
gpGlobals->curtime = savetime;
gpGlobals->frametime = saveframetime;
// Since this isn't called for bots.. call it here?
if(m_pPhysicsController && IsBot())
{
UpdateVPhysicsPosition( m_vNewVPhysicsPosition, m_vNewVPhysicsVelocity, gpGlobals->frametime );
}
}
unsigned int CBasePlayer::PhysicsSolidMaskForEntity() const
317831793180318131823183
//-----------------------------------------------------------------------------
void CBasePlayer::PlayerRunCommand(CUserCmd *ucmd, IMoveHelper *moveHelper)
{
m_touchedPhysObject = false;
if ( pl.fixangle == FIXANGLE_NONE)
336133623363336433653366336733683369
//-----------------------------------------------------------------------------
void CBasePlayer::PlayerRunCommand(CUserCmd *ucmd, IMoveHelper *moveHelper)
{
if( GetTeamNumber() <= TEAM_SPECTATOR )
ucmd->buttons &= ~IN_USE;
m_touchedPhysObject = false;
if ( pl.fixangle == FIXANGLE_NONE)
3193319431953196319731983199
ucmd->forwardmove = 0;
ucmd->sidemove = 0;
ucmd->upmove = 0;
ucmd->buttons = 0;
ucmd->impulse = 0;
VectorCopy ( pl.v_angle, ucmd->viewangles );
}
33793380338133823383338433853386
ucmd->forwardmove = 0;
ucmd->sidemove = 0;
ucmd->upmove = 0;
// Jiggles: Don't block the USE key b/c we need it for squeek's training map (but still block everything else)
ucmd->buttons &= IN_USE;
ucmd->impulse = 0;
VectorCopy ( pl.v_angle, ucmd->viewangles );
}
4716471747184719472047214722
// have the player kill themself
m_iHealth = 0;
Event_Killed( CTakeDamageInfo( this, this, 0, DMG_NEVERGIB ) );
Event_Dying();
}
490349044905490649074908490949104911491249134914491549164917
// have the player kill themself
m_iHealth = 0;
// Bug #0000700: people with infection should give medic kill if they suicide
CFFPlayer *pPlayer = ToFFPlayer( this );
if( pPlayer && pPlayer->GetSpecialInfectedDeath() && pPlayer->IsInfected() && pPlayer->GetInfector() )
{
Event_Killed( CTakeDamageInfo( pPlayer->GetInfector(), pPlayer->GetInfector(), 0, DMG_NEVERGIB ) ); // |-- Mirv: pInflictor = NULL so that death message is "x died."
}
else
Event_Killed( CTakeDamageInfo( NULL, this, 0, DMG_NEVERGIB ) ); // |-- Mirv: pInflictor = NULL so that death message is "x died."
Event_Dying();
}
48684869487048714872487348744875487648774878
}
OnVehicleEnd( vNewPos );
SetAbsOrigin( vNewPos );
SetAbsAngles( qAngles );
// Clear out any leftover velocity
SetAbsVelocity( vec3_origin );
qAngles[ROLL] = 0;
SnapEyeAngles( qAngles );
#ifndef HL2_DLL
506350645065506650675068506950705071507250735074
}
OnVehicleEnd( vNewPos );
SetAbsOrigin( vNewPos );
qAngles[ ROLL ] = 0; // |- mulch
SetAbsAngles( qAngles );
// Clear out any leftover velocity
SetAbsVelocity( vec3_origin );
//qAngles[ROLL] = 0; |- mulch
SnapEyeAngles( qAngles );
#ifndef HL2_DLL
505150525053505450555056
pent->Touch( this );
}
return pent;
}
52475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272
pent->Touch( this );
}
// --> Mirv: Dropped weapon fix
// Sometimes weapons aren't equipped, for some reason. This seems to happen during
// telefrags (either occasionally or constantly) and rapidly dying in respawn spam.
// Check if the weapon has really been picked up and remove if it hasn't.
if (pent->GetOwnerEntity() != this)
{
pent->SetTouch(NULL);
UTIL_Remove(pent);
}
// <-- Mirv
IGameEvent *pEvent = gameeventmanager->CreateEvent("player_additem");
if(pEvent)
{
pEvent->SetInt("userid", GetUserID());
pEvent->SetString("item", pszName);
gameeventmanager->FireEvent(pEvent, true);
}
return pent;
}
523052315232523352345235
void CBasePlayer::ImpulseCommands( )
{
trace_t tr;
int iImpulse = (int)m_nImpulse;
544654475448544954505451545254535454
void CBasePlayer::ImpulseCommands( )
{
if( GetTeamNumber() <= TEAM_SPECTATOR )
return;
trace_t tr;
int iImpulse = (int)m_nImpulse;
56675668566956705671567256735674
// add 1 to frags to balance out the 1 subtracted for killing yourself
IncrementFragCount( 1 );
}
RemoveAllItems( true );
ChangeTeam( TEAM_SPECTATOR );
588658875888588958905891589258935894589558965897589858995900590159025903
// add 1 to frags to balance out the 1 subtracted for killing yourself
IncrementFragCount( 1 );
}
RemoveAllItems( true );
// dexter - if a FF Player, be sure to remove buildables
// note: could we just remove this console command and force the player to use existing team spec/menu code?
CFFPlayer *pPlayer = ToFFPlayer(this);
if(pPlayer)
{
//DevMsg("removing buildables from steamid %s", pPlayer->m_PlayerInfo.GetNetworkIDString());
pPlayer->RemoveProjectiles();
pPlayer->RemoveBackpacks();
pPlayer->RemoveBuildables();
}
ChangeTeam( TEAM_SPECTATOR );
5772577357745775577657775778577957805781578257835784
return true;
}
else if ( stricmp( cmd, "spec_goto" ) == 0 ) // chase next player
{
if ( ( GetObserverMode() == OBS_MODE_FIXED ||
GetObserverMode() == OBS_MODE_ROAMING ) &&
engine->Cmd_Argc() == 6 )
{
Vector origin;
origin.x = atof( engine->Cmd_Argv(1) );
origin.y = atof( engine->Cmd_Argv(2) );
60016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047
return true;
}
else if ( stricmp( cmd, "spec_item" ) == 0 ) // chase next player
{
if ( GetObserverMode() > OBS_MODE_FIXED &&
engine->Cmd_Argc() == 2 )
{
CFFInfoScript *target = NULL;
CFFInfoScript *pEnt = (CFFInfoScript*)gEntList.FindEntityByClassT( NULL, CLASS_INFOSCRIPT );
while( pEnt != NULL )
{
if ( FStrEq( STRING(pEnt->GetEntityName()), engine->Cmd_Argv(1) ) )
{
target = pEnt;
break;
}
// Next!
pEnt = (CFFInfoScript*)gEntList.FindEntityByClassT( pEnt, CLASS_INFOSCRIPT );
}
if ( IsValidObserverTarget( target ) )
{
SetObserverTarget( target );
}
}
return true;
}
else if ( stricmp( cmd, "spec_goto" ) == 0 ) // chase next player
{
if ( (GetObserverMode() == OBS_MODE_FIXED
|| GetObserverMode() == OBS_MODE_ROAMING
|| GetObserverMode() > OBS_MODE_FIXED)
&& engine->Cmd_Argc() == 6 )
{
// if is a spec and in a valid obs mode but not in roaming yet, then force roaming
if (!(GetObserverMode() == OBS_MODE_FIXED || GetObserverMode() == OBS_MODE_ROAMING))
SetObserverMode( OBS_MODE_ROAMING );
Vector origin;
origin.x = atof( engine->Cmd_Argv(1) );
origin.y = atof( engine->Cmd_Argv(2) );
6000600160026003600460056006
gInitHUD = false;
UserMessageBegin( user, "ResetHUD" );
WRITE_BYTE( 0 );
MessageEnd();
if ( !m_fGameHUDInitialized )
6263626462656266626762686269
gInitHUD = false;
UserMessageBegin( user, "ResetHUD" );
//WRITE_BYTE( 0 );
MessageEnd();
if ( !m_fGameHUDInitialized )
608360846085608660876088
&& ( m_nPoisonDmg > m_nPoisonRestored )
&& ( m_iHealth < 100 );
// Let any global rules update the HUD, too
g_pGameRules->UpdateClientData( this );
}
63466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386
&& ( m_nPoisonDmg > m_nPoisonRestored )
&& ( m_iHealth < 100 );
// --> Mirv: Damage indicators too
if (m_DmgTake || m_DmgSave || m_bitsHUDDamage != m_bitsDamageType)
{
// Comes from inside me if not set
Vector damageOrigin = GetLocalOrigin();
// send "damage" message
// causes screen to flash, and pain compass to show direction of damage
damageOrigin = m_DmgOrigin;
// only send down damage type that have hud art
int visibleDamageBits = m_bitsDamageType & DMG_SHOWNHUD;
m_DmgTake = clamp( m_DmgTake, 0, 255 );
m_DmgSave = clamp( m_DmgSave, 0, 255 );
CSingleUserRecipientFilter user( this );
user.MakeReliable();
UserMessageBegin( user, "Damage" );
WRITE_BYTE( m_DmgSave ); // armor
WRITE_BYTE( m_DmgTake ); // health
WRITE_LONG( visibleDamageBits );
WRITE_FLOAT( damageOrigin.x ); //BUG: Should be fixed point (to hud) not floats
WRITE_FLOAT( damageOrigin.y ); //BUG: However, the HUD does _not_ implement bitfield messages (yet)
WRITE_FLOAT( damageOrigin.z ); //BUG: We use WRITE_VEC3COORD for everything else
MessageEnd();
m_DmgTake = 0;
m_DmgSave = 0;
m_bitsHUDDamage = m_bitsDamageType;
// Clear off non-time-based damage indicators
m_bitsDamageType &= DMG_TIMEBASED;
}
// <-- Mirv: Damage indicators too
// Let any global rules update the HUD, too
g_pGameRules->UpdateClientData( this );
}
696969706971697269736974697569766977697869796980
#ifndef HL2_DLL
SendPropFloat ( SENDINFO_VECTORELEM(m_vecViewOffset, 0), 8, SPROP_ROUNDDOWN, -32.0, 32.0f),
SendPropFloat ( SENDINFO_VECTORELEM(m_vecViewOffset, 1), 8, SPROP_ROUNDDOWN, -32.0, 32.0f),
SendPropFloat ( SENDINFO_VECTORELEM(m_vecViewOffset, 2), 10, SPROP_CHANGES_OFTEN, 0.0f, 128.0f),
#endif
SendPropFloat ( SENDINFO(m_flFriction), 8, SPROP_ROUNDDOWN, 0.0f, 4.0f),
SendPropArray3 ( SENDINFO_ARRAY3(m_iAmmo), SendPropInt( SENDINFO_ARRAY(m_iAmmo), 10, SPROP_UNSIGNED ) ),
SendPropInt ( SENDINFO( m_fOnTarget ), 2, SPROP_UNSIGNED ),
7267726872697270727172727273727472757276
#ifndef HL2_DLL
SendPropFloat ( SENDINFO_VECTORELEM(m_vecViewOffset, 0), 8, SPROP_ROUNDDOWN, -32.0, 32.0f),
SendPropFloat ( SENDINFO_VECTORELEM(m_vecViewOffset, 1), 8, SPROP_ROUNDDOWN, -32.0, 32.0f),
SendPropFloat ( SENDINFO_VECTORELEM(m_vecViewOffset, 2), 10, SPROP_CHANGES_OFTEN, -10.0f, 128.0f), // |-- Mirv: Adjusted for TFC style bboxes
#endif
SendPropFloat ( SENDINFO(m_flFriction), 8, SPROP_ROUNDDOWN, 0.0f, 4.0f),
SendPropInt ( SENDINFO( m_fOnTarget ), 2, SPROP_UNSIGNED ),
698469856986698769886989699069916992
SendPropEHandle ( SENDINFO( m_hLastWeapon ) ),
SendPropEHandle ( SENDINFO( m_hGroundEntity ), SPROP_CHANGES_OFTEN ),
SendPropFloat ( SENDINFO_VECTORELEM(m_vecVelocity, 0), 20, SPROP_CHANGES_OFTEN, -2048.0f, 2048.0f ),
SendPropFloat ( SENDINFO_VECTORELEM(m_vecVelocity, 1), 20, SPROP_CHANGES_OFTEN, -2048.0f, 2048.0f ),
SendPropFloat ( SENDINFO_VECTORELEM(m_vecVelocity, 2), 16, SPROP_CHANGES_OFTEN, -2048.0f, 2048.0f ),
SendPropVector ( SENDINFO( m_vecBaseVelocity ), 20, 0, -1000, 1000 ),
72807281728272837284728572867287728872897290
SendPropEHandle ( SENDINFO( m_hLastWeapon ) ),
SendPropEHandle ( SENDINFO( m_hGroundEntity ), SPROP_CHANGES_OFTEN ),
// --> Mirv: Increase bounds
SendPropFloat ( SENDINFO_VECTORELEM(m_vecVelocity, 0), 20, SPROP_CHANGES_OFTEN, /*-2048.0f*/ -4096.0f, /*2048.0f*/ 4096.0f ),
SendPropFloat ( SENDINFO_VECTORELEM(m_vecVelocity, 1), 20, SPROP_CHANGES_OFTEN, /*-2048.0f*/ -4096.0f, /*2048.0f*/ 4096.0f ),
SendPropFloat ( SENDINFO_VECTORELEM(m_vecVelocity, 2), 16, SPROP_CHANGES_OFTEN, /*-2048.0f*/ -4096.0f, /*2048.0f*/ 4096.0f ),
// <-- Mirv
SendPropVector ( SENDINFO( m_vecBaseVelocity ), 20, 0, -1000, 1000 ),
7013701470157016701770187019
SendPropDataTable(SENDINFO_DT(pl), &REFERENCE_SEND_TABLE(DT_PlayerState), SendProxy_DataTableToDataTable),
SendPropEHandle(SENDINFO(m_hVehicle)),
SendPropEHandle(SENDINFO(m_hUseEntity)),
SendPropInt (SENDINFO(m_iHealth), 10 ),
SendPropInt (SENDINFO(m_lifeState), 3, SPROP_UNSIGNED ),
SendPropFloat (SENDINFO(m_flMaxspeed), 12, SPROP_ROUNDDOWN, 0.0f, 2048.0f ), // CL
SendPropInt (SENDINFO(m_fFlags), PLAYER_FLAG_BITS, SPROP_UNSIGNED|SPROP_CHANGES_OFTEN, SendProxy_CropFlagsToPlayerFlagBitsLength ),
731173127313731473157316731773187319732073217322732373247325
SendPropDataTable(SENDINFO_DT(pl), &REFERENCE_SEND_TABLE(DT_PlayerState), SendProxy_DataTableToDataTable),
SendPropEHandle(SENDINFO(m_hVehicle)),
SendPropEHandle(SENDINFO(m_hUseEntity)),
// Added by Mulch for testing
SendPropInt (SENDINFO(m_iHealth), 10 ),
SendPropInt (SENDINFO(m_iMaxHealth), 10 ), //AfterShock: we should work this out from class
SendPropInt (SENDINFO(m_iArmor), 10 ),
SendPropInt (SENDINFO(m_iMaxArmor), 10 ), //AfterShock: we should work this out from class
SendPropArray3 ( SENDINFO_ARRAY3(m_iAmmo), SendPropInt( SENDINFO_ARRAY(m_iAmmo), 10, SPROP_UNSIGNED ), SendProxy_OnlyToObservers ),
// Added by Mulch for testing
SendPropInt (SENDINFO(m_lifeState), 3, SPROP_UNSIGNED ),
SendPropFloat (SENDINFO(m_flMaxspeed), 12, SPROP_ROUNDDOWN, 0.0f, 2048.0f ), // CL
SendPropInt (SENDINFO(m_fFlags), PLAYER_FLAG_BITS, SPROP_UNSIGNED|SPROP_CHANGES_OFTEN, SendProxy_CropFlagsToPlayerFlagBitsLength ),
7392739373947395739673977398739974007401740274037404
if ( pRequester == NULL )
return false;
// If we already have an owner, we only allow requests from that owner
if ( ( m_hZoomOwner != NULL ) && ( m_hZoomOwner != pRequester ) )
{
if ( CanOverrideEnvZoomOwner( m_hZoomOwner ) == false )
return false;
}
else
{
//FIXME: Maybe do this is as an accessor instead
if ( FOV == 0 )
769876997700770177027703770477057706770777087709771077117712
if ( pRequester == NULL )
return false;
// --> Mirv: Got rid of this, is annoying.
/*// If we already have an owner, we only allow requests from that owner
if ( ( m_hZoomOwner != NULL ) && ( m_hZoomOwner != pRequester ) )
{
if ( CanOverrideEnvZoomOwner( m_hZoomOwner ) == false )
return false;
}
else*/
// <-- Mirv: Got rid of this, is annoying.
{
//FIXME: Maybe do this is as an accessor instead
if ( FOV == 0 )
782378247825782678277828
return m_pParent->FragCount();
}
int CPlayerInfo::GetDeathCount()
{
Assert( m_pParent );
813181328133813481358136813781388139814081418142
return m_pParent->FragCount();
}
int CPlayerInfo::GetFortPointsCount()
{
Assert( m_pParent );
return m_pParent->FortPointsCount();
}
int CPlayerInfo::GetDeathCount()
{
Assert( m_pParent );