blob: c14ed1da01b9f63ccf791c23188057b37bf9a3c2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================
#include "cbase.h"
#include "c_dod_bombtarget.h"
#include "dod_shareddefs.h"
#include "c_dod_player.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
IMPLEMENT_NETWORKCLASS_ALIASED( DODBombTarget, DT_DODBombTarget )
BEGIN_NETWORK_TABLE(C_DODBombTarget, DT_DODBombTarget )
RecvPropInt( RECVINFO(m_iState) ),
RecvPropInt( RECVINFO(m_iBombingTeam) ),
RecvPropInt( RECVINFO(m_iTargetModel) ),
RecvPropInt( RECVINFO(m_iUnavailableModel) ),
END_NETWORK_TABLE()
void C_DODBombTarget::NotifyShouldTransmit( ShouldTransmitState_t state )
{
BaseClass::NotifyShouldTransmit( state );
// Turn off
if ( state == SHOULDTRANSMIT_END )
{
SetNextClientThink( CLIENT_THINK_NEVER );
}
// Turn on
if ( state == SHOULDTRANSMIT_START )
{
SetNextClientThink( CLIENT_THINK_ALWAYS );
}
}
void C_DODBombTarget::ClientThink( void )
{
// if we are near the player, maybe give them a hint!
C_DODPlayer *pPlayer = C_DODPlayer::GetLocalDODPlayer();
if ( pPlayer && pPlayer->IsAlive() )
{
Vector vecDist = GetAbsOrigin() - pPlayer->GetAbsOrigin();
if ( vecDist.Length() < 200 )
{
int iOppositeTeam = ( m_iBombingTeam == TEAM_ALLIES ) ? TEAM_AXIS : TEAM_ALLIES;
if ( pPlayer->GetTeamNumber() == m_iBombingTeam && m_iState == BOMB_TARGET_ACTIVE )
{
pPlayer->CheckBombTargetPlantHint();
}
else if ( pPlayer->GetTeamNumber() == iOppositeTeam && m_iState == BOMB_TARGET_ARMED )
{
pPlayer->CheckBombTargetDefuseHint();
}
}
}
SetNextClientThink( gpGlobals->curtime + 0.5 );
}
int C_DODBombTarget::DrawModel( int flags )
{
if ( m_iState == BOMB_TARGET_ACTIVE )
{
C_DODPlayer *pPlayer = C_DODPlayer::GetLocalDODPlayer();
int iOppositeTeam = ( m_iBombingTeam == TEAM_ALLIES ) ? TEAM_AXIS : TEAM_ALLIES;
#ifdef _DEBUG
if ( m_iBombingTeam == TEAM_UNASSIGNED )
iOppositeTeam = TEAM_UNASSIGNED;
#endif
if ( pPlayer && pPlayer->GetTeamNumber() == iOppositeTeam )
{
// draw a different model for the non-planting team
if ( GetModelIndex() != m_iUnavailableModel )
{
SetModelIndex( m_iUnavailableModel );
}
}
else
{
if ( GetModelIndex() != m_iTargetModel )
{
SetModelIndex( m_iTargetModel );
}
}
}
return BaseClass::DrawModel( flags );
}
// a player of the passed team is looking at us, see if we should
// play the hint telling them how to defuse
bool C_DODBombTarget::ShouldPlayDefuseHint( int team )
{
return ( m_iState == BOMB_TARGET_ARMED && team != m_iBombingTeam );
}
// a player of the passed team is looking at us, see if we should
// play the hint telling them how to plant a bomb here
bool C_DODBombTarget::ShouldPlayPlantHint( int team )
{
return ( m_iState == BOMB_TARGET_ACTIVE && team == m_iBombingTeam );
}
|