Fated Support Box handler.

This commit is contained in:
mobius 2015-01-27 18:24:57 +00:00
parent 66e6975de4
commit bc75c7e9fa
4 changed files with 143 additions and 0 deletions

View File

@ -67,6 +67,10 @@
<id>134</id> <!-- Trickster -->
<id>135</id> <!-- Inspector -->
<id>136</id> <!-- Judicator -->
<id>182</id> <!-- Ertheia Fighter -->
<id>184</id> <!-- Marauder -->
<id>186</id> <!-- Ripper -->
<id>188</id> <!-- Eviscerator -->
</category>
<category name="MAGE_GROUP">
<id>10</id> <!-- Human Mystic -->
@ -106,6 +110,10 @@
<id>112</id> <!-- Shillien Saint -->
<id>115</id> <!-- Dominator -->
<id>116</id> <!-- Doom Cryer -->
<id>183</id> <!-- Ertheia Wizard -->
<id>185</id> <!-- Cloud Breaker -->
<id>187</id> <!-- Stratomancer Hound -->
<id>189</id> <!-- Sayha's Seer -->
</category>
<category name="WIZARD_GROUP">
<id>10</id> <!-- Human Mystic -->

View File

@ -168,6 +168,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.ItemAppearance;
@ -473,6 +474,7 @@ public class MasterHandler
EnchantScrolls.class,
EventItem.class,
ExtractableItems.class,
FatedSupportBox.class,
FishShots.class,
Harvester.class,
ItemAppearance.class,

View File

@ -0,0 +1,128 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import com.l2jserver.gameserver.data.xml.impl.CategoryData;
import com.l2jserver.gameserver.enums.CategoryType;
import com.l2jserver.gameserver.enums.Race;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.base.ClassId;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* @author Mobius
*/
public class FatedSupportBox implements IItemHandler
{
@Override
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!playable.isPlayer())
{
playable.sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_THIS_ITEM);
return false;
}
final L2PcInstance player = playable.getActingPlayer();
final Race race = player.getRace();
final ClassId classId = player.getClassId();
// Characters that have gone through their 2nd class transfer/1st liberation will be able to open the Fated Support Box at level 40.
if ((player.getLevel() < 40) || (classId.level() < (race == Race.ERTHEIA ? 1 : 2)))
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED_DUE_TO_UNSUITABLE_TERMS).addItemName(item));
return false;
}
player.getInventory().destroyItem(getClass().getSimpleName(), item, 1, player, null);
player.sendPacket(new InventoryUpdate(item));
// It will stay in your inventory after use until you reach level 84.
if (player.getLevel() > 84)
{
player.sendMessage("Fated Support Box was removed because your level has exceeded the maximum requirement."); // custom message
return true;
}
switch (race)
{
case HUMAN:
case ELF:
case DARK_ELF:
case DWARF:
{
if (player.isMageClass())
{
player.addItem(getClass().getSimpleName(), 37316, 1, player, true);
}
else
{
if (CategoryData.getInstance().isInCategory(CategoryType.SUB_GROUP_ROGUE, classId.getId()))
{
player.addItem(getClass().getSimpleName(), 37318, 1, player, true);
}
else if (CategoryData.getInstance().isInCategory(CategoryType.SUB_GROUP_KNIGHT, classId.getId()))
{
player.addItem(getClass().getSimpleName(), 37315, 1, player, true);
}
else
{
player.addItem(getClass().getSimpleName(), 37317, 1, player, true);
}
}
break;
}
case ORC:
{
if (player.isMageClass())
{
player.addItem(getClass().getSimpleName(), 37321, 1, player, true);
}
else
{
player.addItem(getClass().getSimpleName(), 37320, 1, player, true);
}
break;
}
case KAMAEL:
{
player.addItem(getClass().getSimpleName(), 37319, 1, player, true);
break;
}
case ERTHEIA:
{
if (player.isMageClass())
{
player.addItem(getClass().getSimpleName(), 26229, 1, player, true);
}
else
{
player.addItem(getClass().getSimpleName(), 26230, 1, player, true);
}
break;
}
}
return true;
}
}

View File

@ -209,6 +209,11 @@
<item id="37314" name="Fated Support Box" additionalName="" type="EtcItem">
<!-- Double-click to receive equipment items for your grade and class. Can be used only by characters Lv. 40-84 who have completed their 1st class transfer. -->
<set name="icon" val="icon.etc_box_of_adventure_1_i00" />
<set name="immediate_effect" val="true" />
<set name="material" val="STEEL" />
<set name="weight" val="0" />
<set name="price" val="0" />
<set name="handler" val="FatedSupportBox" />
</item>
<item id="37315" name="Fated Support Box: Fighter (C-grade)" additionalName="" type="EtcItem">
<!-- Double-click to receive C-grade equipment items necessary for fighter-type characters. Can be used by characters Lv. 40 - 84. -->