예제 #1
0
        public static void makeBoltTip(Player p, int index, int amount, bool newCut)
        {
            if (newCut)
            {
                p.setTemporaryAttribute("fletchItem", 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("fletchItem");

            if (item == null || p == null || item.getAmount() <= 0)
            {
                Fletching.setFletchItem(p, null);
                return;
            }
            p.getPackets().closeInterfaces();
            if (!p.getInventory().hasItem(1755))
            {
                p.getPackets().sendMessage("You need a chisel to cut gems into bolt tips.");
                Fletching.setFletchItem(p, null);
                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.");
                }
                Fletching.setFletchItem(p, null);
                return;
            }
            if (p.getSkills().getGreaterLevel(Skills.SKILL.FLETCHING) < item.getLevel())
            {
                p.getPackets().sendMessage("You need a Fletching level of " + item.getLevel() + " to cut that gem.");
                Fletching.setFletchItem(p, null);
                return;
            }
            int amountToMake = item.getCraftItem() == 9 ? 24 : 12;

            if (p.getInventory().deleteItem((int)GEMS[item.getCraftItem()][0]))
            {
                p.getInventory().addItem(item.getFinishedItem(), amountToMake);
                p.getSkills().addXp(Skills.SKILL.FLETCHING, item.getXp());
                p.setLastAnimation(new Animation((int)GEMS[item.getCraftItem()][5]));
                p.getPackets().sendMessage("You cut the " + item.getMessage() + " into " + amountToMake + " " + item.getMessage() + " bolt tips.");
            }
            item.decreaseAmount();
            if (item.getAmount() >= 1)
            {
                Event makeMoreBoltTipEvent = new Event(1500);
                makeMoreBoltTipEvent.setAction(() => {
                    makeBoltTip(p, -1, -1, false);
                    makeMoreBoltTipEvent.stop();
                });
                Server.registerEvent(makeMoreBoltTipEvent);
            }
        }
예제 #2
0
        public static void cutLog(Player p, int amount, int logType, int itemType, bool isStringing, bool newFletch)
        {
            Bow item = null;

            if (newFletch)
            {
                item = getBow(itemType, logType, amount, isStringing);
                Fletching.setFletchItem(p, item);
            }
            item = (Bow)Fletching.getFletchItem(p);
            if (item == null || p == null)
            {
                return;
            }
            bool stringing = item.isStringing();

            if (!canFletch(p, item, stringing))
            {
                p.getPackets().closeInterfaces();
                return;
            }
            int animation = getAnimation(item);

            if (!stringing)
            {
                int amt = item.getItemType() == 2 ? ARROW_AMOUNT : 1;
                if (p.getInventory().deleteItem(LOGS[item.getLogType()]))
                {
                    p.getInventory().addItem(item.getFinishedItem(), amt);
                    p.getSkills().addXp(Skills.SKILL.FLETCHING, item.getXp());
                    item.decreaseAmount();
                    p.getPackets().sendMessage("You carefully cut the wood into " + MESSAGE[item.getItemType()] + ".");
                    p.setLastAnimation(new Animation(animation));
                }
            }
            else
            {
                int[] bows = item.getItemType() == 0 ? UNSTRUNG_SHORTBOW : UNSTRUNG_LONGBOW;
                if (p.getInventory().deleteItem(BOWSTRING) && p.getInventory().deleteItem(bows[item.getLogType()]))
                {
                    p.getInventory().addItem(item.getFinishedItem());
                    p.getSkills().addXp(Skills.SKILL.FLETCHING, item.getXp());
                    item.decreaseAmount();
                    p.getPackets().sendMessage("You add a string to the bow.");
                    p.setLastAnimation(new Animation(animation));
                }
            }
            p.getPackets().closeInterfaces();
            if (item.getAmount() >= 1)
            {
                Event cutMoreLogsEvent = new Event(1500);
                cutMoreLogsEvent.setAction(() => {
                    cutLog(p, -1, -1, -1, false, false);
                    cutMoreLogsEvent.stop();
                });
                Server.registerEvent(cutMoreLogsEvent);
            }
        }
예제 #3
0
        public static void createXbow(Player p, int amount, int xbowType, bool isStringing, bool newFletch)
        {
            SkillItem item = null;

            if (newFletch || Fletching.getFletchItem(p) == null)
            {
                item = getXbow(xbowType, isStringing, amount);
                Fletching.setFletchItem(p, item);
            }
            item = (SkillItem)Fletching.getFletchItem(p);
            if (item == null || p == null)
            {
                return;
            }
            bool stringing = item.getItemTwo() == XBOW_STRING ? true : false;

            if (!canFletch(p, item))
            {
                p.getPackets().closeInterfaces();
                return;
            }
            if (p.getInventory().deleteItem(item.getItemOne()) && p.getInventory().deleteItem(item.getItemTwo()))
            {
                p.getInventory().addItem(item.getFinishedItem());
                p.getSkills().addXp(Skills.SKILL.FLETCHING, item.getXp());
                item.decreaseAmount();
                p.getPackets().closeInterfaces();
                if (!stringing)
                {
                    p.getPackets().sendMessage("You attach some limbs to the Crossbow.");
                }
                else
                {
                    p.setLastAnimation(new Animation(6677));
                    p.getPackets().sendMessage("You add a Crossbow String to the Crossbow, you have completed the " + ItemData.forId(item.getFinishedItem()).getName() + ".");
                }
            }
            if (item.getAmount() >= 1)
            {
                Event createMoreXBowEvent = new Event(1500);
                createMoreXBowEvent.setAction(() => {
                    createXbow(p, -1, -1, false, false);
                    createMoreXBowEvent.stop();
                });
                Server.registerEvent(createMoreXBowEvent);
            }
        }
예제 #4
0
        public static void createAmmo(Player p, int sets, int type, bool bolt, bool newFletch)
        {
            Ammo item = null;

            if (newFletch || Fletching.getFletchItem(p) == null)
            {
                item = getAmmo(type, bolt, sets);
                Fletching.setFletchItem(p, item);
            }
            item = (Ammo)Fletching.getFletchItem(p);
            if (item == null || p == null)
            {
                return;
            }
            if (!canFletch(p, item))
            {
                p.getPackets().closeInterfaces();
                return;
            }
            int amt = getArrowAmount(p, item);

            if (amt <= 0)
            {
                return;
            }
            if (p.getInventory().deleteItem(item.getItemOne(), amt) && p.getInventory().deleteItem(item.getItemTwo(), amt))
            {
                p.getInventory().addItem(item.getFinishedItem(), amt);
                p.getSkills().addXp(Skills.SKILL.FLETCHING, item.getXp() * amt);
                p.getPackets().sendMessage(getMessage(item, amt));
                item.decreaseAmount();
                p.getPackets().closeInterfaces();
            }
            if (item.getAmount() >= 1)
            {
                Event createMoreAmmoEvent = new Event(1500);
                createMoreAmmoEvent.setAction(() => {
                    createAmmo(p, -1, -1, false, false);
                    createMoreAmmoEvent.stop();
                });
                Server.registerEvent(createMoreAmmoEvent);
            }
        }