Separated the Classic Datapack to it's own folder.

This commit is contained in:
MobiusDev
2015-05-02 03:45:56 +00:00
parent 08e28fe058
commit 484bff80bb
11501 changed files with 2200482 additions and 627 deletions

View File

@@ -0,0 +1,63 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.data.xml.impl.AppearanceItemData;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.request.ShapeShiftingItemRequest;
import com.l2jserver.gameserver.model.items.appearance.AppearanceStone;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.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;
}
}

View File

@@ -0,0 +1,140 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import java.util.List;
import java.util.logging.Level;
import java.util.stream.Collectors;
import com.l2jserver.gameserver.enums.ShotType;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.holders.SkillHolder;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jserver.gameserver.util.Broadcast;
/**
* 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)
{
if (!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)
{
if (!pet.isChargedShot(ShotType.SOULSHOTS))
{
pet.setChargedShot(ShotType.SOULSHOTS, true);
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);
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(s, s, skills[0].getSkillId(), skills[0].getSkillLvl(), 0, 0), 600);
}
});
return true;
}
}

View File

@@ -0,0 +1,142 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import java.util.List;
import java.util.logging.Level;
import java.util.stream.Collectors;
import com.l2jserver.gameserver.enums.ShotType;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.holders.SkillHolder;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jserver.gameserver.util.Broadcast;
/**
* 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)
{
if (!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;
}
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);
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);
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(s, s, skills[0].getSkillId(), skills[0].getSkillLvl(), 0, 0), 600);
}
});
return true;
}
}

View File

@@ -0,0 +1,105 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import java.util.logging.Level;
import com.l2jserver.gameserver.enums.ShotType;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.holders.SkillHolder;
import com.l2jserver.gameserver.model.items.L2Weapon;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.model.items.type.ActionType;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jserver.gameserver.util.Broadcast;
public class BlessedSpiritShot implements IItemHandler
{
@Override
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!playable.isPlayer())
{
playable.sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_THIS_ITEM);
return false;
}
L2PcInstance activeChar = (L2PcInstance) playable;
L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
L2Weapon weaponItem = activeChar.getActiveWeaponItem();
final SkillHolder[] skills = item.getItem().getSkills();
int itemId = item.getId();
if (skills == null)
{
_log.log(Level.WARNING, getClass().getSimpleName() + ": is missing skills!");
return false;
}
// Check if Blessed SpiritShot can be used
if ((weaponInst == null) || (weaponItem == null) || (weaponItem.getSpiritShotCount() == 0))
{
if (!activeChar.getAutoSoulShot().contains(itemId))
{
activeChar.sendPacket(SystemMessageId.YOU_MAY_NOT_USE_SPIRITSHOTS);
}
return false;
}
// Check if Blessed SpiritShot is already active (it can be charged over SpiritShot)
if (activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS))
{
return false;
}
// Check for correct grade
boolean gradeCheck = item.isEtcItem() && (item.getEtcItem().getDefaultAction() == ActionType.SPIRITSHOT) && (weaponInst.getItem().getCrystalTypePlus() == item.getItem().getCrystalTypePlus());
if (!gradeCheck)
{
if (!activeChar.getAutoSoulShot().contains(itemId))
{
activeChar.sendPacket(SystemMessageId.YOUR_SPIRITSHOT_DOES_NOT_MATCH_THE_WEAPON_S_GRADE);
}
return false;
}
// Consume Blessed SpiritShot if player has enough of them
if (!activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), weaponItem.getSpiritShotCount(), null, false))
{
if (!activeChar.disableAutoShot(itemId))
{
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_SPIRITSHOT_FOR_THAT);
}
return false;
}
// Send message to client
activeChar.sendPacket(SystemMessageId.YOUR_SPIRITSHOT_HAS_BEEN_ENABLED);
activeChar.setChargedShot(ShotType.BLESSED_SPIRITSHOTS, true);
Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, skills[0].getSkillId(), skills[0].getSkillLvl(), 0, 0), 600);
return true;
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.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;
}
L2PcInstance activeChar = (L2PcInstance) playable;
final int itemId = item.getId();
String filename = "html/help/" + itemId + ".htm";
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;
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.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;
}
L2PcInstance activeChar = (L2PcInstance) playable;
final int itemId = item.getId();
String filename = "html/item/" + itemId + ".htm";
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;
}
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.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;
}
}

View File

@@ -0,0 +1,57 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.request.EnchantItemAttributeRequest;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExChangeAttributeItemList;
import com.l2jserver.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;
}
}

View File

@@ -0,0 +1,90 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.EtcStatusUpdate;
import com.l2jserver.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)
{
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;
}
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.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);
}
}

View File

@@ -0,0 +1,56 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.request.EnchantItemAttributeRequest;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.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;
}
}

View File

@@ -0,0 +1,56 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.request.EnchantItemRequest;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.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;
}
}

View File

@@ -0,0 +1,103 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.instancemanager.HandysBlockCheckerManager;
import com.l2jserver.gameserver.model.ArenaParticipantsHolder;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2BlockInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.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(final L2PcInstance castor, L2ItemInstance item)
{
final int blockCheckerArena = castor.getBlockCheckerArena();
if (blockCheckerArena == -1)
{
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 (final 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;
}
}

View File

@@ -0,0 +1,99 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import java.util.List;
import com.l2jserver.Config;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.L2ExtractableProduct;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.items.L2EtcItem;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.util.Rnd;
/**
* 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;
}
}

View File

@@ -0,0 +1,128 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.data.xml.impl.CategoryData;
import com.l2jserver.gameserver.enums.CategoryType;
import com.l2jserver.gameserver.enums.Race;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.base.ClassId;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jserver.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;
}
}

View File

@@ -0,0 +1,96 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import java.util.logging.Level;
import com.l2jserver.gameserver.enums.ShotType;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.holders.SkillHolder;
import com.l2jserver.gameserver.model.items.L2Weapon;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.model.items.type.ActionType;
import com.l2jserver.gameserver.model.items.type.WeaponType;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jserver.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;
}
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);
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;
}
}

View File

@@ -0,0 +1,72 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.Config;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.holders.SkillHolder;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.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 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;
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.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);
}
}

View File

@@ -0,0 +1,236 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.entity.TvTEvent;
import com.l2jserver.gameserver.model.holders.SkillHolder;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.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;
}
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())
{
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))
{
if (!playable.destroyItem("Consume", item.getObjectId(), 1, playable, false))
{
playable.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT2);
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())
{
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;
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
public class ManaPotion extends ItemSkills
{
@Override
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!Config.L2JMOD_ENABLE_MANA_POTIONS_SUPPORT)
{
playable.sendPacket(SystemMessageId.NOTHING_HAPPENED);
return false;
}
return super.useItem(playable, item, forceUse);
}
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.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;
}
}

View File

@@ -0,0 +1,92 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.instancemanager.MercTicketManager;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Castle;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.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;
}
int itemId = item.getId();
L2PcInstance activeChar = (L2PcInstance) playable;
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;
}
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.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;
}
}

View File

@@ -0,0 +1,105 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import java.util.List;
import com.l2jserver.Config;
import com.l2jserver.gameserver.data.xml.impl.PetDataTable;
import com.l2jserver.gameserver.datatables.SkillData;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
import com.l2jserver.gameserver.model.holders.SkillHolder;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jserver.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;
}
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));
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())
{
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));
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;
}
}

View File

@@ -0,0 +1,114 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.data.xml.impl.RecipeData;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.L2RecipeList;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.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;
}
}

View File

@@ -0,0 +1,91 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.Dice;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.util.Broadcast;
import com.l2jserver.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;
}
L2PcInstance activeChar = playable.getActingPlayer();
int itemId = item.getId();
if (activeChar.isInOlympiadMode())
{
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_THAT_ITEM_IN_A_OLYMPIAD_MATCH);
return false;
}
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()));
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);
}
}

View File

@@ -0,0 +1,102 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.Config;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.instancemanager.CastleManorManager;
import com.l2jserver.gameserver.instancemanager.MapRegionManager;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Seed;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2ChestInstance;
import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.holders.SkillHolder;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.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 SkillHolder[] skills = item.getItem().getSkills();
if (skills != null)
{
for (SkillHolder sk : skills)
{
activeChar.useMagic(sk.getSkill(), false, false);
}
}
return true;
}
}

View File

@@ -0,0 +1,118 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import java.util.logging.Level;
import com.l2jserver.gameserver.enums.ShotType;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.holders.SkillHolder;
import com.l2jserver.gameserver.model.items.L2Weapon;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.model.items.type.ActionType;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jserver.gameserver.util.Broadcast;
import com.l2jserver.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();
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;
}
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);
Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, skills[0].getSkillId(), skills[0].getSkillLvl(), 0, 0), 600);
return true;
}
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.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;
}
}

View File

@@ -0,0 +1,105 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import java.util.logging.Level;
import com.l2jserver.gameserver.enums.ShotType;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.holders.SkillHolder;
import com.l2jserver.gameserver.model.items.L2Weapon;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.model.items.type.ActionType;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jserver.gameserver.util.Broadcast;
public class 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();
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;
}
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);
Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, skills[0].getSkillId(), skills[0].getSkillLvl(), 0, 0), 600);
return true;
}
}

View File

@@ -0,0 +1,82 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.data.xml.impl.PetDataTable;
import com.l2jserver.gameserver.model.L2PetData;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.TvTEvent;
import com.l2jserver.gameserver.model.holders.PetItemHolder;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.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);
}
}

View File

@@ -0,0 +1,61 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.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;
}
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);
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DISAPPEARED);
sm.addItemName(item.getId());
player.sendPacket(sm);
return true;
}
}