Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lighting code, question



[Brian Thomas]
> 	Of course, I am only guessing at the use of monster wisdom
> 	here. Could some knowledgable individual inform me how 
> 	the code goes about treating monster detection of players?
> 	Is mon->stats.Wis the radius of detection? How does stealth
> 	effect monster detection? I notice that Wis==0 monsters 
> 	still detect players! Does this mean that there is a 
> 	(default) minimum detection radius?

The code is as follows.  All monsters sleep when they are created,
but quite often check_wakeup() is called to check if someone
are close enough.  Close enough is within a square, the size of which
depends on the monster's wisdom (quicker than circle, since this is
called alot).  And as you can see below, a stealth-flag would halve
the size of the square.
A wisdom of 0 would mess this up, so hopefully there is another routine
somewhere that sets wisdom to some minimum value (dependent on monster
level) when monsters are created.

int check_wakeup(object *op) {
  objectlink *ol;
  for(ol=first_friendly_object;ol!=NULL;ol=ol->next)
    if(ol->ob->map==op->map&&
       (QUERY_FLAG(ol->ob,FLAG_STEALTH)?
                      (abs(ol->ob->x-op->x)<op->stats.Wis/2+1 &&
                       abs(ol->ob->y-op->y)<op->stats.Wis/2+1) :
                      (abs(ol->ob->x-op->x)<op->stats.Wis &&
                       abs(ol->ob->y-op->y)<op->stats.Wis)))
    {
      CLEAR_FLAG(op,FLAG_SLEEP);
      return 1;
    }
  return 0;
}

-Frank.