Set a skill in battle to a key

What I'm asking is how could I go about setting up a skill(like guard) to be performed only when a certain key is pressed on an actor's turn(and not happen until it's time to take their action)? It wouldn't appear on the command list, but when say 'A' is pressed, it'd take a turn for that character, and have them guard, or wait, or something. I know that through a conditional branch, it'd run something if a key is pressed, like what I'm asking for, but is there a way to have the effect run for the specific actor that uses it?  🤔

(Ah, and I'm using VX Ace.)
The simplest way to do this would be by scripting, as we cannot detect a player's turn selection just with eventing. (It is different if you made a full battle system using just eventing, but....)

This is one example.

class Scene_Battle < Scene_Base alias :create_actor_command_window_shiftguard :create_actor_command_window def create_actor_command_window create_actor_command_window_shiftguard @actor_command_window.set_handler🙂SHIFT, method🙂command_guard)) end endThis will set the Shift key to make the current actor assign guard as action.
I just tested this(as well as in a new project), and..it doesn't work. I mean, it doesn't result in a character guarding, or anything happening actually. I changed the key as well, but still nothing happened(unless I'm doing something wrong o-o).
I would reccomend adding this 

class Window_ActorCommand < Window_Command def process_handling return unless open? && active Window_ActorCommand return call_handler🙂guard) if handle?🙂guard) && Input.trigger?🙂X) endendYou can repeat this line : 

return call_handler🙂guard) if handle?🙂guard) && Input.trigger?🙂X)Changing the "X" depending on the input key you need
RIght, forgot to give the other part of that code....

Code:
class Window_ActorCommand < Window_Command    def process_handling    return unless open? && active    return call_handler(:SHIFT) if handle?(:SHIFT) && Input.trigger?(:SHIFT)    super  end  end
I would reccomend using this 

class Window_ActorCommand < Window_Command def process_handling return unless open? && active Window_ActorCommand return call_handler🙂guard) if handle?🙂guard) && Input.trigger?🙂X) endendYou can repeat this line : 

return call_handler🙂guard) if handle?🙂guard) && Input.trigger?🙂X)Changing the "X" depending on the input key you need
This is..game-breaking. What I mean is that, it lets me only use the key to guard, and nothing else. Also, the windows in battle seem to get a little screwed up(the Fight/Escape menu is off-screen, and doesn't return). :l

RIght, forgot to give the other part of that code....

class Window_ActorCommand < Window_Command def process_handling return unless open? && active return call_handler🙂SHIFT) if handle?🙂SHIFT) && Input.trigger?🙂SHIFT) super end end
Uhm..still nothing happens when I press the key to guard. o-o
It's meant to be used with the previous snippet...

Though, it is still kind of buggy.

Try this, this will correctly set guard when pressing Shift key:

Spoiler
Code:
class Window_ActorCommand < Window_Command    def process_handling    return unless open? && active    return process_key_shift if handle?(:SHIFT) && Input.trigger?(:SHIFT)    super  end    def process_key_shift    Sound.play_ok    Input.update    deactivate    call_shift_handler  end    def call_shift_handler    call_handler(:SHIFT)  endendclass Scene_Battle < Scene_Base    alias :create_actor_command_window_shiftguard :create_actor_command_window  def create_actor_command_window    create_actor_command_window_shiftguard    @actor_command_window.set_handler(:SHIFT, method(:command_guard))  end  end
Ah, okay(didn't know I had to use both snippets..I'm oblivious like that sometimes..). Thanks Shadow, this time it works just fine.  🙂

This can be closed now.  😉
I've moved this thread to RGSS3 Script Requests. Please be sure to post your threads in the correct forum next time. Thank you.


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/set-a-skill-in-battle-to-a-key.25435/