Range checks for skill casting.

Contributed by Liamxroy.
This commit is contained in:
MobiusDev
2017-09-27 00:15:33 +00:00
parent 2708997611
commit 3cb7b3f70e
8 changed files with 80 additions and 0 deletions

View File

@@ -56,6 +56,7 @@ import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.SkillCaster;
import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.util.Util;
/**
* This class manages AI of L2Attackable.
@@ -926,6 +927,11 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
return false;
}
if (!Util.checkIfInRange(skill.getCastRange(), getActiveChar(), target, true))
{
return false;
}
if (target.isCharacter())
{
// Skip if target is already affected by such skill.

View File

@@ -164,6 +164,11 @@ public class SkillCaster implements Runnable
return null;
}
if (!Util.checkIfInRange(skill.getCastRange(), caster, target, true))
{
return null;
}
castTime = castTime > -1 ? castTime : Formulas.calcHitTime(caster, skill);
// Schedule a thread that will execute 500ms before casting time is over (for animation issues and retail handling).
@@ -359,6 +364,15 @@ public class SkillCaster implements Runnable
return false;
}
if (!Util.checkIfInRange(_skill.getEffectRange(), caster, target, true))
{
if (caster.isPlayer())
{
caster.sendPacket(SystemMessageId.THE_DISTANCE_IS_TOO_FAR_AND_SO_THE_CASTING_HAS_BEEN_STOPPED);
}
return false;
}
// Gather list of affected targets by this skill.
_targets = _skill.getTargetsAffected(caster, target);