sonic-radiance/sonic-radiance.love/scenes/overworld/actors/player/health.lua

20 lines
536 B
Lua
Raw Normal View History

2021-04-18 18:23:52 +02:00
local PlayerHealth = Object:extend()
function PlayerHealth:initHealth()
2021-04-19 18:04:29 +02:00
self.fallDamage = 0
2021-04-21 16:46:41 +02:00
self.fallSound = ""
2021-04-18 18:23:52 +02:00
end
2021-04-19 18:04:29 +02:00
function PlayerHealth:takeDamage(damage)
local damage = damage or 10
damage = damage / 100
if (game.difficulty:get("allDamage")) then
for _, name in ipairs(game.characters.team) do
game.characters:sendDamageFromMap(name, damage)
end
else
game.characters:sendDamageFromMap(game.characters.team[game.characters.active], damage)
end
end
2021-04-18 18:23:52 +02:00
return PlayerHealth