forked from PCMRShutnik/Rage-Trigger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ability_item_usage_generic.lua
3695 lines (3584 loc) · 147 KB
/
ability_item_usage_generic.lua
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
require( GetScriptDirectory().."/utilities" )
require( GetScriptDirectory().."/buildings_status" )
require( GetScriptDirectory().."/herofile_utilities" )
_G._savedEnv = getfenv()
module( "ability_item_usage_generic", package.seeall )
require( GetScriptDirectory().."/logic" )
local RAD_Fountain = Vector(-7000.000000,-7000.000000, 256.000000);
local DIRE_Fountain = Vector(7000.000000,7000.000000, 256.000000);
require( GetScriptDirectory().."/utilities" )
require( GetScriptDirectory().."/herofile_utilities" )
if string.find(GetBot():GetUnitName(), "hero") and build == "NOT IMPLEMENTED" then
build = require(GetScriptDirectory() .. "/Shopping cart/item_build_" .. string.gsub(GetBot():GetUnitName(), "npc_dota_hero_", ""))
end
if build == "NOT IMPLEMENTED" then
return
end
function whichlane(Time, Num , camp_distance, camp_loc, bonus_hp)
local LanePickTimer = Time;
local LaneNum = Num;
local npcBot = GetBot();
local herofile = require(GetScriptDirectory() .. "/herofile");
if (DotaTime() - LanePickTimer > 5) then
LanePickTimer = DotaTime();
if ( npcBot:GetLevel() >= 6) then
local toplane_loc = GetLaneFrontLocation(GetOpposingTeam( ) , LANE_TOP, 0) * 0.5 + GetLaneFrontLocation(GetTeam( ) , LANE_TOP, 0) * 0.5;
local midlane_loc = GetLaneFrontLocation(GetOpposingTeam( ) , LANE_MID, 0) * 0.5 + GetLaneFrontLocation(GetTeam( ) , LANE_MID, 0) * 0.5;
local botlane_loc = GetLaneFrontLocation(GetOpposingTeam( ) , LANE_BOT, 0) * 0.5 + GetLaneFrontLocation(GetTeam( ) , LANE_BOT, 0) * 0.5;
local lanedistance_top = GetUnitToLocationDistance( npcBot, toplane_loc);
local lanedistance_mid = GetUnitToLocationDistance( npcBot, midlane_loc);
local lanedistance_bot = GetUnitToLocationDistance( npcBot, botlane_loc);
local timetobekill = 10;
local radius = npcBot:GetCurrentMovementSpeed( ) * timetobekill;
local toplane_herocounts = 0;
local midlane_herocounts = 0;
local botlane_herocounts = 0;
local camp_herocounts = 0;
local toplane_allyfactor = 0;
local midlane_allyfactor = 0;
local botlane_allyfactor = 0;
local jungle_allyfactor = 0;
for k, lane in pairs(herofile.TableEnemyPlayerLaneNum) do
if (IsHeroAlive(herofile.TableEnemyPlayerID[k]) and lane~= nil and lane == 1) then
toplane_herocounts = toplane_herocounts + 1;
elseif (IsHeroAlive(herofile.TableEnemyPlayerID[k]) and lane~= nil and lane == 2) then
midlane_herocounts = midlane_herocounts + 1;
elseif (IsHeroAlive(herofile.TableEnemyPlayerID[k]) and lane~= nil and lane == 3) then
botlane_herocounts = botlane_herocounts + 1;
end
end
if (camp_loc~= nil and LocHeroNum(camp_loc, 800) > 0) then
camp_herocounts = LocHeroNum(camp_loc, 800);
end
for k, lane in pairs(herofile.TableAllyHeroLaneNum) do
if (npcBot:GetPlayerID() ~= herofile.TableAllyPlayerID[k]) then
if (IsHeroAlive(herofile.TableAllyPlayerID[k]) and herofile.TableAllyHeroPriority[k]~=nil and herofile.TableAllyHeroPriority[k] > GetPriority() and herofile.TableAllyHeroState[k]~= nil and herofile.TableAllyHeroState[k] == "gofarmjungle") then
jungle_allyfactor = jungle_allyfactor + 12500;
elseif (IsHeroAlive(herofile.TableAllyPlayerID[k]) and lane~= nil and lane == 1 and herofile.TableAllyHeroRole[k]~= nil and herofile.TableAllyHeroRole[k] < 4 and herofile.TableAllyHeroState[k]~= nil and herofile.TableAllyHeroState[k] == "gofarmlane") then
toplane_allyfactor = 25000;
elseif (IsHeroAlive(herofile.TableAllyPlayerID[k]) and lane~= nil and lane == 2 and herofile.TableAllyHeroRole[k]~= nil and herofile.TableAllyHeroRole[k] < 4 and herofile.TableAllyHeroState[k]~= nil and herofile.TableAllyHeroState[k] == "gofarmlane") then
midlane_allyfactor = 25000;
elseif (IsHeroAlive(herofile.TableAllyPlayerID[k]) and lane~= nil and lane == 3 and herofile.TableAllyHeroRole[k]~= nil and herofile.TableAllyHeroRole[k] < 4 and herofile.TableAllyHeroState[k]~= nil and herofile.TableAllyHeroState[k] == "gofarmlane") then
botlane_allyfactor = 25000;
end
end
end
local toplane_risk = toplane_herocounts * toplane_herocounts * 2000;
local midlane_risk = midlane_herocounts * midlane_herocounts * 2000;
local botlane_risk = botlane_herocounts * botlane_herocounts * 2000;
local camp_risk = camp_herocounts * camp_herocounts * 2000;
if (not IsInAllyTowerRange(toplane_loc, radius)) then
toplane_risk = 25000;
end
if (not IsInAllyTowerRange(midlane_loc, radius)) then
midlane_risk = 25000;
end
if (not IsInAllyTowerRange(botlane_loc, radius)) then
botlane_risk = 25000;
end
local lanedistance_index = 1;
local lanepick_top = (lanedistance_top * lanedistance_index) + toplane_risk + toplane_allyfactor;
local lanepick_mid = (lanedistance_mid * lanedistance_index) + midlane_risk + midlane_allyfactor;
local lanepick_bot = (lanedistance_bot * lanedistance_index) + botlane_risk + botlane_allyfactor;
local lanepick_jungle = (camp_distance * lanedistance_index) + camp_risk + jungle_allyfactor;
local lanepick_roam = 25000;
if ( lanepick_jungle == math.min(lanepick_top, lanepick_mid, lanepick_bot, lanepick_jungle, lanepick_roam) ) then
LaneNum = 0;
elseif ( lanepick_top == math.min(lanepick_top, lanepick_mid, lanepick_bot, lanepick_jungle, lanepick_roam) )then
LaneNum = 1;
elseif ( lanepick_mid == math.min(lanepick_top, lanepick_mid, lanepick_bot, lanepick_jungle, lanepick_roam) ) then
LaneNum = 2;
elseif ( lanepick_bot == math.min(lanepick_top, lanepick_mid, lanepick_bot, lanepick_jungle, lanepick_roam) ) then
LaneNum = 3;
elseif ( lanepick_roam == math.min(lanepick_top, lanepick_mid, lanepick_bot, lanepick_jungle, lanepick_roam) ) then
LaneNum = 4;
end
else
LaneNum = npcBot:GetAssignedLane();
end
end
return LanePickTimer, LaneNum;
end
function roam(LaneNum, SwitchTimer, Strategy)
local roam_p = 0;
local RoamStrategy = Strategy;
local RoamSwitchTimer = SwitchTimer;
if (LaneNum == 4) then
roam_p = 7.5;
if (DotaTime() - RoamSwitchTimer > 90 or ( not npcBot:IsAlive() ) ) then
RoamStrategy = RandomInt(1, 50);
RoamSwitchTimer = DotaTime();
end
end
return roam_p, RoamSwitchTimer, RoamStrategy;
end
function goroam(RoamStrategy)
local npcBot = GetBot();
local herofile = require(GetScriptDirectory() .. "/herofile");
local MainCarry = nil;
local AllyHighestPriority = -1;
local EnemyMainCarry =nil;
local EnemyHighestPriority = 0;
local Weakest_Hero = nil;
local Lowest_hp = 99999;
local com_state = nil;
local com_target = nil;
for k, AllyHeroPriority in pairs(herofile.TableAllyHeroPriority) do
if (AllyHeroPriority~=nil and AllyHeroPriority > AllyHighestPriority and IsHeroAlive( herofile.TableAllyPlayerID[k] ) and herofile.TableAllyHeroState[k]~= nil and herofile.TableAllyHeroState[k]== "gofarmlane") then
MainCarry = herofile.TableAllyPlayerID[k];
AllyHighestPriority = AllyHeroPriority;
end
end
for k, EnemyPlayerPriority in pairs(herofile.TableEnemyPlayerPriority) do
if (EnemyPlayerPriority~=nil and EnemyPlayerPriority > EnemyHighestPriority and IsHeroAlive( herofile.TableEnemyPlayerID[k] )) then
EnemyMainCarry = herofile.TableEnemyPlayerID[k];
EnemyHighestPriority = EnemyPlayerPriority;
end
end
for k, EnemyHeroHP in pairs(herofile.TableEnemyHeroHP) do
if (EnemyHeroHP~=nil and EnemyHeroHP < Lowest_hp and IsHeroAlive( herofile.TableEnemyPlayerID[k] )) then
Weakest_Hero = herofile.TableEnemyPlayerID[k];
Lowest_hp = EnemyHeroHP;
end
end
if (MainCarry~= nil and npcBot:GetUnitName() == GetSelectedHeroName(MainCarry) and RoamStrategy < 51) then
RoamStrategy = RoamStrategy + 50;
end
if (RoamStrategy >= 51 and RoamStrategy < 81 and EnemyMainCarry ~= nil) then
local LastSeenInfo = GetHeroLastSeenInfo( EnemyMainCarry );
npcBot:Action_MoveToLocation( LastSeenInfo.location );
com_state = "gogankenemy";
com_target = EnemyMainCarry;
elseif (RoamStrategy >= 81 and RoamStrategy < 101 and Weakest_Hero ~= nil) then
local LastSeenInfo = GetHeroLastSeenInfo( Weakest_Hero );
npcBot:Action_MoveToLocation( LastSeenInfo.location );
com_state = "gogankenemy";
com_target = Weakest_Hero;
elseif ( MainCarry~= nil ) then
local LastSeenInfo = GetHeroLastSeenInfo( MainCarry );
if (GetUnitToLocationDistance(npcBot, LastSeenInfo.location) > 600) then
local target_loc = LastSeenInfo.location + RandomVector( 400 );
npcBot:Action_MoveToLocation( target_loc );
com_state = "gosupportcarry";
end
end
return com_state, com_target;
end
function farmlane(LaneNum)
local farmlane_p = 0;
if( LaneNum == 1 or LaneNum == 2 or LaneNum == 3 ) then
farmlane_p = 7.1;
end
return farmlane_p;
end
function gofarmlane(LaneNum)
local npcBot = GetBot();
local com_state = "gofarmlane";
local lanefront_index = GetLaneFrontAmount( GetTeam() , LaneNum , false)*0.5 + GetLaneFrontAmount( GetOpposingTeam() , LaneNum , false)*0.5;
local lanefront_location = GetLocationAlongLane( LaneNum, lanefront_index);
local target_location = GetLaneFrontLocation( GetTeam(), LaneNum, -npcBot:GetAttackRange());
local enemy_front_tower = GetFrontTower(GetOpposingTeam(), LaneNum);
if ( IsInTowerRange(target_location ,900 - npcBot:GetAttackRange() ) or #(_G.EnemyFountain - target_location ) < #(_G.EnemyFountain - enemy_front_tower:GetLocation() )) then
local lanefront_amount = GetAmountAlongLane( LaneNum , enemy_front_tower:GetLocation() ).amount - 90/1764;
target_location = GetLocationAlongLane( LaneNum, lanefront_amount ) ;
end
local current_lane = GetLaneNum( npcBot:GetLocation() );
if (npcBot:IsChanneling( ) or npcBot:IsUsingAbility() or DotaTime() < -1.5 ) then
return com_state;
end
if ( current_lane ~= LaneNum ) then
if (GetUnitToLocationDistance(npcBot, lanefront_location) > math.min(npcBot:GetCurrentMovementSpeed() * 15, 4500) ) then
if (CanUseTp()) then
TpToLocation(target_location);
else
npcBot:Action_MoveToLocation(target_location);
end
else
npcBot:Action_MoveToLocation(target_location);
end
elseif ( current_lane == LaneNum ) then
local front_tower = GetFrontTower(GetTeam(), LaneNum);
if (front_tower~= nil and #(_G.Fountain - lanefront_location ) < #(_G.Fountain - front_tower:GetLocation() ) ) then
lanefront_location = front_tower:GetLocation();
end
if (GetUnitToLocationDistance(npcBot, lanefront_location) > math.min(npcBot:GetCurrentMovementSpeed() * 15, 4500) ) then
if (CanUseTp()) then
TpToLocation(target_location);
else
npcBot:Action_MoveToLocation(target_location);
end
else
npcBot:Action_MoveToLocation(target_location);
end
end
return com_state;
end
function lasthit(com_state)
local npcBot = GetBot();
local herofile = require(GetScriptDirectory() .. "/herofile");
local lasthit_p = 0;
local weakest_creep = nil;
if (com_state == "gofarmlane") then
local EnemyCreeps = npcBot:GetNearbyLaneCreeps(1200,true);
local lowest_hp = 10000;
local highest_hp = 0;
local strongest_creep = nil;
local creep_pos = nil;
local itemdamage = 0;
local extradamage = 0;
if(CheckItemByName("item_quelling_blade")) then
itemdamage = 24;
end
for creep_k,creep in pairs(EnemyCreeps) do
if(creep:IsAlive() and (((not IsInTowerRange(creep:GetLocation() ,(900 - npcBot:GetAttackRange())))) )) then
local creep_hp = creep:GetHealth();
if(lowest_hp > creep_hp and creep_hp > 0 ) then
lowest_hp = creep_hp;
weakest_creep = creep;
creep_pos = weakest_creep:GetLocation();
end
end
end
if(weakest_creep ~= nil) then
local rightClick =weakest_creep:GetActualIncomingDamage(npcBot:GetAttackDamage(),DAMAGE_TYPE_PHYSICAL);
local CreepDamage = CreepDamageEstimate(weakest_creep);
local ModifierDamage = ModifierDamageEstimate(weakest_creep);
if (string.find(weakest_creep:GetUnitName( ), "siege") ~= nil) then
rightClick = rightClick * 0.9;
itemdamage = 0;
CreepDamage = CreepDamage * 0.5;
ModifierDamage = ModifierDamage * 0.2;
end
if (GetUnitToLocationDistance(npcBot, creep_pos) > npcBot:GetAttackRange()) then
extradamage = (((GetUnitToLocationDistance(npcBot, creep_pos)-npcBot:GetAttackRange()) * 1.5 / npcBot:GetCurrentMovementSpeed( )) + npcBot:GetAttackPoint() + 1)* (CreepDamage + ModifierDamage);
else
extradamage = npcBot:GetAttackPoint() * CreepDamage;
end
if(lowest_hp > 0 and lowest_hp <= ( rightClick + itemdamage + extradamage) ) then
lasthit_p = 15;
elseif(lowest_hp > ( rightClick + itemdamage + extradamage) ) then
lasthit_p = 0;
end
if (lasthit_p == 15) then
local nearesthero, HeroNum, MinDistance = FindNearestEnemyHero(npcBot:GetLocation());
if ( nearesthero~= nil and MinDistance < herofile.TableEnemyPlayerAttackRange[HeroNum] + herofile.TableEnemyPlayerSpeed[HeroNum] * 0.5 and GetHeroLastSeenInfo( nearesthero ).time < 3) then
local ExpoTime = GetUnitToLocationDistance(npcBot, creep_pos) * 2 / npcBot:GetCurrentMovementSpeed();
if (npcBot:GetActualIncomingDamage( herofile.TableEnemyPlayerAttack[HeroNum], DAMAGE_TYPE_PHYSICAL ) * ExpoTime > npcBot:GetMaxHealth() * 0.3 ) then
lasthit_p = 0;
end
end
end
end
end
return lasthit_p, weakest_creep;
end
function golasthit(AttackPointTimer, com_state)
local npcBot = GetBot();
local lasthit_p, weakest_creep = lasthit(com_state);
local creep_pos = weakest_creep:GetLocation();
local lowest_hp = weakest_creep:GetHealth();
local itemdamage = 0;
local extradamage =0;
local timer = AttackPointTimer;
if (npcBot:IsChanneling( ) or npcBot:IsUsingAbility()) then
return timer;
end
if(CheckItemByName("item_quelling_blade")) then
itemdamage = 24;
end
if(weakest_creep ~= nil) then
local rightClick = weakest_creep:GetActualIncomingDamage(npcBot:GetAttackDamage(),DAMAGE_TYPE_PHYSICAL);
if (string.find(weakest_creep:GetUnitName( ), "siege") ~= nil) then
rightClick = rightClick*0.9;
itemdamage = 0;
end
if (GetUnitToUnitDistance(npcBot, weakest_creep) > npcBot:GetAttackRange()) then
npcBot:Action_MoveToLocation(creep_pos);
else
if ( lowest_hp > rightClick + itemdamage and DotaTime() - AttackPointTimer < npcBot:GetAttackPoint() * 0.9) then
npcBot:Action_AttackUnit(weakest_creep,true);
elseif ( lowest_hp > rightClick + itemdamage and DotaTime() - AttackPointTimer >= npcBot:GetAttackPoint() * 0.9) then
npcBot:Action_ClearActions( true ) ;
timer = DotaTime();
elseif (lowest_hp <= rightClick + itemdamage) then
npcBot:Action_AttackUnit(weakest_creep,true);
end
end
end
return timer;
end
function pullcreep(com_state)
local npcBot = GetBot();
local EnemyCreeps = npcBot:GetNearbyLaneCreeps(1200,true);
local nearestcreep = EnemyCreeps[1];
local NearbyEnemyHeroes = npcBot:GetNearbyHeroes( 1500, true, BOT_MODE_NONE );
local pullcreep_p = 0;
if (com_state == "gofarmlane") then
if (#NearbyEnemyHeroes > 0 and nearestcreep ~= nil and GetUnitToUnitDistance(npcBot, nearestcreep) > npcBot:GetAttackRange() + npcBot:GetCurrentMovementSpeed() * 0.5 and (not IsInTowerRange(nearestcreep:GetLocation(), (975 - nearestcreep:GetAcquisitionRange()) ))) then
for k, hero in pairs(NearbyEnemyHeroes) do
if ( (hero:GetAttackRange() > npcBot:GetAttackRange() or IsInTowerRange(nearestcreep:GetLocation(), 900) ) and GetUnitToUnitDistance(npcBot, hero) > hero:GetAttackRange() + hero:GetCurrentMovementSpeed() * 0.5) then
pullcreep_p = 7.38;
end
end
end
end
return pullcreep_p;
end
function gopullcreep(PullCreepTimer)
local npcBot = GetBot();
local timer = PullCreepTimer
local EnemyCreeps = npcBot:GetNearbyLaneCreeps(1200,true);
local NearbyEnemyHeroes = npcBot:GetNearbyHeroes( 1500, true, BOT_MODE_NONE );
local nearesthero = NearbyEnemyHeroes[1];
local nearestcreep = EnemyCreeps[1];
if (npcBot:IsChanneling( )) then
return timer;
end
if (nearesthero ~= nil and nearestcreep~= nil) then
if ( GetUnitToUnitDistance(npcBot, nearestcreep) > nearestcreep:GetAcquisitionRange() - 75 ) then
npcBot:Action_MoveToLocation( nearestcreep:GetLocation() );
else
if (DotaTime() - PullCreepTimer > 2) then
npcBot:Action_AttackUnit(nearesthero,true);
timer = DotaTime();
elseif ( DotaTime() - PullCreepTimer <= 2) then
npcBot:Action_ClearActions(true);
end
end
end
return timer;
end
function deny(com_state)
local npcBot = GetBot();
local herofile = require(GetScriptDirectory() .. "/herofile");
local deny_p =0;
local weakest_creep = nil;
if (com_state == "gofarmlane") then
local AllyCreeps = npcBot:GetNearbyLaneCreeps(1000,false);
local lowest_hp = 10000;
local creep_pos = nil;
for creep_k,creep in pairs(AllyCreeps) do
if(creep:IsAlive() and ((not IsInTowerRange(creep:GetLocation() ,(900-npcBot:GetAttackRange()))))) then
local creep_hp = creep:GetHealth();
if(lowest_hp > creep_hp and creep_hp > 0 ) then
lowest_hp = creep_hp;
weakest_creep = creep;
creep_pos = weakest_creep:GetLocation();
end
end
end
if(weakest_creep ~= nil) then
local rightClick =weakest_creep:GetActualIncomingDamage(npcBot:GetAttackDamage(),DAMAGE_TYPE_PHYSICAL);
local CreepDamage = CreepDamageEstimate(weakest_creep);
if (string.find(weakest_creep:GetUnitName( ), "siege") ~= nil) then
rightClick = rightClick * 0.5;
CreepDamage = CreepDamage * 0.5;
end
extradamage = (((GetUnitToLocationDistance(npcBot, creep_pos)-npcBot:GetAttackRange()) / npcBot:GetCurrentMovementSpeed( )) * 1.5 + npcBot:GetAttackPoint() + 1 )* CreepDamage;
if(lowest_hp > 0 and lowest_hp/weakest_creep:GetMaxHealth() < 0.5 and lowest_hp <= ( rightClick + extradamage)) then
deny_p = 15.95, weakest_creep;
elseif(lowest_hp > rightClick ) then
deny_p = 15.95;
end
if (deny_p == 15.95) then
local nearesthero, HeroNum, MinDistance = FindNearestEnemyHero(npcBot:GetLocation());
if ( nearesthero~= nil and MinDistance < herofile.TableEnemyPlayerAttackRange[HeroNum] + herofile.TableEnemyPlayerSpeed[HeroNum] * 0.5 and GetHeroLastSeenInfo( nearesthero ).time < 3) then
local ExpoTime = GetUnitToLocationDistance(npcBot, creep_pos) * 2 / npcBot:GetCurrentMovementSpeed();
if (npcBot:GetActualIncomingDamage( herofile.TableEnemyPlayerAttack[HeroNum], DAMAGE_TYPE_PHYSICAL ) * ExpoTime > npcBot:GetMaxHealth() * 0.2 ) then
deny_p = 0;
end
end
end
end
end
return deny_p, weakest_creep;
end
function godeny(AttackPointTimer, com_state)
local npcBot = GetBot();
local timer = AttackPointTimer;
local deny_p, weakest_creep = deny(com_state);
local creep_pos = weakest_creep:GetLocation();
local lowest_hp = weakest_creep:GetHealth();
local NearbyEnemyHeroes = npcBot:GetNearbyHeroes( 1200, true, BOT_MODE_HIGH );
if (npcBot:IsChanneling( )) then
return timer;
end
if(weakest_creep ~= nil) then
local rightClick =weakest_creep:GetActualIncomingDamage(npcBot:GetAttackDamage(),DAMAGE_TYPE_PHYSICAL);
if (string.find(weakest_creep:GetUnitName( ), "siege") ~= nil) then
rightClick = rightClick * 0.9;
end
if (GetUnitToUnitDistance(npcBot, weakest_creep) > npcBot:GetAttackRange()) then
npcBot:Action_MoveToLocation(creep_pos);
else
if (lowest_hp > rightClick and DotaTime() - AttackPointTimer < npcBot:GetAttackPoint() * 3) then
npcBot:Action_AttackUnit(weakest_creep,true);
elseif (lowest_hp > rightClick and DotaTime() - AttackPointTimer >= npcBot:GetAttackPoint() * 3) then
npcBot:Action_ClearActions( true ) ;
timer = DotaTime();
elseif (lowest_hp <= rightClick ) then
npcBot:Action_AttackUnit(weakest_creep,true);
end
end
end
return timer;
end
function farmjungle(LaneNum, com_state)
local farmjungle_p = 0;
local npcBot = GetBot();
if(LaneNum == 0 and DotaTime() > 30) then
farmjungle_p = 7.49;
else
farmjungle_p = 0;
end
return farmjungle_p;
end
function gofarmjungle(camp_distance, camp_loc)
local npcBot = GetBot();
local com_state = "gofarmjungle";
if (npcBot:IsChanneling( )) then
return com_state;
end
local NearbyNeutralCreeps = npcBot:GetNearbyNeutralCreeps( 800 );
local highest_priority = -999;
local target_creep = nil;
if (camp_loc ~= nil and GetUnitToLocationDistance(npcBot, camp_loc) <= 400 and #NearbyNeutralCreeps > 0) then
for creep_k, creep in pairs( NearbyNeutralCreeps ) do
local creep_priority = creep:GetHealth() + (1 - GetUnitToUnitDistance(npcBot, creep)/1500);
if (creep:GetUnitName() == "npc_dota_neutral_dark_troll_warlord") then
creep_priority = 1;
elseif (creep:GetUnitName() == "npc_dota_neutral_ghost" or creep:GetUnitName() == "npc_dota_neutral_prowler_shaman" or creep:GetUnitName() == "npc_dota_neutral_enraged_wildkin") then
creep_priority = 9999;
elseif (creep:GetUnitName() == "npc_dota_neutral_prowler_acolyte") then
creep_priority = 9997;
elseif (creep:GetUnitName() == "npc_dota_neutral_granite_golem") then
creep_priority = 9996;
end
if(creep:IsAlive() and highest_priority < creep_priority) then
highest_priority = creep_priority;
target_creep = creep;
end
end
npcBot:Action_AttackUnit(target_creep, false);
elseif (camp_loc ~= nil and (GetUnitToLocationDistance(npcBot, camp_loc) > 400 or (not IsLocationVisible(camp_loc)) ) ) then
npcBot:Action_MoveToLocation(camp_loc);
elseif (camp_loc == nil) then
print('recalculating');
end
return com_state;
end
function pullcamp()
local pullcamp_p = 0;
if (DotaTime() < math.ceil(DotaTime()/60) * 60) then
pullcamp_p = 7.50;
end
return pullcamp_p;
end
function gopullcamp()
end
function gopullcamp_fallback()
end
function attackhero(com_state)
local npcBot = GetBot();
local herofile = require(GetScriptDirectory() .. "/herofile");
local NearbyEnemyHeroes = npcBot:GetNearbyHeroes( 1200, true, BOT_MODE_NONE );
local nearesthero = NearbyEnemyHeroes[1];
local nearesttower = FindNearestTower( npcBot:GetLocation( ) );
local attackhero_p = 0;
local lasthit_p, weakest_creep = lasthit(com_state);
local HighestPriority = 0;
if (nearesthero ~= nil and (not IsInTowerRange(nearesthero:GetLocation(), 900 - npcBot:GetAttackRange()) ) and (not IsInTowerRange(npcBot:GetLocation(), 900) ) ) then
local EnemyRawPower = GetNearbyEnemyPower( nearesthero:GetLocation() );
local EnemyHealth = GetNearbyEnemyHealth( nearesthero:GetLocation() ) ;
local AllyRawPower = GetNearbyAllyPower( npcBot );
local AllyHealth = GetNearbyAllyHealth( npcBot );
local EnemyDamageEstimate = EnemyDamageEstimate(nearesthero:GetLocation());
local EnemySpeedEstimate = AverageSpeedEstimate(nearesthero:GetLocation());
local ExpoTime = EnemyStunEstimate( npcBot:GetLocation() );
if (nearest_tower~= nil and EnemySpeedEstimate~= 0) then
ExpoTime = math.max(ExpoTime + (GetUnitToUnitDistance(npcBot, nearest_tower)/npcBot:GetCurrentMovementSpeed() - GetUnitToUnitDistance(npcBot, nearest_tower)/EnemySpeedEstimate), 3);
else
ExpoTime = math.max(ExpoTime + (npcBot:DistanceFromFountain() / npcBot:GetCurrentMovementSpeed() - npcBot:DistanceFromFountain()/EnemySpeedEstimate), 3);
end
if ( EnemyDamageEstimate * ExpoTime > npcBot:GetHealth() and GetUnitToUnitDistance(npcBot, nearesthero) < nearesthero:GetAttackRange() + nearesthero:GetCurrentMovementSpeed() ) then
return attackhero_p, nearesthero;
end
if ( EnemyRawPower + EnemyHealth > (AllyRawPower + AllyHealth) * 2 ) then
return attackhero_p, nearesthero;
end
local NearbyEnemyCreeps = npcBot:GetNearbyLaneCreeps(1200,true);
local NearbyAllyCreep = npcBot:GetNearbyLaneCreeps(1200,false);
local allycreepdamage = 0;
local enemycreepdamage = 0;
for k, creep in pairs(NearbyEnemyCreeps) do
if ( GetUnitToUnitDistance(npcBot, creep) < creep:GetAcquisitionRange() + 100) then
enemycreepdamage = enemycreepdamage + npcBot:GetActualIncomingDamage(creep:GetAttackDamage() ,DAMAGE_TYPE_PHYSICAL);
end
end
for k, creep in pairs(NearbyAllyCreep) do
if ( GetUnitToUnitDistance(nearesthero, creep) < creep:GetAcquisitionRange() + 100) then
allycreepdamage = allycreepdamage + nearesthero:GetActualIncomingDamage(creep:GetAttackDamage(), DAMAGE_TYPE_PHYSICAL);
end
end
if ( nearesttower~= nil and GetUnitToUnitDistance(nearesthero, nearesttower) < 800 or (IsInAllyTowerRange(npcBot:GetLocation(), 800) and (800 - GetUnitToUnitDistance(npcBot, nearesttower)) > nearesthero:GetAttackRange()) )then
allycreepdamage = allycreepdamage + nearesthero:GetActualIncomingDamage(nearesttower:GetAttackDamage(), DAMAGE_TYPE_PHYSICAL);
end
local extradamage = 0;
if (npcBot:GetAttackRange() < nearesthero:GetAttackRange() ) then
extradamage = (GetUnitToUnitDistance(npcBot, nearesthero) - npcBot:GetAttackRange())/npcBot:GetCurrentMovementSpeed() * nearesthero:GetEstimatedDamageToTarget( true, npcBot, 5, DAMAGE_TYPE_PHYSICAL) * 0.2;
elseif (nearesthero:GetAttackRange() < npcBot:GetAttackRange() ) then
extradamage = (GetUnitToUnitDistance(npcBot, nearesthero) - nearesthero:GetAttackRange() )/nearesthero:GetCurrentMovementSpeed() * npcBot:GetEstimatedDamageToTarget( true, nearesthero, 5, DAMAGE_TYPE_PHYSICAL) * 0.2;
end
if (npcBot:GetAttackRange() > nearesthero:GetAttackRange()) then
if ( GetUnitToUnitDistance( npcBot, nearesthero) < nearesthero:GetAttackRange() + nearesthero:GetCurrentMovementSpeed() * 0.5 ) then
attackhero_p = 7.38;
elseif ( nearesthero:IsStunned( ) or nearesthero:IsDisarmed( ) ) then
attackhero_p = 11;
elseif (( npcBot:GetHealth() )/(nearesthero:GetEstimatedDamageToTarget( true, npcBot, 3, DAMAGE_TYPE_PHYSICAL) + enemycreepdamage * 3) > (nearesthero:GetHealth() - extradamage)/(npcBot:GetEstimatedDamageToTarget( true, nearesthero, 3, DAMAGE_TYPE_PHYSICAL) + allycreepdamage * 3) and npcBot:GetEstimatedDamageToTarget( true, nearesthero, 3, DAMAGE_TYPE_PHYSICAL) + allycreepdamage * 3 > nearesthero:GetEstimatedDamageToTarget( true, npcBot, 3, DAMAGE_TYPE_PHYSICAL) + enemycreepdamage * 3 and npcBot:GetEstimatedDamageToTarget( true, nearesthero, 3, DAMAGE_TYPE_PHYSICAL) > enemycreepdamage * 3 * 2) then
attackhero_p = 11;
end
elseif (npcBot:GetAttackRange() <= nearesthero:GetAttackRange()) then
if ( nearesthero:IsStunned( ) or nearesthero:IsDisarmed( ) ) then
attackhero_p = 15.299;
elseif (( npcBot:GetHealth() - - extradamage)/(nearesthero:GetEstimatedDamageToTarget( true, npcBot, 3, DAMAGE_TYPE_PHYSICAL) + enemycreepdamage * 3) > nearesthero:GetHealth() /(npcBot:GetEstimatedDamageToTarget( true, nearesthero, 3, DAMAGE_TYPE_PHYSICAL) + allycreepdamage * 3) and npcBot:GetEstimatedDamageToTarget( true, nearesthero, 3, DAMAGE_TYPE_PHYSICAL) + allycreepdamage * 3 > nearesthero:GetEstimatedDamageToTarget( true, npcBot, 3, DAMAGE_TYPE_PHYSICAL) + enemycreepdamage * 3 and npcBot:GetEstimatedDamageToTarget( true, nearesthero, 3, DAMAGE_TYPE_PHYSICAL) > enemycreepdamage * 3 * 2)then
attackhero_p = 11;
end
end
if (attackhero_p == 11 and lasthit_p == 0) then
attackhero_p = 11.5;
end
end
if (attackhero_p == 0) then
for k, AllyHeroState in pairs (herofile.TableAllyHeroState) do
if (AllyHeroState~= nil and AllyHeroState == "goretreat" and herofile.TableAllyHeroCom[k] ~= nil and herofile.TableAllyHeroCom[k] == "helpme" and herofile.TableAllyHeroHandle[k]~= nil and GetUnitToLocationDistance(npcBot, herofile.TableAllyHeroHandle[k]:GetLocation()) < npcBot:GetCurrentMovementSpeed() * 10 and herofile.TableAllyHeroPriority[k] > HighestPriority) then
local AllyNearbyEnemyHeroes = herofile.TableAllyHeroHandle[k]:GetNearbyHeroes( 1300, true, BOT_MODE_NONE );
local AllyNearestHero = AllyNearbyEnemyHeroes[1];
if ( AllyNearestHero ~= nil ) then
attackhero_p = 11.5;
nearesthero = AllyNearestHero;
HighestPriority = herofile.TableAllyHeroPriority[k];
end
end
end
end
return attackhero_p, nearesthero;
end
function goattackhero()
local npcBot = GetBot();
local attackhero_p, attackhero = attackhero();
if (npcBot:IsChanneling( ) or npcBot:IsUsingAbility() ) then
return;
end
if (attackhero ~= nil) then
npcBot:Action_AttackUnit(attackhero, false);
end
end
function fallback( bonus_hp )
local npcBot = GetBot();
local herofile = require(GetScriptDirectory() .. "/herofile");
local tableEnemyHero = GetUnitList( UNIT_LIST_ENEMY_HEROES ) ;
local NearbyAllyHeroes = npcBot:GetNearbyHeroes( 900, false, BOT_MODE_NONE );
local nearesthero, HeroNum, MinDistance = FindNearestEnemyHero(npcBot:GetLocation());
local tableNearbyCreeps = npcBot:GetNearbyLaneCreeps(900,true);
local nearestcreep = tableNearbyCreeps[1];
local NearbyTowers = npcBot:GetNearbyTowers( 1200, true );
local fallback_p = 0;
local dangerunit = nil;
local fallbackrange = 0;
local highest_range = 0;
if (not npcBot:IsAlive() ) then
return fallback_p, danger_loc, fallbackrange;
end
for k, PlayerID in pairs(herofile.TableEnemyPlayerID) do
local LastSeenLocation = GetHeroLastSeenInfo( PlayerID ).location;
local LastSeenTime = GetHeroLastSeenInfo( PlayerID ).time;
if (IsHeroAlive( PlayerID ) and LastSeenTime > -1 and LastSeenTime < 3 and GetUnitToLocationDistance(npcBot, LastSeenLocation) < 1300 and GetUnitToLocationDistance(npcBot, LastSeenLocation) < herofile.TableEnemyPlayerAttackRange[k] + 0.5 * herofile.TableEnemyPlayerSpeed[k] and herofile.TableEnemyPlayerAttackRange[k] > npcBot:GetAttackRange() + npcBot:GetCurrentMovementSpeed() * 0.5 ) then
fallback_p = 7.37;
danger_loc = LastSeenLocation;
fallbackrange = math.min(herofile.TableEnemyPlayerAttackRange[k] + herofile.TableEnemyPlayerSpeed[k] * 0.5, 1300) ;
end
end
local EnemySpeedEstimate = math.max(AverageSpeedEstimate(npcBot:GetLocation()), 1);
local ExpoTime = EnemyStunEstimate( npcBot:GetLocation() );
if (nearest_tower~= nil) then
ExpoTime = math.max(ExpoTime + (GetUnitToUnitDistance(npcBot, nearest_tower)/npcBot:GetCurrentMovementSpeed() - GetUnitToUnitDistance(npcBot, nearest_tower)/EnemySpeedEstimate), 3);
else
ExpoTime = math.max(ExpoTime + (npcBot:DistanceFromFountain() / npcBot:GetCurrentMovementSpeed() - npcBot:DistanceFromFountain()/EnemySpeedEstimate), 3);
end
local TotalEstimateEnemyDamage = 0;
for j, hero in pairs (tableEnemyHero) do
if (GetUnitToUnitDistance(hero, npcBot) < math.max(hero:GetCurrentMovementSpeed() * ExpoTime + hero:GetAttackRange(), 1500) ) then
TotalEstimateEnemyDamage = TotalEstimateEnemyDamage + (ExpoTime) * hero:GetEstimatedDamageToTarget(true, npcBot, 5, DAMAGE_TYPE_ALL) * 0.2;
end
end
if( (npcBot:WasRecentlyDamagedByCreep( 1.5 ) or npcBot:WasRecentlyDamagedByTower(1.5)) and nearestcreep~= nil and (npcBot:HasModifier("modifier_flask_healing") or npcBot:HasModifier("modifier_clarity_potion") )) then
danger_loc = npcBot:GetLocation();
fallbackrange = npcBot:GetCurrentMovementSpeed() * 1.5;
fallback_p = 14.01;
elseif (nearesthero~= nil and MinDistance < 1200 and GetHeroLastSeenInfo( nearesthero ).time < 3 and npcBot:GetHealth()/npcBot:GetMaxHealth() < 0.9 and npcBot:HasModifier("modifier_flask_healing") ) then
fallback_p = 14.01;
danger_loc = GetHeroLastSeenInfo( nearesthero ).location;
fallbackrange = herofile.TableEnemyPlayerAttackRange[HeroNum] + herofile.TableEnemyPlayerSpeed[HeroNum];
elseif (nearesthero~= nil and MinDistance < 1200 and GetHeroLastSeenInfo( nearesthero ).time < 3 and npcBot:GetMana()/npcBot:GetMaxMana() < 0.9 and npcBot:HasModifier("modifier_clarity_potion")) then
fallback_p = 14.01;
danger_loc = GetHeroLastSeenInfo( nearesthero ).location;
fallbackrange = herofile.TableEnemyPlayerAttackRange[HeroNum] + herofile.TableEnemyPlayerSpeed[HeroNum];
elseif (nearesthero~= nil and TotalEstimateEnemyDamage >= npcBot:GetHealth() and MinDistance < 1300) then
fallback_p = 13.99;
danger_loc = GetHeroLastSeenInfo( nearesthero ).location;
fallbackrange = 1300;
elseif(npcBot:WasRecentlyDamagedByTower( 1 ) and #NearbyTowers > 0) then
fallback_p = 11.61;
danger_loc = NearbyTowers[1]:GetLocation() ;
fallbackrange = 900;
elseif(IsInTowerRange( npcBot:GetLocation(), 900) and #NearbyTowers > 0 and (npcBot:GetHealth()/npcBot:GetMaxHealth() < 0.8 or npcBot:GetHealth() < 1000) and nearesthero ~= nil and MinDistance < 1500) then
fallback_p = 11.60;
danger_loc = NearbyTowers[1]:GetLocation();
fallbackrange = 900;
elseif( npcBot:WasRecentlyDamagedByCreep( 1.5 ) and nearestcreep~= nil ) then
danger_loc = npcBot:GetLocation();
fallbackrange = npcBot:GetCurrentMovementSpeed() * 1.5;
fallback_p = 10.5;
elseif(IsInTowerRange(npcBot:GetLocation(), 900) and #NearbyTowers > 0) then
danger_loc = NearbyTowers[1]:GetLocation();
fallbackrange = 900;
fallback_p = 7.4;
end
if (fallback_p < 10.9 and nearesthero ~= nil and npcBot:WasRecentlyDamagedByAnyHero( 1.5 ) ) then
for k, PlayerID in pairs(herofile.TableEnemyPlayerID) do
if (IsHeroAlive( PlayerID ) and npcBot:WasRecentlyDamagedByPlayer(PlayerID , 1.5) and GetHeroLastSeenInfo( PlayerID ).time < 3 and GetUnitToLocationDistance(npcBot, GetHeroLastSeenInfo( PlayerID ).location) < math.max(herofile.TableEnemyPlayerAttackRange[k] + herofile.TableEnemyPlayerSpeed[k],1250) ) then
fallback_p = 10.9;
danger_loc = GetHeroLastSeenInfo( PlayerID ).location;
fallbackrange = math.max(herofile.TableEnemyPlayerAttackRange[k] + herofile.TableEnemyPlayerSpeed[k],1250);
end
end
end
return fallback_p, danger_loc, fallbackrange;
end
function gofallback(danger_loc, fallbackrange)
local npcBot = GetBot();
if (npcBot:IsChanneling()) then
return;
end
local target_loc = nil;
local nearest_tower = FindNearestTower(npcBot:GetLocation());
if (danger_loc ~= nil and GetUnitToLocationDistance(npcBot,danger_loc) < fallbackrange) then
if (nearest_tower ~= nil and #(danger_loc - _G.Fountain) >= #(npcBot:GetLocation() - _G.Fountain) and #(npcBot:GetLocation() - _G.Fountain) > #(nearest_tower:GetLocation() - _G.Fountain) + 700) then
target_loc = nearest_tower:GetLocation();
elseif (nearest_tower ~= nil and #(danger_loc - _G.Fountain) >= #(npcBot:GetLocation() - _G.Fountain) and #(npcBot:GetLocation() - _G.Fountain) <= #(nearest_tower:GetLocation() - _G.Fountain) + 700 ) then
target_loc = _G.Fountain;
elseif (nearest_tower ~= nil and #(danger_loc - _G.Fountain) < #(npcBot:GetLocation() - _G.Fountain) and (not IsInAllyTowerRange(npcBot:GetLocation(), 700)) ) then
target_loc = nearest_tower:GetLocation();
elseif (nearest_tower ~= nil and #(danger_loc - _G.Fountain) < #(npcBot:GetLocation() - _G.Fountain) and (IsInAllyTowerRange(npcBot:GetLocation(), 700)) ) then
if ( (math.floor(math.floor(DotaTime())/2) %2 == 0) ) then
target_loc = nearest_tower:GetLocation() + Vector(150, 150);
else
target_loc = nearest_tower:GetLocation() + Vector(-150, -150);
end
else
target_loc = _G.Fountain;
end
npcBot:Action_MoveToLocation(target_loc);
else
npcBot:Action_ClearActions(true);
end
end
function killhero()
local npcBot = GetBot();
local herofile = require(GetScriptDirectory() .. "/herofile");
local killhero_p = 0;
local TargetPlayer = nil;
local HighestPriority = -99999;
local tableAllyHero = GetUnitList( UNIT_LIST_ALLIED_HEROES ) ;
local TableEnemyHero = GetUnitList( UNIT_LIST_ENEMY_HEROES ) ;
local Distance = 0;
if (npcBot:IsAlive()) then
local NearbyEnemyCreeps = npcBot:GetNearbyLaneCreeps(1200,true);
local enemycreepdamage = 0;
local allycreepdamage = 0;
for k, creep in pairs(NearbyEnemyCreeps) do
if ( GetUnitToUnitDistance(npcBot, creep) < creep:GetAcquisitionRange() + 100) then
enemycreepdamage = enemycreepdamage + npcBot:GetActualIncomingDamage(creep:GetAttackDamage() ,DAMAGE_TYPE_PHYSICAL);
end
end
for k, PlayerID in pairs(herofile.TableEnemyPlayerID) do
local nearest_enemy_tower , nearest_tower_name = FindEnemyNearestTower(npcBot:GetLocation());
local BehindTower = 0;
if (IsInTowerRange(npcBot:GetLocation(), 900) and herofile.TableLastSeenInfo[k].location ~=nil and #(herofile.TableLastSeenInfo[k].location - _G.EnemyFountain) + 450 < #(nearest_enemy_tower:GetLocation() - _G.EnemyFountain) )then
BehindTower = 1;
end
if (BehindTower == 0 and IsHeroAlive( PlayerID ) and herofile.TableLastSeenInfo[k].time < 5 and herofile.TableLastSeenInfo[k].location ~=nil and (not IsInEnemyBase(herofile.TableLastSeenInfo[k].location)) and GetUnitToLocationDistance(npcBot, herofile.TableLastSeenInfo[k].location) < math.max(npcBot:GetCurrentMovementSpeed() * 10 + npcBot:GetAttackRange(), 1500) ) then
if (IsInTowerRange(npcBot:GetLocation(), 900) or IsInTowerRange(herofile.TableLastSeenInfo[k].location, 900 - npcBot:GetAttackRange())) then
enemycreepdamage = enemycreepdamage + npcBot:GetActualIncomingDamage(nearest_enemy_tower:GetAttackDamage() ,DAMAGE_TYPE_PHYSICAL);
end
if ( herofile.TableEnemyPlayerHandle[k]~= nil ) then
local NearByAllyStun = npcBot:GetStunDuration( true ) + npcBot:GetSlowDuration( true ) * 0.2;
local NearByAllyDamage = npcBot:GetEstimatedDamageToTarget(true, herofile.TableEnemyPlayerHandle[k], 5, DAMAGE_TYPE_ALL) * 0.2;
for j, hero in pairs (tableAllyHero) do
if (hero:GetUnitName() ~= npcBot:GetUnitName() and GetUnitToUnitDistance(hero, herofile.TableEnemyPlayerHandle[k]) < math.max(hero:GetAttackRange() + hero:GetCurrentMovementSpeed() * 3, 1500) and hero:GetHealth()/hero:GetMaxHealth() > 0.3) then
NearByAllyStun = NearByAllyStun + hero:GetStunDuration( true ) + hero:GetSlowDuration( true ) * 0.2;
NearByAllyDamage = NearByAllyDamage + hero:GetEstimatedDamageToTarget(true, herofile.TableEnemyPlayerHandle[k], 5, DAMAGE_TYPE_ALL) * 0.2;
end
end
if (IsInAllyTowerRange(herofile.TableEnemyPlayerHandle[k]:GetLocation(), 800)) then
local nearest_ally_tower = FindNearestTower(herofile.TableEnemyPlayerHandle[k]:GetLocation());
allycreepdamage = allycreepdamage + herofile.TableEnemyPlayerHandle[k]:GetActualIncomingDamage(nearest_ally_tower:GetAttackDamage() ,DAMAGE_TYPE_PHYSICAL);
end
local ExpoTime = NearByAllyStun + GetRemainControlTime(herofile.TableEnemyPlayerHandle[k]);
local nearest_tower , nearest_tower_name = FindEnemyNearestTower(herofile.TableEnemyPlayerHandle[k]:GetLocation());
if (nearest_tower~= nil) then
ExpoTime = math.max(ExpoTime + (GetUnitToUnitDistance(herofile.TableEnemyPlayerHandle[k], nearest_tower)/herofile.TableEnemyPlayerHandle[k]:GetCurrentMovementSpeed()), 3);
else
ExpoTime = math.max(ExpoTime + (#(herofile.TableEnemyPlayerHandle[k]:GetLocation() - _G.EnemyFountain)/herofile.TableEnemyPlayerHandle[k]:GetCurrentMovementSpeed()), 3);
end
if (GetUnitToUnitDistance(npcBot, herofile.TableEnemyPlayerHandle[k]) < math.max(npcBot:GetAttackRange() + npcBot:GetCurrentMovementSpeed() * ExpoTime, 1500) ) then
local TotalEstimateAllyDamage = (ExpoTime - (GetUnitToUnitDistance(npcBot, herofile.TableEnemyPlayerHandle[k]) - npcBot:GetAttackRange())/npcBot:GetCurrentMovementSpeed()) * npcBot:GetEstimatedDamageToTarget(true, herofile.TableEnemyPlayerHandle[k], 5, DAMAGE_TYPE_ALL) * 0.2 + allycreepdamage * ExpoTime;
for j, hero in pairs (tableAllyHero) do
if (hero:GetUnitName() ~= npcBot:GetUnitName() and GetUnitToUnitDistance(hero, herofile.TableEnemyPlayerHandle[k]) < math.max(hero:GetCurrentMovementSpeed() * ExpoTime + hero:GetAttackRange(), 1500) and hero:GetHealth()/hero:GetMaxHealth() > 0.3) then
TotalEstimateAllyDamage = TotalEstimateAllyDamage + (ExpoTime - (GetUnitToUnitDistance(hero, herofile.TableEnemyPlayerHandle[k]) - hero:GetAttackRange())/hero:GetCurrentMovementSpeed()) * hero:GetEstimatedDamageToTarget(true, herofile.TableEnemyPlayerHandle[k], 5, DAMAGE_TYPE_ALL) * 0.2;
end
end
local NearByEnemyDamage = herofile.TableEnemyPlayerHandle[k]:GetEstimatedDamageToTarget(true, npcBot, 5, DAMAGE_TYPE_ALL) * 0.2;
for hero_k, hero in pairs (herofile.TableEnemyPlayerHandle) do
if (hero:GetUnitName() ~= herofile.TableEnemyPlayerHandle[k]:GetUnitName() and GetUnitToUnitDistance(hero, herofile.TableEnemyPlayerHandle[k]) < math.max(hero:GetAttackRange() + hero:GetCurrentMovementSpeed() * 3, 1500) or GetUnitToUnitDistance(hero, npcBot) < math.max(hero:GetAttackRange() + hero:GetCurrentMovementSpeed() * 3, 1500)) then
NearByEnemyDamage = NearByEnemyDamage + hero:GetEstimatedDamageToTarget(true, npcBot, 5, DAMAGE_TYPE_ALL) * 0.2;
end
end
if (TotalEstimateAllyDamage >= herofile.TableEnemyPlayerHandle[k]:GetHealth() and herofile.TableEnemyPlayerHandle[k]:GetHealth()/(NearByAllyDamage + allycreepdamage) < (npcBot:GetHealth() - npcBot:GetMaxHealth() * 0.3)/(NearByEnemyDamage + enemycreepdamage) ) then
TargetPlayer = k;
killhero_p = 15.302;
HighestPriority = herofile.TableEnemyPlayerPriority[k];
end
end
else
local HeroNum = GetVarInTable(npcBot:GetPlayerID(), herofile.TableAllyPlayerID);
if (herofile.TableAllyHeroState[HeroNum] == "gokillhero" and herofile.TableAllyHeroTarget[HeroNum] == k and (not IsInTowerRange(npcBot:GetLocation(), 900))) then
local NearByAllyDamage = npcBot:GetRawOffensivePower();
for j, hero in pairs (tableAllyHero) do
if (hero:GetUnitName() ~= npcBot:GetUnitName() and GetUnitToLocationDistance(hero, herofile.TableLastSeenInfo[k].location) < math.max(hero:GetAttackRange() + hero:GetCurrentMovementSpeed()*3, 1500) and hero:GetHealth()/hero:GetMaxHealth() > 0.3) then
NearByAllyDamage = NearByAllyDamage + hero:GetRawOffensivePower();
end
end
if (herofile.TableEnemyHeroHP[k]/NearByAllyDamage < (npcBot:GetHealth() - npcBot:GetMaxHealth() * 0.3)/(GetNearbyEnemyPower( npcBot:GetLocation() ) * 0.2 + enemycreepdamage) ) then
TargetPlayer = k;
killhero_p = 15.301;
HighestPriority = herofile.TableEnemyPlayerPriority[k];
end
end
end
else
local HeroNum = GetVarInTable(npcBot:GetPlayerID(), herofile.TableAllyPlayerID);
if (herofile.TableAllyHeroState[HeroNum] == "gokillhero" and herofile.TableAllyHeroTarget[HeroNum] == k) then
herofile.TableAllyHeroState[HeroNum] = nil;
herofile.TableAllyHeroTarget[HeroNum] = nil;
end
end
end
end
return killhero_p, TargetPlayer;
end
function gokillhero()
local npcBot = GetBot();
local herofile = require(GetScriptDirectory() .. "/herofile");
local killhero_p, killhero = killhero();
local com_state = "gokillhero";
local com_target = killhero;
if (npcBot:IsChanneling( )) then
return com_state, com_target;
end
if (killhero~= nil) then
if (herofile.TableEnemyPlayerHandle[killhero] ~= nil) then
npcBot:Action_AttackUnit(herofile.TableEnemyPlayerHandle[killhero], false);
elseif( herofile.TableLastSeenInfo[killhero].location ~= nil ) then
npcBot:Action_MoveToLocation(herofile.TableLastSeenInfo[killhero].location);
end
end
return com_state, com_target;
end
function dodgelinear()
local npcBot = GetBot();
local angle = npcBot:GetFacing( );
local speed = npcBot:GetCurrentMovementSpeed();
local radians = angle * math.pi / 180;
local TableProjectiles = GetLinearProjectiles( );
local min_distance = 99999;
local nearestprojectile = nil;
local nearestprojectile_name = nil;
local radius = 0;
local velocity = nil;
local location = nil;
local future_loc = nil;
local dodgelinear_p = 0;
local target_loc = nil;
for k, LinearProjectiles in pairs(TableProjectiles) do
if ( GetTeamForPlayer(LinearProjectiles.playerid) == GetOpposingTeam( ) and GetUnitToLocationDistance(npcBot, LinearProjectiles.location) < min_distance) then
min_distance = GetUnitToLocationDistance(npcBot, LinearProjectiles.location);
nearestprojectile_name = LinearProjectiles.ability;
radius = LinearProjectiles.radius;
velocity = LinearProjectiles.velocity;
location = LinearProjectiles.location;
end
end
if (min_distance < 2500) then
local a = velocity.y/velocity.x;
local b = location.y - a * location.x;
local c = npcBot:GetLocation().x;
local d = npcBot:GetLocation().y;
local h = math.sqrt(c * c + (b - d) * (b - d) - (a * (b - d) - c) * (a * (b - d) -c )/(a * a + 1));
local arrowspeed = math.sqrt(velocity.x * velocity.x + velocity.y * velocity.y);
if ( h <= radius + 150 ) then
for i = 1, 30 do
radians = (angle + i * 3 ) * math.pi / 180;
c = npcBot:GetLocation().x + math.cos(radians) * speed * min_distance/arrowspeed;
d = npcBot:GetLocation().y + math.sin(radians) * speed * min_distance/arrowspeed;
h = math.sqrt(c*c + (b - d) * (b - d) - (a*(b-d) -c)*(a*(b-d) -c)/(a*a +1));
if (h > radius + 150 ) then
dodgelinear_p = 20.1;
target_loc = Vector(c, d);
return dodgelinear_p, target_loc;
end
radians = (angle - i * 3) * math.pi / 180;
c = npcBot:GetLocation().x + math.cos(radians) * speed * min_distance/arrowspeed;
d = npcBot:GetLocation().y + math.sin(radians) * speed * min_distance/arrowspeed;
h = math.sqrt(c*c + (b - d) * (b - d) - (a*(b-d) -c)*(a*(b-d) -c)/(a*a +1));
if (h > radius + 150 ) then
dodgelinear_p = 20.1;
target_loc = Vector(c, d);
return dodgelinear_p, target_loc;
end
end
end
end
return dodgelinear_p, target_loc;
end
function gododgelinear()
local dodgelinear_p, target_loc = dodgelinear();
local npcBot = GetBot();
if (target_loc ~= nil) then
npcBot:Action_MoveToLocation(target_loc);
end
end
function dodgeaoe( com_state )
local dodgeaoe_p = 0;
local npcBot = GetBot();
if (com_state ~= "gokillhero" and IsInAoeArea( npcBot:GetLocation() )) then
dodgeaoe_p = 15.1;
end
return dodgeaoe_p;
end
function gododgeaoe()
local npcBot = GetBot();
local speed = npcBot:GetCurrentMovementSpeed();
local angle = npcBot:GetFacing( );
local radians = angle * math.pi / 180;
local target_loc = nil;
local cor_x = nil;
local cor_y = nil;
for j = 1, 5 do
speed = npcBot:GetCurrentMovementSpeed() * j;
for i = 0, 6 do
radians = (angle + i * 30) * math.pi / 180;
cor_x = math.cos(radians) * speed;
cor_y = math.sin(radians) * speed;
target_loc = npcBot:GetLocation() + Vector(cor_x, cor_y);
if ( not IsInAoeArea(target_loc) ) then
npcBot:Action_MoveToLocation(target_loc);
return;
end
radians = (angle - i * 30) * math.pi / 180;
cor_x = math.cos(radians) * speed;
cor_y = math.sin(radians) * speed;
target_loc = npcBot:GetLocation() + Vector(cor_x, cor_y);
if ( not IsInAoeArea(target_loc) ) then
npcBot:Action_MoveToLocation(target_loc);
return;
end
end
end
end
function TeamFightState()
local npcBot = GetBot();
local teamfight_state = 0;
local NearbyAllyHeroes = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_NONE );
if (LocHeroNum(npcBot:GetLocation(), 1500) > 3 and #NearbyAllyHeroes > 2 ) then
teamfight_state = 1;
end
return teamfight_state;
end
function teamfight()
local npcBot = GetBot();
local herofile = require(GetScriptDirectory() .. "/herofile");
local teamfight_p = 0;
local target_loc = nil;
local priority = -99999;
if ( TeamFightState() == 0 and npcBot:GetLevel() > 6) then
for k, state in pairs (herofile.TableAllyTeamFightState) do
if (herofile.TableAllyHeroHandle[k] ~= nil and herofile.TableAllyPlayerID[k]~= npcBot:GetPlayerID() and herofile.TableAllyHeroHandle[k]:IsAlive() and state~=nil and state == 1) then
local allyhero = herofile.TableAllyHeroHandle[k];
local tp_loc, distance = findtploc(allyhero:GetLocation());
if ( herofile.TableAllyHeroPriority[k] > priority and GetUnitToUnitDistance (npcBot, allyhero) <= npcBot:GetCurrentMovementSpeed() * 8 + npcBot:GetAttackRange()) then
teamfight_p = 11.41;
priority = herofile.TableAllyHeroPriority[k];
target_loc = allyhero:GetLocation();
elseif ( herofile.TableAllyHeroPriority[k] > priority and GetUnitToUnitDistance (npcBot, allyhero) > npcBot:GetCurrentMovementSpeed() * 8 + npcBot:GetAttackRange() and CanUseTp() and GetUnitToLocationDistance (allyhero, tp_loc) < GetUnitToUnitDistance (npcBot, allyhero) + npcBot:GetCurrentMovementSpeed() * 3 ) then
teamfight_p = 11.42;
priority = herofile.TableAllyHeroPriority[k];
target_loc = tp_loc;
elseif (herofile.TableAllyHeroPriority[k] > priority and GetUnitToUnitDistance (npcBot, allyhero) > npcBot:GetCurrentMovementSpeed() * 8 + npcBot:GetAttackRange() and CanUseTp() and GetUnitToLocationDistance (allyhero, tp_loc) >= GetUnitToUnitDistance (npcBot, allyhero) + npcBot:GetCurrentMovementSpeed() * 3 ) then
teamfight_p = 11.41;
priority = herofile.TableAllyHeroPriority[k];
target_loc = tp_loc;
end
end
end
end
return teamfight_p, target_loc;
end
function goteamfight()
local npcBot = GetBot();
local teamfight_p, target_loc = teamfight();
if (npcBot:IsChanneling() or target_loc == nil) then
return;
end
if (teamfight_p == 11.41) then
npcBot:Action_MoveToLocation(target_loc);
elseif (teamfight_p == 11.42) then
if (CanUseTp()) then
TpToLocation(target_loc);
print('tp to teamfight');
end
end
end
function push()
local npcBot = GetBot();
local herofile = require(GetScriptDirectory() .. "/herofile");
local push_p = 0;
local push_loc = nil;
local NearbyEnemyTowers = npcBot:GetNearbyTowers(1300,true);
local nearest_tower = NearbyEnemyTowers[1];