l2j_mobius/trunk/dist/game/data/scripts/handlers/itemhandlers/BlessedSpiritShot.java
MobiusDev 2beeb5bfbc -Small fix for Rage Aura debuff
-Update TriggerForce effect to avoid visual bug when Sigel' class use any aura on party, and some bug fixes on this effect.
-Implemented soulshot\spiritshot\blessed spiritshot damage bonus from enchanted weapon
-Implemented soulshot\spiritshot\blessed spiritshot damage bonus from Jewels Ruby\Sapphire
-Implemented Ruby\Sapphire\Topaz\Opal\Obsidian\Diamond\Emerald\Aquamarine\Pearl Jewels and its stats\skills.
-Changed compound jewels rate (in official servers - chances are lower (and from 3-5 lvls - greatly lower)
-Added visual effect to SS\SPS\BSPS if you equip Ruby\Sapphire 3\4\5 lvls (blue\yellow\red glow effects)
-New parameter weaponElementPower - increase weapon attribute power (if fire added in weapon - this parameter increase fire.. also about others)
-Small update skills.xsd to remove some eclipse warnings.

Contributed by NviX.
2015-07-11 16:22:19 +00:00

120 lines
4.6 KiB
Java

/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 java.util.logging.Level;
import com.l2jserver.gameserver.enums.ShotType;
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.holders.SkillHolder;
import com.l2jserver.gameserver.model.items.L2Weapon;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.model.items.type.ActionType;
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 boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!playable.isPlayer())
{
playable.sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_THIS_ITEM);
return false;
}
L2PcInstance activeChar = (L2PcInstance) playable;
L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
L2Weapon weaponItem = activeChar.getActiveWeaponItem();
final SkillHolder[] skills = item.getItem().getSkills();
int itemId = item.getId();
if (skills == null)
{
_log.log(Level.WARNING, getClass().getSimpleName() + ": is missing skills!");
return false;
}
// Check if Blessed SpiritShot can be used
if ((weaponInst == null) || (weaponItem == null) || (weaponItem.getSpiritShotCount() == 0))
{
if (!activeChar.getAutoSoulShot().contains(itemId))
{
activeChar.sendPacket(SystemMessageId.YOU_MAY_NOT_USE_SPIRITSHOTS);
}
return false;
}
// Check if Blessed SpiritShot is already active (it can be charged over SpiritShot)
if (activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS))
{
return false;
}
// Check for correct grade
boolean gradeCheck = item.isEtcItem() && (item.getEtcItem().getDefaultAction() == ActionType.SPIRITSHOT) && (weaponInst.getItem().getCrystalTypePlus() == item.getItem().getCrystalTypePlus());
if (!gradeCheck)
{
if (!activeChar.getAutoSoulShot().contains(itemId))
{
activeChar.sendPacket(SystemMessageId.YOUR_SPIRITSHOT_DOES_NOT_MATCH_THE_WEAPON_S_GRADE);
}
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.YOU_DO_NOT_HAVE_ENOUGH_SPIRITSHOT_FOR_THAT);
}
return false;
}
// Send message to client
activeChar.sendPacket(SystemMessageId.YOUR_SPIRITSHOT_HAS_BEEN_ENABLED);
activeChar.setChargedShot(ShotType.BLESSED_SPIRITSHOTS, true);
// Visual effect change if player has equipped Sapphire lvl 3 or higher
if ((activeChar.getInventory().getItemByItemId(38931) != null) && (activeChar.getInventory().getItemByItemId(38931).isEquipped()))
{
Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, 17821, 2, 0, 0), 600);
}
else if ((activeChar.getInventory().getItemByItemId(38930) != null) && (activeChar.getInventory().getItemByItemId(38930).isEquipped()))
{
Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, 17820, 2, 0, 0), 600);
}
else if ((activeChar.getInventory().getItemByItemId(38929) != null) && (activeChar.getInventory().getItemByItemId(38929).isEquipped()))
{
Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, 17819, 2, 0, 0), 600);
}
else
{
Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, skills[0].getSkillId(), skills[0].getSkillLvl(), 0, 0), 600);
}
return true;
}
}