Implementing stat swap concepts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Derakon
    Prophet
    • Dec 2009
    • 9022

    Implementing stat swap concepts

    As discussed in the gnome mages thread, it'd be nice to have some alternative implementations of the nexus stat swap effect. This thread can discuss implementations. Arguments about what game impact nexus should have can continue going in the original thread; this is more for code details.

    The current effect is "memoryless", i.e. the game just swaps the values of two of your stats, and that's the "new normal". Any effect that allows for later reversion (as a temporary status effect, or reversion at levelup, is going to require the game to keep track of what the stats ought to be when the effect expires, so they can be restored later.

    I haven't had a chance to take a close look at the 4.0 codebase yet, but a quick look indicates that there's still a player struct that includes an array of current stat values (stat_cur). I assume this is the "internal" stat value before race/class/equipment modifiers are applied.

    The way I'd propose tracking nexus stat swaps, then, would be to add a "lookup table" that maps stat indices to stat indices. Normally this would be an array that looks like this: {0, 1, 2, 3, 4}. That is, each stat index maps to itself. When a nexus stat swap occurs, we a) swap the stat values in stat_cur (as we do now), and b) update the mapping array. For example, if STR and INT are swapped, then the array becomes {1, 0, 2, 3, 4}. If STR then further gets swapped with CON, it becomes {4, 0, 2, 3, 1}.

    When the time comes to revert the swap, we can use the mapping array as a guide, and then restore that array to its "identity" state.

    This does result in the interesting behavior that e.g. if you get swapped, then any stat boosts / drains applied during the swap will "transfer" when the swap reverts. Which sounds reasonable enough to me.

    Presumably it'd also be desirable to add a "Nexus" or "Scrambled" text to the status line to indicate to the player that their character is in a temporarily-unusual state. Though this could result in semi-annoying UI if (in Nick's proposal where the stat swap only goes away on levelup) the character hits level 50 with maxed stats across the board and can't get rid of that little status line. One reason to prefer the temporary status effect approach I proposed.
  • Estie
    Veteran
    • Apr 2008
    • 2347

    #2
    What about this:

    A nexus attack applies damage and a random effect from (various teleports, stat swap), right ?

    Now replace full swap with partial swap where the amount of points exchanged is proportional to the damage received; so a weak vortex breath might do +1, while a strong dracolisk breath can do up to +15 or so.
    This way swap effectively remains in the game, but only the most powerfull nexus monsters can deliver the full effect.

    If it is an issue of "not hard enough!", the chance for the swap occuring can be increased.

    Comment

    • Ingwe Ingweron
      Veteran
      • Jan 2009
      • 2129

      #3
      Originally posted by Estie
      What about this:

      A nexus attack applies damage and a random effect from (various teleports, stat swap), right ?

      Now replace full swap with partial swap where the amount of points exchanged is proportional to the damage received; so a weak vortex breath might do +1, while a strong dracolisk breath can do up to +15 or so.
      This way swap effectively remains in the game, but only the most powerfull nexus monsters can deliver the full effect.

      If it is an issue of "not hard enough!", the chance for the swap occuring can be increased.
      This seems reasonable to me. It avoids the "gotcha" effect of a low-level nexus vortex screwing up an unaware @, while not defanging the higher level monsters. It has the added benefit of following the Angband philosophy used with most other monsters of introducing an effect when it is relatively harmless, thereby making a player aware of its existence, before it is encountered full-force later in the game.
      “We're more of the love, blood, and rhetoric school. Well, we can do you blood and love without the rhetoric, and we can do you blood and rhetoric without the love, and we can do you all three concurrent or consecutive. But we can't give you love and rhetoric without the blood. Blood is compulsory. They're all blood, you see.”
      ― Tom Stoppard, Rosencrantz and Guildenstern are Dead

      Comment

      • Derakon
        Prophet
        • Dec 2009
        • 9022

        #4
        Guys, guys, I wanted to keep this thread about the specifics of how an implementation ought to work, not what exactly should be done. Ideally any implementation will support a wide range of possible effects so we can experiment and figure out which effect works best.

        Comment

        • Estie
          Veteran
          • Apr 2008
          • 2347

          #5
          Sorry; my post implies that "memory" isnt needed, so I thought it would fit.

          Comment

          • Nick
            Vanilla maintainer
            • Apr 2007
            • 9637

            #6
            Originally posted by Derakon
            The way I'd propose tracking nexus stat swaps, then, would be to add a "lookup table" that maps stat indices to stat indices. Normally this would be an array that looks like this: {0, 1, 2, 3, 4}. That is, each stat index maps to itself. When a nexus stat swap occurs, we a) swap the stat values in stat_cur (as we do now), and b) update the mapping array. For example, if STR and INT are swapped, then the array becomes {1, 0, 2, 3, 4}. If STR then further gets swapped with CON, it becomes {4, 0, 2, 3, 1}.
            Yes, this looks like the correct way to do it.

            One of the things I have been aiming at with the 4.0 codebase is for the code to represent as transparently as possible what is happening in the game world - so preferencing clarity over efficiency. This scheme fits in, because it is a direct statement of stats being swapped, which is what we are thinking the in-game effect is.
            One for the Dark Lord on his dark throne
            In the Land of Mordor where the Shadows lie.

            Comment

            • Nick
              Vanilla maintainer
              • Apr 2007
              • 9637

              #7
              Originally posted by Estie
              Now replace full swap with partial swap where the amount of points exchanged is proportional to the damage received; so a weak vortex breath might do +1, while a strong dracolisk breath can do up to +15 or so.
              This way swap effectively remains in the game, but only the most powerfull nexus monsters can deliver the full effect.
              Another way of representing the power would be to have stat swaps as an additional effect to the teleport. So any nexus attack has a teleport effect, plus a (small) random number of swaps, more for bigger attacks.
              One for the Dark Lord on his dark throne
              In the Land of Mordor where the Shadows lie.

              Comment

              • Derakon
                Prophet
                • Dec 2009
                • 9022

                #8
                If we do want to be able to represent a partial swap and then later be able to restore the correct stats, then we could store a 2D array representing how much each individual stat has "donated" to the other stats. So e.g. if the first array was {0, 2, 1, 0, 0}, then STR would have given 2 points to INT and 1 to WIS. Reversion of the partial swap would be done by going through the arrays, subtracting the values from the recipient stats, and adding the sum of all values back to the donor stat (being careful to only apply stat caps after all the modifications are reverted).

                Application of multiple swaps could either be done by iteratively applying +1/-1 modifiers or by doing a single swap of larger scope like +3/-3, +10/-10, etc. The former would tend to be more balanced but also be more likely to affect any given stat.

                Under this regime, outside stat modifications like Potions of Strength would continue to affect the "correct" stat both before and after the swap.

                Comment

                • Ingwe Ingweron
                  Veteran
                  • Jan 2009
                  • 2129

                  #9
                  Originally posted by Derakon
                  Guys, guys, I wanted to keep this thread about the specifics of how an implementation ought to work, not what exactly should be done. Ideally any implementation will support a wide range of possible effects so we can experiment and figure out which effect works best.
                  How is Estie's post not a discussion of an alternative implementation of the nexus stat swap effect? It sounded to me like precisely what this thread called for, it just wasn't your particular alternative implementation idea. I favor Estie's alternative implementation, a swap effect proportionate to damage, but not reversable except with the tried and true method of increasing the stats.

                  I'm totally fine with this thread being limited to a discussion of how to implement a change to nexus swap effect. I'm just a little concerned on two fronts, 1) alternative implementation suggestions other than your own should not be chilled, and 2) the discussion as to whether any change is a good idea in the first place should not be hidden away in a seemingly unrelated thread about gnome mages where it might get lost in the shuffle, or is this a game of three card monty?
                  “We're more of the love, blood, and rhetoric school. Well, we can do you blood and love without the rhetoric, and we can do you blood and rhetoric without the love, and we can do you all three concurrent or consecutive. But we can't give you love and rhetoric without the blood. Blood is compulsory. They're all blood, you see.”
                  ― Tom Stoppard, Rosencrantz and Guildenstern are Dead

                  Comment

                  • Derakon
                    Prophet
                    • Dec 2009
                    • 9022

                    #10
                    I don't object to Estie's idea, and in fact I rather like it conceptually. I was merely making an (evidently fruitless) attempt to keep discussion on-track, and also to avoid having a conversation that's relevant to game players (viz. what exactly nexus should do to characters) happen in a subforum that game players might not keep up on (the development forum).

                    Of course I could have just continued this discussion in the other thread (which is already hopelessly off-topic), but it seemed different enough to warrant a new thread.

                    I'm not at all trying to be a dictator here -- that's Nick's job. I'm just trying to get some change to happen. Because I know that once change does happen, it becomes a lot easier for people to concretely say what they do and don't like about some feature, instead of talking about vague hypotheticals. Hell, it's entirely possible that I'll hate the first pass at a "fix" even if it hewed closely to what I suggested. It's just super hard to know without actual playtesting.

                    Comment

                    • Derakon
                      Prophet
                      • Dec 2009
                      • 9022

                      #11
                      I went ahead and implemented my proposed nexus effect -- a temporary (timered) complete scrambling of the player's stats, unless they save, every time they get hit by nexus, in addition to the normal teleportation effects. I created a pull request, and you can see the specific change in my repository if you want to try to implement something similar (or completely different). Warning: may be buggy; my only testing was with a human warrior in the town.

                      Comment

                      • Nick
                        Vanilla maintainer
                        • Apr 2007
                        • 9637

                        #12
                        Originally posted by Derakon
                        I went ahead and implemented my proposed nexus effect -- a temporary (timered) complete scrambling of the player's stats, unless they save, every time they get hit by nexus, in addition to the normal teleportation effects. I created a pull request, and you can see the specific change in my repository if you want to try to implement something similar (or completely different). Warning: may be buggy; my only testing was with a human warrior in the town.
                        That looks good on the face of it. I have also had a bit of a rethink, and am probably coming around to preferring (possibly some modification of) your timed effect.

                        In fact (in a turn of events which is probably not altogether surprising given my past history) I've had a bit of a rethink about a number of the high elements, and will start a new thread about it.
                        One for the Dark Lord on his dark throne
                        In the Land of Mordor where the Shadows lie.

                        Comment

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