Recording the target's TP value inside a variable

Hmm... I'm trying to create a skill effect where one actor steals the TP from another.

I'm utilizing VE - Battle Motions for this one, so what I'd need is the proper way to set a variable with the TP value of the target actor, before then doing the other effects. A snippet of the action sequence:

JavaScript:
<action sequence: execute>
eval: $gameVariables.setValue(6, ????)
animation: all targets, action
wait: all targets, animation
tp: all targets, -100
animation: user, 2
wait: user, animation
tp: user, + $gameVariables.value(6)
</action sequence>

The "????" is where I'd need to evaluate the TP of the target. Nothing I have tried (i.e. "b.tp" among others) has worked. It's easy enough to grab the TP value of a specific actor, or a specific battler based on their position, but I haven't found what can grab the TP value of the intended TARGET of the action.
According to the plugin documentation, you can use target to refer to the target.

1713809002490.png


So you should be able to do:
Code:
eval: $gameVariables.setValue(6, target.tp)
Oh, trust me, that was the first thing I tried. Errored out, unfortunately.

error1.png


error2.png


Maybe it's not so much a syntax error? Maybe the plugin code for this aspect of it is written incorrectly?

This is where it says the error occurs:

JavaScript:
Window_BattleLog.prototype.processMotionEval = function(motion, index, user, action, targets, target) {
        var a = user;
        var b = target;
        var v = $gameVariables._data;
        var item = action ? action.item() : null;
        var index = index;
        var subject = user;
        eval(motion);
    };
you can try using BattleManager._targets[0] then, assuming your skill is single target
you can try using BattleManager._targets[0] then, assuming your skill is single target
Yep, that one worked. Thank you!

So, for future reference, the value within brackets refers to the target ID in order from the first to last target, assuming by their ID when more than one target exists for the action?
As a tip, when you give info on an error, it's better to provide a screenshot of the Console tab - it's much easier to see without all the extra junk.

I suspect there's an error in the code that isn't providing the correct arguments to the battle motions - looking at the parsing function, it's all being constructed in a sort of arcane way, and I've found a good bit of broken code in other Victor Engine plugins.

@Robro33's workaround is probably the easiest method.

So, for future reference, the value within brackets refers to the target ID in order from the first to last target, assuming by their ID when more than one target exists for the action?
ID isn't really the right term, because one might confuse it with the target's enemy or actor ID. But yes, it refers to the index of the target in the list of targets, 0 is the 1st target, etc.
Good to know I can pinpoint a target, now to brainstorm it and see what other weird effects I can cook up with this. 😀

And yeah, I too have had to fix some busted code in some of his plugins, funnily enough the entire "tint" function of Battle Motion was commented out in the released version of the plugin :ewat:

Original thread: https://forums.rpgmakerweb.com/threads/recording-the-targets-tp-value-inside-a-variable.167986/