Browse Source

Refactor item_type

combat-2
MagicBot 8 months ago
parent
commit
df5c607375
  1. 127
      src/engine/Enum.java
  2. 4
      src/engine/db/handlers/dbItemHandler.java
  3. 4
      src/engine/devcmd/cmds/SimulateBootyCmd.java
  4. 8
      src/engine/gameManager/CombatManager.java
  5. 4
      src/engine/gameManager/LootManager.java
  6. 6
      src/engine/gameManager/PowersManager.java
  7. 12
      src/engine/net/client/ClientMessagePump.java
  8. 4
      src/engine/net/client/handlers/ActivateNPCMsgHandler.java
  9. 9
      src/engine/net/client/handlers/GuildCreationFinalizeHandler.java
  10. 14
      src/engine/net/client/handlers/ItemProductionMsgHandler.java
  11. 33
      src/engine/net/client/handlers/ObjectActionMsgHandler.java
  12. 2
      src/engine/net/client/msg/BuyFromNPCWindowMsg.java
  13. 2
      src/engine/net/client/msg/UpdateInventoryMsg.java
  14. 2
      src/engine/net/client/msg/UseCharterMsg.java
  15. 43
      src/engine/objects/CharacterItemManager.java
  16. 6
      src/engine/objects/Item.java
  17. 23
      src/engine/objects/ItemBase.java
  18. 4
      src/engine/objects/ItemFactory.java
  19. 4
      src/engine/objects/Mob.java
  20. 5
      src/engine/objects/MobLoot.java
  21. 4
      src/engine/objects/NPC.java
  22. 14
      src/engine/objects/PlayerCharacter.java
  23. 2
      src/engine/objects/Warehouse.java
  24. 2
      src/engine/powers/poweractions/StealPowerAction.java

127
src/engine/Enum.java

@ -15,7 +15,7 @@ import engine.gameManager.ZoneManager;
import engine.math.Vector2f; import engine.math.Vector2f;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.objects.AbstractCharacter; import engine.objects.AbstractCharacter;
import engine.objects.ItemBase; import engine.objects.Item;
import engine.objects.Shrine; import engine.objects.Shrine;
import engine.objects.Zone; import engine.objects.Zone;
import engine.powers.EffectsBase; import engine.powers.EffectsBase;
@ -560,94 +560,47 @@ public class Enum {
} }
} }
// Enum for ItemBase flags // Enum for ItemBase flags
public enum ItemType { public enum ItemType {
UNKNOWN(0), DECORATION,
WEAPON(1), WEAPON,
ARMOR(2), ARMOR,
BASE(3), BASE,
GOLD(4), GOLD,
SCROLL(5), SCROLL,
BOOK(6), BOOK,
WAND(7), WAND,
POTION(8), POTION,
KEY(9), KEY,
CHARTER(10), CHARTER,
GUILDTREE(11), GUILDTREE,
SOUNDSOURCE(12), SOUNDSOURCE,
JEWELRY(13), JEWELRY,
CONTAINER(14), CONTAINER,
FOUNTAIN(15), FOUNTAIN,
FOOD(16), FOOD,
DRINKCONTAINER(17), DRINKCONTAINER,
MAPMARKER(18), MAPMARKER,
DEED(19), DEED,
EMPLOYMENTCONTRACT(20), EMPLOYMENTCONTRACT,
PETTOTEM(21), PETTOTEM,
SLAVECOLLAR(22), SLAVECOLLAR,
BLANKKEY(23), BLANKKEY,
WARRANT(24), WARRANT,
FURNITUREDEED(25), FURNITUREDEED,
TENT(26), TENT,
REAGENT(27), REAGENT,
DEVICE(28), DEVICE,
FORMULA(29), FORMULA,
BUCKET(30), BUCKET,
TREASURE(31), TREASURE,
RUNE(32), RUNE,
OFFERING(33), OFFERING,
RESOURCE(34), RESOURCE,
REALMCHARTER(35), REALMCHARTER;
// old itembase support
DECORATION(0),
HAIR(3),
COMMANDROD(7),
TEARS(8),
GUILDCHARTER(10),
WINE(16),
ALEJUG(17),
CONTRACT(20),
PET(21),
FURNITURE(25),
BEDROLL(26),
FARMABLE(27),
WATERBUCKET(30),
GIFT(31);
private final static HashMap<Integer, ItemType> _typeLookup = new HashMap<>();
private final int _value;
ItemType(int value) {
this._value = value;
}
public static ItemType getByValue(int value) {
ItemType outType = ItemType.DECORATION;
if (_typeLookup.isEmpty()) {
for (ItemType itemType : ItemType.values()) {
_typeLookup.put(itemType._value, itemType);
}
}
if (_typeLookup.containsKey(value))
outType = _typeLookup.get(value);
return outType;
}
/**
* @return the _value
*/
public int getValue() {
return _value;
} }
}
// Enum to derive effects for active spires from blueprintUUID // Enum to derive effects for active spires from blueprintUUID
public enum SpireType { public enum SpireType {
@ -2493,16 +2446,16 @@ public class Enum {
this.sexRequired = sexRequired; this.sexRequired = sexRequired;
} }
public static GuildCharterType getGuildTypeFromCharter(ItemBase itemBase) { public static GuildCharterType getGuildTypeFromCharter(Item charter) {
GuildCharterType charterType; GuildCharterType charterType;
// Must be a valid charter object // Must be a valid charter object
if (itemBase.getType().equals(ItemType.GUILDCHARTER) == false) if (charter.template.item_type.equals(ItemType.CHARTER) == false)
return GuildCharterType.NONE; //No guild Type return GuildCharterType.NONE; //No guild Type
switch (itemBase.getUUID()) { switch (charter.template.template_id) {
case 559: case 559:
charterType = GuildCharterType.CATHEDRAL; charterType = GuildCharterType.CATHEDRAL;

4
src/engine/db/handlers/dbItemHandler.java

@ -294,7 +294,7 @@ public class dbItemHandler extends dbHandlerBase {
for (Item item : inventory) { for (Item item : inventory) {
if (item.getItemBase().getType().equals(ItemType.GOLD)) if (item.template.item_type.equals(ItemType.GOLD))
continue; continue;
try (Connection connection = DbManager.getConnection(); try (Connection connection = DbManager.getConnection();
@ -438,7 +438,7 @@ public class dbItemHandler extends dbHandlerBase {
*/ */
public boolean UPDATE_GOLD(final Item item, int newValue, int oldValue) { public boolean UPDATE_GOLD(final Item item, int newValue, int oldValue) {
if (!item.getItemBase().getType().equals(ItemType.GOLD)) if (!item.template.item_type.equals(ItemType.GOLD))
return false; return false;
try (Connection connection = DbManager.getConnection(); try (Connection connection = DbManager.getConnection();

4
src/engine/devcmd/cmds/SimulateBootyCmd.java

@ -57,8 +57,8 @@ public class SimulateBootyCmd extends AbstractDevCmd {
try { try {
mob.loadInventory(); mob.loadInventory();
for (Item lootItem : mob.getCharItemManager().getInventory()) { for (Item lootItem : mob.getCharItemManager().getInventory()) {
switch (lootItem.getItemBase().getType()) { switch (lootItem.template.item_type) {
case CONTRACT: //CONTRACT case EMPLOYMENTCONTRACT: //CONTRACT
Contracts.add(lootItem); Contracts.add(lootItem);
break; break;
case OFFERING: //OFFERING case OFFERING: //OFFERING

8
src/engine/gameManager/CombatManager.java

@ -51,7 +51,7 @@ public enum CombatManager {
// if you carry something in the offhand thats a weapon you get to swing it // if you carry something in the offhand thats a weapon you get to swing it
if (weaponOff != null) if (weaponOff != null)
if (weaponOff.getItemBase().getType().equals(ItemType.WEAPON)) if (weaponOff.template.item_type.equals(ItemType.WEAPON))
swingOffhand = true; swingOffhand = true;
// if you carry nothing in either hand you get to swing your offhand // if you carry nothing in either hand you get to swing your offhand
@ -320,7 +320,7 @@ public enum CombatManager {
else { else {
ItemBase ib = weapon.getItemBase(); ItemBase ib = weapon.getItemBase();
if (ib == null || !ib.getType().equals(ItemType.WEAPON)) if (ib == null || !weapon.template.item_type.equals(ItemType.WEAPON))
isWeapon = false; isWeapon = false;
else else
wb = ib; wb = ib;
@ -338,7 +338,7 @@ public enum CombatManager {
if (weaponOff != null) { if (weaponOff != null) {
ItemBase ib = weaponOff.getItemBase(); ItemBase ib = weaponOff.getItemBase();
if (ib == null || !ib.getType().equals(ItemType.WEAPON)) if (ib == null || !weaponOff.template.item_type.equals(ItemType.WEAPON))
hasNoWeapon = true; hasNoWeapon = true;
else else
return 1; //no need to attack with this hand return 1; //no need to attack with this hand
@ -904,7 +904,7 @@ public enum CombatManager {
if (ib == null) if (ib == null)
return false; return false;
if (ib.getType().equals(ItemType.WEAPON) == false) if (item.template.item_type.equals(ItemType.WEAPON) == false)
return false; return false;
return ib.getRange() > MBServerStatics.RANGED_WEAPON_RANGE; return ib.getRange() > MBServerStatics.RANGED_WEAPON_RANGE;

4
src/engine/gameManager/LootManager.java

@ -175,14 +175,12 @@ public enum LootManager {
if (itemUUID == 0) if (itemUUID == 0)
return null; return null;
if (ItemBase.getItemBase(itemUUID).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) { if (ItemTemplate.itemTemplates.get(itemUUID).item_type.equals(Enum.ItemType.RESOURCE)) {
int amount = ThreadLocalRandom.current().nextInt(tableRow.minSpawn, tableRow.maxSpawn + 1); int amount = ThreadLocalRandom.current().nextInt(tableRow.minSpawn, tableRow.maxSpawn + 1);
return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false); return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false);
} }
outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false);
Enum.ItemType outType = outItem.getItemBase().getType();
if(selectedRow.pModTable != 0){ if(selectedRow.pModTable != 0){
try { try {

6
src/engine/gameManager/PowersManager.java

@ -2502,12 +2502,12 @@ public enum PowersManager {
if (pb.targetItem()) if (pb.targetItem())
return true; return true;
// TODO add these checks later // TODO add these checks later
else if (pb.targetArmor() && item.getItemBase().getType().equals(ItemType.ARMOR)) else if (pb.targetArmor() && item.template.item_type.equals(ItemType.ARMOR))
return true; return true;
else if (pb.targetJewelry() && item.getItemBase().getType().equals(ItemType.JEWELRY)) else if (pb.targetJewelry() && item.template.item_type.equals(ItemType.JEWELRY))
return true; return true;
else else
return pb.targetWeapon() && item.getItemBase().getType().equals(ItemType.WEAPON); return pb.targetWeapon() && item.template.item_type.equals(ItemType.WEAPON);
} // How did we get here? all valid targets have been covered } // How did we get here? all valid targets have been covered
else else
return false; return false;

12
src/engine/net/client/ClientMessagePump.java

@ -219,7 +219,7 @@ public class ClientMessagePump implements NetMsgHandler {
return; return;
if (item.containerType == ItemContainerType.INVENTORY && itemManager.isBankOpen()) if (item.containerType == ItemContainerType.INVENTORY && itemManager.isBankOpen())
if (item.getItemBase().getType().equals(engine.Enum.ItemType.GOLD)) { if (item.template.item_type.equals(engine.Enum.ItemType.GOLD)) {
if (!itemManager.moveGoldToBank(item, msg.getNumItems())) if (!itemManager.moveGoldToBank(item, msg.getNumItems()))
return; return;
UpdateGoldMsg goldMes = new UpdateGoldMsg(player); UpdateGoldMsg goldMes = new UpdateGoldMsg(player);
@ -274,7 +274,7 @@ public class ClientMessagePump implements NetMsgHandler {
if (item.containerType == ItemContainerType.BANK && itemManager.isBankOpen() == false) if (item.containerType == ItemContainerType.BANK && itemManager.isBankOpen() == false)
return; return;
if (item.getItemBase().getType().equals(engine.Enum.ItemType.GOLD)) { if (item.template.item_type.equals(engine.Enum.ItemType.GOLD)) {
if (!itemManager.moveGoldToInventory(item, msg.getNumItems())) if (!itemManager.moveGoldToInventory(item, msg.getNumItems()))
return; return;
@ -738,7 +738,7 @@ public class ClientMessagePump implements NetMsgHandler {
return; return;
if (item.getItemBase().getType().equals(engine.Enum.ItemType.GOLD)) { if (item.template.item_type.equals(engine.Enum.ItemType.GOLD)) {
// this is done to prevent the temporary goldItem item // this is done to prevent the temporary goldItem item
// (from the mob) from appearing in player's inventory. // (from the mob) from appearing in player's inventory.
// It also updates the goldItem quantity display // It also updates the goldItem quantity display
@ -769,7 +769,7 @@ public class ClientMessagePump implements NetMsgHandler {
//TODO send group loot message if player is grouped and visible //TODO send group loot message if player is grouped and visible
Group group = GroupManager.getGroup(player); Group group = GroupManager.getGroup(player);
if (group != null && group.getSplitGold() && (item.getItemBase().getType().equals(engine.Enum.ItemType.GOLD) == false)) { if (group != null && group.getSplitGold() && (item.template.item_type.equals(engine.Enum.ItemType.GOLD) == false)) {
String name = item.getName(); String name = item.getName();
String text = player.getFirstName() + " has looted " + name + '.'; String text = player.getFirstName() + " has looted " + name + '.';
ChatManager.chatGroupInfoCanSee(player, text); ChatManager.chatGroupInfoCanSee(player, text);
@ -787,7 +787,7 @@ public class ClientMessagePump implements NetMsgHandler {
return; return;
} }
if (item.getItemBase().getType().equals(engine.Enum.ItemType.GOLD)) { if (item.template.item_type.equals(engine.Enum.ItemType.GOLD)) {
// this is done to prevent the temporary goldItem item // this is done to prevent the temporary goldItem item
// (from the mob) from appearing in player's inventory. // (from the mob) from appearing in player's inventory.
// It also updates the goldItem quantity display // It also updates the goldItem quantity display
@ -826,7 +826,7 @@ public class ClientMessagePump implements NetMsgHandler {
//TODO send group loot message if player is grouped and visible //TODO send group loot message if player is grouped and visible
Group group = GroupManager.getGroup(player); Group group = GroupManager.getGroup(player);
if (group != null && group.getSplitGold() && (item.getItemBase().getType().equals(engine.Enum.ItemType.GOLD) == false)) { if (group != null && group.getSplitGold() && (item.template.item_type.equals(engine.Enum.ItemType.GOLD) == false)) {
String name = item.getName(); String name = item.getName();
String text = player.getFirstName() + " has looted " + name + '.'; String text = player.getFirstName() + " has looted " + name + '.';
ChatManager.chatGroupInfoCanSee(player, text); ChatManager.chatGroupInfoCanSee(player, text);

4
src/engine/net/client/handlers/ActivateNPCMsgHandler.java

@ -48,9 +48,9 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler {
// Filter hirelings by slot type // Filter hirelings by slot type
for (Item hirelings : player.getInventory()) { for (Item hirelings : player.getInventory()) {
if (hirelings.getItemBase().getType().equals(ItemType.CONTRACT)) { if (hirelings.template.item_type.equals(ItemType.EMPLOYMENTCONTRACT)) {
contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.getItemBase().getUUID()); contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.templsteID);
if (contract == null) if (contract == null)
continue; continue;

9
src/engine/net/client/handlers/GuildCreationFinalizeHandler.java

@ -28,7 +28,6 @@ import engine.net.client.msg.guild.GuildCreationFinalizeMsg;
import engine.net.client.msg.guild.GuildInfoMsg; import engine.net.client.msg.guild.GuildInfoMsg;
import engine.objects.Guild; import engine.objects.Guild;
import engine.objects.Item; import engine.objects.Item;
import engine.objects.ItemBase;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
import engine.util.StringUtils; import engine.util.StringUtils;
@ -46,7 +45,7 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler {
Enum.GuildCharterType charterType; Enum.GuildCharterType charterType;
Guild newGuild; Guild newGuild;
Guild playerGuild; Guild playerGuild;
ItemBase itemBase;
Item charter; Item charter;
Dispatch dispatch; Dispatch dispatch;
@ -69,16 +68,14 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler {
return true; return true;
} }
itemBase = charter.getItemBase();
// Item must be a valid charterType (type 10 in db) // Item must be a valid charterType (type 10 in db)
if (itemBase == null || (itemBase.getType().equals(ItemType.GUILDCHARTER) == false)) { if (charter == null || (charter.template.item_type.equals(ItemType.CHARTER) == false)) {
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND); ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
return true; return true;
} }
charterType = Enum.GuildCharterType.getGuildTypeFromCharter(itemBase); charterType = Enum.GuildCharterType.getGuildTypeFromCharter(charter);
if (charterType == null) { if (charterType == null) {
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND); ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);

14
src/engine/net/client/handlers/ItemProductionMsgHandler.java

@ -126,7 +126,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
if (targetItem == null) if (targetItem == null)
return; return;
if (targetItem.getItemBase().getType() == ItemType.GOLD) if (targetItem.template.item_type.equals(ItemType.GOLD))
return; return;
if (!vendor.getCharItemManager().hasRoomInventory(targetItem.template.item_wt)) { if (!vendor.getCharItemManager().hasRoomInventory(targetItem.template.item_wt)) {
@ -266,7 +266,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
if (targetItem == null) if (targetItem == null)
continue; continue;
if (targetItem.getItemBase().getType() == ItemType.GOLD) if (targetItem.template.item_type.equals(ItemType.GOLD))
return; return;
if (!vendor.getCharItemManager().doesCharOwnThisItem(targetItem.getObjectUUID())) if (!vendor.getCharItemManager().doesCharOwnThisItem(targetItem.getObjectUUID()))
@ -281,13 +281,13 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
break; break;
} }
switch (targetItem.getItemBase().getType()) { switch (targetItem.template.item_type) {
case CONTRACT: case EMPLOYMENTCONTRACT:
case GUILDCHARTER: case CHARTER:
case DEED: case DEED:
case REALMCHARTER: case REALMCHARTER:
case SCROLL: case SCROLL:
case TEARS: case POTION:
itemValue = 0; itemValue = 0;
continue; continue;
} }
@ -402,7 +402,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
return; return;
if (targetItem.getItemBase().getType() == ItemType.GOLD) if (targetItem.template.item_type.equals(ItemType.GOLD))
return; return;
if (vendor.getCharItemManager().inventoryContains(targetItem) == false) if (vendor.getCharItemManager().inventoryContains(targetItem) == false)
return; return;

33
src/engine/net/client/handlers/ObjectActionMsgHandler.java

@ -315,18 +315,13 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
if (itemMan.doesCharOwnThisItem(item.getObjectUUID())) { if (itemMan.doesCharOwnThisItem(item.getObjectUUID())) {
if (ib.isConsumable() || ib.getType() == ItemType.FARMABLE) { if (ib.isConsumable() || item.template.item_type.equals(ItemType.REAGENT)) {
int uuid = ib.getUUID(); int uuid = item.templsteID;
int type = ib.getType().getValue();
switch (type) { switch (item.template.item_type) {
case 27: //Mithril repair
break; case DEED: //buildings
case 10: //charters
//don't think they're handled here?
break;
case 19: //buildings
//Call add building screen here, ib.getUseID() get's building ID //Call add building screen here, ib.getUseID() get's building ID
//if inside player city, center loc on tol. otherwise center on player. //if inside player city, center loc on tol. otherwise center on player.
@ -352,10 +347,10 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
//itemMan.consume(item); //temporary fix for dupe.. TODO Make Item Unusable after This message is sent. //itemMan.consume(item); //temporary fix for dupe.. TODO Make Item Unusable after This message is sent.
break; break;
case 25: //furniture case FURNITUREDEED: //furniture
//Call add furniture screen here. ib.getUseID() get's furniture ID //Call add furniture screen here. ib.getUseID() get's furniture ID
break; break;
case 33: case OFFERING:
long shrineCompID = comps.get(1); long shrineCompID = comps.get(1);
Building shrineBuilding = BuildingManager.getBuilding((int) shrineCompID); Building shrineBuilding = BuildingManager.getBuilding((int) shrineCompID);
if (shrineBuilding == null) { if (shrineBuilding == null) {
@ -381,7 +376,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
} }
break; break;
case 35: case REALMCHARTER:
int charterType = 0; int charterType = 0;
switch (uuid) { switch (uuid) {
case 910020: case 910020:
@ -398,7 +393,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
itemMan.consume(item); itemMan.consume(item);
} }
break; break;
case 7: //rod of command case WAND: //rod of command
long compID = comps.get(1); long compID = comps.get(1);
int objectType = AbstractWorldObject.extractTypeID(compID).ordinal(); int objectType = AbstractWorldObject.extractTypeID(compID).ordinal();
@ -422,7 +417,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
} }
break; break;
//ANNIVERSERY GIFT //ANNIVERSERY GIFT
case 31: case TREASURE:
// *** Disabled for now: Needs bootyset created // *** Disabled for now: Needs bootyset created
//if (ib.getUUID() == 971012) { //if (ib.getUUID() == 971012) {
@ -440,13 +435,13 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
// break; // break;
//} //}
LootManager.peddleFate(player,item); LootManager.peddleFate(player, item);
break; break;
case 30: //water bucket case BUCKET: //water bucket
case 8: //potions, tears of saedron case POTION: //potions, tears of saedron
case 5: //runes, petition, warrant, scrolls case SCROLL: //runes, petition, warrant, scrolls
if (uuid > 3000 && uuid < 3050) { //Discipline Runes if (uuid > 3000 && uuid < 3050) { //Discipline Runes
if (ApplyRuneMsg.applyRune(uuid, origin, player)) { if (ApplyRuneMsg.applyRune(uuid, origin, player)) {
itemMan.consume(item); itemMan.consume(item);

2
src/engine/net/client/msg/BuyFromNPCWindowMsg.java

@ -162,7 +162,7 @@ public class BuyFromNPCWindowMsg extends ClientNetMsg {
for (Item item : inventory) { for (Item item : inventory) {
if (item.getOwnerID() != ownerID) if (item.getOwnerID() != ownerID)
continue; continue;
if (item.getItemBase().getType().equals(ItemType.GOLD)) { if (item.template.item_type.equals(ItemType.GOLD)) {
if (item.getNumOfItems() == 0) if (item.getNumOfItems() == 0)
continue; continue;
} }

2
src/engine/net/client/msg/UpdateInventoryMsg.java

@ -54,7 +54,7 @@ public class UpdateInventoryMsg extends ClientNetMsg {
for (Item item : list) { for (Item item : list) {
if (item.getItemBase().getType().equals(ItemType.GOLD)) { if (item.template.item_type.equals(ItemType.GOLD)) {
if (item.getNumOfItems() == 0) if (item.getNumOfItems() == 0)
continue; continue;
} }

2
src/engine/net/client/msg/UseCharterMsg.java

@ -63,7 +63,7 @@ public class UseCharterMsg extends ClientNetMsg {
if (close) { if (close) {
for (Item i : player.getInventory()) { for (Item i : player.getInventory()) {
if (i.getItemBase().getType().equals(ItemType.GUILDCHARTER)) { if (i.template.item_type.equals(ItemType.CHARTER)) {
charterUUID = i.getObjectUUID(); charterUUID = i.getObjectUUID();
break; break;
} }

43
src/engine/objects/CharacterItemManager.java

@ -191,19 +191,19 @@ public class CharacterItemManager {
} }
break; break;
case BANK: case BANK:
if (i.getItemBase().getType().equals(ItemType.GOLD)) if (i.template.item_type.equals(ItemType.GOLD))
this.goldBank = i; this.goldBank = i;
else if (this.bank.contains(i) == false) else if (this.bank.contains(i) == false)
this.bank.add(i); this.bank.add(i);
break; break;
case INVENTORY: case INVENTORY:
if (i.getItemBase().getType().equals(ItemType.GOLD)) if (i.template.item_type.equals(ItemType.GOLD))
this.goldInventory = i; this.goldInventory = i;
else if (this.inventory.contains(i) == false) else if (this.inventory.contains(i) == false)
this.inventory.add(i); this.inventory.add(i);
break; break;
case VAULT: case VAULT:
if (i.getItemBase().getType().equals(ItemType.GOLD)) if (i.template.item_type.equals(ItemType.GOLD))
this.goldVault = i; this.goldVault = i;
else if (this.vault.contains(i) == false) else if (this.vault.contains(i) == false)
this.vault.add(i); this.vault.add(i);
@ -238,13 +238,13 @@ public class CharacterItemManager {
this.equipped.put(i.equipSlot, i); this.equipped.put(i.equipSlot, i);
break; break;
case BANK: case BANK:
if (i.getItemBase().getType().equals(ItemType.GOLD)) if (i.template.item_type.equals(ItemType.GOLD))
this.goldBank = i; this.goldBank = i;
else if (this.bank.contains(i) == false) else if (this.bank.contains(i) == false)
this.bank.add(i); this.bank.add(i);
break; break;
case INVENTORY: case INVENTORY:
if (i.getItemBase().getType().equals(ItemType.GOLD)) if (i.template.item_type.equals(ItemType.GOLD))
this.goldInventory = i; this.goldInventory = i;
else if (this.inventory.contains(i) == false) else if (this.inventory.contains(i) == false)
this.inventory.add(i); this.inventory.add(i);
@ -915,7 +915,7 @@ public class CharacterItemManager {
if (i == null) if (i == null)
return false; return false;
if (i.getItemBase().getType().equals(ItemType.GOLD)) { if (i.template.item_type.equals(ItemType.GOLD)) {
if (this.getGoldInventory() != null) { if (this.getGoldInventory() != null) {
if (i.getObjectUUID() == this.getGoldInventory().getObjectUUID()) if (i.getObjectUUID() == this.getGoldInventory().getObjectUUID())
this.goldInventory = null; this.goldInventory = null;
@ -945,7 +945,7 @@ public class CharacterItemManager {
} }
private synchronized boolean junk(Item i, boolean updateInventory) { private synchronized boolean junk(Item i, boolean updateInventory) {
if (i.getItemBase().getType().equals(ItemType.GOLD)) { if (i.template.item_type.equals(ItemType.GOLD)) {
if (this.getGoldInventory().getObjectUUID() == i.getObjectUUID()) if (this.getGoldInventory().getObjectUUID() == i.getObjectUUID())
if (DbManager.ItemQueries.UPDATE_GOLD(i, 0)) { if (DbManager.ItemQueries.UPDATE_GOLD(i, 0)) {
this.getGoldInventory().setNumOfItems(0); this.getGoldInventory().setNumOfItems(0);
@ -1000,8 +1000,7 @@ public class CharacterItemManager {
if (equippedContains(item)) { if (equippedContains(item)) {
fromEquip = true; fromEquip = true;
ItemBase ib = item.getItemBase(); if (item.template.item_type.equals(ItemType.GOLD))
if (ib != null && ib.getType().equals(ItemType.GOLD))
this.absCharacter.cancelOnUnEquip(); this.absCharacter.cancelOnUnEquip();
} }
@ -1211,7 +1210,7 @@ public class CharacterItemManager {
// This removes ingame item from inventory for loot. // This removes ingame item from inventory for loot.
private synchronized boolean removeItemFromInventory(Item i) { private synchronized boolean removeItemFromInventory(Item i) {
if (i.getItemBase().getType().equals(ItemType.GOLD)) { if (i.template.item_type.equals(ItemType.GOLD)) {
if (i.getObjectUUID() != this.getGoldInventory().getObjectUUID()) if (i.getObjectUUID() != this.getGoldInventory().getObjectUUID())
return false; return false;
if (!DbManager.ItemQueries.UPDATE_GOLD(this.goldInventory, 0)) { if (!DbManager.ItemQueries.UPDATE_GOLD(this.goldInventory, 0)) {
@ -1234,7 +1233,7 @@ public class CharacterItemManager {
// This adds item to inventory for loot. Validity checks already handled // This adds item to inventory for loot. Validity checks already handled
public synchronized boolean addItemToInventory(Item i) { public synchronized boolean addItemToInventory(Item i) {
if (i.getItemBase().getType().equals(ItemType.GOLD)) if (i.template.item_type.equals(ItemType.GOLD))
if (this.absCharacter.getObjectType() == GameObjectType.Mob) { if (this.absCharacter.getObjectType() == GameObjectType.Mob) {
if (this.goldInventory == null) if (this.goldInventory == null)
loadGoldItems(); loadGoldItems();
@ -1261,7 +1260,7 @@ public class CharacterItemManager {
//called for adding gold of a specified amount //called for adding gold of a specified amount
public synchronized boolean addItemToInventory(Item i, int amount) { public synchronized boolean addItemToInventory(Item i, int amount) {
if (i.getItemBase().getType().equals(ItemType.GOLD)) if (i.template.item_type.equals(ItemType.GOLD))
return DbManager.ItemQueries.UPDATE_GOLD(this.getGoldInventory(), this.goldInventory.getNumOfItems() + amount); return DbManager.ItemQueries.UPDATE_GOLD(this.getGoldInventory(), this.goldInventory.getNumOfItems() + amount);
return false; return false;
} }
@ -1623,9 +1622,9 @@ public class CharacterItemManager {
synchronized (lockFirst) { synchronized (lockFirst) {
synchronized (lockSecond) { synchronized (lockSecond) {
// make sure current player has item in inventory // make sure current player has item in inventory
if (lootItem.getItemBase().getType().equals(ItemType.GOLD) && lootItem.getObjectUUID() != this.getGoldInventory().getObjectUUID() && !(this.absCharacter.getObjectType().equals(GameObjectType.Mob))) if (lootItem.template.item_type.equals(ItemType.GOLD) && lootItem.getObjectUUID() != this.getGoldInventory().getObjectUUID() && !(this.absCharacter.getObjectType().equals(GameObjectType.Mob)))
return null; return null;
else if (!this.inventory.contains(lootItem) && !this.getEquippedList().contains(lootItem) && !lootItem.getItemBase().getType().equals(ItemType.GOLD)) else if (!this.inventory.contains(lootItem) && !this.getEquippedList().contains(lootItem) && !lootItem.template.item_type.equals(ItemType.GOLD))
return null; return null;
// get weight of item // get weight of item
@ -1636,10 +1635,10 @@ public class CharacterItemManager {
int weight = lootItem.template.item_wt; int weight = lootItem.template.item_wt;
// make sure lootingPlayer has room for item // make sure lootingPlayer has room for item
if (!lootItem.getItemBase().getType().equals(ItemType.GOLD) && !looterItems.hasRoomInventory(weight)) if (!lootItem.template.item_type.equals(ItemType.GOLD) && !looterItems.hasRoomInventory(weight))
return null; return null;
if (lootItem.getItemBase().getType().equals(ItemType.GOLD)) if (lootItem.template.item_type.equals(ItemType.GOLD))
if (amount != -1) { //from steal if (amount != -1) { //from steal
int total = lootItem.getNumOfItems(); int total = lootItem.getNumOfItems();
amount = (amount > total) ? total : amount; amount = (amount > total) ? total : amount;
@ -1702,25 +1701,25 @@ public class CharacterItemManager {
* Delegates * Delegates
*/ */
public synchronized boolean bankContains(Item i) { public synchronized boolean bankContains(Item i) {
if (i.getItemBase().getType().equals(ItemType.GOLD)) if (i.template.item_type.equals(ItemType.GOLD))
return (this.getGoldBank() != null && this.goldBank.getObjectUUID() == i.getObjectUUID()); return (this.getGoldBank() != null && this.goldBank.getObjectUUID() == i.getObjectUUID());
return bank.contains(i); return bank.contains(i);
} }
public synchronized boolean inventoryContains(Item i) { public synchronized boolean inventoryContains(Item i) {
if (i.getItemBase().getType().equals(ItemType.GOLD)) if (i.template.item_type.equals(ItemType.GOLD))
return (this.getGoldInventory() != null && this.goldInventory.getObjectUUID() == i.getObjectUUID()); return (this.getGoldInventory() != null && this.goldInventory.getObjectUUID() == i.getObjectUUID());
return inventory.contains(i); return inventory.contains(i);
} }
public synchronized boolean forgeContains(Item i, NPC vendor) { public synchronized boolean forgeContains(Item i, NPC vendor) {
if (i.getItemBase().getType().equals(ItemType.GOLD)) if (i.template.item_type.equals(ItemType.GOLD))
return (this.getGoldInventory() != null && this.goldInventory.getObjectUUID() == i.getObjectUUID()); return (this.getGoldInventory() != null && this.goldInventory.getObjectUUID() == i.getObjectUUID());
return vendor.getRolling().contains(i); return vendor.getRolling().contains(i);
} }
public synchronized boolean vaultContains(Item i) { public synchronized boolean vaultContains(Item i) {
if (i.getItemBase().getType().equals(ItemType.GOLD)) if (i.template.item_type.equals(ItemType.GOLD))
return (this.getGoldVault() != null && this.goldVault.getObjectUUID() == i.getObjectUUID()); return (this.getGoldVault() != null && this.goldVault.getObjectUUID() == i.getObjectUUID());
return this.account.getVault().contains(i); return this.account.getVault().contains(i);
} }
@ -2004,13 +2003,13 @@ public class CharacterItemManager {
item.zeroItem(); item.zeroItem();
item.containerType = Enum.ItemContainerType.INVENTORY; item.containerType = Enum.ItemContainerType.INVENTORY;
if (item.getItemBase().getType().equals(ItemType.GOLD)) if (item.template.item_type.equals(ItemType.GOLD))
//only add gold item once //only add gold item once
if (!corpse.hasGold()) if (!corpse.hasGold())
corpse.setHasGold(true); corpse.setHasGold(true);
newInventory.add(item); newInventory.add(item);
} else //item } else //item
if (item.getItemBase().getType().equals(ItemType.GOLD)) { if (item.template.item_type.equals(ItemType.GOLD)) {
int amt = item.getNumOfItems(); int amt = item.getNumOfItems();
item.setNumOfItems(0); item.setNumOfItems(0);
MobLoot ml = new MobLoot(this.absCharacter, amt); MobLoot ml = new MobLoot(this.absCharacter, amt);

6
src/engine/objects/Item.java

@ -280,7 +280,7 @@ public class Item extends AbstractWorldObject {
writer.put((byte) 0); writer.put((byte) 0);
if (item.getItemBase().getType().getValue() != 20) { if (item.template.item_type.equals(ItemType.EMPLOYMENTCONTRACT) == false) {
writer.putShort((short) 0); writer.putShort((short) 0);
return; return;
} }
@ -459,7 +459,7 @@ public class Item extends AbstractWorldObject {
int serialized = 0; int serialized = 0;
for (Item item : list) { for (Item item : list) {
if (item.getItemBase().getType().equals(ItemType.GOLD)) if (item.template.item_type.equals(ItemType.GOLD))
if (item.numberOfItems == 0) if (item.numberOfItems == 0)
continue; continue;
try { try {
@ -493,7 +493,7 @@ public class Item extends AbstractWorldObject {
int serialized = 0; int serialized = 0;
for (Item item : list) { for (Item item : list) {
if (item.getItemBase().getType().equals(ItemType.GOLD)) if (item.template.item_type.equals(ItemType.GOLD))
if (item.numberOfItems == 0) if (item.numberOfItems == 0)
continue; continue;
try { try {

23
src/engine/objects/ItemBase.java

@ -30,8 +30,6 @@ public class ItemBase {
private static final ArrayList<ItemBase> _resourceList = new ArrayList<>(); private static final ArrayList<ItemBase> _resourceList = new ArrayList<>();
public final int uuid; public final int uuid;
//requirements/restrictions
private final ItemType type;
private final int modTable; private final int modTable;
private final int useID; private final int useID;
private int hashID; private int hashID;
@ -61,8 +59,6 @@ public class ItemBase {
public ItemBase(ResultSet rs) throws SQLException { public ItemBase(ResultSet rs) throws SQLException {
this.uuid = rs.getInt("ID"); this.uuid = rs.getInt("ID");
this.type = ItemType.valueOf(rs.getString("Type"));
this.useID = rs.getInt("useID"); this.useID = rs.getInt("useID");
this.useAmount = rs.getByte("useAmount"); this.useAmount = rs.getByte("useAmount");
this.modTable = rs.getInt("modTable"); this.modTable = rs.getInt("modTable");
@ -84,18 +80,17 @@ public class ItemBase {
this.twoHanded = (rs.getInt("twoHanded") == 1); this.twoHanded = (rs.getInt("twoHanded") == 1);
switch (this.type) { switch (ItemTemplate.itemTemplates.get(this.getUUID()).item_type) {
case RUNE: case RUNE:
case SCROLL: case SCROLL:
case COMMANDROD: case WAND:
case POTION: case POTION:
case TEARS: case CHARTER:
case GUILDCHARTER:
case DEED: case DEED:
case CONTRACT: case EMPLOYMENTCONTRACT:
case WATERBUCKET: case BUCKET:
case REALMCHARTER: case REALMCHARTER:
case GIFT: case TREASURE:
this.isConsumable = true; this.isConsumable = true;
break; break;
case OFFERING: case OFFERING:
@ -118,7 +113,7 @@ public class ItemBase {
_itemBaseByUUID.put(itemBase.uuid, itemBase); _itemBaseByUUID.put(itemBase.uuid, itemBase);
if (itemBase.type.equals(ItemType.RESOURCE)) if (ItemTemplate.itemTemplates.get(itemBase.uuid).item_type.equals(ItemType.RESOURCE))
_resourceList.add(itemBase); _resourceList.add(itemBase);
ItemTemplate template = ItemTemplate.itemTemplates.get(itemBase.uuid); ItemTemplate template = ItemTemplate.itemTemplates.get(itemBase.uuid);
@ -225,10 +220,6 @@ public class ItemBase {
} }
public ItemType getType() {
return this.type;
}
public int getUseID() { public int getUseID() {
return this.useID; return this.useID;
} }

4
src/engine/objects/ItemFactory.java

@ -220,7 +220,7 @@ public class ItemFactory {
int suffixCost = 0; int suffixCost = 0;
if (ib.getType() == ItemType.WEAPON && ib.getPercentRequired() == 110) { if (template.item_type.equals(ItemType.WEAPON) && ib.getPercentRequired() == 110) {
switch (ib.getSkillRequired()) { switch (ib.getSkillRequired()) {
case "Bow": case "Bow":
case "Crossbow": case "Crossbow":
@ -814,7 +814,7 @@ public class ItemFactory {
int galvorAmount = 0; int galvorAmount = 0;
int wormwoodAmount = 0; int wormwoodAmount = 0;
if (ib.getType() == ItemType.WEAPON && ib.getPercentRequired() == 110) { if (template.item_type.equals(ItemType.WEAPON) && ib.getPercentRequired() == 110) {
switch (ib.getSkillRequired()) { switch (ib.getSkillRequired()) {
case "Bow": case "Bow":
case "Crossbow": case "Crossbow":

4
src/engine/objects/Mob.java

@ -1295,7 +1295,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
if (ib == null) if (ib == null)
return 0; return 0;
if (!ib.getType().equals(ItemType.ARMOR)) if (!armor.template.item_type.equals(ItemType.ARMOR))
return 0; return 0;
if (ib.getSkillRequired().isEmpty()) if (ib.getSkillRequired().isEmpty())
@ -1334,7 +1334,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
if (ib == null) if (ib == null)
noWeapon = true; noWeapon = true;
else if (ib.getType().equals(ItemType.WEAPON) == false) { else if (weapon.template.item_type.equals(ItemType.WEAPON) == false) {
defaultAtrAndDamage(mainHand); defaultAtrAndDamage(mainHand);
return; return;
} else } else

5
src/engine/objects/MobLoot.java

@ -69,7 +69,7 @@ public final class MobLoot extends Item {
this.ownerID = mob.getObjectUUID(); this.ownerID = mob.getObjectUUID();
this.objectUUID = generateId(); this.objectUUID = generateId();
if (quantity == 0 && ib.getType() == ItemType.RESOURCE) if (quantity == 0 && ItemTemplate.itemTemplates.get(ib.getUUID()).item_type == ItemType.RESOURCE)
quantity = 1; quantity = 1;
if (quantity > 0) if (quantity > 0)
@ -129,10 +129,9 @@ public final class MobLoot extends Item {
if (isDeleted) if (isDeleted)
return null; return null;
if (this.getItemBase().getType().equals(ItemType.GOLD)) if (this.template.item_type.equals(ItemType.GOLD))
return null; return null;
Item item = (Item) this; Item item = (Item) this;
item.setOwner(looter); item.setOwner(looter);

4
src/engine/objects/NPC.java

@ -1070,7 +1070,7 @@ public class NPC extends AbstractCharacter {
ItemBase itemBase; ItemBase itemBase;
for (Integer itemID : fullItemList) { for (Integer itemID : fullItemList) {
itemBase = ItemBase.getItemBase(itemID); itemBase = ItemBase.getItemBase(itemID);
boolean exclude = itemBase.getPercentRequired() == 0 && itemBase.getType() == ItemType.WEAPON; boolean exclude = itemBase.getPercentRequired() == 0 && ItemTemplate.itemTemplates.get(itemID).item_type == ItemType.WEAPON;
if (itemBase.getPercentRequired() <= maxSkill && !exclude) if (itemBase.getPercentRequired() <= maxSkill && !exclude)
filteredItemList.add(itemID); filteredItemList.add(itemID);
} }
@ -1095,7 +1095,7 @@ public class NPC extends AbstractCharacter {
if (ib == null) if (ib == null)
return 0; return 0;
if (ib.getType() == ItemType.SCROLL) if (ItemTemplate.itemTemplates.get(itemID).item_type == ItemType.SCROLL)
return this.getRank() * 60 * 60 * 3; return this.getRank() * 60 * 60 * 3;
float time; float time;

14
src/engine/objects/PlayerCharacter.java

@ -2840,11 +2840,11 @@ public class PlayerCharacter extends AbstractCharacter {
ItemBase ib = item.getItemBase(); ItemBase ib = item.getItemBase();
if (ib != null) { if (ib != null) {
if ((ib.getType().equals(ItemType.WEAPON)) if ((item.template.item_type.equals(ItemType.WEAPON))
&& (ib.getSkillRequired().equals(type) || ib.getMastery().equals(type))) && (ib.getSkillRequired().equals(type) || ib.getMastery().equals(type)))
return true; return true;
return (ib.getType().equals(ItemType.ARMOR)) return (item.template.item_type.equals(ItemType.ARMOR))
&& (ib.getSkillRequired().equals(type)); && (ib.getSkillRequired().equals(type));
} }
@ -3865,7 +3865,7 @@ public class PlayerCharacter extends AbstractCharacter {
ItemBase ib = weapon.getItemBase(); ItemBase ib = weapon.getItemBase();
if (ib == null) if (ib == null)
noWeapon = true; noWeapon = true;
else if (!ib.getType().equals(ItemType.WEAPON)) { else if (!weapon.template.item_type.equals(ItemType.WEAPON)) {
defaultAtrAndDamage(mainHand); defaultAtrAndDamage(mainHand);
return; return;
} else } else
@ -3884,7 +3884,7 @@ public class PlayerCharacter extends AbstractCharacter {
if (noWeapon) { if (noWeapon) {
if (mainHand) { if (mainHand) {
Item off = this.charItemManager.getEquipped().get(EquipSlotType.LHELD); Item off = this.charItemManager.getEquipped().get(EquipSlotType.LHELD);
if (off != null && off.getItemBase() != null && off.getItemBase().getType().equals(ItemType.WEAPON)) if (off != null && off.getItemBase() != null && off.template.item_type.equals(ItemType.WEAPON))
this.rangeHandOne = 10 * (1 + (this.statStrBase / 600)); // Set this.rangeHandOne = 10 * (1 + (this.statStrBase / 600)); // Set
// to // to
// no // no
@ -4026,7 +4026,7 @@ public class PlayerCharacter extends AbstractCharacter {
//if duel wielding, cut damage by 30% //if duel wielding, cut damage by 30%
if (otherHand != null) { if (otherHand != null) {
ItemBase ibo = otherHand.getItemBase(); ItemBase ibo = otherHand.getItemBase();
if (ibo != null && ibo.getType().equals(ItemType.WEAPON)) { if (ibo != null && otherHand.template.equals(ItemType.WEAPON)) {
min *= 0.7f; min *= 0.7f;
max *= 0.7f; max *= 0.7f;
} }
@ -4171,10 +4171,12 @@ public class PlayerCharacter extends AbstractCharacter {
if (ib == null) if (ib == null)
return 0; return 0;
if (!ib.getType().equals(ItemType.ARMOR)) if (!armor.template.item_type.equals(ItemType.ARMOR))
return 0; return 0;
if (ib.getSkillRequired().isEmpty()) if (ib.getSkillRequired().isEmpty())
return ib.getDefense(); return ib.getDefense();
CharacterSkill armorSkill = this.skills.get(ib.getSkillRequired()); CharacterSkill armorSkill = this.skills.get(ib.getSkillRequired());
if (armorSkill == null) { if (armorSkill == null) {
Logger.error("Player " + this.getObjectUUID() Logger.error("Player " + this.getObjectUUID()

2
src/engine/objects/Warehouse.java

@ -341,7 +341,7 @@ public class Warehouse extends AbstractWorldObject {
Resource resourceType; Resource resourceType;
if (resource.getItemBase().getType().equals(Enum.ItemType.GOLD)) if (resource.template.item_type.equals(Enum.ItemType.GOLD))
resourceType = Resource.GOLD; resourceType = Resource.GOLD;
else else
resourceType = Resource.valueOf(ItemTemplate.itemTemplates.get(resource.getTemplsteID()).item_base_name.toUpperCase()); resourceType = Resource.valueOf(ItemTemplate.itemTemplates.get(resource.getTemplsteID()).item_base_name.toUpperCase());

2
src/engine/powers/poweractions/StealPowerAction.java

@ -156,7 +156,7 @@ public class StealPowerAction extends AbstractPowerAction {
if (myCIM == null || ownerCIM == null) if (myCIM == null || ownerCIM == null)
return; return;
if (tar.getItemBase().getType().equals(ItemType.GOLD)) { if (tar.template.item_type.equals(ItemType.GOLD)) {
//stealing gold //stealing gold
if (!myCIM.transferGoldToMyInventory((AbstractCharacter) owner, amount)) if (!myCIM.transferGoldToMyInventory((AbstractCharacter) owner, amount))
return; return;

Loading…
Cancel
Save