diff --git a/trunk/dist/game/data/AppearanceStones.xml b/trunk/dist/game/data/AppearanceStones.xml new file mode 100644 index 0000000000..759d1e50f3 --- /dev/null +++ b/trunk/dist/game/data/AppearanceStones.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/trunk/dist/game/data/scripts/handlers/MasterHandler.java b/trunk/dist/game/data/scripts/handlers/MasterHandler.java index 5a7bfb1fb2..5a03dcb5e8 100644 --- a/trunk/dist/game/data/scripts/handlers/MasterHandler.java +++ b/trunk/dist/game/data/scripts/handlers/MasterHandler.java @@ -170,6 +170,7 @@ import handlers.itemhandlers.EventItem; import handlers.itemhandlers.ExtractableItems; import handlers.itemhandlers.FishShots; import handlers.itemhandlers.Harvester; +import handlers.itemhandlers.ItemAppearance; import handlers.itemhandlers.ItemSkills; import handlers.itemhandlers.ItemSkillsTemplate; import handlers.itemhandlers.ManaPotion; @@ -474,6 +475,7 @@ public class MasterHandler ExtractableItems.class, FishShots.class, Harvester.class, + ItemAppearance.class, ItemSkills.class, ItemSkillsTemplate.class, ManaPotion.class, diff --git a/trunk/dist/game/data/scripts/handlers/itemhandlers/ItemAppearance.java b/trunk/dist/game/data/scripts/handlers/itemhandlers/ItemAppearance.java new file mode 100644 index 0000000000..2fe9947cce --- /dev/null +++ b/trunk/dist/game/data/scripts/handlers/itemhandlers/ItemAppearance.java @@ -0,0 +1,44 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +package handlers.itemhandlers; + +import com.l2jserver.gameserver.handler.IItemHandler; +import com.l2jserver.gameserver.model.actor.L2Playable; +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.model.items.instance.L2ItemInstance; +import com.l2jserver.gameserver.network.serverpackets.itemappearance.ExChoose_Shape_Shifting_Item; + +/** + * @author Erlandys + */ +public class ItemAppearance implements IItemHandler +{ + @Override + public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse) + { + if (!(playable instanceof L2PcInstance)) + { + return false; + } + final L2PcInstance activeChar = (L2PcInstance) playable; + if ((item == null) || !item.isEtcItem() || (item.isEtcItem() && (item.getEtcItem().getAppearanceStone() == null))) + { + return false; + } + activeChar.sendPacket(new ExChoose_Shape_Shifting_Item(item.getEtcItem().getAppearanceStone())); + activeChar.setUsingAppearanceStone(item); + return true; + } +} diff --git a/trunk/dist/game/data/stats/items/22400-22499.xml b/trunk/dist/game/data/stats/items/22400-22499.xml index fb37d4c5d3..613076a2e7 100644 --- a/trunk/dist/game/data/stats/items/22400-22499.xml +++ b/trunk/dist/game/data/stats/items/22400-22499.xml @@ -20,6 +20,7 @@ + diff --git a/trunk/dist/game/data/xsd/AppearanceStones.xsd b/trunk/dist/game/data/xsd/AppearanceStones.xsd new file mode 100644 index 0000000000..fb5e86c7cc --- /dev/null +++ b/trunk/dist/game/data/xsd/AppearanceStones.xsd @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/trunk/dist/tools/sql/game/items.sql b/trunk/dist/tools/sql/game/items.sql index 45ad0ecf48..42f773a9a4 100644 --- a/trunk/dist/tools/sql/game/items.sql +++ b/trunk/dist/tools/sql/game/items.sql @@ -11,6 +11,8 @@ CREATE TABLE IF NOT EXISTS `items` ( `custom_type2` INT DEFAULT 0, `mana_left` decimal(5,0) NOT NULL DEFAULT -1, `time` decimal(13) NOT NULL DEFAULT 0, + `appearance_id` int(11) NOT NULL DEFAULT 0, + `appearance_time` decimal(13) NOT NULL DEFAULT -1, PRIMARY KEY (`object_id`), KEY `owner_id` (`owner_id`), KEY `item_id` (`item_id`), diff --git a/trunk/java/com/l2jserver/gameserver/GameServer.java b/trunk/java/com/l2jserver/gameserver/GameServer.java index 9bf56e905d..1a36f2c112 100644 --- a/trunk/java/com/l2jserver/gameserver/GameServer.java +++ b/trunk/java/com/l2jserver/gameserver/GameServer.java @@ -48,6 +48,7 @@ import com.l2jserver.gameserver.data.sql.impl.SummonSkillsTable; import com.l2jserver.gameserver.data.sql.impl.TeleportLocationTable; import com.l2jserver.gameserver.data.xml.impl.AbilityPointsData; import com.l2jserver.gameserver.data.xml.impl.AdminData; +import com.l2jserver.gameserver.data.xml.impl.AppearanceStonesData; import com.l2jserver.gameserver.data.xml.impl.ArmorSetsData; import com.l2jserver.gameserver.data.xml.impl.BeautyShopData; import com.l2jserver.gameserver.data.xml.impl.BuyListData; @@ -224,6 +225,7 @@ public class GameServer SummonSkillsTable.getInstance(); printSection("Items"); + AppearanceStonesData.getInstance(); ItemTable.getInstance(); EnchantItemGroupsData.getInstance(); EnchantItemData.getInstance(); diff --git a/trunk/java/com/l2jserver/gameserver/data/sql/impl/OfflineTradersTable.java b/trunk/java/com/l2jserver/gameserver/data/sql/impl/OfflineTradersTable.java index 29c5ae2e6d..643133252d 100644 --- a/trunk/java/com/l2jserver/gameserver/data/sql/impl/OfflineTradersTable.java +++ b/trunk/java/com/l2jserver/gameserver/data/sql/impl/OfflineTradersTable.java @@ -203,7 +203,15 @@ public class OfflineTradersTable case BUY: while (items.next()) { - if (player.getBuyList().addItemByItemId(items.getInt(2), items.getLong(3), items.getLong(4)) == null) + if (player.getBuyList().addItemByItemId(items.getInt(2), items.getLong(3), items.getLong(4), 0, 0, 0, new int[] + { + 0, + 0, + 0, + 0, + 0, + 0 + }, 0) == null) { throw new NullPointerException(); } diff --git a/trunk/java/com/l2jserver/gameserver/data/xml/impl/AppearanceStonesData.java b/trunk/java/com/l2jserver/gameserver/data/xml/impl/AppearanceStonesData.java new file mode 100644 index 0000000000..c009efd036 --- /dev/null +++ b/trunk/java/com/l2jserver/gameserver/data/xml/impl/AppearanceStonesData.java @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2004-2015 L2J Server + * + * This file is part of L2J Server. + * + * L2J Server is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * L2J Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jserver.gameserver.data.xml.impl; + +import java.util.HashMap; +import java.util.logging.Level; + +import org.w3c.dom.Document; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; + +import com.l2jserver.gameserver.data.xml.IXmlReader; +import com.l2jserver.gameserver.model.entity.AppearanceStone; +import com.l2jserver.gameserver.model.entity.AppearanceStone.AppearanceItemType; +import com.l2jserver.gameserver.model.entity.AppearanceStone.StoneType; +import com.l2jserver.gameserver.model.items.type.CrystalType; + +/** + * @author Erlandys + */ +public final class AppearanceStonesData implements IXmlReader +{ + private final HashMap _stones = new HashMap<>(); + + protected AppearanceStonesData() + { + load(); + } + + @Override + public synchronized void load() + { + _stones.clear(); + parseDatapackFile("data/AppearanceStones.xml"); + LOGGER.log(Level.INFO, getClass().getSimpleName() + ": Loaded: " + _stones.size() + " appearance stones."); + } + + @Override + public void parseDocument(Document doc) + { + for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) + { + if ("list".equalsIgnoreCase(n.getNodeName())) + { + for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling()) + { + if ("stone".equalsIgnoreCase(d.getNodeName())) + { + final NamedNodeMap attrs = d.getAttributes(); + int itemId = parseInteger(attrs, "id"); + String type = parseString(attrs, "type"); + String itemType = parseString(attrs, "itemType"); + String grade = parseString(attrs, "maxGrade"); + long price = parseLong(attrs, "price", 0l); + int targetItem = parseInteger(attrs, "targetItem", 0); + long timeForAppearance = parseLong(attrs, "time", 0l); + CrystalType cType = CrystalType.valueOf(grade.toUpperCase()); + type = type.substring(0, 1).toUpperCase() + type.substring(1).toLowerCase(); + itemType = itemType.substring(0, 1).toUpperCase() + itemType.substring(1).toLowerCase(); + StoneType sType = StoneType.valueOf(type); + AppearanceItemType iType = AppearanceItemType.valueOf(itemType); + _stones.put(itemId, new AppearanceStone(itemId, sType, iType, cType.getId(), price, targetItem, timeForAppearance)); + } + } + } + } + } + + public AppearanceStone getStone(int itemId) + { + if (_stones.containsKey(itemId)) + { + return _stones.get(itemId); + } + return null; + } + + public static final AppearanceStonesData getInstance() + { + return SingletonHolder._instance; + } + + private static class SingletonHolder + { + protected static final AppearanceStonesData _instance = new AppearanceStonesData(); + } +} diff --git a/trunk/java/com/l2jserver/gameserver/model/ItemInfo.java b/trunk/java/com/l2jserver/gameserver/model/ItemInfo.java index a3dcf4bcb4..132277c03a 100644 --- a/trunk/java/com/l2jserver/gameserver/model/ItemInfo.java +++ b/trunk/java/com/l2jserver/gameserver/model/ItemInfo.java @@ -76,6 +76,9 @@ public class ItemInfo private int[] _option; + private int _appearanceId; + private long _appearanceTime; + /** * Get all information from L2ItemInstance to generate ItemInfo. * @param item @@ -148,6 +151,8 @@ public class ItemInfo _elemDefAttr[i] = item.getElementDefAttr(i); } _option = item.getEnchantOptions(); + _appearanceId = item.getAppearanceId(); + _appearanceTime = item.getAppearanceTime(); } public ItemInfo(L2ItemInstance item, int change) @@ -173,7 +178,14 @@ public class ItemInfo _enchant = item.getEnchant(); // Get the augmentation boni - _augmentation = 0; + if (item.isAugmented()) + { + _augmentation = item.getAugmentation().getAugmentationId(); + } + else + { + _augmentation = 0; + } // Get the quantity of the L2ItemInstance _count = item.getCount(); @@ -189,9 +201,8 @@ public class ItemInfo _change = 0; // Get shadow item mana - _mana = -1; - _time = -9999; - + _mana = item.getMana(); + _time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -9999; _location = item.getLocationSlot(); _elemAtkType = item.getAttackElementType(); @@ -200,8 +211,9 @@ public class ItemInfo { _elemDefAttr[i] = item.getElementDefAttr(i); } - _option = item.getEnchantOptions(); + _appearanceId = item.getAppearanceId(); + _appearanceTime = item.getAppearanceTime(); } public ItemInfo(Product item) @@ -291,6 +303,8 @@ public class ItemInfo _elemDefAttr[i] = item.getElementDefAttr(i); } _option = item.getEnchantOptions(); + _appearanceId = item.getAppearanceId(); + _appearanceTime = item.getAppearanceTime(); } public int getObjectId() @@ -377,4 +391,14 @@ public class ItemInfo { return _option; } + + public int getAppearanceId() + { + return _appearanceId; + } + + public long getAppearanceTime() + { + return _appearanceTime; + } } diff --git a/trunk/java/com/l2jserver/gameserver/model/TradeItem.java b/trunk/java/com/l2jserver/gameserver/model/TradeItem.java index ed86d44262..d3a3ecda6c 100644 --- a/trunk/java/com/l2jserver/gameserver/model/TradeItem.java +++ b/trunk/java/com/l2jserver/gameserver/model/TradeItem.java @@ -23,6 +23,7 @@ import com.l2jserver.gameserver.model.items.instance.L2ItemInstance; public class TradeItem { + private L2ItemInstance _itemInstance; private int _objectId; private final L2Item _item; private final int _location; @@ -44,9 +45,17 @@ public class TradeItem 0 }; private final int[] _enchantOptions; + private final boolean _isAugmented; + private final L2Augmentation _augmentation; + private final int _mana; + private final boolean _isTimeLimited; + private final int _time; + private final int _appearanceId; + private final long _appearanceTime; public TradeItem(L2ItemInstance item, long count, long price) { + _itemInstance = item; _objectId = item.getObjectId(); _item = item.getItem(); _location = item.getLocationSlot(); @@ -62,10 +71,18 @@ public class TradeItem _elemDefAttr[i] = item.getElementDefAttr(i); } _enchantOptions = item.getEnchantOptions(); + _isAugmented = item.isAugmented(); + _augmentation = item.getAugmentation(); + _mana = item.getMana(); + _isTimeLimited = item.isTimeLimitedItem(); + _time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -9999; + _appearanceId = item.getAppearanceId(); + _appearanceTime = item.getAppearanceTime(); } - public TradeItem(L2Item item, long count, long price) + public TradeItem(L2Item item, long count, long price, int enchantLevel, int attackAttribute, int attackAttributeValue, int defenseAttributes[], int appearanceId) { + _itemInstance = null; _objectId = 0; _item = item; _location = 0; @@ -75,13 +92,25 @@ public class TradeItem _count = count; _storeCount = count; _price = price; - _elemAtkType = Elementals.NONE; - _elemAtkPower = 0; + _elemAtkType = (byte) attackAttribute; + _elemAtkPower = attackAttributeValue; + for (byte i = 0; i < 6; i++) + { + _elemDefAttr[i] = defenseAttributes[i]; + } _enchantOptions = L2ItemInstance.DEFAULT_ENCHANT_OPTIONS; + _isAugmented = false; + _augmentation = null; + _mana = -1; + _isTimeLimited = false; + _time = -9999; + _appearanceId = appearanceId; + _appearanceTime = -1; } - public TradeItem(TradeItem item, long count, long price) + public TradeItem(TradeItem item, long count, long price, int enchantLevel, int attackAttribute, int attackAttributeValue, int defenseAttributes[], int appearanceId) { + _itemInstance = item.getItemInstance(); _objectId = item.getObjectId(); _item = item.getItem(); _location = item.getLocationSlot(); @@ -98,6 +127,23 @@ public class TradeItem _elemDefAttr[i] = item.getElementDefAttr(i); } _enchantOptions = item.getEnchantOptions(); + _isAugmented = item.isAugmented(); + _augmentation = item.getAugmentation(); + _mana = item.getMana(); + _isTimeLimited = item.isTimeLimitedItem(); + _time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -9999; + _appearanceId = item.getAppearanceId(); + _appearanceTime = item.getAppearanceTime(); + } + + public L2ItemInstance getItemInstance() + { + return _itemInstance; + } + + public void setItemInstance(L2ItemInstance it) + { + _itemInstance = it; } public void setObjectId(int objectId) @@ -184,4 +230,39 @@ public class TradeItem { return _enchantOptions; } + + public boolean isAugmented() + { + return _isAugmented; + } + + public L2Augmentation getAugmentation() + { + return _augmentation; + } + + public int getMana() + { + return _mana; + } + + public boolean isTimeLimitedItem() + { + return _isTimeLimited; + } + + public int getAppearanceId() + { + return _appearanceId; + } + + public long getAppearanceTime() + { + return _appearanceTime; + } + + public int getRemainingTime() + { + return _time; + } } diff --git a/trunk/java/com/l2jserver/gameserver/model/TradeList.java b/trunk/java/com/l2jserver/gameserver/model/TradeList.java index 4317b7c1fe..ec40b69e66 100644 --- a/trunk/java/com/l2jserver/gameserver/model/TradeList.java +++ b/trunk/java/com/l2jserver/gameserver/model/TradeList.java @@ -126,7 +126,12 @@ public class TradeList FastList list = FastList.newInstance(); for (TradeItem item : _items) { - item = new TradeItem(item, item.getCount(), item.getPrice()); + int el[] = new int[6]; + for (int i = 0; i < 6; i++) + { + el[i] = item.getElementDefAttr((byte) i); + } + item = new TradeItem(item, item.getCount(), item.getPrice(), item.getEnchant(), item.getAttackElementType(), item.getAttackElementPower(), el, item.getAppearanceId()); inventory.adjustAvailableItem(item); list.add(item); } @@ -273,9 +278,14 @@ public class TradeList * @param itemId * @param count * @param price + * @param enchantLevel + * @param attackAttribute + * @param attackAttributeValue + * @param defenseAttributes + * @param appearanceId * @return */ - public synchronized TradeItem addItemByItemId(int itemId, long count, long price) + public synchronized TradeItem addItemByItemId(int itemId, long count, long price, int enchantLevel, int attackAttribute, int attackAttributeValue, int defenseAttributes[], int appearanceId) { if (isLocked()) { @@ -307,7 +317,7 @@ public class TradeList return null; } - TradeItem titem = new TradeItem(item, count, price); + TradeItem titem = new TradeItem(item, count, price, enchantLevel, attackAttribute, attackAttributeValue, defenseAttributes, appearanceId); _items.add(titem); // If Player has already confirmed this trade, invalidate the confirmation diff --git a/trunk/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java b/trunk/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java index 02cb7eaf2a..dd12a8de7f 100644 --- a/trunk/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java +++ b/trunk/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java @@ -4850,6 +4850,15 @@ public final class L2PcInstance extends L2Playable } else { + if ((getPrivateStoreType() != PrivateStoreType.NONE) && !isAlikeDead()) + { + setPrivateStoreType(PrivateStoreType.NONE); + if (isSitting()) + { + standUp(); + } + return; + } if (isInsideZone(ZoneId.NO_STORE)) { sendPacket(SystemMessageId.YOU_CANNOT_OPEN_A_PRIVATE_STORE_HERE); @@ -15087,4 +15096,39 @@ public final class L2PcInstance extends L2Playable { _secondCompoundOID = secondCompoundOID; } + + L2ItemInstance _usingAStone = null; + + public L2ItemInstance getUsingAppearanceStone() + { + return _usingAStone; + } + + public void setUsingAppearanceStone(L2ItemInstance stone) + { + _usingAStone = stone; + } + + L2ItemInstance _appearanceItem = null; + L2ItemInstance _targetAppearanceItem = null; + + public L2ItemInstance getAppearanceItem() + { + return _appearanceItem; + } + + public void setAppearanceItem(L2ItemInstance item) + { + _appearanceItem = item; + } + + public L2ItemInstance getTargetAppearanceItem() + { + return _targetAppearanceItem; + } + + public void setTargetAppearanceItem(L2ItemInstance item) + { + _targetAppearanceItem = item; + } } diff --git a/trunk/java/com/l2jserver/gameserver/model/entity/AppearanceStone.java b/trunk/java/com/l2jserver/gameserver/model/entity/AppearanceStone.java new file mode 100644 index 0000000000..c9141b8ea6 --- /dev/null +++ b/trunk/java/com/l2jserver/gameserver/model/entity/AppearanceStone.java @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2004-2015 L2J Server + * + * This file is part of L2J Server. + * + * L2J Server is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * L2J Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jserver.gameserver.model.entity; + +/** + * @author Erlandas + */ +public class AppearanceStone +{ + public enum StoneType + { + None, + Normal, + Blessed, + Fixed, + Restore + } + + public enum AppearanceItemType + { + None, + Weapon, + Armor, + Accessory, + All + } + + int _itemId; + StoneType _type; + AppearanceItemType _itemType; + int _maxGrade; + long _price; + int _targetItem; + long _timeForAppearance; + + public AppearanceStone(int itemId, StoneType type, AppearanceItemType itemType, int maxGrade, long price, int targetItem, long timeForAppearance) + { + _itemId = itemId; + _type = type; + _itemType = itemType; + _maxGrade = maxGrade; + _price = price; + _targetItem = targetItem; + _timeForAppearance = timeForAppearance; + } + + public int getItemId() + { + return _itemId; + } + + public StoneType getType() + { + return _type; + } + + public AppearanceItemType getItemType() + { + return _itemType; + } + + public int getMaxGrade() + { + return _maxGrade; + } + + public long getPrice() + { + return _price; + } + + public int getTargetItem() + { + return _targetItem; + } + + public long getTimeForAppearance() + { + return _timeForAppearance; + } +} diff --git a/trunk/java/com/l2jserver/gameserver/model/itemcontainer/Inventory.java b/trunk/java/com/l2jserver/gameserver/model/itemcontainer/Inventory.java index 8836b0bc0d..745d7e7294 100644 --- a/trunk/java/com/l2jserver/gameserver/model/itemcontainer/Inventory.java +++ b/trunk/java/com/l2jserver/gameserver/model/itemcontainer/Inventory.java @@ -1112,6 +1112,12 @@ public abstract class Inventory extends ItemContainer return ((item != null) && (item.getAugmentation() != null)) ? item.getAugmentation().getAugmentationId() : 0; } + public int getPaperdollVisualId(int slot) + { + final L2ItemInstance item = _paperdoll[slot]; + return (item != null) ? item.getAppearanceId() : 0; + } + /** * Returns the objectID associated to the item in the paperdoll slot * @param slot : int pointing out the slot @@ -1778,7 +1784,7 @@ public abstract class Inventory extends ItemContainer public void restore() { try (Connection con = L2DatabaseFactory.getInstance().getConnection(); - PreparedStatement statement = con.prepareStatement("SELECT object_id, item_id, count, enchant_level, loc, loc_data, custom_type1, custom_type2, mana_left, time FROM items WHERE owner_id=? AND (loc=? OR loc=?) ORDER BY loc_data")) + PreparedStatement statement = con.prepareStatement("SELECT object_id, item_id, count, enchant_level, loc, loc_data, custom_type1, custom_type2, mana_left, time, appearance_id, appearance_time FROM items WHERE owner_id=? AND (loc=? OR loc=?) ORDER BY loc_data")) { statement.setInt(1, getOwnerId()); statement.setString(2, getBaseLocation().name()); diff --git a/trunk/java/com/l2jserver/gameserver/model/items/L2Armor.java b/trunk/java/com/l2jserver/gameserver/model/items/L2Armor.java index a7c48aecc2..3891319904 100644 --- a/trunk/java/com/l2jserver/gameserver/model/items/L2Armor.java +++ b/trunk/java/com/l2jserver/gameserver/model/items/L2Armor.java @@ -19,6 +19,7 @@ package com.l2jserver.gameserver.model.items; import com.l2jserver.gameserver.model.StatsSet; +import com.l2jserver.gameserver.model.entity.AppearanceStone; import com.l2jserver.gameserver.model.holders.SkillHolder; import com.l2jserver.gameserver.model.items.type.ArmorType; import com.l2jserver.gameserver.model.skills.Skill; @@ -117,4 +118,10 @@ public final class L2Armor extends L2Item } return _enchant4Skill.getSkill(); } + + @Override + public AppearanceStone getAppearanceStone() + { + return null; + } } diff --git a/trunk/java/com/l2jserver/gameserver/model/items/L2EtcItem.java b/trunk/java/com/l2jserver/gameserver/model/items/L2EtcItem.java index c5aa4ddfcc..4e2447b03a 100644 --- a/trunk/java/com/l2jserver/gameserver/model/items/L2EtcItem.java +++ b/trunk/java/com/l2jserver/gameserver/model/items/L2EtcItem.java @@ -21,8 +21,10 @@ package com.l2jserver.gameserver.model.items; import java.util.ArrayList; import java.util.List; +import com.l2jserver.gameserver.data.xml.impl.AppearanceStonesData; import com.l2jserver.gameserver.model.L2ExtractableProduct; import com.l2jserver.gameserver.model.StatsSet; +import com.l2jserver.gameserver.model.entity.AppearanceStone; import com.l2jserver.gameserver.model.itemcontainer.Inventory; import com.l2jserver.gameserver.model.items.type.EtcItemType; import com.l2jserver.util.StringUtil; @@ -37,6 +39,7 @@ public final class L2EtcItem extends L2Item private final boolean _isBlessed; private final List _extractableItems; private final boolean _isInfinite; + private final AppearanceStone _appearanceStone; /** * Constructor for EtcItem. @@ -120,6 +123,7 @@ public final class L2EtcItem extends L2Item } _isInfinite = set.getBoolean("is_infinite", false); + _appearanceStone = (_handler != null) && _handler.equalsIgnoreCase("ItemAppearance") ? AppearanceStonesData.getInstance().getStone(getId()) : null; } /** @@ -171,4 +175,10 @@ public final class L2EtcItem extends L2Item { return _isInfinite; } + + @Override + public AppearanceStone getAppearanceStone() + { + return _appearanceStone; + } } diff --git a/trunk/java/com/l2jserver/gameserver/model/items/L2Item.java b/trunk/java/com/l2jserver/gameserver/model/items/L2Item.java index 7ddf60ecf6..e39861bb13 100644 --- a/trunk/java/com/l2jserver/gameserver/model/items/L2Item.java +++ b/trunk/java/com/l2jserver/gameserver/model/items/L2Item.java @@ -34,6 +34,7 @@ import com.l2jserver.gameserver.model.actor.L2Character; import com.l2jserver.gameserver.model.actor.L2Summon; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.model.conditions.Condition; +import com.l2jserver.gameserver.model.entity.AppearanceStone; import com.l2jserver.gameserver.model.events.ListenersContainer; import com.l2jserver.gameserver.model.holders.SkillHolder; import com.l2jserver.gameserver.model.interfaces.IIdentifiable; @@ -963,4 +964,6 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable { return null; } + + public abstract AppearanceStone getAppearanceStone(); } diff --git a/trunk/java/com/l2jserver/gameserver/model/items/L2WarehouseItem.java b/trunk/java/com/l2jserver/gameserver/model/items/L2WarehouseItem.java index d0e1726713..5c76d240fb 100644 --- a/trunk/java/com/l2jserver/gameserver/model/items/L2WarehouseItem.java +++ b/trunk/java/com/l2jserver/gameserver/model/items/L2WarehouseItem.java @@ -64,6 +64,9 @@ public class L2WarehouseItem private final int _time; + private final int _appearanceId; + private final long _appearanceTime; + public L2WarehouseItem(L2ItemInstance item) { _item = item.getItem(); @@ -94,6 +97,8 @@ public class L2WarehouseItem _elemDefAttr[i] = item.getElementDefAttr(i); } _enchantOptions = item.getEnchantOptions(); + _appearanceId = item.getAppearanceId(); + _appearanceTime = item.getAppearanceTime(); } /** @@ -296,4 +301,14 @@ public class L2WarehouseItem { return _item.toString(); } + + public int getAppearanceId() + { + return _appearanceId; + } + + public long getAppearanceTime() + { + return _appearanceTime; + } } diff --git a/trunk/java/com/l2jserver/gameserver/model/items/L2Weapon.java b/trunk/java/com/l2jserver/gameserver/model/items/L2Weapon.java index 5bc89e1f97..0508e2a2ed 100644 --- a/trunk/java/com/l2jserver/gameserver/model/items/L2Weapon.java +++ b/trunk/java/com/l2jserver/gameserver/model/items/L2Weapon.java @@ -26,6 +26,7 @@ import com.l2jserver.gameserver.model.actor.L2Npc; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.model.conditions.Condition; import com.l2jserver.gameserver.model.conditions.ConditionGameChance; +import com.l2jserver.gameserver.model.entity.AppearanceStone; import com.l2jserver.gameserver.model.events.EventDispatcher; import com.l2jserver.gameserver.model.events.impl.character.npc.OnNpcSkillSee; import com.l2jserver.gameserver.model.holders.SkillHolder; @@ -449,4 +450,10 @@ public final class L2Weapon extends L2Item caster.sendPacket(sm); } } + + @Override + public AppearanceStone getAppearanceStone() + { + return null; + } } diff --git a/trunk/java/com/l2jserver/gameserver/model/items/instance/L2ItemInstance.java b/trunk/java/com/l2jserver/gameserver/model/items/instance/L2ItemInstance.java index a82a5d6ada..270227043a 100644 --- a/trunk/java/com/l2jserver/gameserver/model/items/instance/L2ItemInstance.java +++ b/trunk/java/com/l2jserver/gameserver/model/items/instance/L2ItemInstance.java @@ -170,6 +170,9 @@ public final class L2ItemInstance extends L2Object private final List _enchantOptions = new ArrayList<>(); + private int _appearanceId = 0; + private long _appearanceTime = -1; + /** * Constructor of the L2ItemInstance from the objectId and the itemId. * @param objectId : int designating the ID of the object in the world @@ -1499,8 +1502,8 @@ public final class L2ItemInstance extends L2Object public static L2ItemInstance restoreFromDb(int ownerId, ResultSet rs) { L2ItemInstance inst = null; - int objectId, item_id, loc_data, enchant_level, custom_type1, custom_type2, manaLeft; - long time, count; + int objectId, item_id, loc_data, enchant_level, custom_type1, custom_type2, manaLeft, appearance_id; + long time, count, appearance_time; ItemLocation loc; try { @@ -1514,6 +1517,8 @@ public final class L2ItemInstance extends L2Object custom_type2 = rs.getInt("custom_type2"); manaLeft = rs.getInt("mana_left"); time = rs.getLong("time"); + appearance_id = rs.getInt("appearance_id"); + appearance_time = rs.getLong("appearance_time"); } catch (Exception e) { @@ -1540,6 +1545,8 @@ public final class L2ItemInstance extends L2Object // Setup life time for shadow weapons inst._mana = manaLeft; inst._time = time; + inst._appearanceId = appearance_id; + inst._appearanceTime = appearance_time; // load augmentation and elemental enchant if (inst.isEquipable()) @@ -1658,7 +1665,7 @@ public final class L2ItemInstance extends L2Object } try (Connection con = L2DatabaseFactory.getInstance().getConnection(); - PreparedStatement ps = con.prepareStatement("UPDATE items SET owner_id=?,count=?,loc=?,loc_data=?,enchant_level=?,custom_type1=?,custom_type2=?,mana_left=?,time=? " + "WHERE object_id = ?")) + PreparedStatement ps = con.prepareStatement("UPDATE items SET owner_id=?,count=?,loc=?,loc_data=?,enchant_level=?,custom_type1=?,custom_type2=?,mana_left=?,time=?,appearance_id=?,appearance_time=? " + "WHERE object_id = ?")) { ps.setInt(1, _ownerId); ps.setLong(2, getCount()); @@ -1669,7 +1676,9 @@ public final class L2ItemInstance extends L2Object ps.setInt(7, getCustomType2()); ps.setInt(8, getMana()); ps.setLong(9, getTime()); - ps.setInt(10, getObjectId()); + ps.setInt(10, getAppearanceId()); + ps.setLong(11, getAppearanceTime()); + ps.setInt(12, getObjectId()); ps.executeUpdate(); _existsInDb = true; _storedInDb = true; @@ -2252,4 +2261,26 @@ public final class L2ItemInstance extends L2Object _lifeTimeTask = null; } } + + public int getAppearanceId() + { + return _appearanceId; + } + + public void setAppearanceId(int appearanceId) + { + _storedInDb = false; + _appearanceId = appearanceId; + } + + public long getAppearanceTime() + { + _storedInDb = false; + return _appearanceTime; + } + + public void setAppearanceTime(long appearanceTime) + { + _appearanceTime = appearanceTime; + } } diff --git a/trunk/java/com/l2jserver/gameserver/network/L2GameClient.java b/trunk/java/com/l2jserver/gameserver/network/L2GameClient.java index d5d5553edd..8f96e8decd 100644 --- a/trunk/java/com/l2jserver/gameserver/network/L2GameClient.java +++ b/trunk/java/com/l2jserver/gameserver/network/L2GameClient.java @@ -276,7 +276,6 @@ public final class L2GameClient extends MMOClient> i { return; } - getConnection().sendPacket(gsp); gsp.runImpl(); } diff --git a/trunk/java/com/l2jserver/gameserver/network/L2GamePacketHandler.java b/trunk/java/com/l2jserver/gameserver/network/L2GamePacketHandler.java index e9726aa7a7..51dec82775 100644 --- a/trunk/java/com/l2jserver/gameserver/network/L2GamePacketHandler.java +++ b/trunk/java/com/l2jserver/gameserver/network/L2GamePacketHandler.java @@ -38,6 +38,10 @@ import com.l2jserver.gameserver.network.clientpackets.friend.RequestFriendList; import com.l2jserver.gameserver.network.clientpackets.friend.RequestSendFriendMsg; import com.l2jserver.gameserver.network.clientpackets.friend.RequestUpdateBlockMemo; import com.l2jserver.gameserver.network.clientpackets.friend.RequestUpdateFriendMemo; +import com.l2jserver.gameserver.network.clientpackets.itemappearance.RequestExCancelShape_Shifting_Item; +import com.l2jserver.gameserver.network.clientpackets.itemappearance.RequestExTryToPut_Shape_Shifting_EnchantSupportItem; +import com.l2jserver.gameserver.network.clientpackets.itemappearance.RequestExTryToPut_Shape_Shifting_TargetItem; +import com.l2jserver.gameserver.network.clientpackets.itemappearance.RequestShape_Shifting_Item; import com.l2jserver.gameserver.network.clientpackets.mentoring.ConfirmMenteeAdd; import com.l2jserver.gameserver.network.clientpackets.mentoring.RequestMenteeAdd; import com.l2jserver.gameserver.network.clientpackets.mentoring.RequestMenteeWaitingList; @@ -1459,16 +1463,16 @@ public final class L2GamePacketHandler implements IPacketHandler, // msg = new ExSysstring(); (chdS) break; case 0xC4: - // msg = new RequestExTryToPutShapeShiftingTargetItem(); + msg = new RequestExTryToPut_Shape_Shifting_TargetItem(); break; case 0xC5: - // msg = new RequestExTryToPutShapeShiftingEnchantSupportItem(); + msg = new RequestExTryToPut_Shape_Shifting_EnchantSupportItem(); break; case 0xC6: - // msg = new RequestExCancelShape_Shifting_Item(); + msg = new RequestExCancelShape_Shifting_Item(); break; case 0xC7: - // msg = new RequestShapeShiftingItem(); + msg = new RequestShape_Shifting_Item(); break; case 0xC8: // msg = new NCGuardSendDataToServer(); // (chdb) diff --git a/trunk/java/com/l2jserver/gameserver/network/clientpackets/SetPrivateStoreListBuy.java b/trunk/java/com/l2jserver/gameserver/network/clientpackets/SetPrivateStoreListBuy.java index 1acb76b239..7f9ab87b08 100644 --- a/trunk/java/com/l2jserver/gameserver/network/clientpackets/SetPrivateStoreListBuy.java +++ b/trunk/java/com/l2jserver/gameserver/network/clientpackets/SetPrivateStoreListBuy.java @@ -24,6 +24,7 @@ import com.l2jserver.Config; import com.l2jserver.gameserver.enums.PrivateStoreType; import com.l2jserver.gameserver.model.TradeList; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.model.items.instance.L2ItemInstance; import com.l2jserver.gameserver.model.zone.ZoneId; import com.l2jserver.gameserver.network.SystemMessageId; import com.l2jserver.gameserver.network.serverpackets.ActionFailed; @@ -47,6 +48,11 @@ public final class SetPrivateStoreListBuy extends L2GameClientPacket @Override protected void readImpl() { + L2PcInstance player = getClient().getActiveChar(); + if (player == null) + { + return; + } int count = readD(); if ((count < 1) || (count > Config.MAX_ITEM_IN_PACKET) || ((count * BATCH_LENGTH) != _buf.remaining())) { @@ -57,9 +63,7 @@ public final class SetPrivateStoreListBuy extends L2GameClientPacket for (int i = 0; i < count; i++) { int itemId = readD(); - - readH(); // TODO analyse this - readH(); // TODO analyse this + int enchantLevel = readD(); long cnt = readQ(); long price = readQ(); @@ -69,12 +73,37 @@ public final class SetPrivateStoreListBuy extends L2GameClientPacket _items = null; return; } - readD(); // Unk - readD(); // Unk - readD(); // Unk - readD(); // Unk - - _items[i] = new Item(itemId, cnt, price); + int attackAttribute = readH(); // Attack Attribute Type + int attackAttributeValue = readH(); // Attack Attribute Value + int defenseAttributes[] = new int[6]; + for (int h = 0; h < 6; h++) + { + defenseAttributes[i] = readH(); // Defense attributes + } + int appearanceId = readD(); // Appearance ID + boolean canUse = false; + for (L2ItemInstance item : player.getInventory().getItemsByItemId(itemId)) + { + if ((enchantLevel == item.getEnchantLevel()) && (attackAttribute == item.getAttackElementType()) && (attackAttributeValue == item.getAttackElementPower()) && (appearanceId == item.getAppearanceId()) && (item.getElementDefAttr((byte) 0) == defenseAttributes[0]) && (item.getElementDefAttr((byte) 1) == defenseAttributes[1]) && (item.getElementDefAttr((byte) 2) == defenseAttributes[2]) && (item.getElementDefAttr((byte) 3) == defenseAttributes[3]) && (item.getElementDefAttr((byte) 4) == defenseAttributes[4]) && (item.getElementDefAttr((byte) 5) == defenseAttributes[5])) + { + canUse = true; + break; + } + } + if (!canUse) + { + enchantLevel = 0; + attackAttribute = -1; + attackAttributeValue = 0; + defenseAttributes[0] = 0; + defenseAttributes[1] = 0; + defenseAttributes[2] = 0; + defenseAttributes[3] = 0; + defenseAttributes[4] = 0; + defenseAttributes[5] = 0; + appearanceId = 0; + } + _items[i] = new Item(itemId, cnt, price, enchantLevel, attackAttribute, attackAttributeValue, defenseAttributes, appearanceId); } } @@ -170,12 +199,22 @@ public final class SetPrivateStoreListBuy extends L2GameClientPacket private final int _itemId; private final long _count; private final long _price; + private final int _enchantLevel; + private final int _attackAttribute; + private final int _attackAttributeValue; + private final int _defenseAttributes[]; + private final int _appearanceId; - public Item(int id, long num, long pri) + public Item(int itemId, long cnt, long price, int enchantLevel, int attackAttribute, int attackAttributeValue, int defenseAttributes[], int appearanceId) { - _itemId = id; - _count = num; - _price = pri; + _itemId = itemId; + _count = cnt; + _price = price; + _enchantLevel = enchantLevel; + _attackAttribute = attackAttribute; + _attackAttributeValue = attackAttributeValue; + _defenseAttributes = defenseAttributes; + _appearanceId = appearanceId; } public boolean addToTradeList(TradeList list) @@ -185,7 +224,7 @@ public final class SetPrivateStoreListBuy extends L2GameClientPacket return false; } - list.addItemByItemId(_itemId, _count, _price); + list.addItemByItemId(_itemId, _count, _price, _enchantLevel, _attackAttribute, _attackAttributeValue, _defenseAttributes, _appearanceId); return true; } diff --git a/trunk/java/com/l2jserver/gameserver/network/clientpackets/itemappearance/RequestExCancelShape_Shifting_Item.java b/trunk/java/com/l2jserver/gameserver/network/clientpackets/itemappearance/RequestExCancelShape_Shifting_Item.java new file mode 100644 index 0000000000..e31fb3f719 --- /dev/null +++ b/trunk/java/com/l2jserver/gameserver/network/clientpackets/itemappearance/RequestExCancelShape_Shifting_Item.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2004-2015 L2J Server + * + * This file is part of L2J Server. + * + * L2J Server is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * L2J Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jserver.gameserver.network.clientpackets.itemappearance; + +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket; + +public final class RequestExCancelShape_Shifting_Item extends L2GameClientPacket +{ + private static final String _C__D0_C6_REQUESTEXCANCELSHAPE_SHIFTING_ITEM = "[C] D0:C6 RequestExCancelShape_Shifting_Item"; + + @Override + protected void readImpl() + { + } + + @Override + protected void runImpl() + { + L2PcInstance player = getClient().getActiveChar(); + if (player == null) + { + return; + } + player.setAppearanceItem(null); + player.setTargetAppearanceItem(null); + player.setUsingAppearanceStone(null); + } + + @Override + public String getType() + { + return _C__D0_C6_REQUESTEXCANCELSHAPE_SHIFTING_ITEM; + } +} diff --git a/trunk/java/com/l2jserver/gameserver/network/clientpackets/itemappearance/RequestExTryToPut_Shape_Shifting_EnchantSupportItem.java b/trunk/java/com/l2jserver/gameserver/network/clientpackets/itemappearance/RequestExTryToPut_Shape_Shifting_EnchantSupportItem.java new file mode 100644 index 0000000000..d4bf9e469d --- /dev/null +++ b/trunk/java/com/l2jserver/gameserver/network/clientpackets/itemappearance/RequestExTryToPut_Shape_Shifting_EnchantSupportItem.java @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2004-2015 L2J Server + * + * This file is part of L2J Server. + * + * L2J Server is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * L2J Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jserver.gameserver.network.clientpackets.itemappearance; + +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.model.items.instance.L2ItemInstance; +import com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket; +import com.l2jserver.gameserver.network.serverpackets.itemappearance.ExPut_Shape_Shifting_Extraction_Item_Result; +import com.l2jserver.gameserver.network.serverpackets.itemappearance.ExPut_Shape_Shifting_Target_Item_Result; + +public final class RequestExTryToPut_Shape_Shifting_EnchantSupportItem extends L2GameClientPacket +{ + private static final String _C__D0_C5_REQUESTEXTRYTOPUT_SHAPE_SHIFTING_ENCHANTSUPPORTITEM = "[C] D0:C5 RequestExTryToPut_Shape_Shifting_EnchantSupportItem"; + + private int _itemOID; + + @Override + protected void readImpl() + { + readD(); + _itemOID = readD(); + } + + @Override + protected void runImpl() + { + L2PcInstance player = getClient().getActiveChar(); + if (player == null) + { + return; + } + + L2ItemInstance stone = player.getUsingAppearanceStone(); + if ((stone == null) || (stone.getEtcItem().getAppearanceStone() == null)) + { + player.sendPacket(new ExPut_Shape_Shifting_Target_Item_Result(0)); + return; + } + L2ItemInstance targetItem = player.getInventory().getItemByObjectId(_itemOID); + if (targetItem == null) + { + player.sendPacket(new ExPut_Shape_Shifting_Target_Item_Result(0)); + return; + } + if (stone.getEtcItem().getAppearanceStone().getMaxGrade() < targetItem.getItem().getCrystalType().getId()) + { + player.sendPacket(new ExPut_Shape_Shifting_Target_Item_Result(0)); + return; + } + L2ItemInstance item = player.getAppearanceItem(); + if (item == null) + { + player.sendPacket(new ExPut_Shape_Shifting_Target_Item_Result(0)); + return; + } + if (!item.getItemType().equals(targetItem.getItemType())) + { + player.sendPacket(new ExPut_Shape_Shifting_Extraction_Item_Result(0)); + return; + } + if ((item.isWeapon() && (item.getWeaponItem().getItemType() != targetItem.getWeaponItem().getItemType())) || (item.isArmor() && (item.getArmorItem().getItemType() != targetItem.getArmorItem().getItemType()))) + { + player.sendPacket(new ExPut_Shape_Shifting_Extraction_Item_Result(0)); + return; + } + player.sendPacket(new ExPut_Shape_Shifting_Target_Item_Result(1)); + player.setTargetAppearanceItem(targetItem); + } + + @Override + public String getType() + { + return _C__D0_C5_REQUESTEXTRYTOPUT_SHAPE_SHIFTING_ENCHANTSUPPORTITEM; + } +} diff --git a/trunk/java/com/l2jserver/gameserver/network/clientpackets/itemappearance/RequestExTryToPut_Shape_Shifting_TargetItem.java b/trunk/java/com/l2jserver/gameserver/network/clientpackets/itemappearance/RequestExTryToPut_Shape_Shifting_TargetItem.java new file mode 100644 index 0000000000..bf8d00cae3 --- /dev/null +++ b/trunk/java/com/l2jserver/gameserver/network/clientpackets/itemappearance/RequestExTryToPut_Shape_Shifting_TargetItem.java @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2004-2015 L2J Server + * + * This file is part of L2J Server. + * + * L2J Server is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * L2J Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jserver.gameserver.network.clientpackets.itemappearance; + +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.model.entity.AppearanceStone.AppearanceItemType; +import com.l2jserver.gameserver.model.items.instance.L2ItemInstance; +import com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket; +import com.l2jserver.gameserver.network.serverpackets.itemappearance.ExPut_Shape_Shifting_Extraction_Item_Result; + +public final class RequestExTryToPut_Shape_Shifting_TargetItem extends L2GameClientPacket +{ + private static final String _C__D0_C4_REQUESTEXTRYTOPUT_SHAPE_SHIFTING_TARGETITEM = "[C] D0:C4 RequestExTryToPut_Shape_Shifting_TargetItem"; + + private int _itemId; + + @Override + protected void readImpl() + { + _itemId = readD(); + } + + @Override + protected void runImpl() + { + L2PcInstance player = getClient().getActiveChar(); + if (player == null) + { + return; + } + L2ItemInstance item = player.getInventory().getItemByObjectId(_itemId); + if (item == null) + { + return; + } + L2ItemInstance stone = player.getUsingAppearanceStone(); + if ((stone == null) || (stone.getEtcItem().getAppearanceStone() == null)) + { + return; + } + + if (stone.getEtcItem().getAppearanceStone().getMaxGrade() < item.getItem().getCrystalType().getId()) + { + player.sendPacket(new ExPut_Shape_Shifting_Extraction_Item_Result(0)); + return; + } + boolean isSameType = ((stone.getEtcItem().getAppearanceStone().getItemType() == AppearanceItemType.Armor) && item.isArmor()) || ((stone.getEtcItem().getAppearanceStone().getItemType() == AppearanceItemType.Weapon) && item.isWeapon()) || ((stone.getEtcItem().getAppearanceStone().getItemType() == AppearanceItemType.Accessory) && item.isArmor()) || ((stone.getEtcItem().getAppearanceStone().getItemType() == AppearanceItemType.All)); + if (!isSameType) + { + player.sendPacket(new ExPut_Shape_Shifting_Extraction_Item_Result(0)); + return; + } + player.setAppearanceItem(item); + player.sendPacket(new ExPut_Shape_Shifting_Extraction_Item_Result(1, stone.getEtcItem().getAppearanceStone().getPrice())); + } + + @Override + public String getType() + { + return _C__D0_C4_REQUESTEXTRYTOPUT_SHAPE_SHIFTING_TARGETITEM; + } +} diff --git a/trunk/java/com/l2jserver/gameserver/network/clientpackets/itemappearance/RequestShape_Shifting_Item.java b/trunk/java/com/l2jserver/gameserver/network/clientpackets/itemappearance/RequestShape_Shifting_Item.java new file mode 100644 index 0000000000..15372792c7 --- /dev/null +++ b/trunk/java/com/l2jserver/gameserver/network/clientpackets/itemappearance/RequestShape_Shifting_Item.java @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2004-2015 L2J Server + * + * This file is part of L2J Server. + * + * L2J Server is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * L2J Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jserver.gameserver.network.clientpackets.itemappearance; + +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.model.entity.AppearanceStone; +import com.l2jserver.gameserver.model.entity.AppearanceStone.StoneType; +import com.l2jserver.gameserver.model.items.instance.L2ItemInstance; +import com.l2jserver.gameserver.network.SystemMessageId; +import com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket; +import com.l2jserver.gameserver.network.serverpackets.ExUserInfoEquipSlot; +import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate; +import com.l2jserver.gameserver.network.serverpackets.itemappearance.ExShape_Shifting_Result; + +public final class RequestShape_Shifting_Item extends L2GameClientPacket +{ + private static final String _C__D0_C7_REQUESTSHAPE_SHIFTING_ITEM = "[C] D0:C7 RequestShape_Shifting_Item"; + + @Override + protected void readImpl() + { + readD(); + } + + @Override + protected void runImpl() + { + L2PcInstance player = getClient().getActiveChar(); + if (player == null) + { + return; + } + L2ItemInstance stone = player.getUsingAppearanceStone(); + L2ItemInstance item = player.getAppearanceItem(); + L2ItemInstance targetItem = player.getTargetAppearanceItem(); + boolean needTargetItem = (stone != null) && (stone.getEtcItem().getAppearanceStone() != null) && (stone.getEtcItem().getAppearanceStone().getType().equals(StoneType.Blessed) || stone.getEtcItem().getAppearanceStone().getType().equals(StoneType.Normal)) ? true : false; + player.setUsingAppearanceStone(null); + player.setAppearanceItem(null); + player.setTargetAppearanceItem(null); + if ((stone == null) || (item == null) || ((needTargetItem && (targetItem == null)))) + { + return; + } + AppearanceStone st = stone.getEtcItem().getAppearanceStone(); + if (st == null) + { + return; + } + long cost = st.getPrice(); + if (cost > player.getAdena()) + { + player.sendPacket(SystemMessageId.YOU_CANNOT_MODIFY_AS_YOU_DO_NOT_HAVE_ENOUGH_ADENA); + return; + } + int targetItemId = 0; + int time = -1; + switch (st.getType()) + { + case Normal: + targetItemId = targetItem.getId(); + player.destroyItem("AppearanceStone", targetItem, null, true); + break; + case Blessed: + targetItemId = targetItem.getId(); + break; + case Fixed: + targetItemId = st.getTargetItem(); + time = (int) st.getTimeForAppearance(); + break; + default: + break; + } + if (cost > 0) + { + player.reduceAdena("AppearanceStone", cost, null, true); + } + player.destroyItem("AppearanceStone", stone.getObjectId(), 1, null, true); + item.setAppearanceId(targetItemId); + item.setAppearanceTime(time); + InventoryUpdate iu = new InventoryUpdate(); + iu.addModifiedItem(item); + player.sendPacket(iu); + player.sendPacket(new ExUserInfoEquipSlot(player)); + player.broadcastUserInfo(); + player.sendPacket(new ExShape_Shifting_Result(1, item.getId(), targetItemId, time)); + } + + @Override + public String getType() + { + return _C__D0_C7_REQUESTSHAPE_SHIFTING_ITEM; + } +} diff --git a/trunk/java/com/l2jserver/gameserver/network/serverpackets/AbstractItemPacket.java b/trunk/java/com/l2jserver/gameserver/network/serverpackets/AbstractItemPacket.java index 247a5cf942..cdffda925b 100644 --- a/trunk/java/com/l2jserver/gameserver/network/serverpackets/AbstractItemPacket.java +++ b/trunk/java/com/l2jserver/gameserver/network/serverpackets/AbstractItemPacket.java @@ -71,6 +71,8 @@ public abstract class AbstractItemPacket extends AbstractMaskPacket 0) + { + mask |= ItemListType.VISUAL_ID.getMask(); + } + return mask; } diff --git a/trunk/java/com/l2jserver/gameserver/network/serverpackets/ExUserInfoEquipSlot.java b/trunk/java/com/l2jserver/gameserver/network/serverpackets/ExUserInfoEquipSlot.java index c1862c1e26..56781395cc 100644 --- a/trunk/java/com/l2jserver/gameserver/network/serverpackets/ExUserInfoEquipSlot.java +++ b/trunk/java/com/l2jserver/gameserver/network/serverpackets/ExUserInfoEquipSlot.java @@ -83,7 +83,7 @@ public class ExUserInfoEquipSlot extends AbstractMaskPacket writeD(inventory.getPaperdollObjectId(slot.getSlot())); writeD(inventory.getPaperdollItemId(slot.getSlot())); writeD(inventory.getPaperdollAugmentationId(slot.getSlot())); - writeD(0x00); // Item Visual ID + writeD(inventory.getPaperdollVisualId(slot.getSlot())); } } } diff --git a/trunk/java/com/l2jserver/gameserver/network/serverpackets/PrivateStoreListBuy.java b/trunk/java/com/l2jserver/gameserver/network/serverpackets/PrivateStoreListBuy.java index ddddc3c318..b06d7301f8 100644 --- a/trunk/java/com/l2jserver/gameserver/network/serverpackets/PrivateStoreListBuy.java +++ b/trunk/java/com/l2jserver/gameserver/network/serverpackets/PrivateStoreListBuy.java @@ -51,7 +51,6 @@ public class PrivateStoreListBuy extends AbstractItemPacket for (TradeItem item : _items) { writeItem(item); - // writeD(item.getObjectId()); writeD(0x00); // unk writeQ(item.getPrice()); writeQ(item.getItem().getReferencePrice() * 2); diff --git a/trunk/java/com/l2jserver/gameserver/network/serverpackets/RelationChanged.java b/trunk/java/com/l2jserver/gameserver/network/serverpackets/RelationChanged.java index 1739553b05..d299427533 100644 --- a/trunk/java/com/l2jserver/gameserver/network/serverpackets/RelationChanged.java +++ b/trunk/java/com/l2jserver/gameserver/network/serverpackets/RelationChanged.java @@ -92,7 +92,7 @@ public final class RelationChanged extends L2GameServerPacket r._objId = activeChar.getObjectId(); r._relation = relation; r._autoAttackable = autoattackable ? 1 : 0; - r._karma = 1 - activeChar.getKarma(); + r._karma = activeChar.getKarma(); r._pvpFlag = activeChar.getPvpFlag(); _multi.add(r); } diff --git a/trunk/java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java b/trunk/java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java index a4beec38dc..99c3718029 100644 --- a/trunk/java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java +++ b/trunk/java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java @@ -300,7 +300,7 @@ public class UserInfo extends AbstractMaskPacket { writeH(22); writeC(_activeChar.getPvpFlag()); - writeD(_activeChar.getKarma()); // Reputation + writeD(_activeChar.getKarma()); writeC(_activeChar.isNoble() ? 0x01 : 0x00); writeC(_activeChar.isHero() ? 0x01 : 0x00); writeC(_activeChar.getPledgeClass()); diff --git a/trunk/java/com/l2jserver/gameserver/network/serverpackets/itemappearance/ExChoose_Shape_Shifting_Item.java b/trunk/java/com/l2jserver/gameserver/network/serverpackets/itemappearance/ExChoose_Shape_Shifting_Item.java new file mode 100644 index 0000000000..202ef77793 --- /dev/null +++ b/trunk/java/com/l2jserver/gameserver/network/serverpackets/itemappearance/ExChoose_Shape_Shifting_Item.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2004-2015 L2J Server + * + * This file is part of L2J Server. + * + * L2J Server is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * L2J Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jserver.gameserver.network.serverpackets.itemappearance; + +import com.l2jserver.gameserver.model.entity.AppearanceStone; +import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket; + +/** + * @author Erlandys + */ +public class ExChoose_Shape_Shifting_Item extends L2GameServerPacket +{ + private final int _itemId; + private final int _type; + private final int _itemType; + + public ExChoose_Shape_Shifting_Item(AppearanceStone stone) + { + _itemId = stone.getItemId(); + _type = stone.getType().ordinal(); + _itemType = stone.getItemType().ordinal(); + } + + @Override + protected void writeImpl() + { + writeC(0xFE); + writeH(0x129); + writeD(_type); + writeD(_itemType); + writeD(_itemId); + } +} diff --git a/trunk/java/com/l2jserver/gameserver/network/serverpackets/itemappearance/ExPut_Shape_Shifting_Extraction_Item_Result.java b/trunk/java/com/l2jserver/gameserver/network/serverpackets/itemappearance/ExPut_Shape_Shifting_Extraction_Item_Result.java new file mode 100644 index 0000000000..c4abfcaa9a --- /dev/null +++ b/trunk/java/com/l2jserver/gameserver/network/serverpackets/itemappearance/ExPut_Shape_Shifting_Extraction_Item_Result.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2004-2015 L2J Server + * + * This file is part of L2J Server. + * + * L2J Server is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * L2J Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jserver.gameserver.network.serverpackets.itemappearance; + +import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket; + +/** + * @author Erlandys + */ +public class ExPut_Shape_Shifting_Extraction_Item_Result extends L2GameServerPacket +{ + int _type; + long _price = 0; + + public ExPut_Shape_Shifting_Extraction_Item_Result(int type) + { + _type = type; + } + + public ExPut_Shape_Shifting_Extraction_Item_Result(int type, long price) + { + _type = type; + _price = price; + } + + @Override + protected void writeImpl() + { + writeC(0xFE); + writeH(0x12A); + writeD(_type); + writeQ(_price); + } +} diff --git a/trunk/java/com/l2jserver/gameserver/network/serverpackets/itemappearance/ExPut_Shape_Shifting_Target_Item_Result.java b/trunk/java/com/l2jserver/gameserver/network/serverpackets/itemappearance/ExPut_Shape_Shifting_Target_Item_Result.java new file mode 100644 index 0000000000..fedcd42695 --- /dev/null +++ b/trunk/java/com/l2jserver/gameserver/network/serverpackets/itemappearance/ExPut_Shape_Shifting_Target_Item_Result.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2004-2015 L2J Server + * + * This file is part of L2J Server. + * + * L2J Server is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * L2J Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jserver.gameserver.network.serverpackets.itemappearance; + +import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket; + +/** + * @author Erlandys + */ +public class ExPut_Shape_Shifting_Target_Item_Result extends L2GameServerPacket +{ + private final int _success; + + public ExPut_Shape_Shifting_Target_Item_Result(int success) + { + _success = success; + } + + @Override + protected void writeImpl() + { + writeC(0xFE); + writeH(0x12B); + writeD(_success); + } +} diff --git a/trunk/java/com/l2jserver/gameserver/network/serverpackets/itemappearance/ExShape_Shifting_Result.java b/trunk/java/com/l2jserver/gameserver/network/serverpackets/itemappearance/ExShape_Shifting_Result.java new file mode 100644 index 0000000000..9f78a4aeb7 --- /dev/null +++ b/trunk/java/com/l2jserver/gameserver/network/serverpackets/itemappearance/ExShape_Shifting_Result.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2004-2015 L2J Server + * + * This file is part of L2J Server. + * + * L2J Server is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * L2J Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jserver.gameserver.network.serverpackets.itemappearance; + +import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket; + +/** + * @author Erlandys + */ +public class ExShape_Shifting_Result extends L2GameServerPacket +{ + private final int _success; + private int _itemId = 0, _targetItemId = 0, _time = -1; + + public ExShape_Shifting_Result(int success) + { + _success = success; + } + + public ExShape_Shifting_Result(int success, int itemId, int targetItemId) + { + _success = success; + _itemId = itemId; + _targetItemId = targetItemId; + } + + public ExShape_Shifting_Result(int success, int itemId, int targetItemId, int time) + { + _success = success; + _itemId = itemId; + _targetItemId = targetItemId; + _time = time; + } + + @Override + protected void writeImpl() + { + writeC(0xFE); + writeH(0x12C); + writeD(_success); // Success - 1, Fail - 0 + writeD(_itemId); // targetItemId + writeD(_targetItemId); // extractItemId + writeD(_time); // time + } +}