summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornumber Zero <silverunicorn2011@yandex.ru>2016-04-10 21:47:24 +0300
committerShadowNinja <shadowninja@minetest.net>2017-02-25 20:55:15 -0500
commitb739ed6cb1e24eb2800a4b99222b927acfbef9d0 (patch)
tree418ae5464c380092fc2bf56a726d8c21c4f7a659
parent51be33deea1c6ed942f18ba4f02580540541d2c9 (diff)
Made radiation configurable
-rw-r--r--technic/config.lua2
-rw-r--r--technic/radiation.lua55
2 files changed, 33 insertions, 24 deletions
diff --git a/technic/config.lua b/technic/config.lua
index 81a2224..c253612 100644
--- a/technic/config.lua
+++ b/technic/config.lua
@@ -9,6 +9,8 @@ local defaults = {
enable_wind_mill = "false",
enable_frames = "false",
enable_corium_griefing = "true",
+ enable_entity_radiation_damage = "true",
+ enable_longterm_radiation_damage = "true",
}
for k, v in pairs(defaults) do
diff --git a/technic/radiation.lua b/technic/radiation.lua
index 6ce8ecd..ce3cb80 100644
--- a/technic/radiation.lua
+++ b/technic/radiation.lua
@@ -242,6 +242,9 @@ local cache_scaled_shielding = {}
local rad_dmg_cutoff = 0.2
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 dmg_int = math.floor(dmg)
-- The closer you are to getting one more damage point,
@@ -297,17 +300,17 @@ end
local function dmg_object(pos, object, strength)
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)
if mul == 0 then
return
end
+ local dmg = calculate_base_damage(pos, obj_pos, strength)
+ if not dmg then
+ return
+ end
dmg = dmg * mul
apply_fractional_damage(object, dmg)
- if object:is_player() then
+ if longterm_damage and object:is_player() then
local pn = object:get_player_name()
radiated_players[pn] = (radiated_players[pn] or 0) + dmg
end
@@ -319,7 +322,9 @@ local function dmg_abm(pos, node)
local max_dist = strength * rad_dmg_mult_sqrt
for _, o in pairs(minetest.get_objects_inside_radius(pos,
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
@@ -331,26 +336,28 @@ if minetest.setting_getbool("enable_damage") then
action = dmg_abm,
})
- minetest.register_globalstep(function(dtime)
- for pn, dmg in pairs(radiated_players) do
- dmg = dmg - (dtime / 8)
- local player = minetest.get_player_by_name(pn)
- local killed
- if player and dmg > rad_dmg_cutoff then
- killed = apply_fractional_damage(player, (dmg * dtime) / 8)
- else
- dmg = nil
- end
- -- on_dieplayer will have already set this if the player died
- if not killed then
- radiated_players[pn] = dmg
+ if longterm_damage then
+ minetest.register_globalstep(function(dtime)
+ for pn, dmg in pairs(radiated_players) do
+ dmg = dmg - (dtime / 8)
+ local player = minetest.get_player_by_name(pn)
+ local killed
+ if player and dmg > rad_dmg_cutoff then
+ killed = apply_fractional_damage(player, (dmg * dtime) / 8)
+ 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
- end)
+ end)
- minetest.register_on_dieplayer(function(player)
- radiated_players[player:get_player_name()] = nil
- end)
+ minetest.register_on_dieplayer(function(player)
+ radiated_players[player:get_player_name()] = nil
+ end)
+ end
end
-- Radioactive materials that can result from destroying a reactor