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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "tf_shield_flat.h"
#include "tf_shieldshared.h"
//-----------------------------------------------------------------------------
// Data tables
//-----------------------------------------------------------------------------
LINK_ENTITY_TO_CLASS( shield_flat, CShieldFlat );
IMPLEMENT_SERVERCLASS_ST(CShieldFlat, DT_Shield_Flat)
SendPropInt (SENDINFO(m_ShieldState), 2, SPROP_UNSIGNED ),
SendPropFloat (SENDINFO(m_Width), 8, 0, 0, 256 ),
SendPropFloat (SENDINFO(m_Height), 8, 0, 0, 256 ),
END_SEND_TABLE()
//-----------------------------------------------------------------------------
// Spawn
//-----------------------------------------------------------------------------
void CShieldFlat::Spawn( )
{
BaseClass::Spawn();
m_ShieldState = 0;
ShieldMoved();
}
//-----------------------------------------------------------------------------
// Computes the shield bounding box
//-----------------------------------------------------------------------------
void CShieldFlat::ShieldMoved( void )
{
Vector forward, right, up;
AngleVectors( GetAbsAngles(), &forward, &right, &up );
VectorMA( GetAbsOrigin(), -m_Width * 0.5, right, m_Pos[0] );
VectorMA( m_Pos[0], -m_Height * 0.5, up, m_Pos[0] );
VectorMA( m_Pos[0], m_Width, right, m_Pos[1] );
VectorMA( m_Pos[0], m_Height, up, m_Pos[2] );
VectorMA( m_Pos[2], m_Width, right, m_Pos[3] );
m_LastAngles = GetAbsAngles();
m_LastPosition = GetAbsOrigin();
}
//-----------------------------------------------------------------------------
// Shield size
//-----------------------------------------------------------------------------
void CShieldFlat::SetSize( float w, float h )
{
m_Width = w;
m_Height = h;
Vector mins( -1.0/16.0f, -w * 0.5f, -h * 0.5f );
Vector maxs( 1.0/16.0f, w * 0.5f, h * 0.5f );
UTIL_SetSize( this, mins, maxs );
ShieldMoved();
}
//-----------------------------------------------------------------------------
// Compute world axis-aligned bounding box
//-----------------------------------------------------------------------------
void CShieldFlat::ComputeWorldSpaceSurroundingBox( Vector *pWorldMins, Vector *pWorldMaxs )
{
TransformAABB( CollisionProp()->CollisionToWorldTransform(),
CollisionProp()->OBBMins(), CollisionProp()->OBBMaxs(), *pWorldMins, *pWorldMaxs );
}
//-----------------------------------------------------------------------------
// Shield points
//-----------------------------------------------------------------------------
const Vector& CShieldFlat::GetPoint( int x, int y )
{
if ((m_LastAngles != GetAbsAngles()) || (m_LastPosition != GetAbsOrigin() ))
{
ShieldMoved();
}
int i = (x >= 1);
i += (y >= 1) * 2;
return m_Pos[i];
}
//-----------------------------------------------------------------------------
// Called when the shield is EMPed
//-----------------------------------------------------------------------------
void CShieldFlat::SetEMPed( bool isEmped )
{
CShield::SetEMPed(isEmped);
if (IsEMPed())
{
m_ShieldState |= SHIELD_FLAT_EMP;
}
else
{
m_ShieldState &= ~SHIELD_FLAT_EMP;
}
}
//-----------------------------------------------------------------------------
// Shield is killed here
//-----------------------------------------------------------------------------
void CShieldFlat::Activate( bool active )
{
if (active)
{
m_ShieldState &= ~SHIELD_FLAT_INACTIVE;
}
else
{
m_ShieldState |= SHIELD_FLAT_INACTIVE;
}
ActivateCollisions( active );
}
//-----------------------------------------------------------------------------
// Purpose: Create a mobile version of the shield
//-----------------------------------------------------------------------------
CShieldFlat* CreateFlatShield( CBaseEntity *pOwner, float w, float h, const Vector& relOrigin, const QAngle &relAngles )
{
CShieldFlat *pShield = (CShieldFlat*)CreateEntityByName("shield_flat");
pShield->SetParent( pOwner );
pShield->SetOwnerEntity( pOwner );
UTIL_SetOrigin( pShield, relOrigin );
// Compute relative angles....
pShield->SetLocalAngles( relAngles );
pShield->ChangeTeam( pOwner->GetTeamNumber() );
pShield->Spawn();
pShield->SetSize( w , h );
return pShield;
}
|