slave-princess-charlotte/data/Plugin/battleInfo.js
2025-10-12 13:17:46 -05:00

557 lines
No EOL
18 KiB
JavaScript

PosAttackWindow.getWindowWidth = function() {
return this.getInfoWidth() + this.getUnitWidth() + 20 + 150;
};
PosAttackWindow.getWindowHeight = function() {
return 172;
};
var battleInfoPic = null;
function getBattleInfoPic() {
if (battleInfoPic) {
return battleInfoPic;
}
battleInfoPic = getMyNumberPic(129);
return battleInfoPic;
};
PosAttackWindow.drawInfo = function(xBase, yBase) {
//this.drawName(xBase, yBase);
this.drawInfoTop(xBase, yBase + 53);
this.drawInfoCenter(xBase, yBase - 45);
this.drawInfoBottom(xBase - 10, yBase + 31);
var textui, color, font, pic, x, y, text;
ContentRenderer.drawUnitFace(xBase + 257, yBase - 12, this._unit, false, 255);
this.drawPic(xBase, yBase);
this.drawYPic(xBase, yBase);
//this.drawExp(xBase, yBase);
if (this._roundAttackCount < 2) {
return;
}
textui = root.queryTextUI('attacknumber_title');
color = textui.getColor();
font = textui.getFont();
pic = textui.getUIImage();
x = xBase + 86;
y = yBase + this.getWindowHeight() - 38;
text = StringTable.AttackMenu_AttackCount + StringTable.SignWord_Multiple + this._roundAttackCount;
TextRenderer.drawFixedTitleText(x, y, text, color, font, TextFormat.CENTER, pic, 4);
};
var _145pic;
PosAttackWindow.drawPic = function(x, y) {
if (this._unit.getUnitType() != UnitType.PLAYER) {
return;
}
if (this._weaponCount < 2) {
return;
}
var pic = getPic();
pic.drawParts(x + 176, y - 37, 0, 0, pic.getWidth(), pic.getHeight());
function getPic() {
if (_145pic) {
return _145pic;
}
var list = root.getBaseData().getGraphicsResourceList(GraphicsType.PICTURE, false);
var count = list.getCount();
if (count !== 0) {
pic = list.getDataFromId(145);
if (pic !== null) {
_145pic = pic;
return pic;
}
}
return null;
}
};
var _146pic;
PosAttackWindow.drawYPic = function(x, y) {
if (root.getMetaSession().getGlobalSwitchTable().isSwitchOn(5)) {
return;
}
if (this._unit.getUnitType() != UnitType.PLAYER) {
return;
}
var pic = getPic();
y -= 37;
if (this._weaponCount >= 2) {
y -= 18;
}
pic.drawParts(x + 176, y, 0, 0, pic.getWidth(), pic.getHeight());
function getPic() {
if (_146pic) {
return _146pic;
}
var list = root.getBaseData().getGraphicsResourceList(GraphicsType.PICTURE, false);
var count = list.getCount();
if (count !== 0) {
pic = list.getDataFromId(146);
if (pic !== null) {
_146pic = pic;
return pic;
}
}
return null;
}
};
PosAttackWindow.getWeaponCount = function() {
var i, item;
var count = UnitItemControl.getPossessionItemCount(this._unit);
var weaponCount = 0;
for (i = 0; i < count; i++) {
item = UnitItemControl.getItem(this._unit, i);
if (this._isWeaponAllowed(this._unit, item)) {
weaponCount++;
}
}
return weaponCount;
};
PosAttackWindow._isWeaponAllowed = function(unit, item) {
var indexArray;
if (!ItemControl.isWeaponAvailable(unit, item)) {
return false;
}
indexArray = AttackChecker.getAttackIndexArray(unit, item, true);
return indexArray.length !== 0;
};
PosAttackWindow.drawExp = function(x, y) {
if (this._unit.getUnitType() != UnitType.PLAYER) {
return;
}
var textui = root.queryTextUI('support_title');
var color = textui.getColor();
var font = textui.getFont();
TextRenderer.drawSignText(x + 280, y + 96, StringTable.Status_Experience);
NumberRenderer.drawNumber(x + 330, y + 96, this._unit.getExp());
};
PosBaseWindow.drawWindowContent = function(x, y) {
this.drawInfo(x, y);
this.drawUnit(x + this.getInfoWidth() + 50, y - 15);
var text = this._unit.getName();;
var textui, color, font, pic;
var messageLayout = root.getBaseData().getMessageLayoutList().getData(MessageLayout.TOP);
textui = messageLayout.getNameTextUI();
color = textui.getColor();
font = textui.getFont();
pic = textui.getUIImage();
TextRenderer.drawFixedTitleText(x - 20, y - 50, text, color, font, TextFormat.CENTER, pic, 5);
};
PosAttackWindow.drawInfoTop = function(xBase, yBase) {
var x = xBase;
var y = yBase;
var pic = root.queryUI('unit_gauge');
var balancer = this._gaugeBar.getBalancer();
if (this._unit !== null && this._damage != null) {
var remain = balancer.getCurrentValue() - this._damage;
if (remain < 0) {
remain = 0;
}
ContentRenderer.drawDamage(x, y + 20, balancer.getCurrentValue(), remain);
this._gaugeBar.drawGaugeBar(x, y + 40, pic);
}
};
PosAttackWindow.drawInfoBottom = function(xBase, yBase) {
var x = xBase + 335;
var y = yBase + 110;
var textui = this.getWindowTextUI();
var color = ColorValue.KEYWORD;
var font = textui.getFont();
StatusRenderer.drawAttackStatus2(x, y, this._statusArray, color, font, 40);
var pic = getBattleInfoPic();
pic.drawParts(x - 60, y - 51, 0, 0, pic.getWidth(), pic.getHeight());
};
StatusRenderer.drawAttackStatus = function(x, y, arr, color, font, space) {
var i, text;
var length = this._getTextLength();
var numberSpace = DefineControl.getNumberSpace();
var buf = ['attack_capacity', 'hit_capacity', 'critical_capacity'];
for (i = 0; i < 3; i++) {
text = root.queryCommand(buf[i]);
TextRenderer.drawKeywordText(x, y, text, length + 30, color, font);
x += 30 + numberSpace;
if (i == 1) {
x += 12;
}
if (arr[i] >= 0) {
NumberRenderer.drawNumber(x, y, arr[i]);
}
else {
TextRenderer.drawSignText(x - 5, y, StringTable.SignWord_Limitless);
}
x += space;
}
};
PosAttackWindow.setPosInfo = function(unit, item, isSrc) {
this._unit = unit;
this._item = item;
this._statusArray2 = this._statusArray2 || [];
this._gaugeBar.setGaugeInfo(unit.getHp(), ParamBonus.getMhp(unit), 1, this._statusArray2[0]);
this._weaponCount = this.getWeaponCount();
};
PosAttackWindow.setPosTarget = function(unit, item, targetUnit, targetItem, isSrc) {
var isCalculation = false;
if (item !== null && item.isWeapon() && item.getId() != EVA_ITEM_ID) {
if (isSrc) {
// 自分から仕掛けた場合は無条件にステータスを取得してよい
this._statusArray = AttackChecker.getAttackStatusInternal(unit, item, targetUnit);
isCalculation = true;
}
else {
if (AttackChecker.isCounterattack(targetUnit, unit)) {
this._statusArray = AttackChecker.getAttackStatusInternal(unit, item, targetUnit);
isCalculation = true;
}
else {
this._statusArray = AttackChecker.getNonStatus();
}
}
}
else {
this._statusArray = AttackChecker.getNonStatus();
}
if (isCalculation) {
this._roundAttackCount = Calculator.calculateRoundCount(unit, targetUnit, item);
this._roundAttackCount *= Calculator.calculateAttackCount(unit, targetUnit, item);
}
else {
this._roundAttackCount = 0;
}
this.setPosInfo(unit, item, isSrc);
};
PosAttackWindow.setPosTarget2 = function(unit, item, targetUnit, targetItem, isSrc) {
var isCalculation = false;
if (item !== null && item.isWeapon() && item.getId() != EVA_ITEM_ID) {
if (AttackChecker.isCounterattack(targetUnit, unit)) {
this._statusArray2 = AttackChecker.getAttackStatusInternal(unit, item, targetUnit);
isCalculation = true;
}
else {
this._statusArray2 = AttackChecker.getNonStatus();
}
}
else {
this._statusArray2 = AttackChecker.getNonStatus();
}
var roundAttackCount2;
if (isCalculation) {
roundAttackCount2 = Calculator.calculateRoundCount(unit, targetUnit, item);
roundAttackCount2 *= Calculator.calculateAttackCount(unit, targetUnit, item);
}
else {
roundAttackCount2 = 0;
}
if (! StateControl.isBadStateOption(unit, BadStateOption.NOACTION)) {
this._statusArray2 = this._statusArray2 || [];
this._damage1 = this._statusArray2[0];
if (roundAttackCount2 == 2) {
this._damage2 = Math.floor(this._statusArray2[0] * TSUIGEKI_DAMAGE_RATE / 100);
}
else {
this._damage2 = 0
}
this._damage = this._damage1 + this._damage2;
if (roundAttackCount2 == 0) {
this._damage = 0;
}
} else {
this._damage = 0;
this._damage1 = 0;
this._damage2 = 0;
}
if (roundAttackCount2 == 2) {
this._gaugeBar.setGaugeInfo(targetUnit.getHp(), ParamBonus.getMhp(targetUnit), 1, this._damage1, this._damage2);
} else {
this._gaugeBar.setGaugeInfo(targetUnit.getHp(), ParamBonus.getMhp(targetUnit), 1, this._damage);
}
};
PosMenu.changePosTarget = function(targetUnit) {
var targetItem, isLeft;
if (this._unit === null || !this._isTargetAllowed(targetUnit)) {
this._currentTarget = null;
return;
}
this._currentTarget = targetUnit;
targetItem = ItemControl.getEquippedWeapon(targetUnit);
// srcを常に左側に表示するものとする
isLeft = Miscellaneous.isUnitSrcPriority(this._unit, targetUnit);
// 自軍を左側に表示することを優先している(左側の方が見やすいと判断)
// このため、自軍が仕掛けた場合は当然左側に表示されるが、
// 自軍が仕掛けられた場合でも左側に表示される。
// 両方、自軍である場合は仕掛けた方を左側に表示する。
if (isLeft) {
// 仕掛けたのは自軍であるため、これを_posWindowLeftに指定
this._posWindowLeft.setPosTarget(this._unit, this._item, targetUnit, targetItem, true);
this._posWindowRight.setPosTarget(targetUnit, targetItem, this._unit, this._item, false);
if (this._posWindowLeft.setPosTarget2) {
this._posWindowLeft.setPosTarget2(targetUnit, targetItem, this._unit, this._item, true);
this._posWindowRight.setPosTarget2(this._unit, this._item, targetUnit, targetItem, false);
}
}
else {
// 仕掛けたのは自軍ではない。
// この場合、targetUnitが自軍であるため、これを_posWindowLeftに指定。
this._posWindowLeft.setPosTarget(targetUnit, targetItem, this._unit, this._item, true);
this._posWindowRight.setPosTarget(this._unit, this._item, targetUnit, targetItem, false);
this._posWindowLeft.setPosTarget2(this._unit, this._item, targetUnit, targetItem, false);
this._posWindowRight.setPosTarget2(targetUnit, targetItem, this._unit, this._item, true);
}
};
ContentRenderer.drawDamage = function(x, y, hp, maxHp) {
var textHp = this._getHpText();
var textSlash = '→';
var dx = [0, 47, 75, 116];
TextRenderer.drawSignText(x + dx[0], y, textHp);
NumberRenderer2.drawNumberColor(x + dx[1], y - 8, hp, 1, 255);
if (maxHp == null) {
return;
}
TextRenderer.drawSignText(x + dx[2], y, textSlash);
NumberRenderer.drawNumberColor(x + dx[3], y - 0, maxHp, 0, 255);
};
PosMenu.getPositionWindowY = function() {
return Miscellaneous.getDyamicWindowY(this._unit, this._currentTarget, this._posWindowLeft.getWindowHeight() + 80);
};
PosItemWindow.getWindowWidth = function() {
return this.getInfoWidth() + this.getUnitWidth() + 20 + 160;
};
PosItemWindow.getWindowHeight = function() {
return 183;
};
PosItemWindow.drawInfo = function(xBase, yBase) {
this.drawInfoTop(xBase, yBase + 53);
this.drawInfoCenter(xBase, yBase - 45);
this.drawInfoBottom(xBase - 10, yBase + 31);
var textui, color, font, pic, x, y, text;
ContentRenderer.drawUnitFace(xBase + 257, yBase - 12, this._unit, false, 255);
};
PosItemWindow.drawInfoTop = function(xBase, yBase) {
var x = xBase;
var y = yBase;
var pic = root.queryUI('unit_gauge');
var balancer = this._gaugeBar.getBalancer();
if (this._unit !== null) {
var n = balancer.getCurrentValue() + this._value2;
if (n > balancer.getMaxValue()) {
n = balancer.getMaxValue();
}
ContentRenderer.drawDamage(x, y + 20, balancer.getCurrentValue(), n);
this._gaugeBar.drawGaugeBar(x - 2, y + 40, pic);
}
};
PosItemWindow.drawInfoBottom = function(xBase, yBase) {
var text;
var x = xBase;
var y = yBase + 76;
var textui = this.getWindowTextUI();
var color = ColorValue.KEYWORD;
var font = textui.getFont();
if (this._itemType === ItemType.RECOVERY) {
text = StringTable.Recovery_Value;
}
else if (this._itemType === ItemType.DAMAGE) {
text = StringTable.Damage_Pow;
}
else {
return;
}
TextRenderer.drawKeywordText(x + 264, y, text, -1, color, font);
NumberRenderer.drawNumber(x + 78 + 264, y + 1, this._value);
};
PosItemWindow.setPosTarget2 = function(unit, item, targetUnit, targetItem, isSrc) {
var plus, recoveryInfo, damageInfo;
if (item !== null && !item.isWeapon()) {
this._itemType2 = item.getItemType();
if (this._itemType2 === ItemType.RECOVERY) {
recoveryInfo = item.getRecoveryInfo();
plus = Calculator.calculateRecoveryItemPlus(unit, targetUnit, item);
this._value2 = Calculator.calculateRecoveryValue(targetUnit, recoveryInfo.getRecoveryValue(), recoveryInfo.getRecoveryType(), plus);
}
else if (this._itemType2 === ItemType.DAMAGE) {
damageInfo = item.getDamageInfo();
plus = Calculator.calculateDamageItemPlus(unit, targetUnit, item);
this._value2 = Calculator.calculateDamageValue(targetUnit, damageInfo.getDamageValue(), damageInfo.getDamageType(), plus);
}
}
if (this._itemType2 === ItemType.RECOVERY) {
this._gaugeBar.setGaugeInfo(targetUnit.getHp(), ParamBonus.getMhp(targetUnit), 1, -this._value2);
}
else if (this._itemType2 === ItemType.DAMAGE) {
this._gaugeBar.setGaugeInfo(targetUnit.getHp(), ParamBonus.getMhp(targetUnit), 1, this._value2);
}
};
EasyAttackWindow.setPosTarget = function(unit, item, targetUnit, targetItem, isSrc) {
var isCalculation = false;
if (item !== null && item.isWeapon()) {
if (isSrc) {
// 自分から仕掛けた場合は無条件にステータスを取得してよい
this._statusArray = AttackChecker.getAttackStatusInternal(unit, item, targetUnit);
isCalculation = true;
}
else {
if (AttackChecker.isCounterattack(targetUnit, unit)) {
this._statusArray = AttackChecker.getAttackStatusInternal(unit, item, targetUnit);
isCalculation = true;
}
else {
this._statusArray = AttackChecker.getNonStatus();
}
}
}
else {
this._statusArray = AttackChecker.getNonStatus();
}
if (isCalculation) {
this._roundAttackCount = Calculator.calculateRoundCount(unit, targetUnit, item);
this._roundAttackCount *= Calculator.calculateAttackCount(unit, targetUnit, item);
}
else {
this._roundAttackCount = 0;
}
};
var allCancel = false;
UnitCommand.Attack._moveSelection = function() {
var attackParam;
var result = this._posSelector.movePosSelector();
if (result === PosSelectorResult.SELECT) {
if (this._isPosSelectable()) {
this._posSelector.endPosSelector();
attackParam = this._createAttackParam();
this._preAttack = createObject(PreAttack);
result = this._preAttack.enterPreAttackCycle(attackParam);
if (result === EnterResult.NOTENTER) {
this.endCommandAction();
return MoveResult.END;
}
this.changeCycleMode(AttackCommandMode.RESULT);
}
}
else if (result === PosSelectorResult.CANCEL) {
this._posSelector.endPosSelector();
this._weaponSelectMenu.setMenuTarget(this.getCommandTarget());
this.changeCycleMode(AttackCommandMode.TOP);
}
if (InputControl.isLeftPadAction() || InputControl.isRightPadAction()) {
var cursor = this._weaponSelectMenu._itemListWindow._scrollbar._commandCursor;
if (InputControl.isLeftPadAction()) {
var d = cursor._getIntervalValue(InputType.UP);
} else {
var d = cursor._getIntervalValue(InputType.DOWN);
}
cursor._changeCursorIndex(d);
var weapon = this._weaponSelectMenu.getSelectWeapon();
var filter = this._getUnitFilter();
var unit = this.getCommandTarget();
// 選択したアイテムを装備
ItemControl.setEquippedWeapon(unit, weapon);
var indexArray = this._getIndexArray(unit, weapon);
var targetUnit = this._posSelector.getSelectorTarget();
this._posSelector.setUnitOnly(unit, weapon, indexArray, PosMenuType.Attack, filter);
this._posSelector.setFirstPos();
if (targetUnit != null) {
this._posSelector._mapCursor.setPos(targetUnit.getMapX(), targetUnit.getMapY());
this._posSelector.setNewTarget();
}
}
if (root.isInputAction(InputType.BTN4)) {
allCancel = true;
this._posSelector.endPosSelector();
root.getMetaSession().getGlobalSwitchTable().setSwitch(5, true)
MediaControl.soundDirect('commandcancel');
return MoveResult.END;
}
return MoveResult.CONTINUE;
};
var UnitCommand_Attack_moveTop = UnitCommand.Attack._moveTop;
UnitCommand.Attack._moveTop = function() {
if (root.isInputAction(InputType.BTN4)) {
allCancel = true;
MediaControl.soundDirect('commandcancel');
return MoveResult.END;
}
if (allCancel) {
return MoveResult.END;
}
return UnitCommand_Attack_moveTop.call(this);
};
var UnitCommand_moveListCommandManager = UnitCommand.moveListCommandManager;
UnitCommand.moveListCommandManager = function() {
if (allCancel) {
allCancel = false;
return MoveResult.END;
}
return UnitCommand_moveListCommandManager.call(this);
};
var UnitCommand_drawListCommandManager = UnitCommand.drawListCommandManager;
UnitCommand.drawListCommandManager = function() {
if (allCancel) {
return;
}
return UnitCommand_drawListCommandManager.call(this);
};