Re: Affections Code

From: Welcor (welcor@dune.net)
Date: 03/01/02


From: "Bejhan Jetha" <nhlstar6@YAHOO.COM>
> Okay I feel pretty dumb for asking this because I'm pretty sure this is an
> obvious one but I've never been one of those people who are good with
> declaring. I tried to write an affect code which I did if AFF for every
> spell or skill which affects you which shows a different message. What I
> can't do is duration. I've looked at do stat and tried how it is and I
> can't find how it's declared in there either so here's my code:
>
> ACMD(do_affect)
> {
> bool aff;
> aff = TRUE;
>
> sprintf(buf, "&WAffection          Definition
> Duration&n\r\n"
>
"&R------------------------------------------------------------
> ------&n\r\n");
>     if (affected_by_spell(ch, SPELL_ARMOR))
>  strcat(buf, "&GArmor             Affects AC by -20
> %3d&n\r\n", af->duration);
>     if (affected_by_spell(ch, SPELL_BLESS))
>  strcat(buf, "&GBless             Affects hitroll by +2
> %3d&n\r\n");
<snip>
> send_to_char(buf, ch);
> }
>
> I only tried the duration on one and what I used was "af->duration" and I
> get the error message "act.informative.c:2098: `af' undeclared (first use
> in this function)" so I don't know how to declare this. I also tried
> "af->duration" and I get the error message "act.informative.c:2102:
invalid
> type argument of `->'".
>
> Well anyways I'll ask you not to flame me if this is as dumb as i assume
it
> to be.

Actually it's not.

You just need to loop through the chars affects manually, instead of having
affected_by_spell doing it for you:

ACMD(do_affs) {
  struct affected_type *aff;

  if (ch->affected) {
     sprintf(buf, "Your affections:\r\n");
     for (aff = ch->affected; aff; aff = aff->next) {
       if (aff->next && aff->next->type==aff->type)
         continue;
       if (aff->type = AFF_BLIND)
           sprintf(buf + strlen(buf),
           "Blindness    Impairs vision  %3d\r\n", aff->duration);
       /* add more spells here. */

     }
  } else
    sprintf(buf, "You're currently totally unaffected!\r\n");

  send_to_char(buf, ch);
}

Mailer Code warning..

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