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

Indinera

Indie Dev
Veteran
Joined
Mar 13, 2012
Messages
2,057
Reaction score
855
First Language
French
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?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,699
Reaction score
2,800
First Language
English
Primarily Uses
RMMZ
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;
}
 

Indinera

Indie Dev
Veteran
Joined
Mar 13, 2012
Messages
2,057
Reaction score
855
First Language
French
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;
};
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,270
Reaction score
674
First Language
English
Primarily Uses
RMMV
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);
 

Indinera

Indie Dev
Veteran
Joined
Mar 13, 2012
Messages
2,057
Reaction score
855
First Language
French
How can I make a plugin that performs this then?

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

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,699
Reaction score
2,800
First Language
English
Primarily Uses
RMMZ
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.
 

Indinera

Indie Dev
Veteran
Joined
Mar 13, 2012
Messages
2,057
Reaction score
855
First Language
French
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.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,879
Reaction score
14,702
First Language
English
Primarily Uses
RMVXA
It might be the triple equal signs. When I was doing coding it was == for equals. Try that.
 

Indinera

Indie Dev
Veteran
Joined
Mar 13, 2012
Messages
2,057
Reaction score
855
First Language
French
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;
 

Traverse

Veteran
Veteran
Joined
Jul 3, 2014
Messages
193
Reaction score
125
First Language
English
Primarily Uses
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.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,699
Reaction score
2,800
First Language
English
Primarily Uses
RMMZ
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. :p
 

Indinera

Indie Dev
Veteran
Joined
Mar 13, 2012
Messages
2,057
Reaction score
855
First Language
French
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. :p

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?
 

estriole

Veteran
Veteran
Joined
Jun 27, 2012
Messages
1,502
Reaction score
728
First Language
indonesian
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...
 

Indinera

Indie Dev
Veteran
Joined
Mar 13, 2012
Messages
2,057
Reaction score
855
First Language
French
Bingo! This worked.
Thank you everyone who tried and helped in this thread, much appreciated.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,270
Reaction score
674
First Language
English
Primarily Uses
RMMV
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.
 

Latest Threads

Latest Posts

Latest Profile Posts

Thinking that if I get MZ, I'll work on a new Project. How about instead of just an RPG, I make it episodic, like an anime? You might even get fanservice. Oh, but I need the right costume for the character.
"but what even is an API??"
Poppet Quest stats so far.. 61 views, 20 downloads, 3 reviews, 1 comment, 4 followers gained.... Hmm...
From a content creation standpoint, games really have awful traction. At least the experiment is interesting, time to see what adding Twitter into the mix does. Maybe the supposed 1,290 followers I have on it will prove useful. Then I'll test out Insta. :barf:
I've been trying to work on more "complete" artworks and so far... I'm in so much pain Its really annoying how easy is to completely mess up the proportions and perspectives, but I guess I can only keep practicing
xW1ByDU.jpg

Forum statistics

Threads
113,602
Messages
1,076,135
Members
147,602
Latest member
CertainPerson
Top