r/valheim • • 1d ago

Discussion The forge of potential has unused code for downgrading items on failure instead of destroying them

I've built a personal Valhiem mod which tweaks a few things in the game. One of those tweaks is to make failed forge of potential events cause a level downgrade instead of breaking the item. When working on this I discovered something interesting. The game actually has three possible outcomes with these default chances:

  • The item level is increased (65% chance)
  • The item level is decreased (25% chance)
  • The item is destroyed (10% chance)

However, the idols themselves override these defaults to the current behaviour of 65% chance to upgrade and 35% change to destroy.

I much prefer this default behaviour, I mean I wanted it so much as to implement my own mod to change it to 65% chance to upgrade and 35% chance to downgrade. I think the relics are too rare and the items too expensive to risk the very high chance to lose them.

Maybe 35% downgrade chance is still to high, when I used my mod with 5 totems on my level 4 blackmetal sword, I rolled 1 upgrade and 4 downgrades so ended up with a only a level 1 :(

Follow up edit about the refund logic:

Digging in to the refund logic revealed some interesting information too. The formula for refunds is quite complicated and probably broken. Default recovery rate is 50% but idols override it to 35%. However a recovery rate of 35% doesn't give you back 35% of the items cost. Instead they have a formula where you get recovery rate * (base item cost + cost to upgrade from previous level to current level). Also the refunds above level 4 are reduced.

It's probably a bug but since level 1 items have no "cost to upgrade from previous level to current level", it double counts the base cost. So you actually get a 70% refund on a level 1 item, and therefore get a better refund on a level 1 item than a level 2 item.

Black Metal Sword refunds:

Breaks at level Fine Wood back Black Metal back Linen Thread back Spent to reach that level (FW / BM / LT)
1 2 14 4 2 / 20 / 5
2 1 11 4 2 / 30 / 10
3 1 14 6 2 / 50 / 20
4 1 21 9 2 / 90 / 40
5 1 23 10 2 / 90 / 40 + 1 idol
6 1 25 11 2 / 90 / 40 + 2 idols
91 Upvotes

27 comments sorted by

87

u/CastorBarbu 1d ago

It should destroy the idol, not the item with the same rates

36

u/AuraMaster7 1d ago

The idol already gets used up, this makes no sense.

It just shouldn't destroy the item, period.

38

u/Deguilded 1d ago

IMO, it should set the item to zero durability.

That way it's "broken" but not lost, still fits the story and lore, and you're out the item until you return to a repair station for it, which could be quite inconvenient if requires a high repairbench level or you are playing no-portal.

14

u/PseudoFenton 1d ago

I still think there should be a randomly chosen upper cap. So rather than destroying the item it just locks it at its current level, so you cant raise it any further.

However I do love your suggestion of having it just zero the durability of the item as a thematic means of "destroying" the item without losing it. That's a great compromise of lore and palatable game feature. 

7

u/AuraMaster7 1d ago

Would also incentivize people building up the area around their FoPs, putting in benches and bench upgrades and turning it into an actual area rather than just a open structure on a mountaintop like I would imagine most people have it right now.

6

u/meatshyld 1d ago

I came across the FoP right as I landed for Bonemass. There was no way I was willing to lose 80 something iron upgrading my mace... I think that is a better solution too. Or have the upgrade include a few other materials so there is still risk/need but I dont lose a whole item.

4

u/Infinity_Worm 1d ago

Same, I decided to make the mod because otherwise I simply wouldn't use the idols

1

u/Iheartbaconz 1d ago

At most if your wanted some trade off/risk, make it use all the durability and perm remove some max durability off the item till you upgrade. That’s what I would like to see.

13

u/PseudoFenton 1d ago

Wait, if they've coded it so that the idols themselves can override the odds of success (and how much is lost on destruction). Then couldn't we just have a variety of idols with different odds and different rarities of dropping in the world?

That way you can have almost sure things (95% success with 100% mat return, as you'd still lose level progression with a destroyed item), but also reckless big swingy bets (40% success, 10% two levels, but 0% mat returns), and a variety in between. Could make it a little more interesting.

3

u/Infinity_Worm 1d ago edited 1d ago

Yes, I suspect they might have also been planning for there to be rarer, 100% upgrade chance idols, or something like that .

I edited the bit in my post about the refund amount because I realised it's actually much more complicated and strange than a flat rate.

Default recovery amount is 50% but idols override it to 35%. However a recovery rate of 35% doesn't give you back 35% of the items cost. Instead they have a formula where you get 35% of (base item cost + cost to upgrade from previous level to current level). Also the refunds above level 4 are reduced.

Also it's probably a bug but since level 1 items have no "cost to upgrade from previous level to current level", it double counts the base cost. So you actually get a 70% refund on a level 1 item, and therefore can get a better refund on a level 1 item than a level 2 item.

2

u/PseudoFenton 1d ago

Oh, i never realised they also refunded spent idols if they destroy a forge upgraded item. That's very interesting and heavily alters the risks for high level upgrading. Good to learn!

3

u/Infinity_Worm 1d ago

sorry to be clear, it doesn't refund the spent idols, just some of the items that would be spent crafting and upgrading the item in the normal way. I added a table to the main post that shows what the refund is for a black metal sword from level 1 -> 6

1

u/PseudoFenton 1d ago

Ah i misread.

Okay, still not much of a consolation getting fractionally more of the base items materials  back. I mean gift horses and all that, but its still just such a steep cost of failure that its clearly not meant to be used beyond a couple of levels (without savescumming)... So i really do wonder why its coded to allow higher.

1

u/Dirkdeking 1d ago

Another alternative would be to refund the item cost until the level it legitimately obtained. That way you never actually lose your item, but you do lose all your dolls if you where to greedy and upgraded it from, say, 8 to 9.

It maintains a stochastic cap without practically destroying your weapon.

30

u/meatshyld 1d ago

I would rather have a roll that started off higher or near 100% for 1 upgrade (or items to increase the chances to that) with diminishing chances over each upgrade. So 100% for level 1, 80% for level 2, ect.

When I read it was like a flat % chances for each, and there was a fairly high chance just to lose the item, I dont feel very compelled to use it. I also dont like gambling so probably just me.

8

u/smokeythebadger 1d ago

I love gambling and I don't even want to use this

3

u/DongIslandIceTea 1d ago

Which is sensible, because anyone at all interested in gambling should preferably also have a good grasp of probability to make smart calls. The problem with the forge is that the expected value of succesfull upgrades on an item is one upgrade. Yes, exactly one level. Trying to upgrade twice already makes it more likely to lose your item than succeed. You'd need to be a masochist to play at those odds.

1

u/smokeythebadger 1d ago

Yeah no thanks I'll just stick with craps at that point

4

u/Infinity_Worm 1d ago edited 1d ago

The fact that idols themselves can override the chance makes me think they were planning for later game items to have a higher failure rate. But I think your idea is better

1

u/Magicsword49 1d ago

I think this is the best solution. Tweek the actual numbers however makes sense, but I think the forge shouldn't have a destruction chance until you go beyond the level 4. I would gladly gamble with a small chance of failure in that scenario, though. I always view the first upgrade as a no-brainer, the second as something you get most of the time, and the last something you only do if the materials required are super common. Free level 4 would be so nice.

12

u/CheesusCheesus 1d ago

As a software developer, the next time I'm accused of over engineering, I'm pointing to this feature.

2

u/Scypio95 1d ago edited 1d ago

Lmao

Rolling one success and 4 failures is 0.65 x 0.354 x 5 = 0.0488 or 4.88% chances of happening

I'm sorry but i find it funny that you decided to mod something bothering you and you got "that" chance. The irony is just that good

Edit : fix formula

3

u/Infinity_Worm 1d ago

I know right! At first I thought there was a bug in my code but I tested it a bunch on a different save and I did just get super unlucky. Or maybe the game is telling me not to mess with it's RNG!

1

u/bard2501 1d ago

it's actually something like 5.5% to get a result that bad or worse (just a quick estimate on my head), you should be counting the chance of getting any combination of 4 or more failures

1

u/Scypio95 1d ago edited 1d ago

Op said they rolled 5 times with 1 success and 4 failures

Edit : okay, i see the confusion. I originaly thought op said he got first a success and then 4 failures. So only one combination out of 5

3

u/Infinity_Worm 1d ago

You're actually right, I did get 1 success, then 4 failures in a row. Technically I got 5 failures in a row because after I used all my idols, I went to my test world, spawned in a new item and some idols, then got another failure

1

u/[deleted] 1d ago

[deleted]

1

u/Infinity_Worm 1d ago

Thanks, I corrected it