# How to make the most of custom formulae. Part #1

##### Chemical Engineer, Game Developer, Using BlinkBoy'
@Kes uhm, I replied to this, in which he explicitly stated he wanted to know the MV version of the formula

i cant seem to find something like this in MV thread so im trying my luck here.. anyways will the formula work on MV or just ace alone? do you know what formula to be used in mv? i have a mech class type.. and i have like 2-3 mech characters..

Last edited by a moderator:

#### Kes

##### Chemical Engineer, Game Developer, Using BlinkBoy'
This is indeed quite the wrong place for it though

#### Kes

##### Veteran
I'm trying to write a formula which increases the damage done by 1% for every decrease of 1% in the user's HP. What I have so far is this:

a.atk *4 - b.def * 2 + ((a.atk*4 - b.def * 2) * (a.mhp - a.hp)/a.mhp)

However, this produces zero damage and I can't see what my mistake is.
Can anyone enlighten me?
Thanks.

#### Harosata

##### Dramatic Lightning's BFF
Hm, I do know that Ruby is a bit picky with spacing, so try and see if you should put some more spaces between your numbers and operators.

Anyway, this formula seems to be written correctly. The only way this formula should get a 0 is if you were trying to test this against an enemy with very high defense. For example, if a has 10 attack and b has 5 defense, that should be (40)-(10) which becomes a minimum of 30 damage, but b should need about 20 defense (40) to negate that attack.

Also, here's an alternate way to write your formula: (a.atk * 4 - b.def * 2) * (1 + (a.mhp - a.hp) / a.mhp)

Kes

#### Kes

##### Veteran
@Harosata Arrghhh! It was a spacing issue. I must have been really tired when I typed that. Thank you for suggesting that.

Just out of curiosity I tried your version and it returned no more damage when the actor had 1HP than when he had 200. Multiplying the (a.mhp - a.hp) / a.mhp) by 1 is bound to give less than multiplying it by a.atk * 4 - b.def * 2 isn't it?

#### Harosata

##### Dramatic Lightning's BFF
Hm, I'm pretty certain that your damage formula is (damage * 1) + (damage * 1 * percent), and if math/Excel serves correctly, I could rewrite that as damage * (1+ (1*percent)). Because if your HP is full, that should be damage + (damage * 1/1) or damage * 2.

Hm, I would say that the biggest problem with writing formulas is that some variables can convert the semi-answers to an integer instead of a float. Probably have to put a few .to_f in there so that results become more accurate.

#### gorggi70

##### Warper
Oh thank you great guide! Keep up the good work

#### Harosata

##### Dramatic Lightning's BFF
Hm, a thought just occurred to me. State Resist [state] is a feature you'd normally give to ensure that a state is not added to a battler, and state_resist?(state_id) is its method. Now, I'd imagine that if there is an enemy resistant poison but you use a bomb to give them an illness, the formula could be written as:

And yet consider this:

b.state_resist?(SMALL) ? 1000 : 10

This is a skilled called Stomp and it will deal a lot of damage if the target is small. That's right, we don't actually use a SMALL state but instead use it as a racial property by making the target Resist that state. This applies to both Actors and Enemies as well as anything linked to them, which would include Classes, Weapons, Armor and States. In other words, if we apply Shrink which has a State Resist[SMALL] in it, the affected target will return true for state_resist?(SMALL)

Now, here's another example, a purchased skill for everyone:
a.state_resist?(BEASTMAN) ? 100 : 75

Now, we can ideally give this to the Beastman member of our party for maximum damage. However, we can also transform into a "Beastman" or equip Beastman claws to also qualify for that higher damage.

And finally, something like Waltz, a dance between man and woman in the form of:

Which can become a bit ridiculous if you have your male dancer dress up as a female to charm the majority of male enemies or if you have to transform all those enemies into girls first.

...I will admit, you can use notetags instead, but I figure this is an interesting way if you are uncomfortable with notetags. Also, you can use this method on the map (Entering a girls-only slumber party with disguises or chopping wood with an appropriate ax without having to check each individual equipment) but this topic isn't for that.

---

Theoretically, that should also qualify for other Features, but since most rates are multiplicative, I do not think it is easy to use State Rate to measure how Evil you are.

#### BCj

##### Veteran
Is it possible to have a sort of voidform state?

E.g. you use voidform, you gain let's say, 100 mana points, you can spend those mana points on anything that's linked to the voidform skill category, but the 100 mana depletes per turn?

Or:
You pop voidform, can use unlimited skills in voidform skill category for 4 turns, then it drops off and you go back to normal mode?

#### TheoAllen

##### Self-proclaimed jack of all trades
I think the question deserve their own thread? not sure if custom formula alone could deal with it

#### Starke

##### Veteran
This has been INCREDIBLY helpful for me. Just saved me hours and hours of testing. Thank you so much xD

#### kaukusaki

##### Awesome Programmer Extraordinaire
Im trying to figure out how to make a mp draining heal hp. I'm probably over thinking it and after a week i can't get it working
Am i overlooking something?

#### TheoAllen

##### Self-proclaimed jack of all trades
Your question might be better if you create a new thread for more visibility than asking it here.

#### slickdeath97

##### Veteran
What would be the setup for an if statement for a skill that compares the users and targets attack/m.atk/hp and then do damage based on the outcome. For example I am trying to make a skill that is based on the users attack vs the targets attack. If the user has higher attack then the skill does double the damage, but it only does half if the targets attack is higher.

### Latest Profile Posts

Finally done with the school project, here's the raw video of it.
Can February March? No, but April May.
Alisa: Prophecy of the Falling Stars. Join Alisa, a quiet girl with a heart filled with love and hope, on her journey to prevent a calamity. My next RPG Maker music pack is my largest and most focused pack yet. It's a musical story that focuses on a young heroine named Alisa who has been assigned the ultimate task to prevent a calamity.