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

Function mkobj_erosions

src/mkobj.c:195–222  ·  view source on GitHub ↗

random chance of applying erosions/grease to object */

Source from the content-addressed store, hash-verified

193
194/* random chance of applying erosions/grease to object */
195staticfn void
196mkobj_erosions(struct obj *otmp)
197{
198 if (may_generate_eroded(otmp)) {
199 /* A small fraction of non-artifact items will generate eroded or
200 * possibly erodeproof. An item that generates eroded will never be
201 * erodeproof, and vice versa. */
202 if (!rn2(100)) {
203 otmp->oerodeproof = 1;
204 } else {
205 if (!rn2(80) && (is_flammable(otmp) || is_rustprone(otmp)
206 || is_crackable(otmp))) {
207 do {
208 otmp->oeroded++;
209 } while (otmp->oeroded < 3 && !rn2(9));
210 }
211 if (!rn2(80) && (is_rottable(otmp) || is_corrodeable(otmp))) {
212 do {
213 otmp->oeroded2++;
214 } while (otmp->oeroded2 < 3 && !rn2(9));
215 }
216 }
217 /* and an extremely small fraction of the time, erodable items
218 * will generate greased */
219 if (!rn2(1000))
220 otmp->greased = 1;
221 }
222}
223
224/* make a random object of class 'let' at a specific location;
225 'let' might be random class; place_object() will validate <x,y> */

Callers 1

mksobj_initFunction · 0.85

Calls 4

may_generate_erodedFunction · 0.85
rn2Function · 0.85
is_flammableFunction · 0.85
is_rottableFunction · 0.85

Tested by

no test coverage detected