1 Star 0 Fork 50

恽昊/PUBG

forked from LookOutTheBush/PUBG 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
mouse.py 2.90 KB
一键复制 编辑 原始数据 按行查看 历史
LookOutTheBush 提交于 2023-05-16 17:36 . 姿势
import time
import pydirectinput
from contants import c_contants
from equipment import getCurrentWepone
pydirectinput.PAUSE = 0
def changeOpen():
c_mouse.openFlag = not c_mouse.openFlag
def moveMouse():
curWepone = getCurrentWepone()
if(curWepone.name == 'none'):
return
basic = curWepone.basic
speed = curWepone.speed
startTime = round(time.perf_counter(), 3) * 1000
if curWepone.model == 'auto':
for i in range(curWepone.maxBullets):
if not canFire():
break
holdK = 1.0
if c_contants.hold:
holdK = curWepone.hold
postureK = curWepone.posture_states[c_contants.posture]
moveSum = int(round(basic[i] * curWepone.k * holdK * postureK, 2))
while True:
if moveSum > 10:
pydirectinput.move(xOffset=0, yOffset=10, relative=True)
moveSum -= 10
elif moveSum > 0:
pydirectinput.move(xOffset=0, yOffset=moveSum, relative=True)
moveSum = 0
elapsed = (round(time.perf_counter(), 3) * 1000 - startTime)
if not canFire() or elapsed > (i+1)*speed + 10:
if moveSum > 0:
pydirectinput.move(xOffset=0, yOffset=moveSum, relative=True)
break
time.sleep(0.01)
else:
for i in range(curWepone.maxBullets):
if not canFire():
break
holdK = 1
if c_contants.hold:
holdK = curWepone.hold
moveSum = int(round(basic[i] * curWepone.k * holdK, 2))
i += 1
while True:
if(moveSum > 10):
pydirectinput.move(xOffset=0, yOffset=10, relative=True)
moveSum -= 10
elif(moveSum > 0):
pydirectinput.move(xOffset=0, yOffset=moveSum, relative=True)
moveSum = 0
elapsed = (round(time.perf_counter(), 3) * 1000 - startTime)
if not canFire() or elapsed > (i+1)*speed + 10:
break
time.sleep(0.01)
pydirectinput.click()
def handlePressed():
if not canFire():
return
c_contants.pool.submit(moveMouse)
# 鼠标点击事件
def onClick(x, y, button, pressed):
if 'left' == button.name:
c_mouse.leftPressed = pressed
handlePressed()
return not c_contants.exitFlag
#按下f1测试程序生效
def testMouse():
if c_mouse.openFlag:
for i in range(10):
pydirectinput.moveRel(xOffset=0, yOffset=10)
time.sleep(0.1)
# 是否可以开火
def canFire():
return c_mouse.leftPressed and c_mouse.openFlag and not c_contants.exitFlag and not c_contants.bagOpen
class c_mouse():
leftPressed = False
openFlag = True
def __init__(self):
pass
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/haoyun45/PUBG.git
git@gitee.com:haoyun45/PUBG.git
haoyun45
PUBG
PUBG
master

搜索帮助