That's what happens if you guess with code: programming needs a methodical and precise approach.
setBrightness does not exist on the core Sprite_Enemy, and if it did then based on that name I'd expect it to be a function ("do a thing"), not a value ("store a thing").
- Your formula is incorrect: the denominator should be +1, not -1. To see why, consider a few
_effectDuration values, e.g. 10 or 1: what's the result?
Suggestion (untested):
JavaScript:
Sprite_Enemy.prototype.updateCollapse = function() {
const d = this._effectDuration;
if (!this._colorFilter) // color filter uses lazy-init
this._createColorFilter();
this._colorFilter.uniforms.brightness *= d / (d + 1); // linear dim
this.blendMode = 1; // additive blend mode
};
(Enemy sprites don't usually change their brightness, so more code may be necessary to catch all cases, e.g. if the enemy is revived.)
I suggest you also add a header to the top of the plugin, e.g.
JavaScript:
/*:
* @target MZ
* @plugindesc A different collapse effect!
* @author author
* @url https://forums.rpgmakerweb.com/threads/176841/
* @help Terms of use, helpful info, etc.
*/
The
@target MZ directive suppresses the "this plugin may not be written for MZ" warning in the Plugin Manager. The rest is just nice to have~
I was trying to use minus thinking it'd start from 255 and minus it down to zero or something.. i don't know how this stuff works.. i'm not a coder, but i hate asking for plugins.. i try my hardest to figure things out on my own..
Also, there's a reason there's no header.. it's not on it's own.. i have several things in a single plugin doing different things separately. I like keeping things more organized, rather than having these little plugins cluttering the list for every little thing i'm changing.
Spoiler: This is several modifications to different things
Code:
/*:
* @target MZ
* @plugindesc adds many needed customizations to project.
*/
//Actor Command adjustments
(alias => {
Scene_Battle.prototype.actorCommandWindowRect = function() {
const rect = alias.apply(this, arguments);
//rect.height = 216;
//rect.width = 192;
rect.x = 312;
rect.y = 517;
return rect;
};
})(Scene_Battle.prototype.actorCommandWindowRect);
//Party Command adjustments
(alias => {
Scene_Battle.prototype.partyCommandWindowRect = function() {
const rect = alias.apply(this, arguments);
//rect.height = 216;
//rect.width = 192;
rect.x = 312;
rect.y = 517;
return rect;
};
})(Scene_Battle.prototype.actorCommandWindowRect);
//Sets Battle background to scale of screen
Sprite_Battleback.prototype.adjustPosition = function() {
this.width = Graphics.width;
this.height = Graphics.height;
this.x = 0;
if ($gameSystem.isSideView()) {
this.y = 0;
}
const ratioX = this.width / this.bitmap.width;
const ratioY = this.height / this.bitmap.height;
const scale = Math.max(ratioX, ratioY, 1.0);
this.scale.x = scale;
this.scale.y = scale;
};
//Set's battler speed
Sprite_Actor.prototype.motionSpeed = function() {
return 7; // default 12
};
//Removes rectangles in menus
Window_Selectable.prototype.drawItemBackground = function(index) {
};
//Custom popup font size!
Sprite_Damage.prototype.fontSize = function() {
return $gameSystem.mainFontSize(); // <- edit this line
};
//Change options window position and size
Scene_Options.prototype.optionsWindowRect = function() {
const n = Math.min(this.maxCommands(), this.maxVisibleCommands());
const ww = 500;
const wh = 400;
const wx = (Graphics.boxWidth - ww) / 2;
const wy = (Graphics.boxHeight - wh) / 2;
return new Rectangle(wx, wy, ww, wh);
};
//Adjust enemy collapse effect
Sprite_Enemy.prototype.startCollapse = function() {
this._effectDuration = 29;
this._appeared = false;
};
Sprite_Enemy.prototype.updateCollapse = function() {
this.opacity *= this._effectDuration / (this._effectDuration + 1);
this.setColorTone([89, 0, 71, 255]);
this.blendMode = 1;
//this.setBlendColor([0, 0, 0, 255]);
};
//Weapons animation adjustments
Sprite_Weapon.prototype.updateFrame = function() {
if (this._weaponImageId > 0) {
const index = (this._weaponImageId - 1) % 12;
const w = 96;
const h = 96;
const sx = (Math.floor(index / 6) * 3 + this._pattern) * w;
const sy = Math.floor(index % 6) * h;
this.setFrame(sx, sy, w, h);
} else {
this.setFrame(0, 0, 0, 0);
}
};
Sprite_Weapon.prototype.initMembers = function() {
this._weaponImageId = 0;
this._animationCount = 0;
this._pattern = 0;
this.anchor.x = 0.5;
this.anchor.y = 0.7;
this.scale.x *= 3;
this.scale.y *= 3;
this.x = -16;
this.y = -32;
};
Sprite_Weapon.prototype.animationWait = function() {
return 8;
};
I didn't see a point in a bunch of tiny plugins cluttering things.
Thankfully though, they don't interfere with each other.
And that which you sent works.
I was replicating some old snes RPG Death animations by way of this.
The way the snes works, is it would use something similar to blend mode 1 and rather than turning something transarent, it'd just slowly turn it black.. and because of how the hardware does transparencies it gives a unique look... doing it with just turning something totally transparent looks a bit different.
Turning it black with the blend 1 replicates this effect perfectly.
I just wanted to replicate how monsters fade out in RPG Tsukuru Super Dante on the super famicom/nintendo.