-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwarlock.py
More file actions
130 lines (116 loc) · 3.59 KB
/
warlock.py
File metadata and controls
130 lines (116 loc) · 3.59 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
import time
import json
import win32api
import win32con
from playsound import playsound
LMB = 0x01
RMB = 0x02
end = 0x2E
enable = 0x2D
rel = 0x52 #reload
loadout = 0x48
swap1 = 0x31
swap2 = 0x32
def is_mb_pressed():
return win32api.GetKeyState(LMB) < 0 and win32api.GetKeyState(RMB) < 0
def is_end_pressed():
return win32api.GetKeyState(end) < 0
def is_reload_pressed():
return win32api.GetKeyState(rel) < 0
def is_loadout_pressed():
return win32api.GetKeyState(loadout) < 0
def is_swap_pressed():
if win32api.GetKeyState(swap1) < 0 or win32api.GetKeyState(swap2) < 0:
time.sleep(.05)
return True
return False
def mouse_move_relative(dx, dy):
win32api.mouse_event(win32con.MOUSEEVENTF_MOVE, int(dx), int(dy), 0, 0)
def repeat_sound(x, sound):
while x > 0:
playsound(sound)
time.sleep(.1)
x -= 1
def load_guns_json():
with open('guns.json') as f:
return json.load(f)
def get_loadout(loadout):
if loadout:
return True
start_time = time.time()
while is_loadout_pressed():
if time.time() - start_time > 1:
repeat_sound(3, 'hitmarker.wav')
return True
return False
def load_gun(armed, guns):
if win32api.GetKeyState(0x31) < 0:
repeat_sound(2, 'hitmarker.wav')
return guns['ONE']
elif win32api.GetKeyState(0x32) < 0:
repeat_sound(2, 'hitmarker.wav')
return guns['TWO']
elif win32api.GetKeyState(0x33) < 0:
repeat_sound(2, 'hitmarker.wav')
return guns['THREE']
elif win32api.GetKeyState(0x34) < 0:
repeat_sound(2, 'hitmarker.wav')
return guns['FOUR']
elif win32api.GetKeyState(0x35) < 0:
repeat_sound(2, 'hitmarker.wav')
return guns['FIVE']
elif win32api.GetKeyState(0x36) < 0:
repeat_sound(2, 'hitmarker.wav')
return guns['SIX']
elif win32api.GetKeyState(0x37) < 0:
repeat_sound(2, 'hitmarker.wav')
return guns['SEVEN']
elif win32api.GetKeyState(0x38) < 0:
repeat_sound(2, 'hitmarker.wav')
return guns['EIGHT']
elif win32api.GetKeyState(0x39) < 0:
repeat_sound(2, 'hitmarker.wav')
return guns['NINE']
elif win32api.GetKeyState(0x30) < 0:
repeat_sound(2, 'hitmarker.wav')
return guns['TEN']
else:
time.sleep(.05)
return armed
def is_enabled(enabled)->bool:
if win32api.GetKeyState(enable) < 0:
time.sleep(.05)
enabled = not enabled
if enabled: playsound('hitmarker.wav')
return enabled
def main():
enabled = False
armed = []
index = 0
guns = load_guns_json()
loadout = False
while True:
start = time.time()
enabled = is_enabled(enabled)
loadout = get_loadout(loadout)
if loadout:
armed = []
armed = load_gun(armed, guns)
if armed: loadout = False
continue
if enabled and armed:
if is_mb_pressed() and index < len(armed["RECOIL"]):
mouse_move_relative(armed['RECOIL'][index][0], armed["RECOIL"][index][1])
index += 1
time.sleep((60/armed["RPM"]) - (time.time() - start))
continue
if is_reload_pressed():
index = 0
if is_swap_pressed():
enabled = not enabled
index = 0
if is_end_pressed():
repeat_sound(4, 'hitmarker.wav')
break
if __name__ == "__main__":
main()