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
 private static bool canFletch(Player p, Bow item, bool stringing)
 {
     if (item == null || item.getAmount() <= 0)
     {
         return(false);
     }
     if (p.getSkills().getGreaterLevel(Skills.SKILL.FLETCHING) < item.getLevel())
     {
         p.getPackets().sendMessage("You need a Fletching level of " + item.getLevel() + " to make that.");
         return(false);
     }
     if (!stringing)
     {
         if (!p.getInventory().hasItem(LOGS[item.getLogType()]))
         {
             p.getPackets().sendMessage("You have run out of logs.");
             return(false);
         }
         if (!p.getInventory().hasItem(KNIFE))
         {
             p.getPackets().sendMessage("You need a knife to fletch logs.");
             return(false);
         }
     }
     else
     {
         int[] bows = item.getItemType() == 0 ? UNSTRUNG_SHORTBOW : UNSTRUNG_LONGBOW;
         if (!p.getInventory().hasItem(bows[item.getLogType()]))
         {
             p.getPackets().sendMessage("You do not have a bow to string.");
             return(false);
         }
         if (!p.getInventory().hasItem(BOWSTRING))
         {
             p.getPackets().sendMessage("You need Bowstring if you wish to string a bow!");
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 3
0
 private static bool canFletch(Player p, Bow item, bool stringing)
 {
     if (item == null || item.getAmount() <= 0) {
         return false;
     }
     if (p.getSkills().getGreaterLevel(Skills.SKILL.FLETCHING) < item.getLevel()) {
         p.getPackets().sendMessage("You need a Fletching level of " + item.getLevel() + " to make that.");
         return false;
     }
     if (!stringing) {
         if (!p.getInventory().hasItem(LOGS[item.getLogType()])) {
             p.getPackets().sendMessage("You have run out of logs.");
             return false;
         }
         if (!p.getInventory().hasItem(KNIFE)) {
             p.getPackets().sendMessage("You need a knife to fletch logs.");
             return false;
         }
     } else {
         int[] bows = item.getItemType() == 0 ? UNSTRUNG_SHORTBOW : UNSTRUNG_LONGBOW;
         if (!p.getInventory().hasItem(bows[item.getLogType()])) {
             p.getPackets().sendMessage("You do not have a bow to string.");
             return false;
         }
         if (!p.getInventory().hasItem(BOWSTRING)) {
             p.getPackets().sendMessage("You need Bowstring if you wish to string a bow!");
             return false;
         }
     }
     return true;
 }