RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
Simulation.java
1package com.osroyale.content.simulator;
2
3import com.osroyale.content.activity.impl.barrows.BarrowsUtility;
4import com.osroyale.game.world.entity.mob.npc.definition.NpcDefinition;
5import com.osroyale.game.world.entity.mob.npc.drop.NpcDrop;
6import com.osroyale.game.world.entity.mob.npc.drop.NpcDropManager;
7import com.osroyale.game.world.entity.mob.npc.drop.NpcDropTable;
8import com.osroyale.game.world.entity.mob.player.Player;
9import com.osroyale.game.world.items.Item;
10import com.osroyale.game.world.items.containers.pricechecker.PriceType;
11import com.osroyale.net.packet.out.SendItemOnInterface;
12import com.osroyale.net.packet.out.SendScrollbar;
13import com.osroyale.net.packet.out.SendString;
14import com.osroyale.util.RandomGen;
15import com.osroyale.util.Utility;
16
17import java.util.*;
18
45
46public enum Simulation implements SimulationFunction {
47 BLOOD_MONEY_CHEST() {
48 @Override
49 public void execute(Player player, int id, int amount) {
50 Map<Integer, Integer> items = new HashMap<>();
51 int count = 0;
52 long value = 0;
53
54 for (int index = 0; index < amount; index++) {
55 Item money = new Item(13307, Utility.random(5000, 8000));
56 value += money.getValue() * money.getAmount();
57
58 if (items.containsKey(money.getId())) {
59 int toAdd = items.get(money.getId()) + money.getAmount();
60
61 items.replace(money.getId(), toAdd);
62 } else {
63 items.put(money.getId(), money.getAmount());
64 }
65 count++;
66
67 Item piece = new Item(Utility.randomElement(BarrowsUtility.BARROWS));
68 value += piece.getValue() * piece.getAmount();
69 if (items.containsKey(piece.getId())) {
70 int toAdd = items.get(piece.getId()) + piece.getAmount();
71 items.replace(piece.getId(), toAdd);
72 } else {
73 items.put(piece.getId(), piece.getAmount());
74 }
75 count++;
76 }
77
78 Iterator it = items.entrySet().iterator();
79 while (it.hasNext()) {
80 Map.Entry pair = (Map.Entry) it.next();
81 int mapValue = (int) pair.getValue();
82
83
84
85 Item item = new Item((int) pair.getKey(), (int) pair.getValue());
86
87
88
89 System.out.println(pair.getKey() + " = " + pair.getValue());
90// player.send(new SendItemOnInterfaceSlot(26816, item, count));
91 it.remove();
92 count++;
93 }
94
95 int scroll = (items.size() / 6 + (items.size() % 6 > 0 ? 1 : 0)) * 44;
96 player.send(new SendString(amount, 26811, true));
97 player.send(new SendString("<col=C1A875>Blood Money Chest", 26806));
98 player.send(new SendString("Simulated <col=C1A875>" + Utility.formatDigits(amount) + "</col> drops", 26807));
99 player.send(new SendString("Total value: <col=01FF80>" + Utility.formatDigits(value) + "</col>", 26808));
100 player.send(new SendScrollbar(26815, scroll));
101 player.attributes.set("DROP_SIMULATOR_CUSTOM_KEY", 0);
102 }
103 },
104 NPC_DROP() {
105 @Override
106 public void execute(Player player, int id, int amount) {
107 if (amount > 100_000) {
108 amount = 100_000;
109 }
111 if (npc == null)
112 return;
113 NpcDropTable drop = NpcDropManager.NPC_DROPS.get(id);
114 if (drop == null)
115 return;
116 Map<Integer, Item> items = new HashMap<>();
117 long value = 0;
118 for (int index = 0; index < amount; index++) {
119 List<NpcDrop> npc_drops = drop.generate(player, true);
120 RandomGen gen = new RandomGen();
121 for (NpcDrop drops : npc_drops) {
122 Item item = drops.toItem(gen);
123 value += item.getValue(PriceType.VALUE) * item.getAmount();
124 items.compute(item.getId(), (key, val) -> val == null ? item : val.getId() == item.getId() ? val.createAndIncrement(item.getAmount()) : val);
125 }
126 }
127
128 List<Item> sorted = new ArrayList<>(items.values());
129 sorted.sort((first, second) -> second.getValue() - first.getValue());
130
131 player.attributes.set("DROP_SIMULATOR_SORTED_LIST", sorted.toArray(new Item[0]));
132 int scroll = (items.size() / 6 + (items.size() % 6 > 0 ? 1 : 0)) * 44;
133 player.send(new SendScrollbar(26815, scroll));
134 player.send(new SendItemOnInterface(26816, sorted.toArray(new Item[0])));
135 player.send(new SendString(amount, 26811, true));
136 player.send(new SendString("<col=C1A875>" + npc.getName(), 26806));
137 player.send(new SendString("Simulated <col=C1A875>" + Utility.formatDigits(amount) + "</col> drops", 26807));
138 player.send(new SendString("Total value: <col=01FF80>" + Utility.formatDigits(value) + "</col>", 26808));
139 player.attributes.set("DROP_SIMULATOR_KEY", id);
140 }
141 }
142}
143
144interface SimulationFunction {
145
146 void execute(Player player, int id, int amount);
147
148}
static String formatDigits(final int amount)
Definition Utility.java:78
static< T > T randomElement(Collection< T > collection)
Definition Utility.java:285