Trying to design Skills with variable hit rates

I'm using Yanfly's Skill Core to play with some of my skills and one of the things I want to do is get them to have different hit rates based on the value of a variable. I've been trying to do it like this, but it doesn't seem to be affecting the actual success rate. I have a feeling my script call is wrong... but I'm not real sure. Am I on the right track?


<Before Eval>


if (v[0001] <= 999) {


rate = ((v[0001] - 799) / 5 + 50) / 100;


}


if (v[0001] == 1000) {


rate = 1;


}


</Before Eval>


If it helps, I tested adding some messages inside the curly braces to make sure the conditional branches are working, and those are.
I'm using Yanfly's Skill Core to play with some of my skills and one of the things I want to do is get them to have different hit rates based on the value of a variable. I've been trying to do it like this, but it doesn't seem to be affecting the actual success rate. I have a feeling my script call is wrong... but I'm not real sure. Am I on the right track?


<Before Eval>


if (v[0001] <= 999) {


rate = ((v[0001] - 799) / 5 + 50) / 100;


}


if (v[0001] == 1000) {


rate = 1;


}


</Before Eval>


If it helps, I tested adding some messages inside the curly braces to make sure the conditional branches are working, and those are.



To get the value of a Variable in JavaScript, do:


$gameVariables.value(x)


and replace 'x' with the Variable ID.


I would recommend doing:


<Before Eval>
var variable = $gameVariables.value(1);

if (variable <= 999) {
rate = ((variable - 799) / 5 + 50) / 100;
}

if (variable == 1000) {
rate = 1;
}
</Before Eval>


Just replace the '1' on the first line if you ever want to change the ID of the variable used.
Thanks, I made that mistake before, but unfortunately this time it didn't really solve my problem.


I'm trying to influence the move's hit % but the variable doesn't seem to have any effect on that. is "rate" correct? I saw that syntax on a VXAce question and am not sure if it applies to MV.

Original thread: https://forums.rpgmakerweb.com/threads/trying-to-design-skills-with-variable-hit-rates.67898/