MCPcopy Index your code
hub / github.com/NetHack/NetHack / erode_obj

Function erode_obj

src/trap.c:170–354  ·  view source on GitHub ↗

Generic erode-item function. * "ostr", if non-null, is an alternate string to print instead of the * object's name. * "type" is an ERODE_* value for the erosion type * "flags" is an or-ed list of EF_* flags * * Returns an erosion return value (ER_*) */

Source from the content-addressed store, hash-verified

168 * Returns an erosion return value (ER_*)
169 */
170int
171erode_obj(
172 struct obj *otmp,
173 const char *ostr,
174 int type,
175 int ef_flags)
176{
177 static NEARDATA const char
178 *const action[] = { "smoulder", "rust", "rot", "corrode", "crack" },
179 *const msg[] = { "burnt", "rusted", "rotten", "corroded", "cracked" },
180 *const bythe[] = { "heat", "oxidation", "decay", "corrosion",
181 "impact" }; /* this could use improvement... */
182 boolean vulnerable = FALSE, is_primary = TRUE,
183 check_grease = (ef_flags & EF_GREASE) ? TRUE : FALSE,
184 print = (ef_flags & EF_VERBOSE) ? TRUE : FALSE,
185 crackers = FALSE, /* True: different feedback if otmp destroyed */
186 uvictim, vismon, visobj;
187 int erosion, cost_type;
188 struct monst *victim;
189
190 if (!otmp)
191 return ER_NOTHING;
192
193 victim = carried(otmp) ? &gy.youmonst
194 : mcarried(otmp) ? otmp->ocarry
195 : (struct monst *) 0;
196 uvictim = (victim == &gy.youmonst);
197 vismon = victim && (victim != &gy.youmonst) && canseemon(victim);
198 /* Is gb.bhitpos correct here? Ugh. */
199 visobj = (!victim && cansee(gb.bhitpos.x, gb.bhitpos.y)
200 && (!is_pool(gb.bhitpos.x, gb.bhitpos.y)
201 || (next2u(gb.bhitpos.x,gb.bhitpos.y) && Underwater)));
202
203 switch (type) {
204 case ERODE_BURN:
205 if (uvictim && inventory_resistance_check(AD_FIRE))
206 return ER_NOTHING;
207 vulnerable = is_flammable(otmp);
208 check_grease = FALSE;
209 cost_type = COST_BURN;
210 break;
211 case ERODE_RUST:
212 vulnerable = is_rustprone(otmp);
213 cost_type = COST_RUST;
214 break;
215 case ERODE_ROT:
216 vulnerable = is_rottable(otmp);
217 check_grease = FALSE;
218 is_primary = FALSE;
219 cost_type = COST_ROT;
220 break;
221 case ERODE_CORRODE:
222 if (uvictim && inventory_resistance_check(AD_ACID))
223 return ER_NOTHING;
224 vulnerable = is_corrodeable(otmp);
225 is_primary = FALSE;
226 cost_type = COST_CORRODE;
227 break;

Callers 11

potion_dipFunction · 0.85
destroy_armFunction · 0.85
erode_armorFunction · 0.85
passiveFunction · 0.85
passive_objFunction · 0.85
rustmFunction · 0.85
breakobjFunction · 0.85
fire_damageFunction · 0.85
acid_damageFunction · 0.85
water_damageFunction · 0.85
cursed_bookFunction · 0.85

Calls 15

canseemonFunction · 0.85
is_poolFunction · 0.85
is_flammableFunction · 0.85
is_rottableFunction · 0.85
cxnameFunction · 0.85
grease_protectFunction · 0.85
erosion_mattersFunction · 0.85
s_suffixFunction · 0.85
MonnamFunction · 0.85
vtenseFunction · 0.85
rnlFunction · 0.85

Tested by

no test coverage detected