From: "Guy SJS" <guysjs@BOX.SK>
> 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?
>
I figure you wish this to be generic. I mean, it's a quick change to do_eat
[1] (if obj==leaf : if eater==magicuser AARGGHH else if eater==warrior SMILE)
Doing it so it's (easily) expandable takes a little more (in/around do_eat):
struct spec_objs_struct {
obj_vnum vnum;
int pos_effect;
int neg_effect;
int pos_class;
int neg_class;
} spec_objs[] = {
{ 3001, 10, -10, CLASS_THIEF | CLASS_WARRIOR, CLASS_MAGIC_USER | CLASS_CLERIC },
{ 3002, 15, -50, CLASS_MAGIC_USER | CLASS_CLERIC, CLASS_THIEF},
/*etc*/
{ -1, 0, 0, 0, 0 }
};
for (int i=0;spec_objs[i].vnum!=-1;i++) {
if (GET_OBJ_VNUM(obj)==spec_objs[i].vnum) { /* check the obj */
if (GET_CLASS(ch) & spec_objs[i].pos_class) /* check for postive effect */
GET_HIT(ch) = MIN(GET_MAX_HIT(ch), GET_HIT(ch) + spec_objs[i].pos_effect);
if (GET_CLASS(ch) & spec_objs[i].neg_class) /* check for negative effect */
GET_HIT(ch) = MIN(GET_MAX_HIT(ch), GET_HIT(ch) + spec_objs[i].neg_effect);
}
}
This is all mailer code, and you might want to send some messages to the eater
as well.
> Sorry in advance if this is really stupid.
>
Not at all - enjoyed the mindtraining. :)
Welcor
[1] If you actually try to use this line in code, you need a C tutorial :P
--
+---------------------------------------------------------------+
| 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