-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathEngine.cpp
More file actions
350 lines (253 loc) · 10.9 KB
/
Copy pathEngine.cpp
File metadata and controls
350 lines (253 loc) · 10.9 KB
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
#include "stdafx.h"
#include <Windows.h>
#include <Wingdi.h>
#include <time.h>
#include <iostream>
#include <fstream>
#include <map>
#include <set>
#include <string>
#include <list>
#include "Engine.h"
D3Engine d3Engine;
//skill 01 635 1004 - Half 681 1029
//skill 02 702 1004 - Half 748 1029
//skill 03 768 1004 - Half 814 1029
//skill 04 834 1003 - Half 881 1029
//left 905 1006 - Half 951 1030
//right 970 1006 - Half 1016 1030
//left 905 1006 - Half 951 1030
//right 970 1006 - Half 1016 1030
//Critical Hit Damage - 100% : 319 - 371
//Critical Hit Damage - xx% : 318 - 362
//
//Critical Hit Chance - xx% : 313 - 348
//Critical Hit Chance - a.b% : 313 - 348
//
//
//Reduce melee damage - x% : 368 - 403
const int rol_01_x_left = 318;
const int rol_01_y_top = 388/*Fixed*/;
const int rol_01_x_right = 362;
const int rol_01_y_bottom = 399/*Fixed*/;
const int rol_02_x_left = 313;
const int rol_02_y_top = 432/*Fixed*/;
const int rol_02_x_right = 348;
const int rol_02_y_bottom = 445/*Fixed*/;
const int rol_03_x_left = 318;
const int rol_03_y_top = 476/*Fixed*/;
const int rol_03_x_right = 362;
const int rol_03_y_bottom = 486/*Fixed*/;
const char* RollOption01FilePath = "D:\\DumpRollItem01.txt";
const char* RollOption02FilePath = "D:\\DumpRollItem02.txt";
const char* RollOption03FilePath = "D:\\DumpRollItem03.txt";
const char* logDumpImageFolder = "D:\\DumpImage\\";
void SendD3LeftMouseClick();
void SetD3Mouse(int x, int y);
#ifdef DEBUG
void CaptureInventory(void)
{
int d3WidthScale = 1;
int d3HeightScale = 1;
int xInventoryArray[60] = { int(1428 * d3WidthScale), int(1428 * d3WidthScale), int(1428 * d3WidthScale), int(1428 * d3WidthScale), int(1428 * d3WidthScale), int(1428 * d3WidthScale), int(1478 * d3WidthScale), int(1478 * d3WidthScale), int(1478 * d3WidthScale), int(1478 * d3WidthScale), int(1478 * d3WidthScale), int(1478 * d3WidthScale), int(1529 * d3WidthScale), int(1529 * d3WidthScale), int(1529 * d3WidthScale), int(1529 * d3WidthScale), int(1529 * d3WidthScale), int(1529 * d3WidthScale), int(1579 * d3WidthScale), int(1579 * d3WidthScale), int(1579 * d3WidthScale), int(1579 * d3WidthScale), int(1579 * d3WidthScale), int(1579 * d3WidthScale), int(1630 * d3WidthScale), int(1630 * d3WidthScale), int(1630 * d3WidthScale), int(1630 * d3WidthScale), int(1630 * d3WidthScale), int(1630 * d3WidthScale), int(1680 * d3WidthScale), int(1680 * d3WidthScale), int(1680 * d3WidthScale), int(1680 * d3WidthScale), int(1680 * d3WidthScale), int(1680 * d3WidthScale), int(1731 * d3WidthScale), int(1731 * d3WidthScale), int(1731 * d3WidthScale), int(1731 * d3WidthScale), int(1731 * d3WidthScale), int(1731 * d3WidthScale), int(1781 * d3WidthScale), int(1781 * d3WidthScale), int(1781 * d3WidthScale), int(1781 * d3WidthScale), int(1781 * d3WidthScale), int(1781 * d3WidthScale), int(1831 * d3WidthScale), int(1831 * d3WidthScale), int(1831 * d3WidthScale), int(1831 * d3WidthScale), int(1831 * d3WidthScale), int(1831 * d3WidthScale), int(1881 * d3WidthScale), int(1881 * d3WidthScale), int(1881 * d3WidthScale), int(1881 * d3WidthScale), int(1881 * d3WidthScale), int(1881 * d3WidthScale) };
int yInventoryArray[60] = { int(584 * d3HeightScale), int(634 * d3HeightScale), int(684 * d3HeightScale), int(734 * d3HeightScale), int(784 * d3HeightScale), int(833 * d3HeightScale), int(584 * d3HeightScale), int(634 * d3HeightScale), int(684 * d3HeightScale), int(734 * d3HeightScale), int(784 * d3HeightScale), int(833 * d3HeightScale), int(584 * d3HeightScale), int(634 * d3HeightScale), int(684 * d3HeightScale), int(734 * d3HeightScale), int(784 * d3HeightScale), int(833 * d3HeightScale), int(584 * d3HeightScale), int(634 * d3HeightScale), int(684 * d3HeightScale), int(734 * d3HeightScale), int(784 * d3HeightScale), int(833 * d3HeightScale), int(584 * d3HeightScale), int(634 * d3HeightScale), int(684 * d3HeightScale), int(734 * d3HeightScale), int(784 * d3HeightScale), int(833 * d3HeightScale), int(584 * d3HeightScale), int(634 * d3HeightScale), int(684 * d3HeightScale), int(734 * d3HeightScale), int(784 * d3HeightScale), int(833 * d3HeightScale), int(584 * d3HeightScale), int(634 * d3HeightScale), int(684 * d3HeightScale), int(734 * d3HeightScale), int(784 * d3HeightScale), int(833 * d3HeightScale), int(584 * d3HeightScale), int(634 * d3HeightScale), int(684 * d3HeightScale), int(734 * d3HeightScale), int(784 * d3HeightScale), int(833 * d3HeightScale), int(584 * d3HeightScale), int(634 * d3HeightScale), int(684 * d3HeightScale), int(734 * d3HeightScale), int(784 * d3HeightScale), int(833 * d3HeightScale), int(584 * d3HeightScale), int(634 * d3HeightScale), int(684 * d3HeightScale), int(734 * d3HeightScale), int(784 * d3HeightScale), int(833 * d3HeightScale) };
bool IsD3WindowActive(void);
SetD3Mouse(1000, 500);
d3Engine.DumpRectangle(
1407 + xOffsetItemInventoryArray[0],
563 + yOffsetItemInventoryArray[0],
1449 + xOffsetItemInventoryArray[0],
594 + yOffsetItemInventoryArray[0],
"0");
for (int item = 1; item < 60 && IsD3WindowActive(); item++)
{
SetD3Mouse(xInventoryArray[item - 1], yInventoryArray[item - 1]);
Sleep(100 + (rand() % 5));
SendD3LeftMouseClick();
Sleep(100 + (rand() % 5));
SetD3Mouse(xInventoryArray[item], yInventoryArray[item]);
Sleep(100 + (rand() % 5));
SendD3LeftMouseClick();
Sleep(100 + (rand() % 5));
SetD3Mouse(1000, 500);
Sleep(200 + (rand() % 5));
char bufferPrefix[10] = {};
sprintf_s(bufferPrefix, "%d", item);
d3Engine.DumpRectangle(
1407 + xOffsetItemInventoryArray[item],
563 + yOffsetItemInventoryArray[item],
1449 + xOffsetItemInventoryArray[item],
594 + yOffsetItemInventoryArray[item],
bufferPrefix);
}
}
#endif
void QuangBTDumpScreen(void)
{
#ifdef DEBUG
d3Engine.CaptureDesktop();
d3Engine.SaveScreen();
static bool needCleanFolder = true;
if (needCleanFolder)
{
std::wstring wFolder = L"D:\\DumpImage";
if (wFolder.size() && wFolder[wFolder.size() - 1] != L'\\') wFolder += L'\\';
wFolder += L"*.bmp";
WIN32_FIND_DATAW fd;
HANDLE hFind = FindFirstFileW(wFolder.c_str(), &fd);
if (hFind == INVALID_HANDLE_VALUE) {};
do
{
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{//là thư mục
}
else
{//là file
std::wstring filePath = L"D:\\DumpImage";
if (filePath.size() && filePath[filePath.size() - 1] != L'\\') filePath += L'\\';
filePath += fd.cFileName;
DeleteFileW(filePath.c_str());
}
} while (FindNextFileW(hFind, &fd));
FindClose(hFind);
needCleanFolder = false;
}
//left 905 1006 - Half 951 1030
//right 970 1006 - Half 1016 1030
d3Engine.DumpRollItem();
// d3Engine.DumpSkill01();
// d3Engine.DumpSkill02();
// d3Engine.DumpSkill03();
// d3Engine.DumpSkill04();
//d3Engine.DumpRollOption01();
//d3Engine.DumpRollOption02();
//d3Engine.DumpRollOption03();
//CaptureInventory();
//d3Engine.DumpInventoryItemWithUnderLine();
//d3Engine.DumpFiveZombieDog();
// item slot 01
//d3Engine.DumpRectangle(1407, 563, 1449, 594);
//d3Engine.DumpRectangle(1458, 563, 1498, 594);
//d3Engine.DumpRectangle(171, 776, 282, 785);
#endif // DEBUG
}
/************************************************************************/
/* */
/************************************************************************/
/*Constructor*/ D3Engine::D3Engine(void)
{
hBitmap = NULL;
hScreenMemDC = NULL;
rectDesktop = { 0 };
HWND hDesktop = GetDesktopWindow();
HDC hdcDesktop = GetWindowDC(hDesktop);
if (hdcDesktop != NULL)
{
GetWindowRect(hDesktop, &rectDesktop);
hScreenMemDC = CreateCompatibleDC(hdcDesktop);
if (hScreenMemDC != NULL)
{
hBitmap = CreateCompatibleBitmap(hdcDesktop, rectDesktop.right, rectDesktop.bottom);
if (hBitmap != NULL)
{
SelectObject(hScreenMemDC, hBitmap);
}
else
{
DeleteDC(hScreenMemDC);
hScreenMemDC = NULL;
}
}
ReleaseDC(hDesktop, hdcDesktop);
}
}
void D3Engine::CaptureDesktop(void)
{
HWND hDesktop = GetDesktopWindow();
HDC hdcDesktop = GetWindowDC(hDesktop);
BitBlt(hScreenMemDC, 0, 0, rectDesktop.right, rectDesktop.bottom, hdcDesktop, 0, 0, SRCCOPY);
ReleaseDC(hDesktop, hdcDesktop);
}
int D3Engine::GetPixel(int x, int y)
{
if (hScreenMemDC != NULL)
{
int color = int(::GetPixel(hScreenMemDC, x, y));
return color;
}
return 0;
}
bool D3Engine::ValidMode(void)
{
HWND d3Wnd = FindWindowW(L"D3 Main Window Class", L"Diablo III");
RECT d3rect;
GetClientRect(d3Wnd, &d3rect);
return (hScreenMemDC != NULL
&& d3rect.top == 0
&& d3rect.left == 0
&& d3rect.right == 1920
&& d3rect.bottom == 1080
);
}
/*Destructor*/ D3Engine::~D3Engine()
{
if (hBitmap != NULL) DeleteObject(hBitmap);
if (hScreenMemDC != NULL) DeleteDC(hScreenMemDC);
}
/************************************************************************/
/* Debug */
/************************************************************************/
#ifdef _DEBUG
bool IsD3WindowActive(void);
#include "../DiabloIIICore/GDI/SaveScreen.cpp"
#include "../DiabloIIICore/GDI/DumpRectangle.cpp"
#include "../DiabloIIICore/GDI/DumpSkill.cpp"
#include "../DiabloIIICore/GDI/DumpRollOption.cpp"
#include "../DiabloIIICore/GDI/DumpInventory.cpp"
#endif
#ifdef PREMIUM_FEATURE
#include "../DiabloIIICore/Roll/Roll.cpp"
#include "../DiabloIIICore/Item/Inventory.cpp"
#endif
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
#pragma managed(push, off)
#pragma optimize("", off)
#pragma warning(push)
#pragma warning(disable : 4100)
#else
#pragma GCC push_options
#pragma GCC optimize ("O0")
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#include "../DiabloIIITemp/Diablo3RolDataCode"
#include "../DiabloIIITemp/Diablo3ScreenDataCode"
#include "../DiabloIIITemp/Diablo3Roll"
#ifdef PREMIUM_FEATURE
#include "../DiabloIIICore/Game/Battle"
#include "../DiabloIIICore/Game/Potion"
#include "../DiabloIIICore/Game/Spirit"
#include "../DiabloIIICore/Item/Salvage"
#include "../DiabloIIICore/Skill/Necromancer"
#include "../DiabloIIICore/Skill/DemonHunter"
#include "../DiabloIIICore/Skill/Monk"
#include "../DiabloIIICore/Roll/CriticalHit"
#include "../DiabloIIICore/Roll/ElementDamage"
#include "../DiabloIIICore/Roll/AttackSpeed"
#include "../DiabloIIICore/Roll/Cooldown"
#include "../DiabloIIICore/Roll/ResourceCost"
#include "../DiabloIIICore/Roll/AreaDamage"
#include "../DiabloIIICore/Roll/ReduceDamage"
#include "../DiabloIIICore/Roll/BaseDamage"
#include "../DiabloIIICore/Roll/LifePercent"
#include "../DiabloIIICore/Roll/LifePerHit"
#include "../DiabloIIICore/Roll/LifePerSecond"
#include "../DiabloIIICore/Roll/LifePerKill"
#include "../DiabloIIICore/Roll/Resistance"
#include "../DiabloIIICore/Roll/Socket"
#include "../DiabloIIICore/Roll/Stats"
#include "../DiabloIIICore/Roll/MovementSpeed"
#include "../DiabloIIICore/Roll/Thorn"
#include "../DiabloIIICore/Roll/DemonHunter"
#include "../DiabloIIICore/Roll/Digit"
#endif