docs/en-us/develop/overseas-client-adaptation.md
Before starting this tutorial, make sure you have:
readme.md to ensure that supported features work properly.@ and # type tasks.task.json and template images will use CN client task.json and template images as fallbacks. Content in overseas client task.json will override and rewrite corresponding fields of CN client tasks.Award task, gradually replace template images / text / modify roi step by step according to the next order of the Award task in CN client task.json, ensuring each step works properly after modification or can quickly identify errors. This avoids confusion about which step the program is stuck on when too many changes are made at once.Before making modifications, there are several preparation steps to note:
To get high-quality screenshots, please follow these guidelines:
1280*720 with aspect ratio 16:9.To crop images and get text/image roi, you need to use the MaaAssistantArknights/tools/ImageCropper tool.
ImageCropper is a powerful screenshot tool that supports cropping, saving, and color picking operations for ROI regions from pre-prepared screenshots or devices connected via ADB.
Requires python environment, recommended version is 3.11, minimum version is 3.9 or above.
Windows users are recommended to run install.bat directly, or install manually:
python -m pip install -r requirements.txt
./src/ directorystart.bat or python main.py [device serial] (device address is optional)
python main.py [device serial] to connect to a specific deviceS or ENTER to save the target areaF to save full-screen standardized screenshotR to output ROI range only (without saving)C to output ROI range and ColorMatch fields (without saving)Z, DELETE or BACKSPACE to undo0 ~ 9 to zoom the windowQ or ESC to exit./dst/ directoryFor example, output after completing one crop:
src: Screenshot_xxx.png
dst: Screenshot_xxx.png_426,272,177,201.png
original roi: 476, 322, 77, 101,
amplified roi: 426, 272, 177, 201
Where:
Screenshot_xxx.png is the name of the complete screenshot placed in the src folder. Screenshot_xxx.png_426,272,177,201.png is the cropped image.
original roi is the mouse-selected area. amplified roi is the enlarged area. You need the enlarged range, so fill the roi field in task.json with this value.
Before modifying template images, you need to open the corresponding client's template image folder and CN client's template image folder.
For example:
MaaAssistantArknights\resource\global\YoStarEN\resource\template.MaaAssistantArknights\resource\template.Refer to template images mentioned in task.json, compare CN client and overseas client template images, and find templates missing in overseas client.
Usually, except for logos and other images, templates containing text need to be replaced through screenshots. If image dimensions are significantly larger than corresponding CN client template images, you need to modify roi size.
Place captured and renamed template images into the corresponding client's template image folder.
Before modifying text content, you need to open the corresponding server's task.json and CN client's task.json.
For example:
task.json location: MaaAssistantArknights\resource\global\YoStarEN\resource\tasks.json.task.json location: MaaAssistantArknights\resource\tasks.json.Find the corresponding task and modify the text field to content displayed in the corresponding server. Note that recognized content can be a substring of complete in-game content.
Usually, unless it's pure ASCII character recognition, text containing text needs to be replaced. If text length is significantly larger than CN client, you need to modify roi size, such as the length difference between "任务" and "Mission" being too large, requiring modification of overseas client task roi size.
If the corresponding overseas client task.json doesn't have the task, you need to add the task, only filling in the text field.
task.json, such as EN client location MaaAssistantArknights\resource\global\YoStarEN\resource\tasks.jsonroi range modification, use your prepared overseas game interface screenshots, and adjust roi range size according to amplified roi.roi doesn't need modification, only when recognition content size difference with CN client is too large.task.json doesn't have the task, add the task and write the roi field.After modifications are complete, restart the software to reload files and make changes effective. Or create a DEBUG.txt file in the software directory before opening the software, so templates and files reload every time you click start, without needing restart.
Check for success:
Sometimes after modifying task.json, we find the program still can't run correctly. In this case, we should check logs to find error locations and modify corresponding tasks.
Log file location is in the software root directory, filename asst.log. If you compiled MAA yourself, it's in \x64\Release or x64\RelWithDebInfo, depending on your compilation mode selection.
Here's a log example:
[2022-12-18 17:43:17.535][INF][Px7ec][Tx15c8] {"taskchain":"Award","details":{"to_be_recognized":["Award@ReturnTo","Award","ReceiveAward","DailyTask","WeeklyTask","Award@CloseAnno","Award@CloseAnnoTexas","Award@TodaysSupplies","Award@FromStageSN"],"cur_retry":10,"retry_times":20},"first":["AwardBegin"],"taskid":2,"class":"asst::ProcessTask","subtask":"ProcessTask","pre_task":"AwardBegin"}
[2022-12-18 17:43:18.398][INF][Px7ec][Tx15c8] Call ` C:\Program Files\BlueStacks_nxt\.\HD-Adb.exe -s 127.0.0.1:5555 exec-out "screencap | gzip -1" ` ret 0 , cost 862 ms , stdout size: 2074904 , socket size: 0
[2022-12-18 17:43:18.541][TRC][Px7ec][Tx15c8] OcrPack::recognize | roi: [ 500, 50, 300, 150 ]
[2022-12-18 17:43:18.541][TRC][Px7ec][Tx15c8] Ocr Pipeline with asst::WordOcr | enter
[2022-12-18 17:43:18.634][TRC][Px7ec][Tx15c8] Ocr Pipeline with asst::WordOcr | leave, 93 ms
[2022-12-18 17:43:18.634][TRC][Px7ec][Tx15c8] OcrPack::recognize | raw: [{ : [ 0, 0, 300, 150 ], score: 0.000000 }]
[2022-12-18 17:43:18.634][TRC][Px7ec][Tx15c8] OcrPack::recognize | proc: []
[2022-12-18 17:43:18.637][TRC][Px7ec][Tx15c8] asst::ProcessTask::_run | leave, 1101 ms
[2022-12-18 17:43:18.638][TRC][Px7ec][Tx15c8] ready to sleep 500
[2022-12-18 17:43:19.144][TRC][Px7ec][Tx15c8] end of sleep 500
[2022-12-18 17:43:19.144][TRC][Px7ec][Tx15c8] asst::ProcessTask::_run | enter
In this log, you can see:
taskchain represents the currently running task.details is task content, including fields to be recognized (to_be_recognized), current retry count (cur_retry), and total retry count (retry_times).first represents task start.taskid is the task number.class and subtask represent task class and subtask respectively.pre_task represents the previous task.Additionally, the log records command execution (like Call) and OCR information (like OcrPack::recognize).
In this log, "to_be_recognized", "cur_retry":3,"retry_times":20 indicates it has repeatedly tried recognition 3 times, with maximum recognition attempts of 20. After reaching maximum attempts, it will skip the task and report error, continuing to the next task. If previous tasks had no issues, we can basically determine there's a recognition problem here. We need to check tasks mentioned in the log to see if there's a corresponding template file, if the corresponding task's text is incorrect, if task recognition roi range is correct, to find and fix the problem.
By checking the corresponding template image, we found there's a template for this image in the EN client template folder, but it's significantly larger than the CN client image, causing CN client's roi to fail recognition on EN client. So we need to modify the corresponding task roi in EN client's task.json to match EN client image size.
Please refer to GitHub Pull Request Guide