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...