… | |
… | |
74 | |
74 | |
75 | /* bail out if treasure isn't wanted. */ |
75 | /* bail out if treasure isn't wanted. */ |
76 | if (treasure_style) |
76 | if (treasure_style) |
77 | if (!strcmp (treasure_style, "none")) |
77 | if (!strcmp (treasure_style, "none")) |
78 | return; |
78 | return; |
|
|
79 | |
79 | if (treasureoptions <= 0) |
80 | if (treasureoptions <= 0) |
80 | treasureoptions = RANDOM () % (2 * LAST_OPTION); |
81 | treasureoptions = RANDOM () % (2 * LAST_OPTION); |
81 | |
82 | |
82 | /* filter out the mutually exclusive options */ |
83 | /* filter out the mutually exclusive options */ |
83 | if ((treasureoptions & RICH) && (treasureoptions & SPARSE)) |
84 | if ((treasureoptions & RICH) && (treasureoptions & SPARSE)) |
84 | { |
85 | { |
85 | if (RANDOM () % 2) |
86 | if (rndm (2)) |
86 | treasureoptions -= 1; |
87 | treasureoptions -= 1; |
87 | else |
88 | else |
88 | treasureoptions -= 2; |
89 | treasureoptions -= 2; |
89 | } |
90 | } |
90 | |
91 | |
… | |
… | |
463 | return theMonsterToFind; |
464 | return theMonsterToFind; |
464 | } |
465 | } |
465 | } |
466 | } |
466 | |
467 | |
467 | /* now search all the 8 squares around recursively for a monster,in random order */ |
468 | /* now search all the 8 squares around recursively for a monster,in random order */ |
468 | for (i = RANDOM () % 8, j = 0; j < 8 && theMonsterToFind == NULL; i++, j++) |
469 | for (i = rndm (8), j = 0; j < 8 && theMonsterToFind == NULL; i++, j++) |
469 | { |
470 | { |
470 | theMonsterToFind = find_monster_in_room_recursive (layout, map, x + freearr_x[i % 8 + 1], y + freearr_y[i % 8 + 1], RP); |
471 | theMonsterToFind = find_monster_in_room_recursive (layout, map, x + freearr_x[i % 8 + 1], y + freearr_y[i % 8 + 1], RP); |
471 | if (theMonsterToFind != NULL) |
472 | if (theMonsterToFind != NULL) |
472 | return theMonsterToFind; |
473 | return theMonsterToFind; |
473 | } |
474 | } |
… | |
… | |
536 | room_free_spots_x[number_of_free_spots_in_room] = x; |
537 | room_free_spots_x[number_of_free_spots_in_room] = x; |
537 | room_free_spots_y[number_of_free_spots_in_room] = y; |
538 | room_free_spots_y[number_of_free_spots_in_room] = y; |
538 | number_of_free_spots_in_room++; |
539 | number_of_free_spots_in_room++; |
539 | |
540 | |
540 | /* now search all the 8 squares around recursively for free spots,in random order */ |
541 | /* now search all the 8 squares around recursively for free spots,in random order */ |
541 | for (i = RANDOM () % 8, j = 0; j < 8 && theMonsterToFind == NULL; i++, j++) |
542 | for (i = rndm (8), j = 0; j < 8 && theMonsterToFind == NULL; i++, j++) |
542 | find_spot_in_room_recursive (layout, x + freearr_x[i % 8 + 1], y + freearr_y[i % 8 + 1], RP); |
543 | find_spot_in_room_recursive (layout, x + freearr_x[i % 8 + 1], y + freearr_y[i % 8 + 1], RP); |
543 | |
544 | |
544 | } |
545 | } |
545 | |
546 | |
546 | /* find a random non-blocked spot in this room to drop a key. */ |
547 | /* find a random non-blocked spot in this room to drop a key. */ |
… | |
… | |
660 | *cx = -1; |
661 | *cx = -1; |
661 | *cy = -1; |
662 | *cy = -1; |
662 | } |
663 | } |
663 | } |
664 | } |
664 | |
665 | |
665 | |
|
|
666 | void |
666 | void |
667 | remove_monsters (int x, int y, maptile *map) |
667 | remove_monsters (int x, int y, maptile *map) |
668 | { |
668 | { |
669 | object *tmp; |
669 | object *tmp; |
670 | |
670 | |
671 | for (tmp = GET_MAP_OB (map, x, y); tmp != NULL; tmp = tmp->above) |
671 | for (tmp = GET_MAP_OB (map, x, y); tmp; tmp = tmp->above) |
672 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
672 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
673 | { |
673 | { |
674 | if (tmp->head) |
674 | if (tmp->head) |
675 | tmp = tmp->head; |
675 | tmp = tmp->head; |
676 | tmp->remove (); |
676 | tmp->remove (); |
… | |
… | |
679 | if (tmp == NULL) |
679 | if (tmp == NULL) |
680 | break; |
680 | break; |
681 | }; |
681 | }; |
682 | } |
682 | } |
683 | |
683 | |
684 | |
|
|
685 | /* surrounds the point x,y by doors, so as to enclose something, like |
684 | /* surrounds the point x,y by doors, so as to enclose something, like |
686 | a chest. It only goes as far as the 8 squares surrounding, and |
685 | a chest. It only goes as far as the 8 squares surrounding, and |
687 | it'll remove any monsters it finds.*/ |
686 | it'll remove any monsters it finds.*/ |
688 | |
|
|
689 | object ** |
687 | object ** |
690 | surround_by_doors (maptile *map, char **layout, int x, int y, int opts) |
688 | surround_by_doors (maptile *map, char **layout, int x, int y, int opts) |
691 | { |
689 | { |
692 | int i; |
690 | int i; |
693 | char *doors[2]; |
691 | char *doors[2]; |
… | |
… | |
710 | /* place doors in all the 8 adjacent unblocked squares. */ |
708 | /* place doors in all the 8 adjacent unblocked squares. */ |
711 | for (i = 1; i < 9; i++) |
709 | for (i = 1; i < 9; i++) |
712 | { |
710 | { |
713 | int x1 = x + freearr_x[i], y1 = y + freearr_y[i]; |
711 | int x1 = x + freearr_x[i], y1 = y + freearr_y[i]; |
714 | |
712 | |
715 | if (!wall_blocked (map, x1, y1) || layout[x1][y1] == '>') |
713 | if (!wall_blocked (map, x1, y1) && layout[x1][y1] == '>') |
716 | { /* place a door */ |
714 | { /* place a door */ |
|
|
715 | remove_monsters (x1, y1, map); |
|
|
716 | |
717 | object *new_door = get_archetype ((freearr_x[i] == 0) ? doors[1] : doors[0]); |
717 | object *new_door = get_archetype (freearr_x[i] == 0 ? doors[1] : doors[0]); |
718 | |
718 | map->insert (new_door, x1, y1); |
719 | new_door->x = x + freearr_x[i]; |
|
|
720 | new_door->y = y + freearr_y[i]; |
|
|
721 | remove_monsters (new_door->x, new_door->y, map); |
|
|
722 | insert_ob_in_map (new_door, map, NULL, 0); |
|
|
723 | doorlist[ndoors_made] = new_door; |
719 | doorlist[ndoors_made] = new_door; |
724 | ndoors_made++; |
720 | ndoors_made++; |
725 | } |
721 | } |
726 | } |
722 | } |
|
|
723 | |
727 | return doorlist; |
724 | return doorlist; |
728 | } |
725 | } |
729 | |
726 | |
730 | |
727 | |
731 | /* returns the first door in this square, or NULL if there isn't a door. */ |
728 | /* returns the first door in this square, or NULL if there isn't a door. */ |
… | |
… | |
775 | } |
772 | } |
776 | else |
773 | else |
777 | { |
774 | { |
778 | layout[x][y] = 1; |
775 | layout[x][y] = 1; |
779 | /* now search all the 8 squares around recursively for free spots,in random order */ |
776 | /* now search all the 8 squares around recursively for free spots,in random order */ |
780 | for (i = RANDOM () % 8, j = 0; j < 8 && theMonsterToFind == NULL; i++, j++) |
777 | for (i = rndm (8), j = 0; j < 8 && theMonsterToFind == NULL; i++, j++) |
781 | find_doors_in_room_recursive (layout, map, x + freearr_x[i % 8 + 1], y + freearr_y[i % 8 + 1], doorlist, ndoors, RP); |
778 | find_doors_in_room_recursive (layout, map, x + freearr_x[i % 8 + 1], y + freearr_y[i % 8 + 1], doorlist, ndoors, RP); |
782 | } |
779 | } |
783 | } |
780 | } |
784 | |
781 | |
785 | /* find a random non-blocked spot in this room to drop a key. */ |
782 | /* find a random non-blocked spot in this room to drop a key. */ |