Call Me Taffy
Call Me Maybe
- Joined
- Aug 9, 2009
- Messages
- 656
- Reaction score
- 125
So I want to be able to use my hammer on a variety of different items to give the chance on a random item & amount associated. It's a quick rusty remover edit, but not returning any items at all, the hammer just disappears.
local breakChance = 5
local hammerItems = {
[5892] = {{5880, 4}, {5880, 3}, {5880, 2}, {5880, 1}, {5889, 3}, {5889, 2}, {5889, 1}, {5887, 2}, {5889, 1}, {5887, 1}},
[4850] = {{6541, 25}, {6542, 25}, {6543, 25}, {6544, 25}, {6545, 25}, {6541, 5}, {6542, 5}, {6543, 5}, {6544, 5}, {6545, 5}, {6541, 15}, {6542, 15}, {6543, 15}, {6544, 15}, {6545, 15}},
[2348] = {{2143, 25}, {2144, 25}, {2143, 15}, {2144, 15}, {2143, 5}, {2144, 5}},
[2153] = {{2150, 5}, {2150, 10}, {2150, 15}},
[2154] = {{9970, 5}, {9970, 10}, {9970, 15}},
[2155] = {{2149, 5}, {2149, 10}, {2149, 15}},
[2156] = {{2147, 5}, {2147, 10}, {2147, 15}},
[2158] = {{2146, 5}, {2146, 10}, {2146, 15}}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if hammerItems[itemEx.itemid] ~= nil then
if math.random(100) <= breakChance then
doRemoveItem(itemEx.uid)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You shattered it.")
doSendMagicEffect(getCreaturePosition(cid),34)
else
local newId = hammerItems[itemEx.itemid][math.random(#hammerItems[itemEx.itemid])]
doTransformItem(itemEx.uid,newId)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"SMASH! Got a "..getItemName(newId))
doSendMagicEffect(getCreaturePosition(cid),66)
end
doRemoveItem(item.uid,1)
return true
end
return false
end