RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
BoneSacrifice.java
1package com.osroyale.content.skill.impl.prayer;
2
3import com.osroyale.Config;
4import com.osroyale.content.skillcape.SkillCape;
5import com.osroyale.content.activity.randomevent.RandomEventHandler;
6import com.osroyale.content.dialogue.ChatBoxItemDialogue;
7import com.osroyale.content.event.impl.ItemInteractionEvent;
8import com.osroyale.content.event.impl.ItemOnObjectInteractionEvent;
9import com.osroyale.game.Animation;
10import com.osroyale.game.Graphic;
11import com.osroyale.game.action.Action;
12import com.osroyale.game.action.impl.BuryBoneAction;
13import com.osroyale.game.action.impl.ScatterAshAction;
14import com.osroyale.game.action.policy.WalkablePolicy;
15import com.osroyale.game.world.World;
16import com.osroyale.game.world.entity.mob.player.Player;
17import com.osroyale.game.world.entity.skill.Skill;
18import com.osroyale.game.world.items.Item;
19import com.osroyale.game.world.items.ItemDefinition;
20import com.osroyale.game.world.object.GameObject;
21import com.osroyale.game.world.position.Position;
22import com.osroyale.net.packet.out.SendInputAmount;
23import com.osroyale.net.packet.out.SendMessage;
24import com.osroyale.util.Utility;
25
59
60public class BoneSacrifice extends Skill {
61
62 public BoneSacrifice(int level, double experience) {
63 super(Skill.PRAYER, level, experience);
64 }
65
66 @Override
67 protected double modifier() {
69 }
70
71 @Override
72 protected boolean clickItem(Player player, ItemInteractionEvent event) {
73 if (event.getOpcode() != 0)
74 return false;
75 Item item = event.getItem();
76 int slot = event.getSlot();
77 if (!BoneData.forId(item.getId()).isPresent() && !AshData.forId(item.getId()).isPresent())
78 return false;
79 if (AshData.forId(item.getId()).isPresent()) {
80 AshData ashes = AshData.forId(item.getId()).get();
81 new ScatterAshAction(player, ashes, slot).start();
82 return true;
83 }
84 BoneData bone = BoneData.forId(item.getId()).get();
85 new BuryBoneAction(player, bone, slot).start();
86 return true;
87 }
88
89 @Override
90 protected boolean useItem(Player player, ItemOnObjectInteractionEvent event) {
91 Item item = event.getItem();
92 GameObject object = event.getObject();
93 if (object.getId() != 409 && object.getId() != 411) {
94 return false;
95 }
96 if (!BoneData.forId(item.getId()).isPresent())
97 return false;
98 BoneData bone = BoneData.forId(item.getId()).get();
99
100 if (player.inventory.computeAmountForId(bone.getId()) == 0) {
101 player.action.execute(sacrifice(player, object.getPosition(), bone, 1), true);
102 } else {
103 ChatBoxItemDialogue.sendInterface(player, 1746, bone.getId(), 0, -5, 170);
104 player.chatBoxItemDialogue = new ChatBoxItemDialogue(player) {
105 @Override
106 public void firstOption(Player player) {
107 player.action.execute(sacrifice(player, object.getPosition(), bone, 1), true);
108 }
109
110 @Override
111 public void secondOption(Player player) {
112 player.action.execute(sacrifice(player, object.getPosition(), bone, 5), true);
113 }
114
115 @Override
116 public void thirdOption(Player player) {
117 player.send(new SendInputAmount("Enter the amount of bones you would like to sacrifice", 10, input -> player.action.execute(sacrifice(player, object.getPosition(), bone, Integer.parseInt(input)), true)));
118 }
119
120 @Override
121 public void fourthOption(Player player) {
122 player.action.execute(sacrifice(player, object.getPosition(), bone, 28), true);
123 }
124 };
125 }
126 return true;
127 }
128
129 private Action<Player> sacrifice(Player player, Position position, BoneData bone, int amount) {
130 return new Action<Player>(player, 4, true) {
131 int ticks = 0;
132
133 @Override
134 public void execute() {
135 if (!player.inventory.contains(bone.getId())) {
136 cancel();
137 return;
138 }
139 Graphic graphic = new Graphic(624, true);
140 World.sendGraphic(graphic, position, player.instance);
141 player.animate(new Animation(645, 5));
142 if (player.getPosition().inLocation(Position.create(2946, 3816), Position.create(2959, 3831), true)) {
143 int rnd = Utility.random(100);
144 if (rnd <= 50) {
145 player.send(new SendMessage("You sacrifice the " + ItemDefinition.get(bone.getId()).getName() + " ."));
146 player.inventory.remove(bone.getId(), 1);
147 }
148 if (rnd > 50) {
149 player.message("You've saved a bone due to sacrificing in the wilderness..");
150 }
151 } else {
152 player.inventory.remove(bone.getId(), 1);
153 }
154
155 double exp = bone.getExperience() * (modifier() * 1.8);
156 if (SkillCape.isEquipped(player, SkillCape.PRAYER)) {
157 exp *= 2.0;
158 }
159
160 player.skills.addExperience(Skill.PRAYER, exp);
161 RandomEventHandler.trigger(player);
162 if (++ticks == amount) {
163 cancel();
164 }
165 }
166
167 @Override
168 public String getName() {
169 return "Bone sacrifice";
170 }
171
172 @Override
173 public boolean prioritized() {
174 return false;
175 }
176
177 @Override
178 public WalkablePolicy getWalkablePolicy() {
180 }
181 };
182 }
183
184}
static final double PRAYER_MODIFICATION
Definition Config.java:316
static void sendGraphic(Graphic graphic, Position position, int instance)
Definition World.java:305
static String getName(int skill)
Definition Skill.java:502
Skill(int skill, int level, double experience)
Definition Skill.java:221
void addExperience(int id, double experience)
static Position create(int x, int y, int z)
static Optional< BoneData > forId(int id)
Definition BoneData.java:96