-
Notifications
You must be signed in to change notification settings - Fork 156
Expand file tree
/
Copy pathspechud.sp
More file actions
1419 lines (1186 loc) · 38.3 KB
/
Copy pathspechud.sp
File metadata and controls
1419 lines (1186 loc) · 38.3 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
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
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#include <builtinvotes>
#include <left4dhooks>
#include <colors>
#define L4D2UTIL_STOCKS_ONLY 1
#include <l4d2util>
#undef REQUIRE_PLUGIN
#include <readyup>
#include <pause>
#include <l4d2_boss_percents>
#include <l4d2_hybrid_scoremod>
#include <l4d2_scoremod>
#include <l4d2_health_temp_bonus>
#include <l4d_tank_control_eq>
#include <lerpmonitor>
#include <witch_and_tankifier>
#define PLUGIN_VERSION "3.8.6"
public Plugin myinfo =
{
name = "Hyper-V HUD Manager",
author = "Visor, Forgetest",
description = "Provides different HUDs for spectators",
version = PLUGIN_VERSION,
url = "https://github.com/Target5150/MoYu_Server_Stupid_Plugins"
};
// ======================================================================
// Macros
// ======================================================================
#define SPECHUD_DRAW_INTERVAL 0.5
#define TRANSLATION_FILE "spechud.phrases"
// ======================================================================
// Plugin Vars
// ======================================================================
int g_Gamemode;
//int storedClass[MAXPLAYERS+1];
// Game Var
ConVar survivor_limit, versus_boss_buffer, sv_maxplayers, tank_burn_duration;
int iSurvivorLimit, iMaxPlayers;
float fVersusBossBuffer, fTankBurnDuration;
// Plugin Cvar
ConVar l4d_tank_percent, l4d_witch_percent, hServerNamer, l4d_ready_cfg_name;
// Plugin Var
char sReadyCfgName[64], sHostname[64];
bool bRoundLive;
// Boss Spawn Scheme
StringMap hFirstTankSpawningScheme, hSecondTankSpawningScheme; // eq_finale_tanks (Zonemod, Acemod, etc.)
StringMap hFinaleExceptionMaps; // finale_tank_blocker (Promod and older?)
StringMap hCustomTankScriptMaps; // Handled by this plugin
// Flow Bosses
int iTankCount, iWitchCount;
int iTankFlow, iWitchFlow;
bool bRoundHasFlowTank, bRoundHasFlowWitch, bFlowTankActive, bCustomBossSys;
// Score & Scoremod
//int iFirstHalfScore;
bool bScoremod, bHybridScoremod, bNextScoremod;
int iMaxDistance;
// Tank Control EQ
bool bTankSelection;
// Witch and Tankifier
bool bTankifier;
bool bStaticTank, bStaticWitch;
// Hud Toggle & Hint Message
bool bSpecHudActive[MAXPLAYERS+1], bTankHudActive[MAXPLAYERS+1];
bool bSpecHudHintShown[MAXPLAYERS+1], bTankHudHintShown[MAXPLAYERS+1];
/**********************************************************************************************/
// ======================================================================
// Plugin Start
// ======================================================================
public void OnPluginStart()
{
LoadPluginTranslations();
( survivor_limit = FindConVar("survivor_limit") ).AddChangeHook(GameConVarChanged);
( versus_boss_buffer = FindConVar("versus_boss_buffer") ).AddChangeHook(GameConVarChanged);
( sv_maxplayers = FindConVar("sv_maxplayers") ).AddChangeHook(GameConVarChanged);
( tank_burn_duration = FindConVar("tank_burn_duration") ).AddChangeHook(GameConVarChanged);
GetGameCvars();
FillBossPercents();
FillServerNamer();
FillReadyConfig();
InitTankSpawnSchemeTrie();
RegConsoleCmd("sm_spechud", ToggleSpecHudCmd);
RegConsoleCmd("sm_tankhud", ToggleTankHudCmd);
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);
HookEvent("player_death", Event_PlayerDeath, EventHookMode_Post);
HookEvent("witch_killed", Event_WitchDeath, EventHookMode_PostNoCopy);
HookEvent("player_team", Event_PlayerTeam, EventHookMode_Post);
for (int i = 1; i <= MaxClients; ++i)
{
bSpecHudActive[i] = false;
bSpecHudHintShown[i] = false;
bTankHudActive[i] = true;
bTankHudHintShown[i] = false;
}
CreateTimer(SPECHUD_DRAW_INTERVAL, HudDrawTimer, _, TIMER_REPEAT);
}
/**********************************************************************************************/
// ======================================================================
// ConVar Maintenance
// ======================================================================
void GetGameCvars()
{
iSurvivorLimit = survivor_limit.IntValue;
fVersusBossBuffer = versus_boss_buffer.FloatValue;
iMaxPlayers = sv_maxplayers.IntValue;
fTankBurnDuration = tank_burn_duration.FloatValue;
}
void GetCurrentGameMode()
{
g_Gamemode = L4D_GetGameModeType();
}
// ======================================================================
// Dependency Maintenance
// ======================================================================
void FillBossPercents()
{
l4d_tank_percent = FindConVar("l4d_tank_percent");
l4d_witch_percent = FindConVar("l4d_witch_percent");
}
void FillServerNamer()
{
ConVar convar = null;
if ((convar = FindConVar("l4d_ready_server_cvar")) != null)
{
char buffer[64];
convar.GetString(buffer, sizeof(buffer));
convar = FindConVar(buffer);
}
if (convar == null)
{
convar = FindConVar("hostname");
}
if (hServerNamer == null)
{
hServerNamer = convar;
hServerNamer.AddChangeHook(ServerCvarChanged);
}
else if (hServerNamer != convar)
{
hServerNamer.RemoveChangeHook(ServerCvarChanged);
hServerNamer = convar;
hServerNamer.AddChangeHook(ServerCvarChanged);
}
hServerNamer.GetString(sHostname, sizeof(sHostname));
}
void FillReadyConfig()
{
if (l4d_ready_cfg_name != null || (l4d_ready_cfg_name = FindConVar("l4d_ready_cfg_name")) != null)
l4d_ready_cfg_name.GetString(sReadyCfgName, sizeof(sReadyCfgName));
}
void FindScoreMod()
{
bScoremod = LibraryExists("l4d2_scoremod");
bHybridScoremod = LibraryExists("l4d2_hybrid_scoremod") || LibraryExists("l4d2_hybrid_scoremod_zone");
bNextScoremod = LibraryExists("l4d2_health_temp_bonus");
}
void FindTankSelection()
{
bTankSelection = (GetFeatureStatus(FeatureType_Native, "GetTankSelection") != FeatureStatus_Unknown);
}
void FindTankifier()
{
bTankifier = LibraryExists("witch_and_tankifier");
}
void LoadPluginTranslations()
{
char sPath[PLATFORM_MAX_PATH];
BuildPath(Path_SM, sPath, sizeof sPath, "translations/"...TRANSLATION_FILE... ".txt");
if (!FileExists(sPath))
{
SetFailState("Missing translation file \""...TRANSLATION_FILE...".txt\"");
}
LoadTranslations(TRANSLATION_FILE);
}
// ======================================================================
// Dependency Monitor
// ======================================================================
void GameConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
{
GetGameCvars();
}
void ServerCvarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
{
FillServerNamer();
}
public void OnAllPluginsLoaded()
{
FindScoreMod();
FillBossPercents();
FillServerNamer();
FillReadyConfig();
FindTankSelection();
FindTankifier();
}
public void OnLibraryAdded(const char[] name)
{
FindScoreMod();
FillBossPercents();
FindTankifier();
}
public void OnLibraryRemoved(const char[] name)
{
FindScoreMod();
FillBossPercents();
FindTankifier();
}
public void L4D_OnGameModeChange(int gamemode)
{
GetCurrentGameMode();
}
// ======================================================================
// Bosses Caching
// ======================================================================
void BuildCustomTrieEntries()
{
// Haunted Forest 3
hCustomTankScriptMaps.SetValue("hf03_themansion", true);
}
void InitTankSpawnSchemeTrie()
{
hFirstTankSpawningScheme = new StringMap();
hSecondTankSpawningScheme = new StringMap();
hFinaleExceptionMaps = new StringMap();
hCustomTankScriptMaps = new StringMap();
RegServerCmd("tank_map_flow_and_second_event", SetMapFirstTankSpawningScheme);
RegServerCmd("tank_map_only_first_event", SetMapSecondTankSpawningScheme);
RegServerCmd("finale_tank_default", SetFinaleExceptionMap);
BuildCustomTrieEntries();
}
Action SetMapFirstTankSpawningScheme(int args)
{
char mapname[64];
GetCmdArg(1, mapname, sizeof(mapname));
hFirstTankSpawningScheme.SetValue(mapname, true);
return Plugin_Handled;
}
Action SetMapSecondTankSpawningScheme(int args)
{
char mapname[64];
GetCmdArg(1, mapname, sizeof(mapname));
hSecondTankSpawningScheme.SetValue(mapname, true);
return Plugin_Handled;
}
Action SetFinaleExceptionMap(int args)
{
char mapname[64];
GetCmdArg(1, mapname, sizeof(mapname));
hFinaleExceptionMaps.SetValue(mapname, true);
return Plugin_Handled;
}
/**********************************************************************************************/
// ======================================================================
// Forwards
// ======================================================================
public void OnClientDisconnect(int client)
{
bSpecHudHintShown[client] = false;
bTankHudHintShown[client] = false;
}
public void OnMapStart() { bRoundLive = false; }
public void OnRoundIsLive()
{
FillReadyConfig();
bRoundLive = true;
GetCurrentGameMode();
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && GetClientTeam(i) == L4D2Team_Spectator && !IsClientSourceTV(i))
FakeClientCommand(i, "sm_spectate");
}
if (g_Gamemode == GAMEMODE_VERSUS)
{
bRoundHasFlowTank = RoundHasFlowTank();
bRoundHasFlowWitch = RoundHasFlowWitch();
bFlowTankActive = bRoundHasFlowTank;
bCustomBossSys = IsDarkCarniRemix();
bStaticTank = bTankifier && IsStaticTankMap();
bStaticWitch = bTankifier && IsStaticWitchMap();
iMaxDistance = L4D_GetVersusMaxCompletionScore() / 4 * iSurvivorLimit;
iTankCount = 0;
iWitchCount = 0;
if (l4d_tank_percent != null && l4d_tank_percent.BoolValue)
{
if (GetFeatureStatus(FeatureType_Native, "GetStoredTankPercent") != FeatureStatus_Unknown)
iTankFlow = GetStoredTankPercent();
else
iTankFlow = GetRoundTankFlow();
iTankCount = 1;
char mapname[64];
bool dummy;
GetCurrentMap(mapname, sizeof(mapname));
// TODO: individual plugin served as an interface to tank counts?
if (hCustomTankScriptMaps.GetValue(mapname, dummy)) iTankCount += 1;
else if (!bCustomBossSys && L4D_IsMissionFinalMap())
{
iTankCount = 3
- view_as<int>(hFirstTankSpawningScheme.GetValue(mapname, dummy))
- view_as<int>(hSecondTankSpawningScheme.GetValue(mapname, dummy))
- view_as<int>(hFinaleExceptionMaps.Size > 0 && !hFinaleExceptionMaps.GetValue(mapname, dummy))
- view_as<int>(bStaticTank);
}
}
if (l4d_witch_percent != null && l4d_witch_percent.BoolValue)
{
if (GetFeatureStatus(FeatureType_Native, "GetStoredWitchPercent") != FeatureStatus_Unknown)
iWitchFlow = GetStoredWitchPercent();
else
iWitchFlow = GetRoundWitchFlow();
iWitchCount = 1;
}
}
}
//public void L4D2_OnEndVersusModeRound_Post() { if (!InSecondHalfOfRound()) iFirstHalfScore = L4D_GetTeamScore(GetRealTeam(0) + 1); }
// ======================================================================
// Events
// ======================================================================
void Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
bRoundLive = false;
}
void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
{
bRoundLive = false;
}
void Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if (!client || !IsInfected(client)) return;
if (GetInfectedClass(client) == L4D2Infected_Tank)
{
if (iTankCount > 0) iTankCount--;
if (!RoundHasFlowTank()) bFlowTankActive = false;
}
}
void Event_WitchDeath(Event event, const char[] name, bool dontBroadcast)
{
if (iWitchCount > 0) iWitchCount--;
}
void Event_PlayerTeam(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if (!client) return;
int team = event.GetInt("team");
if (team == L4D2Team_None) // Player disconnecting
{
bSpecHudActive[client] = false;
bTankHudActive[client] = true;
}
//if (team == L4D2Team_Infected) storedClass[client] = ZC_None;
}
/**********************************************************************************************/
// ======================================================================
// HUD Command Callbacks
// ======================================================================
Action ToggleSpecHudCmd(int client, int args)
{
if (!IsValidClientIndex(client) || !IsClientInGame(client))
return Plugin_Handled;
if (GetClientTeam(client) != L4D2Team_Spectator)
return Plugin_Handled;
bSpecHudActive[client] = !bSpecHudActive[client];
CPrintToChat(client, "%t", "Notify_SpechudState", (bSpecHudActive[client] ? "on" : "off"));
return Plugin_Handled;
}
Action ToggleTankHudCmd(int client, int args)
{
if (!IsValidClientIndex(client) || !IsClientInGame(client))
return Plugin_Handled;
if (GetClientTeam(client) == L4D2Team_Survivor)
return Plugin_Handled;
bTankHudActive[client] = !bTankHudActive[client];
CPrintToChat(client, "%t", "Notify_TankhudState", (bTankHudActive[client] ? "on" : "off"));
return Plugin_Handled;
}
/**********************************************************************************************/
// ======================================================================
// HUD Handle
// ======================================================================
Action HudDrawTimer(Handle hTimer)
{
if (IsInReady() || IsInPause())
return Plugin_Continue;
int tankHud_total = 0;
int[] tankHud_clients = new int[MaxClients];
int specHud_total = 0;
int[] specHud_clients = new int[MaxClients];
for (int i = 1; i <= MaxClients; ++i)
{
if (!IsClientInGame(i))
continue;
if (IsClientSourceTV(i))
{
specHud_clients[specHud_total++] = i;
continue;
}
switch (GetClientTeam(i))
{
case L4D2Team_Spectator:
{
if (bSpecHudActive[i])
specHud_clients[specHud_total++] = i;
else if (bTankHudActive[i])
tankHud_clients[tankHud_total++] = i;
}
case L4D2Team_Infected:
{
if (bTankHudActive[i])
tankHud_clients[tankHud_total++] = i;
}
}
}
if (specHud_total) // Only bother if someone's watching us
{
Panel specHud = new Panel();
FillHeaderInfo(specHud);
FillSurvivorInfo(specHud);
FillScoreInfo(specHud);
FillInfectedInfo(specHud);
if (!FillTankInfo(specHud))
FillGameInfo(specHud);
for (int i = 0; i < specHud_total; ++i)
{
int client = specHud_clients[i];
switch (GetClientMenu(client))
{
case MenuSource_External, MenuSource_Normal: continue;
}
specHud.Send(client, DummySpecHudHandler, 3);
if (!bSpecHudHintShown[client])
{
bSpecHudHintShown[client] = true;
CPrintToChat(client, "%t", "Notify_SpechudUsage");
}
}
delete specHud;
}
if (!tankHud_total) return Plugin_Continue;
Panel tankHud = new Panel();
if (FillTankInfo(tankHud, true)) // No tank -- no HUD
{
for (int i = 0; i < tankHud_total; ++i)
{
int client = tankHud_clients[i];
switch (GetClientMenu(client))
{
case MenuSource_External, MenuSource_Normal: continue;
}
tankHud.Send(client, DummyTankHudHandler, 3);
if (!bTankHudHintShown[client])
{
bTankHudHintShown[client] = true;
CPrintToChat(client, "%t", "Notify_TankhudUsage");
}
}
}
delete tankHud;
return Plugin_Continue;
}
int DummySpecHudHandler(Menu hMenu, MenuAction action, int param1, int param2) { return 1; }
int DummyTankHudHandler(Menu hMenu, MenuAction action, int param1, int param2) { return 1; }
/**********************************************************************************************/
// ======================================================================
// HUD Content
// ======================================================================
void FillHeaderInfo(Panel hSpecHud)
{
static int iTickrate = 0;
if (iTickrate == 0 && IsServerProcessing())
iTickrate = RoundToNearest(1.0 / GetTickInterval());
static char buf[64];
Format(buf, sizeof(buf), "Server: %s [Slots %i/%i | %iT]", sHostname, GetRealClientCount(), iMaxPlayers, iTickrate);
DrawPanelText(hSpecHud, buf);
}
void GetMeleePrefix(int client, char[] prefix, int length)
{
int secondary = GetPlayerWeaponSlot(client, L4D2WeaponSlot_Secondary);
if (secondary == -1)
return;
static char buf[4];
switch (IdentifyWeapon(secondary))
{
case WEPID_NONE: buf = "N";
case WEPID_PISTOL: buf = (GetEntProp(secondary, Prop_Send, "m_isDualWielding") ? "DP" : "P");
case WEPID_PISTOL_MAGNUM: buf = "DE";
case WEPID_MELEE: buf = "M";
default: buf = "?";
}
strcopy(prefix, length, buf);
}
void GetWeaponInfo(int client, char[] info, int length)
{
static char buffer[32];
int activeWep = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
int primaryWep = GetPlayerWeaponSlot(client, L4D2WeaponSlot_Primary);
int activeWepId = IdentifyWeapon(activeWep);
int primaryWepId = IdentifyWeapon(primaryWep);
// Let's begin with what player is holding,
// but cares only pistols if holding secondary.
switch (activeWepId)
{
case WEPID_PISTOL, WEPID_PISTOL_MAGNUM:
{
if (activeWepId == WEPID_PISTOL && !!GetEntProp(activeWep, Prop_Send, "m_isDualWielding"))
{
// Dual Pistols Scenario
// Straight use the prefix since full name is a bit long.
Format(buffer, sizeof(buffer), "DP");
}
else GetLongWeaponName(activeWepId, buffer, sizeof(buffer));
FormatEx(info, length, "%s %i", buffer, GetWeaponClipAmmo(activeWep));
}
default:
{
GetLongWeaponName(primaryWepId, buffer, sizeof(buffer));
FormatEx(info, length, "%s %i/%i", buffer, GetWeaponClipAmmo(primaryWep), GetWeaponExtraAmmo(client, primaryWepId));
}
}
// Format our result info
if (primaryWep == -1)
{
// In case with no primary,
// show the melee full name.
if (activeWepId == WEPID_MELEE || activeWepId == WEPID_CHAINSAW)
{
int meleeWepId = IdentifyMeleeWeapon(activeWep);
GetLongMeleeWeaponName(meleeWepId, info, length);
}
}
else
{
// Default display -> [Primary <In Detail> | Secondary <Prefix>]
// Holding melee included in this way
// i.e. [Chrome 8/56 | M]
if (GetSlotFromWeaponId(activeWepId) != L4D2WeaponSlot_Secondary || activeWepId == WEPID_MELEE || activeWepId == WEPID_CHAINSAW)
{
GetMeleePrefix(client, buffer, sizeof(buffer));
Format(info, length, "%s | %s", info, buffer);
}
// Secondary active -> [Secondary <In Detail> | Primary <Ammo Sum>]
// i.e. [Deagle 8 | Mac 700]
else
{
GetLongWeaponName(primaryWepId, buffer, sizeof(buffer));
Format(info, length, "%s | %s %i", info, buffer, GetWeaponClipAmmo(primaryWep) + GetWeaponExtraAmmo(client, primaryWepId));
}
}
}
int SortSurvByCharacter(int elem1, int elem2, const int[] array, Handle hndl)
{
int sc1 = IdentifySurvivor(elem1);
int sc2 = IdentifySurvivor(elem2);
if (sc1 > sc2) { return 1; }
else if (sc1 < sc2) { return -1; }
else { return 0; }
}
void FillSurvivorInfo(Panel hSpecHud)
{
static char info[100];
static char name[MAX_NAME_LENGTH];
int SurvivorTeamIndex = GameRules_GetProp("m_bAreTeamsFlipped");
switch (g_Gamemode)
{
case GAMEMODE_SCAVENGE:
{
int score = GetScavengeMatchScore(SurvivorTeamIndex);
FormatEx(info, sizeof(info), "->1. Survivors [%d of %d]", score, GetScavengeRoundLimit());
}
case GAMEMODE_VERSUS:
{
if (bRoundLive)
{
FormatEx(info, sizeof(info), "->1. Survivors [%d]",
L4D2Direct_GetVSCampaignScore(SurvivorTeamIndex) + GetVersusProgressDistance(SurvivorTeamIndex));
}
else
{
FormatEx(info, sizeof(info), "->1. Survivors [%d]",
L4D2Direct_GetVSCampaignScore(SurvivorTeamIndex));
}
}
}
DrawPanelText(hSpecHud, " ");
DrawPanelText(hSpecHud, info);
int total = 0;
int[] clients = new int[MaxClients];
for (int i = 1; i <= MaxClients; ++i)
{
if (!IsClientInGame(i) || GetClientTeam(i) != L4D2Team_Survivor)
continue;
clients[total++] = i;
}
SortCustom1D(clients, total, SortSurvByCharacter);
for (int i = 0; i < total; ++i)
{
int client = clients[i];
GetClientFixedName(client, name, sizeof(name));
if (!IsPlayerAlive(client))
{
FormatEx(info, sizeof(info), "%s: Dead", name);
}
else
{
if (IsHangingFromLedge(client))
{
// Nick: <300HP@Hanging>
FormatEx(info, sizeof(info), "%s: <%iHP@Hanging>", name, GetClientHealth(client));
}
else if (IsIncapacitated(client))
{
int activeWep = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
GetLongWeaponName(IdentifyWeapon(activeWep), info, sizeof(info));
// Nick: <300HP@1st> [Deagle 8]
Format(info, sizeof(info), "%s: <%iHP@%s> [%s %i]", name, GetClientHealth(client), (GetSurvivorIncapCount(client) == 1 ? "2nd" : "1st"), info, GetWeaponClipAmmo(activeWep));
}
else
{
GetWeaponInfo(client, info, sizeof(info));
int tempHealth = GetSurvivorTemporaryHealth(client);
int health = GetClientHealth(client) + tempHealth;
int incapCount = GetSurvivorIncapCount(client);
if (incapCount == 0)
{
// "#" indicates that player is bleeding.
// Nick: 99HP# [Chrome 8/72]
Format(info, sizeof(info), "%s: %iHP%s [%s]", name, health, (tempHealth > 0 ? "#" : ""), info);
}
else
{
// Player ever incapped should always be bleeding.
// Nick: 99HP (#1st) [Chrome 8/72]
Format(info, sizeof(info), "%s: %iHP (#%s) [%s]", name, health, (incapCount == 2 ? "2nd" : "1st"), info);
}
}
}
DrawPanelText(hSpecHud, info);
}
}
void FillScoreInfo(Panel hSpecHud)
{
static char info[64];
switch (g_Gamemode)
{
case GAMEMODE_SCAVENGE:
{
bool bSecondHalf = InSecondHalfOfRound();
bool bTeamFlipped = !!GameRules_GetProp("m_bAreTeamsFlipped");
float fDuration = GetScavengeRoundDuration(bTeamFlipped);
int iMinutes = RoundToFloor(fDuration / 60);
DrawPanelText(hSpecHud, " ");
FormatEx(info, sizeof(info), "> Accumulated Time [%02d:%02.0f]", iMinutes, fDuration - 60 * iMinutes);
DrawPanelText(hSpecHud, info);
if (bSecondHalf)
{
fDuration = GetScavengeRoundDuration(!bTeamFlipped);
iMinutes = RoundToFloor(fDuration / 60);
FormatEx(info, sizeof(info), "> Opponent Duration [%02d:%05.2f]", iMinutes, fDuration - 60 * iMinutes);
DrawPanelText(hSpecHud, info);
}
}
case GAMEMODE_VERSUS:
{
if (bHybridScoremod)
{
int healthBonus = SMPlus_GetHealthBonus(), maxHealthBonus = SMPlus_GetMaxHealthBonus();
int damageBonus = SMPlus_GetDamageBonus(), maxDamageBonus = SMPlus_GetMaxDamageBonus();
int pillsBonus = SMPlus_GetPillsBonus(), maxPillsBonus = SMPlus_GetMaxPillsBonus();
int totalBonus = healthBonus + damageBonus + pillsBonus;
int maxTotalBonus = maxHealthBonus + maxDamageBonus + maxPillsBonus;
DrawPanelText(hSpecHud, " ");
// > HB: 100% | DB: 100% | Pills: 60 / 100%
// > Bonus: 860 <100.0%>
// > Distance: 400
FormatEx( info,
sizeof(info),
"> HB: %.0f%% | DB: %.0f%% | Pills: %i / %.0f%%",
L4D2Util_IntToPercentFloat(healthBonus, maxHealthBonus),
L4D2Util_IntToPercentFloat(damageBonus, maxDamageBonus),
pillsBonus, L4D2Util_IntToPercentFloat(pillsBonus, maxPillsBonus));
DrawPanelText(hSpecHud, info);
FormatEx(info, sizeof(info), "> Bonus: %i <%.1f%%>", totalBonus, L4D2Util_IntToPercentFloat(totalBonus, maxTotalBonus));
DrawPanelText(hSpecHud, info);
FormatEx(info, sizeof(info), "> Distance: %i", iMaxDistance);
//if (InSecondHalfOfRound())
//{
// Format(info, sizeof(info), "%s | R#1: %i <%.1f%%>", info, iFirstHalfScore, L4D2Util_IntToPercentFloat(iFirstHalfScore, L4D_GetVersusMaxCompletionScore() + maxTotalBonus));
//}
DrawPanelText(hSpecHud, info);
}
else if (bScoremod)
{
int healthBonus = HealthBonus();
DrawPanelText(hSpecHud, " ");
// > Health Bonus: 860
// > Distance: 400
FormatEx(info, sizeof(info), "> Health Bonus: %i", healthBonus);
DrawPanelText(hSpecHud, info);
FormatEx(info, sizeof(info), "> Distance: %i", iMaxDistance);
//if (InSecondHalfOfRound())
//{
// Format(info, sizeof(info), "%s | R#1: %i", info, iFirstHalfScore);
//}
DrawPanelText(hSpecHud, info);
}
else if (bNextScoremod)
{
int permBonus = SMNext_GetPermBonus(), maxPermBonus = SMNext_GetMaxPermBonus();
int tempBonus = SMNext_GetTempBonus(), maxTempBonus = SMNext_GetMaxTempBonus();
int pillsBonus = SMNext_GetPillsBonus(), maxPillsBonus = SMNext_GetMaxPillsBonus();
int totalBonus = permBonus + tempBonus + pillsBonus;
int maxTotalBonus = maxPermBonus + maxTempBonus + maxPillsBonus;
DrawPanelText(hSpecHud, " ");
// > Perm: 114 | Temp: 514 | Pills: 810
// > Bonus: 114514 <100.0%>
// > Distance: 191
// never ever played on Next so take it easy.
FormatEx( info,
sizeof(info),
"> Perm: %i | Temp: %i | Pills: %i",
permBonus, tempBonus, pillsBonus);
DrawPanelText(hSpecHud, info);
FormatEx(info, sizeof(info), "> Bonus: %i <%.1f%%>", totalBonus, L4D2Util_IntToPercentFloat(totalBonus, maxTotalBonus));
DrawPanelText(hSpecHud, info);
FormatEx(info, sizeof(info), "> Distance: %i", iMaxDistance);
//if (InSecondHalfOfRound())
//{
// Format(info, sizeof(info), "%s | R#1: %i <%.1f%%>", info, iFirstHalfScore, ToPercent(iFirstHalfScore, L4D_GetVersusMaxCompletionScore() + maxTotalBonus));
//}
DrawPanelText(hSpecHud, info);
}
}
}
}
void FillInfectedInfo(Panel hSpecHud)
{
static char info[80];
static char buffer[16];
static char name[MAX_NAME_LENGTH];
int InfectedTeamIndex = !GameRules_GetProp("m_bAreTeamsFlipped");
switch (g_Gamemode)
{
case GAMEMODE_SCAVENGE:
{
int score = GetScavengeMatchScore(InfectedTeamIndex);
FormatEx(info, sizeof(info), "->2. Infected [%d of %d]", score, GetScavengeRoundLimit());
}
case GAMEMODE_VERSUS:
{
FormatEx(info, sizeof(info), "->2. Infected [%d]",
L4D2Direct_GetVSCampaignScore(InfectedTeamIndex));
}
}
DrawPanelText(hSpecHud, " ");
DrawPanelText(hSpecHud, info);
int infectedCount = 0;
for (int client = 1; client <= MaxClients; ++client)
{
if (!IsClientInGame(client) || GetClientTeam(client) != L4D2Team_Infected)
continue;
GetClientFixedName(client, name, sizeof(name));
if (!IsPlayerAlive(client))
{
int timeLeft = RoundToFloor(L4D_GetPlayerSpawnTime(client));
if (timeLeft < 0) // Deathcam
{
// verygood: Dead
FormatEx(info, sizeof(info), "%s: Dead", name);
}
else // Ghost Countdown
{
FormatEx(buffer, sizeof(buffer), "%is", timeLeft);
// verygood: Dead (15s)
FormatEx(info, sizeof(info), "%s: Dead (%s)", name, (timeLeft ? buffer : "Spawning..."));
//char zClassName[10];
//GetInfectedClassName(storedClass[client], zClassName, sizeof zClassName);
//if (storedClass[client] > L4D2Team_None)
//{
// FormatEx(info, sizeof(info), "%s: Dead (%s) [%s]", name, zClassName, (RoundToNearest(timeLeft) ? buffer : "Spawning..."));
//} else {
// FormatEx(info, sizeof(info), "%s: Dead (%s)", name, (RoundToNearest(timeLeft) ? buffer : "Spawning..."));
//}
}
}
else
{
int zClass = GetInfectedClass(client);
if (zClass == L4D2Infected_Tank)
continue;
char zClassName[10];
GetInfectedClassName(zClass, zClassName, sizeof(zClassName));
int iHP = GetClientHealth(client), iMaxHP = GetEntProp(client, Prop_Send, "m_iMaxHealth");
if (IsInfectedGhost(client))
{
// DONE: Handle a case of respawning chipped SI, show the ghost's health
if (iHP < iMaxHP)
{
// verygood: Charger (Ghost@1HP)
FormatEx(info, sizeof(info), "%s: %s (Ghost@%iHP)", name, zClassName, iHP);
}
else
{
// verygood: Charger (Ghost)
FormatEx(info, sizeof(info), "%s: %s (Ghost)", name, zClassName);
}
}
else
{
buffer[0] = '\0';
float fTimestamp, fDuration;
if (GetInfectedAbilityTimer(client, fTimestamp, fDuration))
{
int iCooldown = RoundToCeil(fTimestamp - GetGameTime());
if (iCooldown > 0
&& fDuration > 1.0
&& fDuration != 3600
&& GetInfectedVictim(client) <= 0)
{
FormatEx(buffer, sizeof(buffer), " [%is]", iCooldown);
}
}
if (GetEntityFlags(client) & FL_ONFIRE)
{
// verygood: Charger (1HP) [On Fire] [6s]
FormatEx(info, sizeof(info), "%s: %s (%iHP) [On Fire]%s", name, zClassName, iHP, buffer);
}
else