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 != Recall.Header) //OLD 215 { return; } //Log.LogPacket(args.PacketData); Recall.Struct recall = RecallDecode(args.PacketData);//Packet.S2C.Recall.Decoded(args.PacketData); HandleRecall(recall); } catch (Exception ex) { Console.WriteLine("RecallProcess: " + ex); } }
private void HandleRecall(Recall.Struct recallEx) { int time = Environment.TickCount - Game.Ping; foreach (RecallInfo recall in Recalls) { if (recall == null) { continue; } if (recallEx.Type == 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 Recall.Struct(); var t = Menu.RecallDetector.GetMenuItem("SAwarenessRecallDetectorMode").GetValue <StringList>(); if (t.SelectedIndex == 0 || t.SelectedIndex == 2) { var percentHealth = (int)((obj.Health / obj.MaxHealth) * 100); String sColor = "<font color='#FFFFFF'>"; String color = (percentHealth > 50 ? "<font color='#00FF00'>" : (percentHealth > 30 ? "<font color='#FFFF00'>" : "<font color='#FF0000'>")); if (recallEx.Status == Recall.RecallStatus.TeleportStart || recallEx.Status == Recall.RecallStatus.RecallStarted) { String text = (recallEx.Status == Recall.RecallStatus.TeleportStart ? "porting" : "recalling"); recall.StartTime = (int)Game.Time; if ( Menu.RecallDetector.GetMenuItem("SAwarenessRecallDetectorChatChoice") .GetValue <StringList>() .SelectedIndex == 1) { Game.PrintChat(obj.ChampionName + " {0} with {1} hp {2}({3})", text, (int)obj.Health, color, percentHealth); } else if ( Menu.RecallDetector.GetMenuItem("SAwarenessRecallDetectorChatChoice") .GetValue <StringList>() .SelectedIndex == 2 && Menu.GlobalSettings.GetMenuItem("SAwarenessGlobalSettingsServerChatPingActive") .GetValue <bool>()) { Game.Say(obj.ChampionName + " {0} with {1} hp {2}({3})", text, (int)obj.Health, color, percentHealth); } } else if (recallEx.Status == Recall.RecallStatus.TeleportEnd || recallEx.Status == Recall.RecallStatus.RecallFinished) { String text = (recallEx.Status == Recall.RecallStatus.TeleportStart ? "ported" : "recalled"); if ( Menu.RecallDetector.GetMenuItem("SAwarenessRecallDetectorChatChoice") .GetValue <StringList>() .SelectedIndex == 1) { Game.PrintChat(obj.ChampionName + " {0} with {1} hp {2}({3})", text, (int)obj.Health, color, percentHealth); } else if ( Menu.RecallDetector.GetMenuItem("SAwarenessRecallDetectorChatChoice") .GetValue <StringList>() .SelectedIndex == 2 && Menu.GlobalSettings.GetMenuItem( "SAwarenessGlobalSettingsServerChatPingActive").GetValue <bool>()) { Game.Say(obj.ChampionName + " {0} with {1} hp {2}({3})", text, (int)obj.Health, color, percentHealth); } } else { if ( Menu.RecallDetector.GetMenuItem("SAwarenessRecallDetectorChatChoice") .GetValue <StringList>() .SelectedIndex == 1) { Game.PrintChat(obj.ChampionName + " canceled with {0} hp", (int)obj.Health); } else if ( Menu.RecallDetector.GetMenuItem("SAwarenessRecallDetectorChatChoice") .GetValue <StringList>() .SelectedIndex == 2 && Menu.GlobalSettings.GetMenuItem( "SAwarenessGlobalSettingsServerChatPingActive").GetValue <bool>()) { Game.Say(obj.ChampionName + " canceled with {0} hp", (int)obj.Health); } } } return; } } else if (recallEx.Status == Recall.RecallStatus.TeleportStart || recallEx.Status == Recall.RecallStatus.TeleportEnd) { if (recall.Recall.Status == Recall.RecallStatus.TeleportStart) { recall.Recall2 = recallEx; } var obj = ObjectManager.GetUnitByNetworkId <GameObject>(recallEx.UnitNetworkId); Vector3 pos = obj.Position; for (int i = 0; i < Menu.RecallDetector.GetMenuItem("SAwarenessRecallDetectorPingTimes") .GetValue <Slider>() .Value; i++) { GamePacket gPacketT; if (Menu.RecallDetector.GetMenuItem("SAwarenessRecallDetectorLocalPing").GetValue <bool>()) { gPacketT = Packet.S2C.Ping.Encoded(new Packet.S2C.Ping.Struct(pos[0], pos[1], 0, 0, Packet.PingType.Danger)); gPacketT.Process(); } else { gPacketT = Packet.C2S.Ping.Encoded(new Packet.C2S.Ping.Struct(pos.X, pos.Y, 0, Packet.PingType.Danger)); //gPacketT.Send(); } } } } }
public static Recall.Struct RecallDecode(byte[] data) { var reader = new BinaryReader(new MemoryStream(data)); var recall = new Recall.Struct(); reader.ReadByte(); //PacketId reader.ReadInt32(); recall.UnitNetworkId = reader.ReadInt32(); reader.ReadBytes(66); recall.Status = Recall.RecallStatus.Unknown; var teleport = false; if (BitConverter.ToString(reader.ReadBytes(6)) != "00-00-00-00-00-00") { if (BitConverter.ToString(reader.ReadBytes(3)) != "00-00-00") { recall.Status = Recall.RecallStatus.TeleportStart; teleport = true; } else { recall.Status = Recall.RecallStatus.RecallStarted; } } reader.Close(); var champ = ObjectManager.GetUnitByNetworkId <Obj_AI_Hero>(recall.UnitNetworkId); if (champ == null) { return(recall); } if (teleport) { recall.Duration = 3500; } else //use masteries to detect recall duration, because spelldata is not initialized yet when enemy has not been seen { recall.Duration = Utility.Map.GetMap()._MapType == Utility.Map.MapType.CrystalScar ? 4500 : 8000; if (champ.Masteries.Any(x => x.Page == MasteryPage.Utility && x.Id == 65 && x.Points == 1)) { recall.Duration -= Utility.Map.GetMap()._MapType == Utility.Map.MapType.CrystalScar ? 500 : 1000; } //phasewalker mastery } var time = Environment.TickCount - Game.Ping; if (!RecallT.ContainsKey(recall.UnitNetworkId)) { RecallT.Add(recall.UnitNetworkId, time); } //will result in status RecallStarted, which would be wrong if the assembly was to be loaded while somebody recalls else { if (RecallT[recall.UnitNetworkId] == 0) { RecallT[recall.UnitNetworkId] = time; } else { if (time - RecallT[recall.UnitNetworkId] > recall.Duration - 175) { recall.Status = teleport ? Recall.RecallStatus.TeleportEnd : Recall.RecallStatus.RecallFinished; } else { recall.Status = teleport ? Recall.RecallStatus.TeleportAbort : Recall.RecallStatus.RecallAborted; } RecallT[recall.UnitNetworkId] = 0; //recall aborted or finished, reset status } } return(recall); }