Пример #1
0
        public static string AddGold(LeagueServer server, int client, string args)
        {
            if (string.IsNullOrEmpty(args))
            {
                return("Missing speed value!");
            }
            float value = float.Parse(args);

            byte[] buffer = BitConverter.GetBytes(value);

            var packet = new OnReplication();

            packet.SyncID = (uint)Environment.TickCount;
            var data = new ReplicationData()
            {
                UnitNetID = 0x40000001,
            };

            data.Data[0]           = new Tuple <uint, byte[]>(1, buffer);
            packet.ReplicationData = new List <ReplicationData>()
            {
                data
            };
            server.SendEncrypted(client, ChannelID.Broadcast, packet);


            var packet2 = new UnitAddGold
            {
                GoldAmmount = value,
                TargetNetID = 0x40000001,
            };

            server.SendEncrypted(client, ChannelID.Broadcast, packet2);
            return("Gold Added!");
        }
Пример #2
0
        public static string TestRep(LeagueServer server, ClientID client, string args)
        {
            var packet = new OnReplication();

            packet.SyncID = (uint)Environment.TickCount;
            var data = new ReplicationData()
            {
                UnitNetID = (NetID)0x40000001,
            };

            byte[] buffer;
            using (var stream = new MemoryStream())
            {
                using (var writer = new PacketWriter(stream, true))
                {
                    writer.WritePackedFloat(333.0f);
                    writer.WritePackedFloat(123.0f);
                }
                buffer = new byte[stream.Length];
                Buffer.BlockCopy(stream.GetBuffer(), 0, buffer, 0, buffer.Length);
            }
            data.Data[3] = new Tuple <uint, byte[]>((1 << 0) | (1 << 1), buffer);

            packet.ReplicationData = new List <ReplicationData>()
            {
                data
            };
            server.SendEncrypted(client, ChannelID.Broadcast, packet);
            return("TestRep!");
        }
Пример #3
0
        public static string TestBatch(LeagueServer server, int client, string args)
        {
            var batched = new Batched();
            var packet1 = new UnitAddEXP();

            packet1.TargetNetID = 0x40000001;
            packet1.ExpAmmount  = 100.0f;

            var packet2 = new BuyItemAns();

            packet2.SenderNetID      = 0x40000001;
            packet2.Item.ItemID      = 3100;
            packet2.Item.ItemsInSlot = 1;

            var packet3 = new BuyItemAns();

            packet3.SenderNetID      = 0x40000001;
            packet3.Item.ItemID      = 3025;
            packet3.Item.ItemsInSlot = 1;
            packet3.Item.Slot        = 2;

            batched.Packets.Add(packet1);
            batched.Packets.Add(packet2);
            batched.Packets.Add(packet3);

            server.SendEncrypted(client, ChannelID.Broadcast, batched);
            return("Batched!");
        }
Пример #4
0
        public static string TestUndo(LeagueServer server, int client, string args)
        {
            var packet = new S2C_SetUndoEnabled();

            packet.UndoStackSize = 2;
            server.SendEncrypted(client, ChannelID.Broadcast, packet);
            return("Test S2C_SetUndoEnabled!");
        }
Пример #5
0
        public static string LeaveVision(LeagueServer server, int client, string args)
        {
            var packet = new OnLeaveVisiblityClient();

            packet.SenderNetID = 0x40000001;
            server.SendEncrypted(client, ChannelID.Broadcast, packet);
            return("LeaveVision?");
        }
Пример #6
0
        public static string Test016(LeagueServer server, int client, string args)
        {
            var packet = new UnitAddEXP();

            packet.TargetNetID = 0x40000001;
            packet.ExpAmmount  = 100.0f;
            server.SendEncrypted(client, ChannelID.Broadcast, packet);
            return("Test UnitAddEXP!");
        }
Пример #7
0
        public static string Test013(LeagueServer server, int client, string args)
        {
            var packet = new S2C_ReplaceObjectiveText();

            packet.SenderNetID = 0x40000001;
            packet.TextID      = "hello!";
            server.SendEncrypted(client, ChannelID.Broadcast, packet);
            return("Test S2C_ReplaceObjectiveText!");
        }
Пример #8
0
        public static string Test002(LeagueServer server, int client, string args)
        {
            var packet = new S2C_DisplayLocalizedTutorialChatText();

            packet.SenderNetID = 0x40000001;
            packet.Message     = "hello!";
            server.SendEncrypted(client, ChannelID.Broadcast, packet);
            return("Test S2C_DisplayLocalizedTutorialChatText!");
        }
Пример #9
0
        public static string AddItem(LeagueServer server, int client, string args)
        {
            var packet = new BuyItemAns();

            packet.SenderNetID      = 0x40000001;
            packet.Item.ItemID      = 3100;
            packet.Item.ItemsInSlot = 1;
            server.SendEncrypted(client, ChannelID.Broadcast, packet);
            return("AddItem!");
        }
Пример #10
0
        public static string EnterVision(LeagueServer server, int client, string args)
        {
            var packet = new OnEnterVisiblityClient();

            packet.SenderNetID  = 0x40000001;
            packet.MovementData = new MovementDataStop
            {
                Position = new Vector2(26, 280),
                Forward  = new Vector2(26, 280),
                SyncID   = 14
            };
            server.SendEncrypted(client, ChannelID.Broadcast, packet);
            return("EnterVision?");
        }
Пример #11
0
        public static string EnterVision(LeagueServer server, ClientID client, string args)
        {
            var packet = new OnEnterVisiblityClient();

            packet.SenderNetID = (NetID)0x40000001;
            var visibility = new VisibilityDataAIHero();

            visibility.MovementData = new MovementDataStop
            {
                Position = new Vector2(26, 280),
                Forward  = new Vector2(26, 280),
            };
            visibility.MovementSyncID = 14;
            packet.VisibilityData     = visibility;
            server.SendEncrypted(client, ChannelID.Broadcast, packet);
            return("EnterVision?");
        }
Пример #12
0
        public static string TestRep(LeagueServer server, int client, string args)
        {
            var packet = new OnReplication();

            packet.SyncID = (uint)Environment.TickCount;
            var data = new ReplicationData()
            {
                UnitNetID = 0x40000001,
            };

            using (var writer = new ByteWriter())
            {
                writer.WritePackedFloat(333.0f);
                writer.WritePackedFloat(123.0f);
                data.Data[3] = new Tuple <uint, byte[]>((1 << 0) | (1 << 1), writer.GetBytes());
            }

            packet.ReplicationData = new List <ReplicationData>()
            {
                data
            };
            server.SendEncrypted(client, ChannelID.Broadcast, packet);
            return("TestRep!");
        }
Пример #13
0
        public static void Main(string[] args)
        {
            var address = new Address(Address.IPv4HostAny, 5119);
            var key     = Convert.FromBase64String("17BLOhi6KZsTtldTsizvHg==");
            var cids    = new List <ClientID> {
                (ClientID)1
            };
            var server         = new LeagueServer(address, key, cids);
            var mapNum         = 1;
            var playerLiteInfo = new PlayerLoadInfo
            {
                PlayerID      = (PlayerID)1,
                SummonorLevel = 30,
                TeamId        = TeamID.Order,
            };
            var skinID       = 0u;
            var championName = "Annie";
            var playerName   = "Test";
            var jSettings    = new JsonSerializerSettings
            {
                TypeNameHandling = TypeNameHandling.Auto
            };
            var commandsList = new List <KeyValuePair <Regex, MethodInfo> >();

            foreach (var method in typeof(Commands).GetMethods(BindingFlags.Static | BindingFlags.Public))
            {
                var regex = new Regex(@"\." + method.Name + @"((?:\s(?:.*)|))?", RegexOptions.IgnoreCase);
                commandsList.Add(new KeyValuePair <Regex, MethodInfo>(regex, method));
            }


            server.OnPacket += (s, e) =>
            {
                var packet  = e.Packet;
                var cid     = e.ClientID;
                var channel = e.ChannelID;
                if (packet is IUnusedPacket)
                {
                }
                else if (packet is C2S_QueryStatusReq statusReq)
                {
                    var answer = new S2C_QueryStatusAns();
                    answer.SenderNetID = (NetID)(uint)cid;
                    answer.Response    = true;
                    server.SendEncrypted(cid, ChannelID.Broadcast, answer);
                }
                else if (packet is RequestJoinTeam reqJoinTeam)
                {
                    var answer2 = new TeamRosterUpdate();
                    answer2.TeamSizeOrder        = 1;
                    answer2.OrderMembers[0]      = (PlayerID)cid;
                    answer2.TeamSizeOrderCurrent = 1;
                    server.SendEncrypted(cid, ChannelID.LoadingScreen, answer2);

                    var answer1 = new RequestReskin();
                    answer1.PlayerID = (PlayerID)cid;
                    answer1.SkinID   = (int)skinID;
                    answer1.SkinName = championName;
                    server.SendEncrypted(cid, ChannelID.LoadingScreen, answer1);


                    var answer3 = new RequestRename();
                    answer3.PlayerID   = (PlayerID)cid;
                    answer3.SkinID     = 0;
                    answer3.PlayerName = playerName;
                    server.SendEncrypted(cid, ChannelID.LoadingScreen, answer3);
                }
                else if (packet is C2S_Ping_Load_Info reqPingLoadInfo)
                {
                    var answer = new S2C_Ping_Load_Info();
                    answer.SenderNetID             = (NetID)(uint)cid;
                    answer.ConnectionInfo          = reqPingLoadInfo.ConnectionInfo;
                    answer.ConnectionInfo.PlayerID = (PlayerID)cid;
                    server.SendEncrypted(cid, ChannelID.Broadcast, answer);
                }
                else if (packet is SynchVersionC2S syncReq)
                {
                    var answer = new SynchVersionS2C();
                    answer.VersionMatches = true;
                    answer.VersionString  = syncReq.Version;
                    answer.MapToLoad      = mapNum;
                    answer.PlayerInfo[0]  = playerLiteInfo;
                    answer.MapMode        = "CLASSIC";
                    answer.PlatformID     = "NA1";
                    answer.GameFeatures  |= GameFeatures.FoundryOptions;
                    answer.GameFeatures  |= GameFeatures.EarlyWarningForFOWMissiles;
                    answer.GameFeatures  |= GameFeatures.NewPlayerRecommendedPages;
                    answer.GameFeatures  |= GameFeatures.HighlightLineMissileTargets;
                    server.SendEncrypted(cid, ChannelID.Broadcast, answer);
                }
                else if (packet is C2S_CharSelected reqSelected)
                {
                    var startSpawn = new S2C_StartSpawn();
                    server.SendEncrypted(cid, ChannelID.Broadcast, startSpawn);


                    var spawnHero = new S2C_CreateHero();
                    spawnHero.SenderNetID        = (NetID)0x40000001;
                    spawnHero.Name               = playerName;
                    spawnHero.Skin               = championName;
                    spawnHero.SkinID             = 0;
                    spawnHero.NetNodeID          = NetNodeID.Spawned;
                    spawnHero.NetID              = (NetID)0x40000001;
                    spawnHero.TeamIsOrder        = true;
                    spawnHero.CreateHeroDeath    = CreateHeroDeath.Alive;
                    spawnHero.PlayerUID          = cid;
                    spawnHero.SpawnPositionIndex = 2;
                    server.SendEncrypted(cid, ChannelID.Broadcast, spawnHero);


                    var avatarInfo = new AvatarInfo_Server();
                    avatarInfo.SenderNetID = (NetID)0x40000001;
                    server.SendEncrypted(cid, ChannelID.Broadcast, avatarInfo);


                    var endSpawn = new S2C_EndSpawn();
                    server.SendEncrypted(cid, ChannelID.Broadcast, endSpawn);
                }
                else if (packet is C2S_ClientReady reqReady)
                {
                    var startGame = new S2C_StartGame();
                    startGame.EnablePause = true;
                    server.SendEncrypted(cid, ChannelID.Broadcast, startGame);
                }
                else if (packet is World_SendCamera_Server reqCamerPosition)
                {
                }
                else if (packet is World_LockCamera_Server reqLockCameraServer)
                {
                }
                else if (packet is Chat reqChat)
                {
                    foreach (var kvp in commandsList)
                    {
                        var match = kvp.Key.Match(reqChat.Message);
                        if (match.Groups.Count == 2)
                        {
                            object value  = match.Groups[1].Value;
                            object result = kvp.Value.Invoke(null, new object[] {
                                s, e.ClientID, value
                            });
                            if (result != null && result is string strResult)
                            {
                                var response = new Chat();
                                response.Localized = false;
                                response.Message   = strResult;
                                response.ChatType  = ChatType.Team;
                                response.ClientID  = e.ClientID;
                                //response.Params = "Command";
                                server.SendEncrypted(e.ClientID, ChannelID.Chat, response);
                            }
                            break;
                        }
                    }
                }
                else
                {
                    Console.WriteLine(JsonConvert.SerializeObject(e, jSettings));
                    if (packet is NPC_IssueOrderReq movReq && movReq.OrderType == OrderType.MoveTo)
                    {
                        var resWaypoints = new WaypointGroup();
                        resWaypoints.SenderNetID = (NetID)0x40000001;
                        resWaypoints.SyncID      = (int)Environment.TickCount;
                        resWaypoints.Movements.Add(new MovementDataNormal
                        {
                            TeleportNetID = (NetID)0x40000001,
                            Waypoints     = movReq.Waypoints
                        });
                        server.SendEncrypted(e.ClientID, ChannelID.Broadcast, resWaypoints);
                    }
                }
            };
            server.OnBadPacket += (s, e) =>
            {
                Console.WriteLine(JsonConvert.SerializeObject(e, jSettings));
            };
            server.OnConnected += (s, e) =>
            {
                Console.WriteLine(JsonConvert.SerializeObject(e, jSettings));
            };
            server.OnDisconnected += (s, e) =>
            {
                Console.WriteLine(JsonConvert.SerializeObject(e, jSettings));
            };
            while (true)
            {
                server.RunOnce();
            }
        }