When using a skill with a comment event attached, I want to set a variable to one of the selected enemies stats, however I'm not quite sure if this is even possible. How would I do this, if I even can?
For example I wish to set the 40th variable to the attack stat of the selected enemy I'm fighting, would I be able to do that?
You can use skill formula to get that effect. $game_variables[40] = b.atk
I'm not having my pc now but I think it should work.
in that case there is another way that uses no scripts, but requires a lot of event coding in the common event.
Make an invisible target state just for that skill - it should have no icon, no messages, no effect and be nothing but a marker. Then have the skill add that state to the target as a regular skill effect.
In the common event you'll now need a conditional branch for every enemy index (1-8) checking if that enemy has the state applied. If yes, you've found the correct enemy index and can use the commands to read the data of that enemy. Then after that you remove the state to prevent it from repeating.
Problem and disadvantage might be that if several targets could get the state in the same turn, the common event can't assign which actor did what skill and has to handle all targets independently.