From 6e0cc76a4b016d6052e35c48ab50b650b15ade9e Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Wed, 20 May 2015 17:18:39 +0000 Subject: [PATCH] Support for item equip skills. --- trunk/dist/game/data/xsd/items.xsd | 1 + .../model/itemcontainer/Inventory.java | 23 ++++++++++++- .../gameserver/model/items/L2Item.java | 34 +++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/trunk/dist/game/data/xsd/items.xsd b/trunk/dist/game/data/xsd/items.xsd index 4cf77235e7..602219aa88 100644 --- a/trunk/dist/game/data/xsd/items.xsd +++ b/trunk/dist/game/data/xsd/items.xsd @@ -44,6 +44,7 @@ + diff --git a/trunk/java/com/l2jserver/gameserver/model/itemcontainer/Inventory.java b/trunk/java/com/l2jserver/gameserver/model/itemcontainer/Inventory.java index 407cd92e6d..b3f07c63b1 100644 --- a/trunk/java/com/l2jserver/gameserver/model/itemcontainer/Inventory.java +++ b/trunk/java/com/l2jserver/gameserver/model/itemcontainer/Inventory.java @@ -42,6 +42,7 @@ import com.l2jserver.gameserver.model.items.L2Item; import com.l2jserver.gameserver.model.items.instance.L2ItemInstance; import com.l2jserver.gameserver.model.items.type.EtcItemType; import com.l2jserver.gameserver.model.items.type.WeaponType; +import com.l2jserver.gameserver.model.skills.BuffInfo; import com.l2jserver.gameserver.model.skills.Skill; import com.l2jserver.gameserver.network.serverpackets.ExUserInfoEquipSlot; import com.l2jserver.gameserver.network.serverpackets.SkillCoolTime; @@ -381,7 +382,7 @@ public abstract class Inventory extends ItemContainer } // Apply skill, if weapon have "skills on unequip" - Skill unequipSkill = it.getUnequipSkill(); + final Skill unequipSkill = it.getUnequipSkill(); if (unequipSkill != null) { L2PcInstance[] targets = @@ -392,6 +393,14 @@ public abstract class Inventory extends ItemContainer unequipSkill.activateSkill(player, targets); } + // Remove itemEquip skill + final Skill itemEquipSkill = it.getEquipSkill(); + if (itemEquipSkill != null) + { + final BuffInfo info = player.getEffectList().getBuffInfoBySkillId(itemEquipSkill.getId()); + player.getEffectList().remove(true, info); + } + if (update) { player.sendSkillList(); @@ -479,6 +488,18 @@ public abstract class Inventory extends ItemContainer } } + // Apply itemEquip skill + final Skill itemEquipSkill = it.getEquipSkill(); + if (itemEquipSkill != null) + { + L2PcInstance[] targets = + { + player + }; + + itemEquipSkill.activateSkill(player, targets); + } + if (update) { player.sendSkillList(); diff --git a/trunk/java/com/l2jserver/gameserver/model/items/L2Item.java b/trunk/java/com/l2jserver/gameserver/model/items/L2Item.java index 4d928c9cd7..a391d03b3b 100644 --- a/trunk/java/com/l2jserver/gameserver/model/items/L2Item.java +++ b/trunk/java/com/l2jserver/gameserver/model/items/L2Item.java @@ -156,6 +156,7 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable protected List _preConditions; private SkillHolder[] _skillHolder; private SkillHolder _unequipSkill = null; + private SkillHolder _equipSkill = null; private final int _useSkillDisTime; private final int _reuseDelay; @@ -283,6 +284,31 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable } } + skills = set.getString("equip_skill", null); + if (skills != null) + { + String[] info = skills.split("-"); + if ((info != null) && (info.length == 2)) + { + int id = 0; + int level = 0; + try + { + id = Integer.parseInt(info[0]); + level = Integer.parseInt(info[1]); + } + catch (Exception nfe) + { + // Incorrect syntax, don't add new skill + _log.info(StringUtil.concat("Couldnt parse ", skills, " in item equip skill! item ", toString())); + } + if ((id > 0) && (level > 0)) + { + _equipSkill = new SkillHolder(id, level); + } + } + } + _common = ((_itemId >= 11605) && (_itemId <= 12361)); _heroItem = ((_itemId >= 6611) && (_itemId <= 6621)) || ((_itemId >= 9388) && (_itemId <= 9390)) || (_itemId == 6842); _pvpItem = ((_itemId >= 10667) && (_itemId <= 10835)) || ((_itemId >= 12852) && (_itemId <= 12977)) || ((_itemId >= 14363) && (_itemId <= 14525)) || (_itemId == 14528) || (_itemId == 14529) || (_itemId == 14558) || ((_itemId >= 15913) && (_itemId <= 16024)) || ((_itemId >= 16134) && (_itemId <= 16147)) || (_itemId == 16149) || (_itemId == 16151) || (_itemId == 16153) || (_itemId == 16155) || (_itemId == 16157) || (_itemId == 16159) || ((_itemId >= 16168) && (_itemId <= 16176)) || ((_itemId >= 16179) && (_itemId <= 16220)); @@ -781,6 +807,14 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable return _unequipSkill == null ? null : _unequipSkill.getSkill(); } + /** + * @return skill that activates, when player equips this item + */ + public final Skill getEquipSkill() + { + return _equipSkill == null ? null : _equipSkill.getSkill(); + } + public boolean checkCondition(L2Character activeChar, L2Object object, boolean sendMessage) { if (activeChar.canOverrideCond(PcCondOverride.ITEM_CONDITIONS) && !Config.GM_ITEM_RESTRICTION)