master #8

Merged
NO11 merged 21 commits from VoxeLibre/VoxeLibre:master into master 2021-09-19 11:15:44 +02:00
1 changed files with 10 additions and 6 deletions
Showing only changes of commit 95c4d6472b - Show all commits

View File

@ -69,18 +69,19 @@ local function setSprinting(playerName, sprinting) --Sets the state of a player
local controls = player:get_player_control() local controls = player:get_player_control()
if players[playerName] then if players[playerName] then
players[playerName].sprinting = sprinting players[playerName].sprinting = sprinting
local fov_old = players[playerName].fov
local fov_new = fov_old
local fade_time = .15
if sprinting == true if sprinting == true
or controls.RMB or controls.RMB
and string.find(player:get_wielded_item():get_name(), "mcl_bows:bow") and string.find(player:get_wielded_item():get_name(), "mcl_bows:bow")
and player:get_wielded_item():get_name() ~= "mcl_bows:bow" then and player:get_wielded_item():get_name() ~= "mcl_bows:bow" then
if sprinting == true then if sprinting == true then
players[playerName].fov = math.min(players[playerName].fov + 0.05, 1.2) fov_new = math.min(players[playerName].fov + 0.05, 1.2)
players[playerName].fade_time = .15
else else
players[playerName].fov = .7 fov_new = .7
players[playerName].fade_time = .3 players[playerName].fade_time = .3
end end
player:set_fov(players[playerName].fov, true, players[playerName].fade_time)
if sprinting == true then if sprinting == true then
playerphysics.add_physics_factor(player, "speed", "mcl_sprint:sprint", mcl_sprint.SPEED) playerphysics.add_physics_factor(player, "speed", "mcl_sprint:sprint", mcl_sprint.SPEED)
end end
@ -88,12 +89,15 @@ local function setSprinting(playerName, sprinting) --Sets the state of a player
and player:get_wielded_item():get_name() ~= "mcl_bows:bow_0" and player:get_wielded_item():get_name() ~= "mcl_bows:bow_0"
and player:get_wielded_item():get_name() ~= "mcl_bows:bow_1" and player:get_wielded_item():get_name() ~= "mcl_bows:bow_1"
and player:get_wielded_item():get_name() ~= "mcl_bows:bow_2" then and player:get_wielded_item():get_name() ~= "mcl_bows:bow_2" then
players[playerName].fov = math.max(players[playerName].fov - 0.05, 1.0) fov_new = math.max(players[playerName].fov - 0.05, 1.0)
player:set_fov(players[playerName].fov, true, 0.15)
if sprinting == false then if sprinting == false then
playerphysics.remove_physics_factor(player, "speed", "mcl_sprint:sprint") playerphysics.remove_physics_factor(player, "speed", "mcl_sprint:sprint")
end end
end end
if fov_new ~= fov_old then
players[playerName].fov = fov_new
player:set_fov(fov_new, true, fade_time)
end
return true return true
end end
return false return false