Skip to content

Commit

Permalink
Implement new navigatorparameters settings
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Nov 5, 2015
1 parent 3b295fa commit b14e4ee
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/main/java/net/citizensnpcs/Settings.java
Expand Up @@ -68,6 +68,7 @@ public enum Setting {
DEFAULT_LOOK_CLOSE("npc.default.look-close.enabled", false),
DEFAULT_LOOK_CLOSE_RANGE("npc.default.look-close.range", 5),
DEFAULT_NPC_LIMIT("npc.limits.default-limit", 10),
DEFAULT_PATHFINDER_UPDATE_PATH_RATE("npc.pathfinding.update-path-rate", 20),
DEFAULT_PATHFINDING_RANGE("npc.default.pathfinding.range", 25F),
DEFAULT_RANDOM_TALKER("npc.default.random-talker", true),
DEFAULT_REALISTIC_LOOKING("npc.default.realistic-looking", false),
Expand Down Expand Up @@ -96,10 +97,10 @@ public void loadFromKey(DataKey root) {
NEW_PATHFINDER_OPENS_DOORS("npc.pathfinding.new-finder-open-doors", false),
NPC_ATTACK_DISTANCE("npc.pathfinding.attack-range", 1.75 * 1.75),
NPC_COST("economy.npc.cost", 100D),
NPC_SKIN_USE_LATEST("npc.skins.use-latest", true),
NPC_SKIN_VIEW_DISTANCE("npc.skins.view-distance", 100D),
NPC_SKIN_RETRY_DELAY("npc.skins.retry-delay", 120),
NPC_SKIN_ROTATION_UPDATE_DEGREES("npc.skins.rotation-update-degrees", 90f),
NPC_SKIN_USE_LATEST("npc.skins.use-latest", true),
NPC_SKIN_VIEW_DISTANCE("npc.skins.view-distance", 100D),
PACKET_UPDATE_DELAY("npc.packets.update-delay", 30),
QUICK_SELECT("npc.selection.quick-select", false),
REMOVE_PLAYERS_FROM_PLAYER_LIST("npc.player.remove-from-list", true),
Expand Down
Expand Up @@ -40,6 +40,7 @@ public class CitizensNavigator implements Navigator, Runnable {
.range(Setting.DEFAULT_PATHFINDING_RANGE.asFloat())
.defaultAttackStrategy(MCTargetStrategy.DEFAULT_ATTACK_STRATEGY)
.attackRange(Setting.NPC_ATTACK_DISTANCE.asDouble())
.updatePathRate(Setting.DEFAULT_PATHFINDER_UPDATE_PATH_RATE.asInt())
.stationaryTicks(Setting.DEFAULT_STATIONARY_TICKS.asInt()).stuckAction(TeleportStuckAction.INSTANCE)
.examiner(new MinecraftBlockExaminer()).useNewPathfinder(Setting.USE_NEW_PATHFINDER.asBoolean());
private PathStrategy executing;
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/net/citizensnpcs/npc/ai/MCTargetStrategy.java
Expand Up @@ -118,7 +118,7 @@ public boolean update() {
}
if (!aggro && distanceSquared() < parameters.distanceMargin()) {
stop();
} else if (updateCounter++ > 20) {
} else if (updateCounter++ > parameters.updatePathRate()) {
setPath();
updateCounter = 0;
}
Expand All @@ -130,7 +130,7 @@ public boolean update() {
} else if (strategy != parameters.defaultAttackStrategy()) {
parameters.defaultAttackStrategy().handle((LivingEntity) handle.getBukkitEntity(), getTarget());
}
attackTicks = ATTACK_DELAY_TICKS;
attackTicks = parameters.attackDelayTicks();
}
if (attackTicks > 0) {
attackTicks--;
Expand Down Expand Up @@ -198,7 +198,6 @@ private static interface TargetNavigator {
void stop();
}

private static final int ATTACK_DELAY_TICKS = 20;
static final AttackStrategy DEFAULT_ATTACK_STRATEGY = new AttackStrategy() {
@Override
public boolean handle(LivingEntity attacker, LivingEntity bukkitTarget) {
Expand Down

0 comments on commit b14e4ee

Please sign in to comment.