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
|
local PANEL = {}
function PANEL:Init()
self:PerformLayout()
self.Wait = CurTime() + 5
self.Pos = 1
self.YPos = 220
self.ListMode = true
self.DrawTbl = {}
self.Awards = {}
self.Lists = {}
self.Lists[1] = { 5, ScrW() * 0.30, "Survivors", function() return self:GetSurvivors() end, "bot/whoo2.wav" }
self.Lists[2] = { ScrW() * 0.50 - ScrW() * 0.15, ScrW() * 0.30, "Top Killers", function() return self:GetTopKillers() end, "weapons/357_fire2.wav" }
self.Lists[3] = { ScrW() - ( ScrW() * 0.30 ) - 5, ScrW() * 0.30, "Big Spenders", function() return self:GetTopSpenders() end, "physics/metal/chain_impact_soft1.wav" }
local x, w = ScrW() * 0.50 - ScrW() * 0.15, ScrW() * 0.65 - 5
self:ListNewAward( { x, w, "Grey Matter:", "got the most headshots.", function() return self:GetStatMax( "Headshot" ) end, "zombie craniums", "player/headshot1.wav" } )
self:ListNewAward( { x, w, "Silent Partner:", "got the most kill assists.", function() return self:GetStatMax( "Assist" ) end, "assists", "weapons/357/357_spin1.wav" } )
self:ListNewAward( { x, w, "Longshot:", "got the longest distance kill.", function() return self:GetStatMax( "Longshot" ) end, "feet", "weapons/fx/nearmiss/bulletLtoR05.wav" } )
self:ListNewAward( { x, w, "Big Game Hunter:", "dismembered the most zombies with a shotgun.", function() return self:GetStatMax( "Meat" ) end, "zombies poached", "nuke/gore/blood01.wav", true } )
self:ListNewAward( { x, w, "Bullet Hose:", "used the most ammunition.", function() return self:GetStatMax( "Bullets" ) end, "rounds fired", "player/pl_shell1.wav" } )
self:ListNewAward( { x, w, "Meat Grinder:", "butchered the most zombies with a melee weapon.", function() return self:GetStatMax( "Knife" ) end, "melee kills", "weapons/knife/knife_hit2.wav", true } )
self:ListNewAward( { x, w, "Demolitionist:", "killed the most zombies with explosives.", function() return self:GetStatMax( "Explode" ) end, "unidentified bodies", "weapons/underwater_explode3.wav", true } )
self:ListNewAward( { x, w, "Firebug:", "ignited the most zombies.", function() return self:GetStatMax( "Igniter" ) end, "crispy corpses", "ambient/fire/mtov_flame2.wav", true } )
self:ListNewAward( { x, w, "Kleptomaniac:", "picked up the most items.", function() return self:GetStatMax( "Loot" ) end, "items taken", "items/itempickup.wav" } )
self:ListNewAward( { x, w, "Broke The Bank:", "bought the most expensive weapon.", function() return self:GetStatMax( "Pricey" ) end, GAMEMODE.CurrencyName .. "s spent", "ambient/office/coinslot1.wav" } )
self:ListNewAward( { x, w, "Meet The Engineer:", "built the most barricades.", function() return self:GetStatMax( "Wood" ) end, "barricades built", "npc/dog/dog_servo6.wav", true } )
self:ListNewAward( { x, w, "Brain Munch:", "dealt the most damage to humans.", function() return self:GetStatMax( "ZedDamage" ) end, "health points", "npc/zombie/zombie_voice_idle2.wav", true } )
self:ListNewAward( { x, w, "Get To Ze Choppa:", "was the first to reach the evacuation zone.", function() return self:GetStatMax( "Evac" ) end, nil, "ambient/machines/spinup.wav", true } )
self:ListNewAward( { x, w, "Martyr:", "was the first human to die.", function() return self:GetStatMax( "Martyr" ) end, nil, "npc/crow/alert1.wav", true } )
self:ListNewAward( { x, w, "Unhealthy Glow:", "was irradiated the most.", function() return self:GetStatMax( "Rad" ) end, "malignant tumors", "player/geiger3.wav", true } )
self:ListNewAward( { x, w, "Cum Dumpster:", "was infected by zombies the most.", function() return self:GetStatMax( "Infections" ) end, "infections", "ambient/voices/cough1.wav", true } )
self:ListNewAward( { x, w, "Accident Prone:", "took the most damage from zombies.", function() return self:GetStatMax( "Damage" ) end, "damage", "bot/pain2.wav" } )
self:ListNewAward( { x, w, "Roleplayer:", "did jack shit.", function() return self:GetWorstPlayer() end, "kills", "ambient/sheep.wav" } )
//self:ListNewAward( { x, w, "Piss Poor:", "spent the least " .. GAMEMODE.CurrencyName .. "s.", function() return self:GetStatMin( "Spent" ) end, GAMEMODE.CurrencyName .. "s spent", "bot/i_got_nothing.wav" } )
end
function PANEL:ListNewAward( tbl )
table.insert( self.Awards, tbl )
end
function PANEL:GetWorstPlayer()
local min = 9000
local ply = NULL
for k,v in pairs( player.GetAll() ) do
if v:Frags() < min then
min = v:Frags()
ply = v
end
end
return ply, min
end
function PANEL:GetStatMin( name )
local min = 9000
local ply = NULL
for k,v in pairs( PlayerStats ) do
if v.Stats and ( v.Stats[ name ] or 0 ) < min then
min = ( v.Stats[ name ] or 0 )
ply = v.Player
end
end
return ply, min
end
function PANEL:GetStatMax( name )
local max = -1
local ply = NULL
for k,v in pairs( PlayerStats ) do
if v.Stats and ( v.Stats[ name ] or 0 ) > max then
max = ( v.Stats[ name ] or 0 )
ply = v.Player
end
end
return ply, max
end
function PANEL:GetSurvivors()
local tbl = {}
for k,v in pairs( team.GetPlayers( TEAM_ARMY ) ) do
table.insert( tbl, { v } )
end
return tbl
end
function PANEL:GetTopSpenders()
local num = math.min( #player.GetAll(), 5 )
local tbl = {}
local ignore = {}
for i=1, num do
local count = -1
local ply = NULL
for k,v in pairs( PlayerStats ) do
if v.Stats and ( v.Stats[ "Spent" ] or 0 ) > count and not table.HasValue( ignore, v.Player ) then
ply = v.Player
count = ( v.Stats[ "Spent" ] or 0 )
end
end
if ply != NULL then
table.insert( tbl, { ply, count } )
table.insert( ignore, ply )
end
end
return tbl
end
function PANEL:GetTopKillers()
local num = math.min( #player.GetAll(), 5 )
local plys = player.GetAll()
local tbl = {}
for i=1, num do
local count = -1
local ply = NULL
local pos = 0
for k,v in pairs( plys ) do
if v:Frags() > count then
ply = v
pos = k
count = v:Frags()
end
end
if ply != NULL then
table.remove( plys, pos )
table.insert( tbl, { ply, ply:Frags() } )
end
end
return tbl
end
function PANEL:PerformLayout()
self:SetSize( ScrW(), ScrH() )
end
function PANEL:AddList( pos, width, title, players, sound )
surface.PlaySound( sound )
table.insert( self.DrawTbl, { X = pos + width * 0.5, Y = 35, Text = title, Style = TEXT_ALIGN_CENTER, Font = "EndGameBig" } )
if not players[1] then return end
local ypos = 60
for k,v in pairs( players ) do
local list = vgui.Create( "PlayerPanel" )
list:SetPlayerEnt( v[1] )
list:SetCount( v[2] )
list:SetTall( 26 )
list:SetWide( width )
list:SetPos( pos, ypos )
ypos = ypos + 31
end
end
function PANEL:AddAward( ypos, pos, width, title, desc, ply, amt, append, sound, condition )
if condition and amt < 1 then
self.Wait = 0
return
end
surface.PlaySound( sound )
self.YPos = self.YPos + 31
self.Wait = CurTime() + 1.5
table.insert( self.DrawTbl, { X = pos + 2, Y = ypos + 5, Text = title, Style = TEXT_ALIGN_LEFT, Font = "EndGame" } )
local offset = 150
local list = vgui.Create( "PlayerPanel" )
list:SetPlayerEnt( ply )
list:SetDescription( desc )
list:SetTall( 26 )
list:SetWide( width - offset )
list:SetPos( pos + offset, ypos )
if append then
list:SetCount( amt .. " " .. append )
end
end
function PANEL:Think()
if self.Wait and self.Wait < CurTime() then
self.Wait = CurTime() + 0.5
if self.ListMode then
local alist = self.Lists[ self.Pos ]
self:AddList( alist[1], alist[2], alist[3], alist[4](), alist[5] )
self.Pos = self.Pos + 1
if self.Pos > #self.Lists then
self.ListMode = false
self.Wait = CurTime() + 1.5
self.Pos = 1
end
else
local alist = self.Awards[ self.Pos ]
local ply, amt = alist[5]()
self:AddAward( self.YPos, alist[1], alist[2], alist[3], alist[4], ply, amt, alist[6], alist[7], alist[8] )
self.Pos = self.Pos + 1
if self.Pos > #self.Awards then
self.Wait = nil
end
end
end
end
function PANEL:Paint()
for k,v in pairs( self.DrawTbl ) do
draw.SimpleText( v.Text, v.Font, v.X, v.Y, Color( 255, 255, 255 ), v.Style, v.Style )
end
end
derma.DefineControl( "EndGame", "The end-game stat page", PANEL, "PanelBase" )
|