forked from MagicBane/Server
added parameter to simulateBooty command to simulate mob or zone booty and added custom iteraion input
This commit is contained in:
@@ -24,9 +24,19 @@ public class simulateBootyCmd extends AbstractDevCmd {
|
|||||||
if (pc == null) {
|
if (pc == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
int iterations = 100;
|
||||||
String newline = "\r\n ";
|
String newline = "\r\n ";
|
||||||
|
if(words[1].length() > 0){
|
||||||
|
try{
|
||||||
|
iterations = Integer.parseInt(words[1]);
|
||||||
|
}catch(Exception ex){
|
||||||
|
iterations = 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
boolean isZone = false;
|
||||||
|
if(words[2].length() > 0 && words[2].toLowerCase().equals("zone")){
|
||||||
|
isZone = true;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
int targetID = Integer.parseInt(words[0]);
|
int targetID = Integer.parseInt(words[0]);
|
||||||
Building b = BuildingManager.getBuilding(targetID);
|
Building b = BuildingManager.getBuilding(targetID);
|
||||||
@@ -45,13 +55,10 @@ public class simulateBootyCmd extends AbstractDevCmd {
|
|||||||
+ " Table ID: " + pc.getLastTargetID());
|
+ " Table ID: " + pc.getLastTargetID());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Enum.GameObjectType objType = target.getObjectType();
|
Enum.GameObjectType objType = target.getObjectType();
|
||||||
int objectUUID = target.getObjectUUID();
|
|
||||||
String output;
|
String output;
|
||||||
|
|
||||||
output = "Loot Simulation:" + newline;
|
output = "Booty Simulation:" + newline;
|
||||||
|
|
||||||
switch (objType) {
|
switch (objType) {
|
||||||
case Building:
|
case Building:
|
||||||
@@ -74,49 +81,70 @@ public class simulateBootyCmd extends AbstractDevCmd {
|
|||||||
ArrayList<Item> Offerings = new ArrayList<Item>();
|
ArrayList<Item> Offerings = new ArrayList<Item>();
|
||||||
ArrayList<Item> OtherDrops = new ArrayList<Item>();
|
ArrayList<Item> OtherDrops = new ArrayList<Item>();
|
||||||
int failures = 0;
|
int failures = 0;
|
||||||
for(int i = 0; i < 100; ++i) {
|
//for(int i = 0; i < iterations; ++i) {
|
||||||
|
ArrayList<Item> simulatedBooty = new ArrayList<>();
|
||||||
|
if(isZone == false){
|
||||||
|
//simulate individual mob booty
|
||||||
|
simulatedBooty = simulateMobBooty(mob, iterations);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
simulatedBooty = simulateZoneBooty(mob.getParentZone(), iterations);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
mob.loadInventory();
|
for (Item lootItem : simulatedBooty) {
|
||||||
for (Item lootItem : mob.getCharItemManager().getInventory()) {
|
switch (lootItem.getItemBase().getType()) {
|
||||||
ItemBase ib = lootItem.getItemBase();
|
case CONTRACT: //CONTRACT
|
||||||
int ordinal = ib.getType().ordinal();
|
Contracts.add(lootItem);
|
||||||
switch (lootItem.getItemBase().getType()) {
|
break;
|
||||||
case CONTRACT: //CONTRACT
|
case OFFERING: //OFFERING
|
||||||
Contracts.add(lootItem);
|
Offerings.add(lootItem);
|
||||||
break;
|
break;
|
||||||
case OFFERING: //OFFERING
|
case RESOURCE: //RESOURCE
|
||||||
Offerings.add(lootItem);
|
Resources.add(lootItem);
|
||||||
break;
|
break;
|
||||||
case RESOURCE: //RESOURCE
|
case RUNE: //RUNE
|
||||||
Resources.add(lootItem);
|
Runes.add(lootItem);
|
||||||
break;
|
break;
|
||||||
case RUNE: //RUNE
|
case WEAPON: //WEAPON
|
||||||
Runes.add(lootItem);
|
if (lootItem.getItemBase().isGlass()) {
|
||||||
break;
|
GlassItems.add(lootItem);
|
||||||
case WEAPON: //WEAPON
|
} else {
|
||||||
if (lootItem.getItemBase().isGlass()) {
|
OtherDrops.add(lootItem);
|
||||||
GlassItems.add(lootItem);
|
|
||||||
} else {
|
|
||||||
OtherDrops.add(lootItem);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
OtherDrops.add(lootItem);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
OtherDrops.add(lootItem);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
failures++;
|
failures++;
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
output += "GLASS ITEMS DROPPED: " + GlassItems.size() + newline;
|
output += "GLASS ITEMS DROPPED: " + GlassItems.size() + newline;
|
||||||
output += "RESOURCE STACKS DROPPED: " + Resources.size() + newline;
|
output += "RESOURCE STACKS DROPPED: " + Resources.size() + newline;
|
||||||
output += "RUNES DROPPED: " + Runes.size() + newline;
|
output += "RUNES DROPPED: " + Runes.size() + newline;
|
||||||
output += "CONTRACTS DROPPED: " + Contracts.size() + newline;
|
output += "CONTRACTS DROPPED: " + Contracts.size() + newline;
|
||||||
output += "OFFERINGS DROPPED: " + Offerings.size() + newline;
|
output += "OFFERINGS DROPPED: " + Offerings.size() + newline;
|
||||||
output += "OTHERS DROPPED: " + OtherDrops.size() + newline;
|
output += "OTHER ITEMS DROPPED: " + OtherDrops.size() + newline;
|
||||||
output += "FAILED ROLLS: " + failures + newline;
|
output += "FAILED ROLLS: " + failures + newline;
|
||||||
|
|
||||||
|
output += "Glass Drops:" + newline;
|
||||||
|
for(Item glassItem : GlassItems){
|
||||||
|
output += glassItem.getName() + newline;
|
||||||
|
}
|
||||||
|
output += "Rune Drops:" + newline;
|
||||||
|
for(Item runeItem : Runes){
|
||||||
|
output += runeItem.getName() + newline;
|
||||||
|
}
|
||||||
|
output += "Contract Drops:" + newline;
|
||||||
|
for(Item contractItem : Contracts){
|
||||||
|
output += contractItem.getName() + newline;
|
||||||
|
}
|
||||||
|
output += "Resource Drops:" + newline;
|
||||||
|
for(Item resourceItem : Contracts){
|
||||||
|
output += resourceItem.getName() + newline;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,69 +153,33 @@ public class simulateBootyCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String _getHelpString() {
|
protected String _getHelpString() {
|
||||||
return "Gets information on an Object.";
|
return "simulates mob loot X amount of times for mob or zone";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String _getUsageString() {
|
protected String _getUsageString() {
|
||||||
return "' /info targetID'";
|
return "' ./simluatebooty <ITERATIONS> <zone or blank>";
|
||||||
}
|
}
|
||||||
public static ArrayList<MobLoot> SimulateMobLoot(Mob mob){
|
public static ArrayList<Item> simulateMobBooty(Mob mob, int iterations){
|
||||||
ArrayList<MobLoot> outList = new ArrayList<>();
|
ArrayList<Item> producedBooty = new ArrayList<>();
|
||||||
//determine if mob is in hotzone
|
for(int i = 0; i < iterations; ++i) {
|
||||||
boolean inHotzone = ZoneManager.inHotZone(mob.getLoc());
|
mob.loadInventory();
|
||||||
//get multiplier form config manager
|
for (Item lootItem : mob.getCharItemManager().getInventory()) {
|
||||||
float multiplier = Float.parseFloat(ConfigManager.MB_NORMAL_DROP_RATE.getValue());
|
producedBooty.add(lootItem);
|
||||||
if (inHotzone) {
|
}
|
||||||
//if mob is inside hotzone, use the hotzone gold multiplier form the config instead
|
|
||||||
multiplier = Float.parseFloat(ConfigManager.MB_HOTZONE_DROP_RATE.getValue());
|
|
||||||
}
|
}
|
||||||
//simulate loot 100 times
|
return producedBooty;
|
||||||
for(int i = 0; i < 5; ++i) {
|
}
|
||||||
//iterate the booty sets
|
public static ArrayList<Item> simulateZoneBooty(Zone zone, int iterations){
|
||||||
if (mob.getMobBase().bootySet != 0 && NPCManager._bootySetMap.containsKey(mob.getMobBase().bootySet)) {
|
ArrayList<Item> producedBooty = new ArrayList<>();
|
||||||
try {
|
for(Mob mob : zone.zoneMobSet) {
|
||||||
ArrayList<MobLoot> testList = RunBootySet(NPCManager._bootySetMap.get(mob.getMobBase().bootySet), mob, multiplier, inHotzone);
|
for (int i = 0; i < iterations; ++i) {
|
||||||
for (MobLoot lootItem : testList) {
|
mob.loadInventory();
|
||||||
outList.add((lootItem));
|
for (Item lootItem : mob.getCharItemManager().getInventory()) {
|
||||||
}
|
producedBooty.add(lootItem);
|
||||||
}catch(Exception ex){
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return outList;
|
return producedBooty;
|
||||||
}
|
|
||||||
private static ArrayList<MobLoot> RunBootySet(ArrayList<BootySetEntry> entries, Mob mob, float multiplier, boolean inHotzone) {
|
|
||||||
ArrayList<MobLoot> outList = new ArrayList<>();
|
|
||||||
for (BootySetEntry bse : entries) {
|
|
||||||
switch (bse.bootyType) {
|
|
||||||
case "GOLD":
|
|
||||||
|
|
||||||
break;
|
|
||||||
case "LOOT":
|
|
||||||
if (ThreadLocalRandom.current().nextInt(100) <= (bse.dropChance * multiplier)) {
|
|
||||||
//early exit, failed to hit minimum chance roll
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
//iterate the booty tables and add items to mob inventory
|
|
||||||
MobLoot toAdd = getGenTableItem(bse.lootTable, mob);
|
|
||||||
if (toAdd != null) {
|
|
||||||
//mob.getCharItemManager().addItemToInventory(toAdd);
|
|
||||||
outList.add(toAdd);
|
|
||||||
}
|
|
||||||
if (inHotzone) {
|
|
||||||
int lootTableID = bse.lootTable + 1;
|
|
||||||
MobLoot toAddHZ = getGenTableItem(lootTableID, mob);
|
|
||||||
if (toAddHZ != null)
|
|
||||||
//mob.getCharItemManager().addItemToInventory(toAddHZ);
|
|
||||||
outList.add(toAdd);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "ITEM":
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return outList;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user