MV Yanfly's Wit's End

I was looking a 'Tips & Tricks' video of Yanfly about a weapon from LoL called Wit's End, that adds Magic Damage to basic attacks and buffs user MD and debuffs the enemy's MD, he applied a similar effect in game and he even gave the code to use it, but looking at the code, where does it specify that is the Magic Defense that has to be buffed or debuffed?

<Custom Confirm Effect>
// Check if the action is a basic attack.
if (this.isAttack()) {
// Calculate the number of turns the user has for MDF buff.
var turns = user.buffTurns(5);
// Make the minimum number of turns for MDF buff to 3.
turns = Math.max(3, turns);
// Increase the MDF rate for user.
user.addBuff(5, turns);
// Calculate the number of turns the target has for MDF buff.
var turns = target.buffTurns(5);
// Make the minimum number of turns for MDF debuff to 3.
turns = Math.max(3, turns);
// Decrease the MDF rate for target.
target.addDebuff(5, turns);
// Calculate the damage dealt.
var damage = (user.mat - target.mdf) * 0.40;
// Round the damage dealt upward.
damage = Math.ceil(damage);
// Ensure that the bonus damage has a minimum of 0 damage.
value += Math.max(0, damage);
// Set the color used for a screen flash.
var color = [0, 255, 255, 64];
// Set the duration of the screen flash.
var duration = 8;
// Cause the screen to flash when a basic attack connects.
$gameScreen.startFlash(color, duration);
}
</Custom Confirm Effect>
Is it strange that I imagined the title leading to a parody game featuring that Devoloper in a disgruntled state and taking it out on things? 😅

Anywho, I think the lines in bold here are the one's you look for:

<Custom Confirm Effect>
// Check if the action is a basic attack.
if (this.isAttack()) {
// Calculate the number of turns the user has for MDF buff.
var turns = user.buffTurns(5);
// Make the minimum number of turns for MDF buff to 3.
turns = Math.max(3, turns);
// Increase the MDF rate for user.
user.addBuff(5, turns);
// Calculate the number of turns the target has for MDF buff.
var turns = target.buffTurns(5);
// Make the minimum number of turns for MDF debuff to 3.
turns = Math.max(3, turns);
// Decrease the MDF rate for target.
target.addDebuff(5, turns);

// Calculate the damage dealt.
var damage = (user.mat - target.mdf) * 0.40;
// Round the damage dealt upward.
damage = Math.ceil(damage);
// Ensure that the bonus damage has a minimum of 0 damage.
value += Math.max(0, damage);
// Set the color used for a screen flash.
var color = [0, 255, 255, 64];
// Set the duration of the screen flash.
var duration = 8;
// Cause the screen to flash when a basic attack connects.
$gameScreen.startFlash(color, duration);
}
</Custom Confirm Effect>
Correct me if im wrong but the '//' are just comments that explain how it works but are not actually run in the code and then we have:

• target/user.buffTurns - the turns of the buff
• math.max - get max number
• user/target.addBuff/deBuff - buff or debuff a specified rate of the STAT of the user or target.

None of them show where the Magic Defense is specified to be buffed, thats its my concern, there is not an 'user.mat' like in the line where its already calculating damage.
That's right, those "//" lines are not part of the script, they are usually placed there as developer notes.

My scripting knowledge is very limited, but I suggest seeking out the maker of the script for clarification.
I was looking a 'Tips & Tricks' video of Yanfly about a weapon from LoL called Wit's End, that adds Magic Damage to basic attacks and buffs user MD and debuffs the enemy's MD, he applied a similar effect in game and he even gave the code to use it, but looking at the code, where does it specify that is the Magic Defense that has to be buffed or debuffed?

<Custom Confirm Effect>
// Check if the action is a basic attack.
if (this.isAttack()) {
// Calculate the number of turns the user has for MDF buff.
var turns = user.buffTurns(5);

Number 5 here refers to MDF buff (buff numbers are: 0 for Max HP, 1 for Max MP, 2 for P. Atk, 3 for P. Def, 4 for M. Atk, 5 for M. Def, 6 for Agility and 7 for Luck.

// Make the minimum number of turns for MDF buff to 3.
turns = Math.max(3, turns);
// Increase the MDF rate for user.
user.addBuff(5, turns);
So basically we could also simplify this by setting a 'var buff = 5;' and use user.addBuff(buff, turns) for the same effect but in this case it's just simplified a bit.

// Calculate the number of turns the target has for MDF buff.
var turns = target.buffTurns(5);
// Make the minimum number of turns for MDF debuff to 3.
turns = Math.max(3, turns);
// Decrease the MDF rate for target.
target.addDebuff(5, turns);
// Calculate the damage dealt.
var damage = (user.mat - target.mdf) * 0.40;
// Round the damage dealt upward.
damage = Math.ceil(damage);
// Ensure that the bonus damage has a minimum of 0 damage.
value += Math.max(0, damage);
// Set the color used for a screen flash.
var color = [0, 255, 255, 64];
// Set the duration of the screen flash.
var duration = 8;
// Cause the screen to flash when a basic attack connects.
$gameScreen.startFlash(color, duration);
}
</Custom Confirm Effect>
Thanks a lot, I was wrong about that, then how would you specify that the Magic Defense should be buffed by a flat 5 or 10% percent, in the traits section of the state? Since this works as a state.
I think the standard boost rates are hardcoded into the engine, but I might be wrong on that front.

But if you want to add a, say, +15% MDF boost, make a state with a trait with a Parameter M.Defense * 115% and use user.addState(ID); where ID stands for the state number that provides the boost. If you want do decrease MDF, use a rate of 85% for 15% loss. (although you might to use targer.addState(ID) instead if you're not deliberately trying to debuff the player).
And a flat one would be M.Defense-10 right? Thank you so much for making it clear about the stats numbers, I wasnt able to realize that.
Actually, I'm not sure if you can reduce parameters by a flat amount in states without a plugin as the parameters are calculated in percentages. There might be a plugin that allows you to use a note tag in states to accomplish this, but I cannot think of one right away.
Thanks anyway, you teached me a lot and I think I found some workarounds for that too.

Original thread: https://forums.rpgmakerweb.com/threads/yanflys-wits-end.133104/