v0.8.2a: fixes for various crashes

- added a safety check for when an amoked character dies
- added a safety check when ghouls die over pits
- mobs looking for a new enemy when aggroed on an invincible one
- made Tengu's 2nd phase jumping slightly more permissive
- fixed a logic error when placing enemies
- added a safety check in WndWandmaker
- added a safety sync check when playing a sample
This commit is contained in:
Evan Debenham 2020-08-13 17:43:01 -04:00
parent fc6a32058e
commit e51025de0c
7 changed files with 21 additions and 10 deletions

View File

@ -97,7 +97,7 @@ public enum Sample {
return play( id, volume, volume, pitch );
}
public long play( Object id, float leftVolume, float rightVolume, float pitch ) {
public synchronized long play( Object id, float leftVolume, float rightVolume, float pitch ) {
float volume = Math.max(leftVolume, rightVolume);
float pan = rightVolume - leftVolume;
if (enabled && ids.containsKey( id )) {

View File

@ -40,8 +40,9 @@ public class Amok extends FlavourBuff {
@Override
public void detach() {
super.detach();
if (target instanceof Mob)
((Mob)target).aggro( null );
if (target instanceof Mob && target.isAlive()) {
((Mob) target).aggro(null);
}
}
@Override

View File

@ -225,6 +225,12 @@ public class Ghoul extends Mob {
return true;
}
if (Dungeon.level.pit[ghoul.pos]){
super.detach();
ghoul.die(this);
return true;
}
turnsToRevive--;
if (turnsToRevive <= 0){
ghoul.HP = Math.round(ghoul.HT/10f);

View File

@ -227,8 +227,8 @@ public abstract class Mob extends Char {
//We are charmed and current enemy is what charmed us
} else if (buff(Charm.class) != null && buff(Charm.class).object == enemy.id()) {
newEnemy = true;
//we aren't amoked and current enemy is invulnerable to us
} else if (buff( Amok.class ) == null && enemy.isInvulnerable(getClass())) {
//we aren't amoked, current enemy is invulnerable to us, and that enemy isn't affect by aggression
} else if (buff( Amok.class ) == null && enemy.isInvulnerable(getClass()) && enemy.buff(StoneOfAggression.Aggression.class) == null) {
newEnemy = true;
}

View File

@ -274,7 +274,7 @@ public class NewTengu extends Mob {
level.distance(newPos, enemy.pos) > 7 ||
level.distance(newPos, Dungeon.hero.pos) < 5 ||
level.distance(newPos, Dungeon.hero.pos) > 7 ||
level.distance(newPos, pos) < 6 ||
level.distance(newPos, pos) < 5 ||
Actor.findChar(newPos) != null ||
Dungeon.level.heaps.get(newPos) != null);

View File

@ -210,8 +210,8 @@ public abstract class RegularLevel extends Level {
do {
mob.pos = pointToCell(roomToSpawn.random());
tries--;
} while (tries >= 0 && findMob(mob.pos) != null || !passable[mob.pos] || mob.pos == exit
|| (!openSpace[mob.pos] && mob.properties().contains(Char.Property.LARGE)));
} while (tries >= 0 && (findMob(mob.pos) != null || !passable[mob.pos] || mob.pos == exit
|| (!openSpace[mob.pos] && mob.properties().contains(Char.Property.LARGE))));
if (tries >= 0) {
mobsToSpawn--;

View File

@ -88,9 +88,13 @@ public class WndWandmaker extends Window {
}
private void selectReward( Wandmaker wandmaker, Item item, Wand reward ) {
if (reward == null){
return;
}
hide();
item.detach( Dungeon.hero.belongings.backpack );
reward.identify();