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
MV How do I go about making skills that do more damage if an enemy is inflicted with a certain state
RPG Maker MV SupportYou 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/
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
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.
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.
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}
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 🙂
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 🙂
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. 🙂
Good point, I knew I'd forgotten something.
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.
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?
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.
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 😛 This helps.
Does anyone know how to do this in VX Ace?
That really shouldn't be an issue, when you click on States in your database and scroll down to your bleeding state that you're applying, the id is the number to the left of its name. There's no guesswork involved.
You're sure that state is getting applied to the target in the first place?
No. Code isn't like a mathematical equation or writing things out in English where you can just write whatever you want; if you don't use the correctly specific syntax, it doesn't work. If isStateAffected takes one argument, you can't just throw in extra numbers.
This is literally the exact same thing that examples have been given of in this thread (presuming the kinetic barrier is a state). The only difference is that in all the places above where people are multiplying the damage by 2, you'd just say it's 0. If you wanted to display the message like that, then you're getting into territory where you need to attach a common event to the skill.
Enemies don't have levels, unless you're using a plugin to give it to them. Everything that you've seen here with damage calculations will be equally effective (or ineffective) at all levels, it's entirely up to you when you're plugging in the stats for your game.
A skill only becomes unbalanced or ineffective if you choose to do it with your stats (if your damage is based off of Atk vs. Def and you have the player gain Atk more quickly then the enemies gain Def, then you'll be doing ever increasing percentages of the enemy's health with each attack...again presuming their health is increasing linearly).
That's the entire point of stats.
There are threads in the game design (and MV?) forums dedicated to discussing and sharing damage formulae, but your question really has nothing to do with the formula itself, but with how you decided to assign stats.
Original thread: https://forums.rpgmakerweb.com/threads/mv-how-do-i-go-about-making-skills-that-do-more-damage-if-an-enemy-is-inflicted-with-a-certain-state.78329/