Re: [CODE] Remort

From: Daniel Koepke (dkoepke@CALIFORNIA.COM)
Date: 03/20/98


On Fri, 20 Mar 1998, Digital wrote:

->This works great if I set the class to warrior and the remort to Theif

Real quick, now: "i before e except after c, or if the word is weird."

->checks for get_remort(ch) != get_class(ch) && get_remort(ch) !=
->get_remort_two(ch)
->
->etc etc etc.
->I think it is in the check in spoec_procs.c but it still eludes me.

What exactly did you add to spec_procs.c?  My crystal ball is in the
shop right now (damn Motorola's).

Regardless, why would you add "get_class(ch) != get_remort(ch)"?  That
would seemingly only check if their class is not equal to their remort
class, not whether they can see the spells of that class...This, BTW,
seems more like a simple C/logic question (e.g., how to write 'if'
clauses) rather than a valid CircleMUD question.

Anyway, the original looks like,

  if (GET_LEVEL(ch) >= spell_info[i].min_level[(int) GET_CLASS(ch)]) {

the replacement might look like,

  #define CLASS(ch, i) \
   ((i) == 0 ? GET_CLASS(ch) : (i) == 1 ? GET_REMORT(ch) : \
    (i) == 2 ? GET_REMORT_TWO(ch) : GET_REMORT_THREE(ch))

  #define HAS_CLASS(ch, i) (CLASS((ch), (i)) != GET_CLASS(ch))

  #define CLASS_SKILL(ch, i, skl) \
   (HAS_CLASS((ch), (i)) && \
    30 >= spell_info[(skl)].min_level[CLASS((ch), (i))])

  if (GET_LEVEL(ch) >= spell_info[i].min_level[(int) GET_CLASS(ch)] ||
      CLASS_SKILL(ch, 1, i) || CLASS_SKILL(ch, 2, i) ||
      CLASS_SKILL(ch, 3, i)) {

...all of that ugly macro work, BTW, was due to the fact that people
are apparently allergic to arrays.  If you had used a class array, say
like,

  ubyte class[NUM_CLASSES];

in place of the current class variable, it might have taken a little
more time to create the basic remort system, but it would certainly be
better in the long run.

-dak


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



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