Increase stamina heal rate when standing and not taking any actions.

This commit is contained in:
orbea 2020-04-01 15:32:11 -07:00 committed by texmex
parent 7dd27f01dd
commit b5867bdaa1
2 changed files with 9 additions and 1 deletions

@ -11,6 +11,7 @@ local particles = tonumber(setting_get("sprint_particles", "2"))
local stamina = minetest.is_yes(setting_get("sprint_stamina", "true")) local stamina = minetest.is_yes(setting_get("sprint_stamina", "true"))
local stamina_drain = tonumber(setting_get("sprint_stamina_drain", "2")) local stamina_drain = tonumber(setting_get("sprint_stamina_drain", "2"))
local stamina_heal = tonumber(setting_get("sprint_stamina_heal", "2")) local stamina_heal = tonumber(setting_get("sprint_stamina_heal", "2"))
local standing = tonumber(setting_get("sprint_stamina_standing", "2.5"))
local replenish = tonumber(setting_get("sprint_stamina_replenish", "2")) local replenish = tonumber(setting_get("sprint_stamina_replenish", "2"))
local starve = minetest.is_yes(setting_get("sprint_starve", "true")) local starve = minetest.is_yes(setting_get("sprint_starve", "true"))
local starve_drain = tonumber(setting_get("sprint_starve_drain", "0.5")) local starve_drain = tonumber(setting_get("sprint_starve_drain", "0.5"))
@ -92,7 +93,11 @@ local function replenish_stamina(player)
local player_stamina = player:get_meta():get_float("hbsprint:stamina") local player_stamina = player:get_meta():get_float("hbsprint:stamina")
local ctrl = player:get_player_control() local ctrl = player:get_player_control()
if player_stamina < 20 and not ctrl.jump then if player_stamina < 20 and not ctrl.jump then
if not ctrl.right and not ctrl.left and not ctrl.down and not ctrl.up and not ctrl.LMB and not ctrl.RMB then
player_stamina = math.min(20, player_stamina + standing)
else
player_stamina = math.min(20, player_stamina + stamina_heal) player_stamina = math.min(20, player_stamina + stamina_heal)
end
player:get_meta():set_float("hbsprint:stamina", player_stamina) player:get_meta():set_float("hbsprint:stamina", player_stamina)
end end
if mod_hudbars then if mod_hudbars then

@ -19,6 +19,9 @@ sprint_stamina_drain (Stamina drain) float 2
#The amount of stamina to heal while not sprinting #The amount of stamina to heal while not sprinting
sprint_stamina_heal (Stamina heal) float 2 sprint_stamina_heal (Stamina heal) float 2
#The amount of stamina to heal while not moving or taking any actions
sprint_stamina_standing (Stamina heal) float 2.5
#The amount of seconds before starting to replenish stamina #The amount of seconds before starting to replenish stamina
sprint_stamina_replenish (Stamina replenish) float 2 sprint_stamina_replenish (Stamina replenish) float 2