So there's this warning near the top of cmd6.c which reads:
* There may be a BIG problem with any effect that can cause changes
* to the inventory. For example, a "scroll of recharging" can cause
* a wand/staff to disappear, moving the inventory up. Luckily, the
* scrolls all appear BEFORE the staffs/wands, so this is not a problem.
* But, for example, a "staff of recharging" could cause MAJOR problems.
* In such a case, it will be best to either (1) "postpone" the effect
* until the end of the function, or (2) "change" the effect, say, into
* giving a staff "negative" charges, or "turning a staff into a stick".
* It seems as though a "rod of recharging" might in fact cause problems.
* The basic problem is that the act of recharging (and destroying) an
* item causes the inducer of that action to "move", causing "o_ptr" to
* no longer point at the correct item, with horrifying results.
I have transgressed and made an effect which can cause changes to the inventory (the staff of telekinesis), and of couse it causes problems.
There's got to be a way around this. I think it's kindof stupid that the object index changes based on where the object is.
Anyone care to help me find a workaround for this so I can keep the staff of telekinesis in the game? I don't care how hacky it is if it works.
I can't delay the effect until the end of do_cmd_use_staff() because then it would still use a charge if you didn't target anything.
..I just noticed it isn't only the staff of telekinesis, you can use the staff of mana-free spellcasting to cast recharging which can blow up something and mess things up that way too.
PS: whoever made these comments in the code used quotation marks WAY too often. Some of the usages of quotation marks in the comments are just rediculous as you can see from the quote above.
* There may be a BIG problem with any effect that can cause changes
* to the inventory. For example, a "scroll of recharging" can cause
* a wand/staff to disappear, moving the inventory up. Luckily, the
* scrolls all appear BEFORE the staffs/wands, so this is not a problem.
* But, for example, a "staff of recharging" could cause MAJOR problems.
* In such a case, it will be best to either (1) "postpone" the effect
* until the end of the function, or (2) "change" the effect, say, into
* giving a staff "negative" charges, or "turning a staff into a stick".
* It seems as though a "rod of recharging" might in fact cause problems.
* The basic problem is that the act of recharging (and destroying) an
* item causes the inducer of that action to "move", causing "o_ptr" to
* no longer point at the correct item, with horrifying results.
I have transgressed and made an effect which can cause changes to the inventory (the staff of telekinesis), and of couse it causes problems.
There's got to be a way around this. I think it's kindof stupid that the object index changes based on where the object is.
Anyone care to help me find a workaround for this so I can keep the staff of telekinesis in the game? I don't care how hacky it is if it works.
I can't delay the effect until the end of do_cmd_use_staff() because then it would still use a charge if you didn't target anything.
..I just noticed it isn't only the staff of telekinesis, you can use the staff of mana-free spellcasting to cast recharging which can blow up something and mess things up that way too.
PS: whoever made these comments in the code used quotation marks WAY too often. Some of the usages of quotation marks in the comments are just rediculous as you can see from the quote above.
Comment