v2.2.0: fixed statues generating weapons whenever they were loaded

This commit is contained in:
Evan Debenham
2023-10-12 12:47:21 -04:00
parent 265026843f
commit e7bd3857e3
2 changed files with 12 additions and 14 deletions

View File

@@ -56,14 +56,11 @@ public class Statue extends Mob {
public Statue() {
super();
weapon = createWeapon();
HP = HT = 15 + Dungeon.depth * 5;
defenseSkill = 4 + Dungeon.depth;
}
public Weapon createWeapon(){
Weapon weapon = null;
public void createWeapon(){
//this is a bit of a hack. I'm strongly considering redesigning this system code-wise though
if (ShatteredPixelDungeon.scene() instanceof InterlevelScene) {
weapon = (MeleeWeapon) Generator.random(Generator.Category.WEAPON);
@@ -72,7 +69,6 @@ public class Statue extends Mob {
}
weapon.cursed = false;
weapon.enchant( Enchantment.random() );
return weapon;
}
private static final String WEAPON = "weapon";
@@ -195,11 +191,14 @@ public class Statue extends Mob {
}
public static Statue random(){
Statue statue = null;
if (Random.Int(10) == 0){
return new ArmoredStatue();
statue = new ArmoredStatue();
} else {
return new Statue();
statue = new Statue();
}
statue.createWeapon();
return statue;
}
}

View File

@@ -28,7 +28,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
@@ -59,6 +58,7 @@ public class GuardianTrap extends Trap {
for (int i = 0; i < (scalingDepth() - 5)/5; i++){
Guardian guardian = new Guardian();
guardian.createWeapon();
guardian.state = guardian.WANDERING;
guardian.pos = Dungeon.level.randomRespawnCell( guardian );
if (guardian.pos != -1) {
@@ -81,12 +81,11 @@ public class GuardianTrap extends Trap {
}
@Override
public Weapon createWeapon() {
Weapon w = (MeleeWeapon) Generator.randomUsingDefaults(Generator.Category.WEAPON);
w.cursed = false;
w.enchant(null);
w.level(0);
return w;
public void createWeapon() {
weapon = (MeleeWeapon) Generator.randomUsingDefaults(Generator.Category.WEAPON);
weapon.cursed = false;
weapon.enchant(null);
weapon.level(0);
}
@Override