Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Tag enemies with <rainbow> to allow color hue cycleing in battle
- var RainbowHueInterval = 3;
- var RainbowHueStep = 2;
- var _Sprite_Enemy_update = Sprite_Enemy.prototype.update;
- Sprite_Enemy.prototype.update = function() {
- _Sprite_Enemy_update.call(this);
- if (this._enemy && this._enemy.isRainbowEnemy()) {
- if (!this._enemy._rainbowFrame) this._enemy._rainbowFrame = 0;
- this._enemy._rainbowFrame++;
- if (this._enemy._rainbowFrame >= RainbowHueInterval) {
- this._enemy._rainbowFrame = 0;
- this._enemy.testColor = (this._enemy.testColor + RainbowHueStep) % 360;
- this.setHue(this._enemy.testColor);
- }
- }
- };
- var _Game_Enemy_initMembers = Game_Enemy.prototype.initMembers;
- Game_Enemy.prototype.initMembers = function() {
- _Game_Enemy_initMembers.call(this);
- this.testColor = Math.randomInt(360);
- this._rainbowFrame = 0;
- };
- Game_Enemy.prototype.battlerHue = function() {
- return this.enemy().battlerHue;
- };
- Game_Enemy.prototype.isRainbowEnemy = function() {
- return !!$dataEnemies[this.enemy().id].meta.rainbow;
- };
- Sprite_Enemy.prototype.setHue = function(deg) {
- if (!this._rainbowColorMatrix) {
- if (PIXI && PIXI.filters && PIXI.filters.ColorMatrixFilter) {
- this._rainbowColorMatrix = new PIXI.filters.ColorMatrixFilter();
- var list = this.filters ? this.filters.slice() : [];
- list.push(this._rainbowColorMatrix);
- this.filters = list;
- } else {
- this._rainbowColorMatrix = null;
- }
- }
- if (this._rainbowColorMatrix) {
- this._rainbowColorMatrix.reset();
- this._rainbowColorMatrix.hue(deg, false);
- } else {
- var rad = deg * Math.PI / 180;
- var r = Math.round(60 * Math.sin(rad));
- var b = Math.round(60 * Math.cos(rad));
- this.setColorTone([ r, -r, b, 0 ]);
- }
- };
- Sprite_Enemy.prototype.clearRainbowHue = function() {
- if (this._rainbowColorMatrix) {
- var list = (this.filters || []).filter(f => f !== this._rainbowColorMatrix);
- this.filters = list.length ? list : null;
- this._rainbowColorMatrix = null;
- } else {
- this.setColorTone([0,0,0,0]);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment