Extract attack range to a setting

This commit is contained in:
fullwall 2013-05-18 13:19:33 +08:00
parent 005ed48216
commit a47e05728a
2 changed files with 3 additions and 2 deletions

View File

@ -91,6 +91,7 @@ public class Settings {
MAX_NPC_LIMIT_CHECKS("npc.limits.max-permission-checks", 100),
MAX_SPEED("npc.limits.max-speed", 100),
MESSAGE_COLOUR("general.color-scheme.message", "<a>"),
NPC_ATTACK_DISTANCE("npc.pathfinding.attack-range", 1.75 * 1.75),
NPC_COST("economy.npc.cost", 100D),
QUICK_SELECT("npc.selection.quick-select", false),
REMOVE_PLAYERS_FROM_PLAYER_LIST("npc.player.remove-from-list", true),

View File

@ -2,6 +2,7 @@ package net.citizensnpcs.npc.ai;
import java.lang.reflect.Field;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.ai.AttackStrategy;
import net.citizensnpcs.api.ai.EntityTarget;
import net.citizensnpcs.api.ai.NavigatorParameters;
@ -43,7 +44,7 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
private boolean canAttack() {
return attackTicks == 0
&& (handle.boundingBox.e > target.boundingBox.b && handle.boundingBox.b < target.boundingBox.e)
&& distanceSquared() <= ATTACK_DISTANCE && hasLineOfSight();
&& distanceSquared() <= Setting.NPC_ATTACK_DISTANCE.asDouble() && hasLineOfSight();
}
@Override
@ -157,7 +158,6 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
}
private static final int ATTACK_DELAY_TICKS = 20;
private static final double ATTACK_DISTANCE = 1.75 * 1.75;
private static final Location HANDLE_LOCATION = new Location(null, 0, 0, 0);
private static Field NAV_E, NAV_J, NAV_M;