Enemy's target

I know how to get an actors target.


BattleManager._subject.inputtingAction().makeTargets()[0]


Though there is probably a better way.


How do I get the enemy's target?


The enemy doesn't have the inputtingAction function, and I cannot find an equivalent function. 


This code is being written in a separate .js file (a plugin), so as far as I know I don't have access to user and target variables (I wish I did).


I'm making a function that is called when a skill activates. 
can you describe a bit more what exactly you want?


The enemy target is selected randomly based on the actor target rates - but when the skill is processed, it is stored in the object b of the damage formula.


Depending on when exactly you want something to happen and what that something is, there are several ways to handle this.
The function is called in the notetag section of the skill. I'm using the function to implement additional affects that the skill will have on it's target. Seeing as I do not know who the enemy will target, I need to be able to dynamically interact with the target, including obtaining it's Id to store in a variable.
and what plugin are you using to process the notetag data? because by itself the notebox has absolutely no function, it is only a way to give info to plugins.


And why are you using the notebox for this? such a thing is usually done in the damage formula, and in the damage formula you have the info on who the target is - object b.


That's how you access the target data (for example b.def) throughout the damage formula, and it can be used to process any javascript command, including the commands to add states or if-else-sequences to give different results depending on target conditions.


For example in the damage formula, you should be able to use something like $gamevariable(xy).setvalue(b.id) (untested syntax, I'm not at my regular computer at the moment)
I'm using a .js file that I made myself. I include it in the plugin section, and then I can use the functions I write in that file through the notetag section in the editor.


I did not know you could put that sort of code in the damage formula, I will have to try it.


Regardless, I would still like to know if there is a way to access the enemy's target for future reference.


Thanks for the replies.

Original thread: https://forums.rpgmakerweb.com/threads/enemys-target.69419/