Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local creature_table = {}
- local lvlcrit = 16221 -- storage (the same like givecritical.lua script)
- local chance = 10 -- critical chance = 10%
- function onStatsChange(cid, attacker, type, combat, value)
- if not isPlayer(attacker) then
- return true
- elseif cid == attacker then
- return true
- end
- if not creature_table[cid] then
- creature_table[cid] = false
- elseif creature_table[cid] == true then
- creature_table[cid] = false
- return true
- end
- if getPlayerStorageValue(attacker, lvlcrit) < 1 then
- return true
- end
- if (math.random(0, 100) <= chance) then
- if type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS then
- creature_table[cid] = true
- local multiplier = (getPlayerStorageValue(attacker, lvlcrit) / 100) + 1
- local new_value = math.ceil(value * multiplier)
- doPlayerSendTextMessage(attacker, MESSAGE_STATUS_CONSOLE_ORANGE, "Critical Hit: "..math.floor((new_value/1)))
- doTargetCombatHealth(attacker, cid, combat, -new_value, -new_value, 255)
- doSendAnimatedText(getCreaturePos(attacker), "CRITICAL!", 138)
- return false
- end
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement