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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: A clientside, visual only model that's positioned relative to players
//
//=============================================================================
#include "cbase.h"
#include "c_playerrelativemodel.h"
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
C_PlayerRelativeModel *C_PlayerRelativeModel::Create( const char *pszModelName, C_BaseEntity *pParent, Vector vecOffset, QAngle angleOffset, float flAnimSpeed, float flLifetime, int iFlags )
{
C_PlayerRelativeModel *pFlash = new C_PlayerRelativeModel;
if ( !pFlash )
return NULL;
if ( !pFlash->Initialize( pszModelName, pParent, vecOffset, angleOffset, flAnimSpeed, flLifetime, iFlags ) )
return NULL;
return pFlash;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool C_PlayerRelativeModel::Initialize( const char *pszModelName, C_BaseEntity *pParent, Vector vecOffset, QAngle angleOffset, float flAnimSpeed, float flLifetime, int iFlags )
{
AddEffects( EF_NORECEIVESHADOW | EF_NOSHADOW );
if ( InitializeAsClientEntity( pszModelName, RENDER_GROUP_OPAQUE_ENTITY ) == false )
{
Release();
return false;
}
m_vecOffsetPos = vecOffset;
m_angleOffset = angleOffset;
SetParent( pParent, 0 );
SetLocalOrigin( vec3_origin );
SetLocalAngles( vec3_angle );
AddSolidFlags( FSOLID_NOT_SOLID );
SetLifetime( flLifetime );
SetNextClientThink( CLIENT_THINK_ALWAYS );
SetCycle( 0 );
m_qOffsetRotation = vec3_angle;
m_flAnimSpeed = flAnimSpeed;
m_iFlags = iFlags;
return true;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_PlayerRelativeModel::SetLifetime( float flLifetime )
{
if ( flLifetime == PRM_PERMANENT )
{
m_flExpiresAt = PRM_PERMANENT;
}
else
{
// Expire when the lifetime is up
m_flExpiresAt = gpGlobals->curtime + flLifetime;
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_PlayerRelativeModel::ClientThink( void )
{
if ( !GetMoveParent() || (m_flExpiresAt != PRM_PERMANENT && gpGlobals->curtime > m_flExpiresAt) )
{
Release();
return;
}
// Animate
C_BaseEntity *pParent = GetMoveParent();
Vector out(0, 0, 0);
if ( m_iFlags & PRM_SPIN_Z )
{
m_qOffsetRotation += QAngle(0, gpGlobals->frametime * m_flAnimSpeed, 0);
VectorRotate( m_vecOffsetPos, m_qOffsetRotation, out );
}
SetAbsOrigin( pParent->GetAbsOrigin() + out );
SetAbsAngles( m_qOffsetRotation + m_angleOffset );
}
//-----------------------------------------------------------------------------
// C_MerasmusBombEffect
//-----------------------------------------------------------------------------
C_MerasmusBombEffect *C_MerasmusBombEffect::Create( const char *pszModelName, C_TFPlayer *pParent, Vector vecOffset, QAngle angleOffset, float flAnimSpeed, float flLifetime, int iFlags )
{
C_MerasmusBombEffect *pFlash = new C_MerasmusBombEffect;
if ( !pFlash )
return NULL;
if ( !pFlash->Initialize( pszModelName, pParent, vecOffset, angleOffset, flAnimSpeed, flLifetime, iFlags ) )
return NULL;
return pFlash;
}
//-----------------------------------------------------------------------------
bool C_MerasmusBombEffect::Initialize( const char *pszModelName, C_TFPlayer *pParent, Vector vecOffset, QAngle angleOffset, float flAnimSpeed, float flLifetime, int iFlags )
{
if ( !BaseClass::Initialize(pszModelName, pParent, vecOffset, angleOffset, flAnimSpeed, flLifetime, iFlags ) )
return false;
// Create a particle effect
const char *pszEffectName = "bombonomicon_spell_trail";
if ( m_pBombonomiconBeam )
{
m_pBombonomiconBeam->StopEmission();
m_pBombonomiconBeam = NULL;
}
if ( m_pBombonomiconEffect )
{
m_pBombonomiconEffect->StopEmission();
m_pBombonomiconEffect = NULL;
}
m_pBombonomiconBeam = ParticleProp()->Create( pszEffectName, PATTACH_ABSORIGIN_FOLLOW, INVALID_PARTICLE_ATTACHMENT, Vector(0,0,-10) );
if ( m_pBombonomiconBeam )
{
ParticleProp()->AddControlPoint( m_pBombonomiconBeam, 1, pParent, PATTACH_POINT_FOLLOW, "head", Vector(0,0,0) );
}
return true;
}
//-----------------------------------------------------------------------------
void C_MerasmusBombEffect::ClientThink( void )
{
if ( !GetMoveParent() || (m_flExpiresAt != PRM_PERMANENT && gpGlobals->curtime > m_flExpiresAt) )
{
if ( m_pBombonomiconBeam )
{
m_pBombonomiconBeam->StopEmission();
m_pBombonomiconBeam = NULL;
}
if ( m_pBombonomiconEffect )
{
m_pBombonomiconEffect->StopEmission();
m_pBombonomiconEffect = NULL;
}
}
BaseClass::ClientThink();
}
|