-
Notifications
You must be signed in to change notification settings - Fork 23
/
AutoDodger2.lua
1311 lines (1169 loc) · 70.1 KB
/
AutoDodger2.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
local AutoDodger2 = {}
AutoDodger2.option = Menu.AddOption({"Utility", "Super Auto Dodger"}, "Enable", "Automatically dodges projectiles.")
AutoDodger2.linearOption = Menu.AddOption({"Utility", "Super Auto Dodger", "Dodge Linear Projectiles"}, "Enable", "")
AutoDodger2.impactRadiusOption = Menu.AddOption({"Utility", "Super Auto Dodger", "Dodge Linear Projectiles"}, "Impact Radius", "",100,1000,100)
AutoDodger2.disjointOption = Menu.AddOption({"Utility", "Super Auto Dodger","Dodge Disjoint"}, "Enable", "")
AutoDodger2.impactDistanceOption = Menu.AddOption({"Utility", "Super Auto Dodger","Dodge Disjoint"}, "Safe Distance offset", "",100,2000,100)
AutoDodger2.animationOption = Menu.AddOption({"Utility", "Super Auto Dodger","Dodge Animation"}, "Enable", "")
AutoDodger2.castPointOption = Menu.AddOption({"Utility", "Super Auto Dodger","Dodge Animation"}, "CastPoint Offset", "", 1,10,1 )
AutoDodger2.skillItemOption = Menu.AddOption({"Utility", "Super Auto Dodger"}, "Use Item First", "Use item first to dodge skills")
AutoDodger2.skillOption = Menu.AddOption({"Utility", "Super Auto Dodger"}, "Use Skill", "Use skill to dodge skills")
AutoDodger2.itemOption= Menu.AddOption({"Utility", "Super Auto Dodger"}, "Use Item", "Use item to dodge skills")
AutoDodger2.allItemOption = Menu.AddOption({"Utility", "Super Auto Dodger", "Item"}, "Use All Selected Items", "Use all selected items to dodge skills")
AutoDodger2.daggerOption = Menu.AddOption({"Utility", "Super Auto Dodger","Item"}, "Use Dagger", "Use Dagger to dodge skills", -1, 10, 1)
AutoDodger2.blademailOption = Menu.AddOption({"Utility", "Super Auto Dodger","Item"}, "Use BladeMail", "Use BladeMail to defend",-1, 10, 1)
AutoDodger2.ghostOption = Menu.AddOption({"Utility", "Super Auto Dodger","Item"}, "Use Ghost Scepter", "Use Ghost Scepter to defend",-1, 10, 1)
AutoDodger2.mantaOption = Menu.AddOption({"Utility", "Super Auto Dodger","Item"}, "Use Manta", "Use Manta to dodge skills",-1, 10, 1)
AutoDodger2.eulOption = Menu.AddOption({"Utility", "Super Auto Dodger","Item"}, "Use Eul", "Use Eul to dodge skills",-1, 10, 1)
AutoDodger2.lotusOption = Menu.AddOption({"Utility", "Super Auto Dodger","Item"}, "Use Lotus", "Use Lotus to dodge skills",-1, 10, 1)
AutoDodger2.sbOption = Menu.AddOption({"Utility", "Super Auto Dodger","Item"}, "Use Shadow Blade", "Use Shadow Blade to dodge skills",-1, 10, 1)
AutoDodger2.bkbOption = Menu.AddOption({"Utility", "Super Auto Dodger","Item"}, "Use BKB", "Use BKB to dodge skills",-1, 10, 1)
AutoDodger2.capeOption = Menu.AddOption({"Utility", "Super Auto Dodger","Item"}, "Use Glimmer Cape", "Use GlimmerCape to dodge skills",-1, 10, 1)
AutoDodger2.dodgeTick = 0
-- logic for specific particle effects will go here.
AutoDodger2.particleLogic =
{
require("AutoDodger2/PudgeLogic")--,
-- require("AutoDodger2/LinaLogic")
}
AutoDodger2.activeProjectiles = {}
AutoDodger2.knownRanges = {}
AutoDodger2.ignoredProjectileNames = {}
AutoDodger2.ignoredProjectileHashes = {}
AutoDodger2.projectileQueue ={}
AutoDodger2.projectileQueueLength = 0.0
AutoDodger2.impactRadius = 400
AutoDodger2.canReset = true
AutoDodger2.AnimationQueue ={}
AutoDodger2.AnimationQueueLength = 0
AutoDodger2.nextDodgeTime = 0.0
AutoDodger2.nextDodgeTimeProjectile = 0.0
AutoDodger2.nextDodgeTimeAnimation = 0.0
AutoDodger2.movePos = Vector()
AutoDodger2.fountainPos = Vector()
AutoDodger2.active = false
AutoDodger2.drawPos = nil
AutoDodger2.mapFont = Renderer.LoadFont("Tahoma", 50, Enum.FontWeight.NORMAL)
AutoDodger2.skillPickerOption = Menu.AddOption({ "Utility", "Super Auto Dodger"}, "Skill Picker", "Displays enemy hero cooldowns in an easy and intuitive way.")
AutoDodger2.boxSizeOption = Menu.AddOption({ "Utility", "Super Auto Dodger","Skill Picker Setting" }, "Display Size", "", 21, 64, 1)
AutoDodger2.needsInit = true
AutoDodger2.spellIconPath = "resource/flash3/images/spellicons/"
AutoDodger2.cachedIcons = {}
AutoDodger2.w = 1920
AutoDodger2.h = 1080
AutoDodger2.colors = {}
AutoDodger2.skillSelected = {}
AutoDodger2.itemOrder = {}
function AutoDodger2.InsertColor(alias, r_, g_, b_)
table.insert(AutoDodger2.colors, { name = alias, r = r_, g = g_, b = b_})
end
Menu.SetValueName(AutoDodger2.daggerOption, -1, 'OFF')
Menu.SetValueName(AutoDodger2.blademailOption, -1, 'OFF')
Menu.SetValueName(AutoDodger2.ghostOption, -1, 'OFF')
Menu.SetValueName(AutoDodger2.mantaOption, -1, 'OFF')
Menu.SetValueName(AutoDodger2.eulOption, -1, 'OFF')
Menu.SetValueName(AutoDodger2.lotusOption, -1, 'OFF')
Menu.SetValueName(AutoDodger2.sbOption, -1, 'OFF')
Menu.SetValueName(AutoDodger2.bkbOption, -1, 'OFF')
Menu.SetValueName(AutoDodger2.capeOption, -1, 'OFF')
function AutoDodger2.setItemOrder()
AutoDodger2.itemOrder = {
{Menu.GetValue(AutoDodger2.daggerOption), "item_blink"},
{Menu.GetValue(AutoDodger2.blademailOption), "item_blade_mail"},
{Menu.GetValue(AutoDodger2.ghostOption), "item_ghost"},
{Menu.GetValue(AutoDodger2.mantaOption), "item_manta"},
{Menu.GetValue(AutoDodger2.eulOption),"item_cyclone"},
{Menu.GetValue(AutoDodger2.lotusOption),"item_lotus_orb"},
{Menu.GetValue(AutoDodger2.sbOption),"item_invis_sword"},
{Menu.GetValue(AutoDodger2.bkbOption),"item_black_king_bar"},
{Menu.GetValue(AutoDodger2.capeOption),"item_glimmer_cape"}
}
table.sort(AutoDodger2.itemOrder, function(a, b)
return a[1] > b[1]
end)
Log.Write('...........')
for k,v in pairs(AutoDodger2.itemOrder) do
Log.Write(v[1]..':'..v[2])
end
end
AutoDodger2.InsertColor("Green", 0, 255, 0)
AutoDodger2.InsertColor("Yellow", 234, 255, 0)
AutoDodger2.InsertColor("Red", 255, 0, 0)
AutoDodger2.InsertColor("Blue", 0, 0, 255)
AutoDodger2.InsertColor("White", 255, 255, 255)
AutoDodger2.InsertColor("Black", 0, 0, 0)
AutoDodger2.levelColorOption = Menu.AddOption({ "Utility", "Super Auto Dodger","Skill Picker Setting" }, "Level Color", "", 1, #AutoDodger2.colors, 1)
for i, v in ipairs(AutoDodger2.colors) do
Menu.SetValueName(AutoDodger2.levelColorOption, i, v.name)
end
function AutoDodger2.InitDisplay()
AutoDodger2.boxSize = Menu.GetValue(AutoDodger2.boxSizeOption)
AutoDodger2.innerBoxSize = AutoDodger2.boxSize - 2
AutoDodger2.levelBoxSize = math.floor(AutoDodger2.boxSize * 0.1875)
AutoDodger2.font = Renderer.LoadFont("Tahoma", math.floor(AutoDodger2.innerBoxSize * 0.643), Enum.FontWeight.BOLD)
local w, h = Renderer.GetScreenSize()
AutoDodger2.w = math.floor(w/2)
AutoDodger2.h = math.floor(h/2)
end
-------------------------------------------------------------------------------------------------------
function AutoDodger2.OnUpdate()
--Log.Write(AutoDodger2.nextDodgeTimeProjectile..', '..GameRules.GetGameTime())
--Log.Write(AutoDodger2.projectileQueueLength)
if not Menu.IsEnabled(AutoDodger2.option) then return end
AutoDodger2.ProcessLinearProjectile()
AutoDodger2.ProcessProjectile()
AutoDodger2.ProcessAnimation()
AutoDodger2.ProcessChoosingSkills()
end
--------------------------------------------------------------------------------------------------------
function AutoDodger2.DodgeLogicProjectile(key, mode)
if Menu.GetValue(AutoDodger2.skillItemOption) then
local dodged = AutoDodger2.DodgeLogicItem(key, mode, false)
AutoDodger2.DodgeLogicSkill(key, mode, dodged)
else
local dodged = AutoDodger2.DodgeLogicSkill(key, mode,false)
AutoDodger2.DodgeLogicItem(key, mode, dodged)
end
end
function AutoDodger2.DodgeLogicItem(key, mode, dodged)
if not Menu.IsEnabled(AutoDodger2.itemOption) then return false end
local myHero = Heroes.GetLocal()
local eul = NPC.GetItem(myHero, "item_cyclone")
local lotus = NPC.GetItem(myHero, "item_lotus_orb")
local bladeMail = NPC.GetItem(myHero, "item_blade_mail")
local manta = NPC.GetItem(myHero, "item_manta")
local ghost = NPC.GetItem(myHero, "item_ghost")
local eblade = NPC.GetItem(myHero, "item_ethereal_blade")
local blink = NPC.GetItem(myHero, "item_blink")
local shadowblade = NPC.GetItem(myHero, "item_invis_sword")
local glimmerCape = NPC.GetItem(myHero, "item_glimmer_cape")
local bkb = NPC.GetItem(myHero, "item_black_king_bar")
local myTeam = Entity.GetTeamNum(myHero)
local myMana = NPC.GetMana(myHero)
local myPos = Entity.GetAbsOrigin(myHero)
local myName = NPC.GetUnitName(myHero)
AutoDodger2.setItemOrder()
local dodgeAll = Menu.IsEnabled(AutoDodger2.allItemOption)
for k,v in ipairs(AutoDodger2.itemOrder) do
local order = v[1]
local item = v[2]
if order ~= -1 then
if (not dodged or dodgeAll) and eul and Ability.IsCastable(eul,myMana) and item == "item_cyclone" then
Ability.CastTarget(eul,myHero)
dodged = true
end
if (not dodged or dodgeAll) and lotus and Ability.IsCastable(lotus,myMana) and item == "item_lotus_orb" then
Ability.CastTarget(lotus,myHero)
dodged = true
end
if (not dodged or dodgeAll) and bladeMail and Ability.IsCastable(bladeMail,myMana) and item == "item_blade_mail" then
Ability.CastNoTarget(bladeMail)
dodged = true
end
if (not dodged or dodgeAll) and manta and Ability.IsCastable(manta,myMana) and item == "item_manta" then
Ability.CastNoTarget(manta)
dodged = true
end
if (not dodged or dodgeAll) and ghost and Ability.IsCastable(ghost,myMana) and item == "item_ghost" then
Ability.CastNoTarget(ghost)
dodged = true
end
if (not dodged or dodgeAll) and eblade and Ability.IsCastable(eblade,myMana) and item == "item_ethereal_blade" then
Ability.CastTarget(eblade,myHero)
dodged = true
end
if (not dodged or dodgeAll) and blink and Ability.IsCastable(blink,myMana) and item == "item_blink" then
AutoDodger2.DodgeByMoveForward(myHero, 1199, blink)
dodged = true
end
if (not dodged or dodgeAll) and shadowblade and Ability.IsCastable(shadowblade,myMana) and item == "item_invis_sword" then
Ability.CastNoTarget(shadowblade)
dodged = true
end
if (not dodged or dodgeAll) and glimmerCape and Ability.IsCastable(glimmerCape,myMana) and item == "item_glimmer_cape" then
Ability.CastTarget(glimmerCape,myHero)
dodged = true
end
if (not dodged or dodgeAll) and bkb and Ability.IsCastable(bkb,myMana) and item == "item_black_king_bar" then
Ability.CastNoTarget(bkb)
dodged = true
end
end
end
return dodged
end
function AutoDodger2.DodgeLogicSkill(key, mode, dodged)
if not Menu.IsEnabled(AutoDodger2.skillOption) then return false end
local myHero = Heroes.GetLocal()
local myTeam = Entity.GetTeamNum(myHero)
local myMana = NPC.GetMana(myHero)
local myPos = Entity.GetAbsOrigin(myHero)
local myName = NPC.GetUnitName(myHero)
if dodged then return end
if myName == "npc_dota_hero_puck" then
local skill = NPC.GetAbility(myHero, "puck_phase_shift")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
Ability.CastNoTarget(skill)
AutoDodger2.dodgeTick = GameRules.GetGameTime()+1
dodged = true
end
end
if myName == "npc_dota_hero_bane" then
local skill = NPC.GetAbility(myHero, "bane_nightmare")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
Ability.CastTarget(skill,myHero)
dodged = true
end
end
if myName == "npc_dota_hero_omniknight" then
local skill = NPC.GetAbility(myHero, "omniknight_repel")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
Ability.CastTarget(skill,myHero)
dodged = true
end
end
if myName == "npc_dota_hero_shadow_demon" then
local skill = NPC.GetAbility(myHero, "shadow_demon_disruption")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
Ability.CastTarget(skill,myHero)
dodged = true
end
end
if myName == "npc_dota_hero_obsidian_destroyer" then
local skill = NPC.GetAbility(myHero, "obsidian_destroyer_astral_imprisonment")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
Ability.CastTarget(skill,myHero)
dodged = true
end
end
if myName == "npc_dota_hero_abaddon" then
local skill = NPC.GetAbility(myHero, "abaddon_aphotic_shield")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
Ability.CastTarget(skill,myHero)
dodged = true
end
end
if myName == "npc_dota_hero_life_stealer" then
local skill = NPC.GetAbility(myHero, "life_stealer_rage")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
Ability.CastNoTarget(skill)
dodged = true
end
end
if myName == "npc_dota_hero_sand_king" then
local skill = NPC.GetAbility(myHero, "sandking_sand_storm")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
Ability.CastNoTarget(skill)
dodged = true
end
end
if myName == "npc_dota_hero_juggernaut" then
local skill = NPC.GetAbility(myHero, "juggernaut_blade_fury")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
Ability.CastNoTarget(skill)
dodged = true
end
end
if myName == "npc_dota_hero_clinkz" then
local skill = NPC.GetAbility(myHero, "clinkz_wind_walk")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
Ability.CastNoTarget(skill)
dodged = true
end
end
if myName == "npc_dota_hero_alchemist" then
local skill = NPC.GetAbility(myHero, "alchemist_chemical_rage")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
Ability.CastNoTarget(skill)
dodged = true
end
end
if myName == "npc_dota_hero_nyx_assassin" then
local skill = NPC.GetAbility(myHero, "nyx_assassin_spiked_carapace")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
Ability.CastNoTarget(skill)
dodged = true
end
end
if myName == "npc_dota_hero_slark" then
local skill = NPC.GetAbility(myHero, "slark_dark_pact")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
Ability.CastNoTarget(skill)
dodged = true
end
end
if myName == "npc_dota_hero_bounty_hunter" then
local skill = NPC.GetAbility(myHero, "bounty_hunter_wind_walk")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
Ability.CastNoTarget(skill)
dodged = true
end
end
if myName == "npc_dota_hero_weaver" then
local skill = NPC.GetAbility(myHero, "weaver_shukuchi")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
Ability.CastNoTarget(skill)
dodged = true
end
end
if myName == "npc_dota_hero_medusa" then
local skill = NPC.GetAbility(myHero, "medusa_mana_shield")
if skill and not NPC.HasModifier(myHero, "modifier_medusa_mana_shield") and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
Ability.Toggle(skill)
dodged = true
end
end
if myName == "npc_dota_hero_templar_assassin" then
local skill = NPC.GetAbility(myHero, "templar_assassin_meld")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
Ability.CastNoTarget(skill)
dodged = true
end
skill = NPC.GetAbility(myHero, "templar_assassin_refraction")
if not dodged and skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
Ability.CastNoTarget(skill)
dodged = true
end
end
if myName == "npc_dota_hero_morphling" then
local skill = NPC.GetAbility(myHero, "morphling_waveform")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
AutoDodger2.DodgeByMoveForward(myHero, 1000, skill)
dodged = true
end
end
if myName == "npc_dota_hero_storm_spirit" then
local skill = NPC.GetAbility(myHero, "storm_spirit_ball_lightning")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
AutoDodger2.DodgeByMoveForward(myHero, 500, skill)
dodged = true
end
end
if myName == "npc_dota_hero_queenofpain" then
local skill = NPC.GetAbility(myHero, "queenofpain_blink")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
AutoDodger2.DodgeByMoveForward(myHero, 1000, skill)
dodged = true
end
end
if myName == "npc_dota_hero_faceless_void" then
local skill = NPC.GetAbility(myHero, "faceless_void_time_walk")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
AutoDodger2.DodgeByMoveForward(myHero, 1000, skill)
dodged = true
end
end
if myName == "npc_dota_hero_phantom_lancer" then
local skill = NPC.GetAbility(myHero, "phantom_lancer_doppelwalk")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
AutoDodger2.DodgeByMoveForward(myHero, 600, skill)
dodged = true
end
end
-- if myName == "npc_dota_hero_lone_druid" then
-- local skill = NPC.GetAbility(myHero, "lone_druid_true_form")
-- if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
-- Ability.CastNoTarget(skill)
-- dodged = true
-- end
-- skill = NPC.GetAbility(myHero, "lone_druid_true_form_druid")
-- if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
-- Ability.CastNoTarget(skill)
-- dodged = true
-- end
-- end
-- if myName == "npc_dota_hero_riki" then
-- local skill = NPC.GetAbility(myHero, "riki_blink_strike")
-- if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
-- AutoDodger2.DodgeByAttackNearUnits(myHero, 800, skill)
-- end
-- end
if myName == "npc_dota_hero_tusk" then
local skill = NPC.GetAbility(myHero, "tusk_snowball")
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
AutoDodger2.DodgeByAttackNearUnits(myHero, 1250, skill)
end
end
if myName == "npc_dota_hero_ember_spirit" then
local skill = NPC.GetAbility(myHero, "ember_spirit_sleight_of_fist")
local level = Ability.GetLevel(skill)
local range = 700
local fistRadius = {250,350,450,550}
local radius = range + fistRadius[level]
if skill and Ability.IsReady(skill) and Ability.IsCastable(skill,myMana) then
local units = NPC.GetUnitsInRadius(myHero, radius, Enum.TeamType.TEAM_ENEMY)
if #units >0 then
local candidate
for i =1, #units do
if (NPC.IsCreep(units[i]) or NPC.IsHero(units[i])) and Entity.IsAlive(units[i]) then
candidate = units[i]
break
end
end
if candidate then
local enemyPos = Entity.GetAbsOrigin(candidate)
local vec = enemyPos - myPos
local distance = vec:Length2D()
if distance <700 then
Ability.CastPosition(skill, enemyPos)
else
vec:Normalize()
local castPos = vec:Scaled(700) + myPos
Ability.CastPosition(skill, castPos)
end
dodged = true
end
end
end
end
return dodged
end
function AutoDodger2.DodgeByAttackNearUnits(myHero, radius, skill)
local units = NPC.GetUnitsInRadius(myHero, radius, Enum.TeamType.TEAM_ENEMY)
local dodged = false
if #units >0 then
local candidate
for i =1, #units do
if (NPC.IsCreep(units[i]) or NPC.IsHero(units[i])) and Entity.IsAlive(units[i]) then
candidate = units[i]
break
end
end
if candidate then
Ability.CastTarget(skill,candidate)
dodged = true
end
end
return dodged
end
function AutoDodger2.DodgeByMoveToBase(myHero, distance, skill)
AutoDodger2.fountainPos = AutoDodger2.GetFountainPosition(Entity.GetTeamNum(myHero))
local myPos = Entity.GetAbsOrigin(myHero)
local vec = AutoDodger2.fountainPos - myPos
vec=vec:Normalized()
vec=vec:Scaled(distance-1)
vec = vec + myPos
Ability.CastPosition(skill, vec)
end
function AutoDodger2.DodgeByMoveForward(myHero, distance, skill)
local myPos = Entity.GetAbsOrigin(myHero)
local angle = Entity.GetRotation(myHero)
local angleOffset = Angle(0, 45, 0)
angle:SetYaw(angle:GetYaw() + angleOffset:GetYaw())
local x,y,z = angle:GetVectors()
local direction = x + y + z
direction = direction:Normalized()
direction = direction:Scaled(distance)
direction = myPos + direction
Ability.CastPosition(skill, direction)
end
--------------------------------------------------------------------------------------------------------
function AutoDodger2.InsertIgnoredProjectile(name)
AutoDodger2.ignoredProjectileNames[name] = true
end
AutoDodger2.InsertIgnoredProjectile("tinker_machine")
AutoDodger2.InsertIgnoredProjectile("weaver_swarm_projectile")
function AutoDodger2.Reset()
if not AutoDodger2.canReset then return end
AutoDodger2.activeProjectiles = {}
AutoDodger2.nextDodgeTime = 0.0
AutoDodger2.canReset = false
AutoDodger2.skillSelected ={}
AutoDodger2.projectileQueueLength = 0
AutoDodger2.AnimationQueueLength = 0
AutoDodger2.projectileQueue={}
AutoDodger2.setItemOrder()
end
function AutoDodger2.GetFountainPosition(teamNum)
for i = 1, NPCs.Count() do
local npc = NPCs.Get(i)
if Entity.GetTeamNum(npc) == teamNum and NPC.IsStructure(npc) then
local name = NPC.GetUnitName(npc)
if name ~= nil and name == "dota_fountain" then
return NPC.GetAbsOrigin(npc)
end
end
end
end
function AutoDodger2.GetRange(index)
local knownRange = AutoDodger2.knownRanges[index]
if knownRange == nil then return 2000 end
return knownRange
end
function AutoDodger2.OnProjectile(projectile)
if not Menu.IsEnabled(AutoDodger2.option) then return end
if not Menu.IsEnabled(AutoDodger2.disjointOption) then return end
if not projectile.source or projectile.isAttack then return end
local myHero = Heroes.GetLocal()
local enemy = projectile.source
if projectile.target ~= myHero then return end
local myTeam = Entity.GetTeamNum(myHero)
local enemyTeam = Entity.GetTeamNum(enemy)
local sameTeam = Entity.GetTeamNum(enemy) == myTeam
if sameTeam then return end
local myPos = Entity.GetAbsOrigin(myHero)
local enemyPos = Entity.GetAbsOrigin(enemy)
local distance = myPos - enemyPos
local distanceLenth = distance:Length2D() - NPC.GetHullRadius(myHero) - Menu.GetValue(AutoDodger2.impactDistanceOption)
local delay = (distanceLenth/projectile.moveSpeed)
delay = math.max(delay, 0.001)
Log.Write(projectile.name)
if (AutoDodger2.projectileMap[projectile.name] and AutoDodger2.projectileMapRev[AutoDodger2.projectileMap[projectile.name].ability].selected or not AutoDodger2.projectileMap[projectile.name]) and not AutoDodger2.ignoredDisjoint[projectile.name] then
-- table.insert(AutoDodger2.projectileQueue, {GameRules.GetGameTime()+delay,projectile.name})
AutoDodger2.projectileQueue[projectile.particleSystemHandle] = {
source = projectile.source,
target = projectile.target,
origin = Entity.GetAbsOrigin(projectile.source),
moveSpeed = projectile.moveSpeed,
index = projectile.particleSystemHandle,
time = GameRules.GetGameTime(),
dodgeTime = delay + GameRules.GetGameTime(),
name = projectile.name,
}
AutoDodger2.projectileQueueLength = AutoDodger2.projectileQueueLength + 1
end
end
function AutoDodger2.OnLinearProjectileCreate(projectile)
if not Menu.IsEnabled(AutoDodger2.option) then return end
if not Menu.IsEnabled(AutoDodger2.linearOption) then return end
if not projectile.source then return end
if Entity.IsSameTeam(Heroes.GetLocal(), projectile.source) then return end
local shouldIgnore = AutoDodger2.ignoredProjectileHashes[projectile.particleIndex]
if shouldIgnore == true then
return
elseif shouldIgnore == nil then
if AutoDodger2.ignoredProjectileNames[projectile.name] then
AutoDodger2.ignoredProjectileHashes[projectile.particleIndex] = true
return
else
AutoDodger2.ignoredProjectileHashes[projectile.particleIndex] = false
end
end
AutoDodger2.canReset = true
AutoDodger2.activeProjectiles[projectile.handle] = { source = projectile.source,
origin = projectile.origin,
velocity = projectile.velocity,
index = projectile.particleIndex,
time = GameRules.GetGameTime(),
name = projectile.name
}
end
function AutoDodger2.OnLinearProjectileDestroy(projectile)
if not Menu.IsEnabled(AutoDodger2.option) then return end
if not Menu.IsEnabled(AutoDodger2.linearOption) then return end
local projectileData = AutoDodger2.activeProjectiles[projectile.handle]
if not projectileData then return end
local curtime = GameRules.GetGameTime()
local t = curtime - projectileData.time
local curPos = projectileData.origin + (projectileData.velocity:Scaled(t))
local range = (curPos - projectileData.origin):Length2D()
local knownRange = AutoDodger2.knownRanges[projectileData.index]
if knownRange == nil or knownRange < range then
AutoDodger2.knownRanges[projectileData.index] = range
end
AutoDodger2.activeProjectiles[projectile.handle] = nil
end
--------------------------------------------------------------------------------------------------
function AutoDodger2.OnUnitAnimation(animation)
if not Menu.IsEnabled(AutoDodger2.option) then return end
if not animation or not animation.unit then return end
local myHero = Heroes.GetLocal()
if not myHero or Entity.IsSameTeam(myHero, animation.unit) or not NPC.IsHero(animation.unit) then return end
local sequenceName = animation.sequenceName
local enemy = animation.unit
local enemyName = NPC.GetUnitName(animation.unit)
--Log.Write(animation.sequenceName.." Animation")
if AutoDodger2.animationMap[sequenceName] and AutoDodger2.animationMapReverse[AutoDodger2.animationMap[sequenceName].ability].selected then
Log.Write("Yay")
AutoDodger2.AnimationQueue[sequenceName] ={
time = GameRules.GetGameTime()+animation.castpoint,
sequenceName = sequenceName,
enemy = enemy,
enemyName = enemyName,
castPoint = animation.castpoint
}
AutoDodger2.AnimationQueueLength = AutoDodger2.AnimationQueueLength + 1
end
end
function AutoDodger2.OnPrepareUnitOrders(orders)
if not Menu.IsEnabled(AutoDodger2.option) then return true end
if GameRules.GetGameTime()>AutoDodger2.dodgeTick then return true end
return false
end
--------------------------------------------------------------------------------------------------
function AutoDodger2.OnParticleCreate(particle)
--Log.Write(particle.name)
if not Menu.IsEnabled(AutoDodger2.option) then return end
for i, v in ipairs(AutoDodger2.particleLogic) do
v:OnParticleCreate(particle, AutoDodger2.activeProjectiles)
end
end
function AutoDodger2.OnParticleUpdate(particle)
if not Menu.IsEnabled(AutoDodger2.option) then return end
for i, v in ipairs(AutoDodger2.particleLogic) do
v:OnParticleUpdate(particle, AutoDodger2.activeProjectiles, AutoDodger2.knownRanges)
end
end
function AutoDodger2.OnParticleUpdateEntity(particle)
if not Menu.IsEnabled(AutoDodger2.option) then return end
for i, v in ipairs(AutoDodger2.particleLogic) do
v:OnParticleUpdateEntity(particle, AutoDodger2.activeProjectiles)
end
end
function AutoDodger2.OnParticleDestroy(particle)
if not Menu.IsEnabled(AutoDodger2.option) then return end
for i, v in ipairs(AutoDodger2.particleLogic) do
v:OnParticleDestroy(particle, AutoDodger2.activeProjectiles)
end
end
------------------------------------------------------------------------------------------------------
function AutoDodger2.ProcessProjectile()
local min = 999999999
local candidateKey = nil
for k,v in pairs(AutoDodger2.projectileQueue) do
local myPos = Entity.GetAbsOrigin(v.target)
local enemyPos = v.origin
local distance = myPos - enemyPos
local distanceLenth = distance:Length2D() - NPC.GetHullRadius(v.target) - Menu.GetValue(AutoDodger2.impactDistanceOption)
local delay = (distanceLenth/v.moveSpeed)
delay = math.max(delay, 0.00)
AutoDodger2.projectileQueue[k].dodgeTime = delay + v.time
if v.dodgeTime< min then
min = v.dodgeTime
candidateKey=k
end
end
if min~= 999999999 then
AutoDodger2.nextDodgeTimeProjectile = min
end
local curtime = GameRules.GetGameTime()
if curtime< AutoDodger2.nextDodgeTimeProjectile then return end
if AutoDodger2.projectileQueueLength == 0 then return end
local myHero = Heroes.GetLocal()
if not Entity.IsAlive(myHero) then return end
if candidateKey then
AutoDodger2.DodgeLogicProjectile(candidateKey, "projectile")
AutoDodger2.projectileQueue[candidateKey] = nil
AutoDodger2.projectileQueueLength = AutoDodger2.projectileQueueLength - 1
end
AutoDodger2.nextDodgeTimeProjectile = min
end
function AutoDodger2.ProcessLinearProjectile()
if not Menu.IsEnabled(AutoDodger2.linearOption) then return end
local curtime = GameRules.GetGameTime()
if curtime < AutoDodger2.nextDodgeTime then return end
local myHero = Heroes.GetLocal()
if not Entity.IsAlive(myHero) then return end
local myPos = Entity.GetAbsOrigin(myHero)
local movePositions = {}
-- simulate projectiles.
for k, v in pairs(AutoDodger2.activeProjectiles) do
local t = curtime - v.time
local projectileDir = v.velocity:Normalized()
local curPos = v.origin + v.velocity:Scaled(t)
local dir = (curPos - myPos)
local impactPos = curPos + projectileDir:Scaled(dir:Length2D())
local endPos = v.origin + projectileDir:Scaled(AutoDodger2.GetRange(v.index))
-- do not dodge if ahead of the impact point, and do not dodge if ahead of the max range of the projectile.
if (impactPos - curPos):Dot(projectileDir) > 0 and (endPos - impactPos):Dot(projectileDir) > 0 and NPC.IsPositionInRange(myHero, impactPos, AutoDodger2.impactRadius) then
if Menu.GetValue(AutoDodger2.skillItemOption) then
local dodged = AutoDodger2.DodgeLogicItem(key, mode, false)
AutoDodger2.DodgeLogicSkill(key, mode, dodged)
else
local dodged = AutoDodger2.DodgeLogicSkill(key, mode,false)
AutoDodger2.DodgeLogicItem(key, mode, dodged)
end
end
end
-- if #movePositions == 0 then
-- AutoDodger2.active = false
-- return
-- end
-- AutoDodger2.movePos = Vector()
-- for k, v in pairs(movePositions) do
-- AutoDodger2.movePos = AutoDodger2.movePos + v
-- end
-- AutoDodger2.movePos = Vector(AutoDodger2.movePos:GetX() / #movePositions, AutoDodger2.movePos:GetY() / #movePositions, myPos:GetZ())
-- if NPC.IsChannellingAbility(myHero) then return end
-- Player.PrepareUnitOrders(Players.GetLocal(), Enum.UnitOrder.DOTA_UNIT_ORDER_MOVE_TO_POSITION, nil, AutoDodger2.movePos, nil, Enum.PlayerOrderIssuer.DOTA_ORDER_ISSUER_PASSED_UNIT_ONLY, myHero, false, true)
AutoDodger2.nextDodgeTime = GameRules.GetGameTime() + NetChannel.GetAvgLatency(Enum.Flow.FLOW_OUTGOING) + 0.03
AutoDodger2.active = true
end
function AutoDodger2.ProcessChoosingSkills()
end
function AutoDodger2.ProcessAnimation()
if not Menu.IsEnabled(AutoDodger2.option) then return end
if not Menu.IsEnabled(AutoDodger2.animationOption) then return end
local myHero = Heroes.GetLocal()
if not myHero then return end
AutoDodger2.OnOtherAnimationCreation()
--Log.Write(AutoDodger2.AnimationQueueLength)
local min = 999999999
local candidateKey = nil
--Log.Write(AutoDodger2.AnimationQueueLength)
for k,v in pairs(AutoDodger2.AnimationQueue) do
local skillName = AutoDodger2.animationMap[v.sequenceName].ability
local skill = NPC.GetAbility(v.enemy, skillName)
if not Ability.IsInAbilityPhase(skill) then
AutoDodger2.AnimationQueue[k]=nil
AutoDodger2.AnimationQueueLength =AutoDodger2.AnimationQueueLength -1
else
if min>v.time then
min = v.time
candidateKey = k
end
end
end
if candidateKey then
AutoDodger2.nextDodgeTimeAnimation = min
end
local curtime = GameRules.GetGameTime()
if curtime < AutoDodger2.nextDodgeTimeAnimation-Menu.GetValue(AutoDodger2.castPointOption)/40 then return end
if AutoDodger2.AnimationQueueLength == 0 then return end
local myHero = Heroes.GetLocal()
if not Entity.IsAlive(myHero) then return end
if candidateKey and AutoDodger2.isTargetMe(myHero, AutoDodger2.AnimationQueue[candidateKey].enemy, AutoDodger2.AnimationQueue[candidateKey].sequenceName ) then
AutoDodger2.DodgeLogicProjectile(candidateKey,"animation")
AutoDodger2.AnimationQueue[candidateKey] = nil
AutoDodger2.AnimationQueueLength = AutoDodger2.AnimationQueueLength - 1
end
AutoDodger2.nextDodgeTimeAnimation= min
end
function AutoDodger2.OnOtherAnimationCreation()
local myHero = Heroes.GetLocal()
local myTeam = Entity.GetTeamNum(myHero)
for i = 1, Heroes.Count() do
local hero = Heroes.Get(i)
if not NPC.IsIllusion(hero) then
local sameTeam = Entity.GetTeamNum(hero) == myTeam
if not sameTeam then
local enemyName = NPC.GetUnitName(hero)
if AutoDodger2.otherAnimationMapHelper[enemyName] then
for j =1,#AutoDodger2.otherAnimationMapHelper[enemyName] do
local skillName = AutoDodger2.otherAnimationMapHelper[enemyName][j]
local skill = NPC.GetAbility(hero, skillName)
if Ability.IsInAbilityPhase(skill) and not AutoDodger2.AnimationQueue[skillName] and AutoDodger2.animationMap[skillName] and AutoDodger2.animationMap[skillName].selected then
--Log.Write(skillName)
AutoDodger2.AnimationQueue[skillName] ={
time = GameRules.GetGameTime()+Ability.GetCastPoint(skill),
sequenceName = skillName,
enemy = hero,
enemyName = enemyName,
castPoint = Ability.GetCastPoint(skill)
}
AutoDodger2.AnimationQueueLength = AutoDodger2.AnimationQueueLength + 1
end
end
end
end
end
end
end
-- AutoDodger2.AnimationQueue[sequenceName] ={
-- time = GameRules.GetGameTime()+animation.castpoint,
-- sequenceName = sequenceName,
-- enemy = enemy,
-- enemyName = enemyName,
-- castPoint = animation.castpoint
-- }
function AutoDodger2.isTargetMe(myHero,enemy, sequenceName)
local angle = Entity.GetRotation(enemy)
local angleOffset = Angle(0, 45, 0)
angle:SetYaw(angle:GetYaw() + angleOffset:GetYaw())
local x,y,z = angle:GetVectors()
local direction = x + y + z
local name = NPC.GetUnitName(enemy)
direction:SetZ(0)
local skillName = AutoDodger2.animationMap[sequenceName].ability
local skill = NPC.GetAbility(enemy, skillName)
local level = Ability.GetLevel(skill)
local castRange = AutoDodger2.animationMap[sequenceName].castRange[level]
local radius = AutoDodger2.animationMap[sequenceName].radius[level]
local origin = NPC.GetAbsOrigin(enemy)
local pointsNum = math.floor(castRange/25) + 1
for i = pointsNum,1,-1 do
direction:Normalize()
Log.Write(25*(i-1))
direction:Scale(25*(i-1))
Log.Write(direction:Length2D())
local pos = direction + origin
if NPC.IsPositionInRange(myHero, pos, radius + NPC.GetHullRadius(myHero), 0) then
Log.Write("yes")
return true
end
end
return false
end
-- AutoDodger2.AnimationQueue[skillName] ={
-- time = GameRules.GetGameTime(),
-- sequenceName = sequenceName,
-- enemy = enemy,
-- enemyName = enemyName,
-- castPoint = unit.castpoint
-- }
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function AutoDodger2.OnDraw()
if not Engine.IsInGame() or not Menu.IsEnabled(AutoDodger2.option) then
AutoDodger2.Reset()
return
end
local myHero = Heroes.GetLocal()
if not Menu.IsEnabled(AutoDodger2.skillPickerOption) then return end
local myHero = Heroes.GetLocal()
if not myHero then return end
if AutoDodger2.needsInit then
AutoDodger2.InitDisplay()
AutoDodger2.needsInit = false
end
local EnemyCount = 0
for i = 1, Heroes.Count() do
local hero = Heroes.Get(i)
if not Entity.IsSameTeam(myHero, hero) and not NPC.IsIllusion(hero) then
EnemyCount = EnemyCount + 1
AutoDodger2.DrawDisplay(hero, AutoDodger2.w, AutoDodger2.h - (EnemyCount-1)*(AutoDodger2.boxSize+2))
end
end
--Log.Write(Entity.GetRotation(myHero):__tostring())
end
---------------------------------------------------------------------------------------------------------------------------------------------------------
function AutoDodger2.OnMenuOptionChange(option, old, new)
if option == AutoDodger2.boxSizeOption then
AutoDodger2.InitDisplay()
elseif option == AutoDodger2.daggerOption or option == AutoDodger2.blademailOption or
option == AutoDodger2.ghostOption or option == AutoDodger2.mantaOption or option == AutoDodger2.eulOption or
option == AutoDodger2.lotusOption or option == AutoDodger2.sbOption or
option == AutoDodger2.bkbOption or option == AutoDodger2.capeOption then
AutoDodger2.setItemOrder()
end
end
function AutoDodger2.DrawDisplay(hero, x,y)
local abilities = {}
for i = 0, 24 do
local ability = NPC.GetAbilityByIndex(hero, i)
if ability ~= nil and Entity.IsAbility(ability) and not Ability.IsHidden(ability) and not Ability.IsAttributes(ability) then
if AutoDodger2.animationMapReverse[Ability.GetName(ability)] or AutoDodger2.animationMap[Ability.GetName(ability)] or AutoDodger2.projectileMapRev[Ability.GetName(ability)] then
table.insert(abilities, ability)
end
end
end
local startX = x - math.floor((#abilities / 2) * AutoDodger2.boxSize)
Renderer.DrawFilledRect(startX + 1, y - 1, (AutoDodger2.boxSize * #abilities) + 2, AutoDodger2.boxSize + 2)
-- draw the actual ability squares now
for i, ability in ipairs(abilities) do
AutoDodger2.DrawAbilitySquare(hero, ability, startX, y, i - 1)
end
-- black border
Renderer.SetDrawColor(0, 0, 0, 255)
Renderer.DrawOutlineRect(startX + 1, y - 1, (AutoDodger2.boxSize * #abilities) + 2, AutoDodger2.boxSize + 2)
end
function AutoDodger2.DrawAbilitySquare(hero, ability, x, y, index)
local abilityName = Ability.GetName(ability)
local imageHandle = AutoDodger2.cachedIcons[abilityName]
if imageHandle == nil then
imageHandle = Renderer.LoadImage(AutoDodger2.spellIconPath .. abilityName .. ".png")
AutoDodger2.cachedIcons[abilityName] = imageHandle
end
local realX = x + (index * AutoDodger2.boxSize) + 2
-- default colors = can cast
local imageColor = { 255, 255, 255 }
local outlineColor = { 0, 255 , 0 }
local hoveringOver = Input.IsCursorInRect(realX, y, AutoDodger2.boxSize, AutoDodger2.boxSize)
if not hoveringOver then
--if Ability.GetLevel(ability) == 0 then
imageColor = { 125, 125, 125 }
outlineColor = { 255, 0, 0 }
-- elseif Ability.GetManaCost(ability) > NPC.GetMana(hero) then
--imageColor = { 150, 150, 255 }
-- outlineColor = { 0, 0, 255 }
--else