diff --git a/trunk/dist/game/data/scripts/handlers/MasterHandler.java b/trunk/dist/game/data/scripts/handlers/MasterHandler.java index 6ae58ac492..a66ce61d8e 100644 --- a/trunk/dist/game/data/scripts/handlers/MasterHandler.java +++ b/trunk/dist/game/data/scripts/handlers/MasterHandler.java @@ -187,6 +187,7 @@ import handlers.itemhandlers.EnchantAttribute; import handlers.itemhandlers.EnchantScrolls; import handlers.itemhandlers.EventItem; import handlers.itemhandlers.ExtractableItems; +import handlers.itemhandlers.FatedSupportBox; import handlers.itemhandlers.FishShots; import handlers.itemhandlers.Harvester; import handlers.itemhandlers.ItemSkills; @@ -474,6 +475,7 @@ public class MasterHandler EnchantScrolls.class, EventItem.class, ExtractableItems.class, + FatedSupportBox.class, FishShots.class, Harvester.class, ItemSkills.class, diff --git a/trunk/dist/game/data/scripts/handlers/itemhandlers/FatedSupportBox.java b/trunk/dist/game/data/scripts/handlers/itemhandlers/FatedSupportBox.java new file mode 100644 index 0000000000..d2f0f9aa06 --- /dev/null +++ b/trunk/dist/game/data/scripts/handlers/itemhandlers/FatedSupportBox.java @@ -0,0 +1,137 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package handlers.itemhandlers; + +import com.l2jmobius.gameserver.data.xml.impl.CategoryData; +import com.l2jmobius.gameserver.enums.CategoryType; +import com.l2jmobius.gameserver.enums.Race; +import com.l2jmobius.gameserver.handler.IItemHandler; +import com.l2jmobius.gameserver.model.actor.L2Playable; +import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; +import com.l2jmobius.gameserver.model.base.ClassId; +import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance; +import com.l2jmobius.gameserver.network.SystemMessageId; +import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate; +import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; + +/** + * @author Mobius + */ +public class FatedSupportBox implements IItemHandler +{ + // Items + private static final int FATED_BOX_ERTHEIA_WIZARD = 26229; + private static final int FATED_BOX_ERTHEIA_FIGHTER = 26230; + private static final int FATED_BOX_FIGHTER = 37315; + private static final int FATED_BOX_WIZARD = 37316; + private static final int FATED_BOX_WARRIOR = 37317; + private static final int FATED_BOX_ROGUE = 37318; + private static final int FATED_BOX_KAMAEL = 37319; + private static final int FATED_BOX_ORC_FIGHTER = 37320; + private static final int FATED_BOX_ORC_WIZARD = 37321; + + @Override + public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse) + { + if (!playable.isPlayer()) + { + playable.sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_THIS_ITEM); + return false; + } + + final L2PcInstance player = playable.getActingPlayer(); + final Race race = player.getRace(); + final ClassId classId = player.getClassId(); + + // Characters that have gone through their 2nd class transfer/1st liberation will be able to open the Fated Support Box at level 40. + if ((player.getLevel() < 40) || player.isInCategory(CategoryType.FIRST_CLASS_GROUP) || ((race != Race.ERTHEIA) && player.isInCategory(CategoryType.SECOND_CLASS_GROUP))) + { + player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED_DUE_TO_UNSUITABLE_TERMS).addItemName(item)); + return false; + } + + player.getInventory().destroyItem(getClass().getSimpleName(), item, 1, player, null); + player.sendPacket(new InventoryUpdate(item)); + + // It will stay in your inventory after use until you reach level 84. + if (player.getLevel() > 84) + { + player.sendMessage("Fated Support Box was removed because your level has exceeded the maximum requirement."); // custom message + return true; + } + + switch (race) + { + case HUMAN: + case ELF: + case DARK_ELF: + case DWARF: + { + if (player.isMageClass()) + { + player.addItem(getClass().getSimpleName(), FATED_BOX_WIZARD, 1, player, true); + } + else + { + if (CategoryData.getInstance().isInCategory(CategoryType.SUB_GROUP_ROGUE, classId.getId())) + { + player.addItem(getClass().getSimpleName(), FATED_BOX_ROGUE, 1, player, true); + } + else if (CategoryData.getInstance().isInCategory(CategoryType.SUB_GROUP_KNIGHT, classId.getId())) + { + player.addItem(getClass().getSimpleName(), FATED_BOX_FIGHTER, 1, player, true); + } + else + { + player.addItem(getClass().getSimpleName(), FATED_BOX_WARRIOR, 1, player, true); + } + } + break; + } + case ORC: + { + if (player.isMageClass()) + { + player.addItem(getClass().getSimpleName(), FATED_BOX_ORC_WIZARD, 1, player, true); + } + else + { + player.addItem(getClass().getSimpleName(), FATED_BOX_ORC_FIGHTER, 1, player, true); + } + break; + } + case KAMAEL: + { + player.addItem(getClass().getSimpleName(), FATED_BOX_KAMAEL, 1, player, true); + break; + } + case ERTHEIA: + { + if (player.isMageClass()) + { + player.addItem(getClass().getSimpleName(), FATED_BOX_ERTHEIA_WIZARD, 1, player, true); + } + else + { + player.addItem(getClass().getSimpleName(), FATED_BOX_ERTHEIA_FIGHTER, 1, player, true); + } + break; + } + } + return true; + } +} diff --git a/trunk/dist/game/data/stats/items/37300-37399.xml b/trunk/dist/game/data/stats/items/37300-37399.xml index 4212d4854d..2639fcdc39 100644 --- a/trunk/dist/game/data/stats/items/37300-37399.xml +++ b/trunk/dist/game/data/stats/items/37300-37399.xml @@ -443,6 +443,8 @@ + +