2020-06-22 22:46:48 -04:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
|
|
|
local nodecore
|
|
|
|
= nodecore
|
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
|
|
|
local zoom_base = 60 * nodecore.rate_adjustment("zoom", "base")
|
|
|
|
local zoom_ratio = 1 - 1 / (4 * nodecore.rate_adjustment("zoom", "ratio"))
|
|
|
|
local zoom_time = 2 * nodecore.rate_adjustment("zoom", "time")
|
|
|
|
|
|
|
|
nodecore.register_playerstep({
|
|
|
|
label = "zoom focus",
|
|
|
|
action = function(_, data)
|
|
|
|
local ctl = data.control
|
2023-11-05 12:40:32 -05:00
|
|
|
local focusing = ctl.zoom and (not ctl.sneak) and (not ctl.aux1)
|
2022-10-25 07:48:01 -04:00
|
|
|
and (not ctl.jump) and (not ctl.up) and (not ctl.down)
|
|
|
|
and (not ctl.left) and (not ctl.right)
|
2020-06-22 22:46:48 -04:00
|
|
|
local zoom = zoom_base
|
|
|
|
if focusing and data.zoomfocus then
|
2023-11-05 12:40:32 -05:00
|
|
|
local zoomqty = nodecore.gametime - data.zoomfocus - 2
|
|
|
|
if zoomqty < 0 then zoomqty = 0 end
|
2020-06-22 22:46:48 -04:00
|
|
|
zoom = zoom_base - zoom_base * zoom_ratio * (1 - 1 /
|
2023-11-05 12:40:32 -05:00
|
|
|
(zoomqty / zoom_time + 1))
|
2020-06-22 22:46:48 -04:00
|
|
|
else
|
|
|
|
data.zoomfocus = nodecore.gametime
|
|
|
|
end
|
|
|
|
local oldzoom = data.properties.zoom_fov or 0
|
|
|
|
if oldzoom > (zoom * 1.02) or oldzoom < zoom then
|
|
|
|
data.properties.zoom_fov = zoom
|
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|