Merge branch 'sam/durability-fixes' into 'master'

Durability fixes

See merge request veloren/veloren!3873
This commit is contained in:
Samuel Keiffer 2023-04-15 18:03:18 +00:00
commit f14d312ac3
5 changed files with 146 additions and 11 deletions

View File

@ -214,6 +214,99 @@ recipes: {
ItemDefId("common.items.armor.misc.pants.worker_brown"): ( inputs: [], ),
ItemDefId("common.items.armor.misc.pants.worker_blue"): ( inputs: [], ),
ItemDefId("common.items.armor.misc.foot.sandals"): ( inputs: [], ),
// Twigs set
ItemDefId("common.items.armor.twigs.belt"): (
inputs: [
(Item("common.items.crafting_ing.twigs"), 1),
],
),
ItemDefId("common.items.armor.twigs.chest"): (
inputs: [
(Item("common.items.crafting_ing.twigs"), 3),
],
),
ItemDefId("common.items.armor.twigs.foot"): (
inputs: [
(Item("common.items.crafting_ing.twigs"), 1),
],
),
ItemDefId("common.items.armor.twigs.hand"): (
inputs: [
(Item("common.items.crafting_ing.twigs"), 1),
],
),
ItemDefId("common.items.armor.twigs.pants"): (
inputs: [
(Item("common.items.crafting_ing.twigs"), 2),
],
),
ItemDefId("common.items.armor.twigs.shoulder"): (
inputs: [
(Item("common.items.crafting_ing.twigs"), 2),
],
),
// Twigsleaves set
ItemDefId("common.items.armor.twigsleaves.belt"): (
inputs: [
(Item("common.items.crafting_ing.twigs"), 1),
],
),
ItemDefId("common.items.armor.twigsleaves.chest"): (
inputs: [
(Item("common.items.crafting_ing.twigs"), 3),
],
),
ItemDefId("common.items.armor.twigsleaves.foot"): (
inputs: [
(Item("common.items.crafting_ing.twigs"), 1),
],
),
ItemDefId("common.items.armor.twigsleaves.hand"): (
inputs: [
(Item("common.items.crafting_ing.twigs"), 1),
],
),
ItemDefId("common.items.armor.twigsleaves.pants"): (
inputs: [
(Item("common.items.crafting_ing.twigs"), 2),
],
),
ItemDefId("common.items.armor.twigsleaves.shoulder"): (
inputs: [
(Item("common.items.crafting_ing.twigs"), 2),
],
),
// Twigsflowers set
ItemDefId("common.items.armor.twigsflowers.belt"): (
inputs: [
(Item("common.items.crafting_ing.twigs"), 1),
],
),
ItemDefId("common.items.armor.twigsflowers.chest"): (
inputs: [
(Item("common.items.crafting_ing.twigs"), 3),
],
),
ItemDefId("common.items.armor.twigsflowers.foot"): (
inputs: [
(Item("common.items.crafting_ing.twigs"), 1),
],
),
ItemDefId("common.items.armor.twigsflowers.hand"): (
inputs: [
(Item("common.items.crafting_ing.twigs"), 1),
],
),
ItemDefId("common.items.armor.twigsflowers.pants"): (
inputs: [
(Item("common.items.crafting_ing.twigs"), 2),
],
),
ItemDefId("common.items.armor.twigsflowers.shoulder"): (
inputs: [
(Item("common.items.crafting_ing.twigs"), 2),
],
),
// ARMOR/HIDE/RAWHIDE
ItemDefId("common.items.armor.hide.rawhide.back"): (
inputs: [
@ -230,7 +323,7 @@ recipes: {
(Item("common.items.crafting_ing.leather.simple_leather"), 3),
],
),
ItemDefId("common.items.armorhide.rawhide.foot"): (
ItemDefId("common.items.armor.hide.rawhide.foot"): (
inputs: [
(Item("common.items.crafting_ing.leather.simple_leather"), 1),
],
@ -266,7 +359,7 @@ recipes: {
(Item("common.items.crafting_ing.leather.thick_leather"), 3),
],
),
ItemDefId("common.items.armorhide.leather.foot"): (
ItemDefId("common.items.armor.hide.leather.foot"): (
inputs: [
(Item("common.items.crafting_ing.leather.thick_leather"), 1),
],
@ -305,7 +398,7 @@ recipes: {
(Item("common.items.mineral.ore.veloritefrag"), 3),
],
),
ItemDefId("common.items.armorhide.scale.foot"): (
ItemDefId("common.items.armor.hide.scale.foot"): (
inputs: [
(Item("common.items.crafting_ing.hide.scales"), 1),
(Item("common.items.mineral.ore.veloritefrag"), 1),
@ -348,7 +441,7 @@ recipes: {
(Item("common.items.mineral.ore.veloritefrag"), 6),
],
),
ItemDefId("common.items.armorhide.carapace.foot"): (
ItemDefId("common.items.armor.hide.carapace.foot"): (
inputs: [
(Item("common.items.crafting_ing.hide.carapace"), 1),
(Item("common.items.mineral.ore.veloritefrag"), 2),
@ -391,7 +484,7 @@ recipes: {
(Item("common.items.mineral.ore.veloritefrag"), 9),
],
),
ItemDefId("common.items.armorhide.primal.foot"): (
ItemDefId("common.items.armor.hide.primal.foot"): (
inputs: [
(Item("common.items.crafting_ing.hide.plate"), 1),
(Item("common.items.mineral.ore.veloritefrag"), 3),
@ -1084,7 +1177,7 @@ recipes: {
},
fallback: (
inputs: [
(Item("common.items.mineral.ore.veloritefrag"), 16),
(Item("common.items.mineral.ore.veloritefrag"), 8),
],
),
)

View File

@ -293,6 +293,7 @@ pub enum ServerChatCommand {
Region,
ReloadChunks,
RemoveLights,
RepairEquipment,
Respawn,
RevokeBuild,
RevokeBuildAll,
@ -772,6 +773,9 @@ impl ServerChatCommand {
"Scale your character",
Some(Admin),
),
ServerChatCommand::RepairEquipment => {
cmd(vec![], "Repairs all equipped items", Some(Admin))
},
}
}
@ -859,6 +863,7 @@ impl ServerChatCommand {
ServerChatCommand::WeatherZone => "weather_zone",
ServerChatCommand::Lightning => "lightning",
ServerChatCommand::Scale => "scale",
ServerChatCommand::RepairEquipment => "repair_equipment",
}
}

View File

@ -1230,7 +1230,9 @@ impl Item {
DurabilityMultiplier(mult)
}
pub fn has_durability(&self) -> bool { self.kind().has_durability() }
pub fn has_durability(&self) -> bool {
self.kind().has_durability() && self.quality() != Quality::Debug
}
pub fn increment_damage(&mut self, ability_map: &AbilityMap, msm: &MaterialStatManifest) {
if let Some(durability_lost) = &mut self.durability_lost {
@ -1353,7 +1355,9 @@ impl ItemDesc for ItemDef {
fn components(&self) -> &[Item] { &[] }
fn has_durability(&self) -> bool { self.kind().has_durability() }
fn has_durability(&self) -> bool {
self.kind().has_durability() && self.quality != Quality::Debug
}
fn durability(&self) -> Option<u32> { None }

View File

@ -28,7 +28,10 @@ use common::{
self,
aura::{Aura, AuraKind, AuraTarget},
buff::{Buff, BuffCategory, BuffData, BuffKind, BuffSource},
inventory::item::{tool::AbilityMap, MaterialStatManifest, Quality},
inventory::{
item::{tool::AbilityMap, MaterialStatManifest, Quality},
slot::Slot,
},
invite::InviteKind,
AdminRole, ChatType, Inventory, Item, LightEmitter, Presence, PresenceKind, WaypointArea,
},
@ -202,6 +205,7 @@ fn do_command(
ServerChatCommand::WeatherZone => handle_weather_zone,
ServerChatCommand::Lightning => handle_lightning,
ServerChatCommand::Scale => handle_scale,
ServerChatCommand::RepairEquipment => handle_repair_equipment,
};
handler(server, client, target, args, cmd)
@ -4123,3 +4127,32 @@ fn handle_scale(
Err(action.help_string())
}
}
fn handle_repair_equipment(
server: &mut Server,
client: EcsEntity,
target: EcsEntity,
_args: Vec<String>,
action: &ServerChatCommand,
) -> CmdResult<()> {
let ecs = server.state.ecs();
if let Some(mut inventory) = ecs.write_storage::<comp::Inventory>().get_mut(target) {
let ability_map = ecs.read_resource::<AbilityMap>();
let msm = ecs.read_resource::<MaterialStatManifest>();
let slots = inventory
.equipped_items_with_slot()
.filter(|(_, item)| item.has_durability())
.map(|(slot, _)| slot)
.collect::<Vec<_>>();
for slot in slots {
inventory.repair_item_at_slot(Slot::Equip(slot), &ability_map, &msm);
}
server.notify_client(
client,
ServerGeneral::server_msg(ChatType::CommandInfo, "Repaired all equipped items"),
);
Ok(())
} else {
Err(action.help_string())
}
}

View File

@ -773,7 +773,7 @@ impl<'a> Widget for ItemTooltip<'a> {
);
diff_text(text, buff_strength_diff.1, 6)
}
if tool_durability != equipped_durability {
if tool_durability != equipped_durability && item.has_durability() {
let text = format!(
"{} {}",
&durability_diff.0,
@ -1020,7 +1020,7 @@ impl<'a> Widget for ItemTooltip<'a> {
}
index += armor_stats.stealth.is_some() as usize;
if armor_durability != equipped_durability {
if armor_durability != equipped_durability && item.has_durability() {
let diff = armor_durability.unwrap_or(Item::MAX_DURABILITY) as i32
- equipped_durability.unwrap_or(Item::MAX_DURABILITY) as i32;
let text = format!("{} {}", &durability_diff.0, diff);