Re: Charisma again :)

From: Lincoln Chan (linc@CSUA.Berkeley.EDU)
Date: 07/19/95


Data: Here's a patch to your non aggressives scanning the room.  It's not
      a very good idea to put this code into your mud because then, all
      mobs are essentially aggressive.

/* Aggressive Mobs */
if (MOB_FLAGGED(ch, MOB_AGGRESSIVE | MOB_AGGR_TO_ALIGN)) {
  found = FALSE;
  for (vict = world[ch->in_room].people; vict && !found;
       vict = vict->next_in_room) {
    if (IS_NPC(vict) || !CAN_SEE(ch, vict) ||
        PRF_FLAGGED(vict, PRF_NOHASSLE))
      continue;
    if (MOB_FLAGGED(ch, MOB_WIMPY) && AWAKE(vict))
      continue;
    if (!MOB_FLAGGED(ch, MOB_AGGR_TO_ALIGN) ||
        (MOB_FLAGGED(ch, MOB_AGGR_EVIL) && IS_EVIL(vict)) ||
        (MOB_FLAGGED(ch, MOB_AGGR_NEUTRAL) && IS_NEUTRAL(vict)) ||
        (MOB_FLAGGED(ch, MOB_AGGR_GOOD) && IS_GOOD(vict))) {
      hit(ch, vict, TYPE_UNDEFINED);
      found = TRUE;
    }
  }
} else {
  act("$n looks around suspiciously.", FALSE, ch, 0, 0, TO_ROOM);
  for (vict = world[ch->in_room].people; vict && !found;
       vict = vict->next_in_room) {
    if (number(0, 20) >= GET_CHA(vict)) {
      hit(ch, victim, TYPE_UNDEFINED);
      found = TRUE;
    }
  }
}

The error you had before was because vict was never defined (or at least
not yet.)  All I did was reorganize your code to add a for(vict) loop to
it.  This defines the vict as people in the room, one at a time.
Don't worry, the code prevents the mobile from hitting everyone in the
room; it stops checking after it hits the first unfortunately victim.

linc aka Aladdin of Eternity DikuMUD

BTW: mailing data@iii.net got my mail bounced.  Wassup wit dat?



This archive was generated by hypermail 2b30 : 12/07/00 PST