handle item dipped into water potion or steed saddle splashed by same */
| 1495 | |
| 1496 | /* handle item dipped into water potion or steed saddle splashed by same */ |
| 1497 | staticfn boolean |
| 1498 | H2Opotion_dip( |
| 1499 | struct obj *potion, /* water */ |
| 1500 | struct obj *targobj, /* item being dipped into the water */ |
| 1501 | boolean useeit, /* will hero see the glow/aura? */ |
| 1502 | const char *objphrase) /* "Your widget glows" or "Steed's saddle glows" */ |
| 1503 | { |
| 1504 | void (*func)(struct obj *) = (void (*)(struct obj *)) 0; |
| 1505 | const char *glowcolor = 0; |
| 1506 | #define COST_alter (-2) |
| 1507 | #define COST_none (-1) |
| 1508 | int costchange = COST_none; |
| 1509 | boolean altfmt = FALSE, res = FALSE; |
| 1510 | |
| 1511 | if (!potion || potion->otyp != POT_WATER) |
| 1512 | return FALSE; |
| 1513 | |
| 1514 | if (potion->blessed) { |
| 1515 | if (targobj->cursed) { |
| 1516 | func = uncurse; |
| 1517 | glowcolor = NH_AMBER; |
| 1518 | costchange = COST_UNCURS; |
| 1519 | } else if (!targobj->blessed) { |
| 1520 | func = bless; |
| 1521 | glowcolor = NH_LIGHT_BLUE; |
| 1522 | costchange = COST_alter; |
| 1523 | altfmt = TRUE; /* "with a <color> aura" */ |
| 1524 | } |
| 1525 | } else if (potion->cursed) { |
| 1526 | if (targobj->blessed) { |
| 1527 | func = unbless; |
| 1528 | glowcolor = "brown"; |
| 1529 | costchange = COST_UNBLSS; |
| 1530 | } else if (!targobj->cursed) { |
| 1531 | func = curse; |
| 1532 | glowcolor = NH_BLACK; |
| 1533 | costchange = COST_alter; |
| 1534 | altfmt = TRUE; |
| 1535 | } |
| 1536 | } else { |
| 1537 | /* dipping into uncursed water; carried() check skips steed saddle */ |
| 1538 | if (carried(targobj)) { |
| 1539 | gm.mentioned_water = FALSE; /* water_damage() might set this */ |
| 1540 | if (water_damage(targobj, 0, TRUE) != ER_NOTHING) |
| 1541 | res = TRUE; |
| 1542 | if (gm.mentioned_water) |
| 1543 | makeknown(POT_WATER); |
| 1544 | gm.mentioned_water = FALSE; |
| 1545 | } |
| 1546 | } |
| 1547 | if (func) { |
| 1548 | /* give feedback before altering the target object; |
| 1549 | this used to set obj->bknown even when not seeing |
| 1550 | the effect; now hero has to see the glow, and bknown |
| 1551 | is cleared instead of set if perception is distorted */ |
| 1552 | if (useeit) { |
| 1553 | glowcolor = hcolor(glowcolor); |
| 1554 | if (altfmt) |
no test coverage detected