v0.6.1: overhauled bestiary logic for improved consistency
This commit is contained in:
parent
e7117d6577
commit
49543e301c
|
@ -21,27 +21,195 @@
|
|||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.actors.mobs;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Bestiary {
|
||||
|
||||
public static Mob mob( int depth ) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends Mob> cl = (Class<? extends Mob>)mobClass( depth );
|
||||
try {
|
||||
return cl.newInstance();
|
||||
} catch (Exception e) {
|
||||
ShatteredPixelDungeon.reportException(e);
|
||||
return null;
|
||||
public static ArrayList<Class<? extends Mob>> getMobRotation( int depth ){
|
||||
ArrayList<Class<? extends Mob>> mobs = standardMobRotation( depth );
|
||||
addRareMobs(depth, mobs);
|
||||
swapMobAlts(mobs);
|
||||
Random.shuffle(mobs);
|
||||
return mobs;
|
||||
}
|
||||
|
||||
//returns a rotation of standard mobs, unshuffled.
|
||||
private static ArrayList<Class<? extends Mob>> standardMobRotation( int depth ){
|
||||
switch(depth){
|
||||
|
||||
// Sewers
|
||||
case 1: default:
|
||||
//10x rat
|
||||
return new ArrayList<Class<? extends Mob>>(Arrays.asList(
|
||||
Rat.class, Rat.class, Rat.class, Rat.class, Rat.class,
|
||||
Rat.class, Rat.class, Rat.class, Rat.class, Rat.class));
|
||||
case 2:
|
||||
//3x rat, 3x gnoll
|
||||
return new ArrayList<>(Arrays.asList(Rat.class, Rat.class, Rat.class,
|
||||
Gnoll.class, Gnoll.class, Gnoll.class));
|
||||
case 3:
|
||||
//2x rat, 4x gnoll, 1x crab, 1x swarm
|
||||
return new ArrayList<>(Arrays.asList(Rat.class, Rat.class,
|
||||
Gnoll.class, Gnoll.class, Gnoll.class, Gnoll.class,
|
||||
Crab.class, Swarm.class));
|
||||
case 4:
|
||||
//1x rat, 2x gnoll, 3x crab, 1x swarm
|
||||
return new ArrayList<>(Arrays.asList(Rat.class,
|
||||
Gnoll.class, Gnoll.class,
|
||||
Crab.class, Crab.class, Crab.class,
|
||||
Swarm.class));
|
||||
|
||||
// Prison
|
||||
case 6:
|
||||
//3x skeleton, 1x thief, 1x swarm
|
||||
return new ArrayList<>(Arrays.asList(Skeleton.class, Skeleton.class, Skeleton.class,
|
||||
Thief.class,
|
||||
Swarm.class));
|
||||
case 7:
|
||||
//3x skeleton, 1x thief, 1x shaman, 1x guard
|
||||
return new ArrayList<>(Arrays.asList(Skeleton.class, Skeleton.class, Skeleton.class,
|
||||
Thief.class,
|
||||
Shaman.class,
|
||||
Guard.class));
|
||||
case 8:
|
||||
//3x skeleton, 1x thief, 2x shaman, 2x guard
|
||||
return new ArrayList<>(Arrays.asList(Skeleton.class, Skeleton.class, Skeleton.class,
|
||||
Thief.class,
|
||||
Shaman.class, Shaman.class,
|
||||
Guard.class, Guard.class));
|
||||
case 9:
|
||||
//3x skeleton, 1x thief, 2x shaman, 3x guard
|
||||
return new ArrayList<>(Arrays.asList(Skeleton.class, Skeleton.class, Skeleton.class,
|
||||
Thief.class,
|
||||
Shaman.class, Shaman.class,
|
||||
Guard.class, Guard.class, Guard.class));
|
||||
|
||||
// Caves
|
||||
case 11:
|
||||
//5x bat, 1x brute
|
||||
return new ArrayList<>(Arrays.asList(
|
||||
Bat.class, Bat.class, Bat.class, Bat.class, Bat.class,
|
||||
Brute.class));
|
||||
case 12:
|
||||
//5x bat, 5x brute, 1x spinner
|
||||
return new ArrayList<>(Arrays.asList(
|
||||
Bat.class, Bat.class, Bat.class, Bat.class, Bat.class,
|
||||
Brute.class, Brute.class, Brute.class, Brute.class, Brute.class,
|
||||
Spinner.class));
|
||||
case 13:
|
||||
//1x bat, 3x brute, 1x shaman, 1x spinner
|
||||
return new ArrayList<>(Arrays.asList(
|
||||
Bat.class,
|
||||
Brute.class, Brute.class, Brute.class,
|
||||
Shaman.class,
|
||||
Spinner.class));
|
||||
case 14:
|
||||
//1x bat, 3x brute, 1x shaman, 4x spinner
|
||||
return new ArrayList<>(Arrays.asList(
|
||||
Bat.class,
|
||||
Brute.class, Brute.class, Brute.class,
|
||||
Shaman.class,
|
||||
Spinner.class, Spinner.class, Spinner.class, Spinner.class));
|
||||
|
||||
// City
|
||||
case 16:
|
||||
//5x elemental, 5x warlock, 1x monk
|
||||
return new ArrayList<>(Arrays.asList(
|
||||
Elemental.class, Elemental.class, Elemental.class, Elemental.class, Elemental.class,
|
||||
Warlock.class, Warlock.class, Warlock.class, Warlock.class, Warlock.class,
|
||||
Monk.class));
|
||||
case 17:
|
||||
//2x elemental, 2x warlock, 2x monk
|
||||
return new ArrayList<>(Arrays.asList(
|
||||
Elemental.class, Elemental.class,
|
||||
Warlock.class, Warlock.class,
|
||||
Monk.class, Monk.class));
|
||||
case 18:
|
||||
//1x elemental, 1x warlock, 2x monk, 1x golem
|
||||
return new ArrayList<>(Arrays.asList(
|
||||
Elemental.class,
|
||||
Warlock.class,
|
||||
Monk.class, Monk.class,
|
||||
Golem.class));
|
||||
case 19:
|
||||
//1x elemental, 1x warlock, 2x monk, 3x golem
|
||||
return new ArrayList<>(Arrays.asList(
|
||||
Elemental.class,
|
||||
Warlock.class,
|
||||
Monk.class, Monk.class,
|
||||
Golem.class, Golem.class, Golem.class));
|
||||
|
||||
// Halls
|
||||
case 22:
|
||||
//3x succubus, 3x evil eye
|
||||
return new ArrayList<>(Arrays.asList(
|
||||
Succubus.class, Succubus.class, Succubus.class,
|
||||
Eye.class, Eye.class, Eye.class));
|
||||
case 23:
|
||||
//2x succubus, 4x evil eye, 2x scorpio
|
||||
return new ArrayList<>(Arrays.asList(
|
||||
Succubus.class, Succubus.class,
|
||||
Eye.class, Eye.class, Eye.class, Eye.class,
|
||||
Scorpio.class, Scorpio.class));
|
||||
case 24:
|
||||
//1x succubus, 2x evil eye, 3x scorpio
|
||||
return new ArrayList<>(Arrays.asList(
|
||||
Succubus.class,
|
||||
Eye.class, Eye.class,
|
||||
Scorpio.class, Scorpio.class, Scorpio.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//has a chance to add a rarely spawned mobs to the rotation
|
||||
public static void addRareMobs( int depth, ArrayList<Class<?extends Mob>> rotation ){
|
||||
|
||||
switch (depth){
|
||||
|
||||
// Sewers
|
||||
default:
|
||||
return;
|
||||
case 4:
|
||||
if (Random.Float() < 0.01f) rotation.add(Skeleton.class);
|
||||
if (Random.Float() < 0.01f) rotation.add(Thief.class);
|
||||
return;
|
||||
|
||||
// Prison
|
||||
case 6:
|
||||
if (Random.Float() < 0.2f) rotation.add(Shaman.class);
|
||||
return;
|
||||
case 8:
|
||||
if (Random.Float() < 0.02f) rotation.add(Bat.class);
|
||||
return;
|
||||
case 9:
|
||||
if (Random.Float() < 0.02f) rotation.add(Bat.class);
|
||||
if (Random.Float() < 0.01f) rotation.add(Brute.class);
|
||||
return;
|
||||
|
||||
// Caves
|
||||
case 13:
|
||||
if (Random.Float() < 0.02f) rotation.add(Elemental.class);
|
||||
return;
|
||||
case 14:
|
||||
if (Random.Float() < 0.02f) rotation.add(Elemental.class);
|
||||
if (Random.Float() < 0.01f) rotation.add(Monk.class);
|
||||
return;
|
||||
|
||||
// City
|
||||
case 19:
|
||||
if (Random.Float() < 0.02f) rotation.add(Succubus.class);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static Mob mutable( int depth ) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends Mob> cl = (Class<? extends Mob>)mobClass( depth );
|
||||
|
||||
if (Random.Int( 30 ) == 0) {
|
||||
//switches out regular mobs for their alt versions when appropriate
|
||||
private static void swapMobAlts(ArrayList<Class<?extends Mob>> rotation){
|
||||
for (int i = 0; i < rotation.size(); i++){
|
||||
if (Random.Int( 50 ) == 0) {
|
||||
Class<? extends Mob> cl = rotation.get(i);
|
||||
if (cl == Rat.class) {
|
||||
cl = Albino.class;
|
||||
} else if (cl == Thief.class) {
|
||||
|
@ -53,133 +221,8 @@ public class Bestiary {
|
|||
} else if (cl == Scorpio.class) {
|
||||
cl = Acidic.class;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return cl.newInstance();
|
||||
} catch (Exception e) {
|
||||
ShatteredPixelDungeon.reportException(e);
|
||||
return null;
|
||||
rotation.set(i, cl);
|
||||
}
|
||||
}
|
||||
|
||||
private static Class<?> mobClass( int depth ) {
|
||||
|
||||
float[] chances;
|
||||
Class<?>[] classes;
|
||||
|
||||
switch (depth) {
|
||||
case 1:
|
||||
chances = new float[]{ 1 };
|
||||
classes = new Class<?>[]{ Rat.class };
|
||||
break;
|
||||
case 2:
|
||||
chances = new float[]{ 1, 1 };
|
||||
classes = new Class<?>[]{ Rat.class, Gnoll.class };
|
||||
break;
|
||||
case 3:
|
||||
chances = new float[]{ 2, 4, 1, 1 };
|
||||
classes = new Class<?>[]{ Rat.class, Gnoll.class, Crab.class, Swarm.class };
|
||||
break;
|
||||
case 4:
|
||||
chances = new float[]{ 1, 2, 3, 1, 0.01f, 0.01f };
|
||||
classes = new Class<?>[]{ Rat.class, Gnoll.class, Crab.class, Swarm.class, Skeleton.class, Thief.class };
|
||||
break;
|
||||
|
||||
case 5:
|
||||
chances = new float[]{ 1 };
|
||||
classes = new Class<?>[]{ Goo.class };
|
||||
break;
|
||||
|
||||
case 6:
|
||||
chances = new float[]{ 3, 1, 1, 0.2f };
|
||||
classes = new Class<?>[]{ Skeleton.class, Thief.class, Swarm.class, Shaman.class };
|
||||
break;
|
||||
case 7:
|
||||
chances = new float[]{ 3, 1, 1, 1 };
|
||||
classes = new Class<?>[]{ Skeleton.class, Shaman.class, Thief.class, Guard.class };
|
||||
break;
|
||||
case 8:
|
||||
chances = new float[]{ 3, 2, 2, 1, 0.02f };
|
||||
classes = new Class<?>[]{ Skeleton.class, Shaman.class, Guard.class, Thief.class, Bat.class };
|
||||
break;
|
||||
case 9:
|
||||
chances = new float[]{ 3, 3, 2, 1, 0.02f, 0.01f };
|
||||
classes = new Class<?>[]{ Skeleton.class, Guard.class, Shaman.class, Thief.class, Bat.class, Brute.class };
|
||||
break;
|
||||
|
||||
case 10:
|
||||
chances = new float[]{ 1 };
|
||||
classes = new Class<?>[]{ Tengu.class };
|
||||
break;
|
||||
|
||||
case 11:
|
||||
chances = new float[]{ 1, 0.2f };
|
||||
classes = new Class<?>[]{ Bat.class, Brute.class };
|
||||
break;
|
||||
case 12:
|
||||
chances = new float[]{ 1, 1, 0.2f };
|
||||
classes = new Class<?>[]{ Bat.class, Brute.class, Spinner.class };
|
||||
break;
|
||||
case 13:
|
||||
chances = new float[]{ 1, 3, 1, 1, 0.02f };
|
||||
classes = new Class<?>[]{ Bat.class, Brute.class, Shaman.class, Spinner.class, Elemental.class };
|
||||
break;
|
||||
case 14:
|
||||
chances = new float[]{ 1, 3, 1, 4, 0.02f, 0.01f };
|
||||
classes = new Class<?>[]{ Bat.class, Brute.class, Shaman.class, Spinner.class, Elemental.class, Monk.class };
|
||||
break;
|
||||
|
||||
case 15:
|
||||
chances = new float[]{ 1 };
|
||||
classes = new Class<?>[]{ DM300.class };
|
||||
break;
|
||||
|
||||
case 16:
|
||||
chances = new float[]{ 1, 1, 0.2f };
|
||||
classes = new Class<?>[]{ Elemental.class, Warlock.class, Monk.class };
|
||||
break;
|
||||
case 17:
|
||||
chances = new float[]{ 1, 1, 1 };
|
||||
classes = new Class<?>[]{ Elemental.class, Monk.class, Warlock.class };
|
||||
break;
|
||||
case 18:
|
||||
chances = new float[]{ 1, 2, 1, 1 };
|
||||
classes = new Class<?>[]{ Elemental.class, Monk.class, Golem.class, Warlock.class };
|
||||
break;
|
||||
case 19:
|
||||
chances = new float[]{ 1, 2, 3, 1, 0.02f };
|
||||
classes = new Class<?>[]{ Elemental.class, Monk.class, Golem.class, Warlock.class, Succubus.class };
|
||||
break;
|
||||
|
||||
case 20:
|
||||
chances = new float[]{ 1 };
|
||||
classes = new Class<?>[]{ King.class };
|
||||
break;
|
||||
|
||||
case 22:
|
||||
chances = new float[]{ 1, 1 };
|
||||
classes = new Class<?>[]{ Succubus.class, Eye.class };
|
||||
break;
|
||||
case 23:
|
||||
chances = new float[]{ 1, 2, 1 };
|
||||
classes = new Class<?>[]{ Succubus.class, Eye.class, Scorpio.class };
|
||||
break;
|
||||
case 24:
|
||||
chances = new float[]{ 1, 2, 3 };
|
||||
classes = new Class<?>[]{ Succubus.class, Eye.class, Scorpio.class };
|
||||
break;
|
||||
|
||||
case 25:
|
||||
chances = new float[]{ 1 };
|
||||
classes = new Class<?>[]{ Yog.class };
|
||||
break;
|
||||
|
||||
default:
|
||||
chances = new float[]{ 1 };
|
||||
classes = new Class<?>[]{ Eye.class };
|
||||
}
|
||||
|
||||
return classes[ Random.chances( chances )];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bestiary;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue;
|
||||
|
@ -71,7 +70,7 @@ public class Multiplicity extends Armor.Glyph {
|
|||
//FIXME should probably have a mob property for this
|
||||
if (attacker.properties().contains(Char.Property.BOSS) || attacker.properties().contains(Char.Property.MINIBOSS)
|
||||
|| attacker instanceof Mimic || attacker instanceof Statue){
|
||||
m = Bestiary.mutable(Dungeon.depth % 5 == 0 ? Dungeon.depth - 1 : Dungeon.depth);
|
||||
m = Dungeon.level.createMob();
|
||||
} else {
|
||||
try {
|
||||
m = (Mob)attacker.getClass().newInstance();
|
||||
|
|
|
@ -26,7 +26,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Bones;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bestiary;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.DM300;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
|
@ -201,6 +201,11 @@ public class CavesBossLevel extends Level {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mob createMob() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createMobs() {
|
||||
}
|
||||
|
@ -240,7 +245,7 @@ public class CavesBossLevel extends Level {
|
|||
enteredArena = true;
|
||||
seal();
|
||||
|
||||
Mob boss = Bestiary.mob( Dungeon.depth );
|
||||
DM300 boss = new DM300();
|
||||
boss.state = boss.WANDERING;
|
||||
do {
|
||||
boss.pos = Random.Int( length() );
|
||||
|
|
|
@ -26,7 +26,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Bones;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bestiary;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.King;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
|
@ -153,6 +153,11 @@ public class CityBossLevel extends Level {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mob createMob() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createMobs() {
|
||||
}
|
||||
|
@ -194,7 +199,7 @@ public class CityBossLevel extends Level {
|
|||
enteredArena = true;
|
||||
seal();
|
||||
|
||||
Mob boss = Bestiary.mob( Dungeon.depth );
|
||||
King boss = new King();
|
||||
boss.state = boss.WANDERING;
|
||||
int count = 0;
|
||||
do {
|
||||
|
|
|
@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.levels;
|
|||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
|
||||
public class DeadEndLevel extends Level {
|
||||
|
||||
|
@ -72,6 +73,11 @@ public class DeadEndLevel extends Level {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mob createMob() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createMobs() {
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Bones;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Yog;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle;
|
||||
|
@ -141,6 +142,11 @@ public class HallsBossLevel extends Level {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mob createMob() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createMobs() {
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.levels;
|
|||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Amulet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
|
@ -113,6 +114,11 @@ public class LastLevel extends Level {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mob createMob() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createMobs() {
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.levels;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Bones;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.Builder;
|
||||
|
@ -99,6 +100,11 @@ public class LastShopLevel extends RegularLevel {
|
|||
.setGrass( 0.10f, 3 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mob createMob() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createMobs() {
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MindVision;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Shadows;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bestiary;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlowParticle;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.WindParticle;
|
||||
|
@ -461,6 +460,8 @@ public abstract class Level implements Bundlable {
|
|||
|
||||
abstract protected boolean build();
|
||||
|
||||
abstract public Mob createMob();
|
||||
|
||||
abstract protected void createMobs();
|
||||
|
||||
abstract protected void createItems();
|
||||
|
@ -519,7 +520,7 @@ public abstract class Level implements Bundlable {
|
|||
protected boolean act() {
|
||||
if (mobs.size() < nMobs()) {
|
||||
|
||||
Mob mob = Bestiary.mutable( Dungeon.depth );
|
||||
Mob mob = createMob();
|
||||
mob.state = mob.WANDERING;
|
||||
mob.pos = randomRespawnCell();
|
||||
if (Dungeon.hero.isAlive() && mob.pos != -1 && distance(Dungeon.hero.pos, mob.pos) >= 4) {
|
||||
|
|
|
@ -135,6 +135,11 @@ public class PrisonBossLevel extends Level {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mob createMob() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createMobs() {
|
||||
tengu = new Tengu(); //We want to keep track of tengu independently of other mobs, he's not always in the level.
|
||||
|
|
|
@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.levels;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Bones;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bestiary;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
|
@ -191,6 +192,21 @@ public abstract class RegularLevel extends Level {
|
|||
}
|
||||
}
|
||||
|
||||
private ArrayList<Class<?extends Mob>> mobsToSpawn = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public Mob createMob() {
|
||||
if (mobsToSpawn == null || mobsToSpawn.isEmpty())
|
||||
mobsToSpawn = Bestiary.getMobRotation(Dungeon.depth);
|
||||
|
||||
try {
|
||||
return mobsToSpawn.remove(0).newInstance();
|
||||
} catch (Exception e) {
|
||||
ShatteredPixelDungeon.reportException(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createMobs() {
|
||||
//on floor 1, 10 rats are created so the player can get level 2.
|
||||
|
@ -215,7 +231,7 @@ public abstract class RegularLevel extends Level {
|
|||
stdRoomIter = stdRooms.iterator();
|
||||
Room roomToSpawn = stdRoomIter.next();
|
||||
|
||||
Mob mob = Bestiary.mob( Dungeon.depth );
|
||||
Mob mob = createMob();
|
||||
mob.pos = pointToCell(roomToSpawn.random());
|
||||
|
||||
if (findMob(mob.pos) == null && Level.passable[mob.pos]) {
|
||||
|
@ -224,7 +240,7 @@ public abstract class RegularLevel extends Level {
|
|||
|
||||
//TODO: perhaps externalize this logic into a method. Do I want to make mobs more likely to clump deeper down?
|
||||
if (mobsToSpawn > 0 && Random.Int(4) == 0){
|
||||
mob = Bestiary.mob( Dungeon.depth );
|
||||
mob = createMob();
|
||||
mob.pos = pointToCell(roomToSpawn.random());
|
||||
|
||||
if (findMob(mob.pos) == null && Level.passable[mob.pos]) {
|
||||
|
@ -420,6 +436,7 @@ public abstract class RegularLevel extends Level {
|
|||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle( bundle );
|
||||
bundle.put( "rooms", rooms );
|
||||
bundle.put( "mobs_to_spawn", mobsToSpawn.toArray(new Class[0]));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -436,6 +453,12 @@ public abstract class RegularLevel extends Level {
|
|||
roomExit = r;
|
||||
}
|
||||
}
|
||||
|
||||
if (bundle.contains( "mobs_to_spawn" )) {
|
||||
for (Class<? extends Mob> mob : bundle.getClassArray("mobs_to_spawn")) {
|
||||
if (mob != null) mobsToSpawn.add(mob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,10 +22,8 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.levels;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Bones;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bestiary;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Goo;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.Builder;
|
||||
|
@ -115,13 +113,13 @@ public class SewerBossLevel extends SewerLevel {
|
|||
|
||||
@Override
|
||||
protected void createMobs() {
|
||||
Mob mob = Bestiary.mob( Dungeon.depth );
|
||||
Goo boss = new Goo();
|
||||
Room room;
|
||||
do {
|
||||
room = randomRoom(StandardRoom.class);
|
||||
} while (room == roomEntrance);
|
||||
mob.pos = pointToCell(room.random());
|
||||
mobs.add( mob );
|
||||
boss.pos = pointToCell(room.random());
|
||||
mobs.add( boss );
|
||||
}
|
||||
|
||||
public Actor respawner() {
|
||||
|
|
|
@ -23,7 +23,6 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.traps;
|
|||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bestiary;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
|
@ -78,7 +77,7 @@ public class SummoningTrap extends Trap {
|
|||
ArrayList<Mob> mobs = new ArrayList<>();
|
||||
|
||||
for (Integer point : respawnPoints) {
|
||||
Mob mob = Bestiary.mob( Dungeon.depth );
|
||||
Mob mob = Dungeon.level.createMob();
|
||||
mob.state = mob.WANDERING;
|
||||
mob.pos = point;
|
||||
GameScene.add( mob, DELAY );
|
||||
|
|
Loading…
Reference in New Issue
Block a user