ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/spell_attack.C
(Generate patch)

Comparing deliantra/server/server/spell_attack.C (file contents):
Revision 1.12 by root, Thu Sep 14 21:16:13 2006 UTC vs.
Revision 1.14 by root, Thu Sep 14 23:13:49 2006 UTC

1
2/*
3 * static char *rcsid_spell_attack_c =
4 * "$Id: spell_attack.C,v 1.12 2006/09/14 21:16:13 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
409 * explode. 402 * explode.
410 */ 403 */
411void 404void
412explode_bullet (object *op) 405explode_bullet (object *op)
413{ 406{
414 tag_t op_tag = op->count;
415 object *tmp, *owner; 407 object *tmp, *owner;
416 408
417 if (op->other_arch == NULL) 409 if (op->other_arch == NULL)
418 { 410 {
419 LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); 411 LOG (llevError, "BUG: explode_bullet(): op without other_arch\n");
458 } 450 }
459 451
460 if (op->attacktype) 452 if (op->attacktype)
461 { 453 {
462 hit_map (op, 0, op->attacktype, 1); 454 hit_map (op, 0, op->attacktype, 1);
463 if (was_destroyed (op, op_tag)) 455 if (op->destroyed ())
464 return; 456 return;
465 } 457 }
466 458
467 /* other_arch contains what this explodes into */ 459 /* other_arch contains what this explodes into */
468 tmp = arch_to_object (op->other_arch); 460 tmp = arch_to_object (op->other_arch);
511 /* Prevent recursion */ 503 /* Prevent recursion */
512 op->move_on = 0; 504 op->move_on = 0;
513 505
514 insert_ob_in_map (tmp, op->map, op, 0); 506 insert_ob_in_map (tmp, op->map, op, 0);
515 /* remove the firebullet */ 507 /* remove the firebullet */
516 if (!was_destroyed (op, op_tag)) 508 if (!op->destroyed ())
517 { 509 {
518 remove_ob (op); 510 remove_ob (op);
519 free_object (op); 511 free_object (op);
520 } 512 }
521} 513}
527 */ 519 */
528 520
529void 521void
530check_bullet (object *op) 522check_bullet (object *op)
531{ 523{
532 tag_t op_tag = op->count, tmp_tag;
533 object *tmp; 524 object *tmp;
534 int dam, mflags; 525 int dam, mflags;
535 mapstruct *m; 526 mapstruct *m;
536 sint16 sx, sy; 527 sint16 sx, sy;
537 528
553 544
554 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)
555 { 546 {
556 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 547 if (QUERY_FLAG (tmp, FLAG_ALIVE))
557 { 548 {
558 tmp_tag = tmp->count;
559 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); 549 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1);
560 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)
561 { 551 {
562 if (!QUERY_FLAG (op, FLAG_REMOVED)) 552 if (!QUERY_FLAG (op, FLAG_REMOVED))
563 { 553 {
564 remove_ob (op); 554 remove_ob (op);
565 free_object (op); 555 free_object (op);
590 /* peterm: added to make comet leave a trail of burnouts 580 /* peterm: added to make comet leave a trail of burnouts
591 it's an unadulterated hack, but the effect is cool. */ 581 it's an unadulterated hack, but the effect is cool. */
592 if (op->stats.sp == SP_METEOR) 582 if (op->stats.sp == SP_METEOR)
593 { 583 {
594 replace_insert_ob_in_map ("fire_trail", op); 584 replace_insert_ob_in_map ("fire_trail", op);
595 if (was_destroyed (op, op_tag)) 585 if (op->destroyed ())
596 return; 586 return;
597 } /* end addition. */ 587 } /* end addition. */
598#endif 588#endif
599 589
600 /* Reached the end of its life - remove it */ 590 /* Reached the end of its life - remove it */
763 753
764void 754void
765move_cone (object *op) 755move_cone (object *op)
766{ 756{
767 int i; 757 int i;
768 tag_t tag;
769 758
770 /* 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 */
771 if (!op->map) 760 if (!op->map)
772 { 761 {
773 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");
794 free_object (op); 783 free_object (op);
795 return; 784 return;
796 } 785 }
797#endif 786#endif
798 787
799 tag = op->count;
800 hit_map (op, 0, op->attacktype, 0); 788 hit_map (op, 0, op->attacktype, 0);
801 789
802 /* Check to see if we should push anything. 790 /* Check to see if we should push anything.
803 * Spell objects with weight push whatever they encounter to some 791 * Spell objects with weight push whatever they encounter to some
804 * degree. 792 * degree.
805 */ 793 */
806 if (op->weight) 794 if (op->weight)
807 check_spell_knockback (op); 795 check_spell_knockback (op);
808 796
809 if (was_destroyed (op, tag)) 797 if (op->destroyed ())
810 return; 798 return;
811 799
812 if ((op->duration--) < 0) 800 if ((op->duration--) < 0)
813 { 801 {
814 remove_ob (op); 802 remove_ob (op);
1307 1295
1308 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);
1309 1297
1310 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))))
1311 { 1299 {
1312 tag_t tag = op->count;
1313
1314 hit_map (op, op->direction, AT_MAGIC, 1); 1300 hit_map (op, op->direction, AT_MAGIC, 1);
1315 /* Basically, missile only hits one thing then goes away. 1301 /* Basically, missile only hits one thing then goes away.
1316 * 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.
1317 */ 1303 */
1318 if (!was_destroyed (op, tag)) 1304 if (!op->destroyed ())
1319 {
1320 remove_ob (op);
1321 free_object (op); 1305 free_object (op);
1322 } 1306
1323 return; 1307 return;
1324 } 1308 }
1325 1309
1326 remove_ob (op); 1310 remove_ob (op);
1311
1327 if (!op->direction || (mflags & P_OUT_OF_MAP)) 1312 if (!op->direction || (mflags & P_OUT_OF_MAP))
1328 { 1313 {
1329 free_object (op); 1314 free_object (op);
1330 return; 1315 return;
1331 } 1316 }
1317
1332 op->x = new_x; 1318 op->x = new_x;
1333 op->y = new_y; 1319 op->y = new_y;
1334 op->map = m; 1320 op->map = m;
1335 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));
1336 if (i > 0 && i != op->direction) 1322 if (i > 0 && i != op->direction)
1337 { 1323 {
1338 op->direction = i; 1324 op->direction = i;
1339 SET_ANIMATION (op, op->direction); 1325 SET_ANIMATION (op, op->direction);
1340 } 1326 }
1327
1341 insert_ob_in_map (op, op->map, op, 0); 1328 insert_ob_in_map (op, op->map, op, 0);
1342} 1329}
1343 1330
1344/**************************************************************************** 1331/****************************************************************************
1345 * Destruction 1332 * Destruction

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines