Fabi Marzan
Well-Known Member
- Joined
- Aug 31, 2020
- Messages
- 135
- Solutions
- 6
- Reaction score
- 66
OTX 2
I was looking to make a Critical Hit for each Vocation, that is, when a vocation for example a Kina makes a Critical Hit it has an effect, and a paladin when making a critical hit makes another effect for each vocation.
I have a scripts as an example but it would only be necessary to place that each vocation has its effect
I was looking to make a Critical Hit for each Vocation, that is, when a vocation for example a Kina makes a Critical Hit it has an effect, and a paladin when making a critical hit makes another effect for each vocation.
I have a scripts as an example but it would only be necessary to place that each vocation has its effect
Lua:
local tabelachance={ -- Aqui e a chance que cada voc tem, por exemplo a voc numero 4 tem 6% de chance de dar critical.
[4]=6,
[8]=7,
[12]=12,
[16]=16
}
function onAttack(cid,target)
local weapon = getPlayerWeapon(cid)
if weapon.uid == 0 then
return true
end
local atk = getItemInfo(weapon.itemid).attack + getItemInfo(weapon.itemid).extraAttack
if atk < 45 then
return true
end
if getDistanceBetween(getCreaturePos(cid), getCreaturePos(target)) > 1 then
return TRUE
end
local textos = { -- Textos que aparecerao para quando for executado o critical.
[1] = 'Feel My Power!',
[2] = 'For Honor!',
[3] = 'This Safe, Dammit!',
[4] = '',
}
local healing = { --o healing que o critical pode dar, 10%..10% etc.
[1] = 0.10,
[2] = 0.15,
[3] = 0.10,
}
local skill = getPlayerSkillLevel(cid, getPlayerWeaponSkill(cid))
local level = getPlayerLevel(cid)
--Formula para se basear no dano--
local formula1 = level*atk*skill --formula 1
local formula2 = formula1/150 --formula 2
local formula = math.floor(formula2/6+math.random(10, 50)) --formula final, o player hitará isso
local text = "Critical!" --texto animado
local text_color = COLOR_GREY
local effect = 31 --efeito que vai dar no alvo.
local rand1 = math.random(1,100)
local vid = getPlayerVocation(cid)
if tabelachance[vid] and rand1 <= tabelachance[vid] then
doSendAnimatedText(getCreaturePosition(cid), text, text_color)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid)*healing[math.random(1,#healing)])
doTargetCombatHealth(cid, target, COMBAT_PHYSICALDAMAGE, (-formula), (-formula), effect)
doPlayerSay(cid, textos[math.random(1,#textos)], TALKTYPE_ORANGE_1)
end
return true
end