v2.3.0: code refactoring and improved enemy spawn spread in caves quest

This commit is contained in:
Evan Debenham
2023-11-06 17:07:27 -05:00
parent e3b72f1273
commit 268b804ac6
6 changed files with 35 additions and 11 deletions

View File

@@ -125,7 +125,7 @@ public abstract class RegularLevel extends Level {
do {
s = StandardRoom.createRoom();
} while (!s.setSizeCat( standards-i ));
i += s.sizeCat.roomValue-1;
i += s.sizeFactor()-1;
initRooms.add(s);
}
@@ -213,7 +213,7 @@ public abstract class RegularLevel extends Level {
ArrayList<Room> stdRooms = new ArrayList<>();
for (Room room : rooms) {
if (room instanceof StandardRoom && room != roomEntrance) {
for (int i = 0; i < ((StandardRoom) room).sizeCat.roomValue; i++) {
for (int i = 0; i < ((StandardRoom) room).mobSpawnWeight(); i++) {
stdRooms.add(room);
}
}

View File

@@ -123,7 +123,7 @@ public abstract class RegularBuilder extends Builder {
while (roomsOnMainPath > 0 && !multiConnections.isEmpty()){
Room r = multiConnections.remove(0);
if (r instanceof StandardRoom){
roomsOnMainPath -= ((StandardRoom) r).sizeCat.roomValue;
roomsOnMainPath -= ((StandardRoom) r).sizeFactor();
} else {
roomsOnMainPath--;
}
@@ -136,7 +136,7 @@ public abstract class RegularBuilder extends Builder {
protected void weightRooms(ArrayList<Room> rooms){
for (Room r : rooms.toArray(new Room[0])){
if (r instanceof StandardRoom){
for (int i = 1; i < ((StandardRoom) r).sizeCat.connectionWeight(); i++)
for (int i = 1; i < ((StandardRoom) r).connectionWeight(); i++)
rooms.add(r);
}
}
@@ -228,7 +228,7 @@ public abstract class RegularBuilder extends Builder {
}
if (r.maxConnections(Room.ALL) > 1 && Random.Int(3) == 0) {
if (r instanceof StandardRoom){
for (int j = 0; j < ((StandardRoom) r).sizeCat.connectionWeight(); j++){
for (int j = 0; j < ((StandardRoom) r).connectionWeight(); j++){
branchable.add(r);
}
} else {

View File

@@ -47,6 +47,13 @@ public class MineGiantRoom extends CaveRoom {
return 0.70f;
}
@Override
public int mobSpawnWeight() {
//This room contains the boss
// so don't amp up regular enemy spawns too
return 1;
}
@Override
public void paint(Level level) {
super.paint(level);

View File

@@ -61,6 +61,13 @@ public class MineLargeRoom extends CaveRoom {
return 0.55f;
}
@Override
public int mobSpawnWeight() {
//These rooms always spawn their own enemies
// so don't amp up regular enemy spawns too
return 1;
}
@Override
public void paint(Level level) {
super.paint(level);

View File

@@ -87,7 +87,7 @@ public class CavesFissureRoom extends StandardRoom {
//generate angles for 2-4 fissure lines, they can't be too close to doors or eachother
ArrayList<Float> lineAngles = new ArrayList<>();
int numLines = 1 + sizeCat.roomValue;
int numLines = 1 + sizeFactor();
for (int i = 0; i < numLines; i++) {
int tries = 100;
boolean valid;
@@ -190,7 +190,7 @@ public class CavesFissureRoom extends StandardRoom {
buildBridge(level, Random.element(lineAngles), center, 1);
} else {
for (float angle : lineAngles) {
buildBridge(level, angle, center, sizeCat.roomValue);
buildBridge(level, angle, center, sizeFactor());
}
}

View File

@@ -48,10 +48,6 @@ public abstract class StandardRoom extends Room {
roomValue = val;
}
public int connectionWeight(){
return roomValue*roomValue;
}
}
public SizeCategory sizeCat;
@@ -101,6 +97,20 @@ public abstract class StandardRoom extends Room {
public int minHeight() { return sizeCat.minDim; }
public int maxHeight() { return sizeCat.maxDim; }
//larger standard rooms generally count as multiple rooms for various counting/weighting purposes
//but there can be exceptions
public int sizeFactor(){
return sizeCat.roomValue;
}
public int mobSpawnWeight(){
return sizeFactor();
}
public int connectionWeight(){
return sizeFactor() * sizeFactor();
}
@Override
public boolean canMerge(Level l, Point p, int mergeTerrain) {
int cell = l.pointToCell(pointInside(p, 1));