RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
CombatSpecial.java
1package com.osroyale.game.world.entity.combat.strategy.player.special;
2
3import com.osroyale.content.activity.Activity;
4import com.osroyale.game.Animation;
5import com.osroyale.game.Graphic;
6import com.osroyale.game.UpdatePriority;
7import com.osroyale.game.world.entity.combat.Combat;
8import com.osroyale.game.world.entity.combat.strategy.CombatStrategy;
9import com.osroyale.game.world.entity.combat.strategy.player.special.melee.*;
10import com.osroyale.game.world.entity.combat.strategy.player.special.range.*;
11import com.osroyale.game.world.entity.mob.Mob;
12import com.osroyale.game.world.entity.mob.player.Player;
13import com.osroyale.game.world.entity.skill.Skill;
14import com.osroyale.game.world.items.Item;
15import com.osroyale.game.world.items.containers.equipment.Equipment;
16import com.osroyale.net.packet.out.*;
17
18import java.util.Arrays;
19import java.util.Optional;
20
44
45public enum CombatSpecial {
46 /* Abyssal **/
47 ABYSSAL_WHIP(new int[]{4151, 80, 21371, 15441, 15442, 15443, 15444}, 50, AbyssalWhip.get()),
48 ABYSSAL_TENTACLE_WHIP(new int[]{12006}, 50, AbyssalTentacleWhip.get()),
49 ABYSSAL_DAGGER(new int[]{13265}, 50, AbyssalDagger.get()),
50 ABYSSAL_BLUDGEN(new int[]{13263}, 50, AbyssalBludgen.get()),
51
52
53 /* Dragon **/
54 DRAGON_DAGGER(new int[]{1215, 1231, 5680, 5698}, 25, DragonDagger.get()),
55 DRAGON_WARHAMMER(new int[]{13576}, 50, DragonWarhammer.get()),
56 DRAGON_LONGSWORD(new int[]{1305}, 25, DragonLongsword.get()),
57 DRAGON_SCIMITAR(new int[]{4587, 20000}, 55, DragonScimitar.get()),
58 DRAGON_HALBERD(new int[]{3204}, 30, DragonHaldberd.get()),
59 OSMUM_FANG(new int[]{26219, 27246}, 25, OsmumFang.get()),
60 DRAGON_CLAWS(new int[]{13652, 20784}, 50, DragonClaws.get()),
61 DRAGON_SPEAR(new int[]{1249, 1263, 5730, 3176, 5716, 11824, 11889}, 25, DragonSpear.get()),
62 DRAGON_MACE(new int[]{1434}, 25, DragonMace.get()),
63 DRAGON_2H(new int[]{7158}, 60, Dragon2h.get()),
64 VESTAS_LONGSWORD(new int[]{22613}, 25, VestaLongsword.get()),
65
66 STAFF_OF_DEAD(new int[]{11791, 12904}, 100, DefaultMelee.get()) {
67 @Override
68 public void enable(Player player) {
69 if (player.getSpecialPercentage().intValue() < player.getCombatSpecial().getAmount()) {
70 player.send(new SendMessage("You do not have enough special energy left!"));
71 return;
72 }
73 player.staffOfDeadSpecial.reset();
74 player.animate(1720, true);
75 player.graphic(new Graphic(1228, 0, 13107200, UpdatePriority.HIGH));
76 player.skills.setLevel(1, 125);
77 player.send(new SendMessage("Your defence has been boosted!"));
78 drain(player, 100);
79 }
80 },
81 DRAGON_AXE(new int[]{6739, 13241, 20011}, 100, DefaultMelee.get()) {
82 @Override
83 public void enable(Player player) {
84 if (player.getSpecialPercentage().intValue() < player.getCombatSpecial().getAmount()) {
85 player.send(new SendMessage("You do not have enough special energy left!"));
86 return;
87 }
88 player.skills.setLevel(8, player.skills.getLevel(Skill.WOODCUTTING) + 3);
89 player.animate(new Animation(2876, UpdatePriority.HIGH), true);
90 player.graphic(new Graphic(479, true, UpdatePriority.HIGH));
91 player.send(new SendMessage("Your Woodcutting rate has increased by x2!"));
92 drain(player, 100);
93 }
94 },
95 DRAGON_HARPOON(new int[]{21028,25373,21031}, 100, DefaultMelee.get()) {
96 @Override
97 public void enable(Player player) {
98 if (player.getSpecialPercentage().intValue() < player.getCombatSpecial().getAmount()) {
99 player.send(new SendMessage("You do not have enough special energy left!"));
100 return;
101 }
102 player.skills.setLevel(Skill.FISHING, player.skills.getLevel(Skill.FISHING) + 3);
103 player.animate(new Animation(1056, UpdatePriority.HIGH), true);
104 player.graphic(new Graphic(246, UpdatePriority.HIGH));
105 player.speak("Here fishy fishies!");
106 drain(player, 100);
107 }
108 },
109 DRAGON_PICKAXE(new int[]{11920, 12797, 23677, 25376,27695,13243}, 100, DefaultMelee.get()) {
110 @Override
111 public void enable(Player player) {
112 if (player.getSpecialPercentage().intValue() < player.getCombatSpecial().getAmount()) {
113 player.send(new SendMessage("You do not have enough special energy left!"));
114 return;
115 }
116 player.skills.setLevel(Skill.MINING, player.skills.getLevel(Skill.MINING) + 3);
117 player.animate(new Animation(7138, UpdatePriority.HIGH), true);
118 player.speak("Smashing!");
119 drain(player, 100);
120 }
121 },
122 DRAGON_BATTLEAXE(new int[]{1377}, 100, DefaultMelee.get()) {
123 @Override
124 public void enable(Player player) {
125 if (player.getSpecialPercentage().intValue() < player.getCombatSpecial().getAmount()) {
126 player.send(new SendMessage("You do not have enough special energy left!"));
127 return;
128 }
129 player.speak("Raarrrrrgggggghhhhhhh!");
130 player.animate(new Animation(1056, UpdatePriority.HIGH), true);
131 player.graphic(new Graphic(246, UpdatePriority.HIGH));
132 player.skills.modifyLevel(level -> level - level / 10, Skill.ATTACK);
133 player.skills.modifyLevel(level -> level - level / 10, Skill.DEFENCE);
134 player.skills.modifyLevel(level -> level - level / 10, Skill.RANGED);
135 player.skills.modifyLevel(level -> level - level / 10, Skill.MAGIC);
136 player.skills.modifyLevel(level -> level + 10 + (player.skills.getMaxLevel(Skill.STRENGTH) - level) / 4, Skill.STRENGTH, 0, 120);
137 player.skills.refresh(Skill.ATTACK);
138 player.skills.refresh(Skill.DEFENCE);
139 player.skills.refresh(Skill.STRENGTH);
140 player.skills.refresh(Skill.RANGED);
141 player.skills.refresh(Skill.MAGIC);
142 drain(player, 100);
143 }
144 },
145
146 /* Godsword **/
147 SARADOMIN_GODSWORD(new int[]{11806, 20372}, 50, SaradominGodsword.get()),
148 ARMADYL_GODSWORD(new int[]{11802, 81, 20368}, 50, ArmadylGodsword.get()),
149 ZAMORAK_GODSWORD(new int[]{11808, 20374}, 50, ZamorakGodsword.get()),
150 BANDOS_GODSWORD(new int[]{11804, 20370}, 50, BandosGodsword.get()),
151 ANCIENT_GODSWORD(new int[]{26233}, 50, AncientGodsword.get()),
152
153 /* Ranged **/
154 BLOW_PIPE(new int[]{12926}, 50, Blowpipe.get()),
155 DARK_BOW(new int[]{11235, 12765, 12766, 12767, 12768}, 55, DarkBow.get()),
156 MAGIC_SHORTBOW(new int[]{861, 12788}, 55, MagicShortbow.get()),
157 BALLISTA(new int[]{19478, 19481}, 55, Ballista.get()),
158 ARMADYL_CROSSBOW(new int[]{11785}, 40, ArmadylCrossbow.get()),
159 ZARYTE_CROSSBOW(new int[]{26374}, 75, ZaryteCrossbow.get()),
160 DRAGON_THROWNAXE(new int[]{20849}, 25, DragonThrownaxe.get()) {
161 @Override
162 public void enable(Player player) {
163 super.enable(player);
164 if (player.isSpecialActivated()) {
165 player.getCombat().setCooldown(0);
166 }
167 }
168 },
169
170 /* Other **/
171 SARADOMIN_SWORD(new int[]{11838, 12809}, 100, SaradominSword.get()),
172
173
174 STAFF_OF_THE_DEAD(new int[]{11791, 12904}, 100, DefaultMelee.get()) {
175 @Override
176 public void enable(Player player) {
177 if (player.getSpecialPercentage().intValue() < player.getCombatSpecial().getAmount()) {
178 player.send(new SendMessage("You do not have enough special energy left!"));
179 return;
180 }
181 player.animate(1720, true);
182 player.graphic(new Graphic(1228, 0, 13107200, UpdatePriority.HIGH));
183 player.skills.setLevel(1, 125);
184 player.staffOfDeadSpecial.reset();
185 player.send(new SendMessage("Your defence has been boosted!"));
186 drain(player, 100);
187 }
188 },
189 TOXIC_STAFF_OF_THE_DEAD(new int[]{12904}, 100, DefaultMelee.get()) {
190 @Override
191 public void enable(Player player) {
192 if (player.getSpecialPercentage().intValue() < player.getCombatSpecial().getAmount()) {
193 player.send(new SendMessage("You do not have enough special energy left!"));
194 return;
195 }
196 player.animate(1720, true);
197 player.graphic(new Graphic(1228, 0, 13107200, UpdatePriority.HIGH));
198 player.skills.setLevel(1, 125);
199 player.staffOfDeadSpecial.reset();
200 player.send(new SendMessage("Your defence has been boosted!"));
201 drain(player, 100);
202 }
203 },
204 GRANITE_MAUL(new int[]{4153, 24225}, 50, GraniteMaul.get()) {
205 @Override
206 public void enable(Player player) {
207 if (player.getSpecialPercentage().intValue() < player.getCombatSpecial().getAmount()) {
208 player.send(new SendMessage("You do not have enough special energy left!"));
209 return;
210 }
211
212 player.setSpecialActivated(true);
213 player.send(new SendConfig(301, 1));
214
215 Combat<Player> combat = player.getCombat();
216 Mob defender = combat.getLastVictim();
217
218 if (combat.isAttacking(defender)) {
219 combat.performChecks(defender);
220 combat.submitStrategy(defender, GraniteMaul.get());
221 }
222 }
223
224 @Override
225 public void disable(Player player, boolean clicked) {
226 // TODO: potential bug when specials are disabled other
227 // TODO: than in the spec bar, example: switching weapons
228
229 boolean doubleSpec = !player.attributes.has("granite-maul-spec");
230 int current = player.getSpecialPercentage().intValue();
231
232 if (clicked && doubleSpec && current >= getAmount()) {
233 player.attributes.set("granite-maul-spec", true);
234 } else {
235 player.attributes.remove("granite-maul-spec");
236 super.disable(player, clicked);
237 }
238 }
239 },
240
241 DINHS_BULWARK(new int[]{21015}, 50, DinhsBulwark.get()),
242
243
244 DRAGON_KNIVES(new int[] { 22804 }, 25, DragonKnife.get());
245
249 private final int[] ids;
250
254 private final int amount;
255
259 private final CombatStrategy<Player> strategy;
260
267 CombatSpecial(int[] ids, int amount, CombatStrategy<Player> strategy) {
268 this.ids = ids;
269 this.amount = amount;
270 this.strategy = strategy;
271 }
272
273 public static Optional<CombatSpecial> forId(int weapon) {
274 Optional<CombatSpecial> special = Arrays.stream(CombatSpecial.values()).filter(c -> Arrays.stream(c.getIds()).anyMatch(id -> weapon == id)).findFirst();
275 return special;
276 }
277
283 public CombatStrategy<Player> getStrategy() {
284 return strategy;
285 }
286
292 public void drain(Player player) {
293 player.send(new SendSpecialEnabled(0));
294 player.getSpecialPercentage().decrementAndGet(amount, 0);
295 updateSpecialAmount(player);
296 disable(player, false);
297 }
298
299 public static void drain(Player player, int toDrain) {
300 player.send(new SendSpecialEnabled(0));
301 player.getSpecialPercentage().decrementAndGet(toDrain, 0);
302 updateSpecialAmount(player);
303 }
304
305
312 public static void restore(Player player, int amount) {
313 player.getSpecialPercentage().incrementAndGet(amount, 100);
314 updateSpecialAmount(player);
315 }
316
323 public static void updateSpecialAmount(Player player) {
324 if (player.getWeapon().getSpecialBar() == -1 || player.getWeapon().getSpecialMeter() == -1) {
325 return;
326 }
327
328 int specialBar = player.getWeapon().getSpecialMeter();
329 int specialAmount = player.getSpecialPercentage().get() / 10;
330 player.send(new SendSpecialAmount());
331
332 for (int i = 10; i > 0; i--) {
333 player.send(new SendMoveComponent(specialAmount >= i ? 500 : 0, 0, --specialBar));
334 }
335 }
336
337
343 public static void assign(Player player) {
344 if (player.getCombatSpecial() != null) {
345 player.getCombatSpecial().disable(player, false);
346 }
347
348 if (player.getWeapon().getSpecialBar() == -1) {
349 player.setCombatSpecial(null);
350 player.send(new SendInterfaceLayer(player.getWeapon().getSpecialBar(), true));
351 return;
352 }
353
354 Item item = player.equipment.get(Equipment.WEAPON_SLOT);
355 if (item == null) {
356 player.setCombatSpecial(null);
357 player.send(new SendInterfaceLayer(player.getWeapon().getSpecialBar(), true));
358 return;
359 }
360
361 Optional<CombatSpecial> special = Arrays.stream(CombatSpecial.values()).filter(c -> Arrays.stream(c.getIds()).anyMatch(id -> item.getId() == id)).findFirst();
362 if (special.isPresent()) {
363 player.send(new SendInterfaceLayer(player.getWeapon().getSpecialBar(), false));
364 player.setCombatSpecial(special.get());
365 return;
366 }
367
368 player.send(new SendInterfaceLayer(player.getWeapon().getSpecialBar(), true));
369 player.setCombatSpecial(null);
370 }
371
377 public final int[] getIds() {
378 return ids;
379 }
380
386 public final int getAmount() {
387 return amount;
388 }
389
390 public void enable(Player player) {
391 if (Activity.evaluate(player, it -> !it.canUseSpecial(player))) {
392 return;
393 }
394
395 if (!player.isSpecialActivated()) {
396 if (player.getSpecialPercentage().intValue() < player.getCombatSpecial().getAmount()) {
397 player.send(new SendMessage("You do not have enough special energy left!"));
398 return;
399 }
400
401 player.send(new SendConfig(301, 1));
402 player.setSpecialActivated(true);
403 }
404 }
405
406 public void disable(Player player, boolean clicked) {
407 if (player.isSpecialActivated()) {
408 player.send(new SendConfig(301, 0));
409 player.setSpecialActivated(false);
410 }
411 }
412
413}
CombatSpecial(int[] ids, int amount, CombatStrategy< Player > strategy)