RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
SlayerTask.java
1package com.osroyale.content.skill.impl.slayer;
2
3import com.osroyale.game.world.entity.mob.npc.definition.NpcDefinition;
4import com.osroyale.game.world.entity.mob.player.Player;
5import com.osroyale.game.world.entity.skill.Skill;
6import com.osroyale.game.world.position.Position;
7import com.osroyale.util.Utility;
8
9import java.util.ArrayList;
10
38
39public enum SlayerTask implements TaskInterface<Player> {
40 SAND_CRAB(new String[]{"Sand Crab"}, 1, false, TaskDifficulty.EASY, new Position(1726, 3463), "") {
41 @Override
42 public boolean canAssign(Player player) {
43 return true;
44 }
45
46 },
47 ROCK_CRAB(new String[]{"Rock Crab"}, 1, false, TaskDifficulty.EASY, new Position(2676, 3711), "Camelot") {
48 @Override
49 public boolean canAssign(Player player) {
50 return true;
51 }
52
53 },
54 CRAWLING_HAND(new String[]{"Crawling hand"}, 1, false, TaskDifficulty.EASY, new Position(3424, 3543), "Slayer Tower") {
55 @Override
56 public boolean canAssign(Player player) {
57 return true;
58 }
59
60 },
61 HILL_GIANT(new String[]{"Hill Giant"}, 1, false, TaskDifficulty.EASY, new Position(3117, 9856), "") {
62 @Override
63 public boolean canAssign(Player player) {
64 return true;
65 }
66
67 },
68 FIRE_GIANT(new String[]{"Fire giant"}, 5, false, TaskDifficulty.MEDIUM, new Position(2655, 9489), "Slayer Cave") {
69 @Override
70 public boolean canAssign(Player player) {
71 return true;
72 }
73
74 },
75 GREEN_DRAGON(new String[]{"Green dragon", "Baby green dragon"}, 5, false, TaskDifficulty.MEDIUM, new Position(3339, 3668), "WILDERNESS") {
76 @Override
77 public boolean canAssign(Player player) {
78 return true;
79 }
80
81 },
82 BANSHEE(new String[]{"Banshee"}, 15, false, TaskDifficulty.MEDIUM, new Position(3340, 3560), "Pollnivneach Smoke Dungeon") {
83 @Override
84 public boolean canAssign(Player player) {
85 return true;
86 }
87 },
88 BLOODVELDS(new String[]{"Bloodveld"}, 15, false, TaskDifficulty.MEDIUM, new Position(3419, 3562), "Slayer Tower") {
89 @Override
90 public boolean canAssign(Player player) {
91 return true;
92 }
93 },
94 INFERNAL_MAGES(new String[]{"Infernal Mage"}, 45, false, TaskDifficulty.MEDIUM, new Position(3445, 3560), "Pollnivneach Well Dungeon") {
95 @Override
96 public boolean canAssign(Player player) {
97 return true;
98 }
99
100 },
101 AVIANSIES(new String[]{"Aviansie"}, 50, false, TaskDifficulty.MEDIUM, new Position(2882, 5287, 2), "Stronghold of Security") {
102 @Override
103 public boolean canAssign(Player player) {
104 return true;
105 }
106
107 },
108 DUST_DEVILS(new String[]{"Dust devil"}, 65, true, TaskDifficulty.MEDIUM, new Position(3239, 9364), "Pollnivneach Smoke Dungeon") {
109 @Override
110 public boolean canAssign(Player player) {
111 return true;
112 }
113
114 },
115 ABERRANT_SPECTRES(new String[]{"Aberrant spectre"}, 60, true, TaskDifficulty.MEDIUM, new Position(3420, 3553, 1), "Slayer Tower") {
116 @Override
117 public boolean canAssign(Player player) {
118 return true;
119 }
120 },
121 ANKOU(new String[]{"Ankou"}, 1, false, TaskDifficulty.HARD, new Position(2359, 5236), "Stronghold of Security") {
122 @Override
123 public boolean canAssign(Player player) {
124 return true;
125 }
126 },
127 BLACK_DEMONS(new String[]{"Black demon"}, 12, false, TaskDifficulty.HARD, new Position(2876, 9790), "Taverly Dungeon") {
128 @Override
129 public boolean canAssign(Player player) {
130 return true;
131 }
132 },
133 DAGANNOTHS(new String[]{"Dagannoth", "Dagannoth mother", "Dagannoth Supreme", "Dagannoth Prime", "Dagannoth Rex"}, 1, false, TaskDifficulty.HARD, new Position(1891, 4369), "Fremennik Province Light House") {
134 @Override
135 public boolean canAssign(Player player) {
136 return true;
137 }
138
139 },
140 HELLHOUNDS(new String[]{"Hellhound", "Cerberus"}, 12, false, TaskDifficulty.HARD, new Position(2827, 9847), "Taverly Dungeon") {
141 @Override
142 public boolean canAssign(Player player) {
143 return true;
144 }
145
146 },
147 MITHRIL_DRAGON(new String[]{"Mithril dragon"}, 1, false, TaskDifficulty.HARD, new Position(1748, 5326), "Ancient Caverns") {
148 @Override
149 public boolean canAssign(Player player) {
150 return true;
151 }
152
153 },
154 STEEL_DRAGONS(new String[]{"Steel dragon"}, 35, false, TaskDifficulty.HARD, new Position(2629, 9422), "Karamja Dungeon") {
155 @Override
156 public boolean canAssign(Player player) {
157 return true;
158 }
159 },
160 IRON_DRAGONS(new String[]{"Iron dragon"}, 35, false, TaskDifficulty.HARD, new Position(2682, 9463), "Karamja Dungeon") {
161 @Override
162 public boolean canAssign(Player player) {
163 return true;
164 }
165 },
166 BLUE_DRAGONS(new String[]{"Blue dragon", "Baby blue dragon"}, 35, false, TaskDifficulty.MEDIUM, new Position(2886, 9799), "Taverly Dungeon") {
167 @Override
168 public boolean canAssign(Player player) {
169 return true;
170 }
171 },
172 GARGOYLES(new String[]{"Gargoyle"}, 75, true, TaskDifficulty.HARD, new Position(3437, 3542), "Slayer Tower") {
173 @Override
174 public boolean canAssign(Player player) {
175 return player.skills.getMaxLevel(Skill.SLAYER) >= 75;
176 }
177 },
178 CRAZY_ARCHAEOLOGIST(new String[]{"Crazy archaeologist"}, 60, false, TaskDifficulty.HARD, new Position(2966, 3698), "Wilderness") {
179 @Override
180 public boolean canAssign(Player player) {
181 return player.slayer.getUnlocked().contains(SlayerUnlockable.CRAZY_ARCHAEOLOGIST);
182 }
183 },
184 // CHAOS_ELEMENTAL("Chaos elemental", 1, 150, TaskDifficulty.HARD, new Position(1, 1), "Wilderness", 2054) {
185// @Override
186// public boolean canAssign(Player player) {
187// return player.slayer.getUnlocked().contains(SlayerUnlockable.CHAOS_ELEMENT);
188// }
189//
190// @Override
191// public boolean canAttack(Player player) {
192// return true;
193// }
194// },
195 SPIRTUAL_RANGERS(new String[]{"Spiritual Ranger"}, 63, false, TaskDifficulty.HARD, new Position(2882, 5287, 2), "Godwars Dungeon") {
196 @Override
197 public boolean canAssign(Player player) {
198 return true;
199 }
200 },
201 SPIRTUAL_WARRIORS(new String[]{"Spiritual Warrior"}, 68, false, TaskDifficulty.HARD, new Position(2882, 5287, 2), "Godwars Dungeon") {
202 @Override
203 public boolean canAssign(Player player) {
204 return true;
205 }
206 },
207 SPIRTUAL_MAGES(new String[]{"Spiritual Mage"}, 83, false, TaskDifficulty.HARD, new Position(2882, 5287, 2), "Godwars Dungeon") {
208 @Override
209 public boolean canAssign(Player player) {
210 return true;
211 }
212 },
213 SKELETAL_WYVERN(new String[]{"Skeletal wyvern"}, 72, true, TaskDifficulty.HARD, new Position(3056, 9562), "Asgarnia Ice Dungeon") {
214 @Override
215 public boolean canAssign(Player player) {
216 return player.skills.getMaxLevel(Skill.SLAYER) >= 72;
217 }
218 },
219 ABYSSAL_DEMONS(new String[]{"Abyssal Demon"}, 85, true, TaskDifficulty.HARD, new Position(3414, 3558), "Slayer Tower") {
220 @Override
221 public boolean canAssign(Player player) {
222 return player.skills.getMaxLevel(Skill.SLAYER) >= 85;
223 }
224 },
225 DARK_BEAST(new String[]{"Dark beast"}, 90, true, TaskDifficulty.HARD, new Position(2010, 4644), "Temple of Light dungeon") {
226 @Override
227 public boolean canAssign(Player player) {
228 return player.skills.getMaxLevel(Skill.SLAYER) >= 90;
229 }
230 },
231 KRAKEN(new String[]{"Kraken"}, 87, true, TaskDifficulty.BOSS, new Position(2276, 10000, 0), "Kraken cave") {
232 @Override
233 public boolean canAssign(Player player) {
234 return player.skills.getMaxLevel(Skill.SLAYER) >= getLevel();
235 }
236 },
237 KING_BLACK_DRAGON(new String[]{"King black dragon"}, 1, false, TaskDifficulty.BOSS, new Position(3000, 3849), "Wilderness") {
238 @Override
239 public boolean canAssign(Player player) {
240 return player.slayer.getUnlocked().contains(SlayerUnlockable.KING_BLACK_DRAGON);
241 }
242 },
243 ZULRAH(new String[]{"Zulrah"}, 95, false, TaskDifficulty.BOSS, new Position(2206, 3056, 0), "Zulrah's Shrine") {
244 @Override
245 public boolean canAssign(Player player) {
246 return player.slayer.getUnlocked().contains(SlayerUnlockable.ZULRAH);
247 }
248 },
249 CERBERUS(new String[]{"Cerberus"}, 91, true, TaskDifficulty.BOSS, new Position(1310, 1268, 0), "Cerberus' Lair") {
250 public boolean canAssign(Player player) {
251 return player.skills.getMaxLevel(Skill.SLAYER) >= 91;
252 }
253 };
254
256 private final int level;
257
258 private final boolean levelNeeded;
259
261 private TaskDifficulty difficulty;
262
264 private final Position position;
265
267 private final String location;
268
270 private final String[] npc;
271
273 SlayerTask(String[] npc, int level, boolean levelNeeded, TaskDifficulty difficulty, Position position, String location) {
274 this.level = level;
275 this.levelNeeded = levelNeeded;
276 this.difficulty = difficulty;
277 this.position = position;
278 this.location = location;
279 this.npc = npc;
280 }
281
283 public String getName() {
284 return npc[0];
285 }
286
288 public int getLevel() {
289 return level;
290 }
291
292 public boolean isLevelNeeded() {
293 return levelNeeded;
294 }
295
298 return difficulty;
299 }
300
303 return position;
304 }
305
307 public String getLocation() {
308 return location;
309 }
310
312 public String[] getNpc() {
313 return npc;
314 }
315
317 public String getCombatLevel() {
318 return NpcDefinition.getCombatLevelRange(npc[0]);
319 }
320
322 public boolean valid(String name) {
323 for (String npc : npc) {
324 if (npc.equalsIgnoreCase(name))
325 return true;
326 }
327 return false;
328 }
329
331 public static boolean canAttack(Player player, String npc) {
332 for (SlayerTask task : values()) {
333 for (String name : task.getNpc()) {
334 if (npc.equalsIgnoreCase(name) && task.isLevelNeeded() && player.skills.getLevel(Skill.SLAYER) < task.getLevel()) {
335 return false;
336 }
337 }
338 }
339 return true;
340 }
341
343 public static SlayerTask assign(Player player, TaskDifficulty difficulty) {
344 ArrayList<SlayerTask> tasks = asList(player, difficulty);
345
346 if (tasks.isEmpty()) {
347 return null;
348 }
349
350 return Utility.randomElement(tasks);
351 }
352
354 public static ArrayList<SlayerTask> asList(Player player, TaskDifficulty difficulty) {
355 ArrayList<SlayerTask> tasks = new ArrayList<>();
356 for (SlayerTask task : values()) {
357 if (task.getLevel() > player.skills.getLevel(Skill.SLAYER))
358 continue;
359 if (!task.canAssign(player))
360 continue;
361 if (player.slayer.getBlocked().contains(task))
362 continue;
363 if (task.difficulty != difficulty)
364 continue;
365 tasks.add(task);
366 }
367 return tasks;
368 }
369
370 public static int getPoints(TaskDifficulty difficulty) {
371 switch (difficulty) {
372 case EASY:
373 return 15;
374 case MEDIUM:
375 return 20;
376 case HARD:
377 return 30;
378 case BOSS:
379 return 35;
380 }
381 return 0;
382 }
383
384 public static int getCompletionExperience(TaskDifficulty difficulty) {
385 switch (difficulty) {
386 case EASY:
387 return 5000;
388 case MEDIUM:
389 return 10000;
390 case HARD:
391 return 15000;
392 case BOSS:
393 return 25000;
394 }
395 return 0;
396 }
397}
398
399interface TaskInterface<T> {
400 boolean canAssign(final T player);
401}
static< T > T randomElement(Collection< T > collection)
Definition Utility.java:285
static boolean canAttack(Player player, String npc)
static SlayerTask assign(Player player, TaskDifficulty difficulty)
static ArrayList< SlayerTask > asList(Player player, TaskDifficulty difficulty)
SlayerTask(String[] npc, int level, boolean levelNeeded, TaskDifficulty difficulty, Position position, String location)