using System.Collections; using System.Collections.Generic; using UnityEngine; namespace TKS { /// /// 맹장 토벌전 전투(컨텐츠 모드 기획 10판 ③ · 개발 요청서 D) — 맹장은 쓰러지지 않는다(체력 = raid_rotation.n_hp = 한 판 피해 상한) · 턴 제한 없음(안전 장치 raid.safety_max_turns) · /// 아군 전멸 · 철수 · 안전 장치로 끝나고 준 피해가 기록이 된다. 수치는 전부 표(raid_boss_stats · content_modes_config raid.*) · 자리는 raid_layout. /// 기세 = 적 턴이 끝날 때마다 공격 × surge_atk_mult(누적) · surge_extra_action 턴부터 행동 +1 · 협공(combo_pct) · 벽 충돌(wall_hit_mult) · 빈틈(weak_mult · 다음 아군 턴) · /// 기절 = 공격 1회를 받거나 맹장 턴이 시작되면 풀림 · 그 공격엔 반격 없음(cc_release · cc_effect) · 군령(raid_rotation s_order_buff_ko). /// 맹장의 행동 = 정해진 기본 공격(n_basic_targets · f_basic_radius) + 패턴(e_pattern_shape · n_pattern_every · n_pattern_warn) — 슬링샷 이동 없음(여포 돌진만 이동). /// public class RaidBattleRules : ModeBattleRules { public RaidData.Boss Boss; public string Slot; public bool Practice; public BalanceConfig Config; ContentRow st; Unit boss; readonly List layout = new List(); readonly List allySlots = new List(); int refChapter; int surge; // 기세 단(적 턴이 끝난 수 + 수레가 닿은 단) int actionsThisTurn; long damage; // 이 판에 맹장에게 준 피해(상한 n_hp) bool weakNext, weakActive, retreated; int lastHit; // 맹장이 마지막으로 받은 피해(벽 충돌 추가 피해 · 항아리 불길) bool stunHit; readonly HashSet comboHitters = new HashSet(); // 패턴 readonly List marks = new List(); readonly List patternPts = new List(); Vector2 patternDir; bool patternArmed; // 딸린 것 class Add { public ContentLayoutRow row; public Unit unit; public GimmickInstance gim; public int deadTurn = -1; public int clearedUntil; // 안개(장각) 걷힌 턴 } readonly List adds = new List(); // 사마의 Unit gazed; readonly Dictionary dealtThisTurn = new Dictionary(); readonly HashSet backHitters = new HashSet(); // 동탁 불길 int burnTurns, burnDmg; // 원술 수레 class Cart { public Unit unit; public int batch; public float step; } readonly List carts = new List(); readonly Dictionary batchLeft = new Dictionary(); int batchNo, cartCursor; static float C(string key) { return ContentTables.Num(RaidData.Mode, key); } // ---------- 준비 ---------- public string Prepare(BalanceConfig.StageDef stage) { st = Boss.stats; if (st == null) return "raid_boss_stats 에 " + Boss.id + " 줄 없음"; layout.Clear(); foreach (var r in ContentTables.Rows(RaidData.Layout)) if (r.S("s_boss_id") == Boss.id || r.S("s_boss_id") == "*") layout.Add(ContentLayoutRow.From(r)); if (layout.Count == 0) return "배치 표 대기(" + RaidData.Layout + ".csv · 기획 세션 요청 중)"; layout.Sort((a, b) => a.slot.CompareTo(b.slot)); foreach (var r in layout) if (r.side == "ally_slot") allySlots.Add(r.pos); int ch, s2; refChapter = OutGame.ArenaRules.ParseStageKey(ContentTables.Str(RaidData.Mode, "unlock_stage"), out ch, out s2) ? ch : 1; // 딸린 것 체력 = 해금 장 마지막 일반 스테이지의 같은 병종 적 대비 ContentLayoutRow bossRow = null; foreach (var r in layout) if (r.side == "boss") bossRow = r; if (bossRow == null) return "배치 표에 boss 줄 없음"; UnitType t; UnitTypeInfo.TryParseKey(st.S("e_type"), out t); float hpMult = Boss.hpCap / Mathf.Max(1f, Config.GetStats(t).maxHp * Config.bossHpMult); stage.enemies.Add(new BalanceConfig.EnemySpawn { name = Boss.nameKo, type = t, position = bossRow.pos, hpMult = hpMult, atkMult = 1f, isBoss = true, isGeneral = true, art = Boss.art }); foreach (var r in layout) if (r.side == "add" && r.HasType) stage.enemies.Add(AddSpawn(r)); return null; } BalanceConfig.EnemySpawn AddSpawn(ContentLayoutRow r) { float hp, atk; string art; ContentEnemyRef.Of(Config, refChapter, r.UnitType, false, false, out hp, out atk, out art); return new BalanceConfig.EnemySpawn { name = r.nameKo.Length > 0 ? r.nameKo : st.S("s_adds_ko"), type = r.UnitType, position = r.pos, isGeneral = r.general, hpMult = hp * st.I("n_adds_hp_pct") / 100f * r.hpMult, atkMult = atk * r.atkMult, art = r.unitId.Length > 0 ? r.unitId : art, }; } public override Vector2 AllyPosition(int slot, Vector2 fallback) { return slot >= 0 && slot < allySlots.Count ? allySlots[slot] : fallback; } public override bool EliminationVictory { get { return false; } } public override bool CanRetreat { get { return ContentTables.Str(RaidData.Mode, "retreat") == "yes" && !retreated; } } public override void Retreat() { retreated = true; } public override void OnBegin() { foreach (var u in Battle.Units) if (u != null && u.Faction == Faction.Enemy && u.IsBoss && boss == null) boss = u; if (boss != null) { boss.Atk = Mathf.Max(1, Mathf.RoundToInt(C("boss_atk_base") * st.F("n_atk_pct") / 100f)); boss.Def = Mathf.Max(0, Mathf.RoundToInt(C("boss_def_base") * st.F("n_def_pct") / 100f)); boss.MaxHp = boss.Hp = Mathf.Max(1, Boss.hpCap); boss.MinHp = 1; // 맹장은 쓰러지지 않는다 boss.PushTaken = st.F("f_push_taken", 1f); boss.Radius = Config.GetStats(boss.Type).radius * st.F("f_radius_mult", 1f); if (boss.Collider != null) boss.Collider.radius = boss.Radius; if (boss.View != null) boss.View.Refresh(); } foreach (var r in layout) { if (r.side == "gimmick") ContentLayout.SpawnGimmick(Battle.Gimmicks, r); if (r.side != "add") continue; var a = new Add { row = r }; if (r.HasType) a.unit = FindUnitNear(r.pos); else if (r.gimmickId.Length > 0) a.gim = ContentLayout.SpawnGimmick(Battle.Gimmicks, r); adds.Add(a); } SpawnCarts(); // 1턴부터(원술 · every 턴마다) if (boss != null && PatternTurn() && st.I("n_pattern_warn") > 0) ArmPattern(); // 1턴 적 턴 패턴의 예고 } Unit FindUnitNear(Vector2 p) { Unit best = null; float bd = float.MaxValue; foreach (var u in Battle.Units) { if (u == null || u.Faction != Faction.Enemy || u == boss || u.IsBoss) continue; float d = Vector2.Distance(u.Position, p); if (d < bd && !Claimed(u)) { bd = d; best = u; } } return best; } bool Claimed(Unit u) { foreach (var a in adds) if (a.unit == u) return true; return false; } // ---------- 수치 ---------- public override float DealtMult(Unit a, Unit d) { if (a == null || d == null) return 1f; if (a == boss) return Mathf.Pow(C("surge_atk_mult"), surge); // 기세(누적) if (d != boss || a.Faction != Faction.Player) return 1f; float m = 1f; int k = comboHitters.Count + (comboHitters.Contains(a) ? 0 : 1); // 협공 = 이번 아군 턴에 맹장을 맞힌 서로 다른 유닛 수 float pct; if (ContentTables.Map(RaidData.Mode, "combo_pct").TryGetValue(k.ToString(), out pct)) m *= 1f + pct / 100f; if (weakActive) m *= C("weak_mult"); m *= OrderBuff(a); if (Boss.id == "caocao" && GuardsAlive() > 0) m *= C("caocao_guard_dmg_taken"); if (Boss.id == "simayi" && a == gazed) m *= C("simayi_gaze_dmg_mult"); return m; } /// 군령(raid_rotation e_order_kind = class | faction · s_order_target = 병종 키 | 세력 · n_order_pct) — 그 대상의 아군이 맹장에게 주는 피해 +%. float OrderBuff(Unit a) { var r = ContentTables.Find(RaidData.Rotation, "s_boss_id", Boss.id); if (r == null || r.F("n_order_pct") == 0f) return 1f; string kind = r.S("e_order_kind"), target = r.S("s_order_target"); bool hit = kind == "faction" ? a.Camp == target : kind == "class" && UnitTypeInfo.Key(a.Type) == target; return hit ? 1f + r.F("n_order_pct") / 100f : 1f; } bool stunAtStart; /// 아군 행동 시작 = 맹장이 이미 기절해 있었는가를 적어 둔다(그 행동이 건 기절은 풀지 않는다). public override Vector2 AdjustTarget(Unit u, Vector2 target) { stunAtStart = boss != null && SkillStatus.Stunned(boss); return target; } public override bool NoCounter(Unit defender) { return defender == boss && boss != null && SkillStatus.Stunned(boss); } // ---------- 집계 ---------- public override void OnDamaged(Unit d, int dealt, Unit by, HitKind kind, int before) { if (d != boss) return; long cap = Mathf.Max(1, Boss.hpCap); damage = System.Math.Min(cap, damage + dealt); lastHit = dealt; if (stunAtStart && SkillStatus.Stunned(boss)) stunHit = true; // 이 행동 전에 이미 걸려 있던 기절만(이 행동이 건 기절은 제외 · Fable QA 7) if (by != null && by.Faction == Faction.Player && Battle.Phase != BattlePhase.EnemyTurn) { comboHitters.Add(by); int v; dealtThisTurn.TryGetValue(by, out v); dealtThisTurn[by] = v + dealt; if (Boss.id == "simayi" && gazed != null && gazed.IsAlive) { Vector2 face = (gazed.Position - boss.Position).normalized; if (Vector2.Dot(by.Position - boss.Position, face) < 0f) backHitters.Add(by); // 등 뒤 반원 if (backHitters.Count >= Mathf.RoundToInt(C("simayi_back_hits"))) Weak("등 뒤를 찔렸다"); } } } public override void OnSlam(Unit target, Unit pusher) { if (target != boss || pusher == null || pusher.Faction != Faction.Player || lastHit <= 0) return; int extra = Mathf.RoundToInt(lastHit * (C("wall_hit_mult") - 1f)); if (extra <= 0) return; extra = SkillSystem.Deal(boss, extra, pusher, HitKind.Indirect); Fx.Popup(boss.Position, extra + " 벽 충돌", new Color(1f, 0.75f, 0.3f)); } public override void OnAction(Unit actor, ActionOutcome o) { if (stunHit && boss != null) // 기절 = 공격 1회를 받으면 풀림(행동 불가만 · 중독 · 화상은 그대로) { stunHit = false; if (Battle.Gimmicks != null) Battle.Gimmicks.ReleaseStun(boss); } stunAtStart = false; if (Boss.id == "zhangjiao" && actor != null && actor.Faction == Faction.Player && actor.Type == UnitType.Strategist && o != null && o.Fired) { Vector2 c = o.ShotHit != null ? o.ShotHit.Position : (o.Path.Count > 0 ? o.Path[o.Path.Count - 1] : actor.Position); foreach (var a in adds) if (a.gim != null && a.gim.Def.zone == GimmickZone.Fog && Vector2.Distance(c, a.gim.Shape.Center) <= a.gim.Shape.BoundingRadius) a.clearedUntil = Battle.TurnNumber + Mathf.Max(1, st.I("n_adds_respawn")) - 1; // 닿은 안개 1곳이 n 턴 걷힌다 bool all = false; foreach (var a in adds) { if (a.gim == null) continue; all = true; if (a.clearedUntil < Battle.TurnNumber) { all = false; break; } } if (all) Weak("안개가 모두 걷혔다"); } } public override void OnDeath(Unit d, Unit by) { foreach (var a in adds) if (a.unit == d) { a.deadTurn = Battle.TurnNumber; if (Boss.id == "yuanshao") Weak(d.DisplayName + " 쓰러짐"); if (Boss.id == "caocao" && GuardsAlive() == 0) Weak("호위가 모두 쓰러졌다"); } foreach (var c in carts) if (c.unit == d) { int left; batchLeft.TryGetValue(c.batch, out left); batchLeft[c.batch] = --left; if (left == 0) Weak("수레를 모두 부쉈다"); } } public override void OnGimmickBroken(GimmickInstance g, Unit by) { foreach (var a in adds) { if (a.gim != g) continue; a.deadTurn = Battle.TurnNumber; if (Boss.id == "dongzhuo" && boss != null && Vector2.Distance(g.Shape.Center, boss.Position) <= st.F("f_adds_size") + boss.Radius) { Weak("항아리가 곁에서 터졌다"); var burn = ContentTables.Map(RaidData.Mode, "dongzhuo_burn"); float bt, bp; burnTurns = burn.TryGetValue("turns", out bt) ? Mathf.RoundToInt(bt) : 0; burnDmg = burn.TryGetValue("pct", out bp) ? Mathf.RoundToInt(lastHit * bp / 100f) : 0; } } } int GuardsAlive() { int n = 0; foreach (var a in adds) if (a.unit != null && a.unit.IsAlive) n++; return n; } void Weak(string why) { if (weakNext) return; weakNext = true; if (boss != null) Fx.Popup(boss.Position + Vector2.up, "빈틈! " + why, new Color(1f, 0.9f, 0.2f)); } // ---------- 턴 ---------- public override IEnumerator OnTurnStart(Faction f) { if (f == Faction.Enemy) { actionsThisTurn = 0; if (boss != null && SkillStatus.Stunned(boss) && Battle.Gimmicks != null) Battle.Gimmicks.ReleaseStun(boss); // 맹장 턴이 시작되면 풀림 if (boss != null && PatternTurn()) yield return RunPattern(); yield return MoveCarts(); yield break; } // 아군 턴 시작 = 적 턴 하나가 끝남 → 기세 +1 · 빈틈 적용 · 딸린 것 다시 · 사마의 응시 · 불길 · 다음 패턴 예고 · 수레 surge++; enemyTurnsDone++; weakActive = weakNext; weakNext = false; if (weakActive && boss != null) Fx.Popup(boss.Position, "빈틈 — 이번 턴 피해 ×" + C("weak_mult"), new Color(1f, 0.9f, 0.2f)); comboHitters.Clear(); backHitters.Clear(); if (Boss.id == "simayi") PickGaze(); dealtThisTurn.Clear(); if (burnTurns > 0 && boss != null && burnDmg > 0) { burnTurns--; int b = SkillSystem.Deal(boss, burnDmg, null, HitKind.Dot); Fx.Popup(boss.Position, b + " 불길", new Color(1f, 0.5f, 0.2f)); } RespawnAdds(); SpawnCarts(); if (boss != null && PatternTurn() && st.I("n_pattern_warn") > 0) ArmPattern(); } void PickGaze() { Unit best = null; int bv = 0; foreach (var kv in dealtThisTurn) if (kv.Key != null && kv.Key.IsAlive && kv.Value > bv) { best = kv.Key; bv = kv.Value; } gazed = best; if (gazed != null) Fx.Popup(gazed.Position + Vector2.up, "응시당함", new Color(0.8f, 0.6f, 1f)); } void RespawnAdds() { int wait = st.I("n_adds_respawn"); if (wait <= 0) return; foreach (var a in adds) { if (a.deadTurn < 0 || Battle.TurnNumber - a.deadTurn < wait) continue; a.deadTurn = -1; if (a.row.HasType) { var e = AddSpawn(a.row); var u = Battle.SpawnUnit(e.type, Faction.Enemy, e.position, e.name, e.hpMult, e.atkMult, false, e.art); Battle.Skills.AttachEnemy(u, e, false); a.unit = u; } else if (a.row.gimmickId.Length > 0) a.gim = ContentLayout.SpawnGimmick(Battle.Gimmicks, a.row); } if (Battle.Gimmicks != null) Battle.Gimmicks.ResolveOverlaps(); } bool PatternTurn() { int every = st.I("n_pattern_every"); return every > 0 && st.S("e_pattern_shape") != "none" && Battle.TurnNumber % every == 0; } public override bool ActAgain(Unit e) { if (e != boss) return false; actionsThisTurn++; int allowed = 1; foreach (var t in ContentTables.List(RaidData.Mode, "surge_extra_action")) { float v; if (ContentTables.TryNum(t, out v) && Battle.TurnNumber >= v) allowed++; } return actionsThisTurn < allowed; } public override BattlePhase OnTurnLimit(out string message) { message = "안전 장치 " + Battle.TurnLimit + "턴 — 토벌 종료"; return BattlePhase.StageClear; } public override bool CheckEnd(out BattlePhase phase, out string message) { phase = BattlePhase.PlayerTurn; message = null; if (retreated) { phase = BattlePhase.StageClear; message = "철수 — 준 피해가 기록됩니다"; return true; } if (Boss.hpCap > 0 && damage >= Boss.hpCap) // 한 판 피해 상한에 닿음 = 더 쌓을 것이 없다(Fable QA 9 · 기획 확인 대상) { phase = BattlePhase.StageClear; message = "피해 상한 도달 — 토벌 종료"; return true; } return false; } // ---------- 맹장 행동 ---------- /// 둘레 공격 반경 = 표 값 + raid.self_circle_grow × 끝난 적 턴 수(맹장이 움직이지 않아 멀리서만 싸우는 편성 방지). float GrownRadius(float baseR) { return baseR + C("self_circle_grow") * enemyTurnsDone; } int enemyTurnsDone; public override bool ScriptsEnemy(Unit e) { if (e == boss) return true; foreach (var c in carts) if (c.unit == e) return true; return false; } public override bool EnemyActs(Unit e) { return true; } public override bool CountsForVictory(Unit u) { foreach (var c in carts) if (c.unit == u) return false; return true; } public override IEnumerator RunEnemy(Unit e) { foreach (var c in carts) if (c.unit == e) yield break; // 수레는 턴 시작에 움직였다(MoveCarts) if (e != boss) yield break; var players = Battle.AliveUnits(Faction.Player); players.RemoveAll(p => p.Npc); if (players.Count == 0) yield break; // 기본 공격(e_basic_kind · 거리 제한 없음 raid.basic_reach unlimited · 맹장은 움직이지 않음 raid.boss_move none): // melee = 가까운 n기 근접(반격 받음) · ranged = 먼 n기 사격 · splash = 가까운 n기 + 책사 광역 · self_circle = 둘레(커짐) 전부 · none = 패턴이 기본 공격 string kind = st.S("e_basic_kind"); if (kind == "none" || kind.Length == 0) yield break; var targets = new List(); int n = st.I("n_basic_targets"); if (kind == "self_circle") { float radius = GrownRadius(st.F("f_basic_radius")); if (!Sim.Active) Fx.Burst(boss.Position, radius + boss.Radius, new Color(1f, 0.4f, 0.2f, 0.6f)); foreach (var p in players) if (Vector2.Distance(p.Position, boss.Position) <= radius + boss.Radius + p.Radius) targets.Add(p); } else { players.Sort((a, b) => Vector2.Distance(a.Position, boss.Position).CompareTo(Vector2.Distance(b.Position, boss.Position))); if (kind == "ranged") players.Reverse(); // 「가장 먼 1기를 사격」(원소) for (int i = 0; i < n && i < players.Count; i++) targets.Add(players[i]); } bool melee = kind == "melee" || kind == "self_circle"; foreach (var t in targets) { if (!t.IsAlive) continue; if (melee && kind == "melee" && !Sim.Active) yield return Fx.Lunge(boss, t.Position); int dmg = Combat.Damage(Config, boss, t, false, Battle.Rng, melee); dmg = SkillSystem.Deal(t, dmg, boss, HitKind.Attack); Fx.Popup(t.Position, dmg.ToString(), new Color(1f, 0.45f, 0.45f)); if (kind == "melee" && t.IsAlive) // 근접 판정 = 반격을 받는다 { int c = Combat.CounterDamage(Config, t, boss, Battle.Rng); if (c > 0) { c = SkillSystem.Deal(boss, c, t, HitKind.Counter); Fx.Popup(boss.Position, c + " 반격", new Color(1f, 0.85f, 0.4f)); } } if (kind == "splash") // 책사 광역 판정(BalanceConfig strategistSplashRadius · Ratio) { if (!Sim.Active) Fx.Burst(t.Position, Config.strategistSplashRadius, new Color(0.7f, 0.5f, 1f, 0.6f)); foreach (var o in Battle.AliveUnits(Faction.Player)) { if (o == t || Vector2.Distance(o.Position, t.Position) > Config.strategistSplashRadius + o.Radius) continue; int sd = Mathf.RoundToInt(Combat.Damage(Config, boss, o, false, Battle.Rng, false) * Config.strategistSplashRatio); sd = SkillSystem.Deal(o, sd, boss, HitKind.Attack); Fx.Popup(o.Position, sd.ToString(), new Color(1f, 0.45f, 0.45f)); } } Battle.NotifyChanged(); yield return Fx.Wait(0.15f); } Battle.LastMessage = Boss.nameKo + " 공격" + (targets.Count > 0 ? " — " + targets.Count + "기" : ""); } // ---------- 패턴 ---------- void ClearMarks() { foreach (var m in marks) if (m != null) Object.Destroy(m); marks.Clear(); } GameObject Mark(Vector2 c, Vector2 size, float rotDeg, bool circle) { var go = new GameObject("RaidWarn"); go.transform.position = new Vector3(c.x, c.y, 0f); var sr = ProceduralSprites.NewSprite(go.transform, "Fill", circle ? ProceduralSprites.Circle : ProceduralSprites.Square, new Color(1f, 0.15f, 0.1f, 0.32f), 1f, 5); Vector2 native = sr.sprite.bounds.size; sr.transform.localScale = new Vector3(size.x / Mathf.Max(0.001f, native.x), size.y / Mathf.Max(0.001f, native.y), 1f); sr.transform.localRotation = Quaternion.Euler(0f, 0f, rotDeg); marks.Add(go); return go; } /// 예고(아군 턴 시작) — 다음 적 턴에 떨어질 자리를 붉게 표시한다. void ArmPattern() { ClearMarks(); patternPts.Clear(); patternArmed = true; var players = Battle.AliveUnits(Faction.Player); players.RemoveAll(p => p.Npc); if (players.Count == 0) return; float size = st.F("f_pattern_size"); int count = Mathf.Max(1, st.I("n_pattern_count")); var b = Battle.Config.boardSize; switch (st.S("e_pattern_shape")) { case "line": { bool far = ContentTables.Str(RaidData.Mode, "lvbu_charge_target") == "farthest"; // 돌진 방향 = 예고할 때 가장 먼(farthest) · 가까운 아군 Unit pick = players[0]; foreach (var p in players) { float dp = Vector2.Distance(p.Position, boss.Position), dk = Vector2.Distance(pick.Position, boss.Position); if (far ? dp > dk : dp < dk) pick = p; } patternDir = (pick.Position - boss.Position).normalized; float len = b.magnitude; Mark(boss.Position + patternDir * len * 0.5f, new Vector2(size, len), Mathf.Atan2(patternDir.y, patternDir.x) * Mathf.Rad2Deg - 90f, false); break; } case "bands": for (int i = 0; i < count; i++) { var p = players[Battle.Rng.Next(players.Count)]; patternPts.Add(new Vector2(0f, p.Position.y)); Mark(new Vector2(0f, p.Position.y), new Vector2(b.x, size), 0f, false); } break; case "target_circle": { var t = gazed != null && gazed.IsAlive ? gazed : players[0]; patternPts.Add(t.Position); Mark(t.Position, new Vector2(size * 2f, size * 2f), 0f, true); break; } case "random_circles": for (int i = 0; i < count; i++) { var p = players[Battle.Rng.Next(players.Count)]; var c = Battle.Board.ClampInside(p.Position + Random.insideUnitCircle * size, size); patternPts.Add(c); Mark(c, new Vector2(size * 2f, size * 2f), 0f, true); } break; } } IEnumerator RunPattern() { string shape = st.S("e_pattern_shape"); float size = st.F("f_pattern_size"); float mult = st.F("n_pattern_dmg_pct") / 100f; if (st.I("n_pattern_warn") > 0 && !patternArmed) yield break; // 예고 없이 떨어지지 않는다 patternArmed = false; var victims = new List(); var players = Battle.AliveUnits(Faction.Player); switch (shape) { case "self_circle": size = GrownRadius(size); if (!Sim.Active) Fx.Burst(boss.Position, size + boss.Radius, new Color(1f, 0.3f, 0.2f, 0.7f)); foreach (var p in players) if (Vector2.Distance(p.Position, boss.Position) <= size + boss.Radius + p.Radius) victims.Add(p); break; case "bands": foreach (var p in players) foreach (var c in patternPts) if (Mathf.Abs(p.Position.y - c.y) <= size * 0.5f + p.Radius && !victims.Contains(p)) victims.Add(p); break; case "target_circle": case "random_circles": foreach (var c in patternPts) { if (!Sim.Active) Fx.Burst(c, size, new Color(1f, 0.3f, 0.2f, 0.7f)); foreach (var p in players) if (Vector2.Distance(p.Position, c) <= size + p.Radius && !victims.Contains(p)) victims.Add(p); } break; case "line": yield return Charge(size, mult); ClearMarks(); yield break; } ClearMarks(); foreach (var v in victims) { int dmg = Mathf.RoundToInt(Combat.Damage(Config, boss, v, false, Battle.Rng, false) * mult); dmg = SkillSystem.Deal(v, dmg, boss, HitKind.Skill); Fx.Popup(v.Position, dmg + " " + Boss.nameKo, new Color(1f, 0.35f, 0.3f)); } Battle.LastMessage = Boss.nameKo + " — " + Boss.patternKo; Battle.NotifyChanged(); yield return Fx.Wait(0.4f); } /// 여포 돌진 — 예고선 방향으로 전장 끝까지 · 벽 · 바위 기믹에 막히면 그 자리에서 멈추고 빈틈 · 선 안의 아군 = 피해 + 밀림(f_pattern_push). IEnumerator Charge(float width, float mult) { Vector2 from = boss.Position, to = from; bool blocked = false; float stepLen = 0.2f, max = Battle.Config.boardSize.magnitude; for (float d = stepLen; d <= max; d += stepLen) { Vector2 p = from + patternDir * d; if (Battle.Board.ClampInside(p, boss.Radius) != p) break; // 전장 가장자리 = 멈춤(빈틈 아님 · 기획 세션 확인 중) bool hit = false; if (Battle.Gimmicks != null) foreach (var g in Battle.Gimmicks.Items) if (g.BlocksMove && !g.Broken && g.Shape.SignedDistance(p) < boss.Radius) hit = true; if (hit) { blocked = true; break; } to = p; } var victims = new List(); foreach (var u in Battle.AliveUnits(Faction.Player)) { float along = Vector2.Dot(u.Position - from, patternDir); if (along < 0f || along > Vector2.Distance(from, to) + boss.Radius) continue; float off = Mathf.Abs(Vector2.Dot(u.Position - from, new Vector2(-patternDir.y, patternDir.x))); if (off <= width * 0.5f + u.Radius) victims.Add(u); } if (!Sim.Active) yield return Fx.MoveAlong(boss.transform, from, to, Battle.Config.moveSpeed, null); boss.Position = to; float push = st.F("f_pattern_push"); foreach (var v in victims) { int dmg = Mathf.RoundToInt(Combat.Damage(Config, boss, v, false, Battle.Rng, true) * mult); dmg = SkillSystem.Deal(v, dmg, boss, HitKind.Skill); Fx.Popup(v.Position, dmg + " 돌진", new Color(1f, 0.35f, 0.3f)); if (v.IsAlive && push > 0f) { Vector2 end = Battle.Board.ClampInside(v.Position + patternDir * push * v.PushTaken, v.Radius); if (!Sim.Active) yield return Fx.MoveAlong(v.transform, v.Position, end, Battle.Config.moveSpeed, null); v.Position = end; } } if (Battle.Gimmicks != null) Battle.Gimmicks.ResolveOverlaps(); Physics2D.SyncTransforms(); if (blocked) Weak("돌진이 막혔다"); Battle.LastMessage = Boss.nameKo + " 돌진" + (blocked ? " — 막혔다!" : ""); Battle.NotifyChanged(); } // ---------- 원술 수레 ---------- void SpawnCarts() { if (Boss.id != "yuanshu") return; var cfg = ContentTables.Map(RaidData.Mode, "yuanshu_cart"); float every, count; if (!cfg.TryGetValue("every", out every) || !cfg.TryGetValue("count", out count) || every <= 0f) return; if ((Battle.TurnNumber - 1) % Mathf.RoundToInt(every) != 0) return; var spots = new List(); foreach (var r in layout) if (r.side == "cart_spawn") spots.Add(r); if (spots.Count == 0) return; float arrive; cfg.TryGetValue("arrive", out arrive); batchNo++; int made = 0; for (int i = 0; i < Mathf.RoundToInt(count) && spots.Count > 0; i++) { var r = spots[cartCursor % spots.Count]; // raid.yuanshu_cart_pick in_order = n_slot 순서대로 · 끝까지 쓰면 처음부터 cartCursor++; float hp, atk; string art; ContentEnemyRef.Of(Config, refChapter, UnitType.Infantry, false, false, out hp, out atk, out art); var u = Battle.SpawnUnit(UnitType.Infantry, Faction.Enemy, r.pos, st.S("s_adds_ko"), hp * st.I("n_adds_hp_pct") / 100f, 0f); u.Npc = true; // 반격 없음 · 공격하지 않음 u.ActedThisTurn = true; float dist = Vector2.Distance(r.pos, boss.Position); carts.Add(new Cart { unit = u, batch = batchNo, step = arrive > 0f ? dist / arrive : dist }); made++; } batchLeft[batchNo] = made; } IEnumerator MoveCarts() { if (carts.Count == 0 || boss == null) yield break; foreach (var c in carts.ToArray()) { if (c.unit == null || !c.unit.IsAlive) continue; Vector2 dir = boss.Position - c.unit.Position; float left = dir.magnitude - boss.Radius - c.unit.Radius; if (left <= c.step + 0.05f) // 닿음 → 기세 +단 { surge += ContentTables.Int(RaidData.Mode, "yuanshu_cart_surge"); int bl; batchLeft.TryGetValue(c.batch, out bl); batchLeft[c.batch] = -1000; // 이 무리는 빈틈 실패 Fx.Popup(boss.Position, "꿀물 — 기세 +" + ContentTables.Int(RaidData.Mode, "yuanshu_cart_surge"), new Color(1f, 0.8f, 0.3f)); carts.Remove(c); Battle.RemoveUnit(c.unit); continue; } Vector2 to = c.unit.Position + dir.normalized * c.step; if (!Sim.Active) yield return Fx.MoveAlong(c.unit.transform, c.unit.Position, to, Battle.Config.moveSpeed, null); c.unit.Position = to; } Physics2D.SyncTransforms(); } // ---------- 결과 ---------- public long Damage { get { return damage; } } public override float? JudgeValue { get { return damage; } } public override string ProgressLine { get { return "피해 " + damage.ToString("N0") + " · 기세 " + surge + "단" + (weakActive ? " · 빈틈!" : "") + (Practice ? " · 연습" : ""); } } public override void Summarize(List lines) { lines.Add("준 피해 " + damage.ToString("N0") + (Practice ? " (연습 — 기록 · 보상 없음)" : " × 점수 배율 " + RaidData.ScoreMult(Slot))); } } }