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

Function gem_accept

src/dothrow.c:2308–2382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2306#undef special_obj_hits_leader
2307
2308staticfn int
2309gem_accept(struct monst *mon, struct obj *obj)
2310{
2311 static NEARDATA const char
2312 nogood[] = " is not interested in your junk.",
2313 acceptgift[] = " accepts your gift.",
2314 maybeluck[] = " hesitatingly",
2315 noluck[] = " graciously",
2316 addluck[] = " gratefully";
2317 char buf[BUFSZ];
2318 boolean is_buddy = sgn(mon->data->maligntyp) == sgn(u.ualign.type);
2319 boolean is_gem = objects[obj->otyp].oc_material == GEMSTONE;
2320 int ret = 0;
2321
2322 Strcpy(buf, Monnam(mon));
2323 mon->mpeaceful = 1;
2324 mon->mavenge = 0;
2325
2326 /* object properly identified */
2327 if (obj->dknown && objects[obj->otyp].oc_name_known) {
2328 if (is_gem) {
2329 if (is_buddy) {
2330 Strcat(buf, addluck);
2331 change_luck(5);
2332 } else {
2333 Strcat(buf, maybeluck);
2334 change_luck(rn2(7) - 3);
2335 }
2336 } else {
2337 Strcat(buf, nogood);
2338 goto nopick;
2339 }
2340
2341 /* making guesses */
2342 } else if (has_oname(obj) || objects[obj->otyp].oc_uname) {
2343 if (is_gem) {
2344 if (is_buddy) {
2345 Strcat(buf, addluck);
2346 change_luck(2);
2347 } else {
2348 Strcat(buf, maybeluck);
2349 change_luck(rn2(3) - 1);
2350 }
2351 } else {
2352 Strcat(buf, nogood);
2353 goto nopick;
2354 }
2355
2356 /* value completely unknown to @ */
2357 } else {
2358 if (is_gem) {
2359 if (is_buddy) {
2360 Strcat(buf, addluck);
2361 change_luck(1);
2362 } else {
2363 Strcat(buf, maybeluck);
2364 change_luck(rn2(3) - 1);
2365 }

Callers 1

thitmonstFunction · 0.85

Calls 8

sgnFunction · 0.85
MonnamFunction · 0.85
change_luckFunction · 0.85
rn2Function · 0.85
check_shop_objFunction · 0.85
mpickobjFunction · 0.85
tele_restrictFunction · 0.85
rlocFunction · 0.85

Tested by

no test coverage detected