import { readFileSync, writeFileSync } from 'node:fs'; const AI_COMPONENTS = new Set([ 'MOD.Core.AIWanderComponent', 'MOD.Core.AIChaseComponent', ]); const mapFiles = Array.from({ length: 5 }, (_, i) => `map/map${String(i + 1).padStart(2, '0')}.map`); const modelFiles = [ 'Global/MoveMonster.model', 'Global/ChaseMonster.model', 'RootDesk/MyDesk/Models/Monsters/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.');