RMMV Damage Formula - ideas and help

BloodletterQ

Chaotic Neutral Assassin
Veteran
Joined
Aug 15, 2012
Messages
1,484
Reaction score
1,077
First Language
English
Primarily Uses
N/A
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.
 

okugi

Villager
Member
Joined
Oct 27, 2015
Messages
28
Reaction score
6
First Language
English
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?
 
Last edited by a moderator:

Nuhada

Villager
Member
Joined
Oct 26, 2015
Messages
27
Reaction score
14
First Language
French
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)
 

GutshotStr8

Veteran
Veteran
Joined
Feb 14, 2014
Messages
51
Reaction score
21
First Language
English
Primarily Uses
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.
 

VHStapes

Game Designer
Veteran
Joined
May 25, 2014
Messages
57
Reaction score
7
First Language
English
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!
 

YouKnowA

Villager
Member
Joined
Oct 27, 2015
Messages
10
Reaction score
6
First Language
English
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.
 

Nuhada

Villager
Member
Joined
Oct 26, 2015
Messages
27
Reaction score
14
First Language
French
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
 

VHStapes

Game Designer
Veteran
Joined
May 25, 2014
Messages
57
Reaction score
7
First Language
English
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?
 
Last edited by a moderator:

Noferatsi

Level 10
Veteran
Joined
Dec 15, 2013
Messages
59
Reaction score
11
First Language
English
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? 
 

VHStapes

Game Designer
Veteran
Joined
May 25, 2014
Messages
57
Reaction score
7
First Language
English
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.
 
Last edited by a moderator:

JumbocactuarX27

Veteran
Veteran
Joined
Jan 11, 2013
Messages
86
Reaction score
39
First Language
English
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]
 

Mirai Ko

Veteran
Veteran
Joined
Oct 16, 2012
Messages
45
Reaction score
10
First Language
English
    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.
 
Joined
Jul 13, 2013
Messages
15
Reaction score
0
Primarily Uses
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;
};
 
Last edited by a moderator:

Daemien

Veteran
Veteran
Joined
Nov 2, 2015
Messages
48
Reaction score
10
First Language
English
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
 

MikeMakes

Veteran
Veteran
Joined
Sep 30, 2015
Messages
164
Reaction score
41
First Language
English
Primarily Uses
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
 
Last edited by a moderator:

Nuhada

Villager
Member
Joined
Oct 26, 2015
Messages
27
Reaction score
14
First Language
French
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"
 

MikeMakes

Veteran
Veteran
Joined
Sep 30, 2015
Messages
164
Reaction score
41
First Language
English
Primarily Uses
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
 

JumbocactuarX27

Veteran
Veteran
Joined
Jan 11, 2013
Messages
86
Reaction score
39
First Language
English
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.
 

Cassta

Villager
Member
Joined
Nov 3, 2015
Messages
15
Reaction score
2
First Language
English
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
 

Hoppy

Veteran
Veteran
Joined
Oct 6, 2015
Messages
326
Reaction score
54
First Language
English
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 3)

Latest Threads

Latest Profile Posts

On the plus side, if all this rioting sparks another Covid outbreak... I will have a whole lot of time to work on my game. Not exactly how I wanted to get that time, but hey I'm a glass is half full... of RM kind of guy. :LZSwink:
A video once in a while won't hurt.
Have a craving for a Nesquik milkshake. No idea why. Haven't had one since I was a kid. lol. I remember them kinda tasting nice, but also leaving a lot of nasty powder at the bottom of the cup.
The more I think about it, the weirdest part of going to work post-virus will probably be getting used to seeing my coworkers' mouths again. :LZYshock:
I think one of my weirdest realizations is that my speed of game development would probably be about the same if I *didn't* work a full-time manual labor job.

Forum statistics

Threads
98,059
Messages
948,974
Members
129,340
Latest member
guangdi
Top