Ejemplo n.º 1
0
        public override void Handle(GameSession session, PacketReader packet)
        {
            // [bow] Henesys 47 Bow - 15100216
            // [staff] Modded Student Staff - 15200223
            // [longsword] Sword of tria - 13200220
            // [shield] Shield of tria - 14100190
            // [greatsword] Riena - 15000224
            // [scepter] Saint Mushliel Mace - 13300219
            // [codex] Words of Saint mushliel - 14000181
            // [cannon] Cannon of beginnings - 15300199
            // [dagger] Walker knife - 13100225
            // [star] Rook's Star - 13400218
            // [blade] Runesteel Blade - 15400274
            // [knuckles] Pugilist knuckles - 15500514
            // [orb] Guidance training orb - 15600514

            int[] itemIds = new int[] { 15100216, 15200223, 13200220, 14100190, 15000224, 13300219, 14000181, 15300199, 13100225, 13400218, 15400274, 15500514, 15600514 };
            foreach (int id in itemIds)
            {
                ItemMetadata metadata = ItemMetadataStorage.GetMetadata(id);

                if (!metadata.RecommendJobs.Contains((int)session.Player.Job))
                {
                    continue;
                }

                Item item = new Item(id);
                if (session.Player.Job == Job.Thief || session.Player.Job == Job.Assassin)
                {
                    item.Amount = 2;
                }

                InventoryController.Add(session, item, true);
            }
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
    public static void ChangeHair(GameSession session, int hairId, out Item previousHair, out Item newHair)
    {
        Random random = Random.Shared;

        //Grab a preset hair and length of hair
        ItemCustomizeMetadata customize = ItemMetadataStorage.GetMetadata(hairId).Customize;
        int         indexPreset         = random.Next(customize.HairPresets.Count);
        HairPresets chosenPreset        = customize.HairPresets[indexPreset];

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

        //Grab random back hair length
        double chosenBackLength = random.NextDouble() *
                                  (customize.HairPresets[indexPreset].MaxScale - customize.HairPresets[indexPreset].MinScale) + customize.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];

        newHair = new(hairId)
        {
            Color              = EquipColor.Argb(color, indexColor, palette.PaletteId),
            HairData           = new((float)chosenBackLength, (float)chosenFrontLength, chosenPreset.BackPositionCoord, chosenPreset.BackPositionRotation, chosenPreset.FrontPositionCoord, chosenPreset.FrontPositionRotation),
            IsEquipped         = true,
            OwnerCharacterId   = session.Player.CharacterId,
            OwnerCharacterName = session.Player.Name
        };
        Dictionary <ItemSlot, Item> cosmetics = session.Player.Inventory.Cosmetics;

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

        cosmetics[ItemSlot.HR] = newHair;
    }
Ejemplo n.º 4
0
    private static void HandleViaItem(GameSession session, PacketReader packet)
    {
        bool openShop = packet.ReadBool();

        if (!openShop)
        {
            return;
        }

        int coinId = packet.ReadInt();

        ItemMetadata item = ItemMetadataStorage.GetMetadata(coinId);

        if (item is null)
        {
            return;
        }

        ShopHelper.OpenSystemShop(session, item.Shop.ShopId, 0);
    }
Ejemplo n.º 5
0
    private static void HandleStopScore(GameSession session)
    {
        // get Mastery exp
        ItemMusicMetadata metadata = ItemMetadataStorage.GetMetadata(session.Player.Instrument.Value.Score.Id)?.Music;
        int masteryExpGain         = Math.Min(((session.ServerTick - session.Player.Instrument.Value.InstrumentTick) * metadata.MasteryValue) / 1000, metadata.MasteryValueMax);

        session.Player.Levels.GainMasteryExp(MasteryType.Performance, masteryExpGain);

        // get prestige exp
        int prestigeExpGain = (session.ServerTick - session.Player.Instrument.Value.InstrumentTick) / 1000 * 250;

        session.Player.Levels.GainPrestigeExp(prestigeExpGain);

        //TODO: get exp for normal level

        // remove instrument from field
        session.FieldManager.BroadcastPacket(InstrumentPacket.StopScore(session.Player.Instrument));
        session.FieldManager.RemoveInstrument(session.Player.Instrument);
        session.Player.Instrument = null;
    }