public const int MAXTRIES = 10; /* max number of tries to put down a monster */ // Add a treasure room public static void treas_room() { int nm; THING tp; room rp; int spots, num_monst; var mp = new Coord(); rp = rooms[rnd_room()]; spots = (rp.Size.y - 2) * (rp.Size.x - 2) - MINTREAS; if (spots > (MAXTREAS - MINTREAS)) { spots = (MAXTREAS - MINTREAS); } num_monst = nm = R14.rnd(spots) + MINTREAS; while (nm-- != 0) { find_floor(rp, out mp, 2 * MAXTRIES, false); tp = R14.GetNewRandomThing(); tp.ItemPos = mp; R14.attach(ref Dungeon.ItemList, tp); Dungeon.SetCharAt(mp.y, mp.x, (char)tp.ItemType); } //fill up room with monsters from the next level down if ((nm = R14.rnd(spots) + MINTREAS) < num_monst + 2) { nm = num_monst + 2; } spots = (rp.Size.y - 2) * (rp.Size.x - 2); if (nm > spots) { nm = spots; } Agent.LevelOfMap++; while (nm-- != 0) { spots = 0; if (find_floor(rp, out mp, MAXTRIES, true)) { tp = new THING(); R14.new_monster(tp, R14.randmonster(false), mp); tp.t_flags |= Mob.ISMEAN; /* no sloughers in THIS room */ R14.give_pack(tp); } } Agent.LevelOfMap--; }
// populate map with items public static void put_things() { int i; THING obj; /* Once you have found the amulet, the only way to get new stuff is go down into the dungeon */ if (Agent.amulet && Agent.LevelOfMap < Agent.dyn___max_level) { return; } /* check for treasure rooms, and if so, put it in */ if (R14.rnd(TREAS_ROOM) == 0) { treas_room(); } // make items for (i = 0; i < MAXOBJ; i++) { int roll = R14.rnd(100); //Console.WriteLine("rolled " + roll); if (roll < 36) { obj = R14.GetNewRandomThing(); R14.attach(ref Dungeon.ItemList, obj); find_floor(null, out obj.ItemPos, 0, false); SetCharAt(obj.ItemPos.y, obj.ItemPos.x, (char)obj.ItemType); } } // place amulet... if far in enough & hasn't found if (Agent.LevelOfMap >= AMULETLEVEL && !Agent.amulet) { obj = new THING(); R14.attach(ref ItemList, obj); obj.PlusToHit = 0; obj.PlusToDmg = 0; obj.swing___o_damage = "0x0"; obj.o_hurldmg = "0x0"; obj.Ac = 11; obj.ItemType = Char.AMULET; /* * Put it somewhere */ find_floor(null, out obj.ItemPos, 0, false); Dungeon.SetCharAt(obj.ItemPos.y, obj.ItemPos.x, Char.AMULET); } }