Error:
Script:
Functions:
Code:
[26/2/2014 14:38:0] [Error - CreatureScript Interface]
[26/2/2014 14:38:0] data/creaturescripts/scripts/critical.lua:onAttack
[26/2/2014 14:38:0] Description:
[26/2/2014 14:38:0] data/creaturescripts/scripts/critical.lua:33: attempt to call global 'getItemAttack' (a nil value)
[26/2/2014 14:38:0] stack traceback:
[26/2/2014 14:38:0] data/creaturescripts/scripts/critical.lua:33: in function <data/creaturescripts/scripts/critical.lua:8>
Script:
Code:
local tabelachance=
{
[11]=20,
[12]=5
}
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 < 0 then
return true
end
if getDistanceBetween(getCreaturePos(cid), getCreaturePos(target)) > 1 then
return TRUE
end
local healing =
{
[1] = 0.01,
[2] = 0.02,
[3] = 0.03,
[4] = 0.04,
[5] = 0.05
}
local skill = getPlayerSkillLevel(cid, getPlayerWeaponSkill(cid))
local level = getPlayerLevel(cid)
local formula = math.floor((getItemAttack(weapon)/100*60)+(skill/100*60)+(level/100*60))
local text = "Critical!"
local effect = 31
local rand1 = math.random(1,100)
local vid = getPlayerVocation(cid)
if tabelachance[vid] and rand1 <= tabelachance[vid] then
doCreatureSay(cid, text, TALKTYPE_MONSTER)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid)*healing[math.random(1,#healing)])
doTargetCombatHealth(cid, target, COMBAT_PHYSICALDAMAGE, (-formula), (-formula), effect)
end
return true
end
Functions:
Code:
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