RuneHive-Game
Loading...
Searching...
No Matches
MixHerb.java
Go to the documentation of this file.
1package com.runehive.content.wintertodt.actions;
2
3import com.runehive.Config;
4import com.runehive.content.wintertodt.Wintertodt;
5import com.runehive.game.action.Action;
6import com.runehive.game.action.policy.WalkablePolicy;
7import com.runehive.game.world.entity.mob.player.Player;
8import com.runehive.game.world.entity.skill.Skill;
9import com.runehive.game.world.items.Item;
10
11public class MixHerb extends Action<Player> {
12
14
15 public MixHerb(Player player, int amount) {
16 super(player, 1);
17 this.amount = amount;
18 }
19
20 @Override
24
25 @Override
26 public String getName() {
27 return "Mix herb";
28 }
29
30 @Override
31 protected void execute() {
32 if(!getMob().inventory.contains(Wintertodt.BRUMA_HERB) || !getMob().inventory.contains(Wintertodt.REJUV_POT_UNF)) {
33 getMob().animate(65535);
34 getMob().action.getCurrentAction().cancel();
35 return;
36 }
37
38 if(tick % 2 == 0) {
39
40 getMob().message("You combine the bruma herb into the unfinished potion.");
41 getMob().animate(363);
42 getMob().inventory.remove(new Item(Wintertodt.BRUMA_HERB));
43 getMob().inventory.remove(new Item(Wintertodt.REJUV_POT_UNF));
44 getMob().inventory.add(new Item(Wintertodt.REJUV_POT_4));
45 getMob().inventory.refresh();
46 double xp = Skill.getLevelForExperience(getMob().skills.get(Skill.HERBLORE).getExperience()) * 0.1;
47 if(xp > 0) getMob().skills.addExperience(Skill.HERBLORE, xp * Config.HERBLORE_MODIFICATION);
48
49 amount--;
50 if(amount <= 0) {
51 getMob().animate(65535);
52 getMob().action.getCurrentAction().cancel();
53 return;
54 }
55 }
56
57 tick++;
58 }
59}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final double HERBLORE_MODIFICATION
The experience modification for herblore.
Definition Config.java:262
void execute()
A function representing the unit of work that will be carried out.
Definition MixHerb.java:31
WalkablePolicy getWalkablePolicy()
Gets the WalkablePolicy of this action.
Definition MixHerb.java:21
String getName()
Gets the name of this action.
Definition MixHerb.java:26
T getMob()
Gets the player.
Definition Action.java:44
Action(T mob, int delay, boolean instant)
Creates a new Action randomevent.
Definition Action.java:24
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 byte getLevelForExperience(double experience)
Gets the level for a given experience amount.
Definition Skill.java:446
static final int HERBLORE
The herblore skill id.
Definition Skill.java:66
The container class that represents an item that can be interacted with.
Definition Item.java:21
A queue policy determines whether the action can occur while walking.
NON_WALKABLE
This indicates actions cannot occur while walking.