Re: [NEWBIE][CODE] magic leaf

From: Karl B Buchner (zerker@juno.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?

If you have dgScipts, you can add a new trigger type for
eaten objects.  There is a tutorial on this on the same site
as dgScripts and dgEvents (the plaintext one, not the flashy
black bground graphic frames one).

Otherwise, you can use spec_procs:
SPECIAL(hp_leaf){
        if(GET_CLASS(ch) == CLASS_XXX && cmd == /
             CMD_FOOD){
                send_to_char("You eat the leaf blah blah.", ch);
                GET_HIT(ch) = MIN(GET_HIT(ch) + 10, \
            GET_MAX_HIT(ch))
        }
}
where CLASS_XXX is the class that gets the gain
(I hope it's CLASS_DRUID cause druids are cool)
In structs.h #define CMD_FOOD -100 /*random        negative number for
id*/

in act.item.c, find
  if (subcmd == SCMD_EAT)
    extract_obj(food);
replace w/
if (subcmd == SCMD_EAT){
        if (GET_OBJ_SPEC(i) != NULL)
                GET_OBJ_SPEC(i) (ch, i, CMD_FOOD,  /
          NULL);
        extract_obj(food);
}

then in spec_assign at the top
SPECIAL(hp_leaf);
and near the bottom
ASSIGNOBJ(666, hp_leaf);
where 666 is the vnum of the leaf obj
Hope it works,

Blaize

*****************************
* I hate my email word processor *
*****************************


________________________________________________________________
GET INTERNET ACCESS FROM JUNO!
Juno offers FREE or PREMIUM Internet access for less!
Join Juno today!  For your FREE software, visit:
http://dl.www.juno.com/get/web/.

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