… | |
… | |
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 | || sp_op->type == LIGHTNING // XXX: elmex: why is LIGHTNING special cased here? |
|
|
450 | // most spells use subtypes for bolts today... |
|
|
451 | || (rndm (0, 99)) < 90 - (sp_op->level / 10))) |
449 | return 1; |
452 | return 1; |
450 | |
453 | |
451 | return 0; |
454 | return 0; |
452 | } |
455 | } |
453 | |
456 | |
… | |
… | |
504 | return 0; |
507 | return 0; |
505 | |
508 | |
506 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (mp, x, y))) |
509 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (mp, x, y))) |
507 | return 0; |
510 | return 0; |
508 | |
511 | |
509 | for (tmp = get_map_ob (mp, x, y); tmp != NULL; tmp = tmp->above) |
512 | for (tmp = GET_MAP_OB (mp, x, y); tmp != NULL; tmp = tmp->above) |
510 | { |
513 | { |
511 | /* If there is a counterspell on the space, and this |
514 | /* If there is a counterspell on the space, and this |
512 | * object is using magic, don't progress. I believe we could |
515 | * 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 |
516 | * 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 |
517 | * will then remove it, but that would seem to to use more |
… | |
… | |
602 | tmp->range = spell->range + SP_level_range_adjust (caster, spell); |
605 | tmp->range = spell->range + SP_level_range_adjust (caster, spell); |
603 | tmp->attacktype = spell->attacktype; |
606 | tmp->attacktype = spell->attacktype; |
604 | tmp->x = x; |
607 | tmp->x = x; |
605 | tmp->y = y; |
608 | tmp->y = y; |
606 | tmp->direction = dir; |
609 | tmp->direction = dir; |
607 | if (get_owner (op) != NULL) |
610 | if (op->owner != NULL) |
608 | copy_owner (tmp, op); |
611 | tmp->set_owner (op); |
609 | else |
612 | else |
610 | set_owner (tmp, op); |
613 | tmp->set_owner (op); |
611 | tmp->level = caster_level (caster, spell); |
614 | tmp->level = caster_level (caster, spell); |
612 | set_spell_skill (op, caster, spell, tmp); |
615 | set_spell_skill (op, caster, spell, tmp); |
613 | |
616 | |
614 | /* needed for AT_HOLYWORD,AT_GODPOWER stuff */ |
617 | /* needed for AT_HOLYWORD,AT_GODPOWER stuff */ |
615 | if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) |
618 | if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) |
… | |
… | |
677 | * we then make the owner of this object the target. |
680 | * we then make the owner of this object the target. |
678 | * The owner could very well be no where near op. |
681 | * The owner could very well be no where near op. |
679 | */ |
682 | */ |
680 | if (op->type != PLAYER && op->type != RUNE) |
683 | if (op->type != PLAYER && op->type != RUNE) |
681 | { |
684 | { |
682 | tmp = get_owner (op); |
685 | tmp = op->owner; |
683 | /* If the owner does not exist, or is not a monster, than apply the spell |
686 | /* If the owner does not exist, or is not a monster, than apply the spell |
684 | * to the caster. |
687 | * to the caster. |
685 | */ |
688 | */ |
686 | if (!tmp || !QUERY_FLAG (tmp, FLAG_MONSTER)) |
689 | if (!tmp || !QUERY_FLAG (tmp, FLAG_MONSTER)) |
687 | tmp = op; |
690 | tmp = op; |
… | |
… | |
696 | |
699 | |
697 | if (mflags & P_OUT_OF_MAP) |
700 | if (mflags & P_OUT_OF_MAP) |
698 | tmp = NULL; |
701 | tmp = NULL; |
699 | else |
702 | else |
700 | { |
703 | { |
701 | for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) |
704 | for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
702 | if (tmp->type == PLAYER) |
705 | if (tmp->type == PLAYER) |
703 | break; |
706 | break; |
704 | } |
707 | } |
705 | } |
708 | } |
706 | /* didn't find a player there, look in current square for a player */ |
709 | /* didn't find a player there, look in current square for a player */ |
707 | if (tmp == NULL) |
710 | if (tmp == NULL) |
708 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
711 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
709 | { |
712 | { |
710 | if (tmp->type == PLAYER) |
713 | if (tmp->type == PLAYER) |
711 | break; |
714 | break; |
712 | } |
715 | } |
713 | |
716 | |
… | |
… | |
749 | mp = m; |
752 | mp = m; |
750 | mflags = get_map_flags (m, &mp, nx, ny, &nx, &ny); |
753 | mflags = get_map_flags (m, &mp, nx, ny, &nx, &ny); |
751 | if (mflags & (P_OUT_OF_MAP | P_BLOCKSVIEW)) |
754 | if (mflags & (P_OUT_OF_MAP | P_BLOCKSVIEW)) |
752 | continue; |
755 | continue; |
753 | |
756 | |
754 | tmp = get_map_ob (mp, nx, ny); |
757 | tmp = GET_MAP_OB (mp, nx, ny); |
755 | |
758 | |
756 | while (tmp != NULL && (((owner_type == PLAYER && |
759 | while (tmp != NULL && (((owner_type == PLAYER && |
757 | !QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_GENERATOR)) || |
760 | !QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_GENERATOR)) || |
758 | (owner_type != PLAYER && tmp->type != PLAYER)) || (tmp == exclude || (tmp->head && tmp->head == exclude)))) |
761 | (owner_type != PLAYER && tmp->type != PLAYER)) || (tmp == exclude || (tmp->head && tmp->head == exclude)))) |
759 | tmp = tmp->above; |
762 | tmp = tmp->above; |
… | |
… | |
1277 | * spell is actually cast, it knows about the stringarg. |
1280 | * spell is actually cast, it knows about the stringarg. |
1278 | * necessary for the invoke command spells. |
1281 | * necessary for the invoke command spells. |
1279 | */ |
1282 | */ |
1280 | if (stringarg) |
1283 | if (stringarg) |
1281 | { |
1284 | { |
1282 | op->spellarg = strdup_local (stringarg); |
1285 | op->spellarg = strdup (stringarg); |
1283 | } |
1286 | } |
1284 | else |
1287 | else |
1285 | op->spellarg = NULL; |
1288 | op->spellarg = NULL; |
1286 | return 0; |
1289 | return 0; |
1287 | } |
1290 | } |