diff --git a/SPD-classes/src/main/java/com/watabou/utils/Random.java b/SPD-classes/src/main/java/com/watabou/utils/Random.java index 773f053e4..d3478d5b2 100644 --- a/SPD-classes/src/main/java/com/watabou/utils/Random.java +++ b/SPD-classes/src/main/java/com/watabou/utils/Random.java @@ -52,6 +52,11 @@ public class Random { public static float Float( float min, float max ) { return min + Float(max - min); } + + //returns a triangularly distributed float in the range [min, max) + public static float NormalFloat( float min, float max ) { + return min + ((Float(max - min) + Float(max - min))/2f); + } //returns a uniformly distributed int in the range [0, max) public static int Int( int max ) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Bleeding.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Bleeding.java index 0ccf195e5..a0f95aec6 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Bleeding.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Bleeding.java @@ -28,7 +28,8 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.watabou.utils.Bundle; import com.watabou.utils.PointF; -import com.watabou.utils.Random; + +import static com.watabou.utils.Random.NormalFloat; public class Bleeding extends Buff { @@ -37,7 +38,7 @@ public class Bleeding extends Buff { announced = true; } - protected int level; + protected float level; private static final String LEVEL = "level"; @@ -51,7 +52,7 @@ public class Bleeding extends Buff { @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - level = bundle.getInt( LEVEL ); + level = bundle.getFloat( LEVEL ); } public void set( int level ) { @@ -72,12 +73,15 @@ public class Bleeding extends Buff { public boolean act() { if (target.isAlive()) { - if ((level = Random.NormalIntRange( level / 2, level )) > 0) { + level = NormalFloat(level / 2f, level); + int dmg = Math.round(level); + + if (dmg > 0) { - target.damage( level, this ); + target.damage( dmg, this ); if (target.sprite.visible) { Splash.at( target.sprite.center(), -PointF.PI / 2, PointF.PI / 6, - target.sprite.blood(), Math.min( 10 * level / target.HT, 10 ) ); + target.sprite.blood(), Math.min( 10 * dmg / target.HT, 10 ) ); } if (target == Dungeon.hero && !target.isAlive()) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Ooze.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Ooze.java index 5e6e6f115..1bfb4063c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Ooze.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Ooze.java @@ -66,6 +66,8 @@ public class Ooze extends Buff { GLog.n( Messages.get(this, "ondeath") ); } spend( TICK ); + } else { + detach(); } if (Dungeon.level.water[target.pos]) { detach(); 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 0bf341a89..90ce94694 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -815,7 +815,7 @@ public abstract class Level implements Bundlable { if (trap != null) { TimekeepersHourglass.timeFreeze timeFreeze = - ch != null ? ch.buff(TimekeepersHourglass.timeFreeze.class) : null; + Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class); if (timeFreeze == null) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/Ballistica.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/Ballistica.java index 9e5d028fe..e5884dcc9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/Ballistica.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/Ballistica.java @@ -102,13 +102,14 @@ public class Ballistica { while (Dungeon.level.insideMap(cell)) { //if we're in a wall, collide with the previous cell along the path. + //we don't use solid here because we don't want to stop short of closed doors if (stopTerrain && cell != sourcePos && !Dungeon.level.passable[cell] && !Dungeon.level.avoid[cell]) { collide(path.get(path.size() - 1)); } path.add(cell); - if ((stopTerrain && cell != sourcePos && Dungeon.level.losBlocking[cell]) + if ((stopTerrain && cell != sourcePos && Dungeon.level.solid[cell]) || (cell != sourcePos && stopChars && Actor.findChar( cell ) != null) || (cell == to && stopTarget)){ collide(cell); 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 63e48078a..b245e0873 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ShadowCaster.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ShadowCaster.java @@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.mechanics; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.utils.BArray; //based on: http://www.roguebasin.com/index.php?title=FOV_using_recursive_shadowcasting @@ -55,14 +56,19 @@ public final class ShadowCaster { boolean[] losBlocking = Dungeon.level.losBlocking; //scans octants, clockwise - 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); + 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); + } catch (Exception e){ + ShatteredPixelDungeon.reportException(e); + BArray.setFalse(fieldOfView); + } }