68 lines
2.5 KiB
JavaScript
68 lines
2.5 KiB
JavaScript
/*:
|
||
* @target MZ
|
||
* @plugindesc アクター対象選択を「指定アクターのみ」表示に固定(デフォルト: アクターID=1)
|
||
* @author
|
||
*
|
||
* @param TargetActorId
|
||
* @text 対象アクターID
|
||
* @type actor
|
||
* @default 1
|
||
*/
|
||
(() => {
|
||
const params = PluginManager.parameters("OnlyOneActorTargetMZ");
|
||
const TARGET_ID = Number(params.TargetActorId || 1);
|
||
|
||
function resolveTargetActor() {
|
||
const t = $gameActors.actor(TARGET_ID);
|
||
if ($gameParty.battleMembers().includes(t)) return t;
|
||
return $gameParty.battleMembers()[0] || null; // いなければ先頭 or null
|
||
}
|
||
|
||
// 1人だけ表示
|
||
const _WBA_maxItems = Window_BattleActor.prototype.maxItems;
|
||
Window_BattleActor.prototype.maxItems = function() {
|
||
return 1;
|
||
};
|
||
|
||
// indexに依存せず、常に目的のアクターを返す
|
||
Window_BattleActor.prototype.actor = function(_index) {
|
||
return resolveTargetActor();
|
||
};
|
||
|
||
// RestrictionTargetSkill互換:対象判定が参照するメンバーを固定
|
||
Window_BattleActor.prototype.getMember = function(_index) {
|
||
return this.actor(0);
|
||
};
|
||
|
||
// 他プラグインに委譲せず安全に描画
|
||
Window_BattleActor.prototype.drawItem = function(index) {
|
||
const actor = this.actor(index);
|
||
if (!actor) return; // いない場合は描画スキップで安全終了
|
||
|
||
// 無効ターゲットなら減彩表示(RestrictionのAPIがあれば使う)
|
||
let enabled = true;
|
||
if (typeof this.canSelectSkillTarget === "function") {
|
||
enabled = this.canSelectSkillTarget(0);
|
||
}
|
||
if (!enabled && typeof this.deactivateBatter === "function") {
|
||
this.deactivateBatter(0);
|
||
} else {
|
||
this.changePaintOpacity(enabled);
|
||
}
|
||
|
||
// デフォルトと同等のレイアウトで描画(顔+ステータス)
|
||
const faceRect = this.faceRect(index);
|
||
this.drawActorFace(actor, faceRect.x, faceRect.y, faceRect.width, faceRect.height); // ← ここで actor が必ず存在するので安全
|
||
this.drawItemStatus(index); // ここも内部で this.actor(index) を呼ぶが、常に同じactorを返す
|
||
this.changePaintOpacity(true);
|
||
};
|
||
|
||
// カーソル操作は常に1件に固定
|
||
Window_BattleActor.prototype.select = function(_index) {
|
||
Window_Selectable.prototype.select.call(this, 0);
|
||
};
|
||
Window_BattleActor.prototype.hitTest = function(x, y) {
|
||
const i = Window_Selectable.prototype.hitTest.call(this, x, y);
|
||
return i >= 0 ? 0 : -1;
|
||
};
|
||
})();
|