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

Function potion_dip

src/potion.c:2441–2792  ·  view source on GitHub ↗

called by dodip() or dip_into() after obj and potion have been chosen */

Source from the content-addressed store, hash-verified

2439
2440/* called by dodip() or dip_into() after obj and potion have been chosen */
2441staticfn int
2442potion_dip(struct obj *obj, struct obj *potion)
2443{
2444 struct obj *singlepotion;
2445 char qbuf[QBUFSZ];
2446 short mixture;
2447
2448 if (potion == obj && potion->quan == 1L) {
2449 pline("That is a potion bottle, not a Klein bottle!");
2450 return ECMD_OK;
2451 }
2452 if (obj == &hands_obj) {
2453 You("can't fit your %s into the mouth of the bottle!",
2454 body_part(HAND));
2455 return ECMD_OK;
2456 }
2457
2458 obj->pickup_prev = 0; /* no longer 'recently picked up' */
2459 potion->in_use = TRUE; /* assume it will be used up */
2460 if (potion->otyp == POT_WATER) {
2461 boolean useeit = !Blind || (obj == ublindf && Blindfolded_only);
2462 const char *obj_glows = Yobjnam2(obj, "glow");
2463
2464 if (H2Opotion_dip(potion, obj, useeit, obj_glows)) {
2465 poof(potion);
2466 return ECMD_TIME;
2467 }
2468 } else if (obj->otyp == POT_POLYMORPH || potion->otyp == POT_POLYMORPH) {
2469 /* some objects can't be polymorphed */
2470 if (obj_unpolyable(obj->otyp == POT_POLYMORPH ? potion : obj)) {
2471 pline1(nothing_happens);
2472 } else {
2473 short save_otyp = obj->otyp;
2474
2475 /* KMH, conduct */
2476 if (!u.uconduct.polypiles++)
2477 livelog_printf(LL_CONDUCT, "polymorphed %s first item",
2478 uhis());
2479
2480 obj = poly_obj(obj, STRANGE_OBJECT);
2481
2482 /*
2483 * obj might be gone:
2484 * poly_obj() -> set_wear() -> Amulet_on() -> useup()
2485 * if obj->otyp is worn amulet and becomes AMULET_OF_CHANGE.
2486 */
2487 if (!obj) {
2488 makeknown(POT_POLYMORPH);
2489 return ECMD_TIME;
2490 } else if (obj->otyp != save_otyp) {
2491 makeknown(POT_POLYMORPH);
2492 useup(potion);
2493 prinv((char *) 0, obj, 0L);
2494 return ECMD_TIME;
2495 } else {
2496 pline1(nothing_seems_to_happen);
2497 poof(potion);
2498 return ECMD_TIME;

Callers 2

dodipFunction · 0.85
dip_intoFunction · 0.85

Calls 15

YouFunction · 0.85
body_partFunction · 0.85
Yobjnam2Function · 0.85
H2Opotion_dipFunction · 0.85
poofFunction · 0.85
obj_unpolyableFunction · 0.85
livelog_printfFunction · 0.85
poly_objFunction · 0.85
useupFunction · 0.85
prinvFunction · 0.85
mixtypeFunction · 0.85
rndFunction · 0.85

Tested by

no test coverage detected