-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsenna.lua
More file actions
1750 lines (1485 loc) · 80.4 KB
/
senna.lua
File metadata and controls
1750 lines (1485 loc) · 80.4 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
--[[
DanZ-AIO Senna
Q Extended Range Refactor v3 + Soul Collection v1
REVISED & DEBUGGED
]]
if player.charName ~= "Senna" then return end
chat.print("DanZ-AIO Senna Loaded (Q Extended Range v3 + Soul Collection v1)")
-- Module Imports
local orb = module.internal("orb")
local ts = module.internal("TS")
local pred = module.internal("pred")
local damagelib = module.internal("damagelib")
-- local evade = module.internal("evade") -- Keep commented unless needed
-- Constants & Globals
local Q_BUFF_HEAL_HASH = game.fnvhash("SennaQHeal")
local W_MARK_HASH = game.fnvhash("SennaW")
local PASSIVE_STACK_HASH = game.fnvhash("sennapassivemarker")
local SOUL_CHAR_NAME = "SennaSoul"
local Q_MAX_EFFECTIVE_RANGE = 1300 -- Max reach of Q through targets
local Q_CAST_RANGE_BONUS = 25 -- Q cast range is slightly longer than AA
local State = {
q_farm_enabled = true,
last_w_gapclose_time = 0,
last_e_time = 0,
last_r_save_time = 0,
last_ward_attempt_time = 0, -- <<< ADD THIS LINE: Prevent spamming ward attempts
}
local circle_effects = {
aa = graphics.create_effect(graphics.CIRCLE_GLOW_RAINBOW),
q = graphics.create_effect(graphics.CIRCLE_GLOW_RAINBOW),
w = graphics.create_effect(graphics.CIRCLE_GLOW_RAINBOW),
r = graphics.create_effect(graphics.CIRCLE_GLOW_RAINBOW) -- R KS range will still use draw_circle
}
local WARD_RANGE = 600 -- Standard ward placement range
-- Ward Item IDs (Common ones)
local WARD_ITEM_IDS = {
[3340] = true, -- Stealth Ward (Trinket)
[3363] = true, -- Farsight Alteration (Trinket) - Note: Different placement logic might be needed
[2055] = true, -- Control Ward
-- Add other ward types if necessary (e.g., event wards)
}
-- Mapping Inventory Slots to Spell Slots for Actives
local INVENTORY_TO_SPELL_SLOT = {
[0] = 6, [1] = 7, [2] = 8, [3] = 9, [4] = 10, [5] = 11, -- Items 1-6
[6] = 6 -- Trinket (Commonly slot 6)
}
-- Helper: Is Valid Target Check
local function IsValidTarget(target, range)
if not target or not target.valid or target.isDead then
return false
end
-- Souls might not have isTargetable property or it might be false, but we can still attack/move to them
if target.charName ~= SOUL_CHAR_NAME and (not target.isVisible or not target.isTargetable) then
return false
end
if range then
local range_sqr = range * range
-- Use serverPos for more accurate range checks, fallback to pos if needed
local check_pos = target.path and target.path.serverPos or target.pos
if player.pos:distSqr(check_pos) > range_sqr then
return false
end
end
return true
end
-- Helper: Mana Check
local function HasEnoughMana(pct)
return player.mana / player.maxMana * 100 >= pct
end
-- Helper: Check if target is CC'd
local function IsCCd(target)
if not target or not target.valid then return false end
-- Simplified check using buff types
return target.buff[BUFF_STUN] or target.buff[BUFF_SNARE] or target.buff[BUFF_TAUNT] or
target.buff[BUFF_CHARM] or target.buff[BUFF_FEAR] or target.buff[BUFF_SUPPRESSION] or
target.buff[BUFF_KNOCKUP] or target.buff[BUFF_KNOCKBACK] or target.buff[BUFF_ASLEEP]
end
-- Helper: Get Senna's dynamic AA/Q range
local function GetDynamicAARange()
-- Use serverPos for player range calculation if available
return player.attackRange + player.boundingRadius
end
local function GetDynamicQCastRange()
-- Senna Q *cast* range scales with Attack Range
return GetDynamicAARange() + Q_CAST_RANGE_BONUS
end
-- Helper: Simple Position Prediction (adjust time as needed)
local function PredictTargetPos(target, delay_time)
if not target or not target.valid then return target and target.pos or nil end -- Return current pos if invalid/no path
if not delay_time or delay_time <= 0 then return target.path and target.path.serverPos or target.pos end
-- Use prediction module if available and target is moving
if pred and target.path and target.path.isMoving and target.path.count > 0 then
local predicted_pos_2d = pred.core.get_pos_after_time(target, delay_time)
if predicted_pos_2d then
return predicted_pos_2d:to3D(target.pos.y) -- Estimate Y
end
end
-- Fallback to server position or current position if prediction fails or target isn't moving
return target.path and target.path.serverPos or target.pos
end
-- Menu Creation (Structure remains the same)
local isCN = hanbot and hanbot.language == 1
local menu = menu("danz_senna", isCN and "DanZ-AIO ????" or "DanZ-AIO Senna")
-- Q Settings
menu:menu("q", "Q - " .. (isCN and "???????" or "Piercing Darkness"))
menu.q:dropdown("q_extend_prediction", isCN and "Q 扩展预测模式" or "Q Extend Prediction Mode", 1, { isCN and "快速预测" or "Fast Prediction", isCN and "高级预测 (仅移动)" or "Advanced Prediction (Moving Only)" })
menu.q.q_extend_prediction:set('tooltip', isCN and "快速: 使用最近的单位扩展Q。\n高级: 仅当目标最近改变路径时才尝试扩展Q。" or "Fast: Uses nearest unit to extend Q.\nAdvanced: Only attempts Q extend if target recently changed path.")
menu.q:boolean("auto_q_cc", isCN and "??? Q ???????" or "Auto Q on CC'd", true)
menu.q:boolean("auto_q_cc_ally", isCN and "自动 Q 控制中的队友" or "Auto Q on CC'd Ally", true) -- NEW
menu.q:boolean("combo", isCN and "????????? Q" or "Use Q in Combo", true)
menu.q:boolean("harass", isCN and "???????? Q" or "Use Q in Harass", true)
menu.q:slider("harass_mana", isCN and "??? Q ??????? %" or "Harass Q Min Mana %", 60, 0, 100, 5)
menu.q:keybind("farm_toggle", isCN and "?л? Q ??????" or "Toggle Q Farm Mode", nil, "MMB", true)
menu.q:slider("q_min_minions", isCN and "Q 至少命中多少小兵" or "Min Minions for Q", 2, 1, 10, 1) -- <-- ADD THIS LINE
menu.q:slider("farm_mana", isCN and "???? Q ??????? %" or "Farm Q Min Mana %", 50, 0, 100, 5)
menu.q:boolean("jungle", isCN and "???????? Q" or "Use Q in Jungle Clear", true)
menu.q:boolean("heal_ally", isCN and "??? Q ???????" or "Use Q to Heal Allies", true)
menu.q:slider("heal_ally_hp", isCN and "?????????? % ?????" or "Heal Ally Below HP %", 70, 0, 100, 5)
menu.q:dropdown("q_priority", isCN and "Q ??????" or "Q Priority Mode", 1, { isCN and "???????" or "Damage First", isCN and "????????" or "Heal First" }) -- 1: Damage, 2: Heal
menu.q:menu("heal_blacklist", isCN and "Q ?????????" or "Q Heal Blacklist")
menu.q.heal_blacklist:header("heal_blacklist_info_header", isCN and "???????????" or "Select Allies NOT to Heal")
-- Inside menu.q definition
menu.q:boolean("q_ward_ks", isCN and "??? Q+???? ??????" or "Use Q+Ward Extend KS", false)
menu.q.q_ward_ks:set('tooltip', isCN and "???????Q??Ч??Χ??????????????Χ????????????????Q????????????" or "Attempts to place a ward and Q through it if target is killable within effective Q range but outside direct cast range.")
-- W Settings
menu:menu("w", "W - " .. (isCN and "???????" or "Last Embrace"))
-- Inside menu.w definition
menu.w:boolean("killsteal", isCN and "??? W ?????" or "Use W to Killsteal", true) -- Default ON
menu.w:boolean("auto_w_cc", isCN and "??? W ???????" or "Auto W on CC'd", true)
menu.w:boolean("combo", isCN and "????????? W" or "Use W in Combo", true)
menu.w:boolean("harass", isCN and "???????? W" or "Use W in Harass", false)
menu.w:slider("harass_mana", isCN and "??? W ??????? %" or "Harass W Min Mana %", 70, 0, 100, 5)
menu.w:boolean("anti_gapclose", isCN and "??? W ??????" or "Use W vs Gap Closers", true)
menu.w:slider("anti_gapclose_hp", isCN and "??????????? % ???? W ??????" or "Use W vs Gap Closers Below Player HP %", 60, 0, 100, 5)
-- E Settings
menu:menu("e", "E - " .. (isCN and "?????丽" or "Curse of the Black Mist"))
menu.e:boolean("combo", isCN and "????????? E (????/???)" or "Use E in Combo (Escape/Chase)", false)
menu.e:boolean("flee", isCN and "???????? E" or "Use E When Fleeing", true)
menu.e:boolean("auto_escape", isCN and "??? E ?????????" or "Auto E on Low HP", true)
menu.e:slider("auto_escape_hp", isCN and "??????????? % ???? E" or "Auto E Below Player HP %", 30, 0, 100, 5)
-- R Settings
menu:menu("r", "R - " .. (isCN and "??????" or "Dawning Shadow"))
menu.r:boolean("killsteal", isCN and "??? R ?????" or "Use R to Killsteal", true)
menu.r:slider("min_range_ks", isCN and "???????С R ??Χ" or "Min R Range KS", 1000, 500, 5000, 100)
menu.r:slider("max_range_ks", isCN and "???????? R ??Χ" or "Max R Range KS", 15000, 1000, 25000, 500)
menu.r:boolean("aoe_combo", isCN and "?????ж??????? R" or "Use R for AoE in Combo", true)
menu.r:slider("aoe_min_enemies", isCN and "R ??????С???????? (????)" or "Min Enemies Hit for R (Combo)", 3, 1, 5, 1)
menu.r:boolean("save_ally", isCN and "??? R ????????????" or "Use R to Save Low HP Ally", false)
menu.r:slider("save_ally_hp", isCN and "?????????? % ?????" or "Save Ally Below HP %", 20, 0, 100, 5)
menu.r:slider("save_ally_range", isCN and "????????? R ??Χ" or "Max Range to Save Ally (R)", 1000, 500, 10000, 50) -- <<< ADD THIS LINE
menu.r:keybind("semi_manual", isCN and "????? R ??" or "Semi-Manual R Key", "T", nil)
-- Soul Collection Settings
menu:menu("souls", isCN and "??????" or "Soul Collection")
menu.souls:boolean("enabled", isCN and "??????????" or "Enable Soul Collection", true)
menu.souls:boolean("draw_souls", isCN and "??????????" or "Draw Nearby Souls", true)
menu.souls:color("soul_color", isCN and "?????????" or "Soul Highlight Color", 0, 255, 200, 200)
-- Drawing Settings
menu:menu("drawings", isCN and "????????" or "Draw Settings")
menu.drawings:boolean("enabled", isCN and "???????" or "Enable Drawings", true)
menu.drawings:menu("general_drawings", isCN and "通用绘制" or "General Drawings")
menu.drawings.general_drawings:boolean("minimap_r", isCN and "小地图绘制 R 范围" or "Draw R Range on Minimap", false) -- <<< ADD THIS LINE
menu.drawings:menu("ranges", isCN and "??Χ????" or "Range Drawings")
menu.drawings.ranges:boolean("aa", isCN and "?????????Χ (???)" or "Draw AA Range (Dynamic)", true)
menu.drawings.ranges:boolean("q", isCN and "???? Q ??Χ (???)" or "Draw Q Cast Range (Dynamic)", true) -- Clarified label
menu.drawings.ranges:boolean("w", isCN and "???? W ??Χ" or "Draw W Range", true)
menu.drawings.ranges:boolean("r_ks", isCN and "???? R ???????Χ" or "Draw R KS Range", false)
menu.drawings:menu("colors", isCN and "???????" or "Color Settings")
menu.drawings.colors:color("aa", "AA Range Color", 255, 255, 255, 150)
menu.drawings.colors:color("q", "Q Cast Range Color", 100, 255, 100, 150) -- Clarified label
menu.drawings.colors:color("w", "W Range Color", 100, 100, 255, 150)
--menu.drawings.colors:color("r", "R KS Range Color", 255, 100, 100, 150)
menu.drawings:boolean("damage_indicator", isCN and "???????????????" or "Draw Combo Damage Indicator", true)
menu.drawings:menu("damage_drawing", isCN and "???????" or "Damage Drawing")
menu.drawings.damage_drawing:boolean("use_q", isCN and "??? Q ???" or "Show Q Damage", true)
menu.drawings.damage_drawing:boolean("use_w", isCN and "??? W ??? (Detonation)" or "Show W Damage (Detonation)", true)
menu.drawings.damage_drawing:boolean("use_r", isCN and "??? R ???" or "Show R Damage", true)
menu.drawings.damage_drawing:slider("aa_factor", isCN and "????????п???????????" or "Number of AAs in Damage Calc", 1, 0, 5, 1)
menu.drawings.damage_drawing:boolean("include_passive", isCN and "?????????? (????)" or "Show Passive Damage (Estimate)", true)
menu.drawings:boolean("farm_draw_status", isCN and "???? Q ????????" or "Draw Q Farm Mode Status", true)
menu.drawings:menu("indicators", isCN and "指示器绘制" or "Indicator Drawings") -- Optional: New submenu
menu.drawings.indicators:boolean("q_extend_lines", isCN and "绘制 Q 扩展线" or "Draw Q Extend Lines", true)
menu.drawings.indicators:color("q_extend_color", isCN and "Q 扩展线颜色" or "Q Extend Line Color", 0, 200, 255, 180) -- Cyan-ish default
menu.drawings.indicators:color("q_ward_ks_color", isCN and "Q+守卫 KS 线颜色" or "Q+Ward KS Line Color", 255, 255, 0, 180) -- Yellow default
-- **** NEW: Utility Menu ****
menu:menu("utility", isCN and "??ù???" or "Utility")
menu.utility:keybind("place_ward_key", isCN and "??????????" or "Place Ward Key", "U", nil) -- Key '4' for ward placement
menu.utility.place_ward_key:set('tooltip', isCN and "???????????λ?÷?????????????????" or "Hold this key to place a ward at the mouse cursor (if available)")
-- Populate Ally Blacklist
if menu.q.heal_blacklist then
for i = 0, objManager.allies_n - 1 do
local ally = objManager.allies[i]
if ally and ally.valid and ally.ptr ~= player.ptr then
local menu_var = "noheal_" .. ally.charName:lower()
menu.q.heal_blacklist:boolean(menu_var, ally.charName, false)
local blacklist_item = menu.q.heal_blacklist[menu_var]
if blacklist_item and ally.iconSquare and ally.iconSquare.valid then
blacklist_item:set('icon', ally.iconSquare)
end
end
end
else
chat.print("Error: Heal blacklist menu not found!")
end
-- Load spell icons
local spellIcons = {}
local function LoadSpellIcons()
local qSlot = player:spellSlot(0)
if qSlot and qSlot.icon and qSlot.icon.valid then spellIcons.q = qSlot.icon end
local wSlot = player:spellSlot(1)
if wSlot and wSlot.icon and wSlot.icon.valid then spellIcons.w = wSlot.icon end
local eSlot = player:spellSlot(2)
if eSlot and eSlot.icon and eSlot.icon.valid then spellIcons.e = eSlot.icon end
local rSlot = player:spellSlot(3)
if rSlot and rSlot.icon and rSlot.icon.valid then spellIcons.r = rSlot.icon end
if spellIcons.q and menu.q then menu.q:set('icon', spellIcons.q) end
if spellIcons.w and menu.w then menu.w:set('icon', spellIcons.w) end
if spellIcons.e and menu.e then menu.e:set('icon', spellIcons.e) end
if spellIcons.r and menu.r then menu.r:set('icon', spellIcons.r) end
local passiveSlot = player:spellSlot(63)
if passiveSlot and passiveSlot.icon and passiveSlot.icon.valid and menu.souls then
menu.souls:set('icon', passiveSlot.icon)
end
if player.iconCircle and player.iconCircle.valid then menu:set('icon', player.iconCircle) end
end
LoadSpellIcons()
-- Spell Data Table
local spells = {
q = {
slot = 0,
cast_range = GetDynamicQCastRange, -- Function ref for CAST range
effective_range = Q_MAX_EFFECTIVE_RANGE, -- Max EFFECTIVE range
delay = 0.4, -- Approximate delay before damage/heal applies
width = 40, -- Effective width for collision checking the beam
ready = function() return player:spellSlot(0).state == 0 end,
mana = function() return 70 + (player:spellSlot(0).level * 10) end,
},
w = {
slot = 1,
range = 1250,
speed = 1200,
width = 70,
delay = 0.25,
boundingRadiusMod = 1,
ready = function() return player:spellSlot(1).state == 0 end,
mana = function() return 50 + (player:spellSlot(1).level * 5) end,
collision = { minion = true, hero = true, wall = true }
},
e = {
slot = 2,
range = 0,
ready = function() return player:spellSlot(2).state == 0 end,
mana = function() return 70 end
},
r = {
slot = 3,
range = 25000,
speed = 20000,
width = 160,
delay = 1.0,
boundingRadiusMod = 0,
ready = function() return player:spellSlot(3).state == 0 end,
mana = function() return 100 end,
collision = { minion = false, hero = false, wall = true } -- R goes through units but not walls
}
}
-- Prediction Filtering (Simplified for W/R)
local function PredFilter(seg, obj, input)
if not seg or not obj or not input then return false end
-- Check hard CC first
if pred.trace.linear.hardlock(input, seg, obj) or pred.trace.linear.hardlockmove(input, seg, obj) then
return true
end
-- Check for recent path changes (more likely to dodge)
if pred.trace.newpath(obj, 0.033, 0.500) then -- Check for path change in last 0.1s
return true
end
-- Could add more checks here (e.g., dashing away)
return false -- Assume hittable if no obvious dodge indicators
end
-- Get Prediction Logic (Standard for W/R)
local function GetPrediction(spell_key, target)
local spell = spells[spell_key]
if not spell or not target or not IsValidTarget(target) then return nil end
-- Q prediction is handled differently by GetBestQCastTarget
if spell_key == "q" then
-- print("Warning: GetPrediction called for Q, use GetBestQCastTarget instead.")
return PredictTargetPos(target, spells.q.delay) -- Return predicted pos as fallback
end
local current_range = spell.range
if type(current_range) == 'function' then current_range = current_range() end
local input = {
delay = spell.delay,
speed = spell.speed,
width = spell.width,
range = current_range,
boundingRadiusMod = spell.boundingRadiusMod,
collision = spell.collision
}
local seg = pred.linear.get_prediction(input, target)
if not seg then return nil end
-- Check range based on segment length (start to predicted end)
if seg.startPos:distSqr(seg.endPos) > current_range * current_range then return nil end
-- Check collision if applicable
if input.collision then
if pred.collision.get_prediction(input, seg, target) then return nil end
end
-- Check if target is likely to dodge
if not PredFilter(seg, target, input) then return nil end -- If filter returns false (likely hittable), proceed
return vec3(seg.endPos.x, target.pos.y, seg.endPos.y)
end
-- Replace the entire existing GetBestQCastTarget function with this one:
local function GetBestQCastTarget(intended_enemy, intended_ally)
local q_cast_range = GetDynamicQCastRange()
local q_effective_range = spells.q.effective_range
local q_width = spells.q.width
local q_delay = spells.q.delay
local player_pos_2d = player.pos2D
-- 1. Determine the primary target based on priority menu setting
local primary_intended_target = nil
local q_priority_mode = menu.q.q_priority:get()
if q_priority_mode == 2 and intended_ally then -- Heal Priority
primary_intended_target = intended_ally
elseif intended_enemy then -- Damage Priority (or Heal Prio but no ally)
primary_intended_target = intended_enemy
elseif q_priority_mode == 1 and intended_ally then -- Damage Prio fallback to Heal
primary_intended_target = intended_ally
end
-- If no valid primary intended target, we can't cast
if not primary_intended_target or not IsValidTarget(primary_intended_target, q_effective_range) then
return nil
end
-- 2. Predict the primary intended target's position
local predicted_target_pos = PredictTargetPos(primary_intended_target, q_delay)
if not predicted_target_pos then return nil end
local predicted_target_pos_2d = predicted_target_pos:to2D()
-- 3. **** NEW: Prediction Mode Check for Extended Q ****
local dist_to_primary_sqr = player_pos_2d:distSqr(predicted_target_pos_2d) -- Use predicted distance for check
local q_cast_range_sqr = q_cast_range * q_cast_range
-- Check if the primary target is outside direct cast range (requires extension)
if dist_to_primary_sqr > q_cast_range_sqr then
local q_extend_pred_mode = menu.q.q_extend_prediction:get()
-- If Advanced mode is selected, check the intended *enemy* target's movement
if q_extend_pred_mode == 2 then
-- Only apply the movement restriction if there *is* an intended enemy target
if intended_enemy and IsValidTarget(intended_enemy) then -- Ensure enemy target is valid
if not pred.trace.newpath(intended_enemy, 0.033, 0.500) then
-- Enemy exists but hasn't moved recently, block extended Q in Advanced mode
-- print("GetBestQCastTarget: Advanced Mode - Blocking extend, enemy didn't move.") -- Debug
return nil
-- else
-- print("GetBestQCastTarget: Advanced Mode - Allowing extend, enemy moved.") -- Debug
end
-- else
-- print("GetBestQCastTarget: Advanced Mode - Allowing extend, no specific enemy intended or enemy invalid.") -- Debug
end
-- If no intended enemy, or if the enemy moved, Advanced mode allows proceeding.
end
-- If Fast mode (1), we always proceed without the movement check.
-- print("GetBestQCastTarget: Fast Mode - Allowing extend check.") -- Debug
end
-- **** END OF NEW CHECK ****
-- 4. Gather all potential units we can *click* Q on (within Q CAST range)
-- (This part remains the same as before)
local potential_cast_units = {}
local function add_if_valid_cast_unit(unit)
if unit and IsValidTarget(unit, q_cast_range) then
table.insert(potential_cast_units, unit)
end
end
add_if_valid_cast_unit(player)
for i = 0, objManager.allies_n - 1 do add_if_valid_cast_unit(objManager.allies[i]) end
for i = 0, objManager.enemies_n - 1 do add_if_valid_cast_unit(objManager.enemies[i]) end
local lane_minions = objManager.minions["lane_enemy"]
if lane_minions then for i = 0, objManager.minions.size["lane_enemy"] - 1 do add_if_valid_cast_unit(lane_minions[i]) end end
local jungle_minions = objManager.minions[TEAM_NEUTRAL]
if jungle_minions then for i = 0, objManager.minions.size[TEAM_NEUTRAL] - 1 do add_if_valid_cast_unit(jungle_minions[i]) end end
local ally_minions = objManager.minions[TEAM_ALLY]
if ally_minions then for i = 0, objManager.minions.size[TEAM_ALLY] - 1 do add_if_valid_cast_unit(ally_minions[i]) end end
local ally_wards = objManager.wardsAlly
if ally_wards then for i = 0, ally_wards.size - 1 do add_if_valid_cast_unit(ally_wards[i]) end end
for i = 0, objManager.turrets.size[TEAM_ENEMY] - 1 do add_if_valid_cast_unit(objManager.turrets[TEAM_ENEMY][i]) end
for i = 0, objManager.inhibs.size[TEAM_ENEMY] - 1 do add_if_valid_cast_unit(objManager.inhibs[TEAM_ENEMY][i]) end
local nexus = objManager.nexus[TEAM_ENEMY]
add_if_valid_cast_unit(nexus)
-- 5. Iterate through potential cast units and check if the Q beam hits the intended target
-- (This part remains the same as before)
local best_cast_unit = nil
table.sort(potential_cast_units, function(a, b)
return player_pos_2d:distSqr(a.pos2D) < player_pos_2d:distSqr(b.pos2D)
end)
for _, cast_unit in ipairs(potential_cast_units) do
local direction = (cast_unit.pos2D - player_pos_2d):norm()
if direction:lenSqr() < 0.01 then direction = player.direction2D:norm() end
if direction:lenSqr() < 0.01 then direction = vec2(1,0) end
local q_end_point_2d = player_pos_2d + direction * q_effective_range
local target_radius = primary_intended_target.boundingRadius + 15
-- Use the PREDICTED target position for the collision check
if mathf.col_vec_rect(predicted_target_pos_2d, player_pos_2d, q_end_point_2d, target_radius, q_width) then
best_cast_unit = cast_unit
break
end
end
-- 6. Return the best unit found (or nil if none worked or was blocked by Advanced mode)
return best_cast_unit
end
-- Damage Calculation Helpers (Unchanged)
local function GetQDamage(target)
if not IsValidTarget(target) then return 0 end
return damagelib.get_spell_damage("SennaQ", 0, player, target, false, 0)
end
local function GetWDamage(target) -- Detonation damage
if not IsValidTarget(target) then return 0 end
return damagelib.get_spell_damage("SennaW", 1, player, target, false, 0)
end
local function GetRDamage(target)
if not IsValidTarget(target) then return 0 end
return damagelib.get_spell_damage("SennaR", 3, player, target, false, 0)
end
local function GetPassiveDamage(target)
if not IsValidTarget(target) then return 0 end
local passive_base = 20
local passive_ad_ratio = 0.2
local level_scaling = 1 + (player.levelRef / 18)
local raw_passive = (passive_base * level_scaling) + player.totalAd * passive_ad_ratio
return damagelib.calc_physical_damage(player, target, raw_passive)
end
local function GetQHealAmount(target)
if not IsValidTarget(target) or target.type ~= TYPE_HERO then return 0 end
local level = player:spellSlot(0).level
if level == 0 then return 0 end
local base_heal = 30 + level * 10
local ap_ratio = 0.40
local ad_ratio = 0.30
local heal_amount = base_heal + player.totalAp * ap_ratio + player.bonusAd * ad_ratio
-- Consider heal/shield power if needed
return heal_amount
end
-- Soul Collection Logic (Unchanged)
local function CollectSouls()
if not menu.souls.enabled:get() then return false end
local in_combo = orb.combat.is_active()
local in_flee = orb.menu.flee.key:get()
local in_valid_mode = orb.menu.hybrid.key:get() or orb.menu.lane_clear.key:get() or orb.menu.last_hit.key:get()
if in_combo or in_flee or not in_valid_mode then return false end
if not orb.core.can_action() then return false end
local collect_range = player.attackRange + player.boundingRadius
local collect_range_sqr = collect_range * collect_range
local aa_range = GetDynamicAARange()
local aa_range_sqr = aa_range * aa_range
local closest_soul = nil
local min_dist_sqr = collect_range_sqr + 1
local all_minions = objManager.allMinions
if not all_minions then return false end
for i = 0, all_minions.size - 1 do
local minion = all_minions[i]
if minion and minion.charName == SOUL_CHAR_NAME and IsValidTarget(minion) then -- Use IsValidTarget for souls too
local dist_sqr = player.pos:distSqr(minion.pos)
if dist_sqr <= collect_range_sqr and dist_sqr < min_dist_sqr then
min_dist_sqr = dist_sqr
closest_soul = minion
end
end
end
if closest_soul then
if min_dist_sqr <= aa_range_sqr then
if orb.core.can_attack() then
player:attack(closest_soul)
orb.core.set_server_pause()
return true
end
elseif orb.core.can_move() then
player:move(closest_soul.pos)
return true
end
end
return false
end
-- Core Logic Functions (REVISED to use new Q logic)
local function Combo()
if not orb.combat.is_active() then return end
local w_target = nil
-- R target is determined inside the R logic block now
local q_intended_enemy = nil
local q_intended_ally = nil
-- W Logic (Highest priority CC/Setup)
if menu.w.combo:get() and spells.w.ready() then
w_target = ts.get_result(function(res, obj, dist)
if not IsValidTarget(obj, spells.w.range) then return false end
res.obj = obj
return true
end).obj
if w_target then
local pred_pos = GetPrediction("w", w_target)
if pred_pos then
player:castSpell("pos", spells.w.slot, pred_pos)
return -- Cast W and exit for this tick
end
end
end
-- Q Logic (Uses new GetBestQCastTarget)
if menu.q.combo:get() and spells.q.ready() then
local q_prio = menu.q.q_priority:get()
-- Find best enemy target for Q damage (within max effective range)
q_intended_enemy = ts.get_result(function(res, obj, dist)
if not IsValidTarget(obj, spells.q.effective_range) then return false end
res.obj = obj
return true
end).obj
-- Find best ally target for Q heal (within max effective range)
if menu.q.heal_ally:get() then
local lowest_hp_ally = nil
local lowest_hp_pct = 101
for i = 0, objManager.allies_n - 1 do
local ally = objManager.allies[i]
if IsValidTarget(ally, spells.q.effective_range) then -- Check effective range
local blacklist_var = "noheal_" .. ally.charName:lower()
if not (menu.q.heal_blacklist[blacklist_var] and menu.q.heal_blacklist[blacklist_var]:get()) then
local hp_pct = ally.health / ally.maxHealth * 100
if hp_pct < menu.q.heal_ally_hp:get() and hp_pct < lowest_hp_pct then
lowest_hp_pct = hp_pct
lowest_hp_ally = ally
end
end
end
end
q_intended_ally = lowest_hp_ally
end
-- Determine intended targets for GetBestQCastTarget based on priority
local final_intended_enemy = nil
local final_intended_ally = nil
if q_prio == 2 and q_intended_ally then -- Heal Prio
final_intended_ally = q_intended_ally
final_intended_enemy = q_intended_enemy -- Still pass enemy for potential damage+heal
else -- Damage Prio (or Heal prio with no heal target)
final_intended_enemy = q_intended_enemy
final_intended_ally = q_intended_ally -- Pass heal target for potential damage+heal
end
-- Get the actual unit to cast Q on
local best_q_cast_target = GetBestQCastTarget(final_intended_enemy, final_intended_ally)
if best_q_cast_target then
-- print("Combo Q Cast ->", best_q_cast_target.name) -- Optional Debug
player:castSpell("obj", spells.q.slot, best_q_cast_target)
return -- Cast Q and exit
end
end
-- R Logic (AoE Combo - REVISED to use fallback logic ONLY)
if menu.r.aoe_combo:get() and spells.r.ready() then
local best_r_pos = nil
local max_enemies_hit = 0 -- Initialize max hits found
local potential_r_targets = {}
-- 1. Gather potential targets within R range
for i = 0, objManager.enemies_n - 1 do
local enemy = objManager.enemies[i]
if IsValidTarget(enemy, spells.r.range) then
table.insert(potential_r_targets, enemy)
end
end
-- 2. Only proceed if the number of potential targets meets the menu requirement
if #potential_r_targets >= menu.r.aoe_min_enemies:get() then
-- 3. Iterate through each potential target to find the best AIMING position
for _, aim_target in ipairs(potential_r_targets) do
-- Predict where to aim R to hit this specific 'aim_target'
local pred_aim_pos = GetPrediction("r", aim_target)
if pred_aim_pos then
local current_hits = 0
-- 4. For this potential aiming position, check how many targets would be hit
for _, check_enemy in ipairs(potential_r_targets) do
-- Predict where 'check_enemy' will be when the R (aimed at pred_aim_pos) arrives
-- Estimate time based on distance to the *aimed* position
local time_to_hit = player.pos:dist(pred_aim_pos) / spells.r.speed + spells.r.delay
local check_enemy_predicted_pos = PredictTargetPos(check_enemy, time_to_hit)
if check_enemy_predicted_pos then
-- Check collision: Does the R line (player -> pred_aim_pos) hit check_enemy_predicted_pos?
local dist_from_line = check_enemy_predicted_pos:to2D():distLine(player.pos2D, pred_aim_pos:to2D())
-- Check distance from the line segment representing the R path
if dist_from_line <= (spells.r.width / 2) + check_enemy.boundingRadius then
current_hits = current_hits + 1
end
end
end -- End of checking hits for one aim position
-- 5. If this aiming position hits more targets than the current best, update
if current_hits > max_enemies_hit then
max_enemies_hit = current_hits
best_r_pos = pred_aim_pos -- Store this aiming position as the best so far
end
end
end -- End of iterating through potential aiming targets
-- 6. Cast R if a suitable position hitting enough enemies was found
if best_r_pos and max_enemies_hit >= menu.r.aoe_min_enemies:get() then
-- print("Combo R Cast -> AoE on", max_enemies_hit, "targets.") -- Debug print
player:castSpell("pos", spells.r.slot, best_r_pos)
return -- Exit Combo function after casting R
end
end
end -- End of R AoE Combo Logic
-- E Logic (Combo - Unchanged)
if menu.e.combo:get() and spells.e.ready() then
local primary_target = w_target or q_intended_enemy -- Use W target or Q intended enemy
if IsValidTarget(primary_target) then
local dist_sqr = player.pos:distSqr(primary_target.pos)
-- Use Q effective range for chase check, as Q is primary damage tool
local chase_range_sqr = (spells.q.effective_range * 0.8)^2 -- Chase if slightly outside effective Q range
local needs_escape = player.health / player.maxHealth * 100 < 40
if (dist_sqr > chase_range_sqr) or needs_escape then
if game.time - State.last_e_time > 1.0 then
player:castSpell("self", spells.e.slot)
State.last_e_time = game.time
end
end
end
end
end
local function Harass()
if not orb.menu.hybrid.key:get() then return end
local w_mana_ok = HasEnoughMana(menu.w.harass_mana:get())
local q_mana_ok = HasEnoughMana(menu.q.harass_mana:get())
if not q_mana_ok and not w_mana_ok then return end
-- W Logic (Only if enabled for harass)
if menu.w.harass:get() and spells.w.ready() and w_mana_ok then
local target = ts.get_result(function(res, obj, dist)
if not IsValidTarget(obj, spells.w.range) then return false end
res.obj = obj
return true
end).obj
if target then
local pred_pos = GetPrediction("w", target)
if pred_pos then
player:castSpell("pos", spells.w.slot, pred_pos)
return -- Cast W and exit
end
end
end
-- Q Logic (Uses new GetBestQCastTarget)
if menu.q.harass:get() and spells.q.ready() and q_mana_ok then
local q_prio = menu.q.q_priority:get()
local q_intended_enemy = nil
local q_intended_ally = nil
-- Find potential targets within max effective range
q_intended_enemy = ts.get_result(function(res, obj, dist)
if not IsValidTarget(obj, spells.q.effective_range) then return false end
res.obj = obj
return true
end).obj
if menu.q.heal_ally:get() then
local lowest_hp_ally = nil
local lowest_hp_pct = 101
for i = 0, objManager.allies_n - 1 do
local ally = objManager.allies[i]
if IsValidTarget(ally, spells.q.effective_range) then
local blacklist_var = "noheal_" .. ally.charName:lower()
if not (menu.q.heal_blacklist[blacklist_var] and menu.q.heal_blacklist[blacklist_var]:get()) then
local hp_pct = ally.health / ally.maxHealth * 100
if hp_pct < menu.q.heal_ally_hp:get() and hp_pct < lowest_hp_pct then
lowest_hp_pct = hp_pct
lowest_hp_ally = ally
end
end
end
end
q_intended_ally = lowest_hp_ally
end
local final_intended_enemy = nil
local final_intended_ally = nil
if q_prio == 2 and q_intended_ally then
final_intended_ally = q_intended_ally
final_intended_enemy = q_intended_enemy
else
final_intended_enemy = q_intended_enemy
final_intended_ally = q_intended_ally
end
local best_q_cast_target = GetBestQCastTarget(final_intended_enemy, final_intended_ally)
if best_q_cast_target then
-- print("Harass Q Cast ->", best_q_cast_target.name)
player:castSpell("obj", spells.q.slot, best_q_cast_target)
-- No return needed, maybe W is still possible if Q fails?
end
end
end
local function Farm()
-- Basic checks: if Q farming is enabled, Q is ready, and player has enough mana
if not State.q_farm_enabled then return end
if not spells.q.ready() then return end
if not HasEnoughMana(menu.q.farm_mana:get()) then return end -- Use farm mana limit from menu
-- Get Q properties for calculations
local q_cast_range = GetDynamicQCastRange() -- The range we must be within to click a unit
local q_effective_range = spells.q.effective_range -- The maximum reach of the beam
local q_width = spells.q.width -- The width (diameter) of the beam for collision checks
-- Get the list of enemy lane minions
local enemy_minions = objManager.minions["lane_enemy"]
if not enemy_minions then return end -- Return if no enemy lane minions table exists
local enemy_minion_size = objManager.minions.size["lane_enemy"]
if enemy_minion_size == 0 then return end -- Return if there are no enemy lane minions
-- Variables to store the best result found
local best_q_cast_target_for_farm = nil
local max_minions_hit = 0
-- Get the minimum number of minions required to hit from the menu
local min_minions_required = menu.q.q_min_minions:get()
-- Get player position (2D) and Q spell delay for prediction
local player_pos_2d = player.pos2D
local q_delay = spells.q.delay
-- Iterate through each enemy lane minion. We will consider each of these minions
-- as a potential target that the Q beam *must* pass through (determines beam direction).
for i = 0, enemy_minion_size - 1 do
local potential_aim_minion = enemy_minions[i]
-- Ensure the potential aiming minion is valid and within the Q effective range (as a hit target)
if potential_aim_minion and potential_aim_minion.isVisible and not potential_aim_minion.isDead and potential_aim_minion.isTargetable and player_pos_2d:distSqr(potential_aim_minion.pos2D) <= q_effective_range * q_effective_range then
-- Predict the position of this potential aiming minion when the Q beam would arrive.
local predicted_aim_pos = PredictTargetPos(potential_aim_minion, q_delay)
if not predicted_aim_pos then
goto next_potential_aim_minion -- Skip to the next minion if prediction fails
end
local predicted_aim_pos_2d = predicted_aim_pos:to2D()
-- Calculate the direction of the hypothetical Q beam from the player to the predicted aim position.
local beam_direction = (predicted_aim_pos_2d - player_pos_2d):norm()
if beam_direction:lenSqr() < 0.01 then
beam_direction = player.direction2D:norm()
if beam_direction:lenSqr() < 0.01 then beam_direction = vec2(1,0) end
end
-- Calculate the end point of this hypothetical Q beam.
local beam_end_point_2d = player_pos_2d + beam_direction * q_effective_range
local current_minions_hit = 0
local first_valid_clickable_enemy_minion = nil
-- Iterate through ALL enemy lane minions *again* to count how many would be hit by this beam
-- AND find if there's at least one clickable enemy minion on this path.
for j = 0, enemy_minion_size - 1 do
local check_minion = enemy_minions[j]
-- Ensure the minion is valid, visible, and targetable
if check_minion and check_minion.isVisible and not check_minion.isDead and check_minion.isTargetable then
-- Predict the position of this minion
local predicted_check_pos = PredictTargetPos(check_minion, q_delay)
if predicted_check_pos then
local predicted_check_pos_2d = predicted_check_pos:to2D()
local check_minion_radius = check_minion.boundingRadius
-- Check for collision between the minion (predicted) and the beam line segment
if mathf.col_vec_rect(predicted_check_pos_2d, player_pos_2d, beam_end_point_2d, check_minion_radius, q_width) then
current_minions_hit = current_minions_hit + 1
-- *** NEW: Check if this minion is also a valid CLICKABLE target within CAST range and is the first found ***
if first_valid_clickable_enemy_minion == nil and player_pos_2d:distSqr(check_minion.pos2D) <= q_cast_range * q_cast_range then
-- Store this minion as the unit we would click on if this beam path is chosen
first_valid_clickable_enemy_minion = check_minion
end
end -- End if collision occurs
end -- End if predicted_check_pos is valid
end -- End if check_minion is valid
end -- End inner loop (checking how many minions and if any are clickable on this beam)
-- Now, evaluate this beam path:
-- 1. Does it hit enough minions?
-- 2. Is there at least one clickable enemy minion on this path within Q cast range?
-- 3. Is this the best path found so far based on minion count?
if current_minions_hit >= min_minions_required and first_valid_clickable_enemy_minion ~= nil then
if current_minions_hit > max_minions_hit then
-- This is a new best path. Store the clickable unit and the hit count.
max_minions_hit = current_minions_hit
best_q_cast_target_for_farm = first_valid_clickable_enemy_minion
end
end
end -- End if potential_aim_minion is valid and in range
::next_potential_aim_minion:: -- Label for the goto statement
end -- End outer loop (iterating through potential aiming minions)
-- After checking all potential aiming minions, if we found a suitable clickable target
-- that initiates a beam hitting enough enemy minions, cast Q on that target.
if best_q_cast_target_for_farm and max_minions_hit >= min_minions_required then
-- print(string.format("Farm Q Cast -> %s (Click Target) | Hitting %d minions (Predicted Aim: %s).", best_q_cast_target_for_farm.name or "Unknown", max_minions_hit, potential_aim_minion and potential_aim_minion.name or "N/A")) -- More detailed debug
player:castSpell("obj", spells.q.slot, best_q_cast_target_for_farm)
-- Optional: Add a small server pause or a spell cooldown state here if needed
-- orb.core.set_server_pause()
end
end
local function JungleClear()
if not menu.q.jungle:get() or not spells.q.ready() then return end
if not HasEnoughMana(menu.q.farm_mana:get()) then return end
local target_mob = nil
local best_cast_unit_for_jungle = nil
local highest_hp = 0
local jungle_mobs = objManager.minions[TEAM_NEUTRAL]
if not jungle_mobs then return end
-- Prioritize Epic > Large > Small
local mob_priority = { Epic = 3, Large = 2, Small = 1, Default = 0 }
local best_priority = -1
for i = 0, objManager.minions.size[TEAM_NEUTRAL] - 1 do
local mob = jungle_mobs[i]
if IsValidTarget(mob, spells.q.effective_range) then
local current_priority = mob_priority.Default
if mob.isEpicMonster then current_priority = mob_priority.Epic
elseif mob.isLargeMonster then current_priority = mob_priority.Large
else current_priority = mob_priority.Small end
if current_priority > best_priority then
local cast_unit = GetBestQCastTarget(mob, nil)
if cast_unit then
best_priority = current_priority
highest_hp = mob.health -- Track HP within best priority
target_mob = mob
best_cast_unit_for_jungle = cast_unit
end
-- If same priority, target higher HP one (usually the main camp monster)
elseif current_priority == best_priority and mob.health > highest_hp then
local cast_unit = GetBestQCastTarget(mob, nil)
if cast_unit then
highest_hp = mob.health
target_mob = mob
best_cast_unit_for_jungle = cast_unit
end
end
end
end
if best_cast_unit_for_jungle and target_mob then
-- print("Jungle Q Cast ->", best_cast_unit_for_jungle.name, "to hit", target_mob.name)
player:castSpell("obj", spells.q.slot, best_cast_unit_for_jungle)
end
end
local function HealAllies()
if not menu.q.heal_ally:get() or not spells.q.ready() then return end
if orb.combat.is_active() or orb.menu.hybrid.key:get() then return end
if not HasEnoughMana(menu.q.harass_mana:get()) then return end
local lowest_hp_ally = nil
local lowest_hp_pct = 101
for i = 0, objManager.allies_n - 1 do
local ally = objManager.allies[i]
if IsValidTarget(ally, spells.q.effective_range) then -- Check effective range
local blacklist_var = "noheal_" .. ally.charName:lower()
if not (menu.q.heal_blacklist[blacklist_var] and menu.q.heal_blacklist[blacklist_var]:get()) then
local hp_pct = ally.health / ally.maxHealth * 100
if hp_pct < menu.q.heal_ally_hp:get() and hp_pct < lowest_hp_pct then
lowest_hp_pct = hp_pct
lowest_hp_ally = ally
end
end
end
end
if lowest_hp_ally then
local best_q_cast_target = GetBestQCastTarget(nil, lowest_hp_ally) -- Prioritize ally
if best_q_cast_target then
-- print("Heal Q Cast ->", best_q_cast_target.name, "to heal", lowest_hp_ally.name)
player:castSpell("obj", spells.q.slot, best_q_cast_target)
end
end
end
local function AutoCC()
-- Auto Q on CC (Uses new Q logic)
if menu.q.auto_q_cc:get() and spells.q.ready() then
local target = ts.get_result(function(res, obj, dist)
-- Check effective range for CC targets
if not IsValidTarget(obj, spells.q.effective_range) then return false end
if IsCCd(obj) then
res.obj = obj
return true
end
return false
end).obj
if target then
local best_q_cast_target = GetBestQCastTarget(target, nil) -- Prioritize enemy
if best_q_cast_target then
-- print("Auto Q on CC ->", best_q_cast_target.name, "to hit", target.name)
player:castSpell("obj", spells.q.slot, best_q_cast_target)
return -- Return to prioritize Q on CC
end
end
end
-- Auto W on CC (Unchanged)
if menu.w.auto_w_cc:get() and spells.w.ready() then
local target = ts.get_result(function(res, obj, dist)
if not IsValidTarget(obj, spells.w.range) then return false end
if IsCCd(obj) then
res.obj = obj
return true
end
return false
end).obj
if target then
local pred_pos = GetPrediction("w", target)