balancing and const usage for gnarling spawns

This commit is contained in:
horblegorble 2024-07-09 19:11:29 +10:00
parent 554e8be88d
commit 186aea08fc

View File

@ -336,6 +336,7 @@ impl GnarlingFortification {
max: rpos + TerrainChunkSize::RECT_SIZE.map(|e| e as i32),
};
// tunnel junctions
for terminal in &self.tunnels.terminals {
if area.contains_point(terminal.xy() - self.origin) {
let chance = dynamic_rng.gen_range(0..10);
@ -362,6 +363,8 @@ impl GnarlingFortification {
}
}
}
// harvester room
if area.contains_point(self.tunnels.end.xy() - self.origin) {
let boss_room_offset = (self.tunnels.end.xy() - self.tunnels.start.xy())
.map(|e| if e < 0 { -20 } else { 20 });
@ -371,27 +374,32 @@ impl GnarlingFortification {
));
}
// above-ground structures
for (loc, pos, _ori) in &self.structure_locations {
let wpos = *pos + self.origin;
if area.contains_point(pos.xy()) {
match loc {
GnarlingStructure::Hut => {
let num = dynamic_rng.gen_range(1..=2);
for _ in 0..num {
const NUM_HUT_GNARLINGS: [i32; 2] = [1, 2];
let num =
dynamic_rng.gen_range(NUM_HUT_GNARLINGS[0]..=NUM_HUT_GNARLINGS[1]);
for _ in 1..=num {
supplement.add_entity(random_gnarling(wpos, dynamic_rng));
}
},
GnarlingStructure::VeloriteHut => {
const NUM_VELO_GNARLINGS: i32 = 4;
const GOLEM_SPAWN_THRESHOLD: i32 = 2;
const VELO_HEIGHT: i32 = 12;
const GROUND_HEIGHT: i32 = 8;
let num = dynamic_rng.gen_range(1..=4);
for _ in 0..num {
let num = dynamic_rng.gen_range(1..=NUM_VELO_GNARLINGS);
for _ in 1..=num {
supplement.add_entity(random_gnarling(
wpos.xy().with_z(wpos.z + VELO_HEIGHT),
dynamic_rng,
));
}
if num < 3 {
if num <= GOLEM_SPAWN_THRESHOLD {
// wooden golem (with oriented spawn)
let x_offset;
let y_offset;
@ -427,9 +435,9 @@ impl GnarlingFortification {
const FLOOR_HEIGHT: i32 = 8;
let pos = wpos.xy().with_z(wpos.z + FLOOR_HEIGHT);
supplement.add_entity(gnarling_chieftain(pos, dynamic_rng));
for _ in 0..4 {
supplement.add_entity(random_gnarling(pos, dynamic_rng));
}
supplement.add_entity(gnarling_logger(pos, dynamic_rng));
supplement.add_entity(gnarling_mugger(pos, dynamic_rng));
supplement.add_entity(gnarling_stalker(pos, dynamic_rng));
// hut corner posts
const CORNER_HEIGHT: i32 = 10;
const CORNER_OFFSET: i32 = 18;
@ -446,6 +454,7 @@ impl GnarlingFortification {
}
}
// hut sides on ground (using orientation)
const NUM_SIDE_GNARLINGS: i32 = 2;
const GROUND_HEIGHT: i32 = 4;
const GROUND_OFFSET: i32 = 24;
let height = wpos.z + GROUND_HEIGHT;
@ -462,16 +471,17 @@ impl GnarlingFortification {
(pos_ori, pos_xori) = (pos_xori, pos_ori);
}
supplement.add_entity(wood_golem(pos_ori, dynamic_rng));
for _ in 0..3 {
supplement.add_entity(random_gnarling(pos_xori, dynamic_rng));
for _ in 1..=NUM_SIDE_GNARLINGS {
supplement.add_entity(melee_gnarling(pos_xori, dynamic_rng));
}
}
},
GnarlingStructure::WatchTower => {
const NUM_WATCHTOWER_STALKERS: i32 = 2;
const FLOOR_HEIGHT: i32 = 27;
supplement.add_entity(wood_golem(wpos, dynamic_rng));
let spawn_pos = wpos.xy().with_z(wpos.z + 27);
let num = dynamic_rng.gen_range(2..=4);
for _ in 0..num {
let spawn_pos = wpos.xy().with_z(wpos.z + FLOOR_HEIGHT);
for _ in 1..=NUM_WATCHTOWER_STALKERS {
supplement.add_entity(gnarling_stalker(
spawn_pos + Vec2::broadcast(4),
dynamic_rng,
@ -483,12 +493,19 @@ impl GnarlingFortification {
}
}
// wall towers
for pos in &self.wall_towers {
const NUM_WALLTOWER_STALKERS: [i32; 2] = [1, 3];
const FLOOR_HEIGHT: i32 = 27;
let wpos = *pos + self.origin;
if area.contains_point(pos.xy()) {
for _ in 0..4 {
supplement
.add_entity(gnarling_stalker(wpos.xy().with_z(wpos.z + 21), dynamic_rng))
let num =
dynamic_rng.gen_range(NUM_WALLTOWER_STALKERS[0]..=NUM_WALLTOWER_STALKERS[1]);
for _ in 1..=num {
supplement.add_entity(gnarling_stalker(
wpos.xy().with_z(wpos.z + FLOOR_HEIGHT),
dynamic_rng,
))
}
}
}
@ -1971,6 +1988,13 @@ fn random_gnarling<R: Rng>(pos: Vec3<i32>, rng: &mut R) -> EntityInfo {
}
}
fn melee_gnarling<R: Rng>(pos: Vec3<i32>, rng: &mut R) -> EntityInfo {
match rng.gen_range(0..2) {
0 => gnarling_mugger(pos, rng),
_ => gnarling_logger(pos, rng),
}
}
fn gnarling_chieftain<R: Rng>(pos: Vec3<i32>, rng: &mut R) -> EntityInfo {
EntityInfo::at(pos.map(|x| x as f32))
.with_asset_expect("common.entity.dungeon.gnarling.chieftain", rng, None)