… | |
… | |
635 | drain_rod_charge (object *rod) |
635 | drain_rod_charge (object *rod) |
636 | { |
636 | { |
637 | rod->stats.hp -= SP_level_spellpoint_cost (rod, rod->inv, SPELL_HIGHEST); |
637 | rod->stats.hp -= SP_level_spellpoint_cost (rod, rod->inv, SPELL_HIGHEST); |
638 | } |
638 | } |
639 | |
639 | |
640 | |
|
|
641 | |
|
|
642 | |
|
|
643 | /* this function is commonly used to find a friendly target for |
640 | /* this function is commonly used to find a friendly target for |
644 | * spells such as heal or protection or armour |
641 | * spells such as heal or protection or armour |
645 | * op is what is looking for the target (which can be a player), |
642 | * op is what is looking for the target (which can be a player), |
646 | * dir is the direction we are looking in. Return object found, or |
643 | * dir is the direction we are looking in. Return object found, or |
647 | * NULL if no good object. |
644 | * NULL if no good object. |
648 | */ |
645 | */ |
649 | |
|
|
650 | object * |
646 | object * |
651 | find_target_for_friendly_spell (object *op, int dir) |
647 | find_target_for_friendly_spell (object *op, int dir) |
652 | { |
648 | { |
653 | object *tmp; |
649 | object *tmp; |
654 | maptile *m; |
|
|
655 | sint16 x, y; |
|
|
656 | int mflags; |
|
|
657 | |
650 | |
658 | /* I don't really get this block - if op isn't a player or rune, |
651 | /* I don't really get this block - if op isn't a player or rune, |
659 | * we then make the owner of this object the target. |
652 | * we then make the owner of this object the target. |
660 | * The owner could very well be no where near op. |
653 | * The owner could very well be no where near op. |
661 | */ |
654 | */ |
… | |
… | |
668 | if (!tmp || !QUERY_FLAG (tmp, FLAG_MONSTER)) |
661 | if (!tmp || !QUERY_FLAG (tmp, FLAG_MONSTER)) |
669 | tmp = op; |
662 | tmp = op; |
670 | } |
663 | } |
671 | else |
664 | else |
672 | { |
665 | { |
673 | m = op->map; |
666 | maptile *m = op->map; |
674 | x = op->x + freearr_x[dir]; |
667 | sint16 x = op->x + freearr_x[dir]; |
675 | y = op->y + freearr_y[dir]; |
668 | sint16 y = op->y + freearr_y[dir]; |
676 | |
|
|
677 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
|
|
678 | |
|
|
679 | if (mflags & P_OUT_OF_MAP) |
|
|
680 | tmp = 0; |
|
|
681 | else |
669 | |
|
|
670 | tmp = xy_normalise (m, x, y) |
682 | tmp = m->at (x, y).player (); |
671 | ? m->at (x, y).player () |
|
|
672 | : 0; |
683 | } |
673 | } |
684 | |
674 | |
685 | /* didn't find a player there, look in current square for a player */ |
675 | /* didn't find a player there, look in current square for a player */ |
686 | if (!tmp) |
676 | if (!tmp) |
687 | tmp = op->ms ().player (); |
677 | tmp = op->ms ().player (); |