Exemplo n.º 1
0
        public static void craftClay(Player p, int amount, int craftType, int craftItem, bool newCraft)
        {
            if (newCraft)
            {
                if ((craftType != 1 && craftType != 2) || craftItem < 0 || craftItem > 4)
                {
                    return;
                }
                int index   = craftItem;
                int endItem = craftType == 1 ? 0 : 1;
                int xp      = craftType == 1 ? 3 : 4;
                p.setTemporaryAttribute("craftItem", new CraftItem(craftType, craftItem, amount, (double)CLAY_ITEMS[index][xp], (int)CLAY_ITEMS[index][endItem], (string)CLAY_ITEMS[index][5], (int)CLAY_ITEMS[index][2]));
            }
            CraftItem item = (CraftItem)p.getTemporaryAttribute("craftItem");

            if (item == null || p == null || item.getAmount() <= 0)
            {
                Crafting.resetCrafting(p);
                return;
            }
            int    neededItem = item.getCraftType() == 1 ? CLAY : (int)CLAY_ITEMS[item.getCraftItem()][0];
            string s          = item.getCraftType() == 1 ? "You mould the clay into a " + item.getMessage() : "You bake the " + item.getMessage() + " in the oven";
            string s1         = item.getCraftType() == 1 ? "You need some soft clay to mould a " + item.getMessage() : "You need a pre-made " + item.getMessage() + " to put in the oven";
            int    animation  = item.getCraftType() == 1 ? 883 : 899;

            if (p.getSkills().getGreaterLevel(Skills.SKILL.CRAFTING) < item.getLevel())
            {
                p.getPackets().sendMessage("You need a Crafting level of " + item.getLevel() + " to make a " + item.getMessage() + ".");
                Crafting.resetCrafting(p);
                return;
            }
            if (!p.getInventory().hasItem(neededItem))
            {
                p.getPackets().sendMessage(s1 + ".");
                Crafting.resetCrafting(p);
                return;
            }
            p.getPackets().closeInterfaces();
            if (p.getInventory().deleteItem(neededItem))
            {
                if (p.getInventory().addItem(item.getFinishedItem()))
                {
                    p.getSkills().addXp(Skills.SKILL.CRAFTING, item.getXp());
                    p.getPackets().sendMessage(s + ".");
                    p.setLastAnimation(new Animation(animation));
                }
            }
            item.decreaseAmount();
            if (item.getAmount() >= 1)
            {
                Event craftMoreClayEvent = new Event(1500);
                craftMoreClayEvent.setAction(() =>
                {
                    craftClay(p, -1, -1, -1, false);
                    craftMoreClayEvent.stop();
                });
                Server.registerEvent(craftMoreClayEvent);
            }
        }
Exemplo n.º 2
0
        public static void cutGem(Player p, int index, int amount, bool newCut)
        {
            index -= 50;
            if (newCut)
            {
                p.setTemporaryAttribute("craftItem", new CraftItem(5, index, amount, (double)GEMS[index][3], (int)GEMS[index][1], (string)GEMS[index][4], (int)GEMS[index][2]));
            }
            CraftItem item = (CraftItem)p.getTemporaryAttribute("craftItem");

            if (item == null || p == null || item.getAmount() <= 0 || item.getCraftType() != 5)
            {
                Crafting.resetCrafting(p);
                return;
            }
            p.getPackets().closeInterfaces();
            if (!p.getInventory().hasItem(CHISEL))
            {
                p.getPackets().sendMessage("You cannot cut gems without a chisel.");
                Crafting.resetCrafting(p);
                return;
            }
            if (!p.getInventory().hasItem((int)GEMS[item.getCraftItem()][0]))
            {
                if (newCut)
                {
                    p.getPackets().sendMessage("You have no " + item.getMessage() + " to cut.");
                }
                else
                {
                    p.getPackets().sendMessage("You have no more " + item.getMessage() + "'s to cut.");
                }
                Crafting.resetCrafting(p);
                return;
            }
            if (p.getSkills().getGreaterLevel(Skills.SKILL.CRAFTING) < item.getLevel())
            {
                p.getPackets().sendMessage("You need a Crafting level of " + item.getLevel() + " to cut that gem.");
                Crafting.resetCrafting(p);
                return;
            }
            if (p.getInventory().deleteItem((int)GEMS[item.getCraftItem()][0]))
            {
                p.getInventory().addItem(item.getFinishedItem());
                p.getSkills().addXp(Skills.SKILL.CRAFTING, item.getXp());
                p.setLastAnimation(new Animation((int)GEMS[item.getCraftItem()][5]));
                p.getPackets().sendMessage("You cut the " + item.getMessage() + ".");
            }
            item.decreaseAmount();
            if (item.getAmount() >= 1)
            {
                Event cutMoreGemEvent = new Event(1500);
                cutMoreGemEvent.setAction(() =>
                {
                    cutGem(p, -1, -1, false);
                    cutMoreGemEvent.stop();
                });
                Server.registerEvent(cutMoreGemEvent);
            }
        }
Exemplo n.º 3
0
        public static void newSilverItem(Player p, int amount, int index, bool newCraft)
        {
            index -= 120;
            if (newCraft)
            {
                p.setTemporaryAttribute("craftItem", new CraftItem(3, index, amount, (double)SILVER_ITEMS[index][3], (int)SILVER_ITEMS[index][0], (string)SILVER_ITEMS[index][4], (int)SILVER_ITEMS[index][2]));
            }
            CraftItem item = (CraftItem)p.getTemporaryAttribute("craftItem");

            if (item == null || p == null || item.getAmount() <= 0 || item.getCraftType() != 3)
            {
                Crafting.resetCrafting(p);
                return;
            }
            p.getPackets().closeInterfaces();
            string s = item.getCraftItem() == 0 ? "an" : "a";

            if (!p.getInventory().hasItem((int)SILVER_ITEMS[item.getCraftItem()][1]))
            {
                p.getPackets().sendMessage("You need " + s + " " + item.getMessage() + " mould to make that.");
                Crafting.resetCrafting(p);
                return;
            }
            if (!p.getInventory().hasItem(SILVER_BAR))
            {
                p.getPackets().sendMessage("You don't have a Silver bar.");
                Crafting.resetCrafting(p);
                return;
            }
            if (p.getSkills().getGreaterLevel(Skills.SKILL.CRAFTING) < item.getLevel())
            {
                p.getPackets().sendMessage("You need a Crafting level of " + item.getLevel() + " to smelt that.");
                Crafting.resetCrafting(p);
                return;
            }
            if (p.getInventory().deleteItem(SILVER_BAR))
            {
                p.getInventory().addItem(item.getFinishedItem());
                p.getSkills().addXp(Skills.SKILL.CRAFTING, item.getXp());
                p.setLastAnimation(new Animation(3243));
                p.getPackets().sendMessage("You smelt the Silver bar in to " + s + " " + item.getMessage() + ".");
            }
            item.decreaseAmount();
            if (item.getAmount() >= 1)
            {
                Event makeMoreSilverItemEvent = new Event(1500);
                makeMoreSilverItemEvent.setAction(() =>
                {
                    newSilverItem(p, -1, -1, false);
                    makeMoreSilverItemEvent.stop();
                });
                Server.registerEvent(makeMoreSilverItemEvent);
            }
        }
Exemplo n.º 4
0
        public static void craftGlass(Player p, int amount, int index, bool newCraft)
        {
            if (newCraft)
            {
                p.setTemporaryAttribute("craftItem", new CraftItem(3, index, amount, (double)GLASS_ITEMS[index][2], (int)GLASS_ITEMS[index][0], (string)GLASS_ITEMS[index][3], (int)GLASS_ITEMS[index][1]));
            }
            CraftItem item = (CraftItem)p.getTemporaryAttribute("craftItem");

            if (item == null || p == null || item.getAmount() <= 0 || item.getCraftType() != 3)
            {
                Crafting.resetCrafting(p);
                return;
            }
            p.getPackets().closeInterfaces();
            if (!p.getInventory().hasItem(MOLTEN_GLASS))
            {
                p.getPackets().sendMessage("You have no molten glass.");
                Crafting.resetCrafting(p);
                return;
            }
            if (!p.getInventory().hasItem(GLASSBLOWING_PIPE))
            {
                p.getPackets().sendMessage("You need a glassblowing pipe if you wish to make a glass item.");
                Crafting.resetCrafting(p);
                return;
            }
            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().deleteItem(MOLTEN_GLASS))
            {
                p.getInventory().addItem(item.getFinishedItem());
                p.getSkills().addXp(Skills.SKILL.CRAFTING, item.getXp());
                p.setLastAnimation(new Animation(884));
                p.getPackets().sendMessage("You blow through the pipe, shaping the molten glass into a " + item.getMessage() + ".");
            }
            item.decreaseAmount();
            if (item.getAmount() >= 1)
            {
                Event craftMoreGlassEvent = new Event(1500);
                craftMoreGlassEvent.setAction(() =>
                {
                    craftGlass(p, -1, -1, false);
                    craftMoreGlassEvent.stop();
                });
                Server.registerEvent(craftMoreGlassEvent);
            }
        }
Exemplo n.º 5
0
        public static void craftSpinning(Player p, int amount, int index, bool newCraft)
        {
            if (newCraft)
            {
                p.setTemporaryAttribute("craftItem", new CraftItem(6, index, amount, (double)SPINNING_ITEMS[index][3], (int)SPINNING_ITEMS[index][0], (string)SPINNING_ITEMS[index][4], (int)SPINNING_ITEMS[index][2]));
            }
            CraftItem item = (CraftItem)p.getTemporaryAttribute("craftItem");

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

            if (!p.getInventory().hasItem((int)SPINNING_ITEMS[i][1]))
            {
                p.getPackets().sendMessage("You have no " + item.getMessage() + ".");
                Crafting.resetCrafting(p);
                return;
            }
            if (p.getSkills().getGreaterLevel(Skills.SKILL.CRAFTING) < item.getLevel())
            {
                p.getPackets().sendMessage("You need a Crafting level of " + item.getLevel() + " to spin that.");
                Crafting.resetCrafting(p);
                return;
            }
            if (p.getInventory().deleteItem((int)SPINNING_ITEMS[i][1]))
            {
                p.getInventory().addItem(item.getFinishedItem());
                p.getSkills().addXp(Skills.SKILL.CRAFTING, item.getXp());
                p.setLastAnimation(new Animation(894));
                p.getPackets().sendMessage("You spin the " + item.getMessage() + " into a " + SPIN_FINISH[i] + ".");
            }
            item.decreaseAmount();
            if (item.getAmount() >= 1)
            {
                Event craftMoreSpinningEvent = new Event(750);
                craftMoreSpinningEvent.setAction(() =>
                {
                    craftSpinning(p, -1, -1, false);
                    craftMoreSpinningEvent.stop();
                });
                Server.registerEvent(craftMoreSpinningEvent);
            }
        }
Exemplo n.º 6
0
        public static void stringAmulet(Player p, int index, int amount, bool newString)
        {
            index -= 100;
            if (newString)
            {
                p.setTemporaryAttribute("craftItem", new CraftItem(4, index, amount, STRINGING_XP, STRUNG_AMULETS[index][0], (string)GEMS[index][4] + " amulet", 1));
            }
            CraftItem item = (CraftItem)p.getTemporaryAttribute("craftItem");

            if (item == null || p == null || item.getAmount() <= 0 || item.getCraftType() != 4)
            {
                Crafting.resetCrafting(p);
                return;
            }
            p.getPackets().closeInterfaces();
            if (!p.getInventory().hasItem(BALL_OF_WOOL))
            {
                p.getPackets().sendMessage("You do not have a Ball of wool.");
                Crafting.resetCrafting(p);
                return;
            }
            if (!p.getInventory().hasItem(STRUNG_AMULETS[item.getCraftItem()][1]))
            {
                string s = item.getCraftItem() == 1 || item.getCraftItem() == 5 ? "an" : "a";
                p.getPackets().sendMessage("You don't have " + s + " " + GEMS[item.getCraftItem()][4] + " unstrung amulet to string.");
                Crafting.resetCrafting(p);
                return;
            }
            if (p.getInventory().deleteItem(STRUNG_AMULETS[item.getCraftItem()][1]) && p.getInventory().deleteItem(BALL_OF_WOOL))
            {
                p.getInventory().addItem(item.getFinishedItem());
                p.getSkills().addXp(Skills.SKILL.CRAFTING, STRINGING_XP);
                p.getPackets().sendMessage("You add a string to the amulet.");
            }
            item.decreaseAmount();
            if (item.getAmount() >= 1)
            {
                Event stringMoreAmuletEvent = new Event(1000);
                stringMoreAmuletEvent.setAction(() =>
                {
                    stringAmulet(p, -1, -1, false);
                    stringMoreAmuletEvent.stop();
                });
                Server.registerEvent(stringMoreAmuletEvent);
            }
        }
Exemplo n.º 7
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);
            }
        }
Exemplo n.º 8
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.º 9
0
        public static void craftNormalLeather(Player p, int index, int amount, bool newCraft)
        {
            index -= 28;
            if (newCraft)
            {
                p.setTemporaryAttribute("craftItem", new CraftItem(4, index, amount, (double)NORMAL_LEATHER[index][2], (int)NORMAL_LEATHER[index][0], (string)NORMAL_LEATHER[index][3], (int)NORMAL_LEATHER[index][1]));
            }
            CraftItem item = (CraftItem)p.getTemporaryAttribute("craftItem");

            if (item == null || p == null || item.getAmount() <= 0 || item.getCraftType() != 4 || item.getCraftItem() < 0)
            {
                Crafting.resetCrafting(p);
                return;
            }
            p.getPackets().closeInterfaces();
            if (!p.getInventory().hasItem(TANNED_HIDE[4]))
            {
                p.getPackets().sendMessage("You have no Leather.");
                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().hasItem(THREAD))
            {
                p.getPackets().sendMessage("You have no thread.");
                Crafting.resetCrafting(p);
                return;
            }
            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;
            }
            int    i = item.getCraftItem();
            string s = i == 0 || i == 5 || i == 6 ? "a" : "a pair of";

            if (p.getInventory().deleteItem(THREAD) && p.getInventory().deleteItem(TANNED_HIDE[4]))
            {
                p.getInventory().addItem(item.getFinishedItem());
                p.getSkills().addXp(Skills.SKILL.CRAFTING, item.getXp());
                p.setLastAnimation(new Animation(1249));
                p.getPackets().sendMessage("You make " + s + " " + item.getMessage() + ".");
            }
            item.decreaseAmount();
            if (item.getAmount() >= 1)
            {
                Event craftMoreNormalLeather = new Event(1500);
                craftMoreNormalLeather.setAction(() =>
                {
                    craftNormalLeather(p, -1, -1, false);
                    craftMoreNormalLeather.stop();
                });
                Server.registerEvent(craftMoreNormalLeather);
            }
        }