MZ Which js file and which bit of code to edit to change the minimum damage?

I know that this works:

Math.max(a.atk-b.def,Math.randomInt(3)+1)

But personally I think it eats a lot of space in a box that is already not very big to begin with.
I was wondering if it's not possible to edit directly the js files so that the minimum damage is, say, random 1-4 instead of 0. Any clues?
I would do this in Game_Action.prototype.makeDamageValue:

after the line value = this.applyGuard(value, target); add

JavaScript:
if (value === 0) {
    value = Math.randomInt(4) + 1;
}
Thanks for your reply.

For some strange reason, it doesn't seem to work.
I added this bit from rmmz_objects.js:

Code:
Game_Action.prototype.makeDamageValue = function(target, critical) {
    const item = this.item();
    const baseValue = this.evalDamageFormula(target);
    let value = baseValue * this.calcElementRate(target);
    if (this.isPhysical()) {
        value *= target.pdr;
    }
    if (this.isMagical()) {
        value *= target.mdr;
    }
    if (baseValue < 0) {
        value *= target.rec;
    }
    if (critical) {
        value = this.applyCritical(value);
    }
    value = this.applyVariance(value, item.damage.variance);
    value = this.applyGuard(value, target);


    if (value === 0) {
    value = Math.randomInt(4) + 1;
    }


    value = Math.round(value);
    return value;
};
I'm not sure why you care about the length of your damage formula...it's not limited to the amount you see in the text box, they can be quite long.

It is also not good coding habits to modify the source code directly. It is better practice to create a plugin. That's actually what I do for my standard damage formulas, I just made a function in JavaScript, saved it as a plugin, then my damage formulae just say TurDamage(a, b);
How can I make a plugin that performs this then?

if (value === 0) {
value = Math.randomInt(4) + 1;
}
Actually now that I think about it, put that after the call to Math.round because it may not be 0 after calling applyVariance. My bad!

Also Indinera if you look up my topic "The anatomy of a plugin" it tells you how to structure a plugin file that you can put that code into.
Actually now that I think about it, put that after the call to Math.round because it may not be 0 after calling applyVariance. My bad!

I had the same idea and tried it too, but unfortunately it didn't seem to change the damage to something else than 0.
It might be the triple equal signs. When I was doing coding it was == for equals. Try that.
It's not a problem with the formula. I tried this and it didn't show 600 as damage.

value = this.applyVariance(value, item.damage.variance);
value = this.applyGuard(value, target);
value = Math.round(value);
value = 600;
return value;
It's not a problem with the formula. I tried this and it didn't show 600 as damage.
That modification definitely works the way it should in MV.

So unless MZ drastically changed something in the damage calculation process from MV, I would guess that you have a plugin somewhere that is either overwriting or bypassing the default logic for damage calculation.

In which case, that one would be the .js file you need to look at modifying.
Oh, yeah, I thought it would go without saying that my solution would only work if you weren't using any plugins that overwrite the makeDamageValue function. 😛
Oh, yeah, I thought it would go without saying that my solution would only work if you weren't using any plugins that overwrite the makeDamageValue function. 😛

I tried that too, checked if visustella core and battle core had smth similar but couldn't find it.
Does anything from tier 1 VS rewrites it?
I tried that too, checked if visustella core and battle core had smth similar but couldn't find it.
Does anything from tier 1 VS rewrites it?
We won't be able to know... since VisuStella code is obfuscated so human cannot read that easily...
but seeing what you edit did not affect anything... i suspect VisuStella modify that method thus making your changes obselete...

you could try aliasing though...
maybe something like this?
Code:
var vsAliasGameActionMakeDamageValue = Game_Action.prototype.makeDamageValue;
Game_Action.prototype.makeDamageValue = function(target, critical) {
  value = vsAliasGameActionMakeDamageValue.call(this, target, critical);
   if (value == 0) value = Math.randomInt(4) + 1;
   return value;
};
make sure to put that as a plugin below the visuStella plugin...
basically it will call visuStella(or any other plugin) method first and get the value... then check if value == 0 then change it to random int 4 + 1... then return the value

hope this help...
Bingo! This worked.
Thank you everyone who tried and helped in this thread, much appreciated.
It might be the triple equal signs. When I was doing coding it was == for equals. Try that.
Both work...by default, only two equal signs in JS will attempt to convert variable types to see if they're supposed to be the same thing. So things like if (1 == '1') will return true. Three equal signs returns true only if the two things are exactly the same value and type of variable.

Original thread: https://forums.rpgmakerweb.com/threads/which-js-file-and-which-bit-of-code-to-edit-to-change-the-minimum-damage.135296/