Adding Oangband magic realms/spellbooks. What changes do I need to make?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Elfin Jedi
    Adept
    • Mar 2013
    • 102

    Originally posted by Derakon
    This is a bit of trickery to convert the data in list-summon-types.h into a convenient format (the summon_info array). list-summon-types.h has a bunch of entries of the form S(...) with 8 items in-between the parentheses; here we're defining a macro that says "Intepret ''S(...)'' as creating an 8-element array out of the contents of the parentheses, with a comma at the end." Since we're already in an array context (we're defining what summon_info is), these arrays become the contents of summon_info, making it into an array of arrays.
    Ok, thanks. That helps. What does the second section mean though? { #a, b, c, d, e, f, g, h }

    Comment

    • takkaria
      Veteran
      • Apr 2007
      • 1951

      Originally posted by Elfin Jedi
      Ok, thanks. That helps. What does the second section mean though? { #a, b, c, d, e, f, g, h }
      so a #define statement has two parts, the thing that is defined ('NUM_ELEMENTS' below) and what it is defined as (12 below):

      Code:
      #define NUM_ELEMENTS 12
      You can also create a #define statement that takes parameters, like:

      Code:
      #define ADD(a, b) (a + b)
      In this case, wherever 'ADD' appears with two parameters, they will be replced by a simple addition statement:

      Code:
      int num_items;
      int n = ADD(num_items, 7);
      will turn into

      Code:
      int num_items;
      int n = (num_items + 7);
      So
      Code:
      #define S(a, b, c, ...) { a, b, c, ... }
      means 'every time S(a, b, c...) is written, replace it with { a, b, c, ... }'.

      The hash ('#') before the 'a' is a special way of saying 'turn this parameter into a string'. So if you define a macro STRINGIFY like so:

      Code:
      #define STRINGIFY(a) #a
      Then writing STRINGIFY(TEST) is the same as writing:
      Code:
      "TEST"
      In the place you have found it, this trick is used so that the name of the element appears as a string so it can be used in the external text files.

      Hope that helps!
      takkaria whispers something about options. -more-

      Comment

      • Nick
        Vanilla maintainer
        • Apr 2007
        • 9637

        Originally posted by Elfin Jedi
        Also, realm.txt doesn't exist yet in 4.0.5. It would probably make things a lot easier, but I don't have it yet.
        Right, so you need to edit src/list-magic-realms.h.
        One for the Dark Lord on his dark throne
        In the Land of Mordor where the Shadows lie.

        Comment

        • Elfin Jedi
          Adept
          • Mar 2013
          • 102

          Originally posted by Nick
          Right, so you need to edit src/list-magic-realms.h.
          I did that a long time ago, but I'll check it. And edit what I find into this post.

          Edit: Ok, this is what it says:

          /**
          * \file list-magic-realms.h
          * \brief Spell realms
          */
          /* index spell stat verb spell noun book noun realm name*/
          REALM(NONE, STAT_STR, "", "", "", "")
          REALM(ARCANE, STAT_INT, "cast", "spell", "magic book", "arcane")
          REALM(PIOUS, STAT_WIS, "recite", "prayer", "prayer book", "divine")
          REALM(NATURE, STAT_WIS, "use", "druidic lore", "nature book", "nature")
          REALM(NECROMANCY, STAT_INT, "perform", "ritual", "necromancy book", "necromancy")

          Note: the realms work just fine. You can play an Assassin (though you will be casting rogue spells), or a Druid (casting mage spells), the names of the spellbooks just don't display in inventory and store lists. Hence the excitement about finding the 'show_inven' and related sections in ui-object.c and ui-store.c. The problem is if I start a Necromancer, for example, my starting inventory appears like this:

          a)
          b) a ration of food
          c) a scroll of word of recall

          So if you browse, inspect, or gain a spell from a it displays the list of spells just fine and casts them fine. It just won't display the book name. In inventory or store.
          Last edited by Elfin Jedi; April 17, 2017, 09:44.

          Comment

          • Pete Mack
            Prophet
            • Apr 2007
            • 6883

            Inventory has it's own interface with colors. I suspect it's printing black on black, or just giving up. What color did you specify in object_base.txt?

            Comment

            • Elfin Jedi
              Adept
              • Mar 2013
              • 102

              Originally posted by Pete Mack
              Inventory has it's own interface with colors. I suspect it's printing black on black, or just giving up. What color did you specify in object_base.txt?
              light purple for necromancy books, light green for nature books; changing prayer books to light blue. They do display properly on the ASCII map. (Light green ?, light purple ?.)

              Comment

              • Nick
                Vanilla maintainer
                • Apr 2007
                • 9637

                OK, I think you probably need to add some code to obj_desc_get_basename() in obj-desc.c - mimic what is done for TV_MAGIC_BOOK and TV_PRAYER_BOOK.
                One for the Dark Lord on his dark throne
                In the Land of Mordor where the Shadows lie.

                Comment

                • Pete Mack
                  Prophet
                  • Apr 2007
                  • 6883

                  Hmm. Looks like more data that belongs in object_base.txt
                  I'd forgotten all about that.
                  Edit:
                  The thing to do is to grep for cases for TV_MAGIC_BOOK and add new entries. This is not the only place, by a long shot. There are 10 places that need to be edited.
                  Last edited by Pete Mack; April 17, 2017, 17:34.

                  Comment

                  • Elfin Jedi
                    Adept
                    • Mar 2013
                    • 102

                    Originally posted by Nick
                    OK, I think you probably need to add some code to obj_desc_get_basename() in obj-desc.c - mimic what is done for TV_MAGIC_BOOK and TV_PRAYER_BOOK.
                    Originally posted by Pete Mack
                    The thing to do is to grep for cases for TV_MAGIC_BOOK and add new entries. This is not the only place, by a long shot. There are 10 places that need to be edited.
                    Already done, found this:

                    case TV_MAGIC_BOOK:
                    if (terse)
                    return "& Book~ #";
                    else
                    return "& Book~ of Magic Spells #";

                    case TV_PRAYER_BOOK:
                    if (terse)
                    return "& Book~ #";
                    else
                    return "& Holy Book~ of Prayers #";

                    case TV_NATURE_BOOK:
                    if (terse)
                    return "& Book~ #";
                    else
                    return "& Book~ of Nature Lore #";

                    case TV_NECROMANCY_BOOK:
                    if (terse)
                    return "& Book~ #";
                    else
                    return "& Book~ of Necromancy #";

                    I already searched for TV_MAGIC_BOOK, Book, and even TV a while ago and added more code for each of the results. Except for wiz-stats.c which only has TV_MAGIC_BOOK and has a note saying that since prayer books have the same probability only one of the two needs to be tracked. I don't know if there would be anything there that needs editing.

                    List of files changed: list-tvals.h, obj-desc.c, obj-randart.c, obj-tval.c, store.c, ui-knowledge.c, ui-options.c, wiz-spoil.c. Oh and list-magic-realms.h, object.txt, object_base.txt, store.txt, class.txt.
                    Last edited by Elfin Jedi; April 18, 2017, 05:39.

                    Comment

                    • Pete Mack
                      Prophet
                      • Apr 2007
                      • 6883

                      If the issue is still happening, I suspect you'd do better to fire up the debugger. The one in MSVC is pretty easy to use. Put a breakpoint in the appropriate subroutine.

                      Comment

                      • Nick
                        Vanilla maintainer
                        • Apr 2007
                        • 9637

                        Originally posted by Pete Mack
                        If the issue is still happening, I suspect you'd do better to fire up the debugger. The one in MSVC is pretty easy to use. Put a breakpoint in the appropriate subroutine.
                        Agreed - that's what I'd be doing now. In fact, it is what I'm doing for my tragically buggy pathfinding algorithm...
                        One for the Dark Lord on his dark throne
                        In the Land of Mordor where the Shadows lie.

                        Comment

                        • Pete Mack
                          Prophet
                          • Apr 2007
                          • 6883

                          Whoops, forgot which thread I was replying to. But even gdb is better than blind guesses

                          Comment

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