Addition of ChangeAttributeCrystal item handler.

This commit is contained in:
MobiusDev 2017-09-11 01:07:26 +00:00
parent 82de3b7a62
commit fe21a7d72b
48 changed files with 1987 additions and 44 deletions

View File

@ -185,6 +185,7 @@ import handlers.itemhandlers.BlessedSpiritShot;
import handlers.itemhandlers.Book;
import handlers.itemhandlers.Bypass;
import handlers.itemhandlers.Calculator;
import handlers.itemhandlers.ChangeAttributeCrystal;
import handlers.itemhandlers.CharmOfCourage;
import handlers.itemhandlers.Elixir;
import handlers.itemhandlers.EnchantAttribute;
@ -523,6 +524,7 @@ public class MasterHandler
Book.class,
Bypass.class,
Calculator.class,
ChangeAttributeCrystal.class,
CharmOfCourage.class,
Elixir.class,
EnchantAttribute.class,

View File

@ -0,0 +1,86 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.l2jmobius.gameserver.enums.ItemGrade;
import com.l2jmobius.gameserver.enums.PrivateStoreType;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.ItemInfo;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.network.serverpackets.attributechange.ExChangeAttributeItemList;
/**
* @author Mobius
*/
public class ChangeAttributeCrystal implements IItemHandler
{
private static final Map<Integer, ItemGrade> ITEM_GRADES = new HashMap<>();
{
ITEM_GRADES.put(33502, ItemGrade.S);
ITEM_GRADES.put(35749, ItemGrade.R);
}
@Override
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!playable.isPlayer())
{
playable.sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_THIS_ITEM);
return false;
}
final L2PcInstance player = playable.getActingPlayer();
if (player.getPrivateStoreType() != PrivateStoreType.NONE)
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CANNOT_CHANGE_AN_ATTRIBUTE_WHILE_USING_A_PRIVATE_STORE_OR_WORKSHOP));
return false;
}
if (ITEM_GRADES.get(item.getId()) == null)
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CHANGING_ATTRIBUTES_HAS_BEEN_FAILED));
return false;
}
final List<ItemInfo> itemList = new ArrayList<>();
for (L2ItemInstance i : player.getInventory().getItems())
{
if (i.isWeapon() && i.hasAttributes() && (i.getItem().getItemGrade() == ITEM_GRADES.get(item.getId())))
{
itemList.add(new ItemInfo(i));
}
}
if (itemList.isEmpty())
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_ITEM_FOR_CHANGING_AN_ATTRIBUTE_DOES_NOT_EXIST));
return false;
}
player.sendPacket(new ExChangeAttributeItemList(item.getId(), itemList.toArray(new ItemInfo[itemList.size()])));
return true;
}
}

View File

@ -42,14 +42,10 @@
<set name="is_commissionable" val="false" />
<set name="is_private_storeable" val="false" />
<set name="is_oly_restricted" val="true" />
<set name="default_action" val="SKILL_REDUCE" />
<set name="etcitem_type" val="CHANGE_ATTR" />
<set name="handler" val="ItemSkills" />
<set name="handler" val="ChangeAttributeCrystal" />
<set name="immediate_effect" val="true" />
<set name="is_stackable" val="true" />
<skills>
<skill id="12881" level="1" /> <!-- Change Attribute -->
</skills>
</item>
<item id="33503" name="Hero's Blessed Buff Scroll" type="EtcItem">
<!-- When used, HP Recovery Bonus, Max MP, and Critical Atk. Rate + 20%, and you can feel the effects of Prophecy of Water, Might, Haste, Empower, Acumen, Wind Walk, Vampiric Rage, Berserker Spirit, Shield, Focus, Death Whisper, Guidance, Clarity, Wild Magic, and Concentration for 1 hour. -->

View File

@ -942,14 +942,10 @@
<set name="is_freightable" val="false" />
<set name="is_sellable" val="false" />
<set name="is_oly_restricted" val="true" />
<set name="default_action" val="SKILL_REDUCE" />
<set name="etcitem_type" val="CHANGE_ATTR" />
<set name="handler" val="ItemSkills" />
<set name="handler" val="ChangeAttributeCrystal" />
<set name="immediate_effect" val="true" />
<set name="commissionItemType" val="OTHER_ITEM" />
<skills>
<skill id="12881" level="1" /> <!-- Change Attribute -->
</skills>
</item>
<item id="35750" name="Draco's Blessing (30-minute)" additionalName="Event" type="EtcItem">
<!-- For 30 minutes, increases XP and SP acquired in hunt by 200% when used by characters level 85 - 90. -->

View File

@ -40,6 +40,9 @@ import com.l2jmobius.gameserver.network.clientpackets.appearance.RequestExCancel
import com.l2jmobius.gameserver.network.clientpackets.appearance.RequestExTryToPutShapeShiftingEnchantSupportItem;
import com.l2jmobius.gameserver.network.clientpackets.appearance.RequestExTryToPutShapeShiftingTargetItem;
import com.l2jmobius.gameserver.network.clientpackets.appearance.RequestShapeShiftingItem;
import com.l2jmobius.gameserver.network.clientpackets.attributechange.RequestChangeAttributeCancel;
import com.l2jmobius.gameserver.network.clientpackets.attributechange.RequestChangeAttributeItem;
import com.l2jmobius.gameserver.network.clientpackets.attributechange.SendChangeAttributeTargetItem;
import com.l2jmobius.gameserver.network.clientpackets.awakening.RequestCallToChangeClass;
import com.l2jmobius.gameserver.network.clientpackets.ceremonyofchaos.RequestCancelCuriousHouse;
import com.l2jmobius.gameserver.network.clientpackets.ceremonyofchaos.RequestCuriousHouseHtml;
@ -256,9 +259,9 @@ public enum ExIncomingPackets implements IIncomingPackets<L2GameClient>
REQUEST_FIRST_PLAY_START(0xAC, null, ConnectionState.IN_GAME),
REQUEST_FLY_MOVE_START(0xAD, RequestFlyMoveStart::new, ConnectionState.IN_GAME),
REQUEST_HARDWARE_INFO(0xAE, RequestHardWareInfo::new, ConnectionState.values()),
SEND_CHANGE_ATTRIBUTE_TARGET_ITEM(0xB0, null, ConnectionState.IN_GAME),
REQUEST_CHANGE_ATTRIBUTE_ITEM(0xB1, null, ConnectionState.IN_GAME),
REQUEST_CHANGE_ATTRIBUTE_CANCEL(0xB2, null, ConnectionState.IN_GAME),
SEND_CHANGE_ATTRIBUTE_TARGET_ITEM(0xB0, SendChangeAttributeTargetItem::new, ConnectionState.IN_GAME),
REQUEST_CHANGE_ATTRIBUTE_ITEM(0xB1, RequestChangeAttributeItem::new, ConnectionState.IN_GAME),
REQUEST_CHANGE_ATTRIBUTE_CANCEL(0xB2, RequestChangeAttributeCancel::new, ConnectionState.IN_GAME),
REQUEST_BR_PRESENT_BUY_PRODUCT(0xB3, null, ConnectionState.IN_GAME),
CONFIRM_MENTEE_ADD(0xB4, ConfirmMenteeAdd::new, ConnectionState.IN_GAME),
REQUEST_MENTOR_CANCEL(0xB5, RequestMentorCancel::new, ConnectionState.IN_GAME),

View File

@ -0,0 +1,46 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.clientpackets.attributechange;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import com.l2jmobius.gameserver.network.serverpackets.attributechange.ExChangeAttributeFail;
/**
* @author Mobius
*/
public class RequestChangeAttributeCancel implements IClientIncomingPacket
{
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(L2GameClient client)
{
final L2PcInstance activeChar = client.getActiveChar();
if (activeChar == null)
{
return;
}
activeChar.sendPacket(ExChangeAttributeFail.STATIC);
}
}

View File

@ -0,0 +1,92 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.clientpackets.attributechange;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.enums.AttributeType;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.itemcontainer.PcInventory;
import com.l2jmobius.gameserver.model.items.enchant.attribute.AttributeHolder;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.network.serverpackets.attributechange.ExChangeAttributeFail;
import com.l2jmobius.gameserver.network.serverpackets.attributechange.ExChangeAttributeOk;
import com.l2jmobius.gameserver.util.Util;
/**
* @author Mobius
*/
public class RequestChangeAttributeItem implements IClientIncomingPacket
{
private int _consumeItemId;
private int _itemObjId;
private int _newElementId;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
_consumeItemId = packet.readD();
_itemObjId = packet.readD();
_newElementId = packet.readD();
return true;
}
@Override
public void run(L2GameClient client)
{
final L2PcInstance activeChar = client.getActiveChar();
if (activeChar == null)
{
return;
}
final PcInventory inventory = activeChar.getInventory();
final L2ItemInstance item = inventory.getItemByObjectId(_itemObjId);
// attempting to destroy item
if (activeChar.getInventory().destroyItemByItemId("ChangeAttribute", _consumeItemId, 1, activeChar, item) == null)
{
client.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT2);
client.sendPacket(ExChangeAttributeFail.STATIC);
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to change attribute without an attribute change crystal.", Config.DEFAULT_PUNISH);
return;
}
// get values
final int oldElementId = item.getAttackAttributeType().getClientId();
final int elementValue = item.getAttackAttribute().getValue();
item.clearAllAttributes();
item.setAttribute(new AttributeHolder(AttributeType.findByClientId(_newElementId), elementValue));
// send packets
final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.S1_S_S2_ATTRIBUTE_HAS_SUCCESSFULLY_CHANGED_TO_S3_ATTRIBUTE);
msg.addItemName(item);
msg.addAttribute(oldElementId);
msg.addAttribute(_newElementId);
activeChar.sendPacket(msg);
InventoryUpdate iu = new InventoryUpdate();
iu.addModifiedItem(item);
activeChar.sendPacket(iu);
activeChar.broadcastUserInfo();
activeChar.sendPacket(ExChangeAttributeOk.STATIC);
}
}

View File

@ -0,0 +1,61 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.clientpackets.attributechange;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import com.l2jmobius.gameserver.network.serverpackets.attributechange.ExChangeAttributeInfo;
/**
* @author Mobius
*/
public class SendChangeAttributeTargetItem implements IClientIncomingPacket
{
private int _crystalItemId;
private int _itemObjId;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
_crystalItemId = packet.readD();
_itemObjId = packet.readD();
return true;
}
@Override
public void run(L2GameClient client)
{
final L2PcInstance activeChar = client.getActiveChar();
if (activeChar == null)
{
return;
}
final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_itemObjId);
if ((item == null) || !item.isWeapon())
{
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
activeChar.sendPacket(new ExChangeAttributeInfo(_crystalItemId, item));
}
}

View File

@ -0,0 +1,40 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.serverpackets.attributechange;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.network.OutgoingPackets;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExChangeAttributeFail implements IClientOutgoingPacket
{
public static final IClientOutgoingPacket STATIC = new ExChangeAttributeFail();
public ExChangeAttributeFail()
{
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_CHANGE_ATTRIBUTE_FAIL.writeId(packet);
return true;
}
}

View File

@ -0,0 +1,69 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.serverpackets.attributechange;
import java.util.HashMap;
import java.util.Map;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.enums.AttributeType;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.OutgoingPackets;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExChangeAttributeInfo implements IClientOutgoingPacket
{
private static final Map<AttributeType, Byte> ATTRIBUTE_MASKS = new HashMap<>();
{
ATTRIBUTE_MASKS.put(AttributeType.FIRE, (byte) 1);
ATTRIBUTE_MASKS.put(AttributeType.WATER, (byte) 2);
ATTRIBUTE_MASKS.put(AttributeType.WIND, (byte) 4);
ATTRIBUTE_MASKS.put(AttributeType.EARTH, (byte) 8);
ATTRIBUTE_MASKS.put(AttributeType.HOLY, (byte) 16);
ATTRIBUTE_MASKS.put(AttributeType.DARK, (byte) 32);
}
private final int _crystalItemId;
private int _attributes;
private int _itemObjId;
public ExChangeAttributeInfo(int crystalItemId, L2ItemInstance item)
{
_crystalItemId = crystalItemId;
_attributes = 0;
for (AttributeType e : AttributeType.ATTRIBUTE_TYPES)
{
if (e != item.getAttackAttributeType())
{
_attributes |= ATTRIBUTE_MASKS.get(e);
}
}
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_CHANGE_ATTRIBUTE_INFO.writeId(packet);
packet.writeD(_crystalItemId);
packet.writeD(_attributes);
packet.writeD(_itemObjId);
return true;
}
}

View File

@ -0,0 +1,50 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.serverpackets.attributechange;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.model.ItemInfo;
import com.l2jmobius.gameserver.network.OutgoingPackets;
import com.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
/**
* @author Mobius
*/
public class ExChangeAttributeItemList extends AbstractItemPacket
{
private final ItemInfo[] _itemsList;
private final int _itemId;
public ExChangeAttributeItemList(int itemId, ItemInfo[] itemsList)
{
_itemId = itemId;
_itemsList = itemsList;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_CHANGE_ATTRIBUTE_ITEM_LIST.writeId(packet);
packet.writeD(_itemId);
packet.writeD(_itemsList.length);
for (ItemInfo item : _itemsList)
{
writeItem(packet, item);
}
return true;
}
}

View File

@ -0,0 +1,40 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.serverpackets.attributechange;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.network.OutgoingPackets;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExChangeAttributeOk implements IClientOutgoingPacket
{
public static final IClientOutgoingPacket STATIC = new ExChangeAttributeOk();
public ExChangeAttributeOk()
{
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_CHANGE_ATTRIBUTE_OK.writeId(packet);
return true;
}
}

View File

@ -186,6 +186,7 @@ import handlers.itemhandlers.BlessedSpiritShot;
import handlers.itemhandlers.Book;
import handlers.itemhandlers.Bypass;
import handlers.itemhandlers.Calculator;
import handlers.itemhandlers.ChangeAttributeCrystal;
import handlers.itemhandlers.CharmOfCourage;
import handlers.itemhandlers.Elixir;
import handlers.itemhandlers.EnchantAttribute;
@ -525,6 +526,7 @@ public class MasterHandler
Book.class,
Bypass.class,
Calculator.class,
ChangeAttributeCrystal.class,
CharmOfCourage.class,
Elixir.class,
EnchantAttribute.class,

View File

@ -0,0 +1,87 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.l2jmobius.gameserver.enums.ItemGrade;
import com.l2jmobius.gameserver.enums.PrivateStoreType;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.ItemInfo;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.network.serverpackets.attributechange.ExChangeAttributeItemList;
/**
* @author Mobius
*/
public class ChangeAttributeCrystal implements IItemHandler
{
private static final Map<Integer, ItemGrade> ITEM_GRADES = new HashMap<>();
{
ITEM_GRADES.put(33502, ItemGrade.S);
ITEM_GRADES.put(35749, ItemGrade.R);
ITEM_GRADES.put(45817, ItemGrade.R);
}
@Override
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!playable.isPlayer())
{
playable.sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_THIS_ITEM);
return false;
}
final L2PcInstance player = playable.getActingPlayer();
if (player.getPrivateStoreType() != PrivateStoreType.NONE)
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CANNOT_CHANGE_AN_ATTRIBUTE_WHILE_USING_A_PRIVATE_STORE_OR_WORKSHOP));
return false;
}
if (ITEM_GRADES.get(item.getId()) == null)
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CHANGING_ATTRIBUTES_HAS_BEEN_FAILED));
return false;
}
final List<ItemInfo> itemList = new ArrayList<>();
for (L2ItemInstance i : player.getInventory().getItems())
{
if (i.isWeapon() && i.hasAttributes() && (i.getItem().getItemGrade() == ITEM_GRADES.get(item.getId())))
{
itemList.add(new ItemInfo(i));
}
}
if (itemList.isEmpty())
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_ITEM_FOR_CHANGING_AN_ATTRIBUTE_DOES_NOT_EXIST));
return false;
}
player.sendPacket(new ExChangeAttributeItemList(item.getId(), itemList.toArray(new ItemInfo[itemList.size()])));
return true;
}
}

View File

@ -42,14 +42,10 @@
<set name="is_commissionable" val="false" />
<set name="is_private_storeable" val="false" />
<set name="is_oly_restricted" val="true" />
<set name="default_action" val="SKILL_REDUCE" />
<set name="etcitem_type" val="CHANGE_ATTR" />
<set name="handler" val="ItemSkills" />
<set name="handler" val="ChangeAttributeCrystal" />
<set name="immediate_effect" val="true" />
<set name="is_stackable" val="true" />
<skills>
<skill id="12881" level="1" /> <!-- Change Attribute -->
</skills>
</item>
<item id="33503" name="Hero's Blessed Buff Scroll" type="EtcItem">
<!-- When used, HP Recovery Bonus, Max MP, and Critical Atk. Rate + 20%, and you can feel the effects of Prophecy of Water, Might, Haste, Empower, Acumen, Wind Walk, Vampiric Rage, Berserker Spirit, Shield, Focus, Death Whisper, Guidance, Clarity, Wild Magic, and Concentration for 1 hour. -->

View File

@ -942,14 +942,10 @@
<set name="is_freightable" val="false" />
<set name="is_sellable" val="false" />
<set name="is_oly_restricted" val="true" />
<set name="default_action" val="SKILL_REDUCE" />
<set name="etcitem_type" val="CHANGE_ATTR" />
<set name="handler" val="ItemSkills" />
<set name="handler" val="ChangeAttributeCrystal" />
<set name="immediate_effect" val="true" />
<set name="commissionItemType" val="OTHER_ITEM" />
<skills>
<skill id="12881" level="1" /> <!-- Change Attribute -->
</skills>
</item>
<item id="35750" name="Draco's Blessing (30-minute)" additionalName="Event" type="EtcItem">
<!-- For 30 minutes, increases XP and SP acquired in hunt by 200% when used by characters level 85 - 90. -->

View File

@ -354,10 +354,14 @@
<item id="45817" name="Weapon Attribute Change Crystal (R-grade)" type="EtcItem">
<!-- Double-click to change the attribute of R, R95, and R99-grade weapons. It can be used when there is an R-grade weapon bestowed in the inventory. -->
<set name="icon" val="icon.change_elemental_crystal" />
<set name="is_stackable" val="true" />
<set name="is_freightable" val="false" />
<set name="is_sellable" val="false" />
<set name="is_oly_restricted" val="true" />
<set name="etcitem_type" val="CHANGE_ATTR" />
<set name="is_stackable" val="true" />
<set name="handler" val="ChangeAttributeCrystal" />
<set name="immediate_effect" val="true" />
<set name="commissionItemType" val="OTHER_ITEM" />
</item>
<item id="45818" name="Player Commendation Points Coupon (360 Points)" type="EtcItem">
<!-- When double-clicked, 360 Player Commendation Points can be acquired. -->

View File

@ -40,6 +40,9 @@ import com.l2jmobius.gameserver.network.clientpackets.appearance.RequestExCancel
import com.l2jmobius.gameserver.network.clientpackets.appearance.RequestExTryToPutShapeShiftingEnchantSupportItem;
import com.l2jmobius.gameserver.network.clientpackets.appearance.RequestExTryToPutShapeShiftingTargetItem;
import com.l2jmobius.gameserver.network.clientpackets.appearance.RequestShapeShiftingItem;
import com.l2jmobius.gameserver.network.clientpackets.attributechange.RequestChangeAttributeCancel;
import com.l2jmobius.gameserver.network.clientpackets.attributechange.RequestChangeAttributeItem;
import com.l2jmobius.gameserver.network.clientpackets.attributechange.SendChangeAttributeTargetItem;
import com.l2jmobius.gameserver.network.clientpackets.awakening.RequestCallToChangeClass;
import com.l2jmobius.gameserver.network.clientpackets.ceremonyofchaos.RequestCancelCuriousHouse;
import com.l2jmobius.gameserver.network.clientpackets.ceremonyofchaos.RequestCuriousHouseHtml;
@ -262,9 +265,9 @@ public enum ExIncomingPackets implements IIncomingPackets<L2GameClient>
REQUEST_FIRST_PLAY_START(0xAC, null, ConnectionState.IN_GAME),
REQUEST_FLY_MOVE_START(0xAD, RequestFlyMoveStart::new, ConnectionState.IN_GAME),
REQUEST_HARDWARE_INFO(0xAE, RequestHardWareInfo::new, ConnectionState.values()),
SEND_CHANGE_ATTRIBUTE_TARGET_ITEM(0xB0, null, ConnectionState.IN_GAME),
REQUEST_CHANGE_ATTRIBUTE_ITEM(0xB1, null, ConnectionState.IN_GAME),
REQUEST_CHANGE_ATTRIBUTE_CANCEL(0xB2, null, ConnectionState.IN_GAME),
SEND_CHANGE_ATTRIBUTE_TARGET_ITEM(0xB0, SendChangeAttributeTargetItem::new, ConnectionState.IN_GAME),
REQUEST_CHANGE_ATTRIBUTE_ITEM(0xB1, RequestChangeAttributeItem::new, ConnectionState.IN_GAME),
REQUEST_CHANGE_ATTRIBUTE_CANCEL(0xB2, RequestChangeAttributeCancel::new, ConnectionState.IN_GAME),
REQUEST_BR_PRESENT_BUY_PRODUCT(0xB3, null, ConnectionState.IN_GAME),
CONFIRM_MENTEE_ADD(0xB4, ConfirmMenteeAdd::new, ConnectionState.IN_GAME),
REQUEST_MENTOR_CANCEL(0xB5, RequestMentorCancel::new, ConnectionState.IN_GAME),

View File

@ -0,0 +1,46 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.clientpackets.attributechange;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import com.l2jmobius.gameserver.network.serverpackets.attributechange.ExChangeAttributeFail;
/**
* @author Mobius
*/
public class RequestChangeAttributeCancel implements IClientIncomingPacket
{
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(L2GameClient client)
{
final L2PcInstance activeChar = client.getActiveChar();
if (activeChar == null)
{
return;
}
activeChar.sendPacket(ExChangeAttributeFail.STATIC);
}
}

View File

@ -0,0 +1,92 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.clientpackets.attributechange;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.enums.AttributeType;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.itemcontainer.PcInventory;
import com.l2jmobius.gameserver.model.items.enchant.attribute.AttributeHolder;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.network.serverpackets.attributechange.ExChangeAttributeFail;
import com.l2jmobius.gameserver.network.serverpackets.attributechange.ExChangeAttributeOk;
import com.l2jmobius.gameserver.util.Util;
/**
* @author Mobius
*/
public class RequestChangeAttributeItem implements IClientIncomingPacket
{
private int _consumeItemId;
private int _itemObjId;
private int _newElementId;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
_consumeItemId = packet.readD();
_itemObjId = packet.readD();
_newElementId = packet.readD();
return true;
}
@Override
public void run(L2GameClient client)
{
final L2PcInstance activeChar = client.getActiveChar();
if (activeChar == null)
{
return;
}
final PcInventory inventory = activeChar.getInventory();
final L2ItemInstance item = inventory.getItemByObjectId(_itemObjId);
// attempting to destroy item
if (activeChar.getInventory().destroyItemByItemId("ChangeAttribute", _consumeItemId, 1, activeChar, item) == null)
{
client.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT2);
client.sendPacket(ExChangeAttributeFail.STATIC);
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to change attribute without an attribute change crystal.", Config.DEFAULT_PUNISH);
return;
}
// get values
final int oldElementId = item.getAttackAttributeType().getClientId();
final int elementValue = item.getAttackAttribute().getValue();
item.clearAllAttributes();
item.setAttribute(new AttributeHolder(AttributeType.findByClientId(_newElementId), elementValue));
// send packets
final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.S1_S_S2_ATTRIBUTE_HAS_SUCCESSFULLY_CHANGED_TO_S3_ATTRIBUTE);
msg.addItemName(item);
msg.addAttribute(oldElementId);
msg.addAttribute(_newElementId);
activeChar.sendPacket(msg);
InventoryUpdate iu = new InventoryUpdate();
iu.addModifiedItem(item);
activeChar.sendPacket(iu);
activeChar.broadcastUserInfo();
activeChar.sendPacket(ExChangeAttributeOk.STATIC);
}
}

View File

@ -0,0 +1,61 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.clientpackets.attributechange;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import com.l2jmobius.gameserver.network.serverpackets.attributechange.ExChangeAttributeInfo;
/**
* @author Mobius
*/
public class SendChangeAttributeTargetItem implements IClientIncomingPacket
{
private int _crystalItemId;
private int _itemObjId;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
_crystalItemId = packet.readD();
_itemObjId = packet.readD();
return true;
}
@Override
public void run(L2GameClient client)
{
final L2PcInstance activeChar = client.getActiveChar();
if (activeChar == null)
{
return;
}
final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_itemObjId);
if ((item == null) || !item.isWeapon())
{
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
activeChar.sendPacket(new ExChangeAttributeInfo(_crystalItemId, item));
}
}

View File

@ -0,0 +1,40 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.serverpackets.attributechange;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.network.OutgoingPackets;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExChangeAttributeFail implements IClientOutgoingPacket
{
public static final IClientOutgoingPacket STATIC = new ExChangeAttributeFail();
public ExChangeAttributeFail()
{
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_CHANGE_ATTRIBUTE_FAIL.writeId(packet);
return true;
}
}

View File

@ -0,0 +1,69 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.serverpackets.attributechange;
import java.util.HashMap;
import java.util.Map;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.enums.AttributeType;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.OutgoingPackets;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExChangeAttributeInfo implements IClientOutgoingPacket
{
private static final Map<AttributeType, Byte> ATTRIBUTE_MASKS = new HashMap<>();
{
ATTRIBUTE_MASKS.put(AttributeType.FIRE, (byte) 1);
ATTRIBUTE_MASKS.put(AttributeType.WATER, (byte) 2);
ATTRIBUTE_MASKS.put(AttributeType.WIND, (byte) 4);
ATTRIBUTE_MASKS.put(AttributeType.EARTH, (byte) 8);
ATTRIBUTE_MASKS.put(AttributeType.HOLY, (byte) 16);
ATTRIBUTE_MASKS.put(AttributeType.DARK, (byte) 32);
}
private final int _crystalItemId;
private int _attributes;
private int _itemObjId;
public ExChangeAttributeInfo(int crystalItemId, L2ItemInstance item)
{
_crystalItemId = crystalItemId;
_attributes = 0;
for (AttributeType e : AttributeType.ATTRIBUTE_TYPES)
{
if (e != item.getAttackAttributeType())
{
_attributes |= ATTRIBUTE_MASKS.get(e);
}
}
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_CHANGE_ATTRIBUTE_INFO.writeId(packet);
packet.writeD(_crystalItemId);
packet.writeD(_attributes);
packet.writeD(_itemObjId);
return true;
}
}

View File

@ -0,0 +1,50 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.serverpackets.attributechange;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.model.ItemInfo;
import com.l2jmobius.gameserver.network.OutgoingPackets;
import com.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
/**
* @author Mobius
*/
public class ExChangeAttributeItemList extends AbstractItemPacket
{
private final ItemInfo[] _itemsList;
private final int _itemId;
public ExChangeAttributeItemList(int itemId, ItemInfo[] itemsList)
{
_itemId = itemId;
_itemsList = itemsList;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_CHANGE_ATTRIBUTE_ITEM_LIST.writeId(packet);
packet.writeD(_itemId);
packet.writeD(_itemsList.length);
for (ItemInfo item : _itemsList)
{
writeItem(packet, item);
}
return true;
}
}

View File

@ -0,0 +1,40 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.serverpackets.attributechange;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.network.OutgoingPackets;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExChangeAttributeOk implements IClientOutgoingPacket
{
public static final IClientOutgoingPacket STATIC = new ExChangeAttributeOk();
public ExChangeAttributeOk()
{
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_CHANGE_ATTRIBUTE_OK.writeId(packet);
return true;
}
}

View File

@ -186,6 +186,7 @@ import handlers.itemhandlers.BlessedSpiritShot;
import handlers.itemhandlers.Book;
import handlers.itemhandlers.Bypass;
import handlers.itemhandlers.Calculator;
import handlers.itemhandlers.ChangeAttributeCrystal;
import handlers.itemhandlers.CharmOfCourage;
import handlers.itemhandlers.Elixir;
import handlers.itemhandlers.EnchantAttribute;
@ -526,6 +527,7 @@ public class MasterHandler
Book.class,
Bypass.class,
Calculator.class,
ChangeAttributeCrystal.class,
CharmOfCourage.class,
Elixir.class,
EnchantAttribute.class,

View File

@ -0,0 +1,87 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.l2jmobius.gameserver.enums.ItemGrade;
import com.l2jmobius.gameserver.enums.PrivateStoreType;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.ItemInfo;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.network.serverpackets.attributechange.ExChangeAttributeItemList;
/**
* @author Mobius
*/
public class ChangeAttributeCrystal implements IItemHandler
{
private static final Map<Integer, ItemGrade> ITEM_GRADES = new HashMap<>();
{
ITEM_GRADES.put(33502, ItemGrade.S);
ITEM_GRADES.put(35749, ItemGrade.R);
ITEM_GRADES.put(45817, ItemGrade.R);
}
@Override
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!playable.isPlayer())
{
playable.sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_THIS_ITEM);
return false;
}
final L2PcInstance player = playable.getActingPlayer();
if (player.getPrivateStoreType() != PrivateStoreType.NONE)
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CANNOT_CHANGE_AN_ATTRIBUTE_WHILE_USING_A_PRIVATE_STORE_OR_WORKSHOP));
return false;
}
if (ITEM_GRADES.get(item.getId()) == null)
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CHANGING_ATTRIBUTES_HAS_BEEN_FAILED));
return false;
}
final List<ItemInfo> itemList = new ArrayList<>();
for (L2ItemInstance i : player.getInventory().getItems())
{
if (i.isWeapon() && i.hasAttributes() && (i.getItem().getItemGrade() == ITEM_GRADES.get(item.getId())))
{
itemList.add(new ItemInfo(i));
}
}
if (itemList.isEmpty())
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_ITEM_FOR_CHANGING_AN_ATTRIBUTE_DOES_NOT_EXIST));
return false;
}
player.sendPacket(new ExChangeAttributeItemList(item.getId(), itemList.toArray(new ItemInfo[itemList.size()])));
return true;
}
}

View File

@ -42,14 +42,10 @@
<set name="is_commissionable" val="false" />
<set name="is_private_storeable" val="false" />
<set name="is_oly_restricted" val="true" />
<set name="default_action" val="SKILL_REDUCE" />
<set name="etcitem_type" val="CHANGE_ATTR" />
<set name="handler" val="ItemSkills" />
<set name="handler" val="ChangeAttributeCrystal" />
<set name="immediate_effect" val="true" />
<set name="is_stackable" val="true" />
<skills>
<skill id="12881" level="1" /> <!-- Change Attribute -->
</skills>
</item>
<item id="33503" name="Hero's Blessed Buff Scroll" type="EtcItem">
<!-- When used, HP Recovery Bonus, Max MP, and Critical Atk. Rate + 20%, and you can feel the effects of Prophecy of Water, Might, Haste, Empower, Acumen, Wind Walk, Vampiric Rage, Berserker Spirit, Shield, Focus, Death Whisper, Guidance, Clarity, Wild Magic, and Concentration for 1 hour. -->

View File

@ -942,14 +942,10 @@
<set name="is_freightable" val="false" />
<set name="is_sellable" val="false" />
<set name="is_oly_restricted" val="true" />
<set name="default_action" val="SKILL_REDUCE" />
<set name="etcitem_type" val="CHANGE_ATTR" />
<set name="handler" val="ItemSkills" />
<set name="handler" val="ChangeAttributeCrystal" />
<set name="immediate_effect" val="true" />
<set name="commissionItemType" val="OTHER_ITEM" />
<skills>
<skill id="12881" level="1" /> <!-- Change Attribute -->
</skills>
</item>
<item id="35750" name="Draco's Blessing (30-minute)" additionalName="Event" type="EtcItem">
<!-- For 30 minutes, increases XP and SP acquired in hunt by 200% when used by characters level 85 - 90. -->

View File

@ -354,10 +354,14 @@
<item id="45817" name="Weapon Attribute Change Crystal (R-grade)" type="EtcItem">
<!-- Double-click to change the attribute of R, R95, and R99-grade weapons. It can be used when there is an R-grade weapon bestowed in the inventory. -->
<set name="icon" val="icon.change_elemental_crystal" />
<set name="is_stackable" val="true" />
<set name="is_freightable" val="false" />
<set name="is_sellable" val="false" />
<set name="is_oly_restricted" val="true" />
<set name="etcitem_type" val="CHANGE_ATTR" />
<set name="is_stackable" val="true" />
<set name="handler" val="ChangeAttributeCrystal" />
<set name="immediate_effect" val="true" />
<set name="commissionItemType" val="OTHER_ITEM" />
</item>
<item id="45818" name="Player Commendation Points Coupon (360 Points)" type="EtcItem">
<!-- When double-clicked, 360 Player Commendation Points can be acquired. -->

View File

@ -40,6 +40,9 @@ import com.l2jmobius.gameserver.network.clientpackets.appearance.RequestExCancel
import com.l2jmobius.gameserver.network.clientpackets.appearance.RequestExTryToPutShapeShiftingEnchantSupportItem;
import com.l2jmobius.gameserver.network.clientpackets.appearance.RequestExTryToPutShapeShiftingTargetItem;
import com.l2jmobius.gameserver.network.clientpackets.appearance.RequestShapeShiftingItem;
import com.l2jmobius.gameserver.network.clientpackets.attributechange.RequestChangeAttributeCancel;
import com.l2jmobius.gameserver.network.clientpackets.attributechange.RequestChangeAttributeItem;
import com.l2jmobius.gameserver.network.clientpackets.attributechange.SendChangeAttributeTargetItem;
import com.l2jmobius.gameserver.network.clientpackets.awakening.RequestCallToChangeClass;
import com.l2jmobius.gameserver.network.clientpackets.ceremonyofchaos.RequestCancelCuriousHouse;
import com.l2jmobius.gameserver.network.clientpackets.ceremonyofchaos.RequestCuriousHouseHtml;
@ -263,9 +266,9 @@ public enum ExIncomingPackets implements IIncomingPackets<L2GameClient>
REQUEST_FIRST_PLAY_START(0xAC, null, ConnectionState.IN_GAME),
REQUEST_FLY_MOVE_START(0xAD, RequestFlyMoveStart::new, ConnectionState.IN_GAME),
REQUEST_HARDWARE_INFO(0xAE, RequestHardWareInfo::new, ConnectionState.values()),
SEND_CHANGE_ATTRIBUTE_TARGET_ITEM(0xB0, null, ConnectionState.IN_GAME),
REQUEST_CHANGE_ATTRIBUTE_ITEM(0xB1, null, ConnectionState.IN_GAME),
REQUEST_CHANGE_ATTRIBUTE_CANCEL(0xB2, null, ConnectionState.IN_GAME),
SEND_CHANGE_ATTRIBUTE_TARGET_ITEM(0xB0, SendChangeAttributeTargetItem::new, ConnectionState.IN_GAME),
REQUEST_CHANGE_ATTRIBUTE_ITEM(0xB1, RequestChangeAttributeItem::new, ConnectionState.IN_GAME),
REQUEST_CHANGE_ATTRIBUTE_CANCEL(0xB2, RequestChangeAttributeCancel::new, ConnectionState.IN_GAME),
REQUEST_BR_PRESENT_BUY_PRODUCT(0xB3, null, ConnectionState.IN_GAME),
CONFIRM_MENTEE_ADD(0xB4, ConfirmMenteeAdd::new, ConnectionState.IN_GAME),
REQUEST_MENTOR_CANCEL(0xB5, RequestMentorCancel::new, ConnectionState.IN_GAME),

View File

@ -0,0 +1,46 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.clientpackets.attributechange;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import com.l2jmobius.gameserver.network.serverpackets.attributechange.ExChangeAttributeFail;
/**
* @author Mobius
*/
public class RequestChangeAttributeCancel implements IClientIncomingPacket
{
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(L2GameClient client)
{
final L2PcInstance activeChar = client.getActiveChar();
if (activeChar == null)
{
return;
}
activeChar.sendPacket(ExChangeAttributeFail.STATIC);
}
}

View File

@ -0,0 +1,92 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.clientpackets.attributechange;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.enums.AttributeType;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.itemcontainer.PcInventory;
import com.l2jmobius.gameserver.model.items.enchant.attribute.AttributeHolder;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.network.serverpackets.attributechange.ExChangeAttributeFail;
import com.l2jmobius.gameserver.network.serverpackets.attributechange.ExChangeAttributeOk;
import com.l2jmobius.gameserver.util.Util;
/**
* @author Mobius
*/
public class RequestChangeAttributeItem implements IClientIncomingPacket
{
private int _consumeItemId;
private int _itemObjId;
private int _newElementId;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
_consumeItemId = packet.readD();
_itemObjId = packet.readD();
_newElementId = packet.readD();
return true;
}
@Override
public void run(L2GameClient client)
{
final L2PcInstance activeChar = client.getActiveChar();
if (activeChar == null)
{
return;
}
final PcInventory inventory = activeChar.getInventory();
final L2ItemInstance item = inventory.getItemByObjectId(_itemObjId);
// attempting to destroy item
if (activeChar.getInventory().destroyItemByItemId("ChangeAttribute", _consumeItemId, 1, activeChar, item) == null)
{
client.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT2);
client.sendPacket(ExChangeAttributeFail.STATIC);
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to change attribute without an attribute change crystal.", Config.DEFAULT_PUNISH);
return;
}
// get values
final int oldElementId = item.getAttackAttributeType().getClientId();
final int elementValue = item.getAttackAttribute().getValue();
item.clearAllAttributes();
item.setAttribute(new AttributeHolder(AttributeType.findByClientId(_newElementId), elementValue));
// send packets
final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.S1_S_S2_ATTRIBUTE_HAS_SUCCESSFULLY_CHANGED_TO_S3_ATTRIBUTE);
msg.addItemName(item);
msg.addAttribute(oldElementId);
msg.addAttribute(_newElementId);
activeChar.sendPacket(msg);
InventoryUpdate iu = new InventoryUpdate();
iu.addModifiedItem(item);
activeChar.sendPacket(iu);
activeChar.broadcastUserInfo();
activeChar.sendPacket(ExChangeAttributeOk.STATIC);
}
}

View File

@ -0,0 +1,61 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.clientpackets.attributechange;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import com.l2jmobius.gameserver.network.serverpackets.attributechange.ExChangeAttributeInfo;
/**
* @author Mobius
*/
public class SendChangeAttributeTargetItem implements IClientIncomingPacket
{
private int _crystalItemId;
private int _itemObjId;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
_crystalItemId = packet.readD();
_itemObjId = packet.readD();
return true;
}
@Override
public void run(L2GameClient client)
{
final L2PcInstance activeChar = client.getActiveChar();
if (activeChar == null)
{
return;
}
final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_itemObjId);
if ((item == null) || !item.isWeapon())
{
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
activeChar.sendPacket(new ExChangeAttributeInfo(_crystalItemId, item));
}
}

View File

@ -0,0 +1,40 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.serverpackets.attributechange;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.network.OutgoingPackets;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExChangeAttributeFail implements IClientOutgoingPacket
{
public static final IClientOutgoingPacket STATIC = new ExChangeAttributeFail();
public ExChangeAttributeFail()
{
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_CHANGE_ATTRIBUTE_FAIL.writeId(packet);
return true;
}
}

View File

@ -0,0 +1,69 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.serverpackets.attributechange;
import java.util.HashMap;
import java.util.Map;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.enums.AttributeType;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.OutgoingPackets;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExChangeAttributeInfo implements IClientOutgoingPacket
{
private static final Map<AttributeType, Byte> ATTRIBUTE_MASKS = new HashMap<>();
{
ATTRIBUTE_MASKS.put(AttributeType.FIRE, (byte) 1);
ATTRIBUTE_MASKS.put(AttributeType.WATER, (byte) 2);
ATTRIBUTE_MASKS.put(AttributeType.WIND, (byte) 4);
ATTRIBUTE_MASKS.put(AttributeType.EARTH, (byte) 8);
ATTRIBUTE_MASKS.put(AttributeType.HOLY, (byte) 16);
ATTRIBUTE_MASKS.put(AttributeType.DARK, (byte) 32);
}
private final int _crystalItemId;
private int _attributes;
private int _itemObjId;
public ExChangeAttributeInfo(int crystalItemId, L2ItemInstance item)
{
_crystalItemId = crystalItemId;
_attributes = 0;
for (AttributeType e : AttributeType.ATTRIBUTE_TYPES)
{
if (e != item.getAttackAttributeType())
{
_attributes |= ATTRIBUTE_MASKS.get(e);
}
}
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_CHANGE_ATTRIBUTE_INFO.writeId(packet);
packet.writeD(_crystalItemId);
packet.writeD(_attributes);
packet.writeD(_itemObjId);
return true;
}
}

View File

@ -0,0 +1,50 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.serverpackets.attributechange;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.model.ItemInfo;
import com.l2jmobius.gameserver.network.OutgoingPackets;
import com.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
/**
* @author Mobius
*/
public class ExChangeAttributeItemList extends AbstractItemPacket
{
private final ItemInfo[] _itemsList;
private final int _itemId;
public ExChangeAttributeItemList(int itemId, ItemInfo[] itemsList)
{
_itemId = itemId;
_itemsList = itemsList;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_CHANGE_ATTRIBUTE_ITEM_LIST.writeId(packet);
packet.writeD(_itemId);
packet.writeD(_itemsList.length);
for (ItemInfo item : _itemsList)
{
writeItem(packet, item);
}
return true;
}
}

View File

@ -0,0 +1,40 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.serverpackets.attributechange;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.network.OutgoingPackets;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExChangeAttributeOk implements IClientOutgoingPacket
{
public static final IClientOutgoingPacket STATIC = new ExChangeAttributeOk();
public ExChangeAttributeOk()
{
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_CHANGE_ATTRIBUTE_OK.writeId(packet);
return true;
}
}

View File

@ -187,6 +187,7 @@ import handlers.itemhandlers.BlessedSpiritShot;
import handlers.itemhandlers.Book;
import handlers.itemhandlers.Bypass;
import handlers.itemhandlers.Calculator;
import handlers.itemhandlers.ChangeAttributeCrystal;
import handlers.itemhandlers.CharmOfCourage;
import handlers.itemhandlers.Elixir;
import handlers.itemhandlers.EnchantAttribute;
@ -527,6 +528,7 @@ public class MasterHandler
Book.class,
Bypass.class,
Calculator.class,
ChangeAttributeCrystal.class,
CharmOfCourage.class,
Elixir.class,
EnchantAttribute.class,

View File

@ -0,0 +1,87 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.itemhandlers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.l2jmobius.gameserver.enums.ItemGrade;
import com.l2jmobius.gameserver.enums.PrivateStoreType;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.ItemInfo;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.network.serverpackets.attributechange.ExChangeAttributeItemList;
/**
* @author Mobius
*/
public class ChangeAttributeCrystal implements IItemHandler
{
private static final Map<Integer, ItemGrade> ITEM_GRADES = new HashMap<>();
{
ITEM_GRADES.put(33502, ItemGrade.S);
ITEM_GRADES.put(35749, ItemGrade.R);
ITEM_GRADES.put(45817, ItemGrade.R);
}
@Override
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!playable.isPlayer())
{
playable.sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_THIS_ITEM);
return false;
}
final L2PcInstance player = playable.getActingPlayer();
if (player.getPrivateStoreType() != PrivateStoreType.NONE)
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CANNOT_CHANGE_AN_ATTRIBUTE_WHILE_USING_A_PRIVATE_STORE_OR_WORKSHOP));
return false;
}
if (ITEM_GRADES.get(item.getId()) == null)
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CHANGING_ATTRIBUTES_HAS_BEEN_FAILED));
return false;
}
final List<ItemInfo> itemList = new ArrayList<>();
for (L2ItemInstance i : player.getInventory().getItems())
{
if (i.isWeapon() && i.hasAttributes() && (i.getItem().getItemGrade() == ITEM_GRADES.get(item.getId())))
{
itemList.add(new ItemInfo(i));
}
}
if (itemList.isEmpty())
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_ITEM_FOR_CHANGING_AN_ATTRIBUTE_DOES_NOT_EXIST));
return false;
}
player.sendPacket(new ExChangeAttributeItemList(item.getId(), itemList.toArray(new ItemInfo[itemList.size()])));
return true;
}
}

View File

@ -40,6 +40,9 @@ import com.l2jmobius.gameserver.network.clientpackets.appearance.RequestExCancel
import com.l2jmobius.gameserver.network.clientpackets.appearance.RequestExTryToPutShapeShiftingEnchantSupportItem;
import com.l2jmobius.gameserver.network.clientpackets.appearance.RequestExTryToPutShapeShiftingTargetItem;
import com.l2jmobius.gameserver.network.clientpackets.appearance.RequestShapeShiftingItem;
import com.l2jmobius.gameserver.network.clientpackets.attributechange.RequestChangeAttributeCancel;
import com.l2jmobius.gameserver.network.clientpackets.attributechange.RequestChangeAttributeItem;
import com.l2jmobius.gameserver.network.clientpackets.attributechange.SendChangeAttributeTargetItem;
import com.l2jmobius.gameserver.network.clientpackets.awakening.RequestCallToChangeClass;
import com.l2jmobius.gameserver.network.clientpackets.ceremonyofchaos.RequestCancelCuriousHouse;
import com.l2jmobius.gameserver.network.clientpackets.ceremonyofchaos.RequestCuriousHouseHtml;
@ -263,9 +266,9 @@ public enum ExIncomingPackets implements IIncomingPackets<L2GameClient>
REQUEST_FIRST_PLAY_START(0xAC, null, ConnectionState.IN_GAME),
REQUEST_FLY_MOVE_START(0xAD, RequestFlyMoveStart::new, ConnectionState.IN_GAME),
REQUEST_HARDWARE_INFO(0xAE, RequestHardWareInfo::new, ConnectionState.values()),
SEND_CHANGE_ATTRIBUTE_TARGET_ITEM(0xB0, null, ConnectionState.IN_GAME),
REQUEST_CHANGE_ATTRIBUTE_ITEM(0xB1, null, ConnectionState.IN_GAME),
REQUEST_CHANGE_ATTRIBUTE_CANCEL(0xB2, null, ConnectionState.IN_GAME),
SEND_CHANGE_ATTRIBUTE_TARGET_ITEM(0xB0, SendChangeAttributeTargetItem::new, ConnectionState.IN_GAME),
REQUEST_CHANGE_ATTRIBUTE_ITEM(0xB1, RequestChangeAttributeItem::new, ConnectionState.IN_GAME),
REQUEST_CHANGE_ATTRIBUTE_CANCEL(0xB2, RequestChangeAttributeCancel::new, ConnectionState.IN_GAME),
REQUEST_BR_PRESENT_BUY_PRODUCT(0xB3, null, ConnectionState.IN_GAME),
CONFIRM_MENTEE_ADD(0xB4, ConfirmMenteeAdd::new, ConnectionState.IN_GAME),
REQUEST_MENTOR_CANCEL(0xB5, RequestMentorCancel::new, ConnectionState.IN_GAME),

View File

@ -0,0 +1,46 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.clientpackets.attributechange;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import com.l2jmobius.gameserver.network.serverpackets.attributechange.ExChangeAttributeFail;
/**
* @author Mobius
*/
public class RequestChangeAttributeCancel implements IClientIncomingPacket
{
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(L2GameClient client)
{
final L2PcInstance activeChar = client.getActiveChar();
if (activeChar == null)
{
return;
}
activeChar.sendPacket(ExChangeAttributeFail.STATIC);
}
}

View File

@ -0,0 +1,92 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.clientpackets.attributechange;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.enums.AttributeType;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.itemcontainer.PcInventory;
import com.l2jmobius.gameserver.model.items.enchant.attribute.AttributeHolder;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.network.serverpackets.attributechange.ExChangeAttributeFail;
import com.l2jmobius.gameserver.network.serverpackets.attributechange.ExChangeAttributeOk;
import com.l2jmobius.gameserver.util.Util;
/**
* @author Mobius
*/
public class RequestChangeAttributeItem implements IClientIncomingPacket
{
private int _consumeItemId;
private int _itemObjId;
private int _newElementId;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
_consumeItemId = packet.readD();
_itemObjId = packet.readD();
_newElementId = packet.readD();
return true;
}
@Override
public void run(L2GameClient client)
{
final L2PcInstance activeChar = client.getActiveChar();
if (activeChar == null)
{
return;
}
final PcInventory inventory = activeChar.getInventory();
final L2ItemInstance item = inventory.getItemByObjectId(_itemObjId);
// attempting to destroy item
if (activeChar.getInventory().destroyItemByItemId("ChangeAttribute", _consumeItemId, 1, activeChar, item) == null)
{
client.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT2);
client.sendPacket(ExChangeAttributeFail.STATIC);
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to change attribute without an attribute change crystal.", Config.DEFAULT_PUNISH);
return;
}
// get values
final int oldElementId = item.getAttackAttributeType().getClientId();
final int elementValue = item.getAttackAttribute().getValue();
item.clearAllAttributes();
item.setAttribute(new AttributeHolder(AttributeType.findByClientId(_newElementId), elementValue));
// send packets
final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.S1_S_S2_ATTRIBUTE_HAS_SUCCESSFULLY_CHANGED_TO_S3_ATTRIBUTE);
msg.addItemName(item);
msg.addAttribute(oldElementId);
msg.addAttribute(_newElementId);
activeChar.sendPacket(msg);
InventoryUpdate iu = new InventoryUpdate();
iu.addModifiedItem(item);
activeChar.sendPacket(iu);
activeChar.broadcastUserInfo();
activeChar.sendPacket(ExChangeAttributeOk.STATIC);
}
}

View File

@ -0,0 +1,61 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.clientpackets.attributechange;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import com.l2jmobius.gameserver.network.serverpackets.attributechange.ExChangeAttributeInfo;
/**
* @author Mobius
*/
public class SendChangeAttributeTargetItem implements IClientIncomingPacket
{
private int _crystalItemId;
private int _itemObjId;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
_crystalItemId = packet.readD();
_itemObjId = packet.readD();
return true;
}
@Override
public void run(L2GameClient client)
{
final L2PcInstance activeChar = client.getActiveChar();
if (activeChar == null)
{
return;
}
final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_itemObjId);
if ((item == null) || !item.isWeapon())
{
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
activeChar.sendPacket(new ExChangeAttributeInfo(_crystalItemId, item));
}
}

View File

@ -0,0 +1,40 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.serverpackets.attributechange;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.network.OutgoingPackets;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExChangeAttributeFail implements IClientOutgoingPacket
{
public static final IClientOutgoingPacket STATIC = new ExChangeAttributeFail();
public ExChangeAttributeFail()
{
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_CHANGE_ATTRIBUTE_FAIL.writeId(packet);
return true;
}
}

View File

@ -0,0 +1,69 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.serverpackets.attributechange;
import java.util.HashMap;
import java.util.Map;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.enums.AttributeType;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.OutgoingPackets;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExChangeAttributeInfo implements IClientOutgoingPacket
{
private static final Map<AttributeType, Byte> ATTRIBUTE_MASKS = new HashMap<>();
{
ATTRIBUTE_MASKS.put(AttributeType.FIRE, (byte) 1);
ATTRIBUTE_MASKS.put(AttributeType.WATER, (byte) 2);
ATTRIBUTE_MASKS.put(AttributeType.WIND, (byte) 4);
ATTRIBUTE_MASKS.put(AttributeType.EARTH, (byte) 8);
ATTRIBUTE_MASKS.put(AttributeType.HOLY, (byte) 16);
ATTRIBUTE_MASKS.put(AttributeType.DARK, (byte) 32);
}
private final int _crystalItemId;
private int _attributes;
private int _itemObjId;
public ExChangeAttributeInfo(int crystalItemId, L2ItemInstance item)
{
_crystalItemId = crystalItemId;
_attributes = 0;
for (AttributeType e : AttributeType.ATTRIBUTE_TYPES)
{
if (e != item.getAttackAttributeType())
{
_attributes |= ATTRIBUTE_MASKS.get(e);
}
}
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_CHANGE_ATTRIBUTE_INFO.writeId(packet);
packet.writeD(_crystalItemId);
packet.writeD(_attributes);
packet.writeD(_itemObjId);
return true;
}
}

View File

@ -0,0 +1,50 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.serverpackets.attributechange;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.model.ItemInfo;
import com.l2jmobius.gameserver.network.OutgoingPackets;
import com.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
/**
* @author Mobius
*/
public class ExChangeAttributeItemList extends AbstractItemPacket
{
private final ItemInfo[] _itemsList;
private final int _itemId;
public ExChangeAttributeItemList(int itemId, ItemInfo[] itemsList)
{
_itemId = itemId;
_itemsList = itemsList;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_CHANGE_ATTRIBUTE_ITEM_LIST.writeId(packet);
packet.writeD(_itemId);
packet.writeD(_itemsList.length);
for (ItemInfo item : _itemsList)
{
writeItem(packet, item);
}
return true;
}
}

View File

@ -0,0 +1,40 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.serverpackets.attributechange;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.network.OutgoingPackets;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExChangeAttributeOk implements IClientOutgoingPacket
{
public static final IClientOutgoingPacket STATIC = new ExChangeAttributeOk();
public ExChangeAttributeOk()
{
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_CHANGE_ATTRIBUTE_OK.writeId(packet);
return true;
}
}