/* * Implementation of potions. */ #include #include "mon.h" #include "obj.h" #include "vars.h" #include "dice.h" #include "pline.h" #include "speed.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; case OBJ_POTION_OF_SPEED: pline("You seem to be moving faster!"); haste_mon(you,roll("20+d10")); break; } inv_remove(io->inv,io); invobjfree(io); } /* * The identical method for potions. */ static int identical_potion(OBJ *o1, OBJ *o2) { return(o1->type==o2->type); } /* * The collapsible method for potions. */ static int collapsible_potion(OBJ *o1, OBJ *o2) { return(identical_potion(o1,o2)); } /* * The identified method for potions. */ static int identified_potion(INVOBJ *io) { return(!!(objtypes[io->v[0]->type].flags&OTF_KNOWN)); } /* * The identify method for potions. */ static INVOBJ *identify_potion(INVOBJ *io) { objtypes[io->v[0]->type].flags |= OTF_KNOWN; return(io); } /* * The OBJOPS vector for potions. */ #define new_potion noop_new #define old_potion noop_old #define format_potion std_format #define fmt_cond_potion panic_fmt_cond #define fmt_spec_potion panic_fmt_spec #define split_potion std_split #define moved_potion noop_moved OBJOPS objops_potion = OBJOPS_INIT(potion);