├── icon.ico
├── config.json
├── config.py
├── README.md
├── LICENSE
└── main.py
/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xulusjb/PUBG/HEAD/icon.ico
--------------------------------------------------------------------------------
/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "model1":43,
3 | "model2":43,
4 | "model3":43,
5 | "model4":43,
6 | "model5":43,
7 | "waittime": 220
8 | }
9 |
--------------------------------------------------------------------------------
/config.py:
--------------------------------------------------------------------------------
1 | server1 = 4
2 | server2 = 4
3 | server3 = 4
4 | server4 = 4
5 | server5 = 4
6 |
7 | mode1 = 3
8 | mode2 = 3
9 | mode3 = 3
10 | mode4 = 3
11 | mode5 = 3
12 |
13 | waittime = 240
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Introduction
2 | This repo is outdated and will not be updated.
3 | An autoclick script that used to make advantage of the old BP giving strategy. You may find this project helpful if you are developing autoclick scripts.
4 | Planning: move the player to sheds and pick up items.
5 | ```
6 | Changelog
7 | 0410: you can use it directly without config file. Will do default server, one-man squad bp earning.
8 | 0409: added random drop time, random walking and jumping after landing, and quick parachuting.
9 | ```
10 |
11 | # Disclaimer
12 |
13 |
This sample code aims for programming education purpose only. Please delete the depository within 24hrs of downloading. The authors of the code oppose AFK farming, cheating and other kind of aimbot usage of ANYKIND. The game developing company, Bluehole Inc, reserves all rights to persue improper in-game activities.
14 |
15 |
16 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | This is free and unencumbered software released into the public domain.
2 |
3 | Anyone is free to copy, modify, publish, use, compile, sell, or
4 | distribute this software, either in source code form or as a compiled
5 | binary, for any purpose, commercial or non-commercial, and by any
6 | means.
7 |
8 | In jurisdictions that recognize copyright laws, the author or authors
9 | of this software dedicate any and all copyright interest in the
10 | software to the public domain. We make this dedication for the benefit
11 | of the public at large and to the detriment of our heirs and
12 | successors. We intend this dedication to be an overt act of
13 | relinquishment in perpetuity of all present and future rights to this
14 | software under copyright law.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
23 |
24 | For more information, please refer to
25 |
--------------------------------------------------------------------------------
/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | """pubgbot.py: Nasty PUBG farm bot."""
4 |
5 | __author__ = "fdukeshik, h.takatoshi"
6 | __copyright__ = "Copyright 2017, team601"
7 |
8 | from ctypes import *
9 | from pymouse import PyMouse
10 | from pykeyboard import PyKeyboard
11 | import time
12 | import json
13 | import webbrowser
14 | import psutil
15 | import win32gui
16 | import win32con
17 | import win32process
18 | import random
19 | import logging
20 |
21 | import config
22 |
23 | m = PyMouse()
24 | k = PyKeyboard()
25 | gdi32 = windll.gdi32
26 | user32 = windll.user32
27 | hdc = user32.GetDC(None)
28 |
29 | # misc helper functions
30 | def setTitle(titleStr):
31 | windll.kernel32.SetConsoleTitleW(titleStr)
32 |
33 | def l(logStr):
34 | logging.info(logStr)
35 |
36 | def initLogger():
37 | logging.basicConfig(
38 | format='[%(asctime)s] %(message)s',
39 | level=logging.DEBUG,
40 | datefmt='%Y-%m-%d %H:%M:%S')
41 |
42 | # Process related helper functions
43 | def activeWindowName():
44 | hwnd = win32gui.GetForegroundWindow()
45 | tid, current_pid = win32process.GetWindowThreadProcessId(hwnd)
46 | return psutil.Process(current_pid).name()
47 |
48 | def enum_window_callback(hwnd, pid):
49 | tid, current_pid = win32process.GetWindowThreadProcessId(hwnd)
50 | if pid == current_pid and win32gui.IsWindowVisible(hwnd):
51 | win32gui.SetForegroundWindow(hwnd)
52 | l("window activated")
53 |
54 | def opengame():
55 | webbrowser.open('steam://rungameid/578080')
56 |
57 | def activegamewindow():
58 |
59 | gamepid = findgame()
60 | if gamepid is not None:
61 | win32gui.EnumWindows(enum_window_callback, gamepid)
62 |
63 |
64 |
65 | def killgame():
66 | gamepid = findgame()
67 | if gamepid is not None:
68 | try:
69 | psutil.Process(gamepid).terminate()
70 | except psutil.NoSuchProcess:
71 | pass
72 |
73 | def findgame():
74 | for _ in psutil.pids():
75 | try:
76 | name = psutil.Process(_).name()
77 | except psutil.NoSuchProcess:
78 | continue
79 | if name == "TslGame.exe":
80 | return _
81 | return None
82 |
83 | def windowEnumerationHandler(hwnd, top_windows):
84 | top_windows.append((hwnd, win32gui.GetWindowText(hwnd)))
85 |
86 | # BATTLEGROUNDS Crash Reporter
87 | def crashwindow():
88 | top_windows = []
89 | win32gui.EnumWindows(windowEnumerationHandler, top_windows)
90 | for i in top_windows:
91 | if "BATTLEGROUNDS Crash Reporter" in i[1]:
92 | win32gui.PostMessage(i[0],win32con.WM_CLOSE,0,0)
93 | l("crash window closed")
94 | return True
95 | return False
96 |
97 | # pyinput helper functions
98 | def getc(hori,vert):
99 | return hex(gdi32.GetPixel(hdc,hori,vert))
100 |
101 | def mmove(hori,vert,delay):
102 | m.move(hori,vert)
103 | time.sleep(delay)
104 |
105 | def mclick(hori,vert,delay=2): # move, pause and click
106 | mmove(hori,vert,0.5)
107 | m.click(hori,vert,1)
108 | time.sleep(delay)
109 |
110 | def mpress(str,times):
111 | k.press_key(str)
112 | time.sleep(times)
113 | k.release_key(str)
114 |
115 | def color(clr, x, y):
116 | return clr == getc(x,y)
117 |
118 | def move_mouse(x,y):
119 | windll.user32.mouse_event(
120 | c_uint(0x0001),
121 | c_uint(x),
122 | c_uint(y),
123 | c_uint(0),
124 | c_uint(0)
125 | )
126 | # getc(100,300) Get color of certain pixel
127 | # k.type_string('H') Press certain key on keyboard
128 | # k.press_key('H') Keep pressing a key
129 | # k.release_key('H') Release a key
130 | # m.move(200, 200) Move mouse to certain pixel
131 | # m.position() Get pixel of mouse
132 | # int(time.time()) Get current timestamp
133 | # move_mouse(x,y) move mouse in game
134 |
135 | initLogger()
136 |
137 | confs = ""
138 | conf = {}
139 | stayseconds = 240
140 | easymode = 1
141 | useJson = True
142 | try:
143 | with open('config.json', 'r') as f:
144 | confs = f.read()
145 | conf = json.loads(confs)
146 | except:
147 | useJson = False
148 |
149 | if useJson:
150 |
151 | try:
152 |
153 | config.server1 = conf['model1']//10
154 | config.server2 = conf['model2']//10
155 | config.server3 = conf['model3']//10
156 | config.server4 = conf['model4']//10
157 | config.server5 = conf['model5']//10
158 |
159 | config.mode1 = conf['model1']%10
160 | config.mode2 = conf['model2']%10
161 | config.mode3 = conf['model3']%10
162 | config.mode4 = conf['model4']%10
163 | config.mode5 = conf['model5']%10
164 |
165 | stayseconds = conf['waittime']
166 |
167 | l("using user defined config")
168 | print(conf)
169 |
170 | except:
171 | l("error parsing config file")
172 | useJson = False
173 |
174 | if not useJson:
175 | l("now in easymode")
176 |
177 | setTitle("pubgfarmbot.tk - ©xulusjb,hirototakatoshi")
178 |
179 |
180 | l("Farmbot successfully started! Open your game")
181 | server = 4
182 | mode = 3
183 | s = int(time.time())
184 | t = s
185 | ingame = 0
186 |
187 | theround = 0
188 | lobbytime = 0
189 |
190 |
191 | time.sleep(5)
192 | lastgame = time.time()
193 | windowActive = True
194 |
195 | # main event loop
196 | while True:
197 |
198 | # when game is not there, start it
199 |
200 | if crashwindow():
201 | l("game crashed")
202 | opengame()
203 | lastgame = time.time()
204 | time.sleep(25)
205 | #activegamewindow()
206 |
207 | if findgame() is None:
208 | opengame()
209 | l("launch game")
210 | lastgame = time.time()
211 | time.sleep(25)
212 | #activegamewindow()
213 |
214 | # else, do nothing when game is there but not activated
215 |
216 | wName = activeWindowName()
217 | gName = "TslGame.exe"
218 | if not gName in wName:
219 | lastgame = time.time()
220 | if windowActive:
221 | setTitle("pubgfarmbot.tk - idle")
222 | windowActive = False
223 | time.sleep(5)
224 | continue
225 | else:
226 | if not windowActive:
227 | windowActive = True
228 | setTitle("pubgfarmbot.tk - ©xulusjb,hirototakatoshi")
229 |
230 | # ok1
231 | if(color("0xffffff",954,623) and color("0xffffff",979,615) and color("0xffffff",980,635)):
232 | l("on ok 1")
233 | mclick(954,623)
234 | time.sleep(5)
235 |
236 |
237 | #in the lobby
238 | if ( not color("0xcdff",285,974) and color("0xffffff", 1839,1022 ) and color("0xffffff",1843,1036) and color("0xffffff",1834,1036) ):
239 | l("in the lobby")
240 | nowtime = int(time.time())
241 | if ((nowtime - lobbytime) > 50):
242 | lobbytime = nowtime
243 | else: # repeatly matching failed
244 | mclick(1837,1029)
245 | time.sleep(2)
246 | mclick(947,605)
247 | time.sleep(5)
248 | l("restart lobby")
249 |
250 | time.sleep(2)
251 | # server and mode selection when using json
252 | if useJson:
253 | if ((theround % 5) == 0):
254 | server = config.server1
255 | mode = config.mode1
256 | elif ((theround % 5) == 1):
257 | server = config.server2
258 | mode = config.mode2
259 | elif ((theround % 5) == 2):
260 | server = config.server3
261 | mode = config.mode3
262 | elif ((theround % 5) == 3):
263 | server = config.server4
264 | mode = config.mode4
265 | elif ((theround % 5) == 4):
266 | server = config.server5
267 | mode = config.mode5
268 |
269 | mclick(1759,1035) # click bottom
270 | if (server == 1): #NA server
271 | mclick(815,448)
272 | elif (server == 2):#EU server
273 | mclick(847,496)
274 | elif (server == 3):#KR/JP server -- unavailable
275 | mclick(847,505)
276 | elif (server == 4):#asia server
277 | mclick(853,536)
278 | elif (server == 5):#OC server
279 | mclick(844,584)
280 | elif (server == 6):#SA server
281 | mclick(847,622)
282 | elif( server == 7):#SEA server
283 | mclick(842,671)
284 |
285 | mclick(935,736) #esc
286 |
287 |
288 | if (mode == 3):#squad
289 | mclick(155,790)
290 | elif (mode == 2): #duo
291 | mclick(152,718)
292 | elif (mode == 1): #solo
293 | mclick(182,680)
294 | mclick(158,1009)
295 | time.sleep(15)
296 |
297 | #on the plane
298 | if ( ingame == 0 ) and ( color("0xf2f2f2",1071,624) and color("0xf2f3f2",961,21) and color("0xf2f3f2",963,23)):
299 | l("on the plane")
300 | ingame = 1
301 | s = int(time.time())
302 | lastgame = time.time()
303 | if(stayseconds > 15):
304 | mmove(960,1080,0.1)
305 | time.sleep(8 + random.random() * 3) # adjusted this value to keep distance from the map centre
306 | k.press_key('F')
307 | time.sleep(0.2)
308 | k.release_key('F')
309 | time.sleep(1) # double press F key to make sure player jumps
310 | k.press_key('F')
311 | time.sleep(0.2)
312 | k.release_key('F')
313 | timestamp = time.time()
314 | while time.time() - timestamp < 3:
315 | time.sleep(0.01)
316 | move_mouse(0,30)
317 | k.press_key('W')
318 | time.sleep(40)
319 | k.release_key('W')
320 | time.sleep(5)
321 | k.press_key('=')
322 | time.sleep(0.1)
323 | k.release_key('=')
324 | nowstate = 0
325 | nextstate = 0
326 | theround = theround +1
327 |
328 |
329 |
330 | t = int(time.time())
331 | if (ingame == 1):
332 | #on time exit
333 | if ((t-s)>stayseconds):
334 | l("on time exit")
335 | mpress(k.escape_key,0.5)
336 | mclick(840,602)
337 | mclick(848,583)
338 | ingame = 0
339 | time.sleep(10)
340 | else:
341 | if random.random() < 0.2:
342 | mpress(' ', 0.05)
343 | timestamp = time.time()
344 | direction = random.choice([30,-30])
345 | while time.time() - timestamp < 0.4:
346 | move_mouse(direction,0)
347 | time.sleep(0.01)
348 | time.sleep(1)
349 |
350 |
351 |
352 | #cancel continue
353 | if( color("0xffffff", 816,482) and color("0xffffff",931,501) and color("0xffffff",932,553)):
354 | l("cancel continue")
355 | mclick(1024,619)
356 | time.sleep(5)
357 |
358 | # reconnect1
359 | if( color("0xffffff",902,596) and color("0xffffff",911,602) and color("0xffffff",917,606)):
360 | l("on death exit")
361 | mclick(957,608)
362 | time.sleep(5)
363 |
364 | # on death exit
365 | if( color("0xffffff",1703,960) and color("0xffffff",1648,954) and color("0xffffff",1671,954)):
366 | l("on death exit")
367 | mclick(1629,942)
368 | mclick(834,577)
369 | ingame = 0
370 | time.sleep(10)
371 |
372 |
373 | #reconnect2
374 | if( color("0xffffff",902,633) and color("0xffffff",910,642) and color("0xffffff",937,627)):
375 | l("on reconnect 2")
376 | mclick(910,642)
377 | time.sleep(5)
378 |
379 | if time.time() - lastgame > 300 + stayseconds:
380 | killgame()
381 | l("game killed")
382 | time.sleep(20)
383 |
--------------------------------------------------------------------------------