KhymChanur: Currently, if an artfiact gemstone is placed into a non-artifact wand, and the wand is destroyed, the gemstone is destroyed too, even though it's an artifact. The same thing applies to any artifact item which is contained/embedded in a non-artifact object. I can see three ways of handling this:
- The Lua code which inserts the artifact object into the non-artifact object sets some flag in the containing object that makes it impossible to destroy, and the flag is removed when the artifact is removed. If there's a means of inserting an artifact into a non-artifact who's Lua code doesn't take this precaution, then the embedded artifact is lost.
- The object which can contain another object defines a "on me getting destroyed" hook which takes care of removing embedded artifact items and dropping them on the floor when destroyed. If an object can contain another object, but doesn't have this hook defined, then the embedded artifact is lost.
- Change the C code which destroys an item to check to see if there's any embedded artifacts, and drops any artifacts it finds on the floor.
I'd think that #3 would be the ideal, even if #1 is also implemented, to make sure that artifacts are never lost due to some bug, but maybe there's times that you'd want an embedded artifact to be lost if the containing object is destroyed. But then, a "on me getting destroyed" hook could be used to cause this to happen if #3 is implemented. Hmmm...
NeilStevens: If I put an artifact stone into a non-artifact stick, that shouldn't make the stick indestructible. If lightning hits my wands, it should destroy them, leaving only any artifact gems in them.
This parallels the way that a non-artifact gem inside an artifact wand should blow, but leave the wand intact, if charging fails catastrophically.
So, #3 sounds good, but #1 is wrong because it imparts an ability from the gem to the stick. Just have it loop through all embedded items and attempt to destroy them. Any surviving artifacts fall to the floor. Hopefully the destroy function is safe to recurse into, heh. If it is, then calling the actual destroy routine will ensure we hit the destroy hooks for those items.
DarkGod: yes indeed, kill the non arts and keep the arts. I do not think it is too hard, I would need to check the code(I'm at work and my home system is doing a full recompile
but it should be most easy.
KhymChanur: Okay, I've implemented the code that does this, and it seems to work fine, except for the fact that after destroying the containing wand, there's no more of that object left, so item_optimize() deletes a copy of the object that the engine was keeping around in its internals for whatever reason. And when that copy is destroyed, it also drops the artifact gemstone on the ground, resulting in two gemstones. I can't figure out how to stop the second drop in a way that isn't a big hack.
NeilStevens: Sounds like a job for a quantity check. I'd look at the code myself but I haven't received a tome-cvs mail suggesting that it's in yet.
KhymChanur: Okay, it's been checked in.
NeilStevens: And, my attempted fix is in.
KhymChanur: Thanks.
ToME Wiki