hero is moving, do we maybe attack a monster at (x,y)? returns TRUE if hero movement is used up. sets displaceu, if hero and monster could swap places instead. */
| 1952 | sets displaceu, if hero and monster could swap places instead. |
| 1953 | */ |
| 1954 | staticfn boolean |
| 1955 | domove_attackmon_at( |
| 1956 | struct monst *mtmp, |
| 1957 | coordxy x, coordxy y, |
| 1958 | boolean *displaceu) |
| 1959 | { |
| 1960 | /* assert(mtmp != NULL) */ |
| 1961 | /* only attack if we know it's there |
| 1962 | * or if we used the 'F' command to fight blindly |
| 1963 | * or if it hides_under, in which case we call do_attack() to print |
| 1964 | * the Wait! message. |
| 1965 | * This is different from ceiling hiders, who aren't handled in |
| 1966 | * do_attack(). |
| 1967 | */ |
| 1968 | if (svc.context.forcefight || !mtmp->mundetected || sensemon(mtmp) |
| 1969 | || ((hides_under(mtmp->data) || mtmp->data->mlet == S_EEL) |
| 1970 | && !is_safemon(mtmp))) { |
| 1971 | /* target monster might decide to switch places with you... */ |
| 1972 | *displaceu = (mtmp->data == &mons[PM_DISPLACER_BEAST] && !rn2(2) |
| 1973 | && mtmp->mux == u.ux0 && mtmp->muy == u.uy0 |
| 1974 | && !helpless(mtmp) |
| 1975 | && !mtmp->meating && !mtmp->mtrapped |
| 1976 | && !u.utrap && !u.ustuck && !u.usteed |
| 1977 | && !(u.dx && u.dy |
| 1978 | && (NODIAG(u.umonnum) |
| 1979 | || (bad_rock(mtmp->data, x, u.uy0) |
| 1980 | && bad_rock(mtmp->data, u.ux0, y)) |
| 1981 | || (bad_rock(gy.youmonst.data, u.ux0, y) |
| 1982 | && bad_rock(gy.youmonst.data, x, u.uy0)))) |
| 1983 | && goodpos(u.ux0, u.uy0, mtmp, GP_ALLOW_U)); |
| 1984 | /* if not displacing, try to attack; note that it might evade; |
| 1985 | also, we don't attack tame or peaceful when safemon() */ |
| 1986 | if (!*displaceu) { |
| 1987 | if (do_attack(mtmp)) |
| 1988 | return TRUE; |
| 1989 | } |
| 1990 | } |
| 1991 | return FALSE; |
| 1992 | } |
| 1993 | |
| 1994 | /* force-fight iron bars with your weapon? */ |
| 1995 | staticfn boolean |
no test coverage detected