RuneHive-Game
Loading...
Searching...
No Matches
ShootingStarData.java
Go to the documentation of this file.
1package com.runehive.content.shootingstar;
2
3import com.runehive.Config;
4import com.runehive.game.world.World;
5import com.runehive.game.world.entity.mob.player.Player;
6import com.runehive.game.world.entity.skill.Skill;
7import com.runehive.game.world.items.Item;
8import com.runehive.game.world.object.CustomGameObject;
9import com.runehive.util.RandomUtils;
10
11public class ShootingStarData {
12
13 /**
14 * See if the dust needs to be removed double
15 */
16 private boolean decreaseDouble = false;
17
18 /**
19 * The current location of the star
20 */
22
23 /**
24 * The current level of the star
25 */
26 public int starLevel;
27
28 /**
29 * How much dust there currently is in the star
30 */
31 public int availableDust;
32
33 /**
34 * The max dust for this star level
35 */
36 public int maxDust;
37
38 /**
39 * All the possible object ids for the different star levels
40 */
41 public int[] starIds = { 41229, 41228, 41227, 41226, 41225, 41224, 41223, 41021, };
42
43 /**
44 * The amount of star dust the player receives for the different star levels
45 */
46 public int[] possibleDust = { 1200, 700, 430, 250, 175, 80, 40, 40, 15 };
47
48 /**
49 * Possible xp drops for the differernt star levels
50 */
51 public int[] xpDrops = { 12, 22, 26, 31, 48, 74, 123, 162, 244 };
52
53 /**
54 * The game object linked to the star
55 */
57
58 /**
59 * The chance of doubling stardust depending on the star level
60 */
61 public int[] doubleChance = { 2, 6, 12, 20, 30, 42, 56, 72, 90 };
62
68
69 System.out.println("starLocation.starPosition " + starLocation.starPosition);
71 starObject.register();
72 }
73
74 /**
75 * Handles decreasing the dust for a star
76 */
77 public void decreaseDust(Player player) {
79 int amount = 1;
80
81 //Handles the double stardust chance
82 int roll = RandomUtils.inclusive(0, 100);
83 if(roll <= doubleChance[starLevel]) amount *= 2;
84
85 player.inventory.add(new Item(25527, amount));
86 availableDust -= decreaseDouble ? amount : amount / 2;
87
88 if(availableDust <= 0) {
90 for(Player p : World.getPlayers()) {
91 if(p == null || !(p.action.getCurrentAction() instanceof ShootingStarAction)) continue;
92
93 System.out.println("Reset the mining action for all the players with a shooting star action...");
94 p.action.cancel();
95 p.resetFace();
96 p.skills.get(Skill.MINING).setDoingSkill(false);
97 }
98 }
99 }
100
101 /**
102 * Handles the decreasing of the star level
103 */
104 public void decreaseLevel() {
105 starLevel--;
106 if(starLevel < 0) {
107 destruct();
108 return;
109 }
110
113 starObject.transform(getObjectId());
114 }
115
116 /**
117 * Handles removing the star from the game
118 */
119 public void destruct() {
120 starObject.unregister();
121 starObject = null;
122 }
123
124 /**
125 * Gets the random star level
126 * @return
127 */
128 public int getLevel() {
129 int[] chances = { 0, 16, 18, 20, 17, 12, 9, 5 }; //, 3
130
131 for (int index = chances.length - 1; index > 0; index--) {
132 int roll = RandomUtils.inclusive(0, 100);
133 if (roll < chances[index])
134 return index;
135 }
136 return 2;
137 }
138
139 /**
140 * The current object id
141 * @return
142 */
143 public int getObjectId() {
144 return starIds[starLevel];
145 }
146
147 /**
148 * The required mining level for the star level
149 * @return
150 */
151 public int getMiningLevel() {
152 return (starLevel + 1) * 10;
153 }
154
155 /**
156 * Percentage till the next star level
157 * @return
158 */
159 public int getPercentage() {
160 return (maxDust - availableDust) * 100 / maxDust;
161 }
162
163 /**
164 * The xp the player gets for the current star
165 * @return
166 */
167 public int getXPDrop() {
168 return xpDrops[starLevel];
169 }
170
171 /**
172 * The current location of the star
173 * @return
174 */
175 public String getLocationName() {
176 return starLocation.location[0];
177 }
178
179 /**
180 * The current hint of the star location
181 * @return
182 */
183 public String getHint() {
184 return starLocation.location[1];
185 }
186}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final double MINING_MODIFICATION
The experience modification for mining.
Definition Config.java:271
int maxDust
The max dust for this star level.
int[] starIds
All the possible object ids for the different star levels.
int availableDust
How much dust there currently is in the star.
CustomGameObject starObject
The game object linked to the star.
int getXPDrop()
The xp the player gets for the current star.
int[] xpDrops
Possible xp drops for the differernt star levels.
void decreaseDust(Player player)
Handles decreasing the dust for a star.
String getLocationName()
The current location of the star.
void destruct()
Handles removing the star from the game.
boolean decreaseDouble
See if the dust needs to be removed double.
int[] possibleDust
The amount of star dust the player receives for the different star levels.
String getHint()
The current hint of the star location.
int[] doubleChance
The chance of doubling stardust depending on the star level.
int getPercentage()
Percentage till the next star level.
int getMiningLevel()
The required mining level for the star level.
void decreaseLevel()
Handles the decreasing of the star level.
ShootingStarLocations starLocation
The current location of the star.
Represents the game world.
Definition World.java:46
static MobList< Player > getPlayers()
Definition World.java:544
This class represents a character controlled by a player.
Definition Player.java:125
Represents a trainable and usable skill.
Definition Skill.java:18
static final int MINING
The mining skill id.
Definition Skill.java:63
void addExperience(int id, double experience)
Adds experience to a given skill.
The container class that represents an item that can be interacted with.
Definition Item.java:21
boolean add(Item item)
Attempts to deposit item into this container.
Represents a static game object loaded from the map fs.
A static-util class that provides additional functionality for generating pseudo-random numbers.
static int inclusive(int min, int max)
Returns a pseudo-random int value between inclusive min and inclusive max.