RMMV Damage Formula - ideas and help

I repro'd it. You're right, it does. My guess is that the enemy's def(s) nullify the attacking stats completely.

var x = 1; var arr = [1]; for (var i = 0, len = arr.length; i < len; i++) {x += a.hasWeapon($dataWeapons[arr]) ? a.mdf : 0}; 4 * (a.atk += x) - 2 * b.def;or

var x = 1; var arr = [1]; for (var i = 0, len = arr.length; i < len; i++) {x += a.hasWeapon($dataWeapons[arr]) ? a.mdf : 0}; x += 4 * a.atk; x - 2 * b.def;may produce something closer to the desired effect.

The first one adds the stat so it gets multiplied (making the attack w/ the favored weapon MUCH stronger). The second one uses a more tame method w/ the weaponed damage being 1 += a.mdf += (4 * a.atk), and then that total - the normal target defense. Let me know if that works for you. 

Thanks. Modified it for smaller numbers.
Is there an easy way to express 0.5 < a.atk/b.def < 2.5  or would i have to make nested if/else statements?
Is there an easy way to express 0.5 < a.atk/b.def < 2.5  or would i have to make nested if/else statements?
Math.min(Math.max((a.atk/b.def),0.5),2.5)
Neither "$gameVariables.setValue(14, ($gameVariables[14] + 1))" nor "gameVariables[14] += 1" increment the variable by 1 :-(
It's actually "$gameVariables.value(n)" (using parentheses rather than square brackets) to reference the value of a game variable, in case anyone else has been trying to figure this out.
I feel like I'm doing this right but I'm not getting the right results, so maybe you guy can help!

I'm trying to make a fairly simple skill that deals HP damage, then returns the damage dealt to the user's MP. The problem right now is that it is dealing 0 damage every time no matter the stats.

Here's my skill:

var x = (a.mat - b.mdf); a.gainMP(x); x

So what am I missing? Thanks in advance!
Thanks. Modified it for smaller numbers.
Sweet! Glad I could help.

I feel like I'm doing this right but I'm not getting the right results, so maybe you guy can help!

I'm trying to make a fairly simple skill that deals HP damage, then returns the damage dealt to the user's MP. The problem right now is that it is dealing 0 damage every time no matter the stats.

Here's my skill:

var x = (a.mat - b.mdf); a.gainMP(x); x

So what am I missing? Thanks in advance!
I'm gonna' guess the mdf is cancelling out the mat. But, someone more skilled than me might have a better explanation.

var x = (2 * a.mat) - b.mdf; a.gainMp(x); xTry this equation. In the dropdown below the damage formula, I had to turn the variance to 0% to make it behave a little more like how I would expect it to work.
I feel like I'm doing this right but I'm not getting the right results, so maybe you guy can help!

I'm trying to make a fairly simple skill that deals HP damage, then returns the damage dealt to the user's MP. The problem right now is that it is dealing 0 damage every time no matter the stats.

Here's my skill:

var x = (a.mat - b.mdf); a.gainMP(x); x

So what am I missing? Thanks in advance!
var x = (2 * a.mat) - b.mdf; a.gainMp(x); xTry this equation. In the dropdown below the damage formula, I had to turn the variance to 0% to make it behave a little more like how I would expect it to work.
I think you should just not use the "var" at the beginning, and also it's gainMp and not gainMP (note the upper case) so:

Code:
x=(a.mat-b.mdf); a.gainMp(x); x
Thanks for the replies.

It wasn't the stats, and it works with or without the var... it was actually the capitalization that was killing it. Oops!!! Such a newbie mistake! Haha. Anyway, it works perfectly now!

Thanks again!

EDIT: New question!

How can I target a different character in the party, besides a or b, without it being actor specific? Let's say I want a skill that deals damage and heals every party member except the caster for an amount equal to the damage dealt? So...

x = (a.tk - b.def); ALL_OTHER_PARTY_MEMBERS.gainHp(x); x

What should ALL_OTHER_PARTY_MEMBERS be replaced with?
Nuhada covered this a few pages back. You can do something like a.gainHp(-Math.floor((a.atk/10))); at the start of a damage equation if you want it to be based on the user's attack.

a.gainHp(-Math.floor((a.mhp/10))); is also pretty cool. It does damage based on the attacker's max HP.

a.gainHp(-Math.floor((a.mhp/10))); a.agi * 9 - b.def * 2worked for me. If you want to do damage to the attacker's HP similar to the defender's lost MP, you could use something like this:

a.gainHp(-(a.agi * 9 - b.def * 2)); a.agi * 9 - b.def * 2But, replace the equation a.agi * 9 - b.def * 2 w/ the one you want.
How would I make the user take more damage with the first formula? 
How would I make the user take more damage with the first formula? 
I believe you would change

a.gainHp(-Math.floor((a.mhp/10)))to

a.gainHp(-Math.floor((a.mhp/5)))Or something like that. Essentially, divide by less, and it'll deal more damage.
I still don't know how to refer to game variables. :/
I'm at work so I don't have RPGMMV in front of me to test this but I do have the engine's .js files on my phone. Looking at rpg_managers.js it looks like you should be able to just call $gameVariables[n] where n is the index of the variable you want.
I just got around to testing it out and you actually need to call this:

$gameVariables.value(n)not this:

Code:
$gameVariable[n]
    So far, it seems that in order to add to a variable in the damage formula you can use

x = v[n]; x += 10; v[n] = x;
 Which feels like a round about way of doing it, but I can't for the life of me understand

why v[n] += 10 won't work by itself, while v[n] = 10 does.
I'm trying to have a skill with a guaranteed critical. In VX ACE you could use: b.result.critical = true

This doesn't work in MV and I can't work out why.

Game_Action.prototype.apply = function(target) {
    var result = target.result();
    this.subject().clearResult();
    result.clear();
    result.used = this.testApply(target);
    result.missed = (result.used && Math.random() >= this.itemHit(target));
    result.evaded = (!result.missed && Math.random() < this.itemEva(target));
    result.physical = this.isPhysical();
    result.drain = this.isDrain();
    if (result.isHit()) {
        if (this.item().damage.type > 0) {
            result.critical = (Math.random() < this.itemCri(target));
            var value = this.makeDamageValue(target, result.critical);
            this.executeDamage(target, value);
        }
        this.item().effects.forEach(function(effect) {
            this.applyItemEffect(target, effect);
        }, this);
        this.applyItemUserEffect(target);
    }
};
Game_Action.prototype.makeDamageValue = function(target, critical) {
    var item = this.item();
    var baseValue = this.evalDamageFormula(target);
    var value = baseValue * this.calcElementRate(target);
    if (this.isPhysical()) {
        value *= target.pdr;
    }
    if (this.isMagical()) {
        value *= target.mdr;
    }
    if (baseValue < 0) {
        value *= target.rec;
    }
    if (critical) {
        value = this.applyCritical(value);
    }
    value = this.applyVariance(value, item.damage.variance);
    value = this.applyGuard(value, target);
    value = Math.round(value);
    return value;
};
I use a.atk * 2 - b.def

My actors start off at about 60 HP though and gain it at a rate of 10 and below/ per level
From what I had of: b.elementRate(<insert ID of fire element>)>=2?(b.addDebuff(2,1)):0;100+(a.mat*2)-(b.mdf*2)

Is there a syntax to put multiple conditions in a formula that goes like this:

if Element Rate of Fire = 100%, add debuff, then do damage

if Element Rate of Fire > 100%, add state, then do damage
From what I had of: b.elementRate(<insert ID of fire element>)>=2?(b.addDebuff(2,1)):0;100+(a.mat*2)-(b.mdf*2)

Is there a syntax to put multiple conditions in a formula that goes like this:

if Element Rate of Fire = 100%, add debuff, then do damage

if Element Rate of Fire > 100%, add state, then do damage
Just put things like if/elseif/else, wich is by syntax (condition)?(do)🙁elseif)?do:doelse; where the (condition) and the (elseif) are the conditions you want.

By following your exemple that makes:

r=<formula>;(b.elementRate(1)>1)?(b.addDebuff(x,x))🙁b.elementRate(1)==1)?(b.addState(x)):0;rNote: I'm not so sure about the "==1", never used it in a formula so it may be "=1" or even "===1"
Thank you again, Nuhada!

I confirmed that it is: "==1"

Also, there are some unneeded parentheses, so it's:

r=<formula>;b.elementRate(1)>1?(b.addDebuff(x,x)):b.elementRate(1)==1?(b.addState(x)):0;r
Note: I'm not so sure about the "==1", never used it in a formula so it may be "=1" or even "===1"

Just wanted to point out for learning's sake, the == and === are for testing equality (in the formula given, b.elementRate(1) is equal to 1).

It is not = because that'd be trying to assign the value on the right to the function output on the left and syntactically that doesn't make sense.

 == and === are pretty much identical for the purposes we're using them for here in the damage formula thread, but it's best to be consistent with your use of them.
I know I'm a little late to the party, but using the stock health values and whatnot, I use this formula for magic skills that are meant to do a little better than normal attacks. 

Code:
a.atk * b.def * 0.2
I need a formula that works with an agility focused character that does damage based off the actor's agility * atk, I tried one but it ended in misses.

Original thread: https://forums.rpgmakerweb.com/threads/rmmv-damage-formula-ideas-and-help.47099/