TBS Engine Design: Cursor

Instead of traditional battles, I want my RPG to center around larger-scale turn-based battles similar to the ones found in the Romance of the Three Kingdoms series: that is, party members commanding units with several hundred soldiers.

I have a fairly solid roadmap for how I want to approach the mechanics, but I'm still uncertain as to how to set up everything for player input.

The first thing I need to do is set up the 'grid' for handling selecting and moving units: my initial idea was to use a window, but this would only work if the map fit within a single screen. Is there a better way to do this?
I am struggling to see how this is a query for Learning Javascript as you have not mentioned anything about developing a plugin. How are you thinking of approaching this?
Part of the problem is that I'm not exactly sure on the best way to approach it...

The goal is to have directional inputs move a cursor around the battlefield on a grid, rather than moving the player actor.

My initial thought had been to use a window roughly like the one described below:
Code:
function Scene_StrategicBase() { this.initialize.apply(this, arguments); };
Scene_StrategicBase.prototype = Object.create(Scene_Base.prototype);
Scene_StrategicBase.constructor = Scene_StrategicBase;

Scene_StrategicBase.prototype.initialize = function(fieldMap) {
    Scene_Base.prototype.initialize.call(this);
    this._fieldMap = fieldMap;
    this._enemyList = [];
    this._playerUnits = [];
    this._gridWindow = new Window_GridOverlay();
    this.addChild(this._gridWindow);
    //Some code would go here to link Scene_StrategicBase._fieldMap to the new Window_GridOverlay
}; 

Function Window_GridOverlay() { this.initialize.apply(this, arguments);};
Window_GridOverlay.prototype = Object.create(Window_Selectable.prototype);

Window_GridOverlay.prototype.initialize = function() {
   Window_Selectable.prototype.initialize.call(this, 0, 0, Graphics.boxWidth, Graphics.boxHeight);
};

Window_GridOverlay.prototype.maxRows = function() {
   return Math.floor(Graphics.boxHeight / 48);
};

Window_GridOverlay.prototype.maxCols = function() {
   return Math.floor(Graphics.boxWidth/48);
};

Window_GridOverlay.prototype.maxItems = function() {
  return this.maxCols() * this.maxRows();
};

Window_GridOverlay.prototype.itemWidth = function() {
   return 48;
};

Window_GridOverlay.prototype.itemHeight = function() {
   return 48;
};

Window_GridOverlay.prototype.standardBackOpacity = function() {
   return 0;
};

There are two problems in doing this:
1) if the map the battle is taking place on is larger than a single screen, this set-up won't work.
2) I'm unsure of how to go about linking the window to the contents on the map 'behind' it, or if it even can.

I'm also fairly certain that there is a better way to go about doing this in Javascript, but since I don't have a complete knowledge of the Javascript RPG maker uses to run I thought I'd ask.
That makes more sense now, so I'll leave this thread where it is.
After a few days of trying to use a menu to handle the grid, it quickly became apparent that it was far from the best way to approach the situation.

It would be much more efficient to simply replace the player sprite with a cursor. This raises three questions:

1) Is the correct command for this $gameActors.actor(actorId).setCharacterActor ? If so, how do I get the actorId for the player?

2) How can I allow the player to move overtop NPC actors and move freely over terrain?

3) Which functions handle movement speed/animations? I want to have the cursor jump instantly to a cell when the player clicks on/walks to it. I'd also like to add a sound effect for both cases.
Yes the better approach would be to use a game character and add it to the map. Or use an existing game character that's already on the map ex; the player.

1. For the game player you can get it with the $gamePlayer variable. to change it's sprite use the "setImage" function.
2. Set the characters through value to true and you might want to set it's priority type to above or below (that affects it's sprites Z value)
3. There's a few of them, to move instantly you can use the "setPosition" function.
I recommend you look through the Game_CharacterBase class to see the available functions
I've run into issues regarding appropriate values for CharacterIndex for the 'Game_Character.prototype.setImage' function... Every attempt to set the values results in the character sprite vanishing.

CharacterName clearly deals with the .jpg file, and I had thought that CharacterIndex dealt with the smaller sprite set within the image file (since each sprite sheet has 8 different 'sets' on it), but attempts to use a variety of different values for this have failed.

EDIT: The issue was actually with the .jpg file; it was apparently a layering issue that I have since corrected.

I'm having further problems with movement being locked; I suspect this is owing to improperly extending Scene_Map.

The relevant code is below:
Spoiler: Code
Code:
/*----------------------------------------------------------------------------*
 * STRINGS *
/*----------------------------------------------------------------------------*/
//Data manager strings
var ENEMYUNITS = "$enemyUnits";
var ALLYUNITS = "$allyUnits";
var COMMANDERS = "$battleCommanders";
var EVENTS = "$stragicBattleEvents";
var CIRCS = "$circumstances";

//Fixed variables for circumstance types
var UNITPRESENT = "unitpresent";        //Specifies if a unit will appear.
var UNITNUMBER = "unitnumber";            //Specifies number of soldiers.
var UNITCOMMANDER = "unitcommander";     //Specifies who will command a unit.
var EVENTCIRCUMSTANCE = "eventcirc";        //Specifies if an event will be assigned.

//Fixed variables for event types
var TILEENTER = "tileEnter";            //Specifies an event that occurs with
var UNITACTION = "unitaction";            //Specifies an event that may occur when a unit does something.
var UNITDEATH = "unitdeath";
var SIDETROOPTOTALS = "trooptotal";        //Specifies an event that may occur


/*----------------------------------------------------------------------------*
* PLUGIN FUNCTIONS *
/*----------------------------------------------------------------------------*/
Game_Interpreter.prototype.pluginCommand = (function (original) {
    "use strict";
    function pluginCommand(command, args) {
        original.call(this, command, args);
        if (command !== "StrategicBattle") {
            return;
        }
        switch (args[0]) {
            case "start":
                //Set the static variable to the current battle name for ease of use.
                var currentBattle = args[1];
                loadStratData(currentBattle);
            
                //Create the scene.
                break;
            case "end":
                //Offload JSON data.
               clearStratData();
                break;
            case "debug":
                //Special testing case.
                SceneManager.push(Scene_StrategicBase);
        break;
            default:
                break;
            }
    }
    return pluginCommand;
}(Game_Interpreter.prototype.pluginCommand));

function loadStratData(currentBattle) {
    //Load data for enemy units (Commander, troop type and #, position
    DataManager.loadDataFile(ENEMYUNITS, currentBattle+ "/enemyUnits.json");
    //Load data for friendly units (Commander, troop type and #, position
    DataManager.loadDataFile(ALLYUNITS, currentBattle + "/alliedUnits.json");
    //Load commanders to be assigned to units.
    DataManager.loadDataFile(COMMANDERS, currentBattle + "/commanders.json");
    //Load special events that take place during the battle.
    DataManager.loadDataFile(EVENTS, currentBattle + "/events.json");
    //Load special triggers that determine certain starting conditions and whether events take place.
    DataManager.loadDataFile(CIRCS, currentBattle + "/battleCircumstances");
}

function clearStratData() {
    DataManager[ENEMYUNITS] = null;
    DataManager[ALLYUNITS] = null;
    DataManager[COMMANDERS] = null;
    DataManager[EVENTS] = null;
    DataManager[CIRCS] = null;
}

/*----------------------------------------------------------------------------*
* Game_Party edits *
/*----------------------------------------------------------------------------*/

//Add fields to Game_Party on initialization.
Game_Party.prototype.initialize =  (function (original) {
    "use strict";
    function initialize() {
        original.call(this);
        this._playerUnits = [];
        this._soldierCount = 0;
    }
    return initialize;
}(Game_Party.prototype.initialize));

Game_Party.prototype.addSoldiers = function(soldNum) {
    this._soldierCount += soldNum;
};

Game_Party.prototype.removeSoldiers = function(soldNum) {
    this._soldierCount -= soldNum;
    if (this._soldierCount < 0) this._soldierCount = 0;
};
 
/*----------------------------------------------------------------------------*
* BASE SCENE *
/*----------------------------------------------------------------------------*/
function Scene_StrategicBase() { this.initialize.apply(this, arguments); }
Scene_StrategicBase.prototype = Object.create(Scene_Map.prototype);
Scene_StrategicBase.constructor = Scene_StrategicBase;

Scene_StrategicBase.prototype.initialize = function() {
    Scene_Map.prototype.initialize.call(this);
    this._fieldMap = null;
    this._enemyList = [];
    this._playerUnits = $gameParty.$playerUnits;
    this.canGab = (Window_Gab.prototype);
    this._previousCharName = $gamePlayer.characterName();
    this._previousCharIndex = $gamePlayer.characterIndex();
    $gamePlayer.setImage('Cursors', this._previousCharIndex);
 
};

Because I'm still trying to get the basic functionality set up, the stuff relating to loading JSON data isn't being used yet; the current PluginCommand is using the 'Debug' case for simplicity of testing.

EDIT 2: Additionally, the new sprite now shows up consistently, but only after waiting 2-4 seconds following it vanishing. Is there a way to rectify this?

EDIT 3: A lot of the above issues seem to have been related to trying to start the game and immediately load the plugin. I've since re-arranged it so that the player starts on a different map and activates the event on warping to the new one.
This has resulted in the map strobing in and out of view if Scene_StrategicBase extends from Scene_Map, and an immediate cut to black if it extends from Scene_Base. However, the sprite change happens as-expected. I suspect this is because of Scene_Push activating before the map has loaded properly.

EDIT 4: I tried setting the scene change to 'on player touch' and the same cut to black happens...

Original thread: https://forums.rpgmakerweb.com/threads/tbs-engine-design-cursor.83389/