Matheus Vieira
Member
- Joined
- Apr 11, 2015
- Messages
- 105
- Reaction score
- 6
I'm struggling to implement a feature where a player does not die under certain conditions in TFS 1.3. I'm using onHealthChange to check for the condition and prevent death by restoring the player's health and mana when the incoming damage would be fatal. Here's the script I'm using:
However, the player still dies despite meeting the conditions. Any ideas on what might be missing or suggestions on a different approach?
LUA:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if creature:isPlayer() and creature:getStorageValue(98768) > os.time() then
local totalDamage = primaryDamage + secondaryDamage
if totalDamage >= creature:getHealth() then
creature:addHealth(creature:getMaxHealth())
creature:addMana(creature:getMaxMana())
return false
end
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
However, the player still dies despite meeting the conditions. Any ideas on what might be missing or suggestions on a different approach?