Make backpacks distinct ArmorKinds, fix visual offsets of carried weapons

This commit is contained in:
Joshua Barretto 2023-10-13 11:57:49 +01:00
parent 0f2d4c261a
commit 9dd5cd24d1
18 changed files with 85 additions and 55 deletions

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Merchant Backpack", name: "Merchant Backpack",
description: "", description: "",
kind: Armor(( kind: Armor((
kind: Back, kind: Backpack,
stats: FromSet("Merchant"), stats: FromSet("Merchant"),
)), )),
quality: High, quality: High,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Miner's Backpack", name: "Miner's Backpack",
description: "Battered from heavy rocks being carried inside.", description: "Battered from heavy rocks being carried inside.",
kind: Armor(( kind: Armor((
kind: Back, kind: Backpack,
stats: FromSet("Miner"), stats: FromSet("Miner"),
)), )),
quality: High, quality: High,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Traveler's Backpack", name: "Traveler's Backpack",
description: "Comfortable and with enough capacity, its a hoarder's best friend.", description: "Comfortable and with enough capacity, its a hoarder's best friend.",
kind: Armor(( kind: Armor((
kind: Back, kind: Backpack,
stats: Direct(( stats: Direct((
)), )),
)), )),

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Rugged Backpack", name: "Rugged Backpack",
description: "Keeps all your stuff together.", description: "Keeps all your stuff together.",
kind: Armor(( kind: Armor((
kind: Back, kind: Backpack,
stats: Direct(( stats: Direct((
protection: Some(Normal(0.0)), protection: Some(Normal(0.0)),
poise_resilience: Some(Normal(0.0)), poise_resilience: Some(Normal(0.0)),

View File

@ -14,6 +14,7 @@ hud-bag-glider = Glider
hud-bag-belt = Belt hud-bag-belt = Belt
hud-bag-ring = Ring hud-bag-ring = Ring
hud-bag-back = Back hud-bag-back = Back
hud-bag-backpack = Backpack
hud-bag-legs = Legs hud-bag-legs = Legs
hud-bag-feet = Feet hud-bag-feet = Feet
hud-bag-mainhand = Mainhand hud-bag-mainhand = Mainhand

View File

@ -149,7 +149,7 @@
color: None color: None
), ),
"common.items.armor.merchant.back": ( "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 color: None
), ),
}, },

View File

@ -203,6 +203,7 @@ fn get_armor_kind(kind: &ArmorKind) -> String {
ArmorKind::Pants => "Pants".to_string(), ArmorKind::Pants => "Pants".to_string(),
ArmorKind::Foot => "Foot".to_string(), ArmorKind::Foot => "Foot".to_string(),
ArmorKind::Back => "Back".to_string(), ArmorKind::Back => "Back".to_string(),
ArmorKind::Backpack => "Backpack".to_string(),
ArmorKind::Ring => "Ring".to_string(), ArmorKind::Ring => "Ring".to_string(),
ArmorKind::Neck => "Neck".to_string(), ArmorKind::Neck => "Neck".to_string(),
ArmorKind::Head => "Head".to_string(), ArmorKind::Head => "Head".to_string(),

View File

@ -75,6 +75,7 @@ impl From<&Item> for Body {
ArmorKind::Pants => Body::Armor(ItemDropArmorKind::Pants), ArmorKind::Pants => Body::Armor(ItemDropArmorKind::Pants),
ArmorKind::Foot => Body::Armor(ItemDropArmorKind::Foot), ArmorKind::Foot => Body::Armor(ItemDropArmorKind::Foot),
ArmorKind::Back => Body::Armor(ItemDropArmorKind::Back), ArmorKind::Back => Body::Armor(ItemDropArmorKind::Back),
ArmorKind::Backpack => Body::Armor(ItemDropArmorKind::Back),
ArmorKind::Ring => Body::Armor(ItemDropArmorKind::Ring), ArmorKind::Ring => Body::Armor(ItemDropArmorKind::Ring),
ArmorKind::Neck => Body::Armor(ItemDropArmorKind::Neck), ArmorKind::Neck => Body::Armor(ItemDropArmorKind::Neck),
ArmorKind::Head => Body::Armor(ItemDropArmorKind::Head), ArmorKind::Head => Body::Armor(ItemDropArmorKind::Head),

View File

@ -23,6 +23,7 @@ pub enum ArmorKind {
Head, Head,
Tabard, Tabard,
Bag, Bag,
Backpack,
} }
impl ArmorKind { impl ArmorKind {
@ -35,6 +36,7 @@ impl ArmorKind {
ArmorKind::Pants => true, ArmorKind::Pants => true,
ArmorKind::Foot => true, ArmorKind::Foot => true,
ArmorKind::Back => true, ArmorKind::Back => true,
ArmorKind::Backpack => true,
ArmorKind::Ring => false, ArmorKind::Ring => false,
ArmorKind::Neck => false, ArmorKind::Neck => false,
ArmorKind::Head => true, ArmorKind::Head => true,
@ -252,6 +254,7 @@ impl Armor {
ArmorKind::Pants => 2.0, ArmorKind::Pants => 2.0,
ArmorKind::Foot => 1.0, ArmorKind::Foot => 1.0,
ArmorKind::Back => 0.5, ArmorKind::Back => 0.5,
ArmorKind::Backpack => 1.0,
ArmorKind::Ring => 0.0, ArmorKind::Ring => 0.0,
ArmorKind::Neck => 0.0, ArmorKind::Neck => 0.0,
ArmorKind::Head => 0.0, ArmorKind::Head => 0.0,

View File

@ -142,6 +142,7 @@ impl ArmorSlot {
| (Self::Ring1, ArmorKind::Ring) | (Self::Ring1, ArmorKind::Ring)
| (Self::Ring2, ArmorKind::Ring) | (Self::Ring2, ArmorKind::Ring)
| (Self::Back, ArmorKind::Back) | (Self::Back, ArmorKind::Back)
| (Self::Back, ArmorKind::Backpack)
| (Self::Belt, ArmorKind::Belt) | (Self::Belt, ArmorKind::Belt)
| (Self::Legs, ArmorKind::Pants) | (Self::Legs, ArmorKind::Pants)
| (Self::Feet, ArmorKind::Foot) | (Self::Feet, ArmorKind::Foot)

View File

@ -497,8 +497,11 @@ fn backpack_crash() {
let mut inv = Inventory::with_empty(); let mut inv = Inventory::with_empty();
let backpack = Item::new_from_asset_expect("common.items.armor.misc.back.backpack"); let backpack = Item::new_from_asset_expect("common.items.armor.misc.back.backpack");
inv.loadout inv.loadout.swap(
.swap(EquipSlot::Armor(ArmorSlot::Back), Some(backpack), Time(0.0)); EquipSlot::Armor(ArmorSlot::Backpack),
Some(backpack),
Time(0.0),
);
fill_inv_slots(&mut inv, 35); fill_inv_slots(&mut inv, 35);
@ -507,7 +510,7 @@ fn backpack_crash() {
let returned_items = inv.swap_inventory_loadout( let returned_items = inv.swap_inventory_loadout(
InvSlotId::new(9, 17), InvSlotId::new(9, 17),
EquipSlot::Armor(ArmorSlot::Back), EquipSlot::Armor(ArmorSlot::Backpack),
Time(0.0), Time(0.0),
); );
assert_eq!(18, returned_items.len()); assert_eq!(18, returned_items.len());

View File

@ -89,17 +89,17 @@ impl Animation for IdleAnimation {
match hands { match hands {
(Some(Hands::Two), _) | (None, Some(Hands::Two)) => match active_tool_kind { (Some(Hands::Two), _) | (None, Some(Hands::Two)) => match active_tool_kind {
Some(ToolKind::Bow) => { 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 = next.main.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0);
}, },
Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => { 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 = next.main.orientation =
Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(PI / 2.0); 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 = next.main.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0);
}, },
@ -110,12 +110,12 @@ impl Animation for IdleAnimation {
match hands { match hands {
(Some(Hands::One), _) => match active_tool_kind { (Some(Hands::One), _) => match active_tool_kind {
Some(ToolKind::Dagger) => { 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 = next.main.orientation =
Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(2.0 * PI); Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(2.0 * PI);
}, },
Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { 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 = next.main.orientation =
Quaternion::rotation_y(2.35) * Quaternion::rotation_z(PI / 2.0); Quaternion::rotation_y(2.35) * Quaternion::rotation_z(PI / 2.0);
}, },
@ -127,12 +127,12 @@ impl Animation for IdleAnimation {
match hands { match hands {
(None | Some(Hands::One), Some(Hands::One)) => match second_tool_kind { (None | Some(Hands::One), Some(Hands::One)) => match second_tool_kind {
Some(ToolKind::Dagger) => { 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 = next.second.orientation =
Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(-2.0 * PI); Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(-2.0 * PI);
}, },
Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { 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 = next.second.orientation =
Quaternion::rotation_y(-2.5) * Quaternion::rotation_z(-PI / 2.0); Quaternion::rotation_y(-2.5) * Quaternion::rotation_z(-PI / 2.0);
}, },

View File

@ -144,27 +144,27 @@ impl Animation for JumpAnimation {
match main_tool { match main_tool {
Some(ToolKind::Dagger) => { 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 = next.main.orientation =
Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(2.0 * PI); Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(2.0 * PI);
}, },
Some(ToolKind::Shield) => { 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 = next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI); Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
}, },
Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => { 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 = next.main.orientation =
Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(PI / 2.0); Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(PI / 2.0);
}, },
Some(ToolKind::Bow) => { 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 = next.main.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); 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 = next.main.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0);
}, },
@ -172,18 +172,18 @@ impl Animation for JumpAnimation {
match second_tool_kind { match second_tool_kind {
Some(ToolKind::Dagger) => { 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 = next.second.orientation =
Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(-2.0 * PI); Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(-2.0 * PI);
}, },
Some(ToolKind::Shield) => { 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 = next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI); 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 = next.second.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0);
}, },
@ -211,7 +211,7 @@ impl Animation for JumpAnimation {
match hands { match hands {
(Some(Hands::One), _) => match active_tool_kind { (Some(Hands::One), _) => match active_tool_kind {
Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { 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 = next.main.orientation =
Quaternion::rotation_y(2.35) * Quaternion::rotation_z(PI / 2.0); Quaternion::rotation_y(2.35) * Quaternion::rotation_z(PI / 2.0);
}, },
@ -223,7 +223,7 @@ impl Animation for JumpAnimation {
match hands { match hands {
(None | Some(Hands::One), Some(Hands::One)) => match second_tool_kind { (None | Some(Hands::One), Some(Hands::One)) => match second_tool_kind {
Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { 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 = next.second.orientation =
Quaternion::rotation_y(-2.5) * Quaternion::rotation_z(-PI / 2.0); Quaternion::rotation_y(-2.5) * Quaternion::rotation_z(-PI / 2.0);
}, },

View File

@ -86,6 +86,8 @@ skeleton_impls!(struct CharacterSkeleton {
control_r, control_r,
:: // Begin non-bone fields :: // Begin non-bone fields
holding_lantern: bool, 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, main_weapon_trail: bool,
off_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. // 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 { impl CharacterSkeleton {
pub fn new(holding_lantern: bool) -> Self { pub fn new(holding_lantern: bool, back_carry_offset: f32) -> Self {
Self { Self {
holding_lantern, holding_lantern,
back_carry_offset,
..Self::default() ..Self::default()
} }
} }

View File

@ -215,27 +215,27 @@ impl Animation for RunAnimation {
match main_tool { match main_tool {
Some(ToolKind::Dagger) => { 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 = next.main.orientation =
Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(2.0 * PI); Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(2.0 * PI);
}, },
Some(ToolKind::Shield) => { 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 = next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI); Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
}, },
Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => { 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 = next.main.orientation =
Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(PI / 2.0); Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(PI / 2.0);
}, },
Some(ToolKind::Bow) => { 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 = next.main.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); 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 = next.main.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0 + shorte * -0.2); 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 { match second_tool_kind {
Some(ToolKind::Dagger) => { 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 = next.second.orientation =
Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(-2.0 * PI); Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(-2.0 * PI);
}, },
Some(ToolKind::Shield) => { 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 = next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI); 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 = next.second.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0);
}, },
@ -288,7 +288,7 @@ impl Animation for RunAnimation {
match hands { match hands {
(Some(Hands::One), _) => match active_tool_kind { (Some(Hands::One), _) => match active_tool_kind {
Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { 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 = next.main.orientation =
Quaternion::rotation_y(2.35) * Quaternion::rotation_z(PI / 2.0); Quaternion::rotation_y(2.35) * Quaternion::rotation_z(PI / 2.0);
}, },
@ -300,7 +300,7 @@ impl Animation for RunAnimation {
match hands { match hands {
(None | Some(Hands::One), Some(Hands::One)) => match second_tool_kind { (None | Some(Hands::One), Some(Hands::One)) => match second_tool_kind {
Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { 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 = next.second.orientation =
Quaternion::rotation_y(-2.5) * Quaternion::rotation_z(-PI / 2.0); Quaternion::rotation_y(-2.5) * Quaternion::rotation_z(-PI / 2.0);
}, },

View File

@ -111,17 +111,17 @@ impl Animation for StandAnimation {
match (hands, active_tool_kind, second_tool_kind) { match (hands, active_tool_kind, second_tool_kind) {
((Some(Hands::Two), _), tool, _) | ((None, Some(Hands::Two)), _, tool) => match tool { ((Some(Hands::Two), _), tool, _) | ((None, Some(Hands::Two)), _, tool) => match tool {
Some(ToolKind::Bow) => { 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 = next.main.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0);
}, },
Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => { 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 = next.main.orientation =
Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(PI / 2.0); 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 = next.main.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0);
}, },
@ -132,17 +132,17 @@ impl Animation for StandAnimation {
match hands { match hands {
(Some(Hands::One), _) => match active_tool_kind { (Some(Hands::One), _) => match active_tool_kind {
Some(ToolKind::Dagger) => { 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 = next.main.orientation =
Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(2.0 * PI); Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(2.0 * PI);
}, },
Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { 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 = next.main.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0);
}, },
Some(ToolKind::Shield) => { 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 = next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI); Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
}, },
@ -153,17 +153,17 @@ impl Animation for StandAnimation {
match hands { match hands {
(None | Some(Hands::One), Some(Hands::One)) => match second_tool_kind { (None | Some(Hands::One), Some(Hands::One)) => match second_tool_kind {
Some(ToolKind::Dagger) => { 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 = next.second.orientation =
Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(-2.0 * PI); Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(-2.0 * PI);
}, },
Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { 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 = next.second.orientation =
Quaternion::rotation_y(-2.5) * Quaternion::rotation_z(-PI / 2.0); Quaternion::rotation_y(-2.5) * Quaternion::rotation_z(-PI / 2.0);
}, },
Some(ToolKind::Shield) => { 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 = next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI); Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
}, },

View File

@ -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::Pants => i18n.get_msg("hud-bag-legs"),
ArmorKind::Foot => i18n.get_msg("hud-bag-feet"), ArmorKind::Foot => i18n.get_msg("hud-bag-feet"),
ArmorKind::Back => i18n.get_msg("hud-bag-back"), 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::Ring => i18n.get_msg("hud-bag-ring"),
ArmorKind::Neck => i18n.get_msg("hud-bag-neck"), ArmorKind::Neck => i18n.get_msg("hud-bag-neck"),
ArmorKind::Head => i18n.get_msg("hud-bag-head"), ArmorKind::Head => i18n.get_msg("hud-bag-head"),

View File

@ -37,8 +37,9 @@ use anim::{
use common::{ use common::{
comp::{ comp::{
inventory::slot::EquipSlot, inventory::slot::EquipSlot,
item::{Hands, ItemKind, ToolKind}, item::{armor::ArmorKind, Hands, ItemKind, ToolKind},
ship::{self, figuredata::VOXEL_COLLIDER_MANIFEST}, ship::{self, figuredata::VOXEL_COLLIDER_MANIFEST},
slot::ArmorSlot,
Body, CharacterActivity, CharacterState, Collider, Controller, Health, Inventory, Item, Body, CharacterActivity, CharacterState, Collider, Controller, Health, Inventory, Item,
ItemKey, Last, LightAnimation, LightEmitter, Object, Ori, PhysicsState, PoiseState, Pos, ItemKey, Last, LightAnimation, LightEmitter, Object, Ori, PhysicsState, PoiseState, Pos,
Scale, Vel, Scale, Vel,
@ -1107,6 +1108,21 @@ impl FigureMgr {
&& !character.map_or(false, |c| c.is_using_hands()) && !character.map_or(false, |c| c.is_using_hands())
&& physics.in_liquid().is_none(); && 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 let state = self
.states .states
.character_states .character_states
@ -1114,7 +1130,7 @@ impl FigureMgr {
.or_insert_with(|| { .or_insert_with(|| {
FigureState::new( FigureState::new(
renderer, renderer,
CharacterSkeleton::new(holding_lantern), CharacterSkeleton::new(holding_lantern, back_carry_offset),
body, body,
) )
}); });
@ -1141,7 +1157,7 @@ impl FigureMgr {
// Standing or Skating // Standing or Skating
(true, false, false, false, _) | (_, _, false, false, true) => { (true, false, false, false, _) | (_, _, false, false, true) => {
anim::character::StandAnimation::update_skeleton( anim::character::StandAnimation::update_skeleton(
&CharacterSkeleton::new(holding_lantern), &CharacterSkeleton::new(holding_lantern, back_carry_offset),
( (
active_tool_kind, active_tool_kind,
second_tool_kind, second_tool_kind,
@ -1160,7 +1176,7 @@ impl FigureMgr {
// Running // Running
(true, true, false, false, _) => { (true, true, false, false, _) => {
anim::character::RunAnimation::update_skeleton( anim::character::RunAnimation::update_skeleton(
&CharacterSkeleton::new(holding_lantern), &CharacterSkeleton::new(holding_lantern, back_carry_offset),
( (
active_tool_kind, active_tool_kind,
second_tool_kind, second_tool_kind,
@ -1182,7 +1198,7 @@ impl FigureMgr {
// In air // In air
(false, _, false, false, _) => { (false, _, false, false, _) => {
anim::character::JumpAnimation::update_skeleton( anim::character::JumpAnimation::update_skeleton(
&CharacterSkeleton::new(holding_lantern), &CharacterSkeleton::new(holding_lantern, back_carry_offset),
( (
active_tool_kind, active_tool_kind,
second_tool_kind, second_tool_kind,
@ -1200,7 +1216,7 @@ impl FigureMgr {
}, },
// Swim // Swim
(_, _, true, false, _) => anim::character::SwimAnimation::update_skeleton( (_, _, true, false, _) => anim::character::SwimAnimation::update_skeleton(
&CharacterSkeleton::new(holding_lantern), &CharacterSkeleton::new(holding_lantern, back_carry_offset),
( (
active_tool_kind, active_tool_kind,
second_tool_kind, second_tool_kind,
@ -1218,7 +1234,7 @@ impl FigureMgr {
), ),
// Mount // Mount
(_, _, _, true, _) => anim::character::MountAnimation::update_skeleton( (_, _, _, true, _) => anim::character::MountAnimation::update_skeleton(
&CharacterSkeleton::new(holding_lantern), &CharacterSkeleton::new(holding_lantern, back_carry_offset),
( (
active_tool_kind, active_tool_kind,
second_tool_kind, second_tool_kind,