RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
ChestAction.java
1package com.osroyale.game.action.impl;
2
3import com.osroyale.content.ActivityLog;
4import com.osroyale.game.world.items.Item;
5import com.osroyale.net.packet.out.SendMessage;
6import com.osroyale.game.Animation;
7import com.osroyale.game.action.Action;
8import com.osroyale.game.action.policy.WalkablePolicy;
9import com.osroyale.game.world.entity.mob.player.Player;
10import com.osroyale.content.achievement.AchievementHandler;
11import com.osroyale.content.achievement.AchievementKey;
12
18public final class ChestAction extends Action<Player> {
19 private final int key;
20 private final Item[] items;
21
22 public ChestAction(Player player, int key, Item... items) {
23 super(player, 1);
24 this.key = key;
25 this.items = items;
26 }
27
28 @Override
29 protected boolean canSchedule() {
30 if (!getMob().inventory.hasCapacityFor(items)) {
31 getMob().message("You do not have enough free inventory spaces to do this!");
32 return false;
33 }
34 return true;
35 }
36
37 @Override
38 protected void onSchedule() {
39 getMob().locking.lock(2);
40 getMob().inventory.remove(key, 1);
41 getMob().animate(new Animation(881));
42 getMob().send(new SendMessage("You attempt to unlock the chest..."));
43 }
44
45 @Override
46 public void execute() {
47 cancel();
48 }
49
50 @Override
51 protected void onCancel(boolean logout) {
52 getMob().inventory.addOrDrop(items);
53 getMob().send(new SendMessage("...you find a few items inside of the chest.", true));
54
55 if (key == 989) {
56 getMob().activityLogger.add(ActivityLog.CRYSTAL_CHEST);
58 } else if (key == 20608) {
59 getMob().activityLogger.add(ActivityLog.BLOOD_MONEY_CHEST);
60 }
61 }
62
63 @Override
64 public String getName() {
65 return "chest action";
66 }
67
68 @Override
69 public boolean prioritized() {
70 return false;
71 }
72
73 @Override
77}
static void activate(Player player, AchievementKey achievement)
Action(T mob, int delay, boolean instant)
Definition Action.java:24
synchronized final void cancel()
Definition Task.java:147