RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
WallSafe.java
1package com.osroyale.content.skill.impl.thieving;
2
3import com.osroyale.Config;
4import com.osroyale.net.packet.out.SendMessage;
5import com.osroyale.game.Animation;
6import com.osroyale.game.action.Action;
7import com.osroyale.game.action.policy.WalkablePolicy;
8import com.osroyale.game.world.entity.combat.hit.Hit;
9import com.osroyale.game.world.entity.mob.player.Player;
10import com.osroyale.game.world.entity.skill.Skill;
11import com.osroyale.game.world.items.Item;
12import com.osroyale.util.Utility;
13
53
54public class WallSafe {
55
57 private static final Item REWARD[] = {
58 new Item(1617), new Item(1619), new Item(1621), new Item(1623),
59 new Item(1623), new Item(995, 20), new Item(995, 40)
60 };
61
63 static void thieve(Player player) {
64 if (player.skills.getMaxLevel(Skill.THIEVING) < 50) {
65 player.dialogueFactory.sendStatement("You need a thieving level of 50 to do this!").execute();
66 return;
67 }
68 if (player.inventory.remaining() == 0) {
69 player.dialogueFactory.sendStatement("You do not have inventory spaces to do this!").execute();
70 return;
71 }
72 if (player.skills.get(Skill.THIEVING).isDoingSkill()) {
73 return;
74 }
75 player.action.execute(crack(player), true);
76 }
77
79 private static int rate(Player player) {
80 boolean stethoscope = player.inventory.contains(new Item(5560));
81 int calculation = stethoscope ? Utility.random(5) : (Utility.random(11) + 20);
82 int calculated = (10 - (int) Math.floor(player.skills.getMaxLevel(Skill.THIEVING) / 10) + calculation) / 2;
83 return calculated <= 0 ? 1 : (calculated > 10 ? 10 : calculated);
84 }
85
87 public static int chance(Player player) {
88 return (Utility.random((int) Math.floor(player.skills.getMaxLevel(Skill.THIEVING / 10) + 1)));
89 }
90
92 private static Action<Player> crack(Player player) {
93 return new Action<Player>(player, 3, true) {
94 int rate = rate(player);
95 int tick = 0;
96
97 @Override
98 public void execute() {
99 if (tick++ != rate) {
100 player.animate(new Animation(881));
101 return;
102 }
103
104 if (chance(player) == 0) {
105 player.animate(new Animation(404));
106 player.send(new SendMessage("You slip and trigger a trap!"));
107 player.damage(new Hit(Utility.random(1, 5)));
108 cancel();
109 return;
110 }
111
112 player.send(new SendMessage("You get some loot."));
113 player.inventory.add(Utility.randomElement(REWARD));
115 cancel();
116 }
117
118 @Override
119 protected void onSchedule() {
120 player.skills.get(Skill.THIEVING).setDoingSkill(true);
121 player.send(new SendMessage("You attempt to crack the safe... "));
122 }
123
124 @Override
125 protected void onCancel(boolean logout) {
126 player.skills.get(Skill.THIEVING).setDoingSkill(false);
127 }
128
129 @Override
130 public String getName() {
131 return "Wallsafe crack";
132 }
133
134 @Override
135 public boolean prioritized() {
136 return false;
137 }
138
139 @Override
140 public WalkablePolicy getWalkablePolicy() {
141 return WalkablePolicy.NON_WALKABLE;
142 }
143 };
144 }
145}
static final double THIEVING_MODIFICATION
Definition Config.java:328
final DialogueFactory sendStatement(String... lines)
void addExperience(int id, double experience)
static< T > T randomElement(Collection< T > collection)
Definition Utility.java:285