forked from VoxeLibre/VoxeLibre
Added darkness
This commit is contained in:
parent
aa4ff1827d
commit
65b923c43c
|
@ -120,8 +120,12 @@ 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
|
||||||
|
if has_darkness and not is_visited_shepherd then
|
||||||
|
arg = 0
|
||||||
|
else
|
||||||
-- Apply night vision only for dark sky
|
-- 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 is_dark = minetest.get_timeofday() > 0.8 or minetest.get_timeofday() < 0.2 or mcl_weather.state ~= "none"
|
||||||
local pos = player:get_pos()
|
local pos = player:get_pos()
|
||||||
|
@ -135,6 +139,7 @@ mcl_weather.skycolor = {
|
||||||
else
|
else
|
||||||
arg = ratio
|
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