diff --git a/core/src/com/riiablo/ai/QuillRat.java b/core/src/com/riiablo/ai/QuillRat.java index c6ba1a74..f8d4f676 100644 --- a/core/src/com/riiablo/ai/QuillRat.java +++ b/core/src/com/riiablo/ai/QuillRat.java @@ -11,6 +11,7 @@ import com.riiablo.entity.Entity; import com.riiablo.entity.Missile; import com.riiablo.entity.Monster; import com.riiablo.entity.Player; +import com.riiablo.util.EngineUtils; public class QuillRat extends AI { enum State implements com.badlogic.gdx.ai.fsm.State { @@ -79,6 +80,7 @@ public class QuillRat extends AI { Missile miss = new Missile(missile); miss.position().set(entity.position()); + EngineUtils.worldToScreenCoords(miss.position(), miss.screen()); miss.lookAt(ent); // TODO: should be able to set angle to firing entity angle later Riiablo.engine.add(miss); return; diff --git a/core/src/com/riiablo/entity/Entity.java b/core/src/com/riiablo/entity/Entity.java index e51ab720..69f5aa86 100644 --- a/core/src/com/riiablo/entity/Entity.java +++ b/core/src/com/riiablo/entity/Entity.java @@ -565,6 +565,10 @@ public abstract class Entity implements Animation.AnimationListener { return position; } + public Vector2 screen() { + return screen; + } + public boolean contains(Vector2 coords) { if (animation == null) return false; if (!isSelectable()) return false; diff --git a/core/src/com/riiablo/entity/Missile.java b/core/src/com/riiablo/entity/Missile.java index bbf98805..0dfbee27 100644 --- a/core/src/com/riiablo/entity/Missile.java +++ b/core/src/com/riiablo/entity/Missile.java @@ -12,6 +12,7 @@ import com.riiablo.codec.excel.Missiles; import com.riiablo.graphics.BlendMode; import com.riiablo.graphics.PaletteIndexedBatch; import com.riiablo.map.DT1.Tile; +import com.riiablo.util.EngineUtils; public class Missile extends Entity { public final Missiles.Entry missile; @@ -54,8 +55,7 @@ public class Missile extends Entity { //position.add(tmpVec2); radius *= Tile.SUBTILE_WIDTH; // workaround to get approx speed - tmpVec2.x = +(position.x * Tile.SUBTILE_WIDTH50) - (position.y * Tile.SUBTILE_WIDTH50); - tmpVec2.y = -(position.x * Tile.SUBTILE_HEIGHT50) - (position.y * Tile.SUBTILE_HEIGHT50); + EngineUtils.worldToScreenCoords(position, tmpVec2); tmpVec2.x += radius * MathUtils.cos(angle); tmpVec2.y += radius * MathUtils.sin(angle);