QABS - Use Skill from common Event.

Hi guys, does anyone know how I would make the player use a skill in QABS from a common event instead of a hotkey

This is the code to use a skill from an event which is pretty easy.
var chara = this.character();
chara.useSkill(2);

But I have no clue how to apply that to a common event. simply changing the var chara to gameActors.actor was my hope of a quick fix but it doesn't work. The error I get is useSkill is undefined.

Plugin
I'm pretty new to messing with RPG Maker's global variables, but I gave this a shot as I am also trying to use QABS with a common event. I believe -- and this is complete speculation, mind you -- that the plugin requires skills to be used by a map event. So, your idea of grabbing the game actors doesn't work because none of the actors are map events.

What you would end up using is the $gamePlayer variable. Unfortunately, I can't figure out how to execute $gamePlayer.useSkill(id) from within a common event. ;;

Edit: I figured it out. All you need is $gamePlayer.userSkill(SKILL_ID, true); I've left my original solution in spoiler for posterity, but I'm not joking when I say it's a hack script. I kept finding issues with it and how QABS handles cooldowns.

Spoiler
However, $gamePlayer.forceSkill(id) works just fine even from a common event... If you don't care about paying the MP/TP cost of a skill, it's a viable option, but I wanted to be able to pay those costs in my case. With that in mind, here's a script that I came up with, which feels a bit hacky but gets the job done:
JavaScript:
var SKILL_ID = 6; // The skill to use
var player = $gameParty.leader(); // The actor to check -- in this case, the party leader
var skills = player.skills(); var skillIndex;
for(var i=0;i<skills.length;i++) {
  // Check if leader has skill & can pay MP/TP cost
  if(skills[i].id == SKILL_ID && player.canPaySkillCost(skills[i])) {
    skillIndex = skills[i]; break;
  }
}
if(skillIndex) {
  $gamePlayer.forceSkill(SKILL_ID); // Use the skill in QABS
  player.paySkillCost(skillIndex); } // Pay cost

Put this script in the common event. Set SKILL_ID to the skill you want the player to use. It will then go through the party leader's skills, and if the leader both possesses the skill you've selected and can pay the cost of MP and TP, it will execute the skill. It then pays the skill cost and gives you TP, if applicable.

In theory you can swap out $gameParty.leader for other characters in the party. I haven't tested this code in all use cases, but it works properly for what I needed it for. If you encounter any glaring issues with it or can find a way to improve it, let me know!
is posible make a enemy execute a forced skill too by comand? and how i get the ID of the enemy event doing a skill

Original thread: https://forums.rpgmakerweb.com/threads/qabs-use-skill-from-common-event.120526/