#include "obj.h" #include "vars.h" #include "pline.h" #include "format.h" #include "structs.h" #include "display.h" #include "obj-map.h" #include "disputil.h" #include "objtypes.h" #include "mon-@-you.h" #include "obj-scroll.h" static void scroll_of_identify(void) { int dohere; int doinv; INVOBJ *io; objtypes[OBJ_SCROLL_OF_IDENTIFY].flags |= OTF_KNOWN; pline("This is a scroll of identify!"); dohere = 0; doinv = 0; if (you->loc->objs.inv) { if (you->invent.inv) { if (inv_scan(&you->invent,&invobj_unidentified)) { doinv = 1; } if (you->loc->objs.inv->link) { if (inv_scan(&you->loc->objs,&invobj_unidentified)) { dohere = 1; pline("There are objects here"); } else { pline("There are objects here, but they are all identified already"); } } else { if (inv_scan(&you->loc->objs,&invobj_unidentified)) { dohere = 1; pline("There is an object here"); } else { pline("There is an object here, but it is identified already"); } } if (!dohere && !doinv) { pline("What a pity everything in your inventory is also identified!"); } } else { if (you->loc->objs.inv->link) { pline("You are empty-handed, but there are objects here"); if (inv_scan(&you->loc->objs,&invobj_unidentified)) { dohere = 1; } else { pline("What a pity they are all identified already!"); } } else { pline("You are empty-handed, but there is an object here"); if (inv_scan(&you->loc->objs,&invobj_unidentified)) { dohere = 1; } else { pline("What a pity it is identified already!"); } } } } else { if (you->invent.inv) { if (inv_scan(&you->invent,&invobj_unidentified)) { doinv = 1; } else { pline("What a pity everything in your inventory is already identified!"); } } else { pline("What a pity you're empty-handed!"); } } if (dohere || doinv) showmsgbuf(1); if (dohere && doinv) { do { int i; INVENT *inv; i = choose_one("Which location do you want to identify an object from?","here",1,"your inventory",2,(char *)0,-1); if (i < 0) { if (confirm("Don't identify anything?")) { io = 0; break; } continue; } switch (i) { case 1: inv = &you->loc->objs; break; case 2: inv = &you->invent; break; default: panic("impossible inventory list"); } io = pick_inventory(inv,"Identify what (ESC for more choices)? ",&invobj_unidentified); if (io) break; } while (1); } else { do { io = pick_inventory(dohere?&you->loc->objs:&you->invent,"Identify what? ",&invobj_unidentified); } while (!io && !confirm("Don't identify anything?")); } if (io) identify_it(io,1); } static void scroll_of_magic_mapping(INVOBJ *io) { objtypes[OBJ_SCROLL_OF_MAGIC_MAPPING].flags |= OTF_KNOWN; pline("This is a scroll of magic mapping!"); showmsgbuf(1); if (map && confirm("Do you want to just update the map you're using?")) { inv_remove(io->inv,io); invobjfree(io); map_complete(map,you->loc->on); } else { objfree(io->v[0]); io->v[0] = obj_make(OBJ_MAP); map_complete(io->v[0],you->loc->on); if (confirm("Use this map for this level?")) map_replace_current(io->v[0]); pline_invobj(io); } cleardisp(); drawmapped(you->loc->on); } static void scroll_of_phasing(void) { pline("You are out of phase!"); } void read_it(INVOBJ *io) { OBJ *o; int autodestroy; if (io->dispn > 1) panic("read_it: >1 object"); o = io->v[0]; if (objtypes[o->type].class != OC_SCROLL) { pline("Reading non-scroll?"); impossible(); return; } autodestroy = 1; switch (o->type) { case OBJ_SCROLL_OF_MAGIC_MAPPING: scroll_of_magic_mapping(io); autodestroy = 0; break; case OBJ_SCROLL_OF_IDENTIFY: inv_remove(io->inv,io); invobjfree(io); scroll_of_identify(); autodestroy = 0; break; case OBJ_SCROLL_OF_PHASING: scroll_of_phasing(); break; } } static OBJ *new(int type __attribute__((__unused__)), OBJ *o) { o->private = 0; return(o); } static void old(OBJ *o __attribute__((__unused__))) { } static int identical(OBJ *o1, OBJ *o2) { return(o1->type==o2->type); } static int collapsible(OBJ *o1, OBJ *o2) { return(identical(o1,o2)); } static int identified(INVOBJ *io) { return(!!(objtypes[io->v[0]->type].flags&OTF_KNOWN)); } static INVOBJ *identify(INVOBJ *io) { objtypes[io->v[0]->type].flags |= OTF_KNOWN; return(io); } OBJOPS objops_scroll = { &new, &old, &std_format, 0, 0, &collapsible, &identical, &std_split, &identified, &identify };