RuneHive-Game
Loading...
Searching...
No Matches
ScatterAshAction.java
Go to the documentation of this file.
1package com.runehive.game.action.impl;
2
3import com.runehive.Config;
4import com.runehive.content.skill.impl.prayer.AshData;
5import com.runehive.content.skillcape.SkillCape;
6import com.runehive.content.achievement.AchievementHandler;
7import com.runehive.content.achievement.AchievementKey;
8import com.runehive.content.skill.SkillAction;
9import com.runehive.content.skill.impl.prayer.BoneData;
10import com.runehive.game.Animation;
11import com.runehive.game.action.policy.WalkablePolicy;
12import com.runehive.game.world.entity.mob.player.Player;
13import com.runehive.game.world.entity.skill.Skill;
14import com.runehive.game.world.items.Item;
15import com.runehive.net.packet.out.SendMessage;
16
17import java.util.Optional;
18
19public final class ScatterAshAction extends SkillAction {
20 private final int slot;
21 private final Item item;
22 private final AshData ashes;
23
24 public ScatterAshAction(Player player, AshData ashes, int slot) {
25 super(player, Optional.empty(), true);
26 this.slot = slot;
27 this.ashes = ashes;
28 this.item = player.inventory.get(slot);
29 }
30
31 @Override
32 public boolean canInit() {
33 return getMob().skills.getSkills()[skill()].stopwatch.elapsed(1200);
34 }
35
36 @Override
37 public void init() {
38
39 }
40
41 @Override
42 public void onExecute() {
43 getMob().animate(new Animation(2295));
44 Player player = getMob().getPlayer();
45 player.inventory.remove(item, slot, true);
47 player.send(new SendMessage("You scatter the ashes."));
48
49 cancel();
50 }
51
52 @Override
53 public void onCancel(boolean logout) {
54 getMob().skills.getSkills()[skill()].stopwatch.reset();
55 }
56
57 @Override
58 public Optional<SkillAnimation> animation() {
59 return Optional.empty();
60 }
61
62 @Override
63 public double experience() {
64 double exp = (ashes.getExperience() * Config.PRAYER_MODIFICATION);
65 if (SkillCape.isEquipped(getMob().getPlayer(), SkillCape.PRAYER)) {
66 exp *= 2.0;
67 }
68 return exp;
69 }
70
71 @Override
72 public int skill() {
73 return Skill.PRAYER;
74 }
75
76 @Override
77 public String getName() {
78 return "Ash scatter";
79 }
80
81 @Override
82 public boolean prioritized() {
83 return false;
84 }
85
86 @Override
90}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final double PRAYER_MODIFICATION
The experience modification for prayer.
Definition Config.java:274
SkillAction(Mob mob, Optional< Position > position, int delay, boolean instant)
Creates a new Action randomevent.
Class that models a single animation used by an entity.
T getMob()
Gets the player.
Definition Action.java:44
String getName()
Gets the name of this action.
boolean canInit()
Determines if this action can be initialized.
void onCancel(boolean logout)
A function executed on cancellation.
Optional< SkillAnimation > animation()
The skill animation to execute.
void onExecute()
The method which is called on intervals of the specified #delay;.
double experience()
The experience given from this action.
void init()
Any functionality that should be handled when this action is submitted.
boolean prioritized()
Determines if this action is prioritized.
int skill()
The skill we should hand to experience to.
ScatterAshAction(Player player, AshData ashes, int slot)
WalkablePolicy getWalkablePolicy()
Gets the WalkablePolicy of this action.
synchronized final void cancel()
Cancels all subsequent executions.
Definition Task.java:113
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 PRAYER
The prayer skill id.
Definition Skill.java:36
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 remove(Item item)
Attempts to withdraw item from this container.
final Item get(int index)
Gets the Item located on index.
The OutgoingPacket that sends a message to a Players chatbox in the client.
static boolean isEquipped(Player player, SkillCape cape)
A queue policy determines whether the action can occur while walking.
NON_WALKABLE
This indicates actions cannot occur while walking.