RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
BarrowsUtility.java
1package com.osroyale.content.activity.impl.barrows;
2
3import com.osroyale.content.ActivityLog;
4import com.osroyale.content.achievement.AchievementHandler;
5import com.osroyale.content.achievement.AchievementKey;
6import com.osroyale.content.collectionlog.CollectionLog;
7import com.osroyale.content.collectionlog.CollectionLogData;
8import com.osroyale.game.task.impl.CeillingCollapseTask;
9import com.osroyale.game.world.World;
10import com.osroyale.game.world.entity.mob.player.Player;
11import com.osroyale.game.world.items.Item;
12import com.osroyale.net.packet.out.SendItemOnInterface;
13import com.osroyale.net.packet.out.SendMessage;
14import com.osroyale.net.packet.out.SendString;
15import com.osroyale.util.Utility;
16
17import java.util.ArrayList;
18import java.util.HashSet;
19import java.util.List;
20import java.util.Set;
21
50
51public class BarrowsUtility {
52
53 public static Item[] JUNK = {
54 new Item(995, 500),
55 new Item(985),
56 new Item(987),
57 new Item(1149)
58 };
59
60 public static int RUNES_AND_AMMUNITION[] = {
61 4740, 558, 560, 565
62 };
63
64 public static int BARROWS[] = {4708, 4710, 4712, 4714, 4708, 4710, 4712, 4714, 4716, 4718, 4720,
65 4722, 4724, 4718, 4720,
66 4722, 4724, 4718, 4720,
67 4722, 4724, 4726, 4728, 4730, 4732, 4734, 4736, 4738, 4745, 4747,
68 4749, 4751, 4753, 4755, 4757, 4759};
69
70 public static final int[][] BROKEN_BARROWS = {
71 {4708, 4860}, {4710, 4866},
72 {4712, 4872}, {4714, 4878}, {4716, 4884}, {4720, 4896},
73 {4718, 4890}, {4720, 4896}, {4722, 4902}, {4732, 4932},
74 {4734, 4938}, {4736, 4944}, {4738, 4950}, {4724, 4908},
75 {4726, 4914}, {4728, 4920}, {4730, 4926}, {4745, 4956},
76 {4747, 4926}, {4749, 4968}, {4751, 4994}, {4753, 4980},
77 {4755, 4986}, {4757, 4992}, {4759, 4998}};
78
79
80 public static boolean teleportPlayer(Player player) {
81 for (BrotherData brother : BrotherData.values()) {
82 if (player.getPosition().inLocation(brother.getSouthWest(), brother.getNorthEast(), true)) {
83 player.move(brother.getCryptPosition());
84 player.send(new SendMessage("You dig a hole and fall into " + brother.name().toLowerCase() + "s crypt!"));
85 return true;
86 }
87 }
88 return false;
89 }
90
91 static BrotherData getHiddenBrother(Player player) {
92 List<BrotherData> brother = new ArrayList<>();
93 for (int i = 0; i < player.barrowKills.length; i++) {
94 if (!player.barrowKills[i]) {
95 brother.add(BrotherData.values()[i]);
96 }
97 }
98 return Utility.randomElement(brother);
99 }
100
101 static void generateRewards(Player player) {
102 Set<Item> rewards = new HashSet<>();
103 Item[] rewardDisplay = new Item[5];
104 Item junk = Utility.randomElement(JUNK);
105 Item runes = new Item(Utility.randomElement(BarrowsUtility.RUNES_AND_AMMUNITION), 25 + Utility.random(5));
106 Item runes2 = new Item(Utility.randomElement(BarrowsUtility.RUNES_AND_AMMUNITION), 25 + Utility.random(5));
107
108 if (junk.getId() == 995) {
109 junk.setAmount(Utility.random(5000, 25000));
110 }
111
112 rewards.add(junk);
113
114 if (runes.getId() == runes2.getId()) {
115 runes.setAmount(runes.getAmount() + runes2.getAmount());
116 rewards.add(runes);
117 } else {
118 rewards.add(runes);
119 rewards.add(runes2);
120 }
121
122 if (Utility.random(100) >= 90) {
123 rewards.add(new Item(Utility.randomElement(BarrowsUtility.BARROWS)));
124 AchievementHandler.activate(player, AchievementKey.BARROWS_UNIQUE);
125 }
126
127 int value = 0;
128 int count = 0;
129 for (Item item : rewards) {
130 value += item.getValue() * item.getAmount();
131 rewardDisplay[count] = item;
132 count++;
133
134 CollectionLog.logItem(player, CollectionLogData.BARROWS, item.getId(), item.getAmount());
135 }
136
137 player.send(new SendString("Total worth: " + Utility.formatDigits(value), 33306));
138 player.send(new SendItemOnInterface(33305, rewardDisplay));
139 rewards.forEach(player.inventory::addOrDrop);
140 player.interfaceManager.open(33300);
141 player.activityLogger.add(ActivityLog.BARROWS);
144 CollectionLog.increaseCounter(player, CollectionLogData.BARROWS);
145 }
146}
static void activate(Player player, AchievementKey achievement)
static void schedule(Task task)
Definition World.java:284
void move(Position position)
Definition Mob.java:377
static String formatDigits(final int amount)
Definition Utility.java:78
static< T > T randomElement(Collection< T > collection)
Definition Utility.java:285