本脚本无技术含量,纯个人分享,仅供学习

对象:手机分辨率 2280*1080,应天府


前言

在灶神雕像附近设置水井,可得到祝福产量增加75%,建议全满级水井

进入游戏后不要缩放画面,横线对齐,画面最左边井的角对齐到边

image-20211002103348402

应天 MAX 19井,苏州 MAX 40井

原理:截图查找相似图片进行点击

脚本根据写死的坐标开始制作,自动选人,无人自动跳过,点击到居民会重试

遇到拼图防刷自动枚举完成


基本素材准备

jingbase

jingbase

jing

jing

jing2

jing2

ren

ren


增加拼图素材

依次为 1- 12

123456

789101112


脚本执行软件 AutoJS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
auto.waitFor();
//var devheight = device.height;
//var devwidth = device.width;
if (!requestScreenCapture()) { //请求截图权限
toast("请求截图失败");
exit();
}
toast("请求截图成功");

var jingbase = images.read("jingbase.jpg")
var jing = images.read("jing.jpg");
var ren = images.read("ren.jpg");
var jingflag = 0;
var img, a, b, tmp;
var pin=new Array(13);

if (!jingbase) {
toast("没有井base图");
exit();
}
if (!jing) {
toast("没有井图");
exit();
}
if (!ren) {
toast("没有人图");
exit();
}
/*
for (var tmp = 1; tmp < 13; tmp++) {
pin[tmp] = images.read(tmp.toString + ".png");
}*/
pin[0]=0;
pin[1] = images.read("1.png");
pin[2] = images.read("1.png");
pin[3] = images.read("1.png");
pin[4] = images.read("1.png");
pin[5] = images.read("1.png");
pin[6] = images.read("1.png");
pin[7] = images.read("1.png");
pin[8] = images.read("1.png");
pin[9] = images.read("1.png");
pin[10] = images.read("1.png");
pin[11] = images.read("1.png");
pin[12] = images.read("1.png");

var x1 = 152.6, y1 = 857.5,
x2 = 935, y2 = 1143.5,
xx = (x2 - x1) / 6, yy = (y2 - y1) / 2 ;

var pinxy = [
/////第1行
x1, y1, x1 + xx * 1, yy,
x1 + xx * 1, y1, x1 + xx * 2, yy,
x1 + xx * 2, y1, x1 + xx * 3, yy,
x1 + xx * 3, y1, x1 + xx * 4, yy,
x1 + xx * 4, y1, x1 + xx * 5, yy,
x1 + xx * 5, y1, x2, yy,
/////第2行
x1, yy, x1 + xx * 1, y2,
x1 + xx * 1, yy, x1 + xx * 2, y2,
x1 + xx * 2, yy, x1 + xx * 3, y2,
x1 + xx * 3, yy, x1 + xx * 4, y2,
x1 + xx * 4, yy, x1 + xx * 5, y2,
x1 + xx * 5, yy, x2, y2
];

/*
for (var tmp = 1; tmp < 13; tmp++) {
pinset[tmp - 1] = (pinxy[((tmp - 1) * 4 + 2)] - pinxy[((tmp - 1) * 4)]) / 2; //x坐标
pinset[tmp] = (pinxy[(((tmp - 1) * 4) + 3)] - pinxy[(((tmp - 1) * 4) + 1)]) / 4;//y坐标
}
*/

/////////////////////////////////
var jingxy = [
1035, 464,
943, 408,
842, 361,
722, 303,
601, 238,
960, 525,
720, 416,
599, 357,
359, 357,
482, 414,
720, 539,
837, 572,
593, 599,
460, 539,
234, 410,
115, 470,
234, 535,
353, 599,
480, 658,
607, 720,
//30, 789
];
toast("开始");

while (1) {
for (var i = 0; i < jingxy.length - 1; i += 2) {
for (var j = 0; j < 4; j++) {
sleep(100);
click(330, 1813); //修正
sleep(100);
click(330, 1813); //修正
sleep(200);
click(jingxy[i], jingxy[i + 1]); // 点击井base
clickjing();
if (jingflag) break;
}
jingflag = 0;

}

sleep(86000);
}

function clickjing() {
sleep(400);

for (var l = 0; l < 15; l += 1) { //最长 400 + 15 * 20 = 700ms

img = captureScreen();
a = findImage(img, jing, {
region: [273, 226, 767, 356],
threshold: 0.7 //0-1范围,越大越要求精确
})
if (a) break;
sleep(20);;
}

if (a = false) {
toastLog("未找到井");
c = findColor(img, 0xffa337, {
region: [171, 925, 346, 174],
threshold: 70
});
if (c) { jingflag = 1; toastLog("跳过"); }

d = findColor(img, 0x4d7383, {
region: [52, 581, 988, 98],
threshold: 70
});
if (d) { jingflag = 1; toastLog("拼图");pintu(); }
}
else {
//toastLog("找到了井");
click(a.x + (jing.getWidth() / 2), a.y + (jing.getHeight() / 2));
jingflag = 1;
clickren();
}
}

function clickren() {
sleep(600);
img = captureScreen();
b = findImage(img, ren, {
region: [273, 226, 767, 391],
threshold: 0.6
});
if (b) {
//toastLog("找到了人");
click(b.x + (ren.getWidth() / 2), b.y + (ren.getHeight() / 2 * 4));
} else {
toastLog("未找到人");
}
}

//////////////////////////////////
function pintu() {
for (var kuai = 1; kuai < 13; kuai++) {
p = findImage(img, pin[kuai], {
region: [pinxy[(kuai - 1) * 4], pinxy[(kuai - 1) * 4 + 1], pinxy[(kuai - 1) * 4 + 2], pinxy[(kuai - 1) * 4 + 3]],
threshold: 0.6
});
if (p) {
continue;
}
else {
for (var findkuai = kuai + 1; findkuai < 13; findkuai++) {
p = findImage(img, pin[kuai], {
region: [pinxy[(findkuai - 1) * 4], pinxy[(findkuai - 1) * 4 + 1], pinxy[(findkuai - 1) * 4 + 2], pinxy[(findkuai - 1) * 4 + 3]],
threshold: 0.5
});
if (p) {
toast("找到了" + findkuai);
swipe(pinxy[(findkuai - 1) * 4]+50, pinxy[(findkuai - 1) * 4 + 1]+50,
(pinxy[((kuai - 1) * 4 + 2)] - pinxy[((kuai - 1) * 4)]) / 2,(pinxy[(((kuai - 1) * 4) + 3)] - pinxy[(((kuai - 1) * 4) + 1)]) / 4,
1500);

break;
}
}

}

}
}