/*============================================================================= iiiBattleViewCustom.js ---------------------------------------------------------------------------- Version 1.0.0 =============================================================================*/ /*: * @plugindesc バトルシーンに関する表示の変更をまとめて定義します。 * @target MZ * @author iii * * @help iiiBattleViewCustom.js * * 御前試合用。バトルシーン中の表示に関するあれこれを調整します。 * バトル表示関連プラグインの中で、イチバン最後に読み込まれるようにしてください。 * * ActionQueueSystemに関するあれこれはそちらで調整するので本プラグインでは * なるべく弄らないようにしてください。 */ (() => { "use strict"; const script = document.currentScript; // ------------------------------------------------- // // 敵の状態変化アイコンスプライト表示位置調整(敵が1体の前提 // // ------------------------------------------------- var _Sprite_Enemy_prototype_updateStateSprite = Sprite_Enemy.prototype.updateStateSprite; Sprite_Enemy.prototype.updateStateSprite = function () { //一応基底は呼んでおく _Sprite_Enemy_prototype_updateStateSprite.call(this); //ここで座標指定してください。 //直接JS弄ってもらった方がプラグインパラメータ指定よりトライアンドエラーが柔軟になると思ったため。 let scnX = 80; let scnY = 140; //状態異常アイコンの描画原点位置。 //状態異常アイコンが複数出た時にずれが発生しないよう左上原点にしています。 // this._stateIconSprite.anchor.x = 0; // this._stateIconSprite.anchor.y = 0; //スクリーン座標になるよう計算 let enmX = this.x; let enmY = this.y; // this._stateIconSprite.x = scnX - enmX; // this._stateIconSprite.y = scnY - enmY; }; // ------------------------------------------------- // // バトル画面内の装飾表示 // // ------------------------------------------------- const _Scene_Battle_prototype_createDisplayObjects = Scene_Battle.prototype.createDisplayObjects; Scene_Battle.prototype.createDisplayObjects = function () { _Scene_Battle_prototype_createDisplayObjects.call(this); var sprite = new Sprite(); //note: 本来UI周りはsystemにて管理したほうが良いが、管理しやすさ優先ということで sprite.bitmap = ImageManager.loadPicture("BattlePic/UI_Bushi_Battle_backs"); this.addChildAt(sprite, 1); Torigoya.FrameTween.create(sprite) .to({ x: 500, opacity: 0 }, 0) .to( { x: 0, opacity: 255 / 2 }, 180, Torigoya.FrameTween.Easing.easeOutCircular ) .start(); // 立ち絵表示プラグイン対応 if ($gameSwitches.value(131)) { return; } if (this._standSprites) { const leader = $gameParty.leader(); var st = this._standSprites.get(leader.actorId()); if (st != null) { const firstPos = st.x; const stWidth = st.width; Torigoya.FrameTween.create(st) .to({ x: Graphics.width + stWidth, opacity: 255 }, 0) .to( { x: firstPos, opacity: 255 }, 90, Torigoya.FrameTween.Easing.easeOutCircular ) .start(); } } }; // ------------------------------------------------- // // MPP_Pseudo3DBattle 向けの対応 // // ------------------------------------------------- const _Sprite_Enemy_prototype_setBattler = Sprite_Enemy.prototype.setBattler; Sprite_Enemy.prototype.setBattler = function (battler) { _Sprite_Enemy_prototype_setBattler.call(this, battler); if (this._enemy.isBigEnemy && this._enemy.isBigEnemy()) { this._pseudo3dType = "excl"; //3d表示非対応にする // ボスの状態異常表示はCurrentEnemyInfoWindow(iiiEnemyInfo)側で行うので非表示 this._stateIconSprite.hide(); } }; const _Sprite_Enemy_prototype_createStateIconSprite = Sprite_Enemy.prototype.createStateIconSprite; Sprite_Enemy.prototype.createStateIconSprite = function () { //_Sprite_Enemy_prototype_createStateIconSprite this._stateIconSprite = new Sprite_StateIcon2(); this.addChild(this._stateIconSprite); }; // BigEnemyでも疑似3Dとして扱いたい場合、本プラグインをMPP_Pseudo3DBattleより後に読み込むようにしたうえで以下をコメントアウトを解除すること。 // (その場合でも戦闘開始時に相本が見切れてしまう問題には現状対応していません) // const _Sprite_Enemy_prototype_pseudo3dAltitude = Sprite_Enemy.prototype.pseudo3dAltitude; // Sprite_Enemy.prototype.pseudo3dAltitude = function() // { // if (this._enemy.isBigEnemy && this._enemy.isBigEnemy()){ // return 0; // } // const altitude = _Sprite_Enemy_prototype_pseudo3dAltitude.call(this); // return altitude; // }; // ------------------------------------------------- // // ウインドウ関連サイズ・位置調整 // // ------------------------------------------------- const _Scene_Base_prototype_addWindow = Scene_Base.prototype.addWindow; Scene_Base.prototype.addWindow = function (window, childIndex) { if (childIndex == undefined) { _Scene_Base_prototype_addWindow.call(this, window); } else { this._windowLayer.addChildAt(window, childIndex); } }; const _Scene_Battle_prototype_createAllWindows = Scene_Battle.prototype.createAllWindows; Scene_Battle.prototype.createAllWindows = function () { _Scene_Battle_prototype_createAllWindows.call(this); //バトルログウインドウがマスクされないように this._logWindow._isWindow = false; }; Scene_Battle.prototype.isRightInputMode = function () { return false; }; const _Window_BattleStatus_prototype_createInnerSprite = Window_BattleStatus.prototype.createInnerSprite; Window_BattleStatus.prototype.createInnerSprite = function ( key, spriteClass ) { if (spriteClass == Sprite_StateIcon) { return _Window_BattleStatus_prototype_createInnerSprite.call( this, key, Sprite_StateIcon2 ); } return _Window_BattleStatus_prototype_createInnerSprite.call( this, key, spriteClass ); }; const _Window_BattleStatus_prototype_stateIconX = Window_BattleStatus.prototype.stateIconX; Window_BattleStatus.prototype.stateIconX = function (rect) { //return _Window_BattleStatus_prototype_stateIconX.call(this, rect); return rect.x + 4; }; const _Window_BattleStatus_prototype_stateIconY = Window_BattleStatus.prototype.stateIconY; Window_BattleStatus.prototype.stateIconY = function (rect) { //return _Window_BattleStatus_prototype_stateIconY.call(this, rect); return rect.y + 4; }; const _Sprite_Battler_prototype_createDamageSprite = Sprite_Battler.prototype.createDamageSprite; Sprite_Battler.prototype.createDamageSprite = function () { const last = this._damages[this._damages.length - 1]; const sprite = new Sprite_Damage(); if (last) { sprite.x = last.x + 8; sprite.y = last.y - 16; } else { sprite.x = this.x + this.damageOffsetX(); sprite.y = this.y + this.damageOffsetY(); //崩し状態のダメージポップアップ処理 //_stateAccumulations let bigDamage = false; const existsDeath = this._enemy._states.findIndex((x) => x == 1) >= 0; if (existsDeath) { const acc = this._enemy._stateAccumulations[41] | 0; bigDamage = acc && acc >= 1; } else { const existsState = this._enemy._states.findIndex((x) => x == 41) >= 0; const added = this._enemy._result?.addedStates.findIndex((x) => x == 41) >= 0; bigDamage = existsState && !added; } if (bigDamage) { sprite.scale.x = 3; sprite.scale.y = 3; } } sprite.setup(this._battler); this._damages.push(sprite); this.parent.addChild(sprite); }; })(); // Sprite_StateIcon2 // マウスホバー判定 & 状態異常アイコンの横並びに対応したSprite_StateIcon // iiiEnemyInfoでも利用するのでスコープは全体 class Sprite_StateIcon2 extends Sprite_StateIcon { static colNum = 7; static rowNum = 3; constructor() { super(); this.anchor.x = 0; this.anchor.y = 0; this._iconSprites = []; } loadBitmap() { //super.loadBitmap(); //this.bitmapではなく_iconBitmapに持って置き、内容を転写する this._iconBitmap = ImageManager.loadSystem("IconSet"); const pw = ImageManager.iconWidth; const ph = ImageManager.iconHeight; this.bitmap = new Bitmap( pw * Sprite_StateIcon2.colNum, ph * Sprite_StateIcon2.rowNum ); } updateFrame() { this.bitmap.clear(); const icons = this._battler.allIcons(); const pw = ImageManager.iconWidth; const ph = ImageManager.iconHeight; icons.forEach((icon, index) => { const sx = (icon % 16) * pw; const sy = Math.floor(icon / 16) * ph; const xx = (index % Sprite_StateIcon2.colNum) * pw; const yy = parseInt(index / Sprite_StateIcon2.colNum) * ph; this.bitmap.blt(this._iconBitmap, sx, sy, pw, ph, xx, yy); }); } // iiiBattleStateHelp.js で追加しているモノを上書き hitTest(x, y) { if (!super.hitTest || !super.hitTest(x, y)) return false; if (!this._battler) return false; // アイコンの上に乗ってるかを確認する const icons = this._battler.allIcons(); const pw = ImageManager.iconWidth; const ph = ImageManager.iconHeight; const isHit = icons.some((icon, index) => { const xx = (index % Sprite_StateIcon2.colNum) * pw; const yy = parseInt(index / Sprite_StateIcon2.colNum) * ph; const rect = new Rectangle( -this.anchor.x * this.width + xx, -this.anchor.y * this.height + yy, pw, ph ); return rect.contains(x, y); }); return isHit; } }