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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines