Esempio n. 1
0
        public static void ArrivedAtLocation(PacketReader packet, PacketBuilder builder, ClientHandler client, EventHandler events)
        {
            var x = packet.ReadUShort();
            var y = packet.ReadUShort();

            Character character = client.Metadata["fullchar"] as Character;
            var       id        = character.id;

            character.x = (byte)x;
            character.y = (byte)y;

            var clients = (client.Metadata["map"] as IMap).GetSurroundingClients(client, 2);

            (client.Metadata["map"] as IMap).GetTile(client, x, y);

            builder.New(0xD3);
            {
                builder += id;
                builder += x;
                builder += y;
            }

            foreach (var c in clients)
            {
                c.Send(builder, "NFY_MoveEnded");
            }

            NewMobsList(packet, builder, client, events);
            //NewUserList(packet, builder, client, events);

            CharacterManagement.UpdatePosition(client.Metadata["syncServer"] as SyncReceiver, (int)client.Metadata["server"], client.AccountID, character.slot, character.map, character.x, character.y);
        }
Esempio n. 2
0
        public static void LeaveWorld(PacketReader packet, PacketBuilder builder, ClientHandler client, EventHandler events)
        {
            var unk = packet.ReadByte();

            packet.Skip(1);
            var mapID = packet.ReadByte();

            Character character = client.Metadata["fullchar"] as Character;
            var       id        = character.id;

            if (id == -999999998)
            {
                return;
            }

            var clients = client.Metadata["clients"] as Dictionary <ulong, ClientHandler>;
            var map     = client.Metadata["map"] as IMap;
            var server  = (int)client.Metadata["server"];
            var slot    = character.slot;
            var x       = character.x;
            var y       = character.y;
            var magic   = (ulong)client.Metadata["magic"];

            var syncServer = client.Metadata["syncServer"] as SyncReceiver;

            CharacterManagement.UpdatePosition(syncServer, server, client.AccountID, slot, character.map, x, y);

            builder.New(0xC9);
            {
                builder += id;
                builder += (byte)0x12;
            }

            character.id = 0;

            foreach (var c in clients.Values)
            {
                c.Send(builder, "DelUserList");
            }

            builder.New(0x8F);
            {
                builder += (byte)0;
            }

            client.Send(builder, "Uninitialze");
            map.RemoveClient(client);
        }
Esempio n. 3
0
        public static void UpdateHelpInfo(PacketReader packet, PacketBuilder builder, ClientHandler client, EventHandler events)
        {
            Character character  = client.Metadata["fullchar"] as Character;
            var       clients    = client.Metadata["clients"] as Dictionary <ulong, ClientHandler>;
            var       syncServer = client.Metadata["syncServer"] as SyncReceiver;
            var       server     = (int)client.Metadata["server"];
            var       x          = character.x;
            var       y          = character.y;
            var       map        = client.Metadata["map"] as IMap;

            builder.New(0x087D);
            {
                builder += (byte)1;
            }

            CharacterManagement.UpdatePosition(syncServer, server, client.AccountID, character.slot, character.map, x, y);

            client.Send(builder, "UpdateHelpInfo");
        }
Esempio n. 4
0
        public static void AlterDestination(PacketReader packet, PacketBuilder builder, ClientHandler client, EventHandler events)
        {
            var turnX = packet.ReadUShort();
            var turnY = packet.ReadUShort();
            var endX  = packet.ReadUShort();
            var endY  = packet.ReadUShort();
            //var unkX = packet.ReadShort();
            //var unkY = packet.ReadShort();
            //var unk0 = packet.ReadShort();

            Character character = client.Metadata["fullchar"] as Character;
            var       id        = character.id;
            var       timestamp = (uint)client.Metadata["timestamp"];

            character.x = (byte)turnX;
            character.y = (byte)turnY;
            client.Metadata["dest_x"] = endX;
            client.Metadata["dest_y"] = endY;

            var clients = (client.Metadata["map"] as IMap).GetSurroundingClients(client, 2);

            builder.New(0xD4);
            {
                builder += id;
                builder += Environment.TickCount - timestamp;
                builder += turnX;
                builder += turnY;
                builder += endX;
                builder += endY;
            }

            foreach (var c in clients)
            {
                c.Send(builder, "NFY_MoveChanged");
            }

            NewMobsList(packet, builder, client, events);
            //NewUserList(packet, builder, client, events);

            CharacterManagement.UpdatePosition(client.Metadata["syncServer"] as SyncReceiver, (int)client.Metadata["server"], client.AccountID, character.slot, character.map, character.x, character.y);
        }
Esempio n. 5
0
        public static void CharacterSelect(PacketReader packet, PacketBuilder builder, ClientHandler client, EventHandler events)
        {
            builder.New(0x03D9);
            {
                builder += (byte)1;
            }

            Character character = client.Metadata["fullchar"] as Character;

            CharacterManagement.UpdatePosition(client.Metadata["syncServer"] as SyncReceiver, (int)client.Metadata["server"], client.AccountID, character.slot, character.map, character.x, character.y);

            client.Send(builder, "CharacterSelect");

            if (character.id != -999999998)
            {
                character.id = -999999998;
            }
            else
            {
                Log.Error("Character ID Already -999999998!");
            }
        }
Esempio n. 6
0
        public static void AddSkillPoints(PacketReader packet, PacketBuilder builder, ClientHandler client, EventHandler events)
        {
            var       sync      = client.Metadata["syncServer"] as SyncReceiver;
            var       server    = (int)client.Metadata["server"];
            Character character = client.Metadata["fullchar"] as Character;

            var skill    = packet.ReadUShort();
            var slot     = packet.ReadByte();
            var oldlevel = packet.ReadUShort();
            var newlevel = packet.ReadUShort();

            if ((newlevel == oldlevel + 1) || (newlevel == oldlevel - 1))
            {
                CharacterManagement.UpdateSkillPoints(sync, server, character.id, skill, newlevel, slot);
                builder.New(0x0A56);
                client.Send(builder, "AddSkillPoints");
            }
            else //Punishment for hackers :D
            {
                var map = client.Metadata["map"] as IMap;
                CharacterManagement.UpdatePosition(sync, server, client.AccountID, character.slot, character.map, character.x, character.y);
                client.Disconnect();
            }
        }
Esempio n. 7
0
        public static void WarpCommand(PacketReader packet, PacketBuilder builder, ClientHandler client, EventHandler events)
        {

            Character character = client.Metadata["fullchar"] as Character;
            var npc = packet.ReadUShort();
            var unk1 = packet.ReadUShort();
            var unk2 = packet.ReadByte();
            var unk3 = packet.ReadByte();
            var unk4 = packet.ReadByte();

            var y = packet.ReadByte();
            var x = packet.ReadByte();
            var unk5 = packet.ReadByte();
            var unk6 = packet.ReadByte();

            var warpID = packet.ReadUInt();

            var unk7 = packet.ReadByte();
            var unk8 = packet.ReadByte();
            var unk9 = packet.ReadByte();
            var unk10 = packet.ReadByte();
            var unk11 = packet.ReadByte();
            var unk12 = packet.ReadByte();
            var unk13 = packet.ReadByte();
            var unk14 = packet.ReadByte();

            var map = (client.Metadata["map"] as IMap);
            var fee = character.stats.alz;
            var alive = (warpID == 0 && npc != 54 && npc != 63);

            int[] dest = null;

            if (alive)
                dest = map.GetWarpDestination(npc, 0);
            else if (npc == 201)
                warpID = (uint)map.ID;
            else
                dest = map.GetDeathDestination();

            if (dest!=null)
            {
                warpID = (byte)dest[0];
                x = (byte)dest[1];
                y = (byte)dest[2];
            }

            map.GetSurroundingClients(client, 1);
            map.RemoveClient(client);
            events.Warped("world.WarpCommand", client, (int)warpID, x, y);

            builder.New(0x00F4); // TODO: Load x,y values from WarpList
            {
                builder += (ushort)x;
                builder += (ushort)y;
                builder += (uint)character.stats.exp;
                builder += 0;                           //axp
                builder += fee;                         //Alz (for death penalty and fee?)
                builder += (byte)1;
                builder += (byte)1;
                builder += (byte)1;
                builder += (byte)1;
                builder += (byte)1;
                builder += (ulong)0;
                builder += warpID;
                builder += (byte)1;
                builder += (byte)1;
                builder += (byte)1;
                builder += (byte)1;
                builder += (byte)1;
                builder += (byte)1;
                builder += (byte)1;
                builder += (byte)1;
                builder += (byte)1;
                builder += (byte)1;
            }

            #region PacketAnalisys  
#if DEBUG
            string notice = "";

            /*for (int i = 0; i< packet.Size-10; i++)
            {
                notice += packet.ReadByte()+" ";   
            }
            */

            notice += npc + " " + unk1 + " " + unk2 + " " + unk3 + " " + unk4 + " " + x + " " + y + " " + unk5 + " " + unk6 + " " + warpID + " "
                + unk7 + " " + unk8 + " " + unk9 + " " + unk10 + " " + unk11 + " " + unk12 + " " + unk13 + " " + unk14;
            Log.Notice(notice);
#endif
            #endregion

            client.Send(builder, "WarpCommand");

            character.map = (byte)warpID;
            character.x = x;
            character.y = y;

            CharacterManagement.UpdatePosition(client.Metadata["syncServer"] as SyncReceiver, (int)client.Metadata["server"], client.AccountID, character.slot, (byte)warpID, character.x, character.y);
        }
Esempio n. 8
0
        public static void MessageEvent(PacketReader packet, PacketBuilder builder, ClientHandler client, EventHandler events)
        {
            Character character = client.Metadata["fullchar"] as Character;
            var       name      = character.name;
            var       x         = (ushort)character.x;
            var       y         = (ushort)character.y;
            var       id        = character.id;
            var       map       = client.Metadata["map"] as IMap;
            var       clients   = map.GetSurroundingClients(client, 1);

            int unk = packet.ReadInt();

            packet.Skip(4);
            int size = packet.ReadShort() - 3;

            packet.Skip(2);
            var type = packet.ReadByte();
            var msg  = packet.ReadString(size);

            var smsg = msg.Split(' ');

            if (msg == "/quit")
            {
                CharacterManagement.UpdatePosition(client.Metadata["syncServer"] as SyncReceiver, (int)client.Metadata["server"], client.AccountID, character.slot, character.map, character.x, character.y);

                client.Disconnect();
                return;
            }

            #region DebugCommands
#if DEBUG
            if (smsg.Length > 1 && string.IsNullOrEmpty(smsg[0]) == false)
            {
                switch (smsg[0])
                {
                case "_drop":
                    int itemid = 0;

                    if (int.TryParse(smsg[1], out itemid))
                    {
                        map.DropItem(x, y, itemid, (uint)id, (uint)id);
                    }

                    break;

                case "_slm":
                    Unknown_86C(packet, builder, client, events);
                    break;

                case "_warp":
                    ushort mapid = 0;
                    ushort curx  = 0;
                    ushort cury  = 0;

                    if (!ushort.TryParse(smsg[1], out mapid))
                    {
                        return;
                    }

                    if (!ushort.TryParse(smsg[2], out curx))
                    {
                        return;
                    }

                    if (!ushort.TryParse(smsg[3], out cury))
                    {
                        return;
                    }

                    var p = client.CreatePacket("PC_WarpCommand", mapid, curx, cury, client);

                    events.Warped("world.Initialized", client, mapid, curx, cury);

                    client.Send(p, "PC_WarpCommand");

                    break;

                case "_levelup":
                    ushort level = 0;

                    var exp = character.stats.exp;

                    if (!ushort.TryParse(smsg[1], out level))
                    {
                        return;
                    }

                    character.stats.exp = 0;


                    /*
                     * builder.New(0x011F); // 3: Increase Hp, 4: Increase Mp, 5: SP, 8: Party Exp Bonus, 9:
                     * {
                     *  builder += (byte)9;
                     *  builder += (uint)0x5;
                     * }*/

                    //client.Send(builder, "LevelUp1");

                    builder.New(0x0120);
                    {
                        builder += (byte)level;
                        builder += character.id;
                    }

                    character.level += 1;

                    client.Send(builder, "LevelUp");

                    NFY_ChargeInfo(packet, builder, client, events);

                    Unknown9D6(packet, builder, client, events);

                    Unknown9E0(packet, builder, client, events);

                    builder.New(0x03F0);
                    {
                        builder += (byte)4;
                        builder += (uint)1428;
                        builder += (uint)1431;
                        builder += (uint)1430;
                        builder += (uint)1429;
                    }

                    client.Send(builder, "Unk3F0");

                    break;

                case "_spawn":
                    ushort mobid  = 0;
                    ushort specid = 0;

                    if (!ushort.TryParse(smsg[1], out mobid))
                    {
                        return;
                    }

                    if (!ushort.TryParse(smsg[2], out specid))
                    {
                        return;
                    }

                    var p1 = client.CreatePacket("MobSpawned", mobid, specid);

                    client.Send(p1, "MobSpawned");

                    break;

                case "/Partytime":
                    uint pid = 1337;

                    foreach (var c in clients)
                    {
                        builder.New(0xC9);
                        {
                            builder += (int)pid;
                            builder += (byte)12;

                            //b = builder.Data;
                        }

                        var timestamp = (uint)c.Metadata["timestamp"];
                        var style     = (uint)c.Metadata["style"];

                        c.Send(builder, "NFY_DelUserList");

                        builder.New(0xC8);
                        {
                            builder += (short)0x3101;
                            builder += (int)pid++;
                            builder += (short)0x000D;
                            builder += (short)0x0100;
                            builder += 1;
                            builder += Environment.TickCount - (int)timestamp;
                            builder += (short)(x + 1);
                            builder += (short)y;
                            builder += (short)(x + 1);
                            builder += (short)y;
                            builder += (byte)0;
                            builder += 0;
                            builder += (short)0;
                            builder += (int)style;
                            builder += (byte)1;
                            builder += (byte)0;
                            builder += 0;
                            builder += 0;
                            builder += (byte)0;

                            var equipment = (List <CItem>)c.Metadata["equipment"];

                            builder += (byte)(equipment.Count);
                            builder += (short)0;
                            builder += (byte)0;
                            builder += 0;

                            name = "PARTY TIME!!";

                            builder += (byte)(name.Length + 1);
                            builder += name;
                            builder += (byte)0;

                            foreach (var e in equipment)
                            {
                                builder += (short)e.ID;
                                builder += e.Slot;
                            }
                        }

                        c.Send(builder, "NFY_NewUserList");
                    }
                    return;
                }
            }
#endif
            #endregion

            builder.New(0xD9);
            {
                builder += id;
                builder += (byte)0;
                builder += (byte)unk;
                builder += (byte)0;
                builder += (byte)(msg.Length + 3);
                builder += (byte)0;
                builder += (byte)254;
                builder += (byte)254;
                builder += type;
                builder += msg;
                builder += new byte[3];
            }

            foreach (var c in clients)
            {
                c.Send(builder, "NFY_MessageEvnt");
            }

            events.SaidLocal("world.MessageEvnt", id, name, msg);
        }