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