… | |
… | |
402 | * explode. |
402 | * explode. |
403 | */ |
403 | */ |
404 | void |
404 | void |
405 | explode_bullet (object *op) |
405 | explode_bullet (object *op) |
406 | { |
406 | { |
407 | tag_t op_tag = op->count; |
|
|
408 | object *tmp, *owner; |
407 | object *tmp, *owner; |
409 | |
408 | |
410 | if (op->other_arch == NULL) |
409 | if (op->other_arch == NULL) |
411 | { |
410 | { |
412 | LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); |
411 | LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); |
… | |
… | |
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); |
… | |
… | |
504 | /* Prevent recursion */ |
503 | /* Prevent recursion */ |
505 | op->move_on = 0; |
504 | op->move_on = 0; |
506 | |
505 | |
507 | insert_ob_in_map (tmp, op->map, op, 0); |
506 | insert_ob_in_map (tmp, op->map, op, 0); |
508 | /* remove the firebullet */ |
507 | /* remove the firebullet */ |
509 | if (!was_destroyed (op, op_tag)) |
508 | if (!op->destroyed ()) |
510 | { |
509 | { |
511 | remove_ob (op); |
510 | remove_ob (op); |
512 | free_object (op); |
511 | free_object (op); |
513 | } |
512 | } |
514 | } |
513 | } |
… | |
… | |
520 | */ |
519 | */ |
521 | |
520 | |
522 | void |
521 | void |
523 | check_bullet (object *op) |
522 | check_bullet (object *op) |
524 | { |
523 | { |
525 | tag_t op_tag = op->count, tmp_tag; |
|
|
526 | object *tmp; |
524 | object *tmp; |
527 | int dam, mflags; |
525 | int dam, mflags; |
528 | mapstruct *m; |
526 | mapstruct *m; |
529 | sint16 sx, sy; |
527 | sint16 sx, sy; |
530 | |
528 | |
… | |
… | |
546 | |
544 | |
547 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
545 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
548 | { |
546 | { |
549 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
547 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
550 | { |
548 | { |
551 | tmp_tag = tmp->count; |
|
|
552 | dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); |
549 | 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) |
550 | if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) |
554 | { |
551 | { |
555 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
552 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
556 | { |
553 | { |
557 | remove_ob (op); |
554 | remove_ob (op); |
558 | free_object (op); |
555 | free_object (op); |
… | |
… | |
583 | /* peterm: added to make comet leave a trail of burnouts |
580 | /* peterm: added to make comet leave a trail of burnouts |
584 | it's an unadulterated hack, but the effect is cool. */ |
581 | it's an unadulterated hack, but the effect is cool. */ |
585 | if (op->stats.sp == SP_METEOR) |
582 | if (op->stats.sp == SP_METEOR) |
586 | { |
583 | { |
587 | replace_insert_ob_in_map ("fire_trail", op); |
584 | replace_insert_ob_in_map ("fire_trail", op); |
588 | if (was_destroyed (op, op_tag)) |
585 | if (op->destroyed ()) |
589 | return; |
586 | return; |
590 | } /* end addition. */ |
587 | } /* end addition. */ |
591 | #endif |
588 | #endif |
592 | |
589 | |
593 | /* Reached the end of its life - remove it */ |
590 | /* Reached the end of its life - remove it */ |
… | |
… | |
756 | |
753 | |
757 | void |
754 | void |
758 | move_cone (object *op) |
755 | move_cone (object *op) |
759 | { |
756 | { |
760 | int i; |
757 | int i; |
761 | tag_t tag; |
|
|
762 | |
758 | |
763 | /* if no map then hit_map will crash so just ignore object */ |
759 | /* if no map then hit_map will crash so just ignore object */ |
764 | if (!op->map) |
760 | if (!op->map) |
765 | { |
761 | { |
766 | LOG (llevError, "Tried to move_cone object %s without a map.\n", op->name ? &op->name : "unknown"); |
762 | LOG (llevError, "Tried to move_cone object %s without a map.\n", op->name ? &op->name : "unknown"); |
… | |
… | |
787 | free_object (op); |
783 | free_object (op); |
788 | return; |
784 | return; |
789 | } |
785 | } |
790 | #endif |
786 | #endif |
791 | |
787 | |
792 | tag = op->count; |
|
|
793 | hit_map (op, 0, op->attacktype, 0); |
788 | hit_map (op, 0, op->attacktype, 0); |
794 | |
789 | |
795 | /* Check to see if we should push anything. |
790 | /* Check to see if we should push anything. |
796 | * Spell objects with weight push whatever they encounter to some |
791 | * Spell objects with weight push whatever they encounter to some |
797 | * degree. |
792 | * degree. |
798 | */ |
793 | */ |
799 | if (op->weight) |
794 | if (op->weight) |
800 | check_spell_knockback (op); |
795 | check_spell_knockback (op); |
801 | |
796 | |
802 | if (was_destroyed (op, tag)) |
797 | if (op->destroyed ()) |
803 | return; |
798 | return; |
804 | |
799 | |
805 | if ((op->duration--) < 0) |
800 | if ((op->duration--) < 0) |
806 | { |
801 | { |
807 | remove_ob (op); |
802 | remove_ob (op); |
… | |
… | |
1300 | |
1295 | |
1301 | mflags = get_map_flags (op->map, &m, new_x, new_y, &new_x, &new_y); |
1296 | mflags = get_map_flags (op->map, &m, new_x, new_y, &new_x, &new_y); |
1302 | |
1297 | |
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)))) |
1298 | 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 | { |
1299 | { |
1305 | tag_t tag = op->count; |
|
|
1306 | |
|
|
1307 | hit_map (op, op->direction, AT_MAGIC, 1); |
1300 | hit_map (op, op->direction, AT_MAGIC, 1); |
1308 | /* Basically, missile only hits one thing then goes away. |
1301 | /* Basically, missile only hits one thing then goes away. |
1309 | * we need to remove it if someone hasn't already done so. |
1302 | * we need to remove it if someone hasn't already done so. |
1310 | */ |
1303 | */ |
1311 | if (!was_destroyed (op, tag)) |
1304 | if (!op->destroyed ()) |
1312 | { |
|
|
1313 | remove_ob (op); |
|
|
1314 | free_object (op); |
1305 | free_object (op); |
1315 | } |
1306 | |
1316 | return; |
1307 | return; |
1317 | } |
1308 | } |
1318 | |
1309 | |
1319 | remove_ob (op); |
1310 | remove_ob (op); |
|
|
1311 | |
1320 | if (!op->direction || (mflags & P_OUT_OF_MAP)) |
1312 | if (!op->direction || (mflags & P_OUT_OF_MAP)) |
1321 | { |
1313 | { |
1322 | free_object (op); |
1314 | free_object (op); |
1323 | return; |
1315 | return; |
1324 | } |
1316 | } |
|
|
1317 | |
1325 | op->x = new_x; |
1318 | op->x = new_x; |
1326 | op->y = new_y; |
1319 | op->y = new_y; |
1327 | op->map = m; |
1320 | op->map = m; |
1328 | i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); |
1321 | i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); |
1329 | if (i > 0 && i != op->direction) |
1322 | if (i > 0 && i != op->direction) |
1330 | { |
1323 | { |
1331 | op->direction = i; |
1324 | op->direction = i; |
1332 | SET_ANIMATION (op, op->direction); |
1325 | SET_ANIMATION (op, op->direction); |
1333 | } |
1326 | } |
|
|
1327 | |
1334 | insert_ob_in_map (op, op->map, op, 0); |
1328 | insert_ob_in_map (op, op->map, op, 0); |
1335 | } |
1329 | } |
1336 | |
1330 | |
1337 | /**************************************************************************** |
1331 | /**************************************************************************** |
1338 | * Destruction |
1332 | * Destruction |