Resolvi colocar o sistema de critical hit aqui à disposição de todos. Percebi que o fórum não tinha nenhum atualizado ou sem erros, então pode ser útil para outras pessoas. A ideia foi do @fefuxd e foi testado no tfs 0.4. Lembrando que funciona somente para critical hits em players.
Funcionamento: Basicamente, o sistema dará chances diferentes para cada vocação para que aconteça o Critical Hit.
Em creaturescripts/scripts:
CriticalVocs.lua
local CriticalHitMsg, hit = true, --- true (false) para mostrar (ou não) o valor do hit no Default { -- porcentagem de aumento do hit, 1.2 = 20%, 2.0 = 100%, 1.4 = 40% e aí vai... [0] = {percent = 1.0}, [1] = {percent = 2.0}, [2] = {percent = 1.5}, [3] = {percent = 2.0}, [4] = {percent = 1.5}, [5] = {percent = 2.0}, [6] = {percent = 1.5}, [7] = {percent = 1.5}, [8] = {percent = 2.0} } local protect = {} function onStatsChange(cid, attacker, type, combat, value) if isPlayer(attacker) and (not (attacker == cid)) and (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS) and isPlayer(cid) and value >=1 then if (getPlayerStorageValue(attacker, 19830)) >= math.random (0,100) then if protect[attacker] then protect[attacker] = nil return true end critical = math.ceil(2*value*hit[getPlayerVocation(attacker)].percent) protect[attacker] = true doTargetCombatHealth(attacker, cid, combat, -critical, -critical, CONST_ME_NONE) if CriticalHitMsg then doPlayerSendTextMessage(attacker, MESSAGE_STATUS_CONSOLE_ORANGE, "CRITICAL HIT: "..math.floor((critical/2))) end doSendAnimatedText(getCreaturePos(attacker), "CRITICAL!!", COLOR_DARKRED) return false end end return true end
No login.lua:
local chanceTable = { -- chance [0 a 100%] para critical hit [0] = {chance = 10}, [1] = {chance = 20}, [2] = {chance = 30}, [3] = {chance = 50}, [4] = {chance = 40}, [5] = {chance = 20}, [6] = {chance = 30}, [7] = {chance = 50}, [8] = {chance = 40} } registerCreatureEvent(cid, "CriticalHit") setPlayerStorageValue(cid, 19830, chanceTable[getPlayerVocation(cid)].chance)
No creaturescripts.xml, adicione a tag:
<event type="statschange" name="CriticalHit" event="script" value="CriticalVocs.lua"/>
Lembrando que geralmente: (se é quem alguém não sabe)
[1] - Sorcerer ; [5] - Master Sorcerer
[2] - Druid; [6] - Elder Druid
[3] - Paladin; [7] - Royal Paladin
[4] - Knight; [8] - Elite Knight
Espero ter ajudado.