/* * Code to fill the dungeon with objects. */ #include "obj.h" #include "vars.h" #include "dice.h" #include "structs.h" #include "objtypes.h" #include "digdungeon.h" #include "filldungeon.h" /* * Fill the dungeon with objects. This means: * * - Blank maps. We create one per level of the main dungeon. With * the maps created in the player's inventory, this is enough to map * the whole dungeon. * * - The Crown of Yendor. * * - Scarabs of the elemental planes, on the bottom four levels of the * dungeon. */ void filldungeon(void) { int ln; LEVEL *lv; int x; int y; LOC *lc; int scarabs[4]; int i; int j; int t; for (ln=DUNGEON_LEVELS-1;ln>=0;ln--) { lv = &levels[ln]; do { x = 1 + rnd(LEV_X-2); y = 1 + rnd(LEV_Y-2); lc = &lv->cells[x][y]; } while ( (lc->type != LOC_CAVE) || (lc->cavetype != LOC_JUSTCAVE) || (lc->flags & (LF_SHOP|LF_VAULT)) ); add_obj_to_inv(obj_make(OBJ_MAP),&lc->objs); } avoidloc = gate_hell; lc = randomloc(&levels[L_HELL],&ckavoid,-1); add_obj_to_inv(obj_make(OBJ_CROWN),&lc->objs); scarabs[0] = OBJ_SCARAB_OF_EARTH; scarabs[1] = OBJ_SCARAB_OF_AIR; scarabs[2] = OBJ_SCARAB_OF_FIRE; scarabs[3] = OBJ_SCARAB_OF_WATER; for (i=4-1;i>=0;i--) { j = rnd(4); t = scarabs[i]; scarabs[i] = scarabs[j]; scarabs[j] = t; } for (i=4-1;i>=0;i--) { ln = DUNGEON_LEVELS - 1 - i; { lv = &levels[ln]; do { x = 1 + rnd(LEV_X-2); y = 1 + rnd(LEV_Y-2); lc = &lv->cells[x][y]; } while ( (lc->type != LOC_CAVE) || (lc->cavetype != LOC_JUSTCAVE) || (lc->flags & (LF_SHOP|LF_VAULT)) ); add_obj_to_inv(obj_make(scarabs[i]),&lc->objs); } } }