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.13 by root, Thu Sep 14 22:34:05 2006 UTC vs.
Revision 1.15 by root, Sat Sep 16 22:24:13 2006 UTC

117void 117void
118forklightning (object *op, object *tmp) 118forklightning (object *op, object *tmp)
119{ 119{
120 int new_dir = 1; /* direction or -1 for left, +1 for right 0 if no new bolt */ 120 int new_dir = 1; /* direction or -1 for left, +1 for right 0 if no new bolt */
121 int t_dir; /* stores temporary dir calculation */ 121 int t_dir; /* stores temporary dir calculation */
122 mapstruct *m; 122 maptile *m;
123 sint16 sx, sy; 123 sint16 sx, sy;
124 object *new_bolt; 124 object *new_bolt;
125 125
126 /* pick a fork direction. tmp->stats.Con is the left bias 126 /* pick a fork direction. tmp->stats.Con is the left bias
127 * i.e., the chance in 100 of forking LEFT 127 * i.e., the chance in 100 of forking LEFT
170move_bolt (object *op) 170move_bolt (object *op)
171{ 171{
172 object *tmp; 172 object *tmp;
173 int mflags; 173 int mflags;
174 sint16 x, y; 174 sint16 x, y;
175 mapstruct *m; 175 maptile *m;
176 176
177 if (--(op->duration) < 0) 177 if (--(op->duration) < 0)
178 { 178 {
179 remove_ob (op); 179 remove_ob (op);
180 free_object (op); 180 free_object (op);
356 */ 356 */
357void 357void
358explosion (object *op) 358explosion (object *op)
359{ 359{
360 object *tmp; 360 object *tmp;
361 mapstruct *m = op->map; 361 maptile *m = op->map;
362 int i; 362 int i;
363 363
364 if (--(op->duration) < 0) 364 if (--(op->duration) < 0)
365 { 365 {
366 remove_ob (op); 366 remove_ob (op);
402 * explode. 402 * explode.
403 */ 403 */
404void 404void
405explode_bullet (object *op) 405explode_bullet (object *op)
406{ 406{
407 tag_t op_tag = op->count;
408 object *tmp, *owner; 407 object *tmp, *owner;
409 408
410 if (op->other_arch == NULL) 409 if (op->other_arch == NULL)
411 { 410 {
412 LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); 411 LOG (llevError, "BUG: explode_bullet(): op without other_arch\n");
451 } 450 }
452 451
453 if (op->attacktype) 452 if (op->attacktype)
454 { 453 {
455 hit_map (op, 0, op->attacktype, 1); 454 hit_map (op, 0, op->attacktype, 1);
456 if (was_destroyed (op, op_tag)) 455 if (op->destroyed ())
457 return; 456 return;
458 } 457 }
459 458
460 /* other_arch contains what this explodes into */ 459 /* other_arch contains what this explodes into */
461 tmp = arch_to_object (op->other_arch); 460 tmp = arch_to_object (op->other_arch);
504 /* Prevent recursion */ 503 /* Prevent recursion */
505 op->move_on = 0; 504 op->move_on = 0;
506 505
507 insert_ob_in_map (tmp, op->map, op, 0); 506 insert_ob_in_map (tmp, op->map, op, 0);
508 /* remove the firebullet */ 507 /* remove the firebullet */
509 if (!was_destroyed (op, op_tag)) 508 if (!op->destroyed ())
510 { 509 {
511 remove_ob (op); 510 remove_ob (op);
512 free_object (op); 511 free_object (op);
513 } 512 }
514} 513}
520 */ 519 */
521 520
522void 521void
523check_bullet (object *op) 522check_bullet (object *op)
524{ 523{
525 tag_t op_tag = op->count, tmp_tag;
526 object *tmp; 524 object *tmp;
527 int dam, mflags; 525 int dam, mflags;
528 mapstruct *m; 526 maptile *m;
529 sint16 sx, sy; 527 sint16 sx, sy;
530 528
531 mflags = get_map_flags (op->map, &m, op->x, op->y, &sx, &sy); 529 mflags = get_map_flags (op->map, &m, op->x, op->y, &sx, &sy);
532 530
533 if (!(mflags & P_IS_ALIVE) && !OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) 531 if (!(mflags & P_IS_ALIVE) && !OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy)))
546 544
547 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)
548 { 546 {
549 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 547 if (QUERY_FLAG (tmp, FLAG_ALIVE))
550 { 548 {
551 tmp_tag = tmp->count;
552 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); 549 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1);
553 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)
554 { 551 {
555 if (!QUERY_FLAG (op, FLAG_REMOVED)) 552 if (!QUERY_FLAG (op, FLAG_REMOVED))
556 { 553 {
557 remove_ob (op); 554 remove_ob (op);
558 free_object (op); 555 free_object (op);
573void 570void
574move_bullet (object *op) 571move_bullet (object *op)
575{ 572{
576 sint16 new_x, new_y; 573 sint16 new_x, new_y;
577 int mflags; 574 int mflags;
578 mapstruct *m; 575 maptile *m;
579 576
580#if 0 577#if 0
581 /* We need a better general purpose way to do this */ 578 /* We need a better general purpose way to do this */
582 579
583 /* peterm: added to make comet leave a trail of burnouts 580 /* peterm: added to make comet leave a trail of burnouts
584 it's an unadulterated hack, but the effect is cool. */ 581 it's an unadulterated hack, but the effect is cool. */
585 if (op->stats.sp == SP_METEOR) 582 if (op->stats.sp == SP_METEOR)
586 { 583 {
587 replace_insert_ob_in_map ("fire_trail", op); 584 replace_insert_ob_in_map ("fire_trail", op);
588 if (was_destroyed (op, op_tag)) 585 if (op->destroyed ())
589 return; 586 return;
590 } /* end addition. */ 587 } /* end addition. */
591#endif 588#endif
592 589
593 /* Reached the end of its life - remove it */ 590 /* Reached the end of its life - remove it */
756 753
757void 754void
758move_cone (object *op) 755move_cone (object *op)
759{ 756{
760 int i; 757 int i;
761 tag_t tag;
762 758
763 /* 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 */
764 if (!op->map) 760 if (!op->map)
765 { 761 {
766 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");
787 free_object (op); 783 free_object (op);
788 return; 784 return;
789 } 785 }
790#endif 786#endif
791 787
792 tag = op->count;
793 hit_map (op, 0, op->attacktype, 0); 788 hit_map (op, 0, op->attacktype, 0);
794 789
795 /* Check to see if we should push anything. 790 /* Check to see if we should push anything.
796 * Spell objects with weight push whatever they encounter to some 791 * Spell objects with weight push whatever they encounter to some
797 * degree. 792 * degree.
798 */ 793 */
799 if (op->weight) 794 if (op->weight)
800 check_spell_knockback (op); 795 check_spell_knockback (op);
801 796
802 if (was_destroyed (op, tag)) 797 if (op->destroyed ())
803 return; 798 return;
804 799
805 if ((op->duration--) < 0) 800 if ((op->duration--) < 0)
806 { 801 {
807 remove_ob (op); 802 remove_ob (op);
852int 847int
853cast_cone (object *op, object *caster, int dir, object *spell) 848cast_cone (object *op, object *caster, int dir, object *spell)
854{ 849{
855 object *tmp; 850 object *tmp;
856 int i, success = 0, range_min = -1, range_max = 1; 851 int i, success = 0, range_min = -1, range_max = 1;
857 mapstruct *m; 852 maptile *m;
858 sint16 sx, sy; 853 sint16 sx, sy;
859 MoveType movetype; 854 MoveType movetype;
860 855
861 if (!spell->other_arch) 856 if (!spell->other_arch)
862 return 0; 857 return 0;
1075{ 1070{
1076 1071
1077 object *tmp; 1072 object *tmp;
1078 int mflags; 1073 int mflags;
1079 sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir]; 1074 sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir];
1080 mapstruct *m; 1075 maptile *m;
1081 1076
1082 mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy); 1077 mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy);
1083 if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK)) 1078 if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK))
1084 { 1079 {
1085 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); 1080 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way.");
1121get_pointed_target (object *op, int dir, int range, int type) 1116get_pointed_target (object *op, int dir, int range, int type)
1122{ 1117{
1123 object *target; 1118 object *target;
1124 sint16 x, y; 1119 sint16 x, y;
1125 int dist, mflags; 1120 int dist, mflags;
1126 mapstruct *mp; 1121 maptile *mp;
1127 1122
1128 if (dir == 0) 1123 if (dir == 0)
1129 return NULL; 1124 return NULL;
1130 1125
1131 for (dist = 1; dist < range; dist++) 1126 for (dist = 1; dist < range; dist++)
1271move_missile (object *op) 1266move_missile (object *op)
1272{ 1267{
1273 int i, mflags; 1268 int i, mflags;
1274 object *owner; 1269 object *owner;
1275 sint16 new_x, new_y; 1270 sint16 new_x, new_y;
1276 mapstruct *m; 1271 maptile *m;
1277 1272
1278 if (op->range-- <= 0) 1273 if (op->range-- <= 0)
1279 { 1274 {
1280 remove_ob (op); 1275 remove_ob (op);
1281 free_object (op); 1276 free_object (op);
1300 1295
1301 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);
1302 1297
1303 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))))
1304 { 1299 {
1305 tag_t tag = op->count;
1306
1307 hit_map (op, op->direction, AT_MAGIC, 1); 1300 hit_map (op, op->direction, AT_MAGIC, 1);
1308 /* Basically, missile only hits one thing then goes away. 1301 /* Basically, missile only hits one thing then goes away.
1309 * 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.
1310 */ 1303 */
1311 if (!was_destroyed (op, tag)) 1304 if (!op->destroyed ())
1312 {
1313 remove_ob (op);
1314 free_object (op); 1305 free_object (op);
1315 } 1306
1316 return; 1307 return;
1317 } 1308 }
1318 1309
1319 remove_ob (op); 1310 remove_ob (op);
1311
1320 if (!op->direction || (mflags & P_OUT_OF_MAP)) 1312 if (!op->direction || (mflags & P_OUT_OF_MAP))
1321 { 1313 {
1322 free_object (op); 1314 free_object (op);
1323 return; 1315 return;
1324 } 1316 }
1317
1325 op->x = new_x; 1318 op->x = new_x;
1326 op->y = new_y; 1319 op->y = new_y;
1327 op->map = m; 1320 op->map = m;
1328 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));
1329 if (i > 0 && i != op->direction) 1322 if (i > 0 && i != op->direction)
1330 { 1323 {
1331 op->direction = i; 1324 op->direction = i;
1332 SET_ANIMATION (op, op->direction); 1325 SET_ANIMATION (op, op->direction);
1333 } 1326 }
1327
1334 insert_ob_in_map (op, op->map, op, 0); 1328 insert_ob_in_map (op, op->map, op, 0);
1335} 1329}
1336 1330
1337/**************************************************************************** 1331/****************************************************************************
1338 * Destruction 1332 * Destruction
1384int 1378int
1385cast_destruction (object *op, object *caster, object *spell_ob) 1379cast_destruction (object *op, object *caster, object *spell_ob)
1386{ 1380{
1387 int i, j, range, mflags, friendly = 0, dam, dur; 1381 int i, j, range, mflags, friendly = 0, dam, dur;
1388 sint16 sx, sy; 1382 sint16 sx, sy;
1389 mapstruct *m; 1383 maptile *m;
1390 object *tmp; 1384 object *tmp;
1391 const char *skill; 1385 const char *skill;
1392 1386
1393 range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); 1387 range = spell_ob->range + SP_level_range_adjust (caster, spell_ob);
1394 dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); 1388 dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob);
1576mood_change (object *op, object *caster, object *spell) 1570mood_change (object *op, object *caster, object *spell)
1577{ 1571{
1578 object *tmp, *god, *head; 1572 object *tmp, *god, *head;
1579 int done_one, range, mflags, level, at, best_at; 1573 int done_one, range, mflags, level, at, best_at;
1580 sint16 x, y, nx, ny; 1574 sint16 x, y, nx, ny;
1581 mapstruct *m; 1575 maptile *m;
1582 const char *race; 1576 const char *race;
1583 1577
1584 /* We precompute some values here so that we don't have to keep 1578 /* We precompute some values here so that we don't have to keep
1585 * doing it over and over again. 1579 * doing it over and over again.
1586 */ 1580 */
1750move_ball_spell (object *op) 1744move_ball_spell (object *op)
1751{ 1745{
1752 int i, j, dam_save, dir, mflags; 1746 int i, j, dam_save, dir, mflags;
1753 sint16 nx, ny, hx, hy; 1747 sint16 nx, ny, hx, hy;
1754 object *owner; 1748 object *owner;
1755 mapstruct *m; 1749 maptile *m;
1756 1750
1757 owner = get_owner (op); 1751 owner = get_owner (op);
1758 1752
1759 /* the following logic makes sure that the ball doesn't move into a wall, 1753 /* the following logic makes sure that the ball doesn't move into a wall,
1760 * and makes sure that it will move along a wall to try and get at it's 1754 * and makes sure that it will move along a wall to try and get at it's
1872#if 0 1866#if 0
1873 static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 }; 1867 static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 };
1874 static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 }; 1868 static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 };
1875 sint16 target_x, target_y, origin_x, origin_y; 1869 sint16 target_x, target_y, origin_x, origin_y;
1876 int adjustdir; 1870 int adjustdir;
1877 mapstruct *m; 1871 maptile *m;
1878#endif 1872#endif
1879 int basedir; 1873 int basedir;
1880 object *owner; 1874 object *owner;
1881 1875
1882 owner = get_owner (op); 1876 owner = get_owner (op);
2025cast_light (object *op, object *caster, object *spell, int dir) 2019cast_light (object *op, object *caster, object *spell, int dir)
2026{ 2020{
2027 object *target = NULL, *tmp = NULL; 2021 object *target = NULL, *tmp = NULL;
2028 sint16 x, y; 2022 sint16 x, y;
2029 int dam, mflags; 2023 int dam, mflags;
2030 mapstruct *m; 2024 maptile *m;
2031 2025
2032 dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 2026 dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
2033 2027
2034 if (!dir) 2028 if (!dir)
2035 { 2029 {
2103cast_cause_disease (object *op, object *caster, object *spell, int dir) 2097cast_cause_disease (object *op, object *caster, object *spell, int dir)
2104{ 2098{
2105 sint16 x, y; 2099 sint16 x, y;
2106 int i, mflags, range, dam_mod, dur_mod; 2100 int i, mflags, range, dam_mod, dur_mod;
2107 object *walk; 2101 object *walk;
2108 mapstruct *m; 2102 maptile *m;
2109 2103
2110 x = op->x; 2104 x = op->x;
2111 y = op->y; 2105 y = op->y;
2112 2106
2113 /* If casting from a scroll, no direction will be available, so refer to the 2107 /* If casting from a scroll, no direction will be available, so refer to the

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines