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.39 by root, Thu May 8 11:39:24 2008 UTC vs.
Revision 1.42 by root, Thu Sep 25 04:35:50 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,
79keyplace (maptile *map, int x, int y, const shstr &keycode, int door_flag, int n_keys, random_map_params *RP) 73keyplace (maptile *map, int x, int y, const shstr &keycode, int door_flag, int n_keys, random_map_params *RP)
80{ 74{
81 int i, j; 75 int i, j;
82 int kx = 0, ky = 0; 76 int kx = 0, ky = 0;
83 object *the_keymaster; /* the monster that gets the key. */ 77 object *the_keymaster; /* the monster that gets the key. */
78 object *the_key = gen_key (keycode);
84 79
85 if (door_flag == PASS_DOORS) 80 if (door_flag == PASS_DOORS)
86 { 81 {
87 int tries = 0; 82 int tries = 0;
88 83
103 freeindex = -1; 98 freeindex = -1;
104 for (tries = 0; tries < 15 && freeindex == -1; tries++) 99 for (tries = 0; tries < 15 && freeindex == -1; tries++)
105 { 100 {
106 kx = rmg_rndm (RP->Xsize - 2) + 1; 101 kx = rmg_rndm (RP->Xsize - 2) + 1;
107 ky = rmg_rndm (RP->Ysize - 2) + 1; 102 ky = rmg_rndm (RP->Ysize - 2) + 1;
108 freeindex = find_free_spot (gen_key (keycode), map, kx, ky, 1, SIZEOFFREE1 + 1); 103 freeindex = find_free_spot (the_key, map, kx, ky, 1, SIZEOFFREE1 + 1);
109 } 104 }
110 105
111 // can freeindex ever be < 0? 106 // can freeindex ever be < 0?
112 if (freeindex >= 0) 107 if (freeindex >= 0)
113 { 108 {
121 /* don't try to keyplace if we're sitting on a blocked square and 116 /* don't try to keyplace if we're sitting on a blocked square and
122 NO_PASS_DOORS is set. */ 117 NO_PASS_DOORS is set. */
123 if (n_keys == 1) 118 if (n_keys == 1)
124 { 119 {
125 if (wall_blocked (map, x, y)) 120 if (wall_blocked (map, x, y))
121 {
122 the_key->destroy ();
126 return 0; 123 return 0;
124 }
127 125
128 the_keymaster = find_monster_in_room (map, x, y, RP); 126 the_keymaster = find_monster_in_room (map, x, y, RP);
129 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. */
130 find_spot_in_room (map, x, y, &kx, &ky, RP); 128 find_spot_in_room (map, x, y, &kx, &ky, RP);
131 } 129 }
145 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);
146 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);
147 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);
148 } 146 }
149 147
148 the_key->destroy ();
150 return 1; 149 return 1;
151 } 150 }
152 } 151 }
153
154 object *the_key = gen_key (keycode);
155 152
156 if (the_keymaster) 153 if (the_keymaster)
157 the_keymaster->head_ ()->insert (the_key); 154 the_keymaster->head_ ()->insert (the_key);
158 else 155 else
159 { 156 {
825 822
826 if (opts & DOORED) 823 if (opts & DOORED)
827 { 824 {
828 for (i = 0, door = doorlist[0]; doorlist[i] != NULL; i++) 825 for (i = 0, door = doorlist[0]; doorlist[i] != NULL; i++)
829 { 826 {
830 object *new_door = get_archetype ("locked_door1"); 827 object *new_door = get_archetype (shstr_locked_door1);
831 828
832 door = doorlist[i]; 829 door = doorlist[i];
833 new_door->face = door->face; 830 new_door->face = door->face;
834 new_door->x = door->x; 831 new_door->x = door->x;
835 new_door->y = door->y; 832 new_door->y = door->y;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines