RuneHive-Game
Loading...
Searching...
No Matches
WarriorGuild.java
Go to the documentation of this file.
1package com.runehive.content.activity.impl.warriorguild;
2
3import com.runehive.Config;
4import com.runehive.content.activity.Activity;
5import com.runehive.content.activity.ActivityDeathType;
6import com.runehive.content.activity.ActivityType;
7import com.runehive.content.activity.panel.ActivityPanel;
8import com.runehive.content.collectionlog.CollectionLog;
9import com.runehive.content.collectionlog.CollectionLogData;
10import com.runehive.content.dialogue.impl.KamfreenaDialogue;
11import com.runehive.content.event.impl.ItemOnObjectInteractionEvent;
12import com.runehive.content.event.impl.NpcInteractionEvent;
13import com.runehive.content.event.impl.ObjectInteractionEvent;
14import com.runehive.content.event.impl.PickupItemInteractionEvent;
15import com.runehive.content.skillcape.SkillCape;
16import com.runehive.content.store.Store;
17import com.runehive.game.Animation;
18import com.runehive.game.UpdatePriority;
19import com.runehive.game.task.Task;
20import com.runehive.game.task.impl.WarriorGuildCyclopEvent;
21import com.runehive.game.world.World;
22import com.runehive.game.world.entity.mob.Mob;
23import com.runehive.game.world.entity.mob.data.LockType;
24import com.runehive.game.world.entity.mob.npc.Npc;
25import com.runehive.game.world.entity.mob.npc.NpcDeath;
26import com.runehive.game.world.entity.mob.player.Player;
27import com.runehive.game.world.items.Item;
28import com.runehive.game.world.position.Area;
29import com.runehive.game.world.position.Position;
30import com.runehive.net.packet.out.SendEntityHintArrow;
31import com.runehive.net.packet.out.SendMessage;
32import com.runehive.util.Utility;
33
34import java.util.Optional;
35
36/**
37 * This class handles the warrior's guild activity.
38 *
39 * @author Daniel
40 */
41public class WarriorGuild extends Activity {
42
43 /** The player in the warrior guild activity. */
44 private final Player player;
45
46 /** The animated npc. */
47 private Npc animated;
48
49 /** The warrior guild state for this activity. */
51
52 private Item item;
53
54 /** The warrior guild activity listener for this activity. */
56
57 /** Contructs a new <code>WarriorGuild</code>. */
59 super(3, Mob.DEFAULT_INSTANCE);
60 this.player = player;
61 }
62
63 /** Handes creating a new warrior guild activity for the player. */
65 WarriorGuild minigame = new WarriorGuild(player);
66 minigame.state = WarriorGuildState.ANIMATOR;
67 minigame.add(player);
68 return minigame;
69 }
70
71 /** Handles ending the activity. */
72 public void end() {
73 cleanup();
74 finish();
75 }
76
77 /** Handles summoning the animated npc. */
78 private void summon(int index, AnimatorData animator) {
79 boolean walk_state = player.movement.isRunningToggled();
80
82 animated.owner = player;
83 animated.setVisible(false);
85
86 player.movement.setRunningToggled(false);
88
89 for (int i = 0; i < WarriorGuildUtility.ARMOUR[index].length; i++) {
90 player.inventory.remove(WarriorGuildUtility.ARMOUR[index][i]);
91 }
92
93 World.schedule(new Task(1) {
94 int count = 0;
95
96 @Override
97 protected void execute() {
98 if (count == 0) {
99 player.animate(new Animation(827, UpdatePriority.HIGH));
100 player.send(new SendMessage("You place the armour pieces inside the animator..."));
101 } else if (count == 2) {
102 player.send(new SendMessage("The animator begins to hum, something appears to be working..."));
103 player.walkExactlyTo(animator.walkToPosition);
104 } else if (count == 7) {
105 animated.setVisible(true);
106 animated.animate(4166);
107 animated.speak("I'M ALIVE!");
108 animated.getCombat().attack(player);
109 player.face(animated);
111 player.send(new SendMessage("The animated armour comes to life!"));
112 cancel();
113 }
114 count++;
115 }
116
117 @Override
118 protected void onCancel(boolean logout) {
119 player.blockFace = false;
120 player.locking.unlock();
121 player.movement.reset();
122 player.movement.setRunningToggled(walk_state);
123
124 }
125 });
126 }
127
128 @Override
129 protected void start() {
130
131 }
132
133 @Override
134 public void finish() {
135 remove(player);
137 }
138
139 @Override
140 public void cleanup() {
141 if (animated != null) {
142 remove(animated);
143 }
144 }
145
146 @Override
148 int object = event.getObject().getId();
149 if (object == 16671) {
150 player.move(new Position(2841, 3538, 2));
151 return true;
152 }
153 if (object == 24303) {
154 player.move(new Position(2841, 3538, 0));
155 return true;
156 }
157 if (object == 24306 || object == 24309) {
160 if (!player.inventory.contains(new Item(8851, 25))) {
161 player.dialogueFactory.sendStatement("You need at least 25 warrior guild tokens to enter.").execute();
162 return true;
163 }
164 }
165 player.inventory.remove(new Item(8851, 25));
167 player.move(new Position(player.getX() + 1, player.getY(), 2));
169 } else if (state == WarriorGuildState.CYCLOPS) {
170 player.move(new Position(player.getX() - 2, player.getY(), 2));
172 }
173 return true;
174 }
175 return false;
176 }
177
178 @Override
180 int npc = event.getNpc().id;
181 if (npc == 2461) {
182 player.dialogueFactory.sendDialogue(new KamfreenaDialogue());
183 return true;
184 }
185 if (npc == 2462) {
186 Store.STORES.get("Shanomi's Armour Store").open(player);
187 return true;
188 }
189 return false;
190 }
191
192 @Override
194 if (animated != null) {
195 player.dialogueFactory.sendStatement("You already have an animated armour spawned!").execute();
196 return false;
197 }
198
199 int object = event.getObject().getId();
200
201 if (object != 23955) {
202 return false;
203 }
204
205 Item used = event.getItem();
206 int armourIndex = WarriorGuildUtility.contains(player, used.getId());
207
208 if (armourIndex == -1) {
209 return true;
210 }
211
212 Optional<AnimatorData> animator = AnimatorData.getAnimator(event.getObject().getPosition());
213
214 if (!animator.isPresent()) {
215 return true;
216 }
217
218 if (!player.getPosition().equals(animator.get().standPosition)) {
219 player.dialogueFactory.sendStatement("Please stand in front of the animator!").execute();
220 return true;
221 }
222
223 summon(armourIndex, animator.get());
224 return true;
225 }
226
227 @Override
229 if (WarriorGuildUtility.getDefender(player) == event.getItem().getId()) {
230 player.pickup(event.getItem(), event.getPosition());
232 return true;
233 }
234 return false;
235 }
236
237 @Override
238 public void onLogout(Player player) {
240 player.move(new Position(2846, 3540, 2));
241 cleanup();
242 finish();
243 }
244
245 @Override
247 if (!Area.inWarriorGuild(player)) {
248 if (animated != null) {
249 player.send(new SendMessage("The animated armour vanishes as you have leave the region, taking your armour"));
250 player.send(new SendMessage("with him."));
251 }
252 cleanup();
253 finish();
254 }
255 }
256
257 @Override
258 public void onDeath(Mob mob) {
259 if (mob.isNpc()) {
260 World.schedule(new NpcDeath(mob.getNpc()));
261 player.send(new SendEntityHintArrow(player, true));
262 animated = null;
263 return;
264 }
265 remove(mob);
267 end();
268 }
269
270 @Override
271 public void update() {
273 return;
276 int progress = (int) Utility.getPercentageAmount(current + 1, 8);
277 Item defender = new Item(WarriorGuildUtility.getDefender(player), 1);
278 ActivityPanel.update(player, progress, "Warrior Guild", defender, "Cyclops will be dropping:", "<col=FF5500>" + defender.getName(), "Chance: <col=FF5500>1/20</col>");
279 }
280 }
281
282 @Override
283 public boolean canTeleport(Player player) {
284 return true;
285 }
286
287 @Override
288 public void sequence() {
289 }
290
291 @Override
295
296 @Override
297 protected Optional<WarriorGuildActivityListener> getListener() {
298 return Optional.of(listener);
299 }
300
301 @Override
304 }
305}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final Position DEFAULT_POSITION
The default, i.e.
Definition Config.java:197
Activity(int cooldown, int instance)
Constructs a new SequencedMinigame object.
Definition Activity.java:55
void add(Mob mob)
Adds a mob to the activity.
final WarriorGuildActivityListener listener
The warrior guild activity listener for this activity.
WarriorGuild(Player player)
Contructs a new WarriorGuild.
static WarriorGuild create(Player player)
Handes creating a new warrior guild activity for the player.
void onLogout(Player player)
Called when the player logs out.
boolean useItem(Player player, ItemOnObjectInteractionEvent event)
final Player player
The player in the warrior guild activity.
boolean clickNpc(Player player, NpcInteractionEvent event)
void summon(int index, AnimatorData animator)
Handles summoning the animated npc.
void cleanup()
Cleans up the activity when finished.
boolean clickObject(Player player, ObjectInteractionEvent event)
WarriorGuildState state
The warrior guild state for this activity.
Optional< WarriorGuildActivityListener > getListener()
Gets an Optional of the ActivityListener for this activity.
boolean canTeleport(Player player)
Called when the player attempts to teleport.
boolean pickupItem(Player player, PickupItemInteractionEvent event)
void onRegionChange(Player player)
Called when the player changes region.
This class handles util methods for the Warrior's activity.
static final int[] ANIMATED
The warrior guild animated npcs.
static int getDefender(Player player)
Gets the defender index to drop for the player.
static int contains(Player player, int itemId)
Checks if the player has a complete armour set to activate the animator.
static int getDefenderIndex(Player player)
Gets the defender tier index.
static final int[][] ARMOUR
The warrior guild animator armour data .
static void update(Player player, int amount, String title, String footer, String... strings)
Sends all the information for the activity panel.
static void clear(Player player)
Clears the activity panel.
static void logItem(Player player, CollectionLogData data, int item, int amount)
The class which holds support for further abstraction for shops.
Definition Store.java:20
static Map< String, Store > STORES
A mapping of each shop by it's name.
Definition Store.java:23
Class that models a single animation used by an entity.
A game representing a cyclic unit of work.
Definition Task.java:11
An randomevent which handles the warrior guild cyclops randomevent.
Represents the game world.
Definition World.java:46
static void schedule(Task task)
Submits a new event.
Definition World.java:247
Handles the mob class.
Definition Mob.java:66
void move(Position position)
Moves the mob to a set position.
Definition Mob.java:340
final boolean isNpc()
Check if an entity is an npc.
Definition Mob.java:550
Represents a non-player character in the in-game world.
Definition Npc.java:29
This class represents a character controlled by a player.
Definition Player.java:125
The container class that represents an item that can be interacted with.
Definition Item.java:21
final int getId()
Gets the identification of this item.
Definition Item.java:324
Handles checking if mobs are in a certain area.
Definition Area.java:13
static boolean inWarriorGuild(Interactable entity)
Definition Area.java:136
Represents a single tile on the game world.
Definition Position.java:14
The OutgoingPacket that sends a message to a Players chatbox in the client.
Handles miscellaneous methods.
Definition Utility.java:27
static double getPercentageAmount(int progress, int total)
Gets a percentage amount.
Definition Utility.java:36
Holds all activity types that are timed.
final Position walkToPosition
The animator walk to position.
final Position objectPosition
The animator object position.
static Optional< AnimatorData > getAnimator(Position position)
Gets the animator data based on the object position.
static boolean isEquipped(Player player, SkillCape cape)
Represents different priorities for updating.