Browse Source

Equipment slot refactor started.

combat-2
MagicBot 8 months ago
parent
commit
d8d017669a
  1. 2
      src/engine/Enum.java
  2. 6
      src/engine/devcmd/cmds/PrintEquipCmd.java
  3. 41
      src/engine/gameManager/CombatManager.java
  4. 2
      src/engine/gameManager/PowersManager.java
  5. 4
      src/engine/objects/AbstractCharacter.java
  6. 90
      src/engine/objects/CharacterItemManager.java
  7. 33
      src/engine/objects/Item.java
  8. 245
      src/engine/objects/ItemBase.java
  9. 14
      src/engine/objects/ItemTemplate.java
  10. 16
      src/engine/objects/Kit.java
  11. 30
      src/engine/objects/Mob.java
  12. 35
      src/engine/objects/MobEquipment.java
  13. 60
      src/engine/objects/PlayerCharacter.java
  14. 14
      src/engine/objects/Resists.java
  15. 14
      src/engine/server/MBServerStatics.java

2
src/engine/Enum.java

@ -2155,7 +2155,7 @@ public class Enum { @@ -2155,7 +2155,7 @@ public class Enum {
WAREHOUSE
}
public enum ItemEquipSlotType {
public enum EquipSlotType {
NONE,
RHELD,
LHELD,

6
src/engine/devcmd/cmds/PrintEquipCmd.java

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
package engine.devcmd.cmds;
import engine.Enum;
import engine.Enum.GameObjectType;
import engine.devcmd.AbstractDevCmd;
import engine.objects.*;
@ -83,9 +84,10 @@ public class PrintEquipCmd extends AbstractDevCmd { @@ -83,9 +84,10 @@ public class PrintEquipCmd extends AbstractDevCmd {
}
CharacterItemManager cim = ((AbstractCharacter) tar).getCharItemManager();
ConcurrentHashMap<Integer, Item> list = cim.getEquipped();
ConcurrentHashMap<Enum.EquipSlotType, Item> list = cim.getEquipped();
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (Integer slot : list.keySet()) {
for (Enum.EquipSlotType slot : list.keySet()) {
Item item = list.get(slot);
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID());
throwbackInfo(pc, " " + template.item_base_name + ", slot: " + slot);

41
src/engine/gameManager/CombatManager.java

@ -9,7 +9,6 @@ @@ -9,7 +9,6 @@
package engine.gameManager;
import engine.Enum.*;
import engine.exception.MsgSendException;
import engine.job.JobContainer;
import engine.job.JobScheduler;
import engine.jobs.AttackJob;
@ -46,8 +45,8 @@ public enum CombatManager { @@ -46,8 +45,8 @@ public enum CombatManager {
//check my weapon can I do an offhand attack
Item weaponOff = playerCharacter.getCharItemManager().getEquipped().get(MBServerStatics.SLOT_OFFHAND);
Item weaponMain = playerCharacter.getCharItemManager().getEquipped().get(MBServerStatics.SLOT_MAINHAND);
Item weaponOff = playerCharacter.getCharItemManager().getEquipped().get(EquipSlotType.LHELD);
Item weaponMain = playerCharacter.getCharItemManager().getEquipped().get(EquipSlotType.RHELD);
// if you carry something in the offhand thats a weapon you get to swing it
@ -63,12 +62,12 @@ public enum CombatManager { @@ -63,12 +62,12 @@ public enum CombatManager {
//we always swing our mainhand if we are not on timer
JobContainer main = playerCharacter.getTimers().get("Attack" + MBServerStatics.SLOT_MAINHAND);
JobContainer main = playerCharacter.getTimers().get("Attack" + EquipSlotType.RHELD.ordinal());
// no timers on the mainhand, lets submit a job to swing
if (main == null)
CombatManager.createTimer(playerCharacter, MBServerStatics.SLOT_MAINHAND, 1, true); // attack in 0.1 of a second
CombatManager.createTimer(playerCharacter, EquipSlotType.RHELD.ordinal(), 1, true); // attack in 0.1 of a second
/*
only swing offhand if we have a weapon in it or are unarmed in both hands
@ -77,14 +76,14 @@ public enum CombatManager { @@ -77,14 +76,14 @@ public enum CombatManager {
if (swingOffhand) {
JobContainer off = playerCharacter.getTimers().get("Attack" + MBServerStatics.SLOT_OFFHAND);
JobContainer off = playerCharacter.getTimers().get("Attack" + EquipSlotType.LHELD.ordinal());
if (off == null)
CombatManager.createTimer(playerCharacter, MBServerStatics.SLOT_OFFHAND, 1, true); // attack in 0.1 of a second
CombatManager.createTimer(playerCharacter, EquipSlotType.LHELD.ordinal(), 1, true); // attack in 0.1 of a second
}
}
public static void setAttackTarget(PetAttackMsg msg, ClientConnection origin) throws MsgSendException {
public static void setAttackTarget(PetAttackMsg msg, ClientConnection origin) {
PlayerCharacter player;
Mob pet;
@ -150,18 +149,18 @@ public enum CombatManager { @@ -150,18 +149,18 @@ public enum CombatManager {
if (ac == null)
return;
main = ac.getTimers().get("Attack" + MBServerStatics.SLOT_MAINHAND);
off = ac.getTimers().get("Attack" + MBServerStatics.SLOT_OFFHAND);
main = ac.getTimers().get("Attack" + EquipSlotType.RHELD.ordinal());
off = ac.getTimers().get("Attack" + EquipSlotType.LHELD.ordinal());
if (main != null)
JobScheduler.getInstance().cancelScheduledJob(main);
ac.getTimers().remove("Attack" + MBServerStatics.SLOT_MAINHAND);
ac.getTimers().remove("Attack" + EquipSlotType.RHELD.ordinal());
if (off != null)
JobScheduler.getInstance().cancelScheduledJob(off);
ac.getTimers().remove("Attack" + MBServerStatics.SLOT_OFFHAND);
ac.getTimers().remove("Attack" + EquipSlotType.LHELD.ordinal());
ac.setCombatTarget(null);
@ -220,6 +219,8 @@ public enum CombatManager { @@ -220,6 +219,8 @@ public enum CombatManager {
*/
private static int attemptCombat(AbstractCharacter abstractCharacter, int slot) {
EquipSlotType weaponSlot = EquipSlotType.RHELD.values()[slot];
if (abstractCharacter == null)
return 0;
@ -294,7 +295,7 @@ public enum CombatManager { @@ -294,7 +295,7 @@ public enum CombatManager {
if (((PlayerCharacter) abstractCharacter).inSafeZone() || ((PlayerCharacter) target).inSafeZone())
return 0;
if (!(slot == MBServerStatics.SLOT_MAINHAND || slot == MBServerStatics.SLOT_OFFHAND))
if (!(weaponSlot == EquipSlotType.RHELD || weaponSlot == EquipSlotType.LHELD))
return 0;
if (abstractCharacter.getCharItemManager() == null)
@ -302,7 +303,7 @@ public enum CombatManager { @@ -302,7 +303,7 @@ public enum CombatManager {
//get equippment
ConcurrentHashMap<Integer, Item> equipped = abstractCharacter.getCharItemManager().getEquipped();
ConcurrentHashMap<EquipSlotType, Item> equipped = abstractCharacter.getCharItemManager().getEquipped();
boolean hasNoWeapon = false;
if (equipped == null)
@ -328,11 +329,11 @@ public enum CombatManager { @@ -328,11 +329,11 @@ public enum CombatManager {
//no weapon, see if other hand has a weapon
if (!isWeapon)
if (slot == MBServerStatics.SLOT_MAINHAND) {
if (weaponSlot == EquipSlotType.RHELD) {
//make sure offhand has weapon, not shield
Item weaponOff = equipped.get(MBServerStatics.SLOT_OFFHAND);
Item weaponOff = equipped.get(EquipSlotType.RHELD);
if (weaponOff != null) {
ItemBase ib = weaponOff.getItemBase();
@ -345,7 +346,7 @@ public enum CombatManager { @@ -345,7 +346,7 @@ public enum CombatManager {
} else
hasNoWeapon = true;
} else if (equipped.get(MBServerStatics.SLOT_MAINHAND) == null)
} else if (equipped.get(EquipSlotType.RHELD) == null)
return 1; //no need to attack with this hand
//Source can attack.
@ -406,7 +407,7 @@ public enum CombatManager { @@ -406,7 +407,7 @@ public enum CombatManager {
Mob mob = (Mob) abstractCharacter;
if (mob.isPet()) {
attack(abstractCharacter, target, weapon, wb, slot == MBServerStatics.SLOT_MAINHAND);
attack(abstractCharacter, target, weapon, wb, slot == EquipSlotType.RHELD.ordinal());
return 2;
}
}
@ -432,7 +433,7 @@ public enum CombatManager { @@ -432,7 +433,7 @@ public enum CombatManager {
createTimer(abstractCharacter, slot, wepSpeed, true);
}
attack(abstractCharacter, target, weapon, wb, slot == MBServerStatics.SLOT_MAINHAND);
attack(abstractCharacter, target, weapon, wb, slot == EquipSlotType.RHELD.ordinal());
} else
createTimer(abstractCharacter, slot, 5, false); // changed this to half a second to make combat attempts more aggressive than movement sync
@ -1200,7 +1201,7 @@ public enum CombatManager { @@ -1200,7 +1201,7 @@ public enum CombatManager {
pc.setLastTarget(attacker.getObjectType(), attacker.getObjectUUID());
if (target.getTimers() != null)
if (!target.getTimers().containsKey("Attack" + MBServerStatics.SLOT_MAINHAND))
if (!target.getTimers().containsKey("Attack" + EquipSlotType.RHELD.ordinal()))
CombatManager.AttackTarget((PlayerCharacter) target, target.getCombatTarget());
}

2
src/engine/gameManager/PowersManager.java

@ -440,7 +440,7 @@ public enum PowersManager { @@ -440,7 +440,7 @@ public enum PowersManager {
for (PowerPrereq pp : pb.getEquipPrereqs()) {
int slot = pp.mainHand() ? MBServerStatics.SLOT_MAINHAND : MBServerStatics.SLOT_OFFHAND;
EquipSlotType slot = pp.mainHand() ? EquipSlotType.RHELD : EquipSlotType.LHELD;
if (playerCharacter.validEquip(slot, pp.getMessage())) {
passed = true; //should have item in slot

4
src/engine/objects/AbstractCharacter.java

@ -438,7 +438,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -438,7 +438,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
}
//apply item bonuses for equipped items
ConcurrentHashMap<Integer, Item> equip = null;
ConcurrentHashMap<EquipSlotType, Item> equip = null;
if (playerCharacter.charItemManager != null)
equip = playerCharacter.charItemManager.getEquipped();
@ -1770,7 +1770,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -1770,7 +1770,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
}
//apply item bonuses for equipped items
ConcurrentHashMap<Integer, Item> equip = null;
ConcurrentHashMap<EquipSlotType, Item> equip = null;
if (this.charItemManager != null) {
equip = this.charItemManager.getEquipped();

90
src/engine/objects/CharacterItemManager.java

@ -46,7 +46,7 @@ public class CharacterItemManager { @@ -46,7 +46,7 @@ public class CharacterItemManager {
private final ConcurrentHashMap<Integer, Integer> itemIDtoType = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
// Mapping of all items equipped in this Manager
// Key = Item Slot
private final ConcurrentHashMap<Integer, Item> equipped = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private final ConcurrentHashMap<Enum.EquipSlotType, Item> equipped = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private final HashSet<Item> inventory = new HashSet<>();
private final HashSet<Item> bank = new HashSet<>();
private final HashSet<Item> vault = new HashSet<>();
@ -186,8 +186,8 @@ public class CharacterItemManager { @@ -186,8 +186,8 @@ public class CharacterItemManager {
switch (i.containerType) {
case EQUIPPED:
if (this.equipped.containsValue(i) == false) {
this.equipped.put((int) i.getEquipSlot(), i);
addEquipOrder((int) i.getEquipSlot());
this.equipped.put(i.equipSlot, i);
addEquipOrder(i.equipSlot.ordinal());
}
break;
case BANK:
@ -235,7 +235,7 @@ public class CharacterItemManager { @@ -235,7 +235,7 @@ public class CharacterItemManager {
switch (i.containerType) {
case EQUIPPED:
if (this.equipped.containsValue(i) == false)
this.equipped.put((int) i.getEquipSlot(), i);
this.equipped.put(i.equipSlot, i);
break;
case BANK:
if (i.getItemBase().getType().equals(ItemType.GOLD))
@ -927,13 +927,11 @@ public class CharacterItemManager { @@ -927,13 +927,11 @@ public class CharacterItemManager {
return true;
}
byte slot = i.getEquipSlot();
if (this.doesCharOwnThisItem(i.getObjectUUID()) == false)
return false;
// remove it from other lists:
this.remItemFromLists(i, slot);
this.remItemFromLists(i);
this.itemIDtoType.remove(i.getObjectUUID());
calculateWeights();
@ -962,13 +960,11 @@ public class CharacterItemManager { @@ -962,13 +960,11 @@ public class CharacterItemManager {
return false;
}
byte slot = i.getEquipSlot();
if (this.doesCharOwnThisItem(i.getObjectUUID()) == false && this.absCharacter.getObjectType() != GameObjectType.Mob && (i.containerType != Enum.ItemContainerType.FORGE))
return false;
// remove it from other lists:
this.remItemFromLists(i, slot);
this.remItemFromLists(i);
this.itemIDtoType.remove(i.getObjectUUID());
i.junk();
@ -993,7 +989,6 @@ public class CharacterItemManager { @@ -993,7 +989,6 @@ public class CharacterItemManager {
boolean fromEquip = false;
synchronized (this) {
byte slot = i.getEquipSlot();
//Skip if NOT in vault.
if (i.containerType != Enum.ItemContainerType.VAULT)
@ -1019,7 +1014,7 @@ public class CharacterItemManager { @@ -1019,7 +1014,7 @@ public class CharacterItemManager {
return false;
// remove it from other lists:
this.remItemFromLists(i, slot);
this.remItemFromLists(i);
// add to Inventory
this.inventory.add(i);
@ -1040,7 +1035,6 @@ public class CharacterItemManager { @@ -1040,7 +1035,6 @@ public class CharacterItemManager {
}
public synchronized boolean moveItemToBank(Item i) {
byte slot = i.getEquipSlot();
if (this.doesCharOwnThisItem(i.getObjectUUID()) == false)
return false;
@ -1057,7 +1051,7 @@ public class CharacterItemManager { @@ -1057,7 +1051,7 @@ public class CharacterItemManager {
return false;
// remove it from other lists:
this.remItemFromLists(i, slot);
this.remItemFromLists(i);
// add to Bank
this.bank.add(i);
@ -1186,7 +1180,6 @@ public class CharacterItemManager { @@ -1186,7 +1180,6 @@ public class CharacterItemManager {
}
public synchronized boolean moveItemToVault(Item i) {
byte slot = i.getEquipSlot();
// if (this.doesCharOwnThisItem(i.getObjectUUID()) == false)
// return false;
@ -1203,7 +1196,7 @@ public class CharacterItemManager { @@ -1203,7 +1196,7 @@ public class CharacterItemManager {
return false; // NPC's dont have vaults!
// remove it from other lists:
this.remItemFromLists(i, slot);
this.remItemFromLists(i);
// add to Vault
i.addToCache();
@ -1276,13 +1269,14 @@ public class CharacterItemManager { @@ -1276,13 +1269,14 @@ public class CharacterItemManager {
public boolean equipItem(Item i, byte slot) {
synchronized (this) {
byte curSlot = i.getEquipSlot(); // Should be 0
if (this.doesCharOwnThisItem(i.getObjectUUID()) == false && this.absCharacter.getObjectType() != GameObjectType.Mob) {
Logger.error("Doesnt own item");
return false;
}
Enum.EquipSlotType equipSlot = Enum.EquipSlotType.values()[slot];
// Item must be in inventory to equip
if (!this.inventory.contains(i) && this.absCharacter.getObjectType() != GameObjectType.Mob)
return false;
@ -1290,7 +1284,7 @@ public class CharacterItemManager { @@ -1290,7 +1284,7 @@ public class CharacterItemManager {
// make sure player can equip item
if (i.getItemBase() == null)
return false;
if (!i.getItemBase().canEquip(slot, this, absCharacter, i) && this.absCharacter.getObjectType() != GameObjectType.Mob)
if (!i.getItemBase().canEquip(equipSlot, this, absCharacter, i) && this.absCharacter.getObjectType() != GameObjectType.Mob)
return false;
// check to see if item is already there.
@ -1314,13 +1308,14 @@ public class CharacterItemManager { @@ -1314,13 +1308,14 @@ public class CharacterItemManager {
return false;
// remove it from other lists:
this.remItemFromLists(i, slot);
this.remItemFromLists(i);
// add to Equipped
this.equipped.put((int) slot, i);
this.equipped.put(Enum.EquipSlotType.values()[slot], i);
i.addToCache();
addEquipOrder(i.getEquipSlot());
addEquipOrder(slot);
//calculateWeights();
}
@ -1697,9 +1692,9 @@ public class CharacterItemManager { @@ -1697,9 +1692,9 @@ public class CharacterItemManager {
return lootItem;
}
private synchronized void remItemFromLists(Item i, byte slot) {
private synchronized void remItemFromLists(Item i) {
this.equipped.remove((int) slot);
this.equipped.remove(i.equipSlot);
this.vault.remove(i);
this.bank.remove(i);
this.inventory.remove(i);
@ -1858,9 +1853,9 @@ public class CharacterItemManager { @@ -1858,9 +1853,9 @@ public class CharacterItemManager {
return false;
for (int slot : this.equipped.keySet()) {
for (Enum.EquipSlotType slot : this.equipped.keySet()) {
if (slot == MBServerStatics.SLOT_HAIRSTYLE || slot == MBServerStatics.SLOT_BEARDSTYLE)
if (slot == Enum.EquipSlotType.HAIR || slot == Enum.EquipSlotType.BEARD)
continue;
Item item = this.equipped.get(slot);
@ -1872,7 +1867,7 @@ public class CharacterItemManager { @@ -1872,7 +1867,7 @@ public class CharacterItemManager {
}
if (!ItemTemplate.validForSkills(item, pc.getSkills())) {
this.forceToInventory(slot, item, pc, initialized);
this.forceToInventory(slot.ordinal(), item, pc, initialized);
pc.applyBonuses();
}
}
@ -1886,7 +1881,7 @@ public class CharacterItemManager { @@ -1886,7 +1881,7 @@ public class CharacterItemManager {
*
* @return the equipped
*/
public ConcurrentHashMap<Integer, Item> getEquipped() {
public ConcurrentHashMap<Enum.EquipSlotType, Item> getEquipped() {
synchronized (this.equipped) {
return new ConcurrentHashMap<>(this.equipped);
}
@ -1902,9 +1897,9 @@ public class CharacterItemManager { @@ -1902,9 +1897,9 @@ public class CharacterItemManager {
}
if (ret.size() != this.equipped.size())
//missed adding some items, figure out what.
for (int slot : this.equipped.keySet()) {
if (!(this.equipOrder.contains(slot))) {
this.equipOrder.add(slot);
for (Enum.EquipSlotType slot : this.equipped.keySet()) {
if (!(this.equipOrder.contains(slot.ordinal()))) {
this.equipOrder.add(slot.ordinal());
ret.add(this.equipped.get(slot));
}
}
@ -1913,7 +1908,7 @@ public class CharacterItemManager { @@ -1913,7 +1908,7 @@ public class CharacterItemManager {
return ret;
}
public Item getEquipped(int slot) {
public Item getEquipped(Enum.EquipSlotType slot) {
synchronized (this.equipped) {
return this.equipped.get(slot);
}
@ -2282,7 +2277,7 @@ public class CharacterItemManager { @@ -2282,7 +2277,7 @@ public class CharacterItemManager {
}
// remove it from other lists:
this.remItemFromLists(item, (byte) slot);
this.remItemFromLists(item);
// add to Inventory
this.inventory.add(item);
@ -2444,10 +2439,13 @@ public class CharacterItemManager { @@ -2444,10 +2439,13 @@ public class CharacterItemManager {
return;
//verify the item is equipped by this player
int slot = item.getEquipSlot();
Enum.EquipSlotType slot = item.equipSlot;
if (!this.equipped.containsKey(slot))
return;
Item verify = this.equipped.get(slot);
if (verify == null || item.getObjectUUID() != verify.getObjectUUID())
return;
@ -2481,7 +2479,7 @@ public class CharacterItemManager { @@ -2481,7 +2479,7 @@ public class CharacterItemManager {
//send damage item msg to client
PlayerCharacter pc = (PlayerCharacter) this.absCharacter;
ItemHealthUpdateMsg itemHealthUpdateMsg = new ItemHealthUpdateMsg(slot, (float) dur);
ItemHealthUpdateMsg itemHealthUpdateMsg = new ItemHealthUpdateMsg(slot.ordinal(), (float) dur);
Dispatch dispatch = Dispatch.borrow(pc, itemHealthUpdateMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
@ -2490,26 +2488,18 @@ public class CharacterItemManager { @@ -2490,26 +2488,18 @@ public class CharacterItemManager {
//Damage a random piece of armor a specified amount
public void damageRandomArmor(int amount) {
ArrayList<Item> armor = new ArrayList<>();
if (this.equipped.containsKey(MBServerStatics.SLOT_OFFHAND)) {
Item item = this.equipped.get(MBServerStatics.SLOT_OFFHAND);
if (this.equipped.containsKey(Enum.EquipSlotType.LHELD)) {
Item item = this.equipped.get(Enum.EquipSlotType.LHELD);
ItemBase ib = item.getItemBase();
if (ib.isShield())
armor.add(item);
}
if (this.equipped.containsKey(MBServerStatics.SLOT_HELMET))
armor.add(this.equipped.get(MBServerStatics.SLOT_HELMET));
if (this.equipped.containsKey(MBServerStatics.SLOT_CHEST))
armor.add(this.equipped.get(MBServerStatics.SLOT_CHEST));
if (this.equipped.containsKey(MBServerStatics.SLOT_ARMS))
armor.add(this.equipped.get(MBServerStatics.SLOT_ARMS));
if (this.equipped.containsKey(MBServerStatics.SLOT_GLOVES))
armor.add(this.equipped.get(MBServerStatics.SLOT_GLOVES));
if (this.equipped.containsKey(MBServerStatics.SLOT_GLOVES))
armor.add(this.equipped.get(MBServerStatics.SLOT_GLOVES));
if (this.equipped.containsKey(MBServerStatics.SLOT_LEGGINGS))
armor.add(this.equipped.get(MBServerStatics.SLOT_LEGGINGS));
if (this.equipped.containsKey(MBServerStatics.SLOT_FEET))
armor.add(this.equipped.get(MBServerStatics.SLOT_FEET));
for (Item equipment : this.equipped.values())
if (equipment.template.item_type.equals(ItemType.ARMOR))
armor.add(equipment);
if (armor.isEmpty())
return; //nothing to damage

33
src/engine/objects/Item.java

@ -48,7 +48,7 @@ public class Item extends AbstractWorldObject { @@ -48,7 +48,7 @@ public class Item extends AbstractWorldObject {
public int numberOfItems;
public float durabilityCurrent;
public int chargesRemaining;
public byte equipSlot;
public Enum.EquipSlotType equipSlot;
private boolean canDestroy;
private boolean isRandom = false;
private int value;
@ -72,7 +72,7 @@ public class Item extends AbstractWorldObject { @@ -72,7 +72,7 @@ public class Item extends AbstractWorldObject {
this.template = ItemTemplate.itemTemplates.get(templateID);
this.chargesRemaining = this.template.item_initial_charges;
this.durabilityCurrent = this.template.combat_health_full;
this.equipSlot = 0;
this.equipSlot = EquipSlotType.NONE;
this.containerType = ItemContainerType.NONE;
this.numberOfItems = 1;
loadEnchantments();
@ -139,7 +139,7 @@ public class Item extends AbstractWorldObject { @@ -139,7 +139,7 @@ public class Item extends AbstractWorldObject {
this.canDestroy = true;
this.equipSlot = rs.getByte("item_equipSlot");
this.equipSlot = EquipSlotType.values()[rs.getByte("item_equipSlot")];
this.numberOfItems = rs.getInt("item_numberOfItems");
@ -176,7 +176,7 @@ public class Item extends AbstractWorldObject { @@ -176,7 +176,7 @@ public class Item extends AbstractWorldObject {
public static void _serializeForClientMsg(Item item, ByteBufferWriter writer,
boolean includeSlot) {
if (includeSlot)
writer.putInt(item.equipSlot);
writer.putInt(item.equipSlot.ordinal());
writer.putInt(0); // Pad
writer.putInt(item.getItemBase().getUUID());
@ -198,9 +198,11 @@ public class Item extends AbstractWorldObject { @@ -198,9 +198,11 @@ public class Item extends AbstractWorldObject {
}
// Handle Hair / Beard / horns Color.
boolean isHair = (item.equipSlot == (byte) MBServerStatics.SLOT_HAIRSTYLE);
boolean isBeard = (item.equipSlot == (byte) MBServerStatics.SLOT_BEARDSTYLE);
boolean isHair = (item.equipSlot.equals(EquipSlotType.HAIR));
boolean isBeard = (item.equipSlot.equals(EquipSlotType.BEARD));
int itemColor = 0;
if (isHair || isBeard) {
PlayerCharacter pc = PlayerCharacter.getFromCache(item.ownerID);
if (pc != null)
@ -713,11 +715,6 @@ public class Item extends AbstractWorldObject { @@ -713,11 +715,6 @@ public class Item extends AbstractWorldObject {
return canDestroy;
}
public byte getEquipSlot() {
return equipSlot;
}
public int getNumOfItems() {
return this.numberOfItems;
}
@ -850,7 +847,7 @@ public class Item extends AbstractWorldObject { @@ -850,7 +847,7 @@ public class Item extends AbstractWorldObject {
this.ownerType = null;
this.containerType = Enum.ItemContainerType.NONE;
this.equipSlot = MBServerStatics.SLOT_UNEQUIPPED;
this.equipSlot = EquipSlotType.NONE;
}
protected synchronized boolean moveItemToInventory(PlayerCharacter pc) {
@ -974,7 +971,7 @@ public class Item extends AbstractWorldObject { @@ -974,7 +971,7 @@ public class Item extends AbstractWorldObject {
this.ownerID = pc.getObjectUUID();
this.ownerType = OwnerType.PlayerCharacter;
this.containerType = Enum.ItemContainerType.EQUIPPED;
this.equipSlot = slot;
this.equipSlot = EquipSlotType.values()[slot];
return true;
}
@ -992,7 +989,7 @@ public class Item extends AbstractWorldObject { @@ -992,7 +989,7 @@ public class Item extends AbstractWorldObject {
this.ownerID = npc.getObjectUUID();
this.ownerType = OwnerType.Npc;
this.containerType = Enum.ItemContainerType.EQUIPPED;
this.equipSlot = slot;
this.equipSlot = EquipSlotType.values()[slot];
return true;
}
@ -1002,7 +999,7 @@ public class Item extends AbstractWorldObject { @@ -1002,7 +999,7 @@ public class Item extends AbstractWorldObject {
this.ownerID = npc.getObjectUUID();
this.ownerType = OwnerType.Mob;
this.containerType = Enum.ItemContainerType.EQUIPPED;
this.equipSlot = slot;
this.equipSlot = EquipSlotType.values()[slot];
return true;
}
@ -1134,12 +1131,6 @@ public class Item extends AbstractWorldObject { @@ -1134,12 +1131,6 @@ public class Item extends AbstractWorldObject {
return effectNames;
}
public boolean validForItem(long flags) {
if (this.getItemBase() == null)
return false;
return this.getItemBase().validSlotFlag(flags);
}
public boolean validForInventory(ClientConnection origin, PlayerCharacter pc, CharacterItemManager charItemMan) {
if (origin == null || pc == null || charItemMan == null)

245
src/engine/objects/ItemBase.java

@ -13,7 +13,6 @@ import engine.Enum; @@ -13,7 +13,6 @@ import engine.Enum;
import engine.Enum.GameObjectType;
import engine.Enum.ItemType;
import engine.gameManager.DbManager;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
@ -386,7 +385,7 @@ public class ItemBase { @@ -386,7 +385,7 @@ public class ItemBase {
}
public boolean canEquip(int slot, CharacterItemManager itemManager, AbstractCharacter abstractCharacter, Item item) {
public boolean canEquip(Enum.EquipSlotType slot, CharacterItemManager itemManager, AbstractCharacter abstractCharacter, Item item) {
if (itemManager == null || abstractCharacter == null)
return false;
@ -410,244 +409,30 @@ public class ItemBase { @@ -410,244 +409,30 @@ public class ItemBase {
return true; //Mobiles and NPC's don't need to check equip
}
public int getValidSlot() {
int slotValue = 0;
switch (this.type) {
case WEAPON:
if ((this.equipFlag & 1) != 0)
slotValue = MBServerStatics.SLOT_MAINHAND;
else if ((this.equipFlag & 2) != 0)
slotValue = MBServerStatics.SLOT_OFFHAND;
break;
case ARMOR:
if ((this.equipFlag & 2) != 0)
slotValue = MBServerStatics.SLOT_OFFHAND;
else if ((this.equipFlag & 4) != 0)
slotValue = MBServerStatics.SLOT_HELMET;
else if ((this.equipFlag & 8) != 0)
slotValue = MBServerStatics.SLOT_CHEST;
else if ((this.equipFlag & 16) != 0)
slotValue = MBServerStatics.SLOT_ARMS;
else if ((this.equipFlag & 32) != 0)
slotValue = MBServerStatics.SLOT_GLOVES;
else if ((this.equipFlag & 64) != 0)
slotValue = MBServerStatics.SLOT_RING2;
else if ((this.equipFlag & 128) != 0)
slotValue = MBServerStatics.SLOT_RING1;
else if ((this.equipFlag & 256) != 0)
slotValue = MBServerStatics.SLOT_NECKLACE;
else if ((this.equipFlag & 512) != 0)
slotValue = MBServerStatics.SLOT_LEGGINGS;
else if ((this.equipFlag & 1024) != 0)
slotValue = MBServerStatics.SLOT_FEET;
break;
case HAIR:
if (this.equipFlag == 131072)
slotValue = MBServerStatics.SLOT_HAIRSTYLE;
else if (this.equipFlag == 65536)
slotValue = MBServerStatics.SLOT_BEARDSTYLE;
break;
}
return slotValue;
}
public boolean validSlotFlag(long flags) {
boolean validSlot = false;
switch (this.type) {
case WEAPON:
if (this.isMelee())
validSlot = ((flags & 1) != 0);
else if (this.isThrowing())
validSlot = ((flags & 2) != 0);
else if (this.isArchery())
validSlot = ((flags & 4) != 0);
else if (this.isScepter())
validSlot = ((flags & 8) != 0);
else if (this.isStaff())
validSlot = ((flags & 16) != 0);
break;
case JEWELRY:
if (this.isNecklace())
validSlot = ((flags & 2147483648L) != 0L);
else
validSlot = ((flags & 4294967296L) != 0L);
break;
case ARMOR:
if (this.isShield()) {
validSlot = ((flags & 32) != 0);
break;
}
if (this.isClothArmor()) {
if (this.getEquipFlag() == 4) //hood
validSlot = ((flags & 64) != 0);
else if (this.getEquipFlag() == 8) {
if ((restrictFlag & 512) != 0) //Robe
validSlot = ((flags & 128) != 0);
else
validSlot = ((flags & 1024) != 0); //Tunic/Shirt
break;
} else if (this.getEquipFlag() == 16) //Sleeves
validSlot = ((flags & 2048) != 0);
else if (this.getEquipFlag() == 32) //Gloves
validSlot = ((flags & 512) != 0);
else if (this.getEquipFlag() == 512) //Pants
validSlot = ((flags & 4096) != 0);
else if (this.getEquipFlag() == 1024) //Boots
validSlot = ((flags & 256) != 0);
break;
}
if (this.isLightArmor()) {
if (this.getEquipFlag() == 4) //helm
validSlot = ((flags & 8192) != 0);
else if (this.getEquipFlag() == 8) //Chest
validSlot = ((flags & 16384) != 0);
else if (this.getEquipFlag() == 16) //Sleeves
validSlot = ((flags & 32768) != 0);
else if (this.getEquipFlag() == 32) //Gloves
validSlot = ((flags & 65536) != 0);
else if (this.getEquipFlag() == 512) //Pants
validSlot = ((flags & 131072) != 0);
else if (this.getEquipFlag() == 1024) //Boots
validSlot = ((flags & 262144) != 0);
break;
}
if (this.isMediumArmor()) {
if (this.getEquipFlag() == 4) //helm
validSlot = ((flags & 524288) != 0);
else if (this.getEquipFlag() == 8) //Chest
validSlot = ((flags & 1048576) != 0);
else if (this.getEquipFlag() == 16) //Sleeves
validSlot = ((flags & 2097152) != 0);
else if (this.getEquipFlag() == 32) //Gloves
validSlot = ((flags & 4194304) != 0);
else if (this.getEquipFlag() == 512) //Pants
validSlot = ((flags & 8388608) != 0);
else if (this.getEquipFlag() == 1024) //Boots
validSlot = ((flags & 16777216) != 0);
break;
}
if (this.isHeavyArmor())
if (this.getEquipFlag() == 4) //helm
validSlot = ((flags & 33554432) != 0);
else if (this.getEquipFlag() == 8) //Chest
validSlot = ((flags & 67108864) != 0);
else if (this.getEquipFlag() == 16) //Sleeves
validSlot = ((flags & 134217728) != 0);
else if (this.getEquipFlag() == 32) //Gloves
validSlot = ((flags & 268435456) != 0);
else if (this.getEquipFlag() == 512) //Pants
validSlot = ((flags & 536870912) != 0);
else if (this.getEquipFlag() == 1024) //Boots
validSlot = ((flags & 1073741824) != 0);
break;
}
return validSlot;
}
public boolean validForSlot(int slot, ConcurrentHashMap<Integer, Item> equipped, Item item) {
public static boolean validForSlot(Enum.EquipSlotType slot, ConcurrentHashMap<Enum.EquipSlotType, Item> equipped, Item item) {
boolean validSlot = false;
if (equipped == null)
return validSlot;
// Cannot equip an item in a slot already taken
if (equipped.get(slot) != null && equipped.get(slot).equals(item) == false)
return validSlot;
switch (item.getItemBase().type) {
case WEAPON:
// Only two slots available for weapons
if ((slot != MBServerStatics.SLOT_MAINHAND) && (slot != MBServerStatics.SLOT_OFFHAND))
break;
//make sure weapon is valid for slot
if ((slot & this.equipFlag) == 0)
break;
// Two handed weapons take up two slots
if ((this.twoHanded == true) &&
((slot == MBServerStatics.SLOT_OFFHAND && equipped.get(MBServerStatics.SLOT_MAINHAND) != null) ||
(slot == MBServerStatics.SLOT_MAINHAND && equipped.get(MBServerStatics.SLOT_OFFHAND) != null)))
break;
// Validation passed, must be a valid weapon
return false;
validSlot = true;
break;
case JEWELRY:
// Not a valid slot for ring
// Slot is taken
if (this.isRing() &&
((slot != MBServerStatics.SLOT_RING1) && (slot != MBServerStatics.SLOT_RING2)))
break;
if (equipped.get(slot) != null && equipped.get(slot).equals(item) == false)
return false;
// Not a valid slot for necklace
// Two handed weapons take up two slots
if (this.isNecklace() && slot != MBServerStatics.SLOT_NECKLACE)
break;
if ((ItemTemplate.isTwoHanded(item)) &&
((slot == Enum.EquipSlotType.LHELD && equipped.get(Enum.EquipSlotType.RHELD) != null) ||
(slot == Enum.EquipSlotType.RHELD && equipped.get(Enum.EquipSlotType.LHELD) != null)))
return false;
// Passed validation, must be valid bling bling
if (item.template.item_type.equals(ItemType.WEAPON))
if (equipped.get(slot) != null && equipped.get(slot).equals(item) == false)
return false;
validSlot = true;
break;
case ARMOR:
// Invalid slot for armor?
if (slot == MBServerStatics.SLOT_OFFHAND && ((2 & this.equipFlag) == 0))
break;
if (slot == MBServerStatics.SLOT_HELMET && ((4 & this.equipFlag) == 0))
break;
if (slot == MBServerStatics.SLOT_CHEST && ((8 & this.equipFlag) == 0))
break;
if (slot == MBServerStatics.SLOT_ARMS && ((16 & this.equipFlag) == 0))
break;
if (slot == MBServerStatics.SLOT_GLOVES && ((32 & this.equipFlag) == 0))
break;
if (slot == MBServerStatics.SLOT_LEGGINGS && ((512 & this.equipFlag) == 0))
break;
if (slot == MBServerStatics.SLOT_FEET && ((1024 & this.equipFlag) == 0))
break;
// Is slot for this piece already taken?
if (((this.restrictFlag & 2) != 0) && (equipped.get(MBServerStatics.SLOT_OFFHAND) != null) && slot != MBServerStatics.SLOT_OFFHAND)
break;
if (((this.restrictFlag & 4) != 0) && (equipped.get(MBServerStatics.SLOT_HELMET) != null) && slot != MBServerStatics.SLOT_HELMET)
break;
if (((this.restrictFlag & 8) != 0) && (equipped.get(MBServerStatics.SLOT_CHEST) != null) && slot != MBServerStatics.SLOT_CHEST)
break;
if (((this.restrictFlag & 16) != 0) && (equipped.get(MBServerStatics.SLOT_ARMS) != null) && slot != MBServerStatics.SLOT_ARMS)
break;
if (((this.restrictFlag & 32) != 0) && (equipped.get(MBServerStatics.SLOT_GLOVES) != null) && slot != MBServerStatics.SLOT_GLOVES)
break;
if (((this.restrictFlag & 512) != 0) && (equipped.get(MBServerStatics.SLOT_LEGGINGS) != null) && slot != MBServerStatics.SLOT_LEGGINGS)
break;
if (((this.restrictFlag & 1024) != 0) && (equipped.get(MBServerStatics.SLOT_FEET) != null) && slot != MBServerStatics.SLOT_FEET)
break;
// Passed validation. Is a valid armor piece
validSlot = true;
break;
}
return validSlot;
return true;
}
/**

14
src/engine/objects/ItemTemplate.java

@ -40,8 +40,8 @@ public class ItemTemplate { @@ -40,8 +40,8 @@ public class ItemTemplate {
public Enum.ItemType item_type;
public int item_eq_slots_value;
public boolean item_eq_slots_type;
public EnumSet<Enum.ItemEquipSlotType> item_eq_slots_or = EnumSet.noneOf(Enum.ItemEquipSlotType.class);
public EnumSet<Enum.ItemEquipSlotType> item_eq_slots_and = EnumSet.noneOf(Enum.ItemEquipSlotType.class);
public EnumSet<Enum.EquipSlotType> item_eq_slots_or = EnumSet.noneOf(Enum.EquipSlotType.class);
public EnumSet<Enum.EquipSlotType> item_eq_slots_and = EnumSet.noneOf(Enum.EquipSlotType.class);
public boolean item_takeable;
public int item_value;
public int item_wt;
@ -147,13 +147,13 @@ public class ItemTemplate { @@ -147,13 +147,13 @@ public class ItemTemplate {
if (eq_slots_or.isEmpty() == false)
for (Object o : eq_slots_or)
item_eq_slots_or.add(Enum.ItemEquipSlotType.valueOf((String) o));
item_eq_slots_or.add(Enum.EquipSlotType.valueOf((String) o));
JSONArray eq_slots_and = (JSONArray) jsonObject.get("item_eq_slots_and");
if (eq_slots_and.isEmpty() == false)
for (Object o : eq_slots_and)
item_eq_slots_and.add(Enum.ItemEquipSlotType.valueOf((String) o));
item_eq_slots_and.add(Enum.EquipSlotType.valueOf((String) o));
item_takeable = (boolean) jsonObject.get("item_takeable");
item_value = ((Long) jsonObject.get("item_value")).intValue();
@ -370,12 +370,12 @@ public class ItemTemplate { @@ -370,12 +370,12 @@ public class ItemTemplate {
}
public static boolean isTwoHanded(ItemTemplate template) {
public static boolean isTwoHanded(Item item) {
if (!template.item_type.equals(Enum.ItemType.WEAPON))
if (!item.template.item_type.equals(Enum.ItemType.WEAPON))
return false;
return template.item_eq_slots_or.contains(EnumSet.of(Enum.ItemEquipSlotType.LHELD, Enum.ItemEquipSlotType.RHELD));
return item.template.item_eq_slots_and.contains(EnumSet.of(Enum.EquipSlotType.LHELD, Enum.EquipSlotType.RHELD));
}

16
src/engine/objects/Kit.java

@ -9,10 +9,10 @@ @@ -9,10 +9,10 @@
package engine.objects;
import engine.Enum;
import engine.Enum.ItemContainerType;
import engine.Enum.OwnerType;
import engine.gameManager.DbManager;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.net.UnknownHostException;
@ -111,13 +111,13 @@ public class Kit extends AbstractGameObject { @@ -111,13 +111,13 @@ public class Kit extends AbstractGameObject {
* Getters
*/
private static boolean kitItemCreator(PlayerCharacter pc, int itemBase, int slot) {
private static boolean kitItemCreator(PlayerCharacter pc, int itemBase, Enum.EquipSlotType slot) {
Item item = new Item(itemBase);
item.ownerID = pc.getObjectUUID();
item.ownerType = OwnerType.PlayerCharacter;
item.containerType = ItemContainerType.EQUIPPED;
item.equipSlot = (byte) slot;
item.equipSlot = slot;
try {
item = DbManager.ItemQueries.PERSIST(item);
@ -409,15 +409,15 @@ public class Kit extends AbstractGameObject { @@ -409,15 +409,15 @@ public class Kit extends AbstractGameObject {
public void equipPCwithKit(PlayerCharacter pc) {
if (weapon != 0)
kitItemCreator(pc, weapon, MBServerStatics.SLOT_MAINHAND);
kitItemCreator(pc, weapon, Enum.EquipSlotType.RHELD);
if (offhand != 0)
kitItemCreator(pc, offhand, MBServerStatics.SLOT_OFFHAND);
kitItemCreator(pc, offhand, Enum.EquipSlotType.LHELD);
if (chest != 0)
kitItemCreator(pc, chest, MBServerStatics.SLOT_CHEST);
kitItemCreator(pc, chest, Enum.EquipSlotType.CHEST);
if (legs != 0)
kitItemCreator(pc, legs, MBServerStatics.SLOT_LEGGINGS);
kitItemCreator(pc, legs, Enum.EquipSlotType.LEGS);
if (feet != 0)
kitItemCreator(pc, feet, MBServerStatics.SLOT_FEET);
kitItemCreator(pc, feet, Enum.EquipSlotType.FEET);
}
@Override

30
src/engine/objects/Mob.java

@ -1141,17 +1141,17 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed { @@ -1141,17 +1141,17 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
this.rangeHandTwo = 6.5f;
this.speedHandTwo = 20;
if(this.equip.get(MBServerStatics.SLOT_MAINHAND) != null){
if (this.equip.get(EquipSlotType.RHELD) != null) {
//has mainhand weapon to calculate
calculateAtrDamageForWeapon(this.equip.get(MBServerStatics.SLOT_MAINHAND), true);
calculateAtrDamageForWeapon(this.equip.get(EquipSlotType.LHELD), true);
}
if(this.equip.get(MBServerStatics.SLOT_OFFHAND) != null && !this.equip.get(MBServerStatics.SLOT_OFFHAND).getItemBase().isShield()){
if (this.equip.get(EquipSlotType.LHELD) != null && !this.equip.get(EquipSlotType.LHELD).getItemBase().isShield()) {
//has offhand weapon to calculate
calculateAtrDamageForWeapon(this.equip.get(MBServerStatics.SLOT_OFFHAND), false);
calculateAtrDamageForWeapon(this.equip.get(EquipSlotType.LHELD), false);
}
try {
calculateAtrDamageForWeapon(this.equip.get(MBServerStatics.SLOT_MAINHAND), true);
calculateAtrDamageForWeapon(this.equip.get(EquipSlotType.RHELD), true);
} catch (Exception e) {
this.atrHandOne = (short) this.mobBase.getAttackRating();
@ -1163,7 +1163,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed { @@ -1163,7 +1163,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
}
try {
calculateAtrDamageForWeapon(this.equip.get(MBServerStatics.SLOT_OFFHAND), false);
calculateAtrDamageForWeapon(this.equip.get(EquipSlotType.LHELD), false);
} catch (Exception e) {
@ -1177,13 +1177,13 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed { @@ -1177,13 +1177,13 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
try {
float defense = this.mobBase.getDefenseRating();
defense += getShieldDefense(equip.get(MBServerStatics.SLOT_OFFHAND));
defense += getArmorDefense(equip.get(MBServerStatics.SLOT_HELMET));
defense += getArmorDefense(equip.get(MBServerStatics.SLOT_CHEST));
defense += getArmorDefense(equip.get(MBServerStatics.SLOT_ARMS));
defense += getArmorDefense(equip.get(MBServerStatics.SLOT_GLOVES));
defense += getArmorDefense(equip.get(MBServerStatics.SLOT_LEGGINGS));
defense += getArmorDefense(equip.get(MBServerStatics.SLOT_FEET));
defense += getShieldDefense(equip.get(EquipSlotType.LHELD));
defense += getArmorDefense(equip.get(EquipSlotType.HELM));
defense += getArmorDefense(equip.get(EquipSlotType.CHEST));
defense += getArmorDefense(equip.get(EquipSlotType.UPARM));
defense += getArmorDefense(equip.get(EquipSlotType.HANDS));
defense += getArmorDefense(equip.get(EquipSlotType.LEGS));
defense += getArmorDefense(equip.get(EquipSlotType.FEET));
defense += getWeaponDefense(equip);
// TODO add error log here
@ -1220,14 +1220,14 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed { @@ -1220,14 +1220,14 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
private float getWeaponDefense(HashMap<Integer, MobEquipment> equipped) {
MobEquipment weapon = equipped.get(MBServerStatics.SLOT_MAINHAND);
MobEquipment weapon = equipped.get(EquipSlotType.RHELD);
ItemBase wb = null;
CharacterSkill skill, mastery;
float val = 0;
boolean unarmed = false;
if (weapon == null) {
weapon = equipped.get(MBServerStatics.SLOT_OFFHAND);
weapon = equipped.get(EquipSlotType.LHELD);
if (weapon == null)
unarmed = true;

35
src/engine/objects/MobEquipment.java

@ -16,8 +16,6 @@ import engine.powers.EffectsBase; @@ -16,8 +16,6 @@ import engine.powers.EffectsBase;
import engine.powers.poweractions.AbstractPowerAction;
import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.concurrent.atomic.AtomicInteger;
public class MobEquipment extends AbstractGameObject {
@ -58,39 +56,6 @@ public class MobEquipment extends AbstractGameObject { @@ -58,39 +56,6 @@ public class MobEquipment extends AbstractGameObject {
setMagicValue();
}
public MobEquipment(ItemBase itemBase, int slot, int parentID, String pIDString, String sIDString, int pValue, int sValue) {
super(MobEquipment.getNewID());
this.itemBase = itemBase;
this.templateID = this.itemBase.getUUID();
this.template = ItemTemplate.itemTemplates.get(templateID);
this.slot = slot;
this.parentID = parentID;
//add effects
this.prefix = PowersManager.getPowerActionByIDString(pIDString);
this.suffix = PowersManager.getPowerActionByIDString(sIDString);
this.pValue = pValue;
this.sValue = sValue;
this.enchanted = this.prefix == null || this.suffix == null;
setMagicValue();
}
/**
* ResultSet Constructor
*/
public MobEquipment(ResultSet rs) throws SQLException {
super(MobEquipment.getNewID());
int itemBaseID = rs.getInt("ItemID");
this.itemBase = ItemBase.getItemBase(itemBaseID);
this.templateID = this.itemBase.getUUID();
this.template = ItemTemplate.itemTemplates.get(itemBaseID);
this.slot = rs.getInt("slot");
this.parentID = rs.getInt("mobID");
setMagicValue();
}
public MobEquipment(int itemBaseID, float dropChance) {
super(MobEquipment.getNewID());
this.itemBase = ItemBase.getItemBase(itemBaseID);

60
src/engine/objects/PlayerCharacter.java

@ -1196,7 +1196,7 @@ public class PlayerCharacter extends AbstractCharacter { @@ -1196,7 +1196,7 @@ public class PlayerCharacter extends AbstractCharacter {
hair.ownerID = playerCharacter.getObjectUUID();
hair.ownerType = OwnerType.PlayerCharacter;
hair.containerType = ItemContainerType.EQUIPPED;
hair.equipSlot = (byte) MBServerStatics.SLOT_HAIRSTYLE;
hair.equipSlot = EquipSlotType.HAIR;
try {
@ -1208,7 +1208,7 @@ public class PlayerCharacter extends AbstractCharacter { @@ -1208,7 +1208,7 @@ public class PlayerCharacter extends AbstractCharacter {
if (hair == null) {
playerCharacter.deactivateCharacter();
Logger.info("GameObjectManager failed to create Hair:" + hairStyleID + " in Slot:"
+ MBServerStatics.SLOT_HAIRSTYLE);
+ EquipSlotType.HAIR);
return null;
}
}
@ -1219,7 +1219,7 @@ public class PlayerCharacter extends AbstractCharacter { @@ -1219,7 +1219,7 @@ public class PlayerCharacter extends AbstractCharacter {
beard.ownerID = playerCharacter.getObjectUUID();
beard.ownerType = OwnerType.PlayerCharacter;
beard.containerType = ItemContainerType.EQUIPPED;
beard.equipSlot = (byte) MBServerStatics.SLOT_BEARDSTYLE;
beard.equipSlot = EquipSlotType.BEARD;
try {
beard = DbManager.ItemQueries.PERSIST(beard);
@ -1230,7 +1230,7 @@ public class PlayerCharacter extends AbstractCharacter { @@ -1230,7 +1230,7 @@ public class PlayerCharacter extends AbstractCharacter {
if (beard == null) {
playerCharacter.deactivateCharacter();
Logger.info("GameObjectManager failed to create Beard:" + beardStyleID + " in Slot:"
+ MBServerStatics.SLOT_BEARDSTYLE);
+ EquipSlotType.BEARD);
return null;
}
}
@ -2827,7 +2827,7 @@ public class PlayerCharacter extends AbstractCharacter { @@ -2827,7 +2827,7 @@ public class PlayerCharacter extends AbstractCharacter {
}
//called to verify player has correct item equipped for casting.
public boolean validEquip(int slot, String type) {
public boolean validEquip(EquipSlotType slot, String type) {
if (this.charItemManager == null)
return false;
@ -3729,14 +3729,14 @@ public class PlayerCharacter extends AbstractCharacter { @@ -3729,14 +3729,14 @@ public class PlayerCharacter extends AbstractCharacter {
return 1f;
}
ConcurrentHashMap<Integer, Item> equipped = this.charItemManager.getEquipped();
ConcurrentHashMap<EquipSlotType, Item> equipped = this.charItemManager.getEquipped();
float dexPenalty = 0f;
dexPenalty += getDexPenalty(equipped.get(MBServerStatics.SLOT_HELMET));
dexPenalty += getDexPenalty(equipped.get(MBServerStatics.SLOT_CHEST));
dexPenalty += getDexPenalty(equipped.get(MBServerStatics.SLOT_ARMS));
dexPenalty += getDexPenalty(equipped.get(MBServerStatics.SLOT_GLOVES));
dexPenalty += getDexPenalty(equipped.get(MBServerStatics.SLOT_LEGGINGS));
dexPenalty += getDexPenalty(equipped.get(MBServerStatics.SLOT_FEET));
dexPenalty += getDexPenalty(equipped.get(EquipSlotType.HELM));
dexPenalty += getDexPenalty(equipped.get(EquipSlotType.CHEST));
dexPenalty += getDexPenalty(equipped.get(EquipSlotType.UPARM));
dexPenalty += getDexPenalty(equipped.get(EquipSlotType.HANDS));
dexPenalty += getDexPenalty(equipped.get(EquipSlotType.LEGS));
dexPenalty += getDexPenalty(equipped.get(EquipSlotType.FEET));
return (1 - (dexPenalty / 100));
}
@ -3795,7 +3795,7 @@ public class PlayerCharacter extends AbstractCharacter { @@ -3795,7 +3795,7 @@ public class PlayerCharacter extends AbstractCharacter {
this.defenseRating = 0;
return;
}
ConcurrentHashMap<Integer, Item> equipped = this.charItemManager.getEquipped();
ConcurrentHashMap<EquipSlotType, Item> equipped = this.charItemManager.getEquipped();
// // Reset passives
// if (this.bonuses != null) {
@ -3807,8 +3807,8 @@ public class PlayerCharacter extends AbstractCharacter { @@ -3807,8 +3807,8 @@ public class PlayerCharacter extends AbstractCharacter {
// this.bonuses.setBool("Dodge", false);
// }
// calculate atr and damage for each hand
calculateAtrDamageForWeapon(equipped.get(MBServerStatics.SLOT_MAINHAND), true, equipped.get(MBServerStatics.SLOT_OFFHAND));
calculateAtrDamageForWeapon(equipped.get(MBServerStatics.SLOT_OFFHAND), false, equipped.get(MBServerStatics.SLOT_MAINHAND));
calculateAtrDamageForWeapon(equipped.get(EquipSlotType.RHELD), true, equipped.get(EquipSlotType.RHELD));
calculateAtrDamageForWeapon(equipped.get(EquipSlotType.LHELD), false, equipped.get(EquipSlotType.LHELD));
// No Defense while in DeathShroud
if (this.effects != null && this.effects.containsKey("DeathShroud"))
@ -3816,13 +3816,13 @@ public class PlayerCharacter extends AbstractCharacter { @@ -3816,13 +3816,13 @@ public class PlayerCharacter extends AbstractCharacter {
else {
// calculate defense for equipment
float defense = this.statDexCurrent * 2;
defense += getShieldDefense(equipped.get(MBServerStatics.SLOT_OFFHAND));
defense += getArmorDefense(equipped.get(MBServerStatics.SLOT_HELMET));
defense += getArmorDefense(equipped.get(MBServerStatics.SLOT_CHEST));
defense += getArmorDefense(equipped.get(MBServerStatics.SLOT_ARMS));
defense += getArmorDefense(equipped.get(MBServerStatics.SLOT_GLOVES));
defense += getArmorDefense(equipped.get(MBServerStatics.SLOT_LEGGINGS));
defense += getArmorDefense(equipped.get(MBServerStatics.SLOT_FEET));
defense += getShieldDefense(equipped.get(EquipSlotType.LHELD));
defense += getArmorDefense(equipped.get(EquipSlotType.HELM));
defense += getArmorDefense(equipped.get(EquipSlotType.CHEST));
defense += getArmorDefense(equipped.get(EquipSlotType.UPARM));
defense += getArmorDefense(equipped.get(EquipSlotType.HANDS));
defense += getArmorDefense(equipped.get(EquipSlotType.LEGS));
defense += getArmorDefense(equipped.get(EquipSlotType.FEET));
defense += getWeaponDefense(equipped);
if (this.bonuses != null) {
@ -3883,7 +3883,7 @@ public class PlayerCharacter extends AbstractCharacter { @@ -3883,7 +3883,7 @@ public class PlayerCharacter extends AbstractCharacter {
// get skill percentages and min and max damage for weapons
if (noWeapon) {
if (mainHand) {
Item off = this.charItemManager.getEquipped().get(MBServerStatics.SLOT_OFFHAND);
Item off = this.charItemManager.getEquipped().get(EquipSlotType.LHELD);
if (off != null && off.getItemBase() != null && off.getItemBase().getType().equals(ItemType.WEAPON))
this.rangeHandOne = 10 * (1 + (this.statStrBase / 600)); // Set
// to
@ -4114,9 +4114,9 @@ public class PlayerCharacter extends AbstractCharacter { @@ -4114,9 +4114,9 @@ public class PlayerCharacter extends AbstractCharacter {
public void setPassives() {
if (this.bonuses != null) {
ConcurrentHashMap<Integer, Item> equipped = this.charItemManager.getEquipped();
Item off = equipped.get(MBServerStatics.SLOT_OFFHAND);
Item main = equipped.get(MBServerStatics.SLOT_MAINHAND);
ConcurrentHashMap<EquipSlotType, Item> equipped = this.charItemManager.getEquipped();
Item off = equipped.get(EquipSlotType.LHELD);
Item main = equipped.get(EquipSlotType.RHELD);
ItemBase wbMain = null;
ItemBase wbOff = null;
if (main != null)
@ -4186,14 +4186,14 @@ public class PlayerCharacter extends AbstractCharacter { @@ -4186,14 +4186,14 @@ public class PlayerCharacter extends AbstractCharacter {
/**
* @ Calculates Defense for weapon
*/
private float getWeaponDefense(ConcurrentHashMap<Integer, Item> equipped) {
Item weapon = equipped.get(MBServerStatics.SLOT_MAINHAND);
private float getWeaponDefense(ConcurrentHashMap<EquipSlotType, Item> equipped) {
Item weapon = equipped.get(EquipSlotType.RHELD);
ItemBase wb = null;
CharacterSkill skill, mastery;
float val = 0;
boolean unarmed = false;
if (weapon == null) {
weapon = equipped.get(MBServerStatics.SLOT_OFFHAND);
weapon = equipped.get(EquipSlotType.LHELD);
if (weapon == null || weapon.getItemBase().isShield())
unarmed = true;
else
@ -4246,7 +4246,7 @@ public class PlayerCharacter extends AbstractCharacter { @@ -4246,7 +4246,7 @@ public class PlayerCharacter extends AbstractCharacter {
public void calculateItemBonuses() {
if (this.charItemManager == null || this.bonuses == null)
return;
ConcurrentHashMap<Integer, Item> equipped = this.charItemManager.getEquipped();
ConcurrentHashMap<EquipSlotType, Item> equipped = this.charItemManager.getEquipped();
for (Item item : equipped.values()) {
ItemBase ib = item.getItemBase();
if (ib == null)

14
src/engine/objects/Resists.java

@ -402,15 +402,15 @@ public class Resists { @@ -402,15 +402,15 @@ public class Resists {
if (ac.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
if (ac.getCharItemManager() != null && ac.getCharItemManager().getEquipped() != null) {
float[] phys = {0f, 0f, 0f};
ConcurrentHashMap<Integer, Item> equip = ac.getCharItemManager().getEquipped();
ConcurrentHashMap<Enum.EquipSlotType, Item> equip = ac.getCharItemManager().getEquipped();
// get base physical resists
phys = Resists.getArmorResists(equip.get(MBServerStatics.SLOT_HELMET), phys);
phys = Resists.getArmorResists(equip.get(MBServerStatics.SLOT_CHEST), phys);
phys = Resists.getArmorResists(equip.get(MBServerStatics.SLOT_ARMS), phys);
phys = Resists.getArmorResists(equip.get(MBServerStatics.SLOT_GLOVES), phys);
phys = Resists.getArmorResists(equip.get(MBServerStatics.SLOT_LEGGINGS), phys);
phys = Resists.getArmorResists(equip.get(MBServerStatics.SLOT_FEET), phys);
phys = Resists.getArmorResists(equip.get(Enum.EquipSlotType.HELM), phys);
phys = Resists.getArmorResists(equip.get(Enum.EquipSlotType.CHEST), phys);
phys = Resists.getArmorResists(equip.get(Enum.EquipSlotType.UPARM), phys);
phys = Resists.getArmorResists(equip.get(Enum.EquipSlotType.HANDS), phys);
phys = Resists.getArmorResists(equip.get(Enum.EquipSlotType.LEGS), phys);
phys = Resists.getArmorResists(equip.get(Enum.EquipSlotType.FEET), phys);
slash += phys[0];
crush += phys[1];
pierce += phys[2];

14
src/engine/server/MBServerStatics.java

@ -139,20 +139,6 @@ public class MBServerStatics { @@ -139,20 +139,6 @@ public class MBServerStatics {
public static final int STAT_CON_ID = 0xB15DC77E;
public static final int STAT_DEX_ID = 0xE07B3336;
public static final int STAT_INT_ID = 0xFF665EC3;
public static final int SLOT_UNEQUIPPED = 0;
public static final int SLOT_MAINHAND = 1;
public static final int SLOT_OFFHAND = 2;
public static final int SLOT_HELMET = 3;
public static final int SLOT_CHEST = 4;
public static final int SLOT_ARMS = 5;
public static final int SLOT_GLOVES = 6;
public static final int SLOT_RING1 = 7;
public static final int SLOT_RING2 = 8;
public static final int SLOT_NECKLACE = 9;
public static final int SLOT_LEGGINGS = 10;
public static final int SLOT_FEET = 11;
public static final int SLOT_HAIRSTYLE = 18; // 17 & 18? Weird.
public static final int SLOT_BEARDSTYLE = 17; // 17 & 18? Weird.
/*
* Group Formation Names
*/

Loading…
Cancel
Save