# 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

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.

Status
Not open for further replies.

### Latest Profile Posts

i think this girl has to be my favorite though
Wouldn't you know it? Every woman that is interested in me on FB is a bot. Maybe I should respond with 000100100011. If u r willing to date women on FB something has definitely went wrong with your life.
Hello world !! I've created a logo design for my game, I'm calling it "Soup Quest" (It was honestly the best I could come up with <:]) !!
[IMG]https://media.discordapp.net/attachments/866542330286178344/1076307540528332830/Soup_Quest_Game_Logo.png?width=473&height=473[/IMG]
P.S. ty to the person who told me about the "purple text not mixing well with dark mode". I'll be careful on using colored text in the future !!
On your last stream you were talking about dev's who remake or remaster the same game rather than moving on. Does this happen a lot? Me and Tony were thinking of covering a game that did this. We're baffled by the idea and wanted to investigate the game.
...Damn it has been a hot minute since I was here. How y'all doing, how's life been?