# Adding a line in Yanfly Damage_Core formula

#### Nol

##### Veteran
I'm trying to add a check for three separate states (that cannot be used together) :

Power tactics : Reduces the hit and adds damage

Precision tactics : Increases hit and reduces damage

Speed tactics : Reduces Eva but increase every skill's SPD

Modifying Hit is easy (traits), but damage, on a global scale.... well i could add a conditionnal check on EVERY skill, but that would be clunky

Alternative would be using YF's damage core, it offers a hand in the game's "phases" of damage calculation, in which one could "easily" add a check.

After the line on physical damage calculation for exemple :

baseDamage = this.modifyBaseDamage(value, baseDamage, target);

INSERT LINE HERE (because the - or + damage would be affected by potential element resistances)

baseDamage *= this.calcElementRate(target);

Question  :

Any way to add 2 conditional checks for : If a state from 99 to 103 (Precise tactics) is present on initiator, add - Math.ceil (a.level * 0.5)

And  : If a state from 93 to 97 (Power tactics) is present on initiator, add + Math.ceil (a.level * 0.5)

Bonus question :

Any way to modify SPD without changing parameters ? (My Agi doesnt just add speed, but also Hit, Eva and more, so i can't modify it freely)

Thanks for reading

Last edited by a moderator:

#### Nol

##### Veteran
Sooooo

I added on line 53 (under physical damage)

if (baseDamage > 0 && user.isStateAffected(93,94,95,96,97)) {value = baseDamage + Math.ceil(user.level * 0.5);}

Is that good ? is this how you handle multiple states ?

Edit : I'm at :

if (this.isPhysical()) {

if (baseDamage > 0 && user.isStateAffected(93)|| user.isStateAffected(94) || user.isStateAffected(95) || user.isStateAffected(96) || user.isStateAffected(97)) {

(baseDamage = baseDamage + Math.ceil(user.level * 0.5));}

value = this.applyPhysicalRate(value, baseDamage, target);

}

In Bold, what i added

Still doesn't work

Last edited by a moderator:

#### Nol

##### Veteran
Bump, I tried base damage += baseDamage + Math.ceil(user.level * 0.5)

Doesnt work, probably because i'm using baseDamage again ?

Anyway, still interested in a tip : )

#### Nol

##### Veteran
Still looking

The syntax isnt wrong, so it has to be sequence, or logic i'm missing out on

#### Engr. Adiktuzmiko

##### Chemical Engineer, Game Developer, Using BlinkBoy'
Try this condition instead

baseDamage > 0 && (user.isStateAffected(93)|| user.isStateAffected(94) || user.isStateAffected(95) || user.isStateAffected(96) || user.isStateAffected(97) )

Also, where are you modifying that? The only places I found this.isPhysical on Damage Core was on the params... Or are you modifying the base script and not Damage Core?

Last edited by a moderator:

#### Nol

##### Veteran
Are you telling me to remove the if ?

I kinda need the conditional check though no ? Yanfly used one for his initial runic blade tips

(He used : if (baseDamage > 0 && target.isStateAffected(13)) { value = 0; target.gainMp(item.mpCost) } )

I'm editing the Damage Core plugin of Yanfly, the steps of damage calculation, around lign 50 in his plugin (when right clicking on the plugin)

Sorry for the delay in answering

Last edited by a moderator:

#### Engr. Adiktuzmiko

##### Chemical Engineer, Game Developer, Using BlinkBoy'
No, not remove the if but rather change the condition that you used to the one I posted. I'm not sure if it will work with that but at least, the groupings would be correct.

I'm editing the Damage Core plugin of Yanfly, the steps of damage calculation, around lign 50 in his plugin (when right clicking on the plugin)

That means you're editing the plugin parameters

Last edited by a moderator:

#### Nol

##### Veteran
Interestingly enough, something CHANGED !

I got a proper adult-like error this time, instead of nothing

Damage overflow :

baseDamage = this.modifyBaseDamage(value, baseDamage, target);

baseDamage *= this.calcElementRate(target);

critical = this.modifyCritical(critical, baseDamage, target);
target.result().critical = critical;
value = baseDamage;

if (baseDamage > 0) {
value = this.applyDamageRate(value, baseDamage, target);

}

if (baseDamage < 0) {
value = this.applyHealRate(value, baseDamage, target);

}

if (critical) {
value = this.applyCriticalRate(value, baseDamage, target);

}

if (this.isPhysical()) {
if baseDamage > 0 && (user.isStateAffected(93)|| user.isStateAffected(94) || user.isStateAffected(95) || user.isStateAffected(96) || user.isStateAffected(97)) {
(baseDamage += Math.ceil(user.level * 0.5));}
value = this.applyPhysicalRate(value, baseDamage, target);

value = this.applyFlatPhysical(value, baseDamage, target);
}

if (this.isMagical()) {
value = this.applyMagicalRate(value, baseDamage, target);

value = this.applyFlatMagical(value, baseDamage, target);
}

if (baseDamage > 0) {
value = this.applyFlatDamage(value, baseDamage, target);

}

if (baseDamage < 0) {
value = this.applyFlatHeal(value, baseDamage, target);

}

if (critical) {
value = this.applyFlatCritical(value, baseDamage, target);

}

value = this.applyVariance(value, item.damage.variance);

value = this.applyGuard(value, target);

value = this.applyFlatGlobal(value, baseDamage, target);
value = this.applyMinimumDamage(value, baseDamage, target);

EDIT :

Using base damage += baseDamage + Math.ceil(user.level * 0.5)

Got me a SyntaxError: Unexpected identifier

Last edited by a moderator:

#### Engr. Adiktuzmiko

##### Chemical Engineer, Game Developer, Using BlinkBoy'
I'm pretty sure this

if baseDamage > 0 && (user.isStateAffected(93)|| user.isStateAffected(94) || user.isStateAffected(95) || user.isStateAffected(96) || user.isStateAffected(97))

should be

if (baseDamage > 0 && (user.isStateAffected(93)|| user.isStateAffected(94) || user.isStateAffected(95) || user.isStateAffected(96) || user.isStateAffected(97)) )

coz the format is "if (conditions) {actions}" and not "if conditions {actions}"

base damage += baseDamage + Math.ceil(user.level * 0.5)

You placed a space there, base damage.

#### Nol

##### Veteran
God this feels so basic yet so hard ^^

I removed user.level in case it was unrecognized, and replaced it with "5" to make checking easier

I'm at that now :

if (this.isPhysical()) {
if (baseDamage > 0 && (user.isStateAffected(93) || user.isStateAffected(94) || user.isStateAffected(95) || user.isStateAffected(96) || user.isStateAffected(97))); {
baseDamage += 5;}
value = this.applyPhysicalRate(value, baseDamage, target);

I still get unexpected token, oddly enough, on auto passive states,

And said error appears wether i have the "Power attack" state turned on or off

Edit : turning of Autopassive States removed the error, but still no damage increase

Edit 2 : turning it back on doesnt prompt an error anymore, but still no damage increase

Edit 3 : I replaced all the "user." with "a.", and got the auto passive error again.

Turned autopassive Off, retried

Got Equip requierement error, turned it off, retried

now its Equip core that has a problem, i think it's endless (not to mention I use those plugs for a reason)

All three errors were almost identical :

Yanfly.Util.displayError = function(e, code, message) {
console.log(message);
console.log(code || 'NON-EXISTENT');
console.error(e);

Last edited by a moderator:

#### LadyBaskerville

##### Hell-poodle
You have a semicolon after your second condition (after the three closing brackets) that shouldn't be there. Also, in the last code you posted, you never close the block of the first if-statement (closing curly bracket is missing), but that might just be not copied correctly.

#### Nol

##### Veteran
I tried both with and without semi colons (i tried a lot of things, i've been on this for a month)

and yeah the bracket is just part of YF's code

Im using the a.level instead of user.level, and i get a damage flow error, unexpected identifyer, and this error in statusCore

Yanfly.Util = Yanfly.Util || {};

Yanfly.Util.displayError = function(e, code, message) {
console.log(message);
console.log(code || 'NON-EXISTENT');
console.error(e);
if (Utils.isNwjs() && Utils.isOptionValid('test')) {
if (!require('nw.gui').Window.get().isDevToolsOpen()) {
require('nw.gui').Window.get().showDevTools();
}
}
};

Complete code :

aseDamage = this.modifyBaseDamage(value, baseDamage, target);

baseDamage *= this.calcElementRate(target);

critical = this.modifyCritical(critical, baseDamage, target);
target.result().critical = critical;
value = baseDamage;

if (baseDamage > 0) {
value = this.applyDamageRate(value, baseDamage, target);

}

if (baseDamage < 0) {
value = this.applyHealRate(value, baseDamage, target);

}

if (critical) {
value = this.applyCriticalRate(value, baseDamage, target);

}

if (this.isPhysical()) {
if (baseDamage > 0 && (a.isStateAffected(93)|| a.isStateAffected(94) || a.isStateAffected(95) || a.isStateAffected(96) || a.isStateAffected(97))) {
baseDamage += Math.ceil(a.level * 0.5);}

value = this.applyPhysicalRate(value, baseDamage, target);

value = this.applyFlatPhysical(value, baseDamage, target);
}

if (this.isMagical()) {
value = this.applyMagicalRate(value, baseDamage, target);

value = this.applyFlatMagical(value, baseDamage, target);
}

if (baseDamage > 0) {
value = this.applyFlatDamage(value, baseDamage, target);

}

if (baseDamage < 0) {
value = this.applyFlatHeal(value, baseDamage, target);

}

if (critical) {
value = this.applyFlatCritical(value, baseDamage, target);

}

value = this.applyVariance(value, item.damage.variance);

value = this.applyGuard(value, target);

value = this.applyFlatGlobal(value, baseDamage, target);
value = this.applyMinimumDamage(value, baseDamage, target);

Short snippet of what i'm modifying (in bold)

}

if (this.isPhysical()) {
if (baseDamage > 0 && (a.isStateAffected(93)|| a.isStateAffected(94) || a.isStateAffected(95) || a.isStateAffected(96) || a.isStateAffected(97))) {
baseDamage += Math.ceil(a.level * 0.5);}

value = this.applyPhysicalRate(value, baseDamage, target);

value = this.applyFlatPhysical(value, baseDamage, target);
}

Thank you all for your time, i clearly can't handle it alone, or bypass it

Last edited by a moderator:

#### LadyBaskerville

##### Hell-poodle
Could you specify again which plugins you are currently using and where exactly you are modifying the code? I think I lost track.

EDIT: Nevermind, I just replicated the problem. Starting bughunting now.

EDIT2: Try this, @Nol:

Code:
if (this.isPhysical()) {
if (baseDamage > 0 && (a.isStateAffected(93)|| a.isStateAffected(94) || a.isStateAffected(95) || a.isStateAffected(96) || a.isStateAffected(97))) {
value += Math.ceil(a.level * 0.5);}
value = this.applyPhysicalRate(value, baseDamage, target);
value = this.applyFlatPhysical(value, baseDamage, target);
}

Last edited by a moderator:

#### Nol

##### Veteran
While this is closer than anything i have ever dreamt of achieving, and i thank you for that, the slight problem is that now the bonus damage isnt modified by the target's

physical resistance, (which i was hoping to get by playing with baseDamage).

Any idea about that would creating a new variable in between baseDamage and value work ?

Last edited by a moderator:

#### LadyBaskerville

##### Hell-poodle
If you use the Physical Damage Sp-Parameter for physical resistance, it should actually work this way (note that this.applyPhysicalRate is called after the extra value is added).

If you're working with Element rates instead, you can do this:

Code:
if (this.isPhysical()) {
if (baseDamage > 0 && (a.isStateAffected(93)|| a.isStateAffected(94) || a.isStateAffected(95) || a.isStateAffected(96) || a.isStateAffected(97))) {
var plus = Math.ceil(a.level * 0.5);
plus *= this.calcElementRate(target);
value += plus; }
value = this.applyPhysicalRate(value, baseDamage, target);
value = this.applyFlatPhysical(value, baseDamage, target);
}

#### Nol

##### Veteran
Congratulations, you just solved 2/3 of a problem that held me for over a month !

Thanks a lot, it's very satisfying to be unstuck

Should i keep the thread open for my bonus question (-which doesnt relate-) or leave this one in use ?

Bonus question :

Any way to modify SPD without changing parameters ? (My Agi doesnt just add speed, but also Hit, Eva and more, so i can't modify it freely)

I'm missing the state that buffs your spd

Waiiiiiiiiit a minute, i might be able to do that with simple traits !

Last edited by a moderator:

### Latest Profile Posts

working on an A/V sync system for my game! was NOT expecting the first roadblock to be accessing a variable from a public class!! Computers are so finicky sometimes
For the first real time since my game's inception I found myself actually having fun playing around with my party's skills while testing out some battles! So much so, that I actually forgot what I was doing for a minute and had to force myself to move on to the next thing!

That's got to be a good sign considering it only has place holder animations, enemy skills, troop comps, etc. right now. Feels good!
Finally upgraded to RMMZ.

FINALLY, I figured out how to get the "tail" to appear IN the window and not directly below it lol. now it looks like it's part of the window and not hanging from the bottom of it.
Twitch! Stream is about to go live with some Dark Souls 2! Feel free to drop by!

Threads
126,925
Messages
1,182,398
Members
166,755
Latest member
Hahah520