RuneHive-Game
Loading...
Searching...
No Matches
BarrowsUtility.java
Go to the documentation of this file.
1package com.runehive.content.activity.impl.barrows;
2
3import com.runehive.content.ActivityLog;
4import com.runehive.content.achievement.AchievementHandler;
5import com.runehive.content.achievement.AchievementKey;
6import com.runehive.content.collectionlog.CollectionLog;
7import com.runehive.content.collectionlog.CollectionLogData;
8import com.runehive.game.task.impl.CeillingCollapseTask;
9import com.runehive.game.world.World;
10import com.runehive.game.world.entity.mob.player.Player;
11import com.runehive.game.world.items.Item;
12import com.runehive.net.packet.out.SendItemOnInterface;
13import com.runehive.net.packet.out.SendMessage;
14import com.runehive.net.packet.out.SendString;
15import com.runehive.util.Utility;
16
17import java.util.ArrayList;
18import java.util.HashSet;
19import java.util.List;
20import java.util.Set;
21
22public class BarrowsUtility {
23
24 public static Item[] JUNK = {
25 new Item(995, 500),
26 new Item(985),
27 new Item(987),
28 new Item(1149)
29 };
30
31 public static int RUNES_AND_AMMUNITION[] = {
32 4740, 558, 560, 565
33 };
34
35 public static int BARROWS[] = {4708, 4710, 4712, 4714, 4708, 4710, 4712, 4714, 4716, 4718, 4720,
36 4722, 4724, 4718, 4720,
37 4722, 4724, 4718, 4720,
38 4722, 4724, 4726, 4728, 4730, 4732, 4734, 4736, 4738, 4745, 4747,
39 4749, 4751, 4753, 4755, 4757, 4759};
40
41 public static final int[][] BROKEN_BARROWS = {
42 {4708, 4860}, {4710, 4866},
43 {4712, 4872}, {4714, 4878}, {4716, 4884}, {4720, 4896},
44 {4718, 4890}, {4720, 4896}, {4722, 4902}, {4732, 4932},
45 {4734, 4938}, {4736, 4944}, {4738, 4950}, {4724, 4908},
46 {4726, 4914}, {4728, 4920}, {4730, 4926}, {4745, 4956},
47 {4747, 4926}, {4749, 4968}, {4751, 4994}, {4753, 4980},
48 {4755, 4986}, {4757, 4992}, {4759, 4998}};
49
50
51 public static boolean teleportPlayer(Player player) {
52 for (BrotherData brother : BrotherData.values()) {
53 if (player.getPosition().inLocation(brother.getSouthWest(), brother.getNorthEast(), true)) {
54 player.move(brother.getCryptPosition());
55 player.send(new SendMessage("You dig a hole and fall into " + brother.name().toLowerCase() + "s crypt!"));
56 return true;
57 }
58 }
59 return false;
60 }
61
63 List<BrotherData> brother = new ArrayList<>();
64 for (int i = 0; i < player.barrowKills.length; i++) {
65 if (!player.barrowKills[i]) {
66 brother.add(BrotherData.values()[i]);
67 }
68 }
69 return Utility.randomElement(brother);
70 }
71
72 static void generateRewards(Player player) {
73 Set<Item> rewards = new HashSet<>();
74 Item[] rewardDisplay = new Item[5];
78
79 if (junk.getId() == 995) {
80 junk.setAmount(Utility.random(5000, 25000));
81 }
82
83 rewards.add(junk);
84
85 if (runes.getId() == runes2.getId()) {
86 runes.setAmount(runes.getAmount() + runes2.getAmount());
87 rewards.add(runes);
88 } else {
89 rewards.add(runes);
90 rewards.add(runes2);
91 }
92
93 if (Utility.random(100) >= 90) {
96 }
97
98 int value = 0;
99 int count = 0;
100 for (Item item : rewards) {
101 value += item.getValue() * item.getAmount();
102 rewardDisplay[count] = item;
103 count++;
104
105 CollectionLog.logItem(player, CollectionLogData.BARROWS, item.getId(), item.getAmount());
106 }
107
108 player.send(new SendString("Total worth: " + Utility.formatDigits(value), 33306));
109 player.send(new SendItemOnInterface(33305, rewardDisplay));
110 rewards.forEach(player.inventory::addOrDrop);
111 player.interfaceManager.open(33300);
116 }
117}
static void activate(Player player, AchievementKey achievement)
Activates the achievement for the individual player.
static void logItem(Player player, CollectionLogData data, int item, int amount)
static void increaseCounter(Player player, CollectionLogData data)
Represents the game world.
Definition World.java:46
static void schedule(Task task)
Submits a new event.
Definition World.java:247
void move(Position position)
Moves the mob to a set position.
Definition Mob.java:340
void open(int identification)
Opens an interface for the player.
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 void setAmount(int amount)
Sets the quantity of this item.
Definition Item.java:351
final int getId()
Gets the identification of this item.
Definition Item.java:324
final int getAmount()
Gets the quantity of this item.
Definition Item.java:342
boolean inLocation(Position southWest, Position northEast, boolean inclusive)
The OutgoingPacket that sends a message to a Players chatbox in the 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 String formatDigits(final int amount)
Formats digits for integers.
Definition Utility.java:41
static< T > T randomElement(Collection< T > collection)
Picks a random element out of any array type.
Definition Utility.java:248
The activity log class.