mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-08-30 05:59:20 +00:00
upload "kind" alien swarm
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@@ -15,11 +15,9 @@
|
||||
#include "engine/IEngineSound.h"
|
||||
#include "soundenvelope.h"
|
||||
|
||||
#ifdef TF_DLL
|
||||
#include "tf_shareddefs.h"
|
||||
#endif
|
||||
// NOTE: This has to be the last file included!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
#define CONTROL_POINT_UNLOCK_THINK "UnlockThink"
|
||||
|
||||
BEGIN_DATADESC(CTeamControlPoint)
|
||||
DEFINE_KEYFIELD( m_iszPrintName, FIELD_STRING, "point_printname" ),
|
||||
@@ -34,9 +32,6 @@ BEGIN_DATADESC(CTeamControlPoint)
|
||||
DEFINE_KEYFIELD( m_iszCaptureInProgress, FIELD_STRING, "point_capture_progress_sound" ),
|
||||
DEFINE_KEYFIELD( m_iszCaptureInterrupted, FIELD_STRING, "point_capture_interrupted_sound" ),
|
||||
DEFINE_KEYFIELD( m_bRandomOwnerOnRestart, FIELD_BOOLEAN, "random_owner_on_restart" ),
|
||||
DEFINE_KEYFIELD( m_bLocked, FIELD_BOOLEAN, "point_start_locked" ),
|
||||
|
||||
DEFINE_FUNCTION( UnlockThink ),
|
||||
|
||||
// DEFINE_FIELD( m_iTeam, FIELD_INTEGER ),
|
||||
// DEFINE_FIELD( m_iIndex, FIELD_INTEGER ),
|
||||
@@ -52,8 +47,6 @@ BEGIN_DATADESC(CTeamControlPoint)
|
||||
DEFINE_INPUTFUNC( FIELD_VOID, "ShowModel", InputShowModel ),
|
||||
DEFINE_INPUTFUNC( FIELD_VOID, "HideModel", InputHideModel ),
|
||||
DEFINE_INPUTFUNC( FIELD_VOID, "RoundActivate", InputRoundActivate ),
|
||||
DEFINE_INPUTFUNC( FIELD_INTEGER, "SetLocked", InputSetLocked ),
|
||||
DEFINE_INPUTFUNC( FIELD_INTEGER, "SetUnlockTime", InputSetUnlockTime ),
|
||||
|
||||
DEFINE_OUTPUT( m_OnCapTeam1, "OnCapTeam1" ), // these are fired whenever the point changes modes
|
||||
DEFINE_OUTPUT( m_OnCapTeam2, "OnCapTeam2" ),
|
||||
@@ -65,8 +58,6 @@ BEGIN_DATADESC(CTeamControlPoint)
|
||||
DEFINE_OUTPUT( m_OnRoundStartOwnedByTeam1, "OnRoundStartOwnedByTeam1" ), // these are fired when a round is starting
|
||||
DEFINE_OUTPUT( m_OnRoundStartOwnedByTeam2, "OnRoundStartOwnedByTeam2" ),
|
||||
|
||||
DEFINE_OUTPUT( m_OnUnlocked, "OnUnlocked" ),
|
||||
|
||||
DEFINE_THINKFUNC( AnimThink ),
|
||||
END_DATADESC();
|
||||
|
||||
@@ -80,12 +71,7 @@ CTeamControlPoint::CTeamControlPoint()
|
||||
m_TeamData.SetSize( GetNumberOfTeams() );
|
||||
m_pCaptureInProgressSound = NULL;
|
||||
|
||||
m_bLocked = false;
|
||||
m_flUnlockTime = -1;
|
||||
|
||||
#ifdef TF_DLL
|
||||
UseClientSideAnimation();
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -100,29 +86,11 @@ void CTeamControlPoint::Spawn( void )
|
||||
m_iDefaultOwner = TEAM_UNASSIGNED;
|
||||
}
|
||||
|
||||
#ifdef TF_DLL
|
||||
if ( m_iszCaptureStartSound == NULL_STRING )
|
||||
{
|
||||
m_iszCaptureStartSound = AllocPooledString( "Hologram.Start" );
|
||||
}
|
||||
if ( m_iszCaptureEndSound == NULL_STRING )
|
||||
{
|
||||
m_iszCaptureEndSound = AllocPooledString( "Hologram.Stop" );
|
||||
}
|
||||
if ( m_iszCaptureInProgress == NULL_STRING )
|
||||
{
|
||||
m_iszCaptureInProgress = AllocPooledString( "Hologram.Move" );
|
||||
}
|
||||
if ( m_iszCaptureInterrupted == NULL_STRING )
|
||||
{
|
||||
m_iszCaptureInterrupted = AllocPooledString( "Hologram.Interrupted" );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Precache();
|
||||
|
||||
InternalSetOwner( m_iDefaultOwner, false ); //init the owner of this point
|
||||
TeamplayRoundBasedRules()->RecalculateControlPointState();
|
||||
|
||||
SetActive( !m_bStartDisabled );
|
||||
|
||||
@@ -145,6 +113,8 @@ void CTeamControlPoint::Spawn( void )
|
||||
m_flLastContestedAt = -1;
|
||||
|
||||
m_pCaptureInProgressSound = NULL;
|
||||
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -267,9 +237,7 @@ void CTeamControlPoint::Precache( void )
|
||||
PrecacheScriptSound( STRING( m_iszWarnSound ) );
|
||||
}
|
||||
|
||||
#ifdef TF_DLL
|
||||
PrecacheScriptSound( "Announcer.ControlPointContested" );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -290,7 +258,6 @@ void CTeamControlPoint::InputReset( inputdata_t &input )
|
||||
m_flLastContestedAt = -1;
|
||||
InternalSetOwner( m_iDefaultOwner, false );
|
||||
ObjectiveResource()->SetOwningTeam( GetPointIndex(), m_iTeam );
|
||||
TeamplayRoundBasedRules()->RecalculateControlPointState();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -306,18 +273,8 @@ void CTeamControlPoint::HandleScoring( int iTeam )
|
||||
CTeamControlPointMaster *pMaster = g_hControlPointMasters.Count() ? g_hControlPointMasters[0] : NULL;
|
||||
if ( pMaster && !pMaster->WouldNewCPOwnerWinGame( this, iTeam ) )
|
||||
{
|
||||
#ifdef TF_DLL
|
||||
if ( TeamplayRoundBasedRules()->GetGameType() == TF_GAMETYPE_ESCORT )
|
||||
{
|
||||
CBroadcastRecipientFilter filter;
|
||||
EmitSound( filter, entindex(), "Hud.EndRoundScored" );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
CTeamRecipientFilter filter( iTeam );
|
||||
EmitSound( filter, entindex(), "Hud.EndRoundScored" );
|
||||
}
|
||||
CTeamRecipientFilter filter( iTeam );
|
||||
EmitSound( filter, entindex(), "Hud.EndRoundScored" );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -333,9 +290,6 @@ void CTeamControlPoint::InputSetOwner( inputdata_t &input )
|
||||
|
||||
Assert( input.pCaller );
|
||||
|
||||
if ( !input.pCaller )
|
||||
return;
|
||||
|
||||
if ( GetOwner() == iCapTeam )
|
||||
return;
|
||||
|
||||
@@ -355,7 +309,6 @@ void CTeamControlPoint::InputSetOwner( inputdata_t &input )
|
||||
}
|
||||
|
||||
ObjectiveResource()->SetOwningTeam( GetPointIndex(), m_iTeam );
|
||||
TeamplayRoundBasedRules()->RecalculateControlPointState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -429,7 +382,6 @@ void CTeamControlPoint::ForceOwner( int iTeam )
|
||||
{
|
||||
InternalSetOwner( iTeam, false, 0, 0 );
|
||||
ObjectiveResource()->SetOwningTeam( GetPointIndex(), m_iTeam );
|
||||
TeamplayRoundBasedRules()->RecalculateControlPointState();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -444,7 +396,6 @@ void CTeamControlPoint::SetOwner( int iCapTeam, bool bMakeSound, int iNumCappers
|
||||
|
||||
InternalSetOwner( iCapTeam, bMakeSound, iNumCappers, pCappingPlayers );
|
||||
ObjectiveResource()->SetOwningTeam( GetPointIndex(), m_iTeam );
|
||||
TeamplayRoundBasedRules()->RecalculateControlPointState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,18 +406,6 @@ void CTeamControlPoint::CaptureStart( int iCapTeam, int iNumCappingPlayers, int
|
||||
{
|
||||
int iNumCappers = iNumCappingPlayers;
|
||||
|
||||
float flLastOwnershipChangeTime = -1.f;
|
||||
CBaseEntity *pEnt = gEntList.FindEntityByClassname( NULL, GetControlPointMasterName() );
|
||||
while( pEnt )
|
||||
{
|
||||
CTeamControlPointMaster *pMaster = dynamic_cast<CTeamControlPointMaster *>( pEnt );
|
||||
if ( pMaster && pMaster->IsActive() )
|
||||
{
|
||||
flLastOwnershipChangeTime = pMaster->GetLastOwnershipChangeTime();
|
||||
}
|
||||
pEnt = gEntList.FindEntityByClassname( pEnt, GetControlPointMasterName() );
|
||||
}
|
||||
|
||||
IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_point_startcapture" );
|
||||
if ( event )
|
||||
{
|
||||
@@ -474,7 +413,6 @@ void CTeamControlPoint::CaptureStart( int iCapTeam, int iNumCappingPlayers, int
|
||||
event->SetString( "cpname", STRING( m_iszPrintName ) );
|
||||
event->SetInt( "team", m_iTeam );
|
||||
event->SetInt( "capteam", iCapTeam );
|
||||
event->SetFloat( "captime", gpGlobals->curtime - flLastOwnershipChangeTime );
|
||||
|
||||
// safety check
|
||||
if ( iNumCappers > 8 )
|
||||
@@ -683,7 +621,6 @@ void CTeamControlPoint::InternalSetOwner( int iCapTeam, bool bMakeSound, int iNu
|
||||
if ( pMaster->IsActive() )
|
||||
{
|
||||
pMaster->CheckWinConditions();
|
||||
pMaster->SetLastOwnershipChangeTime( gpGlobals->curtime );
|
||||
}
|
||||
|
||||
pEnt = gEntList.FindEntityByClassname( pEnt, GetControlPointMasterName() );
|
||||
@@ -813,15 +750,6 @@ void CTeamControlPoint::SetCappersRequiredForTeam( int iGameTeam, int iCappers )
|
||||
m_TeamData[iGameTeam].iPlayersRequired = iCappers;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Return true if this point has ever been contested, false if the enemy has never contested this point yet
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CTeamControlPoint::HasBeenContested( void ) const
|
||||
{
|
||||
return m_flLastContestedAt > 0.0f;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -970,108 +898,4 @@ void CTeamControlPoint::InputRoundActivate( inputdata_t &inputdata )
|
||||
m_OnRoundStartOwnedByTeam2.FireOutput( this, this );
|
||||
break;
|
||||
}
|
||||
|
||||
InternalSetLocked( m_bLocked );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTeamControlPoint::InputSetLocked( inputdata_t &inputdata )
|
||||
{
|
||||
// never lock/unlock the point if we're in waiting for players
|
||||
if ( TeamplayRoundBasedRules() && TeamplayRoundBasedRules()->IsInWaitingForPlayers() )
|
||||
return;
|
||||
|
||||
bool bLocked = inputdata.value.Int() > 0;
|
||||
InternalSetLocked( bLocked );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTeamControlPoint::InternalSetLocked( bool bLocked )
|
||||
{
|
||||
if ( !bLocked && m_bLocked )
|
||||
{
|
||||
// unlocked this point
|
||||
IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_point_unlocked" );
|
||||
if ( event )
|
||||
{
|
||||
event->SetInt( "cp", m_iPointIndex );
|
||||
event->SetString( "cpname", STRING( m_iszPrintName ) );
|
||||
event->SetInt( "team", m_iTeam );
|
||||
gameeventmanager->FireEvent( event );
|
||||
}
|
||||
}
|
||||
else if ( bLocked && !m_bLocked )
|
||||
{
|
||||
// locked this point
|
||||
IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_point_locked" );
|
||||
if ( event )
|
||||
{
|
||||
event->SetInt( "cp", m_iPointIndex );
|
||||
event->SetString( "cpname", STRING( m_iszPrintName ) );
|
||||
event->SetInt( "team", m_iTeam );
|
||||
gameeventmanager->FireEvent( event );
|
||||
}
|
||||
}
|
||||
|
||||
m_bLocked = bLocked;
|
||||
|
||||
if ( ObjectiveResource() && GetPointIndex() < ObjectiveResource()->GetNumControlPoints() )
|
||||
{
|
||||
ObjectiveResource()->SetCPLocked( GetPointIndex(), m_bLocked );
|
||||
ObjectiveResource()->SetCPUnlockTime( GetPointIndex(), 0.0f );
|
||||
}
|
||||
|
||||
if ( !m_bLocked )
|
||||
{
|
||||
m_flUnlockTime = -1;
|
||||
m_OnUnlocked.FireOutput( this, this );
|
||||
SetContextThink( NULL, 0, CONTROL_POINT_UNLOCK_THINK );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTeamControlPoint::InputSetUnlockTime( inputdata_t &inputdata )
|
||||
{
|
||||
// never lock/unlock the point if we're in waiting for players
|
||||
if ( TeamplayRoundBasedRules() && TeamplayRoundBasedRules()->IsInWaitingForPlayers() )
|
||||
return;
|
||||
|
||||
int nTime = inputdata.value.Int();
|
||||
|
||||
if ( nTime <= 0 )
|
||||
{
|
||||
InternalSetLocked( false );
|
||||
return;
|
||||
}
|
||||
|
||||
m_flUnlockTime = gpGlobals->curtime + nTime;
|
||||
|
||||
if ( ObjectiveResource() )
|
||||
{
|
||||
ObjectiveResource()->SetCPUnlockTime( GetPointIndex(), m_flUnlockTime );
|
||||
}
|
||||
|
||||
SetContextThink( &CTeamControlPoint::UnlockThink, gpGlobals->curtime + 0.1, CONTROL_POINT_UNLOCK_THINK );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTeamControlPoint::UnlockThink( void )
|
||||
{
|
||||
if ( m_flUnlockTime > 0 &&
|
||||
m_flUnlockTime < gpGlobals->curtime &&
|
||||
( TeamplayRoundBasedRules() && TeamplayRoundBasedRules()->State_Get() == GR_STATE_RND_RUNNING ) )
|
||||
{
|
||||
InternalSetLocked( false );
|
||||
return;
|
||||
}
|
||||
|
||||
SetContextThink( &CTeamControlPoint::UnlockThink, gpGlobals->curtime + 0.1, CONTROL_POINT_UNLOCK_THINK );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user