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

Status
Not open for further replies.

#### Binder28

##### Veteran
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...

#### DawoleQ

##### Villager
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

#### Binder28

##### Veteran
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...

#### DawoleQ

##### Villager
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

#### Aoi Ninami

##### Veteran
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?

#### gundambison

##### Veteran
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
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;``

#### Binder28

##### Veteran
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

#### hiddenone

##### Lurker Extraordinaire

Status
Not open for further replies.

### Latest Profile Posts

Learn how to do custom face parts with my latest tutorial!
The Legion
Made a title screen, and by ''made'' I ofc mean I slapped a simple title on some cool art I bought xD This side project might be fun.

Trying for a Classical RPG with Pokemon Elements. Capture monsters like Zombies and Harpys and use them on your team.

Astarte in her usual demeanor: mocking people.
Mother...

129,872
Messages
1,205,837
Members
171,049
Latest member
Azkaelika