/* * 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. * * - Rings of flying, water breathing, fire resistance, and phasing on * the bottom four levels of the dungeon. */ void filldungeon(void) { int ln; LEVEL *lv; int x; int y; LOC *lc; int rings[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); rings[0] = OBJ_RING_OF_FLYING; rings[1] = OBJ_RING_OF_WATER_BREATHING; rings[2] = OBJ_RING_OF_FIRE_RESISTANCE; rings[3] = OBJ_RING_OF_PHASING; for (i=4-1;i>=0;i--) { j = rnd(4); t = rings[i]; rings[i] = rings[j]; rings[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(rings[i]),&lc->objs); } } }