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

Function erode_armor

src/uhitm.c:125–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123}
124
125void
126erode_armor(struct monst *mdef, int hurt)
127{
128 struct obj *target;
129
130 /* What the following code does: it keeps looping until it
131 * finds a target for the rust monster.
132 * Head, feet, etc... not covered by metal, or covered by
133 * rusty metal, are not targets. However, your body always
134 * is, no matter what covers it.
135 */
136 while (1) {
137 switch (rn2(5)) {
138 case 0:
139 target = which_armor(mdef, W_ARMH);
140 if (!target
141 || erode_obj(target, xname(target), hurt, EF_GREASE)
142 == ER_NOTHING)
143 continue;
144 break;
145 case 1:
146 target = which_armor(mdef, W_ARMC);
147 if (target) {
148 (void) erode_obj(target, xname(target), hurt,
149 EF_GREASE | EF_VERBOSE);
150 break;
151 }
152 if ((target = which_armor(mdef, W_ARM)) != (struct obj *) 0) {
153 (void) erode_obj(target, xname(target), hurt,
154 EF_GREASE | EF_VERBOSE);
155 } else if ((target = which_armor(mdef, W_ARMU))
156 != (struct obj *) 0) {
157 (void) erode_obj(target, xname(target), hurt,
158 EF_GREASE | EF_VERBOSE);
159 }
160 break;
161 case 2:
162 target = which_armor(mdef, W_ARMS);
163 if (!target
164 || erode_obj(target, xname(target), hurt, EF_GREASE)
165 == ER_NOTHING)
166 continue;
167 break;
168 case 3:
169 target = which_armor(mdef, W_ARMG);
170 if (!target
171 || erode_obj(target, xname(target), hurt, EF_GREASE)
172 == ER_NOTHING)
173 continue;
174 break;
175 case 4:
176 target = which_armor(mdef, W_ARMF);
177 if (!target
178 || erode_obj(target, xname(target), hurt, EF_GREASE)
179 == ER_NOTHING)
180 continue;
181 break;
182 }

Callers 9

mhitm_ad_rustFunction · 0.85
mhitm_ad_corrFunction · 0.85
mhitm_ad_dcayFunction · 0.85
mhitm_ad_acidFunction · 0.85
passiveFunction · 0.85
passivemmFunction · 0.85
zhitmFunction · 0.85
zhituFunction · 0.85
passiveumFunction · 0.85

Calls 4

rn2Function · 0.85
which_armorFunction · 0.85
erode_objFunction · 0.85
xnameFunction · 0.85

Tested by

no test coverage detected