v0.9.3b: added more safety checks to prismatic images

This commit is contained in:
Evan Debenham 2021-06-16 22:49:48 -04:00
parent eb0c857ef8
commit 57d9f7ffad

View File

@ -144,12 +144,20 @@ public class PrismaticImage extends NPC {
@Override
public int damageRoll() {
return Random.NormalIntRange( 1 + hero.lvl/8, 4 + hero.lvl/2 );
if (hero != null) {
return Random.NormalIntRange( 1 + hero.lvl/8, 4 + hero.lvl/2 );
} else {
return Random.NormalIntRange( 1, 4 );
}
}
@Override
public int attackSkill( Char target ) {
return hero.attackSkill(target);
if (hero != null) {
return hero.attackSkill(target);
} else {
return 0;
}
}
@Override
@ -177,7 +185,7 @@ public class PrismaticImage extends NPC {
@Override
public int defenseProc(Char enemy, int damage) {
damage = super.defenseProc(enemy, damage);
if (hero.belongings.armor != null){
if (hero != null && hero.belongings.armor != null){
return hero.belongings.armor.proc( enemy, this, damage );
} else {
return damage;
@ -188,7 +196,7 @@ public class PrismaticImage extends NPC {
public void damage(int dmg, Object src) {
//TODO improve this when I have proper damage source logic
if (hero.belongings.armor != null && hero.belongings.armor.hasGlyph(AntiMagic.class, this)
if (hero != null && hero.belongings.armor != null && hero.belongings.armor.hasGlyph(AntiMagic.class, this)
&& AntiMagic.RESISTS.contains(src.getClass())){
dmg -= AntiMagic.drRoll(hero.belongings.armor.buffedLvl());
}
@ -198,7 +206,7 @@ public class PrismaticImage extends NPC {
@Override
public float speed() {
if (hero.belongings.armor != null){
if (hero != null && hero.belongings.armor != null){
return hero.belongings.armor.speedFactor(this, super.speed());
}
return super.speed();