From 3cb7b3f70e3481c88868972a1861276e61844587 Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Wed, 27 Sep 2017 00:15:33 +0000 Subject: [PATCH] Range checks for skill casting. Contributed by Liamxroy. --- .../l2jmobius/gameserver/ai/L2AttackableAI.java | 6 ++++++ .../gameserver/model/skills/SkillCaster.java | 14 ++++++++++++++ .../l2jmobius/gameserver/ai/L2AttackableAI.java | 6 ++++++ .../gameserver/model/skills/SkillCaster.java | 14 ++++++++++++++ .../l2jmobius/gameserver/ai/L2AttackableAI.java | 6 ++++++ .../gameserver/model/skills/SkillCaster.java | 14 ++++++++++++++ .../l2jmobius/gameserver/ai/L2AttackableAI.java | 6 ++++++ .../gameserver/model/skills/SkillCaster.java | 14 ++++++++++++++ 8 files changed, 80 insertions(+) diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/ai/L2AttackableAI.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/ai/L2AttackableAI.java index dd74edd00d..28f68acde3 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/ai/L2AttackableAI.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/ai/L2AttackableAI.java @@ -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. diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/skills/SkillCaster.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/skills/SkillCaster.java index 9c70018363..680e67b8b0 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/skills/SkillCaster.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/skills/SkillCaster.java @@ -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); diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/ai/L2AttackableAI.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/ai/L2AttackableAI.java index dd74edd00d..28f68acde3 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/ai/L2AttackableAI.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/ai/L2AttackableAI.java @@ -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. diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/skills/SkillCaster.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/skills/SkillCaster.java index 9c70018363..680e67b8b0 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/skills/SkillCaster.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/skills/SkillCaster.java @@ -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); diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/ai/L2AttackableAI.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/ai/L2AttackableAI.java index dd74edd00d..28f68acde3 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/ai/L2AttackableAI.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/ai/L2AttackableAI.java @@ -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. diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/skills/SkillCaster.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/skills/SkillCaster.java index 9c70018363..680e67b8b0 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/skills/SkillCaster.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/skills/SkillCaster.java @@ -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); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/ai/L2AttackableAI.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/ai/L2AttackableAI.java index dd74edd00d..28f68acde3 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/ai/L2AttackableAI.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/ai/L2AttackableAI.java @@ -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. diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/skills/SkillCaster.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/skills/SkillCaster.java index 9c70018363..680e67b8b0 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/skills/SkillCaster.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/skills/SkillCaster.java @@ -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);