Activating Skills

This sounds to be noob or crazy but in script call or scripting, how can I perform a skill again?

Say I have a command in my BattleCommand named "Forced Magic" and when I select that, it randomly casts any skill from the database. 

What's the script for calling / casting a skill again?
so after Forced Magic is used, you want to use Forced Magic Again???
Nope. I want to use it once only in a battle. How can I cast a skill? or the specific script call to cast this skill?
I can't quite understand what you want... you asked how to perform a skill again, then you tell me that it should only be used once?


or do you want the Forced Magic skill to cast another skill at random? there's a script for that out there... Skill Invoke if I remember correctly
Wait so there's two things involved here.

  1. You want a skill that selects a random other skill from a pool when used, and then force-actions the picked skill from the same actor.
  2. You want this skill to be selectable from Window_ActorCommand  (There is a yanfly script that you can use to achieve this)
Did I get it right?
Being able to activate it randomly was just my example 🙂

My specific request is on how to exactly activate a skill in battle. I am using a script called SEA - Battle Common Events, however, I want to tweak it a bit so that I can cast a skill inside the script instead of using one on common events. This is specifically to control what skill is specific for that actor.
There's some methods to do this.
 
What I often use is inserting a new action for the battler and call use_item/execute_action directly. Something like this:

class Scene_Battle < Scene_Basedef force_skill(actor, skill) #store current subject last_subject = @subject @subject = actor #creating new action action = Game_Action.new(actor) action.set_item(skill) if actor.usable?(action.item) # insert the action to the front of the battler's actions, execute, # then remove the action from the battler's actions. actor.actions.unshift(action) use_item actor.actions.shift end #restore current subject @subject = last_subjectendendYou can look to use_item method in Scene_Battle, or the methods that calls it, to learn how skills/items are executed.
Ahhh, this helps. Does this mean that if I want an actor to perform a skill I have to do them individually? Such as one method per skill?
Ahhh, this helps. Does this mean that if I want an actor to perform a skill I have to do them individually? Such as one method per skill?
Well, that depends on how you code them, really. My example function takes a battler ('actor' is a misnomer, the argument can be supplied with any battler object) and a skill as argument, and forces the battler to use the skill if it fulfills the execution condition. If you remove the usable? check, it'll execute the skill even when the battler is dead. Also, as it is, there will be no delay to the execution of the skill.

(By the way, the snippet as it is will make some errors. action.set_item will set the action to item numbered item id, so the battler use an item instead of skill. Change that line to action.set_skill(skill) and it will take the proper path.)

If you want to take the inputting actor as the skill's executor, there are some parts of the code that need to be changed. Namely, how the code acquire battler.
I see. I am currently searching on the default script and looking how they do perform however there's not one I can think of to where they actually go. I'll try to base your snippet on it, might as well see how it turns out. I've been having problems on this lately, can't figure it out.

Original thread: https://forums.rpgmakerweb.com/threads/activating-skills.24158/