Anyone

Veteran
Veteran
Joined
Aug 24, 2019
Messages
279
Reaction score
382
First Language
German
Primarily Uses
RMMV
I've been at this for probably over 10 hours and still have no idea why this isn't working, so I figure I could use some help from a more experienced coder.

The idea:
I'm trying to get the blink function in Moghunter's ActorPictureCM to work. This will by default, ever now and then, overlay the Actor Bust on the combat screen with a second picture to create the illusion that the character is blinking.

I managed to get it to work thorugh a couple of changes (such as fixing the width to not be width /2, which caused the overlay to bounce around instead of being displayed on top of the bust).

However, I've my mind set on not just having a single closed-eye picture, but of having two in a 1-2-1 rotation:
eyes half-closed -> eyes closed -> eyes half closed
That way, the blink is more fluid. For the number of frames each phase takes, I've ursurped (this._eyesData.speed and introduced this._eyesData.phase in order to be able to recognize which phase the blinking process is in)

The issue:
Unfortunately, it doesn't work. Depending on what max phase I set, I can either have one or the other eye picture shown throughout the entire process, never switch between them during a blink.

The code for the blinking:
Code:
//==============================
// * update Blink
//==============================
Actor_CMPicture.prototype.updateBlink = function() {
    if (this._eyesData.duration <= 0) {
        this._eyesData.speed++;

//If phase still underway, return without doing anything
        if (this._eyesData.speed <= this._eyesData.motionM) {return}

//If speed > motionM
        this._eyesData.speed = 0;
        this._eyesData.index++;
        this._eyesData.phase++;

//BLINK END===If the final index has been reached and the function needs to reset the duration
        if (this._eyesData.phase > 2) {
            this._eyesData.index = -1;
            this._eyesData.phase = 0;
            this._eyesData.duration = Math.randomInt(160) + this._eyesData.blinkD;
        };

//SWITCHING TO EYES2===if the mid-blink phase is reached, will switch image
            if (this._eyesData.phase == 2) {
            this._eyes_closed = 1;
            this.forceBlinkImageChange();
            this.refreshFrame(this._eyes,this._eyesData.index);
        }

//SWITCHING BACK TO EYES==ends the mid blink phase
        else if (this._eyesData.phase == 3) {
            this._eyes_closed = 0;        
            this.forceBlinkImageChange();
            this.refreshFrame(this._eyes,this._eyesData.index);
        }

//Normal Refresh period
        else {
        this.refreshFrame(this._eyes,this._eyesData.index);
    }
     } else {
        this._eyesData.duration--;
     }
};

The blinking code, heavily commented / + lots of console.logs, looks like this:
Code:
//==============================
// * update Blink
//==============================
Actor_CMPicture.prototype.updateBlink = function() {
    if (this._eyesData.duration <= 0) {
        this._eyesData.speed++;

//If phase still underway, return without doing anything
        if (this._eyesData.speed <= this._eyesData.motionM) {return}

        this._eyesData.speed = 0;
        this._eyesData.index++;
        this._eyesData.phase++;

//BLINK END===If the final index has been reached and the function needs to reset the duration
        if (this._eyesData.phase > 2) {
            this._eyesData.index = -1;
            this._eyesData.phase = 0;
            this._eyesData.duration = Math.randomInt(160) + this._eyesData.blinkD;
        };

//SWITCHING TO EYES2===if the mid-blink phase is reached, will switch image
            if (this._eyesData.phase == 2) {
            this._eyes_closed = 1;
            this.forceBlinkImageChange();
            this.refreshFrame(this._eyes,this._eyesData.index);
        }

//SWITCHING BACK TO EYES==ends the mid blink phase
        else if (this._eyesData.phase == 3) {
            this._eyes_closed = 0;         
            this.forceBlinkImageChange();
            this.refreshFrame(this._eyes,this._eyesData.index);
        }

//Normal Refresh period
        else {
        this.refreshFrame(this._eyes,this._eyesData.index);
    }
     } else {
        this._eyesData.duration--;
     }
};
I've made a function that forces the image change that is referred to by forceBlinkImageChange():
Code:
//==============================
// * Force Blink Image Change
//==============================

Actor_CMPicture.prototype.forceBlinkImageChange = function() {
    if (this._eyes_closed) {
        var fileName = this.fileName() + "_eyes2";
        this._eyes.bitmap = ImageManager.loadActorpicCM(fileName);
        this._eyes_closed = 0;
        this._eyes.visible = true;
    } else {
        var fileName = this.fileName() + "_eyes";
        this._eyes.bitmap = ImageManager.loadActorpicCM(fileName);
        this._eyes.visible = true;
    }
};

After which, I refresh the frame:
Code:
//==============================
// * refresh Frame
//==============================
Actor_CMPicture.prototype.refreshFrame = function(sprite,index) {
    var cw = this._eyesData.cw;
    var ch = this._eyesData.ch;
    var fr = cw * index;
    sprite.setFrame(fr,0,cw,ch)
};

But somehow I get the feeling the refresh frame might not actually update the image every time it's called. Even when the frame should be refreshed, it actually isn't.

Problem Demo:
This is a build, containing the modified plugin with everything set up:
https://www.mediafire.com/file/94dzbkpgafokxh9/ActorCMBlink.rar/file

Currently, there's an alert command in the refresh Frame function so that the program stops and allows a glimpse of the face, because otherwise it's hard to see exactly what happens & doesn't happen.

Inside the plugin folder, you'll find a backup of the modded and of the original plugin by moghunter, that's otherwise only available here:
https://atelierrgss.wordpress.com/rmv-actor-picture-cm/
(As part of a demo containing all his scripts)

Note that setting line 660
Code:
if (this._eyesData.phase > 3) {
to
Code:
if (this._eyesData.phase > 2) {

forces the script to end at phase 2 (the closed eyes) which as a result only shows the closed eyes, but not the half-closed eyes. (Hard to spot without using an alert that stops the script temporarily).

It seems like the blinking function doesn't allow updating of pictures while its running and only goes with whatever came last. Maybe something else updates the eyes picture?

I'd really appreciate it if someone more experienced can take a look and tell me where I'm wrong.

EDIT: Removed the console logs & alerts from the code and instead put that version into a spoiler to make the code clearer.
 
Last edited:

Latest Threads

Latest Profile Posts

x5uDBb.png


Big update incoming tomorrow! After some streamer feedback I am adding and recreating multiple facets of the game! Expect:

  • New Challenge Modes!
  • Completely revamped stats and attack types!
  • Additional positioning options!
  • More hidden easter eggs, will you find them??
  • Additional balancing!
Quick little one day make. Having mimosas on a boat tomorrow but wanted to feel productive today. Ask me about my sunburn later.

GABposterwork.png

Working on a new poster.
I just posted the first devlog for The Hidden Art of Innkeeping: https://seaphoenix.itch.io/hiddenart!

BeachLogo.png
Might start playing some rpg maker games and uploading the games on youtube. Realistically they're not going to be for views. Just to give anyone some feedback on any games they're working on. So if you'd like me to play and review your game just reply them down here. And I'll upload them on Rpg4MGames.

Forum statistics

Threads
131,617
Messages
1,221,622
Members
173,346
Latest member
Hereticuss
Top