2024-07-23 12:18:41 +03:00
|
|
|
su = {}
|
2024-07-24 09:17:26 +03:00
|
|
|
surface_effect = {
|
|
|
|
nplayer = {}
|
|
|
|
}
|
2024-07-23 12:18:41 +03:00
|
|
|
local timer = 0
|
|
|
|
|
2024-07-24 09:17:26 +03:00
|
|
|
dofile(minetest.get_modpath("surface_effect") .. "/function.lua")
|
2024-07-26 15:26:43 +03:00
|
|
|
dofile(minetest.get_modpath("surface_effect") .. "/nodes.lua")
|
2024-07-30 12:21:16 +03:00
|
|
|
dofile(minetest.get_modpath("surface_effect") .. "/register_abm.lua")
|
2024-07-23 12:18:41 +03:00
|
|
|
|
|
|
|
minetest.register_globalstep(function(dtime)
|
|
|
|
-- every 5 seconds
|
|
|
|
if timer > os.time() then
|
|
|
|
return
|
|
|
|
end
|
2024-07-30 18:10:59 +03:00
|
|
|
timer = os.time() + 5
|
2024-07-23 12:18:41 +03:00
|
|
|
|
|
|
|
for k, player in ipairs(minetest.get_connected_players()) do
|
|
|
|
local name = player:get_player_name()
|
|
|
|
local object = minetest.env:get_player_by_name(name)
|
|
|
|
|
|
|
|
if object then
|
2024-07-30 18:10:59 +03:00
|
|
|
surface_effect.setHud(player)
|
|
|
|
surface_effect.mask(player)
|
|
|
|
surface_effect.update_inventory(player)
|
|
|
|
surface_effect.technicDetectUranium(player)
|
|
|
|
|
2024-07-23 12:18:41 +03:00
|
|
|
local pos = object:get_pos()
|
|
|
|
su.rediationDomage(player, pos)
|
|
|
|
--minetest.chat_send_all(dump(areas:getAreasAtPos(pos)))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
--Новый игрок
|
|
|
|
minetest.register_on_newplayer(function(player)
|
|
|
|
surface_effect.setHud(player)
|
2024-07-24 09:17:26 +03:00
|
|
|
surface_effect.showLogo(player)
|
|
|
|
|
2024-07-23 12:18:41 +03:00
|
|
|
if minetest.get_modpath("hazmat_suit") then
|
|
|
|
player:get_inventory():add_item("main", 'hazmat_suit:suit_hazmat 1')
|
|
|
|
end
|
|
|
|
|
|
|
|
if minetest.get_modpath("farming") then
|
|
|
|
player:get_inventory():add_item("main", 'farming:bread 99')
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
minetest.register_on_joinplayer(function(player, last_login)
|
|
|
|
surface_effect.setHud(player)
|
2024-07-24 09:17:26 +03:00
|
|
|
surface_effect.showLogo(player)
|
|
|
|
|
2024-07-23 12:18:41 +03:00
|
|
|
local name = player:get_player_name()
|
|
|
|
local pos = player:get_pos()
|
2024-07-26 15:26:43 +03:00
|
|
|
surface_effect.mask(player)
|
2024-07-23 12:18:41 +03:00
|
|
|
|
2024-07-24 09:17:26 +03:00
|
|
|
surface_effect.nplayer[name]['logo'] = 'off'
|
2024-07-23 12:18:41 +03:00
|
|
|
end )
|
|
|
|
|
|
|
|
minetest.register_on_prejoinplayer(function(name, ip)
|
|
|
|
local player = minetest.get_player_by_name(name)
|
|
|
|
|
|
|
|
--Защита игрока отсмерти на спавне
|
|
|
|
--[[if object then
|
|
|
|
local pos = object:get_pos()
|
|
|
|
su.rediationDomage(player, pos)
|
|
|
|
end]]
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
|
|
|
|
--minetest.chat_send_all(dump(areas:getAreasAtPos(pos)))
|
|
|
|
local pos = player:get_pos()
|
|
|
|
local arAtr = areas:getAreasAtPos(pos)
|
|
|
|
|
|
|
|
if minetest.get_modpath("areas") then
|
|
|
|
if type(arAtr[1]) ~= 'nil' then
|
|
|
|
if arAtr[1]['name'] == 'spawn' then return true end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end )
|
|
|
|
|
|
|
|
--Вызывается, когда игрок покидает игру
|
|
|
|
--[[minetest.register_on_leaveplayer(function(player, timed_out)
|
|
|
|
|
|
|
|
end)]]
|
|
|
|
|
|
|
|
local mobs_monster = {
|
|
|
|
{name = "mobs_monster:sand_monster"},
|
|
|
|
{name = "mobs_monster:dirt_monster"},
|
|
|
|
{name = "mobs_monster:dungeon_master"},
|
|
|
|
{name = "mobs_monster:fire_spirit"},
|
|
|
|
{name = "mobs_monster:land_guard"},
|
|
|
|
{name = "mobs_monster:lava_flan"},
|
|
|
|
{name = "mobs_monster:mese_monster"},
|
|
|
|
{name = "mobs_monster:oerkki"},
|
|
|
|
{name = "mobs_monster:stone_monster"},
|
|
|
|
{name = "mobs_monster:tree_monster"},
|
|
|
|
}
|
|
|
|
|
|
|
|
for akey, v in ipairs(mobs_monster) do
|
|
|
|
local def = minetest.registered_entities[v.name]
|
|
|
|
def["on_die"] = function(self, pos)
|
|
|
|
minetest.add_item(pos, 'bonemeal:bone 5')
|
|
|
|
end
|
|
|
|
end
|
2024-07-26 15:26:43 +03:00
|
|
|
|
|
|
|
local on_radiation_damage = function(player, damage, pos)
|
|
|
|
local radiation_multiplier = player:get_armor_groups().radiation
|
|
|
|
if radiation_multiplier then
|
|
|
|
damage = damage * radiation_multiplier / 100
|
|
|
|
end
|
|
|
|
damage = math.floor(damage)
|
|
|
|
if damage > 0 then
|
2024-07-30 12:21:16 +03:00
|
|
|
minetest.log("action", player:get_player_name() .. " Hazmat " .. surface_effect.dump(surface_effect.checkHazmat(player)) .. " pos" .. minetest.pos_to_string(pos))
|
|
|
|
|
|
|
|
if surface_effect.checkHazmat(player) == false then
|
|
|
|
minetest.log("action", player:get_player_name() .. " takes " .. tostring(damage) .. " damage from radiation damage earth at " .. minetest.pos_to_string(pos))
|
|
|
|
player:set_hp(player:get_hp() - damage)
|
|
|
|
end
|
|
|
|
|
|
|
|
if surface_effect.detectNuclides(player) then
|
|
|
|
minetest.sound_play({name = "radiant_damage_geiger", gain = math.min(1, damage/10)}, {
|
|
|
|
to_player=player:get_player_name()
|
|
|
|
})
|
|
|
|
end
|
2024-07-26 15:26:43 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
radiant_damage.register_radiant_damage("radioactive_earth", {
|
|
|
|
interval = 1,
|
2024-07-30 18:10:59 +03:00
|
|
|
range = 4,
|
2024-07-26 15:26:43 +03:00
|
|
|
--inverse_square_falloff = true,
|
|
|
|
emitted_by = {["surface_effect:radioactive_earth"] = 0.5},
|
|
|
|
attenuated_by = {['air'] = 0.4, ['default:grass_1'] = 0.5},
|
2024-07-30 12:21:16 +03:00
|
|
|
default_attenuation = 2,
|
2024-07-26 15:26:43 +03:00
|
|
|
on_damage = on_radiation_damage,
|
|
|
|
})
|
|
|
|
|
2024-07-30 18:10:59 +03:00
|
|
|
--[[minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|
|
|
surface_effect.mask(player)
|
|
|
|
end)]]
|
|
|
|
|
|
|
|
minetest.register_on_player_inventory_action(function(player, action, inventory, inventory_info)
|
2024-07-26 15:26:43 +03:00
|
|
|
surface_effect.mask(player)
|
|
|
|
end)
|