function Player:conjureItem(reagentId, conjureId, conjureCount, effect)
if not conjureCount and conjureId ~= 0 then
local itemType = ItemType(conjureId)
if itemType:getId() == 0 then
return false
end
local charges = itemType:getCharges()
if charges ~= 0 then
conjureCount = charges
end
end
local conjureItem = self:getItemById(reagentId, true, -1)
if reagentId ~= 0 and not conjureItem then
self:sendCancelMessage(RETURNVALUE_YOUNEEDAMAGICITEMTOCASTSPELL)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
local item = conjureItem:getParent():addItem(conjureId, conjureCount)
if not item then
item = self:addItem(conjureId, conjureCount)
if not item then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
end
if item:hasAttribute(ITEM_ATTRIBUTE_DURATION) then
item:decay()
end
conjureItem:remove(1)
self:getPosition():sendMagicEffect(item:getType():isRune() and CONST_ME_MAGIC_RED or effect)
return true
end
I have no idea when this got moved, but i think TFS 1.2, you will find inside spells/lib/spells.lua. Replace it with this:
LUA:function Player:conjureItem(reagentId, conjureId, conjureCount, effect) if not conjureCount and conjureId ~= 0 then local itemType = ItemType(conjureId) if itemType:getId() == 0 then return false end local charges = itemType:getCharges() if charges ~= 0 then conjureCount = charges end end local conjureItem = self:getItemById(reagentId, true, -1) if reagentId ~= 0 and not conjureItem then self:sendCancelMessage(RETURNVALUE_YOUNEEDAMAGICITEMTOCASTSPELL) self:getPosition():sendMagicEffect(CONST_ME_POFF) return false end local item = conjureItem:getParent():addItem(conjureId, conjureCount) if not item then item = self:addItem(conjureId, conjureCount) if not item then self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE) self:getPosition():sendMagicEffect(CONST_ME_POFF) return false end end if item:hasAttribute(ITEM_ATTRIBUTE_DURATION) then item:decay() end conjureItem:remove(1) self:getPosition():sendMagicEffect(item:getType():isRune() and CONST_ME_MAGIC_RED or effect) return true end
Now it will add the conjure item in the container it was orginally, if there is no room in that container. It will just add it somewhere in players backpack. As backup
local item = conjureItem:getParent():addItem(conjureId, conjureCount)
if not item then
item = self:addItem(conjureId, conjureCount)
if not item then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
end
function onCastSpell(creature, variant)
return creature:conjureItem(0, 3447, 15, CONST_ME_MAGIC_BLUE)
end