• 1000 > MoveMouse Относительно точного положения до нажатия
Итак, есть ли способ попробовать шаг 2? Это сценарий:
local Recoil_Pattern = {
{x = 0 ,y = 10 } ,--1st Shot
{x = 0 ,y = 10 } ,--2nd Shot (hold LMB 100ms)
{x = 0 ,y = 10 } ,--3rd Shot (hold LMB 200ms)
{x = 0 ,y = 10 } ,--4rd Shot (hold LMB 300ms)
{x = 0 ,y = 10 } ,--5rd Shot (hold LMB 400ms)
}
local Shot_Sleep = 100
EnablePrimaryMouseButtonEvents(true);
function OnEvent(event, arg)
if event == "MOUSE_BUTTON_PRESSED" and arg == 1 then
if (IsMouseButtonPressed(1)) then
for i = 1, #Recoil_Pattern do
Sleep(10)
if IsMouseButtonPressed(1) then
Sleep(Shot_Sleep)
MoveMouseRelative( Recoil_Pattern[i].x, Recoil_Pattern[i].y )
end
end
end
elseif event == "MOUSE_BUTTON_RELEASED" and arg == 1 then
if not (IsMouseButtonPressed(1)) then
Sleep(10)
-- How to reverse the MoveMouseRelative to exact first position when releasing LMB
-- Ex.
-- If press and release LMB -> move mouse relative (0,-10)
-- If press and hold LMB for 100ms then release LMB -> move mouse relative (0,-20)
-- If press and hold LMB for 400ms then release LMB -> move mouse relative (0,-50)
end
end
end
Edit2: Отлично, он отлично работает с полностью автоматическим режимом съемки, но с полуавтоматическим (я использую кнопку «пауза» в качестве кнопки съемки), после if i = = 3, то он не срабатывает (больше не выполняет PressAndReleaseKey ("пауза")). Пожалуйста, помогите мне сделать его идеальным, я обновил полуавтоматический режим стрельбы в Edit 2
local Recoil_Pattern = {
{x = 0 ,y = 10 } ,--1st Shot
{x = 0 ,y = 10 } ,--2nd Shot (hold LMB 100ms)
{x = 0 ,y = 10 } ,--3rd Shot (hold LMB 200ms)
{x = 0 ,y = 10 } ,--4th Shot (hold LMB 300ms)
{x = 0 ,y = 10 } ,--5th Shot (hold LMB 400ms)
}
local Shot_Sleep = 100
local recoil_sum_x, recoil_sum_y = 0, 0
EnablePrimaryMouseButtonEvents(true);
function OnEvent(event, arg)
if event == "MOUSE_BUTTON_PRESSED" and arg == 1 then
for i = 1, #Recoil_Pattern do
Sleep(10)
if IsMouseButtonPressed(1) then
PressAndReleaseKey("pause")
Sleep(Shot_Sleep)
local dx, dy = Recoil_Pattern[i].x, Recoil_Pattern[i].y
recoil_sum_x, recoil_sum_y = recoil_sum_x - dx, recoil_sum_y - dy
MoveMouseRelative( dx, dy )
Sleep(Shot_Sleep)
if i == 3 then
ctrl_is_down = true
PressKey("lctrl")
end
else
break
end
end
elseif event == "MOUSE_BUTTON_RELEASED" and arg == 1 then
if ctrl_is_down then
ctrl_is_down = false
ReleaseKey("lctrl")
end
while recoil_sum_x ~= 0 or recoil_sum_y ~= 0 do
local dx, dy = recoil_sum_x, recoil_sum_y
dx = dx > 127 and 127 or dx < -127 and -127 or dx
dy = dy > 127 and 127 or dy < -127 and -127 or dy
MoveMouseRelative( dx, dy )
recoil_sum_x, recoil_sum_y = recoil_sum_x - dx, recoil_sum_y - dy
Sleep(10)
end
end
end