| 2488 | } |
| 2489 | |
| 2490 | void |
| 2491 | litroom( |
| 2492 | boolean on, /* True: make nearby area lit; False: cursed scroll */ |
| 2493 | struct obj *obj) /* scroll, spellbook (for spell), or wand of light */ |
| 2494 | { |
| 2495 | struct obj *otmp, *nextobj; |
| 2496 | boolean blessed_effect = (obj && obj->oclass == SCROLL_CLASS |
| 2497 | && obj->blessed); |
| 2498 | boolean no_op = (u.uswallow || Underwater || Is_waterlevel(&u.uz)); |
| 2499 | char is_lit = 0; /* value is irrelevant but assign something anyway; its |
| 2500 | * address is used as a 'not null' flag for set_lit() */ |
| 2501 | |
| 2502 | /* update object lights and produce message (provided you're not blind) */ |
| 2503 | if (!on) { |
| 2504 | int still_lit = 0; |
| 2505 | |
| 2506 | /* |
| 2507 | * The magic douses lamps,&c too and might curse artifact lights. |
| 2508 | * |
| 2509 | * FIXME? |
| 2510 | * Shouldn't this affect all lit objects in the area of effect |
| 2511 | * rather than just those carried by the hero? |
| 2512 | */ |
| 2513 | for (otmp = gi.invent; otmp; otmp = nextobj) { |
| 2514 | nextobj = otmp->nobj; |
| 2515 | if (otmp->lamplit) { |
| 2516 | if (!artifact_light(otmp)) |
| 2517 | (void) snuff_lit(otmp); |
| 2518 | else |
| 2519 | /* wielded Sunsword or worn gold dragon scales/mail; |
| 2520 | maybe lower its BUC state if not already cursed */ |
| 2521 | impact_arti_light(otmp, TRUE, (boolean) !Blind); |
| 2522 | |
| 2523 | if (otmp->lamplit) |
| 2524 | ++still_lit; |
| 2525 | } |
| 2526 | } |
| 2527 | /* scroll of light becomes discovered when not blind, so some |
| 2528 | message to justify that is needed */ |
| 2529 | if (!Blind) { |
| 2530 | /* for the still_lit case, we don't know at this point whether |
| 2531 | anything currently visibly lit is going to go dark; if this |
| 2532 | message came after the darkening, we could count visibly |
| 2533 | lit squares before and after to know; we do know that being |
| 2534 | swallowed won't be affected--the interior is still lit */ |
| 2535 | if (still_lit) |
| 2536 | pline_The("ambient light seems dimmer."); |
| 2537 | else if (u.uswallow) |
| 2538 | pline("It seems even darker in here than before."); |
| 2539 | else |
| 2540 | You("are surrounded by darkness!"); |
| 2541 | } |
| 2542 | } else { /* on */ |
| 2543 | if (blessed_effect) { |
| 2544 | /* might bless artifact lights; no effect on ordinary lights */ |
| 2545 | for (otmp = gi.invent; otmp; otmp = nextobj) { |
| 2546 | nextobj = otmp->nobj; |
| 2547 | if (otmp->lamplit && artifact_light(otmp)) |
no test coverage detected