Re: [code] GET_CLASS for multiclassing...

From: Thomas Arp (t_arp@stofanet.dk)
Date: 11/09/02


From: "peter dahlgren" <peter_dahlgren2002@YAHOO.SE>

> firstly, so all of you have an image of what i made...
>
> GET_CLASS(ch) is changed into GET_CLASS(ch, i)
>
> where i is the position of a class in the array for the multiclassing...
>
<snip>
> what do i do when it checks if ch has the same class as vict?

Loop through ch's classes. For each, find out if vict has one of them.
See below for an implementation example.

> like in say_spell where it displays the spell language if ch and
> vict has the same class?
>
First, decide which classes have the spell. After all, if a
Mage/cleric casts the cleric spell 'bless', a nearby mage/thief
shouldn't understand it.
Then check if the victim is any one of the allowed classes.
I'd suggest using the function you describe below.

> i looked in db.c, but the line GET_CLASS(mob_proto + i) = 0;
>
> i'm not sure what it looks for here... should i change it into
> GET_CLASS(mob_proto + i, 0) = 0; ?

Loop it. All mob_proto classes should be 0;

  int j;
  for (j = 0; j < NUM_MULTICLASSES; j++)
    GET_CLASS(mob_proto + i, j) = 0;

> and the st->chclass = GET_CCLASS(ch);
>
> should i change it to st->chclass[i] = GET_CLASS(ch, i); ?
> or should i loop through it and make it store all values?
>
Again, loop it.
>
> i have created some functions to search for the current position,
> eg the one you are leveling on at the moment... and to search for
> a specific class in the array, that returns the position number...

This is nice. The search for specific class one is the one I meant
above. I guess you have something along the lines of

int is_class(struct char_data *ch, int chclass)
{
  int i;

  for (i = 0; i < NUM_MULTICLASSES; i++)
    if (GET_CLASS(ch, i) == chclass)
      return i;

  return -1;
}

and then simple checks like this

for (i = 0; i < NUM_MULTICLASSES; i++) {
  if (GET_CLASS(ch, i) == 0)
    continue;
  if (is_class(vict, GET_CLASS(ch, i)) != -1)
    /* ch and vict has at least one common class */
    do_stuff(tm)
}

Welcor

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT