Skip to content

Commit

Permalink
Merge pull request icegreentee#361 from segfault-bilibili/rollup-6.4.7
Browse files Browse the repository at this point in the history
【6.4.7】临时开荒支持地图型
  • Loading branch information
segfault-bilibili committed Sep 1, 2022
2 parents 702c5d4 + 73459ed commit a6ccdc0
Show file tree
Hide file tree
Showing 23 changed files with 122 additions and 19 deletions.
106 changes: 103 additions & 3 deletions floatUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -8324,6 +8324,9 @@ function algo_init() {
"newQuest",
"startBtn",
"closeBtn",
"sectionClearMagiaStone",
"sectionOnMapJP",
"shinnyNew",
];

var loadAllImages = syncer.syn(function () {
Expand Down Expand Up @@ -10220,7 +10223,25 @@ function algo_init() {
bottomRight: {
x: 1919, y: 539, pos: "center"
}
}
},
sectionClearMagiaStone: {
//[895,482][1001,589]
topLeft: {
x: 885, y: 472, pos: "center"
},
bottomRight: {
x: 1011, y: 599, pos: "center"
}
},
sectionOnMapJP: {
//搜索右大半边地图
topLeft: {
x: 600, y: 128, pos: "top"
},
bottomRight: {
x: 1919, y: 1079, pos: "bottom"
}
},
};
function getButtonArea(type) {
let knownArea = knownButtonCoords[type];
Expand All @@ -10240,6 +10261,20 @@ function algo_init() {
log(type, point);
return point;
}
function findAllButtons(screenshot, type) {
let template = knownImgs[type];
let img = getButtonImg(screenshot, type);
let matched = null;
try {
matched = images.matchTemplate(img, template, {threshold: 0.9, max: 64});
} catch (e) {
matched = null;
}
if (matched != null && matched.first() != null) matched = matched.points;
else matched = null;
log(type, matched);
return matched;
}
function isButtonPresent(screenshot, type) {
return findButton(screenshot, type) ? true : false;
}
Expand All @@ -10255,6 +10290,62 @@ function algo_init() {
function isMirrorsEntranceButtonPresent(screenshot) {
return isButtonPresent(screenshot, "mirrorsEntranceBtn");
}
function isSectionClear(screenshot) {
return isButtonPresent(screenshot, "sectionClearMagiaStone");
}
function findNewSectionOnMap(screenshot) {
const imgName = "sectionOnMapJP";
let points = findAllButtons(screenshot, imgName);
if (points == null) return null;

const btnSize = getConvertedAreaNoCutout({
topLeft: {x: 0, y: 0, pos: "top"},
bottomRight: {x: 270, y: 210, pos: "top"}
});
const btnOffset = getConvertedAreaNoCutout({
topLeft: {x: 0, y: 0, pos: "top"},
bottomRight: {x: 206, y: 22, pos: "top"}
});

let areas = [];
const searchedArea = getButtonArea(imgName);
points.forEach((point) => {
let area = {topLeft: {pos: "top"}, bottomRight: {pos: "top"}};
for (let corner in btnSize) {
["x", "y"].forEach((axis) => {
//计算出整个按钮所在区域
area[corner][axis] = searchedArea.topLeft[axis]
+ point[axis]
+ btnSize[corner][axis]
- btnOffset.bottomRight[axis];
//防止超出屏幕边界(否则后面截取部分图片时会崩溃)
if (area[corner][axis] > searchedArea.bottomRight[axis])
area[corner][axis] = searchedArea.bottomRight[axis];
});
}
areas.push(area);
});
log("areas", areas);

let point = null;
const template = knownImgs["shinnyNew"];
for (let deadlineTime = new Date().getTime() + 5000; new Date().getTime() <= deadlineTime; ) {
screenshot = compatCaptureScreen();
areas.find((area) => {
let img = renewImage(images.clip(screenshot, area.topLeft.x, area.topLeft.y, getAreaWidth(area), getAreaHeight(area)));
point = images.findImage(img, template, {threshold: 0.85});
if (point != null) {
["x", "y"].forEach((axis) => point[axis] += area.topLeft[axis]);
point.x += parseInt(template.getWidth() / 2);
return true;
}
});
}

log("shinnyNew(click)", point);

return point;
}

//判断是否出现超时回镜层首页按钮
var knownBackToMirrorsTopButtonCoords = {
Expand Down Expand Up @@ -11743,8 +11834,9 @@ function algo_init() {
initOCR();

dialogs.alert("临时开荒辅助",
"临时开荒辅助脚本能够在一个章节(section)内自动选BATTLE进行周回,\n"
+"但不会嗑药,也不会处理掉线等情况。"
"临时开荒辅助脚本能够在一个章节(section)内自动选BATTLE进行周回;\n"
+"以及支持地图型周回,但在找不到没打过(new)的关卡时不会自动拖动地图;\n"
+"另外,不会嗑药,也不会处理掉线等情况。"
);

log("缩放图片...");
Expand Down Expand Up @@ -11818,6 +11910,8 @@ function algo_init() {
return found;
}
while (true) {
let newSectionOnMapPoint = null;

let screenshot = compatCaptureScreen();
if (isMarkedAsNewQuest(screenshot)) {
click(convertCoords(getAreaCenter(knownNewQuestCoords)));
Expand All @@ -11833,6 +11927,12 @@ function algo_init() {
click(convertCoords(clickSets.levelup));
} else if (isQuestResult(screenshot)) {
click(convertCoords(clickSets.closeFollowPrompt));
} else if (isSectionClear(screenshot)) {
click(convertCoords(clickSets.screenCenter));
} else if ((newSectionOnMapPoint = findNewSectionOnMap(screenshot))) {
click(newSectionOnMapPoint);
newSectionOnMapPoint = null;
sleep(3000);
}
sleep(1000);
}
Expand Down
Binary file added images/sectionClearMagiaStone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/sectionOnMapJP.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/shinnyNew.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"build"
],
"packageName": "top.momoe.auto",
"versionName": "6.4.6",
"versionName": "6.4.7",
"versionInfo": "",
"versionCode": 1,
"icon":"./images/icon.png",
Expand Down
2 changes: 1 addition & 1 deletion update/fileJson/43.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion update/fileJson/44.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion update/fileJson/45.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion update/fileJson/46.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion update/fileJson/47.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion update/fileJson/48.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion update/fileJson/49.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion update/fileJson/50.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion update/fileJson/51.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion update/fileJson/52.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion update/fileJson/53.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion update/fileJson/54.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion update/fileJson/55.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions update/fileJson/56.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions update/fileJson/57.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions update/fileJson/58.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion update/updateList.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion update/updateList.json.sig.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
oi8Jf1U0WOdOR1wGBa7iPSIzGwPUcQH3dg6JliKsm3UbjdnwS420zEoGZxlSb0GplJqPNHOU6SIdA/GZ+8+4kkvLnhBfCK0goBPANHBQTtz25ICkUqcauRssuIzXFCPj0QZWtwlVkHQJb7QOhzY2jkV4F0arp4AlKOY0uBv2ws/YiR84Ipu9P89WA9zG+HL4aLvdrjznIJfzw5aa7xmnhU5QVSczCvxQsjZZjd3X5ybQb+SjWJ+sP3DtDtPI6fRNWyDtkn8cdncnAUQ8OzBsjVl/N7WEeFueD1JYl3WlQZ/+Zf5+r83v5ylCQcTyDoNSnl8Sr+Q0luxNnY8LEecPuQ==
YPyD2keuN0E1M7MaR7vUokFnTFqXp3IbRdDp+UaJyT1Tm87lTrcbUvKOOP4bQv+4eSkMfSC1Xmlg8OVVPO2JmJcmqkgZUnTrOE+xfU2cA0J/9MlgtIcAAOGNJxFJtbk/HBgZAczFGIcBMiFwlk9GVN8nZ3mY+yuzbvH/hByMKUWvobe1P0b0Sj/8RSCEBbRwtEe7RWnt3VFlV9/xQFdBzfbsMM8nDdZcZfhigWP7Fi6b4j7gHvpZMz0oJG7NmhAN+E7zKNB95EHU//vpai6pJzytv5Mj6SgIxeG/vN3+iZDBWJXKj8FiDvazETVBdgBuB3zU59lY1P0H2tZb7g1FzQ==

0 comments on commit a6ccdc0

Please sign in to comment.