v0.8.0: added a system for dynamic mob spawning weights

This commit is contained in:
Evan Debenham 2019-11-30 14:26:21 -05:00
parent a9794a6ab0
commit ee6a1ce4fc
7 changed files with 38 additions and 7 deletions

View File

@ -66,7 +66,12 @@ public class Ghoul extends Mob {
public int drRoll() {
return Random.NormalIntRange(0, 4);
}
@Override
public float spawningWeight() {
return 0.5f;
}
private int partnerID = -1;
private static final String PARTNER_ID = "partner_id";

View File

@ -108,7 +108,12 @@ public class Mimic extends Mob {
}
super.rollToDropLoot();
}
@Override
public float spawningWeight() {
return 0f;
}
@Override
public boolean reset() {
state = WANDERING;

View File

@ -671,6 +671,11 @@ public abstract class Mob extends Char {
}
return item;
}
//how many mobs this one should count as when determining spawning totals
public float spawningWeight(){
return 1;
}
public boolean reset() {
return false;

View File

@ -104,7 +104,12 @@ public class Piranha extends Mob {
Statistics.piranhasKilled++;
Badges.validatePiranhasKilled();
}
@Override
public float spawningWeight() {
return 0;
}
@Override
public boolean reset() {
return true;

View File

@ -140,7 +140,12 @@ public class Statue extends Mob {
Notes.remove( Notes.Landmark.STATUE );
super.destroy();
}
@Override
public float spawningWeight() {
return 0f;
}
@Override
public boolean reset() {
state = PASSIVE;

View File

@ -84,6 +84,11 @@ public class Wraith extends Mob {
enemySeen = true;
}
@Override
public float spawningWeight() {
return 0f;
}
@Override
public boolean reset() {
state = WANDERING;

View File

@ -492,11 +492,12 @@ public abstract class Level implements Bundlable {
@Override
protected boolean act() {
int count = 0;
float count = 0;
//TODO some mobs should count for less (ripper shouldn't count at all, ghouls should be 1/2, special enemies should be 0
for (Mob mob : mobs.toArray(new Mob[0])){
if (mob.alignment == Char.Alignment.ENEMY) count++;
if (mob.alignment == Char.Alignment.ENEMY && !mob.properties().contains(Char.Property.MINIBOSS)) {
count += mob.spawningWeight();
}
}
if (count < nMobs()) {