1
0
Fork 0

Made bow unfocus faster

This commit is contained in:
the-real-herowl 2023-12-10 00:20:43 +01:00 committed by the-real-herowl
parent 42ec62562d
commit 5bf6608483
2 changed files with 7 additions and 2 deletions

View File

@ -38,6 +38,7 @@ mcl_fovapi.register_modifier({
name = "bowcomplete", name = "bowcomplete",
fov_factor = 0.8, fov_factor = 0.8,
time = 1, time = 1,
reset_time = 0.3,
is_multiplier = true, is_multiplier = true,
}) })

View File

@ -45,6 +45,9 @@ function mcl_fovapi.register_modifier(def)
if type(def.time) ~= "number" then if type(def.time) ~= "number" then
error("Transition time must be a number") error("Transition time must be a number")
end end
if def.reset_time ~= nil and type(def.reset_time) ~= "number" then
error("Reset time, if provided, must be a number")
end
if def.on_start ~= nil and type(def.on_start) ~= "function" then if def.on_start ~= nil and type(def.on_start) ~= "function" then
error("Callback on_start must be a function") error("Callback on_start must be a function")
@ -57,6 +60,7 @@ function mcl_fovapi.register_modifier(def)
mdef.fov_factor = def.fov_factor mdef.fov_factor = def.fov_factor
mdef.time = def.time mdef.time = def.time
mdef.reset_time = def.reset_time or def.time
if def.is_multiplier == false then mdef.is_multiplier = false if def.is_multiplier == false then mdef.is_multiplier = false
else mdef.is_multiplier = true end else mdef.is_multiplier = true end
@ -168,7 +172,7 @@ function mcl_fovapi.remove_modifier(player, modifier_name)
local elem = next local elem = next
if elem(applied) == nil then if elem(applied) == nil then
player:set_fov(0, false, modifier.time) player:set_fov(0, false, modifier.reset_time)
return return
end end
local exc = false local exc = false
@ -198,7 +202,7 @@ function mcl_fovapi.remove_modifier(player, modifier_name)
fov_factor = fov_factor * x.fov_factor fov_factor = fov_factor * x.fov_factor
end end
end end
player:set_fov(fov_factor, not non_multiplier_added, modifier.time) player:set_fov(fov_factor, not non_multiplier_added, modifier.reset_time)
end end
if mcl_fovapi.registered_modifiers[modifier_name].on_end ~= nil then if mcl_fovapi.registered_modifiers[modifier_name].on_end ~= nil then