Deal Skill Damage to Target in Common Event

I have a skill which uses a common event to check for the number of items the party has and deals damage based on those items (and uses them as well).


I'm having trouble figuring out how to actually attack the enemy or enemies targeted by the skill. The choices for changing enemy HP are Entire Troop and then 1-8. How would I go about doing this?


I read about applying a state to enemy prior to the common event and then attacking any enemies with that state. I know how to apply the state, but I don't know how I would target based on it.
If you try to use that command inside a troop event, the editor would automatically list the name of the enemy inside that troop - do this to get a feel for the command.


It will works similiarly when called by a skill in battle, but unfortunately the editor does not know in which battle/troop the skill is used, so the common event cannot name the enemies - but the numbers are still the indices for the enemy.


You just have to check which enemy to target by number alone - and conditional branches to check if that enemy exists in the battle, because not all troops use the full 8 enemies.


As for the state method - that is one way to check for the enemies. Just make eight conditional branches for the eight possible enemies, check if that enemy has the state inflicted with that conditional branch and if yes, apply the effect and remove the state (to prevent a double effect if the skill is used again).
Thanks for the fast response. That helps a lot to understand how all of that works in the engine. I was hoping something more elegant existed, but now I know!

Original thread: https://forums.rpgmakerweb.com/threads/deal-skill-damage-to-target-in-common-event.62794/