Python,适用于 mad max 的 FreePIE 模拟器 mod
Python, FreePIE emulator mod for mad max
我有一个来自 mod 开发者的 python 小脚本,它使 mad max 可以在 PC 上行走。他使用 freePie 来模拟操纵杆,这样你就可以用 shift 和 Ctrl 切换,这是 Max 行走的速度。问题是脚本操纵杆感觉非常粘而且很慢,因为它试图用鼠标和键盘模拟操纵杆,而且似乎没有办法克服它。这是脚本
# Walk Toggle script for Mad Max (PC)
# by STELLAR-7 Project
# Starting variables
if starting:
vJoy[0].x = 0
vJoy[0].y = 0
vJoy[0].z = 0
vJoy[0].rx = 0
vJoy[0].ry = 0
vJoy[0].rz = 0
up = 0
left = 0
down = 0
right = 0
isMoving = 0
moveMode = 0
axisMax = vJoy[0].axisMax
axis = axisMax * 0.85
mouseSmooth = 0
mouseSens = 5000
# Movement toggle RUN-JOG-WALK key (LeftControl)
if keyboard.getPressed(Key.NumberPad0):
if keyboard.getPressed(Key.LeftControl):
if moveMode > 0:
moveMode -= 1
if moveMode == 0:
axis = axisMax * 0.75
else:
axis = axisMax * 0.81
# Movement toggle WALK-JOG-RUN key (LeftShift)
elif keyboard.getPressed(Key.LeftShift):
if moveMode < 2:
moveMode += 1
if moveMode == 1:
axis = axisMax * 0.81
else:
axis = axisMax
# Get keyboard movement (WASD)
if keyboard.getKeyDown(Key.W):
isMoving = 1
up = 1
else:
up = 0
if keyboard.getKeyDown(Key.A):
isMoving = 1
left = 1
else:
left = 0
if keyboard.getKeyDown(Key.S):
isMoving = 1
down = 1
else:
down = 0
if keyboard.getKeyDown(Key.D):
isMoving = 1
right = 1
else:
right = 0
# Process movement
# Diagonals first...
if up == 1 and right == 1:
vJoy[0].x = axis * 0.7
vJoy[0].y = -axis * 0.7
elif up == 1 and left == 1:
vJoy[0].x = -axis * 0.7
vJoy[0].y = -axis * 0.7
elif down == 1 and left == 1:
vJoy[0].x = -axis * 0.7
vJoy[0].y = axis * 0.7
elif down == 1 and right == 1:
vJoy[0].x = axis * 0.7
vJoy[0].y = axis * 0.7
elif up == 1:
vJoy[0].x = 0
vJoy[0].y = -axis
elif left == 1:
vJoy[0].x = -axis
vJoy[0].y = 0
elif down == 1:
vJoy[0].x = 0
vJoy[0].y = axis
elif right == 1:
vJoy[0].x = axis
vJoy[0].y = 0
else:
isMoving = 0
vJoy[0].x = 0
vJoy[0].y = 0
# Mouse look
if isMoving == 1:
vJoy[0].z = -mouse.deltaX * mouseSmooth
vJoy[0].ry = mouse.deltaY * mouseSmooth
if mouseSmooth < mouseSens:
mouseSmooth += 10
else:
mouseSmooth = 0
vJoy[0].z = 0
vJoy[0].ry = 0
有什么方法可以让脚本在按钮切换或按键时完全停止。有点像打开和关闭它。例如,如果我按下数字小键盘 0,脚本必须停止工作,因为车辆中的控件无法使用。这需要在游戏中发生。这个脚本可以精炼一下吗?或者甚至可以在鼠标处于活动状态时停止工作。
您添加一个变量,当设置为 1 时停止游戏,例如:
# Starting variables
if starting:
stopGame = 0
:
:
if keyboard.getPressed(Key.NumberPad0):
stopGame = 1 - stopGame
# authorize all actions you want when stopGame ==0
# and of course you could do some operation when stopGame ==1
if stopGame == 0:
# Get keyboard movement (WASD)
if keyboard.getKeyDown(Key.W):
isMoving = 1
up = 1
else:
up = 0
:
:
# Walk Toggle script for Mad Max (PC)
# by STELLAR-7 Project
# Starting variables
if starting:
stopGame = 0
vJoy[0].x = 0
vJoy[0].y = 0
vJoy[0].z = 0
vJoy[0].rx = 0
vJoy[0].ry = 0
vJoy[0].rz = 0
up = 0
left = 0
down = 0
right = 0
isMoving = 0
moveMode = 0
axisMax = vJoy[0].axisMax
axis = axisMax * 0.85
mouseSmooth = 0
mouseSens = 5000
# Movement toggle RUN-JOG-WALK key (LeftControl)
if keyboard.getPressed(Key.NumberPad0):
stopGame = 1 - stopGame
if keyboard.getPressed(Key.LeftControl):
if moveMode > 0:
moveMode -= 1
if moveMode == 0:
axis = axisMax * 0.75
else:
axis = axisMax * 0.81
# Movement toggle WALK-JOG-RUN key (LeftShift)
elif keyboard.getPressed(Key.LeftShift):
if moveMode < 2:
moveMode += 1
if moveMode == 1:
axis = axisMax * 0.81
else:
axis = axisMax
if stopGame == 0:
# Get keyboard movement (WASD)
if keyboard.getKeyDown(Key.W):
isMoving = 1
up = 1
else:
up = 0
if keyboard.getKeyDown(Key.A):
isMoving = 1
left = 1
else:
left = 0
if keyboard.getKeyDown(Key.S):
isMoving = 1
down = 1
else:
down = 0
if keyboard.getKeyDown(Key.D):
isMoving = 1
right = 1
else:
right = 0
# Process movement
# Diagonals first...
if up == 1 and right == 1:
vJoy[0].x = axis * 0.7
vJoy[0].y = -axis * 0.7
elif up == 1 and left == 1:
vJoy[0].x = -axis * 0.7
vJoy[0].y = -axis * 0.7
elif down == 1 and left == 1:
vJoy[0].x = -axis * 0.7
vJoy[0].y = axis * 0.7
elif down == 1 and right == 1:
vJoy[0].x = axis * 0.7
vJoy[0].y = axis * 0.7
elif up == 1:
vJoy[0].x = 0
vJoy[0].y = -axis
elif left == 1:
vJoy[0].x = -axis
vJoy[0].y = 0
elif down == 1:
vJoy[0].x = 0
vJoy[0].y = axis
elif right == 1:
vJoy[0].x = axis
vJoy[0].y = 0
else:
isMoving = 0
vJoy[0].x = 0
vJoy[0].y = 0
# Mouse look
if isMoving == 1:
vJoy[0].z = -mouse.deltaX * mouseSmooth
vJoy[0].ry = mouse.deltaY * mouseSmooth
if mouseSmooth < mouseSens:
mouseSmooth += 10
else:
mouseSmooth = 0
vJoy[0].z = 0
vJoy[0].ry = 0
我有一个来自 mod 开发者的 python 小脚本,它使 mad max 可以在 PC 上行走。他使用 freePie 来模拟操纵杆,这样你就可以用 shift 和 Ctrl 切换,这是 Max 行走的速度。问题是脚本操纵杆感觉非常粘而且很慢,因为它试图用鼠标和键盘模拟操纵杆,而且似乎没有办法克服它。这是脚本
# Walk Toggle script for Mad Max (PC)
# by STELLAR-7 Project
# Starting variables
if starting:
vJoy[0].x = 0
vJoy[0].y = 0
vJoy[0].z = 0
vJoy[0].rx = 0
vJoy[0].ry = 0
vJoy[0].rz = 0
up = 0
left = 0
down = 0
right = 0
isMoving = 0
moveMode = 0
axisMax = vJoy[0].axisMax
axis = axisMax * 0.85
mouseSmooth = 0
mouseSens = 5000
# Movement toggle RUN-JOG-WALK key (LeftControl)
if keyboard.getPressed(Key.NumberPad0):
if keyboard.getPressed(Key.LeftControl):
if moveMode > 0:
moveMode -= 1
if moveMode == 0:
axis = axisMax * 0.75
else:
axis = axisMax * 0.81
# Movement toggle WALK-JOG-RUN key (LeftShift)
elif keyboard.getPressed(Key.LeftShift):
if moveMode < 2:
moveMode += 1
if moveMode == 1:
axis = axisMax * 0.81
else:
axis = axisMax
# Get keyboard movement (WASD)
if keyboard.getKeyDown(Key.W):
isMoving = 1
up = 1
else:
up = 0
if keyboard.getKeyDown(Key.A):
isMoving = 1
left = 1
else:
left = 0
if keyboard.getKeyDown(Key.S):
isMoving = 1
down = 1
else:
down = 0
if keyboard.getKeyDown(Key.D):
isMoving = 1
right = 1
else:
right = 0
# Process movement
# Diagonals first...
if up == 1 and right == 1:
vJoy[0].x = axis * 0.7
vJoy[0].y = -axis * 0.7
elif up == 1 and left == 1:
vJoy[0].x = -axis * 0.7
vJoy[0].y = -axis * 0.7
elif down == 1 and left == 1:
vJoy[0].x = -axis * 0.7
vJoy[0].y = axis * 0.7
elif down == 1 and right == 1:
vJoy[0].x = axis * 0.7
vJoy[0].y = axis * 0.7
elif up == 1:
vJoy[0].x = 0
vJoy[0].y = -axis
elif left == 1:
vJoy[0].x = -axis
vJoy[0].y = 0
elif down == 1:
vJoy[0].x = 0
vJoy[0].y = axis
elif right == 1:
vJoy[0].x = axis
vJoy[0].y = 0
else:
isMoving = 0
vJoy[0].x = 0
vJoy[0].y = 0
# Mouse look
if isMoving == 1:
vJoy[0].z = -mouse.deltaX * mouseSmooth
vJoy[0].ry = mouse.deltaY * mouseSmooth
if mouseSmooth < mouseSens:
mouseSmooth += 10
else:
mouseSmooth = 0
vJoy[0].z = 0
vJoy[0].ry = 0
有什么方法可以让脚本在按钮切换或按键时完全停止。有点像打开和关闭它。例如,如果我按下数字小键盘 0,脚本必须停止工作,因为车辆中的控件无法使用。这需要在游戏中发生。这个脚本可以精炼一下吗?或者甚至可以在鼠标处于活动状态时停止工作。
您添加一个变量,当设置为 1 时停止游戏,例如:
# Starting variables
if starting:
stopGame = 0
:
:
if keyboard.getPressed(Key.NumberPad0):
stopGame = 1 - stopGame
# authorize all actions you want when stopGame ==0
# and of course you could do some operation when stopGame ==1
if stopGame == 0:
# Get keyboard movement (WASD)
if keyboard.getKeyDown(Key.W):
isMoving = 1
up = 1
else:
up = 0
:
:
# Walk Toggle script for Mad Max (PC)
# by STELLAR-7 Project
# Starting variables
if starting:
stopGame = 0
vJoy[0].x = 0
vJoy[0].y = 0
vJoy[0].z = 0
vJoy[0].rx = 0
vJoy[0].ry = 0
vJoy[0].rz = 0
up = 0
left = 0
down = 0
right = 0
isMoving = 0
moveMode = 0
axisMax = vJoy[0].axisMax
axis = axisMax * 0.85
mouseSmooth = 0
mouseSens = 5000
# Movement toggle RUN-JOG-WALK key (LeftControl)
if keyboard.getPressed(Key.NumberPad0):
stopGame = 1 - stopGame
if keyboard.getPressed(Key.LeftControl):
if moveMode > 0:
moveMode -= 1
if moveMode == 0:
axis = axisMax * 0.75
else:
axis = axisMax * 0.81
# Movement toggle WALK-JOG-RUN key (LeftShift)
elif keyboard.getPressed(Key.LeftShift):
if moveMode < 2:
moveMode += 1
if moveMode == 1:
axis = axisMax * 0.81
else:
axis = axisMax
if stopGame == 0:
# Get keyboard movement (WASD)
if keyboard.getKeyDown(Key.W):
isMoving = 1
up = 1
else:
up = 0
if keyboard.getKeyDown(Key.A):
isMoving = 1
left = 1
else:
left = 0
if keyboard.getKeyDown(Key.S):
isMoving = 1
down = 1
else:
down = 0
if keyboard.getKeyDown(Key.D):
isMoving = 1
right = 1
else:
right = 0
# Process movement
# Diagonals first...
if up == 1 and right == 1:
vJoy[0].x = axis * 0.7
vJoy[0].y = -axis * 0.7
elif up == 1 and left == 1:
vJoy[0].x = -axis * 0.7
vJoy[0].y = -axis * 0.7
elif down == 1 and left == 1:
vJoy[0].x = -axis * 0.7
vJoy[0].y = axis * 0.7
elif down == 1 and right == 1:
vJoy[0].x = axis * 0.7
vJoy[0].y = axis * 0.7
elif up == 1:
vJoy[0].x = 0
vJoy[0].y = -axis
elif left == 1:
vJoy[0].x = -axis
vJoy[0].y = 0
elif down == 1:
vJoy[0].x = 0
vJoy[0].y = axis
elif right == 1:
vJoy[0].x = axis
vJoy[0].y = 0
else:
isMoving = 0
vJoy[0].x = 0
vJoy[0].y = 0
# Mouse look
if isMoving == 1:
vJoy[0].z = -mouse.deltaX * mouseSmooth
vJoy[0].ry = mouse.deltaY * mouseSmooth
if mouseSmooth < mouseSens:
mouseSmooth += 10
else:
mouseSmooth = 0
vJoy[0].z = 0
vJoy[0].ry = 0