Obtaining an Actor Object with Script call.

I'm not much JS coder, but some stuff I know how to do in RMMV with JS, but today I have strange thought about
obtaining Actor Object in game in map (not battle).

I know the differences and how to operate with following methods:
Code:
$gameActors.actor(id)
$gameParty.members()[id]

Now I would like to do with clean Script (from 3rd tab in Event Editor) create a variable that would hold/store/represent
object of actor(s) exacly the same as yanfly handles it in his plugins. However what I was able to find in his code from YEP_AutoPassiveStates.js plugin variable user and target (see a piece of his code) are reffering to "this".

Is there a particular way to obtain actor data the same way as in image in map with "script..." event?
More less something like that.

PS: I could just use $gameActors.actor(id) and the $gameParty.members()[id] but with that I have to know ID of current actor.
I want to approach it more dynamicly, without knowing actor's ID.
I tried this:
Code:
$gameActors.actor(this._targetActorId).name();
but property "name" is null
"this" is a keyword that refers to the context of the current script. It's used to refer to instances, e.g. $gameActors.actor(1) returns an instance of Game_Actor.

From an event-based script call, this is generally the instance of Game_Interpreter currently processing the event command (in a move route, it's the instance of Game_Character corresponding to the moving character). I wouldn't suggest storing game properties like this on an interpreter! If you need to store different values for different actors, you could instead store the value on the actor objects themselves. If you only need one _targetActorId at a time, consider adding a property to a global object: maybe either $gameTemp (not saved when player saves the game) or $gameSystem (saved). Either way, I would suggest writing a plugin for it rather than doing everything with script calls: a plugin is neater, easier to debug/rework/remove, and will probably provide better performance. 😅

Regarding the excerpt you provided: this is the current instance of Game_BattlerBase. Every Game_Actor and Game_Enemy inherits from Game_BattlerBase, i.e. every actor/enemy instance in-game will now be able to invoke the passiveStateConditionEval method to check if the specified state's condition is met. 😮‍💨

In short, the code needs an actor ID to know which actor object to retrieve. How you get & set that actor ID depends on what you're trying to do. Here's a brief example with some eventing:
Spoiler: Event example
Code:
◆Text:None, Window, Bottom
:    :Pick a party member!
◆Show Choices:\P[1], \P[2], \P[3], \P[4] (Window, Right, #1, #2)
:When \P[1] 
  ◆Control Variables:#0001 Victim = 0
  ◆
:When \P[2] 
  ◆Control Variables:#0001 Victim = 1
  ◆
:When \P[3] 
  ◆Control Variables:#0001 Victim = 2
  ◆
:When \P[4] 
  ◆Control Variables:#0001 Victim = 3
  ◆
:End
◆Control Variables:#0001 Victim = $gameParty.members()[$gameVariables.value(1)].name();
◆Text:None, Window, Bottom
:    :\V[1] has been chosen for the sacrifice!
Thanks @caethyril . Everything makes sense now, thank you. I used to use the way you told me (and thankfuly I did not deleted it) but I stay with
$gameParty and $gameActors.

Thank you again. 🙂
Spoiler
giphy.gif
You're welcome! 😂

Original thread: https://forums.rpgmakerweb.com/threads/obtaining-an-actor-object-with-script-call.113674/