Re: [NEWBIE][CODE] magic leaf

From: Mike Breuer (mbreuer@new.rr.com)
Date: 01/09/02


> Is there any way that i can create an item, say a "magic leaf" that if
a
> certain class eats it, they gain 10hp, but if any other class eats it,
> they lose 10hp?

Yes, it's possible.  You probably want to make an object extra flag
like:

#define ITEM_MAGIC_FOOD   (1 << 17) /* Food gives extra energy */

Then when you create your item, make it food, but with the new flag set.
Also include ITEM_ANTI_<class> flags, and then modify ACMD(do_eat) in
act.item.c:

...
  gain_condition(ch, FULL, amount);

  if (GET_COND(ch, FULL) > 20)
    send_to_char("You are full.\r\n", ch);

+ if (OBJ_FLAGGED(food, ITEM_MAGIC_FOOD)) {
+    if (invalid_class(ch, food)) {
+       /* Code here to lose hp */
+    } else {
+       /* Code here to gain hp */
+    }
+  }

Turns out I'm a bit short on time just now, so if someone wants to fill
in the details, feel free.

Mike

--
   +---------------------------------------------------------------+
   | 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