How ok-oldking/ok-wuthering-waves works
Project Overview & Main Purpose
• This project is an automation tool designed for Windows to interact with “Wuthering Waves” without requiring the game window to be in focus.
• Its core functionalities include automated combat, task execution (e.g., auto-login, auto-pickup, daily tasks), and background computer vision for game element detection (leveraging a YOLO ONNX model).
• The project, distributed both as Python source code and a compiled executable (ok-ww.exe), integrates automation logic with computer vision processes and employs a modular design.
Analyzing the File Structure
• Top-Level Files & Directories:
• Main executables/scripts: main.py, main_debug.py.
• A compiled binary: ok-ww.exe.
• Configuration and deployment files: config.py, deploy.txt, setup.py.
• Internationalization: i18n folder for different language support.
• Assets: Contains images, a result JSON file, and the “yolov5s_320.onnx” model under assets/yolo.
• Source code: src folder, divided into subdirectories:
– src/char: Contains individual character classes (e.g., Baizhi.py, Healer.py, etc.) along with a character factory and support classes.
– src/combat: Contains scripts relevant to combat verification (CombatCheck.py).
– src/scene: Contains modules managing game scene interactions.
– src/task: Contains various automated tasks (AutoCombatTask, AutoPickTask, etc.) as well as base classes for tasks.
– Other modules: YoloDetect.py (for computer vision detection) and globals.py.
• Testing: The tests directory with automated test scripts (e.g., TestCombatCheck.py) confirms unit testing of key components.
• GitHub workflows and issue templates in .github indicate standard CI/CD practices.
Identifying the Main Components
a. Core Application:
• Main Entry Points: main.py and main_debug.py, which initialize and coordinate the application.
• Config and Globals: config.py and globals.py manage settings and shared state.
b. Automation Task Manager:
• Task Module (src/task): Incorporates a range of automated tasks (such as AutoCombatTask, AutoLoginTask, etc.) that perform discrete game actions.
• Base task classes (e.g., BaseCombatTask, SkipDialogTask) used for polymorphic behavior.
c. Character Management:
• Character Module (src/char): Multiple files defining individual game characters with unique abilities or actions.
• CharFactory and supporting helper classes work together to instantiate and manage these characters.
d. Computer Vision Component:
• YoloDetect.py: Implements object detection by loading and processing the ONNX model (assets/yolo/yolov5s_320.onnx).
• Assets Integration: The assets directory holds the relevant images and models.
e. Game Interaction Layer:
• Combat and Scene Modules: src/combat and src/scene handle combat validation and scene management.
• This layer integrates with win32api for simulating key presses and mouse activities.
f. Internationalization:
• i18n folder: Supports multiple languages (e.g., English and Chinese) to provide flexibility in user interactions.
Architectural Patterns & Important Relationships
• Modular Design: The separation of tasks, character definitions, and combat logic suggests a clean modular architecture.
• MVC-like or Service-Oriented Pattern: While not strictly an MVC, the “task” components (controller-like) use the “character” and “scene” elements (model-like) to act upon the game (view/UI through simulation).
• Integration of AI/Computer Vision: YoloDetect serves as a specialized component that communicates its results (detections) to other modules (e.g., tasks) which then trigger win32api actions.
• Dependency Flow: Configuration and initialization (via main.py) set up global settings, which feed into the Task Manager, which in turn orchestrates both the computer vision (detection module) and interaction modules to execute game actions.