actual freya branch

This commit is contained in:
2026-09-12 15:39:57 +00:00
parent 9fa534b20e
commit 8049e0a882
18540 changed files with 1228200 additions and 0 deletions
@@ -0,0 +1,117 @@
/*
* 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.L2ItemInstance;
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.actor.instance.L2PetInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.util.Broadcast;
/**
* Beast SoulShot Handler
*
* @author Tempy
*/
public class BeastSoulShot implements IItemHandler
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (playable == null)
return;
L2PcInstance activeOwner = null;
if (playable instanceof L2Summon)
{
activeOwner = ((L2Summon) playable).getOwner();
activeOwner.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.PET_CANNOT_USE_ITEM));
return;
}
else if (playable instanceof L2PcInstance)
activeOwner = (L2PcInstance) playable;
if (activeOwner == null)
return;
L2Summon activePet = activeOwner.getPet();
if (activePet == null)
{
activeOwner.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.PETS_ARE_NOT_AVAILABLE_AT_THIS_TIME));
return;
}
if (activePet.isDead())
{
activeOwner.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SOULSHOTS_AND_SPIRITSHOTS_ARE_NOT_AVAILABLE_FOR_A_DEAD_PET));
return;
}
int itemId = item.getItemId();
short shotConsumption = activePet.getSoulShotsPerHit();
long shotCount = item.getCount();
if (!(shotCount > shotConsumption))
{
// Not enough Soulshots to use.
if (!activeOwner.disableAutoShot(itemId))
activeOwner.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_SOULSHOTS_FOR_PET));
return;
}
L2ItemInstance weaponInst = null;
if (activePet instanceof L2PetInstance)
weaponInst = ((L2PetInstance) activePet).getActiveWeaponInstance();
if (weaponInst == null)
{
if (activePet.getChargedSoulShot() != L2ItemInstance.CHARGED_NONE)
return;
activePet.setChargedSoulShot(L2ItemInstance.CHARGED_SOULSHOT);
}
else
{
if (weaponInst.getChargedSoulshot() != L2ItemInstance.CHARGED_NONE)
{
// SoulShots are already active.
return;
}
weaponInst.setChargedSoulshot(L2ItemInstance.CHARGED_SOULSHOT);
}
// 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(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_SOULSHOTS_FOR_PET));
return;
}
// Pet uses the power of spirit.
activeOwner.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.PET_USE_SPIRITSHOT));
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(activePet, activePet, itemId == 6645 ? 2033 : 22036, 1, 0, 0), 360000/*600*/);
}
}
@@ -0,0 +1,60 @@
/*
* 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.datatables.SkillTable;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2FeedableBeastInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
public class BeastSpice implements IItemHandler
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
L2PcInstance activeChar = (L2PcInstance) playable;
if (!(activeChar.getTarget() instanceof L2FeedableBeastInstance))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
return;
}
int skillId = 0;
switch (item.getItemId())
{
case 6643:
skillId = 2188;
break;
case 6644:
skillId = 2189;
break;
}
L2Skill skill = SkillTable.getInstance().getInfo(skillId, 1);
if (skill != null)
activeChar.useMagic(skill, false, false);
}
}
@@ -0,0 +1,135 @@
/*
* 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.L2ItemInstance;
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.actor.instance.L2PetInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.util.Broadcast;
/**
* Beast SpiritShot Handler
*
* @author Tempy
*/
public class BeastSpiritShot implements IItemHandler
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (playable == null)
return;
L2PcInstance activeOwner = playable.getActingPlayer();
if (playable instanceof L2Summon)
{
activeOwner.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.PET_CANNOT_USE_ITEM));
return;
}
L2Summon activePet = activeOwner.getPet();
if (activePet == null)
{
activeOwner.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.PETS_ARE_NOT_AVAILABLE_AT_THIS_TIME));
return;
}
if (activePet.isDead())
{
activeOwner.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SOULSHOTS_AND_SPIRITSHOTS_ARE_NOT_AVAILABLE_FOR_A_DEAD_PET));
return;
}
int itemId = item.getItemId();
boolean isBlessed = (itemId == 6647 || itemId == 20334);
short shotConsumption = activePet.getSpiritShotsPerHit();
long shotCount = item.getCount();
if (!(shotCount > shotConsumption))
{
// Not enough SpiritShots to use.
if (!activeOwner.disableAutoShot(itemId))
activeOwner.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_SPIRITHOTS_FOR_PET));
return;
}
L2ItemInstance weaponInst = null;
if (activePet instanceof L2PetInstance)
weaponInst = ((L2PetInstance) activePet).getActiveWeaponInstance();
if (weaponInst == null)
{
if (activePet.getChargedSpiritShot() != L2ItemInstance.CHARGED_NONE)
return;
if (isBlessed)
activePet.setChargedSpiritShot(L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT);
else
activePet.setChargedSpiritShot(L2ItemInstance.CHARGED_SPIRITSHOT);
}
else
{
if (weaponInst.getChargedSpiritshot() != L2ItemInstance.CHARGED_NONE)
{
// SpiritShots are already active.
return;
}
if (isBlessed)
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT);
else
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_SPIRITSHOT);
}
if (!activeOwner.destroyItemWithoutTrace("Consume", item.getObjectId(), shotConsumption, null, false))
{
if (!activeOwner.disableAutoShot(itemId))
activeOwner.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_SPIRITHOTS_FOR_PET));
return;
}
// Pet uses the power of spirit.
activeOwner.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.PET_USE_SPIRITSHOT));
int skillId = 0;
switch (itemId)
{
case 6646:
skillId = 2008;
break;
case 6647:
skillId = 2009;
break;
case 20333:
skillId = 22037;
break;
case 20334:
skillId = 22038;
break;
}
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(activePet, activePet, skillId, 1, 0, 0), 360000/*600*/);
}
}
@@ -0,0 +1,159 @@
/*
* 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.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.item.L2Item;
import com.l2jserver.gameserver.templates.item.L2Weapon;
import com.l2jserver.gameserver.util.Broadcast;
/**
* This class ...
*
* @version $Revision: 1.1.2.1.2.5 $ $Date: 2005/03/27 15:30:07 $
*/
public class BlessedSpiritShot implements IItemHandler
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public synchronized void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
L2PcInstance activeChar = (L2PcInstance) playable;
L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
L2Weapon weaponItem = activeChar.getActiveWeaponItem();
int itemId = item.getItemId();
// Check if Blessed SpiritShot can be used
if (weaponInst == null || weaponItem == null || weaponItem.getSpiritShotCount() == 0)
{
if (!activeChar.getAutoSoulShot().contains(itemId))
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_USE_SPIRITSHOTS));
return;
}
// Check if Blessed SpiritShot is already active (it can be charged over SpiritShot)
if (weaponInst.getChargedSpiritshot() != L2ItemInstance.CHARGED_NONE)
return;
// Check for correct grade
final int weaponGrade = weaponItem.getCrystalType();
boolean gradeCheck = true;
switch (weaponGrade)
{
case L2Item.CRYSTAL_NONE:
if (itemId != 3947)
gradeCheck = false;
break;
case L2Item.CRYSTAL_D:
if (itemId != 3948 && itemId != 22072)
gradeCheck = false;
break;
case L2Item.CRYSTAL_C:
if (itemId != 3949 && itemId != 22073)
gradeCheck = false;
break;
case L2Item.CRYSTAL_B:
if (itemId != 3950 && itemId != 22074)
gradeCheck = false;
break;
case L2Item.CRYSTAL_A:
if (itemId != 3951 && itemId != 22075)
gradeCheck = false;
break;
case L2Item.CRYSTAL_S:
case L2Item.CRYSTAL_S80:
case L2Item.CRYSTAL_S84:
if (itemId != 3952 && itemId != 22076)
gradeCheck = false;
break;
}
if (!gradeCheck)
{
if (!activeChar.getAutoSoulShot().contains(itemId))
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SPIRITSHOTS_GRADE_MISMATCH));
return;
}
// 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(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_SPIRITSHOTS));
return;
}
// Charge Blessed SpiritShot
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT);
// Send message to client
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ENABLED_SPIRITSHOT));
int skillId = 0;
switch (itemId)
{
case 3947:
skillId=2061;
break;
case 3948:
skillId=2160;
break;
case 3949:
skillId=2161;
break;
case 3950:
skillId=2162;
break;
case 3951:
skillId=2163;
break;
case 3952:
skillId=2164;
break;
case 22072:
skillId=26050;
break;
case 22073:
skillId=26051;
break;
case 22074:
skillId=26052;
break;
case 22075:
skillId=26053;
break;
case 22076:
skillId=26054;
break;
}
Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, skillId, 1, 0, 0), 360000);
}
}
@@ -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.cache.HtmCache;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
public class Book implements IItemHandler
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
L2PcInstance activeChar = (L2PcInstance) playable;
final int itemId = item.getItemId();
String filename = "data/html/help/" + itemId + ".htm";
String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), filename);
if (content == null)
{
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setHtml("<html><body>My Text is missing:<br>" + filename + "</body></html>");
activeChar.sendPacket(html);
}
else
{
NpcHtmlMessage itemReply = new NpcHtmlMessage(5, itemId);
itemReply.setHtml(content);
itemReply.disableValidation();
activeChar.sendPacket(itemReply);
}
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
}
}
@@ -0,0 +1,71 @@
/*
* 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.datatables.NpcTable;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Spawn;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;
public class ChristmasTree implements IItemHandler
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
L2PcInstance activeChar = (L2PcInstance) playable;
L2NpcTemplate template1 = null;
switch (item.getItemId())
{
case 5560:
template1 = NpcTable.getInstance().getTemplate(13006);
break;
case 5561:
template1 = NpcTable.getInstance().getTemplate(13007);
break;
}
if (template1 == null)
return;
L2Object target = activeChar.getTarget();
if (target == null)
target = activeChar;
try
{
L2Spawn spawn = new L2Spawn(template1);
spawn.setLocx(target.getX());
spawn.setLocy(target.getY());
spawn.setLocz(target.getZ());
spawn.spawnOne(false);
activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false);
activeChar.sendMessage("Created " + template1.name + " at x: " + spawn.getLocx() + " y: " + spawn.getLocy() + " z: " + spawn.getLocz());
}
catch (Exception e)
{
activeChar.sendMessage("Target is not ingame.");
}
}
}
@@ -0,0 +1,67 @@
/*
* 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.instancemanager.TerritoryWarManager;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
/**
* This class provides handling for items that should display a map
* when double clicked.
*
* @version $Revision: 1.1.4.3 $ $Date: 2005/03/27 15:30:07 $
*/
public class Disguise implements IItemHandler
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
L2PcInstance activeChar = (L2PcInstance) playable;
int regId = TerritoryWarManager.getInstance().getRegisteredTerritoryId(activeChar);
if (regId > 0 && regId == (item.getItemId() - 13596))
{
if (activeChar.getClan() != null && activeChar.getClan().getHasCastle() > 0)
{
activeChar.sendPacket(SystemMessageId.TERRITORY_OWNING_CLAN_CANNOT_USE_DISGUISE_SCROLL);
return;
}
TerritoryWarManager.getInstance().addDisguisedPlayer(activeChar.getObjectId());
activeChar.broadcastUserInfo();
playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
}
else if (regId > 0)
{
activeChar.sendPacket(SystemMessageId.THE_DISGUISE_SCROLL_MEANT_FOR_DIFFERENT_TERRITORY);
return;
}
else
{
activeChar.sendPacket(SystemMessageId.TERRITORY_WAR_SCROLL_CAN_NOT_USED_NOW);
return;
}
}
}
@@ -0,0 +1,39 @@
/*
* 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.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
public class Elixir extends ItemSkills
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
@Override
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
{
playable.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ITEM_NOT_FOR_PETS));
return;
}
super.useItem(playable, item, forceUse);
}
}
@@ -0,0 +1,45 @@
/*
* 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.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExChooseInventoryAttributeItem;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
public class EnchantAttribute implements IItemHandler
{
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
final L2PcInstance activeChar = (L2PcInstance) playable;
if (activeChar.isCastingNow())
return;
if (activeChar.isEnchanting())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ENCHANTMENT_ALREADY_IN_PROGRESS));
return;
}
activeChar.setActiveEnchantAttrItem(item);
activeChar.sendPacket(new ExChooseInventoryAttributeItem(item));
}
}
@@ -0,0 +1,49 @@
/*
* 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.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ChooseInventoryItem;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
public class EnchantScrolls implements IItemHandler
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
final L2PcInstance activeChar = (L2PcInstance) playable;
if (activeChar.isCastingNow())
return;
if (activeChar.isEnchanting())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ENCHANTMENT_ALREADY_IN_PROGRESS));
return;
}
activeChar.setActiveEnchantItem(item);
activeChar.sendPacket(new ChooseInventoryItem(item.getItemId()));
}
}
@@ -0,0 +1,49 @@
/*
* 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.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2AirShipInstance;
import com.l2jserver.gameserver.model.actor.instance.L2ControllableAirShipInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
public class EnergyStarStone extends ItemSkills
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
@Override
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
final L2AirShipInstance ship = ((L2PcInstance)playable).getAirShip();
if (ship == null
|| !(ship instanceof L2ControllableAirShipInstance)
|| ship.getFuel() >= ship.getMaxFuel())
{
playable.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED).addItemName(item));
playable.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
super.useItem(playable, item, forceUse);
}
}
@@ -0,0 +1,83 @@
/**
*
*/
package handlers.itemhandlers;
import java.util.logging.Logger;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.instancemanager.HandysBlockCheckerManager;
import com.l2jserver.gameserver.instancemanager.HandysBlockCheckerManager.ArenaParticipantsHolder;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Skill;
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.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
public class EventItem implements IItemHandler
{
private static final Logger _log = Logger.getLogger(EventItem.class.getName());
/* (non-Javadoc)
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
@Override
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if(!(playable instanceof L2PcInstance))
return;
final L2PcInstance activeChar = (L2PcInstance)playable;
final int itemId = item.getItemId();
switch(itemId)
{
case 13787: // Handy's Block Checker Bond
useBlockCheckerItem(activeChar, item);
break;
case 13788: // Handy's Block Checker Land Mine
useBlockCheckerItem(activeChar, item);
break;
default:
_log.warning("EventItemHandler: Item with id: "+itemId+" is not handled");
}
}
private final void useBlockCheckerItem(final L2PcInstance castor, L2ItemInstance item)
{
final int blockCheckerArena = castor.getBlockCheckerArena();
if(blockCheckerArena == -1)
{
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
msg.addItemName(item);
castor.sendPacket(msg);
return;
}
final L2Skill sk = item.getEtcItem().getSkills()[0].getSkill();
if(sk == null)
return;
if(!castor.destroyItem("Consume", item, 1, castor, true))
return;
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.getEffects(castor, pc);
}
}
else
_log.warning("Char: "+castor.getName()+"["+castor.getObjectId()+"] has unknown block checker arena");
}
}
@@ -0,0 +1,97 @@
/*
* 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.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.L2ExtractableProduct;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.item.L2EtcItem;
import com.l2jserver.util.Rnd;
/**
*
* @author FBIagent 11/12/2006
*
*/
public class ExtractableItems implements IItemHandler
{
private static Logger _log = Logger.getLogger(ItemTable.class.getName());
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
L2PcInstance activeChar = (L2PcInstance) playable;
int itemID = item.getItemId();
L2EtcItem etcitem = (L2EtcItem) item.getItem();
List<L2ExtractableProduct> exitem = etcitem.getExtractableItems();
if (exitem == null)
{
_log.info("No extractable data defined for "+etcitem);
return;
}
//destroy item
if (!activeChar.destroyItem("Extract", item.getObjectId(), 1, activeChar, true))
return;
boolean created= false;
// calculate extraction
for (L2ExtractableProduct expi : exitem)
{
if (Rnd.get(100000) <= expi.getChance())
{
int min = expi.getMin();
int max = expi.getMax();
int createItemID = expi.getId();
if ((itemID >= 6411 && itemID <= 6518) || (itemID >= 7726 && itemID <= 7860) || (itemID >= 8403 && itemID <= 8483))
{
min *= Config.RATE_EXTR_FISH;
max *= Config.RATE_EXTR_FISH;
}
int createitemAmount = 0;
if (max == min)
createitemAmount = min;
else
createitemAmount = Rnd.get(max-min+1) + min;
activeChar.addItem("Extract", createItemID, createitemAmount, activeChar, true);
created = true;
}
}
if (!created)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOTHING_INSIDE_THAT));
}
}
}
@@ -0,0 +1,84 @@
/*
* 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.L2ItemInstance;
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.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.item.L2Item;
import com.l2jserver.gameserver.templates.item.L2Weapon;
import com.l2jserver.gameserver.templates.item.L2WeaponType;
import com.l2jserver.gameserver.util.Broadcast;
/**
* @author -Nemesiss-
*
*/
public class FishShots implements IItemHandler
{
private static final int[] SKILL_IDS =
{
2181, 2182, 2183, 2184, 2185, 2186
};
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
L2PcInstance activeChar = (L2PcInstance) playable;
L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
L2Weapon weaponItem = activeChar.getActiveWeaponItem();
if (weaponInst == null || weaponItem.getItemType() != L2WeaponType.FISHINGROD)
return;
if (weaponInst.getChargedFishshot())
// spirit shot is already active
return;
int FishshotId = item.getItemId();
int grade = weaponItem.getCrystalType();
long count = item.getCount();
if ((grade == L2Item.CRYSTAL_NONE && FishshotId != 6535) || (grade == L2Item.CRYSTAL_D && FishshotId != 6536) || (grade == L2Item.CRYSTAL_C && FishshotId != 6537) || (grade == L2Item.CRYSTAL_B && FishshotId != 6538)
|| (grade == L2Item.CRYSTAL_A && FishshotId != 6539) || (FishshotId != 6540 && grade == L2Item.CRYSTAL_S ))
{
//1479 - This fishing shot is not fit for the fishing pole crystal.
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.WRONG_FISHINGSHOT_GRADE));
return;
}
if (count < 1)
return;
weaponInst.setChargedFishshot(true);
activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), 1, null, false);
L2Object oldTarget = activeChar.getTarget();
activeChar.setTarget(activeChar);
Broadcast.toSelfAndKnownPlayers(activeChar, new MagicSkillUse(activeChar, SKILL_IDS[grade], 1, 0, 0));
activeChar.setTarget(oldTarget);
}
}
@@ -0,0 +1,70 @@
/*
* 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.datatables.SkillTable;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.instancemanager.CastleManorManager;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* @author l3x
*/
public class Harvester implements IItemHandler
{
L2PcInstance _activeChar;
L2MonsterInstance _target;
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public void useItem(L2Playable playable, L2ItemInstance _item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
if (CastleManorManager.getInstance().isDisabled())
return;
_activeChar = (L2PcInstance) playable;
if (!(_activeChar.getTarget() instanceof L2MonsterInstance))
{
_activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
_activeChar.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
_target = (L2MonsterInstance) _activeChar.getTarget();
if (_target == null || !_target.isDead())
{
_activeChar.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
L2Skill skill = SkillTable.getInstance().getInfo(2098, 1); //harvesting skill
if (skill != null)
_activeChar.useMagic(skill, false, false);
}
}
@@ -0,0 +1,44 @@
/*
* 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.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* Item skills not allowed on olympiad
*/
public class ItemSkills extends ItemSkillsTemplate
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
@Override
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
final L2PcInstance activeChar = playable.getActingPlayer();
if (activeChar != null && activeChar.isInOlympiadMode())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT));
return;
}
super.useItem(playable, item, forceUse);
}
}
@@ -0,0 +1,242 @@
/*
* 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 javolution.util.FastMap;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2SummonInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance.TimeStamp;
import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
import com.l2jserver.gameserver.model.entity.TvTEvent;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.ExUseSharedGroupItem;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.skills.SkillHolder;
import com.l2jserver.gameserver.templates.item.L2EtcItemType;
/**
* Template for item skills handler
* Only minimum of checks
*/
public class ItemSkillsTemplate implements IItemHandler
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
L2PcInstance activeChar;
boolean isPet = playable instanceof L2PetInstance;
if (isPet)
activeChar = ((L2PetInstance) playable).getOwner();
else if (playable instanceof L2PcInstance)
activeChar = (L2PcInstance) playable;
else
return;
if (!TvTEvent.onScrollUse(playable.getObjectId()))
{
playable.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// pets can use items only when they are tradeable
if (isPet && !item.isTradeable())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ITEM_NOT_FOR_PETS));
return;
}
int skillId;
int skillLvl;
final SkillHolder[] skills = item.getEtcItem().getSkills();
if (skills != null)
{
for (SkillHolder skillInfo : skills)
{
if(skillInfo == null)
continue;
skillId = skillInfo.getSkillId();
skillLvl = skillInfo.getSkillLvl();
L2Skill itemSkill = skillInfo.getSkill();
if (itemSkill != null)
{
if (!itemSkill.checkCondition(playable, playable.getTarget(), false))
return;
if (playable.isSkillDisabled(itemSkill))
{
reuse(activeChar,itemSkill, item);
return ;
}
if (!itemSkill.isPotion() && playable.isCastingNow())
{
return;
}
if (itemSkill.getItemConsumeId() == 0 && itemSkill.getItemConsume() > 0 && (itemSkill.isPotion() || itemSkill.isSimultaneousCast()))
{
if (!playable.destroyItem("Consume", item.getObjectId(), itemSkill.getItemConsume(), null, false))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
return;
}
}
// send message to owner
if (isPet)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.PET_USES_S1);
sm.addString(itemSkill.getName());
activeChar.sendPacket(sm);
}
else
{
switch (skillId)
{
// short buff icon for healing potions
case 2031:
case 2032:
case 2037:
case 26025:
case 26026:
int buffId = activeChar._shortBuffTaskSkillId;
// greater healing potions
if (skillId == 2037 || skillId == 26025)
activeChar.shortBuffStatusUpdate(skillId, skillLvl, itemSkill.getBuffDuration()/1000);
// healing potions
else if ((skillId == 2032 || skillId == 26026) && buffId !=2037 && buffId != 26025)
activeChar.shortBuffStatusUpdate(skillId, skillLvl, itemSkill.getBuffDuration()/1000);
// lesser healing potions
else
{
if (buffId != 2037 && buffId != 26025 && buffId != 2032 && buffId != 26026)
activeChar.shortBuffStatusUpdate(skillId, skillLvl, itemSkill.getBuffDuration()/1000);
}
break;
}
}
if (itemSkill.isPotion() || itemSkill.isSimultaneousCast())
{
playable.doSimultaneousCast(itemSkill);
// Summons should be affected by herbs too, self time effect is handled at L2Effect constructor
if (!isPet && item.getItemType() == L2EtcItemType.HERB
&& activeChar.getPet() != null
&& activeChar.getPet() instanceof L2SummonInstance)
activeChar.getPet().doSimultaneousCast(itemSkill);
}
else
{
playable.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
if (!playable.useMagic(itemSkill, forceUse, false))
return;
//consume
if (itemSkill.getItemConsumeId() == 0 && itemSkill.getItemConsume() > 0)
{
if (!playable.destroyItem("Consume", item.getObjectId(), itemSkill.getItemConsume(), null, false))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
return;
}
}
}
if (itemSkill.getReuseDelay() > 0)
{
activeChar.addTimeStamp(itemSkill, itemSkill.getReuseDelay());
//activeChar.disableSkill(itemSkill, itemSkill.getReuseDelay());
if (item.isEtcItem())
{
final int group = item.getEtcItem().getSharedReuseGroup();
if (group >= 0)
activeChar.sendPacket(new ExUseSharedGroupItem(item.getItemId(), group, itemSkill.getReuseDelay(), itemSkill.getReuseDelay()));
}
}
}
}
}
else
_log.info("Item "+ item + " does not have registered any skill for handler.");
}
private void reuse(L2PcInstance player,L2Skill skill, L2ItemInstance item)
{
SystemMessage sm = null;
final FastMap<Integer, TimeStamp> timeStamp = player.getReuseTimeStamp();
if (timeStamp != null && timeStamp.containsKey(skill.getReuseHashCode()))
{
final long remainingTime = player.getReuseTimeStamp().get(skill.getReuseHashCode()).getRemaining();
final int hours = (int)(remainingTime / 3600000L);
final int minutes = (int)(remainingTime % 3600000L) / 60000;
final int seconds = (int)(remainingTime / 1000 % 60);
if (hours > 0)
{
sm = SystemMessage.getSystemMessage(SystemMessageId.S2_HOURS_S3_MINUTES_S4_SECONDS_REMAINING_FOR_REUSE_S1);
if (skill.isPotion())
sm.addItemName(item);
else
sm.addSkillName(skill);
sm.addNumber(hours);
sm.addNumber(minutes);
}
else if (minutes > 0)
{
sm = SystemMessage.getSystemMessage(SystemMessageId.S2_MINUTES_S3_SECONDS_REMAINING_FOR_REUSE_S1);
if (skill.isPotion())
sm.addItemName(item);
else
sm.addSkillName(skill);
sm.addNumber(minutes);
}
else
{
sm = SystemMessage.getSystemMessage(SystemMessageId.S2_SECONDS_REMAINING_FOR_REUSE_S1);
if (skill.isPotion())
sm.addItemName(item);
else
sm.addSkillName(skill);
}
sm.addNumber(seconds);
if (item.isEtcItem())
{
final int group = item.getEtcItem().getSharedReuseGroup();
if (group >= 0)
player.sendPacket(new ExUseSharedGroupItem(item.getItemId(), group, (int)remainingTime, skill.getReuseDelay()));
}
}
else
{
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_PREPARED_FOR_REUSE);
sm.addItemName(item);
}
player.sendPacket(sm);
}
}
@@ -0,0 +1,39 @@
/*
* 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.Config;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
public class ManaPotion extends ItemSkills
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
@Override
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!Config.L2JMOD_ENABLE_MANA_POTIONS_SUPPORT)
{
playable.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOTHING_HAPPENED));
return;
}
super.useItem(playable, item, forceUse);
}
}
@@ -0,0 +1,43 @@
/*
* 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.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.ShowMiniMap;
/**
* This class provides handling for items that should display a map
* when double clicked.
*
* @version $Revision: 1.1.4.3 $ $Date: 2005/03/27 15:30:07 $
*/
public class Maps implements IItemHandler
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
playable.sendPacket(new ShowMiniMap(item.getItemId()));
}
}
@@ -0,0 +1,121 @@
/*
* 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.SevenSigns;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.instancemanager.MercTicketManager;
import com.l2jserver.gameserver.model.L2ItemInstance;
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.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
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
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
int itemId = item.getItemId();
L2PcInstance activeChar = (L2PcInstance) playable;
Castle castle = CastleManager.getInstance().getCastle(activeChar);
int castleId = -1;
if (castle != null)
castleId = castle.getCastleId();
//add check that certain tickets can only be placed in certain castles
if (MercTicketManager.getInstance().getTicketCastleId(itemId) != castleId)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.MERCENARIES_CANNOT_BE_POSITIONED_HERE));
return;
}
if (!activeChar.isCastleLord(castleId))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_DO_NOT_HAVE_AUTHORITY_TO_POSITION_MERCENARIES));
return;
}
if (castle.getSiege().getIsInProgress())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_MERCENARY_CANNOT_BE_POSITIONED_ANYMORE));
return;
}
//Checking Seven Signs Quest Period
if (SevenSigns.getInstance().getCurrentPeriod() != SevenSigns.PERIOD_SEAL_VALIDATION)
{
//_log.warning("Someone has tried to spawn a guardian during Quest Event Period of The Seven Signs.");
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_MERCENARY_CANNOT_BE_POSITIONED_ANYMORE));
return;
}
//Checking the Seal of Strife status
switch (SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE))
{
case SevenSigns.CABAL_NULL:
if (SevenSigns.getInstance().checkIsDawnPostingTicket(itemId))
{
//_log.warning("Someone has tried to spawn a Dawn Mercenary though the Seal of Strife is not controlled by anyone.");
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_MERCENARY_CANNOT_BE_POSITIONED_ANYMORE));
return;
}
break;
case SevenSigns.CABAL_DUSK:
if (!SevenSigns.getInstance().checkIsRookiePostingTicket(itemId))
{
//_log.warning("Someone has tried to spawn a non-Rookie Mercenary though the Seal of Strife is controlled by Revolutionaries of Dusk.");
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_MERCENARY_CANNOT_BE_POSITIONED_ANYMORE));
return;
}
break;
case SevenSigns.CABAL_DAWN:
break;
}
if(MercTicketManager.getInstance().isAtCasleLimit(item.getItemId()))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_MERCENARY_CANNOT_BE_POSITIONED_ANYMORE));
return;
}
if (MercTicketManager.getInstance().isAtTypeLimit(item.getItemId()))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_MERCENARY_CANNOT_BE_POSITIONED_ANYMORE));
return;
}
if (MercTicketManager.getInstance().isTooCloseToAnotherTicket(activeChar.getX(), activeChar.getY(), activeChar.getZ()))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.POSITIONING_CANNOT_BE_DONE_BECAUSE_DISTANCE_BETWEEN_MERCENARIES_TOO_SHORT));
return;
}
MercTicketManager.getInstance().addTicket(item.getItemId(), activeChar, null);
activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false); // Remove item from char's inventory
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.PLACE_CURRENT_LOCATION_DIRECTION).addItemName(item));
}
}
@@ -0,0 +1,31 @@
/*
* 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.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.ExRequestChangeNicknameColor;
public class NicknameColor implements IItemHandler
{
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
playable.sendPacket(new ExRequestChangeNicknameColor(item.getObjectId()));
}
}
@@ -0,0 +1,131 @@
/*
* 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.datatables.DoorTable;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.instancemanager.InstanceManager;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* @author chris
*/
public class PaganKeys implements IItemHandler
{
public static final int INTERACTION_DISTANCE = 100;
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
int itemId = item.getItemId();
if (!(playable instanceof L2PcInstance))
return;
L2PcInstance activeChar = (L2PcInstance) playable;
L2Object target = activeChar.getTarget();
if (!(target instanceof L2DoorInstance))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
L2DoorInstance door = (L2DoorInstance) target;
if (!(activeChar.isInsideRadius(door, INTERACTION_DISTANCE, false, false)))
{
activeChar.sendMessage("Too far.");
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (activeChar.getAbnormalEffect() > 0 || activeChar.isInCombat())
{
activeChar.sendMessage("You cannot use the key now.");
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (!playable.destroyItem("Consume", item.getObjectId(), 1, null, false))
return;
switch (itemId)
{
case 9698:
if (door.getDoorId() == 24220020)
{
if (activeChar.getInstanceId() != door.getInstanceId())
{
for (L2DoorInstance instanceDoor : InstanceManager.getInstance().getInstance(activeChar.getInstanceId()).getDoors())
if (instanceDoor.getDoorId() == door.getDoorId())
{
instanceDoor.openMe();
}
}
else
{
door.openMe();
}
}
else
{
activeChar.sendMessage("Incorrect Door.");
}
break;
case 9699:
if (door.getDoorId() == 24220022)
{
if (activeChar.getInstanceId() != door.getInstanceId())
{
for (L2DoorInstance instanceDoor : InstanceManager.getInstance().getInstance(activeChar.getInstanceId()).getDoors())
if (instanceDoor.getDoorId() == door.getDoorId())
{
instanceDoor.openMe();
}
}
else
{
door.openMe();
}
}
else
{
activeChar.sendMessage("Incorrect Door.");
}
break;
case 8056:
if (door.getDoorId() == 23150004||door.getDoorId() == 23150003)
{
DoorTable.getInstance().getDoor(23150003).openMe();
DoorTable.getInstance().getDoor(23150003).onOpen();
DoorTable.getInstance().getDoor(23150004).openMe();
DoorTable.getInstance().getDoor(23150004).onOpen();
}
else
{
activeChar.sendMessage("Incorrect Door.");
}
break;
}
}
}
@@ -0,0 +1,128 @@
/*
* 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.Config;
import com.l2jserver.gameserver.datatables.PetDataTable;
import com.l2jserver.gameserver.datatables.SkillTable;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Skill;
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.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.util.Util;
/**
* @author Kerberos, Zoey76
*/
public class PetFood implements IItemHandler
{
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
int itemId = item.getItemId();
switch (itemId)
{
case 2515: //Food For Wolves
useFood(playable, 2048, item);
break;
case 4038: //Food For Hatchling
useFood(playable, 2063, item);
break;
case 5168: //Food for Strider
useFood(playable, 2101, item);
break;
case 5169: //Deluxe Food for Strider
useFood(playable, 2102, item);
break;
case 6316: //Food for Wyvern
useFood(playable, 2180, item);
break;
case 7582: //Baby Spice
useFood(playable, 2048, item);
break;
case 9668: //Great Wolf Food
useFood(playable, 2361, item);
break;
case 10425: //Improved Baby Pet Food
useFood(playable, 2361, item);
break;
case 14818: //Enriched Pet Food for Wolves
useFood(playable, 2916, item);
break;
default:
_log.warning("Pet Food Id: " + itemId + " without handler!");
break;
}
}
public boolean useFood(L2Playable activeChar, int magicId, L2ItemInstance item)
{
L2Skill skill = SkillTable.getInstance().getInfo(magicId, 1);
if (skill != null)
{
if (activeChar instanceof L2PetInstance)
{
if (((L2PetInstance) activeChar).destroyItem("Consume", item.getObjectId(), 1, null, false))
{
activeChar.broadcastPacket(new MagicSkillUse(activeChar, activeChar, magicId, 1, 0, 0));
((L2PetInstance) activeChar).setCurrentFed(((L2PetInstance) activeChar).getCurrentFed() + (skill.getFeed() * Config.PET_FOOD_RATE));
((L2PetInstance) activeChar).broadcastStatusUpdate();
if (((L2PetInstance) activeChar).getCurrentFed() < (((L2PetInstance) activeChar).getPetData().getHungry_limit() / 100f * ((L2PetInstance) activeChar).getPetLevelData().getPetMaxFeed()))
{
((L2PetInstance) activeChar).getOwner().sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOUR_PET_ATE_A_LITTLE_BUT_IS_STILL_HUNGRY));
}
return true;
}
}
else if (activeChar instanceof L2PcInstance)
{
L2PcInstance player = ((L2PcInstance) activeChar);
int itemId = item.getItemId();
if (player.isMounted())
{
int food[] = PetDataTable.getInstance().getPetData(player.getMountNpcId()).getFood();
if (Util.contains(food, itemId))
{
if (player.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
player.broadcastPacket(new MagicSkillUse(activeChar, activeChar, magicId, 1, 0, 0));
player.setCurrentFeed(player.getCurrentFeed() + skill.getFeed());
}
return true;
}
else
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
sm.addItemName(item);
activeChar.sendPacket(sm);
return false;
}
}
else
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
sm.addItemName(item);
activeChar.sendPacket(sm);
}
return false;
}
}
return false;
}
}
@@ -0,0 +1,104 @@
/*
* 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.RecipeController;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.L2ItemInstance;
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.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* This class ...
*
* @version $Revision: 1.1.2.5.2.5 $ $Date: 2005/04/06 16:13:51 $
*/
public class Recipes implements IItemHandler
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
L2PcInstance activeChar = (L2PcInstance) playable;
L2RecipeList rp = RecipeController.getInstance().getRecipeByItemId(item.getItemId());
if (rp == null)
return;
if (activeChar.hasRecipeList(rp.getId()))
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.RECIPE_ALREADY_REGISTERED));
else
{
if (rp.isDwarvenRecipe())
{
if (activeChar.hasDwarvenCraft())
{
if (rp.getLevel() > activeChar.getDwarvenCraft())
{
//can't add recipe, becouse create item level too low
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CREATE_LVL_TOO_LOW_TO_REGISTER));
}
else if (activeChar.getDwarvenRecipeBook().length >= activeChar.getDwarfRecipeLimit())
{
//Up to $s1 recipes can be registered.
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.UP_TO_S1_RECIPES_CAN_REGISTER);
sm.addNumber(activeChar.getDwarfRecipeLimit());
activeChar.sendPacket(sm);
}
else
{
activeChar.registerDwarvenRecipeList(rp, true);
activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false);
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_ADDED).addItemName(item));
}
}
else
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANT_REGISTER_NO_ABILITY_TO_CRAFT));
}
else
{
if (activeChar.hasCommonCraft())
{
if (rp.getLevel() > activeChar.getCommonCraft())
{
//can't add recipe, becouse create item level too low
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CREATE_LVL_TOO_LOW_TO_REGISTER));
}
else if (activeChar.getCommonRecipeBook().length >= activeChar.getCommonRecipeLimit())
{
//Up to $s1 recipes can be registered.
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.UP_TO_S1_RECIPES_CAN_REGISTER);
sm.addNumber(activeChar.getCommonRecipeLimit());
activeChar.sendPacket(sm);
}
else
{
activeChar.registerCommonRecipeList(rp, true);
activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false);
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_ADDED).addItemName(item));
}
}
else
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANT_REGISTER_NO_ABILITY_TO_CRAFT));
}
}
}
}
@@ -0,0 +1,92 @@
/*
* 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.L2ItemInstance;
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.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;
/**
* This class ...
*
* @version $Revision: 1.1.4.2 $ $Date: 2005/03/27 15:30:07 $
*/
public class RollingDice implements IItemHandler
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
L2PcInstance activeChar = (L2PcInstance) playable;
int itemId = item.getItemId();
if (activeChar.isInOlympiadMode())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT));
return;
}
if (itemId == 4625 || itemId == 4626 || itemId == 4627 || itemId == 4628)
{
int number = rollDice(activeChar);
if (number == 0)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_MAY_NOT_THROW_THE_DICE_AT_THIS_TIME_TRY_AGAIN_LATER));
return;
}
Broadcast.toSelfAndKnownPlayers(activeChar, new Dice(activeChar.getObjectId(), item.getItemId(), number, activeChar.getX() - 30, activeChar.getY() - 30, activeChar.getZ()));
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_ROLLED_S2);
sm.addString(activeChar.getName());
sm.addNumber(number);
activeChar.sendPacket(sm);
if (activeChar.isInsideZone(L2Character.ZONE_PEACE))
Broadcast.toKnownPlayers(activeChar, sm);
else if (activeChar.isInParty())
activeChar.getParty().broadcastToPartyMembers(activeChar, sm);
}
}
/**
*
* @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);
}
}
@@ -0,0 +1,188 @@
/*
* 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.datatables.SkillTable;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Skill;
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.actor.instance.L2PetInstance;
import com.l2jserver.gameserver.model.entity.Castle;
import com.l2jserver.gameserver.model.entity.TvTEvent;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* This class ...
*
* @version $Revision: 1.1.2.2.2.7 $ $Date: 2005/04/05 19:41:13 $
*/
public class ScrollOfResurrection implements IItemHandler
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
L2PcInstance activeChar = (L2PcInstance) playable;
if (!TvTEvent.onScrollUse(playable.getObjectId()))
{
playable.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (activeChar.isSitting())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANT_MOVE_SITTING));
return;
}
if (activeChar.isMovementDisabled())
return;
int itemId = item.getItemId();
//boolean blessedScroll = (itemId != 737);
boolean petScroll = (itemId == 6387);
// SoR Animation section
L2Character target = (L2Character) activeChar.getTarget();
if (target != null && target.isDead())
{
L2PcInstance targetPlayer = null;
if (target instanceof L2PcInstance)
targetPlayer = (L2PcInstance) target;
L2PetInstance targetPet = null;
if (target instanceof L2PetInstance)
targetPet = (L2PetInstance) target;
if (targetPlayer != null || targetPet != null)
{
boolean condGood = true;
//check target is not in a active siege zone
Castle castle = null;
if (targetPlayer != null)
castle = CastleManager.getInstance().getCastle(targetPlayer.getX(), targetPlayer.getY(), targetPlayer.getZ());
else
castle = CastleManager.getInstance().getCastle(targetPet.getOwner().getX(), targetPet.getOwner().getY(), targetPet.getOwner().getZ());
if (castle != null && castle.getSiege().getIsInProgress())
{
condGood = false;
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_BE_RESURRECTED_DURING_SIEGE));
}
if (targetPet != null)
{
if (targetPet.getOwner() != activeChar)
{
if (targetPet.getOwner().isReviveRequested())
{
if (targetPet.getOwner().isRevivingPet())
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.RES_HAS_ALREADY_BEEN_PROPOSED)); // Resurrection is already been proposed.
else
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_RES_PET2)); // A pet cannot be resurrected while it's owner is in the process of resurrecting.
condGood = false;
}
}
}
else
{
if (targetPlayer.isFestivalParticipant()) // Check to see if the current player target is in a festival.
{
condGood = false;
activeChar.sendMessage("You may not resurrect participants in a festival.");
}
if (targetPlayer.isReviveRequested())
{
if (targetPlayer.isRevivingPet())
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.MASTER_CANNOT_RES)); // While a pet is attempting to resurrect, it cannot help in resurrecting its master.
else
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.RES_HAS_ALREADY_BEEN_PROPOSED)); // Resurrection is already been proposed.
condGood = false;
}
else if (petScroll)
{
condGood = false;
activeChar.sendMessage("You do not have the correct scroll");
}
}
if (condGood)
{
if (!activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false))
return;
int skillId = 0;
int skillLevel = 1;
switch (itemId)
{
case 737:
skillId = 2014;
break; // Scroll of Resurrection
case 3936:
skillId = 2049;
break; // Blessed Scroll of Resurrection
case 3959:
skillId = 2062;
break; // L2Day - Blessed Scroll of Resurrection
case 6387:
skillId = 2179;
break; // Blessed Scroll of Resurrection: For Pets
case 9157:
skillId = 2321;
break; // Blessed Scroll of Resurrection Event
case 10150:
skillId = 2393;
break; // Blessed Scroll of Battlefield Resurrection
case 13259:
skillId = 2596;
break; // Gran Kain's Blessed Scroll of Resurrection
}
if (skillId != 0)
{
L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLevel);
activeChar.useMagic(skill, true, true);
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DISAPPEARED);
sm.addItemName(item);
activeChar.sendPacket(sm);
}
}
}
}
else
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
}
}
}
@@ -0,0 +1,109 @@
/*
* 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.datatables.MapRegionTable;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.instancemanager.CastleManorManager;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Manor;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
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.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.skills.SkillHolder;
/**
* @author l3x
*/
public class Seed implements IItemHandler
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
if (CastleManorManager.getInstance().isDisabled())
return;
final L2Object tgt = playable.getTarget();
if (!(tgt instanceof L2Npc))
{
playable.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
playable.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (!(tgt instanceof L2MonsterInstance) || tgt instanceof L2ChestInstance || ((L2Character)tgt).isRaid())
{
playable.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_TARGET_IS_UNAVAILABLE_FOR_SEEDING));
playable.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final L2MonsterInstance target = (L2MonsterInstance)tgt;
if (target.isDead())
{
playable.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
playable.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (target.isSeeded())
{
playable.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final int seedId = item.getItemId();
if (areaValid(seedId, MapRegionTable.getInstance().getAreaCastle(playable)))
{
target.setSeeded(seedId, (L2PcInstance)playable);
final SkillHolder[] skills = item.getEtcItem().getSkills();
if (skills != null)
{
if(skills[0] == null)
return;
L2Skill itemskill = skills[0].getSkill();
((L2PcInstance)playable).useMagic(itemskill, false, false);
}
}
else
playable.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_SEED_MAY_NOT_BE_SOWN_HERE));
}
/**
*
* @param seedId
* @param castleId
* @return
*/
private boolean areaValid(int seedId, int castleId)
{
return (L2Manor.getInstance().getCastleIdForSeed(seedId) == castleId);
}
}
@@ -0,0 +1,41 @@
/*
* 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.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.SSQStatus;
/**
* Item Handler for Seven Signs Record
*
* @author Tempy
*/
public class SevenSignsRecord implements IItemHandler
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
playable.sendPacket(new SSQStatus(playable.getObjectId(), 1));
}
}
@@ -0,0 +1,169 @@
/*
* 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.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.skills.Stats;
import com.l2jserver.gameserver.templates.item.L2Item;
import com.l2jserver.gameserver.templates.item.L2Weapon;
import com.l2jserver.gameserver.util.Broadcast;
/**
* This class ...
*
* @version $Revision: 1.2.4.4 $ $Date: 2005/03/27 15:30:07 $
*/
public class SoulShots implements IItemHandler
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
L2PcInstance activeChar = (L2PcInstance) playable;
L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
L2Weapon weaponItem = activeChar.getActiveWeaponItem();
int itemId = item.getItemId();
// Check if Soul shot can be used
if (weaponInst == null || weaponItem.getSoulShotCount() == 0)
{
if (!activeChar.getAutoSoulShot().contains(itemId))
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_USE_SOULSHOTS));
return;
}
final int weaponGrade = weaponItem.getCrystalType();
boolean gradeCheck = true;
switch (weaponGrade)
{
case L2Item.CRYSTAL_NONE:
if (itemId != 5789 && itemId != 1835)
gradeCheck = false;
break;
case L2Item.CRYSTAL_D:
if (itemId != 1463 && itemId != 22082)
gradeCheck = false;
break;
case L2Item.CRYSTAL_C:
if (itemId != 1464 && itemId != 22083)
gradeCheck = false;
break;
case L2Item.CRYSTAL_B:
if (itemId != 1465 && itemId != 22084)
gradeCheck = false;
break;
case L2Item.CRYSTAL_A:
if (itemId != 1466 && itemId != 22085)
gradeCheck = false;
break;
case L2Item.CRYSTAL_S:
case L2Item.CRYSTAL_S80:
case L2Item.CRYSTAL_S84:
if (itemId != 1467 && itemId != 22086)
gradeCheck = false;
break;
}
if (!gradeCheck)
{
if (!activeChar.getAutoSoulShot().contains(itemId))
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SOULSHOTS_GRADE_MISMATCH));
return;
}
activeChar.soulShotLock.lock();
try
{
// Check if Soul shot is already active
if (weaponInst.getChargedSoulshot() != L2ItemInstance.CHARGED_NONE)
return;
// Consume Soul shots if player has enough of them
int saSSCount = (int) activeChar.getStat().calcStat(Stats.SOULSHOT_COUNT, 0, null, null);
int SSCount = saSSCount == 0 ? weaponItem.getSoulShotCount() : saSSCount;
if (!activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), SSCount, null, false))
{
if (!activeChar.disableAutoShot(itemId))
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_SOULSHOTS));
return;
}
// Charge soul shot
weaponInst.setChargedSoulshot(L2ItemInstance.CHARGED_SOULSHOT);
}
finally
{
activeChar.soulShotLock.unlock();
}
int skillId = 0;
switch (itemId)
{
case 1835:
case 5789:
skillId=2039;
break;
case 1463:
skillId=2150;
break;
case 1464:
skillId=2151;
break;
case 1465:
skillId=2152;
break;
case 1466:
skillId=2153;
break;
case 1467:
skillId=2154;
break;
case 22082:
skillId=26060;
break;
case 22083:
skillId=26061;
break;
case 22084:
skillId=26062;
break;
case 22085:
skillId=26063;
break;
case 22086:
skillId=26064;
break;
}
// Send message to client
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ENABLED_SOULSHOT));
Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, skillId, 1, 0, 0), 360000);
}
}
@@ -0,0 +1,40 @@
/*
* 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.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.ShowXMasSeal;
/**
*
* @author devScarlet & mrTJO
*/
public class SpecialXMas implements IItemHandler
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
playable.broadcastPacket(new ShowXMasSeal(item.getItemId()));
}
}
@@ -0,0 +1,157 @@
/*
* 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.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.item.L2Item;
import com.l2jserver.gameserver.templates.item.L2Weapon;
import com.l2jserver.gameserver.util.Broadcast;
/**
* This class ...
*
* @version $Revision: 1.1.2.1.2.5 $ $Date: 2005/03/27 15:30:07 $
*/
public class SpiritShot implements IItemHandler
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public synchronized void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
L2PcInstance activeChar = (L2PcInstance) playable;
L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
L2Weapon weaponItem = activeChar.getActiveWeaponItem();
int itemId = item.getItemId();
// Check if Spirit shot can be used
if (weaponInst == null || weaponItem.getSpiritShotCount() == 0)
{
if (!activeChar.getAutoSoulShot().contains(itemId))
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_USE_SPIRITSHOTS));
return;
}
// Check if Spirit shot is already active
if (weaponInst.getChargedSpiritshot() != L2ItemInstance.CHARGED_NONE)
return;
final int weaponGrade = weaponItem.getCrystalType();
boolean gradeCheck = true;
switch (weaponGrade)
{
case L2Item.CRYSTAL_NONE:
if (itemId != 5790 && itemId != 2509)
gradeCheck = false;
break;
case L2Item.CRYSTAL_D:
if (itemId != 2510 && itemId != 22077)
gradeCheck = false;
break;
case L2Item.CRYSTAL_C:
if (itemId != 2511 && itemId != 22078)
gradeCheck = false;
break;
case L2Item.CRYSTAL_B:
if (itemId != 2512 && itemId != 22079)
gradeCheck = false;
break;
case L2Item.CRYSTAL_A:
if (itemId != 2513 && itemId != 22080)
gradeCheck = false;
break;
case L2Item.CRYSTAL_S:
case L2Item.CRYSTAL_S80:
case L2Item.CRYSTAL_S84:
if (itemId != 2514 && itemId != 22081)
gradeCheck = false;
break;
}
if (!gradeCheck)
{
if (!activeChar.getAutoSoulShot().contains(itemId))
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SPIRITSHOTS_GRADE_MISMATCH));
return;
}
// 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(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_SPIRITSHOTS));
return;
}
// Charge Spirit shot
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_SPIRITSHOT);
int skillId = 0;
switch (itemId)
{
case 2509:
case 5790:
skillId=2061;
break;
case 2510:
skillId=2155;
break;
case 2511:
skillId=2156;
break;
case 2512:
skillId=2157;
break;
case 2513:
skillId=2158;
break;
case 2514:
skillId=2159;
break;
case 22077:
skillId=26055;
break;
case 22078:
skillId=26056;
break;
case 22079:
skillId=26057;
break;
case 22080:
skillId=26058;
break;
case 22081:
skillId=26059;
break;
}
// Send message to client
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ENABLED_SPIRITSHOT));
Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, skillId, 1, 0, 0), 360000);
}
}
@@ -0,0 +1,274 @@
/*
* 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/>.
*/
/**
*
* @author FBIagent
*
*/
package handlers.itemhandlers;
import java.util.Collection;
import java.util.logging.Level;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.datatables.NpcTable;
import com.l2jserver.gameserver.datatables.SummonItemsData;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Spawn;
import com.l2jserver.gameserver.model.L2SummonItem;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
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.actor.instance.L2XmassTreeInstance;
import com.l2jserver.gameserver.model.entity.TvTEvent;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillLaunched;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jserver.gameserver.network.serverpackets.PetItemList;
import com.l2jserver.gameserver.network.serverpackets.SetupGauge;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;
import com.l2jserver.gameserver.util.Broadcast;
public class SummonItems implements IItemHandler
{
/**
*
* @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
return;
if (!TvTEvent.onItemSummon(playable.getObjectId()))
return;
final L2PcInstance activeChar = (L2PcInstance) playable;
if (!activeChar.getFloodProtectors().getItemPetSummon().tryPerformAction("summon items"))
return;
if (activeChar.isSitting())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANT_MOVE_SITTING));
return;
}
if(activeChar.getBlockCheckerArena() != -1)
return;
if (activeChar.inObserverMode())
return;
if (activeChar.isInOlympiadMode())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT));
return;
}
if (activeChar.isAllSkillsDisabled() || activeChar.isCastingNow())
return;
final L2SummonItem sitem = SummonItemsData.getInstance().getSummonItem(item.getItemId());
if ((activeChar.getPet() != null || activeChar.isMounted()) && sitem.isPetSummon())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_ALREADY_HAVE_A_PET));
return;
}
if (activeChar.isAttackingNow())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CANNOT_SUMMON_IN_COMBAT));
return;
}
if (activeChar.isCursedWeaponEquipped() && sitem.isPetSummon())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.STRIDER_CANT_BE_RIDDEN_WHILE_IN_BATTLE));
return;
}
final int npcId = sitem.getNpcId();
if (npcId == 0)
return;
final L2NpcTemplate npcTemplate = NpcTable.getInstance().getTemplate(npcId);
if (npcTemplate == null)
return;
activeChar.stopMove(null, false);
switch (sitem.getType())
{
case 0: // static summons (like Christmas tree)
try
{
Collection<L2Character> characters = activeChar.getKnownList().getKnownCharactersInRadius(1200);
for (L2Character ch : characters)
{
if (ch instanceof L2XmassTreeInstance && npcTemplate.isSpecialTree())
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.CANNOT_SUMMON_S1_AGAIN);
sm.addCharName(ch);
activeChar.sendPacket(sm);
return;
}
}
if (activeChar.destroyItem("Summon", item.getObjectId(), 1, null, false))
{
final L2Spawn spawn = new L2Spawn(npcTemplate);
spawn.setLocx(activeChar.getX());
spawn.setLocy(activeChar.getY());
spawn.setLocz(activeChar.getZ());
spawn.setInstanceId(activeChar.getInstanceId());
spawn.stopRespawn();
final L2Npc npc = spawn.spawnOne(true);
npc.setTitle(activeChar.getName());
npc.setIsRunning(false); // broadcast info
if (sitem.getDespawnDelay() > 0)
npc.scheduleDespawn(sitem.getDespawnDelay() * 1000L);
}
}
catch (Exception e)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_CANT_FOUND));
}
break;
case 1: // pet summons
final L2Object oldTarget = activeChar.getTarget();
activeChar.setTarget(activeChar);
Broadcast.toSelfAndKnownPlayers(activeChar, new MagicSkillUse(activeChar, 2046, 1, 5000, 0));
activeChar.setTarget(oldTarget);
activeChar.sendPacket(new SetupGauge(0, 5000));
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SUMMON_A_PET));
activeChar.setIsCastingNow(true);
ThreadPoolManager.getInstance().scheduleGeneral(new PetSummonFinalizer(activeChar, npcTemplate, item), 5000);
break;
case 2: // wyvern
activeChar.mount(sitem.getNpcId(), item.getObjectId(), true);
break;
case 3: // Great Wolf
activeChar.mount(sitem.getNpcId(), item.getObjectId(), false);
break;
}
}
static class PetSummonFeedWait implements Runnable
{
private final L2PcInstance _activeChar;
private final L2PetInstance _petSummon;
PetSummonFeedWait(L2PcInstance activeChar, L2PetInstance petSummon)
{
_activeChar = activeChar;
_petSummon = petSummon;
}
public void run()
{
try
{
if (_petSummon.getCurrentFed() <= 0)
_petSummon.unSummon(_activeChar);
else
_petSummon.startFeed();
}
catch (Exception e)
{
_log.log(Level.SEVERE, "", e);
}
}
}
// TODO: this should be inside skill handler
static class PetSummonFinalizer implements Runnable
{
private final L2PcInstance _activeChar;
private final L2ItemInstance _item;
private final L2NpcTemplate _npcTemplate;
PetSummonFinalizer(L2PcInstance activeChar, L2NpcTemplate npcTemplate, L2ItemInstance item)
{
_activeChar = activeChar;
_npcTemplate = npcTemplate;
_item = item;
}
public void run()
{
try
{
_activeChar.sendPacket(new MagicSkillLaunched(_activeChar, 2046, 1));
_activeChar.setIsCastingNow(false);
// check for summon item validity
if (_item == null
|| _item.getOwnerId() != _activeChar.getObjectId()
|| _item.getLocation() != L2ItemInstance.ItemLocation.INVENTORY)
return;
final L2PetInstance petSummon = L2PetInstance.spawnPet(_npcTemplate, _activeChar, _item);
if (petSummon == null)
return;
petSummon.setShowSummonAnimation(true);
petSummon.setTitle(_activeChar.getName());
if (!petSummon.isRespawned())
{
petSummon.setCurrentHp(petSummon.getMaxHp());
petSummon.setCurrentMp(petSummon.getMaxMp());
petSummon.getStat().setExp(petSummon.getExpForThisLevel());
petSummon.setCurrentFed(petSummon.getMaxFed());
}
petSummon.setRunning();
if (!petSummon.isRespawned())
petSummon.store();
_activeChar.setPet(petSummon);
//JIV remove - done on spawn
//L2World.getInstance().storeObject(petSummon);
petSummon.spawnMe(_activeChar.getX() + 50, _activeChar.getY() + 100, _activeChar.getZ());
petSummon.startFeed();
_item.setEnchantLevel(petSummon.getLevel());
if (petSummon.getCurrentFed() <= 0)
ThreadPoolManager.getInstance().scheduleGeneral(new PetSummonFeedWait(_activeChar, petSummon), 60000);
else
petSummon.startFeed();
petSummon.setFollowStatus(true);
petSummon.getOwner().sendPacket(new PetItemList(petSummon));
petSummon.broadcastStatusUpdate();
}
catch (Exception e)
{
_log.log(Level.SEVERE, "", e);
}
}
}
}
@@ -0,0 +1,54 @@
/*
* 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.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* Teleport Bookmark Slot Handler
*
* @author ShanSoft
*/
public class TeleportBookmark implements IItemHandler
{
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (playable == null || item == null || !(playable instanceof L2PcInstance))
return;
L2PcInstance player = (L2PcInstance) playable;
if(player.getBookMarkSlot() >= 9)
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOUR_NUMBER_OF_MY_TELEPORTS_SLOTS_HAS_REACHED_ITS_MAXIMUM_LIMIT));
return;
}
player.destroyItem("Consume", item.getObjectId(), 1, null, false);
player.setBookMarkSlot(player.getBookMarkSlot()+3);
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_NUMBER_OF_MY_TELEPORTS_SLOTS_HAS_BEEN_INCREASED));
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DISAPPEARED);
sm.addItemName(item.getItemId());
player.sendPacket(sm);
}
}