From 83bde8a7816ddbe32f62e1794afdfb4aa35c6d23 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 30 Mar 2019 12:33:01 -0400 Subject: [PATCH] Improved avoidance --- core/src/io/anuke/mindustry/ai/Pathfinder.java | 2 +- core/src/io/anuke/mindustry/entities/type/GroundUnit.java | 4 ++-- core/src/io/anuke/mindustry/entities/type/Unit.java | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/io/anuke/mindustry/ai/Pathfinder.java b/core/src/io/anuke/mindustry/ai/Pathfinder.java index bd162140e5..9121162cfb 100644 --- a/core/src/io/anuke/mindustry/ai/Pathfinder.java +++ b/core/src/io/anuke/mindustry/ai/Pathfinder.java @@ -65,7 +65,7 @@ public class Pathfinder{ Tile other = world.tile(dx, dy); if(other == null) continue; - if(values[dx][dy] < value && (target == null || values[dx][dy] < tl) && + if(values[dx][dy] < value && (target == null || values[dx][dy]< tl) && !other.solid() && !(point.x != 0 && point.y != 0 && (world.solid(tile.x + point.x, tile.y) || world.solid(tile.x, tile.y + point.y)))){ //diagonal corner trap target = other; diff --git a/core/src/io/anuke/mindustry/entities/type/GroundUnit.java b/core/src/io/anuke/mindustry/entities/type/GroundUnit.java index f7dc634a44..79318f4b4f 100644 --- a/core/src/io/anuke/mindustry/entities/type/GroundUnit.java +++ b/core/src/io/anuke/mindustry/entities/type/GroundUnit.java @@ -215,7 +215,7 @@ public abstract class GroundUnit extends BaseUnit{ velocity.add(vec.trns(angleTo(targetTile), type.speed*Time.delta())); if(Units.invalidateTarget(target, this)){ - rotation = Mathf.slerpDelta(rotation, angle, type.rotatespeed); + rotation = Mathf.slerpDelta(rotation, baseRotation, type.rotatespeed); } } @@ -240,6 +240,6 @@ public abstract class GroundUnit extends BaseUnit{ float angle = angleTo(targetTile); velocity.add(vec.trns(angleTo(targetTile), type.speed*Time.delta())); - rotation = Mathf.slerpDelta(rotation, angle, type.rotatespeed); + rotation = Mathf.slerpDelta(rotation, baseRotation, type.rotatespeed); } } diff --git a/core/src/io/anuke/mindustry/entities/type/Unit.java b/core/src/io/anuke/mindustry/entities/type/Unit.java index cfbe040678..e9b48b1b00 100644 --- a/core/src/io/anuke/mindustry/entities/type/Unit.java +++ b/core/src/io/anuke/mindustry/entities/type/Unit.java @@ -245,15 +245,15 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ for(int cy = -rad; cy <= rad; cy++){ Tile tile = world.tileWorld(x + cx*tilesize, y + cy*tilesize); if(tile == null) continue; - float scl = (rad - Mathf.dst(tile.worldx(), tile.worldy(), x, y)/(8f * 1.2f * Mathf.sqrt2)) * 0.08f; + float scl = (rad - Mathf.dst(tile.worldx(), tile.worldy(), x, y)/(8f * 1.2f * Mathf.sqrt2)) * 0.1f; moveVector.add(Mathf.sign(x - tile.worldx()) * scaling * tile.weight * scl, Mathf.sign(y - tile.worldy()) * scaling * tile.weight * scl); } } - //moveVector.limit(0.2f); + moveVector.limit(0.2f); - move(moveVector.x, moveVector.y); + applyImpulse(moveVector.x, moveVector.y); Tile tile = world.tileWorld(x, y);