# RMMV Damage Formula - ideas and help

#### Johnny_Ray

##### Villager
umm guys i already got it working,should have posted the result i guess but though this is a help only thread,well whatever:
<Custom Apply Effect>

user._stateTurns[24] = 10;

</Custom Apply Effect>

<Custom Respond Effect>

var org = target.stateOrigin(24);

var min = Math.round(org.atk * 0.5);

var max = Math.round(org.atk);

var value = Math.floor(Math.random()*(max-min+1))+min;

user.gainHp(-value);

target._stateTurns[24] -= 1;

</Custom Respond Effect>

<Custom Turn End Effect>

user._stateTurns[24] += 1;

</Custom Turn End Effect>
YoraeRasante helped me with the user._stateTurns
The custom turn end effect is so that the turns don't go down unless the target affected by ice spikes takes dmg and it does now work as intended.
Thanks!

#### Marmoon

##### Warper
I'm trying to create a skill that does damage to either the targeted enemy or the person using the skill depending on who has the highest percentage of their health, could anybody here help me?

Last edited:

#### Johnny_Ray

##### Villager
I'm trying to create a skill that does damage to either the targeted enemy or the person using the skill depending on who has the highest percentage of their health, could anybody here help me?
<damage formula>

if (user.hp > target.hp) {

var dmg = user.atk * 2;

target.gainHp(-dmg);

} else if (user.hp < target.hp) {

var dmg = target.atk * 2;

user.gainHp(-dmg);

}

</damage formula>
I set the target to be 1 enemy,it will display that he took 0 dmg though i hope that's not a problem..
All you have to adjust is in var dmg , only adjust atk and it's value, maybe you want magic dmg mat, and want it to deal 4 times the dmg mat *4;
user is the one that uses the skill
target is the one you want to attack
you could even target all enemies,it's up to you

#### YoraeRasante

##### Veteran
you don't really need yanfly's damage core for this.
(a.hpRate() <= b.hpRate()) ? a.gainHp(-(damage formula here with inverted a and b)) : (damage formula here)

#### Aesica

##### undefined
you don't really need yanfly's damage core for this.
(a.hpRate() <= b.hpRate()) ? a.gainHp(-(damage formula here with inverted a and b)) : (damage formula here)
This will work well if you're okay with a zero popping up on the enemy if the skill damages you. If you have yanfly's action sequences, I'd suggest the following approach instead, because it looks the cleanest and will apply any resists/mitigations/etc regardless of whether it hits the enemy or the user.

Code:
``````<Target Action>
perform action
if (user.hpRate() >= target.hpRate())
action animation: target
else
action animation: user
end
wait for animation
if (user.hpRate() >= target.hpRate())
action effect: target
else
action effect: user
end
death break
perform finish
</Target Action>``````

#### YoraeRasante

##### Veteran
@Aesica true, mine would show a 0 as damage on the enemy. And maybe not show a popup on the user too. But so would Johnny_Ray's version.

While yours is definitely the better result, really advice Marmoon to go for it if they can use Action Sequences (I'm not sure they work for first person battles? Which is kinda what my project will use so..), I was kinda out of time for a more in-depth explanation and just wanted to explain you could do the same as JR's idea with just the basic damage formula.

#### Aesica

##### undefined
They *should* work for front view too, but certain effects (mostly those involving actor movement obviously) would probably just be disregarded by the engine because the actors are invisible.

#### Gooseb90

##### Veteran
I want to create a formula for a drain skill (for enemies), but I want the damage in percentage. But if I just write let's say : '10% ' in the formula it doesn't seem to drain 10% MP of a mage/cleric. Actually it doesn't do any damage and doesn't drain. How should I write it differently?

#### Attachments

• 132.1 KB Views: 8

#### Johnny_Ray

##### Villager
I want to create a formula for a drain skill (for enemies), but I want the damage in percentage. But if I just write let's say : '10% ' in the formula it doesn't seem to drain 10% MP of a mage/cleric. Actually it doesn't do any damage and doesn't drain. How should I write it differently?
Yanfly's Lifesteal plugin can give skills a percentage drain.

#### Aesica

##### undefined
I want to create a formula for a drain skill (for enemies), but I want the damage in percentage. But if I just write let's say : '10% ' in the formula it doesn't seem to drain 10% MP of a mage/cleric. Actually it doesn't do any damage and doesn't drain. How should I write it differently?
Code:
``b.mmp * 0.1``
That will drain 10% of the target's max mp. If you want it to be 10%of the target's current mp instead, change b.mmp to b.mp.

Yanfly's Lifesteal plugin can give skills a percentage drain.
I think they're asking about how to have it deal 10% of the target's mp, not 10% of the damage dealt as mp drained.

#### Gooseb90

##### Veteran
I'm not sure if it's the right place to ask. But what would be the best way to make the party player to have lower stats, because I have trouble to balance enemies in my game to the point, some enemies can be beaten fairly easily and enemies don't seem to be able to kill some party member because they have too much HP while other party members just die easily.

#### YoraeRasante

##### Veteran
@Gooseb90 this is definitely the wrong place. This is a balancing conversation, not anything involving damage formulas.

That said, no one can give you a definite balancing formula. Even the best ones need you to fiddle with the class and enemy numbers until you are satisfied.
Balancing is an issue even in big AAA games after all.

But, there are some good articles out there if you search that give some tips and suggestions.

#### oriongates

##### Veteran
Is there a way to use the damage formula to set a variable to an enemy's "slot" number?

There's v[n] = b.enemyId () but that gives the enemy's database number, not its place in the Troop.

Essentially, I'm trying to store it as a variable to then use in a common event. I've found a kludge where I can apply a state and then use that to "target" the common event, but I'm hoping for something a bit more elegant.

#### rainyday

##### Veteran
Is there a way to use the damage formula to set a variable to an enemy's "slot" number?

There's v[n] = b.enemyId () but that gives the enemy's database number, not its place in the Troop.

Essentially, I'm trying to store it as a variable to then use in a common event. I've found a kludge where I can apply a state and then use that to "target" the common event, but I'm hoping for something a bit more elegant.
v[n] = b.index() should do the trick. Remember it'll start at 0, so add 1 if you need a non-zero number for the first enemy in the troop.

#### oriongates

##### Veteran
Thanks! I'll try that out.

#### Deenos

##### Warper
is it possible to change target in damage formula? i know theres like index that can choose desired target/enemy but i would to choose all of them instead...

been checking this and got no answers

#### YoraeRasante

##### Veteran
if I remember right it is something like this._targets[0]
if this is the Game_Action.

#### TorabaSu

##### Villager
Hi, there's a formula I'm trying to work out. I dug around the site with google, but can't quite find the exact syntax:

I want the formula to have an If statement that has a higher multiplier when a specific weapon type is equipped ie, Thief Skills doing more damage if a dagger is equipped, monks with Fists, etc.

I combed the 101, and despite seemingly like it'd be there, the only formulae examples I could find were for if Equipment were sealed, or to remove equipment as an effect of the skill.

#### CHKNRAVE

##### Surprisingly not sponsored by Yanfly.
Finally, a formulae thread. I just need to know how to work with states, like adding or removing, since add_state(n) no longer works in MV.

Never mind, got it now.
For those having this issue, it's a.addState(X) with X being the ID of the state. Replace a. by b. if you want to give the state to the enemy.

<edit>
To remove a state, it's a.removeState(X).

This is very useful when you want to do something to the target while changing status effects on the user, like a forced crit on the next basic attack. You'd just write a.removeState(X); a.atk * 4 - b.def * 2 X being the forced crit state, in the basic attack's damage formula.
For addState, a use you can have is to make an attack that kills the enemy if their HP is below 25%. You'd then write if (b.hp<(b.mhp*25/100)) b.addState(1);
Note that this formula would just display a 0 if the enemy's HP is above that threshold.
</edit>

Anyone know how to generate random numbers in MV?
According to the Damage Formulas 101 I found in a different RPG Maker forum, the formula is Math.floor(Math.random()*X)+Y for a random number between Y and X+Y-1.

Math.floor(Math.random()*100)+1 returns a number between 1 and 100,
Math.floor(Math.random()*100) returns a number between 0 and 99,
Math.floor(Math.random()*201)+50 returns a number between 50 and 250.

<edit> Even better, there's Math.randomInt(X)+Y for short. </edit>

Last edited:

#### Frostorm

##### []D[][]V[][]D aka "Staf00"
Hi, there's a formula I'm trying to work out. I dug around the site with google, but can't quite find the exact syntax:

I want the formula to have an If statement that has a higher multiplier when a specific weapon type is equipped ie, Thief Skills doing more damage if a dagger is equipped, monks with Fists, etc.

I combed the 101, and despite seemingly like it'd be there, the only formulae examples I could find were for if Equipment were sealed, or to remove equipment as an effect of the skill.
This is what I use for my "normal attack" if u need an if conditional for weapon types...
Code:
``````<damage formula>
if (user.isWtypeEquipped(3)) {
value = (a.atk + a.atk + a.agi) / 2;
} else {
value = (a.atk + a.atk + a.agi) / 3;
}
</damage formula>``````
You're gonna need Yanfly's plugins btw.
But if you were referring to the critical strike multiplier, use this...
Code:
``````<Critical Multiplier Formula>

</Critical Multiplier Formula>``````

### Latest Profile Posts

I guess if you're just going solo dev, minimize features is better choice.
As close as possible, now I draw all of them with little by little needle sticking.
Welp, back to the drawing board...
--- Overused ---

Hero: (Drink 3 HP Bottle L)
F.Healer: Don't drink too much,or you got sick!
Hero: Nah,i'm okay. it's the way to repleni---
(Hero Collapse)
Hero: (Weak) Ugh...my head (Coughing Then Vomiting)
F.Healer: I told you to don't Drink 3 HP Bottle L or you're Sick. Let's go to Doctor.
Shaking off the dust. Clearing the cobwebs. Time to get back to gam-mak!

Threads
103,218
Messages
998,054
Members
134,692
Latest member
Matkacharts