MV [SkillCore]How do I make a custom execution keep track of the target?


<Custom Execution>
let a = Math.floor(Math.random() * 10);
console.log(a);
let b = user.skillMasteryLevel(25);
console.log(b);
let c = a + b;
console.log(c);
let d = c / 20;
console.log(d);
target.addBuff(4, d);
</Custom Execution>

I have this on a skill. It's meant to add more stacks of the buff scaling with the mastery level, but the console says that target is undefined. How do I track who the target of the skill is?
you cant without editing the plugin to do so. The execution notetag doesnt provide a target variable.
you can try
Code:
BattleManager._targets[0]
in place of target, but im not sure if the action's targets have been made at that point yet

Also is there a reason this isnt an After Eval effect instead? that would let you access the target easily
you cant without editing the plugin to do so. The execution notetag doesnt provide a target variable.
you can try
Code:
BattleManager._targets[0]
in place of target, but im not sure if the action's targets have been made at that point yet

Also is there a reason this isnt an After Eval effect instead? that would let you access the target easily
It works, but it oddly enough seems to only be increasing the stack by one instead of 5 like the math works out to. The skill is set to 99.
seems to only be increasing the stack by one instead of 5
thats what the function does. the second parameter of addBuff is turn count, not buff stacks. It always increases the buff stack by 1. if you want multiple stacks, youll want to make a loop and run addBuff as many times as needed
thats what the function does. the second parameter of addBuff is turn count, not buff stacks. It always increases the buff stack by 1. if you want multiple stacks, youll want make a loop and run addBuff as many times as needed
Ah, that makes sense. So an until loop?
It works, but it oddly enough seems to only be increasing the stack by one instead of 5 like the math works out to. The skill is set to 99.
I don't think you understand addBuff() correctly - it only adds one stack. The second argument is how many turns the buff lasts for.

Ah, that makes sense. So an until loop?
There's no such thing, only for and while. But yes, you could use a for loop to do it.
<Custom Execution>
let a = Math.floor(Math.random() * 10);
let b = user.skillMasteryLevel(25);
let c = a + b;
let d = c / 25;
for (d == 0){
BattleManager._targets[0].addBuff(4, d);
d -= 1
};
</Custom Execution>

I uh... don't seem to know how to structure loops.

Apparently ) is the unexpected token? That would normally mean I'm closing parentheses without opening, but I don't see that anywhere.
thats not how you set up a for loop, but its close enough to a while, so lets roll with that.
Code:
while (d > 0){
    BattleManager._targets[0].addBuff(4, 5);
    d -= 1
};
thats not how you set up a for loop, but its close enough to a while, so lets roll with that.
Code:
while (d > 0){
    BattleManager._targets[0].addBuff(4, 5);
    d -= 1
};
1732771288540.png

We got it! Five stacks!

Using the while d > 0 loop has an extra benefit. I was worried about how to balance the equation in a way that it always adds at least one stack. But even tiny fractions are greater than zero, so they always add one stack.

Original thread: https://forums.rpgmakerweb.com/threads/skillcore-how-do-i-make-a-custom-execution-keep-track-of-the-target.173510/