RMMV Damage Formula - ideas and help

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,481
Reaction score
2,610
First Language
English
Primarily Uses
RMMZ
Hi everybody, I'm stumped with trying to find a formula I need for a skill. It's supposed to deal damage to an unpredictable number of enemies that can be not all of them, and the damage is split between the targets affected.
The problem is that I can't find anything to put in the damage formula that would return the number of units affected so I can make the division.

What are you using to determine the number of targets? I'm guessing the Target Control plugin?

Edit: Assuming you are, this will work.

Code:
<Custom Target Eval>
  targets = [];
  for (var i = 0; i < foes.aliveMembers().length; ++i) {
    var member = foes.aliveMembers()[i];
    if (Math.random() < 0.3 && targets.length < foes.aliveMembers().length) { targets.push(member); }
  }
  this._targetCount = targets.length;
</Custom Target Eval>
<Damage Formula>
value = (a.atk / 2 - b.def / 4);
value /= this._targetCount;
</Damage Formula>
 
Last edited:

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
216
Reaction score
124
First Language
French
Primarily Uses
RMMV
@Trihan I am, thanks for the code, it's almost working as intended with the exception that it seems to ignore my row targeting. Is it caused by the RNG part in the if statement?

EDIT: It works with this in the notes:
Code:
<Target: Front enemy row>
<Custom Target Eval>
  targets = [];
  for (var i = 0; i < foes.aliveMembers().length; ++i) {
    var member = foes.aliveMembers()[i];
    if (member.row()==1 && targets.length < foes.aliveMembers().length) {
      targets.push(member);
    }
  }
  this._targetCount = targets.length;
</Custom Target Eval>
and the damage formula simply in the formula space. Thank you!
 
Last edited:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,481
Reaction score
2,610
First Language
English
Primarily Uses
RMMZ
Yeah, it didn't take rows into account. :)
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
216
Reaction score
124
First Language
French
Primarily Uses
RMMV
Okay, new question: how do I set up a formula so that if at least one of the multiple targets has a certain state, a different formula is used for all enemies affected?

Full disclosure: I've got a skill that either applies a state to the target enemy, or consumes the state to deal damage to the target and any other enemy standing in the same row. Right now my formula has the right targeting method, but the formula checks if the other enemies in question have the state instead of just doing damage to them.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,481
Reaction score
2,610
First Language
English
Primarily Uses
RMMZ
What does your setup look like currently?
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
216
Reaction score
124
First Language
French
Primarily Uses
RMMV
The current formula as HP damage:
if(!b.isStateAffected(16)){if(Math.random()<=0.7){b.addState(16);}}else{b.removeState(16);100;};
(random number because the state has a 70% chance of being applied)

Current notetags:
Code:
<Custom Target Eval>
if (target.isStateAffected(16)) {
  for (var i = 0; i < foes.aliveMembers().length; ++i) {
    var member = foes.aliveMembers()[i];
    if (member.row() === target.row()) targets.push(member);
  }
} else {
  targets.push(target);
}
</Custom Target Eval>
That's how I get the skill to target one enemy if they don't have state 16, and an enemy's entire row if it has it.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,481
Reaction score
2,610
First Language
English
Primarily Uses
RMMZ
For the next bit, I would do a <damage formula> notetag that checks if any of the targets have state 16 and if so use the formula for the whole row, otherwise use the single-target one.
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
216
Reaction score
124
First Language
French
Primarily Uses
RMMV
I see, then I guess there's no way around the damage formula plugin this time. Thanks (for the 3rd time recently), and maybe I'll see you later if I can't figure out how to set it up.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,481
Reaction score
2,610
First Language
English
Primarily Uses
RMMZ
If you're not using Damage Core there is a way to do it in the default damage formula box.
 

Vergel_Nikolai

Veteran
Veteran
Joined
Mar 6, 2020
Messages
73
Reaction score
13
First Language
English
Primarily Uses
RMMV
Is this the right place to ask for how to make a damage formula that is directly proportional to the taret's missing HP/MP? If so, how can I make those? I was making a spell that deals bonus damage per missing HP and MP of the target.
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
567
Reaction score
244
First Language
English
Primarily Uses
RMMV
The target's missing HP is (b.mhp - b.hp) and their missing MP is (b.mmp - b.mp).
 

Vergel_Nikolai

Veteran
Veteran
Joined
Mar 6, 2020
Messages
73
Reaction score
13
First Language
English
Primarily Uses
RMMV
OK then! Thanks. I can now make an Execute skill and a Mind Blast spell with that.
 
Joined
Jun 16, 2015
Messages
3
Reaction score
0
First Language
English
Primarily Uses
Hello everyone! I am having trouble using percentages in my damage formula. All my actors have very low stats (5-20 for everyone at level 1) and I am wondering if it's possible to calculate a percentage of their attack and add it to the damage formula.

For instance: If Actor 1 uses a skill that does a flat 2 damage, how would I go about adding 120% of his attack stat to the skill's final calculation? (2 + 120% of attack stat)
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,481
Reaction score
2,610
First Language
English
Primarily Uses
RMMZ
Hello everyone! I am having trouble using percentages in my damage formula. All my actors have very low stats (5-20 for everyone at level 1) and I am wondering if it's possible to calculate a percentage of their attack and add it to the damage formula.

For instance: If Actor 1 uses a skill that does a flat 2 damage, how would I go about adding 120% of his attack stat to the skill's final calculation? (2 + 120% of attack stat)

2 + a.atk * 1.2
 

Jenova

Because you are...a puppet!
Veteran
Joined
Nov 29, 2017
Messages
447
Reaction score
292
First Language
English
Primarily Uses
RMMV
Is there a formula to check if the target is under bleed (state 43) and if so, set critical hits to 100%?

Would it be:

Code:
b.isStateAffected(43) ? a.cri(1.0)  : 1;

Thank you.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,481
Reaction score
2,610
First Language
English
Primarily Uses
RMMZ
Setting the critical hit value is a bit more complicated because by default it's governed almost entirely by traits. There are some plugins like Yanfly's Critical Control that allow for this kind of thing, though.
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
567
Reaction score
244
First Language
English
Primarily Uses
RMMV
Is there a formula to check if the target is under bleed (state 43) and if so, set critical hits to 100%?
The formula only determines the amount of damage dealt. I suppose the closest you could get is something like if(b.isStateAffected(43)) a.addState(100); damage formula here where 100 is the ID of a state that sets critical rate to 1. However, damage is calculated after determining whether it's a critical hit, so it would affect the actor's next attack rather than the current attack. To set the critical chance of the skill, you'll need a plugin.
 

Vergel_Nikolai

Veteran
Veteran
Joined
Mar 6, 2020
Messages
73
Reaction score
13
First Language
English
Primarily Uses
RMMV
Same question with the bleed question but slightly different: Is there a way to make a damage formula where you do more damage (not a critical, just additional damage) to an opponent with a certain effect active (let's say for example Poison) without the need of a plugin or is a plugin needed?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,481
Reaction score
2,610
First Language
English
Primarily Uses
RMMZ
If it's just additional damage based on a state you don't need a plugin for that. Let's say you wanted an enemy with poison to take double damage:

Code:
let value = a.atk * 4 - b.def * 2; b.isStateAffected(4) ? value * 2 : value
 

Latest Threads

Latest Posts

Latest Profile Posts

I just did some math and... apparently what seemed to be a little fun gimmick turned out to be an 80+ actors project :kaoswt2:
Yay! the original character contest 3 pack is here!
Both MV and MZ looks very good, congratulation for both RMW and Tkool participant!
I definitely can add these characters to use for my game project.

Steam link
The worst part of game development has to be marketing. Ugh...
May be starting a new job in a month or so. The thought is both exciting and terrifying.
Not like a rollercoaster though. Rollercoasters are just terrifying.
"Merchants don't sell you a product. They sell you something RIGHT NOW. That's all they're selling, the product of having what you want RIGHT NOW and not having to wait for it."

Forum statistics

Threads
112,476
Messages
1,068,546
Members
146,142
Latest member
maaya
Top