| 691 | } |
| 692 | |
| 693 | staticfn int |
| 694 | find_friends(struct monst *mtmp, struct monst *mtarg, int maxdist) |
| 695 | { |
| 696 | struct monst *pal; |
| 697 | int dx = sgn(mtarg->mx - mtmp->mx), |
| 698 | dy = sgn(mtarg->my - mtmp->my); |
| 699 | int curx = mtarg->mx, cury = mtarg->my; |
| 700 | int dist = distmin(mtarg->mx, mtarg->my, mtmp->mx, mtmp->my); |
| 701 | |
| 702 | for ( ; dist <= maxdist; ++dist) { |
| 703 | curx += dx; |
| 704 | cury += dy; |
| 705 | |
| 706 | if (!isok(curx, cury)) |
| 707 | return 0; |
| 708 | |
| 709 | /* If the pet can't see beyond this point, don't |
| 710 | * check any farther |
| 711 | */ |
| 712 | if (!m_cansee(mtmp, curx, cury)) |
| 713 | return 0; |
| 714 | |
| 715 | /* Does pet think you're here? */ |
| 716 | if (mtmp->mux == curx && mtmp->muy == cury) |
| 717 | return 1; |
| 718 | |
| 719 | pal = m_at(curx, cury); |
| 720 | |
| 721 | if (pal) { |
| 722 | if (pal->mtame) { |
| 723 | /* Pet won't notice invisible pets */ |
| 724 | if (!pal->minvis || perceives(mtmp->data)) |
| 725 | return 1; |
| 726 | } else { |
| 727 | /* Quest leaders and guardians are always seen */ |
| 728 | if (pal->data->msound == MS_LEADER |
| 729 | || pal->data->msound == MS_GUARDIAN) |
| 730 | return 1; |
| 731 | } |
| 732 | } |
| 733 | } |
| 734 | return 0; |
| 735 | } |
| 736 | |
| 737 | staticfn long |
| 738 | score_targ(struct monst *mtmp, struct monst *mtarg) |
no test coverage detected