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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • takkaria
    Veteran
    • Apr 2007
    • 1951

    #76
    Some notes in line with the code

    Code:
    	/* Determine if the monster resisted or not, if appropriate */
    	if (check_resist)
    		resisted = mon_resist_effect(mon, ef_idx, timer, flag);
    	
    [B]	// This line should be in mon_resist_effect(), not here.  If you put it here
    	// then the invisible timed effect will never happen, because...
    [/B]	if (ef_idx == MON_TMD_INVISIBLE) return (false);
    
    	if (resisted)
    		m_note = MON_MSG_UNAFFECTED;
    	else
    [B]		// this line is the one where the timer is set ("set the flag to the new timd value"
    [/B]		mon->m_timed[ef_idx] = timer;
    
    	if (player->upkeep->health_who == mon)
    		player->upkeep->redraw |= (PR_HEALTH);
    	
    	if (ef_idx == MON_TMD_INVISIBLE) {
    		update_mon(mon, cave, false);
    	}
    Originally posted by Elfin Jedi
    I really don't know how to do this though:

    Set the flag to the new timed value
    call the function
    return.
    You don't have to do this - it's all already done for you when you use the already existing MON_INC_TIMED effect.
    takkaria whispers something about options. -more-

    Comment

    • Elfin Jedi
      Adept
      • Mar 2013
      • 102

      #77
      Ok,

      static bool mon_resist_effect(const struct monster *mon, int ef_idx, int timer, u16b flag)
      {
      struct mon_timed_effect *effect;
      int resist_chance;
      struct monster_lore *lore;

      assert(ef_idx >= 0 && ef_idx < MON_TMD_MAX);
      assert(mon);

      effect = &effects[ef_idx];
      lore = get_lore(mon->race);

      /* Hasting never fails */
      if (ef_idx == MON_TMD_FAST) return (FALSE);

      /* Becoming invisible never fails */
      if (ef_idx == MON_TMD_INVISIBLE) return (false);

      /* Some effects are marked to never fail */
      if (flag & MON_TMD_FLG_NOFAIL) return (FALSE);



      Edit: oh does false need to be in all caps?

      Comment

      • Elfin Jedi
        Adept
        • Mar 2013
        • 102

        #78
        Yay! Memory mosses can become invisible now.

        However, detect monsters still detects them. I notice there are still parentheses in between the b and c conditionals in this statement:

        /* Exclude monsters that are invisible or out of range */
        if (!(rf_has(mon->race->flags, RF_INVISIBLE ||
        mon->m_timed[MON_TMD_INVISIBLE]) ||
        mflag_has(mon->mflag, MFLAG_UNAWARE)))
        {

        Do they need to be removed, or are they necessary because of the switch to mflag_has?

        Also, when they turn invisible it gives the message:vis from monster-spell.txt, but not the MON_MSG(INVISIBLE, "disappears!")
        from list-mon-message.h.

        And I never saw the Memory moss become visible again, though that might just be because I didn't playtest very long. The mon-message from becoming visible is here: MON_MSG(NOT_INVISIBLE, "appears out of nowhere!")

        Edit: I also still have parentheses in between conditionals in mon-util.c, right here:
        /* Handle "invisible" monsters */
        if (rf_has(mon->race->flags, RF_INVISIBLE) || mon->m_timed[MON_TMD_INVISIBLE]) {
        /* See invisible */
        if (player_of_has(player, OF_SEE_INVIS))

        Comment

        • takkaria
          Veteran
          • Apr 2007
          • 1951

          #79
          Originally posted by Elfin Jedi
          Yay! Memory mosses can become invisible now.

          However, detect monsters still detects them. I notice there are still parentheses in between the b and c conditionals in this statement:

          /* Exclude monsters that are invisible or out of range */
          if (!(rf_has(mon->race->flags, RF_INVISIBLE ||
          mon->m_timed[MON_TMD_INVISIBLE]) ||
          mflag_has(mon->mflag, MFLAG_UNAWARE)))
          {

          Do they need to be removed, or are they necessary because of the switch to mflag_has?
          If you notice again you've written the OR statement as the second parameter of rf_has, instead of being separate. It can be hard to see at first but it gets more obvious as you code more. Fixing this will probably fix monster detection.

          I would have to look at the code to try and work out why messages might not be being displayed, it's not immediately obvious to me right now, or from looking at what's on github right now.
          takkaria whispers something about options. -more-

          Comment

          • Elfin Jedi
            Adept
            • Mar 2013
            • 102

            #80
            I haven't uploaded the changes to github yet. I can do that.

            Comment

            • Elfin Jedi
              Adept
              • Mar 2013
              • 102

              #81
              Agh, how do I write it as a separate parameter? I tried this:

              if (!(rf_has(mon->race->flags, RF_INVISIBLE) ||
              mon->m_timed[MON_TMD_INVISIBLE]) ||
              mflag_has(mon->mflag, MFLAG_UNAWARE))

              But I think that is what I did the first time, and it results in the monster not redrawing, but it does give the second part of the message ("the Memory moss disappears!").

              Comment

              • Elfin Jedi
                Adept
                • Mar 2013
                • 102

                #82
                Added monster race flags: insect, plant, and humanoid (including humans) to list-mon-race-flags.h and monster-base.txt. Tested.

                Added slay/*slay* insect, slay/*slay* plant, and slay/*slay* humanoid to ego_item.txt. Tested.

                Added the slays to obj-slays.c so that they can be used by randarts. Tested.

                Was great fun. (I needed a break.)
                Last edited by Elfin Jedi; July 17, 2016, 09:18.

                Comment

                • Pete Mack
                  Prophet
                  • Apr 2007
                  • 6883

                  #83
                  There is no reason for slays of low-HP or never-move classes like insects and plants. Slay-human has limited use as well--Slay Dragon is simply so much more useful, I would never choose the former. The result of too much slay dilution will be an excess of junk, and yet more weak randart weapons with lots of meaningless flags. This has been tried before. It is not generally successful.

                  Edit: I will further not that with only a few exceptions, there already are effective slays for humans: Acid and lightning brands. For plants, fire brand makes more sense as a slay. If you want to make the equivalent of a *slay*, make plants fire-vulnerable instead. I do like the idea of new monster types much more than new slays just for the sake of new slays.
                  Last edited by Pete Mack; July 17, 2016, 18:42.

                  Comment

                  • Elfin Jedi
                    Adept
                    • Mar 2013
                    • 102

                    #84
                    Ok, thanks for the feedback. I think I will leave them in for now. If I find them annoying later I can always remove them.

                    Comment

                    • Elfin Jedi
                      Adept
                      • Mar 2013
                      • 102

                      #85
                      I tried this:

                      /* Exclude monsters that are invisible or mimics */
                      if (!(rf_has(mon->race->flags, RF_INVISIBLE)) ||
                      mon->m_timed[MON_TMD_INVISIBLE] ||
                      mflag_has(mon->mflag, MFLAG_UNAWARE))

                      The Memory moss vanished properly, but didn't give the second part of the message, got detected by detect monster, and then the game crashed a few moves later.

                      Assuming I am understanding correctly, Pete Mack says I need to get rid of the parentheses between conditionals, and takkaria says I need to separate the b conditional from "rf_has". How do I do both? Is there an easy solution I am missing?

                      I am wondering if I should change this to what has worked best so far and then work on something else until I feel ready to tackle this again.

                      Comment

                      • takkaria
                        Veteran
                        • Apr 2007
                        • 1951

                        #86
                        Originally posted by Elfin Jedi
                        I tried this:

                        /* Exclude monsters that are invisible or mimics */
                        if (!(rf_has(mon->race->flags, RF_INVISIBLE)) ||
                        mon->m_timed[MON_TMD_INVISIBLE] ||
                        mflag_has(mon->mflag, MFLAG_UNAWARE))

                        The Memory moss vanished properly, but didn't give the second part of the message, got detected by detect monster, and then the game crashed a few moves later.

                        Assuming I am understanding correctly, Pete Mack says I need to get rid of the parentheses between conditionals, and takkaria says I need to separate the b conditional from "rf_has". How do I do both? Is there an easy solution I am missing?
                        Is your work up to date on GitHub? If so I will try and have a look in the next few days. Seems like we might be talking at cross-purposes here and it seems the thing that I've suggested hasn't worked.

                        I think Pete was just saying, be careful about where your parentheses go. !a || b || c is different to !(a || b || c) which is different from, e.g. !(a || b) || c. What you've written above is in the form (!a) || b || c, which reads as: if the monster doesn't have the permanent invisibility flag, or if it does have the timed effect, or if the monster is marked 'unaware'. This almost certainly isn't the logic you want. Does that make sense?

                        I am wondering if I should change this to what has worked best so far and then work on something else until I feel ready to tackle this again.
                        This sounds sensible! You might also find it useful to read some kind of introductory guide to C to get more of a feel for the language, just a little bit each day. Reading learning materials is boring but probably worth it in the long run.
                        takkaria whispers something about options. -more-

                        Comment

                        • Elfin Jedi
                          Adept
                          • Mar 2013
                          • 102

                          #87
                          Yes, it makes sense. Really fast before I update github, what does this do?

                          /* Include monsters that are visible and not mimics */
                          if (!(rf_has(mon->race->flags, RF_INVISIBLE)) && !(mon->m_timed[MON_TMD_INVISIBLE])
                          && !(mflag_has(mon->mflag, MFLAG_UNAWARE)));
                          {

                          Has the same effect (monster vanishes without complete message, gets detected, and crashes a few moves later (perhaps when it should appear again?)...

                          I found this interactive tutorial on the c programming language: http://www.learn-c.org/ it looks more my learning style, though it does say it is still under construction. It would probably be a good place to start though.

                          Comment

                          • Pete Mack
                            Prophet
                            • Apr 2007
                            • 6883

                            #88
                            The code snippet looks OK. The crash is almost certainly unrelated. It may be time to try the debugger. At the very least, try a debug build (-g instead of -O2 in the makefile, and run under the debugger. That will tell you what line is crashing.

                            Comment

                            • Elfin Jedi
                              Adept
                              • Mar 2013
                              • 102

                              #89
                              Ok, what does the debugger do? When I tried it a while back it just launched the game. I didn't edit the makefile that time though.

                              Comment

                              • Nick
                                Vanilla maintainer
                                • Apr 2007
                                • 9647

                                #90
                                Originally posted by Elfin Jedi
                                Ok, what does the debugger do? When I tried it a while back it just launched the game. I didn't edit the makefile that time though.
                                If you run the game in the debugger, you can do things like see where the program was when it crashed, make the program stop when it gets to a particular line of code, and check values of variables.
                                One for the Dark Lord on his dark throne
                                In the Land of Mordor where the Shadows lie.

                                Comment

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