mirror of
https://github.com/minetest-mods/technic.git
synced 2025-07-01 07:40:37 +02:00
allow mods to change damage taken by radiation
allow using technic's radiation resistance function and add resistance to lead (needs rework)
This commit is contained in:
@ -507,22 +507,31 @@ local default_radiation_resistance_per_group = {
|
|||||||
local cache_radiation_resistance = {}
|
local cache_radiation_resistance = {}
|
||||||
local function node_radiation_resistance(nodename)
|
local function node_radiation_resistance(nodename)
|
||||||
local eff = cache_radiation_resistance[nodename]
|
local eff = cache_radiation_resistance[nodename]
|
||||||
if eff then return eff end
|
if eff then
|
||||||
|
return eff
|
||||||
|
end
|
||||||
local def = minetest.registered_nodes[nodename] or {groups={}}
|
local def = minetest.registered_nodes[nodename] or {groups={}}
|
||||||
eff = def.radiation_resistance or default_radiation_resistance_per_node[nodename]
|
eff = def.radiation_resistance or default_radiation_resistance_per_node[nodename]
|
||||||
if not eff then
|
if not eff then
|
||||||
for g, v in pairs(def.groups) do
|
for g, v in pairs(def.groups) do
|
||||||
if v > 0 and default_radiation_resistance_per_group[g] then
|
if v > 0
|
||||||
|
and default_radiation_resistance_per_group[g] then
|
||||||
eff = default_radiation_resistance_per_group[g]
|
eff = default_radiation_resistance_per_group[g]
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not eff then eff = 0 end
|
if not eff then
|
||||||
|
eff = 0
|
||||||
|
end
|
||||||
cache_radiation_resistance[nodename] = eff
|
cache_radiation_resistance[nodename] = eff
|
||||||
return eff
|
return eff
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function technic.get_node_radiation_resistance(...)
|
||||||
|
return node_radiation_resistance(...)
|
||||||
|
end
|
||||||
|
|
||||||
-- Radioactive nodes cause damage to nearby players. The damage
|
-- Radioactive nodes cause damage to nearby players. The damage
|
||||||
-- effect depends on the intrinsic strength of the radiation source,
|
-- effect depends on the intrinsic strength of the radiation source,
|
||||||
-- the distance between the source and the player, and the shielding
|
-- the distance between the source and the player, and the shielding
|
||||||
@ -575,6 +584,16 @@ local cache_scaled_shielding = {}
|
|||||||
local damage_enabled = minetest.setting_getbool("enable_damage")
|
local damage_enabled = minetest.setting_getbool("enable_damage")
|
||||||
|
|
||||||
if damage_enabled then
|
if damage_enabled then
|
||||||
|
local registered_on_radiation_damaging = {}
|
||||||
|
function technic.register_on_radiation_damaging(func)
|
||||||
|
registered_on_radiation_damaging[#registered_on_radiation_damaging+1] = func
|
||||||
|
end
|
||||||
|
--[[technic.register_on_radiation_damaging(function(dmg, player, pos, node, strength)
|
||||||
|
return -- do nothing
|
||||||
|
return dmg*2 -- change damage
|
||||||
|
return false -- do not damage player
|
||||||
|
end)]]
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"group:radioactive"},
|
nodenames = {"group:radioactive"},
|
||||||
interval = 1,
|
interval = 1,
|
||||||
@ -609,11 +628,26 @@ if damage_enabled then
|
|||||||
dmg_int = dmg_int + 1
|
dmg_int = dmg_int + 1
|
||||||
end
|
end
|
||||||
if dmg_int > 0 then
|
if dmg_int > 0 then
|
||||||
|
for _,func in ipairs(registered_on_radiation_damaging) do
|
||||||
|
local newdmg = func(dmg_int, o, pos, node, strength)
|
||||||
|
if newdmg == false then
|
||||||
|
dmg_int = 0
|
||||||
|
break
|
||||||
|
elseif newdmg then
|
||||||
|
if newdmg <= 0 then
|
||||||
|
dmg_int = 0
|
||||||
|
break
|
||||||
|
end
|
||||||
|
dmg_int = newdmg
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if dmg_int ~= 0 then
|
||||||
o:set_hp(math.max(o:get_hp() - dmg_int, 0))
|
o:set_hp(math.max(o:get_hp() - dmg_int, 0))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -99,7 +99,8 @@ minetest.register_node(":technic:lead_block", {
|
|||||||
tiles = { "technic_lead_block.png" },
|
tiles = { "technic_lead_block.png" },
|
||||||
is_ground_content = true,
|
is_ground_content = true,
|
||||||
groups = {cracky=1, level=2},
|
groups = {cracky=1, level=2},
|
||||||
sounds = default.node_sound_stone_defaults()
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
radiation_resistance = 500
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_alias("technic:wrought_iron_block", "default:steelblock")
|
minetest.register_alias("technic:wrought_iron_block", "default:steelblock")
|
||||||
|
Reference in New Issue
Block a user