I'm trying to make my Hit Chance mimic a simple d20 system whereby you roll a d20 and add a melee bonus and compare against the target defense. However, for some reason the final result always fails no matter what the roll is. I suspect it has something to do with storing the formula as a game variable and then comparing to the target's defense. Perhaps I'm confusing the game variable storage again. I've debugged the random d20 roll + melee bonus to see that the results in the test Calculate would indeed hit, but it always fails. Here is an image of my hit Chance Formula with the Store Formula Value selected.

https://imgur.com/a/3bmfmSs

And here is the Status Check portion:

https://imgur.com/a/iOYzkuc

Any ideas what could be wrong?
  • Just for sake of completeness, the Attacker's MeleeBonus is 5 and the target's DEF is 11. So, it only needs a d20 roll of 6 to succeed.
  • edited November 2019
    Is storing it as a variable necessary? I think you just 'compare other' the current roll value and target Def.

    Otherwise it looks like it should work just fine.
    Post edited by Wrofir on
    Miuratale : coming 2024
    Miuratale
  • Wrofir said: Is storing it as a variable necessary? I think you just 'compare other' the current roll value and target Def.
    I couldn't figure out any other way to do it. I'll see if your idea works.
  • Compare with other just compares to another status value. It doesn't allow for comparing to the formula's current value.
  • Your Store Formula Value node stores the value into a local variable, the Check Value node checks global variables (due to not having a variable origin setting). So storing the value into a global variable will fix this.

    A different setup would be using 2 formulas. First formula does the random roll and adds the status value, 2nd formula uses the 1st formula in a Check Formula Value node (setting the formula value to the status value to check for first).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • OK, thanks for the tips.
Sign In or Register to comment.