RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
LadderAction.java
1package com.osroyale.game.action.impl;
2
3import com.osroyale.game.Animation;
4import com.osroyale.game.UpdatePriority;
5import com.osroyale.game.action.Action;
6import com.osroyale.game.action.policy.WalkablePolicy;
7import com.osroyale.game.world.entity.mob.player.Player;
8import com.osroyale.game.world.object.GameObject;
9import com.osroyale.game.world.position.Position;
10import com.osroyale.net.packet.out.SendMessage;
11import com.osroyale.util.MessageColor;
12
13import java.util.function.Predicate;
14
18public class LadderAction extends Action<Player> {
19 private int count;
20 private final GameObject ladder;
21 private final Position position;
22 private final Predicate<Player> condition;
23 private final String message;
24
25 public LadderAction(Player mob, GameObject ladder, Position position) {
26 this(mob, ladder, position, null, null);
27 }
28
29 public LadderAction(Player mob, GameObject ladder, Position position, Predicate<Player> condition, String message) {
30 super(mob, 1, false);
31 this.ladder = ladder;
32 this.position = position;
33 this.condition = condition;
34 this.message = message;
35 }
36
37 @Override
38 protected boolean canSchedule() {
39 if (condition != null && !condition.test(getMob())) {
40 getMob().send(new SendMessage(message, MessageColor.RED));
41 return false;
42 }
43 return true;
44 }
45
46 @Override
47 protected void onSchedule() {
48 getMob().locking.lock();
49 getMob().face(ladder.getPosition());
50 getMob().getCombat().reset();
51 getMob().damageImmunity.reset(3_000);
52 }
53
54 @Override
55 public void execute() {
56 if (count == 0) {
57 getMob().animate(new Animation(828, UpdatePriority.VERY_HIGH));
58 } else if (count == 1) {
59 getMob().move(position);
60 cancel();
61 }
62 count++;
63 }
64
65 @Override
66 protected void onCancel(boolean logout) {
67 }
68
69 @Override
73
74 @Override
75 public String getName() {
76 return "Ladder action";
77 }
78
79 @Override
80 public boolean prioritized() {
81 return false;
82 }
83}
Action(T mob, int delay, boolean instant)
Definition Action.java:24
synchronized final void cancel()
Definition Task.java:147