diff --git a/docs/issues.txt b/docs/issues.txt index 46b5ff5f..ae894f29 100644 --- a/docs/issues.txt +++ b/docs/issues.txt @@ -10,8 +10,6 @@ ISSUES: Bugs, Cleanup and Refinements #### # #### # ###### ###### # # #### - NEW HEALTH SYSTEM: - - Prevent healing while moving - - Prevent healing while breath < 11 - Prefer killing later inventory slots over earlier ones (maybe sequentially scan with random chance to stop on an eligible slot) to give players some agency on what diff --git a/mods/nc_player_health/healing.lua b/mods/nc_player_health/healing.lua index edd3f9c9..3d340b18 100644 --- a/mods/nc_player_health/healing.lua +++ b/mods/nc_player_health/healing.lua @@ -5,14 +5,23 @@ local math_exp, math_random, math_sqrt = math.exp, math.random, math.sqrt -- LUALOCALS > --------------------------------------------------------- +local ppos = {} local cache = {} local function envcheck(player) - local stats = {} + local pname = player:get_player_name() + + if player:get_breath() < 11 then return end local pos = player:getpos() pos.y = pos.y + 1.6 + local old = ppos[pname] or pos + ppos[pname] = pos + local moving = not vector.equals(pos, old) + + local stats = {} + stats.light = minetest.get_node_light(pos) local target = vector.add(pos, { @@ -32,7 +41,6 @@ local function envcheck(player) stats.green = groups.green or 0 stats.water = groups.water or 0 + stats.green / 5 - local pname = player:get_player_name() local agg = cache[pname] if not agg then agg = {} @@ -59,6 +67,7 @@ local function envcheck(player) + (agg.space * agg.space) + (agg.light * agg.light) heal = math_sqrt(heal) + if moving then heal = heal / 2 end nodecore.addphealth(player, heal) end