Files
MaaAssistantArknights/docs/maa_tasks_schema.json
2025-06-09 16:15:13 +08:00

223 lines
10 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "maa task config",
"patternProperties": {
"^(?!\\$)": {
"type": "object",
"oneOf": [
{
"$ref": "#/definitions/JustReturnTask"
},
{
"$ref": "#/definitions/MatchTemplateTask"
},
{
"$ref": "#/definitions/OcrDetectTask"
}
]
}
},
"definitions": {
"Rectangle": {
"type": "array",
"maxItems": 4,
"minItems": 4,
"items": {
"type": "number"
}
},
"ParamsArray": {
"type": "array",
"items": {
"type": "number"
}
},
"TaskNameList": {
"type": "array",
"items": {
"type": "string",
"description": "要执行的任务"
}
},
"BaseTask": {
"properties": {
"algorithm": {
"type": "string",
"description": "算法类型"
},
"action": {
"type": "string",
"pattern": "ClickSelf|ClickRand|DoNothing|Stop|ClickRect|Swipe|Input",
"default": "DoNothing",
"description": "可选项,表示识别到后的动作\n不填写时默认为 DoNothing"
},
"inputText": {
"type": "string",
"description": "可选项,当 action 为 Input 时有效,表示要输入的文本"
},
"sub": {
"$ref": "#/definitions/TaskNameList",
"description": "可选项,子任务。会在执行完当前任务后,依次执行每一个子任务\n可以套娃子任务再套子任务。但要注意不要写出了死循环"
},
"subErrorIgnored": {
"type": "boolean",
"default": false,
"description": "可选项,是否忽略子任务的错误。默认为 false\n为 false 时,若某个子任务出错,则不继续执行后续任务(相当于本任务出错了)\n为 true 时,子任务是否出错没有影响"
},
"next": {
"$ref": "#/definitions/TaskNameList",
"description": "可选项,表示执行完当前任务后,下一个要执行的任务\n会从前往后依次去识别去执行第一个匹配上的\n不填写默认执行完当前任务直接停止"
},
"maxTimes": {
"type": "number",
"description": "可选项,表示该任务最大执行次数\n不填写时默认无穷大\n达到最大次数后若存在 exceededNext 字段,则执行 exceededNext否则直接任务停止"
},
"exceededNext": {
"$ref": "#/definitions/TaskNameList",
"description": "可选项,表示达到了最大执行次数后要执行的任务\n不填写时达到了最大执行次数则停止填写后就执行这里的而不是 next 里的"
},
"onErrorNext": {
"$ref": "#/definitions/TaskNameList",
"description": "可选项,表示执行出错时,后续要执行的任务"
},
"preDelay": {
"type": "number",
"description": "可选项,表示识别到后延迟多久才执行 action单位毫秒不填写时默认 0"
},
"postDelay": {
"type": "number",
"description": "可选项,表示 action 执行完后延迟多久才去识别 next, 单位毫秒;不填写时默认 0"
},
"roi": {
"$ref": "#/definitions/Rectangle",
"description": "可选项,表示识别的范围,格式为 [ x, y, width, height ]\n以 1280 * 720 为基准自动缩放;不填写时默认 [ 0, 0, 1280, 720 ]\n尽量填写减小识别范围可以减少性能消耗加快识别速度"
},
"cache": {
"type": "boolean",
"default": true,
"description": "可选项,表示该任务是否使用缓存,默认为 true;\n第一次识别到后以后永远只在第一次识别到的位置进行识别开启可大幅节省性能\n但仅适用于待识别目标位置完全不会变的任务若待识别目标位置会变请设为 false"
},
"rectMove": {
"$ref": "#/definitions/Rectangle",
"description": "可选项,识别后的目标移动,不建议使用该选项。以 1280 * 720 为基准自动缩放\n例如识别到了 A 图标,但实际要点击的是 A 图标旁边的某个位置,则进行移动后再点击。可以的话尽量直接识别要点击的位置,不建议使用该选项\n当 action 为 Swipe 时表示滑动终点"
},
"reduceOtherTimes": {
"type": "array",
"items": {
"type": "string",
"description": "要执行的任务"
},
"description": "可选项,执行后减少其他任务的执行计数。"
},
"specificRect": {
"$ref": "#/definitions/Rectangle",
"description": "当 action 为 ClickRect 时有效且必选,表示指定的点击位置(范围内随机一点),以 1280 * 720 为基准自动缩放\n当 action 为 Swipe 时有效且必现,表示滑动起点"
},
"specialParams": {
"$ref": "#/definitions/ParamsArray",
"description": "某些任务使用的特殊参数(大部分是手写阈值等)"
},
"highResolutionSwipeFix": {
"type": "boolean",
"default": false,
"description": "可选项,是否启用高分辨率滑动修复,现阶段应该只有关卡导航未使用 unity 滑动方式所以需要开启,默认为 false"
}
}
},
"JustReturnTask": {
"allOf": [
{
"$ref": "#/definitions/BaseTask"
}
],
"properties": {
"algorithm": {
"type": "string",
"pattern": "JustReturn"
}
},
"description": "不进行识别,直接执行 action",
"required": ["algorithm"]
},
"MatchTemplateTask": {
"allOf": [
{
"$ref": "#/definitions/BaseTask"
}
],
"properties": {
"algorithm": {
"type": "string",
"pattern": "MatchTemplate"
},
"template": {
"type": ["array", "string"],
"items": {
"type": "string"
},
"default": "",
"description": "可选项,要匹配的图片文件名\n不填时写默认 \"任务名.png\""
},
"templThreshold": {
"type": ["array", "number"],
"items": {
"type": "number"
},
"default": 0.8,
"description": "可选项,图片模板匹配得分的阈值,超过阈值才认为识别到了。\n默认 0.8, 可根据日志查看实际得分是多少"
},
"maskRange": {
"type": "array",
"maxItems": 2,
"minimum": 2,
"items": {
"type": "number"
},
"default": [1, 255],
"description": "可选项,灰度掩码范围。例如将图片不需要识别的部分涂成黑色(灰度值为 0然后设置 [ 1, 255 ], 匹配的时候即刻忽略涂黑的部分"
}
},
"description": "匹配图片"
},
"OcrDetectTask": {
"allOf": [
{
"$ref": "#/definitions/BaseTask"
}
],
"properties": {
"algorithm": {
"type": "string",
"pattern": "OcrDetect"
},
"text": {
"type": "array",
"items": {
"type": "string"
},
"description": "必选项,要识别的文字内容,只要任一匹配上了即认为识别到了"
},
"fullMatch": {
"type": "boolean",
"default": false,
"description": "可选项,文字识别是否需要全字匹配(不能多字),默认为 false\nfalse 时只要是子串即可:例如 text: [ \"开始\" ],实际识别到了 \"开始行动\",也算识别成功;\ntrue 时则必须识别到了 \"开始\",多一个字都不行"
},
"ocrReplace": {
"type": "array",
"items": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {
"type": "string"
}
},
"description": "可选项,针对常见识别错的文字进行替换(支持正则)"
}
},
"description": "文字识别",
"required": ["algorithm", "text"]
}
}
}