inventory effect no-no, got to be a better way to do this.. (code stuff)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • will_asher
    DaJAngband Maintainer
    • Apr 2007
    • 1124

    inventory effect no-no, got to be a better way to do this.. (code stuff)

    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.
    Will_Asher
    aka LibraryAdventurer

    My old variant DaJAngband:
    http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...)
  • andrewdoull
    Unangband maintainer
    • Apr 2007
    • 872

    #2
    Originally posted by will_asher
    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.
    Hey - I fixed this in Unangband and blogged about it briefly. I mark the chosen item with a flag when selecting it, which I then use to find it later when I destroy it. Have a look at the Unangband cmd6.c - the flag is IDENT_BREAKS.

    Andrew
    The Roflwtfzomgbbq Quylthulg summons L33t Paladins -more-
    In UnAngband, the level dives you.
    ASCII Dreams: http://roguelikedeveloper.blogspot.com
    Unangband: http://unangband.blogspot.com

    Comment

    • fizzix
      Prophet
      • Aug 2009
      • 3025

      #3
      Ah, that explains the weirdness of this effect. So telekinesis staff will decrease the charges of whatever is above if the item you get occurs before the staves. If the item is after the staves it works properly. I wonder what would happen if the staff is the only item with charges in your inventory?

      Comment

      • will_asher
        DaJAngband Maintainer
        • Apr 2007
        • 1124

        #4
        Thanks Andrew. I used your idea and got it to work correctly.

        For now I'm only using the IDENT_BREAKS flag for using staffs. I might change it so it uses that for other objects later (like if I add a scroll of telekinesis).

        The other issue with telekinesis is that it picks up items which are out of line of sight, and I think that's overpowered, but Fizzix says it would be pretty much useless if it restricted it to objects in line of sight. So I'm thinking I'll either 1) make the staff very rare and add a scroll of telekinsis also, so it'll usually be a one-use thing. or 2) limit it by distance or by line of sight so you have to get either in line of sight or within ten spaces of the object.
        The thief and tourist both get telekinesis as a spell, but it's in the last dungeon book for the thief and the second to last useable book for the tourist.
        Will_Asher
        aka LibraryAdventurer

        My old variant DaJAngband:
        http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...)

        Comment

        • PowerDiver
          Prophet
          • Mar 2008
          • 2820

          #5
          Originally posted by will_asher
          The other issue with telekinesis is that it picks up items which are out of line of sight, and I think that's overpowered, but Fizzix says it would be pretty much useless if it restricted it to objects in line of sight.
          If you like the idea, but think it is overpowered, you could weaken it by moving the item 1 square closer every 10 [or whatever] game turns. To avoid inventory issues, you could force the player to pick it up manually. I think V currently charges 1 game turn to pick things up, but I'm not sure, and I don't know what it was in 3.0 so you might want to look at that if you went for manual pickup.

          Comment

          • Magnate
            Angband Devteam member
            • May 2007
            • 5110

            #6
            Originally posted by will_asher
            The other issue with telekinesis is that it picks up items which are out of line of sight, and I think that's overpowered, but Fizzix says it would be pretty much useless if it restricted it to objects in line of sight.
            I have to say I'm with Fizzix on this. Sang's "nab object" ability (a burglary-related talent) is essentially short-range tk, and only works on objects in LOS. It's a lovely idea but I can count the number of times I've ever used it on the fingers of one hand. It's a lot of coding effort for such a rarely-used thing.
            "Been away so long I hardly knew the place, gee it's good to be back home" - The Beatles

            Comment

            • Psi
              Knight
              • Apr 2007
              • 870

              #7
              Its a mage spell in FA (for objects in LoS) and I used it a lot when way out of my depth and unable to kill the monsters sitting on or around the object I want.

              Comment

              • Derakon
                Prophet
                • Dec 2009
                • 9022

                #8
                Last I checked (back in the 2.9.3 days, admittedly), Vanilla charged one turn to get any number of objects from the tile you are standing on. However, you can pick up items for free by using - to move onto the tile.

                I say just limit the range to 8 tiles or so. Enough so that you have to actually go into the greater vault to get the items out of its center.

                Comment

                • fizzix
                  Prophet
                  • Aug 2009
                  • 3025

                  #9
                  Originally posted by Psi
                  Its a mage spell in FA (for objects in LoS) and I used it a lot when way out of my depth and unable to kill the monsters sitting on or around the object I want.
                  In my current game, if I'm in LOS I'm already going to use my 0% fail TO rather than try to move an object.

                  Distance could work. I'd actually prefer it goes by path length, so you wouldn't be able to move stuff out of vaults without clearing the walls first. Something like 50-70 connected squares. That may be a hard coding problem though.

                  In my current game I just got the palantir, and I have 3 staves of Telekinesis. If I abuse both the distance issue I have a cheesy tactic of enlighting the level and then clearing out what I want.

                  I'm going to claim a lack of good gear and call it even.

                  Apparently I also abused the telekinesis anywhere bug several times during my comp win. In my defense, I didn't know it was a bug...

                  Comment

                  • will_asher
                    DaJAngband Maintainer
                    • Apr 2007
                    • 1124

                    #10
                    Originally posted by fizzix
                    In my current game I just got the palantir, and I have 3 staves of Telekinesis. If I abuse both the distance issue I have a cheesy tactic of enlighting the level and then clearing out what I want.
                    that's exactly why it's overpowered.

                    I think I finally have it working the way I want it to. Telekinesis requires the object to be in line of sight OR within max distance for the spell, which is usually 8 (but can be a little higher with good luck). If you have a full inventory, you can now use telekinesis to move the object to the space at your feet.
                    There's still one little annoying detail: I have a message to tell the player the max distance, but it gets replaced by the targetting prompt before the player has a chance to see it and I can't figure out how to add a -more- so that the player will have a chance to read the message.
                    EDIT: I figured out how to do this with inkey() so no problems now.
                    Last edited by will_asher; December 3, 2009, 02:46.
                    Will_Asher
                    aka LibraryAdventurer

                    My old variant DaJAngband:
                    http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...)

                    Comment

                    • konijn_
                      Hellband maintainer
                      • Jul 2007
                      • 367

                      #11
                      Originally posted by will_asher
                      that's exactly why it's overpowered.

                      I think I finally have it working mostly the way I want it to. Telekinesis requires the object to be in line of sight OR within max distance for the spell, which is usually 8 (but can be a little higher with good luck). If you have a full inventory, you can now use telekinesis to move the object to the space at your feet.
                      Man!! I was so looking forward to abusing that feature ;\
                      Can you make it an option

                      T.
                      * Are you ready for something else ? Hellband 0.8.8 is out! *

                      Comment

                      • will_asher
                        DaJAngband Maintainer
                        • Apr 2007
                        • 1124

                        #12
                        That might actually be pretty cool, but it'd be a cheat option.
                        cheat_allow_exploits
                        Will_Asher
                        aka LibraryAdventurer

                        My old variant DaJAngband:
                        http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...)

                        Comment

                        Working...
                        😀
                        😂
                        🥰
                        😘
                        🤢
                        😎
                        😞
                        😡
                        👍
                        👎