-
Notifications
You must be signed in to change notification settings - Fork 244
/
CustomizableAntiGapcloser.cs
776 lines (601 loc) · 23.8 KB
/
CustomizableAntiGapcloser.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
namespace LeagueSharp.Common
{
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using SharpDX;
/// <summary>
/// The delegate for the <see cref="CustomizableAntiGapcloser.OnEnemyCustomGapcloser" /> event.
/// </summary>
/// <param name="cGapcloser">The CGapcloser.</param>
public delegate void OnAGapcloseH(CActiveCGapcloser cGapcloser);
/// <summary>
/// The type of Customizable AntiGapcloser.
/// </summary>
public enum CGapcloserTypes
{
/// <summary>
/// The Customizable AntiGapcloser used a skillshot ability.
/// </summary>
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly",
Justification = "Reviewed. Suppression is OK here.")]
Skillshot,
/// <summary>
/// The Customizable AntiGapcloser used a targeted ability.
/// </summary>
Targeted
}
/// <summary>
/// Represents a Customizable AntiGapcloser.
/// </summary>
public struct CGapcloser
{
#region Fields
/// <summary>
/// The champion name
/// </summary>
public string ChampionName;
/// <summary>
/// The danger level
/// </summary>
public int DangerLevel;
/// <summary>
/// The skill type
/// </summary>
public CGapcloserTypes SkillType;
/// <summary>
/// The slot
/// </summary>
public SpellSlot Slot;
/// <summary>
/// The spell name
/// </summary>
public string SpellName;
#endregion
}
/// <summary>
/// Represents an active Customizable AntiGapcloser.
/// </summary>
public struct CActiveCGapcloser
{
#region Fields
/// <summary>
/// The end
/// </summary>
public Vector3 End;
/// <summary>
/// The sender
/// </summary>
public Obj_AI_Hero Sender;
/// <summary>
/// The skill type
/// </summary>
public CGapcloserTypes SkillType;
/// <summary>
/// The slot
/// </summary>
public SpellSlot Slot;
/// <summary>
/// The spell name
/// </summary>
public string SpellName;
/// <summary>
/// The start
/// </summary>
public Vector3 Start;
/// <summary>
/// The tick count
/// </summary>
public int TickCount;
#endregion
}
/// <summary>
/// Provides events and information about Customizable AntiGapcloser.
/// </summary>
public static class CustomizableAntiGapcloser
{
#region Static Fields
/// <summary>
/// The active Gapclosers
/// </summary>
public static List<CActiveCGapcloser> CActiveCGapclosers = new List<CActiveCGapcloser>();
/// <summary>
/// The customizable anti gapcloser menu
/// </summary>
public static Menu CustomizableCustomizableAntiGapcloserMenu;
/// <summary>
/// The Gapcloser spells
/// </summary>
public static List<CGapcloser> Spells = new List<CGapcloser>();
#endregion
#region Constructors and Destructors
/// <summary>
/// Initializes static members of the <see cref="CustomizableAntiGapcloser" /> class.
/// </summary>
static CustomizableAntiGapcloser()
{
#region Aatrox
Spells.Add(
new CGapcloser
{
ChampionName = "Aatrox", Slot = SpellSlot.Q, SpellName = "aatroxq",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 1
});
#endregion
#region Akali
Spells.Add(
new CGapcloser
{
ChampionName = "Akali", Slot = SpellSlot.R, SpellName = "akalishadowdance",
SkillType = CGapcloserTypes.Targeted, DangerLevel = 5,
});
#endregion
#region Alistar
Spells.Add(
new CGapcloser
{
ChampionName = "Alistar", Slot = SpellSlot.W, SpellName = "headbutt",
SkillType = CGapcloserTypes.Targeted, DangerLevel = 5,
});
#endregion
#region Corki
Spells.Add(
new CGapcloser
{
ChampionName = "Corki", Slot = SpellSlot.W, SpellName = "carpetbomb",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 1,
});
#endregion
#region Diana
Spells.Add(
new CGapcloser
{
ChampionName = "Diana", Slot = SpellSlot.R, SpellName = "dianateleport",
SkillType = CGapcloserTypes.Targeted, DangerLevel = 4,
});
#endregion
#region Ekko
Spells.Add(
new CGapcloser
{
ChampionName = "Ekko", Slot = SpellSlot.E, SpellName = "ekkoe",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 4,
});
Spells.Add(
new CGapcloser
{
ChampionName = "Ekko", Slot = SpellSlot.E, SpellName = "ekkoeattack",
SkillType = CGapcloserTypes.Targeted, DangerLevel = 4,
});
#endregion
#region Elise
Spells.Add(
new CGapcloser
{
ChampionName = "Elise", Slot = SpellSlot.Q, SpellName = "elisespiderqcast",
SkillType = CGapcloserTypes.Skillshot
});
Spells.Add(
new CGapcloser
{
ChampionName = "Elise", Slot = SpellSlot.Q, SpellName = "elisespiderqcast",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 1,
});
#endregion
#region Fiora
Spells.Add(
new CGapcloser
{
ChampionName = "Fiora", Slot = SpellSlot.Q, SpellName = "fioraq",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 1,
});
#endregion
#region Fizz
Spells.Add(
new CGapcloser
{
ChampionName = "Fizz", Slot = SpellSlot.Q, SpellName = "fizzpiercingstrike",
SkillType = CGapcloserTypes.Targeted, DangerLevel = 3,
});
#endregion
#region Gnar
Spells.Add(
new CGapcloser
{
ChampionName = "Gnar", Slot = SpellSlot.E, SpellName = "gnarbige",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 1,
});
Spells.Add(
new CGapcloser
{
ChampionName = "Gnar", Slot = SpellSlot.E, SpellName = "gnare",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 1,
});
#endregion
#region Gragas
Spells.Add(
new CGapcloser
{
ChampionName = "Gragas", Slot = SpellSlot.E, SpellName = "gragase",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 2,
});
#endregion
#region Graves
Spells.Add(
new CGapcloser
{
ChampionName = "Graves", Slot = SpellSlot.E, SpellName = "gravesmove",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 4,
});
#endregion
#region Hecarim
Spells.Add(
new CGapcloser
{
ChampionName = "Hecarim", Slot = SpellSlot.R, SpellName = "hecarimult",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 5,
});
#endregion
#region Illaoi
Spells.Add(
new CGapcloser
{
ChampionName = "Illaoi", Slot = SpellSlot.W, SpellName = "illaoiwattack",
SkillType = CGapcloserTypes.Targeted, DangerLevel = 3,
});
#endregion
#region Irelia
Spells.Add(
new CGapcloser
{
ChampionName = "Irelia", Slot = SpellSlot.Q, SpellName = "ireliagatotsu",
SkillType = CGapcloserTypes.Targeted, DangerLevel = 5,
});
#endregion
#region JarvanIV
Spells.Add(
new CGapcloser
{
ChampionName = "JarvanIV", Slot = SpellSlot.Q, SpellName = "jarvanivdragonstrike",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 2,
});
#endregion
#region Jax
Spells.Add(
new CGapcloser
{
ChampionName = "Jax", Slot = SpellSlot.Q, SpellName = "jaxleapstrike",
SkillType = CGapcloserTypes.Targeted, DangerLevel = 5,
});
#endregion
#region Jayce
Spells.Add(
new CGapcloser
{
ChampionName = "Jayce", Slot = SpellSlot.Q, SpellName = "jaycetotheskies",
SkillType = CGapcloserTypes.Targeted, DangerLevel = 3,
});
#endregion
#region Kassadin
Spells.Add(
new CGapcloser
{
ChampionName = "Kassadin", Slot = SpellSlot.R, SpellName = "riftwalk",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 4
});
#endregion
#region Khazix
Spells.Add(
new CGapcloser
{
ChampionName = "Khazix", Slot = SpellSlot.E, SpellName = "khazixe",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 3,
});
Spells.Add(
new CGapcloser
{
ChampionName = "Khazix", Slot = SpellSlot.E, SpellName = "khazixelong",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 3,
});
#endregion
#region Leblanc
Spells.Add(
new CGapcloser
{
ChampionName = "Leblanc", Slot = SpellSlot.W, SpellName = "leblancslide",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 5,
});
Spells.Add(
new CGapcloser
{
ChampionName = "Leblanc", Slot = SpellSlot.R, SpellName = "leblancslidem",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 5,
});
#endregion
#region LeeSin
Spells.Add(
new CGapcloser
{
ChampionName = "LeeSin", Slot = SpellSlot.Q, SpellName = "blindmonkqtwo",
SkillType = CGapcloserTypes.Targeted, DangerLevel = 3,
});
#endregion
#region Leona
Spells.Add(
new CGapcloser
{
ChampionName = "Leona", Slot = SpellSlot.E, SpellName = "leonazenithblade",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 5
});
#endregion
#region Lucian
Spells.Add(
new CGapcloser
{
ChampionName = "Lucian", Slot = SpellSlot.E, SpellName = "luciane",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 4,
});
#endregion
#region Malphite
Spells.Add(
new CGapcloser
{
ChampionName = "Malphite", Slot = SpellSlot.R, SpellName = "ufslash",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 5
});
#endregion
#region MasterYi
Spells.Add(
new CGapcloser
{
ChampionName = "MasterYi", Slot = SpellSlot.Q, SpellName = "alphastrike",
SkillType = CGapcloserTypes.Targeted, DangerLevel = 4
});
#endregion
#region MonkeyKing
Spells.Add(
new CGapcloser
{
ChampionName = "MonkeyKing", Slot = SpellSlot.E, SpellName = "monkeykingnimbus",
SkillType = CGapcloserTypes.Targeted, DangerLevel = 4
});
#endregion
#region Pantheon
Spells.Add(
new CGapcloser
{
ChampionName = "Pantheon", Slot = SpellSlot.W, SpellName = "pantheon_leapbash",
SkillType = CGapcloserTypes.Targeted, DangerLevel = 5
});
Spells.Add(
new CGapcloser
{
ChampionName = "Pantheon", Slot = SpellSlot.R, SpellName = "pantheonrjump",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 4
});
Spells.Add(
new CGapcloser
{
ChampionName = "Pantheon", Slot = SpellSlot.R, SpellName = "pantheonrfall",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 4
});
#endregion
#region Poppy
Spells.Add(
new CGapcloser
{
ChampionName = "Poppy", Slot = SpellSlot.E, SpellName = "poppyheroiccharge",
SkillType = CGapcloserTypes.Targeted, DangerLevel = 4
});
#endregion
#region Renekton
Spells.Add(
new CGapcloser
{
ChampionName = "Renekton", Slot = SpellSlot.E, SpellName = "renektonsliceanddice",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 4,
});
#endregion
#region Riven
Spells.Add(
new CGapcloser
{
ChampionName = "Riven", Slot = SpellSlot.Q, SpellName = "riventricleave",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 4,
});
Spells.Add(
new CGapcloser
{
ChampionName = "Riven", Slot = SpellSlot.E, SpellName = "rivenfeint",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 4,
});
#endregion
#region Sejuani
Spells.Add(
new CGapcloser
{
ChampionName = "Sejuani", Slot = SpellSlot.Q, SpellName = "sejuaniarcticassault",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 4,
});
#endregion
#region Shen
Spells.Add(
new CGapcloser
{
ChampionName = "Shen", Slot = SpellSlot.E, SpellName = "shenshadowdash",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 5,
});
#endregion
#region Shyvana
Spells.Add(
new CGapcloser
{
ChampionName = "Shyvana", Slot = SpellSlot.R, SpellName = "shyvanatransformcast",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 5,
});
#endregion
#region Talon
Spells.Add(
new CGapcloser
{
ChampionName = "Talon", Slot = SpellSlot.E, SpellName = "taloncutthroat",
SkillType = CGapcloserTypes.Targeted, DangerLevel = 4
});
#endregion
#region Tristana
Spells.Add(
new CGapcloser
{
ChampionName = "Tristana", Slot = SpellSlot.W, SpellName = "rocketjump",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 4,
});
#endregion
#region Tryndamere
Spells.Add(
new CGapcloser
{
ChampionName = "Tryndamere", Slot = SpellSlot.E, SpellName = "slashcast",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 2,
});
#endregion
#region Vi
Spells.Add(
new CGapcloser
{
ChampionName = "Vi", Slot = SpellSlot.Q, SpellName = "ViQ", SkillType = CGapcloserTypes.Skillshot,
DangerLevel = 5,
});
#endregion
#region XinZhao
Spells.Add(
new CGapcloser
{
ChampionName = "XinZhao", Slot = SpellSlot.E, SpellName = "xenzhaosweep",
SkillType = CGapcloserTypes.Targeted, DangerLevel = 4,
});
#endregion
#region Yasuo
Spells.Add(
new CGapcloser
{
ChampionName = "Yasuo", Slot = SpellSlot.E, SpellName = "yasuodashwrapper",
SkillType = CGapcloserTypes.Targeted, DangerLevel = 4,
});
#endregion
#region Zac
Spells.Add(
new CGapcloser
{
ChampionName = "Zac", Slot = SpellSlot.E, SpellName = "zace",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 3,
});
#endregion
#region Ziggs
Spells.Add(
new CGapcloser
{
ChampionName = "Ziggs", Slot = SpellSlot.W, SpellName = "ziggswtoggle",
SkillType = CGapcloserTypes.Skillshot, DangerLevel = 4,
});
#endregion
Game.OnUpdate += Game_OnGameUpdate;
Obj_AI_Base.OnProcessSpellCast += Obj_AI_Base_OnProcessSpellCast;
}
#endregion
#region Public Events
/// <summary>
/// Occurs on an incoming enemy Customizable AntiGapcloser.
/// </summary>
public static event OnAGapcloseH OnEnemyCustomGapcloser;
#endregion
#region Public Methods and Operators
/// <summary>
/// Customizable menu of the Anti Gapcloser
/// </summary>
/// <param name="mainmenu"></param>
public static void AddToMenu(Menu mainmenu)
{
CustomizableCustomizableAntiGapcloserMenu = mainmenu;
foreach (
var gapclose in
Spells.Where(
x => ObjectManager.Get<Obj_AI_Hero>().Any(y => y.ChampionName == x.ChampionName && y.IsEnemy)))
{
mainmenu.AddItem(
new MenuItem(
"gapclose." + gapclose.ChampionName,
"Anti-Gapclose: " + gapclose.ChampionName + " - Spell: " + gapclose.Slot).SetValue(true));
mainmenu.AddItem(
new MenuItem(
"gapclose.slider." + gapclose.SpellName,
"" + gapclose.ChampionName + " " + "(" + gapclose.Slot + ") Priority").SetValue(
new Slider(gapclose.DangerLevel, 1, 5)));
}
}
#endregion
#region Methods
/// <summary>
/// Fired when the game updates.
/// </summary>
/// <param name="args">The <see cref="EventArgs" /> instance containing the event data.</param>
private static void Game_OnGameUpdate(EventArgs args)
{
CActiveCGapclosers.RemoveAll(entry => Utils.TickCount > entry.TickCount + 900);
if (OnEnemyCustomGapcloser == null)
{
return;
}
foreach (var cGapcloser in
CActiveCGapclosers.Where(cGapcloser => cGapcloser.Sender.IsValidTarget())
.Where(
cGapcloser =>
cGapcloser.SkillType == CGapcloserTypes.Targeted
|| (cGapcloser.SkillType == CGapcloserTypes.Skillshot
&& ObjectManager.Player.Distance(cGapcloser.Sender, true) < 250000) // 500 * 500
&& CustomizableCustomizableAntiGapcloserMenu.Item("gapclose." + cGapcloser.Sender.ChampionName)
.GetValue<bool>())
.OrderByDescending(
c =>
CustomizableCustomizableAntiGapcloserMenu.Item("gapclose.slider." + c.SpellName)
.GetValue<Slider>()
.Value))
{
OnEnemyCustomGapcloser(cGapcloser);
}
}
/// <summary>
/// Fired when the game processes a spell cast.
/// </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_OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args)
{
if (!SpellIsCGapcloser(args))
{
return;
}
CActiveCGapclosers.Add(
new CActiveCGapcloser
{
Start = args.Start, End = args.End, Sender = (Obj_AI_Hero)sender, TickCount = Utils.TickCount,
SkillType =
(args.Target != null && args.Target.IsMe)
? CGapcloserTypes.Targeted
: CGapcloserTypes.Skillshot,
Slot = ((Obj_AI_Hero)sender).GetSpellSlot(args.SData.Name),
SpellName = args.SData.Name
});
}
/// <summary>
/// Checks if a spell is a Customizable AntiGapcloser.
/// </summary>
/// <param name="args">The <see cref="GameObjectProcessSpellCastEventArgs" /> instance containing the event data.</param>
/// <returns></returns>
private static bool SpellIsCGapcloser(GameObjectProcessSpellCastEventArgs args)
{
return Spells.Any(spell => spell.SpellName == args.SData.Name.ToLower());
}
#endregion
}
}