v1.4.0: simplified explosion position logic for explosive curse
This commit is contained in:
+8
-10
@@ -34,6 +34,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||||
import com.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
|
import com.watabou.utils.PathFinder;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class Explosive extends Weapon.Enchantment {
|
public class Explosive extends Weapon.Enchantment {
|
||||||
@@ -62,17 +63,14 @@ public class Explosive extends Weapon.Enchantment {
|
|||||||
attacker.sprite.emitter().burst(BlastParticle.FACTORY, 5);
|
attacker.sprite.emitter().burst(BlastParticle.FACTORY, 5);
|
||||||
Item.updateQuickslot();
|
Item.updateQuickslot();
|
||||||
} else if (durability <= 0) {
|
} else if (durability <= 0) {
|
||||||
//explosion position is either the attacker's position (when attacker and defender are adjacent)
|
//explosion position is the closest adjacent cell to the defender
|
||||||
//or the closest cell to the defender on a straight path to them otherwise
|
// this will be the attacker's position if they are adjacent
|
||||||
int explosionPos = -1;
|
int explosionPos = -1;
|
||||||
if (Dungeon.level.adjacent(attacker.pos, defender.pos)){
|
for (int i : PathFinder.NEIGHBOURS8){
|
||||||
explosionPos = attacker.pos;
|
if (!Dungeon.level.solid[defender.pos+i] &&
|
||||||
} else {
|
(explosionPos == -1 ||
|
||||||
Ballistica path = new Ballistica(attacker.pos, defender.pos, Ballistica.PROJECTILE);
|
Dungeon.level.trueDistance(attacker.pos, defender.pos+i) < Dungeon.level.trueDistance(attacker.pos, explosionPos))){
|
||||||
if (path.dist == 0){
|
explosionPos = defender.pos+i;
|
||||||
explosionPos = attacker.pos;
|
|
||||||
} else {
|
|
||||||
explosionPos = path.path.get(path.dist-1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user