RuneHive-Game
Loading...
Searching...
No Matches
Wintertodt.java
Go to the documentation of this file.
1package com.runehive.content.wintertodt;
2
3import com.runehive.Config;
4import com.runehive.content.collectionlog.CollectionLog;
5import com.runehive.content.collectionlog.CollectionLogData;
6import com.runehive.content.skill.impl.woodcutting.AxeData;
7import com.runehive.content.wintertodt.actions.*;
8import com.runehive.game.task.Task;
9import com.runehive.game.world.World;
10import com.runehive.game.world.entity.combat.hit.Hit;
11import com.runehive.game.world.entity.mob.Direction;
12import com.runehive.game.world.entity.mob.UpdateFlag;
13import com.runehive.game.world.entity.mob.npc.Npc;
14import com.runehive.game.world.entity.mob.player.Player;
15import com.runehive.game.world.entity.skill.Skill;
16import com.runehive.game.world.items.Item;
17import com.runehive.game.world.object.CustomGameObject;
18import com.runehive.game.world.object.GameObject;
19import com.runehive.game.world.position.Position;
20import com.runehive.game.world.region.Region;
21import com.runehive.net.packet.out.SendConfig;
22import com.runehive.net.packet.out.SendRemoveObject;
23import com.runehive.net.packet.out.SendString;
24import com.runehive.util.Utility;
25
26import java.util.ArrayList;
27import java.util.Arrays;
28import java.util.List;
29import java.util.stream.Collectors;
30
31public class Wintertodt {
32
33 private static final int DEFAULT_DELAY = 10;
34
35 /**
36 * Region of the wintertodt game
37 */
38 public static final int REGION_ID = 6462;
39
40 /**
41 * Game data
42 */
43 private static boolean started = false;
44 public static final int MAX_HP = 3500;
45 public static int health = 0;
46 private static int startDelay = DEFAULT_DELAY;
47 private static int pyroSpeechDelay;
48 public static Region region;
49
50 /**
51 * Item ids
52 */
53 public static final int BRUMA_ROOT = 20695;
54 public static final int BRUMA_KINDLING = 20696;
55 public static final int REJUV_POT_UNF = 20697;
56 public static final int REJUV_POT_4 = 20699;
57 public static final int REJUV_POT_3 = 20700;
58 public static final int REJUV_POT_2 = 20701;
59 public static final int REJUV_POT_1 = 20702;
60 public static final int BRUMA_HERB = 20698;
61
62 /**
63 * Npc ids
64 */
65 private static final String[] PYROMANCER_DEAD_TEXT = {"My flame burns low.", "Mummy!", "I think I'm dying.", "We are doomed.", "Ugh, help me!"};
66
67 public static final int PYROMANCER = 7371;
68 public static final int INCAPACITATED_PYROMANCER = 7372;
69 private static final int FLAME = 7373;
70
71 /**
72 * Game object ids
73 */
74 private static final int SNOW_EFFECT_ID = 26690;
75 private static final int ACTIVE_STORM_ID = 29308;
76 private static final int INACTIVE_STORM_ID = 29309;
77 public static final int EMPTY_BRAZIER_ID = 29312;
78 public static final int BROKEN_BRAZIER_ID = 29313;
79 public static final int BURNING_BRAZIER_ID = 29314;
81
82 /**
83 * List of all minigame items
84 */
86
87 /**
88 * List of all warm clothing
89 */
90
91 private static final List<Integer> WARM_CLOTHING = Arrays.asList(
92 //Santa outfits
93 1050, 12887, 12888, 12889, 12890, 12891, 12892, 12893, 12894, 12895, 12896, 13343, 13344,
94 //Bunny outfit
95 23448, 13663, 13664, 13665, 13182,
96 //Clue hunter outfit
97 19689, 19691, 19693, 19695, 19697,
98 //Polar camo
99 10065, 10066,
100 //Wood camo
101 10053, 10055,
102 //Jungle camo
103 10057, 10059,
104 //Desert camo
105 10061, 10063,
106 //Larupia
107 10045, 10043, 10041,
108 //Graahk
109 10051, 10049, 10047,
110 //Kyatt
111 10039, 10037, 10035,
112 //Bomber
113 9945, 9944,
114 //Yakhide armour
115 10822, 10824,
116 //Pyromancer
117 20708, 20706, 20704, 20710,
118 //Chicken outfit
119 11021, 11020, 11022, 11019,
120 //Evil chicken
121 20439, 20436, 20442, 20434,
122 //Bearhead
123 4502,
124 //Fire tiara
125 5537,
126 //Lumberjack hat
127 10941,
128 //Firemaking hood
129 9806,
130 //Fire cape max hood
131 13330,
132 //Infernal max hood
133 21282,
134 //Scarfs
135 6857, 6859, 6861, 6863, 9470, 21314,
136 //Gloves of silence
137 10075,
138 //Fremennik gloves
139 3799,
140 //Warm gloves
141 20712,
142 //Firemaking cape
143 9804, 9805,
144 //Max cape
145 13280, 13329, 21284, 21285, 13337, 20760, 21898, 24855, 21776, 21780, 21778, 13331, 13333, 13335,
146 //Fire cape
147 6570,
148 //Obsidian cape
149 6568, 20050,
150 //Weapons
151 1387, 1393, 3053, 11787, 11998, 1401, 3054, 11789, 12000, 13241, 13242, 13243, 13244, 21031, 21033, 12773, 20056, 20720,
152 //Shields
153 20714, 20716, 7053
154 //TODO: Add the last few (https://i.imgur.com/Pif4I0l.png)
155 );
156
157 /**
158 * Brazier data
159 */
160 public static final Brazier[] BRAZIERS = {
161 new Brazier(World.getRegions().getRegion(new Position(1620, 3997, 0)).getGameObject(29312, new Position(1620, 3997, 0)), new Npc(7371, new Position(1619, 3996, 0), 0, Direction.NORTH_EAST), 2, 2, Direction.NORTH_EAST), // sw
162 new Brazier(World.getRegions().getRegion(new Position(1620, 4015, 0)).getGameObject(29312, new Position(1620, 4015, 0)), new Npc(7371, new Position(1619, 4018, 0), 0, Direction.SOUTH_EAST), 2, 0, Direction.SOUTH_EAST), // nw
163 new Brazier(World.getRegions().getRegion(new Position(1638, 4015, 0)).getGameObject(29312, new Position(1638, 4015, 0)), new Npc(7371, new Position(1641, 4018, 0), 0, Direction.SOUTH_WEST), 0, 0, Direction.SOUTH_WEST), // ne
164 new Brazier(World.getRegions().getRegion(new Position(1638, 3997, 0)).getGameObject(29312, new Position(1638, 3997, 0)), new Npc(7371, new Position(1641, 3996, 0), 0, Direction.NORTH_WEST), 0, 2, Direction.NORTH_WEST) // se
165 };
166
167 public static boolean isActive() {
168 return startDelay <= 0;
169 }
170
171 public static void init() {
172 region = World.getRegions().getRegion(new Position(1627, 4004, 0));
173 pyroSpeechDelay = 8;
175 WINTERTODT = new CustomGameObject(INACTIVE_STORM_ID, new Position(1627, 4004, 0));
176 WINTERTODT.register();
177 started = false;
178
179 for(Brazier brazier : BRAZIERS)
180 brazier.getPyromancer().register();
181
182 World.schedule(new Task(1) {
183 @Override
184 protected void execute() {
185 if(startDelay > 0)
186 startDelay--;
187
188 if(startDelay <= 0 && !started) start();
189
190 update();
191 }
192 });
193
194 World.schedule(new Task(2) {
195 @Override
196 protected void execute() {
197 if(!isActive()) return;
198
205 dealDamage();
206 }
207 });
208 }
209
210 private static void start() {
211 WINTERTODT.transform(ACTIVE_STORM_ID);
212
213 for (Brazier brazier : BRAZIERS) {
214 //brazier.getObject().transform(EMPTY_BRAZIER_ID);
215 brazier.getObject().unregister();
216 brazier.setObject(EMPTY_BRAZIER_ID);
217 brazier.getObject().register();
218 if (!brazier.isPyromancerAlive())
219 brazier.getPyromancer().transform(PYROMANCER);
220 }
221
222 health = MAX_HP;
223 started = true;
224 update();
225 }
226
227 private static void update() {
228 region.getPlayers(0).forEach(Wintertodt::send);
229 }
230
231 public static void send(Player player) {
232 player.send(new SendString("Wintertodt's Energy: "+(health / (MAX_HP / 100))+"%", 41553));
233 player.send(new SendString(isActive() ? "" : "The Wintertodt returns in: " + ((startDelay * 600) / 1000) + " secs", 41554));
234 player.send(new SendString("<col="+(player.wintertodtPoints >= 500 ? "FFFFFF" : "FF0000")+">Points\\n" + player.wintertodtPoints, 41556));
235
236 //Sends the pyromancer config stuff
237 player.send(new SendConfig(2224, BRAZIERS[0].isPyromancerAlive() ? 0 : 1));
238 player.send(new SendConfig(2222, BRAZIERS[1].isPyromancerAlive() ? 0 : 1));
239 player.send(new SendConfig(2223, BRAZIERS[2].isPyromancerAlive() ? 0 : 1));
240 player.send(new SendConfig(2225, BRAZIERS[3].isPyromancerAlive() ? 0 : 1));
241 //Sends the brazier config stuff
242 player.send(new SendConfig(2228, BRAZIERS[0].getBrazierState()));
243 player.send(new SendConfig(2226, BRAZIERS[1].getBrazierState()));
244 player.send(new SendConfig(2227, BRAZIERS[2].getBrazierState()));
245 player.send(new SendConfig(2229, BRAZIERS[3].getBrazierState()));
246
247 if (player.interfaceManager.getWalkable() != 41550)
248 player.interfaceManager.openWalkable(41550);
249 }
250
251 private static void applyColdDamage() {
252 region.getPlayers(0).forEach(player -> {
253 if(player.getPosition().getY() <= 3987 || Utility.random(25) != 0) return;
254
255 player.damage(new Hit(getColdDamage(player)));
256 player.message("The cold of the Wintertodt seeps into your bones.");
257
258 if(player.action.getCurrentAction() instanceof WintertodtAction)
259 player.action.getCurrentAction().cancel();
260 });
261 }
262
263 /**
264 * Handles extinguishing the braziers
265 */
266 private static void extinguishBraziers() {
267 for (Brazier brazier : BRAZIERS) {
268 int roll = Utility.random(health + 1500) / 10;
269 if(brazier.getObject().getId() == BURNING_BRAZIER_ID && roll == 10) {
270 if(brazier.hasSnowStorm()) continue;
271
272 if(Utility.random(health < (MAX_HP / 2) ? 2 : 3) == 1)
273 breakBrazier(brazier);
274 else {
275 //Graphic (502, 115, 0)
276 //brazier.getObject().transform(EMPTY_BRAZIER_ID);
277 brazier.getObject().unregister();
278 brazier.setObject(EMPTY_BRAZIER_ID);
279 brazier.getObject().register();
280 }
281 }
282 }
283 }
284
285 /**
286 * Handles breaking the brazier
287 */
288 private static void breakBrazier(Brazier brazier) {
289 if(brazier.getObject().getId() == BROKEN_BRAZIER_ID) return;
290
291 List<GameObject> objects = Arrays.asList(
292 new CustomGameObject(SNOW_EFFECT_ID, new Position(brazier.getObject().getPosition().getX() + 1, brazier.getObject().getPosition().getY(), 0)),
293 new CustomGameObject(SNOW_EFFECT_ID, new Position(brazier.getObject().getPosition().getX(), brazier.getObject().getPosition().getY() + 1, 0)),
294 new CustomGameObject(SNOW_EFFECT_ID, new Position(brazier.getObject().getPosition().getX() + 1, brazier.getObject().getPosition().getY() + 1, 0)),
295 new CustomGameObject(SNOW_EFFECT_ID, new Position(brazier.getObject().getPosition().getX() + 2, brazier.getObject().getPosition().getY() + 1, 0)),
296 new CustomGameObject(SNOW_EFFECT_ID, new Position(brazier.getObject().getPosition().getX() + 1, brazier.getObject().getPosition().getY() + 2, 0))
297 );
298
299 for(GameObject gameObject : objects)
300 gameObject.register();
301
302 brazier.setSnowStorm(true);
303
304 World.schedule(new Task(4) {
305 @Override
306 public void execute() {
307
308 for(GameObject gameObject : objects) {
309 gameObject.unregister();
310 region.getPlayers(0).forEach(players -> {
311 players.send(new SendRemoveObject(new CustomGameObject(gameObject.getId(), gameObject.getPosition())));
312 });
313 }
314
315 brazier.setSnowStorm(false);
316
317 if(isActive()) {
318 //Graphio (502, 90, 0)
319 //brazier.getObject().transform(BROKEN_BRAZIER_ID);
320 brazier.getObject().unregister();
322 brazier.getObject().register();
323 region.getPlayers(0).forEach(player -> {
324 if(Utility.goodDistance(brazier.getObject().getPosition().getX() + 1, brazier.getObject().getPosition().getY() + 1, player.getPosition().getX(), player.getPosition().getY(), 2)) {
325 player.message("The brazier is broken and shrapnel damages you.");
326 player.damage(new Hit(Utility.random(getBrazierAttackDamage(player))));
327 }
328 });
329 }
330 this.cancel();
331 }
332 });
333 }
334
335 /**
336 * How much damage the brazier does to a player when it breaks
337 */
338 public static int getBrazierAttackDamage(Player player) {
340 }
341
342 /**
343 * Handles doing the magic attack by the bnoss
344 */
345 private static void doMagicAttack() {
346 if(Utility.random(25) != 1 || region.getPlayers(0).size() == 0) return;
347
348 Player player = region.getPlayers(0).toArray(new Player[0])[Utility.random(region.getPlayers(0).size())];
349 if (player.getPosition().getY() <= 3987) return;
350
351 int baseX = player.getPosition().getX();
352 int baseY = player.getPosition().getY();
353 List<GameObject> snowAttacks = new ArrayList<>();
354
355 snowAttacks.add(new CustomGameObject(SNOW_EFFECT_ID, new Position(baseX, baseY, 0)));
356 if(region.getObjects(new Position(baseX + 1, baseY + 1, 0)).size() == 0)
357 snowAttacks.add(new CustomGameObject(SNOW_EFFECT_ID, new Position(baseX + 1, baseY + 1, 0)));
358 if(region.getObjects(new Position(baseX + 1, baseY - 1, 0)).size() == 0)
359 snowAttacks.add(new CustomGameObject(SNOW_EFFECT_ID, new Position(baseX + 1, baseY - 1, 0)));
360 if(region.getObjects(new Position(baseX - 1, baseY + 1, 0)).size() == 0)
361 snowAttacks.add(new CustomGameObject(SNOW_EFFECT_ID, new Position(baseX - 1, baseY + 1, 0)));
362 if(region.getObjects(new Position(baseX - 1, baseY - 1, 0)).size() == 0)
363 snowAttacks.add(new CustomGameObject(SNOW_EFFECT_ID, new Position(baseX - 1, baseY - 1, 0)));
364
365 for(GameObject gameObject : snowAttacks)
366 gameObject.register();
367
368 World.schedule(new Task(4) {
369 int index = 0;
370 @Override
371 public void execute() {
372 for(GameObject gameObject : snowAttacks) {
373 gameObject.transform(index == 0 ? 29325 : 29324);
374 index++;
375 }
376
377 region.getPlayers(0).forEach(players -> {
378 if(Utility.goodDistance(baseX, baseY, players.getX(), player.getY(), 1)) {
379 players.message("The freezing cold attack of the Wintertodt's magic hits you.");
380 players.damage(new Hit(1 + (getAreaAttackDamage(players) - 1)));
381 }
382 });
383 this.cancel();
384 }
385 });
386
387 World.schedule(new Task(14) {
388 @Override
389 public void execute() {
390 for(GameObject gameObject : snowAttacks) {
391 gameObject.unregister();
392 region.getPlayers(0).forEach(players -> {
393 players.send(new SendRemoveObject(new CustomGameObject(gameObject.getId(), gameObject.getPosition())));
394 });
395 }
396 this.cancel();
397 }
398 });
399 }
400
401 /**
402 * Handles the formula on how much the area attack can do
403 */
404 public static int getAreaAttackDamage(Player player) {
406 }
407
408 /**
409 * Handles attacking the pyromancers
410 */
411 private static void attackPyromancers() {
412 List<Npc> pyros = Arrays.stream(BRAZIERS).filter(Brazier::isPyromancerAlive).map(Brazier::getPyromancer).collect(Collectors.toList());
413 if (!pyros.isEmpty() && Utility.random(pyros.size() * 30) == pyros.size()) {
414 Npc pyro = pyros.get(Utility.random(pyros.size()));
415 if(pyro.pyroHealth <= 0) return;
416
417 if(pyro.pyroSnowAttack) {
418 System.out.println("already a snow attack going for this pyro...");
419 return;
420 }
421
422 pyro.pyroSnowAttack = true;
424 snow.register();
425
426 World.schedule(new Task(4) {
427 @Override
428 public void execute() {
429 int damage = 6 + Utility.random(4);
430 if(damage > pyro.pyroHealth)
431 damage = pyro.pyroHealth;
432 pyro.pyroHealth -= damage;
433 pyro.writeFakeDamage(new Hit(damage));
434 if(pyro.pyroHealth <= 0) {
435 pyro.pyroHealth = 0;
437 }
438 pyro.pyroSnowAttack = false;
439 region.getPlayers(0).forEach(players -> {
440 players.send(new SendRemoveObject(new CustomGameObject(snow.getId(), snow.getPosition())));
441 });
442 snow.unregister();
443 this.cancel();
444 }
445 });
446 }
447 }
448
449 /**
450 * Handles the pyromancer speech
451 */
452 private static void pyromancerText() {
453 if(pyroSpeechDelay <= 0) {
454 pyroSpeechDelay = 8;
455 for (Brazier brazier : BRAZIERS) {
456 if (!brazier.isPyromancerAlive())
457 brazier.getPyromancer().speak(PYROMANCER_DEAD_TEXT[Utility.random(PYROMANCER_DEAD_TEXT.length - 1)]);
458 else if (brazier.getObject().getId() == EMPTY_BRAZIER_ID)
459 brazier.getPyromancer().speak("Light this brazier!");
460 else if (brazier.getObject().getId() == BROKEN_BRAZIER_ID)
461 brazier.getPyromancer().speak("Fix this brazier!");
462 else if (Utility.random(4) == 1)
463 brazier.getPyromancer().speak("Yemalo shi cardito!");
464
465 if (brazier.isPyromancerAlive() && brazier.getObject().getId() == BURNING_BRAZIER_ID && Utility.random(3) == 1)
466 brazier.getPyromancer().animate(4432);
467 }
468 }
469 }
470
471 /**
472 * Handles dealing damage to the boss
473 */
474 private static void dealDamage() {
475 int damage = 0;
476 for (Brazier brazier : BRAZIERS) {
477 if (brazier.isPyromancerAlive() && brazier.getObject().getId() == BURNING_BRAZIER_ID) {
478 shootFlame(brazier);
479 damage += 5;
480 }
481 }
482
483 if (damage > 0) {
484 health -= damage;
485 if (health <= 0) {
486 health = 0;
487 death();
488 }
489 } else
490 health = Math.min(MAX_HP, health + 5);
491 }
492
493 /**
494 * Handles spawning the flame that goes to the middle
495 */
496 public static void shootFlame(Brazier brazier) {
497 Npc flame = new Npc(FLAME, new Position(brazier.getObject().getPosition().getX() + brazier.getFlameOffsetX(), brazier.getObject().getPosition().getY() + brazier.getFlameOffsetY(), brazier.getObject().getPosition().getHeight()), 0, brazier.direction);
498 flame.movement.simplePath(new Position(1630, 4007));
499 flame.register();
500 flame.action.execute(new FlameWalk(flame));
501 }
502
503 /**
504 * Handles the death of the boss
505 */
506 private static void death() {
507 started = false;
509
510 WINTERTODT.transform(INACTIVE_STORM_ID);
511
512 for (Brazier brazier : BRAZIERS) {
513 brazier.getPyromancer().speak("We can rest for a time.");
514 brazier.getPyromancer().transform(PYROMANCER);
515 brazier.getPyromancer().pyroSnowAttack = false;
516 brazier.getPyromancer().pyroHealth = 24;
517 brazier.getPyromancer().animate(65535);
518 //brazier.getObject().transform(EMPTY_BRAZIER_ID);
519 brazier.getObject().unregister();
520 brazier.setObject(EMPTY_BRAZIER_ID);
521 brazier.getObject().register();
522
523 }
524 region.getPlayers(0).forEach(Wintertodt::award);
525 }
526
527 /**
528 * Handles awarding players with crates
529 */
530 private static void award(Player player) {
531 removeGameItems(player);
532
533 if (player.wintertodtPoints >= 500) {
536 int crates = player.wintertodtPoints / 500;
537 if (crates > 1)
538 player.message("You have gained " + crates + " supply crates!");
539 else
540 player.message("You have gained a supply crate!");
541 player.inventory.add(new Item(20703, crates));
542 player.inventory.refresh();
543 } else player.message("You did not earn enough points to be worthy of a gift from the citizens of Kourend this time.");
544
545 player.wintertodtPoints = 0;
546 }
547
548 /**
549 * Handles removes the items within the wintertodt game
550 */
551 public static void removeGameItems(Player player) {
552 int slot = 0;
553 for (Item item : player.inventory.getItems()) {
554 if (item != null && GAME_ITEMS.contains(item.getId())) {
555 player.inventory.set(slot, null, false);
556 }
557 slot++;
558 }
559 player.inventory.refresh();
560 }
561
562 /**
563 * The amount of damagae the player gets from cold
564 */
565 public static int getColdDamage(Player player) {
567 }
568
569 /**
570 * How much warm clothing the player is wearing
571 */
572 public static int getWarmItemsWorn(Player player) {
573 int warmClothing = 0;
574 for(int id : WARM_CLOTHING) {
575 if(player.equipment.contains(id)) warmClothing++;
576 if(warmClothing >= 4) break;
577 }
578 return warmClothing;
579 }
580
581 /**
582 * How many braziers are currently lit
583 */
584 public static int getBraziersLit() {
585 int count = 0;
586 for (Brazier b : BRAZIERS)
587 if (b.getObject().getId() == BURNING_BRAZIER_ID)
588 count++;
589 return Math.min(count, 3);
590 }
591
592 /**
593 * Handles chopping the root
594 */
595 public static void chopRoot(Player player) {
596 if(!isActive()) {
597 player.message("There's no need to do that at this time.");
598 return;
599 }
600
601 AxeData axeData = AxeData.getDefinition(player).orElse(null);
602
603 if(axeData == null) {
604 player.message("You do not have an axe which you have the woodcutting level to use.");
605 return;
606 }
607
608 if(player.inventory.getFreeSlots() <= 0) {
609 player.message("You have no space for that.");
610 return;
611 }
612
613 player.action.execute(new ChopRoots(player));
614 }
615
616 /**
617 * Handles feeding the brazier
618 */
619 public static void feedBrazier(Player player, GameObject gameObject) {
620 if(!isActive()) {
621 player.message("There's no need to do that at this time.");
622 return;
623 }
624
625 Brazier brazier = null;
626
627 for(Brazier b : BRAZIERS) {
628 if(b.getObject().getId() == gameObject.getId() && b.getObject().getPosition() == gameObject.getPosition()) {
629 brazier = b;
630 break;
631 }
632 }
633
634 if(brazier == null) {
635 System.out.println("Brazier has not been found...");
636 return;
637 }
638
639 player.animate(832);
640 player.action.execute(new FeedBrazier(player, brazier));
641 }
642
643 /**
644 * Handles fixing the brazier
645 */
646 public static void fixBrazier(Player player, GameObject gameObject) {
647 if(!isActive()) {
648 player.message("There's no need to do that at this time.");
649 return;
650 }
651
652 Brazier brazier = null;
653
654 for(Brazier b : BRAZIERS) {
655 if(b.getObject().getId() == gameObject.getId() && b.getObject().getPosition() == gameObject.getPosition()) {
656 brazier = b;
657 break;
658 }
659 }
660
661 if(brazier == null) {
662 System.out.println("Brazier has not been found...");
663 return;
664 }
665
666 if(!brazier.isPyromancerAlive()) {
667 player.message("Heal the Pyromancer before fixing the brazier.");
668 return;
669 }
670
671 if(!player.inventory.contains(2347)) {
672 player.message("You need a hammer to fix this brazier.");
673 return;
674 }
675
676 player.animate(3676);
677 player.action.execute(new FixBrazier(player, brazier));
678 }
679
680 /**
681 * Handles fetching the kindling
682 */
683 public static void fletch(Player player) {
684 if(!isActive()) {
685 player.message("There's no need to do that at this time.");
686 return;
687 }
688
689 if(!player.inventory.contains(BRUMA_ROOT)) return;
690
691 player.animate(1248);
693 }
694
695 /**
696 * Handles lighting a brazier
697 */
698 public static void lightBrazier(Player player, GameObject gameObject) {
699 if(!isActive()) {
700 player.message("There's no need to do that at this time.");
701 return;
702 }
703
704 Brazier brazier = null;
705
706 for(Brazier b : BRAZIERS) {
707 if(b.getObject().getId() == gameObject.getId() && b.getObject().getPosition() == gameObject.getPosition()) {
708 brazier = b;
709 break;
710 }
711 }
712
713 if(brazier == null) {
714 System.out.println("Brazier has not been found...");
715 return;
716 }
717
718 if(!brazier.isPyromancerAlive()) {
719 player.message("Heal the Pyromancer before lighting the brazier.");
720 return;
721 }
722
723 if(!player.inventory.contains(590) && !player.equipment.contains(20720)) {
724 player.message("You need a tinderbox or Bruma Torch to light that brazier.");
725 return;
726 }
727
728 player.animate(733);
729 player.action.execute(new LightBrazier(player, brazier));
730 }
731
732 /**
733 * Handles mixing the potion
734 */
735 public static void mixHerb(Player player) {
736 if(!isActive()) {
737 player.message("There's no need to do that at this time.");
738 return;
739 }
740
741 int herbs = player.inventory.computeAmountForId(BRUMA_HERB);
742 int pots = player.inventory.computeAmountForId(REJUV_POT_UNF);
743 int min = Utility.min(herbs, pots);
744
745 if(min == 0) return;
746
747 player.animate(363);
748 player.action.execute(new MixHerb(player, min));
749 }
750
751 /**
752 * Handles taking a bruma herb
753 */
754 public static void takeHerb(Player player) {
755 if(!isActive()) {
756 player.message("There's no need to do that at this time.");
757 return;
758 }
759
760 if(player.inventory.getFreeSlots() <= 0) {
761 player.message("You have no space for that.");
762 return;
763 }
764
765 player.animate(2282);
766 player.action.execute(new PickHerb(player));
767 }
768
769 /**
770 * Handles healing the pyromancer
771 */
772 public static void healPyromancer(Player player, Npc npc, int slot) {
773 if(!isActive()) {
774 player.message("There's no need to do that at this time.");
775 return;
776 }
777
778 Brazier brazier = null;
779
780 for(Brazier b : BRAZIERS) {
781 if(b.getPyromancer().getPosition() == npc.getPosition() && b.getPyromancer().id == npc.id) {
782 brazier = b;
783 break;
784 }
785 }
786
787 if(brazier == null) {
788 System.out.println("Brazier has not been found...");
789 return;
790 }
791
792 Item itemUsed = player.inventory.get(slot);
793
794 if(itemUsed.getId() != REJUV_POT_4 && itemUsed.getId() != REJUV_POT_3 && itemUsed.getId() != REJUV_POT_2 && itemUsed.getId() != REJUV_POT_1) {
795 System.out.println("not a rejuv potion");
796 return;
797 }
798
799 Item newPot = new Item(player.inventory.getId(slot) + 1);
800 if(newPot.getId() > REJUV_POT_1) newPot = null;
801
802 player.inventory.set(slot, newPot, true);
803
805 brazier.getPyromancer().pyroHealth = 24;
806 brazier.getPyromancer().pyroSnowAttack = false;
807
808 addPoints(player, 30);
809 }
810
811 /**
812 * Handles adding wintertodt points to a player
813 */
814 public static void addPoints(Player player, int amount) {
815 int old = player.wintertodtPoints;
816 player.wintertodtPoints += amount;
817 if (old < 500 && player.wintertodtPoints >= 500) {
818 player.message("You have helped enough to earn a supply crate. Further work will go towards better rewards.");
819 }
820 send(player);
821 }
822}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final double FIREMAKING_MODIFICATION
The experience modification for firemaking.
Definition Config.java:256
static void increaseCounter(Player player, CollectionLogData data)
void setSnowStorm(boolean snowStorm)
Definition Brazier.java:48
static final List< Integer > GAME_ITEMS
List of all minigame items.
static int getBraziersLit()
How many braziers are currently lit.
static void shootFlame(Brazier brazier)
Handles spawning the flame that goes to the middle.
static void healPyromancer(Player player, Npc npc, int slot)
Handles healing the pyromancer.
static final String[] PYROMANCER_DEAD_TEXT
Npc ids.
static int getColdDamage(Player player)
The amount of damagae the player gets from cold.
static void doMagicAttack()
Handles doing the magic attack by the bnoss.
static void attackPyromancers()
Handles attacking the pyromancers.
static void fixBrazier(Player player, GameObject gameObject)
Handles fixing the brazier.
static int getWarmItemsWorn(Player player)
How much warm clothing the player is wearing.
static void mixHerb(Player player)
Handles mixing the potion.
static void pyromancerText()
Handles the pyromancer speech.
static void award(Player player)
Handles awarding players with crates.
static void death()
Handles the death of the boss.
static void fletch(Player player)
Handles fetching the kindling.
static void removeGameItems(Player player)
Handles removes the items within the wintertodt game.
static void extinguishBraziers()
Handles extinguishing the braziers.
static final int REGION_ID
Region of the wintertodt game.
static void addPoints(Player player, int amount)
Handles adding wintertodt points to a player.
static void takeHerb(Player player)
Handles taking a bruma herb.
static final int SNOW_EFFECT_ID
Game object ids.
static void feedBrazier(Player player, GameObject gameObject)
Handles feeding the brazier.
static void lightBrazier(Player player, GameObject gameObject)
Handles lighting a brazier.
static void chopRoot(Player player)
Handles chopping the root.
static int getBrazierAttackDamage(Player player)
How much damage the brazier does to a player when it breaks.
static final Brazier[] BRAZIERS
Brazier data.
static int getAreaAttackDamage(Player player)
Handles the formula on how much the area attack can do.
static final List< Integer > WARM_CLOTHING
List of all warm clothing.
static void breakBrazier(Brazier brazier)
Handles breaking the brazier.
static void dealDamage()
Handles dealing damage to the boss.
public< A extends Action<?> > void execute(A action)
A game representing a cyclic unit of work.
Definition Task.java:11
Represents the game world.
Definition World.java:46
static void schedule(Task task)
Submits a new event.
Definition World.java:247
static RegionManager getRegions()
Definition World.java:552
A Hit object holds the damage amount and hitsplat data.
Definition Hit.java:10
void transform(int transformId)
Definition Mob.java:201
boolean simplePath(Position destination)
Finds a smart path to the target.
Represents a non-player character in the in-game world.
Definition Npc.java:29
void register()
Registers an entity to the World.
Definition Npc.java:112
void openWalkable(int identification)
Opens a walkable-itemcontainer for the player.
This class represents a character controlled by a player.
Definition Player.java:125
Represents a trainable and usable skill.
Definition Skill.java:18
static final byte getLevelForExperience(double experience)
Gets the level for a given experience amount.
Definition Skill.java:446
double getExperience()
Gets the skill experience.
Definition Skill.java:223
static final int FIREMAKING
The firemaking skill id.
Definition Skill.java:54
static final int HITPOINTS
The hitpoints skill id.
Definition Skill.java:30
void addExperience(int id, double experience)
Adds experience to a given skill.
Skill get(int id)
Gets the skill for an id.
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
final int computeAmountForId(int id)
Computes the total quantity of the Items in this container with id.
final Item get(int index)
Gets the Item located on index.
boolean add(Item item)
Attempts to deposit item into this container.
final int getId(int index)
Gets the item id located on index.
boolean contains(int id)
Determines if this container contains id.
boolean contains(int[] bowsWithNoArrowsRequired)
void refresh()
Refreshes the players inventory.
Represents a static game object loaded from the map fs.
Represents a single tile on the game world.
Definition Position.java:14
int getHeight()
Gets the height coordinate, or height.
Definition Position.java:51
int getY()
Gets the absolute y coordinate.
Definition Position.java:46
int getX()
Gets the absolute x coordinate.
Definition Position.java:41
Represents a single region.
Definition Region.java:21
Region getRegion(Position position)
Gets a region by position.
The OutgoingPacket responsible for changing settings on a client.
The OutgoingPacket that sends a string to a Players itemcontainer in the client.
Handles miscellaneous methods.
Definition Utility.java:27
static int random(int bound)
Definition Utility.java:239
static final boolean goodDistance(int objectX, int objectY, int playerX, int playerY, int distance)
Definition Utility.java:903
static int min(int... values)
Definition Utility.java:895
static Optional< AxeData > getDefinition(Player player)
Gets the definition for this hatchet.
Definition AxeData.java:74
Represents the enumerated directions an entity can walk or face.
void register()
Registers the game object.
Position getPosition()
Gets the regional location.
void unregister()
Unregisters the game object.
default int getId()
Gets the object id.