Exemplo n.º 1
0
        public static void craftDragonHide(Player p, int amount, int itemIndex, int leatherType, bool newCraft)
        {
            if (newCraft)
            {
                itemIndex = leatherType != 0 ? itemIndex += leatherType : itemIndex;
                p.setTemporaryAttribute("craftItem", new CraftItem(leatherType, itemIndex, amount, (double)LEATHER_ITEMS[itemIndex][2], (int)LEATHER_ITEMS[itemIndex][0], (string)LEATHER_ITEMS[itemIndex][4], (int)LEATHER_ITEMS[itemIndex][1]));
            }
            CraftItem item = (CraftItem)p.getTemporaryAttribute("craftItem");

            if (item == null || p == null || item.getAmount() <= 0)
            {
                Crafting.resetCrafting(p);
                return;
            }
            p.getPackets().closeInterfaces();
            int index = item.getCraftItem();

            if (p.getSkills().getGreaterLevel(Skills.SKILL.CRAFTING) < item.getLevel())
            {
                p.getPackets().sendMessage("You need a Crafting level of " + item.getLevel() + " to craft that item.");
                Crafting.resetCrafting(p);
                return;
            }
            if (!p.getInventory().hasItemAmount(TANNED_HIDE[item.getCraftType()], (int)LEATHER_ITEMS[index][3]))
            {
                p.getPackets().sendMessage("You need " + (int)LEATHER_ITEMS[index][3] + " dragonhide to craft that.");
                Crafting.resetCrafting(p);
                return;
            }
            if (!p.getInventory().hasItem(NEEDLE))
            {
                p.getPackets().sendMessage("You need a needle if you wish to craft leather.");
                Crafting.resetCrafting(p);
                return;
            }
            if (!p.getInventory().hasItemAmount(THREAD, (int)LEATHER_ITEMS[index][3]))
            {
                p.getPackets().sendMessage("You need " + (int)LEATHER_ITEMS[index][3] + " thread to craft that.");
                Crafting.resetCrafting(p);
                return;
            }
            string s = index < 4 ? "a" : "a pair of";

            for (int j = 0; j < (int)LEATHER_ITEMS[index][3]; j++)
            {
                if (!p.getInventory().deleteItem(TANNED_HIDE[item.getCraftType()]))
                {
                    return;
                }
            }
            p.getInventory().deleteItem(THREAD, (int)LEATHER_ITEMS[index][3]);
            p.getInventory().addItem(item.getFinishedItem());
            p.getSkills().addXp(Skills.SKILL.CRAFTING, item.getXp());
            p.setLastAnimation(new Animation(1249));
            p.getPackets().sendMessage("You craft " + s + " " + item.getMessage() + ".");
            item.decreaseAmount();
            if (item.getAmount() >= 1)
            {
                Event craftMoreDragonHide = new Event(1500);
                craftMoreDragonHide.setAction(() => {
                    craftDragonHide(p, -1, -1, -1, false);
                    craftMoreDragonHide.stop();
                });
                Server.registerEvent(craftMoreDragonHide);
            }
        }
Exemplo n.º 2
0
        public static void makeJewellery(Player p, int buttonId, int amount, bool newCraft)
        {
            int index = -1;

            if (newCraft)
            {
                int        itemType = getIndex(buttonId, true);
                object[][] items    = getItemArray(p, itemType);
                index = getIndex(buttonId, false);
                if (index == -1)
                {
                    p.getPackets().closeInterfaces();
                    return;
                }
                p.setTemporaryAttribute("craftItem", new CraftItem(itemType, index, amount, (double)items[index][2], (int)items[index][0], (string)items[index][3], (int)items[index][1]));
            }
            CraftItem item = (CraftItem)p.getTemporaryAttribute("craftItem");

            if (item == null || p == null || item.getAmount() <= 0)
            {
                Crafting.resetCrafting(p);
                p.getPackets().closeInterfaces();
                return;
            }
            p.getPackets().closeInterfaces();
            index = item.getCraftItem();
            Console.WriteLine(index);
            int    index2  = index;
            string gemType = (string)GEMS[index2 - 1][4];
            string s       = index == 3 ? "an" : "a";

            if (p.getSkills().getGreaterLevel(Skills.SKILL.CRAFTING) < item.getLevel())
            {
                p.getPackets().sendMessage("You need a Crafting level of " + item.getLevel() + " to craft a " + gemType + " " + item.getMessage() + ".");
                Crafting.resetCrafting(p);
                return;
            }
            if (!p.getInventory().hasItem(JEWELLERY_INTERFACE_VARS[item.getCraftType()][0]))
            {
                p.getPackets().sendMessage("You need " + s + " " + item.getMessage() + " mould to craft that.");
                Crafting.resetCrafting(p);
                return;
            }
            if (!p.getInventory().hasItem(GOLD_BAR))
            {
                p.getPackets().sendMessage("You need a Gold bar to craft an item of jewellery.");
                Crafting.resetCrafting(p);
                return;
            }
            if (index2 > 0)           // We dont need gems for gold bars
            {
                if (!p.getInventory().hasItem((int)GEMS[index2 - 1][1]))
                {
                    p.getPackets().sendMessage("You don't have a cut " + (string)GEMS[index2 - 1][4] + ".");
                    Crafting.resetCrafting(p);
                    return;
                }
            }
            if (p.getInventory().deleteItem(GOLD_BAR))
            {
                if (index2 > 0)
                {
                    if (!p.getInventory().deleteItem((int)GEMS[index2 - 1][1]))
                    {
                        return;
                    }
                }
                p.setLastAnimation(new Animation(3243));
                p.getInventory().addItem(item.getFinishedItem());
                p.getSkills().addXp(Skills.SKILL.CRAFTING, item.getXp());
                string message = index2 == 0 ? "You smelt the gold bar into a Gold " + item.getMessage() : "You fuse the Gold bar and " + (string)GEMS[index2 - 1][4] + " together, and create a " + (string)GEMS[index2 - 1][4] + " " + item.getMessage();
                p.getPackets().sendMessage(message + ".");
            }
            item.decreaseAmount();
            if (item.getAmount() >= 1)
            {
                Event makeMoreJewelleryEvent = new Event(1500);
                makeMoreJewelleryEvent.setAction(() => {
                    makeJewellery(p, -1, -1, false);
                    makeMoreJewelleryEvent.stop();
                });
                Server.registerEvent(makeMoreJewelleryEvent);
            }
        }