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,
|
||||
|
||||
+35
-6
@@ -21,15 +21,44 @@
|
||||
|
||||
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 class MobSpawner extends Actor {
|
||||
{
|
||||
actPriority = BUFF_PRIO; //as if it were a buff.
|
||||
}
|
||||
|
||||
public static ArrayList<Class<? extends Mob>> getMobRotation( int depth ){
|
||||
@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);
|
||||
@@ -211,9 +240,9 @@ public class Bestiary {
|
||||
}
|
||||
|
||||
//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){
|
||||
|
||||
+2
-2
@@ -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