magical-girls-runa-and-nanami/js/plugins/CGPT_pictureserch.js
2026-02-28 12:33:13 -06:00

70 lines
2.8 KiB
JavaScript

/*:
* @plugindesc ピクチャ使用イベント検索プラグイン
* @author あなた
*
* @help
* 指定したピクチャIDがどのイベントで使われているか検索するプラグインです。
*
* 【使い方】
* 1. プラグインコマンドで検索を実行
* 2. 結果がF12のコンソールに表示される
*
* 【プラグインコマンド】
* PictureEventSearcher search [ピクチャID]
* - 例: PictureEventSearcher search 29
*/
(() => {
PluginManager.registerCommand("PictureEventSearcher", "search", args => {
const pictureId = Number(args[0]);
if (isNaN(pictureId)) {
console.warn("⚠️ ピクチャIDが無効です: " + args[0]);
return;
}
console.log(`🔍 ピクチャID ${pictureId} を検索中...`);
// マップイベントの検索
const foundInMaps = [];
for (let mapId = 1; mapId <= $dataMapInfos.length; mapId++) {
if (!$dataMapInfos[mapId]) continue;
const mapData = DataManager.loadDataFile(`data/Map${mapId.toString().padStart(3, '0')}.json`);
if (!mapData) continue;
for (const event of mapData.events) {
if (!event) continue;
for (const page of event.pages) {
for (const command of page.list) {
if (command.code === 231 && command.parameters[0] === pictureId) { // 231: ピクチャの表示
foundInMaps.push(`マップID:${mapId} - イベントID:${event.id} - "${event.name}"`);
}
}
}
}
}
// コモンイベントの検索
const foundInCommonEvents = [];
for (const commonEvent of $dataCommonEvents) {
if (!commonEvent) continue;
for (const command of commonEvent.list) {
if (command.code === 231 && command.parameters[0] === pictureId) {
foundInCommonEvents.push(`コモンイベントID:${commonEvent.id} - "${commonEvent.name}"`);
}
}
}
// 結果を出力
if (foundInMaps.length > 0) {
console.log(`🗺 マップイベントで使用されている場所:`);
foundInMaps.forEach(e => console.log(e));
}
if (foundInCommonEvents.length > 0) {
console.log(`📂 コモンイベントで使用されている場所:`);
foundInCommonEvents.forEach(e => console.log(e));
}
if (foundInMaps.length === 0 && foundInCommonEvents.length === 0) {
console.log(`❌ ピクチャID ${pictureId} は使用されていません`);
}
});
})();