Code:
local recoil = false
sleep_duration = 50
MaxBreak = 1000
TimeStamp = -MaxBreak-1 -- it's negative 2 seconds
recoil_coords = {
{ x = 0, y = 5 },
{ x = 0, y = 5 },
{ x = 0, y = 5 },
{ x = 0, y = 5 },
{ x = 0, y = 5 },
{ x = 0, y = 5 },
{ x = 0, y = 5 },
{ x = 0, y = 5 },
{ x = 0, y = 5 },
{ x = 0, y = 5 },
{ x = 0, y = 5 },
{ x = 0, y = 5 },
{ x = 0, y = 5 },
{ x = 0, y = 5 },
{ x = 0, y = 5 },
{ x = 0, y = 5 },
{ x = 0, y = 5 },
{ x = 0, y = 5 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
{ x = -1, y = 7 },
}
recoil_count = # recoil_coords
LastIndex = 1
function OnEvent(event, arg)
if event == "PROFILE_ACTIVATED" then
EnablePrimaryMouseButtonEvents(true)
end
if (event == "MOUSE_BUTTON_PRESSED" and arg == 11) then -- Press mouse button 3 to toggle recoil
recoil = not recoil
if (recoil == false) then
OutputLogMessage("RecoilScript turned OFF\n")
else
OutputLogMessage("RecoilScript turned ON\n")
end
end
if (event == "MOUSE_BUTTON_PRESSED" and arg == 1) and recoil then
--OutputLogMessage("schiesen")
if (GetRunningTime() - TimeStamp < MaxBreak) and (LastIndex <= recoil_count) then
i = LastIndex
else
i = 1
end
while i <= recoil_count do
Sleep(sleep_duration)
if not IsMouseButtonPressed(1) then
LastIndex = i
TimeStamp = GetRunningTime()
break
end
MoveMouseRelative( recoil_coords[i].x, recoil_coords[i].y )
if not IsMouseButtonPressed(1) then break end
PressAndReleaseKey("q")
i = i + 1
end
end
if event == "MOUSE_BUTTON_PRESSED" and arg == 2 and recoil then
PlayMacro("DPI Down")
PressKey("lshift")
PressAndReleaseKey("q")
elseif event == "MOUSE_BUTTON_RELEASED" and arg == 2 then
PlayMacro("DPI Up")
ReleaseKey("lshift")
PressAndReleaseKey("q")
end
end