Merged with released L2J-Unity files.
This commit is contained in:
@@ -1,61 +1,61 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.data.xml.impl.AppearanceItemData;
|
||||
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.actor.request.ShapeShiftingItemRequest;
|
||||
import com.l2jmobius.gameserver.model.items.appearance.AppearanceStone;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.appearance.ExChooseShapeShiftingItem;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class Appearance 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 player = playable.getActingPlayer();
|
||||
if (player.hasRequest(ShapeShiftingItemRequest.class))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.APPEARANCE_MODIFICATION_OR_RESTORATION_IN_PROGRESS_PLEASE_TRY_AGAIN_AFTER_COMPLETING_THIS_TASK);
|
||||
return false;
|
||||
}
|
||||
|
||||
final AppearanceStone stone = AppearanceItemData.getInstance().getStone(item.getId());
|
||||
if (stone == null)
|
||||
{
|
||||
player.sendMessage("This item is either not an appearance stone or is currently not handled!");
|
||||
return false;
|
||||
}
|
||||
|
||||
player.addRequest(new ShapeShiftingItemRequest(player, item));
|
||||
player.sendPacket(new ExChooseShapeShiftingItem(stone));
|
||||
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 com.l2jmobius.gameserver.data.xml.impl.AppearanceItemData;
|
||||
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.actor.request.ShapeShiftingItemRequest;
|
||||
import com.l2jmobius.gameserver.model.items.appearance.AppearanceStone;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.appearance.ExChooseShapeShiftingItem;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class Appearance 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 player = playable.getActingPlayer();
|
||||
if (player.hasRequest(ShapeShiftingItemRequest.class))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.APPEARANCE_MODIFICATION_OR_RESTORATION_IN_PROGRESS_PLEASE_TRY_AGAIN_AFTER_COMPLETING_THIS_TASK);
|
||||
return false;
|
||||
}
|
||||
|
||||
final AppearanceStone stone = AppearanceItemData.getInstance().getStone(item.getId());
|
||||
if (stone == null)
|
||||
{
|
||||
player.sendMessage("This item is either not an appearance stone or is currently not handled!");
|
||||
return false;
|
||||
}
|
||||
|
||||
player.addRequest(new ShapeShiftingItemRequest(player, item));
|
||||
player.sendPacket(new ExChooseShapeShiftingItem(stone));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,164 +1,138 @@
|
||||
/*
|
||||
* 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 java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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.L2Summon;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
/**
|
||||
* Beast SoulShot Handler
|
||||
* @author Tempy
|
||||
*/
|
||||
public class BeastSoulShot 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 activeOwner = playable.getActingPlayer();
|
||||
if (!activeOwner.hasSummon())
|
||||
{
|
||||
activeOwner.sendPacket(SystemMessageId.PETS_AND_SERVITORS_ARE_NOT_AVAILABLE_AT_THIS_TIME);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2Summon pet = playable.getPet();
|
||||
if ((pet != null) && pet.isDead())
|
||||
{
|
||||
activeOwner.sendPacket(SystemMessageId.SOULSHOTS_AND_SPIRITSHOTS_ARE_NOT_AVAILABLE_FOR_A_DEAD_PET_OR_SERVITOR_SAD_ISN_T_IT);
|
||||
return false;
|
||||
}
|
||||
|
||||
final List<L2Summon> aliveServitor = playable.getServitors().values().stream().filter(s -> !s.isDead()).collect(Collectors.toList());
|
||||
if (aliveServitor.isEmpty())
|
||||
{
|
||||
activeOwner.sendPacket(SystemMessageId.SOULSHOTS_AND_SPIRITSHOTS_ARE_NOT_AVAILABLE_FOR_A_DEAD_PET_OR_SERVITOR_SAD_ISN_T_IT);
|
||||
return false;
|
||||
}
|
||||
|
||||
final int itemId = item.getId();
|
||||
final long shotCount = item.getCount();
|
||||
final SkillHolder[] skills = item.getItem().getSkills();
|
||||
short shotConsumption = 0;
|
||||
|
||||
if ((pet != null) && !pet.isChargedShot(ShotType.SOULSHOTS))
|
||||
{
|
||||
shotConsumption += pet.getSoulShotsPerHit();
|
||||
}
|
||||
|
||||
for (L2Summon servitors : aliveServitor)
|
||||
{
|
||||
if (!servitors.isChargedShot(ShotType.SOULSHOTS))
|
||||
{
|
||||
shotConsumption += servitors.getSoulShotsPerHit();
|
||||
}
|
||||
}
|
||||
|
||||
if (skills == null)
|
||||
{
|
||||
_log.log(Level.WARNING, getClass().getSimpleName() + ": is missing skills!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (shotCount < shotConsumption)
|
||||
{
|
||||
// Not enough Soulshots to use.
|
||||
if (!activeOwner.disableAutoShot(itemId))
|
||||
{
|
||||
activeOwner.sendPacket(SystemMessageId.YOU_DON_T_HAVE_ENOUGH_SOULSHOTS_NEEDED_FOR_A_PET_SERVITOR);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the player doesn't have enough beast soulshot remaining, remove any auto soulshot task.
|
||||
if (!activeOwner.destroyItemWithoutTrace("Consume", item.getObjectId(), shotConsumption, null, false))
|
||||
{
|
||||
if (!activeOwner.disableAutoShot(itemId))
|
||||
{
|
||||
activeOwner.sendPacket(SystemMessageId.YOU_DON_T_HAVE_ENOUGH_SOULSHOTS_NEEDED_FOR_A_PET_SERVITOR);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Pet uses the power of spirit.
|
||||
activeOwner.sendPacket(SystemMessageId.YOUR_PET_USES_SPIRITSHOT);
|
||||
if ((pet != null) && !pet.isChargedShot(ShotType.SOULSHOTS))
|
||||
{
|
||||
pet.setChargedShot(ShotType.SOULSHOTS, true);
|
||||
// Visual effect change if player has equipped Ruby lvl 3 or higher
|
||||
if ((activeOwner.getInventory().getItemByItemId(38859) != null) && activeOwner.getInventory().getItemByItemId(38859).isEquipped())
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(pet, pet, 17817, 1, 0, 0), 600);
|
||||
}
|
||||
else if ((activeOwner.getInventory().getItemByItemId(38858) != null) && activeOwner.getInventory().getItemByItemId(38858).isEquipped())
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(pet, pet, 17816, 1, 0, 0), 600);
|
||||
}
|
||||
else if ((activeOwner.getInventory().getItemByItemId(38857) != null) && activeOwner.getInventory().getItemByItemId(38857).isEquipped())
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(pet, pet, 17815, 1, 0, 0), 600);
|
||||
}
|
||||
else
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(pet, pet, skills[0].getSkillId(), skills[0].getSkillLvl(), 0, 0), 600);
|
||||
}
|
||||
}
|
||||
|
||||
aliveServitor.forEach(s ->
|
||||
{
|
||||
if (!s.isChargedShot(ShotType.SOULSHOTS))
|
||||
{
|
||||
s.setChargedShot(ShotType.SOULSHOTS, true);
|
||||
// Visual effect change if player has equipped Ruby lvl 3 or higher
|
||||
if ((activeOwner.getInventory().getItemByItemId(38859) != null) && (activeOwner.getInventory().getItemByItemId(38859).isEquipped()))
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(s, s, 17817, 1, 0, 0), 600);
|
||||
}
|
||||
else if ((activeOwner.getInventory().getItemByItemId(38858) != null) && (activeOwner.getInventory().getItemByItemId(38858).isEquipped()))
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(s, s, 17816, 1, 0, 0), 600);
|
||||
}
|
||||
else if ((activeOwner.getInventory().getItemByItemId(38857) != null) && (activeOwner.getInventory().getItemByItemId(38857).isEquipped()))
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(s, s, 17815, 1, 0, 0), 600);
|
||||
}
|
||||
else
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(s, s, 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 java.util.stream.Collectors;
|
||||
|
||||
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.L2Summon;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemSkillHolder;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
/**
|
||||
* Beast SoulShot Handler
|
||||
* @author Tempy
|
||||
*/
|
||||
public class BeastSoulShot 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 activeOwner = playable.getActingPlayer();
|
||||
if (!activeOwner.hasSummon())
|
||||
{
|
||||
activeOwner.sendPacket(SystemMessageId.PETS_AND_SERVITORS_ARE_NOT_AVAILABLE_AT_THIS_TIME);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2Summon pet = playable.getPet();
|
||||
if ((pet != null) && pet.isDead())
|
||||
{
|
||||
activeOwner.sendPacket(SystemMessageId.SOULSHOTS_AND_SPIRITSHOTS_ARE_NOT_AVAILABLE_FOR_A_DEAD_PET_OR_SERVITOR_SAD_ISN_T_IT);
|
||||
return false;
|
||||
}
|
||||
|
||||
final List<L2Summon> aliveServitor = playable.getServitors().values().stream().filter(s -> !s.isDead()).collect(Collectors.toList());
|
||||
if (aliveServitor.isEmpty())
|
||||
{
|
||||
activeOwner.sendPacket(SystemMessageId.SOULSHOTS_AND_SPIRITSHOTS_ARE_NOT_AVAILABLE_FOR_A_DEAD_PET_OR_SERVITOR_SAD_ISN_T_IT);
|
||||
return false;
|
||||
}
|
||||
|
||||
final int itemId = item.getId();
|
||||
final long shotCount = item.getCount();
|
||||
final List<ItemSkillHolder> skills = item.getItem().getSkills(ItemSkillType.NORMAL);
|
||||
short shotConsumption = 0;
|
||||
|
||||
if (pet != null)
|
||||
{
|
||||
if (!pet.isChargedShot(ShotType.SOULSHOTS))
|
||||
{
|
||||
shotConsumption += pet.getSoulShotsPerHit();
|
||||
}
|
||||
}
|
||||
|
||||
for (L2Summon servitors : aliveServitor)
|
||||
{
|
||||
if (!servitors.isChargedShot(ShotType.SOULSHOTS))
|
||||
{
|
||||
shotConsumption += servitors.getSoulShotsPerHit();
|
||||
}
|
||||
}
|
||||
|
||||
if (skills == null)
|
||||
{
|
||||
_log.warning(getClass().getSimpleName() + ": is missing skills!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (shotCount < shotConsumption)
|
||||
{
|
||||
// Not enough Soulshots to use.
|
||||
if (!activeOwner.disableAutoShot(itemId))
|
||||
{
|
||||
activeOwner.sendPacket(SystemMessageId.YOU_DON_T_HAVE_ENOUGH_SOULSHOTS_NEEDED_FOR_A_PET_SERVITOR);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the player doesn't have enough beast soulshot remaining, remove any auto soulshot task.
|
||||
if (!activeOwner.destroyItemWithoutTrace("Consume", item.getObjectId(), shotConsumption, null, false))
|
||||
{
|
||||
if (!activeOwner.disableAutoShot(itemId))
|
||||
{
|
||||
activeOwner.sendPacket(SystemMessageId.YOU_DON_T_HAVE_ENOUGH_SOULSHOTS_NEEDED_FOR_A_PET_SERVITOR);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Pet uses the power of spirit.
|
||||
activeOwner.sendPacket(SystemMessageId.YOUR_PET_USES_SPIRITSHOT);
|
||||
if (pet != null)
|
||||
{
|
||||
if (!pet.isChargedShot(ShotType.SOULSHOTS))
|
||||
{
|
||||
pet.setChargedShot(ShotType.SOULSHOTS, true);
|
||||
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(pet, pet, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600));
|
||||
}
|
||||
}
|
||||
|
||||
aliveServitor.forEach(s ->
|
||||
{
|
||||
if (!s.isChargedShot(ShotType.SOULSHOTS))
|
||||
{
|
||||
s.setChargedShot(ShotType.SOULSHOTS, true);
|
||||
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(s, s, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600));
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,166 +1,140 @@
|
||||
/*
|
||||
* 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 java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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.L2Summon;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
/**
|
||||
* Beast SpiritShot Handler
|
||||
* @author Tempy
|
||||
*/
|
||||
public class BeastSpiritShot 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 activeOwner = playable.getActingPlayer();
|
||||
if (!activeOwner.hasSummon())
|
||||
{
|
||||
activeOwner.sendPacket(SystemMessageId.PETS_AND_SERVITORS_ARE_NOT_AVAILABLE_AT_THIS_TIME);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2Summon pet = playable.getPet();
|
||||
if ((pet != null) && pet.isDead())
|
||||
{
|
||||
activeOwner.sendPacket(SystemMessageId.SOULSHOTS_AND_SPIRITSHOTS_ARE_NOT_AVAILABLE_FOR_A_DEAD_PET_OR_SERVITOR_SAD_ISN_T_IT);
|
||||
return false;
|
||||
}
|
||||
|
||||
final List<L2Summon> aliveServitor = playable.getServitors().values().stream().filter(s -> !s.isDead()).collect(Collectors.toList());
|
||||
if (aliveServitor.isEmpty())
|
||||
{
|
||||
activeOwner.sendPacket(SystemMessageId.SOULSHOTS_AND_SPIRITSHOTS_ARE_NOT_AVAILABLE_FOR_A_DEAD_PET_OR_SERVITOR_SAD_ISN_T_IT);
|
||||
return false;
|
||||
}
|
||||
|
||||
final int itemId = item.getId();
|
||||
final boolean isBlessed = (itemId == 6647) || (itemId == 20334); // TODO: Unhardcode these!
|
||||
final SkillHolder[] skills = item.getItem().getSkills();
|
||||
|
||||
final ShotType shotType = isBlessed ? ShotType.BLESSED_SPIRITSHOTS : ShotType.SPIRITSHOTS;
|
||||
|
||||
short shotConsumption = 0;
|
||||
if ((pet != null) && !pet.isChargedShot(shotType))
|
||||
{
|
||||
shotConsumption += pet.getSpiritShotsPerHit();
|
||||
}
|
||||
|
||||
for (L2Summon servitors : aliveServitor)
|
||||
{
|
||||
if (!servitors.isChargedShot(shotType))
|
||||
{
|
||||
shotConsumption += servitors.getSpiritShotsPerHit();
|
||||
}
|
||||
}
|
||||
|
||||
if (skills == null)
|
||||
{
|
||||
_log.log(Level.WARNING, getClass().getSimpleName() + ": is missing skills!");
|
||||
return false;
|
||||
}
|
||||
|
||||
final long shotCount = item.getCount();
|
||||
if (shotCount < shotConsumption)
|
||||
{
|
||||
// Not enough SpiritShots to use.
|
||||
if (!activeOwner.disableAutoShot(itemId))
|
||||
{
|
||||
activeOwner.sendPacket(SystemMessageId.YOU_DON_T_HAVE_ENOUGH_SPIRITSHOTS_NEEDED_FOR_A_PET_SERVITOR);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!activeOwner.destroyItemWithoutTrace("Consume", item.getObjectId(), shotConsumption, null, false))
|
||||
{
|
||||
if (!activeOwner.disableAutoShot(itemId))
|
||||
{
|
||||
activeOwner.sendPacket(SystemMessageId.YOU_DON_T_HAVE_ENOUGH_SPIRITSHOTS_NEEDED_FOR_A_PET_SERVITOR);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Pet uses the power of spirit.
|
||||
activeOwner.sendPacket(SystemMessageId.YOUR_PET_USES_SPIRITSHOT);
|
||||
if ((pet != null) && !pet.isChargedShot(shotType))
|
||||
{
|
||||
pet.setChargedShot(shotType, true);
|
||||
// Visual effect change if player has equipped Sapphire lvl 3 or higher
|
||||
if ((activeOwner.getInventory().getItemByItemId(38931) != null) && activeOwner.getInventory().getItemByItemId(38931).isEquipped())
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(pet, pet, 17821, 2, 0, 0), 600);
|
||||
}
|
||||
else if ((activeOwner.getInventory().getItemByItemId(38930) != null) && activeOwner.getInventory().getItemByItemId(38930).isEquipped())
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(pet, pet, 17820, 2, 0, 0), 600);
|
||||
}
|
||||
else if ((activeOwner.getInventory().getItemByItemId(38929) != null) && activeOwner.getInventory().getItemByItemId(38929).isEquipped())
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(pet, pet, 17819, 2, 0, 0), 600);
|
||||
}
|
||||
else
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(pet, pet, skills[0].getSkillId(), skills[0].getSkillLvl(), 0, 0), 600);
|
||||
}
|
||||
}
|
||||
|
||||
aliveServitor.forEach(s ->
|
||||
{
|
||||
if (!s.isChargedShot(shotType))
|
||||
{
|
||||
s.setChargedShot(shotType, true);
|
||||
// Visual effect change if player has equipped Sapphire lvl 3 or higher
|
||||
if ((activeOwner.getInventory().getItemByItemId(38931) != null) && (activeOwner.getInventory().getItemByItemId(38931).isEquipped()))
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(s, s, 17821, 2, 0, 0), 600);
|
||||
}
|
||||
else if ((activeOwner.getInventory().getItemByItemId(38930) != null) && (activeOwner.getInventory().getItemByItemId(38930).isEquipped()))
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(s, s, 17820, 2, 0, 0), 600);
|
||||
}
|
||||
else if ((activeOwner.getInventory().getItemByItemId(38929) != null) && (activeOwner.getInventory().getItemByItemId(38929).isEquipped()))
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(s, s, 17819, 2, 0, 0), 600);
|
||||
}
|
||||
else
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(s, s, 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 java.util.stream.Collectors;
|
||||
|
||||
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.L2Summon;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemSkillHolder;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
/**
|
||||
* Beast SpiritShot Handler
|
||||
* @author Tempy
|
||||
*/
|
||||
public class BeastSpiritShot 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 activeOwner = playable.getActingPlayer();
|
||||
if (!activeOwner.hasSummon())
|
||||
{
|
||||
activeOwner.sendPacket(SystemMessageId.PETS_AND_SERVITORS_ARE_NOT_AVAILABLE_AT_THIS_TIME);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2Summon pet = playable.getPet();
|
||||
if ((pet != null) && pet.isDead())
|
||||
{
|
||||
activeOwner.sendPacket(SystemMessageId.SOULSHOTS_AND_SPIRITSHOTS_ARE_NOT_AVAILABLE_FOR_A_DEAD_PET_OR_SERVITOR_SAD_ISN_T_IT);
|
||||
return false;
|
||||
}
|
||||
|
||||
final List<L2Summon> aliveServitor = playable.getServitors().values().stream().filter(s -> !s.isDead()).collect(Collectors.toList());
|
||||
if (aliveServitor.isEmpty())
|
||||
{
|
||||
activeOwner.sendPacket(SystemMessageId.SOULSHOTS_AND_SPIRITSHOTS_ARE_NOT_AVAILABLE_FOR_A_DEAD_PET_OR_SERVITOR_SAD_ISN_T_IT);
|
||||
return false;
|
||||
}
|
||||
|
||||
final int itemId = item.getId();
|
||||
final boolean isBlessed = ((itemId == 6647) || (itemId == 20334)); // TODO: Unhardcode these!
|
||||
final List<ItemSkillHolder> skills = item.getItem().getSkills(ItemSkillType.NORMAL);
|
||||
|
||||
final ShotType shotType = isBlessed ? ShotType.BLESSED_SPIRITSHOTS : ShotType.SPIRITSHOTS;
|
||||
|
||||
short shotConsumption = 0;
|
||||
if (pet != null)
|
||||
{
|
||||
if (!pet.isChargedShot(shotType))
|
||||
{
|
||||
shotConsumption += pet.getSpiritShotsPerHit();
|
||||
}
|
||||
}
|
||||
|
||||
for (L2Summon servitors : aliveServitor)
|
||||
{
|
||||
if (!servitors.isChargedShot(shotType))
|
||||
{
|
||||
shotConsumption += servitors.getSpiritShotsPerHit();
|
||||
}
|
||||
}
|
||||
|
||||
if (skills == null)
|
||||
{
|
||||
_log.warning(getClass().getSimpleName() + ": is missing skills!");
|
||||
return false;
|
||||
}
|
||||
|
||||
final long shotCount = item.getCount();
|
||||
if (shotCount < shotConsumption)
|
||||
{
|
||||
// Not enough SpiritShots to use.
|
||||
if (!activeOwner.disableAutoShot(itemId))
|
||||
{
|
||||
activeOwner.sendPacket(SystemMessageId.YOU_DON_T_HAVE_ENOUGH_SPIRITSHOTS_NEEDED_FOR_A_PET_SERVITOR);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!activeOwner.destroyItemWithoutTrace("Consume", item.getObjectId(), shotConsumption, null, false))
|
||||
{
|
||||
if (!activeOwner.disableAutoShot(itemId))
|
||||
{
|
||||
activeOwner.sendPacket(SystemMessageId.YOU_DON_T_HAVE_ENOUGH_SPIRITSHOTS_NEEDED_FOR_A_PET_SERVITOR);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Pet uses the power of spirit.
|
||||
activeOwner.sendPacket(SystemMessageId.YOUR_PET_USES_SPIRITSHOT);
|
||||
if (pet != null)
|
||||
{
|
||||
if (!pet.isChargedShot(shotType))
|
||||
{
|
||||
pet.setChargedShot(shotType, true);
|
||||
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(pet, pet, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600));
|
||||
}
|
||||
}
|
||||
|
||||
aliveServitor.forEach(s ->
|
||||
{
|
||||
if (!s.isChargedShot(shotType))
|
||||
{
|
||||
s.setChargedShot(shotType, true);
|
||||
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(s, s, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600));
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,61 +1,61 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.cache.HtmCache;
|
||||
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.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
public class Book 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 int itemId = item.getId();
|
||||
|
||||
final String filename = "html/help/" + itemId + ".htm";
|
||||
final String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), filename);
|
||||
|
||||
if (content == null)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, item.getId());
|
||||
html.setHtml("<html><body>My Text is missing:<br>" + filename + "</body></html>");
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
else
|
||||
{
|
||||
final NpcHtmlMessage itemReply = new NpcHtmlMessage();
|
||||
itemReply.setHtml(content);
|
||||
activeChar.sendPacket(itemReply);
|
||||
}
|
||||
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
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 com.l2jmobius.gameserver.cache.HtmCache;
|
||||
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.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
public class Book 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 int itemId = item.getId();
|
||||
|
||||
final String filename = "data/html/help/" + itemId + ".htm";
|
||||
final String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), filename);
|
||||
|
||||
if (content == null)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, item.getId());
|
||||
html.setHtml("<html><body>My Text is missing:<br>" + filename + "</body></html>");
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
else
|
||||
{
|
||||
final NpcHtmlMessage itemReply = new NpcHtmlMessage(0, item.getId());
|
||||
itemReply.setHtml(content);
|
||||
activeChar.sendPacket(itemReply);
|
||||
}
|
||||
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,56 +1,58 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.cache.HtmCache;
|
||||
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.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
/**
|
||||
* @author JIV
|
||||
*/
|
||||
public class Bypass implements IItemHandler
|
||||
{
|
||||
@Override
|
||||
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
|
||||
{
|
||||
if (!(playable instanceof L2PcInstance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final L2PcInstance activeChar = (L2PcInstance) playable;
|
||||
final int itemId = item.getId();
|
||||
|
||||
final String filename = "html/item/" + itemId + ".htm";
|
||||
final String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), filename);
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, item.getId());
|
||||
if (content == null)
|
||||
{
|
||||
html.setHtml("<html><body>My Text is missing:<br>" + filename + "</body></html>");
|
||||
}
|
||||
else
|
||||
{
|
||||
html.setHtml(content);
|
||||
html.replace("%itemId%", String.valueOf(item.getObjectId()));
|
||||
}
|
||||
activeChar.sendPacket(html);
|
||||
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 com.l2jmobius.gameserver.cache.HtmCache;
|
||||
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.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
/**
|
||||
* @author JIV
|
||||
*/
|
||||
public class Bypass implements IItemHandler
|
||||
{
|
||||
@Override
|
||||
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
|
||||
{
|
||||
if (!(playable instanceof L2PcInstance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final L2PcInstance activeChar = (L2PcInstance) playable;
|
||||
final int itemId = item.getId();
|
||||
|
||||
final String filename = "data/html/item/" + itemId + ".htm";
|
||||
final String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), filename);
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, item.getId());
|
||||
if (content == null)
|
||||
{
|
||||
html.setHtml("<html><body>My Text is missing:<br>" + filename + "</body></html>");
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
else
|
||||
{
|
||||
html.setHtml(content);
|
||||
html.replace("%itemId%", String.valueOf(item.getObjectId()));
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,42 +1,42 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ShowCalculator;
|
||||
|
||||
/**
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class Calculator 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;
|
||||
}
|
||||
|
||||
playable.sendPacket(new ShowCalculator(item.getId()));
|
||||
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 com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ShowCalculator;
|
||||
|
||||
/**
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class Calculator 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;
|
||||
}
|
||||
|
||||
playable.sendPacket(new ShowCalculator(item.getId()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* 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.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.request.EnchantItemAttributeRequest;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExChangeAttributeItemList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author Erlandys
|
||||
*/
|
||||
public class ChangeAttribute 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 = playable.getActingPlayer();
|
||||
if (activeChar.isCastingNow())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.hasItemRequest())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CHANGING_ATTRIBUTES_IS_IN_PROGRESS_PLEASE_TRY_AGAIN_AFTER_ENDING_THE_PREVIOUS_TASK));
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.addRequest(new EnchantItemAttributeRequest(activeChar, item.getObjectId()));
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CHANGING_ATTRIBUTES_IS_IN_PROGRESS_PLEASE_TRY_AGAIN_AFTER_ENDING_THE_PREVIOUS_TASK));
|
||||
activeChar.sendPacket(new ExChangeAttributeItemList(activeChar, item.getObjectId()));
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -1,87 +1,88 @@
|
||||
/*
|
||||
* 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 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.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* Charm Of Courage Handler
|
||||
* @author Zealar
|
||||
*/
|
||||
public class CharmOfCourage implements IItemHandler
|
||||
{
|
||||
@Override
|
||||
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
|
||||
{
|
||||
if (!playable.isPlayer())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance activeChar = playable.getActingPlayer();
|
||||
|
||||
int level = activeChar.getLevel();
|
||||
final int itemLevel = item.getItem().getCrystalType().getId();
|
||||
|
||||
if (level < 20)
|
||||
{
|
||||
level = 0;
|
||||
}
|
||||
else if (level < 40)
|
||||
{
|
||||
level = 1;
|
||||
}
|
||||
else if (level < 52)
|
||||
{
|
||||
level = 2;
|
||||
}
|
||||
else if (level < 61)
|
||||
{
|
||||
level = 3;
|
||||
}
|
||||
else if (level < 76)
|
||||
{
|
||||
level = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
level = 5;
|
||||
}
|
||||
|
||||
if (itemLevel < level)
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED_DUE_TO_UNSUITABLE_TERMS);
|
||||
sm.addItemName(item.getId());
|
||||
activeChar.sendPacket(sm);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), 1, null, false))
|
||||
{
|
||||
activeChar.setCharmOfCourage(true);
|
||||
activeChar.sendPacket(new EtcStatusUpdate(activeChar));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 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.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* Charm Of Courage Handler
|
||||
* @author Zealar
|
||||
*/
|
||||
public class CharmOfCourage implements IItemHandler
|
||||
{
|
||||
@Override
|
||||
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
|
||||
{
|
||||
|
||||
if (!playable.isPlayer())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance activeChar = playable.getActingPlayer();
|
||||
|
||||
int level = activeChar.getLevel();
|
||||
final int itemLevel = item.getItem().getCrystalType().getId();
|
||||
|
||||
if (level < 20)
|
||||
{
|
||||
level = 0;
|
||||
}
|
||||
else if (level < 40)
|
||||
{
|
||||
level = 1;
|
||||
}
|
||||
else if (level < 52)
|
||||
{
|
||||
level = 2;
|
||||
}
|
||||
else if (level < 61)
|
||||
{
|
||||
level = 3;
|
||||
}
|
||||
else if (level < 76)
|
||||
{
|
||||
level = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
level = 5;
|
||||
}
|
||||
|
||||
if (itemLevel < level)
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED_DUE_TO_UNSUITABLE_TERMS);
|
||||
sm.addItemName(item.getId());
|
||||
activeChar.sendPacket(sm);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), 1, null, false))
|
||||
{
|
||||
activeChar.setCharmOfCourage(true);
|
||||
activeChar.sendPacket(new EtcStatusUpdate(activeChar));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -1,35 +1,35 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
public class Elixir extends ItemSkills
|
||||
{
|
||||
@Override
|
||||
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
|
||||
{
|
||||
if (!playable.isPlayer())
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_THIS_ITEM);
|
||||
return false;
|
||||
}
|
||||
return super.useItem(playable, item, forceUse);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
public class Elixir extends ItemSkills
|
||||
{
|
||||
@Override
|
||||
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
|
||||
{
|
||||
if (!playable.isPlayer())
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_THIS_ITEM);
|
||||
return false;
|
||||
}
|
||||
return super.useItem(playable, item, forceUse);
|
||||
}
|
||||
}
|
||||
|
@@ -1,54 +1,54 @@
|
||||
/*
|
||||
* 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 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.actor.request.EnchantItemAttributeRequest;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExChooseInventoryAttributeItem;
|
||||
|
||||
public class EnchantAttribute 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 = playable.getActingPlayer();
|
||||
if (activeChar.isCastingNow())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.hasItemRequest())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.ANOTHER_ENCHANTMENT_IS_IN_PROGRESS_PLEASE_COMPLETE_THE_PREVIOUS_TASK_THEN_TRY_AGAIN);
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.addRequest(new EnchantItemAttributeRequest(activeChar, item.getObjectId()));
|
||||
activeChar.sendPacket(new ExChooseInventoryAttributeItem(activeChar, item));
|
||||
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 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.actor.request.EnchantItemAttributeRequest;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExChooseInventoryAttributeItem;
|
||||
|
||||
public class EnchantAttribute 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 = playable.getActingPlayer();
|
||||
if (activeChar.isCastingNow())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.hasItemRequest())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.ANOTHER_ENCHANTMENT_IS_IN_PROGRESS_PLEASE_COMPLETE_THE_PREVIOUS_TASK_THEN_TRY_AGAIN);
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.addRequest(new EnchantItemAttributeRequest(activeChar, item.getObjectId()));
|
||||
activeChar.sendPacket(new ExChooseInventoryAttributeItem(activeChar, item));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,54 +1,54 @@
|
||||
/*
|
||||
* 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 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.actor.request.EnchantItemRequest;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ChooseInventoryItem;
|
||||
|
||||
public class EnchantScrolls 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 = playable.getActingPlayer();
|
||||
if (activeChar.isCastingNow())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.hasItemRequest())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.ANOTHER_ENCHANTMENT_IS_IN_PROGRESS_PLEASE_COMPLETE_THE_PREVIOUS_TASK_THEN_TRY_AGAIN);
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.addRequest(new EnchantItemRequest(activeChar, item.getObjectId()));
|
||||
activeChar.sendPacket(new ChooseInventoryItem(item.getId()));
|
||||
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 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.actor.request.EnchantItemRequest;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ChooseInventoryItem;
|
||||
|
||||
public class EnchantScrolls 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 = playable.getActingPlayer();
|
||||
if (activeChar.isCastingNow())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.hasItemRequest())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.ANOTHER_ENCHANTMENT_IS_IN_PROGRESS_PLEASE_COMPLETE_THE_PREVIOUS_TASK_THEN_TRY_AGAIN);
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.addRequest(new EnchantItemRequest(activeChar, item.getObjectId()));
|
||||
activeChar.sendPacket(new ChooseInventoryItem(item.getId()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,107 +1,103 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.HandysBlockCheckerManager;
|
||||
import com.l2jmobius.gameserver.model.ArenaParticipantsHolder;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2BlockInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
public class EventItem 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;
|
||||
}
|
||||
|
||||
boolean used = false;
|
||||
|
||||
final L2PcInstance activeChar = playable.getActingPlayer();
|
||||
|
||||
final int itemId = item.getId();
|
||||
switch (itemId)
|
||||
{
|
||||
case 13787: // Handy's Block Checker Bond
|
||||
{
|
||||
used = useBlockCheckerItem(activeChar, item);
|
||||
break;
|
||||
}
|
||||
case 13788: // Handy's Block Checker Land Mine
|
||||
{
|
||||
used = useBlockCheckerItem(activeChar, item);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
_log.warning("EventItemHandler: Item with id: " + itemId + " is not handled");
|
||||
}
|
||||
}
|
||||
return used;
|
||||
}
|
||||
|
||||
private final boolean useBlockCheckerItem(L2PcInstance castor, L2ItemInstance item)
|
||||
{
|
||||
final int blockCheckerArena = castor.getBlockCheckerArena();
|
||||
if (blockCheckerArena == -1)
|
||||
{
|
||||
final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED_DUE_TO_UNSUITABLE_TERMS);
|
||||
msg.addItemName(item);
|
||||
castor.sendPacket(msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
final Skill sk = item.getEtcItem().getSkills()[0].getSkill();
|
||||
if (sk == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!castor.destroyItem("Consume", item, 1, castor, true))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2BlockInstance block = (L2BlockInstance) castor.getTarget();
|
||||
|
||||
final ArenaParticipantsHolder holder = HandysBlockCheckerManager.getInstance().getHolder(blockCheckerArena);
|
||||
if (holder != null)
|
||||
{
|
||||
final int team = holder.getPlayerTeam(castor);
|
||||
for (L2PcInstance pc : block.getKnownList().getKnownPlayersInRadius(sk.getEffectRange()))
|
||||
{
|
||||
final int enemyTeam = holder.getPlayerTeam(pc);
|
||||
if ((enemyTeam != -1) && (enemyTeam != team))
|
||||
{
|
||||
sk.applyEffects(castor, pc);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
_log.warning("Char: " + castor.getName() + "[" + castor.getObjectId() + "] has unknown block checker arena");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.enums.ItemSkillType;
|
||||
import com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.HandysBlockCheckerManager;
|
||||
import com.l2jmobius.gameserver.model.ArenaParticipantsHolder;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2BlockInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
public class EventItem 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;
|
||||
}
|
||||
|
||||
boolean used = false;
|
||||
|
||||
final L2PcInstance activeChar = playable.getActingPlayer();
|
||||
|
||||
final int itemId = item.getId();
|
||||
switch (itemId)
|
||||
{
|
||||
case 13787: // Handy's Block Checker Bond
|
||||
used = useBlockCheckerItem(activeChar, item);
|
||||
break;
|
||||
case 13788: // Handy's Block Checker Land Mine
|
||||
used = useBlockCheckerItem(activeChar, item);
|
||||
break;
|
||||
default:
|
||||
_log.warning("EventItemHandler: Item with id: " + itemId + " is not handled");
|
||||
}
|
||||
return used;
|
||||
}
|
||||
|
||||
private final boolean useBlockCheckerItem(L2PcInstance castor, L2ItemInstance item)
|
||||
{
|
||||
final int blockCheckerArena = castor.getBlockCheckerArena();
|
||||
if (blockCheckerArena == -1)
|
||||
{
|
||||
final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED_DUE_TO_UNSUITABLE_TERMS);
|
||||
msg.addItemName(item);
|
||||
castor.sendPacket(msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
final Skill sk = item.getEtcItem().getSkills(ItemSkillType.NORMAL).get(0).getSkill();
|
||||
if (sk == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!castor.destroyItem("Consume", item, 1, castor, true))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2BlockInstance block = (L2BlockInstance) castor.getTarget();
|
||||
|
||||
final ArenaParticipantsHolder holder = HandysBlockCheckerManager.getInstance().getHolder(blockCheckerArena);
|
||||
if (holder != null)
|
||||
{
|
||||
final int team = holder.getPlayerTeam(castor);
|
||||
L2World.getInstance().forEachVisibleObjectInRange(block, L2PcInstance.class, sk.getEffectRange(), pc ->
|
||||
{
|
||||
final int enemyTeam = holder.getPlayerTeam(pc);
|
||||
if ((enemyTeam != -1) && (enemyTeam != team))
|
||||
{
|
||||
sk.applyEffects(castor, pc);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
_log.warning("Char: " + castor.getName() + "[" + castor.getObjectId() + "] has unknown block checker arena");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -1,222 +1,97 @@
|
||||
/*
|
||||
* 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.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.L2ExtractableProduct;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.L2EtcItem;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* Extractable Items handler.
|
||||
* @author HorridoJoho, Mobius
|
||||
*/
|
||||
public class ExtractableItems 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 = playable.getActingPlayer();
|
||||
final L2EtcItem etcitem = (L2EtcItem) item.getItem();
|
||||
final List<L2ExtractableProduct> exitems = etcitem.getExtractableItems();
|
||||
if (exitems == null)
|
||||
{
|
||||
_log.info("No extractable data defined for " + etcitem);
|
||||
return false;
|
||||
}
|
||||
|
||||
// destroy item
|
||||
if (!activeChar.destroyItem("Extract", item.getObjectId(), 1, activeChar, true))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final List<L2ItemInstance> extractedItems = new ArrayList<>();
|
||||
final List<L2ItemInstance> enchantedItems = new ArrayList<>();
|
||||
if (etcitem.getExtractableCountMin() > 0)
|
||||
{
|
||||
while (extractedItems.size() < etcitem.getExtractableCountMin())
|
||||
{
|
||||
for (L2ExtractableProduct expi : exitems)
|
||||
{
|
||||
if ((etcitem.getExtractableCountMax() > 0) && (extractedItems.size() == etcitem.getExtractableCountMax()))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (Rnd.get(100000) <= expi.getChance())
|
||||
{
|
||||
final int min = (int) (expi.getMin() * Config.RATE_EXTRACTABLE);
|
||||
final int max = (int) (expi.getMax() * Config.RATE_EXTRACTABLE);
|
||||
|
||||
int createItemAmount = (max == min) ? min : (Rnd.get((max - min) + 1) + min);
|
||||
if (createItemAmount == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Do not extract the same item.
|
||||
boolean alreadyExtracted = false;
|
||||
for (L2ItemInstance i : extractedItems)
|
||||
{
|
||||
if (i.getItem().getId() == expi.getId())
|
||||
{
|
||||
alreadyExtracted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (alreadyExtracted && (exitems.size() >= etcitem.getExtractableCountMax()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.isStackable() || (createItemAmount == 1))
|
||||
{
|
||||
final L2ItemInstance newItem = activeChar.addItem("Extract", expi.getId(), createItemAmount, activeChar, false);
|
||||
if (expi.getMaxEnchant() > 0)
|
||||
{
|
||||
newItem.setEnchantLevel(Rnd.get(expi.getMinEnchant(), expi.getMaxEnchant()));
|
||||
enchantedItems.add(newItem);
|
||||
}
|
||||
extractedItems.add(newItem);
|
||||
sendMessage(activeChar, newItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (createItemAmount > 0)
|
||||
{
|
||||
final L2ItemInstance newItem = activeChar.addItem("Extract", expi.getId(), 1, activeChar, false);
|
||||
if (expi.getMaxEnchant() > 0)
|
||||
{
|
||||
newItem.setEnchantLevel(Rnd.get(expi.getMinEnchant(), expi.getMaxEnchant()));
|
||||
enchantedItems.add(newItem);
|
||||
}
|
||||
extractedItems.add(newItem);
|
||||
sendMessage(activeChar, newItem);
|
||||
createItemAmount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (L2ExtractableProduct expi : exitems)
|
||||
{
|
||||
if ((etcitem.getExtractableCountMax() > 0) && (extractedItems.size() == etcitem.getExtractableCountMax()))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (Rnd.get(100000) <= expi.getChance())
|
||||
{
|
||||
final int min = (int) (expi.getMin() * Config.RATE_EXTRACTABLE);
|
||||
final int max = (int) (expi.getMax() * Config.RATE_EXTRACTABLE);
|
||||
|
||||
int createItemAmount = (max == min) ? min : (Rnd.get((max - min) + 1) + min);
|
||||
if (createItemAmount == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.isStackable() || (createItemAmount == 1))
|
||||
{
|
||||
final L2ItemInstance newItem = activeChar.addItem("Extract", expi.getId(), createItemAmount, activeChar, false);
|
||||
if (expi.getMaxEnchant() > 0)
|
||||
{
|
||||
newItem.setEnchantLevel(Rnd.get(expi.getMinEnchant(), expi.getMaxEnchant()));
|
||||
enchantedItems.add(newItem);
|
||||
}
|
||||
extractedItems.add(newItem);
|
||||
sendMessage(activeChar, newItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (createItemAmount > 0)
|
||||
{
|
||||
final L2ItemInstance newItem = activeChar.addItem("Extract", expi.getId(), 1, activeChar, false);
|
||||
if (expi.getMaxEnchant() > 0)
|
||||
{
|
||||
newItem.setEnchantLevel(Rnd.get(expi.getMinEnchant(), expi.getMaxEnchant()));
|
||||
enchantedItems.add(newItem);
|
||||
}
|
||||
extractedItems.add(newItem);
|
||||
sendMessage(activeChar, newItem);
|
||||
createItemAmount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (extractedItems.size() == 0)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THERE_WAS_NOTHING_FOUND_INSIDE);
|
||||
}
|
||||
if (!enchantedItems.isEmpty())
|
||||
{
|
||||
final InventoryUpdate playerIU = new InventoryUpdate();
|
||||
for (L2ItemInstance i : enchantedItems)
|
||||
{
|
||||
playerIU.addModifiedItem(i);
|
||||
}
|
||||
activeChar.sendPacket(playerIU);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendMessage(L2PcInstance player, L2ItemInstance item)
|
||||
{
|
||||
final SystemMessage sm;
|
||||
if (item.getCount() > 1)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_OBTAINED_S2_S1);
|
||||
sm.addItemName(item);
|
||||
sm.addLong(item.getCount());
|
||||
}
|
||||
else if (item.getEnchantLevel() > 0)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_OBTAINED_A_S1_S2);
|
||||
sm.addInt(item.getEnchantLevel());
|
||||
sm.addItemName(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_OBTAINED_S1);
|
||||
sm.addItemName(item);
|
||||
}
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.Config;
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.L2ExtractableProduct;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.L2EtcItem;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* Extractable Items handler.
|
||||
* @author HorridoJoho
|
||||
*/
|
||||
public class ExtractableItems 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 = playable.getActingPlayer();
|
||||
final L2EtcItem etcitem = (L2EtcItem) item.getItem();
|
||||
final List<L2ExtractableProduct> exitem = etcitem.getExtractableItems();
|
||||
if (exitem == null)
|
||||
{
|
||||
_log.info("No extractable data defined for " + etcitem);
|
||||
return false;
|
||||
}
|
||||
|
||||
// destroy item
|
||||
if (!activeChar.destroyItem("Extract", item.getObjectId(), 1, activeChar, true))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean created = false;
|
||||
for (L2ExtractableProduct expi : exitem)
|
||||
{
|
||||
if (Rnd.get(100000) <= expi.getChance())
|
||||
{
|
||||
final int min = (int) (expi.getMin() * Config.RATE_EXTRACTABLE);
|
||||
final int max = (int) (expi.getMax() * Config.RATE_EXTRACTABLE);
|
||||
|
||||
int createItemAmount = (max == min) ? min : (Rnd.get((max - min) + 1) + min);
|
||||
if (createItemAmount == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.isStackable() || (createItemAmount == 1))
|
||||
{
|
||||
activeChar.addItem("Extract", expi.getId(), createItemAmount, activeChar, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (createItemAmount > 0)
|
||||
{
|
||||
activeChar.addItem("Extract", expi.getId(), 1, activeChar, true);
|
||||
createItemAmount--;
|
||||
}
|
||||
}
|
||||
created = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!created)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THERE_WAS_NOTHING_FOUND_INSIDE);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.data.xml.impl.CategoryData;
|
||||
import com.l2jmobius.gameserver.enums.CategoryType;
|
||||
import com.l2jmobius.gameserver.enums.Race;
|
||||
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.base.ClassId;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class FatedSupportBox 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 player = playable.getActingPlayer();
|
||||
final Race race = player.getRace();
|
||||
final ClassId classId = player.getClassId();
|
||||
|
||||
// Characters that have gone through their 2nd class transfer/1st liberation will be able to open the Fated Support Box at level 40.
|
||||
if ((player.getLevel() < 40) || (classId.level() < (race == Race.ERTHEIA ? 1 : 2)))
|
||||
{
|
||||
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED_DUE_TO_UNSUITABLE_TERMS).addItemName(item));
|
||||
return false;
|
||||
}
|
||||
|
||||
player.getInventory().destroyItem(getClass().getSimpleName(), item, 1, player, null);
|
||||
player.sendPacket(new InventoryUpdate(item));
|
||||
|
||||
// It will stay in your inventory after use until you reach level 84.
|
||||
if (player.getLevel() > 84)
|
||||
{
|
||||
player.sendMessage("Fated Support Box was removed because your level has exceeded the maximum requirement."); // custom message
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (race)
|
||||
{
|
||||
case HUMAN:
|
||||
case ELF:
|
||||
case DARK_ELF:
|
||||
case DWARF:
|
||||
{
|
||||
if (player.isMageClass())
|
||||
{
|
||||
player.addItem(getClass().getSimpleName(), 37316, 1, player, true);
|
||||
}
|
||||
else if (CategoryData.getInstance().isInCategory(CategoryType.SUB_GROUP_ROGUE, classId.getId()))
|
||||
{
|
||||
player.addItem(getClass().getSimpleName(), 37318, 1, player, true);
|
||||
}
|
||||
else if (CategoryData.getInstance().isInCategory(CategoryType.SUB_GROUP_KNIGHT, classId.getId()))
|
||||
{
|
||||
player.addItem(getClass().getSimpleName(), 37315, 1, player, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.addItem(getClass().getSimpleName(), 37317, 1, player, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ORC:
|
||||
{
|
||||
if (player.isMageClass())
|
||||
{
|
||||
player.addItem(getClass().getSimpleName(), 37321, 1, player, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.addItem(getClass().getSimpleName(), 37320, 1, player, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KAMAEL:
|
||||
{
|
||||
player.addItem(getClass().getSimpleName(), 37319, 1, player, true);
|
||||
break;
|
||||
}
|
||||
case ERTHEIA:
|
||||
{
|
||||
if (player.isMageClass())
|
||||
{
|
||||
player.addItem(getClass().getSimpleName(), 26229, 1, player, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.addItem(getClass().getSimpleName(), 26230, 1, player, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -1,94 +1,95 @@
|
||||
/*
|
||||
* 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.L2Object;
|
||||
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.model.items.type.WeaponType;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
/**
|
||||
* @author -Nemesiss-
|
||||
*/
|
||||
public class FishShots 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 = playable.getActingPlayer();
|
||||
final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
|
||||
final L2Weapon weaponItem = activeChar.getActiveWeaponItem();
|
||||
|
||||
if ((weaponInst == null) || (weaponItem.getItemType() != WeaponType.FISHINGROD))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.isChargedShot(ShotType.FISH_SOULSHOTS))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final long count = item.getCount();
|
||||
final SkillHolder[] skills = item.getItem().getSkills();
|
||||
|
||||
if (skills == null)
|
||||
{
|
||||
_log.log(Level.WARNING, getClass().getSimpleName() + ": is missing skills!");
|
||||
return false;
|
||||
}
|
||||
|
||||
final boolean gradeCheck = item.isEtcItem() && (item.getEtcItem().getDefaultAction() == ActionType.FISHINGSHOT) && (weaponInst.getItem().getCrystalTypePlus() == item.getItem().getCrystalTypePlus());
|
||||
|
||||
if (!gradeCheck)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_IS_THE_WRONG_GRADE_OF_SOULSHOT_FOR_THAT_FISHING_POLE);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (count < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.setChargedShot(ShotType.FISH_SOULSHOTS, true);
|
||||
activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), 1, null, false);
|
||||
final L2Object oldTarget = activeChar.getTarget();
|
||||
activeChar.setTarget(activeChar);
|
||||
|
||||
Broadcast.toSelfAndKnownPlayers(activeChar, new MagicSkillUse(activeChar, skills[0].getSkillId(), skills[0].getSkillLvl(), 0, 0));
|
||||
activeChar.setTarget(oldTarget);
|
||||
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.L2Object;
|
||||
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.model.items.type.WeaponType;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
/**
|
||||
* @author -Nemesiss-
|
||||
*/
|
||||
public class FishShots 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 = playable.getActingPlayer();
|
||||
final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
|
||||
final L2Weapon weaponItem = activeChar.getActiveWeaponItem();
|
||||
|
||||
if ((weaponInst == null) || (weaponItem.getItemType() != WeaponType.FISHINGROD))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.isChargedShot(ShotType.FISH_SOULSHOTS))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final long count = item.getCount();
|
||||
final boolean gradeCheck = item.isEtcItem() && (item.getEtcItem().getDefaultAction() == ActionType.FISHINGSHOT) && (weaponInst.getItem().getCrystalTypePlus() == item.getItem().getCrystalTypePlus());
|
||||
|
||||
if (!gradeCheck)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_IS_THE_WRONG_GRADE_OF_SOULSHOT_FOR_THAT_FISHING_POLE);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (count < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.setChargedShot(ShotType.FISH_SOULSHOTS, true);
|
||||
activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), 1, null, false);
|
||||
final L2Object oldTarget = activeChar.getTarget();
|
||||
activeChar.setTarget(activeChar);
|
||||
|
||||
final List<ItemSkillHolder> skills = item.getItem().getSkills(ItemSkillType.NORMAL);
|
||||
|
||||
if (skills == null)
|
||||
{
|
||||
_log.warning(getClass().getSimpleName() + ": is missing skills!");
|
||||
return false;
|
||||
}
|
||||
|
||||
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600));
|
||||
activeChar.setTarget(oldTarget);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,70 +1,70 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
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.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
|
||||
/**
|
||||
* @author l3x
|
||||
*/
|
||||
public final class Harvester implements IItemHandler
|
||||
{
|
||||
@Override
|
||||
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
|
||||
{
|
||||
if (!Config.ALLOW_MANOR)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!playable.isPlayer())
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_THIS_ITEM);
|
||||
return false;
|
||||
}
|
||||
|
||||
final SkillHolder[] skills = item.getItem().getSkills();
|
||||
if (skills == null)
|
||||
{
|
||||
_log.warning(getClass().getSimpleName() + ": is missing skills!");
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance activeChar = playable.getActingPlayer();
|
||||
final L2Object target = activeChar.getTarget();
|
||||
if ((target == null) || !target.isMonster() || !((L2Character) target).isDead())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (SkillHolder sk : skills)
|
||||
{
|
||||
activeChar.useMagic(sk.getSkill(), false, false);
|
||||
}
|
||||
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.Config;
|
||||
import com.l2jmobius.gameserver.enums.ItemSkillType;
|
||||
import com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
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.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
|
||||
/**
|
||||
* @author l3x
|
||||
*/
|
||||
public final class Harvester implements IItemHandler
|
||||
{
|
||||
@Override
|
||||
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
|
||||
{
|
||||
if (!Config.ALLOW_MANOR)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!playable.isPlayer())
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_THIS_ITEM);
|
||||
return false;
|
||||
}
|
||||
|
||||
final List<ItemSkillHolder> skills = item.getItem().getSkills(ItemSkillType.NORMAL);
|
||||
if (skills == null)
|
||||
{
|
||||
_log.warning(getClass().getSimpleName() + ": is missing skills!");
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance activeChar = playable.getActingPlayer();
|
||||
final L2Object target = activeChar.getTarget();
|
||||
if ((target == null) || !target.isMonster() || !((L2Character) target).isDead())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return false;
|
||||
}
|
||||
|
||||
skills.forEach(holder -> activeChar.useMagic(holder.getSkill(), item, false, false));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,40 +1,40 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* Item skills not allowed on Olympiad.
|
||||
*/
|
||||
public class ItemSkills extends ItemSkillsTemplate
|
||||
{
|
||||
@Override
|
||||
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
|
||||
{
|
||||
final L2PcInstance activeChar = playable.getActingPlayer();
|
||||
if ((activeChar != null) && activeChar.isInOlympiadMode() && item.isOlyRestrictedItem())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_THAT_ITEM_IN_A_OLYMPIAD_MATCH);
|
||||
return false;
|
||||
}
|
||||
return super.useItem(playable, item, forceUse);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* Item skills not allowed on Olympiad.
|
||||
*/
|
||||
public class ItemSkills extends ItemSkillsTemplate
|
||||
{
|
||||
@Override
|
||||
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
|
||||
{
|
||||
final L2PcInstance activeChar = playable.getActingPlayer();
|
||||
if ((activeChar != null) && activeChar.isInOlympiadMode())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_THAT_ITEM_IN_A_OLYMPIAD_MATCH);
|
||||
return false;
|
||||
}
|
||||
return super.useItem(playable, item, forceUse);
|
||||
}
|
||||
}
|
||||
|
@@ -1,227 +1,237 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.entity.TvTEvent;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* Template for item skills handler.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class ItemSkillsTemplate implements IItemHandler
|
||||
{
|
||||
@Override
|
||||
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
|
||||
{
|
||||
if (!playable.isPlayer() && !playable.isPet())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!TvTEvent.onScrollUse(playable.getObjectId()))
|
||||
{
|
||||
playable.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Pets can use items only when they are tradable.
|
||||
if (playable.isPet() && !item.isTradeable())
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_THIS_ITEM);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify that item is not under reuse.
|
||||
if (!checkReuse(playable, null, item))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final SkillHolder[] skills = item.getEtcItem().getSkills();
|
||||
if (skills == null)
|
||||
{
|
||||
_log.info("Item " + item + " does not have registered any skill for handler.");
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean hasConsumeSkill = false;
|
||||
|
||||
for (SkillHolder skillInfo : skills)
|
||||
{
|
||||
if (skillInfo == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final Skill itemSkill = skillInfo.getSkill();
|
||||
|
||||
if (itemSkill != null)
|
||||
{
|
||||
if (itemSkill.getItemConsumeId() > 0)
|
||||
{
|
||||
hasConsumeSkill = true;
|
||||
}
|
||||
|
||||
if (!itemSkill.checkCondition(playable, playable.getTarget(), false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (playable.isSkillDisabled(itemSkill))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify that skill is not under reuse.
|
||||
if (!checkReuse(playable, itemSkill, item))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!item.isPotion() && !item.isElixir() && !item.isScroll() && playable.isCastingNow())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Send message to the master.
|
||||
if (playable.isPet())
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOUR_PET_USES_S1);
|
||||
sm.addSkillName(itemSkill);
|
||||
playable.sendPacket(sm);
|
||||
}
|
||||
|
||||
if (itemSkill.isSimultaneousCast() || ((item.getItem().hasImmediateEffect() || item.getItem().hasExImmediateEffect()) && itemSkill.isStatic()))
|
||||
{
|
||||
playable.doSimultaneousCast(itemSkill);
|
||||
}
|
||||
else
|
||||
{
|
||||
playable.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
|
||||
if (!playable.useMagic(itemSkill, forceUse, false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemSkill.getReuseDelay() > 0)
|
||||
{
|
||||
playable.addTimeStamp(itemSkill, itemSkill.getReuseDelay());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (checkConsume(item, hasConsumeSkill) && !playable.destroyItem("Consume", item.getObjectId(), 1, playable, false))
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item the item being used
|
||||
* @param hasConsumeSkill
|
||||
* @return {@code true} check if item use consume item, {@code false} otherwise
|
||||
*/
|
||||
private boolean checkConsume(L2ItemInstance item, boolean hasConsumeSkill)
|
||||
{
|
||||
switch (item.getItem().getDefaultAction())
|
||||
{
|
||||
case CAPSULE:
|
||||
case SKILL_REDUCE:
|
||||
{
|
||||
if (!hasConsumeSkill && item.getItem().hasImmediateEffect())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param playable the character using the item or skill
|
||||
* @param skill the skill being used, can be null
|
||||
* @param item the item being used
|
||||
* @return {@code true} if the the item or skill to check is available, {@code false} otherwise
|
||||
*/
|
||||
private boolean checkReuse(L2Playable playable, Skill skill, L2ItemInstance item)
|
||||
{
|
||||
final long remainingTime = (skill != null) ? playable.getSkillRemainingReuseTime(skill.getReuseHashCode()) : playable.getItemRemainingReuseTime(item.getObjectId());
|
||||
final boolean isAvailable = remainingTime <= 0;
|
||||
if (playable.isPlayer() && !isAvailable)
|
||||
{
|
||||
final int hours = (int) (remainingTime / 3600000L);
|
||||
final int minutes = (int) (remainingTime % 3600000L) / 60000;
|
||||
final int seconds = (int) ((remainingTime / 1000) % 60);
|
||||
SystemMessage sm = null;
|
||||
if (hours > 0)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.THERE_ARE_S2_HOUR_S_S3_MINUTE_S_AND_S4_SECOND_S_REMAINING_IN_S1_S_RE_USE_TIME);
|
||||
if ((skill == null) || skill.isStatic())
|
||||
{
|
||||
sm.addItemName(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
sm.addSkillName(skill);
|
||||
}
|
||||
sm.addInt(hours);
|
||||
sm.addInt(minutes);
|
||||
}
|
||||
else if (minutes > 0)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.THERE_ARE_S2_MINUTE_S_S3_SECOND_S_REMAINING_IN_S1_S_RE_USE_TIME);
|
||||
if ((skill == null) || skill.isStatic())
|
||||
{
|
||||
sm.addItemName(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
sm.addSkillName(skill);
|
||||
}
|
||||
sm.addInt(minutes);
|
||||
}
|
||||
else
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.THERE_ARE_S2_SECOND_S_REMAINING_IN_S1_S_RE_USE_TIME);
|
||||
if ((skill == null) || skill.isStatic())
|
||||
{
|
||||
sm.addItemName(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
sm.addSkillName(skill);
|
||||
}
|
||||
}
|
||||
sm.addInt(seconds);
|
||||
playable.sendPacket(sm);
|
||||
}
|
||||
return isAvailable;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.enums.ItemSkillType;
|
||||
import com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemSkillHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.skills.SkillCaster;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* Template for item skills handler.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class ItemSkillsTemplate implements IItemHandler
|
||||
{
|
||||
@Override
|
||||
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
|
||||
{
|
||||
if (!playable.isPlayer() && !playable.isPet())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Pets can use items only when they are tradable.
|
||||
if (playable.isPet() && !item.isTradeable())
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_THIS_ITEM);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify that item is not under reuse.
|
||||
if (!checkReuse(playable, null, item))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final List<ItemSkillHolder> skills = item.getItem().getSkills(ItemSkillType.NORMAL);
|
||||
if (skills == null)
|
||||
{
|
||||
_log.info("Item " + item + " does not have registered any skill for handler.");
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean hasConsumeSkill = false;
|
||||
boolean successfulUse = false;
|
||||
|
||||
for (SkillHolder skillInfo : skills)
|
||||
{
|
||||
if (skillInfo == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final Skill itemSkill = skillInfo.getSkill();
|
||||
|
||||
if (itemSkill != null)
|
||||
{
|
||||
if (itemSkill.getItemConsumeId() > 0)
|
||||
{
|
||||
hasConsumeSkill = true;
|
||||
}
|
||||
|
||||
if (!itemSkill.checkCondition(playable, playable.getTarget()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (playable.isSkillDisabled(itemSkill))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Verify that skill is not under reuse.
|
||||
if (!checkReuse(playable, itemSkill, item))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!item.isPotion() && !item.isElixir() && !item.isScroll() && playable.isCastingNow())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Send message to the master.
|
||||
if (playable.isPet())
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOUR_PET_USES_S1);
|
||||
sm.addSkillName(itemSkill);
|
||||
playable.sendPacket(sm);
|
||||
}
|
||||
|
||||
if (itemSkill.isWithoutAction() || item.getItem().hasImmediateEffect() || item.getItem().hasExImmediateEffect())
|
||||
{
|
||||
SkillCaster.triggerCast(playable, null, itemSkill, item, false);
|
||||
successfulUse = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
playable.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
|
||||
if (playable.useMagic(itemSkill, item, forceUse, false))
|
||||
{
|
||||
successfulUse = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemSkill.getReuseDelay() > 0)
|
||||
{
|
||||
playable.addTimeStamp(itemSkill, itemSkill.getReuseDelay());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (successfulUse && checkConsume(item, hasConsumeSkill))
|
||||
{
|
||||
if (!playable.destroyItem("Consume", item.getObjectId(), 1, playable, false))
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT2);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return successfulUse;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item the item being used
|
||||
* @param hasConsumeSkill
|
||||
* @return {@code true} check if item use consume item, {@code false} otherwise
|
||||
*/
|
||||
private boolean checkConsume(L2ItemInstance item, boolean hasConsumeSkill)
|
||||
{
|
||||
switch (item.getItem().getDefaultAction())
|
||||
{
|
||||
case CAPSULE:
|
||||
case SKILL_REDUCE:
|
||||
case SKILL_REDUCE_ON_SKILL_SUCCESS:
|
||||
{
|
||||
if (!hasConsumeSkill && item.getItem().hasImmediateEffect())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param playable the character using the item or skill
|
||||
* @param skill the skill being used, can be null
|
||||
* @param item the item being used
|
||||
* @return {@code true} if the the item or skill to check is available, {@code false} otherwise
|
||||
*/
|
||||
private boolean checkReuse(L2Playable playable, Skill skill, L2ItemInstance item)
|
||||
{
|
||||
final long remainingTime = (skill != null) ? playable.getSkillRemainingReuseTime(skill.getReuseHashCode()) : playable.getItemRemainingReuseTime(item.getObjectId());
|
||||
final boolean isAvailable = remainingTime <= 0;
|
||||
if (playable.isPlayer())
|
||||
{
|
||||
if (!isAvailable)
|
||||
{
|
||||
final int hours = (int) (remainingTime / 3600000L);
|
||||
final int minutes = (int) (remainingTime % 3600000L) / 60000;
|
||||
final int seconds = (int) ((remainingTime / 1000) % 60);
|
||||
SystemMessage sm = null;
|
||||
if (hours > 0)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.THERE_ARE_S2_HOUR_S_S3_MINUTE_S_AND_S4_SECOND_S_REMAINING_IN_S1_S_RE_USE_TIME);
|
||||
if ((skill == null) || skill.isStatic())
|
||||
{
|
||||
sm.addItemName(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
sm.addSkillName(skill);
|
||||
}
|
||||
sm.addInt(hours);
|
||||
sm.addInt(minutes);
|
||||
}
|
||||
else if (minutes > 0)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.THERE_ARE_S2_MINUTE_S_S3_SECOND_S_REMAINING_IN_S1_S_RE_USE_TIME);
|
||||
if ((skill == null) || skill.isStatic())
|
||||
{
|
||||
sm.addItemName(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
sm.addSkillName(skill);
|
||||
}
|
||||
sm.addInt(minutes);
|
||||
}
|
||||
else
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.THERE_ARE_S2_SECOND_S_REMAINING_IN_S1_S_RE_USE_TIME);
|
||||
if ((skill == null) || skill.isStatic())
|
||||
{
|
||||
sm.addItemName(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
sm.addSkillName(skill);
|
||||
}
|
||||
}
|
||||
sm.addInt(seconds);
|
||||
playable.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
return isAvailable;
|
||||
}
|
||||
}
|
||||
|
@@ -1,42 +1,42 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ShowMiniMap;
|
||||
|
||||
/**
|
||||
* This class provides handling for items that should display a map when double clicked.
|
||||
*/
|
||||
public class Maps 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;
|
||||
}
|
||||
|
||||
playable.sendPacket(new ShowMiniMap(item.getId()));
|
||||
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 com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ShowMiniMap;
|
||||
|
||||
/**
|
||||
* This class provides handling for items that should display a map when double clicked.
|
||||
*/
|
||||
public class Maps 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;
|
||||
}
|
||||
|
||||
playable.sendPacket(new ShowMiniMap(item.getId()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,90 +1,125 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.MercTicketManager;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Castle;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
public class MercTicket implements IItemHandler
|
||||
{
|
||||
/**
|
||||
* handler for using mercenary tickets. Things to do: 1) Check constraints: 1.a) Tickets may only be used in a castle 1.b) Only specific tickets may be used in each castle (different tickets for each castle) 1.c) only the owner of that castle may use them 1.d) tickets cannot be used during siege
|
||||
* 1.e) Check if max number of tickets has been reached 1.f) Check if max number of tickets from this ticket's TYPE has been reached 2) If allowed, call the MercTicketManager to add the item and spawn in the world 3) Remove the item from the person's inventory
|
||||
*/
|
||||
@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 int itemId = item.getId();
|
||||
final L2PcInstance activeChar = (L2PcInstance) playable;
|
||||
final Castle castle = CastleManager.getInstance().getCastle(activeChar);
|
||||
int castleId = -1;
|
||||
if (castle != null)
|
||||
{
|
||||
castleId = castle.getResidenceId();
|
||||
}
|
||||
|
||||
// add check that certain tickets can only be placed in certain castles
|
||||
if (MercTicketManager.getInstance().getTicketCastleId(itemId) != castleId)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.MERCENARIES_CANNOT_BE_POSITIONED_HERE);
|
||||
return false;
|
||||
}
|
||||
else if (!activeChar.isCastleLord(castleId))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_AUTHORITY_TO_POSITION_MERCENARIES);
|
||||
return false;
|
||||
}
|
||||
else if ((castle != null) && castle.getSiege().isInProgress())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_MERCENARY_CANNOT_BE_POSITIONED_ANYMORE);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (MercTicketManager.getInstance().isAtCasleLimit(item.getId()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_MERCENARY_CANNOT_BE_POSITIONED_ANYMORE);
|
||||
return false;
|
||||
}
|
||||
else if (MercTicketManager.getInstance().isAtTypeLimit(item.getId()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_MERCENARY_CANNOT_BE_POSITIONED_ANYMORE);
|
||||
return false;
|
||||
}
|
||||
else if (MercTicketManager.getInstance().isTooCloseToAnotherTicket(activeChar.getX(), activeChar.getY(), activeChar.getZ()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.POSITIONING_CANNOT_BE_DONE_HERE_BECAUSE_THE_DISTANCE_BETWEEN_MERCENARIES_IS_TOO_SHORT);
|
||||
return false;
|
||||
}
|
||||
|
||||
MercTicketManager.getInstance().addTicket(item.getId(), activeChar);
|
||||
activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false); // Remove item from char's inventory
|
||||
activeChar.sendPacket(SystemMessageId.PLACE_S1_IN_THE_CURRENT_LOCATION_AND_DIRECTION_DO_YOU_WISH_TO_CONTINUE);
|
||||
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.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.PlayerAction;
|
||||
import com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.SiegeGuardManager;
|
||||
import com.l2jmobius.gameserver.model.ClanPrivilege;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Castle;
|
||||
import com.l2jmobius.gameserver.model.events.EventType;
|
||||
import com.l2jmobius.gameserver.model.events.ListenerRegisterType;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.RegisterEvent;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.RegisterType;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerDlgAnswer;
|
||||
import com.l2jmobius.gameserver.model.holders.SiegeGuardHolder;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ConfirmDlg;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* Mercenary Ticket Item Handler.
|
||||
* @author St3eT
|
||||
*/
|
||||
public final class MercTicket extends AbstractNpcAI implements IItemHandler
|
||||
{
|
||||
private final Map<Integer, L2ItemInstance> _items = new ConcurrentHashMap<>();
|
||||
|
||||
public MercTicket()
|
||||
{
|
||||
}
|
||||
|
||||
@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 = playable.getActingPlayer();
|
||||
final Castle castle = CastleManager.getInstance().getCastle(activeChar);
|
||||
if ((castle == null) || (activeChar.getClan() == null) || (castle.getOwnerId() != activeChar.getClanId()) || !activeChar.hasClanPrivilege(ClanPrivilege.CS_MERCENARIES))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_AUTHORITY_TO_POSITION_MERCENARIES);
|
||||
return false;
|
||||
}
|
||||
|
||||
final int castleId = castle.getResidenceId();
|
||||
final SiegeGuardHolder holder = SiegeGuardManager.getInstance().getSiegeGuardByItem(castleId, item.getId());
|
||||
if ((holder == null) || (castleId != holder.getCastleId()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.MERCENARIES_CANNOT_BE_POSITIONED_HERE);
|
||||
return false;
|
||||
}
|
||||
else if (castle.getSiege().isInProgress())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_MERCENARY_CANNOT_BE_POSITIONED_ANYMORE);
|
||||
return false;
|
||||
}
|
||||
else if (SiegeGuardManager.getInstance().isTooCloseToAnotherTicket(activeChar))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.POSITIONING_CANNOT_BE_DONE_HERE_BECAUSE_THE_DISTANCE_BETWEEN_MERCENARIES_IS_TOO_SHORT);
|
||||
return false;
|
||||
}
|
||||
else if (SiegeGuardManager.getInstance().isAtNpcLimit(castleId, item.getId()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_MERCENARY_CANNOT_BE_POSITIONED_ANYMORE);
|
||||
return false;
|
||||
}
|
||||
|
||||
_items.put(activeChar.getObjectId(), item);
|
||||
final ConfirmDlg dlg = new ConfirmDlg(SystemMessageId.PLACE_S1_IN_THE_CURRENT_LOCATION_AND_DIRECTION_DO_YOU_WISH_TO_CONTINUE);
|
||||
dlg.addTime(15000);
|
||||
dlg.addNpcName(holder.getNpcId());
|
||||
activeChar.sendPacket(dlg);
|
||||
activeChar.addAction(PlayerAction.MERCENARY_CONFIRM);
|
||||
return true;
|
||||
}
|
||||
|
||||
@RegisterEvent(EventType.ON_PLAYER_DLG_ANSWER)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
|
||||
public void onPlayerDlgAnswer(OnPlayerDlgAnswer event)
|
||||
{
|
||||
final L2PcInstance activeChar = event.getActiveChar();
|
||||
if (activeChar.removeAction(PlayerAction.MERCENARY_CONFIRM) && _items.containsKey(activeChar.getObjectId()))
|
||||
{
|
||||
if (SiegeGuardManager.getInstance().isTooCloseToAnotherTicket(activeChar))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.POSITIONING_CANNOT_BE_DONE_HERE_BECAUSE_THE_DISTANCE_BETWEEN_MERCENARIES_IS_TOO_SHORT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getAnswer() == 1)
|
||||
{
|
||||
final L2ItemInstance item = _items.get(activeChar.getObjectId());
|
||||
SiegeGuardManager.getInstance().addTicket(item.getId(), activeChar);
|
||||
activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false); // Remove item from char's inventory
|
||||
}
|
||||
_items.remove(activeChar.getObjectId());
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,39 +1,39 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExRequestChangeNicknameColor;
|
||||
|
||||
public class NicknameColor 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;
|
||||
}
|
||||
|
||||
playable.sendPacket(new ExRequestChangeNicknameColor(item.getObjectId()));
|
||||
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 com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExRequestChangeNicknameColor;
|
||||
|
||||
public class NicknameColor 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;
|
||||
}
|
||||
|
||||
playable.sendPacket(new ExRequestChangeNicknameColor(item.getObjectId()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,94 +1,100 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PetDataTable;
|
||||
import com.l2jmobius.gameserver.datatables.SkillData;
|
||||
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.actor.instance.L2PetInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author Kerberos, Zoey76
|
||||
*/
|
||||
public class PetFood implements IItemHandler
|
||||
{
|
||||
@Override
|
||||
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
|
||||
{
|
||||
if (playable.isPet() && !((L2PetInstance) playable).canEatFoodId(item.getId()))
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.THIS_PET_CANNOT_USE_THIS_ITEM);
|
||||
return false;
|
||||
}
|
||||
|
||||
final SkillHolder[] skills = item.getItem().getSkills();
|
||||
if (skills != null)
|
||||
{
|
||||
for (SkillHolder sk : skills)
|
||||
{
|
||||
useFood(playable, sk.getSkillId(), sk.getSkillLvl(), item);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean useFood(L2Playable activeChar, int skillId, int skillLevel, L2ItemInstance item)
|
||||
{
|
||||
final Skill skill = SkillData.getInstance().getSkill(skillId, skillLevel);
|
||||
if (skill != null)
|
||||
{
|
||||
if (activeChar.isPet())
|
||||
{
|
||||
final L2PetInstance pet = (L2PetInstance) activeChar;
|
||||
if (pet.destroyItem("Consume", item.getObjectId(), 1, null, false))
|
||||
{
|
||||
pet.broadcastPacket(new MagicSkillUse(pet, pet, skillId, skillLevel, 0, 0));
|
||||
pet.setCurrentFed(pet.getCurrentFed() + (skill.getFeed() * Config.PET_FOOD_RATE));
|
||||
pet.broadcastStatusUpdate();
|
||||
if (pet.isHungry())
|
||||
{
|
||||
pet.sendPacket(SystemMessageId.YOUR_PET_ATE_A_LITTLE_BUT_IS_STILL_HUNGRY);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (activeChar.isPlayer())
|
||||
{
|
||||
final L2PcInstance player = activeChar.getActingPlayer();
|
||||
if (player.isMounted() && PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood().contains(Integer.valueOf(item.getId())) && player.destroyItem("Consume", item.getObjectId(), 1, null, false))
|
||||
{
|
||||
player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0));
|
||||
player.setCurrentFeed(player.getCurrentFeed() + skill.getFeed());
|
||||
return true;
|
||||
}
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED_DUE_TO_UNSUITABLE_TERMS);
|
||||
sm.addItemName(item);
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.data.xml.impl.PetDataTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
|
||||
import com.l2jmobius.gameserver.enums.ItemSkillType;
|
||||
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.actor.instance.L2PetInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemSkillHolder;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author Kerberos, Zoey76
|
||||
*/
|
||||
public class PetFood implements IItemHandler
|
||||
{
|
||||
@Override
|
||||
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
|
||||
{
|
||||
if (playable.isPet() && !((L2PetInstance) playable).canEatFoodId(item.getId()))
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.THIS_PET_CANNOT_USE_THIS_ITEM);
|
||||
return false;
|
||||
}
|
||||
|
||||
final List<ItemSkillHolder> skills = item.getItem().getSkills(ItemSkillType.NORMAL);
|
||||
if (skills != null)
|
||||
{
|
||||
skills.forEach(holder -> useFood(playable, holder.getSkillId(), holder.getSkillLvl(), item));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean useFood(L2Playable activeChar, int skillId, int skillLevel, L2ItemInstance item)
|
||||
{
|
||||
final Skill skill = SkillData.getInstance().getSkill(skillId, skillLevel);
|
||||
if (skill != null)
|
||||
{
|
||||
if (activeChar.isPet())
|
||||
{
|
||||
final L2PetInstance pet = (L2PetInstance) activeChar;
|
||||
if (pet.destroyItem("Consume", item.getObjectId(), 1, null, false))
|
||||
{
|
||||
pet.broadcastPacket(new MagicSkillUse(pet, pet, skillId, skillLevel, 0, 0));
|
||||
skill.applyEffects(pet, pet);
|
||||
pet.broadcastStatusUpdate();
|
||||
if (pet.isHungry())
|
||||
{
|
||||
pet.sendPacket(SystemMessageId.YOUR_PET_ATE_A_LITTLE_BUT_IS_STILL_HUNGRY);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (activeChar.isPlayer())
|
||||
{
|
||||
final L2PcInstance player = activeChar.getActingPlayer();
|
||||
if (player.isMounted())
|
||||
{
|
||||
final List<Integer> foodIds = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood();
|
||||
if (foodIds.contains(Integer.valueOf(item.getId())))
|
||||
{
|
||||
if (player.destroyItem("Consume", item.getObjectId(), 1, null, false))
|
||||
{
|
||||
player.broadcastPacket(new MagicSkillUse(player, player, skillId, skillLevel, 0, 0));
|
||||
skill.applyEffects(player, player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED_DUE_TO_UNSUITABLE_TERMS);
|
||||
sm.addItemName(item);
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -1,112 +1,112 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.data.xml.impl.RecipeData;
|
||||
import com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.L2RecipeList;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class Recipes 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 = playable.getActingPlayer();
|
||||
if (activeChar.isInCraftMode())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_MAY_NOT_ALTER_YOUR_RECIPE_BOOK_WHILE_ENGAGED_IN_MANUFACTURING);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2RecipeList rp = RecipeData.getInstance().getRecipeByItemId(item.getId());
|
||||
if (rp == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.hasRecipeList(rp.getId()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_RECIPE_IS_ALREADY_REGISTERED);
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean canCraft = false;
|
||||
boolean recipeLevel = false;
|
||||
boolean recipeLimit = false;
|
||||
if (rp.isDwarvenRecipe())
|
||||
{
|
||||
canCraft = activeChar.hasDwarvenCraft();
|
||||
recipeLevel = rp.getLevel() > activeChar.getDwarvenCraft();
|
||||
recipeLimit = activeChar.getDwarvenRecipeBook().length >= activeChar.getDwarfRecipeLimit();
|
||||
}
|
||||
else
|
||||
{
|
||||
canCraft = activeChar.hasCommonCraft();
|
||||
recipeLevel = rp.getLevel() > activeChar.getCommonCraft();
|
||||
recipeLimit = activeChar.getCommonRecipeBook().length >= activeChar.getCommonRecipeLimit();
|
||||
}
|
||||
|
||||
if (!canCraft)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_RECIPE_CANNOT_BE_REGISTERED_YOU_DO_NOT_HAVE_THE_ABILITY_TO_CREATE_ITEMS);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (recipeLevel)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOUR_CREATE_ITEM_LEVEL_IS_TOO_LOW_TO_REGISTER_THIS_RECIPE);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (recipeLimit)
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.UP_TO_S1_RECIPES_CAN_BE_REGISTERED);
|
||||
sm.addInt(rp.isDwarvenRecipe() ? activeChar.getDwarfRecipeLimit() : activeChar.getCommonRecipeLimit());
|
||||
activeChar.sendPacket(sm);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rp.isDwarvenRecipe())
|
||||
{
|
||||
activeChar.registerDwarvenRecipeList(rp, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.registerCommonRecipeList(rp, true);
|
||||
}
|
||||
|
||||
activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false);
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_ADDED);
|
||||
sm.addItemName(item);
|
||||
activeChar.sendPacket(sm);
|
||||
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 com.l2jmobius.gameserver.data.xml.impl.RecipeData;
|
||||
import com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.L2RecipeList;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class Recipes 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 = playable.getActingPlayer();
|
||||
if (activeChar.isInCraftMode())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_MAY_NOT_ALTER_YOUR_RECIPE_BOOK_WHILE_ENGAGED_IN_MANUFACTURING);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2RecipeList rp = RecipeData.getInstance().getRecipeByItemId(item.getId());
|
||||
if (rp == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.hasRecipeList(rp.getId()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_RECIPE_IS_ALREADY_REGISTERED);
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean canCraft = false;
|
||||
boolean recipeLevel = false;
|
||||
boolean recipeLimit = false;
|
||||
if (rp.isDwarvenRecipe())
|
||||
{
|
||||
canCraft = activeChar.hasDwarvenCraft();
|
||||
recipeLevel = (rp.getLevel() > activeChar.getDwarvenCraft());
|
||||
recipeLimit = (activeChar.getDwarvenRecipeBook().length >= activeChar.getDwarfRecipeLimit());
|
||||
}
|
||||
else
|
||||
{
|
||||
canCraft = activeChar.hasCommonCraft();
|
||||
recipeLevel = (rp.getLevel() > activeChar.getCommonCraft());
|
||||
recipeLimit = (activeChar.getCommonRecipeBook().length >= activeChar.getCommonRecipeLimit());
|
||||
}
|
||||
|
||||
if (!canCraft)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_RECIPE_CANNOT_BE_REGISTERED_YOU_DO_NOT_HAVE_THE_ABILITY_TO_CREATE_ITEMS);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (recipeLevel)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOUR_CREATE_ITEM_LEVEL_IS_TOO_LOW_TO_REGISTER_THIS_RECIPE);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (recipeLimit)
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.UP_TO_S1_RECIPES_CAN_BE_REGISTERED);
|
||||
sm.addInt(rp.isDwarvenRecipe() ? activeChar.getDwarfRecipeLimit() : activeChar.getCommonRecipeLimit());
|
||||
activeChar.sendPacket(sm);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rp.isDwarvenRecipe())
|
||||
{
|
||||
activeChar.registerDwarvenRecipeList(rp, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.registerCommonRecipeList(rp, true);
|
||||
}
|
||||
|
||||
activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false);
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_ADDED);
|
||||
sm.addItemName(item);
|
||||
activeChar.sendPacket(sm);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,88 +1,89 @@
|
||||
/*
|
||||
* 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 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.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.Dice;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
public class RollingDice 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 = playable.getActingPlayer();
|
||||
final int itemId = item.getId();
|
||||
|
||||
if (activeChar.isInOlympiadMode())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_THAT_ITEM_IN_A_OLYMPIAD_MATCH);
|
||||
return false;
|
||||
}
|
||||
|
||||
final int number = rollDice(activeChar);
|
||||
if (number == 0)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_MAY_NOT_THROW_THE_DICE_AT_THIS_TIME_TRY_AGAIN_LATER);
|
||||
return false;
|
||||
}
|
||||
|
||||
Broadcast.toSelfAndKnownPlayers(activeChar, new Dice(activeChar.getObjectId(), itemId, number, activeChar.getX() - 30, activeChar.getY() - 30, activeChar.getZ()));
|
||||
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_ROLLED_A_S2);
|
||||
sm.addString(activeChar.getName());
|
||||
sm.addInt(number);
|
||||
|
||||
activeChar.sendPacket(sm);
|
||||
if (activeChar.isInsideZone(ZoneId.PEACE))
|
||||
{
|
||||
Broadcast.toKnownPlayers(activeChar, sm);
|
||||
}
|
||||
else if (activeChar.isInParty()) // TODO: Verify this!
|
||||
{
|
||||
activeChar.getParty().broadcastToPartyMembers(activeChar, sm);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
private int rollDice(L2PcInstance player)
|
||||
{
|
||||
// Check if the dice is ready
|
||||
if (!player.getFloodProtectors().getRollDice().tryPerformAction("roll dice"))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return Rnd.get(1, 6);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 com.l2jmobius.commons.util.Rnd;
|
||||
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.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.Dice;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
public class RollingDice 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 = playable.getActingPlayer();
|
||||
final int itemId = item.getId();
|
||||
|
||||
if (activeChar.isInOlympiadMode())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_THAT_ITEM_IN_A_OLYMPIAD_MATCH);
|
||||
return false;
|
||||
}
|
||||
|
||||
final int number = rollDice(activeChar);
|
||||
if (number == 0)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_MAY_NOT_THROW_THE_DICE_AT_THIS_TIME_TRY_AGAIN_LATER);
|
||||
return false;
|
||||
}
|
||||
|
||||
Broadcast.toSelfAndKnownPlayers(activeChar, new Dice(activeChar.getObjectId(), itemId, number, activeChar.getX() - 30, activeChar.getY() - 30, activeChar.getZ()));
|
||||
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_ROLLED_A_S2);
|
||||
sm.addString(activeChar.getName());
|
||||
sm.addInt(number);
|
||||
|
||||
activeChar.sendPacket(sm);
|
||||
if (activeChar.isInsideZone(ZoneId.PEACE))
|
||||
{
|
||||
Broadcast.toKnownPlayers(activeChar, sm);
|
||||
}
|
||||
else if (activeChar.isInParty()) // TODO: Verify this!
|
||||
{
|
||||
activeChar.getParty().broadcastToPartyMembers(activeChar, sm);
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
private int rollDice(L2PcInstance player)
|
||||
{
|
||||
// Check if the dice is ready
|
||||
if (!player.getFloodProtectors().getRollDice().tryPerformAction("roll dice"))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return Rnd.get(1, 6);
|
||||
}
|
||||
}
|
||||
|
@@ -1,104 +1,100 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2Seed;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2ChestInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
|
||||
/**
|
||||
* @author l3x
|
||||
*/
|
||||
public class Seed implements IItemHandler
|
||||
{
|
||||
@Override
|
||||
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
|
||||
{
|
||||
if (!Config.ALLOW_MANOR)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!playable.isPlayer())
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_THIS_ITEM);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2Object tgt = playable.getTarget();
|
||||
if (tgt == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!tgt.isNpc())
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
if (!tgt.isMonster() || ((L2MonsterInstance) tgt).isRaid() || (tgt instanceof L2ChestInstance))
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.THE_TARGET_IS_UNAVAILABLE_FOR_SEEDING);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2MonsterInstance target = (L2MonsterInstance) tgt;
|
||||
if (target.isDead())
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
if (target.isSeeded())
|
||||
{
|
||||
playable.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2Seed seed = CastleManorManager.getInstance().getSeed(item.getId());
|
||||
if (seed == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (seed.getCastleId() != MapRegionManager.getInstance().getAreaCastle(playable))
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.THIS_SEED_MAY_NOT_BE_SOWN_HERE);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance activeChar = playable.getActingPlayer();
|
||||
target.setSeeded(seed, activeChar);
|
||||
|
||||
final SkillHolder[] skills = item.getItem().getSkills();
|
||||
if (skills != null)
|
||||
{
|
||||
for (SkillHolder sk : skills)
|
||||
{
|
||||
activeChar.useMagic(sk.getSkill(), false, false);
|
||||
}
|
||||
}
|
||||
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.Config;
|
||||
import com.l2jmobius.gameserver.enums.ItemSkillType;
|
||||
import com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2Seed;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2ChestInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemSkillHolder;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
|
||||
/**
|
||||
* @author l3x
|
||||
*/
|
||||
public class Seed implements IItemHandler
|
||||
{
|
||||
@Override
|
||||
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
|
||||
{
|
||||
if (!Config.ALLOW_MANOR)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!playable.isPlayer())
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_THIS_ITEM);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2Object tgt = playable.getTarget();
|
||||
if (!tgt.isNpc())
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
else if (!tgt.isMonster() || ((L2MonsterInstance) tgt).isRaid() || (tgt instanceof L2ChestInstance))
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.THE_TARGET_IS_UNAVAILABLE_FOR_SEEDING);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2MonsterInstance target = (L2MonsterInstance) tgt;
|
||||
if (target.isDead())
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
else if (target.isSeeded())
|
||||
{
|
||||
playable.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2Seed seed = CastleManorManager.getInstance().getSeed(item.getId());
|
||||
if (seed == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (seed.getCastleId() != MapRegionManager.getInstance().getAreaCastle(playable)) // TODO: replace me with tax zone
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.THIS_SEED_MAY_NOT_BE_SOWN_HERE);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance activeChar = playable.getActingPlayer();
|
||||
target.setSeeded(seed, activeChar);
|
||||
|
||||
final List<ItemSkillHolder> skills = item.getItem().getSkills(ItemSkillType.NORMAL);
|
||||
if (skills != null)
|
||||
{
|
||||
skills.forEach(holder -> activeChar.useMagic(holder.getSkill(), item, false, false));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,132 +1,116 @@
|
||||
/*
|
||||
* 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;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
public class SoulShots 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 = playable.getActingPlayer();
|
||||
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 Soul shot can be used
|
||||
if ((weaponInst == null) || (weaponItem.getSoulShotCount() == 0))
|
||||
{
|
||||
if (!activeChar.getAutoSoulShot().contains(itemId))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.CANNOT_USE_SOULSHOTS);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
final boolean gradeCheck = item.isEtcItem() && (item.getEtcItem().getDefaultAction() == ActionType.SOULSHOT) && (weaponInst.getItem().getCrystalTypePlus() == item.getItem().getCrystalTypePlus());
|
||||
|
||||
if (!gradeCheck)
|
||||
{
|
||||
if (!activeChar.getAutoSoulShot().contains(itemId))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_SOULSHOT_YOU_ARE_ATTEMPTING_TO_USE_DOES_NOT_MATCH_THE_GRADE_OF_YOUR_EQUIPPED_WEAPON);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.soulShotLock.lock();
|
||||
try
|
||||
{
|
||||
// Check if Soul shot is already active
|
||||
if (activeChar.isChargedShot(ShotType.SOULSHOTS))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Consume Soul shots if player has enough of them
|
||||
int SSCount = weaponItem.getSoulShotCount();
|
||||
if ((weaponItem.getReducedSoulShot() > 0) && (Rnd.get(100) < weaponItem.getReducedSoulShotChance()))
|
||||
{
|
||||
SSCount = weaponItem.getReducedSoulShot();
|
||||
}
|
||||
|
||||
if (!activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), SSCount, null, false))
|
||||
{
|
||||
if (!activeChar.disableAutoShot(itemId))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_SOULSHOTS_FOR_THAT);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Charge soul shot
|
||||
weaponInst.setChargedShot(ShotType.SOULSHOTS, true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
activeChar.soulShotLock.unlock();
|
||||
}
|
||||
|
||||
// Send message to client
|
||||
activeChar.sendPacket(SystemMessageId.YOUR_SOULSHOTS_ARE_ENABLED);
|
||||
// Visual effect change if player has equipped Ruby lvl 3 or higher
|
||||
if ((activeChar.getInventory().getItemByItemId(38859) != null) && activeChar.getInventory().getItemByItemId(38859).isEquipped())
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, 17817, 1, 0, 0), 600);
|
||||
}
|
||||
else if ((activeChar.getInventory().getItemByItemId(38858) != null) && activeChar.getInventory().getItemByItemId(38858).isEquipped())
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, 17816, 1, 0, 0), 600);
|
||||
}
|
||||
else if ((activeChar.getInventory().getItemByItemId(38857) != null) && activeChar.getInventory().getItemByItemId(38857).isEquipped())
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, 17815, 1, 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.commons.util.Rnd;
|
||||
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 SoulShots 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 = playable.getActingPlayer();
|
||||
final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
|
||||
final L2Weapon weaponItem = activeChar.getActiveWeaponItem();
|
||||
final List<ItemSkillHolder> skills = item.getItem().getSkills(ItemSkillType.NORMAL);
|
||||
if (skills == null)
|
||||
{
|
||||
_log.warning(getClass().getSimpleName() + ": is missing skills!");
|
||||
return false;
|
||||
}
|
||||
|
||||
final int itemId = item.getId();
|
||||
|
||||
// Check if Soul shot can be used
|
||||
if ((weaponInst == null) || (weaponItem.getSoulShotCount() == 0))
|
||||
{
|
||||
if (!activeChar.getAutoSoulShot().contains(itemId))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.CANNOT_USE_SOULSHOTS);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
final boolean gradeCheck = item.isEtcItem() && (item.getEtcItem().getDefaultAction() == ActionType.SOULSHOT) && (weaponInst.getItem().getCrystalTypePlus() == item.getItem().getCrystalTypePlus());
|
||||
|
||||
if (!gradeCheck)
|
||||
{
|
||||
if (!activeChar.getAutoSoulShot().contains(itemId))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_SOULSHOT_YOU_ARE_ATTEMPTING_TO_USE_DOES_NOT_MATCH_THE_GRADE_OF_YOUR_EQUIPPED_WEAPON);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.soulShotLock.lock();
|
||||
try
|
||||
{
|
||||
// Check if Soul shot is already active
|
||||
if (activeChar.isChargedShot(ShotType.SOULSHOTS))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Consume Soul shots if player has enough of them
|
||||
int SSCount = weaponItem.getSoulShotCount();
|
||||
if ((weaponItem.getReducedSoulShot() > 0) && (Rnd.get(100) < weaponItem.getReducedSoulShotChance()))
|
||||
{
|
||||
SSCount = weaponItem.getReducedSoulShot();
|
||||
}
|
||||
|
||||
if (!activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), SSCount, null, false))
|
||||
{
|
||||
if (!activeChar.disableAutoShot(itemId))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_SOULSHOTS_FOR_THAT);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Charge soul shot
|
||||
weaponInst.setChargedShot(ShotType.SOULSHOTS, true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
activeChar.soulShotLock.unlock();
|
||||
}
|
||||
|
||||
// Send message to client
|
||||
activeChar.sendPacket(SystemMessageId.YOUR_SOULSHOTS_ARE_ENABLED);
|
||||
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,42 +1,42 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ShowXMasSeal;
|
||||
|
||||
/**
|
||||
* @author devScarlet, mrTJO
|
||||
*/
|
||||
public class SpecialXMas 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;
|
||||
}
|
||||
|
||||
playable.broadcastPacket(new ShowXMasSeal(item.getId()));
|
||||
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 com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ShowXMasSeal;
|
||||
|
||||
/**
|
||||
* @author devScarlet, mrTJO
|
||||
*/
|
||||
public class SpecialXMas 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;
|
||||
}
|
||||
|
||||
playable.broadcastPacket(new ShowXMasSeal(item.getId()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,119 +1,103 @@
|
||||
/*
|
||||
* 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 SpiritShot 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 Spirit shot can be used
|
||||
if ((weaponInst == null) || (weaponItem.getSpiritShotCount() == 0))
|
||||
{
|
||||
if (!activeChar.getAutoSoulShot().contains(itemId))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_MAY_NOT_USE_SPIRITSHOTS);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if Spirit shot is already active
|
||||
if (activeChar.isChargedShot(ShotType.SPIRITSHOTS))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
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 Spirit shot 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;
|
||||
}
|
||||
|
||||
// Charge Spirit shot
|
||||
activeChar.setChargedShot(ShotType.SPIRITSHOTS, true);
|
||||
|
||||
// Send message to client
|
||||
activeChar.sendPacket(SystemMessageId.YOUR_SPIRITSHOT_HAS_BEEN_ENABLED);
|
||||
// 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, 1, 0, 0), 600);
|
||||
}
|
||||
else if ((activeChar.getInventory().getItemByItemId(38930) != null) && activeChar.getInventory().getItemByItemId(38930).isEquipped())
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, 17820, 1, 0, 0), 600);
|
||||
}
|
||||
else if ((activeChar.getInventory().getItemByItemId(38929) != null) && activeChar.getInventory().getItemByItemId(38929).isEquipped())
|
||||
{
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, 17819, 1, 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 SpiritShot 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);
|
||||
if (skills == null)
|
||||
{
|
||||
_log.warning(getClass().getSimpleName() + ": is missing skills!");
|
||||
return false;
|
||||
}
|
||||
|
||||
final int itemId = item.getId();
|
||||
|
||||
// Check if Spirit shot can be used
|
||||
if ((weaponInst == null) || (weaponItem.getSpiritShotCount() == 0))
|
||||
{
|
||||
if (!activeChar.getAutoSoulShot().contains(itemId))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_MAY_NOT_USE_SPIRITSHOTS);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if Spirit shot is already active
|
||||
if (activeChar.isChargedShot(ShotType.SPIRITSHOTS))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
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 Spirit shot 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;
|
||||
}
|
||||
|
||||
// Charge Spirit shot
|
||||
activeChar.setChargedShot(ShotType.SPIRITSHOTS, true);
|
||||
|
||||
// Send message to client
|
||||
activeChar.sendPacket(SystemMessageId.YOUR_SPIRITSHOT_HAS_BEEN_ENABLED);
|
||||
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,80 +1,74 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.data.xml.impl.PetDataTable;
|
||||
import com.l2jmobius.gameserver.model.L2PetData;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.TvTEvent;
|
||||
import com.l2jmobius.gameserver.model.holders.PetItemHolder;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho, UnAfraid
|
||||
*/
|
||||
public class SummonItems extends ItemSkillsTemplate
|
||||
{
|
||||
@Override
|
||||
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
|
||||
{
|
||||
if (!playable.isPlayer())
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_THIS_ITEM);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!TvTEvent.onItemSummon(playable.getObjectId()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance activeChar = playable.getActingPlayer();
|
||||
if (!activeChar.getFloodProtectors().getItemPetSummon().tryPerformAction("summon items") || (activeChar.getBlockCheckerArena() != -1) || activeChar.inObserverMode() || activeChar.isAllSkillsDisabled() || activeChar.isCastingNow())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.isSitting())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_MOVE_WHILE_SITTING);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.hasPet() || activeChar.isMounted())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_ALREADY_HAVE_A_PET);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.isAttackingNow())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_SUMMON_DURING_COMBAT);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PetData petData = PetDataTable.getInstance().getPetDataByItemId(item.getId());
|
||||
if ((petData == null) || (petData.getNpcId() == -1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.addScript(new PetItemHolder(item));
|
||||
return super.useItem(playable, item, forceUse);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.data.xml.impl.PetDataTable;
|
||||
import com.l2jmobius.gameserver.model.L2PetData;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.PetItemHolder;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho, UnAfraid
|
||||
*/
|
||||
public class SummonItems extends ItemSkillsTemplate
|
||||
{
|
||||
@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 = playable.getActingPlayer();
|
||||
if (!activeChar.getFloodProtectors().getItemPetSummon().tryPerformAction("summon items") || (activeChar.getBlockCheckerArena() != -1) || activeChar.inObserverMode() || activeChar.isAllSkillsDisabled() || activeChar.isCastingNow())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.isSitting())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_MOVE_WHILE_SITTING);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.hasPet() || activeChar.isMounted())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_ALREADY_HAVE_A_PET);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.isAttackingNow())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_SUMMON_DURING_COMBAT);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PetData petData = PetDataTable.getInstance().getPetDataByItemId(item.getId());
|
||||
if ((petData == null) || (petData.getNpcId() == -1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.addScript(new PetItemHolder(item));
|
||||
return super.useItem(playable, item, forceUse);
|
||||
}
|
||||
}
|
||||
|
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* 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 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.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* Teleport Bookmark Slot Handler
|
||||
* @author ShanSoft
|
||||
*/
|
||||
public class TeleportBookmark 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 player = playable.getActingPlayer();
|
||||
|
||||
if (player.getBookMarkSlot() >= 9)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOUR_NUMBER_OF_MY_TELEPORTS_SLOTS_HAS_REACHED_ITS_MAXIMUM_LIMIT);
|
||||
return false;
|
||||
}
|
||||
|
||||
player.destroyItem("Consume", item.getObjectId(), 1, null, false);
|
||||
|
||||
player.setBookMarkSlot(player.getBookMarkSlot() + 3);
|
||||
player.sendPacket(SystemMessageId.THE_NUMBER_OF_MY_TELEPORTS_SLOTS_HAS_BEEN_INCREASED);
|
||||
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DISAPPEARED);
|
||||
sm.addItemName(item.getId());
|
||||
player.sendPacket(sm);
|
||||
return true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user