Пример #1
0
        public static bool CubeItem(MapleEquip equip, CubeType cubeType, MapleCharacter chr, bool reveal = false)
        {
            WzEquip equipInfo = DataBuffer.GetEquipById(equip.ItemId);

            if (equipInfo == null || !CanCube(equip, equipInfo))
            {
                return(false);
            }
            int    currentLines             = equip.Potential3 > 0 ? 3 : 2;
            double lineIncreaseChance       = 0;
            double gradeIncreaseChance      = 0;
            double gradeDecreaseChance      = 0;
            int    otherLinesIncreaseChance = 0; //chance to increase the other lines' grade to the current grade

            switch (cubeType)
            {
            case CubeType.Occult:
            {
                switch (equip.PotentialState)
                {
                case MaplePotentialState.Rare:
                {
                    gradeIncreaseChance = 4;
                    break;
                }

                case MaplePotentialState.Epic:
                {
                    gradeIncreaseChance      = 2;
                    gradeDecreaseChance      = 2;
                    otherLinesIncreaseChance = 15;
                    break;
                }

                case MaplePotentialState.Unique:
                {
                    gradeDecreaseChance      = 3;
                    otherLinesIncreaseChance = 5;
                    break;
                }

                default:
                    return(false);
                }
                break;
            }

            case CubeType.MasterCraftsman:
            {
                switch (equip.PotentialState)
                {
                case MaplePotentialState.Rare:
                {
                    gradeIncreaseChance = 5;
                    break;
                }

                case MaplePotentialState.Epic:
                {
                    otherLinesIncreaseChance = 20;
                    gradeIncreaseChance      = 3;
                    break;
                }

                case MaplePotentialState.Unique:
                    otherLinesIncreaseChance = 5;
                    break;

                default:
                    return(false);
                }
                break;
            }

            case CubeType.Meister:
            {
                lineIncreaseChance = 5;
                switch (equip.PotentialState)
                {
                case MaplePotentialState.Rare:
                {
                    gradeIncreaseChance = 6;
                    break;
                }

                case MaplePotentialState.Epic:
                {
                    otherLinesIncreaseChance = 30;
                    gradeIncreaseChance      = 4;
                    break;
                }

                case MaplePotentialState.Unique:
                {
                    otherLinesIncreaseChance = 20;
                    gradeIncreaseChance      = 2;
                    break;
                }

                case MaplePotentialState.Legendary:
                {
                    otherLinesIncreaseChance = 10;
                    break;
                }

                default:
                    return(false);
                }
                break;
            }

            case CubeType.PlatinumMiracle:
            {
                lineIncreaseChance = 7;
                switch (equip.PotentialState)
                {
                case MaplePotentialState.Rare:
                {
                    gradeIncreaseChance = 15;
                    break;
                }

                case MaplePotentialState.Epic:
                {
                    otherLinesIncreaseChance = 40;
                    gradeIncreaseChance      = 10;
                    break;
                }

                case MaplePotentialState.Unique:
                {
                    otherLinesIncreaseChance = 30;
                    gradeIncreaseChance      = 4;
                    break;
                }

                case MaplePotentialState.Legendary:
                {
                    otherLinesIncreaseChance = 20;
                    break;
                }

                default:
                    return(false);
                }
                break;
            }

            default:
                return(false);
            }
            if (currentLines == 2 && Functions.MakeChance(lineIncreaseChance))
            {
                currentLines = 3;
            }
            if (Functions.MakeChance(gradeIncreaseChance) && equip.PotentialState < MaplePotentialState.Legendary)
            {
                equip.PotentialState++;
            }
            else if (Functions.MakeChance(gradeDecreaseChance) && equip.PotentialState > MaplePotentialState.Rare)
            {
                equip.PotentialState--;
            }
            ushort[] newLines = new ushort[currentLines];
            newLines[0] = DataBuffer.GetRandomPotential(equip.PotentialState, equipInfo.ReqLevel, equip.ItemId);
            for (int i = 1; i < newLines.Length; i++)
            {
                if (equip.PotentialState == MaplePotentialState.Rare || Functions.MakeChance(otherLinesIncreaseChance))
                {
                    newLines[i] = DataBuffer.GetRandomPotential(equip.PotentialState, equipInfo.ReqLevel, equip.ItemId);
                }
                else
                {
                    newLines[i] = DataBuffer.GetRandomPotential(equip.PotentialState - 1, equipInfo.ReqLevel, equip.ItemId);
                }
            }
            newLines = newLines.OrderByDescending(x => x).ToArray();

            equip.Potential1 = newLines[0];
            equip.Potential2 = newLines[1];
            if (currentLines == 3)
            {
                equip.Potential3 = newLines[2];
            }
            if (!reveal)
            {
                equip.PotentialState -= 16; // Hide potential, needs to be revealed
            }
            equip.SaveToDatabase(chr);
            chr.Client.SendPacket(MapleInventory.Packets.AddItem(equip, MapleInventoryType.Equip, equip.Position));
            return(true);
        }
Пример #2
0
        public static void UseRegularEquipScroll(MapleCharacter chr, MapleEquip equip, MapleItem scroll, bool whiteScroll)
        {
            WzItemEnhancer scrollInfo = DataBuffer.GetItemById(scroll.ItemId) as WzItemEnhancer;

            if (scrollInfo == null)
            {
                return;
            }
            WzEquip equipInfo = DataBuffer.GetEquipById(equip.ItemId);
            string  reason    = "";

            if (equipInfo == null || !CanScroll(equip, equipInfo, scrollInfo, out reason))
            {
                chr.SendPopUpMessage("You cannot use that scroll on this item. " + reason);
                chr.EnableActions();
                return;
            }
            byte upgradeSlotsUsed = 1;
            int  scrollBaseId     = scroll.ItemId / 100;

            if (scrollBaseId == 20490 ||    //clean slate scroll
                scrollBaseId == 20493 ||    //equip enhancement scroll
                scrollBaseId == 20496)      //innocence scroll
            {
                upgradeSlotsUsed = 0;
            }

            switch (scroll.ItemId)
            {
            case 2040727:     //Scroll for Spikes on Shoes
            case 2041058:     //Scroll for Cape for Cold Protection
                upgradeSlotsUsed = 0;
                break;
            }
            int value;

            if (scrollInfo.StatEnhancements.TryGetValue("tuc", out value)) //Uses multiple upgrade slots
            {
                upgradeSlotsUsed = (byte)value;
            }
            if (equip.RemainingUpgradeCount < upgradeSlotsUsed)
            {
                chr.SendPopUpMessage(string.Format("This item does not have enough upgrades available"));
                chr.EnableActions();
                return;
            }
            byte scrollResult = 0;

            bool destroyed              = false;
            bool removeScroll           = true;
            int  chance                 = scrollInfo.Chance;
            bool scrollProtection       = equip.CheckAndRemoveFlag(MapleItemFlags.ScrollProtection);
            bool upgradeCountProtection = upgradeSlotsUsed > 0 && equip.CheckAndRemoveFlag(MapleItemFlags.UpgradeCountProtection);
            bool curseProtection        = equip.CheckAndRemoveFlag(MapleItemFlags.CurseProtection);

            if (equip.CheckAndRemoveFlag(MapleItemFlags.LuckyDay))
            {
                chance += 10;
            }

            if (Functions.MakeChance(chance))
            {
                scrollResult        = 1;
                equip.UpgradeCount += upgradeSlotsUsed;
                foreach (var kvp in scrollInfo.StatEnhancements)
                {
                    switch (kvp.Key)
                    {
                    case "incPDD":
                        equip.Pdd += (short)kvp.Value;
                        break;

                    case "incMDD":
                        equip.Mdd += (short)kvp.Value;
                        break;

                    case "incACC":
                        equip.Acc += (short)kvp.Value;
                        break;

                    case "incMHP":
                        equip.IncMhp += (short)kvp.Value;
                        break;

                    case "incINT":
                        equip.Int += (short)kvp.Value;
                        break;

                    case "incDEX":
                        equip.Dex += (short)kvp.Value;
                        break;

                    case "incMAD":
                        equip.Mad += (short)kvp.Value;
                        break;

                    case "incPAD":
                        equip.Pad += (short)kvp.Value;
                        break;

                    case "incEVA":
                        equip.Eva += (short)kvp.Value;
                        break;

                    case "incLUK":
                        equip.Luk += (short)kvp.Value;
                        break;

                    case "incMMP":
                        equip.IncMmp += (short)kvp.Value;
                        break;

                    case "incSTR":
                        equip.Str += (short)kvp.Value;
                        break;

                    case "incSpeed":
                        equip.Speed += (short)kvp.Value;
                        break;

                    case "incJump":
                        equip.Jump += (short)kvp.Value;
                        break;

                    case "incCraft":
                        equip.Diligence += (short)kvp.Value;
                        break;

                    case "preventslip":
                        equip.Flags |= MapleItemFlags.NoSlip;
                        break;

                    case "warmsupport":
                        equip.Flags |= MapleItemFlags.ColdResistance;
                        break;

                    case "recover":
                    {
                        int totalPossibleUpgrades = equipInfo.TotalUpgradeCount + equip.HammersApplied;
                        int failedUpgrades        = totalPossibleUpgrades - equip.UpgradeCount - equip.RemainingUpgradeCount;
                        int toRestore             = Math.Min(failedUpgrades, kvp.Value);
                        if (toRestore > 0)
                        {
                            equip.RemainingUpgradeCount += (byte)toRestore;
                        }
                        break;
                    }

                    case "randstat":     //chaos scroll
                    {
                        bool betterStats = scrollInfo.StatEnhancements.ContainsKey("incRandVol");
                        bool noNegative  = scrollInfo.StatEnhancements.ContainsKey("noNegative");

                        if (equip.Str > 0)
                        {
                            equip.Str = GetNewChaosStat(equip.Str, betterStats, noNegative);
                        }
                        if (equip.Dex > 0)
                        {
                            equip.Dex = GetNewChaosStat(equip.Dex, betterStats, noNegative);
                        }
                        if (equip.Int > 0)
                        {
                            equip.Int = GetNewChaosStat(equip.Int, betterStats, noNegative);
                        }
                        if (equip.Luk > 0)
                        {
                            equip.Luk = GetNewChaosStat(equip.Luk, betterStats, noNegative);
                        }
                        if (equip.Pad > 0)
                        {
                            equip.Pad = GetNewChaosStat(equip.Pad, betterStats, noNegative);
                        }
                        if (equip.Mad > 0)
                        {
                            equip.Mad = GetNewChaosStat(equip.Mad, betterStats, noNegative);
                        }
                        if (equip.Pdd > 0)
                        {
                            equip.Pdd = GetNewChaosStat(equip.Pdd, betterStats, noNegative);
                        }
                        if (equip.Mdd > 0)
                        {
                            equip.Mdd = GetNewChaosStat(equip.Mdd, betterStats, noNegative);
                        }
                        if (equip.Acc > 0)
                        {
                            equip.Acc = GetNewChaosStat(equip.Acc, betterStats, noNegative);
                        }
                        if (equip.Eva > 0)
                        {
                            equip.Eva = GetNewChaosStat(equip.Eva, betterStats, noNegative);
                        }
                        if (equip.Speed > 0)
                        {
                            equip.Speed = GetNewChaosStat(equip.Speed, betterStats, noNegative);
                        }
                        if (equip.Jump > 0)
                        {
                            equip.Jump = GetNewChaosStat(equip.Jump, betterStats, noNegative);
                        }
                        if (equip.IncMhp > 0)
                        {
                            equip.IncMhp = GetNewChaosStat(equip.IncMhp, betterStats, noNegative);
                        }
                        if (equip.IncMmp > 0)
                        {
                            equip.IncMmp = GetNewChaosStat(equip.IncMmp, betterStats, noNegative);
                        }
                        break;
                    }

                    case "reset":
                    {
                        equip.SetDefaultStats(equipInfo, true);
                        break;
                    }

                    case "perfectReset":
                    {
                        equip.SetDefaultStats(equipInfo);
                        break;
                    }
                    }
                    equip.SaveToDatabase(chr);
                }
            }
            else //Fail
            {
                int cursedChance;
                if (scrollInfo.StatEnhancements.TryGetValue("cursed", out cursedChance))
                {
                    destroyed = !curseProtection && Functions.MakeChance(cursedChance);
                }
                if (scrollProtection)
                {
                    removeScroll = false;
                }
                if (upgradeCountProtection)
                {
                    upgradeSlotsUsed = 0;
                }
                //todo: white scroll
            }

            equip.RemainingUpgradeCount -= upgradeSlotsUsed;

            if (removeScroll)
            {
                chr.Inventory.RemoveItemsFromSlot(scroll.InventoryType, scroll.Position, 1);
            }

            if (destroyed)
            {
                chr.Inventory.RemoveItem(equip.InventoryType, equip.Position);
                scrollResult = 2;
            }
            else
            {
                chr.Client.SendPacket(MapleInventory.Packets.AddItem(equip, equip.InventoryType, equip.Position)); //Update item stats
            }
            chr.Map.BroadcastPacket(Packets.ShowScrollEffect(chr.Id, scrollResult, scroll.ItemId, equip.ItemId), chr, true);
        }