* Return 0 if nothing particular seems wrong, positive numbers for * serious trouble, and negative numbers for comparative annoyances. * This returns the worst problem. There may be others, and the gods * may fix more than one. * * This could get as bizarre as noting surrounding opponents, (or * hostile dogs), but that's really hard. * * We could force rehumanize of polyselfed people, but
| 195 | * hands; that's a case where the ramifications override this doubt. |
| 196 | */ |
| 197 | staticfn int |
| 198 | in_trouble(void) |
| 199 | { |
| 200 | struct obj *otmp; |
| 201 | int i; |
| 202 | |
| 203 | /* |
| 204 | * major troubles |
| 205 | */ |
| 206 | if (Stoned) |
| 207 | return TROUBLE_STONED; |
| 208 | if (Slimed) |
| 209 | return TROUBLE_SLIMED; |
| 210 | if (Strangled) |
| 211 | return TROUBLE_STRANGLED; |
| 212 | if (u.utrap && u.utraptype == TT_LAVA) |
| 213 | return TROUBLE_LAVA; |
| 214 | if (Sick) |
| 215 | return TROUBLE_SICK; |
| 216 | if (u.uhs >= WEAK) |
| 217 | return TROUBLE_STARVING; |
| 218 | if (region_danger()) |
| 219 | return TROUBLE_REGION; |
| 220 | if ((!Upolyd || Unchanging) && critically_low_hp(FALSE)) |
| 221 | return TROUBLE_HIT; |
| 222 | if (ismnum(u.ulycn)) |
| 223 | return TROUBLE_LYCANTHROPE; |
| 224 | if (near_capacity() >= EXT_ENCUMBER && AMAX(A_STR) - ABASE(A_STR) > 3) |
| 225 | return TROUBLE_COLLAPSING; |
| 226 | if (stuck_in_wall()) |
| 227 | return TROUBLE_STUCK_IN_WALL; |
| 228 | if (Cursed_obj(uarmf, LEVITATION_BOOTS) |
| 229 | || stuck_ring(uleft, RIN_LEVITATION) |
| 230 | || stuck_ring(uright, RIN_LEVITATION)) |
| 231 | return TROUBLE_CURSED_LEVITATION; |
| 232 | if (nohands(gy.youmonst.data) || !freehand()) { |
| 233 | /* for bag/box access [cf use_container()]... |
| 234 | make sure it's a case that we know how to handle; |
| 235 | otherwise "fix all troubles" would get stuck in a loop */ |
| 236 | if (welded(uwep)) |
| 237 | return TROUBLE_UNUSEABLE_HANDS; |
| 238 | if (Upolyd && nohands(gy.youmonst.data) |
| 239 | && (!Unchanging || ((otmp = unchanger()) != 0 && otmp->cursed))) |
| 240 | return TROUBLE_UNUSEABLE_HANDS; |
| 241 | } |
| 242 | if (Blindfolded && ublindf->cursed) |
| 243 | return TROUBLE_CURSED_BLINDFOLD; |
| 244 | |
| 245 | /* |
| 246 | * minor troubles |
| 247 | */ |
| 248 | if (Punished || (u.utrap && u.utraptype == TT_BURIEDBALL)) |
| 249 | return TROUBLE_PUNISHED; |
| 250 | if (Cursed_obj(uarmg, GAUNTLETS_OF_FUMBLING) |
| 251 | || Cursed_obj(uarmf, FUMBLE_BOOTS)) |
| 252 | return TROUBLE_FUMBLING; |
| 253 | if (worst_cursed_item()) |
| 254 | return TROUBLE_CURSED_ITEMS; |
no test coverage detected