Untitled

mail@pastecode.io avatar
unknown
lua
a year ago
580 B
3
Indexable
Never
local config = {
	damage = {270, 310},
	effect = CONST_ME_BLOCKHIT,
	combatType = COMBAT_PHYSICALDAMAGE,
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local target = itemEx.uid
	if isMonster(target) then
		if math.random(1, 100) >= 50 then
			doTargetCombatHealth(cid, target, config.combatType, -config.damage[1], -config.damage[2], config.effect)
			if getItemAttribute(item.uid, "charges") > 1 then
				doItemSetAttribute(item.uid, "charges", getItemAttribute(item.uid, "charges") - 1)
			else
				doRemoveItem(item.uid, 1)
			end
		end
	end
  return true
end