script call for actor? not specific, but universal

so I add an item that can clear a state...
I have searched the script call list yet can't found any about remove targets. (yes, there is a remove state, but for a specific actor)

item will check. if the target has state, remove the state and break the loop. else continue repeat till X times or found one that can be cured.
the thing I need help with is, how to make the... system lock the target? not $gameactor.actor(x) that for one target, but can be used for all actors.

1.png2.png
You can't implement your skill this way, because a common event attached to an item or skill will be run after the item/skill is resolved. At that point, you're outside of any targeted circumstance, so the game doesn't know who you targeted.

As far as I can think, you'll have to write it out in JavaScript. From there:
- See if you can cram it into one line to fit in your damage formula.
- Or program the item using Yanfly's Action Sequences.
contrary to what @ATT_Turan wrote, there are ways to make this work by events alone and you even started it correctly. But your solution does not work.

you add a state that does nothing to the actor in the item, exactly what you have done with that target state. That can be used to identify the target in the common event.

however what follows then is tedious - you'll need one conditional branch for every actor checking if the actor has the state, and then apply the commands specifically to that actor inside that conditional branch before removing the state at the end.
can be done (and has been done) if you have half a dozen actors in your game. tedious with two dozen actors and impossible if your game allows for a hundred actors.

the only reasonable way is to use damage coding in the damage formula, but that is limited to how many ifs fit into the line. can be done with a few different effects, but again impossible if it should handle more than that.
You're both wrong. You can do this in a common event and don't need a conditional branch for every actor.

Just use $gameParty._targetActorId, it'll contain the ID of the last actor to be chosen as a target in the menu.
This is the best thread ever.

"You're wrong."

"No, you're wrong."

"Everyone was wrong!"

Plus I learned something 😀
This is the best thread ever.

"You're wrong."

"No, you're wrong."

"Everyone was wrong!"

Plus I learned something 😀
I was just waiting for someone to come in and point out a better way than _targetActorId.
this is another random remove state, but I can't get how it works.
this is another random remove state, but I can't get how it works.
What is your question? Trihan gave you the answer to how to do what you want using the common event you have set up.

Now you provide a link to code that does something different than what you want, and say "I can't get how it works."

Does that mean you want your skill to work that way instead, and you tried that solution and it didn't work? Or does it mean you don't understand the JavaScript used to achieve it and you'd like that explained?
What is your question? Trihan gave you the answer to how to do what you want using the common event you have set up.

Now you provide a link to code that does something different than what you want, and say "I can't get how it works."

Does that mean you want your skill to work that way instead, and you tried that solution and it didn't work? Or does it mean you don't understand the JavaScript used to achieve it and you'd like that explained?
because I don't really know much about using the script, I use a common event instead.
I want an RNG cure state while using common event, but since almost all say can't...
alternative if can't common event.

You're both wrong. You can do this in a common event and don't need a conditional branch for every actor.

Just use $gameParty._targetActorId, it'll contain the ID of the last actor to be chosen as a target in the menu.
ok the last target actor ID, but how about if the last target is state? "$gameParty._targetActorId.isStateAffected(x)" ?
Almost.

$gameActors.actor($gameParty._targetActorId).isStateAffected(x)
I want an RNG cure state while using common event, but since almost all say can't...
alternative if can't common event.
The screenshot you attached to your first post is incomplete, so I misunderstood what you were trying to do (and you never actually said it in your post).

It looked like it's incrementing through the states in order and clearing the first one it gets to.

Now that you've explained what you want to do, here's the script that should do what you want:
Code:
var removeStates = [3, 4, 5, 6, 7];
var currentStates = [];
var target=$gameActors.actor($gameParty._targetActorId);
for (var i = 0; i < removeStates.length; i++) {
  if (target.isStateAffected(removeStates[i]))
    currentStates.push(removeStates[i]);
 }
if (currentStates.length > 0) {
     target.removeState(currentStates[Math.floor(Math.random() * currentStates.length)]);
}

1 - Copy the entire chunk of code and paste it into Notepad. Delete all of the extra blank lines.

2 - In the very first line, change the numbers in that list to the IDs of your states that can be removed by the skill. List as many as you want.

3 - In your common event, go to tab 3 and click Script on the bottom right. Copy the code from Notepad into that box.
The screenshot you attached to your first post is incomplete, so I misunderstood what you were trying to do (and you never actually said it in your post).
didn't mention cause think there will time where I use the same RNG mechanic on different items.
anyway, a fail... even using a notebox (before/after eval). and no point it's B, I test A before test B.
(re-edit, fix and test again the script. still fail)
4.png
5.png


test using it. actor alone, use the item to remove state 3 (poison), no remove.

Almost.

$gameActors.actor($gameParty._targetActorId).isStateAffected(x)
2.png

does the last target even work? I test it using only 1 actor. apply remove state below, yet no remove.
alpha

didn't mention cause think there will time where I use the same RNG mechanic on different items.
anyway, a fail... even using a notebox (before/after eval). and no point it's B, I test A before test B.

test using it. actor alone, use the item to remove state 3 (poison), no remove.
Maybe I'm missing it, but it doesn't look like you copied the line declaring "target".
Also, you might want to consider checking the debug console for output and atttach that if there is anything there.
Maybe I'm missing it, but it doesn't look like you copied the line declaring "target".
Also, you might want to consider checking the debug console for output and atttach that if there is anything there.
my mistake. wrong script. fix and test again, still fail. target 'var target'.
my mistake. wrong script. fix and test again, still fail. target 'var target'.
What about my second proposition? Have you checked (F8 for debug console) if there is some kind of error output?
What about my second proposition? Have you checked (F8 for debug console) if there is some kind of error output?
f8 error output? do they usually appear as...

cannot read property 'X' of undefined'? / undefined is not a function / etc?
-plugins
-plugins
-plugins

? if so, then no. no error message.
@tyranzero, please take a bit more time to translate your posts, we're all doing our best to help you but some of your posts are very difficult to understand.

You need to slow down - if you don't understand what you're doing, wait for someone to answer your questions before changing things. In your last post with pictures, you have these <After Eval> notetags that are useless, they don't do anything.

You also randomly changed the script in your common event to be...something else. It looks like the code from the other thread, which won't work because it's in a common event, not a Yanfly skill notetag. It's also split between two script boxes, so it doubly won't work. I'm surprised testing that code didn't throw an error in the console.

But now:
does the last target even work?
The answer is no. I've gone ahead and tested it on my end and (for @Trihan's knowledge, too!) it's as I said in my first reply - the targeting info is wiped at the end of the skill's resolution, so by the time it executes the common event, that _targetActorId is always 0.

So you need to go back to the first few replies. Now that I understand the complexity of what you want to do, I don't think that entire script I wrote for you will fit inside the damage formula. So you can:
1 - do it in a common event if you use an extra, empty state the way Andar described.
2 - install Yanfly's Skill Core and put it in an After Eval notetag. You can use the script I wrote for you, you'd just delete the line starting with "var target".
That's interesting, because I've been able to use it before. Though I was under the impression that this was for an item being used from the menu, not a battle thing.
I only tried it during battle, not from the menu, but I added a console.log() right at the start and it always returned 0 (which is obviously not a valid actor ID).

Edit: It works as written if you use it from the menu. But if @tyranzero wants it to function as a restorative in battle as well as the menu, he'll need to use one of the other solutions.
So you need to go back to the first few replies. Now that I understand the complexity of what you want to do, I don't think that entire script I wrote for you will fit inside the damage formula. So you can:
1 - do it in a common event if you use an extra, empty state the way Andar described.
2 - install Yanfly's Skill Core and put it in an After Eval notetag. You can use the script I wrote for you, you'd just delete the line starting with "var target".
remove the var target line... and the rng state clear is now working (and yes I have yanfly skill core).
thank you for the help

Original thread: https://forums.rpgmakerweb.com/threads/script-call-for-actor-not-specific-but-universal.137062/