• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[TFS 1.0] Max dmg - 40% of targets Max HP (Players)

Eldin

Eldin Projects
Joined
Jun 12, 2008
Messages
1,334
Reaction score
614
Location
Sweden
Greets!

This script would prevent an abuse for high people to single shot lower ones, this would actually add abit more of a skill.

The script would only target players and prevent people from taking more then 40% of the targets max health.

Lets say you have 1000HP max (when full), that means you can lose a maximim of 400 HP from another player no matter what HP you are at.

Kind Regards,
Eldin.
 
For simplicity I just set secondary damage to 0 when it limits the damage. Primary damage will be 40% of the target's max health. I did not test it though.
Code:
function onHealthChange(target, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if attacker and target then
        if attacker:isPlayer() and target:isPlayer() then
            local maxDamage = target:getMaxHealth() * 0.4
            primaryDamage = math.max(primaryDamage + secondaryDamage, maxDamage)
            secondaryDamage = primaryDamage < maxDamage and secondaryDamage or 0
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
 
Back
Top