erode a number of worn armor(s). if the armor is hit when max eroded, destroys it. */
| 3275 | /* erode a number of worn armor(s). |
| 3276 | if the armor is hit when max eroded, destroys it. */ |
| 3277 | int |
| 3278 | destroy_arm(void) |
| 3279 | { |
| 3280 | struct obj *armors[7] = { NULL }; |
| 3281 | struct obj *otmp; |
| 3282 | int i, idx = 0, hits = rn2(4) + 1; |
| 3283 | int ret = 0; |
| 3284 | |
| 3285 | /* gather worn armor; include non-erodeable ones */ |
| 3286 | if (uarm) armors[idx++] = uarm; |
| 3287 | if (uarmc) armors[idx++] = uarmc; |
| 3288 | if (uarmh) armors[idx++] = uarmh; |
| 3289 | if (uarms) armors[idx++] = uarms; |
| 3290 | if (uarmg) armors[idx++] = uarmg; |
| 3291 | if (uarmf) armors[idx++] = uarmf; |
| 3292 | if (uarmu) armors[idx++] = uarmu; |
| 3293 | if (!idx) |
| 3294 | return 0; |
| 3295 | |
| 3296 | for (i = 0; i < hits; i++) { |
| 3297 | otmp = armors[rn2(idx)]; |
| 3298 | |
| 3299 | if (erosion_matters(otmp) && is_damageable(otmp) && !otmp->oerodeproof) { |
| 3300 | int erosion = obj_erode_type(otmp); |
| 3301 | |
| 3302 | if (erosion != ERODE_NONE) { |
| 3303 | int r = erode_obj(otmp, xname(otmp), erosion, EF_PAY|EF_DESTROY); |
| 3304 | |
| 3305 | if (r != ER_NOTHING) |
| 3306 | ret = 1; |
| 3307 | if (r == ER_DESTROYED) |
| 3308 | break; |
| 3309 | } |
| 3310 | } |
| 3311 | } |
| 3312 | |
| 3313 | if (ret) |
| 3314 | stop_occupation(); |
| 3315 | return ret; |
| 3316 | } |
| 3317 | |
| 3318 | void |
| 3319 | adj_abon(struct obj *otmp, schar delta) |
no test coverage detected