mirror of
https://github.com/minetest-mods/technic.git
synced 2025-01-02 18:57:34 +01:00
Made radiation configurable
This commit is contained in:
parent
51be33deea
commit
b739ed6cb1
@ -9,6 +9,8 @@ local defaults = {
|
|||||||
enable_wind_mill = "false",
|
enable_wind_mill = "false",
|
||||||
enable_frames = "false",
|
enable_frames = "false",
|
||||||
enable_corium_griefing = "true",
|
enable_corium_griefing = "true",
|
||||||
|
enable_entity_radiation_damage = "true",
|
||||||
|
enable_longterm_radiation_damage = "true",
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, v in pairs(defaults) do
|
for k, v in pairs(defaults) do
|
||||||
|
@ -242,6 +242,9 @@ local cache_scaled_shielding = {}
|
|||||||
local rad_dmg_cutoff = 0.2
|
local rad_dmg_cutoff = 0.2
|
||||||
local radiated_players = {}
|
local radiated_players = {}
|
||||||
|
|
||||||
|
local entity_damage = technic.config:get_bool("enable_entity_radiation_damage")
|
||||||
|
local longterm_damage = technic.config:get_bool("enable_longterm_radiation_damage")
|
||||||
|
|
||||||
local function apply_fractional_damage(o, dmg)
|
local function apply_fractional_damage(o, dmg)
|
||||||
local dmg_int = math.floor(dmg)
|
local dmg_int = math.floor(dmg)
|
||||||
-- The closer you are to getting one more damage point,
|
-- The closer you are to getting one more damage point,
|
||||||
@ -297,17 +300,17 @@ end
|
|||||||
|
|
||||||
local function dmg_object(pos, object, strength)
|
local function dmg_object(pos, object, strength)
|
||||||
local obj_pos = vector.add(object:getpos(), calculate_object_center(object))
|
local obj_pos = vector.add(object:getpos(), calculate_object_center(object))
|
||||||
local dmg = calculate_base_damage(pos, obj_pos, strength)
|
|
||||||
if not dmg then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local mul = calculate_damage_multiplier(object)
|
local mul = calculate_damage_multiplier(object)
|
||||||
if mul == 0 then
|
if mul == 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
local dmg = calculate_base_damage(pos, obj_pos, strength)
|
||||||
|
if not dmg then
|
||||||
|
return
|
||||||
|
end
|
||||||
dmg = dmg * mul
|
dmg = dmg * mul
|
||||||
apply_fractional_damage(object, dmg)
|
apply_fractional_damage(object, dmg)
|
||||||
if object:is_player() then
|
if longterm_damage and object:is_player() then
|
||||||
local pn = object:get_player_name()
|
local pn = object:get_player_name()
|
||||||
radiated_players[pn] = (radiated_players[pn] or 0) + dmg
|
radiated_players[pn] = (radiated_players[pn] or 0) + dmg
|
||||||
end
|
end
|
||||||
@ -319,7 +322,9 @@ local function dmg_abm(pos, node)
|
|||||||
local max_dist = strength * rad_dmg_mult_sqrt
|
local max_dist = strength * rad_dmg_mult_sqrt
|
||||||
for _, o in pairs(minetest.get_objects_inside_radius(pos,
|
for _, o in pairs(minetest.get_objects_inside_radius(pos,
|
||||||
max_dist + abdomen_offset)) do
|
max_dist + abdomen_offset)) do
|
||||||
dmg_object(pos, o, strength)
|
if entity_damage or o:is_player() then
|
||||||
|
dmg_object(pos, o, strength)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -331,26 +336,28 @@ if minetest.setting_getbool("enable_damage") then
|
|||||||
action = dmg_abm,
|
action = dmg_abm,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
if longterm_damage then
|
||||||
for pn, dmg in pairs(radiated_players) do
|
minetest.register_globalstep(function(dtime)
|
||||||
dmg = dmg - (dtime / 8)
|
for pn, dmg in pairs(radiated_players) do
|
||||||
local player = minetest.get_player_by_name(pn)
|
dmg = dmg - (dtime / 8)
|
||||||
local killed
|
local player = minetest.get_player_by_name(pn)
|
||||||
if player and dmg > rad_dmg_cutoff then
|
local killed
|
||||||
killed = apply_fractional_damage(player, (dmg * dtime) / 8)
|
if player and dmg > rad_dmg_cutoff then
|
||||||
else
|
killed = apply_fractional_damage(player, (dmg * dtime) / 8)
|
||||||
dmg = nil
|
else
|
||||||
|
dmg = nil
|
||||||
|
end
|
||||||
|
-- on_dieplayer will have already set this if the player died
|
||||||
|
if not killed then
|
||||||
|
radiated_players[pn] = dmg
|
||||||
|
end
|
||||||
end
|
end
|
||||||
-- on_dieplayer will have already set this if the player died
|
end)
|
||||||
if not killed then
|
|
||||||
radiated_players[pn] = dmg
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
minetest.register_on_dieplayer(function(player)
|
minetest.register_on_dieplayer(function(player)
|
||||||
radiated_players[player:get_player_name()] = nil
|
radiated_players[player:get_player_name()] = nil
|
||||||
end)
|
end)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Radioactive materials that can result from destroying a reactor
|
-- Radioactive materials that can result from destroying a reactor
|
||||||
|
Loading…
Reference in New Issue
Block a user