Example #1
0
        public static void SendSpawnPet(Character chr, PetItem pet, Character tochar = null)
        {
            // 43 10000000 01 404B4C00 0300312031 3A00000000000000 0000 00 0000  000000000000000000000000000000000000000000000000000000
            var pw = new Packet(ServerMessages.SPAWN_PET);

            pw.WriteInt(chr.ID);
            pw.WriteBool(true); // Spawns
            pw.WriteInt(pet.ItemID);
            pw.WriteString(pet.Name);
            pw.WriteLong(pet.CashId);
            pw.WriteShort(pet.MovableLife.Position.X);
            pw.WriteShort(pet.MovableLife.Position.Y);
            pw.WriteByte(pet.MovableLife.Stance);
            pw.WriteShort(pet.MovableLife.Foothold);
            pw.WriteLong(0);
            pw.WriteLong(0);
            if (tochar == null)
            {
                chr.Field.SendPacket(chr, pw);
            }
            else
            {
                tochar.SendPacket(pw);
            }
        }
Example #2
0
        public static BaseItem CreateFromItemID(int itemId, short amount = 1)
        {
            if (itemId == 0)
            {
                throw new Exception("Invalid ItemID in CreateFromItemID");
            }

            int itemType = (itemId / 1000000);

            BaseItem ret;

            if (itemType == 1)
            {
                ret = new EquipItem();
            }
            else if (itemType == 5)
            {
                ret = new PetItem();                     // TODO: Pet
            }
            else
            {
                ret = new BundleItem();
            }

            ret.ItemID = itemId;
            ret.Amount = amount;
            return(ret);
        }
Example #3
0
 public PetItem(PetItem itemBase) : base(itemBase)
 {
     Name      = itemBase.Name;
     Level     = itemBase.Level;
     Closeness = itemBase.Closeness;
     Fullness  = itemBase.Fullness;
     DeadDate  = itemBase.DeadDate;
 }
Example #4
0
        public static byte GetLevel(PetItem petItem)
        {
            var expCurve = Constants.PetExp;

            for (byte i = 0; i < expCurve.Length; i++)
            {
                if (expCurve[i] > petItem.Closeness)
                {
                    return((byte)(i + 1));
                }
            }
            return(1);
        }
Example #5
0
        public static void IncreaseCloseness(Character chr, PetItem petItem, short inc)
        {
            if (petItem.Closeness >= Constants.MaxCloseness)
            {
                return;
            }
            petItem.Closeness = (short)Math.Min(Constants.MaxCloseness, petItem.Closeness + inc);

            var possibleLevel = GetLevel(petItem);

            if (possibleLevel != petItem.Level)
            {
                petItem.Level = possibleLevel;
                PetsPacket.SendPetLevelup(chr);
            }
        }
Example #6
0
 public static bool IsNamedPet(PetItem petItem)
 {
     return(DataProvider.Pets.TryGetValue(petItem.ItemID, out var petData) &&
            petItem.Name != petData.Name);
 }
Example #7
0
 public static void UpdatePet(Character chr, PetItem petItem)
 {
     InventoryPacket.AddItem(chr, Constants.getInventory(petItem.ItemID), petItem, false);
 }