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; @@ -15,7 +15,7 @@ import engine.gameManager.ZoneManager;
import engine.math.Vector2f;
import engine.math.Vector3fImmutable;
import engine.objects.AbstractCharacter;
import engine.objects.ItemBase;
import engine.objects.Item;
import engine.objects.Shrine;
import engine.objects.Zone;
import engine.powers.EffectsBase;
@ -560,94 +560,47 @@ public class Enum { @@ -560,94 +560,47 @@ public class Enum {
}
}
// Enum for ItemBase flags
public enum ItemType {
UNKNOWN(0),
WEAPON(1),
ARMOR(2),
BASE(3),
GOLD(4),
SCROLL(5),
BOOK(6),
WAND(7),
POTION(8),
KEY(9),
CHARTER(10),
GUILDTREE(11),
SOUNDSOURCE(12),
JEWELRY(13),
CONTAINER(14),
FOUNTAIN(15),
FOOD(16),
DRINKCONTAINER(17),
MAPMARKER(18),
DEED(19),
EMPLOYMENTCONTRACT(20),
PETTOTEM(21),
SLAVECOLLAR(22),
BLANKKEY(23),
WARRANT(24),
FURNITUREDEED(25),
TENT(26),
REAGENT(27),
DEVICE(28),
FORMULA(29),
BUCKET(30),
TREASURE(31),
RUNE(32),
OFFERING(33),
RESOURCE(34),
REALMCHARTER(35),
// 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;
DECORATION,
WEAPON,
ARMOR,
BASE,
GOLD,
SCROLL,
BOOK,
WAND,
POTION,
KEY,
CHARTER,
GUILDTREE,
SOUNDSOURCE,
JEWELRY,
CONTAINER,
FOUNTAIN,
FOOD,
DRINKCONTAINER,
MAPMARKER,
DEED,
EMPLOYMENTCONTRACT,
PETTOTEM,
SLAVECOLLAR,
BLANKKEY,
WARRANT,
FURNITUREDEED,
TENT,
REAGENT,
DEVICE,
FORMULA,
BUCKET,
TREASURE,
RUNE,
OFFERING,
RESOURCE,
REALMCHARTER;
}
}
// Enum to derive effects for active spires from blueprintUUID
public enum SpireType {
@ -2493,16 +2446,16 @@ public class Enum { @@ -2493,16 +2446,16 @@ public class Enum {
this.sexRequired = sexRequired;
}
public static GuildCharterType getGuildTypeFromCharter(ItemBase itemBase) {
public static GuildCharterType getGuildTypeFromCharter(Item charter) {
GuildCharterType charterType;
// 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
switch (itemBase.getUUID()) {
switch (charter.template.template_id) {
case 559:
charterType = GuildCharterType.CATHEDRAL;

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

@ -294,7 +294,7 @@ public class dbItemHandler extends dbHandlerBase { @@ -294,7 +294,7 @@ public class dbItemHandler extends dbHandlerBase {
for (Item item : inventory) {
if (item.getItemBase().getType().equals(ItemType.GOLD))
if (item.template.item_type.equals(ItemType.GOLD))
continue;
try (Connection connection = DbManager.getConnection();
@ -438,7 +438,7 @@ public class dbItemHandler extends dbHandlerBase { @@ -438,7 +438,7 @@ public class dbItemHandler extends dbHandlerBase {
*/
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;
try (Connection connection = DbManager.getConnection();

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

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

8
src/engine/gameManager/CombatManager.java

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

4
src/engine/gameManager/LootManager.java

@ -175,14 +175,12 @@ public enum LootManager { @@ -175,14 +175,12 @@ public enum LootManager {
if (itemUUID == 0)
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);
return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false);
}
outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false);
Enum.ItemType outType = outItem.getItemBase().getType();
if(selectedRow.pModTable != 0){
try {

6
src/engine/gameManager/PowersManager.java

@ -2502,12 +2502,12 @@ public enum PowersManager { @@ -2502,12 +2502,12 @@ public enum PowersManager {
if (pb.targetItem())
return true;
// 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;
else if (pb.targetJewelry() && item.getItemBase().getType().equals(ItemType.JEWELRY))
else if (pb.targetJewelry() && item.template.item_type.equals(ItemType.JEWELRY))
return true;
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
else
return false;

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

@ -219,7 +219,7 @@ public class ClientMessagePump implements NetMsgHandler { @@ -219,7 +219,7 @@ public class ClientMessagePump implements NetMsgHandler {
return;
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()))
return;
UpdateGoldMsg goldMes = new UpdateGoldMsg(player);
@ -274,7 +274,7 @@ public class ClientMessagePump implements NetMsgHandler { @@ -274,7 +274,7 @@ public class ClientMessagePump implements NetMsgHandler {
if (item.containerType == ItemContainerType.BANK && itemManager.isBankOpen() == false)
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()))
return;
@ -738,7 +738,7 @@ public class ClientMessagePump implements NetMsgHandler { @@ -738,7 +738,7 @@ public class ClientMessagePump implements NetMsgHandler {
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
// (from the mob) from appearing in player's inventory.
// It also updates the goldItem quantity display
@ -769,7 +769,7 @@ public class ClientMessagePump implements NetMsgHandler { @@ -769,7 +769,7 @@ public class ClientMessagePump implements NetMsgHandler {
//TODO send group loot message if player is grouped and visible
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 text = player.getFirstName() + " has looted " + name + '.';
ChatManager.chatGroupInfoCanSee(player, text);
@ -787,7 +787,7 @@ public class ClientMessagePump implements NetMsgHandler { @@ -787,7 +787,7 @@ public class ClientMessagePump implements NetMsgHandler {
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
// (from the mob) from appearing in player's inventory.
// It also updates the goldItem quantity display
@ -826,7 +826,7 @@ public class ClientMessagePump implements NetMsgHandler { @@ -826,7 +826,7 @@ public class ClientMessagePump implements NetMsgHandler {
//TODO send group loot message if player is grouped and visible
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 text = player.getFirstName() + " has looted " + name + '.';
ChatManager.chatGroupInfoCanSee(player, text);

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

@ -48,9 +48,9 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { @@ -48,9 +48,9 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler {
// Filter hirelings by slot type
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)
continue;

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

@ -28,7 +28,6 @@ import engine.net.client.msg.guild.GuildCreationFinalizeMsg; @@ -28,7 +28,6 @@ import engine.net.client.msg.guild.GuildCreationFinalizeMsg;
import engine.net.client.msg.guild.GuildInfoMsg;
import engine.objects.Guild;
import engine.objects.Item;
import engine.objects.ItemBase;
import engine.objects.PlayerCharacter;
import engine.util.StringUtils;
@ -46,7 +45,7 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler { @@ -46,7 +45,7 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler {
Enum.GuildCharterType charterType;
Guild newGuild;
Guild playerGuild;
ItemBase itemBase;
Item charter;
Dispatch dispatch;
@ -69,16 +68,14 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler { @@ -69,16 +68,14 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler {
return true;
}
itemBase = charter.getItemBase();
// 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);
return true;
}
charterType = Enum.GuildCharterType.getGuildTypeFromCharter(itemBase);
charterType = Enum.GuildCharterType.getGuildTypeFromCharter(charter);
if (charterType == null) {
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);

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

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

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

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

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

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

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

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

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

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

43
src/engine/objects/CharacterItemManager.java

@ -191,19 +191,19 @@ public class CharacterItemManager { @@ -191,19 +191,19 @@ public class CharacterItemManager {
}
break;
case BANK:
if (i.getItemBase().getType().equals(ItemType.GOLD))
if (i.template.item_type.equals(ItemType.GOLD))
this.goldBank = i;
else if (this.bank.contains(i) == false)
this.bank.add(i);
break;
case INVENTORY:
if (i.getItemBase().getType().equals(ItemType.GOLD))
if (i.template.item_type.equals(ItemType.GOLD))
this.goldInventory = i;
else if (this.inventory.contains(i) == false)
this.inventory.add(i);
break;
case VAULT:
if (i.getItemBase().getType().equals(ItemType.GOLD))
if (i.template.item_type.equals(ItemType.GOLD))
this.goldVault = i;
else if (this.vault.contains(i) == false)
this.vault.add(i);
@ -238,13 +238,13 @@ public class CharacterItemManager { @@ -238,13 +238,13 @@ public class CharacterItemManager {
this.equipped.put(i.equipSlot, i);
break;
case BANK:
if (i.getItemBase().getType().equals(ItemType.GOLD))
if (i.template.item_type.equals(ItemType.GOLD))
this.goldBank = i;
else if (this.bank.contains(i) == false)
this.bank.add(i);
break;
case INVENTORY:
if (i.getItemBase().getType().equals(ItemType.GOLD))
if (i.template.item_type.equals(ItemType.GOLD))
this.goldInventory = i;
else if (this.inventory.contains(i) == false)
this.inventory.add(i);
@ -915,7 +915,7 @@ public class CharacterItemManager { @@ -915,7 +915,7 @@ public class CharacterItemManager {
if (i == null)
return false;
if (i.getItemBase().getType().equals(ItemType.GOLD)) {
if (i.template.item_type.equals(ItemType.GOLD)) {
if (this.getGoldInventory() != null) {
if (i.getObjectUUID() == this.getGoldInventory().getObjectUUID())
this.goldInventory = null;
@ -945,7 +945,7 @@ public class CharacterItemManager { @@ -945,7 +945,7 @@ public class CharacterItemManager {
}
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 (DbManager.ItemQueries.UPDATE_GOLD(i, 0)) {
this.getGoldInventory().setNumOfItems(0);
@ -1000,8 +1000,7 @@ public class CharacterItemManager { @@ -1000,8 +1000,7 @@ public class CharacterItemManager {
if (equippedContains(item)) {
fromEquip = true;
ItemBase ib = item.getItemBase();
if (ib != null && ib.getType().equals(ItemType.GOLD))
if (item.template.item_type.equals(ItemType.GOLD))
this.absCharacter.cancelOnUnEquip();
}
@ -1211,7 +1210,7 @@ public class CharacterItemManager { @@ -1211,7 +1210,7 @@ public class CharacterItemManager {
// This removes ingame item from inventory for loot.
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())
return false;
if (!DbManager.ItemQueries.UPDATE_GOLD(this.goldInventory, 0)) {
@ -1234,7 +1233,7 @@ public class CharacterItemManager { @@ -1234,7 +1233,7 @@ public class CharacterItemManager {
// This adds item to inventory for loot. Validity checks already handled
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.goldInventory == null)
loadGoldItems();
@ -1261,7 +1260,7 @@ public class CharacterItemManager { @@ -1261,7 +1260,7 @@ public class CharacterItemManager {
//called for adding gold of a specified 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 false;
}
@ -1623,9 +1622,9 @@ public class CharacterItemManager { @@ -1623,9 +1622,9 @@ public class CharacterItemManager {
synchronized (lockFirst) {
synchronized (lockSecond) {
// 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;
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;
// get weight of item
@ -1636,10 +1635,10 @@ public class CharacterItemManager { @@ -1636,10 +1635,10 @@ public class CharacterItemManager {
int weight = lootItem.template.item_wt;
// 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;
if (lootItem.getItemBase().getType().equals(ItemType.GOLD))
if (lootItem.template.item_type.equals(ItemType.GOLD))
if (amount != -1) { //from steal
int total = lootItem.getNumOfItems();
amount = (amount > total) ? total : amount;
@ -1702,25 +1701,25 @@ public class CharacterItemManager { @@ -1702,25 +1701,25 @@ public class CharacterItemManager {
* Delegates
*/
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 bank.contains(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 inventory.contains(i);
}
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 vendor.getRolling().contains(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.account.getVault().contains(i);
}
@ -2004,13 +2003,13 @@ public class CharacterItemManager { @@ -2004,13 +2003,13 @@ public class CharacterItemManager {
item.zeroItem();
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
if (!corpse.hasGold())
corpse.setHasGold(true);
newInventory.add(item);
} else //item
if (item.getItemBase().getType().equals(ItemType.GOLD)) {
if (item.template.item_type.equals(ItemType.GOLD)) {
int amt = item.getNumOfItems();
item.setNumOfItems(0);
MobLoot ml = new MobLoot(this.absCharacter, amt);

6
src/engine/objects/Item.java

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

23
src/engine/objects/ItemBase.java

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

4
src/engine/objects/ItemFactory.java

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

4
src/engine/objects/Mob.java

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

5
src/engine/objects/MobLoot.java

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

4
src/engine/objects/NPC.java

@ -1070,7 +1070,7 @@ public class NPC extends AbstractCharacter { @@ -1070,7 +1070,7 @@ public class NPC extends AbstractCharacter {
ItemBase itemBase;
for (Integer itemID : fullItemList) {
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)
filteredItemList.add(itemID);
}
@ -1095,7 +1095,7 @@ public class NPC extends AbstractCharacter { @@ -1095,7 +1095,7 @@ public class NPC extends AbstractCharacter {
if (ib == null)
return 0;
if (ib.getType() == ItemType.SCROLL)
if (ItemTemplate.itemTemplates.get(itemID).item_type == ItemType.SCROLL)
return this.getRank() * 60 * 60 * 3;
float time;

14
src/engine/objects/PlayerCharacter.java

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

2
src/engine/objects/Warehouse.java

@ -341,7 +341,7 @@ public class Warehouse extends AbstractWorldObject { @@ -341,7 +341,7 @@ public class Warehouse extends AbstractWorldObject {
Resource resourceType;
if (resource.getItemBase().getType().equals(Enum.ItemType.GOLD))
if (resource.template.item_type.equals(Enum.ItemType.GOLD))
resourceType = Resource.GOLD;
else
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 { @@ -156,7 +156,7 @@ public class StealPowerAction extends AbstractPowerAction {
if (myCIM == null || ownerCIM == null)
return;
if (tar.getItemBase().getType().equals(ItemType.GOLD)) {
if (tar.template.item_type.equals(ItemType.GOLD)) {
//stealing gold
if (!myCIM.transferGoldToMyInventory((AbstractCharacter) owner, amount))
return;

Loading…
Cancel
Save