@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 public void onStart(BuffInfo info) { L2Character target = info.getEffected(); L2Character activeChar = info.getEffector(); if ((target == null) || target.isDead() || target.isDoor() || target.isInvul()) { return; } double amount = _power; double staticShotBonus = 0; int mAtkMul = 1; boolean sps = info.getSkill().isMagic() && activeChar.isChargedShot(ShotType.SPIRITSHOTS); boolean bss = info.getSkill().isMagic() && activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS); if (((sps || bss) && (activeChar.isPlayer() && activeChar.getActingPlayer().isMageClass())) || activeChar.isSummon()) { staticShotBonus = info.getSkill().getMpConsume(); // static bonus for spiritshots mAtkMul = bss ? 4 : 2; staticShotBonus *= bss ? 2.4 : 1.0; } else if ((sps || bss) && activeChar.isNpc()) { staticShotBonus = 2.4 * info.getSkill().getMpConsume(); // always blessed spiritshots mAtkMul = 4; } else { // no static bonus // grade dynamic bonus final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance(); if (weaponInst != null) { mAtkMul = weaponInst.getItem().getCrystalType() == CrystalType.S84 ? 4 : weaponInst.getItem().getCrystalType() == CrystalType.S80 ? 2 : 1; } // shot dynamic bonus mAtkMul = bss ? mAtkMul * 4 : mAtkMul + 1; } if (!info.getSkill().isStatic()) { amount += staticShotBonus + Math.sqrt(mAtkMul * activeChar.getMAtk(activeChar, null)); amount = target.calcStat(Stats.HEAL_EFFECT, amount, null, null); // Heal critic, since CT2.3 Gracia Final if (info.getSkill().isMagic() && Formulas.calcMCrit(activeChar.getMCriticalHit(target, info.getSkill()))) { amount *= 3; activeChar.sendPacket(SystemMessageId.M_CRITICAL); activeChar.sendPacket( new ExMagicAttackInfo( activeChar.getObjectId(), target.getObjectId(), ExMagicAttackInfo.CRITICAL_HEAL)); if (target.isPlayer() && (target != activeChar)) { target.sendPacket( new ExMagicAttackInfo( activeChar.getObjectId(), target.getObjectId(), ExMagicAttackInfo.CRITICAL_HEAL)); } } } // Prevents overheal and negative amount final double healAmount = Math.max(Math.min(amount, target.getMaxRecoverableHp() - target.getCurrentHp()), 0); if (healAmount != 0) { target.setCurrentHp(healAmount + target.getCurrentHp()); } if (target.isPlayer()) { if (info.getSkill().getId() == 4051) { target.sendPacket(SystemMessageId.REJUVENATING_HP); } else if (healAmount != 0) { if (activeChar.isPlayer() && (activeChar != target)) { SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S2_HP_HAS_BEEN_RESTORED_BY_C1); sm.addString(activeChar.getName()); sm.addInt((int) healAmount); target.sendPacket(sm); } else { SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HP_HAS_BEEN_RESTORED); sm.addInt((int) healAmount); target.sendPacket(sm); } } amount = Math.max( Math.min(amount - healAmount, target.getMaxRecoverableCp() - target.getCurrentCp()), 0); if (amount != 0) { target.setCurrentCp(amount + target.getCurrentCp()); if (activeChar.isPlayer() && (activeChar != target)) { SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S2_CP_HAS_BEEN_RESTORED_BY_C1); sm.addString(activeChar.getName()); sm.addInt((int) amount); target.sendPacket(sm); } else { SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CP_HAS_BEEN_RESTORED); sm.addInt((int) amount); target.sendPacket(sm); } } } }
public ConfirmDlg addItemName(L2ItemInstance item) { return addItemName(item.getItem().getItemId()); }
private void setEnchant(L2PcInstance activeChar, int ench, int armorType) { // get the target L2Object target = activeChar.getTarget(); if (target == null) { target = activeChar; } L2PcInstance player = null; if (target instanceof L2PcInstance) { player = (L2PcInstance) target; } else { activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET); return; } // now we need to find the equipped weapon of the targeted character... int curEnchant = 0; // display purposes only L2ItemInstance itemInstance = null; // only attempt to enchant if there is a weapon equipped L2ItemInstance parmorInstance = player.getInventory().getPaperdollItem(armorType); if ((parmorInstance != null) && (parmorInstance.getLocationSlot() == armorType)) { itemInstance = parmorInstance; } if (itemInstance != null) { curEnchant = itemInstance.getEnchantLevel(); // set enchant value player.getInventory().unEquipItemInSlot(armorType); itemInstance.setEnchantLevel(ench); player.getInventory().equipItem(itemInstance); // send packets InventoryUpdate iu = new InventoryUpdate(); iu.addModifiedItem(itemInstance); player.sendPacket(iu); player.broadcastPacket(new CharInfo(player)); player.sendPacket(new UserInfo(player)); player.broadcastPacket(new ExBrExtraUserInfo(player)); // informations activeChar.sendMessage( "Changed enchantment of " + player.getName() + "'s " + itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench + "."); player.sendMessage( "Admin has changed the enchantment of your " + itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench + "."); } }
@Override protected void runImpl() { L2PcInstance activeChar = getClient().getActiveChar(); if (activeChar == null) { _log.fine("RequestCrystalizeItem: activeChar was null"); return; } if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("crystallize")) { activeChar.sendMessage("You are crystallizing too fast."); return; } if (_count <= 0) { Util.handleIllegalPlayerAction( activeChar, "[RequestCrystallizeItem] count <= 0! ban! oid: " + _objectId + " owner: " + activeChar.getName(), Config.DEFAULT_PUNISH); return; } if ((activeChar.getPrivateStoreType() != PrivateStoreType.NONE) || !activeChar.isInCrystallize()) { activeChar.sendPacket( SystemMessageId .WHILE_OPERATING_A_PRIVATE_STORE_OR_WORKSHOP_YOU_CANNOT_DISCARD_DESTROY_OR_TRADE_AN_ITEM); return; } int skillLevel = activeChar.getSkillLevel(CommonSkill.CRYSTALLIZE.getId()); if (skillLevel <= 0) { activeChar.sendPacket( SystemMessageId .YOU_MAY_NOT_CRYSTALLIZE_THIS_ITEM_YOUR_CRYSTALLIZATION_SKILL_LEVEL_IS_TOO_LOW); activeChar.sendPacket(ActionFailed.STATIC_PACKET); if ((activeChar.getRace() != Race.DWARF) && (activeChar.getClassId().ordinal() != 117) && (activeChar.getClassId().ordinal() != 55)) { _log.info( "Player " + activeChar.getClient() + " used crystalize with classid: " + activeChar.getClassId().ordinal()); } return; } PcInventory inventory = activeChar.getInventory(); if (inventory != null) { L2ItemInstance item = inventory.getItemByObjectId(_objectId); if (item == null) { activeChar.sendPacket(ActionFailed.STATIC_PACKET); return; } if (item.isHeroItem()) { return; } if (_count > item.getCount()) { _count = activeChar.getInventory().getItemByObjectId(_objectId).getCount(); } } final L2ItemInstance itemToRemove = activeChar.getInventory().getItemByObjectId(_objectId); if ((itemToRemove == null) || itemToRemove.isShadowItem() || itemToRemove.isTimeLimitedItem()) { return; } if (!itemToRemove.getItem().isCrystallizable() || (itemToRemove.getItem().getCrystalCount() <= 0) || (itemToRemove.getItem().getCrystalType() == CrystalType.NONE)) { _log.warning( activeChar.getName() + " (" + activeChar.getObjectId() + ") tried to crystallize " + itemToRemove.getItem().getId()); return; } if (!activeChar.getInventory().canManipulateWithItemId(itemToRemove.getId())) { activeChar.sendMessage("You cannot use this item."); return; } // Check if the char can crystallize items and return if false; boolean canCrystallize = true; switch (itemToRemove.getItem().getCrystalTypePlus()) { case D: { if (skillLevel < 1) { canCrystallize = false; } break; } case C: { if (skillLevel < 2) { canCrystallize = false; } break; } case B: { if (skillLevel < 3) { canCrystallize = false; } break; } case A: { if (skillLevel < 4) { canCrystallize = false; } break; } case S: { if (skillLevel < 5) { canCrystallize = false; } break; } case R: { if (skillLevel < 6) { canCrystallize = false; } break; } } if (!canCrystallize) { activeChar.sendPacket( SystemMessageId .YOU_MAY_NOT_CRYSTALLIZE_THIS_ITEM_YOUR_CRYSTALLIZATION_SKILL_LEVEL_IS_TOO_LOW); activeChar.sendPacket(ActionFailed.STATIC_PACKET); return; } // activeChar.setInCrystallize(true); // unequip if needed SystemMessage sm; if (itemToRemove.isEquipped()) { L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot()); InventoryUpdate iu = new InventoryUpdate(); for (L2ItemInstance item : unequiped) { iu.addModifiedItem(item); } activeChar.sendPacket(iu); if (itemToRemove.getEnchantLevel() > 0) { sm = SystemMessage.getSystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED); sm.addInt(itemToRemove.getEnchantLevel()); sm.addItemName(itemToRemove); } else { sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED); sm.addItemName(itemToRemove); } activeChar.sendPacket(sm); } // remove from inventory final L2ItemInstance removedItem = activeChar.getInventory().destroyItem("Crystalize", _objectId, _count, activeChar, null); final InventoryUpdate iu = new InventoryUpdate(); iu.addRemovedItem(removedItem); activeChar.sendPacket(iu); final int crystalId = itemToRemove.getItem().getCrystalItemId(); final int crystalAmount = itemToRemove.getCrystalCount(); final List<ItemChanceHolder> items = new ArrayList<>(); items.add(new ItemChanceHolder(crystalId, 100, crystalAmount)); final CrystalizationData data = ItemCrystalizationData.getInstance().getCrystalization(itemToRemove.getId()); if (data != null) { data.getItems().stream().filter(holder -> (holder.getId() != crystalId)).forEach(items::add); } for (ItemChanceHolder holder : items) { final double rand = Rnd.nextDouble() * 100; if (rand < holder.getChance()) { // add crystals final L2ItemInstance createdItem = activeChar .getInventory() .addItem("Crystalize", holder.getId(), holder.getCount(), activeChar, activeChar); sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S); sm.addItemName(createdItem); sm.addLong(holder.getCount()); activeChar.sendPacket(sm); } } sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_CRYSTALLIZED); sm.addItemName(removedItem); activeChar.sendPacket(sm); activeChar.broadcastUserInfo(); L2World.getInstance().removeObject(removedItem); activeChar.setInCrystallize(false); }