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