How do I use a damage formula for damage on the overworld?

I want my character to take damage on the overworld based on a damage formula...it goes like this

damage: 2 - AGI +1

Basically there is a fixed damage that is decreased by the characters agility stat, but the minimum damage is 1...I got the agility as a variable if that helps, but I don't know how to deal damage based on the damage formula...the "decrease HP" only let's me deal damage based on a flat number or a variable...
You could put the equasion in a variable and the do "decrease HP" with that variable like so:
In a script call event:
$game_variables[ID] = 2 - $game_variables[AGI_variable_ID] + 1

And after that the "decrease HP" event with the first variable as the value.


Hope I helped 👍
You could put the equasion in a variable and the do "decrease HP" with that variable like so:
In a script call event:
$game_variables[ID] = 2 - $game_variables[AGI_variable_ID] + 1

And after that the "decrease HP" event with the first variable as the value.


Hope I helped 👍

I think there is a problem...I've tested it with 50 agility and it healed me lol...probably because the variable went to the negatives...I need it to deal 1 damage if the stats is greater than necessary...
I think there is a problem...I've tested it with 50 agility and it healed me lol...probably because the variable went to the negatives...I need it to deal 1 damage if the stats is greater than necessary...
Ok, then do it like this:
In the script call:
$game_variables[ID] = 2 - $game_variables[AGI_ID]

$game_variables[ID] = 1 if $game_variables[ID] < 1

And then the decrease HP event.


That should work perfectly even with 50 AGI
I suspect that what you originally wrote for your formula is not what you intended.

"2 - AGI + 1" would output 2 at AGI 1, 1 at AGI 2, 0 or negative if AGI is 3 or above.

Even if you correct it by imposing a minimum of 1, the output can only ever be 1 or 2.

Maybe write a short list in the form "at AGI __, I want the output (damage amount) to be __" and then it will be easier for us to tell you what the correct formula would be?
Making formula is not easy. But you are already have the basic formula, then is good for you.
but sometime calculated damage based AGI, STR, VIT etc is not simple as

Code:
DamageReceive = DamagePure + (something increase damage) - (something decrease damage)
* something increase/decrease like elemen stuff

Sometime we need to make process like this
Spoiler: to long..
rawCalculate = bla-bla (you can use above suggestion or yours)

//condition for agi to evade (%)
if( you can avoid) result =0;
//calculate str
if( result > 0) result = result - strDecreaseDamage;

if(result< 0) result = 0;

damage = rounded( damage );

since the problem is.. there is formula that's make heal instead damage.. then you need to add condition
Code:
if(damage <= 0) damage =0;
hope this help you..
I've done it....I just used the first formula and put it in a conditional branch that checked if the agility was high enough to make the damage zero, in that case you just take 0 damage =) thanks, it's working now

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-use-a-damage-formula-for-damage-on-the-overworld.154730/