Page 1 of 1
Making an Inventory/Equipped Item Disappear
Posted: Mon Mar 16, 2015 7:16 am
by David Ward
Something we've put together recently is a spell that spawns a magic weapon that can be equipped, like a magic sword. Thing is, it is supposed to disappear after a certain amount of time, or if that is simply not workable, after a number of uses, but we haven't been able to figure out how to use a timer in this way.
Is there a way to make an item like this disappear after a certain amount of time, whether it is equipped or not?
Re: Making an Inventory/Equipped Item Disappear
Posted: Tue Mar 17, 2015 3:34 am
by Eburt
As discussed in
this thread this is very difficult due to the possibility of the weapon being in places like in a container. If you can be sure it will be in certain places, it's not so bad... would forcing the party member to keep it equipped until the duration expires be an option? I think that might be doable...
Re: Making an Inventory/Equipped Item Disappear
Posted: Tue Mar 17, 2015 5:43 am
by cameronC
Eburt wrote:As discussed in
this thread this is very difficult due to the possibility of the weapon being in places like in a container. If you can be sure it will be in certain places, it's not so bad... would forcing the party member to keep it equipped until the duration expires be an option? I think that might be doable...
If that is the largest hurdle then it's pretty doable...
ItemComponent:setFitContainer(boolean) Set whether the item fits inside containers such as sacks or wooden boxes (default true)
Re: Making an Inventory/Equipped Item Disappear
Posted: Tue Mar 17, 2015 7:07 am
by minmay
Yep, if you stop it from fitting in containers you only have to:
- store its id, then use FindEntity() to find it if it's on the map
- if that returns nil, it's not on the map so it must be in an inventory; iterate through all champions' slots to find it.
- don't include any ways for it to get into a monster's inventory (you would have to avoid using giant frogs for example) unless you are willing to also iterate through all monster inventories
You do need to worry about the implications of destroying the item while it's in a SocketComponent or SurfaceComponent; it will trigger onRemoveItem connectors for example.
Re: Making an Inventory/Equipped Item Disappear
Posted: Tue Mar 17, 2015 6:43 pm
by David Ward
Thank you all for the input. Looking into it now~