… | |
… | |
457 | } /* stand still */ |
457 | } /* stand still */ |
458 | return 0; |
458 | return 0; |
459 | } /* no enemy */ |
459 | } /* no enemy */ |
460 | |
460 | |
461 | /* We have an enemy. Block immediately below is for pets */ |
461 | /* We have an enemy. Block immediately below is for pets */ |
462 | if ((op->attack_movement & HI4) == PETMOVE && (owner = get_owner (op)) != NULL && !on_same_map (op, owner)) |
462 | if ((op->attack_movement & HI4) == PETMOVE && (owner = op->owner) != NULL && !on_same_map (op, owner)) |
463 | return follow_owner (op, owner); |
463 | return follow_owner (op, owner); |
464 | |
464 | |
465 | /* doppleganger code to change monster facing to that of the nearest |
465 | /* doppleganger code to change monster facing to that of the nearest |
466 | * player. Hmm. The code is here, but no monster in the current |
466 | * player. Hmm. The code is here, but no monster in the current |
467 | * arch set uses it. |
467 | * arch set uses it. |
… | |
… | |
788 | * other monsters) |
788 | * other monsters) |
789 | */ |
789 | */ |
790 | if (!(dir = path_to_player (part, pl, 0))) |
790 | if (!(dir = path_to_player (part, pl, 0))) |
791 | return 0; |
791 | return 0; |
792 | |
792 | |
793 | if (QUERY_FLAG (head, FLAG_FRIENDLY) && (owner = get_owner (head)) != NULL) |
793 | if (QUERY_FLAG (head, FLAG_FRIENDLY) && (owner = head->owner) != NULL) |
794 | { |
794 | { |
795 | get_rangevector (head, owner, &rv1, 0x1); |
795 | get_rangevector (head, owner, &rv1, 0x1); |
796 | if (dirdiff (dir, rv1.direction) < 2) |
796 | if (dirdiff (dir, rv1.direction) < 2) |
797 | { |
797 | { |
798 | return 0; /* Might hit owner with spell */ |
798 | return 0; /* Might hit owner with spell */ |
… | |
… | |
865 | * other monsters) |
865 | * other monsters) |
866 | */ |
866 | */ |
867 | if (!(dir = path_to_player (part, pl, 0))) |
867 | if (!(dir = path_to_player (part, pl, 0))) |
868 | return 0; |
868 | return 0; |
869 | |
869 | |
870 | if (QUERY_FLAG (head, FLAG_FRIENDLY) && (owner = get_owner (head)) != NULL) |
870 | if (QUERY_FLAG (head, FLAG_FRIENDLY) && (owner = head->owner) != NULL) |
871 | { |
871 | { |
872 | get_rangevector (head, owner, &rv1, 0x1); |
872 | get_rangevector (head, owner, &rv1, 0x1); |
873 | if (dirdiff (dir, rv1.direction) < 2) |
873 | if (dirdiff (dir, rv1.direction) < 2) |
874 | { |
874 | { |
875 | return 0; /* Might hit owner with spell */ |
875 | return 0; /* Might hit owner with spell */ |
… | |
… | |
916 | object *skill, *owner; |
916 | object *skill, *owner; |
917 | |
917 | |
918 | if (!(dir = path_to_player (part, pl, 0))) |
918 | if (!(dir = path_to_player (part, pl, 0))) |
919 | return 0; |
919 | return 0; |
920 | |
920 | |
921 | if (QUERY_FLAG (head, FLAG_FRIENDLY) && (owner = get_owner (head)) != NULL) |
921 | if (QUERY_FLAG (head, FLAG_FRIENDLY) && (owner = head->owner) != NULL) |
922 | { |
922 | { |
923 | int dir2 = find_dir_2 (head->x - owner->x, head->y - owner->y); |
923 | int dir2 = find_dir_2 (head->x - owner->x, head->y - owner->y); |
924 | |
924 | |
925 | if (dirdiff (dir, dir2) < 1) |
925 | if (dirdiff (dir, dir2) < 1) |
926 | return 0; /* Might hit owner with skill -thrown rocks for example ? */ |
926 | return 0; /* Might hit owner with skill -thrown rocks for example ? */ |
… | |
… | |
960 | int at_least_one = 0; |
960 | int at_least_one = 0; |
961 | |
961 | |
962 | if (!(dir = path_to_player (part, pl, 0))) |
962 | if (!(dir = path_to_player (part, pl, 0))) |
963 | return 0; |
963 | return 0; |
964 | |
964 | |
965 | if (QUERY_FLAG (head, FLAG_FRIENDLY) && (owner = get_owner (head)) != NULL) |
965 | if (QUERY_FLAG (head, FLAG_FRIENDLY) && (owner = head->owner) != NULL) |
966 | { |
966 | { |
967 | int dir2 = find_dir_2 (head->x - owner->x, head->y - owner->y); |
967 | int dir2 = find_dir_2 (head->x - owner->x, head->y - owner->y); |
968 | |
968 | |
969 | if (dirdiff (dir, dir2) < 2) |
969 | if (dirdiff (dir, dir2) < 2) |
970 | return 0; /* Might hit owner with spell */ |
970 | return 0; /* Might hit owner with spell */ |
… | |
… | |
1031 | if (!(dir = path_to_player (part, pl, 0))) |
1031 | if (!(dir = path_to_player (part, pl, 0))) |
1032 | return 0; |
1032 | return 0; |
1033 | if (QUERY_FLAG (head, FLAG_CONFUSED)) |
1033 | if (QUERY_FLAG (head, FLAG_CONFUSED)) |
1034 | dir = absdir (dir + RANDOM () % 3 + RANDOM () % 3 - 2); |
1034 | dir = absdir (dir + RANDOM () % 3 + RANDOM () % 3 - 2); |
1035 | |
1035 | |
1036 | if (QUERY_FLAG (head, FLAG_FRIENDLY) && (owner = get_owner (head)) != NULL) |
1036 | if (QUERY_FLAG (head, FLAG_FRIENDLY) && (owner = head->owner) != NULL) |
1037 | { |
1037 | { |
1038 | int dir2 = find_dir_2 (head->x - owner->x, head->y - owner->y); |
1038 | int dir2 = find_dir_2 (head->x - owner->x, head->y - owner->y); |
1039 | |
1039 | |
1040 | if (dirdiff (dir, dir2) < 1) |
1040 | if (dirdiff (dir, dir2) < 1) |
1041 | return 0; /* Might hit owner with arrow */ |
1041 | return 0; /* Might hit owner with arrow */ |