How do I show damage using Yanfly Skill Core Codes

Im trying to have a skill deal 15% of targets max HP as bonus damage if enemy has a state.
I did this

<Pre-Damage Eval>
if (b.result().isHit()) {
if (b.isStateAffected(12) && target._enemyId != 3) {
target.gainHp(-target.mhp*.15);
}
}
</Pre-Damage Eval>

So it works perfectly but for some reason it does not show the original damage, is there a code or way to have that number pop up? Right now it just shows the bonus damage
So lets say enemy has 400 max hp and I use this it says damage is 60 but it could in fact lower the HP to less then half.
you can do this without a notetag
damage formula
b.isStateAffected(X) ? a.atk*4 + b.mhp*0.15 - b.def*2 : a.atk*4 - b.def*2;

just change X to the state number
and change the atk and def parts of the formula to whatever u want those to be
you can do this without a notetag
damage formula
b.isStateAffected(X) ? a.atk*4 + b.mhp*0.15 - b.def*2 : a.atk*4 - b.def*2;

just change X to the state number
and change the atk and def parts of the formula to whatever u want those to be

Im having trouble with this because currently my skill deals damage equal to user max hp * .2, it also adds state 1.
I want to have it so that if state 10 is applied it does max hp * .2 + targets max hp * .15 but also adds state 3.
Yes complicated I know but im going for a combo type system. Also I would prefer the damage be applied as a bonus, it will look better if it displays skill damage plus the enemy max hp as bonus damage after or under the original damage.
I tried:
b.isStateAffected(2) ? b.addState(3) a.mhp * .2 + b.mhp * .15 : a.mhp * .2;
and other variations including
b.isStateAffected(2) ? b.addState(3) && a.mhp * .2 + b.mhp * .15 : a.mhp * .2;
b.isStateAffected(2) ? b.addState(3) : a.mhp * .2 + b.mhp * .15 : a.mhp * .2;

Basically my skills are a mess. I use a plugin to allow formulas in note tag:

<formula effect>
if (b.isStateAffected(3)) b.addState(4)
</formula effect>
<formula effect>
if (b.isStateAffected(2)) b.addState(3)
</formula effect>
<formula effect>
if (b.isStateAffected(1)) b.addState(2)
</formula effect>
<formula effect>
b.addState(1)
</formula effect>

The idea is that it stacks a state that allows skills to have enhanced effects with lvl 4 (state 4) at the maximum potential. If you use state 10 (10-14 is a different set but same applies); what happens is from state 10 it goes into state 3 (to otherwise get to state 3 you would cast the spell 3 times so it reduces the casts to only 2 spells) and the unique part of state 10 is that it does extra damage based on targets max hp.
Sorry if its complicated im lacking sleep right now and this makes sense to me lol.
Hey there,

The easiest way I see would be something like Magusalfador did here. (And now that I digged it up I realise I completely forgot about this thread, Sorry 🙁 )
During the pre-damage phase you can make final adjustments to the damage that battler is going to receive by modifying "value". So if you want to increase the damage by 15% of the targets maximum health, instead of reducing the targets HP directly you could write
value = value + b.mhp * 0.15;
for example.

However, the main difference between this and using the damage formula is of course that the additional damage is fixed and not affected by defending, critial strikes, element resistence or damage variance.
Hey there,

The easiest way I see would be something like Magusalfador did here. (And now that I digged it up I realise I completely forgot about this thread, Sorry 🙁 )
During the pre-damage phase you can make final adjustments to the damage that battler is going to receive by modifying "value". So if you want to increase the damage by 15% of the targets maximum health, instead of reducing the targets HP directly you could write
value = value + b.mhp * 0.15;
for example.

However, the main difference between this and using the damage formula is of course that the additional damage is fixed and not affected by defending, critial strikes, element resistence or damage variance.

Yeah lol thats what I thought and tried from other thread but didn't work. I don't know what to write or what is written that allows the damage to show or not show.

I tried this:
<Pre-Damage Eval>
if (b.result().isHit()) {
if (b.isStateAffected(12) && target._enemyId != 3) {
value = value + b.mhp * 0.15;
}
}
</Pre-Damage Eval>

It works but it shows the damage all as one and im trying to learn the code that will display damage and even text, that would help me, I could write and display "enemy suffered a lethal strike!" letting the player know that the extra damage was applied.

What I did instead and it works but eh its good enough:
<Pre-Damage Eval>
if (b.result().isHit()) {
if (b.isStateAffected(12) && target._enemyId != 3) {
user.forceAction(41);
BattleManager.forceAction(user);
}
}
</Pre-Damage Eval>
It casts a new skill that has the formula b.mhp * 0.15, so its as if it hits twice.

However is it possible to insert a text box? Theres no text anywhere and it might get confusing.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-show-damage-using-yanfly-skill-core-codes.96939/