Adapted appearance stone rework to all branches.

This commit is contained in:
MobiusDev
2017-11-20 02:22:09 +00:00
parent 029878f7b8
commit d4b385cffb
112 changed files with 83636 additions and 41736 deletions

View File

@@ -22,13 +22,13 @@ import java.util.Map;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.enums.Race;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.holders.AppearanceHolder;
import com.l2jmobius.gameserver.model.items.appearance.AppearanceStone;
import com.l2jmobius.gameserver.model.items.appearance.AppearanceTargetType;
import com.l2jmobius.gameserver.model.items.type.CrystalType;
@@ -75,9 +75,6 @@ public class AppearanceItemData implements IGameXmlReader
@Override
public void parseDocument(Document doc, File f)
{
StatsSet set;
Node att;
NamedNodeMap attrs;
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
@@ -86,15 +83,7 @@ public class AppearanceItemData implements IGameXmlReader
{
if ("appearance_stone".equalsIgnoreCase(d.getNodeName()))
{
attrs = d.getAttributes();
set = new StatsSet();
for (int i = 0; i < attrs.getLength(); i++)
{
att = attrs.item(i);
set.set(att.getNodeName(), att.getNodeValue());
}
final AppearanceStone stone = new AppearanceStone(set);
final AppearanceStone stone = new AppearanceStone(new StatsSet(parseAttributes(d)));
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
switch (c.getNodeName())
@@ -129,6 +118,10 @@ public class AppearanceItemData implements IGameXmlReader
stone.addRaceNot(raceNot);
break;
}
case "visual":
{
stone.addVisualId(new AppearanceHolder(new StatsSet(parseAttributes(c))));
}
}
}
if (ItemTable.getInstance().getTemplate(stone.getId()) != null)
@@ -145,6 +138,11 @@ public class AppearanceItemData implements IGameXmlReader
}
}
public int getLoadedElementsCount()
{
return _stones.size();
}
public AppearanceStone getStone(int stone)
{
return _stones.get(stone);

View File

@@ -0,0 +1,85 @@
/*
* 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.model.holders;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.items.appearance.AppearanceHandType;
import com.l2jmobius.gameserver.model.items.appearance.AppearanceMagicType;
import com.l2jmobius.gameserver.model.items.appearance.AppearanceTargetType;
import com.l2jmobius.gameserver.model.items.type.ArmorType;
import com.l2jmobius.gameserver.model.items.type.WeaponType;
/**
* @author Sdw
*/
public class AppearanceHolder
{
private final int _visualId;
private final WeaponType _weaponType;
private final ArmorType _armorType;
private final AppearanceHandType _handType;
private final AppearanceMagicType _magicType;
private final AppearanceTargetType _targetType;
private final Integer _bodyPart;
public AppearanceHolder(StatsSet set)
{
_visualId = set.getInt("id", 0);
_weaponType = set.getEnum("weaponType", WeaponType.class, WeaponType.NONE);
_armorType = set.getEnum("armorType", ArmorType.class, ArmorType.NONE);
_handType = set.getEnum("handType", AppearanceHandType.class, AppearanceHandType.NONE);
_magicType = set.getEnum("magicType", AppearanceMagicType.class, AppearanceMagicType.NONE);
_targetType = set.getEnum("targetType", AppearanceTargetType.class, AppearanceTargetType.NONE);
_bodyPart = ItemTable.SLOTS.get(set.getString("bodyPart", "none"));
}
public WeaponType getWeaponType()
{
return _weaponType;
}
public ArmorType getArmorType()
{
return _armorType;
}
public AppearanceHandType getHandType()
{
return _handType;
}
public AppearanceMagicType getMagicType()
{
return _magicType;
}
public AppearanceTargetType getTargetType()
{
return _targetType;
}
public int getBodyPart()
{
return _bodyPart;
}
public int getVisualId()
{
return _visualId;
}
}

View File

@@ -24,10 +24,14 @@ import java.util.List;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.enums.Race;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.AppearanceHolder;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.items.type.ArmorType;
import com.l2jmobius.gameserver.model.items.type.CrystalType;
import com.l2jmobius.gameserver.model.items.type.WeaponType;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* @author UnAfraid
@@ -48,6 +52,7 @@ public class AppearanceStone
private List<Integer> _bodyParts;
private List<Race> _races;
private List<Race> _racesNot;
private List<AppearanceHolder> _allVisualIds;
public AppearanceStone(StatsSet set)
{
@@ -61,15 +66,35 @@ public class AppearanceStone
_handType = set.getEnum("handType", AppearanceHandType.class, AppearanceHandType.NONE);
_magicType = set.getEnum("magicType", AppearanceMagicType.class, AppearanceMagicType.NONE);
// No grade items cannot change appearance, because client doesn't have No-Grade restoration stones.
final CrystalType crystalType = set.getEnum("crystalType", CrystalType.class, CrystalType.NONE);
if (crystalType == CrystalType.NONE)
final AppearanceTargetType targetType = set.getEnum("targetType", AppearanceTargetType.class, AppearanceTargetType.NONE);
if (targetType != AppearanceTargetType.NONE)
{
for (CrystalType cryType : CrystalType.values())
addTargetType(targetType);
}
// No grade items cannot change appearance, because client doesn't have No-Grade restoration stones.
final CrystalType crystalType = set.getEnum("grade", CrystalType.class, null);
// If no crystal type is defined, we must add all defaults.
if (crystalType == null)
{
switch (targetType)
{
if ((cryType != CrystalType.NONE) && (cryType != CrystalType.EVENT))
case ACCESSORY:
case ALL:
{
addCrystalType(cryType);
addCrystalType(CrystalType.NONE);
}
case WEAPON:
case ARMOR:
{
for (CrystalType cryType : CrystalType.values())
{
if ((cryType != CrystalType.NONE) && (cryType != CrystalType.EVENT))
{
addCrystalType(cryType);
}
}
}
}
}
@@ -78,12 +103,6 @@ public class AppearanceStone
addCrystalType(crystalType);
}
final AppearanceTargetType targetType = set.getEnum("targetType", AppearanceTargetType.class, AppearanceTargetType.NONE);
if (targetType != AppearanceTargetType.NONE)
{
addTargetType(targetType);
}
final int bodyPart = ItemTable.SLOTS.get(set.getString("bodyPart", "none"));
if (bodyPart != L2Item.SLOT_NONE)
{
@@ -185,6 +204,20 @@ public class AppearanceStone
_bodyParts.add(part);
}
public void addVisualId(AppearanceHolder appearanceHolder)
{
if (_allVisualIds == null)
{
_allVisualIds = new ArrayList<>();
}
_allVisualIds.add(appearanceHolder);
}
public List<AppearanceHolder> getVisualIds()
{
return _allVisualIds != null ? _allVisualIds : Collections.emptyList();
}
public List<Integer> getBodyParts()
{
return _bodyParts != null ? _bodyParts : Collections.emptyList();
@@ -217,4 +250,297 @@ public class AppearanceStone
{
return _racesNot != null ? _racesNot : Collections.emptyList();
}
/**
* @param player the actor requesting to use this appearance.
* @param targetItem the item to be modified with this appearance.
* @return {@code true} if the item is valid for appearance change, {@code false} otherwise.
*/
public boolean checkConditions(L2PcInstance player, L2ItemInstance targetItem)
{
if (targetItem == null)
{
return false;
}
if (getTargetTypes().isEmpty())
{
return false;
}
if (targetItem.isEquipped() && (getRacesNot().contains(player.getRace()) || (!getRaces().isEmpty() && !getRaces().contains(player.getRace()))))
{
player.sendPacket(SystemMessageId.YOU_CANNOT_MODIFY_AN_EQUIPPED_ITEM_INTO_THE_APPEARANCE_OF_AN_UNEQUIPPABLE_ITEM_PLEASE_CHECK_RACE_GENDER_RESTRICTIONS_YOU_CAN_MODIFY_THE_APPEARANCE_IF_YOU_UNEQUIP_THE_ITEM);
return false;
}
switch (getType())
{
case RESTORE:
{
if (targetItem.getVisualId() == 0)
{
player.sendPacket(SystemMessageId.YOU_CANNOT_RESTORE_ITEMS_THAT_HAVE_NOT_BEEN_MODIFIED);
return false;
}
if ((targetItem.isWeapon() && !getTargetTypes().contains(AppearanceTargetType.WEAPON)) || (targetItem.isArmor() && !getTargetTypes().contains(AppearanceTargetType.ARMOR)) || (targetItem.isEtcItem() && !getTargetTypes().contains(AppearanceTargetType.ACCESSORY)))
{
player.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
return false;
}
if (((targetItem.getItem().getBodyPart() == L2Item.SLOT_HAIR) || (targetItem.getItem().getBodyPart() == L2Item.SLOT_HAIR2) || (targetItem.getItem().getBodyPart() == L2Item.SLOT_HAIRALL)) && !getTargetTypes().contains(AppearanceTargetType.ACCESSORY))
{
player.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
return false;
}
break;
}
default:
{
// Seems like in retail item with already changed appearance, can be changed again without being restored.
final AppearanceTargetType targetType = getTargetTypes().get(0);
switch (targetType)
{
case NONE:
{
return false;
}
case WEAPON:
{
if (!targetItem.isWeapon())
{
player.sendPacket(SystemMessageId.WEAPONS_ONLY);
return false;
}
if (targetItem.getItem().getCrystalType() == CrystalType.NONE)
{
player.sendPacket(SystemMessageId.YOU_CANNOT_MODIFY_OR_RESTORE_NO_GRADE_ITEMS);
return false;
}
break;
}
case ARMOR:
{
if (!targetItem.isArmor())
{
player.sendPacket(SystemMessageId.ARMOR_ONLY);
return false;
}
if (targetItem.getItem().getCrystalType() == CrystalType.NONE)
{
player.sendPacket(SystemMessageId.YOU_CANNOT_MODIFY_OR_RESTORE_NO_GRADE_ITEMS);
return false;
}
break;
}
case ACCESSORY:
{
if ((targetItem.getItem().getBodyPart() != L2Item.SLOT_HAIR) && (targetItem.getItem().getBodyPart() != L2Item.SLOT_HAIR2) && (targetItem.getItem().getBodyPart() != L2Item.SLOT_HAIRALL))
{
player.sendPacket(SystemMessageId.HAIR_ACCESSORIES_ONLY);
return false;
}
break;
}
case ALL:
{
if (!getCrystalTypes().isEmpty() && !getCrystalTypes().contains(targetItem.getItem().getCrystalType()))
{
player.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
return false;
}
if (findVisualChange(targetItem) == null)
{
player.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
return false;
}
return true;
}
}
break;
}
}
if (!getCrystalTypes().isEmpty() && !getCrystalTypes().contains(targetItem.getItem().getCrystalType()))
{
player.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
return false;
}
if (targetItem.isArmor() && !getBodyParts().isEmpty() && !getBodyParts().contains(targetItem.getItem().getBodyPart()))
{
player.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
return false;
}
if (getWeaponType() != WeaponType.NONE)
{
if (!targetItem.isWeapon() || (targetItem.getItemType() != getWeaponType()))
{
player.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_USED_AS_AN_APPEARANCE_WEAPON);
return false;
}
switch (getHandType())
{
case ONE_HANDED:
{
if ((targetItem.getItem().getBodyPart() & L2Item.SLOT_R_HAND) != L2Item.SLOT_R_HAND)
{
player.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
return false;
}
break;
}
case TWO_HANDED:
{
if ((targetItem.getItem().getBodyPart() & L2Item.SLOT_LR_HAND) != L2Item.SLOT_LR_HAND)
{
player.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
return false;
}
break;
}
}
switch (getMagicType())
{
case MAGICAL:
{
if (!targetItem.getItem().isMagicWeapon())
{
player.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
return false;
}
break;
}
case PHYISICAL:
{
if (targetItem.getItem().isMagicWeapon())
{
player.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
return false;
}
}
}
}
if (getArmorType() != ArmorType.NONE)
{
switch (getArmorType())
{
case SHIELD:
{
if (!targetItem.isArmor() || (targetItem.getItemType() != ArmorType.SHIELD))
{
player.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
return false;
}
break;
}
case SIGIL:
{
if (!targetItem.isArmor() || (targetItem.getItemType() != ArmorType.SIGIL))
{
player.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
return false;
}
}
}
}
return true;
}
public AppearanceHolder findVisualChange(L2ItemInstance targetItem)
{
for (AppearanceHolder holder : _allVisualIds)
{
if (targetItem.isArmor() && (holder.getBodyPart() != 0) && (targetItem.getItem().getBodyPart() != holder.getBodyPart()))
{
continue;
}
if (holder.getWeaponType() != WeaponType.NONE)
{
if (!targetItem.isWeapon() || (targetItem.getItemType() != holder.getWeaponType()))
{
continue;
}
switch (holder.getHandType())
{
case ONE_HANDED:
{
if ((targetItem.getItem().getBodyPart() & L2Item.SLOT_R_HAND) != L2Item.SLOT_R_HAND)
{
continue;
}
break;
}
case TWO_HANDED:
{
if ((targetItem.getItem().getBodyPart() & L2Item.SLOT_LR_HAND) != L2Item.SLOT_LR_HAND)
{
continue;
}
break;
}
}
switch (holder.getMagicType())
{
case MAGICAL:
{
if (!targetItem.getItem().isMagicWeapon())
{
continue;
}
break;
}
case PHYISICAL:
{
if (targetItem.getItem().isMagicWeapon())
{
continue;
}
}
}
}
if (holder.getArmorType() != ArmorType.NONE)
{
switch (holder.getArmorType())
{
case SHIELD:
{
if (!targetItem.isArmor() || (targetItem.getItemType() != ArmorType.SHIELD))
{
continue;
}
break;
}
case SIGIL:
{
if (!targetItem.isArmor() || (targetItem.getItemType() != ArmorType.SIGIL))
{
continue;
}
}
}
}
return holder;
}
return null;
}
}

View File

@@ -26,13 +26,11 @@ import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.items.appearance.AppearanceStone;
import com.l2jmobius.gameserver.model.items.appearance.AppearanceType;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.items.type.ArmorType;
import com.l2jmobius.gameserver.model.items.type.WeaponType;
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.appearance.ExPutShapeShiftingExtractionItemResult;
import com.l2jmobius.gameserver.network.serverpackets.appearance.ExShapeShiftingResult;
import com.l2jmobius.gameserver.network.serverpackets.appearance.ExPutShapeShiftingTargetItemResult;
/**
* @author UnAfraid
@@ -63,175 +61,100 @@ public class RequestExTryToPutShapeShiftingEnchantSupportItem implements IClient
if (player.isInStoreMode() || player.isInCraftMode() || player.isProcessingRequest() || player.isProcessingTransaction() || (request == null))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(SystemMessageId.YOU_CANNOT_USE_THIS_SYSTEM_DURING_TRADING_PRIVATE_STORE_AND_WORKSHOP_SETUP);
return;
}
final PcInventory inventory = player.getInventory();
final L2ItemInstance targetItem = inventory.getItemByObjectId(_targetItemObjId);
final L2ItemInstance extracItem = inventory.getItemByObjectId(_extracItemObjId);
final L2ItemInstance extractItem = inventory.getItemByObjectId(_extracItemObjId);
L2ItemInstance stone = request.getAppearanceStone();
if ((targetItem == null) || (extracItem == null) || (stone == null))
if ((targetItem == null) || (extractItem == null) || (stone == null))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
if (!extracItem.getItem().isAppearanceable())
if ((stone.getOwnerId() != player.getObjectId()) || (targetItem.getOwnerId() != player.getObjectId()) || (extractItem.getOwnerId() != player.getObjectId()))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
if ((extracItem.getItemLocation() != ItemLocation.INVENTORY) && (extracItem.getItemLocation() != ItemLocation.PAPERDOLL))
if (!extractItem.getItem().isAppearanceable())
{
player.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
client.sendPacket(ExPutShapeShiftingExtractionItemResult.FAILED);
return;
}
if ((extractItem.getItemLocation() != ItemLocation.INVENTORY) && (extractItem.getItemLocation() != ItemLocation.PAPERDOLL))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
stone = inventory.getItemByObjectId(stone.getObjectId());
if (stone == null)
if ((stone = inventory.getItemByObjectId(stone.getObjectId())) == null)
{
client.sendPacket(ExShapeShiftingResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
final AppearanceStone appearanceStone = AppearanceItemData.getInstance().getStone(stone.getId());
if (appearanceStone == null)
{
client.sendPacket(ExShapeShiftingResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
if ((appearanceStone.getType() == AppearanceType.RESTORE) || (appearanceStone.getType() == AppearanceType.FIXED))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
if (extracItem.getVisualId() > 0)
if (extractItem.getVisualId() > 0)
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(ExPutShapeShiftingExtractionItemResult.FAILED);
client.sendPacket(SystemMessageId.YOU_CANNOT_EXTRACT_FROM_A_MODIFIED_ITEM);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
if (appearanceStone.getWeaponType() != WeaponType.NONE)
if ((extractItem.getItemLocation() != ItemLocation.INVENTORY) && (extractItem.getItemLocation() != ItemLocation.PAPERDOLL))
{
if (!targetItem.isWeapon() || (targetItem.getItemType() != appearanceStone.getWeaponType()))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
}
if (appearanceStone.getWeaponType() != WeaponType.NONE)
{
if (!targetItem.isWeapon() || (targetItem.getItemType() != appearanceStone.getWeaponType()))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
switch (appearanceStone.getHandType())
{
case ONE_HANDED:
{
if ((targetItem.getItem().getBodyPart() & L2Item.SLOT_R_HAND) != L2Item.SLOT_R_HAND)
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
break;
}
case TWO_HANDED:
{
if ((targetItem.getItem().getBodyPart() & L2Item.SLOT_LR_HAND) != L2Item.SLOT_LR_HAND)
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
break;
}
}
switch (appearanceStone.getMagicType())
{
case MAGICAL:
{
if (!targetItem.getItem().isMagicWeapon())
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
break;
}
case PHYISICAL:
{
if (targetItem.getItem().isMagicWeapon())
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
}
}
}
if (appearanceStone.getArmorType() != ArmorType.NONE)
{
switch (appearanceStone.getArmorType())
{
case SHIELD:
{
if (!targetItem.isArmor() || (targetItem.getItemType() != ArmorType.SHIELD))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
break;
}
case SIGIL:
{
if (!targetItem.isArmor() || (targetItem.getItemType() != ArmorType.SIGIL))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
}
}
}
if (extracItem.getOwnerId() != player.getObjectId())
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(ExPutShapeShiftingExtractionItemResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
request.setAppearanceExtractItem(extracItem);
if ((extractItem.getItemType() != targetItem.getItemType()) || (extractItem.getId() == targetItem.getId()) || (extractItem.getObjectId() == targetItem.getObjectId()))
{
player.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
client.sendPacket(ExPutShapeShiftingExtractionItemResult.FAILED);
return;
}
if ((extractItem.getItem().getBodyPart() != targetItem.getItem().getBodyPart()) && ((extractItem.getItem().getBodyPart() != L2Item.SLOT_FULL_ARMOR) || (targetItem.getItem().getBodyPart() != L2Item.SLOT_CHEST)))
{
player.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
client.sendPacket(ExPutShapeShiftingExtractionItemResult.FAILED);
return;
}
if (extractItem.getItem().getCrystalType().isGreater(targetItem.getItem().getCrystalType()))
{
client.sendPacket(SystemMessageId.YOU_CANNOT_EXTRACT_FROM_ITEMS_THAT_ARE_HIGHER_GRADE_THAN_ITEMS_TO_BE_MODIFIED);
player.sendPacket(ExPutShapeShiftingExtractionItemResult.FAILED);
return;
}
if (!appearanceStone.checkConditions(player, targetItem))
{
player.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
return;
}
request.setAppearanceExtractItem(extractItem);
client.sendPacket(ExPutShapeShiftingExtractionItemResult.SUCCESS);
}
}

View File

@@ -22,13 +22,8 @@ import com.l2jmobius.gameserver.enums.ItemLocation;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.request.ShapeShiftingItemRequest;
import com.l2jmobius.gameserver.model.itemcontainer.PcInventory;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.items.appearance.AppearanceStone;
import com.l2jmobius.gameserver.model.items.appearance.AppearanceTargetType;
import com.l2jmobius.gameserver.model.items.appearance.AppearanceType;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.items.type.ArmorType;
import com.l2jmobius.gameserver.model.items.type.WeaponType;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
@@ -77,13 +72,20 @@ public class RequestExTryToPutShapeShiftingTargetItem implements IClientIncoming
return;
}
if (!targetItem.getItem().isAppearanceable())
if ((stone.getOwnerId() != player.getObjectId()) || (targetItem.getOwnerId() != player.getObjectId()))
{
client.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
if (!targetItem.getItem().isAppearanceable())
{
client.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_MODIFIED_OR_RESTORED);
client.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
return;
}
if ((targetItem.getItemLocation() != ItemLocation.INVENTORY) && (targetItem.getItemLocation() != ItemLocation.PAPERDOLL))
{
client.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
@@ -91,8 +93,7 @@ public class RequestExTryToPutShapeShiftingTargetItem implements IClientIncoming
return;
}
stone = inventory.getItemByObjectId(stone.getObjectId());
if (stone == null)
if ((stone = inventory.getItemByObjectId(stone.getObjectId())) == null)
{
client.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
@@ -107,158 +108,9 @@ public class RequestExTryToPutShapeShiftingTargetItem implements IClientIncoming
return;
}
if (((appearanceStone.getType() != AppearanceType.RESTORE) && (targetItem.getVisualId() > 0)) || ((appearanceStone.getType() == AppearanceType.RESTORE) && (targetItem.getVisualId() == 0)))
if (!appearanceStone.checkConditions(player, targetItem))
{
client.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
// TODO: Handle hair accessory!
// if (!targetItem.isEtcItem() && (targetItem.getItem().getCrystalType() == CrystalType.NONE))
{
// client.sendPacket(SystemMessageId.YOU_CANNOT_MODIFY_OR_RESTORE_NOGRADE_ITEMS);
// return;
}
if (!appearanceStone.getTargetTypes().contains(AppearanceTargetType.ACCESSORY)) // accessory tempfix
{
if (!appearanceStone.getCrystalTypes().isEmpty() && !appearanceStone.getCrystalTypes().contains(targetItem.getItem().getCrystalType()))
{
client.sendPacket(SystemMessageId.ITEM_GRADES_DO_NOT_MATCH);
client.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
}
if (appearanceStone.getTargetTypes().isEmpty())
{
client.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
if (!appearanceStone.getTargetTypes().contains(AppearanceTargetType.ALL))
{
if (targetItem.isWeapon() && !appearanceStone.getTargetTypes().contains(AppearanceTargetType.WEAPON))
{
client.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
client.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
else if (targetItem.isArmor() && !appearanceStone.getTargetTypes().contains(AppearanceTargetType.ARMOR) && !appearanceStone.getTargetTypes().contains(AppearanceTargetType.ACCESSORY))
{
client.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
client.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
else if (targetItem.isArmor() && !appearanceStone.getBodyParts().isEmpty() && !appearanceStone.getBodyParts().contains(targetItem.getItem().getBodyPart()))
{
client.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
client.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
}
if (appearanceStone.getWeaponType() != WeaponType.NONE)
{
if (!targetItem.isWeapon() || (targetItem.getItemType() != appearanceStone.getWeaponType()))
{
client.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
client.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
return;
}
switch (appearanceStone.getHandType())
{
case ONE_HANDED:
{
if ((targetItem.getItem().getBodyPart() & L2Item.SLOT_R_HAND) != L2Item.SLOT_R_HAND)
{
client.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
client.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
return;
}
break;
}
case TWO_HANDED:
{
if ((targetItem.getItem().getBodyPart() & L2Item.SLOT_LR_HAND) != L2Item.SLOT_LR_HAND)
{
client.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
client.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
return;
}
break;
}
}
switch (appearanceStone.getMagicType())
{
case MAGICAL:
{
if (!targetItem.getItem().isMagicWeapon())
{
client.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
client.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
return;
}
break;
}
case PHYISICAL:
{
if (targetItem.getItem().isMagicWeapon())
{
client.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
client.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
return;
}
}
}
}
if (appearanceStone.getArmorType() != ArmorType.NONE)
{
switch (appearanceStone.getArmorType())
{
case SHIELD:
{
if (!targetItem.isArmor() || (targetItem.getItemType() != ArmorType.SHIELD))
{
client.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
client.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
return;
}
break;
}
case SIGIL:
{
if (!targetItem.isArmor() || (targetItem.getItemType() != ArmorType.SIGIL))
{
client.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
client.sendPacket(SystemMessageId.THIS_ITEM_DOES_NOT_MEET_REQUIREMENTS);
return;
}
}
}
}
if (targetItem.getOwnerId() != player.getObjectId())
{
client.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
player.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
return;
}

View File

@@ -22,14 +22,12 @@ import com.l2jmobius.gameserver.enums.InventorySlot;
import com.l2jmobius.gameserver.enums.ItemLocation;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.request.ShapeShiftingItemRequest;
import com.l2jmobius.gameserver.model.holders.AppearanceHolder;
import com.l2jmobius.gameserver.model.itemcontainer.PcInventory;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.items.appearance.AppearanceStone;
import com.l2jmobius.gameserver.model.items.appearance.AppearanceTargetType;
import com.l2jmobius.gameserver.model.items.appearance.AppearanceType;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.items.type.ArmorType;
import com.l2jmobius.gameserver.model.items.type.WeaponType;
import com.l2jmobius.gameserver.model.variables.ItemVariables;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.SystemMessageId;
@@ -37,8 +35,6 @@ import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import com.l2jmobius.gameserver.network.serverpackets.ExAdenaInvenCount;
import com.l2jmobius.gameserver.network.serverpackets.ExUserInfoEquipSlot;
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.network.serverpackets.appearance.ExPutShapeShiftingTargetItemResult;
import com.l2jmobius.gameserver.network.serverpackets.appearance.ExShapeShiftingResult;
/**
@@ -68,7 +64,7 @@ public class RequestShapeShiftingItem implements IClientIncomingPacket
if (player.isInStoreMode() || player.isInCraftMode() || player.isProcessingRequest() || player.isProcessingTransaction() || (request == null))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(ExShapeShiftingResult.CLOSE);
client.sendPacket(SystemMessageId.YOU_CANNOT_USE_THIS_SYSTEM_DURING_TRADING_PRIVATE_STORE_AND_WORKSHOP_SETUP);
return;
}
@@ -79,36 +75,36 @@ public class RequestShapeShiftingItem implements IClientIncomingPacket
if ((targetItem == null) || (stone == null))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(ExShapeShiftingResult.CLOSE);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
if (stone.getOwnerId() != player.getObjectId())
if ((stone.getOwnerId() != player.getObjectId()) || (targetItem.getOwnerId() != player.getObjectId()))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(ExShapeShiftingResult.CLOSE);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
if (!targetItem.getItem().isAppearanceable())
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_MODIFIED_OR_RESTORED);
client.sendPacket(ExShapeShiftingResult.CLOSE);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
if ((targetItem.getItemLocation() != ItemLocation.INVENTORY) && (targetItem.getItemLocation() != ItemLocation.PAPERDOLL))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(ExShapeShiftingResult.CLOSE);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
stone = inventory.getItemByObjectId(stone.getObjectId());
if (stone == null)
if ((stone = inventory.getItemByObjectId(stone.getObjectId())) == null)
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(ExShapeShiftingResult.CLOSE);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
@@ -116,223 +112,100 @@ public class RequestShapeShiftingItem implements IClientIncomingPacket
final AppearanceStone appearanceStone = AppearanceItemData.getInstance().getStone(stone.getId());
if (appearanceStone == null)
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(ExShapeShiftingResult.CLOSE);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
if (((appearanceStone.getType() != AppearanceType.RESTORE) && (targetItem.getVisualId() > 0)) || ((appearanceStone.getType() == AppearanceType.RESTORE) && (targetItem.getVisualId() == 0)))
if (!appearanceStone.checkConditions(player, targetItem))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(ExShapeShiftingResult.CLOSE);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
// TODO: Handle hair accessory!
// if (!targetItem.isEtcItem() && (targetItem.getItem().getCrystalType() == CrystalType.NONE))
{
// client.sendPacket(ExShapeShiftingResult.FAILED);
// player.removeRequest(ShapeShiftingItemRequest.class.getName());
// return;
}
if (!appearanceStone.getTargetTypes().contains(AppearanceTargetType.ACCESSORY)) // accessory tempfix
{
if (!appearanceStone.getCrystalTypes().isEmpty() && !appearanceStone.getCrystalTypes().contains(targetItem.getItem().getCrystalType()))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
}
if (appearanceStone.getTargetTypes().isEmpty())
{
client.sendPacket(ExShapeShiftingResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
if (!appearanceStone.getTargetTypes().contains(AppearanceTargetType.ALL))
{
if (targetItem.isWeapon() && !appearanceStone.getTargetTypes().contains(AppearanceTargetType.WEAPON))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
else if (targetItem.isArmor() && !appearanceStone.getTargetTypes().contains(AppearanceTargetType.ARMOR) && !appearanceStone.getTargetTypes().contains(AppearanceTargetType.ACCESSORY))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
else if (targetItem.isArmor() && !appearanceStone.getBodyParts().isEmpty() && !appearanceStone.getBodyParts().contains(targetItem.getItem().getBodyPart()))
{
client.sendPacket(ExPutShapeShiftingTargetItemResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
}
if (appearanceStone.getWeaponType() != WeaponType.NONE)
{
if (!targetItem.isWeapon() || (targetItem.getItemType() != appearanceStone.getWeaponType()))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
switch (appearanceStone.getHandType())
{
case ONE_HANDED:
{
if ((targetItem.getItem().getBodyPart() & L2Item.SLOT_R_HAND) != L2Item.SLOT_R_HAND)
{
client.sendPacket(ExShapeShiftingResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
break;
}
case TWO_HANDED:
{
if ((targetItem.getItem().getBodyPart() & L2Item.SLOT_LR_HAND) != L2Item.SLOT_LR_HAND)
{
client.sendPacket(ExShapeShiftingResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
break;
}
}
switch (appearanceStone.getMagicType())
{
case MAGICAL:
{
if (!targetItem.getItem().isMagicWeapon())
{
client.sendPacket(ExShapeShiftingResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
break;
}
case PHYISICAL:
{
if (targetItem.getItem().isMagicWeapon())
{
client.sendPacket(ExShapeShiftingResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
}
}
}
if (appearanceStone.getArmorType() != ArmorType.NONE)
{
switch (appearanceStone.getArmorType())
{
case SHIELD:
{
if (!targetItem.isArmor() || (targetItem.getItemType() != ArmorType.SHIELD))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
break;
}
case SIGIL:
{
if (!targetItem.isArmor() || (targetItem.getItemType() != ArmorType.SIGIL))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
}
}
}
final L2ItemInstance extracItem = request.getAppearanceExtractItem();
final L2ItemInstance extractItem = request.getAppearanceExtractItem();
int extracItemId = 0;
if ((appearanceStone.getType() != AppearanceType.RESTORE) && (appearanceStone.getType() != AppearanceType.FIXED))
{
if (extracItem == null)
if (extractItem == null)
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(ExShapeShiftingResult.CLOSE);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
if (!targetItem.getItem().isAppearanceable())
if (extractItem.getOwnerId() != player.getObjectId())
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(ExShapeShiftingResult.CLOSE);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
if ((extracItem.getItemLocation() != ItemLocation.INVENTORY) && (extracItem.getItemLocation() != ItemLocation.PAPERDOLL))
if (!extractItem.getItem().isAppearanceable())
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(ExShapeShiftingResult.CLOSE);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
if (!extracItem.isEtcItem() && (targetItem.getItem().getCrystalType().ordinal() <= extracItem.getItem().getCrystalType().ordinal()))
if ((extractItem.getItemLocation() != ItemLocation.INVENTORY) && (extractItem.getItemLocation() != ItemLocation.PAPERDOLL))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(ExShapeShiftingResult.CLOSE);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
if (extracItem.getVisualId() > 0)
if (extractItem.getItem().getCrystalType().isGreater(targetItem.getItem().getCrystalType()))
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(ExShapeShiftingResult.CLOSE);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
if (extracItem.getOwnerId() != player.getObjectId())
if (extractItem.getVisualId() > 0)
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(ExShapeShiftingResult.CLOSE);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
extracItemId = extracItem.getId();
if ((extractItem.getItemType() != targetItem.getItemType()) || (extractItem.getId() == targetItem.getId()) || (extractItem.getObjectId() == targetItem.getObjectId()))
{
client.sendPacket(ExShapeShiftingResult.CLOSE);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
if ((extractItem.getItem().getBodyPart() != targetItem.getItem().getBodyPart()) && ((extractItem.getItem().getBodyPart() != L2Item.SLOT_FULL_ARMOR) || (targetItem.getItem().getBodyPart() != L2Item.SLOT_CHEST)))
{
client.sendPacket(ExShapeShiftingResult.CLOSE);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
extracItemId = extractItem.getId();
}
if (targetItem.getOwnerId() != player.getObjectId())
{
client.sendPacket(ExShapeShiftingResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
final long cost = appearanceStone.getCost();
long cost = appearanceStone.getCost();
if (cost > player.getAdena())
{
client.sendPacket(SystemMessageId.YOU_CANNOT_MODIFY_AS_YOU_DO_NOT_HAVE_ENOUGH_ADENA);
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(ExShapeShiftingResult.CLOSE);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
if (stone.getCount() < 1L)
{
client.sendPacket(ExShapeShiftingResult.FAILED);
client.sendPacket(ExShapeShiftingResult.CLOSE);
player.removeRequest(ShapeShiftingItemRequest.class);
return;
}
if (appearanceStone.getType() == AppearanceType.NORMAL)
{
if (inventory.destroyItem(getClass().getSimpleName(), extracItem, 1, player, this) == null)
if (inventory.destroyItem(getClass().getSimpleName(), extractItem, 1, player, this) == null)
{
client.sendPacket(ExShapeShiftingResult.FAILED);
player.removeRequest(ShapeShiftingItemRequest.class);
@@ -341,7 +214,7 @@ public class RequestShapeShiftingItem implements IClientIncomingPacket
}
inventory.destroyItem(getClass().getSimpleName(), stone, 1, player, this);
player.reduceAdena(getClass().getSimpleName(), cost, extracItem, true);
player.reduceAdena(getClass().getSimpleName(), cost, extractItem, false);
switch (appearanceStone.getType())
{
@@ -353,18 +226,32 @@ public class RequestShapeShiftingItem implements IClientIncomingPacket
}
case NORMAL:
{
targetItem.setVisualId(extracItem.getId());
targetItem.setVisualId(extractItem.getId());
break;
}
case BLESSED:
{
targetItem.setVisualId(extracItem.getId());
targetItem.setVisualId(extractItem.getId());
break;
}
case FIXED:
{
targetItem.setVisualId(appearanceStone.getVisualId());
targetItem.getVariables().set(ItemVariables.VISUAL_APPEARANCE_STONE_ID, appearanceStone.getId());
if (appearanceStone.getVisualIds().isEmpty())
{
extracItemId = appearanceStone.getVisualId();
targetItem.setVisualId(appearanceStone.getVisualId());
targetItem.getVariables().set(ItemVariables.VISUAL_APPEARANCE_STONE_ID, appearanceStone.getId());
}
else
{
final AppearanceHolder holder = appearanceStone.findVisualChange(targetItem);
if (holder != null)
{
extracItemId = holder.getVisualId();
targetItem.setVisualId(holder.getVisualId());
targetItem.getVariables().set(ItemVariables.VISUAL_APPEARANCE_STONE_ID, appearanceStone.getId());
}
}
break;
}
}
@@ -376,17 +263,13 @@ public class RequestShapeShiftingItem implements IClientIncomingPacket
}
targetItem.getVariables().storeMe();
if (appearanceStone.getCost() > 0)
{
client.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_SPENT_S1_ON_A_SUCCESSFUL_APPEARANCE_MODIFICATION).addLong(cost));
}
else
{
client.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_S_APPEARANCE_MODIFICATION_HAS_FINISHED).addItemName(targetItem.getDisplayId()));
}
final InventoryUpdate iu = new InventoryUpdate();
iu.addModifiedItem(targetItem);
if (extractItem != null)
{
iu.addModifiedItem(extractItem);
}
if (inventory.getItemByObjectId(stone.getObjectId()) == null)
{
iu.addRemovedItem(stone);

View File

@@ -27,8 +27,10 @@ public class ExShapeShiftingResult implements IClientOutgoingPacket
{
public static int RESULT_FAILED = 0x00;
public static int RESULT_SUCCESS = 0x01;
public static int RESULT_CLOSE = 0x02;
public static ExShapeShiftingResult FAILED = new ExShapeShiftingResult(RESULT_FAILED, 0, 0);
public static ExShapeShiftingResult CLOSE = new ExShapeShiftingResult(RESULT_CLOSE, 0, 0);
private final int _result;
private final int _targetItemId;