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

Function ini_inv_adjust_obj

src/u_init.c:1207–1250  ·  view source on GitHub ↗

returns: TRUE to stop generating items from this trobj, FALSE for normal behaviour */

Source from the content-addressed store, hash-verified

1205/* returns: TRUE to stop generating items from this trobj,
1206 FALSE for normal behaviour */
1207staticfn boolean
1208ini_inv_adjust_obj(const struct trobj *trop, struct obj *obj)
1209{
1210 boolean stop = FALSE;
1211 if (trop->trclass == COIN_CLASS) {
1212 /* no "blessed" or "identified" money */
1213 obj->quan = u.umoney0;
1214 } else {
1215 if (objects[obj->otyp].oc_uses_known)
1216 obj->known = 1;
1217 /* not observe_object during startup, that's handled later */
1218 obj->dknown = obj->bknown = obj->rknown = 1;
1219 if (Is_container(obj) || obj->otyp == STATUE) {
1220 obj->cknown = obj->lknown = 1;
1221 obj->otrapped = 0;
1222 }
1223 obj->cursed = 0;
1224 if (obj->opoisoned && u.ualign.type != A_CHAOTIC)
1225 obj->opoisoned = 0;
1226 if (obj->oclass == WEAPON_CLASS || obj->oclass == TOOL_CLASS) {
1227 obj->quan = trquan(trop);
1228 stop = TRUE;
1229 } else if (obj->oclass == GEM_CLASS && is_graystone(obj)
1230 && obj->otyp != FLINT) {
1231 obj->quan = 1L;
1232 }
1233 if (trop->trspe != UNDEF_SPE) {
1234 obj->spe = trop->trspe;
1235 if (trop->trotyp == MAGIC_MARKER && obj->spe < 96)
1236 obj->spe += rn2(4);
1237 } else {
1238 /* Don't start with +0 or negative rings */
1239 if (objects[obj->otyp].oc_class == RING_CLASS
1240 && objects[obj->otyp].oc_charged && obj->spe <= 0)
1241 obj->spe = rne(3);
1242 }
1243 if (trop->trbless != UNDEF_BLESS)
1244 obj->blessed = trop->trbless;
1245
1246 }
1247 /* defined after setting otyp+quan + blessedness */
1248 obj->owt = weight(obj);
1249 return stop;
1250}
1251
1252/* initial inventory: wear, wield, learn the spell/obj */
1253staticfn void

Callers 1

ini_invFunction · 0.85

Calls 4

trquanFunction · 0.85
rn2Function · 0.85
rneFunction · 0.85
weightFunction · 0.85

Tested by

no test coverage detected