v1.4.0: sacrifice room prizes are now generated as part of levelgen
This commit is contained in:
@@ -39,6 +39,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Wraith;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.SacrificialParticle;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.SacrificeRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
@@ -61,6 +62,8 @@ public class SacrificialFire extends Blob {
|
||||
// The limit is to prevent farming
|
||||
private int bonusSpawns = 3;
|
||||
|
||||
private Item prize;
|
||||
|
||||
@Override
|
||||
protected void evolve() {
|
||||
int cell;
|
||||
@@ -119,25 +122,31 @@ public class SacrificialFire extends Blob {
|
||||
}
|
||||
|
||||
private static final String BONUS_SPAWNS = "bonus_spawns";
|
||||
private static final String PRIZE = "prize";
|
||||
|
||||
@Override
|
||||
public void storeInBundle(Bundle bundle) {
|
||||
super.storeInBundle(bundle);
|
||||
bundle.put(BONUS_SPAWNS, bonusSpawns);
|
||||
bundle.put(PRIZE, prize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle(Bundle bundle) {
|
||||
super.restoreFromBundle(bundle);
|
||||
bonusSpawns = bundle.getInt(BONUS_SPAWNS);
|
||||
if (bundle.contains(PRIZE)) prize = (Item) bundle.get(PRIZE);
|
||||
}
|
||||
|
||||
public static void sacrifice( Char ch ) {
|
||||
public void setPrize( Item prize ){
|
||||
this.prize = prize;
|
||||
}
|
||||
|
||||
public void sacrifice( Char ch ) {
|
||||
|
||||
SacrificialFire fire = (SacrificialFire)Dungeon.level.blobs.get( SacrificialFire.class );
|
||||
int firePos = -1;
|
||||
for (int i : PathFinder.NEIGHBOURS9){
|
||||
if (fire != null && fire.volume > 0 && fire.cur[ch.pos+i] > 0){
|
||||
if (volume > 0 && cur[ch.pos+i] > 0){
|
||||
firePos = ch.pos+i;
|
||||
break;
|
||||
}
|
||||
@@ -168,16 +177,16 @@ public class SacrificialFire extends Blob {
|
||||
|
||||
if (exp > 0) {
|
||||
|
||||
int volume = fire.cur[firePos] - exp;
|
||||
if (volume > 0) {
|
||||
fire.cur[firePos] -= exp;
|
||||
fire.volume -= exp;
|
||||
fire.bonusSpawns++;
|
||||
int volumeLeft = cur[firePos] - exp;
|
||||
if (volumeLeft > 0) {
|
||||
cur[firePos] -= exp;
|
||||
volume -= exp;
|
||||
bonusSpawns++;
|
||||
CellEmitter.get(firePos).burst( SacrificialParticle.FACTORY, 20 );
|
||||
Sample.INSTANCE.play(Assets.Sounds.BURNING );
|
||||
GLog.w( Messages.get(SacrificialFire.class, "worthy"));
|
||||
} else {
|
||||
fire.clear(firePos);
|
||||
clear(firePos);
|
||||
Notes.remove(Notes.Landmark.SACRIFICIAL_FIRE);
|
||||
|
||||
for (int i : PathFinder.NEIGHBOURS9){
|
||||
@@ -187,7 +196,11 @@ public class SacrificialFire extends Blob {
|
||||
Sample.INSTANCE.play(Assets.Sounds.BURNING );
|
||||
Sample.INSTANCE.play(Assets.Sounds.BURNING );
|
||||
GLog.w( Messages.get(SacrificialFire.class, "reward"));
|
||||
Dungeon.level.drop( SacrificeRoom.prize( Dungeon.level ), firePos ).sprite.drop();
|
||||
if (prize != null) {
|
||||
Dungeon.level.drop(prize, firePos).sprite.drop();
|
||||
} else {
|
||||
Dungeon.level.drop(SacrificeRoom.prize(Dungeon.level), firePos).sprite.drop();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -204,7 +217,10 @@ public class SacrificialFire extends Blob {
|
||||
@Override
|
||||
public void detach() {
|
||||
if (!target.isAlive()) {
|
||||
sacrifice( target );
|
||||
SacrificialFire fire = (SacrificialFire) Dungeon.level.blobs.get(SacrificialFire.class);
|
||||
if (fire != null) {
|
||||
fire.sacrifice(target);
|
||||
}
|
||||
}
|
||||
super.detach();
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class SacrificeRoom extends SpecialRoom {
|
||||
Painter.fill( level, c.x - 1, c.y - 1, 3, 3, Terrain.EMBERS );
|
||||
Painter.set( level, c, Terrain.PEDESTAL );
|
||||
|
||||
Blob.seed( level.pointToCell(c), 6 + Dungeon.depth * 4, SacrificialFire.class, level );
|
||||
Blob.seed( level.pointToCell(c), 6 + Dungeon.depth * 4, SacrificialFire.class, level ).setPrize(prize(level));
|
||||
|
||||
door.set( Door.Type.EMPTY );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user