-
Notifications
You must be signed in to change notification settings - Fork 11
/
Trackers.cs
3637 lines (3419 loc) · 176 KB
/
Trackers.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
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using LeagueSharp;
using LeagueSharp.Common;
using SAwareness.Spectator;
using SharpDX;
using SharpDX.Direct3D9;
using Color = System.Drawing.Color;
using Font = SharpDX.Direct3D9.Font;
using Packet = LeagueSharp.Common.Packet;
namespace SAwareness
{
internal class CloneTracker
{
public CloneTracker()
{
Drawing.OnDraw += Drawing_OnDraw;
}
~CloneTracker()
{
Drawing.OnDraw -= Drawing_OnDraw;
}
public bool IsActive()
{
return Menu.Tracker.GetActive() && Menu.CloneTracker.GetActive();
}
private void Drawing_OnDraw(EventArgs args)
{
if (!IsActive())
return;
foreach (Obj_AI_Hero hero in ObjectManager.Get<Obj_AI_Hero>())
{
if (hero.IsEnemy && !hero.IsDead && hero.IsVisible)
{
if (hero.ChampionName.Contains("Shaco") ||
hero.ChampionName.Contains("Leblanc") ||
hero.ChampionName.Contains("MonkeyKing") ||
hero.ChampionName.Contains("Yorick"))
{
Utility.DrawCircle(hero.ServerPosition, 100, Color.Red);
Utility.DrawCircle(hero.ServerPosition, 110, Color.Red);
}
}
}
}
}
internal class HiddenObject
{
public enum ObjectType
{
Vision,
Sight,
Trap,
Unknown
}
private const int WardRange = 1200;
private const int TrapRange = 300;
public List<ObjectData> HidObjects = new List<ObjectData>();
public List<Object> Objects = new List<Object>();
public HiddenObject()
{
Objects.Add(new Object(ObjectType.Vision, "Vision Ward", "VisionWard", "VisionWard", float.MaxValue, 8,
6424612, Color.BlueViolet));
Objects.Add(new Object(ObjectType.Sight, "Stealth Ward", "SightWard", "SightWard", 180.0f, 161, 234594676,
Color.Green));
Objects.Add(new Object(ObjectType.Sight, "Warding Totem (Trinket)", "YellowTrinket", "TrinketTotemLvl1", 60.0f,
56, 263796881, Color.Green));
Objects.Add(new Object(ObjectType.Sight, "Warding Totem (Trinket)", "YellowTrinketUpgrade", "TrinketTotemLvl2", 120.0f,
56, 263796882, Color.Green));
Objects.Add(new Object(ObjectType.Sight, "Greater Stealth Totem (Trinket)", "SightWard", "TrinketTotemLvl3",
180.0f, 56, 263796882, Color.Green));
Objects.Add(new Object(ObjectType.Sight, "Greater Vision Totem (Trinket)", "VisionWard", "TrinketTotemLvl3B",
9999.9f, 137, 194218338, Color.BlueViolet));
Objects.Add(new Object(ObjectType.Sight, "Wriggle's Lantern", "SightWard", "wrigglelantern", 180.0f, 73,
177752558, Color.Green));
Objects.Add(new Object(ObjectType.Sight, "Quill Coat", "SightWard", "", 180.0f, 73, 135609454, Color.Green));
Objects.Add(new Object(ObjectType.Sight, "Ghost Ward", "SightWard", "ItemGhostWard", 180.0f, 229, 101180708,
Color.Green));
Objects.Add(new Object(ObjectType.Trap, "Yordle Snap Trap", "Cupcake Trap", "CaitlynYordleTrap", 240.0f, 62,
176176816, Color.Red));
Objects.Add(new Object(ObjectType.Trap, "Jack In The Box", "Jack In The Box", "JackInTheBox", 60.0f, 2,
44637032, Color.Red));
Objects.Add(new Object(ObjectType.Trap, "Bushwhack", "Noxious Trap", "Bushwhack", 240.0f, 9, 167611995,
Color.Red));
Objects.Add(new Object(ObjectType.Trap, "Noxious Trap", "Noxious Trap", "BantamTrap", 600.0f, 48, 176304336,
Color.Red));
Game.OnGameProcessPacket += Game_OnGameProcessPacket;
Obj_AI_Base.OnProcessSpellCast += Obj_AI_Base_OnProcessSpellCast;
GameObject.OnDelete += Obj_AI_Base_OnDelete;
Drawing.OnDraw += Drawing_OnDraw;
GameObject.OnCreate += GameObject_OnCreate;
Game.OnGameUpdate += Game_OnGameUpdate;
foreach (var obj in ObjectManager.Get<GameObject>())
{
GameObject_OnCreate(obj, new EventArgs());
}
}
void Game_OnGameUpdate(EventArgs args)
{
if (!IsActive())
return;
List<ObjectData> objects = HidObjects.FindAll(x => x.ObjectBase.Name == "Unknown");
foreach (var obj1 in HidObjects.ToArray())
{
if(obj1.ObjectBase.Name.Contains("Unknown"))
continue;
foreach (var obj2 in objects)
{
if (Geometry.ProjectOn(obj1.EndPosition.To2D(), obj2.StartPosition.To2D(), obj2.EndPosition.To2D()).IsOnSegment)
{
HidObjects.Remove(obj2);
}
}
}
}
~HiddenObject()
{
Game.OnGameProcessPacket -= Game_OnGameProcessPacket;
Obj_AI_Base.OnProcessSpellCast -= Obj_AI_Base_OnProcessSpellCast;
GameObject.OnCreate -= GameObject_OnCreate;
GameObject.OnDelete -= Obj_AI_Base_OnDelete;
Drawing.OnDraw -= Drawing_OnDraw;
}
public bool IsActive()
{
return Menu.Tracker.GetActive() && Menu.VisionDetector.GetActive();
}
private void GameObject_OnCreate(GameObject sender, EventArgs args)
{
if (!IsActive())
return;
try
{
if(!sender.IsValid)
return;
if (sender is Obj_AI_Base && ObjectManager.Player.Team != sender.Team)
{
foreach (Object obj in Objects)
{
if (((Obj_AI_Base)sender).BaseSkinName == obj.ObjectName && !ObjectExist(sender.Position))
{
HidObjects.Add(new ObjectData(obj, sender.Position, Game.Time + ((Obj_AI_Base)sender).Mana, sender.Name,
null, sender.NetworkId));
break;
}
}
}
if (sender is Obj_SpellLineMissile && ObjectManager.Player.Team != ((Obj_SpellMissile)sender).SpellCaster.Team)
{
if (((Obj_SpellMissile)sender).SData.Name.Contains("itemplacementmissile"))
{
Utility.DelayAction.Add(10, () =>
{
if (!ObjectExist(((Obj_SpellMissile)sender).EndPosition))
{
HidObjects.Add(new ObjectData(new Object(ObjectType.Unknown, "Unknown", "Unknown", "Unknown", 180.0f, 0, 0, Color.Yellow), ((Obj_SpellMissile)sender).EndPosition, Game.Time + 180.0f, sender.Name, null,
sender.NetworkId, ((Obj_SpellMissile)sender).StartPosition));
}
});
}
}
}
catch (Exception ex)
{
Console.WriteLine("HiddenObjectCreate: " + ex);
}
}
private void Drawing_OnDraw(EventArgs args)
{
if (!IsActive())
return;
try
{
for (int i = 0; i < HidObjects.Count; i++)
{
ObjectData obj = HidObjects[i];
if (Game.Time > obj.EndTime)
{
HidObjects.RemoveAt(i);
break;
}
Vector2 objMPos = Drawing.WorldToMinimap(obj.EndPosition);
Vector2 objPos = Drawing.WorldToScreen(obj.EndPosition);
var posList = new List<Vector3>();
switch (obj.ObjectBase.Type)
{
case ObjectType.Sight:
if (Menu.VisionDetector.GetMenuItem("SAwarenessVisionDetectorDrawRange").GetValue<bool>())
{
Utility.DrawCircle(obj.EndPosition, WardRange, obj.ObjectBase.Color);
}
posList = GetVision(obj.EndPosition, WardRange);
for (int j = 0; j < posList.Count; j++)
{
Vector2 visionPos1 = Drawing.WorldToScreen(posList[i]);
Vector2 visionPos2 = Drawing.WorldToScreen(posList[i]);
Drawing.DrawLine(visionPos1[0], visionPos1[1], visionPos2[0], visionPos2[1], 1.0f,
obj.ObjectBase.Color);
}
Drawing.DrawText(objMPos[0], objMPos[1], obj.ObjectBase.Color, "S");
break;
case ObjectType.Trap:
if (Menu.VisionDetector.GetMenuItem("SAwarenessVisionDetectorDrawRange").GetValue<bool>())
{
Utility.DrawCircle(obj.EndPosition, TrapRange, obj.ObjectBase.Color);
}
posList = GetVision(obj.EndPosition, TrapRange);
for (int j = 0; j < posList.Count; j++)
{
Vector2 visionPos1 = Drawing.WorldToScreen(posList[i]);
Vector2 visionPos2 = Drawing.WorldToScreen(posList[i]);
Drawing.DrawLine(visionPos1[0], visionPos1[1], visionPos2[0], visionPos2[1], 1.0f,
obj.ObjectBase.Color);
}
Drawing.DrawText(objMPos[0], objMPos[1], obj.ObjectBase.Color, "T");
break;
case ObjectType.Vision:
if (Menu.VisionDetector.GetMenuItem("SAwarenessVisionDetectorDrawRange").GetValue<bool>())
{
Utility.DrawCircle(obj.EndPosition, WardRange, obj.ObjectBase.Color);
}
posList = GetVision(obj.EndPosition, WardRange);
for (int j = 0; j < posList.Count; j++)
{
Vector2 visionPos1 = Drawing.WorldToScreen(posList[i]);
Vector2 visionPos2 = Drawing.WorldToScreen(posList[i]);
Drawing.DrawLine(visionPos1[0], visionPos1[1], visionPos2[0], visionPos2[1], 1.0f,
obj.ObjectBase.Color);
}
Drawing.DrawText(objMPos[0], objMPos[1], obj.ObjectBase.Color, "V");
break;
case ObjectType.Unknown:
Drawing.DrawLine(Drawing.WorldToScreen(obj.StartPosition), Drawing.WorldToScreen(obj.EndPosition), 1, obj.ObjectBase.Color);
break;
}
Utility.DrawCircle(obj.EndPosition, 50, obj.ObjectBase.Color);
float endTime = obj.EndTime - Game.Time;
if (!float.IsInfinity(endTime) && !float.IsNaN(endTime) && endTime.CompareTo(float.MaxValue) != 0)
{
var m = (float) Math.Floor(endTime/60);
var s = (float) Math.Ceiling(endTime%60);
String ms = (s < 10 ? m + ":0" + s : m + ":" + s);
Drawing.DrawText(objPos[0], objPos[1], obj.ObjectBase.Color, ms);
}
}
}
catch (Exception ex)
{
Console.WriteLine("HiddenObjectDraw: " + ex);
}
}
private List<Vector3> GetVision(Vector3 viewPos, float range) //TODO: ADD IT
{
var list = new List<Vector3>();
//double qual = 2*Math.PI/25;
//for (double i = 0; i < 2*Math.PI + qual;)
//{
// Vector3 pos = new Vector3(viewPos.X + range * (float)Math.Cos(i), viewPos.Y - range * (float)Math.Sin(i), viewPos.Z);
// for (int j = 1; j < range; j = j + 25)
// {
// Vector3 nPos = new Vector3(viewPos.X + j * (float)Math.Cos(i), viewPos.Y - j * (float)Math.Sin(i), viewPos.Z);
// if (NavMesh.GetCollisionFlags(nPos).HasFlag(CollisionFlags.Wall))
// {
// pos = nPos;
// break;
// }
// }
// list.Add(pos);
// i = i + 0.1;
//}
return list;
}
private Object HiddenObjectById(int id)
{
return Objects.FirstOrDefault(vision => id == vision.Id2);
}
private bool ObjectExist(Vector3 pos)
{
return HidObjects.Any(obj => pos.Distance(obj.EndPosition) < 30);
}
private void Game_OnGameProcessPacket(GamePacketEventArgs args)
{
if (!IsActive())
return;
try
{
var reader = new BinaryReader(new MemoryStream(args.PacketData));
byte packetId = reader.ReadByte(); //PacketId
if (packetId == 181) //OLD 180
{
int networkId = BitConverter.ToInt32(reader.ReadBytes(4), 0);
var creator = ObjectManager.GetUnitByNetworkId<Obj_AI_Base>(networkId);
if (creator != null && creator.Team != ObjectManager.Player.Team)
{
reader.ReadBytes(7);
int id = reader.ReadInt32();
reader.ReadBytes(21);
networkId = BitConverter.ToInt32(reader.ReadBytes(4), 0);
reader.ReadBytes(12);
float x = BitConverter.ToSingle(reader.ReadBytes(4), 0);
float y = BitConverter.ToSingle(reader.ReadBytes(4), 0);
float z = BitConverter.ToSingle(reader.ReadBytes(4), 0);
var pos = new Vector3(x, y, z);
Object obj = HiddenObjectById(id);
if (obj != null && !ObjectExist(pos))
{
if (obj.Type == ObjectType.Trap)
pos = new Vector3(x, z, y);
networkId = networkId + 2;
Utility.DelayAction.Add(1, () =>
{
for (int i = 0; i < HidObjects.Count; i++)
{
ObjectData objectData = HidObjects[i];
if (objectData != null && objectData.NetworkId == networkId)
{
var objNew = ObjectManager.GetUnitByNetworkId<Obj_AI_Base>(networkId);
if (objNew != null && objNew.IsValid)
objectData.EndPosition = objNew.Position;
}
}
});
HidObjects.Add(new ObjectData(obj, pos, Game.Time + obj.Duration, creator.Name, null,
networkId));
}
}
}
else if (packetId == 178)
{
int networkId = BitConverter.ToInt32(reader.ReadBytes(4), 0);
var gObject = ObjectManager.GetUnitByNetworkId<GameObject>(networkId);
if (gObject != null)
{
for (int i = 0; i < HidObjects.Count; i++)
{
ObjectData objectData = HidObjects[i];
if (objectData != null && objectData.NetworkId == networkId)
{
objectData.EndPosition = gObject.Position;
}
}
}
}
else if (packetId == 50) //OLD 49
{
int networkId = BitConverter.ToInt32(reader.ReadBytes(4), 0);
for (int i = 0; i < HidObjects.Count; i++)
{
ObjectData objectData = HidObjects[i];
var gObject = ObjectManager.GetUnitByNetworkId<GameObject>(networkId);
if (objectData != null && objectData.NetworkId == networkId)
{
HidObjects.RemoveAt(i);
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("HiddenObjectProcess: " + ex);
}
}
private void Obj_AI_Base_OnDelete(GameObject sender, EventArgs args)
{
if (!IsActive())
return;
try
{
if (!sender.IsValid)
return;
for (int i = 0; i < HidObjects.Count; i++)
{
ObjectData obj = HidObjects[i];
if ((obj.ObjectBase != null && sender.Name == obj.ObjectBase.ObjectName) ||
sender.Name.Contains("Ward") && sender.Name.Contains("Death"))
if (sender.Position.Distance(obj.EndPosition) < 30 || sender.Position.Distance(obj.StartPosition) < 30)
{
HidObjects.RemoveAt(i);
}
}
}
catch (Exception ex)
{
Console.WriteLine("HiddenObjectDelete: " + ex);
}
}
private void Obj_AI_Base_OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args)
{
if (!IsActive())
return;
try
{
if (!sender.IsValid)
return;
if (ObjectManager.Player.Team != sender.Team)
{
foreach (Object obj in Objects)
{
if (args.SData.Name == obj.SpellName && !ObjectExist(args.End))
{
HidObjects.Add(new ObjectData(obj, args.End, Game.Time + obj.Duration, sender.Name, null,
sender.NetworkId));
break;
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("HiddenObjectSpell: " + ex);
}
}
public class Object
{
public Color Color;
public float Duration;
public int Id;
public int Id2;
public String Name;
public String ObjectName;
public String SpellName;
public ObjectType Type;
public Object(ObjectType type, String name, String objectName, String spellName, float duration, int id,
int id2, Color color)
{
Type = type;
Name = name;
ObjectName = objectName;
SpellName = spellName;
Duration = duration;
Id = id;
Id2 = id2;
Color = color;
}
}
public class ObjectData
{
public String Creator;
public float EndTime;
public int NetworkId;
public Object ObjectBase;
public List<Vector2> Points;
public Vector3 EndPosition;
public Vector3 StartPosition;
public ObjectData(Object objectBase, Vector3 endPosition, float endTime, String creator, List<Vector2> points,
int networkId, Vector3 startPosition = new Vector3())
{
ObjectBase = objectBase;
EndPosition = endPosition;
EndTime = endTime;
Creator = creator;
Points = points;
NetworkId = networkId;
StartPosition = startPosition;
}
}
}
internal class DestinationTracker
{
private static readonly Dictionary<Obj_AI_Hero, List<Ability>> Enemies =
new Dictionary<Obj_AI_Hero, List<Ability>>();
public DestinationTracker()
{
foreach (Obj_AI_Hero hero in ObjectManager.Get<Obj_AI_Hero>())
{
if (hero.IsEnemy)
{
var abilities = new List<Ability>();
foreach (SpellDataInst spell in hero.SummonerSpellbook.Spells)
{
if (spell.Name.Contains("Flash"))
{
abilities.Add(new Ability("SummonerFlash", 400, 0, hero));
//AddObject(hero, abilities);
}
}
//abilities.Clear(); //TODO: Check if it delets the flash abilities
switch (hero.ChampionName)
{
case "Ezreal":
abilities.Add(new Ability("EzrealArcaneShift", 475, 0, hero));
//AddObject(hero, abilities);
break;
case "Fiora":
abilities.Add(new Ability("FioraDance", 700, 1, hero));
//AddObject(hero, abilities);
break;
case "Kassadin":
abilities.Add(new Ability("RiftWalk", 700, 0, hero));
//AddObject(hero, abilities);
break;
case "Katarina":
abilities.Add(new Ability("KatarinaE", 700, 0, hero));
//AddObject(hero, abilities);
break;
case "Leblanc":
abilities.Add(new Ability("LeblancSlide", 600, 0.5f, hero));
abilities.Add(new Ability("leblancslidereturn", 0, 0, hero));
abilities.Add(new Ability("LeblancSlideM", 600, 0.5f, hero));
abilities.Add(new Ability("leblancslidereturnm", 0, 0, hero));
//AddObject(hero, abilities);
break;
case "Lissandra":
abilities.Add(new Ability("LissandraE", 700, 0, hero));
//AddObject(hero, abilities);
break;
case "MasterYi":
abilities.Add(new Ability("AlphaStrike", 600, 0.9f, hero));
//AddObject(hero, abilities);
break;
case "Shaco":
abilities.Add(new Ability("Deceive", 400, 0, hero));
//AddObject(hero, abilities);
break;
case "Talon":
abilities.Add(new Ability("TalonCutthroat", 700, 0, hero));
//AddObject(hero, abilities);
break;
case "Vayne":
abilities.Add(new Ability("VayneTumble", 250, 0, hero));
//AddObject(hero, abilities);
break;
case "Zed":
abilities.Add(new Ability("ZedShadowDash", 999, 0, hero));
//AddObject(hero, abilities);
break;
}
if (abilities.Count > 0)
AddObject(hero, abilities);
}
}
Game.OnGameUpdate += Game_OnGameUpdate;
Obj_AI_Base.OnProcessSpellCast += Obj_AI_Hero_OnProcessSpellCast;
GameObject.OnCreate += Obj_AI_Base_OnCreate;
Drawing.OnDraw += Drawing_OnDraw;
}
private bool AddObject(Obj_AI_Hero hero, List<Ability> abilities)
{
if (Enemies.ContainsKey(hero))
return false;
Enemies.Add(hero, abilities);
return true;
//TODO:Add
}
~DestinationTracker()
{
Game.OnGameUpdate -= Game_OnGameUpdate;
Obj_AI_Base.OnProcessSpellCast -= Obj_AI_Hero_OnProcessSpellCast;
GameObject.OnCreate -= Obj_AI_Base_OnCreate;
Drawing.OnDraw -= Drawing_OnDraw;
}
public bool IsActive()
{
return Menu.Tracker.GetActive() && Menu.DestinationTracker.GetActive();
}
private void Drawing_OnDraw(EventArgs args)
{
if (!IsActive())
return;
foreach (var enemy in Enemies)
{
foreach (Ability ability in enemy.Value)
{
if (ability.Casted)
{
Vector2 startPos = Drawing.WorldToScreen(ability.StartPos);
Vector2 endPos = Drawing.WorldToScreen(ability.EndPos);
if (ability.OutOfBush)
{
Utility.DrawCircle(ability.EndPos, ability.Range, Color.Red);
}
else
{
Utility.DrawCircle(ability.EndPos, ability.Range, Color.Red);
Drawing.DrawLine(startPos[0], startPos[1], endPos[0], endPos[1], 1.0f, Color.Red);
}
Drawing.DrawText(endPos[0], endPos[1], Color.Bisque,
enemy.Key.ChampionName + " " + ability.SpellName);
}
}
}
}
private void Obj_AI_Base_OnCreate(GameObject sender, EventArgs args)
{
if (!IsActive())
return;
foreach (var enemy in Enemies)
{
if (enemy.Key.ChampionName == "Shaco")
{
if (sender.Type != GameObjectType.obj_LampBulb && sender.Name == "JackintheboxPoof2.troy" && !enemy.Value[0].Casted)
{
enemy.Value[0].StartPos = sender.Position;
enemy.Value[0].EndPos = sender.Position;
enemy.Value[0].Casted = true;
enemy.Value[0].TimeCasted = (int) Game.Time;
enemy.Value[0].OutOfBush = true;
}
}
}
}
private Vector3 CalculateEndPos(Ability ability, GameObjectProcessSpellCastEventArgs args)
{
float dist = Vector3.Distance(args.Start, args.End);
if (dist <= ability.Range)
{
ability.EndPos = args.End;
}
else
{
Vector3 norm = args.Start - args.End;
norm.Normalize();
Vector3 endPos = args.Start - norm*ability.Range;
//endPos = FindNearestNonWall(); TODO: Add FindNearestNonWall
ability.EndPos = endPos;
}
return ability.EndPos;
}
private void Obj_AI_Hero_OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args)
{
if (!IsActive())
return;
if (sender.GetType() == typeof (Obj_AI_Hero))
{
var hero = (Obj_AI_Hero) sender;
if (hero.IsEnemy)
{
Obj_AI_Hero enemy = hero;
foreach (var abilities in Enemies)
{
if (abilities.Key.NetworkId != enemy.NetworkId)
continue;
int index = 0;
foreach (Ability ability in abilities.Value)
{
if (args.SData.Name == "vayneinquisition")
{
if (ability.ExtraTicks > 0)
{
ability.ExtraTicks = (int) Game.Time + 6 + 2*args.Level;
return;
}
}
if (args.SData.Name == ability.SpellName)
{
switch (ability.SpellName)
{
case "VayneTumble":
if (Game.Time >= ability.ExtraTicks)
return;
ability.StartPos = args.Start;
ability.EndPos = CalculateEndPos(ability, args);
break;
case "Deceive":
ability.OutOfBush = false;
ability.StartPos = args.Start;
ability.EndPos = CalculateEndPos(ability, args);
break;
case "LeblancSlideM":
abilities.Value[index - 2].Casted = false;
ability.StartPos = abilities.Value[index - 2].StartPos;
ability.EndPos = CalculateEndPos(ability, args);
break;
case "leblancslidereturn":
case "leblancslidereturnm":
if (ability.SpellName == "leblancslidereturn")
{
abilities.Value[index - 1].Casted = false;
abilities.Value[index + 1].Casted = false;
abilities.Value[index + 2].Casted = false;
}
else
{
abilities.Value[index - 3].Casted = false;
abilities.Value[index - 2].Casted = false;
abilities.Value[index - 1].Casted = false;
}
ability.StartPos = args.Start;
ability.EndPos = abilities.Value[index - 1].StartPos;
break;
case "FioraDance":
case "AlphaStrike":
//TODO: Get Target
//ability.Target = args.Target;
ability.TargetDead = false;
ability.StartPos = args.Start;
//ability.EndPos = args.Target.Position;
break;
default:
ability.StartPos = args.Start;
ability.EndPos = CalculateEndPos(ability, args);
break;
}
ability.Casted = true;
ability.TimeCasted = (int) Game.Time;
return;
}
index++;
}
}
}
}
}
private void Game_OnGameUpdate(EventArgs args)
{
if (!IsActive())
return;
foreach (var abilities in Enemies)
{
foreach (Ability ability in abilities.Value)
{
if (ability.Casted)
{
if (ability.SpellName == "FioraDance" || ability.SpellName == "AlphaStrike" &&
!ability.TargetDead)
{
if (Game.Time > (ability.TimeCasted + ability.Delay + 0.2))
ability.Casted = false;
/*else if (ability.Target.IsDead()) TODO: Waiting for adding Target
{
Vector3 temp = ability.EndPos;
ability.EndPos = ability.StartPos;
ability.StartPos = temp;
ability.TargetDead = true;
}*/
}
else if (ability.Owner.IsDead ||
(!ability.Owner.IsValid && Game.Time > (ability.TimeCasted + /*variable*/ 2)) ||
(ability.Owner.IsVisible &&
Game.Time > (ability.TimeCasted + /*variable*/ 5 + ability.Delay)))
{
ability.Casted = false;
}
else if (!ability.OutOfBush && ability.Owner.IsVisible &&
Game.Time > (ability.TimeCasted + ability.Delay))
{
ability.EndPos = ability.Owner.ServerPosition;
}
}
}
}
}
public class Ability
{
public bool Casted;
public float Delay;
public Vector3 EndPos;
public int ExtraTicks;
public bool OutOfBush;
public Obj_AI_Hero Owner;
public int Range;
public String SpellName;
public Vector3 StartPos;
public Obj_AI_Hero Target;
public bool TargetDead;
public int TimeCasted;
public Ability(string spellName, int range, float delay, Obj_AI_Hero owner)
{
SpellName = spellName;
Range = range;
Delay = delay;
Owner = owner;
}
}
}
internal class SsCaller
{
public static readonly Dictionary<Obj_AI_Hero, Time> Enemies = new Dictionary<Obj_AI_Hero, Time>();
public SsCaller()
{
foreach (Obj_AI_Hero hero in ObjectManager.Get<Obj_AI_Hero>())
{
if (hero.IsEnemy)
{
Enemies.Add(hero, new Time());
}
}
Game.OnGameUpdate += Game_OnGameUpdate;
}
~SsCaller()
{
Game.OnGameUpdate -= Game_OnGameUpdate;
}
public bool IsActive()
{
return Menu.Tracker.GetActive() && Menu.SsCaller.GetActive() &&
Game.Time < (Menu.SsCaller.GetMenuItem("SAwarenessSSCallerDisableTime").GetValue<Slider>().Value*60);
}
private void Game_OnGameUpdate(EventArgs args)
{
if (!IsActive())
return;
foreach (var enemy in Enemies)
{
UpdateTime(enemy);
HandleSs(enemy);
}
}
private void HandleSs(KeyValuePair<Obj_AI_Hero, Time> enemy)
{
Obj_AI_Hero hero = enemy.Key;
if (enemy.Value.InvisibleTime > 5 && !enemy.Value.Called && Game.Time - enemy.Value.LastTimeCalled > 30)
{
var pos = new Vector2(hero.Position.X, hero.Position.Y);
var pingType = Packet.PingType.Normal;
var t = Menu.SsCaller.GetMenuItem("SAwarenessSSCallerPingType").GetValue<StringList>();
pingType = (Packet.PingType) t.SelectedIndex + 1;
GamePacket gPacketT;
for (int i = 0;
i < Menu.SsCaller.GetMenuItem("SAwarenessSSCallerPingTimes").GetValue<Slider>().Value;
i++)
{
if (Menu.SsCaller.GetMenuItem("SAwarenessSSCallerLocalPing").GetValue<bool>())
{
gPacketT =
Packet.S2C.Ping.Encoded(new Packet.S2C.Ping.Struct(pos[0], pos[1], 0, 0, pingType));
gPacketT.Process();
}
else if (!Menu.SsCaller.GetMenuItem("SAwarenessSSCallerLocalPing").GetValue<bool>() &&
Menu.GlobalSettings.GetMenuItem("SAwarenessGlobalSettingsServerChatPingActive")
.GetValue<bool>())
{
gPacketT =
Packet.C2S.Ping.Encoded(new Packet.C2S.Ping.Struct(enemy.Value.LastPosition.X,
enemy.Value.LastPosition.Y, 0, pingType));
gPacketT.Send();
}
}
if (Menu.SsCaller.GetMenuItem("SAwarenessSSCallerChatChoice").GetValue<StringList>().SelectedIndex == 1)
{
Game.PrintChat("ss {0}", hero.ChampionName);
}
else if (
Menu.SsCaller.GetMenuItem("SAwarenessSSCallerChatChoice").GetValue<StringList>().SelectedIndex ==
2 &&
Menu.GlobalSettings.GetMenuItem("SAwarenessGlobalSettingsServerChatPingActive").GetValue<bool>())
{
Game.Say("ss {0}", hero.ChampionName);
}
enemy.Value.LastTimeCalled = (int) Game.Time;
enemy.Value.Called = true;
}
}
private void UpdateTime(KeyValuePair<Obj_AI_Hero, Time> enemy)
{
Obj_AI_Hero hero = enemy.Key;
if (hero.IsVisible)
{
Enemies[hero].InvisibleTime = 0;
Enemies[hero].VisibleTime = (int) Game.Time;
enemy.Value.Called = false;
Enemies[hero].LastPosition = hero.ServerPosition;
}
else
{
if (Enemies[hero].VisibleTime != 0)
{
Enemies[hero].InvisibleTime = (int) (Game.Time - Enemies[hero].VisibleTime);
}
else
{
Enemies[hero].InvisibleTime = 0;
}
}
}
public class Time
{
public bool Called;
public int InvisibleTime;
public Vector3 LastPosition;
public int LastTimeCalled;
public int VisibleTime;
}
}
public class UiTracker
{
private readonly Dictionary<Obj_AI_Hero, ChampInfos> _allies = new Dictionary<Obj_AI_Hero, ChampInfos>();
private readonly Dictionary<Obj_AI_Hero, ChampInfos> _enemies = new Dictionary<Obj_AI_Hero, ChampInfos>();
private Font _champF;
private Render.Rectangle _recB;
private Font _recF;
private Render.Rectangle _recS;
private Render.Rectangle _recNS;
private Sprite _s;
private Font _spellF;
private Font _sumF;
private Font _champIF;
private Texture _backBar;
private Size _backBarSize = new Size(96, 10);
private Size _champSize = new Size(64, 64);
private Texture _healthBar;
private Size _healthManaBarSize = new Size(96, 5);
private Texture _manaBar;
private Texture _overlayEmptyItem;
private Texture _overlayRecall;
private Texture _overlaySpellItem;
private Texture _overlaySpellItemRed;
private Texture _overlaySpellItemGreen;
private Texture _overlaySummoner;
private Texture _overlaySummonerSpell;
private Texture _overlayGoldCsLvl;
private Size _recSize = new Size(64, 12);
private Vector2 _screen = new Vector2(Drawing.Width, Drawing.Height/2);
private Size _spellSize = new Size(16, 16);
private Size _sumSize = new Size(32, 32);
private bool _drawActive = true;
private Size _hudSize;
private Vector2 _lastCursorPos;
private bool _moveActive;
private int _oldAx = 0;
private int _oldAy = 0;
private int _oldEx;
private int _oldEy;
private float _scalePc = 1.0f;
private bool _shiftActive;
public UiTracker()
{
if (!IsActive())
return;