MZ Visustella Conditional Face Status UPDATED



Change actor's face image in main menu depending on condition, such as less than full health.
Plugin Required: Visustella Main Menu Core
Updated to support both Face Sets and Bust Portraits(if actor has no bust portrait set, face set will be used).

Prepare: Images
Spoiler: Set of Images
1667637161724.png

1667658645693.png

Have the original 'healthy' face images.. make a copy and add '_damage' to the file name.
Edit the images to represent damaged, etc.

Navigate to the Plugin Manager(F10).
VisuMZ_1_MainMenuCore >
1667637435887.png

Double-click on List Style Settings
1667637608204.png

Double-click on the style(s) you want to use and replace corresponding code section.

Find the section
Code:
// Draw Actor Graphic
Replace only that section with:
Spoiler: DEFAULT
Code:
// Draw Actor Graphic
const gx = rect.x + (this.graphicType() === 'face' ? 1 : 0);
const gy = rect.y + (this.graphicType() === 'face' ? 1 : 0);
const gw = Math.min(rect.width, ImageManager.faceWidth);
const gh = Math.min(rect.height, ImageManager.faceHeight);
const portraitName = actor._menuImage.replace('_damage', '');
const faceImage = actor._faceName.replace('_damage', '');
if (actor.hp !== actor.mhp) {
    if (actor.getMenuImage() !== '') {
    actor._menuImage = portraitName + "_damage";
    }
    actor._faceName = faceImage + "_damage"
}
else {
    if (actor.getMenuImage() !== '') {
    actor._menuImage = portraitName;
    }
    actor._faceName = faceImage;
}
this.drawActorGraphic(actor, gx, gy, gw, gh);

Do NOT replace anything after
Code:
// Draw Status Stuff
Spoiler: VERTICAL
Code:
// Draw Actor Graphic
const gw = rect.width;
const gh = Math.min(rect.height, ImageManager.faceHeight);
const gx = rect.x;
const gy = Math.max(rect.y, rect.y + (rect.height - totalHeight - gh) / 2);
const portraitName = actor._menuImage.replace('_damage', '');
const faceImage = actor._faceName.replace('_damage', '');
if (actor.hp !== actor.mhp) {
    if (actor.getMenuImage() !== '') {
    actor._menuImage = portraitName + "_damage";
    }
    actor._faceName = faceImage + "_damage"
}
else {
    if (actor.getMenuImage() !== '') {
    actor._menuImage = portraitName;
    }
    actor._faceName = faceImage;
}
this.drawActorGraphic(actor, gx, gy, gw, gh);

Do NOT replace anything after
Code:
// Draw Actor Name
Spoiler: PORTRAIT
Code:
// Draw Actor Graphic
const gw = rect.width;
const gh = rect.height;
const gx = rect.x;
const gy = rect.y;
const portraitName = actor._menuImage.replace('_damage', '');
const faceImage = actor._faceName.replace('_damage', '');
if (actor.hp !== actor.mhp) {
    if (actor.getMenuImage() !== '') {
    actor._menuImage = portraitName + "_damage";
    }
    actor._faceName = faceImage + "_damage"
}
else {
    if (actor.getMenuImage() !== '') {
    actor._menuImage = portraitName;
    }
    actor._faceName = faceImage;
}
if (actor.getMenuImage() !== '') {
    this.drawItemActorMenuImage(actor, rect.x, rect.y, rect.width, rect.height);
}
else {
this.drawActorGraphic(actor, gx, gy, gw, gh);
}

Do NOT replace anything after
Code:
// Draw Dark Rectangle
Spoiler: SOLO
Code:
// Draw Actor Graphic
let sx = rect.x;
let sy = rect.y;
let sw = rect.width;
let sh = rect.height;
const portraitName = actor._menuImage.replace('_damage', '');
const faceImage = actor._faceName.replace('_damage', '');
if (actor.hp !== actor.mhp) {
    if (actor.getMenuImage() !== '') {
    actor._menuImage = portraitName + "_damage";
    }
    actor._faceName = faceImage + "_damage"
}
else {
    if (actor.getMenuImage() !== '') {
    actor._menuImage = portraitName;
    }
    actor._faceName = faceImage;
}

// Portrait
if (actor.getMenuImage() !== '') {
    this.drawItemActorMenuImage(actor, rect.x, rect.y, rect.width, rect.height);

// Everything Else
} else {
    const gx = Math.max(0, rect.x + Math.floor(((rect.width / 2) - ImageManager.faceWidth) / 2));
    const gy = Math.max(0, rect.y + rect.height - Math.ceil(lineHeight * 4.5) - ImageManager.faceHeight);
    this.drawActorGraphic(actor, gx, gy, ImageManager.faceWidth, ImageManager.faceHeight);
}

Do NOT replace anything after
Code:
// Draw Dark Rectangle
Spoiler: THIN
Code:
// Draw Actor Graphic
const gx = rect.x + (this.graphicType() === 'face' ? 1 : 0);
const gy = rect.y + (this.graphicType() === 'face' ? 1 : 0);
const gw = Math.min(rect.width, ImageManager.faceWidth);
const gh = Math.min(rect.height, ImageManager.faceHeight);
const portraitName = actor._menuImage.replace('_damage', '');
const faceImage = actor._faceName.replace('_damage', '');
if (actor.hp !== actor.mhp) {
    if (actor.getMenuImage() !== '') {
    actor._menuImage = portraitName + "_damage";
    }
    actor._faceName = faceImage + "_damage"
}
else {
    if (actor.getMenuImage() !== '') {
    actor._menuImage = portraitName;
    }
    actor._faceName = faceImage;
}
this.drawActorGraphic(actor, gx, gy, gw, gh);

Do NOT replace anything after
Code:
// Draw Status Stuff
Spoiler: THICKER
Code:
// Draw Actor Graphic
const gx = rect.x + (this.graphicType() === 'face' ? 1 : 0);
const gy = rect.y + (this.graphicType() === 'face' ? 1 : 0);
const gw = Math.min(rect.width, ImageManager.faceWidth);
const gh = Math.min(rect.height, ImageManager.faceHeight);
const portraitName = actor._menuImage.replace('_damage', '');
const faceImage = actor._faceName.replace('_damage', '');
if (actor.hp !== actor.mhp) {
    if (actor.getMenuImage() !== '') {
    actor._menuImage = portraitName + "_damage";
    }
    actor._faceName = faceImage + "_damage"
}
else {
    if (actor.getMenuImage() !== '') {
    actor._menuImage = portraitName;
    }
    actor._faceName = faceImage;
}
this.drawActorGraphic(actor, gx, gy, gw, gh);

Do NOT replace anything after
Code:
// Draw Status Stuff

Save all changes and test.
adjust the condition which will change the image.
Examples:
Code:
actor.hp !== actor.mhp // Not at full health.
actor.hp <= actor.mhp * 0.2 // 20% of max health.
Hi there, it is so helpful! Thank you so much and really appreciate that. I have a question though. Is there a way to remove the help window in the status screen?
And is image changing possible to only apply to one actor but not all the actors?

Original thread: https://forums.rpgmakerweb.com/threads/visustella-conditional-face-status-updated.152474/