HUD Party member stats on screen

thalesgal

Veteran
Veteran
Joined
Dec 23, 2016
Messages
195
Reaction score
45
First Language
Portuguese
Primarily Uses
RMMV
Hello guys!
I found this plugin that @Trihan did for me, and I would like to change it to show the HP, MP, LV, and "to next level" gauges bars of the second member of the party. Yes, only the second member. (taking into account that the leader is the first member)

If I change the second member of the party, It would change the HP, MP and LV information to the other actor.

It´s possible?

Thanks in advance!!


Code:
//=============================================================================
// MapHUD.js
//=============================================================================

/*:
 * @plugindesc Simple HUD plugin for thalesgal.
 * @author John Clifford (Trihan)
 *
 * @param X
 * @desc The x coordinate of the window
 * @default 0
 *
 *
 * @param Y
 * @desc The y coordinate of the window
 * @default 0
 *
 * @help
 *
 * Just puts a HUD on the screen that shows the level/HP/MP of the party leader.
 *
 */

(function() {
    var parameters = PluginManager.parameters('MapHUD');
    
    function Window_HUD() {
        this.initialize.apply(this, arguments);
    }
    
    Window_HUD.prototype = Object.create(Window_Base.prototype);
    Window_HUD.prototype.constructor = Window_HUD;
    
    Window_HUD.prototype.initialize = function() {
        Window_Base.prototype.initialize.call(this, parameters['X'], parameters['Y'], 350, 150);
        this.opacity =0;
    };
    
    Window_HUD.prototype.update = function() {
        this.contents.clear();
        this.drawLeaderHUD();
    };
    
 Window_HUD.prototype.drawLeaderLevel = function(leader, x, y) {
        var color1 = this.hpGaugeColor1();
        var color2 = this.hpGaugeColor2();
        this.drawGauge(10, 0, 150, (leader.currentExp() - leader.expForLevel(leader._level)) / (leader.nextLevelExp() - leader.expForLevel(leader._level)), color1, color2);
        this.changeTextColor(this.systemColor());
        this.drawText("Lv", 10, 0, 20);
        this.resetTextColor();
        this.drawText(leader.level, 40, 0, 10, 'right');

    };
    
    Window_HUD.prototype.drawLeaderHUD = function() {
        var leader = $gameParty.members()[0];
        this.drawLeaderLevel(leader, 50, 0);
    this.opacity =0;
        this.drawActorHp(leader, 10, this.lineHeight(), 150);
        this.drawActorMp(leader, 10, this.lineHeight() * 2, 150);       
    };
    
    _Scene_Map_createAllWindows = Scene_Map.prototype.createAllWindows;
    Scene_Map.prototype.createAllWindows = function() {
        _Scene_Map_createAllWindows.call(this);
        this._hudWindow = new Window_HUD();
        this.addChild(this._hudWindow);
    };
        
})();
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,639
First Language
Czech
Primarily Uses
RMMV
Replace the 0 with 1 here:
var leader = $gameParty.members()[0];
 

thalesgal

Veteran
Veteran
Joined
Dec 23, 2016
Messages
195
Reaction score
45
First Language
Portuguese
Primarily Uses
RMMV
Hi! Thank you for reply!
It didn´t work :/

I think the problem is in it:
Code:
Window_HUD.prototype.drawLeaderHUD = function() {
        var leader = $gameParty.members()[0];
        this.drawLeaderLevel(leader, 50, 0);
    this.opacity =0;
        this.drawActorHp(leader, 10, this.lineHeight(), 150);
        this.drawActorMp(leader, 10, this.lineHeight() * 2, 150);
There are a lot of ''leader'' mentions, but I don´t know for what name I have to change.
Could you help me?

Thanks in advance!
 

thalesgal

Veteran
Veteran
Joined
Dec 23, 2016
Messages
195
Reaction score
45
First Language
Portuguese
Primarily Uses
RMMV
Up
Does anyone can help me with this please? :LZScheeze::LZScheeze:
 

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
399
Reaction score
221
First Language
English
Primarily Uses
RMMV
What @Poryg suggested should work. If it doesn't something else is causing a problem.

The word "leader" is being used because this is the name that was chosen for the variable. This line here defines the variable:

Code:
var leader = $gameParty.members()[0];
By changing this line to:

Code:
var leader = $gameParty.members()[1];
We are referencing the second member of the party, but the name of the variable stays the same. This variable could have been called almost anything and it would make no difference to how the plugin functioned, to change it now would be unnecessary.
 

thalesgal

Veteran
Veteran
Joined
Dec 23, 2016
Messages
195
Reaction score
45
First Language
Portuguese
Primarily Uses
RMMV
Thank you for the explanation. But it didn´t work:
error.jpg

I´m realy bad with code, even if it is something very easy to fix I probably would not see it at all.

Here is the whole script. I made the arrows where I changed to 1, and where the error "currentexp" is.
plugin error.jpg
 

CaRa_CrAzY

Undefined Custom Title
Veteran
Joined
Jan 19, 2019
Messages
65
Reaction score
27
First Language
Portuguese
Primarily Uses
Other
Are you testing the suggested changes while having a party without a second member?
If so, try this:
Code:
var leader = $gameParty.members()[1] || return;
You are getting an error at currentExp() because you don't have a character at slot 2 to be classified as a leader. Your error doesn't says currentExp() is undefined. It says leader is undefined thus it can't access a currentExp() from a non-existent object.
 
Last edited:

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,639
First Language
Czech
Primarily Uses
RMMV
The only reason why that could be is, your party is a size of one. Is that true?
Btw. Thanks for the mention, I didn't get an alert of a new message previously.
 

thalesgal

Veteran
Veteran
Joined
Dec 23, 2016
Messages
195
Reaction score
45
First Language
Portuguese
Primarily Uses
RMMV
@CaRa_CrAzY Thank you for your help!
When I put the ''return'' as you said the error message did not happen anymore.
But the HUD did not show up! Even with the [0] to show the leader, it did not appear anymore.

@CaRa_CrAzY , @Poryg
Yes! I was starting without a second party member! If I start the game with a second member, with this parameter
var leader = $gameParty.members()[1], it works nicely!
But, if I remove the second member it shows the "currentexp" message error again.

Could you guys help me? The ''Return'' didn´t work.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
[move]Javascript/Plugin Support[/move]
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,639
First Language
Czech
Primarily Uses
RMMV
And what exactly are you trying to achieve with the return?
 

CaRa_CrAzY

Undefined Custom Title
Veteran
Joined
Jan 19, 2019
Messages
65
Reaction score
27
First Language
Portuguese
Primarily Uses
Other
All right. In my arrogance I tried to write it just in one line, but it looks like it doesn't work that way in Javascript.
Anyways, I think this will do the trick. The method will run only if there is a second party member.

Code:
var leader = $gameParty.members()[1];
if(!leader) return;
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,574
Latest member
nikisknight
Top