v0.7.1: adjusted vision logic to account for new huntress subclasses

This commit is contained in:
Evan Debenham 2018-11-28 04:04:20 -05:00
parent a2cf8c576b
commit 42895419a9
7 changed files with 39 additions and 19 deletions

View File

@ -758,6 +758,7 @@ public class Dungeon {
Rankings.INSTANCE.submit( true, cause ); Rankings.INSTANCE.submit( true, cause );
} }
//TODO hero max vision is now separate from shadowcaster max vision. Might want to adjust.
public static void observe(){ public static void observe(){
observe( ShadowCaster.MAX_DISTANCE+1 ); observe( ShadowCaster.MAX_DISTANCE+1 );
} }

View File

@ -53,7 +53,7 @@ public class Light extends FlavourBuff {
@Override @Override
public void detach() { public void detach() {
target.viewDistance = Dungeon.level.viewDistance; target.viewDistance = Dungeon.level.viewDistance;
Dungeon.observe(DISTANCE+1); Dungeon.observe();
super.detach(); super.detach();
} }

View File

@ -48,7 +48,7 @@ public class ShrapnelBomb extends Bomb {
boolean[] FOV = new boolean[Dungeon.level.length()]; boolean[] FOV = new boolean[Dungeon.level.length()];
Point c = Dungeon.level.cellToPoint(cell); 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++) { for (int i = 0; i < FOV.length; i++) {
if (FOV[i]) { if (FOV[i]) {

View File

@ -51,7 +51,7 @@ public class StoneOfClairvoyance extends Runestone {
protected void activate(final int cell) { protected void activate(final int cell) {
boolean[] FOV = new boolean[Dungeon.level.length()]; boolean[] FOV = new boolean[Dungeon.level.length()];
Point c = Dungeon.level.cellToPoint(cell); 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 sX = Math.max(0, c.x - DIST);
int eX = Math.min(Dungeon.level.width()-1, c.x + DIST); int eX = Math.min(Dungeon.level.width()-1, c.x + DIST);

View File

@ -25,7 +25,6 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.ShadowCaster;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.watabou.utils.Random; import com.watabou.utils.Random;
@ -38,6 +37,8 @@ public class DisplacingDart extends TippedDart {
image = ItemSpriteSheet.DISPLACING_DART; image = ItemSpriteSheet.DISPLACING_DART;
} }
int distance = 8;
@Override @Override
public int proc(Char attacker, Char defender, int damage) { 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){ if (positions.get(i) != null){
probs[i] = i - startDist; probs[i] = i - startDist;
} }

View File

@ -40,6 +40,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MindVision;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Shadows; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Shadows;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; 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.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlowParticle; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlowParticle;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.WindParticle; 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 boolean sighted = c.buff( Blindness.class ) == null && c.buff( Shadows.class ) == null
&& c.buff( TimekeepersHourglass.timeStasis.class ) == null && c.isAlive(); && c.buff( TimekeepersHourglass.timeStasis.class ) == null && c.isAlive();
if (sighted) { 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 { } else {
BArray.setFalse(fieldOfView); BArray.setFalse(fieldOfView);
} }
@ -866,6 +883,9 @@ public abstract class Level implements Bundlable {
if (c.buff(MagicalSight.class) != null){ if (c.buff(MagicalSight.class) != null){
sense = 8; sense = 8;
} }
if (((Hero)c).subClass == HeroSubClass.SNIPER){
sense *= 1.5f;
}
} }
//uses rounding //uses rounding

View File

@ -28,7 +28,7 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.BArray;
//based on: http://www.roguebasin.com/index.php?title=FOV_using_recursive_shadowcasting //based on: http://www.roguebasin.com/index.php?title=FOV_using_recursive_shadowcasting
public final class ShadowCaster { 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 //max length of rows as FOV moves out, for each FOV distance
//This is used to make the overall FOV circular, instead of square //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); BArray.setFalse(fieldOfView);
//set source cell to true //set source cell to true
fieldOfView[y * Dungeon.level.width() + x] = true; fieldOfView[y * Dungeon.level.width() + x] = true;
boolean[] losBlocking = Dungeon.level.losBlocking;
//scans octants, clockwise //scans octants, clockwise
try { try {
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, losBlocking, 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, losBlocking, 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, 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, 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, losBlocking, 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, losBlocking, 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, 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);
} catch (Exception e){ } catch (Exception e){
ShatteredPixelDungeon.reportException(e); ShatteredPixelDungeon.reportException(e);
BArray.setFalse(fieldOfView); BArray.setFalse(fieldOfView);