I’m not completely following what you are trying to do.
I think you’re trying to shortcut adding or subtracting (either a flat number of a percentage) from a variable without first passing the random result into a holding variable.
I think that under the hood, both *set and *rand do the same thing (i.e. assign a value to a variable), so you can’t mix them (e.g. *set Number_Variable (*rand Number_Variable 1 100) + 15) or something weird like that).
Also, because *rand takes specific arguments (namely the min and max), you can’t add additional logic into that.
If I have understood your intention correctly, my first question would be, why do you want to bypass the interim variable?
I was hoping there was a way to rand a percentage on something so that it doesn’t completely change it (ie- I don’t want *rand 1 3 which would change it far too much, I want to *rand either %+ 15 or %- 15 in the same line of code without getting too complicated.)
If i understood perfectly, the amount added or substracted would be the random percent of the target variable right?
But i have a question. The random number need to be between (-15 >= random number <= +15)
And if the random number is 1…2…3…+15 the code would add that amount in percent to the chosen variable and if it’s -1…-2…-3…-15 the code would substract that amount?
*rand food "-30" "30" is a valid expression. If you want to modify by random percentage:
*temp hp 200
*temp value 0
*temp dmg 0 -(hp *(15/100)) <<<The complicated "0 - (sum)" expression is to turn the term into a negation.
*temp heal hp *(20/100)
*rand value dmg heal
*set hp +value
${hp}
This should print any value between HP -15% of it ~ HP +20% of it.
Could you do a no-code example? I think we’re all struggling to understand what you want to achieve. Such as:
I want the ‘alertness’ stat to start at 50.
Then an event will occur and it will either increase or decrease the alertness stat by a random amount.
I want to randomly pick a percent between -15 and +15 to then apply to the alertness stat.
So, if it randomly rolls +10, it would then set alertness to (50 + 10%) = 55
Or, if it randomly rolls -10, it would then set alertness to (50 - 10%) = 45
If you don’t want to use fairmath (which will give you diminishing returns), this should give you what you need (you can add a cap to it to stop it going over 100, or below 0, or whatever limits you want). I’ve written into a repeatable process so you can watch it in action:
*create Loner 50
*create AttributeModifier 0
*create LastEffect ""
*label Choice
Do you want to go with them, or go on your own?
Your current Loner stat is ${Loner}.
Last choice we altered your loner stat by ${LastEffect}${AttributeModifier}%
*choice
#Go with them (decrease loner stat)
*rand AttributeModifier 1 15
*set Loner - round(((Loner / 100) * AttributeModifier))
*set LastEffect "-"
*goto Choice
#Go on my own (increase loner stat)
*rand AttributeModifier 1 15
*set Loner + round(((Loner / 100) * AttributeModifier))
*set LastEffect "+"
*goto Choice