2024-07-24 09:17:26 +03:00
|
|
|
local S = minetest.get_translator("surface_effect")
|
|
|
|
|
|
|
|
surface_effect.dump = function(o)
|
|
|
|
if type(o) == 'table' then
|
|
|
|
local s = '{ '
|
|
|
|
for k,v in pairs(o) do
|
|
|
|
if type(k) ~= 'number' then k = '"'..k..'"' end
|
|
|
|
s = s .. '['..k..'] = ' .. surface_effect.dump(v) .. ','
|
|
|
|
end
|
|
|
|
return s .. '} '
|
|
|
|
else
|
|
|
|
return tostring(o)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
surface_effect.showLogo = function(player)
|
|
|
|
local name = player:get_player_name()
|
|
|
|
|
|
|
|
if surface_effect.nplayer[name]['logo'] == 'off' then
|
|
|
|
local id = player:hud_add({
|
|
|
|
name = "logo",
|
|
|
|
hud_elem_type = "image",
|
|
|
|
position = {x = 0.2, y = 0.9},
|
|
|
|
scale = {
|
|
|
|
x = -30,
|
|
|
|
y = -10
|
|
|
|
},
|
|
|
|
text = "surfaces_effect_Mine_apocalypse.png"
|
|
|
|
})
|
|
|
|
|
|
|
|
surface_effect.nplayer[name]['logo'] = "on"
|
|
|
|
|
|
|
|
minetest.log("action", name .. " status logo " .. surface_effect.nplayer[name]['logo'] .. " id " .. id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
surface_effect.setHud = function(player)
|
|
|
|
local name = player:get_player_name()
|
|
|
|
|
|
|
|
if type(surface_effect.nplayer[name]) == 'nil' then
|
|
|
|
surface_effect.nplayer[name] = {
|
|
|
|
radiation_damage = "OFF",
|
|
|
|
id_varning_text = false,
|
|
|
|
logo = 'off',
|
2024-07-26 15:26:43 +03:00
|
|
|
id_mask = false,
|
2024-07-24 09:17:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
minetest.log("action", "Load nplayer: " .. surface_effect.dump(surface_effect.nplayer))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
surface_effect.checkHazmat = function(player)
|
|
|
|
local armor = armor:get_weared_armor_elements (player)
|
|
|
|
|
|
|
|
if armor ~= 'nil' then
|
|
|
|
if type(armor) == 'nil' then return false end
|
|
|
|
|
|
|
|
if armor.head == "hazmat_suit:suit_hazmat" then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
surface_effect.radiaton_off = function(player)
|
|
|
|
local name = player:get_player_name()
|
|
|
|
|
|
|
|
if surface_effect.nplayer[name]["radiation_damage"] == "ON" then
|
|
|
|
player:hud_remove(surface_effect.nplayer[name]['id_varning_text'])
|
|
|
|
surface_effect.nplayer[name]["radiation_damage"] = "OFF"
|
|
|
|
surface_effect.nplayer[name]["id_varning_text"] = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--Защита от радиацйии
|
|
|
|
surface_effect.technic_forcefield_radiation_protection = function(pos, player)
|
|
|
|
if not minetest.get_modpath("technic") then return false end
|
|
|
|
|
|
|
|
local radius = 20
|
|
|
|
local protectors = minetest.find_nodes_in_area(
|
|
|
|
{x = pos.x - radius , y = pos.y - radius , z = pos.z - radius},
|
|
|
|
{x = pos.x + radius , y = pos.y + radius , z = pos.z + radius},
|
|
|
|
{"technic:forcefield_emitter_on"})
|
|
|
|
|
|
|
|
if #protectors > 0 then
|
|
|
|
local npos = protectors[1]
|
|
|
|
local meta = minetest.get_meta(npos)
|
|
|
|
local pos1 = vector.subtract(pos, npos)
|
|
|
|
local range = meta:get_int("range")
|
|
|
|
|
|
|
|
if math.round(pos1.x) < range and math.round(pos1.x) > 0 - range and
|
|
|
|
math.round(pos1.y) < range and math.round(pos1.y) > 0 - range and
|
|
|
|
math.round(pos1.z) < range and math.round(pos1.z) > 0 - range
|
|
|
|
then
|
|
|
|
--minetest.chat_send_all(dump((0 - range)))
|
|
|
|
surface_effect.radiaton_off(player)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-07-26 15:26:43 +03:00
|
|
|
surface_effect.mask = function(player)
|
|
|
|
local name = player:get_player_name()
|
|
|
|
|
|
|
|
if surface_effect.checkHazmat(player) == true and surface_effect.nplayer[name]["id_mask"] == false then
|
|
|
|
local id = player:hud_add({
|
|
|
|
name = "Radiation effect",
|
|
|
|
hud_elem_type = "image",
|
|
|
|
position = {x = 0.5, y = 0.5},
|
|
|
|
scale = {
|
|
|
|
x = -100,
|
|
|
|
y = -110
|
|
|
|
},
|
|
|
|
z_index = -100,
|
|
|
|
text = "surface_effect_mask.png"
|
|
|
|
})
|
|
|
|
|
|
|
|
surface_effect.nplayer[name]["id_mask"] = id
|
|
|
|
|
|
|
|
elseif surface_effect.nplayer[name]["id_mask"] ~= false and surface_effect.checkHazmat(player) == false then
|
|
|
|
player:hud_remove(surface_effect.nplayer[name]['id_mask'])
|
|
|
|
surface_effect.nplayer[name]["id_mask"] = false
|
|
|
|
end
|
|
|
|
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2024-07-24 09:17:26 +03:00
|
|
|
su.rediationDomage = function (player, pos)
|
|
|
|
local name = player:get_player_name()
|
|
|
|
|
|
|
|
if pos.y > -40 and pos.y < 1500 then
|
|
|
|
if surface_effect.technic_forcefield_radiation_protection(pos,player) == true then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.sound_play("surface_effect_radiaciya",{
|
|
|
|
gain = 1.0,
|
|
|
|
to_player = name,
|
|
|
|
})
|
|
|
|
|
|
|
|
persistent_api.add_persistent_effect({
|
|
|
|
name = "damage_player", -- identifier
|
|
|
|
object = player, -- affected object
|
|
|
|
duration = 10, -- this effect will last 10 seconds
|
|
|
|
effect = function(player)
|
|
|
|
|
|
|
|
if surface_effect.nplayer[name]['radiation_damage'] == "OFF" then
|
|
|
|
local idtext = player:hud_add({
|
|
|
|
name = "Attention! Radiation ",
|
|
|
|
hud_elem_type = "text",
|
|
|
|
position = {x = 1, y = 0.5},
|
|
|
|
offset = {x = -180, y = 0},
|
|
|
|
text = S("Attention! High levels of radiation."),
|
|
|
|
alignment = -1,
|
|
|
|
scale = { x = 50, y = 10},
|
|
|
|
number = 0xFF0000,
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.after(1.52, function(name, id)
|
|
|
|
local player = minetest.get_player_by_name(name)
|
|
|
|
if player then
|
|
|
|
--player:hud_remove(id)
|
|
|
|
else
|
|
|
|
-- player has left the game
|
|
|
|
end
|
|
|
|
end, player:get_player_name(), id)
|
|
|
|
surface_effect.nplayer[name]["radiation_damage"] = "ON"
|
|
|
|
surface_effect.nplayer[name]["id_varning_text"] = idtext
|
|
|
|
end
|
|
|
|
|
|
|
|
if surface_effect.checkHazmat(player) == false then
|
|
|
|
player:set_hp(player:get_hp()-0.1) -- damage the player one half heart
|
|
|
|
end
|
|
|
|
|
|
|
|
end,
|
|
|
|
persistence = 2, -- every 0.1 seconds for 10 seconds the previous function will be run.
|
|
|
|
})
|
|
|
|
else
|
|
|
|
surface_effect.radiaton_off(player)
|
|
|
|
end
|
|
|
|
end
|