Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
There are spells can conjure items in newer version, i.e. diamond arrows and they will disappear after 1 hour but thats a decay attribute on the item itself, not that the spell will take care of that.
All of the field runes (firebomb, energybomb, etc) work like that, the only thing you need to do is guarantee that the item has decaying.
Edit --
On tfs 1.2 inside data/spells/lib/spells.lua
You have the following function:
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()...
There are spells can conjure items in newer version, i.e. diamond arrows and they will disappear after 1 hour but thats a decay attribute on the item itself, not that the spell will take care of that.
All of the field runes (firebomb, energybomb, etc) work like that, the only thing you need to do is guarantee that the item has decaying.
Edit --
On tfs 1.2 inside data/spells/lib/spells.lua
You have the following function:
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
if reagentId ~= 0 and not self:removeItem(reagentId, 1, -1) then
self:sendCancelMessage(RETURNVALUE_YOUNEEDAMAGICITEMTOCASTSPELL)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
local item = self:addItem(conjureId, conjureCount)
if not item then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
if item:hasAttribute(ITEM_ATTRIBUTE_DURATION) then
item:decay()
end
self:getPosition():sendMagicEffect(item:getType():isRune() and CONST_ME_MAGIC_RED or effect)
return true
You could make that function return the item itself, then you can create an event on the spell script to remove that item, for example:
New function:
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
if reagentId ~= 0 and not self:removeItem(reagentId, 1, -1) then
self:sendCancelMessage(RETURNVALUE_YOUNEEDAMAGICITEMTOCASTSPELL)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
local item = self:addItem(conjureId, conjureCount)
if not item then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
if item:hasAttribute(ITEM_ATTRIBUTE_DURATION) then
item:decay()
end
self:getPosition():sendMagicEffect(item:getType():isRune() and CONST_ME_MAGIC_RED or effect)
return item
end
Then, on the spell you could do this:
Lua:
function onCastSpell(creature, variant)
local item = creature:conjureItem(0, ITEM_ID, ITEM_COUNT, CONST_ME_MAGIC_BLUE)
addEvent(function()
item:remove()
end, 10 * 1000)
if not item then
return false
end
return true
end
There are spells can conjure items in newer version, i.e. diamond arrows and they will disappear after 1 hour but thats a decay attribute on the item itself, not that the spell will take care of that.
All of the field runes (firebomb, energybomb, etc) work like that, the only thing you need to do is guarantee that the item has decaying.
Edit --
On tfs 1.2 inside data/spells/lib/spells.lua
You have the following function:
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
if reagentId ~= 0 and not self:removeItem(reagentId, 1, -1) then
self:sendCancelMessage(RETURNVALUE_YOUNEEDAMAGICITEMTOCASTSPELL)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
local item = self:addItem(conjureId, conjureCount)
if not item then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
if item:hasAttribute(ITEM_ATTRIBUTE_DURATION) then
item:decay()
end
self:getPosition():sendMagicEffect(item:getType():isRune() and CONST_ME_MAGIC_RED or effect)
return true
You could make that function return the item itself, then you can create an event on the spell script to remove that item, for example:
New function:
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
if reagentId ~= 0 and not self:removeItem(reagentId, 1, -1) then
self:sendCancelMessage(RETURNVALUE_YOUNEEDAMAGICITEMTOCASTSPELL)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
local item = self:addItem(conjureId, conjureCount)
if not item then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
if item:hasAttribute(ITEM_ATTRIBUTE_DURATION) then
item:decay()
end
self:getPosition():sendMagicEffect(item:getType():isRune() and CONST_ME_MAGIC_RED or effect)
return item
end
Then, on the spell you could do this:
Lua:
function onCastSpell(creature, variant)
local item = creature:conjureItem(0, ITEM_ID, ITEM_COUNT, CONST_ME_MAGIC_BLUE)
addEvent(function()
item:remove()
end, 10 * 1000)
if not item then
return false
end
return true
end
Yes, currently I am using addEvent to remove the items that have been created just like in your example. I thought maybe there are ticks that will do that for me but as you said; apparently I just need to add decay attribute to my own item which will disappear after X time, which is fine with me and that's better and safer alternative than addEvent in my opinion. Thanks