Lecode.S_TBS.RTPUse.oldTBSEntitySprite_processBitmapsConfig = TBSEntity_Sprite.prototype.processBitmapsConfig;
TBSEntity_Sprite.prototype.processBitmapsConfig = function (poseConfig, hue) {
var pose = poseConfig.pose;
var data = poseConfig.data;
var battler = this._entity.battler();
if (data.match(/use_chara/)) {
this._useFrameOrder[pose] = true;
this._poses.push(pose);
var array = data.split(",");
// DrQ: Actors still use params, if they have them
var charaName = (battler.isActor() && !array[1]) ? battler.characterName() : array[1].trim();
var fullBitmap = ImageManager.loadCharacter(charaName, hue);
fullBitmap.addLoadListener(this.createCharaBitmap.bind(this, fullBitmap, array, pose));
return;
}
Lecode.S_TBS.RTPUse.oldTBSEntitySprite_processBitmapsConfig.call(this, poseConfig, hue);
};
TBSEntity_Sprite.prototype.createCharaBitmap = function (fbitmap, array, pose) {
var battler = this._entity.battler();
// DrQ: Actors still use params, if they have them
var charaIndex = (battler.isActor() && !array[2]) ? battler.characterIndex() : Number(array[2].trim());
var lineIndex = array[3] ? Number(array[3].trim()) : undefined;
var frameIndex = array[4] ? Number(array[4].trim()) : undefined;
//var bitmap = new Bitmap(48 * 3, 48 * 4);
var pw = fbitmap.width / 4;
var ph = fbitmap.height / 2;
var bitmap = new Bitmap(pw, ph);
var n = charaIndex;
var sx = (n % 4) * pw;
var sy = Math.floor(n / 4) * ph;
bitmap.blt(fbitmap, sx, sy, pw, ph, 0, 0);
if (lineIndex >= 0) {
ph /= 4;
sy = lineIndex * ph;
if (frameIndex >= 0) {
pw /= 3;
sx = frameIndex * pw;
//var newBmp = new Bitmap(48, 48);
var newBmp = new Bitmap(pw, ph);
newBmp.blt(bitmap, sx, sy, pw, ph, 0, 0);
this._bitmaps[pose] = newBmp;
this._maxFrame[pose] = 0;
this._nbrLines[pose] = 1;
} else {
//var newBmp = new Bitmap(48 * 3, 48);
var newBmp = new Bitmap(pw, ph);
newBmp.blt(bitmap, 0, sy, pw, ph, 0, 0);
this._bitmaps[pose] = newBmp;
this._maxFrame[pose] = 2;
this._nbrLines[pose] = 1;
}
} else {
this._maxFrame[pose] = 2;
this._nbrLines[pose] = 4;
this._bitmaps[pose] = bitmap;
}
this._frameLoaded++;
};