From 9dd5cd24d1b79b5b0d9f93f654d2fe01071caeb6 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Fri, 13 Oct 2023 11:57:49 +0100 Subject: [PATCH] Make backpacks distinct ArmorKinds, fix visual offsets of carried weapons --- assets/common/items/armor/merchant/back.ron | 4 +-- assets/common/items/armor/miner/back.ron | 4 +-- .../common/items/armor/misc/back/backpack.ron | 4 +-- .../items/npc_armor/back/backpack_blue.ron | 2 +- assets/voxygen/i18n/en/hud/bag.ftl | 1 + .../voxel/humanoid_armor_back_manifest.ron | 2 +- common/src/bin/csv_export/main.rs | 1 + common/src/comp/body/item_drop.rs | 1 + common/src/comp/inventory/item/armor.rs | 3 ++ common/src/comp/inventory/slot.rs | 1 + common/src/comp/inventory/test.rs | 9 ++++-- voxygen/anim/src/character/idle.rs | 14 ++++----- voxygen/anim/src/character/jump.rs | 20 ++++++------- voxygen/anim/src/character/mod.rs | 5 +++- voxygen/anim/src/character/run.rs | 20 ++++++------- voxygen/anim/src/character/stand.rs | 18 +++++------ voxygen/src/hud/util.rs | 1 + voxygen/src/scene/figure/mod.rs | 30 ++++++++++++++----- 18 files changed, 85 insertions(+), 55 deletions(-) diff --git a/assets/common/items/armor/merchant/back.ron b/assets/common/items/armor/merchant/back.ron index 998baf4426..6c27d557e4 100644 --- a/assets/common/items/armor/merchant/back.ron +++ b/assets/common/items/armor/merchant/back.ron @@ -2,10 +2,10 @@ ItemDef( name: "Merchant Backpack", description: "", kind: Armor(( - kind: Back, + kind: Backpack, stats: FromSet("Merchant"), )), quality: High, slots: 18, tags: [], -) \ No newline at end of file +) diff --git a/assets/common/items/armor/miner/back.ron b/assets/common/items/armor/miner/back.ron index 85e9fc273a..b1a0223377 100644 --- a/assets/common/items/armor/miner/back.ron +++ b/assets/common/items/armor/miner/back.ron @@ -2,9 +2,9 @@ ItemDef( name: "Miner's Backpack", description: "Battered from heavy rocks being carried inside.", kind: Armor(( - kind: Back, + kind: Backpack, stats: FromSet("Miner"), )), quality: High, tags: [], -) \ No newline at end of file +) diff --git a/assets/common/items/armor/misc/back/backpack.ron b/assets/common/items/armor/misc/back/backpack.ron index db1f9da3f7..91a4ac1531 100644 --- a/assets/common/items/armor/misc/back/backpack.ron +++ b/assets/common/items/armor/misc/back/backpack.ron @@ -2,11 +2,11 @@ ItemDef( name: "Traveler's Backpack", description: "Comfortable and with enough capacity, its a hoarder's best friend.", kind: Armor(( - kind: Back, + kind: Backpack, stats: Direct(( )), )), quality: Epic, tags: [Bag], slots: 20, -) \ No newline at end of file +) diff --git a/assets/common/items/npc_armor/back/backpack_blue.ron b/assets/common/items/npc_armor/back/backpack_blue.ron index 3ea2bd65bc..fb850e4ed0 100644 --- a/assets/common/items/npc_armor/back/backpack_blue.ron +++ b/assets/common/items/npc_armor/back/backpack_blue.ron @@ -2,7 +2,7 @@ ItemDef( name: "Rugged Backpack", description: "Keeps all your stuff together.", kind: Armor(( - kind: Back, + kind: Backpack, stats: Direct(( protection: Some(Normal(0.0)), poise_resilience: Some(Normal(0.0)), diff --git a/assets/voxygen/i18n/en/hud/bag.ftl b/assets/voxygen/i18n/en/hud/bag.ftl index 2504109630..2351ac22d1 100644 --- a/assets/voxygen/i18n/en/hud/bag.ftl +++ b/assets/voxygen/i18n/en/hud/bag.ftl @@ -14,6 +14,7 @@ hud-bag-glider = Glider hud-bag-belt = Belt hud-bag-ring = Ring hud-bag-back = Back +hud-bag-backpack = Backpack hud-bag-legs = Legs hud-bag-feet = Feet hud-bag-mainhand = Mainhand diff --git a/assets/voxygen/voxel/humanoid_armor_back_manifest.ron b/assets/voxygen/voxel/humanoid_armor_back_manifest.ron index 9e68eb5679..0db340b87a 100644 --- a/assets/voxygen/voxel/humanoid_armor_back_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_back_manifest.ron @@ -149,7 +149,7 @@ color: None ), "common.items.armor.merchant.back": ( - vox_spec: ("armor.merchant.back", (-9.0, -7.0, -12.0)), + vox_spec: ("armor.merchant.back", (-8.0, -7.0, -11.0)), color: None ), }, diff --git a/common/src/bin/csv_export/main.rs b/common/src/bin/csv_export/main.rs index 2468aec2ec..99b8dd8561 100644 --- a/common/src/bin/csv_export/main.rs +++ b/common/src/bin/csv_export/main.rs @@ -203,6 +203,7 @@ fn get_armor_kind(kind: &ArmorKind) -> String { ArmorKind::Pants => "Pants".to_string(), ArmorKind::Foot => "Foot".to_string(), ArmorKind::Back => "Back".to_string(), + ArmorKind::Backpack => "Backpack".to_string(), ArmorKind::Ring => "Ring".to_string(), ArmorKind::Neck => "Neck".to_string(), ArmorKind::Head => "Head".to_string(), diff --git a/common/src/comp/body/item_drop.rs b/common/src/comp/body/item_drop.rs index cd82e456ed..97a7730068 100644 --- a/common/src/comp/body/item_drop.rs +++ b/common/src/comp/body/item_drop.rs @@ -75,6 +75,7 @@ impl From<&Item> for Body { ArmorKind::Pants => Body::Armor(ItemDropArmorKind::Pants), ArmorKind::Foot => Body::Armor(ItemDropArmorKind::Foot), ArmorKind::Back => Body::Armor(ItemDropArmorKind::Back), + ArmorKind::Backpack => Body::Armor(ItemDropArmorKind::Back), ArmorKind::Ring => Body::Armor(ItemDropArmorKind::Ring), ArmorKind::Neck => Body::Armor(ItemDropArmorKind::Neck), ArmorKind::Head => Body::Armor(ItemDropArmorKind::Head), diff --git a/common/src/comp/inventory/item/armor.rs b/common/src/comp/inventory/item/armor.rs index a334a95aa5..5f887cb8e1 100644 --- a/common/src/comp/inventory/item/armor.rs +++ b/common/src/comp/inventory/item/armor.rs @@ -23,6 +23,7 @@ pub enum ArmorKind { Head, Tabard, Bag, + Backpack, } impl ArmorKind { @@ -35,6 +36,7 @@ impl ArmorKind { ArmorKind::Pants => true, ArmorKind::Foot => true, ArmorKind::Back => true, + ArmorKind::Backpack => true, ArmorKind::Ring => false, ArmorKind::Neck => false, ArmorKind::Head => true, @@ -252,6 +254,7 @@ impl Armor { ArmorKind::Pants => 2.0, ArmorKind::Foot => 1.0, ArmorKind::Back => 0.5, + ArmorKind::Backpack => 1.0, ArmorKind::Ring => 0.0, ArmorKind::Neck => 0.0, ArmorKind::Head => 0.0, diff --git a/common/src/comp/inventory/slot.rs b/common/src/comp/inventory/slot.rs index 4490deb120..37ca0c981d 100644 --- a/common/src/comp/inventory/slot.rs +++ b/common/src/comp/inventory/slot.rs @@ -142,6 +142,7 @@ impl ArmorSlot { | (Self::Ring1, ArmorKind::Ring) | (Self::Ring2, ArmorKind::Ring) | (Self::Back, ArmorKind::Back) + | (Self::Back, ArmorKind::Backpack) | (Self::Belt, ArmorKind::Belt) | (Self::Legs, ArmorKind::Pants) | (Self::Feet, ArmorKind::Foot) diff --git a/common/src/comp/inventory/test.rs b/common/src/comp/inventory/test.rs index 076ccc56af..ff102bb5e9 100644 --- a/common/src/comp/inventory/test.rs +++ b/common/src/comp/inventory/test.rs @@ -497,8 +497,11 @@ fn backpack_crash() { let mut inv = Inventory::with_empty(); let backpack = Item::new_from_asset_expect("common.items.armor.misc.back.backpack"); - inv.loadout - .swap(EquipSlot::Armor(ArmorSlot::Back), Some(backpack), Time(0.0)); + inv.loadout.swap( + EquipSlot::Armor(ArmorSlot::Backpack), + Some(backpack), + Time(0.0), + ); fill_inv_slots(&mut inv, 35); @@ -507,7 +510,7 @@ fn backpack_crash() { let returned_items = inv.swap_inventory_loadout( InvSlotId::new(9, 17), - EquipSlot::Armor(ArmorSlot::Back), + EquipSlot::Armor(ArmorSlot::Backpack), Time(0.0), ); assert_eq!(18, returned_items.len()); diff --git a/voxygen/anim/src/character/idle.rs b/voxygen/anim/src/character/idle.rs index a1de8aa61a..d010bce292 100644 --- a/voxygen/anim/src/character/idle.rs +++ b/voxygen/anim/src/character/idle.rs @@ -89,17 +89,17 @@ impl Animation for IdleAnimation { match hands { (Some(Hands::Two), _) | (None, Some(Hands::Two)) => match active_tool_kind { Some(ToolKind::Bow) => { - next.main.position = Vec3::new(0.0, -5.0, 6.0); + next.main.position = Vec3::new(0.0, -5.0 - skeleton.back_carry_offset, 6.0); next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); }, Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => { - next.main.position = Vec3::new(2.0, -5.0, -1.0); + next.main.position = Vec3::new(2.0, -5.0 - skeleton.back_carry_offset, -1.0); next.main.orientation = Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(PI / 2.0); }, _ => { - next.main.position = Vec3::new(-7.0, -5.0, 15.0); + next.main.position = Vec3::new(-7.0, -5. - skeleton.back_carry_offset, 15.0); next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); }, @@ -110,12 +110,12 @@ impl Animation for IdleAnimation { match hands { (Some(Hands::One), _) => match active_tool_kind { Some(ToolKind::Dagger) => { - next.main.position = Vec3::new(5.0, 1.0, 2.0); + next.main.position = Vec3::new(5.0, 1.0 - skeleton.back_carry_offset, 2.0); next.main.orientation = Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(2.0 * PI); }, Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { - next.main.position = Vec3::new(-4.0, -5.0, 10.0); + next.main.position = Vec3::new(-4.0, -4.0 - skeleton.back_carry_offset, 10.0); next.main.orientation = Quaternion::rotation_y(2.35) * Quaternion::rotation_z(PI / 2.0); }, @@ -127,12 +127,12 @@ impl Animation for IdleAnimation { match hands { (None | Some(Hands::One), Some(Hands::One)) => match second_tool_kind { Some(ToolKind::Dagger) => { - next.second.position = Vec3::new(-5.0, 1.0, 2.0); + next.second.position = Vec3::new(-5.0, 1.0 - skeleton.back_carry_offset, 2.0); next.second.orientation = Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(-2.0 * PI); }, Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { - next.second.position = Vec3::new(4.0, -6.0, 10.0); + next.second.position = Vec3::new(4.0, -5.0 - skeleton.back_carry_offset, 10.0); next.second.orientation = Quaternion::rotation_y(-2.5) * Quaternion::rotation_z(-PI / 2.0); }, diff --git a/voxygen/anim/src/character/jump.rs b/voxygen/anim/src/character/jump.rs index 16d8ed963b..b57c1bdd8d 100644 --- a/voxygen/anim/src/character/jump.rs +++ b/voxygen/anim/src/character/jump.rs @@ -144,27 +144,27 @@ impl Animation for JumpAnimation { match main_tool { Some(ToolKind::Dagger) => { - next.main.position = Vec3::new(5.0, 1.0, 2.0); + next.main.position = Vec3::new(5.0, 1.0 - skeleton.back_carry_offset, 2.0); next.main.orientation = Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(2.0 * PI); }, Some(ToolKind::Shield) => { - next.main.position = Vec3::new(-0.0, -5.0, 3.0); + next.main.position = Vec3::new(-0.0, -5.0 - skeleton.back_carry_offset, 3.0); next.main.orientation = Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI); }, Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => { - next.main.position = Vec3::new(2.0, -5.0, -1.0); + next.main.position = Vec3::new(2.0, -5.0 - skeleton.back_carry_offset, -1.0); next.main.orientation = Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(PI / 2.0); }, Some(ToolKind::Bow) => { - next.main.position = Vec3::new(0.0, -5.0, 6.0); + next.main.position = Vec3::new(0.0, -5.0 - skeleton.back_carry_offset, 6.0); next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); }, _ => { - next.main.position = Vec3::new(-7.0, -5.0, 15.0); + next.main.position = Vec3::new(-7.0, -5.0 - skeleton.back_carry_offset, 15.0); next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); }, @@ -172,18 +172,18 @@ impl Animation for JumpAnimation { match second_tool_kind { Some(ToolKind::Dagger) => { - next.second.position = Vec3::new(-5.0, 1.0, 2.0); + next.second.position = Vec3::new(-5.0, 1.0 - skeleton.back_carry_offset, 2.0); next.second.orientation = Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(-2.0 * PI); }, Some(ToolKind::Shield) => { - next.second.position = Vec3::new(0.0, -4.0, 3.0); + next.second.position = Vec3::new(0.0, -4.5 - skeleton.back_carry_offset, 3.0); next.second.orientation = Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI); }, _ => { - next.second.position = Vec3::new(-7.0, -5.0, 15.0); + next.second.position = Vec3::new(-7.0, -5.0 - skeleton.back_carry_offset, 15.0); next.second.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); }, @@ -211,7 +211,7 @@ impl Animation for JumpAnimation { match hands { (Some(Hands::One), _) => match active_tool_kind { Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { - next.main.position = Vec3::new(-4.0, -5.0, 10.0); + next.main.position = Vec3::new(-4.0, -5.0 - skeleton.back_carry_offset, 10.0); next.main.orientation = Quaternion::rotation_y(2.35) * Quaternion::rotation_z(PI / 2.0); }, @@ -223,7 +223,7 @@ impl Animation for JumpAnimation { match hands { (None | Some(Hands::One), Some(Hands::One)) => match second_tool_kind { Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { - next.second.position = Vec3::new(4.0, -6.0, 10.0); + next.second.position = Vec3::new(4.0, -6.0 - skeleton.back_carry_offset, 10.0); next.second.orientation = Quaternion::rotation_y(-2.5) * Quaternion::rotation_z(-PI / 2.0); }, diff --git a/voxygen/anim/src/character/mod.rs b/voxygen/anim/src/character/mod.rs index a3a583cb5f..c5cf136a64 100644 --- a/voxygen/anim/src/character/mod.rs +++ b/voxygen/anim/src/character/mod.rs @@ -86,6 +86,8 @@ skeleton_impls!(struct CharacterSkeleton { control_r, :: // Begin non-bone fields holding_lantern: bool, + // The offset from the back that carried weapons should be given to avoid clipping due to, say, a backpack + back_carry_offset: f32, main_weapon_trail: bool, off_weapon_trail: bool, // Cannot exist at same time as weapon trails. Since gliding and attacking are mutually exclusive, should never be a concern. @@ -93,9 +95,10 @@ skeleton_impls!(struct CharacterSkeleton { }); impl CharacterSkeleton { - pub fn new(holding_lantern: bool) -> Self { + pub fn new(holding_lantern: bool, back_carry_offset: f32) -> Self { Self { holding_lantern, + back_carry_offset, ..Self::default() } } diff --git a/voxygen/anim/src/character/run.rs b/voxygen/anim/src/character/run.rs index 098e96cb38..dc766bc718 100644 --- a/voxygen/anim/src/character/run.rs +++ b/voxygen/anim/src/character/run.rs @@ -215,27 +215,27 @@ impl Animation for RunAnimation { match main_tool { Some(ToolKind::Dagger) => { - next.main.position = Vec3::new(5.0, 1.0, 2.0); + next.main.position = Vec3::new(5.0, 1.0 - skeleton.back_carry_offset, 2.0); next.main.orientation = Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(2.0 * PI); }, Some(ToolKind::Shield) => { - next.main.position = Vec3::new(-0.0, -5.0, 3.0); + next.main.position = Vec3::new(-0.0, -5.0 - skeleton.back_carry_offset, 3.0); next.main.orientation = Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI); }, Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => { - next.main.position = Vec3::new(2.0, -5.0, -1.0); + next.main.position = Vec3::new(2.0, -5.0 - skeleton.back_carry_offset, -1.0); next.main.orientation = Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(PI / 2.0); }, Some(ToolKind::Bow) => { - next.main.position = Vec3::new(0.0, -5.0, 6.0); + next.main.position = Vec3::new(0.0, -5.0 - skeleton.back_carry_offset, 6.0); next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); }, _ => { - next.main.position = Vec3::new(-7.0, -5.0, 15.0); + next.main.position = Vec3::new(-7.0, -5.0 - skeleton.back_carry_offset, 15.0); next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0 + shorte * -0.2); }, @@ -243,17 +243,17 @@ impl Animation for RunAnimation { match second_tool_kind { Some(ToolKind::Dagger) => { - next.second.position = Vec3::new(-5.0, 1.0, 2.0); + next.second.position = Vec3::new(-5.0, 1.0 - skeleton.back_carry_offset, 2.0); next.second.orientation = Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(-2.0 * PI); }, Some(ToolKind::Shield) => { - next.second.position = Vec3::new(0.0, -4.0, 3.0); + next.second.position = Vec3::new(0.0, -4.5 - skeleton.back_carry_offset, 3.0); next.second.orientation = Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI); }, _ => { - next.second.position = Vec3::new(-7.0, -5.0, 15.0); + next.second.position = Vec3::new(-7.0, -5.0 - skeleton.back_carry_offset, 15.0); next.second.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); }, @@ -288,7 +288,7 @@ impl Animation for RunAnimation { match hands { (Some(Hands::One), _) => match active_tool_kind { Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { - next.main.position = Vec3::new(-4.0, -5.0, 10.0); + next.main.position = Vec3::new(-4.0, -4.5 - skeleton.back_carry_offset, 10.0); next.main.orientation = Quaternion::rotation_y(2.35) * Quaternion::rotation_z(PI / 2.0); }, @@ -300,7 +300,7 @@ impl Animation for RunAnimation { match hands { (None | Some(Hands::One), Some(Hands::One)) => match second_tool_kind { Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { - next.second.position = Vec3::new(4.0, -6.0, 10.0); + next.second.position = Vec3::new(4.0, -5.0 - skeleton.back_carry_offset, 10.0); next.second.orientation = Quaternion::rotation_y(-2.5) * Quaternion::rotation_z(-PI / 2.0); }, diff --git a/voxygen/anim/src/character/stand.rs b/voxygen/anim/src/character/stand.rs index 347f06623e..24f70e64d3 100644 --- a/voxygen/anim/src/character/stand.rs +++ b/voxygen/anim/src/character/stand.rs @@ -111,17 +111,17 @@ impl Animation for StandAnimation { match (hands, active_tool_kind, second_tool_kind) { ((Some(Hands::Two), _), tool, _) | ((None, Some(Hands::Two)), _, tool) => match tool { Some(ToolKind::Bow) => { - next.main.position = Vec3::new(0.0, -5.0, 6.0); + next.main.position = Vec3::new(0.0, -5.0 - skeleton.back_carry_offset, 6.0); next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); }, Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => { - next.main.position = Vec3::new(2.0, -5.0, -1.0); + next.main.position = Vec3::new(2.0, -5.0 - skeleton.back_carry_offset, -1.0); next.main.orientation = Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(PI / 2.0); }, _ => { - next.main.position = Vec3::new(-7.0, -5.0, 15.0); + next.main.position = Vec3::new(-7.0, -5.0 - skeleton.back_carry_offset, 15.0); next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); }, @@ -132,17 +132,17 @@ impl Animation for StandAnimation { match hands { (Some(Hands::One), _) => match active_tool_kind { Some(ToolKind::Dagger) => { - next.main.position = Vec3::new(5.0, 1.0, 2.0); + next.main.position = Vec3::new(5.0, 1.0 - skeleton.back_carry_offset, 2.0); next.main.orientation = Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(2.0 * PI); }, Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { - next.main.position = Vec3::new(-4.0, -5.0, 10.0); + next.main.position = Vec3::new(-4.0, -4.5 - skeleton.back_carry_offset, 10.0); next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); }, Some(ToolKind::Shield) => { - next.main.position = Vec3::new(-0.0, -4.0, 3.0); + next.main.position = Vec3::new(-0.0, -4.0 - skeleton.back_carry_offset, 3.0); next.main.orientation = Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI); }, @@ -153,17 +153,17 @@ impl Animation for StandAnimation { match hands { (None | Some(Hands::One), Some(Hands::One)) => match second_tool_kind { Some(ToolKind::Dagger) => { - next.second.position = Vec3::new(-5.0, 1.0, 2.0); + next.second.position = Vec3::new(-5.0, 1.0 - skeleton.back_carry_offset, 2.0); next.second.orientation = Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(-2.0 * PI); }, Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { - next.second.position = Vec3::new(4.0, -6.0, 10.0); + next.second.position = Vec3::new(4.0, -5.0 - skeleton.back_carry_offset, 10.0); next.second.orientation = Quaternion::rotation_y(-2.5) * Quaternion::rotation_z(-PI / 2.0); }, Some(ToolKind::Shield) => { - next.second.position = Vec3::new(0.0, -4.0, 3.0); + next.second.position = Vec3::new(0.0, -4.0 - skeleton.back_carry_offset, 3.0); next.second.orientation = Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI); }, diff --git a/voxygen/src/hud/util.rs b/voxygen/src/hud/util.rs index 94e07b1eb7..61ea847b74 100644 --- a/voxygen/src/hud/util.rs +++ b/voxygen/src/hud/util.rs @@ -293,6 +293,7 @@ fn armor_kind<'a>(armor: &Armor, i18n: &'a Localization) -> Cow<'a, str> { ArmorKind::Pants => i18n.get_msg("hud-bag-legs"), ArmorKind::Foot => i18n.get_msg("hud-bag-feet"), ArmorKind::Back => i18n.get_msg("hud-bag-back"), + ArmorKind::Backpack => i18n.get_msg("hud-bag-backpack"), ArmorKind::Ring => i18n.get_msg("hud-bag-ring"), ArmorKind::Neck => i18n.get_msg("hud-bag-neck"), ArmorKind::Head => i18n.get_msg("hud-bag-head"), diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index edb5b3dbef..41617fdd25 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -37,8 +37,9 @@ use anim::{ use common::{ comp::{ inventory::slot::EquipSlot, - item::{Hands, ItemKind, ToolKind}, + item::{armor::ArmorKind, Hands, ItemKind, ToolKind}, ship::{self, figuredata::VOXEL_COLLIDER_MANIFEST}, + slot::ArmorSlot, Body, CharacterActivity, CharacterState, Collider, Controller, Health, Inventory, Item, ItemKey, Last, LightAnimation, LightEmitter, Object, Ori, PhysicsState, PoiseState, Pos, Scale, Vel, @@ -1107,6 +1108,21 @@ impl FigureMgr { && !character.map_or(false, |c| c.is_using_hands()) && physics.in_liquid().is_none(); + let back_carry_offset = inventory + .and_then(|i| i.equipped(EquipSlot::Armor(ArmorSlot::Back))) + .and_then(|i| { + if let ItemKind::Armor(armor) = i.kind().as_ref() { + match &armor.kind { + ArmorKind::Backpack => Some(4.0), + ArmorKind::Back => Some(1.5), + _ => None, + } + } else { + None + } + }) + .unwrap_or(0.0); + let state = self .states .character_states @@ -1114,7 +1130,7 @@ impl FigureMgr { .or_insert_with(|| { FigureState::new( renderer, - CharacterSkeleton::new(holding_lantern), + CharacterSkeleton::new(holding_lantern, back_carry_offset), body, ) }); @@ -1141,7 +1157,7 @@ impl FigureMgr { // Standing or Skating (true, false, false, false, _) | (_, _, false, false, true) => { anim::character::StandAnimation::update_skeleton( - &CharacterSkeleton::new(holding_lantern), + &CharacterSkeleton::new(holding_lantern, back_carry_offset), ( active_tool_kind, second_tool_kind, @@ -1160,7 +1176,7 @@ impl FigureMgr { // Running (true, true, false, false, _) => { anim::character::RunAnimation::update_skeleton( - &CharacterSkeleton::new(holding_lantern), + &CharacterSkeleton::new(holding_lantern, back_carry_offset), ( active_tool_kind, second_tool_kind, @@ -1182,7 +1198,7 @@ impl FigureMgr { // In air (false, _, false, false, _) => { anim::character::JumpAnimation::update_skeleton( - &CharacterSkeleton::new(holding_lantern), + &CharacterSkeleton::new(holding_lantern, back_carry_offset), ( active_tool_kind, second_tool_kind, @@ -1200,7 +1216,7 @@ impl FigureMgr { }, // Swim (_, _, true, false, _) => anim::character::SwimAnimation::update_skeleton( - &CharacterSkeleton::new(holding_lantern), + &CharacterSkeleton::new(holding_lantern, back_carry_offset), ( active_tool_kind, second_tool_kind, @@ -1218,7 +1234,7 @@ impl FigureMgr { ), // Mount (_, _, _, true, _) => anim::character::MountAnimation::update_skeleton( - &CharacterSkeleton::new(holding_lantern), + &CharacterSkeleton::new(holding_lantern, back_carry_offset), ( active_tool_kind, second_tool_kind,