Files
maplecontest/tools/monster/freeze-turn-monsters.mjs
gahusb 124e49b938 refactor(tools): .mjs를 주체별 폴더로 분류 + 카메라/플레이어 제어 분리
- tools/{player,monster,camera,map,deck,balance}/ 로 8개 스크립트 분류 (git mv 이력 보존)
- gen-camera의 플레이어 입력 차단·시선 고정을 tools/player/gen-player-lock.mjs(PlayerLock 코드블록)로 분리
- MapCamera 코드블록은 카메라 속성 전용으로 정리, 11개 맵 루트에 script.PlayerLock 부착
- README 및 스크립트 주석의 도구 경로 갱신

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 23:52:02 +09:00

84 lines
2.6 KiB
JavaScript

import { readFileSync, writeFileSync } from 'node:fs';
const AI_COMPONENTS = new Set([
'MOD.Core.AIWanderComponent',
'MOD.Core.AIChaseComponent',
]);
const mapFiles = Array.from({ length: 11 }, (_, i) => `map/map${String(i + 1).padStart(2, '0')}.map`);
const modelFiles = [
'Global/MoveMonster.model',
'Global/ChaseMonster.model',
'RootDesk/MyDesk/Model_monster-43.model',
];
function isMonster(entity) {
return (entity.componentNames || '').includes('script.Monster');
}
function component(entity, type) {
return entity.jsonString['@components'].find((c) => c['@type'] === type);
}
function patchMonsterEntity(entity) {
const components = entity.jsonString['@components'];
entity.jsonString['@components'] = components.filter((c) => !AI_COMPONENTS.has(c['@type']));
entity.componentNames = entity.jsonString['@components'].map((c) => c['@type']).join(',');
const movement = component(entity, 'MOD.Core.MovementComponent');
if (movement) {
movement.Enable = false;
movement.InputSpeed = 0;
}
const rigidbody = component(entity, 'MOD.Core.RigidbodyComponent');
if (rigidbody) {
rigidbody.MoveVelocity = { x: 0, y: 0 };
rigidbody.RealMoveVelocity = { x: 0, y: 0 };
}
const transform = component(entity, 'MOD.Core.TransformComponent');
if (transform?.Scale) {
transform.Scale.x = Math.abs(transform.Scale.x || 1);
transform.Scale.y = Math.abs(transform.Scale.y || 1);
}
const stateAnimation = component(entity, 'MOD.Core.StateAnimationComponent');
const renderer = component(entity, 'MOD.Core.SpriteRendererComponent');
const stand = stateAnimation?.ActionSheet?.stand;
if (renderer && stand) {
renderer.SpriteRUID = stand;
}
}
function patchMap(file) {
const data = JSON.parse(readFileSync(file, 'utf8'));
for (const entity of data.ContentProto.Entities.filter(isMonster)) {
patchMonsterEntity(entity);
}
writeFileSync(file, `${JSON.stringify(data, null, 2)}\n`, 'utf8');
}
function patchModel(file) {
const data = JSON.parse(readFileSync(file, 'utf8'));
const json = data.ContentProto.Json;
json.Components = (json.Components || []).filter((name) => !AI_COMPONENTS.has(name));
json.Values = (json.Values || []).filter((value) => !AI_COMPONENTS.has(value.TargetType));
for (const value of json.Values) {
if (value.TargetType === 'MOD.Core.MovementComponent' && value.Name === 'InputSpeed') {
value.Value = 0;
}
}
writeFileSync(file, `${JSON.stringify(data, null, 2)}\n`, 'utf8');
}
for (const file of mapFiles) {
patchMap(file);
}
for (const file of modelFiles) {
patchModel(file);
}
console.log('Turn-combat monster movement disabled.');