-
Notifications
You must be signed in to change notification settings - Fork 836
Expand file tree
/
Copy pathclient.lua
More file actions
346 lines (260 loc) · 14.1 KB
/
client.lua
File metadata and controls
346 lines (260 loc) · 14.1 KB
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
--[[---------------------------------------------------------
Get the real frame time, instead of the
host_timescale linked frametime. This is for things
like GUI effects. NOT FOR REAL IN GAME STUFF(!!!)
-----------------------------------------------------------]]
local FrameTime = 0
local LastQuery = 0
function RealFrameTime() return FrameTime end
local function RealFrameTimeThink()
FrameTime = math.Clamp( SysTime() - LastQuery, 0, 0.1 )
LastQuery = SysTime()
end
hook.Add( "Think", "RealFrameTime", RealFrameTimeThink ) -- Think is called after every frame on the client.
-- Make Portal 2 materials work out of the box
matproxy.Add( {
name = "FizzlerVortex",
init = function( self, mat, values )
end,
bind = function( self, mat, ent )
mat:SetFloat( "$flow_color_intensity", 1 )
-- Less than ideal, but serves as an example
--[[local entities = {}
for k, v in pairs( ents.FindInSphere( ent:GetPos(), ent:BoundingRadius() ) ) do
if ( v == ent || v:GetMoveType() != MOVETYPE_VPHYSICS ) then continue end
table.insert( entities, v )
end
table.sort( entities, function( a, b ) return a:GetPos():Distance( ent:GetPos() ) < b:GetPos():Distance( ent:GetPos() ) end )
if ( entities[ 1 ] ) then
mat:SetFloat( "$FLOW_VORTEX1", 1 )
mat:SetVector( "$FLOW_VORTEX_POS1", entities[ 1 ]:GetPos() )
else
mat:SetFloat( "$FLOW_VORTEX1", 0 )
end
if ( entities[ 2 ] ) then
mat:SetFloat( "$FLOW_VORTEX2", 1 )
mat:SetVector( "$FLOW_VORTEX_POS2", entities[ 2 ]:GetPos() )
else
mat:SetFloat( "$FLOW_VORTEX2", 0 )
end]]
end
} )
local function RenderSpawnIcon_Prop( model, pos, middle, size )
if ( size < 900 ) then
size = size * ( 1 - ( size / 900 ) )
else
size = size * ( 1 - ( size / 4096 ) )
end
size = math.Clamp( size, 5, 1000 )
local ViewAngle = Angle( 25, 220, 0 )
local ViewPos = pos + ViewAngle:Forward() * size * -15
local view = {}
view.fov = 4 + size * 0.04
view.origin = ViewPos + middle
view.znear = 1
view.zfar = ViewPos:Distance( pos ) + size * 2
view.angles = ViewAngle
return view
end
local function RenderSpawnIcon_Ragdoll( model, pos, middle, size )
local at = model:GetAttachment( model:LookupAttachment( "eyes" ) )
if ( !at ) then at = { Pos = model:GetPos(), Ang = model:GetAngles() } end
local ViewAngle = at.Ang + Angle( -10, 160, 0 )
local ViewPos = at.Pos + ViewAngle:Forward() * -60 + ViewAngle:Up() * -2
local view = {}
view.fov = 10
view.origin = ViewPos
view.znear = 0.1
view.zfar = 100
view.angles = ViewAngle
return view
end
--
-- For some TF2 ragdolls which do not have "eye" attachments
--
local function RenderSpawnIcon_Ragdoll_Head( model, pos, middle, size )
local at = model:GetAttachment( model:LookupAttachment( "head" ) )
if ( !at ) then at = { Pos = model:GetPos(), Ang = model:GetAngles() } end
local ViewAngle = at.Ang + Angle( -10, 160, 0 )
local ViewPos = at.Pos + ViewAngle:Forward() * -67 + ViewAngle:Up() * -7 + ViewAngle:Right() * 1.5
local view = {}
view.fov = 10
view.origin = ViewPos
view.znear = 0.1
view.zfar = 100
view.angles = ViewAngle
return view
end
local function RenderSpawnIcon_Ragdoll_Facemask( model, pos, middle, size )
local at = model:GetAttachment( model:LookupAttachment( "facemask" ) )
if ( !at ) then at = { Pos = model:GetPos(), Ang = model:GetAngles() } end
local ViewAngle = at.Ang
ViewAngle:RotateAroundAxis( ViewAngle:Right(), -10 )
ViewAngle:RotateAroundAxis( ViewAngle:Up(), 160 )
local ViewPos = at.Pos + ViewAngle:Forward() * -67 + ViewAngle:Up() * -2 + ViewAngle:Right() * -1
local view = {}
view.fov = 10
view.origin = ViewPos
view.znear = 0.1
view.zfar = 100
view.angles = ViewAngle
return view
end
local function RenderSpawnIcon_Ragdoll_Forward( model, pos, middle, size )
local at = model:GetAttachment( model:LookupAttachment( "forward" ) )
if ( !at ) then at = { Pos = model:GetPos(), Ang = model:GetAngles() } end
local ViewAngle = at.Ang + Angle( 10, -20, 0 )
local ViewPos = at.Pos + ViewAngle:Forward() * -67 + ViewAngle:Up() * -1 + ViewAngle:Right() * 2.5
local view = {}
view.fov = 10
view.origin = ViewPos
view.znear = 0.1
view.zfar = 100
view.angles = ViewAngle
return view
end
local function RenderSpawnIcon_DOD( model, pos, middle, size )
local ViewAngle = Angle( 0, 160, 0 )
local ViewPos = pos + ViewAngle:Forward() * -67 + ViewAngle:Up() * 30 + ViewAngle:Right() * 2.5
local view = {}
view.fov = 10
view.origin = ViewPos + middle
view.znear = 1
view.zfar = ViewPos:Distance( pos ) + size * 2
view.angles = ViewAngle
return view
end
local function RenderSpawnIcon_CS( model, pos, middle, size )
local ViewAngle = Angle( 0, 160, 0 )
local ViewPos = pos + ViewAngle:Forward() * -70 + ViewAngle:Up() * 32.4 + ViewAngle:Right() * 1.5
local view = {}
view.fov = 10
view.origin = ViewPos + middle
view.znear = 1
view.zfar = ViewPos:Distance( pos ) + size * 2
view.angles = ViewAngle
return view
end
local function RenderSpawnIcon_Special( model, pos, middle, size, x, y, z )
local ViewAngle = Angle( 15, 140, 0 )
local ViewPos = pos + ViewAngle:Forward() * x + ViewAngle:Up() * y + ViewAngle:Right() * z
local view = {}
view.fov = 20
view.origin = ViewPos + middle
view.znear = 1
view.zfar = ViewPos:Distance( pos ) + size * 2
view.angles = ViewAngle
return view
end
local function RenderSpawnIcon_ViewModel( model, pos, middle, size )
-- Select the most neutral animation
model:ResetSequence( model:SelectWeightedSequence( ACT_VM_IDLE ) )
local view = {}
view.fov = 60 -- Just a value that seems to work well for various models
view.origin = Vector( -3, 0, -2 ) -- Position it so more of the model is in the frame
view.znear = 0.1
view.zfar = 100
view.angles = Angle( 0, 0, 0 )
return view
end
SpawniconGenFunctions = {}
function PositionSpawnIcon( model, pos, noAngles )
local mn, mx = model:GetRenderBounds()
local middle = ( mn + mx ) * 0.5
local size = 0
size = math.max( size, math.abs( mn.x ) + math.abs( mx.x ) )
size = math.max( size, math.abs( mn.y ) + math.abs( mx.y ) )
size = math.max( size, math.abs( mn.z ) + math.abs( mx.z ) )
model:SetPos( pos )
if ( !noAngles ) then model:SetAngles( angle_zero ) end
local ModelName = model:GetModel()
ModelName = string.Replace( ModelName, "--", "/" )
ModelName = string.Replace( ModelName, "\\", "/" )
ModelName = string.Replace( ModelName, "//", "/" )
ModelName = string.Replace( ModelName, "\\\\", "/" )
local fnc = SpawniconGenFunctions[ ModelName ]
if ( fnc ) then return fnc( model, pos, middle, size ) end
if ( model:LookupAttachment( "eyes" ) > 0 ) then
return RenderSpawnIcon_Ragdoll( model, pos, middle, size )
end
if ( model:LookupAttachment( "head" ) > 0 ) then
return RenderSpawnIcon_Ragdoll_Head( model, pos, middle, size )
end
-- CS:GO Player Models
if ( model:LookupAttachment( "facemask" ) > 0 ) then
return RenderSpawnIcon_Ragdoll_Facemask( model, pos, middle, size )
end
-- CS:GO Hostages
if ( model:LookupAttachment( "forward" ) > 0 ) then
return RenderSpawnIcon_Ragdoll_Forward( model, pos, middle, size )
end
-- View models
if ( model:SelectWeightedSequence( ACT_VM_IDLE ) >= 0 /*and model:SelectWeightedSequence( ACT_VM_DRAW ) >= 0*/ and !string.find( ModelName, "/w_" ) ) then
return RenderSpawnIcon_ViewModel( model, pos, middle, size )
end
return RenderSpawnIcon_Prop( model, pos, middle, size )
end
-- DOD Player Models
SpawniconGenFunctions[ "models/player/american_assault.mdl" ] = RenderSpawnIcon_DOD
SpawniconGenFunctions[ "models/player/american_mg.mdl" ] = RenderSpawnIcon_DOD
SpawniconGenFunctions[ "models/player/american_rifleman.mdl" ] = RenderSpawnIcon_DOD
SpawniconGenFunctions[ "models/player/american_rocket.mdl" ] = RenderSpawnIcon_DOD
SpawniconGenFunctions[ "models/player/american_sniper.mdl" ] = RenderSpawnIcon_DOD
SpawniconGenFunctions[ "models/player/american_support.mdl" ] = RenderSpawnIcon_DOD
SpawniconGenFunctions[ "models/player/german_assault.mdl" ] = RenderSpawnIcon_DOD
SpawniconGenFunctions[ "models/player/german_mg.mdl" ] = RenderSpawnIcon_DOD
SpawniconGenFunctions[ "models/player/german_rifleman.mdl" ] = RenderSpawnIcon_DOD
SpawniconGenFunctions[ "models/player/german_rocket.mdl" ] = RenderSpawnIcon_DOD
SpawniconGenFunctions[ "models/player/german_sniper.mdl" ] = RenderSpawnIcon_DOD
SpawniconGenFunctions[ "models/player/german_support.mdl" ] = RenderSpawnIcon_DOD
-- CS Player Models
SpawniconGenFunctions[ "models/player/ct_gign.mdl" ] = RenderSpawnIcon_CS
SpawniconGenFunctions[ "models/player/ct_sas.mdl" ] = RenderSpawnIcon_CS
SpawniconGenFunctions[ "models/player/ct_urban.mdl" ] = RenderSpawnIcon_CS
SpawniconGenFunctions[ "models/player/ct_gsg9.mdl" ] = RenderSpawnIcon_CS
SpawniconGenFunctions[ "models/player/t_leet.mdl" ] = RenderSpawnIcon_CS
SpawniconGenFunctions[ "models/player/t_phoenix.mdl" ] = RenderSpawnIcon_CS
SpawniconGenFunctions[ "models/player/t_arctic.mdl" ] = RenderSpawnIcon_CS
SpawniconGenFunctions[ "models/player/t_guerilla.mdl" ] = RenderSpawnIcon_CS
-- L4D Models
SpawniconGenFunctions[ "models/infected/witch.mdl" ] = function( a, b, c, d ) return RenderSpawnIcon_Special( a, b, c, d, -40, 25, 0 ) end
SpawniconGenFunctions[ "models/infected/smoker.mdl" ] = function( a, b, c, d ) return RenderSpawnIcon_Special( a, b, c, d, -60, 33, 10 ) end
SpawniconGenFunctions[ "models/infected/hunter.mdl" ] = function( a, b, c, d ) return RenderSpawnIcon_Special( a, b, c, d, -50, 26, 2 ) end
SpawniconGenFunctions[ "models/infected/hulk.mdl" ] = function( a, b, c, d ) return RenderSpawnIcon_Special( a, b, c, d, -70, 30, 11 ) end
SpawniconGenFunctions[ "models/infected/boomer.mdl" ] = function( a, b, c, d ) return RenderSpawnIcon_Special( a, b, c, d, -50, 27, 0 ) end
SpawniconGenFunctions[ "models/infected/common_female01.mdl" ] = function ( model, pos, middle, size )
local at = model:GetAttachment( model:LookupAttachment( "forward" ) )
if ( !at ) then at = { Pos = model:GetPos(), Ang = model:GetAngles() } end
local ViewAngle = at.Ang + Angle( 180, 180, 0 ) + Angle( 10, -85, -85 )
local ViewPos = at.Pos + ViewAngle:Forward() * -76 + ViewAngle:Up() * -1.5 + ViewAngle:Right() * 0
return { fov = 10, origin = ViewPos, znear = 0.1, zfar = 200, angles = ViewAngle }
end
SpawniconGenFunctions[ "models/infected/common_female_nurse01.mdl" ] = SpawniconGenFunctions[ "models/infected/common_female01.mdl" ]
SpawniconGenFunctions[ "models/infected/common_female_rural01.mdl" ] = SpawniconGenFunctions[ "models/infected/common_female01.mdl" ]
SpawniconGenFunctions[ "models/infected/common_male01.mdl" ] = SpawniconGenFunctions[ "models/infected/common_female01.mdl" ]
SpawniconGenFunctions[ "models/infected/common_test.mdl" ] = SpawniconGenFunctions[ "models/infected/common_female01.mdl" ]
SpawniconGenFunctions[ "models/infected/common_morph_test.mdl" ] = SpawniconGenFunctions[ "models/infected/common_female01.mdl" ] -- Bad start animation
SpawniconGenFunctions[ "models/infected/common_male_fallen_survivor.mdl" ] = SpawniconGenFunctions[ "models/infected/common_female01.mdl" ] -- Bad start animation
SpawniconGenFunctions[ "models/infected/common_male_baggagehandler_01.mdl" ] = SpawniconGenFunctions[ "models/infected/common_male01.mdl" ]
SpawniconGenFunctions[ "models/infected/common_male_pilot.mdl" ] = SpawniconGenFunctions[ "models/infected/common_male01.mdl" ]
SpawniconGenFunctions[ "models/infected/common_male_rural01.mdl" ] = SpawniconGenFunctions[ "models/infected/common_male01.mdl" ]
SpawniconGenFunctions[ "models/infected/common_male_suit.mdl" ] = SpawniconGenFunctions[ "models/infected/common_male01.mdl" ]
SpawniconGenFunctions[ "models/infected/common_military_male01.mdl" ] = SpawniconGenFunctions[ "models/infected/common_male01.mdl" ]
SpawniconGenFunctions[ "models/infected/common_police_male01.mdl" ] = SpawniconGenFunctions[ "models/infected/common_male01.mdl" ]
SpawniconGenFunctions[ "models/infected/common_patient_male01.mdl" ] = SpawniconGenFunctions[ "models/infected/common_male01.mdl" ]
SpawniconGenFunctions[ "models/infected/common_surgeon_male01.mdl" ] = SpawniconGenFunctions[ "models/infected/common_male01.mdl" ] -- Bad start animation
SpawniconGenFunctions[ "models/infected/common_tsaagent_male01.mdl" ] = SpawniconGenFunctions[ "models/infected/common_male01.mdl" ]
SpawniconGenFunctions[ "models/infected/common_worker_male01.mdl" ] = SpawniconGenFunctions[ "models/infected/common_male01.mdl" ]
-- ZPS Zombies
SpawniconGenFunctions[ "models/zombies/zombie0/zombie0.mdl" ] = function( a, b, c, d ) return RenderSpawnIcon_Special( a, b, c, d, -100, 17, 10 ) end
SpawniconGenFunctions[ "models/zombies/zombie1/zombie1.mdl" ] = function( a, b, c, d ) return RenderSpawnIcon_Special( a, b, c, d, -100, 17, 10 ) end
SpawniconGenFunctions[ "models/zombies/zombie2/zombie2.mdl" ] = function( a, b, c, d ) return RenderSpawnIcon_Special( a, b, c, d, -100, 17, 10 ) end
SpawniconGenFunctions[ "models/zombies/zombie3/zombie3.mdl" ] = function( a, b, c, d ) return RenderSpawnIcon_Special( a, b, c, d, -100, 17, 10 ) end
SpawniconGenFunctions[ "models/zombies/zombie4/zombie4.mdl" ] = function( a, b, c, d ) return RenderSpawnIcon_Special( a, b, c, d, -100, 17, 10 ) end
SpawniconGenFunctions[ "models/zombies/zombie5/zombie5.mdl" ] = function( a, b, c, d ) return RenderSpawnIcon_Special( a, b, c, d, -100, 17, 10 ) end
-- L4D2
SpawniconGenFunctions[ "models/infected/boomette.mdl" ] = function( a, b, c, d ) return RenderSpawnIcon_Special( a, b, c, d, -50, 28, 0 ) end
SpawniconGenFunctions[ "models/infected/charger.mdl" ] = function( a, b, c, d ) return RenderSpawnIcon_Special( a, b, c, d, -70, 14, 20 ) end
SpawniconGenFunctions[ "models/infected/jockey.mdl" ] = function( a, b, c, d ) return RenderSpawnIcon_Special( a, b, c, d, -50, 0, 7 ) end
SpawniconGenFunctions[ "models/infected/spitter.mdl" ] = function( a, b, c, d ) return RenderSpawnIcon_Special( a, b, c, d, -1, 0, -70 ) end -- as good as deleted
SpawniconGenFunctions[ "models/infected/hulk_dlc3.mdl" ] = SpawniconGenFunctions[ "models/infected/hulk.mdl" ]