CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
9.74k stars 4.05k forks source link

RFC: Changing the near term `a`pply knife to item calculation of total material components returned #7810

Closed jeremyosborne closed 9 years ago

jeremyosborne commented 9 years ago

I've started calling "cut item up with knife" item salvaging, and I'm cleaning up the code that goes along with it.

This goes along with issue #7508 and associated pull request #7805.

As this is a work in progress, I'd like some comments on the current logic that exists in the code for determining just how many items you get back and my suggestions for a next-step change. I'd also welcome any longer term changes, as I'd like to get salvaging to be a bit more law-of-thermodynamics friendly as well as in game immersion friendly.

I've regrouped the code in my branch. Here's the basic code for determining the total number of raw components that can be salvaged from an item cut with a knife:

// total number of raw components == total volume of item
count = cut->volume();
// No skill in tailoring, get a random number between 0 and count inclusive.
// Only 1 skill in tailoring, lose between 0 and 2 items if there are more than
// two items possible.
if (p->skillLevel("tailor") == 0) {
    count = rng(0, count);
} else if (p->skillLevel("tailor") == 1 && count >= 2) {
    count -= rng(0, 2);
}
// On a roll of 3d3, if I roll higher than my dex, lose an additional
// 1 to three parts.
if (dice(3, 3) > p->dex_cur) {
    count -= rng(1, 3);
}
// If there are more than 1 possible items remaining that could be salvaged,
// there is a chance of losing material components if the item itself is damaged.
// If the item being cut is not damaged, no additional losses will be incurred.
if (count > 0) {
    float component_success_chance = std::min(std::pow(0.8, cut->damage), 1.0);
    for(int i = count; i > 0; i--) {
        if(component_success_chance < rng_float(0,1)) {
            count--;
        }
    }
}

If I understand this right:

In the very near term I've already got the division of items up based on materials and am using a 70/30 split as Kevin suggested if and when an item is made up of more than 1 material (only 2 maximum items at the moment I'm told).

Changes that I propose in the very near term:

This isn't meant to nerf anything really, but it is designed to create a bit more scarcity.

KA101 commented 9 years ago

I'm not hugely concerned about lost material from cutting fabric items: there's no shortage of 'em in the game. 50/50 shot seems kinda high but wev.

I like the concept. Will take a look at the code in due course.

Zireael07 commented 9 years ago

I like the proposed changes.

kevingranade commented 9 years ago

I'm onboard with everything you suggested, really well thought out. Also consider making space for tool quality, though that probably makes more sense on the 'how long does it take' side of the equation. One volume = one 'scrap item' might be reasonable, or it might not, just sanity-check that that makes sense for all materials.

jeremyosborne commented 9 years ago

Thanks Kevin and Zireael07.

After playing the game last night, I'd like to make some tweaks to the formula:

KA101 commented 9 years ago

Potentially bad example: I reuse old socks as rags fairly often IRL, so IMO saying that I can't simply slit them open seems unrealistically "game-based". ("Sorry, KA101, but you have to lose material because you weren't content with it in its current configuration.")

So losing 20% merely for wanting to convert, maybe not. Agreed that tool quality should factor in.

jeremyosborne commented 9 years ago

@KA101 fair. You're right. I do the same thing too, have a closet full of them right now. Perhaps I sort of want some of them to just disappear ;)

I won't make that change.

kevingranade commented 9 years ago

Woo #7805!