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

178 lines
6.5 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 {
2024-06-15 19:11:49 -05:00
2024-06-15 20:03:45 -05:00
public int simCount = 250;
2023-08-05 18:39:17 -04:00
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;
2024-08-31 16:28:34 -05:00
try
{
simCount = Integer.parseInt(words[0]);
}catch(Exception e)
{
}
2024-06-15 19:11:49 -05:00
output = "Booty Simulation: Rolls:" + simCount + newline;
2023-08-05 18:39:17 -04:00
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)) {
2023-08-05 18:39:17 -04:00
ItemBase item = ItemBase.getItemBase(entry.itemBase);
if (item != null) {
output += "[" + entry.bootyType + "] " + item.getName() + " [Chance] " + entry.dropChance + newline;
}
}
}
ArrayList<Item> GlassItems = new ArrayList<Item>();
ArrayList<Item> Resources = new ArrayList<Item>();
ArrayList<Item> Runes = new ArrayList<Item>();
ArrayList<Item> Contracts = new ArrayList<Item>();
2024-12-27 20:08:07 -06:00
ArrayList<Item> GuardContracts = new ArrayList<Item>();
2023-08-05 18:39:17 -04:00
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;
2024-06-15 19:11:49 -05:00
for (int i = 0; i < simCount; ++i) {
2023-08-05 18:39:17 -04:00
try {
mob.loadInventory();
for (Item lootItem : mob.getCharItemManager().getInventory()) {
switch (lootItem.getItemBase().getType()) {
case CONTRACT: //CONTRACT
2024-12-27 20:08:07 -06:00
if(lootItem.getName().contains("Captain"))
GuardContracts.add(lootItem);
else
Contracts.add(lootItem);
2023-08-05 18:39:17 -04:00
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
if (lootItem.getItemBase().isGlass())
GlassItems.add(lootItem);
else
OtherDrops.add(lootItem);
break;
case GOLD:
goldAmount += lootItem.getNumOfItems();
break;
default:
OtherDrops.add(lootItem);
break;
}
}
} catch (Exception ex) {
failures++;
}
if (mob.getEquip() != null) {
for (MobEquipment me : mob.getEquip().values()) {
if (me.getDropChance() == 0)
continue;
float equipmentRoll = ThreadLocalRandom.current().nextInt(99) + 1;
float dropChance = me.getDropChance() * 100;
if (equipmentRoll > (dropChance))
continue;
MobLoot ml = new MobLoot(mob, me.getItemBase(), false);
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
2024-12-27 20:08:07 -06:00
int baseBound = 100000;
2024-12-27 20:10:39 -06:00
int levelPenalty = (int) (Math.max(0, Math.abs(50 - mob.level)) * 0.01 * 100000);
2024-12-27 20:08:07 -06:00
int totalRange = baseBound + levelPenalty;
2024-12-27 20:16:31 -06:00
if(mob.level >= 50){
totalRange = baseBound;
}
2024-12-27 20:08:07 -06:00
output += "TOTAL ROLL POTENTIAL: " + totalRange + newline;
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;
2024-12-27 20:08:07 -06:00
output += "GUARD CONTRACTS DROPS: " + GuardContracts.size() + newline;
2023-08-05 18:39:17 -04:00
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'";
}
}