Re: limiting the number of attackers

From: Patrick Dughi (dughi@imaxx.net)
Date: 05/14/00


> b> I would recommend not using a new variable to count up the attackers as that
> b> is just asking for trouble(as you've seen).
> b> Try simple for loop in the perform violence code that checks to make sure
> b> there are always 6 or less attackers. It won't use too much cpu time I don't
> b> think. This way you save on memory usage, have a smaller playerfile, and
> b> you're ALWAYS sure who's attacking whom and the exact count.
>
> wont I still need a variable to check that? besides, it wont work with skills
> like bash, kick and backstab. the playerfile is no issue here, I dont save the
> variable attackers. that would be quite pointless. memory is no big issue
> either, attackers is defined as a byte.

        Naw. No problem.

int num_of_attackers(struct char_data *ch) {
  struct char_data *i;
  int j=0;

  for (i = world[IN_ROOM(ch)].people; i; i = i->next_in_room) {
    if(FIGHTING(i)==ch) {
      j++;
    }
  }
  return j;
}
                                                PjD


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT