Moghunter Battle Cursor/Yanfly Selection Control Compatibility

Affected plugins:
MOG Battle Cursor
YEP Target Core
> YEP Selection Control

My issue is that the cursor becomes permanent when you hover over your targeted allies with a skill/item, as seen below. It works fine for enemies. I noticed someone else has made a thread about the same exact issue. Also, I am aware that Yanfly has their own battle cursor plugin, but I prefer the look and feel of Moghunter's, not to mention that I can't select targets with left or right arrow keys for Yanfly's, so I'm reluctant to swap plugins.

mog.jpg

I've attached the cursor plugin and images (img/system) for your convenience. Thanks in advance.

BattleCursor_A.png BattleCursor_B.png
Hello @zaraku,
Did you fix the problem?
I have the same

Thanks
Hello @zaraku,
Did you fix the problem?
I have the same

Thanks
Unfortunately no, I decided to just use Yanfly's cursors. I tried to mimic Mog's cursors the best I can:

Spoiler
Yj0PQYa.png

aYjNcOg.png
Ok thanks
Here's a start (just know that I am not a developer). I'm sure there is a less convoluted way to fix this. For whatever reason, yanfly's plugin commandeers the battleenemy window for BOTH actors and enemies, which is where the compatibilities clash. None of the battleactor functions get used from mog.

First of all, you need to add the MOG arrow clearing code to ok/cancel for skills and items since it's not doing it automatically. I just added it to the 4 Scene_battle functions at the bottom of targetcore:
Code:
Yanfly.Target.Scene_Battle_onEnemyOk = Scene_Battle.prototype.onEnemyOk;
Scene_Battle.prototype.onEnemyOk = function() {
    BattleManager.clearCustomTargetSelectGroup();
    Yanfly.Target.Scene_Battle_onEnemyOk.call(this);
    $gameTemp._arrowAllTargets[1] = false;
    for (var i = 0; i < $gameParty.members().length; i++) {$gameParty.members()[i]._arrowVisible = false; };
    
};

Yanfly.Target.Scene_Battle_onEnemyCancel = Scene_Battle.prototype.onEnemyCancel;
Scene_Battle.prototype.onEnemyCancel = function() {
    BattleManager.clearCustomTargetSelectGroup();
    Yanfly.Target.Scene_Battle_onEnemyCancel.call(this);
    $gameTemp._arrowAllTargets[1] = false;
    for (var i = 0; i < $gameParty.members().length; i++) {$gameParty.members()[i]._arrowVisible = false; };
};

Yanfly.Target.Scene_Battle_onActorOk = Scene_Battle.prototype.onActorOk;
Scene_Battle.prototype.onActorOk = function() {
    BattleManager.clearCustomTargetSelectGroup();
    Yanfly.Target.Scene_Battle_onActorOk.call(this);
    $gameTemp._arrowAllTargets[1] = false;
    for (var i = 0; i < $gameParty.members().length; i++) {$gameParty.members()[i]._arrowVisible = false; };
};

Yanfly.Target.Scene_Battle_onActorCancel = Scene_Battle.prototype.onActorCancel;
Scene_Battle.prototype.onActorCancel = function() {
    BattleManager.clearCustomTargetSelectGroup();
    Yanfly.Target.Scene_Battle_onActorCancel.call(this);
    $gameTemp._arrowAllTargets[1] = false;
    for (var i = 0; i < $gameParty.members().length; i++) {$gameParty.members()[i]._arrowVisible = false; };
};

Secondly, you need to edit the processcursormove in MOG's plugin because it's not clearing after every move. Also, again, it applies to both actors and enemies now.
Code:
var _alias_mog_bcursor_wbeny_processCursorMove = Window_BattleEnemy.prototype.processCursorMove;
Window_BattleEnemy.prototype.processCursorMove = function() {
     if (!this._window_mode && this.isCursorMovable()) {
        
        var lastIndex = this.index();    
        if (Input.isRepeated('down')) {this.addIndex(1)};
        if (Input.isRepeated('up')) {this.addIndex(-1)};
        if (Input.isRepeated('right')) {this.addIndex(1)};
        if (Input.isRepeated('left')) {this.addIndex(-1)}; 
        var newindex = this.index();
        if (this.index() !== lastIndex) {
            SoundManager.playCursor();
            //---------------------------------- changed
            for (var i = 0; i < ($gameParty.members().length); i++) {$gameParty.members()[i]._arrowVisible = false; } 
            if (this.enemy().isActor()) {
                this._enemies[newindex]._arrowVisible = true; 
            }
            //------------------------------------
        };
        return;
     };
     
     _alias_mog_bcursor_wbeny_processCursorMove.call(this);
};

Hopefully this helps someone get started on a fix. The only issue left is that if you use an item that targets all allies, it doesn't clear the blinking white flash on actors. I can't find whatever makes that effect.
Thank you for the nearly perfect solution, @shukiri.
If anybody is still looking for a solution - the answer of shukiri only misses 1 line for each of the functions in the Target Core Plugin.

It has to be like this to work:
JavaScript:
//=============================================================================
// Scene_Battle
//=============================================================================

Yanfly.Target.Scene_Battle_onEnemyOk = Scene_Battle.prototype.onEnemyOk;
Scene_Battle.prototype.onEnemyOk = function() {
    BattleManager.clearCustomTargetSelectGroup();
    Yanfly.Target.Scene_Battle_onEnemyOk.call(this);
    $gameTemp._arrowAllTargets[1] = false;
    for (var i = 0; i < $gameParty.members().length; i++) {
        $gameParty.members()[i]._arrowVisible = false;
        $gameParty.members()[i]._selected = false;
    };
};

Yanfly.Target.Scene_Battle_onEnemyCancel = Scene_Battle.prototype.onEnemyCancel;
Scene_Battle.prototype.onEnemyCancel = function() {
    BattleManager.clearCustomTargetSelectGroup();
    Yanfly.Target.Scene_Battle_onEnemyCancel.call(this);
    $gameTemp._arrowAllTargets[1] = false;
    for (var i = 0; i < $gameParty.members().length; i++){
        $gameParty.members()[i]._arrowVisible = false;
        $gameParty.members()[i]._selected = false;
    };
};

Yanfly.Target.Scene_Battle_onActorOk = Scene_Battle.prototype.onActorOk;
Scene_Battle.prototype.onActorOk = function() {
    BattleManager.clearCustomTargetSelectGroup();
    Yanfly.Target.Scene_Battle_onActorOk.call(this);
    $gameTemp._arrowAllTargets[1] = false;
    for (var i = 0; i < $gameParty.members().length; i++) {
        $gameParty.members()[i]._arrowVisible = false;
        $gameParty.members()[i]._selected = false;
    };
};

Yanfly.Target.Scene_Battle_onActorCancel = Scene_Battle.prototype.onActorCancel;
Scene_Battle.prototype.onActorCancel = function() {
    BattleManager.clearCustomTargetSelectGroup();
    Yanfly.Target.Scene_Battle_onActorCancel.call(this);
    $gameTemp._arrowAllTargets[1] = false;
    for (var i = 0; i < $gameParty.members().length; i++) {
        $gameParty.members()[i]._arrowVisible = false;
        $gameParty.members()[i]._selected = false;
    };
};

Original thread: https://forums.rpgmakerweb.com/threads/moghunter-battle-cursor-yanfly-selection-control-compatibility.104714/