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

Function rnd_otyp_by_wpnskill

src/objnam.c:3431–3452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3429};
3430
3431staticfn short
3432rnd_otyp_by_wpnskill(schar skill)
3433{
3434 int i, n = 0;
3435 short otyp = STRANGE_OBJECT;
3436
3437 for (i = svb.bases[WEAPON_CLASS];
3438 i < NUM_OBJECTS && objects[i].oc_class == WEAPON_CLASS; i++)
3439 if (objects[i].oc_skill == skill) {
3440 n++;
3441 otyp = i;
3442 }
3443 if (n > 0) {
3444 n = rn2(n);
3445 for (i = svb.bases[WEAPON_CLASS];
3446 i < NUM_OBJECTS && objects[i].oc_class == WEAPON_CLASS; i++)
3447 if (objects[i].oc_skill == skill)
3448 if (--n < 0)
3449 return i;
3450 }
3451 return otyp;
3452}
3453
3454staticfn short
3455rnd_otyp_by_namedesc(

Callers 1

readobjnamFunction · 0.85

Calls 1

rn2Function · 0.85

Tested by

no test coverage detected