-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.cpp
422 lines (361 loc) · 8.3 KB
/
scripts.cpp
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
#include "pch.h"
#include "scripts.h"
#include "MirageDragon.h"
#include "MirageDragonDlg.h"
#include "dnfData.h"
#include "dnfMap.h"
#include "keyboardDriver.h"
#include "dnfCALL.h"
#include "dnfUser.h"
#include "dnfBase.h"
// 跑到目标
BOOL runToDestination(int x, int y, bool is_room = false, int target_range = 10)
{
CMirageDragonDlg* mainWindow = (CMirageDragonDlg*)theApp.m_pMainWnd;
InstanceLock wind(mainWindow);
if (x < 1 || y < 1) {
{
InstanceLock lock(mainWindow);
mainWindow->Log(L"位置太近,放弃跑图");
}
return false;
}
CString coor;
coor.Format(L"目标坐标 X:%d Y:%d", x, y);
{
InstanceLock lock(mainWindow);
mainWindow->Log(coor);
}
COORDINATE user_coor = readCoordinate(readLong(C_USER));
bool x_arrived = false, y_arrived = false, isFirst = true, arrive_next = false;
int direction_x;
int direction_y;
if (x > user_coor.x) {
direction_x = Keyboard_RightArrow;
}
else {
direction_x = Keyboard_LeftArrow;
}
if (y > user_coor.y) {
direction_y = Keyboard_DownArrow;
}
else {
direction_y = Keyboard_UpArrow;
}
// 记录当前时间戳
time_t cur_time = time(NULL);
while (true) {
// 如果跑图时间超过5秒。则直接退出跑图
if (time(NULL) - cur_time > 2) {
{
InstanceLock lock(mainWindow);
mainWindow->Log(L"跑图超时,退出跑图");
}
return false;
}
user_coor = readCoordinate(readLong(C_USER));
if (isFirst) {
{
InstanceLock lock(mainWindow);
mainWindow->Log(L"开始跑图");
}
MSDK_keyPress(direction_x, 1);
MSDK_DelayRandom(50, 100);
MSDK_KeyDown(direction_x);
MSDK_DelayRandom(100, 150);
MSDK_KeyDown(direction_y);
// 跑向房间优先跑Y轴,防止意外进入其他房间
if (is_room) {
int x_diff = abs(x - user_coor.x);
int y_diff = abs(y - user_coor.y);
// 如果是上下移动,则立刻弹起左右方向键
if (x_diff < y_diff) {
MSDK_KeyUp(direction_x);
}
}
}
if (game_status != 3) {
//不在图内,停止跑图;
{
InstanceLock lock(mainWindow);
mainWindow->Log(L"人物已离开图内,停止跑图");
}
MSDK_ReleaseAllKey();
break;
}
// 判断人物动作
__int64 user_action = decrypt(readLong(C_USER) + C_MOVEMENT_ID);
if ((int)user_action != 14) {
{
InstanceLock lock(mainWindow);
CString msg;
msg.Format(L"当前动作ID:%ld,非跑动状态已停止跑图", user_action);
mainWindow->Log(msg);
}
// 弹起移动按键
MSDK_KeyUp(direction_x);
MSDK_KeyUp(direction_y);
break;
}
int y_range = 10;
if (is_room) {
y_range = 3;
}
// 优先到达Y坐标
if (y_arrived == false) {
if (direction_y == Keyboard_UpArrow) {
if (y - user_coor.y > y_range) {
{
InstanceLock lock(mainWindow);
mainWindow->Log(L"向上超出Y范围,停止");
}
MSDK_ReleaseAllKey();
break;
}
}
else {
if (user_coor.y - y > y_range) {
{
InstanceLock lock(mainWindow);
mainWindow->Log(L"向下超出Y范围,停止");
}
MSDK_ReleaseAllKey();
break;
}
}
if (abs(user_coor.y - y) > y_range) {
isFirst = false;
continue;
}
else {
MSDK_KeyUp(direction_y);
y_arrived = true;
}
}
if (x_arrived == false) {
if (direction_x == Keyboard_RightArrow) {
if (user_coor.x - x > target_range) {
{
InstanceLock lock(mainWindow);
mainWindow->Log(L"向右超出X范围,停止");
}
MSDK_ReleaseAllKey();
break;
}
}
else {
if (x - user_coor.x > target_range) {
{
InstanceLock lock(mainWindow);
mainWindow->Log(L"向左超出X范围,停止");
}
MSDK_ReleaseAllKey();
break;
}
}
if (abs(user_coor.x - x) > target_range) {
isFirst = false;
continue;
}
else {
MSDK_KeyUp(direction_x);
x_arrived = true;
}
}
if (x_arrived && y_arrived) {
{
InstanceLock lock(mainWindow);
mainWindow->Log(L"到达目标位置,停止按键");
}
MSDK_ReleaseAllKey();
return true;
break;
}
Sleep(100);
//programDelay(100);
}
handleEvents();
{
InstanceLock lock(mainWindow);
mainWindow->Log(L"跑图结束,停止按键");
}
MSDK_ReleaseAllKey();
return false;
}
void autoNextRoom()
{
if (game_status != 3) {
return;
}
COORDINATE room_coor = getCurrentRoom();
COORDINATE boss_coor = getBossRoom();
if (room_coor.x == boss_coor.x && room_coor.y == boss_coor.y) {
return;
}
int next_direction = judgeNextRoomDiretion(room_coor, boss_coor);
{
CMirageDragonDlg* mainWindow = (CMirageDragonDlg*)theApp.m_pMainWnd;
InstanceLock wind(mainWindow);
CString msg;
switch (next_direction)
{
case 0:
msg = L"向左奔跑";
break;
case 1:
msg = L"向右奔跑";
break;
case 2:
msg = L"向上奔跑";
break;
case 3:
msg = L"向下奔跑";
break;
default:
{
InstanceLock lock(mainWindow);
mainWindow->Log(L"获取下个房间入口失败!");
}
return;
}
{
InstanceLock lock(mainWindow);
mainWindow->Log(msg);
}
}
runToNextRoom(next_direction);
}
void runToNextRoom(int direction)
{
__int64 target_room_x; // 目标的房间X
__int64 target_room_y; // 目标的房间Y
target_room_x = readLong(readLong(readLong(readLong(C_ROOM_NUMBER) + C_TIME_ADDRESS) + C_DOOR_TYPE_OFFSET) + C_CURRENT_ROOM_X);
target_room_y = readLong(readLong(readLong(readLong(C_ROOM_NUMBER) + C_TIME_ADDRESS) + C_DOOR_TYPE_OFFSET) + C_CURRENT_ROOM_Y);
__int64 pass_room_data = passRoomData(direction);
__int64 coor_struct = pass_room_data;
int begin_x, begin_y, end_x, end_y, calc_x, calc_y;
begin_x = readInt(coor_struct + 0);
begin_y = readInt(coor_struct + 4);
end_x = readInt(coor_struct + 8);
end_y = readInt(coor_struct + 12);
int far_door;
if (use_pass_room_call) {
far_door = 20;
}
else {
far_door = 100; // 远离门的距离,防止卡门
}
switch (direction)
{
case 0:
target_room_x--;
calc_x = begin_x + end_x + far_door;
calc_y = begin_y + end_y / 2;
break;
case 1:
target_room_x++;
calc_x = begin_x - far_door;
calc_y = begin_y + end_y / 2;
break;
case 2:
target_room_y++;
calc_x = begin_x + end_x / 2;
calc_y = begin_y + end_y + far_door;
break;
case 3:
target_room_y--;
calc_x = begin_x + end_x / 2;
calc_y = begin_y - far_door;
break;
default:
return;
break;
}
if (calc_x < 0 || calc_y < 0)
{
return;
}
if (use_pass_room_call) {
coorCall(calc_x, calc_y, 0);
Sleep(50);
coorCall(begin_x + end_x / 2, begin_y, 0);
}
else {
// 跑目标地点,如果不是向上跑图,则优化传送门位置
int new_begin_y = begin_y;
if (direction != 2) {
new_begin_y = begin_y + 40;
}
runToDestination(begin_x + end_x / 2, new_begin_y, true, 2);
__int64 current_room_x, current_room_y;
current_room_x = readLong(readLong(readLong(readLong(C_ROOM_NUMBER) + C_TIME_ADDRESS) + C_DOOR_TYPE_OFFSET) + C_CURRENT_ROOM_X);
current_room_y = readLong(readLong(readLong(readLong(C_ROOM_NUMBER) + C_TIME_ADDRESS) + C_DOOR_TYPE_OFFSET) + C_CURRENT_ROOM_Y);
if (target_room_x != current_room_x || target_room_y != current_room_y)
{
return;
}
Sleep(100);
// 远离目标地点(防止卡在入口处)
runToDestination(calc_x, calc_y, true, 2);
}
}
void firstRoomFunctions()
{
CMirageDragonDlg* mainWindow = (CMirageDragonDlg*)theApp.m_pMainWnd;
if (is_auto_play)
{
// 上上空格
MSDK_keyPress(Keyboard_UpArrow, 1);
MSDK_keyPress(Keyboard_UpArrow, 1);
MSDK_keyPress(Keyboard_KongGe, 1);
MSDK_DelayRandom(200, 350);
// 右右空格
MSDK_keyPress(Keyboard_RightArrow, 1);
MSDK_keyPress(Keyboard_RightArrow, 1);
MSDK_keyPress(Keyboard_KongGe, 1);
MSDK_DelayRandom(200, 350);
}
if (function_switch.score)
{
superScore();
}
if (function_switch.cool_down)
{
CString num;
mainWindow->page2._cool_down.GetWindowText(num);
float number = (float)_ttof(num);
skillCoolDown(number);
}
if (function_switch.hook_damage)
{
hookDamage(true);
}
if (function_switch.three_speed)
{
CString attack_speed, move_speed, casting_speed;
mainWindow->page2._attack_speed.GetWindowText(attack_speed);
mainWindow->page2._move_speed.GetWindowText(move_speed);
mainWindow->page2._casting_speed.GetWindowText(casting_speed);
threeSpeed(_ttoi(attack_speed), _ttoi(casting_speed), _ttoi(move_speed));
}
if (function_switch.hidden_user)
{
hiddenUser();
}
}
void closeDungeonFunctions()
{
CMirageDragonDlg* mainWindow = (CMirageDragonDlg*)theApp.m_pMainWnd;
if (function_switch.cool_down)
{
skillCoolDown(0);
}
if (function_switch.hook_damage)
{
hookDamage(false);
}
if (function_switch.three_speed)
{
threeSpeed(0, 0, 0);
}
}