1
0
Fork 0

Added darkness

This commit is contained in:
the-real-herowl 2024-01-22 04:45:19 +01:00
parent aa4ff1827d
commit 65b923c43c
2 changed files with 62 additions and 11 deletions

View File

@ -120,20 +120,25 @@ mcl_weather.skycolor = {
override_day_night_ratio = function(player, ratio)
local meta = player:get_meta()
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 arg
-- 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
if has_darkness and not is_visited_shepherd then
arg = 0
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
player:override_day_night_ratio(arg)
end,

View File

@ -406,6 +406,52 @@ mcl_potions.register_effect({
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({
name = "health_boost",
description = S("Health Boost"),