diff --git a/RootDesk/MyDesk/CombatMonster.codeblock b/RootDesk/MyDesk/CombatMonster.codeblock index 1989060..de3f3d8 100644 --- a/RootDesk/MyDesk/CombatMonster.codeblock +++ b/RootDesk/MyDesk/CombatMonster.codeblock @@ -36,6 +36,13 @@ "Attributes": [], "Name": "EnemyId" }, + { + "Type": "string", + "DefaultValue": "\"combat\"", + "SyncDirection": 0, + "Attributes": [], + "Name": "Group" + }, { "Type": "number", "DefaultValue": "0", @@ -54,7 +61,7 @@ "Name": null }, "Arguments": [], - "Code": "self.RegTries = 0\nlocal eventId = 0\nlocal function reg()\n\tself.RegTries = self.RegTries + 1\n\tlocal c = _EntityService:GetEntityByPath(\"/common\")\n\tif c ~= nil and c.SlayDeckController ~= nil then\n\t\tc.SlayDeckController:RegisterMonster(self.Entity, self.EnemyId)\n\t\t_TimerService:ClearTimer(eventId)\n\telseif self.RegTries > 50 then\n\t\t_TimerService:ClearTimer(eventId)\n\tend\nend\neventId = _TimerService:SetTimerRepeat(reg, 0.1)", + "Code": "self.RegTries = 0\nlocal eventId = 0\nlocal function reg()\n\tself.RegTries = self.RegTries + 1\n\tlocal c = _EntityService:GetEntityByPath(\"/common\")\n\tif c ~= nil and c.SlayDeckController ~= nil then\n\t\tc.SlayDeckController:RegisterMonster(self.Entity, self.EnemyId, self.Group)\n\t\t_TimerService:ClearTimer(eventId)\n\telseif self.RegTries > 50 then\n\t\t_TimerService:ClearTimer(eventId)\n\tend\nend\neventId = _TimerService:SetTimerRepeat(reg, 0.1)", "Scope": 2, "ExecSpace": 6, "Attributes": [], diff --git a/map/map01.map b/map/map01.map index 9b33943..a9a8ef4 100644 --- a/map/map01.map +++ b/map/map01.map @@ -6510,7 +6510,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 @@ -6651,7 +6652,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 @@ -6792,7 +6794,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 diff --git a/map/map02.map b/map/map02.map index 4c953a5..52cf8b2 100644 --- a/map/map02.map +++ b/map/map02.map @@ -6510,7 +6510,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 @@ -6663,7 +6664,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 diff --git a/map/map03.map b/map/map03.map index 19f7458..621cd3f 100644 --- a/map/map03.map +++ b/map/map03.map @@ -6510,7 +6510,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 @@ -6663,7 +6664,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 diff --git a/map/map04.map b/map/map04.map index fb6147b..17062a5 100644 --- a/map/map04.map +++ b/map/map04.map @@ -6510,7 +6510,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 @@ -6663,7 +6664,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 diff --git a/map/map05.map b/map/map05.map index 861f25f..25edc3e 100644 --- a/map/map05.map +++ b/map/map05.map @@ -6510,7 +6510,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 @@ -6663,7 +6664,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 diff --git a/map/map06.map b/map/map06.map index fb9adf2..e90ee5c 100644 --- a/map/map06.map +++ b/map/map06.map @@ -6510,7 +6510,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 @@ -6663,7 +6664,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 diff --git a/map/map07.map b/map/map07.map index ff78649..58a8083 100644 --- a/map/map07.map +++ b/map/map07.map @@ -6510,7 +6510,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 @@ -6663,7 +6664,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 diff --git a/map/map08.map b/map/map08.map index 50e9fe2..9f05b4b 100644 --- a/map/map08.map +++ b/map/map08.map @@ -6510,7 +6510,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 @@ -6663,7 +6664,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 diff --git a/map/map09.map b/map/map09.map index bfbbe7c..de82c84 100644 --- a/map/map09.map +++ b/map/map09.map @@ -6510,7 +6510,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 @@ -6663,7 +6664,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 diff --git a/map/map10.map b/map/map10.map index a396993..71dd819 100644 --- a/map/map10.map +++ b/map/map10.map @@ -6510,7 +6510,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 @@ -6663,7 +6664,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 diff --git a/map/map11.map b/map/map11.map index 6753e25..cf593b5 100644 --- a/map/map11.map +++ b/map/map11.map @@ -6510,7 +6510,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 @@ -6663,7 +6664,8 @@ { "@type": "script.CombatMonster", "Enable": true, - "EnemyId": "orange_mushroom" + "EnemyId": "orange_mushroom", + "Group": "combat" } ], "@version": 1 diff --git a/tools/monster/gen-combat-monster.mjs b/tools/monster/gen-combat-monster.mjs index 16b33dc..4270164 100644 --- a/tools/monster/gen-combat-monster.mjs +++ b/tools/monster/gen-combat-monster.mjs @@ -23,7 +23,7 @@ function writeCodeblock() { ContentProto: { Use: 'Json', Json: { CoreVersion: { Major: 0, Minor: 2 }, ScriptVersion: { Major: 1, Minor: 0 }, Description: '', Id: 'CombatMonster', Language: 1, Name: 'CombatMonster', Type: 1, Source: 0, Target: null, - Properties: [prop('string', 'EnemyId', '""'), prop('number', 'RegTries', '0')], + Properties: [prop('string', 'EnemyId', '""'), prop('string', 'Group', '"combat"'), prop('number', 'RegTries', '0')], Methods: [ method('OnBeginPlay', `self.RegTries = 0 local eventId = 0 @@ -31,7 +31,7 @@ local function reg() self.RegTries = self.RegTries + 1 local c = _EntityService:GetEntityByPath("/common") if c ~= nil and c.SlayDeckController ~= nil then - c.SlayDeckController:RegisterMonster(self.Entity, self.EnemyId) + c.SlayDeckController:RegisterMonster(self.Entity, self.EnemyId, self.Group) _TimerService:ClearTimer(eventId) elseif self.RegTries > 50 then _TimerService:ClearTimer(eventId) @@ -51,7 +51,7 @@ function patchMap(nn) { const tag = String(nn).padStart(2, '0'); const file = `map/map${tag}.map`; const map = JSON.parse(readFileSync(file, 'utf8')); - let count = 0; + let added = 0, kept = 0; for (const e of map.ContentProto.Entities.filter(isMonster)) { const comps = e.jsonString && e.jsonString['@components']; if (!Array.isArray(comps)) { @@ -59,16 +59,23 @@ function patchMap(nn) { continue; } const name = (e.jsonString && e.jsonString.name) || ''; - const enemyId = NAME_TO_ENEMY[name] || DEFAULT_ENEMY; - e.jsonString['@components'] = comps.filter((c) => c['@type'] !== 'script.CombatMonster'); - e.jsonString['@components'].push({ '@type': 'script.CombatMonster', Enable: true, EnemyId: enemyId }); + const existing = comps.find((c) => c['@type'] === 'script.CombatMonster'); + if (existing) { + // 사용자가 메이커에서 설정한 값 보존 — 누락된 키만 기본값 채움 + if (existing.Enable === undefined) existing.Enable = true; + if (existing.EnemyId === undefined) existing.EnemyId = NAME_TO_ENEMY[name] || DEFAULT_ENEMY; + if (existing.Group === undefined) existing.Group = 'combat'; + kept++; + } else { + comps.push({ '@type': 'script.CombatMonster', Enable: true, EnemyId: NAME_TO_ENEMY[name] || DEFAULT_ENEMY, Group: 'combat' }); + added++; + } const names = (e.componentNames || '').split(',').filter((s) => s && s !== 'script.CombatMonster'); names.push('script.CombatMonster'); e.componentNames = names.join(','); - count++; } writeFileSync(file, JSON.stringify(map, null, 2), 'utf8'); - return `map${tag}(${count})`; + return `map${tag}(+${added}/keep${kept})`; } writeCodeblock();