Hi,
I'm trying to create a tier system where I use an item on another item to increase target item's action ID.
Problem is, I want this system to work only with weapons and armors, but I didn't figure out how to check that (note that target item can be anywhere - ground, backpack, equipped, etc.)
So far, I am using the following code:
Any ideas? I don't mind reviewing the code to work with a list of IDs and check if target item ID is in the list or something like that, but I don't know how to do that as well.
Thanks!
I'm trying to create a tier system where I use an item on another item to increase target item's action ID.
Problem is, I want this system to work only with weapons and armors, but I didn't figure out how to check that (note that target item can be anywhere - ground, backpack, equipped, etc.)
So far, I am using the following code:
Lua:
local tierpotion = Action()
function tierpotion.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local targetItem = target.itemid
if not targetItem then
player:say("Process not started!",TALKTYPE_MONSTER_SAY)
return true
end
-- if targetItem IS WEAPON OR ARMOR then
local chance = math.random(100)
if chance >= 41 then
if target.actionid == 0 then
target:setActionId(1000)
player:sendMagicEffect(CONST_ME_MAGIC_GREEN)
else
player:say("Process failed!",TALKTYPE_MONSTER_SAY)
player:sendMagicEffect(CONST_ME_BLOCKHIT)
end
return item:remove(1)
end
-- end
end
tierpotion:id(36170)
tierpotion:register()
Any ideas? I don't mind reviewing the code to work with a list of IDs and check if target item ID is in the list or something like that, but I don't know how to do that as well.
Thanks!