From a39923e4d6fc45470f019d0d2e70309c3afe0892 Mon Sep 17 00:00:00 2001 From: Isse Date: Thu, 3 Aug 2023 19:32:00 +0200 Subject: [PATCH] digging shovel --- .../common/abilities/ability_set_manifest.ron | 5 +++ assets/common/abilities/shovel/dig.ron | 17 +++++++ assets/common/items/weapons/tool/shovel-0.ron | 6 ++- assets/common/items/weapons/tool/shovel-1.ron | 6 ++- assets/common/recipe_book.ron | 9 ++++ assets/voxygen/element/weapons/dig.png | 3 ++ assets/voxygen/i18n/en/common.ftl | 3 ++ assets/voxygen/i18n/en/hud/misc.ftl | 2 + common/src/bin/csv_export/main.rs | 1 + common/src/comp/inventory/item/tool.rs | 2 + common/src/states/basic_melee.rs | 4 +- common/src/states/combo_melee.rs | 4 +- common/src/terrain/sprite.rs | 1 + server/agent/src/data.rs | 1 + server/src/persistence/json_models.rs | 4 +- voxygen/anim/src/biped_small/wield.rs | 2 +- voxygen/anim/src/character/alpha.rs | 8 ++-- voxygen/anim/src/character/equip.rs | 2 +- voxygen/anim/src/character/roll.rs | 4 +- voxygen/anim/src/character/stunned.rs | 2 +- voxygen/anim/src/character/wield.rs | 2 +- voxygen/src/hud/diary.rs | 1 + voxygen/src/hud/img_ids.rs | 1 + voxygen/src/hud/mod.rs | 44 +++++++++++++------ voxygen/src/hud/util.rs | 3 ++ voxygen/src/session/mod.rs | 4 +- 26 files changed, 111 insertions(+), 30 deletions(-) create mode 100644 assets/common/abilities/shovel/dig.ron create mode 100644 assets/voxygen/element/weapons/dig.png diff --git a/assets/common/abilities/ability_set_manifest.ron b/assets/common/abilities/ability_set_manifest.ron index 428d693bc1..ed9e0f2547 100644 --- a/assets/common/abilities/ability_set_manifest.ron +++ b/assets/common/abilities/ability_set_manifest.ron @@ -891,6 +891,11 @@ secondary: Simple(None, "common.abilities.pick.swing"), abilities: [], ), + Tool(Shovel): ( + primary: Simple(None, "common.abilities.shovel.dig"), + secondary: Simple(None, "common.abilities.shovel.dig"), + abilities: [], + ), Tool(Empty): ( primary: Simple(None, "common.abilities.empty.basic"), secondary: Simple(None, "common.abilities.empty.basic"), diff --git a/assets/common/abilities/shovel/dig.ron b/assets/common/abilities/shovel/dig.ron new file mode 100644 index 0000000000..dd1c02be5c --- /dev/null +++ b/assets/common/abilities/shovel/dig.ron @@ -0,0 +1,17 @@ +BasicMelee( + energy_cost: 0, + buildup_duration: 0.25, + swing_duration: 0.05, + recover_duration: 0.075, + melee_constructor: ( + kind: Stab( + damage: 5.0, + poise: 0.0, + knockback: 0.0, + energy_regen: 0.0, + ), + range: 4.5, + angle: 20.0, + ), + ori_modifier: 1.0, +) diff --git a/assets/common/items/weapons/tool/shovel-0.ron b/assets/common/items/weapons/tool/shovel-0.ron index 49ad5c2601..bf9b8228b5 100644 --- a/assets/common/items/weapons/tool/shovel-0.ron +++ b/assets/common/items/weapons/tool/shovel-0.ron @@ -2,7 +2,7 @@ ItemDef( name: "Shovel", description: "It's covered in manure.", kind: Tool(( - kind: Farming, + kind: Shovel, hands: Two, stats: ( equip_time_secs: 0.4, @@ -16,6 +16,8 @@ ItemDef( ), )), quality: Common, - tags: [], + tags: [ + CraftingTool, + ], ability_spec: None, ) \ No newline at end of file diff --git a/assets/common/items/weapons/tool/shovel-1.ron b/assets/common/items/weapons/tool/shovel-1.ron index c00ef226cd..9638f3e22b 100644 --- a/assets/common/items/weapons/tool/shovel-1.ron +++ b/assets/common/items/weapons/tool/shovel-1.ron @@ -2,7 +2,7 @@ ItemDef( name: "Shovel", description: "It's been recently cleaned.", kind: Tool(( - kind: Farming, + kind: Shovel, hands: Two, stats: ( equip_time_secs: 0.4, @@ -16,6 +16,8 @@ ItemDef( ), )), quality: Common, - tags: [], + tags: [ + CraftingTool, + ], ability_spec: None, ) \ No newline at end of file diff --git a/assets/common/recipe_book.ron b/assets/common/recipe_book.ron index e51747f3a1..76b06606ad 100644 --- a/assets/common/recipe_book.ron +++ b/assets/common/recipe_book.ron @@ -2282,4 +2282,13 @@ ], craft_sprite: Some(CraftingBench), ), + "shovel": ( + output: ("common.items.weapons.tool.shovel-0", 1), + inputs: [ + (Item("common.items.crafting_ing.twigs"), 5, false), + (Item("common.items.mineral.ingot.iron"), 2, false), + (Item("common.items.tool.craftsman_hammer"), 0, false), + ], + craft_sprite: Some(CraftingBench), + ), } diff --git a/assets/voxygen/element/weapons/dig.png b/assets/voxygen/element/weapons/dig.png new file mode 100644 index 0000000000..2d75ea6b71 --- /dev/null +++ b/assets/voxygen/element/weapons/dig.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e6a156a88c77ef82c3175df47c09e5293145b1c3c22e7157ab291fea16d5eef5 +size 359 diff --git a/assets/voxygen/i18n/en/common.ftl b/assets/voxygen/i18n/en/common.ftl index 337d9ca0d3..5a96cb845c 100644 --- a/assets/voxygen/i18n/en/common.ftl +++ b/assets/voxygen/i18n/en/common.ftl @@ -75,6 +75,7 @@ common-weapons-unique = Unique common-tool-debug = Debug common-tool-farming = Farming Tool common-tool-pick = Pickaxe +common-tool-shovel = Shovel common-tool-mining = Mining common-tool-instrument = Instrument common-kind-modular_component = Modular Component @@ -113,3 +114,5 @@ common-material-cloth = Cloth common-material-hide = Hide common-sprite-chest = Chest common-sprite-chair = Chair +common-sprite-mud = Mud +common-sprite-grave = Grave diff --git a/assets/voxygen/i18n/en/hud/misc.ftl b/assets/voxygen/i18n/en/hud/misc.ftl index f4919ca9bc..6b832607d8 100644 --- a/assets/voxygen/i18n/en/hud/misc.ftl +++ b/assets/voxygen/i18n/en/hud/misc.ftl @@ -47,7 +47,9 @@ hud-read = Read hud-unlock-requires = Open with { $item } hud-unlock-consumes = Use { $item } to open hud-mine = Mine +hud-dig = Dig hud-mine-needs_pickaxe = Needs Pickaxe +hud-mine-needs_shovel = Needs Shovel hud-mine-needs_unhandled_case = Needs ??? hud-talk = Talk hud-trade = Trade diff --git a/common/src/bin/csv_export/main.rs b/common/src/bin/csv_export/main.rs index fd3e53bfc7..2468aec2ec 100644 --- a/common/src/bin/csv_export/main.rs +++ b/common/src/bin/csv_export/main.rs @@ -180,6 +180,7 @@ fn get_tool_kind(kind: &ToolKind) -> String { ToolKind::Debug => "Debug".to_string(), ToolKind::Farming => "Farming".to_string(), ToolKind::Pick => "Pick".to_string(), + ToolKind::Shovel => "Shovel".to_string(), ToolKind::Instrument => "Instrument".to_string(), ToolKind::Natural => "Natural".to_string(), ToolKind::Empty => "Empty".to_string(), diff --git a/common/src/comp/inventory/item/tool.rs b/common/src/comp/inventory/item/tool.rs index 9aeadb7e6f..f70674708b 100644 --- a/common/src/comp/inventory/item/tool.rs +++ b/common/src/comp/inventory/item/tool.rs @@ -36,6 +36,7 @@ pub enum ToolKind { Debug, Farming, Pick, + Shovel, // npcs /// Intended for invisible weapons (e.g. a creature using its claws or /// biting) @@ -64,6 +65,7 @@ impl ToolKind { ToolKind::Debug => "debug", ToolKind::Farming => "farming", ToolKind::Pick => "pickaxe", + ToolKind::Shovel => "shovel", ToolKind::Instrument => "instrument", ToolKind::Empty => "empty", } diff --git a/common/src/states/basic_melee.rs b/common/src/states/basic_melee.rs index cd91f40a28..c39cb05a7d 100644 --- a/common/src/states/basic_melee.rs +++ b/common/src/states/basic_melee.rs @@ -91,7 +91,9 @@ impl CharacterBehavior for Data { self.static_data.ability_info.tool, ) }) - .filter(|(_, tool)| tool == &Some(ToolKind::Pick)), + .filter(|(_, tool)| { + matches!(tool, Some(ToolKind::Pick | ToolKind::Shovel)) + }), ), ); } else if self.timer < self.static_data.swing_duration { diff --git a/common/src/states/combo_melee.rs b/common/src/states/combo_melee.rs index f8c55d0103..f72ff9978e 100644 --- a/common/src/states/combo_melee.rs +++ b/common/src/states/combo_melee.rs @@ -282,7 +282,9 @@ impl CharacterBehavior for Data { self.static_data.ability_info.tool, ) }) - .filter(|(_, tool)| tool == &Some(ToolKind::Pick)), + .filter(|(_, tool)| { + matches!(tool, Some(ToolKind::Pick | ToolKind::Shovel)) + }), }); } else if self.timer < self.static_data.stage_data[stage_index].base_swing_duration { diff --git a/common/src/terrain/sprite.rs b/common/src/terrain/sprite.rs index c9333ebb77..373dd0cee4 100644 --- a/common/src/terrain/sprite.rs +++ b/common/src/terrain/sprite.rs @@ -627,6 +627,7 @@ impl SpriteKind { | SpriteKind::Silver | SpriteKind::Gold | SpriteKind::SapphireSmall => Some(ToolKind::Pick), + SpriteKind::Grave | SpriteKind::Mud => Some(ToolKind::Shovel), _ => None, } } diff --git a/server/agent/src/data.rs b/server/agent/src/data.rs index f81dd65389..a5537684e9 100644 --- a/server/agent/src/data.rs +++ b/server/agent/src/data.rs @@ -118,6 +118,7 @@ impl<'a> TargetData<'a> { | ToolKind::Spear | ToolKind::Farming | ToolKind::Pick + | ToolKind::Shovel | ToolKind::Natural | ToolKind::Empty, ) diff --git a/server/src/persistence/json_models.rs b/server/src/persistence/json_models.rs index f8c4e1d147..13370b29bd 100644 --- a/server/src/persistence/json_models.rs +++ b/server/src/persistence/json_models.rs @@ -86,7 +86,8 @@ pub fn skill_group_to_db_string(skill_group: comp::skillset::SkillGroupKind) -> | Weapon(ToolKind::Farming) | Weapon(ToolKind::Instrument) | Weapon(ToolKind::Empty) - | Weapon(ToolKind::Natural) => panic!( + | Weapon(ToolKind::Natural) + | Weapon(ToolKind::Shovel) => panic!( "Tried to add unsupported skill group to database: {:?}", skill_group ), @@ -200,6 +201,7 @@ fn tool_kind_to_string(tool: Option) -> String { Some(Spear) => "Spear", Some(Blowgun) => "Blowgun", Some(Pick) => "Pick", + Some(Shovel) => "Shovel", // Toolkinds that are not anticipated to have many active abilities (if any at all) Some(Farming) => "Farming", diff --git a/voxygen/anim/src/biped_small/wield.rs b/voxygen/anim/src/biped_small/wield.rs index 33600489b7..9e56c1fdf5 100644 --- a/voxygen/anim/src/biped_small/wield.rs +++ b/voxygen/anim/src/biped_small/wield.rs @@ -167,7 +167,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_y(-0.2 * speednorm) * Quaternion::rotation_z(0.5); }, - Some(ToolKind::Axe | ToolKind::Hammer | ToolKind::Pick) => { + Some(ToolKind::Axe | ToolKind::Hammer | ToolKind::Pick | ToolKind::Shovel) => { next.control_l.position = Vec3::new(2.0 - s_a.grip.0 * 2.0, 1.0, 3.0); next.control_r.position = Vec3::new(9.0 + s_a.grip.0 * 2.0, -1.0, -2.0 + speednorm * -3.0); diff --git a/voxygen/anim/src/character/alpha.rs b/voxygen/anim/src/character/alpha.rs index 90a48ef1ee..0ac1933dbd 100644 --- a/voxygen/anim/src/character/alpha.rs +++ b/voxygen/anim/src/character/alpha.rs @@ -65,7 +65,7 @@ impl Animation for AlphaAnimation { next.head.orientation = Quaternion::rotation_z(move1 * -0.9 + move2 * 1.8); }, - Some(ToolKind::Hammer) | Some(ToolKind::Pick) => { + Some(ToolKind::Hammer) | Some(ToolKind::Pick) | Some(ToolKind::Shovel) => { let (move1, move2, move3) = match stage_section { Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0), Some(StageSection::Action) => (1.0, anim_time.powf(0.25), 0.0), @@ -96,7 +96,7 @@ impl Animation for AlphaAnimation { match hands { (Some(Hands::Two), _) | (None, Some(Hands::Two)) => { match ability_info.and_then(|a| a.tool) { - Some(ToolKind::Hammer) | Some(ToolKind::Pick) => { + Some(ToolKind::Hammer) | Some(ToolKind::Pick) | Some(ToolKind::Shovel) => { let (move1, move2, move3) = match stage_section { Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0), Some(StageSection::Action) => (1.0, anim_time, 0.0), @@ -144,7 +144,7 @@ impl Animation for AlphaAnimation { next.hand_l.position = Vec3::new(0.0, -0.5, 0.0); next.hand_l.orientation = Quaternion::rotation_x(PI / 2.0) }, - Some(ToolKind::Hammer) | Some(ToolKind::Pick) => { + Some(ToolKind::Hammer) | Some(ToolKind::Pick) | Some(ToolKind::Shovel) => { next.control_l.position = Vec3::new( -7.0, 8.0 + move1 * -4.0 + move2 * 4.0, @@ -173,7 +173,7 @@ impl Animation for AlphaAnimation { next.hand_r.position = Vec3::new(0.0, -0.5, 0.0); next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0) }, - Some(ToolKind::Hammer) | Some(ToolKind::Pick) => { + Some(ToolKind::Hammer) | Some(ToolKind::Pick) | Some(ToolKind::Shovel) => { next.control_r.position = Vec3::new( 7.0, 8.0 + move1 * -4.0 + move2h * 4.0, diff --git a/voxygen/anim/src/character/equip.rs b/voxygen/anim/src/character/equip.rs index fd9f8db51d..fcaaa2eea0 100644 --- a/voxygen/anim/src/character/equip.rs +++ b/voxygen/anim/src/character/equip.rs @@ -39,7 +39,7 @@ impl Animation for EquipAnimation { next.hand_l.position = Vec3::new(-7.0, -5.0, 17.0); next.hand_r.position = Vec3::new(-5.0, -4.5, 14.0); }, - Some(ToolKind::Hammer | ToolKind::Pick) => { + Some(ToolKind::Hammer | ToolKind::Pick | ToolKind::Shovel) => { next.hand_l.position = Vec3::new(-5.0, -5.0, 13.0); next.hand_r.position = Vec3::new(-3.0, -4.5, 10.0); }, diff --git a/voxygen/anim/src/character/roll.rs b/voxygen/anim/src/character/roll.rs index 930490f4f2..aeae182ef7 100644 --- a/voxygen/anim/src/character/roll.rs +++ b/voxygen/anim/src/character/roll.rs @@ -103,7 +103,9 @@ impl Animation for RollAnimation { * Quaternion::rotation_y(s_a.ac.4) * Quaternion::rotation_z(s_a.ac.5); }, - Some(ToolKind::Hammer | ToolKind::Pick | ToolKind::Instrument) => { + Some( + ToolKind::Hammer | ToolKind::Pick | ToolKind::Shovel | ToolKind::Instrument, + ) => { next.hand_l.position = Vec3::new(s_a.hhl.0, s_a.hhl.1, s_a.hhl.2); next.hand_l.orientation = Quaternion::rotation_x(s_a.hhl.3) * Quaternion::rotation_y(s_a.hhl.4) diff --git a/voxygen/anim/src/character/stunned.rs b/voxygen/anim/src/character/stunned.rs index a08929e08a..966efa0e78 100644 --- a/voxygen/anim/src/character/stunned.rs +++ b/voxygen/anim/src/character/stunned.rs @@ -99,7 +99,7 @@ impl Animation for StunnedAnimation { * Quaternion::rotation_y(s_a.ac.4) * Quaternion::rotation_z(s_a.ac.5); }, - Some(ToolKind::Hammer | ToolKind::Pick) => { + Some(ToolKind::Hammer | ToolKind::Pick | ToolKind::Shovel) => { next.hand_l.position = Vec3::new(s_a.hhl.0, s_a.hhl.1, s_a.hhl.2); next.hand_l.orientation = Quaternion::rotation_x(s_a.hhl.3) * Quaternion::rotation_y(s_a.hhl.4) diff --git a/voxygen/anim/src/character/wield.rs b/voxygen/anim/src/character/wield.rs index 7863d3a424..dd211094b8 100644 --- a/voxygen/anim/src/character/wield.rs +++ b/voxygen/anim/src/character/wield.rs @@ -223,7 +223,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_y(s_a.ac.4) * Quaternion::rotation_z(s_a.ac.5); }, - Some(ToolKind::Hammer) | Some(ToolKind::Pick) => { + Some(ToolKind::Hammer) | Some(ToolKind::Pick) | Some(ToolKind::Shovel) => { next.hand_l.position = Vec3::new(s_a.hhl.0, s_a.hhl.1, s_a.hhl.2); next.hand_l.orientation = Quaternion::rotation_x(s_a.hhl.3) * Quaternion::rotation_y(s_a.hhl.4) diff --git a/voxygen/src/hud/diary.rs b/voxygen/src/hud/diary.rs index 347cca0b96..ebe262af66 100644 --- a/voxygen/src/hud/diary.rs +++ b/voxygen/src/hud/diary.rs @@ -2937,6 +2937,7 @@ fn unlock_skill_strings(group: SkillGroupKind) -> SkillStrings<'static> { | ToolKind::Farming | ToolKind::Instrument | ToolKind::Pick + | ToolKind::Shovel | ToolKind::Natural | ToolKind::Empty, ) => { diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index 9efa4d1424..1e7fedb214 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -92,6 +92,7 @@ image_ids! { bow: "voxygen.element.weapons.bow", staff: "voxygen.element.weapons.staff", mining: "voxygen.element.weapons.mining", + dig: "voxygen.element.weapons.dig", pickaxe: "voxygen.element.skills.pickaxe", pickaxe_ico: "voxygen.element.weapons.pickaxe", skilltree_ico: "voxygen.element.ui.diary.buttons.skilltree", diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 283ddac7e5..b8bfc8949b 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -2099,15 +2099,34 @@ impl Hud { }, BlockInteraction::Mine(mine_tool) => { if info.is_mining { - vec![( - Some(GameInput::Primary), - i18n.get_msg("hud-mine").to_string(), - )] + match mine_tool { + ToolKind::Pick => { + vec![( + Some(GameInput::Primary), + i18n.get_msg("hud-mine").to_string(), + )] + }, + ToolKind::Shovel => { + vec![( + Some(GameInput::Primary), + i18n.get_msg("hud-dig").to_string(), + )] + }, + _ => { + vec![( + None, + i18n.get_msg("hud-mine-needs_unhandled_case").to_string(), + )] + }, + } } else { match mine_tool { ToolKind::Pick => { vec![(None, i18n.get_msg("hud-mine-needs_pickaxe").to_string())] }, + ToolKind::Shovel => { + vec![(None, i18n.get_msg("hud-mine-needs_shovel").to_string())] + } // TODO: The required tool for mining something may not always be a // pickaxe! _ => { @@ -2148,10 +2167,11 @@ impl Hud { overitem_properties, self.pulse, &global_state.window.key_layout, - vec![( - Some(GameInput::Interact), - i18n.get_msg("hud-open").to_string(), - )], + interaction_text(), + // vec![( + // Some(GameInput::Interact), + // i18n.get_msg("hud-open").to_string(), + // )], ) .x_y(0.0, 100.0) .position_ingame(over_pos) @@ -2160,11 +2180,7 @@ impl Hud { // TODO: Handle this better. The items returned from `try_reclaim_from_block` // are based on rng. We probably want some function to get only gauranteed items // from `LootSpec`. - else if let Some((amount, mut item)) = Item::try_reclaim_from_block(*block) - .into_iter() - .flatten() - .next() - { + else if let Some((amount, mut item)) = Item::try_reclaim_from_block(*block).into_iter().flatten().next() { item.set_amount(amount.clamp(1, item.max_amount())) .expect("amount >= 1 and <= max_amount is always a valid amount"); make_overitem( @@ -5242,6 +5258,8 @@ pub fn get_sprite_desc(sprite: SpriteKind, localized_strings: &Localization) -> | SpriteKind::DungeonChest3 | SpriteKind::DungeonChest4 | SpriteKind::DungeonChest5 => "common-sprite-chest", + SpriteKind::Mud => "common-sprite-mud", + SpriteKind::Grave => "common-sprite-grave", SpriteKind::ChairSingle | SpriteKind::ChairDouble => "common-sprite-chair", sprite => return Some(Cow::Owned(format!("{:?}", sprite))), }; diff --git a/voxygen/src/hud/util.rs b/voxygen/src/hud/util.rs index f4a69fddca..94e07b1eb7 100644 --- a/voxygen/src/hud/util.rs +++ b/voxygen/src/hud/util.rs @@ -320,6 +320,7 @@ fn tool_kind<'a>(tool: &Tool, i18n: &'a Localization) -> Cow<'a, str> { ToolKind::Farming => i18n.get_msg("common-tool-farming"), ToolKind::Instrument => i18n.get_msg("common-tool-instrument"), ToolKind::Pick => i18n.get_msg("common-tool-pick"), + ToolKind::Shovel => i18n.get_msg("common-tool-shovel"), ToolKind::Empty => i18n.get_msg("common-empty"), }; kind @@ -533,6 +534,8 @@ pub fn ability_image(imgs: &img_ids::Imgs, ability_id: &str) -> image::Id { "common.abilities.dagger.tempbasic" => imgs.onehdagger_m1, // Pickaxe "common.abilities.pick.swing" => imgs.mining, + // Shovel + "common.abilities.shovel.dig" => imgs.dig, // Instruments "common.abilities.music.bass" => imgs.instrument, "common.abilities.music.flute" => imgs.instrument, diff --git a/voxygen/src/session/mod.rs b/voxygen/src/session/mod.rs index 8de173a55d..71d0b99fcc 100644 --- a/voxygen/src/session/mod.rs +++ b/voxygen/src/session/mod.rs @@ -603,7 +603,9 @@ impl PlayState for SessionState { .get(player_entity) .and_then(|inv| inv.equipped(EquipSlot::ActiveMainhand)) .and_then(|item| item.tool_info()) - .map_or(false, |tool_kind| tool_kind == ToolKind::Pick) + .map_or(false, |tool_kind| { + matches!(tool_kind, ToolKind::Pick | ToolKind::Shovel) + }) && client.is_wielding() == Some(true); // Check to see whether we're aiming at anything