Browse Source

Mobtype work related to ForgeManager

combat-2
MagicBot 7 months ago
parent
commit
a8d5521dd8
  1. 51
      src/engine/gameManager/ForgeManager.java
  2. 2
      src/engine/objects/Item.java

51
src/engine/gameManager/ForgeManager.java

@ -8,15 +8,19 @@
package engine.gameManager; package engine.gameManager;
import engine.loot.ModTableEntry;
import engine.loot.ModTypeTableEntry;
import engine.loot.WorkOrder; import engine.loot.WorkOrder;
import engine.mbEnums; import engine.mbEnums;
import engine.objects.*; import engine.objects.*;
import engine.powers.EffectsBase; import engine.powers.EffectsBase;
import engine.powers.poweractions.AbstractPowerAction;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.util.HashMap; import java.util.HashMap;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
import java.util.concurrent.DelayQueue; import java.util.concurrent.DelayQueue;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -254,12 +258,22 @@ public enum ForgeManager implements Runnable {
public static Item forgeItem(WorkOrder workOrder) { public static Item forgeItem(WorkOrder workOrder) {
ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID);
Item forgedItem = new Item(workOrder.templateID); Item forgedItem = new Item(workOrder.templateID);
forgedItem.objectUUID = MobLoot.lastNegativeID.getAndDecrement(); forgedItem.objectUUID = MobLoot.lastNegativeID.getAndDecrement();
forgedItem.containerType = mbEnums.ItemContainerType.FORGE; forgedItem.containerType = mbEnums.ItemContainerType.FORGE;
forgedItem.ownerID = workOrder.vendor.getObjectUUID(); forgedItem.ownerID = workOrder.vendor.getObjectUUID();
forgedItem.setDateToUpgrade(workOrder.completionTime); forgedItem.setDateToUpgrade(workOrder.completionTime);
// Give prefix and suffix to this item if random rolled
if (workOrder.prefixToken == 0)
forgedItem.prefixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.PREFIX, template.modTable);
if (workOrder.suffixToken == 0)
forgedItem.suffixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.SUFFIX, template.modTable);
// Forged random rolled items are unidentified until completed // Forged random rolled items are unidentified until completed
if (workOrder.prefixToken == 0 && workOrder.suffixToken == 0) if (workOrder.prefixToken == 0 && workOrder.suffixToken == 0)
@ -282,14 +296,39 @@ public enum ForgeManager implements Runnable {
} }
} }
public static void calsRandomModType(NPC vendor, mbEnums.ItemModType itemModType, Item item) { public static int calcRandomMod(NPC vendor, mbEnums.ItemModType itemModType, int modTable) {
int modifier = 0;
ModTypeTableEntry modTypeTableEntry = null;
ModTableEntry modRollEntry = null;
int modifierRoll;
switch (itemModType) {
case PREFIX:
modifier = vendor.getModTypeTable().get(vendor.getItemModTable().indexOf(modTable));
modTypeTableEntry = ModTypeTableEntry.rollTable(modifier, ThreadLocalRandom.current().nextInt(1, 100 + 1));
break;
case SUFFIX:
modifier = vendor.getModSuffixTable().get(vendor.getItemModTable().indexOf(modTable));
modTypeTableEntry = ModTypeTableEntry.rollTable(modifier, ThreadLocalRandom.current().nextInt(1, 100 + 1));
break;
}
if (modTypeTableEntry == null)
return 0;
int modifier; modifierRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1);
if (itemModType.equals(mbEnums.ItemModType.PREFIX)) if (modifierRoll < 80) {
modifier = vendor.getModTypeTable().get(vendor.getItemModTable().indexOf(item.template.modTable)); modifierRoll = LootManager.TableRoll(vendor.getLevel(), false);
else modRollEntry = ModTableEntry.rollTable(modTypeTableEntry.modTableID, modifierRoll);
modifier = vendor.getModTypeTable().get(vendor.getItemModTable().indexOf(item.template.modTable)); }
if (modRollEntry != null) {
AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(modRollEntry.action);
modifier = abstractPowerAction.getEffectsBase().getToken();
}
return modifier;
} }
} }

2
src/engine/objects/Item.java

@ -59,6 +59,8 @@ public class Item extends AbstractWorldObject {
public int magicValue; public int magicValue;
public ItemTemplate template; public ItemTemplate template;
public String name = ""; public String name = "";
public int prefixToken; // Forge support
public int suffixToken; // Forge support
/** /**
* In Memory constructor * In Memory constructor

Loading…
Cancel
Save