v1.4.0: fixed cases where magical explosions didn't award friendly fire

This commit is contained in:
Evan Debenham
2022-07-31 14:47:07 -04:00
parent 71c9635021
commit f5dba3b056
6 changed files with 14 additions and 7 deletions
@@ -37,7 +37,7 @@ import com.watabou.utils.Random;
import java.util.ArrayList; import java.util.ArrayList;
public class ArcaneBomb extends Bomb { public class ArcaneBomb extends Bomb.MagicalBomb {
{ {
image = ItemSpriteSheet.ARCANE_BOMB; image = ItemSpriteSheet.ARCANE_BOMB;
@@ -22,6 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.items.bombs; package com.shatteredpixel.shatteredpixeldungeon.items.bombs;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
@@ -192,6 +193,9 @@ public class Bomb extends Item {
} }
if (ch == Dungeon.hero && !ch.isAlive()) { if (ch == Dungeon.hero && !ch.isAlive()) {
if (this instanceof MagicalBomb){
Badges.validateDeathFromFriendlyMagic();
}
Dungeon.fail(Bomb.class); Dungeon.fail(Bomb.class);
} }
} }
@@ -255,6 +259,8 @@ public class Bomb extends Item {
Actor.add( fuse = ((Fuse)bundle.get(FUSE)).ignite(this) ); Actor.add( fuse = ((Fuse)bundle.get(FUSE)).ignite(this) );
} }
//used to track the death from friendly magic badge
public static class MagicalBomb extends Bomb{};
public static class Fuse extends Actor{ public static class Fuse extends Actor{
@@ -36,7 +36,7 @@ import com.watabou.utils.Random;
import java.util.ArrayList; import java.util.ArrayList;
public class HolyBomb extends Bomb { public class HolyBomb extends Bomb.MagicalBomb {
{ {
image = ItemSpriteSheet.HOLY_BOMB; image = ItemSpriteSheet.HOLY_BOMB;
@@ -32,7 +32,7 @@ public class StoneOfBlast extends Runestone {
@Override @Override
protected void activate(int cell) { protected void activate(int cell) {
new Bomb().explode(cell); new Bomb.MagicalBomb().explode(cell);
} }
} }
@@ -243,9 +243,10 @@ public class CursedWand {
//Bomb explosion //Bomb explosion
case 2: case 2:
new Bomb().explode(targetPos); if (user == Dungeon.hero) {
if (user == Dungeon.hero && !user.isAlive()){ new Bomb.MagicalBomb().explode(targetPos);
Badges.validateDeathFromFriendlyMagic(); } else {
new Bomb().explode(targetPos);
} }
tryForWandProc(Actor.findChar(targetPos), origin); tryForWandProc(Actor.findChar(targetPos), origin);
return true; return true;
@@ -76,7 +76,7 @@ public class Explosive extends Weapon.Enchantment {
} }
} }
new Bomb().explode(explosionPos); new Bomb.MagicalBomb().explode(explosionPos);
durability = 100; durability = 100;
Item.updateQuickslot(); Item.updateQuickslot();