48 private static final short FULL = 11_000;
50 private static final short ZULRAH_SCALES = 12_934;
52 private static final short UNCHARGED_HELM = 13_198;
53 private static final short CHARGED_HELM = 13_199;
55 private static final DecimalFormat FORMATTER =
new DecimalFormat(
"#.#");
58 FORMATTER.setRoundingMode(RoundingMode.FLOOR);
67 public boolean itemOnItem(
Player player, Item first, Item second) {
70 if (first.getId() == UNCHARGED_HELM || first.getId() == CHARGED_HELM) {
74 if (item.getId() == ZULRAH_SCALES) {
75 charge(player, item.equals(first) ? second : first, item);
85 restore(player, item);
97 public boolean equipment(
Player player, Item item,
int opcode) {
105 public boolean drop(
Player player, Item item) {
106 if (item.matchesId(CHARGED_HELM)) {
113 public static void check(Player player) {
114 String scales = FORMATTER.format(player.magmaHelmCharges * 100 / FULL) +
"%";
115 player.message(
"Charges: <col=007F00>" + scales);
118 private static void charge(Player player, Item helm, Item scales) {
119 if (player.magmaHelmCharges >= FULL) {
120 if (helm.matchesId(UNCHARGED_HELM)) {
121 player.inventory.replace(UNCHARGED_HELM, CHARGED_HELM,
true);
123 player.message(
"Your Magma helm is already fully charged.");
127 if (Integer.MAX_VALUE - scales.getAmount() < FULL) {
128 scales = scales.copy();
129 scales.setAmount(FULL - player.magmaHelmCharges);
132 if (player.magmaHelmCharges + scales.getAmount() > FULL) {
133 scales = scales.copy();
134 scales.setAmount(FULL - player.magmaHelmCharges);
137 player.magmaHelmCharges += scales.getAmount();
138 player.inventory.remove(scales);
139 player.inventory.replace(UNCHARGED_HELM, CHARGED_HELM,
true);
140 player.message(String.format(
"You load %s scales into your Magma helm.", Utility.formatDigits(scales.getAmount())));
143 private static void uncharge(Player player) {
144 Item scales =
new Item(ZULRAH_SCALES, player.magmaHelmCharges);
146 if (!player.inventory.hasCapacityFor(scales)) {
147 player.send(
new SendMessage(
"You need more inventory space to do this."));
151 player.magmaHelmCharges = 0;
152 player.inventory.add(scales);
153 player.inventory.replace(CHARGED_HELM, UNCHARGED_HELM,
true);
154 player.message(String.format(
"You uncharged your Magma helm and received %s of Zulra's scales.", Utility.formatDigits(scales.getAmount())));
157 private static void restore(Player player, Item item) {
158 player.send(
new SendItemOnInterfaceSlot(14171, item, 0));
159 player.send(
new SendString(
"Are you sure you want to restore this item?", 14174));
160 player.send(
new SendString(
"Yes.", 14175));
161 player.send(
new SendString(
"No.", 14176));
162 player.send(
new SendString(
"", 14177));
163 player.send(
new SendString(
"This will replace your helm with the original Serpentine helm.", 14182));
164 player.send(
new SendString(
"", 14183));
165 player.send(
new SendString(item.getName(), 14184));
166 player.send(
new SendChatBoxInterface(14170));
167 player.attributes.set(
"RESTORE_HELM_KEY", item);
boolean inventory(Player player, Item item, int opcode)