RuneHive-Game
Loading...
Searching...
No Matches
SkillRepository.java
Go to the documentation of this file.
1package com.runehive.content.skill;
2
3import com.runehive.Config;
4import com.runehive.content.skill.impl.agility.Agility;
5import com.runehive.content.skill.impl.crafting.impl.Gem;
6import com.runehive.content.skill.impl.crafting.impl.Hide;
7import com.runehive.content.skill.impl.fishing.Fishable;
8import com.runehive.content.skill.impl.fishing.FishingSpot;
9import com.runehive.content.skill.impl.fishing.FishingTool;
10import com.runehive.content.skill.impl.fletching.impl.*;
11import com.runehive.content.skill.impl.herblore.GrimyHerb;
12import com.runehive.content.skill.impl.hunter.net.impl.Butterfly;
13import com.runehive.content.skill.impl.hunter.net.impl.Impling;
14import com.runehive.content.skill.impl.mining.OreData;
15import com.runehive.content.skill.impl.prayer.BoneData;
16import com.runehive.content.skill.impl.woodcutting.TreeData;
17import com.runehive.game.world.entity.mob.Direction;
18import com.runehive.game.world.entity.mob.Mob;
19import com.runehive.game.world.entity.mob.npc.Npc;
20import com.runehive.game.world.entity.mob.player.Player;
21import com.runehive.game.world.position.Position;
22import com.runehive.util.RandomUtils;
23import com.runehive.util.Utility;
24
25import java.util.ArrayList;
26import java.util.List;
27
28public class SkillRepository {
29
30 private static final List<Integer> SKILLING_ITEMS = new ArrayList<>();
31 private static final List<Integer> HERBLORE_ITEMS = new ArrayList<>();
32 private static final List<Integer> BONE_ITEMS = new ArrayList<>();
33
34 private static final List<Integer> ESSENCE_ITEMS = new ArrayList<>();
35
36
37 /** Holds all the impling onSpawn locations. */
38 private static final Position[] HUNTER_SPAWN_POSITION = {
39 new Position(3081, 3484), new Position(3101, 3484), new Position(3115, 3506),
40 new Position(3094, 3453), new Position(3134, 3511), new Position(3180, 3422),
41 new Position(3240, 3440), new Position(3287, 3351), new Position(3257, 3247),
42 new Position(3221, 3213), new Position(2803, 3445), new Position(2721, 3472),
43 new Position(3349, 3271), new Position(3283, 3196), new Position(3574, 3322),
44 new Position(2659, 2660), new Position(3377, 3168), new Position(2660, 3706),
45 new Position(2318, 3813), new Position(3054, 3514)
46 };
47
48 /** Spawns all the skilling npcs. */
49 public static void spawn() {
50 for (Position position : HUNTER_SPAWN_POSITION) {
51 int npc;
52
53 if (RandomUtils.success(.50)) {
54 npc = Utility.randomElement(Butterfly.values()).butterfly;
55 } else {
56 npc = Utility.randomElement(Impling.values()).impling;
57 }
58
60 }
61
62 for (int[] IMPLING : IMPLINGS) {
63 new Npc(IMPLING[0], new Position(IMPLING[1], IMPLING[2]), Config.NPC_WALKING_RADIUS, Mob.DEFAULT_INSTANCE, Direction.NORTH).register();
64
65 }
66
67 }
68
69 /** Loads all the skilling data. */
70 public static void load() {
71 Gem.load();
72 Hide.load();
73 Arrow.load();
74 Carvable.load();
75 Bolt.load();
76 Crossbow.load();
84 spawn();
86 }
87
88 private static void declareItems() {
89 for (TreeData tree : TreeData.values()) {
90 SKILLING_ITEMS.add(tree.item);
91 }
92 for (OreData ore : OreData.values()) {
93 SKILLING_ITEMS.add(ore.ore);
94 }
95 for (Fishable fish : Fishable.values()) {
96 SKILLING_ITEMS.add(fish.getRawFishId());
97 }
98 for (GrimyHerb herb : GrimyHerb.values()) {
99 HERBLORE_ITEMS.add(herb.getCleanID());
100 }
101 for (GrimyHerb herb : GrimyHerb.values()) {
102 HERBLORE_ITEMS.add(herb.getGrimyID());
103 }
104 for (BoneData bones : BoneData.values()) {
105 BONE_ITEMS.add(bones.getId2());
106 }
107 }
108
109 public static boolean isSkillingItem(int item) {
110 for (int id : SKILLING_ITEMS) {
111 if (item == id)
112 return true;
113 }
114 return false;
115 }
116 public static boolean isHerbloreItem(int item) {
117 for (int id : SKILLING_ITEMS) {
118 if (item == id)
119 return true;
120 }
121 return false;
122 }
123
124 public static boolean isBones(int item) {
125 for (int id : BONE_ITEMS) {
126 if (item == id)
127 return true;
128 }
129 return false;
130 }
131
132
133 public static boolean isSuccess(int skill, int levelRequired) {
134 double successChance = Math.ceil(((double) skill * 50.0D - (double) levelRequired * 15.0D) / (double) levelRequired / 3.0D * 4.0D);
135 int roll = Utility.random(99);
136 return successChance >= roll;
137 }
138
139 public static boolean isSuccess(Player p, int skillId, int levelRequired, boolean usingDragonHarpoon) {
140 double level = p.skills.getMaxLevel(skillId);
141 double successChance = Math.ceil((((level * 50.0D) - ((double) levelRequired * 15.0D)) / (double) levelRequired / 3.0D) * 4.0D);
142 int roll = usingDragonHarpoon ? Utility.random(79) : Utility.random(99);
143 return successChance >= roll;
144 }
145
146 public static boolean isSuccess(Player p, int skill, int levelRequired, int toolLevelRequired) {
147 double level = (p.skills.getMaxLevel(skill) + toolLevelRequired) / 2.0D;
148 double successChance = Math.ceil((((level * 50.0D) - ((double) levelRequired * 15.0D)) / (double) levelRequired / 3.0D) * 4.0D);
149 int roll = Utility.random(99);
150 return successChance >= roll;
151 }
152
153 public static final int[][] IMPLINGS = {
154 /**
155 * Baby imps
156 */
157 {1635, 2612, 4318},
158 {1635, 2602, 4314},
159 {1635, 2610, 4338},
160 {1635, 2582, 4344},
161 {1635, 2578, 4344},
162 {1635, 2568, 4311},
163 {1635, 2583, 4295},
164 {1635, 2582, 4330},
165 {1635, 2600, 4303},
166 {1635, 2611, 4301},
167 {1635, 2618, 4329},
168
169 /**
170 * Young imps
171 */
172 {1636, 2591, 4332},
173 {1636, 2600, 4338},
174 {1636, 2595, 4345},
175 {1636, 2610, 4327},
176 {1636, 2617, 4314},
177 {1636, 2619, 4294},
178 {1636, 2599, 4294},
179 {1636, 2575, 4303},
180 {1636, 2570, 4299},
181
182 /**
183 * Gourment imps
184 */
185 {1637, 2573, 4339},
186 {1637, 2567, 4328},
187 {1637, 2593, 4297},
188 {1637, 2618, 4305},
189 {1637, 2605, 4316},
190 {1637, 2596, 4333},
191
192 /**
193 * Earth imps
194 */
195 {1638, 2592, 4338},
196 {1638, 2611, 4345},
197 {1638, 2617, 4339},
198 {1638, 2614, 4301},
199 {1638, 2606, 4295},
200 {1638, 2581, 4299},
201
202 /**
203 * Essence imps
204 */
205 {1639, 2602, 4328},
206 {1639, 2608, 4333},
207 {1639, 2609, 4296},
208 {1639, 2581, 4304},
209 {1639, 2570, 4318},
210
211 /**
212 * Eclectic imps
213 */
214 {1640, 2611, 4310},
215 {1640, 2617, 4319},
216 {1640, 2600, 4347},
217 {1640, 2570, 4326},
218 {1640, 2579, 4310},
219
220 /**
221 * Spirit imps
222 */
223
224 /**
225 * Nature imps
226 */
227 {1641, 2581, 4310},
228 {1641, 2581, 4310},
229 {1641, 2603, 4333},
230 {1641, 2576, 4335},
231 {1641, 2588, 4345},
232
233 /**
234 * Magpie imps
235 */
236 {1642, 2612, 4324},
237 {1642, 2602, 4323},
238 {1642, 2587, 4348},
239 {1642, 2564, 4320},
240 {1642, 2566, 4295},
241
242 /**
243 * Ninja imps
244 */
245 {1643, 2570, 4347},
246 {1643, 2572, 4327},
247 {1643, 2578, 4318},
248 {1643, 2610, 4312},
249 {1643, 2594, 4341},
250
251 /**
252 * Dragon imps
253 */
254 {1654, 2613, 4341},
255 {1654, 2585, 4337},
256 {1654, 2576, 4319},
257 {1654, 2576, 4294},
258 {1654, 2592, 4305},
259 };
260}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final int NPC_WALKING_RADIUS
The walking radius for Npc.
Definition Config.java:157
static boolean isSuccess(int skill, int levelRequired)
static final Position[] HUNTER_SPAWN_POSITION
Holds all the impling onSpawn locations.
static final List< Integer > HERBLORE_ITEMS
static final List< Integer > ESSENCE_ITEMS
static boolean isSuccess(Player p, int skill, int levelRequired, int toolLevelRequired)
static final List< Integer > SKILLING_ITEMS
static void spawn()
Spawns all the skilling npcs.
static void load()
Loads all the skilling data.
static boolean isSuccess(Player p, int skillId, int levelRequired, boolean usingDragonHarpoon)
Created by Daniel on 2017-11-02.
Definition Agility.java:21
Handles the mob class.
Definition Mob.java:66
Represents a non-player character in the in-game world.
Definition Npc.java:29
void register()
Registers an entity to the World.
Definition Npc.java:112
This class represents a character controlled by a player.
Definition Player.java:125
int getMaxLevel(int id)
Gets the highest possible level of a skill.
Represents a single tile on the game world.
Definition Position.java:14
A static-util class that provides additional functionality for generating pseudo-random numbers.
static boolean success(double value)
Determines if a pseudorandomly generated double rounded to two decimal places is below or equal to va...
Handles miscellaneous methods.
Definition Utility.java:27
static int random(int bound)
Definition Utility.java:239
static< T > T randomElement(Collection< T > collection)
Picks a random element out of any array type.
Definition Utility.java:248
Represents the enumerated directions an entity can walk or face.