How to detect user of attack/skill?

Is there a way to detect the user of an attack or skill? Like, if I want the use of a skill to call a Common Event that reacts differently, depending on who casts it (for both monsters and hero characters).
A couple of ways, actually. You could have the skill apply a dummy state to the user (through the damage formula, if the skill targets an enemy), then in the common event, you'd check which actor has the state applied. You could also simply set the user's ID to a variable in the formula box, too, and check that instead--though that would only work for actors.
Like Hollow mentioned - I usually apply a Dummy state to the user (using a.add_state(n) in the formula box) and then run a Common Event that checks who has that state (and clears the state from the entire party at the end of the common event).  If the target for the skill is The User, you can use the standard Add State feature instead.
Like Hollow mentioned - I usually apply a Dummy state to the user (using a.add_state(n) in the formula box) and then run a Common Event that checks who has that state (and clears the state from the entire party at the end of the common event).  If the target for the skill is The User, you can use the standard Add State feature instead.
I found out this doesn't work if the attack or skill misses. Is there a way to still detect the user, or would it require a plugin?
I found out this doesn't work if the attack or skill misses. Is there a way to still detect the user, or would it require a plugin?
Yeah I think you'd need a script (not a plugin) for that.  When I have such a skill missed, I usually don't want to trigger the other effects, but I can see why you would.
It would be a pretty simple script, though. I think this should work, though I haven't tested it:

class Game_Battler < Game_BattlerBase  alias game_battler_item_hit item_hit  def item_hit(user, item)    user.add_state(#)    game_battler_item_hit   endendThis should apply the state while it's calculating the hit rate, so it'll always apply regardless of the calculations outcome. Just replace the "#" with the dummy state's ID.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-detect-user-of-attack-skill.46450/