RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
Inferno.java
1package com.osroyale.content.activity.inferno;
2
3import com.osroyale.content.ActivityLog;
4import com.osroyale.content.activity.Activity;
5import com.osroyale.content.activity.ActivityListener;
6import com.osroyale.content.activity.ActivityType;
7import com.osroyale.content.activity.panel.ActivityPanel;
8import com.osroyale.content.pet.PetData;
9import com.osroyale.content.pet.Pets;
10import com.osroyale.game.Animation;
11import com.osroyale.game.Graphic;
12import com.osroyale.game.world.entity.mob.Mob;
13import com.osroyale.game.world.entity.mob.npc.Npc;
14import com.osroyale.game.world.entity.mob.player.Player;
15import com.osroyale.game.world.items.Item;
16import com.osroyale.game.world.position.Area;
17import com.osroyale.game.world.position.Position;
18import com.osroyale.net.packet.out.SendMessage;
19import com.osroyale.util.RandomUtils;
20import com.osroyale.util.Utility;
21
22import java.util.HashSet;
23import java.util.Optional;
24import java.util.Set;
25
62
63public class Inferno extends Activity {
64
66 private final Player player;
67
69 private boolean completed;
70
72 private long time;
73
75 private int rewards;
76
78 public final Set<Npc> npcs = new HashSet<>();
79
81 private InfernoWaveData.WaveData wave = InfernoWaveData.WaveData.WAVE_1;
82
84 private final InfernoCavesListener listener = new InfernoCavesListener(this);
85
90 private Inferno(Player player, int instance) {
91 super(10, instance);
92 this.player = player;
93 }
94
95 public static Inferno create(Player player) {
96 Inferno minigame = new Inferno(player, player.playerAssistant.instance());
97 player.move(new Position(2273, 5341, player.getHeight()));
98 ActivityPanel.update(player, -1, "Inferno", "Activity Completion:", "Good Luck, " + player.getName() + "!");
99 player.dialogueFactory.sendNpcChat(5567, "Welcome to the Inferno, #name.",
100 "There are a total of 69 waves, TzKal-Zuk being the last.",
101 "Use your activity panel (bottom left tab) for wave information.", "Good luck!").execute();
102 minigame.time = System.currentTimeMillis();
103 minigame.add(player);
104 minigame.resetCooldown();
105 return minigame;
106 }
107
109 void handleDeath(Mob dead) {
110 if (dead.isPlayer() && dead.equals(player)) {
111 finish();
112 return;
113 }
114 if (dead.isNpc() && npcs.contains(dead)) {
115 if (dead.id == 3162) {
116 remove(dead);
117 npcs.remove(dead);
118 for (int index = 0; index < 2; index++) {
119 Position position = new Position(dead.getX() + (index == 0 ? -1 : +1), dead.getY(),
120 dead.getHeight());
121 Npc roc = new Npc(763, position);
122 add(roc);
123 npcs.add(roc);
124 roc.getCombat().attack(player);
125 dead.animate(Animation.RESET, true);
126 dead.graphic(Graphic.RESET, true);
127 }
128 return;
129 }
130
131 npcs.remove(dead);
132 remove(dead);
133 rewards += Utility.random(250, 1000);
134 if (npcs.isEmpty()) {
135 wave = InfernoWaveData.WaveData.getNext(wave.ordinal());
136 if (wave == null) {
137 completed = true;
138 player.send(new SendMessage("You have finished the activity!"));
139 } else {
140 player.send(new SendMessage("The next wave will commence soon."));
141 }
143 return;
144 }
145 }
146 }
147
148 @Override
149 protected void start() {
150 if (wave == null) {
151 finish();
152 return;
153 }
154 if (player.locking.locked()) {
155 return;
156 }
157
158 Position spawn = new Position(2273, 5337, player.getHeight());
159 Position[] boundaries = Utility.getInnerBoundaries(spawn, Utility.random(1, 8), Utility.random(1, 8));
160
161 for (int id : wave.getMonster()) {
162 Npc npc = new Npc(id, RandomUtils.random(boundaries));
163 npc.owner = player;
164 add(npc);
165 npcs.add(npc);
166 npc.getCombat().attack(player);
167 npc.face(player);
168 npc.attack(player);
169 player.face(npc.getPosition());
170 npc.locking.unlock();
171 // pause();
172
173 }
174 if (wave == InfernoWaveData.WaveData.WAVE_69) {
175 player.message("WAVE 69 is here!!");
176 }
177 pause();
178 }
179
180 public static void finalWave() {
181 final int BOSS_ID;
182 InfernoWaveData.WaveData wavee = InfernoWaveData.WaveData.WAVE_69;
183 }
184
185 @Override
186 public void finish() {
187 cleanup();
188 remove(player);
189 player.move(new Position(3086, 3501, 0));
190
191 if (completed) {
192 player.dialogueFactory.sendNpcChat(5567, "You have defeated Inferno, I am most impressed!",
193 "Please accept this gift, young thug.").execute();
194 rewards += 10000;
195 player.inventory.addOrDrop(new Item(7775, rewards));
196 player.message("<img=9>You now have @red@" + rewards + " Inferno Tickets!");
197 if (Utility.random(1, 3) == 3) {
198 player.inventory.addOrDrop(new Item(20211));
199 }
200 player.inventory.addOrDrop(new Item(290));
201 Pets.onReward(player, PetData.PIRATE_PETE);
202 player.send(new SendMessage(
203 "You have completed the Inferno activity. Final time: @red@" + Utility.getTime(time) + "</col>."));
204 player.activityLogger.add(ActivityLog.INFERNO);
205 return;
206 }
207
208 if (rewards <= 0)
209 rewards = 1;
210 player.inventory.addOrDrop(new Item(7775, rewards));
211 player.message("<img=9>You now have @red@" + rewards + " Inferno Tickets!");
212 player.dialogueFactory.sendNpcChat(5567, "Better luck next time!", "Take these points as a reward.").execute();
213 }
214
215 @Override
216 public void cleanup() {
217 ActivityPanel.clear(player);
218 if (!npcs.isEmpty())
219 npcs.forEach(this::remove);
220 }
221
222 @Override
223 public void update() {
224 if (wave == null) {
225 ActivityPanel.update(player, 100, "Inferno", new Item(21295), "Congratulations, you have",
226 "completed the Inferno", "activity!");
227 return;
228 }
229 int progress = (int) Utility.getPercentageAmount(wave.ordinal() + 1, InfernoWaveData.WaveData.values().length);
230 if (progress >= 100 && !completed)
231 progress = 99;
232 ActivityPanel.update(player, progress, "Inferno", new Item(22325),
233 "</col>Wave: <col=FF5500>" + (wave.ordinal() + 1) + "/" + (InfernoWaveData.WaveData.values().length),
234 "</col>Monsters Left: <col=FF5500>" + npcs.size(),
235 "</col>Points Gained: <col=FF5500>" + Utility.formatDigits(rewards),
236 "</col>Time: <col=FF5500>" + Utility.getTime());
237 }
238
239 @Override
240 public boolean canTeleport(Player player) {
241 return true;
242 }
243
244 @Override
245 public void onRegionChange(Player player) {
246 if (!Area.inInferno(player)) {
247 cleanup();
248 remove(player);
249 player.send(new SendMessage("You have lost your current progress as you have teleported."));
250 }
251 }
252
253 @Override
254 public void onLogout(Player player) {
255 finish();
256 remove(player);
257 }
258
259 @Override
260 public ActivityType getType() {
261 return ActivityType.INFERNO;
262 }
263
264 @Override
265 public Optional<? extends ActivityListener<? extends Activity>> getListener() {
266 return Optional.of(listener);
267 }
268}
Activity(int cooldown, int instance)
Definition Activity.java:92
Optional<? extends ActivityListener<? extends Activity > > getListener()
Definition Inferno.java:265
static void update(Player player, int amount, String title, String footer, String... strings)
final DialogueFactory sendNpcChat(int id, String... lines)
static void onReward(Player player, int item, int chance)
Definition Pets.java:70
void move(Position position)
Definition Mob.java:377
void face(GameObject object)
Definition Mob.java:326
static String formatDigits(final int amount)
Definition Utility.java:78
static String getTime()
Definition Utility.java:178
static double getPercentageAmount(int progress, int total)
Definition Utility.java:73