for magic locking; returns true if targeted monster (which might be hero) gets hit by a trap (might avoid actually becoming trapped) */
| 6207 | /* for magic locking; returns true if targeted monster (which might |
| 6208 | be hero) gets hit by a trap (might avoid actually becoming trapped) */ |
| 6209 | boolean |
| 6210 | closeholdingtrap( |
| 6211 | struct monst *mon, |
| 6212 | boolean *noticed) /* set to true iff hero notices the effect; |
| 6213 | * otherwise left with its previous value intact */ |
| 6214 | { |
| 6215 | struct trap *t; |
| 6216 | unsigned dotrapflags; |
| 6217 | boolean ishero = (mon == &gy.youmonst), result; |
| 6218 | |
| 6219 | if (!mon) |
| 6220 | return FALSE; |
| 6221 | if (mon == u.usteed) |
| 6222 | ishero = TRUE; |
| 6223 | t = t_at(ishero ? u.ux : mon->mx, ishero ? u.uy : mon->my); |
| 6224 | /* if no trap here or it's not a holding trap, we're done */ |
| 6225 | if (!t || (t->ttyp != BEAR_TRAP && t->ttyp != WEB)) |
| 6226 | return FALSE; |
| 6227 | |
| 6228 | if (ishero) { |
| 6229 | if (u.utrap) |
| 6230 | return FALSE; /* already trapped */ |
| 6231 | *noticed = TRUE; |
| 6232 | dotrapflags = FORCETRAP; |
| 6233 | /* dotrap calls mintrap when mounted hero encounters a web */ |
| 6234 | if (u.usteed) |
| 6235 | dotrapflags |= NOWEBMSG; |
| 6236 | dotrap(t, dotrapflags | FORCETRAP); |
| 6237 | result = (u.utrap != 0); |
| 6238 | } else { |
| 6239 | if (mon->mtrapped) |
| 6240 | return FALSE; /* already trapped */ |
| 6241 | /* you notice it if you see the trap close/tremble/whatever |
| 6242 | or if you sense the monster who becomes trapped */ |
| 6243 | *noticed = cansee(t->tx, t->ty) || canspotmon(mon); |
| 6244 | result = (mintrap(mon, FORCETRAP) != Trap_Effect_Finished); |
| 6245 | } |
| 6246 | return result; |
| 6247 | } |
| 6248 | |
| 6249 | /* for magic unlocking; returns true if targeted monster (which might |
| 6250 | be hero) gets hit by a trap (target might avoid its effect) */ |
no test coverage detected