diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java index e1075d7ed..584976f39 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java @@ -758,6 +758,7 @@ public class Dungeon { Rankings.INSTANCE.submit( true, cause ); } + //TODO hero max vision is now separate from shadowcaster max vision. Might want to adjust. public static void observe(){ observe( ShadowCaster.MAX_DISTANCE+1 ); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Light.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Light.java index 02b3db6b3..991f5960c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Light.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Light.java @@ -53,7 +53,7 @@ public class Light extends FlavourBuff { @Override public void detach() { target.viewDistance = Dungeon.level.viewDistance; - Dungeon.observe(DISTANCE+1); + Dungeon.observe(); super.detach(); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bombs/ShrapnelBomb.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bombs/ShrapnelBomb.java index bcea9dba4..23a0db9d3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bombs/ShrapnelBomb.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bombs/ShrapnelBomb.java @@ -48,7 +48,7 @@ public class ShrapnelBomb extends Bomb { boolean[] FOV = new boolean[Dungeon.level.length()]; Point c = Dungeon.level.cellToPoint(cell); - ShadowCaster.castShadow(c.x, c.y, FOV, 8); + ShadowCaster.castShadow(c.x, c.y, FOV, Dungeon.level.losBlocking, 8); for (int i = 0; i < FOV.length; i++) { if (FOV[i]) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/stones/StoneOfClairvoyance.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/stones/StoneOfClairvoyance.java index f3f650a71..51af3055e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/stones/StoneOfClairvoyance.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/stones/StoneOfClairvoyance.java @@ -51,7 +51,7 @@ public class StoneOfClairvoyance extends Runestone { protected void activate(final int cell) { boolean[] FOV = new boolean[Dungeon.level.length()]; Point c = Dungeon.level.cellToPoint(cell); - ShadowCaster.castShadow(c.x, c.y, FOV, DIST); + ShadowCaster.castShadow(c.x, c.y, FOV, Dungeon.level.losBlocking, DIST); int sX = Math.max(0, c.x - DIST); int eX = Math.min(Dungeon.level.width()-1, c.x + DIST); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/DisplacingDart.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/DisplacingDart.java index 3207bdf0e..a2a05e0ee 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/DisplacingDart.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/DisplacingDart.java @@ -25,7 +25,6 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; -import com.shatteredpixel.shatteredpixeldungeon.mechanics.ShadowCaster; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.watabou.utils.Random; @@ -38,6 +37,8 @@ public class DisplacingDart extends TippedDart { image = ItemSpriteSheet.DISPLACING_DART; } + int distance = 8; + @Override public int proc(Char attacker, Char defender, int damage) { @@ -63,9 +64,9 @@ public class DisplacingDart extends TippedDart { } } - float[] probs = new float[ShadowCaster.MAX_DISTANCE+1]; + float[] probs = new float[distance+1]; - for (int i = 0; i <= ShadowCaster.MAX_DISTANCE; i++){ + for (int i = 0; i <= distance; i++){ if (positions.get(i) != null){ probs[i] = i - startDist; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java index 955e18235..209d5349e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -40,6 +40,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MindVision; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Shadows; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlowParticle; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.WindParticle; @@ -852,7 +853,23 @@ public abstract class Level implements Bundlable { boolean sighted = c.buff( Blindness.class ) == null && c.buff( Shadows.class ) == null && c.buff( TimekeepersHourglass.timeStasis.class ) == null && c.isAlive(); if (sighted) { - ShadowCaster.castShadow( cx, cy, fieldOfView, c.viewDistance ); + boolean[] blocking; + + if (c instanceof Hero && ((Hero) c).subClass == HeroSubClass.WARDEN) { + blocking = Dungeon.level.losBlocking.clone(); + for (int i = 0; i < blocking.length; i++){ + if (blocking[i] && (Dungeon.level.map[i] == Terrain.HIGH_GRASS || Dungeon.level.map[i] == Terrain.FURROWED_GRASS)){ + blocking[i] = false; + } + } + } else { + blocking = Dungeon.level.losBlocking; + } + + int viewDist = c.viewDistance; + if (c instanceof Hero && ((Hero) c).subClass == HeroSubClass.SNIPER) viewDist *= 1.5f; + + ShadowCaster.castShadow( cx, cy, fieldOfView, blocking, viewDist ); } else { BArray.setFalse(fieldOfView); } @@ -866,6 +883,9 @@ public abstract class Level implements Bundlable { if (c.buff(MagicalSight.class) != null){ sense = 8; } + if (((Hero)c).subClass == HeroSubClass.SNIPER){ + sense *= 1.5f; + } } //uses rounding diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ShadowCaster.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ShadowCaster.java index a3a741bc5..20cfd2bf8 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ShadowCaster.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ShadowCaster.java @@ -28,7 +28,7 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.BArray; //based on: http://www.roguebasin.com/index.php?title=FOV_using_recursive_shadowcasting public final class ShadowCaster { - public static final int MAX_DISTANCE = 8; + public static final int MAX_DISTANCE = 12; //max length of rows as FOV moves out, for each FOV distance //This is used to make the overall FOV circular, instead of square @@ -46,25 +46,23 @@ public final class ShadowCaster { } } - public static void castShadow( int x, int y, boolean[] fieldOfView, int distance ) { + public static void castShadow( int x, int y, boolean[] fieldOfView, boolean[] blocking, int distance ) { BArray.setFalse(fieldOfView); //set source cell to true fieldOfView[y * Dungeon.level.width() + x] = true; - - boolean[] losBlocking = Dungeon.level.losBlocking; //scans octants, clockwise try { - scanOctant(distance, fieldOfView, losBlocking, 1, x, y, 0.0, 1.0, +1, -1, false); - scanOctant(distance, fieldOfView, losBlocking, 1, x, y, 0.0, 1.0, -1, +1, true); - scanOctant(distance, fieldOfView, losBlocking, 1, x, y, 0.0, 1.0, +1, +1, true); - scanOctant(distance, fieldOfView, losBlocking, 1, x, y, 0.0, 1.0, +1, +1, false); - scanOctant(distance, fieldOfView, losBlocking, 1, x, y, 0.0, 1.0, -1, +1, false); - scanOctant(distance, fieldOfView, losBlocking, 1, x, y, 0.0, 1.0, +1, -1, true); - scanOctant(distance, fieldOfView, losBlocking, 1, x, y, 0.0, 1.0, -1, -1, true); - scanOctant(distance, fieldOfView, losBlocking, 1, x, y, 0.0, 1.0, -1, -1, false); + scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, +1, -1, false); + scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, -1, +1, true); + scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, +1, +1, true); + scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, +1, +1, false); + scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, -1, +1, false); + scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, +1, -1, true); + scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, -1, -1, true); + scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, -1, -1, false); } catch (Exception e){ ShatteredPixelDungeon.reportException(e); BArray.setFalse(fieldOfView);