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

@ -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;
}
}