Changed option data to directly use skills.
This commit is contained in:
@@ -28,10 +28,10 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import org.l2jmobius.gameserver.model.options.OptionSkillHolder;
|
||||
import org.l2jmobius.gameserver.model.options.OptionSkillType;
|
||||
import org.l2jmobius.gameserver.model.options.Options;
|
||||
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
||||
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
||||
import org.l2jmobius.gameserver.model.skill.Skill;
|
||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||
import org.l2jmobius.gameserver.model.stats.functions.FuncTemplate;
|
||||
|
||||
@@ -106,27 +106,77 @@ public class OptionData implements IXmlReader
|
||||
}
|
||||
case "active_skill":
|
||||
{
|
||||
option.setActiveSkill(new SkillHolder(parseInteger(cd.getAttributes(), "id"), parseInteger(cd.getAttributes(), "level")));
|
||||
final int skillId = parseInteger(cd.getAttributes(), "id");
|
||||
final int skillLevel = parseInteger(cd.getAttributes(), "level");
|
||||
final Skill skill = SkillData.getInstance().getSkill(skillId, skillLevel);
|
||||
if (skill != null)
|
||||
{
|
||||
option.setActiveSkill(skill);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Could not find skill " + skillId + "(" + skillLevel + ") used by option " + id + ".");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "passive_skill":
|
||||
{
|
||||
option.setPassiveSkill(new SkillHolder(parseInteger(cd.getAttributes(), "id"), parseInteger(cd.getAttributes(), "level")));
|
||||
final int skillId = parseInteger(cd.getAttributes(), "id");
|
||||
final int skillLevel = parseInteger(cd.getAttributes(), "level");
|
||||
final Skill skill = SkillData.getInstance().getSkill(skillId, skillLevel);
|
||||
if (skill != null)
|
||||
{
|
||||
option.setPassiveSkill(skill);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Could not find skill " + skillId + "(" + skillLevel + ") used by option " + id + ".");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "attack_skill":
|
||||
{
|
||||
option.addActivationSkill(new OptionsSkillHolder(parseInteger(cd.getAttributes(), "id"), parseInteger(cd.getAttributes(), "level"), parseDouble(cd.getAttributes(), "chance"), OptionsSkillType.ATTACK));
|
||||
final int skillId = parseInteger(cd.getAttributes(), "id");
|
||||
final int skillLevel = parseInteger(cd.getAttributes(), "level");
|
||||
final Skill skill = SkillData.getInstance().getSkill(skillId, skillLevel);
|
||||
if (skill != null)
|
||||
{
|
||||
option.addActivationSkill(new OptionSkillHolder(skill, parseDouble(cd.getAttributes(), "chance"), OptionSkillType.ATTACK));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Could not find skill " + skillId + "(" + skillLevel + ") used by option " + id + ".");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "magic_skill":
|
||||
{
|
||||
option.addActivationSkill(new OptionsSkillHolder(parseInteger(cd.getAttributes(), "id"), parseInteger(cd.getAttributes(), "level"), parseDouble(cd.getAttributes(), "chance"), OptionsSkillType.MAGIC));
|
||||
final int skillId = parseInteger(cd.getAttributes(), "id");
|
||||
final int skillLevel = parseInteger(cd.getAttributes(), "level");
|
||||
final Skill skill = SkillData.getInstance().getSkill(skillId, skillLevel);
|
||||
if (skill != null)
|
||||
{
|
||||
option.addActivationSkill(new OptionSkillHolder(skill, parseDouble(cd.getAttributes(), "chance"), OptionSkillType.MAGIC));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Could not find skill " + skillId + "(" + skillLevel + ") used by option " + id + ".");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "critical_skill":
|
||||
{
|
||||
option.addActivationSkill(new OptionsSkillHolder(parseInteger(cd.getAttributes(), "id"), parseInteger(cd.getAttributes(), "level"), parseDouble(cd.getAttributes(), "chance"), OptionsSkillType.CRITICAL));
|
||||
final int skillId = parseInteger(cd.getAttributes(), "id");
|
||||
final int skillLevel = parseInteger(cd.getAttributes(), "level");
|
||||
final Skill skill = SkillData.getInstance().getSkill(skillId, skillLevel);
|
||||
if (skill != null)
|
||||
{
|
||||
option.addActivationSkill(new OptionSkillHolder(skill, parseDouble(cd.getAttributes(), "chance"), OptionSkillType.CRITICAL));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Could not find skill " + skillId + "(" + skillLevel + ") used by option " + id + ".");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,8 +117,8 @@ import org.l2jmobius.gameserver.model.item.Weapon;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.model.item.type.WeaponType;
|
||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
||||
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
||||
import org.l2jmobius.gameserver.model.options.OptionSkillHolder;
|
||||
import org.l2jmobius.gameserver.model.options.OptionSkillType;
|
||||
import org.l2jmobius.gameserver.model.skill.AbnormalType;
|
||||
import org.l2jmobius.gameserver.model.skill.AbnormalVisualEffect;
|
||||
import org.l2jmobius.gameserver.model.skill.BuffFinishTask;
|
||||
@@ -240,7 +240,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
|
||||
private boolean _lethalable = true;
|
||||
|
||||
private Map<Integer, OptionsSkillHolder> _triggerSkills;
|
||||
private Map<Integer, OptionSkillHolder> _triggerSkills;
|
||||
|
||||
private Map<Integer, InvulSkillHolder> _invulAgainst;
|
||||
/** Creatures effect list. */
|
||||
@@ -4912,9 +4912,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
|
||||
if (_triggerSkills != null)
|
||||
{
|
||||
for (OptionsSkillHolder holder : _triggerSkills.values())
|
||||
for (OptionSkillHolder holder : _triggerSkills.values())
|
||||
{
|
||||
if (((!crit && (holder.getSkillType() == OptionsSkillType.ATTACK)) || ((holder.getSkillType() == OptionsSkillType.CRITICAL) && crit)) && (Rnd.get(100) < holder.getChance()))
|
||||
if (((!crit && (holder.getSkillType() == OptionSkillType.ATTACK)) || ((holder.getSkillType() == OptionSkillType.CRITICAL) && crit)) && (Rnd.get(100) < holder.getChance()))
|
||||
{
|
||||
makeTriggerCast(holder.getSkill(), target);
|
||||
}
|
||||
@@ -5731,9 +5731,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
|
||||
if (_triggerSkills != null)
|
||||
{
|
||||
for (OptionsSkillHolder holder : _triggerSkills.values())
|
||||
for (OptionSkillHolder holder : _triggerSkills.values())
|
||||
{
|
||||
if (((skill.isMagic() && (holder.getSkillType() == OptionsSkillType.MAGIC)) || (skill.isPhysical() && (holder.getSkillType() == OptionsSkillType.ATTACK))) && (Rnd.get(100) < holder.getChance()))
|
||||
if (((skill.isMagic() && (holder.getSkillType() == OptionSkillType.MAGIC)) || (skill.isPhysical() && (holder.getSkillType() == OptionSkillType.ATTACK))) && (Rnd.get(100) < holder.getChance()))
|
||||
{
|
||||
makeTriggerCast(holder.getSkill(), target);
|
||||
}
|
||||
@@ -6373,7 +6373,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
return _lethalable;
|
||||
}
|
||||
|
||||
public Map<Integer, OptionsSkillHolder> getTriggerSkills()
|
||||
public Map<Integer, OptionSkillHolder> getTriggerSkills()
|
||||
{
|
||||
if (_triggerSkills == null)
|
||||
{
|
||||
@@ -6388,14 +6388,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
return _triggerSkills;
|
||||
}
|
||||
|
||||
public void addTriggerSkill(OptionsSkillHolder holder)
|
||||
public void addTriggerSkill(OptionSkillHolder holder)
|
||||
{
|
||||
getTriggerSkills().put(holder.getSkillId(), holder);
|
||||
getTriggerSkills().put(holder.getSkill().getId(), holder);
|
||||
}
|
||||
|
||||
public void removeTriggerSkill(OptionsSkillHolder holder)
|
||||
public void removeTriggerSkill(OptionSkillHolder holder)
|
||||
{
|
||||
getTriggerSkills().remove(holder.getSkillId());
|
||||
getTriggerSkills().remove(holder.getSkill().getId());
|
||||
}
|
||||
|
||||
public void makeTriggerCast(Skill skill, Creature target, boolean ignoreTargetType)
|
||||
|
||||
@@ -16,36 +16,41 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.options;
|
||||
|
||||
import org.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import org.l2jmobius.gameserver.model.skill.Skill;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
* @author UnAfraid, Mobius
|
||||
*/
|
||||
public class OptionsSkillHolder extends SkillHolder
|
||||
public class OptionSkillHolder
|
||||
{
|
||||
private final OptionsSkillType _type;
|
||||
private final Skill _skill;
|
||||
private final double _chance;
|
||||
private final OptionSkillType _type;
|
||||
|
||||
/**
|
||||
* @param skillId
|
||||
* @param skillLevel
|
||||
* @param skill
|
||||
* @param type
|
||||
* @param chance
|
||||
*/
|
||||
public OptionsSkillHolder(int skillId, int skillLevel, double chance, OptionsSkillType type)
|
||||
public OptionSkillHolder(Skill skill, double chance, OptionSkillType type)
|
||||
{
|
||||
super(skillId, skillLevel);
|
||||
_skill = skill;
|
||||
_chance = chance;
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public OptionsSkillType getSkillType()
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _type;
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public double getChance()
|
||||
{
|
||||
return _chance;
|
||||
}
|
||||
|
||||
public OptionSkillType getSkillType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.options;
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public enum OptionsSkillType
|
||||
public enum OptionSkillType
|
||||
{
|
||||
ATTACK,
|
||||
MAGIC,
|
||||
@@ -22,7 +22,6 @@ import java.util.List;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.model.skill.Skill;
|
||||
import org.l2jmobius.gameserver.model.stats.functions.AbstractFunction;
|
||||
@@ -36,11 +35,9 @@ public class Options
|
||||
{
|
||||
private final int _id;
|
||||
private final List<FuncTemplate> _funcs = new ArrayList<>();
|
||||
|
||||
private SkillHolder _activeSkill = null;
|
||||
private SkillHolder _passiveSkill = null;
|
||||
|
||||
private final List<OptionsSkillHolder> _activationSkills = new ArrayList<>();
|
||||
private Skill _activeSkill = null;
|
||||
private Skill _passiveSkill = null;
|
||||
private final List<OptionSkillHolder> _activationSkills = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* @param id
|
||||
@@ -89,14 +86,14 @@ public class Options
|
||||
return _activeSkill != null;
|
||||
}
|
||||
|
||||
public SkillHolder getActiveSkill()
|
||||
public Skill getActiveSkill()
|
||||
{
|
||||
return _activeSkill;
|
||||
}
|
||||
|
||||
public void setActiveSkill(SkillHolder holder)
|
||||
public void setActiveSkill(Skill skill)
|
||||
{
|
||||
_activeSkill = holder;
|
||||
_activeSkill = skill;
|
||||
}
|
||||
|
||||
public boolean hasPassiveSkill()
|
||||
@@ -104,14 +101,14 @@ public class Options
|
||||
return _passiveSkill != null;
|
||||
}
|
||||
|
||||
public SkillHolder getPassiveSkill()
|
||||
public Skill getPassiveSkill()
|
||||
{
|
||||
return _passiveSkill;
|
||||
}
|
||||
|
||||
public void setPassiveSkill(SkillHolder holder)
|
||||
public void setPassiveSkill(Skill skill)
|
||||
{
|
||||
_passiveSkill = holder;
|
||||
_passiveSkill = skill;
|
||||
}
|
||||
|
||||
public boolean hasActivationSkills()
|
||||
@@ -119,9 +116,9 @@ public class Options
|
||||
return !_activationSkills.isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasActivationSkills(OptionsSkillType type)
|
||||
public boolean hasActivationSkills(OptionSkillType type)
|
||||
{
|
||||
for (OptionsSkillHolder holder : _activationSkills)
|
||||
for (OptionSkillHolder holder : _activationSkills)
|
||||
{
|
||||
if (holder.getSkillType() == type)
|
||||
{
|
||||
@@ -131,15 +128,15 @@ public class Options
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<OptionsSkillHolder> getActivationsSkills()
|
||||
public List<OptionSkillHolder> getActivationSkills()
|
||||
{
|
||||
return _activationSkills;
|
||||
}
|
||||
|
||||
public List<OptionsSkillHolder> getActivationsSkills(OptionsSkillType type)
|
||||
public List<OptionSkillHolder> getActivationSkills(OptionSkillType type)
|
||||
{
|
||||
final List<OptionsSkillHolder> temp = new ArrayList<>();
|
||||
for (OptionsSkillHolder holder : _activationSkills)
|
||||
final List<OptionSkillHolder> temp = new ArrayList<>();
|
||||
for (OptionSkillHolder holder : _activationSkills)
|
||||
{
|
||||
if (holder.getSkillType() == type)
|
||||
{
|
||||
@@ -149,7 +146,7 @@ public class Options
|
||||
return temp;
|
||||
}
|
||||
|
||||
public void addActivationSkill(OptionsSkillHolder holder)
|
||||
public void addActivationSkill(OptionSkillHolder holder)
|
||||
{
|
||||
_activationSkills.add(holder);
|
||||
}
|
||||
@@ -162,15 +159,15 @@ public class Options
|
||||
}
|
||||
if (hasActiveSkill())
|
||||
{
|
||||
addSkill(player, _activeSkill.getSkill());
|
||||
addSkill(player, _activeSkill);
|
||||
}
|
||||
if (hasPassiveSkill())
|
||||
{
|
||||
addSkill(player, _passiveSkill.getSkill());
|
||||
addSkill(player, _passiveSkill);
|
||||
}
|
||||
if (!_activationSkills.isEmpty())
|
||||
{
|
||||
for (OptionsSkillHolder holder : _activationSkills)
|
||||
for (OptionSkillHolder holder : _activationSkills)
|
||||
{
|
||||
player.addTriggerSkill(holder);
|
||||
}
|
||||
@@ -187,15 +184,15 @@ public class Options
|
||||
}
|
||||
if (hasActiveSkill())
|
||||
{
|
||||
player.removeSkill(_activeSkill.getSkill(), false, false);
|
||||
player.removeSkill(_activeSkill, false, false);
|
||||
}
|
||||
if (hasPassiveSkill())
|
||||
{
|
||||
player.removeSkill(_passiveSkill.getSkill(), false, true);
|
||||
player.removeSkill(_passiveSkill, false, true);
|
||||
}
|
||||
if (!_activationSkills.isEmpty())
|
||||
{
|
||||
for (OptionsSkillHolder holder : _activationSkills)
|
||||
for (OptionSkillHolder holder : _activationSkills)
|
||||
{
|
||||
player.removeTriggerSkill(holder);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user