Beispiel #1
0
        /// <summary>
        /// Check if the player can begin to salvage an item
        /// </summary>
        /// <param name="player"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        public static bool IsAllowedToBeginWork(GamePlayer player, InventoryItem item)
        {
            if (player.InCombat)
            {
                player.Out.SendMessage("You can't salvage while in combat.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            if (item.IsNotLosingDur || item.IsIndestructible)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.BeginWork.NoSalvage", item.Name + ".  This item is indestructible"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            // using negative numbers to indicate item cannot be salvaged
            if (item.SalvageYieldID < 0)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "Salvage.BeginWork.NoSalvage", item.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            if (item.SlotPosition < (int)eInventorySlot.FirstBackpack || item.SlotPosition > (int)eInventorySlot.LastBackpack)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.IsAllowedToBeginWork.BackpackItems"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            eCraftingSkill skill = CraftingMgr.GetSecondaryCraftingSkillToWorkOnItem(item);

            if (skill == eCraftingSkill.NoCrafting)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.BeginWork.NoSalvage", item.Name + ".  You do not have the required secondary skill"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            if (player.IsCrafting)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.IsAllowedToBeginWork.EndCurrentAction"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            if (player.GetCraftingSkillValue(skill) < (0.75 * CraftingMgr.GetItemCraftLevel(item)))
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.IsAllowedToBeginWork.NotEnoughSkill", item.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Check if the player own can enchant the item
        /// </summary>
        /// <param name="player"></param>
        /// <param name="item"></param>
        /// <param name="percentNeeded">min 50 max 100</param>
        /// <returns></returns>
        public static bool IsAllowedToBeginWork(GamePlayer player, InventoryItem item, int percentNeeded)
        {
            if (item.IsNotLosingDur)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Repair.IsAllowedToBeginWork.CantRepair", item.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            if (item.SlotPosition < (int)eInventorySlot.FirstBackpack || item.SlotPosition > (int)eInventorySlot.LastBackpack)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Repair.IsAllowedToBeginWork.BackpackItems"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            eCraftingSkill skill = CraftingMgr.GetSecondaryCraftingSkillToWorkOnItem(item);

            if (skill == eCraftingSkill.NoCrafting)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Repair.IsAllowedToBeginWork.CantRepair", item.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            if (player.IsCrafting)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Repair.IsAllowedToBeginWork.EndCurrentAction"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            if (item.Condition >= item.MaxCondition)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Repair.IsAllowedToBeginWork.FullyRepaired", item.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            if (player.GetCraftingSkillValue(skill) < ((percentNeeded / 100) * CraftingMgr.GetItemCraftLevel(item)))
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Repair.IsAllowedToBeginWork.NotEnoughSkill", item.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            return(true);
        }
Beispiel #3
0
        /// <summary>
        /// Return the material yield for this salvage.
        /// </summary>
        public static int GetMaterialYield(GamePlayer player, InventoryItem item, SalvageYield salvageYield, ItemTemplate rawMaterial)
        {
            int maxCount = 0;

            if (rawMaterial == null)
            {
                return(0);
            }

            if (ServerProperties.Properties.USE_NEW_SALVAGE)
            {
                maxCount = GetCountForSalvage(item, salvageYield, rawMaterial);
            }
            else
            {
                maxCount = (int)(item.Price * 0.45 / rawMaterial.Price);                 // crafted item return max 45% of the item value in material

                if (item.IsCrafted)
                {
                    maxCount = (int)Math.Ceiling((double)maxCount / 2);
                }
            }

            int playerPercent = player.GetCraftingSkillValue(CraftingMgr.GetSecondaryCraftingSkillToWorkOnItem(item)) * 100 / CraftingMgr.GetItemCraftLevel(item);

            if (playerPercent > 100)
            {
                playerPercent = 100;
            }
            else if (playerPercent < 75)
            {
                playerPercent = 75;
            }

            int minCount = (int)(((maxCount - 1) / 25f) * playerPercent) - ((3 * maxCount) - 4);             //75% => min = 1; 100% => min = maxCount;

            salvageYield.Count = Util.Random(minCount, maxCount);
            return(salvageYield.Count);
        }
Beispiel #4
0
        /// <summary>
        /// Calculate the chance of sucess
        /// </summary>
        protected static int CalculateSuccessChances(GamePlayer player, InventoryItem item)
        {
            eCraftingSkill skill = CraftingMgr.GetSecondaryCraftingSkillToWorkOnItem(item);

            if (skill == eCraftingSkill.NoCrafting)
            {
                return(0);
            }

            int chancePercent = (int)((90 / (CraftingMgr.GetItemCraftLevel(item) * 0.5)) * player.GetCraftingSkillValue(skill)) - 80;             // 50% = 10% chance, 100% = 100% chance

            if (chancePercent > 100)
            {
                chancePercent = 100;
            }
            else if (chancePercent < 0)
            {
                chancePercent = 0;
            }

            return(chancePercent);
        }