forked from Screeder/SAwareness
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDetector.cs
More file actions
157 lines (144 loc) · 6.38 KB
/
Detector.cs
File metadata and controls
157 lines (144 loc) · 6.38 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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LeagueSharp;
using LeagueSharp.Common;
namespace SAwareness
{
class Recall
{
public List<RecallInfo> _recalls = new List<RecallInfo>();
public class RecallInfo
{
public int NetworkId;
public Packet.S2C.Recall.Struct Recall;
public Packet.S2C.Recall.Struct Recall2;
public int StartTime;
public RecallInfo(int networkId)
{
NetworkId = networkId;
}
}
public Recall()
{
foreach (var enemy in ObjectManager.Get<Obj_AI_Hero>())
{
if (enemy.IsEnemy)
{
_recalls.Add(new RecallInfo(enemy.NetworkId));
}
}
Game.OnGameProcessPacket += Game_OnGameProcessPacket;
}
~Recall()
{
Game.OnGameProcessPacket -= Game_OnGameProcessPacket;
}
public bool IsActive()
{
return Menu.RecallDetector.GetActive();
}
void Game_OnGameProcessPacket(GamePacketEventArgs args) //TODO: Check for Packet id
{
if (!IsActive())
return;
try
{
var reader = new BinaryReader(new MemoryStream(args.PacketData));
byte PacketId = reader.ReadByte(); //PacketId
if (PacketId != Packet.S2C.Recall.Header) //OLD 215
return;
Packet.S2C.Recall.Struct recall = Packet.S2C.Recall.Decoded(args.PacketData);
HandleRecall(recall);
}
catch (Exception ex)
{
Console.WriteLine("RecallProcess: " + ex.ToString());
return;
}
}
void HandleRecall(Packet.S2C.Recall.Struct recallEx)
{
int time = Environment.TickCount - Game.Ping;
foreach (RecallInfo recall in _recalls)
{
if (recall == null) continue;
if (recallEx.Type == Packet.S2C.Recall.ObjectType.Player)
{
var obj = ObjectManager.GetUnitByNetworkId<Obj_AI_Hero>(recall.NetworkId);
var objEx = ObjectManager.GetUnitByNetworkId<Obj_AI_Hero>(recallEx.UnitNetworkId);
if (obj == null)
continue;
if (obj.NetworkId == objEx.NetworkId) //already existing
{
recall.Recall = recallEx;
recall.Recall2 = new Packet.S2C.Recall.Struct();
StringList t = Menu.RecallDetector.GetMenuItem("SAwarenessRecallDetectorMode").GetValue<StringList>();
if (t.SelectedIndex == 0 || t.SelectedIndex == 2)
{
if (recallEx.Status == Packet.S2C.Recall.RecallStatus.TeleportStart || recallEx.Status == Packet.S2C.Recall.RecallStatus.RecallStarted)
{
recall.StartTime = (int)Game.Time;
if (Menu.RecallDetector.GetMenuItem("SAwarenessRecallDetectorLocalChat").GetValue<bool>())
{
Game.PrintChat(obj.ChampionName + " porting with {0} hp", (int)obj.Health);
}
else
{
Game.Say(obj.ChampionName + " porting with {0} hp", (int)obj.Health);
}
}
else if (recallEx.Status == Packet.S2C.Recall.RecallStatus.TeleportEnd || recallEx.Status == Packet.S2C.Recall.RecallStatus.RecallFinished)
{
//recall.StartTime = 0;
if (Menu.RecallDetector.GetMenuItem("SAwarenessRecallDetectorLocalChat").GetValue<bool>())
{
Game.PrintChat(obj.ChampionName + " ported with {0} hp", (int)obj.Health);
}
else
{
Game.Say(obj.ChampionName + " ported with {0} hp", (int)obj.Health);
}
}
else
{
//recall.StartTime = 0;
if (Menu.RecallDetector.GetMenuItem("SAwarenessRecallDetectorLocalChat").GetValue<bool>())
{
Game.PrintChat(obj.ChampionName + " canceled with {0} hp", (int)obj.Health);
}
else
{
Game.Say(obj.ChampionName + " canceled with {0} hp", (int)obj.Health);
}
}
}
return;
}
}
else if (recallEx.Status == Packet.S2C.Recall.RecallStatus.TeleportStart || recallEx.Status == Packet.S2C.Recall.RecallStatus.TeleportEnd)
{
if (recall.Recall.Status == Packet.S2C.Recall.RecallStatus.TeleportStart)
recall.Recall2 = recallEx;
var obj = ObjectManager.GetUnitByNetworkId<GameObject>(recallEx.UnitNetworkId);
var screen = obj.Position;
for (int i = 0; i < Menu.RecallDetector.GetMenuItem("SAwarenessRecallDetectorPingTimes").GetValue<Slider>().Value; i++)
{
GamePacket gPacketT = Packet.C2S.Ping.Encoded(new Packet.C2S.Ping.Struct(screen.X, screen.Y, 0, Packet.PingType.Danger));
if (Menu.RecallDetector.GetMenuItem("SAwarenessRecallDetectorLocalPing").GetValue<bool>())
{
//TODO: Add local ping
}
else
{
gPacketT.Send();
}
}
}
}
}
}
}