Hi John & Damonya,
I have a quick question, seems like this is a relevant thread
I have a spell which spawns a staff weapon in front of the party (floating alcove) and then the staff is destroyed after a period of time (it is a late game power weapon). So, I have adapted (one of) the scripts designed to look through sacks, boxes, mortars etc to find the "item" so we can destroy it.
Here is a cut down version of the destroy staff function that is called when the timer runs out (activates):
Code: Select all
function destroyStave()
local n = "guardian_stave"
for i in allEntities(party.level) do
if i and i.name == n then
i:destroy()
if findEntity("guardiantimer") ~= nil then
findEntity("guardiantimer"):destroy()
return true
end
end
end
for i = 1, 4 do
for j = 1, 31 do
local item = party:getChampion(i):getItem(j)
if item then
if item.name == "sack" or
item.name == "mortar" or
item.name == "wooden_box" or
item.name == "treasure_chest" then
for s = 1,16 do
for m = 1,16 do
for x in item:containedItems() do
if x then
if x.name == "mortar" then
for y in x:containedItems() do
if y then
if y.name == n then
item:getItem(s):removeItem(m)
if findEntity("guardiantimer") ~= nil then
findEntity("guardiantimer"):destroy()
return true
end
end
end
end
end
end
if x.name == n then
item:removeItem(s)
if findEntity("guardiantimer") ~= nil then
findEntity("guardiantimer"):destroy()
return true
end
end
end
end
end
end
if item.name == n then
party:getChampion(i):removeItem(j)
if findEntity("guardiantimer") ~= nil then
findEntity("guardiantimer"):destroy()
return true
end
end
end
end
end
end
Again, this is adapted from a oldish but working script that actually used the itemFound = true/false method that you used in your script^^ John (which by the way I have copied and will experiment with soon - thank you!)
My question here is - Why am I cycling through 1,16 container slots? Where does the 16 come from? Sacks and mortars are 6 and the wooden box is 10 (the custom treasure chest is also 10)... Curious because the function will find and destroy that staff quite effectively - but NOT when the staff is in a wooden box or treasure chest
This has me stumped unfortunately

.... any guidance here??
(p.s. if you want me to post the spell up I am happy to.. just didn't want to dump a whole heap of code and expect people to wade through it

)