Returns an object representing food. * Object may be either on floor or in inventory. */
| 3576 | * Object may be either on floor or in inventory. |
| 3577 | */ |
| 3578 | struct obj * |
| 3579 | floorfood( |
| 3580 | const char *verb, |
| 3581 | int corpsecheck) /* 0, no check, 1, corpses, 2, tinnable corpses */ |
| 3582 | { |
| 3583 | struct obj *otmp; |
| 3584 | char qbuf[QBUFSZ]; |
| 3585 | char c; |
| 3586 | struct permonst *uptr = gy.youmonst.data; |
| 3587 | boolean feeding = !strcmp(verb, "eat"), /* corpsecheck==0 */ |
| 3588 | offering = !strcmp(verb, "sacrifice"); /* corpsecheck==1 */ |
| 3589 | |
| 3590 | getobj_else = 0; /* haven't asked about floor food; is used to vary |
| 3591 | * "you don't have anything [else] to eat" when |
| 3592 | * floor food has been declined and inventory lacks |
| 3593 | * any suitable items */ |
| 3594 | /* if we can't touch floor objects then use invent food only; |
| 3595 | same when 'm' prefix is used--for #eat, it means "skip floor food" */ |
| 3596 | if (iflags.menu_requested |
| 3597 | || !can_reach_floor(TRUE) || (feeding && u.usteed) |
| 3598 | || (is_pool_or_lava(u.ux, u.uy) |
| 3599 | && (Wwalking || is_clinger(uptr) || (Flying && !Breathless)))) |
| 3600 | goto skipfloor; |
| 3601 | |
| 3602 | if (feeding && metallivorous(uptr)) { |
| 3603 | struct obj *gold; |
| 3604 | struct trap *ttmp = t_at(u.ux, u.uy); |
| 3605 | |
| 3606 | if (ttmp && ttmp->tseen && ttmp->ttyp == BEAR_TRAP) { |
| 3607 | boolean u_in_beartrap = (u.utrap && u.utraptype == TT_BEARTRAP); |
| 3608 | |
| 3609 | /* If not already stuck in the trap, perhaps there should |
| 3610 | be a chance to becoming trapped? Probably not, because |
| 3611 | then the trap would just get eaten on the _next_ turn... */ |
| 3612 | Sprintf(qbuf, "There is a bear trap here (%s); eat it?", |
| 3613 | u_in_beartrap ? "holding you" : "armed"); |
| 3614 | if ((c = yn_function(qbuf, ynqchars, 'n', TRUE)) == 'y') { |
| 3615 | struct obj *beartrap; |
| 3616 | |
| 3617 | deltrap(ttmp); |
| 3618 | if (u_in_beartrap) |
| 3619 | reset_utrap(TRUE); |
| 3620 | beartrap = mksobj(BEARTRAP, TRUE, FALSE); |
| 3621 | Sprintf(qbuf,"You only manage to %s the bear trap.", |
| 3622 | u_in_beartrap ? "free yourself from" : "disarm"); |
| 3623 | if (check_capacity(qbuf) && beartrap) { |
| 3624 | obj_extract_self(beartrap); |
| 3625 | dropy(beartrap); /* put it on the floor */ |
| 3626 | return (struct obj *) 0; |
| 3627 | } |
| 3628 | return beartrap; |
| 3629 | } else if (c == 'q') { |
| 3630 | return (struct obj *) 0; |
| 3631 | } |
| 3632 | ++getobj_else; |
| 3633 | } |
| 3634 | if (levl[u.ux][u.uy].typ == IRONBARS) { |
| 3635 | /* already verified that hero is metallivorous above */ |
no test coverage detected