agent changes, sprite spawning changes, alignment changes

This commit is contained in:
Monty Marz
2020-08-13 21:22:47 +02:00
parent 54cba3e7f9
commit b930c34d89
12 changed files with 143 additions and 59 deletions

View File

@ -357,7 +357,7 @@ magically infused items?"#,
"hud.spell": "Spells", "hud.spell": "Spells",
"hud.free_look_indicator": "Free look active", "hud.free_look_indicator": "Free look active. Press {key} to disable.",
"hud.auto_walk_indicator": "Auto walk active", "hud.auto_walk_indicator": "Auto walk active",
/// End HUD section /// End HUD section
@ -482,7 +482,7 @@ Protection
"You can type /group or /g to only chat with players in your current group.", "You can type /group or /g to only chat with players in your current group.",
"To send private messages type /tell followed by a player name and your message.", "To send private messages type /tell followed by a player name and your message.",
"NPCs with the same level can have a different difficulty.", "NPCs with the same level can have a different difficulty.",
"Look at the ground for food, chests and other loot!", "Keep an eye out for food, chests and other loot spread all around the world!",
"Inventory filled with food? Try crafting better food from it!", "Inventory filled with food? Try crafting better food from it!",
"Wondering what's there to do? Dungeons are marked with brown spots on the map!", "Wondering what's there to do? Dungeons are marked with brown spots on the map!",
"Don't forget to adjust the graphics for your system. Press 'N' to open the settings.", "Don't forget to adjust the graphics for your system. Press 'N' to open the settings.",

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,8 +1,11 @@
use crate::{comp::Body, path::Chaser, sync::Uid}; use crate::{
comp::{critter, humanoid, quadruped_low, quadruped_medium, quadruped_small, Body},
path::Chaser,
sync::Uid,
};
use specs::{Component, Entity as EcsEntity}; use specs::{Component, Entity as EcsEntity};
use specs_idvs::IdvStorage; use specs_idvs::IdvStorage;
use vek::*; use vek::*;
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq)]
pub enum Alignment { pub enum Alignment {
/// Wild animals and gentle giants /// Wild animals and gentle giants
@ -15,6 +18,8 @@ pub enum Alignment {
Tame, Tame,
/// Pets you've tamed with a collar /// Pets you've tamed with a collar
Owned(Uid), Owned(Uid),
/// Passive objects like training dummies
Passive,
} }
impl Alignment { impl Alignment {
@ -22,8 +27,13 @@ impl Alignment {
pub fn hostile_towards(self, other: Alignment) -> bool { pub fn hostile_towards(self, other: Alignment) -> bool {
match (self, other) { match (self, other) {
(Alignment::Enemy, Alignment::Enemy) => false, (Alignment::Enemy, Alignment::Enemy) => false,
(Alignment::Enemy, _) => true, (Alignment::Enemy, Alignment::Wild) => false,
(Alignment::Enemy, Alignment::Tame) => true,
(Alignment::Wild, Alignment::Enemy) => false,
(Alignment::Wild, Alignment::Wild) => false,
(Alignment::Npc, Alignment::Wild) => true,
(_, Alignment::Enemy) => true, (_, Alignment::Enemy) => true,
(Alignment::Enemy, _) => true,
_ => false, _ => false,
} }
} }
@ -35,8 +45,11 @@ impl Alignment {
(Alignment::Owned(a), Alignment::Owned(b)) if a == b => true, (Alignment::Owned(a), Alignment::Owned(b)) if a == b => true,
(Alignment::Npc, Alignment::Npc) => true, (Alignment::Npc, Alignment::Npc) => true,
(Alignment::Npc, Alignment::Tame) => true, (Alignment::Npc, Alignment::Tame) => true,
(Alignment::Enemy, Alignment::Wild) => true,
(Alignment::Wild, Alignment::Enemy) => true,
(Alignment::Tame, Alignment::Npc) => true, (Alignment::Tame, Alignment::Npc) => true,
(Alignment::Tame, Alignment::Tame) => true, (Alignment::Tame, Alignment::Tame) => true,
(_, Alignment::Passive) => true,
_ => false, _ => false,
} }
} }
@ -53,25 +66,73 @@ impl Component for Alignment {
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
pub struct Psyche { pub struct Psyche {
pub aggro: f32, // 0.0 = always flees, 1.0 = always attacks pub aggro: f32, // 0.0 = always flees, 1.0 = always attacks, 0.5 = flee at 50% health
} }
#[allow(unreachable_patterns)]
impl<'a> From<&'a Body> for Psyche { impl<'a> From<&'a Body> for Psyche {
fn from(body: &'a Body) -> Self { fn from(body: &'a Body) -> Self {
Self { Self {
aggro: match body { aggro: match body {
Body::Humanoid(_) => 0.5, Body::Humanoid(humanoid) => match humanoid.species {
Body::QuadrupedSmall(_) => 0.35, humanoid::Species::Danari => 0.9,
Body::QuadrupedMedium(_) => 0.5, humanoid::Species::Dwarf => 0.9,
Body::QuadrupedLow(_) => 0.65, humanoid::Species::Elf => 0.95,
humanoid::Species::Human => 0.95,
humanoid::Species::Orc => 1.0,
humanoid::Species::Undead => 1.0,
_ => 1.0,
},
Body::QuadrupedSmall(quadruped_small) => match quadruped_small.species {
quadruped_small::Species::Pig => 0.8,
quadruped_small::Species::Fox => 0.4,
quadruped_small::Species::Sheep => 0.7,
quadruped_small::Species::Boar => 1.0,
quadruped_small::Species::Jackalope => 0.4,
quadruped_small::Species::Skunk => 0.8,
quadruped_small::Species::Cat => 0.2,
quadruped_small::Species::Batfox => 0.7,
quadruped_small::Species::Raccoon => 0.4,
quadruped_small::Species::Quokka => 0.7,
quadruped_small::Species::Dodarock => 0.9,
quadruped_small::Species::Holladon => 1.0,
quadruped_small::Species::Hyena => 0.4,
quadruped_small::Species::Rabbit => 0.1,
quadruped_small::Species::Truffler => 0.8,
quadruped_small::Species::Frog => 0.6,
_ => 1.0,
},
Body::QuadrupedMedium(quadruped_medium) => match quadruped_medium.species {
quadruped_medium::Species::Tuskram => 0.8,
quadruped_medium::Species::Frostfang => 0.9,
quadruped_medium::Species::Mouflon => 0.8,
quadruped_medium::Species::Catoblepas => 0.8,
_ => 1.0,
},
Body::QuadrupedLow(quadruped_low) => match quadruped_low.species {
quadruped_low::Species::Crocodile => 1.0,
quadruped_low::Species::Alligator => 1.0,
quadruped_low::Species::Salamander => 0.8,
quadruped_low::Species::Monitor => 0.9,
quadruped_low::Species::Asp => 0.9,
quadruped_low::Species::Tortoise => 1.0,
quadruped_low::Species::Rocksnapper => 1.0,
quadruped_low::Species::Pangolin => 0.6,
quadruped_low::Species::Maneater => 1.0,
_ => 1.0,
},
Body::BirdMedium(_) => 1.0, Body::BirdMedium(_) => 1.0,
Body::BirdSmall(_) => 0.2, Body::BirdSmall(_) => 0.4,
Body::FishMedium(_) => 0.15, Body::FishMedium(_) => 0.15,
Body::FishSmall(_) => 0.0, Body::FishSmall(_) => 0.0,
Body::BipedLarge(_) => 1.0, Body::BipedLarge(_) => 1.0,
Body::Object(_) => 0.0, Body::Object(_) => 1.0,
Body::Golem(_) => 1.0, Body::Golem(_) => 1.0,
Body::Critter(_) => 0.1, Body::Critter(critter) => match critter.species {
critter::Species::Axolotl => 1.0,
critter::Species::Turtle => 1.0,
critter::Species::Fungome => 1.0,
_ => 0.4,
},
Body::Dragon(_) => 1.0, Body::Dragon(_) => 1.0,
}, },
} }

View File

@ -624,6 +624,7 @@ fn handle_spawn(
Some(comp::group::NPC) Some(comp::group::NPC)
}, },
comp::Alignment::Owned(_) => unreachable!(), comp::Alignment::Owned(_) => unreachable!(),
_ => None,
} { } {
let _ = let _ =
server.state.ecs().write_storage().insert(new_entity, group); server.state.ecs().write_storage().insert(new_entity, group);

View File

@ -44,6 +44,7 @@ pub fn handle_create_npc(
Alignment::Npc | Alignment::Tame => Some(group::NPC), Alignment::Npc | Alignment::Tame => Some(group::NPC),
// TODO: handle // TODO: handle
Alignment::Owned(_) => None, Alignment::Owned(_) => None,
_ => None,
}; };
let entity = server let entity = server

View File

@ -2109,20 +2109,36 @@ impl Hud {
} }
// Free look indicator // Free look indicator
if self.show.free_look { if let Some(freelook_key) = global_state
Text::new(&self.voxygen_i18n.get("hud.free_look_indicator")) .settings
.controls
.get_binding(GameInput::FreeLook)
{
if self.show.free_look {
Text::new(
&self
.voxygen_i18n
.get("hud.free_look_indicator")
.replace("{key}", freelook_key.to_string().as_str()),
)
.color(TEXT_BG) .color(TEXT_BG)
.mid_top_with_margin_on(ui_widgets.window, 100.0) .mid_top_with_margin_on(ui_widgets.window, 130.0)
.font_id(self.fonts.cyri.conrod_id) .font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(20)) .font_size(self.fonts.cyri.scale(20))
.set(self.ids.free_look_bg, ui_widgets); .set(self.ids.free_look_bg, ui_widgets);
Text::new(&self.voxygen_i18n.get("hud.free_look_indicator")) Text::new(
&self
.voxygen_i18n
.get("hud.free_look_indicator")
.replace("{key}", freelook_key.to_string().as_str()),
)
.color(KILL_COLOR) .color(KILL_COLOR)
.top_left_with_margins_on(self.ids.free_look_bg, -1.0, -1.0) .top_left_with_margins_on(self.ids.free_look_bg, -1.0, -1.0)
.font_id(self.fonts.cyri.conrod_id) .font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(20)) .font_size(self.fonts.cyri.scale(20))
.set(self.ids.free_look_txt, ui_widgets); .set(self.ids.free_look_txt, ui_widgets);
} }
};
// Auto walk indicator // Auto walk indicator
if self.show.auto_walk { if self.show.auto_walk {

View File

@ -61,20 +61,20 @@ pub fn apply_scatter_to<'a>(
) )
}), }),
(Twigs, false, |c| { (Twigs, false, |c| {
((c.tree_density - 0.5).max(0.0) * 0.001, None) ((c.tree_density - 0.5).max(0.0) * 0.00001, None)
}), }),
(Stones, false, |c| { (Stones, false, |c| {
((c.rockiness - 0.5).max(0.0) * 0.0008, None) ((c.rockiness - 0.5).max(0.0) * 0.00001, None)
}), }),
(ShortGrass, false, |c| { (ShortGrass, false, |c| {
( (
close(c.temp, 0.3, 0.4).min(close(c.humidity, 0.6, 0.35)) * 0.05, close(c.temp, 0.3, 0.4).min(close(c.humidity, 0.6, 0.35)) * 0.09,
Some((48.0, 0.4)), Some((48.0, 0.4)),
) )
}), }),
(Mushroom, false, |c| { (Mushroom, false, |c| {
( (
close(c.temp, 0.3, 0.4).min(close(c.humidity, 0.6, 0.35)) * 0.04, close(c.temp, 0.3, 0.4).min(close(c.humidity, 0.6, 0.35)) * 0.00001,
None, None,
) )
}), }),
@ -375,56 +375,45 @@ pub fn apply_caves_supplement<'a>(
let difficulty = cave_depth / 200.0; let difficulty = cave_depth / 200.0;
// Scatter things in caves // Scatter things in caves
if RandomField::new(index.seed).chance(wpos2d.into(), 0.00005 * difficulty) if RandomField::new(index.seed).chance(wpos2d.into(), 0.000005 * difficulty)
&& cave_base < surface_z as i32 - 40 && cave_base < surface_z as i32 - 40
{ {
let is_hostile: bool;
let entity = EntityInfo::at(Vec3::new( let entity = EntityInfo::at(Vec3::new(
wpos2d.x as f32, wpos2d.x as f32,
wpos2d.y as f32, wpos2d.y as f32,
cave_base as f32, cave_base as f32,
)) ))
.with_alignment(comp::Alignment::Enemy)
.with_body(match rng.gen_range(0, 6) { .with_body(match rng.gen_range(0, 6) {
0 => { 0 => {
let species = match rng.gen_range(0, 2) { is_hostile = false;
let species = match rng.gen_range(0, 4) {
0 => comp::quadruped_small::Species::Truffler, 0 => comp::quadruped_small::Species::Truffler,
_ => comp::quadruped_small::Species::Hyena, 1 => comp::quadruped_small::Species::Dodarock,
2 => comp::quadruped_small::Species::Holladon,
_ => comp::quadruped_small::Species::Batfox,
}; };
comp::quadruped_small::Body::random_with(rng, &species).into() comp::quadruped_small::Body::random_with(rng, &species).into()
}, },
1 => { 1 => {
let species = match rng.gen_range(0, 3) { is_hostile = false;
let species = match rng.gen_range(0, 5) {
0 => comp::quadruped_medium::Species::Tarasque, 0 => comp::quadruped_medium::Species::Tarasque,
1 => comp::quadruped_medium::Species::Frostfang,
_ => comp::quadruped_medium::Species::Bonerattler, _ => comp::quadruped_medium::Species::Bonerattler,
}; };
comp::quadruped_medium::Body::random_with(rng, &species).into() comp::quadruped_medium::Body::random_with(rng, &species).into()
}, },
2 => { 2 => {
let species = match rng.gen_range(0, 3) { is_hostile = false;
0 => comp::quadruped_low::Species::Maneater, let species = match rng.gen_range(0, 4) {
1 => comp::quadruped_low::Species::Rocksnapper, 1 => comp::quadruped_low::Species::Rocksnapper,
_ => comp::quadruped_low::Species::Salamander, _ => comp::quadruped_low::Species::Salamander,
}; };
comp::quadruped_low::Body::random_with(rng, &species).into() comp::quadruped_low::Body::random_with(rng, &species).into()
}, },
3 => { 3 => {
let species = match rng.gen_range(0, 3) { is_hostile = true;
0 => comp::critter::Species::Fungome, let species = match rng.gen_range(0, 8) {
1 => comp::critter::Species::Axolotl,
_ => comp::critter::Species::Rat,
};
comp::critter::Body::random_with(rng, &species).into()
},
4 => {
#[allow(clippy::match_single_binding)]
let species = match rng.gen_range(0, 1) {
_ => comp::golem::Species::StoneGolem,
};
comp::golem::Body::random_with(rng, &species).into()
},
_ => {
let species = match rng.gen_range(0, 4) {
0 => comp::biped_large::Species::Ogre, 0 => comp::biped_large::Species::Ogre,
1 => comp::biped_large::Species::Cyclops, 1 => comp::biped_large::Species::Cyclops,
2 => comp::biped_large::Species::Wendigo, 2 => comp::biped_large::Species::Wendigo,
@ -432,6 +421,19 @@ pub fn apply_caves_supplement<'a>(
}; };
comp::biped_large::Body::random_with(rng, &species).into() comp::biped_large::Body::random_with(rng, &species).into()
}, },
_ => {
is_hostile = false;
let species = match rng.gen_range(0, 5) {
0 => comp::critter::Species::Fungome,
_ => comp::critter::Species::Rat,
};
comp::critter::Body::random_with(rng, &species).into()
},
})
.with_alignment(if is_hostile {
comp::Alignment::Enemy
} else {
comp::Alignment::Wild
}) })
.with_automatic_name(); .with_automatic_name();

View File

@ -237,7 +237,10 @@ impl World {
&& !sim_chunk.is_underwater() && !sim_chunk.is_underwater()
{ {
let entity = EntityInfo::at(gen_entity_pos()) let entity = EntityInfo::at(gen_entity_pos())
.with_alignment(comp::Alignment::Wild) .with_alignment(match rng.gen_range(0, 10) {
0 => comp::Alignment::Enemy,
_ => comp::Alignment::Wild,
})
.do_if(rng.gen_range(0, 8) == 0, |e| e.into_giant()) .do_if(rng.gen_range(0, 8) == 0, |e| e.into_giant())
.with_body(match rng.gen_range(0, 5) { .with_body(match rng.gen_range(0, 5) {
0 => comp::Body::QuadrupedMedium(quadruped_medium::Body::random()), 0 => comp::Body::QuadrupedMedium(quadruped_medium::Body::random()),

View File

@ -473,10 +473,10 @@ impl Floor {
.with_automatic_name() .with_automatic_name()
.with_main_tool(assets::load_expect_cloned(match rng.gen_range(0, 6) { .with_main_tool(assets::load_expect_cloned(match rng.gen_range(0, 6) {
0 => "common.items.weapons.axe.starter_axe", 0 => "common.items.weapons.axe.starter_axe",
1 => "common.items.weapons.sword.starter_sword", 1 => "common.items.weapons.sword.cultist_purp_2h-0",
2 => "common.items.weapons.sword.short_sword_0", 2 => "common.items.weapons.sword.short_sword_0",
3 => "common.items.weapons.hammer.hammer_1", 3 => "common.items.weapons.hammer.cultist_purp_2h-0",
4 => "common.items.weapons.staff.starter_staff", 4 => "common.items.weapons.staff.cultist_staff",
_ => "common.items.weapons.bow.starter_bow", _ => "common.items.weapons.bow.starter_bow",
})); }));
@ -545,7 +545,7 @@ impl Floor {
"common.items.weapons.sword.greatsword_2h_fine-1", "common.items.weapons.sword.greatsword_2h_fine-1",
), ),
10 => comp::Item::expect_from_asset( 10 => comp::Item::expect_from_asset(
"common.items.weapons.sword.greatsword_2h_fine-2", "common.items.weapons.hammer.cultist_purp_2h-0",
), ),
11 => comp::Item::expect_from_asset( 11 => comp::Item::expect_from_asset(
"common.items.weapons.sword.cultist_purp_2h-0", "common.items.weapons.sword.cultist_purp_2h-0",

View File

@ -897,7 +897,7 @@ impl Settlement {
}) })
.with_agency(!is_dummy) .with_agency(!is_dummy)
.with_alignment(if is_dummy { .with_alignment(if is_dummy {
comp::Alignment::Wild comp::Alignment::Passive
} else if is_human { } else if is_human {
comp::Alignment::Npc comp::Alignment::Npc
} else { } else {