… | |
… | |
144 | { |
144 | { |
145 | int i; |
145 | int i; |
146 | object *op, *head = NULL, *prev = NULL; |
146 | object *op, *head = NULL, *prev = NULL; |
147 | archetype *at = gen->other_arch; |
147 | archetype *at = gen->other_arch; |
148 | |
148 | |
149 | if (gen->other_arch == NULL) |
149 | if (!gen->other_arch) |
150 | { |
|
|
151 | //LOG(llevError,"Generator without other_arch: %s\n",gen->name); |
|
|
152 | return; |
150 | return; |
153 | } |
151 | |
154 | /* Code below assumes the generator is on a map, as it tries |
152 | /* Code below assumes the generator is on a map, as it tries |
155 | * to place the monster on the map. So if the generator |
153 | * to place the monster on the map. So if the generator |
156 | * isn't on a map, complain and exit. |
154 | * isn't on a map, complain and exit. |
157 | */ |
155 | */ |
158 | if (gen->map == NULL) |
156 | if (!gen->map) |
159 | { |
|
|
160 | //LOG(llevError,"Generator (%s) not on a map?\n", gen->name); |
|
|
161 | return; |
157 | return; |
162 | } |
158 | |
163 | i = find_free_spot (&at->clone, gen->map, gen->x, gen->y, 1, 9); |
159 | i = find_free_spot (&at->clone, gen->map, gen->x, gen->y, 1, 9); |
164 | if (i == -1) |
160 | if (i == -1) |
165 | return; |
161 | return; |
|
|
162 | |
166 | while (at != NULL) |
163 | while (at) |
167 | { |
164 | { |
168 | op = arch_to_object (at); |
165 | op = arch_to_object (at); |
169 | op->x = gen->x + freearr_x[i] + at->clone.x; |
166 | op->x = gen->x + freearr_x[i] + at->clone.x; |
170 | op->y = gen->y + freearr_y[i] + at->clone.y; |
167 | op->y = gen->y + freearr_y[i] + at->clone.y; |
171 | |
168 | |
172 | if (head != NULL) |
169 | if (head) |
173 | op->head = head, prev->more = op; |
170 | op->head = head, prev->more = op; |
174 | |
171 | |
175 | if (rndm (0, 9)) |
172 | if (rndm (0, 9)) |
176 | generate_artifact (op, gen->map->difficulty); |
173 | generate_artifact (op, gen->map->difficulty); |
|
|
174 | |
177 | insert_ob_in_map (op, gen->map, gen, 0); |
175 | insert_ob_in_map (op, gen->map, gen, 0); |
178 | if (QUERY_FLAG (op, FLAG_FREED)) |
176 | if (QUERY_FLAG (op, FLAG_FREED)) |
179 | return; |
177 | return; |
|
|
178 | |
180 | if (op->has_random_items ()) |
179 | if (op->has_random_items ()) |
181 | create_treasure (op->randomitems, op, GT_APPLY, gen->map->difficulty, 0); |
180 | create_treasure (op->randomitems, op, GT_APPLY, gen->map->difficulty, 0); |
|
|
181 | |
182 | if (head == NULL) |
182 | if (head == NULL) |
183 | head = op; |
183 | head = op; |
|
|
184 | |
184 | prev = op; |
185 | prev = op; |
185 | at = at->more; |
186 | at = at->more; |
186 | } |
187 | } |
187 | } |
188 | } |
188 | |
189 | |
… | |
… | |
190 | generate_monster (object *gen) |
191 | generate_monster (object *gen) |
191 | { |
192 | { |
192 | |
193 | |
193 | if (GENERATE_SPEED (gen) && rndm (0, GENERATE_SPEED (gen) - 1)) |
194 | if (GENERATE_SPEED (gen) && rndm (0, GENERATE_SPEED (gen) - 1)) |
194 | return; |
195 | return; |
|
|
196 | |
195 | if (QUERY_FLAG (gen, FLAG_CONTENT_ON_GEN)) |
197 | if (QUERY_FLAG (gen, FLAG_CONTENT_ON_GEN)) |
196 | generate_monster_inv (gen); |
198 | generate_monster_inv (gen); |
197 | else |
199 | else |
198 | generate_monster_arch (gen); |
200 | generate_monster_arch (gen); |
199 | |
201 | |
… | |
… | |
1093 | |
1095 | |
1094 | if (!op->map) |
1096 | if (!op->map) |
1095 | return; /* dm has created a firewall in his inventory */ |
1097 | return; /* dm has created a firewall in his inventory */ |
1096 | |
1098 | |
1097 | spell = op->inv; |
1099 | spell = op->inv; |
|
|
1100 | |
1098 | if (!spell || spell->type != SPELL) |
1101 | if (!spell || spell->type != SPELL) |
1099 | spell = &op->other_arch->clone; |
1102 | spell = &op->other_arch->clone; |
|
|
1103 | |
1100 | if (!spell) |
1104 | if (!spell) |
1101 | { |
1105 | { |
1102 | LOG (llevError, "move_firewall: no spell specified (%s, %s, %d, %d)\n", &op->name, op->map->name, op->x, op->y); |
1106 | LOG (llevError, "move_firewall: no spell specified (%s, %s, %d, %d)\n", &op->name, op->map->name, op->x, op->y); |
1103 | return; |
1107 | return; |
1104 | } |
1108 | } |
1105 | |
1109 | |
1106 | cast_spell (op, op, op->stats.sp ? op->stats.sp : rndm (1, 8), spell, NULL); |
1110 | cast_spell (op, op, op->stats.sp ? op->stats.sp : rndm (1, 8), spell, NULL); |
1107 | } |
1111 | } |
1108 | |
|
|
1109 | |
1112 | |
1110 | /* move_player_mover: this function takes a "player mover" as an |
1113 | /* move_player_mover: this function takes a "player mover" as an |
1111 | * argument, and performs the function of a player mover, which is: |
1114 | * argument, and performs the function of a player mover, which is: |
1112 | * |
1115 | * |
1113 | * a player mover finds any players that are sitting on it. It |
1116 | * a player mover finds any players that are sitting on it. It |