예제 #1
0
 public Equip(Equip itemBase)
 {
     ItemID = itemBase.ItemID;
     InventoryId = itemBase.InventoryId;
     InventorySlot = itemBase.InventorySlot;
     Slots = itemBase.Slots;
     Scrolls = itemBase.Scrolls;
     Str = itemBase.Str;
     Dex = itemBase.Dex;
     Int = itemBase.Int;
     Luk = itemBase.Luk;
     HP = itemBase.HP;
     MP = itemBase.MP;
     Watk = itemBase.Watk;
     Matk = itemBase.Matk;
     Wdef = itemBase.Wdef;
     Mdef = itemBase.Mdef;
     Acc = itemBase.Acc;
     Avo = itemBase.Avo;
     Hands = itemBase.Hands;
     Jump = itemBase.Jump;
     Speed = itemBase.Speed;
     CashId = itemBase.CashId;
     Expiration = itemBase.Expiration;
     Name = itemBase.Name;
     Pet = itemBase.Pet;
     Level = itemBase.Level;
     ItemLevel = itemBase.ItemLevel;
     ItemEXP = itemBase.ItemEXP;
 }
예제 #2
0
        public Drop(int mapid, Equip item, Pos position, int owner, bool playerdrop = false, int dropperid = 0)
        {
            QuestID = 0;
            Owner = owner;
            MapID = mapid;
            ItemData = item;
            PlayerID = 0;
            PlayerDrop = playerdrop;
            Type = (byte)DropType.Normal;
            Tradable = true;
            Position = position;
            Mesos = 0;
            Droptime = DateTime.Now;
            DropperID = dropperid;

            Master.Instance.DataProvider.Maps[MapID].AddDrop(this);
        }
예제 #3
0
        public static void HandleCreateCharacter(Client pClient, Packet pPacket)
        {
            if (pClient.Account.LoggedIn != 1) { return; }

            List<Equip> equips = new List<Equip>();

            string name = pPacket.ReadMapleString();
            pPacket.ReadInt();

            int startMap = 0;

            int jobType = pPacket.ReadInt();
            short jobSubtype = pPacket.ReadShort();
            byte gender = pPacket.ReadByte();
            byte skin = pPacket.ReadByte();
            pPacket.ReadByte();
            int face = pPacket.ReadInt();
            int hair = pPacket.ReadInt();
            int hairColor = -1, faceMark = -1, topId, bottomId = -1, capeId = -1, shoesId, weaponId, shieldId = -1;

            if (Constants.CharacterCreation.hasHairColor(jobType))
                hairColor = pPacket.ReadInt();
            if (Constants.CharacterCreation.hasSkinColor(jobType))
                pPacket.ReadInt();
            if (Constants.CharacterCreation.hasFaceMark(jobType))
                faceMark = pPacket.ReadInt();
            if (Constants.CharacterCreation.hasHat(jobType))
            {
                int capId = pPacket.ReadInt();
                Equip cap = new Equip();
                cap.ItemID = capId;
                cap.GiveStats(false);
                cap.InventorySlot = -1;

                equips.Add(cap);
            }
            topId = pPacket.ReadInt();
            Equip top = new Equip();
            top.ItemID = topId;
            top.GiveStats(false);
            top.InventorySlot = -5;

            equips.Add(top);
            if (Constants.CharacterCreation.hasBottom(jobType))
            {
                bottomId = pPacket.ReadInt();
                Equip bottom = new Equip();
                bottom.ItemID = bottomId;
                bottom.GiveStats(false);
                bottom.InventorySlot = -6;

                equips.Add(bottom);
            }
            if (Constants.CharacterCreation.hasCape(jobType))
            {
                capeId = pPacket.ReadInt();
                Equip cape = new Equip();
                cape.ItemID = capeId;
                cape.GiveStats(false);
                cape.InventorySlot = -9;

                equips.Add(cape);
            }
            shoesId = pPacket.ReadInt();
            Equip shoes = new Equip();
            shoes.ItemID = shoesId;
            shoes.GiveStats(false);
            shoes.InventorySlot = -7;

            equips.Add(shoes);
            weaponId = pPacket.ReadInt();
            Equip weapon = new Equip();
            weapon.ItemID = weaponId;
            weapon.GiveStats(false);
            weapon.InventorySlot = -11;

            equips.Add(weapon);
            if (jobType == (int)Constants.CharacterCreation.CreateTypes.Demon)
            {
                shieldId = pPacket.ReadInt();
                Equip shield = new Equip();
                shield.ItemID = shieldId;
                shield.GiveStats(false);
                shield.InventorySlot = -10;

                equips.Add(shield);
            }
            Character newChr = new Character();

            newChr.Client = pClient;
            newChr.AccountId = pClient.Account.Id;
            newChr.WorldId = pClient.World;

            newChr.Name = name;

            newChr.MapId = Constants.CharacterCreation.GetMapByType(jobType);
            if (hairColor < 0) hairColor = 0;
            if (jobType != (short)Constants.CharacterCreation.CreateTypes.Mihile)
            {
                hair += hairColor;
            }
            newChr.HairId = hair;
            newChr.FaceId = face;
            newChr.SkinColor = (byte)skin;
            newChr.Gender = gender;
            if (faceMark < 0) faceMark = 0;
            newChr.FaceMarking = faceMark;

            newChr.Job = Constants.CharacterCreation.GetJobByType(jobType);
            newChr.Level = 1;
            newChr.HP = 50;
            newChr.MaxHP = 50;
            newChr.MP = 50;
            newChr.MaxMP = 50;
            newChr.Str = 4;
            newChr.Dex = 4;
            newChr.Int = 4;
            newChr.Luk = 4;

            newChr.ApHp = 0;

            newChr.MapId = startMap;

            pClient.Account.Characters.Add(newChr);

            try
            {
                newChr.Create();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error creating character for {0}, Exception: {1}.", pClient.Session.IP, ex.Message);
                pClient.Session.Disconnect();
                return;
            }

            newChr.Id = Master.Instance.Accessor.GetLastId();

            Master.Instance.Accessor.AppendInventories(newChr, true);
            Master.Instance.Accessor.LoadInventoriesId(newChr);
            Master.Instance.Accessor.CreateEquips(newChr, equips);

            foreach (KeyValuePair<InventoryType, Inventory> inv in newChr.Inventory)
                inv.Value.Save();

            //TODO: Check for forbidden names and stuff like so.
            pClient.SendPacket(LoginPacket.CreateCharacterResult(newChr, true));
        }
예제 #4
0
        public static void AddEquipPosition(Packet p, Equip equip, bool trade, bool bagSlot)
        {
            if (equip == null)
            {
                p.WriteByte(0);
                return;
            }

            short pos = equip.InventorySlot;
            if (pos <= -1)
            {
                pos = (short)(pos * -1);
                if ((pos > 100) && (pos < 1000))
                {
                    pos = (short)(pos - 100);
                }
            }
            if (bagSlot)
            {
                p.WriteInt(pos % 100 - 1);
            }
            else if ((!trade) && (equip.Type == 1))
            {
                p.WriteShort(pos);
            }
            else
            {
                p.WriteByte((byte)pos);
            }
        }
예제 #5
0
        public static void AddEquipInfo(Packet p, Equip equip, Character c)
        {
            p.WriteByte(1); // Item type. 2 - An item, 3 - A pet. TODO: Pets.
            p.WriteInt(equip.ItemID);

            p.WriteByte(0); // todo: unique id.
            AddExpirationTime(p, equip.Expiration);

            p.WriteByte(0); // TODO: Extended slots.

            p.WriteInt(0); // All values of all stats.

            p.WriteByte(equip.Slots);
            p.WriteByte(equip.Level);
            p.WriteShort(equip.Str);
            p.WriteShort(equip.Str);
            p.WriteShort(equip.Str);
            p.WriteShort(equip.Str);
            p.WriteShort(equip.Str);
            p.WriteShort(equip.Str);
            p.WriteShort(equip.Str);
            p.WriteShort(equip.Str);
            p.WriteShort(equip.Str);
            p.WriteShort(equip.Str);
            p.WriteShort(equip.Str);
            p.WriteShort(equip.Str);
            p.WriteShort(equip.Str);
            p.WriteShort(equip.Str);
            p.WriteShort(equip.Str);
            p.WriteShort(equip.Str);

            p.WriteByte(0); // Inc skills?

            p.WriteByte(equip.ItemLevel);
            p.WriteInt(equip.ItemEXP * 100000);
            p.WriteInt(0); // Durability.
            p.WriteInt(equip.ViciousHammer);
            p.WriteShort(0); // PVP Damage.

            p.WriteInt(4);
            p.WriteByte(0xFF);
            p.WriteMapleString(""); // Owner.
            p.WriteByte(0); // State.
            p.WriteByte(0); // Enhance.
            p.WriteShort(0); // ptl1
            p.WriteShort(0); // ptl2
            p.WriteShort(0); // ptl3
            p.WriteShort(0); // bonus ptl 1
            p.WriteShort(0); // bonus ptl2
            p.WriteShort(0);
            p.WriteShort(0);
            p.WriteShort(0); // socket state
            p.WriteShort(0); // socket1
            p.WriteShort(0); // socket 2
            p.WriteShort(0); // socket 3
            //if (equip.CashId > 0)
            //p.writelong
            p.WriteLong(Tools.GetTime(-2));
            p.WriteInt(-1);
        }
예제 #6
0
 public static void GiveStats(Equip item, bool DoRandom)
 {
     if (!Master.Instance.DataProvider.Equips.ContainsKey(item.ItemID)) return;
     EquipData data = Master.Instance.DataProvider.Equips[item.ItemID];
     item.Str = (short)(DoRandom ? GetRandomStat(2, data.Strength) : data.Strength);
     item.Dex = (short)(DoRandom ? GetRandomStat(2, data.Dexterity) : data.Dexterity);
     item.Int = (short)(DoRandom ? GetRandomStat(2, data.Intellect) : data.Intellect);
     item.Luk = (short)(DoRandom ? GetRandomStat(2, data.Luck) : data.Luck);
     item.HP = (short)(DoRandom ? GetRandomStat(10, data.HP) : data.HP);
     item.MP = (short)(DoRandom ? GetRandomStat(10, data.MP) : data.MP);
     item.Watk = (short)(DoRandom ? GetRandomStat(10, data.WeaponAttack) : data.WeaponAttack);
     item.Wdef = (short)(DoRandom ? GetRandomStat(10, data.WeaponDefense) : data.WeaponDefense);
     item.Matk = (short)(DoRandom ? GetRandomStat(10, data.MagicAttack) : data.MagicAttack);
     item.Mdef = (short)(DoRandom ? GetRandomStat(10, data.MagicDefense) : data.MagicDefense);
     item.Acc = (short)(DoRandom ? GetRandomStat(2, data.Accuracy) : data.Accuracy);
     item.Avo = (short)(DoRandom ? GetRandomStat(2, data.Avoidance) : data.Avoidance);
     item.Hands = (short)(DoRandom ? GetRandomStat(4, data.Hands) : data.Hands);
     item.Speed = (short)(DoRandom ? GetRandomStat(4, data.Speed) : data.Speed);
     item.Jump = (short)(DoRandom ? GetRandomStat(2, data.Jump) : data.Jump);
 }