-
Notifications
You must be signed in to change notification settings - Fork 0
/
hoovyassault.sp
1419 lines (1383 loc) · 48.1 KB
/
hoovyassault.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
/*
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 <https://www.gnu.org/licenses/>.
*/
#include <sourcemod>
#include <tf2>
#include <tf2_stocks>
#include <menus>
#include <sdkhooks>
#include <string>
#define HOOVY_POINTS_LIMIT 65
#define GBW_STAGING 1 // set to 1 to enable the following features: Comissar SMG
#define SPELLS_STAGING 1 // set to 1 to enable the following features: Spells
#define HOOVY_CLASSAPI_ENABLED 1 // set to 1 to enable Hoovy Assault Plugin API
int HoovyClass[MAXPLAYERS+1]
int HoovyFlags[MAXPLAYERS+1] // bitsum
int HoovyRage[MAXPLAYERS+1]
bool HoovyVisuals[MAXPLAYERS+1]
float HoovyCoords[MAXPLAYERS+1][3] // position
float HoovyMaxHealth[MAXPLAYERS+1]
int HoovyScores[2] = {0,0} // 0 = RED, 1 = BLU
bool HoovyValid[MAXPLAYERS+1]
bool HoovySpecialDelivery[MAXPLAYERS+1]
bool MadeHisChoice[MAXPLAYERS+1]
bool BannerDeployed[MAXPLAYERS+1]
bool HoovyPrimaryUnrestricted[MAXPLAYERS+1]
bool HoovyClassUnrestricted[MAXPLAYERS+1]
int BeamSprite[2],HaloSprite
public bool IsFood(weapon)
{
static char classname[64]
GetEdictClassname(weapon, classname, sizeof(classname))
return !strcmp(classname,"tf_weapon_lunchbox")
}
stock min(a,b)
{
return a>b?b:a
}
#define TeamScoresIndex(%1) (TF2_GetClientTeam(%1)==TFTeam_Blue?1:0)
#define ValidUser(%1) ((1<=%1<=MaxClients)&&IsClientInGame(%1)&&IsPlayerAlive(%1))
#define HOOVY_CYCLE_TIME 0.2
#define HOOVY_EFFECTS_RADIUS 315.0
#define MENU_TIMEOUT 4
#define MEDIC_HEAL 15 // HP/tic
#define MEDIC_FIST_HEAL 35
#define MEDIC_HEAL_FIST_DELAY 1.5
#define MEDIC_OVERHEAL 100
#define MEDIC_TICK 0.2 // seconds
#define COMISSAR_OVERHEAL 50.0
#define COMISSAR_DMGRES 0.9
#define OFFICER_DMGBONUS 1.1
#define TRUMPETER_BUFFTIME 10
#define TRUMPETER_DAMAGENEEDED 600
#define HOOVY_BIT_DMGBONUS (1<<1)
#define HOOVY_BIT_DMGRES (1<<2)
#define HOOVY_BIT_OVERHEAL (1<<3)
#define HOOVY_BIT_HEALING (1<<4)
#define HOOVY_BIT_BLOCK_HEALING (1<<5)
#define SOUND_HEAL "items/smallmedkit1.wav"
#define SOUND_BOOM "items/cart_explode.wav"
#define SOUND_RJUMP "weapons/rocket_jumper_explode1.wav"
#define BOOM_RADIUS 600.0
#define LEAPER_VEL 1200.0
#define LEAPER_SPEED 8.0
#define BOT_CLASS_LIMIT 2
#define DISPENSER_COST 5
#define SENTRY_COST 12
#if GBW_STAGING
#include "hoovyassault_module_gbw.inc"
#endif
enum
{
HOOVY_SOLDIER=0,
HOOVY_MEDIC, // Healing allies closer than HOOVY_EFFECTS_RADIUS, BUT can use only melee
HOOVY_COMISSAR,// at choise: +50 maximum health(not current health), +10% damage resistance
//BUT: +30% received damage,-50% maximum health, -15% damage penalty for user at the same time
HOOVY_OFFICER,// +10% damage bonus for allies,+15% damage bonus for user,BUT -25% maximum health, +25% received damage
// The same effects ARE NOT summed up
HOOVY_SCOUT, // accelerated speed,every healthkit fully regenerates you,BUT: -40% health, -15% damage penalty
HOOVY_BOXER, // Kills anyone with one punch, but anyone can kill him with one punch
HOOVY_TRUMPETER,
HOOVY_BOOMER,
HOOVY_LEAPER,
HOOVY_ENGINEER,
HOOVY_GNOME,
NUM_CLASSES
}
enum
{
Char_Maxhealth = 0, Char_Dmgbonus, Char_Dmgrespenalty, Num_Chars
}
float ClassChars[NUM_CLASSES][Num_Chars]={
{1.25,1.0,1.0}, // HOOVY_SOLDIER
{1.0,1.0,1.0}, // HOOVY_MEDIC
{0.5,0.85,1.3}, // HOOVY_COMISSAR
{0.75,1.20,1.15},// HOOVY_OFFICER
{0.6,0.85,1.0}, // HOOVY_SCOUT
{1.0,1.0,1.0}, // HOOVY_BOXER
{0.7,1.0,1.0}, // HOOVY_TRUMPETER
{0.26,0.3,1.0}, // HOOVY_BOOMER
{0.84,0.6,1.3}, // HOOVY_LEAPER
{0.5,1.0,1.0}, // HOOVY_ENGINEER
{0.25,0.5,0.5} // HOOVY_GNOME
}
// negative value means it can't be accessed using the class menu. Set to -2 to remove it from help too
int ClassLimit[NUM_CLASSES]=
{
0, // HOOVY_SOLDIER
0, // HOOVY_MEDIC
0, // HOOVY_COMISSAR
0, // HOOVY_OFFICER
0, // HOOVY_SCOUT
0, // HOOVY_BOXER
0, // HOOVY_TRUMPETER
2, // HOOVY_BOOMER
0, // HOOVY_LEAPER
1, // HOOVY_ENGINEER
2 // HOOVY_GNOME
}
char ClassDescription[NUM_CLASSES][]={
"Health bonus +75 HP",
"Healing allies,BUT may use only melee",
"+50 max HP,+10% dmg res for allies, BUT -50% HP,-30% dmg res,-15% dmg penalty for you",
" +10% dmg bonus for allies,+20% for you, BUT -25% HP,-15% dmg res for you",
"increased speed, BUT -40% HP,-15% dmg penalty",
"kills with one punch, dies from one punch",
"Activate Buff Banner by using POOTIS (press x then press 5), BUT always marked for death,-30% health",
"Now your most terrifying weapon is your sandwich",
"Jump really high using RMB, -30% dmg resistance, -40% dmg penalty",
"Put dispenser here by saying \"Put dispenser here\"(press x then press 5), -50% health,damage penalty based on health",
"Cast gruesome spells on your foes and allies"
}
char ClassName[NUM_CLASSES][]=
{
"Soldier",
"Medic",
"Comissar",
"Officer",
"Scout",
"Boxer",
"Trumpeter",
"Boomer",
"Leaper",
"Engineer",
"Gnome wizard"
}
ConVar meleeOnlyAllowed
ConVar hideCustomWeapons
#define BOOMER_VO_NUM 8
char boomer_sounds[BOOMER_VO_NUM][] = {
"vo/heavy_sandwichtaunt06.mp3",
"vo/heavy_sandwichtaunt10.mp3",
"vo/heavy_sandwichtaunt15.mp3",
"vo/heavy_specialweapon08.mp3",
"vo/heavy_domination15.mp3",
"vo/heavy_award10.mp3",
"vo/heavy_meleeing01.mp3",
"vo/heavy_mvm_bomb_see01.mp3"
}
// modules that require basic Heavyassault constants
#if SPELLS_STAGING
#include "hoovyassault_module_spells"
#endif
#if HOOVY_CLASSAPI_ENABLED
#include "hoovyassault_module_classapi"
#endif
public Plugin myinfo =
{
name = "Hoovy assault",
author = "breins",
description = "Battle of heavies",
version = "24.11.24",
url = ""
};
public OnPluginStart()
{
for(int i=1;i<MaxClients;i++){HoovyClass[i] = HoovyFlags[i] = HoovyRage[i] = 0;HoovyVisuals[i] = true;HoovySpecialDelivery[i] = MadeHisChoice[i] = BannerDeployed[i] = HoovyClassUnrestricted[i] = HoovyPrimaryUnrestricted[i] = false;if(IsClientInGame(i))doSDKHooks(i);}
//LoadTranslations("hoovy.phrases")
CreateTimer(HOOVY_CYCLE_TIME,UpdateHoovies,_, TIMER_REPEAT)
CreateTimer(MEDIC_TICK,HealTimer,_,TIMER_REPEAT)
HookEvent("player_spawn", Event_PlayerSpawn)
HookEvent("player_death", Event_PlayerDeath, EventHookMode_Pre)
HookEvent("item_pickup" , Event_ItemPickup)
HookEvent("post_inventory_application" , Event_Resupply)
HookEvent("player_stealsandvich", Event_StealSandwich)
HookEvent("teamplay_round_start", Event_RoundStart)
HookEvent("teamplay_point_captured",Event_PointCaptured)
HookEvent("teamplay_flag_event",Event_FlagEvent)
HookEvent("killed_capping_player",Event_KilledCappingPlayer)
AddCommandListener(VoiceCommand , "voicemenu")
AddCommandListener(SayCommand, "say")
AddCommandListener(SayCommand, "say_team")
meleeOnlyAllowed = CreateConVar("hassault_melee_only","0","Enable/disable melee mode")
hideCustomWeapons = CreateConVar("hassault_hide_custom_viewmodels","0","Hide viewmodels for non-heavy weapons")
HoovyScores[0] = HoovyScores[1] = 0
#if GBW_STAGING
GBW_Staging_OnPluginStart()
#endif
#if SPELLS_STAGING
Spells_OnPluginStart()
#endif
#if HOOVY_CLASSAPI_ENABLED
Hoovyassault_Classapi_Init()
#endif
}
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
if (GetEngineVersion() != Engine_TF2)
{
Format(error, err_max, "This plugin only works for Team Fortress 2.")
return APLRes_Failure
}
CreateNative("GetHoovyClass",NativeGetHoovyClass)
CreateNative("SetHoovyClass",NativeSetHoovyClass)
CreateNative("AddHoovyScores",NativeAddHoovyScores)
CreateNative("WithdrawHoovyScores",NativeWithdrawHoovyScores)
CreateNative("GetHoovyScores", NativeGetHoovyScores)
CreateNative("SetHoovyScores", NativeSetHoovyScores)
CreateNative("SetHoovyPrimary", NativeSetAllowPrimary)
CreateNative("SetHoovyClassRestriction", NativeSetHoovyClassRestriction)
#if HOOVY_CLASSAPI_ENABLED
Hoovyassault_Classapi_Create_Natives()
#endif
return APLRes_Success
}
public OnMapStart()
{
PrecacheSound(SOUND_BOOM)
PrecacheSound(SOUND_RJUMP)
PrecacheSound(SOUND_HEAL)
BeamSprite[0] = PrecacheModel("materials/sprites/healbeam_blue.vmt")
BeamSprite[1] = PrecacheModel("materials/sprites/healbeam.vmt")
HaloSprite = PrecacheModel("materials/sprites/glow02.vmt")
for(int i = 0 ; i < BOOMER_VO_NUM; i++)
{
PrecacheSound(boomer_sounds[i])
}
#if SPELLS_STAGING
Spells_OnMapStart()
#endif
}
public Action OnPlayerRunCmd(int client,int &buttons)
{
#if SPELLS_STAGING
if(ForceJump[client])buttons|=IN_JUMP
#endif
if(!(buttons&IN_ATTACK2)||!ValidUser(client)||HoovySpecialDelivery[client])return Plugin_Continue
if(HoovyClass[client]==HOOVY_BOOMER)
{
if(getActiveSlot(client)!=TFWeaponSlot_Secondary)return Plugin_Continue
HoovySpecialDelivery[client] = true
float expltime = GetURandomFloat()*3.0
PrintToChatAll("An explosive sandwich has been deployed in this area. Time to take cover, probably.")
CreateTimer(expltime>1.0?expltime:1.0,ExplosiveSandwichTimer,client)
EmitSoundToAll(boomer_sounds[GetRandomInt(0,BOOMER_VO_NUM-1)],client)
}
else if(HoovyClass[client]==HOOVY_LEAPER)
{
static float angles[3],vel[3],fwd[3],right[3],up[3],cur[3]
vel[0]=vel[1]=vel[2]=0.0
GetEntPropVector(client, Prop_Data, "m_vecVelocity", cur)
GetClientAbsAngles(client,angles)
GetAngleVectors(angles,fwd,right,up)
AddVectors(vel,fwd,vel)
AddVectors(vel,right,vel)
AddVectors(vel,up,vel)
ScaleVector(vel,LEAPER_VEL)
AddVectors(vel,cur,vel)
setPlayerSpeed(client,1.0)
if(vel[2]>0)
{
GetClientAbsOrigin(client,cur)
EmitSoundToAll(SOUND_RJUMP,SOUND_FROM_WORLD,SNDCHAN_AUTO,SNDLEVEL_NORMAL,SND_NOFLAGS,SNDVOL_NORMAL,SNDPITCH_NORMAL,-1,cur)
HoovySpecialDelivery[client] = true
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vel)
CreateTimer(12.0,Timer_ResetJumping,client)
}
//setPlayerSpeed(client,LEAPER_SPEED)
return Plugin_Handled
}
return Plugin_Continue
}
public Action OnTakeDamage(iVictim, &iAttacker, &inflictor, &Float:damage, &damagetype, &weapon, Float:damageForce[3], Float:damagePosition[3], damagecustom)
{
static bool validVictim
validVictim = ValidUser(iVictim)
if(!ValidUser(iAttacker))return Plugin_Continue
#if HOOVY_CLASSAPI_ENABLED
static Action APIResult
APIResult = Hoovyassault_Classapi_TakeDamage(iVictim,iAttacker,inflictor,damage,damagetype,weapon)
if(APIResult!=Plugin_Continue)return APIResult
#endif
if(HoovyClass[iAttacker]==HOOVY_GNOME&&(damagetype&DMG_BURN))return Plugin_Continue
if(HoovyFlags[iAttacker]&HOOVY_BIT_DMGBONUS)damage *= OFFICER_DMGBONUS
if(validVictim)
{
if(HoovyFlags[iVictim]&HOOVY_BIT_DMGRES)damage *= COMISSAR_DMGRES
#if HOOVY_CLASSAPI_ENABLED
OnClassApi(iVictim,damage = damage * HoovyExtraClassParams[ClassApiIndex(HoovyClass[iVictim])][Char_Dmgrespenalty])
else
#endif
damage = damage * ClassChars[HoovyClass[iVictim]][Char_Dmgrespenalty]
}
#if GBW_STAGING
if(HoovyClass[iAttacker]==HOOVY_COMISSAR&&getActiveSlot(iAttacker)==TFWeaponSlot_Secondary)damage = damage * 1.25
else
#endif
#if HOOVY_CLASSAPI_ENABLED
OnClassApi(iAttacker,damage = damage * HoovyExtraClassParams[ClassApiIndex(HoovyClass[iAttacker])][Char_Dmgbonus])
else
#endif
damage = damage * ClassChars[HoovyClass[iAttacker]][Char_Dmgbonus]
if((validVictim&&HoovyClass[iVictim]==HOOVY_BOXER)||HoovyClass[iAttacker]==HOOVY_BOXER)
{
if(TF2_GetClientTeam(iAttacker)!=TF2_GetClientTeam(iVictim)&&(damagetype&DMG_CLUB))
{
damage = validVictim?float(GetClientHealth(iVictim)):(damage*2)
}
}
if(HoovyClass[iAttacker]==HOOVY_TRUMPETER)
{
HoovyRage[iAttacker] = min(HoovyRage[iAttacker]+RoundToFloor(damage), TRUMPETER_DAMAGENEEDED)
}
else if(HoovyClass[iAttacker]==HOOVY_ENGINEER&&weapon == GetPlayerWeaponSlot(iAttacker,TFWeaponSlot_Secondary))
{
damage *= float(GetClientHealth(iAttacker))/HoovyMaxHealth[iAttacker]
}
return Plugin_Changed
}
public Action OnTraceAttack(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &ammotype, int hitbox, int hitgroup)
{
if(!ValidUser(victim)||!ValidUser(attacker)||TF2_GetClientTeam(attacker)!=TF2_GetClientTeam(victim)||HoovyClass[attacker]!=HOOVY_MEDIC)return Plugin_Continue
static int health, maxhealth
health = GetClientHealth(victim)
maxhealth = RoundToFloor(HoovyMaxHealth[victim]) + MEDIC_OVERHEAL
if(health>maxhealth)return Plugin_Continue
SetEntityHealth(victim,min(health+MEDIC_FIST_HEAL,maxhealth))
SetEntPropFloat(attacker,Prop_Send,"m_flNextAttack",GetGameTime()+ MEDIC_HEAL_FIST_DELAY)
EmitSoundToAll(SOUND_HEAL,victim)
return Plugin_Handled
}
public Action OnGetMaxHealth(int client, int &maxHealth)
{
maxHealth = RoundToFloor(HoovyMaxHealth[client])
int sandwich = GetPlayerWeaponSlot(client,TFWeaponSlot_Secondary)
if(sandwich!=-1&&IsFood(sandwich)&&getItemIndex(sandwich)==159&&HasEntProp(sandwich,Prop_Send,"m_iPrimaryAmmoType"))
{
int offs = GetEntProp(sandwich, Prop_Send, "m_iPrimaryAmmoType",1)
int iAmmo = FindSendPropInfo("CTFPlayer","m_iAmmo")
if(iAmmo!=-1&&offs!=-1&&(!GetEntData(client,iAmmo+(offs*4),4)))maxHealth += 50 // better than nothing
}
return Plugin_Changed
}
public Action OnWeaponSwitch(int client, int weapon)
{
if(!CanHaveSecondary(client))
{
if(IsValidEntity(weapon))
{
static int melee
melee = GetPlayerWeaponSlot(client,TFWeaponSlot_Melee)
if(weapon==melee)return Plugin_Continue
}
return Plugin_Handled
}
static int machinegun
machinegun = GetPlayerWeaponSlot(client, TFWeaponSlot_Primary)
if(weapon == machinegun)
{
/*static int shotgun, melee, active
shotgun = GetPlayerWeaponSlot(client, TFWeaponSlot_Secondary)
melee = GetPlayerWeaponSlot(client, TFWeaponSlot_Melee)
active = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon")
if(active == shotgun)SetEntPropEnt(client, Prop_Send, "m_hActiveWeapon", melee)
else SetEntPropEnt(client, Prop_Send, "m_hActiveWeapon", shotgun)*/
return Plugin_Handled
}
return Plugin_Continue
}
public void OnWeaponCanSwitchToPost(int client, int weapon)
{
if(!hideCustomWeapons.BoolValue)return
static int index
index = getItemIndex(weapon)
if(index==-1)return
switch(index)
{
case 11,199,42,159,311,425,433,863,1002,1141,1153,1190,15003,15016,15044,15047,15085,15109,15132,15133,15152,5,195,43,239,264,310,331,423,426,474,587,656,880,939,954,1013,1071,1084,1100,1123,1127,1184,30758:SetEntProp(client,Prop_Send,"m_bDrawViewmodel",1);
default: SetEntProp(client,Prop_Send,"m_bDrawViewmodel",0);
}
}
public Action Event_PlayerDeath(Handle:hEvent, const String:strEventName[], bool:bDontBroadcast)
{
int iVictim = GetClientOfUserId(GetEventInt(hEvent, "userid"))
int iAttacker = GetClientOfUserId(GetEventInt(hEvent,"attacker"))
if(iVictim>=1&&iVictim<=MaxClients)
{
MadeHisChoice[iVictim] = false
DestroyClientBuildings(iVictim,"obj_sentrygun")
if(iVictim!=iAttacker)
{
AddScores(iVictim,1)
if(ValidUser(iAttacker))AddScores(iAttacker,2)
}
}
return Plugin_Continue
}
public Action Event_KilledCappingPlayer(Handle:hEvent, const String:strEventName[], bool:bDontBroadcast)
{
int killer = GetEventInt(hEvent,"killer")
if(ValidUser(killer))AddScores(killer,1)
return Plugin_Continue
}
public Action Event_ItemPickup(Handle:hEvent, const String:strEventName[], bool:bDontBroadcast)
{
int user = GetClientOfUserId(GetEventInt(hEvent, "userid"))
static char itemid[28]
GetEventString(hEvent,"item",itemid,sizeof itemid)
if(HoovyClass[user] != HOOVY_SCOUT)return Plugin_Continue
if(StrContains(itemid,"medkit",false)!=-1)SetEntityHealth(user,RoundToFloor(getMaxHealth(user)))
return Plugin_Continue
}
public Action Event_PlayerSpawn(Handle:hEvent, const String:strEventName[], bool:bDontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(hEvent, "userid"))
HoovySpecialDelivery[client] = false
HoovyMaxHealth[client] = getMaxHealth(client)
HoovyRage[client] = 0
BannerDeployed[client] = false
HoovyPrimaryUnrestricted[client] = false
HoovyClassUnrestricted[client] = false
if(ValidUser(client))
{
CreateTimer(2.0,Timer_AfterSpawn,client)
}
return Plugin_Continue
}
public Action Event_FlagEvent(Handle:hEvent, const String:strEventName[], bool:bDontBroadcast)
{
int user = GetEventInt(hEvent,"player")
int eventtype = GetEventInt(hEvent,"eventtype")
switch(eventtype)
{
case(TF_FLAGEVENT_CAPTURED):AddScores(user,20);
case(TF_FLAGEVENT_DEFENDED):AddScores(user,5);
}
return Plugin_Continue
}
public Action Event_PointCaptured(Handle:hEvent, const String:strEventName[], bool:bDontBroadcast)
{
TFTeam team = view_as<TFTeam>(GetEventInt(hEvent,"team"))
int index = team==TFTeam_Blue?1:0
HoovyScores[index] = min(HoovyScores[index]+8,HOOVY_POINTS_LIMIT)
PrintToChatAll("Team %s gets 8 points for capturing the point. Current balance: %i",index?"BLU":"RED",HoovyScores[index])
return Plugin_Continue
}
public Action Event_RoundStart(Handle:hEvent, const String:strEventName[], bool:bDontBroadcast)
{
HoovyScores[0] = HoovyScores[1] = 0
for(int i=1;i<MaxClients;i++)
{
HoovyFlags[i] = 0
MadeHisChoice[i] = false
}
#if SPELLS_STAGING
Spells_RoundStart()
#endif
return Plugin_Continue
}
public Action Event_Resupply(Handle:hEvent, const String:strEventName[], bool:bDontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(hEvent, "userid"))
RemoveUnwantedWeapons(client)
HoovySpecialDelivery[client] = false
return Plugin_Continue
}
public Action Event_StealSandwich(Handle:hEvent, const String:strEventName[], bool:bDontBroadcast)
{
int owner = GetClientOfUserId(GetEventInt(hEvent,"owner"))
int target = GetClientOfUserId(GetEventInt(hEvent,"target"))
if(HoovyClass[owner]==HOOVY_BOOMER)// I have a new way to kill cowards!
{
PrintToChatAll("Ooops, somebody just stepped on the wrong sandwich")
ExplodeSandwich(target,owner)
}
return Plugin_Continue
}
public OnClientConnected(id)
{
HoovyClass[id] = HOOVY_SOLDIER
HoovyFlags[id] = 0
HoovyRage[id] = 0
HoovySpecialDelivery[id] = false
HoovyPrimaryUnrestricted[id] = false
HoovyClassUnrestricted[id] = false
MadeHisChoice[id] = false
HoovyVisuals[id] = true
BannerDeployed[id] = false
}
public OnClientPutInServer(client)
{
doSDKHooks(client)
}
public void OnClientDisconnect(int client)
{
removeSDKHooks(client)
HoovyPrimaryUnrestricted[client] = false
HoovyClassUnrestricted[client] = false
HoovyVisuals[client] = false
HoovyValid[client] = false
DestroyClientBuildings(client, "obj_sentrygun")
DestroyClientBuildings(client, "obj_dispenser")
}
public removeSDKHooks(client)
{
SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage)
SDKUnhook(client, SDKHook_GetMaxHealth,OnGetMaxHealth)
SDKUnhook(client, SDKHook_TraceAttack, OnTraceAttack)
if(IsFakeClient(client))SDKUnhook(client, SDKHook_WeaponSwitch, OnWeaponSwitch)
else SDKUnhook(client, SDKHook_WeaponCanSwitchToPost, OnWeaponCanSwitchToPost)
}
public doSDKHooks(client)
{
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage)
SDKHook(client, SDKHook_GetMaxHealth,OnGetMaxHealth)
SDKHook(client, SDKHook_TraceAttack, OnTraceAttack)
if(IsFakeClient(client))SDKHook(client, SDKHook_WeaponSwitch, OnWeaponSwitch)
else SDKHook(client, SDKHook_WeaponCanSwitchToPost, OnWeaponCanSwitchToPost)
}
public ShowMainMenu(id)
{
if(!ValidUser(id))return
CancelClientMenu(id)
Menu menu = CreateMenu(MainMenuHandler)
menu.SetTitle("Hoovy Class menu")
char strinfo[2]
strinfo[1] = '\0'
for(int i=0;i<NUM_CLASSES;i++)
{
if(!CanPickClass(id,i))continue;
strinfo[0] = i
menu.AddItem(strinfo,ClassName[i])
}
#if HOOVY_CLASSAPI_ENABLED
for(int i=0;i<NumHoovyClasses;i++)
{
if(HoovyExtraClassLimit[i]==-2)continue
strinfo[0] = i+NUM_CLASSES
menu.AddItem(strinfo,HoovyExtraClassName[i])
}
#endif
strinfo[0]++
menu.AddItem(strinfo, "Help")
strinfo[0]++
menu.AddItem(strinfo, HoovyVisuals[id]?"Hide medic beams":"Show medic beams")
strinfo[0]++
menu.AddItem(strinfo, "Source code")
menu.ExitBackButton = false
menu.ExitButton = true
menu.Display( id, MENU_TIMEOUT)
}
public MainMenuHandler(Handle menuid, MenuAction action, id, menu_item)
{
if(action == MenuAction_End)CloseHandle(menuid)
else if(action == MenuAction_Select)
{
char strinfo[2]
GetMenuItem(menuid, menu_item, strinfo, sizeof(strinfo))
int result = strinfo[0]
#if HOOVY_CLASSAPI_ENABLED
if(result<(NUM_CLASSES+NumHoovyClasses))
#else
if(result<NUM_CLASSES)
#endif
{
if(!CanPickClass(id,result))
{
PrintToChat(id,"Sorry, but the team can\'t have any more members of this class")
ShowMainMenu(id)
return
}
MadeHisChoice[id] = true
HoovyClass[id] = result
HoovyMaxHealth[id] = getMaxHealth(id)
SetEntityHealth(id,RoundToFloor(HoovyMaxHealth[id]))
TF2_RespawnPlayer(id)
PrintToChat(id,"You will be able to pick other class after death")
}
#if HOOVY_CLASSAPI_ENABLED
else if(result==NUM_CLASSES+NumHoovyClasses)ShowHelp(id,true)
else if(result==NUM_CLASSES+NumHoovyClasses+1)
{
HoovyVisuals[id] = !HoovyVisuals[id]
ShowMainMenu(id)
}
else if(result==NUM_CLASSES+NumHoovyClasses+2)
{
PrintToChat(id,"You can download the source code at https://github.com/le0nklcpp/hoovyassault")
PrintToChat(id,"Note that the modification is licensed under GNU General Public License version 3.0")
ShowMainMenu(id)
}
#else
else switch(result){
case(NUM_CLASSES):
{
ShowHelp(id,true)
}
case(NUM_CLASSES+1):
{
HoovyVisuals[id] = !HoovyVisuals[id]
ShowMainMenu(id)
}
case(NUM_CLASSES+2):
{
PrintToChat(id,"You can download the source code at https://github.com/le0nklcpp/hoovyassault")
PrintToChat(id,"Note that the modification is licensed under GNU General Public License version 3.0")
ShowMainMenu(id)
}
}
#endif
}
}
public ShowHelp(id,bool canreturn)
{
if(!ValidUser(id))return
CancelClientMenu(id)
Menu menu = CreateMenu(HelpHandler)
menu.SetTitle("Classes information")
char strinfo[3]
strinfo[1] = canreturn?1:0
strinfo[2] = '\0'
for(int i=0;i<NUM_CLASSES;i++)
{
if(ClassLimit[i]==-2)continue;
strinfo[0] = i
menu.AddItem(strinfo,ClassName[i])
}
#if HOOVY_CLASSAPI_ENABLED
for(int i=0;i<NumHoovyClasses;i++)
{
if(HoovyExtraClassLimit[i]==-2)continue
strinfo[0] = i+NUM_CLASSES
menu.AddItem(strinfo,HoovyExtraClassName[i])
}
#endif
menu.ExitButton = true
if(canreturn)menu.ExitBackButton = true
menu.Display( id, MENU_TIMEOUT*3)
}
public HelpHandler(Handle menuid, MenuAction action, id, menu_item)
{
if(action == MenuAction_End)CloseHandle(menuid)
if(action == MenuAction_Cancel&&!MadeHisChoice[id])ShowMainMenu(id)
if(action == MenuAction_Select)
{
char strinfo[3]
GetMenuItem(menuid, menu_item, strinfo, sizeof(strinfo))
ShowClassHelp(id,strinfo[0],strinfo[1]==1?true:false)
}
}
public ShowClassHelp(id,classid,bool canreturn)
{
if(!ValidUser(id))return
CancelClientMenu(id)
Menu menu = CreateMenu(ClassHelpHandler)
#if HOOVY_CLASSAPI_ENABLED
if(classid>=NUM_CLASSES)menu.SetTitle(HoovyExtraClassName[ClassApiIndex(classid)])
else
#endif
menu.SetTitle(ClassName[classid])
char strinfo[2]
strinfo[0] = canreturn?1:0
strinfo[1] = '\0'
#if HOOVY_CLASSAPI_ENABLED
if(classid>=NUM_CLASSES)menu.AddItem(strinfo,HoovyExtraClassDesc[ClassApiIndex(classid)])
else
#endif
menu.AddItem(strinfo,ClassDescription[classid])
menu.ExitBackButton = true
menu.ExitButton = false
menu.Display(id , MENU_TIMEOUT*4)
}
public ClassHelpHandler(Handle menuid, MenuAction action, id, menu_item)
{
if(action == MenuAction_End)CloseHandle(menuid)
else{
char strinfo[2]
GetMenuItem(menuid, menu_item, strinfo, sizeof(strinfo))
if(action == MenuAction_Cancel||action == MenuAction_Select)
{
ShowHelp(id,strinfo[1]?true:false)
}
else if(strinfo[1])ShowMainMenu(id)
}
}
public TryHealing(id)
{
HoovyMaxHealth[id] = getMaxHealth(id)
if(((HoovyFlags[id]&HOOVY_BIT_HEALING)&&!(HoovyFlags[id]&HOOVY_BIT_BLOCK_HEALING))||HoovyClass[id]==HOOVY_MEDIC)
{
static int clienthealth,maxhealth
clienthealth = GetClientHealth(id)
maxhealth = RoundToFloor(HoovyMaxHealth[id])
if(clienthealth<maxhealth)
{
SetEntityHealth(id,min(clienthealth+RoundToFloor(MEDIC_HEAL*MEDIC_TICK),maxhealth))
AttachParticle(id,TF2_GetClientTeam(id) == TFTeam_Red?"healthgained_red":"healthgained_blu","head",_,HOOVY_CYCLE_TIME);
}
}
//if(GetClientHealth(id)>RoundToFloor(HoovyMaxHealth[id]))SetEntityHealth(id,RoundToFloor(HoovyMaxHealth[id]))
}
public HoovyBasicOperations()
{
static int i
for(i = 1;i < MaxClients;i++)
{
if(!ValidUser(i))
{
HoovyValid[i] = false
continue
}
HoovyValid[i] = true
HoovyFlags[i] = 0
GetClientAbsOrigin(i, HoovyCoords[i])
RemoveUnwantedWeapons(i)
if(IsFakeClient(i)&&(!CanHaveSecondary(i)))setActiveSlot(i,TFWeaponSlot_Melee) // force medic bot to use melee
#if HOOVY_CLASSAPI_ENABLED
if(HoovyClass[i]>=NUM_CLASSES)Hoovyassault_Classapi_Think(i)
else
#endif
switch(HoovyClass[i])
{
case(HOOVY_SCOUT):TF2_AddCondition(i, TFCond_SpeedBuffAlly, HOOVY_CYCLE_TIME+0.1);
case(HOOVY_LEAPER):if(!HoovySpecialDelivery[i])TF2_StunPlayer(i,HOOVY_CYCLE_TIME+0.1,0.3,TF_STUNFLAG_SLOWDOWN);
case(HOOVY_BOXER):
{
if(getItemIndex(GetPlayerWeaponSlot(i, TFWeaponSlot_Melee))==43)TF2_AddCondition(i,TFCond_MarkedForDeathSilent,HOOVY_CYCLE_TIME+0.1)
}
case(HOOVY_TRUMPETER):
{
TF2_AddCondition(i,TFCond_MarkedForDeathSilent,HOOVY_CYCLE_TIME+0.1)
Handle hHudText = CreateHudSynchronizer()
SetHudTextParams(-1.0, 0.8, HOOVY_CYCLE_TIME, 255, 0, 0, 255)
ShowSyncHudText(i, hHudText, "Buff:%i/%i",HoovyRage[i],TRUMPETER_DAMAGENEEDED)
CloseHandle(hHudText);
if(!BannerDeployed[i]&&HoovyRage[i]==TRUMPETER_DAMAGENEEDED&&IsFakeClient(i))BannerDeployed[i] = true
if(BannerDeployed[i])
{
HoovyRage[i]-=RoundToFloor(float(TRUMPETER_DAMAGENEEDED)/float(TRUMPETER_BUFFTIME)/(1.0/HOOVY_CYCLE_TIME))
if(HoovyRage[i]<=0)
{
BannerDeployed[i] = false
HoovyRage[i] = 0
}
}
}
case(HOOVY_ENGINEER):
{
Handle hHudText = CreateHudSynchronizer()
SetHudTextParams(-1.0, 0.8, HOOVY_CYCLE_TIME, 255, 0, 0, 255)
ShowSyncHudText(i, hHudText, "Points:%i",HoovyScores[TeamScoresIndex(i)])
CloseHandle(hHudText);
}
case(HOOVY_GNOME):
{
TF2_AddCondition(i,TFCond_HalloweenTiny,HOOVY_CYCLE_TIME+0.1)
}
}
}
}
public RemoveUnwantedWeapons(i)
{
static int weapon
if(!IsFakeClient(i))
{
static bool allowsecondary
allowsecondary = CanHaveSecondary(i)
if(!HoovyPrimaryUnrestricted[i]&&getActiveSlot(i)==TFWeaponSlot_Primary)
{
setActiveSlot(i,(!allowsecondary)?TFWeaponSlot_Melee:TFWeaponSlot_Secondary)
TF2_RemoveWeaponSlot(i,TFWeaponSlot_Primary) // Anti-repick protection
}
weapon = GetPlayerWeaponSlot(i, TFWeaponSlot_Secondary)
if(!allowsecondary)
{
if(weapon!=-1&&!IsFood(weapon))
{
TF2_RemoveWeaponSlot(i,TFWeaponSlot_Secondary)
// setActiveSlot(i,TFWeaponSlot_Melee) // uncomment to disable a-posing
}
}
#if GBW_STAGING
else if(HoovyClass[i]==HOOVY_COMISSAR)
{
if(weapon!=-1&&getItemIndex(weapon)!=16)
{
TF2_RemoveWeaponSlot(i,TFWeaponSlot_Secondary)
if(!CreateWeapon(i,"tf_weapon_smg",16,1))
{
//LogError("Failed to create tf_weapon_smg")
}
else {
setActiveSlot(i,TFWeaponSlot_Secondary)
SetAmmo(i,GetPlayerWeaponSlot(i,TFWeaponSlot_Secondary),100)
}
}
}
#endif
}
}
public CheckBuffZones()
{
static int i,j
for(i = 1;i < MaxClients;i++)
{
if(!HoovyValid[i])continue;
for(j = 1; j < MaxClients; j++)
{
if(!HoovyValid[j]||HoovyClass[j] == HOOVY_SOLDIER||HoovyClass[j] == HOOVY_SCOUT||TF2_GetClientTeam(i)!=TF2_GetClientTeam(j)||(i==j&&HoovyClass[j]!=HOOVY_TRUMPETER))continue;
if(GetVectorDistance(HoovyCoords[i],HoovyCoords[j])<=HOOVY_EFFECTS_RADIUS)
switch(HoovyClass[j])
{
case(HOOVY_MEDIC):
{
if(!(HoovyFlags[i]&HOOVY_BIT_HEALING))
{
HoovyFlags[i] |= HOOVY_BIT_HEALING
Beam(i,j)
}
}
case(HOOVY_COMISSAR):
{
HoovyFlags[i] |= HOOVY_BIT_DMGRES
HoovyFlags[i] |= HOOVY_BIT_OVERHEAL
}
case(HOOVY_OFFICER):
{
HoovyFlags[i]|=HOOVY_BIT_DMGBONUS
}
case(HOOVY_TRUMPETER):
{
if(BannerDeployed[j])
{
TF2_AddCondition(i,TFCond_DefenseBuffed,HOOVY_CYCLE_TIME+0.1)
TF2_AddCondition(i,TFCond_CritOnFirstBlood,HOOVY_CYCLE_TIME+0.1)
}
}
}
}
}
}
public bool CanHaveSecondary(int client)
{
#if HOOVY_CLASSAPI_ENABLED
if(HoovyClass[client]>=NUM_CLASSES)
{
return !(meleeOnlyAllowed.BoolValue||HoovyExtraClassMeleeOnlyAccess[ClassApiIndex(HoovyClass[client])])
}
#endif
return !(meleeOnlyAllowed.BoolValue||HoovyClass[client]==HOOVY_MEDIC||HoovyClass[client]==HOOVY_BOOMER||HoovyClass[client]==HOOVY_GNOME);
}
public bool CanPickClass(int client,int class)
{
#if HOOVY_CLASSAPI_ENABLED
if(class>=NUM_CLASSES)return (!HoovyExtraClassLimit[ClassApiIndex(class)]||(HoovyExtraClassLimit[ClassApiIndex(class)]>countClass(client,class)))
#endif
return (!ClassLimit[class])||(ClassLimit[class]>countClass(client,class))
}
bool AttemptToBuy(int client,int amount,bool as_team=false)
{
int index = as_team?(view_as<TFTeam>(client)==TFTeam_Blue?1:0):TeamScoresIndex(client)
if(HoovyScores[index]>=amount)
{
HoovyScores[index] -= amount
return true
}
return false
}
public GetScores(client)
{
return HoovyScores[TeamScoresIndex(client)]
}
public AddScores(int client,int scores)
{
int index = TeamScoresIndex(client)
HoovyScores[index] = min(HoovyScores[index]+scores,HOOVY_POINTS_LIMIT)
}
public Action Timer_ResetJumping(Handle timer,int client)
{
HoovySpecialDelivery[client] = false
return Plugin_Stop
}
public Action Timer_RemoveSandwich(Handle timer, int client)
{
int ent = findMySandwich(client)
if(ent!=-1&&IsValidEntity(ent))AcceptEntityInput(ent, "Kill")
return Plugin_Stop
}
public Action ExplosiveSandwichTimer(Handle timer,int client)
{
HoovySpecialDelivery[client] = false
static int entity
entity = findMySandwich(client)
if(entity==-1)return Plugin_Stop
ExplodeSandwich(entity,client)
CreateTimer(1.0,Timer_RemoveSandwich,client)
return Plugin_Stop
}
public Action HealTimer(Handle timer)
{
static int i
for(i=1;i<MaxClients;i++)if(ValidUser(i))TryHealing(i)
return Plugin_Continue
}
public Action Timer_DeleteParticle(Handle:hTimer, any:iRefEnt)
{
new iEntity = EntRefToEntIndex(iRefEnt);
if(iEntity > MaxClients)
{
AcceptEntityInput(iEntity, "Kill");
}
return Plugin_Handled;
}
public Action UpdateHoovies(Handle timer)
{
HoovyBasicOperations()
CheckBuffZones()
return Plugin_Continue
}
public Action Timer_AfterSpawn(Handle timer, client)
{
if(!ValidUser(client))return Plugin_Continue
if(!IsFakeClient(client))
{
if(!MadeHisChoice[client])ShowMainMenu(client)
}
else HoovyClass[client] = PickBotClass(client)
#if HOOVY_CLASSAPI_ENABLED
if(HoovyClass[client]>=NUM_CLASSES)
{
if(!Hoovyassault_Classapi_OnSpawn(client))
{
MadeHisChoice[client] = false
HoovyClass[client] = HOOVY_SOLDIER
TF2_RespawnPlayer(client)
}
}
if(TF2_GetPlayerClass(client)!=TFClass_Heavy&&!HoovyClassUnrestricted[client])
{
MadeHisChoice[client] = false
TF2_SetPlayerClass(client, TFClass_Heavy)
TF2_RespawnPlayer(client)
}
#endif
return Plugin_Continue
}
public Action VoiceCommand(client, const String:command[], argc)
{
if(!ValidUser(client))return Plugin_Continue
static char Numbers[32] // thats even too much
GetCmdArgString(Numbers, sizeof(Numbers))
TrimString(Numbers)
if(!StrEqual(Numbers,"1 4"))
{
if(!StrEqual(Numbers,"1 5"))return Plugin_Continue
if(HoovyClass[client] == HOOVY_ENGINEER)
{