Merged with released L2J-Unity files.
This commit is contained in:
@@ -1,118 +1,104 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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 java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.ShotType;
|
||||
import com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jmobius.gameserver.model.items.L2Weapon;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.items.type.ActionType;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jmobius.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;
|
||||
}
|
||||
|
||||
final L2PcInstance activeChar = (L2PcInstance) playable;
|
||||
final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
|
||||
final L2Weapon weaponItem = activeChar.getActiveWeaponItem();
|
||||
final SkillHolder[] skills = item.getItem().getSkills();
|
||||
|
||||
final 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
|
||||
final 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;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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 java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.ItemSkillType;
|
||||
import com.l2jmobius.gameserver.enums.ShotType;
|
||||
import com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemSkillHolder;
|
||||
import com.l2jmobius.gameserver.model.items.L2Weapon;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.items.type.ActionType;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jmobius.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;
|
||||
}
|
||||
|
||||
final L2PcInstance activeChar = (L2PcInstance) playable;
|
||||
final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
|
||||
final L2Weapon weaponItem = activeChar.getActiveWeaponItem();
|
||||
final List<ItemSkillHolder> skills = item.getItem().getSkills(ItemSkillType.NORMAL);
|
||||
|
||||
final int itemId = item.getId();
|
||||
|
||||
if (skills == null)
|
||||
{
|
||||
_log.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
|
||||
final 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);
|
||||
|
||||
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user