Example #1
0
    public void AddItem(ItemInstance item)
    {
        switch (item.Quality)
        {
        case Quality.QualityGrade.Mystic:
            MysticItemsCrafted++;
            break;

        case Quality.QualityGrade.Magical:
            MagicalItemsCrafted++;
            break;

        case Quality.QualityGrade.Sturdy:
            SturdyItemsCrafted++;
            break;

        case Quality.QualityGrade.Passable:
            PassableItemsCrafted++;
            break;

        case Quality.QualityGrade.Brittle:
            BrittleItemsCrafted++;
            break;

        case Quality.QualityGrade.Junk:
            JunkItemsCrafted++;
            break;
        }

        Type t = item.GetType();

        if (t == typeof(Jewel))
        {
            JewelsCrafted++;
        }
        else if (t == typeof(ChargedJewel))
        {
            ChargedJewelsCrafted++;
        }
        else if (t == typeof(Brick))
        {
            BricksCrafted++;
        }
        else if (t == typeof(Shell))
        {
            ShellsCrafted++;
        }
    }
Example #2
0
        public void Pdtse(string packet)
        {
            Logger.Debug(packet, Session.SessionId);
            string[] packetsplit = packet.Split(' ');
            if (packetsplit.Count() < 4)
            {
                return;
            }
            byte  type = 0;
            short VNum = 0;

            if (!byte.TryParse(packetsplit[2], out type) || !short.TryParse(packetsplit[3], out VNum))
            {
                return;
            }
            if (type == 1)
            {
                MapNpc npc      = Session.CurrentMap.Npcs.FirstOrDefault(s => s.MapNpcId == Session.Character.LastNRunId);
                int    distance = Map.GetDistance(new MapCell()
                {
                    X = Session.Character.MapX, Y = Session.Character.MapY
                }, new MapCell()
                {
                    X = npc.MapX, Y = npc.MapY
                });
                if (npc != null && npc.MapId == Session.CurrentMap.MapId && distance <= 5)
                {
                    Recipe rec = npc.Recipes.FirstOrDefault(s => s.ItemVNum == VNum);
                    if (rec != null && rec.Amount > 0)
                    {
                        string rece = $"m_list 3 {rec.Amount}";
                        foreach (RecipeItemDTO ite in rec.Items)
                        {
                            if (ite.Amount > 0)
                            {
                                rece += $" {ite.ItemVNum} {ite.Amount}";
                            }
                        }
                        rece += " -1";
                        Session.SendPacket(rece);
                    }
                }
            }
            else
            {
                MapNpc npc = Session.CurrentMap.Npcs.FirstOrDefault(s => s.MapNpcId == Session.Character.LastNRunId);

                int distance = Map.GetDistance(new MapCell()
                {
                    X = Session.Character.MapX, Y = Session.Character.MapY
                }, new MapCell()
                {
                    X = npc.MapX, Y = npc.MapY
                });
                if (npc != null && npc.MapId == Session.CurrentMap.MapId && distance <= 5)
                {
                    Recipe rec = npc.Recipes.FirstOrDefault(s => s.ItemVNum == VNum);
                    if (rec != null)
                    {
                        if (rec.Amount <= 0)
                        {
                            return;
                        }
                        foreach (RecipeItemDTO ite in rec.Items)
                        {
                            if (Session.Character.Inventory.CountItem(ite.ItemVNum) < ite.Amount)
                            {
                                return;
                            }
                        }

                        ItemInstance inv = Session.Character.Inventory.AddNewToInventory(rec.ItemVNum, rec.Amount);
                        if (inv.GetType().Equals(typeof(WearableInstance)))
                        {
                            WearableInstance item = inv as WearableInstance;
                            if (item != null && (item.Item.EquipmentSlot == EquipmentType.Armor || item.Item.EquipmentSlot == EquipmentType.MainWeapon || item.Item.EquipmentSlot == EquipmentType.SecondaryWeapon))
                            {
                                item.SetRarityPoint();
                            }
                        }

                        if (inv != null)
                        {
                            short Slot = inv.Slot;
                            if (Slot != -1)
                            {
                                foreach (RecipeItemDTO ite in rec.Items)
                                {
                                    Session.Character.Inventory.RemoveItemAmount(ite.ItemVNum, ite.Amount);
                                }
                                Session.SendPacket(Session.Character.GenerateInventoryAdd(inv.ItemVNum, inv.Amount, inv.Type, inv.Slot, 0, inv.Rare, inv.Upgrade, 0));

                                Session.SendPacket($"pdti 11 {inv.ItemVNum} {rec.Amount} 29 {inv.Upgrade} 0");
                                Session.SendPacket(Session.Character.GenerateGuri(19, 1, 1324));

                                Session.SendPacket(Session.Character.GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("CRAFTED_OBJECT"), inv.Item.Name, rec.Amount), 0));
                            }
                        }
                        else
                        {
                            Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                        }
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// pdtse packet
        /// </summary>
        /// <param name="pdtsePacket"></param>
        public void Pdtse(PdtsePacket pdtsePacket)
        {
            Logger.Debug(Session.Character.GenerateIdentity(), pdtsePacket.ToString());
            if (!Session.HasCurrentMapInstance)
            {
                return;
            }
            short VNum = pdtsePacket.VNum;

            if (pdtsePacket.Type == 1)
            {
                MapNpc npc = Session.CurrentMapInstance.Npcs.FirstOrDefault(s => s.MapNpcId == Session.Character.LastNRunId);
                if (npc != null)
                {
                    int distance = Map.GetDistance(new MapCell
                    {
                        X = Session.Character.PositionX,
                        Y = Session.Character.PositionY
                    }, new MapCell
                    {
                        X = npc.MapX,
                        Y = npc.MapY
                    });
                    if (npc.MapInstance == Session.CurrentMapInstance && distance <= 5)
                    {
                        Recipe rec = npc.Recipes.FirstOrDefault(s => s.ItemVNum == VNum);
                        if (rec != null && rec.Amount > 0)
                        {
                            string rece = $"m_list 3 {rec.Amount}";
                            foreach (RecipeItemDTO ite in rec.Items)
                            {
                                if (ite.Amount > 0)
                                {
                                    rece = rece + $" {ite.ItemVNum} {ite.Amount}";
                                }
                            }
                            rece += " -1";
                            Session.SendPacket(rece);
                        }
                    }
                }
            }
            else
            {
                MapNpc npc = Session.CurrentMapInstance.Npcs.FirstOrDefault(s => s.MapNpcId == Session.Character.LastNRunId);
                if (npc != null)
                {
                    int distance = Map.GetDistance(new MapCell
                    {
                        X = Session.Character.PositionX,
                        Y = Session.Character.PositionY
                    }, new MapCell
                    {
                        X = npc.MapX,
                        Y = npc.MapY
                    });
                    if (npc.MapInstance == Session.CurrentMapInstance && distance <= 5)
                    {
                        Recipe rec = npc.Recipes.FirstOrDefault(s => s.ItemVNum == VNum);
                        if (rec != null)
                        {
                            if (rec.Amount <= 0)
                            {
                                return;
                            }
                            if (rec.Items.Any(ite => Session.Character.Inventory.CountItem(ite.ItemVNum) < ite.Amount))
                            {
                                return;
                            }

                            ItemInstance inv = Session.Character.Inventory.AddNewToInventory(rec.ItemVNum, rec.Amount).FirstOrDefault();
                            if (inv != null)
                            {
                                if (inv.GetType() == typeof(WearableInstance))
                                {
                                    if (inv is WearableInstance item && (item.Item.EquipmentSlot == EquipmentType.Armor || item.Item.EquipmentSlot == EquipmentType.MainWeapon || item.Item.EquipmentSlot == EquipmentType.SecondaryWeapon))
                                    {
                                        item.SetRarityPoint();
                                    }
                                }
                                foreach (RecipeItemDTO ite in rec.Items)
                                {
                                    Session.Character.Inventory.RemoveItemAmount(ite.ItemVNum, ite.Amount);
                                }
                                Session.SendPacket($"pdti 11 {inv.ItemVNum} {rec.Amount} 29 {inv.Upgrade} 0");
                                Session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(19, 1, Session.Character.CharacterId, 1324));
                                Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("CRAFTED_OBJECT"), inv.Item.Name, rec.Amount), 0));
                            }
                        }
                    }
                }
            }
        }
Example #4
0
        /// <summary>
        /// pdtse packet
        /// </summary>
        /// <param name="pdtsePacket"></param>
        public void Pdtse(PdtsePacket pdtsePacket)
        {
            if (!Session.HasCurrentMapInstance)
            {
                return;
            }
            short vNum = pdtsePacket.VNum;

            if (pdtsePacket.Type == 1)
            {
                Recipe rec;
                if (Session.Character.LastUsedItem == 0)
                {
                    MapNpc npc =
                        Session.CurrentMapInstance.Npcs.FirstOrDefault(s => s.MapNpcId == Session.Character.LastNRunId);
                    if (npc == null)
                    {
                        return;
                    }
                    int distance = Map.GetDistance(Session.Character.GetPos(), npc.GetPos());
                    if (npc.MapInstance != Session.CurrentMapInstance || distance > 5)
                    {
                        return;
                    }

                    rec = npc.Recipes.FirstOrDefault(s => s.ItemVNum == vNum);
                }
                else
                {
                    if (!ServerManager.Instance.ItemHasRecipe(vNum))
                    {
                        // NO RECIPE WITH THIS VNUM
                        return;
                    }
                    if (Session.Character.Inventory.CountItem(Session.Character.LastUsedItem) <= 0)
                    {
                        // NO SCROLL, PACKET HACKING
                        return;
                    }

                    rec = ServerManager.Instance.GetRecipeByItemVNum(vNum);
                }
                if (rec == null || rec.Amount <= 0)
                {
                    return;
                }
                string rece = $"m_list 3 {rec.Amount}";
                rece  = rec.Items.Where(ite => ite.Amount > 0).Aggregate(rece, (current, ite) => current + $" {ite.ItemVNum} {ite.Amount}");
                rece += " -1";
                Session.SendPacket(rece);
            }
            else
            {
                Recipe rec;
                if (Session.Character.LastUsedItem == 0)
                {
                    MapNpc npc =
                        Session.CurrentMapInstance.Npcs.FirstOrDefault(s => s.MapNpcId == Session.Character.LastNRunId);
                    if (npc == null)
                    {
                        return;
                    }
                    int distance = Map.GetDistance(Session.Character.GetPos(), npc.GetPos());
                    if (npc.MapInstance != Session.CurrentMapInstance || distance > 5)
                    {
                        return;
                    }
                    rec = npc.Recipes.FirstOrDefault(s => s.ItemVNum == vNum);
                }
                else
                {
                    if (!ServerManager.Instance.ItemHasRecipe(vNum))
                    {
                        // NO RECIPE WITH THIS VNUM
                        return;
                    }
                    if (Session.Character.Inventory.CountItem(Session.Character.LastUsedItem) <= 0)
                    {
                        // NO SCROLL, PACKET HACKING
                        return;
                    }

                    rec = ServerManager.Instance.GetRecipeByItemVNum(vNum);
                }
                if (rec == null)
                {
                    return;
                }
                if (rec.Amount <= 0)
                {
                    return;
                }
                if (rec.Items.Any(ite => Session.Character.Inventory.CountItem(ite.ItemVNum) < ite.Amount))
                {
                    return;
                }

                ItemInstance inv = Session.Character.Inventory.AddNewToInventory(rec.ItemVNum, rec.Amount).FirstOrDefault();
                if (inv == null)
                {
                    return;
                }
                if (inv.GetType() == typeof(WearableInstance))
                {
                    if (inv is WearableInstance item && (item.Item.EquipmentSlot == EquipmentType.Armor || item.Item.EquipmentSlot == EquipmentType.MainWeapon ||
                                                         item.Item.EquipmentSlot == EquipmentType.SecondaryWeapon))
                    {
                        item.SetRarityPoint();
                    }
                }
                foreach (RecipeItemDTO ite in rec.Items)
                {
                    Session.Character.Inventory.RemoveItemAmount(ite.ItemVNum, ite.Amount);
                }
                Session.Character.LastUsedItem = 0;
                Session.SendPacket($"pdti 11 {inv.ItemVNum} {rec.Amount} 29 {inv.Upgrade} 0");
                Session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(19, 1, Session.Character.CharacterId, 1324));
                Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("CRAFTED_OBJECT"), inv.Item.Name, rec.Amount), 0));
                Session.Character.IncrementQuests(QuestType.Product, inv.ItemVNum, rec.Amount);
            }
        }