This repository was archived by the owner on Sep 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathEvents.cs
662 lines (559 loc) · 13.7 KB
/
Events.cs
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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
namespace DemoInfo
{
public class HeaderParsedEventArgs : EventArgs
{
public DemoHeader Header { get; private set; }
public HeaderParsedEventArgs(DemoHeader header)
{
this.Header = header;
}
}
public class TickDoneEventArgs : EventArgs
{
}
public class MatchStartedEventArgs : EventArgs
{
}
public class RoundAnnounceMatchStartedEventArgs : EventArgs
{
}
public class RoundEndedEventArgs : EventArgs
{
public RoundEndReason Reason { get; set; }
public string Message { get; set; }
/// <summary>
/// The winning team. Spectate for everything that isn't CT or T.
/// </summary>
public Team Winner;
}
public class RoundOfficiallyEndedEventArgs : EventArgs
{
}
public class RoundMVPEventArgs : EventArgs
{
public Player Player { get; set; }
public RoundMVPReason Reason { get; set; }
}
public class RoundStartedEventArgs : EventArgs
{
public int TimeLimit { get; set; }
public int FragLimit { get; set; }
public string Objective { get; set; }
}
public class WinPanelMatchEventArgs : EventArgs
{
}
public class RoundFinalEventArgs : EventArgs
{
}
public class LastRoundHalfEventArgs : EventArgs
{
}
public class FreezetimeEndedEventArgs : EventArgs
{
}
public class PlayerTeamEventArgs : EventArgs
{
public Player Swapped { get; internal set; }
public Team NewTeam { get; internal set; }
public Team OldTeam { get; internal set; }
public bool Silent { get; internal set; }
public bool IsBot { get; internal set; }
}
public class PlayerKilledEventArgs : EventArgs
{
public Equipment Weapon { get; internal set; }
[Obsolete("Use \"Victim\" instead. This will be removed soon™", false)]
public Player DeathPerson { get { return Victim; } }
public Player Victim { get; internal set; }
public Player Killer { get; internal set; }
public Player Assister { get; internal set; }
public int PenetratedObjects { get; internal set; }
public bool Headshot { get; internal set; }
public bool AssistedFlash { get; internal set; }
}
public class BotTakeOverEventArgs : EventArgs
{
public Player Taker { get; internal set; }
}
public class WeaponFiredEventArgs : EventArgs
{
public Equipment Weapon { get; internal set; }
public Player Shooter { get; internal set; }
}
public class NadeEventArgs : EventArgs
{
public Vector Position { get; internal set; }
public EquipmentElement NadeType { get; internal set; }
public Player ThrownBy { get; internal set; }
internal NadeEventArgs()
{
}
internal NadeEventArgs(EquipmentElement type)
{
this.NadeType = type;
}
}
public class FireEventArgs : NadeEventArgs
{
public FireEventArgs() : base(EquipmentElement.Incendiary)
{
}
}
public class SmokeEventArgs : NadeEventArgs
{
public SmokeEventArgs() : base(EquipmentElement.Smoke)
{
}
}
public class DecoyEventArgs : NadeEventArgs
{
public DecoyEventArgs() : base(EquipmentElement.Decoy)
{
}
}
public class FlashEventArgs : NadeEventArgs
{
//previous blind implementation
public Player[] FlashedPlayers { get; internal set; }
//
public FlashEventArgs() : base(EquipmentElement.Flash)
{
}
}
public class GrenadeEventArgs : NadeEventArgs
{
public GrenadeEventArgs() : base(EquipmentElement.HE)
{
}
}
public class BombEventArgs : EventArgs
{
public Player Player { get; set; }
public char Site { get; set; }
}
public class BombDefuseEventArgs : EventArgs
{
public Player Player { get; set; }
public bool HasKit { get; set; }
}
public class PlayerHurtEventArgs : EventArgs
{
/// <summary>
/// The hurt player
/// </summary>
public Player Player { get; set; }
/// <summary>
/// The attacking player
/// </summary>
public Player Attacker { get; set; }
/// <summary>
/// Remaining health points of the player
/// </summary>
public int Health { get; set; }
/// <summary>
/// Remaining armor points of the player
/// </summary>
public int Armor { get; set; }
/// <summary>
/// The Weapon used to attack.
/// Note: This might be not the same as the raw event
/// we replace "hpk2000" with "usp-s" if the attacker
/// is currently holding it - this value is originally
/// networked "wrong". By using this property you always
/// get the "right" weapon
/// </summary>
/// <value>The weapon.</value>
public Equipment Weapon { get; set; }
/// <summary>
/// The original "weapon"-value from the event.
/// Might be wrong for USP, CZ and M4A1-S
/// </summary>
/// <value>The weapon string.</value>
public string WeaponString { get; set; }
/// <summary>
/// The damage done to the players health
/// </summary>
public int HealthDamage { get; set; }
/// <summary>
/// The damage done to the players armor
/// </summary>
public int ArmorDamage { get; set; }
/// <summary>
/// Where the Player was hit.
/// </summary>
/// <value>The hitgroup.</value>
public Hitgroup Hitgroup { get; set; }
}
public class BlindEventArgs : EventArgs
{
public Player Player { get; set; }
public Player Attacker { get; set; }
public float? FlashDuration { get; set; }
}
public class PlayerBindEventArgs : EventArgs
{
public Player Player { get; set; }
}
public class PlayerDisconnectEventArgs : EventArgs
{
public Player Player { get; set; }
}
/// <summary>
/// Occurs when the server use the "say" command
/// I don't know the purpose of IsChat and IsChatAll because they are everytime false
/// </summary>
public class SayTextEventArgs : EventArgs
{
/// <summary>
/// Should be everytime 0 as it's a message from the server
/// </summary>
public int EntityIndex { get; set; }
/// <summary>
/// Message sent by the server
/// </summary>
public string Text { get; set; }
/// <summary>
/// Everytime false as the message is public
/// </summary>
public bool IsChat { get; set; }
/// <summary>
/// Everytime false as the message is public
/// </summary>
public bool IsChatAll { get; set; }
}
/// <summary>
/// Occurs when a player use the say command
/// Not sure about IsChat and IsChatAll, GOTV doesn't record chat team so this 2 bool are every time true
/// </summary>
public class SayText2EventArgs : EventArgs
{
/// <summary>
/// The player who sent the message
/// </summary>
public Player Sender { get; set; }
/// <summary>
/// The message sent
/// </summary>
public string Text { get; set; }
/// <summary>
/// Not sure about it, maybe it's to indicate say_team or say
/// </summary>
public bool IsChat { get; set; }
/// <summary>
/// true if the message is for all players ?
/// </summary>
public bool IsChatAll { get; set; }
}
/// <summary>
/// Occurs when the server display a player rank
/// It occurs only with Valve demos, at the end of a Matchmaking.
/// So for a 5v5 match there will be 10 events trigerred
/// </summary>
public class RankUpdateEventArgs : EventArgs
{
/// <summary>
/// Player's SteamID64
/// </summary>
public long SteamId { get; set; }
/// <summary>
/// Player's rank at the beginning of the match
/// </summary>
public int RankOld { get; set; }
/// <summary>
/// Player's rank the end of the match
/// </summary>
public int RankNew { get; set; }
/// <summary>
/// Number of win that the player have
/// </summary>
public int WinCount { get; set; }
/// <summary>
/// Number of rank the player win / lost between the beggining and the end of the match
/// </summary>
public float RankChange { get; set; }
}
public class Equipment
{
internal int EntityID { get; set; }
public EquipmentElement Weapon { get; set; }
public EquipmentClass Class
{
get
{
return (EquipmentClass)(((int)Weapon / 100) + 1);
}
}
public string OriginalString { get; set; }
public string SkinID { get; set; }
public int AmmoInMagazine { get; set; }
internal int AmmoType { get; set; }
public Player Owner { get; set; }
public int ReserveAmmo
{
get
{
return (Owner != null && AmmoType != -1) ? Owner.AmmoLeft[AmmoType] : -1;
}
}
internal Equipment()
{
this.Weapon = EquipmentElement.Unknown;
}
internal Equipment(string originalString)
{
OriginalString = originalString;
this.Weapon = MapEquipment(originalString);
}
internal Equipment(string originalString, string skin)
{
OriginalString = originalString;
this.Weapon = MapEquipment(originalString);
SkinID = skin;
}
const string WEAPON_PREFIX = "weapon_";
public static EquipmentElement MapEquipment(string OriginalString)
{
EquipmentElement weapon = EquipmentElement.Unknown;
OriginalString = OriginalString.StartsWith(WEAPON_PREFIX)
? OriginalString.Substring(WEAPON_PREFIX.Length)
: OriginalString;
if (OriginalString.Contains("knife") || OriginalString == "bayonet")
{
weapon = EquipmentElement.Knife;
}
if (weapon == EquipmentElement.Unknown)
{
switch (OriginalString)
{
case "ak47":
weapon = EquipmentElement.AK47;
break;
case "aug":
weapon = EquipmentElement.AUG;
break;
case "awp":
weapon = EquipmentElement.AWP;
break;
case "bizon":
weapon = EquipmentElement.Bizon;
break;
case "c4":
weapon = EquipmentElement.Bomb;
break;
case "deagle":
weapon = EquipmentElement.Deagle;
break;
case "decoy":
case "decoygrenade":
weapon = EquipmentElement.Decoy;
break;
case "elite":
weapon = EquipmentElement.DualBarettas;
break;
case "famas":
weapon = EquipmentElement.Famas;
break;
case "fiveseven":
weapon = EquipmentElement.FiveSeven;
break;
case "flashbang":
weapon = EquipmentElement.Flash;
break;
case "g3sg1":
weapon = EquipmentElement.G3SG1;
break;
case "galil":
case "galilar":
weapon = EquipmentElement.Gallil;
break;
case "glock":
weapon = EquipmentElement.Glock;
break;
case "hegrenade":
weapon = EquipmentElement.HE;
break;
case "hkp2000":
weapon = EquipmentElement.P2000;
break;
case "incgrenade":
case "incendiarygrenade":
weapon = EquipmentElement.Incendiary;
break;
case "m249":
weapon = EquipmentElement.M249;
break;
case "m4a1":
weapon = EquipmentElement.M4A4;
break;
case "mac10":
weapon = EquipmentElement.Mac10;
break;
case "mag7":
weapon = EquipmentElement.Swag7;
break;
case "molotov":
case "molotovgrenade":
case "molotov_projectile":
weapon = EquipmentElement.Molotov;
break;
case "mp7":
weapon = EquipmentElement.MP7;
break;
case "mp9":
weapon = EquipmentElement.MP9;
break;
case "negev":
weapon = EquipmentElement.Negev;
break;
case "nova":
weapon = EquipmentElement.Nova;
break;
case "p250":
weapon = EquipmentElement.P250;
break;
case "p90":
weapon = EquipmentElement.P90;
break;
case "sawedoff":
weapon = EquipmentElement.SawedOff;
break;
case "scar20":
weapon = EquipmentElement.Scar20;
break;
case "sg556":
weapon = EquipmentElement.SG556;
break;
case "smokegrenade":
weapon = EquipmentElement.Smoke;
break;
case "ssg08":
weapon = EquipmentElement.Scout;
break;
case "taser":
weapon = EquipmentElement.Zeus;
break;
case "tec9":
weapon = EquipmentElement.Tec9;
break;
case "ump45":
weapon = EquipmentElement.UMP;
break;
case "xm1014":
weapon = EquipmentElement.XM1014;
break;
case "m4a1_silencer":
case "m4a1_silencer_off":
weapon = EquipmentElement.M4A1;
break;
case "cz75a":
weapon = EquipmentElement.CZ;
break;
case "usp":
case "usp_silencer":
case "usp_silencer_off":
weapon = EquipmentElement.USP;
break;
case "world":
weapon = EquipmentElement.World;
break;
case "inferno":
weapon = EquipmentElement.Incendiary;
break;
case "revolver":
weapon = EquipmentElement.Revolver;
break;
case "mp5sd":
weapon = EquipmentElement.MP5SD;
break;
case "scar17"://These crash the game when given via give weapon_[mp5navy|...], and cannot be purchased ingame.
case "sg550"://yet the server-classes are networked, so I need to resolve them.
case "mp5navy":
case "p228":
case "scout":
case "sg552":
case "tmp":
weapon = EquipmentElement.Unknown;
break;
default:
Trace.WriteLine("Unknown weapon. " + OriginalString, "Equipment.MapEquipment()");
break;
}
}
return weapon;
}
}
public enum EquipmentElement
{
Unknown = 0,
//Pistoles
P2000 = 1,
Glock = 2,
P250 = 3,
Deagle = 4,
FiveSeven = 5,
DualBarettas = 6,
Tec9 = 7,
CZ = 8,
USP = 9,
Revolver = 10,
//SMGs
MP7 = 101,
MP9 = 102,
Bizon = 103,
Mac10 = 104,
UMP = 105,
P90 = 106,
MP5SD = 107,
//Heavy
SawedOff = 201,
Nova = 202,
Swag7 = 203,
XM1014 = 204,
M249 = 205,
Negev = 206,
//Rifle
Gallil = 301,
Famas = 302,
AK47 = 303,
M4A4 = 304,
M4A1 = 305,
Scout = 306,
SG556 = 307,
AUG = 308,
AWP = 309,
Scar20 = 310,
G3SG1 = 311,
//Equipment
Zeus = 401,
Kevlar = 402,
Helmet = 403,
Bomb = 404,
Knife = 405,
DefuseKit = 406,
World = 407,
//Grenades
Decoy = 501,
Molotov = 502,
Incendiary = 503,
Flash = 504,
Smoke = 505,
HE = 506
}
public enum EquipmentClass
{
Unknown = 0,
Pistol = 1,
SMG = 2,
Heavy = 3,
Rifle = 4,
Equipment = 5,
Grenade = 6,
}
}