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?
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.
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.