MV How do I go about making skills that do more damage if an enemy is inflicted with a certain state

filmlosophers

Villager
Member
Joined
Jan 23, 2017
Messages
20
Reaction score
0
First Language
English
Primarily Uses
I can't figure this out. I'm making a hunter class that does a lot of damage if you use his skills in the correct order. I have a skill called puncture which cause bleed then the idea is to combo it with razor dance which is supposed to do 33% more damage to bleeding targets. I'm still fairly new to rpgm but I know what goes into making a good game so I need help with this. Thanks in advance
 

waynee95

Inactive
Veteran
Joined
Jul 2, 2016
Messages
682
Reaction score
598
First Language
German
Primarily Uses
RMMV
You can do that with damage formulas.

If the normal formula looks something like this:
a.atk * 2 - b.def

You can do:
if (b.isStateAffected(ID of the state here) { (a.atk * 2 - b.def) * 2 } else { a.atk * 2 - b.def }

This would use the damge formula (a.atk * 2 - b.def) * 2 when the target has state ID on it and the normal one otherwise.

More info on that:
http://www.rpgmakercentral.com/topic/36290-damage-formulas-101-mv-edition/
 

filmlosophers

Villager
Member
Joined
Jan 23, 2017
Messages
20
Reaction score
0
First Language
English
Primarily Uses
You can do that with damage formulas.

If the normal formula looks something like this:
a.atk * 2 - b.def

You can do:
if (b.isStateAffected(ID of the state here) { (a.atk * 2 - b.def) * 2 } else { a.atk * 2 - b.def }

This would use the damge formula (a.atk * 2 - b.def) * 2 when the target has state ID on it and the normal one otherwise.

More info on that:
http://www.rpgmakercentral.com/topic/36290-damage-formulas-101-mv-edition/
Thanks for the fast reply! Imma try it out now
 

Dope

Veteran
Veteran
Joined
May 29, 2017
Messages
132
Reaction score
16
First Language
English
Primarily Uses
RMMV
I have literally the same question also using MV.

The formula I'm attempting to use it: if (b.isStateAffected(11) { (200 + a.mat * 2 - b.mdf * 2) * 2 } else {200 + a.mat * 2 - b.mdf * 2})

The goal is to get the attack to do twice the damage if the target is affected by a state. I think the state ID is 11, assuming the ID is the number the state is listed as in the database. I'm not sure if the syntax is wrong or ID, I also use a few yanfly plugins if that matters.
 

LadyBaskerville

Hell-poodle
Veteran
Joined
Sep 12, 2016
Messages
645
Reaction score
524
First Language
German
Primarily Uses
RMMV
It's the syntax - it should be
if (b.isStateAffected(11)) { (200 + a.mat * 2 - b.mdf * 2) * 2 } else {200 + a.mat * 2 - b.mdf * 2}
 

Dope

Veteran
Veteran
Joined
May 29, 2017
Messages
132
Reaction score
16
First Language
English
Primarily Uses
RMMV
It's the syntax - it should be
if (b.isStateAffected(11)) { (200 + a.mat * 2 - b.mdf * 2) * 2 } else {200 + a.mat * 2 - b.mdf * 2}
Ah! That's like coding/math 101 right there. Thanks for the help, works like a charm now :)
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,959
First Language
English
Primarily Uses
RMMV
You can simplify this by assigning the base damage value to a variable first:

Code:
dmg = 200 + a.mat * 2 - b.mdf * 2; b.isStateAffected(11) ? dmg * 2 : dmg
 

Dope

Veteran
Veteran
Joined
May 29, 2017
Messages
132
Reaction score
16
First Language
English
Primarily Uses
RMMV
You can simplify this by assigning the base damage value to a variable first:

Code:
dmg = 200 + a.mat * 2 - b.mdf * 2; b.isStateAffected(11) ? dmg * 2 : dmg
Thanks! That works too. Might even work better because for some reason the other formula caused less damage to the target afflicted by the state.

Edit: Actually it doesn't seem to be accounting for the state at all. Took off the variable and crit and the spell does the same damage regardless of the state. I'm pretty sure that's because I'm putting the wrong ID in but at least I know the formulas work :)
 
Last edited:

Kyo Panda

Veteran
Veteran
Joined
May 16, 2017
Messages
34
Reaction score
24
First Language
Portuguese
Primarily Uses
RMMV
Code:
dmg = 200 + a.mat * 2 - b.mdf * 2; b.isStateAffected(11) ? dmg * 2 : dmg
The only problem I see with this approach is that it is actually creating a global scope variable called dmg, because of how the damage is evaluated in MV:

Code:
Game_Action.prototype.evalDamageFormula = function(target) {
    try {
        var item = this.item();
        var a = this.subject();
        var b = target;
        var v = $gameVariables._data;
        var sign = ([3, 4].contains(item.damage.type) ? -1 : 1);
        var value = Math.max(eval(item.damage.formula), 0) * sign; // <-- This
        if (isNaN(value)) value = 0;
        return value;
    } catch (e) {
        return 0;
    }
};
So if some weirdo furball scripter would do something like this to initialize a variable:

Code:
for (var i = 0; i < something.length; i++) {
    var dmg = dmg || 0;
    dmg += something.calcSomeDamuge();
}
dmg could have the evaluated value from the damage formula if the function isn't properly scoped.

---

To avoid this, we should declare it as a local variable:

Code:
var dmg = 200 + a.mat * 2 - b.mdf * 2; b.isStateAffected(11) ? dmg * 2 : dmg
Or avoid them at all:

Code:
(200 + a.mat * 2 - b.mdf * 2) * (b.isStateAffected(11) ? 2 : 1)
---

Just some random info. :rhappy:
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,959
First Language
English
Primarily Uses
RMMV
Good point, I knew I'd forgotten something.
 

Dope

Veteran
Veteran
Joined
May 29, 2017
Messages
132
Reaction score
16
First Language
English
Primarily Uses
RMMV
Wow. Thanks for all the help. All those formulas work, although I'm not too sure of the math/coding behind them. The spell still isn't working as intended but I think that has to do with me not identifying the state properly. I'll figure it out eventually.
 

MakerZeroOne

Chronic Case of Undeserved Misfortune
Veteran
Joined
Nov 3, 2017
Messages
75
Reaction score
102
First Language
American Eng.
Primarily Uses
RMMV
To expand upon this slightly, as i have no coding experience, and havent even tried to use algebra since... high school probably, can you enter multiple state ID separated by comma's?

if (b.isStateAffected(11, 12, 13)) { (200 + a.mat * 2 - b.mdf * 2) * 2 } else {200 + a.mat * 2 - b.mdf * 2}

or multiple lines?

if (b.isStateAffected(11)) { (200 + a.mat * 2 - b.mdf * 2) * 2 } else {200 + a.mat * 2 - b.mdf * 2}
if (b.isStateAffected(12)) { (200 + a.mat * 2 - b.mdf *1.5) * 2 } else {200 + a.mat * 2 - b.mdf * 2}

Also, what if i wanted to make a skill bounce off of an enemy; i.e. "Thrown grenade does no damage because the enemy has a kinetic barrier"
Or if you want to make a skill do damage in relation to the enemy level, so that the skill retains it's lethality later into the game, but is no OP in the beginning?

 

Blue Symphony

Wandering soul
Veteran
Joined
Jan 24, 2014
Messages
63
Reaction score
27
First Language
Spanish
Primarily Uses
RMMV
To expand upon this slightly, as i have no coding experience, and havent even tried to use algebra since... high school probably, can you enter multiple state ID separated by comma's?

if (b.isStateAffected(11, 12, 13)) { (200 + a.mat * 2 - b.mdf * 2) * 2 } else {200 + a.mat * 2 - b.mdf * 2}

or multiple lines?

if (b.isStateAffected(11)) { (200 + a.mat * 2 - b.mdf * 2) * 2 } else {200 + a.mat * 2 - b.mdf * 2}
if (b.isStateAffected(12)) { (200 + a.mat * 2 - b.mdf *1.5) * 2 } else {200 + a.mat * 2 - b.mdf * 2}

Also, what if i wanted to make a skill bounce off of an enemy; i.e. "Thrown grenade does no damage because the enemy has a kinetic barrier"
Or if you want to make a skill do damage in relation to the enemy level, so that the skill retains it's lethality later into the game, but is no OP in the beginning?
You can check for multiple conditions in one "if" statement using a logical operator. You write a simple "||"(that means "or") in between conditions to check for multiple states.

Example
This is what the damage formula would look like for your problem. Of course, I'm using Yanfly's DamageCore plugin here.
Code:
<Damage Formula>
value = (200 + a.mat * 2 - b.mdf * 2);
if (b.isStateAffected(11) || b.isStateAffected(12) || b.isStateAffected(13)) {
  value = Math.ceil(value * 2);
}
</Damage Formula>
Following this you can make any effect like the ones you mentioned. You'll only need a little creativity.
 
Last edited:

MakerZeroOne

Chronic Case of Undeserved Misfortune
Veteran
Joined
Nov 3, 2017
Messages
75
Reaction score
102
First Language
American Eng.
Primarily Uses
RMMV
Wow, thank you. I hadn't event looked at the scripts for the damage core plugin yet. there's a lot to learn. Trying to balance between skills, states, and items has had me stuck for a couple of days. At least on trying to discover what is possible within the confines of the engine, how i actually want the skills and states to affect each other, and my own intellectual ability to make it happen :p This helps.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,040
Members
137,569
Latest member
Shtelsky
Top