… | |
… | |
441 | { |
441 | { |
442 | object *op; |
442 | object *op; |
443 | |
443 | |
444 | if (OUT_OF_REAL_MAP (m, x, y)) |
444 | if (OUT_OF_REAL_MAP (m, x, y)) |
445 | return 0; |
445 | return 0; |
446 | for (op = get_map_ob (m, x, y); op != NULL; op = op->above) |
446 | for (op = GET_MAP_OB (m, x, y); op != NULL; op = op->above) |
447 | if (QUERY_FLAG (op, FLAG_REFL_SPELL) && (!QUERY_FLAG (op, FLAG_ALIVE) || |
447 | if (QUERY_FLAG (op, FLAG_REFL_SPELL) |
448 | sp_op->type == LIGHTNING || (rndm (0, 99)) < 90 - (sp_op->level / 10))) |
448 | && (!QUERY_FLAG (op, FLAG_ALIVE) |
|
|
449 | || (rndm (0, 99)) < 90 - (sp_op->level / 10))) |
449 | return 1; |
450 | return 1; |
450 | |
451 | |
451 | return 0; |
452 | return 0; |
452 | } |
453 | } |
453 | |
454 | |
… | |
… | |
504 | return 0; |
505 | return 0; |
505 | |
506 | |
506 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (mp, x, y))) |
507 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (mp, x, y))) |
507 | return 0; |
508 | return 0; |
508 | |
509 | |
509 | for (tmp = get_map_ob (mp, x, y); tmp != NULL; tmp = tmp->above) |
510 | for (tmp = GET_MAP_OB (mp, x, y); tmp != NULL; tmp = tmp->above) |
510 | { |
511 | { |
511 | /* If there is a counterspell on the space, and this |
512 | /* If there is a counterspell on the space, and this |
512 | * object is using magic, don't progress. I believe we could |
513 | * object is using magic, don't progress. I believe we could |
513 | * leave this out and let in progress, and other areas of the code |
514 | * leave this out and let in progress, and other areas of the code |
514 | * will then remove it, but that would seem to to use more |
515 | * will then remove it, but that would seem to to use more |
… | |
… | |
589 | return 0; |
590 | return 0; |
590 | |
591 | |
591 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, x, y))) |
592 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, x, y))) |
592 | { |
593 | { |
593 | new_draw_info (NDI_UNIQUE, 0, op, "You can't cast the spell on top of a wall!\n"); |
594 | new_draw_info (NDI_UNIQUE, 0, op, "You can't cast the spell on top of a wall!\n"); |
594 | tmp->destroy (0); |
595 | tmp->destroy (); |
595 | return 0; |
596 | return 0; |
596 | } |
597 | } |
597 | |
|
|
598 | |
|
|
599 | |
598 | |
600 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
599 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
601 | tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); |
600 | tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); |
602 | /* code in time.c uses food for some things, duration for others */ |
601 | /* code in time.c uses food for some things, duration for others */ |
603 | tmp->stats.food = tmp->duration; |
602 | tmp->stats.food = tmp->duration; |
604 | tmp->range = spell->range + SP_level_range_adjust (caster, spell); |
603 | tmp->range = spell->range + SP_level_range_adjust (caster, spell); |
605 | tmp->attacktype = spell->attacktype; |
604 | tmp->attacktype = spell->attacktype; |
606 | tmp->x = x; |
605 | tmp->x = x; |
607 | tmp->y = y; |
606 | tmp->y = y; |
608 | tmp->direction = dir; |
607 | tmp->direction = dir; |
609 | if (get_owner (op) != NULL) |
608 | if (op->owner != NULL) |
610 | copy_owner (tmp, op); |
609 | tmp->set_owner (op); |
611 | else |
610 | else |
612 | set_owner (tmp, op); |
611 | tmp->set_owner (op); |
613 | tmp->level = caster_level (caster, spell); |
612 | tmp->level = caster_level (caster, spell); |
614 | set_spell_skill (op, caster, spell, tmp); |
613 | set_spell_skill (op, caster, spell, tmp); |
615 | |
614 | |
616 | /* needed for AT_HOLYWORD,AT_GODPOWER stuff */ |
615 | /* needed for AT_HOLYWORD,AT_GODPOWER stuff */ |
617 | if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) |
616 | if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) |
… | |
… | |
679 | * we then make the owner of this object the target. |
678 | * we then make the owner of this object the target. |
680 | * The owner could very well be no where near op. |
679 | * The owner could very well be no where near op. |
681 | */ |
680 | */ |
682 | if (op->type != PLAYER && op->type != RUNE) |
681 | if (op->type != PLAYER && op->type != RUNE) |
683 | { |
682 | { |
684 | tmp = get_owner (op); |
683 | tmp = op->owner; |
685 | /* If the owner does not exist, or is not a monster, than apply the spell |
684 | /* If the owner does not exist, or is not a monster, than apply the spell |
686 | * to the caster. |
685 | * to the caster. |
687 | */ |
686 | */ |
688 | if (!tmp || !QUERY_FLAG (tmp, FLAG_MONSTER)) |
687 | if (!tmp || !QUERY_FLAG (tmp, FLAG_MONSTER)) |
689 | tmp = op; |
688 | tmp = op; |
… | |
… | |
695 | y = op->y + freearr_y[dir]; |
694 | y = op->y + freearr_y[dir]; |
696 | |
695 | |
697 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
696 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
698 | |
697 | |
699 | if (mflags & P_OUT_OF_MAP) |
698 | if (mflags & P_OUT_OF_MAP) |
700 | tmp = NULL; |
699 | tmp = 0; |
701 | else |
700 | else |
702 | { |
701 | tmp = m->at (x, y).player (); |
703 | for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) |
|
|
704 | if (tmp->type == PLAYER) |
|
|
705 | break; |
|
|
706 | } |
|
|
707 | } |
702 | } |
|
|
703 | |
708 | /* didn't find a player there, look in current square for a player */ |
704 | /* didn't find a player there, look in current square for a player */ |
709 | if (tmp == NULL) |
705 | if (!tmp) |
710 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
706 | tmp = op->ms ().player (); |
711 | { |
|
|
712 | if (tmp->type == PLAYER) |
|
|
713 | break; |
|
|
714 | } |
|
|
715 | |
707 | |
716 | return tmp; |
708 | return tmp; |
717 | } |
709 | } |
718 | |
710 | |
719 | |
711 | |
… | |
… | |
751 | mp = m; |
743 | mp = m; |
752 | mflags = get_map_flags (m, &mp, nx, ny, &nx, &ny); |
744 | mflags = get_map_flags (m, &mp, nx, ny, &nx, &ny); |
753 | if (mflags & (P_OUT_OF_MAP | P_BLOCKSVIEW)) |
745 | if (mflags & (P_OUT_OF_MAP | P_BLOCKSVIEW)) |
754 | continue; |
746 | continue; |
755 | |
747 | |
756 | tmp = get_map_ob (mp, nx, ny); |
748 | tmp = GET_MAP_OB (mp, nx, ny); |
757 | |
749 | |
758 | while (tmp != NULL && (((owner_type == PLAYER && |
750 | while (tmp != NULL && (((owner_type == PLAYER && |
759 | !QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_GENERATOR)) || |
751 | !QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_GENERATOR)) || |
760 | (owner_type != PLAYER && tmp->type != PLAYER)) || (tmp == exclude || (tmp->head && tmp->head == exclude)))) |
752 | (owner_type != PLAYER && tmp->type != PLAYER)) || (tmp == exclude || (tmp->head && tmp->head == exclude)))) |
761 | tmp = tmp->above; |
753 | tmp = tmp->above; |
… | |
… | |
957 | if (failure <= -20 && failure > -40) /* wonder */ |
949 | if (failure <= -20 && failure > -40) /* wonder */ |
958 | { |
950 | { |
959 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s gives a sign to renew your faith.", godname); |
951 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s gives a sign to renew your faith.", godname); |
960 | tmp = get_archetype (SPELL_WONDER); |
952 | tmp = get_archetype (SPELL_WONDER); |
961 | cast_cone (op, op, 0, tmp); |
953 | cast_cone (op, op, 0, tmp); |
962 | tmp->destroy (0); |
954 | tmp->destroy (); |
963 | } |
955 | } |
964 | |
956 | |
965 | else if (failure <= -40 && failure > -60) /* confusion */ |
957 | else if (failure <= -40 && failure > -60) /* confusion */ |
966 | { |
958 | { |
967 | new_draw_info (NDI_UNIQUE, 0, op, "Your diety touches your mind!"); |
959 | new_draw_info (NDI_UNIQUE, 0, op, "Your diety touches your mind!"); |
… | |
… | |
1001 | if (failure <= -20 && failure > -40) /* wonder */ |
993 | if (failure <= -20 && failure > -40) /* wonder */ |
1002 | { |
994 | { |
1003 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell causes an unexpected effect."); |
995 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell causes an unexpected effect."); |
1004 | tmp = get_archetype (SPELL_WONDER); |
996 | tmp = get_archetype (SPELL_WONDER); |
1005 | cast_cone (op, op, 0, tmp); |
997 | cast_cone (op, op, 0, tmp); |
1006 | tmp->destroy (0); |
998 | tmp->destroy (); |
1007 | } |
999 | } |
1008 | |
1000 | |
1009 | else if (failure <= -40 && failure > -60) /* confusion */ |
1001 | else if (failure <= -40 && failure > -60) /* confusion */ |
1010 | { |
1002 | { |
1011 | new_draw_info (NDI_UNIQUE, 0, op, "Your magic recoils on you, making you confused!"); |
1003 | new_draw_info (NDI_UNIQUE, 0, op, "Your magic recoils on you, making you confused!"); |
… | |
… | |
1069 | if (caster->contr->party == NULL) |
1061 | if (caster->contr->party == NULL) |
1070 | { |
1062 | { |
1071 | spell->remove (); |
1063 | spell->remove (); |
1072 | return success; |
1064 | return success; |
1073 | } |
1065 | } |
1074 | for (pl = first_player; pl != NULL; pl = pl->next) |
1066 | for_all_players (pl) |
1075 | if ((pl->ob->contr->party == caster->contr->party) && (on_same_map (pl->ob, caster))) |
1067 | if ((pl->ob->contr->party == caster->contr->party) && (on_same_map (pl->ob, caster))) |
1076 | { |
1068 | { |
1077 | cast_spell (pl->ob, caster, pl->ob->facing, spell, stringarg); |
1069 | cast_spell (pl->ob, caster, pl->ob->facing, spell, stringarg); |
1078 | } |
1070 | } |
1079 | spell->remove (); |
1071 | spell->remove (); |
… | |
… | |
1279 | * spell is actually cast, it knows about the stringarg. |
1271 | * spell is actually cast, it knows about the stringarg. |
1280 | * necessary for the invoke command spells. |
1272 | * necessary for the invoke command spells. |
1281 | */ |
1273 | */ |
1282 | if (stringarg) |
1274 | if (stringarg) |
1283 | { |
1275 | { |
1284 | op->spellarg = strdup_local (stringarg); |
1276 | op->spellarg = strdup (stringarg); |
1285 | } |
1277 | } |
1286 | else |
1278 | else |
1287 | op->spellarg = NULL; |
1279 | op->spellarg = NULL; |
1288 | return 0; |
1280 | return 0; |
1289 | } |
1281 | } |
… | |
… | |
1682 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |
1674 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |
1683 | { |
1675 | { |
1684 | hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); |
1676 | hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); |
1685 | |
1677 | |
1686 | if (!spell->destroyed ()) |
1678 | if (!spell->destroyed ()) |
1687 | { |
|
|
1688 | spell->remove (); |
|
|
1689 | spell->destroy (0); |
1679 | spell->destroy (); |
1690 | } |
|
|
1691 | } |
1680 | } |
1692 | break; |
1681 | break; |
1693 | |
1682 | |
1694 | case SP_MOVING_BALL: |
1683 | case SP_MOVING_BALL: |
1695 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |
1684 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |