MZ Trying to call data from a previous skill

I'm trying to make a skill that heals an actor for a %mhp and 10% of the damage dealt. But I want the healing to happen after actor has returned to their home position. I have VS battle core all coded for a custome action sequence im just having issues getting the heal to land.

Im using a script before the heal portion to call up some info:
skill = $gameTemp.lastActionData(0); user= $gameTemp.lastActionData(2)

But im not sure how to call the info from it to make the formula work.
Math.round((user.mhp * 0.03% + skill.???*0.1))

If i use just the mhp portion it returns -0 heal. im just not sure where to go from here.

any help would be appreciated.
I’m not sure about the lastAction portion of this approach but in your formula that * 0.03% needs to have the percent sign removed because that’s going to get interpreted as the MOD operator.

I’m more familiar with MV but a way I would approach this there would be to use a passive state plugin with Yanfly’s states core to save damage dealt as part of an Action End Effect or Establish Effect in a variable (i.e. user._lastActionDmg = value). Then your formula for this heal skill would be:

Math.round((user.mhp * 0.03 + user._lastActionDmg * 0.1))
where and how do you use those lines?

An additional problem is that depending on your use of 'skill' and 'user' will be defined as local variables that get deleted as soon as the skill execution is complete.
@Andar Im using them in a action sequence common event.
Screenshot 2023-01-28 101410.png
the original script command is sandboxed, which means that all variables defined inside are deleted as soon as the script box closes.

I don't know if visustella changed that when defining action sequences as I never worked with their plugins or MZ
Would there be a way to do like a user.gainHp in the script command?

Edit:
When i remove the script command part it will say user or skill is undefined.
that completely depends on how visustella processes the common event as an action sequence.
which is why I said that I can't help - it might even be that your use of the script command is correct as the sequence is not processed in the same way as a regular event.
Notes:
  • lastActionData values are all numbers, as seen in Control Variables -> Game Data -> Last. You're getting the last skill ID and the last subject actor ID.

  • Your Script command implicitly defines those two variables on the global scope, because you haven't used one of the local declaration keywords: var, let, or const. That's not a good habit to form, but it explains why the values are available for reference in the later eval.
Consider something like this for your action sequence eval?

const a = $gameActors.actor($gameTemp.lastActionData(2)); Math.round((a.mhp * 0.03 + a._lastActionDmg * 0.1))
This is adapted from @Villhelm's suggestion. If the _lastActionDmg value is not set automatically, then you'll need to set it in your damage formula or something, e.g.

a._lastActionDmg = a.atk * 4 - b.def * 2
(Yes, that's literally a whole example skill formula. Assignment returns the assigned value.)

It would make sense if some kind of user variable is already defined for the action sequence eval, or at least accessible via its scope, e.g. this.subject(). I don't know how VisuStella have their plugin set up, though.

Original thread: https://forums.rpgmakerweb.com/threads/trying-to-call-data-from-a-previous-skill.154479/