Roguelike development practice

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PaulBlay
    Knight
    • Jan 2009
    • 657

    Roguelike development practice

    I've attempted (and mostly failed ;-) to gain experience with C++ and the *band builds in various ways and here I go again.

    This time I'm going to keep it simple (if I can) - just produce code to add one feature to the latest Angband code.

    Code:
    ^T  Talk    Attempt to strike up conversation with an adjacent monster.
                (Monster will reply with single line based on its type)
    If I get it to work I'll take suggestions of appropriate lines for monsters in the game.
    Currently turning (Angband) Japanese.
  • pav
    Administrator
    • Apr 2007
    • 793

    #2
    Ogres need to have a line 'Heee did it.'
    See the elves and everything! http://angband.oook.cz

    Comment

    • bio_hazard
      Knight
      • Dec 2008
      • 649

      #3
      Originally posted by pav
      Ogres need to have a line 'Heee did it.'
      "That's Brimstone."

      Comment

      • PaulBlay
        Knight
        • Jan 2009
        • 657

        #4
        Well, I got close this time, but it looks like no cigar for me.

        I thought I'd added everything I needed for an extra parameter in the monster text, but now it is no longer recognizing the D: line! (Which I don't think I've touched)

        Error at line 121 of 'monster.txt'.
        Record 1 contains a 'undefined directive' error.
        Parsing 'D:He looks squalid and thoroughly revolting.'.


        Code:
        	/* Process 'D' for "Description" */
        	if (buf[0] == 'D')
        	{
        		/* Store the text */
        		if (!add_text(&(r_ptr->text), head, buf+2))
        			return (PARSE_ERROR_OUT_OF_MEMORY);
        	}
        
        	/* Process 'T' for "Talk" */ 
        	if (buf[0] == 'T')
        	{
        		/* Store the line of speech */
        		if (!add_text(&(r_ptr->talk), head, buf+2)) 
        			return (PARSE_ERROR_OUT_OF_MEMORY);
        	}
        Oh well, better luck next scheme.
        Currently turning (Angband) Japanese.

        Comment

        • takkaria
          Veteran
          • Apr 2007
          • 1951

          #5
          Originally posted by PaulBlay
          Well, I got close this time, but it looks like no cigar for me.

          I thought I'd added everything I needed for an extra parameter in the monster text, but now it is no longer recognizing the D: line! (Which I don't think I've touched)

          Error at line 121 of 'monster.txt'.
          Record 1 contains a 'undefined directive' error.
          Parsing 'D:He looks squalid and thoroughly revolting.'.


          Code:
          	/* Process 'D' for "Description" */
          	if (buf[0] == 'D')
          	{
          		/* Store the text */
          		if (!add_text(&(r_ptr->text), head, buf+2))
          			return (PARSE_ERROR_OUT_OF_MEMORY);
          	}
          
          	/* Process 'T' for "Talk" */ 
          	if (buf[0] == 'T')
          	{
          		/* Store the line of speech */
          		if (!add_text(&(r_ptr->talk), head, buf+2)) 
          			return (PARSE_ERROR_OUT_OF_MEMORY);
          	}
          Oh well, better luck next scheme.
          That second 'if' should be 'else if'. Follow through the code and you'll see why.
          takkaria whispers something about options. -more-

          Comment

          • PaulBlay
            Knight
            • Jan 2009
            • 657

            #6
            Originally posted by takkaria
            That second 'if' should be 'else if'. Follow through the code and you'll see why.
            That improved things - although it looks like I broke it elsewhere.

            Obviously I need more practice.
            Currently turning (Angband) Japanese.

            Comment

            • Pete Mack
              Prophet
              • Apr 2007
              • 6883

              #7
              @paul --
              Do you have a working debugger? I assume from what you are saying, that you are using MSDEV. Even the free version has a line-by-line stepping debugger/IDE. You can put "breakpoints" in and stop the program at any point, then step from there. It can be very useful. (It can also be a huge time-waster.)

              Comment

              • PaulBlay
                Knight
                • Jan 2009
                • 657

                #8
                Originally posted by Pete Mack
                @paul --
                Do you have a working debugger?
                Presumably.

                I haven't actually tried it yet though. Basically it's been decades since I sort-of-knew what I was doing with this stuff and I'm very slowly getting back up to speed.

                I assume from what you are saying, that you are using MSDEV. Even the free version has a line-by-line stepping debugger/IDE. You can put "breakpoints" in and stop the program at any point, then step from there. It can be very useful. (It can also be a huge time-waster.)
                I'm familiar with breakpoints and stepping from Visual Basic. I'm not sure whether I've ever tried it with a C++ debugger.

                What I did so far required changes to:
                cmd0.c
                cmds.h
                cmd3.c
                monster.txt
                init1.c
                init2.c
                init.h
                and
                monster/types.h

                Everything seems to be spread out to heck and gone.
                Currently turning (Angband) Japanese.

                Comment

                • Pete Mack
                  Prophet
                  • Apr 2007
                  • 6883

                  #9
                  Debugging with a C compiler isn't any harder. The tough part is setting up the compile environment from scratch :/

                  And your changes aren't really spread out "to heck and gone." I could have told you what files would need modifying.

                  For the record:

                  Adding a new command:
                  cmds.h to add the new command declaration
                  * [ED: this is broken, since some of them are also in externs.h]
                  cmd0.c, to add a new command to the command m enus & list.
                  * [pre-3.0.8: was dungeon.c, and was that ever a lousy place!]

                  cmd[1-3].c to add the new command implementation, depending on what type it is. (This depends on which menu in cmd0.c)
                  (cmd4.c is for meta-commands like options and knowledge)


                  To change the behavior of individual monsters: (NOT by monster "genus", like 'T', 'o', 'D', etc.)

                  monster.txt: to add the new flag/descriptor to the individual monster data field.
                  monster/types.h to add the new field in the basic monster type.
                  init1.c to add to the tokens (string constants) tables for initialization.
                  Also, the spoken strings may go here too.
                  init2.c to add to the monster.txt parser.
                  init.h to add the appropriate #defines for token_ids.

                  Comment

                  • PaulBlay
                    Knight
                    • Jan 2009
                    • 657

                    #10
                    Originally posted by Pete Mack
                    And your changes aren't really spread out "to heck and gone." I could have told you what files would need modifying.
                    In other words somebody who already knows where to go can find stuff. For somebody coming to the whole thing from scratch working out which bit does what is rather more of an uphill struggle.
                    Last edited by PaulBlay; February 19, 2009, 20:05.
                    Currently turning (Angband) Japanese.

                    Comment

                    • CunningGabe
                      Swordsman
                      • Feb 2008
                      • 250

                      #11
                      It might be worthwhile, to help patchers/bugfixers/variant developers, to have some high-level descriptions of how to add various things (like what Pete has described) and put them in a help file somewhere. Similarly, the edit files could use some more detailed help -- such as explaining the monster flags. I'll volunteer to write some help for monsters.txt, for starters; perhaps we could include it in the edit directory, or in the help directory with the edit file mentioning it.

                      It would also be nice if cmd0-6 had nicer names. Takkaria's reorganization efforts so far have been great (e.g. separating out the monster-related files into their own directory, and renaming many files to be more descriptive), and a little further renaming and reorganizing would be helpful.

                      Comment

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