diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs index 5cfd6d72ac..b7d646636d 100644 --- a/common/src/comp/body.rs +++ b/common/src/comp/body.rs @@ -452,184 +452,6 @@ impl Body { } } - #[allow(unreachable_patterns)] - pub fn base_exp(&self) -> u32 { - match self { - Body::Humanoid(_) => 5, - Body::QuadrupedSmall(quadruped_small) => match quadruped_small.species { - quadruped_small::Species::Boar => 6, - quadruped_small::Species::Batfox => 2, - quadruped_small::Species::Dodarock => 6, - quadruped_small::Species::Holladon => 8, - quadruped_small::Species::Hyena => 6, - quadruped_small::Species::Truffler => 6, - _ => 4, - }, - Body::QuadrupedMedium(quadruped_medium) => match quadruped_medium.species { - quadruped_medium::Species::Grolgar => 10, - quadruped_medium::Species::Saber => 8, - quadruped_medium::Species::Tiger => 8, - quadruped_medium::Species::Tuskram => 9, - quadruped_medium::Species::Lion => 10, - quadruped_medium::Species::Tarasque => 16, - quadruped_medium::Species::Wolf => 8, - quadruped_medium::Species::Frostfang => 9, - quadruped_medium::Species::Mouflon => 7, - quadruped_medium::Species::Catoblepas => 10, - quadruped_medium::Species::Bonerattler => 10, - quadruped_medium::Species::Deer => 6, - quadruped_medium::Species::Hirdrasil => 9, - quadruped_medium::Species::Roshwalr => 10, - quadruped_medium::Species::Donkey => 8, - quadruped_medium::Species::Camel => 8, - quadruped_medium::Species::Zebra => 8, - quadruped_medium::Species::Antelope => 6, - quadruped_medium::Species::Kelpie => 8, - quadruped_medium::Species::Horse => 8, - _ => 6, - }, - Body::BirdMedium(bird_medium) => match bird_medium.species { - bird_medium::Species::Chicken => 2, - bird_medium::Species::Duck => 2, - bird_medium::Species::Goose => 4, - bird_medium::Species::Parrot => 4, - bird_medium::Species::Peacock => 5, - _ => 8, - }, - Body::FishMedium(_) => 2, - Body::Dragon(_) => 1000, - Body::BirdSmall(_) => 2, - Body::FishSmall(_) => 2, - Body::BipedLarge(biped_large) => match biped_large.species { - biped_large::Species::Ogre => 60, - biped_large::Species::Cyclops => 70, - biped_large::Species::Wendigo => 70, - biped_large::Species::Troll => 50, - biped_large::Species::Dullahan => 100, - biped_large::Species::Mindflayer => 150, - _ => 100, - }, - Body::Object(_) => 1, - Body::Golem(_) => 256, - Body::Theropod(theropod) => match theropod.species { - theropod::Species::Archaeos => 90, - theropod::Species::Odonto => 80, - _ => 50, - }, - Body::QuadrupedLow(quadruped_low) => match quadruped_low.species { - quadruped_low::Species::Crocodile => 10, - quadruped_low::Species::Alligator => 10, - quadruped_low::Species::Salamander => 6, - quadruped_low::Species::Monitor => 4, - quadruped_low::Species::Asp => 4, - quadruped_low::Species::Tortoise => 6, - quadruped_low::Species::Rocksnapper => 12, - quadruped_low::Species::Pangolin => 3, - quadruped_low::Species::Maneater => 14, - quadruped_low::Species::Sandshark => 12, - quadruped_low::Species::Hakulaq => 10, - quadruped_low::Species::Lavadrake => 20, - _ => 10, - }, - } - } - - #[allow(unreachable_patterns)] - pub fn base_dmg(&self) -> f32 { - match self { - Body::Humanoid(_) => 50.0, - Body::QuadrupedSmall(quadruped_small) => match quadruped_small.species { - quadruped_small::Species::Dodarock => 30.0, - quadruped_small::Species::Hyena => 40.0, - quadruped_small::Species::Holladon => 40.0, - quadruped_small::Species::Porcupine => 30.0, - _ => 20.0, - }, - Body::QuadrupedMedium(quadruped_medium) => match quadruped_medium.species { - quadruped_medium::Species::Grolgar => 50.0, - quadruped_medium::Species::Lion => 60.0, - quadruped_medium::Species::Tarasque => 70.0, - quadruped_medium::Species::Mouflon => 30.0, - quadruped_medium::Species::Catoblepas => 20.0, - quadruped_medium::Species::Bonerattler => 50.0, - quadruped_medium::Species::Deer => 30.0, - quadruped_medium::Species::Hirdrasil => 50.0, - quadruped_medium::Species::Roshwalr => 60.0, - quadruped_medium::Species::Donkey => 40.0, - quadruped_medium::Species::Camel => 40.0, - quadruped_medium::Species::Zebra => 40.0, - quadruped_medium::Species::Antelope => 6.0, - quadruped_medium::Species::Kelpie => 60.0, - quadruped_medium::Species::Horse => 50.0, - _ => 40.0, - }, - Body::BirdMedium(bird_medium) => match bird_medium.species { - bird_medium::Species::Chicken => 10.0, - bird_medium::Species::Duck => 10.0, - bird_medium::Species::Goose => 10.0, - bird_medium::Species::Parrot => 20.0, - bird_medium::Species::Peacock => 40.0, - bird_medium::Species::Cockatrice => 60.0, - bird_medium::Species::Eagle => 60.0, - _ => 30.0, - }, - Body::FishMedium(_) => 10.0, - Body::Dragon(_) => 5000.0, - Body::BirdSmall(_) => 10.0, - Body::FishSmall(_) => 10.0, - Body::BipedLarge(biped_large) => match biped_large.species { - biped_large::Species::Ogre => 60.0, - biped_large::Species::Cyclops => 60.0, - biped_large::Species::Wendigo => 60.0, - biped_large::Species::Troll => 60.0, - biped_large::Species::Dullahan => 80.0, - biped_large::Species::Mindflayer => 200.0, - _ => 60.0, - }, - Body::Object(_) => 0.0, - Body::Golem(_) => 250.0, - Body::Theropod(theropod) => match theropod.species { - theropod::Species::Archaeos => 150.0, - theropod::Species::Odonto => 130.0, - _ => 70.0, - }, - Body::QuadrupedLow(quadruped_low) => match quadruped_low.species { - quadruped_low::Species::Crocodile => 50.0, - quadruped_low::Species::Alligator => 50.0, - quadruped_low::Species::Salamander => 50.0, - quadruped_low::Species::Monitor => 30.0, - quadruped_low::Species::Asp => 35.0, - quadruped_low::Species::Tortoise => 10.0, - quadruped_low::Species::Rocksnapper => 80.0, - quadruped_low::Species::Pangolin => 10.0, - quadruped_low::Species::Maneater => 40.0, - quadruped_low::Species::Sandshark => 60.0, - quadruped_low::Species::Hakulaq => 40.0, - _ => 20.0, - }, - } - } - - pub fn base_poise_dmg(&self) -> f32 { 0.0 } - - pub fn base_range(&self) -> f32 { - match self { - Body::Humanoid(_) => 5.0, - Body::QuadrupedSmall(_) => 4.5, - Body::QuadrupedMedium(_) => 5.5, - Body::BirdMedium(_) => 3.5, - Body::FishMedium(_) => 3.5, - Body::Dragon(_) => 12.5, - Body::BirdSmall(_) => 3.0, - Body::FishSmall(_) => 3.0, - Body::BipedLarge(_) => 10.0, - Body::Object(_) => 3.0, - Body::Golem(_) => 7.5, - Body::Theropod(_) => 3.0, - Body::QuadrupedLow(_) => 4.5, - } - } - /// Returns the eye height for this humanoid. pub fn eye_height(&self) -> f32 { self.height() * 0.9 } diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index 28c2725266..ae1adbcef1 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -8,8 +8,7 @@ use crate::{ assets::{self, AssetExt, Error}, comp::{ inventory::{item::tool::AbilityMap, InvSlot}, - skills::Skill, - Body, CharacterAbility, + CharacterAbility, }, effect::Effect, lottery::Lottery, @@ -184,11 +183,9 @@ impl PartialEq for ItemDef { fn eq(&self, other: &Self) -> bool { self.item_definition_id == other.item_definition_id } } -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct ItemConfig { - pub ability1: Option, - pub ability2: Option, - pub ability3: Option<(Option, CharacterAbility)>, + pub abilities: AbilitySet, pub block_ability: Option, pub dodge_ability: Option, } @@ -199,9 +196,7 @@ impl From<(&ItemKind, &AbilityMap)> for ItemConfig { let abilities = tool.get_abilities(map); return ItemConfig { - ability1: Some(abilities.primary), - ability2: Some(abilities.secondary), - ability3: abilities.skills.get(0).cloned(), + abilities, block_ability: None, dodge_ability: Some(CharacterAbility::default_roll()), }; @@ -368,40 +363,6 @@ impl Item { Ok(Item::new_from_item_def(inner_item)) } - pub fn new_default_for_body(body: &Body) -> Self { - let mut item = Item::new_from_asset_expect("common.items.weapons.empty.empty"); - - let empty_def = &*item.item_def; - item.item_def = Arc::new(ItemDef { - slots: empty_def.slots, - name: empty_def.name.clone(), - kind: empty_def.kind.clone(), - description: empty_def.description.clone(), - item_definition_id: empty_def.item_definition_id.clone(), - quality: empty_def.quality, - tags: Vec::new(), - item_config: Some(ItemConfig { - ability1: Some(CharacterAbility::BasicMelee { - energy_cost: 0.010, - buildup_duration: 0.5, - swing_duration: 0.1, - recover_duration: 0.1, - base_damage: body.base_dmg(), - base_poise_damage: body.base_poise_dmg(), - knockback: 0.0, - range: body.base_range(), - max_angle: 20.0, - }), - ability2: None, - ability3: None, - block_ability: None, - dodge_ability: None, - }), - }); - - item - } - /// Duplicates an item, creating an exact copy but with a new item ID pub fn duplicate(&self) -> Self { Item::new_from_item_def(Arc::clone(&self.item_def)) } diff --git a/common/src/comp/inventory/loadout_builder.rs b/common/src/comp/inventory/loadout_builder.rs index 7ea301dd78..ff81dcf0df 100644 --- a/common/src/comp/inventory/loadout_builder.rs +++ b/common/src/comp/inventory/loadout_builder.rs @@ -235,7 +235,7 @@ impl LoadoutBuilder { let active_item = if let Some(ItemKind::Tool(_)) = main_tool.as_ref().map(|i| i.kind()) { main_tool } else { - Some(Item::new_default_for_body(&body)) + Some(Item::empty()) }; // Creates rest of loadout diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 8c8ab7b223..6b382f1fec 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -303,7 +303,7 @@ pub fn attempt_wield(data: &JoinData, update: &mut StateUpdate) { timer: Duration::default(), }); } else { - update.character = CharacterState::Idle; + update.character = CharacterState::Wielding; }; } @@ -404,14 +404,10 @@ pub fn handle_ability1_input(data: &JoinData, update: &mut StateUpdate) { if let Some(ability) = data .inventory .equipped(EquipSlot::Mainhand) - .and_then(|i| { - i.item_config_expect().ability1.as_ref().map(|a| { - let tool = match i.kind() { - ItemKind::Tool(tool) => Some(tool.kind), - _ => None, - }; - a.clone().adjusted_by_skills(&data.stats.skill_set, tool) - }) + .map(|i| &i.item_config_expect().abilities.primary) + .map(|a| { + let tool = unwrap_tool_data(data).map(|t| t.kind); + a.clone().adjusted_by_skills(&data.stats.skill_set, tool) }) .filter(|ability| ability.requirements_paid(data, update)) { @@ -445,14 +441,10 @@ pub fn handle_ability2_input(data: &JoinData, update: &mut StateUpdate) { if let Some(ability) = data .inventory .equipped(EquipSlot::Mainhand) - .and_then(|i| { - i.item_config_expect().ability2.as_ref().map(|a| { - let tool = match i.kind() { - ItemKind::Tool(tool) => Some(tool.kind), - _ => None, - }; - a.clone().adjusted_by_skills(&data.stats.skill_set, tool) - }) + .map(|i| &i.item_config_expect().abilities.secondary) + .map(|a| { + let tool = unwrap_tool_data(data).map(|t| t.kind); + a.clone().adjusted_by_skills(&data.stats.skill_set, tool) }) .filter(|ability| ability.requirements_paid(data, update)) { @@ -463,14 +455,10 @@ pub fn handle_ability2_input(data: &JoinData, update: &mut StateUpdate) { if let Some(ability) = data .inventory .equipped(EquipSlot::Offhand) - .and_then(|i| { - i.item_config_expect().ability2.as_ref().map(|a| { - let tool = match i.kind() { - ItemKind::Tool(tool) => Some(tool.kind), - _ => None, - }; - a.clone().adjusted_by_skills(&data.stats.skill_set, tool) - }) + .map(|i| &i.item_config_expect().abilities.secondary) + .map(|a| { + let tool = unwrap_tool_data(data).map(|t| t.kind); + a.clone().adjusted_by_skills(&data.stats.skill_set, tool) }) .filter(|ability| ability.requirements_paid(data, update)) { @@ -487,19 +475,14 @@ pub fn handle_ability3_input(data: &JoinData, update: &mut StateUpdate) { if let Some(ability) = data .inventory .equipped(EquipSlot::Mainhand) - .and_then(|i| { - let tool = match i.kind() { - ItemKind::Tool(tool) => Some(tool.kind), - _ => None, - }; - i.item_config_expect() - .ability3 - .as_ref() - .and_then(|(s, a)| { - s.map_or(true, |s| data.stats.skill_set.has_skill(s)) - .then_some(a) - }) - .map(|a| a.clone().adjusted_by_skills(&data.stats.skill_set, tool)) + .and_then(|i| i.item_config_expect().abilities.skills.get(0)) + .and_then(|(s, a)| { + s.map_or(true, |s| data.stats.skill_set.has_skill(s)) + .then_some(a) + }) + .map(|a| { + let tool = unwrap_tool_data(data).map(|t| t.kind); + a.clone().adjusted_by_skills(&data.stats.skill_set, tool) }) .filter(|ability| ability.requirements_paid(data, update)) { diff --git a/voxygen/src/hud/hotbar.rs b/voxygen/src/hud/hotbar.rs index 9673e759b9..cd3909baa2 100644 --- a/voxygen/src/hud/hotbar.rs +++ b/voxygen/src/hud/hotbar.rs @@ -76,7 +76,9 @@ impl State { let should_be_present = if let (Some(inventory), Some(stat)) = (inventory, stat) { inventory.equipped(EquipSlot::Mainhand).map_or(false, |i| { i.item_config_expect() - .ability3 + .abilities + .skills + .get(0) .as_ref() .map_or(false, |(s, _)| { s.map_or(true, |s| stat.skill_set.has_skill(s))