v0.3.2: implemented corpse dust quest
This commit is contained in:
@@ -20,8 +20,22 @@
|
|||||||
*/
|
*/
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.items.quest;
|
package com.shatteredpixel.shatteredpixeldungeon.items.quest;
|
||||||
|
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Wraith;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||||
|
import com.watabou.noosa.audio.Sample;
|
||||||
|
import com.watabou.utils.Bundle;
|
||||||
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class CorpseDust extends Item {
|
public class CorpseDust extends Item {
|
||||||
|
|
||||||
@@ -35,6 +49,11 @@ public class CorpseDust extends Item {
|
|||||||
unique = true;
|
unique = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<String> actions(Hero hero) {
|
||||||
|
return new ArrayList<>(); //yup, no dropping this one
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isUpgradable() {
|
public boolean isUpgradable() {
|
||||||
return false;
|
return false;
|
||||||
@@ -45,10 +64,84 @@ public class CorpseDust extends Item {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean doPickUp(Hero hero) {
|
||||||
|
if (super.doPickUp(hero)){
|
||||||
|
GLog.n("You feel a shiver run down your spine.");
|
||||||
|
Buff.affect(hero, DustGhostSpawner.class);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDetach() {
|
||||||
|
DustGhostSpawner spawner = Dungeon.hero.buff(DustGhostSpawner.class);
|
||||||
|
if (spawner != null){
|
||||||
|
spawner.dispel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String info() {
|
public String info() {
|
||||||
return
|
return
|
||||||
"The ball of corpse dust doesn't differ outwardly from a regular dust ball. However, " +
|
"The ball of corpse dust doesn't differ outwardly from a regular dust ball. But you " +
|
||||||
"you know somehow that it's better to get rid of it as soon as possible.";
|
"can feel a malevolent energy lurking within it.\n\n" +
|
||||||
|
"Getting rid of it as soon as possible would be a good idea.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class DustGhostSpawner extends Buff {
|
||||||
|
|
||||||
|
int spawnPower = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean act() {
|
||||||
|
spawnPower++;
|
||||||
|
int wraiths = 1; //we include the wraith we're trying to spawn
|
||||||
|
for (Mob mob : Dungeon.level.mobs){
|
||||||
|
if (mob instanceof Wraith){
|
||||||
|
wraiths++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int powerNeeded = Math.min(25, wraiths*wraiths);
|
||||||
|
|
||||||
|
if (powerNeeded <= spawnPower){
|
||||||
|
spawnPower -= powerNeeded;
|
||||||
|
int pos = 0;
|
||||||
|
do{
|
||||||
|
pos = Random.Int(Level.LENGTH);
|
||||||
|
} while (!Dungeon.visible[pos] || !Level.passable[pos] || Actor.findChar( pos ) != null);
|
||||||
|
Wraith.spawnAt(pos);
|
||||||
|
Sample.INSTANCE.play(Assets.SND_CURSED);
|
||||||
|
}
|
||||||
|
|
||||||
|
spend(TICK);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispel(){
|
||||||
|
detach();
|
||||||
|
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])){
|
||||||
|
if (mob instanceof Wraith){
|
||||||
|
mob.die(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String SPAWNPOWER = "spawnpower";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void storeInBundle(Bundle bundle) {
|
||||||
|
super.storeInBundle(bundle);
|
||||||
|
bundle.put( SPAWNPOWER, spawnPower );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void restoreFromBundle(Bundle bundle) {
|
||||||
|
super.restoreFromBundle(bundle);
|
||||||
|
spawnPower = bundle.getInt( SPAWNPOWER );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user