Skip to content

About

Battle log analyzer for Twinkle Star Knights (ティンクルスターナイツ / クルスタ / 闪耀星骑士), using Frida and IL2CPP.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Latest commit

 

History

178 Commits

Folders and files

Repository files navigation

TSKBattleLog

English | 简体中文

A battle log analyzer for Twinkle Star Knights using Frida and IL2CPP.

TSKBattleLog captures and analyzes battle events from the game runtime — damage, skills, combat states — and provides a floating control panel to load/toggle mods and inspect unit buffs in real time. Auto-battle skill selection is configurable via char_skill.json. It can also capture the game's network API plaintext JSON (Capture tab) and export account-owned data (units / warehouse) to userdata/ for external tools.

Screenshots

MODs tab

MODs tab: mod toggles grouped by category

Logs tab

Logs tab: real-time battle log viewer with clear / copy / open logs folder

Capture tab

Capture tab: captured requests merged into one row each (API name / latency / request summary), with the full plaintext JSON on the right (syntax highlighting) and a raw-event view toggle

Skill Effects window

Skill Effects window (opens on unit click): live stats — ATK / CRT / NoteCount / EX_UP — plus a detail/summary buff table

Battle Log window

Battle Log window: battle timeline — turn separators with cumulative damage, per-attacker skill groups (colored by attribute), Unison events — with a per-segment damage coefficient detail panel

Unit codex

Unit codex (viewer/index.html): full codex grid with a stats bar, per-group filter chips (multi-select with an any/all toggle per group) and sort controls

Unit detail

Unit detail popup: portrait, stat breakdown (base + equipment + affection), equipment with enchant rolls, skills with category tags, and profile

Features

  • Real-time battle event logging with millisecond timestamps
  • Per-unit damage tracking with post-battle ranking
  • Multi-hit skill grouping (per attacker / turn / kind / segment) with crit count and skill multiplier
  • Unison damage tracking
  • Battle Log window: battle timeline (turn separators with cumulative damage, per-attacker skill groups colored by attribute, Unison events) with a per-segment detail panel showing damage coefficients — fluctuation / rush / attribute / critical / down / vulnerability rate / passive; the info line starts with the stage name (from battle/start, requires network-capture) and also shows initial EX and first-round usable EX
  • Battle history: snapshots are auto-saved to logs/battles/ when a battle ends; the History tab lists past battles newest-first (time / stage / turns / total damage / party; stage names come from the battle/start response and require network-capture, older snapshots fall back to mode) for one-click replay, with locking to protect important battles and one-click cleanup of unlocked records; the window also works without injection for browsing local snapshots
  • Configurable auto-battle skill selection via char_skill.json; a per-unit priority dropdown under each player avatar (Default / Normal / EX1 / EX2 / Random) applies changes instantly
  • Config-driven debug observation points and IL2CPP backtraces via trace_config.json
  • Mod loader with runtime enable/disable and a floating control panel
  • Unit avatar bar (player icons from the wiki, tolerant of full-/half-width parentheses in file names) + compact enemy list; click any unit to view its live buffs, ATK/CRT/NoteCount and EX stats, with detail/summary toggle
  • Auto-saved log files + in-panel log viewer (clear / copy / open logs folder)
  • Network API capture: in-process hooks extract request/response plaintext JSON to logs/capture/; the Capture tab merges each request into one row (API name, round-trip time, request summary) with JSON syntax highlighting and a raw-event view toggle
  • Account data export: server-side snapshots of the unit list (unit/list) and warehouse (warehouse/list, incl. character pieces) saved to userdata/, ready for external tools (e.g. TSKUnitViewer)
  • Unit viewer: generates a static viewer/index.html codex from the userdata/ dumps plus wiki data fetched at runtime — full codex incl. unowned units, limit-break piece progress (with a "ready to LB" count), equipment/skill details, portraits and icons. Data processing is ported from TSKUnitViewer
  • On startup, checks GitHub for the latest release and shows a clickable download link on the Settings tab when a newer version exists (silent on failure)

Mod categories

  • Observer: read-only logging / data export, no runtime state change
  • Modifier: alters in-game behaviour (e.g. QTE result, skill selection)
  • Debug: verbose low-level trace for analysis (high log volume)

Installation

npm install

Usage

Method A: Floating control panel (recommended)

A Tkinter always-on-top window powered by frida-python.

One-time dependency install:

pip install frida frida-tools

Launch:

.\control.ps1

The script runs npm run build first, then opens the panel. Tick the mods you want, then press ▶ 启动注入. The game may be started before or after the panel — the bridge waits for the process.

Panel features:

  • 窗口置顶 toggle (top-left)
  • MODs / Logs / 设置 (Settings) tabs; switch to Logs automatically after injection starts
  • Mod list grouped by Observer / Modifier / Debug. Selection is persisted to mods.json. Checkboxes are locked after injection starts (changing mods mid-battle is unsafe).
  • 重载配置: re-read trace_config.json and update trace/backtrace points at runtime
  • 隐藏单位栏: hide the player avatar bar and enemy list to focus on logs
  • 设置 (Settings) tab: battle speed (default 3x), log font size / colored log / diagnostic log toggles, an "open userdata directory" entry for user-data-dump, plus the current version and a new-version download link (all persisted to gui_config.json). The 角色图鉴 (Unit Viewer) section has two buttons: 生成并打开 builds viewer/index.html and opens it in the browser; 下载 / 更新图片 fetches wiki data + portraits/icons with a progress bar (incremental — rerun it to pick up newly released units)
  • Log viewer with 清空 / 复制日志 / 打开日志目录; logs are also auto-saved to logs/ (8 KB buffer, flushed on close)
  • 5000-line ring buffer; older lines are dropped automatically
  • Player avatar bar (48 px wiki icons) and a compact enemy name strip above it. Each avatar has a skill-priority dropdown (Default / Normal / EX1 / EX2 / Random) that writes to char_skill.json and takes effect instantly. Clicking any unit opens a Skill Effects window showing live buffs (detail / summary toggle) plus ATK (base), CRT, NoteCount, EX rate and normal-attack EX gain.
  • 战斗日志 button: opens the Battle Log window (on-demand snapshot, refresh to pull the latest; window size/position remembered). Inside is a 历史 (History) tab: snapshots are auto-saved to logs/battles/ when a battle ends, listed newest-first for one-click replay, with locking and one-click cleanup of unlocked records; the window also opens without injection to browse/replay local snapshots.
  • Capture tab: browse capture files in logs/capture/ (requires the network-capture mod). Requests are merged into one row each (req/URL/resp) showing API name, round-trip time and request summary; clicking a row shows the full plaintext on the right (JSON syntax highlighting, large responses truncated — see the jsonl file for the complete body), and failed responses (code != 1000) are highlighted in red. The 原始事件 (raw events) toggle shows the unmerged event stream (incl. meta and duplicate resp; persisted to gui_config.json).

Method B: Headless injection (console only)

Start the game, then:

.\run.ps1

This builds the agent, attaches to the running game process, and saves logs to logs/.

Using the packaged EXE

Download TSKBattleLog-windows-x64.zip from Releases (or from an Actions run artifact), extract it, and run TSKBattleLog.exe:

  • No Python or frida installation required — dependencies are bundled
  • The panel works exactly like Method A: tick the mods you want, then press ▶ 启动注入
  • Config files sit next to the exe and can be edited directly: mods.json (mod toggles), trace_config.json (debug observation points), char_skill.json (auto-skill priority)
  • Logs are written to logs/ next to the exe (battle snapshots in logs/battles/), exported account data lives in userdata/; window position and other personal preferences are kept in gui_config.json

To build it yourself, see .github/workflows/build-exe.yml.

Mods

Every feature is its own mod under src/mods/. mods.json holds the default enabled state and is updated automatically by the panel.

Key Category Description
battle-log Observer Prints battle-related info (damage stats, multi-hit grouping, turns, post-battle summary); powers the Battle Log window with per-segment damage coefficient details
user-data-dump Observer Exports account-owned data to userdata/ (requires network-capture): on unit list pull → unit_list.json + sister_unit_list.json; on opening the warehouse → warehouse.json (5 groups incl. character pieces, dumped as-is)
network-capture Observer Captures network request/response plaintext (URL, method, RTT) to logs/capture/*.jsonl, shown in the Capture tab; also publishes API responses to an internal bus consumed by other mods
qte-perfect Modifier Forces the battle-start QTE result to PERFECT
auto-skill Modifier In auto mode, picks EX1/EX2 automatically per char_skill.json
avatar-clarity Modifier Keeps character avatar UI (buff icons, awakening indicators) fully opaque during normal gameplay via a native CModule hook on CanvasGroup.set_alpha
trace-config Debug Bulk-registers arg-dump trace points from trace_config.json (edit JSON, then press reload on the panel)
backtrace Debug Prints an IL2CPP call stack on entry of methods listed in trace_config.json
field-watch Debug Watches fields of a given class, logging the writer method + call stack on change

Skill configuration (char_skill.json)

Controls the priority used by auto-skill. The easiest way is the dropdown under each player avatar in the panel (Default / Normal / EX1 / EX2 / Random), which writes and applies changes instantly; you can also edit this file by hand.

{
    "星を見るもの": 2,
    "バニーサンタ": 1,
    "夏色マジカル☆": 0
}

Values:

  • 2: Prefer EX2
  • 1: Prefer EX1
  • 0: Never auto-cast any EX skill

Fallback lookup order is [UnitName] CharacterName → UnitName, so a single entry covers all variants of a unit.

Debug observation points (trace_config.json)

Shared by trace-config and backtrace — adding points requires no source edit and no re-injection:

{
  "trace": [
    { "class": "TSKBattleNote", "method": "SetDamageValue" }
  ],
  "backtrace": [
    { "class": "TSKBattleAI", "method": "LotterySkillAction", "depth": 8 }
  ],
  "backtraceDepth": 5
}
  • trace: attaches dumpArgs to each listed class.method.
  • backtrace: prints an IL2CPP call stack (resolved through the method address index) on entry; per-entry depth overrides the global backtraceDepth.
  • After editing, press 重载配置 to apply — new points attach and removed points detach at runtime.
  • Keep arrays empty by default: tracing a method another mod already hooks doubles that method's log output.

Disclaimer

For research, analysis and personal use only. Some features modify battle state and may affect game behaviour. Use at your own risk.

Credits

Thanks to TSKHook-frida for providing a valuable reference for Frida and IL2CPP runtime analysis.

Thanks to TSKUnitViewer — the built-in unit viewer's data processing is ported from it.

About

Battle log analyzer for Twinkle Star Knights (ティンクルスターナイツ / クルスタ / 闪耀星骑士), using Frida and IL2CPP.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages