Good day to everyone.
I want to create a "No Recoil" scenario with the ability to specify my own aiming sensitivity value.
At the moment, the code that you can see below works exclusively with one setting, namely with the dpi800 and the in-game sensitivity on the X and Y axes equal to 7, is it possible to make it so that I can change literally two digits, for example, not 7, but 9 or 10 and so on, and the script changed using some formula values in line 7(r_p["Weapon1"]) and 8(r_p["Weapon2"])
local r_p = {Weapon1}
local r_o = r_p[o_s_a] or {Weapon2}
local o_s_a = "Weapon2"
local n_o_s_a = {Weapon2 = "Weapon1", Weapon1 = "Weapon2"}
r_p["Weapon1"] = {0, 0, 0, 0, 25, 100, -1, 17, 600, -1, 20, 500, -1, 21, 800}
r_p["Weapon2"] = {0, 0, 0, 0, 22, 150, -1, 17, 400, -1, 20, 700, -1, 20, 300, -1, 20, 150, -2, 21, 400, -2, 21, 550, -2, 21, 300, -2, 21, 250, -2, 21, 100}
function Log()
if not IsKeyLockOn("scrolllock") then
ClearLog()
OutputLogMessage("Current mode: List of weapons | Scroll lock is OFF\n\n")
OutputLogMessage("Selected: %s\n\n", o_s_a)
OutputLogMessage(" (%s) | Weapon1 (%s) | Weapon2\n\n", o_s_a == "Weapon1", o_s_a == "Weapon2")
end
end
function OnEvent(event, arg)
EnablePrimaryMouseButtonEvents(true)
if event == "MOUSE_BUTTON_PRESSED" and arg == 5 and IsModifierPressed("lctrl") and not IsKeyLockOn("scrolllock") then
o_s_a = n_o_s_a[o_s_a]
r_o = r_p[o_s_a] or {}
Log()
else if event == "MOUSE_BUTTON_PRESSED" and arg == 1 and IsMouseButtonPressed(3) and not IsKeyLockOn("capslock") then
for xy = 3, #r_o, 3 do
local c_t = GetRunningTime()
local h_r = r_o[xy-2]
local v_r = r_o[xy-1]
local r_d = r_o[xy]
repeat
local d_t = GetRunningTime() - c_t, r_d
MoveMouseRelative(h_r, v_r)
Sleep(10)
until d_t >= r_d or not IsMouseButtonPressed(1) or not IsMouseButtonPressed(3)
if not IsMouseButtonPressed(1) or not IsMouseButtonPressed(3) then break end
end
end
end
end
I tried using multiplayer, but in this version you can use only 2 values, where sensitivity 12 is standard, when you activate multiplayer, all your sensitivity settings are divided by 2 and as a result you get sensitivity 6, but this is a bit not the option that I need.
Thank you very much for any help if all.
You can modify the values on-the-fly instead of changing values in lines 7(r_p["Weapon1"]) and 8(r_p["Weapon2"]).
Replace the following lines
local h_r = r_o[xy-2]
local v_r = r_o[xy-1]
with
local h_r = round(r_o[xy-2] * sens / 6)
local v_r = round(r_o[xy-1] * sens / 6)
where sens
is a variable with default value 6
, but you can modify it.
round
is a function, define it before OnEvent
:
function round(x)
return math.floor(x + 0.5)
end
sens = 6
UPDATE:
The solution above has a drawback: due to rounding errors, the cursor gradually shifts to the left and/or to the top.
The solution below accumulates fractional parts to avoid such shift.
Define the function MoveMouseRelativeFractional
which accepts fractional arguments and use it instead of the standard MoveMouseRelative
.
The definition should be inserted at the very beginning of the whole script:
local remainder_fractional_x, remainder_fractional_y = 0, 0
local function MoveMouseRelativeFractional(x, y)
x = remainder_fractional_x + x
y = remainder_fractional_y + y
local x_int = math.floor(x + 0.5)
local y_int = math.floor(y + 0.5)
remainder_fractional_x = x - x_int
remainder_fractional_y = y - y_int
MoveMouseRelative(x_int, y_int)
end
Remove round
:
local h_r = r_o[xy-2] * sens / 13
local v_r = r_o[xy-1] * sens / 13
Replace MoveMouseRelative
with MoveMouseRelativeFractional
:
MoveMouseRelativeFractional(h_r, v_r)