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.64 by root, Mon Sep 29 06:32:09 2008 UTC vs.
Revision 1.66 by root, Mon Sep 29 10:31:32 2008 UTC

165 sint16 x, y; 165 sint16 x, y;
166 maptile *m; 166 maptile *m;
167 167
168 if (--op->duration < 0) 168 if (--op->duration < 0)
169 { 169 {
170 op->destroy (); 170 op->drop_and_destroy ();
171 return; 171 return;
172 } 172 }
173 173
174 hit_map (op, 0, op->attacktype, 1); 174 hit_map (op, 0, op->attacktype, 1);
175 175
307 307
308 maptile *newmap; 308 maptile *newmap;
309 mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y); 309 mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y);
310 if (mflags & P_OUT_OF_MAP) 310 if (mflags & P_OUT_OF_MAP)
311 { 311 {
312 tmp->destroy (); 312 tmp->drop_and_destroy ();
313 return 0; 313 return 0;
314 } 314 }
315 315
316 tmp->map = newmap; 316 tmp->map = newmap;
317 317
318 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) 318 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y)))
319 { 319 {
320 if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) 320 if (!QUERY_FLAG (tmp, FLAG_REFLECTING))
321 { 321 {
322 tmp->destroy (); 322 tmp->drop_and_destroy ();
323 return 0; 323 return 0;
324 } 324 }
325 325
326 tmp->x = op->x; 326 tmp->x = op->x;
327 tmp->y = op->y; 327 tmp->y = op->y;
351 maptile *m = op->map; 351 maptile *m = op->map;
352 int i; 352 int i;
353 353
354 if (--op->duration < 0) 354 if (--op->duration < 0)
355 { 355 {
356 op->destroy (); 356 op->destroy (true);
357 return; 357 return;
358 } 358 }
359 359
360 hit_map (op, 0, op->attacktype, 0); 360 hit_map (op, 0, op->attacktype, 0);
361 361
396 object *tmp, *owner; 396 object *tmp, *owner;
397 397
398 if (!op->other_arch) 398 if (!op->other_arch)
399 { 399 {
400 LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); 400 LOG (llevError, "BUG: explode_bullet(): op without other_arch\n");
401 op->destroy (); 401 op->destroy (true);
402 return; 402 return;
403 } 403 }
404 404
405 if (op->env) 405 if (op->env)
406 { 406 {
407 object *env = op->outer_env (); 407 object *env = op->outer_env ();
408 408
409 if (!env->map || out_of_map (env->map, env->x, env->y)) 409 if (!env->map || out_of_map (env->map, env->x, env->y))
410 { 410 {
411 LOG (llevError, "BUG: explode_bullet(): env out of map\n"); 411 LOG (llevError, "BUG: explode_bullet(): env out of map\n");
412 op->destroy (); 412 op->destroy (true);
413 return; 413 return;
414 } 414 }
415 415
416 op->insert_at (env, op, INS_NO_MERGE | INS_NO_WALK_ON); 416 op->insert_at (env, op, INS_NO_MERGE | INS_NO_WALK_ON);
417 } 417 }
418 else if (out_of_map (op->map, op->x, op->y)) 418 else if (out_of_map (op->map, op->x, op->y))
419 { 419 {
420 LOG (llevError, "BUG: explode_bullet(): op out of map\n"); 420 LOG (llevError, "BUG: explode_bullet(): op out of map\n");
421 op->destroy (); 421 op->destroy (true);
422 return; 422 return;
423 } 423 }
424 424
425 // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent explosions of any kind on safe maps 425 // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent explosions of any kind on safe maps
426 // NOTE: If this breaks something important: remove this. I can't think of anything 426 // NOTE: If this breaks something important: remove this. I can't think of anything
427 // bad at the moment that might happen from this. 427 // bad at the moment that might happen from this.
428 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) 428 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE)
429 { 429 {
430 op->destroy (); 430 op->destroy (true);
431 return; 431 return;
432 } 432 }
433 433
434 if (op->attacktype) 434 if (op->attacktype)
435 { 435 {
445 tmp->set_owner (op); 445 tmp->set_owner (op);
446 tmp->skill = op->skill; 446 tmp->skill = op->skill;
447 447
448 owner = op->owner; 448 owner = op->owner;
449 449
450 if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && !tailor_god_spell (tmp, owner)) 450 if ((tmp->attacktype & AT_HOLYWORD
451 || tmp->attacktype & AT_GODPOWER)
452 && owner
453 && !tailor_god_spell (tmp, owner))
451 { 454 {
452 op->destroy (); 455 op->destroy (true);
453 return; 456 return;
454 } 457 }
455 458
456 /* special for bombs - it actually has sane values for these */ 459 /* special for bombs - it actually has sane values for these */
457 if (op->type == SPELL_EFFECT && op->subtype == SP_BOMB) 460 if (op->type == SPELL_EFFECT && op->subtype == SP_BOMB)
485 488
486 tmp->insert_at (op, op); 489 tmp->insert_at (op, op);
487 tmp->play_sound (tmp->sound); 490 tmp->play_sound (tmp->sound);
488 491
489 /* remove the firebullet */ 492 /* remove the firebullet */
490 op->destroy (); 493 op->destroy (true);
491} 494}
492 495
493/* checks to see what op should do, given the space it is on 496/* checks to see what op should do, given the space it is on
494 * (eg, explode, damage player, etc) 497 * (eg, explode, damage player, etc)
495 */ 498 */
521 { 524 {
522 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 525 if (QUERY_FLAG (tmp, FLAG_ALIVE))
523 { 526 {
524 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); 527 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1);
525 528
529 // TODO: can't understand the following if's
526 if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) 530 if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0)
527 { 531 {
528 if (!QUERY_FLAG (op, FLAG_REMOVED)) 532 if (!QUERY_FLAG (op, FLAG_REMOVED))
529 { 533 {
530 op->destroy (); 534 op->destroy (true);
531 return; 535 return;
532 } 536 }
533 } 537 }
534 } 538 }
535 } 539 }
564 if (--op->range <= 0) 568 if (--op->range <= 0)
565 { 569 {
566 if (op->other_arch) 570 if (op->other_arch)
567 explode_bullet (op); 571 explode_bullet (op);
568 else 572 else
569 op->destroy (); 573 op->destroy (true);
570 574
571 return; 575 return;
572 } 576 }
573 577
574 new_x = op->x + DIRX (op); 578 new_x = op->x + DIRX (op);
576 m = op->map; 580 m = op->map;
577 mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y); 581 mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y);
578 582
579 if (mflags & P_OUT_OF_MAP) 583 if (mflags & P_OUT_OF_MAP)
580 { 584 {
581 op->destroy (); 585 op->destroy (true);
582 return; 586 return;
583 } 587 }
584 588
585 if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) 589 if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y)))
586 { 590 {
587 if (op->other_arch) 591 if (op->other_arch)
588 explode_bullet (op); 592 explode_bullet (op);
589 else 593 else
590 op->destroy (); 594 op->destroy (true);
591 595
592 return; 596 return;
593 } 597 }
594 598
595 if (!(op = m->insert (op, new_x, new_y, op))) 599 if (!(op = m->insert (op, new_x, new_y, op)))
651 655
652 maptile *newmap; 656 maptile *newmap;
653 mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y); 657 mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y);
654 if (mflags & P_OUT_OF_MAP) 658 if (mflags & P_OUT_OF_MAP)
655 { 659 {
656 tmp->destroy (); 660 tmp->destroy (true);
657 return 0; 661 return 0;
658 } 662 }
659 663
660 tmp->map = newmap; 664 tmp->map = newmap;
661 665
662 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) 666 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y)))
663 { 667 {
664 if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) 668 if (!QUERY_FLAG (tmp, FLAG_REFLECTING))
665 { 669 {
666 tmp->destroy (); 670 tmp->destroy (true);
667 return 0; 671 return 0;
668 } 672 }
669 673
670 tmp->x = op->x; 674 tmp->x = op->x;
671 tmp->y = op->y; 675 tmp->y = op->y;
726 * when their cone dies when they die. 730 * when their cone dies when they die.
727 */ 731 */
728 /* If no owner left, the spell dies out. */ 732 /* If no owner left, the spell dies out. */
729 if (op->owner == NULL) 733 if (op->owner == NULL)
730 { 734 {
731 op->destroy (); 735 op->destroy (true);
732 return; 736 return;
733 } 737 }
734#endif 738#endif
735 739
736 hit_map (op, 0, op->attacktype, 0); 740 hit_map (op, 0, op->attacktype, 0);
745 if (op->destroyed ()) 749 if (op->destroyed ())
746 return; 750 return;
747 751
748 if (op->duration-- < 0) 752 if (op->duration-- < 0)
749 { 753 {
750 op->destroy (); 754 op->destroy (true);
751 return; 755 return;
752 } 756 }
753 /* Object has hit maximum range, so don't have it move 757 /* Object has hit maximum range, so don't have it move
754 * any further. When the duration above expires, 758 * any further. When the duration above expires,
755 * then the object will get removed. 759 * then the object will get removed.
954 // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding 958 // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding
955 // on a safe map. I don't like this special casing, but it seems to be neccessary 959 // on a safe map. I don't like this special casing, but it seems to be neccessary
956 // as bombs can be carried. 960 // as bombs can be carried.
957 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) 961 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE)
958 { 962 {
959 op->destroy (); 963 op->destroy (true);
960 return; 964 return;
961 } 965 }
962 966
963 /* This copies a lot of the code from the fire bullet, 967 /* This copies a lot of the code from the fire bullet,
964 * but using the cast_bullet isn't really feasible, 968 * but using the cast_bullet isn't really feasible,
1146 } 1150 }
1147 else 1151 else
1148 { 1152 {
1149 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target)); 1153 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target));
1150 target->stats.hp = target->stats.maxhp * 2; 1154 target->stats.hp = target->stats.maxhp * 2;
1151 effect->destroy (); 1155 effect->destroy (true);
1152 return 0; 1156 return 0;
1153 } 1157 }
1154 } 1158 }
1155 } 1159 }
1156 else 1160 else
1179void 1183void
1180move_missile (object *op) 1184move_missile (object *op)
1181{ 1185{
1182 if (op->range-- <= 0) 1186 if (op->range-- <= 0)
1183 { 1187 {
1184 op->destroy (); 1188 op->drop_and_destroy ();
1185 return; 1189 return;
1186 } 1190 }
1187 1191
1188 mapxy pos (op); 1192 mapxy pos (op);
1189 pos.move (op->direction); 1193 pos.move (op->direction);
1190 1194
1191 if (!pos.normalise ()) 1195 if (!pos.normalise ())
1192 { 1196 {
1193 op->destroy (); 1197 op->destroy (true);
1194 return; 1198 return;
1195 } 1199 }
1196 1200
1197 mapspace &ms = pos.ms (); 1201 mapspace &ms = pos.ms ();
1198 1202
1200 { 1204 {
1201 hit_map (op, op->direction, AT_MAGIC, 1); 1205 hit_map (op, op->direction, AT_MAGIC, 1);
1202 /* Basically, missile only hits one thing then goes away. 1206 /* Basically, missile only hits one thing then goes away.
1203 * we need to remove it if someone hasn't already done so. 1207 * we need to remove it if someone hasn't already done so.
1204 */ 1208 */
1205 op->destroy (); 1209 op->destroy (true);
1206 return; 1210 return;
1207 } 1211 }
1208 1212
1209 if (!op->direction) 1213 if (!op->direction)
1210 { 1214 {
1211 op->destroy (); 1215 op->destroy (true);
1212 return; 1216 return;
1213 } 1217 }
1214 1218
1215 int i = spell_find_dir (pos.m, pos.x, pos.y, op->owner); 1219 int i = spell_find_dir (pos.m, pos.x, pos.y, op->owner);
1216 if (i > 0 && i != op->direction) 1220 if (i > 0 && i != op->direction)
1733 object *owner = op->env; 1737 object *owner = op->env;
1734 1738
1735 if (!owner) // MUST not happen, remove when true TODO 1739 if (!owner) // MUST not happen, remove when true TODO
1736 { 1740 {
1737 LOG (llevError, "swarm spell found outside inventory: %s\n", op->debug_desc ()); 1741 LOG (llevError, "swarm spell found outside inventory: %s\n", op->debug_desc ());
1738 op->destroy (); 1742 op->destroy (true);
1739 return; 1743 return;
1740 } 1744 }
1741 1745
1742 if (!op->duration || !owner->is_on_map ()) 1746 if (!op->duration || !owner->is_on_map ())
1743 { 1747 {
1744 op->destroy (); 1748 op->drop_and_destroy ();
1745 return; 1749 return;
1746 } 1750 }
1747 1751
1748 op->duration--; 1752 op->duration--;
1749 1753
2052 2056
2053 if (infect_object (walk, disease, 1)) 2057 if (infect_object (walk, disease, 1))
2054 { 2058 {
2055 new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); 2059 new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name);
2056 2060
2057 disease->destroy (); /* don't need this one anymore */ 2061 disease->destroy (true); /* don't need this one anymore */
2058 walk->map->insert (get_archetype ("detect_magic"), x, y, op); 2062 walk->map->insert (get_archetype ("detect_magic"), x, y, op);
2059 return 1; 2063 return 1;
2060 } 2064 }
2061 2065
2062 disease->destroy (); 2066 disease->destroy (true);
2063 } 2067 }
2064 } /* if living creature */ 2068 } /* if living creature */
2065 } /* for range of spaces */ 2069 } /* for range of spaces */
2066 2070
2067 new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!"); 2071 new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines