From 2cd672b47458af9bd9251f8757c509e13ba84526 Mon Sep 17 00:00:00 2001 From: gahusb Date: Fri, 12 Jun 2026 18:32:39 +0900 Subject: [PATCH 1/2] =?UTF-8?q?docs(motion):=20P12=20=EC=84=A4=EA=B3=84?= =?UTF-8?q?=C2=B7=EA=B3=84=ED=9A=8D=20=E2=80=94=20=EC=A0=84=ED=88=AC=20?= =?UTF-8?q?=EB=AA=A8=EC=85=98=20(=EA=B3=B5=EA=B2=A9/=ED=94=BC=EA=B2=A9/?= =?UTF-8?q?=EB=8F=85=EB=8E=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- .../plans/2026-06-12-combat-motion.md | 18 ++++++++++ .../specs/2026-06-12-combat-motion-design.md | 36 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 docs/superpowers/plans/2026-06-12-combat-motion.md create mode 100644 docs/superpowers/specs/2026-06-12-combat-motion-design.md diff --git a/docs/superpowers/plans/2026-06-12-combat-motion.md b/docs/superpowers/plans/2026-06-12-combat-motion.md new file mode 100644 index 0000000..e8cb3b2 --- /dev/null +++ b/docs/superpowers/plans/2026-06-12-combat-motion.md @@ -0,0 +1,18 @@ +# P12 — 전투 모션 구현 계획 + +> **For agentic workers:** REQUIRED SUB-SKILL: superpowers:executing-plans. 설계: `2026-06-12-combat-motion-design.md` + +### Task 1: 아바타 액션 프로브 (메이커) +- [ ] play 상태에서 `AvatarBodyActionSelectorComponent` 존재·`MapleAvatarBodyActionState.swingO1`(및 stabO1) 대입 pcall 성공 여부 로그 → 성공 멤버 베이크 / 전부 실패 시 런지 폴백만 사용 + +### Task 2: 생성기 — 모션 메서드 4종 + 훅 +- [ ] `PlayerAttackMotion`(아바타 ActionState pcall+복귀 / 폴백 런지) · `PlayerHitMotion`(넉백 틱) · `MonsterLunge(idx)` · `MonsterHitMotion(slot)`(hitClip 캐시 사용·stand 복귀·흔들림 폴백, `m.motionBusy` 가드) +- [ ] BuildMonsters: `hitClip`/`standClip` pcall 캐시 + `motionBusy=false` +- [ ] 훅 연결: PlayCard(공격)·EnemyActStep(런지·넉백·독틱)·DealDamageToTarget·PlayAoeFx·체인메일 반사 +- [ ] 커밋 + +### Task 3: 재생성·메이커 검증·PR +- [ ] 재생성·테스트 40건 유지 → refresh·빌드 0에러 → 플레이테스트(공격 스윙/몬스터 hit 클립/런지·넉백/독 틱) → 커밋·push → gitea-pr.mjs PR·머지 → 메모리 갱신 + +## Self-Review +- 모든 복귀 타이머 isvalid/alive 가드 ✓ / 시뮬 비대상 명시 ✓ / 산출물 검증 카운트만 ✓ diff --git a/docs/superpowers/specs/2026-06-12-combat-motion-design.md b/docs/superpowers/specs/2026-06-12-combat-motion-design.md new file mode 100644 index 0000000..2915203 --- /dev/null +++ b/docs/superpowers/specs/2026-06-12-combat-motion-design.md @@ -0,0 +1,36 @@ +# P12 — 전투 모션 설계 + +날짜: 2026-06-12 (사용자 승인 완료) +브랜치: `feature/p12-combat-motion` + +## 범위 + +플레이어·몬스터의 공격/피격 모션 (독 틱 피해 포함). 순수 클라이언트 연출 — 전투 수치·시뮬 비대상. + +## 모션 매핑 + +| 상황 | 대상 | 모션 | +|---|---|---| +| 카드 공격(단일·AoE) 사용 | 플레이어 | 아바타 공격 스윙 (`AvatarBodyActionSelectorComponent.ActionState`, pcall 가드 — 실패 시 전방 런지 폴백) → 0.4s 후 복귀 | +| 적 공격 행동 | 몬스터 | 플레이어 방향 런지 (x −0.35 → 0.18s 복귀) — 몹 다수가 공격 클립 미보유 → StS식 채택 | +| 몬스터 피격 (카드·AoE·물약·**독 틱**·체인메일 반사) | 몬스터 | `hit` 클립 재생(`SpriteRendererComponent.SpriteRUID` ← `StateAnimationComponent.ActionSheet["hit"]`, BuildMonsters에서 pcall 캐시) → 0.5s 후 stand 복귀. 클립 없으면 좌우 흔들림 폴백 | +| 플레이어 피격 (적 공격) | 플레이어 | 넉백 틱 (x −0.15 → 0.15s 복귀) | + +## 훅 지점 + +- `PlayCard` Attack 분기 → `PlayerAttackMotion()` +- `EnemyActStep` Attack 인텐트 → `MonsterLunge(idx)` + 피해 후 `PlayerHitMotion()`; 독 틱 → `MonsterHitMotion(idx)` +- `DealDamageToTarget` 피해 적용 후 → `MonsterHitMotion(slot)` (물약 화염병 포함 자동) +- `PlayAoeFx` 대상 루프 → `MonsterHitMotion(i)` +- `DealDamageToPlayer` 브론즈 체인메일 반사 → `MonsterHitMotion(attackerSlot)` +- 사망 연출은 기존(KillMonster SetVisible) 유지. 모션 중 사망 시 isvalid·alive 가드로 복귀 타이머 무해화 + +## 구현 메모 + +- `BuildMonsters`에서 `m.hitClip`/`m.standClip` pcall 캐시 (SyncDictionary 인덱싱 실패 대비) +- 모든 위치 복귀는 캡처한 원위치 기준 (이중 발동 시 어긋남 방지를 위해 모션 중 재발동은 위치 캡처 생략 — `m.motionBusy` 플래그) +- 아바타 enum `MapleAvatarBodyActionState` 멤버는 메이커 프로브로 확정 후 베이크 (후보: swingO1·stabO1) + +## 검증 + +메이커 플레이테스트: 카드 공격 시 아바타 스윙(또는 폴백) 로그·몬스터 hit 클립 전환 로그, 적 턴 런지·플레이어 넉백, 독 틱 모션. 빌드·런타임 0에러, 기존 테스트 40건 유지. From abd6d0005288008b8440d010a27348e67ccda067 Mon Sep 17 00:00:00 2001 From: gahusb Date: Fri, 12 Jun 2026 18:37:42 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat(motion):=20=EC=A0=84=ED=88=AC=20?= =?UTF-8?q?=EB=AA=A8=EC=85=98=20=E2=80=94=20=EA=B3=B5=EA=B2=A9/=ED=94=BC?= =?UTF-8?q?=EA=B2=A9/=EB=8F=85=EB=8E=80=20(=EC=83=9D=EC=84=B1=EA=B8=B0+?= =?UTF-8?q?=EC=82=B0=EC=B6=9C=EB=AC=BC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - PlayerAttackMotion(StateComponent ATTACK→IDLE)·PlayerHitMotion(HIT+넉백 틱) - MonsterLunge(공격 시 런지)·MonsterHitMotion(hit 클립 스왑→stand 복귀, 폴백 흔들림) - BuildMonsters에 hit/stand 클립 pcall 캐시·motionBusy - 훅: PlayCard·DealDamageToTarget·PlayAoeFx·독 틱·체인메일 반사·EnemyActStep Co-Authored-By: Claude Opus 4.8 (1M context) --- RootDesk/MyDesk/SlayDeckController.codeblock | 88 ++++++++++++++-- tools/deck/gen-slaydeck.mjs | 102 +++++++++++++++++++ 2 files changed, 184 insertions(+), 6 deletions(-) diff --git a/RootDesk/MyDesk/SlayDeckController.codeblock b/RootDesk/MyDesk/SlayDeckController.codeblock index 6b3b506..d5670bd 100644 --- a/RootDesk/MyDesk/SlayDeckController.codeblock +++ b/RootDesk/MyDesk/SlayDeckController.codeblock @@ -995,7 +995,7 @@ "Name": null }, "Arguments": [], - "Code": "self.Monsters = {}\nlocal g = \"combat\"\nlocal node = self.MapNodes[self.CurrentNodeId]\nif node ~= nil and node.type ~= nil then g = node.type end\nlocal pmap = \"\"\nlocal lp = _UserService.LocalPlayer\nif lp ~= nil and lp.CurrentMapName ~= nil then pmap = lp.CurrentMapName end\nlocal reg = self.Registered or {}\nfor i = 1, #reg do\n\tif reg[i].entity ~= nil and isvalid(reg[i].entity) then\n\t\treg[i].entity:SetVisible(false)\n\tend\nend\nlocal list = {}\nfor i = 1, #reg do\n\tlocal r = reg[i]\n\tif r.entity ~= nil and isvalid(r.entity) and r.group == g and (r.map == nil or r.map == \"\" or pmap == \"\" or r.map == pmap) then\n\t\tlocal x = 0\n\t\tif r.entity.TransformComponent ~= nil then\n\t\t\tx = r.entity.TransformComponent.WorldPosition.x\n\t\tend\n\t\ttable.insert(list, { entity = r.entity, enemyId = r.enemyId, x = x })\n\tend\nend\ntable.sort(list, function(a, b) return a.x < b.x end)\nlocal mult = 1 + (self.Floor - 1) * 0.6\nif g == \"elite\" or g == \"boss\" then\n\tmult = mult + self:AscEliteBonus()\nend\nlocal n = #list\nif n > 4 then n = 4 end\nfor i = 1, n do\n\tlocal item = list[i]\n\tlocal e = self.Enemies[item.enemyId]\n\tif e == nil then e = { name = item.enemyId, maxHp = 10, intents = { { kind = \"Attack\", value = 5 } } } end\n\tlocal intents = {}\n\tfor k = 1, #e.intents do\n\t\tlocal v = e.intents[k].value\n\t\tif e.intents[k].kind == \"Attack\" then\n\t\t\tv = math.floor(v * mult * self:AscAtkMult())\n\t\telseif e.intents[k].kind ~= \"Debuff\" then\n\t\t\tv = math.floor(v * mult)\n\t\tend\n\t\tintents[k] = { kind = e.intents[k].kind, value = v, effect = e.intents[k].effect }\n\tend\n\tlocal maxHp = math.floor(e.maxHp * mult * self:AscHpMult())\n\tself.Monsters[i] = { entity = item.entity, enemyId = item.enemyId, name = e.name,\n\t\thp = maxHp, maxHp = maxHp, block = 0, str = 0, weak = 0, vuln = 0, poison = 0,\n\t\tintents = intents, intentIdx = 1, alive = true, slot = i }\n\tself:ReviveMonsterEntity(item.entity)\n\tself:PositionMonsterSlot(i)\nend\nself.TargetIndex = 1", + "Code": "self.Monsters = {}\nlocal g = \"combat\"\nlocal node = self.MapNodes[self.CurrentNodeId]\nif node ~= nil and node.type ~= nil then g = node.type end\nlocal pmap = \"\"\nlocal lp = _UserService.LocalPlayer\nif lp ~= nil and lp.CurrentMapName ~= nil then pmap = lp.CurrentMapName end\nlocal reg = self.Registered or {}\nfor i = 1, #reg do\n\tif reg[i].entity ~= nil and isvalid(reg[i].entity) then\n\t\treg[i].entity:SetVisible(false)\n\tend\nend\nlocal list = {}\nfor i = 1, #reg do\n\tlocal r = reg[i]\n\tif r.entity ~= nil and isvalid(r.entity) and r.group == g and (r.map == nil or r.map == \"\" or pmap == \"\" or r.map == pmap) then\n\t\tlocal x = 0\n\t\tif r.entity.TransformComponent ~= nil then\n\t\t\tx = r.entity.TransformComponent.WorldPosition.x\n\t\tend\n\t\ttable.insert(list, { entity = r.entity, enemyId = r.enemyId, x = x })\n\tend\nend\ntable.sort(list, function(a, b) return a.x < b.x end)\nlocal mult = 1 + (self.Floor - 1) * 0.6\nif g == \"elite\" or g == \"boss\" then\n\tmult = mult + self:AscEliteBonus()\nend\nlocal n = #list\nif n > 4 then n = 4 end\nfor i = 1, n do\n\tlocal item = list[i]\n\tlocal e = self.Enemies[item.enemyId]\n\tif e == nil then e = { name = item.enemyId, maxHp = 10, intents = { { kind = \"Attack\", value = 5 } } } end\n\tlocal intents = {}\n\tfor k = 1, #e.intents do\n\t\tlocal v = e.intents[k].value\n\t\tif e.intents[k].kind == \"Attack\" then\n\t\t\tv = math.floor(v * mult * self:AscAtkMult())\n\t\telseif e.intents[k].kind ~= \"Debuff\" then\n\t\t\tv = math.floor(v * mult)\n\t\tend\n\t\tintents[k] = { kind = e.intents[k].kind, value = v, effect = e.intents[k].effect }\n\tend\n\tlocal maxHp = math.floor(e.maxHp * mult * self:AscHpMult())\n\tlocal hitClip = nil\n\tlocal standClip = nil\n\tif item.entity.StateAnimationComponent ~= nil then\n\t\tpcall(function()\n\t\t\thitClip = item.entity.StateAnimationComponent.ActionSheet[\"hit\"]\n\t\t\tstandClip = item.entity.StateAnimationComponent.ActionSheet[\"stand\"]\n\t\tend)\n\tend\n\tself.Monsters[i] = { entity = item.entity, enemyId = item.enemyId, name = e.name,\n\t\thp = maxHp, maxHp = maxHp, block = 0, str = 0, weak = 0, vuln = 0, poison = 0,\n\t\thitClip = hitClip, standClip = standClip, motionBusy = false,\n\t\tintents = intents, intentIdx = 1, alive = true, slot = i }\n\tself:ReviveMonsterEntity(item.entity)\n\tself:PositionMonsterSlot(i)\nend\nself.TargetIndex = 1", "Scope": 2, "ExecSpace": 6, "Attributes": [], @@ -1515,7 +1515,7 @@ "Name": "slot" } ], - "Code": "if self.CombatOver == true or self.FxBusy == true or self.TurnBusy == true then\n\treturn\nend\nif self.Hand == nil then\n\treturn\nend\nlocal cardId = self.Hand[slot]\nif cardId == nil then\n\treturn\nend\nlocal c = self.Cards[cardId]\nif c == nil then\n\treturn\nend\nif self.Energy < c.cost then\n\tself:Toast(\"에너지가 부족합니다\")\n\treturn\nend\nself.Energy = self.Energy - c.cost\nif c.kind == \"Attack\" then\n\tif c.damage ~= nil then\n\t\tlocal total = 0\n\t\tlocal hitN = c.hits or 1\n\t\tfor h = 1, hitN do\n\t\t\ttotal = total + self:CalcPlayerAttack(c.damage)\n\t\tend\n\t\tif c.aoe == true then\n\t\t\tself:PlayAoeFx(c.image, total)\n\t\telse\n\t\t\tself:PlayAttackFx(self.TargetIndex, c.image, total, c.pierce == true)\n\t\tend\n\tend\n\tif c.block ~= nil then\n\t\tself.PlayerBlock = self.PlayerBlock + c.block\n\tend\n\tself:ApplyRelics(\"cardPlayed\")\nelseif c.kind == \"Skill\" then\n\tif c.block ~= nil then\n\t\tself.PlayerBlock = self.PlayerBlock + c.block\n\tend\nelseif c.kind == \"Power\" then\n\tif c.powerEffect ~= nil then\n\t\ttable.insert(self.PlayerPowers, cardId)\n\tend\nend\nif c.strength ~= nil then\n\tself.PlayerStr = self.PlayerStr + c.strength\nend\nif c.selfVuln ~= nil then\n\tself.PlayerVuln = self.PlayerVuln + c.selfVuln\nend\nif c.heal ~= nil then\n\tself.PlayerHp = math.min(self.PlayerHp + c.heal, self.PlayerMaxHp)\nend\nif c.weak ~= nil or c.vuln ~= nil or c.poison ~= nil then\n\tlocal tm = self.Monsters[self.TargetIndex]\n\tif tm ~= nil and tm.alive == true then\n\t\tif c.weak ~= nil then tm.weak = tm.weak + c.weak end\n\t\tif c.poison ~= nil then tm.poison = (tm.poison or 0) + c.poison end\n\t\tif c.vuln ~= nil then\n\t\t\ttm.vuln = tm.vuln + c.vuln\n\t\t\tif self:HasRelic(\"championBelt\") then\n\t\t\t\ttm.weak = tm.weak + 1\n\t\t\tend\n\t\tend\n\tend\nend\ntable.remove(self.Hand, slot)\nif c.kind ~= \"Power\" then\n\ttable.insert(self.DiscardPile, cardId)\nend\nif c.draw ~= nil then\n\tself:DrawCards(c.draw)\nend\nself:RenderHand(false)\nself:RenderPiles()\nself:RenderCombat()\nself:CheckCombatEnd()", + "Code": "if self.CombatOver == true or self.FxBusy == true or self.TurnBusy == true then\n\treturn\nend\nif self.Hand == nil then\n\treturn\nend\nlocal cardId = self.Hand[slot]\nif cardId == nil then\n\treturn\nend\nlocal c = self.Cards[cardId]\nif c == nil then\n\treturn\nend\nif self.Energy < c.cost then\n\tself:Toast(\"에너지가 부족합니다\")\n\treturn\nend\nself.Energy = self.Energy - c.cost\nif c.kind == \"Attack\" then\n\tif c.damage ~= nil then\n\t\tself:PlayerAttackMotion()\n\t\tlocal total = 0\n\t\tlocal hitN = c.hits or 1\n\t\tfor h = 1, hitN do\n\t\t\ttotal = total + self:CalcPlayerAttack(c.damage)\n\t\tend\n\t\tif c.aoe == true then\n\t\t\tself:PlayAoeFx(c.image, total)\n\t\telse\n\t\t\tself:PlayAttackFx(self.TargetIndex, c.image, total, c.pierce == true)\n\t\tend\n\tend\n\tif c.block ~= nil then\n\t\tself.PlayerBlock = self.PlayerBlock + c.block\n\tend\n\tself:ApplyRelics(\"cardPlayed\")\nelseif c.kind == \"Skill\" then\n\tif c.block ~= nil then\n\t\tself.PlayerBlock = self.PlayerBlock + c.block\n\tend\nelseif c.kind == \"Power\" then\n\tif c.powerEffect ~= nil then\n\t\ttable.insert(self.PlayerPowers, cardId)\n\tend\nend\nif c.strength ~= nil then\n\tself.PlayerStr = self.PlayerStr + c.strength\nend\nif c.selfVuln ~= nil then\n\tself.PlayerVuln = self.PlayerVuln + c.selfVuln\nend\nif c.heal ~= nil then\n\tself.PlayerHp = math.min(self.PlayerHp + c.heal, self.PlayerMaxHp)\nend\nif c.weak ~= nil or c.vuln ~= nil or c.poison ~= nil then\n\tlocal tm = self.Monsters[self.TargetIndex]\n\tif tm ~= nil and tm.alive == true then\n\t\tif c.weak ~= nil then tm.weak = tm.weak + c.weak end\n\t\tif c.poison ~= nil then tm.poison = (tm.poison or 0) + c.poison end\n\t\tif c.vuln ~= nil then\n\t\t\ttm.vuln = tm.vuln + c.vuln\n\t\t\tif self:HasRelic(\"championBelt\") then\n\t\t\t\ttm.weak = tm.weak + 1\n\t\t\tend\n\t\tend\n\tend\nend\ntable.remove(self.Hand, slot)\nif c.kind ~= \"Power\" then\n\ttable.insert(self.DiscardPile, cardId)\nend\nif c.draw ~= nil then\n\tself:DrawCards(c.draw)\nend\nself:RenderHand(false)\nself:RenderPiles()\nself:RenderCombat()\nself:CheckCombatEnd()", "Scope": 2, "ExecSpace": 6, "Attributes": [], @@ -1681,7 +1681,7 @@ "Name": "pierce" } ], - "Code": "local m = self.Monsters[self.TargetIndex]\nif m == nil or m.alive ~= true then\n\tm = nil\n\tfor i = 1, #self.Monsters do\n\t\tif self.Monsters[i].alive == true then m = self.Monsters[i]; self.TargetIndex = i; break end\n\tend\nend\nif m == nil then\n\treturn\nend\nlocal dmg = amount\nif m.vuln > 0 then\n\tdmg = math.floor(dmg * 1.5)\nend\nif m.block > 0 and pierce ~= true then\n\tlocal absorbed = math.min(m.block, dmg)\n\tm.block = m.block - absorbed\n\tdmg = dmg - absorbed\nend\nm.hp = m.hp - dmg\nif m.hp <= 0 then\n\tm.hp = 0\n\tself:KillMonster(m.slot)\nend", + "Code": "local m = self.Monsters[self.TargetIndex]\nif m == nil or m.alive ~= true then\n\tm = nil\n\tfor i = 1, #self.Monsters do\n\t\tif self.Monsters[i].alive == true then m = self.Monsters[i]; self.TargetIndex = i; break end\n\tend\nend\nif m == nil then\n\treturn\nend\nlocal dmg = amount\nif m.vuln > 0 then\n\tdmg = math.floor(dmg * 1.5)\nend\nif m.block > 0 and pierce ~= true then\n\tlocal absorbed = math.min(m.block, dmg)\n\tm.block = m.block - absorbed\n\tdmg = dmg - absorbed\nend\nm.hp = m.hp - dmg\nself:MonsterHitMotion(m.slot)\nif m.hp <= 0 then\n\tm.hp = 0\n\tself:KillMonster(m.slot)\nend", "Scope": 2, "ExecSpace": 6, "Attributes": [], @@ -1755,7 +1755,7 @@ "Name": "damage" } ], - "Code": "self.FxBusy = true\nlocal fx = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CombatHud/SkillFx\")\nif fx ~= nil then\n\tif fx.SpriteGUIRendererComponent ~= nil and image ~= nil and image ~= \"\" then\n\t\tfx.SpriteGUIRendererComponent.ImageRUID = image\n\tend\n\tif fx.UITransformComponent ~= nil then\n\t\tfx.UITransformComponent.anchoredPosition = Vector2(300, 60)\n\tend\n\tfx.Enable = true\nend\n_TimerService:SetTimerOnce(function()\n\tif fx ~= nil then fx.Enable = false end\n\tself.FxBusy = false\n\tfor i = 1, #self.Monsters do\n\t\tlocal m = self.Monsters[i]\n\t\tif m ~= nil and m.alive == true then\n\t\t\tlocal dmg = damage\n\t\t\tif m.vuln > 0 then\n\t\t\t\tdmg = math.floor(dmg * 1.5)\n\t\t\tend\n\t\t\tif m.block > 0 then\n\t\t\t\tlocal absorbed = math.min(m.block, dmg)\n\t\t\t\tm.block = m.block - absorbed\n\t\t\t\tdmg = dmg - absorbed\n\t\t\tend\n\t\t\tm.hp = m.hp - dmg\n\t\t\tself:ShowDmgPop(i, dmg)\n\t\t\tif m.hp <= 0 then\n\t\t\t\tm.hp = 0\n\t\t\t\tself:KillMonster(m.slot)\n\t\t\tend\n\t\tend\n\tend\n\tself:RenderCombat()\n\tself:CheckCombatEnd()\nend, 0.35)", + "Code": "self.FxBusy = true\nlocal fx = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CombatHud/SkillFx\")\nif fx ~= nil then\n\tif fx.SpriteGUIRendererComponent ~= nil and image ~= nil and image ~= \"\" then\n\t\tfx.SpriteGUIRendererComponent.ImageRUID = image\n\tend\n\tif fx.UITransformComponent ~= nil then\n\t\tfx.UITransformComponent.anchoredPosition = Vector2(300, 60)\n\tend\n\tfx.Enable = true\nend\n_TimerService:SetTimerOnce(function()\n\tif fx ~= nil then fx.Enable = false end\n\tself.FxBusy = false\n\tfor i = 1, #self.Monsters do\n\t\tlocal m = self.Monsters[i]\n\t\tif m ~= nil and m.alive == true then\n\t\t\tlocal dmg = damage\n\t\t\tif m.vuln > 0 then\n\t\t\t\tdmg = math.floor(dmg * 1.5)\n\t\t\tend\n\t\t\tif m.block > 0 then\n\t\t\t\tlocal absorbed = math.min(m.block, dmg)\n\t\t\t\tm.block = m.block - absorbed\n\t\t\t\tdmg = dmg - absorbed\n\t\t\tend\n\t\t\tm.hp = m.hp - dmg\n\t\t\tself:ShowDmgPop(i, dmg)\n\t\t\tself:MonsterHitMotion(i)\n\t\t\tif m.hp <= 0 then\n\t\t\t\tm.hp = 0\n\t\t\t\tself:KillMonster(m.slot)\n\t\t\tend\n\t\tend\n\tend\n\tself:RenderCombat()\n\tself:CheckCombatEnd()\nend, 0.35)", "Scope": 2, "ExecSpace": 6, "Attributes": [], @@ -1808,7 +1808,7 @@ "Name": "attackerSlot" } ], - "Code": "local dmg = amount\nif self.PlayerBlock > 0 then\n\tlocal absorbed = math.min(self.PlayerBlock, dmg)\n\tself.PlayerBlock = self.PlayerBlock - absorbed\n\tdmg = dmg - absorbed\nend\nif dmg > 0 then\n\tself.PlayerHp = self.PlayerHp - dmg\n\tif self:HasRelic(\"bronzeScales\") and attackerSlot ~= nil and attackerSlot > 0 then\n\t\tlocal am = self.Monsters[attackerSlot]\n\t\tif am ~= nil and am.alive == true then\n\t\t\tam.hp = am.hp - 3\n\t\t\tif am.hp <= 0 then\n\t\t\t\tam.hp = 0\n\t\t\t\tself:KillMonster(am.slot)\n\t\t\tend\n\t\tend\n\tend\n\tif self:HasRelic(\"selfFormingClay\") then\n\t\tself.ClayBlockNext = self.ClayBlockNext + 3\n\tend\n\tif self:HasRelic(\"centennialPuzzle\") and self.FirstHpLossDone == false then\n\t\tself.FirstHpLossDone = true\n\t\tself:DrawCards(3)\n\t\tself:RenderHand(false)\n\tend\nend\nif self.PlayerHp < 0 then\n\tself.PlayerHp = 0\nend", + "Code": "local dmg = amount\nif self.PlayerBlock > 0 then\n\tlocal absorbed = math.min(self.PlayerBlock, dmg)\n\tself.PlayerBlock = self.PlayerBlock - absorbed\n\tdmg = dmg - absorbed\nend\nif dmg > 0 then\n\tself.PlayerHp = self.PlayerHp - dmg\n\tif self:HasRelic(\"bronzeScales\") and attackerSlot ~= nil and attackerSlot > 0 then\n\t\tlocal am = self.Monsters[attackerSlot]\n\t\tif am ~= nil and am.alive == true then\n\t\t\tam.hp = am.hp - 3\n\t\t\tself:MonsterHitMotion(am.slot)\n\t\t\tif am.hp <= 0 then\n\t\t\t\tam.hp = 0\n\t\t\t\tself:KillMonster(am.slot)\n\t\t\tend\n\t\tend\n\tend\n\tif self:HasRelic(\"selfFormingClay\") then\n\t\tself.ClayBlockNext = self.ClayBlockNext + 3\n\tend\n\tif self:HasRelic(\"centennialPuzzle\") and self.FirstHpLossDone == false then\n\t\tself.FirstHpLossDone = true\n\t\tself:DrawCards(3)\n\t\tself:RenderHand(false)\n\tend\nend\nif self.PlayerHp < 0 then\n\tself.PlayerHp = 0\nend", "Scope": 2, "ExecSpace": 6, "Attributes": [], @@ -1846,7 +1846,7 @@ "Name": "fromIndex" } ], - "Code": "local idx = 0\nfor i = fromIndex, #self.Monsters do\n\tif self.Monsters[i].alive == true then idx = i; break end\nend\nif idx == 0 or self.PlayerHp <= 0 then\n\tself:FinishEnemyTurn()\n\treturn\nend\nlocal m = self.Monsters[idx]\nlocal base = \"/ui/DefaultGroup/CombatHud/MonsterSlot\" .. tostring(idx)\nself:SetEntityEnabled(base .. \"/ActFrame\", true)\n_TimerService:SetTimerOnce(function()\n\tif m.poison ~= nil and m.poison > 0 then\n\t\tm.hp = m.hp - m.poison\n\t\tself:ShowDmgPop(idx, m.poison)\n\t\tm.poison = m.poison - 1\n\t\tif m.hp <= 0 then\n\t\t\tm.hp = 0\n\t\t\tself:KillMonster(m.slot)\n\t\t\tself:RenderCombat()\n\t\t\tself:SetEntityEnabled(base .. \"/ActFrame\", false)\n\t\t\t_TimerService:SetTimerOnce(function() self:EnemyActStep(idx + 1) end, 0.15)\n\t\t\treturn\n\t\tend\n\tend\n\tm.block = 0\n\tlocal intent = m.intents[m.intentIdx]\n\tif intent ~= nil then\n\t\tif intent.kind == \"Attack\" then\n\t\t\tlocal atk = intent.value + m.str\n\t\t\tif m.weak > 0 then\n\t\t\t\tatk = math.floor(atk * 0.75)\n\t\t\tend\n\t\t\tif self.PlayerVuln > 0 then\n\t\t\t\tatk = math.floor(atk * 1.5)\n\t\t\tend\n\t\t\tlocal before = self.PlayerHp\n\t\t\tself:DealDamageToPlayer(atk, idx)\n\t\t\tself:ShowPlayerDmgPop(before - self.PlayerHp)\n\t\telseif intent.kind == \"Defend\" then\n\t\t\tm.block = m.block + intent.value\n\t\telseif intent.kind == \"Debuff\" then\n\t\t\tif intent.effect == \"weak\" then\n\t\t\t\tself.PlayerWeak = self.PlayerWeak + intent.value\n\t\t\telseif intent.effect == \"vuln\" then\n\t\t\t\tself.PlayerVuln = self.PlayerVuln + intent.value\n\t\t\tend\n\t\tend\n\tend\n\tm.intentIdx = m.intentIdx + 1\n\tif m.intentIdx > #m.intents then\n\t\tm.intentIdx = 1\n\tend\n\tif m.weak > 0 then m.weak = m.weak - 1 end\n\tif m.vuln > 0 then m.vuln = m.vuln - 1 end\n\tself:RenderCombat()\n\tself:SetEntityEnabled(base .. \"/ActFrame\", false)\n\t_TimerService:SetTimerOnce(function() self:EnemyActStep(idx + 1) end, 0.15)\nend, 0.45)", + "Code": "local idx = 0\nfor i = fromIndex, #self.Monsters do\n\tif self.Monsters[i].alive == true then idx = i; break end\nend\nif idx == 0 or self.PlayerHp <= 0 then\n\tself:FinishEnemyTurn()\n\treturn\nend\nlocal m = self.Monsters[idx]\nlocal base = \"/ui/DefaultGroup/CombatHud/MonsterSlot\" .. tostring(idx)\nself:SetEntityEnabled(base .. \"/ActFrame\", true)\n_TimerService:SetTimerOnce(function()\n\tif m.poison ~= nil and m.poison > 0 then\n\t\tm.hp = m.hp - m.poison\n\t\tself:ShowDmgPop(idx, m.poison)\n\t\tself:MonsterHitMotion(idx)\n\t\tm.poison = m.poison - 1\n\t\tif m.hp <= 0 then\n\t\t\tm.hp = 0\n\t\t\tself:KillMonster(m.slot)\n\t\t\tself:RenderCombat()\n\t\t\tself:SetEntityEnabled(base .. \"/ActFrame\", false)\n\t\t\t_TimerService:SetTimerOnce(function() self:EnemyActStep(idx + 1) end, 0.15)\n\t\t\treturn\n\t\tend\n\tend\n\tm.block = 0\n\tlocal intent = m.intents[m.intentIdx]\n\tif intent ~= nil then\n\t\tif intent.kind == \"Attack\" then\n\t\t\tself:MonsterLunge(idx)\n\t\t\tlocal atk = intent.value + m.str\n\t\t\tif m.weak > 0 then\n\t\t\t\tatk = math.floor(atk * 0.75)\n\t\t\tend\n\t\t\tif self.PlayerVuln > 0 then\n\t\t\t\tatk = math.floor(atk * 1.5)\n\t\t\tend\n\t\t\tlocal before = self.PlayerHp\n\t\t\tself:DealDamageToPlayer(atk, idx)\n\t\t\tself:ShowPlayerDmgPop(before - self.PlayerHp)\n\t\t\tself:PlayerHitMotion()\n\t\telseif intent.kind == \"Defend\" then\n\t\t\tm.block = m.block + intent.value\n\t\telseif intent.kind == \"Debuff\" then\n\t\t\tif intent.effect == \"weak\" then\n\t\t\t\tself.PlayerWeak = self.PlayerWeak + intent.value\n\t\t\telseif intent.effect == \"vuln\" then\n\t\t\t\tself.PlayerVuln = self.PlayerVuln + intent.value\n\t\t\tend\n\t\tend\n\tend\n\tm.intentIdx = m.intentIdx + 1\n\tif m.intentIdx > #m.intents then\n\t\tm.intentIdx = 1\n\tend\n\tif m.weak > 0 then m.weak = m.weak - 1 end\n\tif m.vuln > 0 then m.vuln = m.vuln - 1 end\n\tself:RenderCombat()\n\tself:SetEntityEnabled(base .. \"/ActFrame\", false)\n\t_TimerService:SetTimerOnce(function() self:EnemyActStep(idx + 1) end, 0.15)\nend, 0.45)", "Scope": 2, "ExecSpace": 6, "Attributes": [], @@ -2161,6 +2161,82 @@ "Attributes": [], "Name": "ShowPlayerDmgPop" }, + { + "Return": { + "Type": "void", + "DefaultValue": null, + "SyncDirection": 0, + "Attributes": [], + "Name": null + }, + "Arguments": [], + "Code": "local lp = _UserService.LocalPlayer\nif lp == nil or lp.StateComponent == nil then\n\treturn\nend\npcall(function() lp.StateComponent:ChangeState(\"ATTACK\") end)\n_TimerService:SetTimerOnce(function()\n\tif lp ~= nil and isvalid(lp) and lp.StateComponent ~= nil then\n\t\tpcall(function() lp.StateComponent:ChangeState(\"IDLE\") end)\n\tend\nend, 0.5)", + "Scope": 2, + "ExecSpace": 6, + "Attributes": [], + "Name": "PlayerAttackMotion" + }, + { + "Return": { + "Type": "void", + "DefaultValue": null, + "SyncDirection": 0, + "Attributes": [], + "Name": null + }, + "Arguments": [], + "Code": "local lp = _UserService.LocalPlayer\nif lp == nil then\n\treturn\nend\nif lp.StateComponent ~= nil then\n\tpcall(function() lp.StateComponent:ChangeState(\"HIT\") end)\nend\nlocal tr = lp.TransformComponent\nif tr == nil then\n\treturn\nend\nlocal p = tr.Position\ntr.Position = Vector3(p.x - 0.15, p.y, p.z)\n_TimerService:SetTimerOnce(function()\n\tif lp ~= nil and isvalid(lp) and lp.TransformComponent ~= nil then\n\t\tlp.TransformComponent.Position = Vector3(p.x, p.y, p.z)\n\tend\nend, 0.15)", + "Scope": 2, + "ExecSpace": 6, + "Attributes": [], + "Name": "PlayerHitMotion" + }, + { + "Return": { + "Type": "void", + "DefaultValue": null, + "SyncDirection": 0, + "Attributes": [], + "Name": null + }, + "Arguments": [ + { + "Type": "number", + "DefaultValue": null, + "SyncDirection": 0, + "Attributes": [], + "Name": "idx" + } + ], + "Code": "local m = self.Monsters[idx]\nif m == nil or m.alive ~= true or m.entity == nil or not isvalid(m.entity) then\n\treturn\nend\nif m.motionBusy == true then\n\treturn\nend\nm.motionBusy = true\nlocal e = m.entity\nlocal tr = e.TransformComponent\nif tr == nil then\n\tm.motionBusy = false\n\treturn\nend\nlocal p = tr.Position\ntr.Position = Vector3(p.x - 0.35, p.y, p.z)\n_TimerService:SetTimerOnce(function()\n\tif isvalid(e) and e.TransformComponent ~= nil then\n\t\te.TransformComponent.Position = Vector3(p.x, p.y, p.z)\n\tend\n\tm.motionBusy = false\nend, 0.18)", + "Scope": 2, + "ExecSpace": 6, + "Attributes": [], + "Name": "MonsterLunge" + }, + { + "Return": { + "Type": "void", + "DefaultValue": null, + "SyncDirection": 0, + "Attributes": [], + "Name": null + }, + "Arguments": [ + { + "Type": "number", + "DefaultValue": null, + "SyncDirection": 0, + "Attributes": [], + "Name": "slot" + } + ], + "Code": "local m = self.Monsters[slot]\nif m == nil or m.alive ~= true or m.entity == nil or not isvalid(m.entity) then\n\treturn\nend\nlocal e = m.entity\nif m.hitClip ~= nil and e.SpriteRendererComponent ~= nil then\n\te.SpriteRendererComponent.SpriteRUID = m.hitClip\n\t_TimerService:SetTimerOnce(function()\n\t\tif isvalid(e) and e.SpriteRendererComponent ~= nil and m.alive == true and m.standClip ~= nil then\n\t\t\te.SpriteRendererComponent.SpriteRUID = m.standClip\n\t\tend\n\tend, 0.5)\nelse\n\tif m.motionBusy == true then\n\t\treturn\n\tend\n\tm.motionBusy = true\n\tlocal tr = e.TransformComponent\n\tif tr == nil then\n\t\tm.motionBusy = false\n\t\treturn\n\tend\n\tlocal p = tr.Position\n\tlocal seq = { 0.12, -0.12, 0 }\n\tfor i = 1, #seq do\n\t\tlocal dx = seq[i]\n\t\t_TimerService:SetTimerOnce(function()\n\t\t\tif isvalid(e) and e.TransformComponent ~= nil then\n\t\t\t\te.TransformComponent.Position = Vector3(p.x + dx, p.y, p.z)\n\t\t\tend\n\t\t\tif i == #seq then\n\t\t\t\tm.motionBusy = false\n\t\t\tend\n\t\tend, 0.06 * i)\n\tend\nend", + "Scope": 2, + "ExecSpace": 6, + "Attributes": [], + "Name": "MonsterHitMotion" + }, { "Return": { "Type": "void", diff --git a/tools/deck/gen-slaydeck.mjs b/tools/deck/gen-slaydeck.mjs index e762533..a943f0a 100644 --- a/tools/deck/gen-slaydeck.mjs +++ b/tools/deck/gen-slaydeck.mjs @@ -2760,8 +2760,17 @@ for i = 1, n do intents[k] = { kind = e.intents[k].kind, value = v, effect = e.intents[k].effect } end local maxHp = math.floor(e.maxHp * mult * self:AscHpMult()) + local hitClip = nil + local standClip = nil + if item.entity.StateAnimationComponent ~= nil then + pcall(function() + hitClip = item.entity.StateAnimationComponent.ActionSheet["hit"] + standClip = item.entity.StateAnimationComponent.ActionSheet["stand"] + end) + end self.Monsters[i] = { entity = item.entity, enemyId = item.enemyId, name = e.name, hp = maxHp, maxHp = maxHp, block = 0, str = 0, weak = 0, vuln = 0, poison = 0, + hitClip = hitClip, standClip = standClip, motionBusy = false, intents = intents, intentIdx = 1, alive = true, slot = i } self:ReviveMonsterEntity(item.entity) self:PositionMonsterSlot(i) @@ -3241,6 +3250,7 @@ end self.Energy = self.Energy - c.cost if c.kind == "Attack" then if c.damage ~= nil then + self:PlayerAttackMotion() local total = 0 local hitN = c.hits or 1 for h = 1, hitN do @@ -3391,6 +3401,7 @@ if m.block > 0 and pierce ~= true then dmg = dmg - absorbed end m.hp = m.hp - dmg +self:MonsterHitMotion(m.slot) if m.hp <= 0 then m.hp = 0 self:KillMonster(m.slot) @@ -3464,6 +3475,7 @@ _TimerService:SetTimerOnce(function() end m.hp = m.hp - dmg self:ShowDmgPop(i, dmg) + self:MonsterHitMotion(i) if m.hp <= 0 then m.hp = 0 self:KillMonster(m.slot) @@ -3501,6 +3513,7 @@ if dmg > 0 then local am = self.Monsters[attackerSlot] if am ~= nil and am.alive == true then am.hp = am.hp - 3 + self:MonsterHitMotion(am.slot) if am.hp <= 0 then am.hp = 0 self:KillMonster(am.slot) @@ -3539,6 +3552,7 @@ _TimerService:SetTimerOnce(function() if m.poison ~= nil and m.poison > 0 then m.hp = m.hp - m.poison self:ShowDmgPop(idx, m.poison) + self:MonsterHitMotion(idx) m.poison = m.poison - 1 if m.hp <= 0 then m.hp = 0 @@ -3553,6 +3567,7 @@ _TimerService:SetTimerOnce(function() local intent = m.intents[m.intentIdx] if intent ~= nil then if intent.kind == "Attack" then + self:MonsterLunge(idx) local atk = intent.value + m.str if m.weak > 0 then atk = math.floor(atk * 0.75) @@ -3563,6 +3578,7 @@ _TimerService:SetTimerOnce(function() local before = self.PlayerHp self:DealDamageToPlayer(atk, idx) self:ShowPlayerDmgPop(before - self.PlayerHp) + self:PlayerHitMotion() elseif intent.kind == "Defend" then m.block = m.block + intent.value elseif intent.kind == "Debuff" then @@ -3829,6 +3845,92 @@ else end self:SetEntityEnabled(base, true) _TimerService:SetTimerOnce(function() self:SetEntityEnabled(base, false) end, 0.6)`, [{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'amount' }]), + method('PlayerAttackMotion', `local lp = _UserService.LocalPlayer +if lp == nil or lp.StateComponent == nil then + return +end +pcall(function() lp.StateComponent:ChangeState("ATTACK") end) +_TimerService:SetTimerOnce(function() + if lp ~= nil and isvalid(lp) and lp.StateComponent ~= nil then + pcall(function() lp.StateComponent:ChangeState("IDLE") end) + end +end, 0.5)`), + method('PlayerHitMotion', `local lp = _UserService.LocalPlayer +if lp == nil then + return +end +if lp.StateComponent ~= nil then + pcall(function() lp.StateComponent:ChangeState("HIT") end) +end +local tr = lp.TransformComponent +if tr == nil then + return +end +local p = tr.Position +tr.Position = Vector3(p.x - 0.15, p.y, p.z) +_TimerService:SetTimerOnce(function() + if lp ~= nil and isvalid(lp) and lp.TransformComponent ~= nil then + lp.TransformComponent.Position = Vector3(p.x, p.y, p.z) + end +end, 0.15)`), + method('MonsterLunge', `local m = self.Monsters[idx] +if m == nil or m.alive ~= true or m.entity == nil or not isvalid(m.entity) then + return +end +if m.motionBusy == true then + return +end +m.motionBusy = true +local e = m.entity +local tr = e.TransformComponent +if tr == nil then + m.motionBusy = false + return +end +local p = tr.Position +tr.Position = Vector3(p.x - 0.35, p.y, p.z) +_TimerService:SetTimerOnce(function() + if isvalid(e) and e.TransformComponent ~= nil then + e.TransformComponent.Position = Vector3(p.x, p.y, p.z) + end + m.motionBusy = false +end, 0.18)`, [{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'idx' }]), + method('MonsterHitMotion', `local m = self.Monsters[slot] +if m == nil or m.alive ~= true or m.entity == nil or not isvalid(m.entity) then + return +end +local e = m.entity +if m.hitClip ~= nil and e.SpriteRendererComponent ~= nil then + e.SpriteRendererComponent.SpriteRUID = m.hitClip + _TimerService:SetTimerOnce(function() + if isvalid(e) and e.SpriteRendererComponent ~= nil and m.alive == true and m.standClip ~= nil then + e.SpriteRendererComponent.SpriteRUID = m.standClip + end + end, 0.5) +else + if m.motionBusy == true then + return + end + m.motionBusy = true + local tr = e.TransformComponent + if tr == nil then + m.motionBusy = false + return + end + local p = tr.Position + local seq = { 0.12, -0.12, 0 } + for i = 1, #seq do + local dx = seq[i] + _TimerService:SetTimerOnce(function() + if isvalid(e) and e.TransformComponent ~= nil then + e.TransformComponent.Position = Vector3(p.x + dx, p.y, p.z) + end + if i == #seq then + m.motionBusy = false + end + end, 0.06 * i) + end +end`, [{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'slot' }]), method('SetHpBar', `local e = _EntityService:GetEntityByPath(path) if e == nil or e.UITransformComponent == nil then return