v2.5.0: merged spawning logic into one class (freeing up bestiary)
This commit is contained in:
@@ -48,6 +48,11 @@ public class ShatteredPixelDungeon extends Game {
|
||||
public ShatteredPixelDungeon( PlatformSupport platform ) {
|
||||
super( sceneClass == null ? WelcomeScene.class : sceneClass, platform );
|
||||
|
||||
//pre-v2.5.0
|
||||
com.watabou.utils.Bundle.addAlias(
|
||||
com.shatteredpixel.shatteredpixeldungeon.actors.mobs.MobSpawner.class,
|
||||
"com.shatteredpixel.shatteredpixeldungeon.levels.Level$Respawner" );
|
||||
|
||||
//pre-v2.4.0
|
||||
com.watabou.utils.Bundle.addAlias(
|
||||
com.shatteredpixel.shatteredpixeldungeon.items.potions.brews.UnstableBrew.class,
|
||||
|
||||
@@ -21,26 +21,55 @@
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.actors.mobs;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.RatSkull;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Bestiary {
|
||||
|
||||
public static ArrayList<Class<? extends Mob>> getMobRotation( int depth ){
|
||||
public class MobSpawner extends Actor {
|
||||
{
|
||||
actPriority = BUFF_PRIO; //as if it were a buff.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean act() {
|
||||
|
||||
if (Dungeon.level.mobCount() < Dungeon.level.mobLimit()) {
|
||||
|
||||
if (Dungeon.level.spawnMob(12)){
|
||||
spend(Dungeon.level.respawnCooldown());
|
||||
} else {
|
||||
//try again in 1 turn
|
||||
spend(TICK);
|
||||
}
|
||||
|
||||
} else {
|
||||
spend(Dungeon.level.respawnCooldown());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void resetCooldown(){
|
||||
spend(-cooldown());
|
||||
spend(Dungeon.level.respawnCooldown());
|
||||
}
|
||||
|
||||
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:
|
||||
//3x rat, 1x snake
|
||||
@@ -65,7 +94,7 @@ public class Bestiary {
|
||||
Swarm.class,
|
||||
Crab.class, Crab.class,
|
||||
Slime.class, Slime.class));
|
||||
|
||||
|
||||
// Prison
|
||||
case 6:
|
||||
//3x skeleton, 1x thief, 1x swarm
|
||||
@@ -92,7 +121,7 @@ public class Bestiary {
|
||||
DM100.class, DM100.class,
|
||||
Guard.class, Guard.class,
|
||||
Necromancer.class, Necromancer.class));
|
||||
|
||||
|
||||
// Caves
|
||||
case 11:
|
||||
//3x bat, 1x brute, 1x shaman
|
||||
@@ -123,7 +152,7 @@ public class Bestiary {
|
||||
Shaman.random(), Shaman.random(),
|
||||
Spinner.class, Spinner.class,
|
||||
DM200.class, DM200.class));
|
||||
|
||||
|
||||
// City
|
||||
case 16:
|
||||
//3x ghoul, 1x elemental, 1x warlock
|
||||
@@ -153,7 +182,7 @@ public class Bestiary {
|
||||
Warlock.class, Warlock.class,
|
||||
Monk.class, Monk.class,
|
||||
Golem.class, Golem.class, Golem.class));
|
||||
|
||||
|
||||
// Halls
|
||||
case 21:
|
||||
//2x succubus, 1x evil eye
|
||||
@@ -178,42 +207,42 @@ public class Bestiary {
|
||||
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.025f) rotation.add(Thief.class);
|
||||
return;
|
||||
|
||||
|
||||
// Prison
|
||||
case 9:
|
||||
if (Random.Float() < 0.025f) rotation.add(Bat.class);
|
||||
return;
|
||||
|
||||
|
||||
// Caves
|
||||
case 14:
|
||||
if (Random.Float() < 0.025f) rotation.add(Ghoul.class);
|
||||
return;
|
||||
|
||||
|
||||
// City
|
||||
case 19:
|
||||
if (Random.Float() < 0.025f) rotation.add(Succubus.class);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//switches out regular mobs for their alt versions when appropriate
|
||||
private static void swapMobAlts(ArrayList<Class<?extends Mob>> rotation){
|
||||
float altChance = 1/50f * RatSkull.exoticChanceMultiplier();
|
||||
for (int i = 0; i < rotation.size(); i++){
|
||||
private static void swapMobAlts(ArrayList<Class<?extends Mob>> rotation) {
|
||||
float altChance = 1 / 50f * RatSkull.exoticChanceMultiplier();
|
||||
for (int i = 0; i < rotation.size(); i++) {
|
||||
if (Random.Float() < altChance) {
|
||||
Class<? extends Mob> cl = rotation.get(i);
|
||||
if (cl == Rat.class) {
|
||||
@@ -222,7 +251,7 @@ public class Bestiary {
|
||||
cl = CausticSlime.class;
|
||||
} else if (cl == Thief.class) {
|
||||
cl = Bandit.class;
|
||||
} else if (cl == Necromancer.class){
|
||||
} else if (cl == Necromancer.class) {
|
||||
cl = SpectralNecromancer.class;
|
||||
} else if (cl == Brute.class) {
|
||||
cl = ArmoredBrute.class;
|
||||
@@ -47,10 +47,10 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.abilities.huntress.SpiritHawk;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bestiary;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.GnollGeomancer;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.MobSpawner;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Piranha;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.YogFist;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith;
|
||||
@@ -68,10 +68,10 @@ import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfEnchantment;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfIntuition;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.DimensionalSundial;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.EyeOfNewt;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.MimicTooth;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.MossyClump;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.DimensionalSundial;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.TrapMechanism;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.TrinketCatalyst;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfRegrowth;
|
||||
@@ -430,7 +430,7 @@ public abstract class Level implements Bundlable {
|
||||
}
|
||||
|
||||
if (bundle.contains( "respawner" )){
|
||||
respawner = (Respawner) bundle.get("respawner");
|
||||
respawner = (MobSpawner) bundle.get("respawner");
|
||||
}
|
||||
|
||||
buildFlagMaps();
|
||||
@@ -490,7 +490,7 @@ public abstract class Level implements Bundlable {
|
||||
|
||||
public Mob createMob() {
|
||||
if (mobsToSpawn == null || mobsToSpawn.isEmpty()) {
|
||||
mobsToSpawn = Bestiary.getMobRotation(Dungeon.depth);
|
||||
mobsToSpawn = MobSpawner.getMobRotation(Dungeon.depth);
|
||||
}
|
||||
|
||||
Mob m = Reflection.newInstance(mobsToSpawn.remove(0));
|
||||
@@ -671,11 +671,11 @@ public abstract class Level implements Bundlable {
|
||||
return null;
|
||||
}
|
||||
|
||||
private Respawner respawner;
|
||||
private MobSpawner respawner;
|
||||
|
||||
public Actor addRespawner() {
|
||||
if (respawner == null){
|
||||
respawner = new Respawner();
|
||||
respawner = new MobSpawner();
|
||||
Actor.addDelayed(respawner, respawnCooldown());
|
||||
} else {
|
||||
Actor.add(respawner);
|
||||
@@ -686,36 +686,6 @@ public abstract class Level implements Bundlable {
|
||||
return respawner;
|
||||
}
|
||||
|
||||
public static class Respawner extends Actor {
|
||||
{
|
||||
actPriority = BUFF_PRIO; //as if it were a buff.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean act() {
|
||||
|
||||
if (Dungeon.level.mobCount() < Dungeon.level.mobLimit()) {
|
||||
|
||||
if (Dungeon.level.spawnMob(12)){
|
||||
spend(Dungeon.level.respawnCooldown());
|
||||
} else {
|
||||
//try again in 1 turn
|
||||
spend(TICK);
|
||||
}
|
||||
|
||||
} else {
|
||||
spend(Dungeon.level.respawnCooldown());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void resetCooldown(){
|
||||
spend(-cooldown());
|
||||
spend(Dungeon.level.respawnCooldown());
|
||||
}
|
||||
}
|
||||
|
||||
public float respawnCooldown(){
|
||||
float cooldown;
|
||||
if (Statistics.amuletObtained){
|
||||
|
||||
@@ -29,12 +29,12 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Acidic;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Albino;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.ArmoredBrute;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bandit;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bestiary;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.CausticSlime;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.DM201;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Elemental;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.MobSpawner;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Piranha;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Senior;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue;
|
||||
@@ -111,7 +111,7 @@ public class DistortionTrap extends Trap{
|
||||
do {
|
||||
floor = Random.Int(25);
|
||||
} while( Dungeon.bossLevel(floor));
|
||||
mob = Reflection.newInstance(Bestiary.getMobRotation(floor).get(0));
|
||||
mob = Reflection.newInstance(MobSpawner.getMobRotation(floor).get(0));
|
||||
break;
|
||||
case 2:
|
||||
switch (2){
|
||||
|
||||
Reference in New Issue
Block a user