This repository was archived by the owner on Jul 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbot_respawn.sp
More file actions
6169 lines (5387 loc) · 214 KB
/
bot_respawn.sp
File metadata and controls
6169 lines (5387 loc) · 214 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
/**
* [INS] Player Respawn Script - Player and BOT respawn script for sourcemod plugin.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//#pragma dynamic 32768 // Increase heap size
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <insurgencydy>
#undef REQUIRE_EXTENSIONS
#include <cstrike>
#include <tf2>
#include <tf2_stocks>
#define REQUIRE_EXTENSIONS
#include <navmesh>
//#include <insurgency>
// Define grenade index value
#define Gren_M67 68
#define Gren_Incen 73
#define Gren_Molot 74
#define Gren_M18 70
#define Gren_Flash 71
#define Gren_F1 69
#define Gren_IED 72
#define Gren_C4 72
#define Gren_AT4 67
#define Gren_RPG7 61
//LUA Healing define values
#define Healthkit_Timer_Tickrate 0.5 // Basic Sound has 0.8 loop
#define Healthkit_Timer_Timeout 360.0 //6 minutes
#define Healthkit_Radius 120.0
#define Revive_Indicator_Radius 100.0
#define Healthkit_Remove_Type "1"
#define Healthkit_Healing_Per_Tick_Min 1
#define Healthkit_Healing_Per_Tick_Max 3
//Lua Healing Variables
new g_iBeaconBeam;
new g_iBeaconHalo;
new Float:g_fLastHeight[2048] = {0.0, ...};
new Float:g_fTimeCheck[2048] = {0.0, ...};
new g_iTimeCheckHeight[2048] = {0, ...};
new g_healthPack_Amount[2048] = {0, ...};
//VIP
new g_nVIP_ID = 0;
new g_nVIP_counter = 0;
//Player Gear
new g_iPlayerEquipGear;
//Recon Class
new ReconSelfGearID = 35;
new ReconTeamGearID = 36;
ReconClient1 = 0;
ReconClient2 = 0;
//CounterAttack alter
bool g_bNormalCounterAttack = false;
//Addition bot reaction
/*
new Float:g_fBotAmt;
new g_nBotAmtClose;
*/
// This will be used for checking which team the player is on before repsawning them
#define SPECTATOR_TEAM 0
#define TEAM_SPEC 1
#define TEAM_1 2
#define TEAM_2 3
// Navmesh Init
#define MAX_OBJECTIVES 13
#define MAX_HIDING_SPOTS 4096
#define MIN_PLAYER_DISTANCE 128.0
#define MAX_ENTITIES 2048
// Counter-Attack Music
#define COUNTER_ATTACK_MUSIC_DURATION 68.0
// Handle for revive
new Handle:g_hForceRespawn;
new Handle:g_hGameConfig;
// Player respawn
new
g_iEnableRevive = 0,
g_iRespawnTimeRemaining[MAXPLAYERS+1],
g_iReviveRemainingTime[MAXPLAYERS+1],
g_iReviveNonMedicRemainingTime[MAXPLAYERS+1],
g_iPlayerRespawnTimerActive[MAXPLAYERS+1],
g_iSpawnTokens[MAXPLAYERS+1],
g_iHurtFatal[MAXPLAYERS+1],
g_iClientRagdolls[MAXPLAYERS+1],
g_iNearestBody[MAXPLAYERS+1],
g_botStaticGlobal[MAXPLAYERS+1],
g_resupplyCounter[MAXPLAYERS+1],
g_resupplyDeath[MAXPLAYERS+1],
g_ammoResupplyAmt[MAX_ENTITIES+1],
g_trackKillDeaths[MAXPLAYERS+1],
g_iRespawnCount[4],
g_huntReinforceCacheAdd = 120,
bool:g_huntCacheDestroyed = false,
bool:g_playersReady = false,
bool:g_easterEggRound = false,
bool:g_easterEggFlag = false,
Float:g_removeBotGrenadeChance = 0.5,
Float:g_fPlayerPosition[MAXPLAYERS+1][3],
Float:g_fDeadPosition[MAXPLAYERS+1][3],
Float:g_fRagdollPosition[MAXPLAYERS+1][3],
Float:g_vecOrigin[MAXPLAYERS+1][3],
//g_iPlayerBGroups[MAXPLAYERS+1],
Float:g_spawnFrandom[MAXPLAYERS+1],
Float:g_fRespawnPosition[3];
//Ammo Amounts
new
playerClip[MAXPLAYERS + 1][2], // Track primary and secondary ammo
playerAmmo[MAXPLAYERS + 1][4], // track player ammo based on weapon slot 0 - 4
playerPrimary[MAXPLAYERS + 1],
playerSecondary[MAXPLAYERS + 1];
// playerGrenadeType[MAXPLAYERS + 1][10], //track player grenade types
// playerRole[MAXPLAYERS + 1]; // tracks player role so if it changes while wounded, he dies
// These steam ids remove from having a donor tag on request
//[1] = 1 STRING, [64] = 40 character limit per string
new Handle:g_donorTagRemove_Array;
new Handle:g_playerArrayList;
// Navmesh Init
new
Handle:g_hHidingSpots = INVALID_HANDLE,
g_iHidingSpotCount,
m_iNumControlPoints,
g_iCPHidingSpots[MAX_OBJECTIVES][MAX_HIDING_SPOTS],
g_iCPHidingSpotCount[MAX_OBJECTIVES],
g_iCPLastHidingSpot[MAX_OBJECTIVES],
Float:m_vCPPositions[MAX_OBJECTIVES][3];
// Status
new
g_isMapInit,
g_iRoundStatus = 0, //0 is over, 1 is active
bool:g_bIsCounterAttackTimerActive = false,
g_clientDamageDone[MAXPLAYERS+1],
playerPickSquad[MAXPLAYERS + 1],
bool:playerRevived[MAXPLAYERS + 1],
bool:g_preRoundInitial = false,
String:g_client_last_classstring[MAXPLAYERS+1][64],
String:g_client_org_nickname[MAXPLAYERS+1][64],
Float:g_enemyTimerPos[MAXPLAYERS+1][3], // Kill Stray Enemy Bots Globals
Float:g_enemyTimerAwayPos[MAXPLAYERS+1][3], // Kill Stray Enemy Bots Globals
g_plyrGrenScreamCoolDown[MAXPLAYERS+1],
g_plyrFireScreamCoolDown[MAXPLAYERS+1],
g_playerMedicHealsAccumulated[MAXPLAYERS+1],
g_playerNonMedicHealsAccumulated[MAXPLAYERS+1],
g_playerNonMedicRevive[MAXPLAYERS+1],
g_playerWoundType[MAXPLAYERS+1],
g_playerWoundTime[MAXPLAYERS+1],
g_playerFirstJoin[MAXPLAYERS+1];
// Player Distance Plugin //Credits to author = "Popoklopsi", url = "http://popoklopsi.de"
// unit to use 1 = feet, 0 = meters
new g_iUnitMetric;
// Handle for config
new
Handle:sm_respawn_enabled = INVALID_HANDLE,
Handle:sm_revive_enabled = INVALID_HANDLE,
// Respawn delay time
Handle:sm_respawn_delay_team_ins = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec_player_count_01 = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec_player_count_02 = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec_player_count_03 = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec_player_count_04 = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec_player_count_05 = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec_player_count_06 = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec_player_count_07 = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec_player_count_08 = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec_player_count_09 = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec_player_count_10 = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec_player_count_11 = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec_player_count_12 = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec_player_count_13 = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec_player_count_14 = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec_player_count_15 = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec_player_count_16 = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec_player_count_17 = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec_player_count_18 = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec_player_count_19 = INVALID_HANDLE,
Handle:sm_respawn_delay_team_sec_player_count_20 = INVALID_HANDLE,
// Respawn type
Handle:sm_respawn_type_team_ins = INVALID_HANDLE,
Handle:sm_respawn_type_team_sec = INVALID_HANDLE,
// Respawn lives
Handle:sm_respawn_lives_team_sec = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins_player_count_01 = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins_player_count_02 = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins_player_count_03 = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins_player_count_04 = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins_player_count_05 = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins_player_count_06 = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins_player_count_07 = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins_player_count_08 = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins_player_count_09 = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins_player_count_10 = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins_player_count_11 = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins_player_count_12 = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins_player_count_13 = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins_player_count_14 = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins_player_count_15 = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins_player_count_16 = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins_player_count_17 = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins_player_count_18 = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins_player_count_19 = INVALID_HANDLE,
Handle:sm_respawn_lives_team_ins_player_count_20 = INVALID_HANDLE,
// Fatal dead
Handle:sm_respawn_fatal_chance = INVALID_HANDLE,
Handle:sm_respawn_fatal_head_chance = INVALID_HANDLE,
Handle:sm_respawn_fatal_limb_dmg = INVALID_HANDLE,
Handle:sm_respawn_fatal_head_dmg = INVALID_HANDLE,
Handle:sm_respawn_fatal_burn_dmg = INVALID_HANDLE,
Handle:sm_respawn_fatal_explosive_dmg = INVALID_HANDLE,
Handle:sm_respawn_fatal_chest_stomach = INVALID_HANDLE,
// Counter-attack
Handle:sm_respawn_counterattack_type = INVALID_HANDLE,
Handle:sm_respawn_counterattack_vanilla = INVALID_HANDLE,
Handle:sm_respawn_final_counterattack_type = INVALID_HANDLE,
Handle:sm_respawn_security_on_counter = INVALID_HANDLE,
Handle:sm_respawn_counter_chance = INVALID_HANDLE,
Handle:sm_respawn_min_counter_dur_sec = INVALID_HANDLE,
Handle:sm_respawn_max_counter_dur_sec = INVALID_HANDLE,
Handle:sm_respawn_final_counter_dur_sec = INVALID_HANDLE,
//Dynamic Respawn Mechanics
Handle:sm_respawn_dynamic_distance_multiplier = INVALID_HANDLE,
Handle:sm_respawn_dynamic_spawn_counter_percent = INVALID_HANDLE,
Handle:sm_respawn_dynamic_spawn_percent = INVALID_HANDLE,
// Misc
Handle:sm_respawn_reset_type = INVALID_HANDLE,
Handle:sm_respawn_enable_track_ammo = INVALID_HANDLE,
// Reinforcements
Handle:sm_respawn_reinforce_time = INVALID_HANDLE,
Handle:sm_respawn_reinforce_time_subsequent = INVALID_HANDLE,
Handle:sm_respawn_reinforce_multiplier = INVALID_HANDLE,
Handle:sm_respawn_reinforce_multiplier_base = INVALID_HANDLE,
// Monitor static enemy
Handle:sm_respawn_check_static_enemy = INVALID_HANDLE,
Handle:sm_respawn_check_static_enemy_counter = INVALID_HANDLE,
// Donor tag
Handle:sm_respawn_enable_donor_tag = INVALID_HANDLE,
// Related to 'RoundEnd_Protector' plugin
Handle:sm_remaininglife = INVALID_HANDLE,
// Medic specific
Handle:sm_revive_seconds = INVALID_HANDLE,
Handle:sm_revive_bonus = INVALID_HANDLE,
Handle:sm_revive_distance_metric = INVALID_HANDLE,
Handle:sm_heal_bonus = INVALID_HANDLE,
Handle:sm_heal_cap_for_bonus = INVALID_HANDLE,
Handle:sm_heal_amount_medpack = INVALID_HANDLE,
Handle:sm_heal_amount_paddles = INVALID_HANDLE,
Handle:sm_non_medic_heal_amt = INVALID_HANDLE,
Handle:sm_non_medic_revive_hp = INVALID_HANDLE,
Handle:sm_medic_minor_revive_hp = INVALID_HANDLE,
Handle:sm_medic_moderate_revive_hp = INVALID_HANDLE,
Handle:sm_medic_critical_revive_hp = INVALID_HANDLE,
Handle:sm_minor_wound_dmg = INVALID_HANDLE,
Handle:sm_moderate_wound_dmg = INVALID_HANDLE,
Handle:sm_medic_heal_self_max = INVALID_HANDLE,
Handle:sm_non_medic_max_heal_other = INVALID_HANDLE,
Handle:sm_minor_revive_time = INVALID_HANDLE,
Handle:sm_moderate_revive_time = INVALID_HANDLE,
Handle:sm_critical_revive_time = INVALID_HANDLE,
Handle:sm_non_medic_revive_time = INVALID_HANDLE,
Handle:sm_medpack_health_amount = INVALID_HANDLE,
Handle:sm_multi_loadout_enabled = INVALID_HANDLE,
Handle:sm_bombers_only = INVALID_HANDLE,
Handle:sm_non_medic_heal_self_max = INVALID_HANDLE,
// NAV MESH SPECIFIC CVARS
Handle:cvarSpawnMode = INVALID_HANDLE, //1 = Spawn in ins_spawnpoints, 2 = any spawnpoints that meets criteria, 0 = only at normal spawnpoints at next objective
Handle:cvarMinCounterattackDistance = INVALID_HANDLE, //Min distance from counterattack objective to spawn
Handle:cvarMinPlayerDistance = INVALID_HANDLE, //Min/max distance from players to spawn
Handle:cvarSpawnAttackDelay = INVALID_HANDLE, //Attack delay for spawning bots
Handle:cvarMinObjectiveDistance = INVALID_HANDLE, //Min/max distance from next objective to spawn
Handle:cvarMaxObjectiveDistance = INVALID_HANDLE, //Min/max distance from next objective to spawn
Handle:cvarMaxObjectiveDistanceNav = INVALID_HANDLE, //Min/max distance from next objective to spawn using nav
Handle:cvarCanSeeVectorMultiplier = INVALID_HANDLE, //CanSeeVector Multiplier divide this by cvarMaxPlayerDistance
Handle:sm_ammo_resupply_range = INVALID_HANDLE, //Range of ammo resupply
Handle:sm_resupply_delay = INVALID_HANDLE, //Delay to resupply
Handle:sm_jammer_required = INVALID_HANDLE, //Jammer required for intel messages?
Handle:cvarMaxPlayerDistance = INVALID_HANDLE; //Min/max distance from players to spawn
// Init global variables
new
g_iCvar_respawn_enable,
g_jammerRequired,
g_iCvar_revive_enable,
Float:g_respawn_counter_chance,
g_counterAttack_min_dur_sec,
g_counterAttack_max_dur_sec,
g_iCvar_respawn_type_team_ins,
g_iCvar_respawn_type_team_sec,
g_iCvar_respawn_reset_type,
Float:g_fCvar_respawn_delay_team_ins,
g_iCvar_enable_track_ammo,
g_iCvar_counterattack_type,
g_iCvar_counterattack_vanilla,
g_iCvar_final_counterattack_type,
g_iCvar_SpawnMode,
//Dynamic Respawn cvars
g_DynamicRespawn_Distance_mult,
Float:g_dynamicSpawnCounter_Perc,
g_dynamicSpawn_Perc,
// Fatal dead
Float:g_fCvar_fatal_chance,
Float:g_fCvar_fatal_head_chance,
g_iCvar_fatal_limb_dmg,
g_iCvar_fatal_head_dmg,
g_iCvar_fatal_burn_dmg,
g_iCvar_fatal_explosive_dmg,
g_iCvar_fatal_chest_stomach,
//Dynamic Loadouts
g_iCvar_bombers_only,
g_iCvar_multi_loadout_enabled,
g_checkStaticAmt,
g_checkStaticAmtCntr,
g_checkStaticAmtAway,
g_checkStaticAmtCntrAway,
g_iReinforceTime,
g_iRemaining_lives_team_sec,
g_iRemaining_lives_team_ins,
g_iRespawn_lives_team_sec,
g_iRespawn_lives_team_ins,
g_iReviveSeconds,
g_iRespawnSeconds,
g_iHeal_amount_paddles,
g_iHeal_amount_medPack,
g_nonMedicHeal_amount,
g_nonMedicRevive_hp,
g_minorWoundRevive_hp,
g_modWoundRevive_hp,
g_critWoundRevive_hp,
g_minorWound_dmg,
g_moderateWound_dmg,
g_medicHealSelf_max,
g_nonMedicHealSelf_max,
g_nonMedic_maxHealOther,
g_minorRevive_time,
g_modRevive_time,
g_critRevive_time,
g_nonMedRevive_time,
g_medpack_health_amt,
g_botsReady,
g_isConquer,
g_isOutpost,
g_isCheckpoint,
g_isHunt,
Float:g_flMinPlayerDistance,
Float:g_flMaxPlayerDistance,
Float:g_flCanSeeVectorMultiplier,
Float:g_flMinObjectiveDistance,
Float:g_flMaxObjectiveDistance,
Float:g_flMaxObjectiveDistanceNav,
Float:g_flSpawnAttackDelay,
Float:g_flMinCounterattackDistance,
// Insurgency implements
g_iObjResEntity, String:g_iObjResEntityNetClass[32],
g_iLogicEntity, String:g_iLogicEntityNetClass[32];
enum SpawnModes
{
SpawnMode_Normal = 0,
SpawnMode_HidingSpots,
SpawnMode_SpawnPoints,
};
new m_hMyWeapons, m_flNextPrimaryAttack, m_flNextSecondaryAttack;
/////////////////////////////////////
// Rank System (Based on graczu's Simple CS:S Rank - https://forums.alliedmods.net/showthread.php?p=523601)
//
/*
MySQL Query:
CREATE TABLE `ins_rank`(
`rank_id` int(64) NOT NULL auto_increment,
`steamId` varchar(32) NOT NULL default '',
`nick` varchar(128) NOT NULL default '',
`score` int(12) NOT NULL default '0',
`kills` int(12) NOT NULL default '0',
`deaths` int(12) NOT NULL default '0',
`headshots` int(12) NOT NULL default '0',
`sucsides` int(12) NOT NULL default '0',
`revives` int(12) NOT NULL default '0',
`heals` int(12) NOT NULL default '0',
`last_active` int(12) NOT NULL default '0',
`played_time` int(12) NOT NULL default '0',
PRIMARY KEY (`rank_id`)) ENGINE=INNODB DEFAULT CHARSET=utf8;
database.cfg
"insrank"
{
"driver" "default"
"host" "127.0.0.1"
"database" "database_name"
"user" "database_user"
"pass" "PASSWORD"
//"timeout" "0"
"port" "3306"
}
*/
// KOLOROWE KREDKI
#define YELLOW 0x01
#define GREEN 0x04
// SOME DEFINES
#define MAX_LINE_WIDTH 60
// STATS TIME (SET DAYS AFTER STATS ARE DELETE OF NONACTIVE PLAYERS)
#define PLAYER_STATSOLD 30
// STATS DEFINATION FOR PLAYERS
new g_iStatScore[MAXPLAYERS+1];
new g_iStatKills[MAXPLAYERS+1];
new g_iStatDeaths[MAXPLAYERS+1];
new g_iStatHeadShots[MAXPLAYERS+1];
new g_iStatSuicides[MAXPLAYERS+1];
new g_iStatRevives[MAXPLAYERS+1];
new g_iStatHeals[MAXPLAYERS+1];
new g_iUserInit[MAXPLAYERS+1];
new g_iUserFlood[MAXPLAYERS+1];
new g_iUserPtime[MAXPLAYERS+1];
new String:g_sSteamIdSave[MAXPLAYERS+1][255];
new g_iRank[MAXPLAYERS+1];
// HANDLE OF DATABASE
new Handle:g_hDB;
//
/////////////////////////////////////
#define PLUGIN_VERSION "1.0.5"
#define PLUGIN_DESCRIPTION "Respawn dead players via admincommand or by queues"
// Plugin info
public Plugin:myinfo =
{
name = "[INS] Bot and Player Respawn",
author = "Neko- (Jared Ballou (Contributor: Daimyo, naong))",
version = PLUGIN_VERSION,
description = PLUGIN_DESCRIPTION,
};
// Start plugin
public OnPluginStart()
{
//Circleus stuff
//Find player gear offset
g_iPlayerEquipGear = FindSendPropInfo("CINSPlayer", "m_EquippedGear");
RegAdminCmd("recon", ReconInfo, ADMFLAG_KICK, "Show recon info to admin only");
HookEvent("player_team", OnPlayerTeam);
//Create player array list
g_playerArrayList = CreateArray(64);
//RegConsoleCmd("kill", cmd_kill);
CreateConVar("sm_respawn_version", PLUGIN_VERSION, PLUGIN_DESCRIPTION, FCVAR_NOTIFY | FCVAR_DONTRECORD);
sm_respawn_enabled = CreateConVar("sm_respawn_enabled", "1", "Automatically respawn players when they die; 0 - disabled, 1 - enabled");
sm_revive_enabled = CreateConVar("sm_revive_enabled", "0", "Reviving enabled from medics? This creates revivable ragdoll after death; 0 - disabled, 1 - enabled");
// Nav Mesh Botspawn specific START
cvarSpawnMode = CreateConVar("sm_botspawns_spawn_mode", "1", "Only normal spawnpoints at the objective, the old way (0), spawn in hiding spots following rules (1)", FCVAR_NOTIFY);
cvarMinCounterattackDistance = CreateConVar("sm_botspawns_min_counterattack_distance", "1600.0", "Min distance from counterattack objective to spawn", FCVAR_NOTIFY);
cvarMinPlayerDistance = CreateConVar("sm_botspawns_min_player_distance", "500.0", "Min distance from players to spawn", FCVAR_NOTIFY);
cvarMaxPlayerDistance = CreateConVar("sm_botspawns_max_player_distance", "4000.0", "Max distance from players to spawn", FCVAR_NOTIFY);
cvarCanSeeVectorMultiplier = CreateConVar("sm_botpawns_can_see_vect_mult", "1.5", "Divide this with sm_botspawns_max_player_distance to get CanSeeVector allowed distance for bot spawning in LOS", FCVAR_NOTIFY);
cvarMinObjectiveDistance = CreateConVar("sm_botspawns_min_objective_distance", "1", "Min distance from next objective to spawn", FCVAR_NOTIFY);
cvarMaxObjectiveDistance = CreateConVar("sm_botspawns_max_objective_distance", "240", "Max distance from next objective to spawn", FCVAR_NOTIFY);
cvarMaxObjectiveDistanceNav = CreateConVar("sm_botspawns_max_objective_distance_nav", "2500", "Max distance from next objective to spawn", FCVAR_NOTIFY);
cvarSpawnAttackDelay = CreateConVar("sm_botspawns_spawn_attack_delay", "0", "Delay in seconds for spawning bots to wait before firing.", FCVAR_NOTIFY);
// Nav Mesh Botspawn specific END
//Total bot count
RegConsoleCmd("totalb", Check_Total_Enemies, "Show the total alive enemies");
// Respawn delay time
sm_respawn_delay_team_ins = CreateConVar("sm_respawn_delay_team_ins",
"1.0", "How many seconds to delay the respawn (bots)");
sm_respawn_delay_team_sec = CreateConVar("sm_respawn_delay_team_sec",
"30.0", "How many seconds to delay the respawn (If not set 'sm_respawn_delay_team_sec_player_count_XX' uses this value)");
sm_respawn_delay_team_sec_player_count_01 = CreateConVar("sm_respawn_delay_team_sec_player_count_01",
"5.0", "How many seconds to delay the respawn (when player count is 1)");
sm_respawn_delay_team_sec_player_count_02 = CreateConVar("sm_respawn_delay_team_sec_player_count_02",
"10.0", "How many seconds to delay the respawn (when player count is 2)");
sm_respawn_delay_team_sec_player_count_03 = CreateConVar("sm_respawn_delay_team_sec_player_count_03",
"20.0", "How many seconds to delay the respawn (when player count is 3)");
sm_respawn_delay_team_sec_player_count_04 = CreateConVar("sm_respawn_delay_team_sec_player_count_04",
"30.0", "How many seconds to delay the respawn (when player count is 4)");
sm_respawn_delay_team_sec_player_count_05 = CreateConVar("sm_respawn_delay_team_sec_player_count_05",
"60.0", "How many seconds to delay the respawn (when player count is 5)");
sm_respawn_delay_team_sec_player_count_06 = CreateConVar("sm_respawn_delay_team_sec_player_count_06",
"60.0", "How many seconds to delay the respawn (when player count is 6)");
sm_respawn_delay_team_sec_player_count_07 = CreateConVar("sm_respawn_delay_team_sec_player_count_07",
"70.0", "How many seconds to delay the respawn (when player count is 7)");
sm_respawn_delay_team_sec_player_count_08 = CreateConVar("sm_respawn_delay_team_sec_player_count_08",
"70.0", "How many seconds to delay the respawn (when player count is 8)");
sm_respawn_delay_team_sec_player_count_09 = CreateConVar("sm_respawn_delay_team_sec_player_count_09",
"80.0", "How many seconds to delay the respawn (when player count is 9)");
sm_respawn_delay_team_sec_player_count_10 = CreateConVar("sm_respawn_delay_team_sec_player_count_10",
"80.0", "How many seconds to delay the respawn (when player count is 10)");
sm_respawn_delay_team_sec_player_count_11 = CreateConVar("sm_respawn_delay_team_sec_player_count_11",
"90.0", "How many seconds to delay the respawn (when player count is 11)");
sm_respawn_delay_team_sec_player_count_12 = CreateConVar("sm_respawn_delay_team_sec_player_count_12",
"90.0", "How many seconds to delay the respawn (when player count is 12)");
sm_respawn_delay_team_sec_player_count_13 = CreateConVar("sm_respawn_delay_team_sec_player_count_13",
"100.0", "How many seconds to delay the respawn (when player count is 13)");
sm_respawn_delay_team_sec_player_count_14 = CreateConVar("sm_respawn_delay_team_sec_player_count_14",
"100.0", "How many seconds to delay the respawn (when player count is 14)");
sm_respawn_delay_team_sec_player_count_15 = CreateConVar("sm_respawn_delay_team_sec_player_count_15",
"110.0", "How many seconds to delay the respawn (when player count is 15)");
sm_respawn_delay_team_sec_player_count_16 = CreateConVar("sm_respawn_delay_team_sec_player_count_16",
"110.0", "How many seconds to delay the respawn (when player count is 16)");
sm_respawn_delay_team_sec_player_count_17 = CreateConVar("sm_respawn_delay_team_sec_player_count_17",
"120.0", "How many seconds to delay the respawn (when player count is 17)");
sm_respawn_delay_team_sec_player_count_18 = CreateConVar("sm_respawn_delay_team_sec_player_count_18",
"120.0", "How many seconds to delay the respawn (when player count is 18)");
sm_respawn_delay_team_sec_player_count_19 = CreateConVar("sm_respawn_delay_team_sec_player_count_19",
"120.0", "How many seconds to delay the respawn (when player count is 18)");
sm_respawn_delay_team_sec_player_count_20 = CreateConVar("sm_respawn_delay_team_sec_player_count_20",
"120.0", "How many seconds to delay the respawn (when player count is 18)");
// Respawn type
sm_respawn_type_team_sec = CreateConVar("sm_respawn_type_team_sec",
"1", "1 - individual lives, 2 - each team gets a pool of lives used by everyone, sm_respawn_lives_team_sec must be > 0");
sm_respawn_type_team_ins = CreateConVar("sm_respawn_type_team_ins",
"2", "1 - individual lives, 2 - each team gets a pool of lives used by everyone, sm_respawn_lives_team_ins must be > 0");
// Respawn lives
sm_respawn_lives_team_sec = CreateConVar("sm_respawn_lives_team_sec",
"-1", "Respawn players this many times (-1: Disables player respawn)");
sm_respawn_lives_team_ins = CreateConVar("sm_respawn_lives_team_ins",
"10", "If 'sm_respawn_type_team_ins' set 1, respawn bots this many times. If 'sm_respawn_type_team_ins' set 2, total bot count (If not set 'sm_respawn_lives_team_ins_player_count_XX' uses this value)");
sm_respawn_lives_team_ins_player_count_01 = CreateConVar("sm_respawn_lives_team_ins_player_count_01",
"5", "Total bot count (when player count is 1)(sm_respawn_type_team_ins must be 2)");
sm_respawn_lives_team_ins_player_count_02 = CreateConVar("sm_respawn_lives_team_ins_player_count_02",
"10", "Total bot count (when player count is 2)(sm_respawn_type_team_ins must be 2)");
sm_respawn_lives_team_ins_player_count_03 = CreateConVar("sm_respawn_lives_team_ins_player_count_03",
"15", "Total bot count (when player count is 3)(sm_respawn_type_team_ins must be 2)");
sm_respawn_lives_team_ins_player_count_04 = CreateConVar("sm_respawn_lives_team_ins_player_count_04",
"20", "Total bot count (when player count is 4)(sm_respawn_type_team_ins must be 2)");
sm_respawn_lives_team_ins_player_count_05 = CreateConVar("sm_respawn_lives_team_ins_player_count_05",
"25", "Total bot count (when player count is 5)(sm_respawn_type_team_ins must be 2)");
sm_respawn_lives_team_ins_player_count_06 = CreateConVar("sm_respawn_lives_team_ins_player_count_06",
"30", "Total bot count (when player count is 6)(sm_respawn_type_team_ins must be 2)");
sm_respawn_lives_team_ins_player_count_07 = CreateConVar("sm_respawn_lives_team_ins_player_count_07",
"35", "Total bot count (when player count is 7)(sm_respawn_type_team_ins must be 2)");
sm_respawn_lives_team_ins_player_count_08 = CreateConVar("sm_respawn_lives_team_ins_player_count_08",
"40", "Total bot count (when player count is 8)(sm_respawn_type_team_ins must be 2)");
sm_respawn_lives_team_ins_player_count_09 = CreateConVar("sm_respawn_lives_team_ins_player_count_09",
"45", "Total bot count (when player count is 9)(sm_respawn_type_team_ins must be 2)");
sm_respawn_lives_team_ins_player_count_10 = CreateConVar("sm_respawn_lives_team_ins_player_count_10",
"50", "Total bot count (when player count is 10)(sm_respawn_type_team_ins must be 2)");
sm_respawn_lives_team_ins_player_count_11 = CreateConVar("sm_respawn_lives_team_ins_player_count_11",
"55", "Total bot count (when player count is 11)(sm_respawn_type_team_ins must be 2)");
sm_respawn_lives_team_ins_player_count_12 = CreateConVar("sm_respawn_lives_team_ins_player_count_12",
"60", "Total bot count (when player count is 12)(sm_respawn_type_team_ins must be 2)");
sm_respawn_lives_team_ins_player_count_13 = CreateConVar("sm_respawn_lives_team_ins_player_count_13",
"65", "Total bot count (when player count is 13)(sm_respawn_type_team_ins must be 2)");
sm_respawn_lives_team_ins_player_count_14 = CreateConVar("sm_respawn_lives_team_ins_player_count_14",
"70", "Total bot count (when player count is 14)(sm_respawn_type_team_ins must be 2)");
sm_respawn_lives_team_ins_player_count_15 = CreateConVar("sm_respawn_lives_team_ins_player_count_15",
"75", "Total bot count (when player count is 15)(sm_respawn_type_team_ins must be 2)");
sm_respawn_lives_team_ins_player_count_16 = CreateConVar("sm_respawn_lives_team_ins_player_count_16",
"80", "Total bot count (when player count is 16)(sm_respawn_type_team_ins must be 2)");
sm_respawn_lives_team_ins_player_count_17 = CreateConVar("sm_respawn_lives_team_ins_player_count_17",
"85", "Total bot count (when player count is 17)(sm_respawn_type_team_ins must be 2)");
sm_respawn_lives_team_ins_player_count_18 = CreateConVar("sm_respawn_lives_team_ins_player_count_18",
"90", "Total bot count (when player count is 18)(sm_respawn_type_team_ins must be 2)");
sm_respawn_lives_team_ins_player_count_19 = CreateConVar("sm_respawn_lives_team_ins_player_count_19",
"90", "Total bot count (when player count is 18)(sm_respawn_type_team_ins must be 2)");
sm_respawn_lives_team_ins_player_count_20 = CreateConVar("sm_respawn_lives_team_ins_player_count_20",
"90", "Total bot count (when player count is 18)(sm_respawn_type_team_ins must be 2)");
// Fatally death
sm_respawn_fatal_chance = CreateConVar("sm_respawn_fatal_chance", "0.0", "Chance for a kill to be fatal, 0.6 default = 60% chance to be fatal (To disable set 0.0)");
sm_respawn_fatal_head_chance = CreateConVar("sm_respawn_fatal_head_chance", "1.0", "Chance for a headshot kill to be fatal, 0.6 default = 60% chance to be fatal");
sm_respawn_fatal_limb_dmg = CreateConVar("sm_respawn_fatal_limb_dmg", "100", "Amount of damage to fatally kill player in limb");
sm_respawn_fatal_head_dmg = CreateConVar("sm_respawn_fatal_head_dmg", "100", "Amount of damage to fatally kill player in head");
sm_respawn_fatal_burn_dmg = CreateConVar("sm_respawn_fatal_burn_dmg", "100", "Amount of damage to fatally kill player in burn");
sm_respawn_fatal_explosive_dmg = CreateConVar("sm_respawn_fatal_explosive_dmg", "200", "Amount of damage to fatally kill player in explosive");
sm_respawn_fatal_chest_stomach = CreateConVar("sm_respawn_fatal_chest_stomach", "100", "Amount of damage to fatally kill player in chest/stomach");
// Counter attack
sm_respawn_counter_chance = CreateConVar("sm_respawn_counter_chance", "0.5", "Percent chance that a counter attack will happen def: 50%");
sm_respawn_counterattack_type = CreateConVar("sm_respawn_counterattack_type", "1", "Respawn during counterattack? (0: no, 1: yes, 2: infinite)");
sm_respawn_final_counterattack_type = CreateConVar("sm_respawn_final_counterattack_type", "2", "Respawn during final counterattack? (0: no, 1: yes, 2: infinite)");
sm_respawn_security_on_counter = CreateConVar("sm_respawn_security_on_counter", "0", "0/1 When a counter attack starts, spawn all dead players and teleport them to point to defend");
sm_respawn_min_counter_dur_sec = CreateConVar("sm_respawn_min_counter_dur_sec", "60", "Minimum randomized counter attack duration");
sm_respawn_max_counter_dur_sec = CreateConVar("sm_respawn_max_counter_dur_sec", "120", "Maximum randomized counter attack duration");
sm_respawn_final_counter_dur_sec = CreateConVar("sm_respawn_final_counter_dur_sec", "180", "Final counter attack duration");
sm_respawn_counterattack_vanilla = CreateConVar("sm_respawn_counterattack_vanilla", "0", "Use vanilla counter attack mechanics? (0: no, 1: yes)");
//Dynamic respawn mechanics
sm_respawn_dynamic_distance_multiplier = CreateConVar("sm_respawn_dynamic_distance_multiplier", "2", "This multiplier is used to make bot distance from points on/off counter attacks more dynamic by making distance closer/farther when bots respawn");
sm_respawn_dynamic_spawn_counter_percent = CreateConVar("sm_respawn_dynamic_spawn_counter_percent", "0.4", "Percent of bots that will spawn farther away on a counter attack (basically their more ideal normal spawns)");
sm_respawn_dynamic_spawn_percent = CreateConVar("sm_respawn_dynamic_spawn_percent", "0.5", "Percent of bots that will spawn farther away NOT on a counter (basically their more ideal normal spawns)");
// Misc
sm_respawn_reset_type = CreateConVar("sm_respawn_reset_type", "0", "Set type of resetting player respawn counts: each round or each objective (0: each round, 1: each objective)");
sm_respawn_enable_track_ammo = CreateConVar("sm_respawn_enable_track_ammo", "0", "0/1 Track ammo on death to revive (may be buggy if using a different theatre that modifies ammo)");
// Reinforcements
sm_respawn_reinforce_time = CreateConVar("sm_respawn_reinforce_time", "900", "When enemy forces are low on lives, how much time til they get reinforcements?");
sm_respawn_reinforce_time_subsequent = CreateConVar("sm_respawn_reinforce_time_subsequent", "140", "When enemy forces are low on lives and already reinforced, how much time til they get reinforcements on subsequent reinforcement?");
sm_respawn_reinforce_multiplier = CreateConVar("sm_reinforce_multiplier", "4", "Division multiplier to determine when to start reinforce timer for bots based on team pool lives left over");
sm_respawn_reinforce_multiplier_base = CreateConVar("sm_respawn_reinforce_multiplier_base", "10", "This is the base int number added to the division multiplier, so (10 * reinforce_mult + base_mult)");
// Control static enemy
sm_respawn_check_static_enemy = CreateConVar("sm_respawn_check_static_enemy", "120", "Seconds amount to check if an AI has moved probably stuck");
sm_respawn_check_static_enemy_counter = CreateConVar("sm_respawn_check_static_enemy_counter", "10", "Seconds amount to check if an AI has moved during counter");
// Donor tag
sm_respawn_enable_donor_tag = CreateConVar("sm_respawn_enable_donor_tag", "0", "If player has an access to reserved slot, add [DONOR] tag.");
// Related to 'RoundEnd_Protector' plugin
sm_remaininglife = CreateConVar("sm_remaininglife", "-1", "Returns total remaining life.");
// Medic Revive
sm_revive_seconds = CreateConVar("sm_revive_seconds", "5", "Time in seconds medic needs to stand over body to revive");
sm_revive_bonus = CreateConVar("sm_revive_bonus", "1", "Bonus revive score(kill count) for medic");
sm_revive_distance_metric = CreateConVar("sm_revive_distance_metric", "1", "Distance metric (0: meters / 1: feet)");
sm_heal_bonus = CreateConVar("sm_heal_bonus", "1", "Bonus heal score(kill count) for medic");
sm_heal_cap_for_bonus = CreateConVar("sm_heal_cap_for_bonus", "0", "Amount of health given to other players to gain a kill");
sm_heal_amount_medpack = CreateConVar("sm_heal_amount_medpack", "0", "Heal amount per 0.5 seconds when using medpack");
sm_heal_amount_paddles = CreateConVar("sm_heal_amount_paddles", "0", "Heal amount per 0.5 seconds when using paddles");
sm_non_medic_heal_amt = CreateConVar("sm_non_medic_heal_amt", "2", "Heal amount per 0.5 seconds when non-medic");
sm_non_medic_revive_hp = CreateConVar("sm_non_medic_revive_hp", "10", "Health given to target revive when non-medic reviving");
sm_medic_minor_revive_hp = CreateConVar("sm_medic_minor_revive_hp", "75", "Health given to target revive when medic reviving minor wound");
sm_medic_moderate_revive_hp = CreateConVar("sm_medic_moderate_revive_hp", "50", "Health given to target revive when medic reviving moderate wound");
sm_medic_critical_revive_hp = CreateConVar("sm_medic_critical_revive_hp", "25", "Health given to target revive when medic reviving critical wound");
sm_minor_wound_dmg = CreateConVar("sm_minor_wound_dmg", "100", "Any amount of damage <= to this is considered a minor wound when killed");
sm_moderate_wound_dmg = CreateConVar("sm_moderate_wound_dmg", "200", "Any amount of damage <= to this is considered a minor wound when killed. Anything greater is CRITICAL");
sm_medic_heal_self_max = CreateConVar("sm_medic_heal_self_max", "75", "Max medic can heal self to with med pack");
sm_non_medic_heal_self_max = CreateConVar("sm_non_medic_heal_self_max", "25", "Max non-medic can heal self to with med pack");
sm_non_medic_max_heal_other = CreateConVar("sm_non_medic_max_heal_other", "25", "Heal amount per 0.5 seconds when using paddles");
sm_minor_revive_time = CreateConVar("sm_minor_revive_time", "4", "Seconds it takes medic to revive minor wounded");
sm_moderate_revive_time = CreateConVar("sm_moderate_revive_time", "7", "Seconds it takes medic to revive moderate wounded");
sm_critical_revive_time = CreateConVar("sm_critical_revive_time", "10", "Seconds it takes medic to revive critical wounded");
sm_non_medic_revive_time = CreateConVar("sm_non_medic_revive_time", "30", "Seconds it takes non-medic to revive minor wounded, requires medpack");
sm_medpack_health_amount = CreateConVar("sm_medpack_health_amount", "500", "Amount of health a deployed healthpack has");
sm_bombers_only = CreateConVar("sm_bombers_only", "0", "bombers ONLY?");
sm_multi_loadout_enabled = CreateConVar("sm_multi_loadout_enabled", "0", "Use Sernix Variety Bot Loadout? - Default OFF");
sm_ammo_resupply_range = CreateConVar("sm_ammo_resupply_range", "0", "Range to resupply near ammo cache");
sm_resupply_delay = CreateConVar("sm_resupply_delay", "0", "Delay loop for resupply ammo");
sm_jammer_required = CreateConVar("sm_jammer_required", "0", "Require deployable jammer for enemy reports? 0 = Disabled 1 = Enabled");
CreateConVar("Lua_Ins_Healthkit", PLUGIN_VERSION, PLUGIN_DESCRIPTION, FCVAR_NOTIFY | FCVAR_PLUGIN | FCVAR_DONTRECORD);
if ((m_hMyWeapons = FindSendPropInfo("CBasePlayer", "m_hMyWeapons")) == -1) {
SetFailState("Fatal Error: Unable to find property offset \"CBasePlayer::m_hMyWeapons\" !");
}
if ((m_flNextPrimaryAttack = FindSendPropInfo("CBaseCombatWeapon", "m_flNextPrimaryAttack")) == -1) {
SetFailState("Fatal Error: Unable to find property offset \"CBaseCombatWeapon::m_flNextPrimaryAttack\" !");
}
if ((m_flNextSecondaryAttack = FindSendPropInfo("CBaseCombatWeapon", "m_flNextSecondaryAttack")) == -1) {
SetFailState("Fatal Error: Unable to find property offset \"CBaseCombatWeapon::m_flNextSecondaryAttack\" !");
}
// Add admin respawn console command
RegAdminCmd("sm_respawn", Command_Respawn, ADMFLAG_SLAY, "sm_respawn <#userid|name>");
// Add reload config console command for admin
RegAdminCmd("sm_respawn_reload", Command_Reload, ADMFLAG_SLAY, "sm_respawn_reload");
// Event hooking
//Lua Specific
//HookEvent("grenade_thrown", Event_GrenadeThrown);
//For ins_spawnpoint spawning
HookEvent("player_spawn", Event_Spawn);
HookEvent("player_spawn", Event_SpawnPost, EventHookMode_Post);
HookEvent("player_death", Event_PlayerDeath);
HookEvent("round_start", Event_RoundStart);
HookEvent("round_end", Event_RoundEnd);
HookEvent("round_end", Event_RoundEnd_Pre, EventHookMode_Pre);
HookEvent("player_pick_squad", Event_PlayerPickSquad_Post, EventHookMode_Post);
HookEvent("object_destroyed", Event_ObjectDestroyed_Pre, EventHookMode_Pre);
HookEvent("object_destroyed", Event_ObjectDestroyed);
HookEvent("object_destroyed", Event_ObjectDestroyed_Post, EventHookMode_Post);
HookEvent("controlpoint_captured", Event_ControlPointCaptured_Pre, EventHookMode_Pre);
HookEvent("controlpoint_captured", Event_ControlPointCaptured);
HookEvent("controlpoint_captured", Event_ControlPointCaptured_Post, EventHookMode_Post);
HookEvent("player_disconnect", Event_PlayerDisconnect, EventHookMode_Pre);
HookEvent("player_connect", Event_PlayerConnect);
HookEvent("game_end", Event_GameEnd, EventHookMode_PostNoCopy);
// NavMesh Botspawn Specific Start
HookConVarChange(cvarSpawnMode,CvarChange);
// NavMesh Botspawn Specific End
// Revive/Heal specific
HookConVarChange(sm_revive_seconds, CvarChange);
HookConVarChange(sm_heal_amount_medpack, CvarChange);
HookConVarChange(sm_non_medic_heal_amt, CvarChange);
HookConVarChange(sm_non_medic_revive_hp, CvarChange);
HookConVarChange(sm_medic_minor_revive_hp, CvarChange);
HookConVarChange(sm_medic_moderate_revive_hp, CvarChange);
HookConVarChange(sm_medic_critical_revive_hp, CvarChange);
HookConVarChange(sm_minor_wound_dmg, CvarChange);
HookConVarChange(sm_moderate_wound_dmg, CvarChange);
HookConVarChange(sm_medic_heal_self_max, CvarChange);
HookConVarChange(sm_non_medic_heal_self_max, CvarChange);
HookConVarChange(sm_non_medic_max_heal_other, CvarChange);
HookConVarChange(sm_minor_revive_time, CvarChange);
HookConVarChange(sm_moderate_revive_time, CvarChange);
HookConVarChange(sm_critical_revive_time, CvarChange);
HookConVarChange(sm_non_medic_revive_time, CvarChange);
HookConVarChange(sm_medpack_health_amount, CvarChange);
// Respawn specific
HookConVarChange(sm_respawn_enabled, EnableChanged);
HookConVarChange(sm_revive_enabled, EnableChanged);
HookConVarChange(sm_respawn_delay_team_sec, CvarChange);
HookConVarChange(sm_respawn_delay_team_ins, CvarChange);
HookConVarChange(sm_respawn_lives_team_sec, CvarChange);
HookConVarChange(sm_respawn_lives_team_ins, CvarChange);
HookConVarChange(sm_respawn_reset_type, CvarChange);
HookConVarChange(sm_respawn_type_team_sec, CvarChange);
HookConVarChange(sm_respawn_type_team_ins, CvarChange);
HookConVarChange(cvarMinPlayerDistance,CvarChange);
HookConVarChange(cvarMaxPlayerDistance,CvarChange);
HookConVarChange(cvarCanSeeVectorMultiplier,CvarChange);
HookConVarChange(cvarMinObjectiveDistance,CvarChange);
HookConVarChange(cvarMaxObjectiveDistance,CvarChange);
HookConVarChange(cvarMaxObjectiveDistanceNav,CvarChange);
//Dynamic respawning
HookConVarChange(sm_respawn_dynamic_distance_multiplier,CvarChange);
HookConVarChange(sm_respawn_dynamic_spawn_counter_percent,CvarChange);
HookConVarChange(sm_respawn_dynamic_spawn_percent,CvarChange);
//Dynamic Loadouts
HookConVarChange(sm_bombers_only, CvarChange);
HookConVarChange(sm_multi_loadout_enabled, CvarChange);
// Tags
HookConVarChange(FindConVar("sv_tags"), TagsChanged);
//Other
HookConVarChange(sm_jammer_required, CvarChange);
// Init respawn function
// Next 14 lines of text are taken from Andersso's DoDs respawn plugin. Thanks :)
g_hGameConfig = LoadGameConfigFile("insurgency.games");
if (g_hGameConfig == INVALID_HANDLE)
SetFailState("Fatal Error: Missing File \"insurgency.games\"!");
StartPrepSDKCall(SDKCall_Player);
decl String:game[40];
GetGameFolderName(game, sizeof(game));
if (StrEqual(game, "insurgency")) {
//PrintToServer("[RESPAWN] ForceRespawn for Insurgency");
PrepSDKCall_SetFromConf(g_hGameConfig, SDKConf_Signature, "ForceRespawn");
}
if (StrEqual(game, "doi")) {
//PrintToServer("[RESPAWN] ForceRespawn for DoI");
PrepSDKCall_SetFromConf(g_hGameConfig, SDKConf_Virtual, "ForceRespawn");
}
g_hForceRespawn = EndPrepSDKCall();
if (g_hForceRespawn == INVALID_HANDLE) {
SetFailState("Fatal Error: Unable to find signature for \"ForceRespawn\"!");
}
// Load localization file
LoadTranslations("common.phrases");
LoadTranslations("respawn.phrases");
LoadTranslations("nearest_player.phrases.txt");
//Uncomment this code and SQL code below to utilize rank system (youll need to setup yourself.)
/////////////////////////
// Rank System
//RegConsoleCmd("say", Command_Say); // Monitor say
//SQL_TConnect(LoadMySQLBase, "insrank"); // Connect to DB
//
/////////////////////////
AutoExecConfig(true, "bot_respawn");
}
//End Plugin
public OnPluginEnd()
{
new ent = -1;
while ((ent = FindEntityByClassname(ent, "healthkit")) > MaxClients && IsValidEntity(ent))
{
StopSound(ent, SNDCHAN_VOICE, "Lua_sounds/healthkit_healing.wav");
AcceptEntityInput(ent, "Kill");
}
}
// Init config
public OnConfigsExecuted()
{
if (GetConVarBool(sm_respawn_enabled))
TagsCheck("respawntimes");
else
TagsCheck("respawntimes", true);
}
// When cvar changed
public EnableChanged(Handle:convar, const String:oldValue[], const String:newValue[])
{
new intNewValue = StringToInt(newValue);
new intOldValue = StringToInt(oldValue);
if(intNewValue == 1 && intOldValue == 0)
{
TagsCheck("respawntimes");
//HookEvent("player_death", Event_PlayerDeath, EventHookMode_Pre);
}
else if(intNewValue == 0 && intOldValue == 1)
{
TagsCheck("respawntimes", true);
//UnhookEvent("player_death", Event_PlayerDeath, EventHookMode_Pre);
}
}
// When cvar changed
public CvarChange(Handle:cvar, const String:oldvalue[], const String:newvalue[])
{
UpdateRespawnCvars();
}
// Update cvars
void UpdateRespawnCvars(int nSecAlive = 0)
{
//Counter attack chance based on number of points
g_respawn_counter_chance = GetConVarFloat(sm_respawn_counter_chance);
g_counterAttack_min_dur_sec = GetConVarInt(sm_respawn_min_counter_dur_sec);
g_counterAttack_max_dur_sec = GetConVarInt(sm_respawn_max_counter_dur_sec);
// The number of control points
new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
if (ncp < 6)
{
//Add to minimum dur as well.
//new fRandomInt = GetRandomInt(15, 30);
//new fRandomInt2 = GetRandomInt(6, 12);
//g_counterAttack_min_dur_sec += fRandomInt;
//g_counterAttack_max_dur_sec += fRandomInt2;
//g_respawn_counter_chance += 0.2;
}
else if (ncp >= 6 && ncp <= 8)
{
//Add to minimum dur as well.
//new fRandomInt = GetRandomInt(10, 20);
//new fRandomInt2 = GetRandomInt(4, 8);
//g_counterAttack_min_dur_sec += fRandomInt;
//g_counterAttack_max_dur_sec += fRandomInt2;
//g_respawn_counter_chance += 0.1;
}
g_jammerRequired = GetConVarInt(sm_jammer_required);
// Update Cvars
g_iCvar_respawn_enable = GetConVarInt(sm_respawn_enabled);
g_iCvar_revive_enable = GetConVarInt(sm_revive_enabled);
// Bot spawn mode
g_iCvar_SpawnMode = GetConVarInt(cvarSpawnMode);
// Tracking ammo
g_iCvar_enable_track_ammo = GetConVarInt(sm_respawn_enable_track_ammo);
// Respawn type
g_iCvar_respawn_type_team_ins = GetConVarInt(sm_respawn_type_team_ins);
g_iCvar_respawn_type_team_sec = GetConVarInt(sm_respawn_type_team_sec);
// Type of resetting respawn token
g_iCvar_respawn_reset_type = GetConVarInt(sm_respawn_reset_type);
//Dynamic Respawns
g_DynamicRespawn_Distance_mult = GetConVarFloat(sm_respawn_dynamic_distance_multiplier);
g_dynamicSpawnCounter_Perc = GetConVarFloat(sm_respawn_dynamic_spawn_counter_percent);
g_dynamicSpawn_Perc = GetConVarFloat(sm_respawn_dynamic_spawn_percent);
//Revive counts
g_iReviveSeconds = GetConVarInt(sm_revive_seconds);
// Heal Amount
g_iHeal_amount_medPack = GetConVarInt(sm_heal_amount_medpack);
g_iHeal_amount_paddles = GetConVarInt(sm_heal_amount_paddles);
g_nonMedicHeal_amount = GetConVarInt(sm_non_medic_heal_amt);
//HP when revived from wound
g_nonMedicRevive_hp = GetConVarInt(sm_non_medic_revive_hp);
g_minorWoundRevive_hp = GetConVarInt(sm_medic_minor_revive_hp);
g_modWoundRevive_hp = GetConVarInt(sm_medic_moderate_revive_hp);
g_critWoundRevive_hp = GetConVarInt(sm_medic_critical_revive_hp);
//New Revive Mechanics
g_minorWound_dmg = GetConVarInt(sm_minor_wound_dmg);
g_moderateWound_dmg = GetConVarInt(sm_moderate_wound_dmg);
g_medicHealSelf_max = GetConVarInt(sm_medic_heal_self_max);
g_nonMedicHealSelf_max = GetConVarInt(sm_non_medic_heal_self_max);
g_nonMedic_maxHealOther = GetConVarInt(sm_non_medic_max_heal_other);
g_minorRevive_time = GetConVarInt(sm_minor_revive_time);
g_modRevive_time = GetConVarInt(sm_moderate_revive_time);
g_critRevive_time = GetConVarInt(sm_critical_revive_time);
g_nonMedRevive_time = GetConVarInt(sm_non_medic_revive_time);
g_medpack_health_amt = GetConVarInt(sm_medpack_health_amount);
// Fatal dead
g_fCvar_fatal_chance = GetConVarFloat(sm_respawn_fatal_chance);
g_fCvar_fatal_head_chance = GetConVarFloat(sm_respawn_fatal_head_chance);
g_iCvar_fatal_limb_dmg = GetConVarInt(sm_respawn_fatal_limb_dmg);
g_iCvar_fatal_head_dmg = GetConVarInt(sm_respawn_fatal_head_dmg);
g_iCvar_fatal_burn_dmg = GetConVarInt(sm_respawn_fatal_burn_dmg);
g_iCvar_fatal_explosive_dmg = GetConVarInt(sm_respawn_fatal_explosive_dmg);
g_iCvar_fatal_chest_stomach = GetConVarInt(sm_respawn_fatal_chest_stomach);
//Dynamic Loadouts
g_iCvar_bombers_only = GetConVarInt(sm_bombers_only);
g_iCvar_multi_loadout_enabled = GetConVarInt(sm_multi_loadout_enabled);
// Nearest body distance metric
g_iUnitMetric = GetConVarInt(sm_revive_distance_metric);
// Set respawn delay time
g_iRespawnSeconds = -1;
switch (GetTeamSecCount())
{
case 0: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_01);
case 1: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_01);
case 2: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_02);
case 3: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_03);
case 4: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_04);
case 5: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_05);
case 6: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_06);
case 7: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_07);
case 8: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_08);
case 9: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_09);
case 10: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_10);
case 11: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_11);
case 12: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_12);
case 13: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_13);
case 14: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_14);
case 15: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_15);
case 16: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_16);