--0 - fist - SKILL_FIST
--1 - club - SKILL_CLUB
--2 - sword - SKILL_SWORD
--3 - axe - SKILL_AXE
--4 - distance - SKILL_DISTANCE
--5 - shield - SKILL_SHIELD
--13 - mlvl
-- param - multipler of chance
function chanceToUseSkills(player, skill, param)
local skillValue = player:getEffectiveSkillLevel(skill)
local chance = 0.0
local level = player:getLevel()
if skill == 13 then
skillValue = player:getMagicLevel()
end
chance = level/100 + (( skillValue /8) * param)
-- print ("chance: " .. chance .. ", weapon skill " .. skillValue) -- debug info
return chance
end
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, 46)
setCombatFormula(combat1, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
setCombatFormula(combat2, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)
local arr = {
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 1, 0, 1, 0, 0},
{0, 0, 0, 1, 1, 1, 0, 0, 0},
{0, 0, 1, 1, 3, 1, 1, 0, 0},
{0, 0, 0, 1, 1, 1, 0, 0, 0},
{0, 0, 1, 0, 1, 0, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0}
}
local area = createCombatArea(arr)
setCombatArea(combat1, area)
function onUseWeapon(cid, var)
pos = getPlayerPosition(cid)
rand = math.random(1,100)
if chanceToUseSkills(cid, SKILL_CLUB, 1.1) >= rand then
doCombat(cid, combat1, var)
end
return doCombat(cid, combat2, var)
end