/* * Implementation of potions. */ #include #include "mon.h" #include "obj.h" #include "vars.h" #include "dice.h" #include "pline.h" #include "format.h" #include "structs.h" #include "objtypes.h" #include "mon-@-you.h" #include "obj-potion.h" /* * Quaff a potion. This is also responsible for destroying the potion, * when appropriate. */ void quaff_it(INVOBJ *io) { OBJ *o; if (io->n > 1) abort(); o = io->v[0]; if (objtypes[o->type].class != OC_POTION) { pline("Quaffing non-potion?"); impossible(); return; } switch (o->type) { case OBJ_POTION_OF_MEMORY: objtypes[o->type].flags |= OTF_KNOWN; pline("Your memory seems exceptionally sharp!"); extend_memory_mapping(1000); break; case OBJ_POTION_OF_HEALING: pline("You feel better!"); gainhp(you,roll("10000+d5000")); break; } inv_remove(io->inv,io); invobjfree(io); } /* * The new method for potions. */ static OBJ *new(int type __attribute__((__unused__)), OBJ *o) { o->private = 0; return(o); } /* * The old method for potions. */ static void old(OBJ *o __attribute__((__unused__))) { } /* * The identical method for potions. */ static int identical(OBJ *o1, OBJ *o2) { return(o1->type==o2->type); } /* * The collapsible method for potions. */ static int collapsible(OBJ *o1, OBJ *o2) { return(identical(o1,o2)); } /* * The identified method for potions. */ static int identified(INVOBJ *io) { return(!!(objtypes[io->v[0]->type].flags&OTF_KNOWN)); } /* * The identify method for potions. */ static INVOBJ *identify(INVOBJ *io) { objtypes[io->v[0]->type].flags |= OTF_KNOWN; return(io); } /* * The OBJOPS vector for potions. */ OBJOPS objops_potion = { &new, &old, &std_format, 0, 0, &collapsible, &identical, &std_split, &identified, &identify };