The part of m_move that deals with a monster attacking another monster (and * that monster possibly retaliating). * Extracted into its own function so that it can be called with monsters that * have special move patterns (shopkeepers, priests, etc) that want to attack * other monsters but aren't just roaming freely around the level (so allowing * m_move to run fully for them could select an i
| 2085 | * (mtmp died) or 3 (mtmp made its move). |
| 2086 | */ |
| 2087 | int |
| 2088 | m_move_aggress(struct monst *mtmp, coordxy x, coordxy y) |
| 2089 | { |
| 2090 | struct monst *mtmp2; |
| 2091 | int mstatus = 0; /* M_ATTK_MISS */ |
| 2092 | |
| 2093 | mtmp2 = m_at(x, y); |
| 2094 | if (mtmp2) { |
| 2095 | gb.bhitpos.x = x, gb.bhitpos.y = y; |
| 2096 | gn.notonhead = (x != mtmp2->mx || y != mtmp2->my); |
| 2097 | mstatus = mattackm(mtmp, mtmp2); |
| 2098 | } |
| 2099 | |
| 2100 | if ((mstatus & M_ATTK_AGR_DIED) || DEADMONSTER(mtmp)) /* aggressor died */ |
| 2101 | return MMOVE_DIED; |
| 2102 | |
| 2103 | if ((mstatus & (M_ATTK_HIT | M_ATTK_DEF_DIED)) == M_ATTK_HIT |
| 2104 | && rn2(4) && mtmp2->movement > rn2(NORMAL_SPEED)) { |
| 2105 | if (mtmp2->movement > NORMAL_SPEED) |
| 2106 | mtmp2->movement -= NORMAL_SPEED; |
| 2107 | else |
| 2108 | mtmp2->movement = 0; |
| 2109 | gb.bhitpos.x = mtmp->mx, gb.bhitpos.y = mtmp->my; |
| 2110 | gn.notonhead = FALSE; |
| 2111 | mstatus = mattackm(mtmp2, mtmp); /* return attack */ |
| 2112 | /* note: at this point, defender is the original (moving) aggressor */ |
| 2113 | if (mstatus & M_ATTK_DEF_DIED) |
| 2114 | return MMOVE_DIED; |
| 2115 | } |
| 2116 | return MMOVE_DONE; |
| 2117 | } |
| 2118 | |
| 2119 | /* returns TRUE if a mon can hide under the obj */ |
| 2120 | boolean |
no test coverage detected