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
165
166
167
168
169
170
171
172
173
174
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "c_ai_basenpc.h"
#include "iviewrender_beams.h"
#include "beam_shared.h"
#include "materialsystem/imaterial.h"
#include "model_types.h"
#include "clienteffectprecachesystem.h"
#include "beamdraw.h"
class C_RollerMine : public C_AI_BaseNPC
{
DECLARE_CLASS( C_RollerMine, C_AI_BaseNPC );
public:
DECLARE_CLIENTCLASS();
C_RollerMine( void ) {}
int DrawModel( int flags );
RenderGroup_t GetRenderGroup( void )
{
if ( m_bIsOpen )
return RENDER_GROUP_TRANSLUCENT_ENTITY;
else
return RENDER_GROUP_OPAQUE_ENTITY;
}
private:
C_RollerMine( const C_RollerMine & ) {}
bool m_bIsOpen;
float m_flActiveTime;
bool m_bHackedByAlyx;
bool m_bPowerDown;
};
IMPLEMENT_CLIENTCLASS_DT( C_RollerMine, DT_RollerMine, CNPC_RollerMine )
RecvPropInt( RECVINFO( m_bIsOpen ) ),
RecvPropFloat( RECVINFO( m_flActiveTime ) ),
RecvPropInt( RECVINFO( m_bHackedByAlyx ) ),
RecvPropInt( RECVINFO( m_bPowerDown ) ),
END_RECV_TABLE()
#define NUM_ATTACHMENTS 11
//-----------------------------------------------------------------------------
// Purpose:
// Input : flags -
// Output : int
//-----------------------------------------------------------------------------
int C_RollerMine::DrawModel( int flags )
{
if ( m_bIsOpen && m_flActiveTime <= gpGlobals->curtime )
{
float scale = random->RandomFloat( 4.0f, 6.0f );
if ( gpGlobals->frametime != 0 )
{
// Inner beams
BeamInfo_t beamInfo;
beamInfo.m_vecStart = GetAbsOrigin();
Vector offset = RandomVector( -6*scale, 2*scale );
offset += Vector(2,2,2) * scale;
beamInfo.m_vecEnd = GetAbsOrigin() + offset;
beamInfo.m_pStartEnt= cl_entitylist->GetEnt( BEAMENT_ENTITY( entindex() ) );
beamInfo.m_pEndEnt = beamInfo.m_pStartEnt;
beamInfo.m_nStartAttachment = random->RandomInt( 0, NUM_ATTACHMENTS );
beamInfo.m_nEndAttachment = random->RandomInt( 0, NUM_ATTACHMENTS );
// Ensure we're not the same point
if ( beamInfo.m_nStartAttachment == beamInfo.m_nEndAttachment )
{
int nextStep = ( random->RandomInt( 0, 1 ) ) ? 1 : -1;
beamInfo.m_nEndAttachment = ( beamInfo.m_nStartAttachment + nextStep ) % NUM_ATTACHMENTS;
}
beamInfo.m_nType = TE_BEAMTESLA;
beamInfo.m_pszModelName = "sprites/lgtning.vmt";
beamInfo.m_flHaloScale = 0.0f;
beamInfo.m_flLife = 0.1f;
beamInfo.m_flWidth = random->RandomFloat( 2.0f, 4.0f );
beamInfo.m_flEndWidth = random->RandomFloat( 0.0f, 1.0f );
beamInfo.m_flFadeLength = 0.0f;
beamInfo.m_flAmplitude = random->RandomFloat( 16, 32 );
beamInfo.m_flBrightness = 255.0;
beamInfo.m_flSpeed = 0.0;
beamInfo.m_nStartFrame = 0.0;
beamInfo.m_flFrameRate = 1.0f;
if ( m_bPowerDown )
{
beamInfo.m_flRed = 255.0f;;
beamInfo.m_flGreen = 64.0f;
beamInfo.m_flBlue = 64.0f;
}
else if ( m_bHackedByAlyx )
{
beamInfo.m_flRed = 240.0f;;
beamInfo.m_flGreen = 200.0f;
beamInfo.m_flBlue = 80.0f;
}
else
{
beamInfo.m_flRed = 255.0f;;
beamInfo.m_flGreen = 255.0f;
beamInfo.m_flBlue = 255.0f;
}
beamInfo.m_nSegments = 4;
beamInfo.m_bRenderable = true;
beamInfo.m_nFlags = 0;
beams->CreateBeamEntPoint( beamInfo );
// Draw the halo
float color[3];
if ( m_bHackedByAlyx )
{
color[0] = 0.25f;
color[1] = 0.05f;
color[2] = 0.0f;
}
else
{
color[0] = color[1] = color[2] = 0.15f;
}
IMaterial *pMaterial = materials->FindMaterial( "effects/rollerglow", NULL, false );
CMatRenderContextPtr pRenderContext( materials );
pRenderContext->Bind( pMaterial );
DrawHalo( pMaterial, GetAbsOrigin(), random->RandomFloat( 6.0f*scale, 6.5f*scale ), color );
if ( m_bPowerDown )
{
color[0] = random->RandomFloat( 0.80f, 1.00f );
color[1] = random->RandomFloat( 0.10f, 0.25f );
color[2] = 0.0f;
}
else if ( m_bHackedByAlyx )
{
color[0] = random->RandomFloat( 0.25f, 0.75f );
color[1] = random->RandomFloat( 0.10f, 0.25f );
color[2] = 0.0f;
}
else
{
color[0] = color[1] = color[2] = random->RandomFloat( 0.25f, 0.5f );
}
Vector attachOrigin;
QAngle attachAngles;
GetAttachment( beamInfo.m_nEndAttachment, attachOrigin, attachAngles );
DrawHalo( pMaterial, attachOrigin, random->RandomFloat( 1.0f*scale, 1.5f*scale ), color );
GetAttachment( beamInfo.m_nStartAttachment, attachOrigin, attachAngles );
DrawHalo( pMaterial, attachOrigin, random->RandomFloat( 1.0f*scale, 1.5f*scale ), color );
}
}
return BaseClass::DrawModel( flags );
}
|