Create a window in Battle Scene that show the player states

Juzkhain

Villager
Member
Joined
Jul 7, 2016
Messages
17
Reaction score
3
First Language
English
Primarily Uses
First of all I want to point out that the main reason I'm asking for this pluguin is because I'm trying to learn to code for RPG Maker MV.
I think I'know how to manipuilate the Menu to add and remove things, but in the Battle Scene I don't know how to mess with the HUD.

What I want is to create a window that displays the States that are afecting the main actor.
My idea is to have two tipes of States, ones that show in the Battle Status Window in the form of text, others that show in a window I want to create, one State above the other.
I've thought in identify them with note tags.

I've been studing the code up and down, but I can't find how the icons for the States are drawn.

I've thoght that If i had a code that creates a window that showed the States that would help me to better understand how States work in the code.

I'm under the impresion that windows in the Battle Scene work differently, I don't understand how they work.

If some one could recomend to me a good tutorial on the subject, that would be great.

Thank you very much to all the comunity.
 
Last edited:

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,254
Reaction score
1,254
First Language
Spanish
Primarily Uses
RMVXA
What I want is to create a window that displays the States that are afecting the main actor.
I've been studing the code up and down, but I can't find how the icons for the States are drawn.
it's not a window, it's a subprocess of the battle status window.
find window_battlestatus.drawitem()
each "item" is an actor, that serves as a pivot to bring name, health, and list of affected states.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,118
Reaction score
1,526
First Language
EN
Primarily Uses
RMMZ
If you're seeking to learn then this may be better off in Learning JavaScript? :kaoswt:

Basic directions:
  • For the icons, check rpg_windows.js. By default the state icons are drawn via the drawBasicArea method of Window_BattleStatus. This calls drawActorIcons, inherited from Window_Base. Use your text-editor's search function, it's very helpful! :D
  • The main flow of battle is handled by the BattleManager (cf rpg_managers.js); window selections etc are generally still handled by the scene, though.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,254
Reaction score
1,254
First Language
Spanish
Primarily Uses
RMVXA
This calls drawActorIcons
also, for the record, if you're looking for "states" and you can't find a function dealing with "states" or named "states", try "state", singular.
in this case, doing a search for "state" would have brought you to the iterator "state" within "stateIcons", from there to "drawActorIcons", to "window_battlestatus", which was your starting point.

if you don't find it directly, go reverse.
 

Juzkhain

Villager
Member
Joined
Jul 7, 2016
Messages
17
Reaction score
3
First Language
English
Primarily Uses
Thank you all, all your comments and suggestions are being very helpful. If I get to do the pluguin my self I will upload it here.

If you're seeking to learn then this may be better off in Learning JavaScript? :kaoswt:
Yeah, you are right, I was not sure were to post it, sorry .
 

Juzkhain

Villager
Member
Joined
Jul 7, 2016
Messages
17
Reaction score
3
First Language
English
Primarily Uses
Ok, so I was able to create a window on the Battle Scene and I can show the guages or delete them, and also I was able to make the Status Icons don't show on the Battle Status Window.

But for some reason I can't make the Actor Icons show in the window tha I've created.

Thank you all in any case.

Here is my code:

Code:
function Window_ActorState() {
    this.initialize.apply(this, arguments);
}

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

Window_ActorState.prototype.initialize = function() {
    var width = 800;
    var height = 200;
    var x = 0;
    var y = 0;
    Window_Selectable.prototype.initialize.call(this, x, y, width, height);
    this.refresh();
    this.openness = 0;
};

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

Window_ActorState.prototype.windowHeight = function() {
    return this.fittingHeight(this.numVisibleRows());
};

Window_ActorState.prototype.numVisibleRows = function() {
    return 4;
};

Window_ActorState.prototype.maxItems = function() {
    return $gameParty.battleMembers().length;
};

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

Window_ActorState.prototype.drawItem = function(index) {
    var actor = $gameParty.battleMembers()[index];
    this.drawBasicArea(this.basicAreaRect(index), actor);
  
};

Window_ActorState.prototype.basicAreaRect = function(index) {
    var rect = this.itemRectForText(index);
    rect.width -= 200;
    return rect;
};

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

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

Window_ActorState.prototype.drawBasicArea = function(rect, actor) {
    this.drawActorIcons(actor, rect.x + 156, rect.y, rect.width - 156);
};




//=========================================================================

var old_createAllWindows = Scene_Battle.prototype.createAllWindows
Scene_Battle.prototype.createAllWindows = function() {
    old_createAllWindows.call(this)
    this.createActorStateWindow();

};
Scene_Battle.prototype.createActorStateWindow = function() {
    this._actorStateWindow = new Window_ActorState();
    this.addWindow(this._actorStateWindow);
    this._actorStateWindow.open();
//sin esta línea no se abre la ventana
};



//=======================================================================

Window_BattleStatus.prototype.drawItem = function(index) {
    var actor = $gameParty.battleMembers()[index];
    this.drawGaugeArea(this.gaugeAreaRect(index), actor);
};
 

Juzkhain

Villager
Member
Joined
Jul 7, 2016
Messages
17
Reaction score
3
First Language
English
Primarily Uses
Ok, so I kinda figured it out.

I was not able to make the icons to show in the window I'va created, but I gave that window the propietis and functions of the Battle Status Window and left this one only for displaying the State Icons.
So now I have a window that displays de gauges and another taht displays the State Icons witch is pretty much what I intended.
The code:

Code:
function Window_ActorState() {
    this.initialize.apply(this, arguments);
}

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

Window_ActorState.prototype.initialize = function() {
    var width = 800;
    var height = 200;
    var x = 0;
    var y = 0;
    Window_Selectable.prototype.initialize.call(this, x, y, width, height);
    this.refresh();
    this.openness = 0;
};

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

Window_ActorState.prototype.windowHeight = function() {
    return this.fittingHeight(this.numVisibleRows());
};

Window_ActorState.prototype.numVisibleRows = function() {
    return 4;
};

Window_ActorState.prototype.maxItems = function() {
    return $gameParty.battleMembers().length;
};

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

Window_ActorState.prototype.drawItem = function(index) {
    var actor = $gameParty.battleMembers()[index];
    this.drawBasicArea(this.basicAreaRect(index), actor);
    this.drawGaugeArea(this.gaugeAreaRect(index), actor);
};

Window_ActorState.prototype.basicAreaRect = function(index) {
    var rect = this.itemRectForText(index);
    rect.width -= 200;
    return rect;
};

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

Window_ActorState.prototype.drawBasicArea = function(rect, actor) {
    this.drawActorIcons(actor, rect.x + 156, rect.y, rect.width - 156);
};

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

Window_ActorState.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_ActorState.prototype.drawGaugeAreaWithoutTp = function(rect, actor) {
    this.drawActorHp(actor, rect.x + 0, rect.y, 201);
    this.drawActorMp(actor, rect.x + 216,  rect.y, 114);
};




//=========================================================================

var old_createAllWindows = Scene_Battle.prototype.createAllWindows
Scene_Battle.prototype.createAllWindows = function() {
    old_createAllWindows.call(this)
    this.createActorStateWindow();

};
Scene_Battle.prototype.createActorStateWindow = function() {
    this._actorStateWindow = new Window_ActorState();
    this.addWindow(this._actorStateWindow);
    this._actorStateWindow.open();
//sin esta línea no se abre la ventana
};



//=======================================================================

Window_BattleStatus.prototype.drawItem = function(index) {
    var actor = $gameParty.battleMembers()[index];
    this.drawBasicArea(this.basicAreaRect(index), actor);
};

Window_BattleStatus.prototype.drawBasicArea = function(rect, actor) {
    this.drawActorIcons(actor, rect.x + 156, rect.y, rect.width - 156);
};
The next step is diferenciate two kinds of states, ones that show in the Battle Status window in the form of text and ones that show in the other in the form of icons.

Oh boy, this is going to be hard. But I was able to kind of figuire it out by my self, with the help of the community. I feel like I've learned a lot.
 

DarkHunter

Veteran
Veteran
Joined
Nov 9, 2017
Messages
92
Reaction score
70
First Language
English
Primarily Uses
RMMV
is this like FInal Fantasy IV after years? I'm looking for your plugin ^+^
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,049
Messages
1,018,546
Members
137,835
Latest member
yetisteven
Top