mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
ItemConfig now stores AbilitySet directly instead of each individual ability.
This commit is contained in:
parent
fc01e9ea68
commit
f50fa25467
@ -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.
|
/// Returns the eye height for this humanoid.
|
||||||
pub fn eye_height(&self) -> f32 { self.height() * 0.9 }
|
pub fn eye_height(&self) -> f32 { self.height() * 0.9 }
|
||||||
|
|
||||||
|
@ -8,8 +8,7 @@ use crate::{
|
|||||||
assets::{self, AssetExt, Error},
|
assets::{self, AssetExt, Error},
|
||||||
comp::{
|
comp::{
|
||||||
inventory::{item::tool::AbilityMap, InvSlot},
|
inventory::{item::tool::AbilityMap, InvSlot},
|
||||||
skills::Skill,
|
CharacterAbility,
|
||||||
Body, CharacterAbility,
|
|
||||||
},
|
},
|
||||||
effect::Effect,
|
effect::Effect,
|
||||||
lottery::Lottery,
|
lottery::Lottery,
|
||||||
@ -184,11 +183,9 @@ impl PartialEq for ItemDef {
|
|||||||
fn eq(&self, other: &Self) -> bool { self.item_definition_id == other.item_definition_id }
|
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 struct ItemConfig {
|
||||||
pub ability1: Option<CharacterAbility>,
|
pub abilities: AbilitySet<CharacterAbility>,
|
||||||
pub ability2: Option<CharacterAbility>,
|
|
||||||
pub ability3: Option<(Option<Skill>, CharacterAbility)>,
|
|
||||||
pub block_ability: Option<CharacterAbility>,
|
pub block_ability: Option<CharacterAbility>,
|
||||||
pub dodge_ability: Option<CharacterAbility>,
|
pub dodge_ability: Option<CharacterAbility>,
|
||||||
}
|
}
|
||||||
@ -199,9 +196,7 @@ impl From<(&ItemKind, &AbilityMap)> for ItemConfig {
|
|||||||
let abilities = tool.get_abilities(map);
|
let abilities = tool.get_abilities(map);
|
||||||
|
|
||||||
return ItemConfig {
|
return ItemConfig {
|
||||||
ability1: Some(abilities.primary),
|
abilities,
|
||||||
ability2: Some(abilities.secondary),
|
|
||||||
ability3: abilities.skills.get(0).cloned(),
|
|
||||||
block_ability: None,
|
block_ability: None,
|
||||||
dodge_ability: Some(CharacterAbility::default_roll()),
|
dodge_ability: Some(CharacterAbility::default_roll()),
|
||||||
};
|
};
|
||||||
@ -368,40 +363,6 @@ impl Item {
|
|||||||
Ok(Item::new_from_item_def(inner_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
|
/// 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)) }
|
pub fn duplicate(&self) -> Self { Item::new_from_item_def(Arc::clone(&self.item_def)) }
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ impl LoadoutBuilder {
|
|||||||
let active_item = if let Some(ItemKind::Tool(_)) = main_tool.as_ref().map(|i| i.kind()) {
|
let active_item = if let Some(ItemKind::Tool(_)) = main_tool.as_ref().map(|i| i.kind()) {
|
||||||
main_tool
|
main_tool
|
||||||
} else {
|
} else {
|
||||||
Some(Item::new_default_for_body(&body))
|
Some(Item::empty())
|
||||||
};
|
};
|
||||||
|
|
||||||
// Creates rest of loadout
|
// Creates rest of loadout
|
||||||
|
@ -303,7 +303,7 @@ pub fn attempt_wield(data: &JoinData, update: &mut StateUpdate) {
|
|||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
});
|
});
|
||||||
} else {
|
} 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
|
if let Some(ability) = data
|
||||||
.inventory
|
.inventory
|
||||||
.equipped(EquipSlot::Mainhand)
|
.equipped(EquipSlot::Mainhand)
|
||||||
.and_then(|i| {
|
.map(|i| &i.item_config_expect().abilities.primary)
|
||||||
i.item_config_expect().ability1.as_ref().map(|a| {
|
.map(|a| {
|
||||||
let tool = match i.kind() {
|
let tool = unwrap_tool_data(data).map(|t| t.kind);
|
||||||
ItemKind::Tool(tool) => Some(tool.kind),
|
a.clone().adjusted_by_skills(&data.stats.skill_set, tool)
|
||||||
_ => None,
|
|
||||||
};
|
|
||||||
a.clone().adjusted_by_skills(&data.stats.skill_set, tool)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.filter(|ability| ability.requirements_paid(data, update))
|
.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
|
if let Some(ability) = data
|
||||||
.inventory
|
.inventory
|
||||||
.equipped(EquipSlot::Mainhand)
|
.equipped(EquipSlot::Mainhand)
|
||||||
.and_then(|i| {
|
.map(|i| &i.item_config_expect().abilities.secondary)
|
||||||
i.item_config_expect().ability2.as_ref().map(|a| {
|
.map(|a| {
|
||||||
let tool = match i.kind() {
|
let tool = unwrap_tool_data(data).map(|t| t.kind);
|
||||||
ItemKind::Tool(tool) => Some(tool.kind),
|
a.clone().adjusted_by_skills(&data.stats.skill_set, tool)
|
||||||
_ => None,
|
|
||||||
};
|
|
||||||
a.clone().adjusted_by_skills(&data.stats.skill_set, tool)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.filter(|ability| ability.requirements_paid(data, update))
|
.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
|
if let Some(ability) = data
|
||||||
.inventory
|
.inventory
|
||||||
.equipped(EquipSlot::Offhand)
|
.equipped(EquipSlot::Offhand)
|
||||||
.and_then(|i| {
|
.map(|i| &i.item_config_expect().abilities.secondary)
|
||||||
i.item_config_expect().ability2.as_ref().map(|a| {
|
.map(|a| {
|
||||||
let tool = match i.kind() {
|
let tool = unwrap_tool_data(data).map(|t| t.kind);
|
||||||
ItemKind::Tool(tool) => Some(tool.kind),
|
a.clone().adjusted_by_skills(&data.stats.skill_set, tool)
|
||||||
_ => None,
|
|
||||||
};
|
|
||||||
a.clone().adjusted_by_skills(&data.stats.skill_set, tool)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.filter(|ability| ability.requirements_paid(data, update))
|
.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
|
if let Some(ability) = data
|
||||||
.inventory
|
.inventory
|
||||||
.equipped(EquipSlot::Mainhand)
|
.equipped(EquipSlot::Mainhand)
|
||||||
.and_then(|i| {
|
.and_then(|i| i.item_config_expect().abilities.skills.get(0))
|
||||||
let tool = match i.kind() {
|
.and_then(|(s, a)| {
|
||||||
ItemKind::Tool(tool) => Some(tool.kind),
|
s.map_or(true, |s| data.stats.skill_set.has_skill(s))
|
||||||
_ => None,
|
.then_some(a)
|
||||||
};
|
})
|
||||||
i.item_config_expect()
|
.map(|a| {
|
||||||
.ability3
|
let tool = unwrap_tool_data(data).map(|t| t.kind);
|
||||||
.as_ref()
|
a.clone().adjusted_by_skills(&data.stats.skill_set, tool)
|
||||||
.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))
|
|
||||||
})
|
})
|
||||||
.filter(|ability| ability.requirements_paid(data, update))
|
.filter(|ability| ability.requirements_paid(data, update))
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,9 @@ impl State {
|
|||||||
let should_be_present = if let (Some(inventory), Some(stat)) = (inventory, stat) {
|
let should_be_present = if let (Some(inventory), Some(stat)) = (inventory, stat) {
|
||||||
inventory.equipped(EquipSlot::Mainhand).map_or(false, |i| {
|
inventory.equipped(EquipSlot::Mainhand).map_or(false, |i| {
|
||||||
i.item_config_expect()
|
i.item_config_expect()
|
||||||
.ability3
|
.abilities
|
||||||
|
.skills
|
||||||
|
.get(0)
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |(s, _)| {
|
.map_or(false, |(s, _)| {
|
||||||
s.map_or(true, |s| stat.skill_set.has_skill(s))
|
s.map_or(true, |s| stat.skill_set.has_skill(s))
|
||||||
|
Loading…
Reference in New Issue
Block a user