mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
More rtsim monsters
This commit is contained in:
parent
6fbd007cea
commit
2ff0118df0
@ -1,4 +1,11 @@
|
||||
body-generic = creature
|
||||
body-biped_large-ogre = ogre
|
||||
body-biped_large-cyclops = cyclops
|
||||
body-biped_large-wendigo = wendigo
|
||||
body-biped_large-werewolf = werewolf
|
||||
body-biped_large-cave_troll = cave troll
|
||||
body-biped_large-mountain_troll = mountain troll
|
||||
body-biped_large-swamp_troll = swamp troll
|
||||
body-biped_large-blue_oni = blue oni
|
||||
body-biped_large-red_oni = red oni
|
||||
body-biped_large-tursus = tursus
|
||||
|
@ -26,9 +26,16 @@ impl Body {
|
||||
|
||||
pub fn localize(&self) -> Content {
|
||||
Content::localized(match &self.species {
|
||||
Species::Ogre => "body-biped_large-ogre",
|
||||
Species::Cyclops => "body-biped_large-cyclops",
|
||||
Species::Wendigo => "body-biped_large-wendigo",
|
||||
Species::Werewolf => "body-biped_large-werewolf",
|
||||
Species::Cavetroll => "body-biped_large-cave_troll",
|
||||
Species::Mountaintroll => "body-biped_large-mountain_troll",
|
||||
Species::Swamptroll => "body-biped_large-swamp_troll",
|
||||
Species::Blueoni => "body-biped_large-blue_oni",
|
||||
Species::Redoni => "body-biped_large-red_oni",
|
||||
Species::Tursus => "body-biped_large-tursus",
|
||||
_ => "body-generic",
|
||||
})
|
||||
}
|
||||
|
@ -290,8 +290,11 @@ pub enum ChunkResource {
|
||||
// identifiers for the sake of rtsim persistence
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum Role {
|
||||
#[serde(rename = "0")]
|
||||
Civilised(Option<Profession>),
|
||||
#[serde(rename = "1")]
|
||||
Wild,
|
||||
#[serde(rename = "2")]
|
||||
Monster,
|
||||
}
|
||||
|
||||
|
@ -13,13 +13,13 @@ use common::{
|
||||
grid::Grid,
|
||||
resources::TimeOfDay,
|
||||
rtsim::{Personality, Role, WorldSettings},
|
||||
terrain::{CoordinateConversions, TerrainChunkSize},
|
||||
terrain::{BiomeKind, CoordinateConversions, TerrainChunkSize},
|
||||
vol::RectVolSize,
|
||||
};
|
||||
use rand::prelude::*;
|
||||
use tracing::info;
|
||||
use vek::*;
|
||||
use world::{site::SiteKind, site2::PlotKind, IndexRef, World};
|
||||
use world::{site::SiteKind, site2::PlotKind, IndexRef, World, CONFIG};
|
||||
|
||||
impl Data {
|
||||
pub fn generate(settings: &WorldSettings, world: &World, index: IndexRef) -> Self {
|
||||
@ -224,21 +224,35 @@ impl Data {
|
||||
// Spawn monsters into the world
|
||||
for _ in 0..100 {
|
||||
// Try a few times to find a location that's not underwater
|
||||
if let Some(wpos) = (0..10)
|
||||
if let Some((wpos, chunk)) = (0..10)
|
||||
.map(|_| world.sim().get_size().map(|sz| rng.gen_range(0..sz as i32)))
|
||||
.find(|pos| world.sim().get(*pos).map_or(false, |c| !c.is_underwater()))
|
||||
.map(|pos| {
|
||||
.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))
|
||||
(
|
||||
wpos2d
|
||||
.map(|e| e as f32 + 0.5)
|
||||
.with_z(world.sim().get_alt_approx(wpos2d).unwrap_or(0.0)),
|
||||
chunk,
|
||||
)
|
||||
})
|
||||
{
|
||||
let species = match rng.gen_range(0..3) {
|
||||
0 => comp::body::biped_large::Species::Cyclops,
|
||||
1 => comp::body::biped_large::Species::Wendigo,
|
||||
_ => comp::body::biped_large::Species::Werewolf,
|
||||
};
|
||||
let biome = chunk.get_biome();
|
||||
let Some(species) = [
|
||||
Some(comp::body::biped_large::Species::Ogre),
|
||||
Some(comp::body::biped_large::Species::Cyclops),
|
||||
Some(comp::body::biped_large::Species::Wendigo).filter(|_| biome == BiomeKind::Taiga),
|
||||
Some(comp::body::biped_large::Species::Cavetroll),
|
||||
Some(comp::body::biped_large::Species::Mountaintroll).filter(|_| biome == BiomeKind::Mountain),
|
||||
Some(comp::body::biped_large::Species::Swamptroll).filter(|_| biome == BiomeKind::Swamp),
|
||||
Some(comp::body::biped_large::Species::Blueoni),
|
||||
Some(comp::body::biped_large::Species::Redoni),
|
||||
Some(comp::body::biped_large::Species::Tursus).filter(|_| chunk.temp < CONFIG.snow_temp),
|
||||
]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.choose(&mut rng)
|
||||
else { continue };
|
||||
|
||||
this.npcs.create_npc(Npc::new(
|
||||
rng.gen(),
|
||||
|
@ -170,12 +170,23 @@ fn get_npc_entity_info(npc: &Npc, sites: &Sites, index: IndexRef) -> EntityInfo
|
||||
_ => unimplemented!(),
|
||||
},
|
||||
Body::BipedLarge(body) => match body.species {
|
||||
comp::biped_large::Species::Ogre => "common.entity.wild.aggressive.ogre",
|
||||
comp::biped_large::Species::Cyclops => "common.entity.wild.aggressive.cyclops",
|
||||
comp::biped_large::Species::Wendigo => "common.entity.wild.aggressive.wendigo",
|
||||
comp::biped_large::Species::Werewolf => "common.entity.wild.aggressive.werewolf",
|
||||
_ => unimplemented!(),
|
||||
comp::biped_large::Species::Cavetroll => "common.entity.wild.aggressive.cave_troll",
|
||||
comp::biped_large::Species::Mountaintroll => {
|
||||
"common.entity.wild.aggressive.mountain_troll"
|
||||
},
|
||||
comp::biped_large::Species::Swamptroll => {
|
||||
"common.entity.wild.aggressive.swamp_troll"
|
||||
},
|
||||
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",
|
||||
species => unimplemented!("rtsim spawning for {:?}", species),
|
||||
},
|
||||
_ => unimplemented!(),
|
||||
body => unimplemented!("rtsim spawning for {:?}", body),
|
||||
};
|
||||
let entity_config = EntityConfig::from_asset_expect_owned(config_asset)
|
||||
.with_body(BodyBuilder::Exact(npc.body));
|
||||
|
Loading…
Reference in New Issue
Block a user