MCPcopy Create free account
hub / github.com/NetHack/NetHack / destroy_arm

Function destroy_arm

src/do_wear.c:3277–3316  ·  view source on GitHub ↗

erode a number of worn armor(s). if the armor is hit when max eroded, destroys it. */

Source from the content-addressed store, hash-verified

3275/* erode a number of worn armor(s).
3276 if the armor is hit when max eroded, destroys it. */
3277int
3278destroy_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
3318void
3319adj_abon(struct obj *otmp, schar delta)

Callers 2

mcast_destroy_armorFunction · 0.85
seffect_destroy_armorFunction · 0.85

Calls 6

rn2Function · 0.85
erosion_mattersFunction · 0.85
obj_erode_typeFunction · 0.85
erode_objFunction · 0.85
xnameFunction · 0.85
stop_occupationFunction · 0.85

Tested by

no test coverage detected