-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathability_item_usage_generic.lua
More file actions
3843 lines (3678 loc) · 127 KB
/
ability_item_usage_generic.lua
File metadata and controls
3843 lines (3678 loc) · 127 KB
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
---@diagnostic disable: undefined-global
_G._savedEnv = getfenv()
module("ability_item_usage_generic", package.seeall)
require(GetScriptDirectory() .. "/utility")
require(GetScriptDirectory() .. "/teleportation_usage_generic")
--#region COURIER THINK
function CourierUsageThink()
local npcBot = GetBot();
if npcBot == nil or not utility.IsHero(npcBot) or utility.IsClone(npcBot) or utility.IsCloneMeepo(npcBot)
then
return;
end
local courier = utility.GetBotCourier(npcBot);
local state = GetCourierState(courier);
if (state == COURIER_STATE_DEAD)
then
return;
end
local burst = courier:GetAbilityByName("courier_burst");
--local autoDeliver = courier:GetAbilityByName("courier_autodeliver");
local shield = courier:GetAbilityByName("courier_shield");
local canCastBurst = burst ~= nil and burst:IsFullyCastable();
local canCastShield = shield ~= nil and shield:IsFullyCastable();
--local canCastAutoDeliver = autoDeliver ~= nil and autoDeliver:IsFullyCastable();
--local courierHealth = courier:GetHealth() / courier:GetMaxHealth();
if (state == COURIER_STATE_IDLE) or
(npcBot.secretShopMode ~= true and
state ~= COURIER_STATE_AT_BASE and
state ~= COURIER_STATE_DELIVERING_ITEMS and
state ~= COURIER_STATE_RETURNING_TO_BASE)
then
--npcBot:ActionImmediate_Chat("Курьер бездельничает!", true);
npcBot:ActionImmediate_Courier(courier, COURIER_ACTION_RETURN_STASH_ITEMS);
return;
end
if (state == COURIER_STATE_DELIVERING_ITEMS)
then
if (canCastBurst) and GetUnitToUnitDistance(courier, npcBot) >= 3000
then
npcBot:ActionImmediate_Courier(courier, COURIER_ACTION_BURST);
end
end
--[[ if canCastAutoDeliver
then
if npcBot:GetCourierValue() > 0
then
if not autoDeliver:GetAutoCastState()
then
npcBot:ActionImmediate_Chat("Автодоставка: Вкл: " .. autoDeliver:GetName(), true);
autoDeliver:ToggleAutoCast()
end
else
if autoDeliver:GetAutoCastState()
then
npcBot:ActionImmediate_Chat("Автодоставка: Выкл: " .. autoDeliver:GetName(), true);
autoDeliver:ToggleAutoCast()
end
end
end ]]
if ((utility.CountEnemyHeroAroundUnit(courier, 1000) > 0 or utility.CountEnemyTowerAroundUnit(courier, 1000) > 0) and not courier:IsInvulnerable())
or (courier:GetHealth() < courier:GetMaxHealth())
then
if canCastBurst and state == COURIER_STATE_MOVING and courier:DistanceFromFountain() > 1000
then
npcBot:ActionImmediate_Courier(courier, COURIER_ACTION_BURST);
end
if canCastShield and courier:GetHealth() < courier:GetMaxHealth()
then
npcBot:ActionImmediate_Courier(courier, COURIER_ACTION_SHIELD);
--courier:Action_UseAbility(shield);
--npcBot:ActionImmediate_Chat("Курьер юзает щит: " .. shield:GetName(), true);
end
if (state ~= COURIER_STATE_RETURNING_TO_BASE)
then
npcBot:ActionImmediate_Courier(courier, COURIER_ACTION_RETURN_STASH_ITEMS);
return;
end
else
if (state ~= COURIER_STATE_MOVING) and (state ~= COURIER_STATE_DELIVERING_ITEMS)
then
if npcBot:IsAlive()
then
if (npcBot:GetStashValue() > 100) and (state == COURIER_STATE_AT_BASE)
then
npcBot:ActionImmediate_Courier(courier, COURIER_ACTION_TAKE_AND_TRANSFER_ITEMS);
return;
elseif (npcBot:GetCourierValue() > 0) and (npcBot:GetStashValue() <= 0)
then
npcBot:ActionImmediate_Courier(courier, COURIER_ACTION_TRANSFER_ITEMS);
return;
elseif (npcBot.secretShopMode == true) and (npcBot:DistanceFromSecretShop() >= 3000) and (npcBot:GetCourierValue() <= 0)
and not utility.IsCourierItemSlotsFull() and (state == COURIER_STATE_AT_BASE)
then
npcBot:ActionImmediate_Courier(courier, COURIER_ACTION_SECRET_SHOP);
return;
end
else
if (npcBot.secretShopMode == true) and not utility.IsCourierItemSlotsFull() and (npcBot:GetCourierValue() <= 0) and (state == COURIER_STATE_AT_BASE)
then
npcBot:ActionImmediate_Courier(courier, COURIER_ACTION_SECRET_SHOP);
return;
end
end
end
end
end
--#endregion
--#region BUYBACK THINK
function BuybackUsageThink()
local npcBot = GetBot();
if not npcBot:IsHero() or npcBot:IsAlive() or npcBot:IsIllusion() or utility.IsClone(npcBot) or utility.IsCloneMeepo(npcBot)
then
return;
end
if not npcBot:HasBuyback() or (npcBot:GetGold() < npcBot:GetBuybackCost()) or npcBot:GetBuybackCooldown() > 0
then
return;
end
local respawnTime = npcBot:GetRespawnTime();
if (respawnTime >= 60.0)
then
if (npcBot.idletime == nil)
then
npcBot.idletime = GameTime()
else
if (GameTime() - npcBot.idletime >= 5)
then
npcBot.idletime = nil;
npcBot:ActionImmediate_Buyback();
--npcBot:ActionImmediate_Chat("Выкупаюсь!", false);
return;
end
end
end
end
--#endregion
--#region GLYPH THINK
function GlyphUsageThink()
local npcBot = GetBot();
if npcBot == nil or not utility.IsHero(npcBot) or utility.IsClone(npcBot) or utility.IsCloneMeepo(npcBot) or GetGlyphCooldown() > 0
then
return;
end
local towers = {
TOWER_TOP_1,
TOWER_TOP_2,
TOWER_TOP_3,
TOWER_MID_1,
TOWER_MID_2,
TOWER_MID_3,
TOWER_BOT_1,
TOWER_BOT_2,
TOWER_BOT_3,
TOWER_BASE_1,
TOWER_BASE_2,
}
for _, t in pairs(towers)
do
local tower = GetTower(GetTeam(), t);
if tower ~= nil and (tower:GetHealth() > 0 and tower:GetHealth() / tower:GetMaxHealth() <= 0.7)
and utility.IsTargetedByEnemy(tower, true)
then
npcBot:ActionImmediate_Chat("Использую Glyph для защиты " .. tower:GetUnitName(), false);
npcBot:ActionImmediate_Ping(tower:GetLocation().x, tower:GetLocation().y, false);
npcBot:ActionImmediate_Glyph();
return;
end
end
local barracks = {
BARRACKS_TOP_MELEE,
BARRACKS_TOP_RANGED,
BARRACKS_MID_MELEE,
BARRACKS_MID_RANGED,
BARRACKS_BOT_MELEE,
BARRACKS_BOT_RANGED,
}
for _, b in pairs(barracks)
do
local barrack = GetBarracks(GetTeam(), b);
if barrack ~= nil and (barrack:GetHealth() > 0 and barrack:GetHealth() / barrack:GetMaxHealth() <= 0.8)
and utility.IsTargetedByEnemy(barrack, true)
then
npcBot:ActionImmediate_Chat("Использую Glyph для защиты " .. barrack:GetUnitName(), false);
npcBot:ActionImmediate_Ping(barrack:GetLocation().x, barrack:GetLocation().y, false);
npcBot:ActionImmediate_Glyph();
return;
end
end
local ancient = GetAncient(GetTeam());
if ancient ~= nil and (ancient:GetHealth() > 0 and ancient:GetHealth() / ancient:GetMaxHealth() <= 0.8)
and utility.IsTargetedByEnemy(ancient, true)
then
npcBot:ActionImmediate_Chat("Использую Glyph для защиты " .. ancient:GetUnitName(), false);
npcBot:ActionImmediate_Ping(ancient:GetLocation().x, ancient:GetLocation().y, false);
npcBot:ActionImmediate_Glyph();
return;
end
end
--#endregion
--#region ITEM USAGE THINK
local function HaveHealthRegenBuff(npcTarget)
return npcTarget:HasModifier('modifier_fountain_aura_buff') or
npcTarget:HasModifier('modifier_bottle_regeneration') or
npcTarget:HasModifier('modifier_flask_healing');
end
local function HaveManaRegenBuff(npcTarget)
return npcTarget:HasModifier('modifier_fountain_aura_buff') or
npcTarget:HasModifier('modifier_bottle_regeneration') or
npcTarget:HasModifier('modifier_clarity_potion') or
npcTarget:HasModifier("modifier_mana_draught_regeneratio")
end
local function IsItemAvailable(item_name)
local npcBot = GetBot();
local slot = npcBot:FindItemSlot(item_name);
local item = npcBot:GetItemInSlot(slot);
if item ~= nil and item:GetName() == item_name and item:IsFullyCastable()
then
if item_name == "item_smoke_of_deceit"
then
if npcBot:GetItemSlotType(slot) == ITEM_SLOT_TYPE_MAIN or
npcBot:GetItemSlotType(slot) == ITEM_SLOT_TYPE_BACKPACK
then
return item;
end
else
if npcBot:GetItemSlotType(slot) == ITEM_SLOT_TYPE_MAIN
then
return item;
end
end
end
return nil;
end
local function IsNeutralItemAvailable(item_name)
local npcBot = GetBot();
local neutralItem = npcBot:GetItemInSlot(16);
if neutralItem ~= nil and neutralItem:GetName() == item_name and neutralItem:IsFullyCastable()
then
return neutralItem;
end
return nil;
end
local function Contains(set, key) -- Содержит ли таблица указанный коюч
for index, value in ipairs(set) do
if tostring(value) == tostring(key)
then
return true;
end
end
end
-- Имена способностей для использования которых необходимо использовать item_refresher
local _tableOfUltimatesAbility =
{
"abaddon_borrowed_time",
"antimage_mana_void",
"bane_fiends_grip",
"batrider_flaming_lasso",
"beastmaster_primal_roar",
"bloodseeker_rupture",
"brewmaster_primal_split",
"chen_hand_of_god",
"crystal_maiden_freezing_field",
"dark_seer_wall_of_replica",
"dark_willow_terrorize",
"dazzle_shallow_grave",
"death_prophet_exorcism",
"doom_bringer_doom",
"earthshaker_echo_slam",
"elder_titan_earth_splitter",
"enigma_black_hole",
"faceless_void_chronosphere",
"gyrocopter_call_down",
"jakiro_macropyre",
"juggernaut_omni_slash",
"kunkka_ghostship",
"lich_chain_frost",
"lion_finger_of_death",
"luna_eclipse",
"magnataur_reverse_polarity",
"medusa_stone_gaze",
"monkey_king_wukongs_command",
"necrolyte_reapers_scythe",
"nevermore_requiem",
"obsidian_destroyer_sanity_eclipse",
"omniknight_guardian_angel",
"oracle_false_promise",
"phoenix_supernova",
"queenofpain_sonic_wave",
"sandking_epicenter",
"shadow_shaman_mass_serpent_ward",
"silencer_global_silence",
"skeleton_king_reincarnation",
"skywrath_mage_mystic_flare",
"slark_shadow_dance",
"snapfire_mortimer_kisses",
"spectre_haunt",
"spirit_breaker_nether_strike",
"sven_gods_strength",
"terrorblade_metamorphosis",
"tidehunter_ravage",
"treant_overgrowth",
"tusk_walrus_punch",
"undying_tombstone",
"venomancer_noxious_plague",
"warlock_rain_of_chaos",
"winter_wyvern_winters_curse",
"witch_doctor_death_ward",
"zuus_thundergods_wrath",
}
local previousKills = 0;
local isVictorySay = false;
local isDefeatSay = false;
local linesKillEnemyHero = {
"You'll be lucky next time...or not.",
"No luck - pure skill!",
"It was easy!",
"Don't be upset, it's just a game, you know?",
"Ha! Not bad, huh?",
"You can do better!",
"Next time, try not to die!",
"I learned from the best, what chance did you even have?",
"Are there passive bots against us or what?",
"You're not very good at this game, are you?",
}
local linesDefeat = {
"GG.",
"Well played.",
"Next time we will win.",
"Wow, that's unexpected.",
"I'm waiting for a tip on my profile!",
}
local linesVictory = {
"GG.",
"Well played.",
"Easiest win!",
"Didn't even break a sweat! Go next?",
"Try practicing with bots, okay?",
"We won? I mean... of course we won!",
"Well done everyone!",
}
local function BotChatMessages()
local npcBot = GetBot();
--local currentKills = GetHeroKills(npcBot:GetPlayerID());
local ancient = GetAncient(GetTeam());
local enemyAncient = GetAncient(GetOpposingTeam());
if ancient ~= nil and not ancient:IsInvulnerable() and ancient:GetHealth() / ancient:GetMaxHealth() < 0.1
then
if (isDefeatSay == false)
then
--local message = linesDefeat[math.random(#linesDefeat)];
local message = linesDefeat[RandomInt(1, #linesDefeat)];
npcBot:ActionImmediate_Chat(message, true);
isDefeatSay = true;
return;
end
end
if enemyAncient ~= nil and enemyAncient:CanBeSeen() and not enemyAncient:IsInvulnerable() and enemyAncient:GetHealth() / enemyAncient:GetMaxHealth() < 0.1
then
if (isVictorySay == false)
then
--local message = linesVictory[math.random(#linesVictory)];
local message = linesVictory[RandomInt(1, #linesVictory)];
npcBot:ActionImmediate_Chat(message, true);
isVictorySay = true;
return;
end
end
--[[ if (currentKills > previousKills)
then
if RollPercentage(95)
then
local message = linesKillEnemyHero[math.random(#linesKillEnemyHero)];
npcBot:ActionImmediate_Chat(message, true);
end
previousKills = currentKills;
return;
end ]]
end
--local message = nil;
--local message = linesKillEnemyHero[math.random(#linesKillEnemyHero)];
local function EventAbilityUsage()
local npcBot = GetBot();
if not utility.IsHero(npcBot) or utility.IsCloneMeepo(npcBot) or utility.IsClone(npcBot) or not utility.CanCast(npcBot) or RollPercentage(50)
then
return;
end
local botTarget = npcBot:GetTarget();
-- Hive Five usage
local HighFive = npcBot:GetAbilityByName("plus_high_five");
if HighFive ~= nil and utility.IsAbilityAvailable(HighFive)
then
local radiusAbility = HighFive:GetSpecialValueInt("acknowledge_range");
if utility.PvPMode(npcBot)
then
if utility.IsHero(botTarget) and GetUnitToUnitDistance(npcBot, botTarget) <= radiusAbility
then
npcBot:Action_UseAbility(HighFive);
return;
end
end
if utility.RetreatMode(npcBot)
then
local enemyAbility = npcBot:GetNearbyHeroes(radiusAbility, true, BOT_MODE_NONE);
if (#enemyAbility > 0)
then
npcBot:Action_UseAbility(HighFive);
return;
end
end
--npcBot:ActionImmediate_Chat(HighFive:GetName() .. " обнаружен.", true);
end
end
function ItemUsageThink()
local npcBot = GetBot();
GlyphUsageThink()
utility.FixDelayBot()
if not utility.IsHero(npcBot) or not utility.CanUseItems(npcBot) or utility.IsCloneMeepo(npcBot) or
(npcBot:IsInvisible() and not npcBot:HasModifier("modifier_invisible"))
then
return;
end
if not utility.IsClone(npcBot)
then
BotChatMessages()
EventAbilityUsage()
end
local botMode = npcBot:GetActiveMode();
local attackRange = npcBot:GetAttackRange();
local botTarget = npcBot:GetTarget();
local botVisionRange = npcBot:GetCurrentVisionRange();
local healthPercent = npcBot:GetHealth() / npcBot:GetMaxHealth();
local manaPercent = npcBot:GetMana() / npcBot:GetMaxMana();
local incomingSpells = npcBot:GetIncomingTrackingProjectiles();
-- NO INTERRUPT CAST ITEM
-- item_shadow_amulet/item_glimmer_cape
local shadowAmulet = IsItemAvailable('item_shadow_amulet');
local glimmerCape = IsItemAvailable('item_glimmer_cape');
if shadowAmulet ~= nil
then
local itemRange = shadowAmulet:GetCastRange();
local allyHeroes = npcBot:GetNearbyHeroes(itemRange, false, BOT_MODE_NONE);
if (#allyHeroes > 0)
then
for _, ally in pairs(allyHeroes)
do
if utility.IsHero(ally) and not ally:IsInvisible() and not ally:HasModifier("modifier_spirit_breaker_charge_of_darkness")
then
if (ally:GetHealth() / ally:GetMaxHealth() <= 0.8 and ally:WasRecentlyDamagedByAnyHero(2.0)) or ally:IsChanneling() or
ally:HasModifier("modifier_crystal_maiden_freezing_field") or
ally:HasModifier("modifier_teleporting") or
ally:HasModifier("modifier_wisp_relocate_return")
then
--npcBot:ActionImmediate_Chat("Использую shadow Amulet на союзнике!", true);
npcBot:Action_UseAbilityOnEntity(shadowAmulet, ally);
return;
end
end
end
end
end
if glimmerCape ~= nil
then
local itemRange = glimmerCape:GetCastRange();
local allyHeroes = npcBot:GetNearbyHeroes(itemRange, false, BOT_MODE_NONE);
if (#allyHeroes > 0)
then
for _, ally in pairs(allyHeroes)
do
if utility.IsHero(ally) and not ally:IsInvisible()
then
if (ally:GetHealth() / ally:GetMaxHealth() <= 0.8 and ally:WasRecentlyDamagedByAnyHero(2.0)) or ally:IsChanneling() or
ally:HasModifier("modifier_crystal_maiden_freezing_field") or
ally:HasModifier("modifier_teleporting") or
ally:HasModifier("modifier_wisp_relocate_return") or
ally:HasModifier("modifier_spirit_breaker_charge_of_darkness")
then
--npcBot:ActionImmediate_Chat("Использую glimmerCape на союзнике!", true);
npcBot:Action_UseAbilityOnEntity(glimmerCape, ally);
return;
end
end
end
end
end
-- INTERRUPT CAST ITEMS
if npcBot:IsChanneling() or npcBot:IsUsingAbility() or npcBot:IsCastingAbility()
then
return;
end
--[[ local slotTP = npcBot:FindItemSlot("item_tpscroll");
local kek = npcBot:GetItemSlotType(slotTP);
--local tp = npcBot:GetItemInSlot(15);
if slotTP ~= nil and kek ~= nil
then
npcBot:ActionImmediate_Chat("Слот тп: " .. slotTP .. " Тип слота: " .. kek, true);
end ]]
-- item_tpscroll
-- tp_scroll slot type -1
local tpScroll = npcBot:GetItemInSlot(15);
if tpScroll ~= nil and tpScroll:IsFullyCastable()
then
local shouldTP, tpLocation = teleportation_usage_generic.ShouldTP();
if shouldTP and tpLocation ~= nil
then
--npcBot:ActionImmediate_Chat("Телепортируюсь", true);
npcBot:Action_UseAbilityOnLocation(tpScroll, tpLocation);
return;
end
end
-- item_ward_sentry
local wardSentry = IsItemAvailable("item_ward_sentry");
if wardSentry ~= nil
then
local itemRange = wardSentry:GetCastRange();
local itemRadius = wardSentry:GetSpecialValueInt("true_sight_range");
if utility.PvPMode(npcBot) or utility.PvEMode(npcBot) or utility.WanderMode(npcBot) or botMode == BOT_MODE_LANING
then
local enemyHeroes = npcBot:GetNearbyHeroes(itemRadius, true, BOT_MODE_DESIRE_NONE);
if (#enemyHeroes > 0)
then
for _, enemy in pairs(enemyHeroes)
do
if enemy:IsInvisible() and utility.IsHero(enemy) and not enemy:HasModifier("modifier_item_dustofappearance")
then
if utility.CountEnemyTowerAroundPosition(enemy:GetLocation(), itemRadius) <= 0 and
utility.CountAllyTowerAroundPosition(enemy:GetLocation(), itemRadius) <= 0 and
not utility.CloseToAvailableWard("npc_dota_sentry_wards", enemy:GetLocation(), itemRadius)
then
--npcBot:ActionImmediate_Chat("Использую предмет wardSentry против невидимых героев!", true);
npcBot:Action_UseAbilityOnLocation(wardSentry,
utility.GetMaxRangeCastLocation(npcBot, enemy, itemRange));
npcBot:ActionImmediate_Ping(enemy:GetLocation().x, enemy:GetLocation().y, false);
return;
end
end
end
end
end
end
-- item_tango/item_tango_single
local tango = IsItemAvailable("item_tango");
local tangoSingle = IsItemAvailable("item_tango_single");
if tango ~= nil
then
local itemRange = tango:GetCastRange();
local itemHeal = tango:GetSpecialValueInt("health_regen") * tango:GetSpecialValueInt("buff_duration");
local trees = npcBot:GetNearbyTrees(itemRange * 2);
local allyHeroes = npcBot:GetNearbyHeroes(itemRange + botVisionRange, false, BOT_MODE_NONE);
if npcBot:GetHealth() < npcBot:GetMaxHealth() - itemHeal and
(#trees > 0) and
IsLocationVisible(GetTreeLocation(trees[1])) and
IsLocationPassable(GetTreeLocation(trees[1])) and
npcBot:DistanceFromFountain() > 1000 and
utility.CanBeHeal(npcBot) and
not HaveHealthRegenBuff(npcBot) and
not npcBot:HasModifier("modifier_tango_heal")
then
npcBot:Action_UseAbilityOnTree(tango, trees[1]);
return;
end
if not utility.PvPMode(npcBot) and not utility.RetreatMode(npcBot)
then
if (#allyHeroes > 1)
then
for _, ally in pairs(allyHeroes)
do
if ally ~= npcBot and utility.IsHero(ally) and (ally:GetHealth() / ally:GetMaxHealth() <= 0.6)
and utility.GetItemCount(ally, "item_tango") == 0 and utility.GetItemCount(ally, "item_tango_single") == 0
and not ally:HasModifier("modifier_tango_heal") and utility.CanBeHeal(ally) and not utility.IsTargetItemSlotsFull(ally)
then
npcBot:Action_UseAbilityOnEntity(tango, ally);
return;
end
end
end
end
end
if tangoSingle ~= nil
then
local itemRange = tangoSingle:GetCastRange();
local itemHeal = tangoSingle:GetSpecialValueInt("health_regen") * tangoSingle:GetSpecialValueInt("buff_duration");
local trees = npcBot:GetNearbyTrees(itemRange + botVisionRange);
if npcBot:GetHealth() < npcBot:GetMaxHealth() - itemHeal and
(#trees > 0) and
IsLocationVisible(GetTreeLocation(trees[1])) and
IsLocationPassable(GetTreeLocation(trees[1])) and
utility.CanBeHeal(npcBot) and
not npcBot:HasModifier("modifier_tango_heal")
then
npcBot:Action_UseAbilityOnTree(tangoSingle, trees[1]);
return;
end
end
-- item_flask/item_clarity
local flask = IsItemAvailable("item_flask");
local clarity = IsItemAvailable("item_clarity");
if flask ~= nil
then
local itemRange = flask:GetCastRange();
local itemHeal = flask:GetSpecialValueInt("health_regen") * flask:GetSpecialValueInt("buff_duration");
local allyHeroes = npcBot:GetNearbyHeroes(itemRange * 2, false, BOT_MODE_NONE);
if (#allyHeroes > 0)
then
for _, ally in pairs(allyHeroes)
do
if utility.IsHero(ally) and
ally:GetHealth() < ally:GetMaxHealth() - itemHeal and
ally:TimeSinceDamagedByAnyHero() >= 5.0 and
ally:TimeSinceDamagedByCreep() >= 5.0 and
ally:DistanceFromFountain() > 3000 and
not HaveHealthRegenBuff(ally) and
utility.CanBeHeal(ally)
then
--npcBot:ActionImmediate_Chat("Использую предмет flask что бы подлечить союзника!",true);
npcBot:Action_UseAbilityOnEntity(flask, ally);
return;
end
end
end
end
if clarity ~= nil
then
local itemRange = clarity:GetCastRange();
local itemManaRegen = clarity:GetSpecialValueInt("mana_regen") * clarity:GetSpecialValueInt("buff_duration");
local allyHeroes = npcBot:GetNearbyHeroes(itemRange * 2, false, BOT_MODE_NONE);
if (#allyHeroes > 0)
then
for _, ally in pairs(allyHeroes)
do
if utility.IsHero(ally) and
ally:GetMana() < ally:GetMaxMana() - itemManaRegen and
ally:TimeSinceDamagedByAnyHero() >= 5.0 and
ally:TimeSinceDamagedByCreep() >= 5.0 and
ally:DistanceFromFountain() > 3000 and
not HaveManaRegenBuff(ally)
then
npcBot:Action_UseAbilityOnEntity(clarity, ally);
return;
end
end
end
end
-- item_faerie_fire
local faerieFire = IsItemAvailable("item_faerie_fire");
if faerieFire ~= nil
then
if npcBot:DistanceFromFountain() > 1000 and (healthPercent <= 0.2) and utility.CanBeHeal(npcBot) and
(utility.BotWasRecentlyDamagedByEnemyHero(2.0) or npcBot:WasRecentlyDamagedByTower(2.0) or npcBot:WasRecentlyDamagedByCreep(2.0))
then
--npcBot:ActionImmediate_Chat("Использую предмет Faerie Fire что бы подлечить себя!",true);
npcBot:Action_UseAbility(faerieFire);
return;
end
end
-- item_enchanted_mango
local enchantedMango = IsItemAvailable("item_enchanted_mango");
if enchantedMango ~= nil
then
if utility.PvPMode(npcBot) and (manaPercent <= 0.3) and GetUnitToUnitDistance(npcBot, botTarget) <= 2000
then
--npcBot:ActionImmediate_Chat("Использую предмет Enchanted Mango! что бы восстановить себе ману!",true);
npcBot:Action_UseAbility(enchantedMango);
return;
end
end
-- item_blood_grenade
local bloodGrenade = IsItemAvailable("item_blood_grenade");
if bloodGrenade ~= nil
then
local itemRange = bloodGrenade:GetCastRange();
if utility.PvPMode(npcBot)
then
if utility.IsHero(botTarget) and utility.CanCastSpellOnTarget(bloodGrenade, botTarget) and GetUnitToUnitDistance(npcBot, botTarget) <= itemRange
then
--npcBot:ActionImmediate_Chat("Использую bloodGrenade по врагу!", true);
npcBot:Action_UseAbilityOnLocation(bloodGrenade, botTarget:GetLocation());
return;
end
end
if utility.RetreatMode(npcBot)
then
local enemyHeroes = npcBot:GetNearbyHeroes(itemRange, true, BOT_MODE_NONE);
if (#enemyHeroes > 0) and (healthPercent >= 0.2 and healthPercent <= 0.6)
then
for _, enemy in pairs(enemyHeroes)
do
if utility.CanCastSpellOnTarget(bloodGrenade, enemy) and not utility.IsDisabled(enemy)
then
--npcBot:ActionImmediate_Chat("Использую предмет bloodGrenade для оступления!", true);
npcBot:Action_UseAbilityOnLocation(bloodGrenade, enemy:GetLocation());
return;
end
end
end
end
end
-- item_healing_lotus/item_great_healing_lotus
local healingLotus = IsItemAvailable("item_famango");
local greatHealingLotus = IsItemAvailable("item_great_famango");
local greaterHealingLotus = IsItemAvailable("item_greater_famango");
if (healingLotus ~= nil) or (greatHealingLotus ~= nil) or (greaterHealingLotus ~= nil)
then
if healingLotus ~= nil and (healthPercent <= 0.8 or manaPercent <= 0.8)
then
--npcBot:ActionImmediate_Chat("Использую предмет healingLotus!", true);
npcBot:Action_UseAbility(healingLotus);
return;
end
if greatHealingLotus ~= nil and (healthPercent <= 0.6 or manaPercent <= 0.6)
then
--npcBot:ActionImmediate_Chat("Использую предмет greatHealingLotus!", true);
npcBot:Action_UseAbility(greatHealingLotus);
return;
end
if greaterHealingLotus ~= nil and (healthPercent <= 0.5 or manaPercent <= 0.5)
then
--npcBot:ActionImmediate_Chat("Использую предмет greaterHealingLotus!", true);
npcBot:Action_UseAbility(greaterHealingLotus);
return;
end
end
-- item_cheese
local cheese = IsItemAvailable("item_cheese");
if cheese ~= nil
then
if (healthPercent <= 0.3) and (utility.BotWasRecentlyDamagedByEnemyHero(2.0) or npcBot:WasRecentlyDamagedByTower(2.0))
and utility.CanBeHeal(npcBot)
then
npcBot:Action_UseAbility(cheese);
return;
end
end
-- item_soul_ring
local soulRing = IsItemAvailable("item_soul_ring");
if soulRing ~= nil
then
local itemHealthCost = soulRing:GetSpecialValueInt("AbilityHealthCost");
local itemMana = soulRing:GetSpecialValueInt("mana_gain");
if utility.PvPMode(npcBot) and not npcBot:IsSilenced()
then
if utility.IsHero(botTarget) and npcBot:GetHealth() > itemHealthCost and GetUnitToUnitDistance(npcBot, botTarget) <= (attackRange * 3)
then
for i = 0, 23, 1 do
local ability = npcBot:GetAbilityInSlot(i)
if ability ~= nil and not ability:IsTalent() and not ability:IsHidden() and not ability:IsPassive()
and ability:IsCooldownReady() and npcBot:GetMana() < ability:GetManaCost()
then
if npcBot:GetMana() + itemMana >= ability:GetManaCost()
then
--npcBot:ActionImmediate_Chat("Использую предмет soulRing что бы восстановить себе ману!",true);
npcBot:Action_UseAbility(soulRing);
return;
end
end
end
end
end
if utility.RetreatMode(npcBot)
then
local reincarnation = npcBot:GetAbilityByName("skeleton_king_reincarnation");
if reincarnation ~= nil and not reincarnation:IsHidden() and reincarnation:IsCooldownReady() and npcBot:GetMana() < reincarnation:GetManaCost()
and (healthPercent <= 0.2) and utility.BotWasRecentlyDamagedByEnemyHero(2.0)
then
if npcBot:GetMana() + itemMana >= reincarnation:GetManaCost()
then
npcBot:Action_UseAbility(soulRing);
return;
end
end
end
end
-- item_magic_stick/item_magic_wand/item_holy_locket
local magicStick = IsItemAvailable("item_magic_stick");
local magicWand = IsItemAvailable("item_magic_wand");
local holyLocket = IsItemAvailable("item_holy_locket");
if magicStick ~= nil
then
if (healthPercent <= 0.5) or (manaPercent <= 0.4) and utility.CanBeHeal(npcBot)
and magicStick:GetCurrentCharges() > 1
then
--npcBot:ActionImmediate_Chat("Использую magic Stick!", true);
npcBot:Action_UseAbility(magicStick);
return;
end
end
if magicWand ~= nil
then
if (healthPercent <= 0.5) or (manaPercent <= 0.4) and utility.CanBeHeal(npcBot)
and magicWand:GetCurrentCharges() > 1
then
--npcBot:ActionImmediate_Chat("Использую magic Stick!", true);
npcBot:Action_UseAbility(magicWand);
return;
end
end
if holyLocket ~= nil
then
local itemRange = holyLocket:GetCastRange();
local allyHeroes = npcBot:GetNearbyHeroes(itemRange, false, BOT_MODE_NONE);
if (#allyHeroes > 0)
then
for _, ally in pairs(allyHeroes)
do
if utility.IsHero(ally) and utility.CanBeHeal(ally) and holyLocket:GetCurrentCharges() > 1
then
if (ally:GetHealth() / ally:GetMaxHealth() <= 0.7)
then
npcBot:Action_UseAbilityOnEntity(holyLocket, ally);
return;
elseif (ally:GetMana() / ally:GetMaxMana() <= 0.5)
then
npcBot:Action_UseAbilityOnEntity(holyLocket, ally);
return;
end
end
end
end
end
-- item_dust
local dust = IsItemAvailable("item_dust");
if dust ~= nil
then
local itemRange = dust:GetAOERadius();
local enemyHeroes = npcBot:GetNearbyHeroes(itemRange, true, BOT_MODE_NONE);
if (#enemyHeroes > 0)
then
for _, enemy in pairs(enemyHeroes)
do
if enemy:IsInvisible() and utility.IsHero(enemy) and not enemy:HasModifier("modifier_item_dustofappearance")
then
--npcBot:ActionImmediate_Chat("Использую предмет dust против невидимых героев!",true);
npcBot:Action_UseAbility(dust);
npcBot:ActionImmediate_Ping(enemy:GetLocation().x, enemy:GetLocation().y, true);
return;
end
end
end
end
-- item_gem
local gemOfTrueSight = IsItemAvailable("item_gem");
if gemOfTrueSight ~= nil
then
local itemRange = gemOfTrueSight:GetSpecialValueInt("active_radius");
local enemyHeroes = npcBot:GetNearbyHeroes(itemRange, true, BOT_MODE_NONE);
if (#enemyHeroes > 0)
then
for _, enemy in pairs(enemyHeroes)
do
if enemy:IsInvisible()
then
--npcBot:ActionImmediate_Chat("Использую предмет gemOfTrueSight против невидимых героев!", true);
npcBot:Action_UseAbilityOnLocation(gemOfTrueSight, enemy:GetLocation());
return;
end
end
end
end
-- item_smoke_of_deceit
local smokeOfDeceit = IsItemAvailable("item_smoke_of_deceit");
if smokeOfDeceit ~= nil
then
local itemRange = smokeOfDeceit:GetAOERadius();
local visibilityRadius = smokeOfDeceit:GetSpecialValueInt("visibility_radius");
local allyHeroes = npcBot:GetNearbyHeroes(itemRange, false, BOT_MODE_NONE);
local enemyHeroes = npcBot:GetNearbyHeroes(visibilityRadius, true, BOT_MODE_NONE);
local enemyTowers = npcBot:GetNearbyTowers(visibilityRadius, true);
-- Attack/Boss use
if (#enemyHeroes <= 0 and #enemyTowers <= 0)
then
if utility.PvPMode(npcBot) or utility.BossMode(npcBot)
then
if utility.IsHero(botTarget) or utility.IsBoss(botTarget)
then
if (GetUnitToUnitDistance(npcBot, botTarget) > visibilityRadius and GetUnitToUnitDistance(npcBot, botTarget) <= visibilityRadius * 2) and
not npcBot:IsInvisible() and not npcBot:HasModifier("modifier_smoke_of_deceit")
then
--npcBot:ActionImmediate_Chat("Использую предмет smokeOfDeceit для атаки!", true);
npcBot:Action_UseAbility(smokeOfDeceit);
return;
end
end
end
end
if (#allyHeroes > 0)
then
for _, ally in pairs(allyHeroes)
do
local enemyHeroes = ally:GetNearbyHeroes(visibilityRadius, true, BOT_MODE_NONE);
local enemyTowers = ally:GetNearbyTowers(visibilityRadius, true);
if (#enemyHeroes <= 0 and #enemyTowers <= 0)
then
if utility.IsHero(ally) and not ally:IsInvisible() and not ally:HasModifier("modifier_smoke_of_deceit") and
ally:GetCurrentActionType() ~= BOT_ACTION_TYPE_ATTACK and ally:GetCurrentActionType() ~= BOT_ACTION_TYPE_ATTACKMOVE
then
-- Pre game use
if GetGameState() == GAME_STATE_PRE_GAME
then
if (ally:GetCurrentActionType() ~= BOT_ACTION_TYPE_NONE and
ally:GetCurrentActionType() ~= BOT_ACTION_TYPE_IDLE and
ally:GetCurrentActionType() ~= BOT_ACTION_TYPE_DELAY)
then
--npcBot:ActionImmediate_Chat("Использую предмет smokeOfDeceit в начале игры!",true);
npcBot:Action_UseAbility(smokeOfDeceit);
return;
end
end
-- Try to safe ally use
if ally:GetHealth() / ally:GetMaxHealth() <= 0.6 and
(ally:WasRecentlyDamagedByAnyHero(2.0) or
ally:WasRecentlyDamagedByTower(2.0) or
ally:WasRecentlyDamagedByCreep(2.0))
then
--npcBot:ActionImmediate_Chat("Использую предмет smokeOfDeceit для защиты!", true);
npcBot:Action_UseAbility(smokeOfDeceit);
return;
end
end
end
end
end
end
-- item_quelling_blade/item_bfury
local quellingBlade = IsItemAvailable('item_quelling_blade');
local battleFury = IsItemAvailable('item_bfury');
if quellingBlade ~= nil
then
local itemRange = quellingBlade:GetCastRange();
local trees = npcBot:GetNearbyTrees(itemRange);
if not utility.PvPMode(npcBot) and not utility.RetreatMode(npcBot) and npcBot:GetCurrentActionType() ~= BOT_ACTION_TYPE_ATTACK and
(#trees > 0) and IsLocationVisible(GetTreeLocation(trees[1])) and IsLocationPassable(GetTreeLocation(trees[1]))
then
--npcBot:ActionImmediate_Chat("Использую quelling Blade!", true);
npcBot:Action_UseAbilityOnTree(quellingBlade, trees[1]);
return;
end
end