/* * The implementation of scarabs. * * This file knows there is always exactly one scarab of each type. * This simplifies monster flag setting in moved_scarab(), which would * otherwise have to consider the possibility that there is another * scarab of the same type in the from inventory. */ #include "obj.h" #include "util.h" #include "vars.h" #include "pline.h" #include "format.h" #include "structs.h" #include "objtypes.h" static unsigned int flagbit(int ot) { switch (ot) { case OBJ_SCARAB_OF_EARTH: return(MBF_PLANE_E); break; case OBJ_SCARAB_OF_AIR: return(MBF_PLANE_A); break; case OBJ_SCARAB_OF_FIRE: return(MBF_PLANE_F); break; case OBJ_SCARAB_OF_WATER: return(MBF_PLANE_W); break; } panic("impossible flagbit()"); } static int identified_scarab(INVOBJ *io) { return(!!(objtypes[io->v[0]->type].flags&OTF_KNOWN)); } static INVOBJ *identify_scarab(INVOBJ *io) { objtypes[io->v[0]->type].flags |= OTF_KNOWN; return(io); } static void moved_scarab(INVOBJ *io, INVENT *from, INVENT *to) { unsigned int flag; flag = flagbit(io->v[0]->type); if (from && (from->type == IT_MON)) from->u.m->baseflags &= ~flag; if (to && (to->type == IT_MON)) to->u.m->baseflags |= flag; } #define new_scarab noop_new #define old_scarab noop_old #define format_scarab std_format #define fmt_cond_scarab panic_fmt_cond #define fmt_spec_scarab panic_fmt_spec #define collapsible_scarab never_collapsible #define identical_scarab never_identical #define split_scarab std_split #define cursable_scarab 0 #define setcursed_scarab setcursed_uncursable OBJOPS objops_scarab = OBJOPS_INIT(scarab);