Ejemplo n.º 1
0
 public Skill(DatabaseQuery query)
 {
     this.MapleID    = query.GetInt("maple_id");
     this.Level      = query.GetByte("level");
     this.MaxLevel   = query.GetByte("max_level");
     this.Expiration = query.GetDateTime("expiration");
 }
Ejemplo n.º 2
0
 public Account(DatabaseQuery query)
 {
     this.ID       = query.GetInt("account_id");
     this.Username = query.GetString("username");
     this.Password = query.GetString("password");
     this.Salt     = query.GetString("salt");
     this.GmLevel  = (GmLevel)query.GetByte("gm_level");
 }
Ejemplo n.º 3
0
 public Equip(DatabaseQuery query)
     : base(query)
 {
     this.Slots         = query.GetByte("slots");
     this.Scrolls       = query.GetByte("scrolls");
     this.Strength      = query.GetShort("strength");
     this.Dexterity     = query.GetShort("dexterity");
     this.Intelligence  = query.GetShort("intelligence");
     this.Luck          = query.GetShort("luck");
     this.Health        = query.GetShort("health");
     this.Mana          = query.GetShort("mana");
     this.WeaponAttack  = query.GetShort("weapon_attack");
     this.MagicAttack   = query.GetShort("magic_attack");
     this.WeaponDefense = query.GetShort("weapon_defense");
     this.MagicDefense  = query.GetShort("magic_defense");
     this.Accuracy      = query.GetShort("accuracy");
     this.Avoidability  = query.GetShort("avoidability");
     this.Hands         = query.GetShort("hands");
     this.Speed         = query.GetShort("speed");
     this.Jump          = query.GetShort("jump");
 }
Ejemplo n.º 4
0
        public CharacterStats(Character parent, DatabaseQuery query)
        {
            this.Parent = parent;

            this.Gender        = (Gender)query.GetByte("gender");
            this.Skin          = query.GetByte("skin");
            this.Face          = query.GetInt("face");
            this.Hair          = query.GetInt("hair");
            this.Level         = query.GetByte("level");
            this.Job           = (Job)query.GetShort("job");
            this.Strength      = query.GetShort("strength");
            this.Dexterity     = query.GetShort("dexterity");
            this.Intelligence  = query.GetShort("intelligence");
            this.Luck          = query.GetShort("luck");
            this.Health        = query.GetShort("health");
            this.MaxHealth     = query.GetShort("max_health");
            this.Mana          = query.GetShort("mana");
            this.MaxMana       = query.GetShort("max_mana");
            this.AbilityPoints = query.GetShort("ability_points");
            this.SkillPoints   = query.GetShort("skill_points");
            this.Experience    = query.GetInt("experience");
            this.Fame          = query.GetShort("fame");
            this.Mesos         = query.GetInt("mesos");
        }
Ejemplo n.º 5
0
        public CharacterItems(Character parent, byte[] slots, DatabaseQuery query)
            : base()
        {
            this.Parent = parent;

            mEquipped     = new Item[51];
            mCashEquipped = new Item[51];
            mItems        = new Item[(byte)InventoryType.Count][];

            for (byte i = 1; i < slots.Length; i++)
            {
                mItems[i] = new Item[slots[i]];
            }

            while (query.NextRow())
            {
                short slot = query.GetShort("slot");

                if (slot < 0)
                {
                    if (slot < -100)
                    {
                        mCashEquipped[(-slot) - 100] = new Equip(query);
                    }
                    else
                    {
                        mEquipped[-slot] = new Equip(query);
                    }
                }
                else
                {
                    byte inventory = query.GetByte("inventory");

                    if (inventory == (byte)InventoryType.Equipment)
                    {
                        mItems[inventory][slot] = new Equip(query);
                    }
                    else
                    {
                        mItems[inventory][slot] = new Item(query);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private static void AddCharacterEntry(OutPacket oPacket, DatabaseQuery query)
        {
            oPacket
            .WriteInt(query.GetInt("character_id"))
            .WritePaddedString(query.GetString("name"), 13)
            .WriteByte(query.GetByte("gender"))
            .WriteByte(query.GetByte("skin"))
            .WriteInt(query.GetInt("face"))
            .WriteInt(query.GetInt("hair"))
            .WriteLong()
            .WriteLong()
            .WriteLong()
            .WriteByte(query.GetByte("level"))
            .WriteShort(query.GetShort("job"))
            .WriteShort(query.GetShort("strength"))
            .WriteShort(query.GetShort("dexterity"))
            .WriteShort(query.GetShort("intelligence"))
            .WriteShort(query.GetShort("luck"))
            .WriteShort(query.GetShort("health"))
            .WriteShort(query.GetShort("max_health"))
            .WriteShort(query.GetShort("mana"))
            .WriteShort(query.GetShort("max_mana"))
            .WriteShort(query.GetShort("ability_points"))
            .WriteShort(query.GetShort("skill_points"))
            .WriteInt(query.GetInt("experience"))
            .WriteShort(query.GetShort("fame"))
            .WriteInt()
            .WriteInt(query.GetInt("map"))
            .WriteByte(query.GetByte("spawn_point"))
            .WriteInt();

            oPacket
            .WriteByte(query.GetByte("gender"))
            .WriteByte(query.GetByte("skin"))
            .WriteInt(query.GetInt("face"))
            .WriteBool(true)
            .WriteInt(query.GetInt("hair"));

            SortedDictionary <byte, Doublet <int, int> > equipment = new SortedDictionary <byte, Doublet <int, int> >();

            using (DatabaseQuery equipmentQuery = Database.Query("SELECT `slot`, `maple_id` FROM `items` WHERE `character_id` = @character_id AND `inventory` = 1 AND `slot` < 0", new MySqlParameter("@character_id", query.GetInt("character_id"))))
            {
                while (equipmentQuery.NextRow())
                {
                    short slot = (short)(-(equipmentQuery.GetShort("slot")));

                    if (slot > 100)
                    {
                        slot -= 100;
                    }

                    Doublet <int, int> pair = equipment.GetOrDefault((byte)slot, null);

                    if (pair == null)
                    {
                        pair = new Doublet <int, int>(equipmentQuery.GetInt("maple_id"), 0);
                        equipment.Add((byte)slot, pair);
                    }
                    else if (equipmentQuery.GetShort("slot") < -100)
                    {
                        pair.Second = pair.First;
                        pair.First  = equipmentQuery.GetInt("maple_id");
                    }
                    else
                    {
                        pair.Second = (int)equipmentQuery["maple_id"];
                    }
                }
            }

            foreach (KeyValuePair <byte, Doublet <int, int> > pair in equipment)
            {
                oPacket.WriteByte(pair.Key);

                if (pair.Key == 11 && pair.Value.Second > 0)
                {
                    oPacket.WriteInt(pair.Value.Second);
                }
                else
                {
                    oPacket.WriteInt(pair.Value.First);
                }
            }
            oPacket.WriteByte(byte.MaxValue);

            foreach (KeyValuePair <byte, Doublet <int, int> > pair in equipment)
            {
                if (pair.Key != 11 && pair.Value.Second > 0)
                {
                    oPacket
                    .WriteByte(pair.Key)
                    .WriteInt(pair.Value.Second);
                }
            }
            oPacket.WriteByte(byte.MaxValue);

            Doublet <int, int> cashWeapon = equipment.GetOrDefault((byte)11, null);

            oPacket
            .WriteInt(cashWeapon == null ? 0 : cashWeapon.First)
            .WriteZero(12)
            .WriteByte()
            .WriteBool();
        }
Ejemplo n.º 7
0
        public Character(MapleClient client, DatabaseQuery query, bool cashShop = false)
             : base()
        {
            this.Client = client;

            this.ID = query.GetInt("character_id");
            this.Name = query.GetString("name");
            this.Stats = new CharacterStats(this, query);

            int mapID = query.GetInt("map");
            byte spawnPoint = query.GetByte("spawn_point");

            if (this.IsGm) // NOTE: Gms are spawned in the Gm map by default to avoid being seen by other players.
            {
                mapID = 180000000;
                spawnPoint = 0;
            }
            else if (MasterServer.Instance.Data.Maps[mapID].ForcedReturnMapID != MapData.INVALID_MAP_ID)
            {
                mapID = MasterServer.Instance.Data.Maps[mapID].ForcedReturnMapID;
                spawnPoint = 0; // TODO: Should it be randomized?
            }
            else if (!MasterServer.Instance.Data.Maps.ContainsKey(mapID)) // NOTE: Just in case the user purposely edits a wrong map in the database.
            {
                mapID = 100000000;
                spawnPoint = 0;
            }

            this.Map = MasterServer.Instance.Worlds[this.Client.World].Channels[this.Client.Channel].Maps[mapID];
            this.SpawnPoint = spawnPoint;

            this.Position = this.Map.Portals[this.SpawnPoint].Position;
            this.Foothold = 0;
            this.Stance = 0;

            using (DatabaseQuery itemQuery = Database.Query("SELECT * FROM `items` WHERE `character_id` = @character_id", new MySqlParameter("character_id", this.ID)))
            {
                byte[] slots = new byte[(byte)InventoryType.Count];

                slots[(byte)InventoryType.Equipment] = query.GetByte("equipment_slots");
                slots[(byte)InventoryType.Usable] = query.GetByte("usable_slots");
                slots[(byte)InventoryType.Setup] = query.GetByte("setup_slots");
                slots[(byte)InventoryType.Etcetera] = query.GetByte("etcetera_slots");
                slots[(byte)InventoryType.Cash] = query.GetByte("cash_slots");

                this.Items = new CharacterItems(this, slots, itemQuery);
            }

            using (DatabaseQuery skillQuery = Database.Query("SELECT * FROM `skills` WHERE `character_id` = @character_id", new MySqlParameter("character_id", this.ID)))
            {
                this.Skills = new CharacterSkills(this, skillQuery);
            }

            using (DatabaseQuery questQuery = null)
            {
                this.Quests = new CharacterQuests(this, questQuery);
            }

            this.ControlledMobs = new ControlledMobs(this);
            this.ControlledNpcs = new ControlledNpcs(this);
        }