MV How to properly change HP with script calls

Hello,

I have this damage formula which works, however there are 2 problems.

<Custom Turn Start Effect> user.setHp(user.hp - (10 * user.elementRate(1))); </Custom Turn Start Effect>

1. When enemy is killed by this code, their sprite doesn't disappear.
2. Damage dealt by this code is not displayed on screen.
Therefore, my question is, how can I resolve these two issues.

Also I am using yanflys buffs and states core.
You should not be using setHp for this - that's to actually edit the value of a battler's HP.

The correct function is gainHp, e.g.
Code:
user.gainHp(-10*user.elementRate(1));

You may still need to add a manual check for them to die:
Code:
if (user.hp<=0)
    user.performCollapse();
Yes, use gainHp here: it's better suited to your situation and it interfaces with the "action result" system, which is referenced by damage popups.

You may also need to manually trigger the damage popup, e.g.
JavaScript:
user.startDamagePopup();
Thank you both, exactly what I was looking for.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-properly-change-hp-with-script-calls.161019/