Support for item equip skills.

This commit is contained in:
MobiusDev 2015-05-20 17:18:39 +00:00
parent c2fbb18c37
commit 6e0cc76a4b
3 changed files with 57 additions and 1 deletions

View File

@ -44,6 +44,7 @@
<xs:enumeration value="isAttackWeapon" />
<xs:enumeration value="isForceEquip" />
<xs:enumeration value="item_skill" />
<xs:enumeration value="equip_skill" />
<xs:enumeration value="allow_self_resurrection" />
<xs:enumeration value="material" />
<xs:enumeration value="mp_consume" />

View File

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

View File

@ -156,6 +156,7 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable
protected List<Condition> _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)