RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
BuryBoneAction.java
1package com.osroyale.game.action.impl;
2
3import com.osroyale.Config;
4import com.osroyale.content.skillcape.SkillCape;
5import com.osroyale.content.achievement.AchievementHandler;
6import com.osroyale.content.achievement.AchievementKey;
7import com.osroyale.content.skill.SkillAction;
8import com.osroyale.content.skill.impl.prayer.BoneData;
9import com.osroyale.game.Animation;
10import com.osroyale.game.action.policy.WalkablePolicy;
11import com.osroyale.game.world.entity.mob.player.Player;
12import com.osroyale.game.world.entity.skill.Skill;
13import com.osroyale.game.world.items.Item;
14import com.osroyale.net.packet.out.SendMessage;
15
16import java.util.Optional;
17
54
55public final class BuryBoneAction extends SkillAction {
56 private final int slot;
57 private final Item item;
58 private final BoneData bone;
59
60 public BuryBoneAction(Player player, BoneData bone, int slot) {
61 super(player, Optional.empty(), true);
62 this.slot = slot;
63 this.bone = bone;
64 this.item = player.inventory.get(slot);
65 }
66
67 @Override
68 public boolean canInit() {
69 return getMob().skills.getSkills()[skill()].stopwatch.elapsed(1200);
70 }
71
72 @Override
73 public void init() {
74
75 }
76
77 @Override
78 public void onExecute() {
79 getMob().animate(new Animation(827));
80 Player player = getMob().getPlayer();
81 player.inventory.remove(item, slot, true);
82 player.skills.addExperience(skill(), experience());
83 player.send(new SendMessage("You bury the " + item.getName() + "."));
84 AchievementHandler.activate(player, AchievementKey.BURY_BONES, 1);
85
86 if (player.equipment.hasAmulet() && player.equipment.getAmuletSlot().getId() == 22111) {
87 int current = player.skills.getLevel(Skill.PRAYER);
88 int maximum = player.skills.getMaxLevel(Skill.PRAYER);
89
90 if (current < maximum) {
91 int points = bone.getBoneAmulet();
92
93 if (current + points > maximum) {
94 points = maximum - current;
95 }
96
97 player.skills.get(Skill.PRAYER).addLevel(points);
98 player.skills.refresh(Skill.PRAYER);
99 player.message("You feel your " + player.equipment.getAmuletSlot().getName() + " vibrate as you bury the bone.");
100 }
101 }
102
103 cancel();
104 }
105
106 @Override
107 public void onCancel(boolean logout) {
108 getMob().skills.getSkills()[skill()].stopwatch.reset();
109 }
110
111 @Override
112 public Optional<SkillAnimation> animation() {
113 return Optional.empty();
114 }
115
116 @Override
117 public double experience() {
118 double exp = (bone.getExperience() * Config.PRAYER_MODIFICATION);
119 if (SkillCape.isEquipped(getMob().getPlayer(), SkillCape.PRAYER)) {
120 exp *= 2.0;
121 }
122 return exp;
123 }
124
125 @Override
126 public int skill() {
127 return Skill.PRAYER;
128 }
129
130 @Override
131 public String getName() {
132 return "Bone bury";
133 }
134
135 @Override
136 public boolean prioritized() {
137 return false;
138 }
139
140 @Override
144}
static final double PRAYER_MODIFICATION
Definition Config.java:316
static void activate(Player player, AchievementKey achievement)
SkillAction(Mob mob, Optional< Position > position, int delay, boolean instant)
synchronized final void cancel()
Definition Task.java:147
void addExperience(int id, double experience)