Skip to content

Commit

Permalink
Merge pull request #230 from Kherae/master
Browse files Browse the repository at this point in the history
no immortality allowed
  • Loading branch information
sayterdarkwynd authored May 16, 2020
2 parents e2e38bb + 00c54e4 commit f3e53eb
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
7 changes: 6 additions & 1 deletion scripts/fr_scripts/feneroxStuff.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 13 additions & 8 deletions scripts/fr_scripts/floranStuff.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 6 additions & 1 deletion scripts/fr_scripts/healthRegen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 7 additions & 2 deletions scripts/fr_scripts/novakidStuff.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f3e53eb

Please sign in to comment.