ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/random_maps/treasure.C
(Generate patch)

Comparing deliantra/server/random_maps/treasure.C (file contents):
Revision 1.40 by root, Thu May 8 13:47:19 2008 UTC vs.
Revision 1.43 by root, Mon Sep 29 09:04:51 2008 UTC

52 52
53static object * 53static object *
54gen_key (const shstr &keycode) 54gen_key (const shstr &keycode)
55{ 55{
56 /* get a key and set its keycode */ 56 /* get a key and set its keycode */
57 object *key = archetype::get (shstr_key2); 57 object *key = archetype::get (shstr_key_random_map);
58
59 key->slaying = keycode; 58 key->slaying = keycode;
60 key->stats.food = 100;
61 key->speed_left = -1.f;
62 key->flag [FLAG_IS_USED_UP] = true;
63 key->set_speed (1.f / 300.f);
64
65 return key; 59 return key;
66} 60}
67 61
68/* places keys in the map, preferably in something alive. 62/* places keys in the map, preferably in something alive.
69 keycode is the key's code, 63 keycode is the key's code,
123 NO_PASS_DOORS is set. */ 117 NO_PASS_DOORS is set. */
124 if (n_keys == 1) 118 if (n_keys == 1)
125 { 119 {
126 if (wall_blocked (map, x, y)) 120 if (wall_blocked (map, x, y))
127 { 121 {
128 the_key->destroy (); 122 the_key->destroy (true);
129 return 0; 123 return 0;
130 } 124 }
131 125
132 the_keymaster = find_monster_in_room (map, x, y, RP); 126 the_keymaster = find_monster_in_room (map, x, y, RP);
133 if (!the_keymaster) /* if fail, find a spot to drop the key. */ 127 if (!the_keymaster) /* if fail, find a spot to drop the key. */
149 keyplace (map, x + 1, y - 1, keycode, NO_PASS_DOORS, 1, RP); 143 keyplace (map, x + 1, y - 1, keycode, NO_PASS_DOORS, 1, RP);
150 keyplace (map, x - 1, y + 1, keycode, NO_PASS_DOORS, 1, RP); 144 keyplace (map, x - 1, y + 1, keycode, NO_PASS_DOORS, 1, RP);
151 keyplace (map, x - 1, y - 1, keycode, NO_PASS_DOORS, 1, RP); 145 keyplace (map, x - 1, y - 1, keycode, NO_PASS_DOORS, 1, RP);
152 } 146 }
153 147
154 the_key->destroy (); 148 the_key->destroy (true);
155 return 1; 149 return 1;
156 } 150 }
157 } 151 }
158 152
159 if (the_keymaster) 153 if (the_keymaster)
337 331
338 /* first, find a place to put the chest. */ 332 /* first, find a place to put the chest. */
339 int i = find_first_free_spot (the_chest, map, x, y); // this call uses the main rng 333 int i = find_first_free_spot (the_chest, map, x, y); // this call uses the main rng
340 if (i == -1) 334 if (i == -1)
341 { 335 {
342 the_chest->destroy (); 336 the_chest->destroy (true);
343 return NULL; 337 return NULL;
344 } 338 }
345 339
346 int xl = x + freearr_x[i]; 340 int xl = x + freearr_x[i];
347 int yl = y + freearr_y[i]; 341 int yl = y + freearr_y[i];
675} 669}
676 670
677void 671void
678remove_monsters (int x, int y, maptile *map) 672remove_monsters (int x, int y, maptile *map)
679{ 673{
680 object *tmp;
681
682 for (tmp = GET_MAP_OB (map, x, y); tmp; tmp = tmp->above) 674 for (object *tmp = GET_MAP_OB (map, x, y); tmp; )
683 if (QUERY_FLAG (tmp, FLAG_ALIVE))
684 { 675 {
685 if (tmp->head) 676 object *next = tmp->above;
686 tmp = tmp->head; 677
687 tmp->remove (); 678 if (tmp->flag [FLAG_ALIVE])
688 tmp->destroy (); 679 tmp->head_ ()->destroy (true);
689 tmp = GET_MAP_OB (map, x, y); 680
690 if (tmp == NULL) 681 tmp = next;
691 break;
692 }; 682 }
693} 683}
694 684
695/* surrounds the point x,y by doors, so as to enclose something, like 685/* surrounds the point x,y by doors, so as to enclose something, like
696 a chest. It only goes as far as the 8 squares surrounding, and 686 a chest. It only goes as far as the 8 squares surrounding, and
697 it'll remove any monsters it finds.*/ 687 it'll remove any monsters it finds.*/
826 816
827 /* lock the doors and hide the keys. */ 817 /* lock the doors and hide the keys. */
828 818
829 if (opts & DOORED) 819 if (opts & DOORED)
830 { 820 {
831 for (i = 0, door = doorlist[0]; doorlist[i] != NULL; i++) 821 for (i = 0, door = doorlist[0]; doorlist[i]; i++)
832 { 822 {
833 object *new_door = get_archetype ("locked_door1"); 823 object *new_door = get_archetype (shstr_locked_door1);
834 824
835 door = doorlist[i]; 825 door = doorlist[i];
836 new_door->face = door->face; 826 new_door->face = door->face;
837 new_door->x = door->x; 827 new_door->x = door->x;
838 new_door->y = door->y; 828 new_door->y = door->y;
839 door->remove ();
840 door->destroy (); 829 door->destroy (true);
841 doorlist[i] = new_door; 830 doorlist[i] = new_door;
842 insert_ob_in_map (new_door, map, NULL, 0); 831 insert_ob_in_map (new_door, map, NULL, 0);
843 new_door->slaying = format ("RMG-%d-%d", (int)rmg_rndm (1000000000), (int)rmg_rndm (1000000000)); 832 new_door->slaying = format ("RMG-%d-%d", (int)rmg_rndm (1000000000), (int)rmg_rndm (1000000000));
844 keyplace (map, new_door->x, new_door->y, new_door->slaying, NO_PASS_DOORS, 2, RP); 833 keyplace (map, new_door->x, new_door->y, new_door->slaying, NO_PASS_DOORS, 2, RP);
845 } 834 }
861 retrofit_joined_wall (map, door->x, door->y - 1, 0, RP); 850 retrofit_joined_wall (map, door->x, door->y - 1, 0, RP);
862 retrofit_joined_wall (map, door->x, door->y + 1, 0, RP); 851 retrofit_joined_wall (map, door->x, door->y + 1, 0, RP);
863 852
864 door->face = wallface->face; 853 door->face = wallface->face;
865 854
866 if (!QUERY_FLAG (wallface, FLAG_REMOVED))
867 wallface->remove ();
868
869 wallface->destroy (); 855 wallface->destroy (true);
870 } 856 }
871 } 857 }
872 } 858 }
873} 859}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines