Switch skill scope on key press

HI,

I'm trying to make a plugins that make switch between all enemy and one enemy in battle.

I know how to change skill scope, but i can't find a way to bind this change to a keypress event.

For exemple :

my skill scope is  1enemy

When i'm the enemy selection phase if i press 'b' key my skill scope change to all enemy and if i press it again it will change back to 1 enemy.

Any idea how can y bind a keypress to a function ?
I think I understand what you mean. When the game asks you to select an enemy you have two options 'ok' or 'cancel'.

You need to go into the  Scene_Battler and figure out when this code is executing and add a new command into there so you have 'ok' , 'cancel'  and 'b'.

The first thing I would do was to modify the code to where when you press 'ok' it changes the skill scope.

Once that is working the I would move to next step of adding an original command.
HI thanks for your response.

It help me.

Now i have add the command and it work fine.

BUt i can't figure how to refresh the sprite selection.

When you select an enemy he is whitened so when you switch to all enemie with my new command, all enemies are whitened.

But if i switch again to one enemie, only the first enemy should be whitened.

In my case they all stay whitened.

how can i tell to the game to refresh enemy selection?
I haven't looked into the battler scene yet as I intend to just keep it the same.
I will look into it and see if I can find you an answer.  There are more experienced people on here that  know a lot more.
 
If it can help here is my modification :

Spoiler
Code:
Hakuryo.Parameters = PluginManager.parameters('SwitchEnemyScope');Hakuryo.Param = Hakuryo.Param || {};Hakuryo.SES.defaulScope =[];Hakuryo.SES.newScope;Hakuryo.SES.skills = [];Hakuryo.SES.currentskill = 1;//Hakuryo.Param.Variable = String(Yanfly.Parameters['Variable']);//=============================================================================// DataManager//=============================================================================Hakuryo.SES.canSwitchScope = function(obj) {		var notedata = obj.note.split(/[\r\n]+/);		for (var i = 0; i < notedata.length; i++) {			var line = notedata[i];			if (line.match(/<MULTIPLE>/i)) {				return true;			}		}                return false;};//=============================================================================// Plugin Code//=============================================================================Input.keyMapper = {    9: 'tab',       // tab    13: 'ok',       // enter    16: 'shift',    // shift    17: 'control',  // control    18: 'control',  // alt    27: 'escape',   // escape    32: 'ok',       // space    33: 'pageup',   // pageup    34: 'pagedown', // pagedown    37: 'left',     // left arrow    38: 'up',       // up arrow    39: 'right',    // right arrow    40: 'down',     // down arrow    45: 'escape',   // insert    66: 'toggleAll',// B    81: 'pageup',   // Q    87: 'pagedown', // W    88: 'escape',   // X    90: 'ok',       // Z    96: 'escape',   // numpad 0    98: 'down',     // numpad 2    100: 'left',    // numpad 4    102: 'right',   // numpad 6    104: 'up',      // numpad 8    120: 'debug'   // F9};Window_Selectable.prototype.processHandling = function () {    if (this.isOpenAndActive()) {        if (this.isOkEnabled() && this.isOkTriggered()) {            this.processOk();        } else if (this.isCancelEnabled() && this.isCancelTriggered()) {            this.processCancel();        } else if (this.isHandled('pagedown') && Input.isTriggered('pagedown')) {            this.processPagedown();        } else if (this.isHandled('pageup') && Input.isTriggered('pageup')) {            this.processPageup();        } else if (this.isSwitchScopeTriggered()) {            this.processSwitchToggle();        }    }};//set key toggleAll triggerWindow_Selectable.prototype.isSwitchScopeTriggered = function () {    return Input.isRepeated('toggleAll');};//process acrion on key input 'toggle all'Window_Selectable.prototype.processSwitchToggle = function () {    if (this.isCurrentItemEnabled() && Hakuryo.SES.canSwitchScope($dataSkills[Hakuryo.SES.currentskill])) {        if (this.active && this instanceof Window_BattleEnemy) {            SoundManager.playCursor();            Hakuryo.SES.defaulScope.push($dataSkills[Hakuryo.SES.currentskill].scope);            $dataSkills[Hakuryo.SES.currentskill].scope = $dataSkills[Hakuryo.SES.currentskill].scope === 1 ? 2 : 1;            this.refresh();            this.reselect();        }    } else {        this.playBuzzerSound();    }};Scene_Battle.prototype.onSkillOk = function() {    var skill = this._skillWindow.item();    var action = BattleManager.inputtingAction();    // gettting current skill id    Hakuryo.SES.skills.push(skill.id);    Hakuryo.SES.currentskill = skill.id;    action.setSkill(skill.id);    BattleManager.actor().setLastBattleSkill(skill);    this.onSelectAction();};

Original thread: https://forums.rpgmakerweb.com/threads/switch-skill-scope-on-key-press.48016/