RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
SkillRepository.java
1package com.osroyale.content.skill;
2
3import com.osroyale.Config;
4import com.osroyale.content.skill.impl.agility.Agility;
5import com.osroyale.content.skill.impl.crafting.impl.Gem;
6import com.osroyale.content.skill.impl.crafting.impl.Hide;
7import com.osroyale.content.skill.impl.fishing.Fishable;
8import com.osroyale.content.skill.impl.fishing.FishingSpot;
9import com.osroyale.content.skill.impl.fishing.FishingTool;
10import com.osroyale.content.skill.impl.fletching.impl.*;
11import com.osroyale.content.skill.impl.herblore.GrimyHerb;
12import com.osroyale.content.skill.impl.hunter.net.impl.Butterfly;
13import com.osroyale.content.skill.impl.hunter.net.impl.Impling;
14import com.osroyale.content.skill.impl.mining.OreData;
15import com.osroyale.content.skill.impl.prayer.BoneData;
16import com.osroyale.content.skill.impl.woodcutting.TreeData;
17import com.osroyale.game.world.entity.mob.Direction;
18import com.osroyale.game.world.entity.mob.Mob;
19import com.osroyale.game.world.entity.mob.npc.Npc;
20import com.osroyale.game.world.entity.mob.player.Player;
21import com.osroyale.game.world.position.Position;
22import com.osroyale.util.RandomUtils;
23import com.osroyale.util.Utility;
24
25import java.util.ArrayList;
26import java.util.List;
27
64
65public class SkillRepository {
66
67 private static final List<Integer> SKILLING_ITEMS = new ArrayList<>();
68 private static final List<Integer> HERBLORE_ITEMS = new ArrayList<>();
69 private static final List<Integer> BONE_ITEMS = new ArrayList<>();
70
71 private static final List<Integer> ESSENCE_ITEMS = new ArrayList<>();
72
73
75 private static final Position[] HUNTER_SPAWN_POSITION = {
76 new Position(3081, 3484), new Position(3101, 3484), new Position(3115, 3506),
77 new Position(3094, 3453), new Position(3134, 3511), new Position(3180, 3422),
78 new Position(3240, 3440), new Position(3287, 3351), new Position(3257, 3247),
79 new Position(3221, 3213), new Position(2803, 3445), new Position(2721, 3472),
80 new Position(3349, 3271), new Position(3283, 3196), new Position(3574, 3322),
81 new Position(2659, 2660), new Position(3377, 3168), new Position(2660, 3706),
82 new Position(2318, 3813), new Position(3054, 3514)
83 };
84
86 public static void spawn() {
87 for (Position position : HUNTER_SPAWN_POSITION) {
88 int npc;
89
90 if (RandomUtils.success(.50)) {
91 npc = Utility.randomElement(Butterfly.values()).butterfly;
92 } else {
93 npc = Utility.randomElement(Impling.values()).impling;
94 }
95
96 new Npc(npc, position, Config.NPC_WALKING_RADIUS, Mob.DEFAULT_INSTANCE, Direction.NORTH).register();
97 }
98
99 for (int[] IMPLING : IMPLINGS) {
100 new Npc(IMPLING[0], new Position(IMPLING[1], IMPLING[2]), Config.NPC_WALKING_RADIUS, Mob.DEFAULT_INSTANCE, Direction.NORTH).register();
101
102 }
103
104 }
105
107 public static void load() {
108 Gem.load();
109 Hide.load();
110 Arrow.load();
111 Carvable.load();
112 Bolt.load();
113 Crossbow.load();
114 Featherable.load();
115 Stringable.load();
116 Agility.declare();
117 FishingTool.declare();
118 Battlestaff.load();
119 Fishable.declare();
120 FishingSpot.declare();
121 spawn();
122 declareItems();
123 }
124
125 private static void declareItems() {
126 for (TreeData tree : TreeData.values()) {
127 SKILLING_ITEMS.add(tree.item);
128 }
129 for (OreData ore : OreData.values()) {
130 SKILLING_ITEMS.add(ore.ore);
131 }
132 for (Fishable fish : Fishable.values()) {
133 SKILLING_ITEMS.add(fish.getRawFishId());
134 }
135 for (GrimyHerb herb : GrimyHerb.values()) {
136 HERBLORE_ITEMS.add(herb.getCleanID());
137 }
138 for (GrimyHerb herb : GrimyHerb.values()) {
139 HERBLORE_ITEMS.add(herb.getGrimyID());
140 }
141 for (BoneData bones : BoneData.values()) {
142 BONE_ITEMS.add(bones.getId2());
143 }
144 }
145
146 public static boolean isSkillingItem(int item) {
147 for (int id : SKILLING_ITEMS) {
148 if (item == id)
149 return true;
150 }
151 return false;
152 }
153 public static boolean isHerbloreItem(int item) {
154 for (int id : SKILLING_ITEMS) {
155 if (item == id)
156 return true;
157 }
158 return false;
159 }
160
161 public static boolean isBones(int item) {
162 for (int id : BONE_ITEMS) {
163 if (item == id)
164 return true;
165 }
166 return false;
167 }
168
169
170 public static boolean isSuccess(int skill, int levelRequired) {
171 double successChance = Math.ceil(((double) skill * 50.0D - (double) levelRequired * 15.0D) / (double) levelRequired / 3.0D * 4.0D);
172 int roll = Utility.random(99);
173 return successChance >= roll;
174 }
175
176 public static boolean isSuccess(Player p, int skillId, int levelRequired, boolean usingDragonHarpoon) {
177 double level = p.skills.getMaxLevel(skillId);
178 double successChance = Math.ceil((((level * 50.0D) - ((double) levelRequired * 15.0D)) / (double) levelRequired / 3.0D) * 4.0D);
179 int roll = usingDragonHarpoon ? Utility.random(79) : Utility.random(99);
180 return successChance >= roll;
181 }
182
183 public static boolean isSuccess(Player p, int skill, int levelRequired, int toolLevelRequired) {
184 double level = (p.skills.getMaxLevel(skill) + toolLevelRequired) / 2.0D;
185 double successChance = Math.ceil((((level * 50.0D) - ((double) levelRequired * 15.0D)) / (double) levelRequired / 3.0D) * 4.0D);
186 int roll = Utility.random(99);
187 return successChance >= roll;
188 }
189
190 public static final int[][] IMPLINGS = {
194 {1635, 2612, 4318},
195 {1635, 2602, 4314},
196 {1635, 2610, 4338},
197 {1635, 2582, 4344},
198 {1635, 2578, 4344},
199 {1635, 2568, 4311},
200 {1635, 2583, 4295},
201 {1635, 2582, 4330},
202 {1635, 2600, 4303},
203 {1635, 2611, 4301},
204 {1635, 2618, 4329},
205
209 {1636, 2591, 4332},
210 {1636, 2600, 4338},
211 {1636, 2595, 4345},
212 {1636, 2610, 4327},
213 {1636, 2617, 4314},
214 {1636, 2619, 4294},
215 {1636, 2599, 4294},
216 {1636, 2575, 4303},
217 {1636, 2570, 4299},
218
222 {1637, 2573, 4339},
223 {1637, 2567, 4328},
224 {1637, 2593, 4297},
225 {1637, 2618, 4305},
226 {1637, 2605, 4316},
227 {1637, 2596, 4333},
228
232 {1638, 2592, 4338},
233 {1638, 2611, 4345},
234 {1638, 2617, 4339},
235 {1638, 2614, 4301},
236 {1638, 2606, 4295},
237 {1638, 2581, 4299},
238
242 {1639, 2602, 4328},
243 {1639, 2608, 4333},
244 {1639, 2609, 4296},
245 {1639, 2581, 4304},
246 {1639, 2570, 4318},
247
251 {1640, 2611, 4310},
252 {1640, 2617, 4319},
253 {1640, 2600, 4347},
254 {1640, 2570, 4326},
255 {1640, 2579, 4310},
256
260
264 {1641, 2581, 4310},
265 {1641, 2581, 4310},
266 {1641, 2603, 4333},
267 {1641, 2576, 4335},
268 {1641, 2588, 4345},
269
273 {1642, 2612, 4324},
274 {1642, 2602, 4323},
275 {1642, 2587, 4348},
276 {1642, 2564, 4320},
277 {1642, 2566, 4295},
278
282 {1643, 2570, 4347},
283 {1643, 2572, 4327},
284 {1643, 2578, 4318},
285 {1643, 2610, 4312},
286 {1643, 2594, 4341},
287
291 {1654, 2613, 4341},
292 {1654, 2585, 4337},
293 {1654, 2576, 4319},
294 {1654, 2576, 4294},
295 {1654, 2592, 4305},
296 };
297}
static final int NPC_WALKING_RADIUS
Definition Config.java:195
static< T > T randomElement(Collection< T > collection)
Definition Utility.java:285