50 private static final short FULL = 11_000;
52 private static final short ZULRAH_SCALES = 12_934;
54 private static final short UNCHARGED_HELM = 12_929;
55 private static final short CHARGED_HELM = 12_931;
57 private static final short TANZ_MUTAGEN = 13200;
58 private static final short MAGMA_MUTAGEN = 13201;
60 private static final DecimalFormat FORMATTER =
new DecimalFormat(
"#.#");
62 public SerpentineHelm() {
63 FORMATTER.setRoundingMode(RoundingMode.FLOOR);
68 return "Serpentine helm";
72 public boolean itemOnItem(
Player player, Item first, Item second) {
75 if (first.getId() == UNCHARGED_HELM || first.getId() == CHARGED_HELM) {
79 if ((first.matchesId(CHARGED_HELM) && second.matchesId(TANZ_MUTAGEN))
80 || (second.matchesId(CHARGED_HELM) && first.matchesId(TANZ_MUTAGEN))) {
81 player.message(
"You need to uncharge your Serpentine helm first.");
85 if ((first.matchesId(CHARGED_HELM) && second.matchesId(MAGMA_MUTAGEN))
86 || (second.matchesId(CHARGED_HELM) && first.matchesId(MAGMA_MUTAGEN))) {
87 player.message(
"You need to uncharge your Serpentine helm first.");
91 if ((first.matchesId(UNCHARGED_HELM) && second.matchesId(TANZ_MUTAGEN))
92 || (second.matchesId(UNCHARGED_HELM) && first.matchesId(TANZ_MUTAGEN))) {
93 player.inventory.
remove(TANZ_MUTAGEN);
94 player.inventory.
replace(UNCHARGED_HELM, 13_196,
true);
95 player.message(
true,
"You recolor your Serpentine helm into a Tanzanite helm!");
99 if ((first.matchesId(UNCHARGED_HELM) && second.matchesId(MAGMA_MUTAGEN))
100 || (second.matchesId(UNCHARGED_HELM) && first.matchesId(MAGMA_MUTAGEN))) {
101 player.inventory.
remove(MAGMA_MUTAGEN);
102 player.inventory.
replace(UNCHARGED_HELM, 13_198,
true);
103 player.message(
true,
"You recolor your Serpentine helm into a Magma helm!");
107 if (item.getId() == ZULRAH_SCALES) {
108 charge(player, item.equals(first) ? second : first, item);
117 if (opcode == 3 && item.matchesId(UNCHARGED_HELM)) {
118 dismantle(player, item);
130 public boolean equipment(
Player player, Item item,
int opcode) {
138 public boolean drop(
Player player, Item item) {
139 if (item.matchesId(CHARGED_HELM)) {
143 if (item.matchesId(UNCHARGED_HELM)) {
144 dismantle(player, item);
150 public static void check(Player player) {
151 String scales = FORMATTER.format(player.serpentineHelmCharges * 100 / FULL) +
"%";
152 player.message(
"Charges: <col=007F00>" + scales);
155 private static void charge(Player player, Item helm, Item scales) {
156 if (player.serpentineHelmCharges >= FULL) {
157 if (helm.matchesId(UNCHARGED_HELM)) {
158 player.inventory.replace(UNCHARGED_HELM, CHARGED_HELM,
true);
160 player.message(
"Your Serpentine helm is already fully charged.");
164 if (Integer.MAX_VALUE - scales.getAmount() < FULL) {
165 scales = scales.copy();
166 scales.setAmount(FULL - player.serpentineHelmCharges);
169 if (player.serpentineHelmCharges + scales.getAmount() > FULL) {
170 scales = scales.copy();
171 scales.setAmount(FULL - player.serpentineHelmCharges);
174 player.serpentineHelmCharges += scales.getAmount();
175 player.inventory.remove(scales);
176 player.inventory.replace(UNCHARGED_HELM, CHARGED_HELM,
true);
177 player.message(String.format(
"You load %s scales into your Serpentine helm.", Utility.formatDigits(scales.getAmount())));
180 private static void uncharge(Player player) {
181 Item scales =
new Item(ZULRAH_SCALES, player.serpentineHelmCharges);
183 if (!player.inventory.hasCapacityFor(scales)) {
184 player.send(
new SendMessage(
"You need more inventory space to do this."));
188 player.serpentineHelmCharges = 0;
189 player.inventory.add(scales);
190 player.inventory.replace(CHARGED_HELM, UNCHARGED_HELM,
true);
191 player.message(String.format(
"You uncharged your Serpentine helm and received %s of Zulra's scales.", Utility.formatDigits(scales.getAmount())));
194 private static void dismantle(Player player, Item item) {
195 player.send(
new SendItemOnInterfaceSlot(14171, item, 0));
196 player.send(
new SendString(
"Are you sure you want to uncharge this item?", 14174));
197 player.send(
new SendString(
"Yes.", 14175));
198 player.send(
new SendString(
"No.", 14176));
199 player.send(
new SendString(
"", 14177));
200 player.send(
new SendString(
"This will replace your helm with 20,000 Zulrah's scales.", 14182));
201 player.send(
new SendString(
"", 14183));
202 player.send(
new SendString(item.getName(), 14184));
203 player.send(
new SendChatBoxInterface(14170));
204 player.attributes.set(
"UNCHARGE_HELM_KEY", item);
boolean inventory(Player player, Item item, int opcode)