public byte getAttackElement() { L2ItemInstance weaponInstance = _activeChar.getActiveWeaponInstance(); // 1st order - weapon element if ((weaponInstance != null) && (weaponInstance.getAttackElementType() >= 0)) { return weaponInstance.getAttackElementType(); } // temp fix starts int tempVal = 0, stats[] = {0, 0, 0, 0, 0, 0}; byte returnVal = -2; stats[0] = (int) calcStat(Stats.FIRE_POWER, _activeChar.getTemplate().getBaseFire()); stats[1] = (int) calcStat(Stats.WATER_POWER, _activeChar.getTemplate().getBaseWater()); stats[2] = (int) calcStat(Stats.WIND_POWER, _activeChar.getTemplate().getBaseWind()); stats[3] = (int) calcStat(Stats.EARTH_POWER, _activeChar.getTemplate().getBaseEarth()); stats[4] = (int) calcStat(Stats.HOLY_POWER, _activeChar.getTemplate().getBaseHoly()); stats[5] = (int) calcStat(Stats.DARK_POWER, _activeChar.getTemplate().getBaseDark()); for (byte x = 0; x < 6; x++) { if (stats[x] > tempVal) { returnVal = x; tempVal = stats[x]; } } return returnVal; // temp fix ends /* * uncomment me once deadlocks in getAllEffects() fixed return _activeChar.getElementIdFromEffects(); */ }
@Override protected void writeImpl() { writeC(0xFE); writeH(0x6C); writeD(_item.getObjectId()); writeD(_item.getDisplayId()); writeD(_item.getLocationSlot()); writeQ(_item.getCount()); writeH(_item.getItem().getType2()); writeH(_item.getCustomType1()); writeH(_item.isEquipped() ? 0x01 : 0x00); writeD(_item.getItem().getBodyPart()); writeH(_item.getEnchantLevel()); writeH(_item.getCustomType2()); if (_item.isAugmented()) { writeD(_item.getAugmentation().getAugmentationId()); } else { writeD(0x00); } writeD(_item.getMana()); writeD(_item.isTimeLimitedItem() ? (int) (_item.getRemainingTime() / 1000) : -9999); writeH(_item.getAttackElementType()); writeH(_item.getAttackElementPower()); for (byte i = 0; i < 6; i++) { writeH(_item.getElementDefAttr(i)); } // Enchant Effects for (int op : _item.getEnchantOptions()) { writeH(op); } }
@Override protected void readImpl() { L2PcInstance player = getClient().getActiveChar(); if (player == null) { return; } int count = readD(); if ((count < 1) || (count > Config.MAX_ITEM_IN_PACKET) || ((count * BATCH_LENGTH) != _buf.remaining())) { return; } _items = new Item[count]; for (int i = 0; i < count; i++) { int itemId = readD(); int enchantLevel = readD(); long cnt = readQ(); long price = readQ(); if ((itemId < 1) || (cnt < 1) || (price < 0)) { _items = null; return; } int attackAttribute = readH(); // Attack Attribute Type int attackAttributeValue = readH(); // Attack Attribute Value int defenseAttributes[] = new int[6]; for (int h = 0; h < 6; h++) { defenseAttributes[i] = readH(); // Defense attributes } int appearanceId = readD(); // Appearance ID boolean canUse = false; for (L2ItemInstance item : player.getInventory().getItemsByItemId(itemId)) { if ((enchantLevel == item.getEnchantLevel()) && (attackAttribute == item.getAttackElementType()) && (attackAttributeValue == item.getAttackElementPower()) && (appearanceId == item.getVisualId()) && (item.getElementDefAttr((byte) 0) == defenseAttributes[0]) && (item.getElementDefAttr((byte) 1) == defenseAttributes[1]) && (item.getElementDefAttr((byte) 2) == defenseAttributes[2]) && (item.getElementDefAttr((byte) 3) == defenseAttributes[3]) && (item.getElementDefAttr((byte) 4) == defenseAttributes[4]) && (item.getElementDefAttr((byte) 5) == defenseAttributes[5])) { canUse = true; break; } } if (!canUse) { enchantLevel = 0; attackAttribute = -1; attackAttributeValue = 0; defenseAttributes[0] = 0; defenseAttributes[1] = 0; defenseAttributes[2] = 0; defenseAttributes[3] = 0; defenseAttributes[4] = 0; defenseAttributes[5] = 0; appearanceId = 0; } _items[i] = new Item( itemId, cnt, price, enchantLevel, attackAttribute, attackAttributeValue, defenseAttributes, appearanceId); } }