Sprite Effects No Longer Working for Actors. Need help.

sleepy_sealion

Need to work harder!
Veteran
Joined
Jan 4, 2018
Messages
241
Reaction score
365
First Language
English
Primarily Uses
RMVXA
Hello, my stomach is literally sick from trying to fix it and not being able to step back. But I was recreating a script that I had because I felt it got too complicated. And one of the things on that script, was giving the players sprites "sprite effects" looted from the enemy sprite scripts.

In the original script - it mostly works (except for the whiten effect) but for some reason, putting it in a clean project, causes it to not work anymore?

Code:
//-------------------------------------------------------------------------------------
//Actor Sprite Effects
//--------------------------------------------------------------------------------------
Game_Actor.prototype.performDamage = function() {
    Game_Battler.prototype.performDamage.call(this);
    SoundManager.playEnemyDamage();
    this.requestEffect('blink');
};

const spriteActorInitSpriteEffects = Sprite_Actor.prototype.initMembers;
Sprite_Actor.prototype.initMembers = function() {
    this._effectType = null;
    this._effectDuration = 0;
    spriteActorInitSpriteEffects.call(this)
};

Sprite_Actor.prototype.initVisibility = function() {
    this._appeared = this._actor.isAlive();
    if (!this._appeared) {
        this.opacity = 0;
    }
};

Sprite_Actor.prototype.setupEffect = function() {
    if (this._appeared && this._actor.isEffectRequested()) {
        this.startEffect(this._actor.effectType());
        this._actor.clearEffect();
    }
    if (!this._appeared && this._actor.isAlive()) {
        this.startEffect('appear');
    } else if (this._appeared && this._actor.isHidden()) {
        this.startEffect('disappear');
    }
};

Sprite_Actor.prototype.startEffect = function(effectType) {
    this._effectType = effectType;
    switch (this._effectType) {
    case 'appear':
        this.startAppear();
        break;
    case 'disappear':
        this.startDisappear();
        break;
    case 'whiten':
        this.startWhiten();
        break;
    case 'blink':
        this.startBlink();
        break;
    case 'collapse':
        this.startCollapse();
        break;
    case 'bossCollapse':
        this.startBossCollapse();
        break;
    case 'instantCollapse':
        this.startInstantCollapse();
        break;
    }
    this.revertToNormal();
};

Sprite_Actor.prototype.startAppear = function() {
    this._effectDuration = 16;
    this._appeared = true;
};

Sprite_Actor.prototype.startDisappear = function() {
    this._effectDuration = 32;
    this._appeared = false;
};

Sprite_Actor.prototype.startWhiten = function() {
    this._effectDuration = 16;
};

Sprite_Actor.prototype.startBlink = function() {
    this._effectDuration = 20;
};

Sprite_Actor.prototype.startCollapse = function() {
    this._effectDuration = 32;
    this._appeared = false;
};

Sprite_Actor.prototype.startBossCollapse = function() {
    this._effectDuration = this.bitmap.height;
    this._appeared = false;
};

Sprite_Actor.prototype.startInstantCollapse = function() {
    this._effectDuration = 16;
    this._appeared = false;
};

Sprite_Actor.prototype.updateEffect = function() {
    this.setupEffect();
    if (this._effectDuration > 0) {
        this._effectDuration--;
        switch (this._effectType) {
        case 'whiten':
            this.updateWhiten();
            break;
        case 'blink':
            this.updateBlink();
            break;
        case 'appear':
            this.updateAppear();
            break;
        case 'disappear':
            this.updateDisappear();
            break;
        case 'collapse':
            this.updateCollapse();
            break;
        case 'bossCollapse':
            this.updateBossCollapse();
            break;
        case 'instantCollapse':
            this.updateInstantCollapse();
            break;
        }
        if (this._effectDuration === 0) {
            this._effectType = null;
        }
    }
};

Sprite_Actor.prototype.isEffecting = function() {
    return this._effectType !== null;
};

Sprite_Actor.prototype.revertToNormal = function() {
    this._shake = 0;
    this.blendMode = 0;
    this.opacity = 255;
    this.setBlendColor([0, 0, 0, 0]);
};

Sprite_Actor.prototype.updateWhiten = function() {

    var alpha = 128 - (16 - this._effectDuration) * 10;
    this.setBlendColor([255, 255, 255, alpha]);
    if (this._effectDuration < 8) {
    this._homeX += 1};
    if (this._effectDuration >= 8) {
    this._homeX -= 1};
    
};

Sprite_Actor.prototype.updateBlink = function() {
    this.opacity = (this._effectDuration % 10 < 5) ? 255 : 0;
    if (this._effectDuration < 8) {
    this._homeX -= 1};
    if (this._effectDuration >= 8) {
    this._homeX += 1};
};

Sprite_Actor.prototype.updateAppear = function() {
    this.opacity = (16 - this._effectDuration) * 16;
};

Sprite_Actor.prototype.updateDisappear = function() {
    this.opacity = 256 - (32 - this._effectDuration) * 10;
};

Sprite_Actor.prototype.updateCollapse = function() {
    this.blendMode = Graphics.BLEND_ADD;
    this.setBlendColor([255, 128, 128, 128]);
    this.opacity *= this._effectDuration / (this._effectDuration + 1);
};

Sprite_Actor.prototype.updateBossCollapse = function() {
    this._shake = this._effectDuration % 2 * 4 - 2;
    this.blendMode = Graphics.BLEND_ADD;
    this.opacity *= this._effectDuration / (this._effectDuration + 1);
    this.setBlendColor([255, 255, 255, 255 - this.opacity]);
    if (this._effectDuration % 20 === 19) {
        SoundManager.playBossCollapse2();
    }
};

It's driving me nuts, because I don't understand what the other script does - that this one isn't doing. I know it's a long read but if anyone can help me make sense of what's going on I'd really appreciate it.
 

sleepy_sealion

Need to work harder!
Veteran
Joined
Jan 4, 2018
Messages
241
Reaction score
365
First Language
English
Primarily Uses
RMVXA
It's not an error which is the confusing bit. The sprite effects just don't play anymore for the actors.
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
2,613
Reaction score
3,788
First Language
English
Primarily Uses
RMMV
It could be many things. It could be that it is dependent on another script that isn't in the new project, or it could be because of different core script/plugins versions, etc. Those kind of bugs are really hard to pinpoint since it isn't giving you an error you can work with. To fix those kind of bugs I usually go into the code and insert a bunch of console.log() to see what part of the code is getting executed and what parts of the code isn't getting executed properly.
 

sleepy_sealion

Need to work harder!
Veteran
Joined
Jan 4, 2018
Messages
241
Reaction score
365
First Language
English
Primarily Uses
RMVXA
I can give console logging a try. Though I've never really done it before.
 

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

Latest Threads

Latest Profile Posts

My plan after learning to make my voice girly "Wow! You sounds cute!" "But actually I'm a man!" "Nooooo!!!" hehehe...
I get haunted from bugs that emit a terrible stench after being killed.
At first, I was going to put player objectives on the screen labeling it as "Helpful voices"... But that's dumb, I have a madness system. It will simply whisper objectives.... I mean they're probably objectives. The voices wouldn't lie right? They're friendly, and ...helpful. So clearly you should do what they say. Just watch the dark corners of your screen for advice and it will all work out! :LZSexcite:
Take care of your immune system: Go to sleep. If you looked at the clock an hour ago or four and it was way late then maybe now is the time. Mmm sleep...

Forum statistics

Threads
95,667
Messages
930,913
Members
126,005
Latest member
Rbennin
Top