示例#1
0
        public static void SkillToMobs(PacketReader packet, PacketBuilder builder, ClientHandler client, EventHandler events)
        {
            var map     = client.Metadata["map"] as IMap;
            var mapmobs = (client.Metadata["map"] as IMap).GetSurroundingMobs(client, 3);
            var mobdata = map.GetMobsData;



            var skillid = packet.ReadUShort();
            var unk     = packet.ReadInt();
            var unk1    = packet.ReadByte();
            var unk2    = packet.ReadUShort();
            var unk3    = packet.ReadShort();
            var unk4    = packet.ReadByte();
            var dmg     = packet.ReadUInt();
            var unk5    = packet.ReadByte();
            var unk6    = packet.ReadShort();
            var unk7    = packet.ReadShort();
            var unk8    = packet.ReadShort();
            var unk9    = packet.ReadShort();
            var mobid   = packet.ReadShort();
            var unk11   = packet.ReadByte();
            var unk12   = packet.ReadShort();
            var unk13   = packet.ReadShort();

#if DEBUG
            Log.Notice("SkillID:" + skillid + " SkillSlot:" + unk + " unk1:" + unk1 + " unk2:" + unk2 + " unk3:" + unk3 + " unk4:" + unk4 + " dmg:" + dmg + " unk5:" + unk5 + " unk6:" + unk6 + " unk7:" + unk7 + " unk8:" + unk8 + " unk9:" + unk9 + " MobID:" + mobid + " unk11:" + unk11 + " unk12:" + unk12 + " unk13:" + unk13 + "");
#endif

            //packet.Skip(6);
            var attack = packet.ReadUShort();

            Character character = client.Metadata["fullchar"] as Character;
            uint      hp        = character.stats.curhp;
            uint      mp        = character.stats.curmp;

            SkillLoader s         = new SkillLoader();
            var         skilllist = s.LoadSkillData(skillid);
            var         sid       = skilllist.Find(x => x.ID == skillid);

            var char_atk = (int)client.Metadata["patk"];

            if (sid.Type == 1)
            {
                char_atk = (int)client.Metadata["patk"];
            }
            if (sid.Type == 2)
            {
                char_atk = (int)client.Metadata["matk"];
            }

            var mi = mapmobs.Find(x => x.Id == mobid);
            var md = mobdata[mi.SId];

            uint attack_rate = Convert.ToUInt32(new Random().Next(1, 10));

            var normal_atk = char_atk + (sid.Attack + ((sid.Amp / 100) * sid.Attack));

            var mobdef = new Random().Next(md.Defense, md.DefRate);

            var normal_damage = normal_atk - mobdef;
            var crit_damage   = normal_damage + (normal_damage * sid.Critical);

            var damage = 0;

            var atack_result = 0;

            if (attack_rate <= 5)
            {
                atack_result        = 2;
                damage              = normal_damage;
                character.stats.exp = character.stats.exp + (ulong)damage * 2;
            }
            if (attack_rate == 6)
            {
                atack_result        = 1;
                damage              = crit_damage;
                character.stats.exp = character.stats.exp + (ulong)damage * 2;
            }
            if (attack_rate == 7)
            {
                atack_result = 27;
            }

            if (attack_rate >= 8)
            {
                atack_result = 21;
            }

            //Damage Maked
            if (damage < md.Defense && damage > 0)
            {
                damage = new Random().Next(1, 5);
            }

            if (damage >= mi.CurrentHP && damage > 0)
            {
                damage       = mi.CurrentHP;
                mi.CurrentHP = 0;
                //map.DropItem(mi.CurrentPosX, mi.CurrentPosX, 13, 1,1);
            }
            else
            {
                mi.CurrentHP = mi.CurrentHP - damage;
            }


            var exp      = character.stats.exp;
            var skillexp = character.stats.swordrank + sid.Attack;


            builder.New(0x00AE);
            {
                builder += (ushort)skillid;     //skillid
                builder += hp;                  //Hp
                builder += mp;                  //Mp
                builder += (ushort)0;           //SP
                builder += (ulong)exp;          //Exp
                builder += (ulong)0;            //OXP
                builder += (ulong)skillexp;     //SkillEXP

                builder += new byte[26];

                builder += (uint)0xFFFFFFFF;
                builder += (byte)0;
                builder += hp;
                builder += (uint)0;

                builder += (byte)1;

                builder += (byte)mobid;

                builder += (byte)0;

                builder += (byte)map.ID;
                builder += (byte)2;
                builder += (byte)2;

                builder += (byte)atack_result;

                builder += (int)damage;

                builder += (int)mi.CurrentHP;

                builder += new byte[12];
                builder += (byte)1;
            }

            client.Send(builder, "SkillToMobs");

            if (mi.CurrentHP == 0)
            {
                mi.Spawn = Environment.TickCount + md.Respawn * 10;

                mapmobs.Remove(mi);
            }
        }
示例#2
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);
        }
示例#3
0
        public static void SkillToUser(PacketReader packet, PacketBuilder builder, ClientHandler client, EventHandler events)
        {
            var clients = (client.Metadata["map"] as IMap).GetSurroundingClients(client, 2);

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

            var skill = packet.ReadShort();

            if (skill == 0x014C)
            {
                var unk2 = packet.ReadByte();
                var unk3 = packet.ReadShort();
                var unk4 = packet.ReadInt();

                builder.New(0xAF);
                {
                    builder += skill;
                    builder += (short)0x08;
                    builder += unk3;
                    builder += unk4;
                }

                client.Send(builder, "SkillToUser");

                builder.New(0xDD);
                {
                    builder += skill;
                    builder += id;
                    builder += 0x0D;
                    builder += (short)0x0200;
                    builder += unk3;
                    builder += unk4;
                }

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

            if (skill == 0x00D1)
            {
                var unk2 = packet.ReadByte();
                var x    = packet.ReadShort();
                var y    = packet.ReadShort();

                builder.New(0xAF);
                {
                    builder += skill;
                    builder += 0;
                    builder += (short)0x039C;
                }

                client.Send(builder, "SkillToUser");

                builder.New(0xDD);
                {
                    builder += skill;
                    builder += id;
                    builder += 1;
                    builder += x;
                    builder += y;
                }

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

            if (skill == 0x00D0)
            {
                var unk2 = packet.ReadByte();
                var x    = packet.ReadShort();
                var y    = packet.ReadShort();

                builder.New(0xAF);
                {
                    builder += skill;
                    builder += 0;
                    builder += (short)0x0395;
                }

                client.Send(builder, "SkillToUser");

                builder.New(0xDD);
                {
                    builder += skill;
                    builder += id;
                    builder += 1;
                    builder += x;
                    builder += y;
                }

                foreach (var c in clients)
                {
                    c.Send(builder, "NFY_SkillToUser");
                }
            }
        }
示例#4
0
        public static void ChangeMapCell(PacketReader packet, PacketBuilder builder, ClientHandler client, EventHandler events)
        {
            //byte[] b;

            packet.Skip(4);
            var x = packet.ReadShort();
            var y = packet.ReadShort();

            var map = client.Metadata["map"] as IMap;

            map.MoveClient(client, x / 16, y / 16);

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

            if (clients.Count > 1)
            {
                builder.New(0xC8);
                {
                    builder += (short)(clients.Count - 1);

                    foreach (var c in clients)
                    {
                        if (c == client)
                        {
                            continue;
                        }
                        //if (!c.Metadata.ContainsKey("id") || (uint)c.Metadata["cid"] == 0) continue;

                        var id        = (uint)c.Metadata["cid"];
                        var level     = (uint)c.Metadata["level"];
                        var timestamp = (uint)c.Metadata["timestamp"];
                        var px        = (ushort)c.Metadata["x"];
                        var py        = (ushort)c.Metadata["y"];
                        var dx        = (ushort)c.Metadata["dest_x"];
                        var dy        = (ushort)c.Metadata["dest_y"];
                        var style     = (uint)c.Metadata["style"];

                        builder += (int)id;
                        builder += (short)0x000D;
                        builder += (short)0x0100;
                        builder += (int)level;
                        builder += Environment.TickCount - (int)timestamp;
                        builder += (short)px;
                        builder += (short)py;
                        builder += (short)dx;
                        builder += (short)dy;
                        builder += (byte)0;                             // PK penalty
                        builder += 0;
                        builder += (short)0;
                        builder += (int)style;
                        builder += (byte)0;                             // Animation ID
                        builder += 0;
                        builder += 0;
                        builder += (byte)0;
                        builder += (byte)0;                             // 1 = dead

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

                        builder += (byte)equipment.Count;
                        builder += (short)0;
                        builder += (byte)0;                             // 1 = has private shop open
                        builder += 0;

                        var name = c.Metadata["name"] as string;

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

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

                    //b = builder.Data;
                }

                client.Send(builder, "UnknownPacket_0xC8");

                // nested wooooooo!
                {
                    var id        = (uint)client.Metadata["cid"];
                    var level     = (uint)client.Metadata["level"];
                    var timestamp = (uint)client.Metadata["timestamp"];
                    var px        = (ushort)client.Metadata["x"];
                    var py        = (ushort)client.Metadata["y"];
                    var dx        = (ushort)client.Metadata["dest_x"];
                    var dy        = (ushort)client.Metadata["dest_y"];
                    var style     = (uint)client.Metadata["style"];

                    builder.New(0xC8);
                    {
                        builder += (ushort)0x3101;
                        builder += (int)id;
                        builder += (short)0x000D;
                        builder += (short)0x0100;
                        builder += (int)level;
                        builder += Environment.TickCount - (int)timestamp;
                        builder += (short)px;
                        builder += (short)py;
                        builder += (short)dx;
                        builder += (short)dy;
                        builder += (byte)0;                             // PK penalty
                        builder += 0;
                        builder += (short)0;
                        builder += (int)style;
                        builder += (byte)0;                             // Animation ID
                        builder += 0;
                        builder += 0;
                        builder += (byte)0;
                        builder += (byte)0;                             // 1 = dead

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

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

                        var name = client.Metadata["name"] as string;

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

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

                        //b = builder.Data;
                    }

                    foreach (var c in clients)
                    {
                        if (c == client)
                        {
                            continue;
                        }

                        //var b2 = b;

                        c.Send(builder, "UnknownPacket_0xC8");
                    }
                }
            }
        }