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.17 by root, Tue Dec 12 21:39:57 2006 UTC vs.
Revision 1.23 by root, Mon Dec 25 11:25:50 2006 UTC

57 { 57 {
58 weight_move = op->weight + (op->weight * op->level) / 3; 58 weight_move = op->weight + (op->weight * op->level) / 3;
59 /*LOG (llevDebug, "DEBUG: arch weighs %d and masses %d (%s,level %d)\n", op->weight,weight_move,op->name,op->level); */ 59 /*LOG (llevDebug, "DEBUG: arch weighs %d and masses %d (%s,level %d)\n", op->weight,weight_move,op->name,op->level); */
60 } 60 }
61 61
62 for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 62 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above)
63 { 63 {
64 int num_sections = 1; 64 int num_sections = 1;
65 65
66 /* don't move DM */ 66 /* don't move DM */
67 if (QUERY_FLAG (tmp, FLAG_WIZ)) 67 if (QUERY_FLAG (tmp, FLAG_WIZ))
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 = object::create (); 145 new_bolt = tmp->clone ();
146 tmp->copy_to (new_bolt);
147 146
148 /* reduce chances of subsequent forking */ 147 /* reduce chances of subsequent forking */
149 new_bolt->stats.Dex -= 10; 148 new_bolt->stats.Dex -= 10;
150 tmp->stats.Dex -= 10; /* less forks from main bolt too */ 149 tmp->stats.Dex -= 10; /* less forks from main bolt too */
151 new_bolt->stats.Con += 25 * new_dir; /* adjust the left bias */ 150 new_bolt->stats.Con += 25 * new_dir; /* adjust the left bias */
249 update_turn_face (op); /* A bolt *must* be IS_TURNABLE */ 248 update_turn_face (op); /* A bolt *must* be IS_TURNABLE */
250 return; 249 return;
251 } 250 }
252 else 251 else
253 { /* Create a copy of this object and put it ahead */ 252 { /* Create a copy of this object and put it ahead */
254 tmp = object::create (); 253 tmp = op->clone ();
255 op->copy_to (tmp); 254
256 tmp->speed_left = -0.1; 255 tmp->speed_left = -0.1;
257 tmp->x += DIRX (tmp), tmp->y += DIRY (tmp); 256 tmp->x += DIRX (tmp), tmp->y += DIRY (tmp);
258 tmp = insert_ob_in_map (tmp, op->map, op, 0); 257 tmp = insert_ob_in_map (tmp, op->map, op, 0);
259 /* To make up for the decrease at the top of the function */ 258 /* To make up for the decrease at the top of the function */
260 tmp->duration++; 259 tmp->duration++;
281 * we remove the magic flag - that can be derived from 280 * we remove the magic flag - that can be derived from
282 * spob->attacktype. 281 * spob->attacktype.
283 * This function sets up the appropriate owner and skill 282 * This function sets up the appropriate owner and skill
284 * pointers. 283 * pointers.
285 */ 284 */
286
287int 285int
288fire_bolt (object *op, object *caster, int dir, object *spob, object *skill) 286fire_bolt (object *op, object *caster, int dir, object *spob, object *skill)
289{ 287{
290 object *tmp = NULL; 288 object *tmp = NULL;
291 int mflags; 289 int mflags;
309 307
310 tmp->direction = dir; 308 tmp->direction = dir;
311 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) 309 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE))
312 SET_ANIMATION (tmp, dir); 310 SET_ANIMATION (tmp, dir);
313 311
314 set_owner (tmp, op); 312 tmp->set_owner (op);
315 set_spell_skill (op, caster, spob, tmp); 313 set_spell_skill (op, caster, spob, tmp);
316 314
317 tmp->x = op->x + DIRX (tmp); 315 tmp->x = op->x + DIRX (tmp);
318 tmp->y = op->y + DIRY (tmp); 316 tmp->y = op->y + DIRY (tmp);
319 tmp->map = op->map; 317 tmp->map = op->map;
320 318
319 maptile *newmap;
321 mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); 320 mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y);
322 if (mflags & P_OUT_OF_MAP) 321 if (mflags & P_OUT_OF_MAP)
323 { 322 {
324 tmp->destroy (); 323 tmp->destroy ();
325 return 0; 324 return 0;
326 } 325 }
326
327 tmp->map = newmap;
327 328
328 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) 329 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y)))
329 { 330 {
330 if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) 331 if (!QUERY_FLAG (tmp, FLAG_REFLECTING))
331 { 332 {
383 /* ok_to_put_more already does things like checks for walls, 384 /* ok_to_put_more already does things like checks for walls,
384 * out of map, etc. 385 * out of map, etc.
385 */ 386 */
386 if (ok_to_put_more (op->map, dx, dy, op, op->attacktype)) 387 if (ok_to_put_more (op->map, dx, dy, op, op->attacktype))
387 { 388 {
388 tmp = object::create (); 389 tmp = op->clone ();
389 op->copy_to (tmp);
390 tmp->state = 0; 390 tmp->state = 0;
391 tmp->speed_left = -0.21; 391 tmp->speed_left = -0.21;
392 tmp->range--; 392 tmp->range--;
393 tmp->value = 0; 393 tmp->value = 0;
394 tmp->x = dx; 394 tmp->x = dx;
457 } 457 }
458 458
459 /* other_arch contains what this explodes into */ 459 /* other_arch contains what this explodes into */
460 tmp = arch_to_object (op->other_arch); 460 tmp = arch_to_object (op->other_arch);
461 461
462 copy_owner (tmp, op); 462 tmp->set_owner (op);
463 tmp->skill = op->skill; 463 tmp->skill = op->skill;
464 464
465 owner = get_owner (op); 465 owner = op->owner;
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->destroy (); 469 op->destroy ();
470 return; 470 return;
538 538
539 /* If nothing alive on this space, no reason to do anything further */ 539 /* If nothing alive on this space, no reason to do anything further */
540 if (!(mflags & P_IS_ALIVE)) 540 if (!(mflags & P_IS_ALIVE))
541 return; 541 return;
542 542
543 for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 543 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above)
544 { 544 {
545 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 545 if (QUERY_FLAG (tmp, FLAG_ALIVE))
546 { 546 {
547 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); 547 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1);
548 if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) 548 if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0)
555 } 555 }
556 } 556 }
557 } 557 }
558} 558}
559 559
560
561/* Basically, we move 'op' one square, and if it hits something, 560/* Basically, we move 'op' one square, and if it hits something,
562 * call check_bullet. 561 * call check_bullet.
563 * This function is only applicable to bullets, but not to all 562 * This function is only applicable to bullets, but not to all
564 * fired arches (eg, bolts). 563 * fired arches (eg, bolts).
565 */ 564 */
566
567void 565void
568move_bullet (object *op) 566move_bullet (object *op)
569{ 567{
570 sint16 new_x, new_y; 568 sint16 new_x, new_y;
571 int mflags; 569 int mflags;
626 { 624 {
627 op->direction = absdir (op->direction + 4); 625 op->direction = absdir (op->direction + 4);
628 update_turn_face (op); 626 update_turn_face (op);
629 } 627 }
630 else 628 else
631 {
632 check_bullet (op); 629 check_bullet (op);
633 }
634} 630}
635 631
636 632
637 633
638 634
673 669
674 tmp->direction = dir; 670 tmp->direction = dir;
675 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) 671 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE))
676 SET_ANIMATION (tmp, dir); 672 SET_ANIMATION (tmp, dir);
677 673
678 set_owner (tmp, op); 674 tmp->set_owner (op);
679 set_spell_skill (op, caster, spob, tmp); 675 set_spell_skill (op, caster, spob, tmp);
680 676
681 tmp->x = op->x + freearr_x[dir]; 677 tmp->x = op->x + freearr_x[dir];
682 tmp->y = op->y + freearr_y[dir]; 678 tmp->y = op->y + freearr_y[dir];
683 tmp->map = op->map; 679 tmp->map = op->map;
684 680
681 maptile *newmap;
685 mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); 682 mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y);
686 if (mflags & P_OUT_OF_MAP) 683 if (mflags & P_OUT_OF_MAP)
687 { 684 {
688 tmp->destroy (); 685 tmp->destroy ();
689 return 0; 686 return 0;
690 } 687 }
688
689 tmp->map = newmap;
691 690
692 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) 691 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y)))
693 { 692 {
694 if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) 693 if (!QUERY_FLAG (tmp, FLAG_REFLECTING))
695 { 694 {
701 tmp->y = op->y; 700 tmp->y = op->y;
702 tmp->direction = absdir (tmp->direction + 4); 701 tmp->direction = absdir (tmp->direction + 4);
703 tmp->map = op->map; 702 tmp->map = op->map;
704 } 703 }
705 704
706 if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) 705 if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)))
707 check_bullet (tmp); 706 check_bullet (tmp);
708 707
709 return 1; 708 return 1;
710} 709}
711 710
726 object *new_ob = arch_to_object (op->other_arch); 725 object *new_ob = arch_to_object (op->other_arch);
727 726
728 new_ob->x = op->x; 727 new_ob->x = op->x;
729 new_ob->y = op->y; 728 new_ob->y = op->y;
730 new_ob->level = op->level; 729 new_ob->level = op->level;
731 set_owner (new_ob, op->owner); 730 new_ob->set_owner (op->owner);
732 731
733 /* preserve skill ownership */ 732 /* preserve skill ownership */
734 if (op->skill && op->skill != new_ob->skill) 733 if (op->skill && op->skill != new_ob->skill)
735 { 734 {
736 new_ob->skill = op->skill; 735 new_ob->skill = op->skill;
765#if 0 764#if 0
766 /* Disable this - enabling it makes monsters easier, as 765 /* Disable this - enabling it makes monsters easier, as
767 * when their cone dies when they die. 766 * when their cone dies when they die.
768 */ 767 */
769 /* If no owner left, the spell dies out. */ 768 /* If no owner left, the spell dies out. */
770 if (get_owner (op) == NULL) 769 if (op->owner == NULL)
771 { 770 {
772 op->destroy (); 771 op->destroy ();
773 return; 772 return;
774 } 773 }
775#endif 774#endif
805 { 804 {
806 sint16 x = op->x + freearr_x[absdir (op->stats.sp + i)], y = op->y + freearr_y[absdir (op->stats.sp + i)]; 805 sint16 x = op->x + freearr_x[absdir (op->stats.sp + i)], y = op->y + freearr_y[absdir (op->stats.sp + i)];
807 806
808 if (ok_to_put_more (op->map, x, y, op, op->attacktype)) 807 if (ok_to_put_more (op->map, x, y, op, op->attacktype))
809 { 808 {
810 object *tmp = object::create (); 809 object *tmp = op->clone ();
811 810
812 op->copy_to (tmp);
813 tmp->x = x; 811 tmp->x = x;
814 tmp->y = y; 812 tmp->y = y;
815 813
816 tmp->duration = op->duration + 1; 814 tmp->duration = op->duration + 1;
817 815
901 if ((movetype & GET_MAP_MOVE_BLOCK (m, sx, sy)) == movetype) 899 if ((movetype & GET_MAP_MOVE_BLOCK (m, sx, sy)) == movetype)
902 continue; 900 continue;
903 901
904 success = 1; 902 success = 1;
905 tmp = arch_to_object (spell->other_arch); 903 tmp = arch_to_object (spell->other_arch);
906 set_owner (tmp, op); 904 tmp->set_owner (op);
907 set_spell_skill (op, caster, spell, tmp); 905 set_spell_skill (op, caster, spell, tmp);
908 tmp->level = caster_level (caster, spell); 906 tmp->level = caster_level (caster, spell);
909 tmp->x = sx; 907 tmp->x = sx;
910 tmp->y = sy; 908 tmp->y = sy;
911 tmp->attacktype = spell->attacktype; 909 tmp->attacktype = spell->attacktype;
1033 tmp->direction = i; 1031 tmp->direction = i;
1034 tmp->range = op->range; 1032 tmp->range = op->range;
1035 tmp->stats.dam = op->stats.dam; 1033 tmp->stats.dam = op->stats.dam;
1036 tmp->duration = op->duration; 1034 tmp->duration = op->duration;
1037 tmp->attacktype = op->attacktype; 1035 tmp->attacktype = op->attacktype;
1038 copy_owner (tmp, op); 1036 tmp->set_owner (op);
1039 if (op->skill && op->skill != tmp->skill) 1037 if (op->skill && op->skill != tmp->skill)
1040 { 1038 {
1041 tmp->skill = op->skill; 1039 tmp->skill = op->skill;
1042 } 1040 }
1043 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) 1041 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE))
1073 tmp->range = spell->range + SP_level_range_adjust (caster, spell); 1071 tmp->range = spell->range + SP_level_range_adjust (caster, spell);
1074 tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 1072 tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
1075 tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); 1073 tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell);
1076 tmp->attacktype = spell->attacktype; 1074 tmp->attacktype = spell->attacktype;
1077 1075
1078 set_owner (tmp, op); 1076 tmp->set_owner (op);
1079 set_spell_skill (op, caster, spell, tmp); 1077 set_spell_skill (op, caster, spell, tmp);
1080 tmp->x = dx; 1078 tmp->x = dx;
1081 tmp->y = dy; 1079 tmp->y = dy;
1082 insert_ob_in_map (tmp, m, op, 0); 1080 insert_ob_in_map (tmp, m, op, 0);
1083 return 1; 1081 return 1;
1126 if (GET_MAP_MOVE_BLOCK (mp, x, y) & MOVE_FLY_LOW) 1124 if (GET_MAP_MOVE_BLOCK (mp, x, y) & MOVE_FLY_LOW)
1127 return NULL; 1125 return NULL;
1128 1126
1129 if (mflags & P_IS_ALIVE) 1127 if (mflags & P_IS_ALIVE)
1130 { 1128 {
1131 for (target = get_map_ob (mp, x, y); target; target = target->above) 1129 for (target = GET_MAP_OB (mp, x, y); target; target = target->above)
1132 { 1130 {
1133 if (QUERY_FLAG (target->head ? target->head : target, FLAG_MONSTER)) 1131 if (QUERY_FLAG (target->head ? target->head : target, FLAG_MONSTER))
1134 { 1132 {
1135 return target; 1133 return target;
1136 } 1134 }
1203 if (effect->attacktype & AT_DEATH) 1201 if (effect->attacktype & AT_DEATH)
1204 { 1202 {
1205 effect->level = spell->stats.dam + SP_level_dam_adjust (caster, spell); 1203 effect->level = spell->stats.dam + SP_level_dam_adjust (caster, spell);
1206 1204
1207 /* casting death spells at undead isn't a good thing */ 1205 /* casting death spells at undead isn't a good thing */
1208 if QUERY_FLAG
1209 (target, FLAG_UNDEAD) 1206 if (QUERY_FLAG (target, FLAG_UNDEAD))
1210 { 1207 {
1211 if (random_roll (0, 2, op, PREFER_LOW)) 1208 if (random_roll (0, 2, op, PREFER_LOW))
1212 { 1209 {
1213 new_draw_info (NDI_UNIQUE, 0, op, "Idiot! Your spell boomerangs!"); 1210 new_draw_info (NDI_UNIQUE, 0, op, "Idiot! Your spell boomerangs!");
1214 effect->x = op->x; 1211 effect->x = op->x;
1227 { 1224 {
1228 /* how much woe to inflict :) */ 1225 /* how much woe to inflict :) */
1229 effect->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 1226 effect->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
1230 } 1227 }
1231 1228
1232 set_owner (effect, op); 1229 effect->set_owner (op);
1233 set_spell_skill (op, caster, spell, effect); 1230 set_spell_skill (op, caster, spell, effect);
1234 1231
1235 /* ok, tell it where to be, and insert! */ 1232 /* ok, tell it where to be, and insert! */
1236 effect->x = target->x; 1233 effect->x = target->x;
1237 effect->y = target->y; 1234 effect->y = target->y;
1261 { 1258 {
1262 op->destroy (); 1259 op->destroy ();
1263 return; 1260 return;
1264 } 1261 }
1265 1262
1266 owner = get_owner (op); 1263 owner = op->owner;
1267#if 0 1264#if 0
1268 /* It'd make things nastier if this wasn't here - spells cast by 1265 /* It'd make things nastier if this wasn't here - spells cast by
1269 * monster that are then killed would continue to survive 1266 * monster that are then killed would continue to survive
1270 */ 1267 */
1271 if (owner == NULL) 1268 if (owner == NULL)
1301 } 1298 }
1302 1299
1303 op->x = new_x; 1300 op->x = new_x;
1304 op->y = new_y; 1301 op->y = new_y;
1305 op->map = m; 1302 op->map = m;
1306 i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); 1303 i = spell_find_dir (op->map, op->x, op->y, op->owner);
1307 if (i > 0 && i != op->direction) 1304 if (i > 0 && i != op->direction)
1308 { 1305 {
1309 op->direction = i; 1306 op->direction = i;
1310 SET_ANIMATION (op, op->direction); 1307 SET_ANIMATION (op, op->direction);
1311 } 1308 }
1401 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); 1398 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy);
1402 if (mflags & P_OUT_OF_MAP) 1399 if (mflags & P_OUT_OF_MAP)
1403 continue; 1400 continue;
1404 if (mflags & P_IS_ALIVE) 1401 if (mflags & P_IS_ALIVE)
1405 { 1402 {
1406 for (tmp = get_map_ob (m, sx, sy); tmp; tmp = tmp->above) 1403 for (tmp = GET_MAP_OB (m, sx, sy); tmp; tmp = tmp->above)
1407 { 1404 {
1408 if (QUERY_FLAG (tmp, FLAG_ALIVE) || tmp->type == PLAYER) 1405 if (QUERY_FLAG (tmp, FLAG_ALIVE) || tmp->type == PLAYER)
1409 break; 1406 break;
1410 } 1407 }
1411 if (tmp) 1408 if (tmp)
1534 force->stats.ac = spell_ob->stats.ac; 1531 force->stats.ac = spell_ob->stats.ac;
1535 force->stats.wc = spell_ob->stats.wc; 1532 force->stats.wc = spell_ob->stats.wc;
1536 1533
1537 change_abil (tmp, force); /* Mostly to display any messages */ 1534 change_abil (tmp, force); /* Mostly to display any messages */
1538 insert_ob_in_ob (force, tmp); 1535 insert_ob_in_ob (force, tmp);
1539 fix_player (tmp); 1536 tmp->update_stats ();
1540 return 1; 1537 return 1;
1541 1538
1542} 1539}
1543 1540
1544 1541
1595 1592
1596 /* If there is nothing living on this space, no need to go further */ 1593 /* If there is nothing living on this space, no need to go further */
1597 if (!(mflags & P_IS_ALIVE)) 1594 if (!(mflags & P_IS_ALIVE))
1598 continue; 1595 continue;
1599 1596
1600 for (tmp = get_map_ob (m, nx, ny); tmp; tmp = tmp->above) 1597 for (tmp = GET_MAP_OB (m, nx, ny); tmp; tmp = tmp->above)
1601 if (QUERY_FLAG (tmp, FLAG_MONSTER)) 1598 if (QUERY_FLAG (tmp, FLAG_MONSTER))
1602 break; 1599 break;
1603 1600
1604 /* There can be living objects that are not monsters */ 1601 /* There can be living objects that are not monsters */
1605 if (!tmp || tmp->type == PLAYER) 1602 if (!tmp || tmp->type == PLAYER)
1693 SET_FLAG (head, FLAG_FRIENDLY); 1690 SET_FLAG (head, FLAG_FRIENDLY);
1694 /* Prevent uncontolled outbreaks of self replicating monsters. 1691 /* Prevent uncontolled outbreaks of self replicating monsters.
1695 Typical use case is charm, go somwhere, use aggravation to make hostile. 1692 Typical use case is charm, go somwhere, use aggravation to make hostile.
1696 This could lead to fun stuff like mice outbreak in bigworld and server crawl. */ 1693 This could lead to fun stuff like mice outbreak in bigworld and server crawl. */
1697 CLEAR_FLAG (head, FLAG_GENERATOR); 1694 CLEAR_FLAG (head, FLAG_GENERATOR);
1698 set_owner (head, op); 1695 head->set_owner (op);
1699 set_spell_skill (op, caster, spell, head); 1696 set_spell_skill (op, caster, spell, head);
1700 add_friendly_object (head); 1697 add_friendly_object (head);
1701 head->attack_movement = PETMOVE; 1698 head->attack_movement = PETMOVE;
1702 done_one = 1; 1699 done_one = 1;
1703 change_exp (op, head->stats.exp / 2, head->skill, SK_EXP_ADD_SKILL); 1700 change_exp (op, head->stats.exp / 2, head->skill, SK_EXP_ADD_SKILL);
1731 int i, j, dam_save, dir, mflags; 1728 int i, j, dam_save, dir, mflags;
1732 sint16 nx, ny, hx, hy; 1729 sint16 nx, ny, hx, hy;
1733 object *owner; 1730 object *owner;
1734 maptile *m; 1731 maptile *m;
1735 1732
1736 owner = get_owner (op); 1733 owner = op->owner;
1737 1734
1738 /* the following logic makes sure that the ball doesn't move into a wall, 1735 /* the following logic makes sure that the ball doesn't move into a wall,
1739 * and makes sure that it will move along a wall to try and get at it's 1736 * and makes sure that it will move along a wall to try and get at it's
1740 * victim. The block immediately below more or less chooses a random 1737 * victim. The block immediately below more or less chooses a random
1741 * offset to move the ball, eg, keep it mostly on course, with some 1738 * offset to move the ball, eg, keep it mostly on course, with some
1820 } 1817 }
1821 1818
1822 /* restore to the center location and damage */ 1819 /* restore to the center location and damage */
1823 op->stats.dam = dam_save; 1820 op->stats.dam = dam_save;
1824 1821
1825 i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); 1822 i = spell_find_dir (op->map, op->x, op->y, op->owner);
1826 1823
1827 if (i >= 0) 1824 if (i >= 0)
1828 { /* we have a preferred direction! */ 1825 { /* we have a preferred direction! */
1829 /* pick another direction if the preferred dir is blocked. */ 1826 /* pick another direction if the preferred dir is blocked. */
1830 if (get_map_flags (op->map, &m, nx + freearr_x[i], ny + freearr_y[i], &hx, &hy) & P_OUT_OF_MAP || 1827 if (get_map_flags (op->map, &m, nx + freearr_x[i], ny + freearr_y[i], &hx, &hy) & P_OUT_OF_MAP ||
1856 maptile *m; 1853 maptile *m;
1857#endif 1854#endif
1858 int basedir; 1855 int basedir;
1859 object *owner; 1856 object *owner;
1860 1857
1861 owner = get_owner (op); 1858 owner = op->owner;
1862 if (op->duration == 0 || owner == NULL) 1859 if (op->duration == 0 || owner == NULL)
1863 { 1860 {
1864 op->destroy (); 1861 op->destroy ();
1865 return; 1862 return;
1866 } 1863 }
1971 return 0; 1968 return 0;
1972 1969
1973 tmp = get_archetype (SWARM_SPELL); 1970 tmp = get_archetype (SWARM_SPELL);
1974 tmp->x = op->x; 1971 tmp->x = op->x;
1975 tmp->y = op->y; 1972 tmp->y = op->y;
1976 set_owner (tmp, op); /* needed so that if swarm elements kill, caster gets xp. */ 1973 tmp->set_owner (op); /* needed so that if swarm elements kill, caster gets xp. */
1977 set_spell_skill (op, caster, spell, tmp); 1974 set_spell_skill (op, caster, spell, tmp);
1978 1975
1979 tmp->level = caster_level (caster, spell); /*needed later, to get level dep. right. */ 1976 tmp->level = caster_level (caster, spell); /*needed later, to get level dep. right. */
1980 tmp->spell = arch_to_object (spell->other_arch); 1977 tmp->spell = arch_to_object (spell->other_arch);
1981 1978
2028 return 0; 2025 return 0;
2029 } 2026 }
2030 2027
2031 if (mflags & P_IS_ALIVE && spell->attacktype) 2028 if (mflags & P_IS_ALIVE && spell->attacktype)
2032 { 2029 {
2033 for (target = get_map_ob (m, x, y); target; target = target->above) 2030 for (target = GET_MAP_OB (m, x, y); target; target = target->above)
2034 if (QUERY_FLAG (target, FLAG_MONSTER)) 2031 if (QUERY_FLAG (target, FLAG_MONSTER))
2035 { 2032 {
2036 /* oky doky. got a target monster. Lets make a blinding attack */ 2033 /* oky doky. got a target monster. Lets make a blinding attack */
2037 if (target->head) 2034 if (target->head)
2038 target = target->head; 2035 target = target->head;
2120 2117
2121 /* Only bother looking on this space if there is something living here */ 2118 /* Only bother looking on this space if there is something living here */
2122 if (mflags & P_IS_ALIVE) 2119 if (mflags & P_IS_ALIVE)
2123 { 2120 {
2124 /* search this square for a victim */ 2121 /* search this square for a victim */
2125 for (walk = get_map_ob (m, x, y); walk; walk = walk->above) 2122 for (walk = GET_MAP_OB (m, x, y); walk; walk = walk->above)
2126 if (QUERY_FLAG (walk, FLAG_MONSTER) || (walk->type == PLAYER)) 2123 if (QUERY_FLAG (walk, FLAG_MONSTER) || (walk->type == PLAYER))
2127 { /* found a victim */ 2124 { /* found a victim */
2128 object *disease = arch_to_object (spell->other_arch); 2125 object *disease = arch_to_object (spell->other_arch);
2129 2126
2130 set_owner (disease, op); 2127 disease->set_owner (op);
2131 set_spell_skill (op, caster, spell, disease); 2128 set_spell_skill (op, caster, spell, disease);
2132 disease->stats.exp = 0; 2129 disease->stats.exp = 0;
2133 disease->level = caster_level (caster, spell); 2130 disease->level = caster_level (caster, spell);
2134 2131
2135 /* do level adjustments */ 2132 /* do level adjustments */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines