RMMV Damage Formula - ideas and help

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,602
Reaction score
1,933
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

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
90
Reaction score
60
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,602
Reaction score
1,933
First Language
English
Primarily Uses
RMMV
Yeah, it didn't take rows into account. :)
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
90
Reaction score
60
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,602
Reaction score
1,933
First Language
English
Primarily Uses
RMMV
What does your setup look like currently?
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
90
Reaction score
60
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,602
Reaction score
1,933
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

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
90
Reaction score
60
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,602
Reaction score
1,933
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
68
Reaction score
12
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
526
Reaction score
230
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
68
Reaction score
12
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,602
Reaction score
1,933
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
386
Reaction score
259
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,602
Reaction score
1,933
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
526
Reaction score
230
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
68
Reaction score
12
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,602
Reaction score
1,933
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: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Ami
--- Overused ---

Hero: (Drink 3 HP Bottle L)
F.Healer: Don't drink too much,or you got sick!
Hero: Nah,i'm okay. it's the way to repleni---
(Hero Collapse)
Hero: (Weak) Ugh...my head (Coughing Then Vomiting)
F.Healer: I told you to don't Drink 3 HP Bottle L or you're Sick. Let's go to Doctor.
Shaking off the dust. Clearing the cobwebs. Time to get back to gam-mak!
I should have looked for this earlier....

It makes MV only need OGG files, and it fixes the audio lag issue. :LZSexcite:
Battle of the original characters! my main character for my game vs. my friend's main character of his comic...
A video game has a brand attached to it.
No offence meant, but it is disadvantageous to use the default RM graphics due to the fact that they can correlate your game strongly to other RM games and whatever associations a user has with those unrelated games.

Forum statistics

Threads
103,212
Messages
998,029
Members
134,687
Latest member
pen
Top