v0.4.2: fixed issues with wands of fireblast and regrowth

This commit is contained in:
Evan Debenham 2016-09-04 04:21:31 -04:00
parent e9b5161d5e
commit 0c4d302979
3 changed files with 26 additions and 17 deletions

View File

@ -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.

View File

@ -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);
}

View File

@ -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);
}