/
war3source.inc
2640 lines (2308 loc) · 90 KB
/
war3source.inc
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
/**
* File: war3source.inc
* Description: The file to be included for creating races and whatnot.
* Author(s): Anthony Iacono
*
*
* LISTS NATIVES AND FORWARDS, BUT NOT ACTUALLY DEFINES THE CODE
*/
#if defined _War3Source_included
#endinput
#endif
#define _War3Source_included
#pragma semicolon 1
#define W3GAMETITLE "War3Source:EVO"
//#undef REQUIRE_EXTENSIONS
#include <switchgamemode>
#include <steamIDconverter>
#include <sourcemod>
//#pragma newdecls optional
#include <sdkhooks>
#include <sdktools>
#include <sdktools_functions>
#if (GGAMETYPE == GGAME_TF2)
#include <tf2>
#include <tf2_stocks>
#include <morecolors>
#elseif (GGAMETYPE == GGAME_FOF)
#include <morecolors>
#elseif (GGAMETYPE == GGAME_CSGO)
#include <cstrike>
#include <colors>
#elseif (GGAMETYPE == GGAME_CSS)
#include <cstrike>
#include <morecolors>
#else
#include <colors>
#endif
#include <keyvalues>
#include <DiabloStocks>
#include <war3source_paused>
//#pragma newdecls required
//#include "switchgamemode.inc"
#include "War3Source/include/War3Source_Constants.inc"
#include "War3Source/include/War3Source_PlayerProp.inc"
#include "War3Source/include/War3Source_Races.inc"
// natives natives natives natives natives natives natives natives natives natives natives natives natives natives
// natives natives natives natives natives natives natives natives natives natives natives natives natives natives
// natives natives natives natives natives natives natives natives natives natives natives natives natives natives
// natives natives natives natives natives natives natives natives natives natives natives natives natives natives
// natives natives natives natives natives natives natives natives natives natives natives natives natives natives
// natives natives natives natives natives natives natives natives natives natives natives natives natives natives
// natives natives natives natives natives natives natives natives natives natives natives natives natives natives
// natives natives natives natives natives natives natives natives natives natives natives natives natives natives
// natives natives natives natives natives natives natives natives natives natives natives natives natives natives
// natives natives natives natives natives natives natives natives natives natives natives natives natives natives
// natives natives natives natives natives natives natives natives natives natives natives natives natives natives
// natives natives natives natives natives natives natives natives natives natives natives natives natives natives
// natives natives natives natives natives natives natives natives natives natives natives natives natives natives
// natives natives natives natives natives natives natives natives natives natives natives natives natives natives
native bool:War3_SetCollidable(client,bool:SetCollidable);
///NOTE: U NEED TO PASS 'YOUR' FACTION/RACE WHATEVER AS THE FIRST PARAM!!!
//Creates(or just returns the factionid) a (new) faction behavior
native W3Faction(raceid,String:strFactionName[],bool:bCreateIfNotExist=true);
//Changes(or just returns when using relation == ReturnValue) the relation of 2 factions (by id)
native any:W3FactionRelation(faction1,faction2,FactionBehavior:relation=ReturnValue);
//Changes(or just returns when using relation == ReturnValue) the relation of 2 factions (by name)
native any:W3FactionBehaviorByName(String:strFactionName1[],String:strFactionName2[],FactionBehavior:relation=ReturnValue);
//Compares 2 Races and returns the FacitonBehavior id
native any:W3FactionCompare(race1,race2);
//Returns the factionname of a race
native W3GetRaceFaction(race,String:strReturn[],maxsize);
native bool:War3_IsNewPlayer(client);
#if (GGAMETYPE == GGAME_TF2)
native War3_ToggleCyborgSkin(client,bool:toggle);
#endif
native bool:War3_AddCustomModel(client,String:weapon[],modelIndex,mdltype);
native bool:War3_RemoveCustomModel(client,String:weapon[],mdltype);
native W3GetW3Version(String:retstr[],maxlen);//str
native W3GetW3Revision();//int
native W3GetStatsVersion();//int
//Socket functions
native W3Socket(String:url[],Function:callback);
native W3Socket2(String:url[],String:postdata[],Function:callback);
//forces weapon drop, given a weapon entity
native W3DropWeapon(client, weaponent);
/**
* Checks if we are in the freeze time. Certain games support this, like CS.
* @return True if so, false if not.
*
*/
#pragma deprecated
native bool:War3_InFreezeTime();
/* BEGIN GLOBAL VARS */
//retrieves specified values from the main war3 plugin, see W3Var enum in constants.inc, only those values are allowed
//this mostly used for accessing a variable without creating a special native just for it
//this returns any:, you should tag it if return value is not suppose to be normal integer. like Float:W3GetVar( or Handle:W3GetVar(
//most are temporary variables and this function should be called immidiately in the right functions
//examples W3GetVar(OldRace) W3GetVar(DeathRace)
//See W3Var enum in constants to get a list
//Do not get/set vars arbitrarily unless you know what you are doing
native any:W3GetVar(W3Var:variabletoretrieve);
native any:W3SetVar(W3Var:variabletoretrieve,any:value);
/* END GLOBAL VARS */
/*
War3_TFSetItemClasses(itemid, and then use ItemClassString separted by comma )
example:
War3_TFSetItemClasses(itemid,sniper,medic,scout)
if you want all classes then don't assign anything OR you can use:
War3_TFSetItemClasses(itemid,all)
As many classes that you want this item to have access to.
enum ItemClassString
{
all = TFClass_Unknown,
scout = TFClass_Scout,
sniper = TFClass_Sniper,
soldier = TFClass_Soldier,
demoman = TFClass_DemoMan,
medic = TFClass_Medic,
heavy = TFClass_Heavy,
pyro = TFClass_Pyro,
spy = TFClass_Spy,
engineer = TFClass_Engineer
}
*/
native War3_TFSetItemClasses(itemid,any:...);
// If TFClassType is set for TFClass_Unknown, then all classes have access to this item.
// use War3_TFIsItemClass(itemid,TF2_GetPlayerClass(client));
/*
01: enum TFClassType
02: {
03: TFClass_Unknown = 0,
04: TFClass_Scout,
05: TFClass_Sniper,
06: TFClass_Soldier,
07: TFClass_DemoMan,
08: TFClass_Medic,
09: TFClass_Heavy,
10: TFClass_Pyro,
11: TFClass_Spy,
12: TFClass_Engineer
13: };*/
native War3_TFIsItemClass(itemid,TFClassType:iPlayerClass);
//native W3ExtShowShop2(client);
/**
* Registers a help command with the War3Source:EVO plugin for war3help
* @param name: The name of the command. (max 64)
* @param desc: The description of the command. (max 256)
* @noreturn
*/
native War3_CreateHelpCommand(String:name[],String:desc[]);
native W3GetLevelsSpent(client, race);
native W3ClearSkillLevels(client, race);
/**
* When a player dies, this command record's their shopmenu1 items.
* When you use this command, you are telling it to restore their items from death.
* It does all the math as far as taking gold or cs money for items restored.
* It will let the client know what items are discarded and/or bought.
* It will also only buy until the client goes broke.
* If the client already owns some items from the list from death, it will not charge them.
* It only charges for the items that the client must buy to match the items from death.
* It discards items that does not match from the previous death list.
* Note: The no cost method still needs work.
* @param client: Client index
* @param payforit: false = no cost, true = charge
* @param csmoney: true is cs money, false for gold.
* @return The return value will be true if it is successful.
*/
native War3_RestoreItemsFromDeath(client,bool:payforit=true,bool:csmoney=false);
#if (GGAMETYPE == GGAME_TF2)
// Checks if a player is in steam group
// returns true if they are in steam group
native War3_IsInSteamGroup(client);
#endif
//native W3GetItem2ExpireTime(client, item);
//native W3SetItem2ExpireTime(client, item, time); //use full linux time , ie: NOW()+duration
native bool:W3BuyUseCSMoney();
/**
* Finds the best target within a player's view cone
* Can be limited by max distance
* function perfers closer target over a target that has less degrees
* @param client: Client index
* @param max_distance: Optional, set to 0 to allow unlimited distance
* @param include_friendlys: Optional, should we look for friendlys too?
* @param cone_angle: Optional, view cone angle, SDK default is 23.0 degrees.
* @param FilterFunction: Callback filter function, return false in this function to ignore entity.
*/
native War3_GetTargetInViewCone(client,Float:max_distance=0.0,bool:include_friendlys=false,Float:cone_angle=23.0,Function:FilterFunction=INVALID_FUNCTION,SkillID=0);
///traces from client to target and see if they are in view of each other (Line of Signt - LOS)
native W3LOS(client, target);
// MOVED TO W3PLAYERPROP.INC
/*
stock bool:ValidPlayer(client,bool:check_alive=false,bool:alivecheckbyhealth=false) {
if(client>0 && client<=MaxClients && IsClientConnected(client) && IsClientInGame(client))
{
if(check_alive && !IsPlayerAlive(client))
{
return false;
}
if(alivecheckbyhealth&&GetClientHealth(client)<1) {
return false;
}
return true;
}
return false;
} */
/**
* Respawns a dead player.
* @param client: Client's index.
* @param ignore_dead_check: Optional, ignore dead checking.
* @noreturn
*/
native War3_SpawnPlayer(client,bool:ignore_dead_check=false);
// THE FOLLOWING NATIVES RETRIEVE DATA CACHED ONGAMEFRAME!
// THE FUNCTIONS NAMED War3_CachedDead* ARE VALUES SET WHEN THE PLAYER DIES
// THESE ARE ADVANCED FUNCTIONS, CHANCES ARE IF U DON'T KNOW WHAT THEY MEAN
// YOU PROBABLY DON'T HAVE TO USE THEM
/**
* Get last cached player eye angle.
* @param client: Client index
* @param angle[3]: Output array
* @noreturn
*/
native War3_CachedAngle(client,Float:angle[3]);
/**
* Get last cached player position.
* @param client: Client index
* @param position[3]: Output array
* @noreturn
*/
native War3_CachedPosition(client,Float:position[3]);
/**
* Get last cached player ducking state.
* @param client: Client index
* @return True or false.
*/
native bool:War3_CachedDucking(client);
/**
* Get cached weapon entity based on iterator.
* This function is usually called from a loop.
* @param client: Client index
* @param weapon_iterator: Number from 0-9.
* @return Weapon entity, 0 if none.
*/
//native War3_CachedWeapon(client, weapon_iterator);
/**
* Get cached weapon entity "clip1" based on iterator.
* This function is usually called from a loop.
* @param client: Client index
* @param weapon_iterator: Number from 0-9.
* @return Value of clip1.
*/
//native War3_CachedClip1(client, weapon_iterator);
/**
* Get cached ammo of a player with a specific weapon ID.
* This function is usually called from a loop.
* @param client: Client index
* @param game_weapon_id: Game specific weapon identifier, this is constant for each weapon.
* @return Value of iAmmo.
*/
//native War3_CachedAmmo(client, game_weapon_id);
/**
* Get cached weapon entity "clip1" of iterator, only changes when a player dies.
* This function is usually called from a loop.
* @param client: Client index
* @param weapon_iterator: Number from 0-9.
* @return Value of clip1 from last death.
*/
//native War3_CachedDeadClip1(client, weapon_iterator);
/**
* Get cached ammo of a player with a specific weapon ID, only changes when a player dies.
* This function is usually called from a loop.
* @param client: Client index
* @param game_weapon_id: Game specific weapon identifier, this is constant for each weapon.
* @return Value of iAmmo from last death.
*/
//native War3_CachedDeadAmmo(client, game_weapon_id);
/**
* Get cached weapon name of iterator, only changes when a player dies.
* This function is usually called from a loop, sets output_buffer to "" if no weapon at iterator.
* @param client: Client index
* @param weapon_iterator: Number from 0-9.
* @param output_buffer: Output buffer
* @param output_size: Size of output buffer.
* @noreturn
*/
//native War3_CachedDeadWeaponName(client,weapon_iterator,String:output_buffer[],output_size);
#if (GGAMETYPE == GGAME_TF2)
/**
* Is player ubered (TF2)
* @param client:
* @return: true false
*/
native bool:War3_IsUbered(client);
/**
* Is player carrying intellegence
* @param client:
* @return: true false
*/
native bool:War3_HasFlag(client);
/**
* Is player cloaked
* @param client:
* @return: true false
*/
native bool:War3_IsCloaked(client);
#endif
//DELAY TRACKER
//DELAY TRACKER
//DELAY TRACKER
//DELAY TRACKER
//DELAY TRACKER
//DELAY TRACKER
///registers a tracker and returns an index that you must keep. usually do this for each each player or once if global
// Register once on plugin start please!
//returns -1 if tracker is full. LogErrors on Full
/*
usage:
register tracker
create delay
repeat:{
expired?
create delay
}
*/
native War3_RegisterDelayTracker();
//create a delay
native War3_TrackDelay(trackerIndex,Float:delay);
//did the delay expire?
native War3_TrackDelayExpired(trackerIndex);
///PLAYER TRACE
///PLAYER TRACE
///PLAYER TRACE
///PLAYER TRACE
///PLAYER TRACE
//get location of where the player is aiming (trace to the end of your crosshair)
native War3_GetAimEndPoint(client,Float:endpos[3]);
//get location of where the player is aiming (trace to the end of your crosshair) limited by distance
native War3_GetAimTraceMaxLen(client,Float:endpos[3],Float:maxdistance);
//simple weapon restriction: pass "weapon_knife,weapon_hegrenade" to only allow these weapons, separated by comma.
//pass "" to allow all weapons again
//c4 etc is automatically allowed
//to override other restrictions, use a higher priority
//use 1 priorty for ur base race restrictions, USE AT OWN RISK!
native War3_WeaponRestrictTo(client,raceid,String:onlyallowedweaponsnames[],priority=1);
//get weaponlist
native War3_GetWeaponRestriction(client,raceid,String:buffer[],maxlength);
native Float:W3GetPhysicalArmorMulti(client); //damage multipler for client by accounting for physical armor (warcraft physical armor, not cs armor)
native Float:W3GetMagicArmorMulti(client); //damage multipler for client by accounting for magic armor
native W3GetCurrentWeaponEnt(client); //get the entity of the current (active) weapon
//force all supported war3 plugins into failed mode (pause plugin)
//native War3Failed(String:reason[]);
/**
* Use this for getting a chance modifier in OnWar3TakeDamage!!
* This is a cvar based value used for lowering chance of skill activation when a weapon such as flamethrower inflicts damage many times over a period of time.
* If you are making a skill that has a high chance, example 1 in 10, it is advised to change it to something like 10 in 100 if using GetRandomInt, however if you are using GetRandomFloat with the chance modifier*original chance then it shouldn't be an issue.
* @param attacker: Attacker's client index.
* @param inflictor: Inflictor entity index. (ie sentry gun)
* @param damagetype: Type of damage.
* @return Float modifier, 1.0 for 100% chance otherwise percentage between 0.0 and 1.0
*/
/**
* print via hint engine. format accepts translations
*
* W3HintPriority:
* HINT_NORMAL, //things that are attached from non hint engine hints
* HINT_SKILL_STATUS, //"TELEPORTED!"
* HINT_DMG_DEALT,
* HINT_DMG_RCVD,
* HINT_COOLDOWN_NOTREADY,
* HINT_COOLDOWN_EXPIRED,
* HINT_COOLDOWN_COUNTDOWN,
* HINT_LOWEST,
* HINT_SIZE, //do not use this as priority
*
*/
native W3Hint(client,W3HintPriority:type=HINT_LOWEST,Float:duration=5.0,String:format[],any:...);
native War3_SetLevel(client, race, level);
native War3_GetLevel(client, race);
native War3_GetLevelEx(client, race, bool:trueLevel=false);
native W3GetTotalLevels(client); //sum of levels in each race
native W3GetLevelBank(client);
native W3SetLevelBank(client, newlevelbank);
/*
Gets the skill level of a generic skill
@client
@g_skill_id = generic skill id
@genericSkillData = array that the customer race passed to you (if any) when attaching itself to this generic skill
@customerRaceID = the matching race that is trying to use this generic skill
@customerSkillID = the matching skill id for the race trying to use this as generic skill
for example, if race 4 skill 3 is redirected as generic skill 2,
you should have passed 2 as g_skill_id
customerRaceID will be returned as 4
customerSkillID returns 3
*/
native W3_GenericSkillLevel(client,g_skill_id,&Handle:genericSkillData,&customerRaceID=0,&customerSkillID=0);
// MOVED TO W3PlayerProp.inc
//native W3SetPlayerProp(client,W3PlayerProp:property,any:value);
//native any:W3GetPlayerProp(client,W3PlayerProp:property);
//TKV = trie key value , a abstract data storage, emulates cvars for war3
///Creates internal war3 cvars. returns a id to your cvar, store it!
//cvarid of 0 is null null (filled auto)
//make sure native have binded (on plugin start is fine)
native W3CreateCvar(String:cvarstr[],String:cvarvalue[],String:cvardesc[],ReplaceCvar=0);
native W3GetCvar(cvarid,String:returnstr[],maxlen);
native W3SetCvar(cvarid,String:cvarvalue[]);
//returns -1 if not found, otherwise returns cvar id
native W3FindCvar(String:cvar[]);
native Handle:W3CvarList(); //returns a handle arraylist of cvar list (no values, names only. CLOSE THIS!!!
//get cvar value when you have the key
native W3GetCvarByString(String:cvarstr[],String:returnstr[],maxlen);
//get actual cvar name: undead_blah (the KEY)
native W3GetCvarActualString(cvarid,String:returnstr[],maxlen);
native W3IsDeveloper(client);
native W3IsHelper(client);
///use W3GetVar(hDatabase) to get the handle to the database which your xp is saved, so you dont have to connect again for your addon scipts
native bool:W3SaveEnabled();
native W3Log(const String:fmt[],any:...);
native W3LogError(const String:fmt[],any:...);
native W3LogNotError(const String:fmt[],any:...);
//Skills
native War3_SuicideBomber(client, Float:location[], Float:damage, race_skillid, Float:radius, bool:effect=true);
//disabled due to human race requirements..for now
//native bool:War3Teleport(client, Float:distance);
//native War3_StringMath(String:equation[]);
native W3HasDiedThisFrame(client);
/**
* Adds a dependency on a skill
*
* @param iRaceID Race ID
* @param iSkill Skill on which the dependency should be added onto
* @param iRequiredSkill Required Skill ID
* @param iRequiredLevel Required Level Num
* @return true on success, otherwhise false!
* @error Thrown on invalid param num/race
*/
native bool:War3_SetDependency(iRaceID, iSkill, iRequiredSkill, iRequiredLevel);
/**
* Removes any known dependency from a skill(if any)
* NOTE: you should be able to call this safetly without having to bother about anything,
* since no error will be thrown if there currently aren't any active dependencys on this
*
* @param iRaceID Race ID
* @param iSkill Skill on which the dependency should be removed from
* @noreturn
* @error Thrown on invalid param num/race
*/
native War3_RemoveDependency(iRaceID, iSkill);
/**
* Retrieves various informations about a depending skill
* NOTE: This can be called to check if there is any dependency or not
*
* @param iRaceID Race ID
* @param iSkill Target skill to get informations from
* @param eInfo Type of information to retrieve
* @return Retrieved information about the dependency
* @error Thrown on invalid param num/race
*/
native War3_GetDependency(iRaceID, iSkill, SkillDependency:eInfo=ID);
// BOT THINGS!!
/**
* Force a fake client to distribute his skillpoints
*
* @param client: client index
*/
native War3_bots_distribute_sp(client);
native War3_bots_pickrace(client);
/*create an error displayed in various places at runtime*/
native CreateWar3GlobalError(String:str[]);
native W3CreateEvent(W3EVENT:event,client);
// forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards
// forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards
// forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards
// forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards
// forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards
// forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards
// forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards
// forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards
// forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards
// forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards
// forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards
// forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards
// forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards
// forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards
// forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards
// forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards
// forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards
// forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards forwards
enum W3HookType
{
W3Hook_OnW3TakeDmgAllPre, //p_OnW3TakeDmgAllPre
W3Hook_OnW3TakeDmgBulletPre, //p_OnW3TakeDmgBulletPre
W3Hook_OnW3TakeDmgAll, //p_OnW3TakeDmgAll
W3Hook_OnW3TakeDmgBullet, //p_OnW3TakeDmgBullet
W3Hook_OnWar3EventPostHurt, //p_OnWar3EventPostHurtFH
W3Hook_OnWar3Event,
W3Hook_OnUltimateCommand,
W3Hook_OnAbilityCommand,
W3Hook_OnUseItemCommand,
W3Hook_OnWar3EventSpawn,
W3Hook_OnWar3SkinChange,
W3Hook_OnTalentsLoaded,
W3Hook_OnWar3SkillSlotChange //p_OnWar3SkillSlotChange
//W3Hook_,
};
typeset W3HookCB
{
//W3Hook_OnWar3EventSpawn
//W3Hook_OnTalentsLoaded
function void (int client);
//W3Hook_OnWar3Event
function void (W3EVENT event, int client);
//W3Hook_OnUseItemCommand
function void (int client, int useitem, bool pressed);
//W3Hook_FHOnW3TakeDmgAllPre
//W3Hook_FHOnW3TakeDmgAll
//W3Hook_FHOnW3TakeDmgBullet
function Action (int victim, int attacker, float damage);
//W3Hook_FHOnW3TakeDmgBulletPre
function Action (int victim, int attacker, float damage, int damagecustom);
//W3Hook_FHOnWar3EventPostHurtFH
function Action (int victim, int attacker, float dmgamount, char weapon[32], bool isWarcraft, const float damageForce[3], const float damagePosition[3]);
//W3Hook_OnAbilityCommand --> (int client, int ability, bool pressed, bool bypass)
function void (int client, int ability, bool pressed, bool bypass);
//W3Hook_OnUltimateCommand
function void (int client, int race, bool pressed, bool bypass);
//W3Hook_OnWar3SkinChange
function void (int client, int newrace);
//W3Hook_OnWar3SkillSlotChange
function void (int client, int skillslot, int oldskillid, int newskillid);
};
/**
* @brief Hooks for function
*
* @param type Type of function to hook
* @param callback Function to call when hook is called
* @param AllowAutomaticHooking Will Unhook/Rehook functions that are deemed not need for a round event.
* Most likely will unload a function before round start, if is not a active boss
* plugin, and rehook at round end.
* @return returns nothing
*/
// possible future if sourcemod allows storing of functions:
//native void W3Hook(W3HookType type, W3HookCB callback, bool AllowAutomaticHooking = true);
native void W3Hook(W3HookType type, W3HookCB callback);
/**
* @brief Hooks for function
*
* @param type Type of function to hook
* @param callback Function to call when hook is called
* @param AllowAutomaticHooking Will Unhook/Rehook functions that are deemed not need for a round event.
* Most likely will unload a function before round start, if is not a active boss
* plugin, and rehook at round end.
* @return returns true if successful
*/
// possible future if sourcemod allows storing of functions:
//native bool W3HookEx(W3HookType type, W3HookCB callback, bool AllowAutomaticHooking = true);
native bool W3HookEx(W3HookType type, W3HookCB callback);
/**
* @brief Unhooks a function
* Removes a function from a private forward's call list.
* Only removes one instance.
* Functions will be removed automatically if their parent plugin is unloaded.
*
* @param type Type of function to unhook
* @param callback Callback function to unhook
* @return returns nothing
*/
native void W3Unhook(W3HookType type, W3HookCB callback);
/**
* @brief Unhooks a function
* Removes a function from a private forward's call list.
* Only removes one instance.
* Functions will be removed automatically if their parent plugin is unloaded.
*
* @param type Type of function to unhook
* @param callback Callback function to unhook
* @return returns true if successful
*/
native bool W3UnhookEx(W3HookType type, W3HookCB callback);
/**
* @brief Unhooks a function
* Removes all instances of a plugin from a private forward's call list.
* Functions will be removed automatically if their parent plugin is unloaded.
*
* @param type Type of function to unhook
* @param callback Callback function to unhook
* @return returns nothing
*/
native void W3UnhookAll(W3HookType type);
/**
* @brief Unhooks a function
* Removes all instances of a plugin from a private forward's call list.
* Functions will be removed automatically if their parent plugin is unloaded.
*
* @param type Type of function to unhook
* @param callback Callback function to unhook
* @return returns true if successful
*/
native bool W3UnhookAllEx(W3HookType type);
//Called for each category if the user opens the catted cr menu
forward Action:OnW3DrawCategory(client,categoryindex,String:categoryname[]);
/**********************
* Implement this if you have natives/forwards
*/
forward bool:InitNativesForwards();
/**********************
* Implement this if you need AskPluginLoad2Custom
*/
forward APLRes:AskPluginLoad2Custom(Handle:plugin,bool:late,String:error[],err_max);
//forwarded when someone calls CreateWar3GlobalError, store that string for yourself
forward OnWar3GlobalError(String:str[]);
//forward War3FailedSignal(String:str[]);
/* interface side implementation, do not use */
//public War3FailedSignal(String:str[]) {
//LogError(str); //must be a non dependent native log error
//SetFailState(str);
//}
/**
* Called when the plugin is ready.
* this is called many times, increasing num each time 0.0-float(MAXRACES)*10 in 1 increments
* USED FOR OFFICIAL PLUGINS ONLY
*/
forward OnWar3LoadRaceOrItemOrdered(num);
/*
* called when a player goes afk from the afk manager
*/
forward OnWar3PlayerAFK(client);
/**
* Called when the plugin is ready. (after ordered)
*/
forward OnWar3PluginReady();
/**
* Called to send id back to plugin if it changes (usually called on a plugin reload)
*/
//forward OnWar3PluginRaceId(String:plugin_shortname[16],reload_raceid);
/**
* Gets called when after PutInServer, xp retrievcal has started, initial variables may have been set
* @param client: The client's index.
*/
forward OnWar3PlayerAuthed(client);
/**
* Gets called when the +ultimate or -ultimate command is called, IT ISNT ALWAYS FOR YOUR RACE, YOU NEED TO CHECK!!!
* @param client: The client's index.
* @param race: The race for which it was called.
* @param pressed: If true, +ultimate, false, -ultimate.
*/
//forward OnUltimateCommand(client,race,bool:pressed,bool:bypass);
/**
* Gets called when the +ability# or -ability# command is called.
* If its +ability or -ability (without a number), 0 is passed to ability.
* Isn't always for you, check War3_GetRace(client)==yourRace
* @param client: The client's index.
* @param ability: The ability number.
* @param pressed: If true, +ability#, false, -ability#.
* @param bypass: If true, a separate part of the program is requesting to bypass your race restrictions to use the ability.
*/
//forward OnAbilityCommand(client,ability,bool:pressed,bool:bypass);
/**
* Gets called when the +ability# or -ability# command is called.
* If its +ability or -ability (without a number), 0 is passed to ability.
* Isn't always for you, check War3_GetRace(client)==yourRace
* @param client: The client's index.
* @param useitem: The useitem number. (+useitem,+useitem1,+useitem2,etc)
* @param pressed: If true, +ability#, false, -ability#.
*/
//forward OnUseItemCommand(client,useitem,bool:pressed);
/**
* Gets called when a skill level is changed.
*/
forward void OnSkillLevelChanged(int client, int currentrace, int skill, int newskilllevel, int oldskilllevel);
///general events, see W3EVENT enum in constants
///client may not always matter
//forward void OnWar3Event(W3EVENT event, int client);
//when player spawns, fires only in war3 mode
//forward OnWar3EventSpawn(client);
//when player dies, fires only in war3 mode
//Distance in feet
//forward OnWar3EventDeath(victim, attacker, deathrace, distance, attacker_hpleft, String:weapon[32]);
forward OnWar3EventDeath(victim, attacker, deathrace, distance, attacker_hpleft);
//very generic damage event
//derrived from the game engine's posthurt event
//FRIENDLY FIRE IS NOT FILTERED
//forward OnWar3EventPostHurt(victim,attacker,dmgamount,const String:weapon[32],bool:isWarcraft,const Float:damageForce[3], const Float:damagePosition[3]);
//Fired after a player dodges, useful primarily for attaching effects
forward OnW3DodgePost(victim, attacker);
//Fired before a player dodges, you can edit the dodge chance here
forward OnW3DodgePre(victim,attacker,Float:chance);
// DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM
// DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM
// DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM
// DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM
// DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM
// DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM
// DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM
// DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM
// DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM
// DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM
// DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM
// DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM
// DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM
// DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM
// DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM
// DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM
// DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM
// DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM
// DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM
// DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM DENY SYSTEM
//simple system for stopping actions, send a specific event with optinal player, those hooking can use W3Deny() to deny
forward OnW3Denyable(W3DENY:event,client);
native bool:W3Denied(W3DENY:event,client); //returns FALSE if NOT DENIED
stock bool:W3Denyable(W3DENY:event,client) {
return !W3Denied(event,client);
}
native W3Deny();
/*
* STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS
* STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS
* STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS
* STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS
* STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS
* STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS
* STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS
* STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS
* STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS
* STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS
* STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS
* STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS
* STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS
* STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS
* STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS
* STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS
* STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS
* STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS
* STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS STOCKS
*/
// FOF doesn't display hints correctly
stock W3PrintHint(int client, const char[] format, any ...)
{
// for the format
char buffer[254];
VFormat(buffer, sizeof(buffer), format, 2);
//halflife.inc
//native void PrintHintText(int client, const char[] format, any ...);
#if (GGAMETYPE == GGAME_FOF)
War3_ChatMessage(client, buffer);
#else
PrintHintText(client, buffer);
#endif
}
#if (GGAMETYPE == GGAME_CSGO)
stock void CSGO_RADAR(int client,bool TurnON)
{
if(ValidPlayer(client) && !IsFakeClient(client))
{
if(TurnON)
{
int hudflags = GetEntProp(client, Prop_Send, "m_iHideHUD");
if(hudflags & HIDE_RADAR)
{
hudflags &= ~HIDE_RADAR;
hudflags &= ~HIDEHUD_CHAT;
SetEntProp(client, Prop_Send, "m_iHideHUD", hudflags);
}
}
else
{
int hudflags = GetEntProp(client, Prop_Send, "m_iHideHUD");
if(!(hudflags & HIDE_RADAR))
{
hudflags |= HIDE_RADAR;
hudflags |= HIDEHUD_CHAT;
SetEntProp(client, Prop_Send, "m_iHideHUD", hudflags);
}
}
}
}
#endif
///check race limit and force re-choose race
stock CheckRaceTeamLimit(raceid,team)
{
new Float:youngest=-1.0;
new target=0;
for(new i=1;i<=MaxClients;i++){
if(ValidPlayer(i))
{
if(War3_GetRace(i)==raceid&&!W3IsDeveloper(i))
{
if(GetClientTeam(i)==team)
{
if(W3GetPlayerProp(i,LastChangeTeamTime)>youngest){
target=i;
youngest=W3GetPlayerProp(i,LastChangeTeamTime);
}
}
}
}
}
if(target>0)
{
War3_SetRace(target,0);
char racename[64];
War3_GetRaceName(raceid,racename,sizeof(racename));
War3_ChatMessage(target,"%T","{race} race team limit has reached (MAX {amount}), please select a different job",target,racename,W3GetRaceMaxLimitTeam(raceid,team));
PrintToConsole(target,"Your job has been set via raceutils.inc");
int cvar=W3GetRaceMaxLimitTeamCvar(raceid,team);
char cvarstr[64];
if(cvar>-1){
W3GetCvarActualString(cvar,cvarstr,sizeof(cvarstr));
}
cvar=W3FindCvar(cvarstr);
char cvarvalue[64];
if(cvar>-1){
W3GetCvar(cvar,cvarvalue,sizeof(cvarvalue));
}
W3Log("job %s blocked on client %d due to restrictions limit %d (CheckRaceTeamLimit) %s %s",racename,target,W3GetRaceMaxLimitTeam(raceid,team),cvarstr,cvarvalue);
W3CreateEvent(DoShowChangeRaceMenu,target);
}
}
stock CheckPendingRace(client)
{
int pendingrace=W3GetPendingRace(client);
if(pendingrace>0)
{
W3SetPendingRace(client,-1);
/*GetConVarInt(W3GetVar(hRaceLimitEnabledCvar))>0&&
GetRacesOnTeam(pendingrace,GetClientTeam(client))>=W3GetRaceMaxLimitTeam(pendingrace,GetClientTeam(client))*/