v2.3.0: made wraith classes more flexible, and added one for corpse dust

This commit is contained in:
Evan Debenham
2023-11-01 15:04:19 -04:00
parent 052715a694
commit cdec9a68bf
8 changed files with 43 additions and 27 deletions
@@ -835,7 +835,7 @@ public abstract class Mob extends Char {
if (!(this instanceof Wraith)
&& soulMarked
&& Random.Float() < (0.4f*Dungeon.hero.pointsInTalent(Talent.NECROMANCERS_MINIONS)/3f)){
Wraith w = Wraith.spawnAt(pos, false);
Wraith w = Wraith.spawnAt(pos, Wraith.class);
if (w != null) {
Buff.affect(w, Corruption.class);
if (Dungeon.level.heroFOV[pos]) {
@@ -151,7 +151,7 @@ public class SpectralNecromancer extends Necromancer {
summoning = firstSummon = false;
Wraith wraith = Wraith.spawnAt(summoningPos, false);
Wraith wraith = Wraith.spawnAt(summoningPos, Wraith.class);
wraith.adjustStats(0);
Dungeon.level.occupyCell( wraith );
((SpectralNecromancerSprite)sprite).finishSummoning();
@@ -32,6 +32,7 @@ import com.watabou.noosa.tweeners.AlphaTweener;
import com.watabou.utils.Bundle;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;
import com.watabou.utils.Reflection;
public class Wraith extends Mob {
@@ -93,21 +94,34 @@ public class Wraith extends Mob {
state = WANDERING;
return true;
}
public static void spawnAround( int pos, boolean allowExotic ) {
for (int n : PathFinder.NEIGHBOURS4) {
spawnAt( pos + n, allowExotic );
}
public static void spawnAround( int pos ) {
spawnAround( pos, null );
}
public static Wraith spawnAt( int pos, boolean allowExotic ) {
public static void spawnAround( int pos, Class<? extends Wraith> wraithClass ) {
for (int n : PathFinder.NEIGHBOURS4) {
spawnAt( pos + n, wraithClass );
}
}
public static Wraith spawnAt( int pos ) {
return spawnAt( pos, null );
}
public static Wraith spawnAt( int pos, Class<? extends Wraith> wraithClass ) {
if ((!Dungeon.level.solid[pos] || Dungeon.level.passable[pos]) && Actor.findChar( pos ) == null) {
Wraith w;
if (allowExotic && Random.Int(100) == 0){
w = new TormentedSpirit();
//if no wraith type is specified, 1/100 chance for exotic, otherwise normal
if (wraithClass == null){
if (Random.Int(100) == 0){
w = new TormentedSpirit();
} else {
w = new Wraith();
}
} else {
w = new Wraith();
w = Reflection.newInstance(wraithClass);
}
w.adjustStats( Dungeon.scalingDepth() );
w.pos = pos;
@@ -123,7 +137,7 @@ public class Wraith extends Mob {
} else {
w.sprite.emitter().burst(ShadowParticle.CURSE, 5);
}
return w;
} else {
return null;
@@ -84,7 +84,7 @@ public class Heap implements Bundlable {
public void open( Hero hero ) {
switch (type) {
case TOMB:
Wraith.spawnAround( hero.pos, true );
Wraith.spawnAround( hero.pos );
break;
case REMAINS:
case SKELETON:
@@ -94,7 +94,7 @@ public class Heap implements Bundlable {
}
if (haunted){
if (Wraith.spawnAt( pos, true ) == null) {
if (Wraith.spawnAt( pos ) == null) {
hero.sprite.emitter().burst( ShadowParticle.CURSE, 6 );
hero.damage( hero.HP / 2, this );
if (!hero.isAlive()){
@@ -438,7 +438,7 @@ public class DriedRose extends Artifact {
}
if (spawnPoints.size() > 0) {
Wraith.spawnAt(Random.element(spawnPoints), false);
Wraith.spawnAt(Random.element(spawnPoints), Wraith.class);
Sample.INSTANCE.play(Assets.Sounds.CURSED);
}
@@ -105,7 +105,7 @@ public class CorpseDust extends Item {
spawnPower++;
int wraiths = 1; //we include the wraith we're trying to spawn
for (Mob mob : Dungeon.level.mobs){
if (mob instanceof Wraith){
if (mob instanceof DustWraith){
wraiths++;
}
}
@@ -130,7 +130,7 @@ public class CorpseDust extends Item {
}
}
if (!candidates.isEmpty()){
Wraith.spawnAt(Random.element(candidates), false);
Wraith.spawnAt(Random.element(candidates), DustWraith.class);
Sample.INSTANCE.play(Assets.Sounds.CURSED);
spawnPower -= powerNeeded;
}
@@ -143,7 +143,7 @@ public class CorpseDust extends Item {
public void dispel(){
detach();
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])){
if (mob instanceof Wraith){
if (mob instanceof DustWraith){
mob.die(null);
}
}
@@ -177,4 +177,6 @@ public class CorpseDust extends Item {
}
}
public static class DustWraith extends Wraith{};
}
@@ -89,11 +89,11 @@ public class WandOfCorruption extends Wand {
private static final float MINOR_DEBUFF_WEAKEN = 1/4f;
private static final HashMap<Class<? extends Buff>, Float> MINOR_DEBUFFS = new HashMap<>();
static{
MINOR_DEBUFFS.put(Weakness.class, 2f);
MINOR_DEBUFFS.put(Vulnerable.class, 2f);
MINOR_DEBUFFS.put(Cripple.class, 1f);
MINOR_DEBUFFS.put(Blindness.class, 1f);
MINOR_DEBUFFS.put(Terror.class, 1f);
MINOR_DEBUFFS.put(Weakness.class, 0f);
MINOR_DEBUFFS.put(Vulnerable.class, 0f);
MINOR_DEBUFFS.put(Cripple.class, 0f);
MINOR_DEBUFFS.put(Blindness.class, 0f);
MINOR_DEBUFFS.put(Terror.class, 0f);
MINOR_DEBUFFS.put(Chill.class, 0f);
MINOR_DEBUFFS.put(Ooze.class, 0f);
@@ -109,9 +109,9 @@ public class WandOfCorruption extends Wand {
private static final HashMap<Class<? extends Buff>, Float> MAJOR_DEBUFFS = new HashMap<>();
static{
MAJOR_DEBUFFS.put(Amok.class, 3f);
MAJOR_DEBUFFS.put(Slow.class, 2f);
MAJOR_DEBUFFS.put(Hex.class, 2f);
MAJOR_DEBUFFS.put(Paralysis.class, 1f);
MAJOR_DEBUFFS.put(Slow.class, 0f);
MAJOR_DEBUFFS.put(Hex.class, 0f);
MAJOR_DEBUFFS.put(Paralysis.class, 0f);
MAJOR_DEBUFFS.put(Daze.class, 0f);
MAJOR_DEBUFFS.put(Dread.class, 0f);
@@ -116,7 +116,7 @@ public class DistortionTrap extends Trap{
case 2:
switch (2){
case 0: default:
Wraith.spawnAt(point, true);
Wraith.spawnAt(point);
continue; //wraiths spawn themselves, no need to do more
case 1:
//yes it's intended that these are likely to die right away