// 内容を描画する
Window_SrpgPrediction.prototype.drawContents = function() {
this.opacity = 0;
this.resetFontSettings();
var windowWidth = this.windowWidth(); //adjust height
var lineHeight = this.lineHeight();
var padding = 24;
var user = this._actionArray[1];
var target = this._targetArray[1];
// add background image 816 x 624 px located in system folder
this._background = new Sprite(ImageManager.loadSystem('prediction'));
this.addChildAt(this._background, 1);
this._background.anchor.x = 0.5;
this._background.anchor.y = 0.5;
this._background.x = Graphics.boxWidth / 2;
this._background.y = -86;
this._background.z = 1;
// draw user bust (right side) 300 x 300 px located in system folder
this._bust = new Sprite(ImageManager.loadSystem(user.name()));
this._bust.scale.x = -1;
this.addChildAt(this._bust, 1);
this._bust.anchor.x = 0.5;
this._bust.anchor.y = 1;
this._bust.x = Graphics.boxWidth * (10 / 12);
this._bust.y = Graphics.boxHeight - 624;
// draw target bust (left side) 300 x 300 px located in system folder
if(!target.isActor()) {
var loadBust = target.name();
this._bust2 = new Sprite(ImageManager.loadSystem(loadBust));
this._bust2.visible = true;
} else {
this._bust2 = new Sprite(ImageManager.loadSystem(target.name()));
if (user === target) { this._bust2.visible = false;}
this._bust2.scale.x = 1;
}
this.addChildAt(this._bust2, 1);
this._bust2.anchor.x = 0.5;
this._bust2.anchor.y = 1;
this._bust2.x = Graphics.boxWidth * (2 / 12);
this._bust2.y = Graphics.boxHeight - 624;
// attacker
var action = user.currentAction();
var damage = action.srpgPredictionDamage(target);
var hit = action.itemHit(target);
var eva = action.itemEva(target);
var cri = action.itemCri(user);
var xx = 96 ;
this.drawText('Action', orderX - 8, -8, iconBoxWidth * 2, 'center');
// draw name and action name
this.drawText(user.name(), windowWidth / 2 + 32, lineHeight * 0 - 4, windowWidth / 2, 'center');
this.drawSrpgBattleActionName(user, action, windowWidth / 2 + padding * 2 + xx, lineHeight * 1 - 8, true);
//this.drawSrpgBattleDistance(user, action, windowWidth / 2 + 172 + padding * 2, lineHeight * 3);
this.contents.fontSize = 20;
// draw damage hit crit
this.drawSrpgBattleDamage(damage, windowWidth / 2 + padding + 100 + xx, lineHeight * 3 + 4);
this.drawSrpgBattleHit(hit, eva, windowWidth / 2 + padding + 100 + xx, lineHeight * 4 - 6);
this.drawSrpgBattleCri(cri, windowWidth / 2 + padding + 100 + xx, lineHeight * 5 - 18);
// draw HP icon
this.drawIcon(13, windowWidth / 2 + 16 + 32 + xx, lineHeight * 2 + 2);
this.contents.fontSize = 40;
this.drawText(user.hp, windowWidth / 2 + 16 + 64 + xx, lineHeight * 2);
this.contents.fontSize = 16;
// check if double action is true and action used is normal attack
if (_srpgUseAgiAttackPlus == 'true' && target.agi > user.agi && user.attackSkillId() === action.item().id) {
var nowHp = user.hp - (2 * target.currentAction().srpgPredictionDamage(user));
} else {var nowHp = user.hp - target.currentAction().srpgPredictionDamage(user);}
// limit new HP to 0 and maxp HP
if (nowHp > user.mhp) { nowHp = user.mhp;
} else if (nowHp < 0) { nowHp = 0; }
var width = this.textWidth('00000');
this.drawText(nowHp, windowWidth / 2 + 160 + width + 16 + xx, lineHeight * 2 + 12);
this.resetFontSettings();
// draw HP gauge
var rate = nowHp / user.mhp;
this.drawGauge(windowWidth / 2 + 16 + 32 + xx, lineHeight * 2 + 12, windowWidth / 3 - 48, rate, this.hpGaugeColor1(), this.hpGaugeColor2());
// target
var reaction = target.currentAction();
// If the skill cannot be used or the attacker is unable to respond
if (reaction && (!target.canUse(reaction.item()) || user.currentAction().item().meta.srpgUncounterable)) {
reaction = null;
}
if (!reaction || user === target) {
this.drawSrpgBattleActionName(target, reaction, padding, lineHeight * 0, false);
} else {
var damage = reaction.srpgPredictionDamage(user);
var hit = reaction.itemHit(user);
var eva = reaction.itemEva(user);
var cri = reaction.itemCri(target);
// draw name and action name
this.drawText(target.name(),-64, lineHeight * 0 - 4,windowWidth / 2, 'center');
this.drawSrpgBattleActionName(target, reaction, padding + 32, lineHeight * 1 - 8, true);
//this.drawSrpgBattleDistance(target, reaction, 172 + padding, lineHeight * 1);
// draw damage hit crit
this.contents.fontSize = 20;
this.drawSrpgBattleDamage(damage, padding + 100, lineHeight * 3 + 4);
this.drawSrpgBattleHit(hit, eva, padding + 100, lineHeight * 4 - 6);
this.drawSrpgBattleCri(cri, padding + 100, lineHeight * 5 - 18);
// draw HP icon
this.drawIcon(13, padding + 36, lineHeight * 2 + 2);
this.contents.fontSize = 40;
this.drawText(target.hp, padding + 16 + 64, lineHeight * 2);
this.contents.fontSize = 16;
// check if double action is true and action used is normal attack
if (_srpgUseAgiAttackPlus == 'true' && user.agi > target.agi && target.attackSkillId() === action.item().id) {
var nowHp = target.hp - (2 * user.currentAction().srpgPredictionDamage(target));
} else {var nowHp = target.hp - user.currentAction().srpgPredictionDamage(target);}
// limit new HP to 0 and maxp HP
if (nowHp > target.mhp) { nowHp = target.mhp;
} else if (nowHp < 0) { nowHp = 0; }
var width = this.textWidth('00000');
this.drawText( nowHp, padding + 150 + width + 16, lineHeight * 2 + 12);
this.resetFontSettings();
// draw HP Gauage
var rate = nowHp / target.mhp;
this.drawGauge( 28 + 32 , lineHeight * 2 + 12, windowWidth / 3 - 48, rate, this.hpGaugeColor1(), this.hpGaugeColor2());
}
if (_srpgPredictionWindowMode === 2) return;
// action order
BattleManager.makeActionOrders();
this.contents.fontSize = 18;
var order = BattleManager.actionBattlers();
var doubleActioncheck = [];
var doubleActionRate = 0;
var iconBoxWidth = Window_Base._iconWidth + 4;
var orderX = this.windowWidth() / 2 - this.standardPadding() - iconBoxWidth +10;
var orderY = lineHeight - 2;
var line = 0
this.drawText('Action', orderX - 8, -8, iconBoxWidth * 2, 'center');
for (var i = 0; i < order.length; i++) {
battler = order[i];
// user
if (user === battler && action && action.item()) {
// first action
if (doubleActioncheck.indexOf(battler) < 0) {
this.drawSrpgBattleOrders(battler, action.item(), orderX, 17 + orderY * line);
// double action
} else if (_srpgUseAgiAttackPlus === 'true' && doubleActioncheck.indexOf(battler) >= 0) {
actionRate = this.setDoubleActionRate(user, target);
if (actionRate > 0) {
this.drawSrpgBattleOrders(battler, action.item(), orderX, 17 + orderY * line);
this.drawSrpgActionRate(actionRate, orderX + iconBoxWidth, 17 + orderY * line);
}
}
// next
doubleActioncheck.push(battler);
line++;
// target
} else if (target === battler && reaction && reaction.item()) {
// 初回行動時
if (doubleActioncheck.indexOf(battler) < 0) {
this.drawSrpgBattleOrders(battler, reaction.item(), orderX, 17 + orderY * line);
// 応戦が反撃率に応じる場合
if (_srpgBattleReaction === 2 && target.cnt > 0) {
this.drawSrpgActionRate(target.cnt * 100, orderX, 17 + orderY * line);
}
// double action
} else if (_srpgUseAgiAttackPlus === 'true' && doubleActioncheck.indexOf(battler) >= 0) {
actionRate = this.setDoubleActionRate(target, user);
if (_srpgBattleReaction === 2 && target.cnt > 0) actionRate = Math.floor(actionRate * target.cnt);
if (actionRate > 0) {
this.drawSrpgBattleOrders(battler, reaction.item(), orderX, 17 + orderY * line);
this.drawSrpgActionRate(actionRate, orderX, 17 + orderY * line);
}
}
// next
doubleActioncheck.push(battler);
line++;
}
}
};