Fix rotated side
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
dcfe141beb
Commit
f130af5465
FightSystem_Core/src/de/steamwar/fightsystem
@ -151,12 +151,12 @@ public abstract class AI {
|
|||||||
|
|
||||||
public Material getBlock(Vector pos) {
|
public Material getBlock(Vector pos) {
|
||||||
queue.add(new Action(1));
|
queue.add(new Action(1));
|
||||||
return translate(pos, true).getBlock().getType();
|
return translate(pos).getBlock().getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockData getBlockData(Vector pos) {
|
public BlockData getBlockData(Vector pos) {
|
||||||
queue.add(new Action(1));
|
queue.add(new Action(1));
|
||||||
return translate(pos, true).getBlock().getBlockData();
|
return translate(pos).getBlock().getBlockData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTNT(Vector pos) {
|
public void setTNT(Vector pos) {
|
||||||
@ -166,7 +166,7 @@ public abstract class AI {
|
|||||||
if(FightState.getFightState() != FightState.RUNNING)
|
if(FightState.getFightState() != FightState.RUNNING)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Location location = translate(pos, true);
|
Location location = translate(pos);
|
||||||
if(interactionDistanceViolation(location)) {
|
if(interactionDistanceViolation(location)) {
|
||||||
chat("InteractionDistanceViolation: setTNT");
|
chat("InteractionDistanceViolation: setTNT");
|
||||||
return;
|
return;
|
||||||
@ -183,7 +183,7 @@ public abstract class AI {
|
|||||||
queue.add(new Action(1) {
|
queue.add(new Action(1) {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Location location = translate(pos, true);
|
Location location = translate(pos);
|
||||||
if(interactionDistanceViolation(location)) {
|
if(interactionDistanceViolation(location)) {
|
||||||
chat("InteractionDistanceViolation: interact");
|
chat("InteractionDistanceViolation: interact");
|
||||||
return;
|
return;
|
||||||
@ -198,7 +198,7 @@ public abstract class AI {
|
|||||||
queue.add(new Action(1) {
|
queue.add(new Action(1) {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Location location = translate(pos, true);
|
Location location = translate(pos);
|
||||||
if (interactionDistanceViolation(location))
|
if (interactionDistanceViolation(location))
|
||||||
return;
|
return;
|
||||||
Block block = location.getBlock();
|
Block block = location.getBlock();
|
||||||
@ -225,7 +225,7 @@ public abstract class AI {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location target = translate(pos, false);
|
Location target = translate(pos);
|
||||||
if(Math.abs(location.getX() - target.getX()) > 1.0 || Math.abs(location.getY() - target.getY()) > 1.5 || Math.abs(location.getZ() - target.getZ()) > 1.0) {
|
if(Math.abs(location.getX() - target.getX()) > 1.0 || Math.abs(location.getY() - target.getY()) > 1.5 || Math.abs(location.getZ() - target.getZ()) > 1.0) {
|
||||||
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> entity.getName() + ": Overdistance movement " + location.toVector() + " " + target.toVector());
|
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> entity.getName() + ": Overdistance movement " + location.toVector() + " " + target.toVector());
|
||||||
return;
|
return;
|
||||||
@ -315,7 +315,7 @@ public abstract class AI {
|
|||||||
queue.poll().run();
|
queue.poll().run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location translate(Vector pos, boolean blockPos) {
|
public Location translate(Vector pos) {
|
||||||
Region extend = team.getExtendRegion();
|
Region extend = team.getExtendRegion();
|
||||||
if(Fight.getUnrotated() == team)
|
if(Fight.getUnrotated() == team)
|
||||||
return new Location(
|
return new Location(
|
||||||
@ -327,9 +327,9 @@ public abstract class AI {
|
|||||||
else
|
else
|
||||||
return new Location(
|
return new Location(
|
||||||
Config.world,
|
Config.world,
|
||||||
extend.getMaxX() - pos.getX() - (blockPos ? 1 : 0),
|
extend.getMaxX() - pos.getX(),
|
||||||
pos.getY() + team.getSchemRegion().getMinY(),
|
pos.getY() + team.getSchemRegion().getMinY(),
|
||||||
extend.getMaxZ() - pos.getZ() - (blockPos ? 1 : 0)
|
extend.getMaxZ() - pos.getZ()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,8 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
public class LixfelAI extends AI {
|
public class LixfelAI extends AI {
|
||||||
|
|
||||||
|
private static final Vector CENTER_BLOCK = new Vector(0.5, 0.5, 0.5);
|
||||||
|
|
||||||
private final Random random = new Random();
|
private final Random random = new Random();
|
||||||
|
|
||||||
private List<Supplier<PlanResult>> plans = new ArrayList<>();
|
private List<Supplier<PlanResult>> plans = new ArrayList<>();
|
||||||
@ -47,7 +49,8 @@ public class LixfelAI extends AI {
|
|||||||
|
|
||||||
public LixfelAI(FightTeam team) {
|
public LixfelAI(FightTeam team) {
|
||||||
super(team, SteamwarUser.get("Lixfel.AI"));
|
super(team, SteamwarUser.get("Lixfel.AI"));
|
||||||
//getEntity().setGlowing(true);
|
getEntity().setGlowing(true);
|
||||||
|
//TODO AI Replay
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -66,15 +69,15 @@ public class LixfelAI extends AI {
|
|||||||
plans.add(movementEmergency);
|
plans.add(movementEmergency);
|
||||||
plans.add(new ReadyPlan());
|
plans.add(new ReadyPlan());
|
||||||
|
|
||||||
plans.add(new TimedInteraction(200.0, -1, new Vector(25, 15, 25)));
|
plans.add(new TimedInteraction(200.0, -1, new Vector(25.5, 15.5, 25.5)));
|
||||||
plans.add(new TimedInteraction(210.0, 420, new Vector(21, 15, 24)));
|
plans.add(new TimedInteraction(210.0, 420, new Vector(21.5, 15.5, 24.5)));
|
||||||
|
|
||||||
List<Cannon> cannons = new ArrayList<>(Arrays.asList(
|
List<Cannon> cannons = new ArrayList<>(Arrays.asList(
|
||||||
new Cannon(new Vector(11,25,11), 10,23,14, 12,23,14, 10,23,12, 12,23,12, 12,24,15, 10,24,14, 12,23,15, 12,24,14, 11,24,12, 10,24,15, 12,24,12, 10,23,15, 10,24,12),
|
new Cannon(new Vector(11.5,25.5,11.5), 10,23,14, 12,23,14, 10,23,12, 12,23,12, 12,24,15, 10,24,14, 12,23,15, 12,24,14, 11,24,12, 10,24,15, 12,24,12, 10,23,15, 10,24,12),
|
||||||
new Cannon(new Vector(39,25,11), 38,24,15, 38,23,12, 40,23,14, 40,24,12, 40,23,15, 40,24,14, 39,24,12, 38,23,14, 40,24,15, 40,23,12, 38,23,15, 38,24,12, 38,24,14),
|
new Cannon(new Vector(39.5,25.5,11.5), 38,24,15, 38,23,12, 40,23,14, 40,24,12, 40,23,15, 40,24,14, 39,24,12, 38,23,14, 40,24,15, 40,23,12, 38,23,15, 38,24,12, 38,24,14),
|
||||||
new Cannon(new Vector(12,18,11), 13,17,15, 13,17,16, 13,18,16, 13,18,14, 14,18,14, 14,17,15, 14,17,16, 14,18,16, 13,17,14, 14,17,14, 13,18,15, 14,18,15),
|
new Cannon(new Vector(12.5,18.5,11.5), 13,17,15, 13,17,16, 13,18,16, 13,18,14, 14,18,14, 14,17,15, 14,17,16, 14,18,16, 13,17,14, 14,17,14, 13,18,15, 14,18,15),
|
||||||
new Cannon(new Vector(38,18,11), 37,18,14, 36,18,14, 36,17,15, 37,17,15, 37,18,15, 36,18,15, 36,17,14, 37,17,14, 36,17,16, 37,17,16, 36,18,16, 37,18,16),
|
new Cannon(new Vector(38.5,18.5,11.5), 37,18,14, 36,18,14, 36,17,15, 37,17,15, 37,18,15, 36,18,15, 36,17,14, 37,17,14, 36,17,16, 37,17,16, 36,18,16, 37,18,16),
|
||||||
new Cannon(new Vector(9,9,16), 10,11,17, 10,8,19, 10,8,17, 11,8,19, 11,8,15, 10,8,15, 12,8,15, 10,10,15, 12,7,19, 11,10,15, 12,8,19, 12,7,15, 11,7,15, 10,9,17, 11,9,19, 12,9,19, 10,9,19, 10,7,17, 11,7,19, 10,7,15, 10,7,19, 10,10,17, 12,9,15, 10,9,15, 11,9,15, 12,10,19, 11,10,19, 12,10,15, 10,6,17, 10,10,19),
|
new Cannon(new Vector(9.5,9.5,16.5), 10,11,17, 10,8,19, 10,8,17, 11,8,19, 11,8,15, 10,8,15, 12,8,15, 10,10,15, 12,7,19, 11,10,15, 12,8,19, 12,7,15, 11,7,15, 10,9,17, 11,9,19, 12,9,19, 10,9,19, 10,7,17, 11,7,19, 10,7,15, 10,7,19, 10,10,17, 12,9,15, 10,9,15, 11,9,15, 12,10,19, 11,10,19, 12,10,15, 10,6,17, 10,10,19),
|
||||||
new Cannon(null, 23,5,9, 23,6,9, 23,7,9, 23,8,9),
|
new Cannon(null, 23,5,9, 23,6,9, 23,7,9, 23,8,9),
|
||||||
new Cannon(null, 27,5,9, 27,6,9, 27,7,9, 27,8,9)
|
new Cannon(null, 27,5,9, 27,6,9, 27,7,9, 27,8,9)
|
||||||
));
|
));
|
||||||
@ -103,7 +106,7 @@ public class LixfelAI extends AI {
|
|||||||
});
|
});
|
||||||
|
|
||||||
for(Vector water : waterSources) {
|
for(Vector water : waterSources) {
|
||||||
cannons.stream().filter(cannon -> cannon.getTNTMinY() >= water.getBlockY()).min(Comparator.comparingDouble(c -> c.waterDistance(water))).ifPresent(cannon -> cannon.addWater(water));
|
cannons.stream().filter(cannon -> cannon.getTNTMinY() >= water.getBlockY()).min(Comparator.comparingDouble(c -> c.waterDistance(water))).ifPresent(cannon -> cannon.addWater(water.add(CENTER_BLOCK)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +187,7 @@ public class LixfelAI extends AI {
|
|||||||
this.activator = activator;
|
this.activator = activator;
|
||||||
|
|
||||||
for(int i = 0; i < tntpos.length; i+=3) {
|
for(int i = 0; i < tntpos.length; i+=3) {
|
||||||
tnt.put(new Vector(tntpos[i], tntpos[i+1], tntpos[i+2]), false);
|
tnt.put(new Vector(tntpos[i], tntpos[i+1], tntpos[i+2]).add(CENTER_BLOCK), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
minY = tnt.keySet().stream().min(Comparator.comparingInt(Vector::getBlockY)).orElse(new Vector()).getBlockY();
|
minY = tnt.keySet().stream().min(Comparator.comparingInt(Vector::getBlockY)).orElse(new Vector()).getBlockY();
|
||||||
|
@ -38,6 +38,8 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class LixfelPathplanner {
|
public class LixfelPathplanner {
|
||||||
|
|
||||||
|
private static final double INTERACTION_RANGE = AI.INTERACTION_RANGE - 0.05;
|
||||||
|
|
||||||
private static double blockHeight(Clipboard clipboard, BlockVector3 vector) {
|
private static double blockHeight(Clipboard clipboard, BlockVector3 vector) {
|
||||||
BlockData data = BukkitAdapter.adapt(clipboard.getFullBlock(vector));
|
BlockData data = BukkitAdapter.adapt(clipboard.getFullBlock(vector));
|
||||||
Material material = data.getMaterial();
|
Material material = data.getMaterial();
|
||||||
@ -81,7 +83,7 @@ public class LixfelPathplanner {
|
|||||||
private final AI ai;
|
private final AI ai;
|
||||||
private final BlockVector3 diff;
|
private final BlockVector3 diff;
|
||||||
private final Set<Vector> ladders = new HashSet<>();
|
private final Set<Vector> ladders = new HashSet<>();
|
||||||
private final Map<Vector, Vector[]> neighbours = new HashMap<>();
|
private final Map<Vector, List<Vector>> neighbours = new HashMap<>();
|
||||||
|
|
||||||
public LixfelPathplanner(AI ai, Clipboard clipboard) {
|
public LixfelPathplanner(AI ai, Clipboard clipboard) {
|
||||||
this.ai = ai;
|
this.ai = ai;
|
||||||
@ -121,7 +123,7 @@ public class LixfelPathplanner {
|
|||||||
});
|
});
|
||||||
|
|
||||||
for(Vector vector : walkable) {
|
for(Vector vector : walkable) {
|
||||||
neighbours.put(vector, walkable.stream().filter(neighbour -> neighbouring(neighbour, vector)).filter(neighbour -> neighbour != vector).toArray(Vector[]::new));
|
neighbours.put(vector, walkable.stream().filter(neighbour -> neighbouring(neighbour, vector)).filter(neighbour -> neighbour != vector).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,34 +136,27 @@ public class LixfelPathplanner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addPosition(Vector vector) {
|
public void addPosition(Vector vector) {
|
||||||
Vector[] n = neighbours.keySet().stream().filter(neighbour -> neighbouring(neighbour, vector)).toArray(Vector[]::new);
|
List<Vector> n = neighbours.keySet().stream().filter(neighbour -> neighbouring(neighbour, vector)).collect(Collectors.toList());
|
||||||
neighbours.put(vector, n);
|
neighbours.put(vector, n);
|
||||||
|
|
||||||
for(Vector neighbour : n) {
|
for(Vector neighbour : n) {
|
||||||
neighbours.computeIfPresent(neighbour, (neighBour, array) -> {
|
neighbours.computeIfPresent(neighbour, (neighBour, list) -> {
|
||||||
array = Arrays.copyOf(array, array.length+1);
|
list.add(vector);
|
||||||
array[array.length-1] = vector;
|
return list;
|
||||||
return array;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePosition(Vector vector) {
|
public void removePosition(Vector vector) {
|
||||||
ladders.remove(vector);
|
ladders.remove(vector);
|
||||||
Vector[] n = neighbours.remove(vector);
|
List<Vector> n = neighbours.remove(vector);
|
||||||
if(n == null)
|
if(n == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(Vector neighbour : n) {
|
for(Vector neighbour : n) {
|
||||||
neighbours.computeIfPresent(neighbour, (neighBour, array) -> {
|
neighbours.computeIfPresent(neighbour, (neighBour, list) -> {
|
||||||
for(int i = 0; i < array.length; i++) {
|
list.remove(vector);
|
||||||
if(array[i] == vector) {
|
return list;
|
||||||
Vector[] newArray = Arrays.copyOf(array, array.length-1);
|
|
||||||
System.arraycopy(array, i+1, newArray, i, newArray.length-i);
|
|
||||||
return newArray;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new IllegalStateException();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,11 +168,11 @@ public class LixfelPathplanner {
|
|||||||
public PlanResult inRangeAndTime(double rating, int time, Vector target, Supplier<PlanResult> plan) {
|
public PlanResult inRangeAndTime(double rating, int time, Vector target, Supplier<PlanResult> plan) {
|
||||||
Vector position = ai.getPosition();
|
Vector position = ai.getPosition();
|
||||||
double eyeHeight = ai.getEntity().getEyeHeight();
|
double eyeHeight = ai.getEntity().getEyeHeight();
|
||||||
boolean inRange = new Vector(0, eyeHeight, 0).add(position).distance(target) <= AI.INTERACTION_RANGE;
|
boolean inRange = new Vector(0, eyeHeight, 0).add(position).distance(target) <= INTERACTION_RANGE;
|
||||||
if(inRange)
|
if(inRange)
|
||||||
return time <= 0 ? plan.get() : PlanResult.EMPTY;
|
return time <= 0 ? plan.get() : PlanResult.EMPTY;
|
||||||
|
|
||||||
List<Vector> path = new ArrayList<>(planToRange(position, new Vector(0, -eyeHeight, 0).add(target), 5.0));
|
List<Vector> path = new ArrayList<>(planToRange(position, new Vector(0, -eyeHeight, 0).add(target), INTERACTION_RANGE));
|
||||||
if(path.isEmpty() || time > path.size()*AI.MOVEMENT_DELAY)
|
if(path.isEmpty() || time > path.size()*AI.MOVEMENT_DELAY)
|
||||||
return PlanResult.EMPTY;
|
return PlanResult.EMPTY;
|
||||||
|
|
||||||
@ -211,7 +206,7 @@ public class LixfelPathplanner {
|
|||||||
while(!checking.isEmpty()) {
|
while(!checking.isEmpty()) {
|
||||||
Set<Vector> toCheck = new HashSet<>();
|
Set<Vector> toCheck = new HashSet<>();
|
||||||
for(Vector current : checking) {
|
for(Vector current : checking) {
|
||||||
Vector firstStep = Arrays.stream(neighbours.get(current))
|
Vector firstStep = neighbours.get(current).stream()
|
||||||
.filter(vector -> !approach.containsKey(vector))
|
.filter(vector -> !approach.containsKey(vector))
|
||||||
.filter(next -> {
|
.filter(next -> {
|
||||||
approach.put(next, current);
|
approach.put(next, current);
|
||||||
|
@ -36,7 +36,6 @@ public class KitCommand implements CommandExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
AI.printPos();
|
|
||||||
if(!(sender instanceof Player)) {
|
if(!(sender instanceof Player)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren