Get enemy and actor id in a common event

Hello everyone !

I have trouble with getting IDs.

I want the id of my actor who used the skill but also the id of the target.

I put this in the damage formula :

v[2] = b.enemyId()

This just works, but in need this information in a common event who is launched when you use the skill, and the game call the event before the skill is used. i don't know how to use this << v[2] = b.enemyId() >> in a common event, i tried the script button, but it's say something like "b is not defined". why does he understand in the damage formula and not in the common event ? and also how i use this in a comon event ?
Common events are called after the skill is used, not before. Unless you have a plugin that changes that.
I don't know why, but when i attack, my test msgbox pop BEFORE the attack occurs. it mean the variable is not set the first time i use the skill. It can be a plugin, but i don't really care, i just want an answer to my question, how do i get enemy ID and actor ID related to a skill (user and target) in variables outside the damage formula ? It's not possible ? And futhermore, how can i see the system vars ? cause i think like id, the stats like atk,def,HP ect are stocked somewhere. but can i use this kind of variables ? like if i want to have the target enemy atk, how do i do ?
"b is not defined". why does he understand in the damage formula and not in the common event ?

Because the damage formula evaluator actually sets b = your target, that is why it only works inside the damage formula
Okay. so i guess a will be the launcher of the attack ? that's interesting. But can i get the Id of current actor" or "current target ? maybe i check it with a state. but it's pretty lame, cause I forced to check all Possible actor and enemy id ?
If your skill is setting the variable and you want to access the variable value in your common event almost every event command allows you to designate a value using a variable.

If for whatever reason that's not suitable, you can use the script
Code:
$gameVariables.value(id)
where id is the variable id. This will get the value you've set in the damage formula.
I know that ! but the problem is i call a common event in my skill. and the game call the event BEFORE the skill action. so exactly like I said in my first post, it works, but because the common event is called before, the vars are not set. if i use the skill twice in the same instance of the game, it works the second time.

Maybe what I do is just too complex.
and the game call the event BEFORE the skill action
this cannot happen in default.
If the common event is called before skill action, then your battlesystem has been changed by a plugin, because in default the common events called by skills always run at the end of the turn.
So for further help, you would have to find out which of your plugins change that.

that said, ever considered a different way to identify actor or target?
you can apply an invisible state to the user and the target, and then have a loop in the common event check all possible users and targets as to who have that state and then you'll know them. Not as easy as a direct variable access, but usually better to handle.
i have a plugin who change that in fact, cause my RPG is a tactical rpg, and the battle are on the map. I tried with a state "engaged", but I just reporting the problem, cause if i want to apply the state, i have to put it in the damage formula, cause i can't have the ID in the common event. And since the common event is called before....

The solution would be to simply call the common event in the damage formula. How can I do this ?

Original thread: https://forums.rpgmakerweb.com/threads/get-enemy-and-actor-id-in-a-common-event.106556/