danreeves / dt-exchange

40 stars 17 forks source link

Curio Blessings not correctly replaced with in-game value #11

Closed Coconutcoo closed 1 year ago

Coconutcoo commented 1 year ago

I'm looking into the bug where modifiers are not being replaced with their in-game value for gadgets/curios. E.g. image

It looks like the problem stems from gadgets not having any description_values specified directly in the MasterList;

  "content/items/traits/gadget_inate_trait/trait_inate_gadget_health": {
    "description": "loc_inate_gadget_health_desc",
    "description_values": [],
    ...
  }

While at https://github.com/danreeves/dt-exchange/blob/main/src/components/Store.tsx#L250 we still look for these in the same way as they're provided by the rest of the API.

We are given a rarity and a rating, and I believe the answer lies in https://github.com/Cortex-Network/Darkmass-Data-Mining/blob/main/All%20.lua%20Scripts/scripts/settings/buff/gadget_buff_templates.lua and https://github.com/Cortex-Network/Darkmass-Data-Mining/blob/main/All%20.lua%20Scripts/scripts/utilities/items.lua#L691. From this, we know the 4 bits of logic the blessings use, and the calculations for the in-game values.

I'd suggest we add something like this, and then call the relevant functions per a lookup table of curio type.

function lerp(min, max, input) {
  return min * (1 - input) + max * input;
}

function steppedLerp(range, input) {
  let interp = lerp(1, range.length, input);
  return range[Math.round(interp) - 1];
}

console.log("Lerp " + lerp(0.05, 0.25, 0.74).toFixed(2));
// "Lerp 0.20"
console.log("Stepped Lerp " + steppedLerp([1,2,3], 0.74));
// "Stepped Lerp 2"

After rounding to 2dp, we get exactly what I've been observing in the shop today - rating of 71 gives +19%, rating of 74 gives +20% etc.

Overall, the logic appears to be; max_health_modifier - lerp between 0.05 and 0.25 extra_max_amount_of_wounds - 1 stamina_modifier - stepped lerp between 1 and 3. toughness_bonus - lerp between 0.05 and 0.2

Before I started on this fork, I just wanted to ask @danreeves whether they felt these values should be hardcoded, and if so, whether my calculations looked correct. My observations were about 8 curios over 4 hours, and I was using just one character to view the shop at level 30. The curios in my inventory also matched, but since I couldn't see the rarity the API provided for those, I'm not 100% on them. If you're happy to hardcode these, but aren't super confident on the functions yet (especially steppedLerp), perhaps we should look to the Discord users to gather more info again?

As a slight aside, any thoughts on re-organising the blessings to move them above the perks for curios, as they are in the in-game shop? Definitely caught me out once or twice.

danreeves commented 1 year ago

Wow, thanks for all the research. Looks like you've got it exactly right to me. I'm happy for these values to be hardcoded as long as we know where they come from in the source code 👍

Coconutcoo commented 1 year ago

Also not sure if this was what you meant by #5 - I assumed that was about adding more localisation, not this, apologies if this ends up being a dupe of that