From 3d8ad41f0aeccfbc2cef5789f49eddf4bd4daa88 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Wed, 29 Jan 2020 12:01:28 +0000 Subject: [PATCH] Collars --- CHANGELOG.md | 1 + assets/common/items/collar.ron | 7 ++ assets/voxygen/element/icons/collar.vox | Bin 0 -> 58948 bytes assets/voxygen/item_image_manifest.ron | 6 +- assets/voxygen/voxel/object/potion_turq.vox | Bin 0 -> 55889 bytes common/src/comp/inventory/item.rs | 8 ++- server/src/lib.rs | 67 +++++++++++++++++++- voxygen/src/hud/item_imgs.rs | 4 +- voxygen/src/hud/mod.rs | 2 +- 9 files changed, 90 insertions(+), 5 deletions(-) create mode 100644 assets/common/items/collar.ron create mode 100644 assets/voxygen/element/icons/collar.vox create mode 100644 assets/voxygen/voxel/object/potion_turq.vox diff --git a/CHANGELOG.md b/CHANGELOG.md index 18baf2e358..7f36758442 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/assets/common/items/collar.ron b/assets/common/items/collar.ron new file mode 100644 index 0000000000..5226dd0c0a --- /dev/null +++ b/assets/common/items/collar.ron @@ -0,0 +1,7 @@ +Item( + name: "Collar", + description: "Tames wild animals within 5 blocks.", + kind: Utility( + kind: Collar, + ), +) diff --git a/assets/voxygen/element/icons/collar.vox b/assets/voxygen/element/icons/collar.vox new file mode 100644 index 0000000000000000000000000000000000000000..48247213f3358968b2d851465f5b675a1a98c2a8 GIT binary patch literal 58948 zcmds=d3+qzeZZeA$(D8P?#%4&%t(kSaPVHeo{@^|cUIv4s#QmE?W`eDI1{6`IdL zGh;P@t3ri1DCKfL4rY#Mu|dW1%U~(ggHjIlb}>fVDAZ9`3l?KVpkAf&S=Bn(k$#QzYdqAal9T-qrR=~G)_#b!wJBQ=fw)Q$Q$uB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E zD?wqlJaco*HScxX&5v% zTRm8r9aA$iy90yWrG3?>4=%* z9IDN6(pC-n7Rxhxrt`scJ7=b5%0_>@OHC{Z@qd^lM>Dj5={>6p9z>% literal 0 HcmV?d00001 diff --git a/assets/voxygen/item_image_manifest.ron b/assets/voxygen/item_image_manifest.ron index 048ac495b4..a53c7a6c8b 100644 --- a/assets/voxygen/item_image_manifest.ron +++ b/assets/voxygen/item_image_manifest.ron @@ -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", diff --git a/assets/voxygen/voxel/object/potion_turq.vox b/assets/voxygen/voxel/object/potion_turq.vox new file mode 100644 index 0000000000000000000000000000000000000000..25cd469bd698099ed583b75b4c67b1b0fbfdc1ef GIT binary patch literal 55889 zcmdtqd3;pW6$kM9W*{O#3lhR=7+Hh_2s24037dv}-x5TKz%a?YOdgrcOed3&&{PXi zDpC|N1#Ce;8_-%P&`7bijYuh_O)W)gT}mmn*6y{fwRSz8bKj6ag7{}YpWpDgnRo6x z_uTuvZ{hO+J}h0h%(Y!9HGlH#1^lHZy`fam?BeM?B;Ze%M7x2%mn|=zonuI^QuDYu z97#=vBWb_GNZM~0NlnVpwN)8iTOH1>tp+zI$4-eA$J`to8{8b+XGp)J3&&kJ=5KBe zhvTrr;N~!nI}C0P)#5Nzi__t3aT?ARhm)J)W2d9VsiYZvY;d3CaN}HuQ?)2QR(x#m zvB5PBu4!;hgKP5gxsMy4S6o-|c*S)T*EhI6tGLh6V(>hM^l^?u=9XNp!|20?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tsvldEI3#F-p(yW8hdI`LuocZX&Rt3_d{tOfYNM)(tH+5^B|OF6O`s5D9vUl&F7#r zTc9)#Lunp?(rks&JPM`R2BmonO4A6X`8gwpJS((H!P zJOQQI1EtvurP&9ic@j$V6qM#mP?{zv&3-7&0VvJWP?~3;G+&0&JPW1y3Y6v`l;#kW z=BrSe!%&(dP@1Dqny*1=nxQn$L1~UbX}%7nIS!?H9!m2KD9sB{nr}jBz6GWEHk76X zO7kL=<^+`HB`D2FD9v}EG^e06--XhghSGcwN^=HE^L;4I51=%yP?{e?Xk~kKr4wgIl$eroYqpG52sU3Uu0EvCk zL{AqPVnt$hn5{#9T$gi8pD*Z^zA^4huN`{q%zQgqYe#u{qOwqRt*k?j@Pz^~9mEz+ znKP7o<>TPiCed@5;Tqjh83~we>6T7bN<3GmTj4UP;jYyT-yRy7qSEA`{@P~sT zQwDq8F0Wfx@yATROzO^b+Y1g@RTXWM=J6T%Nad?1tqxlsKdCUs=mOU&VU>jJ5;C1f z%VQCHmu2AI#6Y>YSI_N_SK3$AU*`+h=$y8Wite1B<8^u5IbzrSm6myRqI6tyhvY=i z-j95*o;8x~3+Vm09O-c$x4p9-k6YF{Be7N)*|t`FSC&PBzRP=M*SY59(Vaotk}DOj zdAW7zkQuJh2hmt$jb54Fy0S=(6v^@4$UlAls2Ph_$4r}&<<)B`3Hbx2FRaI0(b0ZO zE=Vw>d>ca_lv$xlePGr`Bkk9##tOFYjla~aYF|&#Un!id%q-z7yH;g=ZAwCsNTn83 zTDA5D*cYv;)E}~MfBl5|=P-a6nI2 z8VN;W9i9z6d->((UDq0ss3lw4R!a)|N`mcmuAVdr!SB! zcSB+#IoURmUCfNfx!4sur!RQhBHFLG$*}gQBD)Q?{Gxf!k3LY2#(xpnxP)HIy F9|GAbJz)R< literal 0 HcmV?d00001 diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 1ec6f4508b..23365ceb76 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -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", diff --git a/server/src/lib.rs b/server/src/lib.rs index 880e5b3b99..da009757bc 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -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::().get(entity) + { + if ( + &state.read_storage::(), + &state.read_storage::(), + ) + .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::(), + &state + .ecs() + .read_storage::(), + ) + .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::() + .insert( + tameable_entity, + comp::Alignment::Owned(entity), + ); + false + } else { + true + } + } else { + true + }; + + if reinsert { + let _ = state + .ecs() + .write_storage::() + .get_mut(entity) + .map(|inv| inv.insert(slot, item)); + } + } + }, _ => { - // Re-insert it if unused let _ = state .ecs() .write_storage::() diff --git a/voxygen/src/hud/item_imgs.rs b/voxygen/src/hud/item_imgs.rs index 4d7ee2686f..9c3d7f5d7f 100644 --- a/voxygen/src/hud/item_imgs.rs +++ b/voxygen/src/hud/item_imgs.rs @@ -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()), } diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index cfdde8db7d..1853c5fa88 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -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);