Addition of auto use skill availability methods.
Thanks to manax182.
This commit is contained in:
parent
28c320eef5
commit
349014127c
@ -171,45 +171,14 @@ public class AutoUseTaskManager
|
|||||||
continue BUFFS;
|
continue BUFFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Casting on self stops movement.
|
|
||||||
final WorldObject target = player.getTarget();
|
|
||||||
if (target == player)
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fixes start area issue.
|
// Fixes start area issue.
|
||||||
if (isInPeaceZone)
|
if (isInPeaceZone)
|
||||||
{
|
{
|
||||||
continue BUFFS;
|
continue BUFFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Use getSkillRemainingReuseTime?
|
final WorldObject target = player.getTarget();
|
||||||
if (!player.isAffectedBySkill(skillId.intValue()) && !player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false))
|
if (canCastBuff(skill, player, target))
|
||||||
{
|
|
||||||
// Summon check.
|
|
||||||
if (skill.getAffectScope() == AffectScope.SUMMON_EXCEPT_MASTER)
|
|
||||||
{
|
|
||||||
if (!player.hasServitors()) // Is this check truly needed?
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
int occurrences = 0;
|
|
||||||
for (Summon servitor : player.getServitors().values())
|
|
||||||
{
|
|
||||||
if (servitor.isAffectedBySkill(skillId.intValue()))
|
|
||||||
{
|
|
||||||
occurrences++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (occurrences == player.getServitors().size())
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check buff target.
|
|
||||||
if ((target == null) || !target.isPlayable())
|
|
||||||
{
|
{
|
||||||
final WorldObject savedTarget = target;
|
final WorldObject savedTarget = target;
|
||||||
player.setTarget(player);
|
player.setTarget(player);
|
||||||
@ -217,7 +186,6 @@ public class AutoUseTaskManager
|
|||||||
player.setTarget(savedTarget);
|
player.setTarget(savedTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Continue when auto play is not enabled.
|
// Continue when auto play is not enabled.
|
||||||
if (!AutoPlayTaskManager.getInstance().isAutoPlay(player))
|
if (!AutoPlayTaskManager.getInstance().isAutoPlay(player))
|
||||||
@ -259,7 +227,7 @@ public class AutoUseTaskManager
|
|||||||
continue SKILLS;
|
continue SKILLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false))
|
if (canUseMagic(skill, player, target))
|
||||||
{
|
{
|
||||||
player.useMagic(skill, null, true, false);
|
player.useMagic(skill, null, true, false);
|
||||||
}
|
}
|
||||||
@ -307,6 +275,38 @@ public class AutoUseTaskManager
|
|||||||
}, 1000, 1000);
|
}, 1000, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean canCastBuff(Skill skill, PlayerInstance player, WorldObject target)
|
||||||
|
{
|
||||||
|
// Summon check.
|
||||||
|
if (skill.getAffectScope() == AffectScope.SUMMON_EXCEPT_MASTER)
|
||||||
|
{
|
||||||
|
if (!player.hasServitors()) // Is this check truly needed?
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int occurrences = 0;
|
||||||
|
for (Summon servitor : player.getServitors().values())
|
||||||
|
{
|
||||||
|
if (servitor.isAffectedBySkill(skill.getId()))
|
||||||
|
{
|
||||||
|
occurrences++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (occurrences == player.getServitors().size())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Use getSkillRemainingReuseTime?
|
||||||
|
return !player.isAffectedBySkill(skill.getId()) && canUseMagic(skill, player, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canUseMagic(Skill skill, PlayerInstance player, WorldObject target)
|
||||||
|
{
|
||||||
|
return !player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false);
|
||||||
|
}
|
||||||
|
|
||||||
public void startAutoUseTask(PlayerInstance player)
|
public void startAutoUseTask(PlayerInstance player)
|
||||||
{
|
{
|
||||||
if (!PLAYERS.contains(player))
|
if (!PLAYERS.contains(player))
|
||||||
|
@ -171,45 +171,14 @@ public class AutoUseTaskManager
|
|||||||
continue BUFFS;
|
continue BUFFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Casting on self stops movement.
|
|
||||||
final WorldObject target = player.getTarget();
|
|
||||||
if (target == player)
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fixes start area issue.
|
// Fixes start area issue.
|
||||||
if (isInPeaceZone)
|
if (isInPeaceZone)
|
||||||
{
|
{
|
||||||
continue BUFFS;
|
continue BUFFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Use getSkillRemainingReuseTime?
|
final WorldObject target = player.getTarget();
|
||||||
if (!player.isAffectedBySkill(skillId.intValue()) && !player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false))
|
if (canCastBuff(skill, player, target))
|
||||||
{
|
|
||||||
// Summon check.
|
|
||||||
if (skill.getAffectScope() == AffectScope.SUMMON_EXCEPT_MASTER)
|
|
||||||
{
|
|
||||||
if (!player.hasServitors()) // Is this check truly needed?
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
int occurrences = 0;
|
|
||||||
for (Summon servitor : player.getServitors().values())
|
|
||||||
{
|
|
||||||
if (servitor.isAffectedBySkill(skillId.intValue()))
|
|
||||||
{
|
|
||||||
occurrences++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (occurrences == player.getServitors().size())
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check buff target.
|
|
||||||
if ((target == null) || !target.isPlayable())
|
|
||||||
{
|
{
|
||||||
final WorldObject savedTarget = target;
|
final WorldObject savedTarget = target;
|
||||||
player.setTarget(player);
|
player.setTarget(player);
|
||||||
@ -217,7 +186,6 @@ public class AutoUseTaskManager
|
|||||||
player.setTarget(savedTarget);
|
player.setTarget(savedTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Continue when auto play is not enabled.
|
// Continue when auto play is not enabled.
|
||||||
if (!AutoPlayTaskManager.getInstance().isAutoPlay(player))
|
if (!AutoPlayTaskManager.getInstance().isAutoPlay(player))
|
||||||
@ -259,7 +227,7 @@ public class AutoUseTaskManager
|
|||||||
continue SKILLS;
|
continue SKILLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false))
|
if (canUseMagic(skill, player, target))
|
||||||
{
|
{
|
||||||
player.useMagic(skill, null, true, false);
|
player.useMagic(skill, null, true, false);
|
||||||
}
|
}
|
||||||
@ -307,6 +275,38 @@ public class AutoUseTaskManager
|
|||||||
}, 1000, 1000);
|
}, 1000, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean canCastBuff(Skill skill, PlayerInstance player, WorldObject target)
|
||||||
|
{
|
||||||
|
// Summon check.
|
||||||
|
if (skill.getAffectScope() == AffectScope.SUMMON_EXCEPT_MASTER)
|
||||||
|
{
|
||||||
|
if (!player.hasServitors()) // Is this check truly needed?
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int occurrences = 0;
|
||||||
|
for (Summon servitor : player.getServitors().values())
|
||||||
|
{
|
||||||
|
if (servitor.isAffectedBySkill(skill.getId()))
|
||||||
|
{
|
||||||
|
occurrences++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (occurrences == player.getServitors().size())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Use getSkillRemainingReuseTime?
|
||||||
|
return !player.isAffectedBySkill(skill.getId()) && canUseMagic(skill, player, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canUseMagic(Skill skill, PlayerInstance player, WorldObject target)
|
||||||
|
{
|
||||||
|
return !player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false);
|
||||||
|
}
|
||||||
|
|
||||||
public void startAutoUseTask(PlayerInstance player)
|
public void startAutoUseTask(PlayerInstance player)
|
||||||
{
|
{
|
||||||
if (!PLAYERS.contains(player))
|
if (!PLAYERS.contains(player))
|
||||||
|
@ -171,45 +171,14 @@ public class AutoUseTaskManager
|
|||||||
continue BUFFS;
|
continue BUFFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Casting on self stops movement.
|
|
||||||
final WorldObject target = player.getTarget();
|
|
||||||
if (target == player)
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fixes start area issue.
|
// Fixes start area issue.
|
||||||
if (isInPeaceZone)
|
if (isInPeaceZone)
|
||||||
{
|
{
|
||||||
continue BUFFS;
|
continue BUFFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Use getSkillRemainingReuseTime?
|
final WorldObject target = player.getTarget();
|
||||||
if (!player.isAffectedBySkill(skillId.intValue()) && !player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false))
|
if (canCastBuff(skill, player, target))
|
||||||
{
|
|
||||||
// Summon check.
|
|
||||||
if (skill.getAffectScope() == AffectScope.SUMMON_EXCEPT_MASTER)
|
|
||||||
{
|
|
||||||
if (!player.hasServitors()) // Is this check truly needed?
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
int occurrences = 0;
|
|
||||||
for (Summon servitor : player.getServitors().values())
|
|
||||||
{
|
|
||||||
if (servitor.isAffectedBySkill(skillId.intValue()))
|
|
||||||
{
|
|
||||||
occurrences++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (occurrences == player.getServitors().size())
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check buff target.
|
|
||||||
if ((target == null) || !target.isPlayable())
|
|
||||||
{
|
{
|
||||||
final WorldObject savedTarget = target;
|
final WorldObject savedTarget = target;
|
||||||
player.setTarget(player);
|
player.setTarget(player);
|
||||||
@ -217,7 +186,6 @@ public class AutoUseTaskManager
|
|||||||
player.setTarget(savedTarget);
|
player.setTarget(savedTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Continue when auto play is not enabled.
|
// Continue when auto play is not enabled.
|
||||||
if (!AutoPlayTaskManager.getInstance().isAutoPlay(player))
|
if (!AutoPlayTaskManager.getInstance().isAutoPlay(player))
|
||||||
@ -259,7 +227,7 @@ public class AutoUseTaskManager
|
|||||||
continue SKILLS;
|
continue SKILLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false))
|
if (canUseMagic(skill, player, target))
|
||||||
{
|
{
|
||||||
player.useMagic(skill, null, true, false);
|
player.useMagic(skill, null, true, false);
|
||||||
}
|
}
|
||||||
@ -307,6 +275,38 @@ public class AutoUseTaskManager
|
|||||||
}, 1000, 1000);
|
}, 1000, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean canCastBuff(Skill skill, PlayerInstance player, WorldObject target)
|
||||||
|
{
|
||||||
|
// Summon check.
|
||||||
|
if (skill.getAffectScope() == AffectScope.SUMMON_EXCEPT_MASTER)
|
||||||
|
{
|
||||||
|
if (!player.hasServitors()) // Is this check truly needed?
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int occurrences = 0;
|
||||||
|
for (Summon servitor : player.getServitors().values())
|
||||||
|
{
|
||||||
|
if (servitor.isAffectedBySkill(skill.getId()))
|
||||||
|
{
|
||||||
|
occurrences++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (occurrences == player.getServitors().size())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Use getSkillRemainingReuseTime?
|
||||||
|
return !player.isAffectedBySkill(skill.getId()) && canUseMagic(skill, player, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canUseMagic(Skill skill, PlayerInstance player, WorldObject target)
|
||||||
|
{
|
||||||
|
return !player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false);
|
||||||
|
}
|
||||||
|
|
||||||
public void startAutoUseTask(PlayerInstance player)
|
public void startAutoUseTask(PlayerInstance player)
|
||||||
{
|
{
|
||||||
if (!PLAYERS.contains(player))
|
if (!PLAYERS.contains(player))
|
||||||
|
@ -171,45 +171,14 @@ public class AutoUseTaskManager
|
|||||||
continue BUFFS;
|
continue BUFFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Casting on self stops movement.
|
|
||||||
final WorldObject target = player.getTarget();
|
|
||||||
if (target == player)
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fixes start area issue.
|
// Fixes start area issue.
|
||||||
if (isInPeaceZone)
|
if (isInPeaceZone)
|
||||||
{
|
{
|
||||||
continue BUFFS;
|
continue BUFFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Use getSkillRemainingReuseTime?
|
final WorldObject target = player.getTarget();
|
||||||
if (!player.isAffectedBySkill(skillId.intValue()) && !player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false))
|
if (canCastBuff(skill, player, target))
|
||||||
{
|
|
||||||
// Summon check.
|
|
||||||
if (skill.getAffectScope() == AffectScope.SUMMON_EXCEPT_MASTER)
|
|
||||||
{
|
|
||||||
if (!player.hasServitors()) // Is this check truly needed?
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
int occurrences = 0;
|
|
||||||
for (Summon servitor : player.getServitors().values())
|
|
||||||
{
|
|
||||||
if (servitor.isAffectedBySkill(skillId.intValue()))
|
|
||||||
{
|
|
||||||
occurrences++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (occurrences == player.getServitors().size())
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check buff target.
|
|
||||||
if ((target == null) || !target.isPlayable())
|
|
||||||
{
|
{
|
||||||
final WorldObject savedTarget = target;
|
final WorldObject savedTarget = target;
|
||||||
player.setTarget(player);
|
player.setTarget(player);
|
||||||
@ -217,7 +186,6 @@ public class AutoUseTaskManager
|
|||||||
player.setTarget(savedTarget);
|
player.setTarget(savedTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Continue when auto play is not enabled.
|
// Continue when auto play is not enabled.
|
||||||
if (!AutoPlayTaskManager.getInstance().isAutoPlay(player))
|
if (!AutoPlayTaskManager.getInstance().isAutoPlay(player))
|
||||||
@ -259,7 +227,7 @@ public class AutoUseTaskManager
|
|||||||
continue SKILLS;
|
continue SKILLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false))
|
if (canUseMagic(skill, player, target))
|
||||||
{
|
{
|
||||||
player.useMagic(skill, null, true, false);
|
player.useMagic(skill, null, true, false);
|
||||||
}
|
}
|
||||||
@ -307,6 +275,38 @@ public class AutoUseTaskManager
|
|||||||
}, 1000, 1000);
|
}, 1000, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean canCastBuff(Skill skill, PlayerInstance player, WorldObject target)
|
||||||
|
{
|
||||||
|
// Summon check.
|
||||||
|
if (skill.getAffectScope() == AffectScope.SUMMON_EXCEPT_MASTER)
|
||||||
|
{
|
||||||
|
if (!player.hasServitors()) // Is this check truly needed?
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int occurrences = 0;
|
||||||
|
for (Summon servitor : player.getServitors().values())
|
||||||
|
{
|
||||||
|
if (servitor.isAffectedBySkill(skill.getId()))
|
||||||
|
{
|
||||||
|
occurrences++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (occurrences == player.getServitors().size())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Use getSkillRemainingReuseTime?
|
||||||
|
return !player.isAffectedBySkill(skill.getId()) && canUseMagic(skill, player, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canUseMagic(Skill skill, PlayerInstance player, WorldObject target)
|
||||||
|
{
|
||||||
|
return !player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false);
|
||||||
|
}
|
||||||
|
|
||||||
public void startAutoUseTask(PlayerInstance player)
|
public void startAutoUseTask(PlayerInstance player)
|
||||||
{
|
{
|
||||||
if (!PLAYERS.contains(player))
|
if (!PLAYERS.contains(player))
|
||||||
|
@ -171,45 +171,14 @@ public class AutoUseTaskManager
|
|||||||
continue BUFFS;
|
continue BUFFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Casting on self stops movement.
|
|
||||||
final WorldObject target = player.getTarget();
|
|
||||||
if (target == player)
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fixes start area issue.
|
// Fixes start area issue.
|
||||||
if (isInPeaceZone)
|
if (isInPeaceZone)
|
||||||
{
|
{
|
||||||
continue BUFFS;
|
continue BUFFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Use getSkillRemainingReuseTime?
|
final WorldObject target = player.getTarget();
|
||||||
if (!player.isAffectedBySkill(skillId.intValue()) && !player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false))
|
if (canCastBuff(skill, player, target))
|
||||||
{
|
|
||||||
// Summon check.
|
|
||||||
if (skill.getAffectScope() == AffectScope.SUMMON_EXCEPT_MASTER)
|
|
||||||
{
|
|
||||||
if (!player.hasServitors()) // Is this check truly needed?
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
int occurrences = 0;
|
|
||||||
for (Summon servitor : player.getServitors().values())
|
|
||||||
{
|
|
||||||
if (servitor.isAffectedBySkill(skillId.intValue()))
|
|
||||||
{
|
|
||||||
occurrences++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (occurrences == player.getServitors().size())
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check buff target.
|
|
||||||
if ((target == null) || !target.isPlayable())
|
|
||||||
{
|
{
|
||||||
final WorldObject savedTarget = target;
|
final WorldObject savedTarget = target;
|
||||||
player.setTarget(player);
|
player.setTarget(player);
|
||||||
@ -217,7 +186,6 @@ public class AutoUseTaskManager
|
|||||||
player.setTarget(savedTarget);
|
player.setTarget(savedTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Continue when auto play is not enabled.
|
// Continue when auto play is not enabled.
|
||||||
if (!AutoPlayTaskManager.getInstance().isAutoPlay(player))
|
if (!AutoPlayTaskManager.getInstance().isAutoPlay(player))
|
||||||
@ -259,7 +227,7 @@ public class AutoUseTaskManager
|
|||||||
continue SKILLS;
|
continue SKILLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false))
|
if (canUseMagic(skill, player, target))
|
||||||
{
|
{
|
||||||
player.useMagic(skill, null, true, false);
|
player.useMagic(skill, null, true, false);
|
||||||
}
|
}
|
||||||
@ -307,6 +275,38 @@ public class AutoUseTaskManager
|
|||||||
}, 1000, 1000);
|
}, 1000, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean canCastBuff(Skill skill, PlayerInstance player, WorldObject target)
|
||||||
|
{
|
||||||
|
// Summon check.
|
||||||
|
if (skill.getAffectScope() == AffectScope.SUMMON_EXCEPT_MASTER)
|
||||||
|
{
|
||||||
|
if (!player.hasServitors()) // Is this check truly needed?
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int occurrences = 0;
|
||||||
|
for (Summon servitor : player.getServitors().values())
|
||||||
|
{
|
||||||
|
if (servitor.isAffectedBySkill(skill.getId()))
|
||||||
|
{
|
||||||
|
occurrences++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (occurrences == player.getServitors().size())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Use getSkillRemainingReuseTime?
|
||||||
|
return !player.isAffectedBySkill(skill.getId()) && canUseMagic(skill, player, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canUseMagic(Skill skill, PlayerInstance player, WorldObject target)
|
||||||
|
{
|
||||||
|
return !player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false);
|
||||||
|
}
|
||||||
|
|
||||||
public void startAutoUseTask(PlayerInstance player)
|
public void startAutoUseTask(PlayerInstance player)
|
||||||
{
|
{
|
||||||
if (!PLAYERS.contains(player))
|
if (!PLAYERS.contains(player))
|
||||||
|
@ -171,45 +171,14 @@ public class AutoUseTaskManager
|
|||||||
continue BUFFS;
|
continue BUFFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Casting on self stops movement.
|
|
||||||
final WorldObject target = player.getTarget();
|
|
||||||
if (target == player)
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fixes start area issue.
|
// Fixes start area issue.
|
||||||
if (isInPeaceZone)
|
if (isInPeaceZone)
|
||||||
{
|
{
|
||||||
continue BUFFS;
|
continue BUFFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Use getSkillRemainingReuseTime?
|
final WorldObject target = player.getTarget();
|
||||||
if (!player.isAffectedBySkill(skillId.intValue()) && !player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false))
|
if (canCastBuff(skill, player, target))
|
||||||
{
|
|
||||||
// Summon check.
|
|
||||||
if (skill.getAffectScope() == AffectScope.SUMMON_EXCEPT_MASTER)
|
|
||||||
{
|
|
||||||
if (!player.hasServitors()) // Is this check truly needed?
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
int occurrences = 0;
|
|
||||||
for (Summon servitor : player.getServitors().values())
|
|
||||||
{
|
|
||||||
if (servitor.isAffectedBySkill(skillId.intValue()))
|
|
||||||
{
|
|
||||||
occurrences++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (occurrences == player.getServitors().size())
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check buff target.
|
|
||||||
if ((target == null) || !target.isPlayable())
|
|
||||||
{
|
{
|
||||||
final WorldObject savedTarget = target;
|
final WorldObject savedTarget = target;
|
||||||
player.setTarget(player);
|
player.setTarget(player);
|
||||||
@ -217,7 +186,6 @@ public class AutoUseTaskManager
|
|||||||
player.setTarget(savedTarget);
|
player.setTarget(savedTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Continue when auto play is not enabled.
|
// Continue when auto play is not enabled.
|
||||||
if (!AutoPlayTaskManager.getInstance().isAutoPlay(player))
|
if (!AutoPlayTaskManager.getInstance().isAutoPlay(player))
|
||||||
@ -259,7 +227,7 @@ public class AutoUseTaskManager
|
|||||||
continue SKILLS;
|
continue SKILLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false))
|
if (canUseMagic(skill, player, target))
|
||||||
{
|
{
|
||||||
player.useMagic(skill, null, true, false);
|
player.useMagic(skill, null, true, false);
|
||||||
}
|
}
|
||||||
@ -307,6 +275,38 @@ public class AutoUseTaskManager
|
|||||||
}, 1000, 1000);
|
}, 1000, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean canCastBuff(Skill skill, PlayerInstance player, WorldObject target)
|
||||||
|
{
|
||||||
|
// Summon check.
|
||||||
|
if (skill.getAffectScope() == AffectScope.SUMMON_EXCEPT_MASTER)
|
||||||
|
{
|
||||||
|
if (!player.hasServitors()) // Is this check truly needed?
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int occurrences = 0;
|
||||||
|
for (Summon servitor : player.getServitors().values())
|
||||||
|
{
|
||||||
|
if (servitor.isAffectedBySkill(skill.getId()))
|
||||||
|
{
|
||||||
|
occurrences++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (occurrences == player.getServitors().size())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Use getSkillRemainingReuseTime?
|
||||||
|
return !player.isAffectedBySkill(skill.getId()) && canUseMagic(skill, player, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canUseMagic(Skill skill, PlayerInstance player, WorldObject target)
|
||||||
|
{
|
||||||
|
return !player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false);
|
||||||
|
}
|
||||||
|
|
||||||
public void startAutoUseTask(PlayerInstance player)
|
public void startAutoUseTask(PlayerInstance player)
|
||||||
{
|
{
|
||||||
if (!PLAYERS.contains(player))
|
if (!PLAYERS.contains(player))
|
||||||
|
@ -171,45 +171,14 @@ public class AutoUseTaskManager
|
|||||||
continue BUFFS;
|
continue BUFFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Casting on self stops movement.
|
|
||||||
final WorldObject target = player.getTarget();
|
|
||||||
if (target == player)
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fixes start area issue.
|
// Fixes start area issue.
|
||||||
if (isInPeaceZone)
|
if (isInPeaceZone)
|
||||||
{
|
{
|
||||||
continue BUFFS;
|
continue BUFFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Use getSkillRemainingReuseTime?
|
final WorldObject target = player.getTarget();
|
||||||
if (!player.isAffectedBySkill(skillId.intValue()) && !player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false))
|
if (canCastBuff(skill, player, target))
|
||||||
{
|
|
||||||
// Summon check.
|
|
||||||
if (skill.getAffectScope() == AffectScope.SUMMON_EXCEPT_MASTER)
|
|
||||||
{
|
|
||||||
if (!player.hasServitors()) // Is this check truly needed?
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
int occurrences = 0;
|
|
||||||
for (Summon servitor : player.getServitors().values())
|
|
||||||
{
|
|
||||||
if (servitor.isAffectedBySkill(skillId.intValue()))
|
|
||||||
{
|
|
||||||
occurrences++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (occurrences == player.getServitors().size())
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check buff target.
|
|
||||||
if ((target == null) || !target.isPlayable())
|
|
||||||
{
|
{
|
||||||
final WorldObject savedTarget = target;
|
final WorldObject savedTarget = target;
|
||||||
player.setTarget(player);
|
player.setTarget(player);
|
||||||
@ -217,7 +186,6 @@ public class AutoUseTaskManager
|
|||||||
player.setTarget(savedTarget);
|
player.setTarget(savedTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Continue when auto play is not enabled.
|
// Continue when auto play is not enabled.
|
||||||
if (!AutoPlayTaskManager.getInstance().isAutoPlay(player))
|
if (!AutoPlayTaskManager.getInstance().isAutoPlay(player))
|
||||||
@ -259,7 +227,7 @@ public class AutoUseTaskManager
|
|||||||
continue SKILLS;
|
continue SKILLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false))
|
if (canUseMagic(skill, player, target))
|
||||||
{
|
{
|
||||||
player.useMagic(skill, null, true, false);
|
player.useMagic(skill, null, true, false);
|
||||||
}
|
}
|
||||||
@ -307,6 +275,38 @@ public class AutoUseTaskManager
|
|||||||
}, 1000, 1000);
|
}, 1000, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean canCastBuff(Skill skill, PlayerInstance player, WorldObject target)
|
||||||
|
{
|
||||||
|
// Summon check.
|
||||||
|
if (skill.getAffectScope() == AffectScope.SUMMON_EXCEPT_MASTER)
|
||||||
|
{
|
||||||
|
if (!player.hasServitors()) // Is this check truly needed?
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int occurrences = 0;
|
||||||
|
for (Summon servitor : player.getServitors().values())
|
||||||
|
{
|
||||||
|
if (servitor.isAffectedBySkill(skill.getId()))
|
||||||
|
{
|
||||||
|
occurrences++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (occurrences == player.getServitors().size())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Use getSkillRemainingReuseTime?
|
||||||
|
return !player.isAffectedBySkill(skill.getId()) && canUseMagic(skill, player, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canUseMagic(Skill skill, PlayerInstance player, WorldObject target)
|
||||||
|
{
|
||||||
|
return !player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false);
|
||||||
|
}
|
||||||
|
|
||||||
public void startAutoUseTask(PlayerInstance player)
|
public void startAutoUseTask(PlayerInstance player)
|
||||||
{
|
{
|
||||||
if (!PLAYERS.contains(player))
|
if (!PLAYERS.contains(player))
|
||||||
|
@ -171,45 +171,14 @@ public class AutoUseTaskManager
|
|||||||
continue BUFFS;
|
continue BUFFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Casting on self stops movement.
|
|
||||||
final WorldObject target = player.getTarget();
|
|
||||||
if (target == player)
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fixes start area issue.
|
// Fixes start area issue.
|
||||||
if (isInPeaceZone)
|
if (isInPeaceZone)
|
||||||
{
|
{
|
||||||
continue BUFFS;
|
continue BUFFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Use getSkillRemainingReuseTime?
|
final WorldObject target = player.getTarget();
|
||||||
if (!player.isAffectedBySkill(skillId.intValue()) && !player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false))
|
if (canCastBuff(skill, player, target))
|
||||||
{
|
|
||||||
// Summon check.
|
|
||||||
if (skill.getAffectScope() == AffectScope.SUMMON_EXCEPT_MASTER)
|
|
||||||
{
|
|
||||||
if (!player.hasServitors()) // Is this check truly needed?
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
int occurrences = 0;
|
|
||||||
for (Summon servitor : player.getServitors().values())
|
|
||||||
{
|
|
||||||
if (servitor.isAffectedBySkill(skillId.intValue()))
|
|
||||||
{
|
|
||||||
occurrences++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (occurrences == player.getServitors().size())
|
|
||||||
{
|
|
||||||
continue BUFFS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check buff target.
|
|
||||||
if ((target == null) || !target.isPlayable())
|
|
||||||
{
|
{
|
||||||
final WorldObject savedTarget = target;
|
final WorldObject savedTarget = target;
|
||||||
player.setTarget(player);
|
player.setTarget(player);
|
||||||
@ -217,7 +186,6 @@ public class AutoUseTaskManager
|
|||||||
player.setTarget(savedTarget);
|
player.setTarget(savedTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Continue when auto play is not enabled.
|
// Continue when auto play is not enabled.
|
||||||
if (!AutoPlayTaskManager.getInstance().isAutoPlay(player))
|
if (!AutoPlayTaskManager.getInstance().isAutoPlay(player))
|
||||||
@ -259,7 +227,7 @@ public class AutoUseTaskManager
|
|||||||
continue SKILLS;
|
continue SKILLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false))
|
if (canUseMagic(skill, player, target))
|
||||||
{
|
{
|
||||||
player.useMagic(skill, null, true, false);
|
player.useMagic(skill, null, true, false);
|
||||||
}
|
}
|
||||||
@ -307,6 +275,38 @@ public class AutoUseTaskManager
|
|||||||
}, 1000, 1000);
|
}, 1000, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean canCastBuff(Skill skill, PlayerInstance player, WorldObject target)
|
||||||
|
{
|
||||||
|
// Summon check.
|
||||||
|
if (skill.getAffectScope() == AffectScope.SUMMON_EXCEPT_MASTER)
|
||||||
|
{
|
||||||
|
if (!player.hasServitors()) // Is this check truly needed?
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int occurrences = 0;
|
||||||
|
for (Summon servitor : player.getServitors().values())
|
||||||
|
{
|
||||||
|
if (servitor.isAffectedBySkill(skill.getId()))
|
||||||
|
{
|
||||||
|
occurrences++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (occurrences == player.getServitors().size())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Use getSkillRemainingReuseTime?
|
||||||
|
return !player.isAffectedBySkill(skill.getId()) && canUseMagic(skill, player, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canUseMagic(Skill skill, PlayerInstance player, WorldObject target)
|
||||||
|
{
|
||||||
|
return !player.hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(player, target, false);
|
||||||
|
}
|
||||||
|
|
||||||
public void startAutoUseTask(PlayerInstance player)
|
public void startAutoUseTask(PlayerInstance player)
|
||||||
{
|
{
|
||||||
if (!PLAYERS.contains(player))
|
if (!PLAYERS.contains(player))
|
||||||
|
Loading…
Reference in New Issue
Block a user