Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
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);
            }
        }