v2.0.0: fixed downed ghouls being considered dead in lots of cases

This commit is contained in:
Evan Debenham
2022-11-16 17:17:41 -05:00
parent 69a24db794
commit 1948c11480
5 changed files with 22 additions and 6 deletions
@@ -740,6 +740,10 @@ public abstract class Char extends Actor {
return HP > 0 || deathMarked; return HP > 0 || deathMarked;
} }
public boolean isActive() {
return isAlive();
}
@Override @Override
protected void spendConstant(float time) { protected void spendConstant(float time) {
TimekeepersHourglass.timeFreeze freeze = buff(TimekeepersHourglass.timeFreeze.class); TimekeepersHourglass.timeFreeze freeze = buff(TimekeepersHourglass.timeFreeze.class);
@@ -1343,7 +1343,7 @@ public class Hero extends Char {
Char lastTarget = QuickSlotButton.lastTarget; Char lastTarget = QuickSlotButton.lastTarget;
if (target != null && (lastTarget == null || if (target != null && (lastTarget == null ||
!lastTarget.isAlive() || !lastTarget.isAlive() || !lastTarget.isActive() ||
lastTarget.alignment == Alignment.ALLY || lastTarget.alignment == Alignment.ALLY ||
!fieldOfView[lastTarget.pos])){ !fieldOfView[lastTarget.pos])){
QuickSlotButton.target(target); QuickSlotButton.target(target);
@@ -155,7 +155,6 @@ public class Ghoul extends Mob {
timesDowned++; timesDowned++;
Buff.append(nearby, GhoulLifeLink.class).set(timesDowned*5, this); Buff.append(nearby, GhoulLifeLink.class).set(timesDowned*5, this);
((GhoulSprite)sprite).crumple(); ((GhoulSprite)sprite).crumple();
beingLifeLinked = false;
return; return;
} }
} }
@@ -163,6 +162,16 @@ public class Ghoul extends Mob {
super.die(cause); super.die(cause);
} }
@Override
public boolean isAlive() {
return super.isAlive() || beingLifeLinked;
}
@Override
public boolean isActive() {
return !beingLifeLinked && isAlive();
}
@Override @Override
protected synchronized void onRemove() { protected synchronized void onRemove() {
if (beingLifeLinked) { if (beingLifeLinked) {
@@ -269,6 +278,7 @@ public class Ghoul extends Mob {
} }
} }
ghoul.HP = Math.round(ghoul.HT/10f); ghoul.HP = Math.round(ghoul.HT/10f);
ghoul.beingLifeLinked = false;
Actor.add(ghoul); Actor.add(ghoul);
ghoul.timeToNow(); ghoul.timeToNow();
Dungeon.level.mobs.add(ghoul); Dungeon.level.mobs.add(ghoul);
@@ -321,6 +331,7 @@ public class Ghoul extends Mob {
public void restoreFromBundle(Bundle bundle) { public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle); super.restoreFromBundle(bundle);
ghoul = (Ghoul) bundle.get(GHOUL); ghoul = (Ghoul) bundle.get(GHOUL);
ghoul.beingLifeLinked = true;
turnsToRevive = bundle.getInt(LEFT); turnsToRevive = bundle.getInt(LEFT);
} }
@@ -22,6 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.ui; package com.shatteredpixel.shatteredpixeldungeon.ui;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Ghoul;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
@@ -46,7 +47,7 @@ public class CharHealthIndicator extends HealthBar {
public void update() { public void update() {
super.update(); super.update();
if (target != null && target.isAlive() && target.sprite.visible) { if (target != null && target.isAlive() && target.isActive() && target.sprite.visible) {
CharSprite sprite = target.sprite; CharSprite sprite = target.sprite;
width = sprite.width()*(4/6f); width = sprite.width()*(4/6f);
x = sprite.x + sprite.width()/6f; x = sprite.x + sprite.width()/6f;
@@ -59,7 +60,7 @@ public class CharHealthIndicator extends HealthBar {
} }
public void target( Char ch ) { public void target( Char ch ) {
if (ch != null && ch.isAlive()) { if (ch != null && ch.isAlive() && ch.isActive()) {
target = ch; target = ch;
} else { } else {
target = null; target = null;
@@ -40,7 +40,7 @@ public class TargetHealthIndicator extends HealthBar {
public void update() { public void update() {
super.update(); super.update();
if (target != null && target.isAlive() && target.sprite.visible) { if (target != null && target.isAlive() && target.isActive() && target.sprite.visible) {
CharSprite sprite = target.sprite; CharSprite sprite = target.sprite;
width = sprite.width(); width = sprite.width();
x = sprite.x; x = sprite.x;
@@ -53,7 +53,7 @@ public class TargetHealthIndicator extends HealthBar {
} }
public void target( Char ch ) { public void target( Char ch ) {
if (ch != null && ch.isAlive()) { if (ch != null && ch.isAlive() && ch.isActive()) {
target = ch; target = ch;
} else { } else {
target = null; target = null;