Reuse of several item slot related ids.

This commit is contained in:
MobiusDevelopment 2019-11-24 16:23:54 +00:00
parent 72369a0173
commit a14216215e
11 changed files with 278 additions and 264 deletions

View File

@ -37,89 +37,90 @@ public class ItemTable
{ {
private static Logger _log = Logger.getLogger(ItemTable.class.getName()); private static Logger _log = Logger.getLogger(ItemTable.class.getName());
// private static final int TYPE_ETC_ITEM = 0; private static final int TYPE_ETC_ITEM = 0;
// private static final int TYPE_ARMOR = 1; private static final int TYPE_ARMOR = 1;
// private static final int TYPE_WEAPON = 2; private static final int TYPE_WEAPON = 2;
private static final HashMap<String, Integer> _materials = new HashMap<>(); private static final HashMap<String, Integer> _materials = new HashMap<>();
static static
{ {
_materials.put("steel", 0); _materials.put("steel", Item.MATERIAL_STEEL);
_materials.put("fine_steel", 1); _materials.put("fine_steel", Item.MATERIAL_FINE_STEEL);
_materials.put("cotton", 1); _materials.put("cotton", Item.MATERIAL_FINE_STEEL);
_materials.put("blood_steel", 2); _materials.put("blood_steel", Item.MATERIAL_BLOOD_STEEL);
_materials.put("bronze", 3); _materials.put("bronze", Item.MATERIAL_BRONZE);
_materials.put("silver", 4); _materials.put("silver", Item.MATERIAL_SILVER);
_materials.put("gold", 5); _materials.put("gold", Item.MATERIAL_GOLD);
_materials.put("mithril", 6); _materials.put("mithril", Item.MATERIAL_MITHRIL);
_materials.put("oriharukon", 7); _materials.put("oriharukon", Item.MATERIAL_ORIHARUKON);
_materials.put("paper", 8); _materials.put("paper", Item.MATERIAL_PAPER);
_materials.put("wood", 9); _materials.put("wood", Item.MATERIAL_WOOD);
_materials.put("cloth", 10); _materials.put("cloth", Item.MATERIAL_CLOTH);
_materials.put("leather", 11); _materials.put("leather", Item.MATERIAL_LEATHER);
_materials.put("bone", 12); _materials.put("bone", Item.MATERIAL_BONE);
_materials.put("horn", 13); _materials.put("horn", Item.MATERIAL_HORN);
_materials.put("damascus", 14); _materials.put("damascus", Item.MATERIAL_DAMASCUS);
_materials.put("adamantaite", 15); _materials.put("adamantaite", Item.MATERIAL_ADAMANTAITE);
_materials.put("chrysolite", 16); _materials.put("chrysolite", Item.MATERIAL_CHRYSOLITE);
_materials.put("crystal", 17); _materials.put("crystal", Item.MATERIAL_CRYSTAL);
_materials.put("liquid", 18); _materials.put("liquid", Item.MATERIAL_LIQUID);
_materials.put("scale_of_dragon", 19); _materials.put("scale_of_dragon", Item.MATERIAL_SCALE_OF_DRAGON);
_materials.put("dyestuff", 20); _materials.put("dyestuff", Item.MATERIAL_DYESTUFF);
_materials.put("cobweb", 21); _materials.put("cobweb", Item.MATERIAL_COBWEB);
} }
private static final HashMap<String, Integer> _crystalTypes = new HashMap<>(); private static final HashMap<String, Integer> _crystalTypes = new HashMap<>();
static static
{ {
_crystalTypes.put("none", 1); _crystalTypes.put("none", Item.CRYSTAL_NONE);
_crystalTypes.put("d", 2); _crystalTypes.put("d", Item.CRYSTAL_D);
_crystalTypes.put("c", 3); _crystalTypes.put("c", Item.CRYSTAL_C);
_crystalTypes.put("b", 4); _crystalTypes.put("b", Item.CRYSTAL_B);
_crystalTypes.put("a", 5); _crystalTypes.put("a", Item.CRYSTAL_A);
_crystalTypes.put("s", 6); _crystalTypes.put("s", Item.CRYSTAL_S);
} }
private static final HashMap<String, Integer> _weaponTypes = new HashMap<>(); private static final HashMap<String, Integer> _weaponTypes = new HashMap<>();
static static
{ {
_weaponTypes.put("none", 1); _weaponTypes.put("none", Weapon.WEAPON_TYPE_NONE);
_weaponTypes.put("sword", 2); _weaponTypes.put("sword", Weapon.WEAPON_TYPE_SWORD);
_weaponTypes.put("blunt", 3); _weaponTypes.put("blunt", Weapon.WEAPON_TYPE_BLUNT);
_weaponTypes.put("dagger", 4); _weaponTypes.put("dagger", Weapon.WEAPON_TYPE_DAGGER);
_weaponTypes.put("bow", 5); _weaponTypes.put("bow", Weapon.WEAPON_TYPE_BOW);
_weaponTypes.put("pole", 6); _weaponTypes.put("pole", Weapon.WEAPON_TYPE_POLE);
_weaponTypes.put("etc", 7); _weaponTypes.put("etc", Weapon.WEAPON_TYPE_ETC);
_weaponTypes.put("fist", 8); _weaponTypes.put("fist", Weapon.WEAPON_TYPE_FIST);
_weaponTypes.put("dual", 9); _weaponTypes.put("dual", Weapon.WEAPON_TYPE_DUAL);
_weaponTypes.put("dualfist", 10); _weaponTypes.put("dualfist", Weapon.WEAPON_TYPE_DUALFIST);
} }
private static final HashMap<String, Integer> _armorTypes = new HashMap<>(); private static final HashMap<String, Integer> _armorTypes = new HashMap<>();
static static
{ {
_armorTypes.put("none", 1); _armorTypes.put("none", Armor.ARMORTYPE_NONE);
_armorTypes.put("light", 2); _armorTypes.put("light", Armor.ARMORTYPE_LIGHT);
_armorTypes.put("heavy", 3); _armorTypes.put("heavy", Armor.ARMORTYPE_HEAVY);
_armorTypes.put("magic", 4); _armorTypes.put("magic", Armor.ARMORTYPE_MAGIC);
} }
private static final HashMap<String, Integer> _slots = new HashMap<>(); private static final HashMap<String, Integer> _slots = new HashMap<>();
static static
{ {
_slots.put("none", 0); _slots.put("none", Item.SLOT_NONE);
_slots.put("underwear", 1); _slots.put("underwear", Item.SLOT_UNDERWEAR);
_slots.put("rear,lear", 6); _slots.put("rear,lear", Item.SLOT_R_EAR + Item.SLOT_L_EAR);
_slots.put("neck", 8); _slots.put("neck", Item.SLOT_NECK);
_slots.put("rfinger,lfinger", 48); _slots.put("rfinger,lfinger", Item.SLOT_R_FINGER + Item.SLOT_L_FINGER);
_slots.put("head", 64); _slots.put("head", Item.SLOT_HEAD);
_slots.put("rhand", 128); _slots.put("rhand", Item.SLOT_R_HAND);
_slots.put("lhand", 256); _slots.put("lhand", Item.SLOT_L_HAND);
_slots.put("gloves", 512); _slots.put("gloves", Item.SLOT_GLOVES);
_slots.put("chest", 1024); _slots.put("chest", Item.SLOT_CHEST);
_slots.put("legs", 2048); _slots.put("legs", Item.SLOT_LEGS);
_slots.put("chest,legs", 3072); _slots.put("chest,legs", Item.SLOT_CHEST + Item.SLOT_LEGS);
_slots.put("feet", 4096); _slots.put("feet", Item.SLOT_FEET);
_slots.put("back", 8192); _slots.put("back", Item.SLOT_BACK);
_slots.put("lrhand", 16384); _slots.put("lrhand", Item.SLOT_LR_HAND);
_slots.put("fullarmor", 32768); _slots.put("fullarmor", Item.SLOT_FULL_ARMOR);
} }
private Item[] _allTemplates; private Item[] _allTemplates;
private HashMap<Integer, Item> _etcItems; private HashMap<Integer, Item> _etcItems;
private HashMap<Integer, Item> _armors; private HashMap<Integer, Item> _armors;
@ -136,6 +137,11 @@ public class ItemTable
return _instance; return _instance;
} }
public boolean isInitialized()
{
return _initialized;
}
public ItemTable() public ItemTable()
{ {
File weaponFile; File weaponFile;
@ -159,47 +165,54 @@ public class ItemTable
buildFastLookupTable(); buildFastLookupTable();
} }
public boolean isInitialized()
{
return _initialized;
}
private void parseEtcItems(File data) private void parseEtcItems(File data)
{ {
_etcItems = parseFile(data, 0); _etcItems = parseFile(data, TYPE_ETC_ITEM);
_log.config("Loaded " + _etcItems.size() + " etc items."); _log.config("Loaded " + _etcItems.size() + " etc items.");
fixEtcItems(_etcItems); fixEtcItems(_etcItems);
} }
private void parseArmors(File data)
{
_armors = parseFile(data, TYPE_ARMOR);
_log.config("Loaded " + _armors.size() + " armors.");
}
private void parseWeapons(File data)
{
_weapons = parseFile(data, TYPE_WEAPON);
_log.config("Laoded " + _weapons.size() + " weapons.");
}
private void fixEtcItems(HashMap<Integer, Item> items) private void fixEtcItems(HashMap<Integer, Item> items)
{ {
for (int key : items.keySet()) for (int key : items.keySet())
{ {
final EtcItem item = (EtcItem) items.get(key); final EtcItem item = (EtcItem) items.get(key);
if ((item.getWeight() == 0) && (item.getEtcItemType() != 7) && !item.getName().startsWith("world_map") && !item.getName().startsWith("crystal_")) if ((item.getWeight() == 0) && (item.getEtcItemType() != EtcItem.TYPE_MONEY) && !item.getName().startsWith("world_map") && !item.getName().startsWith("crystal_"))
{ {
item.setType2(3); item.setType2(Item.TYPE2_QUEST);
item.setEtcItemType(6); item.setEtcItemType(EtcItem.TYPE_QUEST);
continue; continue;
} }
if (item.getName().startsWith("sb_")) if (item.getName().startsWith("sb_"))
{ {
item.setType2(5); item.setType2(Item.TYPE2_OTHER);
item.setEtcItemType(9); item.setEtcItemType(EtcItem.TYPE_SPELLBOOK);
continue; continue;
} }
if (item.getName().startsWith("rp_")) if (item.getName().startsWith("rp_"))
{ {
item.setType2(5); item.setType2(Item.TYPE2_OTHER);
item.setEtcItemType(4); item.setEtcItemType(EtcItem.TYPE_RECIPE);
continue; continue;
} }
if (!item.getName().startsWith("q_")) if (!item.getName().startsWith("q_"))
{ {
continue; continue;
} }
item.setType2(3); item.setType2(Item.TYPE2_QUEST);
item.setEtcItemType(6); item.setEtcItemType(EtcItem.TYPE_QUEST);
} }
} }
@ -222,17 +235,17 @@ public class ItemTable
} }
switch (type) switch (type)
{ {
case 0: case TYPE_ETC_ITEM:
{ {
temp = parseEtcLine(line); temp = parseEtcLine(line);
break; break;
} }
case 1: case TYPE_ARMOR:
{ {
temp = parseArmorLine(line); temp = parseArmorLine(line);
break; break;
} }
case 2: case TYPE_WEAPON:
{ {
temp = parseWeaponLine(line); temp = parseWeaponLine(line);
} }
@ -265,47 +278,47 @@ public class ItemTable
result.setName(st.nextToken()); result.setName(st.nextToken());
result.setCrystallizable(Boolean.valueOf(st.nextToken())); result.setCrystallizable(Boolean.valueOf(st.nextToken()));
final String itemType = st.nextToken(); final String itemType = st.nextToken();
result.setType1(4); result.setType1(Item.TYPE1_ITEM_QUESTITEM_ADENA);
if (itemType.equals("none")) if (itemType.equals("none"))
{ {
result.setType2(5); result.setType2(Item.TYPE2_OTHER);
result.setEtcItemType(8); result.setEtcItemType(EtcItem.TYPE_OTHER);
} }
else if (itemType.equals("arrow")) else if (itemType.equals("arrow"))
{ {
result.setType2(5); result.setType2(Item.TYPE2_OTHER);
result.setEtcItemType(0); result.setEtcItemType(EtcItem.TYPE_ARROW);
result.setBodyPart(256); result.setBodyPart(Item.SLOT_L_HAND);
} }
else if (itemType.equals("castle_guard")) else if (itemType.equals("castle_guard"))
{ {
result.setType2(5); result.setType2(Item.TYPE2_OTHER);
result.setEtcItemType(5); result.setEtcItemType(EtcItem.TYPE_SCROLL);
} }
else if (itemType.equals("material")) else if (itemType.equals("material"))
{ {
result.setType2(5); result.setType2(Item.TYPE2_OTHER);
result.setEtcItemType(1); result.setEtcItemType(EtcItem.TYPE_MATERIAL);
} }
else if (itemType.equals("pet_collar")) else if (itemType.equals("pet_collar"))
{ {
result.setType2(5); result.setType2(Item.TYPE2_OTHER);
result.setEtcItemType(2); result.setEtcItemType(EtcItem.TYPE_PET_COLLAR);
} }
else if (itemType.equals("potion")) else if (itemType.equals("potion"))
{ {
result.setType2(5); result.setType2(Item.TYPE2_OTHER);
result.setEtcItemType(3); result.setEtcItemType(EtcItem.TYPE_POTION);
} }
else if (itemType.equals("recipe")) else if (itemType.equals("recipe"))
{ {
result.setType2(5); result.setType2(Item.TYPE2_OTHER);
result.setEtcItemType(4); result.setEtcItemType(EtcItem.TYPE_RECIPE);
} }
else if (itemType.equals("scroll")) else if (itemType.equals("scroll"))
{ {
result.setType2(5); result.setType2(Item.TYPE2_OTHER);
result.setEtcItemType(5); result.setEtcItemType(EtcItem.TYPE_SCROLL);
} }
else else
{ {
@ -316,8 +329,8 @@ public class ItemTable
if (consume.equals("asset")) if (consume.equals("asset"))
{ {
result.setStackable(true); result.setStackable(true);
result.setEtcItemType(7); result.setEtcItemType(EtcItem.TYPE_MONEY);
result.setType2(4); result.setType2(Item.TYPE2_MONEY);
} }
else if (consume.equals("stackable")) else if (consume.equals("stackable"))
{ {
@ -331,8 +344,7 @@ public class ItemTable
} }
catch (Exception e) catch (Exception e)
{ {
_log.warning("Data error on etc item:" + result + " line: " + line); _log.warning("Data error on etc item:" + result + " line: " + line + " " + e);
e.printStackTrace();
} }
return result; return result;
} }
@ -351,15 +363,15 @@ public class ItemTable
final Integer armor = _armorTypes.get(st.nextToken()); final Integer armor = _armorTypes.get(st.nextToken());
result.setArmorType(armor); result.setArmorType(armor);
final int slot = result.getBodyPart(); final int slot = result.getBodyPart();
if ((slot == 8) || ((slot & 4) != 0) || ((slot & 0x20) != 0)) if ((slot == Item.SLOT_NECK) || ((slot & Item.SLOT_L_EAR) != 0) || ((slot & Item.SLOT_L_FINGER) != 0))
{ {
result.setType1(0); result.setType1(Item.TYPE1_WEAPON_RING_EARRING_NECKLACE);
result.setType2(2); result.setType2(Item.TYPE2_ACCESSORY);
} }
else else
{ {
result.setType1(1); result.setType1(Item.TYPE1_SHIELD_ARMOR);
result.setType2(1); result.setType2(Item.TYPE2_SHIELD_ARMOR);
} }
result.setWeight(Integer.parseInt(st.nextToken())); result.setWeight(Integer.parseInt(st.nextToken()));
final Integer material = _materials.get(st.nextToken()); final Integer material = _materials.get(st.nextToken());
@ -374,8 +386,7 @@ public class ItemTable
} }
catch (Exception e) catch (Exception e)
{ {
_log.warning("Data error on armor:" + result + " line: " + line); _log.warning("Data error on armor:" + result + " line: " + line + " " + e);
e.printStackTrace();
} }
return result; return result;
} }
@ -388,8 +399,8 @@ public class ItemTable
final StringTokenizer st = new StringTokenizer(line, ";"); final StringTokenizer st = new StringTokenizer(line, ";");
result.setItemId(Integer.parseInt(st.nextToken())); result.setItemId(Integer.parseInt(st.nextToken()));
result.setName(st.nextToken()); result.setName(st.nextToken());
result.setType1(0); result.setType1(Item.TYPE1_WEAPON_RING_EARRING_NECKLACE);
result.setType2(0); result.setType2(Item.TYPE2_WEAPON);
final Integer bodyPart = _slots.get(st.nextToken()); final Integer bodyPart = _slots.get(st.nextToken());
result.setBodyPart(bodyPart); result.setBodyPart(bodyPart);
result.setCrystallizable(Boolean.valueOf(st.nextToken())); result.setCrystallizable(Boolean.valueOf(st.nextToken()));
@ -406,8 +417,8 @@ public class ItemTable
result.setWeaponType(weapon); result.setWeaponType(weapon);
if (weapon == 1) if (weapon == 1)
{ {
result.setType1(1); result.setType1(Item.TYPE1_SHIELD_ARMOR);
result.setType2(1); result.setType2(Item.TYPE2_SHIELD_ARMOR);
} }
result.setCritical(Integer.parseInt(st.nextToken())); result.setCritical(Integer.parseInt(st.nextToken()));
result.setHitModifier(Double.parseDouble(st.nextToken())); result.setHitModifier(Double.parseDouble(st.nextToken()));
@ -421,24 +432,11 @@ public class ItemTable
} }
catch (Exception e) catch (Exception e)
{ {
_log.warning("Data error on weapon:" + result + " line: " + line); _log.warning("Data error on weapon:" + result + " line: " + line + " " + e);
e.printStackTrace();
} }
return result; return result;
} }
private void parseArmors(File data)
{
_armors = parseFile(data, 1);
_log.config("Loaded " + _armors.size() + " armors.");
}
private void parseWeapons(File data)
{
_weapons = parseFile(data, 2);
_log.config("Laoded " + _weapons.size() + " weapons.");
}
private void buildFastLookupTable() private void buildFastLookupTable()
{ {
int highestId = 0; int highestId = 0;

View File

@ -23,6 +23,7 @@ import org.l2jmobius.gameserver.model.actor.instance.ItemInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUser; import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUser;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.templates.Item;
import org.l2jmobius.gameserver.templates.Weapon; import org.l2jmobius.gameserver.templates.Weapon;
public class SoulShots implements IItemHandler public class SoulShots implements IItemHandler
@ -59,7 +60,7 @@ public class SoulShots implements IItemHandler
activeChar.sendPacket(new SystemMessage(SystemMessage.CANNOT_USE_SOULSHOTS)); activeChar.sendPacket(new SystemMessage(SystemMessage.CANNOT_USE_SOULSHOTS));
return 0; return 0;
} }
if (((grade == 1) && (SoulshotId != 1835)) || ((grade == 2) && (SoulshotId != 1463)) || ((grade == 3) && (SoulshotId != 1464)) || ((grade == 4) && (SoulshotId != 1465)) || ((grade == 5) && (SoulshotId != 1466)) || ((grade == 6) && (SoulshotId != 1467))) if (((grade == Item.CRYSTAL_NONE) && (SoulshotId != 1835)) || ((grade == Item.CRYSTAL_D) && (SoulshotId != 1463)) || ((grade == Item.CRYSTAL_C) && (SoulshotId != 1464)) || ((grade == Item.CRYSTAL_B) && (SoulshotId != 1465)) || ((grade == Item.CRYSTAL_A) && (SoulshotId != 1466)) || ((grade == Item.CRYSTAL_S) && (SoulshotId != 1467)))
{ {
activeChar.sendPacket(new SystemMessage(SystemMessage.SOULSHOTS_GRADE_MISMATCH)); activeChar.sendPacket(new SystemMessage(SystemMessage.SOULSHOTS_GRADE_MISMATCH));
return 0; return 0;

View File

@ -31,6 +31,7 @@ import org.l2jmobius.gameserver.templates.Weapon;
public class Inventory public class Inventory
{ {
private static Logger _log = Logger.getLogger(Inventory.class.getName()); private static Logger _log = Logger.getLogger(Inventory.class.getName());
public static final int PAPERDOLL_UNDER = 0; public static final int PAPERDOLL_UNDER = 0;
public static final int PAPERDOLL_LEAR = 1; public static final int PAPERDOLL_LEAR = 1;
public static final int PAPERDOLL_REAR = 2; public static final int PAPERDOLL_REAR = 2;
@ -46,6 +47,7 @@ public class Inventory
public static final int PAPERDOLL_FEET = 12; public static final int PAPERDOLL_FEET = 12;
public static final int PAPERDOLL_BACK = 13; public static final int PAPERDOLL_BACK = 13;
public static final int PAPERDOLL_LRHAND = 14; public static final int PAPERDOLL_LRHAND = 14;
private final ItemInstance[] _paperdoll = new ItemInstance[16]; private final ItemInstance[] _paperdoll = new ItemInstance[16];
private ItemInstance _adena; private ItemInstance _adena;
private final List<ItemInstance> _items = new CopyOnWriteArrayList<>(); private final List<ItemInstance> _items = new CopyOnWriteArrayList<>();
@ -133,102 +135,102 @@ public class Inventory
public Collection<ItemInstance> unEquipItemInBodySlot(int slot) public Collection<ItemInstance> unEquipItemInBodySlot(int slot)
{ {
final List<ItemInstance> unequipedItems = new ArrayList<>(); final List<ItemInstance> changedItems = new ArrayList<>();
int pdollSlot = -1; int pdollSlot = -1;
switch (slot) switch (slot)
{ {
case 4: case Item.SLOT_L_EAR:
{ {
pdollSlot = 1; pdollSlot = PAPERDOLL_LEAR;
break; break;
} }
case 2: case Item.SLOT_R_EAR:
{ {
pdollSlot = 2; pdollSlot = PAPERDOLL_REAR;
break; break;
} }
case 8: case Item.SLOT_NECK:
{ {
pdollSlot = 3; pdollSlot = PAPERDOLL_NECK;
break; break;
} }
case 16: case Item.SLOT_R_FINGER:
{ {
pdollSlot = 5; pdollSlot = PAPERDOLL_RFINGER;
break; break;
} }
case 32: case Item.SLOT_L_FINGER:
{ {
pdollSlot = 4; pdollSlot = PAPERDOLL_LFINGER;
break; break;
} }
case 64: case Item.SLOT_HEAD:
{ {
pdollSlot = 6; pdollSlot = PAPERDOLL_HEAD;
break; break;
} }
case 128: case Item.SLOT_R_HAND:
{ {
pdollSlot = 7; pdollSlot = PAPERDOLL_RHAND;
break; break;
} }
case 256: case Item.SLOT_L_HAND:
{ {
pdollSlot = 8; pdollSlot = PAPERDOLL_LHAND;
break; break;
} }
case 512: case Item.SLOT_GLOVES:
{ {
pdollSlot = 9; pdollSlot = PAPERDOLL_GLOVES;
break; break;
} }
case 1024: case Item.SLOT_CHEST:
case 32768: case Item.SLOT_FULL_ARMOR:
{ {
pdollSlot = 10; pdollSlot = PAPERDOLL_CHEST;
break; break;
} }
case 2048: case Item.SLOT_LEGS:
{ {
pdollSlot = 11; pdollSlot = PAPERDOLL_LEGS;
break; break;
} }
case 16384: case Item.SLOT_LR_HAND:
{ {
unEquipSlot(unequipedItems, 8); unEquipSlot(changedItems, PAPERDOLL_LHAND);
unEquipSlot(7); unEquipSlot(PAPERDOLL_RHAND);
pdollSlot = 14; pdollSlot = PAPERDOLL_LRHAND;
break; break;
} }
case 8192: case Item.SLOT_BACK:
{ {
pdollSlot = 13; pdollSlot = PAPERDOLL_BACK;
break; break;
} }
case 4096: case Item.SLOT_FEET:
{ {
pdollSlot = 12; pdollSlot = PAPERDOLL_FEET;
break; break;
} }
case 1: case Item.SLOT_UNDERWEAR:
{ {
pdollSlot = 0; pdollSlot = PAPERDOLL_UNDER;
} }
} }
unEquipSlot(unequipedItems, pdollSlot); unEquipSlot(changedItems, pdollSlot);
return unequipedItems; return changedItems;
} }
public Collection<ItemInstance> unEquipItemOnPaperdoll(int pdollSlot) public Collection<ItemInstance> unEquipItemOnPaperdoll(int pdollSlot)
{ {
final List<ItemInstance> unequipedItems = new ArrayList<>(); final List<ItemInstance> changedItems = new ArrayList<>();
if (pdollSlot == 14) if (pdollSlot == 14)
{ {
unEquipSlot(unequipedItems, 8); unEquipSlot(changedItems, PAPERDOLL_LHAND);
unEquipSlot(7); unEquipSlot(PAPERDOLL_RHAND);
} }
unEquipSlot(unequipedItems, pdollSlot); unEquipSlot(changedItems, pdollSlot);
return unequipedItems; return changedItems;
} }
public List<ItemInstance> equipItem(ItemInstance item) public List<ItemInstance> equipItem(ItemInstance item)
@ -237,147 +239,151 @@ public class Inventory
final int targetSlot = item.getItem().getBodyPart(); final int targetSlot = item.getItem().getBodyPart();
switch (targetSlot) switch (targetSlot)
{ {
case 16384: case Item.SLOT_LR_HAND:
{ {
ItemInstance arrow; ItemInstance arrow;
unEquipSlot(changedItems, 8); unEquipSlot(changedItems, PAPERDOLL_LHAND);
final ItemInstance old1 = unEquipSlot(14); final ItemInstance old1 = unEquipSlot(PAPERDOLL_LRHAND);
if (old1 != null) if (old1 != null)
{ {
changedItems.add(old1); changedItems.add(old1);
unEquipSlot(7); unEquipSlot(PAPERDOLL_RHAND);
unEquipSlot(changedItems, 8); unEquipSlot(changedItems, PAPERDOLL_LHAND);
} }
else else
{ {
unEquipSlot(changedItems, 7); unEquipSlot(changedItems, PAPERDOLL_RHAND);
} }
setPaperdollItem(7, item); setPaperdollItem(PAPERDOLL_RHAND, item);
setPaperdollItem(14, item); setPaperdollItem(PAPERDOLL_LRHAND, item);
if ((((Weapon) item.getItem()).getWeaponType() != 5) || ((arrow = findArrowForBow(item.getItem())) == null)) if ((((Weapon) item.getItem()).getWeaponType() != Weapon.WEAPON_TYPE_BOW) || ((arrow = findArrowForBow(item.getItem())) == null))
{ {
break; break;
} }
setPaperdollItem(8, arrow); setPaperdollItem(PAPERDOLL_LHAND, arrow);
arrow.setLastChange(2); arrow.setLastChange(2);
changedItems.add(arrow); changedItems.add(arrow);
break; break;
} }
case 256: case Item.SLOT_L_HAND:
{ {
final ItemInstance old1 = unEquipSlot(14); final ItemInstance old1 = unEquipSlot(PAPERDOLL_LRHAND);
if (old1 != null) if (old1 != null)
{ {
unEquipSlot(changedItems, 7); unEquipSlot(changedItems, PAPERDOLL_RHAND);
} }
unEquipSlot(changedItems, 8); unEquipSlot(changedItems, PAPERDOLL_LHAND);
setPaperdollItem(8, item); setPaperdollItem(PAPERDOLL_LHAND, item);
break; break;
} }
case 128: case Item.SLOT_R_HAND:
{ {
if (unEquipSlot(changedItems, 14)) if (unEquipSlot(changedItems, PAPERDOLL_LRHAND))
{ {
unEquipSlot(changedItems, 8); unEquipSlot(changedItems, PAPERDOLL_LHAND);
unEquipSlot(7); unEquipSlot(PAPERDOLL_RHAND);
} }
else else
{ {
unEquipSlot(changedItems, 7); unEquipSlot(changedItems, PAPERDOLL_RHAND);
} }
setPaperdollItem(7, item); setPaperdollItem(PAPERDOLL_RHAND, item);
break; break;
} }
case 6: case Item.SLOT_R_EAR:
case Item.SLOT_L_EAR:
case Item.SLOT_R_EAR + Item.SLOT_L_EAR:
{ {
if (_paperdoll[1] == null) if (_paperdoll[1] == null)
{ {
setPaperdollItem(1, item); setPaperdollItem(PAPERDOLL_LEAR, item);
break; break;
} }
if (_paperdoll[2] == null) if (_paperdoll[2] == null)
{ {
setPaperdollItem(2, item); setPaperdollItem(PAPERDOLL_REAR, item);
break; break;
} }
unEquipSlot(changedItems, 1); unEquipSlot(changedItems, PAPERDOLL_LEAR);
setPaperdollItem(1, item); setPaperdollItem(PAPERDOLL_LEAR, item);
break; break;
} }
case 48: case Item.SLOT_R_FINGER:
case Item.SLOT_L_FINGER:
case Item.SLOT_R_FINGER + Item.SLOT_L_FINGER:
{ {
if (_paperdoll[4] == null) if (_paperdoll[4] == null)
{ {
setPaperdollItem(4, item); setPaperdollItem(PAPERDOLL_LFINGER, item);
break; break;
} }
if (_paperdoll[5] == null) if (_paperdoll[5] == null)
{ {
setPaperdollItem(5, item); setPaperdollItem(PAPERDOLL_RFINGER, item);
break; break;
} }
unEquipSlot(changedItems, 4); unEquipSlot(changedItems, PAPERDOLL_LFINGER);
setPaperdollItem(4, item); setPaperdollItem(PAPERDOLL_LFINGER, item);
break; break;
} }
case 8: case Item.SLOT_NECK:
{ {
unEquipSlot(changedItems, 3); unEquipSlot(changedItems, PAPERDOLL_NECK);
setPaperdollItem(3, item); setPaperdollItem(PAPERDOLL_NECK, item);
break; break;
} }
case 32768: case Item.SLOT_FULL_ARMOR:
{ {
unEquipSlot(changedItems, 10); unEquipSlot(changedItems, PAPERDOLL_CHEST);
unEquipSlot(changedItems, 11); unEquipSlot(changedItems, PAPERDOLL_LEGS);
setPaperdollItem(10, item); setPaperdollItem(PAPERDOLL_CHEST, item);
break; break;
} }
case 1024: case Item.SLOT_CHEST:
{ {
unEquipSlot(changedItems, 10); unEquipSlot(changedItems, PAPERDOLL_CHEST);
setPaperdollItem(10, item); setPaperdollItem(PAPERDOLL_CHEST, item);
break; break;
} }
case 2048: case Item.SLOT_LEGS:
{ {
final ItemInstance chest = getPaperdollItem(10); final ItemInstance chest = getPaperdollItem(10);
if ((chest != null) && (chest.getItem().getBodyPart() == 32768)) if ((chest != null) && (chest.getItem().getBodyPart() == Item.SLOT_FULL_ARMOR))
{ {
unEquipSlot(changedItems, 10); unEquipSlot(changedItems, PAPERDOLL_CHEST);
} }
unEquipSlot(changedItems, 11); unEquipSlot(changedItems, PAPERDOLL_LEGS);
setPaperdollItem(11, item); setPaperdollItem(PAPERDOLL_LEGS, item);
break; break;
} }
case 4096: case Item.SLOT_FEET:
{ {
unEquipSlot(changedItems, 12); unEquipSlot(changedItems, PAPERDOLL_FEET);
setPaperdollItem(12, item); setPaperdollItem(PAPERDOLL_FEET, item);
break; break;
} }
case 512: case Item.SLOT_GLOVES:
{ {
unEquipSlot(changedItems, 9); unEquipSlot(changedItems, PAPERDOLL_GLOVES);
setPaperdollItem(9, item); setPaperdollItem(PAPERDOLL_GLOVES, item);
break; break;
} }
case 64: case Item.SLOT_HEAD:
{ {
unEquipSlot(changedItems, 6); unEquipSlot(changedItems, PAPERDOLL_HEAD);
setPaperdollItem(6, item); setPaperdollItem(PAPERDOLL_HEAD, item);
break; break;
} }
case 1: case Item.SLOT_UNDERWEAR:
{ {
unEquipSlot(changedItems, 0); unEquipSlot(changedItems, PAPERDOLL_UNDER);
setPaperdollItem(0, item); setPaperdollItem(PAPERDOLL_UNDER, item);
break; break;
} }
case 8192: case Item.SLOT_BACK:
{ {
unEquipSlot(changedItems, 13); unEquipSlot(changedItems, PAPERDOLL_BACK);
setPaperdollItem(13, item); setPaperdollItem(PAPERDOLL_BACK, item);
break; break;
} }
default: default:
@ -576,32 +582,32 @@ public class Inventory
int arrowsId = 0; int arrowsId = 0;
switch (bow.getCrystalType()) switch (bow.getCrystalType())
{ {
case 1: case Item.CRYSTAL_NONE:
{ {
arrowsId = 17; arrowsId = 17;
break; break;
} }
case 2: case Item.CRYSTAL_D:
{ {
arrowsId = 1341; arrowsId = 1341;
break; break;
} }
case 3: case Item.CRYSTAL_C:
{ {
arrowsId = 1342; arrowsId = 1342;
break; break;
} }
case 4: case Item.CRYSTAL_B:
{ {
arrowsId = 1343; arrowsId = 1343;
break; break;
} }
case 5: case Item.CRYSTAL_A:
{ {
arrowsId = 1344; arrowsId = 1344;
break; break;
} }
case 6: case Item.CRYSTAL_S:
{ {
arrowsId = 1345; arrowsId = 1345;
break; break;

View File

@ -1086,7 +1086,7 @@ public abstract class Creature extends WorldObject
sendPacket(af); sendPacket(af);
return; return;
} }
if ((getActiveWeapon().getWeaponType() == 5) && !checkAndEquipArrows()) if ((getActiveWeapon().getWeaponType() == Weapon.WEAPON_TYPE_BOW) && !checkAndEquipArrows())
{ {
setInCombat(false); setInCombat(false);
setCurrentState(CreatureState.IDLE); setCurrentState(CreatureState.IDLE);
@ -1159,7 +1159,7 @@ public abstract class Creature extends WorldObject
_hitTask = ThreadPool.schedule(new HitTask(this, target, damage, crit, miss, false), calculateHitSpeed(weaponItem, 1)); _hitTask = ThreadPool.schedule(new HitTask(this, target, damage, crit, miss, false), calculateHitSpeed(weaponItem, 1));
_hitTask = ThreadPool.schedule(new HitTask(this, target, damage, crit, miss, false), calculateHitSpeed(weaponItem, 2)); _hitTask = ThreadPool.schedule(new HitTask(this, target, damage, crit, miss, false), calculateHitSpeed(weaponItem, 2));
} }
else if (getActiveWeapon().getWeaponType() == 5) else if (getActiveWeapon().getWeaponType() == Weapon.WEAPON_TYPE_BOW)
{ {
if (getCurrentMp() < weaponItem.getMpConsume()) if (getCurrentMp() < weaponItem.getMpConsume())
{ {
@ -1211,7 +1211,7 @@ public abstract class Creature extends WorldObject
} }
if (_currentlyAttacking) if (_currentlyAttacking)
{ {
if (getActiveWeapon().getWeaponType() == 5) if (getActiveWeapon().getWeaponType() == Weapon.WEAPON_TYPE_BOW)
{ {
reduceArrowCount(); reduceArrowCount();
_attackTask = ThreadPool.schedule(new AttackTask(this), calculateAttackSpeed(getActiveWeapon())); _attackTask = ThreadPool.schedule(new AttackTask(this), calculateAttackSpeed(getActiveWeapon()));
@ -1353,7 +1353,7 @@ public abstract class Creature extends WorldObject
atkspd = 325; atkspd = 325;
} }
atkspd = ((886 - atkspd) * 5) / 2; atkspd = ((886 - atkspd) * 5) / 2;
atkspd = weaponItem.getWeaponType() == 4 ? (atkspd += 50) : (weaponItem.getWeaponType() == 10 ? (atkspd += 100) : (weaponItem.getWeaponType() == 9 ? (atkspd += 100) : ((weaponItem.getItemId() == 248) || (weaponItem.getItemId() == 252) ? (atkspd += 100) : (atkspd += 50)))); atkspd = weaponItem.getWeaponType() == Weapon.WEAPON_TYPE_DAGGER ? (atkspd += 50) : (weaponItem.getWeaponType() == Weapon.WEAPON_TYPE_DUALFIST ? (atkspd += 100) : (weaponItem.getWeaponType() == Weapon.WEAPON_TYPE_DUAL ? (atkspd += 100) : ((weaponItem.getItemId() == 248) || (weaponItem.getItemId() == 252) ? (atkspd += 100) : (atkspd += 50))));
return atkspd; return atkspd;
} }
@ -1365,7 +1365,7 @@ public abstract class Creature extends WorldObject
hitspd = 325; hitspd = 325;
} }
hitspd = ((886 - hitspd) * 5) / 2; hitspd = ((886 - hitspd) * 5) / 2;
hitspd = weaponItem.getWeaponType() == 4 ? (hitspd -= 50) : (weaponItem.getWeaponType() == 10 ? (hit == 1 ? (hitspd -= 750) : (hitspd -= 100)) : (weaponItem.getWeaponType() == 9 ? (hit == 1 ? (hitspd -= 750) : (hitspd -= 100)) : (((weaponItem.getItemId() == 248) || (weaponItem.getItemId() == 252)) && (weaponItem.getWeaponType() == 8) ? (hit == 1 ? (hitspd -= 750) : (hitspd -= 150)) : ((weaponItem.getItemId() != 248) && (weaponItem.getItemId() != 252) && (weaponItem.getWeaponType() == 8) ? (hitspd -= 250) : (hitspd -= 200))))); hitspd = weaponItem.getWeaponType() == Weapon.WEAPON_TYPE_DAGGER ? (hitspd -= 50) : (weaponItem.getWeaponType() == Weapon.WEAPON_TYPE_DUALFIST ? (hit == 1 ? (hitspd -= 750) : (hitspd -= 100)) : (weaponItem.getWeaponType() == Weapon.WEAPON_TYPE_DUAL ? (hit == 1 ? (hitspd -= 750) : (hitspd -= 100)) : (((weaponItem.getItemId() == 248) || (weaponItem.getItemId() == 252)) && (weaponItem.getWeaponType() == Weapon.WEAPON_TYPE_FIST) ? (hit == 1 ? (hitspd -= 750) : (hitspd -= 150)) : ((weaponItem.getItemId() != 248) && (weaponItem.getItemId() != 252) && (weaponItem.getWeaponType() == Weapon.WEAPON_TYPE_FIST) ? (hitspd -= 250) : (hitspd -= 200)))));
return hitspd; return hitspd;
} }

View File

@ -48,7 +48,7 @@ public class ItemInstance extends WorldObject
public boolean isEquipable() public boolean isEquipable()
{ {
return (_item.getBodyPart() != 0) && !(_item instanceof EtcItem); return (_item.getBodyPart() != Item.SLOT_NONE) && !(_item instanceof EtcItem);
} }
public boolean isEquipped() public boolean isEquipped()

View File

@ -1184,7 +1184,7 @@ public class PlayerInstance extends Creature
public int getAttackRange() public int getAttackRange()
{ {
final Weapon weapon = getActiveWeapon(); final Weapon weapon = getActiveWeapon();
if ((weapon != null) && (weapon.getWeaponType() == 5)) if ((weapon != null) && (weapon.getWeaponType() == Weapon.WEAPON_TYPE_BOW))
{ {
return 500; return 500;
} }
@ -1495,19 +1495,19 @@ public class PlayerInstance extends Creature
final int weaponType = getActiveWeapon().getWeaponType(); final int weaponType = getActiveWeapon().getWeaponType();
final int skillId = skill.getId(); final int skillId = skill.getId();
if ((skillId == 56) && (weaponType != 5)) if ((skillId == 56) && (weaponType != Weapon.WEAPON_TYPE_BOW))
{ {
return; return;
} }
if ((skillId == 16) && (weaponType != 4)) if ((skillId == 16) && (weaponType != Weapon.WEAPON_TYPE_DAGGER))
{ {
return; return;
} }
if ((skillId == 3) && (weaponType != 3) && (weaponType != 2)) if ((skillId == 3) && (weaponType != Weapon.WEAPON_TYPE_BLUNT) && (weaponType != Weapon.WEAPON_TYPE_SWORD))
{ {
return; return;
} }
if ((skillId == 29) && (weaponType != 10)) if ((skillId == 29) && (weaponType != Weapon.WEAPON_TYPE_DUALFIST))
{ {
return; return;
} }
@ -1653,11 +1653,11 @@ public class PlayerInstance extends Creature
protected boolean isUsingDualWeapon() protected boolean isUsingDualWeapon()
{ {
final Weapon weaponItem = getActiveWeapon(); final Weapon weaponItem = getActiveWeapon();
if (weaponItem.getWeaponType() == 9) if (weaponItem.getWeaponType() == Weapon.WEAPON_TYPE_DUAL)
{ {
return true; return true;
} }
if (weaponItem.getWeaponType() == 10) if (weaponItem.getWeaponType() == Weapon.WEAPON_TYPE_DUALFIST)
{ {
return true; return true;
} }

View File

@ -18,6 +18,7 @@
package org.l2jmobius.gameserver.network.serverpackets; package org.l2jmobius.gameserver.network.serverpackets;
import org.l2jmobius.gameserver.model.actor.instance.ItemInstance; import org.l2jmobius.gameserver.model.actor.instance.ItemInstance;
import org.l2jmobius.gameserver.templates.Item;
public class EquipUpdate extends ServerBasePacket public class EquipUpdate extends ServerBasePacket
{ {
@ -40,72 +41,72 @@ public class EquipUpdate extends ServerBasePacket
writeD(_item.getObjectId()); writeD(_item.getObjectId());
switch (_item.getItem().getBodyPart()) switch (_item.getItem().getBodyPart())
{ {
case 4: case Item.SLOT_L_EAR:
{ {
bodypart = 1; bodypart = 1;
break; break;
} }
case 2: case Item.SLOT_R_EAR:
{ {
bodypart = 2; bodypart = 2;
break; break;
} }
case 8: case Item.SLOT_NECK:
{ {
bodypart = 3; bodypart = 3;
break; break;
} }
case 16: case Item.SLOT_R_FINGER:
{ {
bodypart = 4; bodypart = 4;
break; break;
} }
case 32: case Item.SLOT_L_FINGER:
{ {
bodypart = 5; bodypart = 5;
break; break;
} }
case 64: case Item.SLOT_HEAD:
{ {
bodypart = 6; bodypart = 6;
break; break;
} }
case 128: case Item.SLOT_R_HAND:
{ {
bodypart = 7; bodypart = 7;
break; break;
} }
case 256: case Item.SLOT_L_HAND:
{ {
bodypart = 8; bodypart = 8;
break; break;
} }
case 512: case Item.SLOT_GLOVES:
{ {
bodypart = 9; bodypart = 9;
break; break;
} }
case 1024: case Item.SLOT_CHEST:
{ {
bodypart = 10; bodypart = 10;
break; break;
} }
case 2048: case Item.SLOT_LEGS:
{ {
bodypart = 11; bodypart = 11;
break; break;
} }
case 4096: case Item.SLOT_FEET:
{ {
bodypart = 12; bodypart = 12;
break; break;
} }
case 8192: case Item.SLOT_BACK:
{ {
bodypart = 13; bodypart = 13;
break; break;
} }
case 16384: case Item.SLOT_LR_HAND:
{ {
bodypart = 14; bodypart = 14;
} }

View File

@ -23,6 +23,7 @@ public class Armor extends Item
public static final int ARMORTYPE_LIGHT = 2; public static final int ARMORTYPE_LIGHT = 2;
public static final int ARMORTYPE_HEAVY = 3; public static final int ARMORTYPE_HEAVY = 3;
public static final int ARMORTYPE_MAGIC = 4; public static final int ARMORTYPE_MAGIC = 4;
private int _armorType; private int _armorType;
private int _avoidModifier; private int _avoidModifier;
private int _pDef; private int _pDef;

View File

@ -23,12 +23,13 @@ public class EtcItem extends Item
public static final int TYPE_MATERIAL = 1; public static final int TYPE_MATERIAL = 1;
public static final int TYPE_PET_COLLAR = 2; public static final int TYPE_PET_COLLAR = 2;
public static final int TYPE_POTION = 3; public static final int TYPE_POTION = 3;
public static final int TYPE_RECEIPE = 4; public static final int TYPE_RECIPE = 4;
public static final int TYPE_SCROLL = 5; public static final int TYPE_SCROLL = 5;
public static final int TYPE_QUEST = 6; public static final int TYPE_QUEST = 6;
public static final int TYPE_MONEY = 7; public static final int TYPE_MONEY = 7;
public static final int TYPE_OTHER = 8; public static final int TYPE_OTHER = 8;
public static final int TYPE_SPELLBOOK = 9; public static final int TYPE_SPELLBOOK = 9;
private int _type; private int _type;
public int getEtcItemType() public int getEtcItemType()

View File

@ -24,12 +24,14 @@ public abstract class Item implements Serializable
public static final int TYPE1_WEAPON_RING_EARRING_NECKLACE = 0; public static final int TYPE1_WEAPON_RING_EARRING_NECKLACE = 0;
public static final int TYPE1_SHIELD_ARMOR = 1; public static final int TYPE1_SHIELD_ARMOR = 1;
public static final int TYPE1_ITEM_QUESTITEM_ADENA = 4; public static final int TYPE1_ITEM_QUESTITEM_ADENA = 4;
public static final int TYPE2_WEAPON = 0; public static final int TYPE2_WEAPON = 0;
public static final int TYPE2_SHIELD_ARMOR = 1; public static final int TYPE2_SHIELD_ARMOR = 1;
public static final int TYPE2_ACCESSORY = 2; public static final int TYPE2_ACCESSORY = 2;
public static final int TYPE2_QUEST = 3; public static final int TYPE2_QUEST = 3;
public static final int TYPE2_MONEY = 4; public static final int TYPE2_MONEY = 4;
public static final int TYPE2_OTHER = 5; public static final int TYPE2_OTHER = 5;
public static final int SLOT_NONE = 0; public static final int SLOT_NONE = 0;
public static final int SLOT_UNDERWEAR = 1; public static final int SLOT_UNDERWEAR = 1;
public static final int SLOT_R_EAR = 2; public static final int SLOT_R_EAR = 2;
@ -47,6 +49,7 @@ public abstract class Item implements Serializable
public static final int SLOT_BACK = 8192; public static final int SLOT_BACK = 8192;
public static final int SLOT_LR_HAND = 16384; public static final int SLOT_LR_HAND = 16384;
public static final int SLOT_FULL_ARMOR = 32768; public static final int SLOT_FULL_ARMOR = 32768;
public static final int MATERIAL_STEEL = 0; public static final int MATERIAL_STEEL = 0;
public static final int MATERIAL_FINE_STEEL = 1; public static final int MATERIAL_FINE_STEEL = 1;
public static final int MATERIAL_BLOOD_STEEL = 2; public static final int MATERIAL_BLOOD_STEEL = 2;
@ -69,12 +72,14 @@ public abstract class Item implements Serializable
public static final int MATERIAL_SCALE_OF_DRAGON = 19; public static final int MATERIAL_SCALE_OF_DRAGON = 19;
public static final int MATERIAL_DYESTUFF = 20; public static final int MATERIAL_DYESTUFF = 20;
public static final int MATERIAL_COBWEB = 21; public static final int MATERIAL_COBWEB = 21;
public static final int CRYSTAL_NONE = 1; public static final int CRYSTAL_NONE = 1;
public static final int CRYSTAL_D = 2; public static final int CRYSTAL_D = 2;
public static final int CRYSTAL_C = 3; public static final int CRYSTAL_C = 3;
public static final int CRYSTAL_B = 4; public static final int CRYSTAL_B = 4;
public static final int CRYSTAL_A = 5; public static final int CRYSTAL_A = 5;
public static final int CRYSTAL_S = 6; public static final int CRYSTAL_S = 6;
private int _itemId; private int _itemId;
private String _name; private String _name;
private int _type1; private int _type1;

View File

@ -29,6 +29,7 @@ public class Weapon extends Item
public static final int WEAPON_TYPE_FIST = 8; public static final int WEAPON_TYPE_FIST = 8;
public static final int WEAPON_TYPE_DUAL = 9; public static final int WEAPON_TYPE_DUAL = 9;
public static final int WEAPON_TYPE_DUALFIST = 10; public static final int WEAPON_TYPE_DUALFIST = 10;
private int _soulShotCount; private int _soulShotCount;
private int _spiritShotCount; private int _spiritShotCount;
private int _pDam; private int _pDam;