Need help getting an actor's id when a skill us used.

Hello everyone, 

I am fairly new to the world of RPG creation and I have been looking all over for the answer to this question with no luck. I need a script or event that allows me to make a variable out of whoever is casting a specific skill. Seems like this should be fairly straight forward because the skill already has a user only target so if I could find out where that target is stored when it is cast I can do what I am looking to do. For example, let's say I have a druid class that has the ability to transform himself into different animals. Next let's say that this class is available to anyone in your party. How do I know which actor uses the skill transform?

I would think it would be something along these lines.  

if(actor.skill.transform == true)

{

     variable[5] = actor.id;

}

not sure how I would go about writing that in ruby but that should be the basic logic in Java. Any advice in the right direction would be greatly appreciated. 
In battle or out of battle?
It's probably easier to use the damage formula instead of a script for this.

Just add the commands before the skill's damage is calculated, like:

Code:
$game_variables[5]=a.id; real damage formula after the semicolon
Hey Andar and Shaz, Thanks for the responses. This would be in or out of battle as I have several different classes that would need this theme. Andar that is super helpful, I will give that a shot and see if it works for what I am attempting to do.
I was able to figure this out without scripts. I created a empty state, then when the skill is cast I give that actor the state and run a common event to see who has the state and do what I want to do inside that common event then remove it. Here's an example,

SKILL: Call Spider: target self, usable only in menus.  Add State Ranger 100%, call common event (Call Spider).

COMMON EVENT: @Conditional Branch: [actor[1]] is [ranger] inflicted

@Change Party Member: Add [actor[5]], initialize.

Also as far as I could tell variables can not be set inside the custom damage formula, at least not without more scripting. Thx for the help guys.
yes, variables can be set in the damage formula - the problem is on the other side, the ID-part.


I now remember that there are some problems with getting the ID, but don't remember the solution to that.


Setting game_variables to any other data works without problems
a.id should work if a is the Game_Actor object.

*edit*

Just tested it and I dont see anything wrong with

Code:
$game_variables[5]=a.id;

Original thread: https://forums.rpgmakerweb.com/threads/need-help-getting-an-actors-id-when-a-skill-us-used.39423/