Postado Fevereiro 16, 2015 10 anos Autor Esqueci das virgulas, tenta agora: local config = { specific_weapons = "yes", -- Somente armas especificas poderãoo dar critico? (("yes" / true) / ("no" / false)) critical_chance = 25, -- 1 a 100 critical_damage = 200, -- damage + critical_damage% critical_weapons = { [2400] = {30, 100}, [2222] = {25, 200} } } config.specific_weapons = getBooleanFromString(config.specific_weapons) function onStatsChange(cid, attacker, type, combat, value) if(type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS) then if(specific_weapons) then for weapon_ids, arrays in pairs(config.critical_weapons) do if(getPlayerSlotItem(attacker, CONST_SLOT_RIGHT).itemid == weapon_ids or getPlayerSlotItem(attacker, CONST_SLOT_LEFT).itemid == weapon_ids) then if(math.random(1,100) <= arrays[1]) then doTargetCombatHealth(attacker, cid, combat, -math.floor(value+(value*(arrays[2]/100))), -math.floor(value+(value*(arrays[2]/100))), CONST_ME_NONE) doSendAnimatedText(getThingPos(cid), "CRITICAL!", TEXTCOLOR_DARKRED) -- Só é permitido 9 caracteres return false end end end else if(math.random(1,100) <= config.critical_chance) then doTargetCombatHealth(attacker, cid, combat, -math.floor(value+(value*(config.critical_damage/100))), -math.floor(value+(value*(config.critical_damage/100))), CONST_ME_NONE) doSendAnimatedText(getThingPos(cid), "CRITICAL!", TEXTCOLOR_DARKRED) return false end end end return true end Não funcionou,vou postar um script que eu possuo que funciona perfeitamente para mim,apenas gostaria que houvesse a opção de selecionar a a arma que vai causar o critico e a porcentagem e o dano dela igual você criou nesse script acima: critical_weapons = { [2400] = {30, 100}, [2222] = {25, 200} } Esse script que eu vou postar para analise do funcionamento eu rodo ele com uma função nova na minha LIB,que seria essa: function getWeaponSkill(itemid) if itemid == 0 then return 0 end local skill = {[0]=0, [2]=1, [1]=2, [3]=3, [7]=4, [6]=7} return skill[getItemInfo(itemid).weaponType] end function getPlayerWeaponSkill(cid) return getWeaponSkill(getPlayerWeapon(cid).itemid) end Se conseguir incrementar nesse script apenas a função de poder escolher a arma,chance e porcetagem, no lugar de escolher as vocações ta perfeito,pois ele se baseia pela skill,então um mage nao sera efetivo usando uma arma dessa!: 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 <event type="attack" name="critical" event="script" value="critico.lua"/>
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.