pure-full-lily/js/plugins/PictureHeroineDisplay.js
2025-09-16 10:12:44 -05:00

261 lines
No EOL
10 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*:
* @plugindesc プラグインコマンドで文字列を入力してヒロインピクチャを表示するプラグイン暗号化デプロイ対応版・avatar 0Y バグ修正)
* @target MZ
* @author kaeru
* * @command PictureDisplay
* @text ピクチャ表示
* @desc 数値リストを入力してピクチャを表示します。
*
* @arg values
* @type text
* @text 数値リスト
* @desc 表示する数値リストをカンマ区切りで入力してください。
* @default A,ND,BN,EN,MN,EFD,event
*
* @arg applyTone
* @type boolean
* @text 色調変更を適用
* @desc ONであれば全てのピクチャの色調を0にします。
* @default false
*
* @arg position
* @type select
* @text PCの位置
* @desc 表示するピクチャのX軸位置を指定します。
* @default event
* @option field
* @value field
* @option event
* @value event
*
* @command UpdateBase
* @text ベース更新
* @desc ベースの値を更新します。A あまね / MS 魔法少女 / MD 改造服 / SN 精液沼 / CF 悪落ち / KB 瘤渡り / MC 催眠
*
* @arg values
* @type text
* @text ベース数値
* @default A
*
* @command UpdateAvatar
* @text アバター更新
* @desc アバターの値を更新します。ND 裸 / NP 通常 / Y 破れ / NDH 裸_発情 / YH 破れ_発情 / NPH 通常_発情
*
* @arg values
* @type text
* @text アバター数値
* @default ND
*
* @command UpdateFace
* @text ヒロインの表情更新
* @desc ヒロインの表情に関連する値のみを更新します。【眉】BN 通常 / BT 釣り上げ / BTB 困り【目】EN 通常 / EZ ジト目 / EO 見開き / EL 下向き / EM 催眠 / EE 笑顔 / EEJ アヘ顔 / EH ハート【口】MN 通常 / MS 笑み / MOS 開き笑顔 / MT 狭 / MO 開き / MW へにょり / MC 猫 / MEJ オホ / MK 媚
*
* @arg values
* @type text
* @text 表情数値リスト
* @desc 表情(眉,目,口)を更新する3つの数値をカンマ区切りで入力してください。
* @default BN,EN,MN
*
* @command UpdateEffect
* @text エフェクト更新
* @desc エフェクトの値を更新します。EFD なし / EFS 汗 / EFSF 精液_顔 / EFSG 精液_股 / EFST 蒸気 / EFEJ 潮
*
* @arg values
* @type text
* @text エフェクト数値
* @default EFD
*
* @help PictureHeroineDisplay.js (暗号化対応版)
* 画像を暗号化してデプロイしても読み込めるよう、ファイル存在チェックに
* fs.existsSync() を使用せず、RPG ツクール標準の ImageManager に任せています。
* そのため .png / .png_ / .rpgmvp いずれの拡張子でも動作します。
*
* 【2025-05-26】
* アバターに Y ・ YH などアルファベット1文字が入った際に "0Y" とゼロ埋めされ
* 存在しないファイル名を参照してしまうバグを修正。
* 1桁の数字のみ 0 埋めし、それ以外はそのまま文字列にします。
* * 【2025-07-25】
* ベース更新時に PictureHeroineAdditionalEffects.js の管理する
* ピクチャ(35, 36)が更新されない問題を修正。
* ベース更新をトリガーに追加エフェクトも再描画する処理を追加。
*
* 【2025-07-25 v2】
* 既存ピクチャのトーンが null の場合にエラーが発生する問題を修正。
*/
(() => {
"use strict";
const pluginName = "PictureHeroineDisplay";
//---------------------------------------------------------------------------
// プラグインコマンド
//---------------------------------------------------------------------------
PluginManager.registerCommand(pluginName, "PictureDisplay", args => {
try {
const values = args.values;
const applyTone = args.applyTone === "true";
const position = args.position || "event";
const valuesArray = values.split(',');
if (valuesArray.length !== 7) {
console.warn("値が7つではありません: ", args.values);
return;
}
setDefaultVariables();
// 変数10〜16を設定
$gameVariables.setValue(10, valuesArray[0]); // ベース
$gameVariables.setValue(11, valuesArray[1]); // アバター
valuesArray.slice(2).forEach((v, i) => $gameVariables.setValue(12 + i, v));
$gameVariables.setValue(16, position);
updatePictures(applyTone, [10, 11, 12, 13, 14, 15, 16]);
} catch (e) {
console.error("PictureDisplay エラー: ", e);
}
});
PluginManager.registerCommand(pluginName, "UpdatePosition", args => {
try {
const position = args.position || "field";
setDefaultVariables();
$gameVariables.setValue(16, position);
updatePictures(false, [16]);
} catch (e) {
console.error("UpdatePosition エラー: ", e);
}
});
PluginManager.registerCommand(pluginName, "UpdateBase", args => {
try {
const values = args.values;
setDefaultVariables();
$gameVariables.setValue(10, values);
updatePictures(false, [10]);
} catch (e) {
console.error("UpdateBase エラー: ", e);
}
});
PluginManager.registerCommand(pluginName, "UpdateAvatar", args => {
try {
const values = args.values;
setDefaultVariables();
$gameVariables.setValue(11, values);
updatePictures(false, [11]);
} catch (e) {
console.error("UpdateAvatar エラー: ", e);
}
});
PluginManager.registerCommand(pluginName, "UpdateFace", args => {
try {
const valuesArray = args.values.split(',');
if (valuesArray.length !== 3) {
console.warn("眉・目・口は3つ指定してください: ", args.values);
return;
}
setDefaultVariables();
[12, 13, 14].forEach((id, i) => $gameVariables.setValue(id, valuesArray[i]));
updatePictures(false, [12, 13, 14]);
} catch (e) {
console.error("UpdateFace エラー: ", e);
}
});
PluginManager.registerCommand(pluginName, "UpdateEffect", args => {
try {
const values = args.values;
setDefaultVariables();
$gameVariables.setValue(15, values);
updatePictures(false, [15]);
} catch (e) {
console.error("UpdateEffect エラー: ", e);
}
});
//---------------------------------------------------------------------------
// 内部関数
//---------------------------------------------------------------------------
function setDefaultVariables() {
if ($gameVariables.value(10) === 0) { // 初回のみ
$gameVariables.setValue(10, 'MS'); // ベース
$gameVariables.setValue(11, 'NP'); // アバター
$gameVariables.setValue(12, 'BN'); // 眉
$gameVariables.setValue(13, 'EN'); // 目
$gameVariables.setValue(14, 'MN'); // 口
$gameVariables.setValue(15, 'EFD'); // エフェクト
$gameVariables.setValue(16, 'event'); // 位置
}
}
// 追加エフェクトのピクチャを再描画する関数
function refreshAdditionalEffects() {
showAdditionalEffectPicture(17, 35); // 股エフェクト(変数17, ピクチャID35)を更新
showAdditionalEffectPicture(18, 36); // 顔エフェクト(変数18, ピクチャID36)を更新
}
// PictureHeroineAdditionalEffects.js から持ってきた処理
function showAdditionalEffectPicture(variableId, pictureId) {
const base10 = $gameVariables.value(10) || "MS";
const base11 = $gameVariables.value(11) || "NP";
const effect = $gameVariables.value(variableId);
if (!effect || effect === 0 || effect === "0") return; // 値がなければ表示しない
const x = $gameVariables.value(16) === "field" ? 100 : 0;
const y = 0;
const basePath = "heroine/AddEF";
const name = `${base10}_${base11}_${effect}`;
const oldPic = $gameScreen.picture(pictureId);
// ★エラー修正箇所 1
const tone = (oldPic && oldPic.tone()) || [0, 0, 0, 0];
$gameScreen.showPicture(pictureId, `${basePath}/${name}`, 0, x, y, 100, 100, 255, 0);
$gameScreen.picture(pictureId).tint(tone, 1);
}
// ピクチャを更新(暗号化デプロイ対応)
function updatePictures(applyTone, updateIndices) {
// ベース or 位置を変更した場合は全更新
if (updateIndices.includes(10) || updateIndices.includes(16)) {
updateIndices = [10, 11, 12, 13, 14, 15, 16];
refreshAdditionalEffects();
}
const basePath = 'heroine';
const baseVariable = $gameVariables.value(10);
const xPosition = $gameVariables.value(16) === 'field' ? 100 : 0;
const variableIds = [11, 12, 13, 14, 15]; // ピクチャID 30〜34 に対応
variableIds.forEach((varId, i) => {
if (!updateIndices.includes(varId)) return;
// ------------------------------
// 2025/05/26 fix:
// 1 桁の数値のみ 0 埋めし、アルファベットコードはそのまま使用
// ------------------------------
let value = $gameVariables.value(varId).toString();
if (/^\d$/.test(value)) {
value = value.padStart(2, '0');
}
// ------------------------------
const pictureName = `${basePath}/${baseVariable}/${baseVariable}_${value}`;
const pictureId = 30 + i;
const oldPic = $gameScreen.picture(pictureId);
// ★エラー修正箇所 2
const tone = applyTone ? [0, 0, 0, 0] : ((oldPic && oldPic.tone()) || [0, 0, 0, 0]);
// ImageManager に任せてロードする。暗号化時も自動で .png_ を解決してくれる。
$gameScreen.showPicture(pictureId, pictureName, 0, xPosition, 0, 100, 100, 255, 0);
$gameScreen.picture(pictureId).tint(tone, 1);
});
}
})();