Hey, so I know that there is already a plugin with a similar goal (GALV's Character Frames). But I wanted to make my own to get it how I want it. But I'm kind of stuck. I tried a lot of different methods on transferring the info, and doing it with event tags 'seems' to work.
But the biggest hurdle that I think is stopping things short seems to be the
"Game_CharacterBase.prototype.updatePattern" function.
It never returns the if statement as 'true' so it just returns the else statement.
But idk it could be anything. Honestly at this point I'm just confused. I'm essentially on day 3 of working on this plugin, so my brain is kind of fried. So I figured some fresh eyes would help, especially since y'all are more experienced.
Here's the code.
But the biggest hurdle that I think is stopping things short seems to be the
"Game_CharacterBase.prototype.updatePattern" function.
It never returns the if statement as 'true' so it just returns the else statement.
But idk it could be anything. Honestly at this point I'm just confused. I'm essentially on day 3 of working on this plugin, so my brain is kind of fried. So I figured some fresh eyes would help, especially since y'all are more experienced.
Here's the code.
JavaScript:
/*:
* @plugindesc Plugin for reading sprites wih more than 3 frames.
* @author FarawayGoneaway
*/
///Hold frame information
Sprite_Character.prototype.frameSpecs = function () {
var character = this._character;
if (character && character.event) {
var event = character.event();
var note = event.note;
var moreFrames = /<MoreFrames:\s*(\d+)\s*(\d+)>/i;
var match = note.match(moreFrames);
if (match) {
var frames = Number(match[1]);
var frameSize = Number(match[2]);
return {
Frames: frames,
FrameSize: frameSize,
};
} else {
return 3;
}
} else {
return 3;
}
};
Game_CharacterBase.prototype.frameSpecs = function () {
if (this.event && this.event()) {
var event = this.event();
var note = event.note;
var moreFrames = /<MoreFrames:\s*(\d+)\s*(\d+)>/i;
var match = note.match(moreFrames);
if (match) {
var frames = Number(match[1]);
return frames;
} else {
return 3;
}
} else {
return 3;
}
};
///Calculate frame size
var _alias_Sprite_Character_patternWidth =
Sprite_Character.prototype.patternWidth;
Sprite_Character.prototype.patternWidth = function () {
if (this.bitmap && this.bitmap.isReady()) {
let FrameSpecs = this.frameSpecs();
if (FrameSpecs && FrameSpecs !== 3) {
let frameSize = FrameSpecs.FrameSize;
let calculation = this.bitmap.width / frameSize;
return calculation;
} else {
return _alias_Sprite_Character_patternWidth.call(this);
}
} else {
return _alias_Sprite_Character_patternWidth.call(this);
}
};
var _alias_Sprite_Character_patternHeight =
Sprite_Character.prototype.patternHeight;
Sprite_Character.prototype.patternHeight = function () {
if (this.bitmap && this.bitmap.isReady()) {
let FrameSpecs = this.frameSpecs();
if (FrameSpecs && FrameSpecs !== 3) {
let frameSize = FrameSpecs.FrameSize;
let calculation = this.bitmap.height / frameSize;
return calculation;
} else {
return _alias_Sprite_Character_patternHeight.call(this);
}
} else {
return _alias_Sprite_Character_patternHeight.call(this);
}
};
var _alias_Sprite_Character_characterPatternX =
Sprite_Character.prototype.characterPatternX;
Sprite_Character.prototype.characterPatternX = function () {
let FrameSpecs = this.frameSpecs();
if (FrameSpecs && FrameSpecs !== 3) {
return this._character.pattern();
} else {
return _alias_Sprite_Character_characterPatternX.call(this);
}
};
///Update spritesheet
var _alias_Game_CharacterBase_updatePattern =
Game_CharacterBase.prototype.updatePattern;
Game_CharacterBase.prototype.updatePattern = function () {
let FrameSpecs = this.frameSpecs();
if (FrameSpecs && FrameSpecs !== 3) {
var maxFrames = FrameSpecs;
this._pattern = (this._pattern + 1) % maxFrames;
} else {
return _alias_Game_CharacterBase_updatePattern.call(this);
}
};
var _alias_Sprite_Character_updateCharacterFrame =
Sprite_Character.prototype.updateCharacterFrame;
Sprite_Character.prototype.updateCharacterFrame = function () {
let FrameSpecs = this.frameSpecs();
if (FrameSpecs && FrameSpecs !== 3) {
var pw = this.patternWidth();
var ph = this.patternHeight();
var sx = (0 + this.characterPatternX()) * pw;
var sy = (0 + this.characterPatternY()) * ph;
this.setFrame(sx, sy, pw, ph);
} else if (FrameSpecs === 3) {
_alias_Sprite_Character_updateCharacterFrame.call(this);
}
};
})();