RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
WeaponInterface.java
1package com.osroyale.game.world.entity.combat.weapon;
2
3import com.osroyale.Config;
4import com.osroyale.game.world.entity.combat.attack.FightStyle;
5import com.osroyale.game.world.entity.combat.attack.FightType;
6import com.osroyale.game.world.entity.combat.magic.Autocast;
7import com.osroyale.game.world.entity.combat.strategy.player.special.CombatSpecial;
8import com.osroyale.game.world.entity.mob.player.Player;
9import com.osroyale.game.world.items.Item;
10import com.osroyale.net.packet.out.SendConfig;
11import com.osroyale.net.packet.out.SendString;
12import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
13import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
14
15import java.util.Optional;
16
39
40public enum WeaponInterface {
41 UNARMED(5855, "unarmed",5857, 7737, 7749, 7761, new FightType[]{
42 FightType.UNARMED_PUNCH,
43 FightType.UNARMED_KICK,
44 FightType.UNARMED_BLOCK
45 }),
46
47 DART(4446, "thrown", 4449, 7637, 7649, 7661, new FightType[]{
48 FightType.DART_ACCURATE,
49 FightType.DART_RAPID,
50 FightType.DART_LONGRANGE
51 }),
52
53 STAFF(6103, "staff", 6132, 6104, 6117, 6129, new FightType[]{
54 FightType.STAFF_BASH,
55 FightType.STAFF_POUND,
56 FightType.STAFF_FOCUS
57 }),
58
59 MAGIC_STAFF(328, "staff", 355, 340, 18566, 18569, new FightType[]{
60 FightType.STAFF_BASH,
61 FightType.STAFF_POUND,
62 FightType.STAFF_FOCUS
63 }),
64 NIGHTMARE_STAFF(328, "staff", 355, 340, 18566, 18569, new FightType[]{
65 FightType.NIGHTMARE_STAFF_BASH,
66 FightType.NIGHTMARE_STAFF_POUND,
67 FightType.NIGHTMARE_STAFF_FOCUS
68 }),
69
70
71 WARHAMMER(425, "blunt", 428, 7473, 7474, 7486, new FightType[]{
72 FightType.WARHAMMER_POUND,
73 FightType.WARHAMMER_PUMMEL,
74 FightType.WARHAMMER_BLOCK
75 }),
76
77 SCYTHE(776, "scythe", 779, -1, -1, -1, new FightType[]{
78 FightType.SCYTHE_REAP,
79 FightType.SCYTHE_CHOP,
80 FightType.SCYTHE_JAB,
81 FightType.SCYTHE_BLOCK
82 }),
83 VITUR(776, "scythe", 779, -1, -1, -1, new FightType[]{
84 FightType.VITUR_REAP,
85 FightType.VITUR_CHOP,
86 FightType.VITUR_JAB,
87 FightType.VITUR_BLOCK
88 }),
89
90
91 BATTLEAXE(1698, "weapon", 1701, 7498, 7499, 7511, new FightType[]{
92 FightType.BATTLEAXE_CHOP,
93 FightType.BATTLEAXE_HACK,
94 FightType.BATTLEAXE_SMASH,
95 FightType.BATTLEAXE_BLOCK
96 }),
97
98 CROSSBOW(1764, "crossbow", 1767, 7548, 7549, 7561, new FightType[]{
99 FightType.CROSSBOW_ACCURATE,
100 FightType.CROSSBOW_RAPID,
101 FightType.CROSSBOW_LONGRANGE
102 }),
103 ZARYTE_CROSSBOW(1764, "crossbow", 1767, 7548, 7549, 7561, new FightType[]{
104 FightType.ZARYTE_ACCURATE,
105 FightType.ZARYTE_RAPID,
106 FightType.ZARYTE_LONGRANGE
107 }),
108
109 SHORTBOW(1764, "bow", 1767, 7548, 7549, 7561, new FightType[]{
110 FightType.SHORTBOW_ACCURATE,
111 FightType.SHORTBOW_RAPID,
112 FightType.SHORTBOW_LONGRANGE
113 }),
114
115 LONGBOW(1764, "bow", 1767, 7548, 7549, 7561, new FightType[]{
116 FightType.LONGBOW_ACCURATE,
117 FightType.LONGBOW_RAPID,
118 FightType.LONGBOW_LONGRANGE
119 }),
120
121 DARK_BOW(1764, "bow", 1767, 7548, 7549, 7561, new FightType[]{
122 FightType.DARK_BOW_ACCURATE,
123 FightType.DARK_BOW_RAPID,
124 FightType.DARK_BOW_LONGRANGE
125 }),
126
127 COMPOSITE_BOW(1764, "bow", 1767, 7548, 7549, 7561, new FightType[]{
128 FightType.LONGBOW_ACCURATE,
129 FightType.LONGBOW_RAPID,
130 FightType.LONGBOW_LONGRANGE
131 }),
132
133 DAGGER(2276, "stab_sword", 2279, 7562, 7574, 7586, new FightType[]{
134 FightType.DAGGER_STAB,
135 FightType.DAGGER_LUNGE,
136 FightType.DAGGER_SLASH,
137 FightType.DAGGER_BLOCK
138 }),
139
140 SWORD(2276, "slash_sword", 2279, 7562, 7574, 7586, new FightType[]{
141 FightType.SWORD_STAB,
142 FightType.SWORD_LUNGE,
143 FightType.SWORD_SLASH,
144 FightType.SWORD_BLOCK
145 }),
146
147 SCIMITAR(2423, "slash_sword", 2426, 7587, 7599, 7611, new FightType[]{
148 FightType.SCIMITAR_CHOP,
149 FightType.SCIMITAR_SLASH,
150 FightType.SCIMITAR_LUNGE,
151 FightType.SCIMITAR_BLOCK
152 }),
153
154 LONGSWORD(2423, "slash_sword", 2426, 7587, 7599, 7611, new FightType[]{
155 FightType.LONGSWORD_CHOP,
156 FightType.LONGSWORD_SLASH,
157 FightType.LONGSWORD_LUNGE,
158 FightType.LONGSWORD_BLOCK
159 }),
160
161 MACE(3796, "spiked", 3799, 7623, 7624, 7636, new FightType[]{
162 FightType.MACE_POUND,
163 FightType.MACE_PUMMEL,
164 FightType.MACE_SPIKE,
165 FightType.MACE_BLOCK
166 }),
167 VIGGORA_MACE(3796, "spiked", 3799, 7623, 7624, 7636, new FightType[]{
168 FightType.VIGGORA_MACE_POUND,
169 FightType.VIGGORA_MACE_PUMMEL,
170 FightType.VIGGORA_MACE_SPIKE,
171 FightType.VIGGORA_MACE_BLOCK
172 }),
173
174 INQUISITOR_MACE(3796, "spiked", 3799, 7623, 7624, 7636, new FightType[]{
175 FightType.INQUISITOR_MACE_POUND,
176 FightType.INQUISITOR_MACE_PUMMEL,
177 FightType.INQUISITOR_MACE_SPIKE,
178 FightType.INQUISITOR_MACE_BLOCK
179 }),
180
181 KNIFE(4446, "thrown", 4449, 7637, 7649, 7661, new FightType[]{
182 FightType.KNIFE_ACCURATE,
183 FightType.KNIFE_RAPID,
184 FightType.KNIFE_LONGRANGE
185 }),
186
187 SPEAR(4679, "spear", 4682, 7662, 7674, 7686, new FightType[]{
188 FightType.SPEAR_LUNGE,
189 FightType.SPEAR_SWIPE,
190 FightType.SPEAR_POUND,
191 FightType.SPEAR_BLOCK
192 }),
193 HUNTER_LANCE(4679, "spear", 4682, 7662, 7674, 7686, new FightType[]{
194 FightType.HUNTER_LANCE_LUNGE,
195 FightType.HUNTER_LANCE_SWIPE,
196 FightType.HUNTER_LANCE_POUND,
197 FightType.HUNTER_LANCE_BLOCK
198 }),
199
200 TWO_HANDED_SWORD(4705, "2h_sword", 4708, 7687, 7699, 7711, new FightType[]{
201 FightType.TWOHANDEDSWORD_CHOP,
202 FightType.TWOHANDEDSWORD_SLASH,
203 FightType.TWOHANDEDSWORD_SMASH,
204 FightType.TWOHANDEDSWORD_BLOCK
205 }),
206
207 PICKAXE(5570, "pickaxe", 5573, 7723, 7724, 7736, new FightType[]{
208 FightType.PICKAXE_SPIKE,
209 FightType.PICKAXE_IMPALE,
210 FightType.PICKAXE_SMASH,
211 FightType.PICKAXE_BLOCK
212 }),
213
214 CLAWS(7762, "claw", 7765, 7788, 7800, 7812, new FightType[]{
215 FightType.CLAWS_CHOP,
216 FightType.CLAWS_SLASH,
217 FightType.CLAWS_LUNGE,
218 FightType.CLAWS_BLOCK
219 }),
220
221 HALBERD(8460, "polearm", 8463, 8481, 8493, 8505, new FightType[]{
222 FightType.HALBERD_JAB,
223 FightType.HALBERD_SWIPE,
224 FightType.HALBERD_FEND
225 }),
226
227 WHIP(12290, "weapon", 12293, 12322, 12323, 12335, new FightType[]{
228 FightType.WHIP_FLICK,
229 FightType.WHIP_LASH,
230 FightType.WHIP_DEFLECT
231 }),
232
233 THROWNAXE(4446, "thrown", 4449, 7637, 7649, 7661, new FightType[]{
234 FightType.THROWNAXE_ACCURATE,
235 FightType.THROWNAXE_RAPID,
236 FightType.THROWNAXE_LONGRANGE
237 }),
238
239 CHINCHOMPA(24055, "chinchompas", 24056, -1, -1, -1, new FightType[]{
240 FightType.SHORT_FUSE,
241 FightType.MEDIUM_FUSE,
242 FightType.LONG_FUSE
243 }),
244
245 SALAMANDER(24074, "salamander", 24075, -1, -1, -1, new FightType[]{
246 FightType.SCORCH,
247 FightType.FLARE,
248 FightType.BLAZE
249 }),
250
251 TRIDENT(4446, "powered_staff", 4449, 7637, 7649, 7661, new FightType[]{
252 FightType.TRIDENT_ACCURATE,
253 FightType.TRIDENT_RAPID,
254 FightType.TRIDENT_LONGRANGE
255 }),
256 SHADOW(4446, "powered_staff", 4449, 7637, 7649, 7661, new FightType[]{
257 FightType.SHADOW_ACCURATE,
258 FightType.SHADOW_RAPID,
259 FightType.SHADOW_LONGRANGE
260 }),
261
262 BLOWPIPE(4446, "thrown", 4449, 7637, 7649, 7661, new FightType[]{
263 FightType.BLOWPIPE_ACCURATE,
264 FightType.BLOWPIPE_RAPID,
265 FightType.BLOWPIPE_LONGRANGE
266 }),
267
268 BULWARK(425, "bulwark", 428, 7473, 7474, 7486, new FightType[]{
269 FightType.BULWARK_POUND,
270 FightType.BULWARK_PUMMEL,
271 FightType.BULWARK_BLOCK
272 }),
273
274 GRANITE_MAUL(425, "blunt", 428, 7473, 7474, 7486, new FightType[]{
275 FightType.GRANITE_MAUL_POUND,
276 FightType.GRANITE_MAUL_PUMMEL,
277 FightType.GRANITE_MAUL_BLOCK
278 }),
279
280 ELDER_MAUL(425, "blunt", 428, 7473, 7474, 7486, new FightType[]{
281 FightType.ELDER_MAUL_POUND,
282 FightType.ELDER_MAUL_PUMMEL,
283 FightType.ELDER_MAUL_BLOCK
284 }),
285
286 GREATAXE(1698, "axe", 1701, 7498, 7499, 7591, new FightType[]{
287 FightType.GREATAXE_CHOP,
288 FightType.GREATAXE_HACK,
289 FightType.GREATAXE_SMASH,
290 FightType.GREATAXE_BLOCK
291 }),
292
293 KARIL_CROSSBOW(1764, "crossbow", 1767, 7548, 7549, 7561, new FightType[]{
294 FightType.KARIL_CROSSBOW_ACCURATE,
295 FightType.KARIL_CROSSBOW_RAPID,
296 FightType.KARIL_CROSSBOW_LONGRANGE
297 }),
298
299 BALLISTA(1764, "crossbow", 1767, 7548, 7549, 7561, new FightType[]{
300 FightType.BALLISTA_ACCURATE,
301 FightType.BALLISTA_RAPID,
302 FightType.BALLISTA_LONGRANGE
303 }),
304
305 DRAGON_DAGGER(2276, "stab_sword", 2279, 7562, 7574, 7586, new FightType[]{
306 FightType.DRAGON_DAGGER_STAB,
307 FightType.DRAGON_DAGGER_LUNGE,
308 FightType.DRAGON_DAGGER_SLASH,
309 FightType.DRAGON_DAGGER_BLOCK
310 }),
311
312 FLAIL(3796, "spiked", 3799, 7623, 7624, 7636, new FightType[]{
313 FightType.FLAIL_POUND,
314 FightType.FLAIL_PUMMEL,
315 FightType.FLAIL_SPIKE,
316 FightType.FLAIL_BLOCK
317 }),
318
319 GODSWORD_SWORD(4705, "2h_sword", 4708, 7687, 7699, 7711, new FightType[]{
320 FightType.GODSWORD_CHOP,
321 FightType.GODSWORD_SLASH,
322 FightType.GODSWORD_SMASH,
323 FightType.GODSWORD_BLOCK
324 }),
325 SAELDOR_SWORD(2423, "slash_sword", 2426, 7587, 7599, 7611, new FightType[]{
326 FightType.SAELDOR_STAB,
327 FightType.SAELDOR_SLASH,
328 FightType.SAELDOR_CRUSH,
329 FightType.SAELDOR_BLOCK
330 }),
331 OSMUM_SWORD(2276, "stab_sword", 2279, 7562, 7574, 7586, new FightType[]{
332 FightType.FANG_STAB,
333 FightType.FANG_LUNGE,
334 FightType.FANG_SLASH,
335 FightType.FANG_BLOCK
336 }),
337 GHRAZI_SWORD(2276, "stab_sword", 2279, 7562, 7574, 7586, new FightType[]{
338 FightType.GHRAZI_STAB,
339 FightType.GHRAZI_LUNGE,
340 FightType.GHRAZI_SLASH,
341 FightType.GHRAZI_BLOCK
342 }),
343
344
345
346 SARADOMIN_SWORD(4705, "2h_sword", 4708, 7687, 7699, 7711, new FightType[]{
347 FightType.SARADOMIN_CHOP,
348 FightType.SARADOMIN_SLASH,
349 FightType.SARADOMIN_SMASH,
350 FightType.SARADOMIN_BLOCK
351 }),
352
353 BLUDGEN(4705, "bludgeon", 4708, 7687, 7699, 7711, new FightType[]{
354 FightType.BLUDGEN_CHOP,
355 FightType.BLUDGEN_SLASH,
356 FightType.BLUDGEN_SMASH,
357 FightType.BLUDGEN_BLOCK
358 });
359
363 private final int id;
364
365 private final String newDefName;
366
370 private final int nameLine;
371
375 private final FightType[] fightTypes;
376
380 private final int specialButton;
381
385 private final int specialBar;
386
390 private final int specialMeter;
391
401 WeaponInterface(int id, String newDefName, int nameLine, int specialButton, int specialBar, int specialMeter, FightType[] fightTypes) {
402 this.id = id;
403 this.newDefName = newDefName;
404 this.nameLine = nameLine;
405 this.fightTypes = fightTypes;
406 this.specialButton = specialButton;
407 this.specialBar = specialBar;
408 this.specialMeter = specialMeter;
409 }
410
419
420 public static void execute(Player player, Item item) {
421 execute(player, item, false);
422 }
423
424 public static void execute(Player player, Item item, boolean login) {
425 WeaponInterface weapon = item == null ? null : item.getWeaponInterface();
426 if (weapon == null) weapon = WeaponInterface.UNARMED;
427
428 FightType[] oldTypes = player.getWeapon().fightTypes;
429 FightType[] newTypes = weapon.fightTypes;
430 FightType result = null;
431
432 for (int index = 0; index < oldTypes.length; index++) {
433 if (newTypes.length == index) {
434 break;
435 }
436
437 if (newTypes[index].getStyle().equals(FightStyle.DEFENSIVE)
438 && player.getCombat().getFightType().getStyle().equals(FightStyle.DEFENSIVE)) {
439 result = newTypes[index];
440 break;
441 }
442
443 if (oldTypes[index] == player.getCombat().getFightType()) {
444 boolean oldControlled = oldTypes[index].getStyle().equals(FightStyle.CONTROLLED);
445 boolean newControlled = newTypes[index].getStyle().equals(FightStyle.CONTROLLED);
446
447 if (newControlled != oldControlled) {
448 continue;
449 }
450
451 result = newTypes[index];
452 break;
453 }
454 }
455
456 if (result == null) {
457 if (player.getCombat().getFightType().getStyle().equals(FightStyle.DEFENSIVE)) {
458 result = newTypes[newTypes.length - 1];
459 } else {
460 result = newTypes[1];
461 }
462 }
463 player.setWeapon(weapon);
464
465 if(!login) {
466 player.getCombat().setFightType(result);
467 player.send(new SendConfig(result.getParent(), result.getChild()));
468 }
469
470 if (weapon == WeaponInterface.UNARMED) {
471 defaultWeaponInterface(player);
472 return;
473 }
474
475 CombatSpecial.assign(player);
477 Autocast.reset(player);
478 player.setSingleCast(null);
479
480 player.send(new SendString(item.getName(), weapon.nameLine));
481 player.interfaceManager.setSidebar(Config.ATTACK_TAB, weapon.id);
482 player.equipment.updateAnimation();
483 }
484
485 private static void defaultWeaponInterface(Player player) {
486 CombatSpecial.assign(player);
488 Autocast.reset(player);
489 player.setSingleCast(null);
490
491 player.send(new SendString("<col=ff7000>Unarmed", WeaponInterface.UNARMED.nameLine));
492 player.interfaceManager.setSidebar(Config.ATTACK_TAB, WeaponInterface.UNARMED.id);
493 player.equipment.updateAnimation();
494 }
495
501 public final int getId() {
502 return id;
503 }
504
505 public String getNewDefName() {
506 return newDefName;
507 }
508
514 public final FightType[] getFightTypes() {
515 return fightTypes;
516 }
517
523 public final int getSpecialBar() {
524 return specialBar;
525 }
526
532 public final int getSpecialMeter() {
533 return specialMeter;
534 }
535
536 public Optional<FightType> forFightButton(int button) {
537 for (FightType type : fightTypes) {
538 if (type.getButton() == button) {
539 return Optional.of(type);
540 }
541 }
542 return Optional.empty();
543 }
544
545 public static boolean isSpecialButton(int button) {
546 for (WeaponInterface weaponInterface : values()) {
547 if (weaponInterface.specialButton == button) {
548 return true;
549 }
550 }
551 return false;
552 }
553
554 public static final WeaponInterface[] values = values();
555
556 private static final Object2ObjectMap<String, WeaponInterface> newNameToValue
557 = new Object2ObjectOpenHashMap<>(values.length);
558
559 public static WeaponInterface forNewName(String newDefName) {
560 return newNameToValue.get(newDefName);
561 }
562
563 static {
564 for (WeaponInterface value : values) {
565 newNameToValue.putIfAbsent(value.getNewDefName(), value);
566 }
567 }
568
569}
static final int ATTACK_TAB
Definition Config.java:232
WeaponInterface(int id, String newDefName, int nameLine, int specialButton, int specialBar, int specialMeter, FightType[] fightTypes)