This repository was archived by the owner on Jan 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtf2roundroulette.sp
More file actions
1538 lines (1325 loc) · 46.4 KB
/
tf2roundroulette.sp
File metadata and controls
1538 lines (1325 loc) · 46.4 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
#include <sourcemod>
#include <sdktools>
#include <tf2_stocks>
#include <tf2>
#include <tf2items>
#include <sdkhooks>
#include <morecolors>
#include <steamtools>
#include <tf2_ammo>
#include <tf2attributes>
#include <tf2_objects>
#pragma newdecls required
// Condition start sounds
#define SOUND_BELL "misc/halloween/strongman_bell_01.wav"
#define SOUND_CRITS "vo/halloween_merasmus/sf12_wheel_crits02.mp3"
#define SOUND_MINICRITS "items/powerup_pickup_base.wav"
#define SOUND_SPEEDBOOST "items/powerup_pickup_agility.wav"
#define SOUND_HEALTHBOOST "items/powerup_pickup_regeneration.wav"
#define SOUND_SUPERJUMP "vo/halloween_merasmus/sf12_wheel_jump01.mp3"
#define SOUND_INFJUMPS "vo/scout_apexofjump01.mp3"
#define SOUND_MELEEONLY "vo/halloween_merasmus/sf14_merasmus_effect_noguns_01.mp3"
#define SOUND_CLASSONLY "misc/killstreak.wav"
#define SOUND_GRAVITY "vo/halloween_merasmus/sf12_wheel_gravity05.mp3"
#define SOUND_UNDERWATER "vo/halloween_merasmus/sf14_merasmus_effect_swimming_02.mp3"
#define SOUND_GHOST "vo/halloween_merasmus/sf12_wheel_ghosts01.mp3"
#define SOUND_GHOST "vo/halloween_merasmus/sf12_wheel_ghosts01.mp3"
#define SOUND_DWARF "vo/scout_sf12_badmagic28.mp3"
#define SOUND_MILK "weapons/jar_explode.wav"
#define SOUND_POGO "vo/scout_apexofjump02.mp3"
#define SOUND_SLOWSPEED "vo/scout_jeers04.mp3"
#define SOUND_LOWHEALTH "vo/heavy_negativevocalization06.mp3"
#define SOUND_BLEEDING "vo/halloween_merasmus/sf12_wheel_bloody03.mp3"
#define SOUND_FREEFORALL "ui/duel_score_behind.wav"
#define SOUND_KNOCKOUT "player/pl_impact_stun.wav"
#define SOUND_STRONGRECOIL "weapons/air_burster_explode3.wav"
#define SOUND_MINIGUN "vo/heavy_specialweapon02.mp3"
#define SOUND_INSTAGIB "weapons/shooting_star_shoot_charged.wav"
#define SOUND_KNOCKBACK "items/powerup_pickup_knockout_melee_hit.wav"
#define SOUND_FASTHANDS "items/powerup_pickup_knockout.wav"
#define SOUND_HSONLY "weapons/sniper_rifle_classic_shoot_crit.wav"
// Other
#define SOUND_WHOOSH "playgamesound misc/halloween/strongman_fast_whoosh_01.wav"
// ConVars
ConVar g_hCvarTimerWaiting;
// Handles
Handle g_RRTimer = INVALID_HANDLE;
Handle g_HintTimer[MAXPLAYERS+1] = INVALID_HANDLE;
Handle g_Cvar_Gravity = INVALID_HANDLE;
Handle g_Cvar_FriendlyFire = INVALID_HANDLE;
Handle g_BleedTimer[MAXPLAYERS+1] = INVALID_HANDLE;
Handle g_KnockoutTimer[MAXPLAYERS+1] = INVALID_HANDLE;
Handle g_MilkTimer[MAXPLAYERS+1] = INVALID_HANDLE;
Handle g_CritTimer[MAXPLAYERS+1] = INVALID_HANDLE;
Handle g_SlowspeedTimer[MAXPLAYERS+1] = INVALID_HANDLE;
// Booleans
bool CanRoulette = true;
bool HideChatCurrentCondition[MAXPLAYERS+1] = false;
bool g_FullCrit[MAXPLAYERS+1] = false;
bool g_SoundHasPlayed[MAXPLAYERS+1] = false;
bool g_bDoubleJump = false; //True = Ininite jumps enabled, False = Disabled
bool g_bHasStrongRecoil[MAXPLAYERS+1] = {false, ...};
// Floats
float g_flBoost = 250.0;
// Menus
Menu g_MapMenu = null;
// Integers
int sRoll;
int g_iHealth[MAXPLAYERS+1] = 0;
int jump[MAXPLAYERS + 1] = 0;
int g_fLastButtons[MAXPLAYERS+1];
int g_fLastFlags[MAXPLAYERS+1];
int g_iJumps[MAXPLAYERS+1];
int g_iJumpMax = 999;
int Gravity_Roll;
int OriginalHealth[MAXPLAYERS+1];
// Classtype
TFClassType g_Classonly_OldClass[MAXPLAYERS+1] = TFClass_Unknown;
TFClassType RandomClass = TFClass_Unknown;
// Chars
char g_CurrentCond[MAXPLAYERS+1] = "";
char NewGravityAmount[64];
// Enums
enum nRoll
{
ROULETTE_CRITS=0,
ROULETTE_MINICRITS, // 1
ROULETTE_SPEEDBOOST, // 2
ROULETTE_HEALTHBOOST, //3
ROULETTE_SUPERJUMP, //4
ROULETTE_INFJUMPS, //5
ROULETTE_MELEEONLY, //6
ROULETTE_CLASSONLY, //7
ROULETTE_GRAVITY, //8
ROULETTE_UNDERWATER, //9
ROULETTE_GHOST, //10
ROULETTE_DWARF, //11
ROULETTE_MILK, //12
ROULETTE_POGO, //13
ROULETTE_SLOWSPEED, //14
ROULETTE_LOWHEALTH, //15
ROULETTE_BLEEDING, //16
ROULETTE_FREEFORALL, //17
ROULETTE_KNOCKOUT, //18
ROULETTE_STRONGRECOIL, //19
ROULETTE_MINIGUN, // 20
ROULETTE_INSTAGIB, //21
ROULETTE_KNOCKBACK, //22
ROULETTE_FASTHANDS // 23
};
int nRollRows = view_as<int>(nRoll);
public Plugin myinfo = {
name = "Round Roulette",
author = "Kah!",
description = "New special conditions every round.",
version = "0.1"
};
public void OnPluginStart() {
Steam_SetGameDescription("Round Roulette (0.1 Beta)");
AddServerTag("rr");
g_Cvar_Gravity = FindConVar("sv_gravity");
g_Cvar_FriendlyFire = FindConVar("mp_friendlyfire");
g_hCvarTimerWaiting = CreateConVar("sm_rr_timerwaiting", "10.0", "Amounts of seconds before new condition is chosen every round.");
RegAdminCmd("sm_rr_selectmode", Command_SelectMode, ADMFLAG_GENERIC, "Usage: sm_rr_selectmode <0-23>");
RegAdminCmd("sm_rr_reroulette", Command_ReRoulette, ADMFLAG_GENERIC, "Usage: sm_rr_reroulette");
}
public void OnMapStart() {
Steam_SetGameDescription("Round Roulette");
HookEvent("teamplay_round_active", Event_RoundStart);
HookEvent("teamplay_round_start", Event_RoundSoonStart);
HookEvent("teamplay_round_win", Event_RoundWin);
HookEvent("teamplay_win_panel", Event_RoundWin);
HookEvent("teamplay_round_stalemate", Event_RoundWin);
HookEvent("player_spawn", Event_PlayerSpawn);
HookEvent("post_inventory_application", Event_PostInventory);
PrepareSound(SOUND_CRITS);
PrepareSound(SOUND_MINICRITS);
PrepareSound(SOUND_BELL);
PrepareSound(SOUND_SPEEDBOOST);
PrepareSound(SOUND_HEALTHBOOST);
PrepareSound(SOUND_SUPERJUMP);
PrepareSound(SOUND_INFJUMPS);
PrepareSound(SOUND_MELEEONLY);
PrepareSound(SOUND_CLASSONLY);
PrepareSound(SOUND_GRAVITY);
PrepareSound(SOUND_GHOST);
PrepareSound(SOUND_UNDERWATER);
PrepareSound(SOUND_GHOST);
PrepareSound(SOUND_DWARF);
PrepareSound(SOUND_MILK);
PrepareSound(SOUND_POGO);
PrepareSound(SOUND_SLOWSPEED);
PrepareSound(SOUND_LOWHEALTH);
PrepareSound(SOUND_BLEEDING);
PrepareSound(SOUND_FREEFORALL);
PrepareSound(SOUND_KNOCKOUT);
PrepareSound(SOUND_STRONGRECOIL);
PrepareSound(SOUND_MINIGUN);
PrepareSound(SOUND_INSTAGIB);
PrepareSound(SOUND_KNOCKBACK);
PrepareSound(SOUND_FASTHANDS);
PrepareSound(SOUND_HSONLY);
CanRoulette = true;
for(int client = 1; client <= MaxClients; client++) {
TerminateRoundRoulette(client);
}
g_MapMenu = BuildMapMenu();
}
public void OnMapEnd()
{
if (g_MapMenu != INVALID_HANDLE)
{
delete(g_MapMenu);
g_MapMenu = null;
}
SetConVarInt(g_Cvar_Gravity, 800);
KillTimerSafe(g_RRTimer);
}
Menu BuildMapMenu()
{
Menu menu = new Menu(Menu_ChangeMap);
menu.AddItem("0", "0: Crits");
menu.AddItem("1", "1: Mini-Crits");
menu.AddItem("2", "2: Speed Boost");
menu.AddItem("3", "3: Health Boost");
menu.AddItem("4", "4: Super Jump");
menu.AddItem("5", "5: Infinite Jumps");
menu.AddItem("6", "6: Melee Only");
menu.AddItem("7", "7: One class only (randomed)");
menu.AddItem("8", "8: Low gravity");
menu.AddItem("9", "9: Underwater");
menu.AddItem("10", "10: Ghost");
menu.AddItem("11", "11: Dwarf");
menu.AddItem("12", "12: Milk");
menu.AddItem("13", "13: Pogo Jump");
menu.AddItem("14", "14: Slow Speed");
menu.AddItem("15", "15: Low Health");
menu.AddItem("16", "16: Bleeding");
menu.AddItem("17", "17: Friendly Fire");
menu.AddItem("18", "18: Knockout");
menu.AddItem("19", "19: Strong Recoil");
menu.AddItem("20", "20: Heavy & Minigun only");
menu.AddItem("21", "21: Instagib");
menu.AddItem("22", "22: Knockback");
menu.AddItem("23", "23: Fast Hands");
menu.AddItem("24", "24: Headshots only");
menu.SetTitle("List of condition IDs:");
return menu;
}
public int Menu_ChangeMap(Menu menu, MenuAction action, int param1, int param2)
{
if (action == MenuAction_Select)
{
for(int iClient = 1; iClient <= MaxClients; iClient++) {
if(IsValidClient(iClient)) {
TerminateRoundRoulette(iClient);
}
}
sRoll = param2;
for(int client = 1; client <= MaxClients; client++) {
if(IsValidClient(client)) {
RoundRoulette(client);
PrintToChat(client, "\x04[RR]\x01 Admin has changed mode to \x04%s\x01!", g_CurrentCond);
ChatCurrentConditionInfo(client);
}
}
}
}
public void OnGameFrame() {
if (g_bDoubleJump) { // double jump active
for (int i = 1; i <= MaxClients; i++) { // cycle through players
if (
IsClientInGame(i) && // is in the game
IsPlayerAlive(i) // is alive
) {
DoubleJump(i); // Check for double jumping
}
}
}
}
public void OnClientDisconnect(int client) {
KillTimerSafe(g_HintTimer[client]);
TerminateRoundRoulette(client);
HideChatCurrentCondition[client] = false;
g_FullCrit[client] = false;
g_SoundHasPlayed[client] = false;
g_Classonly_OldClass[client] = TFClass_Unknown;
KillTimerSafe(g_BleedTimer[client]);
KillTimerSafe(g_KnockoutTimer[client]);
KillTimerSafe(g_MilkTimer[client]);
g_bHasStrongRecoil[client] = false;
KillTimerSafe(g_CritTimer[client]);
KillTimerSafe(g_SlowspeedTimer[client]);
}
public void OnClientPutInServer(int client) {
SDKHook(client, SDKHook_GetMaxHealth, OnGetMaxHealth);
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}
public void StrongRecoil_Perk(int client, bool apply){
g_bHasStrongRecoil[client] = apply;
}
public Action Event_PostInventory(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
switch(sRoll) {
case ROULETTE_MELEEONLY:
{
if(IsValidClient(client)) {
TF2_RemoveWeaponSlot(client, 0);
TF2_RemoveWeaponSlot(client, 1);
int iWeapon = GetPlayerWeaponSlot(client, 2);
if(iWeapon > MaxClients && IsValidEntity(iWeapon))
SetEntPropEnt(client, Prop_Send, "m_hActiveWeapon", iWeapon);
TF2_RemoveWeaponSlot(client, 3);
TF2_RemoveWeaponSlot(client, 4);
}
}
case ROULETTE_MINIGUN:
{
if(IsValidClient(client)) {
TF2_RemoveWeaponSlot(client, 2);
TF2_RemoveWeaponSlot(client, 1);
int iWeapon = GetPlayerWeaponSlot(client, 0);
if(iWeapon > MaxClients && IsValidEntity(iWeapon))
SetEntPropEnt(client, Prop_Send, "m_hActiveWeapon", iWeapon);
TF2Attrib_SetByName(client, "minigun spinup time decreased", 0.0);
}
}
case ROULETTE_INSTAGIB:
{
if(IsValidClient(client)) {
TF2_RemoveWeaponSlot(client, 1);
TF2_RemoveWeaponSlot(client, 2);
TF2_RemoveWeaponSlot(client, 0);
SpawnWeapon(client, "tf_weapon_sniperrifle", 526, 1, 0, "76 ; 5.0 ; 96 ; 1.6 ; 47 ; 1 ; 389 ; 1 ; 305 ; 1 ; 309 ; 1");
}
}
case ROULETTE_FASTHANDS:
{
TF2Attrib_SetByName(client, "reload time decreased", 0.1);
TF2Attrib_SetByName(client, "fire rate bonus", 0.5);
TF2Attrib_SetByName(client, "clip size bonus", 5.0);
TF2Attrib_SetByName(client, "maxammo primary increased", 5.0);
TF2Attrib_SetByName(client, "maxammo secondary increased", 5.0);
}
}
return Plugin_Continue;
}
public Action OnGetMaxHealth(int entity, int &maxhealth)
{
switch(sRoll) {
case ROULETTE_LOWHEALTH:
{
int client = entity;
if(!IsValidClient(client)) return Plugin_Continue;
if(!g_iHealth[client]) return Plugin_Continue;
maxhealth = g_iHealth[client];
return Plugin_Changed;
}
}
return Plugin_Continue;
}
stock bool IsValidClient(int client, bool isAlive=false)
{
if(!client||client>MaxClients) return false;
if(isAlive) return IsClientInGame(client) && IsPlayerAlive(client);
return IsClientInGame(client);
}
public void KillTimerSafe(Handle &hTimer)
{
if(hTimer != INVALID_HANDLE)
{
KillTimer(hTimer);
hTimer = INVALID_HANDLE;
}
}
stock int PrepareSound(const char[] szSoundPath)
{
PrecacheSound(szSoundPath, true);
char s[PLATFORM_MAX_PATH];
Format(s, sizeof(s), "sound/%s", szSoundPath);
AddFileToDownloadsTable(s);
}
public Action Command_SelectMode(int client, int args) {
if(args > 0) {
if(CanRoulette == false) {
char target[32];
GetCmdArg(1, target, sizeof(target));
int iRoll = StringToInt(target);
for(int iClient = 1; iClient <= MaxClients; iClient++) {
if(IsValidClient(iClient)) {
TerminateRoundRoulette(iClient); // terminate current one first
}
}
sRoll = iRoll; // new roll
ReplyToCommand(client, "\x04[RR]\x01 Mode changed successfully.");
for(int index = 1; index <= MaxClients; index++) {
if(IsValidClient(index)) {
RoundRoulette(index); // force the new condition
PrintToChat(index, "\x04[RR]\x01 Admin has changed mode to \x04%s\x01!", g_CurrentCond);
ChatCurrentConditionInfo(index);
}
}
return Plugin_Continue;
} else {
ReplyToCommand(client, "\x04[RR]\x01 Round must be active before you can change mode.");
return Plugin_Continue;
}
} else {
ReplyToCommand(client, "\x04[RR]\x01 Usage: sm_rr_selectmode <0-23>");
g_MapMenu.Display(client, 20);
return Plugin_Continue;
}
}
public Action Command_ReRoulette(int client, int args) {
if(args < 1) {
if(CanRoulette == false) {
for(int iClient = 1; iClient <= MaxClients; iClient++) {
if(IsValidClient(iClient)) {
TerminateRoundRoulette(iClient); // terminate current one first
}
}
sRoll = GetRandomInt(0, nRollRows);
for(int index = 1; index <= MaxClients; index++) {
if(IsValidClient(index)) {
RoundRoulette(index); // force the new condition
}
}
ReplyToCommand(client, "\x04[RR]\x01 Mode changed successfully.");
PrintToChatAll("\x04[RR]\x01 Admin has re-roulette the mode to \x04%s\x01!", g_CurrentCond);
return Plugin_Continue;
} else {
ReplyToCommand(client, "\x04[RR]\x01 Round must be active before you can change mode.");
return Plugin_Continue;
}
} else {
ReplyToCommand(client, "\x04[RR]\x01 Usage: sm_rr_reroulette");
return Plugin_Continue;
}
}
public int PanelHandler(Menu menu, MenuAction action, int param1, int param2)
{
if (action == MenuAction_Select)
{
//
} else if (action == MenuAction_Cancel) {
//
}
}
public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast) {
if(CanRoulette == true) {
float TimerWaiting = GetConVarFloat(g_hCvarTimerWaiting);
CanRoulette = false;
PrintToChatAll("\x04[RR]\x01 New condition in: \x04%i\x01 seconds.", RoundFloat(TimerWaiting));
g_RRTimer = CreateTimer(TimerWaiting, LetsRoulette);
}
}
public Action LetsRoulette(Handle timer) {
if(CanRoulette == false) {
// Terminates current condition, if there is one, before it actually rolls a new and picks that
for(int index = 1; index <= MaxClients; index++) {
if(IsValidClient(index)) {
TerminateRoundRoulette(index);
}
}
sRoll = GetRandomInt(0, nRollRows);
for(int client = 1; client <= MaxClients; client++) {
if(IsValidClient(client)) {
RoundRoulette(client);
}
}
CanRoulette = false;
}
}
public Action Timer_Hint(Handle timer, any client){
if(IsValidClient(client)) {
if(!StrEqual(g_CurrentCond, "", true)) { // fixes hint box appearing when mode isnt picked yet
PrintHintText(client, "[RR] Current round condition: %s", g_CurrentCond);
}
}
return Plugin_Continue;
}
public Action TF2_CalcIsAttackCritical(int client, int weapon, char[] weaponname, bool &result)
{
switch(sRoll) {
case ROULETTE_CRITS, ROULETTE_INSTAGIB:
{
if(g_FullCrit[client] == true)
{
result = true;
return Plugin_Handled;
}
}
case ROULETTE_STRONGRECOIL:
{
StrongRecoil_CritCheck(client, weapon);
return Plugin_Handled;
}
}
return Plugin_Continue;
}
stock int OnJump(any client){
switch(sRoll)
{
case ROULETTE_SUPERJUMP:
{
if(GetEntProp(client, Prop_Send, "m_bJumping") == 1){
float vect[3];
GetEntPropVector(client, Prop_Data, "m_vecVelocity", vect);
vect[2] = 750 + 25 * 13.0;
vect[0] *= (1 + Sine(float(25) * FLOAT_PI / 50));
vect[1] *= (1 + Sine(float(25) * FLOAT_PI / 50));
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vect);
ClientCommand(client, SOUND_WHOOSH);
}
}
}
}
public Action OnPlayerRunCmd(int client, int &buttons)
{
switch(sRoll)
{
case ROULETTE_SUPERJUMP:
{
if(!(GetEntityFlags(client) & FL_ONGROUND)){
if(jump[client] == 0){
jump[client] = 1;
OnJump(client);
}
} else {
if(jump[client] != 0){
jump[client] = 0;
}
}
}
case ROULETTE_POGO:
{
if(!(GetEntityFlags(client) & FL_ONGROUND)){
if(jump[client] == 0){
jump[client] = 1;
OnJump(client);
}
}else{
if(jump[client] != 0){
jump[client] = 0;
}
}
}
}
return Plugin_Continue;
}
stock int SetSpeed(int client, float speed){
if(TF2_IsPlayerInCondition(client, TFCond_Charging) || TF2_IsPlayerInCondition(client, TFCond_SpeedBuffAlly)){
return;
}
SetEntPropFloat(client, Prop_Send, "m_flMaxspeed", speed);
}
stock float GetDefSpeed(int client){
TFClassType class = TF2_GetPlayerClass(client);
switch(class){
case TFClass_Scout:{ return 400.0; }
case TFClass_Soldier:{ return 240.0; }
case TFClass_Pyro:{ return 300.0; }
case TFClass_DemoMan:{ return 280.0; }
case TFClass_Heavy:{ return 230.0; }
case TFClass_Engineer:{ return 300.0; }
case TFClass_Medic:{ return 320.0; }
case TFClass_Sniper:{ return 300.0; }
case TFClass_Spy:{ return 300.0; }
}
return 300.0;//Average
}
public Action Timer_Bleeding(Handle timer, any client) {
int curhealth = (GetClientHealth(client) - 1);
SetEntityHealth(client, curhealth);
if(curhealth <= 0){
SDKHooks_TakeDamage(client, 0, 0, 1.0, DMG_GENERIC); //To actually kill
}
return Plugin_Continue;
}
public Action Timer_Knockout(Handle timer, any client) {
TF2_StunPlayer(client, 3.5, 0.0, TF_STUNFLAG_BONKSTUCK, 0);
}
public Action Timer_Milk(Handle timer, any client) {
TF2_AddCondition(client, TFCond_Milked, TFCondDuration_Infinite, 0);
}
public Action Timer_Crits(Handle timer, any client) {
TF2_AddCondition(client, TFCond_Buffed, TFCondDuration_Infinite, 0);
}
public Action Timer_Slowspeed(Handle timer, any client) {
SetSpeed(client, FloatMul(GetDefSpeed(client), 0.8)); //20% slower speed
}
stock int SpawnWeapon(int client, char[] name, int index, int level, int qual, char[] att)
{
Handle hWeapon = TF2Items_CreateItem(OVERRIDE_ATTRIBUTES|FORCE_GENERATION);
if (hWeapon == INVALID_HANDLE)
return -1;
TF2Items_SetClassname(hWeapon, name);
TF2Items_SetItemIndex(hWeapon, index);
TF2Items_SetLevel(hWeapon, level);
TF2Items_SetQuality(hWeapon, qual);
char atts[32][32];
int count = ExplodeString(att, " ; ", atts, 32, 32);
if (count > 1)
{
TF2Items_SetNumAttributes(hWeapon, count/2);
int i2 = 0;
for (int i = 0; i < count; i += 2)
{
TF2Items_SetAttribute(hWeapon, i2, StringToInt(atts[i]), StringToFloat(atts[i+1]));
i2++;
}
} else {
TF2Items_SetNumAttributes(hWeapon, 0);
}
int entity = TF2Items_GiveNamedItem(client, hWeapon);
CloseHandle(hWeapon);
EquipPlayerWeapon(client, entity);
return entity;
}
public int RoundRoulette(int targets) {
switch(sRoll) {
case ROULETTE_CRITS:
{
g_CurrentCond = "Crits";
g_FullCrit[targets] = true;
if(g_SoundHasPlayed[targets] == false) {
EmitSoundToClient(targets, SOUND_CRITS, _, SNDCHAN_AUTO, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 1.0, 100, _, _, NULL_VECTOR, false, 0.0);
g_SoundHasPlayed[targets] = true;
}
}
case ROULETTE_MINICRITS:
{
g_CurrentCond = "Mini-Crits";
if(g_CritTimer[targets] == INVALID_HANDLE) {
g_CritTimer[targets] = CreateTimer(1.0, Timer_Crits, targets, TIMER_REPEAT);
}
if(g_SoundHasPlayed[targets] == false) {
EmitSoundToClient(targets, SOUND_MINICRITS, _, SNDCHAN_AUTO, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 1.0, 100, _, _, NULL_VECTOR, false, 0.0);
g_SoundHasPlayed[targets] = true;
}
}
case ROULETTE_SPEEDBOOST:
{
g_CurrentCond = "Speed boost";
TF2_AddCondition(targets, TFCond_SpeedBuffAlly, TFCondDuration_Infinite, 0);
if(g_SoundHasPlayed[targets] == false) {
EmitSoundToClient(targets, SOUND_SPEEDBOOST, _, SNDCHAN_AUTO, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 1.0, 100, _, _, NULL_VECTOR, false, 0.0);
g_SoundHasPlayed[targets] = true;
}
}
case ROULETTE_HEALTHBOOST:
{
g_CurrentCond = "Health boost";
int iHealth = GetClientHealth(targets);
g_iHealth[targets] = iHealth + 500;
if(TF2_GetPlayerClass(targets) == TFClass_Scout) {
if(iHealth < 126) {
SetEntityHealth(targets, g_iHealth[targets]);
}
} else if(TF2_GetPlayerClass(targets) == TFClass_Soldier) {
if(iHealth < 201) {
SetEntityHealth(targets, g_iHealth[targets]);
}
} else if(TF2_GetPlayerClass(targets) == TFClass_Pyro) {
if(iHealth < 176) {
SetEntityHealth(targets, g_iHealth[targets]);
}
} else if(TF2_GetPlayerClass(targets) == TFClass_DemoMan) {
if(iHealth < 176) {
SetEntityHealth(targets, g_iHealth[targets]);
}
} else if(TF2_GetPlayerClass(targets) == TFClass_Heavy) {
if(iHealth < 326) { // the choco bar gives more max hp
SetEntityHealth(targets, g_iHealth[targets]);
}
} else if(TF2_GetPlayerClass(targets) == TFClass_Engineer) {
if(iHealth < 151) { // gunslinger? gives more max hp
SetEntityHealth(targets, g_iHealth[targets]);
}
} else if(TF2_GetPlayerClass(targets) == TFClass_Sniper) {
if(iHealth < 126) {
SetEntityHealth(targets, g_iHealth[targets]);
}
} else if(TF2_GetPlayerClass(targets) == TFClass_Spy) {
if(iHealth < 126) {
SetEntityHealth(targets, g_iHealth[targets]);
}
}
if(g_SoundHasPlayed[targets] == false) {
EmitSoundToClient(targets, SOUND_HEALTHBOOST, _, SNDCHAN_AUTO, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 1.0, 100, _, _, NULL_VECTOR, false, 0.0);
g_SoundHasPlayed[targets] = true;
}
}
case ROULETTE_SUPERJUMP:
{
g_CurrentCond = "Super jump";
TF2Attrib_SetByName(targets, "cancel falling damage", 1.0);
if(g_SoundHasPlayed[targets] == false) {
EmitSoundToClient(targets, SOUND_SUPERJUMP, _, SNDCHAN_AUTO, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 1.0, 100, _, _, NULL_VECTOR, false, 0.0);
g_SoundHasPlayed[targets] = true;
}
// further effects take change in onplayerruncmd
}
case ROULETTE_INFJUMPS:
{
g_CurrentCond = "Infinite jumps";
g_bDoubleJump = true;
if(g_SoundHasPlayed[targets] == false) {
EmitSoundToClient(targets, SOUND_INFJUMPS, _, SNDCHAN_AUTO, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 1.0, 100, _, _, NULL_VECTOR, false, 0.0);
g_SoundHasPlayed[targets] = true;
}
}
case ROULETTE_MELEEONLY:
{
g_CurrentCond = "Melee only";
TF2_RemoveWeaponSlot(targets, 0);
TF2_RemoveWeaponSlot(targets, 1);
int iWeapon = GetPlayerWeaponSlot(targets, 2);
if(iWeapon > MaxClients && IsValidEntity(iWeapon))
SetEntPropEnt(targets, Prop_Send, "m_hActiveWeapon", iWeapon);
TF2_RemoveWeaponSlot(targets, 3);
TF2_RemoveWeaponSlot(targets, 4);
if(g_SoundHasPlayed[targets] == false) {
EmitSoundToClient(targets, SOUND_MELEEONLY, _, SNDCHAN_AUTO, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 1.0, 100, _, _, NULL_VECTOR, false, 0.0);
g_SoundHasPlayed[targets] = true;
}
}
case ROULETTE_CLASSONLY:
{
g_CurrentCond = "One class only";
if(TF2_GetPlayerClass(targets) != TFClass_Unknown) {
g_Classonly_OldClass[targets] = TF2_GetPlayerClass(targets); // used to switch them back to the old class after
} else {
g_Classonly_OldClass[targets] = TFClass_Scout; // sets it to scout in case they're not a class yet
}
if(RandomClass == TFClass_Unknown) {
RandomClass = view_as<TFClassType>(GetRandomInt(1, 9));
}
if(TF2_GetPlayerClass(targets) != RandomClass && RandomClass != TFClass_Unknown) {
TF2_SetPlayerClass(targets, RandomClass, true);
}
TF2_RegeneratePlayer(targets);
if(g_SoundHasPlayed[targets] == false) {
EmitSoundToClient(targets, SOUND_CLASSONLY, _, SNDCHAN_AUTO, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 1.0, 100, _, _, NULL_VECTOR, false, 0.0);
g_SoundHasPlayed[targets] = true;
}
}
case ROULETTE_GRAVITY:
{
Gravity_Roll = GetRandomInt(1, 2);
if(Gravity_Roll == 1) {
NewGravityAmount = "400"; // 50% higher
g_CurrentCond = "Low Gravity (50%)";
} else if(Gravity_Roll == 2) {
NewGravityAmount = "600"; // 25% higher
g_CurrentCond = "Low Gravity (25%)";
}
SetConVarInt(g_Cvar_Gravity, StringToInt(NewGravityAmount));
if(g_SoundHasPlayed[targets] == false) {
EmitSoundToClient(targets, SOUND_GRAVITY, _, SNDCHAN_AUTO, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 1.0, 100, _, _, NULL_VECTOR, false, 0.0);
g_SoundHasPlayed[targets] = true;
}
}
case ROULETTE_UNDERWATER:
{
g_CurrentCond = "Underwater";
TF2_AddCondition(targets, TFCond_SwimmingCurse, TFCondDuration_Infinite, 0);
if(g_SoundHasPlayed[targets] == false) {
EmitSoundToClient(targets, SOUND_UNDERWATER, _, SNDCHAN_AUTO, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 1.0, 100, _, _, NULL_VECTOR, false, 0.0);
g_SoundHasPlayed[targets] = true;
}
}
case ROULETTE_GHOST:
{
g_CurrentCond = "Ghost";
Invisible(targets, 0.4); //Barely visible
if(g_SoundHasPlayed[targets] == false) {
EmitSoundToClient(targets, SOUND_GHOST, _, SNDCHAN_AUTO, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 1.0, 100, _, _, NULL_VECTOR, false, 0.0);
g_SoundHasPlayed[targets] = true;
}
}
case ROULETTE_DWARF:
{
g_CurrentCond = "Dwarf";
SizePlayer(targets, 0.5); //Half size
if(g_SoundHasPlayed[targets] == false) {
EmitSoundToClient(targets, SOUND_DWARF, _, SNDCHAN_AUTO, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 1.0, 100, _, _, NULL_VECTOR, false, 0.0);
g_SoundHasPlayed[targets] = true;
}
}
case ROULETTE_MILK:
{
g_CurrentCond = "Milk";
if(g_MilkTimer[targets] == INVALID_HANDLE) {
g_MilkTimer[targets] = CreateTimer(1.0, Timer_Milk, targets, TIMER_REPEAT);
}
if(g_SoundHasPlayed[targets] == false) {
EmitSoundToClient(targets, SOUND_MILK, _, SNDCHAN_AUTO, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 1.0, 100, _, _, NULL_VECTOR, false, 0.0);
g_SoundHasPlayed[targets] = true;
}
}
case ROULETTE_POGO:
{
g_CurrentCond = "Pogo Jump";
TF2Attrib_SetByName(targets, "cancel falling damage", 1.0);
TF2Attrib_SetByName(targets, "increased jump height", 3.0);
SetEntityGravity(targets, 1.7);
if(g_SoundHasPlayed[targets] == false) {
EmitSoundToClient(targets, SOUND_POGO, _, SNDCHAN_AUTO, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 1.0, 100, _, _, NULL_VECTOR, false, 0.0);
g_SoundHasPlayed[targets] = true;
}
}
case ROULETTE_SLOWSPEED:
{
g_CurrentCond = "Slower speed";
if(g_SlowspeedTimer[targets] == INVALID_HANDLE) {
g_SlowspeedTimer[targets] = CreateTimer(1.0, Timer_Slowspeed, targets, TIMER_REPEAT);
}
if(g_SoundHasPlayed[targets] == false) {
EmitSoundToClient(targets, SOUND_SLOWSPEED, _, SNDCHAN_AUTO, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 1.0, 100, _, _, NULL_VECTOR, false, 0.0);
g_SoundHasPlayed[targets] = true;
}
}
case ROULETTE_LOWHEALTH:
{
g_CurrentCond = "Low Health";
OriginalHealth[targets] = GetClientHealth(targets);
g_iHealth[targets] = 1;
SetEntityHealth(targets, g_iHealth[targets]);
// Sets sentry health to 1
int sentry=-1;
while((sentry=FindEntityByClassname(sentry, "CObjectSentrygun"))!=-1)
{
SetVariantInt(1);
AcceptEntityInput(sentry, "AddHealth");
}
if(TF2_GetPlayerClass(targets) == TFClass_Medic) {
TF2Attrib_SetByName(targets, "overheal penalty", 0.0);
}
if(g_SoundHasPlayed[targets] == false) {
EmitSoundToClient(targets, SOUND_LOWHEALTH, _, SNDCHAN_AUTO, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 1.0, 100, _, _, NULL_VECTOR, false, 0.0);
g_SoundHasPlayed[targets] = true;
}
}
case ROULETTE_BLEEDING:
{
g_CurrentCond = "Bleeding";
if(g_BleedTimer[targets] == INVALID_HANDLE) {
g_BleedTimer[targets] = CreateTimer(1.0, Timer_Bleeding, targets, TIMER_REPEAT);
}
if(g_SoundHasPlayed[targets] == false) {
EmitSoundToClient(targets, SOUND_BLEEDING, _, SNDCHAN_AUTO, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 1.0, 100, _, _, NULL_VECTOR, false, 0.0);
g_SoundHasPlayed[targets] = true;
}
}
case ROULETTE_FREEFORALL:
{
g_CurrentCond = "Free for all";
SetConVarBool(g_Cvar_FriendlyFire, true);
if(g_SoundHasPlayed[targets] == false) {
EmitSoundToClient(targets, SOUND_FREEFORALL, _, SNDCHAN_AUTO, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 1.0, 100, _, _, NULL_VECTOR, false, 0.0);
g_SoundHasPlayed[targets] = true;
}
}
case ROULETTE_KNOCKOUT:
{
g_CurrentCond = "Knockout";
if(g_KnockoutTimer[targets] == INVALID_HANDLE) {
g_KnockoutTimer[targets] = CreateTimer(35.0, Timer_Knockout, targets, TIMER_REPEAT);
}
if(g_SoundHasPlayed[targets] == false) {
EmitSoundToClient(targets, SOUND_KNOCKOUT, _, SNDCHAN_AUTO, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 1.0, 100, _, _, NULL_VECTOR, false, 0.0);
g_SoundHasPlayed[targets] = true;
}
}
case ROULETTE_STRONGRECOIL:
{
g_CurrentCond = "Strong Recoil";
StrongRecoil_Perk(targets, true);
if(g_SoundHasPlayed[targets] == false) {
EmitSoundToClient(targets, SOUND_STRONGRECOIL, _, SNDCHAN_AUTO, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 1.0, 100, _, _, NULL_VECTOR, false, 0.0);
g_SoundHasPlayed[targets] = true;
}
}
case ROULETTE_MINIGUN:
{
g_CurrentCond = "Heavy & Minigun only";
TF2_SetPlayerClass(targets, TFClass_Heavy);
TF2_RegeneratePlayer(targets);
TF2_RemoveWeaponSlot(targets, 2);
TF2_RemoveWeaponSlot(targets, 1);