Untitled

 avatar
unknown
plain_text
2 years ago
822 B
8
Indexable
local criticalStorage = 48913
local criticalMultiplier = 1.20

function onStatsChange(cid, attacker, type, combat, value, origin)

    if origin == ORIGIN_CRITICAL or not isPlayer(attacker) or attacker == cid or (type ~= STATSCHANGE_HEALTHLOSS and type ~= STATSCHANGE_MANALOSS) then
        return true
    end
 
    local critLevel = math.max(0, tonumber(getPlayerStorageValue(attacker, criticalStorage)) or 0)
    if critLevel == 0 then
        return true
    end

    if critLevel * 3 >= math.random(1000) then
        local damage = math.floor(value * criticalMultiplier)
        doTargetCombatHealth(attacker, cid, combat, -damage, -damage, 255, true, ORIGIN_CRITICAL)
        doSendAnimatedText(getCreaturePos(attacker), "Critical", 198)

        return false
    end
    
    return true
end
Editor is loading...
Leave a Comment