Ejemplo n.º 1
0
 public static void AddRandomBonusPotential(MapleEquip equip, MaplePotentialState grade = MaplePotentialState.Rare, WzEquip equipInfo = null)
 {
     if (equipInfo == null)
     {
         equipInfo = DataBuffer.GetEquipById(equip.ItemId);
     }
 }
Ejemplo n.º 2
0
 private static bool CanAddPotentialOnEquip(MapleEquip equip, MaplePotentialState minimumPotential = MaplePotentialState.None)
 {
     if (equip.PotentialState >= MaplePotentialState.HiddenRare)
     {
         if (equip.PotentialState <= MaplePotentialState.HiddenLegendary)
         {
             return(false);                                                             //not sure if you can use it on hidden
         }
         if (equip.PotentialState > minimumPotential)
         {
             return(false);
         }
     }
     else
     {
         //Check if this
     }
     return(true);
 }
Ejemplo n.º 3
0
        public static ushort GetRandomPotential(MaplePotentialState grade, byte reqLevel, int itemIdFor, bool bonusPotential = false)
        {
            int gradeBaseNum = (int)grade;

            if (grade >= MaplePotentialState.Rare)
            {
                gradeBaseNum -= 16;
            }
            if (gradeBaseNum < 1 || gradeBaseNum > 4)
            {
                return(0);
            }
            gradeBaseNum *= 10000;
            int limit              = gradeBaseNum + 10000;
            int optionSubCategory  = bonusPotential ? 2 : 0; //1 == skill pots but we don't use them for now
            var matchingPotentials = PotentialBuffer.Values.Where(x => x.Id >= gradeBaseNum && x.Id < limit && x.ReqLevel <= reqLevel && x.SubCategory == optionSubCategory && x.FitsItem(itemIdFor)).ToList();
            int index              = Functions.Random(matchingPotentials.Count());

            return((ushort)matchingPotentials[index].Id);
        }
Ejemplo n.º 4
0
        public static void AddRandomPotential(MapleEquip equip, MaplePotentialState minimumGrade = MaplePotentialState.HiddenRare, WzEquip equipInfo = null)
        {
            if (equipInfo == null)
            {
                equipInfo = DataBuffer.GetEquipById(equip.ItemId);
            }
            // 0.25% chance for unique, 5% chance for epic, otherwise rare
            if (minimumGrade > MaplePotentialState.HiddenLegendary)
            {
                minimumGrade -= 16;
            }
            equip.PotentialState = Functions.MakeChance(5) ? (Functions.MakeChance(5) ? MaplePotentialState.HiddenUnique : MaplePotentialState.HiddenEpic) : MaplePotentialState.HiddenRare;
            if (equip.PotentialState < minimumGrade)
            {
                equip.PotentialState = minimumGrade;
            }
            MaplePotentialState lowerGrade = equip.PotentialState == MaplePotentialState.HiddenRare ? MaplePotentialState.HiddenRare : equip.PotentialState - 1;

            equip.Potential1 = DataBuffer.GetRandomPotential(equip.PotentialState, equipInfo.ReqLevel, equip.ItemId);
            equip.Potential2 = DataBuffer.GetRandomPotential(Functions.MakeChance(20) ? equip.PotentialState : lowerGrade, equipInfo.ReqLevel, equip.ItemId); // 20% chance to be of the same grade as line 1, otherwise 1 lower
            equip.Potential3 = Functions.MakeChance(7) ? DataBuffer.GetRandomPotential(lowerGrade, equipInfo.ReqLevel, equip.ItemId) : (ushort)0;             // 7% chance for 3rd line
        }
Ejemplo n.º 5
0
        public static bool UsePotentialScroll(MapleEquip equip, MapleItem scroll, MapleCharacter chr)
        {
            int successChance;
            int curseChance           = 0;
            MaplePotentialState grade = MaplePotentialState.Rare;

            switch (scroll.ItemId)
            {
            //Potential scrolls:
            case 2049401:
            case 2049408:
            {
                successChance = 70;
                curseChance   = 100;
                break;
            }

            case 2049416:
            {
                successChance = 70;
                break;
            }

            case 2049400:
            case 2049407:
            case 2049412:
            case 2049413:
            {
                successChance = 90;
                curseChance   = 100;
                break;
            }

            case 2049402:
            case 2049417:
            case 2049406:
            {
                successChance = 100;
                break;
            }

            //Epic potential scrolls:
            case 2049700:
            //case 2049702: ?
            case 2049703:
            case 2049706:
            {
                successChance = 100;
                grade         = MaplePotentialState.Epic;
                break;
            }

            case 2049702:
            {
                successChance = 80;
                curseChance   = 20;
                grade         = MaplePotentialState.Epic;
                break;
            }

            case 2049704:
            case 2049707:
            {
                successChance = 40;
                grade         = MaplePotentialState.Epic;
                break;
            }

            case 2049709:
            {
                curseChance = 50;
                goto case 2049705;
            }

            case 2049705:
            case 2049708:
            case 2049710:
            {
                successChance = 50;
                grade         = MaplePotentialState.Epic;
                break;
            }

            //Unique potential scrolls:
            case 2049750:
            case 2049753:
            {
                successChance = 80;
                grade         = MaplePotentialState.Unique;
                break;
            }

            case 2049751:
            case 2049754:
            {
                successChance = 60;
                grade         = MaplePotentialState.Unique;
                break;
            }

            case 2049757:
            case 2049758:
            {
                successChance = 50;
                grade         = MaplePotentialState.Unique;
                break;
            }

            case 2049752:
            case 2049755:
            case 2049756:
            {
                successChance = 30;
                grade         = MaplePotentialState.Unique;
                break;
            }

            default:
            {
                chr.SendPopUpMessage("You cannot use this item");
                chr.EnableActions();
                return(false);
            }
            }
            //Item has potential but it's hidden or is same rank as the potential given by the scroll
            if (equip.PotentialState != MaplePotentialState.None && (equip.PotentialState < MaplePotentialState.Rare || equip.PotentialState >= grade))
            {
                return(false);
            }
            if (equip.CheckAndRemoveFlag(MapleItemFlags.LuckyDay))
            {
                successChance += 10;
            }
            bool destroyed        = false;
            bool removeScroll     = true;
            bool scrollProtection = equip.CheckAndRemoveFlag(MapleItemFlags.ScrollProtection);
            bool curseProtection  = curseChance > 0 && equip.CheckAndRemoveFlag(MapleItemFlags.CurseProtection);
            byte scrollResult;

            if (Functions.MakeChance(successChance))
            {
                scrollResult = 1;
                AddRandomPotential(equip);
            }
            else
            {
                scrollResult = 0;
                destroyed    = !curseProtection && Functions.MakeChance(curseChance);
                removeScroll = !scrollProtection;
            }

            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);
            return(true);
        }