From 40832456f275c5ffb2d7759a3c407d290f187ee0 Mon Sep 17 00:00:00 2001 From: flo Date: Wed, 31 May 2023 12:31:54 +0000 Subject: [PATCH] spawn frost gigas --- common/src/comp/projectile.rs | 2 +- rtsim/src/gen/mod.rs | 28 ++++++++++++++++++++++++ server/src/events/entity_manipulation.rs | 8 ++++++- server/src/rtsim/tick.rs | 3 +++ server/src/settings.rs | 1 + 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/common/src/comp/projectile.rs b/common/src/comp/projectile.rs index a9441a47b7..2ae448fb44 100644 --- a/common/src/comp/projectile.rs +++ b/common/src/comp/projectile.rs @@ -730,7 +730,7 @@ impl ProjectileConstructor { let explosion = Explosion { effects: vec![ RadiusEffect::Attack(attack), - RadiusEffect::TerrainDestruction(30.0, Rgb::new(255.0, 255.0, 255.0)), + RadiusEffect::TerrainDestruction(30.0, Rgb::new(0.0, 191.0, 255.0)), ], radius, reagent: Some(Reagent::White), diff --git a/rtsim/src/gen/mod.rs b/rtsim/src/gen/mod.rs index 52541cbdd7..bd6cc5ece6 100644 --- a/rtsim/src/gen/mod.rs +++ b/rtsim/src/gen/mod.rs @@ -264,6 +264,34 @@ impl Data { )); } } + // Spawn one monster Gigasfrost into the world + // Try a few times to find a location that's not underwater + if let Some((wpos, chunk)) = (0..10) + .map(|_| world.sim().get_size().map(|sz| rng.gen_range(0..sz as i32))) + .find_map(|pos| Some((pos, world.sim().get(pos).filter(|c| !c.is_underwater())?))) + .map(|(pos, chunk)| { + let wpos2d = pos.cpos_to_wpos_center(); + ( + wpos2d + .map(|e| e as f32 + 0.5) + .with_z(world.sim().get_alt_approx(wpos2d).unwrap_or(0.0)), + chunk, + ) + }) + { + let species = Some(comp::body::biped_large::Species::Gigasfrost) + .filter(|_| chunk.temp < CONFIG.snow_temp) + .unwrap_or(comp::body::biped_large::Species::Gigasfrost); + + this.npcs.create_npc(Npc::new( + rng.gen(), + wpos, + Body::BipedLarge(comp::body::biped_large::Body::random_with( + &mut rng, &species, + )), + Role::Monster, + )); + } info!("Generated {} rtsim NPCs.", this.npcs.len()); diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 6117d2aa6c..e4f5212c43 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -860,7 +860,13 @@ pub fn handle_explosion(server: &Server, pos: Vec3, explosion: Explosion, o for block_pos in touched_blocks { if let Ok(block) = terrain.get(block_pos) { if !matches!(block.kind(), BlockKind::Lava | BlockKind::GlowingRock) - && settings.gameplay.explosion_burn_marks + && ( + // Check that owner is not player or explosion_burn_marks by players + // is enabled + owner_entity + .map_or(true, |e| ecs.read_storage::().get(e).is_none()) + || settings.gameplay.explosion_burn_marks + ) { let diff2 = block_pos.map(|b| b as f32).distance_squared(pos); let fade = (1.0 - diff2 / color_range.powi(2)).max(0.0); diff --git a/server/src/rtsim/tick.rs b/server/src/rtsim/tick.rs index c7793c996e..d91e40f192 100644 --- a/server/src/rtsim/tick.rs +++ b/server/src/rtsim/tick.rs @@ -184,6 +184,9 @@ fn get_npc_entity_info(npc: &Npc, sites: &Sites, index: IndexRef) -> EntityInfo comp::biped_large::Species::Blueoni => "common.entity.wild.aggressive.blue_oni", comp::biped_large::Species::Redoni => "common.entity.wild.aggressive.red_oni", comp::biped_large::Species::Tursus => "common.entity.wild.aggressive.tursus", + comp::biped_large::Species::Gigasfrost => { + "common.entity.world.world_bosses.gigas_frost" + }, species => unimplemented!("rtsim spawning for {:?}", species), }, body => unimplemented!("rtsim spawning for {:?}", body), diff --git a/server/src/settings.rs b/server/src/settings.rs index 5654561b19..1dfcd68f7d 100644 --- a/server/src/settings.rs +++ b/server/src/settings.rs @@ -82,6 +82,7 @@ pub struct GameplaySettings { #[serde(default)] pub battle_mode: ServerBattleMode, #[serde(default)] + // explosion_burn_marks by players pub explosion_burn_marks: bool, }