RMMV Damage Formula - ideas and help

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,382
Reaction score
1,567
First Language
English
Primarily Uses
RMMV
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

I don't end projects, I start them.
Veteran
Joined
May 11, 2020
Messages
65
Reaction score
46
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
2,382
Reaction score
1,567
First Language
English
Primarily Uses
RMMV
Yeah, it didn't take rows into account. :)
 

CHKNRAVE

I don't end projects, I start them.
Veteran
Joined
May 11, 2020
Messages
65
Reaction score
46
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
2,382
Reaction score
1,567
First Language
English
Primarily Uses
RMMV
What does your setup look like currently?
 

CHKNRAVE

I don't end projects, I start them.
Veteran
Joined
May 11, 2020
Messages
65
Reaction score
46
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
2,382
Reaction score
1,567
First Language
English
Primarily Uses
RMMV
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

I don't end projects, I start them.
Veteran
Joined
May 11, 2020
Messages
65
Reaction score
46
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
2,382
Reaction score
1,567
First Language
English
Primarily Uses
RMMV
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
38
Reaction score
7
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
503
Reaction score
220
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
38
Reaction score
7
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
2,382
Reaction score
1,567
First Language
English
Primarily Uses
RMMV
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
338
Reaction score
183
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
2,382
Reaction score
1,567
First Language
English
Primarily Uses
RMMV
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
503
Reaction score
220
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
38
Reaction score
7
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
2,382
Reaction score
1,567
First Language
English
Primarily Uses
RMMV
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
 

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

Latest Threads

Latest Posts

Latest Profile Posts

How do you cure sleep problem? It has been 7 months and it's 3 AM now..
Darn you, Seals! Why do you gotta be so cute when on land?:kaoluv:
So dragonbones getting laggy xD
I even removed the fingers armatures.

Have to remake this guy after crashing ( corrupted file).
:rtear:

Although limited to only this shop for room decorations, I like this aspect for previewing items.

Forum statistics

Threads
100,837
Messages
980,129
Members
132,487
Latest member
AnthonyDewitt
Top