MV Looking for some help with a Moghunter plugin

Hello! So I'd like to preface this by bringing up the plugin in question, Moghunter's Battle Hud. Generally, it works perfectly for what I am going for however with a glaring issue, being the images used for each actor.

One mechanic I am planning on including involves having the lead player character's design changing depending on their class; however the issue generally lays in how Moghunter's Battle Hud contains no script calls or plugin commands for changing the images used for an actor. Part of this is likely because it seems to operate more so on the corresponding ID used for said actor, but I'm curious to see if there are any solutions to this that I should look into. Perhaps if there is a similar script out there that can achieve a similar effect to Moghunter's Battle Hud, as well as the desired commands, that could be worth it. Or if there's anything I could use outside of that, that would be cool too! Either way, I'd appreciate some insight on the matter.
One mechanic I am planning on including involves having the lead player character's design changing depending on their class; however the issue generally lays in how Moghunter's Battle Hud contains no script calls or plugin commands for changing the images used for an actor. Part of this is likely because it seems to operate more so on the corresponding ID used for said actor
Why would the battle hud need to have functions to change actor images? how are you changing classes right now and can you not change the images there? if thered be a place to change an actor's images when their class is changed, itd be when their class is changed.
Why would the battle hud need to have functions to change actor images? how are you changing classes right now and can you not change the images there? if thered be a place to change an actor's images when their class is changed, itd be when their class is changed.
I probably should have clarified, the image file used for the actors in question exists outside of the standard default actor images used in MV itself. I went and took a screenshot from the Moghunter demo project and circled what I was referring to in red to provide a better idea of what I was talking about.

demonstration.png


The image files themselves are taken from a sprite sheet found in img/battlehud, and typically are named "Face_[actor ID]". These images are what I'm wanting to look into finding a method of changing depending on changes bought to a party member through the events of the game itself.

As for the class changing, while I can just use the typical RPG Maker command for that, I also want to bring in a separate class leveling system akin to Xenoblade Chronicles 3. I already know a few plugins that accomplish this idea, however since Moghunter's plugins often operate within their own image folders and just are generally separate from other plugins I do not see any class changing plugins being able to change the image files used for an actor with the battle hud unless maybe if they were specifically made to do just that. But at the end of the day, I'm not particularly an expert on the specifics here, this is just what I understand from my own outside perspective here.
I probably should have clarified, the image file used for the actors in question exists outside of the standard default actor images used in MV itself. I went and took a screenshot from the Moghunter demo project and circled what I was referring to in red to provide a better idea of what I was talking about.
ah. that makes much more sense then

As for the class changing, while I can just use the typical RPG Maker command for that, I also want to bring in a separate class leveling system akin to Xenoblade Chronicles 3. I already know a few plugins that accomplish this idea, however since Moghunter's plugins often operate within their own image folders and just are generally separate from other plugins I do not see any class changing plugins being able to change the image files used for an actor with the battle hud unless maybe if they were specifically made to do just that.
yeah, once youve decided on a class change plugin, at least one plugin will have to be patched. I see that the HUD plugin is hard coded to only look for the files by actor ID like you mentioned, so the simplest thing would be to have the HUD plugin be adjusted to look for files as [actor name] + [actor class name (or id)] instead of ["Face"] + [actor id]

if that sounds good enough, i can just give that to you
ah. that makes much more sense then


yeah, once youve decided on a class change plugin, at least one plugin will have to be patched. I see that the HUD plugin is hard coded to only look for the files by actor ID like you mentioned, so the simplest thing would be to have the HUD plugin be adjusted to look for files as [actor name] + [actor class name (or id)] instead of ["Face"] + [actor id]

if that sounds good enough, i can just give that to you
Yeah, I think Yanfly's Class Change Core seems to relatively pull off what I'd like to do for the class changing system.

As for modifying the plugin, you're free to go and do that if that's fine with you. I might end up taking notes on the changes between the original plugin and the modified one for future reference as well, in case if I ever want to get a similar effect with a different plugin.
Yeah, I think Yanfly's Class Change Core seems to relatively pull off what I'd like to do for the class changing system.
i had wrote needing to know what class change plugin you were using before i checked the mog hud. it can be made independent entirely. it doesnt actually write any data to the actors like i thought it did before your clarification, so the class change core doesnt need to be touched.

As for modifying the plugin, you're free to go and do that if that's fine with you. I might end up taking notes on the changes between the original plugin and the modified one for future reference as well, in case if I ever want to get a similar effect with a different plugin.
the change that has to be made is just an alteration of a single line in a single function. save this as a .js file, add it to your project as a plugin, and load it after the mog hud plugin.

Code:
Battle_Hud.prototype.create_face = function() {
    if (String(Moghunter.bhud_face_visible) != "true") {return};
    this.removeChild(this._face);
    if (!this._battler) {return}; 
    this._face = new Sprite(ImageManager.loadBHud("Face_"+this._battler.actorId() +"-"+ this._battler.currentClass().id));
    this._face.anchor.x = 0.5;
    this._face.anchor.y = 0.5;
    this._face_data = [0,0,false,false,false,-1];
    this._face.ph = 0;
    this._face.animation = [-1,0,0,0,0,0,0,0,0];
    this._face.breathEffect = this._battler._bhud.faceBreath;
    this._face.scaleY = 0;
    if (String(Moghunter.bhud_face_shake) === "true") {this._face_data[2] = true}
    if (String(Moghunter.bhud_face_animated) === "true") {this._face_data[4] = true}
    this._battler._bhud_face_data = [0,0,0,1]
    this.addChild(this._face);
};

with that change, you want your files set up so that theyre named Face_[actor id]-[class id]
so Face_1-2, Face_3-5, etc
i had wrote needing to know what class change plugin you were using before i checked the mog hud. it can be made independent entirely. it doesnt actually write any data to the actors like i thought it did before your clarification, so the class change core doesnt need to be touched.


the change that has to be made is just an alteration of a single line in a single function. save this as a .js file, add it to your project as a plugin, and load it after the mog hud plugin.

Code:
Battle_Hud.prototype.create_face = function() {
    if (String(Moghunter.bhud_face_visible) != "true") {return};
    this.removeChild(this._face);
    if (!this._battler) {return};
    this._face = new Sprite(ImageManager.loadBHud("Face_"+this._battler.actorId() +"-"+ this._battler.currentClass().id));
    this._face.anchor.x = 0.5;
    this._face.anchor.y = 0.5;
    this._face_data = [0,0,false,false,false,-1];
    this._face.ph = 0;
    this._face.animation = [-1,0,0,0,0,0,0,0,0];
    this._face.breathEffect = this._battler._bhud.faceBreath;
    this._face.scaleY = 0;
    if (String(Moghunter.bhud_face_shake) === "true") {this._face_data[2] = true}
    if (String(Moghunter.bhud_face_animated) === "true") {this._face_data[4] = true}
    this._battler._bhud_face_data = [0,0,0,1]
    this.addChild(this._face);
};

with that change, you want your files set up so that theyre named Face_[actor id]-[class id]
so Face_1-2, Face_3-5, etc
Apologies for the late reply, I tried this out and it works perfectly!

I do want to ask though, I've been trying to replicate some modifications to allow for similar effects in some other Moghunter scripts, however I've found that the scripting is a bit different for a few of the ones that I've been working with. For instance, here's part of Moghunter's Battle Results plugin that I was trying to wrap my head around.

JavaScript:
//==============================
// * Create Actor Sprite
//==============================
BattleResult.prototype.createActorSprite = function() {
    var img = ImageManager.loadPicture("Actor_" + this._actor._actorId)
    this._spriteActor = new Sprite(img);
    this._spriteActor.opacity = 0;
    this._spriteActor.anchor.x = 0.5;
    this.addChild(this._spriteActor);
};

I've been trying different variations of what you put together in the other script, however I'm far from experienced with Javascript so there likely were numerous glaring flaws preventing things from working correctly with the methods I was using.
I've been trying different variations of what you put together in the other script, however I'm far from experienced with Javascript so there likely were numerous glaring flaws preventing things from working correctly with the methods I was using.
if you were unsure of where you went wrong, you could have posted some that you thought would have worked

the scripting is a bit different for a few of the ones that I've been working with. For instance, here's part of Moghunter's Battle Results plugin that I was trying to wrap my head around.
its actually mostly the same as the one before. it is still using ImageManager.loadXxx to create a bitmap and creates a new sprite out of it, but its been split into 2 lines, uses loadPicture instead of loadBHud, and has a different actor reference. if you aim to use loadPicture, the game is going to be looking for a file in the pictures folder named... something. otherwise, you could try using the same bhud files with the bhud function. The reference to the actor within the BattleResults looks to be this._actor instead of this._battler.

using the same convention, try
Code:
//==============================
// * Create Actor Sprite
//==============================
BattleResult.prototype.createActorSprite = function() {
    var img = ImageManager.loadPicture("Actor_" + this._actor.actorId() + "-" +this._actor.currentClass().id())
    this._spriteActor = new Sprite(img);
    this._spriteActor.opacity = 0;
    this._spriteActor.anchor.x = 0.5;
    this.addChild(this._spriteActor);
};
and itll be Actor_[actorId]-[classId] within the pictures folder. if you really wanted to, you could probably use the same bhud files you already have set up by using the bhud function and replacing the "Actor_" with "Face_"
if you were unsure of where you went wrong, you could have posted some that you thought would have worked


its actually mostly the same as the one before. it is still using ImageManager.loadXxx to create a bitmap and creates a new sprite out of it, but its been split into 2 lines, uses loadPicture instead of loadBHud, and has a different actor reference. if you aim to use loadPicture, the game is going to be looking for a file in the pictures folder named... something. otherwise, you could try using the same bhud files with the bhud function. The reference to the actor within the BattleResults looks to be this._actor instead of this._battler.

using the same convention, try
Code:
//==============================
// * Create Actor Sprite
//==============================
BattleResult.prototype.createActorSprite = function() {
    var img = ImageManager.loadPicture("Actor_" + this._actor.actorId() + "-" +this._actor.currentClass().id())
    this._spriteActor = new Sprite(img);
    this._spriteActor.opacity = 0;
    this._spriteActor.anchor.x = 0.5;
    this.addChild(this._spriteActor);
};
and itll be Actor_[actorId]-[classId] within the pictures folder. if you really wanted to, you could probably use the same bhud files you already have set up by using the bhud function and replacing the "Actor_" with "Face_"
Ah yeah, my apologies about not sharing what I had going before. I'm a little embarrassed about my attempts, though looking at the example you gave I think what I had going was somewhere along those lines, actually. Though that is to say that the results were about the same as when I tried it as well. I'll drop the error message that sprung up for me below.

error.png
I'll drop the error message that sprung up for me below.
ah. my bad there. remove the () at the end of this._actor.currentClass().id(). I accidentally slipped that in
ah. my bad there. remove the () at the end of this._actor.currentClass().id(). I accidentally slipped that in
Yeah, that fix seems to work well. I am curious though, one plugin that I am looking at at the moment, Moghunter's Ougi Animations plugin, seems to have an added part for when the images are used.

Code:
//==============================
// ** Create Ougi
//==============================
Scene_Battle.prototype.createOugi = function() {
    this._spriteOugi = [];
    if ($gameTemp._ougiData[1].isActor()) {
       this._spriteOugi[0] =  new Sprite(ImageManager.loadPicture("Actor_" + $gameTemp._ougiData[1]._actorId + $gameTemp._ougiData[4]));
       this._spriteOugi[1] =  new Sprite(ImageManager.loadPicture("ActorOugi_" + $gameTemp._ougiData[1]._actorId));
    } else {
       this._spriteOugi[0] =  new Sprite(ImageManager.loadPicture("Enemy_" + $gameTemp._ougiData[1]._enemyId + $gameTemp._ougiData[4]));
       this._spriteOugi[1] =  new Sprite(ImageManager.loadPicture("Enemy_" + $gameTemp._ougiData[1]._enemyId));
    };
    this._spriteOugi[0].anchor.x = 0.5;
    this._spriteOugi[0].anchor.y = 0.5;
    this._spriteOugi[0].opacity = 0;
    this.addChild(this._spriteOugi[0]);
    this._spriteOugi[1].anchor.x = 0.5;
    this._spriteOugi[1].opacity = 0;
    this.addChild(this._spriteOugi[1]);
    this._spriteOugi[2] = false
};

The modifications that I have been putting through have been more so along the lines of this;

Code:
//==============================
// ** Create Ougi
//==============================
Scene_Battle.prototype.createOugi = function() {
    this._spriteOugi = [];
    if ($gameTemp._ougiData[1].isActor()) {
       this._spriteOugi[0] =  new Sprite(ImageManager.loadPicture("Actor_" + $gameTemp._ougiData[1]._actorId() + $gameTemp._ougiData[4] +"-"+ this._actor.currentClass().id));
       this._spriteOugi[1] =  new Sprite(ImageManager.loadPicture("ActorOugi_" + $gameTemp._ougiData[1]._actorId() +"-"+ this._actor.currentClass().id));
    } else {
       this._spriteOugi[0] =  new Sprite(ImageManager.loadPicture("Enemy_" + $gameTemp._ougiData[1]._enemyId + $gameTemp._ougiData[4]));
       this._spriteOugi[1] =  new Sprite(ImageManager.loadPicture("Enemy_" + $gameTemp._ougiData[1]._enemyId));
    };
    this._spriteOugi[0].anchor.x = 0.5;
    this._spriteOugi[0].anchor.y = 0.5;
    this._spriteOugi[0].opacity = 0;
    this.addChild(this._spriteOugi[0]);
    this._spriteOugi[1].anchor.x = 0.5;
    this._spriteOugi[1].opacity = 0;
    this.addChild(this._spriteOugi[1]);
    this._spriteOugi[2] = false
};

And the last think I should bring up is the error message that pops up whenever I try to use the modified version of the plugin I've been trying to get working.

Code:
$gameTemp._ougiData[1]._actorId is not a function

Part of me believes that the issue could be the fact that there needs to be an addition to the whole "ougiData[number]" parts of the script, comparing the code used in this plugin to the other modified plugins shows that they're something of an outlier here, though I may be mistaken and the issue might have more to do with something else entirely.

I feel like it's also worth mentioning that the script was also slightly modified prior to this, just to change file names for the images used for the primary PNG used in front of the backdrop to be "ActorOugi_id" as opposed to just simply being the same "Actor_id" image that the victory screen would pull from. And that's not mentioning the background images which while I left the file names the same for them during my initial edit, they are still roughly similar to the change I made to the primary images I had been using, being "Actor_id_Ougi". I feel that it was different enough to not bring up any issues, however perhaps something went over my head in the process.

Apologies about the plethora of questions by the way, I genuinely am curious as to how this all works. I'm not the biggest on programming personally however this has provided an additional level of understanding for how javascript works with some of these plugins that I do find interesting, even if I don't know too much of what is going on.
Part of me believes that the issue could be the fact that there needs to be an addition to the whole "ougiData[number]" parts of the script, comparing the code used in this plugin to the other modified plugins shows that they're something of an outlier here, though I may be mistaken and the issue might have more to do with something else entirely.
this one is slightly different because of how the data is organized, but not by much.

the last think I should bring up is the error message that pops up whenever I try to use the modified version of the plugin I've been trying to get working.
When you share error messages, you want to show the error trace from the console tab of the devtools window. Press f12 while the game is open and it should bring it up. among other things, it tells you the exact line that generates the error and is more helpful than the default error massage the game generates.

Theres an immediate issue here that causes the error that you saw, and a second one that may or may not be lying in wait after you fix it. ill bring up both

The first one is exactly as the error says. for actors, _actorId() is not a function. the property is _actorId, and the function to get their id is actorId(). using either one works, but _actorId() doesnt exist. if you noticed, the code i gave you uses .actorId(), but moghunter's code usually uses ._actorId. in most circumstances the difference doesnt matter.

the second problem that may or may not be an issue...
if ($gameTemp._ougiData[1].isActor()) {
so, from this we know that ougiData is an array and index 1 is a battler. the original code never references an _actor, a _battler, or some other similar property in itself like the others did. it uses ougiData[1] instead. That combined with Scene_Battle not having those properties defined in the base code either means its likely the case that this._actor doesnt exist and youll get a crash the second your code gets to this._actor.currentClass().id from trying to read currentClass of undefined

if that happens, your next move is to change any any reference you make to this._actor to $gameTemp._ougiData[1] instead.

Original thread: https://forums.rpgmakerweb.com/threads/looking-for-some-help-with-a-moghunter-plugin.176760/