RMMV Custom Enemy Status Window and refreshing/updating

JUICY_PINEFIELDS

はい!
Member
Joined
Jan 7, 2019
Messages
8
Reaction score
2
First Language
English
Primarily Uses
RMMV
Apologizes in advance if this is a really, really silly thing to ask a question about. I've only seen one other post with a similar issue to this (here) but I didn't want to necrobump it.

I made a custom enemy status window that works similar to the one for the actor, but I've been having trouble with achieving the effect that I want.
I would like for the HP gauge to update similar to the actors. Example being if the actor got hit, it would show the gauge depleting immediately, expected behavior. For the enemy status it only shows changes upon the next turn, when the actor command window shows up. This isn't the behavior I want.
Here is the code for the enemy window and battle scene respectively:

JavaScript:
//-----------------------------------------------------------------------------
// Window_BattleStatusEnemy
//
// The window for displaying the status of enemies on the battle screen.

function Window_BattleStatusEnemy() {
this.initialize.apply(this, arguments);
}

Window_BattleStatusEnemy.prototype = Object.create(Window_Selectable.prototype);
Window_BattleStatusEnemy.prototype.constructor = Window_BattleStatusEnemy;

Window_BattleStatusEnemy.prototype.initialize = function() {
var width = this.windowWidth();
var height = this.windowHeight();
var x = Graphics.boxWidth - width - 10;
var y = 10;
Window_Selectable.prototype.initialize.call(this, x, y, width, height);
this.refresh();
this.openness = 0;
};

Window_BattleStatusEnemy.prototype.windowWidth = function() {
return Graphics.boxWidth - 192;
};

Window_BattleStatusEnemy.prototype.windowHeight = function() {
return 130;
};

Window_BattleStatusEnemy.prototype.numVisibleRows = function() {
return 1;
};
Window_BattleStatusEnemy.prototype.standardFontSize = function() {
return 28;
};
Window_BattleStatusEnemy.prototype.maxItems = function() {
return $gameTroop.members().length;
};

Window_BattleStatusEnemy.prototype.refresh = function() {
this.contents.clear();
this.drawAllItems();
};

Window_BattleStatusEnemy.prototype.drawItem = function(index) {
var actor = $gameTroop.members()[index];
this.drawBasicArea(this.basicAreaRect(index), actor);
this.drawGaugeArea(this.gaugeAreaRect(index), actor);
};

Window_BattleStatusEnemy.prototype.basicAreaRect = function(index) {
var rect = this.itemRectForText(index);
rect.width -= this.gaugeAreaWidth() + 15;
return rect;
};

Window_BattleStatusEnemy.prototype.gaugeAreaRect = function(index) {
var rect = this.itemRectForText(index);
rect.x += rect.width - this.gaugeAreaWidth();
rect.y = 25;
rect.width = this.gaugeAreaWidth();
return rect;
};

Window_BattleStatusEnemy.prototype.gaugeAreaWidth = function() {
return 330;
};

Window_BattleStatusEnemy.prototype.drawBasicArea = function(rect, actor) {
this.drawActorName(actor, rect.x + 0, rect.y, 150);
};

Window_BattleStatusEnemy.prototype.drawGaugeArea = function(rect, actor) {
if ($dataSystem.optDisplayTp) {
this.drawGaugeAreaWithTp(rect, actor);
} else {
this.drawGaugeAreaWithoutTp(rect, actor);
}
};

Window_BattleStatusEnemy.prototype.drawGaugeAreaWithTp = function(rect, actor) {
this.drawActorHp(actor, rect.x + 0, rect.y, 108);
this.drawActorMp(actor, rect.x + 123, rect.y, 96);
this.drawActorTp(actor, rect.x + 234, rect.y, 96);
};

Window_BattleStatusEnemy.prototype.drawGaugeAreaWithoutTp = function(rect, actor) {
this.drawActorHp(actor, rect.x + 0, rect.y, 201);
this.drawActorMp(actor, rect.x + 216, rect.y, 114);
};

JavaScript:
//-----------------------------------------------------------------------------
// Scene_Battle
//
// The scene class of the battle screen.

function Scene_Battle() {
this.initialize.apply(this, arguments);
}

...

Scene_Battle.prototype.updateStatusWindow = function() {
if ($gameMessage.isBusy()) {
this._statusWindow.close();
this._statusWindowEnemy.close();
this._partyCommandWindow.close();
this._actorCommandWindow.close();
} else if (this.isActive() && !this._messageWindow.isClosing()) {
this._statusWindow.open();
this._statusWindowEnemy.open();
}
};

...

Scene_Battle.prototype.createAllWindows = function() {
this.createLogWindow();
this.createStatusWindow();
this.createStatusWindowEnemy();
this.createPartyCommandWindow();
this.createActorCommandWindow();
this.createHelpWindow();
this.createSkillWindow();
this.createItemWindow();
this.createActorWindow();
this.createEnemyWindow();
this.createMessageWindow();
this.createScrollTextWindow();
};

...

Scene_Battle.prototype.createStatusWindow = function() {
this._statusWindow = new Window_BattleStatus();
this.addWindow(this._statusWindow);

};

Scene_Battle.prototype.createStatusWindowEnemy = function() {
this._statusWindowEnemy = new Window_BattleStatusEnemy();
this.addWindow(this._statusWindowEnemy);
}

...

Scene_Battle.prototype.refreshStatus = function() {
this._statusWindowEnemy.refresh();
this._statusWindow.refresh();
};


I have tried editing rpg_managers to see if I could get it to work the way I intended:

JavaScript:
//-----------------------------------------------------------------------------
// BattleManager
//
// The static class that manages battle progress.

function BattleManager() {
throw new Error('This is a static class');
}

BattleManager.setup = function(troopId, canEscape, canLose) {
this.initMembers();
this._canEscape = canEscape;
this._canLose = canLose;
$gameTroop.setup(troopId);
$gameScreen.onBattleStart();
this.makeEscapeRatio();
};

BattleManager.initMembers = function() {
...
this._statusWindow = null;
this._statusWindowEnemy = null;
...
};

...

BattleManager.setStatusWindow = function(statusWindow) {
this._statusWindow = statusWindow;
};

BattleManager.setStatusWindowEnemy = function(statusWindowEnemy) {
this._statusWindowEnemy = statusWindowEnemy;
};

...

BattleManager.refreshStatus = function() {
this._statusWindowEnemy.refresh()
this._statusWindow.refresh() ;
};

but upon selecting an attack I get this error:

Code:
rpg_managers.js:1958 TypeError: Cannot read property 'refresh' of null
at Function.BattleManager.refreshStatus (rpg_managers.js:2421)
at Function.BattleManager.startAction (rpg_managers.js:2530)
at Function.BattleManager.processTurn (rpg_managers.js:2452)
at Function.BattleManager.updateTurn (rpg_managers.js:2440)
at Function.BattleManager.update (rpg_managers.js:2264)
at Scene_Battle.updateBattleProcess (rpg_scenes.js:2290)
at Scene_Battle.update (rpg_scenes.js:2282)
at Function.SceneManager.updateScene (rpg_managers.js:2033)
at Function.SceneManager.updateMain (rpg_managers.js:1992)

I know I'm doing something horribly dumb and wrong here lol, though if it's already defined as = null like the normal status window shouldn't it work the same? I've also tried other combinations like changing = (statusWindowEnemy) to just = (statusWindow) in rpg_managers but still the same problem.

I would have tried something like HUD Maker and see if it did what I want, but I wanted something lowkey as this game will be on mobile systems and didn't want too much plugins loading.
Also quick apology (again) if the code looks like doodoo I'm learning ever so slowly.
 
Last edited:

Latest Threads

Latest Profile Posts

KenKrath wrote on RPGMakerWeb's profile.
Nevermind.
I found a book about game localization. It costs R$708,00 on Amazon. ;_;
I really wish my game was far enough along for it to be actually playable beyond certain aspects. I think I've crafted a really fun battle system thanks to ATB, fighting game, and Boost point mechanics.
Play test of my current progress on Happy Camper
Cutscene Contest Winners have been announced!

Forum statistics

Threads
109,113
Messages
1,042,201
Members
141,612
Latest member
mhayes
Top