Example #1
0
 private bool ServerMessage_0x29_Animations(Client client, ServerPacket msg)
 {
     try
     {
         uint           index     = msg.ReadUInt32();
         uint           From      = msg.ReadUInt32();
         ushort         number    = msg.ReadUInt16();
         uint           Speed     = msg.ReadUInt32();
         SpellAnimation animation = new SpellAnimation(index, From, number, Speed);
         if ((int)index == (int)client.Base.Serial)
         {
             client.Base.Animations.Add(animation);
         }
         if (client.Base.Entitys.ContainsKey(index))
         {
             client.Base.Entitys[index].OnAnimation((object)null, new EntityArgs(client.Base[index], animation));
         }
         if (client.Base.Aislings.ContainsKey(index))
         {
             client.Base.Aislings[index].OnAnimation((object)null, new EntityArgs(client.Base[index], animation));
         }
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
         return(false);
     }
 }
Example #2
0
 private bool ServerMessage_0x0E_SpriteRemoved(Client client, ServerPacket msg)
 {
     try
     {
         client.ShouldUpdateMap = true;
         uint key = msg.ReadUInt32();
         if (client.Base.Entitys.ContainsKey(key) && client.Base.Entitys[key].Type == EntityType.Monster)
         {
             client.Base.LastEntityRemovedLocation = client.Base.Entitys[key].Position;
             client.Base.LastEntityRemoved         = DateTime.Now;
         }
         if (client.Base.Entitys.ContainsKey(key))
         {
             client.Base.Entitys.Remove(key);
         }
         if (client.Base.Aislings.ContainsKey(key))
         {
             client.Base.Aislings[key].lastMap = client.Base.DaMap.Number;
         }
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
         return(false);
     }
 }
Example #3
0
 private bool ServerMessage_0x11_SpriteTurned(Client client, ServerPacket msg)
 {
     try
     {
         uint      key       = msg.ReadUInt32();
         Direction direction = (Direction)msg.ReadByte();
         if ((int)key == (int)client.Base.Serial)
         {
             client.Base.MyPosition.Facing = direction;
         }
         if (client.Base.Entitys.ContainsKey(key))
         {
             client.Base.Entitys[key].Position.Facing = direction;
         }
         if (client.Base.Aislings.ContainsKey(key))
         {
             client.Base.Aislings[key].Position.Facing = direction;
         }
         //if (client.Base.Players.ContainsKey(key))
         //    client.Base.Players[key].Position.Facing = direction;
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
         return(false);
     }
 }
Example #4
0
 private bool ServerMessage_0x2F_DialogResponse(Client client, ServerPacket msg)
 {
     try
     {
         if ((int)msg.ReadByte() != 10)
         {
             int num1   = (int)msg.ReadByte();
             int serial = (int)msg.ReadUInt32();
             msg.Read(16);
             msg.Seek(29, PacketSeekOrigin.Begin); //goto 29
             string response = msg.ReadString();
             client.Base.currentDialogResponse = response;
             int result =
                 // The Convert (System) class comes in pretty handy every time
                 // you want to convert something.
                 Convert.ToInt32(
                     Regex.Replace(
                         client.Base.currentDialogResponse, // Our input
                         "[^0-9]",                          // Select everything that is not in the range of 0-9
                         ""                                 // Replace that with an empty string.
                         ));
             client.Base.dialogNumber = result;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
         return(false);
     }
     return(true);
 }
Example #5
0
        private bool ServerMessage_0x0C_SpriteWalked(Client client, ServerPacket msg)
        {
            try
            {
                uint     key      = msg.ReadUInt32();
                ushort   num1     = msg.ReadUInt16();
                ushort   num2     = msg.ReadUInt16();
                byte     num3     = msg.ReadByte();
                Location location = new Location()
                {
                    X      = num1,
                    Y      = num2,
                    Facing = (Direction)num3
                };
                switch (location.Facing)
                {
                case Direction.Up:
                    --location.Y;
                    break;

                case Direction.Right:
                    ++location.X;
                    break;

                case Direction.Down:
                    ++location.Y;
                    break;

                case Direction.Left:
                    --location.X;
                    break;
                }
                if (client.Base.Entitys.ContainsKey(key))
                {
                    client.Base.Entitys[key].Position = location;
                }
                if (client.Base.Aislings.ContainsKey(key))
                {
                    client.Base.Aislings[key].Position = location;
                }
                client.ShouldUpdateMap = true;
                //if (client.Base.Players.ContainsKey(key))
                //    client.Base.Players[key].Position = location;
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
                return(false);
            }
        }
Example #6
0
 private bool ServerMessage_0x0F_SItemAdded(Client client, ServerPacket msg)
 {
     try
     {
         Item obj = new Item()
         {
             Slot              = msg.ReadByte(),
             IconSet           = msg.ReadUInt16(),
             Icon              = msg.ReadByte(),
             Name              = msg.ReadString8(),
             Amount            = msg.ReadUInt32(),
             Stackable         = msg.ReadBoolean(),
             CurrentDurability = msg.ReadUInt32(),
             MaximumDurability = msg.ReadUInt32()
         };
         client.Base.Inventory.Add(obj);
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
         return(false);
     }
 }
Example #7
0
 private bool ServerMessage_0x1A_SpriteAnimation(Client client, ServerPacket msg)
 {
     try
     {
         SpriteAnimation spriteAnimation = new SpriteAnimation(msg.ReadUInt32(), msg.ReadByte());
         if ((int)spriteAnimation.Serial == (int)client.Base.Serial && ((int)spriteAnimation.Animation == 1 || (int)spriteAnimation.Animation == 129 || (int)spriteAnimation.Animation == 139 || (int)spriteAnimation.Animation == 132))
         {
             ++client.Base.BodySwings;
         }
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
         return(false);
     }
 }
Example #8
0
 private bool ServerMessage_0x13_SpriteHPBar(Client client, ServerPacket msg)
 {
     try
     {
         uint key  = msg.ReadUInt32();
         int  num1 = (int)msg.ReadByte();
         byte num2 = msg.ReadByte();
         msg.ReadByte();
         if (client.Base.Entitys.ContainsKey(key))
         {
             client.Base.Entitys[key].LastAttacked = DateTime.Now;
             ++client.Base.Entitys[key].TimesHit;
             client.Base.Entitys[key].HPPercent = num2;
             if ((int)num2 <= 40)
             {
                 client.Base.Entitys[key].LowHpTime = DateTime.Now;
             }
             client.Base.BodySwings = 0;
         }
         if (client.Base.Aislings.ContainsKey(key))
         {
             client.Base.Aislings[key].LastAttacked = DateTime.Now;
             ++client.Base.Aislings[key].TimesHit;
             client.Base.Aislings[key].HPPercent = num2;
             if ((int)num2 <= 40)
             {
                 client.Base.Aislings[key].LowHpTime = DateTime.Now;
             }
             client.Base.BodySwings = 0;
         }
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
         return(false);
     }
 }
Example #9
0
        public bool ServerMessage_0x05_PlayerID(Client client, ServerPacket msg)
        {
            try
            {
                uint Serial = msg.ReadUInt32();
                client.Base.Serial = Serial;
                client.Base.Me     = new Aisling()
                {
                    Name     = "noname",
                    Position = new Location(),
                    Serial   = Serial
                };

                Form.AddTab(client.Tab);

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
                return(false);
            }
        }
Example #10
0
        public bool ServerMessage_0x03_Redirect(Client client, ServerPacket msg)
        {
            var address = msg.Read(4);
            var port    = msg.ReadUInt16();
            var length  = msg.ReadByte();
            var seed    = msg.ReadByte();
            var key     = msg.Read(msg.ReadByte());
            var name    = msg.ReadString8();
            var id      = msg.ReadUInt32();

            Array.Reverse(address);
            RemoteEndPoint = new IPEndPoint(new IPAddress(address), port);

            msg.Data[0] = 0x01;
            msg.Data[1] = 0x00;
            msg.Data[2] = 0x00;
            msg.Data[3] = 0x7F;

            msg.Data[4] = 0x0A;
            msg.Data[5] = 0x32;

            return(true);
        }
Example #11
0
        private bool ServerMessage_0x33_PlayerAdded(Client client, ServerPacket msg)
        {
            try
            {
                /*if ((int)msg.BodyData[10] == 0 && (int)msg.BodyData[11] == 0 && (int)msg.BodyData[12] == 0 && (int)msg.BodyData[13] == 0)
                 * {
                 *  msg.BodyData[10] = (byte)165;
                 *  msg.BodyData[11] = (byte)16;
                 *  msg.BodyData[12] = (byte)0;
                 *  msg.BodyData[13] = (byte)177;
                 * }*/
                try
                {
                    ushort num1 = msg.ReadUInt16();
                    ushort num2 = msg.ReadUInt16();
                    byte   num3 = msg.ReadByte();
                    uint   key  = msg.ReadUInt32();
                    msg.ReadUInt16();
                    int num4 = (int)msg.ReadUInt16();
                    int num5 = (int)msg.ReadUInt32();
                    msg.ReadByte();
                    ushort num6 = msg.ReadUInt16();
                    msg.ReadByte();
                    int num7 = (int)msg.ReadByte();
                    msg.ReadUInt16();
                    int num8 = (int)msg.ReadInt16();
                    msg.ReadUInt16();
                    int num9 = (int)msg.ReadUInt32();
                    msg.ReadByte();
                    msg.ReadUInt16();
                    int num10 = (int)msg.ReadUInt16();
                    msg.ReadByte();
                    int    num11 = (int)msg.ReadUInt16();
                    string str   = msg.ReadString8();
                    msg.ReadString8();
                    if (string.IsNullOrEmpty(str))
                    {
                        str = "f****t";
                    }

                    if (client.Base.Aislings[client.Base.Serial].Position.X != num1 || client.Base.Aislings[client.Base.Serial].Position.Y != num2)
                    {
                        client.ShouldUpdateMap = true;
                    }
                    //add players to onscreen players array
                    if ((int)client.Base.Serial == (int)key)
                    {
                        client.Base.Me.Name     = str;
                        client.Base.Me.Position = new Location()
                        {
                            X = num1,
                            Y = num2
                        };
                        client.Base.CurrentStaffID    = num6;
                        client.Base.MyPosition.X      = num1;
                        client.Base.MyPosition.Y      = num2;
                        client.Base.MyPosition.Facing = (Direction)num3;
                    }
                    else if (!client.Base.Entitys.ContainsKey(key))
                    {
                        client.Base.Entitys.Add(key, new Aisling()
                        {
                            Name     = str,
                            Position = new Location()
                            {
                                Facing = (Direction)num3,
                                X      = num1,
                                Y      = num2,
                            },
                            Serial = key,
                            Map    = client.Base.DaMap.Number
                        });
                    }
                    else
                    {
                        client.Base.Entitys[key].Name     = str;
                        client.Base.Entitys[key].Position = new Location()
                        {
                            X      = num1,
                            Y      = num2,
                            Facing = (Direction)num3
                        };
                        client.Base.Entitys[key].Map = client.Base.DaMap.Number;
                    }

                    /*else if (!client.Base.Players.ContainsKey(key))
                     * {
                     *  client.Base.Players.Add(key, new Aisling()
                     *  {
                     *      Name = str,
                     *      Position = new Location()
                     *      {
                     *          Facing = (Direction)num3,
                     *          X = num1,
                     *          Y = num2
                     *      },
                     *      Serial = key
                     *  });
                     * }
                     * else
                     * {
                     *  client.Base.Players[key].Name = str;
                     *  client.Base.Players[key].Position = new Location()
                     *  {
                     *      X = num1,
                     *      Y = num2,
                     *      Facing = (Direction)num3
                     *  };
                     * }*/
                    //add players to lasting seen players array
                    if (!client.Base.Aislings.ContainsKey(key))
                    {
                        client.Base.Aislings.Add(key, new Aisling()
                        {
                            Name     = str,
                            Position = new Location()
                            {
                                Facing = (Direction)num3,
                                X      = num1,
                                Y      = num2
                            },
                            Serial = key,
                            Map    = client.Base.DaMap.Number
                        });
                    }
                    else
                    {
                        client.Base.Aislings[key].Name     = str;
                        client.Base.Aislings[key].Position = new Location()
                        {
                            X      = num1,
                            Y      = num2,
                            Facing = (Direction)num3
                        };
                        client.Base.Aislings[key].Map = client.Base.DaMap.Number;
                        if (client.Base.Aislings[key].Map == client.Base.Aislings[key].lastMap)
                        {
                            client.Base.Aislings[key].lastMap = -1;
                        }
                    }
                }
                catch
                {
                    msg.Seek(0, PacketSeekOrigin.Begin);
                    ushort num1 = msg.ReadUInt16();
                    ushort num2 = msg.ReadUInt16();
                    byte   num3 = msg.ReadByte();
                    uint   key  = msg.ReadUInt32();
                    if ((int)client.Base.Serial == (int)key)
                    {
                        client.Base.Me.Name     = "form";
                        client.Base.Me.Position = client.Base.MyPosition;
                    }

                    /*else if (!client.Base.Players.ContainsKey(key))
                     * {
                     *  client.Base.Players.Add(key, new Aisling()
                     *  {
                     *      Name = "form",
                     *      Position = new Location()
                     *      {
                     *          Facing = (Direction)num3,
                     *          X = num1,
                     *          Y = num2
                     *      },
                     *      Serial = key
                     *  });
                     * }
                     * else
                     * {
                     *  client.Base.Players[key].Name = "form";
                     *  client.Base.Players[key].Position = new Location()
                     *  {
                     *      X = num1,
                     *      Y = num2,
                     *      Facing = (Direction)num3
                     *  };
                     * }*/

                    else if (!client.Base.Entitys.ContainsKey(key))
                    {
                        client.Base.Entitys.Add(key, new Aisling()
                        {
                            Name     = "form",
                            Position = new Location()
                            {
                                Facing = (Direction)num3,
                                X      = num1,
                                Y      = num2
                            },
                            Serial = key,
                            Map    = client.Base.DaMap.Number
                        });
                    }
                    else
                    {
                        client.Base.Entitys[key].Name     = "form";
                        client.Base.Entitys[key].Position = new Location()
                        {
                            X      = num1,
                            Y      = num2,
                            Facing = (Direction)num3
                        };
                        client.Base.Entitys[key].Map = client.Base.DaMap.Number;
                    }
                    //add players to lasting seen players array
                    if (!client.Base.Aislings.ContainsKey(key))
                    {
                        client.Base.Aislings.Add(key, new Aisling()
                        {
                            Name     = "form",
                            Position = new Location()
                            {
                                Facing = (Direction)num3,
                                X      = num1,
                                Y      = num2
                            },
                            Serial = key,
                            Map    = client.Base.DaMap.Number
                        });
                    }
                    else
                    {
                        client.Base.Aislings[key].Name     = "form";
                        client.Base.Aislings[key].Position = new Location()
                        {
                            X      = num1,
                            Y      = num2,
                            Facing = (Direction)num3
                        };
                        client.Base.Aislings[key].Map = client.Base.DaMap.Number;
                        if (client.Base.Aislings[key].Map == client.Base.Aislings[key].lastMap)
                        {
                            client.Base.Aislings[key].lastMap = -1;
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
                return(false);
            }
        }
Example #12
0
 private bool ServerMessage_0x08_StatsUpdated(Client client, ServerPacket msg)
 {
     try
     {
         Aisling aisling = client.Base.Me;
         byte    num1    = msg.ReadByte();
         if (((int)num1 & 32) == 32)
         {
             msg.Read(3);
             aisling.Level     = (int)msg.ReadByte();
             aisling.Ability   = (int)msg.ReadByte();
             aisling.MaximumHP = msg.ReadUInt32();
             aisling.MaximumMP = msg.ReadUInt32();
             aisling.Str       = (int)msg.ReadByte();
             aisling.Int       = (int)msg.ReadByte();
             aisling.Wis       = (int)msg.ReadByte();
             aisling.Con       = (int)msg.ReadByte();
             aisling.Dex       = (int)msg.ReadByte();
             bool flag = (int)msg.ReadByte() != 0;
             aisling.AvailablePoints = (int)msg.ReadByte();
             aisling.MaximumWeight   = (int)msg.ReadUInt16();
             aisling.CurrentWeight   = (int)msg.ReadUInt16();
             msg.Read(4);
         }
         if (((int)num1 & 16) == 16)
         {
             aisling.CurrentHP = msg.ReadUInt32();
             aisling.CurrentMP = msg.ReadUInt32();
         }
         if (((int)num1 & 8) == 8)
         {
             aisling.Experience    = msg.ReadUInt32();
             aisling.ToNextLevel   = msg.ReadUInt32();
             aisling.AbilityExp    = msg.ReadUInt32();
             aisling.ToNextAbility = msg.ReadUInt32();
             aisling.GamePoints    = msg.ReadUInt32();
             aisling.Gold          = msg.ReadUInt32();
         }
         if (((int)num1 & 4) == 4)
         {
             aisling.BitMask = (int)msg.ReadUInt16();
             int num2 = (int)msg.ReadByte();
             aisling.AttackElement2  = (int)msg.ReadByte();
             aisling.DefenseElement2 = (int)msg.ReadByte();
             aisling.AttackElement   = (Aisling.Elements)msg.ReadByte();
             aisling.DefenseElement  = (Aisling.Elements)msg.ReadByte();
             aisling.MagicResistance = (int)msg.ReadByte();
             aisling.ArmorClass      = (int)msg.ReadInt16();
             aisling.Damage          = (int)msg.ReadSByte();
             aisling.Hit             = (int)msg.ReadSByte();
         }
         if (aisling.BitMask == 8)
         {
             msg.Data[0] = (byte)0;
         }
         client.Base.Me = aisling;
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
         return(false);
     }
 }