Minor issue is that if you press jump while swimming close to the shore, you accelerate not only in water but for some time out of water too which looks weird, maybe add check to stop speed boost if player suddenly gets out of water. I wonder if it would be possible to add land sprinting with similar script.
So I modified the script in the following way: onUpdate = function(dt) if enabled and doHurt then -- if running this calc if types.Actor.isSwimming(self) then -- if in water local mf = self.controls.movement local ms = self.controls.sideMovement if mf ~= 0 or ms ~= 0 then -- if moving if dynamic.fatigue(self).current == 0 then -- if out of fatigue hurtTime = hurtTime + dt if hurtTime > hurtWait then -- if enough time has passed ui.showMessage('Swimming while out of fatigue!') dynamic.health(self).current = math.max(0,dynamic.health(self).current - hurtVal) -- don't set to below 0 hurtTime = 0 end end end elseif buffTotal > 0 and doBuff == false then ui.showMessage('Out of water!') spdMod(-1,buffTotal) buffTotal = 0 doBuff = true end end end,
and now if you leave water while boosting, message is shown and boost is stopped.
4 comments
I wonder if it would be possible to add land sprinting with similar script.
So I modified the script in the following way:
onUpdate = function(dt)
and now if you leave water while boosting, message is shown and boost is stopped.if enabled and doHurt then -- if running this calc
if types.Actor.isSwimming(self) then -- if in water
local mf = self.controls.movement
local ms = self.controls.sideMovement
if mf ~= 0 or ms ~= 0 then -- if moving
if dynamic.fatigue(self).current == 0 then -- if out of fatigue
hurtTime = hurtTime + dt
if hurtTime > hurtWait then -- if enough time has passed
ui.showMessage('Swimming while out of fatigue!')
dynamic.health(self).current = math.max(0,dynamic.health(self).current - hurtVal) -- don't set to below 0
hurtTime = 0
end
end
end
elseif buffTotal > 0 and doBuff == false then
ui.showMessage('Out of water!')
spdMod(-1,buffTotal)
buffTotal = 0
doBuff = true
end
end
end,
Really makes swimming a little more fun.