mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Collars
This commit is contained in:
parent
4f90a0dde0
commit
faa86226c7
@ -50,6 +50,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Added pathfinding to NPCs
|
||||
- Overhauled NPC AI
|
||||
- Pets now attack enemies and defend their owners
|
||||
- Added collars to tame wild animals
|
||||
|
||||
|
||||
### Changed
|
||||
|
7
assets/common/items/collar.ron
Normal file
7
assets/common/items/collar.ron
Normal 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
BIN
assets/voxygen/element/icons/collar.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -31,6 +31,10 @@
|
||||
"voxel.weapon.shield.wood-0",
|
||||
(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
|
||||
Consumable(Apple): VoxTrans(
|
||||
"element.icons.item_apple",
|
||||
@ -41,7 +45,7 @@
|
||||
(0.0, 0.0, 0.0), (-50.0, 30.0, 20.0), 0.8,
|
||||
),
|
||||
Consumable(Cheese): Png(
|
||||
"element.icons.item_cheese",
|
||||
"element.icons.item_cheese",
|
||||
),
|
||||
Consumable(Potion): VoxTrans(
|
||||
"voxel.object.potion_red",
|
||||
|
BIN
assets/voxygen/voxel/object/potion_turq.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/object/potion_turq.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -88,7 +88,6 @@ pub enum Armor {
|
||||
Necklace,
|
||||
}
|
||||
|
||||
//TODO: Do we even need this?
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum Consumable {
|
||||
Apple,
|
||||
@ -100,6 +99,11 @@ pub enum Consumable {
|
||||
PotionMinor,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum Utility {
|
||||
Collar,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum Ingredient {
|
||||
Flower,
|
||||
@ -111,6 +115,7 @@ pub enum ItemKind {
|
||||
Tool { kind: Tool, power: u32 },
|
||||
Armor { kind: Armor, power: u32 },
|
||||
Consumable { kind: Consumable, effect: Effect },
|
||||
Utility { kind: Utility },
|
||||
Ingredient(Ingredient),
|
||||
}
|
||||
|
||||
@ -165,6 +170,7 @@ impl Item {
|
||||
"common.items.veloritefrag",
|
||||
"common.items.cheese",
|
||||
"common.items.potion_minor",
|
||||
"common.items.collar",
|
||||
"common.items.weapons.starter_sword",
|
||||
"common.items.weapons.starter_axe",
|
||||
"common.items.weapons.starter_hammer",
|
||||
|
@ -575,8 +575,73 @@ impl Server {
|
||||
comp::ItemKind::Consumable { 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
|
||||
.ecs()
|
||||
.write_storage::<comp::Inventory>()
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::ui::{Graphic, SampleStrat, Transform, Ui};
|
||||
use common::{
|
||||
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 dot_vox::DotVoxData;
|
||||
@ -16,6 +16,7 @@ use vek::*;
|
||||
pub enum ItemKey {
|
||||
Tool(Tool),
|
||||
Armor(Armor),
|
||||
Utility(Utility),
|
||||
Consumable(Consumable),
|
||||
Ingredient(Ingredient),
|
||||
}
|
||||
@ -24,6 +25,7 @@ impl From<&Item> for ItemKey {
|
||||
match &item.kind {
|
||||
ItemKind::Tool { kind, .. } => ItemKey::Tool(kind.clone()),
|
||||
ItemKind::Armor { kind, .. } => ItemKey::Armor(kind.clone()),
|
||||
ItemKind::Utility { kind } => ItemKey::Utility(kind.clone()),
|
||||
ItemKind::Consumable { kind, .. } => ItemKey::Consumable(kind.clone()),
|
||||
ItemKind::Ingredient(kind) => ItemKey::Ingredient(kind.clone()),
|
||||
}
|
||||
|
@ -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 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 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 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);
|
||||
|
Loading…
Reference in New Issue
Block a user