Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: java/com/l2jserver/gameserver/model/L2ItemInstance.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/L2ItemInstance.java (revision 4930)
- +++ java/com/l2jserver/gameserver/model/L2ItemInstance.java (working copy)
- @@ -45,6 +45,7 @@
- import com.l2jserver.gameserver.network.serverpackets.SpawnItem;
- import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
- import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
- +import com.l2jserver.gameserver.skills.SkillHolder;
- import com.l2jserver.gameserver.skills.funcs.Func;
- import com.l2jserver.gameserver.templates.item.L2Armor;
- import com.l2jserver.gameserver.templates.item.L2EtcItem;
- @@ -322,10 +323,18 @@
- */
- public void setOwnerId(int owner_id)
- {
- - if (owner_id == _ownerId) return;
- + if (owner_id == _ownerId)
- + return;
- + removeSkillsFromOwner(); // Remove any inventory skills from the old owner.
- +
- _ownerId = owner_id;
- _storedInDb = false;
- +
- + // Give any inventory skills to the new owner only if the item is in inventory
- + // else the skills will be given when location is set to inventory.
- + if (getLocation() == ItemLocation.INVENTORY)
- + giveSkillsToOwner();
- }
- /**
- @@ -347,7 +356,9 @@
- }
- /**
- - * Sets the location of the item.<BR><BR>
- + * Sets the location of the item.<BR>
- + * If the item has inventory skills, those skills will be either added to or removed from the owner,
- + * depending on the new location (if its inventory, skills will be added, else removed).<BR>
- * <U><I>Remark :</I></U> If loc and loc_data different from database, say datas not up-to-date
- * @param loc : ItemLocation (enumeration)
- * @param loc_data : int designating the slot where the item is stored or the village for freights
- @@ -356,6 +367,12 @@
- {
- if (loc == _loc && loc_data == _locData)
- return;
- +
- + if (_loc == ItemLocation.INVENTORY) // Current loc
- + removeSkillsFromOwner();
- + else if (loc == ItemLocation.INVENTORY) // New loc
- + giveSkillsToOwner();
- +
- _loc = loc;
- _locData = loc_data;
- _storedInDb = false;
- @@ -1951,4 +1968,32 @@
- return enchant;
- }
- +
- + private void giveSkillsToOwner()
- + {
- + if (getItem().isInventorySkill() && getOwnerId() > 0)
- + {
- + L2PcInstance player = L2World.getInstance().getPlayer(getOwnerId());
- +
- + if (player != null)
- + {
- + for (SkillHolder sh : getItem().getSkills())
- + player.addSkill(sh.getSkill());
- + }
- + }
- + }
- +
- + private void removeSkillsFromOwner()
- + {
- + if (getItem().isInventorySkill() && getOwnerId() > 0)
- + {
- + L2PcInstance player = L2World.getInstance().getPlayer(getOwnerId());
- +
- + if (player != null)
- + {
- + for (SkillHolder sh : getItem().getSkills())
- + player.removeSkill(sh.getSkill(), false, true);
- + }
- + }
- + }
- }
- Index: java/com/l2jserver/gameserver/templates/item/L2Item.java
- ===================================================================
- --- java/com/l2jserver/gameserver/templates/item/L2Item.java (revision 4930)
- +++ java/com/l2jserver/gameserver/templates/item/L2Item.java (working copy)
- @@ -184,6 +184,7 @@
- protected int _type1; // needed for item list (inventory)
- protected int _type2; // different lists for armor, weapon, etc
- + protected boolean _isInventorySkill;
- protected Elementals[] _elementals = null;
- protected FuncTemplate[] _funcTemplates;
- protected EffectTemplate[] _effectTemplates;
- @@ -223,6 +224,7 @@
- _depositable = set.getBool("is_depositable", true);
- _questItem = set.getBool("is_questitem", false);
- _freightable = set.getBool("is_freightable", false);
- + _isInventorySkill = set.getBool("is_inventory_skill", false);
- //_immediate_effect - herb
- _ex_immediate_effect = set.getInteger("ex_immediate_effect", 0) > 0;
- @@ -357,6 +359,15 @@
- }
- /**
- + * Returns if the item's skills are added while item is at the player's inventory.
- + * @return boolean
- + */
- + public final boolean isInventorySkill()
- + {
- + return _isInventorySkill;
- + }
- +
- + /**
- * Returns the weight of the item
- * @return int
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement