RuneHive-Game
Loading...
Searching...
No Matches
PickHerb.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;
9
10public class PickHerb extends Action<Player> {
11
12 int tick;
13
14 public PickHerb(Player player) {
15 super(player, 3);
16 }
17
18 @Override
22
23 @Override
24 public String getName() {
25 return "Pick herb";
26 }
27
28 @Override
29 protected void execute() {
30 if(tick % 2 == 0) {
31 if(getMob().inventory.getFreeSlots() > 0) {
32 getMob().message("You pick a bruma herb.");
33 getMob().inventory.add(Wintertodt.BRUMA_HERB, 1);
34 getMob().inventory.refresh();
35 double xp = Skill.getLevelForExperience(getMob().skills.get(Skill.FARMING).getExperience()) * 0.1;
36 if(xp > 0) getMob().skills.addExperience(Skill.FARMING, xp * Config.FARMING_MODIFICATION);
37 getMob().animate(2282);
38 } else {
39 getMob().message("You have no space for that.");
40 getMob().action.getCurrentAction().cancel();
41 }
42 }
43 tick++;
44 }
45}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final double FARMING_MODIFICATION
The experience modification for farming.
Definition Config.java:295
void execute()
A function representing the unit of work that will be carried out.
Definition PickHerb.java:29
String getName()
Gets the name of this action.
Definition PickHerb.java:24
WalkablePolicy getWalkablePolicy()
Gets the WalkablePolicy of this action.
Definition PickHerb.java:19
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 FARMING
The farming skill id.
Definition Skill.java:78
A queue policy determines whether the action can occur while walking.
NON_WALKABLE
This indicates actions cannot occur while walking.