-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathfreak_fortress_2.sp
8248 lines (7484 loc) · 220 KB
/
freak_fortress_2.sp
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
/*
===Freak Fortress 2===
By Rainbolt Dash: programmer, modeller, mapper, painter.
Author of Demoman The Pirate: http://www.randomfortress.ru/thepirate/
And one of two creators of Floral Defence: http://www.polycount.com/forum/showthread.php?t=73688
And author of VS Saxton Hale Mode
And notoriously famous for creating plugins with terrible code and then abandoning them.
Plugin thread on AlliedMods: http://forums.alliedmods.net/showthread.php?t=182108
Updated by Otokiru, Powerlord, and RavensBro after Rainbolt Dash got sucked into DOTA2
Updated by Wliu, Chris, Lawd, and Carge after Powerlord quit FF2
*/
#pragma semicolon 1
#include <sourcemod>
#include <freak_fortress_2>
#include <adt_array>
#include <clientprefs>
#include <morecolors>
#include <sdkhooks>
#include <tf2_stocks>
#include <tf2items>
#include <tf2attributes>
#undef REQUIRE_EXTENSIONS
#tryinclude <steamtools>
#define REQUIRE_EXTENSIONS
#undef REQUIRE_PLUGIN
#tryinclude <smac>
#tryinclude <updater>
#define REQUIRE_PLUGIN
#define MAJOR_REVISION "2"
#define MINOR_REVISION "0"
#define STABLE_REVISION "0"
#define DEV_REVISION "alpha"
#if !defined DEV_REVISION
#define PLUGIN_VERSION MAJOR_REVISION..."."...MINOR_REVISION..."."...STABLE_REVISION //2.0.0
#else
#define PLUGIN_VERSION MAJOR_REVISION..."."...MINOR_REVISION..."."...STABLE_REVISION..."-"...DEV_REVISION //semver.org
#endif
#define UPDATE_URL "http://50dkp.github.io/FF2-Official/update.txt"
#define MAXENTITIES 2048
#define HEALTHBAR_CLASS "monster_resource"
#define HEALTHBAR_PROPERTY "m_iBossHealthPercentageByte"
#define HEALTHBAR_MAX 255
#define MONOCULUS "eyeball_boss"
#define FF2_CONFIGS "configs/freak_fortress_2"
#define FF2_SETTINGS "data/freak_fortress_2"
#define BOSS_CONFIG "characters.cfg"
#define DOORS_CONFIG "doors.cfg"
#define WEAPONS_CONFIG "weapons.cfg"
#define MAPS_CONFIG "maps.cfg"
#define CHANGELOG "changelog.txt"
#if defined _steamtools_included
new bool:steamtools;
#endif
new TFTeam:OtherTeam=TFTeam_Red;
new TFTeam:BossTeam=TFTeam_Blue;
new playing;
new healthcheckused;
new RedAlivePlayers;
new BlueAlivePlayers;
new RoundCount;
new character[MAXPLAYERS+1];
new Incoming[MAXPLAYERS+1];
new Damage[MAXPLAYERS+1];
new uberTarget[MAXPLAYERS+1];
new shield[MAXPLAYERS+1];
new detonations[MAXPLAYERS+1];
new bool:playBGM[MAXPLAYERS+1]=true;
new queuePoints[MAXPLAYERS+1];
new muteSound[MAXPLAYERS+1];
new bool:displayInfo[MAXPLAYERS+1];
new String:currentBGM[MAXPLAYERS+1][PLATFORM_MAX_PATH];
new FF2Flags[MAXPLAYERS+1];
new Boss[MAXPLAYERS+1];
new BossHealthMax[MAXPLAYERS+1];
new BossHealth[MAXPLAYERS+1];
new BossHealthLast[MAXPLAYERS+1];
new BossLives[MAXPLAYERS+1];
new BossLivesMax[MAXPLAYERS+1];
new BossRageDamage[MAXPLAYERS+1];
new Float:BossSpeed[MAXPLAYERS+1];
new Float:BossCharge[MAXPLAYERS+1][8];
new Float:Stabbed[MAXPLAYERS+1];
new Float:Marketed[MAXPLAYERS+1];
new Float:KSpreeTimer[MAXPLAYERS+1];
new KSpreeCount[MAXPLAYERS+1];
new Float:GlowTimer[MAXPLAYERS+1];
new shortname[MAXPLAYERS+1];
new bool:emitRageSound[MAXPLAYERS+1];
new bool:bossHasReloadAbility[MAXPLAYERS+1];
new bool:bossHasRightMouseAbility[MAXPLAYERS+1];
new timeleft;
new Handle:cvarVersion;
new Handle:cvarPointDelay;
new Handle:cvarAnnounce;
new Handle:cvarEnabled;
new Handle:cvarAliveToEnable;
new Handle:cvarPointType;
new Handle:cvarCrits;
new Handle:cvarArenaRounds;
new Handle:cvarCircuitStun;
new Handle:cvarSpecForceBoss;
new Handle:cvarCountdownPlayers;
new Handle:cvarCountdownTime;
new Handle:cvarCountdownHealth;
new Handle:cvarCountdownResult;
new Handle:cvarEnableEurekaEffect;
new Handle:cvarForceBossTeam;
new Handle:cvarHealthBar;
new Handle:cvarLastPlayerGlow;
new Handle:cvarBossTeleporter;
new Handle:cvarBossSuicide;
new Handle:cvarShieldCrits;
new Handle:cvarCaberDetonations;
new Handle:cvarUpdater;
new Handle:cvarDebug;
new Handle:cvarPreroundBossDisconnect;
new Handle:bossesArray;
new Handle:bossesArrayShadow; // FIXME: ULTRA HACKY HACK
new Handle:voicesArray; // TODO: Rename this or remove it in favor of something else
new Handle:subpluginArray;
new Handle:chancesArray;
new Handle:FF2Cookie_QueuePoints;
new Handle:FF2Cookie_MuteSound;
new Handle:FF2Cookie_DisplayInfo;
new Handle:changelogMenu;
new Handle:jumpHUD;
new Handle:rageHUD;
new Handle:livesHUD;
new Handle:timeleftHUD;
new Handle:abilitiesHUD;
new Handle:infoHUD;
new bool:Enabled=true;
new bool:Enabled2=true;
new PointDelay=6;
new Float:Announce=120.0;
new AliveToEnable=5;
new PointType;
new bool:BossCrits=true;
new arenaRounds;
new Float:circuitStun;
new countdownPlayers=1;
new countdownTime=120;
new countdownHealth=2000;
new bool:SpecForceBoss;
new bool:lastPlayerGlow=true;
new bool:bossTeleportation=true;
new shieldCrits;
new allowedDetonations;
new Handle:MusicTimer[MAXPLAYERS+1];
new Handle:BossInfoTimer[MAXPLAYERS+1][2];
new Handle:DrawGameTimer;
new Handle:doorCheckTimer;
new botqueuepoints;
new Float:HPTime;
new String:currentmap[99];
new bool:checkDoors;
new bool:bMedieval;
new bool:firstBlood;
new tf_arena_use_queue;
new mp_teams_unbalance_limit;
new tf_arena_first_blood;
new mp_forcecamera;
new tf_dropped_weapon_lifetime;
new Float:tf_feign_death_activate_damage_scale;
new Float:tf_feign_death_damage_scale;
new String:mp_humans_must_join_team[16];
new Handle:cvarNextmap;
new FF2CharSet;
new validCharsets[64];
new String:FF2CharSetString[42];
new bool:isCharSetSelected;
new healthBar=-1;
new g_Monoculus=-1;
static bool:executed;
static bool:executed2;
new changeGamemode;
//new Handle:kvWeaponSpecials;
new Handle:kvWeaponMods;
enum FF2RoundState
{
FF2RoundState_Loading=-1,
FF2RoundState_Setup,
FF2RoundState_RoundRunning,
FF2RoundState_RoundEnd,
}
enum FF2WeaponSpecials
{
FF2WeaponSpecial_PreventDamage,
FF2WeaponSpecial_RemoveOnDamage,
FF2WeaponSpecial_JarateOnChargedHit,
}
enum FF2WeaponModType
{
FF2WeaponMod_AddAttrib,
FF2WeaponMod_RemoveAttrib,
FF2WeaponMod_Replace,
FF2WeaponMod_OnHit,
FF2WeaponMod_OnTakeDamage,
}
/*new String:WeaponSpecials[][]=
{
"drop health pack on kill",
"glow on scoped hit",
"prevent damage",
"remove on damage",
"drain boost when full"
};*/
enum Operators
{
Operator_None=0,
Operator_Add,
Operator_Subtract,
Operator_Multiply,
Operator_Divide,
Operator_Exponent,
};
new Handle:PreAbility;
new Handle:OnAbility;
new Handle:OnMusic;
new Handle:OnTriggerHurt;
new Handle:OnBossSelected;
new Handle:OnAddQueuePoints;
new Handle:OnLoadCharacterSet;
new Handle:OnLoseLife;
new Handle:OnAlivePlayersChanged;
new Handle:OnParseUnknownVariable;
public Plugin:myinfo=
{
name="Freak Fortress 2",
author="Rainbolt Dash, FlaminSarge, Powerlord, the 50DKP team",
description="RUUUUNN!! COWAAAARRDSS!",
version=PLUGIN_VERSION,
};
public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
{
decl String:plugin[PLATFORM_MAX_PATH];
GetPluginFilename(myself, plugin, sizeof(plugin));
if(!StrContains(plugin, "freak_fortress_2/")) //Prevent plugins/freak_fortress_2/freak_fortress_2.smx from loading if it exists -.-
{
strcopy(error, err_max, "There is a duplicate copy of Freak Fortress 2 inside the /plugins/freak_fortress_2 folder. Please remove it");
return APLRes_Failure;
}
CreateNative("FF2_IsFF2Enabled", Native_IsFF2Enabled);
CreateNative("FF2_RegisterSubplugin", Native_RegisterSubplugin);
CreateNative("FF2_UnregisterSubplugin", Native_UnregisterSubplugin);
CreateNative("FF2_GetFF2Version", Native_GetFF2Version);
CreateNative("FF2_GetRoundState", Native_GetRoundState);
CreateNative("FF2_GetBossUserId", Native_GetBossUserId);
CreateNative("FF2_GetBossIndex", Native_GetBossIndex);
CreateNative("FF2_GetBossTeam", Native_GetBossTeam);
CreateNative("FF2_GetBossName", Native_GetBossName);
CreateNative("FF2_GetBossKV", Native_GetBossKV);
CreateNative("FF2_GetBossHealth", Native_GetBossHealth);
CreateNative("FF2_SetBossHealth", Native_SetBossHealth);
CreateNative("FF2_GetBossMaxHealth", Native_GetBossMaxHealth);
CreateNative("FF2_SetBossMaxHealth", Native_SetBossMaxHealth);
CreateNative("FF2_GetBossLives", Native_GetBossLives);
CreateNative("FF2_SetBossLives", Native_SetBossLives);
CreateNative("FF2_GetBossMaxLives", Native_GetBossMaxLives);
CreateNative("FF2_SetBossMaxLives", Native_SetBossMaxLives);
CreateNative("FF2_GetBossCharge", Native_GetBossCharge);
CreateNative("FF2_SetBossCharge", Native_SetBossCharge);
CreateNative("FF2_GetBossRageDamage", Native_GetBossRageDamage);
CreateNative("FF2_SetBossRageDamage", Native_SetBossRageDamage);
CreateNative("FF2_GetBossRageDistance", Native_GetBossRageDistance);
CreateNative("FF2_GetClientDamage", Native_GetClientDamage);
CreateNative("FF2_SetClientDamage", Native_SetClientDamage);
CreateNative("FF2_HasAbility", Native_HasAbility);
CreateNative("FF2_GetAbilityArgument", Native_GetAbilityArgument);
CreateNative("FF2_GetAbilityArgumentFloat", Native_GetAbilityArgumentFloat);
CreateNative("FF2_GetAbilityArgumentString", Native_GetAbilityArgumentString);
CreateNative("FF2_UseAbility", Native_UseAbility);
CreateNative("FF2_GetFF2Flags", Native_GetFF2Flags);
CreateNative("FF2_SetFF2Flags", Native_SetFF2Flags);
CreateNative("FF2_GetQueuePoints", Native_GetQueuePoints);
CreateNative("FF2_SetQueuePoints", Native_SetQueuePoints);
CreateNative("FF2_StartMusic", Native_StartMusic);
CreateNative("FF2_StopMusic", Native_StopMusic);
CreateNative("FF2_FindSound", Native_FindSound);
CreateNative("FF2_GetClientGlow", Native_GetClientGlow);
CreateNative("FF2_SetClientGlow", Native_SetClientGlow);
CreateNative("FF2_Debug", Native_Debug);
CreateNative("FF2_SetSoundFlags", Native_SetSoundFlags);
CreateNative("FF2_ClearSoundFlags", Native_ClearSoundFlags);
CreateNative("FF2_CheckSoundFlags", Native_CheckSoundFlags);
PreAbility=CreateGlobalForward("FF2_PreAbility", ET_Hook, Param_Cell, Param_String, Param_String, Param_Cell, Param_CellByRef); //Boss, plugin name, ability name, slot, enabled
OnAbility=CreateGlobalForward("FF2_OnAbility", ET_Hook, Param_Cell, Param_String, Param_String, Param_Cell, Param_Cell); //Boss, plugin name, ability name, slot, status
OnMusic=CreateGlobalForward("FF2_OnMusic", ET_Hook, Param_Cell, Param_String, Param_CellByRef);
OnTriggerHurt=CreateGlobalForward("FF2_OnTriggerHurt", ET_Hook, Param_Cell, Param_Cell, Param_FloatByRef);
OnBossSelected=CreateGlobalForward("FF2_OnBossSelected", ET_Hook, Param_Cell, Param_CellByRef, Param_String, Param_Cell); //Boss, character index, character name, preset
OnAddQueuePoints=CreateGlobalForward("FF2_OnAddQueuePoints", ET_Hook, Param_Array);
OnLoadCharacterSet=CreateGlobalForward("FF2_OnLoadCharacterSet", ET_Hook, Param_String);
OnLoseLife=CreateGlobalForward("FF2_OnLoseLife", ET_Hook, Param_Cell, Param_CellByRef, Param_Cell); //Boss, lives left, max lives
OnAlivePlayersChanged=CreateGlobalForward("FF2_OnAlivePlayersChanged", ET_Hook, Param_Cell, Param_Cell); //Players, bosses
OnParseUnknownVariable=CreateGlobalForward("FF2_OnParseUnknownVariable", ET_Hook, Param_String, Param_FloatByRef); //Variable, value
RegPluginLibrary("freak_fortress_2");
subpluginArray=CreateArray(64); // Create this as soon as possible so that subplugins have access to it
#if defined _steamtools_included
MarkNativeAsOptional("Steam_SetGameDescription");
#endif
return APLRes_Success;
}
public OnPluginStart()
{
LogMessage("===Freak Fortress 2 Initializing-v%s===", PLUGIN_VERSION);
cvarVersion=CreateConVar("ff2_version", PLUGIN_VERSION, "Freak Fortress 2 Version", FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_SPONLY|FCVAR_DONTRECORD);
cvarPointType=CreateConVar("ff2_point_type", "0", "0-Use ff2_point_alive, 1-Use ff2_point_time", _, true, 0.0, true, 1.0);
cvarPointDelay=CreateConVar("ff2_point_delay", "6", "Seconds to add to the point delay per player", _, true, 0.0);
cvarAliveToEnable=CreateConVar("ff2_point_alive", "5", "The control point will only activate when there are this many people or less left alive");
cvarAnnounce=CreateConVar("ff2_announce", "120", "Amount of seconds to wait until FF2 info is displayed again. 0 to disable", _, true, 0.0);
cvarEnabled=CreateConVar("ff2_enabled", "1", "0-Disable FF2 (WHY?), 1-Enable FF2", FCVAR_DONTRECORD, true, 0.0, true, 1.0);
cvarCrits=CreateConVar("ff2_crits", "0", "Can the boss get random crits?", _, true, 0.0, true, 1.0);
cvarArenaRounds=CreateConVar("ff2_arena_rounds", "1", "Number of rounds to make arena before switching to FF2 (helps for slow-loading players)", _, true, 0.0);
cvarCircuitStun=CreateConVar("ff2_circuit_stun", "2", "Amount of seconds the Short Circuit stuns the boss for. 0 to disable", _, true, 0.0);
cvarCountdownPlayers=CreateConVar("ff2_countdown_players", "1", "Amount of players until the countdown timer starts (0 to disable)", _, true, 0.0);
cvarCountdownTime=CreateConVar("ff2_countdown", "120", "Amount of seconds until the round ends in a stalemate");
cvarCountdownHealth=CreateConVar("ff2_countdown_health", "2000", "Amount of health the Boss has remaining until the countdown stops", _, true, 0.0);
cvarCountdownResult=CreateConVar("ff2_countdown_result", "0", "0-Kill players when the countdown ends, 1-End the round in a stalemate", _, true, 0.0, true, 1.0);
cvarSpecForceBoss=CreateConVar("ff2_spec_force_boss", "0", "0-Spectators are excluded from the queue system, 1-Spectators are counted in the queue system", _, true, 0.0, true, 1.0);
cvarEnableEurekaEffect=CreateConVar("ff2_enable_eureka", "0", "0-Disable the Eureka Effect, 1-Enable the Eureka Effect", _, true, 0.0, true, 1.0);
cvarForceBossTeam=CreateConVar("ff2_force_team", "0", "0-Boss is always on Blu, 1-Boss is on a random team each round, 2-Boss is always on Red", _, true, 0.0, true, 3.0);
cvarHealthBar=CreateConVar("ff2_health_bar", "0", "0-Disable the health bar, 1-Show the health bar", _, true, 0.0, true, 1.0);
cvarLastPlayerGlow=CreateConVar("ff2_last_player_glow", "1", "0-Don't outline the last player, 1-Outline the last player alive", _, true, 0.0, true, 1.0);
cvarBossTeleporter=CreateConVar("ff2_boss_teleporter", "0", "-1 to disallow all bosses from using teleporters, 0 to use TF2 logic, 1 to allow all bosses", _, true, -1.0, true, 1.0);
cvarBossSuicide=CreateConVar("ff2_boss_suicide", "0", "Allow the boss to suicide after the round starts?", _, true, 0.0, true, 1.0);
cvarPreroundBossDisconnect=CreateConVar("ff2_replace_disconnected_boss", "1", "If a boss disconnects before the round starts, use the next player in line instead? 0 - No, 1 - Yes", _, true, 0.0, true, 1.0);
cvarCaberDetonations=CreateConVar("ff2_caber_detonations", "5", "Amount of times somebody can detonate the Ullapool Caber");
cvarShieldCrits=CreateConVar("ff2_shield_crits", "0", "0 to disable grenade launcher crits when equipping a shield, 1 for minicrits, 2 for crits", _, true, 0.0, true, 2.0);
cvarUpdater=CreateConVar("ff2_updater", "1", "0-Disable Updater support, 1-Enable automatic updating (recommended, requires Updater)", _, true, 0.0, true, 1.0);
cvarDebug=CreateConVar("ff2_debug", "0", "0-Disable FF2 debug output, 1-Enable debugging (not recommended)", _, true, 0.0, true, 1.0);
HookEvent("teamplay_round_start", OnRoundStart);
HookEvent("teamplay_round_win", OnRoundEnd);
HookEvent("teamplay_broadcast_audio", OnBroadcast, EventHookMode_Pre);
HookEvent("player_spawn", OnPlayerSpawn, EventHookMode_Pre);
HookEvent("post_inventory_application", OnPostInventoryApplication, EventHookMode_Pre);
HookEvent("player_death", OnPlayerDeath, EventHookMode_Pre);
HookEvent("player_chargedeployed", OnUberDeployed);
HookEvent("player_hurt", OnPlayerHurt, EventHookMode_Pre);
HookEvent("object_destroyed", OnObjectDestroyed, EventHookMode_Pre);
HookEvent("object_deflected", OnObjectDeflected, EventHookMode_Pre);
HookEvent("deploy_buff_banner", OnDeployBackup);
HookUserMessage(GetUserMessageId("PlayerJarated"), OnJarate); //Used to subtract rage when a boss is jarated (not through Sydney Sleeper)
AddCommandListener(OnCallForMedic, "voicemenu"); //Used to activate rages
AddCommandListener(OnSuicide, "explode"); //Used to stop boss from suiciding
AddCommandListener(OnSuicide, "kill"); //Used to stop boss from suiciding
AddCommandListener(OnSuicide, "spectate"); //Used to stop boss from suiciding
AddCommandListener(OnJoinTeam, "jointeam"); //Used to make sure players join the right team
AddCommandListener(OnJoinTeam, "autoteam"); //Used to make sure players don't kill themselves and change team
AddCommandListener(OnChangeClass, "joinclass"); //Used to make sure bosses don't change class
HookConVarChange(cvarEnabled, CvarChange);
HookConVarChange(cvarPointDelay, CvarChange);
HookConVarChange(cvarAnnounce, CvarChange);
HookConVarChange(cvarPointType, CvarChange);
HookConVarChange(cvarPointDelay, CvarChange);
HookConVarChange(cvarAliveToEnable, CvarChange);
HookConVarChange(cvarCrits, CvarChange);
HookConVarChange(cvarCircuitStun, CvarChange);
HookConVarChange(cvarHealthBar, HealthbarEnableChanged);
HookConVarChange(cvarCountdownPlayers, CvarChange);
HookConVarChange(cvarCountdownTime, CvarChange);
HookConVarChange(cvarCountdownHealth, CvarChange);
HookConVarChange(cvarLastPlayerGlow, CvarChange);
HookConVarChange(cvarSpecForceBoss, CvarChange);
HookConVarChange(cvarBossTeleporter, CvarChange);
HookConVarChange(cvarShieldCrits, CvarChange);
HookConVarChange(cvarCaberDetonations, CvarChange);
HookConVarChange(cvarUpdater, CvarChange);
HookConVarChange(cvarNextmap=FindConVar("sm_nextmap"), CvarChangeNextmap);
RegConsoleCmd("ff2", FF2Panel);
RegConsoleCmd("ff2_hp", Command_GetHPCmd);
RegConsoleCmd("ff2_next", QueuePanelCmd);
RegConsoleCmd("ff2_classinfo", Command_HelpPanelClass);
RegConsoleCmd("ff2_changelog", Command_ShowChangelog);
RegConsoleCmd("ff2_music", MusicTogglePanelCmd);
RegConsoleCmd("ff2_voice", VoiceTogglePanelCmd);
RegConsoleCmd("ff2_resetpoints", ResetQueuePointsCmd);
RegConsoleCmd("nextmap", Command_Nextmap);
RegConsoleCmd("say", Command_Say);
RegConsoleCmd("say_team", Command_Say);
RegAdminCmd("ff2_special", Command_SetNextBoss, ADMFLAG_CHEATS, "Usage: ff2_special <boss>. Forces next round to use that boss");
RegAdminCmd("ff2_addpoints", Command_Points, ADMFLAG_CHEATS, "Usage: ff2_addpoints <target> <points>. Adds queue points to any player");
RegAdminCmd("ff2_point_enable", Command_Point_Enable, ADMFLAG_CHEATS, "Enable the control point if ff2_point_type is 0");
RegAdminCmd("ff2_point_disable", Command_Point_Disable, ADMFLAG_CHEATS, "Disable the control point if ff2_point_type is 0");
RegAdminCmd("ff2_start_music", Command_StartMusic, ADMFLAG_CHEATS, "Start the Boss's music");
RegAdminCmd("ff2_stop_music", Command_StopMusic, ADMFLAG_CHEATS, "Stop any currently playing Boss music");
RegAdminCmd("ff2_resetqueuepoints", ResetQueuePointsCmd, ADMFLAG_CHEATS, "Reset a player's queue points");
RegAdminCmd("ff2_resetq", ResetQueuePointsCmd, ADMFLAG_CHEATS, "Reset a player's queue points");
RegAdminCmd("ff2_charset", Command_Charset, ADMFLAG_CHEATS, "Usage: ff2_charset <charset>. Forces FF2 to use a given character set");
RegAdminCmd("ff2_reload_subplugins", Command_ReloadSubPlugins, ADMFLAG_RCON, "Reload FF2's subplugins.");
AutoExecConfig(true, "freak_fortress_2", "sourcemod/freak_fortress_2");
FF2Cookie_QueuePoints=RegClientCookie("ff2_cookie_queuepoints", "Client's queue points", CookieAccess_Protected);
FF2Cookie_MuteSound=RegClientCookie("ff2_cookie_mutesound", "Client's sound preferences", CookieAccess_Public);
FF2Cookie_DisplayInfo=RegClientCookie("ff2_cookie_displayinfo", "Client's display info preferences", CookieAccess_Public);
jumpHUD=CreateHudSynchronizer();
rageHUD=CreateHudSynchronizer();
livesHUD=CreateHudSynchronizer();
abilitiesHUD=CreateHudSynchronizer();
timeleftHUD=CreateHudSynchronizer();
infoHUD=CreateHudSynchronizer();
bossesArray=CreateArray();
bossesArrayShadow=CreateArray();
voicesArray=CreateArray();
decl String:oldVersion[64];
GetConVarString(cvarVersion, oldVersion, sizeof(oldVersion));
if(!StrEqual(oldVersion, PLUGIN_VERSION, false))
{
PrintToServer("[FF2] Warning: Your config may be outdated. Back up tf/cfg/sourcemod/freak_fortress_2.cfg and delete it, and this plugin will generate a new one that you can then modify to your original values.");
}
LoadTranslations("freak_fortress_2.phrases");
LoadTranslations("common.phrases");
AddNormalSoundHook(HookSound);
AddMultiTargetFilter("@hale", BossTargetFilter, "all current Bosses", false);
AddMultiTargetFilter("@!hale", BossTargetFilter, "all non-Boss players", false);
AddMultiTargetFilter("@boss", BossTargetFilter, "all current Bosses", false);
AddMultiTargetFilter("@!boss", BossTargetFilter, "all non-Boss players", false);
#if defined _steamtools_included
steamtools=LibraryExists("SteamTools");
#endif
}
public bool:BossTargetFilter(const String:pattern[], Handle:clients)
{
new bool:non=StrContains(pattern, "!", false)!=-1;
for(new client=1; client<=MaxClients; client++)
{
if(IsValidClient(client) && FindValueInArray(clients, client)==-1)
{
if(Enabled && IsBoss(client))
{
if(!non)
{
PushArrayCell(clients, client);
}
}
else if(non)
{
PushArrayCell(clients, client);
}
}
}
return true;
}
public OnLibraryAdded(const String:name[])
{
#if defined _steamtools_included
if(StrEqual(name, "SteamTools", false))
{
steamtools=true;
}
#endif
#if defined _updater_included && !defined DEV_REVISION
if(StrEqual(name, "updater") && GetConVarBool(cvarUpdater))
{
Updater_AddPlugin(UPDATE_URL);
}
#endif
}
public OnLibraryRemoved(const String:name[])
{
#if defined _steamtools_included
if(StrEqual(name, "SteamTools", false))
{
steamtools=false;
}
#endif
#if defined _updater_included
if(StrEqual(name, "updater"))
{
Updater_RemovePlugin();
}
#endif
}
public OnConfigsExecuted()
{
tf_arena_use_queue=GetConVarInt(FindConVar("tf_arena_use_queue"));
mp_teams_unbalance_limit=GetConVarInt(FindConVar("mp_teams_unbalance_limit"));
tf_arena_first_blood=GetConVarInt(FindConVar("tf_arena_first_blood"));
mp_forcecamera=GetConVarInt(FindConVar("mp_forcecamera"));
tf_dropped_weapon_lifetime=bool:GetConVarInt(FindConVar("tf_dropped_weapon_lifetime"));
tf_feign_death_activate_damage_scale=GetConVarFloat(FindConVar("tf_feign_death_activate_damage_scale"));
tf_feign_death_damage_scale=GetConVarFloat(FindConVar("tf_feign_death_damage_scale"));
GetConVarString(FindConVar("mp_humans_must_join_team"), mp_humans_must_join_team, sizeof(mp_humans_must_join_team));
if(IsFF2Map() && GetConVarBool(cvarEnabled))
{
EnableFF2();
}
else
{
DisableFF2();
}
#if defined _updater_included && !defined DEV_REVISION
if(LibraryExists("updater") && GetConVarBool(cvarUpdater))
{
Updater_AddPlugin(UPDATE_URL);
}
#endif
}
public OnMapStart()
{
HPTime=0.0;
doorCheckTimer=INVALID_HANDLE;
RoundCount=0;
for(new client; client<=MaxClients; client++)
{
KSpreeTimer[client]=0.0;
FF2Flags[client]=0;
Incoming[client]=-1;
MusicTimer[client]=INVALID_HANDLE;
}
for(new index; index<GetArraySize(bossesArray); index++)
{
if(GetArrayCell(bossesArray, index)!=INVALID_HANDLE)
{
CloseHandle(GetArrayCell(bossesArray, index));
SetArrayCell(bossesArray, index, INVALID_HANDLE);
}
if(GetArrayCell(bossesArrayShadow, index)!=INVALID_HANDLE)
{
CloseHandle(GetArrayCell(bossesArrayShadow, index));
SetArrayCell(bossesArrayShadow, index, INVALID_HANDLE);
}
}
}
public OnMapEnd()
{
if(Enabled || Enabled2)
{
DisableFF2(); //This resets all the variables for safety
}
}
public OnPluginEnd()
{
OnMapEnd();
}
public EnableFF2()
{
Enabled=true;
Enabled2=true;
new String:config[PLATFORM_MAX_PATH];
BuildPath(Path_SM, config, sizeof(config), "%s/%s", FF2_SETTINGS, WEAPONS_CONFIG);
if(kvWeaponMods!=INVALID_HANDLE)
{
CloseHandle(kvWeaponMods);
}
kvWeaponMods=CreateKeyValues("FF2Weapons");
if(!FileToKeyValues(kvWeaponMods, config))
{
LogError("[FF2 Configs] Failed to load weapon configuration file!");
Enabled=false;
Enabled2=false;
return;
}
ParseChangelog();
//Cache cvars
SetConVarString(FindConVar("ff2_version"), PLUGIN_VERSION);
Announce=GetConVarFloat(cvarAnnounce);
PointType=GetConVarInt(cvarPointType);
PointDelay=GetConVarInt(cvarPointDelay);
AliveToEnable=GetConVarInt(cvarAliveToEnable);
BossCrits=GetConVarBool(cvarCrits);
arenaRounds=GetConVarInt(cvarArenaRounds);
circuitStun=GetConVarFloat(cvarCircuitStun);
countdownHealth=GetConVarInt(cvarCountdownHealth);
countdownPlayers=GetConVarInt(cvarCountdownPlayers);
countdownTime=GetConVarInt(cvarCountdownTime);
lastPlayerGlow=GetConVarBool(cvarLastPlayerGlow);
bossTeleportation=GetConVarBool(cvarBossTeleporter);
shieldCrits=GetConVarInt(cvarShieldCrits);
allowedDetonations=GetConVarInt(cvarCaberDetonations);
//Set some Valve cvars to what we want them to be
SetConVarInt(FindConVar("tf_arena_use_queue"), 0);
SetConVarInt(FindConVar("mp_teams_unbalance_limit"), 0);
SetConVarInt(FindConVar("tf_arena_first_blood"), 0);
SetConVarInt(FindConVar("mp_forcecamera"), 0);
SetConVarInt(FindConVar("tf_dropped_weapon_lifetime"), 0);
SetConVarFloat(FindConVar("tf_feign_death_activate_damage_scale"), 0.3);
SetConVarFloat(FindConVar("tf_feign_death_damage_scale"), 0.0);
SetConVarString(FindConVar("mp_humans_must_join_team"), "any");
new Float:time=Announce;
if(time>1.0)
{
CreateTimer(time, Timer_Announce, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}
CheckToChangeMapDoors();
MapHasMusic(true);
FindCharacters();
strcopy(FF2CharSetString, 2, "");
bMedieval=FindEntityByClassname(-1, "tf_logic_medieval")!=-1 || bool:GetConVarInt(FindConVar("tf_medieval"));
FindHealthBar();
#if defined _steamtools_included
if(steamtools)
{
decl String:gameDesc[64];
Format(gameDesc, sizeof(gameDesc), "Freak Fortress 2 (%s)", PLUGIN_VERSION);
Steam_SetGameDescription(gameDesc);
}
#endif
changeGamemode=0;
}
public DisableFF2()
{
Enabled=false;
Enabled2=false;
SetConVarInt(FindConVar("tf_arena_use_queue"), tf_arena_use_queue);
SetConVarInt(FindConVar("mp_teams_unbalance_limit"), mp_teams_unbalance_limit);
SetConVarInt(FindConVar("tf_arena_first_blood"), tf_arena_first_blood);
SetConVarInt(FindConVar("mp_forcecamera"), mp_forcecamera);
SetConVarInt(FindConVar("tf_dropped_weapon_lifetime"), tf_dropped_weapon_lifetime);
SetConVarFloat(FindConVar("tf_feign_death_activate_damage_scale"), tf_feign_death_activate_damage_scale);
SetConVarFloat(FindConVar("tf_feign_death_damage_scale"), tf_feign_death_damage_scale);
SetConVarString(FindConVar("mp_humans_must_join_team"), mp_humans_must_join_team);
if(doorCheckTimer!=INVALID_HANDLE)
{
KillTimer(doorCheckTimer);
doorCheckTimer=INVALID_HANDLE;
}
for(new client=1; client<=MaxClients; client++)
{
if(IsValidClient(client))
{
if(BossInfoTimer[client][1]!=INVALID_HANDLE)
{
KillTimer(BossInfoTimer[client][1]);
BossInfoTimer[client][1]=INVALID_HANDLE;
}
}
if(MusicTimer[client]!=INVALID_HANDLE)
{
KillTimer(MusicTimer[client]);
MusicTimer[client]=INVALID_HANDLE;
}
bossHasReloadAbility[client]=false;
bossHasRightMouseAbility[client]=false;
}
#if defined _steamtools_included
if(steamtools)
{
Steam_SetGameDescription("Team Fortress");
}
#endif
changeGamemode=0;
}
public FindCharacters()
{
chancesArray=CreateArray();
decl String:config[PLATFORM_MAX_PATH], String:charset[42];
BuildPath(Path_SM, config, sizeof(config), "%s/%s", FF2_SETTINGS, BOSS_CONFIG);
if(!FileExists(config))
{
LogError("[FF2 Bosses] Disabling Freak Fortress 2 - can not find %s!", config);
Enabled2=false;
return;
}
new Handle:kv=CreateKeyValues("");
FileToKeyValues(kv, config);
new Action:action;
Call_StartForward(OnLoadCharacterSet);
strcopy(charset, sizeof(charset), FF2CharSetString);
Call_PushStringEx(charset, sizeof(charset), SM_PARAM_STRING_UTF8 | SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK);
Call_Finish(action);
if(action==Plugin_Changed)
{
if(strlen(charset))
{
new i;
KvRewind(kv);
while(KvGotoNextKey(kv))
{
KvGetSectionName(kv, config, sizeof(config));
if(StrEqual(config, charset))
{
FF2CharSet=i;
strcopy(FF2CharSetString, sizeof(FF2CharSetString), charset);
break;
}
i++;
}
}
}
KvRewind(kv);
KvJumpToKey(kv, FF2CharSetString); // This *should* always return true
if(KvGotoFirstSubKey(kv, false))
{
new index;
do
{
KvGetSectionName(kv, config, sizeof(config));
int chance=KvGetNum(kv, NULL_STRING, -1);
if(chance<0)
{
LogError("[FF2 Bosses] Character %s has an invalid chance - assuming 0", config);
}
for(new j; j<chance; j++)
{
PushArrayCell(chancesArray, index);
}
if(chance>0)
{
LoadCharacter(config);
}
index++;
}
while(KvGotoNextKey(kv, false));
}
else
{
LogError("[FF2 Bosses] Disabling Freak Fortress 2 - no bosses in character set %s!", FF2CharSetString);
Enabled2=false;
return;
}
CloseHandle(kv);
if(FileExists("sound/saxton_hale/9000.wav", true))
{
AddFileToDownloadsTable("sound/saxton_hale/9000.wav");
PrecacheSound("saxton_hale/9000.wav", true);
}
PrecacheSound("vo/announcer_am_capincite01.mp3", true);
PrecacheSound("vo/announcer_am_capincite03.mp3", true);
PrecacheSound("vo/announcer_am_capenabled01.mp3", true);
PrecacheSound("vo/announcer_am_capenabled02.mp3", true);
PrecacheSound("vo/announcer_am_capenabled03.mp3", true);
PrecacheSound("vo/announcer_am_capenabled04.mp3", true);
PrecacheSound("weapons/barret_arm_zap.wav", true);
PrecacheSound("vo/announcer_ends_5min.mp3", true);
PrecacheSound("vo/announcer_ends_2min.mp3", true);
PrecacheSound("player/doubledonk.wav", true);
isCharSetSelected=false;
}
stock ParseChangelog()
{
decl String:changelog[PLATFORM_MAX_PATH];
BuildPath(Path_SM, changelog, sizeof(changelog), "%s/%s", FF2_SETTINGS, CHANGELOG);
if(!FileExists(changelog))
{
LogError("[FF2] Changelog %s does not exist!", changelog);
return;
}
new Handle:kv=CreateKeyValues("Changelog");
FileToKeyValues(kv, changelog);
changelogMenu=CreateMenu(Handler_ChangelogMenu);
SetMenuTitle(changelogMenu, "%t", "Changelog");
new i, j;
if(KvGotoFirstSubKey(kv))
{
decl String:version[64], String:text[256], String:temp[70];
do
{
KvGetSectionName(kv, version, sizeof(version));
Format(temp, sizeof(temp), "%i", i);
AddMenuItem(changelogMenu, temp, version, ITEMDRAW_DISABLED);
i++;
if(KvGotoFirstSubKey(kv, false))
{
j=0;
do
{
KvGetString(kv, NULL_STRING, text, sizeof(text));
Format(temp, sizeof(temp), "%s %i", version, j);
AddMenuItem(changelogMenu, temp, text, ITEMDRAW_DISABLED);
j++;
}
while(KvGotoNextKey(kv, false));
KvGoBack(kv);
}
}
while(KvGotoNextKey(kv));
}
else
{
LogError("[FF2] Changelog %s is empty!", changelog);
}
}
public LoadCharacter(const String:characterName[])
{
decl String:config[PLATFORM_MAX_PATH];
BuildPath(Path_SM, config, sizeof(config), "%s/%s.cfg", FF2_CONFIGS, characterName);
if(!FileExists(config))
{
LogError("[FF2 Bosses] Character %s does not exist!", characterName);
return;
}
new Handle:kv=CreateKeyValues("character");
PushArrayCell(bossesArray, kv);
FileToKeyValues(kv, config);
kv=CreateKeyValues("character");
PushArrayCell(bossesArrayShadow, kv);
FileToKeyValues(kv, config);
new version=KvGetNum(kv, "version", 1);
if(version!=StringToInt(MAJOR_REVISION))
{
LogError("[FF2 Bosses] Character %s is only compatible with FF2 v%i!", characterName, version);
return;
}
if(KvJumpToKey(kv, "abilities"))
{
if(KvGotoFirstSubKey(kv))
{
decl String:pluginName[64];
do
{
KvGetSectionName(kv, pluginName, sizeof(pluginName));
if(FindStringInArray(subpluginArray, pluginName)<0)
{
LogError("[FF2 Bosses] Character %s needs plugin %s!", characterName, pluginName);
return;
}
}
while(KvGotoNextKey(kv));
}
}
KvRewind(kv);
decl String:file[PLATFORM_MAX_PATH], String:section[64];
new String:extensions[][]={".mdl", ".dx80.vtx", ".dx90.vtx", ".sw.vtx", ".vvd"};
KvSetString(kv, "filename", characterName);
KvGetString(kv, "name", config, sizeof(config));
PushArrayCell(voicesArray, KvGetNum(kv, "block voice", 0));
KvGotoFirstSubKey(kv);
while(KvGotoNextKey(kv))
{
KvGetSectionName(kv, section, sizeof(section));
if(StrEqual(section, "downloads"))
{
while(KvGotoNextKey(kv))
{
KvGetSectionName(kv, file, sizeof(file));
if(KvGetNum(kv, "model"))
{
for(new extension; extension<sizeof(extensions); extension++)
{
Format(file, sizeof(file), "%s%s", file, extensions[extension]);
if(FileExists(file, true))
{
AddFileToDownloadsTable(file);
}
else
{
LogError("[FF2 Bosses] Character %s is missing file '%s'!", character, file);
}
}
if(KvGetNum(kv, "phy"))
{
Format(file, sizeof(file), "%s.phy", file);
if(FileExists(file, true))
{
AddFileToDownloadsTable(file);
}
else
{
LogError("[FF2 Bosses] Character %s is missing file '%s'!", character, file);
}
}
}
else if(KvGetNum(kv, "material"))
{
Format(file, sizeof(file), "%s.vmt", file);
if(FileExists(file, true))
{
AddFileToDownloadsTable(file);
}
else
{
LogError("[FF2 Bosses] Character %s is missing file '%s'!", character, file);
}
Format(file, sizeof(file), "%s.vtf", file);
if(FileExists(file, true))
{
AddFileToDownloadsTable(file);
}
else
{
LogError("[FF2 Bosses] Character %s is missing file '%s'!", character, file);
}
}
else if(FileExists(file, true))
{
AddFileToDownloadsTable(file);
}
else
{