123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- /*
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see <http://www.gnu.org/licenses/>.
- */
- package handlers.itemhandlers;
- import com.l2jserver.gameserver.handler.IItemHandler;
- import com.l2jserver.gameserver.model.actor.L2Playable;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- import com.l2jserver.gameserver.model.items.L2Item;
- import com.l2jserver.gameserver.model.items.L2Weapon;
- import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
- import com.l2jserver.gameserver.network.SystemMessageId;
- import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
- import com.l2jserver.gameserver.util.Broadcast;
- public class BlessedSpiritShot implements IItemHandler
- {
- @Override
- public synchronized boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
- {
- if (!(playable instanceof L2PcInstance))
- return false;
-
- L2PcInstance activeChar = (L2PcInstance) playable;
- L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
- L2Weapon weaponItem = activeChar.getActiveWeaponItem();
- int itemId = item.getItemId();
-
- // Check if Blessed SpiritShot can be used
- if (weaponInst == null || weaponItem == null || weaponItem.getSpiritShotCount() == 0)
- {
- if (!activeChar.getAutoSoulShot().contains(itemId))
- activeChar.sendPacket(SystemMessageId.CANNOT_USE_SPIRITSHOTS);
- return false;
- }
-
- // Check if Blessed SpiritShot is already active (it can be charged over SpiritShot)
- if (weaponInst.getChargedSpiritshot() != L2ItemInstance.CHARGED_NONE)
- return false;
-
- // Check for correct grade
- final int weaponGrade = weaponItem.getCrystalType();
-
- boolean gradeCheck = true;
-
- switch (weaponGrade)
- {
- case L2Item.CRYSTAL_NONE:
- if (itemId != 3947)
- gradeCheck = false;
- break;
- case L2Item.CRYSTAL_D:
- if (itemId != 3948 && itemId != 22072)
- gradeCheck = false;
- break;
- case L2Item.CRYSTAL_C:
- if (itemId != 3949 && itemId != 22073)
- gradeCheck = false;
- break;
- case L2Item.CRYSTAL_B:
- if (itemId != 3950 && itemId != 22074)
- gradeCheck = false;
- break;
- case L2Item.CRYSTAL_A:
- if (itemId != 3951 && itemId != 22075)
- gradeCheck = false;
- break;
- case L2Item.CRYSTAL_S:
- case L2Item.CRYSTAL_S80:
- case L2Item.CRYSTAL_S84:
- if (itemId != 3952 && itemId != 22076)
- gradeCheck = false;
- break;
- }
-
- if (!gradeCheck)
- {
- if (!activeChar.getAutoSoulShot().contains(itemId))
- activeChar.sendPacket(SystemMessageId.SPIRITSHOTS_GRADE_MISMATCH);
-
- return false;
- }
-
-
- // Consume Blessed SpiritShot if player has enough of them
- if (!activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), weaponItem.getSpiritShotCount(), null, false))
- {
- if (!activeChar.disableAutoShot(itemId))
- activeChar.sendPacket(SystemMessageId.NOT_ENOUGH_SPIRITSHOTS);
- return false;
- }
-
- // Charge Blessed SpiritShot
- weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT);
-
- // Send message to client
- activeChar.sendPacket(SystemMessageId.ENABLED_SPIRITSHOT);
- int skillId = 0;
- switch (itemId)
- {
- case 3947:
- skillId=2061;
- break;
- case 3948:
- skillId=2160;
- break;
- case 3949:
- skillId=2161;
- break;
- case 3950:
- skillId=2162;
- break;
- case 3951:
- skillId=2163;
- break;
- case 3952:
- skillId=2164;
- break;
- case 22072:
- skillId=26050;
- break;
- case 22073:
- skillId=26051;
- break;
- case 22074:
- skillId=26052;
- break;
- case 22075:
- skillId=26053;
- break;
- case 22076:
- skillId=26054;
- break;
-
- }
- Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, skillId, 1, 0, 0), 360000);
- return true;
- }
- }
|