forked from saladinaazir/gosext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImpulsVlad.lua
2458 lines (2199 loc) · 85.2 KB
/
ImpulsVlad.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 LoadCallbacks = {}
local currentData = {
Champions = {
Vladimir = {
Version = 1.00,
Changelog = "Vladimir Initial Release",
},
},
Loader = {
Version = 1.00,
},
Dependencies = {
commonLib = {
Version = 1.00,
},
prediction = {
Version = 1.00,
},
changelog = {
Version = 1.00,
},
callbacks = {
Version = 1.00,
},
menuLoad = {
Version = 1.00,
},
},
Utilities = {
baseult = {
Version = 0,
},
evade = {
Version = 0,
},
tracker = {
Version = 0,
},
orbwalker = {
Version = 0,
},
},
Core = {
Version = 1.00,
Changelog =
"Credits to RMAN! \n" ..
"Enjoy your Game! "
,
},
}
if currentData.Champions[myHero.charName] == nil then
print("[Error]: " .. myHero.charName .. ' is not supported !')
return
end
require "MapPositionGOS"
require "DamageLib"
require "2DGeometry"
--
local huge = math.huge
local pi = math.pi
local floor = math.floor
local ceil = math.ceil
local sqrt = math.sqrt
local max = math.max
local min = math.min
--
local lenghtOf = math.lenghtOf
local abs = math.abs
local deg = math.deg
local cos = math.cos
local sin = math.sin
local acos = math.acos
local atan = math.atan
--
local contains = table.contains
local insert = table.insert
local remove = table.remove
local sort = table.sort
--
local TEAM_JUNGLE = 300
local TEAM_ALLY = myHero.team
local TEAM_ENEMY = TEAM_JUNGLE - TEAM_ALLY
--
local _STUN = 5
local _TAUNT = 8
local _SLOW = 11
local _SNARE = 12
local _FEAR = 22
local _CHARM = 23
local _SUPRESS = 25
local _KNOCKUP = 30
local _KNOCKBACK = 31
local _Asleep = 35
local Allies, Enemies, Turrets, FriendlyTurrets, Units = {}, {}, {}, {}, {}--for r aoe
--
local Vector = Vector
local KeyDown = Control.KeyDown
local KeyUp = Control.KeyUp
local IsKeyDown = Control.IsKeyDown
local SetCursorPos = Control.SetCursorPos
--
local GameCanUseSpell = Game.CanUseSpell
local Timer = Game.Timer
local Latency = Game.Latency
local HeroCount = Game.HeroCount
local Hero = Game.Hero
local MinionCount = Game.MinionCount
local Minion = Game.Minion
local TurretCount = Game.TurretCount
local Turret = Game.Turret
local WardCount = Game.WardCount
local Ward = Game.Ward
local ObjectCount = Game.ObjectCount
local Object = Game.Object
local MissileCount = Game.MissileCount
local Missile = Game.Missile
local ParticleCount = Game.ParticleCount
local Particle = Game.Particle
--
local DrawCircle = Draw.Circle
local DrawLine = Draw.Line
local DrawColor = Draw.Color
local DrawMap = Draw.CircleMinimap
local DrawText = Draw.Text
--
local barHeight = 8
local barWidth = 103
local barXOffset = 18
local barYOffset = 10
local DmgColor = DrawColor(255, 235, 103, 25)
local Color = {
Red = DrawColor(255, 255, 0, 0),
Green = DrawColor(255, 0, 255, 0),
Blue = DrawColor(255, 0, 0, 255),
White = DrawColor(255, 255, 255, 255),
Black = DrawColor(255, 0, 0, 0),
}
local Orbwalker
local ObjectManager
local TargetSelector
local HealthPrediction
local GetMode, GetMinions, GetAllyMinions, GetEnemyMinions, GetMonsters, GetHeroes, GetAllyHeroes, GetEnemyHeroes, GetTurrets, GetAllyTurrets, GetEnemyTurrets, GetWards, GetAllyWards, GetEnemyWards, OnPreMovement, OnPreAttack, OnAttack, OnPostAttack, OnPostAttackTick, OnUnkillableMinion, SetMovement, SetAttack, GetTarget, ResetAutoAttack, IsAutoAttacking, Orbwalk, SetHoldRadius, SetMovementDelay, ForceTarget, ForceMovement, GetHealthPrediction, GetPriority
table.insert(LoadCallbacks, function()
Orbwalker = _G.SDK.Orbwalker
ObjectManager = _G.SDK.ObjectManager
TargetSelector = _G.SDK.TargetSelector
HealthPrediction = _G.SDK.HealthPrediction
GetMode = function() --1:Combo|2:Harass|3:LaneClear|4:JungleClear|5:LastHit|6:Flee
local modes = Orbwalker.Modes
for i = 0, #modes do
if modes[i] then return i + 1 end
end
return nil
end
GetMinions = function(range)
return ObjectManager:GetMinions(range)
end
GetAllyMinions = function(range)
return ObjectManager:GetAllyMinions(range)
end
GetEnemyMinions = function(range)
return ObjectManager:GetEnemyMinions(range)
end
GetMonsters = function(range)
return ObjectManager:GetMonsters(range)
end
GetHeroes = function(range)
return ObjectManager:GetHeroes(range)
end
GetAllyHeroes = function(range)
return ObjectManager:GetAllyHeroes(range)
end
GetEnemyHeroes = function(range)
return ObjectManager:GetEnemyHeroes(range)
end
GetTurrets = function(range)
return ObjectManager:GetTurrets(range)
end
GetAllyTurrets = function(range)
return ObjectManager:GetAllyTurrets(range)
end
GetEnemyTurrets = function(range)
return ObjectManager:GetEnemyTurrets(range)
end
GetWards = function(range)
return ObjectManager:GetOtherMinions(range)
end
GetAllyWards = function(range)
return ObjectManager:GetOtherAllyMinions(range)
end
GetEnemyWards = function(range)
return ObjectManager:GetOtherEnemyMinions(range)
end
OnPreMovement = function(fn)
Orbwalker:OnPreMovement(fn)
end
OnPreAttack = function(fn)
Orbwalker:OnPreAttack(fn)
end
OnAttack = function(fn)
Orbwalker:OnAttack(fn)
end
OnPostAttack = function(fn)
Orbwalker:OnPostAttack(fn)
end
OnPostAttackTick = function(fn)
if Orbwalker.OnPostAttackTick then
Orbwalker:OnPostAttackTick(fn)
else
Orbwalker:OnPostAttack(fn)
end
end
OnUnkillableMinion = function(fn)
if Orbwalker.OnUnkillableMinion then
Orbwalker:OnUnkillableMinion(fn)
end
end
SetMovement = function(bool)
Orbwalker:SetMovement(bool)
end
SetAttack = function(bool)
Orbwalker:SetAttack(bool)
end
GetTarget = function(range, mode) --0:Physical|1:Magical|2:True
return TargetSelector:GetTarget(range or huge, mode or 0)
end
ResetAutoAttack = function()
end
IsAutoAttacking = function()
return Orbwalker:IsAutoAttacking()
end
Orbwalk = function()
Orbwalker:Orbwalk()
end
SetHoldRadius = function(value)
Orbwalker.Menu.General.HoldRadius:Value(value)
end
SetMovementDelay = function(value)
Orbwalker.Menu.General.MovementDelay:Value(value)
end
ForceTarget = function(unit)
Orbwalker.ForceTarget = unit
end
ForceMovement = function(pos)
Orbwalker.ForceMovement = pos
end
GetHealthPrediction = function(unit, delay)
return HealthPrediction:GetPrediction(unit, delay)
end
GetPriority = function(unit)
return TargetSelector:GetPriority(unit) or 1
end
end)
local function TextOnScreen(str)
local res = Game.Resolution()
Callback.Add("Draw", function()
DrawText(str, 64, res.x / 2 - (#str * 10), res.y / 2, Color.Red)
end)
end
local function Ready(spell)
return myHero:GetSpellData(spell).currentCd == 0
and myHero:GetSpellData(spell).level > 0
and myHero:GetSpellData(spell).mana <= myHero.mana
and Game.CanUseSpell(spell) == 0
end
local function RotateAroundPoint(v1, v2, angle)
local cos, sin = cos(angle), sin(angle)
local x = ((v1.x - v2.x) * cos) - ((v1.z - v2.z) * sin) + v2.x
local z = ((v1.z - v2.z) * cos) + ((v1.x - v2.x) * sin) + v2.z
return Vector(x, v1.y, z or 0)
end
local function GetDistanceSqr(p1, p2)
local success, message = pcall(function() if p1 == nil then print(p1.x) end end)
if not success then print(message) end
p2 = p2 or myHero
p1 = p1.pos or p1
p2 = p2.pos or p2
local dx, dz = p1.x - p2.x, p1.z - p2.z
return dx * dx + dz * dz
end
local function GetDistance(p1, p2)
return sqrt(GetDistanceSqr(p1, p2))
end
local ItemHotKey = {[ITEM_1] = HK_ITEM_1, [ITEM_2] = HK_ITEM_2, [ITEM_3] = HK_ITEM_3, [ITEM_4] = HK_ITEM_4, [ITEM_5] = HK_ITEM_5, [ITEM_6] = HK_ITEM_6, [ITEM_7] = HK_ITEM_7}
local function GetItemSlot(id) --returns Slot, HotKey
for i = ITEM_1, ITEM_7 do
if myHero:GetItemData(i).itemID == id then
return i, ItemHotKey[i]
end
end
return 0
end
local ItemID = DamageLib.ItemID
local wardItemIDs = {ItemID.StealthWard, ItemID.ControlWard, ItemID.FarsightAlteration, ItemID.ScarecrowEffigy, ItemID.StirringWardstone,
ItemID.VigilantWardstone, ItemID.WatchfulWardstone,
ItemID.BlackMistScythe, ItemID.HarrowingCrescent, ItemID.SpectralSickle,
ItemID.PauldronsofWhiterock, ItemID.RunesteelSpaulders, ItemID.SteelShoulderguards,
ItemID.BulwarkoftheMountain, ItemID.TargonsBuckler, ItemID.RelicShield,
ItemID.ShardofTrueIce, ItemID.Frostfang, ItemID.SpellthiefsEdge, }
local function GetWardSlot() --returns Slot, HotKey
for i = 1, #wardItemIDs do
local ward, key = GetItemSlot(wardItemIDs[i])
if ward ~= 0 then
return ward, key
end
end
end
local rotateAngle = 0
local function DrawMark(pos, thickness, size, color)
rotateAngle = (rotateAngle + 2) % 720
local hPos, thickness, color, size = pos or myHero.pos, thickness or 3, color or Color.Red, size * 2 or 150
local offset, rotateAngle, mod = hPos + Vector(0, 0, size), rotateAngle / 360 * pi, 240 / 360 * pi
local points = {
hPos:To2D(),
RotateAroundPoint(offset, hPos, rotateAngle):To2D(),
RotateAroundPoint(offset, hPos, rotateAngle + mod):To2D(),
RotateAroundPoint(offset, hPos, rotateAngle + 2 * mod):To2D(),
}
--
for i = 1, #points do
for j = 1, #points do
local lambda = i ~= j and DrawLine(points[i].x - 3, points[i].y - 5, points[j].x - 3, points[j].y - 5, thickness, color) -- -3 and -5 are offsets (because ext)
end
end
end
local function DrawRectOutline(vec1, vec2, width, color)
local vec3, vec4 = vec2 - vec1, vec1 - vec2
local A = (vec1 + (vec3:Perpendicular2():Normalized() * width)):To2D()
local B = (vec1 + (vec3:Perpendicular():Normalized() * width)):To2D()
local C = (vec2 + (vec4:Perpendicular2():Normalized() * width)):To2D()
local D = (vec2 + (vec4:Perpendicular():Normalized() * width)):To2D()
DrawLine(A, B, 3, color)
DrawLine(B, C, 3, color)
DrawLine(C, D, 3, color)
DrawLine(D, A, 3, color)
end
local function VectorPointProjectionOnLineSegment(v1, v2, v)
local cx, cy, ax, ay, bx, by = v.x, v.z, v1.x, v1.z, v2.x, v2.z
local rL = ((cx - ax) * (bx - ax) + (cy - ay) * (by - ay)) / ((bx - ax) * (bx - ax) + (by - ay) * (by - ay))
local pointLine = {x = ax + rL * (bx - ax), z = ay + rL * (by - ay)}
local rS = rL < 0 and 0 or (rL > 1 and 1 or rL)
local isOnSegment = rS == rL
local pointSegment = isOnSegment and pointLine or {x = ax + rS * (bx - ax), z = ay + rS * (by - ay)}
return pointSegment, pointLine, isOnSegment
end
local function mCollision(pos1, pos2, spell, list) --returns a table with minions (use #table to get count)
local result, speed, width, delay, list = {}, spell.Speed, spell.Width + 65, spell.Delay, list
--
if not list then
list = GetEnemyMinions(max(GetDistance(pos1), GetDistance(pos2)) + spell.Range + 100)
end
--
for i = 1, #list do
local m = list[i]
local pos3 = delay and m:GetPrediction(speed, delay) or m.pos
if m and m.team ~= TEAM_ALLY and m.dead == false and m.isTargetable and GetDistanceSqr(pos1, pos2) > GetDistanceSqr(pos1, pos3) then
local pointSegment, pointLine, isOnSegment = VectorPointProjectionOnLineSegment(pos1, pos2, pos3)
if isOnSegment and GetDistanceSqr(pointSegment, pos3) < width * width then
result[#result + 1] = m
end
end
end
return result
end
local function hCollision(pos1, pos2, spell, list) --returns a table with heroes (use #table to get count)
local result, speed, width, delay, list = {}, spell.Speed, spell.Width + 65, spell.Delay, list
if not list then
list = GetEnemyHeroes(max(GetDistance(pos1), GetDistance(pos2)) + spell.Range + 100)
end
for i = 1, #list do
local h = list[i]
local pos3 = delay and h:GetPrediction(speed, delay) or h.pos
if h and h.team ~= TEAM_ALLY and h.dead == false and h.isTargetable and GetDistanceSqr(pos1, pos2) > GetDistanceSqr(pos1, pos3) then
local pointSegment, pointLine, isOnSegment = VectorPointProjectionOnLineSegment(pos1, pos2, pos3)
if isOnSegment and GetDistanceSqr(pointSegment, pos3) < width * width then
insert(result, h)
end
end
end
return result
end
local function HealthPercent(unit)
return unit.maxHealth > 5 and unit.health / unit.maxHealth * 100 or 100
end
local function ManaPercent(unit)
return unit.maxMana > 0 and unit.mana / unit.maxMana * 100 or 100
end
local function HasBuffOfType(unit, bufftype, delay) --returns bool and endtime , why not starting at buffCOunt and check back to 1 ?
local delay = delay or 0
local bool = false
local endT = Timer()
for i = 1, unit.buffCount do
local buff = unit:GetBuff(i)
if buff.type == bufftype and buff.expireTime >= Timer() and buff.duration > 0 then
if buff.expireTime > endT then
bool = true
endT = buff.expireTime
end
end
end
return bool, endT
end
local function HasBuff(unit, buffname) --returns bool
return GotBuff(unit, buffname) == 1
end
local function GetBuffByName(unit, buffname) --returns buff
return GetBuffData(unit, buffname)
end
local function GetBuffByType(unit, bufftype) --returns buff
for i = 1, unit.buffCount do
local buff = unit:GetBuff(i)
if buff.type == bufftype and buff.expireTime >= Timer() and buff.duration > 0 then
return buff
end
end
return nil
end
local UndyingBuffs = {
["Aatrox"] = function(target, addHealthCheck)
return HasBuff(target, "aatroxpassivedeath")
end,
["Fiora"] = function(target, addHealthCheck)
return HasBuff(target, "FioraW")
end,
["Tryndamere"] = function(target, addHealthCheck)
return HasBuff(target, "UndyingRage") and (not addHealthCheck or target.health <= 30)
end,
["Vladimir"] = function(target, addHealthCheck)
return HasBuff(target, "VladimirSanguinePool")
end,
}
local function HasUndyingBuff(target, addHealthCheck)
--Self Casts Only
local buffCheck = UndyingBuffs[target.charName]
if buffCheck and buffCheck(target, addHealthCheck) then return true end
--Can Be Casted On Others
if HasBuff(target, "JudicatorIntervention") or ((not addHealthCheck or HealthPercent(target) <= 10) and (HasBuff(target, "kindredrnodeathbuff") or HasBuff(target, "ChronoShift") or HasBuff(target, "chronorevive"))) then
return true
end
return target.isImmortal
end
local function IsValidTarget(unit, range) -- the == false check is faster than using "not"
return unit and unit.valid and unit.visible and not unit.dead and unit.isTargetableToTeam and (not range or GetDistance(unit) <= range) and (not unit.type == myHero.type or not HasUndyingBuff(unit, true))
end
local function GetTrueAttackRange(unit, target)
local extra = target and target.boundingRadius or 0
return unit.range + unit.boundingRadius + extra
end
local function HeroesAround(range, pos, team)
pos = pos or myHero.pos
local dist = GetDistance(pos) + range + 100
local result = {}
local heroes = (team == TEAM_ENEMY and GetEnemyHeroes(dist)) or (team == TEAM_ALLY and GetAllyHeroes(dist) or GetHeroes(dist))
for i = 1, #heroes do
local h = heroes[i]
if GetDistance(pos, h.pos) <= range then
result[#result + 1] = h
end
end
return result
end
local function CountEnemiesAround(pos, range)
return #HeroesAround(range, pos, TEAM_ENEMY)
end
local function GetClosestEnemy(unit)
local unit = unit or myHero
local closest, list = nil, GetHeroes()
for i = 1, #list do
local enemy = list[i]
if IsValidTarget(enemy) and enemy.team ~= unit.team and (not closest or GetDistance(enemy, unit) < GetDistance(closest, unit)) then
closest = enemy
end
end
return closest
end
local function MinionsAround(range, pos, team)
pos = pos or myHero.pos
local dist = GetDistance(pos) + range + 100
local result = {}
local minions = (team == TEAM_ENEMY and GetEnemyMinions(dist)) or (team == TEAM_ALLY and GetAllyMinions(dist) or GetMinions(dist))
for i = 1, #minions do
local m = minions[i]
if m and not m.dead and GetDistance(pos, m.pos) <= range + m.boundingRadius then
result[#result + 1] = m
end
end
return result
end
local function IsUnderTurret(pos, team)
local turrets = GetTurrets(GetDistance(pos) + 1000)
for i = 1, #turrets do
local turret = turrets[i]
if GetDistance(turret, pos) <= 915 and turret.team == team then
return turret
end
end
end
local function GetDanger(pos)
local result = 0
--
local turret = IsUnderTurret(pos, TEAM_ENEMY)
if turret then
result = result + floor((915 - GetDistance(turret, pos)) / 17.3)
end
--
local nearby = HeroesAround(700, pos, TEAM_ENEMY)
for i = 1, #nearby do
local enemy = nearby[i]
local dist, mod = GetDistance(enemy, pos), enemy.range < 350 and 2 or 1
result = result + (dist <= GetTrueAttackRange(enemy) and 5 or 0) * mod
end
--
result = result + #HeroesAround(400, pos, TEAM_ENEMY) * 1
return result
end
local function IsImmobile(unit, delay)
if unit.ms == 0 then return true, unit.pos, unit.pos end
local delay = delay or 0
local debuff, timeCheck = {}, Timer() + delay
for i = 1, unit.buffCount do
local buff = unit:GetBuff(i)
if buff.expireTime >= timeCheck and buff.duration > 0 then
debuff[buff.type] = true
end
end
if debuff[_STUN] or debuff[_TAUNT] or debuff[_SNARE] or debuff[_Asleep] or
debuff[_CHARM] or debuff[_SUPRESS] or debuff[_KNOCKUP] or debuff[_KNOCKBACK] or debuff[_FEAR] then
return true
end
end
local function IsFacing(unit, p2)
p2 = p2 or myHero
p2 = p2.pos or p2
local V = unit.pos - p2
local D = unit.dir
local Angle = 180 - deg(acos(V * D / (V:Len() * D:Len())))
if abs(Angle) < 80 then
return true
end
end
local function CheckHandle(tbl, handle)
for i = 1, #tbl do
local v = tbl[i]
if handle == v.handle then return v end
end
end
local function GetTargetByHandle(handle)
return CheckHandle(GetEnemyHeroes(1200), handle) or
CheckHandle(GetMonsters(1200), handle) or
CheckHandle(GetEnemyTurrets(1200), handle) or
CheckHandle(GetEnemyMinions(1200), handle) or
CheckHandle(GetEnemyWards(1200), handle)
end
local function ShouldWait()
return myHero.dead or HasBuff(myHero, "recall") or Game.IsChatOpen() or (_G.ExtLibEvade and _G.ExtLibEvade.Evading == true) or (_G.JustEvade and _G.JustEvade:Evading())
end
local Emote = {
Joke = HK_ITEM_1,
Taunt = HK_ITEM_2,
Dance = HK_ITEM_3,
Mastery = HK_ITEM_5,
Laugh = HK_ITEM_7,
Casting = false
}
local function CastEmote(emote)
if not emote or Emote.Casting or myHero.attackData.state == STATE_WINDUP then return end
--
Emote.Casting = true
KeyDown(HK_LUS)
KeyDown(emote)
DelayAction(function()
KeyUp(emote)
KeyUp(HK_LUS)
Emote.Casting = false
end, 0.01)
end
-- Farm Stuff
local function ExcludeFurthest(average, lst, sTar)
local removeID = 1
for i = 2, #lst do
if GetDistanceSqr(average, lst[i].pos) > GetDistanceSqr(average, lst[removeID].pos) then
removeID = i
end
end
local Newlst = {}
for i = 1, #lst do
if (sTar and lst[i].networkID == sTar.networkID) or i ~= removeID then
Newlst[#Newlst + 1] = lst[i]
end
end
return Newlst
end
local function GetBestCircularCastPos(spell, sTar, lst)
local average = {x = 0, z = 0, count = 0}
local heroList = lst and lst[1] and (lst[1].type == myHero.type)
local range = spell.Range or 2000
local radius = spell.Radius or 50
if sTar and (not lst or #lst == 0) then
return Prediction:GetBestCastPosition(sTar, spell), 1
end
--
for i = 1, #lst do
if IsValidTarget(lst[i], range) then
local org = heroList and Prediction:GetBestCastPosition(lst[i], spell) or lst[i].pos
average.x = average.x + org.x
average.z = average.z + org.z
average.count = average.count + 1
end
end
--
if sTar and sTar.type ~= lst[1].type then
local org = heroList and Prediction:GetBestCastPosition(sTar, spell) or lst[i].pos
average.x = average.x + org.x
average.z = average.z + org.z
average.count = average.count + 1
end
--
average.x = average.x / average.count
average.z = average.z / average.count
--
local inRange = 0
for i = 1, #lst do
local bR = lst[i].boundingRadius
if GetDistanceSqr(average, lst[i].pos) - bR * bR < radius * radius then
inRange = inRange + 1
end
end
--
local point = Vector(average.x, myHero.pos.y, average.z)
--
if inRange == #lst then
return point, inRange
else
return GetBestCircularCastPos(spell, sTar, ExcludeFurthest(average, lst))
end
end
local function GetBestLinearCastPos(spell, sTar, list)
local startPos = spell.From.pos or myHero.pos
local isHero = list[1].type == myHero.type
--
local center = GetBestCircularCastPos(spell, sTar, list)
local endPos = startPos + (center - startPos):Normalized() * spell.Range
local MostHit = isHero and #hCollision(startPos, endPos, spell, list) or #mCollision(startPos, endPos, spell, list)
return endPos, MostHit
end
local function GetBestLinearFarmPos(spell)
local minions = GetEnemyMinions(spell.Range + spell.Radius)
if #minions == 0 then return nil, 0 end
return GetBestLinearCastPos(spell, nil, minions)
end
local function GetBestCircularFarmPos(spell)
local minions = GetEnemyMinions(spell.Range + spell.Radius)
if #minions == 0 then return nil, 0 end
return GetBestCircularCastPos(spell, nil, minions)
end
local function CircleCircleIntersection(c1, c2, r1, r2)
local D = GetDistance(c1, c2)
if D > r1 + r2 or D <= abs(r1 - r2) then return nil end
local A = (r1 * r2 - r2 * r1 + D * D) / (2 * D)
local H = sqrt(r1 * r1 - A * A)
local Direction = (c2 - c1):Normalized()
local PA = c1 + A * Direction
local S1 = PA + H * Direction:Perpendicular()
local S2 = PA - H * Direction:Perpendicular()
return S1, S2
end
-- Damage calcs
function PassivePercentMod(source, target, dmgMod)
local tarMinion = target.type == Obj_AI_Minion and target
local newMod = dmgMod
if source.type == Obj_AI_Turret then
if tarMinion and (tarMinion.charName:find("MinionSiege") or tarMinion.charName:find("MinionSuper")) then
newMod = newMod * 0.7
end
end
if tarMinion then
if tarMinion.charName:find("MinionMelee") and HasBuff(tarMinion, "exaltedwithbaronnashorminion") then
newMod = newMod * 0.25
end
end
if source.type == Obj_AI_Hero then
if tarMinion then
if HasBuff(source, "barontarget") and tarMinion.charName:find("SRU_Baron") then
newMod = newMod * 0.5
end
end
end
return newMod
end
local reductions = {
["Alistar"] = function(t) return HasBuff(t, "FerociousHowl") and (0.45 + 0.1 * t:GetSpellData(_R).level) end,
["Annie"] = function(t) return HasBuff(t, "AnnieE") and (0.10 + 0.06 * t:GetSpellData(_E).level) end,
["Galio"] = function(t) return HasBuff(t, "GalioW") and (0.15 + 0.05 * t:GetSpellData(_W).level + 0.08 * t.bonusMagicResist / 100) end,
["Garen"] = function(t) return HasBuff(t, "GarenW") and (0.30) end,
["Gragas"] = function(t) return HasBuff(t, "gragaswself") and (0.08 + 0.02 * t:GetSpellData(_W).level + 0.04 * t.ap / 100) end,
["Irelia"] = function(t) return HasBuff(t, "ireliawdefense") and (0.40 + 0.05 * t:GetSpellData(_W).level + 0.07 * t.ap / 100) end,
["Malzahar"] = function(t) return HasBuff(t, "malzaharpassiveshield") and (0.90) end,
["MasterYi"] = function(t) return HasBuff(t, "Meditate") and (0.45 + 0.05 * t:GetSpellData(_W).level) end,
["Warwick"] = function(t) return HasBuff(t, "WarwickE") and (0.30 + 0.05 * t:GetSpellData(_E).level) end,
}
function CalcMagicalDamage(source, target, amount, time)
local passiveMod = 0
local totalMR = target.magicResist + target.bonusMagicResist
if totalMR < 0 then
passiveMod = 2 - 100 / (100 - totalMR)
elseif totalMR * source.magicPenPercent - source.magicPen < 0 then
passiveMod = 1
else
passiveMod = 100 / (100 + totalMR * source.magicPenPercent - source.magicPen)
end
local dmg = max(floor(PassivePercentMod(source, target, passiveMod) * amount), 0)
if target.charName == "Kassadin" then
dmg = dmg * 0.85
elseif reductions[target.charName] then
local reduction = reductions[target.charName](target) or 0
dmg = dmg * (1 - reduction)
end
if HasBuff(target, "cursedtouch") then
dmg = dmg + amount * 0.1
end
if HasBuff(target, "abyssalscepteraura") then
dmg = dmg * 1.15
end
return dmg
end
function CalcPhysicalDamage(source, target, amount, time)
local penPercent = source.armorPenPercent
local penPercentBonus = source.bonusArmorPenPercent
local penFlat = source.armorPen * (0.6 + 0.4 * source.levelData.lvl / 18)
if source.type == Obj_AI_Minion then
penFlat = 0
penPercent = 1
penPercentBonus = 1
elseif source.type == Obj_AI_Turret then
penFlat = 0
penPercentBonus = 1
penPercent = 0.7
end
local armor = target.armor
local bonusArmor = target.bonusArmor
local value
if armor < 0 then
value = 2 - 100 / (100 - armor)
elseif armor * penPercent - bonusArmor * (1 - penPercentBonus) - penFlat < 0 then
value = 1
else
value = 100 / (100 + armor * penPercent - bonusArmor * (1 - penPercentBonus) - penFlat)
end
local dmg = max(floor(PassivePercentMod(source, target, value) * amount), 0)
if reductions[target.charName] then
local reduction = reductions[target.charName](target) or 0
dmg = dmg * (1 - reduction)
end
return dmg
end
function CalcMixedDamage(source, target, physicalAmount, magicalAmount)
return CalcPhysicalDamage(source, target, physicalAmount) + CalcMagicalDamage(source, target, magicalAmount)
end
class "Spell"
function Spell:__init(SpellData)
self.Slot = SpellData.Slot
self.Range = SpellData.Range or huge
self.Delay = SpellData.Delay or 0.25
self.Speed = SpellData.Speed or huge
self.Radius = SpellData.Radius or SpellData.Width or 0
self.Width = SpellData.Width or SpellData.Radius or 0
self.From = SpellData.From or myHero
self.Collision = SpellData.Collision or false
self.Type = SpellData.Type or "Press"
self.DmgType = SpellData.DmgType or "Physical"
--
return self
end
function Spell:IsReady()
return GameCanUseSpell(self.Slot) == READY
end
function Spell:CanCast(unit, range, from)
local from = from or self.From.pos
local range = range or self.Range
return unit and unit.valid and unit.visible and not unit.dead and (not range or GetDistance(from, unit) <= range)
end
function Spell:GetPrediction(target)
return Prediction:GetBestCastPosition(target, self)
end
function Spell:GetBestLinearCastPos(sTar, lst)
return GetBestLinearCastPos(self, sTar, lst)
end
function Spell:GetBestCircularCastPos(sTar, lst)
return GetBestCircularCastPos(self, sTar, lst)
end
function Spell:GetBestLinearFarmPos()
return GetBestLinearFarmPos(self)
end
function Spell:GetBestCircularFarmPos()
return GetBestCircularFarmPos(self)
end
function Spell:CalcDamage(target, stage)
local stage = stage or 1
local rawDmg = self:GetDamage(target, stage)
if rawDmg <= 0 then return 0 end
local damage = rawDmg
return damage
end
function Spell:GetDamage(target, stage)
local slot = self:SlotToString()
return self:IsReady() and getdmg(slot, target, self.From, stage or 1) or 0
end
function Spell:SlotToHK()
return ({[_Q] = HK_Q, [_W] = HK_W, [_E] = HK_E, [_R] = HK_R, [SUMMONER_1] = HK_SUMMONER_1, [SUMMONER_2] = HK_SUMMONER_2})[self.Slot]
end
function Spell:SlotToString()
return ({[_Q] = "Q", [_W] = "W", [_E] = "E", [_R] = "R"})[self.Slot]
end
function Spell:Cast(castOn)
if not self:IsReady() or ShouldWait() then return end
--
local slot = self:SlotToHK()
if self.Type == "Press" then
KeyDown(slot)
return KeyUp(slot)
end
--
if castOn == nil then return end
local pos = castOn.x and castOn
local targ = castOn.health and castOn
--
if self.Type == "AOE" and pos then
local bestPos, hit = self:GetBestCircularCastPos(targ, GetEnemyHeroes(self.Range + self.Radius))
pos = hit >= 2 and bestPos or pos
end
--
if (targ and not targ.pos:To2D().onScreen) then
return
elseif (pos and not pos:To2D().onScreen) then
if self.Type == "AOE" then
local mapPos = pos:ToMM()
Control.CastSpell(slot, mapPos.x, mapPos.y)
else
pos = myHero.pos:Extended(pos, 200)
if not pos:To2D().onScreen then return end
end
end
--
return Control.CastSpell(slot, targ or pos)
end
local Allies, Enemies, Turrets, FriendlyTurrets, Units = {}, {}, {}, {}, {}
local function IsValid(unit)
if (unit
and unit.valid
and unit.isTargetable
and unit.alive
and unit.visible
and unit.networkID
and unit.health > 0
and not unit.dead
) then
return true;
end
return false;
end
local function GetEnemiesAtPos(checkrange, range, pos,target)
local enemies = _G.SDK.ObjectManager:GetEnemyHeroes(checkrange)
local results = {}
for i = 1, #enemies do
local enemy = enemies[i]
local Range = range * range
if GetDistanceSqr(pos, enemy.pos) < Range and IsValid(enemy) and enemy ~= target then
table.insert(results, enemy)
end
if target then
table.insert(results, target)
end
end
return results
end
local function AverageClusterPosition(targets)
local finalPos = {x = 0, z = 0}