• 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!

Help with Loot Magic – Canary Server

Meffon

New Member
Joined
Jul 23, 2022
Messages
1
Reaction score
0
GitHub
Meffon
Hey everyone!

Sorry if this isn't the right place to post, I'm new to posting here ;D

So, I was recently playing on Taleon OT and noticed they have a spell that works like an auto-loot around the character (same range as exori). I tried to replicate it, and it seems to work for picking up loot, but I’d like to make it respect the skipped loot settings from "Manage Container."

Could anyone help me with that? Here’s the spell script:

local spell = Spell("instant")

function spell.onCastSpell(creature, variant)
local player = creature:getPlayer()
if not player then
return false
end

local radius = 2
local position = player:getPosition()

for x = -radius, radius do
for y = -radius, radius do
local effectPos = Position(position.x + x, position.y + y, position.z)
effectPos:sendMagicEffect(CONST_ME_MAGIC_BLUE)
end
end

for x = -radius, radius do
for y = -radius, radius do
local checkPos = Position(position.x + x, position.y + y, position.z)
local tile = Tile(checkPos)

if tile then
local corpse = tile:getTopDownItem()
if corpse and corpse:isContainer() then
local itemsToMove = {}

for i = corpse:getSize() - 1, 0, -1 do
local item = corpse:getItem(i)
if item then
table.insert(itemsToMove, item)
end
end


for _, item in ipairs(itemsToMove) do
local itemId = item:getId()
local itemCount = item:getCount()


local newItem = Game.createItem(itemId, itemCount)
if newItem then
if player:addItemEx(newItem) ~= RETURNVALUE_NOERROR then
player:sendTextMessage(MESSAGE_INFO_DESCR, "Inventário cheio! Loot enviado para a inbox.")
player:addItemEx(newItem, true) -- Envia para a inbox do jogador
end
item:remove()
end
end
end
end
end
end

return true
end

spell:name("Loot Collector")
spell:words("exevo loot")
spell:group("support")
spell:vocation("sorcerer;true", "druid;true", "knight;true", "paladin;true")
spell:castSound(SOUND_EFFECT_TYPE_SPELL_CREATURE_ILLUSION)
spell:id(39)
spell:cooldown(5 * 1000)
spell:groupCooldown(5 * 1000)
spell:level(20)
spell:mana(50)
spell:hasParams(true)
spell:isAggressive(false)
spell:needLearn(false)
spell:register()
 

Similar threads

Back
Top