- Joined
- Jul 19, 2021
- Messages
- 186
- Reaction score
- 302
- First Language
- English
- Primarily Uses
- RMMZ
I can't figure out how to fix this.
I've put together an 'alpha' version of my Turn Priority Window. The core mechanics of it work, but after awhile it's going to get laggy because the faces for one of the windows is not clearing and redrawing like it should, in fact it's just redrawing and not clearing lol. There are two windows, the Active Actor Window, which displays the actor that is currently able to select commands and the Turn Priority Window which displays the order of the remaining party members in which they can have a turn. The Turn Priority Window is the one that isn't clearing properly.
UpdateTpbChargeTime (core file) Despite 'update' in it's name, it's not one of those "always running non stop" updates. It's up to 2-3 times during charging phase. It doesn't run when a player's turn bar is full.
Update function. "always running for as long as the scene its window is in is active." In this case Scene Battle.
Refresh and Redraw. I probably could just have Redraw do its thing and then draw the faces and do away with refresh.
SortBattlersByChargeTime.
DrawFaceByTurn
I am almost certain it has to do with the way all the faces are being drawn, but I don't know another way of displaying them the way I want.
I've put together an 'alpha' version of my Turn Priority Window. The core mechanics of it work, but after awhile it's going to get laggy because the faces for one of the windows is not clearing and redrawing like it should, in fact it's just redrawing and not clearing lol. There are two windows, the Active Actor Window, which displays the actor that is currently able to select commands and the Turn Priority Window which displays the order of the remaining party members in which they can have a turn. The Turn Priority Window is the one that isn't clearing properly.
UpdateTpbChargeTime (core file) Despite 'update' in it's name, it's not one of those "always running non stop" updates. It's up to 2-3 times during charging phase. It doesn't run when a player's turn bar is full.
JavaScript:
Game_Battler.prototype.updateTpbChargeTime = function() {
if (this._tpbState === "charging") {
// how fast the turn bar fills is determined by the acceleration rate
this._tpbChargeTime += this.tpbAcceleration();
if (this._tpbChargeTime >= 1) {
// When someone's turn is up, tell the TP Window to redraw the faces for the new order.
ChargeTracker._hasUpdatedCharge = true;
this._tpbChargeTime = 1;
this.onTpbCharged();
}
}
};
Update function. "always running for as long as the scene its window is in is active." In this case Scene Battle.
JavaScript:
TurnPriorityWindow.prototype.update = function() {
Window_Base.prototype.update.call(this)
if (this._drawOnce === false) {
// draw the initial order of faces at the start of battle(when the Fight/Escape command window appears)
this.drawFacesByTurn();
this._drawOnce = true
} else if (ChargeTracker._hasUpdatedCharge === true) {
/* This is set to true every time Game_Battler.updatetpbChargeTime is called
by a character who's turn is up. Choosing to guard always invokes this.
It's suppose to clear the window of the previous faces and then
draw the faces that reflect the new turn order.
*/
this.refresh()
// This is suppose to prevent unecessary redrawing.
ChargeTracker._hasUpdatedCharge = false
};
};
Refresh and Redraw. I probably could just have Redraw do its thing and then draw the faces and do away with refresh.
JavaScript:
TurnPriorityWindow.prototype.refresh = function() {
this.redraw();
this.drawFacesByTurn();
};
TurnPriorityWindow.prototype.redraw = function() {
// property has the TP Window Rect stored to it.
const TurnWindow = this._redrawWindow
this.contents.clearRect(TurnWindow.x, TurnWindow.y,
TurnWindow.width, TurnWindow.height)
};
SortBattlersByChargeTime.
JavaScript:
TurnPriorityWindow.prototype.sortBattlersByChargeTime = function() {
/* Order all actor faces by the current charge time of their respective
actors. The charge time is actually the fill percentage of their turn
bars. Order is from largest to smallest. Largest = actor nearing their turn.
*/
const party = $gameParty.members();
let sortByChargeTime = [];
for (let i = 0; i < party.length; i++) {
/* Sorting the party array directly will cause the order to be static(never changing)
in the turn priority window for some reason.
Add only actors who's turn progress bar is not 100%(otherwise they would be in the Active Actor Window).
*/
if (party[i]._tpbState === "charging") {
sortByChargeTime.push(party[i]);
};
};
return sortByChargeTime.sort((a, b) => b._tpbChargeTime - a._tpbChargeTime);
};
DrawFaceByTurn
JavaScript:
// this is for actors in the Turn Priority Window.
TurnPriorityWindow.prototype.drawFacesByTurn = function() {
const actors = this.sortBattlersByChargeTime();
// this is the x position
let pos = 0;
for (let i = 0; i < actors.length; i++) {
// faces are scaled down 24x24 (drawFace function had to be changed to allow this)
this.drawFace(actors[i].faceName(), actors[i].faceIndex(), pos, 0, 144, 144, 24, 24);
pos += 24
};
};
I am almost certain it has to do with the way all the faces are being drawn, but I don't know another way of displaying them the way I want.