-
Notifications
You must be signed in to change notification settings - Fork 244
/
Orbwalking.cs
1765 lines (1546 loc) · 72.1 KB
/
Orbwalking.cs
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
namespace LeagueSharp.Common
{
using System;
using System.Collections.Generic;
using System.Linq;
using SharpDX;
using Color = System.Drawing.Color;
/// <summary>
/// This class offers everything related to auto-attacks and orbwalking.
/// </summary>
public static class Orbwalking
{
#region Static Fields
/// <summary>
/// An array of the last 3 targets as NetworkIDs, useful for 3-hit passives or thunderlord
/// </summary>
public static int[] LastTargets = new int[] {0,0,0};
/// <summary>
/// <c>true</c> if the orbwalker will attack.
/// </summary>
public static bool Attack = true;
/// <summary>
/// <c>true</c> if the orbwalker will skip the next attack.
/// </summary>
public static bool DisableNextAttack;
/// <summary>
/// The last auto attack tick
/// </summary>
public static int LastAATick;
/// <summary>
/// The tick the most recent attack command was sent.
/// </summary>
public static int LastAttackCommandT;
/// <summary>
/// The last move command position
/// </summary>
public static Vector3 LastMoveCommandPosition = Vector3.Zero;
/// <summary>
/// The tick the most recent move command was sent.
/// </summary>
public static int LastMoveCommandT;
/// <summary>
/// <c>true</c> if the orbwalker will move.
/// </summary>
public static bool Move = true;
/// <summary>
/// The champion name
/// </summary>
private static readonly string _championName;
/// <summary>
/// The random
/// </summary>
private static readonly Random _random = new Random(DateTime.Now.Millisecond);
/// <summary>
/// Spells that reset the attack timer.
/// </summary>
private static readonly string[] AttackResets =
{
"dariusnoxiantacticsonh", "fiorae", "garenq", "gravesmove",
"hecarimrapidslash", "jaxempowertwo", "jaycehypercharge",
"leonashieldofdaybreak", "luciane", "monkeykingdoubleattack",
"mordekaisermaceofspades", "nasusq", "nautiluspiercinggaze",
"netherblade", "gangplankqwrapper", "powerfist",
"renektonpreexecute", "rengarq", "shyvanadoubleattack",
"sivirw", "takedown", "talonnoxiandiplomacy",
"trundletrollsmash", "vaynetumble", "vie", "volibearq",
"xenzhaocombotarget", "yorickspectral", "reksaiq",
"itemtitanichydracleave", "masochism", "illaoiw",
"elisespiderw", "fiorae", "meditate", "sejuaninorthernwinds",
"asheq", "camilleq", "camilleq2"
};
/// <summary>
/// Spells that are attacks even if they dont have the "attack" word in their name.
/// </summary>
private static readonly string[] Attacks =
{
"caitlynheadshotmissile", "frostarrow", "garenslash2",
"kennenmegaproc", "masteryidoublestrike", "quinnwenhanced",
"renektonexecute", "renektonsuperexecute",
"rengarnewpassivebuffdash", "trundleq", "xenzhaothrust",
"xenzhaothrust2", "xenzhaothrust3", "viktorqbuff",
"lucianpassiveshot"
};
/// <summary>
/// Spells that are not attacks even if they have the "attack" word in their name.
/// </summary>
private static readonly string[] NoAttacks =
{
"volleyattack", "volleyattackwithsound",
"jarvanivcataclysmattack", "monkeykingdoubleattack",
"shyvanadoubleattack", "shyvanadoubleattackdragon",
"zyragraspingplantattack", "zyragraspingplantattack2",
"zyragraspingplantattackfire", "zyragraspingplantattack2fire",
"viktorpowertransfer", "sivirwattackbounce", "asheqattacknoonhit",
"elisespiderlingbasicattack", "heimertyellowbasicattack",
"heimertyellowbasicattack2", "heimertbluebasicattack",
"annietibbersbasicattack", "annietibbersbasicattack2",
"yorickdecayedghoulbasicattack", "yorickravenousghoulbasicattack",
"yorickspectralghoulbasicattack", "malzaharvoidlingbasicattack",
"malzaharvoidlingbasicattack2", "malzaharvoidlingbasicattack3",
"kindredwolfbasicattack", "gravesautoattackrecoil"
};
/// <summary>
/// Champs whose auto attacks can't be cancelled
/// </summary>
private static readonly string[] NoCancelChamps = { "Kalista" };
/// <summary>
/// The player
/// </summary>
private static readonly Obj_AI_Hero Player;
private static int _autoattackCounter;
/// <summary>
/// The delay
/// </summary>
private static int _delay;
/// <summary>
/// The last target
/// </summary>
private static AttackableUnit _lastTarget;
/// <summary>
/// The minimum distance
/// </summary>
private static float _minDistance = 400;
/// <summary>
/// <c>true</c> if the auto attack missile was launched from the player.
/// </summary>
private static bool _missileLaunched;
#endregion
#region Constructors and Destructors
/// <summary>
/// Initializes static members of the <see cref="Orbwalking" /> class.
/// </summary>
static Orbwalking()
{
Player = ObjectManager.Player;
_championName = Player.ChampionName;
Obj_AI_Base.OnProcessSpellCast += OnProcessSpell;
Obj_AI_Base.OnDoCast += Obj_AI_Base_OnDoCast;
Spellbook.OnStopCast += SpellbookOnStopCast;
if (_championName == "Rengar")
{
Obj_AI_Base.OnPlayAnimation += delegate(Obj_AI_Base sender, GameObjectPlayAnimationEventArgs args)
{
if (sender.IsMe && args.Animation == "Spell5")
{
var t = 0;
if (_lastTarget != null && _lastTarget.IsValid)
{
t += (int)Math.Min(ObjectManager.Player.Distance(_lastTarget) / 1.5f, 0.6f);
}
LastAATick = Utils.GameTimeTickCount - Game.Ping / 2 + t;
}
};
}
}
#endregion
#region Delegates
/// <summary>
/// Delegate AfterAttackEvenH
/// </summary>
/// <param name="unit">The unit.</param>
/// <param name="target">The target.</param>
public delegate void AfterAttackEvenH(AttackableUnit unit, AttackableUnit target);
/// <summary>
/// Delegate BeforeAttackEvenH
/// </summary>
/// <param name="args">The <see cref="BeforeAttackEventArgs" /> instance containing the event data.</param>
public delegate void BeforeAttackEvenH(BeforeAttackEventArgs args);
/// <summary>
/// Delegate OnAttackEvenH
/// </summary>
/// <param name="unit">The unit.</param>
/// <param name="target">The target.</param>
public delegate void OnAttackEvenH(AttackableUnit unit, AttackableUnit target);
/// <summary>
/// Delegate OnNonKillableMinionH
/// </summary>
/// <param name="minion">The minion.</param>
public delegate void OnNonKillableMinionH(AttackableUnit minion);
/// <summary>
/// Delegate OnTargetChangeH
/// </summary>
/// <param name="oldTarget">The old target.</param>
/// <param name="newTarget">The new target.</param>
public delegate void OnTargetChangeH(AttackableUnit oldTarget, AttackableUnit newTarget);
#endregion
#region Public Events
/// <summary>
/// This event is fired after a unit finishes auto-attacking another unit (Only works with player for now).
/// </summary>
public static event AfterAttackEvenH AfterAttack;
/// <summary>
/// This event is fired before the player auto attacks.
/// </summary>
public static event BeforeAttackEvenH BeforeAttack;
/// <summary>
/// This event is fired when a unit is about to auto-attack another unit.
/// </summary>
public static event OnAttackEvenH OnAttack;
/// <summary>
/// Occurs when a minion is not killable by an auto attack.
/// </summary>
public static event OnNonKillableMinionH OnNonKillableMinion;
/// <summary>
/// Gets called on target changes
/// </summary>
public static event OnTargetChangeH OnTargetChange;
#endregion
#region Enums
/// <summary>
/// The orbwalking mode.
/// </summary>
public enum OrbwalkingMode
{
/// <summary>
/// The orbwalker will only last hit minions.
/// </summary>
LastHit,
/// <summary>
/// The orbwalker will alternate between last hitting and auto attacking champions.
/// </summary>
Mixed,
/// <summary>
/// The orbwalker will clear the lane of minions as fast as possible while attempting to get the last hit.
/// </summary>
LaneClear,
/// <summary>
/// The orbwalker will only attack the target.
/// </summary>
Combo,
/// <summary>
/// The orbwalker will only last hit minions as late as possible.
/// </summary>
Freeze,
/// <summary>
/// The orbwalker will only move.
/// </summary>
CustomMode,
/// <summary>
/// The orbwalker does nothing.
/// </summary>
None
}
#endregion
#region Public Methods and Operators
/// <summary>
/// Returns if the player's auto-attack is ready.
/// </summary>
/// <returns><c>true</c> if this instance can attack; otherwise, <c>false</c>.</returns>
public static bool CanAttack()
{
if (Player.IsCastingInterruptableSpell())
{
return false;
}
if (Player.HasBuffOfType(BuffType.Blind) && Player.CharData.BaseSkinName != "Kalista")
{
return false;
}
if (Player.ChampionName == "Graves")
{
var attackDelay = 1.0740296828d * 1000 * Player.AttackDelay - 716.2381256175d;
if (Utils.GameTimeTickCount + Game.Ping / 2 + 25 >= LastAATick + attackDelay
&& Player.HasBuff("GravesBasicAttackAmmo1"))
{
return true;
}
return false;
}
if (Player.ChampionName == "Jhin")
{
if (Player.HasBuff("JhinPassiveReload"))
{
return false;
}
}
return Utils.GameTimeTickCount + Game.Ping / 2 + 25 >= LastAATick + Player.AttackDelay * 1000;
}
/// <summary>
/// Returns true if moving won't cancel the auto-attack.
/// </summary>
/// <param name="extraWindup">The extra windup.</param>
/// <returns><c>true</c> if this instance can move the specified extra windup; otherwise, <c>false</c>.</returns>
public static bool CanMove(float extraWindup, bool disableMissileCheck = false)
{
if (_missileLaunched && Orbwalker.MissileCheck && !disableMissileCheck)
{
return true;
}
var localExtraWindup = 0;
if (_championName == "Rengar" && (Player.HasBuff("rengarqbase") || Player.HasBuff("rengarqemp")))
{
localExtraWindup = 200;
}
return NoCancelChamps.Contains(_championName)
|| (Utils.GameTimeTickCount + Game.Ping / 2
>= LastAATick + Player.AttackCastDelay * 1000 + extraWindup + localExtraWindup);
}
/// <summary>
/// Returns the auto-attack range of the target.
/// </summary>
/// <param name="target">The target.</param>
/// <returns>System.Single.</returns>
public static float GetAttackRange(Obj_AI_Hero target)
{
var result = target.AttackRange + target.BoundingRadius;
return result;
}
/// <summary>
/// Gets the last move position.
/// </summary>
/// <returns>Vector3.</returns>
public static Vector3 GetLastMovePosition()
{
return LastMoveCommandPosition;
}
/// <summary>
/// Gets the last move time.
/// </summary>
/// <returns>System.Single.</returns>
public static float GetLastMoveTime()
{
return LastMoveCommandT;
}
/// <summary>
/// Returns player auto-attack missile speed.
/// </summary>
/// <returns>System.Single.</returns>
public static float GetMyProjectileSpeed()
{
return IsMelee(Player) || _championName == "Azir" || _championName == "Velkoz"
|| _championName == "Viktor" && Player.HasBuff("ViktorPowerTransferReturn")
? float.MaxValue
: Player.BasicAttack.MissileSpeed;
}
/// <summary>
/// Returns the auto-attack range of local player with respect to the target.
/// </summary>
/// <param name="target">The target.</param>
/// <returns>System.Single.</returns>
public static float GetRealAutoAttackRange(AttackableUnit target)
{
var result = Player.AttackRange + Player.BoundingRadius;
if (target.IsValidTarget())
{
var aiBase = target as Obj_AI_Base;
if (aiBase != null && Player.ChampionName == "Caitlyn")
{
if (aiBase.HasBuff("caitlynyordletrapinternal"))
{
result += 650;
}
}
return result + target.BoundingRadius;
}
return result;
}
/// <summary>
/// Returns true if the target is in auto-attack range.
/// </summary>
/// <param name="target">The target.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
public static bool InAutoAttackRange(AttackableUnit target)
{
if (!target.IsValidTarget())
{
return false;
}
var myRange = GetRealAutoAttackRange(target);
return
Vector2.DistanceSquared(
target is Obj_AI_Base ? ((Obj_AI_Base)target).ServerPosition.To2D() : target.Position.To2D(),
Player.ServerPosition.To2D()) <= myRange * myRange;
}
/// <summary>
/// Returns true if the spellname is an auto-attack.
/// </summary>
/// <param name="name">The name.</param>
/// <returns><c>true</c> if the name is an auto attack; otherwise, <c>false</c>.</returns>
public static bool IsAutoAttack(string name)
{
return (name.ToLower().Contains("attack") && !NoAttacks.Contains(name.ToLower()))
|| Attacks.Contains(name.ToLower());
}
/// <summary>
/// Returns true if the spellname resets the attack timer.
/// </summary>
/// <param name="name">The name.</param>
/// <returns><c>true</c> if the specified name is an auto attack reset; otherwise, <c>false</c>.</returns>
public static bool IsAutoAttackReset(string name)
{
return AttackResets.Contains(name.ToLower());
}
/// <summary>
/// Returns true if the unit is melee
/// </summary>
/// <param name="unit">The unit.</param>
/// <returns><c>true</c> if the specified unit is melee; otherwise, <c>false</c>.</returns>
public static bool IsMelee(this Obj_AI_Base unit)
{
return unit.CombatType == GameObjectCombatType.Melee;
}
/// <summary>
/// Moves to the position.
/// </summary>
/// <param name="position">The position.</param>
/// <param name="holdAreaRadius">The hold area radius.</param>
/// <param name="overrideTimer">if set to <c>true</c> [override timer].</param>
/// <param name="useFixedDistance">if set to <c>true</c> [use fixed distance].</param>
/// <param name="randomizeMinDistance">if set to <c>true</c> [randomize minimum distance].</param>
public static void MoveTo(
Vector3 position,
float holdAreaRadius = 0,
bool overrideTimer = false,
bool useFixedDistance = true,
bool randomizeMinDistance = true)
{
var playerPosition = Player.ServerPosition;
if (playerPosition.Distance(position, true) < holdAreaRadius * holdAreaRadius)
{
if (Player.Path.Length > 0)
{
Player.IssueOrder(GameObjectOrder.Stop, playerPosition);
LastMoveCommandPosition = playerPosition;
LastMoveCommandT = Utils.GameTimeTickCount - 70;
}
return;
}
var point = position;
if (Player.Distance(point, true) < 150 * 150)
{
point = playerPosition.Extend(
position,
randomizeMinDistance ? (_random.NextFloat(0.6f, 1) + 0.2f) * _minDistance : _minDistance);
}
var angle = 0f;
var currentPath = Player.GetWaypoints();
if (currentPath.Count > 1 && currentPath.PathLength() > 100)
{
var movePath = Player.GetPath(point);
if (movePath.Length > 1)
{
var v1 = currentPath[1] - currentPath[0];
var v2 = movePath[1] - movePath[0];
angle = v1.AngleBetween(v2.To2D());
var distance = movePath.Last().To2D().Distance(currentPath.Last(), true);
if ((angle < 10 && distance < 500 * 500) || distance < 50 * 50)
{
return;
}
}
}
if (Utils.GameTimeTickCount - LastMoveCommandT < 70 + Math.Min(60, Game.Ping) && !overrideTimer
&& angle < 60)
{
return;
}
if (angle >= 60 && Utils.GameTimeTickCount - LastMoveCommandT < 60)
{
return;
}
Player.IssueOrder(GameObjectOrder.MoveTo, point);
LastMoveCommandPosition = point;
LastMoveCommandT = Utils.GameTimeTickCount;
}
/// <summary>
/// Orbwalks a target while moving to Position.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="position">The position.</param>
/// <param name="extraWindup">The extra windup.</param>
/// <param name="holdAreaRadius">The hold area radius.</param>
/// <param name="useFixedDistance">if set to <c>true</c> [use fixed distance].</param>
/// <param name="randomizeMinDistance">if set to <c>true</c> [randomize minimum distance].</param>
public static void Orbwalk(
AttackableUnit target,
Vector3 position,
float extraWindup = 90,
float holdAreaRadius = 0,
bool useFixedDistance = true,
bool randomizeMinDistance = true)
{
if (Utils.GameTimeTickCount - LastAttackCommandT < 70 + Math.Min(60, Game.Ping))
{
return;
}
try
{
if (target.IsValidTarget() && CanAttack() && Attack)
{
DisableNextAttack = false;
FireBeforeAttack(target);
if (!DisableNextAttack)
{
if (!NoCancelChamps.Contains(_championName))
{
_missileLaunched = false;
}
if (Player.IssueOrder(GameObjectOrder.AttackUnit, target))
{
LastAttackCommandT = Utils.GameTimeTickCount;
_lastTarget = target;
}
return;
}
}
if (CanMove(extraWindup) && Move)
{
MoveTo(position, Math.Max(holdAreaRadius, 30), false, useFixedDistance, randomizeMinDistance);
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
/// <summary>
/// Resets the Auto-Attack timer.
/// </summary>
public static void ResetAutoAttackTimer()
{
LastAATick = 0;
}
/// <summary>
/// Sets the minimum orbwalk distance.
/// </summary>
/// <param name="d">The d.</param>
public static void SetMinimumOrbwalkDistance(float d)
{
_minDistance = d;
}
/// <summary>
/// Sets the movement delay.
/// </summary>
/// <param name="delay">The delay.</param>
public static void SetMovementDelay(int delay)
{
_delay = delay;
}
#endregion
#region Methods
/// <summary>
/// Pushes a target to the <see cref="LastTargets"/> list.
/// </summary>
/// <param name="networkId"></param>
private static void PushLastTargets(int networkId)
{
LastTargets[2] = LastTargets[1];
LastTargets[1] = LastTargets[0];
LastTargets[0] = networkId;
}
/// <summary>
/// Fires the after attack event.
/// </summary>
/// <param name="unit">The unit.</param>
/// <param name="target">The target.</param>
private static void FireAfterAttack(AttackableUnit unit, AttackableUnit target)
{
if (AfterAttack != null && target.IsValidTarget())
{
AfterAttack(unit, target);
}
}
/// <summary>
/// Fires the before attack event.
/// </summary>
/// <param name="target">The target.</param>
private static void FireBeforeAttack(AttackableUnit target)
{
if (BeforeAttack != null)
{
BeforeAttack(new BeforeAttackEventArgs { Target = target });
}
else
{
DisableNextAttack = false;
}
}
/// <summary>
/// Fires the on attack event.
/// </summary>
/// <param name="unit">The unit.</param>
/// <param name="target">The target.</param>
private static void FireOnAttack(AttackableUnit unit, AttackableUnit target)
{
if (OnAttack != null)
{
OnAttack(unit, target);
}
}
/// <summary>
/// Fires the on non killable minion event.
/// </summary>
/// <param name="minion">The minion.</param>
private static void FireOnNonKillableMinion(AttackableUnit minion)
{
if (OnNonKillableMinion != null)
{
OnNonKillableMinion(minion);
}
}
/// <summary>
/// Fires the on target switch event.
/// </summary>
/// <param name="newTarget">The new target.</param>
private static void FireOnTargetSwitch(AttackableUnit newTarget)
{
if (OnTargetChange != null && (!_lastTarget.IsValidTarget() || _lastTarget != newTarget))
{
OnTargetChange(_lastTarget, newTarget);
}
}
/// <summary>
/// Fired when an auto attack is fired.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="args">The <see cref="GameObjectProcessSpellCastEventArgs" /> instance containing the event data.</param>
private static void Obj_AI_Base_OnDoCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args)
{
if (sender.IsMe)
{
var ping = Game.Ping;
if (ping <= 30) //First world problems kappa
{
Utility.DelayAction.Add(30 - ping, () => Obj_AI_Base_OnDoCast_Delayed(sender, args));
return;
}
Obj_AI_Base_OnDoCast_Delayed(sender, args);
}
}
/// <summary>
/// Fired 30ms after an auto attack is launched.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="args">The <see cref="GameObjectProcessSpellCastEventArgs" /> instance containing the event data.</param>
private static void Obj_AI_Base_OnDoCast_Delayed(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args)
{
if (IsAutoAttackReset(args.SData.Name))
{
ResetAutoAttackTimer();
}
if (IsAutoAttack(args.SData.Name))
{
FireAfterAttack(sender, args.Target as AttackableUnit);
_missileLaunched = true;
}
}
/// <summary>
/// Handles the <see cref="E:ProcessSpell" /> event.
/// </summary>
/// <param name="unit">The unit.</param>
/// <param name="Spell">The <see cref="GameObjectProcessSpellCastEventArgs" /> instance containing the event data.</param>
private static void OnProcessSpell(Obj_AI_Base unit, GameObjectProcessSpellCastEventArgs Spell)
{
try
{
if (unit.IsMe)
{
var spellName = Spell.SData.Name;
if (IsAutoAttackReset(spellName) && Spell.SData.SpellCastTime == 0)
ResetAutoAttackTimer();
if (!IsAutoAttack(spellName))
return;
if (Spell.Target is Obj_AI_Base || Spell.Target is Obj_BarracksDampener || Spell.Target is Obj_HQ)
{
PushLastTargets(Spell.Target.NetworkId);
LastAATick = Utils.GameTimeTickCount - Game.Ping / 2;
_missileLaunched = false;
LastMoveCommandT = 0;
_autoattackCounter++;
if (Spell.Target is Obj_AI_Base)
{
var target = (Obj_AI_Base)Spell.Target;
if (target.IsValid)
{
FireOnTargetSwitch(target);
_lastTarget = target;
}
}
}
}
FireOnAttack(unit, _lastTarget);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
/// <summary>
/// Fired when the spellbook stops casting a spell.
/// </summary>
/// <param name="spellbook">The spellbook.</param>
/// <param name="args">The <see cref="SpellbookStopCastEventArgs" /> instance containing the event data.</param>
private static void SpellbookOnStopCast(Spellbook spellbook, SpellbookStopCastEventArgs args)
{
if (spellbook.Owner.IsValid && spellbook.Owner.IsMe && args.DestroyMissile && args.StopAnimation)
{
ResetAutoAttackTimer();
}
}
#endregion
/// <summary>
/// The before attack event arguments.
/// </summary>
public class BeforeAttackEventArgs : EventArgs
{
#region Fields
/// <summary>
/// The target
/// </summary>
public AttackableUnit Target;
/// <summary>
/// The unit
/// </summary>
public Obj_AI_Base Unit = ObjectManager.Player;
/// <summary>
/// <c>true</c> if the orbwalker should continue with the attack.
/// </summary>
private bool _process = true;
#endregion
#region Public Properties
/// <summary>
/// Gets or sets a value indicating whether this <see cref="BeforeAttackEventArgs" /> should continue with the attack.
/// </summary>
/// <value><c>true</c> if the orbwalker should continue with the attack; otherwise, <c>false</c>.</value>
public bool Process
{
get
{
return this._process;
}
set
{
DisableNextAttack = !value;
this._process = value;
}
}
#endregion
}
/// <summary>
/// This class allows you to add an instance of "Orbwalker" to your assembly in order to control the orbwalking in an
/// easy way.
/// </summary>
public class Orbwalker : IDisposable
{
#region Constants
/// <summary>
/// The lane clear wait time modifier.
/// </summary>
private const float LaneClearWaitTimeMod = 2f;
#endregion
#region Static Fields
/// <summary>
/// The instances of the orbwalker.
/// </summary>
public static List<Orbwalker> Instances = new List<Orbwalker>();
/// <summary>
/// The configuration
/// </summary>
private static Menu _config;
#endregion
#region Fields
/// <summary>
/// The player
/// </summary>
private readonly Obj_AI_Hero Player;
/// <summary>
/// The forced target
/// </summary>
private Obj_AI_Base _forcedTarget;
/// <summary>
/// The orbalker mode
/// </summary>
private OrbwalkingMode _mode = OrbwalkingMode.None;
/// <summary>
/// The orbwalking point
/// </summary>
private Vector3 _orbwalkingPoint;
/// <summary>
/// The previous minion the orbwalker was targeting.
/// </summary>
private Obj_AI_Minion _prevMinion;
/// <summary>
/// The name of the CustomMode if it is set.
/// </summary>
private string CustomModeName;
#endregion
#region Constructors and Destructors
/// <summary>
/// Initializes a new instance of the <see cref="Orbwalker" /> class.
/// </summary>
/// <param name="attachToMenu">The menu the orbwalker should attach to.</param>
public Orbwalker(Menu attachToMenu)
{
_config = attachToMenu;
/* Drawings submenu */
var drawings = new Menu("Drawings", "drawings");
drawings.AddItem(
new MenuItem("AACircle", "AACircle").SetShared()
.SetValue(new Circle(true, Color.FromArgb(155, 255, 255, 0))));
drawings.AddItem(
new MenuItem("AACircle2", "Enemy AA circle").SetShared()
.SetValue(new Circle(false, Color.FromArgb(155, 255, 255, 0))));
drawings.AddItem(
new MenuItem("HoldZone", "HoldZone").SetShared()
.SetValue(new Circle(false, Color.FromArgb(155, 255, 255, 0))));
drawings.AddItem(new MenuItem("AALineWidth", "Line Width")).SetShared().SetValue(new Slider(2, 1, 6));
drawings.AddItem(new MenuItem("LastHitHelper", "Last Hit Helper").SetShared().SetValue(false));
_config.AddSubMenu(drawings);
/* Misc options */
var misc = new Menu("Misc", "Misc");
misc.AddItem(
new MenuItem("HoldPosRadius", "Hold Position Radius").SetShared().SetValue(new Slider(50, 50, 250)));
misc.AddItem(new MenuItem("PriorizeFarm", "Prioritize farm over harass").SetShared().SetValue(true));
misc.AddItem(new MenuItem("PrioritizeCasters", "Attack caster minions first").SetShared().SetValue(false));
misc.AddItem(new MenuItem("AttackWards", "Auto attack wards").SetShared().SetValue(false));
misc.AddItem(new MenuItem("AttackPetsnTraps", "Auto attack pets & traps").SetShared().SetValue(true));
misc.AddItem(
new MenuItem("AttackGPBarrel", "Auto attack gangplank barrel").SetShared()
.SetValue(new StringList(new[] { "Combo and Farming", "Farming", "No" }, 1)));
misc.AddItem(new MenuItem("Smallminionsprio", "Jungle clear small first").SetShared().SetValue(false));
misc.AddItem(
new MenuItem("FocusMinionsOverTurrets", "Focus minions over objectives").SetShared()
.SetValue(new KeyBind('M', KeyBindType.Toggle)));
_config.AddSubMenu(misc);
/* Missile check */
_config.AddItem(new MenuItem("MissileCheck", "Use Missile Check").SetShared().SetValue(true));
/* Delay sliders */
_config.AddItem(
new MenuItem("ExtraWindup", "Extra windup time").SetShared().SetValue(new Slider(80, 0, 200)));
_config.AddItem(new MenuItem("FarmDelay", "Farm delay").SetShared().SetValue(new Slider(0, 0, 200)));
/*Load the menu*/
_config.AddItem(
new MenuItem("LastHit", "Last hit").SetShared().SetValue(new KeyBind('X', KeyBindType.Press)));
_config.AddItem(new MenuItem("Farm", "Mixed").SetShared().SetValue(new KeyBind('C', KeyBindType.Press)));
_config.AddItem(
new MenuItem("Freeze", "Freeze").SetShared().SetValue(new KeyBind('N', KeyBindType.Press)));
_config.AddItem(
new MenuItem("LaneClear", "LaneClear").SetShared().SetValue(new KeyBind('V', KeyBindType.Press)));
_config.AddItem(
new MenuItem("Orbwalk", "Combo").SetShared().SetValue(new KeyBind(32, KeyBindType.Press)));
_config.AddItem(
new MenuItem("StillCombo", "Combo without moving").SetShared()
.SetValue(new KeyBind('N', KeyBindType.Press)));
_config.Item("StillCombo").ValueChanged +=
(sender, args) => { Move = !args.GetNewValue<KeyBind>().Active; };
this.Player = ObjectManager.Player;
Game.OnUpdate += this.GameOnOnGameUpdate;
Drawing.OnDraw += this.DrawingOnOnDraw;
Instances.Add(this);
}
#endregion