How to make the element rates flat instead of percetile

Status
Not open for further replies.

gambitben

Veteran
Veteran
Joined
Jun 8, 2013
Messages
161
Reaction score
127
First Language
Spanish English
Primarily Uses
RMMV
Hello forum friends!

I've been trying to make so that having a 120 fire element rate is not a 20% damage reduction against fire, but instead a flat -20 fire damage.

Between lines 1670 and 1690 in the objects.js file I found this:

Game_Action.prototype.makeDamageValue = function(target, critical) {
var item = this.item();
var baseValue = 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;
}
if (critical) {
value = this.applyCritical(value);
}
value = this.applyVariance(value, item.damage.variance);
value = this.applyGuard(value, target);
value = Math.round(value);
return value;
};

and thought that if I changed var value = baseValue * this.calcElementRate(target); to var value = baseValue -this.calcElementRate(target); the game would treat that "percentage number" as flat, but I'm sure I must be confused and this is not the line where that is handled. Does anyone know how to do this?

Thank you in advance!
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Actually the problem is the math. An element Rate of 120% would mean the game is going to multiply 1.2 to the number, so if you just change it to - it will now subtract 1.2 from the damage. Try it as such:

var value = baseValue + (this.calcElementRate(target) * 100 - 100)

The * 100 will covert the decimal back to a percent, and the minus 100 will mean only the amount of increase is added on (and if it is negative, it will be the amount of decrease).
 

gambitben

Veteran
Veteran
Joined
Jun 8, 2013
Messages
161
Reaction score
127
First Language
Spanish English
Primarily Uses
RMMV
Actually the problem is the math. An element Rate of 120% would mean the game is going to multiply 1.2 to the number, so if you just change it to - it will now subtract 1.2 from the damage. Try it as such:

var value = baseValue + (this.calcElementRate(target) * 100 - 100)

The * 100 will covert the decimal back to a percent, and the minus 100 will mean only the amount of increase is added on (and if it is negative, it will be the amount of decrease).
I changed it and I don't spot any difference :asad: I'm using Yanfly's element core so I tried both with that on and of but nothing. Shouldn't the +`be a - so it gets decreased?
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Element Core also calculates the rates, so it is probably overwriting it. Best check there. And yes, if you want it decreased at 120% then change it to -.

Also for testing sake you should probably use a skill that does a flat damage and has no variance. So maybe set your skill that you will test this with to just do 100 damage, 0 variance. That will make it easier to see if it is working or not.
 

gambitben

Veteran
Veteran
Joined
Jun 8, 2013
Messages
161
Reaction score
127
First Language
Spanish English
Primarily Uses
RMMV
Element Core also calculates the rates, so it is probably overwriting it. Best check there. And yes, if you want it decreased at 120% then change it to -.

Also for testing sake you should probably use a skill that does a flat damage and has no variance. So maybe set your skill that you will test this with to just do 100 damage, 0 variance. That will make it easier to see if it is working or not.
I tried it now and it works! Thank you so much! The only problem I found is that when paired with Yanfly's damage core, a 100 power skill with 0% variance against 120 elemental rate deals 99 damage... I don't know why, I even changed this: baseDamage -= this.calcElementRate(target); to be minus. :aswt2:

BIG EDIT: Forget what I said, I just pasted what you told me there and now it works. I'm so dumb :kaoswt: Thank you so much bgillisp! You are a true hero :MV1:

Also I think this thread can be closed, as our amazing mod helped me with the issue :rhappy:.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Glad it worked. There is a chance odd things might happen with really high element rates, and keep in mind element rates can't go below 0% as well.

Also if you use any code to absorb elements, keep a close eye on those, as those might work oddly too. If that happens open a thread for that and someone can look at it.

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.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:
attack on titan final season is airing tomorrow, I'm excited and scared at the same time!

Forum statistics

Threads
105,883
Messages
1,017,232
Members
137,607
Latest member
Maddo
Top