RuneHive-Game
Loading...
Searching...
No Matches
Inferno.java
Go to the documentation of this file.
1package com.runehive.content.activity.inferno;
2
3import com.runehive.content.ActivityLog;
4import com.runehive.content.activity.Activity;
5import com.runehive.content.activity.ActivityListener;
6import com.runehive.content.activity.ActivityType;
7import com.runehive.content.activity.panel.ActivityPanel;
8import com.runehive.content.pet.PetData;
9import com.runehive.content.pet.Pets;
10import com.runehive.game.Animation;
11import com.runehive.game.Graphic;
12import com.runehive.game.world.entity.mob.Mob;
13import com.runehive.game.world.entity.mob.npc.Npc;
14import com.runehive.game.world.entity.mob.player.Player;
15import com.runehive.game.world.items.Item;
16import com.runehive.game.world.position.Area;
17import com.runehive.game.world.position.Position;
18import com.runehive.net.packet.out.SendMessage;
19import com.runehive.util.RandomUtils;
20import com.runehive.util.Utility;
21
22import java.util.HashSet;
23import java.util.Optional;
24import java.util.Set;
25
26public class Inferno extends Activity {
27
28 /** The player in the Inferno */
29 private final Player player;
30
31 /** The activity completed flag. */
32 private boolean completed;
33
34 /** The time it took to complete the activity. */
35 private long time;
36
37 /** The amount of rewards the player has acquired. */
38 private int rewards;
39
40 /** A set of npcs in this activity. */
41 public final Set<Npc> npcs = new HashSet<>();
42
43 /** The current wave of this activity. */
45
46 /** The combat listener to add for all mobs. */
48
49 /**
50 * Constructs a new {@code Inferno} object for a {@code player} and an
51 * {@code instance}.
52 */
53 private Inferno(Player player, int instance) {
54 super(10, instance);
55 this.player = player;
56 }
57
58 public static Inferno create(Player player) {
59 Inferno minigame = new Inferno(player, player.playerAssistant.instance());
60 player.move(new Position(2273, 5341, player.getHeight()));
61 ActivityPanel.update(player, -1, "Inferno", "Activity Completion:", "Good Luck, " + player.getName() + "!");
62 player.dialogueFactory.sendNpcChat(5567, "Welcome to the Inferno, #name.",
63 "There are a total of 69 waves, TzKal-Zuk being the last.",
64 "Use your activity panel (bottom left tab) for wave information.", "Good luck!").execute();
65 minigame.time = System.currentTimeMillis();
66 minigame.add(player);
67 minigame.resetCooldown();
68 return minigame;
69 }
70
71 /** Handles what happens to a mob when they die in the activity. */
72 void handleDeath(Mob dead) {
73 if (dead.isPlayer() && dead.equals(player)) {
74 finish();
75 return;
76 }
77 if (dead.isNpc() && npcs.contains(dead)) {
78 if (dead.id == 3162) {
79 remove(dead);
80 npcs.remove(dead);
81 for (int index = 0; index < 2; index++) {
82 Position position = new Position(dead.getX() + (index == 0 ? -1 : +1), dead.getY(),
83 dead.getHeight());
84 Npc roc = new Npc(763, position);
85 add(roc);
86 npcs.add(roc);
87 roc.getCombat().attack(player);
88 dead.animate(Animation.RESET, true);
89 dead.graphic(Graphic.RESET, true);
90 }
91 return;
92 }
93
94 npcs.remove(dead);
95 remove(dead);
96 rewards += Utility.random(250, 1000);
97 if (npcs.isEmpty()) {
99 if (wave == null) {
100 completed = true;
101 player.send(new SendMessage("You have finished the activity!"));
102 } else {
103 player.send(new SendMessage("The next wave will commence soon."));
104 }
106 return;
107 }
108 }
109 }
110
111 @Override
112 protected void start() {
113 if (wave == null) {
114 finish();
115 return;
116 }
117 if (player.locking.locked()) {
118 return;
119 }
120
121 Position spawn = new Position(2273, 5337, player.getHeight());
122 Position[] boundaries = Utility.getInnerBoundaries(spawn, Utility.random(1, 8), Utility.random(1, 8));
123
124 for (int id : wave.getMonster()) {
125 Npc npc = new Npc(id, RandomUtils.random(boundaries));
126 npc.owner = player;
127 add(npc);
128 npcs.add(npc);
129 npc.getCombat().attack(player);
130 npc.face(player);
131 npc.attack(player);
132 player.face(npc.getPosition());
133 npc.locking.unlock();
134 // pause();
135
136 }
138 player.message("WAVE 69 is here!!");
139 }
140 pause();
141 }
142
143 public static void finalWave() {
144 final int BOSS_ID;
146 }
147
148 @Override
149 public void finish() {
150 cleanup();
151 remove(player);
152 player.move(new Position(3086, 3501, 0));
153
154 if (completed) {
155 player.dialogueFactory.sendNpcChat(5567, "You have defeated Inferno, I am most impressed!",
156 "Please accept this gift, young thug.").execute();
157 rewards += 10000;
158 player.inventory.addOrDrop(new Item(7775, rewards));
159 player.message("<img=9>You now have @red@" + rewards + " Inferno Tickets!");
160 if (Utility.random(1, 3) == 3) {
161 player.inventory.addOrDrop(new Item(20211));
162 }
163 player.inventory.addOrDrop(new Item(290));
165 player.send(new SendMessage(
166 "You have completed the Inferno activity. Final time: @red@" + Utility.getTime(time) + "</col>."));
167 player.activityLogger.add(ActivityLog.INFERNO);
168 return;
169 }
170
171 if (rewards <= 0)
172 rewards = 1;
173 player.inventory.addOrDrop(new Item(7775, rewards));
174 player.message("<img=9>You now have @red@" + rewards + " Inferno Tickets!");
175 player.dialogueFactory.sendNpcChat(5567, "Better luck next time!", "Take these points as a reward.").execute();
176 }
177
178 @Override
179 public void cleanup() {
181 if (!npcs.isEmpty())
182 npcs.forEach(this::remove);
183 }
184
185 @Override
186 public void update() {
187 if (wave == null) {
188 ActivityPanel.update(player, 100, "Inferno", new Item(21295), "Congratulations, you have",
189 "completed the Inferno", "activity!");
190 return;
191 }
192 int progress = (int) Utility.getPercentageAmount(wave.ordinal() + 1, InfernoWaveData.WaveData.values().length);
193 if (progress >= 100 && !completed)
194 progress = 99;
195 ActivityPanel.update(player, progress, "Inferno", new Item(22325),
196 "</col>Wave: <col=FF5500>" + (wave.ordinal() + 1) + "/" + (InfernoWaveData.WaveData.values().length),
197 "</col>Monsters Left: <col=FF5500>" + npcs.size(),
198 "</col>Points Gained: <col=FF5500>" + Utility.formatDigits(rewards),
199 "</col>Time: <col=FF5500>" + Utility.getTime());
200 }
201
202 @Override
203 public boolean canTeleport(Player player) {
204 return true;
205 }
206
207 @Override
209 if (!Area.inInferno(player)) {
210 cleanup();
211 remove(player);
212 player.send(new SendMessage("You have lost your current progress as you have teleported."));
213 }
214 }
215
216 @Override
217 public void onLogout(Player player) {
218 finish();
219 remove(player);
220 }
221
222 @Override
224 return ActivityType.INFERNO;
225 }
226
227 @Override
228 public Optional<? extends ActivityListener<? extends Activity>> getListener() {
229 return Optional.of(listener);
230 }
231}
Activity(int cooldown, int instance)
Constructs a new SequencedMinigame object.
Definition Activity.java:55
final void resetCooldown()
Resets the remaining ticks to the cached cooldown ticks.
int instance
The activity instance level.
Definition Activity.java:46
final void pause()
Sets the cooldown flag to PAUSE.
void add(Mob mob)
Adds a mob to the activity.
Inferno(Player player, int instance)
Constructs a new Inferno object for a player and an instance.
Definition Inferno.java:53
final InfernoCavesListener listener
The combat listener to add for all mobs.
Definition Inferno.java:47
void onRegionChange(Player player)
Called when the player changes region.
Definition Inferno.java:208
void cleanup()
Cleans up the activity when finished.
Definition Inferno.java:179
final Set< Npc > npcs
A set of npcs in this activity.
Definition Inferno.java:41
int rewards
The amount of rewards the player has acquired.
Definition Inferno.java:38
final Player player
The player in the Inferno.
Definition Inferno.java:29
void start()
Starts the next activity stage.
Definition Inferno.java:112
void finish()
Finishes the activity.
Definition Inferno.java:149
boolean completed
The activity completed flag.
Definition Inferno.java:32
InfernoWaveData.WaveData wave
The current wave of this activity.
Definition Inferno.java:44
static Inferno create(Player player)
Definition Inferno.java:58
void onLogout(Player player)
Called when the player logs out.
Definition Inferno.java:217
void handleDeath(Mob dead)
Handles what happens to a mob when they die in the activity.
Definition Inferno.java:72
long time
The time it took to complete the activity.
Definition Inferno.java:35
Optional<? extends ActivityListener<? extends Activity > > getListener()
Gets an Optional of the ActivityListener for this activity.
Definition Inferno.java:228
boolean canTeleport(Player player)
Called when the player attempts to teleport.
Definition Inferno.java:203
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.
Handles spawning, rewarding and picking up of pets.
Definition Pets.java:27
static void onReward(Player player, int item, int chance)
Handles calculating the chance of a player receiving a skilling pet.
Definition Pets.java:33
Class that models a single animation used by an entity.
static final Animation RESET
Represents a single graphic that can be used by entities.
Definition Graphic.java:10
static final Graphic RESET
Definition Graphic.java:17
abstract boolean equals(Object obj)
Handles the mob class.
Definition Mob.java:66
void face(GameObject object)
Sets the client update flag to face a certain direction.
Definition Mob.java:289
final boolean isNpc()
Check if an entity is an npc.
Definition Mob.java:550
final boolean isPlayer()
Check if an entity is a player.
Definition Mob.java:564
Optional< Graphic > graphic
Definition Mob.java:91
Represents a non-player character in the in-game world.
Definition Npc.java:29
Combat< Npc > getCombat()
The combat of the mob.
Definition Npc.java:156
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
Handles checking if mobs are in a certain area.
Definition Area.java:13
static boolean inInferno(Entity entity)
Definition Area.java:245
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.
A static-util class that provides additional functionality for generating pseudo-random numbers.
static< T > T random(T[] array)
Pseudo-randomly retrieves a element from array.
Handles miscellaneous methods.
Definition Utility.java:27
static int random(int bound)
Definition Utility.java:239
static String formatDigits(final int amount)
Formats digits for integers.
Definition Utility.java:41
static double getPercentageAmount(int progress, int total)
Gets a percentage amount.
Definition Utility.java:36
static Position[] getInnerBoundaries(Position position, int width, int length)
Definition Utility.java:621
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.
Holds the data for pets.
Definition PetData.java:14