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 string getMessage(Ammo item, int amount) { string s = amount > 1 ? "s" : ""; string s1 = amount > 1 ? "some" : "a"; string s2 = amount > 1 ? "some" : "an"; if (!item.isBolt()) { s = amount > 1 ? "s" : ""; s1 = amount > 1 ? "some" : "a"; s2 = amount > 1 ? "some" : "an"; if (item.getItemType() == 0) { return("You attach Feathers to " + s1 + " of your Arrow shafts, you make " + amount + " " + ItemData.forId(item.getFinishedItem()).getName() + s + "."); } else { return("You attach " + s2 + " Arrowtip" + s + " to " + s1 + " Headless arrow" + s + ", you make " + amount + " " + ItemData.forId(item.getFinishedItem()).getName() + s + "."); } } else { s = amount > 1 ? "s" : ""; s1 = amount > 1 ? "some of your bolts" : "a bolt"; s2 = amount > 1 ? "some" : "a"; if (item.getItemType() < 8) { return("You attach Feathers to " + s1 + ", you make " + amount + " " + ItemData.forId(item.getFinishedItem()).getName() + "."); } else { s = amount > 1 ? "s" : ""; s2 = amount > 1 ? "some" : "a"; return("You attach " + s2 + " bolt tip" + s + " to " + s2 + " headless bolt" + s + ", you make " + amount + " " + ItemData.forId(item.getFinishedItem()).getName() + "."); } } }
private static string getMessage(Ammo item, int amount) { string s = amount > 1 ? "s" : ""; string s1 = amount > 1 ? "some" : "a"; string s2 = amount > 1 ? "some" : "an"; if (!item.isBolt()) { s = amount > 1 ? "s" : ""; s1 = amount > 1 ? "some" : "a"; s2 = amount > 1 ? "some" : "an"; if (item.getItemType() == 0) { return "You attach Feathers to " + s1 + " of your Arrow shafts, you make " + amount + " " + ItemData.forId(item.getFinishedItem()).getName() + s + "."; } else { return "You attach " + s2 + " Arrowtip" + s + " to " + s1 + " Headless arrow" + s + ", you make " + amount + " " + ItemData.forId(item.getFinishedItem()).getName() + s + "."; } } else { s = amount > 1 ? "s" : ""; s1 = amount > 1 ? "some of your bolts" : "a bolt"; s2 = amount > 1 ? "some" : "a"; if (item.getItemType() < 8) { return "You attach Feathers to " + s1 + ", you make " + amount + " " + ItemData.forId(item.getFinishedItem()).getName() + "."; } else { s = amount > 1 ? "s" : ""; s2 = amount > 1 ? "some" : "a"; return "You attach " + s2 + " bolt tip" + s + " to " + s2 + " headless bolt" + s + ", you make " + amount + " " + ItemData.forId(item.getFinishedItem()).getName() + "."; } } }
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; }