Seeking advice on implementing a skill idea

I have an idea for a skill that I want to implement, but I'm unsure of what would be the best approach. The basic idea is that when you use the skill, you select 1 Ally to target. The skill then deals Thunder damage to a random enemy, and if it hits, the selected ally gets a stack of the state "Charged" while the enemy gains the state "Shock." At first I was thinking I could use something along the lines of:

<target action>
action animation: random enemy
wait for animation
action effect: random enemy
add state 29: random enemy
add state 30: target
</target action>

But there isn't a "random enemy" defined in Yanfly's Action Sequence packs. I've also checked to see if there was a tag that might be helpful in the Target Core, but there wasn't anything that matches what I was thinking. Should I change the scope of enemies affected to all? Or just a row? Then use the <Post-Damage Eval> tag to determine if the Charge state is applied? Below is my current list of plugins for reference.
Spoiler: My current plugin list
01.png
02.png
03.png
04.png
The tricky part of what you're asking is the "if it hits" part.

You need the skill scope to target an ally, because that's the part you want to select. But then saying "if it hits" the random enemy means you're reproducing the entire skill hitting process in your notetags.

So for example's sake, I'm just putting a basic hit chance in here, because I don't know what plugins you're using, anything that affects the hit formula, etc.

The way I'd approach this is with a Yanfly Skill Core notetag:
Code:
<Before Eval>
// Get random enemy
    let enemy = $gameTroop.aliveMembers()[Math.randomInt($gameTroop.aliveMembers().length)];
// Do an 80% chance of hitting
    if (Math.random() < .8)
    {
// Replace the -50 with whatever damage formula you want using user and enemy
        enemy.gainHp(-50);
// Replace 69 with the ID of the animation
        enemy.requestAnimation(69);
        enemy.startDamagePopup();
       if (enemy.hp <= 0)
            enemy.performCollapse();
// Replace the two state IDs
        else
        {
            enemy.addState(42);
            target.addState(66);
        }
    }
</Before Eval>
The tricky part of what you're asking is the "if it hits" part.

You need the skill scope to target an ally, because that's the part you want to select. But then saying "if it hits" the random enemy means you're reproducing the entire skill hitting process in your notetags.

So for example's sake, I'm just putting a basic hit chance in here, because I don't know what plugins you're using, anything that affects the hit formula, etc.

The way I'd approach this is with a Yanfly Skill Core notetag:
Code:
<Before Eval>
// Get random enemy
    let enemy = $gameTroop.aliveMembers()[Math.randomInt($gameTroop.aliveMembers().length)];
// Do an 80% chance of hitting
    if (Math.random() < .8)
    {
// Replace the -50 with whatever damage formula you want using user and enemy
        enemy.gainHp(-50);
// Replace 69 with the ID of the animation
        enemy.requestAnimation(69);
        enemy.startDamagePopup();
       if (enemy.hp <= 0)
            enemy.performCollapse();
// Replace the two state IDs
        else
        {
            enemy.addState(42);
            target.addState(66);
        }
    }
</Before Eval>
I copied the code you provided into the skill's notetag. The function appears to work up until it reaches enemy.requestAnimation(). It's giving me an error saying that requestAnimation() is not a function.
Screenshot 2024-03-28 122143.png

The damage does get dealt, but it seems to stop when it reaches that specific line.

UPDATE: I just looked it up in the Google doc by Archeia and Caethyril, and the MV function is startAnimation(). I changed it in the code and it worked, but now the pop up is showing a long string of 9's. It read something like "59 9999999999999", but it seemed it only did 59 damage. Is that just a hiccup?
It read something like "59 9999999999999", but it seemed it only did 59 damage. Is that just a hiccup?
take everything you put in the gainHp function and run it through Math.ceil(formula goes here). when youre not healing/dealing damage directly through the formula box, you have to make sure the value is always going to be an integer or else that happens
take everything you put in the gainHp function and run it through Math.ceil(formula goes here). when youre not healing/dealing damage directly through the formula box, you have to make sure the value is always going to be an integer or else that happens
It works! Thank you both!
Sorry, requestAnimation is on the map, startAnimation is in battle.

Glad you got it working - you might consider getting rid of some of the unnecessary parentheses in your damage formula, all of that makes it prone to error (as well as harder to read) 😉

Original thread: https://forums.rpgmakerweb.com/threads/seeking-advice-on-implementing-a-skill-idea.167250/