void nh_timeout() { register struct prop *upp; int sleeptime; int m_idx; int baseluck = (flags.moonphase == FULL_MOON) ? 1 : 0; if (flags.friday13) baseluck -= 1; if (u.uluck != baseluck && moves % (u.uhave.amulet || u.ugangr ? 300 : 600) == 0) { /* Cursed luckstones stop bad luck from timing out; blessed luckstones * stop good luck from timing out; normal luckstones stop both; * neither is stopped if you don't have a luckstone. * Luck is based at 0 usually, +1 if a full moon and -1 on Friday 13th */ register int time_luck = stone_luck(FALSE); boolean nostone = !carrying(LUCKSTONE) && !stone_luck(TRUE); if(u.uluck > baseluck && (nostone || time_luck < 0)) u.uluck--; else if(u.uluck < baseluck && (nostone || time_luck > 0)) u.uluck++; } if(u.uinvulnerable) return; /* things past this point could kill you */ if(Stoned) stoned_dialogue(); if(Slimed) slime_dialogue(); if(Vomiting) vomiting_dialogue(); if(Strangled) choke_dialogue(); if(u.mtimedone && !--u.mtimedone) { if (Unchanging) u.mtimedone = rnd(100*youmonst.data->mlevel + 1); else rehumanize(); } if(u.ucreamed) u.ucreamed--; /* Dissipate spell-based protection. */ if (u.usptime) { if (--u.usptime == 0 && u.uspellprot) { u.usptime = u.uspmtime; u.uspellprot--; find_ac(); if (!Blind) Norep("The %s haze around you %s.", hcolor(NH_GOLDEN), u.uspellprot ? "becomes less dense" : "disappears"); } } #ifdef STEED if (u.ugallop) { if (--u.ugallop == 0L && u.usteed) pline("%s stops galloping.", Monnam(u.usteed)); } #endif for(upp = u.uprops; upp < u.uprops+SIZE(u.uprops); upp++) if((upp->intrinsic & TIMEOUT) && !(--upp->intrinsic & TIMEOUT)) { switch(upp - u.uprops){ case STONED: if (delayed_killer && !killer) { killer = delayed_killer; delayed_killer = 0; } if (!killer) { /* leaving killer_format would make it "petrified by petrification" */ killer_format = NO_KILLER_PREFIX; killer = "killed by petrification"; } done(STONING); break; case SLIMED: if (delayed_killer && !killer) { killer = delayed_killer; delayed_killer = 0; } if (!killer) { killer_format = NO_KILLER_PREFIX; killer = "turned into green slime"; } done(TURNED_SLIME); break; case VOMITING: make_vomiting(0L, TRUE); break; case SICK: You("die from your illness."); killer_format = KILLED_BY_AN; killer = u.usick_cause; if ((m_idx = name_to_mon(killer)) >= LOW_PM) { if (type_is_pname(&mons[m_idx])) { killer_format = KILLED_BY; } else if (mons[m_idx].geno & G_UNIQ) { killer = the(killer); Strcpy(u.usick_cause, killer); killer_format = KILLED_BY; } } u.usick_type = 0; done(POISONING); break; case FAST: if (!Very_fast) You_feel("yourself slowing down%s.", Fast ? " a bit" : ""); break; case CONFUSION: HConfusion = 1; /* So make_confused works properly */ make_confused(0L, TRUE); stop_occupation(); break; case STUNNED: HStun = 1; make_stunned(0L, TRUE); stop_occupation(); break; case BLINDED: Blinded = 1; make_blinded(0L, TRUE); stop_occupation(); break; case INVIS: newsym(u.ux,u.uy); if (!Invis && !BInvis && !Blind) { You(!See_invisible ? "are no longer invisible." : "can no longer see through yourself."); stop_occupation(); } break; case SEE_INVIS: set_mimic_blocking(); /* do special mimic handling */ see_monsters(); /* make invis mons appear */ newsym(u.ux,u.uy); /* make self appear */ stop_occupation(); break; case WOUNDED_LEGS: heal_legs(); stop_occupation(); break; case HALLUC: HHallucination = 1; (void) make_hallucinated(0L, TRUE, 0L); stop_occupation(); break; case SLEEPING: if (unconscious() || Sleep_resistance) HSleeping += rnd(100); else if (Sleeping) { You("fall asleep."); sleeptime = rnd(20); fall_asleep(-sleeptime, TRUE); HSleeping += sleeptime + rnd(100); } break; case LEVITATION: (void) float_down(I_SPECIAL|TIMEOUT, 0L); break; case STRANGLED: killer_format = KILLED_BY; killer = (u.uburied) ? "suffocation" : "strangulation"; done(DIED); break; case FUMBLING: /* call this only when a move took place. */ /* otherwise handle fumbling msgs locally. */ if (u.umoved && !Levitation) { slip_or_trip(); nomul(-2, "fumbling"); nomovemsg = ""; /* The more you are carrying the more likely you * are to make noise when you fumble. Adjustments * to this number must be thoroughly play tested. */ if ((inv_weight() > -500)) { You("make a lot of noise!"); wake_nearby(); } } /* from outside means slippery ice; don't reset counter if that's the only fumble reason */ HFumbling &= ~FROMOUTSIDE; if (Fumbling) HFumbling += rnd(20); break; case DETECT_MONSTERS: see_monsters(); break; case PREGNANT: { char buf[BUFSZ]; if (!flags.female) { strcpy(buf, body_part(STOMACH)); if (!strcmp(buf, "stomach")) strcpy(buf, "belly"); pline("Something bursts out of your %s!"); killer_format = KILLED_BY; killer = "male childbirth"; done(DIED); } mksobj_at(PLACENTA, u.ux, u.uy, FALSE, FALSE); pline("BABIES!"); /* TODO */ stop_occupation(); break; } } } run_timers(); }
/* * a potential artifact has just been worn/wielded/picked-up or * unworn/unwielded/dropped. Pickup/drop only set/reset the W_ART mask. */ void set_artifact_intrinsic(struct obj *otmp, boolean on, long wp_mask) { unsigned int *mask = 0; const struct artifact *oart = get_artifact(otmp); uchar dtyp; long spfx; if (!oart) return; /* effects from the defn field */ dtyp = (wp_mask != W_ART) ? oart->defn.adtyp : oart->cary.adtyp; if (dtyp == AD_FIRE) mask = &EFire_resistance; else if (dtyp == AD_COLD) mask = &ECold_resistance; else if (dtyp == AD_ELEC) mask = &EShock_resistance; else if (dtyp == AD_MAGM) mask = &EAntimagic; else if (dtyp == AD_DISN) mask = &EDisint_resistance; else if (dtyp == AD_DRST) mask = &EPoison_resistance; if (mask && wp_mask == W_ART && !on) { /* find out if some other artifact also confers this intrinsic */ /* if so, leave the mask alone */ struct obj* obj; for (obj = invent; obj; obj = obj->nobj) if (obj != otmp && obj->oartifact) { const struct artifact *art = get_artifact(obj); if (art->cary.adtyp == dtyp) { mask = NULL; break; } } } if (mask) { if (on) *mask |= wp_mask; else *mask &= ~wp_mask; } /* intrinsics from the spfx field; there could be more than one */ spfx = (wp_mask != W_ART) ? oart->spfx : oart->cspfx; if (spfx && wp_mask == W_ART && !on) { /* don't change any spfx also conferred by other artifacts */ struct obj* obj; for (obj = invent; obj; obj = obj->nobj) if (obj != otmp && obj->oartifact) { const struct artifact *art = get_artifact(obj); spfx &= ~art->cspfx; } } if (spfx & SPFX_SEARCH) { if (on) ESearching |= wp_mask; else ESearching &= ~wp_mask; } if (spfx & SPFX_HALRES) { /* make_hallucinated must (re)set the mask itself to get * the display right */ /* restoring needed because this is the only artifact intrinsic * that can print a message--need to guard against being printed * when restoring a game */ make_hallucinated((long)!on, restoring ? FALSE : TRUE, wp_mask); } if (spfx & SPFX_ESP) { if (on) ETelepat |= wp_mask; else ETelepat &= ~wp_mask; see_monsters(); } if (spfx & SPFX_STLTH) { if (on) EStealth |= wp_mask; else EStealth &= ~wp_mask; } if (spfx & SPFX_REGEN) { if (on) ERegeneration |= wp_mask; else ERegeneration &= ~wp_mask; } if (spfx & SPFX_TCTRL) { if (on) ETeleport_control |= wp_mask; else ETeleport_control &= ~wp_mask; } if (spfx & SPFX_WARN) { if (spec_m2(otmp)) { if (on) { EWarn_of_mon |= wp_mask; flags.warntype |= spec_m2(otmp); } else { EWarn_of_mon &= ~wp_mask; flags.warntype &= ~spec_m2(otmp); } see_monsters(); } else { if (on) EWarning |= wp_mask; else EWarning &= ~wp_mask; } } if (spfx & SPFX_EREGEN) { if (on) EEnergy_regeneration |= wp_mask; else EEnergy_regeneration &= ~wp_mask; } if (spfx & SPFX_HSPDAM) { if (on) EHalf_spell_damage |= wp_mask; else EHalf_spell_damage &= ~wp_mask; } if (spfx & SPFX_HPHDAM) { if (on) EHalf_physical_damage |= wp_mask; else EHalf_physical_damage &= ~wp_mask; } if (spfx & SPFX_XRAY) { /* this assumes that no one else is using xray_range */ if (on) u.xray_range = 3; else u.xray_range = -1; vision_full_recalc = 1; } if ((spfx & SPFX_REFLECT) && (wp_mask & W_WEP)) { if (on) EReflecting |= wp_mask; else EReflecting &= ~wp_mask; } if (wp_mask == W_ART && !on && oart->inv_prop) { /* might have to turn off invoked power too */ if (oart->inv_prop <= LAST_PROP && (u.uprops[oart->inv_prop].extrinsic & W_ARTI)) arti_invoke(otmp); } }