Skill condition checks before auto skill use.

This commit is contained in:
MobiusDevelopment
2020-03-14 09:54:52 +00:00
parent f1b0bc4c07
commit 4531b8962e
16 changed files with 20 additions and 20 deletions

View File

@@ -88,7 +88,7 @@ public class ItemSkillsTemplate implements IItemHandler
hasConsumeSkill = true; hasConsumeSkill = true;
} }
if (!itemSkill.hasEffectType(EffectType.SUMMON_PET) && !itemSkill.checkCondition(playable, playable.getTarget())) if (!itemSkill.hasEffectType(EffectType.SUMMON_PET) && !itemSkill.checkCondition(playable, playable.getTarget(), true))
{ {
continue; continue;
} }

View File

@@ -923,7 +923,7 @@ public class EffectList
} }
// Check for passive skill conditions. // Check for passive skill conditions.
if (!skill.checkCondition(info.getEffector(), info.getEffected())) if (!skill.checkCondition(info.getEffector(), info.getEffected(), true))
{ {
return; return;
} }

View File

@@ -680,7 +680,7 @@ public abstract class Summon extends Playable
} }
// Check if all casting conditions are completed // Check if all casting conditions are completed
if (!skill.checkCondition(this, target)) if (!skill.checkCondition(this, target, true))
{ {
// Send a Server->Client packet ActionFailed to the PlayerInstance // Send a Server->Client packet ActionFailed to the PlayerInstance
sendPacket(ActionFailed.STATIC_PACKET); sendPacket(ActionFailed.STATIC_PACKET);

View File

@@ -8369,7 +8369,7 @@ public class PlayerInstance extends Playable
} }
// Check if all casting conditions are completed // Check if all casting conditions are completed
if (!skill.checkCondition(this, target)) if (!skill.checkCondition(this, target, true))
{ {
sendPacket(ActionFailed.STATIC_PACKET); sendPacket(ActionFailed.STATIC_PACKET);
@@ -14062,7 +14062,7 @@ public class PlayerInstance extends Playable
removeAutoSkill(skillId); removeAutoSkill(skillId);
continue; continue;
} }
if (!isAffectedBySkill(skillId) && !isInsideZone(ZoneId.PEACE) && !hasSkillReuse(skill.getReuseHashCode())) if (!isAffectedBySkill(skillId) && !isInsideZone(ZoneId.PEACE) && !hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(this, this, false))
{ {
doCast(skill); doCast(skill);
} }

View File

@@ -284,7 +284,7 @@ public class Weapon extends Item
} }
// Skill condition not met // Skill condition not met
if (!skill.checkCondition(caster, target)) if (!skill.checkCondition(caster, target, true))
{ {
return; return;
} }

View File

@@ -1042,7 +1042,7 @@ public class Skill implements IIdentifiable
return _effectPoint < 0; return _effectPoint < 0;
} }
public boolean checkCondition(Creature creature, WorldObject object) public boolean checkCondition(Creature creature, WorldObject object, boolean sendMessage)
{ {
if (creature.isFakePlayer() || (creature.canOverrideCond(PlayerCondOverride.SKILL_CONDITIONS) && !Config.GM_SKILL_RESTRICTION)) if (creature.isFakePlayer() || (creature.canOverrideCond(PlayerCondOverride.SKILL_CONDITIONS) && !Config.GM_SKILL_RESTRICTION))
{ {
@@ -1059,7 +1059,7 @@ public class Skill implements IIdentifiable
if (!checkConditions(SkillConditionScope.GENERAL, creature, object) || !checkConditions(SkillConditionScope.TARGET, creature, object)) if (!checkConditions(SkillConditionScope.GENERAL, creature, object) || !checkConditions(SkillConditionScope.TARGET, creature, object))
{ {
if (!((creature == object) && isBad())) // Self targeted bad skills should not send a message. if (sendMessage && !((creature == object) && isBad())) // Self targeted bad skills should not send a message.
{ {
final SystemMessage sm = new SystemMessage(SystemMessageId.S1_CANNOT_BE_USED_DUE_TO_UNSUITABLE_TERMS); final SystemMessage sm = new SystemMessage(SystemMessageId.S1_CANNOT_BE_USED_DUE_TO_UNSUITABLE_TERMS);
sm.addSkillName(_id); sm.addSkillName(_id);

View File

@@ -797,7 +797,7 @@ public class SkillCaster implements Runnable
return; return;
} }
if (skill.checkCondition(creature, target)) if (skill.checkCondition(creature, target, true))
{ {
if (creature.isSkillDisabled(skill)) if (creature.isSkillDisabled(skill))
{ {

View File

@@ -262,7 +262,7 @@ public class EffectZone extends ZoneType
for (Entry<Integer, Integer> e : _skills.entrySet()) for (Entry<Integer, Integer> e : _skills.entrySet())
{ {
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue()); final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character))) if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character, true)))
{ {
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel()) if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
{ {

View File

@@ -88,7 +88,7 @@ public class ItemSkillsTemplate implements IItemHandler
hasConsumeSkill = true; hasConsumeSkill = true;
} }
if (!itemSkill.hasEffectType(EffectType.SUMMON_PET) && !itemSkill.checkCondition(playable, playable.getTarget())) if (!itemSkill.hasEffectType(EffectType.SUMMON_PET) && !itemSkill.checkCondition(playable, playable.getTarget(), true))
{ {
continue; continue;
} }

View File

@@ -923,7 +923,7 @@ public class EffectList
} }
// Check for passive skill conditions. // Check for passive skill conditions.
if (!skill.checkCondition(info.getEffector(), info.getEffected())) if (!skill.checkCondition(info.getEffector(), info.getEffected(), true))
{ {
return; return;
} }

View File

@@ -680,7 +680,7 @@ public abstract class Summon extends Playable
} }
// Check if all casting conditions are completed // Check if all casting conditions are completed
if (!skill.checkCondition(this, target)) if (!skill.checkCondition(this, target, true))
{ {
// Send a Server->Client packet ActionFailed to the PlayerInstance // Send a Server->Client packet ActionFailed to the PlayerInstance
sendPacket(ActionFailed.STATIC_PACKET); sendPacket(ActionFailed.STATIC_PACKET);

View File

@@ -8303,7 +8303,7 @@ public class PlayerInstance extends Playable
} }
// Check if all casting conditions are completed // Check if all casting conditions are completed
if (!skill.checkCondition(this, target)) if (!skill.checkCondition(this, target, true))
{ {
sendPacket(ActionFailed.STATIC_PACKET); sendPacket(ActionFailed.STATIC_PACKET);
@@ -14040,7 +14040,7 @@ public class PlayerInstance extends Playable
removeAutoSkill(skillId); removeAutoSkill(skillId);
continue; continue;
} }
if (!isAffectedBySkill(skillId) && !isInsideZone(ZoneId.PEACE) && !hasSkillReuse(skill.getReuseHashCode())) if (!isAffectedBySkill(skillId) && !isInsideZone(ZoneId.PEACE) && !hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(this, this, false))
{ {
doCast(skill); doCast(skill);
} }

View File

@@ -284,7 +284,7 @@ public class Weapon extends Item
} }
// Skill condition not met // Skill condition not met
if (!skill.checkCondition(caster, target)) if (!skill.checkCondition(caster, target, true))
{ {
return; return;
} }

View File

@@ -1042,7 +1042,7 @@ public class Skill implements IIdentifiable
return _effectPoint < 0; return _effectPoint < 0;
} }
public boolean checkCondition(Creature creature, WorldObject object) public boolean checkCondition(Creature creature, WorldObject object, boolean sendMessage)
{ {
if (creature.isFakePlayer() || (creature.canOverrideCond(PlayerCondOverride.SKILL_CONDITIONS) && !Config.GM_SKILL_RESTRICTION)) if (creature.isFakePlayer() || (creature.canOverrideCond(PlayerCondOverride.SKILL_CONDITIONS) && !Config.GM_SKILL_RESTRICTION))
{ {
@@ -1059,7 +1059,7 @@ public class Skill implements IIdentifiable
if (!checkConditions(SkillConditionScope.GENERAL, creature, object) || !checkConditions(SkillConditionScope.TARGET, creature, object)) if (!checkConditions(SkillConditionScope.GENERAL, creature, object) || !checkConditions(SkillConditionScope.TARGET, creature, object))
{ {
if (!((creature == object) && isBad())) // Self targeted bad skills should not send a message. if (sendMessage && !((creature == object) && isBad())) // Self targeted bad skills should not send a message.
{ {
final SystemMessage sm = new SystemMessage(SystemMessageId.S1_CANNOT_BE_USED_DUE_TO_UNSUITABLE_TERMS); final SystemMessage sm = new SystemMessage(SystemMessageId.S1_CANNOT_BE_USED_DUE_TO_UNSUITABLE_TERMS);
sm.addSkillName(_id); sm.addSkillName(_id);

View File

@@ -797,7 +797,7 @@ public class SkillCaster implements Runnable
return; return;
} }
if (skill.checkCondition(creature, target)) if (skill.checkCondition(creature, target, true))
{ {
if (creature.isSkillDisabled(skill)) if (creature.isSkillDisabled(skill))
{ {

View File

@@ -262,7 +262,7 @@ public class EffectZone extends ZoneType
for (Entry<Integer, Integer> e : _skills.entrySet()) for (Entry<Integer, Integer> e : _skills.entrySet())
{ {
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue()); final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character))) if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character, true)))
{ {
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel()) if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
{ {