- Implemented Appearance Stones with engine.

- Fixed Private Stores, not showing items enchant level, attributes, appearance.
 - Fixed RelationChange packet, with reputation, for green name for normal players on login.
This commit is contained in:
erlandys56
2015-01-26 21:09:25 +00:00
parent 095d3bb620
commit eb8567590a
37 changed files with 1142 additions and 42 deletions

View File

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

View File

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

View File

@ -126,7 +126,12 @@ public class TradeList
FastList<TradeItem> 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

View File

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

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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;
}
}

View File

@ -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());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -170,6 +170,9 @@ public final class L2ItemInstance extends L2Object
private final List<Options> _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;
}
}