I need a Skill that casts a random skill from a LEARNED skillset.

Hi all! This should be simple (I think) Im looking for a way to achieve this: skill that will cast a random skill from their learned skill set. Since I cant use Skill Id`s because I dont know which skills my character will now at the time of the casting. How can I do this?


Thanks!!!
You can do it without a plugin, although it's quite complicated.
If it's a single actor and the only thing you are worries about is making sure the actor can't use skill xe haven't learned yet from level up, have the random skill call a common event that sets a variable to a random number between 1 and the max number of skills that actor can learn, then it goes down a list of conditional branches for each number. If the number is "rolled", it checks to see if the actor knows the skill. If so, use skill and end processing. If not, it restarts the check (use labels) and runs again until a skill is picked.

If anyone can use this and you have some complicated skill setup (such as a class system), then you need to do the same thing but differently. You need a switch and a few variables. First, in the formula for the random skill, set the variable "ActorCheck" to the id of the user (a.id). Then call the common event. Have a second variable "RandomCheck" roll a number based on the total number of skill in your game. Then use a conditional branch with a script call to see if the actor knows the skill, use if so, and restart if not. If enemies can use this, I'd make it another skill so the engine doesn't get confused. I'm not exactly sure how to form the check, but this should help.
I spent a little time on this and figured out a way you can run this through a common event, IF you're only going to make this skill usable in battle. Outside battle, I have no idea yet how you would implement this (or why).

Have your random skill call a common event, and put the following in a script call in the common event:

var index = Math.randomInt(BattleManager._subject.usableSkills().length);
var skillId = BattleManager._subject.usableSkills()[index].id;
BattleManager._subject.forceAction(skillId, -1);

I set my "random" skill to scope "the user" and unfortunately I can't get it to stop saying "There was no effect on [Name]." But other than that it works great.

EDIT: This should only work for actors, not enemies.
Thankyou both!! I was going through all this eventing as Kirb mentioned, but I remember seeing a code with randomint and figured it should be easier, I will try your method Llare, again, thank you both!!!
@Llareian , Hmm....weird, but the actor does nothing. I created a skill (random) with the cope on user, this skill calls the common event X, which has the script code mentioned above. Also gave different skills to the users to test it.

What Im doing wrong?

Could it be that me using plugins overrides the code you gave me? Im using almost ALL of yanfly plugins.
Could it be that me using plugins overrides the code you gave me? Im using almost ALL of yanfly plugins.

Could be. I'll load up one of my projects tomorrow that has Yanfly enabled and try it again. Are you using MV 1.5.1?
Yep, 1.5.1.....Thanks man!

Original thread: https://forums.rpgmakerweb.com/threads/i-need-a-skill-that-casts-a-random-skill-from-a-learned-skillset.86209/