I'm working on a custom battle system, and I'm looking to make an attack that deals damage between some random numbers. I have the base attack value that I'd like to base these numbers on stored in variable 30. Currently, I'm trying to store this new random damage value into a new variable, using 4 different variables: the range, minimum damage, maximum damage, and final attack power.
Here's what I have so far (using the built-in Control Variables events):
I plan to eventually change that value of 100 to a different variable, but kept it at that for now, for testing purposes.
In this case, this attack should damage between 80 - 120, but right now it seems to be picking a random number between 80 to 160. I suspect it's that last line in my code that's doubling the max value somehow, but I'm still learning JavaScript, so I'm not entirely sure how this is happening.
I also tried to use the example for the Control Variables in the RMMV Script, but after a few tries, I wasn't able to get that working either.
I feel like I'm getting really close here, but does anyone have any ideas on how I can update my code to make this work?
Here's what I have so far (using the built-in Control Variables events):
JavaScript:
Control Variables : #0030 ATK Power = 100;
Control Variables : #0057 ATK Range = $gameVariables.value(30) / 5;
Control Variables : #0058 ATK Max = $gameVariables.value(30) + $gameVariables.value(57);
Control Variables : #0059 ATK Min = $gameVariables.value(30) - $gameVariables.value(57);
Control Variables : #0060 ATK Active = Math.floor(Math.random() * $gameVariables.value(58)) + $gameVariables.value(59);
I plan to eventually change that value of 100 to a different variable, but kept it at that for now, for testing purposes.
In this case, this attack should damage between 80 - 120, but right now it seems to be picking a random number between 80 to 160. I suspect it's that last line in my code that's doubling the max value somehow, but I'm still learning JavaScript, so I'm not entirely sure how this is happening.
I also tried to use the example for the Control Variables in the RMMV Script, but after a few tries, I wasn't able to get that working either.
I feel like I'm getting really close here, but does anyone have any ideas on how I can update my code to make this work?