Beispiel #1
0
        private static void HandleChangeToSavedHair(GameSession session, PacketReader packet)
        {
            long hairUid = packet.ReadLong();

            Item hair = session.Player.HairInventory.SavedHair.FirstOrDefault(x => x.Uid == hairUid);

            if (hair == null)
            {
                return;
            }

            BeautyMetadata beautyShop = BeautyMetadataStorage.GetShopById(510);

            if (!PayWithShopTokenCost(session, beautyShop))
            {
                return;
            }

            Dictionary <ItemSlot, Item> cosmetics = session.Player.Inventory.Cosmetics;

            if (cosmetics.Remove(hair.ItemSlot, out Item removeItem))
            {
                removeItem.Slot = -1;
                session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, removeItem));
            }

            cosmetics[removeItem.ItemSlot] = hair;

            session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, hair, hair.ItemSlot));
            session.Send(BeautyPacket.ChangetoSavedHair());
        }
Beispiel #2
0
        private static void HandleChooseRandomHair(GameSession session, PacketReader packet)
        {
            byte selection = packet.ReadByte();

            if (selection == 0) // player chose previous hair
            {
                Dictionary <ItemSlot, Item> cosmetics = session.Player.Inventory.Cosmetics;
                //Remove current hair
                if (cosmetics.Remove(ItemSlot.HR, out Item newHair))
                {
                    newHair.Slot = -1;
                    DatabaseManager.Items.Delete(newHair.Uid);
                    session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, newHair));
                }

                cosmetics[ItemSlot.HR] = session.Player.HairInventory.RandomHair; // apply the previous hair

                session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, session.Player.HairInventory.RandomHair, ItemSlot.HR));

                Item voucher = new Item(20300246)
                {
                };                                     // Chic Salon Voucher
                InventoryController.Add(session, voucher, true);

                session.Send(BeautyPacket.ChooseRandomHair(voucher.Id));
            }
            else // player chose new hair
            {
                session.Send(BeautyPacket.ChooseRandomHair());
            }

            session.Player.HairInventory.RandomHair = null; // remove random hair option from hair inventory
        }
Beispiel #3
0
        private static void HandleRandomHair(GameSession session, PacketReader packet)
        {
            int  shopId     = packet.ReadInt();
            bool useVoucher = packet.ReadBool();

            BeautyMetadata    beautyShop  = BeautyMetadataStorage.GetShopById(shopId);
            List <BeautyItem> beautyItems = BeautyMetadataStorage.GetGenderItems(beautyShop.ShopId, session.Player.Gender);

            if (!HandleShopPay(session, beautyShop, useVoucher))
            {
                return;
            }

            // Grab random hair
            Random     random     = new Random();
            int        indexHair  = random.Next(beautyItems.Count);
            BeautyItem chosenHair = beautyItems[indexHair];

            //Grab a preset hair and length of hair
            ItemMetadata beautyItemData = ItemMetadataStorage.GetMetadata(chosenHair.ItemId);
            int          indexPreset    = random.Next(beautyItemData.HairPresets.Count);
            HairPresets  chosenPreset   = beautyItemData.HairPresets[indexPreset];

            //Grab random front hair length
            double chosenFrontLength = random.NextDouble() *
                                       (beautyItemData.HairPresets[indexPreset].MaxScale - beautyItemData.HairPresets[indexPreset].MinScale) + beautyItemData.HairPresets[indexPreset].MinScale;

            //Grab random back hair length
            double chosenBackLength = random.NextDouble() *
                                      (beautyItemData.HairPresets[indexPreset].MaxScale - beautyItemData.HairPresets[indexPreset].MinScale) + beautyItemData.HairPresets[indexPreset].MinScale;

            // Grab random preset color
            ColorPaletteMetadata palette = ColorPaletteMetadataStorage.GetMetadata(2); // pick from palette 2. Seems like it's the correct palette for basic hair colors

            int        indexColor = random.Next(palette.DefaultColors.Count);
            MixedColor color      = palette.DefaultColors[indexColor];

            Dictionary <ItemSlot, Item> equippedInventory = session.Player.GetEquippedInventory(InventoryTab.Gear);

            Item newHair = new Item(chosenHair.ItemId)
            {
                Color      = EquipColor.Argb(color, indexColor, palette.PaletteId),
                HairD      = new HairData((float)chosenBackLength, (float)chosenFrontLength, chosenPreset.BackPositionCoord, chosenPreset.BackPositionRotation, chosenPreset.FrontPositionCoord, chosenPreset.FrontPositionRotation),
                IsTemplate = false
            };

            //Remove old hair
            if (session.Player.Equips.Remove(ItemSlot.HR, out Item previousHair))
            {
                previousHair.Slot = -1;
                session.Player.HairInventory.RandomHair = previousHair; // store the previous hair
                session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, previousHair));
            }

            equippedInventory[ItemSlot.HR] = newHair;

            session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, newHair, ItemSlot.HR));
            session.Send(BeautyPacket.RandomHairOption(previousHair, newHair));
        }
Beispiel #4
0
        private static void ModifyBeauty(GameSession session, PacketReader packet, Item beautyItem)
        {
            ItemSlot itemSlot = ItemMetadataStorage.GetSlot(beautyItem.Id);
            Dictionary <ItemSlot, Item> cosmetics = session.Player.Inventory.Cosmetics;

            if (cosmetics.TryGetValue(itemSlot, out Item removeItem))
            {
                // Only remove if it isn't the same item
                if (removeItem.Uid != beautyItem.Uid)
                {
                    cosmetics.Remove(itemSlot);
                    removeItem.Slot = -1;
                    DatabaseManager.Items.Delete(removeItem.Uid);
                    session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, removeItem));
                }
            }

            // equip & update new item
            switch (itemSlot)
            {
            case ItemSlot.HR:
                float  backLength            = BitConverter.ToSingle(packet.Read(4), 0);
                CoordF backPositionCoord     = packet.Read <CoordF>();
                CoordF backPositionRotation  = packet.Read <CoordF>();
                float  frontLength           = BitConverter.ToSingle(packet.Read(4), 0);
                CoordF frontPositionCoord    = packet.Read <CoordF>();
                CoordF frontPositionRotation = packet.Read <CoordF>();

                beautyItem.HairData = new HairData(backLength, frontLength, backPositionCoord, backPositionRotation, frontPositionCoord, frontPositionRotation);

                cosmetics[itemSlot] = beautyItem;

                session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, beautyItem, itemSlot));
                break;

            case ItemSlot.FA:
                cosmetics[itemSlot] = beautyItem;

                session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, beautyItem, itemSlot));
                break;

            case ItemSlot.FD:
                byte[] faceDecorationPosition = packet.Read(16);

                beautyItem.FaceDecorationData = faceDecorationPosition;

                cosmetics[itemSlot] = beautyItem;

                session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, beautyItem, itemSlot));
                break;
            }
        }
Beispiel #5
0
        private static void ModifyBeauty(GameSession session, PacketReader packet, Item beautyItem)
        {
            ItemSlot itemSlot = ItemMetadataStorage.GetSlot(beautyItem.Id);

            // remove current item
            if (session.Player.Equips.Remove(itemSlot, out Item removeItem))
            {
                removeItem.Slot = -1;
                session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, removeItem));
            }
            // equip new item

            Dictionary <ItemSlot, Item> equippedInventory = session.Player.GetEquippedInventory(InventoryTab.Gear);

            switch (itemSlot)
            {
            case ItemSlot.HR:
                float  backLength            = BitConverter.ToSingle(packet.Read(4), 0);
                CoordF backPositionCoord     = packet.Read <CoordF>();
                CoordF backPositionRotation  = packet.Read <CoordF>();
                float  frontLength           = BitConverter.ToSingle(packet.Read(4), 0);
                CoordF frontPositionCoord    = packet.Read <CoordF>();
                CoordF frontPositionRotation = packet.Read <CoordF>();

                beautyItem.HairD = new HairData(backLength, frontLength, backPositionCoord, backPositionRotation, frontPositionCoord, frontPositionRotation);

                equippedInventory[itemSlot] = beautyItem;

                session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, beautyItem, itemSlot));
                break;

            case ItemSlot.FA:

                equippedInventory[itemSlot] = beautyItem;

                session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, beautyItem, itemSlot));
                break;

            case ItemSlot.FD:
                byte[] faceDecorationPosition = packet.Read(16);

                beautyItem.FaceDecorationD = faceDecorationPosition;

                equippedInventory[itemSlot] = beautyItem;

                session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, beautyItem, itemSlot));
                break;
            }
        }
        private void HandleEquipItem(GameSession session, PacketReader packet)
        {
            long   itemUid      = packet.ReadLong();
            string equipSlotStr = packet.ReadUnicodeString();

            if (!Enum.TryParse(equipSlotStr, out ItemSlot equipSlot))
            {
                logger.Warning("Unknown equip slot: " + equipSlotStr);
                return;
            }

            // Remove the item from the users inventory
            InventoryController.Remove(session, itemUid, out Item item);

            // TODO: Move unequipped item into the correct slot
            // Move previously equipped item back to inventory
            if (session.Player.Equips.Remove(equipSlot, out Item prevItem))
            {
                InventoryController.Add(session, prevItem, false);
                session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem));
            }

            // Equip new item
            session.Player.Equips[equipSlot] = item;
            session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, item, equipSlot));

            // TODO - Increase stats based on the item stats itself
            session.Player.Stats.CritRate.Max   += 12;
            session.Player.Stats.CritRate.Total += 12;

            session.Player.Stats.MinAtk.Max   += 15;
            session.Player.Stats.MinAtk.Total += 15;

            session.Player.Stats.MaxAtk.Max   += 17;
            session.Player.Stats.MaxAtk.Total += 17;

            session.Player.Stats.MagAtk.Max   += 15;
            session.Player.Stats.MagAtk.Total += 15;

            session.Send(StatPacket.SetStats(session.FieldPlayer));
        }
Beispiel #7
0
    public override void Execute(GameCommandTrigger trigger)
    {
        string equipSlot = trigger.Get <string>("equipSlot");

        if (string.IsNullOrEmpty(equipSlot))
        {
            trigger.Session.SendNotice($"Type '/info {Aliases.First()}' for more details.");
            return;
        }

        if (!Enum.TryParse(equipSlot, ignoreCase: true, out ItemSlot itemSlot) || itemSlot == ItemSlot.NONE)
        {
            trigger.Session.SendNotice($"{equipSlot} is not a valid equip slot.");
            string slots = "";
            foreach (object slot in Enum.GetValues(typeof(ItemSlot)))
            {
                slots += $"{slot} - {((ItemSlot) slot).GetEnumDescription()}, ";
            }

            trigger.Session.SendNotice($"Available slots: {slots.TrimEnd(',', ' ')}");
            return;
        }

        Player player = trigger.Session.Player;

        if (!player.Inventory.Equips.TryGetValue(itemSlot, out Item item))
        {
            trigger.Session.SendNotice($"You don't have an item in slot {itemSlot}.");
            return;
        }

        item.Stats.Constants.Clear();
        item.Stats.Randoms.Clear();
        item.Stats.Statics.Clear();

        player.FieldPlayer.ComputeStats();

        trigger.Session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(player.FieldPlayer, item, itemSlot));

        DatabaseManager.Items.Update(item);
    }
Beispiel #8
0
    private static void HandleRandomHair(GameSession session, PacketReader packet)
    {
        int  shopId     = packet.ReadInt();
        bool useVoucher = packet.ReadBool();

        BeautyShop            beautyShop  = DatabaseManager.BeautyShops.FindById(shopId);
        List <BeautyShopItem> beautyItems = DatabaseManager.BeautyShopItems.FindAllByShopIdAndGender(beautyShop.Id, session.Player.Gender);

        if (!HandleShopPay(session, beautyShop, useVoucher))
        {
            return;
        }

        // Grab random hair
        Random         random     = Random.Shared;
        int            indexHair  = random.Next(beautyItems.Count);
        BeautyShopItem chosenHair = beautyItems[indexHair];

        BeautyHelper.ChangeHair(session, chosenHair.ItemId, out Item previousHair, out Item newHair);

        session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.Player.FieldPlayer, newHair, ItemSlot.HR));
        session.Send(BeautyPacket.RandomHairOption(previousHair, newHair));
    }
        private void HandleEquipItem(GameSession session, PacketReader packet)
        {
            long   itemUid      = packet.ReadLong();
            string equipSlotStr = packet.ReadUnicodeString();

            if (!Enum.TryParse(equipSlotStr, out ItemSlot equipSlot))
            {
                Logger.Warning("Unknown equip slot: " + equipSlotStr);
                return;
            }

            // Remove the item from the users inventory
            InventoryController.Remove(session, itemUid, out Item item);

            // Get correct equipped inventory
            Dictionary <ItemSlot, Item> equippedInventory = session.Player.GetEquippedInventory(item.InventoryTab);

            if (equippedInventory == null)
            {
                Logger.Warning("equippedInventory was null: " + item.InventoryTab);
                return;
            }

            // Move previously equipped item back to inventory
            if (equippedInventory.Remove(equipSlot, out Item prevItem))
            {
                prevItem.Slot = item.Slot;
                InventoryController.Add(session, prevItem, false);
                session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem));
            }

            // Handle unequipping pants when equipping dresses
            // Handle unequipping off-hand when equipping two-handed weapons
            if (item.IsDress || item.IsTwoHand)
            {
                if (equippedInventory.Remove(item.IsDress ? ItemSlot.PA : ItemSlot.LH, out Item prevItem2))
                {
                    prevItem2.Slot = -1;
                    if (prevItem == null)
                    {
                        prevItem2.Slot = item.Slot;
                    }
                    InventoryController.Add(session, prevItem2, false);
                    session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem2));
                }
            }

            // Handle unequipping dresses when equipping pants
            // Handle unequipping two-handed main-hands when equipping off-hand weapons
            if (item.ItemSlot == ItemSlot.PA || item.ItemSlot == ItemSlot.LH)
            {
                ItemSlot prevItemSlot = item.ItemSlot == ItemSlot.PA ? ItemSlot.CL : ItemSlot.RH;
                if (equippedInventory.ContainsKey(prevItemSlot))
                {
                    if (equippedInventory[prevItemSlot] != null && equippedInventory[prevItemSlot].IsDress)
                    {
                        if (equippedInventory.Remove(prevItemSlot, out Item prevItem2))
                        {
                            prevItem2.Slot = item.Slot;
                            InventoryController.Add(session, prevItem2, false);
                            session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem2));
                        }
                    }
                }
            }

            // Equip new item
            equippedInventory[equipSlot] = item;
            session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, item, equipSlot));

            if (item.InventoryTab == InventoryTab.Gear)
            {
                // TODO - Increase stats based on the item stats itself
                session.Player.Stats.CritRate.Max   += 12;
                session.Player.Stats.CritRate.Total += 12;

                session.Player.Stats.MinAtk.Max   += 15;
                session.Player.Stats.MinAtk.Total += 15;

                session.Player.Stats.MaxAtk.Max   += 17;
                session.Player.Stats.MaxAtk.Total += 17;

                session.Player.Stats.MagAtk.Max   += 15;
                session.Player.Stats.MagAtk.Total += 15;

                session.Send(StatPacket.SetStats(session.FieldPlayer));
            }
        }
Beispiel #10
0
    private static void HandleEquipItem(GameSession session, PacketReader packet)
    {
        long   itemUid      = packet.ReadLong();
        string equipSlotStr = packet.ReadUnicodeString();

        if (!Enum.TryParse(equipSlotStr, out ItemSlot equipSlot))
        {
            Logger.Warn($"Unknown equip slot: {equipSlotStr}");
            return;
        }

        // Remove the item from the users inventory
        Inventory inventory = session.Player.Inventory;

        inventory.RemoveItem(session, itemUid, out Item item);
        if (item == null)
        {
            return;
        }

        // Get correct equipped inventory
        Dictionary <ItemSlot, Item> equippedInventory = session.Player.GetEquippedInventory(item.InventoryTab);

        if (equippedInventory == null)
        {
            Logger.Warn($"equippedInventory was null: {item.InventoryTab}");
            return;
        }

        // Move previously equipped item back to inventory
        if (equippedInventory.Remove(equipSlot, out Item prevItem))
        {
            prevItem.Slot       = item.Slot;
            prevItem.IsEquipped = false;
            inventory.AddItem(session, prevItem, false);
            session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.Player.FieldPlayer, prevItem));

            if (prevItem.InventoryTab == InventoryTab.Gear)
            {
                DecreaseStats(session, prevItem);
            }
        }

        // Handle unequipping pants when equipping dresses
        // Handle unequipping off-hand when equipping two-handed weapons
        if (item.IsDress || item.IsTwoHand)
        {
            if (equippedInventory.Remove(item.IsDress ? ItemSlot.PA : ItemSlot.LH, out Item prevItem2))
            {
                prevItem2.Slot = -1;
                if (prevItem == null)
                {
                    prevItem2.Slot = item.Slot;
                }
                prevItem2.IsEquipped = false;
                inventory.AddItem(session, prevItem2, false);
                session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.Player.FieldPlayer, prevItem2));
            }
        }

        // Handle unequipping dresses when equipping pants
        // Handle unequipping two-handed main-hands when equipping off-hand weapons
        if (item.ItemSlot is ItemSlot.PA or ItemSlot.LH)
        {
            ItemSlot prevItemSlot = item.ItemSlot == ItemSlot.PA ? ItemSlot.CL : ItemSlot.RH;
            if (equippedInventory.ContainsKey(prevItemSlot))
            {
                if (equippedInventory[prevItemSlot] != null && equippedInventory[prevItemSlot].IsDress)
                {
                    if (equippedInventory.Remove(prevItemSlot, out Item prevItem2))
                    {
                        prevItem2.Slot       = item.Slot;
                        prevItem2.IsEquipped = false;
                        inventory.AddItem(session, prevItem2, false);
                        session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.Player.FieldPlayer, prevItem2));
                    }
                }
            }
        }

        // Equip new item
        item.IsEquipped = true;
        item.ItemSlot   = equipSlot;
        equippedInventory[equipSlot] = item;
        session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.Player.FieldPlayer, item, equipSlot));

        // Add stats if gear
        if (item.InventoryTab == InventoryTab.Gear)
        {
            IncreaseStats(session, item);
        }
    }
Beispiel #11
0
        private void HandleEquipItem(GameSession session, PacketReader packet)
        {
            long   itemUid      = packet.ReadLong();
            string equipSlotStr = packet.ReadUnicodeString();

            if (!Enum.TryParse(equipSlotStr, out ItemSlot equipSlot))
            {
                logger.Warning("Unknown equip slot: " + equipSlotStr);
                return;
            }

            // Remove the item from the users inventory
            InventoryController.Remove(session, itemUid, out Item item);

            // Equip cosmetic
            if (item.InventoryTab == InventoryTab.Outfit)
            {
                // Move previously equipped item back to inventory
                if (session.Player.Cosmetics.Remove(equipSlot, out Item prevItem))
                {
                    prevItem.Slot = item.Slot;
                    InventoryController.Add(session, prevItem, false);
                    session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem));
                }

                // Handle unequipping off-hand when equipping two-handed weapons
                if (item.IsTwoHand)
                {
                    if (session.Player.Cosmetics.Remove(ItemSlot.LH, out Item prevItem2))
                    {
                        prevItem2.Slot = -1;
                        if (prevItem == null)
                        {
                            prevItem2.Slot = item.Slot;
                        }
                        InventoryController.Add(session, prevItem2, false);
                        session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem2));
                    }
                }

                // Handle unequipping two-handed main-hands when equipping off-hand weapons
                if (item.ItemSlot == ItemSlot.LH && session.Player.Cosmetics[ItemSlot.RH] != null && session.Player.Cosmetics[ItemSlot.RH].IsTwoHand)
                {
                    if (session.Player.Cosmetics.Remove(ItemSlot.RH, out Item prevItem2))
                    {
                        prevItem2.Slot = item.Slot;
                        InventoryController.Add(session, prevItem2, false);
                        session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem2));
                    }
                }

                // Equip new item
                session.Player.Cosmetics[equipSlot] = item;
                session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, item, equipSlot));
            }

            // Equip gear
            else
            {
                // Move previously equipped item back to inventory
                if (session.Player.Equips.Remove(equipSlot, out Item prevItem))
                {
                    prevItem.Slot = item.Slot;
                    InventoryController.Add(session, prevItem, false);
                    session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem));
                }

                // Handle unequipping off-hand when equipping two-handed weapons
                if (item.IsTwoHand)
                {
                    if (session.Player.Equips.Remove(ItemSlot.LH, out Item prevItem2))
                    {
                        prevItem2.Slot = -1;
                        if (prevItem == null)
                        {
                            prevItem2.Slot = item.Slot;
                        }
                        InventoryController.Add(session, prevItem2, false);
                        session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem2));
                    }
                }

                // Handle unequipping two-handed main-hands when equipping off-hand weapons
                if (item.ItemSlot == ItemSlot.LH && session.Player.Equips[ItemSlot.RH] != null && session.Player.Equips[ItemSlot.RH].IsTwoHand)
                {
                    if (session.Player.Equips.Remove(ItemSlot.RH, out Item prevItem2))
                    {
                        prevItem2.Slot = item.Slot;
                        InventoryController.Add(session, prevItem2, false);
                        session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem2));
                    }
                }

                // Equip new item
                session.Player.Equips[equipSlot] = item;
                session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, item, equipSlot));

                // TODO - Increase stats based on the item stats itself
                session.Player.Stats.CritRate.Max   += 12;
                session.Player.Stats.CritRate.Total += 12;

                session.Player.Stats.MinAtk.Max   += 15;
                session.Player.Stats.MinAtk.Total += 15;

                session.Player.Stats.MaxAtk.Max   += 17;
                session.Player.Stats.MaxAtk.Total += 17;

                session.Player.Stats.MagAtk.Max   += 15;
                session.Player.Stats.MagAtk.Total += 15;

                session.Send(StatPacket.SetStats(session.FieldPlayer));
            }
        }
Beispiel #12
0
    public override void Execute(GameCommandTrigger trigger)
    {
        string equipSlot      = trigger.Get <string>("equipSlot");
        string newAttributeId = trigger.Get <string>("newAttributeId");
        float  value          = trigger.Get <float>("value");
        byte   isPercentage   = trigger.Get <byte>("isPercentage");
        byte   category       = trigger.Get <byte>("category");

        if (string.IsNullOrEmpty(equipSlot))
        {
            trigger.Session.SendNotice($"Type '/info {Aliases.First()}' for more details.");
            return;
        }

        if (!Enum.TryParse(equipSlot, ignoreCase: true, out ItemSlot itemSlot) || itemSlot == ItemSlot.NONE)
        {
            trigger.Session.SendNotice($"{equipSlot} is not a valid equip slot.");
            string slots = "";
            foreach (object slot in Enum.GetValues(typeof(ItemSlot)))
            {
                slots += $"{slot} - {((ItemSlot) slot).GetEnumDescription()}, ";
            }

            trigger.Session.SendNotice($"Available slots: {slots.TrimEnd(',', ' ')}");
            return;
        }

        if (!Enum.TryParse(newAttributeId, ignoreCase: true, out StatAttribute newAttribute))
        {
            trigger.Session.SendNotice($"{newAttributeId} is not a valid attribute. Check StatAttribute.cs");
            return;
        }

        Player player = trigger.Session.Player;

        if (!player.Inventory.Equips.TryGetValue(itemSlot, out Item item))
        {
            trigger.Session.SendNotice($"You don't have an item in slot {itemSlot}.");
            return;
        }

        ItemStat          itemStat;
        StatAttributeType attributeType = isPercentage == 1 ? StatAttributeType.Rate : StatAttributeType.Flat;

        if ((int)newAttribute > 11000)
        {
            itemStat = new SpecialStat(newAttribute, value, attributeType);
        }
        else
        {
            itemStat = new BasicStat(newAttribute, value, attributeType);
        }

        if (category == 0)
        {
            if (value == 0)
            {
                item.Stats.Constants.Remove(newAttribute);
            }
            else
            {
                item.Stats.Constants[newAttribute] = itemStat;
            }
        }
        else if (category == 1)
        {
            if (value == 0)
            {
                item.Stats.Statics.Remove(newAttribute);
            }
            else
            {
                item.Stats.Statics[newAttribute] = itemStat;
            }
        }
        else if (category == 2)
        {
            if (value == 0)
            {
                item.Stats.Randoms.Remove(newAttribute);
            }
            else
            {
                item.Stats.Randoms[newAttribute] = itemStat;
            }
        }

        trigger.Session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(player.FieldPlayer, item, itemSlot));

        player.FieldPlayer.ComputeStats();

        DatabaseManager.Items.Update(item);
    }