1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game for X-windows |
3 | |
3 | * |
|
|
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | Copyright (C) 2002-2003 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002-2003 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | |
7 | * |
7 | This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. |
11 | * (at your option) any later version. |
11 | |
12 | * |
12 | This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
16 | |
17 | * |
17 | You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software |
19 | * along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | |
21 | * |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | /* This file contains all the spell attack code. Grouping this code |
25 | /* This file contains all the spell attack code. Grouping this code |
25 | * together should hopefully make it easier to find the relevent bits |
26 | * together should hopefully make it easier to find the relevent bits |
26 | * of code |
27 | * of code |
27 | */ |
28 | */ |
28 | |
29 | |
29 | #include <global.h> |
30 | #include <global.h> |
30 | #include <object.h> |
31 | #include <object.h> |
31 | #include <living.h> |
32 | #include <living.h> |
32 | #ifndef __CEXTRACT__ |
|
|
33 | # include <sproto.h> |
33 | #include <sproto.h> |
34 | #endif |
|
|
35 | #include <spells.h> |
34 | #include <spells.h> |
36 | #include <sounds.h> |
35 | #include <sounds.h> |
37 | |
36 | |
38 | /* this function checks to see if a spell pushes objects as well |
37 | /* this function checks to see if a spell pushes objects as well |
39 | * as flies over and damages them (only used for cones for now) |
38 | * as flies over and damages them (only used for cones for now) |
… | |
… | |
57 | { |
56 | { |
58 | weight_move = op->weight + (op->weight * op->level) / 3; |
57 | weight_move = op->weight + (op->weight * op->level) / 3; |
59 | /*LOG (llevDebug, "DEBUG: arch weighs %d and masses %d (%s,level %d)\n", op->weight,weight_move,op->name,op->level); */ |
58 | /*LOG (llevDebug, "DEBUG: arch weighs %d and masses %d (%s,level %d)\n", op->weight,weight_move,op->name,op->level); */ |
60 | } |
59 | } |
61 | |
60 | |
62 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
61 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
63 | { |
62 | { |
64 | int num_sections = 1; |
63 | int num_sections = 1; |
65 | |
64 | |
66 | /* don't move DM */ |
65 | /* don't move DM */ |
67 | if (QUERY_FLAG (tmp, FLAG_WIZ)) |
66 | if (QUERY_FLAG (tmp, FLAG_WIZ)) |
… | |
… | |
140 | |
139 | |
141 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
140 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
142 | return; |
141 | return; |
143 | |
142 | |
144 | /* OK, we made a fork */ |
143 | /* OK, we made a fork */ |
145 | new_bolt = get_object (); |
144 | new_bolt = tmp->clone (); |
146 | copy_object (tmp, new_bolt); |
|
|
147 | |
145 | |
148 | /* reduce chances of subsequent forking */ |
146 | /* reduce chances of subsequent forking */ |
149 | new_bolt->stats.Dex -= 10; |
147 | new_bolt->stats.Dex -= 10; |
150 | tmp->stats.Dex -= 10; /* less forks from main bolt too */ |
148 | tmp->stats.Dex -= 10; /* less forks from main bolt too */ |
151 | new_bolt->stats.Con += 25 * new_dir; /* adjust the left bias */ |
149 | new_bolt->stats.Con += 25 * new_dir; /* adjust the left bias */ |
152 | new_bolt->speed_left = -0.1; |
150 | new_bolt->speed_left = -0.1; |
153 | new_bolt->direction = t_dir; |
151 | new_bolt->direction = t_dir; |
154 | new_bolt->duration++; |
152 | new_bolt->duration++; |
155 | new_bolt->x = sx; |
|
|
156 | new_bolt->y = sy; |
|
|
157 | new_bolt->stats.dam /= 2; /* reduce daughter bolt damage */ |
153 | new_bolt->stats.dam /= 2; /* reduce daughter bolt damage */ |
158 | new_bolt->stats.dam++; |
154 | new_bolt->stats.dam++; |
159 | tmp->stats.dam /= 2; /* reduce father bolt damage */ |
155 | tmp->stats.dam /= 2; /* reduce father bolt damage */ |
160 | tmp->stats.dam++; |
156 | tmp->stats.dam++; |
161 | new_bolt = insert_ob_in_map (new_bolt, m, op, 0); |
157 | if ((new_bolt = m->insert (new_bolt, sx, sy, op))) |
162 | update_turn_face (new_bolt); |
158 | update_turn_face (new_bolt); |
163 | } |
159 | } |
164 | |
160 | |
165 | /* move_bolt: moves bolt 'op'. Basically, it just advances a space, |
161 | /* move_bolt: moves bolt 'op'. Basically, it just advances a space, |
166 | * and checks for various things that may stop it. |
162 | * and checks for various things that may stop it. |
167 | */ |
163 | */ |
… | |
… | |
172 | object *tmp; |
168 | object *tmp; |
173 | int mflags; |
169 | int mflags; |
174 | sint16 x, y; |
170 | sint16 x, y; |
175 | maptile *m; |
171 | maptile *m; |
176 | |
172 | |
177 | if (--(op->duration) < 0) |
173 | if (--op->duration < 0) |
178 | { |
174 | { |
179 | op->remove (); |
|
|
180 | op->destroy (0); |
175 | op->destroy (); |
181 | return; |
176 | return; |
182 | } |
177 | } |
183 | |
178 | |
184 | hit_map (op, 0, op->attacktype, 1); |
179 | hit_map (op, 0, op->attacktype, 1); |
185 | |
180 | |
186 | if (!op->direction) |
181 | if (!op->direction) |
187 | return; |
182 | return; |
188 | |
183 | |
189 | if (--op->range < 0) |
184 | if (--op->range < 0) |
190 | { |
|
|
191 | op->range = 0; |
185 | op->range = 0; |
192 | } |
|
|
193 | else |
186 | else |
194 | { |
187 | { |
195 | x = op->x + DIRX (op); |
188 | x = op->x + DIRX (op); |
196 | y = op->y + DIRY (op); |
189 | y = op->y + DIRY (op); |
197 | m = op->map; |
190 | m = op->map; |
… | |
… | |
205 | * on the space. So only call reflwall if we think the data it returns |
198 | * on the space. So only call reflwall if we think the data it returns |
206 | * will be useful. |
199 | * will be useful. |
207 | */ |
200 | */ |
208 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y)) || ((mflags & P_IS_ALIVE) && reflwall (m, x, y, op))) |
201 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y)) || ((mflags & P_IS_ALIVE) && reflwall (m, x, y, op))) |
209 | { |
202 | { |
210 | |
|
|
211 | if (!QUERY_FLAG (op, FLAG_REFLECTING)) |
203 | if (!QUERY_FLAG (op, FLAG_REFLECTING)) |
212 | return; |
204 | return; |
213 | |
205 | |
214 | /* Since walls don't run diagonal, if the bolt is in |
206 | /* Since walls don't run diagonal, if the bolt is in |
215 | * one of 4 main directions, it just reflects back in the |
207 | * one of 4 main directions, it just reflects back in the |
… | |
… | |
245 | else if (left) |
237 | else if (left) |
246 | op->direction = absdir (op->direction + 2); |
238 | op->direction = absdir (op->direction + 2); |
247 | else if (right) |
239 | else if (right) |
248 | op->direction = absdir (op->direction - 2); |
240 | op->direction = absdir (op->direction - 2); |
249 | } |
241 | } |
|
|
242 | |
250 | update_turn_face (op); /* A bolt *must* be IS_TURNABLE */ |
243 | update_turn_face (op); /* A bolt *must* be IS_TURNABLE */ |
251 | return; |
244 | return; |
252 | } |
245 | } |
253 | else |
246 | else |
254 | { /* Create a copy of this object and put it ahead */ |
247 | { /* Create a copy of this object and put it ahead */ |
255 | tmp = get_object (); |
248 | object *tmp = op->clone (); |
256 | copy_object (op, tmp); |
249 | |
|
|
250 | m->insert (tmp, x, y, op); |
257 | tmp->speed_left = -0.1; |
251 | tmp->speed_left = -0.1; |
258 | tmp->x += DIRX (tmp), tmp->y += DIRY (tmp); |
|
|
259 | tmp = insert_ob_in_map (tmp, op->map, op, 0); |
|
|
260 | /* To make up for the decrease at the top of the function */ |
252 | /* To make up for the decrease at the top of the function */ |
261 | tmp->duration++; |
253 | tmp->duration++; |
262 | |
254 | |
263 | /* New forking code. Possibly create forks of this object |
255 | /* New forking code. Possibly create forks of this object |
264 | * going off in other directions. |
256 | * going off in other directions. |
265 | */ |
257 | */ |
266 | |
|
|
267 | if (rndm (0, 99) < tmp->stats.Dex) |
258 | if (rndm (0, 99) < tmp->stats.Dex) |
268 | { /* stats.Dex % of forking */ |
259 | { /* stats.Dex % of forking */ |
269 | forklightning (op, tmp); |
260 | forklightning (op, tmp); |
270 | } |
261 | } |
|
|
262 | |
271 | /* In this way, the object left behind sticks on the space, but |
263 | /* In this way, the object left behind sticks on the space, but |
272 | * doesn't create any bolts that continue to move onward. |
264 | * doesn't create any bolts that continue to move onward. |
273 | */ |
265 | */ |
274 | op->range = 0; |
266 | op->range = 0; |
275 | } /* copy object and move it along */ |
267 | } /* copy object and move it along */ |
… | |
… | |
282 | * we remove the magic flag - that can be derived from |
274 | * we remove the magic flag - that can be derived from |
283 | * spob->attacktype. |
275 | * spob->attacktype. |
284 | * This function sets up the appropriate owner and skill |
276 | * This function sets up the appropriate owner and skill |
285 | * pointers. |
277 | * pointers. |
286 | */ |
278 | */ |
287 | |
|
|
288 | int |
279 | int |
289 | fire_bolt (object *op, object *caster, int dir, object *spob, object *skill) |
280 | fire_bolt (object *op, object *caster, int dir, object *spob, object *skill) |
290 | { |
281 | { |
291 | object *tmp = NULL; |
282 | object *tmp = NULL; |
292 | int mflags; |
283 | int mflags; |
… | |
… | |
310 | |
301 | |
311 | tmp->direction = dir; |
302 | tmp->direction = dir; |
312 | if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) |
303 | if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) |
313 | SET_ANIMATION (tmp, dir); |
304 | SET_ANIMATION (tmp, dir); |
314 | |
305 | |
315 | set_owner (tmp, op); |
306 | tmp->set_owner (op); |
316 | set_spell_skill (op, caster, spob, tmp); |
307 | set_spell_skill (op, caster, spob, tmp); |
317 | |
308 | |
318 | tmp->x = op->x + DIRX (tmp); |
309 | tmp->x = op->x + DIRX (tmp); |
319 | tmp->y = op->y + DIRY (tmp); |
310 | tmp->y = op->y + DIRY (tmp); |
320 | tmp->map = op->map; |
311 | tmp->map = op->map; |
321 | |
312 | |
|
|
313 | maptile *newmap; |
322 | mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); |
314 | mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y); |
323 | if (mflags & P_OUT_OF_MAP) |
315 | if (mflags & P_OUT_OF_MAP) |
324 | { |
316 | { |
325 | tmp->destroy (0); |
317 | tmp->destroy (); |
326 | return 0; |
318 | return 0; |
327 | } |
319 | } |
|
|
320 | |
|
|
321 | tmp->map = newmap; |
|
|
322 | |
328 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
323 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
329 | { |
324 | { |
330 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
325 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
331 | { |
326 | { |
332 | tmp->destroy (0); |
327 | tmp->destroy (); |
333 | return 0; |
328 | return 0; |
334 | } |
329 | } |
|
|
330 | |
335 | tmp->x = op->x; |
331 | tmp->x = op->x; |
336 | tmp->y = op->y; |
332 | tmp->y = op->y; |
337 | tmp->direction = absdir (tmp->direction + 4); |
333 | tmp->direction = absdir (tmp->direction + 4); |
338 | tmp->map = op->map; |
334 | tmp->map = op->map; |
339 | } |
335 | } |
340 | if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) |
336 | |
|
|
337 | if ((tmp = tmp->insert_at (tmp, op))) |
341 | move_bolt (tmp); |
338 | move_bolt (tmp); |
|
|
339 | |
342 | return 1; |
340 | return 1; |
343 | } |
341 | } |
344 | |
342 | |
345 | |
343 | |
346 | |
344 | |
… | |
… | |
355 | * At least that is what I think this does. |
353 | * At least that is what I think this does. |
356 | */ |
354 | */ |
357 | void |
355 | void |
358 | explosion (object *op) |
356 | explosion (object *op) |
359 | { |
357 | { |
360 | object *tmp; |
|
|
361 | maptile *m = op->map; |
358 | maptile *m = op->map; |
362 | int i; |
359 | int i; |
363 | |
360 | |
364 | if (--(op->duration) < 0) |
361 | if (--op->duration < 0) |
365 | { |
362 | { |
366 | op->remove (); |
|
|
367 | op->destroy (0); |
363 | op->destroy (); |
368 | return; |
364 | return; |
369 | } |
365 | } |
|
|
366 | |
370 | hit_map (op, 0, op->attacktype, 0); |
367 | hit_map (op, 0, op->attacktype, 0); |
371 | |
368 | |
372 | if (op->range > 0) |
369 | if (op->range > 0) |
373 | { |
370 | { |
374 | for (i = 1; i < 9; i++) |
371 | for (i = 1; i < 9; i++) |
375 | { |
372 | { |
376 | sint16 dx, dy; |
373 | sint16 dx, dy; |
377 | |
374 | |
378 | dx = op->x + freearr_x[i]; |
375 | dx = op->x + freearr_x[i]; |
379 | dy = op->y + freearr_y[i]; |
376 | dy = op->y + freearr_y[i]; |
|
|
377 | |
380 | /* ok_to_put_more already does things like checks for walls, |
378 | /* ok_to_put_more already does things like checks for walls, |
381 | * out of map, etc. |
379 | * out of map, etc. |
382 | */ |
380 | */ |
383 | if (ok_to_put_more (op->map, dx, dy, op, op->attacktype)) |
381 | if (ok_to_put_more (op->map, dx, dy, op, op->attacktype)) |
384 | { |
382 | { |
385 | tmp = get_object (); |
383 | object *tmp = op->clone (); |
386 | copy_object (op, tmp); |
384 | |
387 | tmp->state = 0; |
385 | tmp->state = 0; |
388 | tmp->speed_left = -0.21; |
386 | tmp->speed_left = -0.21; |
389 | tmp->range--; |
387 | tmp->range--; |
390 | tmp->value = 0; |
388 | tmp->value = 0; |
391 | tmp->x = dx; |
389 | |
392 | tmp->y = dy; |
390 | m->insert (tmp, dx, dy, op); |
393 | insert_ob_in_map (tmp, m, op, 0); |
|
|
394 | } |
391 | } |
395 | } |
392 | } |
396 | } |
393 | } |
397 | } |
394 | } |
398 | |
395 | |
… | |
… | |
407 | object *tmp, *owner; |
404 | object *tmp, *owner; |
408 | |
405 | |
409 | if (op->other_arch == NULL) |
406 | if (op->other_arch == NULL) |
410 | { |
407 | { |
411 | LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); |
408 | LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); |
412 | op->remove (); |
|
|
413 | op->destroy (0); |
409 | op->destroy (); |
414 | return; |
410 | return; |
415 | } |
411 | } |
416 | |
412 | |
417 | if (op->env) |
413 | if (op->env) |
418 | { |
414 | { |
419 | object *env; |
|
|
420 | |
|
|
421 | env = object_get_env_recursive (op); |
415 | object *env = object_get_env_recursive (op); |
422 | if (env->map == NULL || out_of_map (env->map, env->x, env->y)) |
416 | if (env->map == NULL || out_of_map (env->map, env->x, env->y)) |
423 | { |
417 | { |
424 | LOG (llevError, "BUG: explode_bullet(): env out of map\n"); |
418 | LOG (llevError, "BUG: explode_bullet(): env out of map\n"); |
425 | op->remove (); |
|
|
426 | op->destroy (0); |
419 | op->destroy (); |
427 | return; |
420 | return; |
428 | } |
421 | } |
429 | op->remove (); |
422 | |
430 | op->x = env->x; |
423 | op->insert_at (env, op, INS_NO_MERGE | INS_NO_WALK_ON); |
431 | op->y = env->y; |
|
|
432 | insert_ob_in_map (op, env->map, op, INS_NO_MERGE | INS_NO_WALK_ON); |
|
|
433 | } |
424 | } |
434 | else if (out_of_map (op->map, op->x, op->y)) |
425 | else if (out_of_map (op->map, op->x, op->y)) |
435 | { |
426 | { |
436 | LOG (llevError, "BUG: explode_bullet(): op out of map\n"); |
427 | LOG (llevError, "BUG: explode_bullet(): op out of map\n"); |
437 | op->remove (); |
|
|
438 | op->destroy (0); |
428 | op->destroy (); |
439 | return; |
429 | return; |
440 | } |
430 | } |
441 | |
431 | |
442 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent explosions of any kind on safe maps |
432 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent explosions of any kind on safe maps |
443 | // NOTE: If this breaks something important: remove this. I can't think of anything |
433 | // NOTE: If this breaks something important: remove this. I can't think of anything |
444 | // bad at the moment that might happen from this. |
434 | // bad at the moment that might happen from this. |
445 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
435 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
446 | { |
436 | { |
447 | op->remove (); |
|
|
448 | op->destroy (0); |
437 | op->destroy (); |
449 | return; |
438 | return; |
450 | } |
439 | } |
451 | |
440 | |
452 | if (op->attacktype) |
441 | if (op->attacktype) |
453 | { |
442 | { |
… | |
… | |
457 | } |
446 | } |
458 | |
447 | |
459 | /* other_arch contains what this explodes into */ |
448 | /* other_arch contains what this explodes into */ |
460 | tmp = arch_to_object (op->other_arch); |
449 | tmp = arch_to_object (op->other_arch); |
461 | |
450 | |
462 | copy_owner (tmp, op); |
451 | tmp->set_owner (op); |
463 | tmp->skill = op->skill; |
452 | tmp->skill = op->skill; |
464 | |
453 | |
465 | owner = get_owner (op); |
454 | owner = op->owner; |
466 | |
455 | |
467 | if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && !tailor_god_spell (tmp, owner)) |
456 | if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && !tailor_god_spell (tmp, owner)) |
468 | { |
457 | { |
469 | op->remove (); |
|
|
470 | op->destroy (0); |
458 | op->destroy (); |
471 | return; |
459 | return; |
472 | } |
460 | } |
473 | |
|
|
474 | tmp->x = op->x; |
|
|
475 | tmp->y = op->y; |
|
|
476 | |
461 | |
477 | /* special for bombs - it actually has sane values for these */ |
462 | /* special for bombs - it actually has sane values for these */ |
478 | if (op->type == SPELL_EFFECT && op->subtype == SP_BOMB) |
463 | if (op->type == SPELL_EFFECT && op->subtype == SP_BOMB) |
479 | { |
464 | { |
480 | tmp->attacktype = op->attacktype; |
465 | tmp->attacktype = op->attacktype; |
… | |
… | |
484 | } |
469 | } |
485 | else |
470 | else |
486 | { |
471 | { |
487 | if (op->attacktype & AT_MAGIC) |
472 | if (op->attacktype & AT_MAGIC) |
488 | tmp->attacktype |= AT_MAGIC; |
473 | tmp->attacktype |= AT_MAGIC; |
|
|
474 | |
489 | /* Spell doc describes what is going on here */ |
475 | /* Spell doc describes what is going on here */ |
490 | tmp->stats.dam = op->dam_modifier; |
476 | tmp->stats.dam = op->dam_modifier; |
491 | tmp->range = op->stats.maxhp; |
477 | tmp->range = op->stats.maxhp; |
492 | tmp->duration = op->stats.hp; |
478 | tmp->duration = op->stats.hp; |
493 | /* Used for spell tracking - just need a unique val for this spell - |
479 | /* Used for spell tracking - just need a unique val for this spell - |
… | |
… | |
501 | tmp->stats.sp = op->direction; |
487 | tmp->stats.sp = op->direction; |
502 | |
488 | |
503 | /* Prevent recursion */ |
489 | /* Prevent recursion */ |
504 | op->move_on = 0; |
490 | op->move_on = 0; |
505 | |
491 | |
506 | insert_ob_in_map (tmp, op->map, op, 0); |
492 | tmp->insert_at (op, op); |
507 | /* remove the firebullet */ |
493 | /* remove the firebullet */ |
508 | if (!op->destroyed ()) |
|
|
509 | { |
|
|
510 | op->remove (); |
|
|
511 | op->destroy (0); |
494 | op->destroy (); |
512 | } |
|
|
513 | } |
495 | } |
514 | |
|
|
515 | |
|
|
516 | |
496 | |
517 | /* checks to see what op should do, given the space it is on |
497 | /* checks to see what op should do, given the space it is on |
518 | * (eg, explode, damage player, etc) |
498 | * (eg, explode, damage player, etc) |
519 | */ |
499 | */ |
520 | |
|
|
521 | void |
500 | void |
522 | check_bullet (object *op) |
501 | check_bullet (object *op) |
523 | { |
502 | { |
524 | object *tmp; |
503 | object *tmp; |
525 | int dam, mflags; |
504 | int dam, mflags; |
… | |
… | |
540 | |
519 | |
541 | /* If nothing alive on this space, no reason to do anything further */ |
520 | /* If nothing alive on this space, no reason to do anything further */ |
542 | if (!(mflags & P_IS_ALIVE)) |
521 | if (!(mflags & P_IS_ALIVE)) |
543 | return; |
522 | return; |
544 | |
523 | |
545 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
524 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
546 | { |
525 | { |
547 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
526 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
548 | { |
527 | { |
549 | dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); |
528 | dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); |
550 | if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) |
529 | if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) |
551 | { |
530 | { |
552 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
531 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
553 | { |
532 | { |
554 | op->remove (); |
|
|
555 | op->destroy (0); |
533 | op->destroy (); |
556 | return; |
534 | return; |
557 | } |
535 | } |
558 | } |
536 | } |
559 | } |
537 | } |
560 | } |
538 | } |
561 | } |
539 | } |
562 | |
|
|
563 | |
540 | |
564 | /* Basically, we move 'op' one square, and if it hits something, |
541 | /* Basically, we move 'op' one square, and if it hits something, |
565 | * call check_bullet. |
542 | * call check_bullet. |
566 | * This function is only applicable to bullets, but not to all |
543 | * This function is only applicable to bullets, but not to all |
567 | * fired arches (eg, bolts). |
544 | * fired arches (eg, bolts). |
568 | */ |
545 | */ |
569 | |
|
|
570 | void |
546 | void |
571 | move_bullet (object *op) |
547 | move_bullet (object *op) |
572 | { |
548 | { |
573 | sint16 new_x, new_y; |
549 | sint16 new_x, new_y; |
574 | int mflags; |
550 | int mflags; |
… | |
… | |
589 | |
565 | |
590 | /* Reached the end of its life - remove it */ |
566 | /* Reached the end of its life - remove it */ |
591 | if (--op->range <= 0) |
567 | if (--op->range <= 0) |
592 | { |
568 | { |
593 | if (op->other_arch) |
569 | if (op->other_arch) |
594 | { |
|
|
595 | explode_bullet (op); |
570 | explode_bullet (op); |
596 | } |
|
|
597 | else |
571 | else |
598 | { |
|
|
599 | op->remove (); |
|
|
600 | op->destroy (0); |
572 | op->destroy (); |
601 | } |
573 | |
602 | return; |
574 | return; |
603 | } |
575 | } |
604 | |
576 | |
605 | new_x = op->x + DIRX (op); |
577 | new_x = op->x + DIRX (op); |
606 | new_y = op->y + DIRY (op); |
578 | new_y = op->y + DIRY (op); |
607 | m = op->map; |
579 | m = op->map; |
608 | mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y); |
580 | mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y); |
609 | |
581 | |
610 | if (mflags & P_OUT_OF_MAP) |
582 | if (mflags & P_OUT_OF_MAP) |
611 | { |
583 | { |
612 | op->remove (); |
|
|
613 | op->destroy (0); |
584 | op->destroy (); |
614 | return; |
585 | return; |
615 | } |
586 | } |
616 | |
587 | |
617 | if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) |
588 | if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) |
618 | { |
589 | { |
619 | if (op->other_arch) |
590 | if (op->other_arch) |
620 | { |
|
|
621 | explode_bullet (op); |
591 | explode_bullet (op); |
622 | } |
|
|
623 | else |
592 | else |
624 | { |
|
|
625 | op->remove (); |
|
|
626 | op->destroy (0); |
593 | op->destroy (); |
627 | } |
594 | |
628 | return; |
595 | return; |
629 | } |
596 | } |
630 | |
597 | |
631 | op->remove (); |
598 | if (!(op = m->insert (op, new_x, new_y, op))) |
632 | op->x = new_x; |
|
|
633 | op->y = new_y; |
|
|
634 | if ((op = insert_ob_in_map (op, m, op, 0)) == NULL) |
|
|
635 | return; |
599 | return; |
636 | |
600 | |
637 | if (reflwall (op->map, op->x, op->y, op)) |
601 | if (reflwall (op->map, op->x, op->y, op)) |
638 | { |
602 | { |
639 | op->direction = absdir (op->direction + 4); |
603 | op->direction = absdir (op->direction + 4); |
640 | update_turn_face (op); |
604 | update_turn_face (op); |
641 | } |
605 | } |
642 | else |
606 | else |
643 | { |
|
|
644 | check_bullet (op); |
607 | check_bullet (op); |
645 | } |
|
|
646 | } |
608 | } |
647 | |
609 | |
648 | |
610 | |
649 | |
611 | |
650 | |
612 | |
… | |
… | |
685 | |
647 | |
686 | tmp->direction = dir; |
648 | tmp->direction = dir; |
687 | if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) |
649 | if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) |
688 | SET_ANIMATION (tmp, dir); |
650 | SET_ANIMATION (tmp, dir); |
689 | |
651 | |
690 | set_owner (tmp, op); |
652 | tmp->set_owner (op); |
691 | set_spell_skill (op, caster, spob, tmp); |
653 | set_spell_skill (op, caster, spob, tmp); |
692 | |
654 | |
693 | tmp->x = op->x + freearr_x[dir]; |
655 | tmp->x = op->x + freearr_x[dir]; |
694 | tmp->y = op->y + freearr_y[dir]; |
656 | tmp->y = op->y + freearr_y[dir]; |
695 | tmp->map = op->map; |
657 | tmp->map = op->map; |
696 | |
658 | |
|
|
659 | maptile *newmap; |
697 | mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); |
660 | mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y); |
698 | if (mflags & P_OUT_OF_MAP) |
661 | if (mflags & P_OUT_OF_MAP) |
699 | { |
662 | { |
700 | tmp->destroy (0); |
663 | tmp->destroy (); |
701 | return 0; |
664 | return 0; |
702 | } |
665 | } |
|
|
666 | |
|
|
667 | tmp->map = newmap; |
|
|
668 | |
703 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
669 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
704 | { |
670 | { |
705 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
671 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
706 | { |
672 | { |
707 | tmp->destroy (0); |
673 | tmp->destroy (); |
708 | return 0; |
674 | return 0; |
709 | } |
675 | } |
|
|
676 | |
710 | tmp->x = op->x; |
677 | tmp->x = op->x; |
711 | tmp->y = op->y; |
678 | tmp->y = op->y; |
712 | tmp->direction = absdir (tmp->direction + 4); |
679 | tmp->direction = absdir (tmp->direction + 4); |
713 | tmp->map = op->map; |
680 | tmp->map = op->map; |
714 | } |
681 | } |
715 | if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) |
682 | |
716 | { |
683 | if ((tmp = tmp->insert_at (tmp, op))) |
717 | check_bullet (tmp); |
684 | check_bullet (tmp); |
718 | } |
685 | |
719 | return 1; |
686 | return 1; |
720 | } |
687 | } |
721 | |
688 | |
722 | |
689 | |
723 | |
690 | |
… | |
… | |
733 | void |
700 | void |
734 | cone_drop (object *op) |
701 | cone_drop (object *op) |
735 | { |
702 | { |
736 | object *new_ob = arch_to_object (op->other_arch); |
703 | object *new_ob = arch_to_object (op->other_arch); |
737 | |
704 | |
738 | new_ob->x = op->x; |
|
|
739 | new_ob->y = op->y; |
|
|
740 | new_ob->level = op->level; |
705 | new_ob->level = op->level; |
741 | set_owner (new_ob, op->owner); |
706 | new_ob->set_owner (op->owner); |
742 | |
707 | |
743 | /* preserve skill ownership */ |
708 | /* preserve skill ownership */ |
744 | if (op->skill && op->skill != new_ob->skill) |
709 | if (op->skill && op->skill != new_ob->skill) |
745 | { |
|
|
746 | new_ob->skill = op->skill; |
710 | new_ob->skill = op->skill; |
747 | } |
|
|
748 | insert_ob_in_map (new_ob, op->map, op, 0); |
|
|
749 | |
711 | |
|
|
712 | new_ob->insert_at (op, op); |
750 | } |
713 | } |
751 | |
714 | |
752 | /* move_cone: causes cone object 'op' to move a space/hit creatures */ |
715 | /* move_cone: causes cone object 'op' to move a space/hit creatures */ |
753 | |
716 | |
754 | void |
717 | void |
… | |
… | |
758 | |
721 | |
759 | /* if no map then hit_map will crash so just ignore object */ |
722 | /* if no map then hit_map will crash so just ignore object */ |
760 | if (!op->map) |
723 | if (!op->map) |
761 | { |
724 | { |
762 | LOG (llevError, "Tried to move_cone object %s without a map.\n", op->name ? &op->name : "unknown"); |
725 | LOG (llevError, "Tried to move_cone object %s without a map.\n", op->name ? &op->name : "unknown"); |
763 | op->speed = 0; |
726 | op->set_speed (0); |
764 | update_ob_speed (op); |
|
|
765 | return; |
727 | return; |
766 | } |
728 | } |
767 | |
729 | |
768 | /* lava saves it's life, but not yours :) */ |
730 | /* lava saves it's life, but not yours :) */ |
769 | if (QUERY_FLAG (op, FLAG_LIFESAVE)) |
731 | if (QUERY_FLAG (op, FLAG_LIFESAVE)) |
… | |
… | |
775 | #if 0 |
737 | #if 0 |
776 | /* Disable this - enabling it makes monsters easier, as |
738 | /* Disable this - enabling it makes monsters easier, as |
777 | * when their cone dies when they die. |
739 | * when their cone dies when they die. |
778 | */ |
740 | */ |
779 | /* If no owner left, the spell dies out. */ |
741 | /* If no owner left, the spell dies out. */ |
780 | if (get_owner (op) == NULL) |
742 | if (op->owner == NULL) |
781 | { |
743 | { |
782 | op->remove (); |
|
|
783 | op->destroy (0); |
744 | op->destroy (); |
784 | return; |
745 | return; |
785 | } |
746 | } |
786 | #endif |
747 | #endif |
787 | |
748 | |
788 | hit_map (op, 0, op->attacktype, 0); |
749 | hit_map (op, 0, op->attacktype, 0); |
… | |
… | |
797 | if (op->destroyed ()) |
758 | if (op->destroyed ()) |
798 | return; |
759 | return; |
799 | |
760 | |
800 | if ((op->duration--) < 0) |
761 | if ((op->duration--) < 0) |
801 | { |
762 | { |
802 | op->remove (); |
|
|
803 | op->destroy (0); |
763 | op->destroy (); |
804 | return; |
764 | return; |
805 | } |
765 | } |
806 | /* Object has hit maximum range, so don't have it move |
766 | /* Object has hit maximum range, so don't have it move |
807 | * any further. When the duration above expires, |
767 | * any further. When the duration above expires, |
808 | * then the object will get removed. |
768 | * then the object will get removed. |
… | |
… | |
817 | { |
777 | { |
818 | sint16 x = op->x + freearr_x[absdir (op->stats.sp + i)], y = op->y + freearr_y[absdir (op->stats.sp + i)]; |
778 | sint16 x = op->x + freearr_x[absdir (op->stats.sp + i)], y = op->y + freearr_y[absdir (op->stats.sp + i)]; |
819 | |
779 | |
820 | if (ok_to_put_more (op->map, x, y, op, op->attacktype)) |
780 | if (ok_to_put_more (op->map, x, y, op, op->attacktype)) |
821 | { |
781 | { |
822 | object *tmp = get_object (); |
782 | object *tmp = op->clone (); |
823 | |
|
|
824 | copy_object (op, tmp); |
|
|
825 | tmp->x = x; |
|
|
826 | tmp->y = y; |
|
|
827 | |
783 | |
828 | tmp->duration = op->duration + 1; |
784 | tmp->duration = op->duration + 1; |
829 | |
785 | |
830 | /* Use for spell tracking - see ok_to_put_more() */ |
786 | /* Use for spell tracking - see ok_to_put_more() */ |
831 | tmp->stats.maxhp = op->stats.maxhp; |
787 | tmp->stats.maxhp = op->stats.maxhp; |
832 | insert_ob_in_map (tmp, op->map, op, 0); |
788 | |
|
|
789 | op->map->insert (tmp, x, y, op); |
|
|
790 | |
833 | if (tmp->other_arch) |
791 | if (tmp->other_arch) |
834 | cone_drop (tmp); |
792 | cone_drop (tmp); |
835 | } |
793 | } |
836 | } |
794 | } |
837 | } |
795 | } |
… | |
… | |
913 | if ((movetype & GET_MAP_MOVE_BLOCK (m, sx, sy)) == movetype) |
871 | if ((movetype & GET_MAP_MOVE_BLOCK (m, sx, sy)) == movetype) |
914 | continue; |
872 | continue; |
915 | |
873 | |
916 | success = 1; |
874 | success = 1; |
917 | tmp = arch_to_object (spell->other_arch); |
875 | tmp = arch_to_object (spell->other_arch); |
918 | set_owner (tmp, op); |
876 | tmp->set_owner (op); |
919 | set_spell_skill (op, caster, spell, tmp); |
877 | set_spell_skill (op, caster, spell, tmp); |
920 | tmp->level = caster_level (caster, spell); |
878 | tmp->level = caster_level (caster, spell); |
921 | tmp->x = sx; |
|
|
922 | tmp->y = sy; |
|
|
923 | tmp->attacktype = spell->attacktype; |
879 | tmp->attacktype = spell->attacktype; |
924 | |
880 | |
925 | /* holy word stuff */ |
881 | /* holy word stuff */ |
926 | if ((tmp->attacktype & AT_HOLYWORD) || (tmp->attacktype & AT_GODPOWER)) |
882 | if ((tmp->attacktype & AT_HOLYWORD) || (tmp->attacktype & AT_GODPOWER)) |
927 | if (!tailor_god_spell (tmp, op)) |
883 | if (!tailor_god_spell (tmp, op)) |
… | |
… | |
964 | |
920 | |
965 | if (!(tmp->move_type & MOVE_FLY_LOW)) |
921 | if (!(tmp->move_type & MOVE_FLY_LOW)) |
966 | LOG (llevDebug, "cast_cone(): arch %s doesn't have flying 1\n", &spell->other_arch->name); |
922 | LOG (llevDebug, "cast_cone(): arch %s doesn't have flying 1\n", &spell->other_arch->name); |
967 | |
923 | |
968 | if (!tmp->move_on && tmp->stats.dam) |
924 | if (!tmp->move_on && tmp->stats.dam) |
969 | { |
|
|
970 | LOG (llevDebug, "cast_cone(): arch %s doesn't have move_on set\n", &spell->other_arch->name); |
925 | LOG (llevDebug, "cast_cone(): arch %s doesn't have move_on set\n", &spell->other_arch->name); |
971 | } |
|
|
972 | |
926 | |
973 | insert_ob_in_map (tmp, m, op, 0); |
927 | m->insert (tmp, sx, sy, op); |
974 | |
928 | |
975 | /* This is used for tracking spells so that one effect doesn't hit |
929 | /* This is used for tracking spells so that one effect doesn't hit |
976 | * a single space too many times. |
930 | * a single space too many times. |
977 | */ |
931 | */ |
978 | tmp->stats.maxhp = tmp->count; |
932 | tmp->stats.maxhp = tmp->count; |
… | |
… | |
997 | void |
951 | void |
998 | animate_bomb (object *op) |
952 | animate_bomb (object *op) |
999 | { |
953 | { |
1000 | int i; |
954 | int i; |
1001 | object *env, *tmp; |
955 | object *env, *tmp; |
1002 | archetype *at; |
|
|
1003 | |
956 | |
1004 | if (op->state != NUM_ANIMATIONS (op) - 1) |
957 | if (op->state != NUM_ANIMATIONS (op) - 1) |
1005 | return; |
958 | return; |
1006 | |
959 | |
1007 | env = object_get_env_recursive (op); |
960 | env = object_get_env_recursive (op); |
… | |
… | |
1012 | return; |
965 | return; |
1013 | |
966 | |
1014 | if (env->type == PLAYER) |
967 | if (env->type == PLAYER) |
1015 | esrv_del_item (env->contr, op->count); |
968 | esrv_del_item (env->contr, op->count); |
1016 | |
969 | |
1017 | op->remove (); |
970 | if (!(op = op->insert_at (env, op))) |
1018 | op->x = env->x; |
|
|
1019 | op->y = env->y; |
|
|
1020 | if ((op = insert_ob_in_map (op, env->map, op, 0)) == NULL) |
|
|
1021 | return; |
971 | return; |
1022 | } |
972 | } |
1023 | |
973 | |
1024 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding |
974 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding |
1025 | // on a safe map. I don't like this special casing, but it seems to be neccessary |
975 | // on a safe map. I don't like this special casing, but it seems to be neccessary |
1026 | // as bombs can be carried. |
976 | // as bombs can be carried. |
1027 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
977 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
1028 | { |
978 | { |
1029 | op->remove (); |
|
|
1030 | op->destroy (0); |
979 | op->destroy (); |
1031 | return; |
980 | return; |
1032 | } |
981 | } |
1033 | |
982 | |
1034 | /* This copies a lot of the code from the fire bullet, |
983 | /* This copies a lot of the code from the fire bullet, |
1035 | * but using the cast_bullet isn't really feasible, |
984 | * but using the cast_bullet isn't really feasible, |
1036 | * so just set up the appropriate values. |
985 | * so just set up the appropriate values. |
1037 | */ |
986 | */ |
1038 | at = archetype::find (SPLINT); |
987 | if (archetype *at = archetype::find (SPLINT)) |
1039 | if (at) |
|
|
1040 | { |
988 | { |
1041 | for (i = 1; i < 9; i++) |
989 | for (i = 1; i < 9; i++) |
1042 | { |
990 | { |
1043 | if (out_of_map (op->map, op->x + freearr_x[i], op->y + freearr_x[i])) |
991 | if (out_of_map (op->map, op->x + freearr_x[i], op->y + freearr_x[i])) |
1044 | continue; |
992 | continue; |
|
|
993 | |
1045 | tmp = arch_to_object (at); |
994 | tmp = arch_to_object (at); |
1046 | tmp->direction = i; |
995 | tmp->direction = i; |
1047 | tmp->range = op->range; |
996 | tmp->range = op->range; |
1048 | tmp->stats.dam = op->stats.dam; |
997 | tmp->stats.dam = op->stats.dam; |
1049 | tmp->duration = op->duration; |
998 | tmp->duration = op->duration; |
1050 | tmp->attacktype = op->attacktype; |
999 | tmp->attacktype = op->attacktype; |
1051 | copy_owner (tmp, op); |
1000 | tmp->set_owner (op); |
1052 | if (op->skill && op->skill != tmp->skill) |
1001 | if (op->skill && op->skill != tmp->skill) |
1053 | { |
|
|
1054 | tmp->skill = op->skill; |
1002 | tmp->skill = op->skill; |
1055 | } |
1003 | |
1056 | if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) |
1004 | if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) |
1057 | SET_ANIMATION (tmp, i); |
1005 | SET_ANIMATION (tmp, i); |
1058 | tmp->x = op->x + freearr_x[i]; |
1006 | |
1059 | tmp->y = op->y + freearr_x[i]; |
1007 | op->map->insert (tmp, op->x + freearr_x[i], op->y + freearr_x[i], op); |
1060 | insert_ob_in_map (tmp, op->map, op, 0); |
|
|
1061 | move_bullet (tmp); |
1008 | move_bullet (tmp); |
1062 | } |
1009 | } |
1063 | } |
1010 | } |
1064 | |
1011 | |
1065 | explode_bullet (op); |
1012 | explode_bullet (op); |
… | |
… | |
1086 | tmp->range = spell->range + SP_level_range_adjust (caster, spell); |
1033 | tmp->range = spell->range + SP_level_range_adjust (caster, spell); |
1087 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1034 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1088 | tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); |
1035 | tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); |
1089 | tmp->attacktype = spell->attacktype; |
1036 | tmp->attacktype = spell->attacktype; |
1090 | |
1037 | |
1091 | set_owner (tmp, op); |
1038 | tmp->set_owner (op); |
1092 | set_spell_skill (op, caster, spell, tmp); |
1039 | set_spell_skill (op, caster, spell, tmp); |
1093 | tmp->x = dx; |
1040 | |
1094 | tmp->y = dy; |
1041 | m->insert (tmp, dx, dy, op); |
1095 | insert_ob_in_map (tmp, m, op, 0); |
|
|
1096 | return 1; |
1042 | return 1; |
1097 | } |
1043 | } |
1098 | |
1044 | |
1099 | /**************************************************************************** |
1045 | /**************************************************************************** |
1100 | * |
1046 | * |
… | |
… | |
1139 | if (GET_MAP_MOVE_BLOCK (mp, x, y) & MOVE_FLY_LOW) |
1085 | if (GET_MAP_MOVE_BLOCK (mp, x, y) & MOVE_FLY_LOW) |
1140 | return NULL; |
1086 | return NULL; |
1141 | |
1087 | |
1142 | if (mflags & P_IS_ALIVE) |
1088 | if (mflags & P_IS_ALIVE) |
1143 | { |
1089 | { |
1144 | for (target = get_map_ob (mp, x, y); target; target = target->above) |
1090 | for (target = GET_MAP_OB (mp, x, y); target; target = target->above) |
1145 | { |
1091 | { |
1146 | if (QUERY_FLAG (target->head ? target->head : target, FLAG_MONSTER)) |
1092 | if (QUERY_FLAG (target->head ? target->head : target, FLAG_MONSTER)) |
1147 | { |
1093 | { |
1148 | return target; |
1094 | return target; |
1149 | } |
1095 | } |
… | |
… | |
1216 | if (effect->attacktype & AT_DEATH) |
1162 | if (effect->attacktype & AT_DEATH) |
1217 | { |
1163 | { |
1218 | effect->level = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1164 | effect->level = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1219 | |
1165 | |
1220 | /* casting death spells at undead isn't a good thing */ |
1166 | /* casting death spells at undead isn't a good thing */ |
1221 | if QUERY_FLAG |
|
|
1222 | (target, FLAG_UNDEAD) |
1167 | if (QUERY_FLAG (target, FLAG_UNDEAD)) |
1223 | { |
1168 | { |
1224 | if (random_roll (0, 2, op, PREFER_LOW)) |
1169 | if (random_roll (0, 2, op, PREFER_LOW)) |
1225 | { |
1170 | { |
1226 | new_draw_info (NDI_UNIQUE, 0, op, "Idiot! Your spell boomerangs!"); |
1171 | new_draw_info (NDI_UNIQUE, 0, op, "Idiot! Your spell boomerangs!"); |
1227 | effect->x = op->x; |
1172 | effect->x = op->x; |
… | |
… | |
1229 | } |
1174 | } |
1230 | else |
1175 | else |
1231 | { |
1176 | { |
1232 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target)); |
1177 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target)); |
1233 | target->stats.hp = target->stats.maxhp * 2; |
1178 | target->stats.hp = target->stats.maxhp * 2; |
1234 | effect->destroy (0); |
1179 | effect->destroy (); |
1235 | return 0; |
1180 | return 0; |
1236 | } |
1181 | } |
1237 | } |
1182 | } |
1238 | } |
1183 | } |
1239 | else |
1184 | else |
1240 | { |
1185 | { |
1241 | /* how much woe to inflict :) */ |
1186 | /* how much woe to inflict :) */ |
1242 | effect->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1187 | effect->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1243 | } |
1188 | } |
1244 | |
1189 | |
1245 | set_owner (effect, op); |
1190 | effect->set_owner (op); |
1246 | set_spell_skill (op, caster, spell, effect); |
1191 | set_spell_skill (op, caster, spell, effect); |
1247 | |
1192 | |
1248 | /* ok, tell it where to be, and insert! */ |
1193 | /* ok, tell it where to be, and insert! */ |
1249 | effect->x = target->x; |
1194 | effect->insert_at (target, op); |
1250 | effect->y = target->y; |
|
|
1251 | insert_ob_in_map (effect, target->map, op, 0); |
|
|
1252 | |
1195 | |
1253 | return 1; |
1196 | return 1; |
1254 | } |
1197 | } |
1255 | |
1198 | |
1256 | |
1199 | |
… | |
… | |
1270 | sint16 new_x, new_y; |
1213 | sint16 new_x, new_y; |
1271 | maptile *m; |
1214 | maptile *m; |
1272 | |
1215 | |
1273 | if (op->range-- <= 0) |
1216 | if (op->range-- <= 0) |
1274 | { |
1217 | { |
1275 | op->remove (); |
|
|
1276 | op->destroy (0); |
1218 | op->destroy (); |
1277 | return; |
1219 | return; |
1278 | } |
1220 | } |
1279 | |
1221 | |
1280 | owner = get_owner (op); |
1222 | owner = op->owner; |
1281 | #if 0 |
1223 | #if 0 |
1282 | /* It'd make things nastier if this wasn't here - spells cast by |
1224 | /* It'd make things nastier if this wasn't here - spells cast by |
1283 | * monster that are then killed would continue to survive |
1225 | * monster that are then killed would continue to survive |
1284 | */ |
1226 | */ |
1285 | if (owner == NULL) |
1227 | if (owner == NULL) |
1286 | { |
1228 | { |
1287 | op->remove (); |
|
|
1288 | op->destroy (0); |
1229 | op->destroy (); |
1289 | return; |
1230 | return; |
1290 | } |
1231 | } |
1291 | #endif |
1232 | #endif |
1292 | |
1233 | |
1293 | new_x = op->x + DIRX (op); |
1234 | new_x = op->x + DIRX (op); |
… | |
… | |
1300 | hit_map (op, op->direction, AT_MAGIC, 1); |
1241 | hit_map (op, op->direction, AT_MAGIC, 1); |
1301 | /* Basically, missile only hits one thing then goes away. |
1242 | /* Basically, missile only hits one thing then goes away. |
1302 | * we need to remove it if someone hasn't already done so. |
1243 | * we need to remove it if someone hasn't already done so. |
1303 | */ |
1244 | */ |
1304 | if (!op->destroyed ()) |
1245 | if (!op->destroyed ()) |
1305 | op->destroy (0); |
1246 | op->destroy (); |
1306 | |
1247 | |
1307 | return; |
1248 | return; |
1308 | } |
1249 | } |
1309 | |
1250 | |
1310 | op->remove (); |
1251 | op->remove (); |
1311 | |
1252 | |
1312 | if (!op->direction || (mflags & P_OUT_OF_MAP)) |
1253 | if (!op->direction || (mflags & P_OUT_OF_MAP)) |
1313 | { |
1254 | { |
1314 | op->destroy (0); |
1255 | op->destroy (); |
1315 | return; |
1256 | return; |
1316 | } |
1257 | } |
1317 | |
1258 | |
1318 | op->x = new_x; |
1259 | i = spell_find_dir (m, new_x, new_y, op->owner); |
1319 | op->y = new_y; |
|
|
1320 | op->map = m; |
|
|
1321 | i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); |
|
|
1322 | if (i > 0 && i != op->direction) |
1260 | if (i > 0 && i != op->direction) |
1323 | { |
1261 | { |
1324 | op->direction = i; |
1262 | op->direction = i; |
1325 | SET_ANIMATION (op, op->direction); |
1263 | SET_ANIMATION (op, op->direction); |
1326 | } |
1264 | } |
1327 | |
1265 | |
1328 | insert_ob_in_map (op, op->map, op, 0); |
1266 | m->insert (op, new_x, new_y, op); |
1329 | } |
1267 | } |
1330 | |
1268 | |
1331 | /**************************************************************************** |
1269 | /**************************************************************************** |
1332 | * Destruction |
1270 | * Destruction |
1333 | ****************************************************************************/ |
1271 | ****************************************************************************/ |
… | |
… | |
1411 | for (j = -range; j < range; j++) |
1349 | for (j = -range; j < range; j++) |
1412 | { |
1350 | { |
1413 | m = op->map; |
1351 | m = op->map; |
1414 | sx = op->x + i; |
1352 | sx = op->x + i; |
1415 | sy = op->y + j; |
1353 | sy = op->y + j; |
|
|
1354 | |
1416 | mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); |
1355 | mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); |
1417 | if (mflags & P_OUT_OF_MAP) |
1356 | if (mflags & P_OUT_OF_MAP) |
1418 | continue; |
1357 | continue; |
|
|
1358 | |
1419 | if (mflags & P_IS_ALIVE) |
1359 | if (mflags & P_IS_ALIVE) |
1420 | { |
1360 | { |
1421 | for (tmp = get_map_ob (m, sx, sy); tmp; tmp = tmp->above) |
1361 | for (tmp = GET_MAP_OB (m, sx, sy); tmp; tmp = tmp->above) |
1422 | { |
|
|
1423 | if (QUERY_FLAG (tmp, FLAG_ALIVE) || tmp->type == PLAYER) |
1362 | if (QUERY_FLAG (tmp, FLAG_ALIVE) || tmp->type == PLAYER) |
1424 | break; |
1363 | break; |
1425 | } |
1364 | |
1426 | if (tmp) |
1365 | if (tmp) |
1427 | { |
1366 | { |
1428 | if (tmp->head) |
1367 | if (tmp->head) |
1429 | tmp = tmp->head; |
1368 | tmp = tmp->head; |
1430 | |
1369 | |
… | |
… | |
1433 | { |
1372 | { |
1434 | if (spell_ob->subtype == SP_DESTRUCTION) |
1373 | if (spell_ob->subtype == SP_DESTRUCTION) |
1435 | { |
1374 | { |
1436 | hit_player (tmp, dam, op, spell_ob->attacktype, 0); |
1375 | hit_player (tmp, dam, op, spell_ob->attacktype, 0); |
1437 | if (spell_ob->other_arch) |
1376 | if (spell_ob->other_arch) |
1438 | { |
|
|
1439 | tmp = arch_to_object (spell_ob->other_arch); |
1377 | m->insert (arch_to_object (spell_ob->other_arch), sx, sy, op); |
1440 | tmp->x = sx; |
|
|
1441 | tmp->y = sy; |
|
|
1442 | insert_ob_in_map (tmp, m, op, 0); |
|
|
1443 | } |
|
|
1444 | } |
1378 | } |
1445 | else if (spell_ob->subtype == SP_FAERY_FIRE && tmp->resist[ATNR_MAGIC] != 100) |
1379 | else if (spell_ob->subtype == SP_FAERY_FIRE && tmp->resist[ATNR_MAGIC] != 100) |
1446 | { |
1380 | { |
1447 | if (make_object_glow (tmp, 1, dur) && spell_ob->other_arch) |
1381 | if (make_object_glow (tmp, 1, dur) && spell_ob->other_arch) |
1448 | { |
|
|
1449 | object *effect = arch_to_object (spell_ob->other_arch); |
1382 | m->insert (arch_to_object (spell_ob->other_arch), sx, sy, op); |
1450 | |
|
|
1451 | effect->x = sx; |
|
|
1452 | effect->y = sy; |
|
|
1453 | insert_ob_in_map (effect, m, op, 0); |
|
|
1454 | } |
|
|
1455 | } |
1383 | } |
1456 | } |
1384 | } |
1457 | } |
1385 | } |
1458 | } |
1386 | } |
1459 | } |
1387 | } |
1460 | } |
1388 | } |
|
|
1389 | |
1461 | op->skill = skill; |
1390 | op->skill = skill; |
1462 | return 1; |
1391 | return 1; |
1463 | } |
1392 | } |
1464 | |
1393 | |
1465 | /*************************************************************************** |
1394 | /*************************************************************************** |
… | |
… | |
1549 | force->stats.ac = spell_ob->stats.ac; |
1478 | force->stats.ac = spell_ob->stats.ac; |
1550 | force->stats.wc = spell_ob->stats.wc; |
1479 | force->stats.wc = spell_ob->stats.wc; |
1551 | |
1480 | |
1552 | change_abil (tmp, force); /* Mostly to display any messages */ |
1481 | change_abil (tmp, force); /* Mostly to display any messages */ |
1553 | insert_ob_in_ob (force, tmp); |
1482 | insert_ob_in_ob (force, tmp); |
1554 | fix_player (tmp); |
1483 | tmp->update_stats (); |
1555 | return 1; |
1484 | return 1; |
1556 | |
1485 | |
1557 | } |
1486 | } |
1558 | |
1487 | |
1559 | |
1488 | |
… | |
… | |
1610 | |
1539 | |
1611 | /* If there is nothing living on this space, no need to go further */ |
1540 | /* If there is nothing living on this space, no need to go further */ |
1612 | if (!(mflags & P_IS_ALIVE)) |
1541 | if (!(mflags & P_IS_ALIVE)) |
1613 | continue; |
1542 | continue; |
1614 | |
1543 | |
1615 | for (tmp = get_map_ob (m, nx, ny); tmp; tmp = tmp->above) |
1544 | for (tmp = GET_MAP_OB (m, nx, ny); tmp; tmp = tmp->above) |
1616 | if (QUERY_FLAG (tmp, FLAG_MONSTER)) |
1545 | if (QUERY_FLAG (tmp, FLAG_MONSTER)) |
1617 | break; |
1546 | break; |
1618 | |
1547 | |
1619 | /* There can be living objects that are not monsters */ |
1548 | /* There can be living objects that are not monsters */ |
1620 | if (!tmp || tmp->type == PLAYER) |
1549 | if (!tmp || tmp->type == PLAYER) |
… | |
… | |
1700 | if (QUERY_FLAG (spell, FLAG_BERSERK) && !QUERY_FLAG (head, FLAG_BERSERK)) |
1629 | if (QUERY_FLAG (spell, FLAG_BERSERK) && !QUERY_FLAG (head, FLAG_BERSERK)) |
1701 | { |
1630 | { |
1702 | SET_FLAG (head, FLAG_BERSERK); |
1631 | SET_FLAG (head, FLAG_BERSERK); |
1703 | done_one = 1; |
1632 | done_one = 1; |
1704 | } |
1633 | } |
|
|
1634 | |
1705 | /* charm */ |
1635 | /* charm */ |
1706 | if (QUERY_FLAG (spell, FLAG_NO_ATTACK) && !QUERY_FLAG (head, FLAG_FRIENDLY)) |
1636 | if (QUERY_FLAG (spell, FLAG_NO_ATTACK) && !QUERY_FLAG (head, FLAG_FRIENDLY)) |
1707 | { |
1637 | { |
1708 | SET_FLAG (head, FLAG_FRIENDLY); |
|
|
1709 | /* Prevent uncontolled outbreaks of self replicating monsters. |
1638 | /* Prevent uncontolled outbreaks of self replicating monsters. |
1710 | Typical use case is charm, go somwhere, use aggravation to make hostile. |
1639 | Typical use case is charm, go somwhere, use aggravation to make hostile. |
1711 | This could lead to fun stuff like mice outbreak in bigworld and server crawl. */ |
1640 | This could lead to fun stuff like mice outbreak in bigworld and server crawl. */ |
1712 | CLEAR_FLAG (head, FLAG_GENERATOR); |
1641 | CLEAR_FLAG (head, FLAG_GENERATOR); |
1713 | set_owner (head, op); |
1642 | head->set_owner (op); |
1714 | set_spell_skill (op, caster, spell, head); |
1643 | set_spell_skill (op, caster, spell, head); |
1715 | add_friendly_object (head); |
1644 | add_friendly_object (head); |
1716 | head->attack_movement = PETMOVE; |
1645 | head->attack_movement = PETMOVE; |
1717 | done_one = 1; |
1646 | done_one = 1; |
1718 | change_exp (op, head->stats.exp / 2, head->skill, SK_EXP_ADD_SKILL); |
1647 | change_exp (op, head->stats.exp / 2, head->skill, SK_EXP_ADD_SKILL); |
1719 | head->stats.exp = 0; |
1648 | head->stats.exp = 0; |
1720 | } |
1649 | } |
1721 | |
1650 | |
1722 | /* If a monster was effected, put an effect in */ |
1651 | /* If a monster was effected, put an effect in */ |
1723 | if (done_one && spell->other_arch) |
1652 | if (done_one && spell->other_arch) |
1724 | { |
|
|
1725 | tmp = arch_to_object (spell->other_arch); |
1653 | m->insert (arch_to_object (spell->other_arch), nx, ny, op); |
1726 | tmp->x = nx; |
|
|
1727 | tmp->y = ny; |
|
|
1728 | insert_ob_in_map (tmp, m, op, 0); |
|
|
1729 | } |
|
|
1730 | } /* for y */ |
1654 | } /* for y */ |
1731 | |
1655 | |
1732 | return 1; |
1656 | return 1; |
1733 | } |
1657 | } |
1734 | |
1658 | |
… | |
… | |
1746 | int i, j, dam_save, dir, mflags; |
1670 | int i, j, dam_save, dir, mflags; |
1747 | sint16 nx, ny, hx, hy; |
1671 | sint16 nx, ny, hx, hy; |
1748 | object *owner; |
1672 | object *owner; |
1749 | maptile *m; |
1673 | maptile *m; |
1750 | |
1674 | |
1751 | owner = get_owner (op); |
1675 | owner = op->owner; |
1752 | |
1676 | |
1753 | /* the following logic makes sure that the ball doesn't move into a wall, |
1677 | /* the following logic makes sure that the ball doesn't move into a wall, |
1754 | * and makes sure that it will move along a wall to try and get at it's |
1678 | * and makes sure that it will move along a wall to try and get at it's |
1755 | * victim. The block immediately below more or less chooses a random |
1679 | * victim. The block immediately below more or less chooses a random |
1756 | * offset to move the ball, eg, keep it mostly on course, with some |
1680 | * offset to move the ball, eg, keep it mostly on course, with some |
… | |
… | |
1785 | nx = op->x; |
1709 | nx = op->x; |
1786 | ny = op->y; |
1710 | ny = op->y; |
1787 | m = op->map; |
1711 | m = op->map; |
1788 | } |
1712 | } |
1789 | |
1713 | |
1790 | op->remove (); |
1714 | m->insert (op, nx, ny, op); |
1791 | op->y = ny; |
|
|
1792 | op->x = nx; |
|
|
1793 | insert_ob_in_map (op, m, op, 0); |
|
|
1794 | |
1715 | |
1795 | dam_save = op->stats.dam; /* save the original dam: we do halfdam on |
1716 | dam_save = op->stats.dam; /* save the original dam: we do halfdam on |
1796 | surrounding squares */ |
1717 | surrounding squares */ |
1797 | |
1718 | |
1798 | /* loop over current square and neighbors to hit. |
1719 | /* loop over current square and neighbors to hit. |
… | |
… | |
1824 | |
1745 | |
1825 | } |
1746 | } |
1826 | |
1747 | |
1827 | /* insert the other arch */ |
1748 | /* insert the other arch */ |
1828 | if (op->other_arch && !(OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, hx, hy)))) |
1749 | if (op->other_arch && !(OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, hx, hy)))) |
1829 | { |
1750 | m->insert (arch_to_object (op->other_arch), hx, hy, op); |
1830 | new_ob = arch_to_object (op->other_arch); |
|
|
1831 | new_ob->x = hx; |
|
|
1832 | new_ob->y = hy; |
|
|
1833 | insert_ob_in_map (new_ob, m, op, 0); |
|
|
1834 | } |
|
|
1835 | } |
1751 | } |
1836 | |
1752 | |
1837 | /* restore to the center location and damage */ |
1753 | /* restore to the center location and damage */ |
1838 | op->stats.dam = dam_save; |
1754 | op->stats.dam = dam_save; |
1839 | |
1755 | |
1840 | i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); |
1756 | i = spell_find_dir (op->map, op->x, op->y, op->owner); |
1841 | |
1757 | |
1842 | if (i >= 0) |
1758 | if (i >= 0) |
1843 | { /* we have a preferred direction! */ |
1759 | { /* we have a preferred direction! */ |
1844 | /* pick another direction if the preferred dir is blocked. */ |
1760 | /* pick another direction if the preferred dir is blocked. */ |
1845 | if (get_map_flags (op->map, &m, nx + freearr_x[i], ny + freearr_y[i], &hx, &hy) & P_OUT_OF_MAP || |
1761 | if (get_map_flags (op->map, &m, nx + freearr_x[i], ny + freearr_y[i], &hx, &hy) & P_OUT_OF_MAP || |
1846 | OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, hx, hy))) |
1762 | OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, hx, hy))) |
1847 | { |
|
|
1848 | i = absdir (i + rndm (0, 2) - 1); /* -1, 0, +1 */ |
1763 | i = absdir (i + rndm (0, 2) - 1); /* -1, 0, +1 */ |
1849 | } |
1764 | |
1850 | op->direction = i; |
1765 | op->direction = i; |
1851 | } |
1766 | } |
1852 | } |
1767 | } |
1853 | |
1768 | |
1854 | |
1769 | |
… | |
… | |
1871 | maptile *m; |
1786 | maptile *m; |
1872 | #endif |
1787 | #endif |
1873 | int basedir; |
1788 | int basedir; |
1874 | object *owner; |
1789 | object *owner; |
1875 | |
1790 | |
1876 | owner = get_owner (op); |
1791 | owner = op->owner; |
1877 | if (op->duration == 0 || owner == NULL) |
1792 | if (op->duration == 0 || owner == NULL) |
1878 | { |
1793 | { |
1879 | op->remove (); |
|
|
1880 | op->destroy (0); |
1794 | op->destroy (); |
1881 | return; |
1795 | return; |
1882 | } |
1796 | } |
|
|
1797 | |
1883 | op->duration--; |
1798 | op->duration--; |
1884 | |
1799 | |
1885 | basedir = op->direction; |
1800 | basedir = op->direction; |
1886 | if (basedir == 0) |
1801 | if (basedir == 0) |
1887 | { |
1802 | { |
… | |
… | |
1984 | |
1899 | |
1985 | if (!spell->other_arch) |
1900 | if (!spell->other_arch) |
1986 | return 0; |
1901 | return 0; |
1987 | |
1902 | |
1988 | tmp = get_archetype (SWARM_SPELL); |
1903 | tmp = get_archetype (SWARM_SPELL); |
1989 | tmp->x = op->x; |
|
|
1990 | tmp->y = op->y; |
|
|
1991 | set_owner (tmp, op); /* needed so that if swarm elements kill, caster gets xp. */ |
1904 | tmp->set_owner (op); /* needed so that if swarm elements kill, caster gets xp. */ |
1992 | set_spell_skill (op, caster, spell, tmp); |
1905 | set_spell_skill (op, caster, spell, tmp); |
1993 | |
1906 | |
1994 | tmp->level = caster_level (caster, spell); /*needed later, to get level dep. right. */ |
1907 | tmp->level = caster_level (caster, spell); /*needed later, to get level dep. right. */ |
1995 | tmp->spell = arch_to_object (spell->other_arch); |
1908 | tmp->spell = arch_to_object (spell->other_arch); |
1996 | |
1909 | |
1997 | tmp->attacktype = tmp->spell->attacktype; |
1910 | tmp->attacktype = tmp->spell->attacktype; |
1998 | |
1911 | |
1999 | if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) |
1912 | if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) |
2000 | { |
|
|
2001 | if (!tailor_god_spell (tmp, op)) |
1913 | if (!tailor_god_spell (tmp, op)) |
2002 | return 1; |
1914 | return 1; |
2003 | } |
1915 | |
2004 | tmp->duration = SP_level_duration_adjust (caster, spell); |
1916 | tmp->duration = SP_level_duration_adjust (caster, spell); |
2005 | for (i = 0; i < spell->duration; i++) |
1917 | for (i = 0; i < spell->duration; i++) |
2006 | tmp->duration += die_roll (1, 3, op, PREFER_HIGH); |
1918 | tmp->duration += die_roll (1, 3, op, PREFER_HIGH); |
2007 | |
1919 | |
2008 | tmp->direction = dir; |
1920 | tmp->direction = dir; |
2009 | tmp->invisible = 1; |
1921 | tmp->invisible = 1; |
2010 | insert_ob_in_map (tmp, op->map, op, 0); |
1922 | |
|
|
1923 | tmp->insert_at (op, op); |
2011 | return 1; |
1924 | return 1; |
2012 | } |
1925 | } |
2013 | |
1926 | |
2014 | |
1927 | |
2015 | /* See the spells documentation file for why this is its own |
1928 | /* See the spells documentation file for why this is its own |
… | |
… | |
2043 | return 0; |
1956 | return 0; |
2044 | } |
1957 | } |
2045 | |
1958 | |
2046 | if (mflags & P_IS_ALIVE && spell->attacktype) |
1959 | if (mflags & P_IS_ALIVE && spell->attacktype) |
2047 | { |
1960 | { |
2048 | for (target = get_map_ob (m, x, y); target; target = target->above) |
1961 | for (target = GET_MAP_OB (m, x, y); target; target = target->above) |
2049 | if (QUERY_FLAG (target, FLAG_MONSTER)) |
1962 | if (QUERY_FLAG (target, FLAG_MONSTER)) |
2050 | { |
1963 | { |
2051 | /* oky doky. got a target monster. Lets make a blinding attack */ |
1964 | /* oky doky. got a target monster. Lets make a blinding attack */ |
2052 | if (target->head) |
1965 | if (target->head) |
2053 | target = target->head; |
1966 | target = target->head; |
… | |
… | |
2075 | { |
1988 | { |
2076 | tmp->glow_radius = spell->range + SP_level_range_adjust (caster, spell); |
1989 | tmp->glow_radius = spell->range + SP_level_range_adjust (caster, spell); |
2077 | if (tmp->glow_radius > MAX_LIGHT_RADII) |
1990 | if (tmp->glow_radius > MAX_LIGHT_RADII) |
2078 | tmp->glow_radius = MAX_LIGHT_RADII; |
1991 | tmp->glow_radius = MAX_LIGHT_RADII; |
2079 | } |
1992 | } |
2080 | tmp->x = x; |
1993 | |
2081 | tmp->y = y; |
1994 | m->insert (tmp, x, y, op); |
2082 | insert_ob_in_map (tmp, m, op, 0); |
|
|
2083 | return 1; |
1995 | return 1; |
2084 | } |
1996 | } |
2085 | |
1997 | |
2086 | |
1998 | |
2087 | |
1999 | |
… | |
… | |
2135 | |
2047 | |
2136 | /* Only bother looking on this space if there is something living here */ |
2048 | /* Only bother looking on this space if there is something living here */ |
2137 | if (mflags & P_IS_ALIVE) |
2049 | if (mflags & P_IS_ALIVE) |
2138 | { |
2050 | { |
2139 | /* search this square for a victim */ |
2051 | /* search this square for a victim */ |
2140 | for (walk = get_map_ob (m, x, y); walk; walk = walk->above) |
2052 | for (walk = GET_MAP_OB (m, x, y); walk; walk = walk->above) |
2141 | if (QUERY_FLAG (walk, FLAG_MONSTER) || (walk->type == PLAYER)) |
2053 | if (QUERY_FLAG (walk, FLAG_MONSTER) || (walk->type == PLAYER)) |
2142 | { /* found a victim */ |
2054 | { /* found a victim */ |
2143 | object *disease = arch_to_object (spell->other_arch); |
2055 | object *disease = arch_to_object (spell->other_arch); |
2144 | |
2056 | |
2145 | set_owner (disease, op); |
2057 | disease->set_owner (op); |
2146 | set_spell_skill (op, caster, spell, disease); |
2058 | set_spell_skill (op, caster, spell, disease); |
2147 | disease->stats.exp = 0; |
2059 | disease->stats.exp = 0; |
2148 | disease->level = caster_level (caster, spell); |
2060 | disease->level = caster_level (caster, spell); |
2149 | |
2061 | |
2150 | /* do level adjustments */ |
2062 | /* do level adjustments */ |
… | |
… | |
2199 | { |
2111 | { |
2200 | object *flash; /* visual effect for inflicting disease */ |
2112 | object *flash; /* visual effect for inflicting disease */ |
2201 | |
2113 | |
2202 | new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); |
2114 | new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); |
2203 | |
2115 | |
2204 | disease->destroy (0); /* don't need this one anymore */ |
2116 | disease->destroy (); /* don't need this one anymore */ |
2205 | flash = get_archetype (ARCH_DETECT_MAGIC); |
2117 | walk->map->insert (get_archetype (ARCH_DETECT_MAGIC), x, y, op); |
2206 | flash->x = x; |
|
|
2207 | flash->y = y; |
|
|
2208 | flash->map = walk->map; |
|
|
2209 | insert_ob_in_map (flash, walk->map, op, 0); |
|
|
2210 | return 1; |
2118 | return 1; |
2211 | } |
2119 | } |
|
|
2120 | |
2212 | disease->destroy (0); |
2121 | disease->destroy (); |
2213 | } |
2122 | } |
2214 | } /* if living creature */ |
2123 | } /* if living creature */ |
2215 | } /* for range of spaces */ |
2124 | } /* for range of spaces */ |
|
|
2125 | |
2216 | new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!"); |
2126 | new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!"); |
2217 | return 1; |
2127 | return 1; |
2218 | } |
2128 | } |