MZ "$gameParty._targetActorId" Doesn't seem to work in battle

I'm trying to make a skill that applies different states based off of the amount of TP you have when you use it. I thought that setting a variable to the TP of the target actor would work, but every time I run the script "$gameActors.actor($gameParty._targetActorId).tp" it crashes.

Screenshot 2021-07-13 163124.png


I figured that "null" meant that it was trying to get the current TP of Actor ID 0, which doesn't exist, meaning that the script call isn't functioning. So, I just put the line "$gameParty._targetActorId" as what the variable is set to, and this is what I got.

Screenshot 2021-07-13 163326.png


None of them had 0 TP, by the way.

So, simply put, the script call to get the current target actor id always returns 0 in battle. Is there a script call specifically for who the skill is targeting? I need it to affect allies and enemies, too. (But the enemies part is less important)
find the method within game_party to retrieve the last actor.
it's the same thing you're doing, except, it's already accounted for.
JavaScript:
BattleManager._targets[0]

Will return the target of a single target skill, assuming you make the check when the action is actually being processed.

JavaScript:
BattleManager._targets

Will return an array of all of the targets selected by a multi-target skill.

Either should work in both MV and MZ.

I'm trying to make a skill that applies different states based off of the amount of TP you have when you use it.

However, the way that you have phrased your question ("based off of the amount of TP you have when you use it") makes it seem like you are trying to base this off of the user's TP, in which case you would need to check the user of the skill:

JavaScript:
BattleManager._subject
find the method within game_party to retrieve the last actor.
it's the same thing you're doing, except, it's already accounted for.

Tecnically speaking, I already tried that, by making the skill check 2 variables and having the script call look for the variable instead of the skill's target, but it also returned 0.

So, of course, I tried it today, and It suddenly started working for no reason.

Script call "$gameActors.actor($gameVariables.value(3)).tp" gets the using actor's TP, as long as Variable 3 is set to "last Target Actor", in spite of the fact that that exact same script call in the exact same context gave me 0 last time I tried it.

JavaScript:
BattleManager._targets[0]

Will return the target of a single target skill, assuming you make the check when the action is actually being processed.

JavaScript:
BattleManager._targets

Will return an array of all of the targets selected by a multi-target skill.

Either should work in both MV and MZ.



However, the way that you have phrased your question ("based off of the amount of TP you have when you use it") makes it seem like you are trying to base this off of the user's TP, in which case you would need to check the user of the skill:

JavaScript:
BattleManager._subject

The specific thing that I'm doing is making a combat system where you start at full TP every turn, but all of your moves cost TP to use, and you can do whatever you want as long as you have TP remaining. I wanted to convert the Guard command to an End Turn command, but I want it so that there could be some tactical choice to ending your turn early, by having End Turn give you a protection level based off of how nuch TP you had when you used it.

But I've found a means to do it, and while I would like it if it only used one variable, unless there's a way to do that exact thing, or to change the level of % damage reduction the Guard state gives you by that same variable (so I don't have to make 10 ~ 20 different states), then this thread should be solved.
I'm not really understanding why you need to use or check numerous variables when you can directly make the checks using the statements that I provided in my post.

But, if you found a solution that works for you, more power to you. I'm checking out of the thread.

Original thread: https://forums.rpgmakerweb.com/threads/gameparty-_targetactorid-doesnt-seem-to-work-in-battle.138480/