mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-09-26 06:13:09 +02:00
Extract attack range to a setting
This commit is contained in:
parent
005ed48216
commit
a47e05728a
@ -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),
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user