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?
Making an Inventory/Equipped Item Disappear
- David Ward
- Posts: 103
- Joined: Wed Jan 07, 2015 11:44 pm
- Location: Vancouver, BC, Canada
Re: Making an Inventory/Equipped Item Disappear
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
If that is the largest hurdle then it's pretty doable...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...
ItemComponent:setFitContainer(boolean) Set whether the item fits inside containers such as sacks or wooden boxes (default true)
Writer and sometimes artist of the very slightly acclaimed comic series Scrambled Circuits. A comic series about a robot written by a human.
Grimrock 2 socketSystem: viewtopic.php?f=22&t=8546 / Github
Grimrock 2 socketSystem: viewtopic.php?f=22&t=8546 / Github
Re: Making an Inventory/Equipped Item Disappear
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.
- 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.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
- David Ward
- Posts: 103
- Joined: Wed Jan 07, 2015 11:44 pm
- Location: Vancouver, BC, Canada
Re: Making an Inventory/Equipped Item Disappear
Thank you all for the input. Looking into it now~