This will send you to a thread I asked for that, cause I was curious.
Now all the things on the puzzle are here for you to build what you need.
So this:
Code:
$gameVariables.setValue(40, BattleManager._action ? 1 + BattleManager._action._targetIndex : -999)
Code means:
We will set the value of Variable with id=40
If we are in battle, set the value equal to what this spell targeted,
otherwise set it to -999
inside the formula works like a charm.
I stored the value to the 40th variable.
IS this the only way to run code through battle?
I mean, can you get the current move's targetIndex using the Common Event?
The real question is, what the scope of targetIndex is. Can it be reached from the common event and what the variable would be?
Case is solved, on my behalf, but I am curious to know if you can use a script command from common event and do the same thing.
TO SUM THINGS UP:
Create the skill you need to do the debuff.
Set damage to HP. In the formula, insert this:
Code:
$gameVariables.setValue(40, BattleManager._action ? 1 + BattleManager._action._targetIndex : -999)
Make sure it is certain hit.
Now imagine that the 40th variable is named EnemyIndex.
Database >> Common Event
Create a common event named Debuff 1.
Set a variable named PROB with a random value.
Conditional Branch: If PROB is less or equal to 30
Conditional Branch: If EnemyIndex =1
Change Enemy HP: #1 -10
End
Conditional Branch: If EnemyIndex =2
Change Enemy HP: #2 -10
End
and so on...
End
(This gives a 30% chance of success. Then we check case of Index. Whoever the index belongs, will get a -10HP ddebuff on our example!)
Go back to your Skill.
Skill >> Effects: Double Click >> Other >> Common Event
Select the Common event you made.
And that's how you can set up what you need to do.