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.16 by root, Tue Dec 12 20:53:03 2006 UTC vs.
Revision 1.17 by root, Tue Dec 12 21:39:57 2006 UTC

140 140
141 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, sx, sy))) 141 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, sx, sy)))
142 return; 142 return;
143 143
144 /* OK, we made a fork */ 144 /* OK, we made a fork */
145 new_bolt = get_object (); 145 new_bolt = object::create ();
146 copy_object (tmp, new_bolt); 146 tmp->copy_to (new_bolt);
147 147
148 /* reduce chances of subsequent forking */ 148 /* reduce chances of subsequent forking */
149 new_bolt->stats.Dex -= 10; 149 new_bolt->stats.Dex -= 10;
150 tmp->stats.Dex -= 10; /* less forks from main bolt too */ 150 tmp->stats.Dex -= 10; /* less forks from main bolt too */
151 new_bolt->stats.Con += 25 * new_dir; /* adjust the left bias */ 151 new_bolt->stats.Con += 25 * new_dir; /* adjust the left bias */
174 sint16 x, y; 174 sint16 x, y;
175 maptile *m; 175 maptile *m;
176 176
177 if (--(op->duration) < 0) 177 if (--(op->duration) < 0)
178 { 178 {
179 op->remove ();
180 op->destroy (0); 179 op->destroy ();
181 return; 180 return;
182 } 181 }
183 182
184 hit_map (op, 0, op->attacktype, 1); 183 hit_map (op, 0, op->attacktype, 1);
185 184
250 update_turn_face (op); /* A bolt *must* be IS_TURNABLE */ 249 update_turn_face (op); /* A bolt *must* be IS_TURNABLE */
251 return; 250 return;
252 } 251 }
253 else 252 else
254 { /* Create a copy of this object and put it ahead */ 253 { /* Create a copy of this object and put it ahead */
255 tmp = get_object (); 254 tmp = object::create ();
256 copy_object (op, tmp); 255 op->copy_to (tmp);
257 tmp->speed_left = -0.1; 256 tmp->speed_left = -0.1;
258 tmp->x += DIRX (tmp), tmp->y += DIRY (tmp); 257 tmp->x += DIRX (tmp), tmp->y += DIRY (tmp);
259 tmp = insert_ob_in_map (tmp, op->map, op, 0); 258 tmp = insert_ob_in_map (tmp, op->map, op, 0);
260 /* To make up for the decrease at the top of the function */ 259 /* To make up for the decrease at the top of the function */
261 tmp->duration++; 260 tmp->duration++;
320 tmp->map = op->map; 319 tmp->map = op->map;
321 320
322 mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); 321 mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y);
323 if (mflags & P_OUT_OF_MAP) 322 if (mflags & P_OUT_OF_MAP)
324 { 323 {
325 tmp->destroy (0); 324 tmp->destroy ();
326 return 0; 325 return 0;
327 } 326 }
327
328 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) 328 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y)))
329 { 329 {
330 if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) 330 if (!QUERY_FLAG (tmp, FLAG_REFLECTING))
331 { 331 {
332 tmp->destroy (0); 332 tmp->destroy ();
333 return 0; 333 return 0;
334 } 334 }
335
335 tmp->x = op->x; 336 tmp->x = op->x;
336 tmp->y = op->y; 337 tmp->y = op->y;
337 tmp->direction = absdir (tmp->direction + 4); 338 tmp->direction = absdir (tmp->direction + 4);
338 tmp->map = op->map; 339 tmp->map = op->map;
339 } 340 }
341
340 if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) 342 if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL)
341 move_bolt (tmp); 343 move_bolt (tmp);
344
342 return 1; 345 return 1;
343} 346}
344 347
345 348
346 349
361 maptile *m = op->map; 364 maptile *m = op->map;
362 int i; 365 int i;
363 366
364 if (--(op->duration) < 0) 367 if (--(op->duration) < 0)
365 { 368 {
366 op->remove ();
367 op->destroy (0); 369 op->destroy ();
368 return; 370 return;
369 } 371 }
372
370 hit_map (op, 0, op->attacktype, 0); 373 hit_map (op, 0, op->attacktype, 0);
371 374
372 if (op->range > 0) 375 if (op->range > 0)
373 { 376 {
374 for (i = 1; i < 9; i++) 377 for (i = 1; i < 9; i++)
380 /* ok_to_put_more already does things like checks for walls, 383 /* ok_to_put_more already does things like checks for walls,
381 * out of map, etc. 384 * out of map, etc.
382 */ 385 */
383 if (ok_to_put_more (op->map, dx, dy, op, op->attacktype)) 386 if (ok_to_put_more (op->map, dx, dy, op, op->attacktype))
384 { 387 {
385 tmp = get_object (); 388 tmp = object::create ();
386 copy_object (op, tmp); 389 op->copy_to (tmp);
387 tmp->state = 0; 390 tmp->state = 0;
388 tmp->speed_left = -0.21; 391 tmp->speed_left = -0.21;
389 tmp->range--; 392 tmp->range--;
390 tmp->value = 0; 393 tmp->value = 0;
391 tmp->x = dx; 394 tmp->x = dx;
407 object *tmp, *owner; 410 object *tmp, *owner;
408 411
409 if (op->other_arch == NULL) 412 if (op->other_arch == NULL)
410 { 413 {
411 LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); 414 LOG (llevError, "BUG: explode_bullet(): op without other_arch\n");
412 op->remove ();
413 op->destroy (0); 415 op->destroy ();
414 return; 416 return;
415 } 417 }
416 418
417 if (op->env) 419 if (op->env)
418 { 420 {
420 422
421 env = object_get_env_recursive (op); 423 env = object_get_env_recursive (op);
422 if (env->map == NULL || out_of_map (env->map, env->x, env->y)) 424 if (env->map == NULL || out_of_map (env->map, env->x, env->y))
423 { 425 {
424 LOG (llevError, "BUG: explode_bullet(): env out of map\n"); 426 LOG (llevError, "BUG: explode_bullet(): env out of map\n");
425 op->remove ();
426 op->destroy (0); 427 op->destroy ();
427 return; 428 return;
428 } 429 }
430
429 op->remove (); 431 op->remove ();
430 op->x = env->x; 432 op->x = env->x;
431 op->y = env->y; 433 op->y = env->y;
432 insert_ob_in_map (op, env->map, op, INS_NO_MERGE | INS_NO_WALK_ON); 434 insert_ob_in_map (op, env->map, op, INS_NO_MERGE | INS_NO_WALK_ON);
433 } 435 }
434 else if (out_of_map (op->map, op->x, op->y)) 436 else if (out_of_map (op->map, op->x, op->y))
435 { 437 {
436 LOG (llevError, "BUG: explode_bullet(): op out of map\n"); 438 LOG (llevError, "BUG: explode_bullet(): op out of map\n");
437 op->remove ();
438 op->destroy (0); 439 op->destroy ();
439 return; 440 return;
440 } 441 }
441 442
442 // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent explosions of any kind on safe maps 443 // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent explosions of any kind on safe maps
443 // NOTE: If this breaks something important: remove this. I can't think of anything 444 // NOTE: If this breaks something important: remove this. I can't think of anything
444 // bad at the moment that might happen from this. 445 // bad at the moment that might happen from this.
445 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) 446 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE)
446 { 447 {
447 op->remove ();
448 op->destroy (0); 448 op->destroy ();
449 return; 449 return;
450 } 450 }
451 451
452 if (op->attacktype) 452 if (op->attacktype)
453 { 453 {
464 464
465 owner = get_owner (op); 465 owner = get_owner (op);
466 466
467 if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && !tailor_god_spell (tmp, owner)) 467 if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && !tailor_god_spell (tmp, owner))
468 { 468 {
469 op->remove ();
470 op->destroy (0); 469 op->destroy ();
471 return; 470 return;
472 } 471 }
473 472
474 tmp->x = op->x; 473 tmp->x = op->x;
475 tmp->y = op->y; 474 tmp->y = op->y;
505 504
506 insert_ob_in_map (tmp, op->map, op, 0); 505 insert_ob_in_map (tmp, op->map, op, 0);
507 /* remove the firebullet */ 506 /* remove the firebullet */
508 if (!op->destroyed ()) 507 if (!op->destroyed ())
509 { 508 {
510 op->remove ();
511 op->destroy (0); 509 op->destroy ();
512 } 510 }
513} 511}
514 512
515 513
516 514
549 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); 547 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1);
550 if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) 548 if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0)
551 { 549 {
552 if (!QUERY_FLAG (op, FLAG_REMOVED)) 550 if (!QUERY_FLAG (op, FLAG_REMOVED))
553 { 551 {
554 op->remove ();
555 op->destroy (0); 552 op->destroy ();
556 return; 553 return;
557 } 554 }
558 } 555 }
559 } 556 }
560 } 557 }
589 586
590 /* Reached the end of its life - remove it */ 587 /* Reached the end of its life - remove it */
591 if (--op->range <= 0) 588 if (--op->range <= 0)
592 { 589 {
593 if (op->other_arch) 590 if (op->other_arch)
594 {
595 explode_bullet (op); 591 explode_bullet (op);
596 }
597 else 592 else
598 {
599 op->remove ();
600 op->destroy (0); 593 op->destroy ();
601 } 594
602 return; 595 return;
603 } 596 }
604 597
605 new_x = op->x + DIRX (op); 598 new_x = op->x + DIRX (op);
606 new_y = op->y + DIRY (op); 599 new_y = op->y + DIRY (op);
607 m = op->map; 600 m = op->map;
608 mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y); 601 mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y);
609 602
610 if (mflags & P_OUT_OF_MAP) 603 if (mflags & P_OUT_OF_MAP)
611 { 604 {
612 op->remove ();
613 op->destroy (0); 605 op->destroy ();
614 return; 606 return;
615 } 607 }
616 608
617 if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) 609 if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y)))
618 { 610 {
619 if (op->other_arch) 611 if (op->other_arch)
620 {
621 explode_bullet (op); 612 explode_bullet (op);
622 }
623 else 613 else
624 {
625 op->remove ();
626 op->destroy (0); 614 op->destroy ();
627 } 615
628 return; 616 return;
629 } 617 }
630 618
631 op->remove (); 619 op->remove ();
632 op->x = new_x; 620 op->x = new_x;
695 tmp->map = op->map; 683 tmp->map = op->map;
696 684
697 mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); 685 mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y);
698 if (mflags & P_OUT_OF_MAP) 686 if (mflags & P_OUT_OF_MAP)
699 { 687 {
700 tmp->destroy (0); 688 tmp->destroy ();
701 return 0; 689 return 0;
702 } 690 }
691
703 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) 692 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y)))
704 { 693 {
705 if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) 694 if (!QUERY_FLAG (tmp, FLAG_REFLECTING))
706 { 695 {
707 tmp->destroy (0); 696 tmp->destroy ();
708 return 0; 697 return 0;
709 } 698 }
699
710 tmp->x = op->x; 700 tmp->x = op->x;
711 tmp->y = op->y; 701 tmp->y = op->y;
712 tmp->direction = absdir (tmp->direction + 4); 702 tmp->direction = absdir (tmp->direction + 4);
713 tmp->map = op->map; 703 tmp->map = op->map;
714 } 704 }
705
715 if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) 706 if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL)
716 {
717 check_bullet (tmp); 707 check_bullet (tmp);
718 } 708
719 return 1; 709 return 1;
720} 710}
721 711
722 712
723 713
777 * when their cone dies when they die. 767 * when their cone dies when they die.
778 */ 768 */
779 /* If no owner left, the spell dies out. */ 769 /* If no owner left, the spell dies out. */
780 if (get_owner (op) == NULL) 770 if (get_owner (op) == NULL)
781 { 771 {
782 op->remove ();
783 op->destroy (0); 772 op->destroy ();
784 return; 773 return;
785 } 774 }
786#endif 775#endif
787 776
788 hit_map (op, 0, op->attacktype, 0); 777 hit_map (op, 0, op->attacktype, 0);
797 if (op->destroyed ()) 786 if (op->destroyed ())
798 return; 787 return;
799 788
800 if ((op->duration--) < 0) 789 if ((op->duration--) < 0)
801 { 790 {
802 op->remove ();
803 op->destroy (0); 791 op->destroy ();
804 return; 792 return;
805 } 793 }
806 /* Object has hit maximum range, so don't have it move 794 /* Object has hit maximum range, so don't have it move
807 * any further. When the duration above expires, 795 * any further. When the duration above expires,
808 * then the object will get removed. 796 * then the object will get removed.
817 { 805 {
818 sint16 x = op->x + freearr_x[absdir (op->stats.sp + i)], y = op->y + freearr_y[absdir (op->stats.sp + i)]; 806 sint16 x = op->x + freearr_x[absdir (op->stats.sp + i)], y = op->y + freearr_y[absdir (op->stats.sp + i)];
819 807
820 if (ok_to_put_more (op->map, x, y, op, op->attacktype)) 808 if (ok_to_put_more (op->map, x, y, op, op->attacktype))
821 { 809 {
822 object *tmp = get_object (); 810 object *tmp = object::create ();
823 811
824 copy_object (op, tmp); 812 op->copy_to (tmp);
825 tmp->x = x; 813 tmp->x = x;
826 tmp->y = y; 814 tmp->y = y;
827 815
828 tmp->duration = op->duration + 1; 816 tmp->duration = op->duration + 1;
829 817
1024 // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding 1012 // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding
1025 // on a safe map. I don't like this special casing, but it seems to be neccessary 1013 // on a safe map. I don't like this special casing, but it seems to be neccessary
1026 // as bombs can be carried. 1014 // as bombs can be carried.
1027 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) 1015 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE)
1028 { 1016 {
1029 op->remove ();
1030 op->destroy (0); 1017 op->destroy ();
1031 return; 1018 return;
1032 } 1019 }
1033 1020
1034 /* This copies a lot of the code from the fire bullet, 1021 /* This copies a lot of the code from the fire bullet,
1035 * but using the cast_bullet isn't really feasible, 1022 * but using the cast_bullet isn't really feasible,
1229 } 1216 }
1230 else 1217 else
1231 { 1218 {
1232 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target)); 1219 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target));
1233 target->stats.hp = target->stats.maxhp * 2; 1220 target->stats.hp = target->stats.maxhp * 2;
1234 effect->destroy (0); 1221 effect->destroy ();
1235 return 0; 1222 return 0;
1236 } 1223 }
1237 } 1224 }
1238 } 1225 }
1239 else 1226 else
1270 sint16 new_x, new_y; 1257 sint16 new_x, new_y;
1271 maptile *m; 1258 maptile *m;
1272 1259
1273 if (op->range-- <= 0) 1260 if (op->range-- <= 0)
1274 { 1261 {
1275 op->remove ();
1276 op->destroy (0); 1262 op->destroy ();
1277 return; 1263 return;
1278 } 1264 }
1279 1265
1280 owner = get_owner (op); 1266 owner = get_owner (op);
1281#if 0 1267#if 0
1282 /* It'd make things nastier if this wasn't here - spells cast by 1268 /* It'd make things nastier if this wasn't here - spells cast by
1283 * monster that are then killed would continue to survive 1269 * monster that are then killed would continue to survive
1284 */ 1270 */
1285 if (owner == NULL) 1271 if (owner == NULL)
1286 { 1272 {
1287 op->remove ();
1288 op->destroy (0); 1273 op->destroy ();
1289 return; 1274 return;
1290 } 1275 }
1291#endif 1276#endif
1292 1277
1293 new_x = op->x + DIRX (op); 1278 new_x = op->x + DIRX (op);
1300 hit_map (op, op->direction, AT_MAGIC, 1); 1285 hit_map (op, op->direction, AT_MAGIC, 1);
1301 /* Basically, missile only hits one thing then goes away. 1286 /* Basically, missile only hits one thing then goes away.
1302 * we need to remove it if someone hasn't already done so. 1287 * we need to remove it if someone hasn't already done so.
1303 */ 1288 */
1304 if (!op->destroyed ()) 1289 if (!op->destroyed ())
1305 op->destroy (0); 1290 op->destroy ();
1306 1291
1307 return; 1292 return;
1308 } 1293 }
1309 1294
1310 op->remove (); 1295 op->remove ();
1311 1296
1312 if (!op->direction || (mflags & P_OUT_OF_MAP)) 1297 if (!op->direction || (mflags & P_OUT_OF_MAP))
1313 { 1298 {
1314 op->destroy (0); 1299 op->destroy ();
1315 return; 1300 return;
1316 } 1301 }
1317 1302
1318 op->x = new_x; 1303 op->x = new_x;
1319 op->y = new_y; 1304 op->y = new_y;
1874 object *owner; 1859 object *owner;
1875 1860
1876 owner = get_owner (op); 1861 owner = get_owner (op);
1877 if (op->duration == 0 || owner == NULL) 1862 if (op->duration == 0 || owner == NULL)
1878 { 1863 {
1879 op->remove ();
1880 op->destroy (0); 1864 op->destroy ();
1881 return; 1865 return;
1882 } 1866 }
1867
1883 op->duration--; 1868 op->duration--;
1884 1869
1885 basedir = op->direction; 1870 basedir = op->direction;
1886 if (basedir == 0) 1871 if (basedir == 0)
1887 { 1872 {
2199 { 2184 {
2200 object *flash; /* visual effect for inflicting disease */ 2185 object *flash; /* visual effect for inflicting disease */
2201 2186
2202 new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); 2187 new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name);
2203 2188
2204 disease->destroy (0); /* don't need this one anymore */ 2189 disease->destroy (); /* don't need this one anymore */
2205 flash = get_archetype (ARCH_DETECT_MAGIC); 2190 flash = get_archetype (ARCH_DETECT_MAGIC);
2206 flash->x = x; 2191 flash->x = x;
2207 flash->y = y; 2192 flash->y = y;
2208 flash->map = walk->map; 2193 flash->map = walk->map;
2209 insert_ob_in_map (flash, walk->map, op, 0); 2194 insert_ob_in_map (flash, walk->map, op, 0);
2210 return 1; 2195 return 1;
2211 } 2196 }
2197
2212 disease->destroy (0); 2198 disease->destroy ();
2213 } 2199 }
2214 } /* if living creature */ 2200 } /* if living creature */
2215 } /* for range of spaces */ 2201 } /* for range of spaces */
2216 new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!"); 2202 new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!");
2217 return 1; 2203 return 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines