-
Notifications
You must be signed in to change notification settings - Fork 0
/
apexmaster.ahk
502 lines (465 loc) · 16.7 KB
/
apexmaster.ahk
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
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
#SingleInstance force
#MaxThreadsBuffer on
#Persistent
Process, Priority, , A
SetBatchLines, -1
ListLines Off
SetWorkingDir %A_ScriptDir%
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
if not A_IsAdmin {
Run *RunAs "%A_ScriptFullPath%"
ExitApp
}
; read settings.ini
GoSub, IniRead
; weapon type constant, mainly for debuging
global DEFAULT_WEAPON_TYPE := "DEFAULT"
global R99_WEAPON_TYPE := "R99"
global R301_WEAPON_TYPE := "R301"
global FLATLINE_WEAPON_TYPE := "FLATLINE"
global SPITFIRE_WEAPON_TYPE := "SPITFIRE"
global LSTAR_WEAPON_TYPE := "LSTAR"
global DEVOTION_WEAPON_TYPE := "DEVOTION"
global DEVOTION_TURBO_WEAPON_TYPE := "DEVOTION TURBO"
global VOLT_WEAPON_TYPE := "VOLT"
global HAVOC_WEAPON_TYPE := "HAVOC"
global HAVOC_TURBO_WEAPON_TYPE := "HAVOC TURBO"
global PROWLER_WEAPON_TYPE := "PROWLER"
global HEMLOK_WEAPON_TYPE := "HEMLOK"
global RE45_WEAPON_TYPE := "RE45"
global ALTERNATOR_WEAPON_TYPE := "ALTERNATOR"
global P2020_WEAPON_TYPE := "P2020"
global RAMPAGE_WEAPON_TYPE := "RAMPAGE"
global WINGMAN_WEAPON_TYPE := "WINGMAN"
global G7_WEAPON_TYPE := "G7"
global CAR_WEAPON_TYPE := "CAR"
global P3030_WEAPON_TYPE := "3030"
global SHOTGUN_WEAPON_TYPE := "shotgun"
; x, y pos for weapon1 and weapon 2
global WEAPON_1_PIXELS = LoadPixel("weapon1")
global WEAPON_2_PIXELS = LoadPixel("weapon2")
; weapon color
global LIGHT_WEAPON_COLOR = 0x2D547D
global HEAVY_WEAPON_COLOR = 0x596B38
global ENERGY_WEAPON_COLOR = 0x286E5A
global SUPPY_DROP_COLOR = 0x3701B2
global SHOTGUN_WEAPON_COLOR = 0x07206B
; three x, y check point, true means 0xFFFFFFFF
; light weapon
global R99_PIXELS := LoadPixel("r99")
global R301_PIXELS := LoadPixel("r301")
global RE45_PIXELS := LoadPixel("re45")
global P2020_PIXELS := LoadPixel("p2020")
; heavy weapon
global FLATLINE_PIXELS := LoadPixel("flatline")
global PROWLER_PIXELS := LoadPixel("prowler")
global HEMLOK_PIXELS := LoadPixel("hemlok")
global RAMPAGE_PIXELS := LoadPixel("rampage")
global WINGMAN_PIXELS := LoadPixel("wingman")
global P3030_PIXELS := LoadPixel("p3030")
; special
global CAR_PIXELS := LoadPixel("car")
; energy weapon
global LSTAR_PIXELS := LoadPixel("lstar")
global DEVOTION_PIXELS := LoadPixel("devotion")
global VOLT_PIXELS := LoadPixel("volt")
global HAVOC_PIXELS := LoadPixel("havoc")
; supply drop weapon
global G7_PIXELS := LoadPixel("g7")
global SPITFIRE_PIXELS := LoadPixel("spitfire")
global ALTERNATOR_PIXELS := LoadPixel("alternator")
; Turbocharger
global HAVOC_TURBOCHARGER_PIXELS := LoadPixel("havoc_turbocharger")
global DEVOTION_TURBOCHARGER_PIXELS := LoadPixel("devotion_turbocharger")
; for gold optics
EMCol := 0x3841AD,0x333DB1
ColVn := 8
AntiShakeX := (A_ScreenHeight // 80)
AntiShakeY := (A_ScreenHeight // 64)
ZeroX := (A_ScreenWidth // 2)
ZeroY := (A_ScreenHeight // 2)
CFovX := (A_ScreenWidth // 32)
CFovY := (A_ScreenHeight // 32)
ScanL := ZeroX - CFovX
ScanT := ZeroY - CFovY
ScanR := ZeroX + CFovX
ScanB := ZeroY + CFovY
NearAimScanL := ZeroX - AntiShakeX
NearAimScanT := ZeroY - AntiShakeY
NearAimScanR := ZeroX + AntiShakeX
NearAimScanB := ZeroY + AntiShakeY
; each player can hold 2 weapons
LoadPixel(name) {
global resolution
IniRead, weapon_pixel_str, %A_ScriptDir%\resolution\%resolution%.ini, pixels, %name%
weapon_num_pixels := []
Loop, Parse, weapon_pixel_str, `,
{
if StrLen(A_LoopField) == 0 {
Continue
}
weapon_num_pixels.Insert(A_LoopField)
}
return weapon_num_pixels
}
; load pattern from file
LoadPattern(filename) {
FileRead, pattern_str, %A_ScriptDir%\pattern\%filename%
pattern := []
Loop, Parse, pattern_str, `n, `, , `" ,`r
{
if StrLen(A_LoopField) == 0 {
Continue
}
pattern.Insert(A_LoopField)
}
return pattern
}
; light weapon pattern
global R301_PATTERN := LoadPattern("R301.txt")
global R99_PATTERN := LoadPattern("R99.txt")
global RE45_PATTERN := LoadPattern("RE45.txt")
global P2020_PATTERN := LoadPattern("P2020.txt")
; energy weapon pattern
global LSTAR_PATTERN := LoadPattern("Lstar.txt")
global DEVOTION_PATTERN := LoadPattern("Devotion.txt")
global TURBODEVOTION_PATTERN := LoadPattern("DevotionTurbo.txt")
global VOLT_PATTERN := LoadPattern("Volt.txt")
global HAVOC_PATTERN := LoadPattern("Havoc.txt")
global TURBOHAVOC_PATTERN := LoadPattern("HavocTurbo.txt")
global P3030_PATTERN := LoadPattern("3030.txt")
; special
global CAR_PATTERN := LoadPattern("CAR.txt")
; heavy weapon pattern
global FLATLINE_PATTERN := LoadPattern("Flatline.txt")
global RAMPAGE_PATTERN := LoadPattern("Rampage.txt")
global RAMPAGEAMP_PATTERN := LoadPattern("RampageAmp.txt")
global PROWLER_PATTERN := LoadPattern("Prowler.txt")
global HEMLOK_PATTERN := LoadPattern("Hemlok.txt")
global WINGMAN_PATTERN := LoadPattern("Wingman.txt")
; supply drop weapon pattern
global SPITFIRE_PATTERN := LoadPattern("Spitfire.txt")
global ALTERNATOR_PATTERN := LoadPattern("Alternator.txt")
global G7_Pattern := LoadPattern("G7.txt")
; tips setting
global hint_method := "Say"
; voice setting
SAPI.voice := SAPI.GetVoices().Item(1) ; uncomment this line to get female voice.
SAPI:=ComObjCreate("SAPI.SpVoice")
SAPI.rate:=rate
SAPI.volume:=volume
; weapon detection
global current_pattern := ["0,0,0"]
global current_weapon_type := DEFAULT_WEAPON_TYPE
global is_single_fire_weapon := false
global is_op_gold_optics_weapon := false
; mouse sensitivity setting
zoom := 1.0/zoom_sens
global modifier := 4/sens*zoom
; check whether the current weapon match the weapon pixels
CheckWeapon(weapon_pixels)
{
target_color := 0xFFFFFF
i := 1
loop, 3 {
PixelGetColor, check_point_color, weapon_pixels[i], weapon_pixels[i + 1]
if (weapon_pixels[i + 2] != (check_point_color == target_color)) {
return False
}
i := i + 3
}
return True
}
CheckTurbocharger(turbocharger_pixels)
{
target_color := 0xFFFFFF
PixelGetColor, check_point_color, turbocharger_pixels[1], turbocharger_pixels[2]
if (check_point_color == target_color) {
return true
}
return false
}
DetectAndSetWeapon()
{
sleep 100
; init
is_single_fire_weapon := false
is_op_gold_optics_weapon := false
current_weapon_type := DEFAULT_WEAPON_TYPE
; first check which weapon is activate
check_point_color := 0
PixelGetColor, check_weapon1_color, WEAPON_1_PIXELS[1], WEAPON_1_PIXELS[2]
PixelGetColor, check_weapon2_color, WEAPON_2_PIXELS[1], WEAPON_2_PIXELS[2]
if (check_weapon1_color == LIGHT_WEAPON_COLOR || check_weapon1_color == HEAVY_WEAPON_COLOR
|| check_weapon1_color == ENERGY_WEAPON_COLOR || check_weapon1_color == SUPPY_DROP_COLOR || check_weapon1_color == SHOTGUN_WEAPON_COLOR) {
check_point_color := check_weapon1_color
} else if (check_weapon2_color == LIGHT_WEAPON_COLOR || check_weapon2_color == HEAVY_WEAPON_COLOR || check_weapon2_color == ENERGY_WEAPON_COLOR
|| check_weapon2_color == SUPPY_DROP_COLOR || check_weapon2_color == SHOTGUN_WEAPON_COLOR) {
check_point_color := check_weapon2_color
} else {
return
}
; then check the weapon type
if (check_point_color == LIGHT_WEAPON_COLOR) {
if (CheckWeapon(R301_PIXELS)) {
current_weapon_type := R301_WEAPON_TYPE
current_pattern := R301_PATTERN
} else if (CheckWeapon(R99_PIXELS)) {
current_weapon_type := R99_WEAPON_TYPE
current_pattern := R99_PATTERN
} else if (CheckWeapon(RE45_PIXELS)) {
current_weapon_type := RE45_WEAPON_TYPE
current_pattern := RE45_PATTERN
} else if (CheckWeapon(P2020_PIXELS)) {
current_weapon_type := P2020_WEAPON_TYPE
current_pattern := P2020_PATTERN
is_single_fire_weapon := true
} else if (CheckWeapon(CAR_PIXELS)) {
current_weapon_type := CAR_WEAPON_TYPE
current_pattern := CAR_PATTERN
}
} else if (check_point_color == HEAVY_WEAPON_COLOR) {
if (CheckWeapon(FLATLINE_PIXELS)) {
current_weapon_type := FLATLINE_WEAPON_TYPE
current_pattern := FLATLINE_PATTERN
} else if (CheckWeapon(PROWLER_PIXELS)) {
current_weapon_type := PROWLER_WEAPON_TYPE
current_pattern := PROWLER_PATTERN
is_single_fire_weapon := true
} else if (CheckWeapon(HEMLOK_PIXELS)) {
current_weapon_type := HEMLOK_WEAPON_TYPE
current_pattern := HEMLOK_PATTERN
is_single_fire_weapon := true
} else if (CheckWeapon(RAMPAGE_PIXELS)) {
current_weapon_type := RAMPAGE_WEAPON_TYPE
current_pattern := RAMPAGE_PATTERN
} else if (CheckWeapon(WINGMAN_PIXELS)) {
current_weapon_type := WINGMAN_WEAPON_TYPE
current_pattern := WINGMAN_PATTERN
is_single_fire_weapon := true
; is_op_gold_optics_weapon := true
} else if (CheckWeapon(CAR_PIXELS)) {
current_weapon_type := CAR_WEAPON_TYPE
current_pattern := CAR_PATTERN
} else if (CheckWeapon(P3030_PIXELS)) {
current_weapon_type := P3030_WEAPON_TYPE
current_pattern := P3030_PATTERN
is_single_fire_weapon := true
}
} else if (check_point_color == ENERGY_WEAPON_COLOR) {
if (CheckWeapon(LSTAR_PIXELS)) {
current_weapon_type := LSTAR_WEAPON_TYPE
current_pattern := LSTAR_PATTERN
} else if (CheckWeapon(DEVOTION_PIXELS)) {
current_weapon_type := DEVOTION_WEAPON_TYPE
current_pattern := DEVOTION_PATTERN
if (CheckTurbocharger(DEVOTION_TURBOCHARGER_PIXELS)) {
current_pattern := TURBODEVOTION_PATTERN
current_weapon_type := DEVOTION_TURBO_WEAPON_TYPE
}
} else if (CheckWeapon(VOLT_PIXELS)) {
current_weapon_type := VOLT_WEAPON_TYPE
current_pattern := VOLT_PATTERN
} else if (CheckWeapon(HAVOC_PIXELS)) {
current_weapon_type := HAVOC_WEAPON_TYPE
current_pattern := HAVOC_PATTERN
if (CheckTurbocharger(HAVOC_TURBOCHARGER_PIXELS)) {
current_pattern := TURBOHAVOC_PATTERN
current_weapon_type := HAVOC_TURBO_WEAPON_TYPE
}
}
} else if (check_point_color == SUPPY_DROP_COLOR) {
if (CheckWeapon(SPITFIRE_PIXELS)) {
current_weapon_type := SPITFIRE_WEAPON_TYPE
current_pattern := SPITFIRE_PATTERN
} else if (CheckWeapon(ALTERNATOR_PIXELS)) {
current_weapon_type := ALTERNATOR_WEAPON_TYPE
current_pattern := ALTERNATOR_PATTERN
} else if (CheckWeapon(G7_PIXELS)) {
current_weapon_type := G7_WEAPON_TYPE
current_pattern := G7_Pattern
is_single_fire_weapon := true
}
} else if (check_point_color == SHOTGUN_WEAPON_COLOR) {
current_weapon_type := SHOTGUN_WEAPON_TYPE
is_op_gold_optics_weapon := true
}
%hint_method%(current_weapon_type)
}
~E Up::
Sleep, 200
DetectAndSetWeapon()
return
~*1::
~*2::
~B::
~R::
DetectAndSetWeapon()
return
~3::
current_weapon_type := DEFAULT_WEAPON_TYPE
return
; For user using ads_only, they don't have to reset the current_weapon_type.
; This is meaningful to me since I sometimes will shot after throwing a grenade.
~G::
~Z::
if (!ads_only) {
current_weapon_type := DEFAULT_WEAPON_TYPE
}
return
~End::
ExitApp
return
~$*RButton::
if (IsMouseShown() || !op_gold_optics || !is_op_gold_optics_weapon)
return
Loop, {
PixelSearch, AimPixelX, AimPixelY, NearAimScanL, NearAimScanT, NearAimScanR, NearAimScanB, EMCol, ColVn, Fast
; If the collimator is already in the corresponding color attachment, do not move to avoid shaking
if (ErrorLevel) {
loop, 10 {
PixelSearch, AimPixelX, AimPixelY, ScanL, ScanT, ScanR, ScanB, EMCol, ColVn, Fast
AimX := AimPixelX - ZeroX
AimY := AimPixelY - ZeroY
DirX := -1
DirY := -1
If ( AimX > 0 ) {
DirX := 1
}
If ( AimY > 0 ) {
DirY := 1
}
AimOffsetX := AimX * DirX
AimOffsetY := AimY * DirY
MoveX := Floor(( AimOffsetX ** ( 1 / 2 ))) * DirX
MoveY := Floor(( AimOffsetY ** ( 1 / 2 ))) * DirY
DllCall("mouse_event", uint, 1, int, MoveX * 1.5, int, MoveY, uint, 0, int, 0)
if (!GetKeyState("RButton","P")) {
break
}
}
}
if (!GetKeyState("RButton","P")) {
break
}
}
return
~$*LButton::
if (IsMouseShown() || current_weapon_type == DEFAULT_WEAPON_TYPE || current_weapon_type == SHOTGUN_WEAPON_TYPE)
return
if (ads_only && !GetKeyState("RButton"))
return
if (is_single_fire_weapon && !auto_fire)
return
Loop {
i := A_Index
if (A_Index > current_pattern.MaxIndex()) {
i := current_pattern.MaxIndex()
}
compensation := StrSplit(current_pattern[i],",")
if (compensation.MaxIndex() < 3) {
return
}
x := compensation[1]
y := compensation[2]
interval := compensation[3]
if (is_single_fire_weapon) {
Click
Random, rand, 1, 20
interval := interval + rand
}
DllCall("mouse_event", uint, 0x01, uint, Round(x * modifier), uint, Round(y * modifier))
Sleep, interval
if (!GetKeyState("LButton","P")) {
DllCall("mouse_event", uint, 4, int, 0, int, 0, uint, 0, int, 0)
break
}
}
return
IniRead:
IfNotExist, settings.ini
{
MsgBox, Couldn't find settings.ini. I'll create one for you.
IniWrite, "1080x1920"`n, settings.ini, screen settings, resolution
IniWrite, "5.0", settings.ini, mouse settings, sens
IniWrite, "1.0", settings.ini, mouse settings, zoom_sens
IniWrite, "1", settings.ini, mouse settings, auto_fire
IniWrite, "0", settings.ini, mouse settings, ads_only
IniWrite, "0"`n, settings.ini, mouse settings, op_gold_optics
IniWrite, "80", settings.ini, voice settings, volume
IniWrite, "7", settings.ini, voice settings, rate
if (A_ScriptName == "apexmaster.ahk") {
Run "apexmaster.ahk"
} else if (A_ScriptName == "apexmaster.exe") {
Run "apexmaster.exe"
}
}
Else {
IniRead, resolution, settings.ini, screen settings, resolution
IniRead, zoom_sens, settings.ini, mouse settings, zoom_sens
IniRead, sens, settings.ini, mouse settings, sens
IniRead, auto_fire, settings.ini, mouse settings, auto_fire
IniRead, op_gold_optics, settings.ini, mouse settings, op_gold_optics
IniRead, ads_only, settings.ini, mouse settings, ads_only
IniRead, volume, settings.ini, voice settings, volume
IniRead, rate, settings.ini, voice settings, rate
}
return
; Suspends the script when mouse is visible ie: inventory, menu, map.
IsMouseShown()
{
StructSize := A_PtrSize + 16
VarSetCapacity(InfoStruct, StructSize)
NumPut(StructSize, InfoStruct)
DllCall("GetCursorInfo", UInt, &InfoStruct)
Result := NumGet(InfoStruct, 8)
if Result > 1
return true
else
Return false
}
ActiveMonitorInfo(ByRef X, ByRef Y, ByRef Width, ByRef Height)
{
CoordMode, Mouse, Screen
MouseGetPos, mouseX, mouseY
SysGet, monCount, MonitorCount
Loop %monCount% {
SysGet, curMon, Monitor, %a_index%
if ( mouseX >= curMonLeft and mouseX <= curMonRight and mouseY >= curMonTop and mouseY <= curMonBottom ) {
X := curMonTop
y := curMonLeft
Height := curMonBottom - curMonTop
Width := curMonRight - curMonLeft
return
}
}
}
Say(text)
{
global SAPI
SAPI.Speak(text, 1)
sleep 150
return
}
Tooltip(Text)
{
ActiveMonitorInfo(X, Y, Width, Height)
xPos := Width / 2 - 50
yPos := Height / 2 + (Height / 10)
Tooltip, %Text%, xPos, yPos
SetTimer, RemoveTooltip, 500
return
RemoveTooltip:
SetTimer, RemoveTooltip, Off
Tooltip
return
}