Apply item skills to all playables.
This commit is contained in:
parent
b6fe06aa07
commit
680902f39d
@ -23,6 +23,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.data.xml.ArmorSetData;
|
||||
import org.l2jmobius.gameserver.model.ArmorSet;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.model.stats.BaseStat;
|
||||
@ -82,7 +83,7 @@ public final class PaperdollCache
|
||||
return value;
|
||||
}
|
||||
|
||||
public int getMaxSetEnchant(Player player)
|
||||
public int getMaxSetEnchant(Playable playable)
|
||||
{
|
||||
if (_maxSetEnchant >= 0)
|
||||
{
|
||||
@ -94,7 +95,7 @@ public final class PaperdollCache
|
||||
{
|
||||
for (ArmorSet set : ArmorSetData.getInstance().getSets(item.getId()))
|
||||
{
|
||||
final int enchantEffect = set.getLowestSetEnchant(player);
|
||||
final int enchantEffect = set.getLowestSetEnchant(playable);
|
||||
if (enchantEffect > maxSetEnchant)
|
||||
{
|
||||
maxSetEnchant = enchantEffect;
|
||||
|
@ -22,11 +22,10 @@ import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.holders.ArmorsetSkillHolder;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import org.l2jmobius.gameserver.model.itemcontainer.PlayerInventory;
|
||||
import org.l2jmobius.gameserver.model.stats.BaseStat;
|
||||
|
||||
/**
|
||||
@ -162,18 +161,18 @@ public class ArmorSet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param playable
|
||||
* @return true if all parts of set are enchanted to +6 or more
|
||||
*/
|
||||
public int getLowestSetEnchant(Player player)
|
||||
public int getLowestSetEnchant(Playable playable)
|
||||
{
|
||||
// Player don't have full set
|
||||
if (getPiecesCountById(player) < _minimumPieces)
|
||||
// Playable don't have full set
|
||||
if (getPiecesCountById(playable) < _minimumPieces)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
final PlayerInventory inv = player.getInventory();
|
||||
final Inventory inv = playable.getInventory();
|
||||
int enchantLevel = Byte.MAX_VALUE;
|
||||
for (int armorSlot : ARMORSET_SLOTS)
|
||||
{
|
||||
@ -192,13 +191,13 @@ public class ArmorSet
|
||||
|
||||
/**
|
||||
* Condition for 3 Lv. Set Effect Applied Skill
|
||||
* @param player
|
||||
* @param playable
|
||||
* @param bookSlot
|
||||
* @return total paperdoll(busy) count for 1 of 3 artifact book slots
|
||||
*/
|
||||
public int getArtifactSlotMask(Player player, int bookSlot)
|
||||
public int getArtifactSlotMask(Playable playable, int bookSlot)
|
||||
{
|
||||
final PlayerInventory inv = player.getInventory();
|
||||
final Inventory inv = playable.getInventory();
|
||||
int slotMask = 0;
|
||||
switch (bookSlot)
|
||||
{
|
||||
@ -242,23 +241,23 @@ public class ArmorSet
|
||||
return slotMask;
|
||||
}
|
||||
|
||||
public boolean hasOptionalEquipped(Player player, Function<Item, Integer> idProvider)
|
||||
public boolean hasOptionalEquipped(Playable playable, Function<Item, Integer> idProvider)
|
||||
{
|
||||
return player.getInventory().getPaperdollItems().stream().anyMatch(item -> CommonUtil.contains(_optionalItems, idProvider.apply(item)));
|
||||
return playable.getInventory().getPaperdollItems().stream().anyMatch(item -> CommonUtil.contains(_optionalItems, idProvider.apply(item)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param playable
|
||||
* @param idProvider
|
||||
* @return the amount of set visual items that player has equipped
|
||||
* @return the amount of set visual items that playable has equipped
|
||||
*/
|
||||
public long getPiecesCount(Player player, Function<Item, Integer> idProvider)
|
||||
public long getPiecesCount(Playable playable, Function<Item, Integer> idProvider)
|
||||
{
|
||||
return player.getInventory().getPaperdollItemCount(item -> CommonUtil.contains(_requiredItems, idProvider.apply(item)));
|
||||
return playable.getInventory().getPaperdollItemCount(item -> CommonUtil.contains(_requiredItems, idProvider.apply(item)));
|
||||
}
|
||||
|
||||
public long getPiecesCountById(Player player)
|
||||
public long getPiecesCountById(Playable playable)
|
||||
{
|
||||
return player.getInventory().getPaperdollItemCount(item -> CommonUtil.contains(_requiredItems, item.getId()));
|
||||
return playable.getInventory().getPaperdollItemCount(item -> CommonUtil.contains(_requiredItems, item.getId()));
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import org.l2jmobius.gameserver.data.xml.OptionData;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.options.Options;
|
||||
|
||||
/**
|
||||
@ -59,27 +59,27 @@ public class VariationInstance
|
||||
return _option2 == null ? -1 : _option2.getId();
|
||||
}
|
||||
|
||||
public void applyBonus(Player player)
|
||||
public void applyBonus(Playable playable)
|
||||
{
|
||||
if (_option1 != null)
|
||||
{
|
||||
_option1.apply(player);
|
||||
_option1.apply(playable);
|
||||
}
|
||||
if (_option2 != null)
|
||||
{
|
||||
_option2.apply(player);
|
||||
_option2.apply(playable);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeBonus(Player player)
|
||||
public void removeBonus(Playable playable)
|
||||
{
|
||||
if (_option1 != null)
|
||||
{
|
||||
_option1.remove(player);
|
||||
_option1.remove(playable);
|
||||
}
|
||||
if (_option2 != null)
|
||||
{
|
||||
_option2.remove(player);
|
||||
_option2.remove(playable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.holders;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.l2jmobius.gameserver.model.ArmorSet;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
|
||||
/**
|
||||
@ -58,34 +58,34 @@ public class ArmorsetSkillHolder extends SkillHolder
|
||||
return _isOptional;
|
||||
}
|
||||
|
||||
public boolean validateConditions(Player player, ArmorSet armorSet, Function<Item, Integer> idProvider)
|
||||
public boolean validateConditions(Playable playable, ArmorSet armorSet, Function<Item, Integer> idProvider)
|
||||
{
|
||||
// Player's doesn't have full busy (1 of 3) artifact real slot
|
||||
if (_artifactSlotMask > armorSet.getArtifactSlotMask(player, _artifactBookSlot))
|
||||
// Playable doesn't have full busy (1 of 3) artifact real slot
|
||||
if (_artifactSlotMask > armorSet.getArtifactSlotMask(playable, _artifactBookSlot))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Player doesn't have enough items equipped to use this skill
|
||||
if (_minimumPieces > armorSet.getPiecesCount(player, idProvider))
|
||||
// Playable doesn't have enough items equipped to use this skill
|
||||
if (_minimumPieces > armorSet.getPiecesCount(playable, idProvider))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Player's set enchantment isn't enough to use this skill
|
||||
if (_minEnchant > armorSet.getLowestSetEnchant(player))
|
||||
// Playable set enchantment isn't enough to use this skill
|
||||
if (_minEnchant > armorSet.getLowestSetEnchant(playable))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Player doesn't have the required item to use this skill
|
||||
if (_isOptional && !armorSet.hasOptionalEquipped(player, idProvider))
|
||||
// Playable doesn't have the required item to use this skill
|
||||
if (_isOptional && !armorSet.hasOptionalEquipped(playable, idProvider))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Player already knows that skill
|
||||
if (player.getSkillLevel(getSkillId()) == getSkillLevel())
|
||||
// Playable already knows that skill
|
||||
if (playable.getSkillLevel(getSkillId()) == getSkillLevel())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ import org.l2jmobius.gameserver.model.ArmorSet;
|
||||
import org.l2jmobius.gameserver.model.VariationInstance;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerItemUnequip;
|
||||
@ -310,12 +311,12 @@ public abstract class Inventory extends ItemContainer
|
||||
@Override
|
||||
public void notifyUnequiped(int slot, Item item, Inventory inventory)
|
||||
{
|
||||
if (!inventory.getOwner().isPlayer())
|
||||
if (!inventory.getOwner().isPlayable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = (Player) inventory.getOwner();
|
||||
final Playable playable = (Playable) inventory.getOwner();
|
||||
final ItemTemplate it = item.getTemplate();
|
||||
final Map<Integer, Skill> addedSkills = new HashMap<>(1);
|
||||
final Map<Integer, Skill> removedSkills = new HashMap<>(1);
|
||||
@ -325,11 +326,11 @@ public abstract class Inventory extends ItemContainer
|
||||
// Remove augmentation bonuses on unequip
|
||||
if (item.isAugmented())
|
||||
{
|
||||
item.getAugmentation().removeBonus(player);
|
||||
item.getAugmentation().removeBonus(playable);
|
||||
}
|
||||
|
||||
// Recalculate all stats
|
||||
player.getStat().recalculateStats(true);
|
||||
playable.getStat().recalculateStats(true);
|
||||
|
||||
// Clear enchant bonus
|
||||
item.clearEnchantStats();
|
||||
@ -406,7 +407,7 @@ public abstract class Inventory extends ItemContainer
|
||||
|
||||
for (ItemSkillHolder holder : otherNormalSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) != 0)
|
||||
if (playable.getSkillLevel(holder.getSkillId()) != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -430,13 +431,13 @@ public abstract class Inventory extends ItemContainer
|
||||
addedSkills.put(skill.getId(), skill);
|
||||
}
|
||||
|
||||
if (skill.isActive() && !player.hasSkillReuse(skill.getReuseHashCode()))
|
||||
if (skill.isActive() && !playable.hasSkillReuse(skill.getReuseHashCode()))
|
||||
{
|
||||
final int equipDelay = item.getEquipReuseDelay();
|
||||
if (equipDelay > 0)
|
||||
{
|
||||
player.addTimeStamp(skill, equipDelay);
|
||||
player.disableSkill(skill, equipDelay);
|
||||
playable.addTimeStamp(skill, equipDelay);
|
||||
playable.disableSkill(skill, equipDelay);
|
||||
}
|
||||
updateTimestamp = true;
|
||||
}
|
||||
@ -477,7 +478,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
removedSkills.putIfAbsent(skill.getId(), skill);
|
||||
update = true;
|
||||
@ -496,7 +497,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
removedSkills.putIfAbsent(skill.getId(), skill);
|
||||
update = true;
|
||||
@ -506,12 +507,12 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Must check for toggle and isRemovedOnUnequipWeapon skill item conditions.
|
||||
for (Skill skill : player.getAllSkills())
|
||||
for (Skill skill : playable.getAllSkills())
|
||||
{
|
||||
if ((skill.isToggle() && player.isAffectedBySkill(skill.getId()) && !skill.checkConditions(SkillConditionScope.GENERAL, player, player)) //
|
||||
if ((skill.isToggle() && playable.isAffectedBySkill(skill.getId()) && !skill.checkConditions(SkillConditionScope.GENERAL, playable, playable)) //
|
||||
|| (it.isWeapon() && skill.isRemovedOnUnequipWeapon()))
|
||||
{
|
||||
player.stopSkillEffects(SkillFinishType.REMOVED, skill.getId());
|
||||
playable.stopSkillEffects(SkillFinishType.REMOVED, skill.getId());
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
@ -519,55 +520,58 @@ public abstract class Inventory extends ItemContainer
|
||||
// Apply skill, if item has "skills on unequip" and it is not a secondary agathion.
|
||||
if ((slot < PAPERDOLL_AGATHION2) || (slot > PAPERDOLL_AGATHION5))
|
||||
{
|
||||
it.forEachSkill(ItemSkillType.ON_UNEQUIP, holder -> holder.getSkill().activateSkill(player, player));
|
||||
it.forEachSkill(ItemSkillType.ON_UNEQUIP, holder -> holder.getSkill().activateSkill(playable, playable));
|
||||
}
|
||||
|
||||
if (update)
|
||||
{
|
||||
for (Skill skill : removedSkills.values())
|
||||
{
|
||||
player.removeSkill(skill, false, skill.isPassive());
|
||||
playable.removeSkill(skill, skill.isPassive());
|
||||
}
|
||||
|
||||
for (Skill skill : addedSkills.values())
|
||||
{
|
||||
player.addSkill(skill, false);
|
||||
playable.addSkill(skill);
|
||||
}
|
||||
|
||||
player.sendSkillList();
|
||||
if (playable.isPlayer())
|
||||
{
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
}
|
||||
|
||||
if (updateTimestamp)
|
||||
if (updateTimestamp && playable.isPlayer())
|
||||
{
|
||||
player.sendPacket(new SkillCoolTime(player));
|
||||
playable.sendPacket(new SkillCoolTime(playable.getActingPlayer()));
|
||||
}
|
||||
|
||||
if (item.isWeapon())
|
||||
{
|
||||
player.unchargeAllShots();
|
||||
playable.unchargeAllShots();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyEquiped(int slot, Item item, Inventory inventory)
|
||||
{
|
||||
if (!inventory.getOwner().isPlayer())
|
||||
if (!inventory.getOwner().isPlayable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = (Player) inventory.getOwner();
|
||||
final Playable playable = (Playable) inventory.getOwner();
|
||||
final Map<Integer, Skill> addedSkills = new HashMap<>(1);
|
||||
boolean updateTimestamp = false;
|
||||
|
||||
// Apply augmentation bonuses on equip
|
||||
if (item.isAugmented())
|
||||
{
|
||||
item.getAugmentation().applyBonus(player);
|
||||
item.getAugmentation().applyBonus(playable);
|
||||
}
|
||||
|
||||
// Recalculate all stats
|
||||
player.getStat().recalculateStats(true);
|
||||
playable.getStat().recalculateStats(true);
|
||||
|
||||
// Apply enchant stats
|
||||
item.applyEnchantStats();
|
||||
@ -582,7 +586,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
for (ItemSkillHolder holder : onEnchantSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -599,7 +603,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -626,7 +630,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
for (ItemSkillHolder holder : onBlessingSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -643,7 +647,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -669,7 +673,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
for (ItemSkillHolder holder : normalSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -681,7 +685,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -699,13 +703,13 @@ public abstract class Inventory extends ItemContainer
|
||||
addedSkills.put(skill.getId(), skill);
|
||||
}
|
||||
|
||||
if (skill.isActive() && !player.hasSkillReuse(skill.getReuseHashCode()))
|
||||
if (skill.isActive() && !playable.hasSkillReuse(skill.getReuseHashCode()))
|
||||
{
|
||||
final int equipDelay = item.getEquipReuseDelay();
|
||||
if (equipDelay > 0)
|
||||
{
|
||||
player.addTimeStamp(skill, equipDelay);
|
||||
player.disableSkill(skill, equipDelay);
|
||||
playable.addTimeStamp(skill, equipDelay);
|
||||
playable.disableSkill(skill, equipDelay);
|
||||
}
|
||||
updateTimestamp = true;
|
||||
}
|
||||
@ -732,7 +736,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
for (ItemSkillHolder holder : otherEnchantSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -749,7 +753,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -773,7 +777,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
for (ItemSkillHolder holder : otherBlessingSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -787,7 +791,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -812,22 +816,25 @@ public abstract class Inventory extends ItemContainer
|
||||
// Apply skill, if item has "skills on equip" and it is not a secondary agathion.
|
||||
if ((slot < PAPERDOLL_AGATHION2) || (slot > PAPERDOLL_AGATHION5))
|
||||
{
|
||||
item.getTemplate().forEachSkill(ItemSkillType.ON_EQUIP, holder -> holder.getSkill().activateSkill(player, player));
|
||||
item.getTemplate().forEachSkill(ItemSkillType.ON_EQUIP, holder -> holder.getSkill().activateSkill(playable, playable));
|
||||
}
|
||||
|
||||
if (!addedSkills.isEmpty())
|
||||
{
|
||||
for (Skill skill : addedSkills.values())
|
||||
{
|
||||
player.addSkill(skill, false);
|
||||
playable.addSkill(skill);
|
||||
}
|
||||
|
||||
player.sendSkillList();
|
||||
if (playable.isPlayer())
|
||||
{
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
}
|
||||
|
||||
if (updateTimestamp)
|
||||
if (updateTimestamp && playable.isPlayer())
|
||||
{
|
||||
player.sendPacket(new SkillCoolTime(player));
|
||||
playable.sendPacket(new SkillCoolTime(playable.getActingPlayer()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -844,16 +851,16 @@ public abstract class Inventory extends ItemContainer
|
||||
@Override
|
||||
public void notifyEquiped(int slot, Item item, Inventory inventory)
|
||||
{
|
||||
if (!inventory.getOwner().isPlayer())
|
||||
if (!inventory.getOwner().isPlayable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = (Player) inventory.getOwner();
|
||||
final Playable playable = (Playable) inventory.getOwner();
|
||||
boolean update = false;
|
||||
|
||||
// Verify and apply normal set
|
||||
if (verifyAndApply(player, item, Item::getId))
|
||||
if (verifyAndApply(playable, item, Item::getId))
|
||||
{
|
||||
update = true;
|
||||
}
|
||||
@ -863,26 +870,26 @@ public abstract class Inventory extends ItemContainer
|
||||
if (itemVisualId > 0)
|
||||
{
|
||||
final AppearanceStone stone = AppearanceItemData.getInstance().getStone(itemVisualId);
|
||||
if ((stone != null) && (stone.getType() == AppearanceType.FIXED) && verifyAndApply(player, item, Item::getVisualId))
|
||||
if ((stone != null) && (stone.getType() == AppearanceType.FIXED) && verifyAndApply(playable, item, Item::getVisualId))
|
||||
{
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (update)
|
||||
if (update && playable.isPlayer())
|
||||
{
|
||||
player.sendSkillList();
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
|
||||
if ((item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH_JEWEL) || (item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH))
|
||||
if (playable.isPlayer() && ((item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH_JEWEL) || (item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH)))
|
||||
{
|
||||
player.updateActiveBroochJewel();
|
||||
playable.getActingPlayer().updateActiveBroochJewel();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean applySkills(Player player, Item item, ArmorSet armorSet, Function<Item, Integer> idProvider)
|
||||
private static boolean applySkills(Playable playable, Item item, ArmorSet armorSet, Function<Item, Integer> idProvider)
|
||||
{
|
||||
final long piecesCount = armorSet.getPiecesCount(player, idProvider);
|
||||
final long piecesCount = armorSet.getPiecesCount(playable, idProvider);
|
||||
if (piecesCount >= armorSet.getMinimumPieces())
|
||||
{
|
||||
// Applying all skills that matching the conditions
|
||||
@ -890,12 +897,12 @@ public abstract class Inventory extends ItemContainer
|
||||
boolean update = false;
|
||||
for (ArmorsetSkillHolder holder : armorSet.getSkills())
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (holder.validateConditions(player, armorSet, idProvider))
|
||||
if (holder.validateConditions(playable, armorSet, idProvider))
|
||||
{
|
||||
final Skill itemSkill = holder.getSkill();
|
||||
if (itemSkill == null)
|
||||
@ -904,21 +911,21 @@ public abstract class Inventory extends ItemContainer
|
||||
continue;
|
||||
}
|
||||
|
||||
if (itemSkill.isPassive() && !itemSkill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (itemSkill.isPassive() && !itemSkill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
player.addSkill(itemSkill, false);
|
||||
playable.addSkill(itemSkill);
|
||||
if (itemSkill.isActive() && (item != null))
|
||||
{
|
||||
if (!player.hasSkillReuse(itemSkill.getReuseHashCode()))
|
||||
if (!playable.hasSkillReuse(itemSkill.getReuseHashCode()))
|
||||
{
|
||||
final int equipDelay = item.getEquipReuseDelay();
|
||||
if (equipDelay > 0)
|
||||
{
|
||||
player.addTimeStamp(itemSkill, equipDelay);
|
||||
player.disableSkill(itemSkill, equipDelay);
|
||||
playable.addTimeStamp(itemSkill, equipDelay);
|
||||
playable.disableSkill(itemSkill, equipDelay);
|
||||
}
|
||||
}
|
||||
updateTimeStamp = true;
|
||||
@ -926,22 +933,22 @@ public abstract class Inventory extends ItemContainer
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
if (updateTimeStamp)
|
||||
if (updateTimeStamp && playable.isPlayer())
|
||||
{
|
||||
player.sendPacket(new SkillCoolTime(player));
|
||||
playable.sendPacket(new SkillCoolTime(playable.getActingPlayer()));
|
||||
}
|
||||
return update;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean verifyAndApply(Player player, Item item, Function<Item, Integer> idProvider)
|
||||
private static boolean verifyAndApply(Playable playable, Item item, Function<Item, Integer> idProvider)
|
||||
{
|
||||
boolean update = false;
|
||||
final List<ArmorSet> armorSets = ArmorSetData.getInstance().getSets(idProvider.apply(item));
|
||||
for (ArmorSet armorSet : armorSets)
|
||||
{
|
||||
if (applySkills(player, item, armorSet, idProvider))
|
||||
if (applySkills(playable, item, armorSet, idProvider))
|
||||
{
|
||||
update = true;
|
||||
}
|
||||
@ -949,7 +956,7 @@ public abstract class Inventory extends ItemContainer
|
||||
return update;
|
||||
}
|
||||
|
||||
private static boolean verifyAndRemove(Player player, Item item, Function<Item, Integer> idProvider)
|
||||
private static boolean verifyAndRemove(Playable playable, Item item, Function<Item, Integer> idProvider)
|
||||
{
|
||||
boolean update = false;
|
||||
final List<ArmorSet> armorSets = ArmorSetData.getInstance().getSets(idProvider.apply(item));
|
||||
@ -958,7 +965,7 @@ public abstract class Inventory extends ItemContainer
|
||||
// Remove all skills that doesn't matches the conditions
|
||||
for (ArmorsetSkillHolder holder : armorSet.getSkills())
|
||||
{
|
||||
if (!holder.validateConditions(player, armorSet, idProvider))
|
||||
if (!holder.validateConditions(playable, armorSet, idProvider))
|
||||
{
|
||||
final Skill itemSkill = holder.getSkill();
|
||||
if (itemSkill == null)
|
||||
@ -968,7 +975,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Update if a skill has been removed.
|
||||
if (player.removeSkill(itemSkill, false, itemSkill.isPassive()) != null)
|
||||
if (playable.removeSkill(itemSkill, itemSkill.isPassive()) != null)
|
||||
{
|
||||
update = true;
|
||||
}
|
||||
@ -976,7 +983,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Attempt to apply lower level skills if possible
|
||||
if (applySkills(player, item, armorSet, idProvider))
|
||||
if (applySkills(playable, item, armorSet, idProvider))
|
||||
{
|
||||
update = true;
|
||||
}
|
||||
@ -988,16 +995,16 @@ public abstract class Inventory extends ItemContainer
|
||||
@Override
|
||||
public void notifyUnequiped(int slot, Item item, Inventory inventory)
|
||||
{
|
||||
if (!inventory.getOwner().isPlayer())
|
||||
if (!inventory.getOwner().isPlayable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = (Player) inventory.getOwner();
|
||||
final Playable playable = (Playable) inventory.getOwner();
|
||||
boolean remove = false;
|
||||
|
||||
// Verify and remove normal set bonus
|
||||
if (verifyAndRemove(player, item, Item::getId))
|
||||
if (verifyAndRemove(playable, item, Item::getId))
|
||||
{
|
||||
remove = true;
|
||||
}
|
||||
@ -1007,21 +1014,26 @@ public abstract class Inventory extends ItemContainer
|
||||
if (itemVisualId > 0)
|
||||
{
|
||||
final AppearanceStone stone = AppearanceItemData.getInstance().getStone(itemVisualId);
|
||||
if ((stone != null) && (stone.getType() == AppearanceType.FIXED) && verifyAndRemove(player, item, Item::getVisualId))
|
||||
if ((stone != null) && (stone.getType() == AppearanceType.FIXED) && verifyAndRemove(playable, item, Item::getVisualId))
|
||||
{
|
||||
remove = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!playable.isPlayer())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (remove)
|
||||
{
|
||||
player.checkItemRestriction();
|
||||
player.sendSkillList();
|
||||
playable.getActingPlayer().checkItemRestriction();
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
|
||||
if ((item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH_JEWEL) || (item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH))
|
||||
{
|
||||
player.updateActiveBroochJewel();
|
||||
playable.getActingPlayer().updateActiveBroochJewel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1189,6 +1201,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
_paperdoll = new Item[PAPERDOLL_TOTALSLOTS];
|
||||
_paperdollListeners = new ArrayList<>();
|
||||
|
||||
if (this instanceof PlayerInventory)
|
||||
{
|
||||
addPaperdollListener(ArmorSetListener.getInstance());
|
||||
@ -1199,6 +1212,11 @@ public abstract class Inventory extends ItemContainer
|
||||
addPaperdollListener(AgathionBraceletListener.getInstance());
|
||||
addPaperdollListener(ArtifactBookListener.getInstance());
|
||||
}
|
||||
else if (this instanceof PetInventory)
|
||||
{
|
||||
addPaperdollListener(ArmorSetListener.getInstance());
|
||||
addPaperdollListener(ItemSkillsListener.getInstance());
|
||||
}
|
||||
|
||||
// common
|
||||
addPaperdollListener(StatsListener.getInstance());
|
||||
@ -2674,12 +2692,12 @@ public abstract class Inventory extends ItemContainer
|
||||
|
||||
public int getArmorMinEnchant()
|
||||
{
|
||||
if ((getOwner() == null) || !getOwner().isPlayer())
|
||||
if ((getOwner() == null) || !getOwner().isPlayable())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
final Player player = getOwner().getActingPlayer();
|
||||
final Playable player = (Playable) getOwner();
|
||||
return _paperdollCache.getMaxSetEnchant(player);
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.gameserver.enums.SkillFinishType;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import org.l2jmobius.gameserver.model.skill.BuffInfo;
|
||||
import org.l2jmobius.gameserver.model.skill.Skill;
|
||||
@ -157,11 +157,11 @@ public class Options
|
||||
_activationSkills.add(holder);
|
||||
}
|
||||
|
||||
public void apply(Player player)
|
||||
public void apply(Playable playable)
|
||||
{
|
||||
if (hasEffects())
|
||||
{
|
||||
final BuffInfo info = new BuffInfo(player, player, null, true, null, this);
|
||||
final BuffInfo info = new BuffInfo(playable, playable, null, true, null, this);
|
||||
for (AbstractEffect effect : _effects)
|
||||
{
|
||||
if (effect.isInstant())
|
||||
@ -174,7 +174,7 @@ public class Options
|
||||
else
|
||||
{
|
||||
effect.continuousInstant(info.getEffector(), info.getEffected(), info.getSkill(), info.getItem());
|
||||
effect.pump(player, info.getSkill());
|
||||
effect.pump(playable, info.getSkill());
|
||||
if (effect.canStart(info.getEffector(), info.getEffected(), info.getSkill()))
|
||||
{
|
||||
info.addEffect(effect);
|
||||
@ -183,44 +183,47 @@ public class Options
|
||||
}
|
||||
if (!info.getEffects().isEmpty())
|
||||
{
|
||||
player.getEffectList().add(info);
|
||||
playable.getEffectList().add(info);
|
||||
}
|
||||
}
|
||||
if (hasActiveSkills())
|
||||
{
|
||||
for (Skill skill : _activeSkill)
|
||||
{
|
||||
addSkill(player, skill);
|
||||
addSkill(playable, skill);
|
||||
}
|
||||
}
|
||||
if (hasPassiveSkills())
|
||||
{
|
||||
for (Skill skill : _passiveSkill)
|
||||
{
|
||||
addSkill(player, skill);
|
||||
addSkill(playable, skill);
|
||||
}
|
||||
}
|
||||
if (hasActivationSkills())
|
||||
{
|
||||
for (OptionSkillHolder holder : _activationSkills)
|
||||
{
|
||||
player.addTriggerSkill(holder);
|
||||
playable.addTriggerSkill(holder);
|
||||
}
|
||||
}
|
||||
|
||||
player.getStat().recalculateStats(true);
|
||||
player.sendSkillList();
|
||||
playable.getStat().recalculateStats(true);
|
||||
if (playable.isPlayer())
|
||||
{
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(Player player)
|
||||
public void remove(Playable playable)
|
||||
{
|
||||
if (hasEffects())
|
||||
{
|
||||
for (BuffInfo info : player.getEffectList().getOptions())
|
||||
for (BuffInfo info : playable.getEffectList().getOptions())
|
||||
{
|
||||
if (info.getOption() == this)
|
||||
{
|
||||
player.getEffectList().remove(info, SkillFinishType.NORMAL, true, true);
|
||||
playable.getEffectList().remove(info, SkillFinishType.NORMAL, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -228,45 +231,48 @@ public class Options
|
||||
{
|
||||
for (Skill skill : _activeSkill)
|
||||
{
|
||||
player.removeSkill(skill, false, false);
|
||||
playable.removeSkill(skill, false);
|
||||
}
|
||||
}
|
||||
if (hasPassiveSkills())
|
||||
{
|
||||
for (Skill skill : _passiveSkill)
|
||||
{
|
||||
player.removeSkill(skill, false, true);
|
||||
playable.removeSkill(skill, true);
|
||||
}
|
||||
}
|
||||
if (hasActivationSkills())
|
||||
{
|
||||
for (OptionSkillHolder holder : _activationSkills)
|
||||
{
|
||||
player.removeTriggerSkill(holder);
|
||||
playable.removeTriggerSkill(holder);
|
||||
}
|
||||
}
|
||||
|
||||
player.getStat().recalculateStats(true);
|
||||
player.sendSkillList();
|
||||
playable.getStat().recalculateStats(true);
|
||||
if (playable.isPlayer())
|
||||
{
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
}
|
||||
|
||||
private void addSkill(Player player, Skill skill)
|
||||
private void addSkill(Playable playable, Skill skill)
|
||||
{
|
||||
boolean updateTimeStamp = false;
|
||||
player.addSkill(skill, false);
|
||||
playable.addSkill(skill);
|
||||
if (skill.isActive())
|
||||
{
|
||||
final long remainingTime = player.getSkillRemainingReuseTime(skill.getReuseHashCode());
|
||||
final long remainingTime = playable.getSkillRemainingReuseTime(skill.getReuseHashCode());
|
||||
if (remainingTime > 0)
|
||||
{
|
||||
player.addTimeStamp(skill, remainingTime);
|
||||
player.disableSkill(skill, remainingTime);
|
||||
playable.addTimeStamp(skill, remainingTime);
|
||||
playable.disableSkill(skill, remainingTime);
|
||||
}
|
||||
updateTimeStamp = true;
|
||||
}
|
||||
if (updateTimeStamp)
|
||||
if (updateTimeStamp && playable.isPlayer())
|
||||
{
|
||||
player.sendPacket(new SkillCoolTime(player));
|
||||
playable.sendPacket(new SkillCoolTime(playable.getActingPlayer()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.data.xml.ArmorSetData;
|
||||
import org.l2jmobius.gameserver.model.ArmorSet;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.model.stats.BaseStat;
|
||||
@ -82,7 +83,7 @@ public final class PaperdollCache
|
||||
return value;
|
||||
}
|
||||
|
||||
public int getMaxSetEnchant(Player player)
|
||||
public int getMaxSetEnchant(Playable playable)
|
||||
{
|
||||
if (_maxSetEnchant >= 0)
|
||||
{
|
||||
@ -94,7 +95,7 @@ public final class PaperdollCache
|
||||
{
|
||||
for (ArmorSet set : ArmorSetData.getInstance().getSets(item.getId()))
|
||||
{
|
||||
final int enchantEffect = set.getLowestSetEnchant(player);
|
||||
final int enchantEffect = set.getLowestSetEnchant(playable);
|
||||
if (enchantEffect > maxSetEnchant)
|
||||
{
|
||||
maxSetEnchant = enchantEffect;
|
||||
|
@ -22,11 +22,10 @@ import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.holders.ArmorsetSkillHolder;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import org.l2jmobius.gameserver.model.itemcontainer.PlayerInventory;
|
||||
import org.l2jmobius.gameserver.model.stats.BaseStat;
|
||||
|
||||
/**
|
||||
@ -162,18 +161,18 @@ public class ArmorSet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param playable
|
||||
* @return true if all parts of set are enchanted to +6 or more
|
||||
*/
|
||||
public int getLowestSetEnchant(Player player)
|
||||
public int getLowestSetEnchant(Playable playable)
|
||||
{
|
||||
// Player don't have full set
|
||||
if (getPiecesCountById(player) < _minimumPieces)
|
||||
// Playable don't have full set
|
||||
if (getPiecesCountById(playable) < _minimumPieces)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
final PlayerInventory inv = player.getInventory();
|
||||
final Inventory inv = playable.getInventory();
|
||||
int enchantLevel = Byte.MAX_VALUE;
|
||||
for (int armorSlot : ARMORSET_SLOTS)
|
||||
{
|
||||
@ -192,13 +191,13 @@ public class ArmorSet
|
||||
|
||||
/**
|
||||
* Condition for 3 Lv. Set Effect Applied Skill
|
||||
* @param player
|
||||
* @param playable
|
||||
* @param bookSlot
|
||||
* @return total paperdoll(busy) count for 1 of 3 artifact book slots
|
||||
*/
|
||||
public int getArtifactSlotMask(Player player, int bookSlot)
|
||||
public int getArtifactSlotMask(Playable playable, int bookSlot)
|
||||
{
|
||||
final PlayerInventory inv = player.getInventory();
|
||||
final Inventory inv = playable.getInventory();
|
||||
int slotMask = 0;
|
||||
switch (bookSlot)
|
||||
{
|
||||
@ -242,23 +241,23 @@ public class ArmorSet
|
||||
return slotMask;
|
||||
}
|
||||
|
||||
public boolean hasOptionalEquipped(Player player, Function<Item, Integer> idProvider)
|
||||
public boolean hasOptionalEquipped(Playable playable, Function<Item, Integer> idProvider)
|
||||
{
|
||||
return player.getInventory().getPaperdollItems().stream().anyMatch(item -> CommonUtil.contains(_optionalItems, idProvider.apply(item)));
|
||||
return playable.getInventory().getPaperdollItems().stream().anyMatch(item -> CommonUtil.contains(_optionalItems, idProvider.apply(item)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param playable
|
||||
* @param idProvider
|
||||
* @return the amount of set visual items that player has equipped
|
||||
* @return the amount of set visual items that playable has equipped
|
||||
*/
|
||||
public long getPiecesCount(Player player, Function<Item, Integer> idProvider)
|
||||
public long getPiecesCount(Playable playable, Function<Item, Integer> idProvider)
|
||||
{
|
||||
return player.getInventory().getPaperdollItemCount(item -> CommonUtil.contains(_requiredItems, idProvider.apply(item)));
|
||||
return playable.getInventory().getPaperdollItemCount(item -> CommonUtil.contains(_requiredItems, idProvider.apply(item)));
|
||||
}
|
||||
|
||||
public long getPiecesCountById(Player player)
|
||||
public long getPiecesCountById(Playable playable)
|
||||
{
|
||||
return player.getInventory().getPaperdollItemCount(item -> CommonUtil.contains(_requiredItems, item.getId()));
|
||||
return playable.getInventory().getPaperdollItemCount(item -> CommonUtil.contains(_requiredItems, item.getId()));
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import org.l2jmobius.gameserver.data.xml.OptionData;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.options.Options;
|
||||
|
||||
/**
|
||||
@ -59,27 +59,27 @@ public class VariationInstance
|
||||
return _option2 == null ? -1 : _option2.getId();
|
||||
}
|
||||
|
||||
public void applyBonus(Player player)
|
||||
public void applyBonus(Playable playable)
|
||||
{
|
||||
if (_option1 != null)
|
||||
{
|
||||
_option1.apply(player);
|
||||
_option1.apply(playable);
|
||||
}
|
||||
if (_option2 != null)
|
||||
{
|
||||
_option2.apply(player);
|
||||
_option2.apply(playable);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeBonus(Player player)
|
||||
public void removeBonus(Playable playable)
|
||||
{
|
||||
if (_option1 != null)
|
||||
{
|
||||
_option1.remove(player);
|
||||
_option1.remove(playable);
|
||||
}
|
||||
if (_option2 != null)
|
||||
{
|
||||
_option2.remove(player);
|
||||
_option2.remove(playable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.holders;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.l2jmobius.gameserver.model.ArmorSet;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
|
||||
/**
|
||||
@ -58,34 +58,34 @@ public class ArmorsetSkillHolder extends SkillHolder
|
||||
return _isOptional;
|
||||
}
|
||||
|
||||
public boolean validateConditions(Player player, ArmorSet armorSet, Function<Item, Integer> idProvider)
|
||||
public boolean validateConditions(Playable playable, ArmorSet armorSet, Function<Item, Integer> idProvider)
|
||||
{
|
||||
// Player's doesn't have full busy (1 of 3) artifact real slot
|
||||
if (_artifactSlotMask > armorSet.getArtifactSlotMask(player, _artifactBookSlot))
|
||||
// Playable doesn't have full busy (1 of 3) artifact real slot
|
||||
if (_artifactSlotMask > armorSet.getArtifactSlotMask(playable, _artifactBookSlot))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Player doesn't have enough items equipped to use this skill
|
||||
if (_minimumPieces > armorSet.getPiecesCount(player, idProvider))
|
||||
// Playable doesn't have enough items equipped to use this skill
|
||||
if (_minimumPieces > armorSet.getPiecesCount(playable, idProvider))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Player's set enchantment isn't enough to use this skill
|
||||
if (_minEnchant > armorSet.getLowestSetEnchant(player))
|
||||
// Playable set enchantment isn't enough to use this skill
|
||||
if (_minEnchant > armorSet.getLowestSetEnchant(playable))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Player doesn't have the required item to use this skill
|
||||
if (_isOptional && !armorSet.hasOptionalEquipped(player, idProvider))
|
||||
// Playable doesn't have the required item to use this skill
|
||||
if (_isOptional && !armorSet.hasOptionalEquipped(playable, idProvider))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Player already knows that skill
|
||||
if (player.getSkillLevel(getSkillId()) == getSkillLevel())
|
||||
// Playable already knows that skill
|
||||
if (playable.getSkillLevel(getSkillId()) == getSkillLevel())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ import org.l2jmobius.gameserver.model.ArmorSet;
|
||||
import org.l2jmobius.gameserver.model.VariationInstance;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerItemUnequip;
|
||||
@ -319,12 +320,12 @@ public abstract class Inventory extends ItemContainer
|
||||
@Override
|
||||
public void notifyUnequiped(int slot, Item item, Inventory inventory)
|
||||
{
|
||||
if (!inventory.getOwner().isPlayer())
|
||||
if (!inventory.getOwner().isPlayable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = (Player) inventory.getOwner();
|
||||
final Playable playable = (Playable) inventory.getOwner();
|
||||
final ItemTemplate it = item.getTemplate();
|
||||
final Map<Integer, Skill> addedSkills = new HashMap<>(1);
|
||||
final Map<Integer, Skill> removedSkills = new HashMap<>(1);
|
||||
@ -334,11 +335,11 @@ public abstract class Inventory extends ItemContainer
|
||||
// Remove augmentation bonuses on unequip
|
||||
if (item.isAugmented())
|
||||
{
|
||||
item.getAugmentation().removeBonus(player);
|
||||
item.getAugmentation().removeBonus(playable);
|
||||
}
|
||||
|
||||
// Recalculate all stats
|
||||
player.getStat().recalculateStats(true);
|
||||
playable.getStat().recalculateStats(true);
|
||||
|
||||
// Clear enchant bonus
|
||||
item.clearEnchantStats();
|
||||
@ -415,7 +416,7 @@ public abstract class Inventory extends ItemContainer
|
||||
|
||||
for (ItemSkillHolder holder : otherNormalSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) != 0)
|
||||
if (playable.getSkillLevel(holder.getSkillId()) != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -439,13 +440,13 @@ public abstract class Inventory extends ItemContainer
|
||||
addedSkills.put(skill.getId(), skill);
|
||||
}
|
||||
|
||||
if (skill.isActive() && !player.hasSkillReuse(skill.getReuseHashCode()))
|
||||
if (skill.isActive() && !playable.hasSkillReuse(skill.getReuseHashCode()))
|
||||
{
|
||||
final int equipDelay = item.getEquipReuseDelay();
|
||||
if (equipDelay > 0)
|
||||
{
|
||||
player.addTimeStamp(skill, equipDelay);
|
||||
player.disableSkill(skill, equipDelay);
|
||||
playable.addTimeStamp(skill, equipDelay);
|
||||
playable.disableSkill(skill, equipDelay);
|
||||
}
|
||||
updateTimestamp = true;
|
||||
}
|
||||
@ -486,7 +487,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
removedSkills.putIfAbsent(skill.getId(), skill);
|
||||
update = true;
|
||||
@ -505,7 +506,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
removedSkills.putIfAbsent(skill.getId(), skill);
|
||||
update = true;
|
||||
@ -515,12 +516,12 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Must check for toggle and isRemovedOnUnequipWeapon skill item conditions.
|
||||
for (Skill skill : player.getAllSkills())
|
||||
for (Skill skill : playable.getAllSkills())
|
||||
{
|
||||
if ((skill.isToggle() && player.isAffectedBySkill(skill.getId()) && !skill.checkConditions(SkillConditionScope.GENERAL, player, player)) //
|
||||
if ((skill.isToggle() && playable.isAffectedBySkill(skill.getId()) && !skill.checkConditions(SkillConditionScope.GENERAL, playable, playable)) //
|
||||
|| (it.isWeapon() && skill.isRemovedOnUnequipWeapon()))
|
||||
{
|
||||
player.stopSkillEffects(SkillFinishType.REMOVED, skill.getId());
|
||||
playable.stopSkillEffects(SkillFinishType.REMOVED, skill.getId());
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
@ -528,55 +529,58 @@ public abstract class Inventory extends ItemContainer
|
||||
// Apply skill, if item has "skills on unequip" and it is not a secondary agathion.
|
||||
if ((slot < PAPERDOLL_AGATHION2) || (slot > PAPERDOLL_AGATHION5))
|
||||
{
|
||||
it.forEachSkill(ItemSkillType.ON_UNEQUIP, holder -> holder.getSkill().activateSkill(player, player));
|
||||
it.forEachSkill(ItemSkillType.ON_UNEQUIP, holder -> holder.getSkill().activateSkill(playable, playable));
|
||||
}
|
||||
|
||||
if (update)
|
||||
{
|
||||
for (Skill skill : removedSkills.values())
|
||||
{
|
||||
player.removeSkill(skill, false, skill.isPassive());
|
||||
playable.removeSkill(skill, skill.isPassive());
|
||||
}
|
||||
|
||||
for (Skill skill : addedSkills.values())
|
||||
{
|
||||
player.addSkill(skill, false);
|
||||
playable.addSkill(skill);
|
||||
}
|
||||
|
||||
player.sendSkillList();
|
||||
if (playable.isPlayer())
|
||||
{
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
}
|
||||
|
||||
if (updateTimestamp)
|
||||
if (updateTimestamp && playable.isPlayer())
|
||||
{
|
||||
player.sendPacket(new SkillCoolTime(player));
|
||||
playable.sendPacket(new SkillCoolTime(playable.getActingPlayer()));
|
||||
}
|
||||
|
||||
if (item.isWeapon())
|
||||
{
|
||||
player.unchargeAllShots();
|
||||
playable.unchargeAllShots();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyEquiped(int slot, Item item, Inventory inventory)
|
||||
{
|
||||
if (!inventory.getOwner().isPlayer())
|
||||
if (!inventory.getOwner().isPlayable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = (Player) inventory.getOwner();
|
||||
final Playable playable = (Playable) inventory.getOwner();
|
||||
final Map<Integer, Skill> addedSkills = new HashMap<>(1);
|
||||
boolean updateTimestamp = false;
|
||||
|
||||
// Apply augmentation bonuses on equip
|
||||
if (item.isAugmented())
|
||||
{
|
||||
item.getAugmentation().applyBonus(player);
|
||||
item.getAugmentation().applyBonus(playable);
|
||||
}
|
||||
|
||||
// Recalculate all stats
|
||||
player.getStat().recalculateStats(true);
|
||||
playable.getStat().recalculateStats(true);
|
||||
|
||||
// Apply enchant stats
|
||||
item.applyEnchantStats();
|
||||
@ -591,7 +595,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
for (ItemSkillHolder holder : onEnchantSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -608,7 +612,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -635,7 +639,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
for (ItemSkillHolder holder : onBlessingSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -652,7 +656,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -678,7 +682,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
for (ItemSkillHolder holder : normalSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -690,7 +694,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -708,13 +712,13 @@ public abstract class Inventory extends ItemContainer
|
||||
addedSkills.put(skill.getId(), skill);
|
||||
}
|
||||
|
||||
if (skill.isActive() && !player.hasSkillReuse(skill.getReuseHashCode()))
|
||||
if (skill.isActive() && !playable.hasSkillReuse(skill.getReuseHashCode()))
|
||||
{
|
||||
final int equipDelay = item.getEquipReuseDelay();
|
||||
if (equipDelay > 0)
|
||||
{
|
||||
player.addTimeStamp(skill, equipDelay);
|
||||
player.disableSkill(skill, equipDelay);
|
||||
playable.addTimeStamp(skill, equipDelay);
|
||||
playable.disableSkill(skill, equipDelay);
|
||||
}
|
||||
updateTimestamp = true;
|
||||
}
|
||||
@ -741,7 +745,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
for (ItemSkillHolder holder : otherEnchantSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -758,7 +762,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -782,7 +786,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
for (ItemSkillHolder holder : otherBlessingSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -796,7 +800,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -821,22 +825,25 @@ public abstract class Inventory extends ItemContainer
|
||||
// Apply skill, if item has "skills on equip" and it is not a secondary agathion.
|
||||
if ((slot < PAPERDOLL_AGATHION2) || (slot > PAPERDOLL_AGATHION5))
|
||||
{
|
||||
item.getTemplate().forEachSkill(ItemSkillType.ON_EQUIP, holder -> holder.getSkill().activateSkill(player, player));
|
||||
item.getTemplate().forEachSkill(ItemSkillType.ON_EQUIP, holder -> holder.getSkill().activateSkill(playable, playable));
|
||||
}
|
||||
|
||||
if (!addedSkills.isEmpty())
|
||||
{
|
||||
for (Skill skill : addedSkills.values())
|
||||
{
|
||||
player.addSkill(skill, false);
|
||||
playable.addSkill(skill);
|
||||
}
|
||||
|
||||
player.sendSkillList();
|
||||
if (playable.isPlayer())
|
||||
{
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
}
|
||||
|
||||
if (updateTimestamp)
|
||||
if (updateTimestamp && playable.isPlayer())
|
||||
{
|
||||
player.sendPacket(new SkillCoolTime(player));
|
||||
playable.sendPacket(new SkillCoolTime(playable.getActingPlayer()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -853,16 +860,16 @@ public abstract class Inventory extends ItemContainer
|
||||
@Override
|
||||
public void notifyEquiped(int slot, Item item, Inventory inventory)
|
||||
{
|
||||
if (!inventory.getOwner().isPlayer())
|
||||
if (!inventory.getOwner().isPlayable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = (Player) inventory.getOwner();
|
||||
final Playable playable = (Playable) inventory.getOwner();
|
||||
boolean update = false;
|
||||
|
||||
// Verify and apply normal set
|
||||
if (verifyAndApply(player, item, Item::getId))
|
||||
if (verifyAndApply(playable, item, Item::getId))
|
||||
{
|
||||
update = true;
|
||||
}
|
||||
@ -872,26 +879,26 @@ public abstract class Inventory extends ItemContainer
|
||||
if (itemVisualId > 0)
|
||||
{
|
||||
final AppearanceStone stone = AppearanceItemData.getInstance().getStone(itemVisualId);
|
||||
if ((stone != null) && (stone.getType() == AppearanceType.FIXED) && verifyAndApply(player, item, Item::getVisualId))
|
||||
if ((stone != null) && (stone.getType() == AppearanceType.FIXED) && verifyAndApply(playable, item, Item::getVisualId))
|
||||
{
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (update)
|
||||
if (update && playable.isPlayer())
|
||||
{
|
||||
player.sendSkillList();
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
|
||||
if ((item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH_JEWEL) || (item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH))
|
||||
if (playable.isPlayer() && ((item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH_JEWEL) || (item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH)))
|
||||
{
|
||||
player.updateActiveBroochJewel();
|
||||
playable.getActingPlayer().updateActiveBroochJewel();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean applySkills(Player player, Item item, ArmorSet armorSet, Function<Item, Integer> idProvider)
|
||||
private static boolean applySkills(Playable playable, Item item, ArmorSet armorSet, Function<Item, Integer> idProvider)
|
||||
{
|
||||
final long piecesCount = armorSet.getPiecesCount(player, idProvider);
|
||||
final long piecesCount = armorSet.getPiecesCount(playable, idProvider);
|
||||
if (piecesCount >= armorSet.getMinimumPieces())
|
||||
{
|
||||
// Applying all skills that matching the conditions
|
||||
@ -899,12 +906,12 @@ public abstract class Inventory extends ItemContainer
|
||||
boolean update = false;
|
||||
for (ArmorsetSkillHolder holder : armorSet.getSkills())
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (holder.validateConditions(player, armorSet, idProvider))
|
||||
if (holder.validateConditions(playable, armorSet, idProvider))
|
||||
{
|
||||
final Skill itemSkill = holder.getSkill();
|
||||
if (itemSkill == null)
|
||||
@ -913,21 +920,21 @@ public abstract class Inventory extends ItemContainer
|
||||
continue;
|
||||
}
|
||||
|
||||
if (itemSkill.isPassive() && !itemSkill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (itemSkill.isPassive() && !itemSkill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
player.addSkill(itemSkill, false);
|
||||
playable.addSkill(itemSkill);
|
||||
if (itemSkill.isActive() && (item != null))
|
||||
{
|
||||
if (!player.hasSkillReuse(itemSkill.getReuseHashCode()))
|
||||
if (!playable.hasSkillReuse(itemSkill.getReuseHashCode()))
|
||||
{
|
||||
final int equipDelay = item.getEquipReuseDelay();
|
||||
if (equipDelay > 0)
|
||||
{
|
||||
player.addTimeStamp(itemSkill, equipDelay);
|
||||
player.disableSkill(itemSkill, equipDelay);
|
||||
playable.addTimeStamp(itemSkill, equipDelay);
|
||||
playable.disableSkill(itemSkill, equipDelay);
|
||||
}
|
||||
}
|
||||
updateTimeStamp = true;
|
||||
@ -935,22 +942,22 @@ public abstract class Inventory extends ItemContainer
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
if (updateTimeStamp)
|
||||
if (updateTimeStamp && playable.isPlayer())
|
||||
{
|
||||
player.sendPacket(new SkillCoolTime(player));
|
||||
playable.sendPacket(new SkillCoolTime(playable.getActingPlayer()));
|
||||
}
|
||||
return update;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean verifyAndApply(Player player, Item item, Function<Item, Integer> idProvider)
|
||||
private static boolean verifyAndApply(Playable playable, Item item, Function<Item, Integer> idProvider)
|
||||
{
|
||||
boolean update = false;
|
||||
final List<ArmorSet> armorSets = ArmorSetData.getInstance().getSets(idProvider.apply(item));
|
||||
for (ArmorSet armorSet : armorSets)
|
||||
{
|
||||
if (applySkills(player, item, armorSet, idProvider))
|
||||
if (applySkills(playable, item, armorSet, idProvider))
|
||||
{
|
||||
update = true;
|
||||
}
|
||||
@ -958,7 +965,7 @@ public abstract class Inventory extends ItemContainer
|
||||
return update;
|
||||
}
|
||||
|
||||
private static boolean verifyAndRemove(Player player, Item item, Function<Item, Integer> idProvider)
|
||||
private static boolean verifyAndRemove(Playable playable, Item item, Function<Item, Integer> idProvider)
|
||||
{
|
||||
boolean update = false;
|
||||
final List<ArmorSet> armorSets = ArmorSetData.getInstance().getSets(idProvider.apply(item));
|
||||
@ -967,7 +974,7 @@ public abstract class Inventory extends ItemContainer
|
||||
// Remove all skills that doesn't matches the conditions
|
||||
for (ArmorsetSkillHolder holder : armorSet.getSkills())
|
||||
{
|
||||
if (!holder.validateConditions(player, armorSet, idProvider))
|
||||
if (!holder.validateConditions(playable, armorSet, idProvider))
|
||||
{
|
||||
final Skill itemSkill = holder.getSkill();
|
||||
if (itemSkill == null)
|
||||
@ -977,7 +984,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Update if a skill has been removed.
|
||||
if (player.removeSkill(itemSkill, false, itemSkill.isPassive()) != null)
|
||||
if (playable.removeSkill(itemSkill, itemSkill.isPassive()) != null)
|
||||
{
|
||||
update = true;
|
||||
}
|
||||
@ -985,7 +992,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Attempt to apply lower level skills if possible
|
||||
if (applySkills(player, item, armorSet, idProvider))
|
||||
if (applySkills(playable, item, armorSet, idProvider))
|
||||
{
|
||||
update = true;
|
||||
}
|
||||
@ -997,16 +1004,16 @@ public abstract class Inventory extends ItemContainer
|
||||
@Override
|
||||
public void notifyUnequiped(int slot, Item item, Inventory inventory)
|
||||
{
|
||||
if (!inventory.getOwner().isPlayer())
|
||||
if (!inventory.getOwner().isPlayable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = (Player) inventory.getOwner();
|
||||
final Playable playable = (Playable) inventory.getOwner();
|
||||
boolean remove = false;
|
||||
|
||||
// Verify and remove normal set bonus
|
||||
if (verifyAndRemove(player, item, Item::getId))
|
||||
if (verifyAndRemove(playable, item, Item::getId))
|
||||
{
|
||||
remove = true;
|
||||
}
|
||||
@ -1016,21 +1023,26 @@ public abstract class Inventory extends ItemContainer
|
||||
if (itemVisualId > 0)
|
||||
{
|
||||
final AppearanceStone stone = AppearanceItemData.getInstance().getStone(itemVisualId);
|
||||
if ((stone != null) && (stone.getType() == AppearanceType.FIXED) && verifyAndRemove(player, item, Item::getVisualId))
|
||||
if ((stone != null) && (stone.getType() == AppearanceType.FIXED) && verifyAndRemove(playable, item, Item::getVisualId))
|
||||
{
|
||||
remove = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!playable.isPlayer())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (remove)
|
||||
{
|
||||
player.checkItemRestriction();
|
||||
player.sendSkillList();
|
||||
playable.getActingPlayer().checkItemRestriction();
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
|
||||
if ((item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH_JEWEL) || (item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH))
|
||||
{
|
||||
player.updateActiveBroochJewel();
|
||||
playable.getActingPlayer().updateActiveBroochJewel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1198,6 +1210,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
_paperdoll = new Item[PAPERDOLL_TOTALSLOTS];
|
||||
_paperdollListeners = new ArrayList<>();
|
||||
|
||||
if (this instanceof PlayerInventory)
|
||||
{
|
||||
addPaperdollListener(ArmorSetListener.getInstance());
|
||||
@ -1208,6 +1221,11 @@ public abstract class Inventory extends ItemContainer
|
||||
addPaperdollListener(AgathionBraceletListener.getInstance());
|
||||
addPaperdollListener(ArtifactBookListener.getInstance());
|
||||
}
|
||||
else if (this instanceof PetInventory)
|
||||
{
|
||||
addPaperdollListener(ArmorSetListener.getInstance());
|
||||
addPaperdollListener(ItemSkillsListener.getInstance());
|
||||
}
|
||||
|
||||
// common
|
||||
addPaperdollListener(StatsListener.getInstance());
|
||||
@ -2704,12 +2722,12 @@ public abstract class Inventory extends ItemContainer
|
||||
|
||||
public int getArmorMinEnchant()
|
||||
{
|
||||
if ((getOwner() == null) || !getOwner().isPlayer())
|
||||
if ((getOwner() == null) || !getOwner().isPlayable())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
final Player player = getOwner().getActingPlayer();
|
||||
final Playable player = (Playable) getOwner();
|
||||
return _paperdollCache.getMaxSetEnchant(player);
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.gameserver.enums.SkillFinishType;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import org.l2jmobius.gameserver.model.skill.BuffInfo;
|
||||
import org.l2jmobius.gameserver.model.skill.Skill;
|
||||
@ -157,11 +157,11 @@ public class Options
|
||||
_activationSkills.add(holder);
|
||||
}
|
||||
|
||||
public void apply(Player player)
|
||||
public void apply(Playable playable)
|
||||
{
|
||||
if (hasEffects())
|
||||
{
|
||||
final BuffInfo info = new BuffInfo(player, player, null, true, null, this);
|
||||
final BuffInfo info = new BuffInfo(playable, playable, null, true, null, this);
|
||||
for (AbstractEffect effect : _effects)
|
||||
{
|
||||
if (effect.isInstant())
|
||||
@ -174,7 +174,7 @@ public class Options
|
||||
else
|
||||
{
|
||||
effect.continuousInstant(info.getEffector(), info.getEffected(), info.getSkill(), info.getItem());
|
||||
effect.pump(player, info.getSkill());
|
||||
effect.pump(playable, info.getSkill());
|
||||
if (effect.canStart(info.getEffector(), info.getEffected(), info.getSkill()))
|
||||
{
|
||||
info.addEffect(effect);
|
||||
@ -183,44 +183,47 @@ public class Options
|
||||
}
|
||||
if (!info.getEffects().isEmpty())
|
||||
{
|
||||
player.getEffectList().add(info);
|
||||
playable.getEffectList().add(info);
|
||||
}
|
||||
}
|
||||
if (hasActiveSkills())
|
||||
{
|
||||
for (Skill skill : _activeSkill)
|
||||
{
|
||||
addSkill(player, skill);
|
||||
addSkill(playable, skill);
|
||||
}
|
||||
}
|
||||
if (hasPassiveSkills())
|
||||
{
|
||||
for (Skill skill : _passiveSkill)
|
||||
{
|
||||
addSkill(player, skill);
|
||||
addSkill(playable, skill);
|
||||
}
|
||||
}
|
||||
if (hasActivationSkills())
|
||||
{
|
||||
for (OptionSkillHolder holder : _activationSkills)
|
||||
{
|
||||
player.addTriggerSkill(holder);
|
||||
playable.addTriggerSkill(holder);
|
||||
}
|
||||
}
|
||||
|
||||
player.getStat().recalculateStats(true);
|
||||
player.sendSkillList();
|
||||
playable.getStat().recalculateStats(true);
|
||||
if (playable.isPlayer())
|
||||
{
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(Player player)
|
||||
public void remove(Playable playable)
|
||||
{
|
||||
if (hasEffects())
|
||||
{
|
||||
for (BuffInfo info : player.getEffectList().getOptions())
|
||||
for (BuffInfo info : playable.getEffectList().getOptions())
|
||||
{
|
||||
if (info.getOption() == this)
|
||||
{
|
||||
player.getEffectList().remove(info, SkillFinishType.NORMAL, true, true);
|
||||
playable.getEffectList().remove(info, SkillFinishType.NORMAL, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -228,45 +231,48 @@ public class Options
|
||||
{
|
||||
for (Skill skill : _activeSkill)
|
||||
{
|
||||
player.removeSkill(skill, false, false);
|
||||
playable.removeSkill(skill, false);
|
||||
}
|
||||
}
|
||||
if (hasPassiveSkills())
|
||||
{
|
||||
for (Skill skill : _passiveSkill)
|
||||
{
|
||||
player.removeSkill(skill, false, true);
|
||||
playable.removeSkill(skill, true);
|
||||
}
|
||||
}
|
||||
if (hasActivationSkills())
|
||||
{
|
||||
for (OptionSkillHolder holder : _activationSkills)
|
||||
{
|
||||
player.removeTriggerSkill(holder);
|
||||
playable.removeTriggerSkill(holder);
|
||||
}
|
||||
}
|
||||
|
||||
player.getStat().recalculateStats(true);
|
||||
player.sendSkillList();
|
||||
playable.getStat().recalculateStats(true);
|
||||
if (playable.isPlayer())
|
||||
{
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
}
|
||||
|
||||
private void addSkill(Player player, Skill skill)
|
||||
private void addSkill(Playable playable, Skill skill)
|
||||
{
|
||||
boolean updateTimeStamp = false;
|
||||
player.addSkill(skill, false);
|
||||
playable.addSkill(skill);
|
||||
if (skill.isActive())
|
||||
{
|
||||
final long remainingTime = player.getSkillRemainingReuseTime(skill.getReuseHashCode());
|
||||
final long remainingTime = playable.getSkillRemainingReuseTime(skill.getReuseHashCode());
|
||||
if (remainingTime > 0)
|
||||
{
|
||||
player.addTimeStamp(skill, remainingTime);
|
||||
player.disableSkill(skill, remainingTime);
|
||||
playable.addTimeStamp(skill, remainingTime);
|
||||
playable.disableSkill(skill, remainingTime);
|
||||
}
|
||||
updateTimeStamp = true;
|
||||
}
|
||||
if (updateTimeStamp)
|
||||
if (updateTimeStamp && playable.isPlayer())
|
||||
{
|
||||
player.sendPacket(new SkillCoolTime(player));
|
||||
playable.sendPacket(new SkillCoolTime(playable.getActingPlayer()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.data.xml.ArmorSetData;
|
||||
import org.l2jmobius.gameserver.model.ArmorSet;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.model.stats.BaseStat;
|
||||
@ -82,7 +83,7 @@ public final class PaperdollCache
|
||||
return value;
|
||||
}
|
||||
|
||||
public int getMaxSetEnchant(Player player)
|
||||
public int getMaxSetEnchant(Playable playable)
|
||||
{
|
||||
if (_maxSetEnchant >= 0)
|
||||
{
|
||||
@ -94,7 +95,7 @@ public final class PaperdollCache
|
||||
{
|
||||
for (ArmorSet set : ArmorSetData.getInstance().getSets(item.getId()))
|
||||
{
|
||||
final int enchantEffect = set.getLowestSetEnchant(player);
|
||||
final int enchantEffect = set.getLowestSetEnchant(playable);
|
||||
if (enchantEffect > maxSetEnchant)
|
||||
{
|
||||
maxSetEnchant = enchantEffect;
|
||||
|
@ -22,11 +22,10 @@ import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.holders.ArmorsetSkillHolder;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import org.l2jmobius.gameserver.model.itemcontainer.PlayerInventory;
|
||||
import org.l2jmobius.gameserver.model.stats.BaseStat;
|
||||
|
||||
/**
|
||||
@ -162,18 +161,18 @@ public class ArmorSet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param playable
|
||||
* @return true if all parts of set are enchanted to +6 or more
|
||||
*/
|
||||
public int getLowestSetEnchant(Player player)
|
||||
public int getLowestSetEnchant(Playable playable)
|
||||
{
|
||||
// Player don't have full set
|
||||
if (getPiecesCountById(player) < _minimumPieces)
|
||||
// Playable don't have full set
|
||||
if (getPiecesCountById(playable) < _minimumPieces)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
final PlayerInventory inv = player.getInventory();
|
||||
final Inventory inv = playable.getInventory();
|
||||
int enchantLevel = Byte.MAX_VALUE;
|
||||
for (int armorSlot : ARMORSET_SLOTS)
|
||||
{
|
||||
@ -192,13 +191,13 @@ public class ArmorSet
|
||||
|
||||
/**
|
||||
* Condition for 3 Lv. Set Effect Applied Skill
|
||||
* @param player
|
||||
* @param playable
|
||||
* @param bookSlot
|
||||
* @return total paperdoll(busy) count for 1 of 3 artifact book slots
|
||||
*/
|
||||
public int getArtifactSlotMask(Player player, int bookSlot)
|
||||
public int getArtifactSlotMask(Playable playable, int bookSlot)
|
||||
{
|
||||
final PlayerInventory inv = player.getInventory();
|
||||
final Inventory inv = playable.getInventory();
|
||||
int slotMask = 0;
|
||||
switch (bookSlot)
|
||||
{
|
||||
@ -242,23 +241,23 @@ public class ArmorSet
|
||||
return slotMask;
|
||||
}
|
||||
|
||||
public boolean hasOptionalEquipped(Player player, Function<Item, Integer> idProvider)
|
||||
public boolean hasOptionalEquipped(Playable playable, Function<Item, Integer> idProvider)
|
||||
{
|
||||
return player.getInventory().getPaperdollItems().stream().anyMatch(item -> CommonUtil.contains(_optionalItems, idProvider.apply(item)));
|
||||
return playable.getInventory().getPaperdollItems().stream().anyMatch(item -> CommonUtil.contains(_optionalItems, idProvider.apply(item)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param playable
|
||||
* @param idProvider
|
||||
* @return the amount of set visual items that player has equipped
|
||||
* @return the amount of set visual items that playable has equipped
|
||||
*/
|
||||
public long getPiecesCount(Player player, Function<Item, Integer> idProvider)
|
||||
public long getPiecesCount(Playable playable, Function<Item, Integer> idProvider)
|
||||
{
|
||||
return player.getInventory().getPaperdollItemCount(item -> CommonUtil.contains(_requiredItems, idProvider.apply(item)));
|
||||
return playable.getInventory().getPaperdollItemCount(item -> CommonUtil.contains(_requiredItems, idProvider.apply(item)));
|
||||
}
|
||||
|
||||
public long getPiecesCountById(Player player)
|
||||
public long getPiecesCountById(Playable playable)
|
||||
{
|
||||
return player.getInventory().getPaperdollItemCount(item -> CommonUtil.contains(_requiredItems, item.getId()));
|
||||
return playable.getInventory().getPaperdollItemCount(item -> CommonUtil.contains(_requiredItems, item.getId()));
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import org.l2jmobius.gameserver.data.xml.OptionData;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.options.Options;
|
||||
|
||||
/**
|
||||
@ -59,27 +59,27 @@ public class VariationInstance
|
||||
return _option2 == null ? -1 : _option2.getId();
|
||||
}
|
||||
|
||||
public void applyBonus(Player player)
|
||||
public void applyBonus(Playable playable)
|
||||
{
|
||||
if (_option1 != null)
|
||||
{
|
||||
_option1.apply(player);
|
||||
_option1.apply(playable);
|
||||
}
|
||||
if (_option2 != null)
|
||||
{
|
||||
_option2.apply(player);
|
||||
_option2.apply(playable);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeBonus(Player player)
|
||||
public void removeBonus(Playable playable)
|
||||
{
|
||||
if (_option1 != null)
|
||||
{
|
||||
_option1.remove(player);
|
||||
_option1.remove(playable);
|
||||
}
|
||||
if (_option2 != null)
|
||||
{
|
||||
_option2.remove(player);
|
||||
_option2.remove(playable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.holders;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.l2jmobius.gameserver.model.ArmorSet;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
|
||||
/**
|
||||
@ -58,34 +58,34 @@ public class ArmorsetSkillHolder extends SkillHolder
|
||||
return _isOptional;
|
||||
}
|
||||
|
||||
public boolean validateConditions(Player player, ArmorSet armorSet, Function<Item, Integer> idProvider)
|
||||
public boolean validateConditions(Playable playable, ArmorSet armorSet, Function<Item, Integer> idProvider)
|
||||
{
|
||||
// Player's doesn't have full busy (1 of 3) artifact real slot
|
||||
if (_artifactSlotMask > armorSet.getArtifactSlotMask(player, _artifactBookSlot))
|
||||
// Playable doesn't have full busy (1 of 3) artifact real slot
|
||||
if (_artifactSlotMask > armorSet.getArtifactSlotMask(playable, _artifactBookSlot))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Player doesn't have enough items equipped to use this skill
|
||||
if (_minimumPieces > armorSet.getPiecesCount(player, idProvider))
|
||||
// Playable doesn't have enough items equipped to use this skill
|
||||
if (_minimumPieces > armorSet.getPiecesCount(playable, idProvider))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Player's set enchantment isn't enough to use this skill
|
||||
if (_minEnchant > armorSet.getLowestSetEnchant(player))
|
||||
// Playable set enchantment isn't enough to use this skill
|
||||
if (_minEnchant > armorSet.getLowestSetEnchant(playable))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Player doesn't have the required item to use this skill
|
||||
if (_isOptional && !armorSet.hasOptionalEquipped(player, idProvider))
|
||||
// Playable doesn't have the required item to use this skill
|
||||
if (_isOptional && !armorSet.hasOptionalEquipped(playable, idProvider))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Player already knows that skill
|
||||
if (player.getSkillLevel(getSkillId()) == getSkillLevel())
|
||||
// Playable already knows that skill
|
||||
if (playable.getSkillLevel(getSkillId()) == getSkillLevel())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ import org.l2jmobius.gameserver.model.ArmorSet;
|
||||
import org.l2jmobius.gameserver.model.VariationInstance;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerItemUnequip;
|
||||
@ -319,12 +320,12 @@ public abstract class Inventory extends ItemContainer
|
||||
@Override
|
||||
public void notifyUnequiped(int slot, Item item, Inventory inventory)
|
||||
{
|
||||
if (!inventory.getOwner().isPlayer())
|
||||
if (!inventory.getOwner().isPlayable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = (Player) inventory.getOwner();
|
||||
final Playable playable = (Playable) inventory.getOwner();
|
||||
final ItemTemplate it = item.getTemplate();
|
||||
final Map<Integer, Skill> addedSkills = new HashMap<>(1);
|
||||
final Map<Integer, Skill> removedSkills = new HashMap<>(1);
|
||||
@ -334,11 +335,11 @@ public abstract class Inventory extends ItemContainer
|
||||
// Remove augmentation bonuses on unequip
|
||||
if (item.isAugmented())
|
||||
{
|
||||
item.getAugmentation().removeBonus(player);
|
||||
item.getAugmentation().removeBonus(playable);
|
||||
}
|
||||
|
||||
// Recalculate all stats
|
||||
player.getStat().recalculateStats(true);
|
||||
playable.getStat().recalculateStats(true);
|
||||
|
||||
// Clear enchant bonus
|
||||
item.clearEnchantStats();
|
||||
@ -415,7 +416,7 @@ public abstract class Inventory extends ItemContainer
|
||||
|
||||
for (ItemSkillHolder holder : otherNormalSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) != 0)
|
||||
if (playable.getSkillLevel(holder.getSkillId()) != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -439,13 +440,13 @@ public abstract class Inventory extends ItemContainer
|
||||
addedSkills.put(skill.getId(), skill);
|
||||
}
|
||||
|
||||
if (skill.isActive() && !player.hasSkillReuse(skill.getReuseHashCode()))
|
||||
if (skill.isActive() && !playable.hasSkillReuse(skill.getReuseHashCode()))
|
||||
{
|
||||
final int equipDelay = item.getEquipReuseDelay();
|
||||
if (equipDelay > 0)
|
||||
{
|
||||
player.addTimeStamp(skill, equipDelay);
|
||||
player.disableSkill(skill, equipDelay);
|
||||
playable.addTimeStamp(skill, equipDelay);
|
||||
playable.disableSkill(skill, equipDelay);
|
||||
}
|
||||
updateTimestamp = true;
|
||||
}
|
||||
@ -486,7 +487,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
removedSkills.putIfAbsent(skill.getId(), skill);
|
||||
update = true;
|
||||
@ -505,7 +506,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
removedSkills.putIfAbsent(skill.getId(), skill);
|
||||
update = true;
|
||||
@ -515,12 +516,12 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Must check for toggle and isRemovedOnUnequipWeapon skill item conditions.
|
||||
for (Skill skill : player.getAllSkills())
|
||||
for (Skill skill : playable.getAllSkills())
|
||||
{
|
||||
if ((skill.isToggle() && player.isAffectedBySkill(skill.getId()) && !skill.checkConditions(SkillConditionScope.GENERAL, player, player)) //
|
||||
if ((skill.isToggle() && playable.isAffectedBySkill(skill.getId()) && !skill.checkConditions(SkillConditionScope.GENERAL, playable, playable)) //
|
||||
|| (it.isWeapon() && skill.isRemovedOnUnequipWeapon()))
|
||||
{
|
||||
player.stopSkillEffects(SkillFinishType.REMOVED, skill.getId());
|
||||
playable.stopSkillEffects(SkillFinishType.REMOVED, skill.getId());
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
@ -528,55 +529,58 @@ public abstract class Inventory extends ItemContainer
|
||||
// Apply skill, if item has "skills on unequip" and it is not a secondary agathion.
|
||||
if ((slot < PAPERDOLL_AGATHION2) || (slot > PAPERDOLL_AGATHION5))
|
||||
{
|
||||
it.forEachSkill(ItemSkillType.ON_UNEQUIP, holder -> holder.getSkill().activateSkill(player, player));
|
||||
it.forEachSkill(ItemSkillType.ON_UNEQUIP, holder -> holder.getSkill().activateSkill(playable, playable));
|
||||
}
|
||||
|
||||
if (update)
|
||||
{
|
||||
for (Skill skill : removedSkills.values())
|
||||
{
|
||||
player.removeSkill(skill, false, skill.isPassive());
|
||||
playable.removeSkill(skill, skill.isPassive());
|
||||
}
|
||||
|
||||
for (Skill skill : addedSkills.values())
|
||||
{
|
||||
player.addSkill(skill, false);
|
||||
playable.addSkill(skill);
|
||||
}
|
||||
|
||||
player.sendSkillList();
|
||||
if (playable.isPlayer())
|
||||
{
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
}
|
||||
|
||||
if (updateTimestamp)
|
||||
if (updateTimestamp && playable.isPlayer())
|
||||
{
|
||||
player.sendPacket(new SkillCoolTime(player));
|
||||
playable.sendPacket(new SkillCoolTime(playable.getActingPlayer()));
|
||||
}
|
||||
|
||||
if (item.isWeapon())
|
||||
{
|
||||
player.unchargeAllShots();
|
||||
playable.unchargeAllShots();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyEquiped(int slot, Item item, Inventory inventory)
|
||||
{
|
||||
if (!inventory.getOwner().isPlayer())
|
||||
if (!inventory.getOwner().isPlayable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = (Player) inventory.getOwner();
|
||||
final Playable playable = (Playable) inventory.getOwner();
|
||||
final Map<Integer, Skill> addedSkills = new HashMap<>(1);
|
||||
boolean updateTimestamp = false;
|
||||
|
||||
// Apply augmentation bonuses on equip
|
||||
if (item.isAugmented())
|
||||
{
|
||||
item.getAugmentation().applyBonus(player);
|
||||
item.getAugmentation().applyBonus(playable);
|
||||
}
|
||||
|
||||
// Recalculate all stats
|
||||
player.getStat().recalculateStats(true);
|
||||
playable.getStat().recalculateStats(true);
|
||||
|
||||
// Apply enchant stats
|
||||
item.applyEnchantStats();
|
||||
@ -591,7 +595,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
for (ItemSkillHolder holder : onEnchantSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -608,7 +612,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -635,7 +639,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
for (ItemSkillHolder holder : onBlessingSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -652,7 +656,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -678,7 +682,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
for (ItemSkillHolder holder : normalSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -690,7 +694,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -708,13 +712,13 @@ public abstract class Inventory extends ItemContainer
|
||||
addedSkills.put(skill.getId(), skill);
|
||||
}
|
||||
|
||||
if (skill.isActive() && !player.hasSkillReuse(skill.getReuseHashCode()))
|
||||
if (skill.isActive() && !playable.hasSkillReuse(skill.getReuseHashCode()))
|
||||
{
|
||||
final int equipDelay = item.getEquipReuseDelay();
|
||||
if (equipDelay > 0)
|
||||
{
|
||||
player.addTimeStamp(skill, equipDelay);
|
||||
player.disableSkill(skill, equipDelay);
|
||||
playable.addTimeStamp(skill, equipDelay);
|
||||
playable.disableSkill(skill, equipDelay);
|
||||
}
|
||||
updateTimestamp = true;
|
||||
}
|
||||
@ -741,7 +745,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
for (ItemSkillHolder holder : otherEnchantSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -758,7 +762,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -782,7 +786,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
for (ItemSkillHolder holder : otherBlessingSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -796,7 +800,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -821,22 +825,25 @@ public abstract class Inventory extends ItemContainer
|
||||
// Apply skill, if item has "skills on equip" and it is not a secondary agathion.
|
||||
if ((slot < PAPERDOLL_AGATHION2) || (slot > PAPERDOLL_AGATHION5))
|
||||
{
|
||||
item.getTemplate().forEachSkill(ItemSkillType.ON_EQUIP, holder -> holder.getSkill().activateSkill(player, player));
|
||||
item.getTemplate().forEachSkill(ItemSkillType.ON_EQUIP, holder -> holder.getSkill().activateSkill(playable, playable));
|
||||
}
|
||||
|
||||
if (!addedSkills.isEmpty())
|
||||
{
|
||||
for (Skill skill : addedSkills.values())
|
||||
{
|
||||
player.addSkill(skill, false);
|
||||
playable.addSkill(skill);
|
||||
}
|
||||
|
||||
player.sendSkillList();
|
||||
if (playable.isPlayer())
|
||||
{
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
}
|
||||
|
||||
if (updateTimestamp)
|
||||
if (updateTimestamp && playable.isPlayer())
|
||||
{
|
||||
player.sendPacket(new SkillCoolTime(player));
|
||||
playable.sendPacket(new SkillCoolTime(playable.getActingPlayer()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -853,16 +860,16 @@ public abstract class Inventory extends ItemContainer
|
||||
@Override
|
||||
public void notifyEquiped(int slot, Item item, Inventory inventory)
|
||||
{
|
||||
if (!inventory.getOwner().isPlayer())
|
||||
if (!inventory.getOwner().isPlayable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = (Player) inventory.getOwner();
|
||||
final Playable playable = (Playable) inventory.getOwner();
|
||||
boolean update = false;
|
||||
|
||||
// Verify and apply normal set
|
||||
if (verifyAndApply(player, item, Item::getId))
|
||||
if (verifyAndApply(playable, item, Item::getId))
|
||||
{
|
||||
update = true;
|
||||
}
|
||||
@ -872,26 +879,26 @@ public abstract class Inventory extends ItemContainer
|
||||
if (itemVisualId > 0)
|
||||
{
|
||||
final AppearanceStone stone = AppearanceItemData.getInstance().getStone(itemVisualId);
|
||||
if ((stone != null) && (stone.getType() == AppearanceType.FIXED) && verifyAndApply(player, item, Item::getVisualId))
|
||||
if ((stone != null) && (stone.getType() == AppearanceType.FIXED) && verifyAndApply(playable, item, Item::getVisualId))
|
||||
{
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (update)
|
||||
if (update && playable.isPlayer())
|
||||
{
|
||||
player.sendSkillList();
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
|
||||
if ((item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH_JEWEL) || (item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH))
|
||||
if (playable.isPlayer() && ((item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH_JEWEL) || (item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH)))
|
||||
{
|
||||
player.updateActiveBroochJewel();
|
||||
playable.getActingPlayer().updateActiveBroochJewel();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean applySkills(Player player, Item item, ArmorSet armorSet, Function<Item, Integer> idProvider)
|
||||
private static boolean applySkills(Playable playable, Item item, ArmorSet armorSet, Function<Item, Integer> idProvider)
|
||||
{
|
||||
final long piecesCount = armorSet.getPiecesCount(player, idProvider);
|
||||
final long piecesCount = armorSet.getPiecesCount(playable, idProvider);
|
||||
if (piecesCount >= armorSet.getMinimumPieces())
|
||||
{
|
||||
// Applying all skills that matching the conditions
|
||||
@ -899,12 +906,12 @@ public abstract class Inventory extends ItemContainer
|
||||
boolean update = false;
|
||||
for (ArmorsetSkillHolder holder : armorSet.getSkills())
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (holder.validateConditions(player, armorSet, idProvider))
|
||||
if (holder.validateConditions(playable, armorSet, idProvider))
|
||||
{
|
||||
final Skill itemSkill = holder.getSkill();
|
||||
if (itemSkill == null)
|
||||
@ -913,21 +920,21 @@ public abstract class Inventory extends ItemContainer
|
||||
continue;
|
||||
}
|
||||
|
||||
if (itemSkill.isPassive() && !itemSkill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (itemSkill.isPassive() && !itemSkill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
player.addSkill(itemSkill, false);
|
||||
playable.addSkill(itemSkill);
|
||||
if (itemSkill.isActive() && (item != null))
|
||||
{
|
||||
if (!player.hasSkillReuse(itemSkill.getReuseHashCode()))
|
||||
if (!playable.hasSkillReuse(itemSkill.getReuseHashCode()))
|
||||
{
|
||||
final int equipDelay = item.getEquipReuseDelay();
|
||||
if (equipDelay > 0)
|
||||
{
|
||||
player.addTimeStamp(itemSkill, equipDelay);
|
||||
player.disableSkill(itemSkill, equipDelay);
|
||||
playable.addTimeStamp(itemSkill, equipDelay);
|
||||
playable.disableSkill(itemSkill, equipDelay);
|
||||
}
|
||||
}
|
||||
updateTimeStamp = true;
|
||||
@ -935,22 +942,22 @@ public abstract class Inventory extends ItemContainer
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
if (updateTimeStamp)
|
||||
if (updateTimeStamp && playable.isPlayer())
|
||||
{
|
||||
player.sendPacket(new SkillCoolTime(player));
|
||||
playable.sendPacket(new SkillCoolTime(playable.getActingPlayer()));
|
||||
}
|
||||
return update;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean verifyAndApply(Player player, Item item, Function<Item, Integer> idProvider)
|
||||
private static boolean verifyAndApply(Playable playable, Item item, Function<Item, Integer> idProvider)
|
||||
{
|
||||
boolean update = false;
|
||||
final List<ArmorSet> armorSets = ArmorSetData.getInstance().getSets(idProvider.apply(item));
|
||||
for (ArmorSet armorSet : armorSets)
|
||||
{
|
||||
if (applySkills(player, item, armorSet, idProvider))
|
||||
if (applySkills(playable, item, armorSet, idProvider))
|
||||
{
|
||||
update = true;
|
||||
}
|
||||
@ -958,7 +965,7 @@ public abstract class Inventory extends ItemContainer
|
||||
return update;
|
||||
}
|
||||
|
||||
private static boolean verifyAndRemove(Player player, Item item, Function<Item, Integer> idProvider)
|
||||
private static boolean verifyAndRemove(Playable playable, Item item, Function<Item, Integer> idProvider)
|
||||
{
|
||||
boolean update = false;
|
||||
final List<ArmorSet> armorSets = ArmorSetData.getInstance().getSets(idProvider.apply(item));
|
||||
@ -967,7 +974,7 @@ public abstract class Inventory extends ItemContainer
|
||||
// Remove all skills that doesn't matches the conditions
|
||||
for (ArmorsetSkillHolder holder : armorSet.getSkills())
|
||||
{
|
||||
if (!holder.validateConditions(player, armorSet, idProvider))
|
||||
if (!holder.validateConditions(playable, armorSet, idProvider))
|
||||
{
|
||||
final Skill itemSkill = holder.getSkill();
|
||||
if (itemSkill == null)
|
||||
@ -977,7 +984,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Update if a skill has been removed.
|
||||
if (player.removeSkill(itemSkill, false, itemSkill.isPassive()) != null)
|
||||
if (playable.removeSkill(itemSkill, itemSkill.isPassive()) != null)
|
||||
{
|
||||
update = true;
|
||||
}
|
||||
@ -985,7 +992,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Attempt to apply lower level skills if possible
|
||||
if (applySkills(player, item, armorSet, idProvider))
|
||||
if (applySkills(playable, item, armorSet, idProvider))
|
||||
{
|
||||
update = true;
|
||||
}
|
||||
@ -997,16 +1004,16 @@ public abstract class Inventory extends ItemContainer
|
||||
@Override
|
||||
public void notifyUnequiped(int slot, Item item, Inventory inventory)
|
||||
{
|
||||
if (!inventory.getOwner().isPlayer())
|
||||
if (!inventory.getOwner().isPlayable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = (Player) inventory.getOwner();
|
||||
final Playable playable = (Playable) inventory.getOwner();
|
||||
boolean remove = false;
|
||||
|
||||
// Verify and remove normal set bonus
|
||||
if (verifyAndRemove(player, item, Item::getId))
|
||||
if (verifyAndRemove(playable, item, Item::getId))
|
||||
{
|
||||
remove = true;
|
||||
}
|
||||
@ -1016,21 +1023,26 @@ public abstract class Inventory extends ItemContainer
|
||||
if (itemVisualId > 0)
|
||||
{
|
||||
final AppearanceStone stone = AppearanceItemData.getInstance().getStone(itemVisualId);
|
||||
if ((stone != null) && (stone.getType() == AppearanceType.FIXED) && verifyAndRemove(player, item, Item::getVisualId))
|
||||
if ((stone != null) && (stone.getType() == AppearanceType.FIXED) && verifyAndRemove(playable, item, Item::getVisualId))
|
||||
{
|
||||
remove = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!playable.isPlayer())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (remove)
|
||||
{
|
||||
player.checkItemRestriction();
|
||||
player.sendSkillList();
|
||||
playable.getActingPlayer().checkItemRestriction();
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
|
||||
if ((item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH_JEWEL) || (item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH))
|
||||
{
|
||||
player.updateActiveBroochJewel();
|
||||
playable.getActingPlayer().updateActiveBroochJewel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1198,6 +1210,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
_paperdoll = new Item[PAPERDOLL_TOTALSLOTS];
|
||||
_paperdollListeners = new ArrayList<>();
|
||||
|
||||
if (this instanceof PlayerInventory)
|
||||
{
|
||||
addPaperdollListener(ArmorSetListener.getInstance());
|
||||
@ -1208,6 +1221,11 @@ public abstract class Inventory extends ItemContainer
|
||||
addPaperdollListener(AgathionBraceletListener.getInstance());
|
||||
addPaperdollListener(ArtifactBookListener.getInstance());
|
||||
}
|
||||
else if (this instanceof PetInventory)
|
||||
{
|
||||
addPaperdollListener(ArmorSetListener.getInstance());
|
||||
addPaperdollListener(ItemSkillsListener.getInstance());
|
||||
}
|
||||
|
||||
// common
|
||||
addPaperdollListener(StatsListener.getInstance());
|
||||
@ -2704,12 +2722,12 @@ public abstract class Inventory extends ItemContainer
|
||||
|
||||
public int getArmorMinEnchant()
|
||||
{
|
||||
if ((getOwner() == null) || !getOwner().isPlayer())
|
||||
if ((getOwner() == null) || !getOwner().isPlayable())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
final Player player = getOwner().getActingPlayer();
|
||||
final Playable player = (Playable) getOwner();
|
||||
return _paperdollCache.getMaxSetEnchant(player);
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.gameserver.enums.SkillFinishType;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import org.l2jmobius.gameserver.model.skill.BuffInfo;
|
||||
import org.l2jmobius.gameserver.model.skill.Skill;
|
||||
@ -157,11 +157,11 @@ public class Options
|
||||
_activationSkills.add(holder);
|
||||
}
|
||||
|
||||
public void apply(Player player)
|
||||
public void apply(Playable playable)
|
||||
{
|
||||
if (hasEffects())
|
||||
{
|
||||
final BuffInfo info = new BuffInfo(player, player, null, true, null, this);
|
||||
final BuffInfo info = new BuffInfo(playable, playable, null, true, null, this);
|
||||
for (AbstractEffect effect : _effects)
|
||||
{
|
||||
if (effect.isInstant())
|
||||
@ -174,7 +174,7 @@ public class Options
|
||||
else
|
||||
{
|
||||
effect.continuousInstant(info.getEffector(), info.getEffected(), info.getSkill(), info.getItem());
|
||||
effect.pump(player, info.getSkill());
|
||||
effect.pump(playable, info.getSkill());
|
||||
if (effect.canStart(info.getEffector(), info.getEffected(), info.getSkill()))
|
||||
{
|
||||
info.addEffect(effect);
|
||||
@ -183,44 +183,47 @@ public class Options
|
||||
}
|
||||
if (!info.getEffects().isEmpty())
|
||||
{
|
||||
player.getEffectList().add(info);
|
||||
playable.getEffectList().add(info);
|
||||
}
|
||||
}
|
||||
if (hasActiveSkills())
|
||||
{
|
||||
for (Skill skill : _activeSkill)
|
||||
{
|
||||
addSkill(player, skill);
|
||||
addSkill(playable, skill);
|
||||
}
|
||||
}
|
||||
if (hasPassiveSkills())
|
||||
{
|
||||
for (Skill skill : _passiveSkill)
|
||||
{
|
||||
addSkill(player, skill);
|
||||
addSkill(playable, skill);
|
||||
}
|
||||
}
|
||||
if (hasActivationSkills())
|
||||
{
|
||||
for (OptionSkillHolder holder : _activationSkills)
|
||||
{
|
||||
player.addTriggerSkill(holder);
|
||||
playable.addTriggerSkill(holder);
|
||||
}
|
||||
}
|
||||
|
||||
player.getStat().recalculateStats(true);
|
||||
player.sendSkillList();
|
||||
playable.getStat().recalculateStats(true);
|
||||
if (playable.isPlayer())
|
||||
{
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(Player player)
|
||||
public void remove(Playable playable)
|
||||
{
|
||||
if (hasEffects())
|
||||
{
|
||||
for (BuffInfo info : player.getEffectList().getOptions())
|
||||
for (BuffInfo info : playable.getEffectList().getOptions())
|
||||
{
|
||||
if (info.getOption() == this)
|
||||
{
|
||||
player.getEffectList().remove(info, SkillFinishType.NORMAL, true, true);
|
||||
playable.getEffectList().remove(info, SkillFinishType.NORMAL, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -228,45 +231,48 @@ public class Options
|
||||
{
|
||||
for (Skill skill : _activeSkill)
|
||||
{
|
||||
player.removeSkill(skill, false, false);
|
||||
playable.removeSkill(skill, false);
|
||||
}
|
||||
}
|
||||
if (hasPassiveSkills())
|
||||
{
|
||||
for (Skill skill : _passiveSkill)
|
||||
{
|
||||
player.removeSkill(skill, false, true);
|
||||
playable.removeSkill(skill, true);
|
||||
}
|
||||
}
|
||||
if (hasActivationSkills())
|
||||
{
|
||||
for (OptionSkillHolder holder : _activationSkills)
|
||||
{
|
||||
player.removeTriggerSkill(holder);
|
||||
playable.removeTriggerSkill(holder);
|
||||
}
|
||||
}
|
||||
|
||||
player.getStat().recalculateStats(true);
|
||||
player.sendSkillList();
|
||||
playable.getStat().recalculateStats(true);
|
||||
if (playable.isPlayer())
|
||||
{
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
}
|
||||
|
||||
private void addSkill(Player player, Skill skill)
|
||||
private void addSkill(Playable playable, Skill skill)
|
||||
{
|
||||
boolean updateTimeStamp = false;
|
||||
player.addSkill(skill, false);
|
||||
playable.addSkill(skill);
|
||||
if (skill.isActive())
|
||||
{
|
||||
final long remainingTime = player.getSkillRemainingReuseTime(skill.getReuseHashCode());
|
||||
final long remainingTime = playable.getSkillRemainingReuseTime(skill.getReuseHashCode());
|
||||
if (remainingTime > 0)
|
||||
{
|
||||
player.addTimeStamp(skill, remainingTime);
|
||||
player.disableSkill(skill, remainingTime);
|
||||
playable.addTimeStamp(skill, remainingTime);
|
||||
playable.disableSkill(skill, remainingTime);
|
||||
}
|
||||
updateTimeStamp = true;
|
||||
}
|
||||
if (updateTimeStamp)
|
||||
if (updateTimeStamp && playable.isPlayer())
|
||||
{
|
||||
player.sendPacket(new SkillCoolTime(player));
|
||||
playable.sendPacket(new SkillCoolTime(playable.getActingPlayer()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.data.xml.ArmorSetData;
|
||||
import org.l2jmobius.gameserver.model.ArmorSet;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.model.stats.BaseStat;
|
||||
@ -82,7 +83,7 @@ public final class PaperdollCache
|
||||
return value;
|
||||
}
|
||||
|
||||
public int getMaxSetEnchant(Player player)
|
||||
public int getMaxSetEnchant(Playable playable)
|
||||
{
|
||||
if (_maxSetEnchant >= 0)
|
||||
{
|
||||
@ -94,7 +95,7 @@ public final class PaperdollCache
|
||||
{
|
||||
for (ArmorSet set : ArmorSetData.getInstance().getSets(item.getId()))
|
||||
{
|
||||
final int enchantEffect = set.getLowestSetEnchant(player);
|
||||
final int enchantEffect = set.getLowestSetEnchant(playable);
|
||||
if (enchantEffect > maxSetEnchant)
|
||||
{
|
||||
maxSetEnchant = enchantEffect;
|
||||
|
@ -22,11 +22,10 @@ import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.holders.ArmorsetSkillHolder;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import org.l2jmobius.gameserver.model.itemcontainer.PlayerInventory;
|
||||
import org.l2jmobius.gameserver.model.stats.BaseStat;
|
||||
|
||||
/**
|
||||
@ -162,18 +161,18 @@ public class ArmorSet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param playable
|
||||
* @return true if all parts of set are enchanted to +6 or more
|
||||
*/
|
||||
public int getLowestSetEnchant(Player player)
|
||||
public int getLowestSetEnchant(Playable playable)
|
||||
{
|
||||
// Player don't have full set
|
||||
if (getPiecesCountById(player) < _minimumPieces)
|
||||
// Playable don't have full set
|
||||
if (getPiecesCountById(playable) < _minimumPieces)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
final PlayerInventory inv = player.getInventory();
|
||||
final Inventory inv = playable.getInventory();
|
||||
int enchantLevel = Byte.MAX_VALUE;
|
||||
for (int armorSlot : ARMORSET_SLOTS)
|
||||
{
|
||||
@ -192,13 +191,13 @@ public class ArmorSet
|
||||
|
||||
/**
|
||||
* Condition for 3 Lv. Set Effect Applied Skill
|
||||
* @param player
|
||||
* @param playable
|
||||
* @param bookSlot
|
||||
* @return total paperdoll(busy) count for 1 of 3 artifact book slots
|
||||
*/
|
||||
public int getArtifactSlotMask(Player player, int bookSlot)
|
||||
public int getArtifactSlotMask(Playable playable, int bookSlot)
|
||||
{
|
||||
final PlayerInventory inv = player.getInventory();
|
||||
final Inventory inv = playable.getInventory();
|
||||
int slotMask = 0;
|
||||
switch (bookSlot)
|
||||
{
|
||||
@ -242,23 +241,23 @@ public class ArmorSet
|
||||
return slotMask;
|
||||
}
|
||||
|
||||
public boolean hasOptionalEquipped(Player player, Function<Item, Integer> idProvider)
|
||||
public boolean hasOptionalEquipped(Playable playable, Function<Item, Integer> idProvider)
|
||||
{
|
||||
return player.getInventory().getPaperdollItems().stream().anyMatch(item -> CommonUtil.contains(_optionalItems, idProvider.apply(item)));
|
||||
return playable.getInventory().getPaperdollItems().stream().anyMatch(item -> CommonUtil.contains(_optionalItems, idProvider.apply(item)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param playable
|
||||
* @param idProvider
|
||||
* @return the amount of set visual items that player has equipped
|
||||
* @return the amount of set visual items that playable has equipped
|
||||
*/
|
||||
public long getPiecesCount(Player player, Function<Item, Integer> idProvider)
|
||||
public long getPiecesCount(Playable playable, Function<Item, Integer> idProvider)
|
||||
{
|
||||
return player.getInventory().getPaperdollItemCount(item -> CommonUtil.contains(_requiredItems, idProvider.apply(item)));
|
||||
return playable.getInventory().getPaperdollItemCount(item -> CommonUtil.contains(_requiredItems, idProvider.apply(item)));
|
||||
}
|
||||
|
||||
public long getPiecesCountById(Player player)
|
||||
public long getPiecesCountById(Playable playable)
|
||||
{
|
||||
return player.getInventory().getPaperdollItemCount(item -> CommonUtil.contains(_requiredItems, item.getId()));
|
||||
return playable.getInventory().getPaperdollItemCount(item -> CommonUtil.contains(_requiredItems, item.getId()));
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import org.l2jmobius.gameserver.data.xml.OptionData;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.options.Options;
|
||||
|
||||
/**
|
||||
@ -59,27 +59,27 @@ public class VariationInstance
|
||||
return _option2 == null ? -1 : _option2.getId();
|
||||
}
|
||||
|
||||
public void applyBonus(Player player)
|
||||
public void applyBonus(Playable playable)
|
||||
{
|
||||
if (_option1 != null)
|
||||
{
|
||||
_option1.apply(player);
|
||||
_option1.apply(playable);
|
||||
}
|
||||
if (_option2 != null)
|
||||
{
|
||||
_option2.apply(player);
|
||||
_option2.apply(playable);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeBonus(Player player)
|
||||
public void removeBonus(Playable playable)
|
||||
{
|
||||
if (_option1 != null)
|
||||
{
|
||||
_option1.remove(player);
|
||||
_option1.remove(playable);
|
||||
}
|
||||
if (_option2 != null)
|
||||
{
|
||||
_option2.remove(player);
|
||||
_option2.remove(playable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.holders;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.l2jmobius.gameserver.model.ArmorSet;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
|
||||
/**
|
||||
@ -58,34 +58,34 @@ public class ArmorsetSkillHolder extends SkillHolder
|
||||
return _isOptional;
|
||||
}
|
||||
|
||||
public boolean validateConditions(Player player, ArmorSet armorSet, Function<Item, Integer> idProvider)
|
||||
public boolean validateConditions(Playable playable, ArmorSet armorSet, Function<Item, Integer> idProvider)
|
||||
{
|
||||
// Player's doesn't have full busy (1 of 3) artifact real slot
|
||||
if (_artifactSlotMask > armorSet.getArtifactSlotMask(player, _artifactBookSlot))
|
||||
// Playable doesn't have full busy (1 of 3) artifact real slot
|
||||
if (_artifactSlotMask > armorSet.getArtifactSlotMask(playable, _artifactBookSlot))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Player doesn't have enough items equipped to use this skill
|
||||
if (_minimumPieces > armorSet.getPiecesCount(player, idProvider))
|
||||
// Playable doesn't have enough items equipped to use this skill
|
||||
if (_minimumPieces > armorSet.getPiecesCount(playable, idProvider))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Player's set enchantment isn't enough to use this skill
|
||||
if (_minEnchant > armorSet.getLowestSetEnchant(player))
|
||||
// Playable set enchantment isn't enough to use this skill
|
||||
if (_minEnchant > armorSet.getLowestSetEnchant(playable))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Player doesn't have the required item to use this skill
|
||||
if (_isOptional && !armorSet.hasOptionalEquipped(player, idProvider))
|
||||
// Playable doesn't have the required item to use this skill
|
||||
if (_isOptional && !armorSet.hasOptionalEquipped(playable, idProvider))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Player already knows that skill
|
||||
if (player.getSkillLevel(getSkillId()) == getSkillLevel())
|
||||
// Playable already knows that skill
|
||||
if (playable.getSkillLevel(getSkillId()) == getSkillLevel())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ import org.l2jmobius.gameserver.model.ArmorSet;
|
||||
import org.l2jmobius.gameserver.model.VariationInstance;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerItemUnequip;
|
||||
@ -319,12 +320,12 @@ public abstract class Inventory extends ItemContainer
|
||||
@Override
|
||||
public void notifyUnequiped(int slot, Item item, Inventory inventory)
|
||||
{
|
||||
if (!inventory.getOwner().isPlayer())
|
||||
if (!inventory.getOwner().isPlayable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = (Player) inventory.getOwner();
|
||||
final Playable playable = (Playable) inventory.getOwner();
|
||||
final ItemTemplate it = item.getTemplate();
|
||||
final Map<Integer, Skill> addedSkills = new HashMap<>(1);
|
||||
final Map<Integer, Skill> removedSkills = new HashMap<>(1);
|
||||
@ -334,11 +335,11 @@ public abstract class Inventory extends ItemContainer
|
||||
// Remove augmentation bonuses on unequip
|
||||
if (item.isAugmented())
|
||||
{
|
||||
item.getAugmentation().removeBonus(player);
|
||||
item.getAugmentation().removeBonus(playable);
|
||||
}
|
||||
|
||||
// Recalculate all stats
|
||||
player.getStat().recalculateStats(true);
|
||||
playable.getStat().recalculateStats(true);
|
||||
|
||||
// Clear enchant bonus
|
||||
item.clearEnchantStats();
|
||||
@ -415,7 +416,7 @@ public abstract class Inventory extends ItemContainer
|
||||
|
||||
for (ItemSkillHolder holder : otherNormalSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) != 0)
|
||||
if (playable.getSkillLevel(holder.getSkillId()) != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -439,13 +440,13 @@ public abstract class Inventory extends ItemContainer
|
||||
addedSkills.put(skill.getId(), skill);
|
||||
}
|
||||
|
||||
if (skill.isActive() && !player.hasSkillReuse(skill.getReuseHashCode()))
|
||||
if (skill.isActive() && !playable.hasSkillReuse(skill.getReuseHashCode()))
|
||||
{
|
||||
final int equipDelay = item.getEquipReuseDelay();
|
||||
if (equipDelay > 0)
|
||||
{
|
||||
player.addTimeStamp(skill, equipDelay);
|
||||
player.disableSkill(skill, equipDelay);
|
||||
playable.addTimeStamp(skill, equipDelay);
|
||||
playable.disableSkill(skill, equipDelay);
|
||||
}
|
||||
updateTimestamp = true;
|
||||
}
|
||||
@ -486,7 +487,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
removedSkills.putIfAbsent(skill.getId(), skill);
|
||||
update = true;
|
||||
@ -505,7 +506,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
removedSkills.putIfAbsent(skill.getId(), skill);
|
||||
update = true;
|
||||
@ -515,12 +516,12 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Must check for toggle and isRemovedOnUnequipWeapon skill item conditions.
|
||||
for (Skill skill : player.getAllSkills())
|
||||
for (Skill skill : playable.getAllSkills())
|
||||
{
|
||||
if ((skill.isToggle() && player.isAffectedBySkill(skill.getId()) && !skill.checkConditions(SkillConditionScope.GENERAL, player, player)) //
|
||||
if ((skill.isToggle() && playable.isAffectedBySkill(skill.getId()) && !skill.checkConditions(SkillConditionScope.GENERAL, playable, playable)) //
|
||||
|| (it.isWeapon() && skill.isRemovedOnUnequipWeapon()))
|
||||
{
|
||||
player.stopSkillEffects(SkillFinishType.REMOVED, skill.getId());
|
||||
playable.stopSkillEffects(SkillFinishType.REMOVED, skill.getId());
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
@ -528,55 +529,58 @@ public abstract class Inventory extends ItemContainer
|
||||
// Apply skill, if item has "skills on unequip" and it is not a secondary agathion.
|
||||
if ((slot < PAPERDOLL_AGATHION2) || (slot > PAPERDOLL_AGATHION5))
|
||||
{
|
||||
it.forEachSkill(ItemSkillType.ON_UNEQUIP, holder -> holder.getSkill().activateSkill(player, player));
|
||||
it.forEachSkill(ItemSkillType.ON_UNEQUIP, holder -> holder.getSkill().activateSkill(playable, playable));
|
||||
}
|
||||
|
||||
if (update)
|
||||
{
|
||||
for (Skill skill : removedSkills.values())
|
||||
{
|
||||
player.removeSkill(skill, false, skill.isPassive());
|
||||
playable.removeSkill(skill, skill.isPassive());
|
||||
}
|
||||
|
||||
for (Skill skill : addedSkills.values())
|
||||
{
|
||||
player.addSkill(skill, false);
|
||||
playable.addSkill(skill);
|
||||
}
|
||||
|
||||
player.sendSkillList();
|
||||
if (playable.isPlayer())
|
||||
{
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
}
|
||||
|
||||
if (updateTimestamp)
|
||||
if (updateTimestamp && playable.isPlayer())
|
||||
{
|
||||
player.sendPacket(new SkillCoolTime(player));
|
||||
playable.sendPacket(new SkillCoolTime(playable.getActingPlayer()));
|
||||
}
|
||||
|
||||
if (item.isWeapon())
|
||||
{
|
||||
player.unchargeAllShots();
|
||||
playable.unchargeAllShots();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyEquiped(int slot, Item item, Inventory inventory)
|
||||
{
|
||||
if (!inventory.getOwner().isPlayer())
|
||||
if (!inventory.getOwner().isPlayable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = (Player) inventory.getOwner();
|
||||
final Playable playable = (Playable) inventory.getOwner();
|
||||
final Map<Integer, Skill> addedSkills = new HashMap<>(1);
|
||||
boolean updateTimestamp = false;
|
||||
|
||||
// Apply augmentation bonuses on equip
|
||||
if (item.isAugmented())
|
||||
{
|
||||
item.getAugmentation().applyBonus(player);
|
||||
item.getAugmentation().applyBonus(playable);
|
||||
}
|
||||
|
||||
// Recalculate all stats
|
||||
player.getStat().recalculateStats(true);
|
||||
playable.getStat().recalculateStats(true);
|
||||
|
||||
// Apply enchant stats
|
||||
item.applyEnchantStats();
|
||||
@ -591,7 +595,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
for (ItemSkillHolder holder : onEnchantSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -608,7 +612,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -635,7 +639,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
for (ItemSkillHolder holder : onBlessingSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -652,7 +656,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -678,7 +682,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
for (ItemSkillHolder holder : normalSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -690,7 +694,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -708,13 +712,13 @@ public abstract class Inventory extends ItemContainer
|
||||
addedSkills.put(skill.getId(), skill);
|
||||
}
|
||||
|
||||
if (skill.isActive() && !player.hasSkillReuse(skill.getReuseHashCode()))
|
||||
if (skill.isActive() && !playable.hasSkillReuse(skill.getReuseHashCode()))
|
||||
{
|
||||
final int equipDelay = item.getEquipReuseDelay();
|
||||
if (equipDelay > 0)
|
||||
{
|
||||
player.addTimeStamp(skill, equipDelay);
|
||||
player.disableSkill(skill, equipDelay);
|
||||
playable.addTimeStamp(skill, equipDelay);
|
||||
playable.disableSkill(skill, equipDelay);
|
||||
}
|
||||
updateTimestamp = true;
|
||||
}
|
||||
@ -741,7 +745,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
for (ItemSkillHolder holder : otherEnchantSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -758,7 +762,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -782,7 +786,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
for (ItemSkillHolder holder : otherBlessingSkills)
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -796,7 +800,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Check passive skill conditions.
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (skill.isPassive() && !skill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -821,22 +825,25 @@ public abstract class Inventory extends ItemContainer
|
||||
// Apply skill, if item has "skills on equip" and it is not a secondary agathion.
|
||||
if ((slot < PAPERDOLL_AGATHION2) || (slot > PAPERDOLL_AGATHION5))
|
||||
{
|
||||
item.getTemplate().forEachSkill(ItemSkillType.ON_EQUIP, holder -> holder.getSkill().activateSkill(player, player));
|
||||
item.getTemplate().forEachSkill(ItemSkillType.ON_EQUIP, holder -> holder.getSkill().activateSkill(playable, playable));
|
||||
}
|
||||
|
||||
if (!addedSkills.isEmpty())
|
||||
{
|
||||
for (Skill skill : addedSkills.values())
|
||||
{
|
||||
player.addSkill(skill, false);
|
||||
playable.addSkill(skill);
|
||||
}
|
||||
|
||||
player.sendSkillList();
|
||||
if (playable.isPlayer())
|
||||
{
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
}
|
||||
|
||||
if (updateTimestamp)
|
||||
if (updateTimestamp && playable.isPlayer())
|
||||
{
|
||||
player.sendPacket(new SkillCoolTime(player));
|
||||
playable.sendPacket(new SkillCoolTime(playable.getActingPlayer()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -853,16 +860,16 @@ public abstract class Inventory extends ItemContainer
|
||||
@Override
|
||||
public void notifyEquiped(int slot, Item item, Inventory inventory)
|
||||
{
|
||||
if (!inventory.getOwner().isPlayer())
|
||||
if (!inventory.getOwner().isPlayable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = (Player) inventory.getOwner();
|
||||
final Playable playable = (Playable) inventory.getOwner();
|
||||
boolean update = false;
|
||||
|
||||
// Verify and apply normal set
|
||||
if (verifyAndApply(player, item, Item::getId))
|
||||
if (verifyAndApply(playable, item, Item::getId))
|
||||
{
|
||||
update = true;
|
||||
}
|
||||
@ -872,26 +879,26 @@ public abstract class Inventory extends ItemContainer
|
||||
if (itemVisualId > 0)
|
||||
{
|
||||
final AppearanceStone stone = AppearanceItemData.getInstance().getStone(itemVisualId);
|
||||
if ((stone != null) && (stone.getType() == AppearanceType.FIXED) && verifyAndApply(player, item, Item::getVisualId))
|
||||
if ((stone != null) && (stone.getType() == AppearanceType.FIXED) && verifyAndApply(playable, item, Item::getVisualId))
|
||||
{
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (update)
|
||||
if (update && playable.isPlayer())
|
||||
{
|
||||
player.sendSkillList();
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
|
||||
if ((item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH_JEWEL) || (item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH))
|
||||
if (playable.isPlayer() && ((item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH_JEWEL) || (item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH)))
|
||||
{
|
||||
player.updateActiveBroochJewel();
|
||||
playable.getActingPlayer().updateActiveBroochJewel();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean applySkills(Player player, Item item, ArmorSet armorSet, Function<Item, Integer> idProvider)
|
||||
private static boolean applySkills(Playable playable, Item item, ArmorSet armorSet, Function<Item, Integer> idProvider)
|
||||
{
|
||||
final long piecesCount = armorSet.getPiecesCount(player, idProvider);
|
||||
final long piecesCount = armorSet.getPiecesCount(playable, idProvider);
|
||||
if (piecesCount >= armorSet.getMinimumPieces())
|
||||
{
|
||||
// Applying all skills that matching the conditions
|
||||
@ -899,12 +906,12 @@ public abstract class Inventory extends ItemContainer
|
||||
boolean update = false;
|
||||
for (ArmorsetSkillHolder holder : armorSet.getSkills())
|
||||
{
|
||||
if (player.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
if (playable.getSkillLevel(holder.getSkillId()) >= holder.getSkillLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (holder.validateConditions(player, armorSet, idProvider))
|
||||
if (holder.validateConditions(playable, armorSet, idProvider))
|
||||
{
|
||||
final Skill itemSkill = holder.getSkill();
|
||||
if (itemSkill == null)
|
||||
@ -913,21 +920,21 @@ public abstract class Inventory extends ItemContainer
|
||||
continue;
|
||||
}
|
||||
|
||||
if (itemSkill.isPassive() && !itemSkill.checkConditions(SkillConditionScope.PASSIVE, player, player))
|
||||
if (itemSkill.isPassive() && !itemSkill.checkConditions(SkillConditionScope.PASSIVE, playable, playable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
player.addSkill(itemSkill, false);
|
||||
playable.addSkill(itemSkill);
|
||||
if (itemSkill.isActive() && (item != null))
|
||||
{
|
||||
if (!player.hasSkillReuse(itemSkill.getReuseHashCode()))
|
||||
if (!playable.hasSkillReuse(itemSkill.getReuseHashCode()))
|
||||
{
|
||||
final int equipDelay = item.getEquipReuseDelay();
|
||||
if (equipDelay > 0)
|
||||
{
|
||||
player.addTimeStamp(itemSkill, equipDelay);
|
||||
player.disableSkill(itemSkill, equipDelay);
|
||||
playable.addTimeStamp(itemSkill, equipDelay);
|
||||
playable.disableSkill(itemSkill, equipDelay);
|
||||
}
|
||||
}
|
||||
updateTimeStamp = true;
|
||||
@ -935,22 +942,22 @@ public abstract class Inventory extends ItemContainer
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
if (updateTimeStamp)
|
||||
if (updateTimeStamp && playable.isPlayer())
|
||||
{
|
||||
player.sendPacket(new SkillCoolTime(player));
|
||||
playable.sendPacket(new SkillCoolTime(playable.getActingPlayer()));
|
||||
}
|
||||
return update;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean verifyAndApply(Player player, Item item, Function<Item, Integer> idProvider)
|
||||
private static boolean verifyAndApply(Playable playable, Item item, Function<Item, Integer> idProvider)
|
||||
{
|
||||
boolean update = false;
|
||||
final List<ArmorSet> armorSets = ArmorSetData.getInstance().getSets(idProvider.apply(item));
|
||||
for (ArmorSet armorSet : armorSets)
|
||||
{
|
||||
if (applySkills(player, item, armorSet, idProvider))
|
||||
if (applySkills(playable, item, armorSet, idProvider))
|
||||
{
|
||||
update = true;
|
||||
}
|
||||
@ -958,7 +965,7 @@ public abstract class Inventory extends ItemContainer
|
||||
return update;
|
||||
}
|
||||
|
||||
private static boolean verifyAndRemove(Player player, Item item, Function<Item, Integer> idProvider)
|
||||
private static boolean verifyAndRemove(Playable playable, Item item, Function<Item, Integer> idProvider)
|
||||
{
|
||||
boolean update = false;
|
||||
final List<ArmorSet> armorSets = ArmorSetData.getInstance().getSets(idProvider.apply(item));
|
||||
@ -967,7 +974,7 @@ public abstract class Inventory extends ItemContainer
|
||||
// Remove all skills that doesn't matches the conditions
|
||||
for (ArmorsetSkillHolder holder : armorSet.getSkills())
|
||||
{
|
||||
if (!holder.validateConditions(player, armorSet, idProvider))
|
||||
if (!holder.validateConditions(playable, armorSet, idProvider))
|
||||
{
|
||||
final Skill itemSkill = holder.getSkill();
|
||||
if (itemSkill == null)
|
||||
@ -977,7 +984,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Update if a skill has been removed.
|
||||
if (player.removeSkill(itemSkill, false, itemSkill.isPassive()) != null)
|
||||
if (playable.removeSkill(itemSkill, itemSkill.isPassive()) != null)
|
||||
{
|
||||
update = true;
|
||||
}
|
||||
@ -985,7 +992,7 @@ public abstract class Inventory extends ItemContainer
|
||||
}
|
||||
|
||||
// Attempt to apply lower level skills if possible
|
||||
if (applySkills(player, item, armorSet, idProvider))
|
||||
if (applySkills(playable, item, armorSet, idProvider))
|
||||
{
|
||||
update = true;
|
||||
}
|
||||
@ -997,16 +1004,16 @@ public abstract class Inventory extends ItemContainer
|
||||
@Override
|
||||
public void notifyUnequiped(int slot, Item item, Inventory inventory)
|
||||
{
|
||||
if (!inventory.getOwner().isPlayer())
|
||||
if (!inventory.getOwner().isPlayable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = (Player) inventory.getOwner();
|
||||
final Playable playable = (Playable) inventory.getOwner();
|
||||
boolean remove = false;
|
||||
|
||||
// Verify and remove normal set bonus
|
||||
if (verifyAndRemove(player, item, Item::getId))
|
||||
if (verifyAndRemove(playable, item, Item::getId))
|
||||
{
|
||||
remove = true;
|
||||
}
|
||||
@ -1016,21 +1023,26 @@ public abstract class Inventory extends ItemContainer
|
||||
if (itemVisualId > 0)
|
||||
{
|
||||
final AppearanceStone stone = AppearanceItemData.getInstance().getStone(itemVisualId);
|
||||
if ((stone != null) && (stone.getType() == AppearanceType.FIXED) && verifyAndRemove(player, item, Item::getVisualId))
|
||||
if ((stone != null) && (stone.getType() == AppearanceType.FIXED) && verifyAndRemove(playable, item, Item::getVisualId))
|
||||
{
|
||||
remove = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!playable.isPlayer())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (remove)
|
||||
{
|
||||
player.checkItemRestriction();
|
||||
player.sendSkillList();
|
||||
playable.getActingPlayer().checkItemRestriction();
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
|
||||
if ((item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH_JEWEL) || (item.getTemplate().getBodyPart() == ItemTemplate.SLOT_BROOCH))
|
||||
{
|
||||
player.updateActiveBroochJewel();
|
||||
playable.getActingPlayer().updateActiveBroochJewel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1198,6 +1210,7 @@ public abstract class Inventory extends ItemContainer
|
||||
{
|
||||
_paperdoll = new Item[PAPERDOLL_TOTALSLOTS];
|
||||
_paperdollListeners = new ArrayList<>();
|
||||
|
||||
if (this instanceof PlayerInventory)
|
||||
{
|
||||
addPaperdollListener(ArmorSetListener.getInstance());
|
||||
@ -1208,6 +1221,11 @@ public abstract class Inventory extends ItemContainer
|
||||
addPaperdollListener(AgathionBraceletListener.getInstance());
|
||||
addPaperdollListener(ArtifactBookListener.getInstance());
|
||||
}
|
||||
else if (this instanceof PetInventory)
|
||||
{
|
||||
addPaperdollListener(ArmorSetListener.getInstance());
|
||||
addPaperdollListener(ItemSkillsListener.getInstance());
|
||||
}
|
||||
|
||||
// common
|
||||
addPaperdollListener(StatsListener.getInstance());
|
||||
@ -2704,12 +2722,12 @@ public abstract class Inventory extends ItemContainer
|
||||
|
||||
public int getArmorMinEnchant()
|
||||
{
|
||||
if ((getOwner() == null) || !getOwner().isPlayer())
|
||||
if ((getOwner() == null) || !getOwner().isPlayable())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
final Player player = getOwner().getActingPlayer();
|
||||
final Playable player = (Playable) getOwner();
|
||||
return _paperdollCache.getMaxSetEnchant(player);
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.gameserver.enums.SkillFinishType;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import org.l2jmobius.gameserver.model.skill.BuffInfo;
|
||||
import org.l2jmobius.gameserver.model.skill.Skill;
|
||||
@ -157,11 +157,11 @@ public class Options
|
||||
_activationSkills.add(holder);
|
||||
}
|
||||
|
||||
public void apply(Player player)
|
||||
public void apply(Playable playable)
|
||||
{
|
||||
if (hasEffects())
|
||||
{
|
||||
final BuffInfo info = new BuffInfo(player, player, null, true, null, this);
|
||||
final BuffInfo info = new BuffInfo(playable, playable, null, true, null, this);
|
||||
for (AbstractEffect effect : _effects)
|
||||
{
|
||||
if (effect.isInstant())
|
||||
@ -174,7 +174,7 @@ public class Options
|
||||
else
|
||||
{
|
||||
effect.continuousInstant(info.getEffector(), info.getEffected(), info.getSkill(), info.getItem());
|
||||
effect.pump(player, info.getSkill());
|
||||
effect.pump(playable, info.getSkill());
|
||||
if (effect.canStart(info.getEffector(), info.getEffected(), info.getSkill()))
|
||||
{
|
||||
info.addEffect(effect);
|
||||
@ -183,44 +183,47 @@ public class Options
|
||||
}
|
||||
if (!info.getEffects().isEmpty())
|
||||
{
|
||||
player.getEffectList().add(info);
|
||||
playable.getEffectList().add(info);
|
||||
}
|
||||
}
|
||||
if (hasActiveSkills())
|
||||
{
|
||||
for (Skill skill : _activeSkill)
|
||||
{
|
||||
addSkill(player, skill);
|
||||
addSkill(playable, skill);
|
||||
}
|
||||
}
|
||||
if (hasPassiveSkills())
|
||||
{
|
||||
for (Skill skill : _passiveSkill)
|
||||
{
|
||||
addSkill(player, skill);
|
||||
addSkill(playable, skill);
|
||||
}
|
||||
}
|
||||
if (hasActivationSkills())
|
||||
{
|
||||
for (OptionSkillHolder holder : _activationSkills)
|
||||
{
|
||||
player.addTriggerSkill(holder);
|
||||
playable.addTriggerSkill(holder);
|
||||
}
|
||||
}
|
||||
|
||||
player.getStat().recalculateStats(true);
|
||||
player.sendSkillList();
|
||||
playable.getStat().recalculateStats(true);
|
||||
if (playable.isPlayer())
|
||||
{
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(Player player)
|
||||
public void remove(Playable playable)
|
||||
{
|
||||
if (hasEffects())
|
||||
{
|
||||
for (BuffInfo info : player.getEffectList().getOptions())
|
||||
for (BuffInfo info : playable.getEffectList().getOptions())
|
||||
{
|
||||
if (info.getOption() == this)
|
||||
{
|
||||
player.getEffectList().remove(info, SkillFinishType.NORMAL, true, true);
|
||||
playable.getEffectList().remove(info, SkillFinishType.NORMAL, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -228,45 +231,48 @@ public class Options
|
||||
{
|
||||
for (Skill skill : _activeSkill)
|
||||
{
|
||||
player.removeSkill(skill, false, false);
|
||||
playable.removeSkill(skill, false);
|
||||
}
|
||||
}
|
||||
if (hasPassiveSkills())
|
||||
{
|
||||
for (Skill skill : _passiveSkill)
|
||||
{
|
||||
player.removeSkill(skill, false, true);
|
||||
playable.removeSkill(skill, true);
|
||||
}
|
||||
}
|
||||
if (hasActivationSkills())
|
||||
{
|
||||
for (OptionSkillHolder holder : _activationSkills)
|
||||
{
|
||||
player.removeTriggerSkill(holder);
|
||||
playable.removeTriggerSkill(holder);
|
||||
}
|
||||
}
|
||||
|
||||
player.getStat().recalculateStats(true);
|
||||
player.sendSkillList();
|
||||
playable.getStat().recalculateStats(true);
|
||||
if (playable.isPlayer())
|
||||
{
|
||||
playable.getActingPlayer().sendSkillList();
|
||||
}
|
||||
}
|
||||
|
||||
private void addSkill(Player player, Skill skill)
|
||||
private void addSkill(Playable playable, Skill skill)
|
||||
{
|
||||
boolean updateTimeStamp = false;
|
||||
player.addSkill(skill, false);
|
||||
playable.addSkill(skill);
|
||||
if (skill.isActive())
|
||||
{
|
||||
final long remainingTime = player.getSkillRemainingReuseTime(skill.getReuseHashCode());
|
||||
final long remainingTime = playable.getSkillRemainingReuseTime(skill.getReuseHashCode());
|
||||
if (remainingTime > 0)
|
||||
{
|
||||
player.addTimeStamp(skill, remainingTime);
|
||||
player.disableSkill(skill, remainingTime);
|
||||
playable.addTimeStamp(skill, remainingTime);
|
||||
playable.disableSkill(skill, remainingTime);
|
||||
}
|
||||
updateTimeStamp = true;
|
||||
}
|
||||
if (updateTimeStamp)
|
||||
if (updateTimeStamp && playable.isPlayer())
|
||||
{
|
||||
player.sendPacket(new SkillCoolTime(player));
|
||||
playable.sendPacket(new SkillCoolTime(playable.getActingPlayer()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user