-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmode_team_roam_generic.lua
2080 lines (1730 loc) · 54.6 KB
/
mode_team_roam_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
if GetBot():IsInvulnerable() or not GetBot():IsHero() or not string.find(GetBot():GetUnitName(), "hero") or GetBot():IsIllusion() then
return;
end
local bot = GetBot();
local bDebugMode = ( 1 == 10 )
local X = {}
local J = require( GetScriptDirectory()..'/FunLib/jmz_func')
local AttackSpecialUnit = dofile( GetScriptDirectory()..'/FunLib/aba_special_units')
local Item = require( GetScriptDirectory()..'/FunLib/aba_item')
local botName = bot:GetUnitName();
local targetUnit = nil;
local towerCreepMode = false;
local towerCreep = nil;
local towerTime = 0;
local towerCreepTime = 0;
local beInitDone = false
local IsSupport = false
local IsHeroCore = false
local beFirstStop = false
local bePvNMode = false
local DroppedShardTime = -90
local DroppedCheeseTime = -90
local SwappedCheeseTime = -90
local SwappedRefresherShardTime = -90
local PickedItem = nil
local ShouldAttackSpecialUnit = false
local shouldHarass = false
local harassTarget = nil
local ShouldHelpWhenCoreIsTargeted = false
local TormentorLocation
function GetDesire()
TormentorLocation = J.GetTormentorLocation(GetTeam())
bot.laneToPush = J.GetMostPushLaneDesire()
bot.laneToDefend = J.GetMostDefendLaneDesire()
-- fix lanes for these two
if botName == 'npc_dota_hero_elder_titan'
or botName == 'npc_dota_hero_wisp'
then
if bot.lane == nil then
local botPos = J.GetPosition(bot)
if botPos == 1 or botPos == 5 then
if GetTeam() == TEAM_RADIANT then
bot.lane = 3
else
bot.lane = 1
end
elseif botPos == 2 then
bot.lane = 2
elseif botPos == 3 or botPos == 4 then
if GetTeam() == TEAM_RADIANT then
bot.lane = 1
else
bot.lane = 3
end
end
end
end
if not beInitDone
then
beInitDone = true
bePvNMode = J.Role.IsPvNMode()
IsHeroCore = J.IsCore(bot)
IsSupport = not J.IsCore(bot)
end
local nDesire = 0
local nEnemyHeroes = J.GetEnemiesNearLoc(bot:GetLocation(), 1600)
if J.IsCore(bot) and J.IsGoingOnSomeone(bot) and #nEnemyHeroes >= 2 then
bot:SetTarget(J.GetSetNearbyTarget(bot, nEnemyHeroes))
end
-- -- Print Skills Pos
-- if J.GetPosition(bot) == 5 and GetTeam() == TEAM_RADIANT
-- then
-- local a = J.Skill.GetAbilityList(GetTeamMember(1))
-- for i = 1, #a do print(i, a[i]) end
-- end
-- Should not retreat if under Wraith King's scepter
if bot:HasModifier('modifier_skeleton_king_reincarnation_scepter_active')
then
targetUnit = X.WeakestUnitCanBeAttacked(true, true, bot:GetCurrentVisionRange(), bot)
if targetUnit ~= nil
then
bot:SetTarget(targetUnit)
return BOT_ACTION_DESIRE_ABSOLUTE * 1.5
end
end
-- Consider help nearby core that's being targeted; defend_ally not reliable
targetUnit, ShouldHelpWhenCoreIsTargeted = X.ConsiderHelpWhenCoreIsTargeted()
if ShouldHelpWhenCoreIsTargeted
then
bot:SetTarget(targetUnit)
return BOT_ACTION_DESIRE_ABSOLUTE * 0.98
end
if bot:HasModifier('modifier_faceless_void_chronosphere_selfbuff')
and bot.ChronoTarget ~= nil
then
return bot:GetActiveModeDesire() + 0.1
end
-- nDesire = X.ConsiderHarassInLaningPhase()
-- if nDesire > 0
-- then
-- return nDesire
-- end
if not bot:IsAlive() or bot:GetCurrentActionType() == BOT_ACTION_TYPE_DELAY then
return BOT_MODE_DESIRE_NONE
end
nDesire = AttackSpecialUnit.GetDesire(bot)
if nDesire > 0 then
ShouldAttackSpecialUnit = true
return nDesire
end
ShouldAttackSpecialUnit = false
-- -- Pickup Neutral Item Tokens; since removed item_generic; some overlap
-- nDesire = TryPickupDroppedNeutralItemTokens()
-- if nDesire > 0
-- then
-- return nDesire
-- end
-- Pickup Roshan Dropped Items
nDesire = TryPickupRefresherShard()
if nDesire > 0
then
return nDesire
end
nDesire = TryPickupCheese()
if nDesire > 0
then
return nDesire
end
SwapSmokeSupport()
-- TrySwapInvItemForCheese()
-- TrySwapInvItemForRefresherShard()
if J.Role['bStopAction'] then return 2.0 end
if not J.IsFarming(bot)
and not J.IsPushing(bot)
and not J.IsDefending(bot)
and not J.IsDoingRoshan(bot)
and not J.IsDoingTormentor(bot)
and bot:GetActiveMode() ~= BOT_MODE_RUNE
and bot:GetActiveMode() ~= BOT_MODE_SECRET_SHOP
and bot:GetActiveMode() ~= BOT_MODE_OUTPOST
and bot:GetActiveMode() ~= BOT_MODE_WARD
then
if IsHeroCore
then
local botTarget, targetDesire = X.CarryFindTarget()
if botTarget ~= nil
then
targetUnit = botTarget
bot:SetTarget(botTarget)
return targetDesire
end
end
if IsSupport
then
local botTarget, targetDesire = X.SupportFindTarget()
if botTarget ~= nil
then
targetUnit = botTarget
bot:SetTarget(botTarget)
return targetDesire
end
end
if bot:IsAlive() and bot:DistanceFromFountain() > 4600
then
if towerTime ~= 0 and X.IsValid(towerCreep)
and DotaTime() < towerTime + towerCreepTime
then
return BOT_MODE_DESIRE_ABSOLUTE *0.9;
else
towerTime = 0;
towerCreepMode = false;
end
towerCreepTime,towerCreep = X.ShouldAttackTowerCreep(bot);
if towerCreepTime ~= 0 and towerCreep ~= nil
then
if towerTime == 0 then
towerTime = DotaTime();
towerCreepMode = true;
end
bot:SetTarget(towerCreep);
return BOT_MODE_DESIRE_ABSOLUTE *0.9;
end
end
end
return 0.0;
end
function OnStart()
end
function OnEnd()
PickedItem = nil
towerTime = 0
towerCreepMode = false
bot:SetTarget(nil)
harassTarget = nil
bot.ChronoTarget = nil
end
function Think()
if J.CanNotUseAction(bot) then return end
if shouldHarass
and harassTarget ~= nil
then
bot:Action_AttackUnit(harassTarget, true)
return
end
if ShouldAttackSpecialUnit
then
if J.IsValid(bot.special_unit_target) then
bot:SetTarget(bot.special_unit_target)
bot:Action_AttackUnit(bot.special_unit_target, false)
return
end
end
if bot:HasModifier('modifier_faceless_void_chronosphere_selfbuff')
and bot.ChronoTarget ~= nil
then
bot:Action_AttackUnit(bot.ChronoTarget, true)
return
end
if towerCreepMode
then
bot:Action_AttackUnit(towerCreep, true)
return
end
if PickedItem ~= nil
then
if GetUnitToLocationDistance(bot, PickedItem.location) > 100
then
bot:Action_MoveToLocation(PickedItem.location)
return
else
bot:Action_PickUpItem(PickedItem.item)
return
end
end
if (IsHeroCore or IsSupport)
and targetUnit ~= nil and not targetUnit:IsNull() and targetUnit:CanBeSeen() and targetUnit:IsAlive()
then
bot:Action_AttackUnit(targetUnit, true)
return
end
end
function X.SupportFindTarget()
if X.CanNotUseAttack(bot) or DotaTime() < 0 then return nil,0 end
local IsModeSuitHit = X.IsModeSuitToHitCreep(bot);
local nAttackRange = bot:GetAttackRange() + 50;
if nAttackRange > 1200 then nAttackRange = 1200 end
local nTarget = J.GetProperTarget(bot);
local botHP = bot:GetHealth()/bot:GetMaxHealth();
local botMode = bot:GetActiveMode();
local botLV = bot:GetLevel();
local botAD = bot:GetAttackDamage();
local botBAD = X.GetAttackDamageToCreep(bot) - 1;
if bot:GetUnitName() == 'npc_dota_hero_jakiro' then
botAD = botAD * 2
end
if X.CanBeAttacked(nTarget) and nTarget == targetUnit
and GetUnitToUnitDistance(bot,nTarget) <= 1600
then
if nTarget:GetTeam() == bot:GetTeam()
then
if nTarget:GetHealth() > X.GetLastHitHealth(bot,nTarget)
then
return nTarget,BOT_MODE_DESIRE_VERYHIGH * 1.08;
end
return nTarget,BOT_MODE_DESIRE_VERYHIGH * 1.04;
end
if nTarget:IsCourier()
and GetUnitToUnitDistance(bot,nTarget) <= nAttackRange + 300
then
return nTarget,BOT_MODE_DESIRE_ABSOLUTE *1.5;
end
if nTarget:IsHero()
and (bot:GetCurrentMovementSpeed() < 300 or botLV >= 25)
then
return nTarget,BOT_MODE_DESIRE_ABSOLUTE *1.2;
end
if not nTarget:IsHero()
and GetUnitToUnitDistance(bot,nTarget) < nAttackRange +50
then
return nTarget,BOT_MODE_DESIRE_ABSOLUTE *0.98;
end
if not nTarget:IsHero()
and GetUnitToUnitDistance(bot,nTarget) > nAttackRange +300
then
return nTarget,BOT_MODE_DESIRE_ABSOLUTE *0.7;
end
return nTarget,BOT_MODE_DESIRE_ABSOLUTE *0.96;
end
local enemyCourier = X.GetEnemyCourier(bot, nAttackRange + botLV * 2 + 20 );
if enemyCourier ~= nil
and not enemyCourier:IsAttackImmune()
and not enemyCourier:IsInvulnerable()
then
return enemyCourier,BOT_MODE_DESIRE_ABSOLUTE * 1.5;
end
if botMode == BOT_MODE_RETREAT
and botLV > 9
and not X.CanBeInVisible(bot)
and X.ShouldNotRetreat(bot)
then
nTarget = X.WeakestUnitCanBeAttacked(true, true, nAttackRange + 50, bot)
if nTarget ~= nil
then
return nTarget,BOT_MODE_DESIRE_ABSOLUTE * 1.09;
end
end
local attackDamage = botBAD - 1;
if IsModeSuitHit
and not X.HasHumanAlly( bot )
and ( botHP > 0.5 or not bot:WasRecentlyDamagedByAnyHero(2.0) )
then
local nBonusRange = 400;
if botLV > 12 then nBonusRange = 300; end
if botLV > 20 then nBonusRange = 200; end
nTarget = X.GetNearbyLastHitCreep(false, true, attackDamage, nAttackRange + nBonusRange, bot); -----**************
if nTarget ~= nil
then
return nTarget,BOT_MODE_DESIRE_ABSOLUTE;
end
local nEnemyTowers = bot:GetNearbyTowers(nAttackRange + 150,true);
if X.CanBeAttacked(nEnemyTowers[1])
and J.IsWithoutTarget(bot)
and X.IsLastHitCreep(nEnemyTowers[1],botAD * 2)
then
return nEnemyTowers[1],BOT_MODE_DESIRE_ABSOLUTE;
end
local nNeutrals = bot:GetNearbyNeutralCreeps(nAttackRange + 150);
local nAllies = bot:GetNearbyHeroes(1300,false,BOT_MODE_NONE); -----***************
if J.IsWithoutTarget(bot)
and botMode ~= BOT_MODE_FARM
and #nNeutrals > 0
and #nAllies <= 1 ----******************
then
for i = 1,#nNeutrals
do
if X.CanBeAttacked(nNeutrals[i])
and not X.IsAllysTarget(nNeutrals[i])
and not J.IsTormentor(nNeutrals[i])
and not J.IsRoshan(nNeutrals[i])
and X.IsLastHitCreep(nNeutrals[i],attackDamage)
then
return nNeutrals[i],BOT_MODE_DESIRE_ABSOLUTE;
end
end
end
end
local denyDamage = botAD + 3
local nNearbyEnemyHeroes = bot:GetNearbyHeroes(750,true,BOT_MODE_NONE); -----------*************
if IsModeSuitHit
and bot:GetLevel() <= 8
and bot:GetNetWorth() < 13998 -----------*************
and ( botHP > 0.38 or not bot:WasRecentlyDamagedByAnyHero(3.0))
and (nNearbyEnemyHeroes[1] == nil or nNearbyEnemyHeroes[1]:GetLevel() < 10) -----------*************
and bot:DistanceFromFountain() > 3800
and J.GetDistanceFromEnemyFountain(bot) > 5000
then
local nWillAttackCreeps = X.GetExceptRangeLastHitCreep(true, attackDamage *1.5, 0, nAttackRange +60, bot);
if nWillAttackCreeps == nil
or denyDamage > 130
or not X.IsOthersTarget(nWillAttackCreeps)
or not X.IsMostAttackDamage(bot)
then
nTarget = X.GetNearbyLastHitCreep(false, false, denyDamage, nAttackRange +300, bot);
if nTarget ~= nil then
return nTarget,BOT_MODE_DESIRE_ABSOLUTE *0.97;
end
end
local nAllyTowers = bot:GetNearbyTowers(nAttackRange + 300,false);
if J.IsWithoutTarget(bot)
and #nAllyTowers > 0
then
if X.CanBeAttacked(nAllyTowers[1])
and J.GetHP(nAllyTowers[1]) < 0.08
and X.IsLastHitCreep(nAllyTowers[1],denyDamage * 3)
then
return nAllyTowers[1],BOT_MODE_DESIRE_ABSOLUTE;
end
end
end
if IsModeSuitHit
and bot:GetLevel() <= 7
and X.CanAttackTogether(bot)
and (nNearbyEnemyHeroes[1] == nil or nNearbyEnemyHeroes[1]:GetLevel() < 12)
and bot:DistanceFromFountain() > 3800
and J.GetDistanceFromEnemyFountain(bot) > 5000
then
local nAllies = bot:GetNearbyHeroes(1200,false,BOT_MODE_NONE);
local nNum = X.GetCanTogetherCount(nAllies)
local centerAlly = X.GetMostDamageUnit(nAllies);
if centerAlly ~= nil and nNum >= 2
then
local nTowerCreeps = centerAlly:GetNearbyLaneCreeps(1600,true);
local nAllyTower = bot:GetNearbyTowers(1400,false);
if(nAllyTower[1] ~= nil and nAllyTower[1]:GetAttackTarget() ~= nil)
then
local nTowerDamage = nAllyTower[1]:GetAttackDamage();
local nTowerTarget = nAllyTower[1]:GetAttackTarget();
for _,creep in pairs(nTowerCreeps)
do
if nTowerTarget == creep
and X.CanBeAttacked(creep)
and creep:GetHealth() < X.GetLastHitHealth(nAllyTower[1],creep)
and creep:GetHealth() > X.GetLastHitHealth(bot,creep)
then
local togetherDamage = 0;
local togetherCount = 0;
for _,ally in pairs(nAllies)
do
if X.CanAttackTogether(ally)
and GetUnitToUnitDistance(ally,creep) <= ally:GetAttackRange() +50
then
togetherDamage = ally:GetAttackDamage() + togetherDamage;
togetherCount = togetherCount +1;
end
end
if X.IsLastHitCreep(creep,togetherDamage)
and togetherCount >= 2
and GetUnitToUnitDistance(bot,creep) <= bot:GetAttackRange() +50
then
return creep,BOT_MODE_DESIRE_ABSOLUTE;
end
end
end
end
local nWillAttackCreeps = X.GetExceptRangeLastHitCreep(true, centerAlly:GetAttackDamage() * 1.2, 0, 800, centerAlly);
if nWillAttackCreeps == nil
or not X.IsOthersTarget(nWillAttackCreeps)
then
local nDenyCreeps = centerAlly:GetNearbyCreeps(1600,false);
for _,creep in pairs(nDenyCreeps)
do
if X.CanBeAttacked(creep)
and creep:GetHealth()/creep:GetMaxHealth() < 0.5
and not X.IsLastHitCreep(creep,denyDamage)
and not J.IsTormentor(creep)
and not J.IsRoshan(creep)
then
local togetherDamage = 0;
local togetherCount = 0;
for _,ally in pairs(nAllies)
do
if X.CanAttackTogether(ally)
and GetUnitToUnitDistance(ally,creep) <= ally:GetAttackRange() + 150
then
togetherDamage = ally:GetAttackDamage() + togetherDamage;
togetherCount = togetherCount +1;
end
end
if X.IsLastHitCreep(creep,togetherDamage)
and togetherCount >= 2
and GetUnitToUnitDistance(bot,creep) <= bot:GetAttackRange() + 150
then
return creep,BOT_MODE_DESIRE_HIGH;
end
end
end
end
end
end
local nNearbyEnemyHeroes = bot:GetNearbyHeroes(1600,true,BOT_MODE_NONE);
local nEnemyLaneCreep = bot:GetNearbyLaneCreeps(1200, true);
local nWillAttackCreeps = X.GetExceptRangeLastHitCreep(true, attackDamage *1.2, 0, nAttackRange + 120, bot);
if IsModeSuitHit
and botLV >= 6 -----------*************
and nNearbyEnemyHeroes[1] == nil
and ( attackDamage > 108 or bot:GetSecondsPerAttack() < 0.7 ) -----------*************
and ( nWillAttackCreeps == nil or not X.IsMostAttackDamage(bot) or not X.IsOthersTarget(nWillAttackCreeps))
then
local nEnemyTowers = bot:GetNearbyTowers(900,true);
local nTwoHitCreeps = bot:GetNearbyLaneCreeps(nAttackRange +150, true);
for _,creep in pairs(nTwoHitCreeps)
do
if X.CanBeAttacked(creep)
and not X.IsLastHitCreep(creep,attackDamage *1.2)
and not X.IsOthersTarget(creep)
then
local nAllyLaneCreep = bot:GetNearbyLaneCreeps(600, false);
if X.IsLastHitCreep(creep,attackDamage *2)
then
return creep,BOT_MODE_DESIRE_ABSOLUTE;
elseif X.IsLastHitCreep(creep,attackDamage *3 - 5)
and #nAllyLaneCreep == 0 and botLV >= 3
then
return creep,BOT_MODE_DESIRE_ABSOLUTE *0.9;
end
end
end
if bot:DistanceFromFountain() > 3800
and not bePvNMode and bot:GetLevel() <= 6
and J.GetDistanceFromEnemyFountain(bot) > 5000
and nEnemyTowers[1] == nil
and bot:GetNetWorth() < 19800
and denyDamage > 110
then
local nTwoHitDenyCreeps = bot:GetNearbyCreeps(nAttackRange +120, false);
for _,creep in pairs(nTwoHitDenyCreeps)
do
if X.CanBeAttacked(creep)
and creep:GetHealth()/creep:GetMaxHealth() < 0.5
and X.IsLastHitCreep(creep,denyDamage *2)
and ( not X.IsLastHitCreep(creep,denyDamage *1.2) or #nEnemyLaneCreep == 0 )
and not X.IsOthersTarget(creep)
and not J.IsTormentor(creep)
and not J.IsRoshan(creep)
then
return creep,BOT_MODE_DESIRE_ABSOLUTE;
end
end
end
end
return nil,0;
end
function X.CarryFindTarget()
if X.CanNotUseAttack(bot) or DotaTime() < 0 then return nil,0 end
local IsModeSuitHit = X.IsModeSuitToHitCreep(bot);
local nAttackRange = bot:GetAttackRange() + 50;
if nAttackRange > 1170 then nAttackRange = 1170 end
if botName == "npc_dota_hero_templar_assassin" then nAttackRange = nAttackRange + 100 end;
local nTarget = J.GetProperTarget(bot);
local botHP = bot:GetHealth()/bot:GetMaxHealth();
local botMode = bot:GetActiveMode();
local botLV = bot:GetLevel();
local botAD = bot:GetAttackDamage()
local botBAD = X.GetAttackDamageToCreep(bot)
if bot:GetUnitName() == 'npc_dota_hero_jakiro' then
botAD = botAD * 2
end
if X.CanBeAttacked(nTarget) and nTarget == targetUnit
and GetUnitToUnitDistance(bot,nTarget) <= 1600
then
if nTarget:GetTeam() == bot:GetTeam()
then
if nTarget:GetHealth() > X.GetLastHitHealth(bot,nTarget)
then
return nTarget,BOT_MODE_DESIRE_VERYHIGH * 1.08;
end
return nTarget,BOT_MODE_DESIRE_VERYHIGH * 1.04;
end
if nTarget:IsCourier()
and GetUnitToUnitDistance(bot,nTarget) <= nAttackRange + 300
then
return nTarget,BOT_MODE_DESIRE_ABSOLUTE *1.5;
end
if nTarget:IsHero()
and (bot:GetCurrentMovementSpeed() < 300 or botLV >= 25)
then
if botName == "npc_dota_hero_antimage"
then
local bAbility = bot:GetAbilityByName("antimage_blink");
if bAbility ~= nil and bAbility:IsFullyCastable()
then
return nil,BOT_MODE_DESIRE_NONE;
end
end
return nTarget,BOT_MODE_DESIRE_ABSOLUTE *1.2;
end
if not nTarget:IsHero()
and GetUnitToUnitDistance(bot,nTarget) < nAttackRange +50
then
return nTarget,BOT_MODE_DESIRE_ABSOLUTE *0.98;
end
if not nTarget:IsHero()
and GetUnitToUnitDistance(bot,nTarget) > nAttackRange +300
then
return nTarget,BOT_MODE_DESIRE_ABSOLUTE *0.7;
end
return nTarget,BOT_MODE_DESIRE_ABSOLUTE *0.96;
end
if bot:HasModifier('modifier_phantom_lancer_phantom_edge_boost')
then
return nil,0
end
local enemyCourier = X.GetEnemyCourier(bot, nAttackRange + botLV * 2 + 30);
if enemyCourier ~= nil
and not enemyCourier:IsAttackImmune()
and not enemyCourier:IsInvulnerable()
then
return enemyCourier,BOT_MODE_DESIRE_ABSOLUTE * 1.5;
end
if botMode == BOT_MODE_RETREAT
and botName ~= "npc_dota_hero_bristleback"
and botLV > 9
and not X.CanBeInVisible(bot)
and X.ShouldNotRetreat(bot)
then
nTarget = X.WeakestUnitCanBeAttacked(true, true, nAttackRange + 50, bot)
if nTarget ~= nil
then
return nTarget,BOT_MODE_DESIRE_ABSOLUTE * 1.09;
end
end
local cItem = J.IsItemAvailable("item_echo_sabre")
if cItem ~= nil and (cItem:IsFullyCastable() or cItem:GetCooldownTimeRemaining() < bot:GetAttackPoint() +0.8)
and IsModeSuitHit
and (botHP > 0.35 or not bot:WasRecentlyDamagedByAnyHero(1.0))
then
local echoDamage = botBAD *2;
if (cItem:IsFullyCastable() or cItem:GetCooldownTimeRemaining() < bot:GetAttackPoint())
then
nTarget = X.GetNearbyLastHitCreep(true, true, echoDamage, 350, bot);
if nTarget ~= nil then return nTarget,BOT_MODE_DESIRE_ABSOLUTE *0.98; end
end
local nEnemyTowers = bot:GetNearbyTowers(1000,true);
if (cItem:IsFullyCastable() or cItem:GetCooldownTimeRemaining() < bot:GetAttackPoint() +0.8)
and #nEnemyTowers == 0
then
for i=400, 580, 60 do
nTarget = X.GetExceptRangeLastHitCreep(true, echoDamage, 350, i, bot);
if nTarget ~= nil
then return nTarget,BOT_MODE_DESIRE_HIGH; end
end
end
end
local attackDamage = botBAD;
if IsModeSuitHit
and not X.HasHumanAlly( bot )
and ( botHP > 0.5 or not bot:WasRecentlyDamagedByAnyHero(2.0))
then
local nBonusRange = 430;
if botLV > 12 then nBonusRange = 380; end
if botLV > 20 then nBonusRange = 330; end
nTarget = X.GetNearbyLastHitCreep(true, true, attackDamage, nAttackRange + nBonusRange, bot);
if nTarget ~= nil
then
return nTarget,BOT_MODE_DESIRE_ABSOLUTE;
end
end
local denyDamage = botAD + 3
local nNearbyEnemyHeroes = bot:GetNearbyHeroes(650,true,BOT_MODE_NONE);
if IsModeSuitHit
and ( botHP > 0.38 or not bot:WasRecentlyDamagedByAnyHero(3.0))
and (nNearbyEnemyHeroes[1] == nil or nNearbyEnemyHeroes[1]:GetLevel() < 12)
and bot:DistanceFromFountain() > 3800
and J.GetDistanceFromEnemyFountain(bot) > 5000
then
if bot:GetLevel() <= 8
then
local nWillAttackCreeps = X.GetExceptRangeLastHitCreep(true, attackDamage *1.5, 0, nAttackRange +60, bot);
if nWillAttackCreeps == nil
or denyDamage > 130
or not X.IsOthersTarget(nWillAttackCreeps)
or not X.IsMostAttackDamage(bot)
then
nTarget = X.GetNearbyLastHitCreep(false, false, denyDamage, nAttackRange +300, bot);
if nTarget ~= nil then
return nTarget,BOT_MODE_DESIRE_ABSOLUTE *0.97;
end
end
end
local nAllyTowers = bot:GetNearbyTowers(nAttackRange + 300, false);
if J.IsWithoutTarget(bot)
and #nAllyTowers > 0
then
if X.CanBeAttacked(nAllyTowers[1])
and J.GetHP(nAllyTowers[1]) < 0.05
and X.IsLastHitCreep(nAllyTowers[1],denyDamage * 3)
then
return nAllyTowers[1],BOT_MODE_DESIRE_ABSOLUTE;
end
end
end
if IsModeSuitHit
and bot:GetLevel() <= 8
and X.CanAttackTogether(bot)
and (nNearbyEnemyHeroes[1] == nil or nNearbyEnemyHeroes[1]:GetLevel() < 12)
and bot:DistanceFromFountain() > 3800
and J.GetDistanceFromEnemyFountain(bot) > 5000
then
local nAllies = bot:GetNearbyHeroes(1200,false,BOT_MODE_NONE);
local nNum = X.GetCanTogetherCount(nAllies)
local centerAlly = X.GetMostDamageUnit(nAllies);
if centerAlly ~= nil and nNum >= 2
then
local nTowerCreeps = centerAlly:GetNearbyLaneCreeps(1600,true);
local nAllyTower = bot:GetNearbyTowers(1400,false);
if(nAllyTower[1] ~= nil and nAllyTower[1]:GetAttackTarget() ~= nil)
then
local nTowerDamage = nAllyTower[1]:GetAttackDamage();
local nTowerTarget = nAllyTower[1]:GetAttackTarget();
for _,creep in pairs(nTowerCreeps)
do
if nTowerTarget == creep
and X.CanBeAttacked(creep)
and creep:GetHealth() < X.GetLastHitHealth(nAllyTower[1],creep)
and creep:GetHealth() > X.GetLastHitHealth(bot,creep)
then
local togetherDamage = 0;
local togetherCount = 0;
for _,ally in pairs(nAllies)
do
if X.CanAttackTogether(ally)
and GetUnitToUnitDistance(ally,creep) <= ally:GetAttackRange() +50
then
togetherDamage = ally:GetAttackDamage() + togetherDamage;
togetherCount = togetherCount +1;
end
end
if X.IsLastHitCreep(creep,togetherDamage)
and togetherCount >= 2
and GetUnitToUnitDistance(bot,creep) <= bot:GetAttackRange() +50
then
return creep,BOT_MODE_DESIRE_ABSOLUTE;
end
end
end
end
local nWillAttackCreeps = X.GetExceptRangeLastHitCreep(true, centerAlly:GetAttackDamage() *1.2, 0, 800, centerAlly);
if nWillAttackCreeps == nil
or not X.IsOthersTarget(nWillAttackCreeps)
then
local nDenyCreeps = centerAlly:GetNearbyCreeps(1600,false);
for _,creep in pairs(nDenyCreeps)
do
if X.CanBeAttacked(creep)
and creep:GetHealth()/creep:GetMaxHealth() < 0.5
and not X.IsLastHitCreep(creep,denyDamage)
and not J.IsTormentor(creep)
and not J.IsRoshan(creep)
then
local togetherDamage = 0;
local togetherCount = 0;
for _,ally in pairs(nAllies)
do
if X.CanAttackTogether(ally)
and GetUnitToUnitDistance(ally,creep) <= ally:GetAttackRange() + 150
then
togetherDamage = ally:GetAttackDamage() + togetherDamage;
togetherCount = togetherCount +1;
end
end
if X.IsLastHitCreep(creep,togetherDamage)
and togetherCount >= 2
and GetUnitToUnitDistance(bot,creep) <= bot:GetAttackRange() + 150
then
return creep,BOT_MODE_DESIRE_HIGH;
end
end
end
end
end
end
local nNearbyEnemyHeroes = bot:GetNearbyHeroes(1600,true,BOT_MODE_NONE);
local nEnemyLaneCreep = bot:GetNearbyLaneCreeps(1200, true);
local nWillAttackCreeps = X.GetExceptRangeLastHitCreep(true, attackDamage *1.2, 0, nAttackRange + 120, bot);
if IsModeSuitHit
and botLV >= 8
and nNearbyEnemyHeroes[1] == nil
and ( attackDamage > 118 or bot:GetSecondsPerAttack() < 0.7 )
and ( nWillAttackCreeps == nil or not X.IsMostAttackDamage(bot) or not X.IsOthersTarget(nWillAttackCreeps))
then
local nEnemyTowers = bot:GetNearbyTowers(900,true);
if botName ~= "npc_dota_hero_templar_assassin"
then
local nTwoHitCreeps = bot:GetNearbyLaneCreeps(nAttackRange +150, true);
for _,creep in pairs(nTwoHitCreeps)
do
if X.CanBeAttacked(creep)
and not X.IsLastHitCreep(creep,attackDamage *1.2)
and not X.IsOthersTarget(creep)
then
local nAllyLaneCreep = bot:GetNearbyLaneCreeps(600, false);
if X.IsLastHitCreep(creep,attackDamage *2)
then
return creep,BOT_MODE_DESIRE_ABSOLUTE;
elseif X.IsLastHitCreep(creep,attackDamage *3 - 5)
and #nAllyLaneCreep == 0 and botLV >= 3
then
return creep,BOT_MODE_DESIRE_ABSOLUTE *0.9;
end
end
end
end
if bot:DistanceFromFountain() > 3800
and not bePvNMode and bot:GetLevel() <= 6
and J.GetDistanceFromEnemyFountain(bot) > 5000
and nEnemyTowers[1] == nil
and bot:GetNetWorth() < 19800
and denyDamage > 110
then
local nTwoHitDenyCreeps = bot:GetNearbyCreeps(nAttackRange +120, false);
for _,creep in pairs(nTwoHitDenyCreeps)
do
if X.CanBeAttacked(creep)
and creep:GetHealth()/creep:GetMaxHealth() < 0.5
and X.IsLastHitCreep(creep,denyDamage *2)
and ( not X.IsLastHitCreep(creep,denyDamage *1.2) or #nEnemyLaneCreep == 0 )
and not X.IsOthersTarget(creep)
and not J.IsTormentor(creep)
and not J.IsRoshan(creep)
then
return creep,BOT_MODE_DESIRE_ABSOLUTE;
end
end
end
local nEnemysCreeps = bot:GetNearbyCreeps(1600,true)
local nAttackAlly = J.GetSpecialModeAllies(bot, 2500, BOT_MODE_ATTACK);
local nTeamFightLocation = J.GetTeamFightLocation(bot);
local nDefendLane,nDefendDesire = J.GetMostDefendLaneDesire();
if X.CanBeAttacked(nEnemysCreeps[1])
and bot:GetHealth() > 300
and not X.IsAllysTarget(nEnemysCreeps[1])
and not J.IsRoshan(nEnemysCreeps[1])
and (nEnemysCreeps[1]:GetTeam() == TEAM_NEUTRAL or attackDamage > 110)
and ( not nEnemysCreeps[1]:IsAncientCreep() or attackDamage > 150 )
and ( not J.IsKeyWordUnit("warlock", nEnemysCreeps[1]) or J.GetHP(bot) > 0.58 )
and ( nTeamFightLocation == nil or GetUnitToLocationDistance(bot,nTeamFightLocation) >= 3000 )
and ( nDefendDesire <= 0.8 )
and botMode ~= BOT_MODE_FARM
and botMode ~= BOT_MODE_RUNE
and botMode ~= BOT_MODE_LANING
and botMode ~= BOT_MODE_ASSEMBLE
and botMode ~= BOT_MODE_SECRET_SHOP
and botMode ~= BOT_MODE_SIDE_SHOP
and botMode ~= BOT_MODE_WARD
and GetRoshanDesire() < BOT_MODE_DESIRE_HIGH
and not bot:WasRecentlyDamagedByAnyHero(2.0)
and bot:GetAttackTarget() == nil
and botLV >= 10
and #nAttackAlly == 0
and #nEnemyTowers == 0
and not J.IsTormentor(nEnemysCreeps[1])
and not J.IsRoshan(nEnemysCreeps[1])
then
if nEnemysCreeps[1]:GetTeam() == TEAM_NEUTRAL
and J.IsInRange(bot, nEnemysCreeps[1], nAttackRange + 100)
and ( #nEnemysCreeps <= 2
or attackDamage > 220
or botName == "npc_dota_hero_antimage" )
then
J.Role['availableCampTable'] = X.UpdateCommonCamp(nEnemysCreeps[1], J.Role['availableCampTable']);
end
return nEnemysCreeps[1],BOT_MODE_DESIRE_ABSOLUTE;
end
if bot:GetHealth() > 160
and J.IsWithoutTarget(bot)
then
local nNeutrals = bot:GetNearbyNeutralCreeps(nAttackRange + 150);
if #nNeutrals > 0
and botMode ~= BOT_MODE_FARM
then
for i = 1,#nNeutrals
do
if X.CanBeAttacked(nNeutrals[i])
and not X.IsAllysTarget(nNeutrals[i])
and not J.IsTormentor(nNeutrals[i])
and not J.IsRoshan(nNeutrals[i])
and X.IsLastHitCreep(nNeutrals[i],attackDamage * 2)
then
return nNeutrals[i],BOT_MODE_DESIRE_ABSOLUTE;
end
end
end
end
end
return nil,0;
end
function X.IsValid(nUnit)
return nUnit ~= nil and not nUnit:IsNull() and nUnit:IsAlive() and nUnit:CanBeSeen()