RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
LowAlchemy.java
1package com.osroyale.content.skill.impl.magic.spell.impl;
2
3import com.osroyale.Config;
4import com.osroyale.content.activity.randomevent.RandomEventHandler;
5import com.osroyale.content.skill.impl.magic.Magic;
6import com.osroyale.content.skill.impl.magic.Spellbook;
7import com.osroyale.content.skill.impl.magic.spell.Spell;
8import com.osroyale.game.Animation;
9import com.osroyale.game.Graphic;
10import com.osroyale.game.world.entity.mob.player.Player;
11import com.osroyale.game.world.entity.skill.Skill;
12import com.osroyale.game.world.items.Item;
13import com.osroyale.net.packet.out.SendForceTab;
14import com.osroyale.net.packet.out.SendMessage;
15
16import java.util.Arrays;
17
46
47public class LowAlchemy implements Spell {
48
49 @Override
50 public String getName() {
51 return "Low alchemy";
52 }
53
54 @Override
55 public int getLevel() {
56 return 21;
57 }
58
59 @Override
60 public Item[] getRunes() {
61 return new Item[] { new Item(554, 3), new Item(561, 1) };
62 }
63
64 @Override
65 public void execute(Player player, Item item) {
66 if (player.spellbook != Spellbook.MODERN)
67 return;
68
69 if (!player.spellCasting.castingDelay.elapsed(500)) {
70 return;
71 }
72
73 if (Arrays.stream(Magic.UNALCHEABLES).anyMatch($it -> item.getId() == $it.getId())) {
74 player.send(new SendMessage("You can not alch this item!"));
75 return;
76 }
77
78 int value = item.getLowAlch();
79
80 if (value > 150_000) {
81 player.send(new SendMessage("The value of this item is too high and can not be low-alched."));
82 return;
83 }
84
85 player.animate(new Animation(712));
86 player.graphic(new Graphic(112, true));
87 player.inventory.remove(item.getId(), 1);
88 player.inventory.removeAll(getRunes());
89 player.inventory.refresh();
90 player.send(new SendForceTab(6));
91 player.inventory.add(Config.CURRENCY, value == 0 ? 1 : value);
92 player.skills.addExperience(Skill.MAGIC, 31 * (Config.MAGIC_MODIFICATION + 5));
93 player.spellCasting.castingDelay.reset();
94 player.action.clearNonWalkableActions();
95 RandomEventHandler.trigger(player);
96 }
97}
static final double MAGIC_MODIFICATION
Definition Config.java:310
static final int CURRENCY
Definition Config.java:213
void addExperience(int id, double experience)
boolean removeAll(Collection<? extends Item > items)