This commit is contained in:
Joshua Barretto 2020-01-29 12:01:28 +00:00
parent 4f90a0dde0
commit faa86226c7
9 changed files with 96 additions and 5 deletions

View File

@ -50,6 +50,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added pathfinding to NPCs - Added pathfinding to NPCs
- Overhauled NPC AI - Overhauled NPC AI
- Pets now attack enemies and defend their owners - Pets now attack enemies and defend their owners
- Added collars to tame wild animals
### Changed ### Changed

View File

@ -0,0 +1,7 @@
Item(
name: "Collar",
description: "Tames wild animals within 5 blocks.",
kind: Utility(
kind: Collar,
),
)

BIN
assets/voxygen/element/icons/collar.vox (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -31,6 +31,10 @@
"voxel.weapon.shield.wood-0", "voxel.weapon.shield.wood-0",
(0.0, 9.0, 0.0), (-90.0, 90.0, 0.0), 2.4, (0.0, 9.0, 0.0), (-90.0, 90.0, 0.0), 2.4,
), ),
Utility(Collar): VoxTrans(
"element.icons.collar",
(0.0, 0.0, 0.0), (-90.0, 180.0, 10.0), 1.3,
),
// Consumables // Consumables
Consumable(Apple): VoxTrans( Consumable(Apple): VoxTrans(
"element.icons.item_apple", "element.icons.item_apple",

BIN
assets/voxygen/voxel/object/potion_turq.vox (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -88,7 +88,6 @@ pub enum Armor {
Necklace, Necklace,
} }
//TODO: Do we even need this?
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Consumable { pub enum Consumable {
Apple, Apple,
@ -100,6 +99,11 @@ pub enum Consumable {
PotionMinor, PotionMinor,
} }
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Utility {
Collar,
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Ingredient { pub enum Ingredient {
Flower, Flower,
@ -111,6 +115,7 @@ pub enum ItemKind {
Tool { kind: Tool, power: u32 }, Tool { kind: Tool, power: u32 },
Armor { kind: Armor, power: u32 }, Armor { kind: Armor, power: u32 },
Consumable { kind: Consumable, effect: Effect }, Consumable { kind: Consumable, effect: Effect },
Utility { kind: Utility },
Ingredient(Ingredient), Ingredient(Ingredient),
} }
@ -165,6 +170,7 @@ impl Item {
"common.items.veloritefrag", "common.items.veloritefrag",
"common.items.cheese", "common.items.cheese",
"common.items.potion_minor", "common.items.potion_minor",
"common.items.collar",
"common.items.weapons.starter_sword", "common.items.weapons.starter_sword",
"common.items.weapons.starter_axe", "common.items.weapons.starter_axe",
"common.items.weapons.starter_hammer", "common.items.weapons.starter_hammer",

View File

@ -575,8 +575,73 @@ impl Server {
comp::ItemKind::Consumable { effect, .. } => { comp::ItemKind::Consumable { effect, .. } => {
state.apply_effect(entity, effect); state.apply_effect(entity, effect);
} }
comp::ItemKind::Utility { kind } => match kind {
comp::item::Utility::Collar => {
let reinsert = if let Some(pos) =
state.read_storage::<comp::Pos>().get(entity)
{
if (
&state.read_storage::<comp::Alignment>(),
&state.read_storage::<comp::Agent>(),
)
.join()
.filter(|(alignment, _)| {
alignment
== &&comp::Alignment::Owned(entity)
})
.count()
>= 3
{
true
} else if let Some(tameable_entity) = {
let nearest_tameable = (
&state.ecs().entities(),
&state.ecs().read_storage::<comp::Pos>(),
&state
.ecs()
.read_storage::<comp::Alignment>(),
)
.join()
.filter(|(_, wild_pos, _)| {
wild_pos.0.distance_squared(pos.0)
< 5.0f32.powf(2.0)
})
.filter(|(_, _, alignment)| {
alignment == &&comp::Alignment::Wild
})
.min_by_key(|(_, wild_pos, _)| {
(wild_pos.0.distance_squared(pos.0)
* 100.0)
as i32
})
.map(|(entity, _, _)| entity);
nearest_tameable
} {
let _ = state
.ecs()
.write_storage::<comp::Alignment>()
.insert(
tameable_entity,
comp::Alignment::Owned(entity),
);
false
} else {
true
}
} else {
true
};
if reinsert {
let _ = state
.ecs()
.write_storage::<comp::Inventory>()
.get_mut(entity)
.map(|inv| inv.insert(slot, item));
}
}
},
_ => { _ => {
// Re-insert it if unused
let _ = state let _ = state
.ecs() .ecs()
.write_storage::<comp::Inventory>() .write_storage::<comp::Inventory>()

View File

@ -1,7 +1,7 @@
use crate::ui::{Graphic, SampleStrat, Transform, Ui}; use crate::ui::{Graphic, SampleStrat, Transform, Ui};
use common::{ use common::{
assets::{self, watch::ReloadIndicator, Asset}, assets::{self, watch::ReloadIndicator, Asset},
comp::item::{Armor, Consumable, Ingredient, Item, ItemKind, Tool}, comp::item::{Armor, Consumable, Ingredient, Item, ItemKind, Tool, Utility},
}; };
use conrod_core::image::Id; use conrod_core::image::Id;
use dot_vox::DotVoxData; use dot_vox::DotVoxData;
@ -16,6 +16,7 @@ use vek::*;
pub enum ItemKey { pub enum ItemKey {
Tool(Tool), Tool(Tool),
Armor(Armor), Armor(Armor),
Utility(Utility),
Consumable(Consumable), Consumable(Consumable),
Ingredient(Ingredient), Ingredient(Ingredient),
} }
@ -24,6 +25,7 @@ impl From<&Item> for ItemKey {
match &item.kind { match &item.kind {
ItemKind::Tool { kind, .. } => ItemKey::Tool(kind.clone()), ItemKind::Tool { kind, .. } => ItemKey::Tool(kind.clone()),
ItemKind::Armor { kind, .. } => ItemKey::Armor(kind.clone()), ItemKind::Armor { kind, .. } => ItemKey::Armor(kind.clone()),
ItemKind::Utility { kind } => ItemKey::Utility(kind.clone()),
ItemKind::Consumable { kind, .. } => ItemKey::Consumable(kind.clone()), ItemKind::Consumable { kind, .. } => ItemKey::Consumable(kind.clone()),
ItemKind::Ingredient(kind) => ItemKey::Ingredient(kind.clone()), ItemKind::Ingredient(kind) => ItemKey::Ingredient(kind.clone()),
} }

View File

@ -66,7 +66,7 @@ const TEXT_COLOR_3: Color = Color::Rgba(1.0, 1.0, 1.0, 0.1);
const HP_COLOR: Color = Color::Rgba(0.33, 0.63, 0.0, 1.0); const HP_COLOR: Color = Color::Rgba(0.33, 0.63, 0.0, 1.0);
const LOW_HP_COLOR: Color = Color::Rgba(0.93, 0.59, 0.03, 1.0); const LOW_HP_COLOR: Color = Color::Rgba(0.93, 0.59, 0.03, 1.0);
const CRITICAL_HP_COLOR: Color = Color::Rgba(0.79, 0.19, 0.17, 1.0); const CRITICAL_HP_COLOR: Color = Color::Rgba(0.79, 0.19, 0.17, 1.0);
const MANA_COLOR: Color = Color::Rgba(0.47, 0.55, 1.0, 0.9); const MANA_COLOR: Color = Color::Rgba(0.29, 0.62, 0.75, 0.9);
//const FOCUS_COLOR: Color = Color::Rgba(1.0, 0.56, 0.04, 1.0); //const FOCUS_COLOR: Color = Color::Rgba(1.0, 0.56, 0.04, 1.0);
//const RAGE_COLOR: Color = Color::Rgba(0.5, 0.04, 0.13, 1.0); //const RAGE_COLOR: Color = Color::Rgba(0.5, 0.04, 0.13, 1.0);
const META_COLOR: Color = Color::Rgba(1.0, 1.0, 0.0, 1.0); const META_COLOR: Color = Color::Rgba(1.0, 1.0, 0.0, 1.0);