diff options
author | ShadowNinja <shadowninja@minetest.net> | 2016-03-20 22:34:59 -0400 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2016-03-20 22:38:30 -0400 |
commit | 097d0335858f85b4c2e85e801caef1976f585aa6 (patch) | |
tree | 2486efc21486d7af67b6457fa1d66ea5fc1bdf58 | |
parent | 584cd82b5869d3e7310c5cf7900ea28764b3cf31 (diff) |
Fix radiation damage
-rw-r--r-- | technic/machines/HV/nuclear_reactor.lua | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/technic/machines/HV/nuclear_reactor.lua b/technic/machines/HV/nuclear_reactor.lua index b4a87e6..c7951ab 100644 --- a/technic/machines/HV/nuclear_reactor.lua +++ b/technic/machines/HV/nuclear_reactor.lua @@ -573,23 +573,24 @@ local abdomen_offset = vector.new(0, 1, 0) local abdomen_offset_length = vector.length(abdomen_offset) local cache_scaled_shielding = {} -local function dmg_player(pos, o) +local function dmg_player(pos, o, strength) local pl_pos = vector.add(o:getpos(), abdomen_offset) local shielding = 0 + local dist = vector.distance(pos, pl_pos) for ray_pos in technic.trace_node_ray(pos, - vector.direction(pos, pl_pos), - vector.distance(pos, pl_pos)) do + vector.direction(pos, pl_pos), dist) do if not vector.equals(ray_pos, pos) then local shield_name = minetest.get_node(ray_pos).name local shield_val = cache_scaled_shielding[sname] if not shield_val then - shield_val = math.sqrt(node_radiation_resistance(shield_name)) * -0.025 + shield_val = math.sqrt(node_radiation_resistance(shield_name)) * 0.025 cache_scaled_shielding[shield_name] = shield_val end - shielding = shielding + sval + shielding = shielding + shield_val end end - local dmg = (0.25e-6 * strength * strength * math.exp(shielding)) / math.max(0.75, dist_sq) + local dmg = (0.25e-6 * strength * strength) / + (math.max(0.75, dist * dist) * math.exp(shielding)) if dmg >= 0.25 then local dmg_int = math.floor(dmg) -- The closer you are to getting one more damage point, @@ -608,7 +609,7 @@ local function dmg_abm(pos, node) for _, o in pairs(minetest.get_objects_inside_radius(pos, strength * 0.001 + abdomen_offset_length)) do if o:is_player() then - dmg_player(pos, o) + dmg_player(pos, o, strength) end end end |