-
Notifications
You must be signed in to change notification settings - Fork 7
/
berobot_dmg_handler.sp
3927 lines (3221 loc) · 128 KB
/
berobot_dmg_handler.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
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <tf2>
#include <tf2_stocks>
#include <sm_logger>
#include <berobot_constants>
#include <berobot>
#include <tf_ontakedamage>
#include <tf2attributes>
#include <morecolors>
#include <tf_custom_attributes>
#include <sdktools>
#include <stocksoup/tf/tempents_stocks>
#include <stocksoup/datapack>
#include <smlib>
#include <tf2utils>
char LOG_TAGS[][] = {"VERBOSE", "INFO", "ERROR"};
enum (<<= 1)
{
SML_VERBOSE = 1,
SML_INFO,
SML_ERROR,
}
#include <berobot_core>
#pragma newdecls required
#pragma semicolon 1
enum //Convar names
{
CV_flSpyBackStabModifier,
CV_bDebugMode,
CV_PluginVersion
}
ConVar g_cvCvarList[CV_PluginVersion + 1];
bool g_cv_bDebugMode;
float g_CV_flSpyBackStabModifier;
int Punch_Count[MAXPLAYERS + 1] = {0, ...};
int Timer_Punch_Count[MAXPLAYERS + 1] = {0, ...};
bool g_Timer[MAXPLAYERS + 1] = {false, ...};
int g_Eyelander_Counter[MAXPLAYERS + 1] = {0, ...};
float g_BazaarHSDMG[MAXPLAYERS +1] = {0.0, ...};
float g_BazaarBodyDMG[MAXPLAYERS +1] = {0.0, ...};
float g_BazaarHSBuildrate = 450.0;
float g_BazaarBodyPenalty = 75.0;
float g_AirStrikeDamage[MAXPLAYERS +1] = {0.0, ...};
float g_AirStrikeDMGRequirement = 250.0;
float g_ElectricStunDuration = 5.0;
float g_HealDebuff = 1.0;
float g_FrontierJusticeDamage[MAXPLAYERS + 1] = {0.0, ...};
float g_FrontierJusticeDMGRequirement = 250.0;
int g_EngineerRevengeCrits[MAXPLAYERS + 1] = {0, ...};
//bool g_Enabled;
float g_Attribute_Display_CollDown = 10.0;
float g_Attribute_Display[MAXPLAYERS + 1] = {0.0, ...};
bool b_Attribute_Display[MAXPLAYERS + 1] = {true, ...};
float g_loose_cannon_timer = 3.0;
float g_loose_cannon_hit[MAXPLAYERS + 1] = {0.0, ...};
float g_bleed_duration_bonus = 10.0;
float g_axtinguisherspeedboost = 5.0;
float g_axtinguisherbuffduration = 5.0;
int g_powerjackhealonhit = 50;
int g_powerjackhealonhitoverheal = 260;
float g_blutsauger_heal_reduction = 0.35;
float g_blutsauger_heal_reduction_duration = 1.0;
float g_syringegun_debuff_amount = 0.85;
float g_syringe_dmg_debuff_duration = 4.0;
float g_spycicle_fire_speed_debuff = 0.7;
float g_spycicle_fire_Speed_debuff_duration = 6.0;
float g_market_gardner_dmg_bonus = 1.5;
int g_warriorspirit_heal_on_hit = 50;
int g_warriorspirit_max_overheal = 450;
float g_kgb_crit_combo_duration = 6.0;
// float g_eviction_notice_haste_duration = 4.0;
float g_protection_rune_duration = 1.0;
float g_electric_rage_reduction = 5.0;
// float g_HumanMiniGunDmGPenalty = 0.55;
float g_wrap_duration = 5.0;
float g_crit_a_cola_duration = 2.0;
float g_bleed_meleevuln_duration = 2.0;
float g_bleed_meleevuln_amount = 1.5;
// #define SPY_ROBOT_STAB "weapons/saxxy_impact_gen_01.wav"
// #define SPY_ROBOT_STAB ")mvm/giant_demoman/giant_demoman_grenade_shoot.wav"
int ParticleStorage[MAXPLAYERS + 1] = {0, ...};
#define POMSON_DRAIN_SOUND "weapons/drg_pomson_drain_01.wav"
public Plugin myinfo =
{
name = "berobot_dmg_handler",
author = "HeavyIsGPS",
description = "Handles the damage vs robots, attributes and onkill weapon stats",
version = "1.0",
url = "https://github.com/higps/robogithub"
};
public void OnPluginStart()
{
SMLoggerInit(LOG_TAGS, sizeof(LOG_TAGS), SML_ERROR, SML_FILE);
SMLogTag(SML_INFO, "berobot_dmg_handler started at %i", GetTime());
g_cvCvarList[CV_bDebugMode] = CreateConVar("sm_mm_dmg_debug", "0", "Enable Damage Debugging for Manned Machines Mode", FCVAR_NOTIFY, true, 0.0, true, 1.0);
g_cvCvarList[CV_flSpyBackStabModifier] = CreateConVar("sm_robo_backstab_damage", "83.3", "Backstab damage that will be multipled by crit multiplier");
/* Convar global variables init */
g_cv_bDebugMode = GetConVarBool(g_cvCvarList[CV_bDebugMode]);
g_CV_flSpyBackStabModifier = GetConVarFloat(g_cvCvarList[CV_flSpyBackStabModifier]);
/* Convar Change Hooks */
g_cvCvarList[CV_bDebugMode].AddChangeHook(CvarChangeHook);
HookEvent("post_inventory_application", Event_post_inventory_application, EventHookMode_Post);
HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
HookEvent("player_death", Event_PlayerDeath, EventHookMode_Post);
HookEvent("crossbow_heal", Event_Crossbow_Heal, EventHookMode_Post);
RegConsoleCmd("sm_mminfo", Command_ToggleMMHumanDisplay, "Toggle Manned Machines Stats Display for humans");
// HookEvent("object_destroyed", Event_Object_Destroyed, EventHookMode_Post);
// HookEvent("object_detonated", Event_Object_Detonated, EventHookMode_Post);
}
public Action Event_PlayerDeath(Event event, char[] name, bool dontBroadcast){
int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
int victim = GetClientOfUserId(GetEventInt(event, "userid"));
int assister = GetClientOfUserId(GetEventInt(event, "assister"));
if (IsValidClient(victim)){
DeleteParticle(0.1, ParticleStorage[victim]);
int decapitations = GetEntProp(victim, Prop_Send, "m_iDecapitations");
if (decapitations != 0)
{
if(!IsAnyRobot(victim) && IsAnyRobot(attacker) || IsAnyRobot(assister))
{
// PrintToChatAll("Decaps %i for %N", decapitations, victim);
if(decapitations >= 8) decapitations = 8;
TF2_AddCondition(attacker, TFCond_CritCola, float(decapitations));
TF2_AddCondition(attacker, TFCond_SpeedBuffAlly, float(decapitations));
TF2_AddCondition(attacker, TFCond_DefenseBuffed, float(decapitations));
TF2_AddCondition(assister, TFCond_CritCola, float(decapitations));
TF2_AddCondition(assister, TFCond_DefenseBuffed, float(decapitations));
TF2_AddCondition(assister, TFCond_SpeedBuffAlly, float(decapitations));
}
}
}
return Plugin_Continue;
}
public void OnMapStart()
{
PrecacheSound(POMSON_DRAIN_SOUND);
}
public Action Command_ToggleMMHumanDisplay(int client, int args)
{
if (b_Attribute_Display[client])
{
b_Attribute_Display[client] = false;
MC_PrintToChatEx(client, client, "{orange}Chat Display of stats: off");
}else
{
b_Attribute_Display[client] = true;
MC_PrintToChatEx(client, client, "{orange}Chat Display of stats: on");
}
return Plugin_Continue;
}
public void CvarChangeHook(ConVar convar, const char[] sOldValue, const char[] sNewValue)
{
if (convar == g_cvCvarList[CV_bDebugMode])
g_cv_bDebugMode = view_as<bool>(StringToInt(sNewValue));
if (convar == g_cvCvarList[CV_flSpyBackStabModifier])
g_CV_flSpyBackStabModifier = StringToFloat(sNewValue);
}
// public void MM_OnEnabledChanged(int enabled)
// {
// //PrintToChatAll("Enabled was %i", enabled);
// }
public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
if (!IsAnyRobot(client))
{
if (HasAirStrike(client))
{
g_AirStrikeDamage[client] = 0.0;
}
ResetBazaarDamage(client);
int Weapon3 = GetPlayerWeaponSlot(client, TFWeaponSlot_Melee);
if (IsSunOnAStick(Weapon3))
{
// RemoveEquippedTFBottle(client);
// TF2_RemoveWeaponSlot(client,9);
int action_slot_item = TF2Util_GetPlayerLoadoutEntity(client, 9);
if(IsValidEntity(action_slot_item))RemoveEntity(action_slot_item);
CreateRoboWeapon(client, "tf_weapon_spellbook", 5605, 0, 1, 4, 0);
TF2CustAttr_SetString(client, "Spell-Caster", "Spell=0 Cooldown=40.0");
}else
{
TF2CustAttr_SetString(client, "Spell-Caster", "Spell=-1 Cooldown=40.0");
}
if (HasFrontierJustice(client))
{
g_FrontierJusticeDamage[client] = 0.0;
}
if (TF2_GetPlayerClass(client) == TFClass_Scout)
{
TF2CustAttr_SetString(client, "faster-respawn", "respawn=8.0");
}
}
}
float g_Razorback_Original_Recharge = -1.0;
float g_Razorback_Original_Recharge_Robot_Hit = 0.2;
//Damage Related functions
/* Plugin Exclusive Functions */
public Action TF2_OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3], int damagecustom, CritType &critType)
{
if (!IsValidClient(victim))
return Plugin_Continue;
if (!IsValidClient(attacker))
return Plugin_Continue;
// if (IsAnyRobot(victim) && damagetype == DMG_FALL && !IsBoss(victim))
// {
// damage *= 0.25;
// return Plugin_Changed;
// }
// return Plugin_Continue;
// }
if (damagecustom == TF_CUSTOM_RUNE_REFLECT)
{
// PrintToChatAll("damage before change %f", damage);
damage *= 0.4;
// PrintToChatAll("damage after change %f", damage);
//critType = CritType_None;
damageForce[0] == -10.0;
damageForce[1] == -10.0;
damageForce[2] == -10.0;
return Plugin_Handled;
}
if(damagecustom == TF_CUSTOM_SPELL_FIREBALL)
{
// PrintToChatAll("WAS FIREBALL!");
damage *= 0.7;
return Plugin_Changed;
}
if (damagecustom == TF_CUSTOM_SPELL_LIGHTNING)
{
damage *= 0.1;
return Plugin_Changed;
}
if (damagecustom == TF_CUSTOM_BLEEDING && IsAnyRobot(victim))
{
damage *= 1.4;
return Plugin_Changed;
}
if (damagecustom == TF_CUSTOM_PLASMA)
{
// PrintToChatAll("PLASMA");
if (TF2_GetPlayerClass(attacker) == TFClass_Heavy || TF2_GetPlayerClass(attacker) == TFClass_Medic){
// PrintToChatAll("For heavy or medic TF_CUSTOM_PLASMA dmg was %f", damage);
damage = 0.0;
// PrintToChatAll("%f", GetEntPropFloat(attacker, Prop_Send, "m_flRageMeter"));
return Plugin_Changed;
}
}
// if (IsElectric(weapon))
// {
// PrintToChatAll("WAS ELECTRIC");
// }
if (IsAnyRobot(victim))
{
if (TF2_GetPlayerClass(attacker) == TFClass_DemoMan)
{
if (IsCaber(weapon))
{
// int Detonated = GetEntProp(weapon, Prop_Send, "m_iDetonated");// PrintToChatAll("Removing Bonus"); //Removes the damage bonus from caber after use, in case of ubered players
// PrintToChatAll("Detonated %i", Detonated);
TF2Attrib_RemoveByName(weapon, "damage bonus");
}
}
if (TF2_GetPlayerClass(attacker) == TFClass_Medic)
{
if (IsBlutsauger(weapon))
{
// int Detonated = GetEntProp(weapon, Prop_Send, "m_iDetonated");// PrintToChatAll("Removing Bonus"); //Removes the damage bonus from caber after use, in case of ubered players
// PrintToChatAll("Detonated %i", Detonated);
SetHealingDebuff(victim, g_blutsauger_heal_reduction, g_blutsauger_heal_reduction_duration, attacker);
// TF2Attrib_AddCustomPlayerAttribute(victim, "reduced_healing_from_medics", g_blutsauger_heal_reduction, g_blutsauger_heal_reduction_duration);
}
if (IsSyringeGun(weapon))
{
SetDamageDebuff(victim, g_syringegun_debuff_amount, g_syringe_dmg_debuff_duration, attacker);
}
}
if (damagecustom == TF_CUSTOM_BLEEDING)
{
TF2Attrib_AddCustomPlayerAttribute(victim, "dmg from melee increased", g_bleed_meleevuln_amount, g_bleed_meleevuln_duration);
}
if (TF2_IsPlayerInCondition(victim, TFCond_Stealthed))
{
if (damagecustom == TF_CUSTOM_BLEEDING || IsElectric(weapon))
{
TF2_RemoveCondition(victim, TFCond_Stealthed);
} //Code to remove stealthed from burning and bleeding
}
}
if (!IsAnyRobot(victim))
{
// //m_flItemChargeMeter
// float data = GetEntPropFloat(victim, Prop_Send, "m_flItemChargeMeter");
// PrintToChatAll("Data %f", data);
// PrintToChatAll("Damagetype was %i\nWeapon was %i\n Damagecustom was %i", damagetype, weapon, damagecustom);
switch (damagecustom)
{
case TF_CUSTOM_BACKSTAB:
{
// PrintToChatAll("BACKSTAB 0!");
int razorback = FindTFWearable(victim, 57);
if (IsValidEntity(razorback))
{
// PrintToChatAll("%N had razorback when stabbed", victim);
// PrintToChatAll("Charge was before %f", g_Razorback_Original_Recharge);
Address rstats;
if (g_Razorback_Original_Recharge == -1.0){
// PrintToChatAll("Finding item_meter");
rstats = TF2Attrib_GetByName(razorback, "item_meter_charge_rate");
g_Razorback_Original_Recharge = TF2Attrib_GetValue(rstats);
}
// PrintToChatAll("Charge was after %f", g_Razorback_Original_Recharge);
if (IsAnyRobot(attacker) && !IsBoss(attacker))
{
TF2Attrib_SetByName(razorback, "item_meter_charge_rate", g_Razorback_Original_Recharge_Robot_Hit);
TF2_StunPlayer(attacker, 0.5, 0.0, TF_STUNFLAG_BONKSTUCK, attacker);
TF2_AddCondition(attacker, TFCond_Sapped, 0.5, attacker);
}else
{
if (g_Razorback_Original_Recharge != -1.0)TF2Attrib_SetByName(razorback, "item_meter_charge_rate", g_Razorback_Original_Recharge);
}
// TF2Attrib_AddCustomPlayerAttribute(victim, "item_meter_charge_rate", 0.1, 5.0);
}
}
}
}
if (IsAnyRobot(attacker))
{
switch (damagecustom)
{
case TF_CUSTOM_BASEBALL:
{
if (IsSandman(weapon))
{
// SetHealingDebuff(victim, g_HealDebuff, 0.5, attacker);
DizzyTarget(victim);
return Plugin_Changed;
}
}
}
}
if (IsAnyRobot(victim) && !IsAnyRobot(attacker))
{
TFClassType iClassAttacker = TF2_GetPlayerClass(attacker);
if (iClassAttacker == TFClass_Pyro)
{
if (IsAxtinguisher(weapon) && TF2_IsPlayerInCondition(victim, TFCond_OnFire))
{
// PrintToChatAll("Target on fire");
TF2_AddCondition(attacker, TFCond_SpeedBuffAlly, g_axtinguisherspeedboost);
TF2_AddCondition(attacker, TFCond_DefenseBuffed, g_axtinguisherspeedboost);
// TF2_AddCondition(attacker, TFCond_CritCanteen, 3.0);
}
if (IsPowerJack(weapon))
{
AddPlayerHealth(attacker, g_powerjackhealonhit, g_powerjackhealonhitoverheal, true, true);
// ShowHealthGain(attacker, 50, attacker);
}
if (IsScorch(weapon) && damagecustom == 0)
{
// PrintToChatAll("Hit with Scorch %i",damagecustom);
DataPack info = new DataPack();
info.Reset();
info.WriteCell(victim);
info.WriteCell(50.0);
RequestFrame(ChangeKnockBack,info);
}
}
if (iClassAttacker == TFClass_Heavy)
{
if (IsWarriorSpirit(weapon))
{
AddPlayerHealth(attacker, g_warriorspirit_heal_on_hit, g_warriorspirit_max_overheal, true, true);
// ShowHealthGain(attacker, 50, attacker);
}
if (IsKGB(weapon))
{
if (g_cv_bDebugMode) PrintToChatAll("Hit # %i", Punch_Count[attacker]);
//Get the name of the player to use with the tauntem plugin
int playerID = GetClientUserId(victim);
if (g_cv_bDebugMode) PrintToChatAll("Victim name %s", playerID);
//Count the punches
Punch_Count[attacker]++;
if (TF2_IsPlayerInCondition(attacker, TFCond_CritCanteen))
{
Punch_Count[attacker] = 0;
TF2_AddCondition(attacker, TFCond_CritCanteen, g_kgb_crit_combo_duration, attacker);
}
if (!g_Timer[attacker]){
CreateTimer(3.0, Combo_Check_Timer, attacker);
Timer_Punch_Count[attacker] = Punch_Count[attacker];
g_Timer[attacker] = true;
}
if (Punch_Count[attacker] > 1)
{
Combo_Stopper(attacker);
TF2_AddCondition(attacker, TFCond_CritCanteen, g_kgb_crit_combo_duration, attacker);
}
}
}
// if (iClassAttacker == TFClass_Medic)
// {
// int Weapon3 = GetPlayerWeaponSlot(attacker, TFWeaponSlot_Melee);
// if (IsSolemnVow(Weapon3))
// {
// damage = 0.0;
// return Plugin_Handled;
// }
// }
// if (iClassAttacker == TFClass_Scout)
// {
// if (IsForceANature(weapon))
// {
// // PrintToChatAll("Engine time: %f", GetEngineTime());
// // PrintToChatAll("Cannon hit %f",g_loose_cannon_hit[victim]);
// if (GetEngineTime() <= g_loose_cannon_hit[victim])
// {
// // PrintToChatAll("Normal Knockback");
// g_loose_cannon_hit[victim] = GetEngineTime() + g_loose_cannon_timer;
// }
// else
// {
// DataPack info = new DataPack();
// info.Reset();
// info.WriteCell(victim);
// info.WriteCell(1050.0);
// // PrintToChatAll("Reducing Knockback");
// RequestFrame(ChangeKnockBack,info);
// }
// }
// }
if (iClassAttacker == TFClass_DemoMan)
{
if (IsLooseCannon(weapon))
{
// PrintToChatAll("Engine time: %f", GetEngineTime());
// PrintToChatAll("Cannon hit %f",g_loose_cannon_hit[victim]);
if (GetEngineTime() >= g_loose_cannon_hit[victim])
{
// PrintToChatAll("Normal Knockback");
g_loose_cannon_hit[victim] = GetEngineTime() + g_loose_cannon_timer;
}
else
{
DataPack info = new DataPack();
info.Reset();
info.WriteCell(victim);
info.WriteCell(50.0);
// PrintToChatAll("Reducing Knockback");
RequestFrame(ChangeKnockBack,info);
}
}
}
if (iClassAttacker == TFClass_Engineer)
{
if (IsValidEntity(inflictor))
{
char AttackerObject[128];
GetEdictClassname(inflictor, AttackerObject, sizeof(AttackerObject));
if (StrEqual(AttackerObject, "obj_sentrygun")) {
// fDamage *= 0.1;
// IncrementHeadCount(attacker);
// Table: SentrygunLocalData (offset 0) (type DT_SentrygunLocalData)
// Member: m_iKills (offset 2648) (type integer) (bits 32) (VarInt|ChangesOften)
// Member: m_iAssists (offset 2652) (type integer) (bits 32) (VarInt|ChangesOften)
if (g_FrontierJusticeDamage[attacker] >= g_FrontierJusticeDMGRequirement)
{
g_EngineerRevengeCrits[attacker]++;
int iSentryAssists = GetEntProp(inflictor, Prop_Send, "m_iAssists");
// PrintToChatAll("I assists %i", iSentryAssists);
if (iSentryAssists == -1)
{
iSentryAssists = 1;
}
// PrintToChatAll("I assists again %i", iSentryAssists+1);
SetEntProp(inflictor, Prop_Send, "m_iAssists", iSentryAssists+1);
g_FrontierJusticeDamage[attacker] = 0.0;
}else
{
g_FrontierJusticeDamage[attacker] += damage;
}
//PrintToChatAll("Sentry damage was %f", damage);
}
}
}
if (damagecustom == TF_CUSTOM_BACKSTAB)
{
if (IsKunai(weapon))
{
AddPlayerHealth(attacker, 120, 275, true);
}
if (HasDiamondback(attacker)) //Diamondback gives 2, has to be+2 for some reason crits on backstab
{
int iCrits = GetEntProp(attacker, Prop_Send, "m_iRevengeCrits");
SetEntProp(attacker, Prop_Send, "m_iRevengeCrits", iCrits+2);
}
if (IsBigEarner(weapon))
{
TF2_AddCondition(attacker, TFCond_SpeedBuffAlly, 3.0);
}
if (IsSpycicle(weapon))
{
TF2Attrib_AddCustomPlayerAttribute(victim, "damage penalty", g_spycicle_fire_speed_debuff, g_spycicle_fire_Speed_debuff_duration);
//TF2_StunPlayer(victim, 1.0, 0.85, TF_STUNFLAG_SLOWDOWN, attacker);
}
if (IsYer(weapon))
{
//PrintToChatAll("Was yer");
//int iteam = GetClientTeam(victim);
TFTeam iTeam = view_as<TFTeam>(GetEntProp(victim, Prop_Send, "m_iTeamNum"));
// int attackerID = GetClientUserId(attacker);
// int victimID = GetClientUserId(victim);
// TFClassType iClassVictim = TF2_GetPlayerClass(victim);
//TF2_DisguisePlayer(attackerID, iTeam, iClassVictim, victimID);
DataPack info = new DataPack();
info.Reset();
info.WriteCell(GetClientUserId(attacker));
info.WriteCell(iTeam);
info.WriteCell(TFClass_Spy);
info.WriteCell(GetClientUserId(victim));
RequestFrame(Disguiseframe, info);
}
//Do backstab modifying
if (g_cv_bDebugMode)PrintToChatAll("Damage before change %f", damage);
int victimHP = GetClientHealth(victim);
int victimMAXHP = GetEntProp(victim, Prop_Data, "m_iMaxHealth");
int victimHPpercent = RoundToNearest(float(victimHP) / float(victimMAXHP) * 100);
// PrintToChatAll("victimHP %i, MAXHP %i", victimHP, victimMAXHP);
if (victimHPpercent >= 95){
//Code for dynamic damage, but doesn't work well with vulnerabilities
// PrintToChatAll("percent %i", victimHPpercent);
// damage = (float(victimMAXHP) / 4.0) / 3.0;
// if (damage > 1250.0)
// {
// damage = 1250.0;
// }
damage = g_CV_flSpyBackStabModifier * 2.0;
}else{
damage = g_CV_flSpyBackStabModifier;
}
//Bonus dmg vs heavies
if (TF2_GetPlayerClass(victim) == TFClass_Heavy)
{
damage *= 1.2;
}
critType = CritType_Crit;
if (g_cv_bDebugMode)PrintToChatAll("Set damage to %f", damage);
TF2_AddCondition(attacker, TFCond_RuneResist, g_protection_rune_duration);
// EmitSoundToAll(SPY_ROBOT_STAB, victim);
// EmitSoundToClient(victim, SPY_ROBOT_STAB);
return Plugin_Changed;
}
switch (damagecustom)
{
case TF_CUSTOM_TAUNT_HIGH_NOON, TF_CUSTOM_TAUNT_GRAND_SLAM,
TF_CUSTOM_TAUNT_FENCING, TF_CUSTOM_TAUNT_ARROW_STAB, TF_CUSTOM_TELEFRAG,
TF_CUSTOM_TAUNT_BARBARIAN_SWING, TF_CUSTOM_TAUNT_UBERSLICE,
TF_CUSTOM_TAUNT_ENGINEER_SMASH, TF_CUSTOM_TAUNT_ENGINEER_ARM, TF_CUSTOM_TAUNT_ALLCLASS_GUITAR_RIFF,
TF_CUSTOM_TAUNTATK_GASBLAST:
{
damage *= 3.0;
return Plugin_Changed;
}
case TF_CUSTOM_TAUNT_GRENADE:
{
damage *= 8.0;
return Plugin_Changed;
}
case TF_CUSTOM_TAUNT_HADOUKEN:
{
damage *= 4.0;
return Plugin_Changed;
}
}
if (!IsBoss(victim) && IsAnyRobot(victim))
{
switch (damagecustom)
{
case TF_CUSTOM_CHARGE_IMPACT, TF_CUSTOM_BOOTS_STOMP:
{
damage *= 2.0;
if (IsTank(victim))
{
float stun_duration = 0.6;
TF2_StunPlayer(victim, stun_duration, 0.0, TF_STUNFLAG_NOSOUNDOREFFECT|TF_STUNFLAG_BONKSTUCK, attacker);
// TE_TFParticleEffectAttachment("bot_radio_waves", victim, PATTACH_POINT_FOLLOW, "head");
// SetHealingDebuff(victim, g_HealDebuff, 0.5, attacker);
// if (TF2_GetClientTeam(iBuilder) == TFTeam_Blue)
// {
// int attachHead = LookupEntityAttachment(victim, "head");
// if (attachHead) {
// int particle = TE_SetupTFParticleEffect("bot_radio_waves", NULL_VECTOR, .entity = victim,
// .attachType = PATTACH_POINT_FOLLOW, .attachPoint = attachHead);
// TE_SendToAll();
// PrintToChatAll("Particle Was %i", particle);
CreateParticle(victim, "bot_radio_waves", stun_duration+0.4);
// DataPack data;
// CreateDataTimer(stun_duration, RemoveStunEffect, data, TIMER_FLAG_NO_MAPCHANGE);
// data.WriteCell(particle);
// data.WriteCell("bot_radio_waves");
}
DizzyTarget(victim);
return Plugin_Changed;
}
case TF_CUSTOM_BASEBALL:
{
if (IsSandman(weapon))
{
// SetHealingDebuff(victim, g_HealDebuff, 0.5, attacker);
DizzyTarget(victim);
}
if (IsWrap(weapon)){
SetHealingDebuff(victim, g_HealDebuff, g_wrap_duration, attacker);
}
return Plugin_Changed;
}
}
}
}
return Plugin_Continue;
}
stock void CreateParticle(int ent, char[] particleType, float time)
{
//int iWeapon = GetPlayerWeaponSlot(ent, TFWeaponSlot_Secondary);
int particle = CreateEntityByName("info_particle_system");
char name[64];
if (IsValidEdict(particle))
{
//Delete existing particle if it's already there
//CreateTimer(0.0, DeleteParticle, particle);
float position[3];
GetEntPropVector(ent, Prop_Send, "m_vecOrigin", position);
position[0] += 0.0;
position[1] += 0.0;
position[2] += 0.0; //z
TeleportEntity(particle, position, NULL_VECTOR, NULL_VECTOR);
GetEntPropString(ent, Prop_Data, "m_iName", name, sizeof(name));
DispatchKeyValue(particle, "targetname", "tf2particle");
DispatchKeyValue(particle, "parentname", name);
DispatchKeyValue(particle, "effect_name", particleType);
//DispatchKeyValue(particle, "angles", "90.0 90.0 0.0");
DispatchSpawn(particle);
// SetVariantString(name);
// AcceptEntityInput(particle, "SetParent", ent, particle, 0);
//if team blue - use player_glowblue
//if team red use - player_glowred
SetVariantString("!activator");
AcceptEntityInput(particle, "SetParent", ent, particle, 0);
SetVariantString("head");
AcceptEntityInput(particle, "SetParentAttachmentMaintainOffset", particle, particle, 0);
DispatchKeyValue(particle, "targetname", "present");
ActivateEntity(particle);
AcceptEntityInput(particle, "start");
CreateTimer(time, DeleteParticle, particle);
ParticleStorage[ent] = particle;
}
}
public Action DeleteParticle(Handle timer, any particle)
{
if (IsValidEntity(particle))
{
char classN[64];
GetEdictClassname(particle, classN, sizeof(classN));
if (StrEqual(classN, "info_particle_system", false))
{
RemoveEdict(particle);
}
}
}
void DizzyTarget (int victim)
{
float angles[3];
GetClientEyeAngles(victim, angles);
// Generate a random value
float randomAngleSideways = GetRandomFloat(20.0, 30.0);
float randomAngleUpDown = GetRandomFloat(10.0,20.0);
// Make the value either positive or negative
if (GetRandomInt(0,1) == 1)
{
randomAngleSideways *= -1.0;
}
if (GetRandomInt(0,1) == 1)
{
randomAngleUpDown *= -1.0;
}
// Apply the random adjustment to the yaw angle
angles[1] += randomAngleSideways;
angles[0] += randomAngleUpDown;
// Ensure the yaw angle stays within the valid range
// while (angles[1] >= 360.0)
// {
// angles[1] -= 360.0;
// }
// while (angles[1] < 0.0)
// {
// angles[1] += 360.0;
// }
// while (angles[0] >= 360.0)
// {
// angles[0] -= 360.0;
// }
// while (angles[0] < 0.0)
// {
// angles[0] += 360.0;
// }
TeleportEntity(victim, NULL_VECTOR, angles, NULL_VECTOR);
}
void ChangeKnockBack (DataPack info)
{
info.Reset();
int victim = info.ReadCell();
int flDistance = info.ReadCell();
delete info;
// PrintToChatAll("WAS LOOSE CANNON %");
if (IsValidClient(victim) && IsPlayerAlive(victim))
{
float vOrigin[3], vAngles[3], vForward[3], vVelocity[3];
GetClientEyePosition(victim, vOrigin);
GetClientEyeAngles(victim, vAngles);
// Get the direction we want to go
GetAngleVectors(vAngles, vForward, NULL_VECTOR, NULL_VECTOR);
// make it usable
// float flDistance = 50.0;
ScaleVector(vForward, flDistance);
// add it to the current velocity to avoid just being able to do full 180s
GetEntPropVector(victim, Prop_Data, "m_vecVelocity", vVelocity);
AddVectors(vVelocity, vForward, vVelocity);
// float flDistanceVertical = 10.0;
// vVelocity[2] -= flDistanceVertical; // we always want to go a bit up
// And set it
TeleportEntity(victim, NULL_VECTOR, NULL_VECTOR, vVelocity);
}
}
void Disguiseframe (DataPack info)
{
info.Reset();
int attacker = GetClientOfUserId(info.ReadCell());
int iTeam = info.ReadCell();
int iClassVictim = info.ReadCell();
int victim = GetClientOfUserId(info.ReadCell());
delete info;
FastDisguise(attacker, iTeam, iClassVictim, victim);
}
void FastDisguise(int iClient, TFTeam iTeam, TFClassType iClass, int iTarget)
{
if (IsValidClient(iClient) && IsPlayerAlive(iClient))
{
TF2_DisguisePlayer(iClient, iTeam, iClass, iTarget); // SetEntProp(iClient, Prop_Send, "m_hDisguiseWeapon", iWeapon);
SetEntProp(iClient, Prop_Send, "m_nDisguiseTeam", _:iTeam);
SetEntProp(iClient, Prop_Send, "m_nMaskClass", _:iClass);
SetEntProp(iClient, Prop_Send, "m_nDisguiseClass", _:iClass);
SetEntProp(iClient, Prop_Send, "m_nDesiredDisguiseClass", _:iClass);
// SetEntProp(iClient, Prop_Send, "m_iDisguiseTargetIndex", iTarget);
SetEntProp(iClient, Prop_Send, "m_iDisguiseHealth", IsPlayerAlive(iTarget) ? GetClientHealth(iTarget) : GetClassBaseHP(iTarget));
TF2_AddCondition(iClient, TFCond_Disguised);
}
}
void ResetBazaarDamage(int client)
{
g_BazaarBodyDMG[client] = 0.0;