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() + "."; } } }