RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.skill.impl.slayer.Slayer Class Reference

Handles the slayer skill. More...

Collaboration diagram for com.runehive.content.skill.impl.slayer.Slayer:

Public Member Functions

void activate (Npc npc, int killAmount)
 Activates killing a slayer npc.
void assign (TaskDifficulty difficulty)
 Assigns a slayer task to the player.
void block ()
 Blocks the current assigned slayer task.
boolean cancel (boolean requiresCost)
 Cancel's the current assigned slayer task.
void confirm (int button)
 Opens the confirm itemcontainer for purchasing a perk.
int getAmount ()
int getAssigned ()
List< SlayerTaskgetBlocked ()
int getPoints ()
SlayerTask getTask ()
int getTotalAssigned ()
int getTotalCancelled ()
int getTotalCompleted ()
int getTotalPoints ()
Set< SlayerUnlockablegetUnlocked ()
void open (SlayerTab tab)
 Opens the slayer itemcontainer.
void purchase ()
 Handles purchasing a slayer perk.
void setAmount (int amount)
void setAssigned (int assigned)
void setBlocked (List< SlayerTask > blocked)
void setPoints (int points)
void setTask (SlayerTask task)
void setTotalAssigned (int totalAssigned)
void setTotalCancelled (int totalCancelled)
void setTotalCompleted (int totalCompleted)
void setTotalPoints (int totalPoints)
void setUnlocked (Set< SlayerUnlockable > unlocked)
 Slayer (Player player)
 Constructs a new Slayer.
void store (int slot, int amount, boolean value)
 Handles purchasing items from the slayer shop.
void unblock (int index)
 Unblocks the slayer task.

Static Package Functions

 [static initializer]

Static Package Attributes

static Item[] ITEMS = new Item[STORE_ITEMS.length]

Private Attributes

int amount
 The current slayer task amount.
int assigned
 The slayer task assigned amount.
List< SlayerTaskblocked = new LinkedList<>()
 The list of all blocked slayer tasks.
Player player
 The player instance.
int points
 The slayer points.
SlayerTask task
 The slayer task.
int totalAssigned
 The total tasks assigned.
int totalCancelled
 The total tasks cancelled.
int totalCompleted
 The total tasks completed.
int totalPoints
 The total points accumulated.
Set< SlayerUnlockableunlocked = new HashSet<>(SlayerUnlockable.values().length)
 The Set of all unlockable slayer perks.

Static Private Attributes

static final StoreItem[] STORE_ITEMS

Detailed Description

Handles the slayer skill.

Author
Daniel

Definition at line 26 of file Slayer.java.

Constructor & Destructor Documentation

◆ Slayer()

com.runehive.content.skill.impl.slayer.Slayer.Slayer ( Player player)

Constructs a new Slayer.

Definition at line 61 of file Slayer.java.

61 {
62 this.player = player;
63 }

References player.

Member Function Documentation

◆ [static initializer]()

com.runehive.content.skill.impl.slayer.Slayer.[static initializer]
staticpackage

References ITEMS, and STORE_ITEMS.

◆ activate()

void com.runehive.content.skill.impl.slayer.Slayer.activate ( Npc npc,
int killAmount )

Activates killing a slayer npc.

Definition at line 171 of file Slayer.java.

171 {
172 if (task != null && task.valid(npc.getName())) {
173 amount -= killAmount;
174 if (amount <= 0) {
175 int rewardPoints = SlayerTask.getPoints(task.getDifficulty());
176 points += rewardPoints;
177 player.skills.addExperience(Skill.SLAYER, SlayerTask.getCompletionExperience(task.getDifficulty()));
178 task = null;
179 amount = 0;
180 totalCompleted++;
181 player.message("Congratulations, you have completed your assigned task! You have earned " + rewardPoints + " slayer points!");
182 AchievementHandler.activate(player, AchievementKey.SLAYER_TASKS);
183 return;
184 }
185 player.skills.addExperience(Skill.SLAYER, npc.getMaximumHealth() * Config.SLAYER_MODIFICATION);
186 }
187 }

References com.runehive.content.achievement.AchievementHandler.activate(), amount, com.runehive.content.skill.impl.slayer.SlayerTask.getCompletionExperience(), com.runehive.game.world.entity.mob.Mob.getMaximumHealth(), com.runehive.game.world.entity.mob.npc.Npc.getName(), com.runehive.content.skill.impl.slayer.SlayerTask.getPoints(), player, points, com.runehive.game.world.entity.skill.Skill.SLAYER, com.runehive.Config.SLAYER_MODIFICATION, com.runehive.content.achievement.AchievementKey.SLAYER_TASKS, task, and totalCompleted.

Referenced by com.runehive.game.world.entity.mob.npc.NpcDeath.postDeath().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ assign()

void com.runehive.content.skill.impl.slayer.Slayer.assign ( TaskDifficulty difficulty)

Assigns a slayer task to the player.

Definition at line 73 of file Slayer.java.

73 {
74 if (task != null) {
75 player.message("You currently have a task assigned!");
76 return;
77 }
78
79 SlayerTask toAssign = SlayerTask.assign(player, difficulty);
80
81 if (toAssign == null) {
82 player.dialogueFactory.sendNpcChat(6797, "There are no tasks available for you!", "This can be because you do not have a valid", "slayer level or you haven't unlocked any tasks.");
83 return;
84 }
85
86 int assignment = 0;
87 if (toAssign.getDifficulty() == TaskDifficulty.EASY) {
88 assignment = Utility.random(35, 75);
89 } else if (toAssign.getDifficulty() == TaskDifficulty.MEDIUM) {
90 assignment = Utility.random(45, 80);
91 } else if (toAssign.getDifficulty() == TaskDifficulty.HARD) {
92 assignment = Utility.random(60, 100);
93 } else if (toAssign.getDifficulty() == TaskDifficulty.BOSS) {
94 assignment = Utility.random(30, 50);
95 }
96
97 totalAssigned++;
98 task = toAssign;
99 amount = assignment;
100 SlayerTab.refresh(player, player.attributes.get("SLAYER_KEY", SlayerTab.class));
101 player.message("You have been assigned " + amount + "x " + task.getName() + ".");
102 }

References amount, com.runehive.content.skill.impl.slayer.SlayerTask.assign(), com.runehive.content.skill.impl.slayer.TaskDifficulty.BOSS, com.runehive.content.skill.impl.slayer.TaskDifficulty.EASY, com.runehive.content.skill.impl.slayer.SlayerTask.getDifficulty(), com.runehive.content.skill.impl.slayer.TaskDifficulty.HARD, com.runehive.content.skill.impl.slayer.TaskDifficulty.MEDIUM, player, com.runehive.util.Utility.random(), com.runehive.content.skill.impl.slayer.SlayerTab.refresh(), task, and totalAssigned.

Here is the call graph for this function:

◆ block()

void com.runehive.content.skill.impl.slayer.Slayer.block ( )

Blocks the current assigned slayer task.

Definition at line 128 of file Slayer.java.

128 {
129 if (task == null) {
130 player.message("You do not have a task to block.");
131 return;
132 }
133
134 if (points < 100) {
135 player.message("You need 100 slayer points to block a task.");
136 return;
137 }
138
139 if (blocked.size() >= 5) {
140 player.message("You can only block up to 5 tasks.");
141 return;
142 }
143
144 if (blocked.contains(task)) {
145 player.message("This task is already blocked... but how did you get it again? mmm...");
146 return;
147 }
148
149 blocked.add(task);
150 points -= 100;
151 task = null;
152 amount = 0;
153 totalCancelled++;
154 SlayerTab.refresh(player, player.attributes.get("SLAYER_KEY", SlayerTab.class));
155 player.message("Your task has been blocked.");
156 }

References amount, blocked, player, points, com.runehive.content.skill.impl.slayer.SlayerTab.refresh(), task, and totalCancelled.

Here is the call graph for this function:

◆ cancel()

boolean com.runehive.content.skill.impl.slayer.Slayer.cancel ( boolean requiresCost)

Cancel's the current assigned slayer task.

Definition at line 105 of file Slayer.java.

105 {
106 if (task == null) {
107 player.message("You do not have a task to cancel.");
108 return false;
109 }
110
111 if (requiresCost) {
112 int cost = PlayerRight.isDonator(player) ? 20 : 25;
113 if (points < cost) {
114 player.message("You need " + cost + " slayer points to cancel a task.");
115 return false;
116 }
117 points -= cost;
118 }
119 task = null;
120 amount = 0;
121 totalCancelled++;
122 SlayerTab.refresh(player, player.attributes.get("SLAYER_KEY", SlayerTab.class));
123 player.message("Your task has been cancelled.");
124 return true;
125 }

References amount, com.runehive.game.world.entity.mob.player.PlayerRight.isDonator(), player, points, com.runehive.content.skill.impl.slayer.SlayerTab.refresh(), task, and totalCancelled.

Here is the call graph for this function:

◆ confirm()

void com.runehive.content.skill.impl.slayer.Slayer.confirm ( int button)

Opens the confirm itemcontainer for purchasing a perk.

Definition at line 190 of file Slayer.java.

190 {
191 int index = Math.abs((-18625 - button) / 6);
192 if (!SlayerUnlockable.get(index).isPresent())
193 return;
194 SlayerUnlockable unlockable = SlayerUnlockable.get(index).get();
195 player.attributes.set("SLAYER_CONFIRM_KEY", unlockable);
196 open(SlayerTab.CONFIRM);
197 }
val index

References com.runehive.content.skill.impl.slayer.SlayerTab.CONFIRM, com.runehive.content.skill.impl.slayer.SlayerUnlockable.get(), open(), and player.

Here is the call graph for this function:

◆ getAmount()

int com.runehive.content.skill.impl.slayer.Slayer.getAmount ( )

Definition at line 303 of file Slayer.java.

303 {
304 return amount;
305 }

References amount.

Referenced by com.runehive.content.skill.impl.slayer.SlayerTab.refresh().

Here is the caller graph for this function:

◆ getAssigned()

int com.runehive.content.skill.impl.slayer.Slayer.getAssigned ( )

Definition at line 311 of file Slayer.java.

311 {
312 return assigned;
313 }

References assigned.

Referenced by com.runehive.content.skill.impl.slayer.SlayerTab.refresh().

Here is the caller graph for this function:

◆ getBlocked()

List< SlayerTask > com.runehive.content.skill.impl.slayer.Slayer.getBlocked ( )

Definition at line 351 of file Slayer.java.

351 {
352 return blocked;
353 }

References blocked.

Referenced by com.runehive.content.skill.impl.slayer.SlayerTask.asList(), and com.runehive.content.skill.impl.slayer.SlayerTab.refresh().

Here is the caller graph for this function:

◆ getPoints()

int com.runehive.content.skill.impl.slayer.Slayer.getPoints ( )

◆ getTask()

◆ getTotalAssigned()

int com.runehive.content.skill.impl.slayer.Slayer.getTotalAssigned ( )

Definition at line 319 of file Slayer.java.

319 {
320 return totalAssigned;
321 }

References totalAssigned.

Referenced by com.runehive.content.skill.impl.slayer.SlayerTab.refresh().

Here is the caller graph for this function:

◆ getTotalCancelled()

int com.runehive.content.skill.impl.slayer.Slayer.getTotalCancelled ( )

Definition at line 335 of file Slayer.java.

335 {
336 return totalCancelled;
337 }

References totalCancelled.

Referenced by com.runehive.content.skill.impl.slayer.SlayerTab.refresh().

Here is the caller graph for this function:

◆ getTotalCompleted()

int com.runehive.content.skill.impl.slayer.Slayer.getTotalCompleted ( )

Definition at line 327 of file Slayer.java.

327 {
328 return totalCompleted;
329 }

References totalCompleted.

Referenced by com.runehive.content.skill.impl.slayer.SlayerTab.refresh().

Here is the caller graph for this function:

◆ getTotalPoints()

int com.runehive.content.skill.impl.slayer.Slayer.getTotalPoints ( )

Definition at line 343 of file Slayer.java.

343 {
344 return totalPoints;
345 }

References totalPoints.

Referenced by com.runehive.content.skill.impl.slayer.SlayerTab.refresh().

Here is the caller graph for this function:

◆ getUnlocked()

Set< SlayerUnlockable > com.runehive.content.skill.impl.slayer.Slayer.getUnlocked ( )

Definition at line 359 of file Slayer.java.

359 {
360 return unlocked;
361 }

References unlocked.

Referenced by com.runehive.content.skill.impl.smithing.SmithingArmour.forge(), and com.runehive.content.skill.impl.slayer.SlayerTab.refresh().

Here is the caller graph for this function:

◆ open()

void com.runehive.content.skill.impl.slayer.Slayer.open ( SlayerTab tab)

Opens the slayer itemcontainer.

Definition at line 66 of file Slayer.java.

66 {
67 SlayerTab.refresh(player, tab);
68 player.attributes.set("SLAYER_KEY", tab);
69 player.interfaceManager.open(tab.getIdentification());
70 }

References com.runehive.content.skill.impl.slayer.SlayerTab.getIdentification(), player, and com.runehive.content.skill.impl.slayer.SlayerTab.refresh().

Referenced by confirm(), com.runehive.game.plugin.PluginContext.onClick(), purchase(), and com.runehive.content.dialogue.impl.NieveDialogue.sendDialogues().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ purchase()

void com.runehive.content.skill.impl.slayer.Slayer.purchase ( )

Handles purchasing a slayer perk.

Definition at line 200 of file Slayer.java.

200 {
201 SlayerUnlockable unlockable = player.attributes.get("SLAYER_CONFIRM_KEY", SlayerUnlockable.class);
202
203 if (points < unlockable.getCost()) {
204 open(SlayerTab.UNLOCK);
205 player.message("You do not have enough points to purchase this!");
206 return;
207 }
208
209 if (unlocked.contains(unlockable)) {
210 open(SlayerTab.UNLOCK);
211 player.message("You have already activated this perk!");
212 return;
213 }
214
215 points -= unlockable.getCost();
216 unlocked.add(unlockable);
217 player.message("You have purchased the " + unlockable.getName() + " Slayer perk.");
218 open(SlayerTab.UNLOCK);
219 }

References com.runehive.content.skill.impl.slayer.SlayerUnlockable.getCost(), com.runehive.content.skill.impl.slayer.SlayerUnlockable.getName(), open(), player, points, com.runehive.content.skill.impl.slayer.SlayerTab.UNLOCK, and unlocked.

Here is the call graph for this function:

◆ setAmount()

void com.runehive.content.skill.impl.slayer.Slayer.setAmount ( int amount)

Definition at line 307 of file Slayer.java.

307 {
308 this.amount = amount;
309 }

References amount.

◆ setAssigned()

void com.runehive.content.skill.impl.slayer.Slayer.setAssigned ( int assigned)

Definition at line 315 of file Slayer.java.

315 {
316 this.assigned = assigned;
317 }

References assigned.

◆ setBlocked()

void com.runehive.content.skill.impl.slayer.Slayer.setBlocked ( List< SlayerTask > blocked)

Definition at line 355 of file Slayer.java.

355 {
356 this.blocked = blocked;
357 }

References blocked.

◆ setPoints()

void com.runehive.content.skill.impl.slayer.Slayer.setPoints ( int points)

Definition at line 291 of file Slayer.java.

291 {
292 this.points = points;
293 }

References points.

Referenced by com.runehive.content.skill.impl.slayer.SlayerOfferings.confirm(), com.runehive.content.store.currency.impl.SlayerPointCurrency.recieveCurrency(), and com.runehive.content.store.currency.impl.SlayerPointCurrency.takeCurrency().

Here is the caller graph for this function:

◆ setTask()

void com.runehive.content.skill.impl.slayer.Slayer.setTask ( SlayerTask task)

Definition at line 299 of file Slayer.java.

299 {
300 this.task = task;
301 }

References task.

◆ setTotalAssigned()

void com.runehive.content.skill.impl.slayer.Slayer.setTotalAssigned ( int totalAssigned)

Definition at line 323 of file Slayer.java.

323 {
324 this.totalAssigned = totalAssigned;
325 }

References totalAssigned.

◆ setTotalCancelled()

void com.runehive.content.skill.impl.slayer.Slayer.setTotalCancelled ( int totalCancelled)

Definition at line 339 of file Slayer.java.

339 {
340 this.totalCancelled = totalCancelled;
341 }

References totalCancelled.

◆ setTotalCompleted()

void com.runehive.content.skill.impl.slayer.Slayer.setTotalCompleted ( int totalCompleted)

Definition at line 331 of file Slayer.java.

331 {
332 this.totalCompleted = totalCompleted;
333 }

References totalCompleted.

◆ setTotalPoints()

void com.runehive.content.skill.impl.slayer.Slayer.setTotalPoints ( int totalPoints)

Definition at line 347 of file Slayer.java.

347 {
348 this.totalPoints = totalPoints;
349 }

References totalPoints.

◆ setUnlocked()

void com.runehive.content.skill.impl.slayer.Slayer.setUnlocked ( Set< SlayerUnlockable > unlocked)

Definition at line 363 of file Slayer.java.

363 {
364 this.unlocked = unlocked;
365 }

References unlocked.

◆ store()

void com.runehive.content.skill.impl.slayer.Slayer.store ( int slot,
int amount,
boolean value )

Handles purchasing items from the slayer shop.

Definition at line 247 of file Slayer.java.

247 {
248 if (slot < 0 && slot > STORE_ITEMS.length) {
249 return;
250 }
251
252 StoreItem item = STORE_ITEMS[slot];
253 int cost = item.getShopValue();
254
255 if (value) {
256 String price = cost == 0 ? "is free!" : "costs " + Utility.formatDigits(cost) + " slayer points.";
257 player.message(item.getName() + " " + price);
258 return;
259 }
260
261 if (player.inventory.remaining() == 0) {
262 player.message("You do not have enough inventory space to buy that.");
263 return;
264 }
265
266 if (!item.isStackable()) {
267 if (amount > player.inventory.remaining()) {
268 amount = player.inventory.remaining();
269 }
270 } else {
271 amount *= item.getAmount();
272 }
273
274 int price = cost * amount;
275
276 if (getPoints() < price) {
277 player.message("You do not have enough slayer points to make this purchase!");
278 return;
279 }
280
281 item.setAmount(amount);
282 points -= price;
283 player.inventory.add(item);
284 player.send(new SendString(Utility.formatDigits(points) + "\\nPoints", 46714));
285 }

References amount, com.runehive.util.Utility.formatDigits(), com.runehive.game.world.items.Item.getAmount(), com.runehive.game.world.items.Item.getName(), getPoints(), com.runehive.content.store.StoreItem.getShopValue(), com.runehive.game.world.items.Item.isStackable(), player, points, com.runehive.game.world.items.Item.setAmount(), and STORE_ITEMS.

Here is the call graph for this function:

◆ unblock()

void com.runehive.content.skill.impl.slayer.Slayer.unblock ( int index)

Unblocks the slayer task.

Definition at line 159 of file Slayer.java.

159 {
160 if (!blocked.isEmpty() && index < blocked.size()) {
161 SlayerTask task = blocked.get(index);
162 blocked.remove(task);
163 SlayerTab.refresh(player, player.attributes.get("SLAYER_KEY", SlayerTab.class));
164 player.message("You have unblocked the task " + task.getName() + ".");
165 return;
166 }
167 player.message("There is no task to unblock.");
168 }

References blocked, player, com.runehive.content.skill.impl.slayer.SlayerTab.refresh(), and task.

Here is the call graph for this function:

Member Data Documentation

◆ amount

int com.runehive.content.skill.impl.slayer.Slayer.amount
private

The current slayer task amount.

Definition at line 40 of file Slayer.java.

Referenced by activate(), assign(), block(), cancel(), getAmount(), setAmount(), and store().

◆ assigned

int com.runehive.content.skill.impl.slayer.Slayer.assigned
private

The slayer task assigned amount.

Definition at line 37 of file Slayer.java.

Referenced by getAssigned(), and setAssigned().

◆ blocked

List<SlayerTask> com.runehive.content.skill.impl.slayer.Slayer.blocked = new LinkedList<>()
private

The list of all blocked slayer tasks.

Definition at line 55 of file Slayer.java.

Referenced by block(), getBlocked(), setBlocked(), and unblock().

◆ ITEMS

Item [] com.runehive.content.skill.impl.slayer.Slayer.ITEMS = new Item[STORE_ITEMS.length]
staticpackage

◆ player

Player com.runehive.content.skill.impl.slayer.Slayer.player
private

The player instance.

Definition at line 28 of file Slayer.java.

Referenced by activate(), assign(), block(), cancel(), confirm(), open(), purchase(), Slayer(), store(), and unblock().

◆ points

int com.runehive.content.skill.impl.slayer.Slayer.points
private

The slayer points.

Definition at line 31 of file Slayer.java.

Referenced by activate(), block(), cancel(), getPoints(), purchase(), setPoints(), and store().

◆ STORE_ITEMS

final StoreItem [] com.runehive.content.skill.impl.slayer.Slayer.STORE_ITEMS
staticprivate
Initial value:
= {
new StoreItem(4155, 1, 0),
new StoreItem(11941, 1, 150),
new StoreItem(11866, 1, 75),
new StoreItem(4166, 1, 5),
new StoreItem(4168, 1, 5),
new StoreItem(4164, 1, 5),
new StoreItem(4551, 1, 5),
new StoreItem(8901, 1, 200),
new StoreItem(10551, 1, 200),
new StoreItem(11738, 1, 25),
new StoreItem(13116, 1, 200),
new StoreItem(25781, 1, 200)
}
A simple wrapper class which holds extra attributes for the item object.

Definition at line 221 of file Slayer.java.

221 {
222 new StoreItem(4155, 1, 0),
223 new StoreItem(11941, 1, 150),
224 new StoreItem(11866, 1, 75),
225 new StoreItem(4166, 1, 5),
226 new StoreItem(4168, 1, 5),
227 new StoreItem(4164, 1, 5),
228 new StoreItem(4551, 1, 5),
229 new StoreItem(8901, 1, 200),
230 new StoreItem(10551, 1, 200),
231 new StoreItem(11738, 1, 25),
232 new StoreItem(13116, 1, 200),
233 new StoreItem(25781, 1, 200)
234 };

Referenced by [static initializer](), and store().

◆ task

SlayerTask com.runehive.content.skill.impl.slayer.Slayer.task
private

The slayer task.

Definition at line 34 of file Slayer.java.

Referenced by activate(), assign(), block(), cancel(), getTask(), setTask(), and unblock().

◆ totalAssigned

int com.runehive.content.skill.impl.slayer.Slayer.totalAssigned
private

The total tasks assigned.

Definition at line 43 of file Slayer.java.

Referenced by assign(), getTotalAssigned(), and setTotalAssigned().

◆ totalCancelled

int com.runehive.content.skill.impl.slayer.Slayer.totalCancelled
private

The total tasks cancelled.

Definition at line 49 of file Slayer.java.

Referenced by block(), cancel(), getTotalCancelled(), and setTotalCancelled().

◆ totalCompleted

int com.runehive.content.skill.impl.slayer.Slayer.totalCompleted
private

The total tasks completed.

Definition at line 46 of file Slayer.java.

Referenced by activate(), getTotalCompleted(), and setTotalCompleted().

◆ totalPoints

int com.runehive.content.skill.impl.slayer.Slayer.totalPoints
private

The total points accumulated.

Definition at line 52 of file Slayer.java.

Referenced by getTotalPoints(), and setTotalPoints().

◆ unlocked

Set<SlayerUnlockable> com.runehive.content.skill.impl.slayer.Slayer.unlocked = new HashSet<>(SlayerUnlockable.values().length)
private

The Set of all unlockable slayer perks.

Definition at line 58 of file Slayer.java.

Referenced by getUnlocked(), purchase(), and setUnlocked().


The documentation for this class was generated from the following file:
  • java/com/runehive/content/skill/impl/slayer/Slayer.java