forked from VoxeLibre/VoxeLibre
Added darkness
This commit is contained in:
parent
872d249169
commit
b404b14ad0
|
@ -120,20 +120,25 @@ mcl_weather.skycolor = {
|
||||||
override_day_night_ratio = function(player, ratio)
|
override_day_night_ratio = function(player, ratio)
|
||||||
local meta = player:get_meta()
|
local meta = player:get_meta()
|
||||||
local has_night_vision = meta:get_int("night_vision") == 1
|
local has_night_vision = meta:get_int("night_vision") == 1
|
||||||
|
local has_darkness = meta:get_int("darkness") == 1
|
||||||
local is_visited_shepherd = meta:get_int("mcl_shepherd:special") == 1
|
local is_visited_shepherd = meta:get_int("mcl_shepherd:special") == 1
|
||||||
local arg
|
local arg
|
||||||
-- Apply night vision only for dark sky
|
if has_darkness and not is_visited_shepherd then
|
||||||
local is_dark = minetest.get_timeofday() > 0.8 or minetest.get_timeofday() < 0.2 or mcl_weather.state ~= "none"
|
arg = 0
|
||||||
local pos = player:get_pos()
|
|
||||||
local dim = mcl_worlds.pos_to_dimension(pos)
|
|
||||||
if (has_night_vision or is_visited_shepherd) and is_dark and dim ~= "nether" and dim ~= "end" then
|
|
||||||
if ratio == nil then
|
|
||||||
arg = NIGHT_VISION_RATIO
|
|
||||||
else
|
|
||||||
arg = math.max(ratio, NIGHT_VISION_RATIO)
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
arg = ratio
|
-- Apply night vision only for dark sky
|
||||||
|
local is_dark = minetest.get_timeofday() > 0.8 or minetest.get_timeofday() < 0.2 or mcl_weather.state ~= "none"
|
||||||
|
local pos = player:get_pos()
|
||||||
|
local dim = mcl_worlds.pos_to_dimension(pos)
|
||||||
|
if (has_night_vision or is_visited_shepherd) and is_dark and dim ~= "nether" and dim ~= "end" then
|
||||||
|
if ratio == nil then
|
||||||
|
arg = NIGHT_VISION_RATIO
|
||||||
|
else
|
||||||
|
arg = math.max(ratio, NIGHT_VISION_RATIO)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
arg = ratio
|
||||||
|
end
|
||||||
end
|
end
|
||||||
player:override_day_night_ratio(arg)
|
player:override_day_night_ratio(arg)
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -406,6 +406,52 @@ mcl_potions.register_effect({
|
||||||
uses_factor = false,
|
uses_factor = false,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
mcl_potions.register_effect({
|
||||||
|
name = "darkness",
|
||||||
|
description = S("Darkness"),
|
||||||
|
get_tt = function(factor)
|
||||||
|
return S("surrounded by darkness")
|
||||||
|
end,
|
||||||
|
res_condition = function(object)
|
||||||
|
return (not object:is_player())
|
||||||
|
end,
|
||||||
|
on_start = function(object, factor)
|
||||||
|
object:get_meta():set_int("darkness", 1)
|
||||||
|
mcl_weather.skycolor.update_sky_color({object})
|
||||||
|
object:set_sky({fog = {
|
||||||
|
fog_distance = 10,
|
||||||
|
}})
|
||||||
|
EF.darkness[object].flash = 0.6
|
||||||
|
end,
|
||||||
|
on_step = function(dtime, object, factor, duration)
|
||||||
|
if object:get_meta():get_int("night_vision") ~= 1 then
|
||||||
|
local flash = EF.darkness[object].flash
|
||||||
|
if flash < 0.1 then EF.darkness[object].flashdir = true
|
||||||
|
elseif flash > 0.6 then EF.darkness[object].flashdir = false end
|
||||||
|
flash = EF.darkness[object].flashdir and (flash + dtime) or (flash - dtime)
|
||||||
|
object:set_sky({fog = {
|
||||||
|
fog_start = flash,
|
||||||
|
}})
|
||||||
|
EF.darkness[object].flash = flash
|
||||||
|
else
|
||||||
|
object:set_sky({fog = {
|
||||||
|
fog_start = 0.99,
|
||||||
|
}})
|
||||||
|
end
|
||||||
|
mcl_weather.skycolor.update_sky_color({object})
|
||||||
|
end,
|
||||||
|
on_end = function(object)
|
||||||
|
object:get_meta():set_int("darkness", 0)
|
||||||
|
mcl_weather.skycolor.update_sky_color({object})
|
||||||
|
object:set_sky({fog = {
|
||||||
|
fog_distance = -1,
|
||||||
|
fog_start = -1,
|
||||||
|
}})
|
||||||
|
end,
|
||||||
|
particle_color = "#000000",
|
||||||
|
uses_factor = false,
|
||||||
|
})
|
||||||
|
|
||||||
mcl_potions.register_effect({
|
mcl_potions.register_effect({
|
||||||
name = "health_boost",
|
name = "health_boost",
|
||||||
description = S("Health Boost"),
|
description = S("Health Boost"),
|
||||||
|
|
Loading…
Reference in New Issue