Hey there, I was wondering if any one had some insight into an issue I'm having. I'm a total amateur trying to code this so I'll explain best that I can.
In combat for attack resolution I first have a hit roll:
This part works totally fine but is included because it's value I reference later.
If an attack hits then I have the damage roll. For a basic attack I want to roll damage between a minimum value and a maximum value. What I'd like is for the range of the damage roll to be dependent on how successful the attack roll was. The maximum value will always be the users attack stat, but I want the minimum possible value to be based off of the attack roll, so a very accurate character will be rolling maximum damage often.
So I'd use the following as a function from my own tiny plugin and put $dmgroll(a, b) in the damage formula box in the database:
But I have no idea how to roll between these two values, I could cap the minimum with a math method which is what I initially did but that just takes anything rolled under the min and sets it to the minimum rather than roll between the two defined values no? Maybe I'm totally overlooking something but any one have any ideas on how to do this?
Relevant plugins include:
Custom Hit Formula MZ by ATT_Turan
https://forums.rpgmakerweb.com/index.php?threads/custom-hit-formula-mz.156236/
VisuStella Battlecore
Thank you.
In combat for attack resolution I first have a hit roll:
Code:
<hitformula>
this._hr = Math.random() + (a.hit - b.eva);
this._hr > 0
</hitformula>
If an attack hits then I have the damage roll. For a basic attack I want to roll damage between a minimum value and a maximum value. What I'd like is for the range of the damage roll to be dependent on how successful the attack roll was. The maximum value will always be the users attack stat, but I want the minimum possible value to be based off of the attack roll, so a very accurate character will be rolling maximum damage often.
So I'd use the following as a function from my own tiny plugin and put $dmgroll(a, b) in the damage formula box in the database:
JavaScript:
/**
* Random Damage Roll
*/
function $dmgroll(a, b) {
// minimum and maximum values.
var min = Math.min(this._hr,1.0) * a.atk; //this._hr is the value taken from the to-hit roll, 0-100%
var max = a.atk;
if (b.result().critical) {
var damage = a.atk; // When Critical calculate damage as maximum
} else {
var damage = (int)(Math.random() * (max - min + 1) + min); //roll damage from hit roll success * maximum to maximum //This is the issue as I do not actually know how to code
}
return damage;
}
But I have no idea how to roll between these two values, I could cap the minimum with a math method which is what I initially did but that just takes anything rolled under the min and sets it to the minimum rather than roll between the two defined values no? Maybe I'm totally overlooking something but any one have any ideas on how to do this?
Relevant plugins include:
Custom Hit Formula MZ by ATT_Turan
https://forums.rpgmakerweb.com/index.php?threads/custom-hit-formula-mz.156236/
VisuStella Battlecore
Thank you.