… | |
… | |
117 | void |
117 | void |
118 | forklightning (object *op, object *tmp) |
118 | forklightning (object *op, object *tmp) |
119 | { |
119 | { |
120 | int new_dir = 1; /* direction or -1 for left, +1 for right 0 if no new bolt */ |
120 | int new_dir = 1; /* direction or -1 for left, +1 for right 0 if no new bolt */ |
121 | int t_dir; /* stores temporary dir calculation */ |
121 | int t_dir; /* stores temporary dir calculation */ |
122 | mapstruct *m; |
122 | maptile *m; |
123 | sint16 sx, sy; |
123 | sint16 sx, sy; |
124 | object *new_bolt; |
124 | object *new_bolt; |
125 | |
125 | |
126 | /* pick a fork direction. tmp->stats.Con is the left bias |
126 | /* pick a fork direction. tmp->stats.Con is the left bias |
127 | * i.e., the chance in 100 of forking LEFT |
127 | * i.e., the chance in 100 of forking LEFT |
… | |
… | |
140 | |
140 | |
141 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
141 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
142 | return; |
142 | return; |
143 | |
143 | |
144 | /* OK, we made a fork */ |
144 | /* OK, we made a fork */ |
145 | new_bolt = get_object (); |
145 | new_bolt = object::create (); |
146 | copy_object (tmp, new_bolt); |
146 | tmp->copy_to (new_bolt); |
147 | |
147 | |
148 | /* reduce chances of subsequent forking */ |
148 | /* reduce chances of subsequent forking */ |
149 | new_bolt->stats.Dex -= 10; |
149 | new_bolt->stats.Dex -= 10; |
150 | tmp->stats.Dex -= 10; /* less forks from main bolt too */ |
150 | tmp->stats.Dex -= 10; /* less forks from main bolt too */ |
151 | new_bolt->stats.Con += 25 * new_dir; /* adjust the left bias */ |
151 | new_bolt->stats.Con += 25 * new_dir; /* adjust the left bias */ |
… | |
… | |
170 | move_bolt (object *op) |
170 | move_bolt (object *op) |
171 | { |
171 | { |
172 | object *tmp; |
172 | object *tmp; |
173 | int mflags; |
173 | int mflags; |
174 | sint16 x, y; |
174 | sint16 x, y; |
175 | mapstruct *m; |
175 | maptile *m; |
176 | |
176 | |
177 | if (--(op->duration) < 0) |
177 | if (--(op->duration) < 0) |
178 | { |
178 | { |
179 | remove_ob (op); |
179 | op->destroy (); |
180 | free_object (op); |
|
|
181 | return; |
180 | return; |
182 | } |
181 | } |
183 | |
182 | |
184 | hit_map (op, 0, op->attacktype, 1); |
183 | hit_map (op, 0, op->attacktype, 1); |
185 | |
184 | |
… | |
… | |
250 | update_turn_face (op); /* A bolt *must* be IS_TURNABLE */ |
249 | update_turn_face (op); /* A bolt *must* be IS_TURNABLE */ |
251 | return; |
250 | return; |
252 | } |
251 | } |
253 | else |
252 | else |
254 | { /* Create a copy of this object and put it ahead */ |
253 | { /* Create a copy of this object and put it ahead */ |
255 | tmp = get_object (); |
254 | tmp = object::create (); |
256 | copy_object (op, tmp); |
255 | op->copy_to (tmp); |
257 | tmp->speed_left = -0.1; |
256 | tmp->speed_left = -0.1; |
258 | tmp->x += DIRX (tmp), tmp->y += DIRY (tmp); |
257 | tmp->x += DIRX (tmp), tmp->y += DIRY (tmp); |
259 | tmp = insert_ob_in_map (tmp, op->map, op, 0); |
258 | tmp = insert_ob_in_map (tmp, op->map, op, 0); |
260 | /* To make up for the decrease at the top of the function */ |
259 | /* To make up for the decrease at the top of the function */ |
261 | tmp->duration++; |
260 | tmp->duration++; |
… | |
… | |
320 | tmp->map = op->map; |
319 | tmp->map = op->map; |
321 | |
320 | |
322 | mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); |
321 | mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); |
323 | if (mflags & P_OUT_OF_MAP) |
322 | if (mflags & P_OUT_OF_MAP) |
324 | { |
323 | { |
325 | free_object (tmp); |
324 | tmp->destroy (); |
326 | return 0; |
325 | return 0; |
327 | } |
326 | } |
|
|
327 | |
328 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
328 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
329 | { |
329 | { |
330 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
330 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
331 | { |
331 | { |
332 | free_object (tmp); |
332 | tmp->destroy (); |
333 | return 0; |
333 | return 0; |
334 | } |
334 | } |
|
|
335 | |
335 | tmp->x = op->x; |
336 | tmp->x = op->x; |
336 | tmp->y = op->y; |
337 | tmp->y = op->y; |
337 | tmp->direction = absdir (tmp->direction + 4); |
338 | tmp->direction = absdir (tmp->direction + 4); |
338 | tmp->map = op->map; |
339 | tmp->map = op->map; |
339 | } |
340 | } |
|
|
341 | |
340 | if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) |
342 | if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) |
341 | move_bolt (tmp); |
343 | move_bolt (tmp); |
|
|
344 | |
342 | return 1; |
345 | return 1; |
343 | } |
346 | } |
344 | |
347 | |
345 | |
348 | |
346 | |
349 | |
… | |
… | |
356 | */ |
359 | */ |
357 | void |
360 | void |
358 | explosion (object *op) |
361 | explosion (object *op) |
359 | { |
362 | { |
360 | object *tmp; |
363 | object *tmp; |
361 | mapstruct *m = op->map; |
364 | maptile *m = op->map; |
362 | int i; |
365 | int i; |
363 | |
366 | |
364 | if (--(op->duration) < 0) |
367 | if (--(op->duration) < 0) |
365 | { |
368 | { |
366 | remove_ob (op); |
369 | op->destroy (); |
367 | free_object (op); |
|
|
368 | return; |
370 | return; |
369 | } |
371 | } |
|
|
372 | |
370 | hit_map (op, 0, op->attacktype, 0); |
373 | hit_map (op, 0, op->attacktype, 0); |
371 | |
374 | |
372 | if (op->range > 0) |
375 | if (op->range > 0) |
373 | { |
376 | { |
374 | for (i = 1; i < 9; i++) |
377 | for (i = 1; i < 9; i++) |
… | |
… | |
380 | /* ok_to_put_more already does things like checks for walls, |
383 | /* ok_to_put_more already does things like checks for walls, |
381 | * out of map, etc. |
384 | * out of map, etc. |
382 | */ |
385 | */ |
383 | if (ok_to_put_more (op->map, dx, dy, op, op->attacktype)) |
386 | if (ok_to_put_more (op->map, dx, dy, op, op->attacktype)) |
384 | { |
387 | { |
385 | tmp = get_object (); |
388 | tmp = object::create (); |
386 | copy_object (op, tmp); |
389 | op->copy_to (tmp); |
387 | tmp->state = 0; |
390 | tmp->state = 0; |
388 | tmp->speed_left = -0.21; |
391 | tmp->speed_left = -0.21; |
389 | tmp->range--; |
392 | tmp->range--; |
390 | tmp->value = 0; |
393 | tmp->value = 0; |
391 | tmp->x = dx; |
394 | tmp->x = dx; |
… | |
… | |
402 | * explode. |
405 | * explode. |
403 | */ |
406 | */ |
404 | void |
407 | void |
405 | explode_bullet (object *op) |
408 | explode_bullet (object *op) |
406 | { |
409 | { |
407 | tag_t op_tag = op->count; |
|
|
408 | object *tmp, *owner; |
410 | object *tmp, *owner; |
409 | |
411 | |
410 | if (op->other_arch == NULL) |
412 | if (op->other_arch == NULL) |
411 | { |
413 | { |
412 | LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); |
414 | LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); |
413 | remove_ob (op); |
415 | op->destroy (); |
414 | free_object (op); |
|
|
415 | return; |
416 | return; |
416 | } |
417 | } |
417 | |
418 | |
418 | if (op->env) |
419 | if (op->env) |
419 | { |
420 | { |
… | |
… | |
421 | |
422 | |
422 | env = object_get_env_recursive (op); |
423 | env = object_get_env_recursive (op); |
423 | if (env->map == NULL || out_of_map (env->map, env->x, env->y)) |
424 | if (env->map == NULL || out_of_map (env->map, env->x, env->y)) |
424 | { |
425 | { |
425 | LOG (llevError, "BUG: explode_bullet(): env out of map\n"); |
426 | LOG (llevError, "BUG: explode_bullet(): env out of map\n"); |
426 | remove_ob (op); |
427 | op->destroy (); |
427 | free_object (op); |
|
|
428 | return; |
428 | return; |
429 | } |
429 | } |
|
|
430 | |
430 | remove_ob (op); |
431 | op->remove (); |
431 | op->x = env->x; |
432 | op->x = env->x; |
432 | op->y = env->y; |
433 | op->y = env->y; |
433 | insert_ob_in_map (op, env->map, op, INS_NO_MERGE | INS_NO_WALK_ON); |
434 | insert_ob_in_map (op, env->map, op, INS_NO_MERGE | INS_NO_WALK_ON); |
434 | } |
435 | } |
435 | else if (out_of_map (op->map, op->x, op->y)) |
436 | else if (out_of_map (op->map, op->x, op->y)) |
436 | { |
437 | { |
437 | LOG (llevError, "BUG: explode_bullet(): op out of map\n"); |
438 | LOG (llevError, "BUG: explode_bullet(): op out of map\n"); |
438 | remove_ob (op); |
439 | op->destroy (); |
439 | free_object (op); |
|
|
440 | return; |
440 | return; |
441 | } |
441 | } |
442 | |
442 | |
443 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent explosions of any kind on safe maps |
443 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent explosions of any kind on safe maps |
444 | // NOTE: If this breaks something important: remove this. I can't think of anything |
444 | // NOTE: If this breaks something important: remove this. I can't think of anything |
445 | // bad at the moment that might happen from this. |
445 | // bad at the moment that might happen from this. |
446 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
446 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
447 | { |
447 | { |
448 | remove_ob (op); |
448 | op->destroy (); |
449 | free_object (op); |
|
|
450 | return; |
449 | return; |
451 | } |
450 | } |
452 | |
451 | |
453 | if (op->attacktype) |
452 | if (op->attacktype) |
454 | { |
453 | { |
455 | hit_map (op, 0, op->attacktype, 1); |
454 | hit_map (op, 0, op->attacktype, 1); |
456 | if (was_destroyed (op, op_tag)) |
455 | if (op->destroyed ()) |
457 | return; |
456 | return; |
458 | } |
457 | } |
459 | |
458 | |
460 | /* other_arch contains what this explodes into */ |
459 | /* other_arch contains what this explodes into */ |
461 | tmp = arch_to_object (op->other_arch); |
460 | tmp = arch_to_object (op->other_arch); |
… | |
… | |
465 | |
464 | |
466 | owner = get_owner (op); |
465 | owner = get_owner (op); |
467 | |
466 | |
468 | if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && !tailor_god_spell (tmp, owner)) |
467 | if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && !tailor_god_spell (tmp, owner)) |
469 | { |
468 | { |
470 | remove_ob (op); |
469 | op->destroy (); |
471 | free_object (op); |
|
|
472 | return; |
470 | return; |
473 | } |
471 | } |
474 | |
472 | |
475 | tmp->x = op->x; |
473 | tmp->x = op->x; |
476 | tmp->y = op->y; |
474 | tmp->y = op->y; |
… | |
… | |
504 | /* Prevent recursion */ |
502 | /* Prevent recursion */ |
505 | op->move_on = 0; |
503 | op->move_on = 0; |
506 | |
504 | |
507 | insert_ob_in_map (tmp, op->map, op, 0); |
505 | insert_ob_in_map (tmp, op->map, op, 0); |
508 | /* remove the firebullet */ |
506 | /* remove the firebullet */ |
509 | if (!was_destroyed (op, op_tag)) |
507 | if (!op->destroyed ()) |
510 | { |
508 | { |
511 | remove_ob (op); |
509 | op->destroy (); |
512 | free_object (op); |
|
|
513 | } |
510 | } |
514 | } |
511 | } |
515 | |
512 | |
516 | |
513 | |
517 | |
514 | |
… | |
… | |
520 | */ |
517 | */ |
521 | |
518 | |
522 | void |
519 | void |
523 | check_bullet (object *op) |
520 | check_bullet (object *op) |
524 | { |
521 | { |
525 | tag_t op_tag = op->count, tmp_tag; |
|
|
526 | object *tmp; |
522 | object *tmp; |
527 | int dam, mflags; |
523 | int dam, mflags; |
528 | mapstruct *m; |
524 | maptile *m; |
529 | sint16 sx, sy; |
525 | sint16 sx, sy; |
530 | |
526 | |
531 | mflags = get_map_flags (op->map, &m, op->x, op->y, &sx, &sy); |
527 | mflags = get_map_flags (op->map, &m, op->x, op->y, &sx, &sy); |
532 | |
528 | |
533 | if (!(mflags & P_IS_ALIVE) && !OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
529 | if (!(mflags & P_IS_ALIVE) && !OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
… | |
… | |
546 | |
542 | |
547 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
543 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
548 | { |
544 | { |
549 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
545 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
550 | { |
546 | { |
551 | tmp_tag = tmp->count; |
|
|
552 | dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); |
547 | dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); |
553 | if (was_destroyed (op, op_tag) || !was_destroyed (tmp, tmp_tag) || (op->stats.dam -= dam) < 0) |
548 | if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) |
554 | { |
549 | { |
555 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
550 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
556 | { |
551 | { |
557 | remove_ob (op); |
552 | op->destroy (); |
558 | free_object (op); |
|
|
559 | return; |
553 | return; |
560 | } |
554 | } |
561 | } |
555 | } |
562 | } |
556 | } |
563 | } |
557 | } |
… | |
… | |
573 | void |
567 | void |
574 | move_bullet (object *op) |
568 | move_bullet (object *op) |
575 | { |
569 | { |
576 | sint16 new_x, new_y; |
570 | sint16 new_x, new_y; |
577 | int mflags; |
571 | int mflags; |
578 | mapstruct *m; |
572 | maptile *m; |
579 | |
573 | |
580 | #if 0 |
574 | #if 0 |
581 | /* We need a better general purpose way to do this */ |
575 | /* We need a better general purpose way to do this */ |
582 | |
576 | |
583 | /* peterm: added to make comet leave a trail of burnouts |
577 | /* peterm: added to make comet leave a trail of burnouts |
584 | it's an unadulterated hack, but the effect is cool. */ |
578 | it's an unadulterated hack, but the effect is cool. */ |
585 | if (op->stats.sp == SP_METEOR) |
579 | if (op->stats.sp == SP_METEOR) |
586 | { |
580 | { |
587 | replace_insert_ob_in_map ("fire_trail", op); |
581 | replace_insert_ob_in_map ("fire_trail", op); |
588 | if (was_destroyed (op, op_tag)) |
582 | if (op->destroyed ()) |
589 | return; |
583 | return; |
590 | } /* end addition. */ |
584 | } /* end addition. */ |
591 | #endif |
585 | #endif |
592 | |
586 | |
593 | /* Reached the end of its life - remove it */ |
587 | /* Reached the end of its life - remove it */ |
594 | if (--op->range <= 0) |
588 | if (--op->range <= 0) |
595 | { |
589 | { |
596 | if (op->other_arch) |
590 | if (op->other_arch) |
597 | { |
|
|
598 | explode_bullet (op); |
591 | explode_bullet (op); |
599 | } |
|
|
600 | else |
592 | else |
601 | { |
593 | op->destroy (); |
602 | remove_ob (op); |
594 | |
603 | free_object (op); |
|
|
604 | } |
|
|
605 | return; |
595 | return; |
606 | } |
596 | } |
607 | |
597 | |
608 | new_x = op->x + DIRX (op); |
598 | new_x = op->x + DIRX (op); |
609 | new_y = op->y + DIRY (op); |
599 | new_y = op->y + DIRY (op); |
610 | m = op->map; |
600 | m = op->map; |
611 | mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y); |
601 | mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y); |
612 | |
602 | |
613 | if (mflags & P_OUT_OF_MAP) |
603 | if (mflags & P_OUT_OF_MAP) |
614 | { |
604 | { |
615 | remove_ob (op); |
605 | op->destroy (); |
616 | free_object (op); |
|
|
617 | return; |
606 | return; |
618 | } |
607 | } |
619 | |
608 | |
620 | if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) |
609 | if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) |
621 | { |
610 | { |
622 | if (op->other_arch) |
611 | if (op->other_arch) |
623 | { |
|
|
624 | explode_bullet (op); |
612 | explode_bullet (op); |
625 | } |
|
|
626 | else |
613 | else |
627 | { |
614 | op->destroy (); |
628 | remove_ob (op); |
615 | |
629 | free_object (op); |
|
|
630 | } |
|
|
631 | return; |
616 | return; |
632 | } |
617 | } |
633 | |
618 | |
634 | remove_ob (op); |
619 | op->remove (); |
635 | op->x = new_x; |
620 | op->x = new_x; |
636 | op->y = new_y; |
621 | op->y = new_y; |
637 | if ((op = insert_ob_in_map (op, m, op, 0)) == NULL) |
622 | if ((op = insert_ob_in_map (op, m, op, 0)) == NULL) |
638 | return; |
623 | return; |
639 | |
624 | |
… | |
… | |
698 | tmp->map = op->map; |
683 | tmp->map = op->map; |
699 | |
684 | |
700 | mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); |
685 | mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); |
701 | if (mflags & P_OUT_OF_MAP) |
686 | if (mflags & P_OUT_OF_MAP) |
702 | { |
687 | { |
703 | free_object (tmp); |
688 | tmp->destroy (); |
704 | return 0; |
689 | return 0; |
705 | } |
690 | } |
|
|
691 | |
706 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
692 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
707 | { |
693 | { |
708 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
694 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
709 | { |
695 | { |
710 | free_object (tmp); |
696 | tmp->destroy (); |
711 | return 0; |
697 | return 0; |
712 | } |
698 | } |
|
|
699 | |
713 | tmp->x = op->x; |
700 | tmp->x = op->x; |
714 | tmp->y = op->y; |
701 | tmp->y = op->y; |
715 | tmp->direction = absdir (tmp->direction + 4); |
702 | tmp->direction = absdir (tmp->direction + 4); |
716 | tmp->map = op->map; |
703 | tmp->map = op->map; |
717 | } |
704 | } |
|
|
705 | |
718 | if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) |
706 | if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) |
719 | { |
|
|
720 | check_bullet (tmp); |
707 | check_bullet (tmp); |
721 | } |
708 | |
722 | return 1; |
709 | return 1; |
723 | } |
710 | } |
724 | |
711 | |
725 | |
712 | |
726 | |
713 | |
… | |
… | |
756 | |
743 | |
757 | void |
744 | void |
758 | move_cone (object *op) |
745 | move_cone (object *op) |
759 | { |
746 | { |
760 | int i; |
747 | int i; |
761 | tag_t tag; |
|
|
762 | |
748 | |
763 | /* if no map then hit_map will crash so just ignore object */ |
749 | /* if no map then hit_map will crash so just ignore object */ |
764 | if (!op->map) |
750 | if (!op->map) |
765 | { |
751 | { |
766 | LOG (llevError, "Tried to move_cone object %s without a map.\n", op->name ? &op->name : "unknown"); |
752 | LOG (llevError, "Tried to move_cone object %s without a map.\n", op->name ? &op->name : "unknown"); |
… | |
… | |
781 | * when their cone dies when they die. |
767 | * when their cone dies when they die. |
782 | */ |
768 | */ |
783 | /* If no owner left, the spell dies out. */ |
769 | /* If no owner left, the spell dies out. */ |
784 | if (get_owner (op) == NULL) |
770 | if (get_owner (op) == NULL) |
785 | { |
771 | { |
786 | remove_ob (op); |
772 | op->destroy (); |
787 | free_object (op); |
|
|
788 | return; |
773 | return; |
789 | } |
774 | } |
790 | #endif |
775 | #endif |
791 | |
776 | |
792 | tag = op->count; |
|
|
793 | hit_map (op, 0, op->attacktype, 0); |
777 | hit_map (op, 0, op->attacktype, 0); |
794 | |
778 | |
795 | /* Check to see if we should push anything. |
779 | /* Check to see if we should push anything. |
796 | * Spell objects with weight push whatever they encounter to some |
780 | * Spell objects with weight push whatever they encounter to some |
797 | * degree. |
781 | * degree. |
798 | */ |
782 | */ |
799 | if (op->weight) |
783 | if (op->weight) |
800 | check_spell_knockback (op); |
784 | check_spell_knockback (op); |
801 | |
785 | |
802 | if (was_destroyed (op, tag)) |
786 | if (op->destroyed ()) |
803 | return; |
787 | return; |
804 | |
788 | |
805 | if ((op->duration--) < 0) |
789 | if ((op->duration--) < 0) |
806 | { |
790 | { |
807 | remove_ob (op); |
791 | op->destroy (); |
808 | free_object (op); |
|
|
809 | return; |
792 | return; |
810 | } |
793 | } |
811 | /* Object has hit maximum range, so don't have it move |
794 | /* Object has hit maximum range, so don't have it move |
812 | * any further. When the duration above expires, |
795 | * any further. When the duration above expires, |
813 | * then the object will get removed. |
796 | * then the object will get removed. |
… | |
… | |
822 | { |
805 | { |
823 | sint16 x = op->x + freearr_x[absdir (op->stats.sp + i)], y = op->y + freearr_y[absdir (op->stats.sp + i)]; |
806 | sint16 x = op->x + freearr_x[absdir (op->stats.sp + i)], y = op->y + freearr_y[absdir (op->stats.sp + i)]; |
824 | |
807 | |
825 | if (ok_to_put_more (op->map, x, y, op, op->attacktype)) |
808 | if (ok_to_put_more (op->map, x, y, op, op->attacktype)) |
826 | { |
809 | { |
827 | object *tmp = get_object (); |
810 | object *tmp = object::create (); |
828 | |
811 | |
829 | copy_object (op, tmp); |
812 | op->copy_to (tmp); |
830 | tmp->x = x; |
813 | tmp->x = x; |
831 | tmp->y = y; |
814 | tmp->y = y; |
832 | |
815 | |
833 | tmp->duration = op->duration + 1; |
816 | tmp->duration = op->duration + 1; |
834 | |
817 | |
… | |
… | |
852 | int |
835 | int |
853 | cast_cone (object *op, object *caster, int dir, object *spell) |
836 | cast_cone (object *op, object *caster, int dir, object *spell) |
854 | { |
837 | { |
855 | object *tmp; |
838 | object *tmp; |
856 | int i, success = 0, range_min = -1, range_max = 1; |
839 | int i, success = 0, range_min = -1, range_max = 1; |
857 | mapstruct *m; |
840 | maptile *m; |
858 | sint16 sx, sy; |
841 | sint16 sx, sy; |
859 | MoveType movetype; |
842 | MoveType movetype; |
860 | |
843 | |
861 | if (!spell->other_arch) |
844 | if (!spell->other_arch) |
862 | return 0; |
845 | return 0; |
… | |
… | |
1017 | return; |
1000 | return; |
1018 | |
1001 | |
1019 | if (env->type == PLAYER) |
1002 | if (env->type == PLAYER) |
1020 | esrv_del_item (env->contr, op->count); |
1003 | esrv_del_item (env->contr, op->count); |
1021 | |
1004 | |
1022 | remove_ob (op); |
1005 | op->remove (); |
1023 | op->x = env->x; |
1006 | op->x = env->x; |
1024 | op->y = env->y; |
1007 | op->y = env->y; |
1025 | if ((op = insert_ob_in_map (op, env->map, op, 0)) == NULL) |
1008 | if ((op = insert_ob_in_map (op, env->map, op, 0)) == NULL) |
1026 | return; |
1009 | return; |
1027 | } |
1010 | } |
… | |
… | |
1029 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding |
1012 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding |
1030 | // on a safe map. I don't like this special casing, but it seems to be neccessary |
1013 | // on a safe map. I don't like this special casing, but it seems to be neccessary |
1031 | // as bombs can be carried. |
1014 | // as bombs can be carried. |
1032 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
1015 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
1033 | { |
1016 | { |
1034 | remove_ob (op); |
1017 | op->destroy (); |
1035 | free_object (op); |
|
|
1036 | return; |
1018 | return; |
1037 | } |
1019 | } |
1038 | |
1020 | |
1039 | /* This copies a lot of the code from the fire bullet, |
1021 | /* This copies a lot of the code from the fire bullet, |
1040 | * but using the cast_bullet isn't really feasible, |
1022 | * but using the cast_bullet isn't really feasible, |
… | |
… | |
1075 | { |
1057 | { |
1076 | |
1058 | |
1077 | object *tmp; |
1059 | object *tmp; |
1078 | int mflags; |
1060 | int mflags; |
1079 | sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir]; |
1061 | sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir]; |
1080 | mapstruct *m; |
1062 | maptile *m; |
1081 | |
1063 | |
1082 | mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy); |
1064 | mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy); |
1083 | if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK)) |
1065 | if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK)) |
1084 | { |
1066 | { |
1085 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
1067 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
… | |
… | |
1121 | get_pointed_target (object *op, int dir, int range, int type) |
1103 | get_pointed_target (object *op, int dir, int range, int type) |
1122 | { |
1104 | { |
1123 | object *target; |
1105 | object *target; |
1124 | sint16 x, y; |
1106 | sint16 x, y; |
1125 | int dist, mflags; |
1107 | int dist, mflags; |
1126 | mapstruct *mp; |
1108 | maptile *mp; |
1127 | |
1109 | |
1128 | if (dir == 0) |
1110 | if (dir == 0) |
1129 | return NULL; |
1111 | return NULL; |
1130 | |
1112 | |
1131 | for (dist = 1; dist < range; dist++) |
1113 | for (dist = 1; dist < range; dist++) |
… | |
… | |
1234 | } |
1216 | } |
1235 | else |
1217 | else |
1236 | { |
1218 | { |
1237 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target)); |
1219 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target)); |
1238 | target->stats.hp = target->stats.maxhp * 2; |
1220 | target->stats.hp = target->stats.maxhp * 2; |
1239 | free_object (effect); |
1221 | effect->destroy (); |
1240 | return 0; |
1222 | return 0; |
1241 | } |
1223 | } |
1242 | } |
1224 | } |
1243 | } |
1225 | } |
1244 | else |
1226 | else |
… | |
… | |
1271 | move_missile (object *op) |
1253 | move_missile (object *op) |
1272 | { |
1254 | { |
1273 | int i, mflags; |
1255 | int i, mflags; |
1274 | object *owner; |
1256 | object *owner; |
1275 | sint16 new_x, new_y; |
1257 | sint16 new_x, new_y; |
1276 | mapstruct *m; |
1258 | maptile *m; |
1277 | |
1259 | |
1278 | if (op->range-- <= 0) |
1260 | if (op->range-- <= 0) |
1279 | { |
1261 | { |
1280 | remove_ob (op); |
1262 | op->destroy (); |
1281 | free_object (op); |
|
|
1282 | return; |
1263 | return; |
1283 | } |
1264 | } |
1284 | |
1265 | |
1285 | owner = get_owner (op); |
1266 | owner = get_owner (op); |
1286 | #if 0 |
1267 | #if 0 |
1287 | /* It'd make things nastier if this wasn't here - spells cast by |
1268 | /* It'd make things nastier if this wasn't here - spells cast by |
1288 | * monster that are then killed would continue to survive |
1269 | * monster that are then killed would continue to survive |
1289 | */ |
1270 | */ |
1290 | if (owner == NULL) |
1271 | if (owner == NULL) |
1291 | { |
1272 | { |
1292 | remove_ob (op); |
1273 | op->destroy (); |
1293 | free_object (op); |
|
|
1294 | return; |
1274 | return; |
1295 | } |
1275 | } |
1296 | #endif |
1276 | #endif |
1297 | |
1277 | |
1298 | new_x = op->x + DIRX (op); |
1278 | new_x = op->x + DIRX (op); |
… | |
… | |
1300 | |
1280 | |
1301 | mflags = get_map_flags (op->map, &m, new_x, new_y, &new_x, &new_y); |
1281 | mflags = get_map_flags (op->map, &m, new_x, new_y, &new_x, &new_y); |
1302 | |
1282 | |
1303 | if (!(mflags & P_OUT_OF_MAP) && ((mflags & P_IS_ALIVE) || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y)))) |
1283 | if (!(mflags & P_OUT_OF_MAP) && ((mflags & P_IS_ALIVE) || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y)))) |
1304 | { |
1284 | { |
1305 | tag_t tag = op->count; |
|
|
1306 | |
|
|
1307 | hit_map (op, op->direction, AT_MAGIC, 1); |
1285 | hit_map (op, op->direction, AT_MAGIC, 1); |
1308 | /* Basically, missile only hits one thing then goes away. |
1286 | /* Basically, missile only hits one thing then goes away. |
1309 | * we need to remove it if someone hasn't already done so. |
1287 | * we need to remove it if someone hasn't already done so. |
1310 | */ |
1288 | */ |
1311 | if (!was_destroyed (op, tag)) |
1289 | if (!op->destroyed ()) |
1312 | { |
1290 | op->destroy (); |
1313 | remove_ob (op); |
1291 | |
1314 | free_object (op); |
|
|
1315 | } |
|
|
1316 | return; |
1292 | return; |
1317 | } |
1293 | } |
1318 | |
1294 | |
1319 | remove_ob (op); |
1295 | op->remove (); |
|
|
1296 | |
1320 | if (!op->direction || (mflags & P_OUT_OF_MAP)) |
1297 | if (!op->direction || (mflags & P_OUT_OF_MAP)) |
1321 | { |
1298 | { |
1322 | free_object (op); |
1299 | op->destroy (); |
1323 | return; |
1300 | return; |
1324 | } |
1301 | } |
|
|
1302 | |
1325 | op->x = new_x; |
1303 | op->x = new_x; |
1326 | op->y = new_y; |
1304 | op->y = new_y; |
1327 | op->map = m; |
1305 | op->map = m; |
1328 | i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); |
1306 | i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); |
1329 | if (i > 0 && i != op->direction) |
1307 | if (i > 0 && i != op->direction) |
1330 | { |
1308 | { |
1331 | op->direction = i; |
1309 | op->direction = i; |
1332 | SET_ANIMATION (op, op->direction); |
1310 | SET_ANIMATION (op, op->direction); |
1333 | } |
1311 | } |
|
|
1312 | |
1334 | insert_ob_in_map (op, op->map, op, 0); |
1313 | insert_ob_in_map (op, op->map, op, 0); |
1335 | } |
1314 | } |
1336 | |
1315 | |
1337 | /**************************************************************************** |
1316 | /**************************************************************************** |
1338 | * Destruction |
1317 | * Destruction |
… | |
… | |
1384 | int |
1363 | int |
1385 | cast_destruction (object *op, object *caster, object *spell_ob) |
1364 | cast_destruction (object *op, object *caster, object *spell_ob) |
1386 | { |
1365 | { |
1387 | int i, j, range, mflags, friendly = 0, dam, dur; |
1366 | int i, j, range, mflags, friendly = 0, dam, dur; |
1388 | sint16 sx, sy; |
1367 | sint16 sx, sy; |
1389 | mapstruct *m; |
1368 | maptile *m; |
1390 | object *tmp; |
1369 | object *tmp; |
1391 | const char *skill; |
1370 | const char *skill; |
1392 | |
1371 | |
1393 | range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); |
1372 | range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); |
1394 | dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); |
1373 | dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); |
… | |
… | |
1576 | mood_change (object *op, object *caster, object *spell) |
1555 | mood_change (object *op, object *caster, object *spell) |
1577 | { |
1556 | { |
1578 | object *tmp, *god, *head; |
1557 | object *tmp, *god, *head; |
1579 | int done_one, range, mflags, level, at, best_at; |
1558 | int done_one, range, mflags, level, at, best_at; |
1580 | sint16 x, y, nx, ny; |
1559 | sint16 x, y, nx, ny; |
1581 | mapstruct *m; |
1560 | maptile *m; |
1582 | const char *race; |
1561 | const char *race; |
1583 | |
1562 | |
1584 | /* We precompute some values here so that we don't have to keep |
1563 | /* We precompute some values here so that we don't have to keep |
1585 | * doing it over and over again. |
1564 | * doing it over and over again. |
1586 | */ |
1565 | */ |
… | |
… | |
1750 | move_ball_spell (object *op) |
1729 | move_ball_spell (object *op) |
1751 | { |
1730 | { |
1752 | int i, j, dam_save, dir, mflags; |
1731 | int i, j, dam_save, dir, mflags; |
1753 | sint16 nx, ny, hx, hy; |
1732 | sint16 nx, ny, hx, hy; |
1754 | object *owner; |
1733 | object *owner; |
1755 | mapstruct *m; |
1734 | maptile *m; |
1756 | |
1735 | |
1757 | owner = get_owner (op); |
1736 | owner = get_owner (op); |
1758 | |
1737 | |
1759 | /* the following logic makes sure that the ball doesn't move into a wall, |
1738 | /* the following logic makes sure that the ball doesn't move into a wall, |
1760 | * and makes sure that it will move along a wall to try and get at it's |
1739 | * and makes sure that it will move along a wall to try and get at it's |
… | |
… | |
1791 | nx = op->x; |
1770 | nx = op->x; |
1792 | ny = op->y; |
1771 | ny = op->y; |
1793 | m = op->map; |
1772 | m = op->map; |
1794 | } |
1773 | } |
1795 | |
1774 | |
1796 | remove_ob (op); |
1775 | op->remove (); |
1797 | op->y = ny; |
1776 | op->y = ny; |
1798 | op->x = nx; |
1777 | op->x = nx; |
1799 | insert_ob_in_map (op, m, op, 0); |
1778 | insert_ob_in_map (op, m, op, 0); |
1800 | |
1779 | |
1801 | dam_save = op->stats.dam; /* save the original dam: we do halfdam on |
1780 | dam_save = op->stats.dam; /* save the original dam: we do halfdam on |
… | |
… | |
1872 | #if 0 |
1851 | #if 0 |
1873 | static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 }; |
1852 | static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 }; |
1874 | static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 }; |
1853 | static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 }; |
1875 | sint16 target_x, target_y, origin_x, origin_y; |
1854 | sint16 target_x, target_y, origin_x, origin_y; |
1876 | int adjustdir; |
1855 | int adjustdir; |
1877 | mapstruct *m; |
1856 | maptile *m; |
1878 | #endif |
1857 | #endif |
1879 | int basedir; |
1858 | int basedir; |
1880 | object *owner; |
1859 | object *owner; |
1881 | |
1860 | |
1882 | owner = get_owner (op); |
1861 | owner = get_owner (op); |
1883 | if (op->duration == 0 || owner == NULL) |
1862 | if (op->duration == 0 || owner == NULL) |
1884 | { |
1863 | { |
1885 | remove_ob (op); |
1864 | op->destroy (); |
1886 | free_object (op); |
|
|
1887 | return; |
1865 | return; |
1888 | } |
1866 | } |
|
|
1867 | |
1889 | op->duration--; |
1868 | op->duration--; |
1890 | |
1869 | |
1891 | basedir = op->direction; |
1870 | basedir = op->direction; |
1892 | if (basedir == 0) |
1871 | if (basedir == 0) |
1893 | { |
1872 | { |
… | |
… | |
2025 | cast_light (object *op, object *caster, object *spell, int dir) |
2004 | cast_light (object *op, object *caster, object *spell, int dir) |
2026 | { |
2005 | { |
2027 | object *target = NULL, *tmp = NULL; |
2006 | object *target = NULL, *tmp = NULL; |
2028 | sint16 x, y; |
2007 | sint16 x, y; |
2029 | int dam, mflags; |
2008 | int dam, mflags; |
2030 | mapstruct *m; |
2009 | maptile *m; |
2031 | |
2010 | |
2032 | dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
2011 | dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
2033 | |
2012 | |
2034 | if (!dir) |
2013 | if (!dir) |
2035 | { |
2014 | { |
… | |
… | |
2103 | cast_cause_disease (object *op, object *caster, object *spell, int dir) |
2082 | cast_cause_disease (object *op, object *caster, object *spell, int dir) |
2104 | { |
2083 | { |
2105 | sint16 x, y; |
2084 | sint16 x, y; |
2106 | int i, mflags, range, dam_mod, dur_mod; |
2085 | int i, mflags, range, dam_mod, dur_mod; |
2107 | object *walk; |
2086 | object *walk; |
2108 | mapstruct *m; |
2087 | maptile *m; |
2109 | |
2088 | |
2110 | x = op->x; |
2089 | x = op->x; |
2111 | y = op->y; |
2090 | y = op->y; |
2112 | |
2091 | |
2113 | /* If casting from a scroll, no direction will be available, so refer to the |
2092 | /* If casting from a scroll, no direction will be available, so refer to the |
… | |
… | |
2205 | { |
2184 | { |
2206 | object *flash; /* visual effect for inflicting disease */ |
2185 | object *flash; /* visual effect for inflicting disease */ |
2207 | |
2186 | |
2208 | new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); |
2187 | new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); |
2209 | |
2188 | |
2210 | free_object (disease); /* don't need this one anymore */ |
2189 | disease->destroy (); /* don't need this one anymore */ |
2211 | flash = get_archetype (ARCH_DETECT_MAGIC); |
2190 | flash = get_archetype (ARCH_DETECT_MAGIC); |
2212 | flash->x = x; |
2191 | flash->x = x; |
2213 | flash->y = y; |
2192 | flash->y = y; |
2214 | flash->map = walk->map; |
2193 | flash->map = walk->map; |
2215 | insert_ob_in_map (flash, walk->map, op, 0); |
2194 | insert_ob_in_map (flash, walk->map, op, 0); |
2216 | return 1; |
2195 | return 1; |
2217 | } |
2196 | } |
2218 | free_object (disease); |
2197 | |
|
|
2198 | disease->destroy (); |
2219 | } |
2199 | } |
2220 | } /* if living creature */ |
2200 | } /* if living creature */ |
2221 | } /* for range of spaces */ |
2201 | } /* for range of spaces */ |
2222 | new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!"); |
2202 | new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!"); |
2223 | return 1; |
2203 | return 1; |