RuneHive-Game
Loading...
Searching...
No Matches
VorkathActivity.java
Go to the documentation of this file.
1package com.runehive.content.activity.impl;
2
3import com.runehive.content.ActivityLog;
4import com.runehive.content.achievement.AchievementHandler;
5import com.runehive.content.achievement.AchievementKey;
6import com.runehive.content.activity.Activity;
7import com.runehive.content.activity.ActivityDeathType;
8import com.runehive.content.activity.ActivityType;
9import com.runehive.content.event.impl.NpcInteractionEvent;
10import com.runehive.game.world.World;
11import com.runehive.game.world.entity.mob.Mob;
12import com.runehive.game.world.entity.mob.npc.Npc;
13import com.runehive.game.world.entity.mob.npc.NpcDeath;
14import com.runehive.game.world.entity.mob.player.Player;
15import com.runehive.game.world.position.Area;
16import com.runehive.game.world.position.Position;
17import com.runehive.util.Utility;
18
19/**
20 * The activity for Vorkath.
21 *
22 * @author Daniel.
23 */
24public class VorkathActivity extends Activity {
25
26 /** The player instance for the activity. */
27 private final Player player;
28
29 /** The Vorkath npc instance. */
30 private Npc vorkath = new Npc(8059, new Position(2269, 4062));
31
32 /** Flag if Vorkath has been summoned. */
33 private boolean summoned;
34
35 /** Constructs a new <code>VorkathActivity</code>. */
37 super(1, instance);
38 this.player = player;
39 }
40
41 /** Creates a new Vorkath activity for the player. */
43 VorkathActivity activity = new VorkathActivity(player, player.playerAssistant.instance());
44 activity.pause();
45 activity.add(player);
46 activity.add(activity.vorkath);
47 activity.vorkath.blockInteract = true;
48 activity.vorkath.blockFace = true;
49 activity.vorkath.locking.lock();
50 return activity;
51 }
52
53 @Override
54 protected void start() {
55 }
56
57 @Override
58 public void finish() {
59 boolean successfull = vorkath.isDead();
60
61 cleanup();
62 remove(player);
63
64 if (successfull) {
65 player.activityLogger.add(ActivityLog.VORKATH);
67 player.message("Congratulations, you have killed the Vorkath. Fight duration: @red@" + Utility.getTime(player.gameRecord.end(ActivityType.VORKATH)) + "</col>.");
68
69
70 restart(10, () -> {
71 if (Area.inVorkath(player)) {
73 } else {
74 remove(player);
75 }
76 });
77 }
78 }
79
80 @Override
81 public void cleanup() {
82 remove(vorkath);
83 }
84
85 @Override
87 if (event.getOpcode() == 0 && event.getNpc().id == 8059 && !summoned) {
88 summoned = true;
89 player.animate(827);
90 vorkath.animate(7950);
91
92 World.schedule(7, () -> {
93 vorkath.transform(8060, true);
94 World.schedule(1, () -> {
95 vorkath.face(player);
96 vorkath.blockInteract = false;
97 vorkath.blockFace = false;
98 vorkath.locking.unlock();
99 player.gameRecord.start();
100 });
101
102 });
103 return true;
104 }
105 return false;
106 }
107
108 @Override
109 public void onLogout(Player player) {
110 cleanup();
111 remove(player);
112 }
113
114 @Override
115 public void onDeath(Mob mob) {
116 if (mob.isNpc() && mob.getNpc().equals(vorkath)) {
117 World.schedule(new NpcDeath(mob.getNpc(), this::finish));
118 return;
119 }
120
121 super.onDeath(mob);
122 }
123
124 @Override
126 if (!Area.inVorkath(player)) {
127 cleanup();
128 remove(player);
129 }
130 }
131
132 @Override
136
137 @Override
138 public boolean canTeleport(Player player) {
139 return true;
140 }
141
142 @Override
144 return ActivityType.VORKATH;
145 }
146}
static void activate(Player player, AchievementKey achievement)
Activates the achievement for the individual player.
Activity(int cooldown, int instance)
Constructs a new SequencedMinigame object.
Definition Activity.java:55
int instance
The activity instance level.
Definition Activity.java:46
void restart(int delay, Runnable runnable)
final Player player
The player instance for the activity.
static VorkathActivity create(Player player)
Creates a new Vorkath activity for the player.
void onDeath(Mob mob)
Called when the player die.
boolean canTeleport(Player player)
Called when the player attempts to teleport.
void onRegionChange(Player player)
Called when the player changes region.
boolean summoned
Flag if Vorkath has been summoned.
void onLogout(Player player)
Called when the player logs out.
void cleanup()
Cleans up the activity when finished.
boolean clickNpc(Player player, NpcInteractionEvent event)
void start()
Starts the next activity stage.
VorkathActivity(Player player, int instance)
Constructs a new VorkathActivity.
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
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
Handles checking if mobs are in a certain area.
Definition Area.java:13
static boolean inVorkath(Interactable entity)
Definition Area.java:183
Represents a single tile on the game world.
Definition Position.java:14
Handles miscellaneous methods.
Definition Utility.java:27
static String getTime()
Gets the current server time and formats it.
Definition Utility.java:141
The activity log class.
Holds all activity types that are timed.