1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_spell_attack_c = |
|
|
4 | * "$Id: spell_attack.C,v 1.10 2006/09/10 23:24:12 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | |
|
|
8 | /* |
1 | /* |
9 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
10 | |
3 | |
11 | Copyright (C) 2002-2003 Mark Wedel & Crossfire Development Team |
4 | Copyright (C) 2002-2003 Mark Wedel & Crossfire Development Team |
12 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
23 | |
16 | |
24 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
25 | along with this program; if not, write to the Free Software |
18 | along with this program; if not, write to the Free Software |
26 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
27 | |
20 | |
28 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
29 | */ |
22 | */ |
30 | |
23 | |
31 | /* This file contains all the spell attack code. Grouping this code |
24 | /* This file contains all the spell attack code. Grouping this code |
32 | * together should hopefully make it easier to find the relevent bits |
25 | * together should hopefully make it easier to find the relevent bits |
33 | * of code |
26 | * of code |
… | |
… | |
185 | { |
178 | { |
186 | remove_ob (op); |
179 | remove_ob (op); |
187 | free_object (op); |
180 | free_object (op); |
188 | return; |
181 | return; |
189 | } |
182 | } |
|
|
183 | |
190 | hit_map (op, 0, op->attacktype, 1); |
184 | hit_map (op, 0, op->attacktype, 1); |
191 | |
185 | |
192 | if (!op->direction) |
186 | if (!op->direction) |
193 | return; |
187 | return; |
194 | |
188 | |
… | |
… | |
408 | * explode. |
402 | * explode. |
409 | */ |
403 | */ |
410 | void |
404 | void |
411 | explode_bullet (object *op) |
405 | explode_bullet (object *op) |
412 | { |
406 | { |
413 | tag_t op_tag = op->count; |
|
|
414 | object *tmp, *owner; |
407 | object *tmp, *owner; |
415 | |
408 | |
416 | if (op->other_arch == NULL) |
409 | if (op->other_arch == NULL) |
417 | { |
410 | { |
418 | LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); |
411 | LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); |
… | |
… | |
457 | } |
450 | } |
458 | |
451 | |
459 | if (op->attacktype) |
452 | if (op->attacktype) |
460 | { |
453 | { |
461 | hit_map (op, 0, op->attacktype, 1); |
454 | hit_map (op, 0, op->attacktype, 1); |
462 | if (was_destroyed (op, op_tag)) |
455 | if (op->destroyed ()) |
463 | return; |
456 | return; |
464 | } |
457 | } |
465 | |
458 | |
466 | /* other_arch contains what this explodes into */ |
459 | /* other_arch contains what this explodes into */ |
467 | tmp = arch_to_object (op->other_arch); |
460 | tmp = arch_to_object (op->other_arch); |
… | |
… | |
510 | /* Prevent recursion */ |
503 | /* Prevent recursion */ |
511 | op->move_on = 0; |
504 | op->move_on = 0; |
512 | |
505 | |
513 | insert_ob_in_map (tmp, op->map, op, 0); |
506 | insert_ob_in_map (tmp, op->map, op, 0); |
514 | /* remove the firebullet */ |
507 | /* remove the firebullet */ |
515 | if (!was_destroyed (op, op_tag)) |
508 | if (!op->destroyed ()) |
516 | { |
509 | { |
517 | remove_ob (op); |
510 | remove_ob (op); |
518 | free_object (op); |
511 | free_object (op); |
519 | } |
512 | } |
520 | } |
513 | } |
… | |
… | |
526 | */ |
519 | */ |
527 | |
520 | |
528 | void |
521 | void |
529 | check_bullet (object *op) |
522 | check_bullet (object *op) |
530 | { |
523 | { |
531 | tag_t op_tag = op->count, tmp_tag; |
|
|
532 | object *tmp; |
524 | object *tmp; |
533 | int dam, mflags; |
525 | int dam, mflags; |
534 | mapstruct *m; |
526 | mapstruct *m; |
535 | sint16 sx, sy; |
527 | sint16 sx, sy; |
536 | |
528 | |
… | |
… | |
552 | |
544 | |
553 | 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) |
554 | { |
546 | { |
555 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
547 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
556 | { |
548 | { |
557 | tmp_tag = tmp->count; |
|
|
558 | dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); |
549 | dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); |
559 | 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) |
560 | { |
551 | { |
561 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
552 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
562 | { |
553 | { |
563 | remove_ob (op); |
554 | remove_ob (op); |
564 | free_object (op); |
555 | free_object (op); |
… | |
… | |
589 | /* peterm: added to make comet leave a trail of burnouts |
580 | /* peterm: added to make comet leave a trail of burnouts |
590 | it's an unadulterated hack, but the effect is cool. */ |
581 | it's an unadulterated hack, but the effect is cool. */ |
591 | if (op->stats.sp == SP_METEOR) |
582 | if (op->stats.sp == SP_METEOR) |
592 | { |
583 | { |
593 | replace_insert_ob_in_map ("fire_trail", op); |
584 | replace_insert_ob_in_map ("fire_trail", op); |
594 | if (was_destroyed (op, op_tag)) |
585 | if (op->destroyed ()) |
595 | return; |
586 | return; |
596 | } /* end addition. */ |
587 | } /* end addition. */ |
597 | #endif |
588 | #endif |
598 | |
589 | |
599 | /* Reached the end of its life - remove it */ |
590 | /* Reached the end of its life - remove it */ |
… | |
… | |
762 | |
753 | |
763 | void |
754 | void |
764 | move_cone (object *op) |
755 | move_cone (object *op) |
765 | { |
756 | { |
766 | int i; |
757 | int i; |
767 | tag_t tag; |
|
|
768 | |
758 | |
769 | /* 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 */ |
770 | if (!op->map) |
760 | if (!op->map) |
771 | { |
761 | { |
772 | 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"); |
… | |
… | |
793 | free_object (op); |
783 | free_object (op); |
794 | return; |
784 | return; |
795 | } |
785 | } |
796 | #endif |
786 | #endif |
797 | |
787 | |
798 | tag = op->count; |
|
|
799 | hit_map (op, 0, op->attacktype, 0); |
788 | hit_map (op, 0, op->attacktype, 0); |
800 | |
789 | |
801 | /* Check to see if we should push anything. |
790 | /* Check to see if we should push anything. |
802 | * Spell objects with weight push whatever they encounter to some |
791 | * Spell objects with weight push whatever they encounter to some |
803 | * degree. |
792 | * degree. |
804 | */ |
793 | */ |
805 | if (op->weight) |
794 | if (op->weight) |
806 | check_spell_knockback (op); |
795 | check_spell_knockback (op); |
807 | |
796 | |
808 | if (was_destroyed (op, tag)) |
797 | if (op->destroyed ()) |
809 | return; |
798 | return; |
810 | |
799 | |
811 | if ((op->duration--) < 0) |
800 | if ((op->duration--) < 0) |
812 | { |
801 | { |
813 | remove_ob (op); |
802 | remove_ob (op); |
… | |
… | |
1044 | |
1033 | |
1045 | /* This copies a lot of the code from the fire bullet, |
1034 | /* This copies a lot of the code from the fire bullet, |
1046 | * but using the cast_bullet isn't really feasible, |
1035 | * but using the cast_bullet isn't really feasible, |
1047 | * so just set up the appropriate values. |
1036 | * so just set up the appropriate values. |
1048 | */ |
1037 | */ |
1049 | at = find_archetype (SPLINT); |
1038 | at = archetype::find (SPLINT); |
1050 | if (at) |
1039 | if (at) |
1051 | { |
1040 | { |
1052 | for (i = 1; i < 9; i++) |
1041 | for (i = 1; i < 9; i++) |
1053 | { |
1042 | { |
1054 | if (out_of_map (op->map, op->x + freearr_x[i], op->y + freearr_x[i])) |
1043 | if (out_of_map (op->map, op->x + freearr_x[i], op->y + freearr_x[i])) |
… | |
… | |
1306 | |
1295 | |
1307 | 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); |
1308 | |
1297 | |
1309 | 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)))) |
1310 | { |
1299 | { |
1311 | tag_t tag = op->count; |
|
|
1312 | |
|
|
1313 | hit_map (op, op->direction, AT_MAGIC, 1); |
1300 | hit_map (op, op->direction, AT_MAGIC, 1); |
1314 | /* Basically, missile only hits one thing then goes away. |
1301 | /* Basically, missile only hits one thing then goes away. |
1315 | * 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. |
1316 | */ |
1303 | */ |
1317 | if (!was_destroyed (op, tag)) |
1304 | if (!op->destroyed ()) |
1318 | { |
|
|
1319 | remove_ob (op); |
|
|
1320 | free_object (op); |
1305 | free_object (op); |
1321 | } |
1306 | |
1322 | return; |
1307 | return; |
1323 | } |
1308 | } |
1324 | |
1309 | |
1325 | remove_ob (op); |
1310 | remove_ob (op); |
|
|
1311 | |
1326 | if (!op->direction || (mflags & P_OUT_OF_MAP)) |
1312 | if (!op->direction || (mflags & P_OUT_OF_MAP)) |
1327 | { |
1313 | { |
1328 | free_object (op); |
1314 | free_object (op); |
1329 | return; |
1315 | return; |
1330 | } |
1316 | } |
|
|
1317 | |
1331 | op->x = new_x; |
1318 | op->x = new_x; |
1332 | op->y = new_y; |
1319 | op->y = new_y; |
1333 | op->map = m; |
1320 | op->map = m; |
1334 | 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)); |
1335 | if (i > 0 && i != op->direction) |
1322 | if (i > 0 && i != op->direction) |
1336 | { |
1323 | { |
1337 | op->direction = i; |
1324 | op->direction = i; |
1338 | SET_ANIMATION (op, op->direction); |
1325 | SET_ANIMATION (op, op->direction); |
1339 | } |
1326 | } |
|
|
1327 | |
1340 | insert_ob_in_map (op, op->map, op, 0); |
1328 | insert_ob_in_map (op, op->map, op, 0); |
1341 | } |
1329 | } |
1342 | |
1330 | |
1343 | /**************************************************************************** |
1331 | /**************************************************************************** |
1344 | * Destruction |
1332 | * Destruction |