Пример #1
0
        private static void AddDrop(WorldClient client, string[] args)
        {
            if (args.Length < 4)
            {
                client.Character.Reply("Add a drop to a set of monsters");
                client.Character.Reply("» .drops adddrop|ad $ItemId $DropRateG1[,$G2,$G3,G4,G5] $MinPP $MinCount $MaxCount [$MonsterId ...]");
                client.Character.Reply(" - <b>$ItemId</b> ⇒ The ID of the item.");
                client.Character.Reply(" - <b>$DropRateG1</b> ⇒ The drop percent [0, 100]. ");
                client.Character.Reply(" - <b>$G2,3,4,5</b> ⇒ The drop percent [0, 100] for each grade. ");
                client.Character.Reply(" - <b>$MinPP</b> ⇒ The min PP value0.");
                client.Character.Reply(" - <b>$MinCount</b> ⇒ Minimum number of dropped items.");
                client.Character.Reply(" - <b>$MaxCount</b> ⇒ Maximum number of dropped items.");
                client.Character.Reply(" - <b>$MonsterId</b> ⇒ The ID of the monster.");

                return;
            }

            ushort itemId   = ushort.Parse(args[1]);
            string rates    = args[2];
            int    pp       = int.Parse(args[3]);
            int    minCount = int.Parse(args[4]);
            int    maxCount = int.Parse(args[5]);

            string[] ratesSplit = rates.Split(',');
            short    g1         = short.Parse(ratesSplit[0]);
            short    g2         = (short)(g1 + 2);
            short    g3         = (short)(g1 + 4);
            short    g4         = (short)(g1 + 6);
            short    g5         = (short)(g1 + 8);

            if (ratesSplit.Length == 5)
            {
                g2 = short.Parse(ratesSplit[1]);
                g3 = short.Parse(ratesSplit[2]);
                g4 = short.Parse(ratesSplit[3]);
                g5 = short.Parse(ratesSplit[4]);
            }


            ItemRecord item = ItemRecord.GetItem(itemId);

            int nextDropId = MonsterRecord.GetNextDropId();

            for (int i = 6; i < args.Length; i++)
            {
                ushort monsterId = ushort.Parse(args[i]);

                MonsterRecord monster = MonsterRecord.GetMonster(monsterId);

                MonsterDrop drop = new MonsterDrop()
                {
                    ItemId               = itemId,
                    Count                = minCount,
                    DropId               = nextDropId,
                    DropLimit            = maxCount,
                    HasCriteria          = false,
                    PercentDropForGrade1 = g1,
                    PercentDropForGrade2 = g2,
                    PercentDropForGrade3 = g3,
                    PercentDropForGrade4 = g4,
                    PercentDropForGrade5 = g5,
                    ProspectingLock      = pp
                };

                monster.Drops.Add(drop);

                // TODO: check if necessary.
                monster.UpdateInstantElement();

                client.Character.Reply($"Added drop '{item.Name}' ({itemId}) to monster '{monster.Name}' ({monsterId}) with drop rates {g1},{g2},{g3},{g4},{g5} (DropId={nextDropId}).");
                nextDropId++;
            }
        }