1
0
Fork 0

Smooth out FOV changes, add specificity to potion effects to avoid overlap

This commit is contained in:
Brandon 2020-06-23 21:36:55 -04:00
parent d632cf289c
commit fceffa6f1c
2 changed files with 15 additions and 12 deletions

View File

@ -124,7 +124,7 @@ minetest.register_globalstep(function(dtime)
if player:get_pos() then mcl_potions._add_spawner(player, "#00CC33") end if player:get_pos() then mcl_potions._add_spawner(player, "#00CC33") end
if is_leaping[player].timer >= is_leaping[player].dur then if is_leaping[player].timer >= is_leaping[player].dur then
playerphysics.remove_physics_factor(player, "jump", "leaping") playerphysics.remove_physics_factor(player, "jump", "mcl_potions:leaping")
is_leaping[player] = nil is_leaping[player] = nil
end end
@ -146,7 +146,7 @@ minetest.register_globalstep(function(dtime)
if player:get_pos() then mcl_potions._add_spawner(player, "#009999") end if player:get_pos() then mcl_potions._add_spawner(player, "#009999") end
if is_swift[player].timer >= is_swift[player].dur then if is_swift[player].timer >= is_swift[player].dur then
playerphysics.remove_physics_factor(player, "speed", "swiftness") playerphysics.remove_physics_factor(player, "speed", "mcl_potions:swiftness")
is_swift[player] = nil is_swift[player] = nil
end end
@ -178,10 +178,9 @@ minetest.register_globalstep(function(dtime)
end end
end ) end)
-- reset player is_invisible/poison if they go offline local function _reset_player_effects(player)
minetest.register_on_leaveplayer(function(player)
player = player or player:get_luaentity() player = player or player:get_luaentity()
@ -221,7 +220,11 @@ minetest.register_on_leaveplayer(function(player)
is_cat[player] = nil is_cat[player] = nil
end end
end) end
minetest.register_on_leaveplayer( function(player) _reset_player_effects(player) end)
minetest.register_on_dieplayer( function(player) _reset_player_effects(player) end)
function mcl_potions.make_invisible(player, toggle) function mcl_potions.make_invisible(player, toggle)
@ -326,13 +329,13 @@ function mcl_potions.swiftness_func(player, factor, duration)
if not is_swift[player] then if not is_swift[player] then
is_swift[player] = {dur = duration, timer = 0} is_swift[player] = {dur = duration, timer = 0}
playerphysics.add_physics_factor(player, "speed", "swiftness", factor) playerphysics.add_physics_factor(player, "speed", "mcl_potions:swiftness", factor)
else else
local victim = is_swift[player] local victim = is_swift[player]
playerphysics.add_physics_factor(player, "speed", "swiftness", factor) playerphysics.add_physics_factor(player, "speed", "mcl_potions:swiftness", factor)
victim.dur = math.max(duration, victim.dur - victim.timer) victim.dur = math.max(duration, victim.dur - victim.timer)
victim.timer = 0 victim.timer = 0
@ -347,13 +350,13 @@ function mcl_potions.leaping_func(player, factor, duration)
if not is_leaping[player] then if not is_leaping[player] then
is_leaping[player] = {dur = duration, timer = 0} is_leaping[player] = {dur = duration, timer = 0}
playerphysics.add_physics_factor(player, "jump", "leaping", factor) playerphysics.add_physics_factor(player, "jump", "mcl_potions:leaping", factor)
else else
local victim = is_leaping[player] local victim = is_leaping[player]
playerphysics.add_physics_factor(player, "jump", "leaping", factor) playerphysics.add_physics_factor(player, "jump", "mcl_potions:leaping", factor)
victim.dur = math.max(duration, victim.dur - victim.timer) victim.dur = math.max(duration, victim.dur - victim.timer)
victim.timer = 0 victim.timer = 0

View File

@ -46,11 +46,11 @@ local function setSprinting(playerName, sprinting) --Sets the state of a player
if players[playerName] then if players[playerName] then
players[playerName].sprinting = sprinting players[playerName].sprinting = sprinting
if sprinting == true then if sprinting == true then
players[playerName].fov = math.min(players[playerName].fov + 0.02, 1.2) players[playerName].fov = math.min(players[playerName].fov + 0.03, 1.2)
player:set_fov(players[playerName].fov, true, 0.15) player:set_fov(players[playerName].fov, true, 0.15)
playerphysics.add_physics_factor(player, "speed", "mcl_sprint:sprint", mcl_sprint.SPEED) playerphysics.add_physics_factor(player, "speed", "mcl_sprint:sprint", mcl_sprint.SPEED)
elseif sprinting == false then elseif sprinting == false then
players[playerName].fov = math.max(players[playerName].fov - 0.02, 1.0) players[playerName].fov = math.max(players[playerName].fov - 0.03, 1.0)
player:set_fov(players[playerName].fov, true, 0.15) player:set_fov(players[playerName].fov, true, 0.15)
playerphysics.remove_physics_factor(player, "speed", "mcl_sprint:sprint") playerphysics.remove_physics_factor(player, "speed", "mcl_sprint:sprint")
end end