MZ Visustella Skill & States Core JS On Expire State help.

Hi. Either the plugin isn't working properly or my brain is not working properly but in my project I have a skill that puts an enemy in a trap for 3 rounds and after the 3 rounds is up the target loses 1/3 of their HP. I've put this in the States note box...


<JS On Expire State>
target.hp * 0.33
</JS On Expire State>

I've also tried different ways like...

<JS On Expire State>
target.hp / 3
</JS On Expire State>

or....

<JS On Expire State>
b.hp * 0.33
</JS On Expire State>

or...

<JS On Expire State>
this.hp * 0.33
</JS On Expire State>

...and nothing seems to be working. Am I missing something else?
You need to actually set the hp. Right now you're just computing the number / 3 but not doing anything with it.

So:

Code:
target.hp = target.hp * 0.33

or

Code:
target.hp *= 0.33

etc.
@contentdeleted is correct insofar as your syntax wasn't correct - you were doing a calculation that wasn't setting any value.

However, .hp isn't actually a member variable that you can just set. It's actually a getter. So saying target.hp = anything will have no effect.

You could bypass the getter and modify the member variable directly ( ._hp ), but that's poor practice. It's better for you to use the included function from RPG Maker, gainHp().

So your notetag should read:
Code:
target.gainHp(0-Math.round(target.hp/3));
Ah right right sorry, the actual value is stored at _hp, hp is only a getter, thanks for the correction
Thank you very much! It definitely works now.

Original thread: https://forums.rpgmakerweb.com/threads/visustella-skill-states-core-js-on-expire-state-help.156604/