RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
TridentOfTheSwamp.java
1package com.osroyale.content.itemaction.impl;
2
3import com.osroyale.content.itemaction.ItemAction;
4import com.osroyale.game.world.entity.mob.player.Player;
5import com.osroyale.game.world.items.Item;
6import com.osroyale.util.Utility;
7
8import java.math.RoundingMode;
9import java.text.DecimalFormat;
10
40
41public class TridentOfTheSwamp extends ItemAction {
42 private static final short TRIDENT_ID = 12899;
43 private static final short CHARGE_LIMIT = 2500;
44 private static final DecimalFormat FORMATTER = new DecimalFormat("#.#");
45
46 public TridentOfTheSwamp() {
47 FORMATTER.setRoundingMode(RoundingMode.FLOOR);
48 }
49
50 @Override
51 public String name() {
52 return "Trident of the Seas";
53 }
54
55 @Override
56 public boolean itemOnItem(Player player, Item first, Item second) {
57 if (first.getId() != TRIDENT_ID && second.getId() != TRIDENT_ID) {
58 return false;
59 }
60
61 if (player.tridentSwampCharges >= CHARGE_LIMIT) {
62 player.message("Your Trident of the Swamp is already fully charged.");
63 return true;
64 }
65
66 int id1 = first.getId();
67 int id2 = second.getId();
68
69 if (id1 == TRIDENT_ID && id2 != TRIDENT_ID)
70 if (id2 != 560 && id2 != 562 && id2 != 554 && id2 != 12934)
71 return true;
72
73 if (id2 == TRIDENT_ID && id1 != TRIDENT_ID)
74 if (id1 != 560 && id1 != 562 && id1 != 554 && id1 != 12934)
75 return true;
76
77 int scales = player.inventory.computeAmountForId(12934);
78 int death = player.inventory.computeAmountForId(560);
79 int chaos = player.inventory.computeAmountForId(562);
80 int fire = player.inventory.computeAmountForId(554);
81
82 if (death >= 1 && chaos >= 1 && fire >= 5 && scales >= 1) {
83 int minF = fire / 5;
84 int charges = Math.min(Math.min(death, chaos), Math.min(scales, minF));
85
86 if (charges > CHARGE_LIMIT)
87 charges = CHARGE_LIMIT;
88
89 if (charges > CHARGE_LIMIT - player.tridentSwampCharges)
90 charges = CHARGE_LIMIT - player.tridentSwampCharges;
91
92 if (charges > 0) {
93 player.inventory.remove(new Item(560, charges), -1, false);
94 player.inventory.remove(new Item(562, charges), -1, false);
95 player.inventory.remove(new Item(554, charges * 5), -1, false);
96 player.inventory.remove(new Item(12934, charges), -1, false);
97 player.inventory.refresh();
98 player.tridentSwampCharges += charges;
99 player.message("You added " + charges + " charges to your Trident of the Swamp");
100 }
101 } else {
102 player.message("You need at least 1x zulrah scale, 1x death rune, 1x chaos rune, and 5x fire runes", "for one charge. Your Trident of the Swamp can hold 2,500 charges.");
103 }
104 return true;
105 }
106
107 @Override
108 public boolean inventory(Player player, Item item, int opcode) {
109 if (item.getId() != TRIDENT_ID) {
110 return false;
111 }
112 if (opcode == 2) {
113 check(player);
114 return true;
115 }
116 if (opcode == 3) {
117 uncharge(player);
118 return true;
119 }
120 return true;
121 }
122
123 @Override
124 public boolean equipment(Player player, Item item, int opcode) {
125 if (item.getId() != TRIDENT_ID) {
126 return false;
127 }
128 if (opcode == 1) {
129 check(player);
130 return true;
131 }
132 return true;
133 }
134
135 private static void check(Player player) {
136 player.message("You have " + Utility.formatDigits(player.tridentSwampCharges) + " charges in your Trident of the Swamp.");
137 }
138
139 private static void uncharge(Player player) {
140 if (player.tridentSwampCharges < 1) {
141 return;
142 }
143
144 int amount = player.tridentSwampCharges;
145 if (!player.inventory.hasCapacityFor(new Item(560, amount), new Item(562, amount), new Item(554, amount * 5))) {
146 player.message("You don't have enough inventory space to uncharge your trident.");
147 return;
148 }
149
150 player.inventory.add(new Item(560, amount), -1, false);
151 player.inventory.add(new Item(562, amount), -1, false);
152 player.inventory.add(new Item(554, amount * 5), -1, false);
153 player.inventory.refresh();
154 player.tridentSwampCharges = 0;
155 player.message("You uncharge your trident.");
156 }
157
158}
boolean inventory(Player player, Item item, int opcode)