RuneHive-Game
Loading...
Searching...
No Matches
PuroPuroAction.java
Go to the documentation of this file.
1package com.runehive.content.skill.impl.hunter.net;
2
3import com.runehive.game.action.Action;
4import com.runehive.game.action.policy.WalkablePolicy;
5import com.runehive.game.world.entity.mob.player.Player;
6import com.runehive.game.world.object.GameObject;
7
8public class PuroPuroAction extends Action<Player> {
9 private final GameObject object;
10 private boolean run = false;
11 private int walkAnimation;
12
13 public PuroPuroAction(Player player, GameObject object) {
14 super(player, 3, false);
15 this.object = object;
16 }
17
18 @Override
19 protected void onSchedule() {
20 run = getMob().movement.isRunningToggled();
21 walkAnimation = getMob().mobAnimation.getWalk();
22 getMob().mobAnimation.setWalk(6594);
23
24 getMob().locking.lock();
25 getMob().movement.setRunningToggled(false);
26 getMob().message("You use your strength to push through the wheat.");
27
28 int dx = 0;
29 int dy = 0;
30
31 if (getMob().getX() > object.getX()) {
32 dx = -2;
33 } else if (getMob().getX() < object.getX()) {
34 dx = 2;
35 }
36
37 if (getMob().getY() > object.getY()) {
38 dy = -2;
39 } else if (getMob().getY() < object.getY()) {
40 dy = 2;
41 }
42
43 getMob().walk(getMob().getPosition().transform(dx, dy), true);
44 }
45
46 @Override
47 protected void execute() {
48 cancel();
49 }
50
51 @Override
52 protected void onCancel(boolean logout) {
53 getMob().locking.unlock();
54 getMob().mobAnimation.setWalk(walkAnimation);
55 getMob().movement.setRunningToggled(run);
56 }
57
58 @Override
62
63 @Override
64 public String getName() {
65 return "puro-puro-action";
66 }
67}
WalkablePolicy getWalkablePolicy()
Gets the WalkablePolicy of this action.
void onSchedule()
A function executed on registration.
void onCancel(boolean logout)
A function executed on cancellation.
void execute()
A function representing the unit of work that will be carried out.
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
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
A queue policy determines whether the action can occur while walking.
NON_WALKABLE
This indicates actions cannot occur while walking.