-
Notifications
You must be signed in to change notification settings - Fork 3
/
asdfaphelios.lua
624 lines (594 loc) · 20.6 KB
/
asdfaphelios.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
local Aphelios = {}
local version = 2.3
GetInternalWebResultAsync(
"asdfaphelios.version",
function(v)
if tonumber(v) > version then
DownloadInternalFileAsync(
"asdfaphelios.lua",
SCRIPT_PATH,
function(success)
if success then
PrintChat("Updated. Press F5")
end
end
)
end
end
)
require "FF15Menu"
require "utils"
local Vector
local Circle = require("BestAOEPos").Circle
local DreamTS = require("DreamTS")
local dmgLib = require("FF15DamageLib")
local Orbwalker = require "FF15OL"
function OnLoad()
if not _G.Prediction then
LoadPaidScript(PaidScript.DREAM_PRED)
Vector = _G.Prediction.Vector
end
function Vector:angleBetweenFull(v1, v2)
local p1, p2 = (-self + v1), (-self + v2)
local theta = p1:polar() - p2:polar()
if theta < 0 then
theta = theta + 360
end
return theta
end
end
function Aphelios:__init()
self.orbSetup = false
self.calibrumQ = {
type = "linear",
speed = 1800,
range = 1350, --1450
delay = 0.35,
width = 120,
collision = {
["Wall"] = true,
["Hero"] = true,
["Minion"] = true
}
}
self.infernumQ = {
type = "linear",
delay = 0.4,
range = 600,
speed = math.huge,
width = 0,
angle = 45
}
self.crescendumQ = {
aaRange = 530,
delay = 0.25,
range = 475
}
self.r = {
type = "linear",
speed = 2050,
range = 1300,
delay = 0.5,
width = 250,
collision = {
["Wall"] = true,
["Hero"] = true,
["Minion"] = false
},
explosionRadius = 350
}
self.guns = {
main = nil,
off = nil
}
self.cd = {}
self:Menu()
self.TS =
DreamTS(
self.menu.dreamTs,
{
Damage = DreamTS.Damages.AD
}
)
AddEvent(
Events.OnTick,
function()
self:OnTick()
end
)
AddEvent(
Events.OnDraw,
function()
self:OnDraw()
end
)
AddEvent(
Events.OnBuffGain,
function(...)
self:OnBuffGain(...)
end
)
AddEvent(
Events.OnBuffLost,
function(...)
self:OnBuffLost(...)
end
)
AddEvent(
Events.OnProcessSpell,
function(...)
self:OnProcessSpell(...)
end
)
PrintChat("Aphelios loaded")
self.font = DrawHandler:CreateFont("Calibri", 10)
end
function Aphelios:Menu()
self.menu = Menu("asdfaphelios", "Aphelios")
self.menu:sub("dreamTs", "Target Selector")
self.menu:key("r", "Manual R Key", 0x5A)
end
function Aphelios:OnDraw()
if self.guns.main == "Calibrum" then
DrawHandler:Circle3D(myHero.position, self.calibrumQ.range, Color.White)
end
DrawHandler:Circle3D(myHero.position, self.r.range, Color.White)
end
function Aphelios:ShouldCast()
for spell, time in pairs(self.LastCasts) do
if time and RiotClock.time < time + 0.25 + NetClient.ping / 2000 + 0.06 then
return false
end
end
return true
end
function Aphelios:GetCalibrumQPred()
return self:GetTarget(
self.calibrumQ,
false,
function(unit)
return not unit.buffManager:HasBuff("aphelioscalibrumbonusrangedebuff")
end
)
end
function Aphelios:CalibrumQ(qTarget, qPred)
if qTarget and qPred and qPred.rates["veryslow"] then
qPred:draw()
myHero.spellbook:CastSpell(0, qPred.castPosition)
return true
end
end
function Aphelios:SevernumQ()
local aa = myHero.characterIntermediate.attackRange
local target =
self:GetTargetAuto(
function(unit)
local dist = aa + unit.boundingRadius
return GetDistanceSqr(unit, myHero) <= dist * dist
end,
false
)
if target then
myHero.spellbook:CastSpell(0, pwHud.hudManager.activeVirtualCursorPos)
end
end
function Aphelios:CalcBestCastAngle(angles)
local maxCount = 0
local maxStart = nil
local maxEnd = nil
for i = 1, #angles do
local base = angles[i]
local endAngle = base + self.infernumQ.angle
local over360 = endAngle > 360
if over360 then
endAngle = endAngle - 360
end
local function isContained(count, angle, base, over360, endAngle)
if angle == base and count ~= 0 then
return
end
if not over360 then
if angle <= endAngle and angle >= base then
return true
end
else
if angle > base and angle <= 360 then
return true
elseif angle <= endAngle and angle < base then
return true
end
end
end
local angle = base
local j = i
local count = 0
local endDelta = angle
while (isContained(count, angle, base, over360, endAngle)) do
endDelta = angles[j]
count = count + 1
j = j + 1
if j > #angles then
j = 1
end
angle = angles[j]
end
if count > maxCount then
maxCount = count
maxStart = base
maxEnd = endDelta
end
end
if maxStart and maxEnd then
if maxStart + self.infernumQ.angle > 360 then
maxEnd = maxEnd + 360
end
local res = (maxStart + maxEnd) / 2
if res > 360 then
res = res - 360
end
return math.rad(res)
end
end
function Aphelios:InfernumQ()
local qTargets, qPreds = self:GetTarget(self.infernumQ, true)
local angles = {}
local basePosition = nil
for _, pred in pairs(qPreds) do
if not basePosition then
angles[1] = 0
basePosition = pred.castPosition
else
angles[#angles + 1] =
Vector(myHero.position):angleBetweenFull(Vector(basePosition), Vector(pred.castPosition))
end
end
local best = self:CalcBestCastAngle(angles)
if best then
local castPosition =
(Vector(myHero.position) +
(Vector(basePosition) - Vector(myHero.position)):rotated(0, best, 0):normalized() *
(self.infernumQ.range - 10)):toDX3()
myHero.spellbook:CastSpell(0, castPosition)
end
end
function Aphelios:ShouldCrescendumQ()
local targets =
self:GetTargetAuto(
function(unit)
return GetDistanceSqr(unit, myHero) <= 1000 * 1000
end,
true
)
if targets then
local points = {}
for _, target in pairs(targets) do
points[#points + 1] =
_G.Prediction.GetUnitPosition(target, 0.06 + NetClient.ping / 1000 + self.crescendumQ.delay)
end
local res = Circle(self.crescendumQ.aaRange + self.crescendumQ.range, self.crescendumQ.range, points)
if res and (res.hits > 1 or res.hits == 1) and GetDistanceSqr(res.castPos) <= 450 * 450 then
return true, res.castPos
end
end
end
function Aphelios:ShouldGravitumQ()
local targets =
self:GetTargetAuto(
function(unit)
return true
end,
true
)
if targets and #targets > 0 then
local hasTarget = false
local shouldCast = true
local dist = myHero.characterIntermediate.attackRange + myHero.boundingRadius
for _, target in pairs(targets) do
if target.buffManager:HasBuff("ApheliosGravitumDebuff") then
hasTarget = true
else
if GetDistanceSqr(target, myHero) <= dist * dist then
shouldCast = false
end
end
end
return hasTarget, shouldCast
end
end
function Aphelios:GravitumQ()
local hasTarget, shouldCast = self:ShouldGravitumQ()
if shouldCast and hasTarget then
myHero.spellbook:CastSpell(0, pwHud.hudManager.activeVirtualCursorPos)
end
end
function Aphelios:CalibrumSwitch()
local target = Orbwalker:GetTarget(myHero.characterIntermediate.attackRange + myHero.boundingRadius + 100)
if target then
local dist = myHero.characterIntermediate.attackRange + myHero.boundingRadius
local targetPred = _G.Prediction.GetUnitPosition(target, 0.5)
local myHeroPred = _G.Prediction.GetUnitPosition(myHero, 0.5)
if GetDistanceSqr(targetPred, myHeroPred) >= dist * dist then
myHero.spellbook:CastSpell(1, pwHud.hudManager.activeVirtualCursorPos)
return true
end
end
local qPred, qTarget = self:GetCalibrumQPred()
if not self.cd[self.guns.off] and qPred and qTarget then
myHero.spellbook:CastSpell(1, pwHud.hudManager.activeVirtualCursorPos)
return true
end
end
function Aphelios:CastR()
if myHero.spellbook:CanUseSpell(0) == 0 then
local rTargets, rPreds =
self:GetTarget(
self.r,
true,
nil,
function(unit, pred)
return pred.rates["slow"]
end
)
local maxTarget = nil
local maxHit = 0
for _, target in pairs(rTargets) do
local pred = rPreds[target.networkId]
if pred then
pred:draw()
local hit = 0
for _, target2 in pairs(rTargets) do
if
target == target2 or
GetDistanceSqr(
_G.Prediction.GetUnitPosition(
target2,
NetClient.ping / 1000 + 0.06 + pred.interceptionTime
),
pred.castPosition
) <=
self.r.explosionRadius * self.r.explosionRadius
then
hit = hit + 1
end
end
if hit > maxHit then
maxTarget = target
maxHit = hit
end
end
end
if maxTarget then
myHero.spellbook:CastSpell(3, rPreds[maxTarget.networkId].castPosition)
end
end
end
function Aphelios:NearEnemiesCount()
local targets =
self:GetTargetAuto(
function(unit)
return GetDistanceSqr(unit, myHero) <= 1000 * 1000
end,
true
)
return #targets
end
function Aphelios:GetGuns()
local qName = myHero.spellbook:Spell(0).name
if qName == "ApheliosCalibrumQ" then
self.guns.main = "Calibrum"
elseif qName == "ApheliosSeverumQ" then
self.guns.main = "Severnum"
elseif qName == "ApheliosGravitumQ" then
self.guns.main = "Gravitum"
elseif qName == "ApheliosInfernumQ" then
self.guns.main = "Infernum"
elseif qName == "ApheliosCrescendumQ" then
self.guns.main = "Crescendum"
end
local buffs = myHero.buffManager.buffs
for i in pairs(buffs) do
local buff = buffs[i]
if buff then
if buff.name == "ApheliosOffHandBuffCalibrum" then
self.guns.off = "Calibrum"
elseif buff.name == "ApheliosOffHandBuffSeverum" then
self.guns.off = "Severnum"
elseif buff.name == "ApheliosOffHandBuffGravitum" then
self.guns.off = "Gravitum"
elseif buff.name == "ApheliosOffHandBuffInfernum" then
self.guns.off = "Infernum"
elseif buff.name == "ApheliosOffHandBuffCrescendum" then
self.guns.off = "Crescendum"
end
end
end
end
function Aphelios:ParseCd()
for gun, cd in pairs(self.cd) do
if RiotClock.time > cd then
self.cd[gun] = nil
end
end
end
function Aphelios:OnTick()
if not self.orbSetup and (_G.AuroraOrb or _G.LegitOrbwalker) then
Orbwalker:Setup()
self.orbSetup = true
end
if self.orbSetup and not Orbwalker:IsAttacking() then
self:GetGuns()
self:ParseCd()
if self.menu.r:get() then
self:CastR()
end
if Orbwalker:GetMode() == "Combo" then
if self.guns.main == "Calibrum" then
local qPred, qTarget = self:GetCalibrumQPred()
if qPred and qTarget and myHero.spellbook:CanUseSpell(0) == 0 then
self:CalibrumQ(qPred, qTarget)
elseif myHero.spellbook:CanUseSpell(1) == 0 then
local target = Orbwalker:GetTarget()
if target then
local dist = myHero.characterIntermediate.attackRange + myHero.boundingRadius - 100
local targetPred = _G.Prediction.GetUnitPosition(target, 0.5)
local myHeroPred = _G.Prediction.GetUnitPosition(myHero, 0.5)
if GetDistanceSqr(targetPred, myHeroPred) <= dist * dist then
myHero.spellbook:CastSpell(1, pwHud.hudManager.activeVirtualCursorPos)
end
end
end
elseif self.guns.main == "Severnum" then
if self.guns.off == "Calibrum" and myHero.spellbook:CanUseSpell(1) == 0 and self:CalibrumSwitch() then
return
elseif myHero.spellbook:CanUseSpell(0) == 0 then
self:SevernumQ()
else
local target = Orbwalker:GetTarget()
local useSpell = myHero.spellbook:CanUseSpell(1) == 0
if useSpell then
if
self.guns.off == "Gravitum" and
(not self.cd[self.guns.off] and (self:ShouldGravitumQ() or target) or
(target and not target.buffManager:HasBuff("ApheliosGravitumDebuff")))
then
myHero.spellbook:CastSpell(1, pwHud.hudManager.activeVirtualCursorPos)
elseif self.guns.off == "Infernum" and not self.cd[self.guns.off] and target then
myHero.spellbook:CastSpell(1, pwHud.hudManager.activeVirtualCursorPos)
elseif
self.guns.off == "Crescendum" and not self.cd[self.guns.off] and
(self:ShouldCrescendumQ() or (target and GetDistanceSqr(target) <= 300 * 300))
then
myHero.spellbook:CastSpell(1, pwHud.hudManager.activeVirtualCursorPos)
end
end
end
elseif self.guns.main == "Gravitum" then
if self.guns.off == "Calibrum" and myHero.spellbook:CanUseSpell(1) == 0 and self:CalibrumSwitch() then
return
elseif myHero.spellbook:CanUseSpell(0) == 0 then
self:GravitumQ()
else
local target = Orbwalker:GetTarget()
local useSpell = myHero.spellbook:CanUseSpell(1) == 0
if target and target.buffManager:HasBuff("ApheliosGravitumDebuff") and useSpell then
print(target.buffManager:HasBuff("ApheliosGravitumDebuff").remainingTime)
myHero.spellbook:CastSpell(1, pwHud.hudManager.activeVirtualCursorPos)
end
end
elseif self.guns.main == "Infernum" then
if self.guns.off == "Calibrum" and myHero.spellbook:CanUseSpell(1) == 0 and self:CalibrumSwitch() then
return
elseif myHero.spellbook:CanUseSpell(0) == 0 then
self:InfernumQ()
else
local target = Orbwalker:GetTarget()
local useSpell = myHero.spellbook:CanUseSpell(1) == 0
if useSpell then
if
self.guns.off == "Severnum" and target and
(self.cd[self.guns.off] or myHero.health / myHero.maxHealth < 0.30)
then
myHero.spellbook:CastSpell(1, pwHud.hudManager.activeVirtualCursorPos)
elseif
self.guns.off == "Gravitum" and
(not self.cd[self.guns.off] and (self:ShouldGravitumQ() or target) or
(target and not target.buffManager:HasBuff("ApheliosGravitumDebuff")))
then
myHero.spellbook:CastSpell(1, pwHud.hudManager.activeVirtualCursorPos)
elseif
self.guns.off == "Crescendum" and
((self:ShouldCrescendumQ() and not self.cd[self.guns.off]) or
self:NearEnemiesCount() <= 2 or
(target and GetDistanceSqr(target) <= 300 * 300))
then
myHero.spellbook:CastSpell(1, pwHud.hudManager.activeVirtualCursorPos)
end
end
end
elseif self.guns.main == "Crescendum" then
if self.guns.off == "Calibrum" and myHero.spellbook:CanUseSpell(1) == 0 and self:CalibrumSwitch() then
return
else
local _, castPos = self:ShouldCrescendumQ()
if myHero.spellbook:CanUseSpell(0) == 0 and castPos then
myHero.spellbook:CastSpell(0, castPos)
else
local target = Orbwalker:GetTarget()
local useSpell = myHero.spellbook:CanUseSpell(1) == 0
if useSpell then
if
self.guns.off == "Severnum" and
(not self.cd[self.guns.off] or myHero.health / myHero.maxHealth < 0.3) and
target
then
myHero.spellbook:CastSpell(1, pwHud.hudManager.activeVirtualCursorPos)
elseif
self.guns.off == "Gravitum" and
(not self.cd[self.guns.off] and (self:ShouldGravitumQ() or target) or
(target and not target.buffManager:HasBuff("ApheliosGravitumDebuff")))
then
myHero.spellbook:CastSpell(1, pwHud.hudManager.activeVirtualCursorPos)
elseif
self.guns.off == "Infernum" and target and
(not self.cd[self.guns.off] or self:NearEnemiesCount() > 2)
then
myHero.spellbook:CastSpell(1, pwHud.hudManager.activeVirtualCursorPos)
end
end
end
end
end
end
end
end
function Aphelios:OnBuffGain(obj, buff)
if obj == myHero then
if buff.name == "ApheliosSeverumQ" then
Orbwalker:BlockAttack(true)
end
end
end
function Aphelios:OnBuffLost(obj, buff)
if obj == myHero then
if buff.name == "ApheliosSeverumQ" then
Orbwalker:BlockAttack(false)
end
end
end
function Aphelios:OnProcessSpell(unit, spell)
if unit == myHero and spell.spellData.name == "ApheliosW" then
local cd = myHero.spellbook:Spell(0).cooldownTimeRemaining
if cd > 0 then
self.cd[self.guns.main] = RiotClock.time + cd
end
end
end
function Aphelios:GetTarget(spell, all, targetFilter, predFilter)
local units, preds = self.TS:GetTargets(spell, myHero.position, targetFilter, predFilter)
if all then
return units, preds
else
local target = self.TS.target
if target then
return target, preds[target.networkId]
end
end
end
function Aphelios:GetTargetAuto(targetFilter, all)
local res =
self.TS:update(
function(unit)
return _G.Prediction.IsValidTarget(unit) and targetFilter(unit)
end
)
if all then
return res
else
if res and res[1] then
return res[1]
end
end
end
if myHero.charName == "Aphelios" then
Aphelios:__init()
end