[WIP] Weapon Durability

Here we have it!

Weapon durability and repairing.

Right now it’s only when you smash another object. All objects can be repaired using the standard tools.

It gives you a very slight chance to damage the weapon based on a number of factors.

This is the code:

[code] if (u.is_armed()) {
// Damage our weapon.
item* damage_weapon = &(u.weapon);
int damage = 10000 / ((u.weapon.weight() + 1) * (u.weapon.volume() / 2 + 1));
if (damage_weapon->made_of(“wood”)) {
damage *= 1.5;
} else if (damage_weapon->made_of(“plastic”)) {
damage *= 1.25;
} else if (damage_weapon->made_of(“glass”)) {
damage *= 2;
}
damage /= u.skillLevel(“melee”).level() / 10 + 1; // Reduce damage based on our skill.
damage *= u.str_cur / 8 + 1; // Change damage based on our strength.
damage /= damage_weapon->damage_bash() / 10 + 1; // Decrease damage based on bashing ability.

        int targetweight = 5;
        furn_t target = m.furn_at(smashx, smashy);
        targetweight = target.move_str_req + 1;
        damage *= targetweight;

        // Do the roll.
        if (rng(0, targetweight * 5) > damage) {
            damage_weapon->damage++;
            if (damage_weapon->damage > 4) {
                add_msg(_("You destroy your%s!"), damage_weapon->tname().c_str());
                u.remove_weapon();
            }
            else {
                add_msg(_("You damage your %s!"), damage_weapon->tname().c_str());
            }
        }
    }[/code]

The damage is based on:
Your strength (Higher = takes more. Determines how many times you need to hit to break the object anyway).
The weapon’s weight and volume. (Higher = takes less)
Your weapon’s bashing damage. (Higher = takes less)
The weapon’s material (Wood = 1.5 more likely, plastic = 1.25, glass = 2, everything else has no modifier)
Your melee skill. (Higher = takes less)
The smashable object’s weight (Higher = takes more)

The result is a chance for your weapon to get damaged. It can be repaired with the standard tools and materials just like armour, but not reinforced.
Big heavy metal objects will be better for bashing than small light ones or wood. The solution is to pick up a junk object when you want to smash something.
It also means you can now destroy objects without acid.

Wait.

If your weapon gets damaged, shouldn’t your fists get damaged too?

Why yes!

You’ll take some random damage when you smash an object with your fists, based on your strength and the volume of the object to smash.

Next will be damage from attacking mobs. Bashing weapons will follow the same principle as this but at a severely reduced rate. Cutting weapons will almost never get damaged, piercing weapons too. There will be a higher chance for damage if your weapon gets stuck.

After that, I’ll add firearm durability.

The durability of firearms seems… somewhat unrealistic when I look at some suggestions.

In reality, the durability of the firearm usually depends on the condition of the barrel, and many fresh gun barrels can withstand 5-6,000 continuously-fired rounds, some upwards of 15,000. If you’re finding your guns off of gun store shelves, you can safely assume that the barrels are fresh and would not need to be repaired or replaced for a good while.

However, I’m thinking that adding durability in the form of stress on and fouling of the action would be reasonable. For standard rounds, you could probably fire about 600-800 rounds before needing to clean your gun, and the action would remain in proper working order. With high-pressure loads, however (9mm +P, for example), more regular maintenance should be required more often; the action would also likely be damaged slightly with each shot, as the internals aren’t generally used to extra pressure from the high-pressure loads.

That’s just my $0.02 on the matter. Feel free to take in or disregard this.

Yeah BadSniper.

I have no intention of adding breakage for firearms when you fire them.

Rather, breakage for firearms would be based on whether you attack with it in melee. Firearms with bayonets would take no damage, but your bayonet would have a chance to be destroyed (very low chance mind you, it’s easily craftable anyway; “it snaps off!”, yielding the parts needed to craft it).

In terms of firing the gun, it will have a chance to jam. Jamming can be prevented by activating the firearm (“Do you want to maintain your %f?”). The maintained %f will go back to neutral status instead of jamming.

The chance for it to jam from maintained status will be very low and will be based on the damage of the ammo type, and the weapon’s durability rating (these are already in the files).

At normal status the chance is slightly higher, but still significantly low and very unlikely to happen.

[quote=“freezerbunny, post:3, topic:3949”]Rather, breakage for firearms would be based on whether you attack with it. Firearms with bayonets would take no damage, but your bayonet would have a chance to be destroyed (very low chance mind you, it’s easily craftable anyway; “it snaps off!”, yielding the parts needed to craft it).[/quote]Ah, okay. That makes much better sense.

In terms of firing the gun, it will have a chance to jam. Jamming can be prevented by activating the firearm ("Do you want to maintain your %f?"). The maintained %f will go back to neutral status instead of jamming.

The chance for it to jam from maintained status will be very low and will be based on the damage of the ammo type, and the weapon’s durability rating (these are already in the files).

I think all guns already have a fixed 1% chance of misfiring (it’s happened to me one while burst-firing an American-180), but modifying its chance to misfire/jam based on maintenance and its durability rating in the files would actually seem rather interesting.

Uhhhh no?

If I’m gonna smash a door or countertop, I’m going to use my boot, not my fist.

Seriously, have you ever heard of anyone punching a door in? No. Because that’s how you get broken hands.

Use your feet and it won’t hurt.

Uhhhh no?

If I’m gonna smash a door or countertop, I’m going to use my boot, not my fist.

Seriously, have you ever heard of anyone punching a door in? No. Because that’s how you get broken hands.

Use your feet and it won’t hurt.[/quote]

What about smashing a locker apart. How does someone do that without hurting themselves.

There should be a penalty to simply smashing something unarmed. Or why would you ever decide to use a weapon. Imagine a character with very high strength, smashing a locker in one turn. That means he must’ve kicked pretty damn hard.

I’ll agree it should be kicking. But there should be a penalty, some damage even if little → possibly to your boots.

[K]ick the door key anyone?

Time. Make the penalty be time.

Perhaps smashing without weapons could take three or four times as long as with a weapon.

Also, chances of damaging your weapon should take into account the weapon and the thing you’re attempting to smash. Broom handle against a steel cabinet? Yeah that’s likely going to break. Woodcutting axe against a wooden door? It really shouldn’t even take a scratch.

It already takes this into account. The weight of the furniture object and the material, bashing damage, volume, and weight of the bashing object. Plus your skills.
Unfortunately furniture has no material flag, just what it deconstructs into. We could check the material of the first item it can deconstruct into and take this into account, though.

The axe has insane weight, very high bash, and is made of iron. So yeah it won’t take a scratch.

Uh, this came up last month and the general idea was “not really”.

If anyone that wants durability wants to test it, you can grab an already built version here: https://github.com/freezerbunny/Freezerbunny-Modified-DDA

So is this going to be merged to the master or it is just a mod?

I’m not freezerbunny but from what I understood, it most likely will be merged into mainline at some point in the future. The real question here is how to make a interesting and balanced gameplay mechanic out of this without adding much tedium.

To be honest, I’m not really sure how it could be anything but tedious, but if there’s enough demand for it I suppose some people might. I’d prefer having it as an option in the upcoming mod manager, though.

I think this is what your code boils down to, but just trying to be clear:

Weapons (meaning arbitrary items) taking damage from bashing terrain/furniture is pretty reasonable, though there should be some (lots, really) items intended for it that have no or practically no chance of taking damage, either via innate toughness or a “goodforbashing” flag, e.g. crowbars, sledgehammers, some axes.

Similarly having “improvised” weapons take damage and break from hitting monsters with them is totally reasonable. Most weapons intended for use in melee should have practically no chance of breaking when used for attacking. This might either be derived from the items stats, or from an attack type flag. So anything with “CHOP”, “STAB”, “SPEAR”, or “SLICE” would be treated as intended for melee, and we can add flags for bashing-type weapons. Some items NOT intended for use as melee weapons would still be immune to damage due to their properties, e.g. crowbars

I’m not a fan of having the player take damage from bashing things when unarmed, I’d much rather just say that they generally limit their bashes such that they don’t take damage. Keep in mind unarmed smashing can also take the form of prying, jumping on things, or picking them up and bashing them on the floor, so you can do more damage than you’d think just based on punching or kicking things. An alternate idea is to have a confirmation for bashing really hard targets, “Really bash that wall, you might hurt your hand?”.

GlyphGryph had some interesting thoughts on this topic here (in Part 3).

I’ve weighed on what my desired system is for the items themselves in the link above, but I would like to talk a bit about what I want to see on the “player damage” front too.

I agree that it’s best to avoid damaging the player, and instead make it so various factors like strength and “worn” equipment on the hands and feet simply allow unarmed smashing damage to be increased. If things are given a hardness variable, it would mean you’d need SOMETHING to break down that bench, and whether you are wearing a pair of heavy boots or wielding a sledgehammer, you need to be able to do enough to overcome it’s durability.

I also think the default smash command should go to whichever method the player has at hand that would deal the most damage - whether it be punching, kicking, or using the wielded weapon. A player wielding a napkin will still be able to kick something open instead of using their napkin to try and napkin-whip it open.

When we get dashing, jumping, and diving later on, players might be able to do THAT for increased damage with a chance of being hurt, but that’s a bit different than the very basic sort of bashing being considered here.

There is one exception - objects that are sharp or dangerous. Breaking a window, while naked, using nothing but your body? That should totally run a risk of the player being injured. But that’s really a separate consideration.

I’ll rethink all of this when I put in the necessary values we need (hardness, etc.) and rework the monsters.

This is what I came up before we had that chat.

I also think the default smash command should go to whichever method the player has at hand that would deal the most damage - whether it be punching, kicking, or using the wielded weapon. A player wielding a napkin will still be able to kick something open instead of using their napkin to try and napkin-whip it open.

Agreed, but there still should be a choice. It should be a warning: “Really use your %s?”. Here, the player is better off using a rock to smash things or a junk item, or they risk damaging their tool.
We’d probably make the sledgehammer the ideal smashing tool, I agree.

Basically we just need more flags on furniture and the like so we can actually factor this stuff in. Right now I just went with the already existing flags.
This’ll all be done when I have the time.