I've already come across a thread where the solution was to simply use the damage formula to have the skill ignore the enemy's Defense stat if the hit goes critical, but I was wondering if there's a way to just change the default critical behavior and avoid cluttering every skill formula with this.
Making critical hits ignore defense
RPG Maker MV SupportYou can definitely modify the default critical behavior, but it would be a little tough to do so in a way that makes the engine just automatically ignore defense. The reason being that the engine doesn't automatically take defense into account in the first place--that's something that you determine yourself, inside the damage formula.
I think that the safest/neatest way to do this would be to make it so that, in the skill's note tag, you can write a second damage formula that will be used during criticals. I don't know if there are already any plugins that enable this or not, but it probably wouldn't be too hard to make one.
I think that the safest/neatest way to do this would be to make it so that, in the skill's note tag, you can write a second damage formula that will be used during criticals. I don't know if there are already any plugins that enable this or not, but it probably wouldn't be too hard to make one.
even the solution above is not "simple" as it would require a number of changes to the battleengine like telling it to use a notetag on critical.
Because by default, notetags do nothing.
there are ways to handle the OP's idea - several even. But they will all require some big changes to the engine and probably some custom plugins.
Because by default, notetags do nothing.
there are ways to handle the OP's idea - several even. But they will all require some big changes to the engine and probably some custom plugins.
usually critical means Damage x 2.
and in this case, Damage results from [damage formula], which sums up to basically [Atk - Def]
so, under normal circumstances, FIRST you do [Atk - Def], THEN, you check for critical (True/False, based on random chance), and THEN you double the result IF critical results to True.
if you have to go and "use the damage formula to...", you're doubling the work on something that shouldn't be done.
and in this case, Damage results from [damage formula], which sums up to basically [Atk - Def]
so, under normal circumstances, FIRST you do [Atk - Def], THEN, you check for critical (True/False, based on random chance), and THEN you double the result IF critical results to True.
if you have to go and "use the damage formula to...", you're doubling the work on something that shouldn't be done.
I certainly wasn't trying to imply that the OP could just type some stuff into the note tag and it would magically work. I did indicate that a plugin would be necessary.
I don't recall saying that it was "simple", but rather that it was the "safest/neatest" method that sprang to mind. It seemed (to me) like the OP was looking for a solution that both respected his/her damage formulas, yet automatically ignored defense when a critical happened. In order for that to happen, one would have to write code that parses the damage formulas and intelligently transforms them into a version where no defense reductions are happening on criticals.
While not impossible, it seems like that would be more hassle than it's worth, and could be a potential source of unforeseen errors. Plus, the engine forcefully changing my damage formulas wouldn't really be something that I personally consider to be desirable anyway. The whole point of damage formulas is to give you fine-tuned control over each individual skill, and you'd be giving up some of that control if you have the engine mess with your damage formulas. The solution that I proposed would allow the OP to keep full control over his/her damage formulas, yet still achieve the desired result.
And even though I didn't say my solution was "simple", it actually kinda is. It wouldn't really require "a number" of changes to the engine, but rather just changing one function (and also adding one more, if you wanna do things neatly).
@Sword_of_Dusk
If you're interested, here is a plugin that does what I described. Just copy and paste the code into a .js file and add it to your project through the plugin manager:
JavaScript:
Game_Action.prototype.makeDamageValue = function(target, critical) {
var item = this.item();
var baseValue = critical && item.meta.critFormula ? this.evalCriticalDamageFormula(target) : this.evalDamageFormula(target);
var value = baseValue * this.calcElementRate(target);
if (this.isPhysical()) {
value *= target.pdr;
}
if (this.isMagical()) {
value *= target.mdr;
}
if (baseValue < 0) {
value *= target.rec;
}
value = this.applyVariance(value, item.damage.variance);
value = this.applyGuard(value, target);
value = Math.round(value);
return value;
};
Game_Action.prototype.evalCriticalDamageFormula = 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.meta.critFormula), 0) * sign;
if (isNaN(value)) value = 0;
return value;
} catch (e) {
return 0;
}
};
In the skill's note box, just use this tag
<critFormula: your formula>. So for example, if you want the crit formula to be a.atk * 4, then this would go in your note box:
Code:
<critFormula: a.atk * 4>
I've completely removed the default crit behavior, so you *have* to use a crit formula if you want anything special to happen on a crit. If you don't put in a crit formula, it will just use the regular damage formula (without the default 3x crit multiplier).
You can also use multiple lines, and JavaScript in the crit formula. For example:
Code:
<critFormula:
if (b.isStateAffected(10)) {
a.atk * 8;
} else {
a.atk * 4;
}
>
@Arthran I really gotta remember that I'm the one who determines the damage formulas being used if I have another question like this. That's what happens when you try to quick post before the end of your lunch break, I suppose. Probably should've waited until I got off work.
Anyway, your little plugin will definitely help me keep the formula box to just the meat of each skill, but I also should probably consider that I might want to use the normal function in some way (even if such a reason doesn't stick out to me), so I'll think carefully before choosing which way to go. Thank you for your help though. Gonna get this topic closed, as this problem is sorted.
Anyway, your little plugin will definitely help me keep the formula box to just the meat of each skill, but I also should probably consider that I might want to use the normal function in some way (even if such a reason doesn't stick out to me), so I'll think carefully before choosing which way to go. Thank you for your help though. Gonna get this topic closed, as this problem is sorted.
No problem. And just FYI, if you'd like, I *can* make it so that in absence of a crit formula, it will fall back to the default behavior (which is to multiply the damage by 3). That way, you can define a crit formula if you want to do something special for the skill, or omit the note tag if you want the default behavior. I just wasn't sure what you'd prefer, so I removed the default functionality completely.
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
Original thread: https://forums.rpgmakerweb.com/threads/making-critical-hits-ignore-defense.149396/