diff --git a/scripts/fr_scripts/feneroxStuff.lua b/scripts/fr_scripts/feneroxStuff.lua index 60506881..3ddb68f2 100644 --- a/scripts/fr_scripts/feneroxStuff.lua +++ b/scripts/fr_scripts/feneroxStuff.lua @@ -10,7 +10,12 @@ function FRHelper:call(args, main, dt, ...) end if nighttime or underground and (foodValue >= args.foodThreshold) then - status.modifyResourcePercentage("health", args.healingRate * dt) + --special handling for NPCs, to prevent immortality + if not (world.isNpc(entity.id()) and status.resource("health") < 1) then + status.modifyResourcePercentage("health", args.healingRate * dt) + else + status.setResource("health",0) + end self:applyStats(args, args.name or "FR_feneroxNightBonus", main, dt, ...) else diff --git a/scripts/fr_scripts/floranStuff.lua b/scripts/fr_scripts/floranStuff.lua index a9fbb5b5..fbd2126e 100644 --- a/scripts/fr_scripts/floranStuff.lua +++ b/scripts/fr_scripts/floranStuff.lua @@ -82,16 +82,21 @@ function FRHelper:call(args, main, dt, ...) local regenCalc = (dayConfig.maxRegen - dayConfig.minRegen) * lightCalc + dayConfig.minRegen -- When it is sunny and they are well fed, florans regenerate - if hungerPerc >= dayConfig.hungerThreshold and lightLevel > dayConfig.minLight then - if underground and lightLevel > dayConfig.undergroundLight then - if hungerEnabled then - status.modifyResourcePercentage("food", -0.005 * dt) + --special handling for NPCs, to prevent immortality + if not (world.isNpc(entity.id()) and status.resource("health") < 1) then + if hungerPerc >= dayConfig.hungerThreshold and lightLevel > dayConfig.minLight then + if underground and lightLevel > dayConfig.undergroundLight then + if hungerEnabled then + status.modifyResourcePercentage("food", -0.005 * dt) + end + regenCalc = regenCalc * dayConfig.undergroundScale + status.modifyResourcePercentage("health", regenCalc * dt) + elseif not underground and lightLevel > dayConfig.minLight then + status.modifyResourcePercentage("health", regenCalc * dt) end - regenCalc = regenCalc * dayConfig.undergroundScale - status.modifyResourcePercentage("health", regenCalc * dt) - elseif not underground and lightLevel > dayConfig.minLight then - status.modifyResourcePercentage("health", regenCalc * dt) end + else + status.setResource("health",0) end end end \ No newline at end of file diff --git a/scripts/fr_scripts/healthRegen.lua b/scripts/fr_scripts/healthRegen.lua index 5aaf8d83..678eb49e 100644 --- a/scripts/fr_scripts/healthRegen.lua +++ b/scripts/fr_scripts/healthRegen.lua @@ -9,5 +9,10 @@ ]] function FRHelper:call(args, main, dt, ...) - status.modifyResourcePercentage("health", args.healingRate * dt) + --special handling for NPCs, to prevent immortality + if not (world.isNpc(entity.id()) and status.resource("health") < 1) then + status.modifyResourcePercentage("health", args.healingRate * dt) + else + status.setResource("health",0) + end end diff --git a/scripts/fr_scripts/novakidStuff.lua b/scripts/fr_scripts/novakidStuff.lua index e494986e..07090bb1 100644 --- a/scripts/fr_scripts/novakidStuff.lua +++ b/scripts/fr_scripts/novakidStuff.lua @@ -58,8 +58,13 @@ function FRHelper:call(args, main, dt, ...) local hungerCalc = math.min(1, (hungerPerc - dayConfig.minHunger) / (dayConfig.maxHunger - dayConfig.minHunger)) local regenCalc = (dayConfig.maxRegen - dayConfig.minRegen) * hungerCalc + dayConfig.minRegen - if hungerPerc >= dayConfig.minHunger then - status.modifyResourcePercentage("health", regenCalc * dt) + --special handling for NPCs, to prevent immortality + if not (world.isNpc(entity.id()) and status.resource("health") < 1) then + if hungerPerc >= dayConfig.minHunger then + status.modifyResourcePercentage("health", regenCalc * dt) + end + else + status.setResource("health",0) end end end \ No newline at end of file