MIT License

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

深度分析 Touhou World Cup 的训练工具 thprac

项目背景与痛点

在电子竞技,特别是射击类游戏的训练中,适量的、有目的的练习至关重要。《touhouworldcup/thprac》项目提供了一个实践平台,让玩家可以在一个严格设计的、自动化的环境中提高自己的射击技巧。无论你是初学者还是高级玩家,thprac 都能够帮助你更好地理解和掌握游戏中的各种机制。

这个问题之所以存在,主要是因为在传统的游戏中,练习往往依赖于玩家自己的判断和努力,缺乏有效的反馈和策略优化。thprac 解决了这些问题,提供了一种科学且可重复的练习方式。

核心技术揭秘

技术架构

thprac 使用的技术栈非常清晰,底层采用了成熟的开发框架,并利用了最新的性能优化技术。以下是一个简化后的数据流图,帮助你了解其内部工作的原理。

graph TD A[用户登录] --> B[调用 Game Manager] B --> C{"验证用户"} C -->|"有效"| D[加载游戏配置] C -->|"无效"| E[返回错误] D --> F[初始化 Game Environment] F --> G[开始训练] G --> H{"训练结果"} H -->|"成功"| I[记录成绩] H -->|"失败"| J[显示提示与反馈]

thprac 的设计中展示了几个值得注意的特性:

  1. 模块化:将游戏逻辑、用户管理和数据处理等模块分离,提升了项目的可维护性和可扩展性。
  2. 中间件模式:在核心逻辑和外部接口之间,使用中间件模式过滤请求,确保系统的健壮性和安全性。
  3. 异步处理:在处理数据和用户交互时,采用了异步处理来提高响应速度和并发处理能力。

代码质量与性能优化

thprac 的代码库非常整洁,注释清晰,结构合理。项目中采用了大量的单元测试和集成测试,确保各个模块的独立性和相互之间的兼容性。此外,性能优化贯穿于整个项目的开发周期中,确保了系统在高负载下的平稳运行。

功能亮点与差异

thprac 的亮点主要体现在以下几个方面:

  1. 自动化练习计划:自动生成基于当前能力水平的练习计划,确保每个用户的学习路径都是最优的。
  2. 即时反馈系统:通过即时反馈机制,玩家能够快速了解自己的进步情况以及需要改进的地方。
  3. 竞技支持:thprac 提供比赛模式,允许玩家之间进行竞技,增强游戏的趣味性和参与感。

与同类竞品相比,thprac 在个性化训练和即时反馈等方面表现更加出色,简化了用户的练习流程,提升了学习效果。

应用场景与落地建议

thprac 在实际生产环境中具有广泛的适用性,无论是个人练习还是团队竞赛都能发挥其作用。在使用过程中,需要注意以下几点:

  • 性能优化:特别是在高并发情况下,需要确保服务器的性能和稳定性。
  • 用户数据安全:由于涉及到用户的练习和比赛数据,数据安全和隐私保护至关重要。
  • 用户体验:对于新手来说,需提供更多引导和支持,而对于高级玩家,则要提供更高难度的挑战。

综合评价

优点

  • 科学的训练模式:通过精准的算法分析用户数据,提供个性化的训练计划。
  • 丰富的反馈机制:即时反馈和比赛模式增强了互动性和趣味性。
  • 优秀的模块化设计:系统清晰易维护,适合扩展和迭代。

缺点

  • 技术门槛较高:对于非开发人员来说,理解和维护相关技术栈可能具有一定难度。
  • 运维成本:特别是对于大规模用户管理,可能会面临较高的运维成本。

综合来看,thprac 是一款非常优秀且针对性很强的射击类游戏训练工具,特别推荐给具有一定技术水平的开发者和需要专业训练的玩家。

关于

GitHub 原始描述(英文)

A tool for practicing Touhou shmups.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
563
价值分
279
活跃状态
活跃

语言占比

Batchfile
C
C++

Release

README

简体中文 日本語

thprac

thprac is a tool for practicing Touhou shmups.

ko-fi

Download - Download Beta

Note that beta versions will only update to the next stable version, not the next beta version.

Table of Contents

Downloading

If you want to download the tool, you can download the latest release here and the latest beta here. Do note that the latest beta will update into the next stable release and NOT the next beta release.

Usage

You can use this tool in a variety of ways; the main ways to do this are placing the executable in the same folder as your game, running the executable after running your game, or using thprac’s launcher.

thprac in the Game Folder

This method will NOT work with Steam games. You can run thprac by placing the thprac.exe file in the same folder as your game. This method will also automatically detect vpatch. You must ensure that the game is updated to the latest version and follows one of the following naming schemes. This method also works with vpatch.

  • thXX.exe (most games)
  • 東方紅魔郷.exe (Embodiment of Scarlet Devil)
  • alcostg.exe (Uwabami Breakers)

thprac after Running the Game

This method will work for most methods. First, run the game in whichever method you want (whether it’s thcrap, using vpatch, Steam, etc.) and then run thprac.exe. thprac will then detect the running game and attempt to attach itself to it. You may have to return to the menu screen to see thprac take effect.

thprac Using the Launcher

This video explains how to use the launcher. A quick and dirty overview of thprac 2.0

Command line

The following command line options are supported:

  • <path to game exe> The command thprac.exe <path to game exe> will run a game and attach thprac without any confirmation prompt. This makes it possible to drag a Touhou game executable onto thprac.exe and it will run with thprac. Note that if you place more command line parameters after <path to game exe>, those parameters will be forwarded to the game exe. This is completely useless because ZUN does not use command line parameters.
  • --attach <pid> immediately inject thprac into a process with ID <pid> without any confirmation prompts.
  • --attach (without any other flags). The command thprac.exe --attach will attach thprac to the first Touhou game process it finds without opening any kind of confirmation prompt.
  • --without-vpatch Prevent automatically applying vpatch.
  • --without-oilp Prevent automatically applying OpenInputLagPatch.

Small note about the last two flags: if neither of them are specified, but both vpatch and OpenInputLagPatch are present, OpenInputLagPatch will take priority.

Example commands:

thprac.exe --attach 1234
thprac.exe --attach
thprac.exe C:\Users\Name\Desktop\Games\Touhou\th17\th17.exe
thprac.exe --without-vpatch C:\Users\Name\Desktop\Games\Touhou\th12\th12.exe

Compatability

thprac officially supports every version of Windows starting with Windows Vista. Windows XP may work using One-Core-API, but this is NOT being actively tested.

thprac is also compatible with Wine and the Steam Deck. Do note that the Quick Menu is tailored to work well with the Steam Deck, although this is untested.

Features

thprac features an enhanced practice mode that supports all main games along with Great Fairy Wars and Uwabami Breakers.

Unconnected Marketeers

Imperishable Night

thprac replaces the original practice menu with a new UI shown in the image above; certain spells allow you to select phases or change certain parameters. For the games without an original practice mode (Uwabami Breakers, Great Fairy War, etc.), a practice menu is added to the “Start Game” menu.

Uwabami Breakers Great Fairy Wars

This menu can be controlled using your keyboard or your controller. Using this, you can select options using the UP and DOWN keys and change the option using the LEFT and RIGHT keys and the SHOT key to select. You can also use your mouse to interact with the menu.

thprac will also automatically save the options you selected into any replay saved. When playing back the replay, thprac will automatically apply said options. Replays saved while thprac is active using “Custom” mode will NOT work with the unmodified game.

Quick Menu

In any supported game (except Touhou 9 and 19), you can press the Backspace key to enter the Quick Menu. This menu shows a variety of options that can be activated using the function (F) keys.

These options are always clickable, meaning you can interact with them using a mouse on a desktop computer or by tapping on them with your left thumb when using a Steam Deck. To use this feature on the Steam Deck, map the Backspace key in Steam Input.

The hotkey for this menu can be changed from the launcher’s settings tab to a different key or combination of keys if you want it bound to something else.

Unconnected Marketeers Wily Beast and Weakest Creature

Advanced Options

In any supported game (except Touhou 9 and 19), you may use the F12 key to access the Advanced Options; these options may offer fixes or patches related to the game or other quality of life features.

Like the Quick Menu, the hotkey for this can also be changed from the launcher’s settings tab.

Imperishable Night Unconnected Marketeers

Game-specific Features

100th BM - Force Wave

100th Black Market

If thprac is enabled using “Custom” mode, the popup above will appear when the game is about to choose a wave.

PoFV - Tools

Phantasmagoria of Flower View

When starting a game in Match Mode, you can select “Custom” in a “Mode” prompt. If you do that, this window will appear in your game. You can move and adjust this window as much as you want. This replaces Advanced Options and can be opened with F12.

UDoALG - Tools

TH19 Tools

It’s just like PoFV Tools, but for UDoALG.

EoSD - Pause Menu

TH06

Choosing “Exit” will now prompt you to save a replay.

Warning: replays saved like this will continue after the point you chose to save the replay. The player character will stand still and not shoot.

ESC + R fix for EoSD, VD and beyond

Credits (post May 27th, 2022)

Building from Source

First time setup (only needs to be performed once)

Inside the folder named thprac, compile loc_json.cpp into loc_json.exe in whatever way you like most. I recommend this command

cl /Isrc\3rdparties\yyjson /nologo /EHsc /O2 /std:c++20 loc_json.cpp .\src\3rdParties\yyjson\yyjson.c /Fe:loc_json.exe

Building on the command line

In a Visual Studio Developer Command Prompt, run the following command

msbuild thprac.sln -t:restore,build -p:RestorePackagesConfig=true,Configuration=Release

Building from the Visual Studio GUI

Open thprac.sln click on “Build”, then “Build solution”

Frequently Asked Questions (FAQ)

General

Why did thprac move?

The original developer, Ack, has indefinitely ceased all future development of thprac/Marketeer. Below is their statement:

I will indefinitely cease all future development on thprac/Marketeer, you are free to continue working on it, granting that you follow the license’s terms.
Due to my insufficient skill, the code is glutted with obscure writings and terrible logic, turning the whole thing into a complete mess. I’m sorry if that disturbs you.

Ack cannot be contacted at this time, and development has been taken over by others.

My antivirus says thprac is malware. Is it safe?

Thprac contains no malicious code, but its behavior may trigger your antivirus. If flagged, add an exception or trust rule in your antivirus to allow thprac to work. Alternatively, you can try this version and report back if the issue persists.


Compatibility

Does thprac work with English patches?

Thprac is compatible with thcrap and can function as a thcrap launcher, similar to the Universal THCRAP Launcher. It does not support static English patches, like those created by gensokyo.org.


thprac cannot find Embodiment of Scarlet Devil. What should I do?

Ensure your executable is named either 東方紅魔郷.exe or th06.exe. If thprac still fails to detect it, you can manually launch the game with any filename through the launcher, which will attach thprac to the game.


Features

How do I save a replay mid-game in TH06-10?

Saving replays mid-game is not supported due to technical limitations. As per the thprac 2.0.8.3 manual:

Because of how these games were programmed, adding this feature would be quite troublesome, so currently there’s no direct solution to this.

However, EoSD now supports this functionality.

Note: replays saved mid-game do not return to the title screen after the save point.


What does “Everlasting BGM” mean?

This option prevents the background music (BGM) from resetting when you restart the game.


What does “Coercive Reporting” mean? (Shoot the Bullet/Double Spoiler)

This feature locks the camera onto the boss at all times and eliminates the camera’s recharge time.


How do I switch languages?
  • The launcher automatically selects its language based on your Windows settings.
  • To change the language in-game, use the shortcuts:
    • ALT + 1: Japanese
    • ALT + 2: Chinese
    • ALT + 3: English

The hotkey for changing languages can be changed from the launcher’s settings tab.

These shortcuts do not work in the launcher itself. Refer to the video in the “How to Use” section for detailed instructions.


Bug Reporting

Where can I report bugs?

Visit the Issues tab on GitHub to report bugs or suggest improvements.


Technical Issues

Unsupported VsyncPatch version in advanced options

Ensure you’re using a compatible version of VsyncPatch. You can download it from here. Use DLLs from rev7 whenever possible.


FPS adjustment seems to be broken when using vpatch

Some tools, like “DX8 to DX9 Converter,” conflict with VsyncPatch. Replay speed adjustment (slowdown/speedup) is only supported in TH13.


Game-Specific

This fixes the infamous Marisa laser desync bug in Double Dealing Character (TH14). Please refer to the original developer, Ack’s demonstration video on Bilibili (in Chinese, backup video link on YouTube)

评论

暂无评论