private static bool canFletch(Player p, Ammo item) { if (item == null || item.getAmount() <= 0) { return(false); } string s = item.getItemOne() == HEADLESS_ARROW ? "s." : "."; string s1 = item.getItemTwo() == HEADLESS_ARROW ? "s." : "."; 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 (!p.getInventory().hasItem(item.getItemOne())) { p.getPackets().sendMessage("You don't have any " + ItemData.forId(item.getItemOne()).getName() + s); return(false); } if (!p.getInventory().hasItem(item.getItemTwo())) { p.getPackets().sendMessage("You don't have any " + ItemData.forId(item.getItemTwo()).getName() + s1); return(false); } return(true); }
private static int getArrowAmount(Player p, Ammo item) { if (item == null || p == null) { return(0); } int amt = item.isBolt() ? 12 : 15; int itemOneAmount = p.getInventory().getItemAmount(item.getItemOne()); int itemTwoAmount = p.getInventory().getItemAmount(item.getItemTwo()); int lowestStack = itemOneAmount > itemTwoAmount ? itemTwoAmount : itemOneAmount; int finalAmount = lowestStack > amt ? amt : lowestStack; return(finalAmount); }
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); } }
private static int getArrowAmount(Player p, Ammo item) { if (item == null || p == null) { return 0; } int amt = item.isBolt() ? 12 : 15; int itemOneAmount = p.getInventory().getItemAmount(item.getItemOne()); int itemTwoAmount = p.getInventory().getItemAmount(item.getItemTwo()); int lowestStack = itemOneAmount > itemTwoAmount ? itemTwoAmount : itemOneAmount; int finalAmount = lowestStack > amt ? amt : lowestStack; return finalAmount; }
private static bool canFletch(Player p, Ammo item) { if (item == null || item.getAmount() <= 0) { return false; } string s = item.getItemOne() == HEADLESS_ARROW ? "s." : "."; string s1 = item.getItemTwo() == HEADLESS_ARROW ? "s." : "."; 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 (!p.getInventory().hasItem(item.getItemOne())) { p.getPackets().sendMessage("You don't have any " + ItemData.forId(item.getItemOne()).getName() + s); return false; } if (!p.getInventory().hasItem(item.getItemTwo())) { p.getPackets().sendMessage("You don't have any " + ItemData.forId(item.getItemTwo()).getName() + s1); return false; } return true; }