Files
Server/src/engine/devcmd/cmds/SimulateBootyCmd.java
T

157 lines
5.7 KiB
Java
Raw Normal View History

2023-08-05 18:39:17 -04:00
package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.LootManager;
import engine.gameManager.ZoneManager;
2023-08-06 14:04:06 -04:00
import engine.loot.BootySetEntry;
2023-08-05 18:39:17 -04:00
import engine.objects.*;
import java.util.ArrayList;
import java.util.concurrent.ThreadLocalRandom;
public class SimulateBootyCmd extends AbstractDevCmd {
public SimulateBootyCmd() {
super("bootysim");
}
@Override
2023-08-05 18:42:43 -04:00
protected void _doCmd(PlayerCharacter playerCharacter, String[] words,
2023-08-05 18:39:17 -04:00
AbstractGameObject target) {
2023-08-05 18:42:43 -04:00
if (playerCharacter == null)
2023-08-05 18:39:17 -04:00
return;
String newline = "\r\n ";
String output;
output = "Booty Simulation:" + newline;
Mob mob = (Mob) target;
output += "Name: " + mob.getName() + newline;
output += "Special Loot:" + newline;
if (mob.bootySet != 0) {
2023-08-08 18:30:21 -04:00
for (BootySetEntry entry : LootManager._bootySetMap.get(mob.bootySet)) {
2024-03-01 08:20:34 -05:00
2024-03-16 07:57:17 -04:00
ItemTemplate template = ItemTemplate.templates.get(entry.templateID);
2024-03-01 08:20:34 -05:00
if (template != null)
2024-02-28 16:31:09 -05:00
output += "[" + entry.bootyType + "] " + template.item_base_name + " [Chance] " + entry.dropChance + newline;
2023-08-05 18:39:17 -04:00
}
}
ArrayList<Item> GlassItems = new ArrayList<Item>();
ArrayList<Item> Resources = new ArrayList<Item>();
ArrayList<Item> Runes = new ArrayList<Item>();
ArrayList<Item> Contracts = new ArrayList<Item>();
ArrayList<Item> Offerings = new ArrayList<Item>();
ArrayList<Item> OtherDrops = new ArrayList<Item>();
ArrayList<Item> EquipmentDrops = new ArrayList<Item>();
2023-08-05 18:42:43 -04:00
2023-08-05 18:39:17 -04:00
int failures = 0;
int goldAmount = 0;
for (int i = 0; i < 100; ++i) {
try {
mob.loadInventory();
2024-03-18 10:01:29 -04:00
for (Item lootItem : mob.charItemManager.getInventory()) {
2024-03-10 13:34:24 -04:00
switch (lootItem.template.item_type) {
case EMPLOYMENTCONTRACT: //CONTRACT
2023-08-05 18:39:17 -04:00
Contracts.add(lootItem);
break;
case OFFERING: //OFFERING
Offerings.add(lootItem);
break;
case RESOURCE: //RESOURCE
Resources.add(lootItem);
break;
case RUNE: //RUNE
Runes.add(lootItem);
break;
case WEAPON: //WEAPON
2024-03-15 10:55:49 -04:00
if (lootItem.getName().toUpperCase().contains("GLASS"))
2023-08-05 18:39:17 -04:00
GlassItems.add(lootItem);
else
OtherDrops.add(lootItem);
break;
case GOLD:
goldAmount += lootItem.getNumOfItems();
break;
default:
OtherDrops.add(lootItem);
break;
}
}
} catch (Exception ex) {
failures++;
}
2024-03-18 10:12:13 -04:00
if (mob.charItemManager.equipped.isEmpty() == false) {
for (Item me : mob.charItemManager.equipped.values()) {
2023-08-05 18:39:17 -04:00
2024-03-18 10:12:13 -04:00
if (me.drop_chance == 0)
2023-08-05 18:39:17 -04:00
continue;
float equipmentRoll = ThreadLocalRandom.current().nextInt(99) + 1;
2024-03-18 10:12:13 -04:00
float dropChance = me.drop_chance * 100;
2023-08-05 18:39:17 -04:00
if (equipmentRoll > (dropChance))
continue;
2024-03-15 10:01:22 -04:00
MobLoot ml = new MobLoot(mob, me.template, false);
2023-08-05 18:39:17 -04:00
if (ml != null)
EquipmentDrops.add(ml);
}
}
}
output += "MobBase BootySet: " + mob.getMobBase().bootySet + newline;
output += "Mob BootySet: " + mob.bootySet + newline;
output += "Tables Rolled On: " + newline;
2023-08-05 18:49:48 -04:00
boolean hotZoneRan = false;
2023-08-05 19:46:29 -04:00
float dropRate = 1.0f;
if (ZoneManager.inHotZone(mob.getLoc()))
dropRate = LootManager.HOTZONE_DROP_RATE;
else
dropRate = LootManager.NORMAL_DROP_RATE;
2023-08-05 18:49:48 -04:00
2023-08-08 18:30:21 -04:00
for (BootySetEntry entry : LootManager._bootySetMap.get(mob.getMobBase().bootySet)) {
2023-08-05 18:49:48 -04:00
2023-08-05 20:11:07 -04:00
if (entry.bootyType.equals("GOLD"))
2023-08-06 07:53:33 -04:00
output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.genTable + ": " + entry.dropChance + newline;
2023-08-05 20:11:07 -04:00
else
2023-08-06 07:53:33 -04:00
output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.genTable + ": " + entry.dropChance * dropRate + newline;
2023-08-05 18:39:17 -04:00
2023-08-07 10:16:30 -04:00
if (hotZoneRan == false && ZoneManager.inHotZone(mob.getLoc()) && LootManager._genTables.containsKey(entry.genTable + 1)) {
2023-08-06 07:53:33 -04:00
output += "HOTZONE TABLE [" + entry.bootyType + "] " + (entry.genTable + 1) + ": " + entry.dropChance * dropRate + newline;
2023-08-05 18:49:48 -04:00
hotZoneRan = true;
}
}
2023-08-05 18:39:17 -04:00
output += "GLASS DROPS: " + GlassItems.size() + newline;
output += "RUNE DROPS: " + Runes.size() + newline;
output += "CONTRACTS DROPS: " + Contracts.size() + newline;
output += "RESOURCE DROPS: " + Resources.size() + newline;
output += "OFFERINGS DROPPED: " + Offerings.size() + newline;
output += "ENCHANTED ITEMS DROPPED: " + OtherDrops.size() + newline;
output += "TOTAL GOLD DROPPED: " + goldAmount + newline;
output += "EQUIPMENT DROPPED: " + EquipmentDrops.size() + newline;
output += "FAILED ROLLS: " + failures + newline;
2023-08-05 18:42:43 -04:00
throwbackInfo(playerCharacter, output);
2023-08-05 18:39:17 -04:00
}
@Override
protected String _getHelpString() {
return "Simulates loot drops";
}
@Override
protected String _getUsageString() {
return "'/bootysim targetID'";
}
}