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_*) */
| 168 | * Returns an erosion return value (ER_*) |
| 169 | */ |
| 170 | int |
| 171 | erode_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; |
no test coverage detected