[CF-Devel] blinding code not working

Kurt Fitzner kfitzner at excelcia.org
Tue Sep 3 10:43:51 CDT 2002


I noticed, since my characters normally pick Valriel, that blinding didn't
tend to do much.  I've traced the issue down to a problem with operator
presedence.  Either my compiler doesn't do it right, or there was a subtle bug
in the program.  The following code is from monster.c check_wakeup()

  if (rv->distance < QUERY_FLAG(enemy, FLAG_STEALTH)?(radius/2)+1:radius) {
      CLEAR_FLAG(op,FLAG_SLEEP);
      return 1;
  }

On my version of GCC (I'm not an expert on precedence, so I don't know what
the ANSI spec says), the < operator takes precedence over the ? operator, so
the expression is reading:

if ( (rv->distance < QUERY_FLAG(enemy, FLAG_STEALTH)) ? (radius/2)+1:radius )

Which will always return true because radius will always be nonzero.

This makes it so that blinding never works.

Also, the code for blinding is set up so that it checks if the monster is
blind, but also if the monster can't see in the dark.  IF the monster can see
in the dark, then apparently blinding has no effect.  I'd suggest changing
this.  Elf and Dwarf players can see in the dark, but don't have blinding
protection.  If anything, seeing in the dark would make you more succeptable
to blinding.  My real issue, though, is that if you want to protect a monster
from blinding, making it see in the dark isn't the way to do it.  The way to
do it is resist_blind 100 in the archtype.  This would be for monsters that
don't depend on actual sight but, for example, smell.  There are a lot of see
in the dark monsters for whom it is not appropriate for them to be immune to
blinding.

        Kurt.


    
    


More information about the crossfire mailing list