v0.8.0: added a system for dynamic mob spawning weights
This commit is contained in:
parent
a9794a6ab0
commit
ee6a1ce4fc
|
@ -66,7 +66,12 @@ public class Ghoul extends Mob {
|
||||||
public int drRoll() {
|
public int drRoll() {
|
||||||
return Random.NormalIntRange(0, 4);
|
return Random.NormalIntRange(0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float spawningWeight() {
|
||||||
|
return 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
private int partnerID = -1;
|
private int partnerID = -1;
|
||||||
private static final String PARTNER_ID = "partner_id";
|
private static final String PARTNER_ID = "partner_id";
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,12 @@ public class Mimic extends Mob {
|
||||||
}
|
}
|
||||||
super.rollToDropLoot();
|
super.rollToDropLoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float spawningWeight() {
|
||||||
|
return 0f;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean reset() {
|
public boolean reset() {
|
||||||
state = WANDERING;
|
state = WANDERING;
|
||||||
|
|
|
@ -671,6 +671,11 @@ public abstract class Mob extends Char {
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//how many mobs this one should count as when determining spawning totals
|
||||||
|
public float spawningWeight(){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean reset() {
|
public boolean reset() {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -104,7 +104,12 @@ public class Piranha extends Mob {
|
||||||
Statistics.piranhasKilled++;
|
Statistics.piranhasKilled++;
|
||||||
Badges.validatePiranhasKilled();
|
Badges.validatePiranhasKilled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float spawningWeight() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean reset() {
|
public boolean reset() {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -140,7 +140,12 @@ public class Statue extends Mob {
|
||||||
Notes.remove( Notes.Landmark.STATUE );
|
Notes.remove( Notes.Landmark.STATUE );
|
||||||
super.destroy();
|
super.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float spawningWeight() {
|
||||||
|
return 0f;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean reset() {
|
public boolean reset() {
|
||||||
state = PASSIVE;
|
state = PASSIVE;
|
||||||
|
|
|
@ -84,6 +84,11 @@ public class Wraith extends Mob {
|
||||||
enemySeen = true;
|
enemySeen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float spawningWeight() {
|
||||||
|
return 0f;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean reset() {
|
public boolean reset() {
|
||||||
state = WANDERING;
|
state = WANDERING;
|
||||||
|
|
|
@ -492,11 +492,12 @@ public abstract class Level implements Bundlable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean act() {
|
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])){
|
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()) {
|
if (count < nMobs()) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user