[CF-Devel] button.c magic mouth suggestions

Kurt Fitzner kfitzner at excelcia.org
Fri Sep 6 13:10:10 CDT 2002


I'd like to make a suggestion for magic mouths.  After struggling in a map
editor for an hour on an esoteric problem, I finally realized that a slight
code change makes more sense.  The gist of the problem was that I needed a
magic mouth to be activated when a button was pushed, but not released.  I
can't think of why someone would want to 'connect' a magic mouth and then have
it respond to both push and release signals.  But, I'm sure that it happens,
so as not to break maps, I propose the following in button.c (line 75 or so)

    case SIGN:
      if (!tmp->stats.sp || ((tmp->stats.sp > 0) && op->value)
                       || ((tmp->stats.sp < 0) &&  !op->value))
          if (!tmp->stats.food || tmp->last_eat < tmp->stats.food) {
            (*info_map_func)(NDI_UNIQUE | NDI_NAVY,tmp->map,tmp->msg);
            if (tmp->stats.food) tmp->last_eat++;
          }
      break;

The effect is this:

If sp is set and greater than zero on a magic mouth, it will respond only to
button push events.  If sp is set and less than zero, it will respond only to
button release.  This has made it easier for me to make maps where I want
things like a message when a gate opens and a different message when a gate
closes.  I chose 'sp' since it's the same variable that reverses button
push/release events on buttons.  Since 'sp' hasn't done anything on magic
mouths before, it shouldn't break any maps.

I'm hoping this will make it into CVS, so I can release maps I'm making on my
server.

        Kurt.



    
    


More information about the crossfire mailing list