From 0c4d3029797e88ddc1785d32221bde71084c500b Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 4 Sep 2016 04:21:31 -0400 Subject: [PATCH] v0.4.2: fixed issues with wands of fireblast and regrowth --- .../java/com/watabou/utils/PathFinder.java | 6 ++++++ .../items/wands/WandOfFireblast.java | 21 +++++++++++-------- .../items/wands/WandOfRegrowth.java | 16 +++++++------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/SPD-classes/src/main/java/com/watabou/utils/PathFinder.java b/SPD-classes/src/main/java/com/watabou/utils/PathFinder.java index 843bd2d15..ab568b9be 100644 --- a/SPD-classes/src/main/java/com/watabou/utils/PathFinder.java +++ b/SPD-classes/src/main/java/com/watabou/utils/PathFinder.java @@ -41,6 +41,10 @@ public class PathFinder { public static int[] NEIGHBOURS4; public static int[] NEIGHBOURS8; public static int[] NEIGHBOURS9; + + //similar to NEIGHBOURS8, but the order is circular. + //Useful for some logic functions, but is slower due to lack of array-access order. + public static int[] CIRCLE; public static void setMapSize( int width, int height ) { @@ -59,6 +63,8 @@ public class PathFinder { NEIGHBOURS4 = new int[]{-width, -1, +1, +width}; NEIGHBOURS8 = new int[]{-width-1, -width, -width+1, -1, +1, +width-1, +width, +width+1}; NEIGHBOURS9 = new int[]{-width-1, -width, -width+1, -1, 0, +1, +width-1, +width, +width+1}; + + CIRCLE = new int[]{-width-1, -width, -width+1, +1, +width+1, +width, +width-1, -1}; } //TODO currently this isn't used, and all pathfinding is recomputed each step. diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfFireblast.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfFireblast.java index f0f87934f..02945833f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfFireblast.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfFireblast.java @@ -21,6 +21,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.wands; import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob; @@ -71,7 +72,9 @@ public class WandOfFireblast extends DamageWand { protected void onZap( Ballistica bolt ) { for( int cell : affectedCells){ - GameScene.add( Blob.seed( cell, 1+chargesPerCast(), Fire.class ) ); + + if (Level.flamable[cell] || !Dungeon.level.adjacent(bolt.sourcePos, cell)) + GameScene.add( Blob.seed( cell, 1+chargesPerCast(), Fire.class ) ); Char ch = Actor.findChar( cell ); if (ch != null) { @@ -97,9 +100,9 @@ public class WandOfFireblast extends DamageWand { affectedCells.add(cell); if (strength >= 1.5f) { visualCells.remove(cell); - spreadFlames(cell + PathFinder.NEIGHBOURS8[left(direction)], strength - 1.5f); - spreadFlames(cell + PathFinder.NEIGHBOURS8[direction], strength - 1.5f); - spreadFlames(cell + PathFinder.NEIGHBOURS8[right(direction)], strength - 1.5f); + spreadFlames(cell + PathFinder.CIRCLE[left(direction)], strength - 1.5f); + spreadFlames(cell + PathFinder.CIRCLE[direction], strength - 1.5f); + spreadFlames(cell + PathFinder.CIRCLE[right(direction)], strength - 1.5f); } else { visualCells.add(cell); } @@ -131,8 +134,8 @@ public class WandOfFireblast extends DamageWand { int maxDist = (int)(4 * Math.pow(1.5,(chargesPerCast()-1))); int dist = Math.min(bolt.dist, maxDist); - for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++){ - if (bolt.sourcePos+PathFinder.NEIGHBOURS8[i] == bolt.path.get(1)){ + for (int i = 0; i < PathFinder.CIRCLE.length; i++){ + if (bolt.sourcePos+PathFinder.CIRCLE[i] == bolt.path.get(1)){ direction = i; break; } @@ -143,9 +146,9 @@ public class WandOfFireblast extends DamageWand { strength--; //as we start at dist 1, not 0. affectedCells.add(c); if (strength > 1) { - spreadFlames(c + PathFinder.NEIGHBOURS8[left(direction)], strength - 1); - spreadFlames(c + PathFinder.NEIGHBOURS8[direction], strength - 1); - spreadFlames(c + PathFinder.NEIGHBOURS8[right(direction)], strength - 1); + spreadFlames(c + PathFinder.CIRCLE[left(direction)], strength - 1); + spreadFlames(c + PathFinder.CIRCLE[direction], strength - 1); + spreadFlames(c + PathFinder.CIRCLE[right(direction)], strength - 1); } else { visualCells.add(c); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfRegrowth.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfRegrowth.java index aabbde414..dbe80de92 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfRegrowth.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfRegrowth.java @@ -111,9 +111,9 @@ public class WandOfRegrowth extends Wand { if (strength >= 0 && Level.passable[cell] && !Level.losBlocking[cell]){ affectedCells.add(cell); if (strength >= 1.5f) { - spreadRegrowth(cell + PathFinder.NEIGHBOURS8[left(direction)], strength - 1.5f); - spreadRegrowth(cell + PathFinder.NEIGHBOURS8[direction], strength - 1.5f); - spreadRegrowth(cell + PathFinder.NEIGHBOURS8[right(direction)], strength-1.5f); + spreadRegrowth(cell + PathFinder.CIRCLE[left(direction)], strength - 1.5f); + spreadRegrowth(cell + PathFinder.CIRCLE[direction], strength - 1.5f); + spreadRegrowth(cell + PathFinder.CIRCLE[right(direction)], strength-1.5f); } else { visualCells.add(cell); } @@ -188,8 +188,8 @@ public class WandOfRegrowth extends Wand { int maxDist = Math.round(1.2f + chargesPerCast()*.8f); int dist = Math.min(bolt.dist, maxDist); - for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++){ - if (bolt.sourcePos+PathFinder.NEIGHBOURS8[i] == bolt.path.get(1)){ + for (int i = 0; i < PathFinder.CIRCLE.length; i++){ + if (bolt.sourcePos+PathFinder.CIRCLE[i] == bolt.path.get(1)){ direction = i; break; } @@ -200,9 +200,9 @@ public class WandOfRegrowth extends Wand { strength--; //as we start at dist 1, not 0. if (!Level.losBlocking[c]) { affectedCells.add(c); - spreadRegrowth(c + PathFinder.NEIGHBOURS8[left(direction)], strength - 1); - spreadRegrowth(c + PathFinder.NEIGHBOURS8[direction], strength - 1); - spreadRegrowth(c + PathFinder.NEIGHBOURS8[right(direction)], strength - 1); + spreadRegrowth(c + PathFinder.CIRCLE[left(direction)], strength - 1); + spreadRegrowth(c + PathFinder.CIRCLE[direction], strength - 1); + spreadRegrowth(c + PathFinder.CIRCLE[right(direction)], strength - 1); } else { visualCells.add(c); }