Math.round and how to implement it in this case

 Hello fellow RM Mv users, I need your help once more.  🙂

So I'm trying to manipulate the code a bit in order to make more custom damage formulas, but when I try to change the damage output:

Game_Action.prototype.executeDamage = function(target, value) {                                   

    var result = target.result();       

    if (value === 0) {

        result.critical = false;

    }

    if (this.isHpEffect()) {

        this.executeHpDamage(target, value);

    }

    if (this.isMpEffect()) {

        this.executeMpDamage(target, value);

    }

};

 

to:

 

Game_Action.prototype.executeDamage = function(target, value) {

    var result = target.result();

    if (value === 0) {

        result.critical = false;

    }

    if (this.isHpEffect()) {

        this.executeHpDamage(target, value - (target.luk / 10));

    }

    if (this.isMpEffect()) {

        this.executeMpDamage(target, value);

    }

};

 

the game calculates the damage with decimals and then in battle goes insane. How do I round them up, so instead of 1.11 it shows 1, or instead of 1.8 it shows 2? Maybe using Math.round? The same happens when I alter the Hp drain formula.

 

I don't know how to do it as I'm not a scripter myself, maybe someone more skilled knows the answer. 

 

Also, if someone knows how to change the crit change so your agi modifys it I would be super thankful.

 

that's it, many thanks in advance and I hope to learn a bit more of JavaS from this!  🤘   🤘
Math.round(value - target.luk/10)But you could also insert your modification directly in your damage formulas ("-b.luk/10"), instead of scripting it. That's up to you, of course.

Also, if someone knows how to change the crit change so your agi modifys it I would be super thankful.
You could change here:

Game_Action.prototype.itemCri = function(target) {    return this.item().damage.critical ? this.subject().cri * (1 - target.cev) : 0;};Do note that the result of this formula (a.cri * (1-b.cev)) is a decimal value that goes from 0 to 1, so plan your modifications accordingly.

For example, if you want so that each 5 points of Agility gives 1% (relative, not absolute) extra critical chance:

Code:
return this.item().damage.critical ? (1+this.subject().agi/500) * this.subject().cri * (1 - target.cev) : 0;
O.O

Thank you SO much! And so fast! 

I will use this right now  BD

And you also got my other concern! You are such an amazing person  😎

This can be closed, as it is answered  🙂
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/math-round-and-how-to-implement-it-in-this-case.49176/