su = {} surface_effect = { nplayer = {}, debug = minetest.settings:get_bool('surface_effect.debug') or false } local timer = 0 dofile(minetest.get_modpath("surface_effect") .. "/function.lua") dofile(minetest.get_modpath("surface_effect") .. "/nodes.lua") dofile(minetest.get_modpath("surface_effect") .. "/craft.lua") dofile(minetest.get_modpath("surface_effect") .. "/register_abm.lua") minetest.register_globalstep(function(dtime) -- every 5 seconds if timer > os.time() then return end timer = os.time() + 5 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 surface_effect.setHud(player) surface_effect.mask(player) surface_effect.update_inventory(player) surface_effect.technicDetectUranium(player) 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) 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) local name = player:get_player_name() surface_effect.nplayer[name]['radiation_damage'] = false local pos = player:get_pos() surface_effect.mask(player) su.rediationDomage(player, pos) 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) local name = player:get_player_name() surface_effect.nplayer[name]["radiation_damage"] = false surface_effect.nplayer[name]["id_varning_text"] = false surface_effect.nplayer[name]["id_mask"] = false surface_effect.nplayer[name]["id_varning_text"] = false 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 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 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 end end radiant_damage.register_radiant_damage("radioactive_earth", { interval = 1, range = 4, --inverse_square_falloff = true, emitted_by = {["surface_effect:radioactive_earth"] = 0.5}, attenuated_by = {['air'] = 0.4, ['default:grass_1'] = 0.5}, default_attenuation = 2, on_damage = on_radiation_damage, }) --[[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) surface_effect.mask(player) end) minetest.clear_craft({ output = "rangedweapons:hand_grenade" }) minetest.clear_craft({ output = "rangedweapons:rpg" }) minetest.clear_craft({ output = "rangedweapons:rocket" }) minetest.clear_craft({ output = "rangedweapons:40mm" })